@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
@@ -64,5 +64,5 @@
64
64
  "watch:builds": "pnpm ldmk-tool watch --entryPoints index.ts,src/**/*.ts --tsconfig tsconfig.prod.json",
65
65
  "watch:types": "concurrently \"tsc --watch -p tsconfig.prod.json\" \"tsc-alias --watch -p tsconfig.prod.json\""
66
66
  },
67
- "version": "1.1.0"
67
+ "version": "1.2.0"
68
68
  }
@@ -1,2 +1,2 @@
1
- "use strict";var i=Object.defineProperty;var s=Object.getOwnPropertyDescriptor;var p=Object.getOwnPropertyNames;var l=Object.prototype.hasOwnProperty;var A=(r,t)=>{for(var e in t)i(r,e,{get:t[e],enumerable:!0})},h=(r,t,e,d)=>{if(t&&typeof t=="object"||typeof t=="function")for(let a of p(t))!l.call(r,a)&&a!==e&&i(r,a,{get:()=>t[a],enumerable:!(d=s(t,a))||d.enumerable});return r};var B=r=>h(i({},"__esModule",{value:!0}),r);var y={};A(y,{APDU_MAX_PAYLOAD:()=>n,APDU_MAX_SIZE:()=>c,ApduBuilder:()=>f,HEADER_LENGTH:()=>m});module.exports=B(y);var u=require("../../apdu/model/Apdu"),o=require("./ByteArrayBuilder");const m=5,n=255,c=n+5;class f{_ins;_cla;_p1;p2;data=new o.ByteArrayBuilder(n);constructor({ins:t,cla:e,p1:d,p2:a}){this._cla=e&255,this._ins=t&255,this._p1=d&255,this.p2=a&255}build=()=>new u.Apdu(this._cla,this._ins,this._p1,this.p2,this.data.build());add8BitUIntToData=t=>(this.data.add8BitUIntToData(t),this);add16BitUIntToData=t=>(this.data.add16BitUIntToData(t),this);add32BitUIntToData=t=>(this.data.add32BitUIntToData(t),this);addBufferToData=t=>(this.data.addBufferToData(t),this);addHexaStringToData=t=>(this.data.addHexaStringToData(t),this);addAsciiStringToData=t=>(this.data.addAsciiStringToData(t),this);encodeInLVFromHexa=t=>(this.data.encodeInLVFromHexa(t),this);encodeInLVFromBuffer=t=>(this.data.encodeInLVFromBuffer(t),this);encodeInLVFromAscii=t=>(this.data.encodeInLVFromAscii(t),this);getAvailablePayloadLength=()=>this.data.getAvailablePayloadLength();getErrors=()=>this.data.getErrors()}0&&(module.exports={APDU_MAX_PAYLOAD,APDU_MAX_SIZE,ApduBuilder,HEADER_LENGTH});
1
+ "use strict";var i=Object.defineProperty;var s=Object.getOwnPropertyDescriptor;var p=Object.getOwnPropertyNames;var l=Object.prototype.hasOwnProperty;var A=(r,t)=>{for(var a in t)i(r,a,{get:t[a],enumerable:!0})},h=(r,t,a,d)=>{if(t&&typeof t=="object"||typeof t=="function")for(let e of p(t))!l.call(r,e)&&e!==a&&i(r,e,{get:()=>t[e],enumerable:!(d=s(t,e))||d.enumerable});return r};var B=r=>h(i({},"__esModule",{value:!0}),r);var f={};A(f,{APDU_MAX_PAYLOAD:()=>n,APDU_MAX_SIZE:()=>c,ApduBuilder:()=>b,HEADER_LENGTH:()=>m});module.exports=B(f);var u=require("../../apdu/model/Apdu"),o=require("./ByteArrayBuilder");const m=5,n=255,c=n+5;class b{_ins;_cla;_p1;p2;data=new o.ByteArrayBuilder(n);constructor({ins:t,cla:a,p1:d,p2:e}){this._cla=a&255,this._ins=t&255,this._p1=d&255,this.p2=e&255}build=()=>new u.Apdu(this._cla,this._ins,this._p1,this.p2,this.data.build());add8BitUIntToData=t=>(this.data.add8BitUIntToData(t),this);add16BitUIntToData=t=>(this.data.add16BitUIntToData(t),this);add32BitUIntToData=t=>(this.data.add32BitUIntToData(t),this);add64BitUIntToData=(t,a=!0)=>(this.data.add64BitUIntToData(t,a),this);addBufferToData=t=>(this.data.addBufferToData(t),this);addHexaStringToData=t=>(this.data.addHexaStringToData(t),this);addAsciiStringToData=t=>(this.data.addAsciiStringToData(t),this);encodeInLVFromHexa=t=>(this.data.encodeInLVFromHexa(t),this);encodeInLVFromBuffer=t=>(this.data.encodeInLVFromBuffer(t),this);encodeInLVFromAscii=t=>(this.data.encodeInLVFromAscii(t),this);getAvailablePayloadLength=()=>this.data.getAvailablePayloadLength();getErrors=()=>this.data.getErrors()}0&&(module.exports={APDU_MAX_PAYLOAD,APDU_MAX_SIZE,ApduBuilder,HEADER_LENGTH});
2
2
  //# sourceMappingURL=ApduBuilder.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../../../src/api/apdu/utils/ApduBuilder.ts"],
4
- "sourcesContent": ["import { Apdu } from \"@api/apdu/model/Apdu\";\n\nimport { type AppBuilderError } from \"./AppBuilderError\";\nimport { ByteArrayBuilder } from \"./ByteArrayBuilder\";\n\nexport const HEADER_LENGTH = 5;\nexport const APDU_MAX_PAYLOAD = 255;\nexport const APDU_MAX_SIZE = APDU_MAX_PAYLOAD + 5;\n\nexport type ApduBuilderArgs = {\n readonly ins: number;\n readonly cla: number;\n readonly p1: number;\n readonly p2: number;\n};\n\n/**\n * ApduBuilder is a utility class to help build APDU commands.\n * It allows to easily add data to the data field of the APDU command\n * and to encode this data in different formats.\n *\n * @example\n * ```\n * const apduBuilder = new ApduBuilder({ ins: 0x01, cla: 0x02, p1: 0x03, p2: 0x04 })\n * .add8BitUIntToData(0x05)\n * .add16BitUIntToData(0x0607)\n * .addHexaStringToData(\"0x0809\")\n * .addAsciiStringToData(\"hello\")\n *\n * const apdu = apduBuilder.build();\n * const builderErrors = apduBuilder.getErrors();\n * ```\n */\nexport class ApduBuilder {\n private readonly _ins: number;\n private readonly _cla: number;\n private readonly _p1: number;\n private readonly p2: number;\n private data: ByteArrayBuilder = new ByteArrayBuilder(APDU_MAX_PAYLOAD);\n\n constructor({ ins, cla, p1, p2 }: ApduBuilderArgs) {\n this._cla = cla & 0xff;\n this._ins = ins & 0xff;\n this._p1 = p1 & 0xff;\n this.p2 = p2 & 0xff;\n }\n\n // ==========\n // Public API\n // ==========\n\n /**\n * Build a new Apdu instance with the current state of the builder\n * @returns {Apdu} - Returns a new Apdu instance\n */\n build = (): Apdu =>\n new Apdu(this._cla, this._ins, this._p1, this.p2, this.data.build());\n\n /**\n * Add a 8-bit unsigned integer to the data field (max value 0xff = 255)\n * @param value?: number - The value to add to the data\n * @returns {ApduBuilder} - Returns the current instance of ApduBuilder\n */\n add8BitUIntToData = (value: number): ApduBuilder => {\n this.data.add8BitUIntToData(value);\n return this;\n };\n\n /**\n * Add a 16-bit unsigned integer to the data field (max value 0xffff = 65535)\n * @param value: number - The value to add to the data\n * @returns {ApduBuilder} - Returns the current instance of ApduBuilder\n */\n add16BitUIntToData = (value: number): ApduBuilder => {\n this.data.add16BitUIntToData(value);\n return this;\n };\n\n /**\n * Add a 32-bit unsigned integer to the data field (max value 0xffffffff = 4294967295)\n * @param value: number - The value to add to the data\n * @returns {ApduBuilder} - Returns the current instance of ApduBuilder\n */\n add32BitUIntToData = (value: number): ApduBuilder => {\n this.data.add32BitUIntToData(value);\n return this;\n };\n\n /**\n * Add a Uint8Array to the data field if it has enough remaining space\n * @param value: Uint8Array - The value to add to the data\n * @returns {ApduBuilder} - Returns the current instance of ApduBuilder\n */\n addBufferToData = (value: Uint8Array): ApduBuilder => {\n this.data.addBufferToData(value);\n return this;\n };\n\n /**\n * Add a string to the data field if it has enough remaining space\n * and it can be formatted as a hexadecimal string\n * @param value: string - The value to add to the data\n * @returns {ApduBuilder} - Returns the current instance of ApduBuilder\n */\n addHexaStringToData = (value: string): ApduBuilder => {\n this.data.addHexaStringToData(value);\n return this;\n };\n\n /**\n * Add an ascii string to the data field if it has enough remaining space\n * @param value: string - The value to add to the data\n * @returns {ApduBuilder} - Returns the current instance of ApduBuilder\n */\n addAsciiStringToData = (value: string): ApduBuilder => {\n this.data.addAsciiStringToData(value);\n return this;\n };\n\n /**\n * Add a Length-Value encoded hexadecimal string to the data field if it has enough remaining space\n * Length-Value encoding is a way to encode data in a binary format with the first byte\n * being the length of the data and the following bytes being the data itself\n * @param value: string - The value to add to the data\n * @returns {ApduBuilder} - Returns the current instance of ApduBuilder\n */\n encodeInLVFromHexa = (value: string): ApduBuilder => {\n this.data.encodeInLVFromHexa(value);\n return this;\n };\n\n /**\n * Add a Length-Value encoded buffer to the data field if it has enough remaining space\n * Length-Value encoding is a way to encode data in a binary format with the first byte\n * being the length of the data and the following bytes being the data itself\n * @param value: Uint8Array - The value to add to the data\n * @returns {ApduBuilder} - Returns the current instance of ApduBuilder\n */\n encodeInLVFromBuffer = (value: Uint8Array): ApduBuilder => {\n this.data.encodeInLVFromBuffer(value);\n return this;\n };\n\n /**\n * Add a Length-Value encoded ascii string to the data field if it has enough remaining space\n * Length-Value encoding is a way to encode data in a binary format with the first byte\n * being the length of the data and the following bytes being the data itself\n * @param value: string - The value to add to the data\n * @returns {ApduBuilder} - Returns the current instance of ApduBuilder\n */\n encodeInLVFromAscii = (value: string): ApduBuilder => {\n this.data.encodeInLVFromAscii(value);\n return this;\n };\n\n /**\n * Returns the remaining payload length\n * @returns {number}\n */\n getAvailablePayloadLength = (): number =>\n this.data.getAvailablePayloadLength();\n\n /**\n * Returns the current errors\n * @returns {AppBuilderError[]} - Returns an array of errors\n */\n getErrors = (): AppBuilderError[] => this.data.getErrors();\n}\n"],
5
- "mappings": "yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,sBAAAE,EAAA,kBAAAC,EAAA,gBAAAC,EAAA,kBAAAC,IAAA,eAAAC,EAAAN,GAAA,IAAAO,EAAqB,gCAGrBC,EAAiC,8BAE1B,MAAMH,EAAgB,EAChBH,EAAmB,IACnBC,EAAgBD,EAAmB,EA0BzC,MAAME,CAAY,CACN,KACA,KACA,IACA,GACT,KAAyB,IAAI,mBAAiBF,CAAgB,EAEtE,YAAY,CAAE,IAAAO,EAAK,IAAAC,EAAK,GAAAC,EAAI,GAAAC,CAAG,EAAoB,CACjD,KAAK,KAAOF,EAAM,IAClB,KAAK,KAAOD,EAAM,IAClB,KAAK,IAAME,EAAK,IAChB,KAAK,GAAKC,EAAK,GACjB,CAUA,MAAQ,IACN,IAAI,OAAK,KAAK,KAAM,KAAK,KAAM,KAAK,IAAK,KAAK,GAAI,KAAK,KAAK,MAAM,CAAC,EAOrE,kBAAqBC,IACnB,KAAK,KAAK,kBAAkBA,CAAK,EAC1B,MAQT,mBAAsBA,IACpB,KAAK,KAAK,mBAAmBA,CAAK,EAC3B,MAQT,mBAAsBA,IACpB,KAAK,KAAK,mBAAmBA,CAAK,EAC3B,MAQT,gBAAmBA,IACjB,KAAK,KAAK,gBAAgBA,CAAK,EACxB,MAST,oBAAuBA,IACrB,KAAK,KAAK,oBAAoBA,CAAK,EAC5B,MAQT,qBAAwBA,IACtB,KAAK,KAAK,qBAAqBA,CAAK,EAC7B,MAUT,mBAAsBA,IACpB,KAAK,KAAK,mBAAmBA,CAAK,EAC3B,MAUT,qBAAwBA,IACtB,KAAK,KAAK,qBAAqBA,CAAK,EAC7B,MAUT,oBAAuBA,IACrB,KAAK,KAAK,oBAAoBA,CAAK,EAC5B,MAOT,0BAA4B,IAC1B,KAAK,KAAK,0BAA0B,EAMtC,UAAY,IAAyB,KAAK,KAAK,UAAU,CAC3D",
6
- "names": ["ApduBuilder_exports", "__export", "APDU_MAX_PAYLOAD", "APDU_MAX_SIZE", "ApduBuilder", "HEADER_LENGTH", "__toCommonJS", "import_Apdu", "import_ByteArrayBuilder", "ins", "cla", "p1", "p2", "value"]
4
+ "sourcesContent": ["import { Apdu } from \"@api/apdu/model/Apdu\";\n\nimport { type AppBuilderError } from \"./AppBuilderError\";\nimport { ByteArrayBuilder } from \"./ByteArrayBuilder\";\n\nexport const HEADER_LENGTH = 5;\nexport const APDU_MAX_PAYLOAD = 255;\nexport const APDU_MAX_SIZE = APDU_MAX_PAYLOAD + 5;\n\nexport type ApduBuilderArgs = {\n readonly ins: number;\n readonly cla: number;\n readonly p1: number;\n readonly p2: number;\n};\n\n/**\n * ApduBuilder is a utility class to help build APDU commands.\n * It allows to easily add data to the data field of the APDU command\n * and to encode this data in different formats.\n *\n * @example\n * ```\n * const apduBuilder = new ApduBuilder({ ins: 0x01, cla: 0x02, p1: 0x03, p2: 0x04 })\n * .add8BitUIntToData(0x05)\n * .add16BitUIntToData(0x0607)\n * .addHexaStringToData(\"0x0809\")\n * .addAsciiStringToData(\"hello\")\n *\n * const apdu = apduBuilder.build();\n * const builderErrors = apduBuilder.getErrors();\n * ```\n */\nexport class ApduBuilder {\n private readonly _ins: number;\n private readonly _cla: number;\n private readonly _p1: number;\n private readonly p2: number;\n private data: ByteArrayBuilder = new ByteArrayBuilder(APDU_MAX_PAYLOAD);\n\n constructor({ ins, cla, p1, p2 }: ApduBuilderArgs) {\n this._cla = cla & 0xff;\n this._ins = ins & 0xff;\n this._p1 = p1 & 0xff;\n this.p2 = p2 & 0xff;\n }\n\n // ==========\n // Public API\n // ==========\n\n /**\n * Build a new Apdu instance with the current state of the builder\n * @returns {Apdu} - Returns a new Apdu instance\n */\n build = (): Apdu =>\n new Apdu(this._cla, this._ins, this._p1, this.p2, this.data.build());\n\n /**\n * Add a 8-bit unsigned integer to the data field (max value 0xff = 255)\n * @param value?: number - The value to add to the data\n * @returns {ApduBuilder} - Returns the current instance of ApduBuilder\n */\n add8BitUIntToData = (value: number): ApduBuilder => {\n this.data.add8BitUIntToData(value);\n return this;\n };\n\n /**\n * Add a 16-bit unsigned integer to the data field (max value 0xffff = 65535)\n * @param value: number - The value to add to the data\n * @returns {ApduBuilder} - Returns the current instance of ApduBuilder\n */\n add16BitUIntToData = (value: number): ApduBuilder => {\n this.data.add16BitUIntToData(value);\n return this;\n };\n\n /**\n * Add a 32-bit unsigned integer to the data field (max value 0xffffffff = 4294967295)\n * @param value: number - The value to add to the data\n * @returns {ApduBuilder} - Returns the current instance of ApduBuilder\n */\n add32BitUIntToData = (value: number): ApduBuilder => {\n this.data.add32BitUIntToData(value);\n return this;\n };\n\n /**\n * Add a 64-bit unsigned integer to the data field in big-endian (max value 0xffffffffffffffff)\n * @param value: number | bigint - The value to add to the data\n * @param bigEndian: boolean - True for big-endian (default), false for little-endian\n * @returns {ApduBuilder} - Returns the current instance of ApduBuilder\n */\n add64BitUIntToData = (\n value: number | bigint,\n bigEndian: boolean = true,\n ): ApduBuilder => {\n this.data.add64BitUIntToData(value, bigEndian);\n return this;\n };\n\n /**\n * Add a Uint8Array to the data field if it has enough remaining space\n * @param value: Uint8Array - The value to add to the data\n * @returns {ApduBuilder} - Returns the current instance of ApduBuilder\n */\n addBufferToData = (value: Uint8Array): ApduBuilder => {\n this.data.addBufferToData(value);\n return this;\n };\n\n /**\n * Add a string to the data field if it has enough remaining space\n * and it can be formatted as a hexadecimal string\n * @param value: string - The value to add to the data\n * @returns {ApduBuilder} - Returns the current instance of ApduBuilder\n */\n addHexaStringToData = (value: string): ApduBuilder => {\n this.data.addHexaStringToData(value);\n return this;\n };\n\n /**\n * Add an ascii string to the data field if it has enough remaining space\n * @param value: string - The value to add to the data\n * @returns {ApduBuilder} - Returns the current instance of ApduBuilder\n */\n addAsciiStringToData = (value: string): ApduBuilder => {\n this.data.addAsciiStringToData(value);\n return this;\n };\n\n /**\n * Add a Length-Value encoded hexadecimal string to the data field if it has enough remaining space\n * Length-Value encoding is a way to encode data in a binary format with the first byte\n * being the length of the data and the following bytes being the data itself\n * @param value: string - The value to add to the data\n * @returns {ApduBuilder} - Returns the current instance of ApduBuilder\n */\n encodeInLVFromHexa = (value: string): ApduBuilder => {\n this.data.encodeInLVFromHexa(value);\n return this;\n };\n\n /**\n * Add a Length-Value encoded buffer to the data field if it has enough remaining space\n * Length-Value encoding is a way to encode data in a binary format with the first byte\n * being the length of the data and the following bytes being the data itself\n * @param value: Uint8Array - The value to add to the data\n * @returns {ApduBuilder} - Returns the current instance of ApduBuilder\n */\n encodeInLVFromBuffer = (value: Uint8Array): ApduBuilder => {\n this.data.encodeInLVFromBuffer(value);\n return this;\n };\n\n /**\n * Add a Length-Value encoded ascii string to the data field if it has enough remaining space\n * Length-Value encoding is a way to encode data in a binary format with the first byte\n * being the length of the data and the following bytes being the data itself\n * @param value: string - The value to add to the data\n * @returns {ApduBuilder} - Returns the current instance of ApduBuilder\n */\n encodeInLVFromAscii = (value: string): ApduBuilder => {\n this.data.encodeInLVFromAscii(value);\n return this;\n };\n\n /**\n * Returns the remaining payload length\n * @returns {number}\n */\n getAvailablePayloadLength = (): number =>\n this.data.getAvailablePayloadLength();\n\n /**\n * Returns the current errors\n * @returns {AppBuilderError[]} - Returns an array of errors\n */\n getErrors = (): AppBuilderError[] => this.data.getErrors();\n}\n"],
5
+ "mappings": "yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,sBAAAE,EAAA,kBAAAC,EAAA,gBAAAC,EAAA,kBAAAC,IAAA,eAAAC,EAAAN,GAAA,IAAAO,EAAqB,gCAGrBC,EAAiC,8BAE1B,MAAMH,EAAgB,EAChBH,EAAmB,IACnBC,EAAgBD,EAAmB,EA0BzC,MAAME,CAAY,CACN,KACA,KACA,IACA,GACT,KAAyB,IAAI,mBAAiBF,CAAgB,EAEtE,YAAY,CAAE,IAAAO,EAAK,IAAAC,EAAK,GAAAC,EAAI,GAAAC,CAAG,EAAoB,CACjD,KAAK,KAAOF,EAAM,IAClB,KAAK,KAAOD,EAAM,IAClB,KAAK,IAAME,EAAK,IAChB,KAAK,GAAKC,EAAK,GACjB,CAUA,MAAQ,IACN,IAAI,OAAK,KAAK,KAAM,KAAK,KAAM,KAAK,IAAK,KAAK,GAAI,KAAK,KAAK,MAAM,CAAC,EAOrE,kBAAqBC,IACnB,KAAK,KAAK,kBAAkBA,CAAK,EAC1B,MAQT,mBAAsBA,IACpB,KAAK,KAAK,mBAAmBA,CAAK,EAC3B,MAQT,mBAAsBA,IACpB,KAAK,KAAK,mBAAmBA,CAAK,EAC3B,MAST,mBAAqB,CACnBA,EACAC,EAAqB,MAErB,KAAK,KAAK,mBAAmBD,EAAOC,CAAS,EACtC,MAQT,gBAAmBD,IACjB,KAAK,KAAK,gBAAgBA,CAAK,EACxB,MAST,oBAAuBA,IACrB,KAAK,KAAK,oBAAoBA,CAAK,EAC5B,MAQT,qBAAwBA,IACtB,KAAK,KAAK,qBAAqBA,CAAK,EAC7B,MAUT,mBAAsBA,IACpB,KAAK,KAAK,mBAAmBA,CAAK,EAC3B,MAUT,qBAAwBA,IACtB,KAAK,KAAK,qBAAqBA,CAAK,EAC7B,MAUT,oBAAuBA,IACrB,KAAK,KAAK,oBAAoBA,CAAK,EAC5B,MAOT,0BAA4B,IAC1B,KAAK,KAAK,0BAA0B,EAMtC,UAAY,IAAyB,KAAK,KAAK,UAAU,CAC3D",
6
+ "names": ["ApduBuilder_exports", "__export", "APDU_MAX_PAYLOAD", "APDU_MAX_SIZE", "ApduBuilder", "HEADER_LENGTH", "__toCommonJS", "import_Apdu", "import_ByteArrayBuilder", "ins", "cla", "p1", "p2", "value", "bigEndian"]
7
7
  }
@@ -1,2 +1,2 @@
1
- "use strict";var c=Object.defineProperty;var y=Object.getOwnPropertyDescriptor;var I=Object.getOwnPropertyNames;var D=Object.prototype.hasOwnProperty;var M=(e,t)=>{for(var o in t)c(e,o,{get:t[o],enumerable:!0})},v=(e,t,o,m)=>{if(t&&typeof t=="object"||typeof t=="function")for(let p of I(t))!D.call(e,p)&&p!==o&&c(e,p,{get:()=>t[p],enumerable:!(m=y(t,p))||m.enumerable});return e};var O=e=>v(c({},"__esModule",{value:!0}),e);var w={};M(w,{setupGetDeviceMetadataMock:()=>h,setupGetDeviceStatusMock:()=>L,setupGoToDashboardMock:()=>V,setupInstallOrUpdateAppsMock:()=>G,setupListAppsMock:()=>U,setupListInstalledAppsMock:()=>q,setupOpenAppMock:()=>S});module.exports=O(w);var n=require("purify-ts"),a=require("xstate"),i=require("../../device-action/model/UserInteractionRequired"),r=require("../../device-action/os/Errors"),s=require("../../device-action/os/GetDeviceMetadata/GetDeviceMetadataDeviceAction"),d=require("../../device-action/os/GetDeviceStatus/GetDeviceStatusDeviceAction"),l=require("../../device-action/os/GoToDashboard/GoToDashboardDeviceAction"),u=require("../../device-action/os/InstallOrUpdateApps/InstallOrUpdateAppsDeviceAction"),f=require("../../device-action/os/ListApps/ListAppsDeviceAction"),A=require("../../device-action/os/OpenAppDeviceAction/OpenAppDeviceAction"),k=require("../../secure-channel/device-action/ListInstalledApps/ListInstalledAppsDeviceAction");const U=(e,t=!1)=>{f.ListAppsDeviceAction.mockImplementation(()=>({makeStateMachine:vi.fn().mockImplementation(()=>(0,a.createMachine)({id:"MockListAppsDeviceAction",initial:"ready",states:{ready:{after:{0:"done"},entry:(0,a.assign)({intermediateValue:()=>({requiredUserInteraction:i.UserInteractionRequired.AllowListApps})})},done:{type:"final"}},output:()=>t?(0,n.Left)(new r.UnknownDAError("ListApps failed")):(0,n.Right)(e)}))}))},h=(e,t=!1)=>{s.GetDeviceMetadataDeviceAction.mockImplementation(()=>({makeStateMachine:vi.fn().mockImplementation(()=>(0,a.createMachine)({id:"MockGetDeviceMetadataDeviceAction",initial:"ready",states:{ready:{after:{0:"done"},entry:(0,a.assign)({intermediateValue:()=>({requiredUserInteraction:i.UserInteractionRequired.None})})},done:{type:"final"}},output:()=>t?(0,n.Left)(new r.UnknownDAError("GetDeviceMetadata failed")):(0,n.Right)(e)}))}))},G=(e,t,o=!1)=>{u.InstallOrUpdateAppsDeviceAction.mockImplementation(()=>({makeStateMachine:vi.fn().mockImplementation(()=>(0,a.createMachine)({id:"MockInstallOrUpdateAppsDeviceAction",initial:"ready",states:{ready:{after:{0:"done"},entry:(0,a.assign)({intermediateValue:()=>t})},done:{type:"final"}},output:()=>o?(0,n.Left)(new r.UnknownDAError("InstallOrUpdateApps failed")):(0,n.Right)(e)}))}))},S=(e=!1)=>{A.OpenAppDeviceAction.mockImplementation(()=>({makeStateMachine:vi.fn().mockImplementation(()=>(0,a.createMachine)({initial:"ready",states:{ready:{entry:(0,a.assign)({intermediateValue:{requiredUserInteraction:i.UserInteractionRequired.ConfirmOpenApp}}),after:{0:"done"}},done:{type:"final"}},output:()=>e?(0,n.Left)(new r.UnknownDAError("OpenApp failed")):(0,n.Right)(void 0)}))}))},V=(e=!1)=>{l.GoToDashboardDeviceAction.mockImplementation(()=>({makeStateMachine:vi.fn().mockImplementation(()=>(0,a.createMachine)({id:"MockGoToDashboardDeviceAction",initial:"ready",states:{ready:{after:{0:"done"},entry:(0,a.assign)({intermediateValue:()=>({requiredUserInteraction:i.UserInteractionRequired.None})})},done:{type:"final"}},output:()=>e?(0,n.Left)(new r.UnknownDAError("GoToDashboard failed")):(0,n.Right)(void 0)}))}))},L=(e=[{currentApp:"BOLOS",currentAppVersion:"1.0.0"}])=>{const t=vi.fn();for(const o of e)t.mockImplementationOnce(()=>"currentApp"in o?(0,n.Right)(o):(0,n.Left)(o));d.GetDeviceStatusDeviceAction.mockImplementation(()=>({makeStateMachine:vi.fn().mockImplementation(()=>(0,a.createMachine)({id:"MockGetDeviceStatusDeviceAction",initial:"ready",states:{ready:{after:{0:"done"},entry:(0,a.assign)({intermediateValue:()=>({requiredUserInteraction:i.UserInteractionRequired.None})})},done:{type:"final"}},output:t}))}))},q=(e=[])=>{k.ListInstalledAppsDeviceAction.mockImplementation(()=>({makeStateMachine:vi.fn().mockImplementation(()=>(0,a.createMachine)({id:"MockListInstalledAppsDeviceAction",initial:"ready",states:{ready:{after:{0:"done"},entry:(0,a.assign)({intermediateValue:()=>({requiredUserInteraction:i.UserInteractionRequired.None})})},done:{type:"final"}},output:e.reduce((t,o)=>t.mockImplementationOnce(()=>"installedApps"in o?(0,n.Right)(o):(0,n.Left)(o)),vi.fn()).mockImplementation(()=>(0,n.Right)([]))}))}))};0&&(module.exports={setupGetDeviceMetadataMock,setupGetDeviceStatusMock,setupGoToDashboardMock,setupInstallOrUpdateAppsMock,setupListAppsMock,setupListInstalledAppsMock,setupOpenAppMock});
1
+ "use strict";var m=Object.defineProperty;var S=Object.getOwnPropertyDescriptor;var O=Object.getOwnPropertyNames;var U=Object.prototype.hasOwnProperty;var T=(e,t)=>{for(var o in t)m(e,o,{get:t[o],enumerable:!0})},G=(e,t,o,s)=>{if(t&&typeof t=="object"||typeof t=="function")for(let p of O(t))!U.call(e,p)&&p!==o&&m(e,p,{get:()=>t[p],enumerable:!(s=S(t,p))||s.enumerable});return e};var E=e=>G(m({},"__esModule",{value:!0}),e);var q={};T(q,{setupGetDeviceMetadataMock:()=>V,setupGetDeviceStatusMock:()=>b,setupGoToDashboardMock:()=>C,setupInstallOrUpdateAppsMock:()=>L,setupListAppsMock:()=>h,setupListInstalledAppsMock:()=>g,setupOpenAppMock:()=>_});module.exports=E(q);var a=require("purify-ts"),n=require("xstate"),i=require("../../device-action/model/UserInteractionRequired"),r=require("../../device-action/os/Errors"),c=require("../../device-action/os/GetDeviceMetadata/GetDeviceMetadataDeviceAction"),d=require("../../device-action/os/GetDeviceMetadata/types"),l=require("../../device-action/os/GetDeviceStatus/GetDeviceStatusDeviceAction"),A=require("../../device-action/os/GetDeviceStatus/types"),u=require("../../device-action/os/GoToDashboard/GoToDashboardDeviceAction"),f=require("../../device-action/os/GoToDashboard/types"),k=require("../../device-action/os/InstallOrUpdateApps/InstallOrUpdateAppsDeviceAction"),D=require("../../device-action/os/ListApps/ListAppsDeviceAction"),I=require("../../device-action/os/ListApps/types"),y=require("../../device-action/os/OpenAppDeviceAction/OpenAppDeviceAction"),M=require("../../device-action/os/OpenAppDeviceAction/types"),v=require("../../secure-channel/device-action/ListInstalledApps/ListInstalledAppsDeviceAction");const h=(e,t=!1)=>{D.ListAppsDeviceAction.mockImplementation(()=>({makeStateMachine:vi.fn().mockImplementation(()=>(0,n.createMachine)({id:"MockListAppsDeviceAction",initial:"ready",states:{ready:{after:{0:"done"},entry:(0,n.assign)({intermediateValue:()=>({requiredUserInteraction:i.UserInteractionRequired.AllowListApps,step:I.listAppsDAStateStep.LIST_APPS})})},done:{type:"final"}},output:()=>t?(0,a.Left)(new r.UnknownDAError("ListApps failed")):(0,a.Right)(e)}))}))},V=(e,t=!1)=>{c.GetDeviceMetadataDeviceAction.mockImplementation(()=>({makeStateMachine:vi.fn().mockImplementation(()=>(0,n.createMachine)({id:"MockGetDeviceMetadataDeviceAction",initial:"ready",states:{ready:{after:{0:"done"},entry:(0,n.assign)({intermediateValue:()=>({requiredUserInteraction:i.UserInteractionRequired.None,step:d.getDeviceMetadataDAStateStep.GET_DEVICE_METADATA})})},done:{type:"final"}},output:()=>t?(0,a.Left)(new r.UnknownDAError("GetDeviceMetadata failed")):(0,a.Right)(e)}))}))},L=(e,t,o=!1)=>{k.InstallOrUpdateAppsDeviceAction.mockImplementation(()=>({makeStateMachine:vi.fn().mockImplementation(()=>(0,n.createMachine)({id:"MockInstallOrUpdateAppsDeviceAction",initial:"ready",states:{ready:{after:{0:"done"},entry:(0,n.assign)({intermediateValue:()=>t})},done:{type:"final"}},output:()=>o?(0,a.Left)(new r.UnknownDAError("InstallOrUpdateApps failed")):(0,a.Right)(e)}))}))},_=(e=!1)=>{y.OpenAppDeviceAction.mockImplementation(()=>({makeStateMachine:vi.fn().mockImplementation(()=>(0,n.createMachine)({initial:"ready",states:{ready:{entry:(0,n.assign)({intermediateValue:{requiredUserInteraction:i.UserInteractionRequired.ConfirmOpenApp,step:M.openAppDAStateStep.GET_DEVICE_STATUS}}),after:{0:"done"}},done:{type:"final"}},output:()=>e?(0,a.Left)(new r.UnknownDAError("OpenApp failed")):(0,a.Right)(void 0)}))}))},C=(e=!1)=>{u.GoToDashboardDeviceAction.mockImplementation(()=>({makeStateMachine:vi.fn().mockImplementation(()=>(0,n.createMachine)({id:"MockGoToDashboardDeviceAction",initial:"ready",states:{ready:{after:{0:"done"},entry:(0,n.assign)({intermediateValue:()=>({requiredUserInteraction:i.UserInteractionRequired.None,step:f.goToDashboardDAStateStep.GET_DEVICE_STATUS})})},done:{type:"final"}},output:()=>e?(0,a.Left)(new r.UnknownDAError("GoToDashboard failed")):(0,a.Right)(void 0)}))}))},b=(e=[{currentApp:"BOLOS",currentAppVersion:"1.0.0"}])=>{const t=vi.fn();for(const o of e)t.mockImplementationOnce(()=>"currentApp"in o?(0,a.Right)(o):(0,a.Left)(o));l.GetDeviceStatusDeviceAction.mockImplementation(()=>({makeStateMachine:vi.fn().mockImplementation(()=>(0,n.createMachine)({id:"MockGetDeviceStatusDeviceAction",initial:"ready",states:{ready:{after:{0:"done"},entry:(0,n.assign)({intermediateValue:()=>({requiredUserInteraction:i.UserInteractionRequired.None,step:A.getDeviceStatusDAStateStep.ONBOARD_CHECK})})},done:{type:"final"}},output:t}))}))},g=(e=[])=>{v.ListInstalledAppsDeviceAction.mockImplementation(()=>({makeStateMachine:vi.fn().mockImplementation(()=>(0,n.createMachine)({id:"MockListInstalledAppsDeviceAction",initial:"ready",states:{ready:{after:{0:"done"},entry:(0,n.assign)({intermediateValue:()=>({requiredUserInteraction:i.UserInteractionRequired.None})})},done:{type:"final"}},output:e.reduce((t,o)=>t.mockImplementationOnce(()=>"installedApps"in o?(0,a.Right)(o):(0,a.Left)(o)),vi.fn()).mockImplementation(()=>(0,a.Right)([]))}))}))};0&&(module.exports={setupGetDeviceMetadataMock,setupGetDeviceStatusMock,setupGoToDashboardMock,setupInstallOrUpdateAppsMock,setupListAppsMock,setupListInstalledAppsMock,setupOpenAppMock});
2
2
  //# sourceMappingURL=setupTestMachine.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../../../src/api/device-action/__test-utils__/setupTestMachine.ts"],
4
- "sourcesContent": ["import { Left, Right } from \"purify-ts\";\nimport { type Mock } from \"vitest\";\nimport { assign, createMachine } from \"xstate\";\n\nimport { UserInteractionRequired } from \"@api/device-action/model/UserInteractionRequired\";\nimport { UnknownDAError } from \"@api/device-action/os/Errors\";\nimport { GetDeviceMetadataDeviceAction } from \"@api/device-action/os/GetDeviceMetadata/GetDeviceMetadataDeviceAction\";\nimport { type GetDeviceMetadataDAOutput } from \"@api/device-action/os/GetDeviceMetadata/types\";\nimport { GetDeviceStatusDeviceAction } from \"@api/device-action/os/GetDeviceStatus/GetDeviceStatusDeviceAction\";\nimport { GoToDashboardDeviceAction } from \"@api/device-action/os/GoToDashboard/GoToDashboardDeviceAction\";\nimport { InstallOrUpdateAppsDeviceAction } from \"@api/device-action/os/InstallOrUpdateApps/InstallOrUpdateAppsDeviceAction\";\nimport {\n type InstallOrUpdateAppsDAIntermediateValue,\n type InstallOrUpdateAppsDAOutput,\n} from \"@api/device-action/os/InstallOrUpdateApps/types\";\nimport { ListAppsDeviceAction } from \"@api/device-action/os/ListApps/ListAppsDeviceAction\";\nimport { OpenAppDeviceAction } from \"@api/device-action/os/OpenAppDeviceAction/OpenAppDeviceAction\";\nimport { type DmkError } from \"@api/Error\";\nimport { ListInstalledAppsDeviceAction } from \"@api/secure-channel/device-action/ListInstalledApps/ListInstalledAppsDeviceAction\";\nimport { type InstalledApp } from \"@api/secure-channel/device-action/ListInstalledApps/types\";\n\nimport { type BTC_APP } from \"./data\";\n\ntype App = typeof BTC_APP;\n\nexport const setupListAppsMock = (apps: App[], error = false) => {\n (ListAppsDeviceAction as Mock).mockImplementation(() => ({\n makeStateMachine: vi.fn().mockImplementation(() =>\n createMachine({\n id: \"MockListAppsDeviceAction\",\n initial: \"ready\",\n states: {\n ready: {\n after: {\n 0: \"done\",\n },\n entry: assign({\n intermediateValue: () => ({\n requiredUserInteraction: UserInteractionRequired.AllowListApps,\n }),\n }),\n },\n done: {\n type: \"final\",\n },\n },\n output: () => {\n return error\n ? Left(new UnknownDAError(\"ListApps failed\"))\n : Right(apps);\n },\n }),\n ),\n }));\n};\n\nexport const setupGetDeviceMetadataMock = (\n metadata: GetDeviceMetadataDAOutput,\n error = false,\n) => {\n (GetDeviceMetadataDeviceAction as Mock).mockImplementation(() => ({\n makeStateMachine: vi.fn().mockImplementation(() =>\n createMachine({\n id: \"MockGetDeviceMetadataDeviceAction\",\n initial: \"ready\",\n states: {\n ready: {\n after: {\n 0: \"done\",\n },\n entry: assign({\n intermediateValue: () => ({\n requiredUserInteraction: UserInteractionRequired.None,\n }),\n }),\n },\n done: {\n type: \"final\",\n },\n },\n output: () => {\n return error\n ? Left(new UnknownDAError(\"GetDeviceMetadata failed\"))\n : Right(metadata);\n },\n }),\n ),\n }));\n};\n\nexport const setupInstallOrUpdateAppsMock = (\n result: InstallOrUpdateAppsDAOutput,\n intermediateValue: InstallOrUpdateAppsDAIntermediateValue,\n error = false,\n) => {\n (InstallOrUpdateAppsDeviceAction as Mock).mockImplementation(() => ({\n makeStateMachine: vi.fn().mockImplementation(() =>\n createMachine({\n id: \"MockInstallOrUpdateAppsDeviceAction\",\n initial: \"ready\",\n states: {\n ready: {\n after: {\n 0: \"done\",\n },\n entry: assign({\n intermediateValue: () => intermediateValue,\n }),\n },\n done: {\n type: \"final\",\n },\n },\n output: () => {\n return error\n ? Left(new UnknownDAError(\"InstallOrUpdateApps failed\"))\n : Right(result);\n },\n }),\n ),\n }));\n};\n\nexport const setupOpenAppMock = (error: boolean = false) => {\n (OpenAppDeviceAction as Mock).mockImplementation(() => ({\n makeStateMachine: vi.fn().mockImplementation(() =>\n createMachine({\n initial: \"ready\",\n states: {\n ready: {\n entry: assign({\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.ConfirmOpenApp,\n },\n }),\n after: {\n 0: \"done\",\n },\n },\n done: {\n type: \"final\",\n },\n },\n output: () => {\n return error\n ? Left(new UnknownDAError(\"OpenApp failed\"))\n : Right(undefined);\n },\n }),\n ),\n }));\n};\n\nexport const setupGoToDashboardMock = (error: boolean = false) => {\n (GoToDashboardDeviceAction as Mock).mockImplementation(() => ({\n makeStateMachine: vi.fn().mockImplementation(() =>\n createMachine({\n id: \"MockGoToDashboardDeviceAction\",\n initial: \"ready\",\n states: {\n ready: {\n after: {\n 0: \"done\",\n },\n entry: assign({\n intermediateValue: () => ({\n requiredUserInteraction: UserInteractionRequired.None,\n }),\n }),\n },\n done: {\n type: \"final\",\n },\n },\n output: () => {\n return error\n ? Left(new UnknownDAError(\"GoToDashboard failed\"))\n : Right(undefined);\n },\n }),\n ),\n }));\n};\n\nexport const setupGetDeviceStatusMock = (\n outputs: ReadonlyArray<\n { currentApp: string; currentAppVersion: string } | DmkError\n > = [\n {\n currentApp: \"BOLOS\",\n currentAppVersion: \"1.0.0\",\n },\n ],\n) => {\n const outputFn = vi.fn();\n\n for (const output of outputs) {\n outputFn.mockImplementationOnce(() =>\n \"currentApp\" in output ? Right(output) : Left(output),\n );\n }\n (GetDeviceStatusDeviceAction as Mock).mockImplementation(() => ({\n makeStateMachine: vi.fn().mockImplementation(() =>\n createMachine({\n id: \"MockGetDeviceStatusDeviceAction\",\n initial: \"ready\",\n states: {\n ready: {\n after: {\n 0: \"done\",\n },\n entry: assign({\n intermediateValue: () => ({\n requiredUserInteraction: UserInteractionRequired.None,\n }),\n }),\n },\n done: {\n type: \"final\",\n },\n },\n output: outputFn,\n }),\n ),\n }));\n};\n\nexport const setupListInstalledAppsMock = (\n outputs: Array<{ installedApps: InstalledApp[] } | DmkError> = [],\n) => {\n (ListInstalledAppsDeviceAction as Mock).mockImplementation(() => ({\n makeStateMachine: vi.fn().mockImplementation(() =>\n createMachine({\n id: \"MockListInstalledAppsDeviceAction\",\n initial: \"ready\",\n states: {\n ready: {\n after: {\n 0: \"done\",\n },\n entry: assign({\n intermediateValue: () => ({\n requiredUserInteraction: UserInteractionRequired.None,\n }),\n }),\n },\n done: {\n type: \"final\",\n },\n },\n output: outputs\n .reduce(\n (mockFn, output) =>\n mockFn.mockImplementationOnce(() =>\n \"installedApps\" in output ? Right(output) : Left(output),\n ),\n vi.fn(),\n )\n .mockImplementation(() => Right([])),\n }),\n ),\n }));\n};\n"],
5
- "mappings": "yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,gCAAAE,EAAA,6BAAAC,EAAA,2BAAAC,EAAA,iCAAAC,EAAA,sBAAAC,EAAA,+BAAAC,EAAA,qBAAAC,IAAA,eAAAC,EAAAT,GAAA,IAAAU,EAA4B,qBAE5BC,EAAsC,kBAEtCC,EAAwC,4DACxCC,EAA+B,wCAC/BC,EAA8C,iFAE9CC,EAA4C,6EAC5CC,EAA0C,yEAC1CC,EAAgD,qFAKhDC,EAAqC,+DACrCC,EAAoC,yEAEpCC,EAA8C,6FAOvC,MAAMd,EAAoB,CAACe,EAAaC,EAAQ,KAAU,CAC9D,uBAA8B,mBAAmB,KAAO,CACvD,iBAAkB,GAAG,GAAG,EAAE,mBAAmB,OAC3C,iBAAc,CACZ,GAAI,2BACJ,QAAS,QACT,OAAQ,CACN,MAAO,CACL,MAAO,CACL,EAAG,MACL,EACA,SAAO,UAAO,CACZ,kBAAmB,KAAO,CACxB,wBAAyB,0BAAwB,aACnD,EACF,CAAC,CACH,EACA,KAAM,CACJ,KAAM,OACR,CACF,EACA,OAAQ,IACCA,KACH,QAAK,IAAI,iBAAe,iBAAiB,CAAC,KAC1C,SAAMD,CAAI,CAElB,CAAC,CACH,CACF,EAAE,CACJ,EAEanB,EAA6B,CACxCqB,EACAD,EAAQ,KACL,CACF,gC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ACG,EAAQD,IACPC,EAAO,uBAAuB,IAC5B,kBAAmBD,KAAS,SAAMA,CAAM,KAAI,QAAKA,CAAM,CACzD,EACF,GAAG,GAAG,CACR,EACC,mBAAmB,OAAM,SAAM,CAAC,CAAC,CAAC,CACvC,CAAC,CACH,CACF,EAAE,CACJ",
6
- "names": ["setupTestMachine_exports", "__export", "setupGetDeviceMetadataMock", "setupGetDeviceStatusMock", "setupGoToDashboardMock", "setupInstallOrUpdateAppsMock", "setupListAppsMock", "setupListInstalledAppsMock", "setupOpenAppMock", "__toCommonJS", "import_purify_ts", "import_xstate", "import_UserInteractionRequired", "import_Errors", "import_GetDeviceMetadataDeviceAction", "import_GetDeviceStatusDeviceAction", "import_GoToDashboardDeviceAction", "import_InstallOrUpdateAppsDeviceAction", "import_ListAppsDeviceAction", "import_OpenAppDeviceAction", "import_ListInstalledAppsDeviceAction", "apps", "error", "metadata", "result", "intermediateValue", "outputs", "outputFn", "output", "mockFn"]
4
+ "sourcesContent": ["import { Left, Right } from \"purify-ts\";\nimport { type Mock } from \"vitest\";\nimport { assign, createMachine } from \"xstate\";\n\nimport { UserInteractionRequired } from \"@api/device-action/model/UserInteractionRequired\";\nimport { UnknownDAError } from \"@api/device-action/os/Errors\";\nimport { GetDeviceMetadataDeviceAction } from \"@api/device-action/os/GetDeviceMetadata/GetDeviceMetadataDeviceAction\";\nimport {\n type GetDeviceMetadataDAOutput,\n getDeviceMetadataDAStateStep,\n} from \"@api/device-action/os/GetDeviceMetadata/types\";\nimport { GetDeviceStatusDeviceAction } from \"@api/device-action/os/GetDeviceStatus/GetDeviceStatusDeviceAction\";\nimport { getDeviceStatusDAStateStep } from \"@api/device-action/os/GetDeviceStatus/types\";\nimport { GoToDashboardDeviceAction } from \"@api/device-action/os/GoToDashboard/GoToDashboardDeviceAction\";\nimport { goToDashboardDAStateStep } from \"@api/device-action/os/GoToDashboard/types\";\nimport { InstallOrUpdateAppsDeviceAction } from \"@api/device-action/os/InstallOrUpdateApps/InstallOrUpdateAppsDeviceAction\";\nimport {\n type InstallOrUpdateAppsDAIntermediateValue,\n type InstallOrUpdateAppsDAOutput,\n} from \"@api/device-action/os/InstallOrUpdateApps/types\";\nimport { ListAppsDeviceAction } from \"@api/device-action/os/ListApps/ListAppsDeviceAction\";\nimport { listAppsDAStateStep } from \"@api/device-action/os/ListApps/types\";\nimport { OpenAppDeviceAction } from \"@api/device-action/os/OpenAppDeviceAction/OpenAppDeviceAction\";\nimport { openAppDAStateStep } from \"@api/device-action/os/OpenAppDeviceAction/types\";\nimport { type DmkError } from \"@api/Error\";\nimport { ListInstalledAppsDeviceAction } from \"@api/secure-channel/device-action/ListInstalledApps/ListInstalledAppsDeviceAction\";\nimport { type InstalledApp } from \"@api/secure-channel/device-action/ListInstalledApps/types\";\n\nimport { type BTC_APP } from \"./data\";\n\ntype App = typeof BTC_APP;\n\nexport const setupListAppsMock = (apps: App[], error = false) => {\n (ListAppsDeviceAction as Mock).mockImplementation(() => ({\n makeStateMachine: vi.fn().mockImplementation(() =>\n createMachine({\n id: \"MockListAppsDeviceAction\",\n initial: \"ready\",\n states: {\n ready: {\n after: {\n 0: \"done\",\n },\n entry: assign({\n intermediateValue: () => ({\n requiredUserInteraction: UserInteractionRequired.AllowListApps,\n step: listAppsDAStateStep.LIST_APPS,\n }),\n }),\n },\n done: {\n type: \"final\",\n },\n },\n output: () => {\n return error\n ? Left(new UnknownDAError(\"ListApps failed\"))\n : Right(apps);\n },\n }),\n ),\n }));\n};\n\nexport const setupGetDeviceMetadataMock = (\n metadata: GetDeviceMetadataDAOutput,\n error = false,\n) => {\n (GetDeviceMetadataDeviceAction as Mock).mockImplementation(() => ({\n makeStateMachine: vi.fn().mockImplementation(() =>\n createMachine({\n id: \"MockGetDeviceMetadataDeviceAction\",\n initial: \"ready\",\n states: {\n ready: {\n after: {\n 0: \"done\",\n },\n entry: assign({\n intermediateValue: () => ({\n requiredUserInteraction: UserInteractionRequired.None,\n step: getDeviceMetadataDAStateStep.GET_DEVICE_METADATA,\n }),\n }),\n },\n done: {\n type: \"final\",\n },\n },\n output: () => {\n return error\n ? Left(new UnknownDAError(\"GetDeviceMetadata failed\"))\n : Right(metadata);\n },\n }),\n ),\n }));\n};\n\nexport const setupInstallOrUpdateAppsMock = (\n result: InstallOrUpdateAppsDAOutput,\n intermediateValue: InstallOrUpdateAppsDAIntermediateValue,\n error = false,\n) => {\n (InstallOrUpdateAppsDeviceAction as Mock).mockImplementation(() => ({\n makeStateMachine: vi.fn().mockImplementation(() =>\n createMachine({\n id: \"MockInstallOrUpdateAppsDeviceAction\",\n initial: \"ready\",\n states: {\n ready: {\n after: {\n 0: \"done\",\n },\n entry: assign({\n intermediateValue: () => intermediateValue,\n }),\n },\n done: {\n type: \"final\",\n },\n },\n output: () => {\n return error\n ? Left(new UnknownDAError(\"InstallOrUpdateApps failed\"))\n : Right(result);\n },\n }),\n ),\n }));\n};\n\nexport const setupOpenAppMock = (error: boolean = false) => {\n (OpenAppDeviceAction as Mock).mockImplementation(() => ({\n makeStateMachine: vi.fn().mockImplementation(() =>\n createMachine({\n initial: \"ready\",\n states: {\n ready: {\n entry: assign({\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.ConfirmOpenApp,\n step: openAppDAStateStep.GET_DEVICE_STATUS,\n },\n }),\n after: {\n 0: \"done\",\n },\n },\n done: {\n type: \"final\",\n },\n },\n output: () => {\n return error\n ? Left(new UnknownDAError(\"OpenApp failed\"))\n : Right(undefined);\n },\n }),\n ),\n }));\n};\n\nexport const setupGoToDashboardMock = (error: boolean = false) => {\n (GoToDashboardDeviceAction as Mock).mockImplementation(() => ({\n makeStateMachine: vi.fn().mockImplementation(() =>\n createMachine({\n id: \"MockGoToDashboardDeviceAction\",\n initial: \"ready\",\n states: {\n ready: {\n after: {\n 0: \"done\",\n },\n entry: assign({\n intermediateValue: () => ({\n requiredUserInteraction: UserInteractionRequired.None,\n step: goToDashboardDAStateStep.GET_DEVICE_STATUS,\n }),\n }),\n },\n done: {\n type: \"final\",\n },\n },\n output: () => {\n return error\n ? Left(new UnknownDAError(\"GoToDashboard failed\"))\n : Right(undefined);\n },\n }),\n ),\n }));\n};\n\nexport const setupGetDeviceStatusMock = (\n outputs: ReadonlyArray<\n { currentApp: string; currentAppVersion: string } | DmkError\n > = [\n {\n currentApp: \"BOLOS\",\n currentAppVersion: \"1.0.0\",\n },\n ],\n) => {\n const outputFn = vi.fn();\n\n for (const output of outputs) {\n outputFn.mockImplementationOnce(() =>\n \"currentApp\" in output ? Right(output) : Left(output),\n );\n }\n (GetDeviceStatusDeviceAction as Mock).mockImplementation(() => ({\n makeStateMachine: vi.fn().mockImplementation(() =>\n createMachine({\n id: \"MockGetDeviceStatusDeviceAction\",\n initial: \"ready\",\n states: {\n ready: {\n after: {\n 0: \"done\",\n },\n entry: assign({\n intermediateValue: () => ({\n requiredUserInteraction: UserInteractionRequired.None,\n step: getDeviceStatusDAStateStep.ONBOARD_CHECK,\n }),\n }),\n },\n done: {\n type: \"final\",\n },\n },\n output: outputFn,\n }),\n ),\n }));\n};\n\nexport const setupListInstalledAppsMock = (\n outputs: Array<{ installedApps: InstalledApp[] } | DmkError> = [],\n) => {\n (ListInstalledAppsDeviceAction as Mock).mockImplementation(() => ({\n makeStateMachine: vi.fn().mockImplementation(() =>\n createMachine({\n id: \"MockListInstalledAppsDeviceAction\",\n initial: \"ready\",\n states: {\n ready: {\n after: {\n 0: \"done\",\n },\n entry: assign({\n intermediateValue: () => ({\n requiredUserInteraction: UserInteractionRequired.None,\n }),\n }),\n },\n done: {\n type: \"final\",\n },\n },\n output: outputs\n .reduce(\n (mockFn, output) =>\n mockFn.mockImplementationOnce(() =>\n \"installedApps\" in output ? Right(output) : Left(output),\n ),\n vi.fn(),\n )\n .mockImplementation(() => Right([])),\n }),\n ),\n }));\n};\n"],
5
+ "mappings": "yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,gCAAAE,EAAA,6BAAAC,EAAA,2BAAAC,EAAA,iCAAAC,EAAA,sBAA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C,CACH,CACF,EAAE,CACJ,EAEapB,EAA2B,CACtCwB,EAEI,CACF,CACE,WAAY,QACZ,kBAAmB,OACrB,CACF,IACG,CACH,MAAMC,EAAW,GAAG,GAAG,EAEvB,UAAWC,KAAUF,EACnBC,EAAS,uBAAuB,IAC9B,eAAgBC,KAAS,SAAMA,CAAM,KAAI,QAAKA,CAAM,CACtD,EAED,8BAAqC,mBAAmB,KAAO,CAC9D,iBAAkB,GAAG,GAAG,EAAE,mBAAmB,OAC3C,iBAAc,CACZ,GAAI,kCACJ,QAAS,QACT,OAAQ,CACN,MAAO,CACL,MAAO,CACL,EAAG,MACL,EACA,SAAO,UAAO,CACZ,kBAAmB,KAAO,CACxB,wBAAyB,0BAAwB,KACjD,KAAM,6BAA2B,aACnC,EACF,CAAC,CACH,EACA,KAAM,CACJ,KAAM,OACR,CACF,EACA,OAAQD,CACV,CAAC,CACH,CACF,EAAE,CACJ,EAEarB,EAA6B,CACxCoB,EAA+D,CAAC,IAC7D,CACF,gCAAuC,mBAAmB,KAAO,CAChE,iBAAkB,GAAG,GAAG,EAAE,mBAAmB,OAC3C,iBAAc,CACZ,GAAI,oCACJ,QAAS,QACT,OAAQ,CACN,MAAO,CACL,MAAO,CACL,EAAG,MACL,EACA,SAAO,UAAO,CACZ,kBAAmB,KAAO,CACxB,wBAAyB,0BAAwB,IACnD,EACF,CAAC,CACH,EACA,KAAM,CACJ,KAAM,OACR,CACF,EACA,OAAQA,EACL,OACC,CAACG,EAAQD,IACPC,EAAO,uBAAuB,IAC5B,kBAAmBD,KAAS,SAAMA,CAAM,KAAI,QAAKA,CAAM,CACzD,EACF,GAAG,GAAG,CACR,EACC,mBAAmB,OAAM,SAAM,CAAC,CAAC,CAAC,CACvC,CAAC,CACH,CACF,EAAE,CACJ",
6
+ "names": ["setupTestMachine_exports", "__export", "setupGetDeviceMetadataMock", "setupGetDeviceStatusMock", "setupGoToDashboardMock", "setupInstallOrUpdateAppsMock", "setupListAppsMock", "setupListInstalledAppsMock", "setupOpenAppMock", "__toCommonJS", "import_purify_ts", "import_xstate", "import_UserInteractionRequired", "import_Errors", "import_GetDeviceMetadataDeviceAction", "import_types", "import_GetDeviceStatusDeviceAction", "import_GoToDashboardDeviceAction", "import_InstallOrUpdateAppsDeviceAction", "import_ListAppsDeviceAction", "import_OpenAppDeviceAction", "import_ListInstalledAppsDeviceAction", "apps", "error", "metadata", "result", "intermediateValue", "outputs", "outputFn", "output", "mockFn"]
7
7
  }
@@ -1,2 +1,2 @@
1
- "use strict";var o=Object.defineProperty;var A=Object.getOwnPropertyDescriptor;var T=Object.getOwnPropertyNames;var I=Object.prototype.hasOwnProperty;var m=(r,t)=>{for(var s in t)o(r,s,{get:t[s],enumerable:!0})},C=(r,t,s,e)=>{if(t&&typeof t=="object"||typeof t=="function")for(let n of T(t))!I.call(r,n)&&n!==s&&o(r,n,{get:()=>t[n],enumerable:!(e=A(t,n))||e.enumerable});return r};var d=r=>C(o({},"__esModule",{value:!0}),r);var S={};m(S,{CallTaskInAppDeviceAction:()=>D});module.exports=d(S);var p=require("purify-ts"),a=require("xstate"),l=require("../../../command/model/CommandResult"),i=require("../../../device-action/model/UserInteractionRequired"),c=require("../../../device-action/os/Errors"),u=require("../../../device-action/os/OpenAppDeviceAction/OpenAppDeviceAction"),k=require("../../../device-action/xstate-utils/XStateDeviceAction");class D extends k.XStateDeviceAction{makeStateMachine(t){const{callTask:s}=this.extractDependencies(t);return(0,a.setup)({types:{input:{},context:{},output:{}},actors:{callTask:(0,a.fromPromise)(s),openAppStateMachine:new u.OpenAppDeviceAction({input:{appName:this.input.appName}}).makeStateMachine(t)},guards:{skipOpenApp:()=>this.input.skipOpenApp,noInternalError:({context:e})=>e._internalState.error===null},actions:{assignErrorFromEvent:(0,a.assign)({_internalState:e=>({...e.context._internalState,error:e.event.error})})}}).createMachine({id:"CallTaskInAppDeviceAction",initial:"InitialState",context:({input:e})=>({input:e,intermediateValue:{requiredUserInteraction:i.UserInteractionRequired.None},_internalState:{taskResponse:null,error:null}}),states:{InitialState:{always:[{target:"CallTask",guard:"skipOpenApp"},"OpenAppDeviceAction"]},OpenAppDeviceAction:{invoke:{id:"openAppStateMachine",input:{appName:this.input.appName},src:"openAppStateMachine",onSnapshot:{actions:(0,a.assign)({intermediateValue:e=>e.event.snapshot.context.intermediateValue})},onDone:{actions:(0,a.assign)({_internalState:e=>e.event.output.caseOf({Right:()=>e.context._internalState,Left:n=>({...e.context._internalState,error:n})})}),target:"CheckOpenAppDeviceActionResult"}}},CheckOpenAppDeviceActionResult:{always:[{target:"CallTask",guard:"noInternalError"},"Error"]},CallTask:{entry:(0,a.assign)({intermediateValue:{requiredUserInteraction:this.input.requiredUserInteraction}}),exit:(0,a.assign)({intermediateValue:{requiredUserInteraction:i.UserInteractionRequired.None}}),invoke:{id:"callTask",src:"callTask",input:e=>e.context.input.task,onDone:{target:"CallTaskResultCheck",actions:[(0,a.assign)({_internalState:({event:e,context:n})=>(0,l.isSuccessCommandResult)(e.output)?{...n._internalState,taskResponse:e.output.data}:{...n._internalState,error:e.output.error}})]},onError:{target:"Error",actions:"assignErrorFromEvent"}}},CallTaskResultCheck:{always:[{target:"Success",guard:"noInternalError"},"Error"]},Success:{type:"final"},Error:{type:"final"}},output:({context:e})=>e._internalState.taskResponse?(0,p.Right)(e._internalState.taskResponse):(0,p.Left)(e._internalState.error||new c.UnknownDAError("No error in final state"))})}extractDependencies(t){return{callTask:s=>s.input(t)}}}0&&(module.exports={CallTaskInAppDeviceAction});
1
+ "use strict";var i=Object.defineProperty;var T=Object.getOwnPropertyDescriptor;var I=Object.getOwnPropertyNames;var C=Object.prototype.hasOwnProperty;var m=(r,t)=>{for(var s in t)i(r,s,{get:t[s],enumerable:!0})},d=(r,t,s,e)=>{if(t&&typeof t=="object"||typeof t=="function")for(let n of I(t))!C.call(r,n)&&n!==s&&i(r,n,{get:()=>t[n],enumerable:!(e=T(t,n))||e.enumerable});return r};var S=r=>d(i({},"__esModule",{value:!0}),r);var E={};m(E,{CallTaskInAppDeviceAction:()=>D});module.exports=S(E);var o=require("purify-ts"),a=require("xstate"),c=require("../../../command/model/CommandResult"),l=require("../../../device-action/model/UserInteractionRequired"),u=require("../../../device-action/os/Errors"),k=require("../../../device-action/os/OpenAppDeviceAction/OpenAppDeviceAction"),A=require("../../../device-action/xstate-utils/XStateDeviceAction"),p=require("./CallTaskInAppDeviceActionTypes");class D extends A.XStateDeviceAction{makeStateMachine(t){const{callTask:s}=this.extractDependencies(t);return(0,a.setup)({types:{input:{},context:{},output:{}},actors:{callTask:(0,a.fromPromise)(s),openAppStateMachine:new k.OpenAppDeviceAction({input:{appName:this.input.appName}}).makeStateMachine(t)},guards:{skipOpenApp:()=>this.input.skipOpenApp,noInternalError:({context:e})=>e._internalState.error===null},actions:{assignErrorFromEvent:(0,a.assign)({_internalState:e=>({...e.context._internalState,error:e.event.error})})}}).createMachine({id:"CallTaskInAppDeviceAction",initial:"InitialState",context:({input:e})=>({input:e,intermediateValue:{requiredUserInteraction:l.UserInteractionRequired.None,step:p.callTaskInAppDAStateStep.OPEN_APP},_internalState:{taskResponse:null,error:null}}),states:{InitialState:{always:[{target:"CallTask",guard:"skipOpenApp"},"OpenAppDeviceAction"]},OpenAppDeviceAction:{invoke:{id:"openAppStateMachine",input:{appName:this.input.appName},src:"openAppStateMachine",onSnapshot:{actions:(0,a.assign)({intermediateValue:e=>e.event.snapshot.context.intermediateValue})},onDone:{actions:(0,a.assign)({_internalState:e=>e.event.output.caseOf({Right:()=>e.context._internalState,Left:n=>({...e.context._internalState,error:n})})}),target:"CheckOpenAppDeviceActionResult"}}},CheckOpenAppDeviceActionResult:{always:[{target:"CallTask",guard:"noInternalError"},"Error"]},CallTask:{entry:(0,a.assign)({intermediateValue:{requiredUserInteraction:this.input.requiredUserInteraction,step:p.callTaskInAppDAStateStep.CALL_TASK}}),exit:(0,a.assign)({intermediateValue:{requiredUserInteraction:l.UserInteractionRequired.None,step:p.callTaskInAppDAStateStep.CALL_TASK}}),invoke:{id:"callTask",src:"callTask",input:e=>e.context.input.task,onDone:{target:"CallTaskResultCheck",actions:[(0,a.assign)({_internalState:({event:e,context:n})=>(0,c.isSuccessCommandResult)(e.output)?{...n._internalState,taskResponse:e.output.data}:{...n._internalState,error:e.output.error}})]},onError:{target:"Error",actions:"assignErrorFromEvent"}}},CallTaskResultCheck:{always:[{target:"Success",guard:"noInternalError"},"Error"]},Success:{type:"final"},Error:{type:"final"}},output:({context:e})=>e._internalState.taskResponse?(0,o.Right)(e._internalState.taskResponse):(0,o.Left)(e._internalState.error||new u.UnknownDAError("No error in final state"))})}extractDependencies(t){return{callTask:s=>s.input(t)}}}0&&(module.exports={CallTaskInAppDeviceAction});
2
2
  //# sourceMappingURL=CallTaskInAppDeviceAction.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../../../../src/api/device-action/os/CallTaskInAppDeviceAction/CallTaskInAppDeviceAction.ts"],
4
- "sourcesContent": ["import { Left, Right } from \"purify-ts\";\nimport { assign, fromPromise, setup } from \"xstate\";\n\nimport {\n type CommandResult,\n isSuccessCommandResult,\n} from \"@api/command/model/CommandResult\";\nimport { type InternalApi } from \"@api/device-action/DeviceAction\";\nimport { UserInteractionRequired } from \"@api/device-action/model/UserInteractionRequired\";\nimport { UnknownDAError } from \"@api/device-action/os/Errors\";\nimport { OpenAppDeviceAction } from \"@api/device-action/os/OpenAppDeviceAction/OpenAppDeviceAction\";\nimport { type StateMachineTypes } from \"@api/device-action/xstate-utils/StateMachineTypes\";\nimport {\n type DeviceActionStateMachine,\n XStateDeviceAction,\n} from \"@api/device-action/xstate-utils/XStateDeviceAction\";\n\nimport {\n type CallTaskInAppDAError,\n type CallTaskInAppDAInput,\n type CallTaskInAppDAIntermediateValue,\n type CallTaskInAppDAInternalState,\n type CallTaskInAppDAOutput,\n} from \"./CallTaskInAppDeviceActionTypes\";\n\n/**\n * Tries to open an app on the device, and if it is successful, calls a task\n * in the app.\n * The output will be the result of the task.\n *\n * ```ts\n * input: {\n * appName: string;\n * task: (internalApi: InternalApi) => Promise<CommandResult<TaskResponse, TaskErrorCodes>>;\n * requiredUserInteraction: UserInteraction;\n * }\n * ```\n *\n * Example of usage:\n *\n * ```ts\n * const deviceAction = new CallTaskInAppDeviceAction({\n * input: {\n * appName: \"MyApp\",\n * task: async (internalApi: InternalApi) => internalApi.sendCommand(new MyAppSpecificCommand()),\n * requiredUserInteraction: UserInteractionRequired.None,\n * },\n * });\n * dmk.executeDeviceAction({ sessionId: \"mySessionId\", deviceAction });\n * ```\n */\nexport class CallTaskInAppDeviceAction<\n TaskResponse,\n TaskErrorCodes,\n UserInteraction extends UserInteractionRequired,\n> extends XStateDeviceAction<\n CallTaskInAppDAOutput<TaskResponse>,\n CallTaskInAppDAInput<TaskResponse, TaskErrorCodes, UserInteraction>,\n CallTaskInAppDAError<TaskErrorCodes>,\n CallTaskInAppDAIntermediateValue<UserInteraction>,\n CallTaskInAppDAInternalState<TaskResponse, TaskErrorCodes>\n> {\n makeStateMachine(\n internalAPI: InternalApi,\n ): DeviceActionStateMachine<\n CallTaskInAppDAOutput<TaskResponse>,\n CallTaskInAppDAInput<TaskResponse, TaskErrorCodes, UserInteraction>,\n CallTaskInAppDAError<TaskErrorCodes>,\n CallTaskInAppDAIntermediateValue<UserInteraction>,\n CallTaskInAppDAInternalState<TaskResponse, TaskErrorCodes>\n > {\n type types = StateMachineTypes<\n CallTaskInAppDAOutput<TaskResponse>,\n CallTaskInAppDAInput<TaskResponse, TaskErrorCodes, UserInteraction>,\n CallTaskInAppDAError<TaskErrorCodes>,\n CallTaskInAppDAIntermediateValue<UserInteraction>,\n CallTaskInAppDAInternalState<TaskResponse, TaskErrorCodes>\n >;\n\n const { callTask } = this.extractDependencies(internalAPI);\n\n return setup({\n types: {\n input: {} as types[\"input\"],\n context: {} as types[\"context\"],\n output: {} as types[\"output\"],\n },\n actors: {\n callTask: fromPromise(callTask),\n openAppStateMachine: new OpenAppDeviceAction({\n input: {\n appName: this.input.appName,\n },\n }).makeStateMachine(internalAPI),\n },\n guards: {\n skipOpenApp: () => this.input.skipOpenApp,\n noInternalError: ({ context }) => context._internalState.error === null,\n },\n actions: {\n assignErrorFromEvent: assign({\n _internalState: (_) => ({\n ..._.context._internalState,\n error: _.event[\"error\"], // NOTE: it should never happen, the error is not typed anymore here\n }),\n }),\n },\n }).createMachine({\n id: \"CallTaskInAppDeviceAction\",\n initial: \"InitialState\",\n context: ({ input }) => {\n return {\n input: input,\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.None,\n },\n _internalState: {\n taskResponse: null,\n error: null,\n },\n };\n },\n states: {\n InitialState: {\n always: [\n {\n target: \"CallTask\",\n guard: \"skipOpenApp\",\n },\n \"OpenAppDeviceAction\",\n ],\n },\n OpenAppDeviceAction: {\n invoke: {\n id: \"openAppStateMachine\",\n input: {\n appName: this.input.appName,\n },\n src: \"openAppStateMachine\",\n onSnapshot: {\n actions: assign({\n intermediateValue: (_) =>\n _.event.snapshot.context.intermediateValue,\n }),\n },\n onDone: {\n actions: assign({\n _internalState: (_) => {\n return _.event.output.caseOf<\n CallTaskInAppDAInternalState<TaskResponse, TaskErrorCodes>\n >({\n Right: () => _.context._internalState,\n Left: (error) => ({\n ..._.context._internalState,\n error,\n }),\n });\n },\n }),\n target: \"CheckOpenAppDeviceActionResult\",\n },\n },\n },\n CheckOpenAppDeviceActionResult: {\n always: [\n {\n target: \"CallTask\",\n guard: \"noInternalError\",\n },\n \"Error\",\n ],\n },\n CallTask: {\n entry: assign({\n intermediateValue: {\n requiredUserInteraction: this.input.requiredUserInteraction,\n },\n }),\n exit: assign({\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.None,\n },\n }),\n invoke: {\n id: \"callTask\",\n src: \"callTask\",\n input: (_: { context: types[\"context\"] }) => _.context.input.task,\n onDone: {\n target: \"CallTaskResultCheck\",\n actions: [\n assign({\n _internalState: ({ event, context }) => {\n if (isSuccessCommandResult(event.output)) {\n return {\n ...context._internalState,\n taskResponse: event.output.data,\n };\n }\n return {\n ...context._internalState,\n error: event.output.error,\n };\n },\n }),\n ],\n },\n onError: {\n target: \"Error\",\n actions: \"assignErrorFromEvent\",\n },\n },\n },\n CallTaskResultCheck: {\n always: [\n {\n target: \"Success\",\n guard: \"noInternalError\",\n },\n \"Error\",\n ],\n },\n Success: {\n type: \"final\",\n },\n Error: {\n type: \"final\",\n },\n },\n output: ({ context }) =>\n context._internalState.taskResponse\n ? Right(context._internalState.taskResponse)\n : Left(\n context._internalState.error ||\n new UnknownDAError(\"No error in final state\"),\n ),\n });\n }\n\n extractDependencies(internalApi: InternalApi) {\n return {\n callTask: (_: {\n input: (\n internalApi: InternalApi,\n ) => Promise<CommandResult<TaskResponse, TaskErrorCodes>>;\n }): Promise<CommandResult<TaskResponse, TaskErrorCodes>> =>\n _.input(internalApi),\n };\n }\n}\n"],
5
- "mappings": "yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,+BAAAE,IAAA,eAAAC,EAAAH,GAAA,IAAAI,EAA4B,qBAC5BC,EAA2C,kBAE3CC,EAGO,4CAEPC,EAAwC,4DACxCC,EAA+B,wCAC/BC,EAAoC,yEAEpCC,EAGO,8DAoCA,MAAMR,UAIH,oBAMR,CACA,iBACES,EAOA,CASA,KAAM,CAAE,SAAAC,CAAS,EAAI,KAAK,oBAAoBD,CAAW,EAEzD,SAAO,SAAM,CACX,MAAO,CACL,MAAO,CAAC,EACR,QAAS,CAAC,EACV,OAAQ,CAAC,CACX,EACA,OAAQ,CACN,YAAU,eAAYC,CAAQ,EAC9B,oBAAqB,IAAI,sBAAoB,CAC3C,MAAO,CACL,QAAS,KAAK,MAAM,OACtB,CACF,CAAC,EAAE,iBAAiBD,CAAW,CACjC,EACA,OAAQ,CACN,YAAa,IAAM,KAAK,MAAM,YAC9B,gBAAiB,CAAC,CAAE,QAAAE,CAAQ,IAAMA,EAAQ,eAAe,QAAU,IACrE,EACA,QAAS,CACP,wBAAsB,UAAO,CAC3B,eAAiBC,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AM,OAAO,IAC7B,EAEK,CACL,GAAGJ,EAAQ,eACX,MAAOI,EAAM,OAAO,KACtB,CAEJ,CAAC,CACH,CACF,EACA,QAAS,CACP,OAAQ,QACR,QAAS,sBACX,CACF,CACF,EACA,oBAAqB,CACnB,OAAQ,CACN,CACE,OAAQ,UACR,MAAO,iBACT,EACA,OACF,CACF,EACA,QAAS,CACP,KAAM,OACR,EACA,MAAO,CACL,KAAM,OACR,CACF,EACA,OAAQ,CAAC,CAAE,QAAAJ,CAAQ,IACjBA,EAAQ,eAAe,gBACnB,SAAMA,EAAQ,eAAe,YAAY,KACzC,QACEA,EAAQ,eAAe,OACrB,IAAI,iBAAe,yBAAyB,CAChD,CACR,CAAC,CACH,CAEA,oBAAoBK,EAA0B,CAC5C,MAAO,CACL,SAAWJ,GAKTA,EAAE,MAAMI,CAAW,CACvB,CACF,CACF",
6
- "names": ["CallTaskInAppDeviceAction_exports", "__export", "CallTaskInAppDeviceAction", "__toCommonJS", "import_purify_ts", "import_xstate", "import_CommandResult", "import_UserInteractionRequired", "import_Errors", "import_OpenAppDeviceAction", "import_XStateDeviceAction", "internalAPI", "callTask", "context", "_", "input", "error", "event", "internalApi"]
4
+ "sourcesContent": ["import { Left, Right } from \"purify-ts\";\nimport { assign, fromPromise, setup } from \"xstate\";\n\nimport {\n type CommandResult,\n isSuccessCommandResult,\n} from \"@api/command/model/CommandResult\";\nimport { type InternalApi } from \"@api/device-action/DeviceAction\";\nimport { UserInteractionRequired } from \"@api/device-action/model/UserInteractionRequired\";\nimport { UnknownDAError } from \"@api/device-action/os/Errors\";\nimport { OpenAppDeviceAction } from \"@api/device-action/os/OpenAppDeviceAction/OpenAppDeviceAction\";\nimport { type StateMachineTypes } from \"@api/device-action/xstate-utils/StateMachineTypes\";\nimport {\n type DeviceActionStateMachine,\n XStateDeviceAction,\n} from \"@api/device-action/xstate-utils/XStateDeviceAction\";\n\nimport {\n type CallTaskInAppDAError,\n type CallTaskInAppDAInput,\n type CallTaskInAppDAIntermediateValue,\n type CallTaskInAppDAInternalState,\n type CallTaskInAppDAOutput,\n callTaskInAppDAStateStep,\n} from \"./CallTaskInAppDeviceActionTypes\";\n\n/**\n * Tries to open an app on the device, and if it is successful, calls a task\n * in the app.\n * The output will be the result of the task.\n *\n * ```ts\n * input: {\n * appName: string;\n * task: (internalApi: InternalApi) => Promise<CommandResult<TaskResponse, TaskErrorCodes>>;\n * requiredUserInteraction: UserInteraction;\n * }\n * ```\n *\n * Example of usage:\n *\n * ```ts\n * const deviceAction = new CallTaskInAppDeviceAction({\n * input: {\n * appName: \"MyApp\",\n * task: async (internalApi: InternalApi) => internalApi.sendCommand(new MyAppSpecificCommand()),\n * requiredUserInteraction: UserInteractionRequired.None,\n * },\n * });\n * dmk.executeDeviceAction({ sessionId: \"mySessionId\", deviceAction });\n * ```\n */\nexport class CallTaskInAppDeviceAction<\n TaskResponse,\n TaskErrorCodes,\n UserInteraction extends UserInteractionRequired,\n> extends XStateDeviceAction<\n CallTaskInAppDAOutput<TaskResponse>,\n CallTaskInAppDAInput<TaskResponse, TaskErrorCodes, UserInteraction>,\n CallTaskInAppDAError<TaskErrorCodes>,\n CallTaskInAppDAIntermediateValue<UserInteraction>,\n CallTaskInAppDAInternalState<TaskResponse, TaskErrorCodes>\n> {\n makeStateMachine(\n internalAPI: InternalApi,\n ): DeviceActionStateMachine<\n CallTaskInAppDAOutput<TaskResponse>,\n CallTaskInAppDAInput<TaskResponse, TaskErrorCodes, UserInteraction>,\n CallTaskInAppDAError<TaskErrorCodes>,\n CallTaskInAppDAIntermediateValue<UserInteraction>,\n CallTaskInAppDAInternalState<TaskResponse, TaskErrorCodes>\n > {\n type types = StateMachineTypes<\n CallTaskInAppDAOutput<TaskResponse>,\n CallTaskInAppDAInput<TaskResponse, TaskErrorCodes, UserInteraction>,\n CallTaskInAppDAError<TaskErrorCodes>,\n CallTaskInAppDAIntermediateValue<UserInteraction>,\n CallTaskInAppDAInternalState<TaskResponse, TaskErrorCodes>\n >;\n\n const { callTask } = this.extractDependencies(internalAPI);\n\n return setup({\n types: {\n input: {} as types[\"input\"],\n context: {} as types[\"context\"],\n output: {} as types[\"output\"],\n },\n actors: {\n callTask: fromPromise(callTask),\n openAppStateMachine: new OpenAppDeviceAction({\n input: {\n appName: this.input.appName,\n },\n }).makeStateMachine(internalAPI),\n },\n guards: {\n skipOpenApp: () => this.input.skipOpenApp,\n noInternalError: ({ context }) => context._internalState.error === null,\n },\n actions: {\n assignErrorFromEvent: assign({\n _internalState: (_) => ({\n ..._.context._internalState,\n error: _.event[\"error\"], // NOTE: it should never happen, the error is not typed anymore here\n }),\n }),\n },\n }).createMachine({\n id: \"CallTaskInAppDeviceAction\",\n initial: \"InitialState\",\n context: ({ input }) => {\n return {\n input: input,\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.None,\n step: callTaskInAppDAStateStep.OPEN_APP,\n },\n _internalState: {\n taskResponse: null,\n error: null,\n },\n };\n },\n states: {\n InitialState: {\n always: [\n {\n target: \"CallTask\",\n guard: \"skipOpenApp\",\n },\n \"OpenAppDeviceAction\",\n ],\n },\n OpenAppDeviceAction: {\n invoke: {\n id: \"openAppStateMachine\",\n input: {\n appName: this.input.appName,\n },\n src: \"openAppStateMachine\",\n onSnapshot: {\n actions: assign({\n intermediateValue: (_) =>\n _.event.snapshot.context.intermediateValue,\n }),\n },\n onDone: {\n actions: assign({\n _internalState: (_) => {\n return _.event.output.caseOf<\n CallTaskInAppDAInternalState<TaskResponse, TaskErrorCodes>\n >({\n Right: () => _.context._internalState,\n Left: (error) => ({\n ..._.context._internalState,\n error,\n }),\n });\n },\n }),\n target: \"CheckOpenAppDeviceActionResult\",\n },\n },\n },\n CheckOpenAppDeviceActionResult: {\n always: [\n {\n target: \"CallTask\",\n guard: \"noInternalError\",\n },\n \"Error\",\n ],\n },\n CallTask: {\n entry: assign({\n intermediateValue: {\n requiredUserInteraction: this.input.requiredUserInteraction,\n step: callTaskInAppDAStateStep.CALL_TASK,\n },\n }),\n exit: assign({\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.None,\n step: callTaskInAppDAStateStep.CALL_TASK,\n },\n }),\n invoke: {\n id: \"callTask\",\n src: \"callTask\",\n input: (_: { context: types[\"context\"] }) => _.context.input.task,\n onDone: {\n target: \"CallTaskResultCheck\",\n actions: [\n assign({\n _internalState: ({ event, context }) => {\n if (isSuccessCommandResult(event.output)) {\n return {\n ...context._internalState,\n taskResponse: event.output.data,\n };\n }\n return {\n ...context._internalState,\n error: event.output.error,\n };\n },\n }),\n ],\n },\n onError: {\n target: \"Error\",\n actions: \"assignErrorFromEvent\",\n },\n },\n },\n CallTaskResultCheck: {\n always: [\n {\n target: \"Success\",\n guard: \"noInternalError\",\n },\n \"Error\",\n ],\n },\n Success: {\n type: \"final\",\n },\n Error: {\n type: \"final\",\n },\n },\n output: ({ context }) =>\n context._internalState.taskResponse\n ? Right(context._internalState.taskResponse)\n : Left(\n context._internalState.error ||\n new UnknownDAError(\"No error in final state\"),\n ),\n });\n }\n\n extractDependencies(internalApi: InternalApi) {\n return {\n callTask: (_: {\n input: (\n internalApi: InternalApi,\n ) => Promise<CommandResult<TaskResponse, TaskErrorCodes>>;\n }): Promise<CommandResult<TaskResponse, TaskErrorCodes>> =>\n _.input(internalApi),\n };\n }\n}\n"],
5
+ "mappings": "yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,+BAAAE,IAAA,eAAAC,EAAAH,GAAA,IAAAI,EAA4B,qBAC5BC,EAA2C,kBAE3CC,EAGO,4CAEPC,EAAwC,4DACxCC,EAA+B,wCAC/BC,EAAoC,yEAEpCC,EAGO,8DAEPC,EAOO,4CA4BA,MAAMT,UAIH,oBAMR,CACA,iBACEU,EAOA,CASA,KAAM,CAAE,SAAAC,CAAS,EAAI,KAAK,oBAAoBD,CAAW,EAEzD,SAAO,SAAM,CACX,MAAO,CACL,MAAO,CAAC,EACR,QAAS,CAAC,EACV,OAAQ,CAAC,CACX,EACA,OAAQ,CACN,YAAU,eAAY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AAC,EACD,QAAM,UAAO,CACX,kBAAmB,CACjB,wBAAyB,0BAAwB,KACjD,KAAM,2BAAyB,SACjC,CACF,CAAC,EACD,OAAQ,CACN,GAAI,WACJ,IAAK,WACL,MAAQF,GAAqCA,EAAE,QAAQ,MAAM,KAC7D,OAAQ,CACN,OAAQ,sBACR,QAAS,IACP,UAAO,CACL,eAAgB,CAAC,CAAE,MAAAG,EAAO,QAAAJ,CAAQ,OAC5B,0BAAuBI,EAAM,MAAM,EAC9B,CACL,GAAGJ,EAAQ,eACX,aAAcI,EAAM,OAAO,IAC7B,EAEK,CACL,GAAGJ,EAAQ,eACX,MAAOI,EAAM,OAAO,KACtB,CAEJ,CAAC,CACH,CACF,EACA,QAAS,CACP,OAAQ,QACR,QAAS,sBACX,CACF,CACF,EACA,oBAAqB,CACnB,OAAQ,CACN,CACE,OAAQ,UACR,MAAO,iBACT,EACA,OACF,CACF,EACA,QAAS,CACP,KAAM,OACR,EACA,MAAO,CACL,KAAM,OACR,CACF,EACA,OAAQ,CAAC,CAAE,QAAAJ,CAAQ,IACjBA,EAAQ,eAAe,gBACnB,SAAMA,EAAQ,eAAe,YAAY,KACzC,QACEA,EAAQ,eAAe,OACrB,IAAI,iBAAe,yBAAyB,CAChD,CACR,CAAC,CACH,CAEA,oBAAoBK,EAA0B,CAC5C,MAAO,CACL,SAAWJ,GAKTA,EAAE,MAAMI,CAAW,CACvB,CACF,CACF",
6
+ "names": ["CallTaskInAppDeviceAction_exports", "__export", "CallTaskInAppDeviceAction", "__toCommonJS", "import_purify_ts", "import_xstate", "import_CommandResult", "import_UserInteractionRequired", "import_Errors", "import_OpenAppDeviceAction", "import_XStateDeviceAction", "import_CallTaskInAppDeviceActionTypes", "internalAPI", "callTask", "context", "_", "input", "error", "event", "internalApi"]
7
7
  }
@@ -1,2 +1,2 @@
1
- "use strict";var f=require("purify-ts"),C=require("xstate"),I=require("../../../apdu/utils/ApduBuilder"),u=require("../../../command/model/CommandResult"),p=require("../../../device-action/__test-utils__/makeInternalApi"),k=require("../../../device-action/__test-utils__/testDeviceActionStates"),n=require("../../../device-action/model/DeviceActionState"),e=require("../../../device-action/model/UserInteractionRequired"),v=require("../../../device-action/os/Errors"),M=require("../../../device-action/os/OpenAppDeviceAction/OpenAppDeviceAction"),D=require("../../../../../src"),c=require("./CallTaskInAppDeviceAction");vi.mock("@api/device-action/os/OpenAppDeviceAction/OpenAppDeviceAction",async r=>{const o=await r();return{...o,OpenAppDeviceAction:vi.fn(()=>({...o.OpenAppDeviceAction,makeStateMachine:vi.fn()}))}});const A=r=>{M.OpenAppDeviceAction.mockImplementation(()=>({makeStateMachine:vi.fn().mockImplementation(()=>(0,C.createMachine)({initial:"pending",states:{pending:{entry:(0,C.assign)({intermediateValue:{requiredUserInteraction:e.UserInteractionRequired.ConfirmOpenApp}}),after:{0:"done"}},done:{type:"final"}},output:()=>r?(0,f.Left)(r):(0,f.Right)(void 0)}))}))};describe("CallTaskInAppDeviceAction",()=>{const r=vi.fn(),o=()=>({callTask:r}),{sendCommand:w}=(0,p.makeDeviceActionInternalApiMock)(),m={paramString:"aParameter",paramNumber:1234},y={aNumber:5678,aString:"mockedResponseString"};beforeEach(()=>{vi.resetAllMocks()}),describe("without mocking extractDependencies",()=>{it("should call sendCommand on internalApi with the correct parameters",async()=>{A(),w.mockResolvedValue((0,u.CommandResultFactory)({data:void 0}));const i=new c.CallTaskInAppDeviceAction({input:{task:async a=>await a.sendCommand(new d(m)),appName:"MyApp",requiredUserInteraction:e.UserInteractionRequired.VerifyAddress,skipOpenApp:!1}});await new Promise((a,t)=>{i._execute((0,p.makeDeviceActionInternalApiMock)()).observable.subscribe({error:()=>t(),complete:()=>a(),next:()=>{}})}),expect(w).toHaveBeenCalledWith(new d(m))})}),describe("error cases",()=>{it("should error and output the error if the open app fails",()=>new Promise((i,a)=>{A(new v.UnknownDAError("Mocked error"));const t=[{status:n.DeviceActionStatus.Pending,intermediateValue:{requiredUserInteraction:e.UserInteractionRequired.None}},{status:n.DeviceActionStatus.Pending,intermediateValue:{requiredUserInteraction:e.UserInteractionRequired.ConfirmOpenApp}},{status:n.DeviceActionStatus.Error,error:new v.UnknownDAError("Mocked error")}];(0,k.testDeviceActionStates)(new c.CallTaskInAppDeviceAction({input:{task:async s=>await s.sendCommand(new d(m)),appName:"MyApp",requiredUserInteraction:e.UserInteractionRequired.VerifyAddress,skipOpenApp:!1}}),t,(0,p.makeDeviceActionInternalApiMock)(),{onDone:i,onError:a})})),it("should error and output an error if the call task fails",()=>new Promise((i,a)=>{A(),r.mockResolvedValue((0,u.CommandResultFactory)({error:new D.UnknownDeviceExchangeError("Mocked error")}));const t=new c.CallTaskInAppDeviceAction({input:{task:async l=>await l.sendCommand(new d(m)),appName:"MyApp",requiredUserInteraction:e.UserInteractionRequired.VerifyAddress,skipOpenApp:!1}});vi.spyOn(t,"extractDependencies").mockImplementation(o);const s=[{status:n.DeviceActionStatus.Pending,intermediateValue:{requiredUserInteraction:e.UserInteractionRequired.None}},{status:n.DeviceActionStatus.Pending,intermediateValue:{requiredUserInteraction:e.UserInteractionRequired.ConfirmOpenApp}},{status:n.DeviceActionStatus.Pending,intermediateValue:{requiredUserInteraction:e.UserInteractionRequired.VerifyAddress}},{status:n.DeviceActionStatus.Error,error:new D.UnknownDeviceExchangeError("Mocked error")}];(0,k.testDeviceActionStates)(t,s,(0,p.makeDeviceActionInternalApiMock)(),{onDone:i,onError:a})}))}),describe("success cases",()=>{it("should succeed and output the command result if the send command succeeds",()=>new Promise((i,a)=>{A(),r.mockResolvedValue((0,u.CommandResultFactory)({data:y}));const t=new c.CallTaskInAppDeviceAction({input:{task:async l=>await l.sendCommand(new d(m)),appName:"MyApp",requiredUserInteraction:e.UserInteractionRequired.VerifyAddress,skipOpenApp:!1}});vi.spyOn(t,"extractDependencies").mockImplementation(o);const s=[{status:n.DeviceActionStatus.Pending,intermediateValue:{requiredUserInteraction:e.UserInteractionRequired.None}},{status:n.DeviceActionStatus.Pending,intermediateValue:{requiredUserInteraction:e.UserInteractionRequired.ConfirmOpenApp}},{status:n.DeviceActionStatus.Pending,intermediateValue:{requiredUserInteraction:e.UserInteractionRequired.VerifyAddress}},{status:n.DeviceActionStatus.Completed,output:y}];(0,k.testDeviceActionStates)(t,s,(0,p.makeDeviceActionInternalApiMock)(),{onDone:i,onError:a})})),it("should succeed while skipping OpenApp",()=>new Promise((i,a)=>{A(),r.mockResolvedValue((0,u.CommandResultFactory)({data:y}));const t=new c.CallTaskInAppDeviceAction({input:{task:async l=>await l.sendCommand(new d(m)),appName:"MyApp",requiredUserInteraction:e.UserInteractionRequired.VerifyAddress,skipOpenApp:!0}});vi.spyOn(t,"extractDependencies").mockImplementation(o);const s=[{status:n.DeviceActionStatus.Pending,intermediateValue:{requiredUserInteraction:e.UserInteractionRequired.VerifyAddress}},{status:n.DeviceActionStatus.Completed,output:y}];(0,k.testDeviceActionStates)(t,s,(0,p.makeDeviceActionInternalApiMock)(),{onDone:i,onError:a})}))})});class d{name="testCommand";params;constructor(o){this.params=o}getApdu(){return new I.ApduBuilder({cla:0,ins:1,p1:2,p2:3}).add32BitUIntToData(this.params.paramNumber).addAsciiStringToData(this.params.paramString).build()}parseResponse(){return(0,u.CommandResultFactory)({data:{aNumber:1,aString:"aString"}})}}
1
+ "use strict";var D=require("purify-ts"),v=require("xstate"),T=require("../../../apdu/utils/ApduBuilder"),A=require("../../../command/model/CommandResult"),p=require("../../../device-action/__test-utils__/makeInternalApi"),C=require("../../../device-action/__test-utils__/testDeviceActionStates"),t=require("../../../device-action/model/DeviceActionState"),e=require("../../../device-action/model/UserInteractionRequired"),I=require("../../../device-action/os/Errors"),M=require("../../../device-action/os/OpenAppDeviceAction/OpenAppDeviceAction"),y=require("../../../device-action/os/OpenAppDeviceAction/types"),S=require("../../../../../src"),u=require("./CallTaskInAppDeviceAction"),m=require("./CallTaskInAppDeviceActionTypes");vi.mock("@api/device-action/os/OpenAppDeviceAction/OpenAppDeviceAction",async r=>{const o=await r();return{...o,OpenAppDeviceAction:vi.fn(()=>({...o.OpenAppDeviceAction,makeStateMachine:vi.fn()}))}});const k=r=>{M.OpenAppDeviceAction.mockImplementation(()=>({makeStateMachine:vi.fn().mockImplementation(()=>(0,v.createMachine)({initial:"pending",states:{pending:{entry:(0,v.assign)({intermediateValue:{requiredUserInteraction:e.UserInteractionRequired.ConfirmOpenApp,step:y.openAppDAStateStep.GET_DEVICE_STATUS}}),after:{0:"done"}},done:{type:"final"}},output:()=>r?(0,D.Left)(r):(0,D.Right)(void 0)}))}))};describe("CallTaskInAppDeviceAction",()=>{const r=vi.fn(),o=()=>({callTask:r}),{sendCommand:w}=(0,p.makeDeviceActionInternalApiMock)(),d={paramString:"aParameter",paramNumber:1234},f={aNumber:5678,aString:"mockedResponseString"};beforeEach(()=>{vi.resetAllMocks()}),describe("without mocking extractDependencies",()=>{it("should call sendCommand on internalApi with the correct parameters",async()=>{k(),w.mockResolvedValue((0,A.CommandResultFactory)({data:void 0}));const i=new u.CallTaskInAppDeviceAction({input:{task:async a=>await a.sendCommand(new c(d)),appName:"MyApp",requiredUserInteraction:e.UserInteractionRequired.VerifyAddress,skipOpenApp:!1}});await new Promise((a,n)=>{i._execute((0,p.makeDeviceActionInternalApiMock)()).observable.subscribe({error:()=>n(),complete:()=>a(),next:()=>{}})}),expect(w).toHaveBeenCalledWith(new c(d))})}),describe("error cases",()=>{it("should error and output the error if the open app fails",()=>new Promise((i,a)=>{k(new I.UnknownDAError("Mocked error"));const n=[{status:t.DeviceActionStatus.Pending,intermediateValue:{requiredUserInteraction:e.UserInteractionRequired.None,step:m.callTaskInAppDAStateStep.OPEN_APP}},{status:t.DeviceActionStatus.Pending,intermediateValue:{requiredUserInteraction:e.UserInteractionRequired.ConfirmOpenApp,step:y.openAppDAStateStep.GET_DEVICE_STATUS}},{status:t.DeviceActionStatus.Error,error:new I.UnknownDAError("Mocked error")}];(0,C.testDeviceActionStates)(new u.CallTaskInAppDeviceAction({input:{task:async s=>await s.sendCommand(new c(d)),appName:"MyApp",requiredUserInteraction:e.UserInteractionRequired.VerifyAddress,skipOpenApp:!1}}),n,(0,p.makeDeviceActionInternalApiMock)(),{onDone:i,onError:a})})),it("should error and output an error if the call task fails",()=>new Promise((i,a)=>{k(),r.mockResolvedValue((0,A.CommandResultFactory)({error:new S.UnknownDeviceExchangeError("Mocked error")}));const n=new u.CallTaskInAppDeviceAction({input:{task:async l=>await l.sendCommand(new c(d)),appName:"MyApp",requiredUserInteraction:e.UserInteractionRequired.VerifyAddress,skipOpenApp:!1}});vi.spyOn(n,"extractDependencies").mockImplementation(o);const s=[{status:t.DeviceActionStatus.Pending,intermediateValue:{requiredUserInteraction:e.UserInteractionRequired.None,step:m.callTaskInAppDAStateStep.OPEN_APP}},{status:t.DeviceActionStatus.Pending,intermediateValue:{requiredUserInteraction:e.UserInteractionRequired.ConfirmOpenApp,step:y.openAppDAStateStep.GET_DEVICE_STATUS}},{status:t.DeviceActionStatus.Pending,intermediateValue:{requiredUserInteraction:e.UserInteractionRequired.VerifyAddress,step:m.callTaskInAppDAStateStep.CALL_TASK}},{status:t.DeviceActionStatus.Error,error:new S.UnknownDeviceExchangeError("Mocked error")}];(0,C.testDeviceActionStates)(n,s,(0,p.makeDeviceActionInternalApiMock)(),{onDone:i,onError:a})}))}),describe("success cases",()=>{it("should succeed and output the command result if the send command succeeds",()=>new Promise((i,a)=>{k(),r.mockResolvedValue((0,A.CommandResultFactory)({data:f}));const n=new u.CallTaskInAppDeviceAction({input:{task:async l=>await l.sendCommand(new c(d)),appName:"MyApp",requiredUserInteraction:e.UserInteractionRequired.VerifyAddress,skipOpenApp:!1}});vi.spyOn(n,"extractDependencies").mockImplementation(o);const s=[{status:t.DeviceActionStatus.Pending,intermediateValue:{requiredUserInteraction:e.UserInteractionRequired.None,step:m.callTaskInAppDAStateStep.OPEN_APP}},{status:t.DeviceActionStatus.Pending,intermediateValue:{requiredUserInteraction:e.UserInteractionRequired.ConfirmOpenApp,step:y.openAppDAStateStep.GET_DEVICE_STATUS}},{status:t.DeviceActionStatus.Pending,intermediateValue:{requiredUserInteraction:e.UserInteractionRequired.VerifyAddress,step:m.callTaskInAppDAStateStep.CALL_TASK}},{status:t.DeviceActionStatus.Completed,output:f}];(0,C.testDeviceActionStates)(n,s,(0,p.makeDeviceActionInternalApiMock)(),{onDone:i,onError:a})})),it("should succeed while skipping OpenApp",()=>new Promise((i,a)=>{k(),r.mockResolvedValue((0,A.CommandResultFactory)({data:f}));const n=new u.CallTaskInAppDeviceAction({input:{task:async l=>await l.sendCommand(new c(d)),appName:"MyApp",requiredUserInteraction:e.UserInteractionRequired.VerifyAddress,skipOpenApp:!0}});vi.spyOn(n,"extractDependencies").mockImplementation(o);const s=[{status:t.DeviceActionStatus.Pending,intermediateValue:{requiredUserInteraction:e.UserInteractionRequired.VerifyAddress,step:m.callTaskInAppDAStateStep.CALL_TASK}},{status:t.DeviceActionStatus.Completed,output:f}];(0,C.testDeviceActionStates)(n,s,(0,p.makeDeviceActionInternalApiMock)(),{onDone:i,onError:a})}))})});class c{name="testCommand";params;constructor(o){this.params=o}getApdu(){return new T.ApduBuilder({cla:0,ins:1,p1:2,p2:3}).add32BitUIntToData(this.params.paramNumber).addAsciiStringToData(this.params.paramString).build()}parseResponse(){return(0,A.CommandResultFactory)({data:{aNumber:1,aString:"aString"}})}}
2
2
  //# sourceMappingURL=CallTaskInAppDeviceAction.test.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../../../../src/api/device-action/os/CallTaskInAppDeviceAction/CallTaskInAppDeviceAction.test.ts"],
4
- "sourcesContent": ["/* eslint @typescript-eslint/consistent-type-imports:0 */\nimport { Left, Right } from \"purify-ts\";\nimport { type Mock } from \"vitest\";\nimport { assign, createMachine } from \"xstate\";\n\nimport { type Apdu } from \"@api/apdu/model/Apdu\";\nimport { ApduBuilder } from \"@api/apdu/utils/ApduBuilder\";\nimport { CommandResultFactory } from \"@api/command/model/CommandResult\";\nimport { makeDeviceActionInternalApiMock } from \"@api/device-action/__test-utils__/makeInternalApi\";\nimport { testDeviceActionStates } from \"@api/device-action/__test-utils__/testDeviceActionStates\";\nimport {\n type DeviceActionState,\n DeviceActionStatus,\n} from \"@api/device-action/model/DeviceActionState\";\nimport { UserInteractionRequired } from \"@api/device-action/model/UserInteractionRequired\";\nimport { UnknownDAError } from \"@api/device-action/os/Errors\";\nimport { OpenAppDeviceAction } from \"@api/device-action/os/OpenAppDeviceAction/OpenAppDeviceAction\";\nimport { type Command } from \"@api/types\";\nimport { UnknownDeviceExchangeError } from \"@root/src\";\n\nimport { CallTaskInAppDeviceAction } from \"./CallTaskInAppDeviceAction\";\nimport {\n type CallTaskInAppDAError,\n type CallTaskInAppDAIntermediateValue,\n type CallTaskInAppDAOutput,\n} from \"./CallTaskInAppDeviceActionTypes\";\n\nvi.mock(\n \"@api/device-action/os/OpenAppDeviceAction/OpenAppDeviceAction\",\n async (importOriginal) => {\n const original =\n await importOriginal<\n typeof import(\"@api/device-action/os/OpenAppDeviceAction/OpenAppDeviceAction\")\n >();\n return {\n ...original,\n OpenAppDeviceAction: vi.fn(() => ({\n ...original.OpenAppDeviceAction,\n makeStateMachine: vi.fn(),\n })),\n };\n },\n);\n\nconst setupOpenAppDAMock = (error?: unknown) => {\n (OpenAppDeviceAction as Mock).mockImplementation(() => ({\n makeStateMachine: vi.fn().mockImplementation(() =>\n createMachine({\n initial: \"pending\",\n states: {\n pending: {\n entry: assign({\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.ConfirmOpenApp,\n },\n }),\n after: {\n 0: \"done\",\n },\n },\n done: {\n type: \"final\",\n },\n },\n output: () => (error ? Left(error) : Right(undefined)),\n }),\n ),\n }));\n};\n\ndescribe(\"CallTaskInAppDeviceAction\", () => {\n const callMyTask = vi.fn();\n\n const extractDependenciesMock = () => ({\n callTask: callMyTask,\n });\n\n const { sendCommand: apiSendCommandMock } = makeDeviceActionInternalApiMock();\n\n const commandParams = {\n paramString: \"aParameter\",\n paramNumber: 1234,\n };\n const mockedCommandResponse = {\n aNumber: 5678,\n aString: \"mockedResponseString\",\n };\n beforeEach(() => {\n vi.resetAllMocks();\n });\n\n describe(\"without mocking extractDependencies\", () => {\n it(\"should call sendCommand on internalApi with the correct parameters\", async () => {\n setupOpenAppDAMock();\n apiSendCommandMock.mockResolvedValue(\n CommandResultFactory({ data: undefined }),\n );\n\n const deviceAction = new CallTaskInAppDeviceAction({\n input: {\n task: async (internalApi) =>\n await internalApi.sendCommand(new TestCommand(commandParams)),\n appName: \"MyApp\",\n requiredUserInteraction: UserInteractionRequired.VerifyAddress,\n skipOpenApp: false,\n },\n });\n await new Promise<void>((resolve, reject) => {\n deviceAction\n ._execute(makeDeviceActionInternalApiMock())\n .observable.subscribe({\n error: () => reject(),\n complete: () => resolve(),\n next: () => {},\n });\n });\n\n expect(apiSendCommandMock).toHaveBeenCalledWith(\n new TestCommand(commandParams),\n );\n });\n });\n\n describe(\"error cases\", () => {\n it(\"should error and output the error if the open app fails\", () =>\n new Promise<void>((resolve, reject) => {\n setupOpenAppDAMock(new UnknownDAError(\"Mocked error\"));\n\n const expectedStates: MyCommandCallTaskDAState[] = [\n {\n status: DeviceActionStatus.Pending,\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.None,\n },\n },\n {\n status: DeviceActionStatus.Pending,\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.ConfirmOpenApp,\n },\n },\n {\n status: DeviceActionStatus.Error,\n error: new UnknownDAError(\"Mocked error\"),\n },\n ];\n\n testDeviceActionStates(\n new CallTaskInAppDeviceAction({\n input: {\n task: async (internalApi) =>\n await internalApi.sendCommand(new TestCommand(commandParams)),\n appName: \"MyApp\",\n requiredUserInteraction: UserInteractionRequired.VerifyAddress,\n skipOpenApp: false,\n },\n }),\n expectedStates,\n makeDeviceActionInternalApiMock(),\n {\n onDone: resolve,\n onError: reject,\n },\n );\n }));\n\n it(\"should error and output an error if the call task fails\", () =>\n new Promise<void>((resolve, reject) => {\n setupOpenAppDAMock();\n\n callMyTask.mockResolvedValue(\n CommandResultFactory({\n error: new UnknownDeviceExchangeError(\"Mocked error\"),\n }),\n );\n\n const deviceAction = new CallTaskInAppDeviceAction({\n input: {\n task: async (internalApi) =>\n await internalApi.sendCommand(new TestCommand(commandParams)),\n appName: \"MyApp\",\n requiredUserInteraction: UserInteractionRequired.VerifyAddress,\n skipOpenApp: false,\n },\n });\n\n vi.spyOn(deviceAction, \"extractDependencies\").mockImplementation(\n extractDependenciesMock,\n );\n\n const expectedStates: MyCommandCallTaskDAState[] = [\n {\n status: DeviceActionStatus.Pending,\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.None,\n },\n },\n {\n status: DeviceActionStatus.Pending,\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.ConfirmOpenApp,\n },\n },\n {\n status: DeviceActionStatus.Pending,\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.VerifyAddress,\n },\n },\n {\n status: DeviceActionStatus.Error,\n error: new UnknownDeviceExchangeError(\"Mocked error\"),\n },\n ];\n\n testDeviceActionStates(\n deviceAction,\n expectedStates,\n makeDeviceActionInternalApiMock(),\n {\n onDone: resolve,\n onError: reject,\n },\n );\n }));\n });\n\n describe(\"success cases\", () => {\n it(\"should succeed and output the command result if the send command succeeds\", () =>\n new Promise<void>((resolve, reject) => {\n setupOpenAppDAMock();\n\n callMyTask.mockResolvedValue(\n CommandResultFactory({ data: mockedCommandResponse }),\n );\n\n const deviceAction = new CallTaskInAppDeviceAction({\n input: {\n task: async (internalApi) =>\n await internalApi.sendCommand(new TestCommand(commandParams)),\n appName: \"MyApp\",\n requiredUserInteraction: UserInteractionRequired.VerifyAddress,\n skipOpenApp: false,\n },\n });\n\n vi.spyOn(deviceAction, \"extractDependencies\").mockImplementation(\n extractDependenciesMock,\n );\n\n const expectedStates: MyCommandCallTaskDAState[] = [\n {\n status: DeviceActionStatus.Pending,\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.None,\n },\n },\n {\n status: DeviceActionStatus.Pending,\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.ConfirmOpenApp,\n },\n },\n {\n status: DeviceActionStatus.Pending,\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.VerifyAddress,\n },\n },\n {\n status: DeviceActionStatus.Completed,\n output: mockedCommandResponse,\n },\n ];\n\n testDeviceActionStates(\n deviceAction,\n expectedStates,\n makeDeviceActionInternalApiMock(),\n {\n onDone: resolve,\n onError: reject,\n },\n );\n }));\n\n it(\"should succeed while skipping OpenApp\", () =>\n new Promise<void>((resolve, reject) => {\n setupOpenAppDAMock();\n\n callMyTask.mockResolvedValue(\n CommandResultFactory({ data: mockedCommandResponse }),\n );\n\n const deviceAction = new CallTaskInAppDeviceAction({\n input: {\n task: async (internalApi) =>\n await internalApi.sendCommand(new TestCommand(commandParams)),\n appName: \"MyApp\",\n requiredUserInteraction: UserInteractionRequired.VerifyAddress,\n skipOpenApp: true,\n },\n });\n\n vi.spyOn(deviceAction, \"extractDependencies\").mockImplementation(\n extractDependenciesMock,\n );\n\n const expectedStates: MyCommandCallTaskDAState[] = [\n {\n status: DeviceActionStatus.Pending,\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.VerifyAddress,\n },\n },\n {\n status: DeviceActionStatus.Completed,\n output: mockedCommandResponse,\n },\n ];\n\n testDeviceActionStates(\n deviceAction,\n expectedStates,\n makeDeviceActionInternalApiMock(),\n {\n onDone: resolve,\n onError: reject,\n },\n );\n }));\n });\n});\n\ntype MyCommandResponse = {\n aNumber: number;\n aString: string;\n};\n\ntype MyCommandParams = {\n paramString: string;\n paramNumber: number;\n};\n\nclass TestCommand implements Command<MyCommandResponse, MyCommandParams> {\n readonly name = \"testCommand\";\n\n params: MyCommandParams;\n constructor(params: MyCommandParams) {\n this.params = params;\n }\n getApdu(): Apdu {\n return new ApduBuilder({ cla: 0x00, ins: 0x01, p1: 0x02, p2: 0x03 })\n .add32BitUIntToData(this.params.paramNumber)\n .addAsciiStringToData(this.params.paramString)\n .build();\n }\n parseResponse() {\n return CommandResultFactory({ data: { aNumber: 1, aString: \"aString\" } });\n }\n}\n\ntype MyCommandCallTaskDAState = DeviceActionState<\n CallTaskInAppDAOutput<MyCommandResponse>,\n CallTaskInAppDAError<UnknownDAError>,\n CallTaskInAppDAIntermediateValue<\n UserInteractionRequired.None | UserInteractionRequired.VerifyAddress\n >\n>;\n"],
5
- "mappings": "aACA,IAAAA,EAA4B,qBAE5BC,EAAsC,kBAGtCC,EAA4B,uCAC5BC,EAAqC,4CACrCC,EAAgD,6DAChDC,EAAuC,oEACvCC,EAGO,sDACPC,EAAwC,4DACxCC,EAA+B,wCAC/BC,EAAoC,yEAEpCC,EAA2C,qBAE3CC,EAA0C,uCAO1C,GAAG,KACD,gEACA,MAAOC,GAAmB,CACxB,MAAMC,EACJ,MAAMD,EAEJ,EACJ,MAAO,CACL,GAAGC,EACH,oBAAqB,GAAG,GAAG,KAAO,CAChC,GAAGA,EAAS,oBACZ,iBAAkB,GAAG,GAAG,CAC1B,EAAE,CACJ,CACF,CACF,EAEA,MAAMC,EAAsBC,GAAoB,CAC7C,sBAA6B,mBAAmB,KAAO,CACtD,iBAAkB,GAAG,GAAG,EAAE,mBAAmB,OAC3C,iBAAc,CACZ,QAAS,UACT,OAAQ,CACN,QAAS,CACP,SAAO,UAAO,CACZ,kBAAmB,CACjB,wBAAyB,0BAAwB,cACnD,CACF,CAAC,EACD,MAAO,CACL,EAAG,MACL,CACF,EACA,KAAM,CACJ,KAAM,OACR,CACF,EACA,OAAQ,IAAOA,KAAQ,QAAKA,CAAK,KAAI,SAAM,MAAS,CACtD,CAAC,CACH,CACF,EAAE,CACJ,EAEA,SAAS,4BAA6B,IAAM,CAC1C,MAAMC,EAAa,GAAG,GAAG,EAEnBC,EAA0B,KAAO,CACrC,SAAUD,CACZ,GAEM,CAAE,YAAaE,CAAmB,KAAI,mCAAgC,EAEtEC,EAAgB,CACpB,YAAa,aACb,YAAa,IACf,EACMC,EAAwB,CAC5B,QA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5C,MAAM,CACX,CACA,eAAgB,CACd,SAAO,wBAAqB,CAAE,KAAM,CAAE,QAAS,EAAG,QAAS,SAAU,CAAE,CAAC,CAC1E,CACF",
6
- "names": ["import_purify_ts", "import_xstate", "import_ApduBuilder", "import_CommandResult", "import_makeInternalApi", "import_testDeviceActionStates", "import_DeviceActionState", "import_UserInteractionRequired", "import_Errors", "import_OpenAppDeviceAction", "import_src", "import_CallTaskInAppDeviceAction", "importOriginal", "original", "setupOpenAppDAMock", "error", "callMyTask", "extractDependenciesMock", "apiSendCommandMock", "commandParams", "mockedCommandResponse", "deviceAction", "internalApi", "TestCommand", "resolve", "reject", "expectedStates", "params"]
4
+ "sourcesContent": ["/* eslint @typescript-eslint/consistent-type-imports:0 */\nimport { Left, Right } from \"purify-ts\";\nimport { type Mock } from \"vitest\";\nimport { assign, createMachine } from \"xstate\";\n\nimport { type Apdu } from \"@api/apdu/model/Apdu\";\nimport { ApduBuilder } from \"@api/apdu/utils/ApduBuilder\";\nimport { CommandResultFactory } from \"@api/command/model/CommandResult\";\nimport { makeDeviceActionInternalApiMock } from \"@api/device-action/__test-utils__/makeInternalApi\";\nimport { testDeviceActionStates } from \"@api/device-action/__test-utils__/testDeviceActionStates\";\nimport {\n type DeviceActionState,\n DeviceActionStatus,\n} from \"@api/device-action/model/DeviceActionState\";\nimport { UserInteractionRequired } from \"@api/device-action/model/UserInteractionRequired\";\nimport { UnknownDAError } from \"@api/device-action/os/Errors\";\nimport { OpenAppDeviceAction } from \"@api/device-action/os/OpenAppDeviceAction/OpenAppDeviceAction\";\nimport { openAppDAStateStep } from \"@api/device-action/os/OpenAppDeviceAction/types\";\nimport { type Command } from \"@api/types\";\nimport { UnknownDeviceExchangeError } from \"@root/src\";\n\nimport { CallTaskInAppDeviceAction } from \"./CallTaskInAppDeviceAction\";\nimport {\n type CallTaskInAppDAError,\n type CallTaskInAppDAIntermediateValue,\n type CallTaskInAppDAOutput,\n callTaskInAppDAStateStep,\n} from \"./CallTaskInAppDeviceActionTypes\";\n\nvi.mock(\n \"@api/device-action/os/OpenAppDeviceAction/OpenAppDeviceAction\",\n async (importOriginal) => {\n const original =\n await importOriginal<\n typeof import(\"@api/device-action/os/OpenAppDeviceAction/OpenAppDeviceAction\")\n >();\n return {\n ...original,\n OpenAppDeviceAction: vi.fn(() => ({\n ...original.OpenAppDeviceAction,\n makeStateMachine: vi.fn(),\n })),\n };\n },\n);\n\nconst setupOpenAppDAMock = (error?: unknown) => {\n (OpenAppDeviceAction as Mock).mockImplementation(() => ({\n makeStateMachine: vi.fn().mockImplementation(() =>\n createMachine({\n initial: \"pending\",\n states: {\n pending: {\n entry: assign({\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.ConfirmOpenApp,\n step: openAppDAStateStep.GET_DEVICE_STATUS,\n },\n }),\n after: {\n 0: \"done\",\n },\n },\n done: {\n type: \"final\",\n },\n },\n output: () => (error ? Left(error) : Right(undefined)),\n }),\n ),\n }));\n};\n\ndescribe(\"CallTaskInAppDeviceAction\", () => {\n const callMyTask = vi.fn();\n\n const extractDependenciesMock = () => ({\n callTask: callMyTask,\n });\n\n const { sendCommand: apiSendCommandMock } = makeDeviceActionInternalApiMock();\n\n const commandParams = {\n paramString: \"aParameter\",\n paramNumber: 1234,\n };\n const mockedCommandResponse = {\n aNumber: 5678,\n aString: \"mockedResponseString\",\n };\n beforeEach(() => {\n vi.resetAllMocks();\n });\n\n describe(\"without mocking extractDependencies\", () => {\n it(\"should call sendCommand on internalApi with the correct parameters\", async () => {\n setupOpenAppDAMock();\n apiSendCommandMock.mockResolvedValue(\n CommandResultFactory({ data: undefined }),\n );\n\n const deviceAction = new CallTaskInAppDeviceAction({\n input: {\n task: async (internalApi) =>\n await internalApi.sendCommand(new TestCommand(commandParams)),\n appName: \"MyApp\",\n requiredUserInteraction: UserInteractionRequired.VerifyAddress,\n skipOpenApp: false,\n },\n });\n await new Promise<void>((resolve, reject) => {\n deviceAction\n ._execute(makeDeviceActionInternalApiMock())\n .observable.subscribe({\n error: () => reject(),\n complete: () => resolve(),\n next: () => {},\n });\n });\n\n expect(apiSendCommandMock).toHaveBeenCalledWith(\n new TestCommand(commandParams),\n );\n });\n });\n\n describe(\"error cases\", () => {\n it(\"should error and output the error if the open app fails\", () =>\n new Promise<void>((resolve, reject) => {\n setupOpenAppDAMock(new UnknownDAError(\"Mocked error\"));\n\n const expectedStates: MyCommandCallTaskDAState[] = [\n {\n status: DeviceActionStatus.Pending,\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.None,\n step: callTaskInAppDAStateStep.OPEN_APP,\n },\n },\n {\n status: DeviceActionStatus.Pending,\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.ConfirmOpenApp,\n step: openAppDAStateStep.GET_DEVICE_STATUS,\n },\n },\n {\n status: DeviceActionStatus.Error,\n error: new UnknownDAError(\"Mocked error\"),\n },\n ];\n\n testDeviceActionStates(\n new CallTaskInAppDeviceAction({\n input: {\n task: async (internalApi) =>\n await internalApi.sendCommand(new TestCommand(commandParams)),\n appName: \"MyApp\",\n requiredUserInteraction: UserInteractionRequired.VerifyAddress,\n skipOpenApp: false,\n },\n }),\n expectedStates,\n makeDeviceActionInternalApiMock(),\n {\n onDone: resolve,\n onError: reject,\n },\n );\n }));\n\n it(\"should error and output an error if the call task fails\", () =>\n new Promise<void>((resolve, reject) => {\n setupOpenAppDAMock();\n\n callMyTask.mockResolvedValue(\n CommandResultFactory({\n error: new UnknownDeviceExchangeError(\"Mocked error\"),\n }),\n );\n\n const deviceAction = new CallTaskInAppDeviceAction({\n input: {\n task: async (internalApi) =>\n await internalApi.sendCommand(new TestCommand(commandParams)),\n appName: \"MyApp\",\n requiredUserInteraction: UserInteractionRequired.VerifyAddress,\n skipOpenApp: false,\n },\n });\n\n vi.spyOn(deviceAction, \"extractDependencies\").mockImplementation(\n extractDependenciesMock,\n );\n\n const expectedStates: MyCommandCallTaskDAState[] = [\n {\n status: DeviceActionStatus.Pending,\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.None,\n step: callTaskInAppDAStateStep.OPEN_APP,\n },\n },\n {\n status: DeviceActionStatus.Pending,\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.ConfirmOpenApp,\n step: openAppDAStateStep.GET_DEVICE_STATUS,\n },\n },\n {\n status: DeviceActionStatus.Pending,\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.VerifyAddress,\n step: callTaskInAppDAStateStep.CALL_TASK,\n },\n },\n {\n status: DeviceActionStatus.Error,\n error: new UnknownDeviceExchangeError(\"Mocked error\"),\n },\n ];\n\n testDeviceActionStates(\n deviceAction,\n expectedStates,\n makeDeviceActionInternalApiMock(),\n {\n onDone: resolve,\n onError: reject,\n },\n );\n }));\n });\n\n describe(\"success cases\", () => {\n it(\"should succeed and output the command result if the send command succeeds\", () =>\n new Promise<void>((resolve, reject) => {\n setupOpenAppDAMock();\n\n callMyTask.mockResolvedValue(\n CommandResultFactory({ data: mockedCommandResponse }),\n );\n\n const deviceAction = new CallTaskInAppDeviceAction({\n input: {\n task: async (internalApi) =>\n await internalApi.sendCommand(new TestCommand(commandParams)),\n appName: \"MyApp\",\n requiredUserInteraction: UserInteractionRequired.VerifyAddress,\n skipOpenApp: false,\n },\n });\n\n vi.spyOn(deviceAction, \"extractDependencies\").mockImplementation(\n extractDependenciesMock,\n );\n\n const expectedStates: MyCommandCallTaskDAState[] = [\n {\n status: DeviceActionStatus.Pending,\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.None,\n step: callTaskInAppDAStateStep.OPEN_APP,\n },\n },\n {\n status: DeviceActionStatus.Pending,\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.ConfirmOpenApp,\n step: openAppDAStateStep.GET_DEVICE_STATUS,\n },\n },\n {\n status: DeviceActionStatus.Pending,\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.VerifyAddress,\n step: callTaskInAppDAStateStep.CALL_TASK,\n },\n },\n {\n status: DeviceActionStatus.Completed,\n output: mockedCommandResponse,\n },\n ];\n\n testDeviceActionStates(\n deviceAction,\n expectedStates,\n makeDeviceActionInternalApiMock(),\n {\n onDone: resolve,\n onError: reject,\n },\n );\n }));\n\n it(\"should succeed while skipping OpenApp\", () =>\n new Promise<void>((resolve, reject) => {\n setupOpenAppDAMock();\n\n callMyTask.mockResolvedValue(\n CommandResultFactory({ data: mockedCommandResponse }),\n );\n\n const deviceAction = new CallTaskInAppDeviceAction({\n input: {\n task: async (internalApi) =>\n await internalApi.sendCommand(new TestCommand(commandParams)),\n appName: \"MyApp\",\n requiredUserInteraction: UserInteractionRequired.VerifyAddress,\n skipOpenApp: true,\n },\n });\n\n vi.spyOn(deviceAction, \"extractDependencies\").mockImplementation(\n extractDependenciesMock,\n );\n\n const expectedStates: MyCommandCallTaskDAState[] = [\n {\n status: DeviceActionStatus.Pending,\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.VerifyAddress,\n step: callTaskInAppDAStateStep.CALL_TASK,\n },\n },\n {\n status: DeviceActionStatus.Completed,\n output: mockedCommandResponse,\n },\n ];\n\n testDeviceActionStates(\n deviceAction,\n expectedStates,\n makeDeviceActionInternalApiMock(),\n {\n onDone: resolve,\n onError: reject,\n },\n );\n }));\n });\n});\n\ntype MyCommandResponse = {\n aNumber: number;\n aString: string;\n};\n\ntype MyCommandParams = {\n paramString: string;\n paramNumber: number;\n};\n\nclass TestCommand implements Command<MyCommandResponse, MyCommandParams> {\n readonly name = \"testCommand\";\n\n params: MyCommandParams;\n constructor(params: MyCommandParams) {\n this.params = params;\n }\n getApdu(): Apdu {\n return new ApduBuilder({ cla: 0x00, ins: 0x01, p1: 0x02, p2: 0x03 })\n .add32BitUIntToData(this.params.paramNumber)\n .addAsciiStringToData(this.params.paramString)\n .build();\n }\n parseResponse() {\n return CommandResultFactory({ data: { aNumber: 1, aString: \"aString\" } });\n }\n}\n\ntype MyCommandCallTaskDAState = DeviceActionState<\n CallTaskInAppDAOutput<MyCommandResponse>,\n CallTaskInAppDAError<UnknownDAError>,\n CallTaskInAppDAIntermediateValue<\n UserInteractionRequired.None | UserInteractionRequired.VerifyAddress\n >\n>;\n"],
5
+ "mappings": "aACA,IAAAA,EAA4B,qBAE5BC,EAAsC,kBAGtCC,EAA4B,uCAC5BC,EAAqC,4CACrCC,EAAgD,6DAChDC,EAAuC,oEACvCC,EAGO,sDACPC,EAAwC,4DACxCC,EAA+B,wCAC/BC,EAAoC,yEACpCC,EAAmC,2DAEnCC,EAA2C,qBAE3CC,EAA0C,uCAC1CC,EAKO,4CAEP,GAAG,KACD,gEACA,MAAOC,GAAmB,CACxB,MAAMC,EACJ,MAAMD,EAEJ,EACJ,MAAO,CACL,GAAGC,EACH,oBAAqB,GAAG,GAAG,KAAO,CAChC,GAAGA,EAAS,oBACZ,iBAAkB,GAAG,GAAG,CAC1B,EAAE,CACJ,CACF,CACF,EAEA,MAAMC,EAAsBC,GAAoB,CAC7C,sBAA6B,mBAAmB,KAAO,CACtD,iBAAkB,GAAG,GAAG,EAAE,mBAAmB,OAC3C,iBAAc,CACZ,QAAS,UACT,OAAQ,CACN,QAAS,CACP,SAAO,UAAO,CACZ,kBAAmB,CACjB,wBAAyB,0BAAwB,eACjD,KAAM,qBAAmB,iBAC3B,CACF,CAAC,EACD,MAAO,CACL,EAAG,MACL,CACF,EACA,KAAM,CACJ,KAAM,OACR,CACF,EACA,OAAQ,IAAOA,KAAQ,QAAKA,CAAK,KAAI,SAAM,MAAS,CACtD,CAAC,CACH,CACF,EAAE,CACJ,EAEA,SAAS,4BAA6B,IAAM,CAC1C,MAAMC,EAAa,GAAG,GAAG,EAEnBC,EAA0B,KAAO,CACrC,SAAUD,CACZ,GAEM,CAAE,YAAaE,CAAmB,KAAI,mCAAgC,EAEtEC,EAAgB,CACpB,YAAa,aACb,YAAa,IACf,EACMC,EAAwB,CAC5B,QAAS,KACT,QAAS,sBACX,EACA,WAAW,IAAM,CACf,GAAG,cAAc,CACnB,CAAC,EAED,SAAS,sCAAuC,IAAM,CACpD,GAAG,qEAAsE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AAK,CAAC,EAChE,mBAAmB,KAAK,OAAO,WAAW,EAC1C,qBAAqB,KAAK,OAAO,WAAW,EAC5C,MAAM,CACX,CACA,eAAgB,CACd,SAAO,wBAAqB,CAAE,KAAM,CAAE,QAAS,EAAG,QAAS,SAAU,CAAE,CAAC,CAC1E,CACF",
6
+ "names": ["import_purify_ts", "import_xstate", "import_ApduBuilder", "import_CommandResult", "import_makeInternalApi", "import_testDeviceActionStates", "import_DeviceActionState", "import_UserInteractionRequired", "import_Errors", "import_OpenAppDeviceAction", "import_types", "import_src", "import_CallTaskInAppDeviceAction", "import_CallTaskInAppDeviceActionTypes", "importOriginal", "original", "setupOpenAppDAMock", "error", "callMyTask", "extractDependenciesMock", "apiSendCommandMock", "commandParams", "mockedCommandResponse", "deviceAction", "internalApi", "TestCommand", "resolve", "reject", "expectedStates", "params"]
7
7
  }
@@ -1,2 +1,2 @@
1
- "use strict";var a=Object.defineProperty;var s=Object.getOwnPropertyDescriptor;var t=Object.getOwnPropertyNames;var l=Object.prototype.hasOwnProperty;var A=(r,e,n,o)=>{if(e&&typeof e=="object"||typeof e=="function")for(let p of t(e))!l.call(r,p)&&p!==n&&a(r,p,{get:()=>e[p],enumerable:!(o=s(e,p))||o.enumerable});return r};var d=r=>A(a({},"__esModule",{value:!0}),r);var i={};module.exports=d(i);
1
+ "use strict";var a=Object.defineProperty;var o=Object.getOwnPropertyDescriptor;var s=Object.getOwnPropertyNames;var l=Object.prototype.hasOwnProperty;var A=(r,e)=>{for(var t in e)a(r,t,{get:e[t],enumerable:!0})},k=(r,e,t,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let p of s(e))!l.call(r,p)&&p!==t&&a(r,p,{get:()=>e[p],enumerable:!(n=o(e,p))||n.enumerable});return r};var I=r=>k(a({},"__esModule",{value:!0}),r);var T={};A(T,{callTaskInAppDAStateStep:()=>i});module.exports=I(T);const i=Object.freeze({OPEN_APP:"os.callTaskInApp.steps.openApp",CALL_TASK:"os.callTaskInApp.steps.callTask"});0&&(module.exports={callTaskInAppDAStateStep});
2
2
  //# sourceMappingURL=CallTaskInAppDeviceActionTypes.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../../../../src/api/device-action/os/CallTaskInAppDeviceAction/CallTaskInAppDeviceActionTypes.ts"],
4
- "sourcesContent": ["import {\n type CommandErrorResult,\n type CommandResult,\n} from \"@api/command/model/CommandResult\";\nimport { type InternalApi } from \"@api/device-action/DeviceAction\";\nimport {\n type OpenAppDAError,\n type OpenAppDAIntermediateValue,\n} from \"@api/device-action/os/OpenAppDeviceAction/types\";\n\nexport type CallTaskInAppDAOutput<TaskResponse> = TaskResponse;\n\nexport type CallTaskInAppDAInput<\n TaskResponse,\n TaskErrorCodes,\n UserInteraction,\n> = {\n readonly task: (\n internalApi: InternalApi,\n ) => Promise<CommandResult<TaskResponse, TaskErrorCodes>>;\n readonly appName: string;\n readonly skipOpenApp: boolean;\n readonly requiredUserInteraction: UserInteraction;\n};\n\nexport type CallTaskInAppDAError<TaskErrorCodes = void> =\n | OpenAppDAError\n | CommandErrorResult<TaskErrorCodes>[\"error\"];\n\nexport type CallTaskInAppDAIntermediateValue<UserInteraction> =\n | { readonly requiredUserInteraction: UserInteraction }\n | OpenAppDAIntermediateValue;\n\nexport type CallTaskInAppDAInternalState<TaskResponse, TaskErrorCodes> = {\n readonly taskResponse: TaskResponse | null;\n readonly error: CallTaskInAppDAError<TaskErrorCodes> | null;\n};\n"],
5
- "mappings": "+WAAA,IAAAA,EAAA,kBAAAC,EAAAD",
6
- "names": ["CallTaskInAppDeviceActionTypes_exports", "__toCommonJS"]
4
+ "sourcesContent": ["import {\n type CommandErrorResult,\n type CommandResult,\n} from \"@api/command/model/CommandResult\";\nimport { type InternalApi } from \"@api/device-action/DeviceAction\";\nimport { type UserInteractionRequired } from \"@api/device-action/model/UserInteractionRequired\";\nimport {\n type OpenAppDAError,\n type OpenAppDAIntermediateValue,\n} from \"@api/device-action/os/OpenAppDeviceAction/types\";\n\nexport const callTaskInAppDAStateStep = Object.freeze({\n OPEN_APP: \"os.callTaskInApp.steps.openApp\",\n CALL_TASK: \"os.callTaskInApp.steps.callTask\",\n} as const);\n\nexport type CallTaskInAppDAStateStep =\n (typeof callTaskInAppDAStateStep)[keyof typeof callTaskInAppDAStateStep];\n\nexport type CallTaskInAppDAOutput<TaskResponse> = TaskResponse;\n\nexport type CallTaskInAppDAInput<\n TaskResponse,\n TaskErrorCodes,\n UserInteraction,\n> = {\n readonly task: (\n internalApi: InternalApi,\n ) => Promise<CommandResult<TaskResponse, TaskErrorCodes>>;\n readonly appName: string;\n readonly skipOpenApp: boolean;\n readonly requiredUserInteraction: UserInteraction;\n};\n\nexport type CallTaskInAppDAError<TaskErrorCodes = void> =\n | OpenAppDAError\n | CommandErrorResult<TaskErrorCodes>[\"error\"];\n\nexport type CallTaskInAppDARequiredInteraction = UserInteractionRequired.None;\n\nexport type CallTaskInAppDAIntermediateValue<UserInteraction> =\n | {\n readonly requiredUserInteraction:\n | UserInteraction\n | CallTaskInAppDARequiredInteraction;\n readonly step: CallTaskInAppDAStateStep;\n }\n | OpenAppDAIntermediateValue;\n\nexport type CallTaskInAppDAInternalState<TaskResponse, TaskErrorCodes> = {\n readonly taskResponse: TaskResponse | null;\n readonly error: CallTaskInAppDAError<TaskErrorCodes> | null;\n};\n"],
5
+ "mappings": "yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,8BAAAE,IAAA,eAAAC,EAAAH,GAWO,MAAME,EAA2B,OAAO,OAAO,CACpD,SAAU,iCACV,UAAW,iCACb,CAAU",
6
+ "names": ["CallTaskInAppDeviceActionTypes_exports", "__export", "callTaskInAppDAStateStep", "__toCommonJS"]
7
7
  }
@@ -1,2 +1,2 @@
1
- "use strict";var v=Object.defineProperty;var L=Object.getOwnPropertyDescriptor;var R=Object.getOwnPropertyNames;var b=Object.prototype.hasOwnProperty;var O=(i,a)=>{for(var s in a)v(i,s,{get:a[s],enumerable:!0})},P=(i,a,s,c)=>{if(a&&typeof a=="object"||typeof a=="function")for(let o of R(a))!b.call(i,o)&&o!==s&&v(i,o,{get:()=>a[o],enumerable:!(c=L(a,o))||c.enumerable});return i};var q=i=>P(v({},"__esModule",{value:!0}),i);var B={};O(B,{GetDeviceMetadataDeviceAction:()=>N});module.exports=q(B);var d=require("purify-ts"),n=require("xstate"),f=require("../../../command/model/CommandResult"),l=require("../../../device-action/model/UserInteractionRequired"),h=require("../../../device-action/os/Const"),D=require("../../../device-action/os/GoToDashboard/GoToDashboardDeviceAction"),M=require("../../../device-action/os/ListApps/ListAppsDeviceAction"),y=require("../../../device-action/task/GetApplicationsMetadataTask"),A=require("../../../device-action/task/GetFirmwareMetadataTask"),C=require("../../../device-action/xstate-utils/XStateDeviceAction"),u=require("../../../device-session/DeviceSessionState"),x=require("../../../secure-channel/device-action/ListInstalledApps/types"),V=require("../../../secure-channel/task/ConnectToSecureChannelTask"),p=require("../../../secure-channel/task/types");class N extends C.XStateDeviceAction{makeStateMachine(a){const{getDeviceMetadata:s,getFirmwareMetadata:c,getApplicationsMetadata:o,listAppsSecureChannel:S}=this.extractDependencies(a),t=this.input.unlockTimeout??h.DEFAULT_UNLOCK_TIMEOUT_MS,m=new D.GoToDashboardDeviceAction({input:{unlockTimeout:t}}).makeStateMachine(a),g=new M.ListAppsDeviceAction({input:{unlockTimeout:t}}).makeStateMachine(a);return(0,n.setup)({types:{input:{unlockTimeout:t},context:{},output:{}},actors:{goToDashboard:m,getDeviceMetadata:(0,n.fromPromise)(s),getFirmwareMetadata:(0,n.fromPromise)(c),getApplicationsMetadata:(0,n.fromPromise)(o),listApps:g,listAppsSecureChannel:(0,n.fromObservable)(S)},guards:{hasError:({context:e})=>e._internalState.error!==null,hasMetadata:({context:e})=>e._internalState.firmwareVersion!==null&&e._internalState.firmwareUpdateContext!==null&&e._internalState.customImage!==null&&e._internalState.applications!==null&&e._internalState.applicationsUpdates!==null&&e._internalState.installedLanguages!==null&&e._internalState.catalog!==null,forceUpdate:({context:e})=>!!e.input.forceUpdate,useSecureChannel:({context:e})=>!!e.input.useSecureChannel},actions:{assignErrorFromEvent:(0,n.assign)({_internalState:e=>({...e.context._internalState,error:e.event.error})})}}).createMachine({id:"GetDeviceMetadataDeviceAction",initial:"DeviceReady",context:e=>({input:{useSecureChannel:e.input.useSecureChannel,forceUpdate:e.input.forceUpdate,unlockTimeout:e.input.unlockTimeout},intermediateValue:{requiredUserInteraction:l.UserInteractionRequired.None},_internalState:{error:null,deviceVersion:null,firmware:null,firmwareVersion:null,firmwareUpdateContext:null,customImage:null,installedApps:null,applications:null,applicationsUpdates:null,installedLanguages:null,catalog:null}}),states:{DeviceReady:{always:[{target:"GoToDashboard",guard:"forceUpdate"},{target:"GetDeviceMetadataFromContext"}]},GetDeviceMetadataFromContext:{invoke:{src:"getDeviceMetadata",onDone:{target:"GetDeviceMetadataFromContextResultCheck",actions:(0,n.assign)({_internalState:e=>e.event.output===null?e.context._internalState:{...e.context._internalState,firmwareVersion:e.event.output.firmwareVersion,firmwareUpdateContext:e.event.output.firmwareUpdateContext,customImage:e.event.output.customImage,applications:e.event.output.applications,applicationsUpdates:e.event.output.applicationsUpdates,installedLanguages:e.event.output.installedLanguages,catalog:e.event.output.catalog}})},onError:{target:"Error",actions:"assignErrorFromEvent"}}},GetDeviceMetadataFromContextResultCheck:{always:[{target:"Success",guard:"hasMetadata"},{target:"GoToDashboard"}]},GoToDashboard:{exit:(0,n.assign)({intermediateValue:{requiredUserInteraction:l.UserInteractionRequired.None}}),invoke:{id:"dashboard",src:"goToDashboard",input:e=>({unlockTimeout:e.context.input.unlockTimeout}),onSnapshot:{actions:(0,n.assign)({intermediateValue:e=>e.event.snapshot.context.intermediateValue})},onDone:{target:"GoToDashboardCheck",actions:(0,n.assign)({_internalState:e=>e.event.output.caseOf({Right:()=>e.context._internalState,Left:r=>({...e.context._internalState,error:r})})})},onError:{target:"Error",actions:"assignErrorFromEvent"}}},GoToDashboardCheck:{always:[{target:"Error",guard:"hasError"},{target:"GetFirmwareMetadata"}]},GetFirmwareMetadata:{invoke:{src:"getFirmwareMetadata",onDone:{target:"GetFirmwareMetadataResultCheck",actions:(0,n.assign)({_internalState:e=>{if((0,f.isSuccessCommandResult)(e.event.output)){const r=a.getDeviceSessionState();return r.sessionStateType!==u.DeviceSessionStateType.Connected&&a.setDeviceSessionState({...r,firmwareVersion:e.event.output.data.firmwareVersion,firmwareUpdateContext:e.event.output.data.firmwareUpdateContext,customImage:e.event.output.data.customImage}),{...e.context._internalState,deviceVersion:e.event.output.data.deviceVersion,firmware:e.event.output.data.firmware,firmwareVersion:e.event.output.data.firmwareVersion,firmwareUpdateContext:e.event.output.data.firmwareUpdateContext,customImage:e.event.output.data.customImage}}return{...e.context._internalState,error:e.event.output.error}}})},onError:{target:"Error",actions:"assignErrorFromEvent"}}},GetFirmwareMetadataResultCheck:{always:[{guard:"hasError",target:"Error"},{guard:"useSecureChannel",target:"ListAppsSecureChannel"},{target:"ListApps"}]},ListAppsSecureChannel:{exit:(0,n.assign)({intermediateValue:{requiredUserInteraction:l.UserInteractionRequired.None}}),invoke:{id:"listAppsSecureChannel",src:"listAppsSecureChannel",input:e=>({firmware:e.context._internalState.firmware,firmwareVersion:e.context._internalState.firmwareVersion}),onSnapshot:{actions:(0,n.assign)({intermediateValue:e=>{switch(e.event.snapshot.context?.type){case p.SecureChannelEventType.DeviceId:return{...e.context.intermediateValue,deviceId:e.event.snapshot.context.payload.deviceId};case p.SecureChannelEventType.PermissionRequested:return{...e.context.intermediateValue,requiredUserInteraction:l.UserInteractionRequired.AllowSecureConnection};case p.SecureChannelEventType.PermissionGranted:{const r=a.getDeviceSessionState();return r.sessionStateType!==u.DeviceSessionStateType.Connected&&a.setDeviceSessionState({...r,isSecureConnectionAllowed:!0}),{...e.context.intermediateValue,requiredUserInteraction:l.UserInteractionRequired.None}}default:return{...e.context.intermediateValue}}},_internalState:e=>{if(e.event.snapshot.context?.type===p.SecureChannelEventType.Error)return{...e.context._internalState,error:e.event.snapshot.context.error.mapDAErrors()};if(e.event.snapshot.context?.type===p.SecureChannelEventType.Result){if((0,x.installedAppResultGuard)(e.event.snapshot.context.payload))return{...e.context._internalState,installedApps:e.event.snapshot.context.payload.map(r=>({name:r.name,hash:r.hash,hashCode:r.hash_code_data}))};throw new Error(`Invalid result ${JSON.stringify(e.event.snapshot.context.payload)}`)}return{...e.context._internalState}}})},onDone:{target:"ListAppsCheck"},onError:{target:"Error",actions:"assignErrorFromEvent"}}},ListApps:{exit:(0,n.assign)({intermediateValue:{requiredUserInteraction:l.UserInteractionRequired.None}}),invoke:{id:"listApps",src:"listApps",input:e=>({unlockTimeout:e.context.input.unlockTimeout}),onSnapshot:{actions:(0,n.assign)({intermediateValue:e=>e.event.snapshot.context.intermediateValue})},onDone:{target:"ListAppsCheck",actions:(0,n.assign)({_internalState:e=>e.event.output.isLeft()?{...e.context._internalState,error:e.event.output.extract()}:{...e.context._internalState,installedApps:e.event.output.unsafeCoerce().map(r=>({name:r.appName,hash:r.appFullHash,hashCode:r.appCodeHash}))}})},onError:{target:"Error",actions:"assignErrorFromEvent"}}},ListAppsCheck:{always:[{target:"Error",guard:"hasError"},{target:"GetApplicationsMetadata"}]},GetApplicationsMetadata:{invoke:{src:"getApplicationsMetadata",input:e=>({deviceVersion:e.context._internalState.deviceVersion,firmware:e.context._internalState.firmware,firmwareVersion:e.context._internalState.firmwareVersion,installedApps:e.context._internalState.installedApps}),onDone:{target:"GetApplicationsMetadataResultCheck",actions:(0,n.assign)({_internalState:e=>{if((0,f.isSuccessCommandResult)(e.event.output)){const r=a.getDeviceSessionState();return r.sessionStateType!==u.DeviceSessionStateType.Connected&&a.setDeviceSessionState({...r,installedApps:e.event.output.data.applications,appsUpdates:e.event.output.data.applicationsUpdates,installedLanguages:e.event.output.data.installedLanguages,catalog:e.event.output.data.catalog}),{...e.context._internalState,applications:e.event.output.data.applications,applicationsUpdates:e.event.output.data.applicationsUpdates,installedLanguages:e.event.output.data.installedLanguages,catalog:e.event.output.data.catalog}}return{...e.context._internalState,error:e.event.output.error}}})},onError:{target:"Error",actions:"assignErrorFromEvent"}}},GetApplicationsMetadataResultCheck:{always:[{guard:"hasError",target:"Error"},{target:"Success"}]},Success:{type:"final"},Error:{type:"final"}},output:e=>{const{context:r}=e,{error:w,firmwareVersion:I,firmwareUpdateContext:G,customImage:E,applications:F,applicationsUpdates:U,installedLanguages:k,catalog:T}=r._internalState;return w?(0,d.Left)(w):(0,d.Right)({firmwareVersion:I,firmwareUpdateContext:G,customImage:E,applications:F,applicationsUpdates:U,installedLanguages:k,catalog:T})}})}extractDependencies(a){return{getDeviceMetadata:()=>{const t=a.getDeviceSessionState();return t.sessionStateType===u.DeviceSessionStateType.Connected||t.firmwareVersion?.metadata===void 0||t.firmwareUpdateContext===void 0||t.customImage===void 0||t.installedApps.length===0||t.appsUpdates===void 0||t.installedLanguages===void 0||t.catalog===void 0?Promise.resolve(null):Promise.resolve({firmwareVersion:t.firmwareVersion,firmwareUpdateContext:t.firmwareUpdateContext,customImage:t.customImage,applications:t.installedApps,applicationsUpdates:t.appsUpdates,installedLanguages:t.installedLanguages,catalog:t.catalog})},getFirmwareMetadata:async()=>new A.GetFirmwareMetadataTask(a).run(),getApplicationsMetadata:async t=>new y.GetApplicationsMetadataTask(a,{deviceVersion:t.input.deviceVersion,firmware:t.input.firmware,firmwareVersion:t.input.firmwareVersion,installedApps:t.input.installedApps}).run(),listAppsSecureChannel:t=>{const{firmware:m,firmwareVersion:g}=t.input,e=a.getSecureChannelService().listInstalledApps(g.metadata,m);return new V.ConnectToSecureChannelTask(a,{connection:e}).run()}}}}0&&(module.exports={GetDeviceMetadataDeviceAction});
1
+ "use strict";var f=Object.defineProperty;var R=Object.getOwnPropertyDescriptor;var b=Object.getOwnPropertyNames;var P=Object.prototype.hasOwnProperty;var O=(i,a)=>{for(var s in a)f(i,s,{get:a[s],enumerable:!0})},N=(i,a,s,c)=>{if(a&&typeof a=="object"||typeof a=="function")for(let o of b(a))!P.call(i,o)&&o!==s&&f(i,o,{get:()=>a[o],enumerable:!(c=R(a,o))||c.enumerable});return i};var q=i=>N(f({},"__esModule",{value:!0}),i);var B={};O(B,{GetDeviceMetadataDeviceAction:()=>H});module.exports=q(B);var m=require("purify-ts"),n=require("xstate"),S=require("../../../command/model/CommandResult"),l=require("../../../device-action/model/UserInteractionRequired"),h=require("../../../device-action/os/Const"),A=require("../../../device-action/os/GoToDashboard/GoToDashboardDeviceAction"),M=require("../../../device-action/os/ListApps/ListAppsDeviceAction"),y=require("../../../device-action/task/GetApplicationsMetadataTask"),C=require("../../../device-action/task/GetFirmwareMetadataTask"),x=require("../../../device-action/xstate-utils/XStateDeviceAction"),u=require("../../../device-session/DeviceSessionState"),V=require("../../../secure-channel/device-action/ListInstalledApps/types"),E=require("../../../secure-channel/task/ConnectToSecureChannelTask"),p=require("../../../secure-channel/task/types"),d=require("./types");class H extends x.XStateDeviceAction{makeStateMachine(a){const{getDeviceMetadata:s,getFirmwareMetadata:c,getApplicationsMetadata:o,listAppsSecureChannel:D}=this.extractDependencies(a),t=this.input.unlockTimeout??h.DEFAULT_UNLOCK_TIMEOUT_MS,g=new A.GoToDashboardDeviceAction({input:{unlockTimeout:t}}).makeStateMachine(a),v=new M.ListAppsDeviceAction({input:{unlockTimeout:t}}).makeStateMachine(a);return(0,n.setup)({types:{input:{unlockTimeout:t},context:{},output:{}},actors:{goToDashboard:g,getDeviceMetadata:(0,n.fromPromise)(s),getFirmwareMetadata:(0,n.fromPromise)(c),getApplicationsMetadata:(0,n.fromPromise)(o),listApps:v,listAppsSecureChannel:(0,n.fromObservable)(D)},guards:{hasError:({context:e})=>e._internalState.error!==null,hasMetadata:({context:e})=>e._internalState.firmwareVersion!==null&&e._internalState.firmwareUpdateContext!==null&&e._internalState.customImage!==null&&e._internalState.applications!==null&&e._internalState.applicationsUpdates!==null&&e._internalState.installedLanguages!==null&&e._internalState.catalog!==null,forceUpdate:({context:e})=>!!e.input.forceUpdate,useSecureChannel:({context:e})=>!!e.input.useSecureChannel},actions:{assignErrorFromEvent:(0,n.assign)({_internalState:e=>({...e.context._internalState,error:e.event.error})})}}).createMachine({id:"GetDeviceMetadataDeviceAction",initial:"DeviceReady",context:e=>({input:{useSecureChannel:e.input.useSecureChannel,forceUpdate:e.input.forceUpdate,unlockTimeout:e.input.unlockTimeout},intermediateValue:{requiredUserInteraction:l.UserInteractionRequired.None,step:d.getDeviceMetadataDAStateStep.GET_DEVICE_METADATA},_internalState:{error:null,deviceVersion:null,firmware:null,firmwareVersion:null,firmwareUpdateContext:null,customImage:null,installedApps:null,applications:null,applicationsUpdates:null,installedLanguages:null,catalog:null}}),states:{DeviceReady:{always:[{target:"GoToDashboard",guard:"forceUpdate"},{target:"GetDeviceMetadataFromContext"}]},GetDeviceMetadataFromContext:{invoke:{src:"getDeviceMetadata",onDone:{target:"GetDeviceMetadataFromContextResultCheck",actions:(0,n.assign)({_internalState:e=>e.event.output===null?e.context._internalState:{...e.context._internalState,firmwareVersion:e.event.output.firmwareVersion,firmwareUpdateContext:e.event.output.firmwareUpdateContext,customImage:e.event.output.customImage,applications:e.event.output.applications,applicationsUpdates:e.event.output.applicationsUpdates,installedLanguages:e.event.output.installedLanguages,catalog:e.event.output.catalog}})},onError:{target:"Error",actions:"assignErrorFromEvent"}}},GetDeviceMetadataFromContextResultCheck:{always:[{target:"Success",guard:"hasMetadata"},{target:"GoToDashboard"}]},GoToDashboard:{exit:(0,n.assign)({intermediateValue:{requiredUserInteraction:l.UserInteractionRequired.None,step:d.getDeviceMetadataDAStateStep.GO_TO_DASHBOARD}}),invoke:{id:"dashboard",src:"goToDashboard",input:e=>({unlockTimeout:e.context.input.unlockTimeout}),onSnapshot:{actions:(0,n.assign)({intermediateValue:e=>e.event.snapshot.context.intermediateValue})},onDone:{target:"GoToDashboardCheck",actions:(0,n.assign)({_internalState:e=>e.event.output.caseOf({Right:()=>e.context._internalState,Left:r=>({...e.context._internalState,error:r})})})},onError:{target:"Error",actions:"assignErrorFromEvent"}}},GoToDashboardCheck:{always:[{target:"Error",guard:"hasError"},{target:"GetFirmwareMetadata"}]},GetFirmwareMetadata:{invoke:{src:"getFirmwareMetadata",onDone:{target:"GetFirmwareMetadataResultCheck",actions:(0,n.assign)({_internalState:e=>{if((0,S.isSuccessCommandResult)(e.event.output)){const r=a.getDeviceSessionState();return r.sessionStateType!==u.DeviceSessionStateType.Connected&&a.setDeviceSessionState({...r,firmwareVersion:e.event.output.data.firmwareVersion,firmwareUpdateContext:e.event.output.data.firmwareUpdateContext,customImage:e.event.output.data.customImage}),{...e.context._internalState,deviceVersion:e.event.output.data.deviceVersion,firmware:e.event.output.data.firmware,firmwareVersion:e.event.output.data.firmwareVersion,firmwareUpdateContext:e.event.output.data.firmwareUpdateContext,customImage:e.event.output.data.customImage}}return{...e.context._internalState,error:e.event.output.error}}})},onError:{target:"Error",actions:"assignErrorFromEvent"}}},GetFirmwareMetadataResultCheck:{always:[{guard:"hasError",target:"Error"},{guard:"useSecureChannel",target:"ListAppsSecureChannel"},{target:"ListApps"}]},ListAppsSecureChannel:{exit:(0,n.assign)({intermediateValue:{requiredUserInteraction:l.UserInteractionRequired.None,step:d.getDeviceMetadataDAStateStep.LIST_APPS_SECURE_CHANNEL}}),invoke:{id:"listAppsSecureChannel",src:"listAppsSecureChannel",input:e=>({firmware:e.context._internalState.firmware,firmwareVersion:e.context._internalState.firmwareVersion}),onSnapshot:{actions:(0,n.assign)({intermediateValue:e=>{switch(e.event.snapshot.context?.type){case p.SecureChannelEventType.DeviceId:return{...e.context.intermediateValue,deviceId:e.event.snapshot.context.payload.deviceId};case p.SecureChannelEventType.PermissionRequested:return{...e.context.intermediateValue,requiredUserInteraction:l.UserInteractionRequired.AllowSecureConnection};case p.SecureChannelEventType.PermissionGranted:{const r=a.getDeviceSessionState();return r.sessionStateType!==u.DeviceSessionStateType.Connected&&a.setDeviceSessionState({...r,isSecureConnectionAllowed:!0}),{...e.context.intermediateValue,requiredUserInteraction:l.UserInteractionRequired.None}}default:return{...e.context.intermediateValue}}},_internalState:e=>{if(e.event.snapshot.context?.type===p.SecureChannelEventType.Error)return{...e.context._internalState,error:e.event.snapshot.context.error.mapDAErrors()};if(e.event.snapshot.context?.type===p.SecureChannelEventType.Result){if((0,V.installedAppResultGuard)(e.event.snapshot.context.payload))return{...e.context._internalState,installedApps:e.event.snapshot.context.payload.map(r=>({name:r.name,hash:r.hash,hashCode:r.hash_code_data}))};throw new Error(`Invalid result ${JSON.stringify(e.event.snapshot.context.payload)}`)}return{...e.context._internalState}}})},onDone:{target:"ListAppsCheck"},onError:{target:"Error",actions:"assignErrorFromEvent"}}},ListApps:{exit:(0,n.assign)({intermediateValue:{requiredUserInteraction:l.UserInteractionRequired.None,step:d.getDeviceMetadataDAStateStep.LIST_APPS}}),invoke:{id:"listApps",src:"listApps",input:e=>({unlockTimeout:e.context.input.unlockTimeout}),onSnapshot:{actions:(0,n.assign)({intermediateValue:e=>e.event.snapshot.context.intermediateValue})},onDone:{target:"ListAppsCheck",actions:(0,n.assign)({_internalState:e=>e.event.output.isLeft()?{...e.context._internalState,error:e.event.output.extract()}:{...e.context._internalState,installedApps:e.event.output.unsafeCoerce().map(r=>({name:r.appName,hash:r.appFullHash,hashCode:r.appCodeHash}))}})},onError:{target:"Error",actions:"assignErrorFromEvent"}}},ListAppsCheck:{always:[{target:"Error",guard:"hasError"},{target:"GetApplicationsMetadata"}]},GetApplicationsMetadata:{invoke:{src:"getApplicationsMetadata",input:e=>({deviceVersion:e.context._internalState.deviceVersion,firmware:e.context._internalState.firmware,firmwareVersion:e.context._internalState.firmwareVersion,installedApps:e.context._internalState.installedApps}),onDone:{target:"GetApplicationsMetadataResultCheck",actions:(0,n.assign)({_internalState:e=>{if((0,S.isSuccessCommandResult)(e.event.output)){const r=a.getDeviceSessionState();return r.sessionStateType!==u.DeviceSessionStateType.Connected&&a.setDeviceSessionState({...r,installedApps:e.event.output.data.applications,appsUpdates:e.event.output.data.applicationsUpdates,installedLanguages:e.event.output.data.installedLanguages,catalog:e.event.output.data.catalog}),{...e.context._internalState,applications:e.event.output.data.applications,applicationsUpdates:e.event.output.data.applicationsUpdates,installedLanguages:e.event.output.data.installedLanguages,catalog:e.event.output.data.catalog}}return{...e.context._internalState,error:e.event.output.error}}})},onError:{target:"Error",actions:"assignErrorFromEvent"}}},GetApplicationsMetadataResultCheck:{always:[{guard:"hasError",target:"Error"},{target:"Success"}]},Success:{type:"final"},Error:{type:"final"}},output:e=>{const{context:r}=e,{error:w,firmwareVersion:I,firmwareUpdateContext:G,customImage:F,applications:U,applicationsUpdates:T,installedLanguages:k,catalog:L}=r._internalState;return w?(0,m.Left)(w):(0,m.Right)({firmwareVersion:I,firmwareUpdateContext:G,customImage:F,applications:U,applicationsUpdates:T,installedLanguages:k,catalog:L})}})}extractDependencies(a){return{getDeviceMetadata:()=>{const t=a.getDeviceSessionState();return t.sessionStateType===u.DeviceSessionStateType.Connected||t.firmwareVersion?.metadata===void 0||t.firmwareUpdateContext===void 0||t.customImage===void 0||t.installedApps.length===0||t.appsUpdates===void 0||t.installedLanguages===void 0||t.catalog===void 0?Promise.resolve(null):Promise.resolve({firmwareVersion:t.firmwareVersion,firmwareUpdateContext:t.firmwareUpdateContext,customImage:t.customImage,applications:t.installedApps,applicationsUpdates:t.appsUpdates,installedLanguages:t.installedLanguages,catalog:t.catalog})},getFirmwareMetadata:async()=>new C.GetFirmwareMetadataTask(a).run(),getApplicationsMetadata:async t=>new y.GetApplicationsMetadataTask(a,{deviceVersion:t.input.deviceVersion,firmware:t.input.firmware,firmwareVersion:t.input.firmwareVersion,installedApps:t.input.installedApps}).run(),listAppsSecureChannel:t=>{const{firmware:g,firmwareVersion:v}=t.input,e=a.getSecureChannelService().listInstalledApps(v.metadata,g);return new E.ConnectToSecureChannelTask(a,{connection:e}).run()}}}}0&&(module.exports={GetDeviceMetadataDeviceAction});
2
2
  //# sourceMappingURL=GetDeviceMetadataDeviceAction.js.map