@ledgerhq/device-management-kit 0.0.0-rn-hid-improvements-explorations-20250523153215 → 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 (278) hide show
  1. package/lib/cjs/src/api/DeviceManagementKit.js +1 -1
  2. package/lib/cjs/src/api/DeviceManagementKit.js.map +2 -2
  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/DeviceAction.js +1 -1
  14. package/lib/cjs/src/api/device-action/DeviceAction.js.map +1 -1
  15. package/lib/cjs/src/api/device-action/__test-utils__/makeInternalApi.js +1 -1
  16. package/lib/cjs/src/api/device-action/__test-utils__/makeInternalApi.js.map +2 -2
  17. package/lib/cjs/src/api/device-action/model/UserInteractionRequired.js +1 -1
  18. package/lib/cjs/src/api/device-action/model/UserInteractionRequired.js.map +2 -2
  19. package/lib/cjs/src/api/device-action/os/CallTaskInAppDeviceAction/CallTaskInAppDeviceAction.js +1 -1
  20. package/lib/cjs/src/api/device-action/os/CallTaskInAppDeviceAction/CallTaskInAppDeviceAction.js.map +2 -2
  21. package/lib/cjs/src/api/device-action/os/CallTaskInAppDeviceAction/CallTaskInAppDeviceActionTypes.js.map +1 -1
  22. package/lib/cjs/src/api/device-action/os/Errors.js +1 -1
  23. package/lib/cjs/src/api/device-action/os/Errors.js.map +3 -3
  24. package/lib/cjs/src/api/device-action/os/GetDeviceMetadata/GetDeviceMetadataDeviceAction.js +1 -1
  25. package/lib/cjs/src/api/device-action/os/GetDeviceMetadata/GetDeviceMetadataDeviceAction.js.map +2 -2
  26. package/lib/cjs/src/api/device-action/os/GetDeviceMetadata/types.js.map +1 -1
  27. package/lib/cjs/src/api/device-action/os/GetDeviceStatus/GetDeviceStatusDeviceAction.js +1 -1
  28. package/lib/cjs/src/api/device-action/os/GetDeviceStatus/GetDeviceStatusDeviceAction.js.map +2 -2
  29. package/lib/cjs/src/api/device-action/os/GetDeviceStatus/GetDeviceStatusDeviceAction.test.js +1 -1
  30. package/lib/cjs/src/api/device-action/os/GetDeviceStatus/GetDeviceStatusDeviceAction.test.js.map +2 -2
  31. package/lib/cjs/src/api/device-action/os/GoToDashboard/GoToDashboardDeviceAction.js +1 -1
  32. package/lib/cjs/src/api/device-action/os/GoToDashboard/GoToDashboardDeviceAction.js.map +3 -3
  33. package/lib/cjs/src/api/device-action/os/InstallOrUpdateApps/InstallOrUpdateAppsDeviceAction.js +1 -1
  34. package/lib/cjs/src/api/device-action/os/InstallOrUpdateApps/InstallOrUpdateAppsDeviceAction.js.map +2 -2
  35. package/lib/cjs/src/api/device-action/os/InstallOrUpdateApps/types.js +1 -1
  36. package/lib/cjs/src/api/device-action/os/InstallOrUpdateApps/types.js.map +1 -1
  37. package/lib/cjs/src/api/device-action/os/OpenAppDeviceAction/OpenAppDeviceAction.js +1 -1
  38. package/lib/cjs/src/api/device-action/os/OpenAppDeviceAction/OpenAppDeviceAction.js.map +3 -3
  39. package/lib/cjs/src/api/device-action/os/OpenAppDeviceAction/OpenAppDeviceAction.test.js +1 -1
  40. package/lib/cjs/src/api/device-action/os/OpenAppDeviceAction/OpenAppDeviceAction.test.js.map +2 -2
  41. package/lib/cjs/src/api/device-action/os/OpenAppDeviceAction/types.js +1 -1
  42. package/lib/cjs/src/api/device-action/os/OpenAppDeviceAction/types.js.map +1 -1
  43. package/lib/cjs/src/api/device-action/os/OpenAppWithDependencies/OpenAppWithDependenciesDeviceAction.js +1 -1
  44. package/lib/cjs/src/api/device-action/os/OpenAppWithDependencies/OpenAppWithDependenciesDeviceAction.js.map +2 -2
  45. package/lib/cjs/src/api/device-action/os/OpenAppWithDependencies/types.js.map +1 -1
  46. package/lib/cjs/src/api/device-action/os/SendCommandInAppDeviceAction/SendCommandInAppDeviceAction.js +1 -1
  47. package/lib/cjs/src/api/device-action/os/SendCommandInAppDeviceAction/SendCommandInAppDeviceAction.js.map +2 -2
  48. package/lib/cjs/src/api/device-action/os/SendCommandInAppDeviceAction/SendCommandInAppDeviceActionTypes.js +1 -1
  49. package/lib/cjs/src/api/device-action/os/SendCommandInAppDeviceAction/SendCommandInAppDeviceActionTypes.js.map +1 -1
  50. package/lib/cjs/src/api/device-action/task/BuildAppsInstallPlanTask.js +1 -1
  51. package/lib/cjs/src/api/device-action/task/BuildAppsInstallPlanTask.js.map +2 -2
  52. package/lib/cjs/src/api/device-action/task/BuildAppsInstallPlanTask.test.js +1 -1
  53. package/lib/cjs/src/api/device-action/task/BuildAppsInstallPlanTask.test.js.map +2 -2
  54. package/lib/cjs/src/api/index.js +1 -1
  55. package/lib/cjs/src/api/index.js.map +2 -2
  56. package/lib/cjs/src/api/secure-channel/device-action/GenuineCheck/GenuineCheckDeviceAction.js +1 -1
  57. package/lib/cjs/src/api/secure-channel/device-action/GenuineCheck/GenuineCheckDeviceAction.js.map +2 -2
  58. package/lib/cjs/src/api/secure-channel/device-action/GenuineCheck/types.js.map +1 -1
  59. package/lib/cjs/src/api/secure-channel/device-action/InstallApp/InstallAppDeviceAction.js +1 -1
  60. package/lib/cjs/src/api/secure-channel/device-action/InstallApp/InstallAppDeviceAction.js.map +2 -2
  61. package/lib/cjs/src/api/secure-channel/device-action/InstallApp/types.js +1 -1
  62. package/lib/cjs/src/api/secure-channel/device-action/InstallApp/types.js.map +1 -1
  63. package/lib/cjs/src/api/secure-channel/device-action/ListInstalledApps/ListInstalledAppsDeviceAction.js +1 -1
  64. package/lib/cjs/src/api/secure-channel/device-action/ListInstalledApps/ListInstalledAppsDeviceAction.js.map +2 -2
  65. package/lib/cjs/src/api/secure-channel/device-action/ListInstalledApps/types.js +1 -1
  66. package/lib/cjs/src/api/secure-channel/device-action/ListInstalledApps/types.js.map +2 -2
  67. package/lib/cjs/src/api/secure-channel/device-action/UninstallApp/UninstallAppDeviceAction.js +1 -1
  68. package/lib/cjs/src/api/secure-channel/device-action/UninstallApp/UninstallAppDeviceAction.js.map +2 -2
  69. package/lib/cjs/src/api/secure-channel/device-action/UninstallApp/types.js +1 -1
  70. package/lib/cjs/src/api/secure-channel/device-action/UninstallApp/types.js.map +1 -1
  71. package/lib/cjs/src/api/secure-channel/task/ConnectToSecureChannelTask.js +1 -1
  72. package/lib/cjs/src/api/secure-channel/task/ConnectToSecureChannelTask.js.map +3 -3
  73. package/lib/cjs/src/api/secure-channel/task/ConnectToSecureChannelTask.test.js +1 -1
  74. package/lib/cjs/src/api/secure-channel/task/ConnectToSecureChannelTask.test.js.map +3 -3
  75. package/lib/cjs/src/api/secure-channel/task/types.js +1 -1
  76. package/lib/cjs/src/api/secure-channel/task/types.js.map +2 -2
  77. package/lib/cjs/src/api/secure-channel/utils.js +1 -1
  78. package/lib/cjs/src/api/secure-channel/utils.js.map +3 -3
  79. package/lib/cjs/src/api/secure-channel/utils.test.js +1 -1
  80. package/lib/cjs/src/api/secure-channel/utils.test.js.map +3 -3
  81. package/lib/cjs/src/api/transport/model/DeviceConnection.js +1 -1
  82. package/lib/cjs/src/api/transport/model/DeviceConnection.js.map +1 -1
  83. package/lib/cjs/src/api/transport/model/DeviceConnectionStateMachine.js +1 -1
  84. package/lib/cjs/src/api/transport/model/DeviceConnectionStateMachine.js.map +3 -3
  85. package/lib/cjs/src/api/transport/model/DeviceConnectionStateMachine.test.js +2 -0
  86. package/lib/cjs/src/api/transport/model/DeviceConnectionStateMachine.test.js.map +7 -0
  87. package/lib/cjs/src/api/transport/model/Errors.js +1 -1
  88. package/lib/cjs/src/api/transport/model/Errors.js.map +3 -3
  89. package/lib/cjs/src/api/transport/model/TransportConnectedDevice.js +1 -1
  90. package/lib/cjs/src/api/transport/model/TransportConnectedDevice.js.map +3 -3
  91. package/lib/cjs/src/api/utils/AppName.js +2 -0
  92. package/lib/cjs/src/api/utils/AppName.js.map +7 -0
  93. package/lib/cjs/src/api/utils/AppName.test.js +2 -0
  94. package/lib/cjs/src/api/utils/AppName.test.js.map +7 -0
  95. package/lib/cjs/src/internal/device-session/model/DeviceSession.js +1 -1
  96. package/lib/cjs/src/internal/device-session/model/DeviceSession.js.map +3 -3
  97. package/lib/cjs/src/internal/secure-channel/model/Errors.js +1 -1
  98. package/lib/cjs/src/internal/secure-channel/model/Errors.js.map +3 -3
  99. package/lib/cjs/src/internal/send/di/sendModule.js +1 -1
  100. package/lib/cjs/src/internal/send/di/sendModule.js.map +3 -3
  101. package/lib/cjs/src/internal/send/di/sendTypes.js +1 -1
  102. package/lib/cjs/src/internal/send/di/sendTypes.js.map +2 -2
  103. package/lib/cjs/src/internal/send/use-case/SendApduUseCase.js +1 -1
  104. package/lib/cjs/src/internal/send/use-case/SendApduUseCase.js.map +3 -3
  105. package/lib/esm/src/api/DeviceManagementKit.js +1 -1
  106. package/lib/esm/src/api/DeviceManagementKit.js.map +2 -2
  107. package/lib/esm/src/api/apdu/utils/ByteArrayBuilder.js +1 -1
  108. package/lib/esm/src/api/apdu/utils/ByteArrayBuilder.js.map +3 -3
  109. package/lib/esm/src/api/apdu/utils/ByteArrayBuilder.test.js +1 -1
  110. package/lib/esm/src/api/apdu/utils/ByteArrayBuilder.test.js.map +2 -2
  111. package/lib/esm/src/api/command/utils/CommandUtils.js +1 -1
  112. package/lib/esm/src/api/command/utils/CommandUtils.js.map +3 -3
  113. package/lib/esm/src/api/command/utils/CommandUtils.test.js +1 -1
  114. package/lib/esm/src/api/command/utils/CommandUtils.test.js.map +2 -2
  115. package/lib/esm/src/api/command/utils/GlobalCommandError.js +1 -1
  116. package/lib/esm/src/api/command/utils/GlobalCommandError.js.map +2 -2
  117. package/lib/esm/src/api/device-action/__test-utils__/makeInternalApi.js +1 -1
  118. package/lib/esm/src/api/device-action/__test-utils__/makeInternalApi.js.map +2 -2
  119. package/lib/esm/src/api/device-action/model/UserInteractionRequired.js +1 -1
  120. package/lib/esm/src/api/device-action/model/UserInteractionRequired.js.map +2 -2
  121. package/lib/esm/src/api/device-action/os/CallTaskInAppDeviceAction/CallTaskInAppDeviceAction.js +1 -1
  122. package/lib/esm/src/api/device-action/os/CallTaskInAppDeviceAction/CallTaskInAppDeviceAction.js.map +2 -2
  123. package/lib/esm/src/api/device-action/os/Errors.js +1 -1
  124. package/lib/esm/src/api/device-action/os/Errors.js.map +3 -3
  125. package/lib/esm/src/api/device-action/os/GetDeviceMetadata/GetDeviceMetadataDeviceAction.js +1 -1
  126. package/lib/esm/src/api/device-action/os/GetDeviceMetadata/GetDeviceMetadataDeviceAction.js.map +2 -2
  127. package/lib/esm/src/api/device-action/os/GetDeviceStatus/GetDeviceStatusDeviceAction.js +1 -1
  128. package/lib/esm/src/api/device-action/os/GetDeviceStatus/GetDeviceStatusDeviceAction.js.map +2 -2
  129. package/lib/esm/src/api/device-action/os/GetDeviceStatus/GetDeviceStatusDeviceAction.test.js +1 -1
  130. package/lib/esm/src/api/device-action/os/GetDeviceStatus/GetDeviceStatusDeviceAction.test.js.map +2 -2
  131. package/lib/esm/src/api/device-action/os/GoToDashboard/GoToDashboardDeviceAction.js +1 -1
  132. package/lib/esm/src/api/device-action/os/GoToDashboard/GoToDashboardDeviceAction.js.map +3 -3
  133. package/lib/esm/src/api/device-action/os/InstallOrUpdateApps/InstallOrUpdateAppsDeviceAction.js +1 -1
  134. package/lib/esm/src/api/device-action/os/InstallOrUpdateApps/InstallOrUpdateAppsDeviceAction.js.map +2 -2
  135. package/lib/esm/src/api/device-action/os/OpenAppDeviceAction/OpenAppDeviceAction.js +1 -1
  136. package/lib/esm/src/api/device-action/os/OpenAppDeviceAction/OpenAppDeviceAction.js.map +3 -3
  137. package/lib/esm/src/api/device-action/os/OpenAppDeviceAction/OpenAppDeviceAction.test.js +1 -1
  138. package/lib/esm/src/api/device-action/os/OpenAppDeviceAction/OpenAppDeviceAction.test.js.map +3 -3
  139. package/lib/esm/src/api/device-action/os/OpenAppWithDependencies/OpenAppWithDependenciesDeviceAction.js +1 -1
  140. package/lib/esm/src/api/device-action/os/OpenAppWithDependencies/OpenAppWithDependenciesDeviceAction.js.map +2 -2
  141. package/lib/esm/src/api/device-action/os/SendCommandInAppDeviceAction/SendCommandInAppDeviceAction.js +1 -1
  142. package/lib/esm/src/api/device-action/os/SendCommandInAppDeviceAction/SendCommandInAppDeviceAction.js.map +2 -2
  143. package/lib/esm/src/api/device-action/task/BuildAppsInstallPlanTask.js +1 -1
  144. package/lib/esm/src/api/device-action/task/BuildAppsInstallPlanTask.js.map +3 -3
  145. package/lib/esm/src/api/device-action/task/BuildAppsInstallPlanTask.test.js +1 -1
  146. package/lib/esm/src/api/device-action/task/BuildAppsInstallPlanTask.test.js.map +3 -3
  147. package/lib/esm/src/api/index.js +1 -1
  148. package/lib/esm/src/api/index.js.map +3 -3
  149. package/lib/esm/src/api/secure-channel/device-action/GenuineCheck/GenuineCheckDeviceAction.js +1 -1
  150. package/lib/esm/src/api/secure-channel/device-action/GenuineCheck/GenuineCheckDeviceAction.js.map +2 -2
  151. package/lib/esm/src/api/secure-channel/device-action/InstallApp/InstallAppDeviceAction.js +1 -1
  152. package/lib/esm/src/api/secure-channel/device-action/InstallApp/InstallAppDeviceAction.js.map +2 -2
  153. package/lib/esm/src/api/secure-channel/device-action/ListInstalledApps/ListInstalledAppsDeviceAction.js +1 -1
  154. package/lib/esm/src/api/secure-channel/device-action/ListInstalledApps/ListInstalledAppsDeviceAction.js.map +2 -2
  155. package/lib/esm/src/api/secure-channel/device-action/ListInstalledApps/types.js +1 -1
  156. package/lib/esm/src/api/secure-channel/device-action/ListInstalledApps/types.js.map +2 -2
  157. package/lib/esm/src/api/secure-channel/device-action/UninstallApp/UninstallAppDeviceAction.js +1 -1
  158. package/lib/esm/src/api/secure-channel/device-action/UninstallApp/UninstallAppDeviceAction.js.map +2 -2
  159. package/lib/esm/src/api/secure-channel/task/ConnectToSecureChannelTask.js +1 -1
  160. package/lib/esm/src/api/secure-channel/task/ConnectToSecureChannelTask.js.map +3 -3
  161. package/lib/esm/src/api/secure-channel/task/ConnectToSecureChannelTask.test.js +1 -1
  162. package/lib/esm/src/api/secure-channel/task/ConnectToSecureChannelTask.test.js.map +3 -3
  163. package/lib/esm/src/api/secure-channel/task/types.js +1 -1
  164. package/lib/esm/src/api/secure-channel/task/types.js.map +2 -2
  165. package/lib/esm/src/api/secure-channel/utils.js +1 -1
  166. package/lib/esm/src/api/secure-channel/utils.js.map +3 -3
  167. package/lib/esm/src/api/secure-channel/utils.test.js +1 -1
  168. package/lib/esm/src/api/secure-channel/utils.test.js.map +3 -3
  169. package/lib/esm/src/api/transport/model/DeviceConnectionStateMachine.js +1 -1
  170. package/lib/esm/src/api/transport/model/DeviceConnectionStateMachine.js.map +3 -3
  171. package/lib/esm/src/api/transport/model/DeviceConnectionStateMachine.test.js +2 -0
  172. package/lib/esm/src/api/transport/model/DeviceConnectionStateMachine.test.js.map +7 -0
  173. package/lib/esm/src/api/transport/model/Errors.js +1 -1
  174. package/lib/esm/src/api/transport/model/Errors.js.map +3 -3
  175. package/lib/esm/src/api/transport/model/TransportConnectedDevice.js +1 -1
  176. package/lib/esm/src/api/transport/model/TransportConnectedDevice.js.map +3 -3
  177. package/lib/esm/src/api/utils/AppName.js +2 -0
  178. package/lib/esm/src/api/utils/AppName.js.map +7 -0
  179. package/lib/esm/src/api/utils/AppName.test.js +2 -0
  180. package/lib/esm/src/api/utils/AppName.test.js.map +7 -0
  181. package/lib/esm/src/internal/device-session/model/DeviceSession.js +1 -1
  182. package/lib/esm/src/internal/device-session/model/DeviceSession.js.map +3 -3
  183. package/lib/esm/src/internal/secure-channel/model/Errors.js +1 -1
  184. package/lib/esm/src/internal/secure-channel/model/Errors.js.map +3 -3
  185. package/lib/esm/src/internal/send/di/sendModule.js +1 -1
  186. package/lib/esm/src/internal/send/di/sendModule.js.map +3 -3
  187. package/lib/esm/src/internal/send/di/sendTypes.js +1 -1
  188. package/lib/esm/src/internal/send/di/sendTypes.js.map +2 -2
  189. package/lib/esm/src/internal/send/use-case/SendApduUseCase.js +1 -1
  190. package/lib/esm/src/internal/send/use-case/SendApduUseCase.js.map +3 -3
  191. package/lib/types/src/api/DeviceManagementKit.d.ts +0 -13
  192. package/lib/types/src/api/DeviceManagementKit.d.ts.map +1 -1
  193. package/lib/types/src/api/apdu/utils/ByteArrayBuilder.d.ts +28 -0
  194. package/lib/types/src/api/apdu/utils/ByteArrayBuilder.d.ts.map +1 -1
  195. package/lib/types/src/api/command/utils/CommandUtils.d.ts +3 -0
  196. package/lib/types/src/api/command/utils/CommandUtils.d.ts.map +1 -1
  197. package/lib/types/src/api/command/utils/GlobalCommandError.d.ts +1 -1
  198. package/lib/types/src/api/command/utils/GlobalCommandError.d.ts.map +1 -1
  199. package/lib/types/src/api/device-action/DeviceAction.d.ts +0 -5
  200. package/lib/types/src/api/device-action/DeviceAction.d.ts.map +1 -1
  201. package/lib/types/src/api/device-action/__test-utils__/makeInternalApi.d.ts.map +1 -1
  202. package/lib/types/src/api/device-action/model/UserInteractionRequired.d.ts +1 -0
  203. package/lib/types/src/api/device-action/model/UserInteractionRequired.d.ts.map +1 -1
  204. package/lib/types/src/api/device-action/os/CallTaskInAppDeviceAction/CallTaskInAppDeviceAction.d.ts.map +1 -1
  205. package/lib/types/src/api/device-action/os/CallTaskInAppDeviceAction/CallTaskInAppDeviceActionTypes.d.ts +0 -1
  206. package/lib/types/src/api/device-action/os/CallTaskInAppDeviceAction/CallTaskInAppDeviceActionTypes.d.ts.map +1 -1
  207. package/lib/types/src/api/device-action/os/Errors.d.ts +10 -0
  208. package/lib/types/src/api/device-action/os/Errors.d.ts.map +1 -1
  209. package/lib/types/src/api/device-action/os/GetDeviceMetadata/GetDeviceMetadataDeviceAction.d.ts.map +1 -1
  210. package/lib/types/src/api/device-action/os/GetDeviceMetadata/types.d.ts +2 -1
  211. package/lib/types/src/api/device-action/os/GetDeviceMetadata/types.d.ts.map +1 -1
  212. package/lib/types/src/api/device-action/os/GetDeviceStatus/GetDeviceStatusDeviceAction.d.ts.map +1 -1
  213. package/lib/types/src/api/device-action/os/GoToDashboard/GoToDashboardDeviceAction.d.ts.map +1 -1
  214. package/lib/types/src/api/device-action/os/InstallOrUpdateApps/InstallOrUpdateAppsDeviceAction.d.ts.map +1 -1
  215. package/lib/types/src/api/device-action/os/InstallOrUpdateApps/types.d.ts +3 -2
  216. package/lib/types/src/api/device-action/os/InstallOrUpdateApps/types.d.ts.map +1 -1
  217. package/lib/types/src/api/device-action/os/OpenAppDeviceAction/OpenAppDeviceAction.d.ts.map +1 -1
  218. package/lib/types/src/api/device-action/os/OpenAppDeviceAction/types.d.ts +0 -1
  219. package/lib/types/src/api/device-action/os/OpenAppDeviceAction/types.d.ts.map +1 -1
  220. package/lib/types/src/api/device-action/os/OpenAppWithDependencies/OpenAppWithDependenciesDeviceAction.d.ts.map +1 -1
  221. package/lib/types/src/api/device-action/os/OpenAppWithDependencies/types.d.ts +0 -1
  222. package/lib/types/src/api/device-action/os/OpenAppWithDependencies/types.d.ts.map +1 -1
  223. package/lib/types/src/api/device-action/os/SendCommandInAppDeviceAction/SendCommandInAppDeviceAction.d.ts.map +1 -1
  224. package/lib/types/src/api/device-action/os/SendCommandInAppDeviceAction/SendCommandInAppDeviceActionTypes.d.ts +0 -1
  225. package/lib/types/src/api/device-action/os/SendCommandInAppDeviceAction/SendCommandInAppDeviceActionTypes.d.ts.map +1 -1
  226. package/lib/types/src/api/device-action/task/BuildAppsInstallPlanTask.d.ts +2 -2
  227. package/lib/types/src/api/device-action/task/BuildAppsInstallPlanTask.d.ts.map +1 -1
  228. package/lib/types/src/api/index.d.ts +1 -1
  229. package/lib/types/src/api/index.d.ts.map +1 -1
  230. package/lib/types/src/api/secure-channel/device-action/GenuineCheck/GenuineCheckDeviceAction.d.ts.map +1 -1
  231. package/lib/types/src/api/secure-channel/device-action/GenuineCheck/types.d.ts +2 -1
  232. package/lib/types/src/api/secure-channel/device-action/GenuineCheck/types.d.ts.map +1 -1
  233. package/lib/types/src/api/secure-channel/device-action/InstallApp/InstallAppDeviceAction.d.ts.map +1 -1
  234. package/lib/types/src/api/secure-channel/device-action/InstallApp/types.d.ts +2 -1
  235. package/lib/types/src/api/secure-channel/device-action/InstallApp/types.d.ts.map +1 -1
  236. package/lib/types/src/api/secure-channel/device-action/ListInstalledApps/ListInstalledAppsDeviceAction.d.ts.map +1 -1
  237. package/lib/types/src/api/secure-channel/device-action/ListInstalledApps/types.d.ts +2 -1
  238. package/lib/types/src/api/secure-channel/device-action/ListInstalledApps/types.d.ts.map +1 -1
  239. package/lib/types/src/api/secure-channel/device-action/UninstallApp/UninstallAppDeviceAction.d.ts.map +1 -1
  240. package/lib/types/src/api/secure-channel/device-action/UninstallApp/types.d.ts +2 -1
  241. package/lib/types/src/api/secure-channel/device-action/UninstallApp/types.d.ts.map +1 -1
  242. package/lib/types/src/api/secure-channel/task/ConnectToSecureChannelTask.d.ts +5 -2
  243. package/lib/types/src/api/secure-channel/task/ConnectToSecureChannelTask.d.ts.map +1 -1
  244. package/lib/types/src/api/secure-channel/task/types.d.ts +6 -1
  245. package/lib/types/src/api/secure-channel/task/types.d.ts.map +1 -1
  246. package/lib/types/src/api/secure-channel/utils.d.ts +0 -11
  247. package/lib/types/src/api/secure-channel/utils.d.ts.map +1 -1
  248. package/lib/types/src/api/transport/model/DeviceConnection.d.ts +0 -6
  249. package/lib/types/src/api/transport/model/DeviceConnection.d.ts.map +1 -1
  250. package/lib/types/src/api/transport/model/DeviceConnectionStateMachine.d.ts +8 -7
  251. package/lib/types/src/api/transport/model/DeviceConnectionStateMachine.d.ts.map +1 -1
  252. package/lib/types/src/api/transport/model/DeviceConnectionStateMachine.test.d.ts +2 -0
  253. package/lib/types/src/api/transport/model/DeviceConnectionStateMachine.test.d.ts.map +1 -0
  254. package/lib/types/src/api/transport/model/Errors.d.ts +0 -5
  255. package/lib/types/src/api/transport/model/Errors.d.ts.map +1 -1
  256. package/lib/types/src/api/transport/model/TransportConnectedDevice.d.ts +2 -4
  257. package/lib/types/src/api/transport/model/TransportConnectedDevice.d.ts.map +1 -1
  258. package/lib/types/src/api/utils/AppName.d.ts +2 -0
  259. package/lib/types/src/api/utils/AppName.d.ts.map +1 -0
  260. package/lib/types/src/api/utils/AppName.test.d.ts +2 -0
  261. package/lib/types/src/api/utils/AppName.test.d.ts.map +1 -0
  262. package/lib/types/src/internal/device-session/model/DeviceSession.d.ts +0 -2
  263. package/lib/types/src/internal/device-session/model/DeviceSession.d.ts.map +1 -1
  264. package/lib/types/src/internal/secure-channel/model/Errors.d.ts +22 -2
  265. package/lib/types/src/internal/secure-channel/model/Errors.d.ts.map +1 -1
  266. package/lib/types/src/internal/send/di/sendModule.d.ts.map +1 -1
  267. package/lib/types/src/internal/send/di/sendTypes.d.ts +0 -1
  268. package/lib/types/src/internal/send/di/sendTypes.d.ts.map +1 -1
  269. package/lib/types/src/internal/send/use-case/SendApduUseCase.d.ts +5 -1
  270. package/lib/types/src/internal/send/use-case/SendApduUseCase.d.ts.map +1 -1
  271. package/lib/types/tsconfig.prod.tsbuildinfo +1 -1
  272. package/package.json +1 -1
  273. package/lib/cjs/src/internal/send/use-case/ExchangeBulkApdusUseCase.js +0 -2
  274. package/lib/cjs/src/internal/send/use-case/ExchangeBulkApdusUseCase.js.map +0 -7
  275. package/lib/esm/src/internal/send/use-case/ExchangeBulkApdusUseCase.js +0 -2
  276. package/lib/esm/src/internal/send/use-case/ExchangeBulkApdusUseCase.js.map +0 -7
  277. package/lib/types/src/internal/send/use-case/ExchangeBulkApdusUseCase.d.ts +0 -32
  278. package/lib/types/src/internal/send/use-case/ExchangeBulkApdusUseCase.d.ts.map +0 -1
@@ -1,2 +1,2 @@
1
- import{Left as I,Right as g}from"purify-ts";import{assign as a,fromObservable as h,fromPromise as d,setup as D}from"xstate";import{isSuccessCommandResult as v}from"../../../command/model/CommandResult";import{GetOsVersionCommand as f}from"../../../command/os/GetOsVersionCommand";import{UserInteractionRequired as x}from"../../../device-action/model/UserInteractionRequired";import{DEFAULT_UNLOCK_TIMEOUT_MS as y}from"../../../device-action/os/Const";import{UnknownDAError as A}from"../../../device-action/os/Errors";import{GoToDashboardDeviceAction as V}from"../../../device-action/os/GoToDashboard/GoToDashboardDeviceAction";import{XStateDeviceAction as E}from"../../../device-action/xstate-utils/XStateDeviceAction";import{DeviceSessionStateType as S}from"../../../device-session/DeviceSessionState";import{ListInstalledAppsDeviceAction as T}from"../../../secure-channel/device-action/ListInstalledApps/ListInstalledAppsDeviceAction";import{ConnectToSecureChannelTask as L}from"../../../secure-channel/task/ConnectToSecureChannelTask";import{SecureChannelEventType as O}from"../../../secure-channel/task/types";class X extends E{makeStateMachine(n){const{getOsVersion:l,getAppList:c,installApp:u,getDeviceSessionState:r,setDeviceSessionState:o}=this.extractDependencies(n),i=this.input.unlockTimeout??y,p=new T({input:{unlockTimeout:i}}).makeStateMachine(n),m=new V({input:{unlockTimeout:i}}).makeStateMachine(n);return D({types:{input:{},context:{},output:{}},actors:{listInstalledApps:p,goToDashboard:m,getOsVersion:d(l),getAppList:d(c),installApp:h(u)},guards:{hasError:t=>t.context._internalState.error!==null,appInstalled:t=>t.context._internalState.installedApps.some(e=>e.name===t.context.input.appName),appNotFound:t=>t.context._internalState.appList.findIndex(({versionName:e})=>e===t.context.input.appName)===-1,depAppNotInstalled:t=>{const e=t.context._internalState.appList.find(({versionName:s})=>s===t.context.input.appName);return e?.parentName?t.context._internalState.installedApps.findIndex(({name:s})=>s===e.parentName)===-1:!1}},actions:{assignErrorFromEvent:a({_internalState:t=>({...t.context._internalState,error:t.event.error})}),assignAppNotFound:a({_internalState:t=>({...t.context._internalState,error:new A("App to install not found in manager API")})}),assignDepAppNotInstalled:a({_internalState:t=>({...t.context._internalState,error:new A("Dep app is not installed on the device")})}),cleanupDeviceState:()=>{const t=r();t.sessionStateType!==S.Connected&&o({...t,installedApps:[],appsUpdates:void 0})}}}).createMachine({id:"InstallAppDeviceAction",initial:"DeviceReady",context:t=>({input:{unlockTimeout:t.input.unlockTimeout,appName:t.input.appName},intermediateValue:{requiredUserInteraction:x.None,progress:0},_internalState:{error:null,installedApps:[],getOsVersionResponse:null,appList:[]}}),states:{DeviceReady:{always:{target:"ListInstalledApps"}},ListInstalledApps:{value:"ListInstalledApps",invoke:{id:"listInstalledApps",src:"listInstalledApps",input:t=>({unlockTimeout:t.context.input.unlockTimeout}),onSnapshot:{actions:a({intermediateValue:t=>({...t.context.intermediateValue,requiredUserInteraction:t.event.snapshot.context.intermediateValue.requiredUserInteraction})})},onDone:{target:"ListInstalledAppsCheck",actions:a({_internalState:t=>t.event.output.caseOf({Right:({installedApps:e})=>({...t.context._internalState,installedApps:e}),Left:e=>({...t.context._internalState,error:e})})})}}},ListInstalledAppsCheck:{always:[{target:"Error",guard:"hasError"},{target:"Success",guard:"appInstalled"},{target:"GoToDashboard"}]},GoToDashboard:{invoke:{id:"goToDashboard",src:"goToDashboard",input:t=>({unlockTimeout:t.context.input.unlockTimeout}),onSnapshot:{actions:a({intermediateValue:t=>({...t.context.intermediateValue,requiredUserInteraction:t.event.snapshot.context.intermediateValue.requiredUserInteraction})})},onDone:{target:"GoToDashboardCheck",actions:a({_internalState:t=>t.event.output.caseOf({Right:()=>t.context._internalState,Left:e=>({...t.context._internalState,error:e})})})},onError:{target:"Error",actions:"assignErrorFromEvent"}}},GoToDashboardCheck:{always:[{target:"Error",guard:"hasError"},{target:"GetOsVersion"}]},GetOsVersion:{invoke:{id:"getOsVersion",src:"getOsVersion",input:t=>{},onDone:{target:"GetOsVersionCheck",actions:a({_internalState:t=>{if(v(t.event.output)){const e=r(),s=t.event.output.data.secureElementFlags.isSecureConnectionAllowed;return e.sessionStateType!==S.Connected&&o({...e,isSecureConnectionAllowed:s}),{...t.context._internalState,getOsVersionResponse:t.event.output.data}}return{...t.context._internalState,error:t.event.output.error}}})}}},GetOsVersionCheck:{always:[{target:"Error",guard:"hasError"},{target:"GetAppList"}]},GetAppList:{invoke:{id:"getAppList",src:"getAppList",input:t=>({deviceInfo:t.context._internalState.getOsVersionResponse}),onDone:{target:"GetAppListCheck",actions:a({_internalState:t=>t.event.output.caseOf({Right:e=>({...t.context._internalState,appList:e}),Left:e=>({...t.context._internalState,error:e})})})}}},GetAppListCheck:{always:[{target:"Error",guard:"hasError"},{target:"Error",guard:"appNotFound",actions:"assignAppNotFound"},{target:"Error",guard:"depAppNotInstalled",actions:"assignDepAppNotInstalled"},{target:"InstallApp"}]},InstallApp:{invoke:{id:"installApp",src:"installApp",input:t=>({deviceInfo:t.context._internalState.getOsVersionResponse,app:t.context._internalState.appList.find(({versionName:e})=>e===t.context.input.appName)}),onSnapshot:{actions:a({intermediateValue:t=>t.event.snapshot.context?.type===O.Progress?{...t.context.intermediateValue,progress:t.event.snapshot.context.payload.progress}:{...t.context.intermediateValue}})},onDone:{target:"ListInstalledApps",actions:"cleanupDeviceState"},onError:{target:"Error",actions:"assignErrorFromEvent"}}},Success:{type:"final",description:"App installed successfully"},Error:{type:"final"}},output:({context:t})=>t._internalState.error?I(t._internalState.error):g(void 0)})}extractDependencies(n){return{getOsVersion:()=>n.sendCommand(new f),getAppList:({input:r})=>{const{deviceInfo:o}=r;return n.getManagerApiService().getAppList(o)},installApp:({input:r})=>{const{deviceInfo:o,app:i}=r,p=n.getSecureChannelService().installApp(o,i);return new L(n,{connection:p}).run()},getDeviceSessionState:()=>n.getDeviceSessionState(),setDeviceSessionState:r=>n.setDeviceSessionState(r)}}}export{X as InstallAppDeviceAction};
1
+ import{Left as g,Right as h}from"purify-ts";import{assign as a,fromObservable as D,fromPromise as d,setup as v}from"xstate";import{isSuccessCommandResult as f}from"../../../command/model/CommandResult";import{GetOsVersionCommand as x}from"../../../command/os/GetOsVersionCommand";import{UserInteractionRequired as y}from"../../../device-action/model/UserInteractionRequired";import{DEFAULT_UNLOCK_TIMEOUT_MS as E}from"../../../device-action/os/Const";import{UnknownDAError as A}from"../../../device-action/os/Errors";import{GoToDashboardDeviceAction as V}from"../../../device-action/os/GoToDashboard/GoToDashboardDeviceAction";import{XStateDeviceAction as T}from"../../../device-action/xstate-utils/XStateDeviceAction";import{DeviceSessionStateType as S}from"../../../device-session/DeviceSessionState";import{ListInstalledAppsDeviceAction as L}from"../../../secure-channel/device-action/ListInstalledApps/ListInstalledAppsDeviceAction";import{ConnectToSecureChannelTask as O}from"../../../secure-channel/task/ConnectToSecureChannelTask";import{SecureChannelEventType as m}from"../../../secure-channel/task/types";class X extends T{makeStateMachine(n){const{getOsVersion:l,getAppList:c,installApp:u,getDeviceSessionState:r,setDeviceSessionState:o}=this.extractDependencies(n),i=this.input.unlockTimeout??E,p=new L({input:{unlockTimeout:i}}).makeStateMachine(n),I=new V({input:{unlockTimeout:i}}).makeStateMachine(n);return v({types:{input:{},context:{},output:{}},actors:{listInstalledApps:p,goToDashboard:I,getOsVersion:d(l),getAppList:d(c),installApp:D(u)},guards:{hasError:t=>t.context._internalState.error!==null,appInstalled:t=>t.context._internalState.installedApps.some(e=>e.name===t.context.input.appName),appNotFound:t=>t.context._internalState.appList.findIndex(({versionName:e})=>e===t.context.input.appName)===-1,depAppNotInstalled:t=>{const e=t.context._internalState.appList.find(({versionName:s})=>s===t.context.input.appName);return e?.parentName?t.context._internalState.installedApps.findIndex(({name:s})=>s===e.parentName)===-1:!1}},actions:{assignErrorFromEvent:a({_internalState:t=>({...t.context._internalState,error:t.event.error})}),assignAppNotFound:a({_internalState:t=>({...t.context._internalState,error:new A("App to install not found in manager API")})}),assignDepAppNotInstalled:a({_internalState:t=>({...t.context._internalState,error:new A("Dep app is not installed on the device")})}),cleanupDeviceState:()=>{const t=r();t.sessionStateType!==S.Connected&&o({...t,installedApps:[],appsUpdates:void 0})}}}).createMachine({id:"InstallAppDeviceAction",initial:"DeviceReady",context:t=>({input:{unlockTimeout:t.input.unlockTimeout,appName:t.input.appName},intermediateValue:{requiredUserInteraction:y.None,progress:0},_internalState:{error:null,installedApps:[],getOsVersionResponse:null,appList:[]}}),states:{DeviceReady:{always:{target:"ListInstalledApps"}},ListInstalledApps:{value:"ListInstalledApps",invoke:{id:"listInstalledApps",src:"listInstalledApps",input:t=>({unlockTimeout:t.context.input.unlockTimeout}),onSnapshot:{actions:a({intermediateValue:t=>({...t.context.intermediateValue,requiredUserInteraction:t.event.snapshot.context.intermediateValue.requiredUserInteraction})})},onDone:{target:"ListInstalledAppsCheck",actions:a({_internalState:t=>t.event.output.caseOf({Right:({installedApps:e})=>({...t.context._internalState,installedApps:e}),Left:e=>({...t.context._internalState,error:e})})})}}},ListInstalledAppsCheck:{always:[{target:"Error",guard:"hasError"},{target:"Success",guard:"appInstalled"},{target:"GoToDashboard"}]},GoToDashboard:{invoke:{id:"goToDashboard",src:"goToDashboard",input:t=>({unlockTimeout:t.context.input.unlockTimeout}),onSnapshot:{actions:a({intermediateValue:t=>({...t.context.intermediateValue,requiredUserInteraction:t.event.snapshot.context.intermediateValue.requiredUserInteraction})})},onDone:{target:"GoToDashboardCheck",actions:a({_internalState:t=>t.event.output.caseOf({Right:()=>t.context._internalState,Left:e=>({...t.context._internalState,error:e})})})},onError:{target:"Error",actions:"assignErrorFromEvent"}}},GoToDashboardCheck:{always:[{target:"Error",guard:"hasError"},{target:"GetOsVersion"}]},GetOsVersion:{invoke:{id:"getOsVersion",src:"getOsVersion",input:t=>{},onDone:{target:"GetOsVersionCheck",actions:a({_internalState:t=>{if(f(t.event.output)){const e=r(),s=t.event.output.data.secureElementFlags.isSecureConnectionAllowed;return e.sessionStateType!==S.Connected&&o({...e,isSecureConnectionAllowed:s}),{...t.context._internalState,getOsVersionResponse:t.event.output.data}}return{...t.context._internalState,error:t.event.output.error}}})}}},GetOsVersionCheck:{always:[{target:"Error",guard:"hasError"},{target:"GetAppList"}]},GetAppList:{invoke:{id:"getAppList",src:"getAppList",input:t=>({deviceInfo:t.context._internalState.getOsVersionResponse}),onDone:{target:"GetAppListCheck",actions:a({_internalState:t=>t.event.output.caseOf({Right:e=>({...t.context._internalState,appList:e}),Left:e=>({...t.context._internalState,error:e})})})}}},GetAppListCheck:{always:[{target:"Error",guard:"hasError"},{target:"Error",guard:"appNotFound",actions:"assignAppNotFound"},{target:"Error",guard:"depAppNotInstalled",actions:"assignDepAppNotInstalled"},{target:"InstallApp"}]},InstallApp:{invoke:{id:"installApp",src:"installApp",input:t=>({deviceInfo:t.context._internalState.getOsVersionResponse,app:t.context._internalState.appList.find(({versionName:e})=>e===t.context.input.appName)}),onSnapshot:{actions:a({intermediateValue:t=>t.event.snapshot.context?.type===m.Progress?{...t.context.intermediateValue,progress:t.event.snapshot.context.payload.progress}:{...t.context.intermediateValue},_internalState:t=>t.event.snapshot.context?.type===m.Error?{...t.context._internalState,error:t.event.snapshot.context.error.mapInstallDAErrors()}:t.context._internalState})},onDone:{target:"ListInstalledApps",actions:"cleanupDeviceState"},onError:{target:"Error",actions:"assignErrorFromEvent"}}},Success:{type:"final",description:"App installed successfully"},Error:{type:"final"}},output:({context:t})=>t._internalState.error?g(t._internalState.error):h(void 0)})}extractDependencies(n){return{getOsVersion:()=>n.sendCommand(new x),getAppList:({input:r})=>{const{deviceInfo:o}=r;return n.getManagerApiService().getAppList(o)},installApp:({input:r})=>{const{deviceInfo:o,app:i}=r,p=n.getSecureChannelService().installApp(o,i);return new O(n,{connection:p}).run()},getDeviceSessionState:()=>n.getDeviceSessionState(),setDeviceSessionState:r=>n.setDeviceSessionState(r)}}}export{X as InstallAppDeviceAction};
2
2
  //# sourceMappingURL=InstallAppDeviceAction.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../../../../src/api/secure-channel/device-action/InstallApp/InstallAppDeviceAction.ts"],
4
- "sourcesContent": ["import { Left, Right } from \"purify-ts\";\nimport { assign, fromObservable, fromPromise, setup } from \"xstate\";\n\nimport { isSuccessCommandResult } from \"@api/command/model/CommandResult\";\nimport {\n GetOsVersionCommand,\n type GetOsVersionResponse,\n} from \"@api/command/os/GetOsVersionCommand\";\nimport { type InternalApi } from \"@api/device-action/DeviceAction\";\nimport { UserInteractionRequired } from \"@api/device-action/model/UserInteractionRequired\";\nimport { DEFAULT_UNLOCK_TIMEOUT_MS } from \"@api/device-action/os/Const\";\nimport { UnknownDAError } from \"@api/device-action/os/Errors\";\nimport { GoToDashboardDeviceAction } from \"@api/device-action/os/GoToDashboard/GoToDashboardDeviceAction\";\nimport { type StateMachineTypes } from \"@api/device-action/xstate-utils/StateMachineTypes\";\nimport {\n type DeviceActionStateMachine,\n XStateDeviceAction,\n} from \"@api/device-action/xstate-utils/XStateDeviceAction\";\nimport {\n type DeviceSessionState,\n DeviceSessionStateType,\n} from \"@api/device-session/DeviceSessionState\";\nimport { ListInstalledAppsDeviceAction } from \"@api/secure-channel/device-action/ListInstalledApps/ListInstalledAppsDeviceAction\";\nimport { ConnectToSecureChannelTask } from \"@api/secure-channel/task/ConnectToSecureChannelTask\";\nimport { SecureChannelEventType } from \"@api/secure-channel/task/types\";\nimport { type Input } from \"@api/secure-channel/types\";\nimport { type Application } from \"@internal/manager-api/model/Application\";\n\nimport {\n type InstallAppDAError,\n type InstallAppDAInput,\n type InstallAppDAIntermediateValue,\n type InstallAppDAOutput,\n type InstallAppStateMachineInternalState,\n type MachineDependencies,\n} from \"./types\";\n\nexport class InstallAppDeviceAction extends XStateDeviceAction<\n InstallAppDAOutput,\n InstallAppDAInput,\n InstallAppDAError,\n InstallAppDAIntermediateValue,\n InstallAppStateMachineInternalState\n> {\n override makeStateMachine(\n internalApi: InternalApi,\n ): DeviceActionStateMachine<\n InstallAppDAOutput,\n InstallAppDAInput,\n InstallAppDAError,\n InstallAppDAIntermediateValue,\n InstallAppStateMachineInternalState\n > {\n type types = StateMachineTypes<\n InstallAppDAOutput,\n InstallAppDAInput,\n InstallAppDAError,\n InstallAppDAIntermediateValue,\n InstallAppStateMachineInternalState\n >;\n\n const {\n getOsVersion,\n getAppList,\n installApp,\n getDeviceSessionState,\n setDeviceSessionState,\n } = this.extractDependencies(internalApi);\n\n const unlockTimeout = this.input.unlockTimeout ?? DEFAULT_UNLOCK_TIMEOUT_MS;\n\n const listInstalledAppsMachine = new ListInstalledAppsDeviceAction({\n input: {\n unlockTimeout,\n },\n }).makeStateMachine(internalApi);\n\n const goToDashboardMachine = new GoToDashboardDeviceAction({\n input: {\n unlockTimeout,\n },\n }).makeStateMachine(internalApi);\n\n return setup({\n types: {\n input: {} as types[\"input\"],\n context: {} as types[\"context\"],\n output: {} as types[\"output\"],\n },\n actors: {\n listInstalledApps: listInstalledAppsMachine,\n goToDashboard: goToDashboardMachine,\n getOsVersion: fromPromise(getOsVersion),\n getAppList: fromPromise(getAppList),\n installApp: fromObservable(installApp),\n },\n guards: {\n hasError: (_) => _.context._internalState.error !== null,\n appInstalled: (_) =>\n _.context._internalState.installedApps.some(\n (app) => app.name === _.context.input.appName,\n ),\n appNotFound: (_) =>\n _.context._internalState.appList.findIndex(\n ({ versionName }) => versionName === _.context.input.appName,\n ) === -1,\n depAppNotInstalled: (_) => {\n const appToInstall = _.context._internalState.appList.find(\n ({ versionName }) => versionName === _.context.input.appName,\n );\n if (appToInstall?.parentName) {\n return (\n _.context._internalState.installedApps.findIndex(\n ({ name }) => name === appToInstall.parentName,\n ) === -1\n );\n }\n return false;\n },\n },\n actions: {\n assignErrorFromEvent: assign({\n _internalState: (_) => ({\n ..._.context._internalState,\n error: _.event[\"error\"],\n }),\n }),\n assignAppNotFound: assign({\n _internalState: (_) => ({\n ..._.context._internalState,\n error: new UnknownDAError(\n \"App to install not found in manager API\",\n ),\n }),\n }),\n assignDepAppNotInstalled: assign({\n _internalState: (_) => ({\n ..._.context._internalState,\n error: new UnknownDAError(\"Dep app is not installed on the device\"),\n }),\n }),\n cleanupDeviceState: () => {\n // After app successful installation, cleanup the device session state\n // to force fetching the new device state when required\n const state = getDeviceSessionState();\n if (state.sessionStateType !== DeviceSessionStateType.Connected) {\n setDeviceSessionState({\n ...state,\n installedApps: [],\n appsUpdates: undefined,\n });\n }\n },\n },\n }).createMachine({\n /** @xstate-layout N4IgpgJg5mDOIC5QEkB2sAuBDANjgggA6EAiYAbgJYDGY+1GlA9qgHRlW0BKYWEAngGIA2gAYAuolCEmsSoxZSQAD0QBGAJyjWADgDsAFg0A2HSb2iArMbUBmADQh+iAExrjrS6KuWNtte7Glga2AL6hjmiYuATEHDR0DMxsADKUmFHYeJBEhLCCECxgrJSo5EwA1sU46RiZMTnEsGKSSCAycgqoSqoIBgaWrC6i-i6Wjs4ItqJqnt62BsYuGmoGLguW4ZHoWbGkFAn0XaxpGTsNELmwAMIAFmDUFSISSh3yyT2Ituu6vrZ64yciB0djmogGAxcLmMMwMWxA9TwuXitCOyROtUROEaeTuDyewjUrWksneijavW+tl+fgBE2BelmXnBwUsUJhq3hWORB1RSRYGLO0WylyaeMeIhcxPapK6nymPx0fzpQIQGmWYIhbOhsK55yRcV5iWOAHEmAAVJgkLCwW4AIyYWAAThACkUSmVKsUoBarTb7Y6XS1XrKPhTEEtBjNrAsbAZwYt6VNbB41KI9MNvpGbJyIgj9XsUcb0WbLdbbQ7na6wE6nUwnaxCDgsBgAGb1gC2rB9Zf9laDLzabzl4YQkdY0eMsdWCeMSbUeg0nnWZgC300vmMeuFhaNaIFpb9FcDEHFBMHJM6YdAvTTXiGQT0MOMBgsOjMSZhOgn3i17N1ebcoanDFgevrlgGVZniIRIhle5I3uoVjaNClhPqIL5vh+qq2JY1KBO+GgaBmK5hIBBY8iB+5sCaYAYAA8rAABqNZyCwbqoMUpTlFU3Z0YxLFOmxqDBkOoYISo6hsrMWhBL4Oi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AA */\n id: \"InstallAppDeviceAction\",\n initial: \"DeviceReady\",\n context: (_) => ({\n input: {\n unlockTimeout: _.input.unlockTimeout,\n appName: _.input.appName,\n },\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.None,\n progress: 0,\n },\n _internalState: {\n error: null,\n installedApps: [],\n getOsVersionResponse: null,\n appList: [],\n },\n }),\n states: {\n DeviceReady: {\n always: {\n target: \"ListInstalledApps\",\n },\n },\n ListInstalledApps: {\n value: \"ListInstalledApps\",\n invoke: {\n id: \"listInstalledApps\",\n src: \"listInstalledApps\",\n input: (_) => ({\n unlockTimeout: _.context.input.unlockTimeout,\n }),\n onSnapshot: {\n actions: assign({\n intermediateValue: (_) => ({\n ..._.context.intermediateValue,\n requiredUserInteraction:\n _.event.snapshot.context.intermediateValue\n .requiredUserInteraction,\n }),\n }),\n },\n onDone: {\n target: \"ListInstalledAppsCheck\",\n actions: assign({\n _internalState: (_) =>\n _.event.output.caseOf<InstallAppStateMachineInternalState>({\n Right: ({ installedApps }) => ({\n ..._.context._internalState,\n installedApps,\n }),\n Left: (error) => ({\n ..._.context._internalState,\n error,\n }),\n }),\n }),\n },\n },\n },\n ListInstalledAppsCheck: {\n always: [\n {\n target: \"Error\",\n guard: \"hasError\",\n },\n {\n target: \"Success\",\n guard: \"appInstalled\",\n },\n {\n target: \"GoToDashboard\",\n },\n ],\n },\n GoToDashboard: {\n invoke: {\n id: \"goToDashboard\",\n src: \"goToDashboard\",\n input: (_) => ({\n unlockTimeout: _.context.input.unlockTimeout,\n }),\n onSnapshot: {\n actions: assign({\n intermediateValue: (_) => ({\n ..._.context.intermediateValue,\n requiredUserInteraction:\n _.event.snapshot.context.intermediateValue\n .requiredUserInteraction,\n }),\n }),\n },\n onDone: {\n target: \"GoToDashboardCheck\",\n actions: assign({\n _internalState: (_) =>\n _.event.output.caseOf<InstallAppStateMachineInternalState>({\n Right: () => _.context._internalState,\n Left: (error) => ({\n ..._.context._internalState,\n error,\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: \"GetOsVersion\",\n },\n ],\n },\n GetOsVersion: {\n invoke: {\n id: \"getOsVersion\",\n src: \"getOsVersion\",\n input: (_) => undefined,\n onDone: {\n target: \"GetOsVersionCheck\",\n actions: assign({\n _internalState: (_) => {\n if (isSuccessCommandResult(_.event.output)) {\n const currentState: DeviceSessionState =\n getDeviceSessionState();\n const isSecureConnectionAllowed =\n _.event.output.data.secureElementFlags\n .isSecureConnectionAllowed;\n if (\n currentState.sessionStateType !==\n DeviceSessionStateType.Connected\n ) {\n setDeviceSessionState({\n ...currentState,\n isSecureConnectionAllowed,\n });\n }\n return {\n ..._.context._internalState,\n getOsVersionResponse: _.event.output.data,\n };\n }\n return {\n ..._.context._internalState,\n error: _.event.output.error,\n };\n },\n }),\n },\n },\n },\n GetOsVersionCheck: {\n always: [\n {\n target: \"Error\",\n guard: \"hasError\",\n },\n {\n target: \"GetAppList\",\n },\n ],\n },\n GetAppList: {\n invoke: {\n id: \"getAppList\",\n src: \"getAppList\",\n input: (_) => ({\n deviceInfo: _.context._internalState.getOsVersionResponse!,\n }),\n onDone: {\n target: \"GetAppListCheck\",\n actions: assign({\n _internalState: (_) =>\n _.event.output.caseOf<InstallAppStateMachineInternalState>({\n Right: (appList) => ({\n ..._.context._internalState,\n appList,\n }),\n Left: (error) => ({\n ..._.context._internalState,\n error,\n }),\n }),\n }),\n },\n },\n },\n GetAppListCheck: {\n always: [\n {\n target: \"Error\",\n guard: \"hasError\",\n },\n {\n target: \"Error\",\n guard: \"appNotFound\",\n actions: \"assignAppNotFound\",\n },\n {\n target: \"Error\",\n guard: \"depAppNotInstalled\",\n actions: \"assignDepAppNotInstalled\",\n },\n {\n target: \"InstallApp\",\n },\n ],\n },\n InstallApp: {\n invoke: {\n id: \"installApp\",\n src: \"installApp\",\n input: (_) => ({\n deviceInfo: _.context._internalState.getOsVersionResponse!,\n app: _.context._internalState.appList.find(\n ({ versionName }) => versionName === _.context.input.appName,\n )!,\n }),\n onSnapshot: {\n actions: assign({\n intermediateValue: (_) => {\n if (\n _.event.snapshot.context?.type ===\n SecureChannelEventType.Progress\n ) {\n return {\n ..._.context.intermediateValue,\n progress: _.event.snapshot.context.payload.progress,\n };\n }\n return { ..._.context.intermediateValue };\n },\n }),\n },\n onDone: {\n target: \"ListInstalledApps\",\n actions: \"cleanupDeviceState\",\n },\n onError: {\n target: \"Error\",\n actions: \"assignErrorFromEvent\",\n },\n },\n },\n Success: {\n type: \"final\",\n description: \"App installed successfully\",\n },\n Error: {\n type: \"final\",\n },\n },\n output: ({ context }) =>\n context._internalState.error\n ? Left(context._internalState.error)\n : Right(undefined),\n });\n }\n\n extractDependencies(internalApi: InternalApi): MachineDependencies {\n const getOsVersion = () =>\n internalApi.sendCommand(new GetOsVersionCommand());\n\n const getAppList = ({\n input,\n }: Input<{\n deviceInfo: GetOsVersionResponse;\n }>) => {\n const { deviceInfo } = input;\n return internalApi.getManagerApiService().getAppList(deviceInfo);\n };\n\n const installApp = ({\n input,\n }: Input<{\n deviceInfo: GetOsVersionResponse;\n app: Application;\n }>) => {\n const { deviceInfo, app } = input;\n const eitherConnection = internalApi\n .getSecureChannelService()\n .installApp(deviceInfo, app);\n return new ConnectToSecureChannelTask(internalApi, {\n connection: eitherConnection,\n }).run();\n };\n\n return {\n getOsVersion,\n getAppList,\n installApp,\n getDeviceSessionState: () => internalApi.getDeviceSessionState(),\n setDeviceSessionState: (state) =>\n internalApi.setDeviceSessionState(state),\n };\n }\n}\n"],
5
- "mappings": "AAAA,OAAS,QAAAA,EAAM,SAAAC,MAAa,YAC5B,OAAS,UAAAC,EAAQ,kBAAAC,EAAgB,eAAAC,EAAa,SAAAC,MAAa,SAE3D,OAAS,0BAAAC,MAA8B,mCACvC,OACE,uBAAAC,MAEK,sCAEP,OAAS,2BAAAC,MAA+B,mDACxC,OAAS,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A,EAAE,MAAM,SAAS,QAAQ,QAAQ,QAC7C,EAEK,CAAE,GAAGA,EAAE,QAAQ,iBAAkB,CAE5C,CAAC,CACH,EACA,OAAQ,CACN,OAAQ,oBACR,QAAS,oBACX,EACA,QAAS,CACP,OAAQ,QACR,QAAS,sBACX,CACF,CACF,EACA,QAAS,CACP,KAAM,QACN,YAAa,4BACf,EACA,MAAO,CACL,KAAM,OACR,CACF,EACA,OAAQ,CAAC,CAAE,QAAAW,CAAQ,IACjBA,EAAQ,eAAe,MACnBtC,EAAKsC,EAAQ,eAAe,KAAK,EACjCrC,EAAM,MAAS,CACvB,CAAC,CACH,CAEA,oBAAoBiB,EAA+C,CA4BjE,MAAO,CACL,aA5BmB,IACnBA,EAAY,YAAY,IAAIX,CAAqB,EA4BjD,WA1BiB,CAAC,CAClB,MAAAgC,CACF,IAEO,CACL,KAAM,CAAE,WAAAC,CAAW,EAAID,EACvB,OAAOrB,EAAY,qBAAqB,EAAE,WAAWsB,CAAU,CACjE,EAoBE,WAlBiB,CAAC,CAClB,MAAAD,CACF,IAGO,CACL,KAAM,CAAE,WAAAC,EAAY,IAAAZ,CAAI,EAAIW,EACtBE,EAAmBvB,EACtB,wBAAwB,EACxB,WAAWsB,EAAYZ,CAAG,EAC7B,OAAO,IAAIb,EAA2BG,EAAa,CACjD,WAAYuB,CACd,CAAC,EAAE,IAAI,CACT,EAME,sBAAuB,IAAMvB,EAAY,sBAAsB,EAC/D,sBAAwBc,GACtBd,EAAY,sBAAsBc,CAAK,CAC3C,CACF,CACF",
4
+ "sourcesContent": ["import { Left, Right } from \"purify-ts\";\nimport { assign, fromObservable, fromPromise, setup } from \"xstate\";\n\nimport { isSuccessCommandResult } from \"@api/command/model/CommandResult\";\nimport {\n GetOsVersionCommand,\n type GetOsVersionResponse,\n} from \"@api/command/os/GetOsVersionCommand\";\nimport { type InternalApi } from \"@api/device-action/DeviceAction\";\nimport { UserInteractionRequired } from \"@api/device-action/model/UserInteractionRequired\";\nimport { DEFAULT_UNLOCK_TIMEOUT_MS } from \"@api/device-action/os/Const\";\nimport { UnknownDAError } from \"@api/device-action/os/Errors\";\nimport { GoToDashboardDeviceAction } from \"@api/device-action/os/GoToDashboard/GoToDashboardDeviceAction\";\nimport { type StateMachineTypes } from \"@api/device-action/xstate-utils/StateMachineTypes\";\nimport {\n type DeviceActionStateMachine,\n XStateDeviceAction,\n} from \"@api/device-action/xstate-utils/XStateDeviceAction\";\nimport {\n type DeviceSessionState,\n DeviceSessionStateType,\n} from \"@api/device-session/DeviceSessionState\";\nimport { ListInstalledAppsDeviceAction } from \"@api/secure-channel/device-action/ListInstalledApps/ListInstalledAppsDeviceAction\";\nimport { ConnectToSecureChannelTask } from \"@api/secure-channel/task/ConnectToSecureChannelTask\";\nimport { SecureChannelEventType } from \"@api/secure-channel/task/types\";\nimport { type Input } from \"@api/secure-channel/types\";\nimport { type Application } from \"@internal/manager-api/model/Application\";\n\nimport {\n type InstallAppDAError,\n type InstallAppDAInput,\n type InstallAppDAIntermediateValue,\n type InstallAppDAOutput,\n type InstallAppStateMachineInternalState,\n type MachineDependencies,\n} from \"./types\";\n\nexport class InstallAppDeviceAction extends XStateDeviceAction<\n InstallAppDAOutput,\n InstallAppDAInput,\n InstallAppDAError,\n InstallAppDAIntermediateValue,\n InstallAppStateMachineInternalState\n> {\n override makeStateMachine(\n internalApi: InternalApi,\n ): DeviceActionStateMachine<\n InstallAppDAOutput,\n InstallAppDAInput,\n InstallAppDAError,\n InstallAppDAIntermediateValue,\n InstallAppStateMachineInternalState\n > {\n type types = StateMachineTypes<\n InstallAppDAOutput,\n InstallAppDAInput,\n InstallAppDAError,\n InstallAppDAIntermediateValue,\n InstallAppStateMachineInternalState\n >;\n\n const {\n getOsVersion,\n getAppList,\n installApp,\n getDeviceSessionState,\n setDeviceSessionState,\n } = this.extractDependencies(internalApi);\n\n const unlockTimeout = this.input.unlockTimeout ?? DEFAULT_UNLOCK_TIMEOUT_MS;\n\n const listInstalledAppsMachine = new ListInstalledAppsDeviceAction({\n input: {\n unlockTimeout,\n },\n }).makeStateMachine(internalApi);\n\n const goToDashboardMachine = new GoToDashboardDeviceAction({\n input: {\n unlockTimeout,\n },\n }).makeStateMachine(internalApi);\n\n return setup({\n types: {\n input: {} as types[\"input\"],\n context: {} as types[\"context\"],\n output: {} as types[\"output\"],\n },\n actors: {\n listInstalledApps: listInstalledAppsMachine,\n goToDashboard: goToDashboardMachine,\n getOsVersion: fromPromise(getOsVersion),\n getAppList: fromPromise(getAppList),\n installApp: fromObservable(installApp),\n },\n guards: {\n hasError: (_) => _.context._internalState.error !== null,\n appInstalled: (_) =>\n _.context._internalState.installedApps.some(\n (app) => app.name === _.context.input.appName,\n ),\n appNotFound: (_) =>\n _.context._internalState.appList.findIndex(\n ({ versionName }) => versionName === _.context.input.appName,\n ) === -1,\n depAppNotInstalled: (_) => {\n const appToInstall = _.context._internalState.appList.find(\n ({ versionName }) => versionName === _.context.input.appName,\n );\n if (appToInstall?.parentName) {\n return (\n _.context._internalState.installedApps.findIndex(\n ({ name }) => name === appToInstall.parentName,\n ) === -1\n );\n }\n return false;\n },\n },\n actions: {\n assignErrorFromEvent: assign({\n _internalState: (_) => ({\n ..._.context._internalState,\n error: _.event[\"error\"],\n }),\n }),\n assignAppNotFound: assign({\n _internalState: (_) => ({\n ..._.context._internalState,\n error: new UnknownDAError(\n \"App to install not found in manager API\",\n ),\n }),\n }),\n assignDepAppNotInstalled: assign({\n _internalState: (_) => ({\n ..._.context._internalState,\n error: new UnknownDAError(\"Dep app is not installed on the device\"),\n }),\n }),\n cleanupDeviceState: () => {\n // After app successful installation, cleanup the device session state\n // to force fetching the new device state when required\n const state = getDeviceSessionState();\n if (state.sessionStateType !== DeviceSessionStateType.Connected) {\n setDeviceSessionState({\n ...state,\n installedApps: [],\n appsUpdates: undefined,\n });\n }\n },\n },\n }).createMachine({\n /** @xstate-layout N4IgpgJg5mDOIC5QEkB2sAuBDANjgggA6EAiYAbgJYDGY+1GlA9qgHRlW0B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F80PYtrC0ctq33BKwhSnBm2jplaiDLYWhmHojIaAMKmqgYmj5cYFgWKY6rERo+l3RV+xUSZyPPW1r3owStjveJiVfXjBNE8RpPk0mbLUhsG4M8sOjwwa7NVeiQGEA1Ho8Y192EB1H0SZSQSsP8gKTFDO3Mn+Oq5qzCOq49Aoa4INZ1g2TYtu2TpdqUesG0L8opgTKqTGmr4-iykK22VeaoEwEBwEoGtFtR2MjklAC0OWqpn0LLgsAwrIYaZ2Mru4c8cRY8Hwkw2RnX1rEmbiDMyaYAnt7jXeXC3UYKdQFji8DxTjSWiEmFipd4Ufahys32yrqec3VWJD2e6efb04+qu+re-qy-52-metL6a4F9ieG9G64Srg6YGaWHYN2iDd87qpHsbLKs6wDD3iN94eCC-ZTx8yvsLXoN0XB33fHYf4hMOQnR2jdf4egQQvnTMsP+jskYowEhZCShtwHqDcPhIKlgdD9BGJ5KwqkXA7WLt4FYbgrCLDKgvCuasDxRXwagdeI8G63kZNSdBgUUzTChObL4j8nILm-oTK6SwsGnyeqjWoYDurph2mMQqj4hruGOjhNwYI4ELHVAuYiSi9ycxRi9TAfD66b1cJNbQpivCeXjERSRCBUGzGUjCTKj8oSKUsZXdWFFiDqNHNvMOiltDTxtnPEJnC2AAGUACu1BaCwGHg46+30zDaGsF-EElhSkjCTCCME6wobOSMLdY+bNlECgAKK1nrJEpKmVfpFJWCUspDgcLBBpnTDCZhliLn0uEIAA */\n id: \"InstallAppDeviceAction\",\n initial: \"DeviceReady\",\n context: (_) => ({\n input: {\n unlockTimeout: _.input.unlockTimeout,\n appName: _.input.appName,\n },\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.None,\n progress: 0,\n },\n _internalState: {\n error: null,\n installedApps: [],\n getOsVersionResponse: null,\n appList: [],\n },\n }),\n states: {\n DeviceReady: {\n always: {\n target: \"ListInstalledApps\",\n },\n },\n ListInstalledApps: {\n value: \"ListInstalledApps\",\n invoke: {\n id: \"listInstalledApps\",\n src: \"listInstalledApps\",\n input: (_) => ({\n unlockTimeout: _.context.input.unlockTimeout,\n }),\n onSnapshot: {\n actions: assign({\n intermediateValue: (_) => ({\n ..._.context.intermediateValue,\n requiredUserInteraction:\n _.event.snapshot.context.intermediateValue\n .requiredUserInteraction,\n }),\n }),\n },\n onDone: {\n target: \"ListInstalledAppsCheck\",\n actions: assign({\n _internalState: (_) =>\n _.event.output.caseOf<InstallAppStateMachineInternalState>({\n Right: ({ installedApps }) => ({\n ..._.context._internalState,\n installedApps,\n }),\n Left: (error) => ({\n ..._.context._internalState,\n error,\n }),\n }),\n }),\n },\n },\n },\n ListInstalledAppsCheck: {\n always: [\n {\n target: \"Error\",\n guard: \"hasError\",\n },\n {\n target: \"Success\",\n guard: \"appInstalled\",\n },\n {\n target: \"GoToDashboard\",\n },\n ],\n },\n GoToDashboard: {\n invoke: {\n id: \"goToDashboard\",\n src: \"goToDashboard\",\n input: (_) => ({\n unlockTimeout: _.context.input.unlockTimeout,\n }),\n onSnapshot: {\n actions: assign({\n intermediateValue: (_) => ({\n ..._.context.intermediateValue,\n requiredUserInteraction:\n _.event.snapshot.context.intermediateValue\n .requiredUserInteraction,\n }),\n }),\n },\n onDone: {\n target: \"GoToDashboardCheck\",\n actions: assign({\n _internalState: (_) =>\n _.event.output.caseOf<InstallAppStateMachineInternalState>({\n Right: () => _.context._internalState,\n Left: (error) => ({\n ..._.context._internalState,\n error,\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: \"GetOsVersion\",\n },\n ],\n },\n GetOsVersion: {\n invoke: {\n id: \"getOsVersion\",\n src: \"getOsVersion\",\n input: (_) => undefined,\n onDone: {\n target: \"GetOsVersionCheck\",\n actions: assign({\n _internalState: (_) => {\n if (isSuccessCommandResult(_.event.output)) {\n const currentState: DeviceSessionState =\n getDeviceSessionState();\n const isSecureConnectionAllowed =\n _.event.output.data.secureElementFlags\n .isSecureConnectionAllowed;\n if (\n currentState.sessionStateType !==\n DeviceSessionStateType.Connected\n ) {\n setDeviceSessionState({\n ...currentState,\n isSecureConnectionAllowed,\n });\n }\n return {\n ..._.context._internalState,\n getOsVersionResponse: _.event.output.data,\n };\n }\n return {\n ..._.context._internalState,\n error: _.event.output.error,\n };\n },\n }),\n },\n },\n },\n GetOsVersionCheck: {\n always: [\n {\n target: \"Error\",\n guard: \"hasError\",\n },\n {\n target: \"GetAppList\",\n },\n ],\n },\n GetAppList: {\n invoke: {\n id: \"getAppList\",\n src: \"getAppList\",\n input: (_) => ({\n deviceInfo: _.context._internalState.getOsVersionResponse!,\n }),\n onDone: {\n target: \"GetAppListCheck\",\n actions: assign({\n _internalState: (_) =>\n _.event.output.caseOf<InstallAppStateMachineInternalState>({\n Right: (appList) => ({\n ..._.context._internalState,\n appList,\n }),\n Left: (error) => ({\n ..._.context._internalState,\n error,\n }),\n }),\n }),\n },\n },\n },\n GetAppListCheck: {\n always: [\n {\n target: \"Error\",\n guard: \"hasError\",\n },\n {\n target: \"Error\",\n guard: \"appNotFound\",\n actions: \"assignAppNotFound\",\n },\n {\n target: \"Error\",\n guard: \"depAppNotInstalled\",\n actions: \"assignDepAppNotInstalled\",\n },\n {\n target: \"InstallApp\",\n },\n ],\n },\n InstallApp: {\n invoke: {\n id: \"installApp\",\n src: \"installApp\",\n input: (_) => ({\n deviceInfo: _.context._internalState.getOsVersionResponse!,\n app: _.context._internalState.appList.find(\n ({ versionName }) => versionName === _.context.input.appName,\n )!,\n }),\n onSnapshot: {\n actions: assign({\n intermediateValue: (_) => {\n if (\n _.event.snapshot.context?.type ===\n SecureChannelEventType.Progress\n ) {\n return {\n ..._.context.intermediateValue,\n progress: _.event.snapshot.context.payload.progress,\n };\n }\n return { ..._.context.intermediateValue };\n },\n _internalState: (_) => {\n if (\n _.event.snapshot.context?.type ===\n SecureChannelEventType.Error\n ) {\n return {\n ..._.context._internalState,\n error:\n _.event.snapshot.context.error.mapInstallDAErrors(),\n };\n }\n return _.context._internalState;\n },\n }),\n },\n onDone: {\n target: \"ListInstalledApps\",\n actions: \"cleanupDeviceState\",\n },\n onError: {\n target: \"Error\",\n actions: \"assignErrorFromEvent\",\n },\n },\n },\n Success: {\n type: \"final\",\n description: \"App installed successfully\",\n },\n Error: {\n type: \"final\",\n },\n },\n output: ({ context }) =>\n context._internalState.error\n ? Left(context._internalState.error)\n : Right(undefined),\n });\n }\n\n extractDependencies(internalApi: InternalApi): MachineDependencies {\n const getOsVersion = () =>\n internalApi.sendCommand(new GetOsVersionCommand());\n\n const getAppList = ({\n input,\n }: Input<{\n deviceInfo: GetOsVersionResponse;\n }>) => {\n const { deviceInfo } = input;\n return internalApi.getManagerApiService().getAppList(deviceInfo);\n };\n\n const installApp = ({\n input,\n }: Input<{\n deviceInfo: GetOsVersionResponse;\n app: Application;\n }>) => {\n const { deviceInfo, app } = input;\n const eitherConnection = internalApi\n .getSecureChannelService()\n .installApp(deviceInfo, app);\n return new ConnectToSecureChannelTask(internalApi, {\n connection: eitherConnection,\n }).run();\n };\n\n return {\n getOsVersion,\n getAppList,\n installApp,\n getDeviceSessionState: () => internalApi.getDeviceSessionState(),\n setDeviceSessionState: (state) =>\n internalApi.setDeviceSessionState(state),\n };\n }\n}\n"],
5
+ "mappings": "AAAA,OAAS,QAAAA,EAAM,SAAAC,MAAa,YAC5B,OAAS,UAAAC,EAAQ,kBAAAC,EAAgB,eAAAC,EAAa,SAAAC,MAAa,SAE3D,OAAS,0BAAAC,MAA8B,mCACvC,OACE,uBAAAC,MAEK,sCAEP,OAAS,2BAAAC,MAA+B,mDACxC,OAAS,6BAAAC,MAAiC,8BAC1C,OAAS,kBAAAC,MAAsB,+BAC/B,OAAS,6BAAAC,MAAiC,gEAE1C,OAEE,sBAAAC,MACK,qDACP,OAEE,0BAAAC,MACK,yCACP,OAAS,iCAAAC,MAAqC,oFAC9C,OAAS,8BAAAC,MAAkC,sDAC3C,OAAS,0BAAAC,MAA8B,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AM,mBAAmB,CACtD,EAEKA,EAAE,QAAQ,cAErB,CAAC,CACH,EACA,OAAQ,CACN,OAAQ,oBACR,QAAS,oBACX,EACA,QAAS,CACP,OAAQ,QACR,QAAS,sBACX,CACF,CACF,EACA,QAAS,CACP,KAAM,QACN,YAAa,4BACf,EACA,MAAO,CACL,KAAM,OACR,CACF,EACA,OAAQ,CAAC,CAAE,QAAAW,CAAQ,IACjBA,EAAQ,eAAe,MACnBtC,EAAKsC,EAAQ,eAAe,KAAK,EACjCrC,EAAM,MAAS,CACvB,CAAC,CACH,CAEA,oBAAoBiB,EAA+C,CA4BjE,MAAO,CACL,aA5BmB,IACnBA,EAAY,YAAY,IAAIX,CAAqB,EA4BjD,WA1BiB,CAAC,CAClB,MAAAgC,CACF,IAEO,CACL,KAAM,CAAE,WAAAC,CAAW,EAAID,EACvB,OAAOrB,EAAY,qBAAqB,EAAE,WAAWsB,CAAU,CACjE,EAoBE,WAlBiB,CAAC,CAClB,MAAAD,CACF,IAGO,CACL,KAAM,CAAE,WAAAC,EAAY,IAAAZ,CAAI,EAAIW,EACtBE,EAAmBvB,EACtB,wBAAwB,EACxB,WAAWsB,EAAYZ,CAAG,EAC7B,OAAO,IAAIb,EAA2BG,EAAa,CACjD,WAAYuB,CACd,CAAC,EAAE,IAAI,CACT,EAME,sBAAuB,IAAMvB,EAAY,sBAAsB,EAC/D,sBAAwBc,GACtBd,EAAY,sBAAsBc,CAAK,CAC3C,CACF,CACF",
6
6
  "names": ["Left", "Right", "assign", "fromObservable", "fromPromise", "setup", "isSuccessCommandResult", "GetOsVersionCommand", "UserInteractionRequired", "DEFAULT_UNLOCK_TIMEOUT_MS", "UnknownDAError", "GoToDashboardDeviceAction", "XStateDeviceAction", "DeviceSessionStateType", "ListInstalledAppsDeviceAction", "ConnectToSecureChannelTask", "SecureChannelEventType", "InstallAppDeviceAction", "internalApi", "getOsVersion", "getAppList", "installApp", "getDeviceSessionState", "setDeviceSessionState", "unlockTimeout", "listInstalledAppsMachine", "goToDashboardMachine", "_", "app", "versionName", "appToInstall", "name", "state", "installedApps", "error", "currentState", "isSecureConnectionAllowed", "appList", "context", "input", "deviceInfo", "eitherConnection"]
7
7
  }
@@ -1,2 +1,2 @@
1
- import{Left as v,Right as I}from"purify-ts";import{assign as i,fromObservable as D,fromPromise as c,setup as A}from"xstate";import{isSuccessCommandResult as h}from"../../../command/model/CommandResult";import{GetOsVersionCommand as V}from"../../../command/os/GetOsVersionCommand";import{UserInteractionRequired as p}from"../../../device-action/model/UserInteractionRequired";import{DEFAULT_UNLOCK_TIMEOUT_MS as f}from"../../../device-action/os/Const";import{GoToDashboardDeviceAction as y}from"../../../device-action/os/GoToDashboard/GoToDashboardDeviceAction";import{XStateDeviceAction as E}from"../../../device-action/xstate-utils/XStateDeviceAction";import{DeviceSessionStateType as x}from"../../../device-session/DeviceSessionState";import{ConnectToSecureChannelTask as L}from"../../../secure-channel/task/ConnectToSecureChannelTask";import{SecureChannelEventType as l}from"../../../secure-channel/task/types";import{installedAppResultGuard as w}from"./types";class P extends E{makeStateMachine(n){const{getOsVersion:u,getDeviceVersion:d,getFirmwareVersion:m,listInstalledApps:S,getDeviceSessionState:r,setDeviceSessionState:s}=this.extractDependencies(n),o=this.input.unlockTimeout??f,a=new y({input:{unlockTimeout:o}}).makeStateMachine(n);return A({types:{input:{},context:{},output:{}},actors:{goToDashboard:a,getOsVersion:c(u),getDeviceVersion:c(d),getFirmwareVersion:c(m),listInstalledApps:D(S)},guards:{hasError:e=>e.context._internalState.error!==null},actions:{assignErrorFromEvent:i({_internalState:e=>({...e.context._internalState,error:e.event.error})})}}).createMachine({id:"ListInstalledAppsDeviceAction",initial:"DeviceReady",context:e=>({input:{unlockTimeout:e.input.unlockTimeout},intermediateValue:{requiredUserInteraction:p.None},_internalState:{error:null,getOsVersionResponse:null,deviceVersion:null,firmwareVersion:null,result:{installedApps:[]}}}),states:{DeviceReady:{always:{target:"GoToDashboard"}},GoToDashboard:{invoke:{id:"goToDashboard",src:"goToDashboard",input:e=>({unlockTimeout:e.context.input.unlockTimeout}),onSnapshot:{actions:i({intermediateValue:e=>({...e.context.intermediateValue,requiredUserInteraction:e.event.snapshot.context.intermediateValue.requiredUserInteraction})})},onDone:{target:"GoToDashboardCheck",actions:i({_internalState:e=>e.event.output.caseOf({Right:()=>e.context._internalState,Left:t=>({...e.context._internalState,error:t})})})},onError:{target:"Error",actions:"assignErrorFromEvent"}}},GoToDashboardCheck:{always:[{target:"Error",guard:"hasError"},{target:"GetOsVersion"}]},GetOsVersion:{invoke:{id:"getOsVersion",src:"getOsVersion",input:e=>{},onDone:{target:"GetOsVersionCheck",actions:i({_internalState:e=>{if(h(e.event.output)){const t=r(),g=e.event.output.data.secureElementFlags.isSecureConnectionAllowed;return t.sessionStateType!==x.Connected&&s({...t,isSecureConnectionAllowed:g}),{...e.context._internalState,getOsVersionResponse:e.event.output.data}}return{...e.context._internalState,error:e.event.output.error}}})}}},GetOsVersionCheck:{always:[{target:"Error",guard:"hasError"},{target:"GetDeviceVersion"}]},GetDeviceVersion:{invoke:{id:"getDeviceVersion",src:"getDeviceVersion",input:e=>({deviceInfo:e.context._internalState.getOsVersionResponse}),onDone:{target:"GetDeviceVersionCheck",actions:i({_internalState:e=>e.event.output.caseOf({Right:t=>({...e.context._internalState,deviceVersion:t}),Left:t=>({...e.context._internalState,error:t})})})},onError:{target:"Error",actions:"assignErrorFromEvent"}}},GetDeviceVersionCheck:{always:[{target:"Error",guard:"hasError"},{target:"GetFirmwareVersion"}]},GetFirmwareVersion:{invoke:{id:"getFirmwareVersion",src:"getFirmwareVersion",input:e=>({deviceInfo:e.context._internalState.getOsVersionResponse,deviceVersion:e.context._internalState.deviceVersion}),onDone:{target:"GetFirmwareVersionCheck",actions:i({_internalState:e=>e.event.output.caseOf({Right:t=>({...e.context._internalState,firmwareVersion:t}),Left:t=>({...e.context._internalState,error:t})})})},onError:{target:"Error",actions:"assignErrorFromEvent"}}},GetFirmwareVersionCheck:{always:[{target:"Error",guard:"hasError"},{target:"ListInstalledApps"}]},ListInstalledApps:{invoke:{id:"listInstalledApps",src:"listInstalledApps",input:e=>({deviceInfo:e.context._internalState.getOsVersionResponse,finalFirmware:e.context._internalState.firmwareVersion}),onSnapshot:{actions:i({intermediateValue:e=>{switch(e.event.snapshot.context?.type){case l.PermissionRequested:return{requiredUserInteraction:p.AllowSecureConnection};case l.PermissionGranted:return{requiredUserInteraction:p.None};default:return{...e.context.intermediateValue}}},_internalState:e=>{if(e.event.snapshot.context?.type===l.Result){if(w(e.event.snapshot.context.payload))return{...e.context._internalState,result:{installedApps:e.event.snapshot.context.payload}};throw new Error(`Invalid result ${JSON.stringify(e.event.snapshot.context.payload)}`)}return{...e.context._internalState}}})},onDone:{target:"Success"},onError:{target:"Error",actions:"assignErrorFromEvent"}}},ListInstalledAppsCheck:{always:[{target:"Error",guard:"hasError"},{target:"Success"}]},Success:{type:"final"},Error:{type:"final"}},output:e=>e.context._internalState.error?v(e.context._internalState.error):I(e.context._internalState.result)})}extractDependencies(n){return{getOsVersion:()=>n.sendCommand(new V),getDeviceVersion:({input:r})=>{const{deviceInfo:s}=r;return n.getManagerApiService().getDeviceVersion(s)},getFirmwareVersion:({input:r})=>{const{deviceInfo:s,deviceVersion:o}=r;return n.getManagerApiService().getFirmwareVersion(s,o)},listInstalledApps:({input:r})=>{const{deviceInfo:s,finalFirmware:o}=r,a=n.getSecureChannelService().listInstalledApps(s,o);return new L(n,{connection:a}).run()},getDeviceSessionState:()=>n.getDeviceSessionState(),setDeviceSessionState:r=>n.setDeviceSessionState(r)}}}export{P as ListInstalledAppsDeviceAction};
1
+ import{Left as g,Right as I}from"purify-ts";import{assign as o,fromObservable as D,fromPromise as p,setup as h}from"xstate";import{isSuccessCommandResult as A}from"../../../command/model/CommandResult";import{GetOsVersionCommand as V}from"../../../command/os/GetOsVersionCommand";import{UserInteractionRequired as l}from"../../../device-action/model/UserInteractionRequired";import{DEFAULT_UNLOCK_TIMEOUT_MS as f}from"../../../device-action/os/Const";import{GoToDashboardDeviceAction as y}from"../../../device-action/os/GoToDashboard/GoToDashboardDeviceAction";import{XStateDeviceAction as E}from"../../../device-action/xstate-utils/XStateDeviceAction";import{DeviceSessionStateType as x}from"../../../device-session/DeviceSessionState";import{ConnectToSecureChannelTask as L}from"../../../secure-channel/task/ConnectToSecureChannelTask";import{SecureChannelEventType as a}from"../../../secure-channel/task/types";import{installedAppResultGuard as w}from"./types";class P extends E{makeStateMachine(n){const{getOsVersion:u,getDeviceVersion:d,getFirmwareVersion:m,listInstalledApps:S,getDeviceSessionState:r,setDeviceSessionState:s}=this.extractDependencies(n),i=this.input.unlockTimeout??f,c=new y({input:{unlockTimeout:i}}).makeStateMachine(n);return h({types:{input:{},context:{},output:{}},actors:{goToDashboard:c,getOsVersion:p(u),getDeviceVersion:p(d),getFirmwareVersion:p(m),listInstalledApps:D(S)},guards:{hasError:e=>e.context._internalState.error!==null},actions:{assignErrorFromEvent:o({_internalState:e=>({...e.context._internalState,error:e.event.error})})}}).createMachine({id:"ListInstalledAppsDeviceAction",initial:"DeviceReady",context:e=>({input:{unlockTimeout:e.input.unlockTimeout},intermediateValue:{requiredUserInteraction:l.None},_internalState:{error:null,getOsVersionResponse:null,deviceVersion:null,firmwareVersion:null,result:{installedApps:[]}}}),states:{DeviceReady:{always:{target:"GoToDashboard"}},GoToDashboard:{invoke:{id:"goToDashboard",src:"goToDashboard",input:e=>({unlockTimeout:e.context.input.unlockTimeout}),onSnapshot:{actions:o({intermediateValue:e=>({...e.context.intermediateValue,requiredUserInteraction:e.event.snapshot.context.intermediateValue.requiredUserInteraction})})},onDone:{target:"GoToDashboardCheck",actions:o({_internalState:e=>e.event.output.caseOf({Right:()=>e.context._internalState,Left:t=>({...e.context._internalState,error:t})})})},onError:{target:"Error",actions:"assignErrorFromEvent"}}},GoToDashboardCheck:{always:[{target:"Error",guard:"hasError"},{target:"GetOsVersion"}]},GetOsVersion:{invoke:{id:"getOsVersion",src:"getOsVersion",input:e=>{},onDone:{target:"GetOsVersionCheck",actions:o({_internalState:e=>{if(A(e.event.output)){const t=r(),v=e.event.output.data.secureElementFlags.isSecureConnectionAllowed;return t.sessionStateType!==x.Connected&&s({...t,isSecureConnectionAllowed:v}),{...e.context._internalState,getOsVersionResponse:e.event.output.data}}return{...e.context._internalState,error:e.event.output.error}}})}}},GetOsVersionCheck:{always:[{target:"Error",guard:"hasError"},{target:"GetDeviceVersion"}]},GetDeviceVersion:{invoke:{id:"getDeviceVersion",src:"getDeviceVersion",input:e=>({deviceInfo:e.context._internalState.getOsVersionResponse}),onDone:{target:"GetDeviceVersionCheck",actions:o({_internalState:e=>e.event.output.caseOf({Right:t=>({...e.context._internalState,deviceVersion:t}),Left:t=>({...e.context._internalState,error:t})})})},onError:{target:"Error",actions:"assignErrorFromEvent"}}},GetDeviceVersionCheck:{always:[{target:"Error",guard:"hasError"},{target:"GetFirmwareVersion"}]},GetFirmwareVersion:{invoke:{id:"getFirmwareVersion",src:"getFirmwareVersion",input:e=>({deviceInfo:e.context._internalState.getOsVersionResponse,deviceVersion:e.context._internalState.deviceVersion}),onDone:{target:"GetFirmwareVersionCheck",actions:o({_internalState:e=>e.event.output.caseOf({Right:t=>({...e.context._internalState,firmwareVersion:t}),Left:t=>({...e.context._internalState,error:t})})})},onError:{target:"Error",actions:"assignErrorFromEvent"}}},GetFirmwareVersionCheck:{always:[{target:"Error",guard:"hasError"},{target:"ListInstalledApps"}]},ListInstalledApps:{invoke:{id:"listInstalledApps",src:"listInstalledApps",input:e=>({deviceInfo:e.context._internalState.getOsVersionResponse,finalFirmware:e.context._internalState.firmwareVersion}),onSnapshot:{actions:o({intermediateValue:e=>{switch(e.event.snapshot.context?.type){case a.PermissionRequested:return{requiredUserInteraction:l.AllowSecureConnection};case a.PermissionGranted:return{requiredUserInteraction:l.None};default:return{...e.context.intermediateValue}}},_internalState:e=>{if(e.event.snapshot.context?.type===a.Error)return{...e.context._internalState,error:e.event.snapshot.context.error.mapDAErrors()};if(e.event.snapshot.context?.type===a.Result){if(w(e.event.snapshot.context.payload))return{...e.context._internalState,result:{installedApps:e.event.snapshot.context.payload}};throw new Error(`Invalid result ${JSON.stringify(e.event.snapshot.context.payload)}`)}return{...e.context._internalState}}})},onDone:{target:"Success"},onError:{target:"Error",actions:"assignErrorFromEvent"}}},ListInstalledAppsCheck:{always:[{target:"Error",guard:"hasError"},{target:"Success"}]},Success:{type:"final"},Error:{type:"final"}},output:e=>e.context._internalState.error?g(e.context._internalState.error):I(e.context._internalState.result)})}extractDependencies(n){return{getOsVersion:()=>n.sendCommand(new V),getDeviceVersion:({input:r})=>{const{deviceInfo:s}=r;return n.getManagerApiService().getDeviceVersion(s)},getFirmwareVersion:({input:r})=>{const{deviceInfo:s,deviceVersion:i}=r;return n.getManagerApiService().getFirmwareVersion(s,i)},listInstalledApps:({input:r})=>{const{deviceInfo:s,finalFirmware:i}=r,c=n.getSecureChannelService().listInstalledApps(s,i);return new L(n,{connection:c}).run()},getDeviceSessionState:()=>n.getDeviceSessionState(),setDeviceSessionState:r=>n.setDeviceSessionState(r)}}}export{P as ListInstalledAppsDeviceAction};
2
2
  //# sourceMappingURL=ListInstalledAppsDeviceAction.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../../../../src/api/secure-channel/device-action/ListInstalledApps/ListInstalledAppsDeviceAction.ts"],
4
- "sourcesContent": ["import { Left, Right } from \"purify-ts\";\nimport { assign, fromObservable, fromPromise, setup } from \"xstate\";\n\nimport { isSuccessCommandResult } from \"@api/command/model/CommandResult\";\nimport {\n GetOsVersionCommand,\n type GetOsVersionResponse,\n} from \"@api/command/os/GetOsVersionCommand\";\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 { type StateMachineTypes } from \"@api/device-action/xstate-utils/StateMachineTypes\";\nimport {\n type DeviceActionStateMachine,\n XStateDeviceAction,\n} from \"@api/device-action/xstate-utils/XStateDeviceAction\";\nimport {\n type DeviceSessionState,\n DeviceSessionStateType,\n} from \"@api/device-session/DeviceSessionState\";\nimport { ConnectToSecureChannelTask } from \"@api/secure-channel/task/ConnectToSecureChannelTask\";\nimport { SecureChannelEventType } from \"@api/secure-channel/task/types\";\nimport { type Input } from \"@api/secure-channel/types\";\nimport { type DeviceVersion } from \"@internal/manager-api/model/Device\";\nimport { type FinalFirmware } from \"@internal/manager-api/model/Firmware\";\n\nimport {\n installedAppResultGuard,\n type ListInstalledAppsDAError,\n type ListInstalledAppsDAInput,\n type ListInstalledAppsDAIntermediateValue,\n type ListInstalledAppsDAOutput,\n type ListInstalledAppsStateMachineInternalState,\n type MachineDependencies,\n} from \"./types\";\n\nexport class ListInstalledAppsDeviceAction extends XStateDeviceAction<\n ListInstalledAppsDAOutput,\n ListInstalledAppsDAInput,\n ListInstalledAppsDAError,\n ListInstalledAppsDAIntermediateValue,\n ListInstalledAppsStateMachineInternalState\n> {\n override makeStateMachine(\n internalApi: InternalApi,\n ): DeviceActionStateMachine<\n ListInstalledAppsDAOutput,\n ListInstalledAppsDAInput,\n ListInstalledAppsDAError,\n ListInstalledAppsDAIntermediateValue,\n ListInstalledAppsStateMachineInternalState\n > {\n type types = StateMachineTypes<\n ListInstalledAppsDAOutput,\n ListInstalledAppsDAInput,\n ListInstalledAppsDAError,\n ListInstalledAppsDAIntermediateValue,\n ListInstalledAppsStateMachineInternalState\n >;\n\n const {\n getOsVersion,\n getDeviceVersion,\n getFirmwareVersion,\n listInstalledApps,\n getDeviceSessionState,\n setDeviceSessionState,\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\n return setup({\n types: {\n input: {} as types[\"input\"],\n context: {} as types[\"context\"],\n output: {} as types[\"output\"],\n },\n actors: {\n goToDashboard: goToDashboardMachine,\n getOsVersion: fromPromise(getOsVersion),\n getDeviceVersion: fromPromise(getDeviceVersion),\n getFirmwareVersion: fromPromise(getFirmwareVersion),\n listInstalledApps: fromObservable(listInstalledApps),\n },\n guards: {\n hasError: (_) => _.context._internalState.error !== null,\n },\n actions: {\n assignErrorFromEvent: assign({\n _internalState: (_) => ({\n ..._.context._internalState,\n error: _.event[\"error\"],\n }),\n }),\n },\n }).createMachine({\n /** @xstate-layout N4IgpgJg5mDOIC5QEkB2sAuBDANjgggA6EAiYAbgJYDGY+1GlA9qgHRlW0BKYWEAngGIA2gAYAuolCEmsSoxZSQAD0QBGAJyjWADgDsAFg0A2HSb2iArMbUBmADQh+iAExrjrS6KuWNtte7Glga2AL6hjmiYuATEHDR0DMxsAOJMACpMJFiwABYARkxYAE4QghAsYKyUqORMANZVUBlZOQVFpWKSSCAycgqoSqoIxi6WrKJq1rYGNgaiBrOOzgi2th5qonouorYuo9YBBuGR6Nh4RKQUCfQDrGmZ2XmFJWVgxcVMxayEOFgYADMvgBbVjNR5tF6dCRKPryZJDRAHCZTYwzOYLJZOdR6DSeFy2MwBPaaXzGE4gKLnWJXTiJO4PVrPDoQADCuTA1HqIhhPThA0RCE2XlY+0semMomMBgsOjMyyRoh0E28BmClhc+0mxwilLOMUu8Vot2S9xaT3ar3ZnO5wjU3Wksnhih6w2F2jFEqlMqV8uxq0stlYgTlGg02wJOjCuqpBri12NSRY9zAGAA8rAAGrvOQscqVaq1BpNVMZ7PFXOoLqwp0C13qDVqVhaIK+HSifazNQK1YuPHGLTWQxabaLSwU2MXeN0k3JlKlrM55LWrk8h29WsI+tCjRqAysebSvY6TWagw6HvnvFeDsaGX6UR+Wx6Cf6qe0m5J1IL8uVle2+0a36LdQDdXd90PEIXBPU9zx7dFWD0LwxgMHYFkmckYzfGkjXpU15wwS4ABlKEwfNUCqGo6kaFNCOIEjMGrPlNxdUDXFscVRR0VFxXDJCL39PYgxcPRbD8NQ9DUOV9BfLDonfXDZ2-OjCAYjB-zXIDnUGbcRIkxDNEfEIwwCFx4MDYNjFMMxw01Qlo1OeScITPC51TYjSPUjlVztdd+RAlRXEkvQDK0O8xN3NQzP9HR9xvKxCT0E9Jj0WTdVQJgIDgJRJ2cmcvy0us2IQABaYwezK18nMNFylPYFyeD4FZHWA1jAoQVCezccYb02JDDPcQkqupGr8oZc1IRZQqAuGaDxhMfQxjsKMlQcf1NBcFVdlmPs9wJNVhrjD9E3GiFmStbz6mmtrhijTaFu4tZRJMSZzJCqNnyS9x5m2DRDoU2qv1osslza-ybvUNwg02DRLFi+YZnbSx4JE5sJO8Xc3CsWZMMckbp0-Bkf1B1B-2unTiokuxWGlJULHWWwOzGcymwMKnULEuzRn+vLCfw9z6M88nBR2VLRWQ6xxR0GxRhRpsb2fNYjDcXFZLxo7FKBgiPMwMnmNain2rGDiD01PdUs0NVu0EtUtq8KydginV1YBsbTQAZQAV2oWhYHgfXtJFsxtGsXbuMsCPdh7bjPG8AkNFi70-B50a+eTABRD4vmF3Tg88UZd3DyO1pWDj9wlCwLFMDQ+1xcdwlCIA */\n id: \"ListInstalledAppsDeviceAction\",\n initial: \"DeviceReady\",\n context: (_) => {\n return {\n input: {\n unlockTimeout: _.input.unlockTimeout,\n },\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.None,\n },\n _internalState: {\n error: null,\n getOsVersionResponse: null,\n deviceVersion: null,\n firmwareVersion: null,\n result: { installedApps: [] },\n },\n };\n },\n states: {\n DeviceReady: {\n always: {\n target: \"GoToDashboard\",\n },\n },\n GoToDashboard: {\n invoke: {\n id: \"goToDashboard\",\n src: \"goToDashboard\",\n input: (_) => ({\n unlockTimeout: _.context.input.unlockTimeout,\n }),\n onSnapshot: {\n actions: assign({\n intermediateValue: (_) => ({\n ..._.context.intermediateValue,\n requiredUserInteraction:\n _.event.snapshot.context.intermediateValue\n .requiredUserInteraction,\n }),\n }),\n },\n onDone: {\n target: \"GoToDashboardCheck\",\n actions: assign({\n _internalState: (_) =>\n _.event.output.caseOf<ListInstalledAppsStateMachineInternalState>(\n {\n Right: () => _.context._internalState,\n Left: (error) => ({\n ..._.context._internalState,\n error,\n }),\n },\n ),\n }),\n },\n onError: {\n target: \"Error\",\n actions: \"assignErrorFromEvent\",\n },\n },\n },\n GoToDashboardCheck: {\n always: [\n {\n target: \"Error\",\n guard: \"hasError\",\n },\n {\n target: \"GetOsVersion\",\n },\n ],\n },\n GetOsVersion: {\n invoke: {\n id: \"getOsVersion\",\n src: \"getOsVersion\",\n input: (_) => undefined,\n onDone: {\n target: \"GetOsVersionCheck\",\n actions: assign({\n _internalState: (_) => {\n if (isSuccessCommandResult(_.event.output)) {\n const currentState: DeviceSessionState =\n getDeviceSessionState();\n const isSecureConnectionAllowed =\n _.event.output.data.secureElementFlags\n .isSecureConnectionAllowed;\n if (\n currentState.sessionStateType !==\n DeviceSessionStateType.Connected\n ) {\n setDeviceSessionState({\n ...currentState,\n isSecureConnectionAllowed,\n });\n }\n return {\n ..._.context._internalState,\n getOsVersionResponse: _.event.output.data,\n };\n }\n return {\n ..._.context._internalState,\n error: _.event.output.error,\n };\n },\n }),\n },\n },\n },\n GetOsVersionCheck: {\n always: [\n {\n target: \"Error\",\n guard: \"hasError\",\n },\n {\n target: \"GetDeviceVersion\",\n },\n ],\n },\n GetDeviceVersion: {\n invoke: {\n id: \"getDeviceVersion\",\n src: \"getDeviceVersion\",\n input: (_) => ({\n deviceInfo: _.context._internalState.getOsVersionResponse!,\n }),\n onDone: {\n target: \"GetDeviceVersionCheck\",\n actions: assign({\n _internalState: (_) =>\n _.event.output.caseOf<ListInstalledAppsStateMachineInternalState>(\n {\n Right: (deviceVersion) => ({\n ..._.context._internalState,\n deviceVersion,\n }),\n Left: (error) => ({\n ..._.context._internalState,\n error,\n }),\n },\n ),\n }),\n },\n onError: {\n target: \"Error\",\n actions: \"assignErrorFromEvent\",\n },\n },\n },\n GetDeviceVersionCheck: {\n always: [\n {\n target: \"Error\",\n guard: \"hasError\",\n },\n { target: \"GetFirmwareVersion\" },\n ],\n },\n GetFirmwareVersion: {\n invoke: {\n id: \"getFirmwareVersion\",\n src: \"getFirmwareVersion\",\n input: (_) => ({\n deviceInfo: _.context._internalState.getOsVersionResponse!,\n deviceVersion: _.context._internalState.deviceVersion!,\n }),\n onDone: {\n target: \"GetFirmwareVersionCheck\",\n actions: assign({\n _internalState: (_) =>\n _.event.output.caseOf<ListInstalledAppsStateMachineInternalState>(\n {\n Right: (firmwareVersion) => ({\n ..._.context._internalState,\n firmwareVersion,\n }),\n Left: (error) => ({\n ..._.context._internalState,\n error,\n }),\n },\n ),\n }),\n },\n onError: {\n target: \"Error\",\n actions: \"assignErrorFromEvent\",\n },\n },\n },\n GetFirmwareVersionCheck: {\n always: [\n {\n target: \"Error\",\n guard: \"hasError\",\n },\n { target: \"ListInstalledApps\" },\n ],\n },\n ListInstalledApps: {\n invoke: {\n id: \"listInstalledApps\",\n src: \"listInstalledApps\",\n input: (_) => ({\n deviceInfo: _.context._internalState.getOsVersionResponse!,\n finalFirmware: _.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 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 result: {\n installedApps: _.event.snapshot.context.payload,\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: \"Success\",\n },\n onError: {\n target: \"Error\",\n actions: \"assignErrorFromEvent\",\n },\n },\n },\n ListInstalledAppsCheck: {\n always: [\n {\n target: \"Error\",\n guard: \"hasError\",\n },\n {\n target: \"Success\",\n },\n ],\n },\n Success: {\n type: \"final\",\n },\n Error: {\n type: \"final\",\n },\n },\n output: (_) => {\n if (_.context._internalState.error) {\n return Left(_.context._internalState.error);\n } else {\n return Right(_.context._internalState.result);\n }\n },\n });\n }\n\n extractDependencies(internalApi: InternalApi): MachineDependencies {\n const getOsVersion = () =>\n internalApi.sendCommand(new GetOsVersionCommand());\n\n const getDeviceVersion = ({\n input,\n }: Input<{ deviceInfo: GetOsVersionResponse }>) => {\n const { deviceInfo } = input;\n return internalApi.getManagerApiService().getDeviceVersion(deviceInfo);\n };\n\n const getFirmwareVersion = ({\n input,\n }: Input<{\n deviceInfo: GetOsVersionResponse;\n deviceVersion: DeviceVersion;\n }>) => {\n const { deviceInfo, deviceVersion } = input;\n return internalApi\n .getManagerApiService()\n .getFirmwareVersion(deviceInfo, deviceVersion);\n };\n\n const listInstalledApps = ({\n input,\n }: Input<{\n deviceInfo: GetOsVersionResponse;\n finalFirmware: FinalFirmware;\n }>) => {\n const { deviceInfo, finalFirmware } = input;\n const eitherConnection = internalApi\n .getSecureChannelService()\n .listInstalledApps(deviceInfo, finalFirmware);\n return new ConnectToSecureChannelTask(internalApi, {\n connection: eitherConnection,\n }).run();\n };\n\n return {\n getOsVersion,\n getDeviceVersion,\n getFirmwareVersion,\n listInstalledApps,\n getDeviceSessionState: () => internalApi.getDeviceSessionState(),\n setDeviceSessionState: (state) =>\n internalApi.setDeviceSessionState(state),\n };\n }\n}\n"],
5
- "mappings": "AAAA,OAAS,QAAAA,EAAM,SAAAC,MAAa,YAC5B,OAAS,UAAAC,EAAQ,kBAAAC,EAAgB,eAAAC,EAAa,SAAAC,MAAa,SAE3D,OAAS,0BAAAC,MAA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mBA9ByB,CAAC,CAC1B,MAAAD,CACF,IAGO,CACL,KAAM,CAAE,WAAAC,EAAY,cAAAH,CAAc,EAAIE,EACtC,OAAOf,EACJ,qBAAqB,EACrB,mBAAmBgB,EAAYH,CAAa,CACjD,EAqBE,kBAnBwB,CAAC,CACzB,MAAAE,CACF,IAGO,CACL,KAAM,CAAE,WAAAC,EAAY,cAAAC,CAAc,EAAIF,EAChCG,EAAmBlB,EACtB,wBAAwB,EACxB,kBAAkBgB,EAAYC,CAAa,EAC9C,OAAO,IAAIrB,EAA2BI,EAAa,CACjD,WAAYkB,CACd,CAAC,EAAE,IAAI,CACT,EAOE,sBAAuB,IAAMlB,EAAY,sBAAsB,EAC/D,sBAAwBmB,GACtBnB,EAAY,sBAAsBmB,CAAK,CAC3C,CACF,CACF",
4
+ "sourcesContent": ["import { Left, Right } from \"purify-ts\";\nimport { assign, fromObservable, fromPromise, setup } from \"xstate\";\n\nimport { isSuccessCommandResult } from \"@api/command/model/CommandResult\";\nimport {\n GetOsVersionCommand,\n type GetOsVersionResponse,\n} from \"@api/command/os/GetOsVersionCommand\";\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 { type StateMachineTypes } from \"@api/device-action/xstate-utils/StateMachineTypes\";\nimport {\n type DeviceActionStateMachine,\n XStateDeviceAction,\n} from \"@api/device-action/xstate-utils/XStateDeviceAction\";\nimport {\n type DeviceSessionState,\n DeviceSessionStateType,\n} from \"@api/device-session/DeviceSessionState\";\nimport { ConnectToSecureChannelTask } from \"@api/secure-channel/task/ConnectToSecureChannelTask\";\nimport { SecureChannelEventType } from \"@api/secure-channel/task/types\";\nimport { type Input } from \"@api/secure-channel/types\";\nimport { type DeviceVersion } from \"@internal/manager-api/model/Device\";\nimport { type FinalFirmware } from \"@internal/manager-api/model/Firmware\";\n\nimport {\n installedAppResultGuard,\n type ListInstalledAppsDAError,\n type ListInstalledAppsDAInput,\n type ListInstalledAppsDAIntermediateValue,\n type ListInstalledAppsDAOutput,\n type ListInstalledAppsStateMachineInternalState,\n type MachineDependencies,\n} from \"./types\";\n\nexport class ListInstalledAppsDeviceAction extends XStateDeviceAction<\n ListInstalledAppsDAOutput,\n ListInstalledAppsDAInput,\n ListInstalledAppsDAError,\n ListInstalledAppsDAIntermediateValue,\n ListInstalledAppsStateMachineInternalState\n> {\n override makeStateMachine(\n internalApi: InternalApi,\n ): DeviceActionStateMachine<\n ListInstalledAppsDAOutput,\n ListInstalledAppsDAInput,\n ListInstalledAppsDAError,\n ListInstalledAppsDAIntermediateValue,\n ListInstalledAppsStateMachineInternalState\n > {\n type types = StateMachineTypes<\n ListInstalledAppsDAOutput,\n ListInstalledAppsDAInput,\n ListInstalledAppsDAError,\n ListInstalledAppsDAIntermediateValue,\n ListInstalledAppsStateMachineInternalState\n >;\n\n const {\n getOsVersion,\n getDeviceVersion,\n getFirmwareVersion,\n listInstalledApps,\n getDeviceSessionState,\n setDeviceSessionState,\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\n return setup({\n types: {\n input: {} as types[\"input\"],\n context: {} as types[\"context\"],\n output: {} as types[\"output\"],\n },\n actors: {\n goToDashboard: goToDashboardMachine,\n getOsVersion: fromPromise(getOsVersion),\n getDeviceVersion: fromPromise(getDeviceVersion),\n getFirmwareVersion: fromPromise(getFirmwareVersion),\n listInstalledApps: fromObservable(listInstalledApps),\n },\n guards: {\n hasError: (_) => _.context._internalState.error !== null,\n },\n actions: {\n assignErrorFromEvent: assign({\n _internalState: (_) => ({\n ..._.context._internalState,\n error: _.event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sKMlQcf1NBcFVdlmPs9wJNVhrjD9E3GiFmStbz6mmtrhijTaFu4tZRJMSZzJCqNnyS9x5m2DRDoU2qv1osslza-ybvUNwg02DRLFi+YZnbSx4JE5sJO8Xc3CsWZMMckbp0-Bkf1B1B-2unTiokuxWGlJULHWWwOzGcymwMKnULEuzRn+vLCfw9z6M88nBR2VLRWQ6xxR0GxRhRpsb2fNYjDcXFZLxo7FKBgiPMwMnmNain2rGDiD01PdUs0NVu0EtUtq8KydginV1YBsbTQAZQAV2oWhYHgfXtJFsxtGsXbuMsCPdh7bjPG8AkNFi70-B50a+eTABRD4vmF3Tg88UZd3DyO1pWDj9wlCwLFMDQ+1xcdwlCIA */\n id: \"ListInstalledAppsDeviceAction\",\n initial: \"DeviceReady\",\n context: (_) => {\n return {\n input: {\n unlockTimeout: _.input.unlockTimeout,\n },\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.None,\n },\n _internalState: {\n error: null,\n getOsVersionResponse: null,\n deviceVersion: null,\n firmwareVersion: null,\n result: { installedApps: [] },\n },\n };\n },\n states: {\n DeviceReady: {\n always: {\n target: \"GoToDashboard\",\n },\n },\n GoToDashboard: {\n invoke: {\n id: \"goToDashboard\",\n src: \"goToDashboard\",\n input: (_) => ({\n unlockTimeout: _.context.input.unlockTimeout,\n }),\n onSnapshot: {\n actions: assign({\n intermediateValue: (_) => ({\n ..._.context.intermediateValue,\n requiredUserInteraction:\n _.event.snapshot.context.intermediateValue\n .requiredUserInteraction,\n }),\n }),\n },\n onDone: {\n target: \"GoToDashboardCheck\",\n actions: assign({\n _internalState: (_) =>\n _.event.output.caseOf<ListInstalledAppsStateMachineInternalState>(\n {\n Right: () => _.context._internalState,\n Left: (error) => ({\n ..._.context._internalState,\n error,\n }),\n },\n ),\n }),\n },\n onError: {\n target: \"Error\",\n actions: \"assignErrorFromEvent\",\n },\n },\n },\n GoToDashboardCheck: {\n always: [\n {\n target: \"Error\",\n guard: \"hasError\",\n },\n {\n target: \"GetOsVersion\",\n },\n ],\n },\n GetOsVersion: {\n invoke: {\n id: \"getOsVersion\",\n src: \"getOsVersion\",\n input: (_) => undefined,\n onDone: {\n target: \"GetOsVersionCheck\",\n actions: assign({\n _internalState: (_) => {\n if (isSuccessCommandResult(_.event.output)) {\n const currentState: DeviceSessionState =\n getDeviceSessionState();\n const isSecureConnectionAllowed =\n _.event.output.data.secureElementFlags\n .isSecureConnectionAllowed;\n if (\n currentState.sessionStateType !==\n DeviceSessionStateType.Connected\n ) {\n setDeviceSessionState({\n ...currentState,\n isSecureConnectionAllowed,\n });\n }\n return {\n ..._.context._internalState,\n getOsVersionResponse: _.event.output.data,\n };\n }\n return {\n ..._.context._internalState,\n error: _.event.output.error,\n };\n },\n }),\n },\n },\n },\n GetOsVersionCheck: {\n always: [\n {\n target: \"Error\",\n guard: \"hasError\",\n },\n {\n target: \"GetDeviceVersion\",\n },\n ],\n },\n GetDeviceVersion: {\n invoke: {\n id: \"getDeviceVersion\",\n src: \"getDeviceVersion\",\n input: (_) => ({\n deviceInfo: _.context._internalState.getOsVersionResponse!,\n }),\n onDone: {\n target: \"GetDeviceVersionCheck\",\n actions: assign({\n _internalState: (_) =>\n _.event.output.caseOf<ListInstalledAppsStateMachineInternalState>(\n {\n Right: (deviceVersion) => ({\n ..._.context._internalState,\n deviceVersion,\n }),\n Left: (error) => ({\n ..._.context._internalState,\n error,\n }),\n },\n ),\n }),\n },\n onError: {\n target: \"Error\",\n actions: \"assignErrorFromEvent\",\n },\n },\n },\n GetDeviceVersionCheck: {\n always: [\n {\n target: \"Error\",\n guard: \"hasError\",\n },\n { target: \"GetFirmwareVersion\" },\n ],\n },\n GetFirmwareVersion: {\n invoke: {\n id: \"getFirmwareVersion\",\n src: \"getFirmwareVersion\",\n input: (_) => ({\n deviceInfo: _.context._internalState.getOsVersionResponse!,\n deviceVersion: _.context._internalState.deviceVersion!,\n }),\n onDone: {\n target: \"GetFirmwareVersionCheck\",\n actions: assign({\n _internalState: (_) =>\n _.event.output.caseOf<ListInstalledAppsStateMachineInternalState>(\n {\n Right: (firmwareVersion) => ({\n ..._.context._internalState,\n firmwareVersion,\n }),\n Left: (error) => ({\n ..._.context._internalState,\n error,\n }),\n },\n ),\n }),\n },\n onError: {\n target: \"Error\",\n actions: \"assignErrorFromEvent\",\n },\n },\n },\n GetFirmwareVersionCheck: {\n always: [\n {\n target: \"Error\",\n guard: \"hasError\",\n },\n { target: \"ListInstalledApps\" },\n ],\n },\n ListInstalledApps: {\n invoke: {\n id: \"listInstalledApps\",\n src: \"listInstalledApps\",\n input: (_) => ({\n deviceInfo: _.context._internalState.getOsVersionResponse!,\n finalFirmware: _.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 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 result: {\n installedApps: _.event.snapshot.context.payload,\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: \"Success\",\n },\n onError: {\n target: \"Error\",\n actions: \"assignErrorFromEvent\",\n },\n },\n },\n ListInstalledAppsCheck: {\n always: [\n {\n target: \"Error\",\n guard: \"hasError\",\n },\n {\n target: \"Success\",\n },\n ],\n },\n Success: {\n type: \"final\",\n },\n Error: {\n type: \"final\",\n },\n },\n output: (_) => {\n if (_.context._internalState.error) {\n return Left(_.context._internalState.error);\n } else {\n return Right(_.context._internalState.result);\n }\n },\n });\n }\n\n extractDependencies(internalApi: InternalApi): MachineDependencies {\n const getOsVersion = () =>\n internalApi.sendCommand(new GetOsVersionCommand());\n\n const getDeviceVersion = ({\n input,\n }: Input<{ deviceInfo: GetOsVersionResponse }>) => {\n const { deviceInfo } = input;\n return internalApi.getManagerApiService().getDeviceVersion(deviceInfo);\n };\n\n const getFirmwareVersion = ({\n input,\n }: Input<{\n deviceInfo: GetOsVersionResponse;\n deviceVersion: DeviceVersion;\n }>) => {\n const { deviceInfo, deviceVersion } = input;\n return internalApi\n .getManagerApiService()\n .getFirmwareVersion(deviceInfo, deviceVersion);\n };\n\n const listInstalledApps = ({\n input,\n }: Input<{\n deviceInfo: GetOsVersionResponse;\n finalFirmware: FinalFirmware;\n }>) => {\n const { deviceInfo, finalFirmware } = input;\n const eitherConnection = internalApi\n .getSecureChannelService()\n .listInstalledApps(deviceInfo, finalFirmware);\n return new ConnectToSecureChannelTask(internalApi, {\n connection: eitherConnection,\n }).run();\n };\n\n return {\n getOsVersion,\n getDeviceVersion,\n getFirmwareVersion,\n listInstalledApps,\n getDeviceSessionState: () => internalApi.getDeviceSessionState(),\n setDeviceSessionState: (state) =>\n internalApi.setDeviceSessionState(state),\n };\n }\n}\n"],
5
+ "mappings": "AAAA,OAAS,QAAAA,EAAM,SAAAC,MAAa,YAC5B,OAAS,UAAAC,EAAQ,kBAAAC,EAAgB,eAAAC,EAAa,SAAAC,MAAa,SAE3D,OAAS,0BAAAC,MAA8B,mCACvC,OACE,uBAAAC,MAEK,sCAEP,OAAS,2BAAAC,MAA+B,mDACxC,OAAS,6BAAAC,MAAiC,8BAC1C,OAAS,6BAAAC,MAAiC,gEAE1C,OAEE,sBAAAC,MACK,qDACP,OAEE,0BAAAC,MACK,yCACP,OAAS,8BAAAC,MAAkC,sDAC3C,OAAS,0BAAAC,MAA8B,iCAKvC,OACE,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,OAAOf,EACJ,qBAAqB,EACrB,mBAAmBgB,EAAYH,CAAa,CACjD,EAqBE,kBAnBwB,CAAC,CACzB,MAAAE,CACF,IAGO,CACL,KAAM,CAAE,WAAAC,EAAY,cAAAC,CAAc,EAAIF,EAChCG,EAAmBlB,EACtB,wBAAwB,EACxB,kBAAkBgB,EAAYC,CAAa,EAC9C,OAAO,IAAIrB,EAA2BI,EAAa,CACjD,WAAYkB,CACd,CAAC,EAAE,IAAI,CACT,EAOE,sBAAuB,IAAMlB,EAAY,sBAAsB,EAC/D,sBAAwBmB,GACtBnB,EAAY,sBAAsBmB,CAAK,CAC3C,CACF,CACF",
6
6
  "names": ["Left", "Right", "assign", "fromObservable", "fromPromise", "setup", "isSuccessCommandResult", "GetOsVersionCommand", "UserInteractionRequired", "DEFAULT_UNLOCK_TIMEOUT_MS", "GoToDashboardDeviceAction", "XStateDeviceAction", "DeviceSessionStateType", "ConnectToSecureChannelTask", "SecureChannelEventType", "installedAppResultGuard", "ListInstalledAppsDeviceAction", "internalApi", "getOsVersion", "getDeviceVersion", "getFirmwareVersion", "listInstalledApps", "getDeviceSessionState", "setDeviceSessionState", "unlockTimeout", "goToDashboardMachine", "_", "error", "currentState", "isSecureConnectionAllowed", "deviceVersion", "firmwareVersion", "input", "deviceInfo", "finalFirmware", "eitherConnection", "state"]
7
7
  }
@@ -1,2 +1,2 @@
1
- function r(t){return Array.isArray(t)&&t.every(e=>typeof e=="object"&&e!==null&&"flags"in e&&"hash"in e&&"hash_code_data"in e&&"name"in e&&typeof e.flags=="number"&&typeof e.hash=="string"&&typeof e.hash_code_data=="string"&&typeof e.name=="string")}export{r as installedAppResultGuard};
1
+ function t(r){return Array.isArray(r)&&r.every(e=>typeof e=="object"&&e!==null&&"flags"in e&&"hash"in e&&"hash_code_data"in e&&"name"in e&&typeof e.flags=="number"&&typeof e.hash=="string"&&typeof e.hash_code_data=="string"&&typeof e.name=="string")}export{t as installedAppResultGuard};
2
2
  //# sourceMappingURL=types.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../../../../src/api/secure-channel/device-action/ListInstalledApps/types.ts"],
4
- "sourcesContent": ["import { type EitherAsync } from \"purify-ts\";\nimport { type Observable } from \"rxjs\";\n\nimport { type CommandErrorResult } from \"@api/command/model/CommandResult\";\nimport {\n type GetOsVersionCommandResult,\n type GetOsVersionResponse,\n} from \"@api/command/os/GetOsVersionCommand\";\nimport { type DeviceActionState } from \"@api/device-action/model/DeviceActionState\";\nimport { type UserInteractionRequired } from \"@api/device-action/model/UserInteractionRequired\";\nimport { type UnknownDAError } from \"@api/device-action/os/Errors\";\nimport {\n type GoToDashboardDAError,\n type GoToDashboardDAInput,\n} from \"@api/device-action/os/GoToDashboard/types\";\nimport { type DeviceSessionState } from \"@api/device-session/DeviceSessionState\";\nimport { type SecureChannelEvent } from \"@api/secure-channel/task/types\";\nimport { type Input } from \"@api/secure-channel/types\";\nimport { type DeviceVersion } from \"@internal/manager-api/model/Device\";\nimport { type HttpFetchApiError } from \"@internal/manager-api/model/Errors\";\nimport { type FinalFirmware } from \"@internal/manager-api/model/Firmware\";\n\nexport type ListInstalledAppsDAOutput = {\n installedApps: Array<InstalledApp>;\n};\n\nexport type ListInstalledAppsDAInput = GoToDashboardDAInput;\n\nexport type ListInstalledAppsDAError =\n | CommandErrorResult[\"error\"]\n | GoToDashboardDAError\n | HttpFetchApiError\n | UnknownDAError;\n\nexport type ListInstalledAppsDARequiredInteraction =\n | UserInteractionRequired.None\n | UserInteractionRequired.UnlockDevice\n | UserInteractionRequired.AllowSecureConnection;\n\nexport type ListInstalledAppsDAIntermediateValue = {\n requiredUserInteraction: ListInstalledAppsDARequiredInteraction;\n};\n\nexport type ListInstalledAppsDAState = DeviceActionState<\n ListInstalledAppsDAOutput,\n ListInstalledAppsDAError,\n ListInstalledAppsDAIntermediateValue\n>;\n\nexport type ListInstalledAppsStateMachineInternalState = {\n error: ListInstalledAppsDAError | null;\n result: { installedApps: Array<InstalledApp> };\n getOsVersionResponse: GetOsVersionResponse | null;\n deviceVersion: DeviceVersion | null;\n firmwareVersion: FinalFirmware | null;\n};\n\nexport type MachineDependencies = {\n getOsVersion: () => Promise<GetOsVersionCommandResult>;\n getDeviceVersion: (\n args: Input<{ deviceInfo: GetOsVersionResponse }>,\n ) => EitherAsync<HttpFetchApiError, DeviceVersion>;\n getFirmwareVersion: (\n args: Input<{\n deviceInfo: GetOsVersionResponse;\n deviceVersion: DeviceVersion;\n }>,\n ) => EitherAsync<HttpFetchApiError, FinalFirmware>;\n listInstalledApps: (\n args: Input<{\n deviceInfo: GetOsVersionResponse;\n finalFirmware: FinalFirmware;\n }>,\n ) => Observable<SecureChannelEvent>;\n getDeviceSessionState: () => DeviceSessionState;\n setDeviceSessionState: (state: DeviceSessionState) => DeviceSessionState;\n};\n\nexport type InstalledApp = {\n flags: number;\n hash: string;\n hash_code_data: string;\n name: string;\n};\n\nexport function installedAppResultGuard(\n value: unknown,\n): value is ListInstalledAppsDAOutput[\"installedApps\"] {\n return (\n Array.isArray(value) &&\n value.every(\n (item) =>\n typeof item === \"object\" &&\n item !== null &&\n \"flags\" in item &&\n \"hash\" in item &&\n \"hash_code_data\" in item &&\n \"name\" in item &&\n typeof item.flags === \"number\" &&\n typeof item.hash === \"string\" &&\n typeof item.hash_code_data === \"string\" &&\n typeof item.name === \"string\",\n )\n );\n}\n"],
5
- "mappings": "AAqFO,SAASA,EACdC,EACqD,CACrD,OACE,MAAM,QAAQA,CAAK,GACnBA,EAAM,MACHC,GACC,OAAOA,GAAS,UAChBA,IAAS,MACT,UAAWA,GACX,SAAUA,GACV,mBAAoBA,GACpB,SAAUA,GACV,OAAOA,EAAK,OAAU,UACtB,OAAOA,EAAK,MAAS,UACrB,OAAOA,EAAK,gBAAmB,UAC/B,OAAOA,EAAK,MAAS,QACzB,CAEJ",
4
+ "sourcesContent": ["import { type EitherAsync } from \"purify-ts\";\nimport { type Observable } from \"rxjs\";\n\nimport { type CommandErrorResult } from \"@api/command/model/CommandResult\";\nimport {\n type GetOsVersionCommandResult,\n type GetOsVersionResponse,\n} from \"@api/command/os/GetOsVersionCommand\";\nimport { type DeviceActionState } from \"@api/device-action/model/DeviceActionState\";\nimport { type UserInteractionRequired } from \"@api/device-action/model/UserInteractionRequired\";\nimport { type UnknownDAError } from \"@api/device-action/os/Errors\";\nimport {\n type GoToDashboardDAError,\n type GoToDashboardDAInput,\n} from \"@api/device-action/os/GoToDashboard/types\";\nimport { type DeviceSessionState } from \"@api/device-session/DeviceSessionState\";\nimport { type SecureChannelEvent } from \"@api/secure-channel/task/types\";\nimport { type Input } from \"@api/secure-channel/types\";\nimport { type DeviceVersion } from \"@internal/manager-api/model/Device\";\nimport { type HttpFetchApiError } from \"@internal/manager-api/model/Errors\";\nimport { type FinalFirmware } from \"@internal/manager-api/model/Firmware\";\nimport type { SecureChannelDAErrors } from \"@internal/secure-channel/model/Errors\";\n\nexport type ListInstalledAppsDAOutput = {\n installedApps: Array<InstalledApp>;\n};\n\nexport type ListInstalledAppsDAInput = GoToDashboardDAInput;\n\nexport type ListInstalledAppsDAError =\n | CommandErrorResult[\"error\"]\n | GoToDashboardDAError\n | HttpFetchApiError\n | SecureChannelDAErrors\n | UnknownDAError;\n\nexport type ListInstalledAppsDARequiredInteraction =\n | UserInteractionRequired.None\n | UserInteractionRequired.UnlockDevice\n | UserInteractionRequired.AllowSecureConnection;\n\nexport type ListInstalledAppsDAIntermediateValue = {\n requiredUserInteraction: ListInstalledAppsDARequiredInteraction;\n};\n\nexport type ListInstalledAppsDAState = DeviceActionState<\n ListInstalledAppsDAOutput,\n ListInstalledAppsDAError,\n ListInstalledAppsDAIntermediateValue\n>;\n\nexport type ListInstalledAppsStateMachineInternalState = {\n error: ListInstalledAppsDAError | null;\n result: { installedApps: Array<InstalledApp> };\n getOsVersionResponse: GetOsVersionResponse | null;\n deviceVersion: DeviceVersion | null;\n firmwareVersion: FinalFirmware | null;\n};\n\nexport type MachineDependencies = {\n getOsVersion: () => Promise<GetOsVersionCommandResult>;\n getDeviceVersion: (\n args: Input<{ deviceInfo: GetOsVersionResponse }>,\n ) => EitherAsync<HttpFetchApiError, DeviceVersion>;\n getFirmwareVersion: (\n args: Input<{\n deviceInfo: GetOsVersionResponse;\n deviceVersion: DeviceVersion;\n }>,\n ) => EitherAsync<HttpFetchApiError, FinalFirmware>;\n listInstalledApps: (\n args: Input<{\n deviceInfo: GetOsVersionResponse;\n finalFirmware: FinalFirmware;\n }>,\n ) => Observable<SecureChannelEvent>;\n getDeviceSessionState: () => DeviceSessionState;\n setDeviceSessionState: (state: DeviceSessionState) => DeviceSessionState;\n};\n\nexport type InstalledApp = {\n flags: number;\n hash: string;\n hash_code_data: string;\n name: string;\n};\n\nexport function installedAppResultGuard(\n value: unknown,\n): value is ListInstalledAppsDAOutput[\"installedApps\"] {\n return (\n Array.isArray(value) &&\n value.every(\n (item) =>\n typeof item === \"object\" &&\n item !== null &&\n \"flags\" in item &&\n \"hash\" in item &&\n \"hash_code_data\" in item &&\n \"name\" in item &&\n typeof item.flags === \"number\" &&\n typeof item.hash === \"string\" &&\n typeof item.hash_code_data === \"string\" &&\n typeof item.name === \"string\",\n )\n );\n}\n"],
5
+ "mappings": "AAuFO,SAASA,EACdC,EACqD,CACrD,OACE,MAAM,QAAQA,CAAK,GACnBA,EAAM,MACHC,GACC,OAAOA,GAAS,UAChBA,IAAS,MACT,UAAWA,GACX,SAAUA,GACV,mBAAoBA,GACpB,SAAUA,GACV,OAAOA,EAAK,OAAU,UACtB,OAAOA,EAAK,MAAS,UACrB,OAAOA,EAAK,gBAAmB,UAC/B,OAAOA,EAAK,MAAS,QACzB,CAEJ",
6
6
  "names": ["installedAppResultGuard", "value", "item"]
7
7
  }
@@ -1,2 +1,2 @@
1
- import{Left as D,Right as v}from"purify-ts";import{assign as a,fromObservable as I,fromPromise as d,setup as f}from"xstate";import{isSuccessCommandResult as y}from"../../../command/model/CommandResult";import{GetOsVersionCommand as E}from"../../../command/os/GetOsVersionCommand";import{UserInteractionRequired as p}from"../../../device-action/model/UserInteractionRequired";import{DEFAULT_UNLOCK_TIMEOUT_MS as U}from"../../../device-action/os/Const";import{UnknownDAError as A}from"../../../device-action/os/Errors";import{GoToDashboardDeviceAction as x}from"../../../device-action/os/GoToDashboard/GoToDashboardDeviceAction";import{XStateDeviceAction as O}from"../../../device-action/xstate-utils/XStateDeviceAction";import{DeviceSessionStateType as m}from"../../../device-session/DeviceSessionState";import{ListInstalledAppsDeviceAction as V}from"../../../secure-channel/device-action/ListInstalledApps/ListInstalledAppsDeviceAction";import{ConnectToSecureChannelTask as T}from"../../../secure-channel/task/ConnectToSecureChannelTask";import{SecureChannelEventType as S}from"../../../secure-channel/task/types";class P extends O{makeStateMachine(n){const{getOsVersion:l,getAppsByHash:c,uninstallApp:u,getDeviceSessionState:r,setDeviceSessionState:s}=this.extractDependencies(n),o=this.input.unlockTimeout??U,i=new x({input:{unlockTimeout:o}}).makeStateMachine(n),h=new V({input:{unlockTimeout:o}}).makeStateMachine(n);return f({types:{input:{},context:{},output:{}},actors:{listInstalledApps:h,goToDashboard:i,getOsVersion:d(l),getAppsByHash:d(c),uninstallApp:I(u)},guards:{hasError:t=>t.context._internalState.error!==null,appNotInstalled:t=>!t.context._internalState.installedApps.some(e=>e.name===t.context.input.appName),appNotFound:t=>t.context._internalState.appList.findIndex(e=>e?.versionName===t.context.input.appName)===-1,isDepAppOfOther:t=>t.context._internalState.appList.some(e=>e?.parentName===t.context.input.appName)},actions:{assignErrorFromEvent:a({_internalState:t=>({...t.context._internalState,error:t.event.error})}),assignAppNotFound:a({_internalState:t=>({...t.context._internalState,error:new A("App to uninstall not found in manager API")})}),assignIsDepAppOfOther:a({_internalState:t=>({...t.context._internalState,error:new A("App to uninstall is a dependency of another installed app")})}),cleanupDeviceState:()=>{const t=r();t.sessionStateType!==m.Connected&&s({...t,installedApps:[],appsUpdates:void 0})}}}).createMachine({id:"UninstallAppDeviceAction",initial:"DeviceReady",context:t=>({input:{unlockTimeout:t.input.unlockTimeout,appName:t.input.appName},intermediateValue:{requiredUserInteraction:p.None},_internalState:{error:null,installedApps:[],appList:[],getOsVersionResponse:null}}),states:{DeviceReady:{always:{target:"ListInstalledApps"}},ListInstalledApps:{invoke:{id:"listInstalledApps",src:"listInstalledApps",input:t=>({unlockTimeout:t.context.input.unlockTimeout}),onSnapshot:{actions:a({intermediateValue:t=>({...t.context.intermediateValue,requiredUserInteraction:t.event.snapshot.context.intermediateValue.requiredUserInteraction})})},onDone:{target:"ListInstalledAppsCheck",actions:a({_internalState:t=>t.event.output.caseOf({Right:({installedApps:e})=>({...t.context._internalState,installedApps:e,hasCheckedInstalledApps:!0}),Left:e=>({...t.context._internalState,error:e})})})},onError:{target:"Error",actions:"assignErrorFromEvent"}}},ListInstalledAppsCheck:{always:[{target:"Error",guard:"hasError"},{target:"Success",guard:"appNotInstalled"},{target:"GetAppsByHash"}]},GetAppsByHash:{invoke:{id:"getAppsByHash",src:"getAppsByHash",input:t=>t.context._internalState.installedApps,onDone:{target:"GetAppsByHashCheck",actions:a({_internalState:t=>t.event.output.caseOf({Right:e=>({...t.context._internalState,appList:e}),Left:e=>({...t.context._internalState,error:e})})})},onError:{target:"Error",actions:"assignErrorFromEvent"}}},GetAppsByHashCheck:{always:[{target:"Error",guard:"hasError"},{target:"Error",guard:"appNotFound",actions:"assignAppNotFound"},{target:"Error",guard:"isDepAppOfOther",actions:"assignIsDepAppOfOther"},{target:"GoToDashboard"}]},GoToDashboard:{invoke:{id:"goToDashboard",src:"goToDashboard",input:t=>({unlockTimeout:t.context.input.unlockTimeout}),onSnapshot:{actions:a({intermediateValue:t=>({...t.context.intermediateValue,requiredUserInteraction:t.event.snapshot.context.intermediateValue.requiredUserInteraction})})},onDone:{target:"GoToDashboardCheck",actions:a({_internalState:t=>t.event.output.caseOf({Right:()=>t.context._internalState,Left:e=>({...t.context._internalState,error:e})})})},onError:{target:"Error",actions:"assignErrorFromEvent"}}},GoToDashboardCheck:{always:[{target:"Error",guard:"hasError"},{target:"GetOsVersion"}]},GetOsVersion:{invoke:{id:"getOsVersion",src:"getOsVersion",input:t=>{},onDone:{target:"GetOsVersionCheck",actions:a({_internalState:t=>{if(y(t.event.output)){const e=r(),g=t.event.output.data.secureElementFlags.isSecureConnectionAllowed;return e.sessionStateType!==m.Connected&&s({...e,isSecureConnectionAllowed:g}),{...t.context._internalState,getOsVersionResponse:t.event.output.data}}return{...t.context._internalState,error:t.event.output.error}}})}}},GetOsVersionCheck:{always:[{target:"Error",guard:"hasError"},{target:"UninstallApp"}]},UninstallApp:{invoke:{id:"uninstallApp",src:"uninstallApp",input:t=>({deviceInfo:t.context._internalState.getOsVersionResponse,app:t.context._internalState.appList.find(e=>e?.versionName===t.context.input.appName)}),onSnapshot:{actions:a({intermediateValue:t=>{switch(t.event.snapshot.context?.type){case S.PermissionRequested:return{requiredUserInteraction:p.AllowSecureConnection};case S.PermissionGranted:return{requiredUserInteraction:p.None};default:return{...t.context.intermediateValue}}}})},onDone:{target:"ListInstalledApps",actions:"cleanupDeviceState"},onError:{target:"Error",actions:"assignErrorFromEvent"}}},Success:{type:"final",description:"App uninstalled successfully"},Error:{type:"final"}},output:({context:t})=>t._internalState.error?D(t._internalState.error):v(void 0)})}extractDependencies(n){return{getOsVersion:()=>n.sendCommand(new E),getAppsByHash:({input:r})=>{const s=r.map(o=>o.hash);return n.getManagerApiService().getAppsByHash(s)},uninstallApp:({input:r})=>{const{deviceInfo:s,app:o}=r,i=n.getSecureChannelService().uninstallApp(s,o);return new T(n,{connection:i}).run()},getDeviceSessionState:()=>n.getDeviceSessionState(),setDeviceSessionState:r=>n.setDeviceSessionState(r)}}}export{P as UninstallAppDeviceAction};
1
+ import{Left as D,Right as v}from"purify-ts";import{assign as a,fromObservable as I,fromPromise as A,setup as f}from"xstate";import{isSuccessCommandResult as y}from"../../../command/model/CommandResult";import{GetOsVersionCommand as x}from"../../../command/os/GetOsVersionCommand";import{UserInteractionRequired as p}from"../../../device-action/model/UserInteractionRequired";import{DEFAULT_UNLOCK_TIMEOUT_MS as E}from"../../../device-action/os/Const";import{UnknownDAError as m}from"../../../device-action/os/Errors";import{GoToDashboardDeviceAction as U}from"../../../device-action/os/GoToDashboard/GoToDashboardDeviceAction";import{XStateDeviceAction as O}from"../../../device-action/xstate-utils/XStateDeviceAction";import{DeviceSessionStateType as S}from"../../../device-session/DeviceSessionState";import{ListInstalledAppsDeviceAction as V}from"../../../secure-channel/device-action/ListInstalledApps/ListInstalledAppsDeviceAction";import{ConnectToSecureChannelTask as T}from"../../../secure-channel/task/ConnectToSecureChannelTask";import{SecureChannelEventType as l}from"../../../secure-channel/task/types";class P extends O{makeStateMachine(n){const{getOsVersion:c,getAppsByHash:u,uninstallApp:d,getDeviceSessionState:r,setDeviceSessionState:s}=this.extractDependencies(n),o=this.input.unlockTimeout??E,i=new U({input:{unlockTimeout:o}}).makeStateMachine(n),h=new V({input:{unlockTimeout:o}}).makeStateMachine(n);return f({types:{input:{},context:{},output:{}},actors:{listInstalledApps:h,goToDashboard:i,getOsVersion:A(c),getAppsByHash:A(u),uninstallApp:I(d)},guards:{hasError:t=>t.context._internalState.error!==null,appNotInstalled:t=>!t.context._internalState.installedApps.some(e=>e.name===t.context.input.appName),appNotFound:t=>t.context._internalState.appList.findIndex(e=>e?.versionName===t.context.input.appName)===-1,isDepAppOfOther:t=>t.context._internalState.appList.some(e=>e?.parentName===t.context.input.appName)},actions:{assignErrorFromEvent:a({_internalState:t=>({...t.context._internalState,error:t.event.error})}),assignAppNotFound:a({_internalState:t=>({...t.context._internalState,error:new m("App to uninstall not found in manager API")})}),assignIsDepAppOfOther:a({_internalState:t=>({...t.context._internalState,error:new m("App to uninstall is a dependency of another installed app")})}),cleanupDeviceState:()=>{const t=r();t.sessionStateType!==S.Connected&&s({...t,installedApps:[],appsUpdates:void 0})}}}).createMachine({id:"UninstallAppDeviceAction",initial:"DeviceReady",context:t=>({input:{unlockTimeout:t.input.unlockTimeout,appName:t.input.appName},intermediateValue:{requiredUserInteraction:p.None},_internalState:{error:null,installedApps:[],appList:[],getOsVersionResponse:null}}),states:{DeviceReady:{always:{target:"ListInstalledApps"}},ListInstalledApps:{invoke:{id:"listInstalledApps",src:"listInstalledApps",input:t=>({unlockTimeout:t.context.input.unlockTimeout}),onSnapshot:{actions:a({intermediateValue:t=>({...t.context.intermediateValue,requiredUserInteraction:t.event.snapshot.context.intermediateValue.requiredUserInteraction})})},onDone:{target:"ListInstalledAppsCheck",actions:a({_internalState:t=>t.event.output.caseOf({Right:({installedApps:e})=>({...t.context._internalState,installedApps:e,hasCheckedInstalledApps:!0}),Left:e=>({...t.context._internalState,error:e})})})},onError:{target:"Error",actions:"assignErrorFromEvent"}}},ListInstalledAppsCheck:{always:[{target:"Error",guard:"hasError"},{target:"Success",guard:"appNotInstalled"},{target:"GetAppsByHash"}]},GetAppsByHash:{invoke:{id:"getAppsByHash",src:"getAppsByHash",input:t=>t.context._internalState.installedApps,onDone:{target:"GetAppsByHashCheck",actions:a({_internalState:t=>t.event.output.caseOf({Right:e=>({...t.context._internalState,appList:e}),Left:e=>({...t.context._internalState,error:e})})})},onError:{target:"Error",actions:"assignErrorFromEvent"}}},GetAppsByHashCheck:{always:[{target:"Error",guard:"hasError"},{target:"Error",guard:"appNotFound",actions:"assignAppNotFound"},{target:"Error",guard:"isDepAppOfOther",actions:"assignIsDepAppOfOther"},{target:"GoToDashboard"}]},GoToDashboard:{invoke:{id:"goToDashboard",src:"goToDashboard",input:t=>({unlockTimeout:t.context.input.unlockTimeout}),onSnapshot:{actions:a({intermediateValue:t=>({...t.context.intermediateValue,requiredUserInteraction:t.event.snapshot.context.intermediateValue.requiredUserInteraction})})},onDone:{target:"GoToDashboardCheck",actions:a({_internalState:t=>t.event.output.caseOf({Right:()=>t.context._internalState,Left:e=>({...t.context._internalState,error:e})})})},onError:{target:"Error",actions:"assignErrorFromEvent"}}},GoToDashboardCheck:{always:[{target:"Error",guard:"hasError"},{target:"GetOsVersion"}]},GetOsVersion:{invoke:{id:"getOsVersion",src:"getOsVersion",input:t=>{},onDone:{target:"GetOsVersionCheck",actions:a({_internalState:t=>{if(y(t.event.output)){const e=r(),g=t.event.output.data.secureElementFlags.isSecureConnectionAllowed;return e.sessionStateType!==S.Connected&&s({...e,isSecureConnectionAllowed:g}),{...t.context._internalState,getOsVersionResponse:t.event.output.data}}return{...t.context._internalState,error:t.event.output.error}}})}}},GetOsVersionCheck:{always:[{target:"Error",guard:"hasError"},{target:"UninstallApp"}]},UninstallApp:{invoke:{id:"uninstallApp",src:"uninstallApp",input:t=>({deviceInfo:t.context._internalState.getOsVersionResponse,app:t.context._internalState.appList.find(e=>e?.versionName===t.context.input.appName)}),onSnapshot:{actions:a({intermediateValue:t=>{switch(t.event.snapshot.context?.type){case l.PermissionRequested:return{requiredUserInteraction:p.AllowSecureConnection};case l.PermissionGranted:return{requiredUserInteraction:p.None};default:return{...t.context.intermediateValue}}},_internalState:t=>t.event.snapshot.context?.type===l.Error?{...t.context._internalState,error:t.event.snapshot.context.error.mapDAErrors()}:t.context._internalState})},onDone:{target:"ListInstalledApps",actions:"cleanupDeviceState"},onError:{target:"Error",actions:"assignErrorFromEvent"}}},Success:{type:"final",description:"App uninstalled successfully"},Error:{type:"final"}},output:({context:t})=>t._internalState.error?D(t._internalState.error):v(void 0)})}extractDependencies(n){return{getOsVersion:()=>n.sendCommand(new x),getAppsByHash:({input:r})=>{const s=r.map(o=>o.hash);return n.getManagerApiService().getAppsByHash(s)},uninstallApp:({input:r})=>{const{deviceInfo:s,app:o}=r,i=n.getSecureChannelService().uninstallApp(s,o);return new T(n,{connection:i}).run()},getDeviceSessionState:()=>n.getDeviceSessionState(),setDeviceSessionState:r=>n.setDeviceSessionState(r)}}}export{P as UninstallAppDeviceAction};
2
2
  //# sourceMappingURL=UninstallAppDeviceAction.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../../../../src/api/secure-channel/device-action/UninstallApp/UninstallAppDeviceAction.ts"],
4
- "sourcesContent": ["import { Left, Right } from \"purify-ts\";\nimport { assign, fromObservable, fromPromise, setup } from \"xstate\";\n\nimport { isSuccessCommandResult } from \"@api/command/model/CommandResult\";\nimport {\n GetOsVersionCommand,\n type GetOsVersionResponse,\n} from \"@api/command/os/GetOsVersionCommand\";\nimport { type InternalApi } from \"@api/device-action/DeviceAction\";\nimport { UserInteractionRequired } from \"@api/device-action/model/UserInteractionRequired\";\nimport { DEFAULT_UNLOCK_TIMEOUT_MS } from \"@api/device-action/os/Const\";\nimport { UnknownDAError } from \"@api/device-action/os/Errors\";\nimport { GoToDashboardDeviceAction } from \"@api/device-action/os/GoToDashboard/GoToDashboardDeviceAction\";\nimport { type StateMachineTypes } from \"@api/device-action/xstate-utils/StateMachineTypes\";\nimport {\n type DeviceActionStateMachine,\n XStateDeviceAction,\n} from \"@api/device-action/xstate-utils/XStateDeviceAction\";\nimport {\n type DeviceSessionState,\n DeviceSessionStateType,\n} from \"@api/device-session/DeviceSessionState\";\nimport { ListInstalledAppsDeviceAction } from \"@api/secure-channel/device-action/ListInstalledApps/ListInstalledAppsDeviceAction\";\nimport { type InstalledApp } 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 Input } from \"@api/secure-channel/types\";\nimport { type Application } from \"@internal/manager-api/model/Application\";\n\nimport {\n type MachineDependencies,\n type UninstallAppDAError,\n type UninstallAppDAInput,\n type UninstallAppDAIntermediateValue,\n type UninstallAppDAOutput,\n type UninstallAppStateMachineInternalState,\n} from \"./types\";\n\nexport class UninstallAppDeviceAction extends XStateDeviceAction<\n UninstallAppDAOutput,\n UninstallAppDAInput,\n UninstallAppDAError,\n UninstallAppDAIntermediateValue,\n UninstallAppStateMachineInternalState\n> {\n override makeStateMachine(\n internalApi: InternalApi,\n ): DeviceActionStateMachine<\n UninstallAppDAOutput,\n UninstallAppDAInput,\n UninstallAppDAError,\n UninstallAppDAIntermediateValue,\n UninstallAppStateMachineInternalState\n > {\n type types = StateMachineTypes<\n UninstallAppDAOutput,\n UninstallAppDAInput,\n UninstallAppDAError,\n UninstallAppDAIntermediateValue,\n UninstallAppStateMachineInternalState\n >;\n\n const {\n getOsVersion,\n getAppsByHash,\n uninstallApp,\n getDeviceSessionState,\n setDeviceSessionState,\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\n const listInstalledAppsMachine = new ListInstalledAppsDeviceAction({\n input: {\n unlockTimeout,\n },\n }).makeStateMachine(internalApi);\n\n return setup({\n types: {\n input: {} as types[\"input\"],\n context: {} as types[\"context\"],\n output: {} as types[\"output\"],\n },\n actors: {\n listInstalledApps: listInstalledAppsMachine,\n goToDashboard: goToDashboardMachine,\n getOsVersion: fromPromise(getOsVersion),\n getAppsByHash: fromPromise(getAppsByHash),\n uninstallApp: fromObservable(uninstallApp),\n },\n guards: {\n hasError: (_) => _.context._internalState.error !== null,\n appNotInstalled: (_) =>\n !_.context._internalState.installedApps.some(\n (app) => app.name === _.context.input.appName,\n ),\n appNotFound: (_) =>\n _.context._internalState.appList.findIndex(\n (app) => app?.versionName === _.context.input.appName,\n ) === -1,\n isDepAppOfOther: (_) =>\n _.context._internalState.appList.some(\n (app) => app?.parentName === _.context.input.appName,\n ),\n },\n actions: {\n assignErrorFromEvent: assign({\n _internalState: (_) => ({\n ..._.context._internalState,\n error: _.event[\"error\"],\n }),\n }),\n assignAppNotFound: assign({\n _internalState: (_) => ({\n ..._.context._internalState,\n error: new UnknownDAError(\n \"App to uninstall not found in manager API\",\n ),\n }),\n }),\n assignIsDepAppOfOther: assign({\n _internalState: (_) => ({\n ..._.context._internalState,\n error: new UnknownDAError(\n \"App to uninstall is a dependency of another installed app\",\n ),\n }),\n }),\n cleanupDeviceState: () => {\n // After app successful uninstallation, cleanup the device session state\n // to force fetching the new device state when required\n const state = getDeviceSessionState();\n if (state.sessionStateType !== DeviceSessionStateType.Connected) {\n setDeviceSessionState({\n ...state,\n installedApps: [],\n appsUpdates: undefined,\n });\n }\n },\n },\n }).createMachine({\n /** @xstate-layout N4IgpgJg5mDOIC5QEkB2sAuBDANjgggA6EAiYAbgJYDGY+1GlA9qgHRlW0BKYWEAngGIA2gAYAuolCEmsSoxZSQAD0QBGAJyjWADgDsAFg0A2HSb2iArMbUBmADQh+iAExrjrS6KuWNtte7Glga2AL6hjmiYuATEHDR0DMxsAOJMACpMJFiwABYARkxYAE4QghAsYKyUqORMANZVUBlZOQVFpWKSSCAycgqoSqoIxi6WrKJq1rYGNgaiBrOOzgi2th5qonouorYuo9YBBuGR6Nh4RKQUCfQDrGmZ2XmFJWVgxcVMxayEOFgYADMvgBbVjNR5tF6dCRKPryZJDRAHCZTYwzOYLJZOdR6DSeFy2MwBPaaXzGE4gKLnWJXTiJO4PVrPDoQADCuTA1HqIhhPThA0RCE2XlY+0semMomMBgsOjMyyRoh0E28BmClhc+0mxwilLOMUu8Vot2S9xaT3ar3ZnO5wjU3Wksnhih6w2F2jFEqlMqV8uxq0stlYgTlGg02wJOjCuqpBri12NSRY9zAGAA8rAAGrvOQscqVaq1BpNVMZ7PFXOoLqwp0C13qDVqVhaIK+HSifazNQK1YuPHGLTWQxabaLSwU2MXeN0k3JlKlrM55LWrk8h29WsI+tCjRqAysebSvY6TWagw6HvnvFeDsaGX6UR+Wx6Cf6qe0m5J1IL8uVle2+0a36LdQDdXd90PEIXBPU9zx7dFWD0LwxgMHYFkmckYzfGkjXpU15wwS4ABlKEwfNUCqGo6kaFNCOIEjMGrPlNxdUDXFscVRR0VFxXDJCL39PYgxcPRbD8NQ9DUOV9BfLDonfXDZ2-OjCAYjB-zXIDnUGbcRIkxDNEfEIwwCFx4MDYNjFMMxw01Qlo1OeScITPC51TYjSPUjlVztdd+RAlRXEkvQDK0O8xN3NQzP9HR9xvKxCT0E9Jj0WTdVQJgIDgJRJ2cmcvy0us2IQABaYwezK18nMNFylPYFyeD4FZHWA1jAoQVCezccYb02JDDPcQkqupGr8oZc1IRZQqAuGaDxhMfQxjsKMlQcf1NBcFVdlmPs9wJNVhrjD9E3GiFmStbz6mmtrhijTaFu4tZRJMSZzJCqNnyS9x5m2DRDoU2qv1osslza-ybvUNwg02DRLFi+YZnbSx4JE5sJO8Xc3CsWZMMckbp0-Bkf1B1B-2unTiokuxWGlJULHWWwOzGcymwMKnULEuzRn+vLCfw9z6M88nBR2VLRWQ6xxR0GxRhRpsb2fNYjDcXFZLxo7FKBgiPMwMnmNain2rGDiD01PdUs0NVu0EtUtq8KydginV1YBsbTQAZQAV2oWhYHgfXtJFsxtGsXbuMsCPdh7bjPG8AkNFi70-B50a+eTABRD4vmF3Tg88UZd3DyO1pWDj9wlCwLFMDQ+1xcdwlCIA */\n id: \"UninstallAppDeviceAction\",\n initial: \"DeviceReady\",\n context: (_) => {\n return {\n input: {\n unlockTimeout: _.input.unlockTimeout,\n appName: _.input.appName,\n },\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.None,\n },\n _internalState: {\n error: null,\n installedApps: [],\n appList: [],\n getOsVersionResponse: null,\n },\n };\n },\n states: {\n DeviceReady: {\n always: {\n target: \"ListInstalledApps\",\n },\n },\n ListInstalledApps: {\n invoke: {\n id: \"listInstalledApps\",\n src: \"listInstalledApps\",\n input: (_) => ({\n unlockTimeout: _.context.input.unlockTimeout,\n }),\n onSnapshot: {\n actions: assign({\n intermediateValue: (_) => ({\n ..._.context.intermediateValue,\n requiredUserInteraction:\n _.event.snapshot.context.intermediateValue\n .requiredUserInteraction,\n }),\n }),\n },\n onDone: {\n target: \"ListInstalledAppsCheck\",\n actions: assign({\n _internalState: (_) =>\n _.event.output.caseOf<UninstallAppStateMachineInternalState>({\n Right: ({ installedApps }) => ({\n ..._.context._internalState,\n installedApps,\n hasCheckedInstalledApps: true,\n }),\n Left: (error) => ({\n ..._.context._internalState,\n error,\n }),\n }),\n }),\n },\n onError: {\n target: \"Error\",\n actions: \"assignErrorFromEvent\",\n },\n },\n },\n ListInstalledAppsCheck: {\n always: [\n {\n target: \"Error\",\n guard: \"hasError\",\n },\n {\n target: \"Success\",\n guard: \"appNotInstalled\",\n },\n {\n target: \"GetAppsByHash\",\n },\n ],\n },\n GetAppsByHash: {\n invoke: {\n id: \"getAppsByHash\",\n src: \"getAppsByHash\",\n input: (_) => _.context._internalState.installedApps!,\n onDone: {\n target: \"GetAppsByHashCheck\",\n actions: assign({\n _internalState: (_) =>\n _.event.output.caseOf({\n Right: (apps) => ({\n ..._.context._internalState,\n appList: apps,\n }),\n Left: (error) => ({\n ..._.context._internalState,\n error,\n }),\n }),\n }),\n },\n onError: {\n target: \"Error\",\n actions: \"assignErrorFromEvent\",\n },\n },\n },\n GetAppsByHashCheck: {\n always: [\n {\n target: \"Error\",\n guard: \"hasError\",\n },\n {\n target: \"Error\",\n guard: \"appNotFound\",\n actions: \"assignAppNotFound\",\n },\n {\n target: \"Error\",\n guard: \"isDepAppOfOther\",\n actions: \"assignIsDepAppOfOther\",\n },\n {\n target: \"GoToDashboard\",\n },\n ],\n },\n GoToDashboard: {\n invoke: {\n id: \"goToDashboard\",\n src: \"goToDashboard\",\n input: (_) => ({\n unlockTimeout: _.context.input.unlockTimeout,\n }),\n onSnapshot: {\n actions: assign({\n intermediateValue: (_) => ({\n ..._.context.intermediateValue,\n requiredUserInteraction:\n _.event.snapshot.context.intermediateValue\n .requiredUserInteraction,\n }),\n }),\n },\n onDone: {\n target: \"GoToDashboardCheck\",\n actions: assign({\n _internalState: (_) =>\n _.event.output.caseOf<UninstallAppStateMachineInternalState>({\n Right: () => _.context._internalState,\n Left: (error) => ({\n ..._.context._internalState,\n error,\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: \"GetOsVersion\",\n },\n ],\n },\n GetOsVersion: {\n invoke: {\n id: \"getOsVersion\",\n src: \"getOsVersion\",\n input: (_) => undefined,\n onDone: {\n target: \"GetOsVersionCheck\",\n actions: assign({\n _internalState: (_) => {\n if (isSuccessCommandResult(_.event.output)) {\n const currentState: DeviceSessionState =\n getDeviceSessionState();\n const isSecureConnectionAllowed =\n _.event.output.data.secureElementFlags\n .isSecureConnectionAllowed;\n if (\n currentState.sessionStateType !==\n DeviceSessionStateType.Connected\n ) {\n setDeviceSessionState({\n ...currentState,\n isSecureConnectionAllowed,\n });\n }\n return {\n ..._.context._internalState,\n getOsVersionResponse: _.event.output.data,\n };\n }\n return {\n ..._.context._internalState,\n error: _.event.output.error,\n };\n },\n }),\n },\n },\n },\n GetOsVersionCheck: {\n always: [\n {\n target: \"Error\",\n guard: \"hasError\",\n },\n {\n target: \"UninstallApp\",\n },\n ],\n },\n UninstallApp: {\n invoke: {\n id: \"uninstallApp\",\n src: \"uninstallApp\",\n input: (_) => ({\n deviceInfo: _.context._internalState.getOsVersionResponse!,\n app: _.context._internalState.appList.find(\n (app) => app?.versionName === _.context.input.appName,\n )!,\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 return {\n requiredUserInteraction: UserInteractionRequired.None,\n };\n }\n default:\n return {\n ..._.context.intermediateValue,\n };\n }\n },\n }),\n },\n onDone: {\n target: \"ListInstalledApps\",\n actions: \"cleanupDeviceState\",\n },\n onError: {\n target: \"Error\",\n actions: \"assignErrorFromEvent\",\n },\n },\n },\n Success: {\n type: \"final\",\n description: \"App uninstalled successfully\",\n },\n Error: {\n type: \"final\",\n },\n },\n output: ({ context }) =>\n context._internalState.error\n ? Left(context._internalState.error)\n : Right(undefined),\n });\n }\n\n extractDependencies(internalApi: InternalApi): MachineDependencies {\n const getOsVersion = () =>\n internalApi.sendCommand(new GetOsVersionCommand());\n\n const getAppsByHash = ({ input }: Input<InstalledApp[]>) => {\n const appHashes = input.map((app) => app.hash);\n return internalApi.getManagerApiService().getAppsByHash(appHashes);\n };\n\n const uninstallApp = ({\n input,\n }: Input<{\n deviceInfo: GetOsVersionResponse;\n app: Application;\n }>) => {\n const { deviceInfo, app } = input;\n const eitherConnection = internalApi\n .getSecureChannelService()\n .uninstallApp(deviceInfo, app);\n return new ConnectToSecureChannelTask(internalApi, {\n connection: eitherConnection,\n }).run();\n };\n\n return {\n getOsVersion,\n getAppsByHash,\n uninstallApp,\n getDeviceSessionState: () => internalApi.getDeviceSessionState(),\n setDeviceSessionState: (state) =>\n internalApi.setDeviceSessionState(state),\n };\n }\n}\n"],
5
- "mappings": "AAAA,OAAS,QAAAA,EAAM,SAAAC,MAAa,YAC5B,OAAS,UAAAC,EAAQ,kBAAAC,EAAgB,eAAAC,EAAa,SAAAC,MAAa,SAE3D,OAAS,0BAAAC,MAA8B,mCACvC,OACE,uBAAAC,MAEK,sCAEP,OAAS,2BAAAC,MAA+B,mDACxC,OAAS,6BAAAC,MAAiC,8BAC1C,OAAS,kBAAAC,MAAsB,+BAC/B,OAAS,6BAAAC,MAAiC,gEAE1C,OAEE,sBAAAC,MACK,qDACP,OAEE,0BAAAC,MACK,yCACP,OAAS,iCAAAC,MAAqC,oFAE9C,OAAS,8BAAAC,MAAkC,sDAC3C,OAAS,0BAAAC,MAA8B,iCAahC,MAAMC,UAAiCL,CAM5C,CACS,iBACPM,EAOA,CASA,KAAM,CACJ,aAAAC,EACA,cAAAC,EACA,aAAAC,EACA,sBAAAC,EACA,sBAAAC,CACF,EAAI,KAAK,oBAAoBL,CAAW,EAElCM,EAAgB,KAAK,MAAM,eAAiBf,EAE5CgB,EAAuB,IAAId,EAA0B,CACzD,MAAO,CACL,cAAA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A6B,CAC1D,MAAMC,EAAYD,EAAM,IAAKR,GAAQA,EAAI,IAAI,EAC7C,OAAOV,EAAY,qBAAqB,EAAE,cAAcmB,CAAS,CACnE,EAoBE,aAlBmB,CAAC,CACpB,MAAAD,CACF,IAGO,CACL,KAAM,CAAE,WAAAE,EAAY,IAAAV,CAAI,EAAIQ,EACtBG,EAAmBrB,EACtB,wBAAwB,EACxB,aAAaoB,EAAYV,CAAG,EAC/B,OAAO,IAAIb,EAA2BG,EAAa,CACjD,WAAYqB,CACd,CAAC,EAAE,IAAI,CACT,EAME,sBAAuB,IAAMrB,EAAY,sBAAsB,EAC/D,sBAAwBW,GACtBX,EAAY,sBAAsBW,CAAK,CAC3C,CACF,CACF",
4
+ "sourcesContent": ["import { Left, Right } from \"purify-ts\";\nimport { assign, fromObservable, fromPromise, setup } from \"xstate\";\n\nimport { isSuccessCommandResult } from \"@api/command/model/CommandResult\";\nimport {\n GetOsVersionCommand,\n type GetOsVersionResponse,\n} from \"@api/command/os/GetOsVersionCommand\";\nimport { type InternalApi } from \"@api/device-action/DeviceAction\";\nimport { UserInteractionRequired } from \"@api/device-action/model/UserInteractionRequired\";\nimport { DEFAULT_UNLOCK_TIMEOUT_MS } from \"@api/device-action/os/Const\";\nimport { UnknownDAError } from \"@api/device-action/os/Errors\";\nimport { GoToDashboardDeviceAction } from \"@api/device-action/os/GoToDashboard/GoToDashboardDeviceAction\";\nimport { type StateMachineTypes } from \"@api/device-action/xstate-utils/StateMachineTypes\";\nimport {\n type DeviceActionStateMachine,\n XStateDeviceAction,\n} from \"@api/device-action/xstate-utils/XStateDeviceAction\";\nimport {\n type DeviceSessionState,\n DeviceSessionStateType,\n} from \"@api/device-session/DeviceSessionState\";\nimport { ListInstalledAppsDeviceAction } from \"@api/secure-channel/device-action/ListInstalledApps/ListInstalledAppsDeviceAction\";\nimport { type InstalledApp } 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 Input } from \"@api/secure-channel/types\";\nimport { type Application } from \"@internal/manager-api/model/Application\";\n\nimport {\n type MachineDependencies,\n type UninstallAppDAError,\n type UninstallAppDAInput,\n type UninstallAppDAIntermediateValue,\n type UninstallAppDAOutput,\n type UninstallAppStateMachineInternalState,\n} from \"./types\";\n\nexport class UninstallAppDeviceAction extends XStateDeviceAction<\n UninstallAppDAOutput,\n UninstallAppDAInput,\n UninstallAppDAError,\n UninstallAppDAIntermediateValue,\n UninstallAppStateMachineInternalState\n> {\n override makeStateMachine(\n internalApi: InternalApi,\n ): DeviceActionStateMachine<\n UninstallAppDAOutput,\n UninstallAppDAInput,\n UninstallAppDAError,\n UninstallAppDAIntermediateValue,\n UninstallAppStateMachineInternalState\n > {\n type types = StateMachineTypes<\n UninstallAppDAOutput,\n UninstallAppDAInput,\n UninstallAppDAError,\n UninstallAppDAIntermediateValue,\n UninstallAppStateMachineInternalState\n >;\n\n const {\n getOsVersion,\n getAppsByHash,\n uninstallApp,\n getDeviceSessionState,\n setDeviceSessionState,\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\n const listInstalledAppsMachine = new ListInstalledAppsDeviceAction({\n input: {\n unlockTimeout,\n },\n }).makeStateMachine(internalApi);\n\n return setup({\n types: {\n input: {} as types[\"input\"],\n context: {} as types[\"context\"],\n output: {} as types[\"output\"],\n },\n actors: {\n listInstalledApps: listInstalledAppsMachine,\n goToDashboard: goToDashboardMachine,\n getOsVersion: fromPromise(getOsVersion),\n getAppsByHash: fromPromise(getAppsByHash),\n uninstallApp: fromObservable(uninstallApp),\n },\n guards: {\n hasError: (_) => _.context._internalState.error !== null,\n appNotInstalled: (_) =>\n !_.context._internalState.installedApps.some(\n (app) => app.name === _.context.input.appName,\n ),\n appNotFound: (_) =>\n _.context._internalState.appList.findIndex(\n (app) => app?.versionName === _.context.input.appName,\n ) === -1,\n isDepAppOfOther: (_) =>\n _.context._internalState.appList.some(\n (app) => app?.parentName === _.context.input.appName,\n ),\n },\n actions: {\n assignErrorFromEvent: assign({\n _internalState: (_) => ({\n ..._.context._internalState,\n error: _.event[\"error\"],\n }),\n }),\n assignAppNotFound: assign({\n _internalState: (_) => ({\n ..._.context._internalState,\n error: new UnknownDAError(\n \"App to uninstall not found in manager API\",\n ),\n }),\n }),\n assignIsDepAppOfOther: assign({\n _internalState: (_) => ({\n ..._.context._internalState,\n error: new UnknownDAError(\n \"App to uninstall is a dependency of another installed app\",\n ),\n }),\n }),\n cleanupDeviceState: () => {\n // After app successful uninstallation, cleanup the device session state\n // to force fetching the new device state when required\n const state = getDeviceSessionState();\n if (state.sessionStateType !== DeviceSessionStateType.Connected) {\n setDeviceSessionState({\n ...state,\n installedApps: [],\n appsUpdates: undefined,\n });\n }\n },\n },\n }).createMachine({\n /** @xstate-layout N4IgpgJg5mDOIC5QEkB2sAuBDANjgggA6EAiYAbgJYDGY+1GlA9qgHRlW0BKYWEAngGIA2gAYAuolCEmsSoxZSQAD0QBGAJyjWADgDsAFg0A2HSb2iArMbUBmADQh+iAExrjrS6KuWNtte7Glga2AL6hjmiYuATEHDR0DMxsAOJMACpMJFiwABYARkxYAE4QghAsYKyUqORMANZVUBlZOQVFpWKSSCAycgqoSqoIxi6WrKJq1rYGNgaiBrOOzgi2th5qonouorYuo9YBBuGR6Nh4RKQUCfQDrGmZ2XmFJWVgxcVMxayEOFgYADMvgBbVjNR5tF6dCRKPryZJDRAHCZTYwzOYLJZOdR6DSeFy2MwBPaaXzGE4gKLnWJXTiJO4PVrPDoQADCuTA1HqIhhPThA0RCE2XlY+0semMomMBgsOjMyyRoh0E28BmClhc+0mxwilLOMUu8Vot2S9xaT3ar3ZnO5wjU3Wksnhih6w2F2jFEqlMqV8uxq0stlYgTlGg02wJOjCuqpBri12NSRY9zAGAA8rAAGrvOQscqVaq1BpNVMZ7PFXOoLqwp0C13qDVqVhaIK+HSifazNQK1YuPHGLTWQxabaLSwU2MXeN0k3JlKlrM55LWrk8h29WsI+tCjRqAysebSvY6TWagw6HvnvFeDsaGX6UR+Wx6Cf6qe0m5J1IL8uVle2+0a36LdQDdXd90PEIXBPU9zx7dFWD0LwxgMHYFkmckYzfGkjXpU15wwS4ABlKEwfNUCqGo6kaFNCOIEjMGrPlNxdUDXFscVRR0VFxXDJCL39PYgxcPRbD8NQ9DUOV9BfLDonfXDZ2-OjCAYjB-zXIDnUGbcRIkxDNEfEIwwCFx4MDYNjFMMxw01Qlo1OeScITPC51TYjSPUjlVztdd+RAlRXEkvQDK0O8xN3NQzP9HR9xvKxCT0E9Jj0WTdVQJgIDgJRJ2cmcvy0us2IQABaYwezK18nMNFylPYFyeD4FZHWA1jAoQVCezccYb02JDDPcQkqupGr8oZc1IRZQqAuGaDxhMfQxjsKMlQcf1NBcFVdlmPs9wJNVhrjD9E3GiFmStbz6mmtrhijTaFu4tZRJMSZzJCqNnyS9x5m2DRDoU2qv1osslza-ybvUNwg02DRLFi+YZnbSx4JE5sJO8Xc3CsWZMMckbp0-Bkf1B1B-2unTiokuxWGlJULHWWwOzGcymwMKnULEuzRn+vLCfw9z6M88nBR2VLRWQ6xxR0GxRhRpsb2fNYjDcXFZLxo7FKBgiPMwMnmNain2rGDiD01PdUs0NVu0EtUtq8KydginV1YBsbTQAZQAV2oWhYHgfXtJFsxtGsXbuMsCPdh7bjPG8AkNFi70-B50a+eTABRD4vmF3Tg88UZd3DyO1pWDj9wlCwLFMDQ+1xcdwlCIA */\n id: \"UninstallAppDeviceAction\",\n initial: \"DeviceReady\",\n context: (_) => {\n return {\n input: {\n unlockTimeout: _.input.unlockTimeout,\n appName: _.input.appName,\n },\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.None,\n },\n _internalState: {\n error: null,\n installedApps: [],\n appList: [],\n getOsVersionResponse: null,\n },\n };\n },\n states: {\n DeviceReady: {\n always: {\n target: \"ListInstalledApps\",\n },\n },\n ListInstalledApps: {\n invoke: {\n id: \"listInstalledApps\",\n src: \"listInstalledApps\",\n input: (_) => ({\n unlockTimeout: _.context.input.unlockTimeout,\n }),\n onSnapshot: {\n actions: assign({\n intermediateValue: (_) => ({\n ..._.context.intermediateValue,\n requiredUserInteraction:\n _.event.snapshot.context.intermediateValue\n .requiredUserInteraction,\n }),\n }),\n },\n onDone: {\n target: \"ListInstalledAppsCheck\",\n actions: assign({\n _internalState: (_) =>\n _.event.output.caseOf<UninstallAppStateMachineInternalState>({\n Right: ({ installedApps }) => ({\n ..._.context._internalState,\n installedApps,\n hasCheckedInstalledApps: true,\n }),\n Left: (error) => ({\n ..._.context._internalState,\n error,\n }),\n }),\n }),\n },\n onError: {\n target: \"Error\",\n actions: \"assignErrorFromEvent\",\n },\n },\n },\n ListInstalledAppsCheck: {\n always: [\n {\n target: \"Error\",\n guard: \"hasError\",\n },\n {\n target: \"Success\",\n guard: \"appNotInstalled\",\n },\n {\n target: \"GetAppsByHash\",\n },\n ],\n },\n GetAppsByHash: {\n invoke: {\n id: \"getAppsByHash\",\n src: \"getAppsByHash\",\n input: (_) => _.context._internalState.installedApps!,\n onDone: {\n target: \"GetAppsByHashCheck\",\n actions: assign({\n _internalState: (_) =>\n _.event.output.caseOf({\n Right: (apps) => ({\n ..._.context._internalState,\n appList: apps,\n }),\n Left: (error) => ({\n ..._.context._internalState,\n error,\n }),\n }),\n }),\n },\n onError: {\n target: \"Error\",\n actions: \"assignErrorFromEvent\",\n },\n },\n },\n GetAppsByHashCheck: {\n always: [\n {\n target: \"Error\",\n guard: \"hasError\",\n },\n {\n target: \"Error\",\n guard: \"appNotFound\",\n actions: \"assignAppNotFound\",\n },\n {\n target: \"Error\",\n guard: \"isDepAppOfOther\",\n actions: \"assignIsDepAppOfOther\",\n },\n {\n target: \"GoToDashboard\",\n },\n ],\n },\n GoToDashboard: {\n invoke: {\n id: \"goToDashboard\",\n src: \"goToDashboard\",\n input: (_) => ({\n unlockTimeout: _.context.input.unlockTimeout,\n }),\n onSnapshot: {\n actions: assign({\n intermediateValue: (_) => ({\n ..._.context.intermediateValue,\n requiredUserInteraction:\n _.event.snapshot.context.intermediateValue\n .requiredUserInteraction,\n }),\n }),\n },\n onDone: {\n target: \"GoToDashboardCheck\",\n actions: assign({\n _internalState: (_) =>\n _.event.output.caseOf<UninstallAppStateMachineInternalState>({\n Right: () => _.context._internalState,\n Left: (error) => ({\n ..._.context._internalState,\n error,\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: \"GetOsVersion\",\n },\n ],\n },\n GetOsVersion: {\n invoke: {\n id: \"getOsVersion\",\n src: \"getOsVersion\",\n input: (_) => undefined,\n onDone: {\n target: \"GetOsVersionCheck\",\n actions: assign({\n _internalState: (_) => {\n if (isSuccessCommandResult(_.event.output)) {\n const currentState: DeviceSessionState =\n getDeviceSessionState();\n const isSecureConnectionAllowed =\n _.event.output.data.secureElementFlags\n .isSecureConnectionAllowed;\n if (\n currentState.sessionStateType !==\n DeviceSessionStateType.Connected\n ) {\n setDeviceSessionState({\n ...currentState,\n isSecureConnectionAllowed,\n });\n }\n return {\n ..._.context._internalState,\n getOsVersionResponse: _.event.output.data,\n };\n }\n return {\n ..._.context._internalState,\n error: _.event.output.error,\n };\n },\n }),\n },\n },\n },\n GetOsVersionCheck: {\n always: [\n {\n target: \"Error\",\n guard: \"hasError\",\n },\n {\n target: \"UninstallApp\",\n },\n ],\n },\n UninstallApp: {\n invoke: {\n id: \"uninstallApp\",\n src: \"uninstallApp\",\n input: (_) => ({\n deviceInfo: _.context._internalState.getOsVersionResponse!,\n app: _.context._internalState.appList.find(\n (app) => app?.versionName === _.context.input.appName,\n )!,\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 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 }\n return _.context._internalState;\n },\n }),\n },\n onDone: {\n target: \"ListInstalledApps\",\n actions: \"cleanupDeviceState\",\n },\n onError: {\n target: \"Error\",\n actions: \"assignErrorFromEvent\",\n },\n },\n },\n Success: {\n type: \"final\",\n description: \"App uninstalled successfully\",\n },\n Error: {\n type: \"final\",\n },\n },\n output: ({ context }) =>\n context._internalState.error\n ? Left(context._internalState.error)\n : Right(undefined),\n });\n }\n\n extractDependencies(internalApi: InternalApi): MachineDependencies {\n const getOsVersion = () =>\n internalApi.sendCommand(new GetOsVersionCommand());\n\n const getAppsByHash = ({ input }: Input<InstalledApp[]>) => {\n const appHashes = input.map((app) => app.hash);\n return internalApi.getManagerApiService().getAppsByHash(appHashes);\n };\n\n const uninstallApp = ({\n input,\n }: Input<{\n deviceInfo: GetOsVersionResponse;\n app: Application;\n }>) => {\n const { deviceInfo, app } = input;\n const eitherConnection = internalApi\n .getSecureChannelService()\n .uninstallApp(deviceInfo, app);\n return new ConnectToSecureChannelTask(internalApi, {\n connection: eitherConnection,\n }).run();\n };\n\n return {\n getOsVersion,\n getAppsByHash,\n uninstallApp,\n getDeviceSessionState: () => internalApi.getDeviceSessionState(),\n setDeviceSessionState: (state) =>\n internalApi.setDeviceSessionState(state),\n };\n }\n}\n"],
5
+ "mappings": "AAAA,OAAS,QAAAA,EAAM,SAAAC,MAAa,YAC5B,OAAS,UAAAC,EAAQ,kBAAAC,EAAgB,eAAA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Promise", "setup", "isSuccessCommandResult", "GetOsVersionCommand", "UserInteractionRequired", "DEFAULT_UNLOCK_TIMEOUT_MS", "UnknownDAError", "GoToDashboardDeviceAction", "XStateDeviceAction", "DeviceSessionStateType", "ListInstalledAppsDeviceAction", "ConnectToSecureChannelTask", "SecureChannelEventType", "UninstallAppDeviceAction", "internalApi", "getOsVersion", "getAppsByHash", "uninstallApp", "getDeviceSessionState", "setDeviceSessionState", "unlockTimeout", "goToDashboardMachine", "listInstalledAppsMachine", "_", "app", "state", "installedApps", "error", "apps", "currentState", "isSecureConnectionAllowed", "context", "input", "appHashes", "deviceInfo", "eitherConnection"]
7
7
  }
@@ -1,2 +1,2 @@
1
- import A from"isomorphic-ws";import{Observable as E}from"rxjs";import{CommandUtils as S}from"../../command/utils/CommandUtils";import{InMessageQueryEnum as u,OutMessageResponseEnum as x,SecureChannelEventType as s}from"../../secure-channel/task/types";import{isRefusedByUser as _,willRequestPermission as v}from"../../secure-channel/utils";import{bufferToHexaString as C,hexaStringToBuffer as k}from"../../utils/HexaString";import{SecureChannelError as o}from"../../../internal/secure-channel/model/Errors";class U{constructor(p,w){this._api=p;this._args=w;if(this._args.connection.isRight())this._connection=this._args.connection.extract();else throw new o(`Invalid WebSocket connection: ${String(this._args.connection.extract())}`)}_connection;run(){const p=this._api.disableRefresher("connectToSecureChannel");return new E(e=>{let c=!1,d=!1,h=!1,f=null,g=!1;return this._connection.onopen=()=>{e.next({type:s.Opened})},this._connection.onerror=m=>{d||e.error(new o({url:this._connection.url,errorMessage:m.message}))},this._connection.onclose=()=>{d||(h?(e.next({type:s.Closed}),e.complete()):e.error(new o(f??{url:this._connection.url,errorMessage:"Connection closed unexpectedly"})))},this._connection.onmessage=async m=>{if(!c){f=null;try{const r=JSON.parse(String(m.data));switch(r.query){case u.EXCHANGE:{const{nonce:a}=r;if(Array.isArray(r.data)){e.error(new o(`${u.EXCHANGE} data type should not be Array`));break}const l=k(r.data);if(l===null||l.length<5){e.error(new o(`Received invalid APDU data: ${r.data}`));break}e.next({type:s.PreExchange,payload:{nonce:a,apdu:l}}),v(l)&&!this.isSecureConnectionAllowed()&&(g=!0,e.next({type:s.PermissionRequested}));const y=await this._api.sendApdu(l);if(c)return;y.caseOf({Left:t=>{e.error(new o(t))},Right:t=>{let n;if(S.isSuccessResponse(t))n=x.SUCCESS,e.next({type:s.Exchange,payload:{nonce:a,apdu:l,data:t.data,status:t.statusCode}});else{if(n=x.ERROR,f=new o({url:this._connection.url,errorMessage:`Invalid status code: ${C(t.statusCode)}`}),S.isLockedDeviceResponse(t)){e.error(new o({url:this._connection.url,errorMessage:"Device is locked"}));return}if(_(t.statusCode)&&g){e.error(new o({url:this._connection.url,errorMessage:"User refused on the device"}));return}}g&&(e.next({type:s.PermissionGranted}),g=!1);const i={nonce:a,response:n,data:C(t.data).slice(2)};this._connection.send(JSON.stringify(i))}});break}case u.BULK:{if(d=!0,this._connection.close(),!Array.isArray(r.data)||r.data.length===0){e.error(new o("Invalid bulk data received"));break}const a=r.data.reduce((t,n)=>{const i=k(n);return i===null?t:[...t,i]},[]),l=performance.now(),y=!0;if(console.log("PERF: exchangeBulkApdus call at",l,{enableNativeBulk:y}),y)this._api.exchangeBulkApdus(a).then(t=>{t.subscribe({next:n=>{if(!c)if("currentIndex"in n)e.next({type:s.Progress,payload:{progress:+Number((n.currentIndex+1)/a.length).toFixed(2),index:n.currentIndex,total:a.length}});else{const i=n.result;i.isLeft()?e.error(new o(i.extract())):e.next({type:s.Result,payload:i.extract()})}},error:n=>{c||e.error(new o(n))},complete:()=>{if(c)return;h=!0,e.complete();const n=performance.now();console.log("PERF: exchangeBulkApdus result from nativeModule duration:",n-l,"ms")}})});else{for(let n=0,i=a.length;n<i;n++){if(await this._api.sendApdu(a[n]),c){e.error(new o("Bulk sending cancelled by unsubscribing"));break}e.next({type:s.Progress,payload:{progress:+Number((n+1)/i).toFixed(2),index:n,total:i}})}const t=performance.now();console.log("PERF: exchangeBulkApdus result from TS implementation duration:",t-l,"ms"),h=!0,e.complete()}break}case u.SUCCESS:{if(d)break;const a=r.result??r.data;a&&e.next({type:s.Result,payload:a??""}),h=!0,e.complete();break}case u.WARNING:{if(d)break;e.next({type:s.Warning,payload:{message:String(r.data)}});break}case u.ERROR:{if(d)break;e.error(new o({url:this._connection.url,errorMessage:String(r.data)}))}}}catch(r){f=new o(r),e.error(f)}}},()=>{p(),c=!0,this._connection.readyState===A.OPEN&&this._connection.close()}})}isSecureConnectionAllowed(){const p=this._api.getDeviceSessionState();return"isSecureConnectionAllowed"in p&&p.isSecureConnectionAllowed}}export{U as ConnectToSecureChannelTask};
1
+ import M from"isomorphic-ws";import{Observable as k}from"rxjs";import{CommandUtils as h}from"../../command/utils/CommandUtils";import{InMessageQueryEnum as d,OutMessageResponseEnum as w,SecureChannelEventType as s}from"../../secure-channel/task/types";import{willRequestPermission as R}from"../../secure-channel/utils";import{bufferToHexaString as _,hexaStringToBuffer as A}from"../../utils/HexaString";import{SecureChannelError as r,SecureChannelErrorType as S}from"../../../internal/secure-channel/model/Errors";class q{constructor(t,c){this._api=t;this._args=c;if(this._args.connection.isRight())this._connection=this._args.connection.extract();else throw new r(`Invalid WebSocket connection: ${String(this._args.connection.extract())}`)}_connection;run(){const t=this._api.disableRefresher("connectToSecureChannel");return new k(n=>{let g=!1,l=!1,E=!1;const i=f=>{n.next({type:s.Error,error:f}),n.complete(),l=!0};return this._connection.onopen=()=>{n.next({type:s.Opened})},this._connection.onerror=f=>{l||(n.next({type:s.Error,error:new r({url:this._connection.url,errorMessage:f.message})}),n.complete())},this._connection.onclose=()=>{l||(E?n.next({type:s.Closed}):n.next({type:s.Error,error:new r({url:this._connection.url,errorMessage:"Connection closed unexpectedly"})}),n.complete())},this._connection.onmessage=async f=>{if(g)return;let o;try{const e=JSON.parse(String(f.data));if(this.isInMessageType(e))o=e;else throw new Error("Data does not match InMessageType")}catch{i(new r({url:this._connection.url,errorMessage:`Invalid message received: ${String(f.data)}`}));return}switch(o.query){case d.EXCHANGE:{const{nonce:e,data:u}=o;if(typeof u!="string"){i(new r(`${d.EXCHANGE} data type should be an APDU`));return}const a=A(u);if(a===null||a.length<5){i(new r(`Received invalid APDU data: ${u}`));return}n.next({type:s.PreExchange,payload:{nonce:e,apdu:a}});let p=!1;R(a)&&!this.isSecureConnectionAllowed()&&(p=!0,n.next({type:s.PermissionRequested}));const m=await this._api.sendApdu(a);if(g)return;m.caseOf({Left:y=>{i(new r(y))},Right:y=>{let v;const C=this.mapDeviceError(y);C===null?(v=w.SUCCESS,n.next({type:s.Exchange,payload:{nonce:e,apdu:a,data:y.data,status:y.statusCode}}),p&&n.next({type:s.PermissionGranted})):(v=w.ERROR,i(C));const x={nonce:e,response:v,data:_(y.data).slice(2)};this._connection.send(JSON.stringify(x))}});break}case d.BULK:{if(l=!0,this._connection.close(),!Array.isArray(o.data)||o.data.length===0||!o.data.every(e=>typeof e=="string")){i(new r("Invalid bulk data received"));return}for(let e=0,u=o.data.length;e<u;e++){const a=A(o.data[e]);if(a===null||a.length<5){i(new r(`Received invalid APDU bulk data: ${o.data[e]}`));return}const p=await this._api.sendApdu(a);if(g)return;if(p.isLeft()){i(new r(p.extract()));return}else if(p.isRight()){const m=this.mapDeviceError(p.extract());if(m===null)n.next({type:s.Progress,payload:{progress:+Number((e+1)/u).toFixed(2),index:e,total:u}});else{i(m);return}}}E=!0,n.complete();break}case d.SUCCESS:{if(l)break;const e=o.result??o.data;e&&n.next({type:s.Result,payload:e??""}),E=!0,n.complete();break}case d.WARNING:{if(l)break;n.next({type:s.Warning,payload:{message:String(o.data)}});break}case d.ERROR:{if(l)break;i(new r({url:this._connection.url,errorMessage:String(o.data)}))}}},()=>{t(),g=!0,this._connection.readyState===M.OPEN&&this._connection.close()}})}isSecureConnectionAllowed(){const t=this._api.getDeviceSessionState();return"isSecureConnectionAllowed"in t&&t.isSecureConnectionAllowed}isInMessageType(t){if(typeof t!="object"||!t)return!1;const c=t;return typeof c.uuid=="string"&&typeof c.session=="string"&&typeof c.query=="string"&&Object.values(d).includes(c.query)&&typeof c.nonce=="number"}mapDeviceError(t){return h.isSuccessResponse(t)?null:h.isLockedDeviceResponse(t)?new r({url:this._connection.url,errorMessage:"Device is locked"},S.DeviceLocked):h.isRefusedByUser(t)?new r({url:this._connection.url,errorMessage:"User refused on the device"},S.RefusedByUser):h.isAppAlreadyInstalled(t)?new r({url:this._connection.url,errorMessage:"App already installed"},S.AppAlreadyInstalled):h.isOutOfMemory(t)?new r({url:this._connection.url,errorMessage:"Out of memory"},S.OutOfMemory):new r({url:this._connection.url,errorMessage:`Invalid status code: ${_(t.statusCode)}`})}}export{q as ConnectToSecureChannelTask};
2
2
  //# sourceMappingURL=ConnectToSecureChannelTask.js.map