@ledgerhq/device-management-kit 1.1.0 → 1.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (204) hide show
  1. package/lib/cjs/package.json +1 -1
  2. package/lib/cjs/src/api/apdu/utils/ApduBuilder.js +1 -1
  3. package/lib/cjs/src/api/apdu/utils/ApduBuilder.js.map +3 -3
  4. package/lib/cjs/src/api/device-action/__test-utils__/setupTestMachine.js +1 -1
  5. package/lib/cjs/src/api/device-action/__test-utils__/setupTestMachine.js.map +3 -3
  6. package/lib/cjs/src/api/device-action/os/CallTaskInAppDeviceAction/CallTaskInAppDeviceAction.js +1 -1
  7. package/lib/cjs/src/api/device-action/os/CallTaskInAppDeviceAction/CallTaskInAppDeviceAction.js.map +3 -3
  8. package/lib/cjs/src/api/device-action/os/CallTaskInAppDeviceAction/CallTaskInAppDeviceAction.test.js +1 -1
  9. package/lib/cjs/src/api/device-action/os/CallTaskInAppDeviceAction/CallTaskInAppDeviceAction.test.js.map +3 -3
  10. package/lib/cjs/src/api/device-action/os/CallTaskInAppDeviceAction/CallTaskInAppDeviceActionTypes.js +1 -1
  11. package/lib/cjs/src/api/device-action/os/CallTaskInAppDeviceAction/CallTaskInAppDeviceActionTypes.js.map +3 -3
  12. package/lib/cjs/src/api/device-action/os/GetDeviceMetadata/GetDeviceMetadataDeviceAction.js +1 -1
  13. package/lib/cjs/src/api/device-action/os/GetDeviceMetadata/GetDeviceMetadataDeviceAction.js.map +2 -2
  14. package/lib/cjs/src/api/device-action/os/GetDeviceMetadata/GetDeviceMetadataDeviceAction.test.js +1 -1
  15. package/lib/cjs/src/api/device-action/os/GetDeviceMetadata/GetDeviceMetadataDeviceAction.test.js.map +3 -3
  16. package/lib/cjs/src/api/device-action/os/GetDeviceMetadata/types.js +1 -1
  17. package/lib/cjs/src/api/device-action/os/GetDeviceMetadata/types.js.map +3 -3
  18. package/lib/cjs/src/api/device-action/os/GetDeviceStatus/GetDeviceStatusDeviceAction.js +1 -1
  19. package/lib/cjs/src/api/device-action/os/GetDeviceStatus/GetDeviceStatusDeviceAction.js.map +3 -3
  20. package/lib/cjs/src/api/device-action/os/GetDeviceStatus/GetDeviceStatusDeviceAction.test.js +1 -1
  21. package/lib/cjs/src/api/device-action/os/GetDeviceStatus/GetDeviceStatusDeviceAction.test.js.map +3 -3
  22. package/lib/cjs/src/api/device-action/os/GetDeviceStatus/types.js +1 -1
  23. package/lib/cjs/src/api/device-action/os/GetDeviceStatus/types.js.map +3 -3
  24. package/lib/cjs/src/api/device-action/os/GoToDashboard/GoToDashboardDeviceAction.js +1 -1
  25. package/lib/cjs/src/api/device-action/os/GoToDashboard/GoToDashboardDeviceAction.js.map +3 -3
  26. package/lib/cjs/src/api/device-action/os/GoToDashboard/GoToDashboardDeviceAction.test.js +1 -1
  27. package/lib/cjs/src/api/device-action/os/GoToDashboard/GoToDashboardDeviceAction.test.js.map +3 -3
  28. package/lib/cjs/src/api/device-action/os/GoToDashboard/types.js +1 -1
  29. package/lib/cjs/src/api/device-action/os/GoToDashboard/types.js.map +3 -3
  30. package/lib/cjs/src/api/device-action/os/InstallOrUpdateApps/InstallOrUpdateAppsDeviceAction.js +1 -1
  31. package/lib/cjs/src/api/device-action/os/InstallOrUpdateApps/InstallOrUpdateAppsDeviceAction.js.map +2 -2
  32. package/lib/cjs/src/api/device-action/os/InstallOrUpdateApps/InstallOrUpdateAppsDeviceAction.test.js +1 -1
  33. package/lib/cjs/src/api/device-action/os/InstallOrUpdateApps/InstallOrUpdateAppsDeviceAction.test.js.map +2 -2
  34. package/lib/cjs/src/api/device-action/os/InstallOrUpdateApps/types.js +1 -1
  35. package/lib/cjs/src/api/device-action/os/InstallOrUpdateApps/types.js.map +3 -3
  36. package/lib/cjs/src/api/device-action/os/ListApps/ListAppsDeviceAction.js +1 -1
  37. package/lib/cjs/src/api/device-action/os/ListApps/ListAppsDeviceAction.js.map +3 -3
  38. package/lib/cjs/src/api/device-action/os/ListApps/ListAppsDeviceAction.test.js +1 -1
  39. package/lib/cjs/src/api/device-action/os/ListApps/ListAppsDeviceAction.test.js.map +3 -3
  40. package/lib/cjs/src/api/device-action/os/ListApps/types.js +1 -1
  41. package/lib/cjs/src/api/device-action/os/ListApps/types.js.map +3 -3
  42. package/lib/cjs/src/api/device-action/os/ListAppsWithMetadata/ListAppsWithMetadataDeviceAction.js +1 -1
  43. package/lib/cjs/src/api/device-action/os/ListAppsWithMetadata/ListAppsWithMetadataDeviceAction.js.map +3 -3
  44. package/lib/cjs/src/api/device-action/os/ListAppsWithMetadata/ListAppsWithMetadataDeviceAction.test.js +1 -1
  45. package/lib/cjs/src/api/device-action/os/ListAppsWithMetadata/ListAppsWithMetadataDeviceAction.test.js.map +3 -3
  46. package/lib/cjs/src/api/device-action/os/ListAppsWithMetadata/types.js +1 -1
  47. package/lib/cjs/src/api/device-action/os/ListAppsWithMetadata/types.js.map +3 -3
  48. package/lib/cjs/src/api/device-action/os/OpenAppDeviceAction/OpenAppDeviceAction.js +1 -1
  49. package/lib/cjs/src/api/device-action/os/OpenAppDeviceAction/OpenAppDeviceAction.js.map +3 -3
  50. package/lib/cjs/src/api/device-action/os/OpenAppDeviceAction/OpenAppDeviceAction.test.js +1 -1
  51. package/lib/cjs/src/api/device-action/os/OpenAppDeviceAction/OpenAppDeviceAction.test.js.map +3 -3
  52. package/lib/cjs/src/api/device-action/os/OpenAppDeviceAction/types.js +1 -1
  53. package/lib/cjs/src/api/device-action/os/OpenAppDeviceAction/types.js.map +3 -3
  54. package/lib/cjs/src/api/device-action/os/OpenAppWithDependencies/OpenAppWithDependenciesDeviceAction.js +1 -1
  55. package/lib/cjs/src/api/device-action/os/OpenAppWithDependencies/OpenAppWithDependenciesDeviceAction.js.map +3 -3
  56. package/lib/cjs/src/api/device-action/os/OpenAppWithDependencies/OpenAppWithDependenciesDeviceAction.test.js +1 -1
  57. package/lib/cjs/src/api/device-action/os/OpenAppWithDependencies/OpenAppWithDependenciesDeviceAction.test.js.map +3 -3
  58. package/lib/cjs/src/api/device-action/os/OpenAppWithDependencies/types.js +1 -1
  59. package/lib/cjs/src/api/device-action/os/OpenAppWithDependencies/types.js.map +3 -3
  60. package/lib/cjs/src/api/device-action/os/SendCommandInAppDeviceAction/SendCommandInAppDeviceAction.js +1 -1
  61. package/lib/cjs/src/api/device-action/os/SendCommandInAppDeviceAction/SendCommandInAppDeviceAction.js.map +3 -3
  62. package/lib/cjs/src/api/device-action/os/SendCommandInAppDeviceAction/SendCommandInAppDeviceAction.test.js +1 -1
  63. package/lib/cjs/src/api/device-action/os/SendCommandInAppDeviceAction/SendCommandInAppDeviceAction.test.js.map +3 -3
  64. package/lib/cjs/src/api/device-action/os/SendCommandInAppDeviceAction/SendCommandInAppDeviceActionTypes.js +1 -1
  65. package/lib/cjs/src/api/device-action/os/SendCommandInAppDeviceAction/SendCommandInAppDeviceActionTypes.js.map +3 -3
  66. package/lib/cjs/src/api/index.js +1 -1
  67. package/lib/cjs/src/api/index.js.map +3 -3
  68. package/lib/cjs/src/api/types.js +1 -1
  69. package/lib/cjs/src/api/types.js.map +1 -1
  70. package/lib/cjs/src/api/utils/ApplicationChecker.js +2 -0
  71. package/lib/cjs/src/api/utils/ApplicationChecker.js.map +7 -0
  72. package/lib/cjs/src/api/utils/ApplicationChecker.test.js +2 -0
  73. package/lib/cjs/src/api/utils/ApplicationChecker.test.js.map +7 -0
  74. package/lib/cjs/src/api/utils/ApplicationResolver.js +2 -0
  75. package/lib/cjs/src/api/utils/ApplicationResolver.js.map +7 -0
  76. package/lib/cjs/src/api/utils/Base64String.js +1 -1
  77. package/lib/cjs/src/api/utils/Base64String.js.map +3 -3
  78. package/lib/cjs/src/api/utils/Base64String.test.js +1 -1
  79. package/lib/cjs/src/api/utils/Base64String.test.js.map +3 -3
  80. package/lib/esm/package.json +1 -1
  81. package/lib/esm/src/api/apdu/utils/ApduBuilder.js +1 -1
  82. package/lib/esm/src/api/apdu/utils/ApduBuilder.js.map +3 -3
  83. package/lib/esm/src/api/device-action/__test-utils__/setupTestMachine.js +1 -1
  84. package/lib/esm/src/api/device-action/__test-utils__/setupTestMachine.js.map +3 -3
  85. package/lib/esm/src/api/device-action/os/CallTaskInAppDeviceAction/CallTaskInAppDeviceAction.js +1 -1
  86. package/lib/esm/src/api/device-action/os/CallTaskInAppDeviceAction/CallTaskInAppDeviceAction.js.map +3 -3
  87. package/lib/esm/src/api/device-action/os/CallTaskInAppDeviceAction/CallTaskInAppDeviceAction.test.js +1 -1
  88. package/lib/esm/src/api/device-action/os/CallTaskInAppDeviceAction/CallTaskInAppDeviceAction.test.js.map +3 -3
  89. package/lib/esm/src/api/device-action/os/CallTaskInAppDeviceAction/CallTaskInAppDeviceActionTypes.js +1 -0
  90. package/lib/esm/src/api/device-action/os/CallTaskInAppDeviceAction/CallTaskInAppDeviceActionTypes.js.map +4 -4
  91. package/lib/esm/src/api/device-action/os/GetDeviceMetadata/GetDeviceMetadataDeviceAction.js +1 -1
  92. package/lib/esm/src/api/device-action/os/GetDeviceMetadata/GetDeviceMetadataDeviceAction.js.map +3 -3
  93. package/lib/esm/src/api/device-action/os/GetDeviceMetadata/GetDeviceMetadataDeviceAction.test.js +1 -1
  94. package/lib/esm/src/api/device-action/os/GetDeviceMetadata/GetDeviceMetadataDeviceAction.test.js.map +3 -3
  95. package/lib/esm/src/api/device-action/os/GetDeviceMetadata/types.js +1 -0
  96. package/lib/esm/src/api/device-action/os/GetDeviceMetadata/types.js.map +4 -4
  97. package/lib/esm/src/api/device-action/os/GetDeviceStatus/GetDeviceStatusDeviceAction.js +1 -1
  98. package/lib/esm/src/api/device-action/os/GetDeviceStatus/GetDeviceStatusDeviceAction.js.map +3 -3
  99. package/lib/esm/src/api/device-action/os/GetDeviceStatus/GetDeviceStatusDeviceAction.test.js +1 -1
  100. package/lib/esm/src/api/device-action/os/GetDeviceStatus/GetDeviceStatusDeviceAction.test.js.map +3 -3
  101. package/lib/esm/src/api/device-action/os/GetDeviceStatus/types.js +1 -0
  102. package/lib/esm/src/api/device-action/os/GetDeviceStatus/types.js.map +4 -4
  103. package/lib/esm/src/api/device-action/os/GoToDashboard/GoToDashboardDeviceAction.js +1 -1
  104. package/lib/esm/src/api/device-action/os/GoToDashboard/GoToDashboardDeviceAction.js.map +3 -3
  105. package/lib/esm/src/api/device-action/os/GoToDashboard/GoToDashboardDeviceAction.test.js +1 -1
  106. package/lib/esm/src/api/device-action/os/GoToDashboard/GoToDashboardDeviceAction.test.js.map +3 -3
  107. package/lib/esm/src/api/device-action/os/GoToDashboard/types.js +1 -0
  108. package/lib/esm/src/api/device-action/os/GoToDashboard/types.js.map +4 -4
  109. package/lib/esm/src/api/device-action/os/InstallOrUpdateApps/InstallOrUpdateAppsDeviceAction.js +1 -1
  110. package/lib/esm/src/api/device-action/os/InstallOrUpdateApps/InstallOrUpdateAppsDeviceAction.js.map +3 -3
  111. package/lib/esm/src/api/device-action/os/InstallOrUpdateApps/InstallOrUpdateAppsDeviceAction.test.js +1 -1
  112. package/lib/esm/src/api/device-action/os/InstallOrUpdateApps/InstallOrUpdateAppsDeviceAction.test.js.map +3 -3
  113. package/lib/esm/src/api/device-action/os/InstallOrUpdateApps/types.js +1 -0
  114. package/lib/esm/src/api/device-action/os/InstallOrUpdateApps/types.js.map +4 -4
  115. package/lib/esm/src/api/device-action/os/ListApps/ListAppsDeviceAction.js +1 -1
  116. package/lib/esm/src/api/device-action/os/ListApps/ListAppsDeviceAction.js.map +3 -3
  117. package/lib/esm/src/api/device-action/os/ListApps/ListAppsDeviceAction.test.js +1 -1
  118. package/lib/esm/src/api/device-action/os/ListApps/ListAppsDeviceAction.test.js.map +3 -3
  119. package/lib/esm/src/api/device-action/os/ListApps/types.js +1 -0
  120. package/lib/esm/src/api/device-action/os/ListApps/types.js.map +4 -4
  121. package/lib/esm/src/api/device-action/os/ListAppsWithMetadata/ListAppsWithMetadataDeviceAction.js +1 -1
  122. package/lib/esm/src/api/device-action/os/ListAppsWithMetadata/ListAppsWithMetadataDeviceAction.js.map +3 -3
  123. package/lib/esm/src/api/device-action/os/ListAppsWithMetadata/ListAppsWithMetadataDeviceAction.test.js +1 -1
  124. package/lib/esm/src/api/device-action/os/ListAppsWithMetadata/ListAppsWithMetadataDeviceAction.test.js.map +3 -3
  125. package/lib/esm/src/api/device-action/os/ListAppsWithMetadata/types.js +1 -0
  126. package/lib/esm/src/api/device-action/os/ListAppsWithMetadata/types.js.map +4 -4
  127. package/lib/esm/src/api/device-action/os/OpenAppDeviceAction/OpenAppDeviceAction.js +1 -1
  128. package/lib/esm/src/api/device-action/os/OpenAppDeviceAction/OpenAppDeviceAction.js.map +3 -3
  129. package/lib/esm/src/api/device-action/os/OpenAppDeviceAction/OpenAppDeviceAction.test.js +1 -1
  130. package/lib/esm/src/api/device-action/os/OpenAppDeviceAction/OpenAppDeviceAction.test.js.map +3 -3
  131. package/lib/esm/src/api/device-action/os/OpenAppDeviceAction/types.js +1 -0
  132. package/lib/esm/src/api/device-action/os/OpenAppDeviceAction/types.js.map +4 -4
  133. package/lib/esm/src/api/device-action/os/OpenAppWithDependencies/OpenAppWithDependenciesDeviceAction.js +1 -1
  134. package/lib/esm/src/api/device-action/os/OpenAppWithDependencies/OpenAppWithDependenciesDeviceAction.js.map +3 -3
  135. package/lib/esm/src/api/device-action/os/OpenAppWithDependencies/OpenAppWithDependenciesDeviceAction.test.js +1 -1
  136. package/lib/esm/src/api/device-action/os/OpenAppWithDependencies/OpenAppWithDependenciesDeviceAction.test.js.map +3 -3
  137. package/lib/esm/src/api/device-action/os/OpenAppWithDependencies/types.js +1 -0
  138. package/lib/esm/src/api/device-action/os/OpenAppWithDependencies/types.js.map +4 -4
  139. package/lib/esm/src/api/device-action/os/SendCommandInAppDeviceAction/SendCommandInAppDeviceAction.js +1 -1
  140. package/lib/esm/src/api/device-action/os/SendCommandInAppDeviceAction/SendCommandInAppDeviceAction.js.map +3 -3
  141. package/lib/esm/src/api/device-action/os/SendCommandInAppDeviceAction/SendCommandInAppDeviceAction.test.js +1 -1
  142. package/lib/esm/src/api/device-action/os/SendCommandInAppDeviceAction/SendCommandInAppDeviceAction.test.js.map +3 -3
  143. package/lib/esm/src/api/device-action/os/SendCommandInAppDeviceAction/SendCommandInAppDeviceActionTypes.js +1 -0
  144. package/lib/esm/src/api/device-action/os/SendCommandInAppDeviceAction/SendCommandInAppDeviceActionTypes.js.map +4 -4
  145. package/lib/esm/src/api/index.js +1 -1
  146. package/lib/esm/src/api/index.js.map +3 -3
  147. package/lib/esm/src/api/utils/ApplicationChecker.js +2 -0
  148. package/lib/esm/src/api/utils/ApplicationChecker.js.map +7 -0
  149. package/lib/esm/src/api/utils/ApplicationChecker.test.js +2 -0
  150. package/lib/esm/src/api/utils/ApplicationChecker.test.js.map +7 -0
  151. package/lib/esm/src/api/utils/ApplicationResolver.js +1 -0
  152. package/lib/esm/src/api/utils/ApplicationResolver.js.map +7 -0
  153. package/lib/esm/src/api/utils/Base64String.js +1 -1
  154. package/lib/esm/src/api/utils/Base64String.js.map +3 -3
  155. package/lib/esm/src/api/utils/Base64String.test.js +1 -1
  156. package/lib/esm/src/api/utils/Base64String.test.js.map +3 -3
  157. package/lib/types/src/api/apdu/utils/ApduBuilder.d.ts +7 -0
  158. package/lib/types/src/api/apdu/utils/ApduBuilder.d.ts.map +1 -1
  159. package/lib/types/src/api/device-action/__test-utils__/setupTestMachine.d.ts.map +1 -1
  160. package/lib/types/src/api/device-action/os/CallTaskInAppDeviceAction/CallTaskInAppDeviceAction.d.ts.map +1 -1
  161. package/lib/types/src/api/device-action/os/CallTaskInAppDeviceAction/CallTaskInAppDeviceActionTypes.d.ts +9 -1
  162. package/lib/types/src/api/device-action/os/CallTaskInAppDeviceAction/CallTaskInAppDeviceActionTypes.d.ts.map +1 -1
  163. package/lib/types/src/api/device-action/os/GetDeviceMetadata/GetDeviceMetadataDeviceAction.d.ts.map +1 -1
  164. package/lib/types/src/api/device-action/os/GetDeviceMetadata/types.d.ts +13 -2
  165. package/lib/types/src/api/device-action/os/GetDeviceMetadata/types.d.ts.map +1 -1
  166. package/lib/types/src/api/device-action/os/GetDeviceStatus/GetDeviceStatusDeviceAction.d.ts.map +1 -1
  167. package/lib/types/src/api/device-action/os/GetDeviceStatus/types.d.ts +6 -0
  168. package/lib/types/src/api/device-action/os/GetDeviceStatus/types.d.ts.map +1 -1
  169. package/lib/types/src/api/device-action/os/GoToDashboard/GoToDashboardDeviceAction.d.ts +1 -1
  170. package/lib/types/src/api/device-action/os/GoToDashboard/GoToDashboardDeviceAction.d.ts.map +1 -1
  171. package/lib/types/src/api/device-action/os/GoToDashboard/types.d.ts +9 -1
  172. package/lib/types/src/api/device-action/os/GoToDashboard/types.d.ts.map +1 -1
  173. package/lib/types/src/api/device-action/os/InstallOrUpdateApps/InstallOrUpdateAppsDeviceAction.d.ts.map +1 -1
  174. package/lib/types/src/api/device-action/os/InstallOrUpdateApps/types.d.ts +9 -1
  175. package/lib/types/src/api/device-action/os/InstallOrUpdateApps/types.d.ts.map +1 -1
  176. package/lib/types/src/api/device-action/os/ListApps/ListAppsDeviceAction.d.ts.map +1 -1
  177. package/lib/types/src/api/device-action/os/ListApps/types.d.ts +6 -0
  178. package/lib/types/src/api/device-action/os/ListApps/types.d.ts.map +1 -1
  179. package/lib/types/src/api/device-action/os/ListAppsWithMetadata/ListAppsWithMetadataDeviceAction.d.ts.map +1 -1
  180. package/lib/types/src/api/device-action/os/ListAppsWithMetadata/types.d.ts +8 -1
  181. package/lib/types/src/api/device-action/os/ListAppsWithMetadata/types.d.ts.map +1 -1
  182. package/lib/types/src/api/device-action/os/OpenAppDeviceAction/OpenAppDeviceAction.d.ts.map +1 -1
  183. package/lib/types/src/api/device-action/os/OpenAppDeviceAction/types.d.ts +12 -2
  184. package/lib/types/src/api/device-action/os/OpenAppDeviceAction/types.d.ts.map +1 -1
  185. package/lib/types/src/api/device-action/os/OpenAppWithDependencies/OpenAppWithDependenciesDeviceAction.d.ts.map +1 -1
  186. package/lib/types/src/api/device-action/os/OpenAppWithDependencies/types.d.ts +8 -0
  187. package/lib/types/src/api/device-action/os/OpenAppWithDependencies/types.d.ts.map +1 -1
  188. package/lib/types/src/api/device-action/os/SendCommandInAppDeviceAction/SendCommandInAppDeviceAction.d.ts.map +1 -1
  189. package/lib/types/src/api/device-action/os/SendCommandInAppDeviceAction/SendCommandInAppDeviceActionTypes.d.ts +9 -1
  190. package/lib/types/src/api/device-action/os/SendCommandInAppDeviceAction/SendCommandInAppDeviceActionTypes.d.ts.map +1 -1
  191. package/lib/types/src/api/index.d.ts +4 -2
  192. package/lib/types/src/api/index.d.ts.map +1 -1
  193. package/lib/types/src/api/types.d.ts +1 -0
  194. package/lib/types/src/api/types.d.ts.map +1 -1
  195. package/lib/types/src/api/utils/ApplicationChecker.d.ts +14 -0
  196. package/lib/types/src/api/utils/ApplicationChecker.d.ts.map +1 -0
  197. package/lib/types/src/api/utils/ApplicationChecker.test.d.ts +2 -0
  198. package/lib/types/src/api/utils/ApplicationChecker.test.d.ts.map +1 -0
  199. package/lib/types/src/api/utils/ApplicationResolver.d.ts +12 -0
  200. package/lib/types/src/api/utils/ApplicationResolver.d.ts.map +1 -0
  201. package/lib/types/src/api/utils/Base64String.d.ts +1 -0
  202. package/lib/types/src/api/utils/Base64String.d.ts.map +1 -1
  203. package/lib/types/tsconfig.prod.tsbuildinfo +1 -1
  204. package/package.json +5 -5
@@ -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 {\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\"][\"intermediateVal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WRtZ2FEgqsMwEBwKo1WKXVG5pgNaokmRZmQg4fyLHR7ieCNpjGPyx7aNo6UNo4nGeQpsFKdKax8AIoyJQSg3Ge0L07q9F3+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 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": "AAAA,OAAS,QAAAA,EAAM,SAAAC,MAAa,YAC5B,OACE,SAAAC,EACA,QAAAC,EACA,YAAAC,EACA,YAAAC,EAEA,MAAAC,EACA,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,eACzD,OAAIM,EACKrC,EAAKqC,CAAK,EAEZpC,EAA+B,CACpC,WAAYqC,EACZ,kBAAmBC,CACrB,CAAC,CACH,CACF,CAAC,CACH,CAEA,oBAAoBf,EAA+C,CA4BjE,MAAO,CACL,iBA5BuB,IAChBA,EAAY,YAAY,IAAIT,CAAyB,EA4B5D,oBAzB0B,CAAC,CAC3B,MAAAyB,CACF,IAGEpC,EAAS,GAAI,EAAE,KACbG,EAAU,IACRJ,EAAKqB,EAAY,YAAY,IAAIT,CAAyB,CAAC,CAC7D,EACAV,EAAUoC,GAEN,CAAC3B,EAAuB2B,CAAM,GAC9B,cAAeA,EAAO,OACtBA,EAAO,MAAM,YAAc,OAEpBvC,EAEFI,EAAG,MAAS,CACpB,EACDE,EAAK,CAAC,EACNC,EAAQ+B,EAAM,aAAa,CAC7B,EAKA,sBAAuB,IAAMhB,EAAY,sBAAsB,EAC/D,sBAAwBW,GACtBX,EAAY,sBAAsBW,CAAK,EACzC,kBAAmB,IAAM,EAC3B,CACF,CACF",
6
- "names": ["Left", "Right", "EMPTY", "from", "interval", "mergeMap", "of", "switchMap", "take", "timeout", "assign", "fromObservable", "fromPromise", "setup", "isSuccessCommandResult", "GetAppAndVersionCommand", "DeviceStatus", "UserInteractionRequired", "DEFAULT_UNLOCK_TIMEOUT_MS", "DeviceLockedError", "DeviceNotOnboardedError", "XStateDeviceAction", "DeviceSessionStateType", "GetDeviceStatusDeviceAction", "internalApi", "getAppAndVersion", "getDeviceSessionState", "setDeviceSessionState", "waitForDeviceUnlock", "isDeviceOnboarded", "unlockTimeout", "context", "_", "sessionState", "sessionStateType", "state", "args", "error", "currentApp", "currentAppVersion", "input", "output"]
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 getDeviceStatusDAStateStep,\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 step: getDeviceStatusDAStateStep.UNLOCK_DEVICE,\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 step: getDeviceStatusDAStateStep.UNLOCK_DEVICE,\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 step: getDeviceStatusDAStateStep.ONBOARD_CHECK,\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": "AAAA,OAAS,QAAAA,EAAM,SAAAC,MAAa,YAC5B,OACE,SAAAC,EACA,QAAAC,EACA,YAAAC,EACA,YAAAC,EAEA,MAAAC,EACA,aAAAC,EACA,QAAAC,MACK,OACP,OAAS,WAAAC,MAAe,iBACxB,OAAS,UAAAC,EAAQ,kBAAAC,EAAgB,eAAAC,EAAa,SAAAC,MAAa,SAE3D,OAAS,0BAAAC,MAA8B,mCACvC,OACE,2BAAAC,MAEK,0CACP,OAAS,gBAAAC,MAAoB,2BAE7B,OAAS,2BAAAC,MAA+B,mDACxC,OAAS,6BAAAC,MAAiC,8BAC1C,OACE,qBAAAC,EACA,2BAAAC,MACK,+BAEP,OAEE,sBAAAC,MACK,qDACP,OAEE,0BAAAC,MACK,yCAEP,OAKE,8BAAAC,MACK,UA0BA,MAAMC,UAAoCH,CAM/C,CACA,iBACEI,EAOA,CASA,KAAM,CACJ,iBAAAC,EACA,sBAAAC,EACA,sBAAAC,EACA,oBAAAC,EACA,kBAAAC,CACF,EAAI,KAAK,oBAAoBL,CAAW,EAElCM,EAAgB,KAAK,MAAM,eAAiBb,EAElD,OAAOL,EAAM,CACX,MAAO,CACL,MAAO,CACL,cAAAkB,CACF,EACA,QAAS,CAAC,EACV,OAAQ,CAAC,CACX,EACA,OAAQ,CACN,iBAAkBnB,EAAYc,CAAgB,EAC9C,oBAAqBf,EAAekB,CAAmB,CACzD,EACA,OAAQ,CACN,kBAAmB,IAAMC,EAAkB,EAC3C,eAAgB,CAAC,CAAE,QAAAE,CAAQ,IAAMA,EAAQ,eAAe,OACxD,SAAU,CAAC,CAAE,QAAAA,CAAQ,IAAMA,EAAQ,eAAe,QAAU,IAC9D,EACA,QAAS,CACP,8BAA+BtB,EAAO,CACpC,eAAiBuB,IAAO,CACtB,GAAGA,EAAE,QAAQ,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F,EACA,gCAAiC,CAC/B,OAAQ,CACN,CACE,MAAO,WACP,OAAQ,OACV,EACA,CACE,OAAQ,yBACR,MAAO,gBACT,EACA,CACE,OAAQ,SACV,CACF,CACF,EACA,QAAS,CACP,KAAM,OACR,EACA,MAAO,CACL,KAAM,OACR,CACF,EACA,OAASI,GAAS,CAEhB,KAAM,CAAE,QAAAL,CAAQ,EAAIK,EACd,CAAE,MAAAC,EAAO,WAAAC,EAAY,kBAAAC,CAAkB,EAAIR,EAAQ,eACzD,OAAIM,EACKtC,EAAKsC,CAAK,EAEZrC,EAA+B,CACpC,WAAYsC,EACZ,kBAAmBC,CACrB,CAAC,CACH,CACF,CAAC,CACH,CAEA,oBAAoBf,EAA+C,CA4BjE,MAAO,CACL,iBA5BuB,IAChBA,EAAY,YAAY,IAAIV,CAAyB,EA4B5D,oBAzB0B,CAAC,CAC3B,MAAA0B,CACF,IAGErC,EAAS,GAAI,EAAE,KACbG,EAAU,IACRJ,EAAKsB,EAAY,YAAY,IAAIV,CAAyB,CAAC,CAC7D,EACAV,EAAUqC,GAEN,CAAC5B,EAAuB4B,CAAM,GAC9B,cAAeA,EAAO,OACtBA,EAAO,MAAM,YAAc,OAEpBxC,EAEFI,EAAG,MAAS,CACpB,EACDE,EAAK,CAAC,EACNC,EAAQgC,EAAM,aAAa,CAC7B,EAKA,sBAAuB,IAAMhB,EAAY,sBAAsB,EAC/D,sBAAwBW,GACtBX,EAAY,sBAAsBW,CAAK,EACzC,kBAAmB,IAAM,EAC3B,CACF,CACF",
6
+ "names": ["Left", "Right", "EMPTY", "from", "interval", "mergeMap", "of", "switchMap", "take", "timeout", "assign", "fromObservable", "fromPromise", "setup", "isSuccessCommandResult", "GetAppAndVersionCommand", "DeviceStatus", "UserInteractionRequired", "DEFAULT_UNLOCK_TIMEOUT_MS", "DeviceLockedError", "DeviceNotOnboardedError", "XStateDeviceAction", "DeviceSessionStateType", "getDeviceStatusDAStateStep", "GetDeviceStatusDeviceAction", "internalApi", "getAppAndVersion", "getDeviceSessionState", "setDeviceSessionState", "waitForDeviceUnlock", "isDeviceOnboarded", "unlockTimeout", "context", "_", "sessionState", "sessionStateType", "state", "args", "error", "currentApp", "currentAppVersion", "input", "output"]
7
7
  }
@@ -1,2 +1,2 @@
1
- import{interval as N,Observable as y}from"rxjs";import{CommandResultFactory as a}from"../../../command/model/CommandResult";import{GLOBAL_ERRORS as A,GlobalCommandError as k}from"../../../command/utils/GlobalCommandError";import{DeviceModelId as C}from"../../../device/DeviceModel";import{DeviceStatus as i}from"../../../device/DeviceStatus";import{makeDeviceActionInternalApiMock as u}from"../../../device-action/__test-utils__/makeInternalApi";import{testDeviceActionStates as d}from"../../../device-action/__test-utils__/testDeviceActionStates";import{DeviceActionStatus as t}from"../../../device-action/model/DeviceActionState";import{UserInteractionRequired as c}from"../../../device-action/model/UserInteractionRequired";import{DeviceLockedError as T,DeviceNotOnboardedError as I,UnknownDAError as f}from"../../../device-action/os/Errors";import{DeviceSessionStateType as s}from"../../../device-session/DeviceSessionState";import{GetDeviceStatusDeviceAction as p}from"./GetDeviceStatusDeviceAction";describe("GetDeviceStatusDeviceAction",()=>{const v=vi.fn(),m=vi.fn(),V=vi.fn(),w=vi.fn(),R=vi.fn();function S(){return{getAppAndVersion:v,getDeviceSessionState:m,waitForDeviceUnlock:V,setDeviceSessionState:w,isDeviceOnboarded:R}}const{sendCommand:O,getDeviceSessionState:h,getDeviceSessionStateObservable:g}=u();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 p({input:{unlockTimeout:500}});h.mockReturnValue({sessionStateType:s.Connected,deviceStatus:i.CONNECTED,deviceModelId:C.NANO_X}),O.mockResolvedValue(a({data:{name:"BOLOS",version:"1.0.0"}}));const n=[{intermediateValue:{requiredUserInteraction:c.None},status:t.Pending},{output:{currentApp:"BOLOS",currentAppVersion:"1.0.0"},status:t.Completed}];d(e,n,u(),{onDone:r,onError:o})})),it("should run the device action with a locked device",()=>new Promise((r,o)=>{const e=new p({input:{unlockTimeout:1500}});h.mockReturnValue({sessionStateType:s.ReadyWithoutSecureChannel,deviceStatus:i.LOCKED,currentApp:{name:"mockedCurrentApp",version:"1.0.0"},installedApps:[],deviceModelId:C.NANO_X,isSecureConnectionAllowed:!1}),O.mockResolvedValueOnce(a({error:new k({...A[5515],errorCode:"5515"})})).mockResolvedValue(a({data:{name:"BOLOS",version:"1.0.0"}}));const n=[{intermediateValue:{requiredUserInteraction:c.None},status:t.Pending},{intermediateValue:{requiredUserInteraction:c.UnlockDevice},status:t.Pending},{intermediateValue:{requiredUserInteraction:c.None},status:t.Pending},{output:{currentApp:"BOLOS",currentAppVersion:"1.0.0"},status:t.Completed}];d(e,n,u(),{onDone:r,onError:o})})),it("should timeout with a locked device",()=>new Promise((r,o)=>{const e=new p({input:{unlockTimeout:200}});h.mockReturnValue({sessionStateType:s.ReadyWithoutSecureChannel,deviceStatus:i.LOCKED,currentApp:{name:"mockedCurrentApp",version:"1.0.0"},installedApps:[],deviceModelId:C.NANO_X,isSecureConnectionAllowed:!1}),O.mockResolvedValueOnce(a({error:new k({...A[5515],errorCode:"5515"})})).mockResolvedValue(a({data:{name:"BOLOS",version:"1.0.0"}}));const n=[{intermediateValue:{requiredUserInteraction:c.None},status:t.Pending},{intermediateValue:{requiredUserInteraction:c.UnlockDevice},status:t.Pending},{error:new T("Device locked."),status:t.Error}];d(e,n,u(),{onDone:r,onError:o})})),it("should run the device action with an old firmware not supporting GetAppAndVersion",()=>new Promise((r,o)=>{const e=new p({input:{unlockTimeout:500}});h.mockReturnValue({sessionStateType:s.Connected,deviceStatus:i.CONNECTED,deviceModelId:C.NANO_X}),O.mockResolvedValue(a({error:new k({...A["6e00"],errorCode:"6e00"})}));const n=[{intermediateValue:{requiredUserInteraction:c.None},status:t.Pending},{output:{currentApp:"BOLOS",currentAppVersion:"0.0.0"},status:t.Completed}];d(e,n,u(),{onDone:r,onError:o})}))}),describe("success cases",()=>{it("should return the device status if the device is unlocked",()=>new Promise((r,o)=>{m.mockReturnValue({sessionStateType:s.ReadyWithoutSecureChannel,deviceStatus:i.CONNECTED,currentApp:{name:"mockedCurrentApp",version:"1.0.0"}}),v.mockResolvedValue(a({data:{name:"BOLOS",version:"1.0.0"}}));const e=new p({input:{unlockTimeout:void 0}});vi.spyOn(e,"extractDependencies").mockReturnValue(S());const n=[{intermediateValue:{requiredUserInteraction:c.None},status:t.Pending},{status:t.Completed,output:{currentApp:"BOLOS",currentAppVersion:"1.0.0"}}];d(e,n,u(),{onDone:()=>{expect(w).toHaveBeenCalledWith({sessionStateType:s.ReadyWithoutSecureChannel,deviceStatus:i.CONNECTED,currentApp:{name:"BOLOS",version:"1.0.0"}}),r()},onError:o})})),it("should return the device status and update session if the device is not ready",()=>new Promise((r,o)=>{m.mockReturnValue({sessionStateType:s.Connected,deviceStatus:i.CONNECTED}),v.mockResolvedValue(a({data:{name:"BOLOS",version:"1.0.0"}}));const e=new p({input:{unlockTimeout:void 0}});vi.spyOn(e,"extractDependencies").mockReturnValue(S());const n=[{intermediateValue:{requiredUserInteraction:c.None},status:t.Pending},{status:t.Completed,output:{currentApp:"BOLOS",currentAppVersion:"1.0.0"}}];d(e,n,u(),{onDone:()=>{expect(w).toHaveBeenCalledWith({sessionStateType:s.ReadyWithoutSecureChannel,deviceStatus:i.CONNECTED,currentApp:{name:"BOLOS",version:"1.0.0"},installedApps:[],isSecureConnectionAllowed:!1}),r()},onError:o})})),it("should return the device status if the device is locked and the user unlocks the device",()=>new Promise((r,o)=>{m.mockReturnValue({sessionStateType:s.ReadyWithoutSecureChannel,deviceStatus:i.LOCKED,currentApp:{name:"mockedCurrentApp",version:"1.0.0"}}),v.mockResolvedValueOnce(a({error:new k({...A[5515],errorCode:"5515"})})).mockResolvedValueOnce(a({data:{name:"BOLOS",version:"1.0.0"}})),V.mockImplementation(()=>new y(l=>{const D=N(50).subscribe({next:E=>{E>2?(l.next({sessionStateType:s.ReadyWithoutSecureChannel,deviceStatus:i.CONNECTED,currentApp:{name:"mockedCurrentApp",version:"1.0.0"}}),l.complete()):l.next({sessionStateType:s.ReadyWithoutSecureChannel,deviceStatus:i.LOCKED,currentApp:{name:"mockedCurrentApp",version:"1.0.0"}})}});return()=>{D.unsubscribe()}}));const e=new p({input:{unlockTimeout:500}});vi.spyOn(e,"extractDependencies").mockReturnValue(S());const n=[{intermediateValue:{requiredUserInteraction:c.None},status:t.Pending},{intermediateValue:{requiredUserInteraction:c.UnlockDevice},status:t.Pending},{intermediateValue:{requiredUserInteraction:c.None},status:t.Pending},{status:t.Completed,output:{currentApp:"BOLOS",currentAppVersion:"1.0.0"}}];d(e,n,u(),{onDone:r,onError:o})}))}),describe("errors cases",()=>{it("should end in an error if the device is not onboarded",()=>new Promise((r,o)=>{m.mockReturnValue({sessionStateType:s.ReadyWithoutSecureChannel,deviceStatus:i.LOCKED,currentApp:{name:"mockedCurrentApp",version:"1.0.0"}}),R.mockReturnValue(!1);const e=new p({input:{unlockTimeout:500}});vi.spyOn(e,"extractDependencies").mockReturnValue(S());const n=[{error:new I,status:t.Error}];d(e,n,u(),{onDone:r,onError:o})})),it("should end in an error if the device is locked and the user does not unlock",()=>new Promise((r,o)=>{m.mockReturnValue({sessionStateType:s.ReadyWithoutSecureChannel,deviceStatus:i.LOCKED,currentApp:{name:"mockedCurrentApp",version:"1.0.0"}}),v.mockResolvedValue(a({error:new k({...A[5515],errorCode:"5515"})})),g.mockImplementation(()=>new y(l=>{const D=N(200).subscribe({next:()=>{l.next({sessionStateType:s.ReadyWithoutSecureChannel,deviceStatus:i.LOCKED,currentApp:{name:"mockedCurrentApp",version:"1.0.0"},installedApps:[],deviceModelId:C.NANO_X,isSecureConnectionAllowed:!1})}});return()=>{D.unsubscribe()}}));const e=new p({input:{unlockTimeout:500}});vi.spyOn(e,"extractDependencies").mockReturnValue(S());const n=[{intermediateValue:{requiredUserInteraction:c.None},status:t.Pending},{intermediateValue:{requiredUserInteraction:c.UnlockDevice},status:t.Pending},{error:new T("Device locked."),status:t.Error}];d(e,n,u(),{onDone:r,onError:o})})),it("should end in an error if the GetAppAndVersion command fails",()=>new Promise((r,o)=>{m.mockReturnValue({sessionStateType:s.ReadyWithoutSecureChannel,deviceStatus:i.LOCKED,currentApp:{name:"mockedCurrentApp",version:"1.0.0"}});const e=new k({...A[5501],errorCode:"5501"});v.mockResolvedValue(a({error:e})),V.mockImplementation(()=>new y(D=>{const E=N(50).subscribe({next:x=>{x>2?(D.next({sessionStateType:s.ReadyWithoutSecureChannel,deviceStatus:i.CONNECTED,currentApp:{name:"mockedCurrentApp",version:"1.0.0"}}),D.complete()):D.next({sessionStateType:s.ReadyWithoutSecureChannel,deviceStatus:i.LOCKED,currentApp:{name:"mockedCurrentApp",version:"1.0.0"}})}});return()=>{E.unsubscribe()}}));const n=new p({input:{unlockTimeout:500}});vi.spyOn(n,"extractDependencies").mockReturnValue(S());const l=[{intermediateValue:{requiredUserInteraction:c.None},status:t.Pending},{error:e,status:t.Error}];d(n,l,u(),{onDone:r,onError:o})})),it("should end in an error if getAppAndVersion actor throws an error",()=>new Promise((r,o)=>{m.mockReturnValue({sessionStateType:s.ReadyWithoutSecureChannel,deviceStatus:i.LOCKED,currentApp:{name:"mockedCurrentApp",version:"1.0.0"}}),v.mockImplementation(()=>{throw new f("error")}),V.mockImplementation(()=>new y(l=>{l.complete()}));const e=new p({input:{unlockTimeout:500}});vi.spyOn(e,"extractDependencies").mockReturnValue(S());const n=[{intermediateValue:{requiredUserInteraction:c.None},status:t.Pending},{error:new f("error"),status:t.Error}];d(e,n,u(),{onDone:r,onError:o})}))}),it("should emit a stopped state if the action is cancelled",()=>new Promise((r,o)=>{h.mockReturnValue({sessionStateType:s.ReadyWithoutSecureChannel,deviceStatus:i.CONNECTED,currentApp:{name:"mockedCurrentApp",version:"1.0.0"},installedApps:[],deviceModelId:C.NANO_X,isSecureConnectionAllowed:!1}),O.mockResolvedValue(a({data:{name:"BOLOS",version:"1.0.0"}}));const e=new p({input:{unlockTimeout:500}}),n=[{status:t.Pending,intermediateValue:{requiredUserInteraction:c.None}},{status:t.Stopped}],{cancel:l}=d(e,n,u(),{onDone:r,onError:o});l()}))});
1
+ import{interval as T,Observable as R}from"rxjs";import{CommandResultFactory as u}from"../../../command/model/CommandResult";import{GLOBAL_ERRORS as C,GlobalCommandError as O}from"../../../command/utils/GlobalCommandError";import{DeviceModelId as k}from"../../../device/DeviceModel";import{DeviceStatus as i}from"../../../device/DeviceStatus";import{makeDeviceActionInternalApiMock as d}from"../../../device-action/__test-utils__/makeInternalApi";import{testDeviceActionStates as p}from"../../../device-action/__test-utils__/testDeviceActionStates";import{DeviceActionStatus as t}from"../../../device-action/model/DeviceActionState";import{UserInteractionRequired as c}from"../../../device-action/model/UserInteractionRequired";import{DeviceLockedError as f,DeviceNotOnboardedError as x,UnknownDAError as g}from"../../../device-action/os/Errors";import{DeviceSessionStateType as s}from"../../../device-session/DeviceSessionState";import{GetDeviceStatusDeviceAction as l}from"./GetDeviceStatusDeviceAction";import{getDeviceStatusDAStateStep as a}from"./types";describe("GetDeviceStatusDeviceAction",()=>{const S=vi.fn(),v=vi.fn(),V=vi.fn(),N=vi.fn(),y=vi.fn();function D(){return{getAppAndVersion:S,getDeviceSessionState:v,waitForDeviceUnlock:V,setDeviceSessionState:N,isDeviceOnboarded:y}}const{sendCommand:E,getDeviceSessionState:h,getDeviceSessionStateObservable:I}=d();beforeEach(()=>{vi.resetAllMocks(),y.mockReturnValue(!0)}),describe("without overriding `extractDependencies`",()=>{it("should run the device action with an unlocked device",()=>new Promise((r,o)=>{const e=new l({input:{unlockTimeout:500}});h.mockReturnValue({sessionStateType:s.Connected,deviceStatus:i.CONNECTED,deviceModelId:k.NANO_X}),E.mockResolvedValue(u({data:{name:"BOLOS",version:"1.0.0"}}));const n=[{intermediateValue:{requiredUserInteraction:c.None,step:a.ONBOARD_CHECK},status:t.Pending},{output:{currentApp:"BOLOS",currentAppVersion:"1.0.0"},status:t.Completed}];p(e,n,d(),{onDone:r,onError:o})})),it("should run the device action with a locked device",()=>new Promise((r,o)=>{const e=new l({input:{unlockTimeout:1500}});h.mockReturnValue({sessionStateType:s.ReadyWithoutSecureChannel,deviceStatus:i.LOCKED,currentApp:{name:"mockedCurrentApp",version:"1.0.0"},installedApps:[],deviceModelId:k.NANO_X,isSecureConnectionAllowed:!1}),E.mockResolvedValueOnce(u({error:new O({...C[5515],errorCode:"5515"})})).mockResolvedValue(u({data:{name:"BOLOS",version:"1.0.0"}}));const n=[{intermediateValue:{requiredUserInteraction:c.None,step:a.ONBOARD_CHECK},status:t.Pending},{intermediateValue:{requiredUserInteraction:c.UnlockDevice,step:a.UNLOCK_DEVICE},status:t.Pending},{intermediateValue:{requiredUserInteraction:c.None,step:a.UNLOCK_DEVICE},status:t.Pending},{output:{currentApp:"BOLOS",currentAppVersion:"1.0.0"},status:t.Completed}];p(e,n,d(),{onDone:r,onError:o})})),it("should timeout with a locked device",()=>new Promise((r,o)=>{const e=new l({input:{unlockTimeout:200}});h.mockReturnValue({sessionStateType:s.ReadyWithoutSecureChannel,deviceStatus:i.LOCKED,currentApp:{name:"mockedCurrentApp",version:"1.0.0"},installedApps:[],deviceModelId:k.NANO_X,isSecureConnectionAllowed:!1}),E.mockResolvedValueOnce(u({error:new O({...C[5515],errorCode:"5515"})})).mockResolvedValue(u({data:{name:"BOLOS",version:"1.0.0"}}));const n=[{intermediateValue:{requiredUserInteraction:c.None,step:a.ONBOARD_CHECK},status:t.Pending},{intermediateValue:{requiredUserInteraction:c.UnlockDevice,step:a.UNLOCK_DEVICE},status:t.Pending},{error:new f("Device locked."),status:t.Error}];p(e,n,d(),{onDone:r,onError:o})})),it("should run the device action with an old firmware not supporting GetAppAndVersion",()=>new Promise((r,o)=>{const e=new l({input:{unlockTimeout:500}});h.mockReturnValue({sessionStateType:s.Connected,deviceStatus:i.CONNECTED,deviceModelId:k.NANO_X}),E.mockResolvedValue(u({error:new O({...C["6e00"],errorCode:"6e00"})}));const n=[{intermediateValue:{requiredUserInteraction:c.None,step:a.ONBOARD_CHECK},status:t.Pending},{output:{currentApp:"BOLOS",currentAppVersion:"0.0.0"},status:t.Completed}];p(e,n,d(),{onDone:r,onError:o})}))}),describe("success cases",()=>{it("should return the device status if the device is unlocked",()=>new Promise((r,o)=>{v.mockReturnValue({sessionStateType:s.ReadyWithoutSecureChannel,deviceStatus:i.CONNECTED,currentApp:{name:"mockedCurrentApp",version:"1.0.0"}}),S.mockResolvedValue(u({data:{name:"BOLOS",version:"1.0.0"}}));const e=new l({input:{unlockTimeout:void 0}});vi.spyOn(e,"extractDependencies").mockReturnValue(D());const n=[{intermediateValue:{requiredUserInteraction:c.None,step:a.ONBOARD_CHECK},status:t.Pending},{status:t.Completed,output:{currentApp:"BOLOS",currentAppVersion:"1.0.0"}}];p(e,n,d(),{onDone:()=>{expect(N).toHaveBeenCalledWith({sessionStateType:s.ReadyWithoutSecureChannel,deviceStatus:i.CONNECTED,currentApp:{name:"BOLOS",version:"1.0.0"}}),r()},onError:o})})),it("should return the device status and update session if the device is not ready",()=>new Promise((r,o)=>{v.mockReturnValue({sessionStateType:s.Connected,deviceStatus:i.CONNECTED}),S.mockResolvedValue(u({data:{name:"BOLOS",version:"1.0.0"}}));const e=new l({input:{unlockTimeout:void 0}});vi.spyOn(e,"extractDependencies").mockReturnValue(D());const n=[{intermediateValue:{requiredUserInteraction:c.None,step:a.ONBOARD_CHECK},status:t.Pending},{status:t.Completed,output:{currentApp:"BOLOS",currentAppVersion:"1.0.0"}}];p(e,n,d(),{onDone:()=>{expect(N).toHaveBeenCalledWith({sessionStateType:s.ReadyWithoutSecureChannel,deviceStatus:i.CONNECTED,currentApp:{name:"BOLOS",version:"1.0.0"},installedApps:[],isSecureConnectionAllowed:!1}),r()},onError:o})})),it("should return the device status if the device is locked and the user unlocks the device",()=>new Promise((r,o)=>{v.mockReturnValue({sessionStateType:s.ReadyWithoutSecureChannel,deviceStatus:i.LOCKED,currentApp:{name:"mockedCurrentApp",version:"1.0.0"}}),S.mockResolvedValueOnce(u({error:new O({...C[5515],errorCode:"5515"})})).mockResolvedValueOnce(u({data:{name:"BOLOS",version:"1.0.0"}})),V.mockImplementation(()=>new R(m=>{const A=T(50).subscribe({next:w=>{w>2?(m.next({sessionStateType:s.ReadyWithoutSecureChannel,deviceStatus:i.CONNECTED,currentApp:{name:"mockedCurrentApp",version:"1.0.0"}}),m.complete()):m.next({sessionStateType:s.ReadyWithoutSecureChannel,deviceStatus:i.LOCKED,currentApp:{name:"mockedCurrentApp",version:"1.0.0"}})}});return()=>{A.unsubscribe()}}));const e=new l({input:{unlockTimeout:500}});vi.spyOn(e,"extractDependencies").mockReturnValue(D());const n=[{intermediateValue:{requiredUserInteraction:c.None,step:a.ONBOARD_CHECK},status:t.Pending},{intermediateValue:{requiredUserInteraction:c.UnlockDevice,step:a.UNLOCK_DEVICE},status:t.Pending},{intermediateValue:{requiredUserInteraction:c.None,step:a.UNLOCK_DEVICE},status:t.Pending},{status:t.Completed,output:{currentApp:"BOLOS",currentAppVersion:"1.0.0"}}];p(e,n,d(),{onDone:r,onError:o})}))}),describe("errors cases",()=>{it("should end in an error if the device is not onboarded",()=>new Promise((r,o)=>{v.mockReturnValue({sessionStateType:s.ReadyWithoutSecureChannel,deviceStatus:i.LOCKED,currentApp:{name:"mockedCurrentApp",version:"1.0.0"}}),y.mockReturnValue(!1);const e=new l({input:{unlockTimeout:500}});vi.spyOn(e,"extractDependencies").mockReturnValue(D());const n=[{error:new x,status:t.Error}];p(e,n,d(),{onDone:r,onError:o})})),it("should end in an error if the device is locked and the user does not unlock",()=>new Promise((r,o)=>{v.mockReturnValue({sessionStateType:s.ReadyWithoutSecureChannel,deviceStatus:i.LOCKED,currentApp:{name:"mockedCurrentApp",version:"1.0.0"}}),S.mockResolvedValue(u({error:new O({...C[5515],errorCode:"5515"})})),I.mockImplementation(()=>new R(m=>{const A=T(200).subscribe({next:()=>{m.next({sessionStateType:s.ReadyWithoutSecureChannel,deviceStatus:i.LOCKED,currentApp:{name:"mockedCurrentApp",version:"1.0.0"},installedApps:[],deviceModelId:k.NANO_X,isSecureConnectionAllowed:!1})}});return()=>{A.unsubscribe()}}));const e=new l({input:{unlockTimeout:500}});vi.spyOn(e,"extractDependencies").mockReturnValue(D());const n=[{intermediateValue:{requiredUserInteraction:c.None,step:a.ONBOARD_CHECK},status:t.Pending},{intermediateValue:{requiredUserInteraction:c.UnlockDevice,step:a.UNLOCK_DEVICE},status:t.Pending},{error:new f("Device locked."),status:t.Error}];p(e,n,d(),{onDone:r,onError:o})})),it("should end in an error if the GetAppAndVersion command fails",()=>new Promise((r,o)=>{v.mockReturnValue({sessionStateType:s.ReadyWithoutSecureChannel,deviceStatus:i.LOCKED,currentApp:{name:"mockedCurrentApp",version:"1.0.0"}});const e=new O({...C[5501],errorCode:"5501"});S.mockResolvedValue(u({error:e})),V.mockImplementation(()=>new R(A=>{const w=T(50).subscribe({next:L=>{L>2?(A.next({sessionStateType:s.ReadyWithoutSecureChannel,deviceStatus:i.CONNECTED,currentApp:{name:"mockedCurrentApp",version:"1.0.0"}}),A.complete()):A.next({sessionStateType:s.ReadyWithoutSecureChannel,deviceStatus:i.LOCKED,currentApp:{name:"mockedCurrentApp",version:"1.0.0"}})}});return()=>{w.unsubscribe()}}));const n=new l({input:{unlockTimeout:500}});vi.spyOn(n,"extractDependencies").mockReturnValue(D());const m=[{intermediateValue:{requiredUserInteraction:c.None,step:a.ONBOARD_CHECK},status:t.Pending},{error:e,status:t.Error}];p(n,m,d(),{onDone:r,onError:o})})),it("should end in an error if getAppAndVersion actor throws an error",()=>new Promise((r,o)=>{v.mockReturnValue({sessionStateType:s.ReadyWithoutSecureChannel,deviceStatus:i.LOCKED,currentApp:{name:"mockedCurrentApp",version:"1.0.0"}}),S.mockImplementation(()=>{throw new g("error")}),V.mockImplementation(()=>new R(m=>{m.complete()}));const e=new l({input:{unlockTimeout:500}});vi.spyOn(e,"extractDependencies").mockReturnValue(D());const n=[{intermediateValue:{requiredUserInteraction:c.None,step:a.ONBOARD_CHECK},status:t.Pending},{error:new g("error"),status:t.Error}];p(e,n,d(),{onDone:r,onError:o})}))}),it("should emit a stopped state if the action is cancelled",()=>new Promise((r,o)=>{h.mockReturnValue({sessionStateType:s.ReadyWithoutSecureChannel,deviceStatus:i.CONNECTED,currentApp:{name:"mockedCurrentApp",version:"1.0.0"},installedApps:[],deviceModelId:k.NANO_X,isSecureConnectionAllowed:!1}),E.mockResolvedValue(u({data:{name:"BOLOS",version:"1.0.0"}}));const e=new l({input:{unlockTimeout:500}}),n=[{status:t.Pending,intermediateValue:{requiredUserInteraction:c.None,step:a.ONBOARD_CHECK}},{status:t.Stopped}],{cancel:m}=p(e,n,d(),{onDone:r,onError:o});m()}))});
2
2
  //# sourceMappingURL=GetDeviceStatusDeviceAction.test.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../../../../src/api/device-action/os/GetDeviceStatus/GetDeviceStatusDeviceAction.test.ts"],
4
- "sourcesContent": ["import { interval, Observable } from \"rxjs\";\n\nimport { CommandResultFactory } from \"@api/command/model/CommandResult\";\nimport {\n GLOBAL_ERRORS,\n GlobalCommandError,\n} from \"@api/command/utils/GlobalCommandError\";\nimport { DeviceModelId } from \"@api/device/DeviceModel\";\nimport { DeviceStatus } from \"@api/device/DeviceStatus\";\nimport { makeDeviceActionInternalApiMock } from \"@api/device-action/__test-utils__/makeInternalApi\";\nimport { testDeviceActionStates } from \"@api/device-action/__test-utils__/testDeviceActionStates\";\nimport { DeviceActionStatus } from \"@api/device-action/model/DeviceActionState\";\nimport { UserInteractionRequired } from \"@api/device-action/model/UserInteractionRequired\";\nimport {\n DeviceLockedError,\n DeviceNotOnboardedError,\n UnknownDAError,\n} from \"@api/device-action/os/Errors\";\nimport { DeviceSessionStateType } from \"@api/device-session/DeviceSessionState\";\n\nimport { GetDeviceStatusDeviceAction } from \"./GetDeviceStatusDeviceAction\";\nimport { type GetDeviceStatusDAState } from \"./types\";\n\ndescribe(\"GetDeviceStatusDeviceAction\", () => {\n const getAppAndVersionMock = vi.fn();\n const getDeviceSessionStateMock = vi.fn();\n const waitForDeviceUnlockMock = vi.fn();\n const setDeviceSessionState = vi.fn();\n const isDeviceOnboardedMock = vi.fn();\n\n function extractDependenciesMock() {\n return {\n getAppAndVersion: getAppAndVersionMock,\n getDeviceSessionState: getDeviceSessionStateMock,\n waitForDeviceUnlock: waitForDeviceUnlockMock,\n setDeviceSessionState: setDeviceSessionState,\n isDeviceOnboarded: isDeviceOnboardedMock,\n };\n }\n\n const {\n sendCommand: sendCommandMock,\n getDeviceSessionState: apiGetDeviceSessionStateMock,\n getDeviceSessionStateObservable: apiGetDeviceSessionStateObservableMock,\n } = makeDeviceActionInternalApiMock();\n beforeEach(() => {\n vi.resetAllMocks();\n isDeviceOnboardedMock.mockReturnValue(true);\n });\n\n describe(\"without overriding `extractDependencies`\", () => {\n it(\"should run the device action with an unlocked device\", () =>\n new Promise<void>((resolve, reject) => {\n const getDeviceStateDeviceAction = new GetDeviceStatusDeviceAction({\n input: { unlockTimeout: 500 },\n });\n\n apiGetDeviceSessionStateMock.mockReturnValue({\n sessionStateType: DeviceSessionStateType.Connected,\n deviceStatus: DeviceStatus.CONNECTED,\n deviceModelId: DeviceModelId.NANO_X,\n });\n\n sendCommandMock.mockResolvedValue(\n CommandResultFactory({\n data: {\n name: \"BOLOS\",\n version: \"1.0.0\",\n },\n }),\n );\n\n const expectedStates: Array<GetDeviceStatusDAState> = [\n {\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.None,\n },\n status: DeviceActionStatus.Pending,\n },\n {\n output: {\n currentApp: \"BOLOS\",\n currentAppVersion: \"1.0.0\",\n },\n status: DeviceActionStatus.Completed,\n },\n ];\n\n testDeviceActionStates(\n getDeviceStateDeviceAction,\n expectedStates,\n makeDeviceActionInternalApiMock(),\n {\n onDone: resolve,\n onError: reject,\n },\n );\n }));\n\n it(\"should run the device action with a locked device\", () =>\n new Promise<void>((resolve, reject) => {\n const getDeviceStateDeviceAction = new GetDeviceStatusDeviceAction({\n input: { unlockTimeout: 1500 },\n });\n\n apiGetDeviceSessionStateMock.mockReturnValue({\n sessionStateType: DeviceSessionStateType.ReadyWithoutSecureChannel,\n deviceStatus: DeviceStatus.LOCKED,\n currentApp: { name: \"mockedCurrentApp\", version: \"1.0.0\" },\n installedApps: [],\n deviceModelId: DeviceModelId.NANO_X,\n isSecureConnectionAllowed: false,\n });\n\n sendCommandMock\n .mockResolvedValueOnce(\n CommandResultFactory({\n error: new GlobalCommandError({\n ...GLOBAL_ERRORS[\"5515\"],\n errorCode: \"5515\",\n }),\n }),\n )\n .mockResolvedValue(\n CommandResultFactory({\n data: {\n name: \"BOLOS\",\n version: \"1.0.0\",\n },\n }),\n );\n\n const expectedStates: Array<GetDeviceStatusDAState> = [\n {\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.None,\n },\n status: DeviceActionStatus.Pending,\n },\n {\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.UnlockDevice,\n },\n status: DeviceActionStatus.Pending,\n },\n {\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.None,\n },\n status: DeviceActionStatus.Pending,\n },\n {\n output: {\n currentApp: \"BOLOS\",\n currentAppVersion: \"1.0.0\",\n },\n status: DeviceActionStatus.Completed,\n },\n ];\n\n testDeviceActionStates(\n getDeviceStateDeviceAction,\n expectedStates,\n makeDeviceActionInternalApiMock(),\n {\n onDone: resolve,\n onError: reject,\n },\n );\n }));\n\n it(\"should timeout with a locked device\", () =>\n new Promise<void>((resolve, reject) => {\n const getDeviceStateDeviceAction = new GetDeviceStatusDeviceAction({\n input: { unlockTimeout: 200 },\n });\n\n apiGetDeviceSessionStateMock.mockReturnValue({\n sessionStateType: DeviceSessionStateType.ReadyWithoutSecureChannel,\n deviceStatus: DeviceStatus.LOCKED,\n currentApp: { name: \"mockedCurrentApp\", version: \"1.0.0\" },\n installedApps: [],\n deviceModelId: DeviceModelId.NANO_X,\n isSecureConnectionAllowed: false,\n });\n\n sendCommandMock\n .mockResolvedValueOnce(\n CommandResultFactory({\n error: new GlobalCommandError({\n ...GLOBAL_ERRORS[\"5515\"],\n errorCode: \"5515\",\n }),\n }),\n )\n .mockResolvedValue(\n CommandResultFactory({\n data: {\n name: \"BOLOS\",\n version: \"1.0.0\",\n },\n }),\n );\n\n const expectedStates: Array<GetDeviceStatusDAState> = [\n {\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.None,\n },\n status: DeviceActionStatus.Pending,\n },\n {\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.UnlockDevice,\n },\n status: DeviceActionStatus.Pending,\n },\n {\n error: new DeviceLockedError(\"Device locked.\"),\n status: DeviceActionStatus.Error,\n },\n ];\n\n testDeviceActionStates(\n getDeviceStateDeviceAction,\n expectedStates,\n makeDeviceActionInternalApiMock(),\n {\n onDone: resolve,\n onError: reject,\n },\n );\n }));\n\n it(\"should run the device action with an old firmware not supporting GetAppAndVersion\", () =>\n new Promise<void>((resolve, reject) => {\n const getDeviceStateDeviceAction = new GetDeviceStatusDeviceAction({\n input: { unlockTimeout: 500 },\n });\n\n apiGetDeviceSessionStateMock.mockReturnValue({\n sessionStateType: DeviceSessionStateType.Connected,\n deviceStatus: DeviceStatus.CONNECTED,\n deviceModelId: DeviceModelId.NANO_X,\n });\n\n sendCommandMock.mockResolvedValue(\n CommandResultFactory({\n error: new GlobalCommandError({\n ...GLOBAL_ERRORS[\"6e00\"],\n errorCode: \"6e00\",\n }),\n }),\n );\n\n const expectedStates: Array<GetDeviceStatusDAState> = [\n {\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.None,\n },\n status: DeviceActionStatus.Pending,\n },\n {\n output: {\n currentApp: \"BOLOS\",\n currentAppVersion: \"0.0.0\",\n },\n status: DeviceActionStatus.Completed,\n },\n ];\n\n testDeviceActionStates(\n getDeviceStateDeviceAction,\n expectedStates,\n makeDeviceActionInternalApiMock(),\n {\n onDone: resolve,\n onError: reject,\n },\n );\n }));\n });\n\n describe(\"success cases\", () => {\n it(\"should return the device status if the device is unlocked\", () =>\n new Promise<void>((resolve, reject) => {\n getDeviceSessionStateMock.mockReturnValue({\n sessionStateType: DeviceSessionStateType.ReadyWithoutSecureChannel,\n deviceStatus: DeviceStatus.CONNECTED,\n currentApp: { name: \"mockedCurrentApp\", version: \"1.0.0\" },\n });\n\n getAppAndVersionMock.mockResolvedValue(\n CommandResultFactory({\n data: {\n name: \"BOLOS\",\n version: \"1.0.0\",\n },\n }),\n );\n\n const getDeviceStateDeviceAction = new GetDeviceStatusDeviceAction({\n input: { unlockTimeout: undefined },\n });\n\n vi.spyOn(\n getDeviceStateDeviceAction,\n \"extractDependencies\",\n ).mockReturnValue(extractDependenciesMock());\n\n const expectedStates: Array<GetDeviceStatusDAState> = [\n {\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.None,\n },\n status: DeviceActionStatus.Pending,\n },\n {\n status: DeviceActionStatus.Completed,\n output: {\n currentApp: \"BOLOS\",\n currentAppVersion: \"1.0.0\",\n },\n },\n ];\n\n testDeviceActionStates(\n getDeviceStateDeviceAction,\n expectedStates,\n makeDeviceActionInternalApiMock(),\n {\n onDone: () => {\n // Session should be updated with current app\n expect(setDeviceSessionState).toHaveBeenCalledWith({\n sessionStateType:\n DeviceSessionStateType.ReadyWithoutSecureChannel,\n deviceStatus: DeviceStatus.CONNECTED,\n currentApp: {\n name: \"BOLOS\",\n version: \"1.0.0\",\n },\n });\n resolve();\n },\n onError: reject,\n },\n );\n }));\n\n it(\"should return the device status and update session if the device is not ready\", () =>\n new Promise<void>((resolve, reject) => {\n getDeviceSessionStateMock.mockReturnValue({\n sessionStateType: DeviceSessionStateType.Connected,\n deviceStatus: DeviceStatus.CONNECTED,\n });\n\n getAppAndVersionMock.mockResolvedValue(\n CommandResultFactory({\n data: {\n name: \"BOLOS\",\n version: \"1.0.0\",\n },\n }),\n );\n\n const getDeviceStateDeviceAction = new GetDeviceStatusDeviceAction({\n input: { unlockTimeout: undefined },\n });\n\n vi.spyOn(\n getDeviceStateDeviceAction,\n \"extractDependencies\",\n ).mockReturnValue(extractDependenciesMock());\n\n const expectedStates: Array<GetDeviceStatusDAState> = [\n {\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.None,\n },\n status: DeviceActionStatus.Pending,\n },\n {\n status: DeviceActionStatus.Completed,\n output: {\n currentApp: \"BOLOS\",\n currentAppVersion: \"1.0.0\",\n },\n },\n ];\n\n testDeviceActionStates(\n getDeviceStateDeviceAction,\n expectedStates,\n makeDeviceActionInternalApiMock(),\n {\n onDone: () => {\n // Session should be set as ready if GetAppAndVersionCommand was successful\n expect(setDeviceSessionState).toHaveBeenCalledWith({\n sessionStateType:\n DeviceSessionStateType.ReadyWithoutSecureChannel,\n deviceStatus: DeviceStatus.CONNECTED,\n currentApp: {\n name: \"BOLOS\",\n version: \"1.0.0\",\n },\n installedApps: [],\n isSecureConnectionAllowed: false,\n });\n resolve();\n },\n onError: reject,\n },\n );\n }));\n\n it(\"should return the device status if the device is locked and the user unlocks the device\", () =>\n new Promise<void>((resolve, reject) => {\n getDeviceSessionStateMock.mockReturnValue({\n sessionStateType: DeviceSessionStateType.ReadyWithoutSecureChannel,\n deviceStatus: DeviceStatus.LOCKED,\n currentApp: { name: \"mockedCurrentApp\", version: \"1.0.0\" },\n });\n\n getAppAndVersionMock\n .mockResolvedValueOnce(\n CommandResultFactory({\n error: new GlobalCommandError({\n ...GLOBAL_ERRORS[\"5515\"],\n errorCode: \"5515\",\n }),\n }),\n )\n .mockResolvedValueOnce(\n CommandResultFactory({\n data: {\n name: \"BOLOS\",\n version: \"1.0.0\",\n },\n }),\n );\n\n waitForDeviceUnlockMock.mockImplementation(\n () =>\n new Observable((o) => {\n const inner = interval(50).subscribe({\n next: (i) => {\n if (i > 2) {\n o.next({\n sessionStateType:\n DeviceSessionStateType.ReadyWithoutSecureChannel,\n deviceStatus: DeviceStatus.CONNECTED,\n currentApp: {\n name: \"mockedCurrentApp\",\n version: \"1.0.0\",\n },\n });\n o.complete();\n } else {\n o.next({\n sessionStateType:\n DeviceSessionStateType.ReadyWithoutSecureChannel,\n deviceStatus: DeviceStatus.LOCKED,\n currentApp: {\n name: \"mockedCurrentApp\",\n version: \"1.0.0\",\n },\n });\n }\n },\n });\n\n return () => {\n inner.unsubscribe();\n };\n }),\n );\n\n const getDeviceStateDeviceAction = new GetDeviceStatusDeviceAction({\n input: { unlockTimeout: 500 },\n });\n\n vi.spyOn(\n getDeviceStateDeviceAction,\n \"extractDependencies\",\n ).mockReturnValue(extractDependenciesMock());\n\n const expectedStates: Array<GetDeviceStatusDAState> = [\n {\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.None,\n },\n status: DeviceActionStatus.Pending,\n },\n {\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.UnlockDevice,\n },\n status: DeviceActionStatus.Pending,\n },\n {\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.None,\n },\n status: DeviceActionStatus.Pending,\n },\n {\n status: DeviceActionStatus.Completed,\n output: {\n currentApp: \"BOLOS\",\n currentAppVersion: \"1.0.0\",\n },\n },\n ];\n\n testDeviceActionStates(\n getDeviceStateDeviceAction,\n expectedStates,\n makeDeviceActionInternalApiMock(),\n {\n onDone: resolve,\n onError: reject,\n },\n );\n }));\n });\n\n describe(\"errors cases\", () => {\n it(\"should end in an error if the device is not onboarded\", () =>\n new Promise<void>((resolve, reject) => {\n getDeviceSessionStateMock.mockReturnValue({\n sessionStateType: DeviceSessionStateType.ReadyWithoutSecureChannel,\n deviceStatus: DeviceStatus.LOCKED,\n currentApp: { name: \"mockedCurrentApp\", version: \"1.0.0\" },\n });\n isDeviceOnboardedMock.mockReturnValue(false);\n\n const getDeviceStateDeviceAction = new GetDeviceStatusDeviceAction({\n input: { unlockTimeout: 500 },\n });\n\n vi.spyOn(\n getDeviceStateDeviceAction,\n \"extractDependencies\",\n ).mockReturnValue(extractDependenciesMock());\n\n const expectedStates: Array<GetDeviceStatusDAState> = [\n {\n error: new DeviceNotOnboardedError(),\n status: DeviceActionStatus.Error,\n },\n ];\n\n testDeviceActionStates(\n getDeviceStateDeviceAction,\n expectedStates,\n makeDeviceActionInternalApiMock(),\n {\n onDone: resolve,\n onError: reject,\n },\n );\n }));\n\n it(\"should end in an error if the device is locked and the user does not unlock\", () =>\n new Promise<void>((resolve, reject) => {\n getDeviceSessionStateMock.mockReturnValue({\n sessionStateType: DeviceSessionStateType.ReadyWithoutSecureChannel,\n deviceStatus: DeviceStatus.LOCKED,\n currentApp: { name: \"mockedCurrentApp\", version: \"1.0.0\" },\n });\n\n getAppAndVersionMock.mockResolvedValue(\n CommandResultFactory({\n error: new GlobalCommandError({\n ...GLOBAL_ERRORS[\"5515\"],\n errorCode: \"5515\",\n }),\n }),\n );\n\n apiGetDeviceSessionStateObservableMock.mockImplementation(\n () =>\n new Observable((o) => {\n const inner = interval(200).subscribe({\n next: () => {\n o.next({\n sessionStateType:\n DeviceSessionStateType.ReadyWithoutSecureChannel,\n deviceStatus: DeviceStatus.LOCKED,\n currentApp: { name: \"mockedCurrentApp\", version: \"1.0.0\" },\n installedApps: [],\n deviceModelId: DeviceModelId.NANO_X,\n isSecureConnectionAllowed: false,\n });\n },\n });\n\n return () => {\n inner.unsubscribe();\n };\n }),\n );\n\n const getDeviceStateDeviceAction = new GetDeviceStatusDeviceAction({\n input: { unlockTimeout: 500 },\n });\n\n vi.spyOn(\n getDeviceStateDeviceAction,\n \"extractDependencies\",\n ).mockReturnValue(extractDependenciesMock());\n\n const expectedStates: Array<GetDeviceStatusDAState> = [\n {\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.None,\n },\n status: DeviceActionStatus.Pending,\n },\n {\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.UnlockDevice,\n },\n status: DeviceActionStatus.Pending,\n },\n {\n error: new DeviceLockedError(\"Device locked.\"),\n status: DeviceActionStatus.Error,\n },\n ];\n\n testDeviceActionStates(\n getDeviceStateDeviceAction,\n expectedStates,\n makeDeviceActionInternalApiMock(),\n {\n onDone: resolve,\n onError: reject,\n },\n );\n }));\n\n it(\"should end in an error if the GetAppAndVersion command fails\", () =>\n new Promise<void>((resolve, reject) => {\n getDeviceSessionStateMock.mockReturnValue({\n sessionStateType: DeviceSessionStateType.ReadyWithoutSecureChannel,\n deviceStatus: DeviceStatus.LOCKED,\n currentApp: { name: \"mockedCurrentApp\", version: \"1.0.0\" },\n });\n\n const error = new GlobalCommandError({\n ...GLOBAL_ERRORS[\"5501\"],\n errorCode: \"5501\",\n });\n\n getAppAndVersionMock.mockResolvedValue(CommandResultFactory({ error }));\n\n waitForDeviceUnlockMock.mockImplementation(\n () =>\n new Observable((o) => {\n const inner = interval(50).subscribe({\n next: (i) => {\n if (i > 2) {\n o.next({\n sessionStateType:\n DeviceSessionStateType.ReadyWithoutSecureChannel,\n deviceStatus: DeviceStatus.CONNECTED,\n currentApp: {\n name: \"mockedCurrentApp\",\n version: \"1.0.0\",\n },\n });\n o.complete();\n } else {\n o.next({\n sessionStateType:\n DeviceSessionStateType.ReadyWithoutSecureChannel,\n deviceStatus: DeviceStatus.LOCKED,\n currentApp: {\n name: \"mockedCurrentApp\",\n version: \"1.0.0\",\n },\n });\n }\n },\n });\n\n return () => {\n inner.unsubscribe();\n };\n }),\n );\n\n const getDeviceStateDeviceAction = new GetDeviceStatusDeviceAction({\n input: { unlockTimeout: 500 },\n });\n\n vi.spyOn(\n getDeviceStateDeviceAction,\n \"extractDependencies\",\n ).mockReturnValue(extractDependenciesMock());\n\n const expectedStates: Array<GetDeviceStatusDAState> = [\n {\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.None,\n },\n status: DeviceActionStatus.Pending,\n },\n {\n error,\n status: DeviceActionStatus.Error,\n },\n ];\n\n testDeviceActionStates(\n getDeviceStateDeviceAction,\n expectedStates,\n makeDeviceActionInternalApiMock(),\n {\n onDone: resolve,\n onError: reject,\n },\n );\n }));\n\n it(\"should end in an error if getAppAndVersion actor throws an error\", () =>\n new Promise<void>((resolve, reject) => {\n getDeviceSessionStateMock.mockReturnValue({\n sessionStateType: DeviceSessionStateType.ReadyWithoutSecureChannel,\n deviceStatus: DeviceStatus.LOCKED,\n currentApp: { name: \"mockedCurrentApp\", version: \"1.0.0\" },\n });\n\n getAppAndVersionMock.mockImplementation(() => {\n throw new UnknownDAError(\"error\");\n });\n\n waitForDeviceUnlockMock.mockImplementation(\n () =>\n new Observable((o) => {\n o.complete();\n }),\n );\n\n const getDeviceStateDeviceAction = new GetDeviceStatusDeviceAction({\n input: { unlockTimeout: 500 },\n });\n\n vi.spyOn(\n getDeviceStateDeviceAction,\n \"extractDependencies\",\n ).mockReturnValue(extractDependenciesMock());\n\n const expectedStates: Array<GetDeviceStatusDAState> = [\n {\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.None,\n },\n status: DeviceActionStatus.Pending,\n },\n {\n error: new UnknownDAError(\"error\"),\n status: DeviceActionStatus.Error,\n },\n ];\n\n testDeviceActionStates(\n getDeviceStateDeviceAction,\n expectedStates,\n makeDeviceActionInternalApiMock(),\n {\n onDone: resolve,\n onError: reject,\n },\n );\n }));\n });\n\n it(\"should emit a stopped state if the action is cancelled\", () =>\n new Promise<void>((resolve, reject) => {\n apiGetDeviceSessionStateMock.mockReturnValue({\n sessionStateType: DeviceSessionStateType.ReadyWithoutSecureChannel,\n deviceStatus: DeviceStatus.CONNECTED,\n currentApp: { name: \"mockedCurrentApp\", version: \"1.0.0\" },\n installedApps: [],\n deviceModelId: DeviceModelId.NANO_X,\n isSecureConnectionAllowed: false,\n });\n\n sendCommandMock.mockResolvedValue(\n CommandResultFactory({\n data: {\n name: \"BOLOS\",\n version: \"1.0.0\",\n },\n }),\n );\n\n const getDeviceStateDeviceAction = new GetDeviceStatusDeviceAction({\n input: { unlockTimeout: 500 },\n });\n\n const expectedStates: Array<GetDeviceStatusDAState> = [\n {\n status: DeviceActionStatus.Pending, // get app and version\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.None,\n },\n },\n {\n status: DeviceActionStatus.Stopped,\n },\n ];\n\n const { cancel } = testDeviceActionStates(\n getDeviceStateDeviceAction,\n expectedStates,\n makeDeviceActionInternalApiMock(),\n {\n onDone: resolve,\n onError: reject,\n },\n );\n cancel();\n }));\n});\n"],
5
- "mappings": "AAAA,OAAS,YAAAA,EAAU,cAAAC,MAAkB,OAErC,OAAS,wBAAAC,MAA4B,mCACrC,OACE,iBAAAC,EACA,sBAAAC,MACK,wCACP,OAAS,iBAAAC,MAAqB,0BAC9B,OAAS,gBAAAC,MAAoB,2BAC7B,OAAS,mCAAAC,MAAuC,oDAChD,OAAS,0BAAAC,MAA8B,2DACvC,OAAS,sBAAAC,MAA0B,6CACnC,OAAS,2BAAAC,MAA+B,mDACxC,OACE,qBAAAC,EACA,2BAAAC,EACA,kBAAAC,MACK,+BACP,OAAS,0BAAAC,MAA8B,yCAEvC,OAAS,+BAAAC,MAAmC,gCAG5C,SAAS,8BAA+B,IAAM,CAC5C,MAAMC,EAAuB,GAAG,GAAG,EAC7BC,EAA4B,GAAG,GAAG,EAClCC,EAA0B,GAAG,GAAG,EAChCC,EAAwB,GAAG,GAAG,EAC9BC,EAAwB,GAAG,GAAG,EAEpC,SAASC,GAA0B,CACjC,MAAO,CACL,iBAAkBL,EAClB,sBAAuBC,EACvB,oBAAqBC,EACrB,sBAAuBC,EACvB,kBAAmBC,CACrB,CACF,CAEA,KAAM,CACJ,YAAaE,EACb,sBAAuBC,EACvB,gCAAiCC,CACnC,EAAIjB,EAAgC,EACpC,WAAW,IAAM,CACf,GAAG,cAAc,EACjBa,EAAsB,gBAAgB,EAAI,CAC5C,CAAC,EAED,SAAS,2CAA4C,IAAM,CACzD,GAAG,uDAAwD,IACzD,IAAI,QAAc,CAACK,EAASC,IAAW,CACrC,MAAMC,EAA6B,IAAIZ,EAA4B,CACjE,MAAO,CAAE,cAAe,GAAI,CAC9B,CAAC,EAEDQ,EAA6B,gBAAgB,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,CAAC,EAEKa,EAAgD,CACpD,CACE,OAAQnB,EAAmB,QAC3B,kBAAmB,CACjB,wBAAyBC,EAAwB,IACnD,CACF,EACA,CACE,OAAQD,EAAmB,OAC7B,CACF,EAEM,CAAE,OAAAwB,CAAO,EAAIzB,EACjBmB,EACAC,EACArB,EAAgC,EAChC,CACE,OAAQkB,EACR,QAASC,CACX,CACF,EACAO,EAAO,CACT,CAAC,CAAC,CACN,CAAC",
6
- "names": ["interval", "Observable", "CommandResultFactory", "GLOBAL_ERRORS", "GlobalCommandError", "DeviceModelId", "DeviceStatus", "makeDeviceActionInternalApiMock", "testDeviceActionStates", "DeviceActionStatus", "UserInteractionRequired", "DeviceLockedError", "DeviceNotOnboardedError", "UnknownDAError", "DeviceSessionStateType", "GetDeviceStatusDeviceAction", "getAppAndVersionMock", "getDeviceSessionStateMock", "waitForDeviceUnlockMock", "setDeviceSessionState", "isDeviceOnboardedMock", "extractDependenciesMock", "sendCommandMock", "apiGetDeviceSessionStateMock", "apiGetDeviceSessionStateObservableMock", "resolve", "reject", "getDeviceStateDeviceAction", "expectedStates", "o", "inner", "i", "error", "cancel"]
4
+ "sourcesContent": ["import { interval, Observable } from \"rxjs\";\n\nimport { CommandResultFactory } from \"@api/command/model/CommandResult\";\nimport {\n GLOBAL_ERRORS,\n GlobalCommandError,\n} from \"@api/command/utils/GlobalCommandError\";\nimport { DeviceModelId } from \"@api/device/DeviceModel\";\nimport { DeviceStatus } from \"@api/device/DeviceStatus\";\nimport { makeDeviceActionInternalApiMock } from \"@api/device-action/__test-utils__/makeInternalApi\";\nimport { testDeviceActionStates } from \"@api/device-action/__test-utils__/testDeviceActionStates\";\nimport { DeviceActionStatus } from \"@api/device-action/model/DeviceActionState\";\nimport { UserInteractionRequired } from \"@api/device-action/model/UserInteractionRequired\";\nimport {\n DeviceLockedError,\n DeviceNotOnboardedError,\n UnknownDAError,\n} from \"@api/device-action/os/Errors\";\nimport { DeviceSessionStateType } from \"@api/device-session/DeviceSessionState\";\n\nimport { GetDeviceStatusDeviceAction } from \"./GetDeviceStatusDeviceAction\";\nimport {\n type GetDeviceStatusDAState,\n getDeviceStatusDAStateStep,\n} from \"./types\";\n\ndescribe(\"GetDeviceStatusDeviceAction\", () => {\n const getAppAndVersionMock = vi.fn();\n const getDeviceSessionStateMock = vi.fn();\n const waitForDeviceUnlockMock = vi.fn();\n const setDeviceSessionState = vi.fn();\n const isDeviceOnboardedMock = vi.fn();\n\n function extractDependenciesMock() {\n return {\n getAppAndVersion: getAppAndVersionMock,\n getDeviceSessionState: getDeviceSessionStateMock,\n waitForDeviceUnlock: waitForDeviceUnlockMock,\n setDeviceSessionState: setDeviceSessionState,\n isDeviceOnboarded: isDeviceOnboardedMock,\n };\n }\n\n const {\n sendCommand: sendCommandMock,\n getDeviceSessionState: apiGetDeviceSessionStateMock,\n getDeviceSessionStateObservable: apiGetDeviceSessionStateObservableMock,\n } = makeDeviceActionInternalApiMock();\n beforeEach(() => {\n vi.resetAllMocks();\n isDeviceOnboardedMock.mockReturnValue(true);\n });\n\n describe(\"without overriding `extractDependencies`\", () => {\n it(\"should run the device action with an unlocked device\", () =>\n new Promise<void>((resolve, reject) => {\n const getDeviceStateDeviceAction = new GetDeviceStatusDeviceAction({\n input: { unlockTimeout: 500 },\n });\n\n apiGetDeviceSessionStateMock.mockReturnValue({\n sessionStateType: DeviceSessionStateType.Connected,\n deviceStatus: DeviceStatus.CONNECTED,\n deviceModelId: DeviceModelId.NANO_X,\n });\n\n sendCommandMock.mockResolvedValue(\n CommandResultFactory({\n data: {\n name: \"BOLOS\",\n version: \"1.0.0\",\n },\n }),\n );\n\n const expectedStates: Array<GetDeviceStatusDAState> = [\n {\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.None,\n step: getDeviceStatusDAStateStep.ONBOARD_CHECK,\n },\n status: DeviceActionStatus.Pending,\n },\n {\n output: {\n currentApp: \"BOLOS\",\n currentAppVersion: \"1.0.0\",\n },\n status: DeviceActionStatus.Completed,\n },\n ];\n\n testDeviceActionStates(\n getDeviceStateDeviceAction,\n expectedStates,\n makeDeviceActionInternalApiMock(),\n {\n onDone: resolve,\n onError: reject,\n },\n );\n }));\n\n it(\"should run the device action with a locked device\", () =>\n new Promise<void>((resolve, reject) => {\n const getDeviceStateDeviceAction = new GetDeviceStatusDeviceAction({\n input: { unlockTimeout: 1500 },\n });\n\n apiGetDeviceSessionStateMock.mockReturnValue({\n sessionStateType: DeviceSessionStateType.ReadyWithoutSecureChannel,\n deviceStatus: DeviceStatus.LOCKED,\n currentApp: { name: \"mockedCurrentApp\", version: \"1.0.0\" },\n installedApps: [],\n deviceModelId: DeviceModelId.NANO_X,\n isSecureConnectionAllowed: false,\n });\n\n sendCommandMock\n .mockResolvedValueOnce(\n CommandResultFactory({\n error: new GlobalCommandError({\n ...GLOBAL_ERRORS[\"5515\"],\n errorCode: \"5515\",\n }),\n }),\n )\n .mockResolvedValue(\n CommandResultFactory({\n data: {\n name: \"BOLOS\",\n version: \"1.0.0\",\n },\n }),\n );\n\n const expectedStates: Array<GetDeviceStatusDAState> = [\n {\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.None,\n step: getDeviceStatusDAStateStep.ONBOARD_CHECK,\n },\n status: DeviceActionStatus.Pending,\n },\n {\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.UnlockDevice,\n step: getDeviceStatusDAStateStep.UNLOCK_DEVICE,\n },\n status: DeviceActionStatus.Pending,\n },\n {\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.None,\n step: getDeviceStatusDAStateStep.UNLOCK_DEVICE,\n },\n status: DeviceActionStatus.Pending,\n },\n {\n output: {\n currentApp: \"BOLOS\",\n currentAppVersion: \"1.0.0\",\n },\n status: DeviceActionStatus.Completed,\n },\n ];\n\n testDeviceActionStates(\n getDeviceStateDeviceAction,\n expectedStates,\n makeDeviceActionInternalApiMock(),\n {\n onDone: resolve,\n onError: reject,\n },\n );\n }));\n\n it(\"should timeout with a locked device\", () =>\n new Promise<void>((resolve, reject) => {\n const getDeviceStateDeviceAction = new GetDeviceStatusDeviceAction({\n input: { unlockTimeout: 200 },\n });\n\n apiGetDeviceSessionStateMock.mockReturnValue({\n sessionStateType: DeviceSessionStateType.ReadyWithoutSecureChannel,\n deviceStatus: DeviceStatus.LOCKED,\n currentApp: { name: \"mockedCurrentApp\", version: \"1.0.0\" },\n installedApps: [],\n deviceModelId: DeviceModelId.NANO_X,\n isSecureConnectionAllowed: false,\n });\n\n sendCommandMock\n .mockResolvedValueOnce(\n CommandResultFactory({\n error: new GlobalCommandError({\n ...GLOBAL_ERRORS[\"5515\"],\n errorCode: \"5515\",\n }),\n }),\n )\n .mockResolvedValue(\n CommandResultFactory({\n data: {\n name: \"BOLOS\",\n version: \"1.0.0\",\n },\n }),\n );\n\n const expectedStates: Array<GetDeviceStatusDAState> = [\n {\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.None,\n step: getDeviceStatusDAStateStep.ONBOARD_CHECK,\n },\n status: DeviceActionStatus.Pending,\n },\n {\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.UnlockDevice,\n step: getDeviceStatusDAStateStep.UNLOCK_DEVICE,\n },\n status: DeviceActionStatus.Pending,\n },\n {\n error: new DeviceLockedError(\"Device locked.\"),\n status: DeviceActionStatus.Error,\n },\n ];\n\n testDeviceActionStates(\n getDeviceStateDeviceAction,\n expectedStates,\n makeDeviceActionInternalApiMock(),\n {\n onDone: resolve,\n onError: reject,\n },\n );\n }));\n\n it(\"should run the device action with an old firmware not supporting GetAppAndVersion\", () =>\n new Promise<void>((resolve, reject) => {\n const getDeviceStateDeviceAction = new GetDeviceStatusDeviceAction({\n input: { unlockTimeout: 500 },\n });\n\n apiGetDeviceSessionStateMock.mockReturnValue({\n sessionStateType: DeviceSessionStateType.Connected,\n deviceStatus: DeviceStatus.CONNECTED,\n deviceModelId: DeviceModelId.NANO_X,\n });\n\n sendCommandMock.mockResolvedValue(\n CommandResultFactory({\n error: new GlobalCommandError({\n ...GLOBAL_ERRORS[\"6e00\"],\n errorCode: \"6e00\",\n }),\n }),\n );\n\n const expectedStates: Array<GetDeviceStatusDAState> = [\n {\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.None,\n step: getDeviceStatusDAStateStep.ONBOARD_CHECK,\n },\n status: DeviceActionStatus.Pending,\n },\n {\n output: {\n currentApp: \"BOLOS\",\n currentAppVersion: \"0.0.0\",\n },\n status: DeviceActionStatus.Completed,\n },\n ];\n\n testDeviceActionStates(\n getDeviceStateDeviceAction,\n expectedStates,\n makeDeviceActionInternalApiMock(),\n {\n onDone: resolve,\n onError: reject,\n },\n );\n }));\n });\n\n describe(\"success cases\", () => {\n it(\"should return the device status if the device is unlocked\", () =>\n new Promise<void>((resolve, reject) => {\n getDeviceSessionStateMock.mockReturnValue({\n sessionStateType: DeviceSessionStateType.ReadyWithoutSecureChannel,\n deviceStatus: DeviceStatus.CONNECTED,\n currentApp: { name: \"mockedCurrentApp\", version: \"1.0.0\" },\n });\n\n getAppAndVersionMock.mockResolvedValue(\n CommandResultFactory({\n data: {\n name: \"BOLOS\",\n version: \"1.0.0\",\n },\n }),\n );\n\n const getDeviceStateDeviceAction = new GetDeviceStatusDeviceAction({\n input: { unlockTimeout: undefined },\n });\n\n vi.spyOn(\n getDeviceStateDeviceAction,\n \"extractDependencies\",\n ).mockReturnValue(extractDependenciesMock());\n\n const expectedStates: Array<GetDeviceStatusDAState> = [\n {\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.None,\n step: getDeviceStatusDAStateStep.ONBOARD_CHECK,\n },\n status: DeviceActionStatus.Pending,\n },\n {\n status: DeviceActionStatus.Completed,\n output: {\n currentApp: \"BOLOS\",\n currentAppVersion: \"1.0.0\",\n },\n },\n ];\n\n testDeviceActionStates(\n getDeviceStateDeviceAction,\n expectedStates,\n makeDeviceActionInternalApiMock(),\n {\n onDone: () => {\n // Session should be updated with current app\n expect(setDeviceSessionState).toHaveBeenCalledWith({\n sessionStateType:\n DeviceSessionStateType.ReadyWithoutSecureChannel,\n deviceStatus: DeviceStatus.CONNECTED,\n currentApp: {\n name: \"BOLOS\",\n version: \"1.0.0\",\n },\n });\n resolve();\n },\n onError: reject,\n },\n );\n }));\n\n it(\"should return the device status and update session if the device is not ready\", () =>\n new Promise<void>((resolve, reject) => {\n getDeviceSessionStateMock.mockReturnValue({\n sessionStateType: DeviceSessionStateType.Connected,\n deviceStatus: DeviceStatus.CONNECTED,\n });\n\n getAppAndVersionMock.mockResolvedValue(\n CommandResultFactory({\n data: {\n name: \"BOLOS\",\n version: \"1.0.0\",\n },\n }),\n );\n\n const getDeviceStateDeviceAction = new GetDeviceStatusDeviceAction({\n input: { unlockTimeout: undefined },\n });\n\n vi.spyOn(\n getDeviceStateDeviceAction,\n \"extractDependencies\",\n ).mockReturnValue(extractDependenciesMock());\n\n const expectedStates: Array<GetDeviceStatusDAState> = [\n {\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.None,\n step: getDeviceStatusDAStateStep.ONBOARD_CHECK,\n },\n status: DeviceActionStatus.Pending,\n },\n {\n status: DeviceActionStatus.Completed,\n output: {\n currentApp: \"BOLOS\",\n currentAppVersion: \"1.0.0\",\n },\n },\n ];\n\n testDeviceActionStates(\n getDeviceStateDeviceAction,\n expectedStates,\n makeDeviceActionInternalApiMock(),\n {\n onDone: () => {\n // Session should be set as ready if GetAppAndVersionCommand was successful\n expect(setDeviceSessionState).toHaveBeenCalledWith({\n sessionStateType:\n DeviceSessionStateType.ReadyWithoutSecureChannel,\n deviceStatus: DeviceStatus.CONNECTED,\n currentApp: {\n name: \"BOLOS\",\n version: \"1.0.0\",\n },\n installedApps: [],\n isSecureConnectionAllowed: false,\n });\n resolve();\n },\n onError: reject,\n },\n );\n }));\n\n it(\"should return the device status if the device is locked and the user unlocks the device\", () =>\n new Promise<void>((resolve, reject) => {\n getDeviceSessionStateMock.mockReturnValue({\n sessionStateType: DeviceSessionStateType.ReadyWithoutSecureChannel,\n deviceStatus: DeviceStatus.LOCKED,\n currentApp: { name: \"mockedCurrentApp\", version: \"1.0.0\" },\n });\n\n getAppAndVersionMock\n .mockResolvedValueOnce(\n CommandResultFactory({\n error: new GlobalCommandError({\n ...GLOBAL_ERRORS[\"5515\"],\n errorCode: \"5515\",\n }),\n }),\n )\n .mockResolvedValueOnce(\n CommandResultFactory({\n data: {\n name: \"BOLOS\",\n version: \"1.0.0\",\n },\n }),\n );\n\n waitForDeviceUnlockMock.mockImplementation(\n () =>\n new Observable((o) => {\n const inner = interval(50).subscribe({\n next: (i) => {\n if (i > 2) {\n o.next({\n sessionStateType:\n DeviceSessionStateType.ReadyWithoutSecureChannel,\n deviceStatus: DeviceStatus.CONNECTED,\n currentApp: {\n name: \"mockedCurrentApp\",\n version: \"1.0.0\",\n },\n });\n o.complete();\n } else {\n o.next({\n sessionStateType:\n DeviceSessionStateType.ReadyWithoutSecureChannel,\n deviceStatus: DeviceStatus.LOCKED,\n currentApp: {\n name: \"mockedCurrentApp\",\n version: \"1.0.0\",\n },\n });\n }\n },\n });\n\n return () => {\n inner.unsubscribe();\n };\n }),\n );\n\n const getDeviceStateDeviceAction = new GetDeviceStatusDeviceAction({\n input: { unlockTimeout: 500 },\n });\n\n vi.spyOn(\n getDeviceStateDeviceAction,\n \"extractDependencies\",\n ).mockReturnValue(extractDependenciesMock());\n\n const expectedStates: Array<GetDeviceStatusDAState> = [\n {\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.None,\n step: getDeviceStatusDAStateStep.ONBOARD_CHECK,\n },\n status: DeviceActionStatus.Pending,\n },\n {\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.UnlockDevice,\n step: getDeviceStatusDAStateStep.UNLOCK_DEVICE,\n },\n status: DeviceActionStatus.Pending,\n },\n {\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.None,\n step: getDeviceStatusDAStateStep.UNLOCK_DEVICE,\n },\n status: DeviceActionStatus.Pending,\n },\n {\n status: DeviceActionStatus.Completed,\n output: {\n currentApp: \"BOLOS\",\n currentAppVersion: \"1.0.0\",\n },\n },\n ];\n\n testDeviceActionStates(\n getDeviceStateDeviceAction,\n expectedStates,\n makeDeviceActionInternalApiMock(),\n {\n onDone: resolve,\n onError: reject,\n },\n );\n }));\n });\n\n describe(\"errors cases\", () => {\n it(\"should end in an error if the device is not onboarded\", () =>\n new Promise<void>((resolve, reject) => {\n getDeviceSessionStateMock.mockReturnValue({\n sessionStateType: DeviceSessionStateType.ReadyWithoutSecureChannel,\n deviceStatus: DeviceStatus.LOCKED,\n currentApp: { name: \"mockedCurrentApp\", version: \"1.0.0\" },\n });\n isDeviceOnboardedMock.mockReturnValue(false);\n\n const getDeviceStateDeviceAction = new GetDeviceStatusDeviceAction({\n input: { unlockTimeout: 500 },\n });\n\n vi.spyOn(\n getDeviceStateDeviceAction,\n \"extractDependencies\",\n ).mockReturnValue(extractDependenciesMock());\n\n const expectedStates: Array<GetDeviceStatusDAState> = [\n {\n error: new DeviceNotOnboardedError(),\n status: DeviceActionStatus.Error,\n },\n ];\n\n testDeviceActionStates(\n getDeviceStateDeviceAction,\n expectedStates,\n makeDeviceActionInternalApiMock(),\n {\n onDone: resolve,\n onError: reject,\n },\n );\n }));\n\n it(\"should end in an error if the device is locked and the user does not unlock\", () =>\n new Promise<void>((resolve, reject) => {\n getDeviceSessionStateMock.mockReturnValue({\n sessionStateType: DeviceSessionStateType.ReadyWithoutSecureChannel,\n deviceStatus: DeviceStatus.LOCKED,\n currentApp: { name: \"mockedCurrentApp\", version: \"1.0.0\" },\n });\n\n getAppAndVersionMock.mockResolvedValue(\n CommandResultFactory({\n error: new GlobalCommandError({\n ...GLOBAL_ERRORS[\"5515\"],\n errorCode: \"5515\",\n }),\n }),\n );\n\n apiGetDeviceSessionStateObservableMock.mockImplementation(\n () =>\n new Observable((o) => {\n const inner = interval(200).subscribe({\n next: () => {\n o.next({\n sessionStateType:\n DeviceSessionStateType.ReadyWithoutSecureChannel,\n deviceStatus: DeviceStatus.LOCKED,\n currentApp: { name: \"mockedCurrentApp\", version: \"1.0.0\" },\n installedApps: [],\n deviceModelId: DeviceModelId.NANO_X,\n isSecureConnectionAllowed: false,\n });\n },\n });\n\n return () => {\n inner.unsubscribe();\n };\n }),\n );\n\n const getDeviceStateDeviceAction = new GetDeviceStatusDeviceAction({\n input: { unlockTimeout: 500 },\n });\n\n vi.spyOn(\n getDeviceStateDeviceAction,\n \"extractDependencies\",\n ).mockReturnValue(extractDependenciesMock());\n\n const expectedStates: Array<GetDeviceStatusDAState> = [\n {\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.None,\n step: getDeviceStatusDAStateStep.ONBOARD_CHECK,\n },\n status: DeviceActionStatus.Pending,\n },\n {\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.UnlockDevice,\n step: getDeviceStatusDAStateStep.UNLOCK_DEVICE,\n },\n status: DeviceActionStatus.Pending,\n },\n {\n error: new DeviceLockedError(\"Device locked.\"),\n status: DeviceActionStatus.Error,\n },\n ];\n\n testDeviceActionStates(\n getDeviceStateDeviceAction,\n expectedStates,\n makeDeviceActionInternalApiMock(),\n {\n onDone: resolve,\n onError: reject,\n },\n );\n }));\n\n it(\"should end in an error if the GetAppAndVersion command fails\", () =>\n new Promise<void>((resolve, reject) => {\n getDeviceSessionStateMock.mockReturnValue({\n sessionStateType: DeviceSessionStateType.ReadyWithoutSecureChannel,\n deviceStatus: DeviceStatus.LOCKED,\n currentApp: { name: \"mockedCurrentApp\", version: \"1.0.0\" },\n });\n\n const error = new GlobalCommandError({\n ...GLOBAL_ERRORS[\"5501\"],\n errorCode: \"5501\",\n });\n\n getAppAndVersionMock.mockResolvedValue(CommandResultFactory({ error }));\n\n waitForDeviceUnlockMock.mockImplementation(\n () =>\n new Observable((o) => {\n const inner = interval(50).subscribe({\n next: (i) => {\n if (i > 2) {\n o.next({\n sessionStateType:\n DeviceSessionStateType.ReadyWithoutSecureChannel,\n deviceStatus: DeviceStatus.CONNECTED,\n currentApp: {\n name: \"mockedCurrentApp\",\n version: \"1.0.0\",\n },\n });\n o.complete();\n } else {\n o.next({\n sessionStateType:\n DeviceSessionStateType.ReadyWithoutSecureChannel,\n deviceStatus: DeviceStatus.LOCKED,\n currentApp: {\n name: \"mockedCurrentApp\",\n version: \"1.0.0\",\n },\n });\n }\n },\n });\n\n return () => {\n inner.unsubscribe();\n };\n }),\n );\n\n const getDeviceStateDeviceAction = new GetDeviceStatusDeviceAction({\n input: { unlockTimeout: 500 },\n });\n\n vi.spyOn(\n getDeviceStateDeviceAction,\n \"extractDependencies\",\n ).mockReturnValue(extractDependenciesMock());\n\n const expectedStates: Array<GetDeviceStatusDAState> = [\n {\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.None,\n step: getDeviceStatusDAStateStep.ONBOARD_CHECK,\n },\n status: DeviceActionStatus.Pending,\n },\n {\n error,\n status: DeviceActionStatus.Error,\n },\n ];\n\n testDeviceActionStates(\n getDeviceStateDeviceAction,\n expectedStates,\n makeDeviceActionInternalApiMock(),\n {\n onDone: resolve,\n onError: reject,\n },\n );\n }));\n\n it(\"should end in an error if getAppAndVersion actor throws an error\", () =>\n new Promise<void>((resolve, reject) => {\n getDeviceSessionStateMock.mockReturnValue({\n sessionStateType: DeviceSessionStateType.ReadyWithoutSecureChannel,\n deviceStatus: DeviceStatus.LOCKED,\n currentApp: { name: \"mockedCurrentApp\", version: \"1.0.0\" },\n });\n\n getAppAndVersionMock.mockImplementation(() => {\n throw new UnknownDAError(\"error\");\n });\n\n waitForDeviceUnlockMock.mockImplementation(\n () =>\n new Observable((o) => {\n o.complete();\n }),\n );\n\n const getDeviceStateDeviceAction = new GetDeviceStatusDeviceAction({\n input: { unlockTimeout: 500 },\n });\n\n vi.spyOn(\n getDeviceStateDeviceAction,\n \"extractDependencies\",\n ).mockReturnValue(extractDependenciesMock());\n\n const expectedStates: Array<GetDeviceStatusDAState> = [\n {\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.None,\n step: getDeviceStatusDAStateStep.ONBOARD_CHECK,\n },\n status: DeviceActionStatus.Pending,\n },\n {\n error: new UnknownDAError(\"error\"),\n status: DeviceActionStatus.Error,\n },\n ];\n\n testDeviceActionStates(\n getDeviceStateDeviceAction,\n expectedStates,\n makeDeviceActionInternalApiMock(),\n {\n onDone: resolve,\n onError: reject,\n },\n );\n }));\n });\n\n it(\"should emit a stopped state if the action is cancelled\", () =>\n new Promise<void>((resolve, reject) => {\n apiGetDeviceSessionStateMock.mockReturnValue({\n sessionStateType: DeviceSessionStateType.ReadyWithoutSecureChannel,\n deviceStatus: DeviceStatus.CONNECTED,\n currentApp: { name: \"mockedCurrentApp\", version: \"1.0.0\" },\n installedApps: [],\n deviceModelId: DeviceModelId.NANO_X,\n isSecureConnectionAllowed: false,\n });\n\n sendCommandMock.mockResolvedValue(\n CommandResultFactory({\n data: {\n name: \"BOLOS\",\n version: \"1.0.0\",\n },\n }),\n );\n\n const getDeviceStateDeviceAction = new GetDeviceStatusDeviceAction({\n input: { unlockTimeout: 500 },\n });\n\n const expectedStates: Array<GetDeviceStatusDAState> = [\n {\n status: DeviceActionStatus.Pending, // get app and version\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.None,\n step: getDeviceStatusDAStateStep.ONBOARD_CHECK,\n },\n },\n {\n status: DeviceActionStatus.Stopped,\n },\n ];\n\n const { cancel } = testDeviceActionStates(\n getDeviceStateDeviceAction,\n expectedStates,\n makeDeviceActionInternalApiMock(),\n {\n onDone: resolve,\n onError: reject,\n },\n );\n cancel();\n }));\n});\n"],
5
+ "mappings": "AAAA,OAAS,YAAAA,EAAU,cAAAC,MAAkB,OAErC,OAAS,wBAAAC,MAA4B,mCACrC,OACE,iBAAAC,EACA,sBAAAC,MACK,wCACP,OAAS,iBAAAC,MAAqB,0BAC9B,OAAS,gBAAAC,MAAoB,2BAC7B,OAAS,mCAAAC,MAAuC,oDAChD,OAAS,0BAAAC,MAA8B,2DACvC,OAAS,sBAAAC,MAA0B,6CACnC,OAAS,2BAAAC,MAA+B,mDACxC,OACE,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OAC7B,CACF,EAEM,CAAE,OAAAyB,CAAO,EAAI1B,EACjBoB,EACAC,EACAtB,EAAgC,EAChC,CACE,OAAQmB,EACR,QAASC,CACX,CACF,EACAO,EAAO,CACT,CAAC,CAAC,CACN,CAAC",
6
+ "names": ["interval", "Observable", "CommandResultFactory", "GLOBAL_ERRORS", "GlobalCommandError", "DeviceModelId", "DeviceStatus", "makeDeviceActionInternalApiMock", "testDeviceActionStates", "DeviceActionStatus", "UserInteractionRequired", "DeviceLockedError", "DeviceNotOnboardedError", "UnknownDAError", "DeviceSessionStateType", "GetDeviceStatusDeviceAction", "getDeviceStatusDAStateStep", "getAppAndVersionMock", "getDeviceSessionStateMock", "waitForDeviceUnlockMock", "setDeviceSessionState", "isDeviceOnboardedMock", "extractDependenciesMock", "sendCommandMock", "apiGetDeviceSessionStateMock", "apiGetDeviceSessionStateObservableMock", "resolve", "reject", "getDeviceStateDeviceAction", "expectedStates", "o", "inner", "i", "error", "cancel"]
7
7
  }
@@ -1 +1,2 @@
1
+ const e=Object.freeze({ONBOARD_CHECK:"os.getDeviceStatus.steps.onboardCheck",UNLOCK_DEVICE:"os.getDeviceStatus.steps.unlockDevice"});export{e as getDeviceStatusDAStateStep};
1
2
  //# sourceMappingURL=types.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
- "sources": [],
4
- "sourcesContent": [],
5
- "mappings": "",
6
- "names": []
3
+ "sources": ["../../../../../../../src/api/device-action/os/GetDeviceStatus/types.ts"],
4
+ "sourcesContent": ["import { type CommandErrorResult } from \"@api/command/model/CommandResult\";\nimport { type DeviceActionState } from \"@api/device-action/model/DeviceActionState\";\nimport { type UserInteractionRequired } from \"@api/device-action/model/UserInteractionRequired\";\nimport {\n type DeviceLockedError,\n type DeviceNotOnboardedError,\n type UnknownDAError,\n} from \"@api/device-action/os/Errors\";\n\nexport const getDeviceStatusDAStateStep = Object.freeze({\n ONBOARD_CHECK: \"os.getDeviceStatus.steps.onboardCheck\",\n UNLOCK_DEVICE: \"os.getDeviceStatus.steps.unlockDevice\",\n} as const);\n\nexport type GetDeviceStatusDAStateStep =\n (typeof getDeviceStatusDAStateStep)[keyof typeof getDeviceStatusDAStateStep];\n\nexport type GetDeviceStatusDAOutput = {\n readonly currentApp: string;\n readonly currentAppVersion: string;\n};\nexport type GetDeviceStatusDAInput = {\n readonly unlockTimeout?: number;\n};\n\nexport type GetDeviceStatusDAError =\n | DeviceNotOnboardedError\n | DeviceLockedError\n | UnknownDAError\n | CommandErrorResult[\"error\"];\n\nexport type GetDeviceStatusDARequiredInteraction =\n | UserInteractionRequired.None\n | UserInteractionRequired.UnlockDevice;\n\nexport type GetDeviceStatusDAIntermediateValue = {\n requiredUserInteraction: GetDeviceStatusDARequiredInteraction;\n step: GetDeviceStatusDAStateStep;\n};\n\nexport type GetDeviceStatusDAState = DeviceActionState<\n GetDeviceStatusDAOutput,\n GetDeviceStatusDAError,\n GetDeviceStatusDAIntermediateValue\n>;\n"],
5
+ "mappings": "AASO,MAAMA,EAA6B,OAAO,OAAO,CACtD,cAAe,wCACf,cAAe,uCACjB,CAAU",
6
+ "names": ["getDeviceStatusDAStateStep"]
7
7
  }
@@ -1,2 +1,2 @@
1
- import{Left as D,Right as l}from"purify-ts";import{assign as n,fromPromise as p,setup as S}from"xstate";import{isSuccessCommandResult as c}from"../../../command/model/CommandResult";import{CloseAppCommand as A}from"../../../command/os/CloseAppCommand";import{GetAppAndVersionCommand as m}from"../../../command/os/GetAppAndVersionCommand";import{UserInteractionRequired as h}from"../../../device-action/model/UserInteractionRequired";import{DEFAULT_UNLOCK_TIMEOUT_MS as v}from"../../../device-action/os/Const";import{UnknownDAError as y}from"../../../device-action/os/Errors";import{GetDeviceStatusDeviceAction as g}from"../../../device-action/os/GetDeviceStatus/GetDeviceStatusDeviceAction";import{XStateDeviceAction as T}from"../../../device-action/xstate-utils/XStateDeviceAction";import{DeviceSessionStateType as G}from"../../../device-session/DeviceSessionState";import{isDashboardName as b}from"../../../utils/AppName";class L extends T{makeStateMachine(r){const{getDeviceSessionState:o,setDeviceSessionState:s,closeApp:a,getAppAndVersion:u}=this.extractDependencies(r),i=this.input.unlockTimeout??v,d=new g({input:{unlockTimeout:i}}).makeStateMachine(r);return S({types:{input:{unlockTimeout:i},context:{},output:{}},actors:{getAppAndVersion:p(u),closeApp:p(a),getDeviceStatus:d},guards:{hasError:({context:e})=>e._internalState.error!==null,isDashboardOpen:({context:e})=>e._internalState.currentApp!==null&&b(e._internalState.currentApp)},actions:{assignErrorFromEvent:n({_internalState:e=>({...e.context._internalState,error:e.event.error})})}}).createMachine({id:"GoToDashboardDeviceAction",initial:"DeviceReady",context:e=>{const t=o();return{input:{unlockTimeout:e.input.unlockTimeout},intermediateValue:{requiredUserInteraction:h.None},_internalState:{currentApp:"currentApp"in t?t.currentApp.name:null,error:null}}},states:{DeviceReady:{always:{target:"GetDeviceStatus"}},GetDeviceStatus:{invoke:{id:"deviceStatus",src:"getDeviceStatus",input:e=>({unlockTimeout:e.context.input.unlockTimeout}),onSnapshot:{actions:n({intermediateValue:e=>e.event.snapshot.context.intermediateValue})},onDone:{target:"CheckDeviceStatus",actions:n({_internalState:e=>e.event.output.caseOf({Right:t=>({...e.context._internalState,currentApp:t.currentApp}),Left:t=>({...e.context._internalState,error:t})})})}}},CheckDeviceStatus:{always:[{target:"Error",guard:"hasError"},{target:"DashboardCheck"}]},DashboardCheck:{always:[{target:"Success",guard:"isDashboardOpen"},{target:"Error",guard:"hasError"},{target:"Error",guard:e=>e.context._internalState.currentApp===null,actions:n({_internalState:e=>({...e.context._internalState,error:new y("currentApp === null")})})},{target:"CloseApp"}]},CloseApp:{invoke:{src:"closeApp",onDone:{target:"CloseAppCheck",actions:n({_internalState:e=>c(e.event.output)?e.context._internalState:{...e.context._internalState,error:e.event.output.error}})},onError:{target:"Error",actions:"assignErrorFromEvent"}}},CloseAppCheck:{always:[{target:"Error",guard:"hasError"},{target:"GetAppAndVersion",reenter:!0}]},GetAppAndVersion:{invoke:{src:"getAppAndVersion",onDone:{target:"DashboardCheck",actions:n({_internalState:e=>{if(c(e.event.output)){const t=o();return t.sessionStateType!==G.Connected&&s({...t,currentApp:e.event.output.data}),{...e.context._internalState,currentApp:e.event.output.data.name}}return{...e.context._internalState,error:e.event.output.error}}})}}},Success:{type:"final"},Error:{type:"final"}},output:e=>e.context._internalState.error?D(e.context._internalState.error):l(void 0)})}extractDependencies(r){return{closeApp:async()=>r.sendCommand(new A),getAppAndVersion:async()=>r.sendCommand(new m),getDeviceSessionState:()=>r.getDeviceSessionState(),setDeviceSessionState:a=>r.setDeviceSessionState(a)}}}export{L as GoToDashboardDeviceAction};
1
+ import{Left as S,Right as A}from"purify-ts";import{assign as n,fromPromise as u,setup as m}from"xstate";import{isSuccessCommandResult as d}from"../../../command/model/CommandResult";import{CloseAppCommand as h}from"../../../command/os/CloseAppCommand";import{GetAppAndVersionCommand as v}from"../../../command/os/GetAppAndVersionCommand";import{UserInteractionRequired as o}from"../../../device-action/model/UserInteractionRequired";import{DEFAULT_UNLOCK_TIMEOUT_MS as y}from"../../../device-action/os/Const";import{UnknownDAError as T}from"../../../device-action/os/Errors";import{GetDeviceStatusDeviceAction as g}from"../../../device-action/os/GetDeviceStatus/GetDeviceStatusDeviceAction";import{XStateDeviceAction as G}from"../../../device-action/xstate-utils/XStateDeviceAction";import{DeviceSessionStateType as b}from"../../../device-session/DeviceSessionState";import{isDashboardName as C}from"../../../utils/AppName";import{goToDashboardDAStateStep as a}from"./types";class q extends G{makeStateMachine(r){const{getDeviceSessionState:s,setDeviceSessionState:p,closeApp:i,getAppAndVersion:D}=this.extractDependencies(r),c=this.input.unlockTimeout??y,l=new g({input:{unlockTimeout:c}}).makeStateMachine(r);return m({types:{input:{unlockTimeout:c},context:{},output:{}},actors:{getAppAndVersion:u(D),closeApp:u(i),getDeviceStatus:l},guards:{hasError:({context:e})=>e._internalState.error!==null,isDashboardOpen:({context:e})=>e._internalState.currentApp!==null&&C(e._internalState.currentApp)},actions:{assignErrorFromEvent:n({_internalState:e=>({...e.context._internalState,error:e.event.error})})}}).createMachine({id:"GoToDashboardDeviceAction",initial:"DeviceReady",context:e=>{const t=s();return{input:{unlockTimeout:e.input.unlockTimeout},intermediateValue:{requiredUserInteraction:o.None,step:a.GET_DEVICE_STATUS},_internalState:{currentApp:"currentApp"in t?t.currentApp.name:null,error:null}}},states:{DeviceReady:{always:{target:"GetDeviceStatus"}},GetDeviceStatus:{invoke:{id:"deviceStatus",src:"getDeviceStatus",input:e=>({unlockTimeout:e.context.input.unlockTimeout}),onSnapshot:{actions:n({intermediateValue:e=>e.event.snapshot.context.intermediateValue})},onDone:{target:"CheckDeviceStatus",actions:n({_internalState:e=>e.event.output.caseOf({Right:t=>({...e.context._internalState,currentApp:t.currentApp}),Left:t=>({...e.context._internalState,error:t})})})}}},CheckDeviceStatus:{always:[{target:"Error",guard:"hasError"},{target:"DashboardCheck"}]},DashboardCheck:{always:[{target:"Success",guard:"isDashboardOpen"},{target:"Error",guard:"hasError"},{target:"Error",guard:e=>e.context._internalState.currentApp===null,actions:n({_internalState:e=>({...e.context._internalState,error:new T("currentApp === null")}),intermediateValue:e=>({requiredUserInteraction:o.None,step:a.DASHBOARD_CHECK})})},{target:"CloseApp"}]},CloseApp:{invoke:{src:"closeApp",onDone:{target:"CloseAppCheck",actions:n({_internalState:e=>d(e.event.output)?e.context._internalState:{...e.context._internalState,error:e.event.output.error},intermediateValue:e=>({requiredUserInteraction:o.None,step:a.CLOSE_APP})})},onError:{target:"Error",actions:"assignErrorFromEvent"}}},CloseAppCheck:{always:[{target:"Error",guard:"hasError"},{target:"GetAppAndVersion",reenter:!0}]},GetAppAndVersion:{invoke:{src:"getAppAndVersion",onDone:{target:"DashboardCheck",actions:n({_internalState:e=>{if(d(e.event.output)){const t=s();return t.sessionStateType!==b.Connected&&p({...t,currentApp:e.event.output.data}),{...e.context._internalState,currentApp:e.event.output.data.name}}return{...e.context._internalState,error:e.event.output.error}},intermediateValue:e=>({requiredUserInteraction:o.None,step:a.CONFIRM_DASHBOARD_OPEN})})}}},Success:{type:"final"},Error:{type:"final"}},output:e=>e.context._internalState.error?S(e.context._internalState.error):A(void 0)})}extractDependencies(r){return{closeApp:async()=>r.sendCommand(new h),getAppAndVersion:async()=>r.sendCommand(new v),getDeviceSessionState:()=>r.getDeviceSessionState(),setDeviceSessionState:i=>r.setDeviceSessionState(i)}}}export{q as GoToDashboardDeviceAction};
2
2
  //# sourceMappingURL=GoToDashboardDeviceAction.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../../../../src/api/device-action/os/GoToDashboard/GoToDashboardDeviceAction.ts"],
4
- "sourcesContent": ["import { Left, Right } from \"purify-ts\";\nimport { assign, fromPromise, setup } from \"xstate\";\n\nimport { isSuccessCommandResult } from \"@api/command/model/CommandResult\";\nimport {\n CloseAppCommand,\n type CloseAppCommandResult,\n} from \"@api/command/os/CloseAppCommand\";\nimport {\n GetAppAndVersionCommand,\n type GetAppAndVersionCommandResult,\n} from \"@api/command/os/GetAppAndVersionCommand\";\nimport { type InternalApi } from \"@api/device-action/DeviceAction\";\nimport { UserInteractionRequired } from \"@api/device-action/model/UserInteractionRequired\";\nimport { DEFAULT_UNLOCK_TIMEOUT_MS } from \"@api/device-action/os/Const\";\nimport { UnknownDAError } from \"@api/device-action/os/Errors\";\nimport { GetDeviceStatusDeviceAction } from \"@api/device-action/os/GetDeviceStatus/GetDeviceStatusDeviceAction\";\nimport { type StateMachineTypes } from \"@api/device-action/xstate-utils/StateMachineTypes\";\nimport {\n type DeviceActionStateMachine,\n XStateDeviceAction,\n} from \"@api/device-action/xstate-utils/XStateDeviceAction\";\nimport {\n type DeviceSessionState,\n DeviceSessionStateType,\n} from \"@api/device-session/DeviceSessionState\";\nimport { isDashboardName } from \"@api/utils/AppName\";\n\nimport type {\n GoToDashboardDAError,\n GoToDashboardDAInput,\n GoToDashboardDAIntermediateValue,\n GoToDashboardDAOutput,\n} from \"./types\";\n\ntype GoToDashboardMachineInternalState = {\n readonly currentApp: string | null;\n readonly error: GoToDashboardDAError | null;\n};\n\nexport type MachineDependencies = {\n readonly getAppAndVersion: () => Promise<GetAppAndVersionCommandResult>;\n readonly closeApp: () => Promise<CloseAppCommandResult>;\n readonly getDeviceSessionState: () => DeviceSessionState;\n readonly setDeviceSessionState: (\n state: DeviceSessionState,\n ) => DeviceSessionState;\n};\n\nexport type ExtractMachineDependencies = (\n internalApi: InternalApi,\n) => MachineDependencies;\n\nexport class GoToDashboardDeviceAction extends XStateDeviceAction<\n GoToDashboardDAOutput,\n GoToDashboardDAInput,\n GoToDashboardDAError,\n GoToDashboardDAIntermediateValue,\n GoToDashboardMachineInternalState\n> {\n makeStateMachine(\n internalApi: InternalApi,\n ): DeviceActionStateMachine<\n GoToDashboardDAOutput,\n GoToDashboardDAInput,\n GoToDashboardDAError,\n GoToDashboardDAIntermediateValue,\n GoToDashboardMachineInternalState\n > {\n type types = StateMachineTypes<\n GoToDashboardDAOutput,\n GoToDashboardDAInput,\n GoToDashboardDAError,\n GoToDashboardDAIntermediateValue,\n GoToDashboardMachineInternalState\n >;\n\n const {\n getDeviceSessionState,\n setDeviceSessionState,\n closeApp,\n getAppAndVersion,\n } = this.extractDependencies(internalApi);\n\n const unlockTimeout = this.input.unlockTimeout ?? DEFAULT_UNLOCK_TIMEOUT_MS;\n\n const getDeviceStatusMachine = new GetDeviceStatusDeviceAction({\n input: {\n unlockTimeout,\n },\n }).makeStateMachine(internalApi);\n return setup({\n types: {\n input: {\n unlockTimeout,\n } as types[\"input\"],\n context: {} as types[\"context\"],\n output: {} as types[\"output\"],\n },\n actors: {\n getAppAndVersion: fromPromise(getAppAndVersion),\n closeApp: fromPromise(closeApp),\n getDeviceStatus: getDeviceStatusMachine,\n },\n guards: {\n hasError: ({ context }: { context: types[\"context\"] }) => {\n return context._internalState.error !== null;\n },\n isDashboardOpen: ({ context }: { context: types[\"context\"] }) =>\n context._internalState.currentApp !== null &&\n isDashboardName(context._internalState.currentApp),\n },\n actions: {\n // assignGetDeviceStatusUnknownError: assign({\n // _internalState: (_) => ({\n // ..._.context._internalState,\n // error: new UnknownDAError(\"GetDeviceUnknownStatusError\"),\n // }),\n // }),\n assignErrorFromEvent: assign({\n _internalState: (_) => ({\n ..._.context._internalState,\n error: _.event[\"error\"], // NOTE: it should never happen, the error is not typed anymore here\n }),\n }),\n },\n }).createMachine({\n /** @xstate-layout N4IgpgJg5mDOIC5QHED2AVVARAhrAFgEao4BOEWYAbgJYDGYAgnQC42oB2AdJbQwEpgcEAJ4BiANoAGALqJQAB1SwabTvJAAPRAHYAjFwDMATikA2MwA5DOnQBYArGeOGANCBGI9VrlcvmpRyknQwcAXzD3NExcAmIyCmp6JlZ2bmQwFl5kgGUWHBYAV1gxCE4wLhoOKlQAawqIJIY8guLpOSQQJRU1Dg1tBAAmOy49QYcpHQdBvR0pMcszO3dPBEM7My4HYz1pqWNLPRsdJYiojGw8IhJybIZmXq4AYXwwOlq7sBaikvaNbtUaX6iDsgy2g3Wdksjn8JlBDhWiAchk2OkMgysB2RzlBZxA0UucRuiT4KUeLzeHyaX3yP0keg6imUgPUnQGgxmo3hdkcemMwwcG0RCGxXDRGMsWJRxlxkXxF1i1wSnweaR4V3i5Ap70ksn+zN6wIQfMsYsG0LMg2MZlm60mwucDi4HMli0GgX0zjxBMVmpJyVVnHVRIS2tq9MZXQNQLZII5XEcoQx5kO3mWHkQjud5oOlo93mM3oVGuJKtSQd9xLDkkGkYBhtjCEtxi41h5fJs+ysOgdOjBE2Gw1sUmC5qLMRLyupge4ldDrx1EkMdejrNAA2sTu8jsO0Lsej5wr7prsoTGs2CJz748JStu0-L3CeABtlEwFApSuVKtU6hUfZO96kjOzyvrA74KAgVQ1HQBRpO0fydPWMbrl4kwGFMzizMYcyCsK-gjE4OiWBC-jGDK+g3nOQEBo+oFvowH5iGApCkKgpBcAoz4FAAZuxAC2XAASGNH3HRL4MR+UG-rBvQIXqSGrn0jaHGCNocoYko2BiUzCvymyadsdg6Dh+zTFRgH+mJ5JgRB1aIUyPQoVoaHEWKegjsYDgOGi9hjMKHmGAYdg7KCVhLOagoWSJVlkmqEngYxCj2Qy+pOWuLnGuMUhcNagoHMZgqhMYAVSEFCahRKEWWFFcrCXesUgRkLBJYwHAQAAaixKicF+HAVNBf5CcWMVlo8zWte1XWkD1HDSTBcGcPJK7pcpqEIARCZQsMqZSDM+7Cg4limjaXnbHMlhzIYERyhwqCNPAnT1X6Y3OchGUDAAtDKvj6NYgQohYljCsMRjzIYASTN2NjXXVI0Na9FbUoIwirI5LJrZloJcCOI52GVZihD5goIhmxoHq24OQycl02NFCMPuNmSfN8xRpRjRqfRsv16P9p4WFYIOGIYCYjgex1mD5oLrPTL2M-FC5UqSrOPejDbrbMraniZ+4nGV6J6OmqwbJsl3jPY2wQ2YaKy6W8sVpZYbs+rmUzDl4y84T7rBDyZgOvsWvqd4EI67bU7AeJtlJc7zkbnyYrBORxGaVCDh6PhhtGAcJjjPye3EWHolxUGCV2YrMcfWhFi5TyjgUYb9h+2TFG+GMIUhRyUy7IXjV0RNH5tZ13VvUpRpjOYYpBWZCxzOnZNHQZGweSR7qhDLcMTqN9vcDkhR0AwsCq1Gq1GhyIxWvsSYWMZ-I9mTJGEbXsx7Av4Qb7ecsR48ACirHsRXmMBjIi2JaRwEIDzeWtsDMmgUdCthwjadSaJFiWBumEIAA */\n id: \"GoToDashboardDeviceAction\",\n initial: \"DeviceReady\",\n context: (_) => {\n const sessionState = getDeviceSessionState();\n return {\n input: {\n unlockTimeout: _.input.unlockTimeout,\n },\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.None,\n },\n _internalState: {\n currentApp:\n \"currentApp\" in sessionState\n ? sessionState.currentApp.name\n : null,\n error: null,\n },\n };\n },\n states: {\n DeviceReady: {\n always: {\n target: \"GetDeviceStatus\",\n },\n },\n GetDeviceStatus: {\n // We run the GetDeviceStatus flow to get information about the device state\n invoke: {\n id: \"deviceStatus\",\n src: \"getDeviceStatus\",\n input: (_) => ({\n unlockTimeout: _.context.input.unlockTimeout,\n }),\n onSnapshot: {\n actions: assign({\n intermediateValue: (_) =>\n _.event.snapshot.context.intermediateValue,\n }),\n },\n onDone: {\n target: \"CheckDeviceStatus\",\n actions: assign({\n _internalState: (_) => {\n return _.event.output.caseOf<GoToDashboardMachineInternalState>(\n {\n Right: (output) => ({\n ..._.context._internalState,\n currentApp: output.currentApp,\n }),\n Left: (error) => ({\n ..._.context._internalState,\n error,\n }),\n },\n );\n },\n }),\n },\n // NOTE: The way we handle our DeviceActions means that we should never as we return an Either\n // onError: {\n // target: \"Error\",\n // actions: \"assignGetDeviceStatusUnknownError\",\n // },\n },\n },\n CheckDeviceStatus: {\n // We check the device status to see if we can have an error\n always: [\n {\n target: \"Error\",\n guard: \"hasError\",\n },\n {\n target: \"DashboardCheck\",\n },\n ],\n },\n DashboardCheck: {\n // We check if the dashboard is open\n always: [\n {\n target: \"Success\",\n guard: \"isDashboardOpen\",\n },\n {\n target: \"Error\",\n guard: \"hasError\",\n },\n {\n target: \"Error\",\n guard: (_) => {\n return _.context._internalState.currentApp === null;\n },\n actions: assign({\n _internalState: (_) => ({\n ..._.context._internalState,\n error: new UnknownDAError(\"currentApp === null\"),\n }),\n }),\n },\n {\n target: \"CloseApp\",\n },\n ],\n },\n CloseApp: {\n invoke: {\n src: \"closeApp\",\n onDone: {\n target: \"CloseAppCheck\",\n actions: assign({\n _internalState: (_) => {\n if (isSuccessCommandResult(_.event.output)) {\n return _.context._internalState;\n }\n return {\n ..._.context._internalState,\n error: _.event.output.error,\n };\n },\n }),\n },\n onError: {\n target: \"Error\",\n actions: \"assignErrorFromEvent\",\n },\n },\n },\n CloseAppCheck: {\n always: [\n {\n target: \"Error\",\n guard: \"hasError\",\n },\n {\n target: \"GetAppAndVersion\",\n reenter: true,\n },\n ],\n },\n GetAppAndVersion: {\n invoke: {\n src: \"getAppAndVersion\",\n onDone: {\n target: \"DashboardCheck\",\n actions: assign({\n _internalState: (_) => {\n if (isSuccessCommandResult(_.event.output)) {\n const state: DeviceSessionState = getDeviceSessionState();\n // Narrow the type to ReadyWithoutSecureChannelState or ReadyWithSecureChannelState\n if (\n state.sessionStateType !==\n DeviceSessionStateType.Connected\n ) {\n setDeviceSessionState({\n ...state,\n currentApp: _.event.output.data,\n });\n }\n return {\n ..._.context._internalState,\n currentApp: _.event.output.data.name,\n };\n }\n return {\n ..._.context._internalState,\n error: _.event.output.error,\n };\n },\n }),\n },\n },\n },\n Success: {\n type: \"final\",\n },\n Error: {\n type: \"final\",\n },\n },\n output: (_) => {\n if (_.context._internalState.error) {\n return Left(_.context._internalState.error);\n }\n\n return Right(undefined);\n },\n });\n }\n\n extractDependencies(internalApi: InternalApi): MachineDependencies {\n const closeApp = async () => internalApi.sendCommand(new CloseAppCommand());\n const getAppAndVersion = async () =>\n internalApi.sendCommand(new GetAppAndVersionCommand());\n\n return {\n closeApp,\n getAppAndVersion,\n getDeviceSessionState: () => internalApi.getDeviceSessionState(),\n setDeviceSessionState: (state: DeviceSessionState) =>\n internalApi.setDeviceSessionState(state),\n };\n }\n}\n"],
5
- "mappings": "AAAA,OAAS,QAAAA,EAAM,SAAAC,MAAa,YAC5B,OAAS,UAAAC,EAAQ,eAAAC,EAAa,SAAAC,MAAa,SAE3C,OAAS,0BAAAC,MAA8B,mCACvC,OACE,mBAAAC,MAEK,kCACP,OACE,2BAAAC,MAEK,0CAEP,OAAS,2BAAAC,MAA+B,mDACxC,OAAS,6BAAAC,MAAiC,8BAC1C,OAAS,kBAAAC,MAAsB,+BAC/B,OAAS,+BAAAC,MAAmC,oEAE5C,OAEE,sBAAAC,MACK,qDACP,OAEE,0BAAAC,MACK,yCACP,OAAS,mBAAAC,MAAuB,qBA2BzB,MAAMC,UAAkCH,CAM7C,CACA,iBACEI,EAOA,CASA,KAAM,CACJ,sBAAAC,EACA,sBAAAC,EACA,SAAAC,EACA,iBAAAC,CACF,EAAI,KAAK,oBAAoBJ,CAAW,EAElCK,EAAgB,KAAK,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CAAC,EAEI,CACL,GAAGA,EAAE,QAAQ,eACb,WAAYA,EAAE,MAAM,OAAO,KAAK,IAClC,CACF,CACA,MAAO,CACL,GAAGA,EAAE,QAAQ,eACb,MAAOA,EAAE,MAAM,OAAO,KACxB,CACF,CACF,CAAC,CACH,CACF,CACF,EACA,QAAS,CACP,KAAM,OACR,EACA,MAAO,CACL,KAAM,OACR,CACF,EACA,OAASA,GACHA,EAAE,QAAQ,eAAe,MACpBxB,EAAKwB,EAAE,QAAQ,eAAe,KAAK,EAGrCvB,EAAM,MAAS,CAE1B,CAAC,CACH,CAEA,oBAAoBe,EAA+C,CAKjE,MAAO,CACL,SALe,SAAYA,EAAY,YAAY,IAAIV,CAAiB,EAMxE,iBALuB,SACvBU,EAAY,YAAY,IAAIT,CAAyB,EAKrD,sBAAuB,IAAMS,EAAY,sBAAsB,EAC/D,sBAAwBY,GACtBZ,EAAY,sBAAsBY,CAAK,CAC3C,CACF,CACF",
6
- "names": ["Left", "Right", "assign", "fromPromise", "setup", "isSuccessCommandResult", "CloseAppCommand", "GetAppAndVersionCommand", "UserInteractionRequired", "DEFAULT_UNLOCK_TIMEOUT_MS", "UnknownDAError", "GetDeviceStatusDeviceAction", "XStateDeviceAction", "DeviceSessionStateType", "isDashboardName", "GoToDashboardDeviceAction", "internalApi", "getDeviceSessionState", "setDeviceSessionState", "closeApp", "getAppAndVersion", "unlockTimeout", "getDeviceStatusMachine", "context", "_", "sessionState", "output", "error", "state"]
4
+ "sourcesContent": ["import { Left, Right } from \"purify-ts\";\nimport { assign, fromPromise, setup } from \"xstate\";\n\nimport { isSuccessCommandResult } from \"@api/command/model/CommandResult\";\nimport {\n CloseAppCommand,\n type CloseAppCommandResult,\n} from \"@api/command/os/CloseAppCommand\";\nimport {\n GetAppAndVersionCommand,\n type GetAppAndVersionCommandResult,\n} from \"@api/command/os/GetAppAndVersionCommand\";\nimport { type InternalApi } from \"@api/device-action/DeviceAction\";\nimport { UserInteractionRequired } from \"@api/device-action/model/UserInteractionRequired\";\nimport { DEFAULT_UNLOCK_TIMEOUT_MS } from \"@api/device-action/os/Const\";\nimport { UnknownDAError } from \"@api/device-action/os/Errors\";\nimport { GetDeviceStatusDeviceAction } from \"@api/device-action/os/GetDeviceStatus/GetDeviceStatusDeviceAction\";\nimport { type StateMachineTypes } from \"@api/device-action/xstate-utils/StateMachineTypes\";\nimport {\n type DeviceActionStateMachine,\n XStateDeviceAction,\n} from \"@api/device-action/xstate-utils/XStateDeviceAction\";\nimport {\n type DeviceSessionState,\n DeviceSessionStateType,\n} from \"@api/device-session/DeviceSessionState\";\nimport { isDashboardName } from \"@api/utils/AppName\";\n\nimport {\n type GoToDashboardDAError,\n type GoToDashboardDAInput,\n type GoToDashboardDAIntermediateValue,\n type GoToDashboardDAOutput,\n goToDashboardDAStateStep,\n} from \"./types\";\n\ntype GoToDashboardMachineInternalState = {\n readonly currentApp: string | null;\n readonly error: GoToDashboardDAError | null;\n};\n\nexport type MachineDependencies = {\n readonly getAppAndVersion: () => Promise<GetAppAndVersionCommandResult>;\n readonly closeApp: () => Promise<CloseAppCommandResult>;\n readonly getDeviceSessionState: () => DeviceSessionState;\n readonly setDeviceSessionState: (\n state: DeviceSessionState,\n ) => DeviceSessionState;\n};\n\nexport type ExtractMachineDependencies = (\n internalApi: InternalApi,\n) => MachineDependencies;\n\nexport class GoToDashboardDeviceAction extends XStateDeviceAction<\n GoToDashboardDAOutput,\n GoToDashboardDAInput,\n GoToDashboardDAError,\n GoToDashboardDAIntermediateValue,\n GoToDashboardMachineInternalState\n> {\n makeStateMachine(\n internalApi: InternalApi,\n ): DeviceActionStateMachine<\n GoToDashboardDAOutput,\n GoToDashboardDAInput,\n GoToDashboardDAError,\n GoToDashboardDAIntermediateValue,\n GoToDashboardMachineInternalState\n > {\n type types = StateMachineTypes<\n GoToDashboardDAOutput,\n GoToDashboardDAInput,\n GoToDashboardDAError,\n GoToDashboardDAIntermediateValue,\n GoToDashboardMachineInternalState\n >;\n\n const {\n getDeviceSessionState,\n setDeviceSessionState,\n closeApp,\n getAppAndVersion,\n } = this.extractDependencies(internalApi);\n\n const unlockTimeout = this.input.unlockTimeout ?? DEFAULT_UNLOCK_TIMEOUT_MS;\n\n const getDeviceStatusMachine = new GetDeviceStatusDeviceAction({\n input: {\n unlockTimeout,\n },\n }).makeStateMachine(internalApi);\n return setup({\n types: {\n input: {\n unlockTimeout,\n } as types[\"input\"],\n context: {} as types[\"context\"],\n output: {} as types[\"output\"],\n },\n actors: {\n getAppAndVersion: fromPromise(getAppAndVersion),\n closeApp: fromPromise(closeApp),\n getDeviceStatus: getDeviceStatusMachine,\n },\n guards: {\n hasError: ({ context }: { context: types[\"context\"] }) => {\n return context._internalState.error !== null;\n },\n isDashboardOpen: ({ context }: { context: types[\"context\"] }) =>\n context._internalState.currentApp !== null &&\n isDashboardName(context._internalState.currentApp),\n },\n actions: {\n // assignGetDeviceStatusUnknownError: assign({\n // _internalState: (_) => ({\n // ..._.context._internalState,\n // error: new UnknownDAError(\"GetDeviceUnknownStatusError\"),\n // }),\n // }),\n assignErrorFromEvent: assign({\n _internalState: (_) => ({\n ..._.context._internalState,\n error: _.event[\"error\"], // NOTE: it should never happen, the error is not typed anymore here\n }),\n }),\n },\n }).createMachine({\n /** @xstate-layout N4IgpgJg5mDOIC5QHED2AVVARAhrAFgEao4BOEWYAbgJYDGYAgnQC42oB2AdJbQwEpgcEAJ4BiANoAGALqJQAB1SwabTvJAAPRAHYAjFwDMATikA2MwA5DOnQBYArGeOGANCBGI9VrlcvmpRyknQwcAXzD3NExcAmIyCmp6JlZ2bmQwFl5kgGUWHBYAV1gxCE4wLhoOKlQAawqIJIY8guLpOSQQJRU1Dg1tBAAmOy49QYcpHQdBvR0pMcszO3dPBEM7My4HYz1pqWNLPRsdJYiojGw8IhJybIZmXq4AYXwwOlq7sBaikvaNbtUaX6iDsgy2g3Wdksjn8JlBDhWiAchk2OkMgysB2RzlBZxA0UucRuiT4KUeLzeHyaX3yP0keg6imUgPUnQGgx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hDLcMTqN9vcDkhR0AwsCq1Gq1GhyIxWvsSYWMZ-I9mTJGEbXsx7Av4Qb7ecsR48ACirHsRXmMBjIi2JaRwEIDzeWtsDMmgUdCthwjadSaJFiWBumEIAA */\n id: \"GoToDashboardDeviceAction\",\n initial: \"DeviceReady\",\n context: (_) => {\n const sessionState = getDeviceSessionState();\n return {\n input: {\n unlockTimeout: _.input.unlockTimeout,\n },\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.None,\n step: goToDashboardDAStateStep.GET_DEVICE_STATUS,\n },\n _internalState: {\n currentApp:\n \"currentApp\" in sessionState\n ? sessionState.currentApp.name\n : null,\n error: null,\n },\n };\n },\n states: {\n DeviceReady: {\n always: {\n target: \"GetDeviceStatus\",\n },\n },\n GetDeviceStatus: {\n // We run the GetDeviceStatus flow to get information about the device state\n invoke: {\n id: \"deviceStatus\",\n src: \"getDeviceStatus\",\n input: (_) => ({\n unlockTimeout: _.context.input.unlockTimeout,\n }),\n onSnapshot: {\n actions: assign({\n intermediateValue: (_) =>\n _.event.snapshot.context.intermediateValue,\n }),\n },\n onDone: {\n target: \"CheckDeviceStatus\",\n actions: assign({\n _internalState: (_) => {\n return _.event.output.caseOf<GoToDashboardMachineInternalState>(\n {\n Right: (output) => ({\n ..._.context._internalState,\n currentApp: output.currentApp,\n }),\n Left: (error) => ({\n ..._.context._internalState,\n error,\n }),\n },\n );\n },\n }),\n },\n // NOTE: The way we handle our DeviceActions means that we should never as we return an Either\n // onError: {\n // target: \"Error\",\n // actions: \"assignGetDeviceStatusUnknownError\",\n // },\n },\n },\n CheckDeviceStatus: {\n // We check the device status to see if we can have an error\n always: [\n {\n target: \"Error\",\n guard: \"hasError\",\n },\n {\n target: \"DashboardCheck\",\n },\n ],\n },\n DashboardCheck: {\n // We check if the dashboard is open\n always: [\n {\n target: \"Success\",\n guard: \"isDashboardOpen\",\n },\n {\n target: \"Error\",\n guard: \"hasError\",\n },\n {\n target: \"Error\",\n guard: (_) => {\n return _.context._internalState.currentApp === null;\n },\n actions: assign({\n _internalState: (_) => ({\n ..._.context._internalState,\n error: new UnknownDAError(\"currentApp === null\"),\n }),\n intermediateValue: (_) => ({\n requiredUserInteraction: UserInteractionRequired.None,\n step: goToDashboardDAStateStep.DASHBOARD_CHECK,\n }),\n }),\n },\n {\n target: \"CloseApp\",\n },\n ],\n },\n CloseApp: {\n invoke: {\n src: \"closeApp\",\n onDone: {\n target: \"CloseAppCheck\",\n actions: assign({\n _internalState: (_) => {\n if (isSuccessCommandResult(_.event.output)) {\n return _.context._internalState;\n }\n return {\n ..._.context._internalState,\n error: _.event.output.error,\n };\n },\n intermediateValue: (_) => ({\n requiredUserInteraction: UserInteractionRequired.None,\n step: goToDashboardDAStateStep.CLOSE_APP,\n }),\n }),\n },\n onError: {\n target: \"Error\",\n actions: \"assignErrorFromEvent\",\n },\n },\n },\n CloseAppCheck: {\n always: [\n {\n target: \"Error\",\n guard: \"hasError\",\n },\n {\n target: \"GetAppAndVersion\",\n reenter: true,\n },\n ],\n },\n GetAppAndVersion: {\n invoke: {\n src: \"getAppAndVersion\",\n onDone: {\n target: \"DashboardCheck\",\n actions: assign({\n _internalState: (_) => {\n if (isSuccessCommandResult(_.event.output)) {\n const state: DeviceSessionState = getDeviceSessionState();\n // Narrow the type to ReadyWithoutSecureChannelState or ReadyWithSecureChannelState\n if (\n state.sessionStateType !==\n DeviceSessionStateType.Connected\n ) {\n setDeviceSessionState({\n ...state,\n currentApp: _.event.output.data,\n });\n }\n return {\n ..._.context._internalState,\n currentApp: _.event.output.data.name,\n };\n }\n return {\n ..._.context._internalState,\n error: _.event.output.error,\n };\n },\n intermediateValue: (_) => ({\n requiredUserInteraction: UserInteractionRequired.None,\n step: goToDashboardDAStateStep.CONFIRM_DASHBOARD_OPEN,\n }),\n }),\n },\n },\n },\n Success: {\n type: \"final\",\n },\n Error: {\n type: \"final\",\n },\n },\n output: (_) => {\n if (_.context._internalState.error) {\n return Left(_.context._internalState.error);\n }\n\n return Right(undefined);\n },\n });\n }\n\n extractDependencies(internalApi: InternalApi): MachineDependencies {\n const closeApp = async () => internalApi.sendCommand(new CloseAppCommand());\n const getAppAndVersion = async () =>\n internalApi.sendCommand(new GetAppAndVersionCommand());\n\n return {\n closeApp,\n getAppAndVersion,\n getDeviceSessionState: () => internalApi.getDeviceSessionState(),\n setDeviceSessionState: (state: DeviceSessionState) =>\n internalApi.setDeviceSessionState(state),\n };\n }\n}\n"],
5
+ "mappings": "AAAA,OAAS,QAAAA,EAAM,SAAAC,MAAa,YAC5B,OAAS,UAAAC,EAAQ,eAAAC,EAAa,SAAAC,MAAa,SAE3C,OAAS,0BAAAC,MAA8B,mCACvC,OACE,mBAAAC,MAEK,kCACP,OACE,2BAAAC,MAEK,0CAEP,OAAS,2BAAAC,MAA+B,mDACxC,OAAS,6BAAAC,MAAiC,8BAC1C,OAAS,kBAAAC,MAAsB,+BAC/B,OAAS,+BAAAC,MAAmC,oEAE5C,OAEE,sBAAAC,MACK,qDACP,OAEE,0BAAAC,MACK,yCACP,OAAS,mBAAAC,MAAuB,qBAEhC,OAKE,4BAAAC,MACK,UAoBA,MAAMC,UAAkCJ,CAM7C,CACA,iBACEK,EAOA,CASA,KAAM,CACJ,sBAAAC,EACA,sBAAAC,EACA,SAAAC,EACA,iBAAAC,CACF,EAAI,KAAK,oBAAoBJ,CAAW,EAElCK,EAAgB,KAAK,MAAM,eAAiBb,EAE5Cc,EAAyB,IAAIZ,EAA4B,CAC7D,MAAO,CACL,cAAAW,CACF,CACF,CAAC,EAAE,iBAAiBL,CAAW,EAC/B,OAAOb,EAAM,CACX,MAAO,CACL,MAAO,CACL,cAAAkB,CACF,EACA,QAAS,CAAC,EACV,OAAQ,CAAC,CACX,EACA,OAAQ,CACN,iBAAkBnB,EAAYkB,CAAgB,EAC9C,SAAUlB,EAAYiB,CAAQ,EAC9B,gBAAiBG,CACnB,EACA,OAAQ,CACN,SAAU,CAAC,CAAE,QAAAC,CAAQ,IACZA,EAAQ,eAAe,QAAU,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EAAyB,sBACjC,EACF,CAAC,CACH,CACF,CACF,EACA,QAAS,CACP,KAAM,OACR,EACA,MAAO,CACL,KAAM,OACR,CACF,EACA,OAASU,GACHA,EAAE,QAAQ,eAAe,MACpBzB,EAAKyB,EAAE,QAAQ,eAAe,KAAK,EAGrCxB,EAAM,MAAS,CAE1B,CAAC,CACH,CAEA,oBAAoBgB,EAA+C,CAKjE,MAAO,CACL,SALe,SAAYA,EAAY,YAAY,IAAIX,CAAiB,EAMxE,iBALuB,SACvBW,EAAY,YAAY,IAAIV,CAAyB,EAKrD,sBAAuB,IAAMU,EAAY,sBAAsB,EAC/D,sBAAwBY,GACtBZ,EAAY,sBAAsBY,CAAK,CAC3C,CACF,CACF",
6
+ "names": ["Left", "Right", "assign", "fromPromise", "setup", "isSuccessCommandResult", "CloseAppCommand", "GetAppAndVersionCommand", "UserInteractionRequired", "DEFAULT_UNLOCK_TIMEOUT_MS", "UnknownDAError", "GetDeviceStatusDeviceAction", "XStateDeviceAction", "DeviceSessionStateType", "isDashboardName", "goToDashboardDAStateStep", "GoToDashboardDeviceAction", "internalApi", "getDeviceSessionState", "setDeviceSessionState", "closeApp", "getAppAndVersion", "unlockTimeout", "getDeviceStatusMachine", "context", "_", "sessionState", "output", "error", "state"]
7
7
  }
@@ -1,2 +1,2 @@
1
- import{CommandResultFactory as a}from"../../../command/model/CommandResult";import{GLOBAL_ERRORS as g,GlobalCommandError as C}from"../../../command/utils/GlobalCommandError";import{DeviceModelId as V}from"../../../device/DeviceModel";import{DeviceStatus as c}from"../../../device/DeviceStatus";import{makeDeviceActionInternalApiMock as s}from"../../../device-action/__test-utils__/makeInternalApi";import{setupGetDeviceStatusMock as d}from"../../../device-action/__test-utils__/setupTestMachine";import{testDeviceActionStates as u}from"../../../device-action/__test-utils__/testDeviceActionStates";import{DeviceActionStatus as e}from"../../../device-action/model/DeviceActionState";import{UserInteractionRequired as t}from"../../../device-action/model/UserInteractionRequired";import{UnknownDAError as h}from"../../../device-action/os/Errors";import{DeviceSessionStateType as p}from"../../../device-session/DeviceSessionState";import{UnknownDeviceExchangeError as k}from"../../../../../src";import{GoToDashboardDeviceAction as l}from"./GoToDashboardDeviceAction";vi.mock("@api/device-action/os/GetDeviceStatus/GetDeviceStatusDeviceAction");describe("GoToDashboardDeviceAction",()=>{const v=vi.fn(),D=vi.fn(),m=vi.fn(),N=vi.fn();function A(){return{closeApp:v,getAppAndVersion:D,getDeviceSessionState:m,setDeviceSessionState:N}}const{sendCommand:T,getDeviceSessionState:S}=s();beforeEach(()=>{vi.resetAllMocks()}),describe("without overriding `extractDependencies`",()=>{it("should run the device action with device already on dashboard",()=>new Promise((r,i)=>{d();const n=new l({input:{unlockTimeout:500}});S.mockReturnValue({sessionStateType:p.ReadyWithoutSecureChannel,deviceStatus:c.CONNECTED,currentApp:{name:"BOLOS",version:"1.5.0"},installedApps:[],deviceModelId:V.NANO_X,isSecureConnectionAllowed:!1});const o=[{intermediateValue:{requiredUserInteraction:t.None},status:e.Pending},{intermediateValue:{requiredUserInteraction:t.None},status:e.Pending},{output:void 0,status:e.Completed}];u(n,o,s(),{onDone:r,onError:i})})),it("should run the device action with device not on dashboard",()=>new Promise((r,i)=>{d([{currentApp:"Bitcoin",currentAppVersion:"1.0.0"}]);const n=new l({input:{unlockTimeout:500}});S.mockReturnValue({sessionStateType:p.ReadyWithoutSecureChannel,deviceStatus:c.CONNECTED,currentApp:{name:"Bitcoin",version:"1.0.0"},installedApps:[],deviceModelId:V.NANO_X,isSecureConnectionAllowed:!1}),T.mockResolvedValueOnce(a({data:void 0})).mockResolvedValueOnce(a({data:{name:"BOLOS",version:"1.5.0"}}));const o=[{intermediateValue:{requiredUserInteraction:t.None},status:e.Pending},{intermediateValue:{requiredUserInteraction:t.None},status:e.Pending},{intermediateValue:{requiredUserInteraction:t.None},status:e.Pending},{intermediateValue:{requiredUserInteraction:t.None},status:e.Pending},{output:void 0,status:e.Completed}];u(n,o,s(),{onDone:r,onError:i})}))}),describe("success cases",()=>{it("should success if the device is already on dashboard",()=>new Promise((r,i)=>{d();const n=new l({input:{unlockTimeout:500}});m.mockReturnValue({sessionStateType:p.Connected,deviceStatus:c.CONNECTED,currentApp:{name:"BOLOS",version:"1.5.0"}}),D.mockReturnValue({app:"BOLOS",version:"1.5.0"}),vi.spyOn(n,"extractDependencies").mockReturnValue(A());const o=[{intermediateValue:{requiredUserInteraction:t.None},status:e.Pending},{intermediateValue:{requiredUserInteraction:t.None},status:e.Pending},{output:void 0,status:e.Completed}];u(n,o,s(),{onDone:r,onError:i})})),it("should success if the device is not on dashboard",()=>new Promise((r,i)=>{d();const n=new l({input:{unlockTimeout:500}});vi.spyOn(n,"extractDependencies").mockReturnValue(A()),m.mockReturnValue({sessionStateType:p.Connected,deviceStatus:c.CONNECTED}),v.mockResolvedValue(a({data:void 0})),D.mockReturnValue(a({data:{name:"BOLOS",version:"1.5.0"}}));const o=[{intermediateValue:{requiredUserInteraction:t.None},status:e.Pending},{intermediateValue:{requiredUserInteraction:t.None},status:e.Pending},{output:void 0,status:e.Completed}];u(n,o,s(),{onDone:r,onError:i})}))}),describe("error cases",()=>{it("should return an error if GetDeviceStatus return an error",()=>new Promise((r,i)=>{d([new h("Unknown error")]);const n=new l({input:{unlockTimeout:500}});S.mockReturnValue({sessionStateType:p.ReadyWithoutSecureChannel,deviceStatus:c.CONNECTED,currentApp:{name:"BOLOS",version:"1.5.0"},installedApps:[],deviceModelId:V.NANO_X,isSecureConnectionAllowed:!1});const o=[{intermediateValue:{requiredUserInteraction:t.None},status:e.Pending},{intermediateValue:{requiredUserInteraction:t.None},status:e.Pending},{status:e.Error,error:new h("Unknown error")}];u(n,o,s(),{onDone:r,onError:i})})),describe("not on dashboard",()=>{it("should return an error if closeApp fails",()=>new Promise((r,i)=>{d([{currentApp:"Bitcoin",currentAppVersion:"1.0.0"}]);const n=new l({input:{}});vi.spyOn(n,"extractDependencies").mockReturnValue(A()),m.mockReturnValue({sessionStateType:p.Connected,deviceStatus:c.CONNECTED,currentApp:"Bitcoin"}),v.mockReturnValue(a({error:new k("Close app failed")}));const o=[{intermediateValue:{requiredUserInteraction:t.None},status:e.Pending},{intermediateValue:{requiredUserInteraction:t.None},status:e.Pending},{intermediateValue:{requiredUserInteraction:t.None},status:e.Pending},{status:e.Error,error:new k("Close app failed")}];u(n,o,s(),{onDone:r,onError:i})})),it("should return an error if getAppAndVersion fails",()=>new Promise((r,i)=>{d([{currentApp:"Bitcoin",currentAppVersion:"1.0.0"}]);const n=new l({input:{unlockTimeout:500}}),o=new C({...g[5501],errorCode:"5501"});vi.spyOn(n,"extractDependencies").mockReturnValue(A()),m.mockReturnValue({sessionStateType:p.Connected,deviceStatus:c.CONNECTED,currentApp:"Bitcoin"}),v.mockResolvedValue(a({data:void 0})),D.mockResolvedValue(a({error:o}));const f=[{intermediateValue:{requiredUserInteraction:t.None},status:e.Pending},{intermediateValue:{requiredUserInteraction:t.None},status:e.Pending},{intermediateValue:{requiredUserInteraction:t.None},status:e.Pending},{intermediateValue:{requiredUserInteraction:t.None},status:e.Pending},{status:e.Error,error:o}];u(n,f,s(),{onDone:r,onError:i})})),it("should return an error if getAppAndVersion does not return an app name",()=>new Promise((r,i)=>{d([{currentApp:"Bitcoin",currentAppVersion:"1.0.0"}]);const n=new l({input:{unlockTimeout:500}});vi.spyOn(n,"extractDependencies").mockReturnValue(A()),m.mockReturnValue({sessionStateType:p.Connected,deviceStatus:c.CONNECTED,currentApp:"Bitcoin"}),v.mockResolvedValue(a({data:void 0})),D.mockResolvedValue(a({data:{name:null,version:"1.0.0"}}));const o=[{intermediateValue:{requiredUserInteraction:t.None},status:e.Pending},{intermediateValue:{requiredUserInteraction:t.None},status:e.Pending},{intermediateValue:{requiredUserInteraction:t.None},status:e.Pending},{intermediateValue:{requiredUserInteraction:t.None},status:e.Pending},{status:e.Error,error:new h("currentApp === null")}];u(n,o,s(),{onDone:r,onError:i})}))})})});
1
+ import{CommandResultFactory as c}from"../../../command/model/CommandResult";import{GLOBAL_ERRORS as R,GlobalCommandError as f}from"../../../command/utils/GlobalCommandError";import{DeviceModelId as T}from"../../../device/DeviceModel";import{DeviceStatus as u}from"../../../device/DeviceStatus";import{makeDeviceActionInternalApiMock as d}from"../../../device-action/__test-utils__/makeInternalApi";import{setupGetDeviceStatusMock as p}from"../../../device-action/__test-utils__/setupTestMachine";import{testDeviceActionStates as l}from"../../../device-action/__test-utils__/testDeviceActionStates";import{DeviceActionStatus as e}from"../../../device-action/model/DeviceActionState";import{UserInteractionRequired as t}from"../../../device-action/model/UserInteractionRequired";import{UnknownDAError as V}from"../../../device-action/os/Errors";import{getDeviceStatusDAStateStep as s}from"../../../device-action/os/GetDeviceStatus/types";import{DeviceSessionStateType as m}from"../../../device-session/DeviceSessionState";import{UnknownDeviceExchangeError as O}from"../../../../../src";import{GoToDashboardDeviceAction as D}from"./GoToDashboardDeviceAction";import{goToDashboardDAStateStep as a}from"./types";vi.mock("@api/device-action/os/GetDeviceStatus/GetDeviceStatusDeviceAction");describe("GoToDashboardDeviceAction",()=>{const S=vi.fn(),v=vi.fn(),A=vi.fn(),N=vi.fn();function C(){return{closeApp:S,getAppAndVersion:v,getDeviceSessionState:A,setDeviceSessionState:N}}const{sendCommand:h,getDeviceSessionState:E}=d();beforeEach(()=>{vi.resetAllMocks()}),describe("without overriding `extractDependencies`",()=>{it("should run the device action with device already on dashboard",()=>new Promise((r,i)=>{p();const n=new D({input:{unlockTimeout:500}});E.mockReturnValue({sessionStateType:m.ReadyWithoutSecureChannel,deviceStatus:u.CONNECTED,currentApp:{name:"BOLOS",version:"1.5.0"},installedApps:[],deviceModelId:T.NANO_X,isSecureConnectionAllowed:!1});const o=[{intermediateValue:{requiredUserInteraction:t.None,step:a.GET_DEVICE_STATUS},status:e.Pending},{intermediateValue:{requiredUserInteraction:t.None,step:s.ONBOARD_CHECK},status:e.Pending},{output:void 0,status:e.Completed}];l(n,o,d(),{onDone:r,onError:i})})),it("should run the device action with device not on dashboard",()=>new Promise((r,i)=>{p([{currentApp:"Bitcoin",currentAppVersion:"1.0.0"}]);const n=new D({input:{unlockTimeout:500}});E.mockReturnValue({sessionStateType:m.ReadyWithoutSecureChannel,deviceStatus:u.CONNECTED,currentApp:{name:"Bitcoin",version:"1.0.0"},installedApps:[],deviceModelId:T.NANO_X,isSecureConnectionAllowed:!1}),h.mockResolvedValueOnce(c({data:void 0})).mockResolvedValueOnce(c({data:{name:"BOLOS",version:"1.5.0"}}));const o=[{intermediateValue:{requiredUserInteraction:t.None,step:a.GET_DEVICE_STATUS},status:e.Pending},{intermediateValue:{requiredUserInteraction:t.None,step:s.ONBOARD_CHECK},status:e.Pending},{intermediateValue:{requiredUserInteraction:t.None,step:s.ONBOARD_CHECK},status:e.Pending},{intermediateValue:{requiredUserInteraction:t.None,step:a.CLOSE_APP},status:e.Pending},{output:void 0,status:e.Completed}];l(n,o,d(),{onDone:r,onError:i})}))}),describe("success cases",()=>{it("should success if the device is already on dashboard",()=>new Promise((r,i)=>{p();const n=new D({input:{unlockTimeout:500}});A.mockReturnValue({sessionStateType:m.Connected,deviceStatus:u.CONNECTED,currentApp:{name:"BOLOS",version:"1.5.0"}}),v.mockReturnValue({app:"BOLOS",version:"1.5.0"}),vi.spyOn(n,"extractDependencies").mockReturnValue(C());const o=[{intermediateValue:{requiredUserInteraction:t.None,step:a.GET_DEVICE_STATUS},status:e.Pending},{intermediateValue:{requiredUserInteraction:t.None,step:s.ONBOARD_CHECK},status:e.Pending},{output:void 0,status:e.Completed}];l(n,o,d(),{onDone:r,onError:i})})),it("should success if the device is not on dashboard",()=>new Promise((r,i)=>{p();const n=new D({input:{unlockTimeout:500}});vi.spyOn(n,"extractDependencies").mockReturnValue(C()),A.mockReturnValue({sessionStateType:m.Connected,deviceStatus:u.CONNECTED}),S.mockResolvedValue(c({data:void 0})),v.mockReturnValue(c({data:{name:"BOLOS",version:"1.5.0"}}));const o=[{intermediateValue:{requiredUserInteraction:t.None,step:a.GET_DEVICE_STATUS},status:e.Pending},{intermediateValue:{requiredUserInteraction:t.None,step:s.ONBOARD_CHECK},status:e.Pending},{output:void 0,status:e.Completed}];l(n,o,d(),{onDone:r,onError:i})}))}),describe("error cases",()=>{it("should return an error if GetDeviceStatus return an error",()=>new Promise((r,i)=>{p([new V("Unknown error")]);const n=new D({input:{unlockTimeout:500}});E.mockReturnValue({sessionStateType:m.ReadyWithoutSecureChannel,deviceStatus:u.CONNECTED,currentApp:{name:"BOLOS",version:"1.5.0"},installedApps:[],deviceModelId:T.NANO_X,isSecureConnectionAllowed:!1});const o=[{intermediateValue:{requiredUserInteraction:t.None,step:a.GET_DEVICE_STATUS},status:e.Pending},{intermediateValue:{requiredUserInteraction:t.None,step:s.ONBOARD_CHECK},status:e.Pending},{status:e.Error,error:new V("Unknown error")}];l(n,o,d(),{onDone:r,onError:i})})),describe("not on dashboard",()=>{it("should return an error if closeApp fails",()=>new Promise((r,i)=>{p([{currentApp:"Bitcoin",currentAppVersion:"1.0.0"}]);const n=new D({input:{}});vi.spyOn(n,"extractDependencies").mockReturnValue(C()),A.mockReturnValue({sessionStateType:m.Connected,deviceStatus:u.CONNECTED,currentApp:"Bitcoin"}),S.mockReturnValue(c({error:new O("Close app failed")}));const o=[{intermediateValue:{requiredUserInteraction:t.None,step:a.GET_DEVICE_STATUS},status:e.Pending},{intermediateValue:{requiredUserInteraction:t.None,step:s.ONBOARD_CHECK},status:e.Pending},{intermediateValue:{requiredUserInteraction:t.None,step:s.ONBOARD_CHECK},status:e.Pending},{status:e.Error,error:new O("Close app failed")}];l(n,o,d(),{onDone:r,onError:i})})),it("should return an error if getAppAndVersion fails",()=>new Promise((r,i)=>{p([{currentApp:"Bitcoin",currentAppVersion:"1.0.0"}]);const n=new D({input:{unlockTimeout:500}}),o=new f({...R[5501],errorCode:"5501"});vi.spyOn(n,"extractDependencies").mockReturnValue(C()),A.mockReturnValue({sessionStateType:m.Connected,deviceStatus:u.CONNECTED,currentApp:"Bitcoin"}),S.mockResolvedValue(c({data:void 0})),v.mockResolvedValue(c({error:o}));const k=[{intermediateValue:{requiredUserInteraction:t.None,step:a.GET_DEVICE_STATUS},status:e.Pending},{intermediateValue:{requiredUserInteraction:t.None,step:s.ONBOARD_CHECK},status:e.Pending},{intermediateValue:{requiredUserInteraction:t.None,step:s.ONBOARD_CHECK},status:e.Pending},{intermediateValue:{requiredUserInteraction:t.None,step:a.CLOSE_APP},status:e.Pending},{status:e.Error,error:o}];l(n,k,d(),{onDone:r,onError:i})})),it("should return an error if getAppAndVersion does not return an app name",()=>new Promise((r,i)=>{p([{currentApp:"Bitcoin",currentAppVersion:"1.0.0"}]);const n=new D({input:{unlockTimeout:500}});vi.spyOn(n,"extractDependencies").mockReturnValue(C()),A.mockReturnValue({sessionStateType:m.Connected,deviceStatus:u.CONNECTED,currentApp:"Bitcoin"}),S.mockResolvedValue(c({data:void 0})),v.mockResolvedValue(c({data:{name:null,version:"1.0.0"}}));const o=[{intermediateValue:{requiredUserInteraction:t.None,step:a.GET_DEVICE_STATUS},status:e.Pending},{intermediateValue:{requiredUserInteraction:t.None,step:s.ONBOARD_CHECK},status:e.Pending},{intermediateValue:{requiredUserInteraction:t.None,step:s.ONBOARD_CHECK},status:e.Pending},{intermediateValue:{requiredUserInteraction:t.None,step:a.CLOSE_APP},status:e.Pending},{status:e.Error,error:new V("currentApp === null")}];l(n,o,d(),{onDone:r,onError:i})}))})})});
2
2
  //# sourceMappingURL=GoToDashboardDeviceAction.test.js.map