@ledgerhq/device-management-kit 0.0.0-legacy-speculos-datasource-20250820121907 → 0.0.0-lifi-with-logger-20251208144248

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 (424) hide show
  1. package/README.md +3 -3
  2. package/lib/cjs/package.json +42 -37
  3. package/lib/cjs/src/api/DeviceManagementKit.js +1 -1
  4. package/lib/cjs/src/api/DeviceManagementKit.js.map +3 -3
  5. package/lib/cjs/src/api/DeviceManagementKit.test.js +1 -1
  6. package/lib/cjs/src/api/DeviceManagementKit.test.js.map +3 -3
  7. package/lib/cjs/src/api/apdu/utils/ByteArrayBuilder.js +1 -1
  8. package/lib/cjs/src/api/apdu/utils/ByteArrayBuilder.js.map +2 -2
  9. package/lib/cjs/src/api/apdu/utils/ByteArrayBuilder.test.js +1 -1
  10. package/lib/cjs/src/api/apdu/utils/ByteArrayBuilder.test.js.map +2 -2
  11. package/lib/cjs/src/api/command/Command.js +1 -1
  12. package/lib/cjs/src/api/command/Command.js.map +1 -1
  13. package/lib/cjs/src/api/command/Errors.js +1 -1
  14. package/lib/cjs/src/api/command/Errors.js.map +3 -3
  15. package/lib/cjs/src/api/command/model/CommandResult.js +1 -1
  16. package/lib/cjs/src/api/command/model/CommandResult.js.map +2 -2
  17. package/lib/cjs/src/api/command/os/CloseAppCommand.js +1 -1
  18. package/lib/cjs/src/api/command/os/CloseAppCommand.js.map +2 -2
  19. package/lib/cjs/src/api/command/os/CloseAppCommand.test.js +1 -1
  20. package/lib/cjs/src/api/command/os/CloseAppCommand.test.js.map +2 -2
  21. package/lib/cjs/src/api/command/os/GetAppAndVersionCommand.js +1 -1
  22. package/lib/cjs/src/api/command/os/GetAppAndVersionCommand.js.map +2 -2
  23. package/lib/cjs/src/api/command/os/GetAppAndVersionCommand.test.js +1 -1
  24. package/lib/cjs/src/api/command/os/GetAppAndVersionCommand.test.js.map +2 -2
  25. package/lib/cjs/src/api/command/os/GetBatteryStatusCommand.js +1 -1
  26. package/lib/cjs/src/api/command/os/GetBatteryStatusCommand.js.map +2 -2
  27. package/lib/cjs/src/api/command/os/GetBatteryStatusCommand.test.js +1 -1
  28. package/lib/cjs/src/api/command/os/GetBatteryStatusCommand.test.js.map +3 -3
  29. package/lib/cjs/src/api/command/os/GetCustomImageSizeCommand.js +1 -1
  30. package/lib/cjs/src/api/command/os/GetCustomImageSizeCommand.js.map +2 -2
  31. package/lib/cjs/src/api/command/os/GetCustomImageSizeCommand.test.js +1 -1
  32. package/lib/cjs/src/api/command/os/GetCustomImageSizeCommand.test.js.map +2 -2
  33. package/lib/cjs/src/api/command/os/GetOsVersionCommand.js +1 -1
  34. package/lib/cjs/src/api/command/os/GetOsVersionCommand.js.map +2 -2
  35. package/lib/cjs/src/api/command/os/GetOsVersionCommand.test.js +1 -1
  36. package/lib/cjs/src/api/command/os/GetOsVersionCommand.test.js.map +2 -2
  37. package/lib/cjs/src/api/command/os/ListAppsCommand.js +1 -1
  38. package/lib/cjs/src/api/command/os/ListAppsCommand.js.map +2 -2
  39. package/lib/cjs/src/api/command/os/ListAppsCommand.test.js +1 -1
  40. package/lib/cjs/src/api/command/os/ListAppsCommand.test.js.map +2 -2
  41. package/lib/cjs/src/api/command/os/ListLanguagePackCommand.js +1 -1
  42. package/lib/cjs/src/api/command/os/ListLanguagePackCommand.js.map +2 -2
  43. package/lib/cjs/src/api/command/os/ListLanguagePackCommand.test.js +1 -1
  44. package/lib/cjs/src/api/command/os/ListLanguagePackCommand.test.js.map +2 -2
  45. package/lib/cjs/src/api/command/os/LoadCertificateCommand.js +1 -1
  46. package/lib/cjs/src/api/command/os/LoadCertificateCommand.js.map +2 -2
  47. package/lib/cjs/src/api/command/os/LoadCertificateCommand.test.js +1 -1
  48. package/lib/cjs/src/api/command/os/LoadCertificateCommand.test.js.map +3 -3
  49. package/lib/cjs/src/api/command/os/OpenAppCommand.js +1 -1
  50. package/lib/cjs/src/api/command/os/OpenAppCommand.js.map +2 -2
  51. package/lib/cjs/src/api/command/os/OpenAppCommand.test.js +1 -1
  52. package/lib/cjs/src/api/command/os/OpenAppCommand.test.js.map +2 -2
  53. package/lib/cjs/src/api/command/use-case/SendCommandUseCase.test.js +1 -1
  54. package/lib/cjs/src/api/command/use-case/SendCommandUseCase.test.js.map +2 -2
  55. package/lib/cjs/src/api/device/DeviceModel.js +1 -1
  56. package/lib/cjs/src/api/device/DeviceModel.js.map +2 -2
  57. package/lib/cjs/src/api/device-action/model/UserInteractionRequired.js +1 -1
  58. package/lib/cjs/src/api/device-action/model/UserInteractionRequired.js.map +2 -2
  59. package/lib/cjs/src/api/device-action/os/CallTaskInAppDeviceAction/CallTaskInAppDeviceAction.test.js +1 -1
  60. package/lib/cjs/src/api/device-action/os/CallTaskInAppDeviceAction/CallTaskInAppDeviceAction.test.js.map +2 -2
  61. package/lib/cjs/src/api/device-action/os/Errors.js +1 -1
  62. package/lib/cjs/src/api/device-action/os/Errors.js.map +3 -3
  63. package/lib/cjs/src/api/device-action/os/GetDeviceMetadata/GetDeviceMetadataDeviceAction.js +1 -1
  64. package/lib/cjs/src/api/device-action/os/GetDeviceMetadata/GetDeviceMetadataDeviceAction.js.map +2 -2
  65. package/lib/cjs/src/api/device-action/os/GetDeviceMetadata/types.js +1 -1
  66. package/lib/cjs/src/api/device-action/os/GetDeviceMetadata/types.js.map +1 -1
  67. package/lib/cjs/src/api/device-action/os/GetDeviceStatus/GetDeviceStatusDeviceAction.js +1 -1
  68. package/lib/cjs/src/api/device-action/os/GetDeviceStatus/GetDeviceStatusDeviceAction.js.map +3 -3
  69. package/lib/cjs/src/api/device-action/os/GetDeviceStatus/GetDeviceStatusDeviceAction.test.js +1 -1
  70. package/lib/cjs/src/api/device-action/os/GetDeviceStatus/GetDeviceStatusDeviceAction.test.js.map +2 -2
  71. package/lib/cjs/src/api/device-action/os/InstallOrUpdateApps/InstallOrUpdateAppsDeviceAction.js +1 -1
  72. package/lib/cjs/src/api/device-action/os/InstallOrUpdateApps/InstallOrUpdateAppsDeviceAction.js.map +2 -2
  73. package/lib/cjs/src/api/device-action/os/InstallOrUpdateApps/types.js +1 -1
  74. package/lib/cjs/src/api/device-action/os/InstallOrUpdateApps/types.js.map +1 -1
  75. package/lib/cjs/src/api/device-action/os/OpenAppWithDependencies/OpenAppWithDependenciesDeviceAction.js +1 -1
  76. package/lib/cjs/src/api/device-action/os/OpenAppWithDependencies/OpenAppWithDependenciesDeviceAction.js.map +2 -2
  77. package/lib/cjs/src/api/device-action/os/OpenAppWithDependencies/types.js +1 -1
  78. package/lib/cjs/src/api/device-action/os/OpenAppWithDependencies/types.js.map +1 -1
  79. package/lib/cjs/src/api/device-action/os/SendCommandInAppDeviceAction/SendCommandInAppDeviceAction.test.js +1 -1
  80. package/lib/cjs/src/api/device-action/os/SendCommandInAppDeviceAction/SendCommandInAppDeviceAction.test.js.map +2 -2
  81. package/lib/cjs/src/api/device-action/task/BuildAppsInstallPlanTask.js +1 -1
  82. package/lib/cjs/src/api/device-action/task/BuildAppsInstallPlanTask.js.map +2 -2
  83. package/lib/cjs/src/api/device-action/task/BuildAppsInstallPlanTask.test.js +1 -1
  84. package/lib/cjs/src/api/device-action/task/BuildAppsInstallPlanTask.test.js.map +2 -2
  85. package/lib/cjs/src/api/device-action/task/GetFirmwareMetadataTask.js +1 -1
  86. package/lib/cjs/src/api/device-action/task/GetFirmwareMetadataTask.js.map +2 -2
  87. package/lib/cjs/src/api/device-action/task/GetFirmwareMetadataTask.test.js +1 -1
  88. package/lib/cjs/src/api/device-action/task/GetFirmwareMetadataTask.test.js.map +2 -2
  89. package/lib/cjs/src/api/device-action/xstate-utils/XStateDeviceAction.js +1 -1
  90. package/lib/cjs/src/api/device-action/xstate-utils/XStateDeviceAction.js.map +2 -2
  91. package/lib/cjs/src/api/device-model/data/StaticDeviceModelDataSource.js +1 -1
  92. package/lib/cjs/src/api/device-model/data/StaticDeviceModelDataSource.js.map +2 -2
  93. package/lib/cjs/src/api/device-model/data/StaticDeviceModelDataSource.test.js +1 -1
  94. package/lib/cjs/src/api/device-model/data/StaticDeviceModelDataSource.test.js.map +2 -2
  95. package/lib/cjs/src/api/index.js +1 -1
  96. package/lib/cjs/src/api/index.js.map +2 -2
  97. package/lib/cjs/src/api/logger-subscriber/service/ConsoleLogger.js +1 -1
  98. package/lib/cjs/src/api/logger-subscriber/service/ConsoleLogger.js.map +3 -3
  99. package/lib/cjs/src/api/secure-channel/device-action/GenuineCheck/GenuineCheckDeviceAction.js +1 -1
  100. package/lib/cjs/src/api/secure-channel/device-action/GenuineCheck/GenuineCheckDeviceAction.js.map +2 -2
  101. package/lib/cjs/src/api/secure-channel/device-action/GenuineCheck/types.js.map +1 -1
  102. package/lib/cjs/src/api/secure-channel/device-action/InstallApp/InstallAppDeviceAction.js +1 -1
  103. package/lib/cjs/src/api/secure-channel/device-action/InstallApp/InstallAppDeviceAction.js.map +2 -2
  104. package/lib/cjs/src/api/secure-channel/device-action/InstallApp/types.js.map +1 -1
  105. package/lib/cjs/src/api/secure-channel/device-action/ListInstalledApps/ListInstalledAppsDeviceAction.js +1 -1
  106. package/lib/cjs/src/api/secure-channel/device-action/ListInstalledApps/ListInstalledAppsDeviceAction.js.map +2 -2
  107. package/lib/cjs/src/api/secure-channel/device-action/ListInstalledApps/types.js +1 -1
  108. package/lib/cjs/src/api/secure-channel/device-action/ListInstalledApps/types.js.map +2 -2
  109. package/lib/cjs/src/api/secure-channel/device-action/UninstallApp/UninstallAppDeviceAction.js +1 -1
  110. package/lib/cjs/src/api/secure-channel/device-action/UninstallApp/UninstallAppDeviceAction.js.map +2 -2
  111. package/lib/cjs/src/api/secure-channel/device-action/UninstallApp/types.js.map +1 -1
  112. package/lib/cjs/src/api/secure-channel/task/ConnectToSecureChannelTask.js +1 -1
  113. package/lib/cjs/src/api/secure-channel/task/ConnectToSecureChannelTask.js.map +3 -3
  114. package/lib/cjs/src/api/secure-channel/task/ConnectToSecureChannelTask.test.js +1 -1
  115. package/lib/cjs/src/api/secure-channel/task/ConnectToSecureChannelTask.test.js.map +3 -3
  116. package/lib/cjs/src/api/secure-channel/task/types.js +1 -1
  117. package/lib/cjs/src/api/secure-channel/task/types.js.map +2 -2
  118. package/lib/cjs/src/api/secure-channel/utils.js +1 -1
  119. package/lib/cjs/src/api/secure-channel/utils.js.map +3 -3
  120. package/lib/cjs/src/api/secure-channel/utils.test.js +1 -1
  121. package/lib/cjs/src/api/secure-channel/utils.test.js.map +3 -3
  122. package/lib/cjs/src/api/transport/model/ConnectedDevice.js +1 -1
  123. package/lib/cjs/src/api/transport/model/ConnectedDevice.js.map +3 -3
  124. package/lib/cjs/src/api/transport/model/DeviceConnectionStateMachine.js +1 -1
  125. package/lib/cjs/src/api/transport/model/DeviceConnectionStateMachine.js.map +2 -2
  126. package/lib/cjs/src/api/transport/model/Errors.js +1 -1
  127. package/lib/cjs/src/api/transport/model/Errors.js.map +3 -3
  128. package/lib/cjs/src/api/transport/model/TransportConnectedDevice.js +1 -1
  129. package/lib/cjs/src/api/transport/model/TransportConnectedDevice.js.map +3 -3
  130. package/lib/cjs/src/api/utils/HexaString.js +1 -1
  131. package/lib/cjs/src/api/utils/HexaString.js.map +3 -3
  132. package/lib/cjs/src/api/utils/HexaString.test.js +1 -1
  133. package/lib/cjs/src/api/utils/HexaString.test.js.map +2 -2
  134. package/lib/cjs/src/internal/crypto/CryptoService.js +2 -0
  135. package/lib/cjs/src/internal/crypto/CryptoService.js.map +7 -0
  136. package/lib/cjs/src/internal/crypto/NobleCryptoService.js +2 -0
  137. package/lib/cjs/src/internal/crypto/NobleCryptoService.js.map +7 -0
  138. package/lib/cjs/src/internal/crypto/NobleCryptoService.test.js +2 -0
  139. package/lib/cjs/src/internal/crypto/NobleCryptoService.test.js.map +7 -0
  140. package/lib/cjs/src/internal/device-session/model/DeviceSession.js +1 -1
  141. package/lib/cjs/src/internal/device-session/model/DeviceSession.js.map +3 -3
  142. package/lib/cjs/src/internal/device-session/service/DefaultApduReceiverService.js +1 -1
  143. package/lib/cjs/src/internal/device-session/service/DefaultApduReceiverService.js.map +2 -2
  144. package/lib/cjs/src/internal/device-session/service/DefaultApduSenderService.js +1 -1
  145. package/lib/cjs/src/internal/device-session/service/DefaultApduSenderService.js.map +2 -2
  146. package/lib/cjs/src/internal/device-session/service/DefaultDeviceSessionService.js +1 -1
  147. package/lib/cjs/src/internal/device-session/service/DefaultDeviceSessionService.js.map +3 -3
  148. package/lib/cjs/src/internal/device-session/service/DefaultDeviceSessionService.test.js +1 -1
  149. package/lib/cjs/src/internal/device-session/service/DefaultDeviceSessionService.test.js.map +3 -3
  150. package/lib/cjs/src/internal/device-session/service/DeviceSessionService.js +1 -1
  151. package/lib/cjs/src/internal/device-session/service/DeviceSessionService.js.map +1 -1
  152. package/lib/cjs/src/internal/discovery/di/discoveryModule.js +1 -1
  153. package/lib/cjs/src/internal/discovery/di/discoveryModule.js.map +3 -3
  154. package/lib/cjs/src/internal/discovery/di/discoveryModule.test.js +1 -1
  155. package/lib/cjs/src/internal/discovery/di/discoveryModule.test.js.map +3 -3
  156. package/lib/cjs/src/internal/discovery/di/discoveryTypes.js +1 -1
  157. package/lib/cjs/src/internal/discovery/di/discoveryTypes.js.map +2 -2
  158. package/lib/cjs/src/internal/discovery/use-case/ConnectUseCase.js +1 -1
  159. package/lib/cjs/src/internal/discovery/use-case/ConnectUseCase.js.map +3 -3
  160. package/lib/cjs/src/internal/discovery/use-case/ConnectUseCase.test.js +1 -1
  161. package/lib/cjs/src/internal/discovery/use-case/ConnectUseCase.test.js.map +3 -3
  162. package/lib/cjs/src/internal/discovery/use-case/DisconnectUseCase.js +1 -1
  163. package/lib/cjs/src/internal/discovery/use-case/DisconnectUseCase.js.map +3 -3
  164. package/lib/cjs/src/internal/discovery/use-case/ReconnectUseCase.js +2 -0
  165. package/lib/cjs/src/internal/discovery/use-case/ReconnectUseCase.js.map +7 -0
  166. package/lib/cjs/src/internal/discovery/use-case/ReconnectUseCase.test.js +2 -0
  167. package/lib/cjs/src/internal/discovery/use-case/ReconnectUseCase.test.js.map +7 -0
  168. package/lib/cjs/src/internal/manager-api/data/ManagerApiDataSource.js.map +1 -1
  169. package/lib/esm/package.json +42 -37
  170. package/lib/esm/src/api/DeviceManagementKit.js +1 -1
  171. package/lib/esm/src/api/DeviceManagementKit.js.map +3 -3
  172. package/lib/esm/src/api/DeviceManagementKit.test.js +1 -1
  173. package/lib/esm/src/api/DeviceManagementKit.test.js.map +3 -3
  174. package/lib/esm/src/api/apdu/utils/ByteArrayBuilder.js +1 -1
  175. package/lib/esm/src/api/apdu/utils/ByteArrayBuilder.js.map +3 -3
  176. package/lib/esm/src/api/apdu/utils/ByteArrayBuilder.test.js +1 -1
  177. package/lib/esm/src/api/apdu/utils/ByteArrayBuilder.test.js.map +2 -2
  178. package/lib/esm/src/api/command/Errors.js +1 -1
  179. package/lib/esm/src/api/command/Errors.js.map +3 -3
  180. package/lib/esm/src/api/command/model/CommandResult.js.map +2 -2
  181. package/lib/esm/src/api/command/os/CloseAppCommand.js +1 -1
  182. package/lib/esm/src/api/command/os/CloseAppCommand.js.map +2 -2
  183. package/lib/esm/src/api/command/os/CloseAppCommand.test.js +1 -1
  184. package/lib/esm/src/api/command/os/CloseAppCommand.test.js.map +2 -2
  185. package/lib/esm/src/api/command/os/GetAppAndVersionCommand.js +1 -1
  186. package/lib/esm/src/api/command/os/GetAppAndVersionCommand.js.map +2 -2
  187. package/lib/esm/src/api/command/os/GetAppAndVersionCommand.test.js +1 -1
  188. package/lib/esm/src/api/command/os/GetAppAndVersionCommand.test.js.map +2 -2
  189. package/lib/esm/src/api/command/os/GetBatteryStatusCommand.js +1 -1
  190. package/lib/esm/src/api/command/os/GetBatteryStatusCommand.js.map +2 -2
  191. package/lib/esm/src/api/command/os/GetBatteryStatusCommand.test.js +1 -1
  192. package/lib/esm/src/api/command/os/GetBatteryStatusCommand.test.js.map +3 -3
  193. package/lib/esm/src/api/command/os/GetCustomImageSizeCommand.js +1 -1
  194. package/lib/esm/src/api/command/os/GetCustomImageSizeCommand.js.map +2 -2
  195. package/lib/esm/src/api/command/os/GetCustomImageSizeCommand.test.js +1 -1
  196. package/lib/esm/src/api/command/os/GetCustomImageSizeCommand.test.js.map +2 -2
  197. package/lib/esm/src/api/command/os/GetOsVersionCommand.js +1 -1
  198. package/lib/esm/src/api/command/os/GetOsVersionCommand.js.map +2 -2
  199. package/lib/esm/src/api/command/os/GetOsVersionCommand.test.js +1 -1
  200. package/lib/esm/src/api/command/os/GetOsVersionCommand.test.js.map +2 -2
  201. package/lib/esm/src/api/command/os/ListAppsCommand.js +1 -1
  202. package/lib/esm/src/api/command/os/ListAppsCommand.js.map +2 -2
  203. package/lib/esm/src/api/command/os/ListAppsCommand.test.js +1 -1
  204. package/lib/esm/src/api/command/os/ListAppsCommand.test.js.map +2 -2
  205. package/lib/esm/src/api/command/os/ListLanguagePackCommand.js +1 -1
  206. package/lib/esm/src/api/command/os/ListLanguagePackCommand.js.map +2 -2
  207. package/lib/esm/src/api/command/os/ListLanguagePackCommand.test.js +1 -1
  208. package/lib/esm/src/api/command/os/ListLanguagePackCommand.test.js.map +2 -2
  209. package/lib/esm/src/api/command/os/LoadCertificateCommand.js +1 -1
  210. package/lib/esm/src/api/command/os/LoadCertificateCommand.js.map +2 -2
  211. package/lib/esm/src/api/command/os/LoadCertificateCommand.test.js +1 -1
  212. package/lib/esm/src/api/command/os/LoadCertificateCommand.test.js.map +3 -3
  213. package/lib/esm/src/api/command/os/OpenAppCommand.js +1 -1
  214. package/lib/esm/src/api/command/os/OpenAppCommand.js.map +2 -2
  215. package/lib/esm/src/api/command/os/OpenAppCommand.test.js +1 -1
  216. package/lib/esm/src/api/command/os/OpenAppCommand.test.js.map +2 -2
  217. package/lib/esm/src/api/command/use-case/SendCommandUseCase.test.js +1 -1
  218. package/lib/esm/src/api/command/use-case/SendCommandUseCase.test.js.map +2 -2
  219. package/lib/esm/src/api/device/DeviceModel.js +1 -1
  220. package/lib/esm/src/api/device/DeviceModel.js.map +2 -2
  221. package/lib/esm/src/api/device-action/model/UserInteractionRequired.js +1 -1
  222. package/lib/esm/src/api/device-action/model/UserInteractionRequired.js.map +2 -2
  223. package/lib/esm/src/api/device-action/os/CallTaskInAppDeviceAction/CallTaskInAppDeviceAction.test.js +1 -1
  224. package/lib/esm/src/api/device-action/os/CallTaskInAppDeviceAction/CallTaskInAppDeviceAction.test.js.map +2 -2
  225. package/lib/esm/src/api/device-action/os/Errors.js +1 -1
  226. package/lib/esm/src/api/device-action/os/Errors.js.map +3 -3
  227. package/lib/esm/src/api/device-action/os/GetDeviceMetadata/GetDeviceMetadataDeviceAction.js +1 -1
  228. package/lib/esm/src/api/device-action/os/GetDeviceMetadata/GetDeviceMetadataDeviceAction.js.map +2 -2
  229. package/lib/esm/src/api/device-action/os/GetDeviceStatus/GetDeviceStatusDeviceAction.js +1 -1
  230. package/lib/esm/src/api/device-action/os/GetDeviceStatus/GetDeviceStatusDeviceAction.js.map +3 -3
  231. package/lib/esm/src/api/device-action/os/GetDeviceStatus/GetDeviceStatusDeviceAction.test.js +1 -1
  232. package/lib/esm/src/api/device-action/os/GetDeviceStatus/GetDeviceStatusDeviceAction.test.js.map +2 -2
  233. package/lib/esm/src/api/device-action/os/InstallOrUpdateApps/InstallOrUpdateAppsDeviceAction.js +1 -1
  234. package/lib/esm/src/api/device-action/os/InstallOrUpdateApps/InstallOrUpdateAppsDeviceAction.js.map +2 -2
  235. package/lib/esm/src/api/device-action/os/OpenAppWithDependencies/OpenAppWithDependenciesDeviceAction.js +1 -1
  236. package/lib/esm/src/api/device-action/os/OpenAppWithDependencies/OpenAppWithDependenciesDeviceAction.js.map +2 -2
  237. package/lib/esm/src/api/device-action/os/SendCommandInAppDeviceAction/SendCommandInAppDeviceAction.test.js +1 -1
  238. package/lib/esm/src/api/device-action/os/SendCommandInAppDeviceAction/SendCommandInAppDeviceAction.test.js.map +2 -2
  239. package/lib/esm/src/api/device-action/task/BuildAppsInstallPlanTask.js +1 -1
  240. package/lib/esm/src/api/device-action/task/BuildAppsInstallPlanTask.js.map +3 -3
  241. package/lib/esm/src/api/device-action/task/BuildAppsInstallPlanTask.test.js +1 -1
  242. package/lib/esm/src/api/device-action/task/BuildAppsInstallPlanTask.test.js.map +3 -3
  243. package/lib/esm/src/api/device-action/task/GetFirmwareMetadataTask.js +1 -1
  244. package/lib/esm/src/api/device-action/task/GetFirmwareMetadataTask.js.map +3 -3
  245. package/lib/esm/src/api/device-action/task/GetFirmwareMetadataTask.test.js +1 -1
  246. package/lib/esm/src/api/device-action/task/GetFirmwareMetadataTask.test.js.map +3 -3
  247. package/lib/esm/src/api/device-action/xstate-utils/XStateDeviceAction.js +1 -1
  248. package/lib/esm/src/api/device-action/xstate-utils/XStateDeviceAction.js.map +2 -2
  249. package/lib/esm/src/api/device-model/data/StaticDeviceModelDataSource.js +1 -1
  250. package/lib/esm/src/api/device-model/data/StaticDeviceModelDataSource.js.map +2 -2
  251. package/lib/esm/src/api/device-model/data/StaticDeviceModelDataSource.test.js +1 -1
  252. package/lib/esm/src/api/device-model/data/StaticDeviceModelDataSource.test.js.map +2 -2
  253. package/lib/esm/src/api/index.js +1 -1
  254. package/lib/esm/src/api/index.js.map +3 -3
  255. package/lib/esm/src/api/logger-subscriber/service/ConsoleLogger.js +1 -1
  256. package/lib/esm/src/api/logger-subscriber/service/ConsoleLogger.js.map +3 -3
  257. package/lib/esm/src/api/secure-channel/device-action/GenuineCheck/GenuineCheckDeviceAction.js +1 -1
  258. package/lib/esm/src/api/secure-channel/device-action/GenuineCheck/GenuineCheckDeviceAction.js.map +2 -2
  259. package/lib/esm/src/api/secure-channel/device-action/InstallApp/InstallAppDeviceAction.js +1 -1
  260. package/lib/esm/src/api/secure-channel/device-action/InstallApp/InstallAppDeviceAction.js.map +2 -2
  261. package/lib/esm/src/api/secure-channel/device-action/ListInstalledApps/ListInstalledAppsDeviceAction.js +1 -1
  262. package/lib/esm/src/api/secure-channel/device-action/ListInstalledApps/ListInstalledAppsDeviceAction.js.map +2 -2
  263. package/lib/esm/src/api/secure-channel/device-action/ListInstalledApps/types.js.map +2 -2
  264. package/lib/esm/src/api/secure-channel/device-action/UninstallApp/UninstallAppDeviceAction.js +1 -1
  265. package/lib/esm/src/api/secure-channel/device-action/UninstallApp/UninstallAppDeviceAction.js.map +2 -2
  266. package/lib/esm/src/api/secure-channel/task/ConnectToSecureChannelTask.js +1 -1
  267. package/lib/esm/src/api/secure-channel/task/ConnectToSecureChannelTask.js.map +3 -3
  268. package/lib/esm/src/api/secure-channel/task/ConnectToSecureChannelTask.test.js +1 -1
  269. package/lib/esm/src/api/secure-channel/task/ConnectToSecureChannelTask.test.js.map +3 -3
  270. package/lib/esm/src/api/secure-channel/task/types.js +1 -1
  271. package/lib/esm/src/api/secure-channel/task/types.js.map +2 -2
  272. package/lib/esm/src/api/secure-channel/utils.js +1 -1
  273. package/lib/esm/src/api/secure-channel/utils.js.map +3 -3
  274. package/lib/esm/src/api/secure-channel/utils.test.js +1 -1
  275. package/lib/esm/src/api/secure-channel/utils.test.js.map +3 -3
  276. package/lib/esm/src/api/transport/model/ConnectedDevice.js +1 -1
  277. package/lib/esm/src/api/transport/model/ConnectedDevice.js.map +3 -3
  278. package/lib/esm/src/api/transport/model/DeviceConnectionStateMachine.js +1 -1
  279. package/lib/esm/src/api/transport/model/DeviceConnectionStateMachine.js.map +2 -2
  280. package/lib/esm/src/api/transport/model/Errors.js +1 -1
  281. package/lib/esm/src/api/transport/model/Errors.js.map +3 -3
  282. package/lib/esm/src/api/transport/model/TransportConnectedDevice.js +1 -1
  283. package/lib/esm/src/api/transport/model/TransportConnectedDevice.js.map +3 -3
  284. package/lib/esm/src/api/utils/HexaString.js +1 -1
  285. package/lib/esm/src/api/utils/HexaString.js.map +3 -3
  286. package/lib/esm/src/api/utils/HexaString.test.js +1 -1
  287. package/lib/esm/src/api/utils/HexaString.test.js.map +2 -2
  288. package/lib/esm/src/internal/crypto/CryptoService.js +1 -0
  289. package/lib/esm/src/internal/crypto/CryptoService.js.map +7 -0
  290. package/lib/esm/src/internal/crypto/NobleCryptoService.js +2 -0
  291. package/lib/esm/src/internal/crypto/NobleCryptoService.js.map +7 -0
  292. package/lib/esm/src/internal/crypto/NobleCryptoService.test.js +2 -0
  293. package/lib/esm/src/internal/crypto/NobleCryptoService.test.js.map +7 -0
  294. package/lib/esm/src/internal/device-session/model/DeviceSession.js +1 -1
  295. package/lib/esm/src/internal/device-session/model/DeviceSession.js.map +3 -3
  296. package/lib/esm/src/internal/device-session/service/DefaultApduReceiverService.js +1 -1
  297. package/lib/esm/src/internal/device-session/service/DefaultApduReceiverService.js.map +2 -2
  298. package/lib/esm/src/internal/device-session/service/DefaultApduSenderService.js +1 -1
  299. package/lib/esm/src/internal/device-session/service/DefaultApduSenderService.js.map +2 -2
  300. package/lib/esm/src/internal/device-session/service/DefaultDeviceSessionService.js +1 -1
  301. package/lib/esm/src/internal/device-session/service/DefaultDeviceSessionService.js.map +3 -3
  302. package/lib/esm/src/internal/device-session/service/DefaultDeviceSessionService.test.js +1 -1
  303. package/lib/esm/src/internal/device-session/service/DefaultDeviceSessionService.test.js.map +3 -3
  304. package/lib/esm/src/internal/discovery/di/discoveryModule.js +1 -1
  305. package/lib/esm/src/internal/discovery/di/discoveryModule.js.map +3 -3
  306. package/lib/esm/src/internal/discovery/di/discoveryModule.test.js +1 -1
  307. package/lib/esm/src/internal/discovery/di/discoveryModule.test.js.map +3 -3
  308. package/lib/esm/src/internal/discovery/di/discoveryTypes.js +1 -1
  309. package/lib/esm/src/internal/discovery/di/discoveryTypes.js.map +2 -2
  310. package/lib/esm/src/internal/discovery/use-case/ConnectUseCase.js +1 -1
  311. package/lib/esm/src/internal/discovery/use-case/ConnectUseCase.js.map +3 -3
  312. package/lib/esm/src/internal/discovery/use-case/ConnectUseCase.test.js +1 -1
  313. package/lib/esm/src/internal/discovery/use-case/ConnectUseCase.test.js.map +3 -3
  314. package/lib/esm/src/internal/discovery/use-case/DisconnectUseCase.js +1 -1
  315. package/lib/esm/src/internal/discovery/use-case/DisconnectUseCase.js.map +3 -3
  316. package/lib/esm/src/internal/discovery/use-case/ReconnectUseCase.js +2 -0
  317. package/lib/esm/src/internal/discovery/use-case/ReconnectUseCase.js.map +7 -0
  318. package/lib/esm/src/internal/discovery/use-case/ReconnectUseCase.test.js +2 -0
  319. package/lib/esm/src/internal/discovery/use-case/ReconnectUseCase.test.js.map +7 -0
  320. package/lib/types/src/api/DeviceManagementKit.d.ts +24 -1
  321. package/lib/types/src/api/DeviceManagementKit.d.ts.map +1 -1
  322. package/lib/types/src/api/apdu/utils/ByteArrayBuilder.d.ts +38 -0
  323. package/lib/types/src/api/apdu/utils/ByteArrayBuilder.d.ts.map +1 -1
  324. package/lib/types/src/api/command/Command.d.ts +4 -0
  325. package/lib/types/src/api/command/Command.d.ts.map +1 -1
  326. package/lib/types/src/api/command/Errors.d.ts +5 -0
  327. package/lib/types/src/api/command/Errors.d.ts.map +1 -1
  328. package/lib/types/src/api/command/model/CommandResult.d.ts +3 -3
  329. package/lib/types/src/api/command/model/CommandResult.d.ts.map +1 -1
  330. package/lib/types/src/api/command/os/CloseAppCommand.d.ts +1 -0
  331. package/lib/types/src/api/command/os/CloseAppCommand.d.ts.map +1 -1
  332. package/lib/types/src/api/command/os/GetAppAndVersionCommand.d.ts +1 -0
  333. package/lib/types/src/api/command/os/GetAppAndVersionCommand.d.ts.map +1 -1
  334. package/lib/types/src/api/command/os/GetBatteryStatusCommand.d.ts +1 -0
  335. package/lib/types/src/api/command/os/GetBatteryStatusCommand.d.ts.map +1 -1
  336. package/lib/types/src/api/command/os/GetCustomImageSizeCommand.d.ts +1 -0
  337. package/lib/types/src/api/command/os/GetCustomImageSizeCommand.d.ts.map +1 -1
  338. package/lib/types/src/api/command/os/GetOsVersionCommand.d.ts +1 -0
  339. package/lib/types/src/api/command/os/GetOsVersionCommand.d.ts.map +1 -1
  340. package/lib/types/src/api/command/os/ListAppsCommand.d.ts +1 -0
  341. package/lib/types/src/api/command/os/ListAppsCommand.d.ts.map +1 -1
  342. package/lib/types/src/api/command/os/ListLanguagePackCommand.d.ts +1 -0
  343. package/lib/types/src/api/command/os/ListLanguagePackCommand.d.ts.map +1 -1
  344. package/lib/types/src/api/command/os/LoadCertificateCommand.d.ts +1 -0
  345. package/lib/types/src/api/command/os/LoadCertificateCommand.d.ts.map +1 -1
  346. package/lib/types/src/api/command/os/OpenAppCommand.d.ts +1 -0
  347. package/lib/types/src/api/command/os/OpenAppCommand.d.ts.map +1 -1
  348. package/lib/types/src/api/device/DeviceModel.d.ts +1 -1
  349. package/lib/types/src/api/device/DeviceModel.d.ts.map +1 -1
  350. package/lib/types/src/api/device-action/model/UserInteractionRequired.d.ts +2 -1
  351. package/lib/types/src/api/device-action/model/UserInteractionRequired.d.ts.map +1 -1
  352. package/lib/types/src/api/device-action/os/Errors.d.ts +5 -0
  353. package/lib/types/src/api/device-action/os/Errors.d.ts.map +1 -1
  354. package/lib/types/src/api/device-action/os/GetDeviceMetadata/GetDeviceMetadataDeviceAction.d.ts.map +1 -1
  355. package/lib/types/src/api/device-action/os/GetDeviceMetadata/types.d.ts +1 -0
  356. package/lib/types/src/api/device-action/os/GetDeviceMetadata/types.d.ts.map +1 -1
  357. package/lib/types/src/api/device-action/os/GetDeviceStatus/GetDeviceStatusDeviceAction.d.ts +1 -1
  358. package/lib/types/src/api/device-action/os/GetDeviceStatus/GetDeviceStatusDeviceAction.d.ts.map +1 -1
  359. package/lib/types/src/api/device-action/os/InstallOrUpdateApps/InstallOrUpdateAppsDeviceAction.d.ts.map +1 -1
  360. package/lib/types/src/api/device-action/os/InstallOrUpdateApps/types.d.ts +3 -2
  361. package/lib/types/src/api/device-action/os/InstallOrUpdateApps/types.d.ts.map +1 -1
  362. package/lib/types/src/api/device-action/os/OpenAppWithDependencies/OpenAppWithDependenciesDeviceAction.d.ts.map +1 -1
  363. package/lib/types/src/api/device-action/os/OpenAppWithDependencies/types.d.ts +1 -0
  364. package/lib/types/src/api/device-action/os/OpenAppWithDependencies/types.d.ts.map +1 -1
  365. package/lib/types/src/api/device-action/task/BuildAppsInstallPlanTask.d.ts +2 -2
  366. package/lib/types/src/api/device-action/task/BuildAppsInstallPlanTask.d.ts.map +1 -1
  367. package/lib/types/src/api/device-action/task/GetFirmwareMetadataTask.d.ts.map +1 -1
  368. package/lib/types/src/api/device-action/xstate-utils/XStateDeviceAction.d.ts +1 -0
  369. package/lib/types/src/api/device-action/xstate-utils/XStateDeviceAction.d.ts.map +1 -1
  370. package/lib/types/src/api/index.d.ts +1 -1
  371. package/lib/types/src/api/index.d.ts.map +1 -1
  372. package/lib/types/src/api/logger-subscriber/service/ConsoleLogger.d.ts +1 -0
  373. package/lib/types/src/api/logger-subscriber/service/ConsoleLogger.d.ts.map +1 -1
  374. package/lib/types/src/api/secure-channel/device-action/GenuineCheck/GenuineCheckDeviceAction.d.ts.map +1 -1
  375. package/lib/types/src/api/secure-channel/device-action/GenuineCheck/types.d.ts +1 -0
  376. package/lib/types/src/api/secure-channel/device-action/GenuineCheck/types.d.ts.map +1 -1
  377. package/lib/types/src/api/secure-channel/device-action/InstallApp/InstallAppDeviceAction.d.ts.map +1 -1
  378. package/lib/types/src/api/secure-channel/device-action/InstallApp/types.d.ts +1 -0
  379. package/lib/types/src/api/secure-channel/device-action/InstallApp/types.d.ts.map +1 -1
  380. package/lib/types/src/api/secure-channel/device-action/ListInstalledApps/ListInstalledAppsDeviceAction.d.ts.map +1 -1
  381. package/lib/types/src/api/secure-channel/device-action/ListInstalledApps/types.d.ts +1 -0
  382. package/lib/types/src/api/secure-channel/device-action/ListInstalledApps/types.d.ts.map +1 -1
  383. package/lib/types/src/api/secure-channel/device-action/UninstallApp/UninstallAppDeviceAction.d.ts.map +1 -1
  384. package/lib/types/src/api/secure-channel/device-action/UninstallApp/types.d.ts +1 -0
  385. package/lib/types/src/api/secure-channel/device-action/UninstallApp/types.d.ts.map +1 -1
  386. package/lib/types/src/api/secure-channel/task/ConnectToSecureChannelTask.d.ts +4 -0
  387. package/lib/types/src/api/secure-channel/task/ConnectToSecureChannelTask.d.ts.map +1 -1
  388. package/lib/types/src/api/secure-channel/task/types.d.ts +7 -0
  389. package/lib/types/src/api/secure-channel/task/types.d.ts.map +1 -1
  390. package/lib/types/src/api/secure-channel/utils.d.ts +18 -1
  391. package/lib/types/src/api/secure-channel/utils.d.ts.map +1 -1
  392. package/lib/types/src/api/transport/model/ConnectedDevice.d.ts +3 -2
  393. package/lib/types/src/api/transport/model/ConnectedDevice.d.ts.map +1 -1
  394. package/lib/types/src/api/transport/model/Errors.d.ts +5 -0
  395. package/lib/types/src/api/transport/model/Errors.d.ts.map +1 -1
  396. package/lib/types/src/api/transport/model/TransportConnectedDevice.d.ts +3 -1
  397. package/lib/types/src/api/transport/model/TransportConnectedDevice.d.ts.map +1 -1
  398. package/lib/types/src/api/utils/HexaString.d.ts +4 -3
  399. package/lib/types/src/api/utils/HexaString.d.ts.map +1 -1
  400. package/lib/types/src/internal/crypto/CryptoService.d.ts +12 -0
  401. package/lib/types/src/internal/crypto/CryptoService.d.ts.map +1 -0
  402. package/lib/types/src/internal/crypto/NobleCryptoService.d.ts +8 -0
  403. package/lib/types/src/internal/crypto/NobleCryptoService.d.ts.map +1 -0
  404. package/lib/types/src/internal/crypto/NobleCryptoService.test.d.ts +2 -0
  405. package/lib/types/src/internal/crypto/NobleCryptoService.test.d.ts.map +1 -0
  406. package/lib/types/src/internal/device-session/model/DeviceSession.d.ts.map +1 -1
  407. package/lib/types/src/internal/device-session/service/DefaultApduReceiverService.d.ts.map +1 -1
  408. package/lib/types/src/internal/device-session/service/DefaultDeviceSessionService.d.ts +7 -5
  409. package/lib/types/src/internal/device-session/service/DefaultDeviceSessionService.d.ts.map +1 -1
  410. package/lib/types/src/internal/device-session/service/DeviceSessionService.d.ts +28 -1
  411. package/lib/types/src/internal/device-session/service/DeviceSessionService.d.ts.map +1 -1
  412. package/lib/types/src/internal/discovery/di/discoveryModule.d.ts.map +1 -1
  413. package/lib/types/src/internal/discovery/di/discoveryTypes.d.ts +1 -0
  414. package/lib/types/src/internal/discovery/di/discoveryTypes.d.ts.map +1 -1
  415. package/lib/types/src/internal/discovery/use-case/ConnectUseCase.d.ts +3 -2
  416. package/lib/types/src/internal/discovery/use-case/ConnectUseCase.d.ts.map +1 -1
  417. package/lib/types/src/internal/discovery/use-case/DisconnectUseCase.d.ts.map +1 -1
  418. package/lib/types/src/internal/discovery/use-case/ReconnectUseCase.d.ts +32 -0
  419. package/lib/types/src/internal/discovery/use-case/ReconnectUseCase.d.ts.map +1 -0
  420. package/lib/types/src/internal/discovery/use-case/ReconnectUseCase.test.d.ts +2 -0
  421. package/lib/types/src/internal/discovery/use-case/ReconnectUseCase.test.d.ts.map +1 -0
  422. package/lib/types/src/internal/manager-api/data/ManagerApiDataSource.d.ts +1 -1
  423. package/lib/types/tsconfig.prod.tsbuildinfo +1 -1
  424. package/package.json +34 -29
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../../../../src/api/device-action/os/GetDeviceMetadata/GetDeviceMetadataDeviceAction.ts"],
4
- "sourcesContent": ["import { Left, Right } from \"purify-ts\";\nimport { type Observable } from \"rxjs\";\nimport { assign, fromObservable, fromPromise, setup } from \"xstate\";\n\nimport { isSuccessCommandResult } from \"@api/command/model/CommandResult\";\nimport { type InternalApi } from \"@api/device-action/DeviceAction\";\nimport { UserInteractionRequired } from \"@api/device-action/model/UserInteractionRequired\";\nimport { DEFAULT_UNLOCK_TIMEOUT_MS } from \"@api/device-action/os/Const\";\nimport { GoToDashboardDeviceAction } from \"@api/device-action/os/GoToDashboard/GoToDashboardDeviceAction\";\nimport { ListAppsDeviceAction } from \"@api/device-action/os/ListApps/ListAppsDeviceAction\";\nimport {\n GetApplicationsMetadataTask,\n type GetApplicationsMetadataTaskResult,\n type InstalledApp,\n} from \"@api/device-action/task/GetApplicationsMetadataTask\";\nimport {\n GetFirmwareMetadataTask,\n type GetFirmwareMetadataTaskResult,\n} from \"@api/device-action/task/GetFirmwareMetadataTask\";\nimport { type StateMachineTypes } from \"@api/device-action/xstate-utils/StateMachineTypes\";\nimport {\n type DeviceActionStateMachine,\n XStateDeviceAction,\n} from \"@api/device-action/xstate-utils/XStateDeviceAction\";\nimport {\n type Catalog,\n type CustomImage,\n DeviceSessionStateType,\n type FirmwareUpdateContext,\n type FirmwareVersion,\n type InstalledLanguagePackage,\n} from \"@api/device-session/DeviceSessionState\";\nimport { installedAppResultGuard } from \"@api/secure-channel/device-action/ListInstalledApps/types\";\nimport { ConnectToSecureChannelTask } from \"@api/secure-channel/task/ConnectToSecureChannelTask\";\nimport { SecureChannelEventType } from \"@api/secure-channel/task/types\";\nimport { type SecureChannelEvent } from \"@api/secure-channel/task/types\";\nimport { type Application } from \"@internal/manager-api/model/Application\";\nimport { type DeviceVersion } from \"@internal/manager-api/model/Device\";\nimport { type FinalFirmware } from \"@internal/manager-api/model/Firmware\";\n\nimport {\n type GetDeviceMetadataDAError,\n type GetDeviceMetadataDAInput,\n type GetDeviceMetadataDAIntermediateValue,\n type GetDeviceMetadataDAOutput,\n} from \"./types\";\n\ntype GetDeviceMetadataMachineInternalState = {\n readonly error: GetDeviceMetadataDAError | null;\n readonly deviceVersion: DeviceVersion | null;\n readonly firmware: FinalFirmware | null;\n readonly firmwareVersion: FirmwareVersion | null;\n readonly firmwareUpdateContext: FirmwareUpdateContext | null;\n readonly customImage: CustomImage | null;\n readonly installedApps: InstalledApp[] | null;\n readonly applications: Application[] | null;\n readonly applicationsUpdates: Application[] | null;\n readonly installedLanguages: InstalledLanguagePackage[] | null;\n readonly catalog: Catalog | null;\n};\n\nexport type GetDeviceMetadataFromContextTaskResult = {\n readonly firmwareVersion: FirmwareVersion;\n readonly firmwareUpdateContext: FirmwareUpdateContext;\n readonly customImage: CustomImage;\n readonly applications: Application[];\n readonly applicationsUpdates: Application[];\n readonly installedLanguages: InstalledLanguagePackage[];\n readonly catalog: Catalog;\n} | null;\n\nexport type MachineDependencies = {\n readonly getDeviceMetadata: () => Promise<GetDeviceMetadataFromContextTaskResult>;\n readonly getFirmwareMetadata: () => Promise<GetFirmwareMetadataTaskResult>;\n readonly getApplicationsMetadata: (arg0: {\n input: {\n deviceVersion: DeviceVersion;\n firmware: FinalFirmware;\n firmwareVersion: FirmwareVersion;\n installedApps: InstalledApp[];\n };\n }) => Promise<GetApplicationsMetadataTaskResult>;\n readonly listAppsSecureChannel: (arg0: {\n input: {\n firmware: FinalFirmware;\n firmwareVersion: FirmwareVersion;\n };\n }) => Observable<SecureChannelEvent>;\n};\n\nexport type ExtractMachineDependencies = (\n internalApi: InternalApi,\n) => MachineDependencies;\n\nexport class GetDeviceMetadataDeviceAction extends XStateDeviceAction<\n GetDeviceMetadataDAOutput,\n GetDeviceMetadataDAInput,\n GetDeviceMetadataDAError,\n GetDeviceMetadataDAIntermediateValue,\n GetDeviceMetadataMachineInternalState\n> {\n makeStateMachine(\n internalApi: InternalApi,\n ): DeviceActionStateMachine<\n GetDeviceMetadataDAOutput,\n GetDeviceMetadataDAInput,\n GetDeviceMetadataDAError,\n GetDeviceMetadataDAIntermediateValue,\n GetDeviceMetadataMachineInternalState\n > {\n type types = StateMachineTypes<\n GetDeviceMetadataDAOutput,\n GetDeviceMetadataDAInput,\n GetDeviceMetadataDAError,\n GetDeviceMetadataDAIntermediateValue,\n GetDeviceMetadataMachineInternalState\n >;\n\n const {\n getDeviceMetadata,\n getFirmwareMetadata,\n getApplicationsMetadata,\n listAppsSecureChannel,\n } = this.extractDependencies(internalApi);\n\n const unlockTimeout = this.input.unlockTimeout ?? DEFAULT_UNLOCK_TIMEOUT_MS;\n\n const goToDashboardMachine = new GoToDashboardDeviceAction({\n input: {\n unlockTimeout,\n },\n }).makeStateMachine(internalApi);\n const listAppsMachine = new ListAppsDeviceAction({\n input: {\n unlockTimeout,\n },\n }).makeStateMachine(internalApi);\n\n return setup({\n types: {\n input: {\n unlockTimeout,\n } as types[\"input\"],\n context: {} as types[\"context\"],\n output: {} as types[\"output\"],\n },\n actors: {\n goToDashboard: goToDashboardMachine,\n getDeviceMetadata: fromPromise(getDeviceMetadata),\n getFirmwareMetadata: fromPromise(getFirmwareMetadata),\n getApplicationsMetadata: fromPromise(getApplicationsMetadata),\n listApps: listAppsMachine,\n listAppsSecureChannel: fromObservable(listAppsSecureChannel),\n },\n guards: {\n hasError: ({ context }) => context._internalState.error !== null,\n hasMetadata: ({ context }) =>\n context._internalState.firmwareVersion !== null &&\n context._internalState.firmwareUpdateContext !== null &&\n context._internalState.customImage !== null &&\n context._internalState.applications !== null &&\n context._internalState.applicationsUpdates !== null &&\n context._internalState.installedLanguages !== null &&\n context._internalState.catalog !== null,\n forceUpdate: ({ context }) => Boolean(context.input.forceUpdate),\n useSecureChannel: ({ context }) =>\n Boolean(context.input.useSecureChannel),\n },\n actions: {\n assignErrorFromEvent: assign({\n _internalState: (_) => ({\n ..._.context._internalState,\n error: _.event[\"error\"], // NOTE: it should never happen, the error is not typed anymore here\n }),\n }),\n },\n }).createMachine({\n id: \"GetDeviceMetadataDeviceAction\",\n initial: \"DeviceReady\",\n context: (_) => {\n return {\n input: {\n useSecureChannel: _.input.useSecureChannel,\n forceUpdate: _.input.forceUpdate,\n unlockTimeout: _.input.unlockTimeout,\n },\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.None,\n },\n _internalState: {\n error: null,\n deviceVersion: null,\n firmware: null,\n firmwareVersion: null,\n firmwareUpdateContext: null,\n customImage: null,\n installedApps: null,\n applications: null,\n applicationsUpdates: null,\n installedLanguages: null,\n catalog: null,\n },\n };\n },\n states: {\n DeviceReady: {\n always: [\n {\n target: \"GoToDashboard\",\n guard: \"forceUpdate\",\n },\n {\n target: \"GetDeviceMetadataFromContext\",\n },\n ],\n },\n GetDeviceMetadataFromContext: {\n invoke: {\n src: \"getDeviceMetadata\",\n onDone: {\n target: \"GetDeviceMetadataFromContextResultCheck\",\n actions: assign({\n _internalState: (_) => {\n if (_.event.output === null) {\n return _.context._internalState;\n } else {\n return {\n ..._.context._internalState,\n firmwareVersion: _.event.output.firmwareVersion,\n firmwareUpdateContext:\n _.event.output.firmwareUpdateContext,\n customImage: _.event.output.customImage,\n applications: _.event.output.applications,\n applicationsUpdates: _.event.output.applicationsUpdates,\n installedLanguages: _.event.output.installedLanguages,\n catalog: _.event.output.catalog,\n };\n }\n },\n }),\n },\n onError: {\n target: \"Error\",\n actions: \"assignErrorFromEvent\",\n },\n },\n },\n GetDeviceMetadataFromContextResultCheck: {\n always: [\n {\n target: \"Success\",\n guard: \"hasMetadata\",\n },\n {\n target: \"GoToDashboard\",\n },\n ],\n },\n GoToDashboard: {\n exit: assign({\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.None,\n },\n }),\n invoke: {\n id: \"dashboard\",\n src: \"goToDashboard\",\n input: (_) => ({\n unlockTimeout: _.context.input.unlockTimeout,\n }),\n onSnapshot: {\n actions: assign({\n intermediateValue: (_) =>\n _.event.snapshot.context.intermediateValue,\n }),\n },\n onDone: {\n target: \"GoToDashboardCheck\",\n actions: assign({\n _internalState: (_) => {\n return _.event.output.caseOf({\n Right: () => _.context._internalState,\n Left: (error) => ({\n ..._.context._internalState,\n error,\n }),\n });\n },\n }),\n },\n onError: {\n target: \"Error\",\n actions: \"assignErrorFromEvent\",\n },\n },\n },\n GoToDashboardCheck: {\n always: [\n {\n target: \"Error\",\n guard: \"hasError\",\n },\n {\n target: \"GetFirmwareMetadata\",\n },\n ],\n },\n GetFirmwareMetadata: {\n invoke: {\n src: \"getFirmwareMetadata\",\n onDone: {\n target: \"GetFirmwareMetadataResultCheck\",\n actions: assign({\n _internalState: (_) => {\n if (isSuccessCommandResult(_.event.output)) {\n const deviceState = internalApi.getDeviceSessionState();\n if (\n deviceState.sessionStateType !==\n DeviceSessionStateType.Connected\n ) {\n internalApi.setDeviceSessionState({\n ...deviceState,\n firmwareVersion: _.event.output.data.firmwareVersion,\n firmwareUpdateContext:\n _.event.output.data.firmwareUpdateContext,\n customImage: _.event.output.data.customImage,\n });\n }\n return {\n ..._.context._internalState,\n deviceVersion: _.event.output.data.deviceVersion,\n firmware: _.event.output.data.firmware,\n firmwareVersion: _.event.output.data.firmwareVersion,\n firmwareUpdateContext:\n _.event.output.data.firmwareUpdateContext,\n customImage: _.event.output.data.customImage,\n };\n }\n return {\n ..._.context._internalState,\n error: _.event.output.error,\n };\n },\n }),\n },\n onError: {\n target: \"Error\",\n actions: \"assignErrorFromEvent\",\n },\n },\n },\n GetFirmwareMetadataResultCheck: {\n always: [\n {\n guard: \"hasError\",\n target: \"Error\",\n },\n {\n guard: \"useSecureChannel\",\n target: \"ListAppsSecureChannel\",\n },\n {\n target: \"ListApps\",\n },\n ],\n },\n ListAppsSecureChannel: {\n exit: assign({\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.None,\n },\n }),\n invoke: {\n id: \"listAppsSecureChannel\",\n src: \"listAppsSecureChannel\",\n input: (_) => ({\n firmware: _.context._internalState.firmware!,\n firmwareVersion: _.context._internalState.firmwareVersion!,\n }),\n onSnapshot: {\n actions: assign({\n intermediateValue: (_) => {\n switch (_.event.snapshot.context?.type) {\n case SecureChannelEventType.PermissionRequested: {\n return {\n requiredUserInteraction:\n UserInteractionRequired.AllowSecureConnection,\n };\n }\n case SecureChannelEventType.PermissionGranted: {\n const deviceState = internalApi.getDeviceSessionState();\n if (\n deviceState.sessionStateType !==\n DeviceSessionStateType.Connected\n ) {\n internalApi.setDeviceSessionState({\n ...deviceState,\n isSecureConnectionAllowed: true,\n });\n }\n return {\n requiredUserInteraction: UserInteractionRequired.None,\n };\n }\n default:\n return {\n ..._.context.intermediateValue,\n };\n }\n },\n _internalState: (_) => {\n if (\n _.event.snapshot.context?.type ===\n SecureChannelEventType.Error\n ) {\n return {\n ..._.context._internalState,\n error: _.event.snapshot.context.error.mapDAErrors(),\n };\n } else if (\n _.event.snapshot.context?.type ===\n SecureChannelEventType.Result\n ) {\n if (\n installedAppResultGuard(_.event.snapshot.context.payload)\n ) {\n return {\n ..._.context._internalState,\n installedApps: _.event.snapshot.context.payload.map(\n (app) => ({\n name: app.name,\n hash: app.hash,\n hashCode: app.hash_code_data,\n }),\n ),\n };\n }\n throw new Error(\n `Invalid result ${JSON.stringify(_.event.snapshot.context.payload)}`,\n );\n }\n return { ..._.context._internalState };\n },\n }),\n },\n onDone: {\n target: \"ListAppsCheck\",\n },\n onError: {\n target: \"Error\",\n actions: \"assignErrorFromEvent\",\n },\n },\n },\n ListApps: {\n exit: assign({\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.None,\n },\n }),\n invoke: {\n id: \"listApps\",\n src: \"listApps\",\n input: (_) => ({\n unlockTimeout: _.context.input.unlockTimeout,\n }),\n onSnapshot: {\n actions: assign({\n intermediateValue: (_) =>\n _.event.snapshot.context.intermediateValue,\n }),\n },\n onDone: {\n target: \"ListAppsCheck\",\n actions: assign({\n _internalState: (_) => {\n if (_.event.output.isLeft()) {\n return {\n ..._.context._internalState,\n error: _.event.output.extract(),\n };\n } else {\n return {\n ..._.context._internalState,\n installedApps: _.event.output\n .unsafeCoerce()\n .map((app) => ({\n name: app.appName,\n hash: app.appFullHash,\n hashCode: app.appCodeHash,\n })),\n };\n }\n },\n }),\n },\n onError: {\n target: \"Error\",\n actions: \"assignErrorFromEvent\",\n },\n },\n },\n ListAppsCheck: {\n always: [\n {\n target: \"Error\",\n guard: \"hasError\",\n },\n {\n target: \"GetApplicationsMetadata\",\n },\n ],\n },\n GetApplicationsMetadata: {\n invoke: {\n src: \"getApplicationsMetadata\",\n input: (_) => ({\n deviceVersion: _.context._internalState.deviceVersion!,\n firmware: _.context._internalState.firmware!,\n firmwareVersion: _.context._internalState.firmwareVersion!,\n installedApps: _.context._internalState.installedApps!,\n }),\n onDone: {\n target: \"GetApplicationsMetadataResultCheck\",\n actions: assign({\n _internalState: (_) => {\n if (isSuccessCommandResult(_.event.output)) {\n const deviceState = internalApi.getDeviceSessionState();\n if (\n deviceState.sessionStateType !==\n DeviceSessionStateType.Connected\n ) {\n internalApi.setDeviceSessionState({\n ...deviceState,\n installedApps: _.event.output.data.applications,\n appsUpdates: _.event.output.data.applicationsUpdates,\n installedLanguages:\n _.event.output.data.installedLanguages,\n catalog: _.event.output.data.catalog,\n });\n }\n return {\n ..._.context._internalState,\n applications: _.event.output.data.applications,\n applicationsUpdates:\n _.event.output.data.applicationsUpdates,\n installedLanguages:\n _.event.output.data.installedLanguages,\n catalog: _.event.output.data.catalog,\n };\n }\n return {\n ..._.context._internalState,\n error: _.event.output.error,\n };\n },\n }),\n },\n onError: {\n target: \"Error\",\n actions: \"assignErrorFromEvent\",\n },\n },\n },\n GetApplicationsMetadataResultCheck: {\n always: [\n {\n guard: \"hasError\",\n target: \"Error\",\n },\n {\n target: \"Success\",\n },\n ],\n },\n Success: {\n type: \"final\",\n },\n Error: {\n type: \"final\",\n },\n },\n output: (args) => {\n const { context } = args;\n const {\n error,\n firmwareVersion,\n firmwareUpdateContext,\n customImage,\n applications,\n applicationsUpdates,\n installedLanguages,\n catalog,\n } = context._internalState;\n if (error) {\n return Left(error);\n }\n return Right({\n firmwareVersion: firmwareVersion!,\n firmwareUpdateContext: firmwareUpdateContext!,\n customImage: customImage!,\n applications: applications!,\n applicationsUpdates: applicationsUpdates!,\n installedLanguages: installedLanguages!,\n catalog: catalog!,\n });\n },\n });\n }\n\n extractDependencies(internalApi: InternalApi): MachineDependencies {\n const getDeviceMetadata = async () => {\n const deviceState = internalApi.getDeviceSessionState();\n if (deviceState.sessionStateType === DeviceSessionStateType.Connected) {\n return null;\n }\n if (\n deviceState.firmwareVersion?.metadata === undefined ||\n deviceState.firmwareUpdateContext === undefined ||\n deviceState.customImage === undefined ||\n deviceState.installedApps.length === 0 ||\n deviceState.appsUpdates === undefined ||\n deviceState.installedLanguages === undefined ||\n deviceState.catalog === undefined\n ) {\n return null;\n }\n return {\n firmwareVersion: deviceState.firmwareVersion,\n firmwareUpdateContext: deviceState.firmwareUpdateContext,\n customImage: deviceState.customImage,\n applications: deviceState.installedApps,\n applicationsUpdates: deviceState.appsUpdates,\n installedLanguages: deviceState.installedLanguages,\n catalog: deviceState.catalog,\n };\n };\n\n const getFirmwareMetadata = async () =>\n new GetFirmwareMetadataTask(internalApi).run();\n\n const getApplicationsMetadata = async (arg0: {\n input: {\n deviceVersion: DeviceVersion;\n firmware: FinalFirmware;\n firmwareVersion: FirmwareVersion;\n installedApps: InstalledApp[];\n };\n }) =>\n new GetApplicationsMetadataTask(internalApi, {\n deviceVersion: arg0.input.deviceVersion,\n firmware: arg0.input.firmware,\n firmwareVersion: arg0.input.firmwareVersion,\n installedApps: arg0.input.installedApps,\n }).run();\n\n const listAppsSecureChannel = (arg0: {\n input: {\n firmware: FinalFirmware;\n firmwareVersion: FirmwareVersion;\n };\n }) => {\n const { firmware, firmwareVersion } = arg0.input;\n const connection = internalApi\n .getSecureChannelService()\n .listInstalledApps(firmwareVersion.metadata!, firmware);\n return new ConnectToSecureChannelTask(internalApi, {\n connection,\n }).run();\n };\n\n return {\n getDeviceMetadata,\n getFirmwareMetadata,\n getApplicationsMetadata,\n listAppsSecureChannel,\n };\n }\n}\n"],
5
- "mappings": "yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,mCAAAE,IAAA,eAAAC,EAAAH,GAAA,IAAAI,EAA4B,qBAE5BC,EAA2D,kBAE3DC,EAAuC,4CAEvCC,EAAwC,4DACxCC,EAA0C,uCAC1CC,EAA0C,yEAC1CC,EAAqC,+DACrCC,EAIO,+DACPC,EAGO,2DAEPC,EAGO,8DACPC,EAOO,kDACPC,EAAwC,qEACxCC,EAA2C,+DAC3CD,EAAuC,0CA4DhC,MAAMb,UAAsC,oBAMjD,CACA,iBACEe,EAOA,CASA,KAAM,CACJ,kBAAAC,EACA,oBAAAC,EACA,wBAAAC,EACA,sBAAAC,CACF,EAAI,KAAK,oBAAoBJ,CAAW,EAElCK,EAAgB,KAAK,MAAM,eAAiB,4BAE5CC,EAAuB,IAAI,4BAA0B,CACzD,MAAO,CACL,cAAAD,CACF,CACF,CAAC,EAAE,iBAAiBL,CAAW,EAC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X,CAAW,EAAE,IAAI,EAmC7C,wBAjC8B,MAAOqB,GAQrC,IAAI,8BAA4BrB,EAAa,CAC3C,cAAeqB,EAAK,MAAM,cAC1B,SAAUA,EAAK,MAAM,SACrB,gBAAiBA,EAAK,MAAM,gBAC5B,cAAeA,EAAK,MAAM,aAC5B,CAAC,EAAE,IAAI,EAqBP,sBAnB6BA,GAKzB,CACJ,KAAM,CAAE,SAAAC,EAAU,gBAAAR,CAAgB,EAAIO,EAAK,MACrCE,EAAavB,EAChB,wBAAwB,EACxB,kBAAkBc,EAAgB,SAAWQ,CAAQ,EACxD,OAAO,IAAI,6BAA2BtB,EAAa,CACjD,WAAAuB,CACF,CAAC,EAAE,IAAI,CACT,CAOA,CACF,CACF",
4
+ "sourcesContent": ["import { Left, Right } from \"purify-ts\";\nimport { type Observable } from \"rxjs\";\nimport { assign, fromObservable, fromPromise, setup } from \"xstate\";\n\nimport { isSuccessCommandResult } from \"@api/command/model/CommandResult\";\nimport { type InternalApi } from \"@api/device-action/DeviceAction\";\nimport { UserInteractionRequired } from \"@api/device-action/model/UserInteractionRequired\";\nimport { DEFAULT_UNLOCK_TIMEOUT_MS } from \"@api/device-action/os/Const\";\nimport { GoToDashboardDeviceAction } from \"@api/device-action/os/GoToDashboard/GoToDashboardDeviceAction\";\nimport { ListAppsDeviceAction } from \"@api/device-action/os/ListApps/ListAppsDeviceAction\";\nimport {\n GetApplicationsMetadataTask,\n type GetApplicationsMetadataTaskResult,\n type InstalledApp,\n} from \"@api/device-action/task/GetApplicationsMetadataTask\";\nimport {\n GetFirmwareMetadataTask,\n type GetFirmwareMetadataTaskResult,\n} from \"@api/device-action/task/GetFirmwareMetadataTask\";\nimport { type StateMachineTypes } from \"@api/device-action/xstate-utils/StateMachineTypes\";\nimport {\n type DeviceActionStateMachine,\n XStateDeviceAction,\n} from \"@api/device-action/xstate-utils/XStateDeviceAction\";\nimport {\n type Catalog,\n type CustomImage,\n DeviceSessionStateType,\n type FirmwareUpdateContext,\n type FirmwareVersion,\n type InstalledLanguagePackage,\n} from \"@api/device-session/DeviceSessionState\";\nimport { installedAppResultGuard } from \"@api/secure-channel/device-action/ListInstalledApps/types\";\nimport { ConnectToSecureChannelTask } from \"@api/secure-channel/task/ConnectToSecureChannelTask\";\nimport { SecureChannelEventType } from \"@api/secure-channel/task/types\";\nimport { type SecureChannelEvent } from \"@api/secure-channel/task/types\";\nimport { type Application } from \"@internal/manager-api/model/Application\";\nimport { type DeviceVersion } from \"@internal/manager-api/model/Device\";\nimport { type FinalFirmware } from \"@internal/manager-api/model/Firmware\";\n\nimport {\n type GetDeviceMetadataDAError,\n type GetDeviceMetadataDAInput,\n type GetDeviceMetadataDAIntermediateValue,\n type GetDeviceMetadataDAOutput,\n} from \"./types\";\n\ntype GetDeviceMetadataMachineInternalState = {\n readonly error: GetDeviceMetadataDAError | null;\n readonly deviceVersion: DeviceVersion | null;\n readonly firmware: FinalFirmware | null;\n readonly firmwareVersion: FirmwareVersion | null;\n readonly firmwareUpdateContext: FirmwareUpdateContext | null;\n readonly customImage: CustomImage | null;\n readonly installedApps: InstalledApp[] | null;\n readonly applications: Application[] | null;\n readonly applicationsUpdates: Application[] | null;\n readonly installedLanguages: InstalledLanguagePackage[] | null;\n readonly catalog: Catalog | null;\n};\n\nexport type GetDeviceMetadataFromContextTaskResult = {\n readonly firmwareVersion: FirmwareVersion;\n readonly firmwareUpdateContext: FirmwareUpdateContext;\n readonly customImage: CustomImage;\n readonly applications: Application[];\n readonly applicationsUpdates: Application[];\n readonly installedLanguages: InstalledLanguagePackage[];\n readonly catalog: Catalog;\n} | null;\n\nexport type MachineDependencies = {\n readonly getDeviceMetadata: () => Promise<GetDeviceMetadataFromContextTaskResult>;\n readonly getFirmwareMetadata: () => Promise<GetFirmwareMetadataTaskResult>;\n readonly getApplicationsMetadata: (arg0: {\n input: {\n deviceVersion: DeviceVersion;\n firmware: FinalFirmware;\n firmwareVersion: FirmwareVersion;\n installedApps: InstalledApp[];\n };\n }) => Promise<GetApplicationsMetadataTaskResult>;\n readonly listAppsSecureChannel: (arg0: {\n input: {\n firmware: FinalFirmware;\n firmwareVersion: FirmwareVersion;\n };\n }) => Observable<SecureChannelEvent>;\n};\n\nexport type ExtractMachineDependencies = (\n internalApi: InternalApi,\n) => MachineDependencies;\n\nexport class GetDeviceMetadataDeviceAction extends XStateDeviceAction<\n GetDeviceMetadataDAOutput,\n GetDeviceMetadataDAInput,\n GetDeviceMetadataDAError,\n GetDeviceMetadataDAIntermediateValue,\n GetDeviceMetadataMachineInternalState\n> {\n makeStateMachine(\n internalApi: InternalApi,\n ): DeviceActionStateMachine<\n GetDeviceMetadataDAOutput,\n GetDeviceMetadataDAInput,\n GetDeviceMetadataDAError,\n GetDeviceMetadataDAIntermediateValue,\n GetDeviceMetadataMachineInternalState\n > {\n type types = StateMachineTypes<\n GetDeviceMetadataDAOutput,\n GetDeviceMetadataDAInput,\n GetDeviceMetadataDAError,\n GetDeviceMetadataDAIntermediateValue,\n GetDeviceMetadataMachineInternalState\n >;\n\n const {\n getDeviceMetadata,\n getFirmwareMetadata,\n getApplicationsMetadata,\n listAppsSecureChannel,\n } = this.extractDependencies(internalApi);\n\n const unlockTimeout = this.input.unlockTimeout ?? DEFAULT_UNLOCK_TIMEOUT_MS;\n\n const goToDashboardMachine = new GoToDashboardDeviceAction({\n input: {\n unlockTimeout,\n },\n }).makeStateMachine(internalApi);\n const listAppsMachine = new ListAppsDeviceAction({\n input: {\n unlockTimeout,\n },\n }).makeStateMachine(internalApi);\n\n return setup({\n types: {\n input: {\n unlockTimeout,\n } as types[\"input\"],\n context: {} as types[\"context\"],\n output: {} as types[\"output\"],\n },\n actors: {\n goToDashboard: goToDashboardMachine,\n getDeviceMetadata: fromPromise(getDeviceMetadata),\n getFirmwareMetadata: fromPromise(getFirmwareMetadata),\n getApplicationsMetadata: fromPromise(getApplicationsMetadata),\n listApps: listAppsMachine,\n listAppsSecureChannel: fromObservable(listAppsSecureChannel),\n },\n guards: {\n hasError: ({ context }) => context._internalState.error !== null,\n hasMetadata: ({ context }) =>\n context._internalState.firmwareVersion !== null &&\n context._internalState.firmwareUpdateContext !== null &&\n context._internalState.customImage !== null &&\n context._internalState.applications !== null &&\n context._internalState.applicationsUpdates !== null &&\n context._internalState.installedLanguages !== null &&\n context._internalState.catalog !== null,\n forceUpdate: ({ context }) => Boolean(context.input.forceUpdate),\n useSecureChannel: ({ context }) =>\n Boolean(context.input.useSecureChannel),\n },\n actions: {\n assignErrorFromEvent: assign({\n _internalState: (_) => ({\n ..._.context._internalState,\n error: _.event[\"error\"], // NOTE: it should never happen, the error is not typed anymore here\n }),\n }),\n },\n }).createMachine({\n id: \"GetDeviceMetadataDeviceAction\",\n initial: \"DeviceReady\",\n context: (_) => {\n return {\n input: {\n useSecureChannel: _.input.useSecureChannel,\n forceUpdate: _.input.forceUpdate,\n unlockTimeout: _.input.unlockTimeout,\n },\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.None,\n },\n _internalState: {\n error: null,\n deviceVersion: null,\n firmware: null,\n firmwareVersion: null,\n firmwareUpdateContext: null,\n customImage: null,\n installedApps: null,\n applications: null,\n applicationsUpdates: null,\n installedLanguages: null,\n catalog: null,\n },\n };\n },\n states: {\n DeviceReady: {\n always: [\n {\n target: \"GoToDashboard\",\n guard: \"forceUpdate\",\n },\n {\n target: \"GetDeviceMetadataFromContext\",\n },\n ],\n },\n GetDeviceMetadataFromContext: {\n invoke: {\n src: \"getDeviceMetadata\",\n onDone: {\n target: \"GetDeviceMetadataFromContextResultCheck\",\n actions: assign({\n _internalState: (_) => {\n if (_.event.output === null) {\n return _.context._internalState;\n } else {\n return {\n ..._.context._internalState,\n firmwareVersion: _.event.output.firmwareVersion,\n firmwareUpdateContext:\n _.event.output.firmwareUpdateContext,\n customImage: _.event.output.customImage,\n applications: _.event.output.applications,\n applicationsUpdates: _.event.output.applicationsUpdates,\n installedLanguages: _.event.output.installedLanguages,\n catalog: _.event.output.catalog,\n };\n }\n },\n }),\n },\n onError: {\n target: \"Error\",\n actions: \"assignErrorFromEvent\",\n },\n },\n },\n GetDeviceMetadataFromContextResultCheck: {\n always: [\n {\n target: \"Success\",\n guard: \"hasMetadata\",\n },\n {\n target: \"GoToDashboard\",\n },\n ],\n },\n GoToDashboard: {\n exit: assign({\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.None,\n },\n }),\n invoke: {\n id: \"dashboard\",\n src: \"goToDashboard\",\n input: (_) => ({\n unlockTimeout: _.context.input.unlockTimeout,\n }),\n onSnapshot: {\n actions: assign({\n intermediateValue: (_) =>\n _.event.snapshot.context.intermediateValue,\n }),\n },\n onDone: {\n target: \"GoToDashboardCheck\",\n actions: assign({\n _internalState: (_) => {\n return _.event.output.caseOf({\n Right: () => _.context._internalState,\n Left: (error) => ({\n ..._.context._internalState,\n error,\n }),\n });\n },\n }),\n },\n onError: {\n target: \"Error\",\n actions: \"assignErrorFromEvent\",\n },\n },\n },\n GoToDashboardCheck: {\n always: [\n {\n target: \"Error\",\n guard: \"hasError\",\n },\n {\n target: \"GetFirmwareMetadata\",\n },\n ],\n },\n GetFirmwareMetadata: {\n invoke: {\n src: \"getFirmwareMetadata\",\n onDone: {\n target: \"GetFirmwareMetadataResultCheck\",\n actions: assign({\n _internalState: (_) => {\n if (isSuccessCommandResult(_.event.output)) {\n const deviceState = internalApi.getDeviceSessionState();\n if (\n deviceState.sessionStateType !==\n DeviceSessionStateType.Connected\n ) {\n internalApi.setDeviceSessionState({\n ...deviceState,\n firmwareVersion: _.event.output.data.firmwareVersion,\n firmwareUpdateContext:\n _.event.output.data.firmwareUpdateContext,\n customImage: _.event.output.data.customImage,\n });\n }\n return {\n ..._.context._internalState,\n deviceVersion: _.event.output.data.deviceVersion,\n firmware: _.event.output.data.firmware,\n firmwareVersion: _.event.output.data.firmwareVersion,\n firmwareUpdateContext:\n _.event.output.data.firmwareUpdateContext,\n customImage: _.event.output.data.customImage,\n };\n }\n return {\n ..._.context._internalState,\n error: _.event.output.error,\n };\n },\n }),\n },\n onError: {\n target: \"Error\",\n actions: \"assignErrorFromEvent\",\n },\n },\n },\n GetFirmwareMetadataResultCheck: {\n always: [\n {\n guard: \"hasError\",\n target: \"Error\",\n },\n {\n guard: \"useSecureChannel\",\n target: \"ListAppsSecureChannel\",\n },\n {\n target: \"ListApps\",\n },\n ],\n },\n ListAppsSecureChannel: {\n exit: assign({\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.None,\n },\n }),\n invoke: {\n id: \"listAppsSecureChannel\",\n src: \"listAppsSecureChannel\",\n input: (_) => ({\n firmware: _.context._internalState.firmware!,\n firmwareVersion: _.context._internalState.firmwareVersion!,\n }),\n onSnapshot: {\n actions: assign({\n intermediateValue: (_) => {\n switch (_.event.snapshot.context?.type) {\n case SecureChannelEventType.DeviceId: {\n return {\n ..._.context.intermediateValue,\n deviceId: _.event.snapshot.context.payload.deviceId,\n };\n }\n case SecureChannelEventType.PermissionRequested: {\n return {\n ..._.context.intermediateValue,\n requiredUserInteraction:\n UserInteractionRequired.AllowSecureConnection,\n };\n }\n case SecureChannelEventType.PermissionGranted: {\n const deviceState = internalApi.getDeviceSessionState();\n if (\n deviceState.sessionStateType !==\n DeviceSessionStateType.Connected\n ) {\n internalApi.setDeviceSessionState({\n ...deviceState,\n isSecureConnectionAllowed: true,\n });\n }\n return {\n ..._.context.intermediateValue,\n requiredUserInteraction: UserInteractionRequired.None,\n };\n }\n default:\n return {\n ..._.context.intermediateValue,\n };\n }\n },\n _internalState: (_) => {\n if (\n _.event.snapshot.context?.type ===\n SecureChannelEventType.Error\n ) {\n return {\n ..._.context._internalState,\n error: _.event.snapshot.context.error.mapDAErrors(),\n };\n } else if (\n _.event.snapshot.context?.type ===\n SecureChannelEventType.Result\n ) {\n if (\n installedAppResultGuard(_.event.snapshot.context.payload)\n ) {\n return {\n ..._.context._internalState,\n installedApps: _.event.snapshot.context.payload.map(\n (app) => ({\n name: app.name,\n hash: app.hash,\n hashCode: app.hash_code_data,\n }),\n ),\n };\n }\n throw new Error(\n `Invalid result ${JSON.stringify(_.event.snapshot.context.payload)}`,\n );\n }\n return { ..._.context._internalState };\n },\n }),\n },\n onDone: {\n target: \"ListAppsCheck\",\n },\n onError: {\n target: \"Error\",\n actions: \"assignErrorFromEvent\",\n },\n },\n },\n ListApps: {\n exit: assign({\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.None,\n },\n }),\n invoke: {\n id: \"listApps\",\n src: \"listApps\",\n input: (_) => ({\n unlockTimeout: _.context.input.unlockTimeout,\n }),\n onSnapshot: {\n actions: assign({\n intermediateValue: (_) =>\n _.event.snapshot.context.intermediateValue,\n }),\n },\n onDone: {\n target: \"ListAppsCheck\",\n actions: assign({\n _internalState: (_) => {\n if (_.event.output.isLeft()) {\n return {\n ..._.context._internalState,\n error: _.event.output.extract(),\n };\n } else {\n return {\n ..._.context._internalState,\n installedApps: _.event.output\n .unsafeCoerce()\n .map((app) => ({\n name: app.appName,\n hash: app.appFullHash,\n hashCode: app.appCodeHash,\n })),\n };\n }\n },\n }),\n },\n onError: {\n target: \"Error\",\n actions: \"assignErrorFromEvent\",\n },\n },\n },\n ListAppsCheck: {\n always: [\n {\n target: \"Error\",\n guard: \"hasError\",\n },\n {\n target: \"GetApplicationsMetadata\",\n },\n ],\n },\n GetApplicationsMetadata: {\n invoke: {\n src: \"getApplicationsMetadata\",\n input: (_) => ({\n deviceVersion: _.context._internalState.deviceVersion!,\n firmware: _.context._internalState.firmware!,\n firmwareVersion: _.context._internalState.firmwareVersion!,\n installedApps: _.context._internalState.installedApps!,\n }),\n onDone: {\n target: \"GetApplicationsMetadataResultCheck\",\n actions: assign({\n _internalState: (_) => {\n if (isSuccessCommandResult(_.event.output)) {\n const deviceState = internalApi.getDeviceSessionState();\n if (\n deviceState.sessionStateType !==\n DeviceSessionStateType.Connected\n ) {\n internalApi.setDeviceSessionState({\n ...deviceState,\n installedApps: _.event.output.data.applications,\n appsUpdates: _.event.output.data.applicationsUpdates,\n installedLanguages:\n _.event.output.data.installedLanguages,\n catalog: _.event.output.data.catalog,\n });\n }\n return {\n ..._.context._internalState,\n applications: _.event.output.data.applications,\n applicationsUpdates:\n _.event.output.data.applicationsUpdates,\n installedLanguages:\n _.event.output.data.installedLanguages,\n catalog: _.event.output.data.catalog,\n };\n }\n return {\n ..._.context._internalState,\n error: _.event.output.error,\n };\n },\n }),\n },\n onError: {\n target: \"Error\",\n actions: \"assignErrorFromEvent\",\n },\n },\n },\n GetApplicationsMetadataResultCheck: {\n always: [\n {\n guard: \"hasError\",\n target: \"Error\",\n },\n {\n target: \"Success\",\n },\n ],\n },\n Success: {\n type: \"final\",\n },\n Error: {\n type: \"final\",\n },\n },\n output: (args) => {\n const { context } = args;\n const {\n error,\n firmwareVersion,\n firmwareUpdateContext,\n customImage,\n applications,\n applicationsUpdates,\n installedLanguages,\n catalog,\n } = context._internalState;\n if (error) {\n return Left(error);\n }\n return Right({\n firmwareVersion: firmwareVersion!,\n firmwareUpdateContext: firmwareUpdateContext!,\n customImage: customImage!,\n applications: applications!,\n applicationsUpdates: applicationsUpdates!,\n installedLanguages: installedLanguages!,\n catalog: catalog!,\n });\n },\n });\n }\n\n extractDependencies(internalApi: InternalApi): MachineDependencies {\n const getDeviceMetadata = () => {\n const deviceState = internalApi.getDeviceSessionState();\n if (\n deviceState.sessionStateType === DeviceSessionStateType.Connected ||\n deviceState.firmwareVersion?.metadata === undefined ||\n deviceState.firmwareUpdateContext === undefined ||\n deviceState.customImage === undefined ||\n deviceState.installedApps.length === 0 ||\n deviceState.appsUpdates === undefined ||\n deviceState.installedLanguages === undefined ||\n deviceState.catalog === undefined\n ) {\n return Promise.resolve(null);\n }\n return Promise.resolve({\n firmwareVersion: deviceState.firmwareVersion,\n firmwareUpdateContext: deviceState.firmwareUpdateContext,\n customImage: deviceState.customImage,\n applications: deviceState.installedApps,\n applicationsUpdates: deviceState.appsUpdates,\n installedLanguages: deviceState.installedLanguages,\n catalog: deviceState.catalog,\n });\n };\n\n const getFirmwareMetadata = async () =>\n new GetFirmwareMetadataTask(internalApi).run();\n\n const getApplicationsMetadata = async (arg0: {\n input: {\n deviceVersion: DeviceVersion;\n firmware: FinalFirmware;\n firmwareVersion: FirmwareVersion;\n installedApps: InstalledApp[];\n };\n }) =>\n new GetApplicationsMetadataTask(internalApi, {\n deviceVersion: arg0.input.deviceVersion,\n firmware: arg0.input.firmware,\n firmwareVersion: arg0.input.firmwareVersion,\n installedApps: arg0.input.installedApps,\n }).run();\n\n const listAppsSecureChannel = (arg0: {\n input: {\n firmware: FinalFirmware;\n firmwareVersion: FirmwareVersion;\n };\n }) => {\n const { firmware, firmwareVersion } = arg0.input;\n const connection = internalApi\n .getSecureChannelService()\n .listInstalledApps(firmwareVersion.metadata!, firmware);\n return new ConnectToSecureChannelTask(internalApi, {\n connection,\n }).run();\n };\n\n return {\n getDeviceMetadata,\n getFirmwareMetadata,\n getApplicationsMetadata,\n listAppsSecureChannel,\n };\n }\n}\n"],
5
+ "mappings": "yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,mCAAAE,IAAA,eAAAC,EAAAH,GAAA,IAAAI,EAA4B,qBAE5BC,EAA2D,kBAE3DC,EAAuC,4CAEvCC,EAAwC,4DACxCC,EAA0C,uCAC1CC,EAA0C,yEAC1CC,EAAqC,+DACrCC,EAIO,+DACPC,EAGO,2DAEPC,EAGO,8DACPC,EAOO,kDACPC,EAAwC,qEACxCC,EAA2C,+DAC3CD,EAAuC,0CA4DhC,MAAMb,UAAsC,oBAMjD,CACA,iBACEe,EAOA,CASA,KAAM,CACJ,kBAAAC,EACA,oBAAAC,EACA,wBAAAC,EACA,sBAAAC,CACF,EAAI,KAAK,oBAAoBJ,CAAW,EAElCK,EAAgB,KAAK,MAAM,eAAiB,4BAE5CC,EAAuB,IAAI,4BAA0B,CACzD,MAAO,CACL,cAAAD,CACF,CACF,CAAC,EAAE,iBAAiBL,CAAW,EACzBO,EAAkB,IAAI,uBAAqB,CAC/C,MAAO,CACL,cAAAF,CACF,CACF,CAAC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AY,YACzB,aAAcA,EAAY,cAC1B,oBAAqBA,EAAY,YACjC,mBAAoBA,EAAY,mBAChC,QAASA,EAAY,OACvB,CAAC,CACH,EAqCE,oBAnC0B,SAC1B,IAAI,0BAAwBX,CAAW,EAAE,IAAI,EAmC7C,wBAjC8B,MAAOqB,GAQrC,IAAI,8BAA4BrB,EAAa,CAC3C,cAAeqB,EAAK,MAAM,cAC1B,SAAUA,EAAK,MAAM,SACrB,gBAAiBA,EAAK,MAAM,gBAC5B,cAAeA,EAAK,MAAM,aAC5B,CAAC,EAAE,IAAI,EAqBP,sBAnB6BA,GAKzB,CACJ,KAAM,CAAE,SAAAC,EAAU,gBAAAR,CAAgB,EAAIO,EAAK,MACrCE,EAAavB,EAChB,wBAAwB,EACxB,kBAAkBc,EAAgB,SAAWQ,CAAQ,EACxD,OAAO,IAAI,6BAA2BtB,EAAa,CACjD,WAAAuB,CACF,CAAC,EAAE,IAAI,CACT,CAOA,CACF,CACF",
6
6
  "names": ["GetDeviceMetadataDeviceAction_exports", "__export", "GetDeviceMetadataDeviceAction", "__toCommonJS", "import_purify_ts", "import_xstate", "import_CommandResult", "import_UserInteractionRequired", "import_Const", "import_GoToDashboardDeviceAction", "import_ListAppsDeviceAction", "import_GetApplicationsMetadataTask", "import_GetFirmwareMetadataTask", "import_XStateDeviceAction", "import_DeviceSessionState", "import_types", "import_ConnectToSecureChannelTask", "internalApi", "getDeviceMetadata", "getFirmwareMetadata", "getApplicationsMetadata", "listAppsSecureChannel", "unlockTimeout", "goToDashboardMachine", "listAppsMachine", "context", "_", "error", "deviceState", "app", "args", "firmwareVersion", "firmwareUpdateContext", "customImage", "applications", "applicationsUpdates", "installedLanguages", "catalog", "arg0", "firmware", "connection"]
7
7
  }
@@ -1,2 +1,2 @@
1
- "use strict";var o=Object.defineProperty;var i=Object.getOwnPropertyDescriptor;var n=Object.getOwnPropertyNames;var d=Object.prototype.hasOwnProperty;var s=(t,e,p,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let a of n(e))!d.call(t,a)&&a!==p&&o(t,a,{get:()=>e[a],enumerable:!(r=i(e,a))||r.enumerable});return t};var D=t=>s(o({},"__esModule",{value:!0}),t);var l={};module.exports=D(l);
1
+ "use strict";var o=Object.defineProperty;var p=Object.getOwnPropertyDescriptor;var n=Object.getOwnPropertyNames;var d=Object.prototype.hasOwnProperty;var s=(t,e,i,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let a of n(e))!d.call(t,a)&&a!==i&&o(t,a,{get:()=>e[a],enumerable:!(r=p(e,a))||r.enumerable});return t};var D=t=>s(o({},"__esModule",{value:!0}),t);var l={};module.exports=D(l);
2
2
  //# sourceMappingURL=types.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../../../../src/api/device-action/os/GetDeviceMetadata/types.ts"],
4
- "sourcesContent": ["import { type CommandErrorResult } from \"@api/command/model/CommandResult\";\nimport { type DeviceActionState } from \"@api/device-action/model/DeviceActionState\";\nimport {\n type GoToDashboardDAError,\n type GoToDashboardDAInput,\n type GoToDashboardDARequiredInteraction,\n} from \"@api/device-action/os/GoToDashboard/types\";\nimport {\n type ListAppsDAError,\n type ListAppsDARequiredInteraction,\n} from \"@api/device-action/os/ListApps/types\";\nimport {\n type Catalog,\n type CustomImage,\n type FirmwareUpdateContext,\n type FirmwareVersion,\n type InstalledLanguagePackage,\n} from \"@api/device-session/DeviceSessionState\";\nimport {\n type ListInstalledAppsDAError,\n type ListInstalledAppsDARequiredInteraction,\n} from \"@api/secure-channel/device-action/ListInstalledApps/types\";\nimport { type Application } from \"@internal/manager-api/model/Application\";\nimport { type SecureChannelDAErrors } from \"@internal/secure-channel/model/Errors\";\n\nexport type GetDeviceMetadataDAOutput = {\n readonly firmwareVersion: FirmwareVersion;\n readonly firmwareUpdateContext: FirmwareUpdateContext;\n readonly applications: Application[];\n readonly applicationsUpdates: Application[];\n readonly installedLanguages: InstalledLanguagePackage[];\n readonly catalog: Catalog;\n readonly customImage: CustomImage;\n};\n\nexport type GetDeviceMetadataDAInput = GoToDashboardDAInput & {\n readonly useSecureChannel?: boolean;\n readonly forceUpdate?: boolean;\n};\n\nexport type GetDeviceMetadataDAError =\n | GoToDashboardDAError\n | ListAppsDAError\n | ListInstalledAppsDAError\n | SecureChannelDAErrors\n | CommandErrorResult[\"error\"];\n\nexport type GetDeviceMetadataDARequiredInteraction =\n | GoToDashboardDARequiredInteraction\n | ListAppsDARequiredInteraction\n | ListInstalledAppsDARequiredInteraction;\n\nexport type GetDeviceMetadataDAIntermediateValue = {\n requiredUserInteraction: GetDeviceMetadataDARequiredInteraction;\n};\n\nexport type GetDeviceMetadataDAState = DeviceActionState<\n GetDeviceMetadataDAOutput,\n GetDeviceMetadataDAError,\n GetDeviceMetadataDAIntermediateValue\n>;\n"],
4
+ "sourcesContent": ["import { type CommandErrorResult } from \"@api/command/model/CommandResult\";\nimport { type DeviceActionState } from \"@api/device-action/model/DeviceActionState\";\nimport {\n type GoToDashboardDAError,\n type GoToDashboardDAInput,\n type GoToDashboardDARequiredInteraction,\n} from \"@api/device-action/os/GoToDashboard/types\";\nimport {\n type ListAppsDAError,\n type ListAppsDARequiredInteraction,\n} from \"@api/device-action/os/ListApps/types\";\nimport {\n type Catalog,\n type CustomImage,\n type FirmwareUpdateContext,\n type FirmwareVersion,\n type InstalledLanguagePackage,\n} from \"@api/device-session/DeviceSessionState\";\nimport {\n type ListInstalledAppsDAError,\n type ListInstalledAppsDARequiredInteraction,\n} from \"@api/secure-channel/device-action/ListInstalledApps/types\";\nimport { type Application } from \"@internal/manager-api/model/Application\";\nimport { type SecureChannelDAErrors } from \"@internal/secure-channel/model/Errors\";\n\nexport type GetDeviceMetadataDAOutput = {\n readonly firmwareVersion: FirmwareVersion;\n readonly firmwareUpdateContext: FirmwareUpdateContext;\n readonly applications: Application[];\n readonly applicationsUpdates: Application[];\n readonly installedLanguages: InstalledLanguagePackage[];\n readonly catalog: Catalog;\n readonly customImage: CustomImage;\n};\n\nexport type GetDeviceMetadataDAInput = GoToDashboardDAInput & {\n readonly useSecureChannel?: boolean;\n readonly forceUpdate?: boolean;\n};\n\nexport type GetDeviceMetadataDAError =\n | GoToDashboardDAError\n | ListAppsDAError\n | ListInstalledAppsDAError\n | SecureChannelDAErrors\n | CommandErrorResult[\"error\"];\n\nexport type GetDeviceMetadataDARequiredInteraction =\n | GoToDashboardDARequiredInteraction\n | ListAppsDARequiredInteraction\n | ListInstalledAppsDARequiredInteraction;\n\nexport type GetDeviceMetadataDAIntermediateValue = {\n requiredUserInteraction: GetDeviceMetadataDARequiredInteraction;\n deviceId?: Uint8Array;\n};\n\nexport type GetDeviceMetadataDAState = DeviceActionState<\n GetDeviceMetadataDAOutput,\n GetDeviceMetadataDAError,\n GetDeviceMetadataDAIntermediateValue\n>;\n"],
5
5
  "mappings": "+WAAA,IAAAA,EAAA,kBAAAC,EAAAD",
6
6
  "names": ["types_exports", "__toCommonJS"]
7
7
  }
@@ -1,2 +1,2 @@
1
- "use strict";var m=Object.defineProperty;var U=Object.getOwnPropertyDescriptor;var G=Object.getOwnPropertyNames;var x=Object.prototype.hasOwnProperty;var O=(i,t)=>{for(var a in t)m(i,a,{get:t[a],enumerable:!0})},C=(i,t,a,s)=>{if(t&&typeof t=="object"||typeof t=="function")for(let r of G(t))!x.call(i,r)&&r!==a&&m(i,r,{get:()=>t[r],enumerable:!(s=U(t,r))||s.enumerable});return i};var I=i=>C(m({},"__esModule",{value:!0}),i);var T={};O(T,{GetDeviceStatusDeviceAction:()=>M});module.exports=I(T);var D=require("purify-ts"),g=require("rxjs"),S=require("rxjs/operators"),n=require("xstate"),k=require("../../../command/model/CommandResult"),f=require("../../../command/os/GetAppAndVersionCommand"),y=require("../../../device/DeviceStatus"),c=require("../../../device-action/model/UserInteractionRequired"),b=require("../../../device-action/os/Const"),v=require("../../../device-action/os/Errors"),E=require("../../../device-action/xstate-utils/XStateDeviceAction"),d=require("../../../device-session/DeviceSessionState");class M extends E.XStateDeviceAction{makeStateMachine(t){const{getAppAndVersion:a,getDeviceSessionState:s,setDeviceSessionState:r,waitForDeviceUnlock:A,isDeviceOnboarded:u}=this.extractDependencies(t),p=this.input.unlockTimeout??b.DEFAULT_UNLOCK_TIMEOUT_MS;return(0,n.setup)({types:{input:{unlockTimeout:p},context:{},output:{}},actors:{getAppAndVersion:(0,n.fromPromise)(a),waitForDeviceUnlock:(0,n.fromObservable)(A)},guards:{isDeviceOnboarded:()=>u(),isDeviceLocked:({context:e})=>e._internalState.locked,hasError:({context:e})=>e._internalState.error!==null},actions:{assignErrorDeviceNotOnboarded:(0,n.assign)({_internalState:e=>({...e.context._internalState,error:new v.DeviceNotOnboardedError})}),assignErrorDeviceLocked:(0,n.assign)({_internalState:e=>({...e.context._internalState,error:new v.DeviceLockedError}),intermediateValue:{requiredUserInteraction:c.UserInteractionRequired.UnlockDevice}}),assignErrorFromEvent:(0,n.assign)({_internalState:e=>({...e.context._internalState,error:e.event.error})}),assignNoUserActionNeeded:(0,n.assign)({intermediateValue:e=>({...e.context.intermediateValue,requiredUserInteraction:c.UserInteractionRequired.None})}),assignUserActionUnlockNeeded:(0,n.assign)({intermediateValue:e=>({...e.context.intermediateValue,requiredUserInteraction:c.UserInteractionRequired.UnlockDevice})})}}).createMachine({id:"GetDeviceStatusDeviceAction",initial:"DeviceReady",context:e=>{const o=s(),{sessionStateType:l}=o;return{input:{unlockTimeout:e.input.unlockTimeout},intermediateValue:{requiredUserInteraction:c.UserInteractionRequired.None},_internalState:{onboarded:!1,locked:!1,currentApp:l===d.DeviceSessionStateType.ReadyWithoutSecureChannel?o.currentApp.name:null,currentAppVersion:null,error:null}}},states:{DeviceReady:{always:{target:"OnboardingCheck"}},OnboardingCheck:{always:[{guard:{type:"isDeviceOnboarded"},target:"AppAndVersionCheck",actions:(0,n.assign)({_internalState:e=>({...e.context._internalState,onboarded:!0})})},{target:"Error",actions:"assignErrorDeviceNotOnboarded"}]},UserActionUnlockDevice:{entry:"assignUserActionUnlockNeeded",exit:"assignNoUserActionNeeded",invoke:{id:"UserActionUnlockDevice",src:"waitForDeviceUnlock",input:e=>({unlockTimeout:p}),onDone:{target:"AppAndVersionCheck",actions:(0,n.assign)({_internalState:e=>({...e.context._internalState,locked:!1})})},onError:{target:"Error",actions:"assignErrorDeviceLocked"}}},AppAndVersionCheck:{invoke:{src:"getAppAndVersion",onDone:{target:"ApplicationAvailableResultCheck",actions:(0,n.assign)({_internalState:e=>{if((0,k.isSuccessCommandResult)(e.event.output)){const o=s();return o.sessionStateType!==d.DeviceSessionStateType.Connected?r({...o,currentApp:e.event.output.data}):r({deviceModelId:o.deviceModelId,sessionStateType:d.DeviceSessionStateType.ReadyWithoutSecureChannel,deviceStatus:y.DeviceStatus.CONNECTED,currentApp:e.event.output.data,installedApps:[],isSecureConnectionAllowed:!1}),{...e.context._internalState,locked:!1,currentApp:e.event.output.data.name,currentAppVersion:e.event.output.data.version}}if("errorCode"in e.event.output.error){if(e.event.output.error.errorCode==="5515")return{...e.context._internalState,locked:!0};if(e.event.output.error.errorCode==="6e00")return{...e.context._internalState,locked:!1,currentApp:"BOLOS",currentAppVersion:"0.0.0"}}return{...e.context._internalState,error:e.event.output.error}}})},onError:{target:"Error",actions:"assignErrorFromEvent"}}},ApplicationAvailableResultCheck:{always:[{guard:"hasError",target:"Error"},{target:"UserActionUnlockDevice",guard:"isDeviceLocked"},{target:"Success"}]},Success:{type:"final"},Error:{type:"final"}},output:e=>{const{context:o}=e,{error:l,currentApp:h,currentAppVersion:V}=o._internalState;return l?(0,D.Left)(l):(0,D.Right)({currentApp:h,currentAppVersion:V})}})}extractDependencies(t){return{getAppAndVersion:()=>t.sendCommand(new f.GetAppAndVersionCommand),waitForDeviceUnlock:({input:r})=>new g.Observable(A=>{const u=t.getDeviceSessionStateObservable().pipe((0,S.tap)(p=>{p.deviceStatus===y.DeviceStatus.CONNECTED&&(A.complete(),u.unsubscribe())})).subscribe();return()=>{u.unsubscribe()}}).pipe((0,S.timeout)(r.unlockTimeout)),getDeviceSessionState:()=>t.getDeviceSessionState(),setDeviceSessionState:r=>t.setDeviceSessionState(r),isDeviceOnboarded:()=>!0}}}0&&(module.exports={GetDeviceStatusDeviceAction});
1
+ "use strict";var v=Object.defineProperty;var G=Object.getOwnPropertyDescriptor;var b=Object.getOwnPropertyNames;var x=Object.prototype.hasOwnProperty;var C=(o,t)=>{for(var s in t)v(o,s,{get:t[s],enumerable:!0})},I=(o,t,s,c)=>{if(t&&typeof t=="object"||typeof t=="function")for(let i of b(t))!x.call(o,i)&&i!==s&&v(o,i,{get:()=>t[i],enumerable:!(c=G(t,i))||c.enumerable});return o};var O=o=>I(v({},"__esModule",{value:!0}),o);var T={};C(T,{GetDeviceStatusDeviceAction:()=>M});module.exports=O(T);var D=require("purify-ts"),n=require("rxjs"),g=require("rxjs/operators"),r=require("xstate"),A=require("../../../command/model/CommandResult"),m=require("../../../command/os/GetAppAndVersionCommand"),f=require("../../../device/DeviceStatus"),p=require("../../../device-action/model/UserInteractionRequired"),h=require("../../../device-action/os/Const"),S=require("../../../device-action/os/Errors"),E=require("../../../device-action/xstate-utils/XStateDeviceAction"),l=require("../../../device-session/DeviceSessionState");class M extends E.XStateDeviceAction{makeStateMachine(t){const{getAppAndVersion:s,getDeviceSessionState:c,setDeviceSessionState:i,waitForDeviceUnlock:u,isDeviceOnboarded:y}=this.extractDependencies(t),k=this.input.unlockTimeout??h.DEFAULT_UNLOCK_TIMEOUT_MS;return(0,r.setup)({types:{input:{unlockTimeout:k},context:{},output:{}},actors:{getAppAndVersion:(0,r.fromPromise)(s),waitForDeviceUnlock:(0,r.fromObservable)(u)},guards:{isDeviceOnboarded:()=>y(),isDeviceLocked:({context:e})=>e._internalState.locked,hasError:({context:e})=>e._internalState.error!==null},actions:{assignErrorDeviceNotOnboarded:(0,r.assign)({_internalState:e=>({...e.context._internalState,error:new S.DeviceNotOnboardedError})}),assignErrorDeviceLocked:(0,r.assign)({_internalState:e=>({...e.context._internalState,error:new S.DeviceLockedError}),intermediateValue:{requiredUserInteraction:p.UserInteractionRequired.UnlockDevice}}),assignErrorFromEvent:(0,r.assign)({_internalState:e=>({...e.context._internalState,error:e.event.error})}),assignNoUserActionNeeded:(0,r.assign)({intermediateValue:e=>({...e.context.intermediateValue,requiredUserInteraction:p.UserInteractionRequired.None})}),assignUserActionUnlockNeeded:(0,r.assign)({intermediateValue:e=>({...e.context.intermediateValue,requiredUserInteraction:p.UserInteractionRequired.UnlockDevice})})}}).createMachine({id:"GetDeviceStatusDeviceAction",initial:"DeviceReady",context:e=>{const a=c(),{sessionStateType:d}=a;return{input:{unlockTimeout:e.input.unlockTimeout},intermediateValue:{requiredUserInteraction:p.UserInteractionRequired.None},_internalState:{onboarded:!1,locked:!1,currentApp:d===l.DeviceSessionStateType.ReadyWithoutSecureChannel?a.currentApp.name:null,currentAppVersion:null,error:null}}},states:{DeviceReady:{always:{target:"OnboardingCheck"}},OnboardingCheck:{always:[{guard:{type:"isDeviceOnboarded"},target:"AppAndVersionCheck",actions:(0,r.assign)({_internalState:e=>({...e.context._internalState,onboarded:!0})})},{target:"Error",actions:"assignErrorDeviceNotOnboarded"}]},UserActionUnlockDevice:{entry:"assignUserActionUnlockNeeded",exit:"assignNoUserActionNeeded",invoke:{id:"UserActionUnlockDevice",src:"waitForDeviceUnlock",input:e=>({unlockTimeout:k}),onDone:{target:"AppAndVersionCheck",actions:(0,r.assign)({_internalState:e=>({...e.context._internalState,locked:!1})})},onError:{target:"Error",actions:"assignErrorDeviceLocked"}}},AppAndVersionCheck:{invoke:{src:"getAppAndVersion",onDone:{target:"ApplicationAvailableResultCheck",actions:(0,r.assign)({_internalState:e=>{if((0,A.isSuccessCommandResult)(e.event.output)){const a=c();return a.sessionStateType!==l.DeviceSessionStateType.Connected?i({...a,currentApp:e.event.output.data}):i({deviceModelId:a.deviceModelId,sessionStateType:l.DeviceSessionStateType.ReadyWithoutSecureChannel,deviceStatus:f.DeviceStatus.CONNECTED,currentApp:e.event.output.data,installedApps:[],isSecureConnectionAllowed:!1}),{...e.context._internalState,locked:!1,currentApp:e.event.output.data.name,currentAppVersion:e.event.output.data.version}}if("errorCode"in e.event.output.error){if(e.event.output.error.errorCode==="5515")return{...e.context._internalState,locked:!0};if(e.event.output.error.errorCode==="6e00")return{...e.context._internalState,locked:!1,currentApp:"BOLOS",currentAppVersion:"0.0.0"}}return{...e.context._internalState,error:e.event.output.error}}})},onError:{target:"Error",actions:"assignErrorFromEvent"}}},ApplicationAvailableResultCheck:{always:[{guard:"hasError",target:"Error"},{target:"UserActionUnlockDevice",guard:"isDeviceLocked"},{target:"Success"}]},Success:{type:"final"},Error:{type:"final"}},output:e=>{const{context:a}=e,{error:d,currentApp:V,currentAppVersion:U}=a._internalState;return d?(0,D.Left)(d):(0,D.Right)({currentApp:V,currentAppVersion:U})}})}extractDependencies(t){return{getAppAndVersion:()=>t.sendCommand(new m.GetAppAndVersionCommand),waitForDeviceUnlock:({input:i})=>(0,n.interval)(1e3).pipe((0,n.switchMap)(()=>(0,n.from)(t.sendCommand(new m.GetAppAndVersionCommand))),(0,n.mergeMap)(u=>!(0,A.isSuccessCommandResult)(u)&&"errorCode"in u.error&&u.error.errorCode==="5515"?n.EMPTY:(0,n.of)(void 0)),(0,n.take)(1),(0,g.timeout)(i.unlockTimeout)),getDeviceSessionState:()=>t.getDeviceSessionState(),setDeviceSessionState:i=>t.setDeviceSessionState(i),isDeviceOnboarded:()=>!0}}}0&&(module.exports={GetDeviceStatusDeviceAction});
2
2
  //# sourceMappingURL=GetDeviceStatusDeviceAction.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../../../../src/api/device-action/os/GetDeviceStatus/GetDeviceStatusDeviceAction.ts"],
4
- "sourcesContent": ["import { Left, Right } from \"purify-ts\";\nimport { Observable } from \"rxjs\";\nimport { tap, timeout } from \"rxjs/operators\";\nimport { assign, fromObservable, fromPromise, setup } from \"xstate\";\n\nimport { isSuccessCommandResult } from \"@api/command/model/CommandResult\";\nimport {\n GetAppAndVersionCommand,\n type GetAppAndVersionCommandResult,\n} from \"@api/command/os/GetAppAndVersionCommand\";\nimport { DeviceStatus } from \"@api/device/DeviceStatus\";\nimport { type InternalApi } from \"@api/device-action/DeviceAction\";\nimport { UserInteractionRequired } from \"@api/device-action/model/UserInteractionRequired\";\nimport { DEFAULT_UNLOCK_TIMEOUT_MS } from \"@api/device-action/os/Const\";\nimport {\n DeviceLockedError,\n DeviceNotOnboardedError,\n} from \"@api/device-action/os/Errors\";\nimport { type StateMachineTypes } from \"@api/device-action/xstate-utils/StateMachineTypes\";\nimport {\n type DeviceActionStateMachine,\n XStateDeviceAction,\n} from \"@api/device-action/xstate-utils/XStateDeviceAction\";\nimport {\n type DeviceSessionState,\n DeviceSessionStateType,\n} from \"@api/device-session/DeviceSessionState\";\n\nimport {\n type GetDeviceStatusDAError,\n type GetDeviceStatusDAInput,\n type GetDeviceStatusDAIntermediateValue,\n type GetDeviceStatusDAOutput,\n} from \"./types\";\n\ntype GetDeviceStatusMachineInternalState = {\n readonly onboarded: boolean;\n readonly locked: boolean;\n readonly currentApp: string | null;\n readonly currentAppVersion: string | null;\n readonly error: GetDeviceStatusDAError | null;\n};\n\nexport type MachineDependencies = {\n readonly getAppAndVersion: () => Promise<GetAppAndVersionCommandResult>;\n readonly getDeviceSessionState: () => DeviceSessionState;\n readonly waitForDeviceUnlock: (args: {\n input: { unlockTimeout: number };\n }) => Observable<void>;\n readonly setDeviceSessionState: (\n state: DeviceSessionState,\n ) => DeviceSessionState;\n readonly isDeviceOnboarded: () => boolean;\n};\n\nexport type ExtractMachineDependencies = (\n internalApi: InternalApi,\n) => MachineDependencies;\n\nexport class GetDeviceStatusDeviceAction extends XStateDeviceAction<\n GetDeviceStatusDAOutput,\n GetDeviceStatusDAInput,\n GetDeviceStatusDAError,\n GetDeviceStatusDAIntermediateValue,\n GetDeviceStatusMachineInternalState\n> {\n makeStateMachine(\n internalApi: InternalApi,\n ): DeviceActionStateMachine<\n GetDeviceStatusDAOutput,\n GetDeviceStatusDAInput,\n GetDeviceStatusDAError,\n GetDeviceStatusDAIntermediateValue,\n GetDeviceStatusMachineInternalState\n > {\n type types = StateMachineTypes<\n GetDeviceStatusDAOutput,\n GetDeviceStatusDAInput,\n GetDeviceStatusDAError,\n GetDeviceStatusDAIntermediateValue,\n GetDeviceStatusMachineInternalState\n >;\n\n const {\n getAppAndVersion,\n getDeviceSessionState,\n setDeviceSessionState,\n waitForDeviceUnlock,\n isDeviceOnboarded,\n } = this.extractDependencies(internalApi);\n\n const unlockTimeout = this.input.unlockTimeout ?? DEFAULT_UNLOCK_TIMEOUT_MS;\n\n return setup({\n types: {\n input: {\n unlockTimeout,\n } as types[\"input\"],\n context: {} as types[\"context\"],\n output: {} as types[\"output\"],\n },\n actors: {\n getAppAndVersion: fromPromise(getAppAndVersion),\n waitForDeviceUnlock: fromObservable(waitForDeviceUnlock),\n },\n guards: {\n isDeviceOnboarded: () => isDeviceOnboarded(), // TODO: we don't have this info for now, this can be derived from the \"flags\" obtained in the getVersion command\n isDeviceLocked: ({ context }) => context._internalState.locked,\n hasError: ({ context }) => context._internalState.error !== null,\n },\n actions: {\n assignErrorDeviceNotOnboarded: assign({\n _internalState: (_) => ({\n ..._.context._internalState,\n error: new DeviceNotOnboardedError(),\n }),\n }),\n assignErrorDeviceLocked: assign({\n _internalState: (_) => ({\n ..._.context._internalState,\n error: new DeviceLockedError(),\n }),\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.UnlockDevice,\n },\n }),\n assignErrorFromEvent: assign({\n _internalState: (_) => ({\n ..._.context._internalState,\n error: _.event[\"error\"], // NOTE: it should never happen, the error is not typed anymore here\n }),\n }),\n assignNoUserActionNeeded: assign({\n intermediateValue: (_) =>\n ({\n ..._.context.intermediateValue,\n requiredUserInteraction: UserInteractionRequired.None,\n }) satisfies types[\"context\"][\"intermediateValue\"],\n }),\n assignUserActionUnlockNeeded: assign({\n intermediateValue: (_) =>\n ({\n ..._.context.intermediateValue,\n requiredUserInteraction: UserInteractionRequired.UnlockDevice,\n }) satisfies types[\"context\"][\"intermediateValue\"],\n }),\n },\n }).createMachine({\n /** @xstate-layout N4IgpgJg5mDOIC5QHEwBcAiYBuBLAxmAMpoCGaArrFnoQIL5q4D2AdgHQ0FgBKYpEAJ4BiANoAGALqJQAB2axcTNjJAAPRAFoArAHZx7AIwAmQ7oCcugMyHzANmMAWYwBoQgxI8vsAHOJM+VuLmVj5e2gC+EW6omDjcJORUXPSMLBwA8qwARsykAE4QuKxQAMIAFmD4ANZiUqryisqsqhoImo4O7OGhPj4h5n6Obh4IunZ2RoZ+ena6nYaGUTHoKcRklNTxqc3sWbkFRSUVVbWihtJIII1K6a1aVtoGTxOOjtbv84YjiObik7ofPM7GFDP9jNofMsQLE1olNmsGLsADLMGrFMqVGp1S5yBS3FRXNqaOzadjiHx2KyORbzcRBczmH4IbTOdjaabaKmdGy6XSRaIw1bbdZJLa0MBI9LsVHo45Ys4XBr45r3dps-n0ubaGxgx6PZlWULkkLBGmDCzGYzQ2Ei+HJEVStjsACqsDA+SdrBdrAANmjqmthBA2GB2MVsMxqmG3R6vT7-TU1hJcdcVXciYgglZycYQiYqRTQoZtMynDmbM4aW8rHYzD4BSs4hL7eLuF7Xe7PWk2AmA0GPflmPl2LJfeQAGbDgC2nbjPe9fv7IpTyqaGdAbXmxnZPkMNNM820VuZ+8M7Dsb3MznpwW31sFtpbGwdEo7dFksjorAgADUPYobAnNiIasGGEZRmGT4JC+bY7NKH5fj+-75IBrDAdUCAQfg5DpCmq5XDcqqZmMjgGDY-yGJeejjFRzJ2P47DZoEJb+Hyx42sKz5ioiC7sIh35-gB6QYcIg7DqO45oFO+SztBhCtrxuwCchwlAQqWGsJGOHNPh9SEemhKbogdLsIMTjmPuNF1nYZaOBW+5OPu9l1oCjZCs2ME8Y6fGIb6BC4WwdDYKQuDjtkvq8HAFC+mgokEXi65GeoiBguYZJOPSJa6Hm1hGsyuglkxxiUjYVjXlq7nyaKCI+cpn7+Tp6TBaF4WRXwsAxXFCpiEqBlJS0JFAo4vg+BCe55e8-QFUVVglVShjlWRtZ2FEgqsMwEBwKo1WKXVG5pgNaokmRZmQg4fyLHR7ieCNpjGPyx7aNo6UNo4nGeQpsFKdKax8AIoyJQSg3Ge0L07q9F3+Istk3Qg1IjUaZ7GNS-LlU4H1wt9+3OvseSFBiGFrsDx01mZ15mHooReFaVj0fZ5Jci5zissYIKY3a2NvnxsrVITCrE8RoMdDucxWgx1jpZCELDHDgKTC9jg6mNXKLDSHPcbV3O7LG3bNH2SYioLB3EmCI1-HuVL6Cj4hU6eNjsIVD3UrWfKXVCj5cV5Wvtr5n6CShaFE-1JMkWzPgXpCjh+Faw3Mjq5jdOlJhGvo-RzRr3uvr79VjgFzQtWFpARVFnWxcHQNCylCBm+eKPjJL4jWMEdNww4O46vSFVsfyD5Nlj3na9KRAUPghCwPAIdV20QIR7e-RzOYbNK98cN7ndgR-BSzgo+YmdfYPOfSgAovkQ75MbyVtItehmSrJgcijz2uHD+pmXyQSQnyVLs2tQA */\n id: \"GetDeviceStatusDeviceAction\",\n initial: \"DeviceReady\",\n context: (_) => {\n const sessionState = getDeviceSessionState();\n const { sessionStateType } = sessionState;\n return {\n input: {\n unlockTimeout: _.input.unlockTimeout,\n },\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.None,\n },\n _internalState: {\n onboarded: false, // we don't know how to check yet\n locked: false,\n currentApp:\n sessionStateType ===\n DeviceSessionStateType.ReadyWithoutSecureChannel\n ? sessionState.currentApp.name\n : null,\n currentAppVersion: null,\n error: null,\n },\n };\n },\n states: {\n DeviceReady: {\n always: {\n target: \"OnboardingCheck\",\n },\n },\n OnboardingCheck: {\n // TODO: we don't have this info for now\n always: [\n {\n guard: {\n type: \"isDeviceOnboarded\",\n },\n target: \"AppAndVersionCheck\",\n actions: assign({\n _internalState: (_) => ({\n ..._.context._internalState,\n onboarded: true,\n }),\n }),\n },\n {\n target: \"Error\",\n actions: \"assignErrorDeviceNotOnboarded\",\n },\n ],\n },\n UserActionUnlockDevice: {\n // we wait for the device to be unlocked (default timeout is 15s)\n entry: \"assignUserActionUnlockNeeded\",\n exit: \"assignNoUserActionNeeded\",\n invoke: {\n id: \"UserActionUnlockDevice\",\n src: \"waitForDeviceUnlock\",\n input: (_) => ({\n unlockTimeout,\n }),\n onDone: {\n target: \"AppAndVersionCheck\",\n actions: assign({\n _internalState: (_) => ({\n ..._.context._internalState,\n locked: false,\n }),\n }),\n },\n onError: {\n target: \"Error\",\n actions: \"assignErrorDeviceLocked\",\n },\n },\n },\n AppAndVersionCheck: {\n // We check the current app and version using the getAppAndVersion command\n invoke: {\n src: \"getAppAndVersion\",\n onDone: {\n target: \"ApplicationAvailableResultCheck\",\n actions: assign({\n _internalState: (_) => {\n if (isSuccessCommandResult(_.event.output)) {\n const state: DeviceSessionState = getDeviceSessionState();\n if (\n state.sessionStateType !==\n DeviceSessionStateType.Connected\n ) {\n // Update the current app\n setDeviceSessionState({\n ...state,\n currentApp: _.event.output.data,\n });\n } else {\n // The device can be set to Ready if GetAppAndVersionCommand was successful\n setDeviceSessionState({\n deviceModelId: state.deviceModelId,\n sessionStateType:\n DeviceSessionStateType.ReadyWithoutSecureChannel,\n deviceStatus: DeviceStatus.CONNECTED,\n currentApp: _.event.output.data,\n installedApps: [],\n isSecureConnectionAllowed: false,\n });\n }\n return {\n ..._.context._internalState,\n locked: false,\n currentApp: _.event.output.data.name,\n currentAppVersion: _.event.output.data.version,\n };\n }\n if (\"errorCode\" in _.event.output.error) {\n if (_.event.output.error.errorCode === \"5515\") {\n // Locked device error\n return {\n ..._.context._internalState,\n locked: true,\n };\n } else if (_.event.output.error.errorCode === \"6e00\") {\n // CLA not supported\n // GetAppAndVersion should always be supported by the firmware or any app.\n // But on old firmware versions, that APDU was not supported in the dashboard.\n // On those firmwares, it fails with CLA_NOT_SUPPORTED in BOLOS, and INS_NOT_SUPPORTED\n // in applications. Therefore if CLA is not supported, we can consider we're on the\n // dashboard on an old firmware. We should therefore return that information to\n // ensure the user can still update his firmware and is not blocked at this step.\n return {\n ..._.context._internalState,\n locked: false,\n currentApp: \"BOLOS\",\n currentAppVersion: \"0.0.0\",\n };\n }\n }\n return {\n ..._.context._internalState,\n error: _.event.output.error,\n };\n },\n }),\n },\n onError: {\n target: \"Error\",\n actions: \"assignErrorFromEvent\",\n },\n },\n },\n ApplicationAvailableResultCheck: {\n always: [\n {\n guard: \"hasError\",\n target: \"Error\",\n },\n {\n target: \"UserActionUnlockDevice\",\n guard: \"isDeviceLocked\",\n },\n {\n target: \"Success\",\n },\n ],\n },\n Success: {\n type: \"final\",\n },\n Error: {\n type: \"final\",\n },\n },\n output: (args) => {\n // TODO: instead we should rely on the current state (\"Success\" or \"Error\")\n const { context } = args;\n const { error, currentApp, currentAppVersion } = context._internalState;\n if (error) {\n return Left(error);\n }\n return Right<GetDeviceStatusDAOutput>({\n currentApp: currentApp!,\n currentAppVersion: currentAppVersion!,\n });\n },\n });\n }\n\n extractDependencies(internalApi: InternalApi): MachineDependencies {\n const getAppAndVersion = () => {\n return internalApi.sendCommand(new GetAppAndVersionCommand());\n };\n\n const waitForDeviceUnlock = ({\n input,\n }: {\n input: { unlockTimeout: number };\n }) =>\n new Observable<void>((subscriber) => {\n const inner = internalApi\n .getDeviceSessionStateObservable()\n .pipe(\n tap((state) => {\n if (state.deviceStatus === DeviceStatus.CONNECTED) {\n subscriber.complete();\n inner.unsubscribe();\n }\n }),\n )\n .subscribe();\n\n return () => {\n inner.unsubscribe();\n };\n }).pipe(timeout(input.unlockTimeout));\n\n return {\n getAppAndVersion,\n waitForDeviceUnlock,\n getDeviceSessionState: () => internalApi.getDeviceSessionState(),\n setDeviceSessionState: (state: DeviceSessionState) =>\n internalApi.setDeviceSessionState(state),\n isDeviceOnboarded: () => true, // TODO: we don't have this info for now\n };\n }\n}\n"],
5
- "mappings": "yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,iCAAAE,IAAA,eAAAC,EAAAH,GAAA,IAAAI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0B,CAAC,CAC3B,MAAAgB,CACF,IAGE,IAAI,aAAkBC,GAAe,CACnC,MAAMC,EAAQlB,EACX,gCAAgC,EAChC,QACC,OAAKW,GAAU,CACTA,EAAM,eAAiB,eAAa,YACtCM,EAAW,SAAS,EACpBC,EAAM,YAAY,EAEtB,CAAC,CACH,EACC,UAAU,EAEb,MAAO,IAAM,CACXA,EAAM,YAAY,CACpB,CACF,CAAC,EAAE,QAAK,WAAQF,EAAM,aAAa,CAAC,EAKpC,sBAAuB,IAAMhB,EAAY,sBAAsB,EAC/D,sBAAwBW,GACtBX,EAAY,sBAAsBW,CAAK,EACzC,kBAAmB,IAAM,EAC3B,CACF,CACF",
6
- "names": ["GetDeviceStatusDeviceAction_exports", "__export", "GetDeviceStatusDeviceAction", "__toCommonJS", "import_purify_ts", "import_rxjs", "import_operators", "import_xstate", "import_CommandResult", "import_GetAppAndVersionCommand", "import_DeviceStatus", "import_UserInteractionRequired", "import_Const", "import_Errors", "import_XStateDeviceAction", "import_DeviceSessionState", "internalApi", "getAppAndVersion", "getDeviceSessionState", "setDeviceSessionState", "waitForDeviceUnlock", "isDeviceOnboarded", "unlockTimeout", "context", "_", "sessionState", "sessionStateType", "state", "args", "error", "currentApp", "currentAppVersion", "input", "subscriber", "inner"]
4
+ "sourcesContent": ["import { Left, Right } from \"purify-ts\";\nimport {\n EMPTY,\n from,\n interval,\n mergeMap,\n type Observable,\n of,\n switchMap,\n take,\n} from \"rxjs\";\nimport { timeout } from \"rxjs/operators\";\nimport { assign, fromObservable, fromPromise, setup } from \"xstate\";\n\nimport { isSuccessCommandResult } from \"@api/command/model/CommandResult\";\nimport {\n GetAppAndVersionCommand,\n type GetAppAndVersionCommandResult,\n} from \"@api/command/os/GetAppAndVersionCommand\";\nimport { DeviceStatus } from \"@api/device/DeviceStatus\";\nimport { type InternalApi } from \"@api/device-action/DeviceAction\";\nimport { UserInteractionRequired } from \"@api/device-action/model/UserInteractionRequired\";\nimport { DEFAULT_UNLOCK_TIMEOUT_MS } from \"@api/device-action/os/Const\";\nimport {\n DeviceLockedError,\n DeviceNotOnboardedError,\n} from \"@api/device-action/os/Errors\";\nimport { type StateMachineTypes } from \"@api/device-action/xstate-utils/StateMachineTypes\";\nimport {\n type DeviceActionStateMachine,\n XStateDeviceAction,\n} from \"@api/device-action/xstate-utils/XStateDeviceAction\";\nimport {\n type DeviceSessionState,\n DeviceSessionStateType,\n} from \"@api/device-session/DeviceSessionState\";\n\nimport {\n type GetDeviceStatusDAError,\n type GetDeviceStatusDAInput,\n type GetDeviceStatusDAIntermediateValue,\n type GetDeviceStatusDAOutput,\n} from \"./types\";\n\ntype GetDeviceStatusMachineInternalState = {\n readonly onboarded: boolean;\n readonly locked: boolean;\n readonly currentApp: string | null;\n readonly currentAppVersion: string | null;\n readonly error: GetDeviceStatusDAError | null;\n};\n\nexport type MachineDependencies = {\n readonly getAppAndVersion: () => Promise<GetAppAndVersionCommandResult>;\n readonly getDeviceSessionState: () => DeviceSessionState;\n readonly waitForDeviceUnlock: (args: {\n input: { unlockTimeout: number };\n }) => Observable<void>;\n readonly setDeviceSessionState: (\n state: DeviceSessionState,\n ) => DeviceSessionState;\n readonly isDeviceOnboarded: () => boolean;\n};\n\nexport type ExtractMachineDependencies = (\n internalApi: InternalApi,\n) => MachineDependencies;\n\nexport class GetDeviceStatusDeviceAction extends XStateDeviceAction<\n GetDeviceStatusDAOutput,\n GetDeviceStatusDAInput,\n GetDeviceStatusDAError,\n GetDeviceStatusDAIntermediateValue,\n GetDeviceStatusMachineInternalState\n> {\n makeStateMachine(\n internalApi: InternalApi,\n ): DeviceActionStateMachine<\n GetDeviceStatusDAOutput,\n GetDeviceStatusDAInput,\n GetDeviceStatusDAError,\n GetDeviceStatusDAIntermediateValue,\n GetDeviceStatusMachineInternalState\n > {\n type types = StateMachineTypes<\n GetDeviceStatusDAOutput,\n GetDeviceStatusDAInput,\n GetDeviceStatusDAError,\n GetDeviceStatusDAIntermediateValue,\n GetDeviceStatusMachineInternalState\n >;\n\n const {\n getAppAndVersion,\n getDeviceSessionState,\n setDeviceSessionState,\n waitForDeviceUnlock,\n isDeviceOnboarded,\n } = this.extractDependencies(internalApi);\n\n const unlockTimeout = this.input.unlockTimeout ?? DEFAULT_UNLOCK_TIMEOUT_MS;\n\n return setup({\n types: {\n input: {\n unlockTimeout,\n } as types[\"input\"],\n context: {} as types[\"context\"],\n output: {} as types[\"output\"],\n },\n actors: {\n getAppAndVersion: fromPromise(getAppAndVersion),\n waitForDeviceUnlock: fromObservable(waitForDeviceUnlock),\n },\n guards: {\n isDeviceOnboarded: () => isDeviceOnboarded(), // TODO: we don't have this info for now, this can be derived from the \"flags\" obtained in the getVersion command\n isDeviceLocked: ({ context }) => context._internalState.locked,\n hasError: ({ context }) => context._internalState.error !== null,\n },\n actions: {\n assignErrorDeviceNotOnboarded: assign({\n _internalState: (_) => ({\n ..._.context._internalState,\n error: new DeviceNotOnboardedError(),\n }),\n }),\n assignErrorDeviceLocked: assign({\n _internalState: (_) => ({\n ..._.context._internalState,\n error: new DeviceLockedError(),\n }),\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.UnlockDevice,\n },\n }),\n assignErrorFromEvent: assign({\n _internalState: (_) => ({\n ..._.context._internalState,\n error: _.event[\"error\"], // NOTE: it should never happen, the error is not typed anymore here\n }),\n }),\n assignNoUserActionNeeded: assign({\n intermediateValue: (_) =>\n ({\n ..._.context.intermediateValue,\n requiredUserInteraction: UserInteractionRequired.None,\n }) satisfies types[\"context\"][\"intermediateValue\"],\n }),\n assignUserActionUnlockNeeded: assign({\n intermediateValue: (_) =>\n ({\n ..._.context.intermediateValue,\n requiredUserInteraction: UserInteractionRequired.UnlockDevice,\n }) satisfies types[\"context\"][\"intermediateValue\"],\n }),\n },\n }).createMachine({\n /** @xstate-layout N4IgpgJg5mDOIC5QHEwBcAiYBuBLAxmAMpoCGaArrFnoQIL5q4D2AdgHQ0FgBKYpEAJ4BiANoAGALqJQAB2axcTNjJAAPRAFoArAHZx7A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rsDx01mZ15mHooReFaVj0fZ5Jci5zissYIKY3a2NvnxsrVITCrE8RoMdDucxWgx1jpZCELDHDgKTC9jg6mNXKLDSHPcbV3O7LG3bNH2SYioLB3EmCI1-HuVL6Cj4hU6eNjsIVD3UrWfKXVCj5cV5Wvtr5n6CShaFE-1JMkWzPgXpCjh+Faw3Mjq5jdOlJhGvo-RzRr3uvr79VjgFzQtWFpARVFnWxcHQNCylCBm+eKPjJL4jWMEdNww4O46vSFVsfyD5Nlj3na9KRAUPghCwPAIdV20QIR7e-RzOYbNK98cN7ndgR-BSzgo+YmdfYPOfSgAovkQ75MbyVtItehmSrJgcijz2uHD+pmXyQSQnyVLs2tQA */\n id: \"GetDeviceStatusDeviceAction\",\n initial: \"DeviceReady\",\n context: (_) => {\n const sessionState = getDeviceSessionState();\n const { sessionStateType } = sessionState;\n return {\n input: {\n unlockTimeout: _.input.unlockTimeout,\n },\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.None,\n },\n _internalState: {\n onboarded: false, // we don't know how to check yet\n locked: false,\n currentApp:\n sessionStateType ===\n DeviceSessionStateType.ReadyWithoutSecureChannel\n ? sessionState.currentApp.name\n : null,\n currentAppVersion: null,\n error: null,\n },\n };\n },\n states: {\n DeviceReady: {\n always: {\n target: \"OnboardingCheck\",\n },\n },\n OnboardingCheck: {\n // TODO: we don't have this info for now\n always: [\n {\n guard: {\n type: \"isDeviceOnboarded\",\n },\n target: \"AppAndVersionCheck\",\n actions: assign({\n _internalState: (_) => ({\n ..._.context._internalState,\n onboarded: true,\n }),\n }),\n },\n {\n target: \"Error\",\n actions: \"assignErrorDeviceNotOnboarded\",\n },\n ],\n },\n UserActionUnlockDevice: {\n // we wait for the device to be unlocked (default timeout is 15s)\n entry: \"assignUserActionUnlockNeeded\",\n exit: \"assignNoUserActionNeeded\",\n invoke: {\n id: \"UserActionUnlockDevice\",\n src: \"waitForDeviceUnlock\",\n input: (_) => ({\n unlockTimeout,\n }),\n onDone: {\n target: \"AppAndVersionCheck\",\n actions: assign({\n _internalState: (_) => ({\n ..._.context._internalState,\n locked: false,\n }),\n }),\n },\n onError: {\n target: \"Error\",\n actions: \"assignErrorDeviceLocked\",\n },\n },\n },\n AppAndVersionCheck: {\n // We check the current app and version using the getAppAndVersion command\n invoke: {\n src: \"getAppAndVersion\",\n onDone: {\n target: \"ApplicationAvailableResultCheck\",\n actions: assign({\n _internalState: (_) => {\n if (isSuccessCommandResult(_.event.output)) {\n const state: DeviceSessionState = getDeviceSessionState();\n if (\n state.sessionStateType !==\n DeviceSessionStateType.Connected\n ) {\n // Update the current app\n setDeviceSessionState({\n ...state,\n currentApp: _.event.output.data,\n });\n } else {\n // The device can be set to Ready if GetAppAndVersionCommand was successful\n setDeviceSessionState({\n deviceModelId: state.deviceModelId,\n sessionStateType:\n DeviceSessionStateType.ReadyWithoutSecureChannel,\n deviceStatus: DeviceStatus.CONNECTED,\n currentApp: _.event.output.data,\n installedApps: [],\n isSecureConnectionAllowed: false,\n });\n }\n return {\n ..._.context._internalState,\n locked: false,\n currentApp: _.event.output.data.name,\n currentAppVersion: _.event.output.data.version,\n };\n }\n if (\"errorCode\" in _.event.output.error) {\n if (_.event.output.error.errorCode === \"5515\") {\n // Locked device error\n return {\n ..._.context._internalState,\n locked: true,\n };\n } else if (_.event.output.error.errorCode === \"6e00\") {\n // CLA not supported\n // GetAppAndVersion should always be supported by the firmware or any app.\n // But on old firmware versions, that APDU was not supported in the dashboard.\n // On those firmwares, it fails with CLA_NOT_SUPPORTED in BOLOS, and INS_NOT_SUPPORTED\n // in applications. Therefore if CLA is not supported, we can consider we're on the\n // dashboard on an old firmware. We should therefore return that information to\n // ensure the user can still update his firmware and is not blocked at this step.\n return {\n ..._.context._internalState,\n locked: false,\n currentApp: \"BOLOS\",\n currentAppVersion: \"0.0.0\",\n };\n }\n }\n return {\n ..._.context._internalState,\n error: _.event.output.error,\n };\n },\n }),\n },\n onError: {\n target: \"Error\",\n actions: \"assignErrorFromEvent\",\n },\n },\n },\n ApplicationAvailableResultCheck: {\n always: [\n {\n guard: \"hasError\",\n target: \"Error\",\n },\n {\n target: \"UserActionUnlockDevice\",\n guard: \"isDeviceLocked\",\n },\n {\n target: \"Success\",\n },\n ],\n },\n Success: {\n type: \"final\",\n },\n Error: {\n type: \"final\",\n },\n },\n output: (args) => {\n // TODO: instead we should rely on the current state (\"Success\" or \"Error\")\n const { context } = args;\n const { error, currentApp, currentAppVersion } = context._internalState;\n if (error) {\n return Left(error);\n }\n return Right<GetDeviceStatusDAOutput>({\n currentApp: currentApp!,\n currentAppVersion: currentAppVersion!,\n });\n },\n });\n }\n\n extractDependencies(internalApi: InternalApi): MachineDependencies {\n const getAppAndVersion = () => {\n return internalApi.sendCommand(new GetAppAndVersionCommand());\n };\n\n const waitForDeviceUnlock = ({\n input,\n }: {\n input: { unlockTimeout: number };\n }) =>\n interval(1000).pipe(\n switchMap(() =>\n from(internalApi.sendCommand(new GetAppAndVersionCommand())),\n ),\n mergeMap((output) => {\n const isLocked =\n !isSuccessCommandResult(output) &&\n \"errorCode\" in output.error &&\n output.error.errorCode === \"5515\";\n if (isLocked) {\n return EMPTY; // Continue the polling\n }\n return of(undefined); // Complete the observable\n }),\n take(1),\n timeout(input.unlockTimeout),\n );\n\n return {\n getAppAndVersion,\n waitForDeviceUnlock,\n getDeviceSessionState: () => internalApi.getDeviceSessionState(),\n setDeviceSessionState: (state: DeviceSessionState) =>\n internalApi.setDeviceSessionState(state),\n isDeviceOnboarded: () => true, // TODO: we don't have this info for now\n };\n }\n}\n"],
5
+ "mappings": "yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,iCAAAE,IAAA,eAAAC,EAAAH,GAAA,IAAAI,EAA4B,qBAC5BC,EASO,gBACPC,EAAwB,0BACxBC,EAA2D,kBAE3DC,EAAuC,4CACvCC,EAGO,mDACPC,EAA6B,oCAE7BC,EAAwC,4DACxCC,EAA0C,uCAC1CC,EAGO,wCAEPC,EAGO,8DACPC,EAGO,kDAiCA,MAAMb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AM,YAAc,OAEpB,WAEF,MAAG,MAAS,CACpB,KACD,QAAK,CAAC,KACN,WAAQD,EAAM,aAAa,CAC7B,EAKA,sBAAuB,IAAMhB,EAAY,sBAAsB,EAC/D,sBAAwBW,GACtBX,EAAY,sBAAsBW,CAAK,EACzC,kBAAmB,IAAM,EAC3B,CACF,CACF",
6
+ "names": ["GetDeviceStatusDeviceAction_exports", "__export", "GetDeviceStatusDeviceAction", "__toCommonJS", "import_purify_ts", "import_rxjs", "import_operators", "import_xstate", "import_CommandResult", "import_GetAppAndVersionCommand", "import_DeviceStatus", "import_UserInteractionRequired", "import_Const", "import_Errors", "import_XStateDeviceAction", "import_DeviceSessionState", "internalApi", "getAppAndVersion", "getDeviceSessionState", "setDeviceSessionState", "waitForDeviceUnlock", "isDeviceOnboarded", "unlockTimeout", "context", "_", "sessionState", "sessionStateType", "state", "args", "error", "currentApp", "currentAppVersion", "input", "output"]
7
7
  }
@@ -1,2 +1,2 @@
1
- "use strict";var v=require("rxjs"),d=require("../../../command/model/CommandResult"),m=require("../../../command/utils/GlobalCommandError"),D=require("../../../device/DeviceModel"),i=require("../../../device/DeviceStatus"),u=require("../../../device-action/__test-utils__/makeInternalApi"),p=require("../../../device-action/__test-utils__/testDeviceActionStates"),t=require("../../../device-action/model/DeviceActionState"),c=require("../../../device-action/model/UserInteractionRequired"),O=require("../../../device-action/os/Errors"),s=require("../../../device-session/DeviceSessionState"),l=require("./GetDeviceStatusDeviceAction");describe("GetDeviceStatusDeviceAction",()=>{const k=vi.fn(),A=vi.fn(),y=vi.fn(),w=vi.fn(),E=vi.fn();function C(){return{getAppAndVersion:k,getDeviceSessionState:A,waitForDeviceUnlock:y,setDeviceSessionState:w,isDeviceOnboarded:E}}const{sendCommand:V,getDeviceSessionState:R,getDeviceSessionStateObservable:N}=(0,u.makeDeviceActionInternalApiMock)();beforeEach(()=>{vi.resetAllMocks(),E.mockReturnValue(!0)}),describe("without overriding `extractDependencies`",()=>{it("should run the device action with an unlocked device",()=>new Promise((r,o)=>{const e=new l.GetDeviceStatusDeviceAction({input:{unlockTimeout:500}});R.mockReturnValue({sessionStateType:s.DeviceSessionStateType.Connected,deviceStatus:i.DeviceStatus.CONNECTED,deviceModelId:D.DeviceModelId.NANO_X}),V.mockResolvedValue((0,d.CommandResultFactory)({data:{name:"BOLOS",version:"1.0.0"}}));const n=[{intermediateValue:{requiredUserInteraction:c.UserInteractionRequired.None},status:t.DeviceActionStatus.Pending},{output:{currentApp:"BOLOS",currentAppVersion:"1.0.0"},status:t.DeviceActionStatus.Completed}];(0,p.testDeviceActionStates)(e,n,(0,u.makeDeviceActionInternalApiMock)(),{onDone:r,onError:o})})),it("should run the device action with a locked device",()=>new Promise((r,o)=>{const e=new l.GetDeviceStatusDeviceAction({input:{unlockTimeout:500}});R.mockReturnValue({sessionStateType:s.DeviceSessionStateType.ReadyWithoutSecureChannel,deviceStatus:i.DeviceStatus.LOCKED,currentApp:{name:"mockedCurrentApp",version:"1.0.0"},installedApps:[],deviceModelId:D.DeviceModelId.NANO_X,isSecureConnectionAllowed:!1}),N.mockImplementation(()=>new v.Observable(a=>{const S=(0,v.interval)(50).subscribe({next:h=>{h>2?(a.next({sessionStateType:s.DeviceSessionStateType.ReadyWithoutSecureChannel,deviceStatus:i.DeviceStatus.CONNECTED,currentApp:{name:"mockedCurrentApp",version:"1.0.0"},installedApps:[],deviceModelId:D.DeviceModelId.NANO_X,isSecureConnectionAllowed:!1}),a.complete()):a.next({sessionStateType:s.DeviceSessionStateType.ReadyWithoutSecureChannel,deviceStatus:i.DeviceStatus.LOCKED,currentApp:{name:"mockedCurrentApp",version:"1.0.0"},installedApps:[],deviceModelId:D.DeviceModelId.NANO_X,isSecureConnectionAllowed:!1})}});return()=>{S.unsubscribe()}})),V.mockResolvedValueOnce((0,d.CommandResultFactory)({error:new m.GlobalCommandError({...m.GLOBAL_ERRORS[5515],errorCode:"5515"})})).mockResolvedValueOnce((0,d.CommandResultFactory)({data:{name:"BOLOS",version:"1.0.0"}}));const n=[{intermediateValue:{requiredUserInteraction:c.UserInteractionRequired.None},status:t.DeviceActionStatus.Pending},{intermediateValue:{requiredUserInteraction:c.UserInteractionRequired.UnlockDevice},status:t.DeviceActionStatus.Pending},{intermediateValue:{requiredUserInteraction:c.UserInteractionRequired.None},status:t.DeviceActionStatus.Pending},{output:{currentApp:"BOLOS",currentAppVersion:"1.0.0"},status:t.DeviceActionStatus.Completed}];(0,p.testDeviceActionStates)(e,n,(0,u.makeDeviceActionInternalApiMock)(),{onDone:r,onError:o})})),it("should run the device action with an old firmware not supporting GetAppAndVersion",()=>new Promise((r,o)=>{const e=new l.GetDeviceStatusDeviceAction({input:{unlockTimeout:500}});R.mockReturnValue({sessionStateType:s.DeviceSessionStateType.Connected,deviceStatus:i.DeviceStatus.CONNECTED,deviceModelId:D.DeviceModelId.NANO_X}),V.mockResolvedValue((0,d.CommandResultFactory)({error:new m.GlobalCommandError({...m.GLOBAL_ERRORS["6e00"],errorCode:"6e00"})}));const n=[{intermediateValue:{requiredUserInteraction:c.UserInteractionRequired.None},status:t.DeviceActionStatus.Pending},{output:{currentApp:"BOLOS",currentAppVersion:"0.0.0"},status:t.DeviceActionStatus.Completed}];(0,p.testDeviceActionStates)(e,n,(0,u.makeDeviceActionInternalApiMock)(),{onDone:r,onError:o})}))}),describe("success cases",()=>{it("should return the device status if the device is unlocked",()=>new Promise((r,o)=>{A.mockReturnValue({sessionStateType:s.DeviceSessionStateType.ReadyWithoutSecureChannel,deviceStatus:i.DeviceStatus.CONNECTED,currentApp:{name:"mockedCurrentApp",version:"1.0.0"}}),k.mockResolvedValue((0,d.CommandResultFactory)({data:{name:"BOLOS",version:"1.0.0"}}));const e=new l.GetDeviceStatusDeviceAction({input:{unlockTimeout:void 0}});vi.spyOn(e,"extractDependencies").mockReturnValue(C());const n=[{intermediateValue:{requiredUserInteraction:c.UserInteractionRequired.None},status:t.DeviceActionStatus.Pending},{status:t.DeviceActionStatus.Completed,output:{currentApp:"BOLOS",currentAppVersion:"1.0.0"}}];(0,p.testDeviceActionStates)(e,n,(0,u.makeDeviceActionInternalApiMock)(),{onDone:()=>{expect(w).toHaveBeenCalledWith({sessionStateType:s.DeviceSessionStateType.ReadyWithoutSecureChannel,deviceStatus:i.DeviceStatus.CONNECTED,currentApp:{name:"BOLOS",version:"1.0.0"}}),r()},onError:o})})),it("should return the device status and update session if the device is not ready",()=>new Promise((r,o)=>{A.mockReturnValue({sessionStateType:s.DeviceSessionStateType.Connected,deviceStatus:i.DeviceStatus.CONNECTED}),k.mockResolvedValue((0,d.CommandResultFactory)({data:{name:"BOLOS",version:"1.0.0"}}));const e=new l.GetDeviceStatusDeviceAction({input:{unlockTimeout:void 0}});vi.spyOn(e,"extractDependencies").mockReturnValue(C());const n=[{intermediateValue:{requiredUserInteraction:c.UserInteractionRequired.None},status:t.DeviceActionStatus.Pending},{status:t.DeviceActionStatus.Completed,output:{currentApp:"BOLOS",currentAppVersion:"1.0.0"}}];(0,p.testDeviceActionStates)(e,n,(0,u.makeDeviceActionInternalApiMock)(),{onDone:()=>{expect(w).toHaveBeenCalledWith({sessionStateType:s.DeviceSessionStateType.ReadyWithoutSecureChannel,deviceStatus:i.DeviceStatus.CONNECTED,currentApp:{name:"BOLOS",version:"1.0.0"},installedApps:[],isSecureConnectionAllowed:!1}),r()},onError:o})})),it("should return the device status if the device is locked and the user unlocks the device",()=>new Promise((r,o)=>{A.mockReturnValue({sessionStateType:s.DeviceSessionStateType.ReadyWithoutSecureChannel,deviceStatus:i.DeviceStatus.LOCKED,currentApp:{name:"mockedCurrentApp",version:"1.0.0"}}),k.mockResolvedValueOnce((0,d.CommandResultFactory)({error:new m.GlobalCommandError({...m.GLOBAL_ERRORS[5515],errorCode:"5515"})})).mockResolvedValueOnce((0,d.CommandResultFactory)({data:{name:"BOLOS",version:"1.0.0"}})),y.mockImplementation(()=>new v.Observable(a=>{const S=(0,v.interval)(50).subscribe({next:h=>{h>2?(a.next({sessionStateType:s.DeviceSessionStateType.ReadyWithoutSecureChannel,deviceStatus:i.DeviceStatus.CONNECTED,currentApp:{name:"mockedCurrentApp",version:"1.0.0"}}),a.complete()):a.next({sessionStateType:s.DeviceSessionStateType.ReadyWithoutSecureChannel,deviceStatus:i.DeviceStatus.LOCKED,currentApp:{name:"mockedCurrentApp",version:"1.0.0"}})}});return()=>{S.unsubscribe()}}));const e=new l.GetDeviceStatusDeviceAction({input:{unlockTimeout:500}});vi.spyOn(e,"extractDependencies").mockReturnValue(C());const n=[{intermediateValue:{requiredUserInteraction:c.UserInteractionRequired.None},status:t.DeviceActionStatus.Pending},{intermediateValue:{requiredUserInteraction:c.UserInteractionRequired.UnlockDevice},status:t.DeviceActionStatus.Pending},{intermediateValue:{requiredUserInteraction:c.UserInteractionRequired.None},status:t.DeviceActionStatus.Pending},{status:t.DeviceActionStatus.Completed,output:{currentApp:"BOLOS",currentAppVersion:"1.0.0"}}];(0,p.testDeviceActionStates)(e,n,(0,u.makeDeviceActionInternalApiMock)(),{onDone:r,onError:o})}))}),describe("errors cases",()=>{it("should end in an error if the device is not onboarded",()=>new Promise((r,o)=>{A.mockReturnValue({sessionStateType:s.DeviceSessionStateType.ReadyWithoutSecureChannel,deviceStatus:i.DeviceStatus.LOCKED,currentApp:{name:"mockedCurrentApp",version:"1.0.0"}}),E.mockReturnValue(!1);const e=new l.GetDeviceStatusDeviceAction({input:{unlockTimeout:500}});vi.spyOn(e,"extractDependencies").mockReturnValue(C());const n=[{error:new O.DeviceNotOnboardedError,status:t.DeviceActionStatus.Error}];(0,p.testDeviceActionStates)(e,n,(0,u.makeDeviceActionInternalApiMock)(),{onDone:r,onError:o})})),it("should end in an error if the device is locked and the user does not unlock",()=>new Promise((r,o)=>{A.mockReturnValue({sessionStateType:s.DeviceSessionStateType.ReadyWithoutSecureChannel,deviceStatus:i.DeviceStatus.LOCKED,currentApp:{name:"mockedCurrentApp",version:"1.0.0"}}),k.mockResolvedValue((0,d.CommandResultFactory)({error:new m.GlobalCommandError({...m.GLOBAL_ERRORS[5515],errorCode:"5515"})})),N.mockImplementation(()=>new v.Observable(a=>{const S=(0,v.interval)(200).subscribe({next:()=>{a.next({sessionStateType:s.DeviceSessionStateType.ReadyWithoutSecureChannel,deviceStatus:i.DeviceStatus.LOCKED,currentApp:{name:"mockedCurrentApp",version:"1.0.0"},installedApps:[],deviceModelId:D.DeviceModelId.NANO_X,isSecureConnectionAllowed:!1})}});return()=>{S.unsubscribe()}}));const e=new l.GetDeviceStatusDeviceAction({input:{unlockTimeout:500}});vi.spyOn(e,"extractDependencies").mockReturnValue(C());const n=[{intermediateValue:{requiredUserInteraction:c.UserInteractionRequired.None},status:t.DeviceActionStatus.Pending},{intermediateValue:{requiredUserInteraction:c.UserInteractionRequired.UnlockDevice},status:t.DeviceActionStatus.Pending},{error:new O.DeviceLockedError("Device locked."),status:t.DeviceActionStatus.Error}];(0,p.testDeviceActionStates)(e,n,(0,u.makeDeviceActionInternalApiMock)(),{onDone:r,onError:o})})),it("should end in an error if the GetAppAndVersion command fails",()=>new Promise((r,o)=>{A.mockReturnValue({sessionStateType:s.DeviceSessionStateType.ReadyWithoutSecureChannel,deviceStatus:i.DeviceStatus.LOCKED,currentApp:{name:"mockedCurrentApp",version:"1.0.0"}});const e=new m.GlobalCommandError({...m.GLOBAL_ERRORS[5501],errorCode:"5501"});k.mockResolvedValue((0,d.CommandResultFactory)({error:e})),y.mockImplementation(()=>new v.Observable(S=>{const h=(0,v.interval)(50).subscribe({next:f=>{f>2?(S.next({sessionStateType:s.DeviceSessionStateType.ReadyWithoutSecureChannel,deviceStatus:i.DeviceStatus.CONNECTED,currentApp:{name:"mockedCurrentApp",version:"1.0.0"}}),S.complete()):S.next({sessionStateType:s.DeviceSessionStateType.ReadyWithoutSecureChannel,deviceStatus:i.DeviceStatus.LOCKED,currentApp:{name:"mockedCurrentApp",version:"1.0.0"}})}});return()=>{h.unsubscribe()}}));const n=new l.GetDeviceStatusDeviceAction({input:{unlockTimeout:500}});vi.spyOn(n,"extractDependencies").mockReturnValue(C());const a=[{intermediateValue:{requiredUserInteraction:c.UserInteractionRequired.None},status:t.DeviceActionStatus.Pending},{error:e,status:t.DeviceActionStatus.Error}];(0,p.testDeviceActionStates)(n,a,(0,u.makeDeviceActionInternalApiMock)(),{onDone:r,onError:o})})),it("should end in an error if getAppAndVersion actor throws an error",()=>new Promise((r,o)=>{A.mockReturnValue({sessionStateType:s.DeviceSessionStateType.ReadyWithoutSecureChannel,deviceStatus:i.DeviceStatus.LOCKED,currentApp:{name:"mockedCurrentApp",version:"1.0.0"}}),k.mockImplementation(()=>{throw new O.UnknownDAError("error")}),y.mockImplementation(()=>new v.Observable(a=>{a.complete()}));const e=new l.GetDeviceStatusDeviceAction({input:{unlockTimeout:500}});vi.spyOn(e,"extractDependencies").mockReturnValue(C());const n=[{intermediateValue:{requiredUserInteraction:c.UserInteractionRequired.None},status:t.DeviceActionStatus.Pending},{error:new O.UnknownDAError("error"),status:t.DeviceActionStatus.Error}];(0,p.testDeviceActionStates)(e,n,(0,u.makeDeviceActionInternalApiMock)(),{onDone:r,onError:o})}))}),it("should emit a stopped state if the action is cancelled",()=>new Promise((r,o)=>{R.mockReturnValue({sessionStateType:s.DeviceSessionStateType.ReadyWithoutSecureChannel,deviceStatus:i.DeviceStatus.CONNECTED,currentApp:{name:"mockedCurrentApp",version:"1.0.0"},installedApps:[],deviceModelId:D.DeviceModelId.NANO_X,isSecureConnectionAllowed:!1}),V.mockResolvedValue((0,d.CommandResultFactory)({data:{name:"BOLOS",version:"1.0.0"}}));const e=new l.GetDeviceStatusDeviceAction({input:{unlockTimeout:500}}),n=[{status:t.DeviceActionStatus.Pending,intermediateValue:{requiredUserInteraction:c.UserInteractionRequired.None}},{status:t.DeviceActionStatus.Stopped}],{cancel:a}=(0,p.testDeviceActionStates)(e,n,(0,u.makeDeviceActionInternalApiMock)(),{onDone:r,onError:o});a()}))});
1
+ "use strict";var v=require("rxjs"),a=require("../../../command/model/CommandResult"),d=require("../../../command/utils/GlobalCommandError"),O=require("../../../device/DeviceModel"),i=require("../../../device/DeviceStatus"),u=require("../../../device-action/__test-utils__/makeInternalApi"),p=require("../../../device-action/__test-utils__/testDeviceActionStates"),t=require("../../../device-action/model/DeviceActionState"),c=require("../../../device-action/model/UserInteractionRequired"),D=require("../../../device-action/os/Errors"),s=require("../../../device-session/DeviceSessionState"),l=require("./GetDeviceStatusDeviceAction");describe("GetDeviceStatusDeviceAction",()=>{const A=vi.fn(),S=vi.fn(),y=vi.fn(),w=vi.fn(),R=vi.fn();function k(){return{getAppAndVersion:A,getDeviceSessionState:S,waitForDeviceUnlock:y,setDeviceSessionState:w,isDeviceOnboarded:R}}const{sendCommand:h,getDeviceSessionState:V,getDeviceSessionStateObservable:N}=(0,u.makeDeviceActionInternalApiMock)();beforeEach(()=>{vi.resetAllMocks(),R.mockReturnValue(!0)}),describe("without overriding `extractDependencies`",()=>{it("should run the device action with an unlocked device",()=>new Promise((r,o)=>{const e=new l.GetDeviceStatusDeviceAction({input:{unlockTimeout:500}});V.mockReturnValue({sessionStateType:s.DeviceSessionStateType.Connected,deviceStatus:i.DeviceStatus.CONNECTED,deviceModelId:O.DeviceModelId.NANO_X}),h.mockResolvedValue((0,a.CommandResultFactory)({data:{name:"BOLOS",version:"1.0.0"}}));const n=[{intermediateValue:{requiredUserInteraction:c.UserInteractionRequired.None},status:t.DeviceActionStatus.Pending},{output:{currentApp:"BOLOS",currentAppVersion:"1.0.0"},status:t.DeviceActionStatus.Completed}];(0,p.testDeviceActionStates)(e,n,(0,u.makeDeviceActionInternalApiMock)(),{onDone:r,onError:o})})),it("should run the device action with a locked device",()=>new Promise((r,o)=>{const e=new l.GetDeviceStatusDeviceAction({input:{unlockTimeout:1500}});V.mockReturnValue({sessionStateType:s.DeviceSessionStateType.ReadyWithoutSecureChannel,deviceStatus:i.DeviceStatus.LOCKED,currentApp:{name:"mockedCurrentApp",version:"1.0.0"},installedApps:[],deviceModelId:O.DeviceModelId.NANO_X,isSecureConnectionAllowed:!1}),h.mockResolvedValueOnce((0,a.CommandResultFactory)({error:new d.GlobalCommandError({...d.GLOBAL_ERRORS[5515],errorCode:"5515"})})).mockResolvedValue((0,a.CommandResultFactory)({data:{name:"BOLOS",version:"1.0.0"}}));const n=[{intermediateValue:{requiredUserInteraction:c.UserInteractionRequired.None},status:t.DeviceActionStatus.Pending},{intermediateValue:{requiredUserInteraction:c.UserInteractionRequired.UnlockDevice},status:t.DeviceActionStatus.Pending},{intermediateValue:{requiredUserInteraction:c.UserInteractionRequired.None},status:t.DeviceActionStatus.Pending},{output:{currentApp:"BOLOS",currentAppVersion:"1.0.0"},status:t.DeviceActionStatus.Completed}];(0,p.testDeviceActionStates)(e,n,(0,u.makeDeviceActionInternalApiMock)(),{onDone:r,onError:o})})),it("should timeout with a locked device",()=>new Promise((r,o)=>{const e=new l.GetDeviceStatusDeviceAction({input:{unlockTimeout:200}});V.mockReturnValue({sessionStateType:s.DeviceSessionStateType.ReadyWithoutSecureChannel,deviceStatus:i.DeviceStatus.LOCKED,currentApp:{name:"mockedCurrentApp",version:"1.0.0"},installedApps:[],deviceModelId:O.DeviceModelId.NANO_X,isSecureConnectionAllowed:!1}),h.mockResolvedValueOnce((0,a.CommandResultFactory)({error:new d.GlobalCommandError({...d.GLOBAL_ERRORS[5515],errorCode:"5515"})})).mockResolvedValue((0,a.CommandResultFactory)({data:{name:"BOLOS",version:"1.0.0"}}));const n=[{intermediateValue:{requiredUserInteraction:c.UserInteractionRequired.None},status:t.DeviceActionStatus.Pending},{intermediateValue:{requiredUserInteraction:c.UserInteractionRequired.UnlockDevice},status:t.DeviceActionStatus.Pending},{error:new D.DeviceLockedError("Device locked."),status:t.DeviceActionStatus.Error}];(0,p.testDeviceActionStates)(e,n,(0,u.makeDeviceActionInternalApiMock)(),{onDone:r,onError:o})})),it("should run the device action with an old firmware not supporting GetAppAndVersion",()=>new Promise((r,o)=>{const e=new l.GetDeviceStatusDeviceAction({input:{unlockTimeout:500}});V.mockReturnValue({sessionStateType:s.DeviceSessionStateType.Connected,deviceStatus:i.DeviceStatus.CONNECTED,deviceModelId:O.DeviceModelId.NANO_X}),h.mockResolvedValue((0,a.CommandResultFactory)({error:new d.GlobalCommandError({...d.GLOBAL_ERRORS["6e00"],errorCode:"6e00"})}));const n=[{intermediateValue:{requiredUserInteraction:c.UserInteractionRequired.None},status:t.DeviceActionStatus.Pending},{output:{currentApp:"BOLOS",currentAppVersion:"0.0.0"},status:t.DeviceActionStatus.Completed}];(0,p.testDeviceActionStates)(e,n,(0,u.makeDeviceActionInternalApiMock)(),{onDone:r,onError:o})}))}),describe("success cases",()=>{it("should return the device status if the device is unlocked",()=>new Promise((r,o)=>{S.mockReturnValue({sessionStateType:s.DeviceSessionStateType.ReadyWithoutSecureChannel,deviceStatus:i.DeviceStatus.CONNECTED,currentApp:{name:"mockedCurrentApp",version:"1.0.0"}}),A.mockResolvedValue((0,a.CommandResultFactory)({data:{name:"BOLOS",version:"1.0.0"}}));const e=new l.GetDeviceStatusDeviceAction({input:{unlockTimeout:void 0}});vi.spyOn(e,"extractDependencies").mockReturnValue(k());const n=[{intermediateValue:{requiredUserInteraction:c.UserInteractionRequired.None},status:t.DeviceActionStatus.Pending},{status:t.DeviceActionStatus.Completed,output:{currentApp:"BOLOS",currentAppVersion:"1.0.0"}}];(0,p.testDeviceActionStates)(e,n,(0,u.makeDeviceActionInternalApiMock)(),{onDone:()=>{expect(w).toHaveBeenCalledWith({sessionStateType:s.DeviceSessionStateType.ReadyWithoutSecureChannel,deviceStatus:i.DeviceStatus.CONNECTED,currentApp:{name:"BOLOS",version:"1.0.0"}}),r()},onError:o})})),it("should return the device status and update session if the device is not ready",()=>new Promise((r,o)=>{S.mockReturnValue({sessionStateType:s.DeviceSessionStateType.Connected,deviceStatus:i.DeviceStatus.CONNECTED}),A.mockResolvedValue((0,a.CommandResultFactory)({data:{name:"BOLOS",version:"1.0.0"}}));const e=new l.GetDeviceStatusDeviceAction({input:{unlockTimeout:void 0}});vi.spyOn(e,"extractDependencies").mockReturnValue(k());const n=[{intermediateValue:{requiredUserInteraction:c.UserInteractionRequired.None},status:t.DeviceActionStatus.Pending},{status:t.DeviceActionStatus.Completed,output:{currentApp:"BOLOS",currentAppVersion:"1.0.0"}}];(0,p.testDeviceActionStates)(e,n,(0,u.makeDeviceActionInternalApiMock)(),{onDone:()=>{expect(w).toHaveBeenCalledWith({sessionStateType:s.DeviceSessionStateType.ReadyWithoutSecureChannel,deviceStatus:i.DeviceStatus.CONNECTED,currentApp:{name:"BOLOS",version:"1.0.0"},installedApps:[],isSecureConnectionAllowed:!1}),r()},onError:o})})),it("should return the device status if the device is locked and the user unlocks the device",()=>new Promise((r,o)=>{S.mockReturnValue({sessionStateType:s.DeviceSessionStateType.ReadyWithoutSecureChannel,deviceStatus:i.DeviceStatus.LOCKED,currentApp:{name:"mockedCurrentApp",version:"1.0.0"}}),A.mockResolvedValueOnce((0,a.CommandResultFactory)({error:new d.GlobalCommandError({...d.GLOBAL_ERRORS[5515],errorCode:"5515"})})).mockResolvedValueOnce((0,a.CommandResultFactory)({data:{name:"BOLOS",version:"1.0.0"}})),y.mockImplementation(()=>new v.Observable(m=>{const C=(0,v.interval)(50).subscribe({next:E=>{E>2?(m.next({sessionStateType:s.DeviceSessionStateType.ReadyWithoutSecureChannel,deviceStatus:i.DeviceStatus.CONNECTED,currentApp:{name:"mockedCurrentApp",version:"1.0.0"}}),m.complete()):m.next({sessionStateType:s.DeviceSessionStateType.ReadyWithoutSecureChannel,deviceStatus:i.DeviceStatus.LOCKED,currentApp:{name:"mockedCurrentApp",version:"1.0.0"}})}});return()=>{C.unsubscribe()}}));const e=new l.GetDeviceStatusDeviceAction({input:{unlockTimeout:500}});vi.spyOn(e,"extractDependencies").mockReturnValue(k());const n=[{intermediateValue:{requiredUserInteraction:c.UserInteractionRequired.None},status:t.DeviceActionStatus.Pending},{intermediateValue:{requiredUserInteraction:c.UserInteractionRequired.UnlockDevice},status:t.DeviceActionStatus.Pending},{intermediateValue:{requiredUserInteraction:c.UserInteractionRequired.None},status:t.DeviceActionStatus.Pending},{status:t.DeviceActionStatus.Completed,output:{currentApp:"BOLOS",currentAppVersion:"1.0.0"}}];(0,p.testDeviceActionStates)(e,n,(0,u.makeDeviceActionInternalApiMock)(),{onDone:r,onError:o})}))}),describe("errors cases",()=>{it("should end in an error if the device is not onboarded",()=>new Promise((r,o)=>{S.mockReturnValue({sessionStateType:s.DeviceSessionStateType.ReadyWithoutSecureChannel,deviceStatus:i.DeviceStatus.LOCKED,currentApp:{name:"mockedCurrentApp",version:"1.0.0"}}),R.mockReturnValue(!1);const e=new l.GetDeviceStatusDeviceAction({input:{unlockTimeout:500}});vi.spyOn(e,"extractDependencies").mockReturnValue(k());const n=[{error:new D.DeviceNotOnboardedError,status:t.DeviceActionStatus.Error}];(0,p.testDeviceActionStates)(e,n,(0,u.makeDeviceActionInternalApiMock)(),{onDone:r,onError:o})})),it("should end in an error if the device is locked and the user does not unlock",()=>new Promise((r,o)=>{S.mockReturnValue({sessionStateType:s.DeviceSessionStateType.ReadyWithoutSecureChannel,deviceStatus:i.DeviceStatus.LOCKED,currentApp:{name:"mockedCurrentApp",version:"1.0.0"}}),A.mockResolvedValue((0,a.CommandResultFactory)({error:new d.GlobalCommandError({...d.GLOBAL_ERRORS[5515],errorCode:"5515"})})),N.mockImplementation(()=>new v.Observable(m=>{const C=(0,v.interval)(200).subscribe({next:()=>{m.next({sessionStateType:s.DeviceSessionStateType.ReadyWithoutSecureChannel,deviceStatus:i.DeviceStatus.LOCKED,currentApp:{name:"mockedCurrentApp",version:"1.0.0"},installedApps:[],deviceModelId:O.DeviceModelId.NANO_X,isSecureConnectionAllowed:!1})}});return()=>{C.unsubscribe()}}));const e=new l.GetDeviceStatusDeviceAction({input:{unlockTimeout:500}});vi.spyOn(e,"extractDependencies").mockReturnValue(k());const n=[{intermediateValue:{requiredUserInteraction:c.UserInteractionRequired.None},status:t.DeviceActionStatus.Pending},{intermediateValue:{requiredUserInteraction:c.UserInteractionRequired.UnlockDevice},status:t.DeviceActionStatus.Pending},{error:new D.DeviceLockedError("Device locked."),status:t.DeviceActionStatus.Error}];(0,p.testDeviceActionStates)(e,n,(0,u.makeDeviceActionInternalApiMock)(),{onDone:r,onError:o})})),it("should end in an error if the GetAppAndVersion command fails",()=>new Promise((r,o)=>{S.mockReturnValue({sessionStateType:s.DeviceSessionStateType.ReadyWithoutSecureChannel,deviceStatus:i.DeviceStatus.LOCKED,currentApp:{name:"mockedCurrentApp",version:"1.0.0"}});const e=new d.GlobalCommandError({...d.GLOBAL_ERRORS[5501],errorCode:"5501"});A.mockResolvedValue((0,a.CommandResultFactory)({error:e})),y.mockImplementation(()=>new v.Observable(C=>{const E=(0,v.interval)(50).subscribe({next:T=>{T>2?(C.next({sessionStateType:s.DeviceSessionStateType.ReadyWithoutSecureChannel,deviceStatus:i.DeviceStatus.CONNECTED,currentApp:{name:"mockedCurrentApp",version:"1.0.0"}}),C.complete()):C.next({sessionStateType:s.DeviceSessionStateType.ReadyWithoutSecureChannel,deviceStatus:i.DeviceStatus.LOCKED,currentApp:{name:"mockedCurrentApp",version:"1.0.0"}})}});return()=>{E.unsubscribe()}}));const n=new l.GetDeviceStatusDeviceAction({input:{unlockTimeout:500}});vi.spyOn(n,"extractDependencies").mockReturnValue(k());const m=[{intermediateValue:{requiredUserInteraction:c.UserInteractionRequired.None},status:t.DeviceActionStatus.Pending},{error:e,status:t.DeviceActionStatus.Error}];(0,p.testDeviceActionStates)(n,m,(0,u.makeDeviceActionInternalApiMock)(),{onDone:r,onError:o})})),it("should end in an error if getAppAndVersion actor throws an error",()=>new Promise((r,o)=>{S.mockReturnValue({sessionStateType:s.DeviceSessionStateType.ReadyWithoutSecureChannel,deviceStatus:i.DeviceStatus.LOCKED,currentApp:{name:"mockedCurrentApp",version:"1.0.0"}}),A.mockImplementation(()=>{throw new D.UnknownDAError("error")}),y.mockImplementation(()=>new v.Observable(m=>{m.complete()}));const e=new l.GetDeviceStatusDeviceAction({input:{unlockTimeout:500}});vi.spyOn(e,"extractDependencies").mockReturnValue(k());const n=[{intermediateValue:{requiredUserInteraction:c.UserInteractionRequired.None},status:t.DeviceActionStatus.Pending},{error:new D.UnknownDAError("error"),status:t.DeviceActionStatus.Error}];(0,p.testDeviceActionStates)(e,n,(0,u.makeDeviceActionInternalApiMock)(),{onDone:r,onError:o})}))}),it("should emit a stopped state if the action is cancelled",()=>new Promise((r,o)=>{V.mockReturnValue({sessionStateType:s.DeviceSessionStateType.ReadyWithoutSecureChannel,deviceStatus:i.DeviceStatus.CONNECTED,currentApp:{name:"mockedCurrentApp",version:"1.0.0"},installedApps:[],deviceModelId:O.DeviceModelId.NANO_X,isSecureConnectionAllowed:!1}),h.mockResolvedValue((0,a.CommandResultFactory)({data:{name:"BOLOS",version:"1.0.0"}}));const e=new l.GetDeviceStatusDeviceAction({input:{unlockTimeout:500}}),n=[{status:t.DeviceActionStatus.Pending,intermediateValue:{requiredUserInteraction:c.UserInteractionRequired.None}},{status:t.DeviceActionStatus.Stopped}],{cancel:m}=(0,p.testDeviceActionStates)(e,n,(0,u.makeDeviceActionInternalApiMock)(),{onDone:r,onError:o});m()}))});
2
2
  //# sourceMappingURL=GetDeviceStatusDeviceAction.test.js.map