@ledgerhq/device-management-kit 0.0.0-develop-20250106155719 → 0.0.0-webhid-20250124103640

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 (189) hide show
  1. package/lib/cjs/package.json +4 -1
  2. package/lib/cjs/src/api/DeviceManagementKit.test.js +1 -1
  3. package/lib/cjs/src/api/DeviceManagementKit.test.js.map +2 -2
  4. package/lib/cjs/src/api/DeviceManagementKitBuilder.js +1 -1
  5. package/lib/cjs/src/api/DeviceManagementKitBuilder.js.map +2 -2
  6. package/lib/cjs/src/api/DmkConfig.js +1 -1
  7. package/lib/cjs/src/api/DmkConfig.js.map +1 -1
  8. package/lib/cjs/src/api/command/model/CommandResult.js.map +1 -1
  9. package/lib/cjs/src/api/command/use-case/SendCommandUseCase.test.js +1 -1
  10. package/lib/cjs/src/api/command/use-case/SendCommandUseCase.test.js.map +2 -2
  11. package/lib/cjs/src/api/command/utils/CommandUtils.js +1 -1
  12. package/lib/cjs/src/api/command/utils/CommandUtils.js.map +2 -2
  13. package/lib/cjs/src/api/device-action/DeviceAction.js.map +1 -1
  14. package/lib/cjs/src/api/device-action/__test-utils__/makeInternalApi.js +1 -1
  15. package/lib/cjs/src/api/device-action/__test-utils__/makeInternalApi.js.map +3 -3
  16. package/lib/cjs/src/api/device-action/os/GetDeviceStatus/GetDeviceStatusDeviceAction.test.js +1 -1
  17. package/lib/cjs/src/api/device-action/os/GetDeviceStatus/GetDeviceStatusDeviceAction.test.js.map +3 -3
  18. package/lib/cjs/src/api/device-action/os/GoToDashboard/GoToDashboardDeviceAction.test.js +1 -1
  19. package/lib/cjs/src/api/device-action/os/GoToDashboard/GoToDashboardDeviceAction.test.js.map +3 -3
  20. package/lib/cjs/src/api/device-action/os/ListAppsWithMetadata/ListAppsWithMetadataDeviceAction.js +1 -1
  21. package/lib/cjs/src/api/device-action/os/ListAppsWithMetadata/ListAppsWithMetadataDeviceAction.js.map +2 -2
  22. package/lib/cjs/src/api/device-action/os/ListAppsWithMetadata/ListAppsWithMetadataDeviceAction.test.js +1 -1
  23. package/lib/cjs/src/api/device-action/os/ListAppsWithMetadata/ListAppsWithMetadataDeviceAction.test.js.map +3 -3
  24. package/lib/cjs/src/api/device-action/os/OpenAppDeviceAction/OpenAppDeviceAction.js +1 -1
  25. package/lib/cjs/src/api/device-action/os/OpenAppDeviceAction/OpenAppDeviceAction.js.map +2 -2
  26. package/lib/cjs/src/api/device-action/os/OpenAppDeviceAction/OpenAppDeviceAction.test.js +1 -1
  27. package/lib/cjs/src/api/device-action/os/OpenAppDeviceAction/OpenAppDeviceAction.test.js.map +3 -3
  28. package/lib/cjs/src/api/device-action/os/OpenAppDeviceAction/types.js +1 -1
  29. package/lib/cjs/src/api/device-action/os/OpenAppDeviceAction/types.js.map +1 -1
  30. package/lib/cjs/src/api/device-action/os/SendCommandInAppDeviceAction/SendCommandInAppDeviceAction.js +1 -1
  31. package/lib/cjs/src/api/device-action/os/SendCommandInAppDeviceAction/SendCommandInAppDeviceAction.js.map +2 -2
  32. package/lib/cjs/src/api/device-action/os/SendCommandInAppDeviceAction/SendCommandInAppDeviceActionTypes.js +1 -1
  33. package/lib/cjs/src/api/device-action/os/SendCommandInAppDeviceAction/SendCommandInAppDeviceActionTypes.js.map +1 -1
  34. package/lib/cjs/src/api/device-session/DeviceSessionState.js +1 -1
  35. package/lib/cjs/src/api/device-session/DeviceSessionState.js.map +2 -2
  36. package/lib/cjs/src/api/device-session/use-case/ToggleDeviceSessionRefresher.test.js +1 -1
  37. package/lib/cjs/src/api/device-session/use-case/ToggleDeviceSessionRefresher.test.js.map +2 -2
  38. package/lib/cjs/src/api/types.js.map +1 -1
  39. package/lib/cjs/src/di.js +1 -1
  40. package/lib/cjs/src/di.js.map +2 -2
  41. package/lib/cjs/src/internal/device-session/model/DeviceSession.js +1 -1
  42. package/lib/cjs/src/internal/device-session/model/DeviceSession.js.map +3 -3
  43. package/lib/cjs/src/internal/device-session/service/DefaultDeviceSessionService.test.js +1 -1
  44. package/lib/cjs/src/internal/device-session/service/DefaultDeviceSessionService.test.js.map +2 -2
  45. package/lib/cjs/src/internal/device-session/use-case/CloseSessionsUseCase.test.js +1 -1
  46. package/lib/cjs/src/internal/device-session/use-case/CloseSessionsUseCase.test.js.map +2 -2
  47. package/lib/cjs/src/internal/device-session/use-case/GetDeviceSessionStateUseCase.test.js +1 -1
  48. package/lib/cjs/src/internal/device-session/use-case/GetDeviceSessionStateUseCase.test.js.map +2 -2
  49. package/lib/cjs/src/internal/discovery/di/discoveryModule.test.js +1 -1
  50. package/lib/cjs/src/internal/discovery/di/discoveryModule.test.js.map +2 -2
  51. package/lib/cjs/src/internal/discovery/use-case/ConnectUseCase.test.js +1 -1
  52. package/lib/cjs/src/internal/discovery/use-case/ConnectUseCase.test.js.map +2 -2
  53. package/lib/cjs/src/internal/discovery/use-case/DisconnectUseCase.test.js +1 -1
  54. package/lib/cjs/src/internal/discovery/use-case/DisconnectUseCase.test.js.map +2 -2
  55. package/lib/cjs/src/internal/discovery/use-case/GetConnectedDeviceUseCase.test.js +1 -1
  56. package/lib/cjs/src/internal/discovery/use-case/GetConnectedDeviceUseCase.test.js.map +2 -2
  57. package/lib/cjs/src/internal/discovery/use-case/ListConnectedDevicesUseCase.test.js +1 -1
  58. package/lib/cjs/src/internal/discovery/use-case/ListConnectedDevicesUseCase.test.js.map +2 -2
  59. package/lib/cjs/src/internal/discovery/use-case/ListenToConnectedDeviceUseCase.test.js +1 -1
  60. package/lib/cjs/src/internal/discovery/use-case/ListenToConnectedDeviceUseCase.test.js.map +2 -2
  61. package/lib/cjs/src/internal/manager-api/data/AxiosManagerApiDataSource.js +1 -1
  62. package/lib/cjs/src/internal/manager-api/data/AxiosManagerApiDataSource.js.map +3 -3
  63. package/lib/cjs/src/internal/manager-api/data/AxiosManagerApiDataSource.test.js +1 -1
  64. package/lib/cjs/src/internal/manager-api/data/AxiosManagerApiDataSource.test.js.map +3 -3
  65. package/lib/cjs/src/internal/manager-api/data/ManagerApiDataSource.js +1 -1
  66. package/lib/cjs/src/internal/manager-api/data/ManagerApiDataSource.js.map +1 -1
  67. package/lib/cjs/src/internal/manager-api/data/__mocks__/AxiosManagerApiDataSource.js +1 -1
  68. package/lib/cjs/src/internal/manager-api/data/__mocks__/AxiosManagerApiDataSource.js.map +2 -2
  69. package/lib/cjs/src/internal/manager-api/di/managerApiModule.test.js +1 -1
  70. package/lib/cjs/src/internal/manager-api/di/managerApiModule.test.js.map +2 -2
  71. package/lib/cjs/src/internal/manager-api/model/Const.js +1 -1
  72. package/lib/cjs/src/internal/manager-api/model/Const.js.map +3 -3
  73. package/lib/cjs/src/internal/manager-api/model/Errors.js +1 -1
  74. package/lib/cjs/src/internal/manager-api/model/Errors.js.map +3 -3
  75. package/lib/cjs/src/internal/manager-api/model/Params.js +2 -0
  76. package/lib/cjs/src/internal/manager-api/model/Params.js.map +7 -0
  77. package/lib/cjs/src/internal/manager-api/service/DefaultManagerApiService.test.js +1 -1
  78. package/lib/cjs/src/internal/manager-api/service/DefaultManagerApiService.test.js.map +3 -3
  79. package/lib/cjs/src/internal/send/use-case/SendApduUseCase.test.js +1 -1
  80. package/lib/cjs/src/internal/send/use-case/SendApduUseCase.test.js.map +2 -2
  81. package/lib/cjs/src/internal/transport/di/transportModule.test.js +1 -1
  82. package/lib/cjs/src/internal/transport/di/transportModule.test.js.map +2 -2
  83. package/lib/esm/package.json +4 -1
  84. package/lib/esm/src/api/DeviceManagementKit.test.js +1 -1
  85. package/lib/esm/src/api/DeviceManagementKit.test.js.map +2 -2
  86. package/lib/esm/src/api/DeviceManagementKitBuilder.js +1 -1
  87. package/lib/esm/src/api/DeviceManagementKitBuilder.js.map +3 -3
  88. package/lib/esm/src/api/command/model/CommandResult.js.map +1 -1
  89. package/lib/esm/src/api/command/use-case/SendCommandUseCase.test.js +1 -1
  90. package/lib/esm/src/api/command/use-case/SendCommandUseCase.test.js.map +2 -2
  91. package/lib/esm/src/api/command/utils/CommandUtils.js +1 -1
  92. package/lib/esm/src/api/command/utils/CommandUtils.js.map +2 -2
  93. package/lib/esm/src/api/device-action/__test-utils__/makeInternalApi.js +1 -1
  94. package/lib/esm/src/api/device-action/__test-utils__/makeInternalApi.js.map +3 -3
  95. package/lib/esm/src/api/device-action/os/GetDeviceStatus/GetDeviceStatusDeviceAction.test.js +1 -1
  96. package/lib/esm/src/api/device-action/os/GetDeviceStatus/GetDeviceStatusDeviceAction.test.js.map +3 -3
  97. package/lib/esm/src/api/device-action/os/GoToDashboard/GoToDashboardDeviceAction.test.js +1 -1
  98. package/lib/esm/src/api/device-action/os/GoToDashboard/GoToDashboardDeviceAction.test.js.map +3 -3
  99. package/lib/esm/src/api/device-action/os/ListAppsWithMetadata/ListAppsWithMetadataDeviceAction.js +1 -1
  100. package/lib/esm/src/api/device-action/os/ListAppsWithMetadata/ListAppsWithMetadataDeviceAction.js.map +2 -2
  101. package/lib/esm/src/api/device-action/os/ListAppsWithMetadata/ListAppsWithMetadataDeviceAction.test.js +1 -1
  102. package/lib/esm/src/api/device-action/os/ListAppsWithMetadata/ListAppsWithMetadataDeviceAction.test.js.map +3 -3
  103. package/lib/esm/src/api/device-action/os/OpenAppDeviceAction/OpenAppDeviceAction.js +1 -1
  104. package/lib/esm/src/api/device-action/os/OpenAppDeviceAction/OpenAppDeviceAction.js.map +2 -2
  105. package/lib/esm/src/api/device-action/os/OpenAppDeviceAction/OpenAppDeviceAction.test.js +1 -1
  106. package/lib/esm/src/api/device-action/os/OpenAppDeviceAction/OpenAppDeviceAction.test.js.map +3 -3
  107. package/lib/esm/src/api/device-action/os/SendCommandInAppDeviceAction/SendCommandInAppDeviceAction.js +1 -1
  108. package/lib/esm/src/api/device-action/os/SendCommandInAppDeviceAction/SendCommandInAppDeviceAction.js.map +2 -2
  109. package/lib/esm/src/api/device-session/DeviceSessionState.js.map +2 -2
  110. package/lib/esm/src/api/device-session/use-case/ToggleDeviceSessionRefresher.test.js +1 -1
  111. package/lib/esm/src/api/device-session/use-case/ToggleDeviceSessionRefresher.test.js.map +2 -2
  112. package/lib/esm/src/di.js +1 -1
  113. package/lib/esm/src/di.js.map +3 -3
  114. package/lib/esm/src/internal/device-session/model/DeviceSession.js +1 -1
  115. package/lib/esm/src/internal/device-session/model/DeviceSession.js.map +3 -3
  116. package/lib/esm/src/internal/device-session/service/DefaultDeviceSessionService.test.js +1 -1
  117. package/lib/esm/src/internal/device-session/service/DefaultDeviceSessionService.test.js.map +2 -2
  118. package/lib/esm/src/internal/device-session/use-case/CloseSessionsUseCase.test.js +1 -1
  119. package/lib/esm/src/internal/device-session/use-case/CloseSessionsUseCase.test.js.map +2 -2
  120. package/lib/esm/src/internal/device-session/use-case/GetDeviceSessionStateUseCase.test.js +1 -1
  121. package/lib/esm/src/internal/device-session/use-case/GetDeviceSessionStateUseCase.test.js.map +2 -2
  122. package/lib/esm/src/internal/discovery/di/discoveryModule.test.js +1 -1
  123. package/lib/esm/src/internal/discovery/di/discoveryModule.test.js.map +2 -2
  124. package/lib/esm/src/internal/discovery/use-case/ConnectUseCase.test.js +1 -1
  125. package/lib/esm/src/internal/discovery/use-case/ConnectUseCase.test.js.map +2 -2
  126. package/lib/esm/src/internal/discovery/use-case/DisconnectUseCase.test.js +1 -1
  127. package/lib/esm/src/internal/discovery/use-case/DisconnectUseCase.test.js.map +2 -2
  128. package/lib/esm/src/internal/discovery/use-case/GetConnectedDeviceUseCase.test.js +1 -1
  129. package/lib/esm/src/internal/discovery/use-case/GetConnectedDeviceUseCase.test.js.map +2 -2
  130. package/lib/esm/src/internal/discovery/use-case/ListConnectedDevicesUseCase.test.js +1 -1
  131. package/lib/esm/src/internal/discovery/use-case/ListConnectedDevicesUseCase.test.js.map +2 -2
  132. package/lib/esm/src/internal/discovery/use-case/ListenToConnectedDeviceUseCase.test.js +1 -1
  133. package/lib/esm/src/internal/discovery/use-case/ListenToConnectedDeviceUseCase.test.js.map +2 -2
  134. package/lib/esm/src/internal/manager-api/data/AxiosManagerApiDataSource.js +1 -1
  135. package/lib/esm/src/internal/manager-api/data/AxiosManagerApiDataSource.js.map +3 -3
  136. package/lib/esm/src/internal/manager-api/data/AxiosManagerApiDataSource.test.js +1 -1
  137. package/lib/esm/src/internal/manager-api/data/AxiosManagerApiDataSource.test.js.map +3 -3
  138. package/lib/esm/src/internal/manager-api/data/__mocks__/AxiosManagerApiDataSource.js +1 -1
  139. package/lib/esm/src/internal/manager-api/data/__mocks__/AxiosManagerApiDataSource.js.map +2 -2
  140. package/lib/esm/src/internal/manager-api/di/managerApiModule.test.js +1 -1
  141. package/lib/esm/src/internal/manager-api/di/managerApiModule.test.js.map +2 -2
  142. package/lib/esm/src/internal/manager-api/model/Const.js +1 -1
  143. package/lib/esm/src/internal/manager-api/model/Const.js.map +3 -3
  144. package/lib/esm/src/internal/manager-api/model/Errors.js +1 -1
  145. package/lib/esm/src/internal/manager-api/model/Errors.js.map +3 -3
  146. package/lib/esm/src/internal/manager-api/model/Params.js +1 -0
  147. package/lib/esm/src/internal/manager-api/model/Params.js.map +7 -0
  148. package/lib/esm/src/internal/manager-api/service/DefaultManagerApiService.test.js +1 -1
  149. package/lib/esm/src/internal/manager-api/service/DefaultManagerApiService.test.js.map +3 -3
  150. package/lib/esm/src/internal/send/use-case/SendApduUseCase.test.js +1 -1
  151. package/lib/esm/src/internal/send/use-case/SendApduUseCase.test.js.map +2 -2
  152. package/lib/esm/src/internal/transport/di/transportModule.test.js +1 -1
  153. package/lib/esm/src/internal/transport/di/transportModule.test.js.map +2 -2
  154. package/lib/types/src/api/DeviceManagementKitBuilder.d.ts.map +1 -1
  155. package/lib/types/src/api/DmkConfig.d.ts +1 -0
  156. package/lib/types/src/api/DmkConfig.d.ts.map +1 -1
  157. package/lib/types/src/api/command/model/CommandResult.d.ts +1 -2
  158. package/lib/types/src/api/command/model/CommandResult.d.ts.map +1 -1
  159. package/lib/types/src/api/device-action/DeviceAction.d.ts +1 -1
  160. package/lib/types/src/api/device-action/DeviceAction.d.ts.map +1 -1
  161. package/lib/types/src/api/device-action/os/ListAppsWithMetadata/ListAppsWithMetadataDeviceAction.d.ts.map +1 -1
  162. package/lib/types/src/api/device-action/os/OpenAppDeviceAction/OpenAppDeviceAction.d.ts.map +1 -1
  163. package/lib/types/src/api/device-action/os/OpenAppDeviceAction/types.d.ts +1 -0
  164. package/lib/types/src/api/device-action/os/OpenAppDeviceAction/types.d.ts.map +1 -1
  165. package/lib/types/src/api/device-action/os/SendCommandInAppDeviceAction/SendCommandInAppDeviceAction.d.ts.map +1 -1
  166. package/lib/types/src/api/device-action/os/SendCommandInAppDeviceAction/SendCommandInAppDeviceActionTypes.d.ts +1 -0
  167. package/lib/types/src/api/device-action/os/SendCommandInAppDeviceAction/SendCommandInAppDeviceActionTypes.d.ts.map +1 -1
  168. package/lib/types/src/api/device-session/DeviceSessionState.d.ts +5 -0
  169. package/lib/types/src/api/device-session/DeviceSessionState.d.ts.map +1 -1
  170. package/lib/types/src/api/transport/model/Errors.d.ts +26 -26
  171. package/lib/types/src/api/transport/model/Errors.d.ts.map +1 -1
  172. package/lib/types/src/api/types.d.ts +1 -1
  173. package/lib/types/src/api/types.d.ts.map +1 -1
  174. package/lib/types/src/di.d.ts.map +1 -1
  175. package/lib/types/src/internal/device-session/model/DeviceSession.d.ts.map +1 -1
  176. package/lib/types/src/internal/manager-api/data/AxiosManagerApiDataSource.d.ts +15 -5
  177. package/lib/types/src/internal/manager-api/data/AxiosManagerApiDataSource.d.ts.map +1 -1
  178. package/lib/types/src/internal/manager-api/data/ManagerApiDataSource.d.ts +70 -2
  179. package/lib/types/src/internal/manager-api/data/ManagerApiDataSource.d.ts.map +1 -1
  180. package/lib/types/src/internal/manager-api/data/__mocks__/AxiosManagerApiDataSource.d.ts +6 -0
  181. package/lib/types/src/internal/manager-api/data/__mocks__/AxiosManagerApiDataSource.d.ts.map +1 -1
  182. package/lib/types/src/internal/manager-api/model/Const.d.ts +1 -0
  183. package/lib/types/src/internal/manager-api/model/Const.d.ts.map +1 -1
  184. package/lib/types/src/internal/manager-api/model/Errors.d.ts +6 -0
  185. package/lib/types/src/internal/manager-api/model/Errors.d.ts.map +1 -1
  186. package/lib/types/src/internal/manager-api/model/Params.d.ts +86 -0
  187. package/lib/types/src/internal/manager-api/model/Params.d.ts.map +1 -0
  188. package/lib/types/tsconfig.prod.tsbuildinfo +1 -1
  189. package/package.json +5 -2
@@ -1,2 +1,2 @@
1
- "use strict";var k=require("rxjs"),S=require("../../../command/Errors"),A=require("../../../command/model/CommandResult"),o=require("../../../device/DeviceStatus"),s=require("../../../device-action/__test-utils__/makeInternalApi"),d=require("../../../device-action/__test-utils__/setupTestMachine"),p=require("../../../device-action/__test-utils__/testDeviceActionStates"),e=require("../../../device-action/model/DeviceActionState"),n=require("../../../device-action/model/UserInteractionRequired"),l=require("../../../device-action/os/Errors"),a=require("../../../device-session/DeviceSessionState"),c=require("./OpenAppDeviceAction");jest.mock("@api/device-action/os/GetDeviceStatus/GetDeviceStatusDeviceAction");describe("OpenAppDeviceAction",()=>{const O=jest.fn(),V=jest.fn(),v=jest.fn(),u=jest.fn(),h=jest.fn(),N=jest.fn();function m(){return{getDeviceSessionState:u,setDeviceSessionState:h,getAppAndVersion:O,openApp:V,closeApp:v,isDeviceOnboarded:N}}const{getDeviceSessionState:y}=(0,s.makeDeviceActionInternalApiMock)();beforeEach(()=>{jest.resetAllMocks(),N.mockReturnValue(!0)}),describe("without overriding `extractDependencies`",()=>{it("should end if the required application is opened",r=>{y.mockReturnValue({sessionStateType:a.DeviceSessionStateType.ReadyWithoutSecureChannel,deviceStatus:o.DeviceStatus.CONNECTED,currentApp:{name:"Bitcoin",version:"1.0.0"},installedApps:[]}),(0,d.setupGetDeviceStatusMock)([{currentApp:"Bitcoin",currentAppVersion:"0.0.0"}]);const t=new c.OpenAppDeviceAction({input:{appName:"Bitcoin"}}),i=[{status:e.DeviceActionStatus.Pending,intermediateValue:{requiredUserInteraction:n.UserInteractionRequired.None}},{status:e.DeviceActionStatus.Pending,intermediateValue:{requiredUserInteraction:n.UserInteractionRequired.None}},{status:e.DeviceActionStatus.Completed,output:void 0}];(0,p.testDeviceActionStates)(t,i,(0,s.makeDeviceActionInternalApiMock)(),r)})}),describe("success cases",()=>{it("should end in a success if the app is already opened",r=>{u.mockReturnValue({sessionStateType:a.DeviceSessionStateType.ReadyWithoutSecureChannel,deviceStatus:o.DeviceStatus.CONNECTED,currentApp:{name:"Bitcoin",version:"1.0.0"}}),(0,d.setupGetDeviceStatusMock)([{currentApp:"Bitcoin",currentAppVersion:"1.0.0"}]);const t=new c.OpenAppDeviceAction({input:{appName:"Bitcoin",unlockTimeout:void 0}});jest.spyOn(t,"extractDependencies").mockReturnValue(m());const i=[{status:e.DeviceActionStatus.Pending,intermediateValue:{requiredUserInteraction:n.UserInteractionRequired.None}},{status:e.DeviceActionStatus.Pending,intermediateValue:{requiredUserInteraction:n.UserInteractionRequired.None}},{status:e.DeviceActionStatus.Completed,output:void 0}];(0,p.testDeviceActionStates)(t,i,(0,s.makeDeviceActionInternalApiMock)(),r)}),it("should end in a success if the dashboard is open and open app succeeds",r=>{u.mockReturnValue({sessionStateType:a.DeviceSessionStateType.ReadyWithoutSecureChannel,deviceStatus:o.DeviceStatus.CONNECTED,currentApp:{name:"BOLOS",version:"0.0.0"}}),(0,d.setupGetDeviceStatusMock)([{currentApp:"Bitcoin",currentAppVersion:"1.0.0"}]),V.mockResolvedValue((0,A.CommandResultFactory)({data:void 0}));const t=new c.OpenAppDeviceAction({input:{appName:"Bitcoin"}});jest.spyOn(t,"extractDependencies").mockReturnValue(m());const i=[{status:e.DeviceActionStatus.Pending,intermediateValue:{requiredUserInteraction:n.UserInteractionRequired.None}},{status:e.DeviceActionStatus.Pending,intermediateValue:{requiredUserInteraction:n.UserInteractionRequired.None}},{status:e.DeviceActionStatus.Completed,output:void 0}],{observable:D}=(0,p.testDeviceActionStates)(t,i,(0,s.makeDeviceActionInternalApiMock)(),r);(0,k.lastValueFrom)(D).then(()=>{expect(h).toHaveBeenCalledWith({deviceStatus:o.DeviceStatus.CONNECTED,sessionStateType:a.DeviceSessionStateType.ReadyWithoutSecureChannel,currentApp:{name:"Bitcoin",version:"1.0.0"}})})}),it("should end in a success if another app is open, close app succeeds and open app succeeds",r=>{u.mockReturnValue({sessionStateType:a.DeviceSessionStateType.ReadyWithoutSecureChannel,deviceStatus:o.DeviceStatus.CONNECTED,currentApp:{name:"AnotherApp",version:"0.0.0"}}),(0,d.setupGetDeviceStatusMock)([{currentApp:"AnotherApp",currentAppVersion:"0.0.0"},{currentApp:"Bitcoin",currentAppVersion:"1.0.0"}]),v.mockResolvedValue((0,A.CommandResultFactory)({data:void 0})),V.mockResolvedValue((0,A.CommandResultFactory)({data:void 0}));const t=new c.OpenAppDeviceAction({input:{appName:"Bitcoin"}});jest.spyOn(t,"extractDependencies").mockReturnValue(m());const i=[{status:e.DeviceActionStatus.Pending,intermediateValue:{requiredUserInteraction:n.UserInteractionRequired.None}},{status:e.DeviceActionStatus.Pending,intermediateValue:{requiredUserInteraction:n.UserInteractionRequired.None}},{status:e.DeviceActionStatus.Pending,intermediateValue:{requiredUserInteraction:n.UserInteractionRequired.None}},{status:e.DeviceActionStatus.Pending,intermediateValue:{requiredUserInteraction:n.UserInteractionRequired.ConfirmOpenApp}},{status:e.DeviceActionStatus.Pending,intermediateValue:{requiredUserInteraction:n.UserInteractionRequired.None}},{status:e.DeviceActionStatus.Pending,intermediateValue:{requiredUserInteraction:n.UserInteractionRequired.None}},{status:e.DeviceActionStatus.Completed,output:void 0}],{observable:D}=(0,p.testDeviceActionStates)(t,i,(0,s.makeDeviceActionInternalApiMock)(),r);(0,k.lastValueFrom)(D).then(()=>{expect(h).toHaveBeenCalledWith({currentApp:{name:"Bitcoin",version:"1.0.0"},deviceStatus:o.DeviceStatus.CONNECTED,sessionStateType:a.DeviceSessionStateType.ReadyWithoutSecureChannel})})})}),describe("errors cases",()=>{it("should end in an error if the device is not onboarded",r=>{u.mockReturnValue({sessionStateType:a.DeviceSessionStateType.ReadyWithoutSecureChannel,deviceStatus:o.DeviceStatus.CONNECTED,currentApp:{name:"mockedCurrentApp",version:"1.0.0"}}),N.mockReturnValue(!1);const t=new c.OpenAppDeviceAction({input:{appName:"Bitcoin"}});jest.spyOn(t,"extractDependencies").mockReturnValue(m());const i=[{error:new l.DeviceNotOnboardedError,status:e.DeviceActionStatus.Error}];(0,p.testDeviceActionStates)(t,i,(0,s.makeDeviceActionInternalApiMock)(),r)}),it("should end in an error if the device is locked",r=>{u.mockReturnValue({sessionStateType:a.DeviceSessionStateType.ReadyWithoutSecureChannel,deviceStatus:o.DeviceStatus.LOCKED,currentApp:{name:"mockedCurrentApp",version:"1.0.0"}}),(0,d.setupGetDeviceStatusMock)([new l.DeviceLockedError]);const t=new c.OpenAppDeviceAction({input:{appName:"Bitcoin"}});jest.spyOn(t,"extractDependencies").mockReturnValue(m());const i=[{status:e.DeviceActionStatus.Pending,intermediateValue:{requiredUserInteraction:n.UserInteractionRequired.None}},{status:e.DeviceActionStatus.Pending,intermediateValue:{requiredUserInteraction:n.UserInteractionRequired.None}},{status:e.DeviceActionStatus.Error,error:new l.DeviceLockedError}];(0,p.testDeviceActionStates)(t,i,(0,s.makeDeviceActionInternalApiMock)(),r)}),it("should end in an error if getAppAndVersion returns an error",r=>{u.mockReturnValue({sessionStateType:a.DeviceSessionStateType.ReadyWithoutSecureChannel,deviceStatus:o.DeviceStatus.CONNECTED,currentApp:{name:"mockedCurrentApp",version:"1.0.0"}}),(0,d.setupGetDeviceStatusMock)([new S.InvalidStatusWordError("mocked error")]);const t=new c.OpenAppDeviceAction({input:{appName:"Bitcoin"}});jest.spyOn(t,"extractDependencies").mockReturnValue(m());const i=[{status:e.DeviceActionStatus.Pending,intermediateValue:{requiredUserInteraction:n.UserInteractionRequired.None}},{status:e.DeviceActionStatus.Pending,intermediateValue:{requiredUserInteraction:n.UserInteractionRequired.None}},{status:e.DeviceActionStatus.Error,error:new S.InvalidStatusWordError("mocked error")}];(0,p.testDeviceActionStates)(t,i,(0,s.makeDeviceActionInternalApiMock)(),r)}),it("should end in an error if the dashboard is open and open app returns an error",r=>{u.mockReturnValue((0,A.CommandResultFactory)({data:{sessionStateType:a.DeviceSessionStateType.ReadyWithoutSecureChannel,deviceStatus:o.DeviceStatus.CONNECTED,currentApp:{name:"BOLOS",version:"0.0.0"}}})),O.mockResolvedValue((0,A.CommandResultFactory)({data:{name:"BOLOS",version:"0.0.0"}})),(0,d.setupGetDeviceStatusMock)([{currentApp:"BOLOS",currentAppVersion:"0.0.0"}]),V.mockResolvedValue((0,A.CommandResultFactory)({error:new S.InvalidStatusWordError("mocked error")}));const t=new c.OpenAppDeviceAction({input:{appName:"Bitcoin"}});jest.spyOn(t,"extractDependencies").mockReturnValue(m());const i=[{status:e.DeviceActionStatus.Pending,intermediateValue:{requiredUserInteraction:n.UserInteractionRequired.None}},{status:e.DeviceActionStatus.Pending,intermediateValue:{requiredUserInteraction:n.UserInteractionRequired.None}},{status:e.DeviceActionStatus.Pending,intermediateValue:{requiredUserInteraction:n.UserInteractionRequired.ConfirmOpenApp}},{status:e.DeviceActionStatus.Error,error:new S.InvalidStatusWordError("mocked error")}];(0,p.testDeviceActionStates)(t,i,(0,s.makeDeviceActionInternalApiMock)(),r)}),it("should end in an error if another app is open, and close app returns an error",r=>{u.mockReturnValue({sessionStateType:a.DeviceSessionStateType.ReadyWithoutSecureChannel,deviceStatus:o.DeviceStatus.CONNECTED,currentApp:{name:"AnotherApp",version:"0.0.0"}}),(0,d.setupGetDeviceStatusMock)([{currentApp:"AnotherApp",currentAppVersion:"0.0.0"}]),v.mockResolvedValue((0,A.CommandResultFactory)({error:new S.InvalidStatusWordError("mocked error")}));const t=new c.OpenAppDeviceAction({input:{appName:"Bitcoin"}});jest.spyOn(t,"extractDependencies").mockReturnValue(m());const i=[{status:e.DeviceActionStatus.Pending,intermediateValue:{requiredUserInteraction:n.UserInteractionRequired.None}},{status:e.DeviceActionStatus.Pending,intermediateValue:{requiredUserInteraction:n.UserInteractionRequired.None}},{status:e.DeviceActionStatus.Pending,intermediateValue:{requiredUserInteraction:n.UserInteractionRequired.None}},{status:e.DeviceActionStatus.Error,error:new S.InvalidStatusWordError("mocked error")}];(0,p.testDeviceActionStates)(t,i,(0,s.makeDeviceActionInternalApiMock)(),r)}),it("should end in an error if another app is open, close app succeeds but open app returns an error",r=>{u.mockReturnValue({sessionStateType:a.DeviceSessionStateType.ReadyWithoutSecureChannel,deviceStatus:o.DeviceStatus.CONNECTED,currentApp:{name:"AnotherApp",version:"0.0.0"}}),(0,d.setupGetDeviceStatusMock)([{currentApp:"AnotherApp",currentAppVersion:"0.0.0"}]),v.mockResolvedValue((0,A.CommandResultFactory)({data:void 0})),V.mockResolvedValue((0,A.CommandResultFactory)({error:new S.InvalidStatusWordError("mocked error")}));const t=new c.OpenAppDeviceAction({input:{appName:"Bitcoin"}});jest.spyOn(t,"extractDependencies").mockReturnValue(m());const i=[{status:e.DeviceActionStatus.Pending,intermediateValue:{requiredUserInteraction:n.UserInteractionRequired.None}},{status:e.DeviceActionStatus.Pending,intermediateValue:{requiredUserInteraction:n.UserInteractionRequired.None}},{status:e.DeviceActionStatus.Pending,intermediateValue:{requiredUserInteraction:n.UserInteractionRequired.None}},{status:e.DeviceActionStatus.Pending,intermediateValue:{requiredUserInteraction:n.UserInteractionRequired.ConfirmOpenApp}},{status:e.DeviceActionStatus.Error,error:new S.InvalidStatusWordError("mocked error")}];(0,p.testDeviceActionStates)(t,i,(0,s.makeDeviceActionInternalApiMock)(),r)}),it("should end in an error if getAppAndVersion actor throws an error",r=>{u.mockReturnValue({sessionStateType:a.DeviceSessionStateType.ReadyWithoutSecureChannel,deviceStatus:o.DeviceStatus.CONNECTED,currentApp:{name:"mockedCurrentApp",version:"1.0.0"}}),(0,d.setupGetDeviceStatusMock)([new l.UnknownDAError("Unknown error")]);const t=new c.OpenAppDeviceAction({input:{appName:"Bitcoin"}});jest.spyOn(t,"extractDependencies").mockReturnValue(m());const i=[{status:e.DeviceActionStatus.Pending,intermediateValue:{requiredUserInteraction:n.UserInteractionRequired.None}},{status:e.DeviceActionStatus.Pending,intermediateValue:{requiredUserInteraction:n.UserInteractionRequired.None}},{status:e.DeviceActionStatus.Error,error:new l.UnknownDAError("Unknown error")}];(0,p.testDeviceActionStates)(t,i,(0,s.makeDeviceActionInternalApiMock)(),r)}),it("should end in an error if openApp actor throws an error",r=>{u.mockReturnValue((0,A.CommandResultFactory)({data:{sessionStateType:a.DeviceSessionStateType.ReadyWithoutSecureChannel,deviceStatus:o.DeviceStatus.CONNECTED,currentApp:{name:"BOLOS",version:"0.0.0"}}})),(0,d.setupGetDeviceStatusMock)([{currentApp:"BOLOS",currentAppVersion:"0.0.0"}]),V.mockImplementation(()=>{throw new l.UnknownDAError("Unknown error")});const t=new c.OpenAppDeviceAction({input:{appName:"Bitcoin"}});jest.spyOn(t,"extractDependencies").mockReturnValue(m());const i=[{status:e.DeviceActionStatus.Pending,intermediateValue:{requiredUserInteraction:n.UserInteractionRequired.None}},{status:e.DeviceActionStatus.Pending,intermediateValue:{requiredUserInteraction:n.UserInteractionRequired.None}},{status:e.DeviceActionStatus.Pending,intermediateValue:{requiredUserInteraction:n.UserInteractionRequired.ConfirmOpenApp}},{status:e.DeviceActionStatus.Error,error:new l.UnknownDAError("Unknown error")}];(0,p.testDeviceActionStates)(t,i,(0,s.makeDeviceActionInternalApiMock)(),r)}),it("should end in an error if closeApp actor throws an error",r=>{u.mockReturnValue((0,A.CommandResultFactory)({data:{sessionStateType:a.DeviceSessionStateType.ReadyWithoutSecureChannel,deviceStatus:o.DeviceStatus.CONNECTED,currentApp:{name:"BOLOS",version:"0.0.0"}}})),(0,d.setupGetDeviceStatusMock)([{currentApp:"anApp",currentAppVersion:"0.0.0"}]),v.mockImplementation(()=>{throw new l.UnknownDAError("Unknown error")});const t=new c.OpenAppDeviceAction({input:{appName:"Bitcoin"}});jest.spyOn(t,"extractDependencies").mockReturnValue(m());const i=[{status:e.DeviceActionStatus.Pending,intermediateValue:{requiredUserInteraction:n.UserInteractionRequired.None}},{status:e.DeviceActionStatus.Pending,intermediateValue:{requiredUserInteraction:n.UserInteractionRequired.None}},{status:e.DeviceActionStatus.Pending,intermediateValue:{requiredUserInteraction:n.UserInteractionRequired.None}},{status:e.DeviceActionStatus.Error,error:new l.UnknownDAError("Unknown error")}];(0,p.testDeviceActionStates)(t,i,(0,s.makeDeviceActionInternalApiMock)(),r)})}),it("should emit a stopped state if the action is cancelled",r=>{u.mockReturnValue({sessionStateType:a.DeviceSessionStateType.ReadyWithoutSecureChannel,deviceStatus:o.DeviceStatus.CONNECTED,currentApp:{name:"AnotherApp",version:"0.0.0"}}),(0,d.setupGetDeviceStatusMock)([{currentApp:"AnotherApp",currentAppVersion:"0.0.0"}]);const t=new c.OpenAppDeviceAction({input:{appName:"Bitcoin"}});jest.spyOn(t,"extractDependencies").mockReturnValue(m());const i=[{status:e.DeviceActionStatus.Pending,intermediateValue:{requiredUserInteraction:n.UserInteractionRequired.None}},{status:e.DeviceActionStatus.Pending,intermediateValue:{requiredUserInteraction:n.UserInteractionRequired.None}},{status:e.DeviceActionStatus.Stopped}],{cancel:D}=(0,p.testDeviceActionStates)(t,i,(0,s.makeDeviceActionInternalApiMock)(),r);D()})});
1
+ "use strict";var k=require("rxjs"),S=require("../../../command/Errors"),A=require("../../../command/model/CommandResult"),y=require("../../../device/DeviceModel"),o=require("../../../device/DeviceStatus"),s=require("../../../device-action/__test-utils__/makeInternalApi"),d=require("../../../device-action/__test-utils__/setupTestMachine"),p=require("../../../device-action/__test-utils__/testDeviceActionStates"),e=require("../../../device-action/model/DeviceActionState"),n=require("../../../device-action/model/UserInteractionRequired"),l=require("../../../device-action/os/Errors"),a=require("../../../device-session/DeviceSessionState"),c=require("./OpenAppDeviceAction");jest.mock("@api/device-action/os/GetDeviceStatus/GetDeviceStatusDeviceAction");describe("OpenAppDeviceAction",()=>{const O=jest.fn(),V=jest.fn(),v=jest.fn(),u=jest.fn(),N=jest.fn(),h=jest.fn();function m(){return{getDeviceSessionState:u,setDeviceSessionState:N,getAppAndVersion:O,openApp:V,closeApp:v,isDeviceOnboarded:h}}const{getDeviceSessionState:C}=(0,s.makeDeviceActionInternalApiMock)();beforeEach(()=>{jest.resetAllMocks(),h.mockReturnValue(!0)}),describe("without overriding `extractDependencies`",()=>{it("should end if the required application is opened",r=>{C.mockReturnValue({sessionStateType:a.DeviceSessionStateType.ReadyWithoutSecureChannel,deviceStatus:o.DeviceStatus.CONNECTED,currentApp:{name:"Bitcoin",version:"1.0.0"},installedApps:[],deviceModelId:y.DeviceModelId.NANO_X}),(0,d.setupGetDeviceStatusMock)([{currentApp:"Bitcoin",currentAppVersion:"0.0.0"}]);const t=new c.OpenAppDeviceAction({input:{appName:"Bitcoin"}}),i=[{status:e.DeviceActionStatus.Pending,intermediateValue:{requiredUserInteraction:n.UserInteractionRequired.None}},{status:e.DeviceActionStatus.Pending,intermediateValue:{requiredUserInteraction:n.UserInteractionRequired.None}},{status:e.DeviceActionStatus.Completed,output:void 0}];(0,p.testDeviceActionStates)(t,i,(0,s.makeDeviceActionInternalApiMock)(),r)})}),describe("success cases",()=>{it("should end in a success if the app is already opened",r=>{u.mockReturnValue({sessionStateType:a.DeviceSessionStateType.ReadyWithoutSecureChannel,deviceStatus:o.DeviceStatus.CONNECTED,currentApp:{name:"Bitcoin",version:"1.0.0"}}),(0,d.setupGetDeviceStatusMock)([{currentApp:"Bitcoin",currentAppVersion:"1.0.0"}]);const t=new c.OpenAppDeviceAction({input:{appName:"Bitcoin",unlockTimeout:void 0}});jest.spyOn(t,"extractDependencies").mockReturnValue(m());const i=[{status:e.DeviceActionStatus.Pending,intermediateValue:{requiredUserInteraction:n.UserInteractionRequired.None}},{status:e.DeviceActionStatus.Pending,intermediateValue:{requiredUserInteraction:n.UserInteractionRequired.None}},{status:e.DeviceActionStatus.Completed,output:void 0}];(0,p.testDeviceActionStates)(t,i,(0,s.makeDeviceActionInternalApiMock)(),r)}),it("should end in a success if a compatible app is already opened",r=>{u.mockReturnValue({sessionStateType:a.DeviceSessionStateType.ReadyWithoutSecureChannel,deviceStatus:o.DeviceStatus.CONNECTED,currentApp:{name:"Bitcoin Testnet",version:"1.0.0"}}),(0,d.setupGetDeviceStatusMock)([{currentApp:"Bitcoin Testnet",currentAppVersion:"1.0.0"}]);const t=new c.OpenAppDeviceAction({input:{appName:"Bitcoin",unlockTimeout:void 0,compatibleAppNames:["Bitcoin Testnet"]}});jest.spyOn(t,"extractDependencies").mockReturnValue(m());const i=[{status:e.DeviceActionStatus.Pending,intermediateValue:{requiredUserInteraction:n.UserInteractionRequired.None}},{status:e.DeviceActionStatus.Pending,intermediateValue:{requiredUserInteraction:n.UserInteractionRequired.None}},{status:e.DeviceActionStatus.Completed,output:void 0}];(0,p.testDeviceActionStates)(t,i,(0,s.makeDeviceActionInternalApiMock)(),r)}),it("should end in a success if the dashboard is open and open app succeeds",r=>{u.mockReturnValue({sessionStateType:a.DeviceSessionStateType.ReadyWithoutSecureChannel,deviceStatus:o.DeviceStatus.CONNECTED,currentApp:{name:"BOLOS",version:"0.0.0"}}),(0,d.setupGetDeviceStatusMock)([{currentApp:"Bitcoin",currentAppVersion:"1.0.0"}]),V.mockResolvedValue((0,A.CommandResultFactory)({data:void 0}));const t=new c.OpenAppDeviceAction({input:{appName:"Bitcoin"}});jest.spyOn(t,"extractDependencies").mockReturnValue(m());const i=[{status:e.DeviceActionStatus.Pending,intermediateValue:{requiredUserInteraction:n.UserInteractionRequired.None}},{status:e.DeviceActionStatus.Pending,intermediateValue:{requiredUserInteraction:n.UserInteractionRequired.None}},{status:e.DeviceActionStatus.Completed,output:void 0}],{observable:D}=(0,p.testDeviceActionStates)(t,i,(0,s.makeDeviceActionInternalApiMock)(),r);(0,k.lastValueFrom)(D).then(()=>{expect(N).toHaveBeenCalledWith({deviceStatus:o.DeviceStatus.CONNECTED,sessionStateType:a.DeviceSessionStateType.ReadyWithoutSecureChannel,currentApp:{name:"Bitcoin",version:"1.0.0"}})})}),it("should end in a success if another app is open, close app succeeds and open app succeeds",r=>{u.mockReturnValue({sessionStateType:a.DeviceSessionStateType.ReadyWithoutSecureChannel,deviceStatus:o.DeviceStatus.CONNECTED,currentApp:{name:"AnotherApp",version:"0.0.0"}}),(0,d.setupGetDeviceStatusMock)([{currentApp:"AnotherApp",currentAppVersion:"0.0.0"},{currentApp:"Bitcoin",currentAppVersion:"1.0.0"}]),v.mockResolvedValue((0,A.CommandResultFactory)({data:void 0})),V.mockResolvedValue((0,A.CommandResultFactory)({data:void 0}));const t=new c.OpenAppDeviceAction({input:{appName:"Bitcoin"}});jest.spyOn(t,"extractDependencies").mockReturnValue(m());const i=[{status:e.DeviceActionStatus.Pending,intermediateValue:{requiredUserInteraction:n.UserInteractionRequired.None}},{status:e.DeviceActionStatus.Pending,intermediateValue:{requiredUserInteraction:n.UserInteractionRequired.None}},{status:e.DeviceActionStatus.Pending,intermediateValue:{requiredUserInteraction:n.UserInteractionRequired.None}},{status:e.DeviceActionStatus.Pending,intermediateValue:{requiredUserInteraction:n.UserInteractionRequired.ConfirmOpenApp}},{status:e.DeviceActionStatus.Pending,intermediateValue:{requiredUserInteraction:n.UserInteractionRequired.None}},{status:e.DeviceActionStatus.Pending,intermediateValue:{requiredUserInteraction:n.UserInteractionRequired.None}},{status:e.DeviceActionStatus.Completed,output:void 0}],{observable:D}=(0,p.testDeviceActionStates)(t,i,(0,s.makeDeviceActionInternalApiMock)(),r);(0,k.lastValueFrom)(D).then(()=>{expect(N).toHaveBeenCalledWith({currentApp:{name:"Bitcoin",version:"1.0.0"},deviceStatus:o.DeviceStatus.CONNECTED,sessionStateType:a.DeviceSessionStateType.ReadyWithoutSecureChannel})})})}),describe("errors cases",()=>{it("should end in an error if the device is not onboarded",r=>{u.mockReturnValue({sessionStateType:a.DeviceSessionStateType.ReadyWithoutSecureChannel,deviceStatus:o.DeviceStatus.CONNECTED,currentApp:{name:"mockedCurrentApp",version:"1.0.0"}}),h.mockReturnValue(!1);const t=new c.OpenAppDeviceAction({input:{appName:"Bitcoin"}});jest.spyOn(t,"extractDependencies").mockReturnValue(m());const i=[{error:new l.DeviceNotOnboardedError,status:e.DeviceActionStatus.Error}];(0,p.testDeviceActionStates)(t,i,(0,s.makeDeviceActionInternalApiMock)(),r)}),it("should end in an error if the device is locked",r=>{u.mockReturnValue({sessionStateType:a.DeviceSessionStateType.ReadyWithoutSecureChannel,deviceStatus:o.DeviceStatus.LOCKED,currentApp:{name:"mockedCurrentApp",version:"1.0.0"}}),(0,d.setupGetDeviceStatusMock)([new l.DeviceLockedError]);const t=new c.OpenAppDeviceAction({input:{appName:"Bitcoin"}});jest.spyOn(t,"extractDependencies").mockReturnValue(m());const i=[{status:e.DeviceActionStatus.Pending,intermediateValue:{requiredUserInteraction:n.UserInteractionRequired.None}},{status:e.DeviceActionStatus.Pending,intermediateValue:{requiredUserInteraction:n.UserInteractionRequired.None}},{status:e.DeviceActionStatus.Error,error:new l.DeviceLockedError}];(0,p.testDeviceActionStates)(t,i,(0,s.makeDeviceActionInternalApiMock)(),r)}),it("should end in an error if getAppAndVersion returns an error",r=>{u.mockReturnValue({sessionStateType:a.DeviceSessionStateType.ReadyWithoutSecureChannel,deviceStatus:o.DeviceStatus.CONNECTED,currentApp:{name:"mockedCurrentApp",version:"1.0.0"}}),(0,d.setupGetDeviceStatusMock)([new S.InvalidStatusWordError("mocked error")]);const t=new c.OpenAppDeviceAction({input:{appName:"Bitcoin"}});jest.spyOn(t,"extractDependencies").mockReturnValue(m());const i=[{status:e.DeviceActionStatus.Pending,intermediateValue:{requiredUserInteraction:n.UserInteractionRequired.None}},{status:e.DeviceActionStatus.Pending,intermediateValue:{requiredUserInteraction:n.UserInteractionRequired.None}},{status:e.DeviceActionStatus.Error,error:new S.InvalidStatusWordError("mocked error")}];(0,p.testDeviceActionStates)(t,i,(0,s.makeDeviceActionInternalApiMock)(),r)}),it("should end in an error if the dashboard is open and open app returns an error",r=>{u.mockReturnValue((0,A.CommandResultFactory)({data:{sessionStateType:a.DeviceSessionStateType.ReadyWithoutSecureChannel,deviceStatus:o.DeviceStatus.CONNECTED,currentApp:{name:"BOLOS",version:"0.0.0"}}})),O.mockResolvedValue((0,A.CommandResultFactory)({data:{name:"BOLOS",version:"0.0.0"}})),(0,d.setupGetDeviceStatusMock)([{currentApp:"BOLOS",currentAppVersion:"0.0.0"}]),V.mockResolvedValue((0,A.CommandResultFactory)({error:new S.InvalidStatusWordError("mocked error")}));const t=new c.OpenAppDeviceAction({input:{appName:"Bitcoin"}});jest.spyOn(t,"extractDependencies").mockReturnValue(m());const i=[{status:e.DeviceActionStatus.Pending,intermediateValue:{requiredUserInteraction:n.UserInteractionRequired.None}},{status:e.DeviceActionStatus.Pending,intermediateValue:{requiredUserInteraction:n.UserInteractionRequired.None}},{status:e.DeviceActionStatus.Pending,intermediateValue:{requiredUserInteraction:n.UserInteractionRequired.ConfirmOpenApp}},{status:e.DeviceActionStatus.Error,error:new S.InvalidStatusWordError("mocked error")}];(0,p.testDeviceActionStates)(t,i,(0,s.makeDeviceActionInternalApiMock)(),r)}),it("should end in an error if another app is open, and close app returns an error",r=>{u.mockReturnValue({sessionStateType:a.DeviceSessionStateType.ReadyWithoutSecureChannel,deviceStatus:o.DeviceStatus.CONNECTED,currentApp:{name:"AnotherApp",version:"0.0.0"}}),(0,d.setupGetDeviceStatusMock)([{currentApp:"AnotherApp",currentAppVersion:"0.0.0"}]),v.mockResolvedValue((0,A.CommandResultFactory)({error:new S.InvalidStatusWordError("mocked error")}));const t=new c.OpenAppDeviceAction({input:{appName:"Bitcoin"}});jest.spyOn(t,"extractDependencies").mockReturnValue(m());const i=[{status:e.DeviceActionStatus.Pending,intermediateValue:{requiredUserInteraction:n.UserInteractionRequired.None}},{status:e.DeviceActionStatus.Pending,intermediateValue:{requiredUserInteraction:n.UserInteractionRequired.None}},{status:e.DeviceActionStatus.Pending,intermediateValue:{requiredUserInteraction:n.UserInteractionRequired.None}},{status:e.DeviceActionStatus.Error,error:new S.InvalidStatusWordError("mocked error")}];(0,p.testDeviceActionStates)(t,i,(0,s.makeDeviceActionInternalApiMock)(),r)}),it("should end in an error if another app is open, close app succeeds but open app returns an error",r=>{u.mockReturnValue({sessionStateType:a.DeviceSessionStateType.ReadyWithoutSecureChannel,deviceStatus:o.DeviceStatus.CONNECTED,currentApp:{name:"AnotherApp",version:"0.0.0"}}),(0,d.setupGetDeviceStatusMock)([{currentApp:"AnotherApp",currentAppVersion:"0.0.0"}]),v.mockResolvedValue((0,A.CommandResultFactory)({data:void 0})),V.mockResolvedValue((0,A.CommandResultFactory)({error:new S.InvalidStatusWordError("mocked error")}));const t=new c.OpenAppDeviceAction({input:{appName:"Bitcoin"}});jest.spyOn(t,"extractDependencies").mockReturnValue(m());const i=[{status:e.DeviceActionStatus.Pending,intermediateValue:{requiredUserInteraction:n.UserInteractionRequired.None}},{status:e.DeviceActionStatus.Pending,intermediateValue:{requiredUserInteraction:n.UserInteractionRequired.None}},{status:e.DeviceActionStatus.Pending,intermediateValue:{requiredUserInteraction:n.UserInteractionRequired.None}},{status:e.DeviceActionStatus.Pending,intermediateValue:{requiredUserInteraction:n.UserInteractionRequired.ConfirmOpenApp}},{status:e.DeviceActionStatus.Error,error:new S.InvalidStatusWordError("mocked error")}];(0,p.testDeviceActionStates)(t,i,(0,s.makeDeviceActionInternalApiMock)(),r)}),it("should end in an error if getAppAndVersion actor throws an error",r=>{u.mockReturnValue({sessionStateType:a.DeviceSessionStateType.ReadyWithoutSecureChannel,deviceStatus:o.DeviceStatus.CONNECTED,currentApp:{name:"mockedCurrentApp",version:"1.0.0"}}),(0,d.setupGetDeviceStatusMock)([new l.UnknownDAError("Unknown error")]);const t=new c.OpenAppDeviceAction({input:{appName:"Bitcoin"}});jest.spyOn(t,"extractDependencies").mockReturnValue(m());const i=[{status:e.DeviceActionStatus.Pending,intermediateValue:{requiredUserInteraction:n.UserInteractionRequired.None}},{status:e.DeviceActionStatus.Pending,intermediateValue:{requiredUserInteraction:n.UserInteractionRequired.None}},{status:e.DeviceActionStatus.Error,error:new l.UnknownDAError("Unknown error")}];(0,p.testDeviceActionStates)(t,i,(0,s.makeDeviceActionInternalApiMock)(),r)}),it("should end in an error if openApp actor throws an error",r=>{u.mockReturnValue((0,A.CommandResultFactory)({data:{sessionStateType:a.DeviceSessionStateType.ReadyWithoutSecureChannel,deviceStatus:o.DeviceStatus.CONNECTED,currentApp:{name:"BOLOS",version:"0.0.0"}}})),(0,d.setupGetDeviceStatusMock)([{currentApp:"BOLOS",currentAppVersion:"0.0.0"}]),V.mockImplementation(()=>{throw new l.UnknownDAError("Unknown error")});const t=new c.OpenAppDeviceAction({input:{appName:"Bitcoin"}});jest.spyOn(t,"extractDependencies").mockReturnValue(m());const i=[{status:e.DeviceActionStatus.Pending,intermediateValue:{requiredUserInteraction:n.UserInteractionRequired.None}},{status:e.DeviceActionStatus.Pending,intermediateValue:{requiredUserInteraction:n.UserInteractionRequired.None}},{status:e.DeviceActionStatus.Pending,intermediateValue:{requiredUserInteraction:n.UserInteractionRequired.ConfirmOpenApp}},{status:e.DeviceActionStatus.Error,error:new l.UnknownDAError("Unknown error")}];(0,p.testDeviceActionStates)(t,i,(0,s.makeDeviceActionInternalApiMock)(),r)}),it("should end in an error if closeApp actor throws an error",r=>{u.mockReturnValue((0,A.CommandResultFactory)({data:{sessionStateType:a.DeviceSessionStateType.ReadyWithoutSecureChannel,deviceStatus:o.DeviceStatus.CONNECTED,currentApp:{name:"BOLOS",version:"0.0.0"}}})),(0,d.setupGetDeviceStatusMock)([{currentApp:"anApp",currentAppVersion:"0.0.0"}]),v.mockImplementation(()=>{throw new l.UnknownDAError("Unknown error")});const t=new c.OpenAppDeviceAction({input:{appName:"Bitcoin"}});jest.spyOn(t,"extractDependencies").mockReturnValue(m());const i=[{status:e.DeviceActionStatus.Pending,intermediateValue:{requiredUserInteraction:n.UserInteractionRequired.None}},{status:e.DeviceActionStatus.Pending,intermediateValue:{requiredUserInteraction:n.UserInteractionRequired.None}},{status:e.DeviceActionStatus.Pending,intermediateValue:{requiredUserInteraction:n.UserInteractionRequired.None}},{status:e.DeviceActionStatus.Error,error:new l.UnknownDAError("Unknown error")}];(0,p.testDeviceActionStates)(t,i,(0,s.makeDeviceActionInternalApiMock)(),r)})}),it("should emit a stopped state if the action is cancelled",r=>{u.mockReturnValue({sessionStateType:a.DeviceSessionStateType.ReadyWithoutSecureChannel,deviceStatus:o.DeviceStatus.CONNECTED,currentApp:{name:"AnotherApp",version:"0.0.0"}}),(0,d.setupGetDeviceStatusMock)([{currentApp:"AnotherApp",currentAppVersion:"0.0.0"}]);const t=new c.OpenAppDeviceAction({input:{appName:"Bitcoin"}});jest.spyOn(t,"extractDependencies").mockReturnValue(m());const i=[{status:e.DeviceActionStatus.Pending,intermediateValue:{requiredUserInteraction:n.UserInteractionRequired.None}},{status:e.DeviceActionStatus.Pending,intermediateValue:{requiredUserInteraction:n.UserInteractionRequired.None}},{status:e.DeviceActionStatus.Stopped}],{cancel:D}=(0,p.testDeviceActionStates)(t,i,(0,s.makeDeviceActionInternalApiMock)(),r);D()})});
2
2
  //# sourceMappingURL=OpenAppDeviceAction.test.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../../../../src/api/device-action/os/OpenAppDeviceAction/OpenAppDeviceAction.test.ts"],
4
- "sourcesContent": ["import { lastValueFrom } from \"rxjs\";\n\nimport { InvalidStatusWordError } from \"@api/command/Errors\";\nimport { CommandResultFactory } from \"@api/command/model/CommandResult\";\nimport { DeviceStatus } from \"@api/device/DeviceStatus\";\nimport { makeDeviceActionInternalApiMock } from \"@api/device-action/__test-utils__/makeInternalApi\";\nimport { setupGetDeviceStatusMock } from \"@api/device-action/__test-utils__/setupTestMachine\";\nimport { testDeviceActionStates } from \"@api/device-action/__test-utils__/testDeviceActionStates\";\nimport { DeviceActionStatus } from \"@api/device-action/model/DeviceActionState\";\nimport { UserInteractionRequired } from \"@api/device-action/model/UserInteractionRequired\";\nimport {\n DeviceLockedError,\n DeviceNotOnboardedError,\n UnknownDAError,\n} from \"@api/device-action/os/Errors\";\nimport { DeviceSessionStateType } from \"@api/device-session/DeviceSessionState\";\n\nimport { OpenAppDeviceAction } from \"./OpenAppDeviceAction\";\nimport type { OpenAppDAState } from \"./types\";\n\njest.mock(\"@api/device-action/os/GetDeviceStatus/GetDeviceStatusDeviceAction\");\n\ndescribe(\"OpenAppDeviceAction\", () => {\n const getAppAndVersionMock = jest.fn();\n const openAppMock = jest.fn();\n const closeAppMock = jest.fn();\n const getDeviceSessionStateMock = jest.fn();\n const setDeviceSessionStateMock = jest.fn();\n const isDeviceOnboardedMock = jest.fn();\n\n function extractDependenciesMock() {\n return {\n getDeviceSessionState: getDeviceSessionStateMock,\n setDeviceSessionState: setDeviceSessionStateMock,\n getAppAndVersion: getAppAndVersionMock,\n openApp: openAppMock,\n closeApp: closeAppMock,\n isDeviceOnboarded: isDeviceOnboardedMock,\n };\n }\n\n const { getDeviceSessionState: apiGetDeviceSessionStateMock } =\n makeDeviceActionInternalApiMock();\n\n beforeEach(() => {\n jest.resetAllMocks();\n isDeviceOnboardedMock.mockReturnValue(true);\n });\n\n describe(\"without overriding `extractDependencies`\", () => {\n it(\"should end if the required application is opened\", (done) => {\n apiGetDeviceSessionStateMock.mockReturnValue({\n sessionStateType: DeviceSessionStateType.ReadyWithoutSecureChannel,\n deviceStatus: DeviceStatus.CONNECTED,\n currentApp: { name: \"Bitcoin\", version: \"1.0.0\" },\n installedApps: [],\n });\n setupGetDeviceStatusMock([\n {\n currentApp: \"Bitcoin\",\n currentAppVersion: \"0.0.0\",\n },\n ]);\n\n const openAppDeviceAction = new OpenAppDeviceAction({\n input: { appName: \"Bitcoin\" },\n });\n\n const expectedStates: Array<OpenAppDAState> = [\n {\n status: DeviceActionStatus.Pending, // get onboarding status\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.None,\n },\n },\n {\n status: DeviceActionStatus.Pending, // get device status\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.None,\n },\n },\n {\n status: DeviceActionStatus.Completed,\n output: undefined,\n },\n ];\n\n testDeviceActionStates(\n openAppDeviceAction,\n expectedStates,\n makeDeviceActionInternalApiMock(),\n done,\n );\n });\n });\n\n describe(\"success cases\", () => {\n it(\"should end in a success if the app is already opened\", (done) => {\n getDeviceSessionStateMock.mockReturnValue({\n sessionStateType: DeviceSessionStateType.ReadyWithoutSecureChannel,\n deviceStatus: DeviceStatus.CONNECTED,\n currentApp: { name: \"Bitcoin\", version: \"1.0.0\" },\n });\n\n setupGetDeviceStatusMock([\n {\n currentApp: \"Bitcoin\",\n currentAppVersion: \"1.0.0\",\n },\n ]);\n const openAppDeviceAction = new OpenAppDeviceAction({\n input: { appName: \"Bitcoin\", unlockTimeout: undefined },\n });\n jest\n .spyOn(openAppDeviceAction, \"extractDependencies\")\n .mockReturnValue(extractDependenciesMock());\n\n const expectedStates: Array<OpenAppDAState> = [\n {\n status: DeviceActionStatus.Pending, // get onboarding status\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.None,\n },\n },\n {\n status: DeviceActionStatus.Pending, // get app and version\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.None,\n },\n },\n {\n status: DeviceActionStatus.Completed,\n output: undefined,\n },\n ];\n\n testDeviceActionStates(\n openAppDeviceAction,\n expectedStates,\n makeDeviceActionInternalApiMock(),\n done,\n );\n });\n\n it(\"should end in a success if the dashboard is open and open app succeeds\", (done) => {\n getDeviceSessionStateMock.mockReturnValue({\n sessionStateType: DeviceSessionStateType.ReadyWithoutSecureChannel,\n deviceStatus: DeviceStatus.CONNECTED,\n currentApp: { name: \"BOLOS\", version: \"0.0.0\" },\n });\n\n setupGetDeviceStatusMock([\n {\n currentApp: \"Bitcoin\",\n currentAppVersion: \"1.0.0\",\n },\n ]);\n\n openAppMock.mockResolvedValue(CommandResultFactory({ data: undefined }));\n\n const openAppDeviceAction = new OpenAppDeviceAction({\n input: { appName: \"Bitcoin\" },\n });\n jest\n .spyOn(openAppDeviceAction, \"extractDependencies\")\n .mockReturnValue(extractDependenciesMock());\n\n const expectedStates: Array<OpenAppDAState> = [\n {\n status: DeviceActionStatus.Pending, // get app and version\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.None,\n },\n },\n {\n status: DeviceActionStatus.Pending, // get app and version\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.None,\n },\n },\n {\n status: DeviceActionStatus.Completed,\n output: undefined,\n },\n ];\n\n const { observable } = testDeviceActionStates(\n openAppDeviceAction,\n expectedStates,\n makeDeviceActionInternalApiMock(),\n done,\n );\n\n lastValueFrom(observable).then(() => {\n expect(setDeviceSessionStateMock).toHaveBeenCalledWith({\n deviceStatus: DeviceStatus.CONNECTED,\n sessionStateType: DeviceSessionStateType.ReadyWithoutSecureChannel,\n currentApp: { name: \"Bitcoin\", version: \"1.0.0\" },\n });\n });\n });\n\n it(\"should end in a success if another app is open, close app succeeds and open app succeeds\", (done) => {\n getDeviceSessionStateMock.mockReturnValue({\n sessionStateType: DeviceSessionStateType.ReadyWithoutSecureChannel,\n deviceStatus: DeviceStatus.CONNECTED,\n currentApp: { name: \"AnotherApp\", version: \"0.0.0\" },\n });\n setupGetDeviceStatusMock([\n {\n currentApp: \"AnotherApp\",\n currentAppVersion: \"0.0.0\",\n },\n { currentApp: \"Bitcoin\", currentAppVersion: \"1.0.0\" },\n ]);\n closeAppMock.mockResolvedValue(CommandResultFactory({ data: undefined }));\n openAppMock.mockResolvedValue(CommandResultFactory({ data: undefined }));\n\n const openAppDeviceAction = new OpenAppDeviceAction({\n input: { appName: \"Bitcoin\" },\n });\n jest\n .spyOn(openAppDeviceAction, \"extractDependencies\")\n .mockReturnValue(extractDependenciesMock());\n\n const expectedStates: Array<OpenAppDAState> = [\n {\n status: DeviceActionStatus.Pending, // get app and version\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.None,\n },\n },\n {\n status: DeviceActionStatus.Pending, // close app\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.None,\n },\n },\n {\n status: DeviceActionStatus.Pending, // get device status\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.None,\n },\n },\n {\n status: DeviceActionStatus.Pending, // open app\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.ConfirmOpenApp,\n },\n },\n {\n status: DeviceActionStatus.Pending, // get app and version\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.None,\n },\n },\n {\n status: DeviceActionStatus.Pending, // get app and version\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.None,\n },\n },\n {\n status: DeviceActionStatus.Completed,\n output: undefined,\n },\n ];\n\n const { observable } = testDeviceActionStates(\n openAppDeviceAction,\n expectedStates,\n makeDeviceActionInternalApiMock(),\n done,\n );\n\n lastValueFrom(observable).then(() => {\n expect(setDeviceSessionStateMock).toHaveBeenCalledWith({\n currentApp: { name: \"Bitcoin\", version: \"1.0.0\" },\n deviceStatus: DeviceStatus.CONNECTED,\n sessionStateType: DeviceSessionStateType.ReadyWithoutSecureChannel,\n });\n });\n });\n });\n\n describe(\"errors cases\", () => {\n it(\"should end in an error if the device is not onboarded\", (done) => {\n getDeviceSessionStateMock.mockReturnValue({\n sessionStateType: DeviceSessionStateType.ReadyWithoutSecureChannel,\n deviceStatus: DeviceStatus.CONNECTED,\n currentApp: { name: \"mockedCurrentApp\", version: \"1.0.0\" },\n });\n isDeviceOnboardedMock.mockReturnValue(false);\n\n const openAppDeviceAction = new OpenAppDeviceAction({\n input: { appName: \"Bitcoin\" },\n });\n\n jest\n .spyOn(openAppDeviceAction, \"extractDependencies\")\n .mockReturnValue(extractDependenciesMock());\n\n const expectedStates: Array<OpenAppDAState> = [\n {\n error: new DeviceNotOnboardedError(),\n status: DeviceActionStatus.Error,\n },\n ];\n\n testDeviceActionStates(\n openAppDeviceAction,\n expectedStates,\n makeDeviceActionInternalApiMock(),\n done,\n );\n });\n\n it(\"should end in an error if the device is locked\", (done) => {\n getDeviceSessionStateMock.mockReturnValue({\n sessionStateType: DeviceSessionStateType.ReadyWithoutSecureChannel,\n deviceStatus: DeviceStatus.LOCKED,\n currentApp: { name: \"mockedCurrentApp\", version: \"1.0.0\" },\n });\n\n setupGetDeviceStatusMock([new DeviceLockedError()]);\n\n const openAppDeviceAction = new OpenAppDeviceAction({\n input: { appName: \"Bitcoin\" },\n });\n\n jest\n .spyOn(openAppDeviceAction, \"extractDependencies\")\n .mockReturnValue(extractDependenciesMock());\n\n const expectedStates: Array<OpenAppDAState> = [\n {\n status: DeviceActionStatus.Pending,\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.None,\n },\n },\n {\n status: DeviceActionStatus.Pending,\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.None,\n },\n },\n {\n status: DeviceActionStatus.Error,\n error: new DeviceLockedError(),\n },\n ];\n\n testDeviceActionStates(\n openAppDeviceAction,\n expectedStates,\n makeDeviceActionInternalApiMock(),\n done,\n );\n });\n\n it(\"should end in an error if getAppAndVersion returns an error\", (done) => {\n getDeviceSessionStateMock.mockReturnValue({\n sessionStateType: DeviceSessionStateType.ReadyWithoutSecureChannel,\n deviceStatus: DeviceStatus.CONNECTED,\n currentApp: { name: \"mockedCurrentApp\", version: \"1.0.0\" },\n });\n\n setupGetDeviceStatusMock([new InvalidStatusWordError(\"mocked error\")]);\n\n const openAppDeviceAction = new OpenAppDeviceAction({\n input: { appName: \"Bitcoin\" },\n });\n\n jest\n .spyOn(openAppDeviceAction, \"extractDependencies\")\n .mockReturnValue(extractDependenciesMock());\n\n const expectedStates: Array<OpenAppDAState> = [\n {\n status: DeviceActionStatus.Pending, // get app and version\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.None,\n },\n },\n {\n status: DeviceActionStatus.Pending, // get device status\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.None,\n },\n },\n {\n status: DeviceActionStatus.Error,\n error: new InvalidStatusWordError(\"mocked error\"),\n },\n ];\n\n testDeviceActionStates(\n openAppDeviceAction,\n expectedStates,\n makeDeviceActionInternalApiMock(),\n done,\n );\n });\n\n it(\"should end in an error if the dashboard is open and open app returns an error\", (done) => {\n getDeviceSessionStateMock.mockReturnValue(\n CommandResultFactory({\n data: {\n sessionStateType: DeviceSessionStateType.ReadyWithoutSecureChannel,\n deviceStatus: DeviceStatus.CONNECTED,\n currentApp: { name: \"BOLOS\", version: \"0.0.0\" },\n },\n }),\n );\n getAppAndVersionMock.mockResolvedValue(\n CommandResultFactory({\n data: {\n name: \"BOLOS\",\n version: \"0.0.0\",\n },\n }),\n );\n setupGetDeviceStatusMock([\n {\n currentApp: \"BOLOS\",\n currentAppVersion: \"0.0.0\",\n },\n ]);\n openAppMock.mockResolvedValue(\n CommandResultFactory({\n error: new InvalidStatusWordError(\"mocked error\"),\n }),\n );\n\n const openAppDeviceAction = new OpenAppDeviceAction({\n input: { appName: \"Bitcoin\" },\n });\n jest\n .spyOn(openAppDeviceAction, \"extractDependencies\")\n .mockReturnValue(extractDependenciesMock());\n\n const expectedStates: Array<OpenAppDAState> = [\n {\n status: DeviceActionStatus.Pending, // get onboarded status\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.None,\n },\n },\n {\n status: DeviceActionStatus.Pending, // get device status\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.None,\n },\n },\n {\n status: DeviceActionStatus.Pending, // open app\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.ConfirmOpenApp,\n },\n },\n {\n status: DeviceActionStatus.Error,\n error: new InvalidStatusWordError(\"mocked error\"),\n },\n ];\n\n testDeviceActionStates(\n openAppDeviceAction,\n expectedStates,\n makeDeviceActionInternalApiMock(),\n done,\n );\n });\n\n it(\"should end in an error if another app is open, and close app returns an error\", (done) => {\n getDeviceSessionStateMock.mockReturnValue({\n sessionStateType: DeviceSessionStateType.ReadyWithoutSecureChannel,\n deviceStatus: DeviceStatus.CONNECTED,\n currentApp: { name: \"AnotherApp\", version: \"0.0.0\" },\n });\n setupGetDeviceStatusMock([\n {\n currentApp: \"AnotherApp\",\n currentAppVersion: \"0.0.0\",\n },\n ]);\n closeAppMock.mockResolvedValue(\n CommandResultFactory({\n error: new InvalidStatusWordError(\"mocked error\"),\n }),\n );\n\n const openAppDeviceAction = new OpenAppDeviceAction({\n input: { appName: \"Bitcoin\" },\n });\n jest\n .spyOn(openAppDeviceAction, \"extractDependencies\")\n .mockReturnValue(extractDependenciesMock());\n\n const expectedStates: Array<OpenAppDAState> = [\n {\n status: DeviceActionStatus.Pending, // get onboarded status\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.None,\n },\n },\n {\n status: DeviceActionStatus.Pending, // get device status\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.None,\n },\n },\n {\n status: DeviceActionStatus.Pending, // close app\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.None,\n },\n },\n {\n status: DeviceActionStatus.Error,\n error: new InvalidStatusWordError(\"mocked error\"),\n },\n ];\n\n testDeviceActionStates(\n openAppDeviceAction,\n expectedStates,\n makeDeviceActionInternalApiMock(),\n done,\n );\n });\n\n it(\"should end in an error if another app is open, close app succeeds but open app returns an error\", (done) => {\n getDeviceSessionStateMock.mockReturnValue({\n sessionStateType: DeviceSessionStateType.ReadyWithoutSecureChannel,\n deviceStatus: DeviceStatus.CONNECTED,\n currentApp: { name: \"AnotherApp\", version: \"0.0.0\" },\n });\n setupGetDeviceStatusMock([\n {\n currentApp: \"AnotherApp\",\n currentAppVersion: \"0.0.0\",\n },\n ]);\n closeAppMock.mockResolvedValue(CommandResultFactory({ data: undefined }));\n openAppMock.mockResolvedValue(\n CommandResultFactory({\n error: new InvalidStatusWordError(\"mocked error\"),\n }),\n );\n\n const openAppDeviceAction = new OpenAppDeviceAction({\n input: { appName: \"Bitcoin\" },\n });\n jest\n .spyOn(openAppDeviceAction, \"extractDependencies\")\n .mockReturnValue(extractDependenciesMock());\n\n const expectedStates: Array<OpenAppDAState> = [\n {\n status: DeviceActionStatus.Pending, // get onboarded status\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.None,\n },\n },\n {\n status: DeviceActionStatus.Pending, // get device status\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.None,\n },\n },\n {\n status: DeviceActionStatus.Pending, // close app\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.None,\n },\n },\n {\n status: DeviceActionStatus.Pending, // open app\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.ConfirmOpenApp,\n },\n },\n {\n status: DeviceActionStatus.Error,\n error: new InvalidStatusWordError(\"mocked error\"),\n },\n ];\n\n testDeviceActionStates(\n openAppDeviceAction,\n expectedStates,\n makeDeviceActionInternalApiMock(),\n done,\n );\n });\n\n it(\"should end in an error if getAppAndVersion actor throws an error\", (done) => {\n getDeviceSessionStateMock.mockReturnValue({\n sessionStateType: DeviceSessionStateType.ReadyWithoutSecureChannel,\n deviceStatus: DeviceStatus.CONNECTED,\n currentApp: { name: \"mockedCurrentApp\", version: \"1.0.0\" },\n });\n\n setupGetDeviceStatusMock([new UnknownDAError(\"Unknown error\")]);\n\n const openAppDeviceAction = new OpenAppDeviceAction({\n input: { appName: \"Bitcoin\" },\n });\n\n jest\n .spyOn(openAppDeviceAction, \"extractDependencies\")\n .mockReturnValue(extractDependenciesMock());\n\n const expectedStates: Array<OpenAppDAState> = [\n {\n status: DeviceActionStatus.Pending, // get onboarded status\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.None,\n },\n },\n {\n status: DeviceActionStatus.Pending, // get device status\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.None,\n },\n },\n {\n status: DeviceActionStatus.Error,\n error: new UnknownDAError(\"Unknown error\"),\n },\n ];\n\n testDeviceActionStates(\n openAppDeviceAction,\n expectedStates,\n makeDeviceActionInternalApiMock(),\n done,\n );\n });\n\n it(\"should end in an error if openApp actor throws an error\", (done) => {\n getDeviceSessionStateMock.mockReturnValue(\n CommandResultFactory({\n data: {\n sessionStateType: DeviceSessionStateType.ReadyWithoutSecureChannel,\n deviceStatus: DeviceStatus.CONNECTED,\n currentApp: { name: \"BOLOS\", version: \"0.0.0\" },\n },\n }),\n );\n setupGetDeviceStatusMock([\n {\n currentApp: \"BOLOS\",\n currentAppVersion: \"0.0.0\",\n },\n ]);\n openAppMock.mockImplementation(() => {\n throw new UnknownDAError(\"Unknown error\");\n });\n\n const openAppDeviceAction = new OpenAppDeviceAction({\n input: { appName: \"Bitcoin\" },\n });\n jest\n .spyOn(openAppDeviceAction, \"extractDependencies\")\n .mockReturnValue(extractDependenciesMock());\n\n const expectedStates: Array<OpenAppDAState> = [\n {\n status: DeviceActionStatus.Pending, // get device onboarded\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.None,\n },\n },\n {\n status: DeviceActionStatus.Pending, // get device status\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.None,\n },\n },\n {\n status: DeviceActionStatus.Pending, // open app\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.ConfirmOpenApp,\n },\n },\n {\n status: DeviceActionStatus.Error,\n error: new UnknownDAError(\"Unknown error\"),\n },\n ];\n\n testDeviceActionStates(\n openAppDeviceAction,\n expectedStates,\n makeDeviceActionInternalApiMock(),\n done,\n );\n });\n\n it(\"should end in an error if closeApp actor throws an error\", (done) => {\n getDeviceSessionStateMock.mockReturnValue(\n CommandResultFactory({\n data: {\n sessionStateType: DeviceSessionStateType.ReadyWithoutSecureChannel,\n deviceStatus: DeviceStatus.CONNECTED,\n currentApp: { name: \"BOLOS\", version: \"0.0.0\" },\n },\n }),\n );\n setupGetDeviceStatusMock([\n {\n currentApp: \"anApp\",\n currentAppVersion: \"0.0.0\",\n },\n ]);\n closeAppMock.mockImplementation(() => {\n throw new UnknownDAError(\"Unknown error\");\n });\n\n const openAppDeviceAction = new OpenAppDeviceAction({\n input: { appName: \"Bitcoin\" },\n });\n jest\n .spyOn(openAppDeviceAction, \"extractDependencies\")\n .mockReturnValue(extractDependenciesMock());\n\n const expectedStates: Array<OpenAppDAState> = [\n {\n status: DeviceActionStatus.Pending, // get onboarded status\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.None,\n },\n },\n {\n status: DeviceActionStatus.Pending, // get device status\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.None,\n },\n },\n {\n status: DeviceActionStatus.Pending, // close app\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.None,\n },\n },\n {\n status: DeviceActionStatus.Error,\n error: new UnknownDAError(\"Unknown error\"),\n },\n ];\n\n testDeviceActionStates(\n openAppDeviceAction,\n expectedStates,\n makeDeviceActionInternalApiMock(),\n done,\n );\n });\n });\n\n it(\"should emit a stopped state if the action is cancelled\", (done) => {\n getDeviceSessionStateMock.mockReturnValue({\n sessionStateType: DeviceSessionStateType.ReadyWithoutSecureChannel,\n deviceStatus: DeviceStatus.CONNECTED,\n currentApp: { name: \"AnotherApp\", version: \"0.0.0\" },\n });\n setupGetDeviceStatusMock([\n {\n currentApp: \"AnotherApp\",\n currentAppVersion: \"0.0.0\",\n },\n ]);\n\n const openAppDeviceAction = new OpenAppDeviceAction({\n input: { appName: \"Bitcoin\" },\n });\n jest\n .spyOn(openAppDeviceAction, \"extractDependencies\")\n .mockReturnValue(extractDependenciesMock());\n\n const expectedStates: Array<OpenAppDAState> = [\n {\n status: DeviceActionStatus.Pending, // get device onboarded\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.None,\n },\n },\n {\n status: DeviceActionStatus.Pending, // get device status\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.None,\n },\n },\n {\n status: DeviceActionStatus.Stopped,\n },\n ];\n\n const { cancel } = testDeviceActionStates(\n openAppDeviceAction,\n expectedStates,\n makeDeviceActionInternalApiMock(),\n done,\n );\n cancel();\n });\n});\n"],
5
- "mappings": "aAAA,IAAAA,EAA8B,gBAE9BC,EAAuC,+BACvCC,EAAqC,4CACrCC,EAA6B,oCAC7BC,EAAgD,6DAChDC,EAAyC,8DACzCC,EAAuC,oEACvCC,EAAmC,sDACnCC,EAAwC,4DACxCP,EAIO,wCACPQ,EAAuC,kDAEv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,CACE,OAAQ,qBAAmB,QAC3B,kBAAmB,CACjB,wBAAyB,0BAAwB,IACnD,CACF,EACA,CACE,OAAQ,qBAAmB,OAC7B,CACF,EAEM,CAAE,OAAAE,CAAO,KAAI,0BACjBH,EACAC,KACA,mCAAgC,EAChCF,CACF,EACAI,EAAO,CACT,CAAC,CACH,CAAC",
6
- "names": ["import_rxjs", "import_Errors", "import_CommandResult", "import_DeviceStatus", "import_makeInternalApi", "import_setupTestMachine", "import_testDeviceActionStates", "import_DeviceActionState", "import_UserInteractionRequired", "import_DeviceSessionState", "import_OpenAppDeviceAction", "getAppAndVersionMock", "openAppMock", "closeAppMock", "getDeviceSessionStateMock", "setDeviceSessionStateMock", "isDeviceOnboardedMock", "extractDependenciesMock", "apiGetDeviceSessionStateMock", "done", "openAppDeviceAction", "expectedStates", "observable", "cancel"]
4
+ "sourcesContent": ["import { lastValueFrom } from \"rxjs\";\n\nimport { InvalidStatusWordError } from \"@api/command/Errors\";\nimport { CommandResultFactory } from \"@api/command/model/CommandResult\";\nimport { DeviceModelId } from \"@api/device/DeviceModel\";\nimport { DeviceStatus } from \"@api/device/DeviceStatus\";\nimport { makeDeviceActionInternalApiMock } from \"@api/device-action/__test-utils__/makeInternalApi\";\nimport { setupGetDeviceStatusMock } from \"@api/device-action/__test-utils__/setupTestMachine\";\nimport { testDeviceActionStates } from \"@api/device-action/__test-utils__/testDeviceActionStates\";\nimport { DeviceActionStatus } from \"@api/device-action/model/DeviceActionState\";\nimport { UserInteractionRequired } from \"@api/device-action/model/UserInteractionRequired\";\nimport {\n DeviceLockedError,\n DeviceNotOnboardedError,\n UnknownDAError,\n} from \"@api/device-action/os/Errors\";\nimport { DeviceSessionStateType } from \"@api/device-session/DeviceSessionState\";\n\nimport { OpenAppDeviceAction } from \"./OpenAppDeviceAction\";\nimport type { OpenAppDAState } from \"./types\";\n\njest.mock(\"@api/device-action/os/GetDeviceStatus/GetDeviceStatusDeviceAction\");\n\ndescribe(\"OpenAppDeviceAction\", () => {\n const getAppAndVersionMock = jest.fn();\n const openAppMock = jest.fn();\n const closeAppMock = jest.fn();\n const getDeviceSessionStateMock = jest.fn();\n const setDeviceSessionStateMock = jest.fn();\n const isDeviceOnboardedMock = jest.fn();\n\n function extractDependenciesMock() {\n return {\n getDeviceSessionState: getDeviceSessionStateMock,\n setDeviceSessionState: setDeviceSessionStateMock,\n getAppAndVersion: getAppAndVersionMock,\n openApp: openAppMock,\n closeApp: closeAppMock,\n isDeviceOnboarded: isDeviceOnboardedMock,\n };\n }\n\n const { getDeviceSessionState: apiGetDeviceSessionStateMock } =\n makeDeviceActionInternalApiMock();\n\n beforeEach(() => {\n jest.resetAllMocks();\n isDeviceOnboardedMock.mockReturnValue(true);\n });\n\n describe(\"without overriding `extractDependencies`\", () => {\n it(\"should end if the required application is opened\", (done) => {\n apiGetDeviceSessionStateMock.mockReturnValue({\n sessionStateType: DeviceSessionStateType.ReadyWithoutSecureChannel,\n deviceStatus: DeviceStatus.CONNECTED,\n currentApp: { name: \"Bitcoin\", version: \"1.0.0\" },\n installedApps: [],\n deviceModelId: DeviceModelId.NANO_X,\n });\n setupGetDeviceStatusMock([\n {\n currentApp: \"Bitcoin\",\n currentAppVersion: \"0.0.0\",\n },\n ]);\n\n const openAppDeviceAction = new OpenAppDeviceAction({\n input: { appName: \"Bitcoin\" },\n });\n\n const expectedStates: Array<OpenAppDAState> = [\n {\n status: DeviceActionStatus.Pending, // get onboarding status\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.None,\n },\n },\n {\n status: DeviceActionStatus.Pending, // get device status\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.None,\n },\n },\n {\n status: DeviceActionStatus.Completed,\n output: undefined,\n },\n ];\n\n testDeviceActionStates(\n openAppDeviceAction,\n expectedStates,\n makeDeviceActionInternalApiMock(),\n done,\n );\n });\n });\n\n describe(\"success cases\", () => {\n it(\"should end in a success if the app is already opened\", (done) => {\n getDeviceSessionStateMock.mockReturnValue({\n sessionStateType: DeviceSessionStateType.ReadyWithoutSecureChannel,\n deviceStatus: DeviceStatus.CONNECTED,\n currentApp: { name: \"Bitcoin\", version: \"1.0.0\" },\n });\n\n setupGetDeviceStatusMock([\n {\n currentApp: \"Bitcoin\",\n currentAppVersion: \"1.0.0\",\n },\n ]);\n const openAppDeviceAction = new OpenAppDeviceAction({\n input: { appName: \"Bitcoin\", unlockTimeout: undefined },\n });\n jest\n .spyOn(openAppDeviceAction, \"extractDependencies\")\n .mockReturnValue(extractDependenciesMock());\n\n const expectedStates: Array<OpenAppDAState> = [\n {\n status: DeviceActionStatus.Pending, // get onboarding status\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.None,\n },\n },\n {\n status: DeviceActionStatus.Pending, // get app and version\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.None,\n },\n },\n {\n status: DeviceActionStatus.Completed,\n output: undefined,\n },\n ];\n\n testDeviceActionStates(\n openAppDeviceAction,\n expectedStates,\n makeDeviceActionInternalApiMock(),\n done,\n );\n });\n\n it(\"should end in a success if a compatible app is already opened\", (done) => {\n getDeviceSessionStateMock.mockReturnValue({\n sessionStateType: DeviceSessionStateType.ReadyWithoutSecureChannel,\n deviceStatus: DeviceStatus.CONNECTED,\n currentApp: {\n name: \"Bitcoin Testnet\",\n version: \"1.0.0\",\n },\n });\n\n setupGetDeviceStatusMock([\n {\n currentApp: \"Bitcoin Testnet\",\n currentAppVersion: \"1.0.0\",\n },\n ]);\n const openAppDeviceAction = new OpenAppDeviceAction({\n input: {\n appName: \"Bitcoin\",\n unlockTimeout: undefined,\n compatibleAppNames: [\"Bitcoin Testnet\"],\n },\n });\n jest\n .spyOn(openAppDeviceAction, \"extractDependencies\")\n .mockReturnValue(extractDependenciesMock());\n\n const expectedStates: Array<OpenAppDAState> = [\n {\n status: DeviceActionStatus.Pending, // get onboarding status\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.None,\n },\n },\n {\n status: DeviceActionStatus.Pending, // get app and version\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.None,\n },\n },\n {\n status: DeviceActionStatus.Completed,\n output: undefined,\n },\n ];\n\n testDeviceActionStates(\n openAppDeviceAction,\n expectedStates,\n makeDeviceActionInternalApiMock(),\n done,\n );\n });\n\n it(\"should end in a success if the dashboard is open and open app succeeds\", (done) => {\n getDeviceSessionStateMock.mockReturnValue({\n sessionStateType: DeviceSessionStateType.ReadyWithoutSecureChannel,\n deviceStatus: DeviceStatus.CONNECTED,\n currentApp: { name: \"BOLOS\", version: \"0.0.0\" },\n });\n\n setupGetDeviceStatusMock([\n {\n currentApp: \"Bitcoin\",\n currentAppVersion: \"1.0.0\",\n },\n ]);\n\n openAppMock.mockResolvedValue(CommandResultFactory({ data: undefined }));\n\n const openAppDeviceAction = new OpenAppDeviceAction({\n input: { appName: \"Bitcoin\" },\n });\n jest\n .spyOn(openAppDeviceAction, \"extractDependencies\")\n .mockReturnValue(extractDependenciesMock());\n\n const expectedStates: Array<OpenAppDAState> = [\n {\n status: DeviceActionStatus.Pending, // get app and version\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.None,\n },\n },\n {\n status: DeviceActionStatus.Pending, // get app and version\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.None,\n },\n },\n {\n status: DeviceActionStatus.Completed,\n output: undefined,\n },\n ];\n\n const { observable } = testDeviceActionStates(\n openAppDeviceAction,\n expectedStates,\n makeDeviceActionInternalApiMock(),\n done,\n );\n\n lastValueFrom(observable).then(() => {\n expect(setDeviceSessionStateMock).toHaveBeenCalledWith({\n deviceStatus: DeviceStatus.CONNECTED,\n sessionStateType: DeviceSessionStateType.ReadyWithoutSecureChannel,\n currentApp: { name: \"Bitcoin\", version: \"1.0.0\" },\n });\n });\n });\n\n it(\"should end in a success if another app is open, close app succeeds and open app succeeds\", (done) => {\n getDeviceSessionStateMock.mockReturnValue({\n sessionStateType: DeviceSessionStateType.ReadyWithoutSecureChannel,\n deviceStatus: DeviceStatus.CONNECTED,\n currentApp: { name: \"AnotherApp\", version: \"0.0.0\" },\n });\n setupGetDeviceStatusMock([\n {\n currentApp: \"AnotherApp\",\n currentAppVersion: \"0.0.0\",\n },\n { currentApp: \"Bitcoin\", currentAppVersion: \"1.0.0\" },\n ]);\n closeAppMock.mockResolvedValue(CommandResultFactory({ data: undefined }));\n openAppMock.mockResolvedValue(CommandResultFactory({ data: undefined }));\n\n const openAppDeviceAction = new OpenAppDeviceAction({\n input: { appName: \"Bitcoin\" },\n });\n jest\n .spyOn(openAppDeviceAction, \"extractDependencies\")\n .mockReturnValue(extractDependenciesMock());\n\n const expectedStates: Array<OpenAppDAState> = [\n {\n status: DeviceActionStatus.Pending, // get app and version\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.None,\n },\n },\n {\n status: DeviceActionStatus.Pending, // close app\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.None,\n },\n },\n {\n status: DeviceActionStatus.Pending, // get device status\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.None,\n },\n },\n {\n status: DeviceActionStatus.Pending, // open app\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.ConfirmOpenApp,\n },\n },\n {\n status: DeviceActionStatus.Pending, // get app and version\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.None,\n },\n },\n {\n status: DeviceActionStatus.Pending, // get app and version\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.None,\n },\n },\n {\n status: DeviceActionStatus.Completed,\n output: undefined,\n },\n ];\n\n const { observable } = testDeviceActionStates(\n openAppDeviceAction,\n expectedStates,\n makeDeviceActionInternalApiMock(),\n done,\n );\n\n lastValueFrom(observable).then(() => {\n expect(setDeviceSessionStateMock).toHaveBeenCalledWith({\n currentApp: { name: \"Bitcoin\", version: \"1.0.0\" },\n deviceStatus: DeviceStatus.CONNECTED,\n sessionStateType: DeviceSessionStateType.ReadyWithoutSecureChannel,\n });\n });\n });\n });\n\n describe(\"errors cases\", () => {\n it(\"should end in an error if the device is not onboarded\", (done) => {\n getDeviceSessionStateMock.mockReturnValue({\n sessionStateType: DeviceSessionStateType.ReadyWithoutSecureChannel,\n deviceStatus: DeviceStatus.CONNECTED,\n currentApp: { name: \"mockedCurrentApp\", version: \"1.0.0\" },\n });\n isDeviceOnboardedMock.mockReturnValue(false);\n\n const openAppDeviceAction = new OpenAppDeviceAction({\n input: { appName: \"Bitcoin\" },\n });\n\n jest\n .spyOn(openAppDeviceAction, \"extractDependencies\")\n .mockReturnValue(extractDependenciesMock());\n\n const expectedStates: Array<OpenAppDAState> = [\n {\n error: new DeviceNotOnboardedError(),\n status: DeviceActionStatus.Error,\n },\n ];\n\n testDeviceActionStates(\n openAppDeviceAction,\n expectedStates,\n makeDeviceActionInternalApiMock(),\n done,\n );\n });\n\n it(\"should end in an error if the device is locked\", (done) => {\n getDeviceSessionStateMock.mockReturnValue({\n sessionStateType: DeviceSessionStateType.ReadyWithoutSecureChannel,\n deviceStatus: DeviceStatus.LOCKED,\n currentApp: { name: \"mockedCurrentApp\", version: \"1.0.0\" },\n });\n\n setupGetDeviceStatusMock([new DeviceLockedError()]);\n\n const openAppDeviceAction = new OpenAppDeviceAction({\n input: { appName: \"Bitcoin\" },\n });\n\n jest\n .spyOn(openAppDeviceAction, \"extractDependencies\")\n .mockReturnValue(extractDependenciesMock());\n\n const expectedStates: Array<OpenAppDAState> = [\n {\n status: DeviceActionStatus.Pending,\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.None,\n },\n },\n {\n status: DeviceActionStatus.Pending,\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.None,\n },\n },\n {\n status: DeviceActionStatus.Error,\n error: new DeviceLockedError(),\n },\n ];\n\n testDeviceActionStates(\n openAppDeviceAction,\n expectedStates,\n makeDeviceActionInternalApiMock(),\n done,\n );\n });\n\n it(\"should end in an error if getAppAndVersion returns an error\", (done) => {\n getDeviceSessionStateMock.mockReturnValue({\n sessionStateType: DeviceSessionStateType.ReadyWithoutSecureChannel,\n deviceStatus: DeviceStatus.CONNECTED,\n currentApp: { name: \"mockedCurrentApp\", version: \"1.0.0\" },\n });\n\n setupGetDeviceStatusMock([new InvalidStatusWordError(\"mocked error\")]);\n\n const openAppDeviceAction = new OpenAppDeviceAction({\n input: { appName: \"Bitcoin\" },\n });\n\n jest\n .spyOn(openAppDeviceAction, \"extractDependencies\")\n .mockReturnValue(extractDependenciesMock());\n\n const expectedStates: Array<OpenAppDAState> = [\n {\n status: DeviceActionStatus.Pending, // get app and version\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.None,\n },\n },\n {\n status: DeviceActionStatus.Pending, // get device status\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.None,\n },\n },\n {\n status: DeviceActionStatus.Error,\n error: new InvalidStatusWordError(\"mocked error\"),\n },\n ];\n\n testDeviceActionStates(\n openAppDeviceAction,\n expectedStates,\n makeDeviceActionInternalApiMock(),\n done,\n );\n });\n\n it(\"should end in an error if the dashboard is open and open app returns an error\", (done) => {\n getDeviceSessionStateMock.mockReturnValue(\n CommandResultFactory({\n data: {\n sessionStateType: DeviceSessionStateType.ReadyWithoutSecureChannel,\n deviceStatus: DeviceStatus.CONNECTED,\n currentApp: { name: \"BOLOS\", version: \"0.0.0\" },\n },\n }),\n );\n getAppAndVersionMock.mockResolvedValue(\n CommandResultFactory({\n data: {\n name: \"BOLOS\",\n version: \"0.0.0\",\n },\n }),\n );\n setupGetDeviceStatusMock([\n {\n currentApp: \"BOLOS\",\n currentAppVersion: \"0.0.0\",\n },\n ]);\n openAppMock.mockResolvedValue(\n CommandResultFactory({\n error: new InvalidStatusWordError(\"mocked error\"),\n }),\n );\n\n const openAppDeviceAction = new OpenAppDeviceAction({\n input: { appName: \"Bitcoin\" },\n });\n jest\n .spyOn(openAppDeviceAction, \"extractDependencies\")\n .mockReturnValue(extractDependenciesMock());\n\n const expectedStates: Array<OpenAppDAState> = [\n {\n status: DeviceActionStatus.Pending, // get onboarded status\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.None,\n },\n },\n {\n status: DeviceActionStatus.Pending, // get device status\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.None,\n },\n },\n {\n status: DeviceActionStatus.Pending, // open app\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.ConfirmOpenApp,\n },\n },\n {\n status: DeviceActionStatus.Error,\n error: new InvalidStatusWordError(\"mocked error\"),\n },\n ];\n\n testDeviceActionStates(\n openAppDeviceAction,\n expectedStates,\n makeDeviceActionInternalApiMock(),\n done,\n );\n });\n\n it(\"should end in an error if another app is open, and close app returns an error\", (done) => {\n getDeviceSessionStateMock.mockReturnValue({\n sessionStateType: DeviceSessionStateType.ReadyWithoutSecureChannel,\n deviceStatus: DeviceStatus.CONNECTED,\n currentApp: { name: \"AnotherApp\", version: \"0.0.0\" },\n });\n setupGetDeviceStatusMock([\n {\n currentApp: \"AnotherApp\",\n currentAppVersion: \"0.0.0\",\n },\n ]);\n closeAppMock.mockResolvedValue(\n CommandResultFactory({\n error: new InvalidStatusWordError(\"mocked error\"),\n }),\n );\n\n const openAppDeviceAction = new OpenAppDeviceAction({\n input: { appName: \"Bitcoin\" },\n });\n jest\n .spyOn(openAppDeviceAction, \"extractDependencies\")\n .mockReturnValue(extractDependenciesMock());\n\n const expectedStates: Array<OpenAppDAState> = [\n {\n status: DeviceActionStatus.Pending, // get onboarded status\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.None,\n },\n },\n {\n status: DeviceActionStatus.Pending, // get device status\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.None,\n },\n },\n {\n status: DeviceActionStatus.Pending, // close app\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.None,\n },\n },\n {\n status: DeviceActionStatus.Error,\n error: new InvalidStatusWordError(\"mocked error\"),\n },\n ];\n\n testDeviceActionStates(\n openAppDeviceAction,\n expectedStates,\n makeDeviceActionInternalApiMock(),\n done,\n );\n });\n\n it(\"should end in an error if another app is open, close app succeeds but open app returns an error\", (done) => {\n getDeviceSessionStateMock.mockReturnValue({\n sessionStateType: DeviceSessionStateType.ReadyWithoutSecureChannel,\n deviceStatus: DeviceStatus.CONNECTED,\n currentApp: { name: \"AnotherApp\", version: \"0.0.0\" },\n });\n setupGetDeviceStatusMock([\n {\n currentApp: \"AnotherApp\",\n currentAppVersion: \"0.0.0\",\n },\n ]);\n closeAppMock.mockResolvedValue(CommandResultFactory({ data: undefined }));\n openAppMock.mockResolvedValue(\n CommandResultFactory({\n error: new InvalidStatusWordError(\"mocked error\"),\n }),\n );\n\n const openAppDeviceAction = new OpenAppDeviceAction({\n input: { appName: \"Bitcoin\" },\n });\n jest\n .spyOn(openAppDeviceAction, \"extractDependencies\")\n .mockReturnValue(extractDependenciesMock());\n\n const expectedStates: Array<OpenAppDAState> = [\n {\n status: DeviceActionStatus.Pending, // get onboarded status\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.None,\n },\n },\n {\n status: DeviceActionStatus.Pending, // get device status\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.None,\n },\n },\n {\n status: DeviceActionStatus.Pending, // close app\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.None,\n },\n },\n {\n status: DeviceActionStatus.Pending, // open app\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.ConfirmOpenApp,\n },\n },\n {\n status: DeviceActionStatus.Error,\n error: new InvalidStatusWordError(\"mocked error\"),\n },\n ];\n\n testDeviceActionStates(\n openAppDeviceAction,\n expectedStates,\n makeDeviceActionInternalApiMock(),\n done,\n );\n });\n\n it(\"should end in an error if getAppAndVersion actor throws an error\", (done) => {\n getDeviceSessionStateMock.mockReturnValue({\n sessionStateType: DeviceSessionStateType.ReadyWithoutSecureChannel,\n deviceStatus: DeviceStatus.CONNECTED,\n currentApp: { name: \"mockedCurrentApp\", version: \"1.0.0\" },\n });\n\n setupGetDeviceStatusMock([new UnknownDAError(\"Unknown error\")]);\n\n const openAppDeviceAction = new OpenAppDeviceAction({\n input: { appName: \"Bitcoin\" },\n });\n\n jest\n .spyOn(openAppDeviceAction, \"extractDependencies\")\n .mockReturnValue(extractDependenciesMock());\n\n const expectedStates: Array<OpenAppDAState> = [\n {\n status: DeviceActionStatus.Pending, // get onboarded status\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.None,\n },\n },\n {\n status: DeviceActionStatus.Pending, // get device status\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.None,\n },\n },\n {\n status: DeviceActionStatus.Error,\n error: new UnknownDAError(\"Unknown error\"),\n },\n ];\n\n testDeviceActionStates(\n openAppDeviceAction,\n expectedStates,\n makeDeviceActionInternalApiMock(),\n done,\n );\n });\n\n it(\"should end in an error if openApp actor throws an error\", (done) => {\n getDeviceSessionStateMock.mockReturnValue(\n CommandResultFactory({\n data: {\n sessionStateType: DeviceSessionStateType.ReadyWithoutSecureChannel,\n deviceStatus: DeviceStatus.CONNECTED,\n currentApp: { name: \"BOLOS\", version: \"0.0.0\" },\n },\n }),\n );\n setupGetDeviceStatusMock([\n {\n currentApp: \"BOLOS\",\n currentAppVersion: \"0.0.0\",\n },\n ]);\n openAppMock.mockImplementation(() => {\n throw new UnknownDAError(\"Unknown error\");\n });\n\n const openAppDeviceAction = new OpenAppDeviceAction({\n input: { appName: \"Bitcoin\" },\n });\n jest\n .spyOn(openAppDeviceAction, \"extractDependencies\")\n .mockReturnValue(extractDependenciesMock());\n\n const expectedStates: Array<OpenAppDAState> = [\n {\n status: DeviceActionStatus.Pending, // get device onboarded\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.None,\n },\n },\n {\n status: DeviceActionStatus.Pending, // get device status\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.None,\n },\n },\n {\n status: DeviceActionStatus.Pending, // open app\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.ConfirmOpenApp,\n },\n },\n {\n status: DeviceActionStatus.Error,\n error: new UnknownDAError(\"Unknown error\"),\n },\n ];\n\n testDeviceActionStates(\n openAppDeviceAction,\n expectedStates,\n makeDeviceActionInternalApiMock(),\n done,\n );\n });\n\n it(\"should end in an error if closeApp actor throws an error\", (done) => {\n getDeviceSessionStateMock.mockReturnValue(\n CommandResultFactory({\n data: {\n sessionStateType: DeviceSessionStateType.ReadyWithoutSecureChannel,\n deviceStatus: DeviceStatus.CONNECTED,\n currentApp: { name: \"BOLOS\", version: \"0.0.0\" },\n },\n }),\n );\n setupGetDeviceStatusMock([\n {\n currentApp: \"anApp\",\n currentAppVersion: \"0.0.0\",\n },\n ]);\n closeAppMock.mockImplementation(() => {\n throw new UnknownDAError(\"Unknown error\");\n });\n\n const openAppDeviceAction = new OpenAppDeviceAction({\n input: { appName: \"Bitcoin\" },\n });\n jest\n .spyOn(openAppDeviceAction, \"extractDependencies\")\n .mockReturnValue(extractDependenciesMock());\n\n const expectedStates: Array<OpenAppDAState> = [\n {\n status: DeviceActionStatus.Pending, // get onboarded status\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.None,\n },\n },\n {\n status: DeviceActionStatus.Pending, // get device status\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.None,\n },\n },\n {\n status: DeviceActionStatus.Pending, // close app\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.None,\n },\n },\n {\n status: DeviceActionStatus.Error,\n error: new UnknownDAError(\"Unknown error\"),\n },\n ];\n\n testDeviceActionStates(\n openAppDeviceAction,\n expectedStates,\n makeDeviceActionInternalApiMock(),\n done,\n );\n });\n });\n\n it(\"should emit a stopped state if the action is cancelled\", (done) => {\n getDeviceSessionStateMock.mockReturnValue({\n sessionStateType: DeviceSessionStateType.ReadyWithoutSecureChannel,\n deviceStatus: DeviceStatus.CONNECTED,\n currentApp: { name: \"AnotherApp\", version: \"0.0.0\" },\n });\n setupGetDeviceStatusMock([\n {\n currentApp: \"AnotherApp\",\n currentAppVersion: \"0.0.0\",\n },\n ]);\n\n const openAppDeviceAction = new OpenAppDeviceAction({\n input: { appName: \"Bitcoin\" },\n });\n jest\n .spyOn(openAppDeviceAction, \"extractDependencies\")\n .mockReturnValue(extractDependenciesMock());\n\n const expectedStates: Array<OpenAppDAState> = [\n {\n status: DeviceActionStatus.Pending, // get device onboarded\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.None,\n },\n },\n {\n status: DeviceActionStatus.Pending, // get device status\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.None,\n },\n },\n {\n status: DeviceActionStatus.Stopped,\n },\n ];\n\n const { cancel } = testDeviceActionStates(\n openAppDeviceAction,\n expectedStates,\n makeDeviceActionInternalApiMock(),\n done,\n );\n cancel();\n });\n});\n"],
5
+ "mappings": "aAAA,IAAAA,EAA8B,gBAE9BC,EAAuC,+BACvCC,EAAqC,4CACrCC,EAA8B,mCAC9BC,EAA6B,oCAC7BC,EAAgD,6DAChDC,EAAyC,8DACzCC,EAAuC,oEACvCC,EAAmC,sDACnCC,EAAwC,4DACxCR,EAIO,wCACPS,EAAuC,kDAEvCC,EAAoC,iCAGpC,KAAK,KAAK,mEAAmE,EAE7E,SAAS,sBAAuB,IAAM,CACpC,MAAMC,EAAuB,KAAK,GAAG,EAC/BC,EAAc,KAAK,GAAG,EACtBC,EAAe,KAAK,GAAG,EACvBC,EAA4B,KAAK,GAAG,EACpCC,EAA4B,KAAK,GAAG,EACpCC,EAAwB,KAAK,GAAG,EAEtC,SAASC,GAA0B,CACjC,MAAO,CACL,sBAAuBH,EACvB,sBAAuBC,EACvB,iBAAkBJ,EAClB,QAASC,EACT,SAAUC,EACV,kBAAmBG,CACrB,CACF,CAEA,KAAM,CAAE,sBAAuBE,CAA6B,KAC1D,mCAAgC,EAElC,WAAW,IAAM,CACf,KAAK,cAAc,EACnBF,EAAsB,gBAAgB,EAAI,CAC5C,CAAC,EAED,SAAS,2CAA4C,IAAM,CACzD,GAAG,mDAAqDG,GAAS,CAC/DD,EAA6B,gBAAgB,CAC3C,iBAAkB,yBAAuB,0BACzC,aAAc,eAAa,UAC3B,WAAY,CAAE,KAAM,UAAW,QAAS,OAAQ,EAChD,cAAe,CAAC,EAChB,c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,CACE,OAAQ,qBAAmB,QAC3B,kBAAmB,CACjB,wBAAyB,0BAAwB,IACnD,CACF,EACA,CACE,OAAQ,qBAAmB,OAC7B,CACF,EAEM,CAAE,OAAAE,CAAO,KAAI,0BACjBH,EACAC,KACA,mCAAgC,EAChCF,CACF,EACAI,EAAO,CACT,CAAC,CACH,CAAC",
6
+ "names": ["import_rxjs", "import_Errors", "import_CommandResult", "import_DeviceModel", "import_DeviceStatus", "import_makeInternalApi", "import_setupTestMachine", "import_testDeviceActionStates", "import_DeviceActionState", "import_UserInteractionRequired", "import_DeviceSessionState", "import_OpenAppDeviceAction", "getAppAndVersionMock", "openAppMock", "closeAppMock", "getDeviceSessionStateMock", "setDeviceSessionStateMock", "isDeviceOnboardedMock", "extractDependenciesMock", "apiGetDeviceSessionStateMock", "done", "openAppDeviceAction", "expectedStates", "observable", "cancel"]
7
7
  }
@@ -1,2 +1,2 @@
1
- "use strict";var o=Object.defineProperty;var i=Object.getOwnPropertyDescriptor;var A=Object.getOwnPropertyNames;var a=Object.prototype.hasOwnProperty;var D=(r,e,n,t)=>{if(e&&typeof e=="object"||typeof e=="function")for(let p of A(e))!a.call(r,p)&&p!==n&&o(r,p,{get:()=>e[p],enumerable:!(t=i(e,p))||t.enumerable});return r};var d=r=>D(o({},"__esModule",{value:!0}),r);var c={};module.exports=d(c);
1
+ "use strict";var o=Object.defineProperty;var i=Object.getOwnPropertyDescriptor;var A=Object.getOwnPropertyNames;var a=Object.prototype.hasOwnProperty;var d=(r,e,n,t)=>{if(e&&typeof e=="object"||typeof e=="function")for(let p of A(e))!a.call(r,p)&&p!==n&&o(r,p,{get:()=>e[p],enumerable:!(t=i(e,p))||t.enumerable});return r};var D=r=>d(o({},"__esModule",{value:!0}),r);var c={};module.exports=D(c);
2
2
  //# sourceMappingURL=types.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../../../../src/api/device-action/os/OpenAppDeviceAction/types.ts"],
4
- "sourcesContent": ["import { type CommandErrorResult } from \"@api/command/model/CommandResult\";\nimport { type OpenAppErrorCodes } from \"@api/command/os/OpenAppCommand\";\nimport { type DeviceActionState } from \"@api/device-action/model/DeviceActionState\";\nimport { type UserInteractionRequired } from \"@api/device-action/model/UserInteractionRequired\";\nimport {\n type DeviceLockedError,\n type DeviceNotOnboardedError,\n type UnknownDAError,\n} from \"@api/device-action/os/Errors\";\nimport { type GetDeviceStatusDAInput } from \"@api/device-action/os/GetDeviceStatus/types\";\n\nexport type OpenAppDAOutput = void;\n\nexport type OpenAppDAInput = GetDeviceStatusDAInput & {\n readonly appName: string;\n};\n\nexport type OpenAppDAError =\n | DeviceNotOnboardedError\n | DeviceLockedError\n | UnknownDAError\n | CommandErrorResult<OpenAppErrorCodes | void>[\"error\"];\n\nexport type OpenAppDARequiredInteraction =\n | UserInteractionRequired.None\n | UserInteractionRequired.UnlockDevice\n | UserInteractionRequired.ConfirmOpenApp;\n\nexport type OpenAppDAIntermediateValue = {\n requiredUserInteraction: OpenAppDARequiredInteraction;\n};\n\nexport type OpenAppDAState = DeviceActionState<\n OpenAppDAOutput,\n OpenAppDAError,\n OpenAppDAIntermediateValue\n>;\n"],
4
+ "sourcesContent": ["import { type CommandErrorResult } from \"@api/command/model/CommandResult\";\nimport { type OpenAppErrorCodes } from \"@api/command/os/OpenAppCommand\";\nimport { type DeviceActionState } from \"@api/device-action/model/DeviceActionState\";\nimport { type UserInteractionRequired } from \"@api/device-action/model/UserInteractionRequired\";\nimport {\n type DeviceLockedError,\n type DeviceNotOnboardedError,\n type UnknownDAError,\n} from \"@api/device-action/os/Errors\";\nimport { type GetDeviceStatusDAInput } from \"@api/device-action/os/GetDeviceStatus/types\";\n\nexport type OpenAppDAOutput = void;\n\nexport type OpenAppDAInput = GetDeviceStatusDAInput & {\n readonly appName: string;\n readonly compatibleAppNames?: string[];\n};\n\nexport type OpenAppDAError =\n | DeviceNotOnboardedError\n | DeviceLockedError\n | UnknownDAError\n | CommandErrorResult<OpenAppErrorCodes | void>[\"error\"];\n\nexport type OpenAppDARequiredInteraction =\n | UserInteractionRequired.None\n | UserInteractionRequired.UnlockDevice\n | UserInteractionRequired.ConfirmOpenApp;\n\nexport type OpenAppDAIntermediateValue = {\n requiredUserInteraction: OpenAppDARequiredInteraction;\n};\n\nexport type OpenAppDAState = DeviceActionState<\n OpenAppDAOutput,\n OpenAppDAError,\n OpenAppDAIntermediateValue\n>;\n"],
5
5
  "mappings": "+WAAA,IAAAA,EAAA,kBAAAC,EAAAD",
6
6
  "names": ["types_exports", "__toCommonJS"]
7
7
  }
@@ -1,2 +1,2 @@
1
- "use strict";var p=Object.defineProperty;var u=Object.getOwnPropertyDescriptor;var A=Object.getOwnPropertyNames;var S=Object.prototype.hasOwnProperty;var I=(o,n)=>{for(var a in n)p(o,a,{get:n[a],enumerable:!0})},l=(o,n,a,e)=>{if(n&&typeof n=="object"||typeof n=="function")for(let r of A(n))!S.call(o,r)&&r!==a&&p(o,r,{get:()=>n[r],enumerable:!(e=u(n,r))||e.enumerable});return o};var D=o=>l(p({},"__esModule",{value:!0}),o);var R={};I(R,{SendCommandInAppDeviceAction:()=>E});module.exports=D(R);var m=require("purify-ts"),t=require("xstate"),i=require("../../../command/model/CommandResult"),d=require("../../../device-action/model/UserInteractionRequired"),s=require("../../../device-action/os/Errors"),C=require("../../../device-action/os/OpenAppDeviceAction/OpenAppDeviceAction"),c=require("../../../device-action/xstate-utils/XStateDeviceAction");class E extends c.XStateDeviceAction{makeStateMachine(n){const{sendCommand:a}=this.extractDependencies(n);return(0,t.setup)({types:{input:{},context:{},output:{}},actors:{sendCommand:(0,t.fromPromise)(a),openAppStateMachine:new C.OpenAppDeviceAction({input:{appName:this.input.appName}}).makeStateMachine(n)},guards:{noInternalError:({context:e})=>e._internalState.error===null},actions:{assignErrorFromEvent:(0,t.assign)({_internalState:e=>({...e.context._internalState,error:e.event.error})})}}).createMachine({id:"SendCommandInAppDeviceAction",initial:"OpenAppDeviceAction",context:({input:e})=>({input:e,intermediateValue:{requiredUserInteraction:d.UserInteractionRequired.None},_internalState:{commandResponse:null,error:null}}),states:{OpenAppDeviceAction:{invoke:{id:"openAppStateMachine",input:{appName:this.input.appName},src:"openAppStateMachine",onSnapshot:{actions:(0,t.assign)({intermediateValue:e=>e.event.snapshot.context.intermediateValue})},onDone:{actions:(0,t.assign)({_internalState:e=>e.event.output.caseOf({Right:()=>e.context._internalState,Left:r=>({...e.context._internalState,error:r})})}),target:"CheckOpenAppDeviceActionResult"}}},CheckOpenAppDeviceActionResult:{always:[{target:"SendCommand",guard:"noInternalError"},"Error"]},SendCommand:{entry:(0,t.assign)({intermediateValue:{requiredUserInteraction:this.input.requiredUserInteraction}}),exit:(0,t.assign)({intermediateValue:{requiredUserInteraction:d.UserInteractionRequired.None}}),invoke:{id:"sendCommand",src:"sendCommand",input:({context:e})=>e.input.command,onDone:{target:"SendCommandResultCheck",actions:[(0,t.assign)({_internalState:({event:e,context:r})=>(0,i.isSuccessCommandResult)(e.output)?{...r._internalState,commandResponse:e.output.data}:{...r._internalState,error:e.output.error}})]},onError:{target:"Error",actions:"assignErrorFromEvent"}}},SendCommandResultCheck:{always:[{target:"Success",guard:"noInternalError"},"Error"]},Success:{type:"final"},Error:{type:"final"}},output:({context:e})=>e._internalState.commandResponse?(0,m.Right)(e._internalState.commandResponse):(0,m.Left)(e._internalState.error||new s.UnknownDAError("No error in final state"))})}extractDependencies(n){return{sendCommand:a=>n.sendCommand(a.input)}}}0&&(module.exports={SendCommandInAppDeviceAction});
1
+ "use strict";var p=Object.defineProperty;var u=Object.getOwnPropertyDescriptor;var A=Object.getOwnPropertyNames;var S=Object.prototype.hasOwnProperty;var l=(o,n)=>{for(var a in n)p(o,a,{get:n[a],enumerable:!0})},I=(o,n,a,e)=>{if(n&&typeof n=="object"||typeof n=="function")for(let r of A(n))!S.call(o,r)&&r!==a&&p(o,r,{get:()=>n[r],enumerable:!(e=u(n,r))||e.enumerable});return o};var D=o=>I(p({},"__esModule",{value:!0}),o);var R={};l(R,{SendCommandInAppDeviceAction:()=>E});module.exports=D(R);var m=require("purify-ts"),t=require("xstate"),i=require("../../../command/model/CommandResult"),d=require("../../../device-action/model/UserInteractionRequired"),s=require("../../../device-action/os/Errors"),C=require("../../../device-action/os/OpenAppDeviceAction/OpenAppDeviceAction"),c=require("../../../device-action/xstate-utils/XStateDeviceAction");class E extends c.XStateDeviceAction{makeStateMachine(n){const{sendCommand:a}=this.extractDependencies(n);return(0,t.setup)({types:{input:{},context:{},output:{}},actors:{sendCommand:(0,t.fromPromise)(a),openAppStateMachine:new C.OpenAppDeviceAction({input:{appName:this.input.appName,compatibleAppNames:this.input.compatibleAppNames}}).makeStateMachine(n)},guards:{noInternalError:({context:e})=>e._internalState.error===null},actions:{assignErrorFromEvent:(0,t.assign)({_internalState:e=>({...e.context._internalState,error:e.event.error})})}}).createMachine({id:"SendCommandInAppDeviceAction",initial:"OpenAppDeviceAction",context:({input:e})=>({input:e,intermediateValue:{requiredUserInteraction:d.UserInteractionRequired.None},_internalState:{commandResponse:null,error:null}}),states:{OpenAppDeviceAction:{invoke:{id:"openAppStateMachine",input:{appName:this.input.appName,compatibleAppNames:this.input.compatibleAppNames},src:"openAppStateMachine",onSnapshot:{actions:(0,t.assign)({intermediateValue:e=>e.event.snapshot.context.intermediateValue})},onDone:{actions:(0,t.assign)({_internalState:e=>e.event.output.caseOf({Right:()=>e.context._internalState,Left:r=>({...e.context._internalState,error:r})})}),target:"CheckOpenAppDeviceActionResult"}}},CheckOpenAppDeviceActionResult:{always:[{target:"SendCommand",guard:"noInternalError"},"Error"]},SendCommand:{entry:(0,t.assign)({intermediateValue:{requiredUserInteraction:this.input.requiredUserInteraction}}),exit:(0,t.assign)({intermediateValue:{requiredUserInteraction:d.UserInteractionRequired.None}}),invoke:{id:"sendCommand",src:"sendCommand",input:({context:e})=>e.input.command,onDone:{target:"SendCommandResultCheck",actions:[(0,t.assign)({_internalState:({event:e,context:r})=>(0,i.isSuccessCommandResult)(e.output)?{...r._internalState,commandResponse:e.output.data}:{...r._internalState,error:e.output.error}})]},onError:{target:"Error",actions:"assignErrorFromEvent"}}},SendCommandResultCheck:{always:[{target:"Success",guard:"noInternalError"},"Error"]},Success:{type:"final"},Error:{type:"final"}},output:({context:e})=>e._internalState.commandResponse?(0,m.Right)(e._internalState.commandResponse):(0,m.Left)(e._internalState.error||new s.UnknownDAError("No error in final state"))})}extractDependencies(n){return{sendCommand:a=>n.sendCommand(a.input)}}}0&&(module.exports={SendCommandInAppDeviceAction});
2
2
  //# sourceMappingURL=SendCommandInAppDeviceAction.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../../../../src/api/device-action/os/SendCommandInAppDeviceAction/SendCommandInAppDeviceAction.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\";\nimport { type Command } from \"@api/types\";\n\nimport {\n type SendCommandInAppDAError,\n type SendCommandInAppDAInput,\n type SendCommandInAppDAIntermediateValue,\n type SendCommandInAppDAInternalState,\n type SendCommandInAppDAOutput,\n} from \"./SendCommandInAppDeviceActionTypes\";\n\n/**\n * Tries to open an app on the device, and if it is successful, sends a command\n * to the app.\n * The output will be the result of the command.\n *\n * ```ts\n * input: {\n * appName: string;\n * command: Command<CommandResult, CommandArgs>;\n * requiredUserInteraction: UserInteraction;\n * }\n * ```\n *\n * Example of usage:\n *\n * ```ts\n * const deviceAction = new SendCommandInAppDeviceAction({\n * input: {\n * appName: \"MyApp\",\n * command: new MyAppSpecificCommand({commandSpecificArg: \"foo\"}),\n * requiredUserInteraction: UserInteractionRequired.None,\n * },\n * });\n * dmk.executeDeviceAction({ sessionId: \"mySessionId\", deviceAction });\n * ```\n */\nexport class SendCommandInAppDeviceAction<\n CommandResponse,\n CommandArgs,\n CommandErrorCodes,\n UserInteraction extends UserInteractionRequired,\n> extends XStateDeviceAction<\n SendCommandInAppDAOutput<CommandResponse>,\n SendCommandInAppDAInput<\n CommandResponse,\n CommandArgs,\n CommandErrorCodes,\n UserInteraction\n >,\n SendCommandInAppDAError<CommandErrorCodes>,\n SendCommandInAppDAIntermediateValue<UserInteraction>,\n SendCommandInAppDAInternalState<CommandResponse, CommandErrorCodes>\n> {\n makeStateMachine(\n internalAPI: InternalApi,\n ): DeviceActionStateMachine<\n SendCommandInAppDAOutput<CommandResponse>,\n SendCommandInAppDAInput<\n CommandResponse,\n CommandArgs,\n CommandErrorCodes,\n UserInteraction\n >,\n SendCommandInAppDAError<CommandErrorCodes>,\n SendCommandInAppDAIntermediateValue<UserInteraction>,\n SendCommandInAppDAInternalState<CommandResponse, CommandErrorCodes>\n > {\n type types = StateMachineTypes<\n SendCommandInAppDAOutput<CommandResponse>,\n SendCommandInAppDAInput<\n CommandResponse,\n CommandArgs,\n CommandErrorCodes,\n UserInteraction\n >,\n SendCommandInAppDAError<CommandErrorCodes>,\n SendCommandInAppDAIntermediateValue<UserInteraction>,\n SendCommandInAppDAInternalState<CommandResponse, CommandErrorCodes>\n >;\n\n const { sendCommand } = 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 sendCommand: fromPromise(sendCommand),\n openAppStateMachine: new OpenAppDeviceAction({\n input: { appName: this.input.appName },\n }).makeStateMachine(internalAPI),\n },\n guards: {\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 /** @xstate-layout N4IgpgJg5mDOIC5QFEAuALA0mAngJwEsA7KAcTFQEEII85YARMANwIGMxK3UCB7IgHQB5AA5gilESKasOXHvwDEEfmAHFmvANZreYiVIDKqAIaowAWRNt0xMAG0ADAF1EoEb1gEFRNyAAeiACMQQDsAgAcACwAzKEArABMUfGpEQCcEYkANCA4iFGO8QKhjokxERUpQenp8QC+9bloWLiEJORUNHSwjCzsnNx8ggDC6GBsWqLiktL9ckP8AEpwAK4ANqiKTq5IIB5ePn6BCEFR4YkAbKE1Zemh55URufkI8fcC8TGXl0EVoelHJcio1mhhsPhiGQKNRaPQZAN5MMBGMJlN9LMEQsfCtYBstvYgrt3J5vMNjgUQgJLokHlEgldko50rEXoh3uEvj8-hEAUCQU0QC0Ie1oV04b0sYMfAJOrCerARrwALbKkxECDKVTqIiaHQCGDihVK1XqiA7PwHMn8CmnRJBASOFIxKJXJ21GLpHJ5RARGoCEL3CKXDLpS4pCKgoXgtpQuXdeHzaXI+MSxUqtUaxRgPB4Xh4AQidZmABm+eVBphCd6Jsz5pcltJRz2Jyiv0dvIeNJi8UqoWePoQIccn3iId+sSqkajRF4EDgfmFsY6VbTUqRNr2VuboBOAFpLmzTpd0iV+0EkkEylcAVEo0vISujYnZMn+MIMVJ14tfFum+SWwKb1XkSMdIhuQFEidYNSjvQUH1FVMFW-GVUUmaYDDmV8NyIXF8UbQ4AN3X0ogEF17S9eJQhiJ0ojbI8khHc54mvRwGUBXl7xjR8xXlF9ER-WVV2NDMzQI61f2IhBXUdRw5NDX54gvXkjx+CIzxuMdfnKd44LBVoeKQ-jsWRQxVjYDhenEncAmCcMBHKBlqKyIEYivGIjzDGJqQSYMamDa4BX0kU42E4y30EZBc3zayiNshBSmKFjqn7GCMgHV57lIz0aT9P0lL+S5GkaIA */\n id: \"SendCommandInAppDeviceAction\",\n initial: \"OpenAppDeviceAction\",\n context: ({ input }) => {\n return {\n input: input,\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.None,\n },\n _internalState: {\n commandResponse: null,\n error: null,\n },\n };\n },\n states: {\n OpenAppDeviceAction: {\n invoke: {\n id: \"openAppStateMachine\",\n input: { appName: this.input.appName },\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 SendCommandInAppDAInternalState<\n CommandResponse,\n CommandErrorCodes\n >\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: \"SendCommand\",\n guard: \"noInternalError\",\n },\n \"Error\",\n ],\n },\n SendCommand: {\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: \"sendCommand\",\n src: \"sendCommand\",\n input: ({ context }) => context.input.command,\n onDone: {\n target: \"SendCommandResultCheck\",\n actions: [\n assign({\n _internalState: ({ event, context }) => {\n if (isSuccessCommandResult(event.output)) {\n return {\n ...context._internalState,\n commandResponse: 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 SendCommandResultCheck: {\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.commandResponse\n ? Right(context._internalState.commandResponse)\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 sendCommand: (_: {\n input: Command<CommandResponse, CommandArgs, CommandErrorCodes>;\n }): Promise<CommandResult<CommandResponse, CommandErrorCodes>> =>\n internalApi.sendCommand(_.input),\n };\n }\n}\n"],
5
- "mappings": "yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,kCAAAE,IAAA,eAAAC,EAAAH,GAAA,IAAAI,EAA4B,qBAC5BC,EAA2C,kBAE3CC,EAGO,4CAEPC,EAAwC,4DACxCC,EAA+B,wCAC/BC,EAAoC,yEAEpCC,EAGO,8DAqCA,MAAMR,UAKH,oBAWR,CACA,iBACES,EAYA,CAcA,KAAM,CAAE,YAAAC,CAAY,EAAI,KAAK,oBAAoBD,CAAW,EAE5D,SAAO,SAAM,CACX,MAAO,CACL,MAAO,CAAC,EACR,QAAS,CAAC,EACV,OAAQ,CAAC,CACX,EACA,OAAQ,CACN,eAAa,eAAYC,CAAW,EACpC,oBAAqB,IAAI,sBAAoB,CAC3C,MAAO,CAAE,QAAS,KAAK,MAAM,OAAQ,CACvC,CAAC,EAAE,iBAAiBD,CAAW,CACjC,EACA,OAAQ,CACN,gBAAiB,CAAC,CAAE,QAAAE,CAAQ,IAAMA,EAAQ,eAAe,QAAU,IACrE,EACA,QAAS,CACP,wBAAsB,UAAO,CAC3B,eAAiBC,IAAO,CACtB,GAAGA,EAAE,QAAQ,eACb,MAAOA,EAAE,MAAM,KACjB,EACF,CAAC,CACH,CACF,CAAC,EAAE,cAAc,CAEf,GAAI,+BACJ,QAAS,sBACT,QAAS,CAAC,CAAE,MAAAC,CAAM,KACT,CACL,MAAOA,EACP,kBAAmB,CACjB,wBAAyB,0BAAwB,IACnD,EACA,eAAgB,CACd,gBAAiB,KACjB,MAAO,IACT,CACF,GAEF,OAAQ,CACN,oBAAqB,CACnB,OAAQ,CACN,GAAI,sBACJ,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KAC5C,QACEA,EAAQ,eAAe,OACrB,IAAI,iBAAe,yBAAyB,CAChD,CACR,CAAC,CACH,CAEA,oBAAoBK,EAA0B,CAC5C,MAAO,CACL,YAAcJ,GAGZI,EAAY,YAAYJ,EAAE,KAAK,CACnC,CACF,CACF",
4
+ "sourcesContent": ["import { Left, Right } from \"purify-ts\";\nimport { assign, fromPromise, setup } from \"xstate\";\n\nimport {\n type CommandResult,\n isSuccessCommandResult,\n} from \"@api/command/model/CommandResult\";\nimport { type InternalApi } from \"@api/device-action/DeviceAction\";\nimport { UserInteractionRequired } from \"@api/device-action/model/UserInteractionRequired\";\nimport { UnknownDAError } from \"@api/device-action/os/Errors\";\nimport { OpenAppDeviceAction } from \"@api/device-action/os/OpenAppDeviceAction/OpenAppDeviceAction\";\nimport { type StateMachineTypes } from \"@api/device-action/xstate-utils/StateMachineTypes\";\nimport {\n type DeviceActionStateMachine,\n XStateDeviceAction,\n} from \"@api/device-action/xstate-utils/XStateDeviceAction\";\nimport { type Command } from \"@api/types\";\n\nimport {\n type SendCommandInAppDAError,\n type SendCommandInAppDAInput,\n type SendCommandInAppDAIntermediateValue,\n type SendCommandInAppDAInternalState,\n type SendCommandInAppDAOutput,\n} from \"./SendCommandInAppDeviceActionTypes\";\n\n/**\n * Tries to open an app on the device, and if it is successful, sends a command\n * to the app.\n * The output will be the result of the command.\n *\n * ```ts\n * input: {\n * appName: string;\n * command: Command<CommandResult, CommandArgs>;\n * requiredUserInteraction: UserInteraction;\n * }\n * ```\n *\n * Example of usage:\n *\n * ```ts\n * const deviceAction = new SendCommandInAppDeviceAction({\n * input: {\n * appName: \"MyApp\",\n * command: new MyAppSpecificCommand({commandSpecificArg: \"foo\"}),\n * requiredUserInteraction: UserInteractionRequired.None,\n * },\n * });\n * dmk.executeDeviceAction({ sessionId: \"mySessionId\", deviceAction });\n * ```\n */\nexport class SendCommandInAppDeviceAction<\n CommandResponse,\n CommandArgs,\n CommandErrorCodes,\n UserInteraction extends UserInteractionRequired,\n> extends XStateDeviceAction<\n SendCommandInAppDAOutput<CommandResponse>,\n SendCommandInAppDAInput<\n CommandResponse,\n CommandArgs,\n CommandErrorCodes,\n UserInteraction\n >,\n SendCommandInAppDAError<CommandErrorCodes>,\n SendCommandInAppDAIntermediateValue<UserInteraction>,\n SendCommandInAppDAInternalState<CommandResponse, CommandErrorCodes>\n> {\n makeStateMachine(\n internalAPI: InternalApi,\n ): DeviceActionStateMachine<\n SendCommandInAppDAOutput<CommandResponse>,\n SendCommandInAppDAInput<\n CommandResponse,\n CommandArgs,\n CommandErrorCodes,\n UserInteraction\n >,\n SendCommandInAppDAError<CommandErrorCodes>,\n SendCommandInAppDAIntermediateValue<UserInteraction>,\n SendCommandInAppDAInternalState<CommandResponse, CommandErrorCodes>\n > {\n type types = StateMachineTypes<\n SendCommandInAppDAOutput<CommandResponse>,\n SendCommandInAppDAInput<\n CommandResponse,\n CommandArgs,\n CommandErrorCodes,\n UserInteraction\n >,\n SendCommandInAppDAError<CommandErrorCodes>,\n SendCommandInAppDAIntermediateValue<UserInteraction>,\n SendCommandInAppDAInternalState<CommandResponse, CommandErrorCodes>\n >;\n\n const { sendCommand } = 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 sendCommand: fromPromise(sendCommand),\n openAppStateMachine: new OpenAppDeviceAction({\n input: {\n appName: this.input.appName,\n compatibleAppNames: this.input.compatibleAppNames,\n },\n }).makeStateMachine(internalAPI),\n },\n guards: {\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 /** @xstate-layout N4IgpgJg5mDOIC5QFEAuALA0mAngJwEsA7KAcTFQEEII85YARMANwIGMxK3UCB7IgHQB5AA5gilESKasOXHvwDEEfmAHFmvANZreYiVIDKqAIaowAWRNt0xMAG0ADAF1EoEb1gEFRNyAAeiACMQQDsAgAcACwAzKEArABMUfGpEQCcEYkANCA4iFGO8QKhjokxERUpQenp8QC+9bloWLiEJORUNHSwjCzsnNx8ggDC6GBsWqLiktL9ckP8AEpwAK4ANqiKTq5IIB5ePn6BCEFR4YkAbKE1Zemh55URufkI8fcC8TGXl0EVoelHJcio1mhhsPhiGQKNRaPQZAN5MMBGMJlN9LMEQsfCtYBstvYgrt3J5vMNjgUQgJLokHlEgldko50rEXoh3uEvj8-hEAUCQU0QC0Ie1oV04b0sYMfAJOrCerARrwALbKkxECDKVTqIiaHQCGDihVK1XqiA7PwHMn8CmnRJBASOFIxKJXJ21GLpHJ5RARGoCEL3CKXDLpS4pCKgoXgtpQuXdeHzaXI+MSxUqtUaxRgPB4Xh4AQidZmABm+eVBphCd6Jsz5pcltJRz2Jyiv0dvIeNJi8UqoWePoQIccn3iId+sSqkajRF4EDgfmFsY6VbTUqRNr2VuboBOAFpLmzTpd0iV+0EkkEylcAVEo0vISujYnZMn+MIMVJ14tfFum+SWwKb1XkSMdIhuQFEidYNSjvQUH1FVMFW-GVUUmaYDDmV8NyIXF8UbQ4AN3X0ogEF17S9eJQhiJ0ojbI8khHc54mvRwGUBXl7xjR8xXlF9ER-WVV2NDMzQI61f2IhBXUdRw5NDX54gvXkjx+CIzxuMdfnKd44LBVoeKQ-jsWRQxVjYDhenEncAmCcMBHKBlqKyIEYivGIjzDGJqQSYMamDa4BX0kU42E4y30EZBc3zayiNshBSmKFjqn7GCMgHV57lIz0aT9P0lL+S5GkaIA */\n id: \"SendCommandInAppDeviceAction\",\n initial: \"OpenAppDeviceAction\",\n context: ({ input }) => {\n return {\n input: input,\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.None,\n },\n _internalState: {\n commandResponse: null,\n error: null,\n },\n };\n },\n states: {\n OpenAppDeviceAction: {\n invoke: {\n id: \"openAppStateMachine\",\n input: {\n appName: this.input.appName,\n compatibleAppNames: this.input.compatibleAppNames,\n },\n src: \"openAppStateMachine\",\n onSnapshot: {\n actions: assign({\n intermediateValue: (_) =>\n _.event.snapshot.context.intermediateValue,\n }),\n },\n onDone: {\n actions: assign({\n _internalState: (_) => {\n return _.event.output.caseOf<\n SendCommandInAppDAInternalState<\n CommandResponse,\n CommandErrorCodes\n >\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: \"SendCommand\",\n guard: \"noInternalError\",\n },\n \"Error\",\n ],\n },\n SendCommand: {\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: \"sendCommand\",\n src: \"sendCommand\",\n input: ({ context }) => context.input.command,\n onDone: {\n target: \"SendCommandResultCheck\",\n actions: [\n assign({\n _internalState: ({ event, context }) => {\n if (isSuccessCommandResult(event.output)) {\n return {\n ...context._internalState,\n commandResponse: 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 SendCommandResultCheck: {\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.commandResponse\n ? Right(context._internalState.commandResponse)\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 sendCommand: (_: {\n input: Command<CommandResponse, CommandArgs, CommandErrorCodes>;\n }): Promise<CommandResult<CommandResponse, CommandErrorCodes>> =>\n internalApi.sendCommand(_.input),\n };\n }\n}\n"],
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SendCommandInAppDeviceAction_exports", "__export", "SendCommandInAppDeviceAction", "__toCommonJS", "import_purify_ts", "import_xstate", "import_CommandResult", "import_UserInteractionRequired", "import_Errors", "import_OpenAppDeviceAction", "import_XStateDeviceAction", "internalAPI", "sendCommand", "context", "_", "input", "error", "event", "internalApi"]
7
7
  }
@@ -1,2 +1,2 @@
1
- "use strict";var m=Object.defineProperty;var d=Object.getOwnPropertyDescriptor;var a=Object.getOwnPropertyNames;var t=Object.prototype.hasOwnProperty;var s=(r,e,p,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of a(e))!t.call(r,o)&&o!==p&&m(r,o,{get:()=>e[o],enumerable:!(n=d(e,o))||n.enumerable});return r};var C=r=>s(m({},"__esModule",{value:!0}),r);var A={};module.exports=C(A);
1
+ "use strict";var m=Object.defineProperty;var a=Object.getOwnPropertyDescriptor;var d=Object.getOwnPropertyNames;var t=Object.prototype.hasOwnProperty;var s=(r,e,p,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of d(e))!t.call(r,o)&&o!==p&&m(r,o,{get:()=>e[o],enumerable:!(n=a(e,o))||n.enumerable});return r};var C=r=>s(m({},"__esModule",{value:!0}),r);var A={};module.exports=C(A);
2
2
  //# sourceMappingURL=SendCommandInAppDeviceActionTypes.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../../../../src/api/device-action/os/SendCommandInAppDeviceAction/SendCommandInAppDeviceActionTypes.ts"],
4
- "sourcesContent": ["import { type CommandErrorResult } from \"@api/command/model/CommandResult\";\nimport {\n type OpenAppDAError,\n type OpenAppDAIntermediateValue,\n} from \"@api/device-action/os/OpenAppDeviceAction/types\";\nimport { type Command } from \"@api/types\";\n\nexport type SendCommandInAppDAOutput<CommandResponse> = CommandResponse;\n\nexport type SendCommandInAppDAInput<\n CommandResponse,\n CommandArgs,\n CommandErrorCodes,\n UserInteraction,\n> = {\n readonly command: Command<CommandResponse, CommandArgs, CommandErrorCodes>;\n readonly appName: string;\n readonly requiredUserInteraction: UserInteraction;\n};\n\nexport type SendCommandInAppDAError<CommandErrorCodes = void> =\n | OpenAppDAError\n | CommandErrorResult<CommandErrorCodes>[\"error\"];\n\nexport type SendCommandInAppDAIntermediateValue<UserInteraction> =\n | { readonly requiredUserInteraction: UserInteraction }\n | OpenAppDAIntermediateValue;\n\nexport type SendCommandInAppDAInternalState<\n CommandResponse,\n CommandErrorCodes,\n> = {\n readonly commandResponse: CommandResponse | null;\n readonly error: SendCommandInAppDAError<CommandErrorCodes> | null;\n};\n"],
4
+ "sourcesContent": ["import { type CommandErrorResult } from \"@api/command/model/CommandResult\";\nimport {\n type OpenAppDAError,\n type OpenAppDAIntermediateValue,\n} from \"@api/device-action/os/OpenAppDeviceAction/types\";\nimport { type Command } from \"@api/types\";\n\nexport type SendCommandInAppDAOutput<CommandResponse> = CommandResponse;\n\nexport type SendCommandInAppDAInput<\n CommandResponse,\n CommandArgs,\n CommandErrorCodes,\n UserInteraction,\n> = {\n readonly command: Command<CommandResponse, CommandArgs, CommandErrorCodes>;\n readonly appName: string;\n readonly requiredUserInteraction: UserInteraction;\n readonly compatibleAppNames?: string[];\n};\n\nexport type SendCommandInAppDAError<CommandErrorCodes = void> =\n | OpenAppDAError\n | CommandErrorResult<CommandErrorCodes>[\"error\"];\n\nexport type SendCommandInAppDAIntermediateValue<UserInteraction> =\n | { readonly requiredUserInteraction: UserInteraction }\n | OpenAppDAIntermediateValue;\n\nexport type SendCommandInAppDAInternalState<\n CommandResponse,\n CommandErrorCodes,\n> = {\n readonly commandResponse: CommandResponse | null;\n readonly error: SendCommandInAppDAError<CommandErrorCodes> | null;\n};\n"],
5
5
  "mappings": "+WAAA,IAAAA,EAAA,kBAAAC,EAAAD",
6
6
  "names": ["SendCommandInAppDeviceActionTypes_exports", "__toCommonJS"]
7
7
  }
@@ -1,2 +1,2 @@
1
- "use strict";var o=Object.defineProperty;var i=Object.getOwnPropertyDescriptor;var y=Object.getOwnPropertyNames;var p=Object.prototype.hasOwnProperty;var d=(a,e)=>{for(var r in e)o(a,r,{get:e[r],enumerable:!0})},S=(a,e,r,t)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of y(e))!p.call(a,n)&&n!==r&&o(a,n,{get:()=>e[n],enumerable:!(t=i(e,n))||t.enumerable});return a};var l=a=>S(o({},"__esModule",{value:!0}),a);var u={};d(u,{DeviceSessionStateType:()=>s});module.exports=l(u);var s=(t=>(t[t.Connected=0]="Connected",t[t.ReadyWithoutSecureChannel=1]="ReadyWithoutSecureChannel",t[t.ReadyWithSecureChannel=2]="ReadyWithSecureChannel",t))(s||{});0&&(module.exports={DeviceSessionStateType});
1
+ "use strict";var o=Object.defineProperty;var i=Object.getOwnPropertyDescriptor;var y=Object.getOwnPropertyNames;var p=Object.prototype.hasOwnProperty;var d=(a,e)=>{for(var r in e)o(a,r,{get:e[r],enumerable:!0})},l=(a,e,r,t)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of y(e))!p.call(a,n)&&n!==r&&o(a,n,{get:()=>e[n],enumerable:!(t=i(e,n))||t.enumerable});return a};var S=a=>l(o({},"__esModule",{value:!0}),a);var u={};d(u,{DeviceSessionStateType:()=>s});module.exports=S(u);var s=(t=>(t[t.Connected=0]="Connected",t[t.ReadyWithoutSecureChannel=1]="ReadyWithoutSecureChannel",t[t.ReadyWithSecureChannel=2]="ReadyWithSecureChannel",t))(s||{});0&&(module.exports={DeviceSessionStateType});
2
2
  //# sourceMappingURL=DeviceSessionState.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../../src/api/device-session/DeviceSessionState.ts"],
4
- "sourcesContent": ["import { type GetAppAndVersionResponse } from \"@api/command/os/GetAppAndVersionCommand\";\nimport { type BatteryStatusFlags } from \"@api/command/os/GetBatteryStatusCommand\";\nimport { type DeviceStatus } from \"@api/device/DeviceStatus\";\nimport { type Application } from \"@internal/manager-api/model/Application\";\n\n/**\n * The battery status of a device.\n */\nexport type BatteryStatus = {\n readonly level: number;\n readonly voltage: number;\n readonly temperature: number;\n readonly current: number;\n readonly status: BatteryStatusFlags;\n};\n\n/**\n * The firmware version of a device.\n */\nexport type FirmwareVersion = {\n /**\n * Microcontroller Unit version\n */\n readonly mcu: string;\n\n /**\n * Bootloader version\n */\n readonly bootloader: string;\n\n /**\n * Operating System version\n */\n readonly os: string;\n};\n\n/**\n * The current application running on a device. Alias of GetAppAndVersionResponse.\n */\nexport type RunningApp = GetAppAndVersionResponse;\n\n/**\n * The state types of a device session.\n */\nexport enum DeviceSessionStateType {\n Connected,\n ReadyWithoutSecureChannel,\n ReadyWithSecureChannel,\n}\n\ntype DeviceSessionBaseState = {\n readonly sessionStateType: DeviceSessionStateType;\n\n /**\n * The status of the device.\n */\n readonly deviceStatus: DeviceStatus;\n\n /**\n * The name of the device.\n */\n readonly deviceName?: string;\n};\n\ntype DeviceSessionReadyState = {\n /**\n * The battery status of the device.\n * TODO: This should not be optional, but it is not in the current implementation.\n */\n readonly batteryStatus?: BatteryStatus;\n\n /**\n * The firmware version of the device.\n * TODO: This should not be optional, but it is not in the current implementation.\n */\n readonly firmwareVersion?: FirmwareVersion;\n\n /**\n * The current application running on the device.\n */\n readonly currentApp: RunningApp;\n\n /**\n * The current applications installed on the device.\n */\n readonly installedApps: Application[];\n};\n\n/**\n * The state of a connected device session.\n */\nexport type ConnectedState = DeviceSessionBaseState & {\n /**\n * The type of the device session state.\n */\n readonly sessionStateType: DeviceSessionStateType.Connected;\n};\n\n/**\n * The state of a device session when it is ready without a secure channel.\n */\nexport type ReadyWithoutSecureChannelState = DeviceSessionBaseState &\n DeviceSessionReadyState & {\n /**\n * The type of the device session state.\n */\n readonly sessionStateType: DeviceSessionStateType.ReadyWithoutSecureChannel;\n };\n\n/**\n * The state of a device session when it is ready with a secure channel.\n */\nexport type ReadyWithSecureChannelState = DeviceSessionBaseState &\n DeviceSessionReadyState & {\n /**\n * The type of the device session state.\n */\n readonly sessionStateType: DeviceSessionStateType.ReadyWithSecureChannel;\n };\n\n/**\n * The state of a device session.\n */\nexport type DeviceSessionState =\n | ConnectedState\n | ReadyWithoutSecureChannelState\n | ReadyWithSecureChannelState;\n"],
5
- "mappings": "yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,4BAAAE,IAAA,eAAAC,EAAAH,GA4CO,IAAKE,OACVA,IAAA,yBACAA,IAAA,yDACAA,IAAA,mDAHUA,OAAA",
4
+ "sourcesContent": ["import { type GetAppAndVersionResponse } from \"@api/command/os/GetAppAndVersionCommand\";\nimport { type BatteryStatusFlags } from \"@api/command/os/GetBatteryStatusCommand\";\nimport { type DeviceModelId } from \"@api/device/DeviceModel\";\nimport { type DeviceStatus } from \"@api/device/DeviceStatus\";\nimport { type Application } from \"@internal/manager-api/model/Application\";\n\n/**\n * The battery status of a device.\n */\nexport type BatteryStatus = {\n readonly level: number;\n readonly voltage: number;\n readonly temperature: number;\n readonly current: number;\n readonly status: BatteryStatusFlags;\n};\n\n/**\n * The firmware version of a device.\n */\nexport type FirmwareVersion = {\n /**\n * Microcontroller Unit version\n */\n readonly mcu: string;\n\n /**\n * Bootloader version\n */\n readonly bootloader: string;\n\n /**\n * Operating System version\n */\n readonly os: string;\n};\n\n/**\n * The current application running on a device. Alias of GetAppAndVersionResponse.\n */\nexport type RunningApp = GetAppAndVersionResponse;\n\n/**\n * The state types of a device session.\n */\nexport enum DeviceSessionStateType {\n Connected,\n ReadyWithoutSecureChannel,\n ReadyWithSecureChannel,\n}\n\ntype DeviceSessionBaseState = {\n readonly sessionStateType: DeviceSessionStateType;\n\n /**\n * The status of the device.\n */\n readonly deviceStatus: DeviceStatus;\n\n /**\n * The model of the device.\n */\n readonly deviceModelId: DeviceModelId;\n\n /**\n * The name of the device.\n */\n readonly deviceName?: string;\n};\n\ntype DeviceSessionReadyState = {\n /**\n * The battery status of the device.\n * TODO: This should not be optional, but it is not in the current implementation.\n */\n readonly batteryStatus?: BatteryStatus;\n\n /**\n * The firmware version of the device.\n * TODO: This should not be optional, but it is not in the current implementation.\n */\n readonly firmwareVersion?: FirmwareVersion;\n\n /**\n * The current application running on the device.\n */\n readonly currentApp: RunningApp;\n\n /**\n * The current applications installed on the device.\n */\n readonly installedApps: Application[];\n};\n\n/**\n * The state of a connected device session.\n */\nexport type ConnectedState = DeviceSessionBaseState & {\n /**\n * The type of the device session state.\n */\n readonly sessionStateType: DeviceSessionStateType.Connected;\n};\n\n/**\n * The state of a device session when it is ready without a secure channel.\n */\nexport type ReadyWithoutSecureChannelState = DeviceSessionBaseState &\n DeviceSessionReadyState & {\n /**\n * The type of the device session state.\n */\n readonly sessionStateType: DeviceSessionStateType.ReadyWithoutSecureChannel;\n };\n\n/**\n * The state of a device session when it is ready with a secure channel.\n */\nexport type ReadyWithSecureChannelState = DeviceSessionBaseState &\n DeviceSessionReadyState & {\n /**\n * The type of the device session state.\n */\n readonly sessionStateType: DeviceSessionStateType.ReadyWithSecureChannel;\n };\n\n/**\n * The state of a device session.\n */\nexport type DeviceSessionState =\n | ConnectedState\n | ReadyWithoutSecureChannelState\n | ReadyWithSecureChannelState;\n"],
5
+ "mappings": "yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,4BAAAE,IAAA,eAAAC,EAAAH,GA6CO,IAAKE,OACVA,IAAA,yBACAA,IAAA,yDACAA,IAAA,mDAHUA,OAAA",
6
6
  "names": ["DeviceSessionState_exports", "__export", "DeviceSessionStateType", "__toCommonJS"]
7
7
  }
@@ -1,2 +1,2 @@
1
- "use strict";var n=require("../../../internal/device-session/model/DeviceSession.stub"),a=require("../../../internal/device-session/model/Errors"),l=require("../../../internal/device-session/service/DefaultDeviceSessionService"),f=require("../../../internal/logger-publisher/service/DefaultLoggerPublisherService"),S=require("../../../internal/manager-api/data/AxiosManagerApiDataSource"),p=require("../../../internal/manager-api/service/DefaultManagerApiService"),t=require("./ToggleDeviceSessionRefresher");let e,s,r,i,c;describe("ToggleDeviceSessionRefresherUseCase",()=>{beforeEach(()=>{e=new f.DefaultLoggerPublisherService([],"get-connected-device-use-case-test"),s=new l.DefaultDeviceSessionService(()=>e),c=new p.DefaultManagerApiService(new S.AxiosManagerApiDataSource({managerApiUrl:"http://fake.url",mockUrl:"http://fake-mock.url"}))}),afterEach(()=>{jest.clearAllMocks()}),describe("execute",()=>{it("should toggle the device session refresher",()=>{i=(0,n.deviceSessionStubBuilder)({id:"fakeSessionId"},()=>e,c),s.addDeviceSession(i),r=new t.ToggleDeviceSessionRefresherUseCase(s,()=>e);const o=jest.spyOn(i,"toggleRefresher");r.execute({sessionId:"fakeSessionId",enabled:!1}),expect(o).toHaveBeenCalledWith(!1),i.close()}),it("should throw error when deviceSession is not found",()=>{r=new t.ToggleDeviceSessionRefresherUseCase(s,()=>e);try{r.execute({sessionId:"fakeSessionId",enabled:!1})}catch(o){expect(o).toBeInstanceOf(a.DeviceSessionNotFound)}})})});
1
+ "use strict";var c=require("../../../internal/device-session/model/DeviceSession.stub"),a=require("../../../internal/device-session/model/Errors"),f=require("../../../internal/device-session/service/DefaultDeviceSessionService"),l=require("../../../internal/logger-publisher/service/DefaultLoggerPublisherService"),S=require("../../../internal/manager-api/data/AxiosManagerApiDataSource"),m=require("../../../internal/manager-api/service/DefaultManagerApiService"),t=require("./ToggleDeviceSessionRefresher");let e,s,i,o,n;describe("ToggleDeviceSessionRefresherUseCase",()=>{beforeEach(()=>{e=new l.DefaultLoggerPublisherService([],"get-connected-device-use-case-test"),s=new f.DefaultDeviceSessionService(()=>e),n=new m.DefaultManagerApiService(new S.AxiosManagerApiDataSource({}))}),afterEach(()=>{jest.clearAllMocks()}),describe("execute",()=>{it("should toggle the device session refresher",()=>{o=(0,c.deviceSessionStubBuilder)({id:"fakeSessionId"},()=>e,n),s.addDeviceSession(o),i=new t.ToggleDeviceSessionRefresherUseCase(s,()=>e);const r=jest.spyOn(o,"toggleRefresher");i.execute({sessionId:"fakeSessionId",enabled:!1}),expect(r).toHaveBeenCalledWith(!1),o.close()}),it("should throw error when deviceSession is not found",()=>{i=new t.ToggleDeviceSessionRefresherUseCase(s,()=>e);try{i.execute({sessionId:"fakeSessionId",enabled:!1})}catch(r){expect(r).toBeInstanceOf(a.DeviceSessionNotFound)}})})});
2
2
  //# sourceMappingURL=ToggleDeviceSessionRefresher.test.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../../../src/api/device-session/use-case/ToggleDeviceSessionRefresher.test.ts"],
4
- "sourcesContent": ["import { type LoggerPublisherService } from \"@api/logger-publisher/service/LoggerPublisherService\";\nimport { type DeviceSession } from \"@internal/device-session/model/DeviceSession\";\nimport { deviceSessionStubBuilder } from \"@internal/device-session/model/DeviceSession.stub\";\nimport { DeviceSessionNotFound } from \"@internal/device-session/model/Errors\";\nimport { DefaultDeviceSessionService } from \"@internal/device-session/service/DefaultDeviceSessionService\";\nimport { type DeviceSessionService } from \"@internal/device-session/service/DeviceSessionService\";\nimport { DefaultLoggerPublisherService } from \"@internal/logger-publisher/service/DefaultLoggerPublisherService\";\nimport { AxiosManagerApiDataSource } from \"@internal/manager-api/data/AxiosManagerApiDataSource\";\nimport { DefaultManagerApiService } from \"@internal/manager-api/service/DefaultManagerApiService\";\nimport { type ManagerApiService } from \"@internal/manager-api/service/ManagerApiService\";\n\nimport { ToggleDeviceSessionRefresherUseCase } from \"./ToggleDeviceSessionRefresher\";\n\nlet logger: LoggerPublisherService;\nlet sessionService: DeviceSessionService;\nlet useCase: ToggleDeviceSessionRefresherUseCase;\nlet deviceSession: DeviceSession;\nlet managerApi: ManagerApiService;\ndescribe(\"ToggleDeviceSessionRefresherUseCase\", () => {\n beforeEach(() => {\n logger = new DefaultLoggerPublisherService(\n [],\n \"get-connected-device-use-case-test\",\n );\n sessionService = new DefaultDeviceSessionService(() => logger);\n managerApi = new DefaultManagerApiService(\n new AxiosManagerApiDataSource({\n managerApiUrl: \"http://fake.url\",\n mockUrl: \"http://fake-mock.url\",\n }),\n );\n });\n\n afterEach(() => {\n jest.clearAllMocks();\n });\n\n describe(\"execute\", () => {\n it(\"should toggle the device session refresher\", () => {\n // given\n deviceSession = deviceSessionStubBuilder(\n { id: \"fakeSessionId\" },\n () => logger,\n managerApi,\n );\n sessionService.addDeviceSession(deviceSession);\n useCase = new ToggleDeviceSessionRefresherUseCase(\n sessionService,\n () => logger,\n );\n\n const spy = jest.spyOn(deviceSession, \"toggleRefresher\");\n\n // when\n useCase.execute({ sessionId: \"fakeSessionId\", enabled: false });\n\n // then\n expect(spy).toHaveBeenCalledWith(false);\n deviceSession.close();\n });\n\n it(\"should throw error when deviceSession is not found\", () => {\n // given\n useCase = new ToggleDeviceSessionRefresherUseCase(\n sessionService,\n () => logger,\n );\n\n // when\n try {\n useCase.execute({ sessionId: \"fakeSessionId\", enabled: false });\n } catch (error) {\n // then\n expect(error).toBeInstanceOf(DeviceSessionNotFound);\n }\n });\n });\n});\n"],
5
- "mappings": "aAEA,IAAAA,EAAyC,6DACzCC,EAAsC,iDACtCC,EAA4C,wEAE5CC,EAA8C,4EAC9CC,EAA0C,gEAC1CC,EAAyC,kEAGzCC,EAAoD,0CAEpD,IAAIC,EACAC,EACAC,EACAC,EACAC,EACJ,SAAS,sCAAuC,IAAM,CACpD,WAAW,IAAM,CACfJ,EAAS,IAAI,gCACX,CAAC,EACD,oCACF,EACAC,EAAiB,IAAI,8BAA4B,IAAMD,CAAM,EAC7DI,EAAa,IAAI,2BACf,IAAI,4BAA0B,CAC5B,cAAe,kBACf,QAAS,sBACX,CAAC,CACH,CACF,CAAC,EAED,UAAU,IAAM,CACd,KAAK,cAAc,CACrB,CAAC,EAED,SAAS,UAAW,IAAM,CACxB,GAAG,6CAA8C,IAAM,CAErDD,KAAgB,4BACd,CAAE,GAAI,eAAgB,EACtB,IAAMH,EACNI,CACF,EACAH,EAAe,iBAAiBE,CAAa,EAC7CD,EAAU,IAAI,sCACZD,EACA,IAAMD,CACR,EAEA,MAAMK,EAAM,KAAK,MAAMF,EAAe,iBAAiB,EAGvDD,EAAQ,QAAQ,CAAE,UAAW,gBAAiB,QAAS,EAAM,CAAC,EAG9D,OAAOG,CAAG,EAAE,qBAAqB,EAAK,EACtCF,EAAc,MAAM,CACtB,CAAC,EAED,GAAG,qDAAsD,IAAM,CAE7DD,EAAU,IAAI,sCACZD,EACA,IAAMD,CACR,EAGA,GAAI,CACFE,EAAQ,QAAQ,CAAE,UAAW,gBAAiB,QAAS,EAAM,CAAC,CAChE,OAASI,EAAO,CAEd,OAAOA,CAAK,EAAE,eAAe,uBAAqB,CACpD,CACF,CAAC,CACH,CAAC,CACH,CAAC",
4
+ "sourcesContent": ["import { type DmkConfig } from \"@api/DmkConfig\";\nimport { type LoggerPublisherService } from \"@api/logger-publisher/service/LoggerPublisherService\";\nimport { type DeviceSession } from \"@internal/device-session/model/DeviceSession\";\nimport { deviceSessionStubBuilder } from \"@internal/device-session/model/DeviceSession.stub\";\nimport { DeviceSessionNotFound } from \"@internal/device-session/model/Errors\";\nimport { DefaultDeviceSessionService } from \"@internal/device-session/service/DefaultDeviceSessionService\";\nimport { type DeviceSessionService } from \"@internal/device-session/service/DeviceSessionService\";\nimport { DefaultLoggerPublisherService } from \"@internal/logger-publisher/service/DefaultLoggerPublisherService\";\nimport { AxiosManagerApiDataSource } from \"@internal/manager-api/data/AxiosManagerApiDataSource\";\nimport { DefaultManagerApiService } from \"@internal/manager-api/service/DefaultManagerApiService\";\nimport { type ManagerApiService } from \"@internal/manager-api/service/ManagerApiService\";\n\nimport { ToggleDeviceSessionRefresherUseCase } from \"./ToggleDeviceSessionRefresher\";\n\nlet logger: LoggerPublisherService;\nlet sessionService: DeviceSessionService;\nlet useCase: ToggleDeviceSessionRefresherUseCase;\nlet deviceSession: DeviceSession;\nlet managerApi: ManagerApiService;\ndescribe(\"ToggleDeviceSessionRefresherUseCase\", () => {\n beforeEach(() => {\n logger = new DefaultLoggerPublisherService(\n [],\n \"get-connected-device-use-case-test\",\n );\n sessionService = new DefaultDeviceSessionService(() => logger);\n managerApi = new DefaultManagerApiService(\n new AxiosManagerApiDataSource({} as DmkConfig),\n );\n });\n\n afterEach(() => {\n jest.clearAllMocks();\n });\n\n describe(\"execute\", () => {\n it(\"should toggle the device session refresher\", () => {\n // given\n deviceSession = deviceSessionStubBuilder(\n { id: \"fakeSessionId\" },\n () => logger,\n managerApi,\n );\n sessionService.addDeviceSession(deviceSession);\n useCase = new ToggleDeviceSessionRefresherUseCase(\n sessionService,\n () => logger,\n );\n\n const spy = jest.spyOn(deviceSession, \"toggleRefresher\");\n\n // when\n useCase.execute({ sessionId: \"fakeSessionId\", enabled: false });\n\n // then\n expect(spy).toHaveBeenCalledWith(false);\n deviceSession.close();\n });\n\n it(\"should throw error when deviceSession is not found\", () => {\n // given\n useCase = new ToggleDeviceSessionRefresherUseCase(\n sessionService,\n () => logger,\n );\n\n // when\n try {\n useCase.execute({ sessionId: \"fakeSessionId\", enabled: false });\n } catch (error) {\n // then\n expect(error).toBeInstanceOf(DeviceSessionNotFound);\n }\n });\n });\n});\n"],
5
+ "mappings": "aAGA,IAAAA,EAAyC,6DACzCC,EAAsC,iDACtCC,EAA4C,wEAE5CC,EAA8C,4EAC9CC,EAA0C,gEAC1CC,EAAyC,kEAGzCC,EAAoD,0CAEpD,IAAIC,EACAC,EACAC,EACAC,EACAC,EACJ,SAAS,sCAAuC,IAAM,CACpD,WAAW,IAAM,CACfJ,EAAS,IAAI,gCACX,CAAC,EACD,oCACF,EACAC,EAAiB,IAAI,8BAA4B,IAAMD,CAAM,EAC7DI,EAAa,IAAI,2BACf,IAAI,4BAA0B,CAAC,CAAc,CAC/C,CACF,CAAC,EAED,UAAU,IAAM,CACd,KAAK,cAAc,CACrB,CAAC,EAED,SAAS,UAAW,IAAM,CACxB,GAAG,6CAA8C,IAAM,CAErDD,KAAgB,4BACd,CAAE,GAAI,eAAgB,EACtB,IAAMH,EACNI,CACF,EACAH,EAAe,iBAAiBE,CAAa,EAC7CD,EAAU,IAAI,sCACZD,EACA,IAAMD,CACR,EAEA,MAAMK,EAAM,KAAK,MAAMF,EAAe,iBAAiB,EAGvDD,EAAQ,QAAQ,CAAE,UAAW,gBAAiB,QAAS,EAAM,CAAC,EAG9D,OAAOG,CAAG,EAAE,qBAAqB,EAAK,EACtCF,EAAc,MAAM,CACtB,CAAC,EAED,GAAG,qDAAsD,IAAM,CAE7DD,EAAU,IAAI,sCACZD,EACA,IAAMD,CACR,EAGA,GAAI,CACFE,EAAQ,QAAQ,CAAE,UAAW,gBAAiB,QAAS,EAAM,CAAC,CAChE,OAASI,EAAO,CAEd,OAAOA,CAAK,EAAE,eAAe,uBAAqB,CACpD,CACF,CAAC,CACH,CAAC,CACH,CAAC",
6
6
  "names": ["import_DeviceSession", "import_Errors", "import_DefaultDeviceSessionService", "import_DefaultLoggerPublisherService", "import_AxiosManagerApiDataSource", "import_DefaultManagerApiService", "import_ToggleDeviceSessionRefresher", "logger", "sessionService", "useCase", "deviceSession", "managerApi", "spy", "error"]
7
7
  }
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../src/api/types.ts"],
4
- "sourcesContent": ["export type { OpenAppErrorCodes } from \"./command/os/OpenAppCommand\";\nexport type { CommandErrors } from \"./command/utils/CommandErrors\";\nexport type { DeviceId } from \"./device/DeviceModel\";\nexport type { ConnectionType } from \"./discovery/ConnectionType\";\nexport type { CommandErrorArgs } from \"./Error\";\nexport type { LogSubscriberOptions } from \"./logger-subscriber/model/LogSubscriberOptions\";\nexport type { DiscoveredDevice } from \"./transport/model/DiscoveredDevice\";\nexport type {\n Transport,\n TransportArgs,\n TransportFactory,\n} from \"./transport/model/Transport\";\nexport type { TransportIdentifier } from \"./transport/model/TransportIdentifier\";\nexport type { ApduBuilderArgs } from \"@api/apdu/utils/ApduBuilder\";\nexport type { Command } from \"@api/command/Command\";\nexport type {\n CommandErrorResult,\n CommandResult,\n} from \"@api/command/model/CommandResult\";\nexport type { SendCommandUseCaseArgs } from \"@api/command/use-case/SendCommandUseCase\";\nexport type { DeviceModelId } from \"@api/device/DeviceModel\";\nexport {\n type DeviceAction,\n type DeviceActionIntermediateValue,\n type ExecuteDeviceActionReturnType,\n} from \"@api/device-action/DeviceAction\";\nexport {\n type GetDeviceStatusDAError,\n type GetDeviceStatusDAInput,\n type GetDeviceStatusDAIntermediateValue,\n type GetDeviceStatusDAOutput,\n type GetDeviceStatusDAState,\n} from \"@api/device-action/os/GetDeviceStatus/types\";\nexport {\n type GoToDashboardDAError,\n type GoToDashboardDAInput,\n type GoToDashboardDAIntermediateValue,\n type GoToDashboardDAOutput,\n type GoToDashboardDAState,\n} from \"@api/device-action/os/GoToDashboard/types\";\nexport {\n type ListAppsDAError,\n type ListAppsDAInput,\n type ListAppsDAIntermediateValue,\n type ListAppsDAOutput,\n type ListAppsDAState,\n} from \"@api/device-action/os/ListApps/types\";\nexport {\n type ListAppsWithMetadataDAError,\n type ListAppsWithMetadataDAInput,\n type ListAppsWithMetadataDAIntermediateValue,\n type ListAppsWithMetadataDAOutput,\n type ListAppsWithMetadataDAState,\n} from \"@api/device-action/os/ListAppsWithMetadata/types\";\nexport {\n type OpenAppDAError,\n type OpenAppDAInput,\n type OpenAppDAIntermediateValue,\n type OpenAppDAOutput,\n type OpenAppDARequiredInteraction,\n type OpenAppDAState,\n} from \"@api/device-action/os/OpenAppDeviceAction/types\";\nexport {\n type SendCommandInAppDAError,\n type SendCommandInAppDAInput,\n type SendCommandInAppDAIntermediateValue,\n type SendCommandInAppDAOutput,\n} from \"@api/device-action/os/SendCommandInAppDeviceAction/SendCommandInAppDeviceActionTypes\";\nexport type { ExecuteDeviceActionUseCaseArgs } from \"@api/device-action/use-case/ExecuteDeviceActionUseCase\";\nexport { type StateMachineTypes } from \"@api/device-action/xstate-utils/StateMachineTypes\";\nexport { type DeviceModelDataSource } from \"@api/device-model/data/DeviceModelDataSource\";\nexport type { DeviceSessionState } from \"@api/device-session/DeviceSessionState\";\nexport { type ApduReceiverService } from \"@api/device-session/service/ApduReceiverService\";\nexport { type ApduReceiverServiceFactory } from \"@api/device-session/service/ApduReceiverService\";\nexport { type ApduSenderServiceFactory } from \"@api/device-session/service/ApduSenderService\";\nexport { type ApduSenderService } from \"@api/device-session/service/ApduSenderService\";\nexport type { DeviceSessionId } from \"@api/device-session/types\";\nexport type { DmkConfig } from \"@api/DmkConfig\";\nexport type { DmkError } from \"@api/Error\";\nexport type { LoggerPublisherService } from \"@api/logger-publisher/service/LoggerPublisherService\";\nexport type {\n LoggerSubscriberService,\n LogParams,\n} from \"@api/logger-subscriber/service/LoggerSubscriberService\";\nexport {\n type DeviceConnection,\n type DisconnectHandler,\n type SendApduFnType,\n} from \"@api/transport/model/DeviceConnection\";\nexport { type TransportDiscoveredDevice } from \"@api/transport/model/TransportDiscoveredDevice\";\nexport type { HexaString } from \"@api/utils/HexaString\";\nexport type { ConnectUseCaseArgs } from \"@internal/discovery/use-case/ConnectUseCase\";\nexport type { DisconnectUseCaseArgs } from \"@internal/discovery/use-case/DisconnectUseCase\";\nexport type { GetConnectedDeviceUseCaseArgs } from \"@internal/discovery/use-case/GetConnectedDeviceUseCase\";\nexport type { StartDiscoveringUseCaseArgs } from \"@internal/discovery/use-case/StartDiscoveringUseCase\";\nexport type { SendApduUseCaseArgs } from \"@internal/send/use-case/SendApduUseCase\";\n"],
4
+ "sourcesContent": ["export type { OpenAppErrorCodes } from \"./command/os/OpenAppCommand\";\nexport type { CommandErrors } from \"./command/utils/CommandErrors\";\nexport type { DeviceId } from \"./device/DeviceModel\";\nexport type { ConnectionType } from \"./discovery/ConnectionType\";\nexport type { CommandErrorArgs } from \"./Error\";\nexport type { LogSubscriberOptions } from \"./logger-subscriber/model/LogSubscriberOptions\";\nexport type { DiscoveredDevice } from \"./transport/model/DiscoveredDevice\";\nexport type {\n Transport,\n TransportArgs,\n TransportFactory,\n} from \"./transport/model/Transport\";\nexport type { TransportIdentifier } from \"./transport/model/TransportIdentifier\";\nexport type { ApduBuilderArgs } from \"@api/apdu/utils/ApduBuilder\";\nexport type { Command } from \"@api/command/Command\";\nexport type {\n CommandErrorResult,\n CommandResult,\n CommandSuccessResult,\n} from \"@api/command/model/CommandResult\";\nexport type { SendCommandUseCaseArgs } from \"@api/command/use-case/SendCommandUseCase\";\nexport type { DeviceModelId } from \"@api/device/DeviceModel\";\nexport {\n type DeviceAction,\n type DeviceActionIntermediateValue,\n type ExecuteDeviceActionReturnType,\n} from \"@api/device-action/DeviceAction\";\nexport {\n type GetDeviceStatusDAError,\n type GetDeviceStatusDAInput,\n type GetDeviceStatusDAIntermediateValue,\n type GetDeviceStatusDAOutput,\n type GetDeviceStatusDAState,\n} from \"@api/device-action/os/GetDeviceStatus/types\";\nexport {\n type GoToDashboardDAError,\n type GoToDashboardDAInput,\n type GoToDashboardDAIntermediateValue,\n type GoToDashboardDAOutput,\n type GoToDashboardDAState,\n} from \"@api/device-action/os/GoToDashboard/types\";\nexport {\n type ListAppsDAError,\n type ListAppsDAInput,\n type ListAppsDAIntermediateValue,\n type ListAppsDAOutput,\n type ListAppsDAState,\n} from \"@api/device-action/os/ListApps/types\";\nexport {\n type ListAppsWithMetadataDAError,\n type ListAppsWithMetadataDAInput,\n type ListAppsWithMetadataDAIntermediateValue,\n type ListAppsWithMetadataDAOutput,\n type ListAppsWithMetadataDAState,\n} from \"@api/device-action/os/ListAppsWithMetadata/types\";\nexport {\n type OpenAppDAError,\n type OpenAppDAInput,\n type OpenAppDAIntermediateValue,\n type OpenAppDAOutput,\n type OpenAppDARequiredInteraction,\n type OpenAppDAState,\n} from \"@api/device-action/os/OpenAppDeviceAction/types\";\nexport {\n type SendCommandInAppDAError,\n type SendCommandInAppDAInput,\n type SendCommandInAppDAIntermediateValue,\n type SendCommandInAppDAOutput,\n} from \"@api/device-action/os/SendCommandInAppDeviceAction/SendCommandInAppDeviceActionTypes\";\nexport type { ExecuteDeviceActionUseCaseArgs } from \"@api/device-action/use-case/ExecuteDeviceActionUseCase\";\nexport { type StateMachineTypes } from \"@api/device-action/xstate-utils/StateMachineTypes\";\nexport { type DeviceModelDataSource } from \"@api/device-model/data/DeviceModelDataSource\";\nexport type { DeviceSessionState } from \"@api/device-session/DeviceSessionState\";\nexport { type ApduReceiverService } from \"@api/device-session/service/ApduReceiverService\";\nexport { type ApduReceiverServiceFactory } from \"@api/device-session/service/ApduReceiverService\";\nexport { type ApduSenderServiceFactory } from \"@api/device-session/service/ApduSenderService\";\nexport { type ApduSenderService } from \"@api/device-session/service/ApduSenderService\";\nexport type { DeviceSessionId } from \"@api/device-session/types\";\nexport type { DmkConfig } from \"@api/DmkConfig\";\nexport type { DmkError } from \"@api/Error\";\nexport type { LoggerPublisherService } from \"@api/logger-publisher/service/LoggerPublisherService\";\nexport type {\n LoggerSubscriberService,\n LogParams,\n} from \"@api/logger-subscriber/service/LoggerSubscriberService\";\nexport {\n type DeviceConnection,\n type DisconnectHandler,\n type SendApduFnType,\n} from \"@api/transport/model/DeviceConnection\";\nexport { type TransportDiscoveredDevice } from \"@api/transport/model/TransportDiscoveredDevice\";\nexport type { HexaString } from \"@api/utils/HexaString\";\nexport type { ConnectUseCaseArgs } from \"@internal/discovery/use-case/ConnectUseCase\";\nexport type { DisconnectUseCaseArgs } from \"@internal/discovery/use-case/DisconnectUseCase\";\nexport type { GetConnectedDeviceUseCaseArgs } from \"@internal/discovery/use-case/GetConnectedDeviceUseCase\";\nexport type { StartDiscoveringUseCaseArgs } from \"@internal/discovery/use-case/StartDiscoveringUseCase\";\nexport type { SendApduUseCaseArgs } from \"@internal/send/use-case/SendApduUseCase\";\n"],
5
5
  "mappings": "+WAAA,IAAAA,EAAA,kBAAAC,EAAAD",
6
6
  "names": ["types_exports", "__toCommonJS"]
7
7
  }
package/lib/cjs/src/di.js CHANGED
@@ -1,2 +1,2 @@
1
- "use strict";var a=Object.defineProperty;var A=Object.getOwnPropertyDescriptor;var S=Object.getOwnPropertyNames;var _=Object.prototype.hasOwnProperty;var u=(o,r)=>{for(var t in r)a(o,t,{get:r[t],enumerable:!0})},C=(o,r,t,m)=>{if(r&&typeof r=="object"||typeof r=="function")for(let e of S(r))!_.call(o,e)&&e!==t&&a(o,e,{get:()=>r[e],enumerable:!(m=A(r,e))||m.enumerable});return o};var E=o=>C(a({},"__esModule",{value:!0}),o);var v={};u(v,{makeContainer:()=>k});module.exports=E(v);var p=require("inversify"),c=require("./api/command/di/commandModule"),n=require("./api/device-action/di/deviceActionModule"),f=require("./internal/config/di/configModule"),l=require("./internal/device-model/di/deviceModelModule"),d=require("./internal/device-session/di/deviceSessionModule"),y=require("./internal/discovery/di/discoveryModule"),M=require("./internal/logger-publisher/di/loggerModule"),F=require("./internal/manager-api/di/managerApiModule"),i=require("./internal/manager-api/model/Const"),g=require("./internal/send/di/sendModule"),s=require("./internal/transport/di/transportModule");const k=({stub:o=!1,transports:r=[],loggers:t=[],config:m={managerApiUrl:i.DEFAULT_MANAGER_API_BASE_URL,mockUrl:i.DEFAULT_MOCK_SERVER_BASE_URL}})=>{const e=new p.Container;return e.load((0,f.configModuleFactory)({stub:o}),(0,l.deviceModelModuleFactory)({stub:o}),(0,s.transportModuleFactory)({stub:o,transports:r,config:m}),(0,F.managerApiModuleFactory)({stub:o,config:m}),(0,y.discoveryModuleFactory)({stub:o}),(0,M.loggerModuleFactory)({subscribers:t}),(0,d.deviceSessionModuleFactory)({stub:o}),(0,g.sendModuleFactory)({stub:o}),(0,c.commandModuleFactory)({stub:o}),(0,n.deviceActionModuleFactory)({stub:o})),e};0&&(module.exports={makeContainer});
1
+ "use strict";var a=Object.defineProperty;var A=Object.getOwnPropertyDescriptor;var _=Object.getOwnPropertyNames;var E=Object.prototype.hasOwnProperty;var S=(o,r)=>{for(var t in r)a(o,t,{get:r[t],enumerable:!0})},U=(o,r,t,i)=>{if(r&&typeof r=="object"||typeof r=="function")for(let e of _(r))!E.call(o,e)&&e!==t&&a(o,e,{get:()=>r[e],enumerable:!(i=A(r,e))||i.enumerable});return o};var C=o=>U(a({},"__esModule",{value:!0}),o);var k={};S(k,{makeContainer:()=>L});module.exports=C(k);var c=require("inversify"),p=require("./api/command/di/commandModule"),n=require("./api/device-action/di/deviceActionModule"),l=require("./internal/config/di/configModule"),f=require("./internal/device-model/di/deviceModelModule"),d=require("./internal/device-session/di/deviceSessionModule"),y=require("./internal/discovery/di/discoveryModule"),F=require("./internal/logger-publisher/di/loggerModule"),M=require("./internal/manager-api/di/managerApiModule"),m=require("./internal/manager-api/model/Const"),g=require("./internal/send/di/sendModule"),s=require("./internal/transport/di/transportModule");const L=({stub:o=!1,transports:r=[],loggers:t=[],config:i={mockUrl:m.DEFAULT_MOCK_SERVER_BASE_URL,managerApiUrl:m.DEFAULT_MANAGER_API_BASE_URL,webSocketUrl:m.DEFAULT_WEB_SOCKET_BASE_URL}})=>{const e=new c.Container;return e.load((0,l.configModuleFactory)({stub:o}),(0,f.deviceModelModuleFactory)({stub:o}),(0,s.transportModuleFactory)({stub:o,transports:r,config:i}),(0,M.managerApiModuleFactory)({stub:o,config:i}),(0,y.discoveryModuleFactory)({stub:o}),(0,F.loggerModuleFactory)({subscribers:t}),(0,d.deviceSessionModuleFactory)({stub:o}),(0,g.sendModuleFactory)({stub:o}),(0,p.commandModuleFactory)({stub:o}),(0,n.deviceActionModuleFactory)({stub:o})),e};0&&(module.exports={makeContainer});
2
2
  //# sourceMappingURL=di.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../src/di.ts"],
4
- "sourcesContent": ["import { Container } from \"inversify\";\n\n// Uncomment this line to enable the logger middleware\n// import { makeLoggerMiddleware } from \"inversify-logger-middleware\";\nimport { commandModuleFactory } from \"@api/command/di/commandModule\";\nimport { deviceActionModuleFactory } from \"@api/device-action/di/deviceActionModule\";\nimport { type DmkConfig } from \"@api/DmkConfig\";\nimport { type LoggerSubscriberService } from \"@api/logger-subscriber/service/LoggerSubscriberService\";\nimport { type TransportFactory } from \"@api/transport/model/Transport\";\nimport { configModuleFactory } from \"@internal/config/di/configModule\";\nimport { deviceModelModuleFactory } from \"@internal/device-model/di/deviceModelModule\";\nimport { deviceSessionModuleFactory } from \"@internal/device-session/di/deviceSessionModule\";\nimport { discoveryModuleFactory } from \"@internal/discovery/di/discoveryModule\";\nimport { loggerModuleFactory } from \"@internal/logger-publisher/di/loggerModule\";\nimport { managerApiModuleFactory } from \"@internal/manager-api/di/managerApiModule\";\nimport {\n DEFAULT_MANAGER_API_BASE_URL,\n DEFAULT_MOCK_SERVER_BASE_URL,\n} from \"@internal/manager-api/model/Const\";\nimport { sendModuleFactory } from \"@internal/send/di/sendModule\";\nimport { transportModuleFactory } from \"@internal/transport//di/transportModule\";\n\n// Uncomment this line to enable the logger middleware\n// const logger = makeLoggerMiddleware();\n\nexport type MakeContainerProps = {\n stub: boolean;\n transports: TransportFactory[];\n loggers: LoggerSubscriberService[];\n config: DmkConfig;\n};\n\nexport const makeContainer = ({\n stub = false,\n transports = [],\n loggers = [],\n config = {\n managerApiUrl: DEFAULT_MANAGER_API_BASE_URL,\n mockUrl: DEFAULT_MOCK_SERVER_BASE_URL,\n },\n}: Partial<MakeContainerProps>) => {\n const container = new Container();\n\n // Uncomment this line to enable the logger middleware\n // container.applyMiddleware(logger);\n\n container.load(\n configModuleFactory({ stub }),\n deviceModelModuleFactory({ stub }),\n transportModuleFactory({ stub, transports, config }),\n managerApiModuleFactory({ stub, config }),\n discoveryModuleFactory({ stub }),\n loggerModuleFactory({ subscribers: loggers }),\n deviceSessionModuleFactory({ stub }),\n sendModuleFactory({ stub }),\n commandModuleFactory({ stub }),\n deviceActionModuleFactory({ stub }),\n // modules go here\n );\n\n return container;\n};\n"],
5
- "mappings": "yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,mBAAAE,IAAA,eAAAC,EAAAH,GAAA,IAAAI,EAA0B,qBAI1BC,EAAqC,yCACrCC,EAA0C,oDAI1CC,EAAoC,4CACpCC,EAAyC,uDACzCC,EAA2C,2DAC3CC,EAAuC,kDACvCC,EAAoC,sDACpCC,EAAwC,qDACxCC,EAGO,6CACPC,EAAkC,wCAClCC,EAAuC,mDAYhC,MAAMb,EAAgB,CAAC,CAC5B,KAAAc,EAAO,GACP,WAAAC,EAAa,CAAC,EACd,QAAAC,EAAU,CAAC,EACX,OAAAC,EAAS,CACP,cAAe,+BACf,QAAS,8BACX,CACF,IAAmC,CACjC,MAAMC,EAAY,IAAI,YAKtB,OAAAA,EAAU,QACR,uBAAoB,CAAE,KAAAJ,CAAK,CAAC,KAC5B,4BAAyB,CAAE,KAAAA,CAAK,CAAC,KACjC,0BAAuB,CAAE,KAAAA,EAAM,WAAAC,EAAY,OAAAE,CAAO,CAAC,KACnD,2BAAwB,CAAE,KAAAH,EAAM,OAAAG,CAAO,CAAC,KACxC,0BAAuB,CAAE,KAAAH,CAAK,CAAC,KAC/B,uBAAoB,CAAE,YAAaE,CAAQ,CAAC,KAC5C,8BAA2B,CAAE,KAAAF,CAAK,CAAC,KACnC,qBAAkB,CAAE,KAAAA,CAAK,CAAC,KAC1B,wBAAqB,CAAE,KAAAA,CAAK,CAAC,KAC7B,6BAA0B,CAAE,KAAAA,CAAK,CAAC,CAEpC,EAEOI,CACT",
4
+ "sourcesContent": ["import { Container } from \"inversify\";\n\n// Uncomment this line to enable the logger middleware\n// import { makeLoggerMiddleware } from \"inversify-logger-middleware\";\nimport { commandModuleFactory } from \"@api/command/di/commandModule\";\nimport { deviceActionModuleFactory } from \"@api/device-action/di/deviceActionModule\";\nimport { type DmkConfig } from \"@api/DmkConfig\";\nimport { type LoggerSubscriberService } from \"@api/logger-subscriber/service/LoggerSubscriberService\";\nimport { type TransportFactory } from \"@api/transport/model/Transport\";\nimport { configModuleFactory } from \"@internal/config/di/configModule\";\nimport { deviceModelModuleFactory } from \"@internal/device-model/di/deviceModelModule\";\nimport { deviceSessionModuleFactory } from \"@internal/device-session/di/deviceSessionModule\";\nimport { discoveryModuleFactory } from \"@internal/discovery/di/discoveryModule\";\nimport { loggerModuleFactory } from \"@internal/logger-publisher/di/loggerModule\";\nimport { managerApiModuleFactory } from \"@internal/manager-api/di/managerApiModule\";\nimport {\n DEFAULT_MANAGER_API_BASE_URL,\n DEFAULT_MOCK_SERVER_BASE_URL,\n DEFAULT_WEB_SOCKET_BASE_URL,\n} from \"@internal/manager-api/model/Const\";\nimport { sendModuleFactory } from \"@internal/send/di/sendModule\";\nimport { transportModuleFactory } from \"@internal/transport//di/transportModule\";\n\n// Uncomment this line to enable the logger middleware\n// const logger = makeLoggerMiddleware();\n\nexport type MakeContainerProps = {\n stub: boolean;\n transports: TransportFactory[];\n loggers: LoggerSubscriberService[];\n config: DmkConfig;\n};\n\nexport const makeContainer = ({\n stub = false,\n transports = [],\n loggers = [],\n config = {\n mockUrl: DEFAULT_MOCK_SERVER_BASE_URL,\n managerApiUrl: DEFAULT_MANAGER_API_BASE_URL,\n webSocketUrl: DEFAULT_WEB_SOCKET_BASE_URL,\n },\n}: Partial<MakeContainerProps>) => {\n const container = new Container();\n\n // Uncomment this line to enable the logger middleware\n // container.applyMiddleware(logger);\n\n container.load(\n configModuleFactory({ stub }),\n deviceModelModuleFactory({ stub }),\n transportModuleFactory({ stub, transports, config }),\n managerApiModuleFactory({ stub, config }),\n discoveryModuleFactory({ stub }),\n loggerModuleFactory({ subscribers: loggers }),\n deviceSessionModuleFactory({ stub }),\n sendModuleFactory({ stub }),\n commandModuleFactory({ stub }),\n deviceActionModuleFactory({ stub }),\n // modules go here\n );\n\n return container;\n};\n"],
5
+ "mappings": "yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,mBAAAE,IAAA,eAAAC,EAAAH,GAAA,IAAAI,EAA0B,qBAI1BC,EAAqC,yCACrCC,EAA0C,oDAI1CC,EAAoC,4CACpCC,EAAyC,uDACzCC,EAA2C,2DAC3CC,EAAuC,kDACvCC,EAAoC,sDACpCC,EAAwC,qDACxCC,EAIO,6CACPC,EAAkC,wCAClCC,EAAuC,mDAYhC,MAAMb,EAAgB,CAAC,CAC5B,KAAAc,EAAO,GACP,WAAAC,EAAa,CAAC,EACd,QAAAC,EAAU,CAAC,EACX,OAAAC,EAAS,CACP,QAAS,+BACT,cAAe,+BACf,aAAc,6BAChB,CACF,IAAmC,CACjC,MAAMC,EAAY,IAAI,YAKtB,OAAAA,EAAU,QACR,uBAAoB,CAAE,KAAAJ,CAAK,CAAC,KAC5B,4BAAyB,CAAE,KAAAA,CAAK,CAAC,KACjC,0BAAuB,CAAE,KAAAA,EAAM,WAAAC,EAAY,OAAAE,CAAO,CAAC,KACnD,2BAAwB,CAAE,KAAAH,EAAM,OAAAG,CAAO,CAAC,KACxC,0BAAuB,CAAE,KAAAH,CAAK,CAAC,KAC/B,uBAAoB,CAAE,YAAaE,CAAQ,CAAC,KAC5C,8BAA2B,CAAE,KAAAF,CAAK,CAAC,KACnC,qBAAkB,CAAE,KAAAA,CAAK,CAAC,KAC1B,wBAAqB,CAAE,KAAAA,CAAK,CAAC,KAC7B,6BAA0B,CAAE,KAAAA,CAAK,CAAC,CAEpC,EAEOI,CACT",
6
6
  "names": ["di_exports", "__export", "makeContainer", "__toCommonJS", "import_inversify", "import_commandModule", "import_deviceActionModule", "import_configModule", "import_deviceModelModule", "import_deviceSessionModule", "import_discoveryModule", "import_loggerModule", "import_managerApiModule", "import_Const", "import_sendModule", "import_transportModule", "stub", "transports", "loggers", "config", "container"]
7
7
  }