@ledgerhq/device-management-kit 0.0.0-develop-20250219001044 → 0.0.0-develop-20250227001103

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 (232) hide show
  1. package/lib/cjs/package.json +4 -3
  2. package/lib/cjs/src/api/DeviceManagementKit.js +1 -1
  3. package/lib/cjs/src/api/DeviceManagementKit.js.map +2 -2
  4. package/lib/cjs/src/api/command/os/GetOsVersionCommand.js +1 -1
  5. package/lib/cjs/src/api/command/os/GetOsVersionCommand.js.map +3 -3
  6. package/lib/cjs/src/api/command/os/SecureElementFlagsParser.js +2 -0
  7. package/lib/cjs/src/api/command/os/SecureElementFlagsParser.js.map +7 -0
  8. package/lib/cjs/src/api/command/os/SecureElementFlagsParser.test.js +2 -0
  9. package/lib/cjs/src/api/command/os/SecureElementFlagsParser.test.js.map +7 -0
  10. package/lib/cjs/src/api/command/os/__mocks__/GetOsVersionCommand.js +1 -1
  11. package/lib/cjs/src/api/command/os/__mocks__/GetOsVersionCommand.js.map +2 -2
  12. package/lib/cjs/src/api/device/SecureElementFlags.js +2 -0
  13. package/lib/cjs/src/api/device/SecureElementFlags.js.map +7 -0
  14. package/lib/cjs/src/api/device-action/DeviceAction.js +1 -1
  15. package/lib/cjs/src/api/device-action/DeviceAction.js.map +1 -1
  16. package/lib/cjs/src/api/device-action/__test-utils__/makeInternalApi.js +1 -1
  17. package/lib/cjs/src/api/device-action/__test-utils__/makeInternalApi.js.map +3 -3
  18. package/lib/cjs/src/api/device-action/os/GetDeviceStatus/GetDeviceStatusDeviceAction.test.js +1 -1
  19. package/lib/cjs/src/api/device-action/os/GetDeviceStatus/GetDeviceStatusDeviceAction.test.js.map +2 -2
  20. package/lib/cjs/src/api/device-action/os/GoToDashboard/GoToDashboardDeviceAction.test.js +1 -1
  21. package/lib/cjs/src/api/device-action/os/GoToDashboard/GoToDashboardDeviceAction.test.js.map +2 -2
  22. package/lib/cjs/src/api/device-action/os/ListAppsWithMetadata/ListAppsWithMetadataDeviceAction.js +1 -1
  23. package/lib/cjs/src/api/device-action/os/ListAppsWithMetadata/ListAppsWithMetadataDeviceAction.js.map +3 -3
  24. package/lib/cjs/src/api/device-action/os/ListAppsWithMetadata/ListAppsWithMetadataDeviceAction.test.js +1 -1
  25. package/lib/cjs/src/api/device-action/os/ListAppsWithMetadata/ListAppsWithMetadataDeviceAction.test.js.map +3 -3
  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 +2 -2
  28. package/lib/cjs/src/api/device-session/DeviceSessionState.js +1 -1
  29. package/lib/cjs/src/api/device-session/DeviceSessionState.js.map +1 -1
  30. package/lib/cjs/src/api/index.js +1 -1
  31. package/lib/cjs/src/api/index.js.map +3 -3
  32. package/lib/cjs/src/api/secure-channel/constants.js +2 -0
  33. package/lib/cjs/src/api/secure-channel/constants.js.map +7 -0
  34. package/lib/cjs/src/api/secure-channel/device-action/GenuineCheck/GenuineCheckDeviceAction.js +2 -0
  35. package/lib/cjs/src/api/secure-channel/device-action/GenuineCheck/GenuineCheckDeviceAction.js.map +7 -0
  36. package/lib/cjs/src/api/secure-channel/device-action/GenuineCheck/GenuineCheckDeviceAction.test.js +2 -0
  37. package/lib/cjs/src/api/secure-channel/device-action/GenuineCheck/GenuineCheckDeviceAction.test.js.map +7 -0
  38. package/lib/cjs/src/api/secure-channel/device-action/GenuineCheck/types.js +2 -0
  39. package/lib/cjs/src/api/secure-channel/device-action/GenuineCheck/types.js.map +7 -0
  40. package/lib/cjs/src/api/secure-channel/task/ConnectToSecureChannelTask.js +2 -0
  41. package/lib/cjs/src/api/secure-channel/task/ConnectToSecureChannelTask.js.map +7 -0
  42. package/lib/cjs/src/api/secure-channel/task/ConnectToSecureChannelTask.test.js +2 -0
  43. package/lib/cjs/src/api/secure-channel/task/ConnectToSecureChannelTask.test.js.map +7 -0
  44. package/lib/cjs/src/api/secure-channel/task/types.js +2 -0
  45. package/lib/cjs/src/api/secure-channel/task/types.js.map +7 -0
  46. package/lib/cjs/src/api/secure-channel/utils.js +2 -0
  47. package/lib/cjs/src/api/secure-channel/utils.js.map +7 -0
  48. package/lib/cjs/src/api/secure-channel/utils.test.js +2 -0
  49. package/lib/cjs/src/api/secure-channel/utils.test.js.map +7 -0
  50. package/lib/cjs/src/api/transport/model/DiscoveredDevice.js +1 -1
  51. package/lib/cjs/src/api/transport/model/DiscoveredDevice.js.map +1 -1
  52. package/lib/cjs/src/api/transport/model/Transport.js.map +1 -1
  53. package/lib/cjs/src/api/transport/model/TransportDiscoveredDevice.js +1 -1
  54. package/lib/cjs/src/api/transport/model/TransportDiscoveredDevice.js.map +1 -1
  55. package/lib/cjs/src/api/transport/model/__mocks__/TransportMock.js +1 -1
  56. package/lib/cjs/src/api/transport/model/__mocks__/TransportMock.js.map +2 -2
  57. package/lib/cjs/src/api/types.js +1 -1
  58. package/lib/cjs/src/api/types.js.map +1 -1
  59. package/lib/cjs/src/internal/device-session/model/DeviceSession.js +1 -1
  60. package/lib/cjs/src/internal/device-session/model/DeviceSession.js.map +3 -3
  61. package/lib/cjs/src/internal/device-session/model/DeviceSessionRefresher.js +1 -1
  62. package/lib/cjs/src/internal/device-session/model/DeviceSessionRefresher.js.map +2 -2
  63. package/lib/cjs/src/internal/discovery/di/discoveryModule.js +1 -1
  64. package/lib/cjs/src/internal/discovery/di/discoveryModule.js.map +3 -3
  65. package/lib/cjs/src/internal/discovery/di/discoveryModule.test.js +1 -1
  66. package/lib/cjs/src/internal/discovery/di/discoveryModule.test.js.map +3 -3
  67. package/lib/cjs/src/internal/discovery/di/discoveryTypes.js +1 -1
  68. package/lib/cjs/src/internal/discovery/di/discoveryTypes.js.map +2 -2
  69. package/lib/cjs/src/internal/discovery/use-case/ConnectUseCase.test.js +1 -1
  70. package/lib/cjs/src/internal/discovery/use-case/ConnectUseCase.test.js.map +2 -2
  71. package/lib/cjs/src/internal/discovery/use-case/ListenToAvailableDevicesUseCase.js +2 -0
  72. package/lib/cjs/src/internal/discovery/use-case/ListenToAvailableDevicesUseCase.js.map +7 -0
  73. package/lib/cjs/src/internal/discovery/use-case/ListenToAvailableDevicesUseCase.test.js +2 -0
  74. package/lib/cjs/src/internal/discovery/use-case/ListenToAvailableDevicesUseCase.test.js.map +7 -0
  75. package/lib/cjs/src/internal/secure-channel/data/DefaultSecureChannelDataSource.js +1 -1
  76. package/lib/cjs/src/internal/secure-channel/data/DefaultSecureChannelDataSource.js.map +2 -2
  77. package/lib/cjs/src/internal/secure-channel/data/SecureChannelDataSource.js.map +1 -1
  78. package/lib/cjs/src/internal/secure-channel/model/Errors.js +1 -1
  79. package/lib/cjs/src/internal/secure-channel/model/Errors.js.map +3 -3
  80. package/lib/cjs/src/internal/secure-channel/service/DefaultSecureChannelService.js +1 -1
  81. package/lib/cjs/src/internal/secure-channel/service/DefaultSecureChannelService.js.map +3 -3
  82. package/lib/cjs/src/internal/secure-channel/service/SecureChannelService.js.map +1 -1
  83. package/lib/esm/package.json +4 -3
  84. package/lib/esm/src/api/DeviceManagementKit.js +1 -1
  85. package/lib/esm/src/api/DeviceManagementKit.js.map +2 -2
  86. package/lib/esm/src/api/command/os/GetOsVersionCommand.js +1 -1
  87. package/lib/esm/src/api/command/os/GetOsVersionCommand.js.map +3 -3
  88. package/lib/esm/src/api/command/os/SecureElementFlagsParser.js +2 -0
  89. package/lib/esm/src/api/command/os/SecureElementFlagsParser.js.map +7 -0
  90. package/lib/esm/src/api/command/os/SecureElementFlagsParser.test.js +2 -0
  91. package/lib/esm/src/api/command/os/SecureElementFlagsParser.test.js.map +7 -0
  92. package/lib/esm/src/api/command/os/__mocks__/GetOsVersionCommand.js +1 -1
  93. package/lib/esm/src/api/command/os/__mocks__/GetOsVersionCommand.js.map +2 -2
  94. package/lib/esm/src/api/device/SecureElementFlags.js +1 -0
  95. package/lib/esm/src/api/device/SecureElementFlags.js.map +7 -0
  96. package/lib/esm/src/api/device-action/__test-utils__/makeInternalApi.js +1 -1
  97. package/lib/esm/src/api/device-action/__test-utils__/makeInternalApi.js.map +3 -3
  98. package/lib/esm/src/api/device-action/os/GetDeviceStatus/GetDeviceStatusDeviceAction.test.js +1 -1
  99. package/lib/esm/src/api/device-action/os/GetDeviceStatus/GetDeviceStatusDeviceAction.test.js.map +2 -2
  100. package/lib/esm/src/api/device-action/os/GoToDashboard/GoToDashboardDeviceAction.test.js +1 -1
  101. package/lib/esm/src/api/device-action/os/GoToDashboard/GoToDashboardDeviceAction.test.js.map +2 -2
  102. package/lib/esm/src/api/device-action/os/ListAppsWithMetadata/ListAppsWithMetadataDeviceAction.js +1 -1
  103. package/lib/esm/src/api/device-action/os/ListAppsWithMetadata/ListAppsWithMetadataDeviceAction.js.map +3 -3
  104. package/lib/esm/src/api/device-action/os/ListAppsWithMetadata/ListAppsWithMetadataDeviceAction.test.js +1 -1
  105. package/lib/esm/src/api/device-action/os/ListAppsWithMetadata/ListAppsWithMetadataDeviceAction.test.js.map +3 -3
  106. package/lib/esm/src/api/device-action/os/OpenAppDeviceAction/OpenAppDeviceAction.test.js +1 -1
  107. package/lib/esm/src/api/device-action/os/OpenAppDeviceAction/OpenAppDeviceAction.test.js.map +2 -2
  108. package/lib/esm/src/api/device-session/DeviceSessionState.js.map +1 -1
  109. package/lib/esm/src/api/index.js +1 -1
  110. package/lib/esm/src/api/index.js.map +3 -3
  111. package/lib/esm/src/api/secure-channel/constants.js +2 -0
  112. package/lib/esm/src/api/secure-channel/constants.js.map +7 -0
  113. package/lib/esm/src/api/secure-channel/device-action/GenuineCheck/GenuineCheckDeviceAction.js +2 -0
  114. package/lib/esm/src/api/secure-channel/device-action/GenuineCheck/GenuineCheckDeviceAction.js.map +7 -0
  115. package/lib/esm/src/api/secure-channel/device-action/GenuineCheck/GenuineCheckDeviceAction.test.js +2 -0
  116. package/lib/esm/src/api/secure-channel/device-action/GenuineCheck/GenuineCheckDeviceAction.test.js.map +7 -0
  117. package/lib/esm/src/api/secure-channel/device-action/GenuineCheck/types.js +1 -0
  118. package/lib/esm/src/api/secure-channel/device-action/GenuineCheck/types.js.map +7 -0
  119. package/lib/esm/src/api/secure-channel/task/ConnectToSecureChannelTask.js +2 -0
  120. package/lib/esm/src/api/secure-channel/task/ConnectToSecureChannelTask.js.map +7 -0
  121. package/lib/esm/src/api/secure-channel/task/ConnectToSecureChannelTask.test.js +2 -0
  122. package/lib/esm/src/api/secure-channel/task/ConnectToSecureChannelTask.test.js.map +7 -0
  123. package/lib/esm/src/api/secure-channel/task/types.js +2 -0
  124. package/lib/esm/src/api/secure-channel/task/types.js.map +7 -0
  125. package/lib/esm/src/api/secure-channel/utils.js +2 -0
  126. package/lib/esm/src/api/secure-channel/utils.js.map +7 -0
  127. package/lib/esm/src/api/secure-channel/utils.test.js +2 -0
  128. package/lib/esm/src/api/secure-channel/utils.test.js.map +7 -0
  129. package/lib/esm/src/api/transport/model/__mocks__/TransportMock.js +1 -1
  130. package/lib/esm/src/api/transport/model/__mocks__/TransportMock.js.map +2 -2
  131. package/lib/esm/src/internal/device-session/model/DeviceSession.js +1 -1
  132. package/lib/esm/src/internal/device-session/model/DeviceSession.js.map +3 -3
  133. package/lib/esm/src/internal/device-session/model/DeviceSessionRefresher.js +1 -1
  134. package/lib/esm/src/internal/device-session/model/DeviceSessionRefresher.js.map +2 -2
  135. package/lib/esm/src/internal/discovery/di/discoveryModule.js +1 -1
  136. package/lib/esm/src/internal/discovery/di/discoveryModule.js.map +3 -3
  137. package/lib/esm/src/internal/discovery/di/discoveryModule.test.js +1 -1
  138. package/lib/esm/src/internal/discovery/di/discoveryModule.test.js.map +3 -3
  139. package/lib/esm/src/internal/discovery/di/discoveryTypes.js +1 -1
  140. package/lib/esm/src/internal/discovery/di/discoveryTypes.js.map +2 -2
  141. package/lib/esm/src/internal/discovery/use-case/ConnectUseCase.test.js +1 -1
  142. package/lib/esm/src/internal/discovery/use-case/ConnectUseCase.test.js.map +2 -2
  143. package/lib/esm/src/internal/discovery/use-case/ListenToAvailableDevicesUseCase.js +2 -0
  144. package/lib/esm/src/internal/discovery/use-case/ListenToAvailableDevicesUseCase.js.map +7 -0
  145. package/lib/esm/src/internal/discovery/use-case/ListenToAvailableDevicesUseCase.test.js +2 -0
  146. package/lib/esm/src/internal/discovery/use-case/ListenToAvailableDevicesUseCase.test.js.map +7 -0
  147. package/lib/esm/src/internal/secure-channel/data/DefaultSecureChannelDataSource.js +1 -1
  148. package/lib/esm/src/internal/secure-channel/data/DefaultSecureChannelDataSource.js.map +2 -2
  149. package/lib/esm/src/internal/secure-channel/model/Errors.js +1 -1
  150. package/lib/esm/src/internal/secure-channel/model/Errors.js.map +3 -3
  151. package/lib/esm/src/internal/secure-channel/service/DefaultSecureChannelService.js +1 -1
  152. package/lib/esm/src/internal/secure-channel/service/DefaultSecureChannelService.js.map +3 -3
  153. package/lib/types/src/api/DeviceManagementKit.d.ts +1 -1
  154. package/lib/types/src/api/DeviceManagementKit.d.ts.map +1 -1
  155. package/lib/types/src/api/command/os/GetOsVersionCommand.d.ts +8 -2
  156. package/lib/types/src/api/command/os/GetOsVersionCommand.d.ts.map +1 -1
  157. package/lib/types/src/api/command/os/SecureElementFlagsParser.d.ts +43 -0
  158. package/lib/types/src/api/command/os/SecureElementFlagsParser.d.ts.map +1 -0
  159. package/lib/types/src/api/command/os/SecureElementFlagsParser.test.d.ts +2 -0
  160. package/lib/types/src/api/command/os/SecureElementFlagsParser.test.d.ts.map +1 -0
  161. package/lib/types/src/api/command/os/__mocks__/GetOsVersionCommand.d.ts.map +1 -1
  162. package/lib/types/src/api/device/SecureElementFlags.d.ts +41 -0
  163. package/lib/types/src/api/device/SecureElementFlags.d.ts.map +1 -0
  164. package/lib/types/src/api/device-action/DeviceAction.d.ts +1 -0
  165. package/lib/types/src/api/device-action/DeviceAction.d.ts.map +1 -1
  166. package/lib/types/src/api/device-action/__test-utils__/makeInternalApi.d.ts.map +1 -1
  167. package/lib/types/src/api/device-action/os/ListAppsWithMetadata/ListAppsWithMetadataDeviceAction.d.ts +1 -1
  168. package/lib/types/src/api/device-action/os/ListAppsWithMetadata/ListAppsWithMetadataDeviceAction.d.ts.map +1 -1
  169. package/lib/types/src/api/device-session/DeviceSessionState.d.ts +4 -0
  170. package/lib/types/src/api/device-session/DeviceSessionState.d.ts.map +1 -1
  171. package/lib/types/src/api/index.d.ts +1 -0
  172. package/lib/types/src/api/index.d.ts.map +1 -1
  173. package/lib/types/src/api/secure-channel/constants.d.ts +2 -0
  174. package/lib/types/src/api/secure-channel/constants.d.ts.map +1 -0
  175. package/lib/types/src/api/secure-channel/device-action/GenuineCheck/GenuineCheckDeviceAction.d.ts +8 -0
  176. package/lib/types/src/api/secure-channel/device-action/GenuineCheck/GenuineCheckDeviceAction.d.ts.map +1 -0
  177. package/lib/types/src/api/secure-channel/device-action/GenuineCheck/GenuineCheckDeviceAction.test.d.ts +1 -0
  178. package/lib/types/src/api/secure-channel/device-action/GenuineCheck/GenuineCheckDeviceAction.test.d.ts.map +1 -0
  179. package/lib/types/src/api/secure-channel/device-action/GenuineCheck/types.d.ts +50 -0
  180. package/lib/types/src/api/secure-channel/device-action/GenuineCheck/types.d.ts.map +1 -0
  181. package/lib/types/src/api/secure-channel/task/ConnectToSecureChannelTask.d.ts +23 -0
  182. package/lib/types/src/api/secure-channel/task/ConnectToSecureChannelTask.d.ts.map +1 -0
  183. package/lib/types/src/api/secure-channel/task/ConnectToSecureChannelTask.test.d.ts +2 -0
  184. package/lib/types/src/api/secure-channel/task/ConnectToSecureChannelTask.test.d.ts.map +1 -0
  185. package/lib/types/src/api/secure-channel/task/types.d.ts +105 -0
  186. package/lib/types/src/api/secure-channel/task/types.d.ts.map +1 -0
  187. package/lib/types/src/api/secure-channel/utils.d.ts +30 -0
  188. package/lib/types/src/api/secure-channel/utils.d.ts.map +1 -0
  189. package/lib/types/src/api/secure-channel/utils.test.d.ts +2 -0
  190. package/lib/types/src/api/secure-channel/utils.test.d.ts.map +1 -0
  191. package/lib/types/src/api/transport/model/DiscoveredDevice.d.ts +2 -0
  192. package/lib/types/src/api/transport/model/DiscoveredDevice.d.ts.map +1 -1
  193. package/lib/types/src/api/transport/model/Transport.d.ts +1 -1
  194. package/lib/types/src/api/transport/model/Transport.d.ts.map +1 -1
  195. package/lib/types/src/api/transport/model/TransportDiscoveredDevice.d.ts +2 -0
  196. package/lib/types/src/api/transport/model/TransportDiscoveredDevice.d.ts.map +1 -1
  197. package/lib/types/src/api/transport/model/__mocks__/TransportMock.d.ts +1 -1
  198. package/lib/types/src/api/transport/model/__mocks__/TransportMock.d.ts.map +1 -1
  199. package/lib/types/src/api/types.d.ts +1 -0
  200. package/lib/types/src/api/types.d.ts.map +1 -1
  201. package/lib/types/src/internal/device-session/model/DeviceSession.d.ts +1 -0
  202. package/lib/types/src/internal/device-session/model/DeviceSession.d.ts.map +1 -1
  203. package/lib/types/src/internal/device-session/model/DeviceSessionRefresher.d.ts.map +1 -1
  204. package/lib/types/src/internal/discovery/di/discoveryTypes.d.ts +1 -1
  205. package/lib/types/src/internal/discovery/di/discoveryTypes.d.ts.map +1 -1
  206. package/lib/types/src/internal/discovery/use-case/{ListenToKnownDevicesUseCase.d.ts → ListenToAvailableDevicesUseCase.d.ts} +2 -2
  207. package/lib/types/src/internal/discovery/use-case/ListenToAvailableDevicesUseCase.d.ts.map +1 -0
  208. package/lib/types/src/internal/discovery/use-case/ListenToAvailableDevicesUseCase.test.d.ts +2 -0
  209. package/lib/types/src/internal/discovery/use-case/ListenToAvailableDevicesUseCase.test.d.ts.map +1 -0
  210. package/lib/types/src/internal/secure-channel/data/DefaultSecureChannelDataSource.d.ts +3 -3
  211. package/lib/types/src/internal/secure-channel/data/DefaultSecureChannelDataSource.d.ts.map +1 -1
  212. package/lib/types/src/internal/secure-channel/data/SecureChannelDataSource.d.ts +13 -13
  213. package/lib/types/src/internal/secure-channel/data/SecureChannelDataSource.d.ts.map +1 -1
  214. package/lib/types/src/internal/secure-channel/model/Errors.d.ts +6 -0
  215. package/lib/types/src/internal/secure-channel/model/Errors.d.ts.map +1 -1
  216. package/lib/types/src/internal/secure-channel/service/DefaultSecureChannelService.d.ts +3 -3
  217. package/lib/types/src/internal/secure-channel/service/DefaultSecureChannelService.d.ts.map +1 -1
  218. package/lib/types/src/internal/secure-channel/service/SecureChannelService.d.ts +1 -0
  219. package/lib/types/src/internal/secure-channel/service/SecureChannelService.d.ts.map +1 -1
  220. package/lib/types/tsconfig.prod.tsbuildinfo +1 -1
  221. package/package.json +7 -6
  222. package/lib/cjs/src/internal/discovery/use-case/ListenToKnownDevicesUseCase.js +0 -2
  223. package/lib/cjs/src/internal/discovery/use-case/ListenToKnownDevicesUseCase.js.map +0 -7
  224. package/lib/cjs/src/internal/discovery/use-case/ListenToKnownDevicesUseCase.test.js +0 -2
  225. package/lib/cjs/src/internal/discovery/use-case/ListenToKnownDevicesUseCase.test.js.map +0 -7
  226. package/lib/esm/src/internal/discovery/use-case/ListenToKnownDevicesUseCase.js +0 -2
  227. package/lib/esm/src/internal/discovery/use-case/ListenToKnownDevicesUseCase.js.map +0 -7
  228. package/lib/esm/src/internal/discovery/use-case/ListenToKnownDevicesUseCase.test.js +0 -2
  229. package/lib/esm/src/internal/discovery/use-case/ListenToKnownDevicesUseCase.test.js.map +0 -7
  230. package/lib/types/src/internal/discovery/use-case/ListenToKnownDevicesUseCase.d.ts.map +0 -1
  231. package/lib/types/src/internal/discovery/use-case/ListenToKnownDevicesUseCase.test.d.ts +0 -2
  232. package/lib/types/src/internal/discovery/use-case/ListenToKnownDevicesUseCase.test.d.ts.map +0 -1
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../../../../src/api/secure-channel/task/ConnectToSecureChannelTask.test.ts"],
4
+ "sourcesContent": ["import WebSocket from \"isomorphic-ws\";\nimport { Right } from \"purify-ts\";\nimport { describe, it, vi } from \"vitest\";\n\nimport { type InternalApi } from \"@api/index\";\nimport {\n type SecureChannelEvent,\n SecureChannelEventType,\n} from \"@api/secure-channel/task/types\";\nimport { SecureChannelError } from \"@internal/secure-channel/model/Errors\";\n\nimport {\n ConnectToSecureChannelTask,\n type ConnectToSecureChannelTaskArgs,\n} from \"./ConnectToSecureChannelTask\";\n\nvi.mock(\"isomorphic-ws\", () => ({\n ...vi.importActual(\"isomorphic-ws\"),\n __esModule: true,\n default: class {\n onopen: (() => void) | null = null;\n onmessage: ((event: { data: string }) => void) | null = null;\n send = vi.fn();\n close = vi.fn();\n url: string;\n constructor(url: string) {\n this.url = url;\n }\n },\n}));\n\nconst TEST_DELAY = 5;\n\ndescribe(\"ConnectToSecureChannelTask\", () => {\n let mockWebSocket: WebSocket;\n let mockInternalApi: InternalApi;\n let taskArgs: ConnectToSecureChannelTaskArgs;\n let task: ConnectToSecureChannelTask;\n const sendApduFn = vi.fn();\n\n beforeEach(() => {\n // vi.useFakeTimers({ shouldAdvanceTime: true });\n\n mockWebSocket = new WebSocket(\"wss://test-host.com\");\n mockInternalApi = {\n sendApdu: sendApduFn,\n toggleRefresher: vi.fn(),\n } as unknown as InternalApi;\n taskArgs = { connection: Right(mockWebSocket) };\n task = new ConnectToSecureChannelTask(mockInternalApi, taskArgs);\n });\n\n afterEach(() => {\n vi.resetAllMocks();\n });\n\n it(\"should emit Opened event on WebSocket open\", async () => {\n const events: SecureChannelEvent[] = [];\n const obs = task.run();\n obs.subscribe((e) => events.push(e));\n\n expect(mockWebSocket.onopen).toBeDefined();\n mockWebSocket.onopen!({\n type: \"open\",\n target: {} as WebSocket,\n });\n\n await new Promise((resolve) => setTimeout(resolve, TEST_DELAY));\n\n expect(events).toStrictEqual([{ type: SecureChannelEventType.Opened }]);\n });\n\n it(\"should handle incoming EXCHANGE message including reequestng user permission\", async () => {\n sendApduFn.mockResolvedValue(\n Right({\n data: new Uint8Array([0x90, 0x00]),\n statusCode: new Uint8Array([0x90, 0x00]),\n }),\n );\n\n const sendSpy = vi.spyOn(mockWebSocket, \"send\");\n vi.spyOn(task, \"isSecureConnectionAllowed\").mockReturnValueOnce(false);\n\n const events: SecureChannelEvent[] = [];\n const obs = task.run();\n obs.subscribe({\n next: (event) => {\n events.push(event);\n },\n });\n\n expect(mockWebSocket.onmessage).toBeDefined();\n mockWebSocket.onmessage!({\n data: JSON.stringify({\n query: \"exchange\",\n nonce: 1,\n data: \"e051000000\",\n }),\n type: \"\",\n target: {} as WebSocket,\n });\n\n await new Promise((resolve) => setTimeout(resolve, TEST_DELAY));\n\n expect(sendSpy).toHaveBeenCalledExactlyOnceWith(\n JSON.stringify({\n nonce: 1,\n response: \"success\",\n data: \"9000\",\n }),\n );\n expect(events).toStrictEqual([\n {\n type: SecureChannelEventType.PreExchange,\n payload: {\n nonce: 1,\n apdu: new Uint8Array([0xe0, 0x51, 0x00, 0x00, 0x00]),\n },\n },\n {\n type: SecureChannelEventType.PermissionRequested,\n },\n {\n type: SecureChannelEventType.Exchange,\n payload: {\n nonce: 1,\n apdu: new Uint8Array([0xe0, 0x51, 0x00, 0x00, 0x00]),\n data: new Uint8Array([0x90, 0x00]),\n status: new Uint8Array([0x90, 0x00]),\n },\n },\n {\n type: SecureChannelEventType.PermissionGranted,\n },\n ]);\n });\n\n it(\"should handle incoming BULK message\", async () => {\n sendApduFn.mockResolvedValue(\n Right({\n data: new Uint8Array([0x90, 0x00]),\n statusCode: new Uint8Array([0x90, 0x00]),\n }),\n );\n const completeFn: () => void = vi.fn();\n const obs = task.run();\n const events: SecureChannelEvent[] = [];\n obs.subscribe({\n next: (event: SecureChannelEvent) => {\n events.push(event);\n },\n complete: () => completeFn(),\n });\n\n expect(mockWebSocket.onmessage).toBeDefined();\n mockWebSocket.onmessage!({\n data: JSON.stringify({\n query: \"bulk\",\n nonce: 1,\n data: [\"0000000100\", \"0000000200\", \"0000000300\"],\n }),\n type: \"\",\n target: {} as WebSocket,\n });\n\n await new Promise((resolve) => setTimeout(resolve, TEST_DELAY));\n\n expect(sendApduFn).toHaveBeenCalledTimes(3);\n expect(events).toStrictEqual([\n {\n type: SecureChannelEventType.Progress,\n payload: { progress: 0.33, index: 0, total: 3 },\n },\n {\n type: SecureChannelEventType.Progress,\n payload: { progress: 0.67, index: 1, total: 3 },\n },\n {\n type: SecureChannelEventType.Progress,\n payload: { progress: 1.0, index: 2, total: 3 },\n },\n ]);\n expect(completeFn).toHaveBeenCalledOnce();\n });\n\n it(\"should handle incoming SUCCESS message\", () => {\n const completeFn: () => void = vi.fn();\n const events: SecureChannelEvent[] = [];\n const observable = task.run();\n observable.subscribe({\n next: (event: SecureChannelEvent) => events.push(event),\n complete: () => completeFn(),\n });\n\n mockWebSocket.onmessage!({\n data: JSON.stringify({\n query: \"success\",\n nonce: 1,\n result: \"success result\",\n }),\n type: \"\",\n target: {} as WebSocket,\n });\n\n expect(events).toStrictEqual([\n { type: SecureChannelEventType.Result, payload: \"success result\" },\n ]);\n expect(completeFn).toHaveBeenCalledOnce();\n });\n\n it(\"should handle incoming WARNING message\", () => {\n const events: SecureChannelEvent[] = [];\n const observable = task.run();\n observable.subscribe({\n next: (event: SecureChannelEvent) => events.push(event),\n });\n\n expect(mockWebSocket.onmessage).toBeDefined();\n mockWebSocket.onmessage!({\n data: JSON.stringify({\n query: \"warning\",\n nonce: 1,\n data: \"warning message\",\n }),\n type: \"\",\n target: {} as WebSocket,\n });\n\n expect(events).toStrictEqual([\n {\n type: SecureChannelEventType.Warning,\n payload: { message: \"warning message\" },\n },\n ]);\n });\n\n it(\"should handle incoming ERROR message\", () => {\n const errorFn = vi.fn();\n const observable = task.run();\n observable.subscribe({\n error: (err) => {\n expect(err).toBeInstanceOf(SecureChannelError);\n errorFn(err);\n },\n });\n\n expect(mockWebSocket.onmessage).toBeDefined();\n mockWebSocket.onmessage!({\n data: JSON.stringify({\n query: \"error\",\n }),\n type: \"\",\n target: {} as WebSocket,\n });\n\n expect(errorFn).toHaveBeenCalled();\n });\n});\n"],
5
+ "mappings": "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",
6
+ "names": ["import_isomorphic_ws", "import_purify_ts", "import_vitest", "import_types", "import_Errors", "import_ConnectToSecureChannelTask", "url", "TEST_DELAY", "mockWebSocket", "mockInternalApi", "taskArgs", "task", "sendApduFn", "WebSocket", "events", "e", "resolve", "sendSpy", "event", "completeFn", "obs", "errorFn", "err"]
7
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";var o=Object.defineProperty;var c=Object.getOwnPropertyDescriptor;var u=Object.getOwnPropertyNames;var x=Object.prototype.hasOwnProperty;var P=(r,e)=>{for(var t in e)o(r,t,{get:e[t],enumerable:!0})},h=(r,e,t,d)=>{if(e&&typeof e=="object"||typeof e=="function")for(let s of u(e))!x.call(r,s)&&s!==t&&o(r,s,{get:()=>e[s],enumerable:!(d=c(e,s))||d.enumerable});return r};var A=r=>h(o({},"__esModule",{value:!0}),r);var R={};P(R,{InMessageQueryEnum:()=>l,OutMessageResponseEnum:()=>g,SecureChannelEventType:()=>y,SecureChannelOperationEnum:()=>i});module.exports=A(R);var i=(a=>(a.GenuineCheck="GenuineCheck",a.ListInstalledApps="ListInstalledApps",a.UpdateMcu="UpdateMcu",a.UpdateFirmware="UpdateFirmware",a.InstallApp="InstallApp",a.UninstallApp="UninstallApp",a))(i||{}),l=(p=>(p.EXCHANGE="exchange",p.BULK="bulk",p.ERROR="error",p.WARNING="warning",p.SUCCESS="success",p))(l||{}),g=(t=>(t.SUCCESS="success",t.ERROR="error",t))(g||{}),y=(n=>(n.Opened="opened",n.Closed="closed",n.PermissionRequested="permission-requested",n.PermissionGranted="permission-granted",n.PreExchange="pre-exchange",n.Exchange="exchange",n.Progress="progress",n.Warning="warning",n.Result="result",n))(y||{});0&&(module.exports={InMessageQueryEnum,OutMessageResponseEnum,SecureChannelEventType,SecureChannelOperationEnum});
2
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../../../../src/api/secure-channel/task/types.ts"],
4
+ "sourcesContent": ["export enum SecureChannelOperationEnum {\n GenuineCheck = \"GenuineCheck\",\n ListInstalledApps = \"ListInstalledApps\",\n UpdateMcu = \"UpdateMcu\",\n UpdateFirmware = \"UpdateFirmware\",\n InstallApp = \"InstallApp\",\n UninstallApp = \"UninstallApp\",\n}\n\n/**\n * The message that will be received from the server by the secure channel.\n */\nexport type InMessageType = {\n uuid: string;\n session: string;\n query: InMessageQueryEnum;\n nonce: number;\n data: string | Array<string>;\n result?: unknown;\n};\n\nexport enum InMessageQueryEnum {\n EXCHANGE = \"exchange\",\n BULK = \"bulk\",\n ERROR = \"error\",\n WARNING = \"warning\",\n SUCCESS = \"success\",\n}\n\n/**\n * The message that will be sent to the server by the secure channel.\n */\nexport type OutMessageType = {\n nonce: number;\n response: OutMessageResponseEnum;\n data: string;\n};\n\nexport enum OutMessageResponseEnum {\n SUCCESS = \"success\",\n ERROR = \"error\",\n}\n\n/**\n * The all event types that can be emitted to the client by the secure channel.\n *\n */\nexport enum SecureChannelEventType {\n Opened = \"opened\",\n Closed = \"closed\",\n PermissionRequested = \"permission-requested\",\n PermissionGranted = \"permission-granted\",\n PreExchange = \"pre-exchange\",\n Exchange = \"exchange\",\n Progress = \"progress\",\n Warning = \"warning\",\n Result = \"result\",\n}\n\n/**\n * The possible payload that will be sent to the client when a secure channel event occurs.\n */\nexport type SecureChannelEventPayload = {\n PreExchange: { nonce: number; apdu: Uint8Array };\n Exchange: {\n nonce: number;\n apdu: Uint8Array;\n data: Uint8Array;\n status: Uint8Array;\n };\n Progress: { progress: number; index: number; total: number };\n Warning: { message: string };\n Result: string | Record<string, unknown>;\n};\n\n/**\n * The event type that will be emitted to the client when a secure channel event occurs.\n */\nexport type SecureChannelEvent =\n | {\n type: SecureChannelEventType.Opened;\n }\n | {\n type: SecureChannelEventType.Closed;\n }\n | {\n type: SecureChannelEventType.PermissionRequested;\n }\n | {\n type: SecureChannelEventType.PermissionGranted;\n }\n | {\n type: SecureChannelEventType.PreExchange;\n payload: SecureChannelEventPayload[\"PreExchange\"];\n }\n | {\n type: SecureChannelEventType.Exchange;\n payload: SecureChannelEventPayload[\"Exchange\"];\n }\n | {\n type: SecureChannelEventType.Progress;\n payload: SecureChannelEventPayload[\"Progress\"];\n }\n | {\n type: SecureChannelEventType.Warning;\n payload: SecureChannelEventPayload[\"Warning\"];\n }\n | {\n type: SecureChannelEventType.Result;\n payload: SecureChannelEventPayload[\"Result\"];\n };\n"],
5
+ "mappings": "yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,wBAAAE,EAAA,2BAAAC,EAAA,2BAAAC,EAAA,+BAAAC,IAAA,eAAAC,EAAAN,GAAO,IAAKK,OACVA,EAAA,aAAe,eACfA,EAAA,kBAAoB,oBACpBA,EAAA,UAAY,YACZA,EAAA,eAAiB,iBACjBA,EAAA,WAAa,aACbA,EAAA,aAAe,eANLA,OAAA,IAqBAH,OACVA,EAAA,SAAW,WACXA,EAAA,KAAO,OACPA,EAAA,MAAQ,QACRA,EAAA,QAAU,UACVA,EAAA,QAAU,UALAA,OAAA,IAiBAC,OACVA,EAAA,QAAU,UACVA,EAAA,MAAQ,QAFEA,OAAA,IASAC,OACVA,EAAA,OAAS,SACTA,EAAA,OAAS,SACTA,EAAA,oBAAsB,uBACtBA,EAAA,kBAAoB,qBACpBA,EAAA,YAAc,eACdA,EAAA,SAAW,WACXA,EAAA,SAAW,WACXA,EAAA,QAAU,UACVA,EAAA,OAAS,SATCA,OAAA",
6
+ "names": ["types_exports", "__export", "InMessageQueryEnum", "OutMessageResponseEnum", "SecureChannelEventType", "SecureChannelOperationEnum", "__toCommonJS"]
7
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";var o=Object.defineProperty;var x=Object.getOwnPropertyDescriptor;var u=Object.getOwnPropertyNames;var E=Object.prototype.hasOwnProperty;var c=(e,n)=>{for(var i in n)o(e,i,{get:n[i],enumerable:!0})},f=(e,n,i,t)=>{if(n&&typeof n=="object"||typeof n=="function")for(let r of u(n))!E.call(e,r)&&r!==i&&o(e,r,{get:()=>n[r],enumerable:!(t=x(n,r))||t.enumerable});return e};var y=e=>f(o({},"__esModule",{value:!0}),e);var U={};c(U,{isDeviceGenuine:()=>p,isRefusedByUser:()=>m,willRequestPermission:()=>a});module.exports=y(U);var l=require("./constants");function a(e){return e[0]===224&&e[1]===81}function m(e){return e.length===2&&(e[0]===85&&e[1]===1||e[0]===105&&e[1]===133)}function p(e){return e===l.GENUINE_DEVICE_RESULT}0&&(module.exports={isDeviceGenuine,isRefusedByUser,willRequestPermission});
2
+ //# sourceMappingURL=utils.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../../../src/api/secure-channel/utils.ts"],
4
+ "sourcesContent": ["import { type SecureChannelEventPayload } from \"./task/types\";\nimport { GENUINE_DEVICE_RESULT } from \"./constants\";\n\n/**\n * Checks if the given APDU command will request permission.\n *\n * This method checks if the first byte of the APDU command is `0xe0` and the second byte is `0x51`.\n *\n * @param apdu - The APDU command as a Uint8Array.\n * @returns `true` if the APDU command will request permission, otherwise `false`.\n */\nexport function willRequestPermission(apdu: Uint8Array): boolean {\n return apdu[0] === 0xe0 && apdu[1] === 0x51;\n}\n\n/**\n * Checks if the user refused the permission on the device.\n *\n * The following status codes indicate a refusal:\n * - \"0x5501\": User refused the permission.\n * - \"0x6985\": Condition of use not satisfied.\n *\n * @param statusCode - The status code to check.\n * @returns `true` if the status code indicates a refusal, otherwise `false`.\n */\nexport function isRefusedByUser(statusCode: Uint8Array): boolean {\n return (\n statusCode.length === 2 &&\n ((statusCode[0] === 0x55 && statusCode[1] === 0x01) ||\n (statusCode[0] === 0x69 && statusCode[1] === 0x85))\n );\n}\n\n/**\n * Checks if the device is genuine.\n *\n * @param payload - The payload of the result secure channel event.\n * The payload has already been stringified, so that the type check is not necessary.\n * @returns `true` if the device is genuine, otherwise `false`.\n */\nexport function isDeviceGenuine(payload: SecureChannelEventPayload[\"Result\"]) {\n return payload === GENUINE_DEVICE_RESULT;\n}\n"],
5
+ "mappings": "yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,qBAAAE,EAAA,oBAAAC,EAAA,0BAAAC,IAAA,eAAAC,EAAAL,GACA,IAAAM,EAAsC,uBAU/B,SAASF,EAAsBG,EAA2B,CAC/D,OAAOA,EAAK,CAAC,IAAM,KAAQA,EAAK,CAAC,IAAM,EACzC,CAYO,SAASJ,EAAgBK,EAAiC,CAC/D,OACEA,EAAW,SAAW,IACpBA,EAAW,CAAC,IAAM,IAAQA,EAAW,CAAC,IAAM,GAC3CA,EAAW,CAAC,IAAM,KAAQA,EAAW,CAAC,IAAM,IAEnD,CASO,SAASN,EAAgBO,EAA8C,CAC5E,OAAOA,IAAY,uBACrB",
6
+ "names": ["utils_exports", "__export", "isDeviceGenuine", "isRefusedByUser", "willRequestPermission", "__toCommonJS", "import_constants", "apdu", "statusCode", "payload"]
7
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";var t=require("./utils");describe("willRequestPermission",()=>{it("should return true if the APDU is a permission request",()=>{const e=new Uint8Array([224,81,0,0,0]);expect((0,t.willRequestPermission)(e)).toBe(!0)}),it("should return false if the APDU is not a permission request",()=>{const e=new Uint8Array([224,82,0,0,0]);expect((0,t.willRequestPermission)(e)).toBe(!1)})});describe("isRefusedByUser",()=>{it("should return true if the status code indicates a refusal",()=>{[new Uint8Array([85,1]),new Uint8Array([105,133])].forEach(e=>{expect((0,t.isRefusedByUser)(e)).toBe(!0)})}),it("should return false if the status code does not indicate a refusal",()=>{const e=new Uint8Array([144,0]);expect((0,t.isRefusedByUser)(e)).toBe(!1)})});describe("isDeviceGenuine",()=>{it("should return true if the device is genuine",()=>{expect((0,t.isDeviceGenuine)("0000")).toBe(!0)}),it("should return false if the device is not genuine",()=>{expect((0,t.isDeviceGenuine)("not genuine")).toBe(!1)})});describe.todo("SecureElementFlags");
2
+ //# sourceMappingURL=utils.test.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../../../src/api/secure-channel/utils.test.ts"],
4
+ "sourcesContent": ["import {\n isDeviceGenuine,\n isRefusedByUser,\n willRequestPermission,\n} from \"./utils\";\n\ndescribe(\"willRequestPermission\", () => {\n it(\"should return true if the APDU is a permission request\", () => {\n const apdu = new Uint8Array([0xe0, 0x51, 0x00, 0x00, 0x00]);\n expect(willRequestPermission(apdu)).toBe(true);\n });\n it(\"should return false if the APDU is not a permission request\", () => {\n const apdu = new Uint8Array([0xe0, 0x52, 0x00, 0x00, 0x00]);\n expect(willRequestPermission(apdu)).toBe(false);\n });\n});\n\ndescribe(\"isRefusedByUser\", () => {\n it(\"should return true if the status code indicates a refusal\", () => {\n [new Uint8Array([0x55, 0x01]), new Uint8Array([0x69, 0x85])].forEach(\n (statusCode) => {\n expect(isRefusedByUser(statusCode)).toBe(true);\n },\n );\n });\n it(\"should return false if the status code does not indicate a refusal\", () => {\n const statusCode = new Uint8Array([0x90, 0x00]);\n expect(isRefusedByUser(statusCode)).toBe(false);\n });\n});\n\ndescribe(\"isDeviceGenuine\", () => {\n it(\"should return true if the device is genuine\", () => {\n const payload = \"0000\";\n expect(isDeviceGenuine(payload)).toBe(true);\n });\n it(\"should return false if the device is not genuine\", () => {\n const payload = \"not genuine\";\n expect(isDeviceGenuine(payload)).toBe(false);\n });\n});\n\ndescribe.todo(\"SecureElementFlags\");\n"],
5
+ "mappings": "aAAA,IAAAA,EAIO,mBAEP,SAAS,wBAAyB,IAAM,CACtC,GAAG,yDAA0D,IAAM,CACjE,MAAMC,EAAO,IAAI,WAAW,CAAC,IAAM,GAAM,EAAM,EAAM,CAAI,CAAC,EAC1D,UAAO,yBAAsBA,CAAI,CAAC,EAAE,KAAK,EAAI,CAC/C,CAAC,EACD,GAAG,8DAA+D,IAAM,CACtE,MAAMA,EAAO,IAAI,WAAW,CAAC,IAAM,GAAM,EAAM,EAAM,CAAI,CAAC,EAC1D,UAAO,yBAAsBA,CAAI,CAAC,EAAE,KAAK,EAAK,CAChD,CAAC,CACH,CAAC,EAED,SAAS,kBAAmB,IAAM,CAChC,GAAG,4DAA6D,IAAM,CACpE,CAAC,IAAI,WAAW,CAAC,GAAM,CAAI,CAAC,EAAG,IAAI,WAAW,CAAC,IAAM,GAAI,CAAC,CAAC,EAAE,QAC1DC,GAAe,CACd,UAAO,mBAAgBA,CAAU,CAAC,EAAE,KAAK,EAAI,CAC/C,CACF,CACF,CAAC,EACD,GAAG,qEAAsE,IAAM,CAC7E,MAAMA,EAAa,IAAI,WAAW,CAAC,IAAM,CAAI,CAAC,EAC9C,UAAO,mBAAgBA,CAAU,CAAC,EAAE,KAAK,EAAK,CAChD,CAAC,CACH,CAAC,EAED,SAAS,kBAAmB,IAAM,CAChC,GAAG,8CAA+C,IAAM,CAEtD,UAAO,mBADS,MACc,CAAC,EAAE,KAAK,EAAI,CAC5C,CAAC,EACD,GAAG,mDAAoD,IAAM,CAE3D,UAAO,mBADS,aACc,CAAC,EAAE,KAAK,EAAK,CAC7C,CAAC,CACH,CAAC,EAED,SAAS,KAAK,oBAAoB",
6
+ "names": ["import_utils", "apdu", "statusCode"]
7
+ }
@@ -1,2 +1,2 @@
1
- "use strict";var d=Object.defineProperty;var p=Object.getOwnPropertyDescriptor;var n=Object.getOwnPropertyNames;var c=Object.prototype.hasOwnProperty;var v=(r,e,t,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of n(e))!c.call(r,o)&&o!==t&&d(r,o,{get:()=>e[o],enumerable:!(i=p(e,o))||i.enumerable});return r};var y=r=>v(d({},"__esModule",{value:!0}),r);var a={};module.exports=y(a);
1
+ "use strict";var d=Object.defineProperty;var t=Object.getOwnPropertyDescriptor;var l=Object.getOwnPropertyNames;var p=Object.prototype.hasOwnProperty;var a=(r,e,n,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of l(e))!p.call(r,o)&&o!==n&&d(r,o,{get:()=>e[o],enumerable:!(i=t(e,o))||i.enumerable});return r};var y=r=>a(d({},"__esModule",{value:!0}),r);var c={};module.exports=y(c);
2
2
  //# sourceMappingURL=DiscoveredDevice.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../../../src/api/transport/model/DiscoveredDevice.ts"],
4
- "sourcesContent": ["import { type DeviceId, type DeviceModel } from \"@api/device/DeviceModel\";\nimport { type TransportIdentifier } from \"@api/transport/model/TransportIdentifier\";\n\n/**\n * A discovered device.\n */\nexport type DiscoveredDevice = {\n readonly id: DeviceId;\n readonly deviceModel: DeviceModel;\n readonly transport: TransportIdentifier;\n};\n"],
4
+ "sourcesContent": ["import { type DeviceId, type DeviceModel } from \"@api/device/DeviceModel\";\nimport { type TransportIdentifier } from \"@api/transport/model/TransportIdentifier\";\n\n/**\n * A discovered device.\n */\nexport type DiscoveredDevice = {\n readonly id: DeviceId;\n readonly deviceModel: DeviceModel;\n readonly transport: TransportIdentifier;\n readonly name?: string;\n readonly rssi?: number | null;\n};\n"],
5
5
  "mappings": "+WAAA,IAAAA,EAAA,kBAAAC,EAAAD",
6
6
  "names": ["DiscoveredDevice_exports", "__toCommonJS"]
7
7
  }
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../../../src/api/transport/model/Transport.ts"],
4
- "sourcesContent": ["import { type Either } from \"purify-ts\";\nimport { type Observable } from \"rxjs\";\n\nimport { type DeviceId } from \"@api/device/DeviceModel\";\nimport { type DeviceModelDataSource } from \"@api/device-model/data/DeviceModelDataSource\";\nimport { type ApduReceiverServiceFactory } from \"@api/device-session/service/ApduReceiverService\";\nimport { type ApduSenderServiceFactory } from \"@api/device-session/service/ApduSenderService\";\nimport { type DmkConfig } from \"@api/DmkConfig\";\nimport { type DmkError } from \"@api/Error\";\nimport { type LoggerPublisherService } from \"@api/logger-publisher/service/LoggerPublisherService\";\nimport { type ConnectError } from \"@api/transport/model/Errors\";\nimport { type TransportDiscoveredDevice } from \"@api/transport/model/TransportDiscoveredDevice\";\nimport { type TransportIdentifier } from \"@api/transport/model/TransportIdentifier\";\n\nimport { type TransportConnectedDevice } from \"./TransportConnectedDevice\";\n\nexport type DisconnectHandler = (deviceId: DeviceId) => void;\n\n/**\n * Transport interface\n */\nexport interface Transport {\n /**\n * Get the transport identifier, which is a string to uniquely identify that transport.\n */\n getIdentifier(): TransportIdentifier;\n\n isSupported(): boolean;\n\n startDiscovering(): Observable<TransportDiscoveredDevice>;\n\n stopDiscovering(): void;\n\n listenToKnownDevices(): Observable<TransportDiscoveredDevice[]>;\n\n /**\n * Enables communication with the device by connecting to it.\n *\n * @param params containing\n * - id: the device id from the DTO discovered device\n */\n connect(params: {\n deviceId: DeviceId;\n onDisconnect: DisconnectHandler;\n }): Promise<Either<ConnectError, TransportConnectedDevice>>;\n\n disconnect(params: {\n connectedDevice: TransportConnectedDevice;\n }): Promise<Either<DmkError, void>>;\n}\n\nexport type TransportArgs = {\n deviceModelDataSource: DeviceModelDataSource;\n loggerServiceFactory: (tag: string) => LoggerPublisherService;\n config: DmkConfig;\n apduSenderServiceFactory: ApduSenderServiceFactory;\n apduReceiverServiceFactory: ApduReceiverServiceFactory;\n};\n\nexport type TransportFactory = (args: TransportArgs) => Transport;\n"],
4
+ "sourcesContent": ["import { type Either } from \"purify-ts\";\nimport { type Observable } from \"rxjs\";\n\nimport { type DeviceId } from \"@api/device/DeviceModel\";\nimport { type DeviceModelDataSource } from \"@api/device-model/data/DeviceModelDataSource\";\nimport { type ApduReceiverServiceFactory } from \"@api/device-session/service/ApduReceiverService\";\nimport { type ApduSenderServiceFactory } from \"@api/device-session/service/ApduSenderService\";\nimport { type DmkConfig } from \"@api/DmkConfig\";\nimport { type DmkError } from \"@api/Error\";\nimport { type LoggerPublisherService } from \"@api/logger-publisher/service/LoggerPublisherService\";\nimport { type ConnectError } from \"@api/transport/model/Errors\";\nimport { type TransportDiscoveredDevice } from \"@api/transport/model/TransportDiscoveredDevice\";\nimport { type TransportIdentifier } from \"@api/transport/model/TransportIdentifier\";\n\nimport { type TransportConnectedDevice } from \"./TransportConnectedDevice\";\n\nexport type DisconnectHandler = (deviceId: DeviceId) => void;\n\n/**\n * Transport interface\n */\nexport interface Transport {\n /**\n * Get the transport identifier, which is a string to uniquely identify that transport.\n */\n getIdentifier(): TransportIdentifier;\n\n isSupported(): boolean;\n\n startDiscovering(): Observable<TransportDiscoveredDevice>;\n\n stopDiscovering(): void;\n\n listenToAvailableDevices(): Observable<TransportDiscoveredDevice[]>;\n\n /**\n * Enables communication with the device by connecting to it.\n *\n * @param params containing\n * - id: the device id from the DTO discovered device\n */\n connect(params: {\n deviceId: DeviceId;\n onDisconnect: DisconnectHandler;\n }): Promise<Either<ConnectError, TransportConnectedDevice>>;\n\n disconnect(params: {\n connectedDevice: TransportConnectedDevice;\n }): Promise<Either<DmkError, void>>;\n}\n\nexport type TransportArgs = {\n deviceModelDataSource: DeviceModelDataSource;\n loggerServiceFactory: (tag: string) => LoggerPublisherService;\n config: DmkConfig;\n apduSenderServiceFactory: ApduSenderServiceFactory;\n apduReceiverServiceFactory: ApduReceiverServiceFactory;\n};\n\nexport type TransportFactory = (args: TransportArgs) => Transport;\n"],
5
5
  "mappings": "+WAAA,IAAAA,EAAA,kBAAAC,EAAAD",
6
6
  "names": ["Transport_exports", "__toCommonJS"]
7
7
  }
@@ -1,2 +1,2 @@
1
- "use strict";var i=Object.defineProperty;var d=Object.getOwnPropertyDescriptor;var n=Object.getOwnPropertyNames;var c=Object.prototype.hasOwnProperty;var s=(r,e,p,t)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of n(e))!c.call(r,o)&&o!==p&&i(r,o,{get:()=>e[o],enumerable:!(t=d(e,o))||t.enumerable});return r};var v=r=>s(i({},"__esModule",{value:!0}),r);var a={};module.exports=v(a);
1
+ "use strict";var o=Object.defineProperty;var n=Object.getOwnPropertyDescriptor;var d=Object.getOwnPropertyNames;var s=Object.prototype.hasOwnProperty;var m=(r,e,p,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let t of d(e))!s.call(r,t)&&t!==p&&o(r,t,{get:()=>e[t],enumerable:!(i=n(e,t))||i.enumerable});return r};var a=r=>m(o({},"__esModule",{value:!0}),r);var c={};module.exports=a(c);
2
2
  //# sourceMappingURL=TransportDiscoveredDevice.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../../../src/api/transport/model/TransportDiscoveredDevice.ts"],
4
- "sourcesContent": ["import { type DeviceId } from \"@api/device/DeviceModel\";\nimport { type TransportDeviceModel } from \"@api/device-model/model/DeviceModel\";\nimport { type TransportIdentifier } from \"@api/transport/model/TransportIdentifier\";\n\n/**\n * A discovered / scanned (not yet connected to) device.\n */\nexport type TransportDiscoveredDevice = {\n // type: \"web-hid\", // \"node-hid\" in the future -> no need as we will only have 1 USB transport implementation running\n\n /**\n * Unique identifier for the device.\n * NB: This identifier is generated at runtime and is not persisted.\n * It cannot be used to identify a device across sessions.\n * There is in fact no way to identify a device across sessions, which is a\n * privacy feature of Ledger devices.\n */\n id: DeviceId;\n deviceModel: TransportDeviceModel;\n transport: TransportIdentifier;\n};\n"],
4
+ "sourcesContent": ["import { type DeviceId } from \"@api/device/DeviceModel\";\nimport { type TransportDeviceModel } from \"@api/device-model/model/DeviceModel\";\nimport { type TransportIdentifier } from \"@api/transport/model/TransportIdentifier\";\n\n/**\n * A discovered / scanned (not yet connected to) device.\n */\nexport type TransportDiscoveredDevice = {\n /**\n * Unique identifier for the device.\n * NB: This identifier is generated at runtime and is not persisted.\n * It cannot be used to identify a device across sessions.\n * There is in fact no way to identify a device across sessions, which is a\n * privacy feature of Ledger devices.\n */\n id: DeviceId;\n deviceModel: TransportDeviceModel;\n transport: TransportIdentifier;\n name?: string;\n rssi?: number | null;\n};\n"],
5
5
  "mappings": "+WAAA,IAAAA,EAAA,kBAAAC,EAAAD",
6
6
  "names": ["TransportDiscoveredDevice_exports", "__toCommonJS"]
7
7
  }
@@ -1,2 +1,2 @@
1
- "use strict";var r=Object.defineProperty;var s=Object.getOwnPropertyDescriptor;var c=Object.getOwnPropertyNames;var p=Object.prototype.hasOwnProperty;var v=(i,n)=>{for(var o in n)r(i,o,{get:n[o],enumerable:!0})},f=(i,n,o,e)=>{if(n&&typeof n=="object"||typeof n=="function")for(let t of c(n))!p.call(i,t)&&t!==o&&r(i,t,{get:()=>n[t],enumerable:!(e=s(n,t))||e.enumerable});return i};var a=i=>f(r({},"__esModule",{value:!0}),i);var T={};v(T,{TransportMock:()=>m});module.exports=a(T);class m{constructor(){}getIdentifier=vi.fn();isSupported=vi.fn();startDiscovering=vi.fn();stopDiscovering=vi.fn();listenToKnownDevices=vi.fn();connect=vi.fn();disconnect=vi.fn()}0&&(module.exports={TransportMock});
1
+ "use strict";var o=Object.defineProperty;var s=Object.getOwnPropertyDescriptor;var c=Object.getOwnPropertyNames;var v=Object.prototype.hasOwnProperty;var p=(n,i)=>{for(var e in i)o(n,e,{get:i[e],enumerable:!0})},f=(n,i,e,r)=>{if(i&&typeof i=="object"||typeof i=="function")for(let t of c(i))!v.call(n,t)&&t!==e&&o(n,t,{get:()=>i[t],enumerable:!(r=s(i,t))||r.enumerable});return n};var a=n=>f(o({},"__esModule",{value:!0}),n);var m={};p(m,{TransportMock:()=>l});module.exports=a(m);class l{constructor(){}getIdentifier=vi.fn();isSupported=vi.fn();startDiscovering=vi.fn();stopDiscovering=vi.fn();listenToAvailableDevices=vi.fn();connect=vi.fn();disconnect=vi.fn()}0&&(module.exports={TransportMock});
2
2
  //# sourceMappingURL=TransportMock.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../../../../src/api/transport/model/__mocks__/TransportMock.ts"],
4
- "sourcesContent": ["import { type Transport } from \"@api/transport/model/Transport\";\n\nexport class TransportMock implements Transport {\n constructor() {}\n getIdentifier = vi.fn();\n isSupported = vi.fn();\n startDiscovering = vi.fn();\n stopDiscovering = vi.fn();\n listenToKnownDevices = vi.fn();\n connect = vi.fn();\n disconnect = vi.fn();\n}\n"],
5
- "mappings": "yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,mBAAAE,IAAA,eAAAC,EAAAH,GAEO,MAAME,CAAmC,CAC9C,aAAc,CAAC,CACf,cAAgB,GAAG,GAAG,EACtB,YAAc,GAAG,GAAG,EACpB,iBAAmB,GAAG,GAAG,EACzB,gBAAkB,GAAG,GAAG,EACxB,qBAAuB,GAAG,GAAG,EAC7B,QAAU,GAAG,GAAG,EAChB,WAAa,GAAG,GAAG,CACrB",
4
+ "sourcesContent": ["import { type Transport } from \"@api/transport/model/Transport\";\n\nexport class TransportMock implements Transport {\n constructor() {}\n getIdentifier = vi.fn();\n isSupported = vi.fn();\n startDiscovering = vi.fn();\n stopDiscovering = vi.fn();\n listenToAvailableDevices = vi.fn();\n connect = vi.fn();\n disconnect = vi.fn();\n}\n"],
5
+ "mappings": "yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,mBAAAE,IAAA,eAAAC,EAAAH,GAEO,MAAME,CAAmC,CAC9C,aAAc,CAAC,CACf,cAAgB,GAAG,GAAG,EACtB,YAAc,GAAG,GAAG,EACpB,iBAAmB,GAAG,GAAG,EACzB,gBAAkB,GAAG,GAAG,EACxB,yBAA2B,GAAG,GAAG,EACjC,QAAU,GAAG,GAAG,EAChB,WAAa,GAAG,GAAG,CACrB",
6
6
  "names": ["TransportMock_exports", "__export", "TransportMock", "__toCommonJS"]
7
7
  }
@@ -1,2 +1,2 @@
1
- "use strict";var o=Object.defineProperty;var a=Object.getOwnPropertyDescriptor;var i=Object.getOwnPropertyNames;var n=Object.prototype.hasOwnProperty;var m=(t,e,s,p)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of i(e))!n.call(t,r)&&r!==s&&o(t,r,{get:()=>e[r],enumerable:!(p=a(e,r))||p.enumerable});return t};var c=t=>m(o({},"__esModule",{value:!0}),t);var d={};module.exports=c(d);
1
+ "use strict";var o=Object.defineProperty;var i=Object.getOwnPropertyDescriptor;var n=Object.getOwnPropertyNames;var a=Object.prototype.hasOwnProperty;var c=(t,e,s,p)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of n(e))!a.call(t,r)&&r!==s&&o(t,r,{get:()=>e[r],enumerable:!(p=i(e,r))||p.enumerable});return t};var m=t=>c(o({},"__esModule",{value:!0}),t);var d={};module.exports=m(d);
2
2
  //# sourceMappingURL=types.js.map
@@ -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 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"],
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 GenuineCheckDAError,\n type GenuineCheckDAInput,\n type GenuineCheckDAIntermediateValue,\n type GenuineCheckDAOutput,\n type GenuineCheckDARequiredInteraction,\n type GenuineCheckDAState,\n} from \"@api/secure-channel/device-action/GenuineCheck/types\";\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
  }
@@ -1,2 +1,2 @@
1
- "use strict";var a=Object.defineProperty;var g=Object.getOwnPropertyDescriptor;var f=Object.getOwnPropertyNames;var C=Object.prototype.hasOwnProperty;var A=(r,e)=>{for(var i in e)a(r,i,{get:e[i],enumerable:!0})},_=(r,e,i,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let t of f(e))!C.call(r,t)&&t!==i&&a(r,t,{get:()=>e[t],enumerable:!(n=g(e,t))||n.enumerable});return r};var y=r=>_(a({},"__esModule",{value:!0}),r);var R={};A(R,{DeviceSession:()=>E});module.exports=y(R);var d=require("purify-ts"),p=require("rxjs"),v=require("uuid"),u=require("../../../api/command/utils/CommandUtils"),s=require("../../../api/device/DeviceStatus"),S=require("../../../api/device-session/DeviceSessionState"),h=require("../../../api/Error"),l=require("../../device-session/data/DeviceSessionRefresherConst"),m=require("./DeviceSessionRefresher");class E{_id;_connectedDevice;_deviceState;_refresher;_managerApiService;_secureChannelService;constructor({connectedDevice:e,id:i=(0,v.v4)()},n,t,o){this._id=i,this._connectedDevice=e,this._deviceState=new p.BehaviorSubject({sessionStateType:S.DeviceSessionStateType.Connected,deviceStatus:s.DeviceStatus.CONNECTED,deviceModelId:this._connectedDevice.deviceModel.id}),this._refresher=new m.DeviceSessionRefresher({refreshInterval:l.DEVICE_SESSION_REFRESH_INTERVAL,deviceStatus:s.DeviceStatus.CONNECTED,deviceModelId:this._connectedDevice.deviceModel.id,sendApduFn:c=>this.sendApdu(c,{isPolling:!0,triggersDisconnection:!1}),updateStateFn:c=>{const D=this._deviceState.getValue();this.setDeviceSessionState(c(D))}},n("device-session-refresher")),this._managerApiService=t,this._secureChannelService=o}get id(){return this._id}get connectedDevice(){return this._connectedDevice}get state(){return this._deviceState.asObservable()}setDeviceSessionState(e){this._deviceState.next(e)}updateDeviceStatus(e){const i=this._deviceState.getValue();this._refresher.setDeviceStatus(e),this._deviceState.next({...i,deviceStatus:e})}async sendApdu(e,i={isPolling:!1,triggersDisconnection:!1}){return this._deviceState.getValue().deviceStatus===s.DeviceStatus.BUSY?(0,d.Left)(new h.DeviceBusyError):(i.isPolling||this.updateDeviceStatus(s.DeviceStatus.BUSY),(await this._connectedDevice.sendApdu(e,i.triggersDisconnection)).ifRight(o=>{u.CommandUtils.isLockedDeviceResponse(o)?this.updateDeviceStatus(s.DeviceStatus.LOCKED):this.updateDeviceStatus(s.DeviceStatus.CONNECTED)}).ifLeft(()=>{this.updateDeviceStatus(s.DeviceStatus.CONNECTED)}))}async sendCommand(e){const i=e.getApdu();return(await this.sendApdu(i.getRawApdu(),{isPolling:!1,triggersDisconnection:e.triggersDisconnection??!1})).caseOf({Left:t=>{throw t},Right:t=>e.parseResponse(t,this._connectedDevice.deviceModel.id)})}executeDeviceAction(e){const{observable:i,cancel:n}=e._execute({sendApdu:async t=>this.sendApdu(t),sendCommand:async t=>this.sendCommand(t),getDeviceSessionState:()=>this._deviceState.getValue(),getDeviceSessionStateObservable:()=>this.state,setDeviceSessionState:t=>(this.setDeviceSessionState(t),this._deviceState.getValue()),getManagerApiService:()=>this._managerApiService,getSecureChannelService:()=>this._secureChannelService});return{observable:i,cancel:n}}close(){this.updateDeviceStatus(s.DeviceStatus.NOT_CONNECTED),this._deviceState.complete(),this._refresher.stop()}toggleRefresher(e){e?this._refresher.start():this._refresher.stop()}}0&&(module.exports={DeviceSession});
1
+ "use strict";var a=Object.defineProperty;var D=Object.getOwnPropertyDescriptor;var f=Object.getOwnPropertyNames;var C=Object.prototype.hasOwnProperty;var _=(n,e)=>{for(var i in e)a(n,i,{get:e[i],enumerable:!0})},y=(n,e,i,s)=>{if(e&&typeof e=="object"||typeof e=="function")for(let t of f(e))!C.call(n,t)&&t!==i&&a(n,t,{get:()=>e[t],enumerable:!(s=D(e,t))||s.enumerable});return n};var A=n=>y(a({},"__esModule",{value:!0}),n);var R={};_(R,{DeviceSession:()=>E});module.exports=A(R);var d=require("purify-ts"),p=require("rxjs"),u=require("uuid"),v=require("../../../api/command/utils/CommandUtils"),r=require("../../../api/device/DeviceStatus"),S=require("../../../api/device-session/DeviceSessionState"),l=require("../../../api/Error"),h=require("../../device-session/data/DeviceSessionRefresherConst"),g=require("./DeviceSessionRefresher");class E{_id;_connectedDevice;_deviceState;_refresher;_managerApiService;_secureChannelService;constructor({connectedDevice:e,id:i=(0,u.v4)()},s,t,o){this._id=i,this._connectedDevice=e,this._deviceState=new p.BehaviorSubject({sessionStateType:S.DeviceSessionStateType.Connected,deviceStatus:r.DeviceStatus.CONNECTED,deviceModelId:this._connectedDevice.deviceModel.id}),this._refresher=new g.DeviceSessionRefresher({refreshInterval:h.DEVICE_SESSION_REFRESH_INTERVAL,deviceStatus:r.DeviceStatus.CONNECTED,deviceModelId:this._connectedDevice.deviceModel.id,sendApduFn:c=>this.sendApdu(c,{isPolling:!0,triggersDisconnection:!1}),updateStateFn:c=>{const m=this._deviceState.getValue();this.setDeviceSessionState(c(m))}},s("device-session-refresher")),this._managerApiService=t,this._secureChannelService=o}get id(){return this._id}get connectedDevice(){return this._connectedDevice}get state(){return this._deviceState.asObservable()}setDeviceSessionState(e){this._deviceState.next(e)}updateDeviceStatus(e){const i=this._deviceState.getValue();this._refresher.setDeviceStatus(e),this._deviceState.next({...i,deviceStatus:e})}async sendApdu(e,i={isPolling:!1,triggersDisconnection:!1}){return i.isPolling||(this.toggleRefresher(!1),await this.waitUntilReady()),this._deviceState.getValue().deviceStatus===r.DeviceStatus.BUSY?(0,d.Left)(new l.DeviceBusyError):(this.updateDeviceStatus(r.DeviceStatus.BUSY),(await this._connectedDevice.sendApdu(e,i.triggersDisconnection)).ifRight(o=>{v.CommandUtils.isLockedDeviceResponse(o)?this.updateDeviceStatus(r.DeviceStatus.LOCKED):this.updateDeviceStatus(r.DeviceStatus.CONNECTED),i.isPolling||this.toggleRefresher(!0)}).ifLeft(()=>{this.updateDeviceStatus(r.DeviceStatus.CONNECTED),i.isPolling||this.toggleRefresher(!0)}))}async waitUntilReady(){let e;await new Promise(i=>{e=this._deviceState.subscribe(s=>{s.deviceStatus===r.DeviceStatus.CONNECTED&&(e?.unsubscribe(),i())})})}async sendCommand(e){const i=e.getApdu();return(await this.sendApdu(i.getRawApdu(),{isPolling:!1,triggersDisconnection:e.triggersDisconnection??!1})).caseOf({Left:t=>{throw t},Right:t=>e.parseResponse(t,this._connectedDevice.deviceModel.id)})}executeDeviceAction(e){const{observable:i,cancel:s}=e._execute({sendApdu:async t=>this.sendApdu(t),sendCommand:async t=>this.sendCommand(t),getDeviceSessionState:()=>this._deviceState.getValue(),getDeviceSessionStateObservable:()=>this.state,setDeviceSessionState:t=>(this.setDeviceSessionState(t),this._deviceState.getValue()),toggleRefresher:t=>this.toggleRefresher(t),getManagerApiService:()=>this._managerApiService,getSecureChannelService:()=>this._secureChannelService});return{observable:i,cancel:s}}close(){this.updateDeviceStatus(r.DeviceStatus.NOT_CONNECTED),this._deviceState.complete(),this._refresher.stop()}toggleRefresher(e){e?this._refresher.start():this._refresher.stop()}}0&&(module.exports={DeviceSession});
2
2
  //# sourceMappingURL=DeviceSession.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../../../src/internal/device-session/model/DeviceSession.ts"],
4
- "sourcesContent": ["import { type Either, Left } from \"purify-ts\";\nimport { BehaviorSubject } from \"rxjs\";\nimport { v4 as uuidv4 } from \"uuid\";\n\nimport { type Command } from \"@api/command/Command\";\nimport { type CommandResult } from \"@api/command/model/CommandResult\";\nimport { CommandUtils } from \"@api/command/utils/CommandUtils\";\nimport { DeviceStatus } from \"@api/device/DeviceStatus\";\nimport {\n type DeviceAction,\n type DeviceActionIntermediateValue,\n type ExecuteDeviceActionReturnType,\n} from \"@api/device-action/DeviceAction\";\nimport { type ApduResponse } from \"@api/device-session/ApduResponse\";\nimport {\n type DeviceSessionState,\n DeviceSessionStateType,\n} from \"@api/device-session/DeviceSessionState\";\nimport { type DeviceSessionId } from \"@api/device-session/types\";\nimport { DeviceBusyError, type DmkError } from \"@api/Error\";\nimport { type LoggerPublisherService } from \"@api/logger-publisher/service/LoggerPublisherService\";\nimport { type TransportConnectedDevice } from \"@api/transport/model/TransportConnectedDevice\";\nimport { DEVICE_SESSION_REFRESH_INTERVAL } from \"@internal/device-session/data/DeviceSessionRefresherConst\";\nimport { type ManagerApiService } from \"@internal/manager-api/service/ManagerApiService\";\nimport { type SecureChannelService } from \"@internal/secure-channel/service/SecureChannelService\";\n\nimport { DeviceSessionRefresher } from \"./DeviceSessionRefresher\";\n\nexport type SessionConstructorArgs = {\n connectedDevice: TransportConnectedDevice;\n id?: DeviceSessionId;\n};\n\ntype SendApduOptions = {\n isPolling?: boolean;\n triggersDisconnection?: boolean;\n};\n\n/**\n * Represents a session with a device.\n */\nexport class DeviceSession {\n private readonly _id: DeviceSessionId;\n private readonly _connectedDevice: TransportConnectedDevice;\n private readonly _deviceState: BehaviorSubject<DeviceSessionState>;\n private readonly _refresher: DeviceSessionRefresher;\n private readonly _managerApiService: ManagerApiService;\n private readonly _secureChannelService: SecureChannelService;\n\n constructor(\n { connectedDevice, id = uuidv4() }: SessionConstructorArgs,\n loggerModuleFactory: (tag: string) => LoggerPublisherService,\n managerApiService: ManagerApiService,\n secureChannelService: SecureChannelService,\n ) {\n this._id = id;\n this._connectedDevice = connectedDevice;\n this._deviceState = new BehaviorSubject<DeviceSessionState>({\n sessionStateType: DeviceSessionStateType.Connected,\n deviceStatus: DeviceStatus.CONNECTED,\n deviceModelId: this._connectedDevice.deviceModel.id,\n });\n this._refresher = new DeviceSessionRefresher(\n {\n refreshInterval: DEVICE_SESSION_REFRESH_INTERVAL,\n deviceStatus: DeviceStatus.CONNECTED,\n deviceModelId: this._connectedDevice.deviceModel.id,\n sendApduFn: (rawApdu: Uint8Array) =>\n this.sendApdu(rawApdu, {\n isPolling: true,\n triggersDisconnection: false,\n }),\n updateStateFn: (callback) => {\n const state = this._deviceState.getValue();\n this.setDeviceSessionState(callback(state));\n },\n },\n loggerModuleFactory(\"device-session-refresher\"),\n );\n this._managerApiService = managerApiService;\n this._secureChannelService = secureChannelService;\n }\n\n public get id() {\n return this._id;\n }\n\n public get connectedDevice() {\n return this._connectedDevice;\n }\n\n public get state() {\n return this._deviceState.asObservable();\n }\n\n public setDeviceSessionState(state: DeviceSessionState) {\n this._deviceState.next(state);\n }\n\n private updateDeviceStatus(deviceStatus: DeviceStatus) {\n const sessionState = this._deviceState.getValue();\n this._refresher.setDeviceStatus(deviceStatus);\n this._deviceState.next({\n ...sessionState,\n deviceStatus,\n });\n }\n\n async sendApdu(\n rawApdu: Uint8Array,\n options: SendApduOptions = {\n isPolling: false,\n triggersDisconnection: false,\n },\n ): Promise<Either<DmkError, ApduResponse>> {\n const sessionState = this._deviceState.getValue();\n if (sessionState.deviceStatus === DeviceStatus.BUSY) {\n return Left(new DeviceBusyError());\n }\n\n if (!options.isPolling) {\n this.updateDeviceStatus(DeviceStatus.BUSY);\n }\n\n const errorOrResponse = await this._connectedDevice.sendApdu(\n rawApdu,\n options.triggersDisconnection,\n );\n\n return errorOrResponse\n .ifRight((response: ApduResponse) => {\n if (CommandUtils.isLockedDeviceResponse(response)) {\n this.updateDeviceStatus(DeviceStatus.LOCKED);\n } else {\n this.updateDeviceStatus(DeviceStatus.CONNECTED);\n }\n })\n .ifLeft(() => {\n this.updateDeviceStatus(DeviceStatus.CONNECTED);\n });\n }\n\n async sendCommand<Response, Args, ErrorStatusCodes>(\n command: Command<Response, Args, ErrorStatusCodes>,\n ): Promise<CommandResult<Response, ErrorStatusCodes>> {\n const apdu = command.getApdu();\n const response = await this.sendApdu(apdu.getRawApdu(), {\n isPolling: false,\n triggersDisconnection: command.triggersDisconnection ?? false,\n });\n\n return response.caseOf({\n Left: (err) => {\n throw err;\n },\n Right: (r) =>\n command.parseResponse(r, this._connectedDevice.deviceModel.id),\n });\n }\n\n executeDeviceAction<\n Output,\n Input,\n Error extends DmkError,\n IntermediateValue extends DeviceActionIntermediateValue,\n >(\n deviceAction: DeviceAction<Output, Input, Error, IntermediateValue>,\n ): ExecuteDeviceActionReturnType<Output, Error, IntermediateValue> {\n const { observable, cancel } = deviceAction._execute({\n sendApdu: async (apdu: Uint8Array) => this.sendApdu(apdu),\n sendCommand: async <Response, ErrorStatusCodes, Args>(\n command: Command<Response, ErrorStatusCodes, Args>,\n ) => this.sendCommand(command),\n getDeviceSessionState: () => this._deviceState.getValue(),\n getDeviceSessionStateObservable: () => this.state,\n setDeviceSessionState: (state: DeviceSessionState) => {\n this.setDeviceSessionState(state);\n return this._deviceState.getValue();\n },\n getManagerApiService: () => this._managerApiService,\n getSecureChannelService: () => this._secureChannelService,\n });\n\n return {\n observable,\n cancel,\n };\n }\n\n close() {\n this.updateDeviceStatus(DeviceStatus.NOT_CONNECTED);\n this._deviceState.complete();\n this._refresher.stop();\n }\n\n toggleRefresher(enabled: boolean) {\n if (enabled) {\n this._refresher.start();\n } else {\n this._refresher.stop();\n }\n }\n}\n"],
5
- "mappings": "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",
6
- "names": ["DeviceSession_exports", "__export", "DeviceSession", "__toCommonJS", "import_purify_ts", "import_rxjs", "import_uuid", "import_CommandUtils", "import_DeviceStatus", "import_DeviceSessionState", "import_Error", "import_DeviceSessionRefresherConst", "import_DeviceSessionRefresher", "connectedDevice", "id", "uuidv4", "loggerModuleFactory", "managerApiService", "secureChannelService", "rawApdu", "callback", "state", "deviceStatus", "sessionState", "options", "response", "command", "apdu", "err", "r", "deviceAction", "observable", "cancel", "enabled"]
4
+ "sourcesContent": ["import { type Either, Left } from \"purify-ts\";\nimport { BehaviorSubject, type Subscription } from \"rxjs\";\nimport { v4 as uuidv4 } from \"uuid\";\n\nimport { type Command } from \"@api/command/Command\";\nimport { type CommandResult } from \"@api/command/model/CommandResult\";\nimport { CommandUtils } from \"@api/command/utils/CommandUtils\";\nimport { DeviceStatus } from \"@api/device/DeviceStatus\";\nimport {\n type DeviceAction,\n type DeviceActionIntermediateValue,\n type ExecuteDeviceActionReturnType,\n} from \"@api/device-action/DeviceAction\";\nimport { type ApduResponse } from \"@api/device-session/ApduResponse\";\nimport {\n type DeviceSessionState,\n DeviceSessionStateType,\n} from \"@api/device-session/DeviceSessionState\";\nimport { type DeviceSessionId } from \"@api/device-session/types\";\nimport { DeviceBusyError, type DmkError } from \"@api/Error\";\nimport { type LoggerPublisherService } from \"@api/logger-publisher/service/LoggerPublisherService\";\nimport { type TransportConnectedDevice } from \"@api/transport/model/TransportConnectedDevice\";\nimport { DEVICE_SESSION_REFRESH_INTERVAL } from \"@internal/device-session/data/DeviceSessionRefresherConst\";\nimport { type ManagerApiService } from \"@internal/manager-api/service/ManagerApiService\";\nimport { type SecureChannelService } from \"@internal/secure-channel/service/SecureChannelService\";\n\nimport { DeviceSessionRefresher } from \"./DeviceSessionRefresher\";\n\nexport type SessionConstructorArgs = {\n connectedDevice: TransportConnectedDevice;\n id?: DeviceSessionId;\n};\n\ntype SendApduOptions = {\n isPolling?: boolean;\n triggersDisconnection?: boolean;\n};\n\n/**\n * Represents a session with a device.\n */\nexport class DeviceSession {\n private readonly _id: DeviceSessionId;\n private readonly _connectedDevice: TransportConnectedDevice;\n private readonly _deviceState: BehaviorSubject<DeviceSessionState>;\n private readonly _refresher: DeviceSessionRefresher;\n private readonly _managerApiService: ManagerApiService;\n private readonly _secureChannelService: SecureChannelService;\n\n constructor(\n { connectedDevice, id = uuidv4() }: SessionConstructorArgs,\n loggerModuleFactory: (tag: string) => LoggerPublisherService,\n managerApiService: ManagerApiService,\n secureChannelService: SecureChannelService,\n ) {\n this._id = id;\n this._connectedDevice = connectedDevice;\n this._deviceState = new BehaviorSubject<DeviceSessionState>({\n sessionStateType: DeviceSessionStateType.Connected,\n deviceStatus: DeviceStatus.CONNECTED,\n deviceModelId: this._connectedDevice.deviceModel.id,\n });\n this._refresher = new DeviceSessionRefresher(\n {\n refreshInterval: DEVICE_SESSION_REFRESH_INTERVAL,\n deviceStatus: DeviceStatus.CONNECTED,\n deviceModelId: this._connectedDevice.deviceModel.id,\n sendApduFn: (rawApdu: Uint8Array) =>\n this.sendApdu(rawApdu, {\n isPolling: true,\n triggersDisconnection: false,\n }),\n updateStateFn: (callback) => {\n const state = this._deviceState.getValue();\n this.setDeviceSessionState(callback(state));\n },\n },\n loggerModuleFactory(\"device-session-refresher\"),\n );\n this._managerApiService = managerApiService;\n this._secureChannelService = secureChannelService;\n }\n\n public get id() {\n return this._id;\n }\n\n public get connectedDevice() {\n return this._connectedDevice;\n }\n\n public get state() {\n return this._deviceState.asObservable();\n }\n\n public setDeviceSessionState(state: DeviceSessionState) {\n this._deviceState.next(state);\n }\n\n private updateDeviceStatus(deviceStatus: DeviceStatus) {\n const sessionState = this._deviceState.getValue();\n this._refresher.setDeviceStatus(deviceStatus);\n this._deviceState.next({\n ...sessionState,\n deviceStatus,\n });\n }\n\n async sendApdu(\n rawApdu: Uint8Array,\n options: SendApduOptions = {\n isPolling: false,\n triggersDisconnection: false,\n },\n ): Promise<Either<DmkError, ApduResponse>> {\n if (!options.isPolling) {\n this.toggleRefresher(false);\n await this.waitUntilReady();\n }\n\n const sessionState = this._deviceState.getValue();\n if (sessionState.deviceStatus === DeviceStatus.BUSY) {\n return Left(new DeviceBusyError());\n }\n\n this.updateDeviceStatus(DeviceStatus.BUSY);\n\n const errorOrResponse = await this._connectedDevice.sendApdu(\n rawApdu,\n options.triggersDisconnection,\n );\n\n return errorOrResponse\n .ifRight((response: ApduResponse) => {\n if (CommandUtils.isLockedDeviceResponse(response)) {\n this.updateDeviceStatus(DeviceStatus.LOCKED);\n } else {\n this.updateDeviceStatus(DeviceStatus.CONNECTED);\n }\n\n if (!options.isPolling) {\n this.toggleRefresher(true);\n }\n })\n .ifLeft(() => {\n this.updateDeviceStatus(DeviceStatus.CONNECTED);\n\n if (!options.isPolling) {\n this.toggleRefresher(true);\n }\n });\n }\n\n async waitUntilReady() {\n let deviceStateSub: Subscription;\n\n await new Promise<void>((resolve) => {\n deviceStateSub = this._deviceState.subscribe((state) => {\n if (state.deviceStatus === DeviceStatus.CONNECTED) {\n deviceStateSub?.unsubscribe();\n resolve();\n }\n });\n });\n }\n\n async sendCommand<Response, Args, ErrorStatusCodes>(\n command: Command<Response, Args, ErrorStatusCodes>,\n ): Promise<CommandResult<Response, ErrorStatusCodes>> {\n const apdu = command.getApdu();\n const response = await this.sendApdu(apdu.getRawApdu(), {\n isPolling: false,\n triggersDisconnection: command.triggersDisconnection ?? false,\n });\n\n return response.caseOf({\n Left: (err) => {\n throw err;\n },\n Right: (r) =>\n command.parseResponse(r, this._connectedDevice.deviceModel.id),\n });\n }\n\n executeDeviceAction<\n Output,\n Input,\n Error extends DmkError,\n IntermediateValue extends DeviceActionIntermediateValue,\n >(\n deviceAction: DeviceAction<Output, Input, Error, IntermediateValue>,\n ): ExecuteDeviceActionReturnType<Output, Error, IntermediateValue> {\n const { observable, cancel } = deviceAction._execute({\n sendApdu: async (apdu: Uint8Array) => this.sendApdu(apdu),\n sendCommand: async <Response, ErrorStatusCodes, Args>(\n command: Command<Response, ErrorStatusCodes, Args>,\n ) => this.sendCommand(command),\n getDeviceSessionState: () => this._deviceState.getValue(),\n getDeviceSessionStateObservable: () => this.state,\n setDeviceSessionState: (state: DeviceSessionState) => {\n this.setDeviceSessionState(state);\n return this._deviceState.getValue();\n },\n toggleRefresher: (enabled: boolean) => this.toggleRefresher(enabled),\n getManagerApiService: () => this._managerApiService,\n getSecureChannelService: () => this._secureChannelService,\n });\n\n return {\n observable,\n cancel,\n };\n }\n\n close() {\n this.updateDeviceStatus(DeviceStatus.NOT_CONNECTED);\n this._deviceState.complete();\n this._refresher.stop();\n }\n\n toggleRefresher(enabled: boolean) {\n if (enabled) {\n this._refresher.start();\n } else {\n this._refresher.stop();\n }\n }\n}\n"],
5
+ "mappings": "yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,mBAAAE,IAAA,eAAAC,EAAAH,GAAA,IAAAI,EAAkC,qBAClCC,EAAmD,gBACnDC,EAA6B,gBAI7BC,EAA6B,2CAC7BC,EAA6B,oCAO7BC,EAGO,kDAEPC,EAA+C,sBAG/CC,EAAgD,qEAIhDC,EAAuC,oCAehC,MAAMV,CAAc,CACR,IACA,iBACA,aACA,WACA,mBACA,sBAEjB,YACE,CAAE,gBAAAW,EAAiB,GAAAC,KAAK,EAAAC,IAAO,CAAE,EACjCC,EACAC,EACAC,EACA,CACA,KAAK,IAAMJ,EACX,KAAK,iBAAmBD,EACxB,KAAK,aAAe,IAAI,kBAAoC,CAC1D,iBAAkB,yBAAuB,UACzC,aAAc,eAAa,UAC3B,cAAe,KAAK,iBAAiB,YAAY,EACnD,CAAC,EACD,KAAK,WAAa,IAAI,yBACpB,CACE,gBAAiB,kCACjB,aAAc,eAAa,UAC3B,cAAe,KAAK,iBAAiB,YAAY,GACjD,WAAaM,GACX,KAAK,SAASA,EAAS,CACrB,UAAW,GACX,sBAAuB,EACzB,CAAC,EACH,cAAgBC,GAAa,CAC3B,MAAMC,EAAQ,KAAK,aAAa,SAAS,EACzC,KAAK,sBAAsBD,EAASC,CAAK,CAAC,CAC5C,CACF,EACAL,EAAoB,0BAA0B,CAChD,EACA,KAAK,mBAAqBC,EAC1B,KAAK,sBAAwBC,CAC/B,CAEA,IAAW,IAAK,CACd,OAAO,KAAK,GACd,CAEA,IAAW,iBAAkB,CAC3B,OAAO,KAAK,gBACd,CAEA,IAAW,OAAQ,CACjB,OAAO,KAAK,aAAa,aAAa,CACxC,CAEO,sBAAsBG,EAA2B,CACtD,KAAK,aAAa,KAAKA,CAAK,CAC9B,CAEQ,mBAAmBC,EAA4B,CACrD,MAAMC,EAAe,KAAK,aAAa,SAAS,EAChD,KAAK,WAAW,gBAAgBD,CAAY,EAC5C,KAAK,aAAa,KAAK,CACrB,GAAGC,EACH,aAAAD,CACF,CAAC,CACH,CAEA,MAAM,SACJH,EACAK,EAA2B,CACzB,UAAW,GACX,sBAAuB,EACzB,EACyC,CAOzC,OANKA,EAAQ,YACX,KAAK,gBAAgB,EAAK,EAC1B,MAAM,KAAK,eAAe,GAGP,KAAK,aAAa,SAAS,EAC/B,eAAiB,eAAa,QACtC,QAAK,IAAI,iBAAiB,GAGnC,KAAK,mBAAmB,eAAa,IAAI,GAEjB,MAAM,KAAK,iBAAiB,SAClDL,EACAK,EAAQ,qBACV,GAGG,QAASC,GAA2B,CAC/B,eAAa,uBAAuBA,CAAQ,EAC9C,KAAK,mBAAmB,eAAa,MAAM,EAE3C,KAAK,mBAAmB,eAAa,SAAS,EAG3CD,EAAQ,WACX,KAAK,gBAAgB,EAAI,CAE7B,CAAC,EACA,OAAO,IAAM,CACZ,KAAK,mBAAmB,eAAa,SAAS,EAEzCA,EAAQ,WACX,KAAK,gBAAgB,EAAI,CAE7B,CAAC,EACL,CAEA,MAAM,gBAAiB,CACrB,IAAIE,EAEJ,MAAM,IAAI,QAAeC,GAAY,CACnCD,EAAiB,KAAK,aAAa,UAAWL,GAAU,CAClDA,EAAM,eAAiB,eAAa,YACtCK,GAAgB,YAAY,EAC5BC,EAAQ,EAEZ,CAAC,CACH,CAAC,CACH,CAEA,MAAM,YACJC,EACoD,CACpD,MAAMC,EAAOD,EAAQ,QAAQ,EAM7B,OALiB,MAAM,KAAK,SAASC,EAAK,WAAW,EAAG,CACtD,UAAW,GACX,sBAAuBD,EAAQ,uBAAyB,EAC1D,CAAC,GAEe,OAAO,CACrB,KAAOE,GAAQ,CACb,MAAMA,CACR,EACA,MAAQC,GACNH,EAAQ,cAAcG,EAAG,KAAK,iBAAiB,YAAY,EAAE,CACjE,CAAC,CACH,CAEA,oBAMEC,EACiE,CACjE,KAAM,CAAE,WAAAC,EAAY,OAAAC,CAAO,EAAIF,EAAa,SAAS,CACnD,SAAU,MAAOH,GAAqB,KAAK,SAASA,CAAI,EACxD,YAAa,MACXD,GACG,KAAK,YAAYA,CAAO,EAC7B,sBAAuB,IAAM,KAAK,aAAa,SAAS,EACxD,gCAAiC,IAAM,KAAK,MAC5C,sBAAwBP,IACtB,KAAK,sBAAsBA,CAAK,EACzB,KAAK,aAAa,SAAS,GAEpC,gBAAkBc,GAAqB,KAAK,gBAAgBA,CAAO,EACnE,qBAAsB,IAAM,KAAK,mBACjC,wBAAyB,IAAM,KAAK,qBACtC,CAAC,EAED,MAAO,CACL,WAAAF,EACA,OAAAC,CACF,CACF,CAEA,OAAQ,CACN,KAAK,mBAAmB,eAAa,aAAa,EAClD,KAAK,aAAa,SAAS,EAC3B,KAAK,WAAW,KAAK,CACvB,CAEA,gBAAgBC,EAAkB,CAC5BA,EACF,KAAK,WAAW,MAAM,EAEtB,KAAK,WAAW,KAAK,CAEzB,CACF",
6
+ "names": ["DeviceSession_exports", "__export", "DeviceSession", "__toCommonJS", "import_purify_ts", "import_rxjs", "import_uuid", "import_CommandUtils", "import_DeviceStatus", "import_DeviceSessionState", "import_Error", "import_DeviceSessionRefresherConst", "import_DeviceSessionRefresher", "connectedDevice", "id", "uuidv4", "loggerModuleFactory", "managerApiService", "secureChannelService", "rawApdu", "callback", "state", "deviceStatus", "sessionState", "options", "response", "deviceStateSub", "resolve", "command", "apdu", "err", "r", "deviceAction", "observable", "cancel", "enabled"]
7
7
  }
@@ -1,2 +1,2 @@
1
- "use strict";var u=Object.defineProperty;var l=Object.getOwnPropertyDescriptor;var A=Object.getOwnPropertyNames;var g=Object.prototype.hasOwnProperty;var f=(n,e)=>{for(var t in e)u(n,t,{get:e[t],enumerable:!0})},O=(n,e,t,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let s of A(e))!g.call(n,s)&&s!==t&&u(n,s,{get:()=>e[s],enumerable:!(i=l(e,s))||i.enumerable});return n};var y=n=>O(u({},"__esModule",{value:!0}),n),c=(n,e,t,i)=>{for(var s=i>1?void 0:i?l(e,t):e,a=n.length-1,o;a>=0;a--)(o=n[a])&&(s=(i?o(e,t,s):o(s))||s);return i&&s&&u(e,t,s),s};var D={};f(D,{DeviceSessionRefresher:()=>d});module.exports=y(D);var m=require("inversify"),r=require("rxjs"),h=require("../../../api/command/model/CommandResult"),v=require("../../../api/command/os/GetAppAndVersionCommand"),_=require("../../../api/command/os/GetOsVersionCommand"),b=require("../../../api/device/DeviceModel"),p=require("../../../api/device/DeviceStatus"),S=require("../../../api/device-session/DeviceSessionState");let d=class{_logger;_getAppAndVersionCommand=new v.GetAppAndVersionCommand;_getOsVersionCommand=new _.GetOsVersionCommand;_deviceStatus;_subscription;_refreshInterval;_deviceModelId;_sendApduFn;_updateStateFn;constructor({refreshInterval:e,deviceStatus:t,sendApduFn:i,updateStateFn:s,deviceModelId:a},o){this._deviceStatus=t,this._logger=o,this._sendApduFn=i,this._updateStateFn=s,this._refreshInterval=e,this._deviceModelId=a,this.start()}start(){if(this._subscription&&!this._subscription.closed){this._logger.warn("Refresher already started");return}const e=this._deviceModelId===b.DeviceModelId.NANO_S?this._getNanoSRefreshObservable(this._refreshInterval*2):this._getDefaultRefreshObservable((0,r.interval)(this._refreshInterval));this._subscription=e.subscribe(t=>{!t||!(0,h.isSuccessCommandResult)(t)||this._updateStateFn(i=>({...i,sessionStateType:S.DeviceSessionStateType.ReadyWithoutSecureChannel,deviceStatus:this._deviceStatus,currentApp:t.data,installedApps:"installedApps"in i?i.installedApps:[]}))})}_getDefaultRefreshObservable(e=(0,r.from)([0])){return e.pipe((0,r.filter)(()=>![p.DeviceStatus.BUSY,p.DeviceStatus.NOT_CONNECTED].includes(this._deviceStatus)),(0,r.switchMap)(async()=>{const t=this._getAppAndVersionCommand.getApdu().getRawApdu();return await this._sendApduFn(t)}),(0,r.map)(t=>t.caseOf({Left:i=>(this._logger.error("Error in sending APDU when polling",{data:{error:i}}),null),Right:i=>{try{return this._getAppAndVersionCommand.parseResponse(i)}catch(s){return this._logger.error("Error in parsing APDU response",{data:{error:s}}),null}}})),(0,r.filter)(t=>t!==null))}_getNanoSRefreshObservable(e){const t=this._getDefaultRefreshObservable().pipe((0,r.switchMap)(async s=>{const a=this._getOsVersionCommand.getApdu().getRawApdu();return await this._sendApduFn(a),s})),i=(0,r.of)(null).pipe((0,r.delay)(e),(0,r.map)(s=>{this._logger.warn("Nanos refresh timeout, setting device status to LOCKED"),this._updateStateFn(a=>({...a,deviceStatus:p.DeviceStatus.LOCKED}))}));return(0,r.interval)(e+100).pipe((0,r.switchMap)(()=>(0,r.race)(t,i)))}setDeviceStatus(e){e===p.DeviceStatus.NOT_CONNECTED&&this.stop(),this._deviceStatus=e}stop(){!this._subscription||this._subscription.closed||(this._subscription.unsubscribe(),this._subscription=void 0)}};d=c([(0,m.injectable)()],d);0&&(module.exports={DeviceSessionRefresher});
1
+ "use strict";var u=Object.defineProperty;var l=Object.getOwnPropertyDescriptor;var A=Object.getOwnPropertyNames;var f=Object.prototype.hasOwnProperty;var g=(n,e)=>{for(var t in e)u(n,t,{get:e[t],enumerable:!0})},O=(n,e,t,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of A(e))!f.call(n,i)&&i!==t&&u(n,i,{get:()=>e[i],enumerable:!(r=l(e,i))||r.enumerable});return n};var y=n=>O(u({},"__esModule",{value:!0}),n),c=(n,e,t,r)=>{for(var i=r>1?void 0:r?l(e,t):e,o=n.length-1,a;o>=0;o--)(a=n[o])&&(i=(r?a(e,t,i):a(i))||i);return r&&i&&u(e,t,i),i};var D={};g(D,{DeviceSessionRefresher:()=>d});module.exports=y(D);var m=require("inversify"),s=require("rxjs"),h=require("../../../api/command/model/CommandResult"),v=require("../../../api/command/os/GetAppAndVersionCommand"),_=require("../../../api/command/os/GetOsVersionCommand"),b=require("../../../api/device/DeviceModel"),p=require("../../../api/device/DeviceStatus"),S=require("../../../api/device-session/DeviceSessionState");let d=class{_logger;_getAppAndVersionCommand=new v.GetAppAndVersionCommand;_getOsVersionCommand=new _.GetOsVersionCommand;_deviceStatus;_subscription;_refreshInterval;_deviceModelId;_sendApduFn;_updateStateFn;constructor({refreshInterval:e,deviceStatus:t,sendApduFn:r,updateStateFn:i,deviceModelId:o},a){this._deviceStatus=t,this._logger=a,this._sendApduFn=r,this._updateStateFn=i,this._refreshInterval=e,this._deviceModelId=o,this.start()}start(){if(this._subscription&&!this._subscription.closed){this._logger.warn("Refresher already started");return}const e=this._deviceModelId===b.DeviceModelId.NANO_S?this._getNanoSRefreshObservable(this._refreshInterval*2):this._getDefaultRefreshObservable((0,s.interval)(this._refreshInterval));this._subscription=e.subscribe(t=>{!t||!(0,h.isSuccessCommandResult)(t)||this._updateStateFn(r=>({...r,sessionStateType:S.DeviceSessionStateType.ReadyWithoutSecureChannel,deviceStatus:this._deviceStatus,currentApp:t.data,installedApps:"installedApps"in r?r.installedApps:[],isSecureConnectionAllowed:"isSecureConnectionAllowed"in r?r.isSecureConnectionAllowed:!1}))})}_getDefaultRefreshObservable(e=(0,s.from)([0])){return e.pipe((0,s.filter)(()=>![p.DeviceStatus.BUSY,p.DeviceStatus.NOT_CONNECTED].includes(this._deviceStatus)),(0,s.switchMap)(async()=>{const t=this._getAppAndVersionCommand.getApdu().getRawApdu();return await this._sendApduFn(t)}),(0,s.map)(t=>t.caseOf({Left:r=>(this._logger.error("Error in sending APDU when polling",{data:{error:r}}),null),Right:r=>{try{return this._getAppAndVersionCommand.parseResponse(r)}catch(i){return this._logger.error("Error in parsing APDU response",{data:{error:i}}),null}}})),(0,s.filter)(t=>t!==null))}_getNanoSRefreshObservable(e){const t=this._getDefaultRefreshObservable().pipe((0,s.switchMap)(async i=>{const o=this._getOsVersionCommand.getApdu().getRawApdu();return await this._sendApduFn(o),i})),r=(0,s.of)(null).pipe((0,s.delay)(e),(0,s.map)(i=>{this._logger.warn("Nanos refresh timeout, setting device status to LOCKED"),this._updateStateFn(o=>({...o,deviceStatus:p.DeviceStatus.LOCKED}))}));return(0,s.interval)(e+100).pipe((0,s.switchMap)(()=>(0,s.race)(t,r)))}setDeviceStatus(e){e===p.DeviceStatus.NOT_CONNECTED&&this.stop(),this._deviceStatus=e}stop(){!this._subscription||this._subscription.closed||(this._subscription.unsubscribe(),this._subscription=void 0)}};d=c([(0,m.injectable)()],d);0&&(module.exports={DeviceSessionRefresher});
2
2
  //# sourceMappingURL=DeviceSessionRefresher.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../../../src/internal/device-session/model/DeviceSessionRefresher.ts"],
4
- "sourcesContent": ["import { injectable } from \"inversify\";\nimport { Either } from \"purify-ts\";\nimport {\n delay,\n filter,\n from,\n interval,\n map,\n Observable,\n of,\n race,\n Subscription,\n switchMap,\n} from \"rxjs\";\n\nimport { isSuccessCommandResult } from \"@api/command/model/CommandResult\";\nimport {\n GetAppAndVersionCommand,\n GetAppAndVersionCommandResult,\n} from \"@api/command/os/GetAppAndVersionCommand\";\nimport { GetOsVersionCommand } from \"@api/command/os/GetOsVersionCommand\";\nimport { DeviceModelId } from \"@api/device/DeviceModel\";\nimport { DeviceStatus } from \"@api/device/DeviceStatus\";\nimport { ApduResponse } from \"@api/device-session/ApduResponse\";\nimport {\n DeviceSessionState,\n DeviceSessionStateType,\n} from \"@api/device-session/DeviceSessionState\";\nimport { DmkError } from \"@api/Error\";\nimport { type LoggerPublisherService } from \"@api/logger-publisher/service/LoggerPublisherService\";\nimport { SendApduFnType } from \"@api/transport/model/DeviceConnection\";\n\ntype UpdateStateFnType = (\n callback: (state: DeviceSessionState) => DeviceSessionState,\n) => void;\n\n/**\n * The arguments for the DeviceSessionRefresher.\n */\nexport type DeviceSessionRefresherArgs = {\n /**\n * The refresh interval in milliseconds.\n */\n refreshInterval: number;\n\n /**\n * The current device status when the refresher is created.\n */\n deviceStatus: Exclude<DeviceStatus, DeviceStatus.NOT_CONNECTED>;\n\n /**\n * The function used to send APDU commands to the device.\n */\n sendApduFn: (rawApdu: Uint8Array) => Promise<Either<DmkError, ApduResponse>>;\n\n /**\n * Callback that updates the state of the device session with\n * polling response.\n * @param callback - A function that will take the previous state and return the new state.\n * @returns void\n */\n updateStateFn: UpdateStateFnType;\n\n /**\n * Device model to handle NanoS specific refresher\n */\n deviceModelId: DeviceModelId;\n};\n\n/**\n * The session refresher that periodically sends a command to refresh the session.\n */\n@injectable()\nexport class DeviceSessionRefresher {\n private readonly _logger: LoggerPublisherService;\n private readonly _getAppAndVersionCommand = new GetAppAndVersionCommand();\n private readonly _getOsVersionCommand = new GetOsVersionCommand();\n private _deviceStatus: DeviceStatus;\n private _subscription?: Subscription;\n private readonly _refreshInterval: number;\n private readonly _deviceModelId: DeviceModelId;\n private readonly _sendApduFn: SendApduFnType;\n private readonly _updateStateFn: UpdateStateFnType;\n\n constructor(\n {\n refreshInterval,\n deviceStatus,\n sendApduFn,\n updateStateFn,\n deviceModelId,\n }: DeviceSessionRefresherArgs,\n logger: LoggerPublisherService,\n ) {\n this._deviceStatus = deviceStatus;\n this._logger = logger;\n this._sendApduFn = sendApduFn;\n this._updateStateFn = updateStateFn;\n this._refreshInterval = refreshInterval;\n this._deviceModelId = deviceModelId;\n\n this.start();\n }\n\n /**\n * Start the session refresher.\n * The refresher will send commands to refresh the session.\n */\n start() {\n if (this._subscription && !this._subscription.closed) {\n this._logger.warn(\"Refresher already started\");\n return;\n }\n\n // NanoS has a specific refresher that sends GetAppAndVersion and GetOsVersion commands\n const refreshObservable =\n this._deviceModelId === DeviceModelId.NANO_S\n ? this._getNanoSRefreshObservable(this._refreshInterval * 2)\n : this._getDefaultRefreshObservable(interval(this._refreshInterval));\n\n this._subscription = refreshObservable.subscribe((parsedResponse) => {\n if (!parsedResponse || !isSuccessCommandResult(parsedResponse)) {\n return;\n }\n // `batteryStatus` and `firmwareVersion` are not available in the polling response.\n this._updateStateFn((state) => ({\n ...state,\n sessionStateType: DeviceSessionStateType.ReadyWithoutSecureChannel,\n deviceStatus: this._deviceStatus,\n currentApp: parsedResponse.data,\n installedApps: \"installedApps\" in state ? state.installedApps : [],\n }));\n });\n }\n\n /**\n * Creates an observable that refreshes a device state with GetAppAndVersion command result.\n *\n * @param {ObservableInput<number>} parentObservable - The parent observable to base the refresh observable on. Defaults to an array with a single number [0].\n * @return {Observable<GetAppAndVersionCommandResult>} An observable that emits the result of the GetAppAndVersionCommand.\n */\n private _getDefaultRefreshObservable(\n parentObservable: Observable<number> = from([0]),\n ): Observable<GetAppAndVersionCommandResult> {\n return parentObservable.pipe(\n filter(\n () =>\n ![DeviceStatus.BUSY, DeviceStatus.NOT_CONNECTED].includes(\n this._deviceStatus,\n ),\n ),\n switchMap(async () => {\n const rawApdu = this._getAppAndVersionCommand.getApdu().getRawApdu();\n return await this._sendApduFn(rawApdu);\n }),\n map((resp) =>\n resp.caseOf({\n Left: (error) => {\n this._logger.error(\"Error in sending APDU when polling\", {\n data: { error },\n });\n return null;\n },\n Right: (data: ApduResponse) => {\n try {\n return this._getAppAndVersionCommand.parseResponse(data);\n } catch (error) {\n this._logger.error(\"Error in parsing APDU response\", {\n data: { error },\n });\n return null;\n }\n },\n }),\n ),\n filter((parsedResponse) => parsedResponse !== null),\n );\n }\n\n /**\n * Creates an observable that emits events to refresh the NanoS device state.\n *\n * @param {number} refreshInterval - The interval, in milliseconds, at which the NanoS state should be refreshed.\n * @return {Observable<GetAppAndVersionCommandResult | void>} An observable that emits events to refresh the NanoS device state and handle timeout scenarios.\n */\n private _getNanoSRefreshObservable(\n refreshInterval: number,\n ): Observable<GetAppAndVersionCommandResult | void> {\n const nanoSRefreshObservable = this._getDefaultRefreshObservable().pipe(\n switchMap(async (resp) => {\n const rawApdu = this._getOsVersionCommand.getApdu().getRawApdu();\n await this._sendApduFn(rawApdu);\n return resp;\n }),\n );\n const timeoutObservable = of(null).pipe(\n delay(refreshInterval),\n map((_) => {\n this._logger.warn(\n \"Nanos refresh timeout, setting device status to LOCKED\",\n );\n this._updateStateFn((state) => ({\n ...state,\n deviceStatus: DeviceStatus.LOCKED,\n }));\n }),\n );\n return interval(refreshInterval + 100).pipe(\n switchMap(() => race(nanoSRefreshObservable, timeoutObservable)),\n );\n }\n\n /**\n * Maintain a device status to prevent sending APDU when the device is busy.\n *\n * @param {DeviceStatus} deviceStatus - The new device status.\n */\n setDeviceStatus(deviceStatus: DeviceStatus) {\n if (deviceStatus === DeviceStatus.NOT_CONNECTED) {\n this.stop();\n }\n this._deviceStatus = deviceStatus;\n }\n\n /**\n * Stops the session refresher.\n * The refresher will no longer send commands to refresh the session.\n */\n stop() {\n if (!this._subscription || this._subscription.closed) {\n return;\n }\n this._subscription.unsubscribe();\n this._subscription = undefined;\n }\n}\n"],
5
- "mappings": "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",
4
+ "sourcesContent": ["import { injectable } from \"inversify\";\nimport { Either } from \"purify-ts\";\nimport {\n delay,\n filter,\n from,\n interval,\n map,\n Observable,\n of,\n race,\n Subscription,\n switchMap,\n} from \"rxjs\";\n\nimport { isSuccessCommandResult } from \"@api/command/model/CommandResult\";\nimport {\n GetAppAndVersionCommand,\n GetAppAndVersionCommandResult,\n} from \"@api/command/os/GetAppAndVersionCommand\";\nimport { GetOsVersionCommand } from \"@api/command/os/GetOsVersionCommand\";\nimport { DeviceModelId } from \"@api/device/DeviceModel\";\nimport { DeviceStatus } from \"@api/device/DeviceStatus\";\nimport { ApduResponse } from \"@api/device-session/ApduResponse\";\nimport {\n DeviceSessionState,\n DeviceSessionStateType,\n} from \"@api/device-session/DeviceSessionState\";\nimport { DmkError } from \"@api/Error\";\nimport { type LoggerPublisherService } from \"@api/logger-publisher/service/LoggerPublisherService\";\nimport { SendApduFnType } from \"@api/transport/model/DeviceConnection\";\n\ntype UpdateStateFnType = (\n callback: (state: DeviceSessionState) => DeviceSessionState,\n) => void;\n\n/**\n * The arguments for the DeviceSessionRefresher.\n */\nexport type DeviceSessionRefresherArgs = {\n /**\n * The refresh interval in milliseconds.\n */\n refreshInterval: number;\n\n /**\n * The current device status when the refresher is created.\n */\n deviceStatus: Exclude<DeviceStatus, DeviceStatus.NOT_CONNECTED>;\n\n /**\n * The function used to send APDU commands to the device.\n */\n sendApduFn: (rawApdu: Uint8Array) => Promise<Either<DmkError, ApduResponse>>;\n\n /**\n * Callback that updates the state of the device session with\n * polling response.\n * @param callback - A function that will take the previous state and return the new state.\n * @returns void\n */\n updateStateFn: UpdateStateFnType;\n\n /**\n * Device model to handle NanoS specific refresher\n */\n deviceModelId: DeviceModelId;\n};\n\n/**\n * The session refresher that periodically sends a command to refresh the session.\n */\n@injectable()\nexport class DeviceSessionRefresher {\n private readonly _logger: LoggerPublisherService;\n private readonly _getAppAndVersionCommand = new GetAppAndVersionCommand();\n private readonly _getOsVersionCommand = new GetOsVersionCommand();\n private _deviceStatus: DeviceStatus;\n private _subscription?: Subscription;\n private readonly _refreshInterval: number;\n private readonly _deviceModelId: DeviceModelId;\n private readonly _sendApduFn: SendApduFnType;\n private readonly _updateStateFn: UpdateStateFnType;\n\n constructor(\n {\n refreshInterval,\n deviceStatus,\n sendApduFn,\n updateStateFn,\n deviceModelId,\n }: DeviceSessionRefresherArgs,\n logger: LoggerPublisherService,\n ) {\n this._deviceStatus = deviceStatus;\n this._logger = logger;\n this._sendApduFn = sendApduFn;\n this._updateStateFn = updateStateFn;\n this._refreshInterval = refreshInterval;\n this._deviceModelId = deviceModelId;\n\n this.start();\n }\n\n /**\n * Start the session refresher.\n * The refresher will send commands to refresh the session.\n */\n start() {\n if (this._subscription && !this._subscription.closed) {\n this._logger.warn(\"Refresher already started\");\n return;\n }\n\n // NanoS has a specific refresher that sends GetAppAndVersion and GetOsVersion commands\n const refreshObservable =\n this._deviceModelId === DeviceModelId.NANO_S\n ? this._getNanoSRefreshObservable(this._refreshInterval * 2)\n : this._getDefaultRefreshObservable(interval(this._refreshInterval));\n\n this._subscription = refreshObservable.subscribe((parsedResponse) => {\n if (!parsedResponse || !isSuccessCommandResult(parsedResponse)) {\n return;\n }\n // `batteryStatus` and `firmwareVersion` are not available in the polling response.\n this._updateStateFn((state) => ({\n ...state,\n sessionStateType: DeviceSessionStateType.ReadyWithoutSecureChannel,\n deviceStatus: this._deviceStatus,\n currentApp: parsedResponse.data,\n installedApps: \"installedApps\" in state ? state.installedApps : [],\n isSecureConnectionAllowed:\n \"isSecureConnectionAllowed\" in state\n ? state.isSecureConnectionAllowed\n : false,\n }));\n });\n }\n\n /**\n * Creates an observable that refreshes a device state with GetAppAndVersion command result.\n *\n * @param {ObservableInput<number>} parentObservable - The parent observable to base the refresh observable on. Defaults to an array with a single number [0].\n * @return {Observable<GetAppAndVersionCommandResult>} An observable that emits the result of the GetAppAndVersionCommand.\n */\n private _getDefaultRefreshObservable(\n parentObservable: Observable<number> = from([0]),\n ): Observable<GetAppAndVersionCommandResult> {\n return parentObservable.pipe(\n filter(\n () =>\n ![DeviceStatus.BUSY, DeviceStatus.NOT_CONNECTED].includes(\n this._deviceStatus,\n ),\n ),\n switchMap(async () => {\n const rawApdu = this._getAppAndVersionCommand.getApdu().getRawApdu();\n return await this._sendApduFn(rawApdu);\n }),\n map((resp) =>\n resp.caseOf({\n Left: (error) => {\n this._logger.error(\"Error in sending APDU when polling\", {\n data: { error },\n });\n return null;\n },\n Right: (data: ApduResponse) => {\n try {\n return this._getAppAndVersionCommand.parseResponse(data);\n } catch (error) {\n this._logger.error(\"Error in parsing APDU response\", {\n data: { error },\n });\n return null;\n }\n },\n }),\n ),\n filter((parsedResponse) => parsedResponse !== null),\n );\n }\n\n /**\n * Creates an observable that emits events to refresh the NanoS device state.\n *\n * @param {number} refreshInterval - The interval, in milliseconds, at which the NanoS state should be refreshed.\n * @return {Observable<GetAppAndVersionCommandResult | void>} An observable that emits events to refresh the NanoS device state and handle timeout scenarios.\n */\n private _getNanoSRefreshObservable(\n refreshInterval: number,\n ): Observable<GetAppAndVersionCommandResult | void> {\n const nanoSRefreshObservable = this._getDefaultRefreshObservable().pipe(\n switchMap(async (resp) => {\n const rawApdu = this._getOsVersionCommand.getApdu().getRawApdu();\n await this._sendApduFn(rawApdu);\n return resp;\n }),\n );\n const timeoutObservable = of(null).pipe(\n delay(refreshInterval),\n map((_) => {\n this._logger.warn(\n \"Nanos refresh timeout, setting device status to LOCKED\",\n );\n this._updateStateFn((state) => ({\n ...state,\n deviceStatus: DeviceStatus.LOCKED,\n }));\n }),\n );\n return interval(refreshInterval + 100).pipe(\n switchMap(() => race(nanoSRefreshObservable, timeoutObservable)),\n );\n }\n\n /**\n * Maintain a device status to prevent sending APDU when the device is busy.\n *\n * @param {DeviceStatus} deviceStatus - The new device status.\n */\n setDeviceStatus(deviceStatus: DeviceStatus) {\n if (deviceStatus === DeviceStatus.NOT_CONNECTED) {\n this.stop();\n }\n this._deviceStatus = deviceStatus;\n }\n\n /**\n * Stops the session refresher.\n * The refresher will no longer send commands to refresh the session.\n */\n stop() {\n if (!this._subscription || this._subscription.closed) {\n return;\n }\n this._subscription.unsubscribe();\n this._subscription = undefined;\n }\n}\n"],
5
+ "mappings": "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",
6
6
  "names": ["DeviceSessionRefresher_exports", "__export", "DeviceSessionRefresher", "__toCommonJS", "import_inversify", "import_rxjs", "import_CommandResult", "import_GetAppAndVersionCommand", "import_GetOsVersionCommand", "import_DeviceModel", "import_DeviceStatus", "import_DeviceSessionState", "DeviceSessionRefresher", "refreshInterval", "deviceStatus", "sendApduFn", "updateStateFn", "deviceModelId", "logger", "refreshObservable", "parsedResponse", "state", "parentObservable", "rawApdu", "resp", "error", "data", "nanoSRefreshObservable", "timeoutObservable", "_", "__decorateClass"]
7
7
  }
@@ -1,2 +1,2 @@
1
- "use strict";var C=Object.defineProperty;var y=Object.getOwnPropertyDescriptor;var S=Object.getOwnPropertyNames;var T=Object.prototype.hasOwnProperty;var g=(t,e)=>{for(var n in e)C(t,n,{get:e[n],enumerable:!0})},u=(t,e,n,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let s of S(e))!T.call(t,s)&&s!==n&&C(t,s,{get:()=>e[s],enumerable:!(i=y(e,s))||i.enumerable});return t};var l=t=>u(C({},"__esModule",{value:!0}),t);var F={};g(F,{discoveryModuleFactory:()=>w});module.exports=l(F);var a=require("inversify"),r=require("../../discovery/use-case/ConnectUseCase"),U=require("../../discovery/use-case/DisconnectUseCase"),m=require("../../discovery/use-case/GetConnectedDeviceUseCase"),D=require("../../discovery/use-case/ListConnectedDevicesUseCase"),v=require("../../discovery/use-case/ListenToConnectedDeviceUseCase"),p=require("../../discovery/use-case/ListenToKnownDevicesUseCase"),f=require("../../discovery/use-case/StartDiscoveringUseCase"),L=require("../../discovery/use-case/StopDiscoveringUseCase"),c=require("../../../../src/di.stub"),o=require("./discoveryTypes");const w=({stub:t=!1})=>new a.ContainerModule((e,n,i,s)=>{e(o.discoveryTypes.ConnectUseCase).to(r.ConnectUseCase),e(o.discoveryTypes.DisconnectUseCase).to(U.DisconnectUseCase),e(o.discoveryTypes.StartDiscoveringUseCase).to(f.StartDiscoveringUseCase),e(o.discoveryTypes.StopDiscoveringUseCase).to(L.StopDiscoveringUseCase),e(o.discoveryTypes.GetConnectedDeviceUseCase).to(m.GetConnectedDeviceUseCase),e(o.discoveryTypes.ListenToKnownDevicesUseCase).to(p.ListenToKnownDevicesUseCase),e(o.discoveryTypes.ListenToConnectedDeviceUseCase).to(v.ListenToConnectedDeviceUseCase),e(o.discoveryTypes.ListConnectedDevicesUseCase).to(D.ListConnectedDevicesUseCase),t&&(s(o.discoveryTypes.StartDiscoveringUseCase).to(c.StubUseCase),s(o.discoveryTypes.StopDiscoveringUseCase).to(c.StubUseCase),s(o.discoveryTypes.ConnectUseCase).to(c.StubUseCase),s(o.discoveryTypes.DisconnectUseCase).to(c.StubUseCase),s(o.discoveryTypes.GetConnectedDeviceUseCase).to(c.StubUseCase),s(o.discoveryTypes.ListenToKnownDevicesUseCase).to(c.StubUseCase),s(o.discoveryTypes.ListenToConnectedDeviceUseCase).to(c.StubUseCase),s(o.discoveryTypes.ListConnectedDevicesUseCase).to(c.StubUseCase))});0&&(module.exports={discoveryModuleFactory});
1
+ "use strict";var C=Object.defineProperty;var L=Object.getOwnPropertyDescriptor;var y=Object.getOwnPropertyNames;var S=Object.prototype.hasOwnProperty;var T=(t,e)=>{for(var i in e)C(t,i,{get:e[i],enumerable:!0})},g=(t,e,i,a)=>{if(e&&typeof e=="object"||typeof e=="function")for(let s of y(e))!S.call(t,s)&&s!==i&&C(t,s,{get:()=>e[s],enumerable:!(a=L(e,s))||a.enumerable});return t};var u=t=>g(C({},"__esModule",{value:!0}),t);var F={};T(F,{discoveryModuleFactory:()=>A});module.exports=u(F);var n=require("inversify"),r=require("../../discovery/use-case/ConnectUseCase"),U=require("../../discovery/use-case/DisconnectUseCase"),v=require("../../discovery/use-case/GetConnectedDeviceUseCase"),m=require("../../discovery/use-case/ListConnectedDevicesUseCase"),D=require("../../discovery/use-case/ListenToAvailableDevicesUseCase"),p=require("../../discovery/use-case/ListenToConnectedDeviceUseCase"),f=require("../../discovery/use-case/StartDiscoveringUseCase"),l=require("../../discovery/use-case/StopDiscoveringUseCase"),c=require("../../../../src/di.stub"),o=require("./discoveryTypes");const A=({stub:t=!1})=>new n.ContainerModule((e,i,a,s)=>{e(o.discoveryTypes.ConnectUseCase).to(r.ConnectUseCase),e(o.discoveryTypes.DisconnectUseCase).to(U.DisconnectUseCase),e(o.discoveryTypes.StartDiscoveringUseCase).to(f.StartDiscoveringUseCase),e(o.discoveryTypes.StopDiscoveringUseCase).to(l.StopDiscoveringUseCase),e(o.discoveryTypes.GetConnectedDeviceUseCase).to(v.GetConnectedDeviceUseCase),e(o.discoveryTypes.ListenToAvailableDevicesUseCase).to(D.ListenToAvailableDevicesUseCase),e(o.discoveryTypes.ListenToConnectedDeviceUseCase).to(p.ListenToConnectedDeviceUseCase),e(o.discoveryTypes.ListConnectedDevicesUseCase).to(m.ListConnectedDevicesUseCase),t&&(s(o.discoveryTypes.StartDiscoveringUseCase).to(c.StubUseCase),s(o.discoveryTypes.StopDiscoveringUseCase).to(c.StubUseCase),s(o.discoveryTypes.ConnectUseCase).to(c.StubUseCase),s(o.discoveryTypes.DisconnectUseCase).to(c.StubUseCase),s(o.discoveryTypes.GetConnectedDeviceUseCase).to(c.StubUseCase),s(o.discoveryTypes.ListenToAvailableDevicesUseCase).to(c.StubUseCase),s(o.discoveryTypes.ListenToConnectedDeviceUseCase).to(c.StubUseCase),s(o.discoveryTypes.ListConnectedDevicesUseCase).to(c.StubUseCase))});0&&(module.exports={discoveryModuleFactory});
2
2
  //# sourceMappingURL=discoveryModule.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../../../src/internal/discovery/di/discoveryModule.ts"],
4
- "sourcesContent": ["import { ContainerModule } from \"inversify\";\n\nimport { ConnectUseCase } from \"@internal/discovery/use-case/ConnectUseCase\";\nimport { DisconnectUseCase } from \"@internal/discovery/use-case/DisconnectUseCase\";\nimport { GetConnectedDeviceUseCase } from \"@internal/discovery/use-case/GetConnectedDeviceUseCase\";\nimport { ListConnectedDevicesUseCase } from \"@internal/discovery/use-case/ListConnectedDevicesUseCase\";\nimport { ListenToConnectedDeviceUseCase } from \"@internal/discovery/use-case/ListenToConnectedDeviceUseCase\";\nimport { ListenToKnownDevicesUseCase } from \"@internal/discovery/use-case/ListenToKnownDevicesUseCase\";\nimport { StartDiscoveringUseCase } from \"@internal/discovery/use-case/StartDiscoveringUseCase\";\nimport { StopDiscoveringUseCase } from \"@internal/discovery/use-case/StopDiscoveringUseCase\";\nimport { StubUseCase } from \"@root/src/di.stub\";\n\nimport { discoveryTypes } from \"./discoveryTypes\";\n\ntype FactoryProps = {\n stub: boolean;\n};\n\nexport const discoveryModuleFactory = ({ stub = false }: FactoryProps) =>\n new ContainerModule((bind, _unbind, _isBound, rebind) => {\n bind(discoveryTypes.ConnectUseCase).to(ConnectUseCase);\n bind(discoveryTypes.DisconnectUseCase).to(DisconnectUseCase);\n bind(discoveryTypes.StartDiscoveringUseCase).to(StartDiscoveringUseCase);\n bind(discoveryTypes.StopDiscoveringUseCase).to(StopDiscoveringUseCase);\n bind(discoveryTypes.GetConnectedDeviceUseCase).to(\n GetConnectedDeviceUseCase,\n );\n bind(discoveryTypes.ListenToKnownDevicesUseCase).to(\n ListenToKnownDevicesUseCase,\n );\n bind(discoveryTypes.ListenToConnectedDeviceUseCase).to(\n ListenToConnectedDeviceUseCase,\n );\n bind(discoveryTypes.ListConnectedDevicesUseCase).to(\n ListConnectedDevicesUseCase,\n );\n\n if (stub) {\n rebind(discoveryTypes.StartDiscoveringUseCase).to(StubUseCase);\n rebind(discoveryTypes.StopDiscoveringUseCase).to(StubUseCase);\n rebind(discoveryTypes.ConnectUseCase).to(StubUseCase);\n rebind(discoveryTypes.DisconnectUseCase).to(StubUseCase);\n rebind(discoveryTypes.GetConnectedDeviceUseCase).to(StubUseCase);\n rebind(discoveryTypes.ListenToKnownDevicesUseCase).to(StubUseCase);\n rebind(discoveryTypes.ListenToConnectedDeviceUseCase).to(StubUseCase);\n rebind(discoveryTypes.ListConnectedDevicesUseCase).to(StubUseCase);\n }\n });\n"],
5
- "mappings": "yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,4BAAAE,IAAA,eAAAC,EAAAH,GAAA,IAAAI,EAAgC,qBAEhCC,EAA+B,uDAC/BC,EAAkC,0DAClCC,EAA0C,kEAC1CC,EAA4C,oEAC5CC,EAA+C,uEAC/CC,EAA4C,oEAC5CC,EAAwC,gEACxCC,EAAuC,+DACvCC,EAA4B,6BAE5BC,EAA+B,4BAMxB,MAAMZ,EAAyB,CAAC,CAAE,KAAAa,EAAO,EAAM,IACpD,IAAI,kBAAgB,CAACC,EAAMC,EAASC,EAAUC,IAAW,CACvDH,EAAK,iBAAe,cAAc,EAAE,GAAG,gBAAc,EACrDA,EAAK,iBAAe,iBAAiB,EAAE,GAAG,mBAAiB,EAC3DA,EAAK,iBAAe,uBAAuB,EAAE,GAAG,yBAAuB,EACvEA,EAAK,iBAAe,sBAAsB,EAAE,GAAG,wBAAsB,EACrEA,EAAK,iBAAe,yBAAyB,EAAE,GAC7C,2BACF,EACAA,EAAK,iBAAe,2BAA2B,EAAE,GAC/C,6BACF,EACAA,EAAK,iBAAe,8BAA8B,EAAE,GAClD,gCACF,EACAA,EAAK,iBAAe,2BAA2B,EAAE,GAC/C,6BACF,EAEID,IACFI,EAAO,iBAAe,uBAAuB,EAAE,GAAG,aAAW,EAC7DA,EAAO,iBAAe,sBAAsB,EAAE,GAAG,aAAW,EAC5DA,EAAO,iBAAe,cAAc,EAAE,GAAG,aAAW,EACpDA,EAAO,iBAAe,iBAAiB,EAAE,GAAG,aAAW,EACvDA,EAAO,iBAAe,yBAAyB,EAAE,GAAG,aAAW,EAC/DA,EAAO,iBAAe,2BAA2B,EAAE,GAAG,aAAW,EACjEA,EAAO,iBAAe,8BAA8B,EAAE,GAAG,aAAW,EACpEA,EAAO,iBAAe,2BAA2B,EAAE,GAAG,aAAW,EAErE,CAAC",
6
- "names": ["discoveryModule_exports", "__export", "discoveryModuleFactory", "__toCommonJS", "import_inversify", "import_ConnectUseCase", "import_DisconnectUseCase", "import_GetConnectedDeviceUseCase", "import_ListConnectedDevicesUseCase", "import_ListenToConnectedDeviceUseCase", "import_ListenToKnownDevicesUseCase", "import_StartDiscoveringUseCase", "import_StopDiscoveringUseCase", "import_di", "import_discoveryTypes", "stub", "bind", "_unbind", "_isBound", "rebind"]
4
+ "sourcesContent": ["import { ContainerModule } from \"inversify\";\n\nimport { ConnectUseCase } from \"@internal/discovery/use-case/ConnectUseCase\";\nimport { DisconnectUseCase } from \"@internal/discovery/use-case/DisconnectUseCase\";\nimport { GetConnectedDeviceUseCase } from \"@internal/discovery/use-case/GetConnectedDeviceUseCase\";\nimport { ListConnectedDevicesUseCase } from \"@internal/discovery/use-case/ListConnectedDevicesUseCase\";\nimport { ListenToAvailableDevicesUseCase } from \"@internal/discovery/use-case/ListenToAvailableDevicesUseCase\";\nimport { ListenToConnectedDeviceUseCase } from \"@internal/discovery/use-case/ListenToConnectedDeviceUseCase\";\nimport { StartDiscoveringUseCase } from \"@internal/discovery/use-case/StartDiscoveringUseCase\";\nimport { StopDiscoveringUseCase } from \"@internal/discovery/use-case/StopDiscoveringUseCase\";\nimport { StubUseCase } from \"@root/src/di.stub\";\n\nimport { discoveryTypes } from \"./discoveryTypes\";\n\ntype FactoryProps = {\n stub: boolean;\n};\n\nexport const discoveryModuleFactory = ({ stub = false }: FactoryProps) =>\n new ContainerModule((bind, _unbind, _isBound, rebind) => {\n bind(discoveryTypes.ConnectUseCase).to(ConnectUseCase);\n bind(discoveryTypes.DisconnectUseCase).to(DisconnectUseCase);\n bind(discoveryTypes.StartDiscoveringUseCase).to(StartDiscoveringUseCase);\n bind(discoveryTypes.StopDiscoveringUseCase).to(StopDiscoveringUseCase);\n bind(discoveryTypes.GetConnectedDeviceUseCase).to(\n GetConnectedDeviceUseCase,\n );\n bind(discoveryTypes.ListenToAvailableDevicesUseCase).to(\n ListenToAvailableDevicesUseCase,\n );\n bind(discoveryTypes.ListenToConnectedDeviceUseCase).to(\n ListenToConnectedDeviceUseCase,\n );\n bind(discoveryTypes.ListConnectedDevicesUseCase).to(\n ListConnectedDevicesUseCase,\n );\n\n if (stub) {\n rebind(discoveryTypes.StartDiscoveringUseCase).to(StubUseCase);\n rebind(discoveryTypes.StopDiscoveringUseCase).to(StubUseCase);\n rebind(discoveryTypes.ConnectUseCase).to(StubUseCase);\n rebind(discoveryTypes.DisconnectUseCase).to(StubUseCase);\n rebind(discoveryTypes.GetConnectedDeviceUseCase).to(StubUseCase);\n rebind(discoveryTypes.ListenToAvailableDevicesUseCase).to(StubUseCase);\n rebind(discoveryTypes.ListenToConnectedDeviceUseCase).to(StubUseCase);\n rebind(discoveryTypes.ListConnectedDevicesUseCase).to(StubUseCase);\n }\n });\n"],
5
+ "mappings": "yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,4BAAAE,IAAA,eAAAC,EAAAH,GAAA,IAAAI,EAAgC,qBAEhCC,EAA+B,uDAC/BC,EAAkC,0DAClCC,EAA0C,kEAC1CC,EAA4C,oEAC5CC,EAAgD,wEAChDC,EAA+C,uEAC/CC,EAAwC,gEACxCC,EAAuC,+DACvCC,EAA4B,6BAE5BC,EAA+B,4BAMxB,MAAMZ,EAAyB,CAAC,CAAE,KAAAa,EAAO,EAAM,IACpD,IAAI,kBAAgB,CAACC,EAAMC,EAASC,EAAUC,IAAW,CACvDH,EAAK,iBAAe,cAAc,EAAE,GAAG,gBAAc,EACrDA,EAAK,iBAAe,iBAAiB,EAAE,GAAG,mBAAiB,EAC3DA,EAAK,iBAAe,uBAAuB,EAAE,GAAG,yBAAuB,EACvEA,EAAK,iBAAe,sBAAsB,EAAE,GAAG,wBAAsB,EACrEA,EAAK,iBAAe,yBAAyB,EAAE,GAC7C,2BACF,EACAA,EAAK,iBAAe,+BAA+B,EAAE,GACnD,iCACF,EACAA,EAAK,iBAAe,8BAA8B,EAAE,GAClD,gCACF,EACAA,EAAK,iBAAe,2BAA2B,EAAE,GAC/C,6BACF,EAEID,IACFI,EAAO,iBAAe,uBAAuB,EAAE,GAAG,aAAW,EAC7DA,EAAO,iBAAe,sBAAsB,EAAE,GAAG,aAAW,EAC5DA,EAAO,iBAAe,cAAc,EAAE,GAAG,aAAW,EACpDA,EAAO,iBAAe,iBAAiB,EAAE,GAAG,aAAW,EACvDA,EAAO,iBAAe,yBAAyB,EAAE,GAAG,aAAW,EAC/DA,EAAO,iBAAe,+BAA+B,EAAE,GAAG,aAAW,EACrEA,EAAO,iBAAe,8BAA8B,EAAE,GAAG,aAAW,EACpEA,EAAO,iBAAe,2BAA2B,EAAE,GAAG,aAAW,EAErE,CAAC",
6
+ "names": ["discoveryModule_exports", "__export", "discoveryModuleFactory", "__toCommonJS", "import_inversify", "import_ConnectUseCase", "import_DisconnectUseCase", "import_GetConnectedDeviceUseCase", "import_ListConnectedDevicesUseCase", "import_ListenToAvailableDevicesUseCase", "import_ListenToConnectedDeviceUseCase", "import_StartDiscoveringUseCase", "import_StopDiscoveringUseCase", "import_di", "import_discoveryTypes", "stub", "bind", "_unbind", "_isBound", "rebind"]
7
7
  }
@@ -1,2 +1,2 @@
1
- "use strict";var r=require("inversify"),n=require("../../../api/transport/model/__mocks__/TransportMock"),c=require("../../device-model/di/deviceModelModule"),i=require("../../device-session/di/deviceSessionModule"),a=require("../../discovery/use-case/ConnectUseCase"),m=require("../../discovery/use-case/DisconnectUseCase"),p=require("../../discovery/use-case/ListConnectedDevicesUseCase"),f=require("../../discovery/use-case/ListenToKnownDevicesUseCase"),l=require("../../discovery/use-case/StartDiscoveringUseCase"),d=require("../../discovery/use-case/StopDiscoveringUseCase"),C=require("../../logger-publisher/di/loggerModule"),u=require("../../manager-api/di/managerApiModule"),g=require("../../secure-channel/di/secureChannelModule"),U=require("../../transport/di/transportModule"),v=require("./discoveryModule"),o=require("./discoveryTypes");describe("discoveryModuleFactory",()=>{let e,t,s;beforeEach(()=>{t=(0,v.discoveryModuleFactory)({stub:!1}),e=new r.Container,s=new n.TransportMock,e.load(t,(0,C.loggerModuleFactory)(),(0,c.deviceModelModuleFactory)({stub:!1}),(0,i.deviceSessionModuleFactory)(),(0,U.transportModuleFactory)({transports:[vi.fn().mockImplementation(()=>s)]}),(0,u.managerApiModuleFactory)({config:{managerApiUrl:"http://fake.url",mockUrl:"http://fake-mock.url"}}),(0,g.secureChannelModuleFactory)({config:{webSocketUrl:"http://fake-websocket.url"}}))}),it("should return the device module",()=>{expect(t).toBeDefined()}),it("should return none mocked use cases",()=>{const y=e.get(o.discoveryTypes.StartDiscoveringUseCase);expect(y).toBeInstanceOf(l.StartDiscoveringUseCase);const D=e.get(o.discoveryTypes.StopDiscoveringUseCase);expect(D).toBeInstanceOf(d.StopDiscoveringUseCase);const k=e.get(o.discoveryTypes.DisconnectUseCase);expect(k).toBeInstanceOf(m.DisconnectUseCase);const M=e.get(o.discoveryTypes.ConnectUseCase);expect(M).toBeInstanceOf(a.ConnectUseCase);const F=e.get(o.discoveryTypes.ListenToKnownDevicesUseCase);expect(F).toBeInstanceOf(f.ListenToKnownDevicesUseCase);const h=e.get(o.discoveryTypes.ListConnectedDevicesUseCase);expect(h).toBeInstanceOf(p.ListConnectedDevicesUseCase)})});
1
+ "use strict";var r=require("inversify"),n=require("../../../api/transport/model/__mocks__/TransportMock"),c=require("../../device-model/di/deviceModelModule"),i=require("../../device-session/di/deviceSessionModule"),a=require("../../discovery/use-case/ConnectUseCase"),m=require("../../discovery/use-case/DisconnectUseCase"),p=require("../../discovery/use-case/ListConnectedDevicesUseCase"),f=require("../../discovery/use-case/ListenToAvailableDevicesUseCase"),l=require("../../discovery/use-case/StartDiscoveringUseCase"),d=require("../../discovery/use-case/StopDiscoveringUseCase"),C=require("../../logger-publisher/di/loggerModule"),v=require("../../manager-api/di/managerApiModule"),u=require("../../secure-channel/di/secureChannelModule"),g=require("../../transport/di/transportModule"),U=require("./discoveryModule"),o=require("./discoveryTypes");describe("discoveryModuleFactory",()=>{let e,t,s;beforeEach(()=>{t=(0,U.discoveryModuleFactory)({stub:!1}),e=new r.Container,s=new n.TransportMock,e.load(t,(0,C.loggerModuleFactory)(),(0,c.deviceModelModuleFactory)({stub:!1}),(0,i.deviceSessionModuleFactory)(),(0,g.transportModuleFactory)({transports:[vi.fn().mockImplementation(()=>s)]}),(0,v.managerApiModuleFactory)({config:{managerApiUrl:"http://fake.url",mockUrl:"http://fake-mock.url"}}),(0,u.secureChannelModuleFactory)({config:{webSocketUrl:"http://fake-websocket.url"}}))}),it("should return the device module",()=>{expect(t).toBeDefined()}),it("should return none mocked use cases",()=>{const y=e.get(o.discoveryTypes.StartDiscoveringUseCase);expect(y).toBeInstanceOf(l.StartDiscoveringUseCase);const D=e.get(o.discoveryTypes.StopDiscoveringUseCase);expect(D).toBeInstanceOf(d.StopDiscoveringUseCase);const k=e.get(o.discoveryTypes.DisconnectUseCase);expect(k).toBeInstanceOf(m.DisconnectUseCase);const M=e.get(o.discoveryTypes.ConnectUseCase);expect(M).toBeInstanceOf(a.ConnectUseCase);const b=e.get(o.discoveryTypes.ListenToAvailableDevicesUseCase);expect(b).toBeInstanceOf(f.ListenToAvailableDevicesUseCase);const F=e.get(o.discoveryTypes.ListConnectedDevicesUseCase);expect(F).toBeInstanceOf(p.ListConnectedDevicesUseCase)})});
2
2
  //# sourceMappingURL=discoveryModule.test.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../../../src/internal/discovery/di/discoveryModule.test.ts"],
4
- "sourcesContent": ["import { Container } from \"inversify\";\n\nimport { TransportMock } from \"@api/transport/model/__mocks__/TransportMock\";\nimport { type DmkConfig, type Transport } from \"@api/types\";\nimport { deviceModelModuleFactory } from \"@internal/device-model/di/deviceModelModule\";\nimport { deviceSessionModuleFactory } from \"@internal/device-session/di/deviceSessionModule\";\nimport { ConnectUseCase } from \"@internal/discovery/use-case/ConnectUseCase\";\nimport { DisconnectUseCase } from \"@internal/discovery/use-case/DisconnectUseCase\";\nimport { ListConnectedDevicesUseCase } from \"@internal/discovery/use-case/ListConnectedDevicesUseCase\";\nimport { ListenToKnownDevicesUseCase } from \"@internal/discovery/use-case/ListenToKnownDevicesUseCase\";\nimport { StartDiscoveringUseCase } from \"@internal/discovery/use-case/StartDiscoveringUseCase\";\nimport { StopDiscoveringUseCase } from \"@internal/discovery/use-case/StopDiscoveringUseCase\";\nimport { loggerModuleFactory } from \"@internal/logger-publisher/di/loggerModule\";\nimport { managerApiModuleFactory } from \"@internal/manager-api/di/managerApiModule\";\nimport { secureChannelModuleFactory } from \"@internal/secure-channel/di/secureChannelModule\";\nimport { transportModuleFactory } from \"@internal/transport/di/transportModule\";\n\nimport { discoveryModuleFactory } from \"./discoveryModule\";\nimport { discoveryTypes } from \"./discoveryTypes\";\n\ndescribe(\"discoveryModuleFactory\", () => {\n let container: Container;\n let mod: ReturnType<typeof discoveryModuleFactory>;\n let transport: Transport;\n beforeEach(() => {\n mod = discoveryModuleFactory({ stub: false });\n container = new Container();\n transport = new TransportMock();\n\n container.load(\n mod,\n // The following modules are injected into discovery module\n loggerModuleFactory(),\n deviceModelModuleFactory({ stub: false }),\n deviceSessionModuleFactory(),\n transportModuleFactory({\n transports: [vi.fn().mockImplementation(() => transport)],\n }),\n managerApiModuleFactory({\n config: {\n managerApiUrl: \"http://fake.url\",\n mockUrl: \"http://fake-mock.url\",\n } as DmkConfig,\n }),\n secureChannelModuleFactory({\n config: {\n webSocketUrl: \"http://fake-websocket.url\",\n } as DmkConfig,\n }),\n );\n });\n it(\"should return the device module\", () => {\n expect(mod).toBeDefined();\n });\n\n it(\"should return none mocked use cases\", () => {\n const startDiscoveringUseCase = container.get(\n discoveryTypes.StartDiscoveringUseCase,\n );\n expect(startDiscoveringUseCase).toBeInstanceOf(StartDiscoveringUseCase);\n\n const stopDiscoveringUseCase = container.get(\n discoveryTypes.StopDiscoveringUseCase,\n );\n expect(stopDiscoveringUseCase).toBeInstanceOf(StopDiscoveringUseCase);\n\n const disconnectUseCase = container.get(discoveryTypes.DisconnectUseCase);\n expect(disconnectUseCase).toBeInstanceOf(DisconnectUseCase);\n\n const connectUseCase = container.get(discoveryTypes.ConnectUseCase);\n expect(connectUseCase).toBeInstanceOf(ConnectUseCase);\n\n const listenToKnownDevicesUseCase = container.get(\n discoveryTypes.ListenToKnownDevicesUseCase,\n );\n expect(listenToKnownDevicesUseCase).toBeInstanceOf(\n ListenToKnownDevicesUseCase,\n );\n const listConnectedDevicesUseCase = container.get(\n discoveryTypes.ListConnectedDevicesUseCase,\n );\n expect(listConnectedDevicesUseCase).toBeInstanceOf(\n ListConnectedDevicesUseCase,\n );\n });\n});\n"],
5
- "mappings": "aAAA,IAAAA,EAA0B,qBAE1BC,EAA8B,wDAE9BC,EAAyC,uDACzCC,EAA2C,2DAC3CC,EAA+B,uDAC/BC,EAAkC,0DAClCC,EAA4C,oEAC5CC,EAA4C,oEAC5CC,EAAwC,gEACxCC,EAAuC,+DACvCC,EAAoC,sDACpCC,EAAwC,qDACxCC,EAA2C,2DAC3CC,EAAuC,kDAEvCC,EAAuC,6BACvCC,EAA+B,4BAE/B,SAAS,yBAA0B,IAAM,CACvC,IAAIC,EACAC,EACAC,EACJ,WAAW,IAAM,CACfD,KAAM,0BAAuB,CAAE,KAAM,EAAM,CAAC,EAC5CD,EAAY,IAAI,YAChBE,EAAY,IAAI,gBAEhBF,EAAU,KACRC,KAEA,uBAAoB,KACpB,4BAAyB,CAAE,KAAM,EAAM,CAAC,KACxC,8BAA2B,KAC3B,0BAAuB,CACrB,WAAY,CAAC,GAAG,GAAG,EAAE,mBAAmB,IAAMC,CAAS,CAAC,CAC1D,CAAC,KACD,2BAAwB,CACtB,OAAQ,CACN,cAAe,kBACf,QAAS,sBACX,CACF,CAAC,KACD,8BAA2B,CACzB,OAAQ,CACN,aAAc,2BAChB,CACF,CAAC,CACH,CACF,CAAC,EACD,GAAG,kCAAmC,IAAM,CAC1C,OAAOD,CAAG,EAAE,YAAY,CAC1B,CAAC,EAED,GAAG,sCAAuC,IAAM,CAC9C,MAAME,EAA0BH,EAAU,IACxC,iBAAe,uBACjB,EACA,OAAOG,CAAuB,EAAE,eAAe,yBAAuB,EAEtE,MAAMC,EAAyBJ,EAAU,IACvC,iBAAe,sBACjB,EACA,OAAOI,CAAsB,EAAE,eAAe,wBAAsB,EAEpE,MAAMC,EAAoBL,EAAU,IAAI,iBAAe,iBAAiB,EACxE,OAAOK,CAAiB,EAAE,eAAe,mBAAiB,EAE1D,MAAMC,EAAiBN,EAAU,IAAI,iBAAe,cAAc,EAClE,OAAOM,CAAc,EAAE,eAAe,gBAAc,EAEpD,MAAMC,EAA8BP,EAAU,IAC5C,iBAAe,2BACjB,EACA,OAAOO,CAA2B,EAAE,eAClC,6BACF,EACA,MAAMC,EAA8BR,EAAU,IAC5C,iBAAe,2BACjB,EACA,OAAOQ,CAA2B,EAAE,eAClC,6BACF,CACF,CAAC,CACH,CAAC",
6
- "names": ["import_inversify", "import_TransportMock", "import_deviceModelModule", "import_deviceSessionModule", "import_ConnectUseCase", "import_DisconnectUseCase", "import_ListConnectedDevicesUseCase", "import_ListenToKnownDevicesUseCase", "import_StartDiscoveringUseCase", "import_StopDiscoveringUseCase", "import_loggerModule", "import_managerApiModule", "import_secureChannelModule", "import_transportModule", "import_discoveryModule", "import_discoveryTypes", "container", "mod", "transport", "startDiscoveringUseCase", "stopDiscoveringUseCase", "disconnectUseCase", "connectUseCase", "listenToKnownDevicesUseCase", "listConnectedDevicesUseCase"]
4
+ "sourcesContent": ["import { Container } from \"inversify\";\n\nimport { TransportMock } from \"@api/transport/model/__mocks__/TransportMock\";\nimport { type DmkConfig, type Transport } from \"@api/types\";\nimport { deviceModelModuleFactory } from \"@internal/device-model/di/deviceModelModule\";\nimport { deviceSessionModuleFactory } from \"@internal/device-session/di/deviceSessionModule\";\nimport { ConnectUseCase } from \"@internal/discovery/use-case/ConnectUseCase\";\nimport { DisconnectUseCase } from \"@internal/discovery/use-case/DisconnectUseCase\";\nimport { ListConnectedDevicesUseCase } from \"@internal/discovery/use-case/ListConnectedDevicesUseCase\";\nimport { ListenToAvailableDevicesUseCase } from \"@internal/discovery/use-case/ListenToAvailableDevicesUseCase\";\nimport { StartDiscoveringUseCase } from \"@internal/discovery/use-case/StartDiscoveringUseCase\";\nimport { StopDiscoveringUseCase } from \"@internal/discovery/use-case/StopDiscoveringUseCase\";\nimport { loggerModuleFactory } from \"@internal/logger-publisher/di/loggerModule\";\nimport { managerApiModuleFactory } from \"@internal/manager-api/di/managerApiModule\";\nimport { secureChannelModuleFactory } from \"@internal/secure-channel/di/secureChannelModule\";\nimport { transportModuleFactory } from \"@internal/transport/di/transportModule\";\n\nimport { discoveryModuleFactory } from \"./discoveryModule\";\nimport { discoveryTypes } from \"./discoveryTypes\";\n\ndescribe(\"discoveryModuleFactory\", () => {\n let container: Container;\n let mod: ReturnType<typeof discoveryModuleFactory>;\n let transport: Transport;\n beforeEach(() => {\n mod = discoveryModuleFactory({ stub: false });\n container = new Container();\n transport = new TransportMock();\n\n container.load(\n mod,\n // The following modules are injected into discovery module\n loggerModuleFactory(),\n deviceModelModuleFactory({ stub: false }),\n deviceSessionModuleFactory(),\n transportModuleFactory({\n transports: [vi.fn().mockImplementation(() => transport)],\n }),\n managerApiModuleFactory({\n config: {\n managerApiUrl: \"http://fake.url\",\n mockUrl: \"http://fake-mock.url\",\n } as DmkConfig,\n }),\n secureChannelModuleFactory({\n config: {\n webSocketUrl: \"http://fake-websocket.url\",\n } as DmkConfig,\n }),\n );\n });\n it(\"should return the device module\", () => {\n expect(mod).toBeDefined();\n });\n\n it(\"should return none mocked use cases\", () => {\n const startDiscoveringUseCase = container.get(\n discoveryTypes.StartDiscoveringUseCase,\n );\n expect(startDiscoveringUseCase).toBeInstanceOf(StartDiscoveringUseCase);\n\n const stopDiscoveringUseCase = container.get(\n discoveryTypes.StopDiscoveringUseCase,\n );\n expect(stopDiscoveringUseCase).toBeInstanceOf(StopDiscoveringUseCase);\n\n const disconnectUseCase = container.get(discoveryTypes.DisconnectUseCase);\n expect(disconnectUseCase).toBeInstanceOf(DisconnectUseCase);\n\n const connectUseCase = container.get(discoveryTypes.ConnectUseCase);\n expect(connectUseCase).toBeInstanceOf(ConnectUseCase);\n\n const listenToAvailableDevicesUseCase = container.get(\n discoveryTypes.ListenToAvailableDevicesUseCase,\n );\n expect(listenToAvailableDevicesUseCase).toBeInstanceOf(\n ListenToAvailableDevicesUseCase,\n );\n const listConnectedDevicesUseCase = container.get(\n discoveryTypes.ListConnectedDevicesUseCase,\n );\n expect(listConnectedDevicesUseCase).toBeInstanceOf(\n ListConnectedDevicesUseCase,\n );\n });\n});\n"],
5
+ "mappings": "aAAA,IAAAA,EAA0B,qBAE1BC,EAA8B,wDAE9BC,EAAyC,uDACzCC,EAA2C,2DAC3CC,EAA+B,uDAC/BC,EAAkC,0DAClCC,EAA4C,oEAC5CC,EAAgD,wEAChDC,EAAwC,gEACxCC,EAAuC,+DACvCC,EAAoC,sDACpCC,EAAwC,qDACxCC,EAA2C,2DAC3CC,EAAuC,kDAEvCC,EAAuC,6BACvCC,EAA+B,4BAE/B,SAAS,yBAA0B,IAAM,CACvC,IAAIC,EACAC,EACAC,EACJ,WAAW,IAAM,CACfD,KAAM,0BAAuB,CAAE,KAAM,EAAM,CAAC,EAC5CD,EAAY,IAAI,YAChBE,EAAY,IAAI,gBAEhBF,EAAU,KACRC,KAEA,uBAAoB,KACpB,4BAAyB,CAAE,KAAM,EAAM,CAAC,KACxC,8BAA2B,KAC3B,0BAAuB,CACrB,WAAY,CAAC,GAAG,GAAG,EAAE,mBAAmB,IAAMC,CAAS,CAAC,CAC1D,CAAC,KACD,2BAAwB,CACtB,OAAQ,CACN,cAAe,kBACf,QAAS,sBACX,CACF,CAAC,KACD,8BAA2B,CACzB,OAAQ,CACN,aAAc,2BAChB,CACF,CAAC,CACH,CACF,CAAC,EACD,GAAG,kCAAmC,IAAM,CAC1C,OAAOD,CAAG,EAAE,YAAY,CAC1B,CAAC,EAED,GAAG,sCAAuC,IAAM,CAC9C,MAAME,EAA0BH,EAAU,IACxC,iBAAe,uBACjB,EACA,OAAOG,CAAuB,EAAE,eAAe,yBAAuB,EAEtE,MAAMC,EAAyBJ,EAAU,IACvC,iBAAe,sBACjB,EACA,OAAOI,CAAsB,EAAE,eAAe,wBAAsB,EAEpE,MAAMC,EAAoBL,EAAU,IAAI,iBAAe,iBAAiB,EACxE,OAAOK,CAAiB,EAAE,eAAe,mBAAiB,EAE1D,MAAMC,EAAiBN,EAAU,IAAI,iBAAe,cAAc,EAClE,OAAOM,CAAc,EAAE,eAAe,gBAAc,EAEpD,MAAMC,EAAkCP,EAAU,IAChD,iBAAe,+BACjB,EACA,OAAOO,CAA+B,EAAE,eACtC,iCACF,EACA,MAAMC,EAA8BR,EAAU,IAC5C,iBAAe,2BACjB,EACA,OAAOQ,CAA2B,EAAE,eAClC,6BACF,CACF,CAAC,CACH,CAAC",
6
+ "names": ["import_inversify", "import_TransportMock", "import_deviceModelModule", "import_deviceSessionModule", "import_ConnectUseCase", "import_DisconnectUseCase", "import_ListConnectedDevicesUseCase", "import_ListenToAvailableDevicesUseCase", "import_StartDiscoveringUseCase", "import_StopDiscoveringUseCase", "import_loggerModule", "import_managerApiModule", "import_secureChannelModule", "import_transportModule", "import_discoveryModule", "import_discoveryTypes", "container", "mod", "transport", "startDiscoveringUseCase", "stopDiscoveringUseCase", "disconnectUseCase", "connectUseCase", "listenToAvailableDevicesUseCase", "listConnectedDevicesUseCase"]
7
7
  }
@@ -1,2 +1,2 @@
1
- "use strict";var c=Object.defineProperty;var i=Object.getOwnPropertyDescriptor;var C=Object.getOwnPropertyNames;var a=Object.prototype.hasOwnProperty;var r=(s,e)=>{for(var n in e)c(s,n,{get:e[n],enumerable:!0})},U=(s,e,n,t)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of C(e))!a.call(s,o)&&o!==n&&c(s,o,{get:()=>e[o],enumerable:!(t=i(e,o))||t.enumerable});return s};var D=s=>U(c({},"__esModule",{value:!0}),s);var S={};r(S,{discoveryTypes:()=>v});module.exports=D(S);const v={StartDiscoveringUseCase:Symbol.for("StartDiscoveringUseCase"),StopDiscoveringUseCase:Symbol.for("StopDiscoveringUseCase"),ConnectUseCase:Symbol.for("ConnectUseCase"),DisconnectUseCase:Symbol.for("DisconnectUseCase"),GetConnectedDeviceUseCase:Symbol.for("GetConnectedDeviceUseCase"),ListenToKnownDevicesUseCase:Symbol.for("ListenToKnownDevicesUseCase"),ListenToConnectedDeviceUseCase:Symbol.for("ListenToConnectedDeviceUseCase"),ListConnectedDevicesUseCase:Symbol.for("ListConnectedDevicesUseCase")};0&&(module.exports={discoveryTypes});
1
+ "use strict";var i=Object.defineProperty;var t=Object.getOwnPropertyDescriptor;var C=Object.getOwnPropertyNames;var a=Object.prototype.hasOwnProperty;var r=(s,e)=>{for(var n in e)i(s,n,{get:e[n],enumerable:!0})},U=(s,e,n,c)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of C(e))!a.call(s,o)&&o!==n&&i(s,o,{get:()=>e[o],enumerable:!(c=t(e,o))||c.enumerable});return s};var v=s=>U(i({},"__esModule",{value:!0}),s);var l={};r(l,{discoveryTypes:()=>D});module.exports=v(l);const D={StartDiscoveringUseCase:Symbol.for("StartDiscoveringUseCase"),StopDiscoveringUseCase:Symbol.for("StopDiscoveringUseCase"),ConnectUseCase:Symbol.for("ConnectUseCase"),DisconnectUseCase:Symbol.for("DisconnectUseCase"),GetConnectedDeviceUseCase:Symbol.for("GetConnectedDeviceUseCase"),ListenToAvailableDevicesUseCase:Symbol.for("ListenToAvailableDevicesUseCase"),ListenToConnectedDeviceUseCase:Symbol.for("ListenToConnectedDeviceUseCase"),ListConnectedDevicesUseCase:Symbol.for("ListConnectedDevicesUseCase")};0&&(module.exports={discoveryTypes});
2
2
  //# sourceMappingURL=discoveryTypes.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../../../src/internal/discovery/di/discoveryTypes.ts"],
4
- "sourcesContent": ["export const discoveryTypes = {\n StartDiscoveringUseCase: Symbol.for(\"StartDiscoveringUseCase\"),\n StopDiscoveringUseCase: Symbol.for(\"StopDiscoveringUseCase\"),\n ConnectUseCase: Symbol.for(\"ConnectUseCase\"),\n DisconnectUseCase: Symbol.for(\"DisconnectUseCase\"),\n GetConnectedDeviceUseCase: Symbol.for(\"GetConnectedDeviceUseCase\"),\n ListenToKnownDevicesUseCase: Symbol.for(\"ListenToKnownDevicesUseCase\"),\n ListenToConnectedDeviceUseCase: Symbol.for(\"ListenToConnectedDeviceUseCase\"),\n ListConnectedDevicesUseCase: Symbol.for(\"ListConnectedDevicesUseCase\"),\n};\n"],
5
- "mappings": "yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,oBAAAE,IAAA,eAAAC,EAAAH,GAAO,MAAME,EAAiB,CAC5B,wBAAyB,OAAO,IAAI,yBAAyB,EAC7D,uBAAwB,OAAO,IAAI,wBAAwB,EAC3D,eAAgB,OAAO,IAAI,gBAAgB,EAC3C,kBAAmB,OAAO,IAAI,mBAAmB,EACjD,0BAA2B,OAAO,IAAI,2BAA2B,EACjE,4BAA6B,OAAO,IAAI,6BAA6B,EACrE,+BAAgC,OAAO,IAAI,gCAAgC,EAC3E,4BAA6B,OAAO,IAAI,6BAA6B,CACvE",
4
+ "sourcesContent": ["export const discoveryTypes = {\n StartDiscoveringUseCase: Symbol.for(\"StartDiscoveringUseCase\"),\n StopDiscoveringUseCase: Symbol.for(\"StopDiscoveringUseCase\"),\n ConnectUseCase: Symbol.for(\"ConnectUseCase\"),\n DisconnectUseCase: Symbol.for(\"DisconnectUseCase\"),\n GetConnectedDeviceUseCase: Symbol.for(\"GetConnectedDeviceUseCase\"),\n ListenToAvailableDevicesUseCase: Symbol.for(\n \"ListenToAvailableDevicesUseCase\",\n ),\n ListenToConnectedDeviceUseCase: Symbol.for(\"ListenToConnectedDeviceUseCase\"),\n ListConnectedDevicesUseCase: Symbol.for(\"ListConnectedDevicesUseCase\"),\n};\n"],
5
+ "mappings": "yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,oBAAAE,IAAA,eAAAC,EAAAH,GAAO,MAAME,EAAiB,CAC5B,wBAAyB,OAAO,IAAI,yBAAyB,EAC7D,uBAAwB,OAAO,IAAI,wBAAwB,EAC3D,eAAgB,OAAO,IAAI,gBAAgB,EAC3C,kBAAmB,OAAO,IAAI,mBAAmB,EACjD,0BAA2B,OAAO,IAAI,2BAA2B,EACjE,gCAAiC,OAAO,IACtC,iCACF,EACA,+BAAgC,OAAO,IAAI,gCAAgC,EAC3E,4BAA6B,OAAO,IAAI,6BAA6B,CACvE",
6
6
  "names": ["discoveryTypes_exports", "__export", "discoveryTypes", "__toCommonJS"]
7
7
  }
@@ -1,2 +1,2 @@
1
- "use strict";var e=require("purify-ts"),l=require("../../../api/transport/model/__mocks__/TransportMock"),s=require("../../../api/transport/model/Errors"),S=require("../../../api/transport/model/TransportConnectedDevice.stub"),D=require("../../device-session/service/DefaultDeviceSessionService"),g=require("../../logger-publisher/service/DefaultLoggerPublisherService"),d=require("../../manager-api/data/AxiosManagerApiDataSource"),y=require("../../manager-api/service/DefaultManagerApiService"),k=require("../../secure-channel/data/DefaultSecureChannelDataSource"),C=require("../../secure-channel/service/DefaultSecureChannelService"),w=require("../../transport/service/DefaultTransportService"),p=require("./ConnectUseCase");vi.mock("uuid",()=>({v4:vi.fn().mockReturnValue("fakeSessionId")}));vi.mock("@internal/manager-api/data/AxiosManagerApiDataSource");vi.mock("@internal/transport/service/DefaultTransportService");let o,t,n,r,c,u,f,a;const M="fakeSessionId";describe("ConnectUseCase",()=>{const m={id:"",deviceModel:{},transport:"USB"},A=(0,S.connectedDeviceStubBuilder)({id:"1"}),h="logger-tag";beforeAll(()=>{n=new g.DefaultLoggerPublisherService([],h),o=new l.TransportMock,r=new D.DefaultDeviceSessionService(()=>n),u=new d.AxiosManagerApiDataSource({}),c=new y.DefaultManagerApiService(u),f=new k.DefaultSecureChannelDataSource({}),a=new C.DefaultSecureChannelService(f),t=new w.DefaultTransportService}),afterEach(()=>{for(const i of r.getDeviceSessions())r.removeDeviceSession(i.id)}),afterAll(()=>{vi.restoreAllMocks()}),test("If connect use case encounter an error, return it",async()=>{vi.spyOn(o,"connect").mockResolvedValue((0,e.Left)(new s.UnknownDeviceError)),vi.spyOn(t,"getTransport").mockReturnValue(e.Maybe.of(o));const i=new p.ConnectUseCase(t,r,()=>n,c,a);await expect(i.execute({device:m})).rejects.toBeInstanceOf(s.UnknownDeviceError)}),test("If connect is in success, return a deviceSession id",async()=>{vi.spyOn(o,"connect").mockResolvedValue((0,e.Right)(A)),vi.spyOn(t,"getTransport").mockReturnValue(e.Maybe.of(o));const v=await new p.ConnectUseCase(t,r,()=>n,c,a).execute({device:m});expect(v).toBe(M),r.removeDeviceSession(v)})});
1
+ "use strict";var e=require("purify-ts"),l=require("../../../api/transport/model/__mocks__/TransportMock"),s=require("../../../api/transport/model/Errors"),S=require("../../../api/transport/model/TransportConnectedDevice.stub"),D=require("../../device-session/service/DefaultDeviceSessionService"),g=require("../../logger-publisher/service/DefaultLoggerPublisherService"),d=require("../../manager-api/data/AxiosManagerApiDataSource"),y=require("../../manager-api/service/DefaultManagerApiService"),k=require("../../secure-channel/data/DefaultSecureChannelDataSource"),C=require("../../secure-channel/service/DefaultSecureChannelService"),w=require("../../transport/service/DefaultTransportService"),p=require("./ConnectUseCase");vi.mock("uuid",()=>({v4:vi.fn().mockReturnValue("fakeSessionId")}));vi.mock("@internal/manager-api/data/AxiosManagerApiDataSource");vi.mock("@internal/transport/service/DefaultTransportService");let o,t,n,r,a,u,f,c;const M="fakeSessionId";describe("ConnectUseCase",()=>{const m={id:"",deviceModel:{},transport:"USB",name:"TEST"},A=(0,S.connectedDeviceStubBuilder)({id:"1"}),h="logger-tag";beforeAll(()=>{n=new g.DefaultLoggerPublisherService([],h),o=new l.TransportMock,r=new D.DefaultDeviceSessionService(()=>n),u=new d.AxiosManagerApiDataSource({}),a=new y.DefaultManagerApiService(u),f=new k.DefaultSecureChannelDataSource({}),c=new C.DefaultSecureChannelService(f),t=new w.DefaultTransportService}),afterEach(()=>{for(const i of r.getDeviceSessions())r.removeDeviceSession(i.id)}),afterAll(()=>{vi.restoreAllMocks()}),test("If connect use case encounter an error, return it",async()=>{vi.spyOn(o,"connect").mockResolvedValue((0,e.Left)(new s.UnknownDeviceError)),vi.spyOn(t,"getTransport").mockReturnValue(e.Maybe.of(o));const i=new p.ConnectUseCase(t,r,()=>n,a,c);await expect(i.execute({device:m})).rejects.toBeInstanceOf(s.UnknownDeviceError)}),test("If connect is in success, return a deviceSession id",async()=>{vi.spyOn(o,"connect").mockResolvedValue((0,e.Right)(A)),vi.spyOn(t,"getTransport").mockReturnValue(e.Maybe.of(o));const v=await new p.ConnectUseCase(t,r,()=>n,a,c).execute({device:m});expect(v).toBe(M),r.removeDeviceSession(v)})});
2
2
  //# sourceMappingURL=ConnectUseCase.test.js.map