@ledgerhq/device-management-kit 0.6.0 → 0.6.2

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 (647) hide show
  1. package/lib/cjs/index.js.map +1 -1
  2. package/lib/cjs/package.json +11 -10
  3. package/lib/cjs/src/api/DeviceManagementKit.js +1 -1
  4. package/lib/cjs/src/api/DeviceManagementKit.js.map +2 -2
  5. package/lib/cjs/src/api/DeviceManagementKit.test.js +1 -1
  6. package/lib/cjs/src/api/DeviceManagementKit.test.js.map +2 -2
  7. package/lib/cjs/src/api/DeviceManagementKitBuilder.js +1 -1
  8. package/lib/cjs/src/api/DeviceManagementKitBuilder.js.map +2 -2
  9. package/lib/cjs/src/api/DeviceManagementKitBuilder.test.js +1 -1
  10. package/lib/cjs/src/api/DeviceManagementKitBuilder.test.js.map +2 -2
  11. package/lib/cjs/src/api/apdu/utils/ByteArrayParser.test.js +1 -1
  12. package/lib/cjs/src/api/apdu/utils/ByteArrayParser.test.js.map +2 -2
  13. package/lib/cjs/src/api/command/os/GetOsVersionCommand.js +1 -1
  14. package/lib/cjs/src/api/command/os/GetOsVersionCommand.js.map +3 -3
  15. package/lib/cjs/src/api/command/os/LoadCertificateCommand.js +2 -0
  16. package/lib/cjs/src/api/command/os/LoadCertificateCommand.js.map +7 -0
  17. package/lib/cjs/src/api/command/os/LoadCertificateCommand.test.js +2 -0
  18. package/lib/cjs/src/api/command/os/LoadCertificateCommand.test.js.map +7 -0
  19. package/lib/cjs/src/api/command/os/SecureElementFlagsParser.js +2 -0
  20. package/lib/cjs/src/api/command/os/SecureElementFlagsParser.js.map +7 -0
  21. package/lib/cjs/src/api/command/os/SecureElementFlagsParser.test.js +2 -0
  22. package/lib/cjs/src/api/command/os/SecureElementFlagsParser.test.js.map +7 -0
  23. package/lib/cjs/src/api/command/os/__mocks__/GetOsVersionCommand.js +1 -1
  24. package/lib/cjs/src/api/command/os/__mocks__/GetOsVersionCommand.js.map +2 -2
  25. package/lib/cjs/src/api/command/use-case/SendCommandUseCase.test.js +1 -1
  26. package/lib/cjs/src/api/command/use-case/SendCommandUseCase.test.js.map +3 -3
  27. package/lib/cjs/src/api/device/SecureElementFlags.js +2 -0
  28. package/lib/cjs/src/api/device/SecureElementFlags.js.map +7 -0
  29. package/lib/cjs/src/api/device-action/DeviceAction.js +1 -1
  30. package/lib/cjs/src/api/device-action/DeviceAction.js.map +1 -1
  31. package/lib/cjs/src/api/device-action/__test-utils__/makeInternalApi.js +1 -1
  32. package/lib/cjs/src/api/device-action/__test-utils__/makeInternalApi.js.map +3 -3
  33. package/lib/cjs/src/api/device-action/__test-utils__/setupTestMachine.js +1 -1
  34. package/lib/cjs/src/api/device-action/__test-utils__/setupTestMachine.js.map +2 -2
  35. package/lib/cjs/src/api/device-action/__test-utils__/testDeviceActionStates.js +1 -1
  36. package/lib/cjs/src/api/device-action/__test-utils__/testDeviceActionStates.js.map +3 -3
  37. package/lib/cjs/src/api/device-action/model/UserInteractionRequired.js.map +1 -1
  38. package/lib/cjs/src/api/device-action/os/CallTaskInAppDeviceAction/CallTaskInAppDeviceAction.js +2 -0
  39. package/lib/cjs/src/api/device-action/os/CallTaskInAppDeviceAction/CallTaskInAppDeviceAction.js.map +7 -0
  40. package/lib/cjs/src/api/device-action/os/CallTaskInAppDeviceAction/CallTaskInAppDeviceAction.test.js +2 -0
  41. package/lib/cjs/src/api/device-action/os/CallTaskInAppDeviceAction/CallTaskInAppDeviceAction.test.js.map +7 -0
  42. package/lib/cjs/src/api/device-action/os/CallTaskInAppDeviceAction/CallTaskInAppDeviceActionTypes.js +2 -0
  43. package/lib/cjs/src/api/device-action/os/CallTaskInAppDeviceAction/CallTaskInAppDeviceActionTypes.js.map +7 -0
  44. package/lib/cjs/src/api/device-action/os/GetDeviceStatus/GetDeviceStatusDeviceAction.test.js +1 -1
  45. package/lib/cjs/src/api/device-action/os/GetDeviceStatus/GetDeviceStatusDeviceAction.test.js.map +3 -3
  46. package/lib/cjs/src/api/device-action/os/GoToDashboard/GoToDashboardDeviceAction.test.js +1 -1
  47. package/lib/cjs/src/api/device-action/os/GoToDashboard/GoToDashboardDeviceAction.test.js.map +3 -3
  48. package/lib/cjs/src/api/device-action/os/ListApps/ListAppsDeviceAction.test.js +1 -1
  49. package/lib/cjs/src/api/device-action/os/ListApps/ListAppsDeviceAction.test.js.map +3 -3
  50. package/lib/cjs/src/api/device-action/os/ListAppsWithMetadata/ListAppsWithMetadataDeviceAction.js +1 -1
  51. package/lib/cjs/src/api/device-action/os/ListAppsWithMetadata/ListAppsWithMetadataDeviceAction.js.map +3 -3
  52. package/lib/cjs/src/api/device-action/os/ListAppsWithMetadata/ListAppsWithMetadataDeviceAction.test.js +1 -1
  53. package/lib/cjs/src/api/device-action/os/ListAppsWithMetadata/ListAppsWithMetadataDeviceAction.test.js.map +3 -3
  54. package/lib/cjs/src/api/device-action/os/OpenAppDeviceAction/OpenAppDeviceAction.test.js +1 -1
  55. package/lib/cjs/src/api/device-action/os/OpenAppDeviceAction/OpenAppDeviceAction.test.js.map +3 -3
  56. package/lib/cjs/src/api/device-action/os/SendCommandInAppDeviceAction/SendCommandInAppDeviceAction.test.js +1 -1
  57. package/lib/cjs/src/api/device-action/os/SendCommandInAppDeviceAction/SendCommandInAppDeviceAction.test.js.map +3 -3
  58. package/lib/cjs/src/api/device-action/xstate-utils/XStateDeviceAction.js +1 -1
  59. package/lib/cjs/src/api/device-action/xstate-utils/XStateDeviceAction.js.map +3 -3
  60. package/lib/cjs/src/api/device-session/DeviceSessionState.js +1 -1
  61. package/lib/cjs/src/api/device-session/DeviceSessionState.js.map +1 -1
  62. package/lib/cjs/src/api/device-session/use-case/DisableDeviceSessionRefresher.js +2 -0
  63. package/lib/cjs/src/api/device-session/use-case/DisableDeviceSessionRefresher.js.map +7 -0
  64. package/lib/cjs/src/api/device-session/use-case/DisableDeviceSessionRefresher.test.js +2 -0
  65. package/lib/cjs/src/api/device-session/use-case/DisableDeviceSessionRefresher.test.js.map +7 -0
  66. package/lib/cjs/src/api/index.js +1 -1
  67. package/lib/cjs/src/api/index.js.map +3 -3
  68. package/lib/cjs/src/api/logger-subscriber/service/ConsoleLogger.test.js +1 -1
  69. package/lib/cjs/src/api/logger-subscriber/service/ConsoleLogger.test.js.map +2 -2
  70. package/lib/cjs/src/api/logger-subscriber/service/WebLogsExporterLogger.test.js +1 -1
  71. package/lib/cjs/src/api/logger-subscriber/service/WebLogsExporterLogger.test.js.map +2 -2
  72. package/lib/cjs/src/api/logger-subscriber/service/__mocks__/ConsoleLogger.js +1 -1
  73. package/lib/cjs/src/api/logger-subscriber/service/__mocks__/ConsoleLogger.js.map +2 -2
  74. package/lib/cjs/src/api/secure-channel/constants.js +2 -0
  75. package/lib/cjs/src/api/secure-channel/constants.js.map +7 -0
  76. package/lib/cjs/src/api/secure-channel/device-action/GenuineCheck/GenuineCheckDeviceAction.js +2 -0
  77. package/lib/cjs/src/api/secure-channel/device-action/GenuineCheck/GenuineCheckDeviceAction.js.map +7 -0
  78. package/lib/cjs/src/api/secure-channel/device-action/GenuineCheck/GenuineCheckDeviceAction.test.js +2 -0
  79. package/lib/cjs/src/api/secure-channel/device-action/GenuineCheck/GenuineCheckDeviceAction.test.js.map +7 -0
  80. package/lib/cjs/src/api/secure-channel/device-action/GenuineCheck/types.js +2 -0
  81. package/lib/cjs/src/api/secure-channel/device-action/GenuineCheck/types.js.map +7 -0
  82. package/lib/cjs/src/api/secure-channel/task/ConnectToSecureChannelTask.js +2 -0
  83. package/lib/cjs/src/api/secure-channel/task/ConnectToSecureChannelTask.js.map +7 -0
  84. package/lib/cjs/src/api/secure-channel/task/ConnectToSecureChannelTask.test.js +2 -0
  85. package/lib/cjs/src/api/secure-channel/task/ConnectToSecureChannelTask.test.js.map +7 -0
  86. package/lib/cjs/src/api/secure-channel/task/types.js +2 -0
  87. package/lib/cjs/src/api/secure-channel/task/types.js.map +7 -0
  88. package/lib/cjs/src/api/secure-channel/types.js +2 -0
  89. package/lib/cjs/src/api/secure-channel/types.js.map +7 -0
  90. package/lib/cjs/src/api/secure-channel/utils.js +2 -0
  91. package/lib/cjs/src/api/secure-channel/utils.js.map +7 -0
  92. package/lib/cjs/src/api/secure-channel/utils.test.js +2 -0
  93. package/lib/cjs/src/api/secure-channel/utils.test.js.map +7 -0
  94. package/lib/cjs/src/api/transport/model/DeviceConnectionFactory.stub.js +1 -1
  95. package/lib/cjs/src/api/transport/model/DeviceConnectionFactory.stub.js.map +2 -2
  96. package/lib/cjs/src/api/transport/model/DiscoveredDevice.js +1 -1
  97. package/lib/cjs/src/api/transport/model/DiscoveredDevice.js.map +1 -1
  98. package/lib/cjs/src/api/transport/model/Errors.js.map +2 -2
  99. package/lib/cjs/src/api/transport/model/Transport.js.map +1 -1
  100. package/lib/cjs/src/api/transport/model/TransportConnectedDevice.stub.js +1 -1
  101. package/lib/cjs/src/api/transport/model/TransportConnectedDevice.stub.js.map +2 -2
  102. package/lib/cjs/src/api/transport/model/TransportDiscoveredDevice.js +1 -1
  103. package/lib/cjs/src/api/transport/model/TransportDiscoveredDevice.js.map +1 -1
  104. package/lib/cjs/src/api/transport/model/__mocks__/TransportMock.js +1 -1
  105. package/lib/cjs/src/api/transport/model/__mocks__/TransportMock.js.map +2 -2
  106. package/lib/cjs/src/api/types.js +1 -1
  107. package/lib/cjs/src/api/types.js.map +1 -1
  108. package/lib/cjs/src/api/utils/Base64String.test.js +1 -1
  109. package/lib/cjs/src/api/utils/Base64String.test.js.map +2 -2
  110. package/lib/cjs/src/api/utils/HexaString.js +1 -1
  111. package/lib/cjs/src/api/utils/HexaString.js.map +2 -2
  112. package/lib/cjs/src/api/utils/HexaString.test.js +1 -1
  113. package/lib/cjs/src/api/utils/HexaString.test.js.map +2 -2
  114. package/lib/cjs/src/di.js +1 -1
  115. package/lib/cjs/src/di.js.map +3 -3
  116. package/lib/cjs/src/di.stub.js +1 -1
  117. package/lib/cjs/src/di.stub.js.map +2 -2
  118. package/lib/cjs/src/internal/config/data/LocalConfigDataSource.test.js +1 -1
  119. package/lib/cjs/src/internal/config/data/LocalConfigDataSource.test.js.map +3 -3
  120. package/lib/cjs/src/internal/config/data/RemoteConfigDataSource.test.js +1 -1
  121. package/lib/cjs/src/internal/config/data/RemoteConfigDataSource.test.js.map +2 -2
  122. package/lib/cjs/src/internal/config/data/__mocks__/LocalConfigDataSource.js +1 -1
  123. package/lib/cjs/src/internal/config/data/__mocks__/LocalConfigDataSource.js.map +2 -2
  124. package/lib/cjs/src/internal/config/data/__mocks__/RemoteConfigDataSource.js +1 -1
  125. package/lib/cjs/src/internal/config/data/__mocks__/RemoteConfigDataSource.js.map +2 -2
  126. package/lib/cjs/src/internal/config/service/DefaultConfigService.test.js +1 -1
  127. package/lib/cjs/src/internal/config/service/DefaultConfigService.test.js.map +2 -2
  128. package/lib/cjs/src/internal/config/use-case/GetDmkVersionUseCase.test.js +1 -1
  129. package/lib/cjs/src/internal/config/use-case/GetDmkVersionUseCase.test.js.map +2 -2
  130. package/lib/cjs/src/internal/device-session/di/deviceSessionModule.js +1 -1
  131. package/lib/cjs/src/internal/device-session/di/deviceSessionModule.js.map +3 -3
  132. package/lib/cjs/src/internal/device-session/di/deviceSessionTypes.js +1 -1
  133. package/lib/cjs/src/internal/device-session/di/deviceSessionTypes.js.map +2 -2
  134. package/lib/cjs/src/internal/device-session/model/DeviceSession.js +1 -1
  135. package/lib/cjs/src/internal/device-session/model/DeviceSession.js.map +3 -3
  136. package/lib/cjs/src/internal/device-session/model/DeviceSession.stub.js +1 -1
  137. package/lib/cjs/src/internal/device-session/model/DeviceSession.stub.js.map +3 -3
  138. package/lib/cjs/src/internal/device-session/model/DeviceSessionRefresher.js +1 -1
  139. package/lib/cjs/src/internal/device-session/model/DeviceSessionRefresher.js.map +2 -2
  140. package/lib/cjs/src/internal/device-session/model/DeviceSessionRefresher.test.js +1 -1
  141. package/lib/cjs/src/internal/device-session/model/DeviceSessionRefresher.test.js.map +2 -2
  142. package/lib/cjs/src/internal/device-session/service/DefaultApduReceiverService.test.js +1 -1
  143. package/lib/cjs/src/internal/device-session/service/DefaultApduReceiverService.test.js.map +2 -2
  144. package/lib/cjs/src/internal/device-session/service/DefaultApduSenderService.test.js +1 -1
  145. package/lib/cjs/src/internal/device-session/service/DefaultApduSenderService.test.js.map +2 -2
  146. package/lib/cjs/src/internal/device-session/service/DefaultDeviceSessionService.test.js +1 -1
  147. package/lib/cjs/src/internal/device-session/service/DefaultDeviceSessionService.test.js.map +3 -3
  148. package/lib/cjs/src/internal/device-session/service/RefresherService.js +2 -0
  149. package/lib/cjs/src/internal/device-session/service/RefresherService.js.map +7 -0
  150. package/lib/cjs/src/internal/device-session/service/RefresherService.test.js +2 -0
  151. package/lib/cjs/src/internal/device-session/service/RefresherService.test.js.map +7 -0
  152. package/lib/cjs/src/internal/device-session/use-case/CloseSessionsUseCase.test.js +1 -1
  153. package/lib/cjs/src/internal/device-session/use-case/CloseSessionsUseCase.test.js.map +3 -3
  154. package/lib/cjs/src/internal/device-session/use-case/GetDeviceSessionStateUseCase.test.js +1 -1
  155. package/lib/cjs/src/internal/device-session/use-case/GetDeviceSessionStateUseCase.test.js.map +3 -3
  156. package/lib/cjs/src/internal/discovery/di/discoveryModule.js +1 -1
  157. package/lib/cjs/src/internal/discovery/di/discoveryModule.js.map +3 -3
  158. package/lib/cjs/src/internal/discovery/di/discoveryModule.test.js +1 -1
  159. package/lib/cjs/src/internal/discovery/di/discoveryModule.test.js.map +3 -3
  160. package/lib/cjs/src/internal/discovery/di/discoveryTypes.js +1 -1
  161. package/lib/cjs/src/internal/discovery/di/discoveryTypes.js.map +2 -2
  162. package/lib/cjs/src/internal/discovery/use-case/ConnectUseCase.js +1 -1
  163. package/lib/cjs/src/internal/discovery/use-case/ConnectUseCase.js.map +3 -3
  164. package/lib/cjs/src/internal/discovery/use-case/ConnectUseCase.test.js +1 -1
  165. package/lib/cjs/src/internal/discovery/use-case/ConnectUseCase.test.js.map +3 -3
  166. package/lib/cjs/src/internal/discovery/use-case/DisconnectUseCase.test.js +1 -1
  167. package/lib/cjs/src/internal/discovery/use-case/DisconnectUseCase.test.js.map +3 -3
  168. package/lib/cjs/src/internal/discovery/use-case/GetConnectedDeviceUseCase.test.js +1 -1
  169. package/lib/cjs/src/internal/discovery/use-case/GetConnectedDeviceUseCase.test.js.map +3 -3
  170. package/lib/cjs/src/internal/discovery/use-case/ListConnectedDevicesUseCase.test.js +1 -1
  171. package/lib/cjs/src/internal/discovery/use-case/ListConnectedDevicesUseCase.test.js.map +3 -3
  172. package/lib/cjs/src/internal/discovery/use-case/ListenToAvailableDevicesUseCase.js +2 -0
  173. package/lib/cjs/src/internal/discovery/use-case/ListenToAvailableDevicesUseCase.js.map +7 -0
  174. package/lib/cjs/src/internal/discovery/use-case/ListenToAvailableDevicesUseCase.test.js +2 -0
  175. package/lib/cjs/src/internal/discovery/use-case/ListenToAvailableDevicesUseCase.test.js.map +7 -0
  176. package/lib/cjs/src/internal/discovery/use-case/ListenToConnectedDeviceUseCase.test.js +1 -1
  177. package/lib/cjs/src/internal/discovery/use-case/ListenToConnectedDeviceUseCase.test.js.map +3 -3
  178. package/lib/cjs/src/internal/discovery/use-case/StartDiscoveringUseCase.test.js +1 -1
  179. package/lib/cjs/src/internal/discovery/use-case/StartDiscoveringUseCase.test.js.map +3 -3
  180. package/lib/cjs/src/internal/discovery/use-case/StopDiscoveringUseCase.test.js +1 -1
  181. package/lib/cjs/src/internal/discovery/use-case/StopDiscoveringUseCase.test.js.map +2 -2
  182. package/lib/cjs/src/internal/logger-publisher/service/DefaultLoggerPublisherService.stub.js +1 -1
  183. package/lib/cjs/src/internal/logger-publisher/service/DefaultLoggerPublisherService.stub.js.map +2 -2
  184. package/lib/cjs/src/internal/logger-publisher/service/DefaultLoggerPublisherService.test.js +1 -1
  185. package/lib/cjs/src/internal/logger-publisher/service/DefaultLoggerPublisherService.test.js.map +2 -2
  186. package/lib/cjs/src/internal/manager-api/data/AxiosManagerApiDataSource.js +1 -1
  187. package/lib/cjs/src/internal/manager-api/data/AxiosManagerApiDataSource.js.map +3 -3
  188. package/lib/cjs/src/internal/manager-api/data/AxiosManagerApiDataSource.test.js +1 -1
  189. package/lib/cjs/src/internal/manager-api/data/AxiosManagerApiDataSource.test.js.map +3 -3
  190. package/lib/cjs/src/internal/manager-api/data/ManagerApiDataSource.js +1 -1
  191. package/lib/cjs/src/internal/manager-api/data/ManagerApiDataSource.js.map +1 -1
  192. package/lib/cjs/src/internal/manager-api/data/ManagerApiDto.js +1 -1
  193. package/lib/cjs/src/internal/manager-api/data/ManagerApiDto.js.map +1 -1
  194. package/lib/cjs/src/internal/manager-api/data/__mocks__/AxiosManagerApiDataSource.js +1 -1
  195. package/lib/cjs/src/internal/manager-api/data/__mocks__/AxiosManagerApiDataSource.js.map +2 -2
  196. package/lib/cjs/src/internal/manager-api/model/Application.js +1 -1
  197. package/lib/cjs/src/internal/manager-api/model/Application.js.map +1 -1
  198. package/lib/cjs/src/internal/manager-api/model/Const.js +1 -1
  199. package/lib/cjs/src/internal/manager-api/model/Const.js.map +3 -3
  200. package/lib/cjs/src/internal/manager-api/model/Errors.js +1 -1
  201. package/lib/cjs/src/internal/manager-api/model/Errors.js.map +3 -3
  202. package/lib/cjs/src/internal/manager-api/model/Firmware.js +1 -1
  203. package/lib/cjs/src/internal/manager-api/model/Firmware.js.map +1 -1
  204. package/lib/cjs/src/internal/manager-api/model/Params.js +1 -1
  205. package/lib/cjs/src/internal/manager-api/model/Params.js.map +1 -1
  206. package/lib/cjs/src/internal/manager-api/service/DefaultManagerApiService.js +1 -1
  207. package/lib/cjs/src/internal/manager-api/service/DefaultManagerApiService.js.map +3 -3
  208. package/lib/cjs/src/internal/manager-api/service/DefaultManagerApiService.test.js +1 -1
  209. package/lib/cjs/src/internal/manager-api/service/DefaultManagerApiService.test.js.map +3 -3
  210. package/lib/cjs/src/internal/manager-api/service/ManagerApiService.js +1 -1
  211. package/lib/cjs/src/internal/manager-api/service/ManagerApiService.js.map +1 -1
  212. package/lib/cjs/src/internal/secure-channel/data/DefaultSecureChannelDataSource.js +2 -0
  213. package/lib/cjs/src/internal/secure-channel/data/DefaultSecureChannelDataSource.js.map +7 -0
  214. package/lib/cjs/src/internal/secure-channel/data/DefaultSecureChannelDataSource.test.js +2 -0
  215. package/lib/cjs/src/internal/secure-channel/data/DefaultSecureChannelDataSource.test.js.map +7 -0
  216. package/lib/cjs/src/internal/secure-channel/data/SecureChannelDataSource.js +2 -0
  217. package/lib/cjs/src/internal/secure-channel/data/SecureChannelDataSource.js.map +7 -0
  218. package/lib/cjs/src/internal/secure-channel/data/__mocks__/DefaultSecureChannelDataSource.js +2 -0
  219. package/lib/cjs/src/internal/secure-channel/data/__mocks__/DefaultSecureChannelDataSource.js.map +7 -0
  220. package/lib/cjs/src/internal/secure-channel/di/secureChannelModule.js +2 -0
  221. package/lib/cjs/src/internal/secure-channel/di/secureChannelModule.js.map +7 -0
  222. package/lib/cjs/src/internal/secure-channel/di/secureChannelModule.test.js +2 -0
  223. package/lib/cjs/src/internal/secure-channel/di/secureChannelModule.test.js.map +7 -0
  224. package/lib/cjs/src/internal/secure-channel/di/secureChannelTypes.js +2 -0
  225. package/lib/cjs/src/internal/secure-channel/di/secureChannelTypes.js.map +7 -0
  226. package/lib/cjs/src/internal/secure-channel/model/Const.js +2 -0
  227. package/lib/cjs/src/internal/secure-channel/model/Const.js.map +7 -0
  228. package/lib/cjs/src/internal/secure-channel/model/Errors.js +2 -0
  229. package/lib/cjs/src/internal/secure-channel/model/Errors.js.map +7 -0
  230. package/lib/cjs/src/internal/secure-channel/model/Params.js +2 -0
  231. package/lib/cjs/src/internal/secure-channel/model/Params.js.map +7 -0
  232. package/lib/cjs/src/internal/secure-channel/service/DefaultSecureChannelService.js +2 -0
  233. package/lib/cjs/src/internal/secure-channel/service/DefaultSecureChannelService.js.map +7 -0
  234. package/lib/cjs/src/internal/secure-channel/service/DefaultSecureChannelService.test.js +2 -0
  235. package/lib/cjs/src/internal/secure-channel/service/DefaultSecureChannelService.test.js.map +7 -0
  236. package/lib/cjs/src/internal/secure-channel/service/SecureChannelService.js +2 -0
  237. package/lib/cjs/src/internal/secure-channel/service/SecureChannelService.js.map +7 -0
  238. package/lib/cjs/src/internal/send/use-case/SendApduUseCase.test.js +1 -1
  239. package/lib/cjs/src/internal/send/use-case/SendApduUseCase.test.js.map +3 -3
  240. package/lib/cjs/src/internal/transport/di/transportModule.test.js +1 -1
  241. package/lib/cjs/src/internal/transport/di/transportModule.test.js.map +2 -2
  242. package/lib/cjs/src/internal/transport/service/DefaultTransportService.test.js +1 -1
  243. package/lib/cjs/src/internal/transport/service/DefaultTransportService.test.js.map +2 -2
  244. package/lib/cjs/src/internal/transport/service/__mocks__/DefaultTransportService.js +1 -1
  245. package/lib/cjs/src/internal/transport/service/__mocks__/DefaultTransportService.js.map +2 -2
  246. package/lib/esm/package.json +11 -10
  247. package/lib/esm/src/api/DeviceManagementKit.js +1 -1
  248. package/lib/esm/src/api/DeviceManagementKit.js.map +2 -2
  249. package/lib/esm/src/api/DeviceManagementKit.test.js +1 -1
  250. package/lib/esm/src/api/DeviceManagementKit.test.js.map +2 -2
  251. package/lib/esm/src/api/DeviceManagementKitBuilder.js +1 -1
  252. package/lib/esm/src/api/DeviceManagementKitBuilder.js.map +2 -2
  253. package/lib/esm/src/api/DeviceManagementKitBuilder.test.js +1 -1
  254. package/lib/esm/src/api/DeviceManagementKitBuilder.test.js.map +2 -2
  255. package/lib/esm/src/api/apdu/utils/ByteArrayParser.test.js +1 -1
  256. package/lib/esm/src/api/apdu/utils/ByteArrayParser.test.js.map +2 -2
  257. package/lib/esm/src/api/command/os/GetOsVersionCommand.js +1 -1
  258. package/lib/esm/src/api/command/os/GetOsVersionCommand.js.map +3 -3
  259. package/lib/esm/src/api/command/os/LoadCertificateCommand.js +2 -0
  260. package/lib/esm/src/api/command/os/LoadCertificateCommand.js.map +7 -0
  261. package/lib/esm/src/api/command/os/LoadCertificateCommand.test.js +2 -0
  262. package/lib/esm/src/api/command/os/LoadCertificateCommand.test.js.map +7 -0
  263. package/lib/esm/src/api/command/os/SecureElementFlagsParser.js +2 -0
  264. package/lib/esm/src/api/command/os/SecureElementFlagsParser.js.map +7 -0
  265. package/lib/esm/src/api/command/os/SecureElementFlagsParser.test.js +2 -0
  266. package/lib/esm/src/api/command/os/SecureElementFlagsParser.test.js.map +7 -0
  267. package/lib/esm/src/api/command/os/__mocks__/GetOsVersionCommand.js +1 -1
  268. package/lib/esm/src/api/command/os/__mocks__/GetOsVersionCommand.js.map +2 -2
  269. package/lib/esm/src/api/command/use-case/SendCommandUseCase.test.js +1 -1
  270. package/lib/esm/src/api/command/use-case/SendCommandUseCase.test.js.map +3 -3
  271. package/lib/esm/src/api/device/SecureElementFlags.js +1 -0
  272. package/lib/esm/src/api/device/SecureElementFlags.js.map +7 -0
  273. package/lib/esm/src/api/device-action/__test-utils__/makeInternalApi.js +1 -1
  274. package/lib/esm/src/api/device-action/__test-utils__/makeInternalApi.js.map +3 -3
  275. package/lib/esm/src/api/device-action/__test-utils__/setupTestMachine.js +1 -1
  276. package/lib/esm/src/api/device-action/__test-utils__/setupTestMachine.js.map +2 -2
  277. package/lib/esm/src/api/device-action/__test-utils__/testDeviceActionStates.js +1 -1
  278. package/lib/esm/src/api/device-action/__test-utils__/testDeviceActionStates.js.map +3 -3
  279. package/lib/esm/src/api/device-action/model/UserInteractionRequired.js.map +1 -1
  280. package/lib/esm/src/api/device-action/os/CallTaskInAppDeviceAction/CallTaskInAppDeviceAction.js +2 -0
  281. package/lib/esm/src/api/device-action/os/CallTaskInAppDeviceAction/CallTaskInAppDeviceAction.js.map +7 -0
  282. package/lib/esm/src/api/device-action/os/CallTaskInAppDeviceAction/CallTaskInAppDeviceAction.test.js +2 -0
  283. package/lib/esm/src/api/device-action/os/CallTaskInAppDeviceAction/CallTaskInAppDeviceAction.test.js.map +7 -0
  284. package/lib/esm/src/api/device-action/os/CallTaskInAppDeviceAction/CallTaskInAppDeviceActionTypes.js +1 -0
  285. package/lib/esm/src/api/device-action/os/CallTaskInAppDeviceAction/CallTaskInAppDeviceActionTypes.js.map +7 -0
  286. package/lib/esm/src/api/device-action/os/GetDeviceStatus/GetDeviceStatusDeviceAction.test.js +1 -1
  287. package/lib/esm/src/api/device-action/os/GetDeviceStatus/GetDeviceStatusDeviceAction.test.js.map +3 -3
  288. package/lib/esm/src/api/device-action/os/GoToDashboard/GoToDashboardDeviceAction.test.js +1 -1
  289. package/lib/esm/src/api/device-action/os/GoToDashboard/GoToDashboardDeviceAction.test.js.map +3 -3
  290. package/lib/esm/src/api/device-action/os/ListApps/ListAppsDeviceAction.test.js +1 -1
  291. package/lib/esm/src/api/device-action/os/ListApps/ListAppsDeviceAction.test.js.map +3 -3
  292. package/lib/esm/src/api/device-action/os/ListAppsWithMetadata/ListAppsWithMetadataDeviceAction.js +1 -1
  293. package/lib/esm/src/api/device-action/os/ListAppsWithMetadata/ListAppsWithMetadataDeviceAction.js.map +3 -3
  294. package/lib/esm/src/api/device-action/os/ListAppsWithMetadata/ListAppsWithMetadataDeviceAction.test.js +1 -1
  295. package/lib/esm/src/api/device-action/os/ListAppsWithMetadata/ListAppsWithMetadataDeviceAction.test.js.map +3 -3
  296. package/lib/esm/src/api/device-action/os/OpenAppDeviceAction/OpenAppDeviceAction.test.js +1 -1
  297. package/lib/esm/src/api/device-action/os/OpenAppDeviceAction/OpenAppDeviceAction.test.js.map +3 -3
  298. package/lib/esm/src/api/device-action/os/SendCommandInAppDeviceAction/SendCommandInAppDeviceAction.test.js +1 -1
  299. package/lib/esm/src/api/device-action/os/SendCommandInAppDeviceAction/SendCommandInAppDeviceAction.test.js.map +3 -3
  300. package/lib/esm/src/api/device-action/xstate-utils/XStateDeviceAction.js +1 -1
  301. package/lib/esm/src/api/device-action/xstate-utils/XStateDeviceAction.js.map +3 -3
  302. package/lib/esm/src/api/device-session/DeviceSessionState.js.map +1 -1
  303. package/lib/esm/src/api/device-session/use-case/DisableDeviceSessionRefresher.js +2 -0
  304. package/lib/esm/src/api/device-session/use-case/DisableDeviceSessionRefresher.js.map +7 -0
  305. package/lib/esm/src/api/device-session/use-case/DisableDeviceSessionRefresher.test.js +2 -0
  306. package/lib/esm/src/api/device-session/use-case/DisableDeviceSessionRefresher.test.js.map +7 -0
  307. package/lib/esm/src/api/index.js +1 -1
  308. package/lib/esm/src/api/index.js.map +3 -3
  309. package/lib/esm/src/api/logger-subscriber/service/ConsoleLogger.test.js +1 -1
  310. package/lib/esm/src/api/logger-subscriber/service/ConsoleLogger.test.js.map +2 -2
  311. package/lib/esm/src/api/logger-subscriber/service/WebLogsExporterLogger.test.js +1 -1
  312. package/lib/esm/src/api/logger-subscriber/service/WebLogsExporterLogger.test.js.map +2 -2
  313. package/lib/esm/src/api/logger-subscriber/service/__mocks__/ConsoleLogger.js +1 -1
  314. package/lib/esm/src/api/logger-subscriber/service/__mocks__/ConsoleLogger.js.map +2 -2
  315. package/lib/esm/src/api/secure-channel/constants.js +2 -0
  316. package/lib/esm/src/api/secure-channel/constants.js.map +7 -0
  317. package/lib/esm/src/api/secure-channel/device-action/GenuineCheck/GenuineCheckDeviceAction.js +2 -0
  318. package/lib/esm/src/api/secure-channel/device-action/GenuineCheck/GenuineCheckDeviceAction.js.map +7 -0
  319. package/lib/esm/src/api/secure-channel/device-action/GenuineCheck/GenuineCheckDeviceAction.test.js +2 -0
  320. package/lib/esm/src/api/secure-channel/device-action/GenuineCheck/GenuineCheckDeviceAction.test.js.map +7 -0
  321. package/lib/esm/src/api/secure-channel/device-action/GenuineCheck/types.js +1 -0
  322. package/lib/esm/src/api/secure-channel/device-action/GenuineCheck/types.js.map +7 -0
  323. package/lib/esm/src/api/secure-channel/task/ConnectToSecureChannelTask.js +2 -0
  324. package/lib/esm/src/api/secure-channel/task/ConnectToSecureChannelTask.js.map +7 -0
  325. package/lib/esm/src/api/secure-channel/task/ConnectToSecureChannelTask.test.js +2 -0
  326. package/lib/esm/src/api/secure-channel/task/ConnectToSecureChannelTask.test.js.map +7 -0
  327. package/lib/esm/src/api/secure-channel/task/types.js +2 -0
  328. package/lib/esm/src/api/secure-channel/task/types.js.map +7 -0
  329. package/lib/esm/src/api/secure-channel/types.js +1 -0
  330. package/lib/esm/src/api/secure-channel/types.js.map +7 -0
  331. package/lib/esm/src/api/secure-channel/utils.js +2 -0
  332. package/lib/esm/src/api/secure-channel/utils.js.map +7 -0
  333. package/lib/esm/src/api/secure-channel/utils.test.js +2 -0
  334. package/lib/esm/src/api/secure-channel/utils.test.js.map +7 -0
  335. package/lib/esm/src/api/transport/model/DeviceConnectionFactory.stub.js +1 -1
  336. package/lib/esm/src/api/transport/model/DeviceConnectionFactory.stub.js.map +2 -2
  337. package/lib/esm/src/api/transport/model/Errors.js.map +2 -2
  338. package/lib/esm/src/api/transport/model/TransportConnectedDevice.stub.js +1 -1
  339. package/lib/esm/src/api/transport/model/TransportConnectedDevice.stub.js.map +2 -2
  340. package/lib/esm/src/api/transport/model/__mocks__/TransportMock.js +1 -1
  341. package/lib/esm/src/api/transport/model/__mocks__/TransportMock.js.map +2 -2
  342. package/lib/esm/src/api/utils/Base64String.test.js +1 -1
  343. package/lib/esm/src/api/utils/Base64String.test.js.map +2 -2
  344. package/lib/esm/src/api/utils/HexaString.js +1 -1
  345. package/lib/esm/src/api/utils/HexaString.js.map +2 -2
  346. package/lib/esm/src/api/utils/HexaString.test.js +1 -1
  347. package/lib/esm/src/api/utils/HexaString.test.js.map +2 -2
  348. package/lib/esm/src/di.js +1 -1
  349. package/lib/esm/src/di.js.map +3 -3
  350. package/lib/esm/src/di.stub.js +1 -1
  351. package/lib/esm/src/di.stub.js.map +2 -2
  352. package/lib/esm/src/internal/config/data/LocalConfigDataSource.test.js +1 -1
  353. package/lib/esm/src/internal/config/data/LocalConfigDataSource.test.js.map +3 -3
  354. package/lib/esm/src/internal/config/data/RemoteConfigDataSource.test.js +1 -1
  355. package/lib/esm/src/internal/config/data/RemoteConfigDataSource.test.js.map +2 -2
  356. package/lib/esm/src/internal/config/data/__mocks__/LocalConfigDataSource.js +1 -1
  357. package/lib/esm/src/internal/config/data/__mocks__/LocalConfigDataSource.js.map +2 -2
  358. package/lib/esm/src/internal/config/data/__mocks__/RemoteConfigDataSource.js +1 -1
  359. package/lib/esm/src/internal/config/data/__mocks__/RemoteConfigDataSource.js.map +2 -2
  360. package/lib/esm/src/internal/config/service/DefaultConfigService.test.js +1 -1
  361. package/lib/esm/src/internal/config/service/DefaultConfigService.test.js.map +2 -2
  362. package/lib/esm/src/internal/config/use-case/GetDmkVersionUseCase.test.js +1 -1
  363. package/lib/esm/src/internal/config/use-case/GetDmkVersionUseCase.test.js.map +2 -2
  364. package/lib/esm/src/internal/device-session/di/deviceSessionModule.js +1 -1
  365. package/lib/esm/src/internal/device-session/di/deviceSessionModule.js.map +3 -3
  366. package/lib/esm/src/internal/device-session/di/deviceSessionTypes.js +1 -1
  367. package/lib/esm/src/internal/device-session/di/deviceSessionTypes.js.map +2 -2
  368. package/lib/esm/src/internal/device-session/model/DeviceSession.js +1 -1
  369. package/lib/esm/src/internal/device-session/model/DeviceSession.js.map +3 -3
  370. package/lib/esm/src/internal/device-session/model/DeviceSession.stub.js +1 -1
  371. package/lib/esm/src/internal/device-session/model/DeviceSession.stub.js.map +3 -3
  372. package/lib/esm/src/internal/device-session/model/DeviceSessionRefresher.js +1 -1
  373. package/lib/esm/src/internal/device-session/model/DeviceSessionRefresher.js.map +2 -2
  374. package/lib/esm/src/internal/device-session/model/DeviceSessionRefresher.test.js +1 -1
  375. package/lib/esm/src/internal/device-session/model/DeviceSessionRefresher.test.js.map +2 -2
  376. package/lib/esm/src/internal/device-session/service/DefaultApduReceiverService.test.js +1 -1
  377. package/lib/esm/src/internal/device-session/service/DefaultApduReceiverService.test.js.map +2 -2
  378. package/lib/esm/src/internal/device-session/service/DefaultApduSenderService.test.js +1 -1
  379. package/lib/esm/src/internal/device-session/service/DefaultApduSenderService.test.js.map +2 -2
  380. package/lib/esm/src/internal/device-session/service/DefaultDeviceSessionService.test.js +1 -1
  381. package/lib/esm/src/internal/device-session/service/DefaultDeviceSessionService.test.js.map +3 -3
  382. package/lib/esm/src/internal/device-session/service/RefresherService.js +2 -0
  383. package/lib/esm/src/internal/device-session/service/RefresherService.js.map +7 -0
  384. package/lib/esm/src/internal/device-session/service/RefresherService.test.js +2 -0
  385. package/lib/esm/src/internal/device-session/service/RefresherService.test.js.map +7 -0
  386. package/lib/esm/src/internal/device-session/use-case/CloseSessionsUseCase.test.js +1 -1
  387. package/lib/esm/src/internal/device-session/use-case/CloseSessionsUseCase.test.js.map +3 -3
  388. package/lib/esm/src/internal/device-session/use-case/GetDeviceSessionStateUseCase.test.js +1 -1
  389. package/lib/esm/src/internal/device-session/use-case/GetDeviceSessionStateUseCase.test.js.map +3 -3
  390. package/lib/esm/src/internal/discovery/di/discoveryModule.js +1 -1
  391. package/lib/esm/src/internal/discovery/di/discoveryModule.js.map +3 -3
  392. package/lib/esm/src/internal/discovery/di/discoveryModule.test.js +1 -1
  393. package/lib/esm/src/internal/discovery/di/discoveryModule.test.js.map +3 -3
  394. package/lib/esm/src/internal/discovery/di/discoveryTypes.js +1 -1
  395. package/lib/esm/src/internal/discovery/di/discoveryTypes.js.map +2 -2
  396. package/lib/esm/src/internal/discovery/use-case/ConnectUseCase.js +1 -1
  397. package/lib/esm/src/internal/discovery/use-case/ConnectUseCase.js.map +3 -3
  398. package/lib/esm/src/internal/discovery/use-case/ConnectUseCase.test.js +1 -1
  399. package/lib/esm/src/internal/discovery/use-case/ConnectUseCase.test.js.map +3 -3
  400. package/lib/esm/src/internal/discovery/use-case/DisconnectUseCase.test.js +1 -1
  401. package/lib/esm/src/internal/discovery/use-case/DisconnectUseCase.test.js.map +3 -3
  402. package/lib/esm/src/internal/discovery/use-case/GetConnectedDeviceUseCase.test.js +1 -1
  403. package/lib/esm/src/internal/discovery/use-case/GetConnectedDeviceUseCase.test.js.map +3 -3
  404. package/lib/esm/src/internal/discovery/use-case/ListConnectedDevicesUseCase.test.js +1 -1
  405. package/lib/esm/src/internal/discovery/use-case/ListConnectedDevicesUseCase.test.js.map +3 -3
  406. package/lib/esm/src/internal/discovery/use-case/ListenToAvailableDevicesUseCase.js +2 -0
  407. package/lib/esm/src/internal/discovery/use-case/ListenToAvailableDevicesUseCase.js.map +7 -0
  408. package/lib/esm/src/internal/discovery/use-case/ListenToAvailableDevicesUseCase.test.js +2 -0
  409. package/lib/esm/src/internal/discovery/use-case/ListenToAvailableDevicesUseCase.test.js.map +7 -0
  410. package/lib/esm/src/internal/discovery/use-case/ListenToConnectedDeviceUseCase.test.js +1 -1
  411. package/lib/esm/src/internal/discovery/use-case/ListenToConnectedDeviceUseCase.test.js.map +3 -3
  412. package/lib/esm/src/internal/discovery/use-case/StartDiscoveringUseCase.test.js +1 -1
  413. package/lib/esm/src/internal/discovery/use-case/StartDiscoveringUseCase.test.js.map +3 -3
  414. package/lib/esm/src/internal/discovery/use-case/StopDiscoveringUseCase.test.js +1 -1
  415. package/lib/esm/src/internal/discovery/use-case/StopDiscoveringUseCase.test.js.map +2 -2
  416. package/lib/esm/src/internal/logger-publisher/service/DefaultLoggerPublisherService.stub.js +1 -1
  417. package/lib/esm/src/internal/logger-publisher/service/DefaultLoggerPublisherService.stub.js.map +2 -2
  418. package/lib/esm/src/internal/logger-publisher/service/DefaultLoggerPublisherService.test.js +1 -1
  419. package/lib/esm/src/internal/logger-publisher/service/DefaultLoggerPublisherService.test.js.map +2 -2
  420. package/lib/esm/src/internal/manager-api/data/AxiosManagerApiDataSource.js +1 -1
  421. package/lib/esm/src/internal/manager-api/data/AxiosManagerApiDataSource.js.map +3 -3
  422. package/lib/esm/src/internal/manager-api/data/AxiosManagerApiDataSource.test.js +1 -1
  423. package/lib/esm/src/internal/manager-api/data/AxiosManagerApiDataSource.test.js.map +3 -3
  424. package/lib/esm/src/internal/manager-api/data/ManagerApiDto.js.map +1 -1
  425. package/lib/esm/src/internal/manager-api/data/__mocks__/AxiosManagerApiDataSource.js +1 -1
  426. package/lib/esm/src/internal/manager-api/data/__mocks__/AxiosManagerApiDataSource.js.map +2 -2
  427. package/lib/esm/src/internal/manager-api/model/Application.js.map +1 -1
  428. package/lib/esm/src/internal/manager-api/model/Const.js +1 -1
  429. package/lib/esm/src/internal/manager-api/model/Const.js.map +3 -3
  430. package/lib/esm/src/internal/manager-api/model/Errors.js +1 -1
  431. package/lib/esm/src/internal/manager-api/model/Errors.js.map +3 -3
  432. package/lib/esm/src/internal/manager-api/service/DefaultManagerApiService.js +1 -1
  433. package/lib/esm/src/internal/manager-api/service/DefaultManagerApiService.js.map +3 -3
  434. package/lib/esm/src/internal/manager-api/service/DefaultManagerApiService.test.js +1 -1
  435. package/lib/esm/src/internal/manager-api/service/DefaultManagerApiService.test.js.map +3 -3
  436. package/lib/esm/src/internal/secure-channel/data/DefaultSecureChannelDataSource.js +2 -0
  437. package/lib/esm/src/internal/secure-channel/data/DefaultSecureChannelDataSource.js.map +7 -0
  438. package/lib/esm/src/internal/secure-channel/data/DefaultSecureChannelDataSource.test.js +2 -0
  439. package/lib/esm/src/internal/secure-channel/data/DefaultSecureChannelDataSource.test.js.map +7 -0
  440. package/lib/esm/src/internal/secure-channel/data/SecureChannelDataSource.js +1 -0
  441. package/lib/esm/src/internal/secure-channel/data/SecureChannelDataSource.js.map +7 -0
  442. package/lib/esm/src/internal/secure-channel/data/__mocks__/DefaultSecureChannelDataSource.js +2 -0
  443. package/lib/esm/src/internal/secure-channel/data/__mocks__/DefaultSecureChannelDataSource.js.map +7 -0
  444. package/lib/esm/src/internal/secure-channel/di/secureChannelModule.js +2 -0
  445. package/lib/esm/src/internal/secure-channel/di/secureChannelModule.js.map +7 -0
  446. package/lib/esm/src/internal/secure-channel/di/secureChannelModule.test.js +2 -0
  447. package/lib/esm/src/internal/secure-channel/di/secureChannelModule.test.js.map +7 -0
  448. package/lib/esm/src/internal/secure-channel/di/secureChannelTypes.js +2 -0
  449. package/lib/esm/src/internal/secure-channel/di/secureChannelTypes.js.map +7 -0
  450. package/lib/esm/src/internal/secure-channel/model/Const.js +2 -0
  451. package/lib/esm/src/internal/secure-channel/model/Const.js.map +7 -0
  452. package/lib/esm/src/internal/secure-channel/model/Errors.js +2 -0
  453. package/lib/esm/src/internal/secure-channel/model/Errors.js.map +7 -0
  454. package/lib/esm/src/internal/secure-channel/model/Params.js +1 -0
  455. package/lib/esm/src/internal/secure-channel/model/Params.js.map +7 -0
  456. package/lib/esm/src/internal/secure-channel/service/DefaultSecureChannelService.js +2 -0
  457. package/lib/esm/src/internal/secure-channel/service/DefaultSecureChannelService.js.map +7 -0
  458. package/lib/esm/src/internal/secure-channel/service/DefaultSecureChannelService.test.js +2 -0
  459. package/lib/esm/src/internal/secure-channel/service/DefaultSecureChannelService.test.js.map +7 -0
  460. package/lib/esm/src/internal/secure-channel/service/SecureChannelService.js +1 -0
  461. package/lib/esm/src/internal/secure-channel/service/SecureChannelService.js.map +7 -0
  462. package/lib/esm/src/internal/send/use-case/SendApduUseCase.test.js +1 -1
  463. package/lib/esm/src/internal/send/use-case/SendApduUseCase.test.js.map +3 -3
  464. package/lib/esm/src/internal/transport/di/transportModule.test.js +1 -1
  465. package/lib/esm/src/internal/transport/di/transportModule.test.js.map +2 -2
  466. package/lib/esm/src/internal/transport/service/DefaultTransportService.test.js +1 -1
  467. package/lib/esm/src/internal/transport/service/DefaultTransportService.test.js.map +2 -2
  468. package/lib/esm/src/internal/transport/service/__mocks__/DefaultTransportService.js +1 -1
  469. package/lib/esm/src/internal/transport/service/__mocks__/DefaultTransportService.js.map +2 -2
  470. package/lib/types/src/api/DeviceManagementKit.d.ts +10 -8
  471. package/lib/types/src/api/DeviceManagementKit.d.ts.map +1 -1
  472. package/lib/types/src/api/command/os/GetOsVersionCommand.d.ts +8 -2
  473. package/lib/types/src/api/command/os/GetOsVersionCommand.d.ts.map +1 -1
  474. package/lib/types/src/api/command/os/LoadCertificateCommand.d.ts +25 -0
  475. package/lib/types/src/api/command/os/LoadCertificateCommand.d.ts.map +1 -0
  476. package/lib/types/src/api/command/os/LoadCertificateCommand.test.d.ts +2 -0
  477. package/lib/types/src/api/command/os/LoadCertificateCommand.test.d.ts.map +1 -0
  478. package/lib/types/src/api/command/os/SecureElementFlagsParser.d.ts +43 -0
  479. package/lib/types/src/api/command/os/SecureElementFlagsParser.d.ts.map +1 -0
  480. package/lib/types/src/api/command/os/SecureElementFlagsParser.test.d.ts +2 -0
  481. package/lib/types/src/api/command/os/SecureElementFlagsParser.test.d.ts.map +1 -0
  482. package/lib/types/src/api/command/os/__mocks__/GetOsVersionCommand.d.ts.map +1 -1
  483. package/lib/types/src/api/device/SecureElementFlags.d.ts +41 -0
  484. package/lib/types/src/api/device/SecureElementFlags.d.ts.map +1 -0
  485. package/lib/types/src/api/device-action/DeviceAction.d.ts +6 -0
  486. package/lib/types/src/api/device-action/DeviceAction.d.ts.map +1 -1
  487. package/lib/types/src/api/device-action/__test-utils__/makeInternalApi.d.ts +2 -1
  488. package/lib/types/src/api/device-action/__test-utils__/makeInternalApi.d.ts.map +1 -1
  489. package/lib/types/src/api/device-action/__test-utils__/setupTestMachine.d.ts.map +1 -1
  490. package/lib/types/src/api/device-action/__test-utils__/testDeviceActionStates.d.ts +5 -2
  491. package/lib/types/src/api/device-action/__test-utils__/testDeviceActionStates.d.ts.map +1 -1
  492. package/lib/types/src/api/device-action/model/UserInteractionRequired.d.ts +1 -1
  493. package/lib/types/src/api/device-action/os/CallTaskInAppDeviceAction/CallTaskInAppDeviceAction.d.ts +40 -0
  494. package/lib/types/src/api/device-action/os/CallTaskInAppDeviceAction/CallTaskInAppDeviceAction.d.ts.map +1 -0
  495. package/lib/types/src/api/device-action/os/CallTaskInAppDeviceAction/CallTaskInAppDeviceAction.test.d.ts +2 -0
  496. package/lib/types/src/api/device-action/os/CallTaskInAppDeviceAction/CallTaskInAppDeviceAction.test.d.ts.map +1 -0
  497. package/lib/types/src/api/device-action/os/CallTaskInAppDeviceAction/CallTaskInAppDeviceActionTypes.d.ts +19 -0
  498. package/lib/types/src/api/device-action/os/CallTaskInAppDeviceAction/CallTaskInAppDeviceActionTypes.d.ts.map +1 -0
  499. package/lib/types/src/api/device-action/os/ListAppsWithMetadata/ListAppsWithMetadataDeviceAction.d.ts +1 -1
  500. package/lib/types/src/api/device-action/os/ListAppsWithMetadata/ListAppsWithMetadataDeviceAction.d.ts.map +1 -1
  501. package/lib/types/src/api/device-session/DeviceSessionState.d.ts +4 -0
  502. package/lib/types/src/api/device-session/DeviceSessionState.d.ts.map +1 -1
  503. package/lib/types/src/api/device-session/use-case/{ToggleDeviceSessionRefresher.d.ts → DisableDeviceSessionRefresher.d.ts} +6 -6
  504. package/lib/types/src/api/device-session/use-case/DisableDeviceSessionRefresher.d.ts.map +1 -0
  505. package/lib/types/src/api/device-session/use-case/DisableDeviceSessionRefresher.test.d.ts +2 -0
  506. package/lib/types/src/api/device-session/use-case/DisableDeviceSessionRefresher.test.d.ts.map +1 -0
  507. package/lib/types/src/api/index.d.ts +3 -0
  508. package/lib/types/src/api/index.d.ts.map +1 -1
  509. package/lib/types/src/api/logger-subscriber/service/__mocks__/ConsoleLogger.d.ts +1 -1
  510. package/lib/types/src/api/logger-subscriber/service/__mocks__/ConsoleLogger.d.ts.map +1 -1
  511. package/lib/types/src/api/secure-channel/constants.d.ts +2 -0
  512. package/lib/types/src/api/secure-channel/constants.d.ts.map +1 -0
  513. package/lib/types/src/api/secure-channel/device-action/GenuineCheck/GenuineCheckDeviceAction.d.ts +8 -0
  514. package/lib/types/src/api/secure-channel/device-action/GenuineCheck/GenuineCheckDeviceAction.d.ts.map +1 -0
  515. package/lib/types/src/api/secure-channel/device-action/GenuineCheck/GenuineCheckDeviceAction.test.d.ts +1 -0
  516. package/lib/types/src/api/secure-channel/device-action/GenuineCheck/GenuineCheckDeviceAction.test.d.ts.map +1 -0
  517. package/lib/types/src/api/secure-channel/device-action/GenuineCheck/types.d.ts +48 -0
  518. package/lib/types/src/api/secure-channel/device-action/GenuineCheck/types.d.ts.map +1 -0
  519. package/lib/types/src/api/secure-channel/task/ConnectToSecureChannelTask.d.ts +23 -0
  520. package/lib/types/src/api/secure-channel/task/ConnectToSecureChannelTask.d.ts.map +1 -0
  521. package/lib/types/src/api/secure-channel/task/ConnectToSecureChannelTask.test.d.ts +2 -0
  522. package/lib/types/src/api/secure-channel/task/ConnectToSecureChannelTask.test.d.ts.map +1 -0
  523. package/lib/types/src/api/secure-channel/task/types.d.ts +105 -0
  524. package/lib/types/src/api/secure-channel/task/types.d.ts.map +1 -0
  525. package/lib/types/src/api/secure-channel/types.d.ts +4 -0
  526. package/lib/types/src/api/secure-channel/types.d.ts.map +1 -0
  527. package/lib/types/src/api/secure-channel/utils.d.ts +30 -0
  528. package/lib/types/src/api/secure-channel/utils.d.ts.map +1 -0
  529. package/lib/types/src/api/secure-channel/utils.test.d.ts +2 -0
  530. package/lib/types/src/api/secure-channel/utils.test.d.ts.map +1 -0
  531. package/lib/types/src/api/transport/model/DeviceConnectionFactory.stub.d.ts +1 -1
  532. package/lib/types/src/api/transport/model/DeviceConnectionFactory.stub.d.ts.map +1 -1
  533. package/lib/types/src/api/transport/model/DiscoveredDevice.d.ts +2 -0
  534. package/lib/types/src/api/transport/model/DiscoveredDevice.d.ts.map +1 -1
  535. package/lib/types/src/api/transport/model/Errors.d.ts.map +1 -1
  536. package/lib/types/src/api/transport/model/Transport.d.ts +1 -1
  537. package/lib/types/src/api/transport/model/Transport.d.ts.map +1 -1
  538. package/lib/types/src/api/transport/model/TransportDiscoveredDevice.d.ts +2 -0
  539. package/lib/types/src/api/transport/model/TransportDiscoveredDevice.d.ts.map +1 -1
  540. package/lib/types/src/api/transport/model/__mocks__/TransportMock.d.ts +7 -7
  541. package/lib/types/src/api/transport/model/__mocks__/TransportMock.d.ts.map +1 -1
  542. package/lib/types/src/api/types.d.ts +1 -0
  543. package/lib/types/src/api/types.d.ts.map +1 -1
  544. package/lib/types/src/api/utils/HexaString.d.ts +1 -1
  545. package/lib/types/src/api/utils/HexaString.d.ts.map +1 -1
  546. package/lib/types/src/di.d.ts.map +1 -1
  547. package/lib/types/src/di.stub.d.ts +1 -1
  548. package/lib/types/src/di.stub.d.ts.map +1 -1
  549. package/lib/types/src/internal/config/data/__mocks__/LocalConfigDataSource.d.ts +1 -1
  550. package/lib/types/src/internal/config/data/__mocks__/LocalConfigDataSource.d.ts.map +1 -1
  551. package/lib/types/src/internal/config/data/__mocks__/RemoteConfigDataSource.d.ts +3 -3
  552. package/lib/types/src/internal/config/data/__mocks__/RemoteConfigDataSource.d.ts.map +1 -1
  553. package/lib/types/src/internal/device-session/di/deviceSessionTypes.d.ts +1 -1
  554. package/lib/types/src/internal/device-session/model/DeviceSession.d.ts +13 -7
  555. package/lib/types/src/internal/device-session/model/DeviceSession.d.ts.map +1 -1
  556. package/lib/types/src/internal/device-session/model/DeviceSession.stub.d.ts +2 -1
  557. package/lib/types/src/internal/device-session/model/DeviceSession.stub.d.ts.map +1 -1
  558. package/lib/types/src/internal/device-session/model/DeviceSessionRefresher.d.ts.map +1 -1
  559. package/lib/types/src/internal/device-session/service/RefresherService.d.ts +10 -0
  560. package/lib/types/src/internal/device-session/service/RefresherService.d.ts.map +1 -0
  561. package/lib/types/src/internal/device-session/service/RefresherService.test.d.ts +2 -0
  562. package/lib/types/src/internal/device-session/service/RefresherService.test.d.ts.map +1 -0
  563. package/lib/types/src/internal/discovery/di/discoveryTypes.d.ts +1 -1
  564. package/lib/types/src/internal/discovery/di/discoveryTypes.d.ts.map +1 -1
  565. package/lib/types/src/internal/discovery/use-case/ConnectUseCase.d.ts +3 -1
  566. package/lib/types/src/internal/discovery/use-case/ConnectUseCase.d.ts.map +1 -1
  567. package/lib/types/src/internal/discovery/use-case/ListenToAvailableDevicesUseCase.d.ts +24 -0
  568. package/lib/types/src/internal/discovery/use-case/ListenToAvailableDevicesUseCase.d.ts.map +1 -0
  569. package/lib/types/src/internal/discovery/use-case/ListenToAvailableDevicesUseCase.test.d.ts +2 -0
  570. package/lib/types/src/internal/discovery/use-case/ListenToAvailableDevicesUseCase.test.d.ts.map +1 -0
  571. package/lib/types/src/internal/logger-publisher/service/DefaultLoggerPublisherService.stub.d.ts +5 -5
  572. package/lib/types/src/internal/logger-publisher/service/DefaultLoggerPublisherService.stub.d.ts.map +1 -1
  573. package/lib/types/src/internal/manager-api/data/AxiosManagerApiDataSource.d.ts +8 -16
  574. package/lib/types/src/internal/manager-api/data/AxiosManagerApiDataSource.d.ts.map +1 -1
  575. package/lib/types/src/internal/manager-api/data/ManagerApiDataSource.d.ts +16 -55
  576. package/lib/types/src/internal/manager-api/data/ManagerApiDataSource.d.ts.map +1 -1
  577. package/lib/types/src/internal/manager-api/data/ManagerApiDto.d.ts +4 -1
  578. package/lib/types/src/internal/manager-api/data/ManagerApiDto.d.ts.map +1 -1
  579. package/lib/types/src/internal/manager-api/data/__mocks__/AxiosManagerApiDataSource.d.ts +4 -9
  580. package/lib/types/src/internal/manager-api/data/__mocks__/AxiosManagerApiDataSource.d.ts.map +1 -1
  581. package/lib/types/src/internal/manager-api/model/Application.d.ts +4 -1
  582. package/lib/types/src/internal/manager-api/model/Application.d.ts.map +1 -1
  583. package/lib/types/src/internal/manager-api/model/Const.d.ts +0 -1
  584. package/lib/types/src/internal/manager-api/model/Const.d.ts.map +1 -1
  585. package/lib/types/src/internal/manager-api/model/Errors.d.ts +0 -6
  586. package/lib/types/src/internal/manager-api/model/Errors.d.ts.map +1 -1
  587. package/lib/types/src/internal/manager-api/model/Firmware.d.ts +4 -0
  588. package/lib/types/src/internal/manager-api/model/Firmware.d.ts.map +1 -1
  589. package/lib/types/src/internal/manager-api/model/Params.d.ts +25 -68
  590. package/lib/types/src/internal/manager-api/model/Params.d.ts.map +1 -1
  591. package/lib/types/src/internal/manager-api/service/DefaultManagerApiService.d.ts +5 -5
  592. package/lib/types/src/internal/manager-api/service/DefaultManagerApiService.d.ts.map +1 -1
  593. package/lib/types/src/internal/manager-api/service/ManagerApiService.d.ts +33 -2
  594. package/lib/types/src/internal/manager-api/service/ManagerApiService.d.ts.map +1 -1
  595. package/lib/types/src/internal/secure-channel/data/DefaultSecureChannelDataSource.d.ts +18 -0
  596. package/lib/types/src/internal/secure-channel/data/DefaultSecureChannelDataSource.d.ts.map +1 -0
  597. package/lib/types/src/internal/secure-channel/data/DefaultSecureChannelDataSource.test.d.ts +2 -0
  598. package/lib/types/src/internal/secure-channel/data/DefaultSecureChannelDataSource.test.d.ts.map +1 -0
  599. package/lib/types/src/internal/secure-channel/data/SecureChannelDataSource.d.ts +52 -0
  600. package/lib/types/src/internal/secure-channel/data/SecureChannelDataSource.d.ts.map +1 -0
  601. package/lib/types/src/internal/secure-channel/data/__mocks__/DefaultSecureChannelDataSource.d.ts +10 -0
  602. package/lib/types/src/internal/secure-channel/data/__mocks__/DefaultSecureChannelDataSource.d.ts.map +1 -0
  603. package/lib/types/src/internal/secure-channel/di/secureChannelModule.d.ts +9 -0
  604. package/lib/types/src/internal/secure-channel/di/secureChannelModule.d.ts.map +1 -0
  605. package/lib/types/src/internal/secure-channel/di/secureChannelModule.test.d.ts +2 -0
  606. package/lib/types/src/internal/secure-channel/di/secureChannelModule.test.d.ts.map +1 -0
  607. package/lib/types/src/internal/secure-channel/di/secureChannelTypes.d.ts +6 -0
  608. package/lib/types/src/internal/secure-channel/di/secureChannelTypes.d.ts.map +1 -0
  609. package/lib/types/src/internal/secure-channel/model/Const.d.ts +2 -0
  610. package/lib/types/src/internal/secure-channel/model/Const.d.ts.map +1 -0
  611. package/lib/types/src/internal/secure-channel/model/Errors.d.ts +14 -0
  612. package/lib/types/src/internal/secure-channel/model/Errors.d.ts.map +1 -0
  613. package/lib/types/src/internal/secure-channel/model/Params.d.ts +86 -0
  614. package/lib/types/src/internal/secure-channel/model/Params.d.ts.map +1 -0
  615. package/lib/types/src/internal/secure-channel/service/DefaultSecureChannelService.d.ts +21 -0
  616. package/lib/types/src/internal/secure-channel/service/DefaultSecureChannelService.d.ts.map +1 -0
  617. package/lib/types/src/internal/secure-channel/service/DefaultSecureChannelService.test.d.ts +2 -0
  618. package/lib/types/src/internal/secure-channel/service/DefaultSecureChannelService.test.d.ts.map +1 -0
  619. package/lib/types/src/internal/secure-channel/service/SecureChannelService.d.ts +22 -0
  620. package/lib/types/src/internal/secure-channel/service/SecureChannelService.d.ts.map +1 -0
  621. package/lib/types/src/internal/transport/service/__mocks__/DefaultTransportService.d.ts +6 -6
  622. package/lib/types/src/internal/transport/service/__mocks__/DefaultTransportService.d.ts.map +1 -1
  623. package/lib/types/tsconfig.prod.tsbuildinfo +1 -1
  624. package/package.json +12 -11
  625. package/lib/cjs/src/api/device-session/use-case/ToggleDeviceSessionRefresher.js +0 -2
  626. package/lib/cjs/src/api/device-session/use-case/ToggleDeviceSessionRefresher.js.map +0 -7
  627. package/lib/cjs/src/api/device-session/use-case/ToggleDeviceSessionRefresher.test.js +0 -2
  628. package/lib/cjs/src/api/device-session/use-case/ToggleDeviceSessionRefresher.test.js.map +0 -7
  629. package/lib/cjs/src/internal/discovery/use-case/ListenToKnownDevicesUseCase.js +0 -2
  630. package/lib/cjs/src/internal/discovery/use-case/ListenToKnownDevicesUseCase.js.map +0 -7
  631. package/lib/cjs/src/internal/discovery/use-case/ListenToKnownDevicesUseCase.test.js +0 -2
  632. package/lib/cjs/src/internal/discovery/use-case/ListenToKnownDevicesUseCase.test.js.map +0 -7
  633. package/lib/esm/src/api/device-session/use-case/ToggleDeviceSessionRefresher.js +0 -2
  634. package/lib/esm/src/api/device-session/use-case/ToggleDeviceSessionRefresher.js.map +0 -7
  635. package/lib/esm/src/api/device-session/use-case/ToggleDeviceSessionRefresher.test.js +0 -2
  636. package/lib/esm/src/api/device-session/use-case/ToggleDeviceSessionRefresher.test.js.map +0 -7
  637. package/lib/esm/src/internal/discovery/use-case/ListenToKnownDevicesUseCase.js +0 -2
  638. package/lib/esm/src/internal/discovery/use-case/ListenToKnownDevicesUseCase.js.map +0 -7
  639. package/lib/esm/src/internal/discovery/use-case/ListenToKnownDevicesUseCase.test.js +0 -2
  640. package/lib/esm/src/internal/discovery/use-case/ListenToKnownDevicesUseCase.test.js.map +0 -7
  641. package/lib/types/src/api/device-session/use-case/ToggleDeviceSessionRefresher.d.ts.map +0 -1
  642. package/lib/types/src/api/device-session/use-case/ToggleDeviceSessionRefresher.test.d.ts +0 -2
  643. package/lib/types/src/api/device-session/use-case/ToggleDeviceSessionRefresher.test.d.ts.map +0 -1
  644. package/lib/types/src/internal/discovery/use-case/ListenToKnownDevicesUseCase.d.ts +0 -13
  645. package/lib/types/src/internal/discovery/use-case/ListenToKnownDevicesUseCase.d.ts.map +0 -1
  646. package/lib/types/src/internal/discovery/use-case/ListenToKnownDevicesUseCase.test.d.ts +0 -2
  647. package/lib/types/src/internal/discovery/use-case/ListenToKnownDevicesUseCase.test.d.ts.map +0 -1
@@ -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": "2iBAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,4BAAAE,IAAA,eAAAC,EAAAH,GAAA,IAAAI,EAA2B,qBAE3BC,EAWO,gBAEPC,EAAuC,4CACvCC,EAGO,mDACPC,EAAoC,+CACpCC,EAA8B,mCAC9BC,EAA6B,oCAE7BC,EAGO,kDA8CA,IAAMC,EAAN,KAA6B,CACjB,QACA,yBAA2B,IAAI,0BAC/B,qBAAuB,IAAI,sBACpC,cACA,cACS,iBACA,eACA,YACA,eAEjB,YACE,CACE,gBAAAC,EACA,aAAAC,EACA,WAAAC,EACA,cAAAC,EACA,cAAAC,CACF,EACAC,EACA,CACA,KAAK,cAAgBJ,EACrB,KAAK,QAAUI,EACf,KAAK,YAAcH,EACnB,KAAK,eAAiBC,EACtB,KAAK,iBAAmBH,EACxB,KAAK,eAAiBI,EAEtB,KAAK,MAAM,CACb,CAMA,OAAQ,CACN,GAAI,KAAK,eAAiB,CAAC,KAAK,cAAc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AAM,KAAK,YAAYA,CAAO,EACvBC,CACT,CAAC,CACH,EACMI,KAAoB,MAAG,IAAI,EAAE,QACjC,SAAMf,CAAe,KACrB,OAAKgB,GAAM,CACT,KAAK,QAAQ,KACX,wDACF,EACA,KAAK,eAAgBR,IAAW,CAC9B,GAAGA,EACH,aAAc,eAAa,MAC7B,EAAE,CACJ,CAAC,CACH,EACA,SAAO,YAASR,EAAkB,GAAG,EAAE,QACrC,aAAU,OAAM,QAAKc,EAAwBC,CAAiB,CAAC,CACjE,CACF,CAOA,gBAAgBd,EAA4B,CACtCA,IAAiB,eAAa,eAChC,KAAK,KAAK,EAEZ,KAAK,cAAgBA,CACvB,CAMA,MAAO,CACD,CAAC,KAAK,eAAiB,KAAK,cAAc,SAG9C,KAAK,cAAc,YAAY,EAC/B,KAAK,cAAgB,OACvB,CACF,EAlKaF,EAANkB,EAAA,IADN,cAAW,GACClB",
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": "2iBAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,4BAAAE,IAAA,eAAAC,EAAAH,GAAA,IAAAI,EAA2B,qBAE3BC,EAWO,gBAEPC,EAAuC,4CACvCC,EAGO,mDACPC,EAAoC,+CACpCC,EAA8B,mCAC9BC,EAA6B,oCAE7BC,EAGO,kDA8CA,IAAMC,EAAN,KAA6B,CACjB,QACA,yBAA2B,IAAI,0BAC/B,qBAAuB,IAAI,sBACpC,cACA,cACS,iBACA,eACA,YACA,eAEjB,YACE,CACE,gBAAAC,EACA,aAAAC,EACA,WAAAC,EACA,cAAAC,EACA,cAAAC,CACF,EACAC,EACA,CACA,KAAK,cAAgBJ,EACrB,KAAK,QAAUI,EACf,KAAK,YAAcH,EACnB,KAAK,eAAiBC,EACtB,KAAK,iBAAmBH,EACxB,KAAK,eAAiBI,EAEtB,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AyB,KAAK,6BAA6B,EAAE,QACjE,aAAU,MAAOH,GAAS,CACxB,MAAMD,EAAU,KAAK,qBAAqB,QAAQ,EAAE,WAAW,EAC/D,aAAM,KAAK,YAAYA,CAAO,EACvBC,CACT,CAAC,CACH,EACMI,KAAoB,MAAG,IAAI,EAAE,QACjC,SAAMf,CAAe,KACrB,OAAKgB,GAAM,CACT,KAAK,QAAQ,KACX,wDACF,EACA,KAAK,eAAgBR,IAAW,CAC9B,GAAGA,EACH,aAAc,eAAa,MAC7B,EAAE,CACJ,CAAC,CACH,EACA,SAAO,YAASR,EAAkB,GAAG,EAAE,QACrC,aAAU,OAAM,QAAKc,EAAwBC,CAAiB,CAAC,CACjE,CACF,CAOA,gBAAgBd,EAA4B,CACtCA,IAAiB,eAAa,eAChC,KAAK,KAAK,EAEZ,KAAK,cAAgBA,CACvB,CAMA,MAAO,CACD,CAAC,KAAK,eAAiB,KAAK,cAAc,SAG9C,KAAK,cAAc,YAAY,EAC/B,KAAK,cAAgB,OACvB,CACF,EAtKaF,EAANkB,EAAA,IADN,cAAW,GACClB",
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 r=require("purify-ts"),v=require("../../../api/command/model/CommandResult"),l=require("../../../api/command/os/GetAppAndVersionCommand"),p=require("../../../api/command/os/GetOsVersionCommand"),d=require("../../../api/device/DeviceModel"),a=require("../../../api/device/DeviceStatus"),s=require("../../device-session/data/DeviceSessionRefresherConst"),u=require("../../logger-publisher/service/DefaultLoggerPublisherService"),c=require("./DeviceSessionRefresher");const t=jest.fn().mockResolvedValue(Promise.resolve((0,r.Right)({}))),i=jest.fn().mockImplementation(()=>{});jest.useFakeTimers();describe("DeviceSessionRefresher",()=>{let e,n;beforeEach(()=>{jest.spyOn(l.GetAppAndVersionCommand.prototype,"parseResponse").mockReturnValueOnce((0,v.CommandResultFactory)({data:{name:"testAppName"}})),jest.spyOn(p.GetOsVersionCommand.prototype,"parseResponse").mockReturnValueOnce((0,v.CommandResultFactory)({data:{}})),n=new u.DefaultLoggerPublisherService([],"DeviceSessionRefresherTest")}),describe("With a modern device",()=>{beforeEach(()=>{const o=Object.values(d.DeviceModelId).filter(m=>m!==d.DeviceModelId.NANO_S);e=new c.DeviceSessionRefresher({refreshInterval:s.DEVICE_SESSION_REFRESH_INTERVAL,deviceStatus:a.DeviceStatus.CONNECTED,sendApduFn:t,updateStateFn:i,deviceModelId:o[Math.floor(Math.random()*o.length)]},n)}),afterEach(()=>{e.stop(),jest.clearAllMocks()}),it("should poll by calling sendApduFn 2 times",()=>{jest.advanceTimersByTime(s.DEVICE_SESSION_REFRESH_INTERVAL*2),expect(t).toHaveBeenCalledTimes(2)}),it("should not poll when device is busy",()=>{e.setDeviceStatus(a.DeviceStatus.BUSY),jest.advanceTimersByTime(s.DEVICE_SESSION_REFRESH_INTERVAL),expect(t).not.toHaveBeenCalled()}),it("should not poll when device is disconnected",()=>{e.setDeviceStatus(a.DeviceStatus.NOT_CONNECTED),jest.advanceTimersByTime(s.DEVICE_SESSION_REFRESH_INTERVAL),expect(t).not.toHaveBeenCalled()}),it("should update device session state by calling updateStateFn",async()=>{jest.advanceTimersByTime(s.DEVICE_SESSION_REFRESH_INTERVAL),await expect(t()).resolves.toEqual((0,r.Right)({})),expect(t).toHaveBeenCalled(),expect(i).toHaveBeenCalled()}),it("should not update device session state with failed polling response",async()=>{t.mockResolvedValueOnce(Promise.resolve((0,r.Left)("error")));const o=jest.spyOn(n,"error");jest.advanceTimersByTime(s.DEVICE_SESSION_REFRESH_INTERVAL),await t(),await expect(i).not.toHaveBeenCalled(),expect(o).toHaveBeenCalled()}),it("should stop the refresher when device is disconnected",()=>{const o=jest.spyOn(e,"stop");e.setDeviceStatus(a.DeviceStatus.NOT_CONNECTED),expect(o).toHaveBeenCalledTimes(1)}),it("should not throw error if stop is called on a stopped refresher",()=>{e.stop(),expect(()=>e.stop()).not.toThrow()}),it("should not throw error if start is called on a started refresher",()=>{e.start(),expect(()=>e.start()).not.toThrow()})}),describe("With a NanoS device",()=>{afterEach(()=>{e.stop(),jest.clearAllMocks()}),it("should call sendApduFn 2 times and update state 1 time for a single interval",async()=>{e=new c.DeviceSessionRefresher({refreshInterval:s.DEVICE_SESSION_REFRESH_INTERVAL,deviceStatus:a.DeviceStatus.CONNECTED,sendApduFn:t,updateStateFn:i,deviceModelId:d.DeviceModelId.NANO_S},n),jest.advanceTimersByTime(s.DEVICE_SESSION_REFRESH_INTERVAL*2+100),await Promise.resolve(),expect(t).toHaveBeenNthCalledWith(1,new l.GetAppAndVersionCommand().getApdu().getRawApdu()),await Promise.resolve(),expect(t).toHaveBeenLastCalledWith(new p.GetOsVersionCommand().getApdu().getRawApdu()),await Promise.resolve(),expect(t).toHaveBeenCalledTimes(2),await Promise.resolve(),expect(i).toHaveBeenCalledTimes(1)}),it("should set device locked when get os version times out",async()=>{t.mockImplementation(o=>o.toString()===new p.GetOsVersionCommand().getApdu().getRawApdu().toString()?new Promise(m=>setTimeout(()=>m((0,r.Left)("timeout")),s.DEVICE_SESSION_REFRESH_INTERVAL*10)):Promise.resolve((0,r.Right)({}))),i.mockImplementation(o=>{e.setDeviceStatus(o().deviceStatus)}),e=new c.DeviceSessionRefresher({refreshInterval:s.DEVICE_SESSION_REFRESH_INTERVAL,deviceStatus:a.DeviceStatus.CONNECTED,sendApduFn:t,updateStateFn:i,deviceModelId:d.DeviceModelId.NANO_S},n),jest.spyOn(e,"setDeviceStatus"),jest.advanceTimersByTime(s.DEVICE_SESSION_REFRESH_INTERVAL*5+100),await Promise.resolve(),expect(t).toHaveBeenNthCalledWith(1,new l.GetAppAndVersionCommand().getApdu().getRawApdu()),await Promise.resolve(),expect(e.setDeviceStatus).toHaveBeenCalledWith(a.DeviceStatus.LOCKED)})})});
1
+ "use strict";var r=require("purify-ts"),m=require("../../../api/command/model/CommandResult"),p=require("../../../api/command/os/GetAppAndVersionCommand"),l=require("../../../api/command/os/GetOsVersionCommand"),d=require("../../../api/device/DeviceModel"),i=require("../../../api/device/DeviceStatus"),s=require("../../device-session/data/DeviceSessionRefresherConst"),u=require("../../logger-publisher/service/DefaultLoggerPublisherService"),c=require("./DeviceSessionRefresher");const t=vi.fn().mockResolvedValue(Promise.resolve((0,r.Right)({}))),a=vi.fn().mockImplementation(()=>{});vi.useFakeTimers();describe("DeviceSessionRefresher",()=>{let e,n;beforeEach(()=>{vi.spyOn(p.GetAppAndVersionCommand.prototype,"parseResponse").mockReturnValueOnce((0,m.CommandResultFactory)({data:{name:"testAppName"}})),vi.spyOn(l.GetOsVersionCommand.prototype,"parseResponse").mockReturnValueOnce((0,m.CommandResultFactory)({data:{}})),n=new u.DefaultLoggerPublisherService([],"DeviceSessionRefresherTest")}),describe("With a modern device",()=>{beforeEach(()=>{const o=Object.values(d.DeviceModelId).filter(v=>v!==d.DeviceModelId.NANO_S);e=new c.DeviceSessionRefresher({refreshInterval:s.DEVICE_SESSION_REFRESH_INTERVAL,deviceStatus:i.DeviceStatus.CONNECTED,sendApduFn:t,updateStateFn:a,deviceModelId:o[Math.floor(Math.random()*o.length)]},n)}),afterEach(()=>{e.stop(),vi.clearAllMocks()}),it("should poll by calling sendApduFn 2 times",()=>{vi.advanceTimersByTime(s.DEVICE_SESSION_REFRESH_INTERVAL*2),expect(t).toHaveBeenCalledTimes(2)}),it("should not poll when device is busy",()=>{e.setDeviceStatus(i.DeviceStatus.BUSY),vi.advanceTimersByTime(s.DEVICE_SESSION_REFRESH_INTERVAL),expect(t).not.toHaveBeenCalled()}),it("should not poll when device is disconnected",()=>{e.setDeviceStatus(i.DeviceStatus.NOT_CONNECTED),vi.advanceTimersByTime(s.DEVICE_SESSION_REFRESH_INTERVAL),expect(t).not.toHaveBeenCalled()}),it("should update device session state by calling updateStateFn",async()=>{vi.advanceTimersByTime(s.DEVICE_SESSION_REFRESH_INTERVAL),await expect(t()).resolves.toEqual((0,r.Right)({})),expect(t).toHaveBeenCalled(),expect(a).toHaveBeenCalled()}),it("should not update device session state with failed polling response",async()=>{t.mockResolvedValueOnce(Promise.resolve((0,r.Left)("error")));const o=vi.spyOn(n,"error");vi.advanceTimersByTime(s.DEVICE_SESSION_REFRESH_INTERVAL),await t(),await expect(a).not.toHaveBeenCalled(),expect(o).toHaveBeenCalled()}),it("should stop the refresher when device is disconnected",()=>{const o=vi.spyOn(e,"stop");e.setDeviceStatus(i.DeviceStatus.NOT_CONNECTED),expect(o).toHaveBeenCalledTimes(1)}),it("should not throw error if stop is called on a stopped refresher",()=>{e.stop(),expect(()=>e.stop()).not.toThrow()}),it("should not throw error if start is called on a started refresher",()=>{e.start(),expect(()=>e.start()).not.toThrow()})}),describe("With a NanoS device",()=>{afterEach(()=>{e.stop(),vi.clearAllMocks()}),it("should call sendApduFn 2 times and update state 1 time for a single interval",async()=>{e=new c.DeviceSessionRefresher({refreshInterval:s.DEVICE_SESSION_REFRESH_INTERVAL,deviceStatus:i.DeviceStatus.CONNECTED,sendApduFn:t,updateStateFn:a,deviceModelId:d.DeviceModelId.NANO_S},n),vi.advanceTimersByTime(s.DEVICE_SESSION_REFRESH_INTERVAL*2+100),await Promise.resolve(),expect(t).toHaveBeenNthCalledWith(1,new p.GetAppAndVersionCommand().getApdu().getRawApdu()),await Promise.resolve(),expect(t).toHaveBeenLastCalledWith(new l.GetOsVersionCommand().getApdu().getRawApdu()),await Promise.resolve(),expect(t).toHaveBeenCalledTimes(2),await Promise.resolve(),expect(a).toHaveBeenCalledTimes(1)}),it("should set device locked when get os version times out",async()=>{t.mockImplementation(o=>o.toString()===new l.GetOsVersionCommand().getApdu().getRawApdu().toString()?new Promise(v=>setTimeout(()=>v((0,r.Left)("timeout")),s.DEVICE_SESSION_REFRESH_INTERVAL*10)):Promise.resolve((0,r.Right)({}))),a.mockImplementation(o=>{e.setDeviceStatus(o().deviceStatus)}),e=new c.DeviceSessionRefresher({refreshInterval:s.DEVICE_SESSION_REFRESH_INTERVAL,deviceStatus:i.DeviceStatus.CONNECTED,sendApduFn:t,updateStateFn:a,deviceModelId:d.DeviceModelId.NANO_S},n),vi.spyOn(e,"setDeviceStatus"),vi.advanceTimersByTime(s.DEVICE_SESSION_REFRESH_INTERVAL*5+100),await Promise.resolve(),expect(t).toHaveBeenNthCalledWith(1,new p.GetAppAndVersionCommand().getApdu().getRawApdu()),await Promise.resolve(),expect(e.setDeviceStatus).toHaveBeenCalledWith(i.DeviceStatus.LOCKED)})})});
2
2
  //# sourceMappingURL=DeviceSessionRefresher.test.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../../../src/internal/device-session/model/DeviceSessionRefresher.test.ts"],
4
- "sourcesContent": ["import { Left, Right } from \"purify-ts\";\n\nimport { CommandResultFactory } from \"@api/command/model/CommandResult\";\nimport {\n GetAppAndVersionCommand,\n type GetAppAndVersionResponse,\n} from \"@api/command/os/GetAppAndVersionCommand\";\nimport {\n GetOsVersionCommand,\n type GetOsVersionResponse,\n} from \"@api/command/os/GetOsVersionCommand\";\nimport { DeviceModelId } from \"@api/device/DeviceModel\";\nimport { DeviceStatus } from \"@api/device/DeviceStatus\";\nimport { type ApduResponse } from \"@api/device-session/ApduResponse\";\nimport { type DeviceSessionState } from \"@api/device-session/DeviceSessionState\";\nimport { type LoggerPublisherService } from \"@api/logger-publisher/service/LoggerPublisherService\";\nimport { DEVICE_SESSION_REFRESH_INTERVAL } from \"@internal/device-session/data/DeviceSessionRefresherConst\";\nimport { DefaultLoggerPublisherService } from \"@internal/logger-publisher/service/DefaultLoggerPublisherService\";\n\nimport { DeviceSessionRefresher } from \"./DeviceSessionRefresher\";\n\nconst mockSendApduFn = jest\n .fn()\n .mockResolvedValue(Promise.resolve(Right({} as ApduResponse)));\nconst mockUpdateStateFn = jest.fn().mockImplementation(() => undefined);\n\njest.useFakeTimers();\n\ndescribe(\"DeviceSessionRefresher\", () => {\n let deviceSessionRefresher: DeviceSessionRefresher;\n let logger: LoggerPublisherService;\n\n beforeEach(() => {\n jest\n .spyOn(GetAppAndVersionCommand.prototype, \"parseResponse\")\n .mockReturnValueOnce(\n CommandResultFactory({\n data: {\n name: \"testAppName\",\n } as GetAppAndVersionResponse,\n }),\n );\n jest\n .spyOn(GetOsVersionCommand.prototype, \"parseResponse\")\n .mockReturnValueOnce(\n CommandResultFactory({\n data: {} as GetOsVersionResponse,\n }),\n );\n logger = new DefaultLoggerPublisherService(\n [],\n \"DeviceSessionRefresherTest\",\n );\n });\n\n describe(\"With a modern device\", () => {\n beforeEach(() => {\n const deviceIds = Object.values(DeviceModelId).filter(\n (id) => id !== DeviceModelId.NANO_S,\n );\n deviceSessionRefresher = new DeviceSessionRefresher(\n {\n refreshInterval: DEVICE_SESSION_REFRESH_INTERVAL,\n deviceStatus: DeviceStatus.CONNECTED,\n sendApduFn: mockSendApduFn,\n updateStateFn: mockUpdateStateFn,\n deviceModelId:\n deviceIds[Math.floor(Math.random() * deviceIds.length)]!,\n },\n logger,\n );\n });\n\n afterEach(() => {\n deviceSessionRefresher.stop();\n jest.clearAllMocks();\n });\n\n it(\"should poll by calling sendApduFn 2 times\", () => {\n jest.advanceTimersByTime(DEVICE_SESSION_REFRESH_INTERVAL * 2);\n expect(mockSendApduFn).toHaveBeenCalledTimes(2);\n });\n\n it(\"should not poll when device is busy\", () => {\n deviceSessionRefresher.setDeviceStatus(DeviceStatus.BUSY);\n\n jest.advanceTimersByTime(DEVICE_SESSION_REFRESH_INTERVAL);\n\n expect(mockSendApduFn).not.toHaveBeenCalled();\n });\n\n it(\"should not poll when device is disconnected\", () => {\n deviceSessionRefresher.setDeviceStatus(DeviceStatus.NOT_CONNECTED);\n\n jest.advanceTimersByTime(DEVICE_SESSION_REFRESH_INTERVAL);\n\n expect(mockSendApduFn).not.toHaveBeenCalled();\n });\n\n it(\"should update device session state by calling updateStateFn\", async () => {\n jest.advanceTimersByTime(DEVICE_SESSION_REFRESH_INTERVAL);\n\n await expect(mockSendApduFn()).resolves.toEqual(Right({}));\n expect(mockSendApduFn).toHaveBeenCalled();\n expect(mockUpdateStateFn).toHaveBeenCalled();\n });\n\n it(\"should not update device session state with failed polling response\", async () => {\n mockSendApduFn.mockResolvedValueOnce(Promise.resolve(Left(\"error\")));\n const spy = jest.spyOn(logger, \"error\");\n\n jest.advanceTimersByTime(DEVICE_SESSION_REFRESH_INTERVAL);\n await mockSendApduFn();\n\n await expect(mockUpdateStateFn).not.toHaveBeenCalled();\n expect(spy).toHaveBeenCalled();\n });\n\n it(\"should stop the refresher when device is disconnected\", () => {\n const spy = jest.spyOn(deviceSessionRefresher, \"stop\");\n deviceSessionRefresher.setDeviceStatus(DeviceStatus.NOT_CONNECTED);\n expect(spy).toHaveBeenCalledTimes(1);\n });\n\n it(\"should not throw error if stop is called on a stopped refresher\", () => {\n deviceSessionRefresher.stop();\n expect(() => deviceSessionRefresher.stop()).not.toThrow();\n });\n\n it(\"should not throw error if start is called on a started refresher\", () => {\n deviceSessionRefresher.start();\n expect(() => deviceSessionRefresher.start()).not.toThrow();\n });\n });\n\n describe(\"With a NanoS device\", () => {\n afterEach(() => {\n deviceSessionRefresher.stop();\n jest.clearAllMocks();\n });\n\n it(\"should call sendApduFn 2 times and update state 1 time for a single interval\", async () => {\n deviceSessionRefresher = new DeviceSessionRefresher(\n {\n refreshInterval: DEVICE_SESSION_REFRESH_INTERVAL,\n deviceStatus: DeviceStatus.CONNECTED,\n sendApduFn: mockSendApduFn,\n updateStateFn: mockUpdateStateFn,\n deviceModelId: DeviceModelId.NANO_S,\n },\n logger,\n );\n jest.advanceTimersByTime(DEVICE_SESSION_REFRESH_INTERVAL * 2 + 100);\n\n await Promise.resolve();\n expect(mockSendApduFn).toHaveBeenNthCalledWith(\n 1,\n new GetAppAndVersionCommand().getApdu().getRawApdu(),\n );\n await Promise.resolve();\n expect(mockSendApduFn).toHaveBeenLastCalledWith(\n new GetOsVersionCommand().getApdu().getRawApdu(),\n );\n await Promise.resolve();\n expect(mockSendApduFn).toHaveBeenCalledTimes(2);\n await Promise.resolve();\n expect(mockUpdateStateFn).toHaveBeenCalledTimes(1);\n });\n\n it(\"should set device locked when get os version times out\", async () => {\n mockSendApduFn.mockImplementation((apdu) => {\n if (\n apdu.toString() ===\n new GetOsVersionCommand().getApdu().getRawApdu().toString()\n ) {\n return new Promise((resolve) =>\n setTimeout(\n () => resolve(Left(\"timeout\")),\n DEVICE_SESSION_REFRESH_INTERVAL * 10,\n ),\n );\n }\n return Promise.resolve(Right({}));\n });\n mockUpdateStateFn.mockImplementation(\n (getState: () => DeviceSessionState) => {\n deviceSessionRefresher.setDeviceStatus(getState().deviceStatus);\n },\n );\n deviceSessionRefresher = new DeviceSessionRefresher(\n {\n refreshInterval: DEVICE_SESSION_REFRESH_INTERVAL,\n deviceStatus: DeviceStatus.CONNECTED,\n sendApduFn: mockSendApduFn,\n updateStateFn: mockUpdateStateFn,\n deviceModelId: DeviceModelId.NANO_S,\n },\n logger,\n );\n jest.spyOn(deviceSessionRefresher, \"setDeviceStatus\");\n jest.advanceTimersByTime(DEVICE_SESSION_REFRESH_INTERVAL * 5 + 100);\n await Promise.resolve();\n expect(mockSendApduFn).toHaveBeenNthCalledWith(\n 1,\n new GetAppAndVersionCommand().getApdu().getRawApdu(),\n );\n await Promise.resolve();\n expect(deviceSessionRefresher.setDeviceStatus).toHaveBeenCalledWith(\n DeviceStatus.LOCKED,\n );\n });\n });\n});\n"],
5
- "mappings": "aAAA,IAAAA,EAA4B,qBAE5BC,EAAqC,4CACrCC,EAGO,mDACPC,EAGO,+CACPC,EAA8B,mCAC9BC,EAA6B,oCAI7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GAAG,EAElE,MAAM,QAAQ,QAAQ,EACtB,OAAOH,CAAc,EAAE,wBACrB,EACA,IAAI,0BAAwB,EAAE,QAAQ,EAAE,WAAW,CACrD,EACA,MAAM,QAAQ,QAAQ,EACtB,OAAOA,CAAc,EAAE,yBACrB,IAAI,sBAAoB,EAAE,QAAQ,EAAE,WAAW,CACjD,EACA,MAAM,QAAQ,QAAQ,EACtB,OAAOA,CAAc,EAAE,sBAAsB,CAAC,EAC9C,MAAM,QAAQ,QAAQ,EACtB,OAAOC,CAAiB,EAAE,sBAAsB,CAAC,CACnD,CAAC,EAED,GAAG,yDAA0D,SAAY,CACvED,EAAe,mBAAoBO,GAE/BA,EAAK,SAAS,IACd,IAAI,sBAAoB,EAAE,QAAQ,EAAE,WAAW,EAAE,SAAS,EAEnD,IAAI,QAASC,GAClB,WACE,IAAMA,KAAQ,QAAK,SAAS,CAAC,EAC7B,kCAAkC,EACpC,CACF,EAEK,QAAQ,WAAQ,SAAM,CAAC,CAAC,CAAC,CACjC,EACDP,EAAkB,mBACfQ,GAAuC,CACtCP,EAAuB,gBAAgBO,EAAS,EAAE,YAAY,CAChE,CACF,EACAP,EAAyB,IAAI,yBAC3B,CACE,gBAAiB,kCACjB,aAAc,eAAa,UAC3B,WAAYF,EACZ,cAAeC,EACf,cAAe,gBAAc,MAC/B,EACAE,CACF,EACA,KAAK,MAAMD,EAAwB,iBAAiB,EACpD,KAAK,oBAAoB,kCAAkC,EAAI,GAAG,EAClE,MAAM,QAAQ,QAAQ,EACtB,OAAOF,CAAc,EAAE,wBACrB,EACA,IAAI,0BAAwB,EAAE,QAAQ,EAAE,WAAW,CACrD,EACA,MAAM,QAAQ,QAAQ,EACtB,OAAOE,EAAuB,eAAe,EAAE,qBAC7C,eAAa,MACf,CACF,CAAC,CACH,CAAC,CACH,CAAC",
4
+ "sourcesContent": ["import { Left, Right } from \"purify-ts\";\n\nimport { type Apdu } from \"@api/apdu/model/Apdu\";\nimport { CommandResultFactory } from \"@api/command/model/CommandResult\";\nimport {\n GetAppAndVersionCommand,\n type GetAppAndVersionResponse,\n} from \"@api/command/os/GetAppAndVersionCommand\";\nimport {\n GetOsVersionCommand,\n type GetOsVersionResponse,\n} from \"@api/command/os/GetOsVersionCommand\";\nimport { DeviceModelId } from \"@api/device/DeviceModel\";\nimport { DeviceStatus } from \"@api/device/DeviceStatus\";\nimport { type ApduResponse } from \"@api/device-session/ApduResponse\";\nimport { type DeviceSessionState } from \"@api/device-session/DeviceSessionState\";\nimport { type LoggerPublisherService } from \"@api/logger-publisher/service/LoggerPublisherService\";\nimport { DEVICE_SESSION_REFRESH_INTERVAL } from \"@internal/device-session/data/DeviceSessionRefresherConst\";\nimport { DefaultLoggerPublisherService } from \"@internal/logger-publisher/service/DefaultLoggerPublisherService\";\n\nimport { DeviceSessionRefresher } from \"./DeviceSessionRefresher\";\n\nconst mockSendApduFn = vi\n .fn()\n .mockResolvedValue(Promise.resolve(Right({} as ApduResponse)));\nconst mockUpdateStateFn = vi.fn().mockImplementation(() => undefined);\n\nvi.useFakeTimers();\n\ndescribe(\"DeviceSessionRefresher\", () => {\n let deviceSessionRefresher: DeviceSessionRefresher;\n let logger: LoggerPublisherService;\n\n beforeEach(() => {\n vi.spyOn(\n GetAppAndVersionCommand.prototype,\n \"parseResponse\",\n ).mockReturnValueOnce(\n CommandResultFactory({\n data: {\n name: \"testAppName\",\n } as GetAppAndVersionResponse,\n }),\n );\n vi.spyOn(\n GetOsVersionCommand.prototype,\n \"parseResponse\",\n ).mockReturnValueOnce(\n CommandResultFactory({\n data: {} as GetOsVersionResponse,\n }),\n );\n logger = new DefaultLoggerPublisherService(\n [],\n \"DeviceSessionRefresherTest\",\n );\n });\n\n describe(\"With a modern device\", () => {\n beforeEach(() => {\n const deviceIds = Object.values(DeviceModelId).filter(\n (id) => id !== DeviceModelId.NANO_S,\n );\n deviceSessionRefresher = new DeviceSessionRefresher(\n {\n refreshInterval: DEVICE_SESSION_REFRESH_INTERVAL,\n deviceStatus: DeviceStatus.CONNECTED,\n sendApduFn: mockSendApduFn,\n updateStateFn: mockUpdateStateFn,\n deviceModelId:\n deviceIds[Math.floor(Math.random() * deviceIds.length)]!,\n },\n logger,\n );\n });\n\n afterEach(() => {\n deviceSessionRefresher.stop();\n vi.clearAllMocks();\n });\n\n it(\"should poll by calling sendApduFn 2 times\", () => {\n vi.advanceTimersByTime(DEVICE_SESSION_REFRESH_INTERVAL * 2);\n expect(mockSendApduFn).toHaveBeenCalledTimes(2);\n });\n\n it(\"should not poll when device is busy\", () => {\n deviceSessionRefresher.setDeviceStatus(DeviceStatus.BUSY);\n\n vi.advanceTimersByTime(DEVICE_SESSION_REFRESH_INTERVAL);\n\n expect(mockSendApduFn).not.toHaveBeenCalled();\n });\n\n it(\"should not poll when device is disconnected\", () => {\n deviceSessionRefresher.setDeviceStatus(DeviceStatus.NOT_CONNECTED);\n\n vi.advanceTimersByTime(DEVICE_SESSION_REFRESH_INTERVAL);\n\n expect(mockSendApduFn).not.toHaveBeenCalled();\n });\n\n it(\"should update device session state by calling updateStateFn\", async () => {\n vi.advanceTimersByTime(DEVICE_SESSION_REFRESH_INTERVAL);\n\n await expect(mockSendApduFn()).resolves.toEqual(Right({}));\n expect(mockSendApduFn).toHaveBeenCalled();\n expect(mockUpdateStateFn).toHaveBeenCalled();\n });\n\n it(\"should not update device session state with failed polling response\", async () => {\n mockSendApduFn.mockResolvedValueOnce(Promise.resolve(Left(\"error\")));\n const spy = vi.spyOn(logger, \"error\");\n\n vi.advanceTimersByTime(DEVICE_SESSION_REFRESH_INTERVAL);\n await mockSendApduFn();\n\n await expect(mockUpdateStateFn).not.toHaveBeenCalled();\n expect(spy).toHaveBeenCalled();\n });\n\n it(\"should stop the refresher when device is disconnected\", () => {\n const spy = vi.spyOn(deviceSessionRefresher, \"stop\");\n deviceSessionRefresher.setDeviceStatus(DeviceStatus.NOT_CONNECTED);\n expect(spy).toHaveBeenCalledTimes(1);\n });\n\n it(\"should not throw error if stop is called on a stopped refresher\", () => {\n deviceSessionRefresher.stop();\n expect(() => deviceSessionRefresher.stop()).not.toThrow();\n });\n\n it(\"should not throw error if start is called on a started refresher\", () => {\n deviceSessionRefresher.start();\n expect(() => deviceSessionRefresher.start()).not.toThrow();\n });\n });\n\n describe(\"With a NanoS device\", () => {\n afterEach(() => {\n deviceSessionRefresher.stop();\n vi.clearAllMocks();\n });\n\n it(\"should call sendApduFn 2 times and update state 1 time for a single interval\", async () => {\n deviceSessionRefresher = new DeviceSessionRefresher(\n {\n refreshInterval: DEVICE_SESSION_REFRESH_INTERVAL,\n deviceStatus: DeviceStatus.CONNECTED,\n sendApduFn: mockSendApduFn,\n updateStateFn: mockUpdateStateFn,\n deviceModelId: DeviceModelId.NANO_S,\n },\n logger,\n );\n vi.advanceTimersByTime(DEVICE_SESSION_REFRESH_INTERVAL * 2 + 100);\n\n await Promise.resolve();\n expect(mockSendApduFn).toHaveBeenNthCalledWith(\n 1,\n new GetAppAndVersionCommand().getApdu().getRawApdu(),\n );\n await Promise.resolve();\n expect(mockSendApduFn).toHaveBeenLastCalledWith(\n new GetOsVersionCommand().getApdu().getRawApdu(),\n );\n await Promise.resolve();\n expect(mockSendApduFn).toHaveBeenCalledTimes(2);\n await Promise.resolve();\n expect(mockUpdateStateFn).toHaveBeenCalledTimes(1);\n });\n\n it(\"should set device locked when get os version times out\", async () => {\n mockSendApduFn.mockImplementation((apdu: Apdu) => {\n if (\n apdu.toString() ===\n new GetOsVersionCommand().getApdu().getRawApdu().toString()\n ) {\n return new Promise((resolve) =>\n setTimeout(\n () => resolve(Left(\"timeout\")),\n DEVICE_SESSION_REFRESH_INTERVAL * 10,\n ),\n );\n }\n return Promise.resolve(Right({}));\n });\n mockUpdateStateFn.mockImplementation(\n (getState: () => DeviceSessionState) => {\n deviceSessionRefresher.setDeviceStatus(getState().deviceStatus);\n },\n );\n deviceSessionRefresher = new DeviceSessionRefresher(\n {\n refreshInterval: DEVICE_SESSION_REFRESH_INTERVAL,\n deviceStatus: DeviceStatus.CONNECTED,\n sendApduFn: mockSendApduFn,\n updateStateFn: mockUpdateStateFn,\n deviceModelId: DeviceModelId.NANO_S,\n },\n logger,\n );\n vi.spyOn(deviceSessionRefresher, \"setDeviceStatus\");\n vi.advanceTimersByTime(DEVICE_SESSION_REFRESH_INTERVAL * 5 + 100);\n await Promise.resolve();\n expect(mockSendApduFn).toHaveBeenNthCalledWith(\n 1,\n new GetAppAndVersionCommand().getApdu().getRawApdu(),\n );\n await Promise.resolve();\n expect(deviceSessionRefresher.setDeviceStatus).toHaveBeenCalledWith(\n DeviceStatus.LOCKED,\n );\n });\n });\n});\n"],
5
+ "mappings": "aAAA,IAAAA,EAA4B,qBAG5BC,EAAqC,4CACrCC,EAGO,mDACPC,EAGO,+CACPC,EAA8B,mCAC9BC,EAA6B,oCAI7BC,EAAgD,qEAChDC,EAA8C,4EAE9CC,EAAuC,oCAEvC,MAAMC,EAAiB,GACpB,GAAG,EACH,kBAAkB,QAAQ,WAAQ,SAAM,CAAC,CAAiB,CAAC,CAAC,EACzDC,EAAoB,GAAG,GAAG,EAAE,mBAAmB,IAAG,EAAY,EAEpE,GAAG,cAAc,EAEjB,SAAS,yBAA0B,IAAM,CACvC,IAAIC,EACAC,EAEJ,WAAW,IAAM,CACf,GAAG,MACD,0BAAwB,UACxB,eACF,EAAE,uBACA,wBAAqB,CACnB,KAAM,CACJ,KAAM,aACR,CACF,CAAC,CACH,EACA,GAAG,MACD,sBAAoB,UACpB,eACF,EAAE,uBACA,wBAAqB,CACnB,KAAM,CAAC,CACT,CAAC,CACH,EACAA,EAAS,IAAI,gCACX,CAAC,EACD,4BACF,CACF,CAAC,EAED,SAAS,uBAAwB,IAAM,CACrC,WAAW,IAAM,CACf,MAAMC,EAAY,OAAO,OAAO,eAAa,EAAE,OAC5CC,GAAOA,IAAO,gBAAc,MAC/B,EACAH,EAAyB,IAAI,yBAC3B,CACE,gBAAiB,kCACjB,aAAc,eAAa,UAC3B,WAAYF,EACZ,cAAeC,EACf,cAC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BAC3B,CACE,gBAAiB,kCACjB,aAAc,eAAa,UAC3B,WAAYF,EACZ,cAAeC,EACf,cAAe,gBAAc,MAC/B,EACAE,CACF,EACA,GAAG,MAAMD,EAAwB,iBAAiB,EAClD,GAAG,oBAAoB,kCAAkC,EAAI,GAAG,EAChE,MAAM,QAAQ,QAAQ,EACtB,OAAOF,CAAc,EAAE,wBACrB,EACA,IAAI,0BAAwB,EAAE,QAAQ,EAAE,WAAW,CACrD,EACA,MAAM,QAAQ,QAAQ,EACtB,OAAOE,EAAuB,eAAe,EAAE,qBAC7C,eAAa,MACf,CACF,CAAC,CACH,CAAC,CACH,CAAC",
6
6
  "names": ["import_purify_ts", "import_CommandResult", "import_GetAppAndVersionCommand", "import_GetOsVersionCommand", "import_DeviceModel", "import_DeviceStatus", "import_DeviceSessionRefresherConst", "import_DefaultLoggerPublisherService", "import_DeviceSessionRefresher", "mockSendApduFn", "mockUpdateStateFn", "deviceSessionRefresher", "logger", "deviceIds", "id", "spy", "apdu", "resolve", "getState"]
7
7
  }
@@ -1,2 +1,2 @@
1
- "use strict";var e=require("purify-ts"),s=require("../../../api/device-session/ApduResponse"),c=require("../../device-session/model/Errors"),f=require("../../logger-publisher/service/DefaultLoggerPublisherService"),d=require("./DefaultApduReceiverService");jest.mock("uuid");const u=new f.DefaultLoggerPublisherService([],"frame"),o=new Uint8Array([170,170,5,0,0,0,33,51,0,0,4,5,50,46,50,46,51,4,230,0,0,0,4,50,46,51,48,4,49,46,49,54,1,1,1,0,1,0,144,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]),p=new Uint8Array([170,170,5,0,0,0,2,85,21,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]),t=[new Uint8Array([170,170,5,0,0,0,158,1,77,0,19,202,80,250,161,145,64,154,107,250,108,15,187,178,231,196,169,207,229,87,65,0,93,189,132,171,154,189,102,199,108,144,221,8,121,13,8,71,185,58,143,167,111,96,51,174,211,37,215,177,229,124,235,215]),new Uint8Array([170,170,5,0,1,75,46,44,159,180,70,120,222,5,95,158,128,10,7,66,105,116,99,111,105,110,78,0,21,202,64,6,3,40,248,143,198,214,66,152,208,73,0,199,4,152,25,27,108,235,237,216,203,132,93,245,75,227,189,187,37,122,63,111]),new Uint8Array([170,170,5,0,2,104,143,84,239,127,170,196,34,170,84,231,184,10,200,163,47,150,229,94,67,45,243,163,69,141,142,170,241,78,209,30,8,69,116,104,101,114,101,117,109,144,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0])];describe("DefaultApduReceiverService",()=>{let r;beforeAll(()=>{jest.mock("uuid",()=>({v4:jest.fn().mockReturnValue("42")}))}),describe("without dataSize",()=>{beforeEach(()=>{r=new d.DefaultApduReceiverService({channel:(0,e.Just)(new Uint8Array([170,170]))},()=>u)}),it("should return a left error when the first frame has no dataSize",()=>{const a=t[1],x=r.handleFrame(a);expect(x).toEqual((0,e.Left)(new c.ReceiverApduError))})}),describe("[USB] With padding and channel",()=>{beforeEach(()=>{r=new d.DefaultApduReceiverService({channel:(0,e.Just)(new Uint8Array([170,170]))},()=>u)}),it("should return a response directly when a frame is complete",()=>{const a=o,x=r.handleFrame(a);expect(x).toEqual((0,e.Right)((0,e.Just)(new s.ApduResponse({data:o.slice(7,38),statusCode:new Uint8Array([144,0])}))))}),it("should return a response on a third frame when the two first are not complete",()=>{const a=[...t];let x=e.Nothing;const n=[];for(;x.isNothing();){const i=a.shift();r.handleFrame(i).map(l=>{x=l,n.push(x)})}expect(n).toEqual([e.Nothing,e.Nothing,(0,e.Just)(new s.ApduResponse({data:new Uint8Array([...Array.from(t[0].slice(7)),...Array.from(t[1].slice(5)),...Array.from(t[2]).slice(5,45)]),statusCode:new Uint8Array([144,0])}))])}),it("should return two response directly when each frame is complete",()=>{const a=p,x=o,n=r.handleFrame(a),i=r.handleFrame(x);expect(n).toEqual((0,e.Right)((0,e.Just)(new s.ApduResponse({data:new Uint8Array([]),statusCode:new Uint8Array([85,21])})))),expect(i).toEqual((0,e.Right)((0,e.Just)(new s.ApduResponse({data:o.slice(7,38),statusCode:new Uint8Array([144,0])}))))}),it("should return an error if the frame is without index",()=>{const a=t[0].slice(0,4),x=r.handleFrame(a);expect(x).toEqual((0,e.Left)(new c.ReceiverApduError("Unable to parse header from apdu")))}),it("should return an error if the frame is without datasize",()=>{const a=t[0].slice(0,6),x=r.handleFrame(a);expect(x).toEqual((0,e.Left)(new c.ReceiverApduError("Unable to parse header from apdu")))})}),describe("[BLE] Without padding nor channel",()=>{beforeEach(()=>{r=new d.DefaultApduReceiverService({},()=>u)}),it("should return a response directly when a frame is complete",()=>{const a=o.slice(2,40),x=r.handleFrame(a);expect(x).toEqual((0,e.Right)((0,e.Just)(new s.ApduResponse({data:o.slice(7,38),statusCode:new Uint8Array([144,0])}))))}),it("should return a response on a third frame when the two first are not complete",()=>{const a=[t[0].slice(2),t[1].slice(2),t[2].slice(2,47)];let x=e.Nothing;const n=[];for(;x.isNothing();){const i=a.shift();r.handleFrame(i).map(l=>{x=l,n.push(x)})}expect(n).toEqual([e.Nothing,e.Nothing,(0,e.Just)(new s.ApduResponse({data:new Uint8Array([...Array.from(t[0].slice(7)),...Array.from(t[1].slice(5)),...Array.from(t[2]).slice(5,45)]),statusCode:new Uint8Array([144,0])}))])}),it("should return two response directly when each frame is complete",()=>{const a=p.slice(2,9),x=o.slice(2,40),n=r.handleFrame(a),i=r.handleFrame(x);expect(n).toEqual((0,e.Right)((0,e.Just)(new s.ApduResponse({data:new Uint8Array([]),statusCode:new Uint8Array([85,21])})))),expect(i).toEqual((0,e.Right)((0,e.Just)(new s.ApduResponse({data:o.slice(7,38),statusCode:new Uint8Array([144,0])}))))}),it("should return an error if the frame is without index",()=>{const a=t[0].slice(2,4),x=r.handleFrame(a);expect(x).toEqual((0,e.Left)(new c.ReceiverApduError("Unable to parse header from apdu")))}),it("should return an error if the frame is without datasize",()=>{const a=t[0].slice(2,6),x=r.handleFrame(a);expect(x).toEqual((0,e.Left)(new c.ReceiverApduError("Unable to parse header from apdu")))})})});
1
+ "use strict";var e=require("purify-ts"),s=require("../../../api/device-session/ApduResponse"),c=require("../../device-session/model/Errors"),f=require("../../logger-publisher/service/DefaultLoggerPublisherService"),d=require("./DefaultApduReceiverService");vi.mock("uuid");const u=new f.DefaultLoggerPublisherService([],"frame"),o=new Uint8Array([170,170,5,0,0,0,33,51,0,0,4,5,50,46,50,46,51,4,230,0,0,0,4,50,46,51,48,4,49,46,49,54,1,1,1,0,1,0,144,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]),p=new Uint8Array([170,170,5,0,0,0,2,85,21,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]),t=[new Uint8Array([170,170,5,0,0,0,158,1,77,0,19,202,80,250,161,145,64,154,107,250,108,15,187,178,231,196,169,207,229,87,65,0,93,189,132,171,154,189,102,199,108,144,221,8,121,13,8,71,185,58,143,167,111,96,51,174,211,37,215,177,229,124,235,215]),new Uint8Array([170,170,5,0,1,75,46,44,159,180,70,120,222,5,95,158,128,10,7,66,105,116,99,111,105,110,78,0,21,202,64,6,3,40,248,143,198,214,66,152,208,73,0,199,4,152,25,27,108,235,237,216,203,132,93,245,75,227,189,187,37,122,63,111]),new Uint8Array([170,170,5,0,2,104,143,84,239,127,170,196,34,170,84,231,184,10,200,163,47,150,229,94,67,45,243,163,69,141,142,170,241,78,209,30,8,69,116,104,101,114,101,117,109,144,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0])];describe("DefaultApduReceiverService",()=>{let r;beforeAll(()=>{vi.mock("uuid",()=>({v4:vi.fn().mockReturnValue("42")}))}),describe("without dataSize",()=>{beforeEach(()=>{r=new d.DefaultApduReceiverService({channel:(0,e.Just)(new Uint8Array([170,170]))},()=>u)}),it("should return a left error when the first frame has no dataSize",()=>{const a=t[1],x=r.handleFrame(a);expect(x).toEqual((0,e.Left)(new c.ReceiverApduError))})}),describe("[USB] With padding and channel",()=>{beforeEach(()=>{r=new d.DefaultApduReceiverService({channel:(0,e.Just)(new Uint8Array([170,170]))},()=>u)}),it("should return a response directly when a frame is complete",()=>{const a=o,x=r.handleFrame(a);expect(x).toEqual((0,e.Right)((0,e.Just)(new s.ApduResponse({data:o.slice(7,38),statusCode:new Uint8Array([144,0])}))))}),it("should return a response on a third frame when the two first are not complete",()=>{const a=[...t];let x=e.Nothing;const n=[];for(;x.isNothing();){const i=a.shift();r.handleFrame(i).map(l=>{x=l,n.push(x)})}expect(n).toEqual([e.Nothing,e.Nothing,(0,e.Just)(new s.ApduResponse({data:new Uint8Array([...Array.from(t[0].slice(7)),...Array.from(t[1].slice(5)),...Array.from(t[2]).slice(5,45)]),statusCode:new Uint8Array([144,0])}))])}),it("should return two response directly when each frame is complete",()=>{const a=p,x=o,n=r.handleFrame(a),i=r.handleFrame(x);expect(n).toEqual((0,e.Right)((0,e.Just)(new s.ApduResponse({data:new Uint8Array([]),statusCode:new Uint8Array([85,21])})))),expect(i).toEqual((0,e.Right)((0,e.Just)(new s.ApduResponse({data:o.slice(7,38),statusCode:new Uint8Array([144,0])}))))}),it("should return an error if the frame is without index",()=>{const a=t[0].slice(0,4),x=r.handleFrame(a);expect(x).toEqual((0,e.Left)(new c.ReceiverApduError("Unable to parse header from apdu")))}),it("should return an error if the frame is without datasize",()=>{const a=t[0].slice(0,6),x=r.handleFrame(a);expect(x).toEqual((0,e.Left)(new c.ReceiverApduError("Unable to parse header from apdu")))})}),describe("[BLE] Without padding nor channel",()=>{beforeEach(()=>{r=new d.DefaultApduReceiverService({},()=>u)}),it("should return a response directly when a frame is complete",()=>{const a=o.slice(2,40),x=r.handleFrame(a);expect(x).toEqual((0,e.Right)((0,e.Just)(new s.ApduResponse({data:o.slice(7,38),statusCode:new Uint8Array([144,0])}))))}),it("should return a response on a third frame when the two first are not complete",()=>{const a=[t[0].slice(2),t[1].slice(2),t[2].slice(2,47)];let x=e.Nothing;const n=[];for(;x.isNothing();){const i=a.shift();r.handleFrame(i).map(l=>{x=l,n.push(x)})}expect(n).toEqual([e.Nothing,e.Nothing,(0,e.Just)(new s.ApduResponse({data:new Uint8Array([...Array.from(t[0].slice(7)),...Array.from(t[1].slice(5)),...Array.from(t[2]).slice(5,45)]),statusCode:new Uint8Array([144,0])}))])}),it("should return two response directly when each frame is complete",()=>{const a=p.slice(2,9),x=o.slice(2,40),n=r.handleFrame(a),i=r.handleFrame(x);expect(n).toEqual((0,e.Right)((0,e.Just)(new s.ApduResponse({data:new Uint8Array([]),statusCode:new Uint8Array([85,21])})))),expect(i).toEqual((0,e.Right)((0,e.Just)(new s.ApduResponse({data:o.slice(7,38),statusCode:new Uint8Array([144,0])}))))}),it("should return an error if the frame is without index",()=>{const a=t[0].slice(2,4),x=r.handleFrame(a);expect(x).toEqual((0,e.Left)(new c.ReceiverApduError("Unable to parse header from apdu")))}),it("should return an error if the frame is without datasize",()=>{const a=t[0].slice(2,6),x=r.handleFrame(a);expect(x).toEqual((0,e.Left)(new c.ReceiverApduError("Unable to parse header from apdu")))})})});
2
2
  //# sourceMappingURL=DefaultApduReceiverService.test.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../../../src/internal/device-session/service/DefaultApduReceiverService.test.ts"],
4
- "sourcesContent": ["jest.mock(\"uuid\");\n\nimport { Just, Left, type Maybe, Nothing, Right } from \"purify-ts\";\n\nimport { ApduResponse } from \"@api/device-session/ApduResponse\";\nimport { type ApduReceiverService } from \"@api/device-session/service/ApduReceiverService\";\nimport { ReceiverApduError } from \"@internal/device-session/model/Errors\";\nimport { DefaultLoggerPublisherService } from \"@internal/logger-publisher/service/DefaultLoggerPublisherService\";\n\nimport { DefaultApduReceiverService } from \"./DefaultApduReceiverService\";\n\nconst loggerService = new DefaultLoggerPublisherService([], \"frame\");\n\nconst RESPONSE_GET_VERSION = new Uint8Array([\n 0xaa, 0xaa, 0x05, 0x00, 0x00, 0x00, 0x21, 0x33, 0x00, 0x00, 0x04, 0x05, 0x32,\n 0x2e, 0x32, 0x2e, 0x33, 0x04, 0xe6, 0x00, 0x00, 0x00, 0x04, 0x32, 0x2e, 0x33,\n 0x30, 0x04, 0x31, 0x2e, 0x31, 0x36, 0x01, 0x01, 0x01, 0x00, 0x01, 0x00, 0x90,\n 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,\n 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,\n]);\n\nconst RESPONSE_LOCKED_DEVICE = new Uint8Array([\n 0xaa, 0xaa, 0x05, 0x00, 0x00, 0x00, 0x02, 0x55, 0x15, 0x00, 0x00, 0x00, 0x00,\n 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,\n 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,\n 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,\n 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,\n]);\n\nconst RESPONSE_LIST_APPS = [\n new Uint8Array([\n 0xaa, 0xaa, 0x05, 0x00, 0x00, 0x00, 0x9e, 0x01, 0x4d, 0x00, 0x13, 0xca,\n 0x50, 0xfa, 0xa1, 0x91, 0x40, 0x9a, 0x6b, 0xfa, 0x6c, 0x0f, 0xbb, 0xb2,\n 0xe7, 0xc4, 0xa9, 0xcf, 0xe5, 0x57, 0x41, 0x00, 0x5d, 0xbd, 0x84, 0xab,\n 0x9a, 0xbd, 0x66, 0xc7, 0x6c, 0x90, 0xdd, 0x08, 0x79, 0x0d, 0x08, 0x47,\n 0xb9, 0x3a, 0x8f, 0xa7, 0x6f, 0x60, 0x33, 0xae, 0xd3, 0x25, 0xd7, 0xb1,\n 0xe5, 0x7c, 0xeb, 0xd7,\n ]),\n new Uint8Array([\n 0xaa, 0xaa, 0x05, 0x00, 0x01, 0x4b, 0x2e, 0x2c, 0x9f, 0xb4, 0x46, 0x78,\n 0xde, 0x05, 0x5f, 0x9e, 0x80, 0x0a, 0x07, 0x42, 0x69, 0x74, 0x63, 0x6f,\n 0x69, 0x6e, 0x4e, 0x00, 0x15, 0xca, 0x40, 0x06, 0x03, 0x28, 0xf8, 0x8f,\n 0xc6, 0xd6, 0x42, 0x98, 0xd0, 0x49, 0x00, 0xc7, 0x04, 0x98, 0x19, 0x1b,\n 0x6c, 0xeb, 0xed, 0xd8, 0xcb, 0x84, 0x5d, 0xf5, 0x4b, 0xe3, 0xbd, 0xbb,\n 0x25, 0x7a, 0x3f, 0x6f,\n ]),\n new Uint8Array([\n 0xaa, 0xaa, 0x05, 0x00, 0x02, 0x68, 0x8f, 0x54, 0xef, 0x7f, 0xaa, 0xc4,\n 0x22, 0xaa, 0x54, 0xe7, 0xb8, 0x0a, 0xc8, 0xa3, 0x2f, 0x96, 0xe5, 0x5e,\n 0x43, 0x2d, 0xf3, 0xa3, 0x45, 0x8d, 0x8e, 0xaa, 0xf1, 0x4e, 0xd1, 0x1e,\n 0x08, 0x45, 0x74, 0x68, 0x65, 0x72, 0x65, 0x75, 0x6d, 0x90, 0x00, 0x00,\n 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,\n 0x00, 0x00, 0x00,\n ]),\n];\n\ndescribe(\"DefaultApduReceiverService\", () => {\n let service: ApduReceiverService;\n\n beforeAll(() => {\n jest.mock(\"uuid\", () => ({\n v4: jest.fn().mockReturnValue(\"42\"),\n }));\n });\n\n describe(\"without dataSize\", () => {\n beforeEach(() => {\n service = new DefaultApduReceiverService(\n { channel: Just(new Uint8Array([0xaa, 0xaa])) },\n () => loggerService,\n );\n });\n\n it(\"should return a left error when the first frame has no dataSize\", () => {\n //given\n const frame = RESPONSE_LIST_APPS[1]!;\n\n //when\n const apdu = service.handleFrame(frame);\n\n //then\n expect(apdu).toEqual(Left(new ReceiverApduError()));\n });\n });\n\n describe(\"[USB] With padding and channel\", () => {\n beforeEach(() => {\n service = new DefaultApduReceiverService(\n { channel: Just(new Uint8Array([0xaa, 0xaa])) },\n () => loggerService,\n );\n });\n\n it(\"should return a response directly when a frame is complete\", () => {\n // given\n const frame = RESPONSE_GET_VERSION;\n\n // when\n const apdu = service.handleFrame(frame);\n\n // then\n expect(apdu).toEqual(\n Right(\n Just(\n new ApduResponse({\n data: RESPONSE_GET_VERSION.slice(7, 38),\n statusCode: new Uint8Array([0x90, 0x00]),\n }),\n ),\n ),\n );\n });\n\n it(\"should return a response on a third frame when the two first are not complete\", () => {\n //given\n const apdus = [...RESPONSE_LIST_APPS];\n\n //when\n let response: Maybe<ApduResponse> = Nothing;\n const responses: Maybe<ApduResponse>[] = [];\n while (response.isNothing()) {\n const apdu = apdus.shift()!;\n const either = service.handleFrame(apdu);\n\n either.map((value) => {\n response = value;\n responses.push(response);\n });\n }\n\n //then\n expect(responses).toEqual([\n Nothing,\n Nothing,\n Just(\n new ApduResponse({\n data: new Uint8Array([\n ...Array.from(RESPONSE_LIST_APPS[0]!.slice(7)),\n ...Array.from(RESPONSE_LIST_APPS[1]!.slice(5)),\n ...Array.from(RESPONSE_LIST_APPS[2]!).slice(5, 45),\n ]),\n statusCode: new Uint8Array([0x90, 0x00]),\n }),\n ),\n ]);\n });\n\n it(\"should return two response directly when each frame is complete\", () => {\n // given\n const firstFrame = RESPONSE_LOCKED_DEVICE;\n const secondFrame = RESPONSE_GET_VERSION;\n\n // when\n const firstResponse = service.handleFrame(firstFrame);\n const secondResponse = service.handleFrame(secondFrame);\n\n // then\n expect(firstResponse).toEqual(\n Right(\n Just(\n new ApduResponse({\n data: new Uint8Array([]),\n statusCode: new Uint8Array([0x55, 0x15]),\n }),\n ),\n ),\n );\n expect(secondResponse).toEqual(\n Right(\n Just(\n new ApduResponse({\n data: RESPONSE_GET_VERSION.slice(7, 38),\n statusCode: new Uint8Array([0x90, 0x00]),\n }),\n ),\n ),\n );\n });\n\n it(\"should return an error if the frame is without index\", () => {\n //given\n //frame with channelId, headTag, and partial Index only\n const frame = RESPONSE_LIST_APPS[0]!.slice(0, 4);\n\n //when\n const apdu = service.handleFrame(frame);\n\n //then\n expect(apdu).toEqual(\n Left(new ReceiverApduError(\"Unable to parse header from apdu\")),\n );\n });\n\n it(\"should return an error if the frame is without datasize\", () => {\n //given\n //frame with channelId, headTag, and Index and partial dataSize only\n const frame = RESPONSE_LIST_APPS[0]!.slice(0, 6);\n\n //when\n const apdu = service.handleFrame(frame);\n\n //then\n expect(apdu).toEqual(\n Left(new ReceiverApduError(\"Unable to parse header from apdu\")),\n );\n });\n });\n\n describe(\"[BLE] Without padding nor channel\", () => {\n beforeEach(() => {\n service = new DefaultApduReceiverService({}, () => loggerService);\n });\n\n it(\"should return a response directly when a frame is complete\", () => {\n // given\n const frame = RESPONSE_GET_VERSION.slice(2, 40);\n\n // when\n const apdu = service.handleFrame(frame);\n\n // then\n expect(apdu).toEqual(\n Right(\n Just(\n new ApduResponse({\n data: RESPONSE_GET_VERSION.slice(7, 38),\n statusCode: new Uint8Array([0x90, 0x00]),\n }),\n ),\n ),\n );\n });\n\n it(\"should return a response on a third frame when the two first are not complete\", () => {\n //given\n const apdus = [\n RESPONSE_LIST_APPS[0]!.slice(2),\n RESPONSE_LIST_APPS[1]!.slice(2),\n RESPONSE_LIST_APPS[2]!.slice(2, 47),\n ];\n\n //when\n let response: Maybe<ApduResponse> = Nothing;\n const responses: Maybe<ApduResponse>[] = [];\n while (response.isNothing()) {\n const apdu = apdus.shift()!;\n const either = service.handleFrame(apdu);\n\n either.map((value) => {\n response = value;\n responses.push(response);\n });\n }\n\n //then\n expect(responses).toEqual([\n Nothing,\n Nothing,\n Just(\n new ApduResponse({\n data: new Uint8Array([\n ...Array.from(RESPONSE_LIST_APPS[0]!.slice(7)),\n ...Array.from(RESPONSE_LIST_APPS[1]!.slice(5)),\n ...Array.from(RESPONSE_LIST_APPS[2]!).slice(5, 45),\n ]),\n statusCode: new Uint8Array([0x90, 0x00]),\n }),\n ),\n ]);\n });\n\n it(\"should return two response directly when each frame is complete\", () => {\n // given\n const firstFrame = RESPONSE_LOCKED_DEVICE.slice(2, 9);\n const secondFrame = RESPONSE_GET_VERSION.slice(2, 40);\n\n // when\n const firstResponse = service.handleFrame(firstFrame);\n const secondResponse = service.handleFrame(secondFrame);\n\n // then\n expect(firstResponse).toEqual(\n Right(\n Just(\n new ApduResponse({\n data: new Uint8Array([]),\n statusCode: new Uint8Array([0x55, 0x15]),\n }),\n ),\n ),\n );\n expect(secondResponse).toEqual(\n Right(\n Just(\n new ApduResponse({\n data: RESPONSE_GET_VERSION.slice(7, 38),\n statusCode: new Uint8Array([0x90, 0x00]),\n }),\n ),\n ),\n );\n });\n\n it(\"should return an error if the frame is without index\", () => {\n //given\n //frame with channelId, headTag, and partial Index only\n const frame = RESPONSE_LIST_APPS[0]!.slice(2, 4);\n\n //when\n const apdu = service.handleFrame(frame);\n\n //then\n expect(apdu).toEqual(\n Left(new ReceiverApduError(\"Unable to parse header from apdu\")),\n );\n });\n\n it(\"should return an error if the frame is without datasize\", () => {\n //given\n //frame with channelId, headTag, and Index and partial dataSize only\n const frame = RESPONSE_LIST_APPS[0]!.slice(2, 6);\n\n //when\n const apdu = service.handleFrame(frame);\n\n //then\n expect(apdu).toEqual(\n Left(new ReceiverApduError(\"Unable to parse header from apdu\")),\n );\n });\n });\n});\n"],
5
- "mappings": "aAEA,IAAAA,EAAuD,qBAEvDC,EAA6B,4CAE7BC,EAAkC,iDAClCC,EAA8C,4EAE9CC,EAA2C,wCAT3C,KAAK,KAAK,MAAM,EAWhB,MAAMC,EAAgB,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a,CACf,KAAMb,EAAqB,MAAM,EAAG,EAAE,EACtC,WAAY,IAAI,WAAW,CAAC,IAAM,CAAI,CAAC,CACzC,CAAC,CACH,CACF,CACF,CACF,CAAC,EAED,GAAG,uDAAwD,IAAM,CAG/D,MAAMI,EAAQF,EAAmB,CAAC,EAAG,MAAM,EAAG,CAAC,EAGzCG,EAAOF,EAAQ,YAAYC,CAAK,EAGtC,OAAOC,CAAI,EAAE,WACX,QAAK,IAAI,oBAAkB,kCAAkC,CAAC,CAChE,CACF,CAAC,EAED,GAAG,0DAA2D,IAAM,CAGlE,MAAMD,EAAQF,EAAmB,CAAC,EAAG,MAAM,EAAG,CAAC,EAGzCG,EAAOF,EAAQ,YAAYC,CAAK,EAGtC,OAAOC,CAAI,EAAE,WACX,QAAK,IAAI,oBAAkB,kCAAkC,CAAC,CAChE,CACF,CAAC,CACH,CAAC,CACH,CAAC",
4
+ "sourcesContent": ["vi.mock(\"uuid\");\n\nimport { Just, Left, type Maybe, Nothing, Right } from \"purify-ts\";\n\nimport { ApduResponse } from \"@api/device-session/ApduResponse\";\nimport { type ApduReceiverService } from \"@api/device-session/service/ApduReceiverService\";\nimport { ReceiverApduError } from \"@internal/device-session/model/Errors\";\nimport { DefaultLoggerPublisherService } from \"@internal/logger-publisher/service/DefaultLoggerPublisherService\";\n\nimport { DefaultApduReceiverService } from \"./DefaultApduReceiverService\";\n\nconst loggerService = new DefaultLoggerPublisherService([], \"frame\");\n\nconst RESPONSE_GET_VERSION = new Uint8Array([\n 0xaa, 0xaa, 0x05, 0x00, 0x00, 0x00, 0x21, 0x33, 0x00, 0x00, 0x04, 0x05, 0x32,\n 0x2e, 0x32, 0x2e, 0x33, 0x04, 0xe6, 0x00, 0x00, 0x00, 0x04, 0x32, 0x2e, 0x33,\n 0x30, 0x04, 0x31, 0x2e, 0x31, 0x36, 0x01, 0x01, 0x01, 0x00, 0x01, 0x00, 0x90,\n 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,\n 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,\n]);\n\nconst RESPONSE_LOCKED_DEVICE = new Uint8Array([\n 0xaa, 0xaa, 0x05, 0x00, 0x00, 0x00, 0x02, 0x55, 0x15, 0x00, 0x00, 0x00, 0x00,\n 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,\n 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,\n 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,\n 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,\n]);\n\nconst RESPONSE_LIST_APPS = [\n new Uint8Array([\n 0xaa, 0xaa, 0x05, 0x00, 0x00, 0x00, 0x9e, 0x01, 0x4d, 0x00, 0x13, 0xca,\n 0x50, 0xfa, 0xa1, 0x91, 0x40, 0x9a, 0x6b, 0xfa, 0x6c, 0x0f, 0xbb, 0xb2,\n 0xe7, 0xc4, 0xa9, 0xcf, 0xe5, 0x57, 0x41, 0x00, 0x5d, 0xbd, 0x84, 0xab,\n 0x9a, 0xbd, 0x66, 0xc7, 0x6c, 0x90, 0xdd, 0x08, 0x79, 0x0d, 0x08, 0x47,\n 0xb9, 0x3a, 0x8f, 0xa7, 0x6f, 0x60, 0x33, 0xae, 0xd3, 0x25, 0xd7, 0xb1,\n 0xe5, 0x7c, 0xeb, 0xd7,\n ]),\n new Uint8Array([\n 0xaa, 0xaa, 0x05, 0x00, 0x01, 0x4b, 0x2e, 0x2c, 0x9f, 0xb4, 0x46, 0x78,\n 0xde, 0x05, 0x5f, 0x9e, 0x80, 0x0a, 0x07, 0x42, 0x69, 0x74, 0x63, 0x6f,\n 0x69, 0x6e, 0x4e, 0x00, 0x15, 0xca, 0x40, 0x06, 0x03, 0x28, 0xf8, 0x8f,\n 0xc6, 0xd6, 0x42, 0x98, 0xd0, 0x49, 0x00, 0xc7, 0x04, 0x98, 0x19, 0x1b,\n 0x6c, 0xeb, 0xed, 0xd8, 0xcb, 0x84, 0x5d, 0xf5, 0x4b, 0xe3, 0xbd, 0xbb,\n 0x25, 0x7a, 0x3f, 0x6f,\n ]),\n new Uint8Array([\n 0xaa, 0xaa, 0x05, 0x00, 0x02, 0x68, 0x8f, 0x54, 0xef, 0x7f, 0xaa, 0xc4,\n 0x22, 0xaa, 0x54, 0xe7, 0xb8, 0x0a, 0xc8, 0xa3, 0x2f, 0x96, 0xe5, 0x5e,\n 0x43, 0x2d, 0xf3, 0xa3, 0x45, 0x8d, 0x8e, 0xaa, 0xf1, 0x4e, 0xd1, 0x1e,\n 0x08, 0x45, 0x74, 0x68, 0x65, 0x72, 0x65, 0x75, 0x6d, 0x90, 0x00, 0x00,\n 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,\n 0x00, 0x00, 0x00,\n ]),\n];\n\ndescribe(\"DefaultApduReceiverService\", () => {\n let service: ApduReceiverService;\n\n beforeAll(() => {\n vi.mock(\"uuid\", () => ({\n v4: vi.fn().mockReturnValue(\"42\"),\n }));\n });\n\n describe(\"without dataSize\", () => {\n beforeEach(() => {\n service = new DefaultApduReceiverService(\n { channel: Just(new Uint8Array([0xaa, 0xaa])) },\n () => loggerService,\n );\n });\n\n it(\"should return a left error when the first frame has no dataSize\", () => {\n //given\n const frame = RESPONSE_LIST_APPS[1]!;\n\n //when\n const apdu = service.handleFrame(frame);\n\n //then\n expect(apdu).toEqual(Left(new ReceiverApduError()));\n });\n });\n\n describe(\"[USB] With padding and channel\", () => {\n beforeEach(() => {\n service = new DefaultApduReceiverService(\n { channel: Just(new Uint8Array([0xaa, 0xaa])) },\n () => loggerService,\n );\n });\n\n it(\"should return a response directly when a frame is complete\", () => {\n // given\n const frame = RESPONSE_GET_VERSION;\n\n // when\n const apdu = service.handleFrame(frame);\n\n // then\n expect(apdu).toEqual(\n Right(\n Just(\n new ApduResponse({\n data: RESPONSE_GET_VERSION.slice(7, 38),\n statusCode: new Uint8Array([0x90, 0x00]),\n }),\n ),\n ),\n );\n });\n\n it(\"should return a response on a third frame when the two first are not complete\", () => {\n //given\n const apdus = [...RESPONSE_LIST_APPS];\n\n //when\n let response: Maybe<ApduResponse> = Nothing;\n const responses: Maybe<ApduResponse>[] = [];\n while (response.isNothing()) {\n const apdu = apdus.shift()!;\n const either = service.handleFrame(apdu);\n\n either.map((value) => {\n response = value;\n responses.push(response);\n });\n }\n\n //then\n expect(responses).toEqual([\n Nothing,\n Nothing,\n Just(\n new ApduResponse({\n data: new Uint8Array([\n ...Array.from(RESPONSE_LIST_APPS[0]!.slice(7)),\n ...Array.from(RESPONSE_LIST_APPS[1]!.slice(5)),\n ...Array.from(RESPONSE_LIST_APPS[2]!).slice(5, 45),\n ]),\n statusCode: new Uint8Array([0x90, 0x00]),\n }),\n ),\n ]);\n });\n\n it(\"should return two response directly when each frame is complete\", () => {\n // given\n const firstFrame = RESPONSE_LOCKED_DEVICE;\n const secondFrame = RESPONSE_GET_VERSION;\n\n // when\n const firstResponse = service.handleFrame(firstFrame);\n const secondResponse = service.handleFrame(secondFrame);\n\n // then\n expect(firstResponse).toEqual(\n Right(\n Just(\n new ApduResponse({\n data: new Uint8Array([]),\n statusCode: new Uint8Array([0x55, 0x15]),\n }),\n ),\n ),\n );\n expect(secondResponse).toEqual(\n Right(\n Just(\n new ApduResponse({\n data: RESPONSE_GET_VERSION.slice(7, 38),\n statusCode: new Uint8Array([0x90, 0x00]),\n }),\n ),\n ),\n );\n });\n\n it(\"should return an error if the frame is without index\", () => {\n //given\n //frame with channelId, headTag, and partial Index only\n const frame = RESPONSE_LIST_APPS[0]!.slice(0, 4);\n\n //when\n const apdu = service.handleFrame(frame);\n\n //then\n expect(apdu).toEqual(\n Left(new ReceiverApduError(\"Unable to parse header from apdu\")),\n );\n });\n\n it(\"should return an error if the frame is without datasize\", () => {\n //given\n //frame with channelId, headTag, and Index and partial dataSize only\n const frame = RESPONSE_LIST_APPS[0]!.slice(0, 6);\n\n //when\n const apdu = service.handleFrame(frame);\n\n //then\n expect(apdu).toEqual(\n Left(new ReceiverApduError(\"Unable to parse header from apdu\")),\n );\n });\n });\n\n describe(\"[BLE] Without padding nor channel\", () => {\n beforeEach(() => {\n service = new DefaultApduReceiverService({}, () => loggerService);\n });\n\n it(\"should return a response directly when a frame is complete\", () => {\n // given\n const frame = RESPONSE_GET_VERSION.slice(2, 40);\n\n // when\n const apdu = service.handleFrame(frame);\n\n // then\n expect(apdu).toEqual(\n Right(\n Just(\n new ApduResponse({\n data: RESPONSE_GET_VERSION.slice(7, 38),\n statusCode: new Uint8Array([0x90, 0x00]),\n }),\n ),\n ),\n );\n });\n\n it(\"should return a response on a third frame when the two first are not complete\", () => {\n //given\n const apdus = [\n RESPONSE_LIST_APPS[0]!.slice(2),\n RESPONSE_LIST_APPS[1]!.slice(2),\n RESPONSE_LIST_APPS[2]!.slice(2, 47),\n ];\n\n //when\n let response: Maybe<ApduResponse> = Nothing;\n const responses: Maybe<ApduResponse>[] = [];\n while (response.isNothing()) {\n const apdu = apdus.shift()!;\n const either = service.handleFrame(apdu);\n\n either.map((value) => {\n response = value;\n responses.push(response);\n });\n }\n\n //then\n expect(responses).toEqual([\n Nothing,\n Nothing,\n Just(\n new ApduResponse({\n data: new Uint8Array([\n ...Array.from(RESPONSE_LIST_APPS[0]!.slice(7)),\n ...Array.from(RESPONSE_LIST_APPS[1]!.slice(5)),\n ...Array.from(RESPONSE_LIST_APPS[2]!).slice(5, 45),\n ]),\n statusCode: new Uint8Array([0x90, 0x00]),\n }),\n ),\n ]);\n });\n\n it(\"should return two response directly when each frame is complete\", () => {\n // given\n const firstFrame = RESPONSE_LOCKED_DEVICE.slice(2, 9);\n const secondFrame = RESPONSE_GET_VERSION.slice(2, 40);\n\n // when\n const firstResponse = service.handleFrame(firstFrame);\n const secondResponse = service.handleFrame(secondFrame);\n\n // then\n expect(firstResponse).toEqual(\n Right(\n Just(\n new ApduResponse({\n data: new Uint8Array([]),\n statusCode: new Uint8Array([0x55, 0x15]),\n }),\n ),\n ),\n );\n expect(secondResponse).toEqual(\n Right(\n Just(\n new ApduResponse({\n data: RESPONSE_GET_VERSION.slice(7, 38),\n statusCode: new Uint8Array([0x90, 0x00]),\n }),\n ),\n ),\n );\n });\n\n it(\"should return an error if the frame is without index\", () => {\n //given\n //frame with channelId, headTag, and partial Index only\n const frame = RESPONSE_LIST_APPS[0]!.slice(2, 4);\n\n //when\n const apdu = service.handleFrame(frame);\n\n //then\n expect(apdu).toEqual(\n Left(new ReceiverApduError(\"Unable to parse header from apdu\")),\n );\n });\n\n it(\"should return an error if the frame is without datasize\", () => {\n //given\n //frame with channelId, headTag, and Index and partial dataSize only\n const frame = RESPONSE_LIST_APPS[0]!.slice(2, 6);\n\n //when\n const apdu = service.handleFrame(frame);\n\n //then\n expect(apdu).toEqual(\n Left(new ReceiverApduError(\"Unable to parse header from apdu\")),\n );\n });\n });\n});\n"],
5
+ "mappings": "aAEA,IAAAA,EAAuD,qBAEvDC,EAA6B,4CAE7BC,EAAkC,iDAClCC,EAA8C,4EAE9CC,EAA2C,wCAT3C,GAAG,KAAK,MAAM,EAWd,MAAMC,EAAgB,IAAI,gCAA8B,CAAC,EAAG,OAAO,EAE7DC,EAAuB,IAAI,WAAW,CAC1C,IAAM,IAAM,EAAM,EAAM,EAAM,EAAM,GAAM,GAAM,EAAM,EAAM,EAAM,EAAM,GACxE,GAAM,GAAM,GAAM,GAAM,EAAM,IAAM,EAAM,EAAM,EAAM,EAAM,GAAM,GAAM,GACxE,GAAM,EAAM,GAAM,GAAM,GAAM,GAAM,EAAM,EAAM,EAAM,EAAM,EAAM,EAAM,IACxE,EAAM,EAAM,EAAM,EAAM,EAAM,EAAM,EAAM,EAAM,EAAM,EAAM,EAAM,EAAM,EACx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AmB,CAAC,EAAG,MAAM,EAAG,CAAC,EAGzCG,EAAOF,EAAQ,YAAYC,CAAK,EAGtC,OAAOC,CAAI,EAAE,WACX,QAAK,IAAI,oBAAkB,kCAAkC,CAAC,CAChE,CACF,CAAC,CACH,CAAC,CACH,CAAC",
6
6
  "names": ["import_purify_ts", "import_ApduResponse", "import_Errors", "import_DefaultLoggerPublisherService", "import_DefaultApduReceiverService", "loggerService", "RESPONSE_GET_VERSION", "RESPONSE_LOCKED_DEVICE", "RESPONSE_LIST_APPS", "service", "frame", "apdu", "apdus", "response", "responses", "value", "firstFrame", "secondFrame", "firstResponse", "secondResponse"]
7
7
  }
@@ -1,2 +1,2 @@
1
- "use strict";var x=require("purify-ts"),t=require("../../device-session/model/Frame"),i=require("../../device-session/model/FrameHeader"),w=require("../../logger-publisher/service/DefaultLoggerPublisherService"),d=require("./DefaultApduSenderService");jest.mock("uuid",()=>({v4:jest.fn().mockReturnValue("42")}));const o=new w.DefaultLoggerPublisherService([],"frame");describe("DefaultApduSenderService",()=>{describe("[USB] With padding and channel",()=>{it("should return 1 frame",()=>{const n=x.Maybe.of(new Uint8Array([18,52])),a=new d.DefaultApduSenderService({frameSize:64,padding:!0,channel:n},()=>o),e=new Uint8Array([224,1,0,0,0]),r=a.getFrames(e);expect(r).toEqual([new t.Frame({header:new i.FrameHeader({uuid:"42",channel:x.Maybe.of(new Uint8Array([18,52])),headTag:new Uint8Array([5]),dataSize:x.Maybe.of(new Uint8Array([0,5])),index:new Uint8Array([0,0]),length:7}),data:new Uint8Array([224,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0])})]),expect(r.map(c=>c.getRawData())).toEqual([new Uint8Array([18,52,5,0,0,0,5,224,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0])])}),it("should return 2 frames",()=>{const n=x.Maybe.of(new Uint8Array([18,52])),a=new d.DefaultApduSenderService({frameSize:64,padding:!0,channel:n},()=>o),e=new Uint8Array([224,212,0,0,64,84,111,102,117,73,115,78,117,116,114,105,116,105,111,117,115,65,110,100,66,114,105,110,103,115,74,111,121,68,101,108,105,103,104,116,72,101,97,108,116,104,105,110,101,115,115,72,97,114,109,111,110,121,73,110,69,118,101,114,121,66,105,116,101]),r=a.getFrames(e);expect(r).toEqual([new t.Frame({header:new i.FrameHeader({uuid:"42",channel:x.Maybe.of(new Uint8Array([18,52])),headTag:new Uint8Array([5]),dataSize:x.Maybe.of(new Uint8Array([0,69])),index:new Uint8Array([0,0]),length:7}),data:new Uint8Array([224,212,0,0,64,84,111,102,117,73,115,78,117,116,114,105,116,105,111,117,115,65,110,100,66,114,105,110,103,115,74,111,121,68,101,108,105,103,104,116,72,101,97,108,116,104,105,110,101,115,115,72,97,114,109,111,110])}),new t.Frame({header:new i.FrameHeader({uuid:"42",channel:x.Maybe.of(new Uint8Array([18,52])),headTag:new Uint8Array([5]),index:new Uint8Array([0,1]),length:5,dataSize:x.Maybe.zero()}),data:new Uint8Array([121,73,110,69,118,101,114,121,66,105,116,101,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0])})]),expect(r.map(c=>c.getRawData())).toEqual([new Uint8Array([18,52,5,0,0,0,69,224,212,0,0,64,84,111,102,117,73,115,78,117,116,114,105,116,105,111,117,115,65,110,100,66,114,105,110,103,115,74,111,121,68,101,108,105,103,104,116,72,101,97,108,116,104,105,110,101,115,115,72,97,114,109,111,110]),new Uint8Array([18,52,5,0,1,121,73,110,69,118,101,114,121,66,105,116,101,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0])])})}),describe("[BLE] Without padding nor channel",()=>{it("should return 1 frame",()=>{const n=new d.DefaultApduSenderService({frameSize:123},()=>o),a=new Uint8Array([224,1,0,0,0]),e=n.getFrames(a);expect(e).toEqual([new t.Frame({header:new i.FrameHeader({uuid:"42",channel:x.Maybe.zero(),headTag:new Uint8Array([5]),dataSize:x.Maybe.of(new Uint8Array([0,5])),index:new Uint8Array([0,0]),length:5}),data:new Uint8Array([224,1,0,0,0])})]),expect(e.map(r=>r.getRawData())).toEqual([new Uint8Array([5,0,0,0,5,224,1,0,0,0])])}),it("should return 3 frames",()=>{const n=new d.DefaultApduSenderService({frameSize:10},()=>o),a=new Uint8Array([1,5,79,76,79,83,0,7,46,50,46,52,45,50,0,144,0]),e=n.getFrames(a);expect(e).toEqual([new t.Frame({header:new i.FrameHeader({uuid:"42",channel:x.Maybe.zero(),headTag:new Uint8Array([5]),index:new Uint8Array([0,0]),dataSize:x.Maybe.of(new Uint8Array([0,17])),length:5}),data:new Uint8Array([1,5,79,76,79])}),new t.Frame({header:new i.FrameHeader({uuid:"42",channel:x.Maybe.zero(),headTag:new Uint8Array([5]),dataSize:x.Maybe.zero(),index:new Uint8Array([0,1]),length:3}),data:new Uint8Array([83,0,7,46,50,46,52])}),new t.Frame({header:new i.FrameHeader({uuid:"42",channel:x.Maybe.zero(),headTag:new Uint8Array([5]),dataSize:x.Maybe.zero(),index:new Uint8Array([0,2]),length:3}),data:new Uint8Array([45,50,0,144,0])})]),expect(e.map(r=>r.getRawData())).toEqual([new Uint8Array([5,0,0,0,17,1,5,79,76,79]),new Uint8Array([5,0,1,83,0,7,46,50,46,52]),new Uint8Array([5,0,2,45,50,0,144,0])])})}),describe("Errors",()=>{it("should return a well formatted header with very big channel",()=>{const n=new d.DefaultApduSenderService({frameSize:64,channel:x.Maybe.of(new Uint8Array([1193012,214084,353364,30788,590916]))},()=>o),a=new Uint8Array([224,1,0,0,0]),e=n.getFrames(a);expect(e).toEqual([new t.Frame({header:new i.FrameHeader({uuid:"42",channel:x.Maybe.of(new Uint8Array([68,68])),headTag:new Uint8Array([5]),dataSize:x.Maybe.of(new Uint8Array([0,5])),index:new Uint8Array([0,0]),length:7}),data:new Uint8Array([224,1,0,0,0])})]),expect(e.map(r=>r.getRawData())).toEqual([new Uint8Array([68,68,5,0,0,0,5,224,1,0,0,0])])}),it("should return empty if packet size smaller than header size",()=>{const n=new d.DefaultApduSenderService({frameSize:Math.random()&4,channel:x.Maybe.of(new Uint8Array([18,52]))},()=>o),a=new Uint8Array([224,1,0,0,0]),e=n.getFrames(a);expect(e.length).toEqual(0)}),it("should return empty if no apdu length",()=>{const n=new d.DefaultApduSenderService({frameSize:Math.random()&255,padding:Math.random()>.5,channel:x.Maybe.of(new Uint8Array([18,52]))},()=>o),a=new Uint8Array([]),e=n.getFrames(a);expect(e.length).toEqual(0)})})});
1
+ "use strict";var x=require("purify-ts"),t=require("../../device-session/model/Frame"),i=require("../../device-session/model/FrameHeader"),w=require("../../logger-publisher/service/DefaultLoggerPublisherService"),d=require("./DefaultApduSenderService");vi.mock("uuid",()=>({v4:vi.fn().mockReturnValue("42")}));const o=new w.DefaultLoggerPublisherService([],"frame");describe("DefaultApduSenderService",()=>{describe("[USB] With padding and channel",()=>{it("should return 1 frame",()=>{const n=x.Maybe.of(new Uint8Array([18,52])),a=new d.DefaultApduSenderService({frameSize:64,padding:!0,channel:n},()=>o),e=new Uint8Array([224,1,0,0,0]),r=a.getFrames(e);expect(r).toEqual([new t.Frame({header:new i.FrameHeader({uuid:"42",channel:x.Maybe.of(new Uint8Array([18,52])),headTag:new Uint8Array([5]),dataSize:x.Maybe.of(new Uint8Array([0,5])),index:new Uint8Array([0,0]),length:7}),data:new Uint8Array([224,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0])})]),expect(r.map(c=>c.getRawData())).toEqual([new Uint8Array([18,52,5,0,0,0,5,224,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0])])}),it("should return 2 frames",()=>{const n=x.Maybe.of(new Uint8Array([18,52])),a=new d.DefaultApduSenderService({frameSize:64,padding:!0,channel:n},()=>o),e=new Uint8Array([224,212,0,0,64,84,111,102,117,73,115,78,117,116,114,105,116,105,111,117,115,65,110,100,66,114,105,110,103,115,74,111,121,68,101,108,105,103,104,116,72,101,97,108,116,104,105,110,101,115,115,72,97,114,109,111,110,121,73,110,69,118,101,114,121,66,105,116,101]),r=a.getFrames(e);expect(r).toEqual([new t.Frame({header:new i.FrameHeader({uuid:"42",channel:x.Maybe.of(new Uint8Array([18,52])),headTag:new Uint8Array([5]),dataSize:x.Maybe.of(new Uint8Array([0,69])),index:new Uint8Array([0,0]),length:7}),data:new Uint8Array([224,212,0,0,64,84,111,102,117,73,115,78,117,116,114,105,116,105,111,117,115,65,110,100,66,114,105,110,103,115,74,111,121,68,101,108,105,103,104,116,72,101,97,108,116,104,105,110,101,115,115,72,97,114,109,111,110])}),new t.Frame({header:new i.FrameHeader({uuid:"42",channel:x.Maybe.of(new Uint8Array([18,52])),headTag:new Uint8Array([5]),index:new Uint8Array([0,1]),length:5,dataSize:x.Maybe.zero()}),data:new Uint8Array([121,73,110,69,118,101,114,121,66,105,116,101,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0])})]),expect(r.map(c=>c.getRawData())).toEqual([new Uint8Array([18,52,5,0,0,0,69,224,212,0,0,64,84,111,102,117,73,115,78,117,116,114,105,116,105,111,117,115,65,110,100,66,114,105,110,103,115,74,111,121,68,101,108,105,103,104,116,72,101,97,108,116,104,105,110,101,115,115,72,97,114,109,111,110]),new Uint8Array([18,52,5,0,1,121,73,110,69,118,101,114,121,66,105,116,101,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0])])})}),describe("[BLE] Without padding nor channel",()=>{it("should return 1 frame",()=>{const n=new d.DefaultApduSenderService({frameSize:123},()=>o),a=new Uint8Array([224,1,0,0,0]),e=n.getFrames(a);expect(e).toEqual([new t.Frame({header:new i.FrameHeader({uuid:"42",channel:x.Maybe.zero(),headTag:new Uint8Array([5]),dataSize:x.Maybe.of(new Uint8Array([0,5])),index:new Uint8Array([0,0]),length:5}),data:new Uint8Array([224,1,0,0,0])})]),expect(e.map(r=>r.getRawData())).toEqual([new Uint8Array([5,0,0,0,5,224,1,0,0,0])])}),it("should return 3 frames",()=>{const n=new d.DefaultApduSenderService({frameSize:10},()=>o),a=new Uint8Array([1,5,79,76,79,83,0,7,46,50,46,52,45,50,0,144,0]),e=n.getFrames(a);expect(e).toEqual([new t.Frame({header:new i.FrameHeader({uuid:"42",channel:x.Maybe.zero(),headTag:new Uint8Array([5]),index:new Uint8Array([0,0]),dataSize:x.Maybe.of(new Uint8Array([0,17])),length:5}),data:new Uint8Array([1,5,79,76,79])}),new t.Frame({header:new i.FrameHeader({uuid:"42",channel:x.Maybe.zero(),headTag:new Uint8Array([5]),dataSize:x.Maybe.zero(),index:new Uint8Array([0,1]),length:3}),data:new Uint8Array([83,0,7,46,50,46,52])}),new t.Frame({header:new i.FrameHeader({uuid:"42",channel:x.Maybe.zero(),headTag:new Uint8Array([5]),dataSize:x.Maybe.zero(),index:new Uint8Array([0,2]),length:3}),data:new Uint8Array([45,50,0,144,0])})]),expect(e.map(r=>r.getRawData())).toEqual([new Uint8Array([5,0,0,0,17,1,5,79,76,79]),new Uint8Array([5,0,1,83,0,7,46,50,46,52]),new Uint8Array([5,0,2,45,50,0,144,0])])})}),describe("Errors",()=>{it("should return a well formatted header with very big channel",()=>{const n=new d.DefaultApduSenderService({frameSize:64,channel:x.Maybe.of(new Uint8Array([1193012,214084,353364,30788,590916]))},()=>o),a=new Uint8Array([224,1,0,0,0]),e=n.getFrames(a);expect(e).toEqual([new t.Frame({header:new i.FrameHeader({uuid:"42",channel:x.Maybe.of(new Uint8Array([68,68])),headTag:new Uint8Array([5]),dataSize:x.Maybe.of(new Uint8Array([0,5])),index:new Uint8Array([0,0]),length:7}),data:new Uint8Array([224,1,0,0,0])})]),expect(e.map(r=>r.getRawData())).toEqual([new Uint8Array([68,68,5,0,0,0,5,224,1,0,0,0])])}),it("should return empty if packet size smaller than header size",()=>{const n=new d.DefaultApduSenderService({frameSize:Math.random()&4,channel:x.Maybe.of(new Uint8Array([18,52]))},()=>o),a=new Uint8Array([224,1,0,0,0]),e=n.getFrames(a);expect(e.length).toEqual(0)}),it("should return empty if no apdu length",()=>{const n=new d.DefaultApduSenderService({frameSize:Math.random()&255,padding:Math.random()>.5,channel:x.Maybe.of(new Uint8Array([18,52]))},()=>o),a=new Uint8Array([]),e=n.getFrames(a);expect(e.length).toEqual(0)})})});
2
2
  //# sourceMappingURL=DefaultApduSenderService.test.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../../../src/internal/device-session/service/DefaultApduSenderService.test.ts"],
4
- "sourcesContent": ["jest.mock(\"uuid\", () => ({\n v4: jest.fn().mockReturnValue(\"42\"),\n}));\n\nimport { Maybe } from \"purify-ts\";\n\nimport { Frame } from \"@internal/device-session/model/Frame\";\nimport { FrameHeader } from \"@internal/device-session/model/FrameHeader\";\nimport { DefaultLoggerPublisherService } from \"@internal/logger-publisher/service/DefaultLoggerPublisherService\";\n\nimport { DefaultApduSenderService } from \"./DefaultApduSenderService\";\n\nconst loggerService = new DefaultLoggerPublisherService([], \"frame\");\n\ndescribe(\"DefaultApduSenderService\", () => {\n describe(\"[USB] With padding and channel\", () => {\n it(\"should return 1 frame\", () => {\n // given\n const channel = Maybe.of(new Uint8Array([0x12, 0x34]));\n const apduSenderService = new DefaultApduSenderService(\n {\n frameSize: 64,\n padding: true,\n channel,\n },\n () => loggerService,\n );\n // getVersion APDU\n const apdu = new Uint8Array([0xe0, 0x01, 0x00, 0x00, 0x00]);\n\n // when\n const frames = apduSenderService.getFrames(apdu);\n\n // then\n expect(frames).toEqual([\n new Frame({\n header: new FrameHeader({\n uuid: \"42\",\n channel: Maybe.of(new Uint8Array([0x12, 0x34])),\n headTag: new Uint8Array([0x05]),\n dataSize: Maybe.of(new Uint8Array([0, 0x05])),\n index: new Uint8Array([0, 0]),\n length: 7,\n }),\n data: new Uint8Array([\n 0xe0, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,\n 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,\n 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,\n 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,\n 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,\n 0x00, 0x00,\n ]),\n }),\n ]);\n expect(frames.map((fr) => fr.getRawData())).toEqual([\n new Uint8Array([\n 0x12, 0x34, 0x05, 0x00, 0x00, 0x00, 0x05, 0xe0, 0x01, 0x00, 0x00,\n 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,\n 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,\n 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,\n 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,\n 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,\n ]),\n ]);\n });\n\n it(\"should return 2 frames\", () => {\n // given\n const channel = Maybe.of(new Uint8Array([0x12, 0x34]));\n const apduSenderService = new DefaultApduSenderService(\n {\n frameSize: 64,\n padding: true,\n channel,\n },\n () => loggerService,\n );\n const apdu = new Uint8Array([\n // editDeviceName APDU\n 0xe0, 0xd4, 0x00, 0x00, 0x40,\n // editDeviceNameData\n 0x54, 0x6f, 0x66, 0x75, 0x49, 0x73, 0x4e, 0x75, 0x74, 0x72, 0x69, 0x74,\n 0x69, 0x6f, 0x75, 0x73, 0x41, 0x6e, 0x64, 0x42, 0x72, 0x69, 0x6e, 0x67,\n 0x73, 0x4a, 0x6f, 0x79, 0x44, 0x65, 0x6c, 0x69, 0x67, 0x68, 0x74, 0x48,\n 0x65, 0x61, 0x6c, 0x74, 0x68, 0x69, 0x6e, 0x65, 0x73, 0x73, 0x48, 0x61,\n 0x72, 0x6d, 0x6f, 0x6e, 0x79, 0x49, 0x6e, 0x45, 0x76, 0x65, 0x72, 0x79,\n 0x42, 0x69, 0x74, 0x65,\n ]);\n\n // when\n const frames = apduSenderService.getFrames(apdu);\n\n // then\n expect(frames).toEqual([\n new Frame({\n header: new FrameHeader({\n uuid: \"42\",\n channel: Maybe.of(new Uint8Array([0x12, 0x34])),\n headTag: new Uint8Array([0x05]),\n dataSize: Maybe.of(new Uint8Array([0x00, 0x45])),\n index: new Uint8Array([0x00, 0x00]),\n length: 7,\n }),\n data: new Uint8Array([\n 0xe0, 0xd4, 0x00, 0x00, 0x40, 0x54, 0x6f, 0x66, 0x75, 0x49, 0x73,\n 0x4e, 0x75, 0x74, 0x72, 0x69, 0x74, 0x69, 0x6f, 0x75, 0x73, 0x41,\n 0x6e, 0x64, 0x42, 0x72, 0x69, 0x6e, 0x67, 0x73, 0x4a, 0x6f, 0x79,\n 0x44, 0x65, 0x6c, 0x69, 0x67, 0x68, 0x74, 0x48, 0x65, 0x61, 0x6c,\n 0x74, 0x68, 0x69, 0x6e, 0x65, 0x73, 0x73, 0x48, 0x61, 0x72, 0x6d,\n 0x6f, 0x6e,\n ]),\n }),\n new Frame({\n header: new FrameHeader({\n uuid: \"42\",\n channel: Maybe.of(new Uint8Array([0x12, 0x34])),\n headTag: new Uint8Array([0x05]),\n index: new Uint8Array([0x00, 0x01]),\n length: 5,\n dataSize: Maybe.zero(),\n }),\n data: new Uint8Array([\n 0x79, 0x49, 0x6e, 0x45, 0x76, 0x65, 0x72, 0x79, 0x42, 0x69, 0x74,\n 0x65, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,\n 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,\n 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,\n 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,\n 0x00, 0x00, 0x00, 0x00,\n ]),\n }),\n ]);\n expect(frames.map((fr) => fr.getRawData())).toEqual([\n new Uint8Array([\n 0x12, 0x34, 0x05, 0x00, 0x00, 0x00, 0x45, 0xe0, 0xd4, 0x00, 0x00,\n 0x40, 0x54, 0x6f, 0x66, 0x75, 0x49, 0x73, 0x4e, 0x75, 0x74, 0x72,\n 0x69, 0x74, 0x69, 0x6f, 0x75, 0x73, 0x41, 0x6e, 0x64, 0x42, 0x72,\n 0x69, 0x6e, 0x67, 0x73, 0x4a, 0x6f, 0x79, 0x44, 0x65, 0x6c, 0x69,\n 0x67, 0x68, 0x74, 0x48, 0x65, 0x61, 0x6c, 0x74, 0x68, 0x69, 0x6e,\n 0x65, 0x73, 0x73, 0x48, 0x61, 0x72, 0x6d, 0x6f, 0x6e,\n ]),\n new Uint8Array([\n 0x12, 0x34, 0x05, 0x00, 0x01, 0x79, 0x49, 0x6e, 0x45, 0x76, 0x65,\n 0x72, 0x79, 0x42, 0x69, 0x74, 0x65, 0x00, 0x00, 0x00, 0x00, 0x00,\n 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,\n 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,\n 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,\n 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,\n ]),\n ]);\n });\n });\n\n describe(\"[BLE] Without padding nor channel\", () => {\n it(\"should return 1 frame\", () => {\n // given\n const apduSenderService = new DefaultApduSenderService(\n {\n frameSize: 123,\n },\n () => loggerService,\n );\n const command = new Uint8Array([0xe0, 0x01, 0x00, 0x00, 0x00]);\n\n // when\n const frames = apduSenderService.getFrames(command);\n\n // then\n expect(frames).toEqual([\n new Frame({\n header: new FrameHeader({\n uuid: \"42\",\n channel: Maybe.zero(),\n headTag: new Uint8Array([0x05]),\n dataSize: Maybe.of(new Uint8Array([0, 5])),\n index: new Uint8Array([0, 0]),\n length: 5,\n }),\n data: new Uint8Array([0xe0, 0x01, 0x00, 0x00, 0x00]),\n }),\n ]);\n expect(frames.map((fr) => fr.getRawData())).toEqual([\n new Uint8Array([\n 0x05, 0x00, 0x00, 0x00, 0x05, 0xe0, 0x01, 0x00, 0x00, 0x00,\n ]),\n ]);\n });\n\n it(\"should return 3 frames\", () => {\n // given\n const apduSenderService = new DefaultApduSenderService(\n {\n frameSize: 10,\n },\n () => loggerService,\n );\n const command = new Uint8Array([\n 0x01, 0x05, 0x4f, 0x4c, 0x4f, 0x53, 0x00, 0x07, 0x2e, 0x32, 0x2e, 0x34,\n 0x2d, 0x32, 0x00, 0x90, 0x00,\n ]);\n\n // when\n const frames = apduSenderService.getFrames(command);\n\n // then\n expect(frames).toEqual([\n new Frame({\n header: new FrameHeader({\n uuid: \"42\",\n channel: Maybe.zero(),\n headTag: new Uint8Array([0x05]),\n index: new Uint8Array([0, 0]),\n dataSize: Maybe.of(new Uint8Array([0, 0x11])),\n length: 5,\n }),\n data: new Uint8Array([0x01, 0x05, 0x4f, 0x4c, 0x4f]),\n }),\n new Frame({\n header: new FrameHeader({\n uuid: \"42\",\n channel: Maybe.zero(),\n headTag: new Uint8Array([0x05]),\n dataSize: Maybe.zero(),\n index: new Uint8Array([0, 0x01]),\n length: 3,\n }),\n data: new Uint8Array([0x53, 0x00, 0x07, 0x2e, 0x32, 0x2e, 0x34]),\n }),\n new Frame({\n header: new FrameHeader({\n uuid: \"42\",\n channel: Maybe.zero(),\n headTag: new Uint8Array([0x05]),\n dataSize: Maybe.zero(),\n index: new Uint8Array([0, 0x02]),\n length: 3,\n }),\n data: new Uint8Array([0x2d, 0x32, 0x00, 0x90, 0x00]),\n }),\n ]);\n expect(frames.map((fr) => fr.getRawData())).toEqual([\n new Uint8Array([\n 0x05, 0x00, 0x00, 0x00, 0x11, 0x01, 0x05, 0x4f, 0x4c, 0x4f,\n ]),\n new Uint8Array([\n 0x05, 0x00, 0x01, 0x53, 0x00, 0x07, 0x2e, 0x32, 0x2e, 0x34,\n ]),\n new Uint8Array([0x05, 0x00, 0x02, 0x2d, 0x32, 0x00, 0x90, 0x00]),\n ]);\n });\n });\n\n describe(\"Errors\", () => {\n it(\"should return a well formatted header with very big channel\", () => {\n // given\n const apduSenderService = new DefaultApduSenderService(\n {\n frameSize: 64,\n channel: Maybe.of(\n new Uint8Array([0x123434, 0x34444, 0x56454, 0x7844, 0x90444]),\n ),\n },\n () => loggerService,\n );\n const command = new Uint8Array([0xe0, 0x01, 0x00, 0x00, 0x00]);\n\n // when\n const frames = apduSenderService.getFrames(command);\n\n // then\n expect(frames).toEqual([\n new Frame({\n header: new FrameHeader({\n uuid: \"42\",\n channel: Maybe.of(new Uint8Array([0x44, 0x44])),\n headTag: new Uint8Array([0x05]),\n dataSize: Maybe.of(new Uint8Array([0, 0x05])),\n index: new Uint8Array([0, 0]),\n length: 7,\n }),\n data: new Uint8Array([0xe0, 0x01, 0x00, 0x00, 0x00]),\n }),\n ]);\n expect(frames.map((fr) => fr.getRawData())).toEqual([\n new Uint8Array([\n 0x44, 0x44, 0x05, 0x00, 0x00, 0x00, 0x05, 0xe0, 0x01, 0x00, 0x00,\n 0x00,\n ]),\n ]);\n });\n it(\"should return empty if packet size smaller than header size\", () => {\n // given\n const apduSenderService = new DefaultApduSenderService(\n {\n frameSize: Math.random() & 4,\n channel: Maybe.of(new Uint8Array([0x12, 0x34])),\n },\n () => loggerService,\n );\n const command = new Uint8Array([0xe0, 0x01, 0x00, 0x00, 0x00]);\n\n // when\n const frames = apduSenderService.getFrames(command);\n\n // then\n expect(frames.length).toEqual(0);\n });\n\n it(\"should return empty if no apdu length\", () => {\n // given\n const apduSenderService = new DefaultApduSenderService(\n {\n // random frameSize < 0xff\n frameSize: Math.random() & 0xff,\n // random padding boolean\n padding: Math.random() > 0.5,\n channel: Maybe.of(new Uint8Array([0x12, 0x34])),\n },\n () => loggerService,\n );\n const command = new Uint8Array([]);\n\n // when\n const frames = apduSenderService.getFrames(command);\n\n // then\n expect(frames.length).toEqual(0);\n });\n });\n});\n"],
5
- "mappings": "aAIA,IAAAA,EAAsB,qBAEtBC,EAAsB,gDACtBC,EAA4B,sDAC5BC,EAA8C,4EAE9CC,EAAyC,sCAVzC,KAAK,KAAK,OAAQ,KAAO,CACvB,GAAI,KAAK,GAAG,EAAE,gBAAgB,IAAI,CACpC,EAAE,EAUF,MAAMC,EAAgB,IAAI,gCAA8B,CAAC,EAAG,OAAO,EAEnE,SAAS,2BAA4B,IAAM,CACzC,SAAS,iCAAkC,IAAM,CAC/C,GAAG,wBAAyB,IAAM,CAEhC,MAAMC,EAAU,QAAM,GAAG,IAAI,WAAW,CAAC,GAAM,EAAI,CAAC,CAAC,EAC/CC,EAAoB,IAAI,2BAC5B,CACE,UAAW,GACX,QAAS,GACT,QAAAD,CACF,EACA,IAAMD,CACR,EAEMG,EAAO,IAAI,WAAW,CAAC,IAAM,EAAM,EAAM,EAAM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M,EAAM,EAAM,CAAI,CAAC,CACrD,CAAC,CACH,CAAC,EACD,OAAOA,EAAO,IAAKC,GAAOA,EAAG,WAAW,CAAC,CAAC,EAAE,QAAQ,CAClD,IAAI,WAAW,CACb,GAAM,GAAM,EAAM,EAAM,EAAM,EAAM,EAAM,IAAM,EAAM,EAAM,EAC5D,CACF,CAAC,CACH,CAAC,CACH,CAAC,EACD,GAAG,8DAA+D,IAAM,CAEtE,MAAMH,EAAoB,IAAI,2BAC5B,CACE,UAAW,KAAK,OAAO,EAAI,EAC3B,QAAS,QAAM,GAAG,IAAI,WAAW,CAAC,GAAM,EAAI,CAAC,CAAC,CAChD,EACA,IAAMF,CACR,EACMM,EAAU,IAAI,WAAW,CAAC,IAAM,EAAM,EAAM,EAAM,CAAI,CAAC,EAGvDF,EAASF,EAAkB,UAAUI,CAAO,EAGlD,OAAOF,EAAO,MAAM,EAAE,QAAQ,CAAC,CACjC,CAAC,EAED,GAAG,wCAAyC,IAAM,CAEhD,MAAMF,EAAoB,IAAI,2BAC5B,CAEE,UAAW,KAAK,OAAO,EAAI,IAE3B,QAAS,KAAK,OAAO,EAAI,GACzB,QAAS,QAAM,GAAG,IAAI,WAAW,CAAC,GAAM,EAAI,CAAC,CAAC,CAChD,EACA,IAAMF,CACR,EACMM,EAAU,IAAI,WAAW,CAAC,CAAC,EAG3BF,EAASF,EAAkB,UAAUI,CAAO,EAGlD,OAAOF,EAAO,MAAM,EAAE,QAAQ,CAAC,CACjC,CAAC,CACH,CAAC,CACH,CAAC",
4
+ "sourcesContent": ["import { Maybe } from \"purify-ts\";\n\nimport { Frame } from \"@internal/device-session/model/Frame\";\nimport { FrameHeader } from \"@internal/device-session/model/FrameHeader\";\nimport { DefaultLoggerPublisherService } from \"@internal/logger-publisher/service/DefaultLoggerPublisherService\";\n\nimport { DefaultApduSenderService } from \"./DefaultApduSenderService\";\n\nvi.mock(\"uuid\", () => ({\n v4: vi.fn().mockReturnValue(\"42\"),\n}));\n\nconst loggerService = new DefaultLoggerPublisherService([], \"frame\");\n\ndescribe(\"DefaultApduSenderService\", () => {\n describe(\"[USB] With padding and channel\", () => {\n it(\"should return 1 frame\", () => {\n // given\n const channel = Maybe.of(new Uint8Array([0x12, 0x34]));\n const apduSenderService = new DefaultApduSenderService(\n {\n frameSize: 64,\n padding: true,\n channel,\n },\n () => loggerService,\n );\n // getVersion APDU\n const apdu = new Uint8Array([0xe0, 0x01, 0x00, 0x00, 0x00]);\n\n // when\n const frames = apduSenderService.getFrames(apdu);\n\n // then\n expect(frames).toEqual([\n new Frame({\n header: new FrameHeader({\n uuid: \"42\",\n channel: Maybe.of(new Uint8Array([0x12, 0x34])),\n headTag: new Uint8Array([0x05]),\n dataSize: Maybe.of(new Uint8Array([0, 0x05])),\n index: new Uint8Array([0, 0]),\n length: 7,\n }),\n data: new Uint8Array([\n 0xe0, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,\n 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,\n 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,\n 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,\n 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,\n 0x00, 0x00,\n ]),\n }),\n ]);\n expect(frames.map((fr) => fr.getRawData())).toEqual([\n new Uint8Array([\n 0x12, 0x34, 0x05, 0x00, 0x00, 0x00, 0x05, 0xe0, 0x01, 0x00, 0x00,\n 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,\n 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,\n 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,\n 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,\n 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,\n ]),\n ]);\n });\n\n it(\"should return 2 frames\", () => {\n // given\n const channel = Maybe.of(new Uint8Array([0x12, 0x34]));\n const apduSenderService = new DefaultApduSenderService(\n {\n frameSize: 64,\n padding: true,\n channel,\n },\n () => loggerService,\n );\n const apdu = new Uint8Array([\n // editDeviceName APDU\n 0xe0, 0xd4, 0x00, 0x00, 0x40,\n // editDeviceNameData\n 0x54, 0x6f, 0x66, 0x75, 0x49, 0x73, 0x4e, 0x75, 0x74, 0x72, 0x69, 0x74,\n 0x69, 0x6f, 0x75, 0x73, 0x41, 0x6e, 0x64, 0x42, 0x72, 0x69, 0x6e, 0x67,\n 0x73, 0x4a, 0x6f, 0x79, 0x44, 0x65, 0x6c, 0x69, 0x67, 0x68, 0x74, 0x48,\n 0x65, 0x61, 0x6c, 0x74, 0x68, 0x69, 0x6e, 0x65, 0x73, 0x73, 0x48, 0x61,\n 0x72, 0x6d, 0x6f, 0x6e, 0x79, 0x49, 0x6e, 0x45, 0x76, 0x65, 0x72, 0x79,\n 0x42, 0x69, 0x74, 0x65,\n ]);\n\n // when\n const frames = apduSenderService.getFrames(apdu);\n\n // then\n expect(frames).toEqual([\n new Frame({\n header: new FrameHeader({\n uuid: \"42\",\n channel: Maybe.of(new Uint8Array([0x12, 0x34])),\n headTag: new Uint8Array([0x05]),\n dataSize: Maybe.of(new Uint8Array([0x00, 0x45])),\n index: new Uint8Array([0x00, 0x00]),\n length: 7,\n }),\n data: new Uint8Array([\n 0xe0, 0xd4, 0x00, 0x00, 0x40, 0x54, 0x6f, 0x66, 0x75, 0x49, 0x73,\n 0x4e, 0x75, 0x74, 0x72, 0x69, 0x74, 0x69, 0x6f, 0x75, 0x73, 0x41,\n 0x6e, 0x64, 0x42, 0x72, 0x69, 0x6e, 0x67, 0x73, 0x4a, 0x6f, 0x79,\n 0x44, 0x65, 0x6c, 0x69, 0x67, 0x68, 0x74, 0x48, 0x65, 0x61, 0x6c,\n 0x74, 0x68, 0x69, 0x6e, 0x65, 0x73, 0x73, 0x48, 0x61, 0x72, 0x6d,\n 0x6f, 0x6e,\n ]),\n }),\n new Frame({\n header: new FrameHeader({\n uuid: \"42\",\n channel: Maybe.of(new Uint8Array([0x12, 0x34])),\n headTag: new Uint8Array([0x05]),\n index: new Uint8Array([0x00, 0x01]),\n length: 5,\n dataSize: Maybe.zero(),\n }),\n data: new Uint8Array([\n 0x79, 0x49, 0x6e, 0x45, 0x76, 0x65, 0x72, 0x79, 0x42, 0x69, 0x74,\n 0x65, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,\n 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,\n 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,\n 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,\n 0x00, 0x00, 0x00, 0x00,\n ]),\n }),\n ]);\n expect(frames.map((fr) => fr.getRawData())).toEqual([\n new Uint8Array([\n 0x12, 0x34, 0x05, 0x00, 0x00, 0x00, 0x45, 0xe0, 0xd4, 0x00, 0x00,\n 0x40, 0x54, 0x6f, 0x66, 0x75, 0x49, 0x73, 0x4e, 0x75, 0x74, 0x72,\n 0x69, 0x74, 0x69, 0x6f, 0x75, 0x73, 0x41, 0x6e, 0x64, 0x42, 0x72,\n 0x69, 0x6e, 0x67, 0x73, 0x4a, 0x6f, 0x79, 0x44, 0x65, 0x6c, 0x69,\n 0x67, 0x68, 0x74, 0x48, 0x65, 0x61, 0x6c, 0x74, 0x68, 0x69, 0x6e,\n 0x65, 0x73, 0x73, 0x48, 0x61, 0x72, 0x6d, 0x6f, 0x6e,\n ]),\n new Uint8Array([\n 0x12, 0x34, 0x05, 0x00, 0x01, 0x79, 0x49, 0x6e, 0x45, 0x76, 0x65,\n 0x72, 0x79, 0x42, 0x69, 0x74, 0x65, 0x00, 0x00, 0x00, 0x00, 0x00,\n 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,\n 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,\n 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,\n 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,\n ]),\n ]);\n });\n });\n\n describe(\"[BLE] Without padding nor channel\", () => {\n it(\"should return 1 frame\", () => {\n // given\n const apduSenderService = new DefaultApduSenderService(\n {\n frameSize: 123,\n },\n () => loggerService,\n );\n const command = new Uint8Array([0xe0, 0x01, 0x00, 0x00, 0x00]);\n\n // when\n const frames = apduSenderService.getFrames(command);\n\n // then\n expect(frames).toEqual([\n new Frame({\n header: new FrameHeader({\n uuid: \"42\",\n channel: Maybe.zero(),\n headTag: new Uint8Array([0x05]),\n dataSize: Maybe.of(new Uint8Array([0, 5])),\n index: new Uint8Array([0, 0]),\n length: 5,\n }),\n data: new Uint8Array([0xe0, 0x01, 0x00, 0x00, 0x00]),\n }),\n ]);\n expect(frames.map((fr) => fr.getRawData())).toEqual([\n new Uint8Array([\n 0x05, 0x00, 0x00, 0x00, 0x05, 0xe0, 0x01, 0x00, 0x00, 0x00,\n ]),\n ]);\n });\n\n it(\"should return 3 frames\", () => {\n // given\n const apduSenderService = new DefaultApduSenderService(\n {\n frameSize: 10,\n },\n () => loggerService,\n );\n const command = new Uint8Array([\n 0x01, 0x05, 0x4f, 0x4c, 0x4f, 0x53, 0x00, 0x07, 0x2e, 0x32, 0x2e, 0x34,\n 0x2d, 0x32, 0x00, 0x90, 0x00,\n ]);\n\n // when\n const frames = apduSenderService.getFrames(command);\n\n // then\n expect(frames).toEqual([\n new Frame({\n header: new FrameHeader({\n uuid: \"42\",\n channel: Maybe.zero(),\n headTag: new Uint8Array([0x05]),\n index: new Uint8Array([0, 0]),\n dataSize: Maybe.of(new Uint8Array([0, 0x11])),\n length: 5,\n }),\n data: new Uint8Array([0x01, 0x05, 0x4f, 0x4c, 0x4f]),\n }),\n new Frame({\n header: new FrameHeader({\n uuid: \"42\",\n channel: Maybe.zero(),\n headTag: new Uint8Array([0x05]),\n dataSize: Maybe.zero(),\n index: new Uint8Array([0, 0x01]),\n length: 3,\n }),\n data: new Uint8Array([0x53, 0x00, 0x07, 0x2e, 0x32, 0x2e, 0x34]),\n }),\n new Frame({\n header: new FrameHeader({\n uuid: \"42\",\n channel: Maybe.zero(),\n headTag: new Uint8Array([0x05]),\n dataSize: Maybe.zero(),\n index: new Uint8Array([0, 0x02]),\n length: 3,\n }),\n data: new Uint8Array([0x2d, 0x32, 0x00, 0x90, 0x00]),\n }),\n ]);\n expect(frames.map((fr) => fr.getRawData())).toEqual([\n new Uint8Array([\n 0x05, 0x00, 0x00, 0x00, 0x11, 0x01, 0x05, 0x4f, 0x4c, 0x4f,\n ]),\n new Uint8Array([\n 0x05, 0x00, 0x01, 0x53, 0x00, 0x07, 0x2e, 0x32, 0x2e, 0x34,\n ]),\n new Uint8Array([0x05, 0x00, 0x02, 0x2d, 0x32, 0x00, 0x90, 0x00]),\n ]);\n });\n });\n\n describe(\"Errors\", () => {\n it(\"should return a well formatted header with very big channel\", () => {\n // given\n const apduSenderService = new DefaultApduSenderService(\n {\n frameSize: 64,\n channel: Maybe.of(\n new Uint8Array([0x123434, 0x34444, 0x56454, 0x7844, 0x90444]),\n ),\n },\n () => loggerService,\n );\n const command = new Uint8Array([0xe0, 0x01, 0x00, 0x00, 0x00]);\n\n // when\n const frames = apduSenderService.getFrames(command);\n\n // then\n expect(frames).toEqual([\n new Frame({\n header: new FrameHeader({\n uuid: \"42\",\n channel: Maybe.of(new Uint8Array([0x44, 0x44])),\n headTag: new Uint8Array([0x05]),\n dataSize: Maybe.of(new Uint8Array([0, 0x05])),\n index: new Uint8Array([0, 0]),\n length: 7,\n }),\n data: new Uint8Array([0xe0, 0x01, 0x00, 0x00, 0x00]),\n }),\n ]);\n expect(frames.map((fr) => fr.getRawData())).toEqual([\n new Uint8Array([\n 0x44, 0x44, 0x05, 0x00, 0x00, 0x00, 0x05, 0xe0, 0x01, 0x00, 0x00,\n 0x00,\n ]),\n ]);\n });\n it(\"should return empty if packet size smaller than header size\", () => {\n // given\n const apduSenderService = new DefaultApduSenderService(\n {\n frameSize: Math.random() & 4,\n channel: Maybe.of(new Uint8Array([0x12, 0x34])),\n },\n () => loggerService,\n );\n const command = new Uint8Array([0xe0, 0x01, 0x00, 0x00, 0x00]);\n\n // when\n const frames = apduSenderService.getFrames(command);\n\n // then\n expect(frames.length).toEqual(0);\n });\n\n it(\"should return empty if no apdu length\", () => {\n // given\n const apduSenderService = new DefaultApduSenderService(\n {\n // random frameSize < 0xff\n frameSize: Math.random() & 0xff,\n // random padding boolean\n padding: Math.random() > 0.5,\n channel: Maybe.of(new Uint8Array([0x12, 0x34])),\n },\n () => loggerService,\n );\n const command = new Uint8Array([]);\n\n // when\n const frames = apduSenderService.getFrames(command);\n\n // then\n expect(frames.length).toEqual(0);\n });\n });\n});\n"],
5
+ "mappings": "aAAA,IAAAA,EAAsB,qBAEtBC,EAAsB,gDACtBC,EAA4B,sDAC5BC,EAA8C,4EAE9CC,EAAyC,sCAEzC,GAAG,KAAK,OAAQ,KAAO,CACrB,GAAI,GAAG,GAAG,EAAE,gBAAgB,IAAI,CAClC,EAAE,EAEF,MAAMC,EAAgB,IAAI,gCAA8B,CAAC,EAAG,OAAO,EAEnE,SAAS,2BAA4B,IAAM,CACzC,SAAS,iCAAkC,IAAM,CAC/C,GAAG,wBAAyB,IAAM,CAEhC,MAAMC,EAAU,QAAM,GAAG,IAAI,WAAW,CAAC,GAAM,EAAI,CAAC,CAAC,EAC/CC,EAAoB,IAAI,2BAC5B,CACE,UAAW,GACX,QAA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W,CAAC,EAAG,CAAC,CAAC,EAC5B,OAAQ,CACV,CAAC,EACD,KAAM,IAAI,WAAW,CAAC,IAAM,EAAM,EAAM,EAAM,CAAI,CAAC,CACrD,CAAC,CACH,CAAC,EACD,OAAOA,EAAO,IAAKC,GAAOA,EAAG,WAAW,CAAC,CAAC,EAAE,QAAQ,CAClD,IAAI,WAAW,CACb,GAAM,GAAM,EAAM,EAAM,EAAM,EAAM,EAAM,IAAM,EAAM,EAAM,EAC5D,CACF,CAAC,CACH,CAAC,CACH,CAAC,EACD,GAAG,8DAA+D,IAAM,CAEtE,MAAMH,EAAoB,IAAI,2BAC5B,CACE,UAAW,KAAK,OAAO,EAAI,EAC3B,QAAS,QAAM,GAAG,IAAI,WAAW,CAAC,GAAM,EAAI,CAAC,CAAC,CAChD,EACA,IAAMF,CACR,EACMM,EAAU,IAAI,WAAW,CAAC,IAAM,EAAM,EAAM,EAAM,CAAI,CAAC,EAGvDF,EAASF,EAAkB,UAAUI,CAAO,EAGlD,OAAOF,EAAO,MAAM,EAAE,QAAQ,CAAC,CACjC,CAAC,EAED,GAAG,wCAAyC,IAAM,CAEhD,MAAMF,EAAoB,IAAI,2BAC5B,CAEE,UAAW,KAAK,OAAO,EAAI,IAE3B,QAAS,KAAK,OAAO,EAAI,GACzB,QAAS,QAAM,GAAG,IAAI,WAAW,CAAC,GAAM,EAAI,CAAC,CAAC,CAChD,EACA,IAAMF,CACR,EACMM,EAAU,IAAI,WAAW,CAAC,CAAC,EAG3BF,EAASF,EAAkB,UAAUI,CAAO,EAGlD,OAAOF,EAAO,MAAM,EAAE,QAAQ,CAAC,CACjC,CAAC,CACH,CAAC,CACH,CAAC",
6
6
  "names": ["import_purify_ts", "import_Frame", "import_FrameHeader", "import_DefaultLoggerPublisherService", "import_DefaultApduSenderService", "loggerService", "channel", "apduSenderService", "apdu", "frames", "fr", "command"]
7
7
  }
@@ -1,2 +1,2 @@
1
- "use strict";var n=require("purify-ts"),v=require("rxjs"),c=require("../../device-session/model/DeviceSession.stub"),S=require("../../device-session/model/Errors"),l=require("../../logger-publisher/service/DefaultLoggerPublisherService"),u=require("../../manager-api/data/AxiosManagerApiDataSource"),p=require("../../manager-api/service/DefaultManagerApiService"),D=require("./DefaultDeviceSessionService");jest.mock("@internal/logger-publisher/service/DefaultLoggerPublisherService");jest.mock("@internal/manager-api/data/AxiosManagerApiDataSource");let e,t,s,a,d;describe("DefaultDeviceSessionService",()=>{beforeEach(()=>{jest.restoreAllMocks(),t=new l.DefaultLoggerPublisherService([],"deviceSession"),e=new D.DefaultDeviceSessionService(()=>t),d=new u.AxiosManagerApiDataSource({}),a=new p.DefaultManagerApiService(d),s=(0,c.deviceSessionStubBuilder)({},()=>t,a)}),afterEach(()=>{s.close()}),it("should have an empty sessions list",()=>{expect(e.getDeviceSessions()).toEqual([])}),it("should add a deviceSession",()=>{e.addDeviceSession(s),expect(e.getDeviceSessions()).toEqual([s])}),it("should not add a deviceSession if it already exists",()=>{e.addDeviceSession(s),e.addDeviceSession(s),expect(e.getDeviceSessions()).toEqual([s])}),it("should remove a deviceSession",()=>{e.addDeviceSession(s),e.removeDeviceSession(s.id),expect(e.getDeviceSessions()).toEqual([])}),it("should not remove a deviceSession if it does not exist",()=>{e.removeDeviceSession(s.id),expect(e.getDeviceSessions()).toEqual([])}),it("should get a deviceSession",()=>{e.addDeviceSession(s),expect(e.getDeviceSessionById(s.id)).toEqual(n.Either.of(s))}),it("should not get a deviceSession if it does not exist",()=>{expect(e.getDeviceSessionById(s.id)).toEqual((0,n.Left)(new S.DeviceSessionNotFound))}),it("should get all sessions",()=>{e.addDeviceSession(s),expect(e.getDeviceSessions()).toEqual([s])}),it("should retrieve sessionObs",()=>{expect(e.sessionsObs).toBeInstanceOf(v.Observable)}),it("should emit new session",i=>{const o=e.sessionsObs.subscribe({next(r){expect(r).toStrictEqual(s),o.unsubscribe(),i()}});e.addDeviceSession(s)}),it("should emit previous added session",()=>{const i=(0,c.deviceSessionStubBuilder)({id:"last-session"},()=>t,a),o=[];e.addDeviceSession(s),e.addDeviceSession(i);const r=e.sessionsObs.subscribe({next(m){o.push(m)}});i.close(),expect(o).toEqual([s,i]),r.unsubscribe()})});
1
+ "use strict";var r=require("purify-ts"),d=require("rxjs"),l=require("../../device-session/model/DeviceSession.stub"),p=require("../../device-session/model/Errors"),m=require("../../logger-publisher/service/DefaultLoggerPublisherService"),D=require("../../manager-api/data/AxiosManagerApiDataSource"),f=require("../../manager-api/service/DefaultManagerApiService"),g=require("../../secure-channel/data/DefaultSecureChannelDataSource"),h=require("../../secure-channel/service/DefaultSecureChannelService"),b=require("./DefaultDeviceSessionService");vi.mock("@internal/logger-publisher/service/DefaultLoggerPublisherService");vi.mock("@internal/manager-api/data/AxiosManagerApiDataSource");let e,t,i,v,c,u,S;describe("DefaultDeviceSessionService",()=>{beforeEach(()=>{vi.restoreAllMocks(),t=new m.DefaultLoggerPublisherService([],"deviceSession"),e=new b.DefaultDeviceSessionService(()=>t),v=new D.AxiosManagerApiDataSource({}),c=new f.DefaultManagerApiService(v),u=new g.DefaultSecureChannelDataSource({}),S=new h.DefaultSecureChannelService(u),i=(0,l.deviceSessionStubBuilder)({},()=>t,c,S)}),afterEach(()=>{i.close()}),it("should have an empty sessions list",()=>{expect(e.getDeviceSessions()).toEqual([])}),it("should add a deviceSession",()=>{e.addDeviceSession(i),expect(e.getDeviceSessions()).toEqual([i])}),it("should not add a deviceSession if it already exists",()=>{e.addDeviceSession(i),e.addDeviceSession(i),expect(e.getDeviceSessions()).toEqual([i])}),it("should remove a deviceSession",()=>{e.addDeviceSession(i),e.removeDeviceSession(i.id),expect(e.getDeviceSessions()).toEqual([])}),it("should not remove a deviceSession if it does not exist",()=>{e.removeDeviceSession(i.id),expect(e.getDeviceSessions()).toEqual([])}),it("should get a deviceSession",()=>{e.addDeviceSession(i),expect(e.getDeviceSessionById(i.id)).toEqual(r.Either.of(i))}),it("should not get a deviceSession if it does not exist",()=>{expect(e.getDeviceSessionById(i.id)).toEqual((0,r.Left)(new p.DeviceSessionNotFound))}),it("should get all sessions",()=>{e.addDeviceSession(i),expect(e.getDeviceSessions()).toEqual([i])}),it("should retrieve sessionObs",()=>{expect(e.sessionsObs).toBeInstanceOf(d.Observable)}),it("should emit new session",()=>new Promise((s,o)=>{const n=e.sessionsObs.subscribe({next(a){try{expect(a).toStrictEqual(i),n.unsubscribe(),s()}catch(x){o(x)}}});e.addDeviceSession(i)})),it("should emit previous added session",()=>{const s=(0,l.deviceSessionStubBuilder)({id:"last-session"},()=>t,c,S),o=[];e.addDeviceSession(i),e.addDeviceSession(s);const n=e.sessionsObs.subscribe({next(a){o.push(a)}});s.close(),expect(o).toEqual([i,s]),n.unsubscribe()})});
2
2
  //# sourceMappingURL=DefaultDeviceSessionService.test.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../../../src/internal/device-session/service/DefaultDeviceSessionService.test.ts"],
4
- "sourcesContent": ["import { Either, Left } from \"purify-ts\";\nimport { Observable } from \"rxjs\";\n\nimport { type DmkConfig } from \"@api/DmkConfig\";\nimport { type DeviceSession } from \"@internal/device-session/model/DeviceSession\";\nimport { deviceSessionStubBuilder } from \"@internal/device-session/model/DeviceSession.stub\";\nimport { DeviceSessionNotFound } from \"@internal/device-session/model/Errors\";\nimport { DefaultLoggerPublisherService } from \"@internal/logger-publisher/service/DefaultLoggerPublisherService\";\nimport { AxiosManagerApiDataSource } from \"@internal/manager-api/data/AxiosManagerApiDataSource\";\nimport { type ManagerApiDataSource } from \"@internal/manager-api/data/ManagerApiDataSource\";\nimport { DefaultManagerApiService } from \"@internal/manager-api/service/DefaultManagerApiService\";\nimport type { ManagerApiService } from \"@internal/manager-api/service/ManagerApiService\";\n\nimport { DefaultDeviceSessionService } from \"./DefaultDeviceSessionService\";\n\njest.mock(\"@internal/logger-publisher/service/DefaultLoggerPublisherService\");\njest.mock(\"@internal/manager-api/data/AxiosManagerApiDataSource\");\n\nlet sessionService: DefaultDeviceSessionService;\nlet loggerService: DefaultLoggerPublisherService;\nlet deviceSession: DeviceSession;\nlet managerApi: ManagerApiService;\nlet managerApiDataSource: ManagerApiDataSource;\ndescribe(\"DefaultDeviceSessionService\", () => {\n beforeEach(() => {\n jest.restoreAllMocks();\n loggerService = new DefaultLoggerPublisherService([], \"deviceSession\");\n sessionService = new DefaultDeviceSessionService(() => loggerService);\n managerApiDataSource = new AxiosManagerApiDataSource({} as DmkConfig);\n managerApi = new DefaultManagerApiService(managerApiDataSource);\n\n deviceSession = deviceSessionStubBuilder(\n {},\n () => loggerService,\n managerApi,\n );\n });\n\n afterEach(() => {\n deviceSession.close();\n });\n\n it(\"should have an empty sessions list\", () => {\n expect(sessionService.getDeviceSessions()).toEqual([]);\n });\n\n it(\"should add a deviceSession\", () => {\n sessionService.addDeviceSession(deviceSession);\n expect(sessionService.getDeviceSessions()).toEqual([deviceSession]);\n });\n\n it(\"should not add a deviceSession if it already exists\", () => {\n sessionService.addDeviceSession(deviceSession);\n sessionService.addDeviceSession(deviceSession);\n expect(sessionService.getDeviceSessions()).toEqual([deviceSession]);\n });\n\n it(\"should remove a deviceSession\", () => {\n sessionService.addDeviceSession(deviceSession);\n sessionService.removeDeviceSession(deviceSession.id);\n expect(sessionService.getDeviceSessions()).toEqual([]);\n });\n\n it(\"should not remove a deviceSession if it does not exist\", () => {\n sessionService.removeDeviceSession(deviceSession.id);\n expect(sessionService.getDeviceSessions()).toEqual([]);\n });\n\n it(\"should get a deviceSession\", () => {\n sessionService.addDeviceSession(deviceSession);\n expect(sessionService.getDeviceSessionById(deviceSession.id)).toEqual(\n Either.of(deviceSession),\n );\n });\n\n it(\"should not get a deviceSession if it does not exist\", () => {\n expect(sessionService.getDeviceSessionById(deviceSession.id)).toEqual(\n Left(new DeviceSessionNotFound()),\n );\n });\n\n it(\"should get all sessions\", () => {\n sessionService.addDeviceSession(deviceSession);\n expect(sessionService.getDeviceSessions()).toEqual([deviceSession]);\n });\n\n it(\"should retrieve sessionObs\", () => {\n expect(sessionService.sessionsObs).toBeInstanceOf(\n Observable<DeviceSession>,\n );\n });\n\n it(\"should emit new session\", (done) => {\n const subscription = sessionService.sessionsObs.subscribe({\n next(emittedDeviceSession) {\n expect(emittedDeviceSession).toStrictEqual(deviceSession);\n subscription.unsubscribe();\n done();\n },\n });\n sessionService.addDeviceSession(deviceSession);\n });\n\n it(\"should emit previous added session\", () => {\n const lastDeviceSession = deviceSessionStubBuilder(\n { id: \"last-session\" },\n () => loggerService,\n managerApi,\n );\n const emittedSessions: DeviceSession[] = [];\n sessionService.addDeviceSession(deviceSession);\n sessionService.addDeviceSession(lastDeviceSession);\n\n const subscription = sessionService.sessionsObs.subscribe({\n next(emittedDeviceSession) {\n emittedSessions.push(emittedDeviceSession);\n },\n });\n lastDeviceSession.close();\n expect(emittedSessions).toEqual([deviceSession, lastDeviceSession]);\n subscription.unsubscribe();\n });\n});\n"],
5
- "mappings": "aAAA,IAAAA,EAA6B,qBAC7BC,EAA2B,gBAI3BC,EAAyC,6DACzCC,EAAsC,iDACtCC,EAA8C,4EAC9CC,EAA0C,gEAE1CC,EAAyC,kEAGzCC,EAA4C,yCAE5C,KAAK,KAAK,kEAAkE,EAC5E,KAAK,KAAK,sDAAsD,EAEhE,IAAIC,EACAC,EACAC,EACAC,EACAC,EACJ,SAAS,8BAA+B,IAAM,CAC5C,WAAW,IAAM,CACf,KAAK,gBAAgB,EACrBH,EAAgB,IAAI,gCAA8B,CAAC,EAAG,eAAe,EACrED,EAAiB,IAAI,8BAA4B,IAAMC,CAAa,EACpEG,EAAuB,IAAI,4BAA0B,CAAC,CAAc,EACpED,EAAa,IAAI,2BAAyBC,CAAoB,EAE9DF,KAAgB,4BACd,CAAC,EACD,IAAMD,EACNE,CACF,CACF,CAAC,EAED,UAAU,IAAM,CACdD,EAAc,MAAM,CACtB,CAAC,EAED,GAAG,qCAAsC,IAAM,CAC7C,OAAOF,EAAe,kBAAkB,CAAC,EAAE,QAAQ,CAAC,CAAC,CACvD,CAAC,EA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P,CACF,CAAC,EACDL,EAAe,iBAAiBE,CAAa,CAC/C,CAAC,EAED,GAAG,qCAAsC,IAAM,CAC7C,MAAMM,KAAoB,4BACxB,CAAE,GAAI,cAAe,EACrB,IAAMP,EACNE,CACF,EACMM,EAAmC,CAAC,EAC1CT,EAAe,iBAAiBE,CAAa,EAC7CF,EAAe,iBAAiBQ,CAAiB,EAEjD,MAAMF,EAAeN,EAAe,YAAY,UAAU,CACxD,KAAKO,EAAsB,CACzBE,EAAgB,KAAKF,CAAoB,CAC3C,CACF,CAAC,EACDC,EAAkB,MAAM,EACxB,OAAOC,CAAe,EAAE,QAAQ,CAACP,EAAeM,CAAiB,CAAC,EAClEF,EAAa,YAAY,CAC3B,CAAC,CACH,CAAC",
6
- "names": ["import_purify_ts", "import_rxjs", "import_DeviceSession", "import_Errors", "import_DefaultLoggerPublisherService", "import_AxiosManagerApiDataSource", "import_DefaultManagerApiService", "import_DefaultDeviceSessionService", "sessionService", "loggerService", "deviceSession", "managerApi", "managerApiDataSource", "done", "subscription", "emittedDeviceSession", "lastDeviceSession", "emittedSessions"]
4
+ "sourcesContent": ["import { Either, Left } from \"purify-ts\";\nimport { Observable } from \"rxjs\";\n\nimport { type DmkConfig } from \"@api/DmkConfig\";\nimport { type DeviceSession } from \"@internal/device-session/model/DeviceSession\";\nimport { deviceSessionStubBuilder } from \"@internal/device-session/model/DeviceSession.stub\";\nimport { DeviceSessionNotFound } from \"@internal/device-session/model/Errors\";\nimport { DefaultLoggerPublisherService } from \"@internal/logger-publisher/service/DefaultLoggerPublisherService\";\nimport { AxiosManagerApiDataSource } from \"@internal/manager-api/data/AxiosManagerApiDataSource\";\nimport { type ManagerApiDataSource } from \"@internal/manager-api/data/ManagerApiDataSource\";\nimport { DefaultManagerApiService } from \"@internal/manager-api/service/DefaultManagerApiService\";\nimport type { ManagerApiService } from \"@internal/manager-api/service/ManagerApiService\";\nimport { DefaultSecureChannelDataSource } from \"@internal/secure-channel/data/DefaultSecureChannelDataSource\";\nimport { type SecureChannelDataSource } from \"@internal/secure-channel/data/SecureChannelDataSource\";\nimport { DefaultSecureChannelService } from \"@internal/secure-channel/service/DefaultSecureChannelService\";\nimport { type SecureChannelService } from \"@internal/secure-channel/service/SecureChannelService\";\n\nimport { DefaultDeviceSessionService } from \"./DefaultDeviceSessionService\";\n\nvi.mock(\"@internal/logger-publisher/service/DefaultLoggerPublisherService\");\nvi.mock(\"@internal/manager-api/data/AxiosManagerApiDataSource\");\n\nlet sessionService: DefaultDeviceSessionService;\nlet loggerService: DefaultLoggerPublisherService;\nlet deviceSession: DeviceSession;\nlet managerApiDataSource: ManagerApiDataSource;\nlet managerApi: ManagerApiService;\nlet secureChannelDataSource: SecureChannelDataSource;\nlet secureChannel: SecureChannelService;\n\ndescribe(\"DefaultDeviceSessionService\", () => {\n beforeEach(() => {\n vi.restoreAllMocks();\n loggerService = new DefaultLoggerPublisherService([], \"deviceSession\");\n sessionService = new DefaultDeviceSessionService(() => loggerService);\n managerApiDataSource = new AxiosManagerApiDataSource({} as DmkConfig);\n managerApi = new DefaultManagerApiService(managerApiDataSource);\n secureChannelDataSource = new DefaultSecureChannelDataSource(\n {} as DmkConfig,\n );\n secureChannel = new DefaultSecureChannelService(secureChannelDataSource);\n\n deviceSession = deviceSessionStubBuilder(\n {},\n () => loggerService,\n managerApi,\n secureChannel,\n );\n });\n\n afterEach(() => {\n deviceSession.close();\n });\n\n it(\"should have an empty sessions list\", () => {\n expect(sessionService.getDeviceSessions()).toEqual([]);\n });\n\n it(\"should add a deviceSession\", () => {\n sessionService.addDeviceSession(deviceSession);\n expect(sessionService.getDeviceSessions()).toEqual([deviceSession]);\n });\n\n it(\"should not add a deviceSession if it already exists\", () => {\n sessionService.addDeviceSession(deviceSession);\n sessionService.addDeviceSession(deviceSession);\n expect(sessionService.getDeviceSessions()).toEqual([deviceSession]);\n });\n\n it(\"should remove a deviceSession\", () => {\n sessionService.addDeviceSession(deviceSession);\n sessionService.removeDeviceSession(deviceSession.id);\n expect(sessionService.getDeviceSessions()).toEqual([]);\n });\n\n it(\"should not remove a deviceSession if it does not exist\", () => {\n sessionService.removeDeviceSession(deviceSession.id);\n expect(sessionService.getDeviceSessions()).toEqual([]);\n });\n\n it(\"should get a deviceSession\", () => {\n sessionService.addDeviceSession(deviceSession);\n expect(sessionService.getDeviceSessionById(deviceSession.id)).toEqual(\n Either.of(deviceSession),\n );\n });\n\n it(\"should not get a deviceSession if it does not exist\", () => {\n expect(sessionService.getDeviceSessionById(deviceSession.id)).toEqual(\n Left(new DeviceSessionNotFound()),\n );\n });\n\n it(\"should get all sessions\", () => {\n sessionService.addDeviceSession(deviceSession);\n expect(sessionService.getDeviceSessions()).toEqual([deviceSession]);\n });\n\n it(\"should retrieve sessionObs\", () => {\n expect(sessionService.sessionsObs).toBeInstanceOf(\n Observable<DeviceSession>,\n );\n });\n\n it(\"should emit new session\", () =>\n new Promise<void>((resolve, reject) => {\n const subscription = sessionService.sessionsObs.subscribe({\n next(emittedDeviceSession) {\n try {\n expect(emittedDeviceSession).toStrictEqual(deviceSession);\n subscription.unsubscribe();\n resolve();\n } catch (error) {\n reject(error);\n }\n },\n });\n sessionService.addDeviceSession(deviceSession);\n }));\n\n it(\"should emit previous added session\", () => {\n const lastDeviceSession = deviceSessionStubBuilder(\n { id: \"last-session\" },\n () => loggerService,\n managerApi,\n secureChannel,\n );\n const emittedSessions: DeviceSession[] = [];\n sessionService.addDeviceSession(deviceSession);\n sessionService.addDeviceSession(lastDeviceSession);\n\n const subscription = sessionService.sessionsObs.subscribe({\n next(emittedDeviceSession) {\n emittedSessions.push(emittedDeviceSession);\n },\n });\n lastDeviceSession.close();\n expect(emittedSessions).toEqual([deviceSession, lastDeviceSession]);\n subscription.unsubscribe();\n });\n});\n"],
5
+ "mappings": "aAAA,IAAAA,EAA6B,qBAC7BC,EAA2B,gBAI3BC,EAAyC,6DACzCC,EAAsC,iDACtCC,EAA8C,4EAC9CC,EAA0C,gEAE1CC,EAAyC,kEAEzCC,EAA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"names": ["import_purify_ts", "import_rxjs", "import_DeviceSession", "import_Errors", "import_DefaultLoggerPublisherService", "import_AxiosManagerApiDataSource", "import_DefaultManagerApiService", "import_DefaultSecureChannelDataSource", "import_DefaultSecureChannelService", "import_DefaultDeviceSessionService", "sessionService", "loggerService", "deviceSession", "managerApiDataSource", "managerApi", "secureChannelDataSource", "secureChannel", "resolve", "reject", "subscription", "emittedDeviceSession", "error", "lastDeviceSession", "emittedSessions"]
7
7
  }
@@ -0,0 +1,2 @@
1
+ "use strict";var o=Object.defineProperty;var f=Object.getOwnPropertyDescriptor;var c=Object.getOwnPropertyNames;var l=Object.prototype.hasOwnProperty;var n=(s,e)=>{for(var r in e)o(s,r,{get:e[r],enumerable:!0})},a=(s,e,r,t)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of c(e))!l.call(s,i)&&i!==r&&o(s,i,{get:()=>e[i],enumerable:!(t=f(e,i))||t.enumerable});return s};var d=s=>a(o({},"__esModule",{value:!0}),s);var B={};n(B,{RefresherService:()=>v});module.exports=d(B);var h=require("uuid");class v{constructor(e){this._refresher=e}_refresherBlockers=new Set;disableRefresher(e){const r=`${e}-${(0,h.v4)()}`;this.addRefresherBlocker(r);let t=!1;return()=>{t||(t=!0,this.removeRefresherBlocker(r))}}addRefresherBlocker(e){const r=this._refresherBlockers.size;this._refresherBlockers.add(e),r===0&&this._refresher.stop()}removeRefresherBlocker(e){const r=this._refresherBlockers.size;this._refresherBlockers.delete(e),r>0&&this._refresherBlockers.size===0&&this._refresher.start()}}0&&(module.exports={RefresherService});
2
+ //# sourceMappingURL=RefresherService.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../../../../src/internal/device-session/service/RefresherService.ts"],
4
+ "sourcesContent": ["import { v4 as uuidv4 } from \"uuid\";\n\nimport { type DeviceSessionRefresher } from \"@internal/device-session/model/DeviceSessionRefresher\";\n\nexport class RefresherService {\n // the refresher should be enabled if and only if the size of this is equal to zero\n private readonly _refresherBlockers = new Set<string>();\n\n constructor(private readonly _refresher: DeviceSessionRefresher) {}\n\n public disableRefresher(id: string): () => void {\n const uniqueId = `${id}-${uuidv4()}`;\n this.addRefresherBlocker(uniqueId);\n\n let hasBeenReenabled = false;\n\n return () => {\n if (hasBeenReenabled) return;\n\n hasBeenReenabled = true;\n this.removeRefresherBlocker(uniqueId);\n };\n }\n\n private addRefresherBlocker(blockerId: string) {\n const prevBlockersCount = this._refresherBlockers.size;\n this._refresherBlockers.add(blockerId);\n\n if (prevBlockersCount === 0) {\n this._refresher.stop();\n }\n }\n\n private removeRefresherBlocker(blockerId: string) {\n const prevBlockersCount = this._refresherBlockers.size;\n this._refresherBlockers.delete(blockerId);\n\n if (prevBlockersCount > 0 && this._refresherBlockers.size === 0) {\n this._refresher.start();\n }\n }\n}\n"],
5
+ "mappings": "yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,sBAAAE,IAAA,eAAAC,EAAAH,GAAA,IAAAI,EAA6B,gBAItB,MAAMF,CAAiB,CAI5B,YAA6BG,EAAoC,CAApC,gBAAAA,CAAqC,CAFjD,mBAAqB,IAAI,IAInC,iBAAiBC,EAAwB,CAC9C,MAAMC,EAAW,GAAGD,CAAE,OAAI,EAAAE,IAAO,CAAC,GAClC,KAAK,oBAAoBD,CAAQ,EAEjC,IAAIE,EAAmB,GAEvB,MAAO,IAAM,CACPA,IAEJA,EAAmB,GACnB,KAAK,uBAAuBF,CAAQ,EACtC,CACF,CAEQ,oBAAoBG,EAAmB,CAC7C,MAAMC,EAAoB,KAAK,mBAAmB,KAClD,KAAK,mBAAmB,IAAID,CAAS,EAEjCC,IAAsB,GACxB,KAAK,WAAW,KAAK,CAEzB,CAEQ,uBAAuBD,EAAmB,CAChD,MAAMC,EAAoB,KAAK,mBAAmB,KAClD,KAAK,mBAAmB,OAAOD,CAAS,EAEpCC,EAAoB,GAAK,KAAK,mBAAmB,OAAS,GAC5D,KAAK,WAAW,MAAM,CAE1B,CACF",
6
+ "names": ["RefresherService_exports", "__export", "RefresherService", "__toCommonJS", "import_uuid", "_refresher", "id", "uniqueId", "uuidv4", "hasBeenReenabled", "blockerId", "prevBlockersCount"]
7
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";var s=require("./RefresherService");let e;describe("RefresherService",()=>{beforeEach(()=>{e={start:vi.fn(),stop:vi.fn()}}),it("should be created",()=>{const r=new s.RefresherService(e);expect(r).toBeDefined()}),describe("with only 1 blocker",()=>{it("should disable the refresher",()=>{new s.RefresherService(e).disableRefresher("test"),expect(e.stop).toHaveBeenCalled()}),it("should reenable the refresher",()=>{new s.RefresherService(e).disableRefresher("test")(),expect(e.stop).toHaveBeenCalled(),expect(e.start).toHaveBeenCalled()})}),describe("with 2+ blockers",()=>{it("should not disable the refresher a second time",()=>{const r=new s.RefresherService(e);r.disableRefresher("test"),r.disableRefresher("test-2"),expect(e.stop).toHaveBeenCalledTimes(1)}),it("should reenable the refresher when the last blocker is removed",()=>{const r=new s.RefresherService(e),t=r.disableRefresher("test"),o=r.disableRefresher("test-2");expect(e.stop).toHaveBeenCalledTimes(1),t(),expect(e.start).not.toHaveBeenCalled(),o(),expect(e.start).toHaveBeenCalled()})})});
2
+ //# sourceMappingURL=RefresherService.test.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../../../../src/internal/device-session/service/RefresherService.test.ts"],
4
+ "sourcesContent": ["import { type DeviceSessionRefresher } from \"@internal/device-session/model/DeviceSessionRefresher\";\n\nimport { RefresherService } from \"./RefresherService\";\n\nlet refresher: DeviceSessionRefresher;\ndescribe(\"RefresherService\", () => {\n beforeEach(() => {\n refresher = {\n start: vi.fn(),\n stop: vi.fn(),\n } as unknown as DeviceSessionRefresher;\n });\n\n it(\"should be created\", () => {\n const refresherService = new RefresherService(refresher);\n expect(refresherService).toBeDefined();\n });\n\n describe(\"with only 1 blocker\", () => {\n it(\"should disable the refresher\", () => {\n const refresherService = new RefresherService(refresher);\n refresherService.disableRefresher(\"test\");\n expect(refresher.stop).toHaveBeenCalled();\n });\n\n it(\"should reenable the refresher\", () => {\n const refresherService = new RefresherService(refresher);\n const reenableRefresher = refresherService.disableRefresher(\"test\");\n reenableRefresher();\n expect(refresher.stop).toHaveBeenCalled();\n expect(refresher.start).toHaveBeenCalled();\n });\n });\n\n describe(\"with 2+ blockers\", () => {\n it(\"should not disable the refresher a second time\", () => {\n const refresherService = new RefresherService(refresher);\n refresherService.disableRefresher(\"test\");\n refresherService.disableRefresher(\"test-2\");\n expect(refresher.stop).toHaveBeenCalledTimes(1);\n });\n\n it(\"should reenable the refresher when the last blocker is removed\", () => {\n const refresherService = new RefresherService(refresher);\n const reenableRefresher1 = refresherService.disableRefresher(\"test\");\n const reenableRefresher2 = refresherService.disableRefresher(\"test-2\");\n expect(refresher.stop).toHaveBeenCalledTimes(1);\n reenableRefresher1();\n expect(refresher.start).not.toHaveBeenCalled();\n reenableRefresher2();\n expect(refresher.start).toHaveBeenCalled();\n });\n });\n});\n"],
5
+ "mappings": "aAEA,IAAAA,EAAiC,8BAEjC,IAAIC,EACJ,SAAS,mBAAoB,IAAM,CACjC,WAAW,IAAM,CACfA,EAAY,CACV,MAAO,GAAG,GAAG,EACb,KAAM,GAAG,GAAG,CACd,CACF,CAAC,EAED,GAAG,oBAAqB,IAAM,CAC5B,MAAMC,EAAmB,IAAI,mBAAiBD,CAAS,EACvD,OAAOC,CAAgB,EAAE,YAAY,CACvC,CAAC,EAED,SAAS,sBAAuB,IAAM,CACpC,GAAG,+BAAgC,IAAM,CACd,IAAI,mBAAiBD,CAAS,EACtC,iBAAiB,MAAM,EACxC,OAAOA,EAAU,IAAI,EAAE,iBAAiB,CAC1C,CAAC,EAED,GAAG,gCAAiC,IAAM,CACf,IAAI,mBAAiBA,CAAS,EACZ,iBAAiB,MAAM,EAChD,EAClB,OAAOA,EAAU,IAAI,EAAE,iBAAiB,EACxC,OAAOA,EAAU,KAAK,EAAE,iBAAiB,CAC3C,CAAC,CACH,CAAC,EAED,SAAS,mBAAoB,IAAM,CACjC,GAAG,iDAAkD,IAAM,CACzD,MAAMC,EAAmB,IAAI,mBAAiBD,CAAS,EACvDC,EAAiB,iBAAiB,MAAM,EACxCA,EAAiB,iBAAiB,QAAQ,EAC1C,OAAOD,EAAU,IAAI,EAAE,sBAAsB,CAAC,CAChD,CAAC,EAED,GAAG,iEAAkE,IAAM,CACzE,MAAMC,EAAmB,IAAI,mBAAiBD,CAAS,EACjDE,EAAqBD,EAAiB,iBAAiB,MAAM,EAC7DE,EAAqBF,EAAiB,iBAAiB,QAAQ,EACrE,OAAOD,EAAU,IAAI,EAAE,sBAAsB,CAAC,EAC9CE,EAAmB,EACnB,OAAOF,EAAU,KAAK,EAAE,IAAI,iBAAiB,EAC7CG,EAAmB,EACnB,OAAOH,EAAU,KAAK,EAAE,iBAAiB,CAC3C,CAAC,CACH,CAAC,CACH,CAAC",
6
+ "names": ["import_RefresherService", "refresher", "refresherService", "reenableRefresher1", "reenableRefresher2"]
7
+ }
@@ -1,2 +1,2 @@
1
- "use strict";var n=require("../../device-session/model/DeviceSession.stub"),c=require("../../device-session/service/DefaultDeviceSessionService"),m=require("../../device-session/use-case/CloseSessionsUseCase"),p=require("../../logger-publisher/service/DefaultLoggerPublisherService"),S=require("../../manager-api/data/AxiosManagerApiDataSource"),l=require("../../manager-api/service/DefaultManagerApiService");let s,a,t,r;describe("CloseSessionsUseCase",()=>{beforeEach(()=>{s=new p.DefaultLoggerPublisherService([],"close-sessions-use-case-test"),a=new S.AxiosManagerApiDataSource({}),t=new l.DefaultManagerApiService(a),r=new c.DefaultDeviceSessionService(()=>s)}),it("should be able to close every session",()=>{const o=[...Array(10).keys()].map(e=>{const i=(0,n.deviceSessionStubBuilder)({id:e.toString()},()=>s,t);return jest.spyOn(i,"close"),i});o.forEach(e=>r.addDeviceSession(e)),new m.CloseSessionsUseCase(r).execute(),o.forEach(e=>{expect(e.close).toHaveBeenCalled()})})});
1
+ "use strict";var m=require("../../device-session/model/DeviceSession.stub"),S=require("../../device-session/service/DefaultDeviceSessionService"),l=require("../../device-session/use-case/CloseSessionsUseCase"),p=require("../../logger-publisher/service/DefaultLoggerPublisherService"),u=require("../../manager-api/data/AxiosManagerApiDataSource"),f=require("../../manager-api/service/DefaultManagerApiService"),v=require("../../secure-channel/data/DefaultSecureChannelDataSource"),g=require("../../secure-channel/service/DefaultSecureChannelService");let r,a,t,n,c,o;describe("CloseSessionsUseCase",()=>{beforeEach(()=>{r=new p.DefaultLoggerPublisherService([],"close-sessions-use-case-test"),a=new u.AxiosManagerApiDataSource({}),t=new f.DefaultManagerApiService(a),n=new v.DefaultSecureChannelDataSource({}),c=new g.DefaultSecureChannelService(n),o=new S.DefaultDeviceSessionService(()=>r)}),it("should be able to close every session",()=>{const i=[...Array(10).keys()].map(e=>{const s=(0,m.deviceSessionStubBuilder)({id:e.toString()},()=>r,t,c);return vi.spyOn(s,"close"),s});i.forEach(e=>o.addDeviceSession(e)),new l.CloseSessionsUseCase(o).execute(),i.forEach(e=>{expect(e.close).toHaveBeenCalled()})})});
2
2
  //# sourceMappingURL=CloseSessionsUseCase.test.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../../../src/internal/device-session/use-case/CloseSessionsUseCase.test.ts"],
4
- "sourcesContent": ["import { type DmkConfig } from \"@api/DmkConfig\";\nimport { type LoggerPublisherService } from \"@api/logger-publisher/service/LoggerPublisherService\";\nimport { deviceSessionStubBuilder } from \"@internal/device-session/model/DeviceSession.stub\";\nimport { DefaultDeviceSessionService } from \"@internal/device-session/service/DefaultDeviceSessionService\";\nimport { type DeviceSessionService } from \"@internal/device-session/service/DeviceSessionService\";\nimport { CloseSessionsUseCase } from \"@internal/device-session/use-case/CloseSessionsUseCase\";\nimport { DefaultLoggerPublisherService } from \"@internal/logger-publisher/service/DefaultLoggerPublisherService\";\nimport { AxiosManagerApiDataSource } from \"@internal/manager-api/data/AxiosManagerApiDataSource\";\nimport { type ManagerApiDataSource } from \"@internal/manager-api/data/ManagerApiDataSource\";\nimport { DefaultManagerApiService } from \"@internal/manager-api/service/DefaultManagerApiService\";\nimport { type ManagerApiService } from \"@internal/manager-api/service/ManagerApiService\";\n\nlet logger: LoggerPublisherService;\nlet managerApiDataSource: ManagerApiDataSource;\nlet managerApi: ManagerApiService;\nlet sessionService: DeviceSessionService;\n\ndescribe(\"CloseSessionsUseCase\", () => {\n beforeEach(() => {\n logger = new DefaultLoggerPublisherService(\n [],\n \"close-sessions-use-case-test\",\n );\n managerApiDataSource = new AxiosManagerApiDataSource({} as DmkConfig);\n managerApi = new DefaultManagerApiService(managerApiDataSource);\n sessionService = new DefaultDeviceSessionService(() => logger);\n });\n\n it(\"should be able to close every session\", () => {\n //given\n const sessions = [...Array(10).keys()].map((id) => {\n const session = deviceSessionStubBuilder(\n { id: id.toString() },\n () => logger,\n managerApi,\n );\n jest.spyOn(session, \"close\");\n return session;\n });\n sessions.forEach((session) => sessionService.addDeviceSession(session));\n const useCase = new CloseSessionsUseCase(sessionService);\n //when\n useCase.execute();\n //then\n sessions.forEach((session) => {\n expect(session.close).toHaveBeenCalled();\n });\n });\n});\n"],
5
- "mappings": "aAEA,IAAAA,EAAyC,6DACzCC,EAA4C,wEAE5CC,EAAqC,kEACrCC,EAA8C,4EAC9CC,EAA0C,gEAE1CC,EAAyC,kEAGzC,IAAIC,EACAC,EACAC,EACAC,EAEJ,SAAS,uBAAwB,IAAM,CACrC,WAAW,IAAM,CACfH,EAAS,IAAI,gCACX,CAAC,EACD,8BACF,EACAC,EAAuB,IAAI,4BAA0B,CAAC,CAAc,EACpEC,EAAa,IAAI,2BAAyBD,CAAoB,EAC9DE,EAAiB,IAAI,8BAA4B,IAAMH,CAAM,CAC/D,CAAC,EAED,GAAG,wCAAyC,IAAM,CAEhD,MAAMI,EAAW,CAAC,GAAG,MAAM,EAAE,EAAE,KAAK,CAAC,EAAE,IAAKC,GAAO,CACjD,MAAMC,KAAU,4BACd,CAAE,GAAID,EAAG,SAAS,CAAE,EACpB,IAAML,EACNE,CACF,EACA,YAAK,MAAMI,EAAS,OAAO,EACpBA,CACT,CAAC,EACDF,EAAS,QAASE,GAAYH,EAAe,iBAAiBG,CAAO,CAAC,EACtD,IAAI,uBAAqBH,CAAc,EAE/C,QAAQ,EAEhBC,EAAS,QAASE,GAAY,CAC5B,OAAOA,EAAQ,KAAK,EAAE,iBAAiB,CACzC,CAAC,CACH,CAAC,CACH,CAAC",
6
- "names": ["import_DeviceSession", "import_DefaultDeviceSessionService", "import_CloseSessionsUseCase", "import_DefaultLoggerPublisherService", "import_AxiosManagerApiDataSource", "import_DefaultManagerApiService", "logger", "managerApiDataSource", "managerApi", "sessionService", "sessions", "id", "session"]
4
+ "sourcesContent": ["import { type DmkConfig } from \"@api/DmkConfig\";\nimport { type LoggerPublisherService } from \"@api/logger-publisher/service/LoggerPublisherService\";\nimport { deviceSessionStubBuilder } from \"@internal/device-session/model/DeviceSession.stub\";\nimport { DefaultDeviceSessionService } from \"@internal/device-session/service/DefaultDeviceSessionService\";\nimport { type DeviceSessionService } from \"@internal/device-session/service/DeviceSessionService\";\nimport { CloseSessionsUseCase } from \"@internal/device-session/use-case/CloseSessionsUseCase\";\nimport { DefaultLoggerPublisherService } from \"@internal/logger-publisher/service/DefaultLoggerPublisherService\";\nimport { AxiosManagerApiDataSource } from \"@internal/manager-api/data/AxiosManagerApiDataSource\";\nimport { type ManagerApiDataSource } from \"@internal/manager-api/data/ManagerApiDataSource\";\nimport { DefaultManagerApiService } from \"@internal/manager-api/service/DefaultManagerApiService\";\nimport { type ManagerApiService } from \"@internal/manager-api/service/ManagerApiService\";\nimport { DefaultSecureChannelDataSource } from \"@internal/secure-channel/data/DefaultSecureChannelDataSource\";\nimport { type SecureChannelDataSource } from \"@internal/secure-channel/data/SecureChannelDataSource\";\nimport { DefaultSecureChannelService } from \"@internal/secure-channel/service/DefaultSecureChannelService\";\nimport { type SecureChannelService } from \"@internal/secure-channel/service/SecureChannelService\";\n\nlet logger: LoggerPublisherService;\nlet managerApiDataSource: ManagerApiDataSource;\nlet managerApi: ManagerApiService;\nlet secureChannelDataSource: SecureChannelDataSource;\nlet secureChannel: SecureChannelService;\nlet sessionService: DeviceSessionService;\n\ndescribe(\"CloseSessionsUseCase\", () => {\n beforeEach(() => {\n logger = new DefaultLoggerPublisherService(\n [],\n \"close-sessions-use-case-test\",\n );\n managerApiDataSource = new AxiosManagerApiDataSource({} as DmkConfig);\n managerApi = new DefaultManagerApiService(managerApiDataSource);\n secureChannelDataSource = new DefaultSecureChannelDataSource(\n {} as DmkConfig,\n );\n secureChannel = new DefaultSecureChannelService(secureChannelDataSource);\n sessionService = new DefaultDeviceSessionService(() => logger);\n });\n\n it(\"should be able to close every session\", () => {\n //given\n const sessions = [...Array(10).keys()].map((id) => {\n const session = deviceSessionStubBuilder(\n { id: id.toString() },\n () => logger,\n managerApi,\n secureChannel,\n );\n vi.spyOn(session, \"close\");\n return session;\n });\n sessions.forEach((session) => sessionService.addDeviceSession(session));\n const useCase = new CloseSessionsUseCase(sessionService);\n //when\n useCase.execute();\n //then\n sessions.forEach((session) => {\n expect(session.close).toHaveBeenCalled();\n });\n });\n});\n"],
5
+ "mappings": "aAEA,IAAAA,EAAyC,6DACzCC,EAA4C,wEAE5CC,EAAqC,kEACrCC,EAA8C,4EAC9CC,EAA0C,gEAE1CC,EAAyC,kEAEzCC,EAA+C,wEAE/CC,EAA4C,wEAG5C,IAAIC,EACAC,EACAC,EACAC,EACAC,EACAC,EAEJ,SAAS,uBAAwB,IAAM,CACrC,WAAW,IAAM,CACfL,EAAS,IAAI,gCACX,CAAC,EACD,8BACF,EACAC,EAAuB,IAAI,4BAA0B,CAAC,CAAc,EACpEC,EAAa,IAAI,2BAAyBD,CAAoB,EAC9DE,EAA0B,IAAI,iCAC5B,CAAC,CACH,EACAC,EAAgB,IAAI,8BAA4BD,CAAuB,EACvEE,EAAiB,IAAI,8BAA4B,IAAML,CAAM,CAC/D,CAAC,EAED,GAAG,wCAAyC,IAAM,CAEhD,MAAMM,EAAW,CAAC,GAAG,MAAM,EAAE,EAAE,KAAK,CAAC,EAAE,IAAKC,GAAO,CACjD,MAAMC,KAAU,4BACd,CAAE,GAAID,EAAG,SAAS,CAAE,EACpB,IAAMP,EACNE,EACAE,CACF,EACA,UAAG,MAAMI,EAAS,OAAO,EAClBA,CACT,CAAC,EACDF,EAAS,QAASE,GAAYH,EAAe,iBAAiBG,CAAO,CAAC,EACtD,IAAI,uBAAqBH,CAAc,EAE/C,QAAQ,EAEhBC,EAAS,QAASE,GAAY,CAC5B,OAAOA,EAAQ,KAAK,EAAE,iBAAiB,CACzC,CAAC,CACH,CAAC,CACH,CAAC",
6
+ "names": ["import_DeviceSession", "import_DefaultDeviceSessionService", "import_CloseSessionsUseCase", "import_DefaultLoggerPublisherService", "import_AxiosManagerApiDataSource", "import_DefaultManagerApiService", "import_DefaultSecureChannelDataSource", "import_DefaultSecureChannelService", "logger", "managerApiDataSource", "managerApi", "secureChannelDataSource", "secureChannel", "sessionService", "sessions", "id", "session"]
7
7
  }
@@ -1,2 +1,2 @@
1
- "use strict";var S=require("../../device-session/model/DeviceSession.stub"),m=require("../../device-session/model/Errors"),p=require("../../device-session/service/DefaultDeviceSessionService"),u=require("../../logger-publisher/service/DefaultLoggerPublisherService"),v=require("../../manager-api/data/AxiosManagerApiDataSource"),d=require("../../manager-api/service/DefaultManagerApiService"),t=require("./GetDeviceSessionStateUseCase");jest.mock("@internal/manager-api/data/AxiosManagerApiDataSource");let i,o,c,n;const s="fakeSessionId";describe("GetDeviceSessionStateUseCase",()=>{beforeEach(()=>{i=new u.DefaultLoggerPublisherService([],"get-connected-device-use-case-test"),c=new v.AxiosManagerApiDataSource({}),n=new d.DefaultManagerApiService(c),o=new p.DefaultDeviceSessionService(()=>i)}),it("should retrieve deviceSession device state",()=>{const e=(0,S.deviceSessionStubBuilder)({id:s},()=>i,n);o.addDeviceSession(e);const r=new t.GetDeviceSessionStateUseCase(o,()=>i).execute({sessionId:s}),f=e.state;e.close(),expect(r).toStrictEqual(f)}),it("should throw error when deviceSession is not found",e=>{const a=new t.GetDeviceSessionStateUseCase(o,()=>i);try{a.execute({sessionId:s}).subscribe()}catch(r){expect(r).toBeInstanceOf(m.DeviceSessionNotFound),e()}})});
1
+ "use strict";var u=require("../../device-session/model/DeviceSession.stub"),p=require("../../device-session/model/Errors"),f=require("../../device-session/service/DefaultDeviceSessionService"),l=require("../../logger-publisher/service/DefaultLoggerPublisherService"),v=require("../../manager-api/data/AxiosManagerApiDataSource"),D=require("../../manager-api/service/DefaultManagerApiService"),d=require("../../secure-channel/data/DefaultSecureChannelDataSource"),g=require("../../secure-channel/service/DefaultSecureChannelService"),s=require("./GetDeviceSessionStateUseCase");vi.mock("@internal/manager-api/data/AxiosManagerApiDataSource");let r,i,n,c,S,m;const t="fakeSessionId";describe("GetDeviceSessionStateUseCase",()=>{beforeEach(()=>{r=new l.DefaultLoggerPublisherService([],"get-connected-device-use-case-test"),n=new v.AxiosManagerApiDataSource({}),c=new D.DefaultManagerApiService(n),S=new d.DefaultSecureChannelDataSource({}),m=new g.DefaultSecureChannelService(S),i=new f.DefaultDeviceSessionService(()=>r)}),it("should retrieve deviceSession device state",()=>{const e=(0,u.deviceSessionStubBuilder)({id:t},()=>r,c,m);i.addDeviceSession(e);const o=new s.GetDeviceSessionStateUseCase(i,()=>r).execute({sessionId:t}),h=e.state;e.close(),expect(o).toStrictEqual(h)}),it("should throw error when deviceSession is not found",()=>new Promise(e=>{const a=new s.GetDeviceSessionStateUseCase(i,()=>r);try{a.execute({sessionId:t}).subscribe()}catch(o){expect(o).toBeInstanceOf(p.DeviceSessionNotFound),e()}}))});
2
2
  //# sourceMappingURL=GetDeviceSessionStateUseCase.test.js.map