@ledgerhq/device-management-kit 1.7.0 → 1.8.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (198) hide show
  1. package/README.md +0 -3
  2. package/lib/cjs/package.json +1 -1
  3. package/lib/cjs/src/api/device-action/__test-utils__/setupTestMachine.js +1 -1
  4. package/lib/cjs/src/api/device-action/__test-utils__/setupTestMachine.js.map +3 -3
  5. package/lib/cjs/src/api/device-action/model/UserInteractionRequired.js +1 -1
  6. package/lib/cjs/src/api/device-action/model/UserInteractionRequired.js.map +2 -2
  7. package/lib/cjs/src/api/device-action/os/GetDeviceStatus/GetDeviceStatusDeviceAction.js +1 -1
  8. package/lib/cjs/src/api/device-action/os/GetDeviceStatus/GetDeviceStatusDeviceAction.js.map +3 -3
  9. package/lib/cjs/src/api/device-action/os/GetDeviceStatus/GetDeviceStatusDeviceAction.test.js +1 -1
  10. package/lib/cjs/src/api/device-action/os/GetDeviceStatus/GetDeviceStatusDeviceAction.test.js.map +3 -3
  11. package/lib/cjs/src/api/device-action/os/GetDeviceStatus/types.js +1 -1
  12. package/lib/cjs/src/api/device-action/os/GetDeviceStatus/types.js.map +2 -2
  13. package/lib/cjs/src/api/device-action/os/InstallLanguagePackage/types.js +1 -1
  14. package/lib/cjs/src/api/device-action/os/InstallLanguagePackage/types.js.map +3 -3
  15. package/lib/cjs/src/api/device-action/os/OpenAppDeviceAction/OpenAppDeviceAction.js +1 -1
  16. package/lib/cjs/src/api/device-action/os/OpenAppDeviceAction/OpenAppDeviceAction.js.map +2 -2
  17. package/lib/cjs/src/api/device-action/os/OpenAppDeviceAction/OpenAppDeviceAction.test.js +1 -1
  18. package/lib/cjs/src/api/device-action/os/OpenAppDeviceAction/OpenAppDeviceAction.test.js.map +2 -2
  19. package/lib/cjs/src/api/device-action/os/OpenAppDeviceAction/types.js +1 -1
  20. package/lib/cjs/src/api/device-action/os/OpenAppDeviceAction/types.js.map +1 -1
  21. package/lib/cjs/src/api/device-action/os/OpenAppWithDependencies/types.js.map +1 -1
  22. package/lib/cjs/src/api/device-action/task/GetFirmwareMetadataTask.js +1 -1
  23. package/lib/cjs/src/api/device-action/task/GetFirmwareMetadataTask.js.map +3 -3
  24. package/lib/cjs/src/api/device-action/task/GetFirmwareMetadataTask.test.js +1 -1
  25. package/lib/cjs/src/api/device-action/task/GetFirmwareMetadataTask.test.js.map +3 -3
  26. package/lib/cjs/src/api/index.js +1 -1
  27. package/lib/cjs/src/api/index.js.map +3 -3
  28. package/lib/cjs/src/api/types.js +1 -1
  29. package/lib/cjs/src/api/types.js.map +3 -3
  30. package/lib/cjs/src/api/utils/apduLogs.js +1 -1
  31. package/lib/cjs/src/api/utils/apduLogs.js.map +3 -3
  32. package/lib/cjs/src/api/utils/apduLogs.test.js +1 -1
  33. package/lib/cjs/src/api/utils/apduLogs.test.js.map +3 -3
  34. package/lib/cjs/src/internal/device-session/model/DeviceSession.js +1 -1
  35. package/lib/cjs/src/internal/device-session/model/DeviceSession.js.map +3 -3
  36. package/lib/cjs/src/internal/device-session/model/DeviceSessionRefresher.js +1 -1
  37. package/lib/cjs/src/internal/device-session/model/DeviceSessionRefresher.js.map +2 -2
  38. package/lib/cjs/src/internal/device-session/model/DeviceSessionRefresher.test.js +1 -1
  39. package/lib/cjs/src/internal/device-session/model/DeviceSessionRefresher.test.js.map +2 -2
  40. package/lib/cjs/src/internal/manager-api/data/HttpManagerApiDataSource.js +1 -1
  41. package/lib/cjs/src/internal/manager-api/data/HttpManagerApiDataSource.js.map +2 -2
  42. package/lib/cjs/src/internal/manager-api/data/HttpManagerApiDataSource.test.js +1 -1
  43. package/lib/cjs/src/internal/manager-api/data/HttpManagerApiDataSource.test.js.map +2 -2
  44. package/lib/cjs/src/internal/manager-api/data/ManagerApiDataSource.js +1 -1
  45. package/lib/cjs/src/internal/manager-api/data/ManagerApiDataSource.js.map +1 -1
  46. package/lib/cjs/src/internal/manager-api/model/Const.js +1 -1
  47. package/lib/cjs/src/internal/manager-api/model/Const.js.map +1 -1
  48. package/lib/cjs/src/internal/manager-api/model/Firmware.js +1 -1
  49. package/lib/cjs/src/internal/manager-api/model/Firmware.js.map +1 -1
  50. package/lib/cjs/src/internal/manager-api/service/DefaultManagerApiService.js +1 -1
  51. package/lib/cjs/src/internal/manager-api/service/DefaultManagerApiService.js.map +2 -2
  52. package/lib/cjs/src/internal/manager-api/service/DefaultManagerApiService.test.js +1 -1
  53. package/lib/cjs/src/internal/manager-api/service/DefaultManagerApiService.test.js.map +3 -3
  54. package/lib/cjs/src/internal/manager-api/service/ManagerApiService.js +1 -1
  55. package/lib/cjs/src/internal/manager-api/service/ManagerApiService.js.map +1 -1
  56. package/lib/cjs/src/internal/secure-channel/model/Errors.js +1 -1
  57. package/lib/cjs/src/internal/secure-channel/model/Errors.js.map +2 -2
  58. package/lib/cjs/src/internal/secure-channel/service/DefaultSecureChannelService.js +1 -1
  59. package/lib/cjs/src/internal/secure-channel/service/DefaultSecureChannelService.js.map +3 -3
  60. package/lib/cjs/src/internal/secure-channel/service/SecureChannelService.js +1 -1
  61. package/lib/cjs/src/internal/secure-channel/service/SecureChannelService.js.map +1 -1
  62. package/lib/esm/package.json +1 -1
  63. package/lib/esm/src/api/device-action/__test-utils__/setupTestMachine.js +1 -1
  64. package/lib/esm/src/api/device-action/__test-utils__/setupTestMachine.js.map +3 -3
  65. package/lib/esm/src/api/device-action/model/UserInteractionRequired.js +1 -1
  66. package/lib/esm/src/api/device-action/model/UserInteractionRequired.js.map +2 -2
  67. package/lib/esm/src/api/device-action/os/GetDeviceStatus/GetDeviceStatusDeviceAction.js +1 -1
  68. package/lib/esm/src/api/device-action/os/GetDeviceStatus/GetDeviceStatusDeviceAction.js.map +3 -3
  69. package/lib/esm/src/api/device-action/os/GetDeviceStatus/GetDeviceStatusDeviceAction.test.js +1 -1
  70. package/lib/esm/src/api/device-action/os/GetDeviceStatus/GetDeviceStatusDeviceAction.test.js.map +3 -3
  71. package/lib/esm/src/api/device-action/os/GetDeviceStatus/types.js +1 -1
  72. package/lib/esm/src/api/device-action/os/GetDeviceStatus/types.js.map +2 -2
  73. package/lib/esm/src/api/device-action/os/InstallLanguagePackage/types.js +1 -1
  74. package/lib/esm/src/api/device-action/os/InstallLanguagePackage/types.js.map +3 -3
  75. package/lib/esm/src/api/device-action/os/OpenAppDeviceAction/OpenAppDeviceAction.js +1 -1
  76. package/lib/esm/src/api/device-action/os/OpenAppDeviceAction/OpenAppDeviceAction.js.map +2 -2
  77. package/lib/esm/src/api/device-action/os/OpenAppDeviceAction/OpenAppDeviceAction.test.js +1 -1
  78. package/lib/esm/src/api/device-action/os/OpenAppDeviceAction/OpenAppDeviceAction.test.js.map +2 -2
  79. package/lib/esm/src/api/device-action/os/OpenAppDeviceAction/types.js.map +1 -1
  80. package/lib/esm/src/api/device-action/os/OpenAppWithDependencies/types.js.map +1 -1
  81. package/lib/esm/src/api/device-action/task/GetFirmwareMetadataTask.js +1 -1
  82. package/lib/esm/src/api/device-action/task/GetFirmwareMetadataTask.js.map +3 -3
  83. package/lib/esm/src/api/device-action/task/GetFirmwareMetadataTask.test.js +1 -1
  84. package/lib/esm/src/api/device-action/task/GetFirmwareMetadataTask.test.js.map +3 -3
  85. package/lib/esm/src/api/index.js +1 -1
  86. package/lib/esm/src/api/index.js.map +3 -3
  87. package/lib/esm/src/api/types.js +1 -0
  88. package/lib/esm/src/api/types.js.map +4 -4
  89. package/lib/esm/src/api/utils/apduLogs.js +1 -1
  90. package/lib/esm/src/api/utils/apduLogs.js.map +3 -3
  91. package/lib/esm/src/api/utils/apduLogs.test.js +1 -1
  92. package/lib/esm/src/api/utils/apduLogs.test.js.map +3 -3
  93. package/lib/esm/src/internal/device-session/model/DeviceSession.js +1 -1
  94. package/lib/esm/src/internal/device-session/model/DeviceSession.js.map +3 -3
  95. package/lib/esm/src/internal/device-session/model/DeviceSessionRefresher.js +1 -1
  96. package/lib/esm/src/internal/device-session/model/DeviceSessionRefresher.js.map +2 -2
  97. package/lib/esm/src/internal/device-session/model/DeviceSessionRefresher.test.js +1 -1
  98. package/lib/esm/src/internal/device-session/model/DeviceSessionRefresher.test.js.map +2 -2
  99. package/lib/esm/src/internal/manager-api/data/HttpManagerApiDataSource.js +1 -1
  100. package/lib/esm/src/internal/manager-api/data/HttpManagerApiDataSource.js.map +3 -3
  101. package/lib/esm/src/internal/manager-api/data/HttpManagerApiDataSource.test.js +1 -1
  102. package/lib/esm/src/internal/manager-api/data/HttpManagerApiDataSource.test.js.map +3 -3
  103. package/lib/esm/src/internal/manager-api/model/Const.js +1 -1
  104. package/lib/esm/src/internal/manager-api/model/Const.js.map +1 -1
  105. package/lib/esm/src/internal/manager-api/service/DefaultManagerApiService.js +1 -1
  106. package/lib/esm/src/internal/manager-api/service/DefaultManagerApiService.js.map +2 -2
  107. package/lib/esm/src/internal/manager-api/service/DefaultManagerApiService.test.js +1 -1
  108. package/lib/esm/src/internal/manager-api/service/DefaultManagerApiService.test.js.map +3 -3
  109. package/lib/esm/src/internal/secure-channel/model/Errors.js +1 -1
  110. package/lib/esm/src/internal/secure-channel/model/Errors.js.map +3 -3
  111. package/lib/esm/src/internal/secure-channel/service/DefaultSecureChannelService.js +1 -1
  112. package/lib/esm/src/internal/secure-channel/service/DefaultSecureChannelService.js.map +3 -3
  113. package/lib/types/src/api/device-action/__test-utils__/setupTestMachine.d.ts +3 -0
  114. package/lib/types/src/api/device-action/__test-utils__/setupTestMachine.d.ts.map +1 -1
  115. package/lib/types/src/api/device-action/model/UserInteractionRequired.d.ts +3 -1
  116. package/lib/types/src/api/device-action/model/UserInteractionRequired.d.ts.map +1 -1
  117. package/lib/types/src/api/device-action/os/GetDeviceStatus/GetDeviceStatusDeviceAction.d.ts +0 -9
  118. package/lib/types/src/api/device-action/os/GetDeviceStatus/GetDeviceStatusDeviceAction.d.ts.map +1 -1
  119. package/lib/types/src/api/device-action/os/GetDeviceStatus/types.d.ts +5 -4
  120. package/lib/types/src/api/device-action/os/GetDeviceStatus/types.d.ts.map +1 -1
  121. package/lib/types/src/api/device-action/os/InstallLanguagePackage/types.d.ts +1 -0
  122. package/lib/types/src/api/device-action/os/InstallLanguagePackage/types.d.ts.map +1 -1
  123. package/lib/types/src/api/device-action/os/OpenAppDeviceAction/OpenAppDeviceAction.d.ts.map +1 -1
  124. package/lib/types/src/api/device-action/os/OpenAppDeviceAction/types.d.ts +1 -1
  125. package/lib/types/src/api/device-action/os/OpenAppDeviceAction/types.d.ts.map +1 -1
  126. package/lib/types/src/api/device-action/os/OpenAppWithDependencies/types.d.ts +1 -1
  127. package/lib/types/src/api/device-action/os/OpenAppWithDependencies/types.d.ts.map +1 -1
  128. package/lib/types/src/api/device-action/task/GetFirmwareMetadataTask.d.ts +2 -0
  129. package/lib/types/src/api/device-action/task/GetFirmwareMetadataTask.d.ts.map +1 -1
  130. package/lib/types/src/api/index.d.ts +3 -4
  131. package/lib/types/src/api/index.d.ts.map +1 -1
  132. package/lib/types/src/api/types.d.ts +1 -1
  133. package/lib/types/src/api/types.d.ts.map +1 -1
  134. package/lib/types/src/api/utils/apduLogs.d.ts +15 -0
  135. package/lib/types/src/api/utils/apduLogs.d.ts.map +1 -1
  136. package/lib/types/src/internal/device-session/model/DeviceSession.d.ts.map +1 -1
  137. package/lib/types/src/internal/device-session/model/DeviceSessionRefresher.d.ts.map +1 -1
  138. package/lib/types/src/internal/manager-api/data/HttpManagerApiDataSource.d.ts +2 -2
  139. package/lib/types/src/internal/manager-api/data/HttpManagerApiDataSource.d.ts.map +1 -1
  140. package/lib/types/src/internal/manager-api/data/ManagerApiDataSource.d.ts +4 -4
  141. package/lib/types/src/internal/manager-api/data/ManagerApiDataSource.d.ts.map +1 -1
  142. package/lib/types/src/internal/manager-api/model/Const.d.ts +1 -1
  143. package/lib/types/src/internal/manager-api/model/Firmware.d.ts +3 -0
  144. package/lib/types/src/internal/manager-api/model/Firmware.d.ts.map +1 -1
  145. package/lib/types/src/internal/manager-api/service/DefaultManagerApiService.d.ts +2 -1
  146. package/lib/types/src/internal/manager-api/service/DefaultManagerApiService.d.ts.map +1 -1
  147. package/lib/types/src/internal/manager-api/service/ManagerApiService.d.ts +9 -3
  148. package/lib/types/src/internal/manager-api/service/ManagerApiService.d.ts.map +1 -1
  149. package/lib/types/src/internal/secure-channel/model/Errors.d.ts +8 -1
  150. package/lib/types/src/internal/secure-channel/model/Errors.d.ts.map +1 -1
  151. package/lib/types/src/internal/secure-channel/service/DefaultSecureChannelService.d.ts +1 -1
  152. package/lib/types/src/internal/secure-channel/service/DefaultSecureChannelService.d.ts.map +1 -1
  153. package/lib/types/src/internal/secure-channel/service/SecureChannelService.d.ts +2 -2
  154. package/lib/types/src/internal/secure-channel/service/SecureChannelService.d.ts.map +1 -1
  155. package/lib/types/tsconfig.prod.tsbuildinfo +1 -1
  156. package/package.json +4 -4
  157. package/lib/cjs/src/api/command/os/BackupStorageCommand.js +0 -2
  158. package/lib/cjs/src/api/command/os/BackupStorageCommand.js.map +0 -7
  159. package/lib/cjs/src/api/command/os/BackupStorageCommand.test.js +0 -2
  160. package/lib/cjs/src/api/command/os/BackupStorageCommand.test.js.map +0 -7
  161. package/lib/cjs/src/api/command/os/GetAppStorageInfoCommand.js +0 -2
  162. package/lib/cjs/src/api/command/os/GetAppStorageInfoCommand.js.map +0 -7
  163. package/lib/cjs/src/api/command/os/GetAppStorageInfoCommand.test.js +0 -2
  164. package/lib/cjs/src/api/command/os/GetAppStorageInfoCommand.test.js.map +0 -7
  165. package/lib/cjs/src/api/device-action/task/BackupAppStorageTask.js +0 -2
  166. package/lib/cjs/src/api/device-action/task/BackupAppStorageTask.js.map +0 -7
  167. package/lib/cjs/src/api/device-action/task/BackupAppStorageTask.test.js +0 -2
  168. package/lib/cjs/src/api/device-action/task/BackupAppStorageTask.test.js.map +0 -7
  169. package/lib/cjs/src/api/storage/KeyValueStorage.js +0 -2
  170. package/lib/cjs/src/api/storage/KeyValueStorage.js.map +0 -7
  171. package/lib/esm/src/api/command/os/BackupStorageCommand.js +0 -2
  172. package/lib/esm/src/api/command/os/BackupStorageCommand.js.map +0 -7
  173. package/lib/esm/src/api/command/os/BackupStorageCommand.test.js +0 -2
  174. package/lib/esm/src/api/command/os/BackupStorageCommand.test.js.map +0 -7
  175. package/lib/esm/src/api/command/os/GetAppStorageInfoCommand.js +0 -2
  176. package/lib/esm/src/api/command/os/GetAppStorageInfoCommand.js.map +0 -7
  177. package/lib/esm/src/api/command/os/GetAppStorageInfoCommand.test.js +0 -2
  178. package/lib/esm/src/api/command/os/GetAppStorageInfoCommand.test.js.map +0 -7
  179. package/lib/esm/src/api/device-action/task/BackupAppStorageTask.js +0 -2
  180. package/lib/esm/src/api/device-action/task/BackupAppStorageTask.js.map +0 -7
  181. package/lib/esm/src/api/device-action/task/BackupAppStorageTask.test.js +0 -2
  182. package/lib/esm/src/api/device-action/task/BackupAppStorageTask.test.js.map +0 -7
  183. package/lib/esm/src/api/storage/KeyValueStorage.js +0 -2
  184. package/lib/esm/src/api/storage/KeyValueStorage.js.map +0 -7
  185. package/lib/types/src/api/command/os/BackupStorageCommand.d.ts +0 -23
  186. package/lib/types/src/api/command/os/BackupStorageCommand.d.ts.map +0 -1
  187. package/lib/types/src/api/command/os/BackupStorageCommand.test.d.ts +0 -2
  188. package/lib/types/src/api/command/os/BackupStorageCommand.test.d.ts.map +0 -1
  189. package/lib/types/src/api/command/os/GetAppStorageInfoCommand.d.ts +0 -31
  190. package/lib/types/src/api/command/os/GetAppStorageInfoCommand.d.ts.map +0 -1
  191. package/lib/types/src/api/command/os/GetAppStorageInfoCommand.test.d.ts +0 -2
  192. package/lib/types/src/api/command/os/GetAppStorageInfoCommand.test.d.ts.map +0 -1
  193. package/lib/types/src/api/device-action/task/BackupAppStorageTask.d.ts +0 -23
  194. package/lib/types/src/api/device-action/task/BackupAppStorageTask.d.ts.map +0 -1
  195. package/lib/types/src/api/device-action/task/BackupAppStorageTask.test.d.ts +0 -2
  196. package/lib/types/src/api/device-action/task/BackupAppStorageTask.test.d.ts.map +0 -1
  197. package/lib/types/src/api/storage/KeyValueStorage.d.ts +0 -7
  198. package/lib/types/src/api/storage/KeyValueStorage.d.ts.map +0 -1
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../src/api/index.ts"],
4
- "sourcesContent": ["\"use strict\";\n\nexport { Apdu } from \"@api/apdu/model/Apdu\";\nexport { APDU_MAX_PAYLOAD, ApduBuilder } from \"@api/apdu/utils/ApduBuilder\";\nexport { ApduParser } from \"@api/apdu/utils/ApduParser\";\nexport * from \"@api/apdu/utils/AppBuilderError\";\nexport { ByteArrayBuilder } from \"@api/apdu/utils/ByteArrayBuilder\";\nexport { ByteArrayParser } from \"@api/apdu/utils/ByteArrayParser\";\nexport { type Command } from \"@api/command/Command\";\nexport {\n InvalidResponseFormatError,\n InvalidStatusWordError,\n} from \"@api/command/Errors\";\nexport {\n CommandResultFactory,\n CommandResultStatus,\n isSuccessCommandResult,\n} from \"@api/command/model/CommandResult\";\nexport {\n BackupStorageCommand,\n type BackupStorageCommandErrorCodes,\n type BackupStorageCommandResponse,\n type BackupStorageCommandResult,\n} from \"@api/command/os/BackupStorageCommand\";\nexport { CloseAppCommand } from \"@api/command/os/CloseAppCommand\";\nexport {\n DeleteLanguagePackCommand,\n type DeleteLanguagePackCommandArgs,\n DeleteLanguagePackCommandError,\n type DeleteLanguagePackCommandResult,\n type DeleteLanguagePackErrorCodes,\n} from \"@api/command/os/DeleteLanguagePackCommand\";\nexport {\n GetAppAndVersionCommand,\n type GetAppAndVersionResponse,\n} from \"@api/command/os/GetAppAndVersionCommand\";\nexport {\n GetAppStorageInfoCommand,\n type GetAppStorageInfoCommandArgs,\n type GetAppStorageInfoCommandErrorCodes,\n type GetAppStorageInfoCommandResponse,\n type GetAppStorageInfoCommandResult,\n} from \"@api/command/os/GetAppStorageInfoCommand\";\nexport {\n GetBackgroundImageSizeCommand,\n GetBackgroundImageSizeCommandError,\n type GetBackgroundImageSizeCommandResult,\n type GetBackgroundImageSizeErrorCodes,\n type GetBackgroundImageSizeResponse,\n} from \"@api/command/os/GetBackgroundImageSizeCommand\";\nexport {\n BatteryStatusType,\n type GetBatteryStatusArgs,\n GetBatteryStatusCommand,\n type GetBatteryStatusResponse,\n} from \"@api/command/os/GetBatteryStatusCommand\";\nexport {\n GetOsVersionCommand,\n type GetOsVersionResponse,\n} from \"@api/command/os/GetOsVersionCommand\";\nexport {\n type ListAppsArgs,\n ListAppsCommand,\n type ListAppsErrorCodes,\n type ListAppsResponse,\n} from \"@api/command/os/ListAppsCommand\";\nexport {\n ListLanguagePackCommand,\n type ListLanguagePackCommandArgs,\n ListLanguagePackCommandError,\n type ListLanguagePackCommandResult,\n type ListLanguagePackErrorCodes,\n type ListLanguagePackResponse,\n} from \"@api/command/os/ListLanguagePackCommand\";\nexport {\n type LoadCertificateArgs,\n LoadCertificateCommand,\n type LoadCertificateErrorCodes,\n} from \"@api/command/os/LoadCertificateCommand\";\nexport {\n type OpenAppArgs,\n OpenAppCommand,\n} from \"@api/command/os/OpenAppCommand\";\nexport { isCommandErrorCode } from \"@api/command/utils/CommandErrors\";\nexport { CommandUtils } from \"@api/command/utils/CommandUtils\";\nexport {\n GLOBAL_ERRORS,\n GlobalCommandError,\n GlobalCommandErrorHandler,\n} from \"@api/command/utils/GlobalCommandError\";\nexport {\n DeviceModel,\n DeviceModelId,\n LEDGER_VENDOR_ID,\n} from \"@api/device/DeviceModel\";\nexport { DeviceStatus } from \"@api/device/DeviceStatus\";\nexport { type InternalApi } from \"@api/device-action/DeviceAction\";\nexport {\n type DeviceActionState,\n DeviceActionStatus,\n} from \"@api/device-action/model/DeviceActionState\";\nexport { UserInteractionRequired } from \"@api/device-action/model/UserInteractionRequired\";\nexport { CallTaskInAppDeviceAction } from \"@api/device-action/os/CallTaskInAppDeviceAction/CallTaskInAppDeviceAction\";\nexport { DEFAULT_UNLOCK_TIMEOUT_MS } from \"@api/device-action/os/Const\";\nexport {\n AppAlreadyInstalledDAError,\n DeleteLanguagePackDAError,\n DeviceLockedError,\n DeviceNotOnboardedError,\n OutOfMemoryDAError,\n RefusedByUserDAError,\n UnknownDAError,\n UnsupportedFirmwareDAError,\n} from \"@api/device-action/os/Errors\";\nexport { GetDeviceMetadataDeviceAction } from \"@api/device-action/os/GetDeviceMetadata/GetDeviceMetadataDeviceAction\";\nexport { GetDeviceStatusDeviceAction } from \"@api/device-action/os/GetDeviceStatus/GetDeviceStatusDeviceAction\";\nexport { GoToDashboardDeviceAction } from \"@api/device-action/os/GoToDashboard/GoToDashboardDeviceAction\";\nexport type {\n GoToDashboardDAError,\n GoToDashboardDAInput,\n GoToDashboardDAIntermediateValue,\n GoToDashboardDAOutput,\n GoToDashboardDARequiredInteraction,\n GoToDashboardDAState,\n} from \"@api/device-action/os/GoToDashboard/types\";\nexport { InstallLanguagePackageDeviceAction } from \"@api/device-action/os/InstallLanguagePackage/InstallLanguagePackageDeviceAction\";\nexport { InstallOrUpdateAppsDeviceAction } from \"@api/device-action/os/InstallOrUpdateApps/InstallOrUpdateAppsDeviceAction\";\nexport { ListAppsDeviceAction } from \"@api/device-action/os/ListApps/ListAppsDeviceAction\";\nexport { ListAppsWithMetadataDeviceAction } from \"@api/device-action/os/ListAppsWithMetadata/ListAppsWithMetadataDeviceAction\";\nexport { OpenAppDeviceAction } from \"@api/device-action/os/OpenAppDeviceAction/OpenAppDeviceAction\";\nexport { OpenAppWithDependenciesDeviceAction } from \"@api/device-action/os/OpenAppWithDependencies/OpenAppWithDependenciesDeviceAction\";\nexport { SendCommandInAppDeviceAction } from \"@api/device-action/os/SendCommandInAppDeviceAction/SendCommandInAppDeviceAction\";\nexport type {\n WaitForAppAndVersionDAError,\n WaitForAppAndVersionDAInput,\n WaitForAppAndVersionDAIntermediateValue,\n WaitForAppAndVersionDAOutput,\n WaitForAppAndVersionDARequiredInteraction,\n WaitForAppAndVersionDAState,\n} from \"@api/device-action/os/WaitForAppAndVersion/types\";\nexport { WaitForAppAndVersionDeviceAction } from \"@api/device-action/os/WaitForAppAndVersion/WaitForAppAndVersionDeviceAction\";\nexport { BackupAppStorageTask } from \"@api/device-action/task/BackupAppStorageTask\";\nexport {\n GetApplicationsMetadataTaskError,\n InvalidGetFirmwareMetadataResponseError,\n} from \"@api/device-action/task/Errors\";\nexport {\n type DeviceActionStateMachine,\n XStateDeviceAction,\n} from \"@api/device-action/xstate-utils/XStateDeviceAction\";\nexport { StaticDeviceModelDataSource } from \"@api/device-model/data/StaticDeviceModelDataSource\";\nexport { BleDeviceInfos } from \"@api/device-model/model/BleDeviceInfos\";\nexport { TransportDeviceModel } from \"@api/device-model/model/DeviceModel\";\nexport { ApduResponse } from \"@api/device-session/ApduResponse\";\nexport * from \"@api/device-session/data/FramerConst\";\nexport {\n type DeviceSessionState,\n DeviceSessionStateType,\n} from \"@api/device-session/DeviceSessionState\";\nexport {\n DmkResultFactory,\n DmkResultStatus,\n isSuccessDmkResult,\n} from \"@api/model/DmkResult\";\nexport { GenuineCheckDeviceAction } from \"@api/secure-channel/device-action/GenuineCheck/GenuineCheckDeviceAction\";\nexport { InstallAppDeviceAction } from \"@api/secure-channel/device-action/InstallApp/InstallAppDeviceAction\";\nexport { ListInstalledAppsDeviceAction } from \"@api/secure-channel/device-action/ListInstalledApps/ListInstalledAppsDeviceAction\";\nexport type { InstalledApp } from \"@api/secure-channel/device-action/ListInstalledApps/types\";\nexport { UninstallAppDeviceAction } from \"@api/secure-channel/device-action/UninstallApp/UninstallAppDeviceAction\";\nexport {\n DMK_STORAGE_PREFIX_KEY,\n type KeyValueStorage,\n} from \"@api/storage/KeyValueStorage\";\nexport { SecureChannelError } from \"@internal/secure-channel/model/Errors\";\n// TODO: remove from exported\nexport { defaultApduReceiverServiceStubBuilder } from \"@api/device-session/service/DefaultApduReceiverService.stub\";\nexport { defaultApduSenderServiceStubBuilder } from \"@api/device-session/service/DefaultApduSenderService.stub\";\nexport { FramerUtils } from \"@api/device-session/utils/FramerUtils\";\nexport { DeviceManagementKit } from \"@api/DeviceManagementKit\";\nexport { DeviceManagementKitBuilder } from \"@api/DeviceManagementKitBuilder\";\nexport * from \"@api/Error\";\nexport {\n noopLogger,\n noopLoggerFactory,\n} from \"@api/logger-publisher/utils/noopLoggerFactory\";\nexport { LogLevel } from \"@api/logger-subscriber/model/LogLevel\";\nexport { ConsoleLogger } from \"@api/logger-subscriber/service/ConsoleLogger\";\nexport { DefaultLogTagFormatter } from \"@api/logger-subscriber/service/DefaultLogTagFormatter\";\nexport { type LogTagFormatter } from \"@api/logger-subscriber/service/LogTagFormatter\";\nexport { WebLogsExporterLogger } from \"@api/logger-subscriber/service/WebLogsExporterLogger\";\nexport {\n DmkNetworkClient,\n type DmkNetworkClientOptions,\n type DmkNetworkResponse,\n type DmkQueryParams,\n type DmkQueryParamValue,\n type DmkRequestConfig,\n type DmkResponseType,\n} from \"@api/network/DmkNetworkClient\";\nexport { DmkNetworkClientError } from \"@api/network/DmkNetworkClientError\";\nexport { ConnectedDevice } from \"@api/transport/model/ConnectedDevice\";\nexport {\n DeviceConnectionStateMachine,\n type DeviceConnectionStateMachineParams,\n} from \"@api/transport/model/DeviceConnectionStateMachine\";\nexport * from \"@api/transport/model/Errors\";\nexport { TransportConnectedDevice } from \"@api/transport/model/TransportConnectedDevice\";\nexport { connectedDeviceStubBuilder } from \"@api/transport/model/TransportConnectedDevice.stub\";\nexport * from \"@api/types\";\nexport { formatApduReceivedLog, formatApduSentLog } from \"@api/utils/apduLogs\";\nexport { ApplicationChecker } from \"@api/utils/ApplicationChecker\";\nexport {\n type AppConfig,\n type ApplicationResolver,\n type ResolvedApp,\n} from \"@api/utils/ApplicationResolver\";\nexport {\n base64StringToBuffer,\n bufferToBase64String,\n isBase64String,\n} from \"@api/utils/Base64String\";\nexport {\n bufferToHexaString,\n hexaStringToBuffer,\n isHexaString,\n} from \"@api/utils/HexaString\";\n"],
5
- "mappings": "meAAA,IAAAA,EAAA,GAAAC,GAAAD,EAAA,sjKAAAE,GAAAF,GAEA,IAAAG,EAAqB,gCACrBC,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c,sBAhNd,gBAiNA,IAAAsE,EAAyD,+BACzDC,GAAmC,yCAMnCC,EAIO,mCACPC,EAIO",
6
- "names": ["api_exports", "__export", "__toCommonJS", "import_Apdu", "import_ApduBuilder", "import_ApduParser", "__reExport", "import_ByteArrayBuilder", "import_ByteArrayParser", "import_Errors", "import_CommandResult", "import_BackupStorageCommand", "import_CloseAppCommand", "import_DeleteLanguagePackCommand", "import_GetAppAndVersionCommand", "import_GetAppStorageInfoCommand", "import_GetBackgroundImageSizeCommand", "import_GetBatteryStatusCommand", "import_GetOsVersionCommand", "import_ListAppsCommand", "import_ListLanguagePackCommand", "import_LoadCertificateCommand", "import_OpenAppCommand", "import_CommandErrors", "import_CommandUtils", "import_GlobalCommandError", "import_DeviceModel", "import_DeviceStatus", "import_DeviceActionState", "import_UserInteractionRequired", "import_CallTaskInAppDeviceAction", "import_Const", "import_GetDeviceMetadataDeviceAction", "import_GetDeviceStatusDeviceAction", "import_GoToDashboardDeviceAction", "import_InstallLanguagePackageDeviceAction", "import_InstallOrUpdateAppsDeviceAction", "import_ListAppsDeviceAction", "import_ListAppsWithMetadataDeviceAction", "import_OpenAppDeviceAction", "import_OpenAppWithDependenciesDeviceAction", "import_SendCommandInAppDeviceAction", "import_WaitForAppAndVersionDeviceAction", "import_BackupAppStorageTask", "import_XStateDeviceAction", "import_StaticDeviceModelDataSource", "import_BleDeviceInfos", "import_ApduResponse", "import_DeviceSessionState", "import_DmkResult", "import_GenuineCheckDeviceAction", "import_InstallAppDeviceAction", "import_ListInstalledAppsDeviceAction", "import_UninstallAppDeviceAction", "import_KeyValueStorage", "import_DefaultApduReceiverService", "import_DefaultApduSenderService", "import_FramerUtils", "import_DeviceManagementKit", "import_DeviceManagementKitBuilder", "import_noopLoggerFactory", "import_LogLevel", "import_ConsoleLogger", "import_DefaultLogTagFormatter", "import_WebLogsExporterLogger", "import_DmkNetworkClient", "import_DmkNetworkClientError", "import_ConnectedDevice", "import_DeviceConnectionStateMachine", "import_TransportConnectedDevice", "import_apduLogs", "import_ApplicationChecker", "import_Base64String", "import_HexaString"]
4
+ "sourcesContent": ["\"use strict\";\n\nexport { Apdu } from \"@api/apdu/model/Apdu\";\nexport { APDU_MAX_PAYLOAD, ApduBuilder } from \"@api/apdu/utils/ApduBuilder\";\nexport { ApduParser } from \"@api/apdu/utils/ApduParser\";\nexport * from \"@api/apdu/utils/AppBuilderError\";\nexport { ByteArrayBuilder } from \"@api/apdu/utils/ByteArrayBuilder\";\nexport { ByteArrayParser } from \"@api/apdu/utils/ByteArrayParser\";\nexport { type Command } from \"@api/command/Command\";\nexport {\n InvalidResponseFormatError,\n InvalidStatusWordError,\n} from \"@api/command/Errors\";\nexport {\n CommandResultFactory,\n CommandResultStatus,\n isSuccessCommandResult,\n} from \"@api/command/model/CommandResult\";\nexport { CloseAppCommand } from \"@api/command/os/CloseAppCommand\";\nexport {\n DeleteLanguagePackCommand,\n type DeleteLanguagePackCommandArgs,\n DeleteLanguagePackCommandError,\n type DeleteLanguagePackCommandResult,\n type DeleteLanguagePackErrorCodes,\n} from \"@api/command/os/DeleteLanguagePackCommand\";\nexport {\n GetAppAndVersionCommand,\n type GetAppAndVersionResponse,\n} from \"@api/command/os/GetAppAndVersionCommand\";\nexport {\n GetBackgroundImageSizeCommand,\n GetBackgroundImageSizeCommandError,\n type GetBackgroundImageSizeCommandResult,\n type GetBackgroundImageSizeErrorCodes,\n type GetBackgroundImageSizeResponse,\n} from \"@api/command/os/GetBackgroundImageSizeCommand\";\nexport {\n BatteryStatusType,\n type GetBatteryStatusArgs,\n GetBatteryStatusCommand,\n type GetBatteryStatusResponse,\n} from \"@api/command/os/GetBatteryStatusCommand\";\nexport {\n GetOsVersionCommand,\n type GetOsVersionResponse,\n} from \"@api/command/os/GetOsVersionCommand\";\nexport {\n type ListAppsArgs,\n ListAppsCommand,\n type ListAppsErrorCodes,\n type ListAppsResponse,\n} from \"@api/command/os/ListAppsCommand\";\nexport {\n ListLanguagePackCommand,\n type ListLanguagePackCommandArgs,\n ListLanguagePackCommandError,\n type ListLanguagePackCommandResult,\n type ListLanguagePackErrorCodes,\n type ListLanguagePackResponse,\n} from \"@api/command/os/ListLanguagePackCommand\";\nexport {\n type LoadCertificateArgs,\n LoadCertificateCommand,\n type LoadCertificateErrorCodes,\n} from \"@api/command/os/LoadCertificateCommand\";\nexport {\n type OpenAppArgs,\n OpenAppCommand,\n} from \"@api/command/os/OpenAppCommand\";\nexport { isCommandErrorCode } from \"@api/command/utils/CommandErrors\";\nexport { CommandUtils } from \"@api/command/utils/CommandUtils\";\nexport {\n GLOBAL_ERRORS,\n GlobalCommandError,\n GlobalCommandErrorHandler,\n} from \"@api/command/utils/GlobalCommandError\";\nexport {\n DeviceModel,\n DeviceModelId,\n LEDGER_VENDOR_ID,\n} from \"@api/device/DeviceModel\";\nexport { DeviceStatus } from \"@api/device/DeviceStatus\";\nexport { type InternalApi } from \"@api/device-action/DeviceAction\";\nexport {\n type DeviceActionState,\n DeviceActionStatus,\n} from \"@api/device-action/model/DeviceActionState\";\nexport { UserInteractionRequired } from \"@api/device-action/model/UserInteractionRequired\";\nexport { CallTaskInAppDeviceAction } from \"@api/device-action/os/CallTaskInAppDeviceAction/CallTaskInAppDeviceAction\";\nexport { DEFAULT_UNLOCK_TIMEOUT_MS } from \"@api/device-action/os/Const\";\nexport {\n AppAlreadyInstalledDAError,\n DeleteLanguagePackDAError,\n DeviceLockedError,\n DeviceNotOnboardedError,\n OutOfMemoryDAError,\n RefusedByUserDAError,\n UnknownDAError,\n UnsupportedFirmwareDAError,\n} from \"@api/device-action/os/Errors\";\nexport { GetDeviceMetadataDeviceAction } from \"@api/device-action/os/GetDeviceMetadata/GetDeviceMetadataDeviceAction\";\nexport { GetDeviceStatusDeviceAction } from \"@api/device-action/os/GetDeviceStatus/GetDeviceStatusDeviceAction\";\nexport { GoToDashboardDeviceAction } from \"@api/device-action/os/GoToDashboard/GoToDashboardDeviceAction\";\nexport type {\n GoToDashboardDAError,\n GoToDashboardDAInput,\n GoToDashboardDAIntermediateValue,\n GoToDashboardDAOutput,\n GoToDashboardDARequiredInteraction,\n GoToDashboardDAState,\n} from \"@api/device-action/os/GoToDashboard/types\";\nexport { InstallLanguagePackageDeviceAction } from \"@api/device-action/os/InstallLanguagePackage/InstallLanguagePackageDeviceAction\";\nexport { InstallOrUpdateAppsDeviceAction } from \"@api/device-action/os/InstallOrUpdateApps/InstallOrUpdateAppsDeviceAction\";\nexport { ListAppsDeviceAction } from \"@api/device-action/os/ListApps/ListAppsDeviceAction\";\nexport { ListAppsWithMetadataDeviceAction } from \"@api/device-action/os/ListAppsWithMetadata/ListAppsWithMetadataDeviceAction\";\nexport { OpenAppDeviceAction } from \"@api/device-action/os/OpenAppDeviceAction/OpenAppDeviceAction\";\nexport { OpenAppWithDependenciesDeviceAction } from \"@api/device-action/os/OpenAppWithDependencies/OpenAppWithDependenciesDeviceAction\";\nexport { SendCommandInAppDeviceAction } from \"@api/device-action/os/SendCommandInAppDeviceAction/SendCommandInAppDeviceAction\";\nexport type {\n WaitForAppAndVersionDAError,\n WaitForAppAndVersionDAInput,\n WaitForAppAndVersionDAIntermediateValue,\n WaitForAppAndVersionDAOutput,\n WaitForAppAndVersionDARequiredInteraction,\n WaitForAppAndVersionDAState,\n} from \"@api/device-action/os/WaitForAppAndVersion/types\";\nexport { WaitForAppAndVersionDeviceAction } from \"@api/device-action/os/WaitForAppAndVersion/WaitForAppAndVersionDeviceAction\";\nexport {\n GetApplicationsMetadataTaskError,\n InvalidGetFirmwareMetadataResponseError,\n} from \"@api/device-action/task/Errors\";\nexport {\n type DeviceActionStateMachine,\n XStateDeviceAction,\n} from \"@api/device-action/xstate-utils/XStateDeviceAction\";\nexport { StaticDeviceModelDataSource } from \"@api/device-model/data/StaticDeviceModelDataSource\";\nexport { BleDeviceInfos } from \"@api/device-model/model/BleDeviceInfos\";\nexport { TransportDeviceModel } from \"@api/device-model/model/DeviceModel\";\nexport { ApduResponse } from \"@api/device-session/ApduResponse\";\nexport * from \"@api/device-session/data/FramerConst\";\nexport {\n type DeviceSessionState,\n DeviceSessionStateType,\n} from \"@api/device-session/DeviceSessionState\";\nexport {\n DmkResultFactory,\n DmkResultStatus,\n isSuccessDmkResult,\n} from \"@api/model/DmkResult\";\nexport { GenuineCheckDeviceAction } from \"@api/secure-channel/device-action/GenuineCheck/GenuineCheckDeviceAction\";\nexport { InstallAppDeviceAction } from \"@api/secure-channel/device-action/InstallApp/InstallAppDeviceAction\";\nexport { ListInstalledAppsDeviceAction } from \"@api/secure-channel/device-action/ListInstalledApps/ListInstalledAppsDeviceAction\";\nexport type { InstalledApp } from \"@api/secure-channel/device-action/ListInstalledApps/types\";\nexport { UninstallAppDeviceAction } from \"@api/secure-channel/device-action/UninstallApp/UninstallAppDeviceAction\";\nexport { ConnectToSecureChannelTask } from \"@api/secure-channel/task/ConnectToSecureChannelTask\";\nexport { SecureChannelEventType } from \"@api/secure-channel/task/types\";\nexport { SecureChannelError } from \"@internal/secure-channel/model/Errors\";\n// TODO: remove from exported\nexport { defaultApduReceiverServiceStubBuilder } from \"@api/device-session/service/DefaultApduReceiverService.stub\";\nexport { defaultApduSenderServiceStubBuilder } from \"@api/device-session/service/DefaultApduSenderService.stub\";\nexport { FramerUtils } from \"@api/device-session/utils/FramerUtils\";\nexport { DeviceManagementKit } from \"@api/DeviceManagementKit\";\nexport { DeviceManagementKitBuilder } from \"@api/DeviceManagementKitBuilder\";\nexport * from \"@api/Error\";\nexport {\n noopLogger,\n noopLoggerFactory,\n} from \"@api/logger-publisher/utils/noopLoggerFactory\";\nexport { LogLevel } from \"@api/logger-subscriber/model/LogLevel\";\nexport { ConsoleLogger } from \"@api/logger-subscriber/service/ConsoleLogger\";\nexport { DefaultLogTagFormatter } from \"@api/logger-subscriber/service/DefaultLogTagFormatter\";\nexport { type LogTagFormatter } from \"@api/logger-subscriber/service/LogTagFormatter\";\nexport { WebLogsExporterLogger } from \"@api/logger-subscriber/service/WebLogsExporterLogger\";\nexport {\n DmkNetworkClient,\n type DmkNetworkClientOptions,\n type DmkNetworkResponse,\n type DmkQueryParams,\n type DmkQueryParamValue,\n type DmkRequestConfig,\n type DmkResponseType,\n} from \"@api/network/DmkNetworkClient\";\nexport { DmkNetworkClientError } from \"@api/network/DmkNetworkClientError\";\nexport { ConnectedDevice } from \"@api/transport/model/ConnectedDevice\";\nexport {\n DeviceConnectionStateMachine,\n type DeviceConnectionStateMachineParams,\n} from \"@api/transport/model/DeviceConnectionStateMachine\";\nexport * from \"@api/transport/model/Errors\";\nexport { TransportConnectedDevice } from \"@api/transport/model/TransportConnectedDevice\";\nexport { connectedDeviceStubBuilder } from \"@api/transport/model/TransportConnectedDevice.stub\";\nexport * from \"@api/types\";\nexport { formatApduReceivedLog, formatApduSentLog } from \"@api/utils/apduLogs\";\nexport { ApplicationChecker } from \"@api/utils/ApplicationChecker\";\nexport {\n type AppConfig,\n type ApplicationResolver,\n type ResolvedApp,\n} from \"@api/utils/ApplicationResolver\";\nexport { isDashboardName } from \"@api/utils/AppName\";\nexport {\n base64StringToBuffer,\n bufferToBase64String,\n isBase64String,\n} from \"@api/utils/Base64String\";\nexport {\n bufferToHexaString,\n hexaStringToBuffer,\n isHexaString,\n} from \"@api/utils/HexaString\";\n"],
5
+ "mappings": "meAAA,IAAAA,EAAA,GAAAC,GAAAD,EAAA,+/JAAAE,GAAAF,GAEA,IAAAG,EAAqB,gCACrBC,EAA8C,uCAC9CC,EAA2B,sCAC3BC,EAAAN,EAAc,2CALd,gBAMA,IAAAO,EAAiC,4CACjCC,EAAgC,2CAEhCC,EAGO,+BACPC,EAIO,4CACPC,EAAgC,2CAChCC,EAMO,qDACPC,EAGO,mDACPC,EAMO,yDACPC,EAKO,mDACPC,EAGO,+CACPC,EAKO,2CACPC,EAOO,mDACPC,EAIO,kDACPC,EAGO,0CACPC,EAAmC,4CACnCC,EAA6B,2CAC7BC,EAIO,iDACPC,EAIO,mCACPC,EAA6B,oCAE7BC,EAGO,sDACPC,EAAwC,4DACxCC,EAA0C,qFAC1CC,EAA0C,uCAC1CpB,EASO,wCACPqB,EAA8C,iFAC9CC,EAA4C,6EAC5CC,EAA0C,yEAS1CC,EAAmD,2FACnDC,EAAgD,qFAChDC,EAAqC,+DACrCC,EAAiD,uFACjDC,EAAoC,yEACpCC,EAAoD,6FACpDC,EAA6C,2FAS7CC,EAAiD,uFACjD/B,EAGO,0CACPgC,EAGO,8DACPC,GAA4C,8DAC5CC,GAA+B,kDAC/BnB,GAAqC,+CACrCoB,GAA6B,4CAC7BtC,EAAAN,EAAc,gDA5Id,gBA6IA,IAAA6C,GAGO,kDACPC,EAIO,gCACPC,GAAyC,mFACzCC,GAAuC,+EACvCC,GAA8C,6FAE9CC,GAAyC,mFACzCC,GAA2C,+DAC3CC,GAAuC,0CACvC3C,GAAmC,iDAEnC4C,GAAsD,uEACtDC,GAAoD,qEACpDC,GAA4B,iDAC5BC,GAAoC,oCACpCC,GAA2C,2CAC3CnD,EAAAN,EAAc,sBApKd,gBAqKA,IAAA0D,EAGO,yDACPC,GAAyB,iDACzBC,GAA8B,wDAC9BC,GAAuC,iEAEvCC,GAAsC,gEACtCC,GAQO,yCACPC,GAAsC,8CACtCC,GAAgC,gDAChCC,GAGO,6DACP5D,EAAAN,EAAc,uCA7Ld,gBA8LA,IAAAmE,GAAyC,yDACzCA,GAA2C,8DAC3C7D,EAAAN,EAAc,sBAhMd,gBAiMA,IAAAoE,EAAyD,+BACzDC,GAAmC,yCAMnCC,GAAgC,8BAChCC,EAIO,mCACPC,EAIO",
6
+ "names": ["api_exports", "__export", "__toCommonJS", "import_Apdu", "import_ApduBuilder", "import_ApduParser", "__reExport", "import_ByteArrayBuilder", "import_ByteArrayParser", "import_Errors", "import_CommandResult", "import_CloseAppCommand", "import_DeleteLanguagePackCommand", "import_GetAppAndVersionCommand", "import_GetBackgroundImageSizeCommand", "import_GetBatteryStatusCommand", "import_GetOsVersionCommand", "import_ListAppsCommand", "import_ListLanguagePackCommand", "import_LoadCertificateCommand", "import_OpenAppCommand", "import_CommandErrors", "import_CommandUtils", "import_GlobalCommandError", "import_DeviceModel", "import_DeviceStatus", "import_DeviceActionState", "import_UserInteractionRequired", "import_CallTaskInAppDeviceAction", "import_Const", "import_GetDeviceMetadataDeviceAction", "import_GetDeviceStatusDeviceAction", "import_GoToDashboardDeviceAction", "import_InstallLanguagePackageDeviceAction", "import_InstallOrUpdateAppsDeviceAction", "import_ListAppsDeviceAction", "import_ListAppsWithMetadataDeviceAction", "import_OpenAppDeviceAction", "import_OpenAppWithDependenciesDeviceAction", "import_SendCommandInAppDeviceAction", "import_WaitForAppAndVersionDeviceAction", "import_XStateDeviceAction", "import_StaticDeviceModelDataSource", "import_BleDeviceInfos", "import_ApduResponse", "import_DeviceSessionState", "import_DmkResult", "import_GenuineCheckDeviceAction", "import_InstallAppDeviceAction", "import_ListInstalledAppsDeviceAction", "import_UninstallAppDeviceAction", "import_ConnectToSecureChannelTask", "import_types", "import_DefaultApduReceiverService", "import_DefaultApduSenderService", "import_FramerUtils", "import_DeviceManagementKit", "import_DeviceManagementKitBuilder", "import_noopLoggerFactory", "import_LogLevel", "import_ConsoleLogger", "import_DefaultLogTagFormatter", "import_WebLogsExporterLogger", "import_DmkNetworkClient", "import_DmkNetworkClientError", "import_ConnectedDevice", "import_DeviceConnectionStateMachine", "import_TransportConnectedDevice", "import_apduLogs", "import_ApplicationChecker", "import_AppName", "import_Base64String", "import_HexaString"]
7
7
  }
@@ -1,2 +1,2 @@
1
- "use strict";var a=Object.defineProperty;var n=Object.getOwnPropertyDescriptor;var s=Object.getOwnPropertyNames;var i=Object.prototype.hasOwnProperty;var A=(t,e,o,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let p of s(e))!i.call(t,p)&&p!==o&&a(t,p,{get:()=>e[p],enumerable:!(r=n(e,p))||r.enumerable});return t};var y=t=>A(a({},"__esModule",{value:!0}),t);var d={};module.exports=y(d);
1
+ "use strict";var a=Object.defineProperty;var s=Object.getOwnPropertyDescriptor;var i=Object.getOwnPropertyNames;var A=Object.prototype.hasOwnProperty;var y=(t,e)=>{for(var r in e)a(t,r,{get:e[r],enumerable:!0})},d=(t,e,r,o)=>{if(e&&typeof e=="object"||typeof e=="function")for(let p of i(e))!A.call(t,p)&&p!==r&&a(t,p,{get:()=>e[p],enumerable:!(o=s(e,p))||o.enumerable});return t};var D=t=>d(a({},"__esModule",{value:!0}),t);var u={};y(u,{LANGUAGE_ID_TO_LANGUAGE:()=>n.LANGUAGE_ID_TO_LANGUAGE});module.exports=D(u);var n=require("./device-action/os/InstallLanguagePackage/types");0&&(module.exports={LANGUAGE_ID_TO_LANGUAGE});
2
2
  //# sourceMappingURL=types.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../src/api/types.ts"],
4
- "sourcesContent": ["export type { OpenAppErrorCodes } from \"./command/os/OpenAppCommand\";\nexport type { CommandErrors } from \"./command/utils/CommandErrors\";\nexport type { DeviceId } from \"./device/DeviceModel\";\nexport type { ConnectionType } from \"./discovery/ConnectionType\";\nexport type { CommandErrorArgs } from \"./Error\";\nexport type { LogSubscriberOptions } from \"./logger-subscriber/model/LogSubscriberOptions\";\nexport type { DiscoveredDevice } from \"./transport/model/DiscoveredDevice\";\nexport type {\n Transport,\n TransportArgs,\n TransportFactory,\n} from \"./transport/model/Transport\";\nexport type { TransportIdentifier } from \"./transport/model/TransportIdentifier\";\nexport type { ApduBuilderArgs } from \"@api/apdu/utils/ApduBuilder\";\nexport type { Command } from \"@api/command/Command\";\nexport type {\n CommandErrorResult,\n CommandResult,\n CommandSuccessResult,\n} from \"@api/command/model/CommandResult\";\nexport type { SendCommandUseCaseArgs } from \"@api/command/use-case/SendCommandUseCase\";\nexport type { DeviceModelId } from \"@api/device/DeviceModel\";\nexport {\n type DeviceAction,\n type DeviceActionIntermediateValue,\n type ExecuteDeviceActionReturnType,\n} from \"@api/device-action/DeviceAction\";\nexport {\n type CallTaskInAppDAError,\n type CallTaskInAppDAIntermediateValue,\n type CallTaskInAppDAOutput,\n} from \"@api/device-action/os/CallTaskInAppDeviceAction/CallTaskInAppDeviceActionTypes\";\nexport {\n type GetDeviceMetadataDAError,\n type GetDeviceMetadataDAInput,\n type GetDeviceMetadataDAIntermediateValue,\n type GetDeviceMetadataDAOutput,\n type GetDeviceMetadataDAState,\n} from \"@api/device-action/os/GetDeviceMetadata/types\";\nexport {\n type GetDeviceStatusDAError,\n type GetDeviceStatusDAInput,\n type GetDeviceStatusDAIntermediateValue,\n type GetDeviceStatusDAOutput,\n type GetDeviceStatusDAState,\n} from \"@api/device-action/os/GetDeviceStatus/types\";\nexport {\n type GoToDashboardDAError,\n type GoToDashboardDAInput,\n type GoToDashboardDAIntermediateValue,\n type GoToDashboardDAOutput,\n type GoToDashboardDAState,\n} from \"@api/device-action/os/GoToDashboard/types\";\nexport {\n type InstallLanguagePackageDAError,\n type InstallLanguagePackageDAInput,\n type InstallLanguagePackageDAIntermediateValue,\n type InstallLanguagePackageDAOutput,\n type InstallLanguagePackageDAState,\n type Language,\n} from \"@api/device-action/os/InstallLanguagePackage/types\";\nexport {\n type ApplicationConstraint,\n type ApplicationDependency,\n type ApplicationVersionConstraint,\n type InstallOrUpdateAppsDAError,\n type InstallOrUpdateAppsDAInput,\n type InstallOrUpdateAppsDAIntermediateValue,\n type InstallOrUpdateAppsDAOutput,\n type InstallOrUpdateAppsDAState,\n type InstallPlan,\n} from \"@api/device-action/os/InstallOrUpdateApps/types\";\nexport {\n type ListAppsDAError,\n type ListAppsDAInput,\n type ListAppsDAIntermediateValue,\n type ListAppsDAOutput,\n type ListAppsDAState,\n} from \"@api/device-action/os/ListApps/types\";\nexport {\n type ListAppsWithMetadataDAError,\n type ListAppsWithMetadataDAInput,\n type ListAppsWithMetadataDAIntermediateValue,\n type ListAppsWithMetadataDAOutput,\n type ListAppsWithMetadataDAState,\n} from \"@api/device-action/os/ListAppsWithMetadata/types\";\nexport {\n type OpenAppDAError,\n type OpenAppDAInput,\n type OpenAppDAIntermediateValue,\n type OpenAppDAOutput,\n type OpenAppDARequiredInteraction,\n type OpenAppDAState,\n} from \"@api/device-action/os/OpenAppDeviceAction/types\";\nexport {\n type OpenAppWithDependenciesDAError,\n type OpenAppWithDependenciesDAInput,\n type OpenAppWithDependenciesDAIntermediateValue,\n type OpenAppWithDependenciesDAOutput,\n type OpenAppWithDependenciesDARequiredInteraction,\n type OpenAppWithDependenciesDAState,\n} from \"@api/device-action/os/OpenAppWithDependencies/types\";\nexport {\n type SendCommandInAppDAError,\n type SendCommandInAppDAInput,\n type SendCommandInAppDAIntermediateValue,\n type SendCommandInAppDAOutput,\n} from \"@api/device-action/os/SendCommandInAppDeviceAction/SendCommandInAppDeviceActionTypes\";\nexport type { ExecuteDeviceActionUseCaseArgs } from \"@api/device-action/use-case/ExecuteDeviceActionUseCase\";\nexport { type StateMachineTypes } from \"@api/device-action/xstate-utils/StateMachineTypes\";\nexport { type DeviceModelDataSource } from \"@api/device-model/data/DeviceModelDataSource\";\nexport type {\n Catalog,\n CustomImage,\n DeviceSessionState,\n FirmwareUpdate,\n FirmwareUpdateContext,\n FirmwareVersion,\n InstalledLanguagePackage,\n RunningApp,\n} from \"@api/device-session/DeviceSessionState\";\nexport { type ApduReceiverService } from \"@api/device-session/service/ApduReceiverService\";\nexport { type ApduReceiverServiceFactory } from \"@api/device-session/service/ApduReceiverService\";\nexport { type ApduSenderServiceFactory } from \"@api/device-session/service/ApduSenderService\";\nexport { type ApduSenderService } from \"@api/device-session/service/ApduSenderService\";\nexport type { DeviceSessionId } from \"@api/device-session/types\";\nexport type { DmkConfig } from \"@api/DmkConfig\";\nexport type { DmkError } from \"@api/Error\";\nexport type { LoggerPublisherService } from \"@api/logger-publisher/service/LoggerPublisherService\";\nexport type {\n LoggerSubscriberService,\n LogParams,\n} from \"@api/logger-subscriber/service/LoggerSubscriberService\";\nexport type {\n DmkErrorResult,\n DmkResult,\n DmkSuccessResult,\n} from \"@api/model/DmkResult\";\nexport {\n type GenuineCheckDAError,\n type GenuineCheckDAInput,\n type GenuineCheckDAIntermediateValue,\n type GenuineCheckDAOutput,\n type GenuineCheckDARequiredInteraction,\n type GenuineCheckDAState,\n} from \"@api/secure-channel/device-action/GenuineCheck/types\";\nexport {\n type InstallAppDAError,\n type InstallAppDAInput,\n type InstallAppDAIntermediateValue,\n type InstallAppDAOutput,\n type InstallAppDARequiredInteraction,\n type InstallAppDAState,\n} from \"@api/secure-channel/device-action/InstallApp/types\";\nexport {\n type ListInstalledAppsDAError,\n type ListInstalledAppsDAInput,\n type ListInstalledAppsDAIntermediateValue,\n type ListInstalledAppsDAOutput,\n type ListInstalledAppsDARequiredInteraction,\n type ListInstalledAppsDAState,\n} from \"@api/secure-channel/device-action/ListInstalledApps/types\";\nexport {\n type UninstallAppDAError,\n type UninstallAppDAInput,\n type UninstallAppDAIntermediateValue,\n type UninstallAppDAOutput,\n type UninstallAppDARequiredInteraction,\n type UninstallAppDAState,\n} from \"@api/secure-channel/device-action/UninstallApp/types\";\nexport { type DeviceApduSender } from \"@api/transport/model/DeviceApduSender\";\nexport {\n type DeviceConnection,\n type DisconnectHandler,\n type SendApduFnType,\n type SendApduResult,\n} from \"@api/transport/model/DeviceConnection\";\nexport { type TransportDiscoveredDevice } from \"@api/transport/model/TransportDiscoveredDevice\";\nexport type { HexaString } from \"@api/utils/HexaString\";\nexport type { ConnectUseCaseArgs } from \"@internal/discovery/use-case/ConnectUseCase\";\nexport type { DisconnectUseCaseArgs } from \"@internal/discovery/use-case/DisconnectUseCase\";\nexport type { GetConnectedDeviceUseCaseArgs } from \"@internal/discovery/use-case/GetConnectedDeviceUseCase\";\nexport type { StartDiscoveringUseCaseArgs } from \"@internal/discovery/use-case/StartDiscoveringUseCase\";\nexport type { SendApduUseCaseArgs } from \"@internal/send/use-case/SendApduUseCase\";\n"],
5
- "mappings": "+WAAA,IAAAA,EAAA,kBAAAC,EAAAD",
6
- "names": ["types_exports", "__toCommonJS"]
4
+ "sourcesContent": ["export type { OpenAppErrorCodes } from \"./command/os/OpenAppCommand\";\nexport type { CommandErrors } from \"./command/utils/CommandErrors\";\nexport type { DeviceId } from \"./device/DeviceModel\";\nexport type { ConnectionType } from \"./discovery/ConnectionType\";\nexport type { CommandErrorArgs } from \"./Error\";\nexport type { LogSubscriberOptions } from \"./logger-subscriber/model/LogSubscriberOptions\";\nexport type { DiscoveredDevice } from \"./transport/model/DiscoveredDevice\";\nexport type {\n Transport,\n TransportArgs,\n TransportFactory,\n} from \"./transport/model/Transport\";\nexport type { TransportIdentifier } from \"./transport/model/TransportIdentifier\";\nexport type { ApduBuilderArgs } from \"@api/apdu/utils/ApduBuilder\";\nexport type { Command } from \"@api/command/Command\";\nexport type {\n CommandErrorResult,\n CommandResult,\n CommandSuccessResult,\n} from \"@api/command/model/CommandResult\";\nexport type { SendCommandUseCaseArgs } from \"@api/command/use-case/SendCommandUseCase\";\nexport type { DeviceModelId } from \"@api/device/DeviceModel\";\nexport {\n type DeviceAction,\n type DeviceActionIntermediateValue,\n type ExecuteDeviceActionReturnType,\n} from \"@api/device-action/DeviceAction\";\nexport {\n type CallTaskInAppDAError,\n type CallTaskInAppDAIntermediateValue,\n type CallTaskInAppDAOutput,\n} from \"@api/device-action/os/CallTaskInAppDeviceAction/CallTaskInAppDeviceActionTypes\";\nexport {\n type GetDeviceMetadataDAError,\n type GetDeviceMetadataDAInput,\n type GetDeviceMetadataDAIntermediateValue,\n type GetDeviceMetadataDAOutput,\n type GetDeviceMetadataDAState,\n} from \"@api/device-action/os/GetDeviceMetadata/types\";\nexport {\n type GetDeviceStatusDAError,\n type GetDeviceStatusDAInput,\n type GetDeviceStatusDAIntermediateValue,\n type GetDeviceStatusDAOutput,\n type GetDeviceStatusDAState,\n} from \"@api/device-action/os/GetDeviceStatus/types\";\nexport {\n type GoToDashboardDAError,\n type GoToDashboardDAInput,\n type GoToDashboardDAIntermediateValue,\n type GoToDashboardDAOutput,\n type GoToDashboardDAState,\n} from \"@api/device-action/os/GoToDashboard/types\";\nexport {\n type InstallLanguagePackageDAError,\n type InstallLanguagePackageDAInput,\n type InstallLanguagePackageDAIntermediateValue,\n type InstallLanguagePackageDAOutput,\n type InstallLanguagePackageDAState,\n type Language,\n LANGUAGE_ID_TO_LANGUAGE,\n} from \"@api/device-action/os/InstallLanguagePackage/types\";\nexport {\n type ApplicationConstraint,\n type ApplicationDependency,\n type ApplicationVersionConstraint,\n type InstallOrUpdateAppsDAError,\n type InstallOrUpdateAppsDAInput,\n type InstallOrUpdateAppsDAIntermediateValue,\n type InstallOrUpdateAppsDAOutput,\n type InstallOrUpdateAppsDAState,\n type InstallPlan,\n} from \"@api/device-action/os/InstallOrUpdateApps/types\";\nexport {\n type ListAppsDAError,\n type ListAppsDAInput,\n type ListAppsDAIntermediateValue,\n type ListAppsDAOutput,\n type ListAppsDAState,\n} from \"@api/device-action/os/ListApps/types\";\nexport {\n type ListAppsWithMetadataDAError,\n type ListAppsWithMetadataDAInput,\n type ListAppsWithMetadataDAIntermediateValue,\n type ListAppsWithMetadataDAOutput,\n type ListAppsWithMetadataDAState,\n} from \"@api/device-action/os/ListAppsWithMetadata/types\";\nexport {\n type OpenAppDAError,\n type OpenAppDAInput,\n type OpenAppDAIntermediateValue,\n type OpenAppDAOutput,\n type OpenAppDARequiredInteraction,\n type OpenAppDAState,\n} from \"@api/device-action/os/OpenAppDeviceAction/types\";\nexport {\n type OpenAppWithDependenciesDAError,\n type OpenAppWithDependenciesDAInput,\n type OpenAppWithDependenciesDAIntermediateValue,\n type OpenAppWithDependenciesDAOutput,\n type OpenAppWithDependenciesDARequiredInteraction,\n type OpenAppWithDependenciesDAState,\n} from \"@api/device-action/os/OpenAppWithDependencies/types\";\nexport {\n type SendCommandInAppDAError,\n type SendCommandInAppDAInput,\n type SendCommandInAppDAIntermediateValue,\n type SendCommandInAppDAOutput,\n} from \"@api/device-action/os/SendCommandInAppDeviceAction/SendCommandInAppDeviceActionTypes\";\nexport type { ExecuteDeviceActionUseCaseArgs } from \"@api/device-action/use-case/ExecuteDeviceActionUseCase\";\nexport { type StateMachineTypes } from \"@api/device-action/xstate-utils/StateMachineTypes\";\nexport { type DeviceModelDataSource } from \"@api/device-model/data/DeviceModelDataSource\";\nexport type {\n Catalog,\n CustomImage,\n DeviceSessionState,\n FirmwareUpdate,\n FirmwareUpdateContext,\n FirmwareVersion,\n InstalledLanguagePackage,\n RunningApp,\n} from \"@api/device-session/DeviceSessionState\";\nexport { type ApduReceiverService } from \"@api/device-session/service/ApduReceiverService\";\nexport { type ApduReceiverServiceFactory } from \"@api/device-session/service/ApduReceiverService\";\nexport { type ApduSenderServiceFactory } from \"@api/device-session/service/ApduSenderService\";\nexport { type ApduSenderService } from \"@api/device-session/service/ApduSenderService\";\nexport type { DeviceSessionId } from \"@api/device-session/types\";\nexport type { DmkConfig } from \"@api/DmkConfig\";\nexport type { DmkError } from \"@api/Error\";\nexport type { LoggerPublisherService } from \"@api/logger-publisher/service/LoggerPublisherService\";\nexport type {\n LoggerSubscriberService,\n LogParams,\n} from \"@api/logger-subscriber/service/LoggerSubscriberService\";\nexport type {\n DmkErrorResult,\n DmkResult,\n DmkSuccessResult,\n} from \"@api/model/DmkResult\";\nexport {\n type GenuineCheckDAError,\n type GenuineCheckDAInput,\n type GenuineCheckDAIntermediateValue,\n type GenuineCheckDAOutput,\n type GenuineCheckDARequiredInteraction,\n type GenuineCheckDAState,\n} from \"@api/secure-channel/device-action/GenuineCheck/types\";\nexport {\n type InstallAppDAError,\n type InstallAppDAInput,\n type InstallAppDAIntermediateValue,\n type InstallAppDAOutput,\n type InstallAppDARequiredInteraction,\n type InstallAppDAState,\n} from \"@api/secure-channel/device-action/InstallApp/types\";\nexport {\n type ListInstalledAppsDAError,\n type ListInstalledAppsDAInput,\n type ListInstalledAppsDAIntermediateValue,\n type ListInstalledAppsDAOutput,\n type ListInstalledAppsDARequiredInteraction,\n type ListInstalledAppsDAState,\n} from \"@api/secure-channel/device-action/ListInstalledApps/types\";\nexport {\n type UninstallAppDAError,\n type UninstallAppDAInput,\n type UninstallAppDAIntermediateValue,\n type UninstallAppDAOutput,\n type UninstallAppDARequiredInteraction,\n type UninstallAppDAState,\n} from \"@api/secure-channel/device-action/UninstallApp/types\";\nexport { type DeviceApduSender } from \"@api/transport/model/DeviceApduSender\";\nexport {\n type DeviceConnection,\n type DisconnectHandler,\n type SendApduFnType,\n type SendApduResult,\n} from \"@api/transport/model/DeviceConnection\";\nexport { type TransportDiscoveredDevice } from \"@api/transport/model/TransportDiscoveredDevice\";\nexport type { HexaString } from \"@api/utils/HexaString\";\nexport type { ConnectUseCaseArgs } from \"@internal/discovery/use-case/ConnectUseCase\";\nexport type { DisconnectUseCaseArgs } from \"@internal/discovery/use-case/DisconnectUseCase\";\nexport type { GetConnectedDeviceUseCaseArgs } from \"@internal/discovery/use-case/GetConnectedDeviceUseCase\";\nexport type { StartDiscoveringUseCaseArgs } from \"@internal/discovery/use-case/StartDiscoveringUseCase\";\nexport type { SendApduUseCaseArgs } from \"@internal/send/use-case/SendApduUseCase\";\n"],
5
+ "mappings": "yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,wEAAAE,EAAAF,GAqDA,IAAAG,EAQO",
6
+ "names": ["types_exports", "__export", "__toCommonJS", "import_types"]
7
7
  }
@@ -1,2 +1,2 @@
1
- "use strict";var a=Object.defineProperty;var i=Object.getOwnPropertyDescriptor;var s=Object.getOwnPropertyNames;var u=Object.prototype.hasOwnProperty;var p=(e,r)=>{for(var o in r)a(e,o,{get:r[o],enumerable:!0})},g=(e,r,o,f)=>{if(r&&typeof r=="object"||typeof r=="function")for(let t of s(r))!u.call(e,t)&&t!==o&&a(e,t,{get:()=>r[t],enumerable:!(f=i(r,t))||f.enumerable});return e};var d=e=>g(a({},"__esModule",{value:!0}),e);var l={};p(l,{formatApduReceivedLog:()=>c,formatApduSendingLog:()=>A,formatApduSentLog:()=>m});module.exports=d(l);var n=require("./HexaString");function A(e){return`[will send APDU] ~...> ${(0,n.bufferToHexaString)(e,!1)}`}function m(e){return`[exchange] => ${(0,n.bufferToHexaString)(e,!1)}`}function c(e){return`[exchange] <= ${(0,n.bufferToHexaString)(e.data,!1)}${(0,n.bufferToHexaString)(e.statusCode,!1)}`}0&&(module.exports={formatApduReceivedLog,formatApduSendingLog,formatApduSentLog});
1
+ "use strict";var a=Object.defineProperty;var i=Object.getOwnPropertyDescriptor;var u=Object.getOwnPropertyNames;var f=Object.prototype.hasOwnProperty;var d=(e,t)=>{for(var r in t)a(e,r,{get:t[r],enumerable:!0})},A=(e,t,r,o)=>{if(t&&typeof t=="object"||typeof t=="function")for(let s of u(t))!f.call(e,s)&&s!==r&&a(e,s,{get:()=>t[s],enumerable:!(o=i(t,s))||o.enumerable});return e};var c=e=>A(a({},"__esModule",{value:!0}),e);var y={};d(y,{APDU_EXCHANGE_LOG:()=>p,formatApduExchangeLog:()=>l,formatApduReceivedLog:()=>g,formatApduSendingLog:()=>x,formatApduSentLog:()=>m});module.exports=c(y);var n=require("./HexaString");function x(e){return`[will send APDU] ~...> ${(0,n.bufferToHexaString)(e,!1)}`}function m(e){return`[exchange] => ${(0,n.bufferToHexaString)(e,!1)}`}function g(e){return`[exchange] <= ${(0,n.bufferToHexaString)(e.data,!1)}${(0,n.bufferToHexaString)(e.statusCode,!1)}`}const p="apdu-exchange";function l(e,t,r){const o=(0,n.bufferToHexaString)(t,!1),s=`${(0,n.bufferToHexaString)(r.data,!1)}${(0,n.bufferToHexaString)(r.statusCode,!1)}`;return{message:g(r),data:{type:p,sessionId:e,apdu:o,response:s}}}0&&(module.exports={APDU_EXCHANGE_LOG,formatApduExchangeLog,formatApduReceivedLog,formatApduSendingLog,formatApduSentLog});
2
2
  //# sourceMappingURL=apduLogs.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../../src/api/utils/apduLogs.ts"],
4
- "sourcesContent": ["import { type ApduResponse } from \"@api/device-session/ApduResponse\";\n\nimport { bufferToHexaString } from \"./HexaString\";\n\n/**\n * Formats the log message for an APDU that is about to be sent.\n * Only call this at the device session layer, before calling sendApdu on the connected device.\n */\nexport function formatApduSendingLog(apdu: Uint8Array): string {\n return `[will send APDU] ~...> ${bufferToHexaString(apdu, false)}`;\n}\n\n/**\n * Formats the log message for an APDU that was sent.\n * Only call this at the transport layer, after the APDU sending logic has been executed\n * without any error.\n */\nexport function formatApduSentLog(apdu: Uint8Array): string {\n return `[exchange] => ${bufferToHexaString(apdu, false)}`;\n}\n\n/**\n * Formats the log message for an APDU response received from the device.\n */\nexport function formatApduReceivedLog(apduResponse: ApduResponse): string {\n return `[exchange] <= ${bufferToHexaString(apduResponse.data, false)}${bufferToHexaString(apduResponse.statusCode, false)}`;\n}\n"],
5
- "mappings": "yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,2BAAAE,EAAA,yBAAAC,EAAA,sBAAAC,IAAA,eAAAC,EAAAL,GAEA,IAAAM,EAAmC,wBAM5B,SAASH,EAAqBI,EAA0B,CAC7D,MAAO,6BAA0B,sBAAmBA,EAAM,EAAK,CAAC,EAClE,CAOO,SAASH,EAAkBG,EAA0B,CAC1D,MAAO,oBAAiB,sBAAmBA,EAAM,EAAK,CAAC,EACzD,CAKO,SAASL,EAAsBM,EAAoC,CACxE,MAAO,oBAAiB,sBAAmBA,EAAa,KAAM,EAAK,CAAC,MAAG,sBAAmBA,EAAa,WAAY,EAAK,CAAC,EAC3H",
6
- "names": ["apduLogs_exports", "__export", "formatApduReceivedLog", "formatApduSendingLog", "formatApduSentLog", "__toCommonJS", "import_HexaString", "apdu", "apduResponse"]
4
+ "sourcesContent": ["import { type ApduResponse } from \"@api/device-session/ApduResponse\";\n\nimport { bufferToHexaString } from \"./HexaString\";\n\n/**\n * Formats the log message for an APDU that is about to be sent.\n * Only call this at the device session layer, before calling sendApdu on the connected device.\n */\nexport function formatApduSendingLog(apdu: Uint8Array): string {\n return `[will send APDU] ~...> ${bufferToHexaString(apdu, false)}`;\n}\n\n/**\n * Formats the log message for an APDU that was sent.\n * Only call this at the transport layer, after the APDU sending logic has been executed\n * without any error.\n */\nexport function formatApduSentLog(apdu: Uint8Array): string {\n return `[exchange] => ${bufferToHexaString(apdu, false)}`;\n}\n\n/**\n * Formats the log message for an APDU response received from the device.\n */\nexport function formatApduReceivedLog(apduResponse: ApduResponse): string {\n return `[exchange] <= ${bufferToHexaString(apduResponse.data, false)}${bufferToHexaString(apduResponse.statusCode, false)}`;\n}\n\nexport const APDU_EXCHANGE_LOG = \"apdu-exchange\";\n\nexport type ApduExchangeLog = {\n type: typeof APDU_EXCHANGE_LOG;\n sessionId: string;\n apdu: string;\n response: string;\n};\n\n/**\n * Formats the log message and builds the structured `data` payload for a completed APDU exchange\n * (request + response).\n */\nexport function formatApduExchangeLog(\n sessionId: string,\n apdu: Uint8Array,\n apduResponse: ApduResponse,\n): { message: string; data: ApduExchangeLog } {\n const request = bufferToHexaString(apdu, false);\n const response = `${bufferToHexaString(apduResponse.data, false)}${bufferToHexaString(apduResponse.statusCode, false)}`;\n return {\n message: formatApduReceivedLog(apduResponse),\n data: { type: APDU_EXCHANGE_LOG, sessionId, apdu: request, response },\n };\n}\n"],
5
+ "mappings": "yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,uBAAAE,EAAA,0BAAAC,EAAA,0BAAAC,EAAA,yBAAAC,EAAA,sBAAAC,IAAA,eAAAC,EAAAP,GAEA,IAAAQ,EAAmC,wBAM5B,SAASH,EAAqBI,EAA0B,CAC7D,MAAO,6BAA0B,sBAAmBA,EAAM,EAAK,CAAC,EAClE,CAOO,SAASH,EAAkBG,EAA0B,CAC1D,MAAO,oBAAiB,sBAAmBA,EAAM,EAAK,CAAC,EACzD,CAKO,SAASL,EAAsBM,EAAoC,CACxE,MAAO,oBAAiB,sBAAmBA,EAAa,KAAM,EAAK,CAAC,MAAG,sBAAmBA,EAAa,WAAY,EAAK,CAAC,EAC3H,CAEO,MAAMR,EAAoB,gBAa1B,SAASC,EACdQ,EACAF,EACAC,EAC4C,CAC5C,MAAME,KAAU,sBAAmBH,EAAM,EAAK,EACxCI,EAAW,MAAG,sBAAmBH,EAAa,KAAM,EAAK,CAAC,MAAG,sBAAmBA,EAAa,WAAY,EAAK,CAAC,GACrH,MAAO,CACL,QAASN,EAAsBM,CAAY,EAC3C,KAAM,CAAE,KAAMR,EAAmB,UAAAS,EAAW,KAAMC,EAAS,SAAAC,CAAS,CACtE,CACF",
6
+ "names": ["apduLogs_exports", "__export", "APDU_EXCHANGE_LOG", "formatApduExchangeLog", "formatApduReceivedLog", "formatApduSendingLog", "formatApduSentLog", "__toCommonJS", "import_HexaString", "apdu", "apduResponse", "sessionId", "request", "response"]
7
7
  }
@@ -1,2 +1,2 @@
1
- "use strict";var o=require("vitest"),e=require("./apduLogs");(0,o.describe)("apduLogs",()=>{(0,o.describe)("formatApduSendingLog",()=>{(0,o.it)("should format APDU with correct format before sending",()=>{const t=Uint8Array.from([224,1,0,0,4]);(0,o.expect)((0,e.formatApduSendingLog)(t)).toBe("[will send APDU] ~...> e001000004")}),(0,o.it)("should handle empty APDU",()=>{const t=Uint8Array.from([]);(0,o.expect)((0,e.formatApduSendingLog)(t)).toBe("[will send APDU] ~...> ")})}),(0,o.describe)("formatApduSentLog",()=>{(0,o.it)("should format APDU with correct format after sending",()=>{const t=Uint8Array.from([224,1,0,0,4]);(0,o.expect)((0,e.formatApduSentLog)(t)).toBe("[exchange] => e001000004")}),(0,o.it)("should handle empty APDU",()=>{const t=Uint8Array.from([]);(0,o.expect)((0,e.formatApduSentLog)(t)).toBe("[exchange] => ")})}),(0,o.describe)("formatApduReceivedLog",()=>{(0,o.it)("should format APDU response with data and status code",()=>{const t={data:Uint8Array.from([1,2,3]),statusCode:Uint8Array.from([144,0])};(0,o.expect)((0,e.formatApduReceivedLog)(t)).toBe("[exchange] <= 0102039000")}),(0,o.it)("should format APDU response with only status code when data is empty",()=>{const t={data:Uint8Array.from([]),statusCode:Uint8Array.from([144,0])};(0,o.expect)((0,e.formatApduReceivedLog)(t)).toBe("[exchange] <= 9000")}),(0,o.it)("should format error status code correctly",()=>{const t={data:Uint8Array.from([]),statusCode:Uint8Array.from([105,133])};(0,o.expect)((0,e.formatApduReceivedLog)(t)).toBe("[exchange] <= 6985")})})});
1
+ "use strict";var e=require("vitest"),o=require("./apduLogs");(0,e.describe)("apduLogs",()=>{(0,e.describe)("formatApduSendingLog",()=>{(0,e.it)("should format APDU with correct format before sending",()=>{const t=Uint8Array.from([224,1,0,0,4]);(0,e.expect)((0,o.formatApduSendingLog)(t)).toBe("[will send APDU] ~...> e001000004")}),(0,e.it)("should handle empty APDU",()=>{const t=Uint8Array.from([]);(0,e.expect)((0,o.formatApduSendingLog)(t)).toBe("[will send APDU] ~...> ")})}),(0,e.describe)("formatApduSentLog",()=>{(0,e.it)("should format APDU with correct format after sending",()=>{const t=Uint8Array.from([224,1,0,0,4]);(0,e.expect)((0,o.formatApduSentLog)(t)).toBe("[exchange] => e001000004")}),(0,e.it)("should handle empty APDU",()=>{const t=Uint8Array.from([]);(0,e.expect)((0,o.formatApduSentLog)(t)).toBe("[exchange] => ")})}),(0,e.describe)("formatApduReceivedLog",()=>{(0,e.it)("should format APDU response with data and status code",()=>{const t={data:Uint8Array.from([1,2,3]),statusCode:Uint8Array.from([144,0])};(0,e.expect)((0,o.formatApduReceivedLog)(t)).toBe("[exchange] <= 0102039000")}),(0,e.it)("should format APDU response with only status code when data is empty",()=>{const t={data:Uint8Array.from([]),statusCode:Uint8Array.from([144,0])};(0,e.expect)((0,o.formatApduReceivedLog)(t)).toBe("[exchange] <= 9000")}),(0,e.it)("should format error status code correctly",()=>{const t={data:Uint8Array.from([]),statusCode:Uint8Array.from([105,133])};(0,e.expect)((0,o.formatApduReceivedLog)(t)).toBe("[exchange] <= 6985")})}),(0,e.describe)("formatApduExchangeLog",()=>{(0,e.it)("should keep the legacy received-log message and expose structured data",()=>{const t=Uint8Array.from([224,1,0,0,4]),a={data:Uint8Array.from([1,2,3]),statusCode:Uint8Array.from([144,0])},{message:r,data:s}=(0,o.formatApduExchangeLog)("session-1",t,a);(0,e.expect)(r).toBe((0,o.formatApduReceivedLog)(a)),(0,e.expect)(r).toBe("[exchange] <= 0102039000"),(0,e.expect)(s).toEqual({type:o.APDU_EXCHANGE_LOG,sessionId:"session-1",apdu:"e001000004",response:"0102039000"})}),(0,e.it)("should concatenate empty data with the status word in the structured payload",()=>{const t=Uint8Array.from([176,1,0,0]),a={data:Uint8Array.from([]),statusCode:Uint8Array.from([85,21])},{message:r,data:s}=(0,o.formatApduExchangeLog)("session-2",t,a);(0,e.expect)(r).toBe("[exchange] <= 5515"),(0,e.expect)(s.apdu).toBe("b0010000"),(0,e.expect)(s.response).toBe("5515")})})});
2
2
  //# sourceMappingURL=apduLogs.test.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../../src/api/utils/apduLogs.test.ts"],
4
- "sourcesContent": ["import { describe, expect, it } from \"vitest\";\n\nimport {\n formatApduReceivedLog,\n formatApduSendingLog,\n formatApduSentLog,\n} from \"./apduLogs\";\n\ndescribe(\"apduLogs\", () => {\n describe(\"formatApduSendingLog\", () => {\n it(\"should format APDU with correct format before sending\", () => {\n const apdu = Uint8Array.from([0xe0, 0x01, 0x00, 0x00, 0x04]);\n expect(formatApduSendingLog(apdu)).toBe(\n \"[will send APDU] ~...> e001000004\",\n );\n });\n\n it(\"should handle empty APDU\", () => {\n const apdu = Uint8Array.from([]);\n expect(formatApduSendingLog(apdu)).toBe(\"[will send APDU] ~...> \");\n });\n });\n\n describe(\"formatApduSentLog\", () => {\n it(\"should format APDU with correct format after sending\", () => {\n const apdu = Uint8Array.from([0xe0, 0x01, 0x00, 0x00, 0x04]);\n expect(formatApduSentLog(apdu)).toBe(\"[exchange] => e001000004\");\n });\n\n it(\"should handle empty APDU\", () => {\n const apdu = Uint8Array.from([]);\n expect(formatApduSentLog(apdu)).toBe(\"[exchange] => \");\n });\n });\n\n describe(\"formatApduReceivedLog\", () => {\n it(\"should format APDU response with data and status code\", () => {\n const apduResponse = {\n data: Uint8Array.from([0x01, 0x02, 0x03]),\n statusCode: Uint8Array.from([0x90, 0x00]),\n };\n expect(formatApduReceivedLog(apduResponse)).toBe(\n \"[exchange] <= 0102039000\",\n );\n });\n\n it(\"should format APDU response with only status code when data is empty\", () => {\n const apduResponse = {\n data: Uint8Array.from([]),\n statusCode: Uint8Array.from([0x90, 0x00]),\n };\n expect(formatApduReceivedLog(apduResponse)).toBe(\"[exchange] <= 9000\");\n });\n\n it(\"should format error status code correctly\", () => {\n const apduResponse = {\n data: Uint8Array.from([]),\n statusCode: Uint8Array.from([0x69, 0x85]),\n };\n expect(formatApduReceivedLog(apduResponse)).toBe(\"[exchange] <= 6985\");\n });\n });\n});\n"],
5
- "mappings": "aAAA,IAAAA,EAAqC,kBAErCC,EAIO,yBAEP,YAAS,WAAY,IAAM,IACzB,YAAS,uBAAwB,IAAM,IACrC,MAAG,wDAAyD,IAAM,CAChE,MAAMC,EAAO,WAAW,KAAK,CAAC,IAAM,EAAM,EAAM,EAAM,CAAI,CAAC,KAC3D,aAAO,wBAAqBA,CAAI,CAAC,EAAE,KACjC,mCACF,CACF,CAAC,KAED,MAAG,2BAA4B,IAAM,CACnC,MAAMA,EAAO,WAAW,KAAK,CAAC,CAAC,KAC/B,aAAO,wBAAqBA,CAAI,CAAC,EAAE,KAAK,yBAAyB,CACnE,CAAC,CACH,CAAC,KAED,YAAS,oBAAqB,IAAM,IAClC,MAAG,uDAAwD,IAAM,CAC/D,MAAMA,EAAO,WAAW,KAAK,CAAC,IAAM,EAAM,EAAM,EAAM,CAAI,CAAC,KAC3D,aAAO,qBAAkBA,CAAI,CAAC,EAAE,KAAK,0BAA0B,CACjE,CAAC,KAED,MAAG,2BAA4B,IAAM,CACnC,MAAMA,EAAO,WAAW,KAAK,CAAC,CAAC,KAC/B,aAAO,qBAAkBA,CAAI,CAAC,EAAE,KAAK,gBAAgB,CACvD,CAAC,CACH,CAAC,KAED,YAAS,wBAAyB,IAAM,IACtC,MAAG,wDAAyD,IAAM,CAChE,MAAMC,EAAe,CACnB,KAAM,WAAW,KAAK,CAAC,EAAM,EAAM,CAAI,CAAC,EACxC,WAAY,WAAW,KAAK,CAAC,IAAM,CAAI,CAAC,CAC1C,KACA,aAAO,yBAAsBA,CAAY,CAAC,EAAE,KAC1C,0BACF,CACF,CAAC,KAED,MAAG,uEAAwE,IAAM,CAC/E,MAAMA,EAAe,CACnB,KAAM,WAAW,KAAK,CAAC,CAAC,EACxB,WAAY,WAAW,KAAK,CAAC,IAAM,CAAI,CAAC,CAC1C,KACA,aAAO,yBAAsBA,CAAY,CAAC,EAAE,KAAK,oBAAoB,CACvE,CAAC,KAED,MAAG,4CAA6C,IAAM,CACpD,MAAMA,EAAe,CACnB,KAAM,WAAW,KAAK,CAAC,CAAC,EACxB,WAAY,WAAW,KAAK,CAAC,IAAM,GAAI,CAAC,CAC1C,KACA,aAAO,yBAAsBA,CAAY,CAAC,EAAE,KAAK,oBAAoB,CACvE,CAAC,CACH,CAAC,CACH,CAAC",
6
- "names": ["import_vitest", "import_apduLogs", "apdu", "apduResponse"]
4
+ "sourcesContent": ["import { describe, expect, it } from \"vitest\";\n\nimport {\n APDU_EXCHANGE_LOG,\n formatApduExchangeLog,\n formatApduReceivedLog,\n formatApduSendingLog,\n formatApduSentLog,\n} from \"./apduLogs\";\n\ndescribe(\"apduLogs\", () => {\n describe(\"formatApduSendingLog\", () => {\n it(\"should format APDU with correct format before sending\", () => {\n const apdu = Uint8Array.from([0xe0, 0x01, 0x00, 0x00, 0x04]);\n expect(formatApduSendingLog(apdu)).toBe(\n \"[will send APDU] ~...> e001000004\",\n );\n });\n\n it(\"should handle empty APDU\", () => {\n const apdu = Uint8Array.from([]);\n expect(formatApduSendingLog(apdu)).toBe(\"[will send APDU] ~...> \");\n });\n });\n\n describe(\"formatApduSentLog\", () => {\n it(\"should format APDU with correct format after sending\", () => {\n const apdu = Uint8Array.from([0xe0, 0x01, 0x00, 0x00, 0x04]);\n expect(formatApduSentLog(apdu)).toBe(\"[exchange] => e001000004\");\n });\n\n it(\"should handle empty APDU\", () => {\n const apdu = Uint8Array.from([]);\n expect(formatApduSentLog(apdu)).toBe(\"[exchange] => \");\n });\n });\n\n describe(\"formatApduReceivedLog\", () => {\n it(\"should format APDU response with data and status code\", () => {\n const apduResponse = {\n data: Uint8Array.from([0x01, 0x02, 0x03]),\n statusCode: Uint8Array.from([0x90, 0x00]),\n };\n expect(formatApduReceivedLog(apduResponse)).toBe(\n \"[exchange] <= 0102039000\",\n );\n });\n\n it(\"should format APDU response with only status code when data is empty\", () => {\n const apduResponse = {\n data: Uint8Array.from([]),\n statusCode: Uint8Array.from([0x90, 0x00]),\n };\n expect(formatApduReceivedLog(apduResponse)).toBe(\"[exchange] <= 9000\");\n });\n\n it(\"should format error status code correctly\", () => {\n const apduResponse = {\n data: Uint8Array.from([]),\n statusCode: Uint8Array.from([0x69, 0x85]),\n };\n expect(formatApduReceivedLog(apduResponse)).toBe(\"[exchange] <= 6985\");\n });\n });\n\n describe(\"formatApduExchangeLog\", () => {\n it(\"should keep the legacy received-log message and expose structured data\", () => {\n const apdu = Uint8Array.from([0xe0, 0x01, 0x00, 0x00, 0x04]);\n const apduResponse = {\n data: Uint8Array.from([0x01, 0x02, 0x03]),\n statusCode: Uint8Array.from([0x90, 0x00]),\n };\n\n const { message, data } = formatApduExchangeLog(\n \"session-1\",\n apdu,\n apduResponse,\n );\n\n expect(message).toBe(formatApduReceivedLog(apduResponse));\n expect(message).toBe(\"[exchange] <= 0102039000\");\n expect(data).toEqual({\n type: APDU_EXCHANGE_LOG,\n sessionId: \"session-1\",\n apdu: \"e001000004\",\n response: \"0102039000\",\n });\n });\n\n it(\"should concatenate empty data with the status word in the structured payload\", () => {\n const apdu = Uint8Array.from([0xb0, 0x01, 0x00, 0x00]);\n const apduResponse = {\n data: Uint8Array.from([]),\n statusCode: Uint8Array.from([0x55, 0x15]),\n };\n\n const { message, data } = formatApduExchangeLog(\n \"session-2\",\n apdu,\n apduResponse,\n );\n\n expect(message).toBe(\"[exchange] <= 5515\");\n expect(data.apdu).toBe(\"b0010000\");\n expect(data.response).toBe(\"5515\");\n });\n });\n});\n"],
5
+ "mappings": "aAAA,IAAAA,EAAqC,kBAErCC,EAMO,yBAEP,YAAS,WAAY,IAAM,IACzB,YAAS,uBAAwB,IAAM,IACrC,MAAG,wDAAyD,IAAM,CAChE,MAAMC,EAAO,WAAW,KAAK,CAAC,IAAM,EAAM,EAAM,EAAM,CAAI,CAAC,KAC3D,aAAO,wBAAqBA,CAAI,CAAC,EAAE,KACjC,mCACF,CACF,CAAC,KAED,MAAG,2BAA4B,IAAM,CACnC,MAAMA,EAAO,WAAW,KAAK,CAAC,CAAC,KAC/B,aAAO,wBAAqBA,CAAI,CAAC,EAAE,KAAK,yBAAyB,CACnE,CAAC,CACH,CAAC,KAED,YAAS,oBAAqB,IAAM,IAClC,MAAG,uDAAwD,IAAM,CAC/D,MAAMA,EAAO,WAAW,KAAK,CAAC,IAAM,EAAM,EAAM,EAAM,CAAI,CAAC,KAC3D,aAAO,qBAAkBA,CAAI,CAAC,EAAE,KAAK,0BAA0B,CACjE,CAAC,KAED,MAAG,2BAA4B,IAAM,CACnC,MAAMA,EAAO,WAAW,KAAK,CAAC,CAAC,KAC/B,aAAO,qBAAkBA,CAAI,CAAC,EAAE,KAAK,gBAAgB,CACvD,CAAC,CACH,CAAC,KAED,YAAS,wBAAyB,IAAM,IACtC,MAAG,wDAAyD,IAAM,CAChE,MAAMC,EAAe,CACnB,KAAM,WAAW,KAAK,CAAC,EAAM,EAAM,CAAI,CAAC,EACxC,WAAY,WAAW,KAAK,CAAC,IAAM,CAAI,CAAC,CAC1C,KACA,aAAO,yBAAsBA,CAAY,CAAC,EAAE,KAC1C,0BACF,CACF,CAAC,KAED,MAAG,uEAAwE,IAAM,CAC/E,MAAMA,EAAe,CACnB,KAAM,WAAW,KAAK,CAAC,CAAC,EACxB,WAAY,WAAW,KAAK,CAAC,IAAM,CAAI,CAA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"names": ["import_vitest", "import_apduLogs", "apdu", "apduResponse", "message", "data"]
7
7
  }
@@ -1,2 +1,2 @@
1
- "use strict";var l=Object.defineProperty;var R=Object.getOwnPropertyDescriptor;var y=Object.getOwnPropertyNames;var I=Object.prototype.hasOwnProperty;var O=(a,e)=>{for(var t in e)l(a,t,{get:e[t],enumerable:!0})},T=(a,e,t,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let s of y(e))!I.call(a,s)&&s!==t&&l(a,s,{get:()=>e[s],enumerable:!(i=R(e,s))||i.enumerable});return a};var x=a=>T(l({},"__esModule",{value:!0}),a);var P={};O(P,{DeviceSession:()=>w});module.exports=x(P);var r=require("rxjs"),S=require("uuid"),D=require("../../../api/command/utils/CommandUtils"),h=require("../../../api/device/DeviceStatus"),_=require("../../../api/device-session/DeviceSessionState"),p=require("../../../api/transport/model/Errors"),v=require("../../../api/utils/apduLogs"),g=require("../../device-session/data/DeviceSessionRefresherConst"),f=require("../../device-session/service/IntentQueueService"),E=require("../../device-session/service/RefresherService"),b=require("./DevicePinger"),u=require("./DeviceSessionEventDispatcher"),A=require("./DeviceSessionRefresher"),C=require("./DeviceSessionStateHandler");class w{_id;_connectedDevice;_deviceState;_managerApiService;_secureChannelService;_logger;_loggerModuleFactory;_refresherOptions;_pinger;_deviceSessionRefresher;_refresherService;_intentQueueService;_sessionEventDispatcher=new u.DeviceSessionEventDispatcher;_bypassIntentQueue=!1;constructor({connectedDevice:e,id:t=(0,S.v4)()},i,s,n,o,d=c=>new f.IntentQueueService(i,c)){this._id=t,this._connectedDevice=e,this._loggerModuleFactory=i,this._logger=i("device-session"),this._managerApiService=s,this._intentQueueService=d(this._sessionEventDispatcher),this._secureChannelService=n,this._refresherOptions={...g.DEVICE_SESSION_REFRESHER_DEFAULT_OPTIONS,...o},this._deviceState=new r.BehaviorSubject({sessionStateType:_.DeviceSessionStateType.Connected,deviceStatus:h.DeviceStatus.CONNECTED,deviceModelId:this._connectedDevice.deviceModel.id}),this._pinger=new b.DevicePinger(i,e,this._sessionEventDispatcher,(c,m)=>this.sendCommand(c,m)),this._deviceSessionRefresher=new A.DeviceSessionRefresher(i,this._refresherOptions,this._sessionEventDispatcher,this._connectedDevice),new C.DeviceSessionStateHandler(i,this._sessionEventDispatcher,this._connectedDevice,this._deviceState,c=>this.setDeviceSessionState(c)),this._refresherService=new E.RefresherService(i,{start:()=>this._deviceSessionRefresher.restartRefresher(),stop:()=>this._deviceSessionRefresher.stopRefresher()})}async initialiseSession(){try{this._refresherOptions.isRefresherDisabled?await this._pinger.ping():this._deviceSessionRefresher.startRefresher()}catch(e){throw this._logger.error("Error while initialising session",{data:{error:e}}),e}}get id(){return this._id}get connectedDevice(){return this._connectedDevice}get state(){return this._deviceState.asObservable()}getDeviceSessionState(){return this._deviceState.getValue()}setDeviceSessionState(e){this._deviceState.next(e)}sendApdu(e,t={isPolling:!1,triggersDisconnection:!1,abortTimeout:void 0}){return this._bypassIntentQueue?this._unsafeInternalSendApdu(e,t):this._internalSendApdu(e,t)}_internalSendApdu(e,t){const i=t.abortTimeout,s=Date.now(),{observable:n,cancel:o}=this._intentQueueService.enqueue({type:"send-apdu",execute:()=>(0,r.from)((async()=>{const c=Date.now()-s;return await this._unsafeInternalSendApdu(e,{isPolling:t.isPolling,triggersDisconnection:t.triggersDisconnection,abortTimeout:i?i-c:void 0})})())}),d=i?n.pipe((0,r.timeout)({each:i,with:()=>{throw o(),new p.SendApduTimeoutError}})):n;return(0,r.lastValueFrom)(d)}async _unsafeInternalSendApdu(e,t={isPolling:!1,triggersDisconnection:!1,abortTimeout:void 0}){return this._logger.debug((0,v.formatApduSendingLog)(e)),(await this._connectedDevice.sendApdu(e,t.triggersDisconnection,t.abortTimeout)).ifRight(s=>{this._logger.debug((0,v.formatApduReceivedLog)(s)),D.CommandUtils.isLockedDeviceResponse(s)?this._sessionEventDispatcher.dispatch({eventName:u.SessionEvents.DEVICE_STATE_UPDATE_LOCKED}):this._sessionEventDispatcher.dispatch({eventName:u.SessionEvents.DEVICE_STATE_UPDATE_CONNECTED})}).ifLeft(()=>{this._sessionEventDispatcher.dispatch({eventName:u.SessionEvents.DEVICE_STATE_UPDATE_UNKNOWN})})}sendCommand(e,t){return this._logger.debug(`[sendCommand] ${e.name}`),this._bypassIntentQueue?this._unsafeInternalSendCommand(e,t):this._internalSendCommand(e,t)}_internalSendCommand(e,t){const i=Date.now(),{observable:s,cancel:n}=this._intentQueueService.enqueue({type:"send-command",execute:()=>(0,r.from)((async()=>{const d=Date.now()-i;return await this._unsafeInternalSendCommand(e,t?t-d:void 0)})())}),o=t?s.pipe((0,r.timeout)({each:t,with:()=>{throw n(),new p.SendCommandTimeoutError}})):s;return(0,r.lastValueFrom)(o)}async _unsafeInternalSendCommand(e,t){const i=e.getApdu();return(await this._unsafeInternalSendApdu(i.getRawApdu(),{isPolling:!1,triggersDisconnection:e.triggersDisconnection??!1,abortTimeout:t})).caseOf({Left:n=>{throw this._logger.error("[sendCommand] error",{data:{err:n}}),n},Right:n=>{const o=e.parseResponse(n,this._connectedDevice.deviceModel.id);return this._logger.debug("[sendCommand] result",{data:{result:o}}),o}})}executeDeviceAction(e){return this._bypassIntentQueue?this._unsafeInternalExecuteDeviceAction(e):this._internalExecuteDeviceAction(e)}_internalExecuteDeviceAction(e){let t;const{observable:i,cancel:s}=this._intentQueueService.enqueue({type:"device-action",execute:()=>{const{observable:n,cancel:o}=this._unsafeInternalExecuteDeviceAction(e);return t=o,n}});return{observable:i,cancel:()=>{t?.(),s()}}}_unsafeInternalExecuteDeviceAction(e){const{observable:t,cancel:i}=e._execute({sendApdu:async s=>this._unsafeInternalSendApdu(s),sendCommand:async s=>this._unsafeInternalSendCommand(s),getDeviceModel:()=>this._connectedDevice.deviceModel,getDeviceSessionState:()=>this._deviceState.getValue(),getDeviceSessionStateObservable:()=>this.state,setDeviceSessionState:s=>(this.setDeviceSessionState(s),this._deviceState.getValue()),getManagerApiService:()=>this._managerApiService,getSecureChannelService:()=>this._secureChannelService,loggerFactory:this._loggerModuleFactory});return{observable:t,cancel:i}}close(){this._updateDeviceStatus(h.DeviceStatus.NOT_CONNECTED),this._deviceState.complete(),this._deviceSessionRefresher.stopRefresher(),this._pinger.unsubscribe()}disableRefresher(e){return this._refresherService.disableRefresher(e)}_unsafeBypassIntentQueue(e){this._bypassIntentQueue=e}_updateDeviceStatus(e){const t=this._deviceState.getValue();this._deviceState.next({...t,deviceStatus:e})}}0&&(module.exports={DeviceSession});
1
+ "use strict";var l=Object.defineProperty;var y=Object.getOwnPropertyDescriptor;var R=Object.getOwnPropertyNames;var I=Object.prototype.hasOwnProperty;var O=(a,e)=>{for(var t in e)l(a,t,{get:e[t],enumerable:!0})},T=(a,e,t,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let s of R(e))!I.call(a,s)&&s!==t&&l(a,s,{get:()=>e[s],enumerable:!(i=y(e,s))||i.enumerable});return a};var x=a=>T(l({},"__esModule",{value:!0}),a);var P={};O(P,{DeviceSession:()=>w});module.exports=x(P);var o=require("rxjs"),S=require("uuid"),D=require("../../../api/command/utils/CommandUtils"),h=require("../../../api/device/DeviceStatus"),_=require("../../../api/device-session/DeviceSessionState"),p=require("../../../api/transport/model/Errors"),v=require("../../../api/utils/apduLogs"),g=require("../../device-session/data/DeviceSessionRefresherConst"),f=require("../../device-session/service/IntentQueueService"),E=require("../../device-session/service/RefresherService"),b=require("./DevicePinger"),u=require("./DeviceSessionEventDispatcher"),A=require("./DeviceSessionRefresher"),C=require("./DeviceSessionStateHandler");class w{_id;_connectedDevice;_deviceState;_managerApiService;_secureChannelService;_logger;_loggerModuleFactory;_refresherOptions;_pinger;_deviceSessionRefresher;_refresherService;_intentQueueService;_sessionEventDispatcher=new u.DeviceSessionEventDispatcher;_bypassIntentQueue=!1;constructor({connectedDevice:e,id:t=(0,S.v4)()},i,s,n,r,d=c=>new f.IntentQueueService(i,c)){this._id=t,this._connectedDevice=e,this._loggerModuleFactory=i,this._logger=i("device-session"),this._managerApiService=s,this._intentQueueService=d(this._sessionEventDispatcher),this._secureChannelService=n,this._refresherOptions={...g.DEVICE_SESSION_REFRESHER_DEFAULT_OPTIONS,...r},this._deviceState=new o.BehaviorSubject({sessionStateType:_.DeviceSessionStateType.Connected,deviceStatus:h.DeviceStatus.CONNECTED,deviceModelId:this._connectedDevice.deviceModel.id}),this._pinger=new b.DevicePinger(i,e,this._sessionEventDispatcher,(c,m)=>this.sendCommand(c,m)),this._deviceSessionRefresher=new A.DeviceSessionRefresher(i,this._refresherOptions,this._sessionEventDispatcher,this._connectedDevice),new C.DeviceSessionStateHandler(i,this._sessionEventDispatcher,this._connectedDevice,this._deviceState,c=>this.setDeviceSessionState(c)),this._refresherService=new E.RefresherService(i,{start:()=>this._deviceSessionRefresher.restartRefresher(),stop:()=>this._deviceSessionRefresher.stopRefresher()})}async initialiseSession(){try{this._refresherOptions.isRefresherDisabled?await this._pinger.ping():this._deviceSessionRefresher.startRefresher()}catch(e){throw this._logger.error("Error while initialising session",{data:{error:e}}),e}}get id(){return this._id}get connectedDevice(){return this._connectedDevice}get state(){return this._deviceState.asObservable()}getDeviceSessionState(){return this._deviceState.getValue()}setDeviceSessionState(e){this._deviceState.next(e)}sendApdu(e,t={isPolling:!1,triggersDisconnection:!1,abortTimeout:void 0}){return this._bypassIntentQueue?this._unsafeInternalSendApdu(e,t):this._internalSendApdu(e,t)}_internalSendApdu(e,t){const i=t.abortTimeout,s=Date.now(),{observable:n,cancel:r}=this._intentQueueService.enqueue({type:"send-apdu",execute:()=>(0,o.from)((async()=>{const c=Date.now()-s;return await this._unsafeInternalSendApdu(e,{isPolling:t.isPolling,triggersDisconnection:t.triggersDisconnection,abortTimeout:i?i-c:void 0})})())}),d=i?n.pipe((0,o.timeout)({each:i,with:()=>{throw r(),new p.SendApduTimeoutError}})):n;return(0,o.lastValueFrom)(d)}async _unsafeInternalSendApdu(e,t={isPolling:!1,triggersDisconnection:!1,abortTimeout:void 0}){return this._logger.debug((0,v.formatApduSendingLog)(e)),(await this._connectedDevice.sendApdu(e,t.triggersDisconnection,t.abortTimeout)).ifRight(s=>{const{message:n,data:r}=(0,v.formatApduExchangeLog)(this._id,e,s);this._logger.debug(n,{data:r}),D.CommandUtils.isLockedDeviceResponse(s)?this._sessionEventDispatcher.dispatch({eventName:u.SessionEvents.DEVICE_STATE_UPDATE_LOCKED}):this._sessionEventDispatcher.dispatch({eventName:u.SessionEvents.DEVICE_STATE_UPDATE_CONNECTED})}).ifLeft(()=>{this._sessionEventDispatcher.dispatch({eventName:u.SessionEvents.DEVICE_STATE_UPDATE_UNKNOWN})})}sendCommand(e,t){return this._logger.debug(`[sendCommand] ${e.name}`),this._bypassIntentQueue?this._unsafeInternalSendCommand(e,t):this._internalSendCommand(e,t)}_internalSendCommand(e,t){const i=Date.now(),{observable:s,cancel:n}=this._intentQueueService.enqueue({type:"send-command",execute:()=>(0,o.from)((async()=>{const d=Date.now()-i;return await this._unsafeInternalSendCommand(e,t?t-d:void 0)})())}),r=t?s.pipe((0,o.timeout)({each:t,with:()=>{throw n(),new p.SendCommandTimeoutError}})):s;return(0,o.lastValueFrom)(r)}async _unsafeInternalSendCommand(e,t){const i=e.getApdu();return(await this._unsafeInternalSendApdu(i.getRawApdu(),{isPolling:!1,triggersDisconnection:e.triggersDisconnection??!1,abortTimeout:t})).caseOf({Left:n=>{throw this._logger.error("[sendCommand] error",{data:{err:n}}),n},Right:n=>{const r=e.parseResponse(n,this._connectedDevice.deviceModel.id);return this._logger.debug("[sendCommand] result",{data:{result:r}}),r}})}executeDeviceAction(e){return this._bypassIntentQueue?this._unsafeInternalExecuteDeviceAction(e):this._internalExecuteDeviceAction(e)}_internalExecuteDeviceAction(e){let t;const{observable:i,cancel:s}=this._intentQueueService.enqueue({type:"device-action",execute:()=>{const{observable:n,cancel:r}=this._unsafeInternalExecuteDeviceAction(e);return t=r,n}});return{observable:i,cancel:()=>{t?.(),s()}}}_unsafeInternalExecuteDeviceAction(e){const{observable:t,cancel:i}=e._execute({sendApdu:async s=>this._unsafeInternalSendApdu(s),sendCommand:async s=>this._unsafeInternalSendCommand(s),getDeviceModel:()=>this._connectedDevice.deviceModel,getDeviceSessionState:()=>this._deviceState.getValue(),getDeviceSessionStateObservable:()=>this.state,setDeviceSessionState:s=>(this.setDeviceSessionState(s),this._deviceState.getValue()),getManagerApiService:()=>this._managerApiService,getSecureChannelService:()=>this._secureChannelService,loggerFactory:this._loggerModuleFactory});return{observable:t,cancel:i}}close(){this._updateDeviceStatus(h.DeviceStatus.NOT_CONNECTED),this._deviceState.complete(),this._deviceSessionRefresher.stopRefresher(),this._pinger.unsubscribe()}disableRefresher(e){return this._refresherService.disableRefresher(e)}_unsafeBypassIntentQueue(e){this._bypassIntentQueue=e}_updateDeviceStatus(e){const t=this._deviceState.getValue();this._deviceState.next({...t,deviceStatus:e})}}0&&(module.exports={DeviceSession});
2
2
  //# sourceMappingURL=DeviceSession.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../../../src/internal/device-session/model/DeviceSession.ts"],
4
- "sourcesContent": ["import { type Either } from \"purify-ts\";\nimport {\n BehaviorSubject,\n from,\n lastValueFrom,\n type Observable,\n timeout,\n} from \"rxjs\";\nimport { v4 as uuidv4 } from \"uuid\";\n\nimport { type Command } from \"@api/command/Command\";\nimport { type CommandResult } from \"@api/command/model/CommandResult\";\nimport { CommandUtils } from \"@api/command/utils/CommandUtils\";\nimport { DeviceStatus } from \"@api/device/DeviceStatus\";\nimport {\n type DeviceAction,\n type DeviceActionIntermediateValue,\n type ExecuteDeviceActionReturnType,\n} from \"@api/device-action/DeviceAction\";\nimport { type ApduResponse } from \"@api/device-session/ApduResponse\";\nimport {\n type DeviceSessionState,\n DeviceSessionStateType,\n} from \"@api/device-session/DeviceSessionState\";\nimport { type DeviceSessionId } from \"@api/device-session/types\";\nimport { type DmkError } from \"@api/Error\";\nimport { type LoggerPublisherService } from \"@api/logger-publisher/service/LoggerPublisherService\";\nimport {\n SendApduTimeoutError,\n SendCommandTimeoutError,\n} from \"@api/transport/model/Errors\";\nimport { type TransportConnectedDevice } from \"@api/transport/model/TransportConnectedDevice\";\nimport {\n formatApduReceivedLog,\n formatApduSendingLog,\n} from \"@api/utils/apduLogs\";\nimport { DEVICE_SESSION_REFRESHER_DEFAULT_OPTIONS } from \"@internal/device-session/data/DeviceSessionRefresherConst\";\nimport { IntentQueueService } from \"@internal/device-session/service/IntentQueueService\";\nimport { RefresherService } from \"@internal/device-session/service/RefresherService\";\nimport { type ManagerApiService } from \"@internal/manager-api/service/ManagerApiService\";\nimport { type SecureChannelService } from \"@internal/secure-channel/service/SecureChannelService\";\n\nimport { DevicePinger } from \"./DevicePinger\";\nimport {\n DeviceSessionEventDispatcher,\n SessionEvents,\n} from \"./DeviceSessionEventDispatcher\";\nimport { DeviceSessionRefresher } from \"./DeviceSessionRefresher\";\nimport { DeviceSessionStateHandler } from \"./DeviceSessionStateHandler\";\n\nexport type SessionConstructorArgs = {\n connectedDevice: TransportConnectedDevice;\n id?: DeviceSessionId;\n};\n\nexport type DeviceSessionRefresherOptions = {\n isRefresherDisabled: boolean;\n pollingInterval?: number;\n};\n\ntype SendApduOptions = {\n isPolling?: boolean;\n triggersDisconnection?: boolean;\n abortTimeout?: number;\n};\n\n/**\n * Represents a session with a device.\n */\nexport class DeviceSession {\n private readonly _id: DeviceSessionId;\n private readonly _connectedDevice: TransportConnectedDevice;\n private readonly _deviceState: BehaviorSubject<DeviceSessionState>;\n private readonly _managerApiService: ManagerApiService;\n private readonly _secureChannelService: SecureChannelService;\n private readonly _logger: LoggerPublisherService;\n private readonly _loggerModuleFactory: (\n tag: string,\n ) => LoggerPublisherService;\n private readonly _refresherOptions: DeviceSessionRefresherOptions;\n private _pinger: DevicePinger;\n private _deviceSessionRefresher: DeviceSessionRefresher;\n private readonly _refresherService: RefresherService;\n private readonly _intentQueueService: IntentQueueService;\n private _sessionEventDispatcher = new DeviceSessionEventDispatcher();\n private _bypassIntentQueue: boolean = false;\n\n constructor(\n { connectedDevice, id = uuidv4() }: SessionConstructorArgs,\n loggerModuleFactory: (tag: string) => LoggerPublisherService,\n managerApiService: ManagerApiService,\n secureChannelService: SecureChannelService,\n deviceSessionRefresherOptions: DeviceSessionRefresherOptions | undefined,\n intentQueueServiceFactory: (\n sessionEventDispatcher: DeviceSessionEventDispatcher,\n ) => IntentQueueService = (sessionEventDispatcher) =>\n new IntentQueueService(loggerModuleFactory, sessionEventDispatcher),\n ) {\n this._id = id;\n this._connectedDevice = connectedDevice;\n this._loggerModuleFactory = loggerModuleFactory;\n this._logger = loggerModuleFactory(\"device-session\");\n this._managerApiService = managerApiService;\n this._intentQueueService = intentQueueServiceFactory(\n this._sessionEventDispatcher,\n );\n this._secureChannelService = secureChannelService;\n this._refresherOptions = {\n ...DEVICE_SESSION_REFRESHER_DEFAULT_OPTIONS,\n ...deviceSessionRefresherOptions,\n };\n this._deviceState = new BehaviorSubject<DeviceSessionState>({\n sessionStateType: DeviceSessionStateType.Connected,\n deviceStatus: DeviceStatus.CONNECTED,\n deviceModelId: this._connectedDevice.deviceModel.id,\n });\n\n this._pinger = new DevicePinger(\n loggerModuleFactory,\n connectedDevice,\n this._sessionEventDispatcher,\n (command, abortTimeout) => this.sendCommand(command, abortTimeout),\n );\n this._deviceSessionRefresher = new DeviceSessionRefresher(\n loggerModuleFactory,\n this._refresherOptions,\n this._sessionEventDispatcher,\n this._connectedDevice,\n );\n new DeviceSessionStateHandler(\n loggerModuleFactory,\n this._sessionEventDispatcher,\n this._connectedDevice,\n this._deviceState,\n (state) => this.setDeviceSessionState(state),\n );\n\n this._refresherService = new RefresherService(loggerModuleFactory, {\n start: () => this._deviceSessionRefresher.restartRefresher(),\n stop: () => this._deviceSessionRefresher.stopRefresher(),\n });\n }\n\n public async initialiseSession(): Promise<void> {\n try {\n if (this._refresherOptions.isRefresherDisabled) await this._pinger.ping();\n else this._deviceSessionRefresher.startRefresher();\n } catch (error) {\n this._logger.error(\"Error while initialising session\", {\n data: { error },\n });\n throw error;\n }\n }\n\n public get id(): DeviceSessionId {\n return this._id;\n }\n\n public get connectedDevice(): TransportConnectedDevice {\n return this._connectedDevice;\n }\n\n public get state(): Observable<DeviceSessionState> {\n return this._deviceState.asObservable();\n }\n\n public getDeviceSessionState(): DeviceSessionState {\n return this._deviceState.getValue();\n }\n\n public setDeviceSessionState(state: DeviceSessionState): void {\n this._deviceState.next(state);\n }\n\n public sendApdu(\n rawApdu: Uint8Array,\n options: SendApduOptions = {\n isPolling: false,\n triggersDisconnection: false,\n abortTimeout: undefined,\n },\n ): Promise<Either<DmkError, ApduResponse>> {\n // Bypass intent queue if flag is set\n if (this._bypassIntentQueue) {\n return this._unsafeInternalSendApdu(rawApdu, options);\n }\n return this._internalSendApdu(rawApdu, options);\n }\n\n private _internalSendApdu(\n rawApdu: Uint8Array,\n options: SendApduOptions,\n ): Promise<Either<DmkError, ApduResponse>> {\n const abortTimeout = options.abortTimeout;\n const beforeQueuedTimestamp = Date.now();\n const { observable, cancel } = this._intentQueueService.enqueue({\n type: \"send-apdu\",\n execute: () =>\n from(\n (async () => {\n const elapsedTime = Date.now() - beforeQueuedTimestamp;\n const result = await this._unsafeInternalSendApdu(rawApdu, {\n isPolling: options.isPolling,\n triggersDisconnection: options.triggersDisconnection,\n // Subtract the elapsed time to account for the time spent in the queue\n // to sync both observable and transport timeout\n abortTimeout: abortTimeout\n ? abortTimeout - elapsedTime\n : undefined,\n });\n return result;\n })(),\n ),\n });\n\n const timeoutObservable = abortTimeout\n ? observable.pipe(\n timeout({\n each: abortTimeout,\n with: () => {\n cancel();\n throw new SendApduTimeoutError();\n },\n }),\n )\n : observable;\n\n return lastValueFrom(timeoutObservable);\n }\n\n private async _unsafeInternalSendApdu(\n rawApdu: Uint8Array,\n options: SendApduOptions = {\n isPolling: false,\n triggersDisconnection: false,\n abortTimeout: undefined,\n },\n ): Promise<Either<DmkError, ApduResponse>> {\n this._logger.debug(formatApduSendingLog(rawApdu));\n const result = await this._connectedDevice.sendApdu(\n rawApdu,\n options.triggersDisconnection,\n options.abortTimeout,\n );\n\n return result\n .ifRight((response: ApduResponse) => {\n this._logger.debug(formatApduReceivedLog(response));\n if (CommandUtils.isLockedDeviceResponse(response)) {\n this._sessionEventDispatcher.dispatch({\n eventName: SessionEvents.DEVICE_STATE_UPDATE_LOCKED,\n });\n } else {\n this._sessionEventDispatcher.dispatch({\n eventName: SessionEvents.DEVICE_STATE_UPDATE_CONNECTED,\n });\n }\n })\n .ifLeft(() => {\n this._sessionEventDispatcher.dispatch({\n eventName: SessionEvents.DEVICE_STATE_UPDATE_UNKNOWN,\n });\n });\n }\n\n public sendCommand<Response, Args, ErrorStatusCodes>(\n command: Command<Response, Args, ErrorStatusCodes>,\n abortTimeout?: number,\n ): Promise<CommandResult<Response, ErrorStatusCodes>> {\n this._logger.debug(`[sendCommand] ${command.name}`);\n\n // Bypass intent queue if flag is set\n if (this._bypassIntentQueue) {\n return this._unsafeInternalSendCommand(command, abortTimeout);\n }\n return this._internalSendCommand(command, abortTimeout);\n }\n\n private _internalSendCommand<Response, Args, ErrorStatusCodes>(\n command: Command<Response, Args, ErrorStatusCodes>,\n abortTimeout?: number,\n ): Promise<CommandResult<Response, ErrorStatusCodes>> {\n const beforeQueuedTimestamp = Date.now();\n const { observable, cancel } = this._intentQueueService.enqueue({\n type: \"send-command\",\n execute: () =>\n from(\n (async () => {\n const elapsedTime = Date.now() - beforeQueuedTimestamp;\n const result = await this._unsafeInternalSendCommand(\n command,\n // Subtract the elapsed time to account for the time spent in the queue\n // to sync both observable and transport timeout\n abortTimeout ? abortTimeout - elapsedTime : undefined,\n );\n return result;\n })(),\n ),\n });\n\n const timeoutObservable = abortTimeout\n ? observable.pipe(\n timeout({\n each: abortTimeout,\n with: () => {\n cancel();\n throw new SendCommandTimeoutError();\n },\n }),\n )\n : observable;\n\n return lastValueFrom(timeoutObservable);\n }\n\n private async _unsafeInternalSendCommand<Response, Args, ErrorStatusCodes>(\n command: Command<Response, Args, ErrorStatusCodes>,\n abortTimeout?: number,\n ): Promise<CommandResult<Response, ErrorStatusCodes>> {\n const apdu = command.getApdu();\n\n const response = await this._unsafeInternalSendApdu(apdu.getRawApdu(), {\n isPolling: false,\n triggersDisconnection: command.triggersDisconnection ?? false,\n abortTimeout,\n });\n\n return response.caseOf({\n Left: (err) => {\n this._logger.error(\"[sendCommand] error\", { data: { err } });\n throw err;\n },\n Right: (r) => {\n const result = command.parseResponse(\n r,\n this._connectedDevice.deviceModel.id,\n );\n this._logger.debug(\"[sendCommand] result\", { data: { result } });\n return result;\n },\n });\n }\n\n public executeDeviceAction<\n Output,\n Input,\n E extends DmkError,\n IntermediateValue extends DeviceActionIntermediateValue,\n >(\n deviceAction: DeviceAction<Output, Input, E, IntermediateValue>,\n ): ExecuteDeviceActionReturnType<Output, E, IntermediateValue> {\n // Bypass intent queue if flag is set\n if (this._bypassIntentQueue) {\n return this._unsafeInternalExecuteDeviceAction(deviceAction);\n }\n return this._internalExecuteDeviceAction(deviceAction);\n }\n\n private _internalExecuteDeviceAction<\n Output,\n Input,\n E extends DmkError,\n IntermediateValue extends DeviceActionIntermediateValue,\n >(\n deviceAction: DeviceAction<Output, Input, E, IntermediateValue>,\n ): ExecuteDeviceActionReturnType<Output, E, IntermediateValue> {\n let deviceActionCancel: (() => void) | undefined;\n\n const { observable: o, cancel: queueCancel } =\n this._intentQueueService.enqueue({\n type: \"device-action\",\n execute: () => {\n const { observable, cancel } =\n this._unsafeInternalExecuteDeviceAction(deviceAction);\n deviceActionCancel = cancel;\n return observable;\n },\n });\n\n return {\n observable: o,\n cancel: () => {\n deviceActionCancel?.();\n queueCancel();\n },\n };\n }\n\n private _unsafeInternalExecuteDeviceAction<\n Output,\n Input,\n E extends DmkError,\n IntermediateValue extends DeviceActionIntermediateValue,\n >(\n deviceAction: DeviceAction<Output, Input, E, IntermediateValue>,\n ): ExecuteDeviceActionReturnType<Output, E, IntermediateValue> {\n const { observable, cancel } = deviceAction._execute({\n sendApdu: async (apdu: Uint8Array) => this._unsafeInternalSendApdu(apdu), // note: there is no timeout handled at this stage\n sendCommand: async <Response, ErrorStatusCodes, Args>(\n command: Command<Response, ErrorStatusCodes, Args>,\n ) => this._unsafeInternalSendCommand(command), // note: there is no timeout handled at this stage\n getDeviceModel: () => this._connectedDevice.deviceModel,\n getDeviceSessionState: () => this._deviceState.getValue(),\n getDeviceSessionStateObservable: () => this.state,\n setDeviceSessionState: (state: DeviceSessionState) => {\n this.setDeviceSessionState(state);\n return this._deviceState.getValue();\n },\n getManagerApiService: () => this._managerApiService,\n getSecureChannelService: () => this._secureChannelService,\n loggerFactory: this._loggerModuleFactory,\n });\n\n return {\n observable,\n cancel,\n };\n }\n\n public close(): void {\n this._updateDeviceStatus(DeviceStatus.NOT_CONNECTED);\n this._deviceState.complete();\n this._deviceSessionRefresher.stopRefresher();\n this._pinger.unsubscribe();\n }\n\n public disableRefresher(id: string): () => void {\n return this._refresherService.disableRefresher(id);\n }\n\n public _unsafeBypassIntentQueue(bypass: boolean): void {\n this._bypassIntentQueue = bypass;\n }\n\n private _updateDeviceStatus(deviceStatus: DeviceStatus): void {\n const state = this._deviceState.getValue();\n this._deviceState.next({ ...state, deviceStatus });\n }\n}\n"],
5
- "mappings": "yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,mBAAAE,IAAA,eAAAC,EAAAH,GACA,IAAAI,EAMO,gBACPC,EAA6B,gBAI7BC,EAA6B,2CAC7BC,EAA6B,oCAO7BC,EAGO,kDAIPC,EAGO,uCAEPC,EAGO,+BACPC,EAAyD,qEACzDC,EAAmC,+DACnCC,EAAiC,6DAIjCC,EAA6B,0BAC7BC,EAGO,0CACPC,EAAuC,oCACvCC,EAA0C,uCAqBnC,MAAMf,CAAc,CACR,IACA,iBACA,aACA,mBACA,sBACA,QACA,qBAGA,kBACT,QACA,wBACS,kBACA,oBACT,wBAA0B,IAAI,+BAC9B,mBAA8B,GAEtC,YACE,CAAE,gBAAAgB,EAAiB,GAAAC,KAAK,EAAAC,IAAO,CAAE,EACjC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,SAAS,EACzC,KAAK,aAAa,KAAK,CAAE,GAAGA,EAAO,aAAAmB,CAAa,CAAC,CACnD,CACF",
6
- "names": ["DeviceSession_exports", "__export", "DeviceSession", "__toCommonJS", "import_rxjs", "import_uuid", "import_CommandUtils", "import_DeviceStatus", "import_DeviceSessionState", "import_Errors", "import_apduLogs", "import_DeviceSessionRefresherConst", "import_IntentQueueService", "import_RefresherService", "import_DevicePinger", "import_DeviceSessionEventDispatcher", "import_DeviceSessionRefresher", "import_DeviceSessionStateHandler", "connectedDevice", "id", "uuidv4", "loggerModuleFactory", "managerApiService", "secureChannelService", "deviceSessionRefresherOptions", "intentQueueServiceFactory", "sessionEventDispatcher", "command", "abortTimeout", "state", "error", "rawApdu", "options", "beforeQueuedTimestamp", "observable", "cancel", "elapsedTime", "timeoutObservable", "response", "apdu", "err", "r", "result", "deviceAction", "deviceActionCancel", "o", "queueCancel", "bypass", "deviceStatus"]
4
+ "sourcesContent": ["import { type Either } from \"purify-ts\";\nimport {\n BehaviorSubject,\n from,\n lastValueFrom,\n type Observable,\n timeout,\n} from \"rxjs\";\nimport { v4 as uuidv4 } from \"uuid\";\n\nimport { type Command } from \"@api/command/Command\";\nimport { type CommandResult } from \"@api/command/model/CommandResult\";\nimport { CommandUtils } from \"@api/command/utils/CommandUtils\";\nimport { DeviceStatus } from \"@api/device/DeviceStatus\";\nimport {\n type DeviceAction,\n type DeviceActionIntermediateValue,\n type ExecuteDeviceActionReturnType,\n} from \"@api/device-action/DeviceAction\";\nimport { type ApduResponse } from \"@api/device-session/ApduResponse\";\nimport {\n type DeviceSessionState,\n DeviceSessionStateType,\n} from \"@api/device-session/DeviceSessionState\";\nimport { type DeviceSessionId } from \"@api/device-session/types\";\nimport { type DmkError } from \"@api/Error\";\nimport { type LoggerPublisherService } from \"@api/logger-publisher/service/LoggerPublisherService\";\nimport {\n SendApduTimeoutError,\n SendCommandTimeoutError,\n} from \"@api/transport/model/Errors\";\nimport { type TransportConnectedDevice } from \"@api/transport/model/TransportConnectedDevice\";\nimport {\n formatApduExchangeLog,\n formatApduSendingLog,\n} from \"@api/utils/apduLogs\";\nimport { DEVICE_SESSION_REFRESHER_DEFAULT_OPTIONS } from \"@internal/device-session/data/DeviceSessionRefresherConst\";\nimport { IntentQueueService } from \"@internal/device-session/service/IntentQueueService\";\nimport { RefresherService } from \"@internal/device-session/service/RefresherService\";\nimport { type ManagerApiService } from \"@internal/manager-api/service/ManagerApiService\";\nimport { type SecureChannelService } from \"@internal/secure-channel/service/SecureChannelService\";\n\nimport { DevicePinger } from \"./DevicePinger\";\nimport {\n DeviceSessionEventDispatcher,\n SessionEvents,\n} from \"./DeviceSessionEventDispatcher\";\nimport { DeviceSessionRefresher } from \"./DeviceSessionRefresher\";\nimport { DeviceSessionStateHandler } from \"./DeviceSessionStateHandler\";\n\nexport type SessionConstructorArgs = {\n connectedDevice: TransportConnectedDevice;\n id?: DeviceSessionId;\n};\n\nexport type DeviceSessionRefresherOptions = {\n isRefresherDisabled: boolean;\n pollingInterval?: number;\n};\n\ntype SendApduOptions = {\n isPolling?: boolean;\n triggersDisconnection?: boolean;\n abortTimeout?: number;\n};\n\n/**\n * Represents a session with a device.\n */\nexport class DeviceSession {\n private readonly _id: DeviceSessionId;\n private readonly _connectedDevice: TransportConnectedDevice;\n private readonly _deviceState: BehaviorSubject<DeviceSessionState>;\n private readonly _managerApiService: ManagerApiService;\n private readonly _secureChannelService: SecureChannelService;\n private readonly _logger: LoggerPublisherService;\n private readonly _loggerModuleFactory: (\n tag: string,\n ) => LoggerPublisherService;\n private readonly _refresherOptions: DeviceSessionRefresherOptions;\n private _pinger: DevicePinger;\n private _deviceSessionRefresher: DeviceSessionRefresher;\n private readonly _refresherService: RefresherService;\n private readonly _intentQueueService: IntentQueueService;\n private _sessionEventDispatcher = new DeviceSessionEventDispatcher();\n private _bypassIntentQueue: boolean = false;\n\n constructor(\n { connectedDevice, id = uuidv4() }: SessionConstructorArgs,\n loggerModuleFactory: (tag: string) => LoggerPublisherService,\n managerApiService: ManagerApiService,\n secureChannelService: SecureChannelService,\n deviceSessionRefresherOptions: DeviceSessionRefresherOptions | undefined,\n intentQueueServiceFactory: (\n sessionEventDispatcher: DeviceSessionEventDispatcher,\n ) => IntentQueueService = (sessionEventDispatcher) =>\n new IntentQueueService(loggerModuleFactory, sessionEventDispatcher),\n ) {\n this._id = id;\n this._connectedDevice = connectedDevice;\n this._loggerModuleFactory = loggerModuleFactory;\n this._logger = loggerModuleFactory(\"device-session\");\n this._managerApiService = managerApiService;\n this._intentQueueService = intentQueueServiceFactory(\n this._sessionEventDispatcher,\n );\n this._secureChannelService = secureChannelService;\n this._refresherOptions = {\n ...DEVICE_SESSION_REFRESHER_DEFAULT_OPTIONS,\n ...deviceSessionRefresherOptions,\n };\n this._deviceState = new BehaviorSubject<DeviceSessionState>({\n sessionStateType: DeviceSessionStateType.Connected,\n deviceStatus: DeviceStatus.CONNECTED,\n deviceModelId: this._connectedDevice.deviceModel.id,\n });\n\n this._pinger = new DevicePinger(\n loggerModuleFactory,\n connectedDevice,\n this._sessionEventDispatcher,\n (command, abortTimeout) => this.sendCommand(command, abortTimeout),\n );\n this._deviceSessionRefresher = new DeviceSessionRefresher(\n loggerModuleFactory,\n this._refresherOptions,\n this._sessionEventDispatcher,\n this._connectedDevice,\n );\n new DeviceSessionStateHandler(\n loggerModuleFactory,\n this._sessionEventDispatcher,\n this._connectedDevice,\n this._deviceState,\n (state) => this.setDeviceSessionState(state),\n );\n\n this._refresherService = new RefresherService(loggerModuleFactory, {\n start: () => this._deviceSessionRefresher.restartRefresher(),\n stop: () => this._deviceSessionRefresher.stopRefresher(),\n });\n }\n\n public async initialiseSession(): Promise<void> {\n try {\n if (this._refresherOptions.isRefresherDisabled) await this._pinger.ping();\n else this._deviceSessionRefresher.startRefresher();\n } catch (error) {\n this._logger.error(\"Error while initialising session\", {\n data: { error },\n });\n throw error;\n }\n }\n\n public get id(): DeviceSessionId {\n return this._id;\n }\n\n public get connectedDevice(): TransportConnectedDevice {\n return this._connectedDevice;\n }\n\n public get state(): Observable<DeviceSessionState> {\n return this._deviceState.asObservable();\n }\n\n public getDeviceSessionState(): DeviceSessionState {\n return this._deviceState.getValue();\n }\n\n public setDeviceSessionState(state: DeviceSessionState): void {\n this._deviceState.next(state);\n }\n\n public sendApdu(\n rawApdu: Uint8Array,\n options: SendApduOptions = {\n isPolling: false,\n triggersDisconnection: false,\n abortTimeout: undefined,\n },\n ): Promise<Either<DmkError, ApduResponse>> {\n // Bypass intent queue if flag is set\n if (this._bypassIntentQueue) {\n return this._unsafeInternalSendApdu(rawApdu, options);\n }\n return this._internalSendApdu(rawApdu, options);\n }\n\n private _internalSendApdu(\n rawApdu: Uint8Array,\n options: SendApduOptions,\n ): Promise<Either<DmkError, ApduResponse>> {\n const abortTimeout = options.abortTimeout;\n const beforeQueuedTimestamp = Date.now();\n const { observable, cancel } = this._intentQueueService.enqueue({\n type: \"send-apdu\",\n execute: () =>\n from(\n (async () => {\n const elapsedTime = Date.now() - beforeQueuedTimestamp;\n const result = await this._unsafeInternalSendApdu(rawApdu, {\n isPolling: options.isPolling,\n triggersDisconnection: options.triggersDisconnection,\n // Subtract the elapsed time to account for the time spent in the queue\n // to sync both observable and transport timeout\n abortTimeout: abortTimeout\n ? abortTimeout - elapsedTime\n : undefined,\n });\n return result;\n })(),\n ),\n });\n\n const timeoutObservable = abortTimeout\n ? observable.pipe(\n timeout({\n each: abortTimeout,\n with: () => {\n cancel();\n throw new SendApduTimeoutError();\n },\n }),\n )\n : observable;\n\n return lastValueFrom(timeoutObservable);\n }\n\n private async _unsafeInternalSendApdu(\n rawApdu: Uint8Array,\n options: SendApduOptions = {\n isPolling: false,\n triggersDisconnection: false,\n abortTimeout: undefined,\n },\n ): Promise<Either<DmkError, ApduResponse>> {\n this._logger.debug(formatApduSendingLog(rawApdu));\n const result = await this._connectedDevice.sendApdu(\n rawApdu,\n options.triggersDisconnection,\n options.abortTimeout,\n );\n\n return result\n .ifRight((response: ApduResponse) => {\n const { message, data } = formatApduExchangeLog(\n this._id,\n rawApdu,\n response,\n );\n this._logger.debug(message, { data });\n if (CommandUtils.isLockedDeviceResponse(response)) {\n this._sessionEventDispatcher.dispatch({\n eventName: SessionEvents.DEVICE_STATE_UPDATE_LOCKED,\n });\n } else {\n this._sessionEventDispatcher.dispatch({\n eventName: SessionEvents.DEVICE_STATE_UPDATE_CONNECTED,\n });\n }\n })\n .ifLeft(() => {\n this._sessionEventDispatcher.dispatch({\n eventName: SessionEvents.DEVICE_STATE_UPDATE_UNKNOWN,\n });\n });\n }\n\n public sendCommand<Response, Args, ErrorStatusCodes>(\n command: Command<Response, Args, ErrorStatusCodes>,\n abortTimeout?: number,\n ): Promise<CommandResult<Response, ErrorStatusCodes>> {\n this._logger.debug(`[sendCommand] ${command.name}`);\n\n // Bypass intent queue if flag is set\n if (this._bypassIntentQueue) {\n return this._unsafeInternalSendCommand(command, abortTimeout);\n }\n return this._internalSendCommand(command, abortTimeout);\n }\n\n private _internalSendCommand<Response, Args, ErrorStatusCodes>(\n command: Command<Response, Args, ErrorStatusCodes>,\n abortTimeout?: number,\n ): Promise<CommandResult<Response, ErrorStatusCodes>> {\n const beforeQueuedTimestamp = Date.now();\n const { observable, cancel } = this._intentQueueService.enqueue({\n type: \"send-command\",\n execute: () =>\n from(\n (async () => {\n const elapsedTime = Date.now() - beforeQueuedTimestamp;\n const result = await this._unsafeInternalSendCommand(\n command,\n // Subtract the elapsed time to account for the time spent in the queue\n // to sync both observable and transport timeout\n abortTimeout ? abortTimeout - elapsedTime : undefined,\n );\n return result;\n })(),\n ),\n });\n\n const timeoutObservable = abortTimeout\n ? observable.pipe(\n timeout({\n each: abortTimeout,\n with: () => {\n cancel();\n throw new SendCommandTimeoutError();\n },\n }),\n )\n : observable;\n\n return lastValueFrom(timeoutObservable);\n }\n\n private async _unsafeInternalSendCommand<Response, Args, ErrorStatusCodes>(\n command: Command<Response, Args, ErrorStatusCodes>,\n abortTimeout?: number,\n ): Promise<CommandResult<Response, ErrorStatusCodes>> {\n const apdu = command.getApdu();\n\n const response = await this._unsafeInternalSendApdu(apdu.getRawApdu(), {\n isPolling: false,\n triggersDisconnection: command.triggersDisconnection ?? false,\n abortTimeout,\n });\n\n return response.caseOf({\n Left: (err) => {\n this._logger.error(\"[sendCommand] error\", { data: { err } });\n throw err;\n },\n Right: (r) => {\n const result = command.parseResponse(\n r,\n this._connectedDevice.deviceModel.id,\n );\n this._logger.debug(\"[sendCommand] result\", { data: { result } });\n return result;\n },\n });\n }\n\n public executeDeviceAction<\n Output,\n Input,\n E extends DmkError,\n IntermediateValue extends DeviceActionIntermediateValue,\n >(\n deviceAction: DeviceAction<Output, Input, E, IntermediateValue>,\n ): ExecuteDeviceActionReturnType<Output, E, IntermediateValue> {\n // Bypass intent queue if flag is set\n if (this._bypassIntentQueue) {\n return this._unsafeInternalExecuteDeviceAction(deviceAction);\n }\n return this._internalExecuteDeviceAction(deviceAction);\n }\n\n private _internalExecuteDeviceAction<\n Output,\n Input,\n E extends DmkError,\n IntermediateValue extends DeviceActionIntermediateValue,\n >(\n deviceAction: DeviceAction<Output, Input, E, IntermediateValue>,\n ): ExecuteDeviceActionReturnType<Output, E, IntermediateValue> {\n let deviceActionCancel: (() => void) | undefined;\n\n const { observable: o, cancel: queueCancel } =\n this._intentQueueService.enqueue({\n type: \"device-action\",\n execute: () => {\n const { observable, cancel } =\n this._unsafeInternalExecuteDeviceAction(deviceAction);\n deviceActionCancel = cancel;\n return observable;\n },\n });\n\n return {\n observable: o,\n cancel: () => {\n deviceActionCancel?.();\n queueCancel();\n },\n };\n }\n\n private _unsafeInternalExecuteDeviceAction<\n Output,\n Input,\n E extends DmkError,\n IntermediateValue extends DeviceActionIntermediateValue,\n >(\n deviceAction: DeviceAction<Output, Input, E, IntermediateValue>,\n ): ExecuteDeviceActionReturnType<Output, E, IntermediateValue> {\n const { observable, cancel } = deviceAction._execute({\n sendApdu: async (apdu: Uint8Array) => this._unsafeInternalSendApdu(apdu), // note: there is no timeout handled at this stage\n sendCommand: async <Response, ErrorStatusCodes, Args>(\n command: Command<Response, ErrorStatusCodes, Args>,\n ) => this._unsafeInternalSendCommand(command), // note: there is no timeout handled at this stage\n getDeviceModel: () => this._connectedDevice.deviceModel,\n getDeviceSessionState: () => this._deviceState.getValue(),\n getDeviceSessionStateObservable: () => this.state,\n setDeviceSessionState: (state: DeviceSessionState) => {\n this.setDeviceSessionState(state);\n return this._deviceState.getValue();\n },\n getManagerApiService: () => this._managerApiService,\n getSecureChannelService: () => this._secureChannelService,\n loggerFactory: this._loggerModuleFactory,\n });\n\n return {\n observable,\n cancel,\n };\n }\n\n public close(): void {\n this._updateDeviceStatus(DeviceStatus.NOT_CONNECTED);\n this._deviceState.complete();\n this._deviceSessionRefresher.stopRefresher();\n this._pinger.unsubscribe();\n }\n\n public disableRefresher(id: string): () => void {\n return this._refresherService.disableRefresher(id);\n }\n\n public _unsafeBypassIntentQueue(bypass: boolean): void {\n this._bypassIntentQueue = bypass;\n }\n\n private _updateDeviceStatus(deviceStatus: DeviceStatus): void {\n const state = this._deviceState.getValue();\n this._deviceState.next({ ...state, deviceStatus });\n }\n}\n"],
5
+ "mappings": "yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,mBAAAE,IAAA,eAAAC,EAAAH,GACA,IAAAI,EAMO,gBACPC,EAA6B,gBAI7BC,EAA6B,2CAC7BC,EAA6B,oCAO7BC,EAGO,kDAIPC,EAGO,uCAEPC,EAGO,+BACPC,EAAyD,qEACzDC,EAAmC,+DACnCC,EAAiC,6DAIjCC,EAA6B,0BAC7BC,EAGO,0CACPC,EAAuC,oCACvCC,EAA0C,uCAqBnC,MAAMf,CAAc,CACR,IACA,iBACA,aACA,mBACA,sBACA,QACA,qBAGA,kBACT,QACA,wBACS,kBACA,oBACT,wBAA0B,IAAI,+BAC9B,mBAA8B,GAEtC,YACE,CAAE,gBAAAgB,EAAiB,GAAAC,KAAK,EAAAC,IAAO,CAAE,EACjCC,EACAC,EACAC,EAC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,CAC5B,CAEQ,oBAAoBC,EAAkC,CAC5D,MAAMrB,EAAQ,KAAK,aAAa,SAAS,EACzC,KAAK,aAAa,KAAK,CAAE,GAAGA,EAAO,aAAAqB,CAAa,CAAC,CACnD,CACF",
6
+ "names": ["DeviceSession_exports", "__export", "DeviceSession", "__toCommonJS", "import_rxjs", "import_uuid", "import_CommandUtils", "import_DeviceStatus", "import_DeviceSessionState", "import_Errors", "import_apduLogs", "import_DeviceSessionRefresherConst", "import_IntentQueueService", "import_RefresherService", "import_DevicePinger", "import_DeviceSessionEventDispatcher", "import_DeviceSessionRefresher", "import_DeviceSessionStateHandler", "connectedDevice", "id", "uuidv4", "loggerModuleFactory", "managerApiService", "secureChannelService", "deviceSessionRefresherOptions", "intentQueueServiceFactory", "sessionEventDispatcher", "command", "abortTimeout", "state", "error", "rawApdu", "options", "beforeQueuedTimestamp", "observable", "cancel", "elapsedTime", "timeoutObservable", "response", "message", "data", "apdu", "err", "r", "result", "deviceAction", "deviceActionCancel", "o", "queueCancel", "bypass", "deviceStatus"]
7
7
  }
@@ -1,2 +1,2 @@
1
- "use strict";var p=Object.defineProperty;var l=Object.getOwnPropertyDescriptor;var a=Object.getOwnPropertyNames;var f=Object.prototype.hasOwnProperty;var v=(n,s)=>{for(var t in s)p(n,t,{get:s[t],enumerable:!0})},_=(n,s,t,e)=>{if(s&&typeof s=="object"||typeof s=="function")for(let i of a(s))!f.call(n,i)&&i!==t&&p(n,i,{get:()=>s[i],enumerable:!(e=l(s,i))||e.enumerable});return n};var d=n=>_(p({},"__esModule",{value:!0}),n);var g={};v(g,{DeviceSessionRefresher:()=>u});module.exports=d(g);var r=require("rxjs"),c=require("../../../api/device/DeviceModel"),o=require("../../device-session/data/DeviceSessionRefresherConst"),h=require("../../device-session/model/DeviceSessionEventDispatcher");class u{constructor(s,t,e,i){this._sessionEventDispatcher=e;this._refresherOptions=t,this._logger=s("device-session-refresher"),this._connectedDeviceID=i.deviceModel.id}_refresherSubscription;_refresherOptions;_logger;_connectedDeviceID;startRefresher(){if(this._refresherOptions.isRefresherDisabled||this._refresherSubscription)return;const s=this.getValidPollingInterval(this._refresherOptions,this._logger)*2,t=this._sessionEventDispatcher.listen().pipe((0,r.filter)(e=>e.eventName===h.SessionEvents.DEVICE_STATE_UPDATE_BUSY||e.eventName===h.SessionEvents.NEW_STATE),(0,r.map)(e=>e.eventName===h.SessionEvents.DEVICE_STATE_UPDATE_BUSY),(0,r.startWith)(!1),(0,r.distinctUntilChanged)());this._refresherSubscription=(0,r.timer)(0,s).pipe((0,r.withLatestFrom)(t),(0,r.tap)(([e,i])=>{i&&this._logger.debug("Refresh skipped: device is busy")}),(0,r.filter)(([e,i])=>!i),(0,r.tap)(()=>this._sessionEventDispatcher.dispatch({eventName:h.SessionEvents.REFRESH_NEEDED}))).subscribe(),this._logger.info("Refresher started.")}stopRefresher(){this._refresherSubscription&&(this._refresherSubscription.unsubscribe(),this._refresherSubscription=void 0,this._logger.info("Refresher stopped."))}restartRefresher(){this.stopRefresher(),this.startRefresher(),this._logger.info("Refresher restarted.")}getValidPollingInterval=(s,t)=>{const{pollingInterval:e}=s;switch(this._connectedDeviceID){case c.DeviceModelId.NANO_S:{const i=o.DEVICE_SESSION_REFRESHER_POLLING_INTERVAL*2;return e!==void 0&&e<i?(t.warn(`Polling interval of ${e} is too low, setting to minimum as ${i}`),i):e??i}default:return e!==void 0&&e<o.DEVICE_SESSION_REFRESHER_MINIMUM_POLLING_INTERVAL?(t.warn(`Polling interval of ${e} is too low, setting to minimum as ${o.DEVICE_SESSION_REFRESHER_MINIMUM_POLLING_INTERVAL}`),o.DEVICE_SESSION_REFRESHER_MINIMUM_POLLING_INTERVAL):e??o.DEVICE_SESSION_REFRESHER_POLLING_INTERVAL}}}0&&(module.exports={DeviceSessionRefresher});
1
+ "use strict";var p=Object.defineProperty;var l=Object.getOwnPropertyDescriptor;var a=Object.getOwnPropertyNames;var f=Object.prototype.hasOwnProperty;var v=(n,s)=>{for(var t in s)p(n,t,{get:s[t],enumerable:!0})},_=(n,s,t,e)=>{if(s&&typeof s=="object"||typeof s=="function")for(let i of a(s))!f.call(n,i)&&i!==t&&p(n,i,{get:()=>s[i],enumerable:!(e=l(s,i))||e.enumerable});return n};var d=n=>_(p({},"__esModule",{value:!0}),n);var g={};v(g,{DeviceSessionRefresher:()=>u});module.exports=d(g);var r=require("rxjs"),c=require("../../../api/device/DeviceModel"),o=require("../../device-session/data/DeviceSessionRefresherConst"),h=require("../../device-session/model/DeviceSessionEventDispatcher");class u{constructor(s,t,e,i){this._sessionEventDispatcher=e;this._refresherOptions=t,this._logger=s("device-session-refresher"),this._connectedDeviceID=i.deviceModel.id}_refresherSubscription;_refresherOptions;_logger;_connectedDeviceID;startRefresher(){if(this._refresherOptions.isRefresherDisabled||this._refresherSubscription)return;const s=this.getValidPollingInterval(this._refresherOptions,this._logger),t=this._sessionEventDispatcher.listen().pipe((0,r.filter)(e=>e.eventName===h.SessionEvents.DEVICE_STATE_UPDATE_BUSY||e.eventName===h.SessionEvents.NEW_STATE),(0,r.map)(e=>e.eventName===h.SessionEvents.DEVICE_STATE_UPDATE_BUSY),(0,r.startWith)(!1),(0,r.distinctUntilChanged)());this._refresherSubscription=(0,r.timer)(0,s).pipe((0,r.withLatestFrom)(t),(0,r.tap)(([e,i])=>{i&&this._logger.debug("Refresh skipped: device is busy")}),(0,r.filter)(([e,i])=>!i),(0,r.tap)(()=>this._sessionEventDispatcher.dispatch({eventName:h.SessionEvents.REFRESH_NEEDED}))).subscribe(),this._logger.info("Refresher started.")}stopRefresher(){this._refresherSubscription&&(this._refresherSubscription.unsubscribe(),this._refresherSubscription=void 0,this._logger.info("Refresher stopped."))}restartRefresher(){this.stopRefresher(),this.startRefresher(),this._logger.info("Refresher restarted.")}getValidPollingInterval=(s,t)=>{const{pollingInterval:e}=s;switch(this._connectedDeviceID){case c.DeviceModelId.NANO_S:{const i=o.DEVICE_SESSION_REFRESHER_POLLING_INTERVAL*2;return e!==void 0&&e<i?(t.warn(`Polling interval of ${e} is too low, setting to minimum as ${i}`),i):e??i}default:return e!==void 0&&e<o.DEVICE_SESSION_REFRESHER_MINIMUM_POLLING_INTERVAL?(t.warn(`Polling interval of ${e} is too low, setting to minimum as ${o.DEVICE_SESSION_REFRESHER_MINIMUM_POLLING_INTERVAL}`),o.DEVICE_SESSION_REFRESHER_MINIMUM_POLLING_INTERVAL):e??o.DEVICE_SESSION_REFRESHER_POLLING_INTERVAL}}}0&&(module.exports={DeviceSessionRefresher});
2
2
  //# sourceMappingURL=DeviceSessionRefresher.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../../../src/internal/device-session/model/DeviceSessionRefresher.ts"],
4
- "sourcesContent": ["import {\n distinctUntilChanged,\n filter,\n map,\n startWith,\n type Subscription,\n tap,\n timer,\n withLatestFrom,\n} from \"rxjs\";\n\nimport { DeviceModelId } from \"@api/device/DeviceModel\";\nimport { type TransportConnectedDevice } from \"@api/transport/model/TransportConnectedDevice\";\nimport { type LoggerPublisherService } from \"@api/types\";\nimport {\n DEVICE_SESSION_REFRESHER_MINIMUM_POLLING_INTERVAL,\n DEVICE_SESSION_REFRESHER_POLLING_INTERVAL,\n} from \"@internal/device-session/data/DeviceSessionRefresherConst\";\nimport {\n type DeviceSessionEventDispatcher,\n SessionEvents,\n} from \"@internal/device-session/model/DeviceSessionEventDispatcher\";\n\nexport interface DeviceSessionRefresherOptions {\n isRefresherDisabled: boolean;\n pollingInterval?: number;\n}\n\nexport class DeviceSessionRefresher {\n private _refresherSubscription!: Subscription | undefined;\n private _refresherOptions: DeviceSessionRefresherOptions;\n private readonly _logger: LoggerPublisherService;\n private _connectedDeviceID: DeviceModelId;\n\n constructor(\n loggerModuleFactory: (tag: string) => LoggerPublisherService,\n refresherOptions: DeviceSessionRefresherOptions,\n private _sessionEventDispatcher: DeviceSessionEventDispatcher,\n connectedDevice: TransportConnectedDevice,\n ) {\n this._refresherOptions = refresherOptions;\n this._logger = loggerModuleFactory(\"device-session-refresher\");\n this._connectedDeviceID = connectedDevice.deviceModel.id;\n }\n\n public startRefresher(): void {\n if (this._refresherOptions.isRefresherDisabled) return;\n if (this._refresherSubscription) return;\n\n const pollingInterval =\n this.getValidPollingInterval(this._refresherOptions, this._logger) * 2;\n\n const isBusy$ = this._sessionEventDispatcher.listen().pipe(\n filter(\n (event) =>\n event.eventName === SessionEvents.DEVICE_STATE_UPDATE_BUSY ||\n event.eventName === SessionEvents.NEW_STATE,\n ),\n map(\n (event) => event.eventName === SessionEvents.DEVICE_STATE_UPDATE_BUSY,\n ),\n startWith(false),\n distinctUntilChanged(),\n );\n\n this._refresherSubscription = timer(0, pollingInterval)\n .pipe(\n withLatestFrom(isBusy$),\n tap(([_, isBusy]) => {\n if (isBusy) {\n this._logger.debug(\"Refresh skipped: device is busy\");\n }\n }),\n filter(([_, isBusy]) => !isBusy),\n tap(() =>\n this._sessionEventDispatcher.dispatch({\n eventName: SessionEvents.REFRESH_NEEDED,\n }),\n ),\n )\n .subscribe();\n\n this._logger.info(\"Refresher started.\");\n }\n\n public stopRefresher(): void {\n if (this._refresherSubscription) {\n this._refresherSubscription.unsubscribe();\n this._refresherSubscription = undefined;\n this._logger.info(\"Refresher stopped.\");\n }\n }\n\n public restartRefresher(): void {\n this.stopRefresher();\n this.startRefresher();\n this._logger.info(\"Refresher restarted.\");\n }\n\n private getValidPollingInterval = (\n refresherOptions: DeviceSessionRefresherOptions,\n logger: LoggerPublisherService,\n ): number => {\n const { pollingInterval } = refresherOptions;\n switch (this._connectedDeviceID) {\n case DeviceModelId.NANO_S: {\n const defaultNanoPollingInterval =\n DEVICE_SESSION_REFRESHER_POLLING_INTERVAL * 2;\n if (\n pollingInterval !== undefined &&\n pollingInterval < defaultNanoPollingInterval\n ) {\n logger.warn(\n `Polling interval of ${pollingInterval} is too low, setting to minimum as ${defaultNanoPollingInterval}`,\n );\n return defaultNanoPollingInterval;\n }\n return pollingInterval ?? defaultNanoPollingInterval;\n }\n default:\n if (\n pollingInterval !== undefined &&\n pollingInterval < DEVICE_SESSION_REFRESHER_MINIMUM_POLLING_INTERVAL\n ) {\n logger.warn(\n `Polling interval of ${pollingInterval} is too low, setting to minimum as ${DEVICE_SESSION_REFRESHER_MINIMUM_POLLING_INTERVAL}`,\n );\n return DEVICE_SESSION_REFRESHER_MINIMUM_POLLING_INTERVAL;\n }\n\n return pollingInterval ?? DEVICE_SESSION_REFRESHER_POLLING_INTERVAL;\n }\n };\n}\n"],
5
- "mappings": "yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,4BAAAE,IAAA,eAAAC,EAAAH,GAAA,IAAAI,EASO,gBAEPC,EAA8B,mCAG9BC,EAGO,qEACPC,EAGO,uEAOA,MAAML,CAAuB,CAMlC,YACEM,EACAC,EACQC,EACRC,EACA,CAFQ,6BAAAD,EAGR,KAAK,kBAAoBD,EACzB,KAAK,QAAUD,EAAoB,0BAA0B,EAC7D,KAAK,mBAAqBG,EAAgB,YAAY,EACxD,CAdQ,uBACA,kBACS,QACT,mBAaD,gBAAuB,CAE5B,GADI,KAAK,kBAAkB,qBACvB,KAAK,uBAAwB,OAEjC,MAAMC,EACJ,KAAK,wBAAwB,KAAK,kBAAmB,KAAK,OAAO,EAAI,EAEjEC,EAAU,KAAK,wBAAwB,OAAO,EAAE,QACpD,UACGC,GACCA,EAAM,YAAc,gBAAc,0BAClCA,EAAM,YAAc,gBAAc,SACtC,KACA,OACGA,GAAUA,EAAM,YAAc,gBAAc,wBAC/C,KACA,aAAU,EAAK,KACf,wBAAqB,CACvB,EAEA,KAAK,0BAAyB,SAAM,EAAGF,CAAe,EACnD,QACC,kBAAeC,CAAO,KACtB,OAAI,CAAC,CAACE,EAAGC,CAAM,IAAM,CACfA,GACF,KAAK,QAAQ,MAAM,iCAAiC,CAExD,CAAC,KACD,UAAO,CAAC,CAACD,EAAGC,CAAM,IAAM,CAACA,CAAM,KAC/B,OAAI,IACF,KAAK,wBAAwB,SAAS,CACpC,UAAW,gBAAc,cAC3B,CAAC,CACH,CACF,EACC,UAAU,EAEb,KAAK,QAAQ,KAAK,oBAAoB,CACxC,CAEO,eAAsB,CACvB,KAAK,yBACP,KAAK,uBAAuB,YAAY,EACxC,KAAK,uBAAyB,OAC9B,KAAK,QAAQ,KAAK,oBAAoB,EAE1C,CAEO,kBAAyB,CAC9B,KAAK,cAAc,EACnB,KAAK,eAAe,EACpB,KAAK,QAAQ,KAAK,sBAAsB,CAC1C,CAEQ,wBAA0B,CAChCP,EACAQ,IACW,CACX,KAAM,CAAE,gBAAAL,CAAgB,EAAIH,EAC5B,OAAQ,KAAK,mBAAoB,CAC/B,KAAK,gBAAc,OAAQ,CACzB,MAAMS,EACJ,4CAA4C,EAC9C,OACEN,IAAoB,QACpBA,EAAkBM,GAElBD,EAAO,KACL,uBAAuBL,CAAe,sCAAsCM,CAA0B,EACxG,EACOA,GAEFN,GAAmBM,CAC5B,CACA,QACE,OACEN,IAAoB,QACpBA,EAAkB,qDAElBK,EAAO,KACL,uBAAuBL,CAAe,sCAAsC,mDAAiD,EAC/H,EACO,qDAGFA,GAAmB,2CAC9B,CACF,CACF",
4
+ "sourcesContent": ["import {\n distinctUntilChanged,\n filter,\n map,\n startWith,\n type Subscription,\n tap,\n timer,\n withLatestFrom,\n} from \"rxjs\";\n\nimport { DeviceModelId } from \"@api/device/DeviceModel\";\nimport { type TransportConnectedDevice } from \"@api/transport/model/TransportConnectedDevice\";\nimport { type LoggerPublisherService } from \"@api/types\";\nimport {\n DEVICE_SESSION_REFRESHER_MINIMUM_POLLING_INTERVAL,\n DEVICE_SESSION_REFRESHER_POLLING_INTERVAL,\n} from \"@internal/device-session/data/DeviceSessionRefresherConst\";\nimport {\n type DeviceSessionEventDispatcher,\n SessionEvents,\n} from \"@internal/device-session/model/DeviceSessionEventDispatcher\";\n\nexport interface DeviceSessionRefresherOptions {\n isRefresherDisabled: boolean;\n pollingInterval?: number;\n}\n\nexport class DeviceSessionRefresher {\n private _refresherSubscription!: Subscription | undefined;\n private _refresherOptions: DeviceSessionRefresherOptions;\n private readonly _logger: LoggerPublisherService;\n private _connectedDeviceID: DeviceModelId;\n\n constructor(\n loggerModuleFactory: (tag: string) => LoggerPublisherService,\n refresherOptions: DeviceSessionRefresherOptions,\n private _sessionEventDispatcher: DeviceSessionEventDispatcher,\n connectedDevice: TransportConnectedDevice,\n ) {\n this._refresherOptions = refresherOptions;\n this._logger = loggerModuleFactory(\"device-session-refresher\");\n this._connectedDeviceID = connectedDevice.deviceModel.id;\n }\n\n public startRefresher(): void {\n if (this._refresherOptions.isRefresherDisabled) return;\n if (this._refresherSubscription) return;\n\n const pollingInterval = this.getValidPollingInterval(\n this._refresherOptions,\n this._logger,\n );\n\n const isBusy$ = this._sessionEventDispatcher.listen().pipe(\n filter(\n (event) =>\n event.eventName === SessionEvents.DEVICE_STATE_UPDATE_BUSY ||\n event.eventName === SessionEvents.NEW_STATE,\n ),\n map(\n (event) => event.eventName === SessionEvents.DEVICE_STATE_UPDATE_BUSY,\n ),\n startWith(false),\n distinctUntilChanged(),\n );\n\n this._refresherSubscription = timer(0, pollingInterval)\n .pipe(\n withLatestFrom(isBusy$),\n tap(([_, isBusy]) => {\n if (isBusy) {\n this._logger.debug(\"Refresh skipped: device is busy\");\n }\n }),\n filter(([_, isBusy]) => !isBusy),\n tap(() =>\n this._sessionEventDispatcher.dispatch({\n eventName: SessionEvents.REFRESH_NEEDED,\n }),\n ),\n )\n .subscribe();\n\n this._logger.info(\"Refresher started.\");\n }\n\n public stopRefresher(): void {\n if (this._refresherSubscription) {\n this._refresherSubscription.unsubscribe();\n this._refresherSubscription = undefined;\n this._logger.info(\"Refresher stopped.\");\n }\n }\n\n public restartRefresher(): void {\n this.stopRefresher();\n this.startRefresher();\n this._logger.info(\"Refresher restarted.\");\n }\n\n private getValidPollingInterval = (\n refresherOptions: DeviceSessionRefresherOptions,\n logger: LoggerPublisherService,\n ): number => {\n const { pollingInterval } = refresherOptions;\n switch (this._connectedDeviceID) {\n case DeviceModelId.NANO_S: {\n const defaultNanoPollingInterval =\n DEVICE_SESSION_REFRESHER_POLLING_INTERVAL * 2;\n if (\n pollingInterval !== undefined &&\n pollingInterval < defaultNanoPollingInterval\n ) {\n logger.warn(\n `Polling interval of ${pollingInterval} is too low, setting to minimum as ${defaultNanoPollingInterval}`,\n );\n return defaultNanoPollingInterval;\n }\n return pollingInterval ?? defaultNanoPollingInterval;\n }\n default:\n if (\n pollingInterval !== undefined &&\n pollingInterval < DEVICE_SESSION_REFRESHER_MINIMUM_POLLING_INTERVAL\n ) {\n logger.warn(\n `Polling interval of ${pollingInterval} is too low, setting to minimum as ${DEVICE_SESSION_REFRESHER_MINIMUM_POLLING_INTERVAL}`,\n );\n return DEVICE_SESSION_REFRESHER_MINIMUM_POLLING_INTERVAL;\n }\n\n return pollingInterval ?? DEVICE_SESSION_REFRESHER_POLLING_INTERVAL;\n }\n };\n}\n"],
5
+ "mappings": "yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,4BAAAE,IAAA,eAAAC,EAAAH,GAAA,IAAAI,EASO,gBAEPC,EAA8B,mCAG9BC,EAGO,qEACPC,EAGO,uEAOA,MAAML,CAAuB,CAMlC,YACEM,EACAC,EACQC,EACRC,EACA,CAFQ,6BAAAD,EAGR,KAAK,kBAAoBD,EACzB,KAAK,QAAUD,EAAoB,0BAA0B,EAC7D,KAAK,mBAAqBG,EAAgB,YAAY,EACxD,CAdQ,uBACA,kBACS,QACT,mBAaD,gBAAuB,CAE5B,GADI,KAAK,kBAAkB,qBACvB,KAAK,uBAAwB,OAEjC,MAAMC,EAAkB,KAAK,wBAC3B,KAAK,kBACL,KAAK,OACP,EAEMC,EAAU,KAAK,wBAAwB,OAAO,EAAE,QACpD,UACGC,GACCA,EAAM,YAAc,gBAAc,0BAClCA,EAAM,YAAc,gBAAc,SACtC,KACA,OACGA,GAAUA,EAAM,YAAc,gBAAc,wBAC/C,KACA,aAAU,EAAK,KACf,wBAAqB,CACvB,EAEA,KAAK,0BAAyB,SAAM,EAAGF,CAAe,EACnD,QACC,kBAAeC,CAAO,KACtB,OAAI,CAAC,CAACE,EAAGC,CAAM,IAAM,CACfA,GACF,KAAK,QAAQ,MAAM,iCAAiC,CAExD,CAAC,KACD,UAAO,CAAC,CAACD,EAAGC,CAAM,IAAM,CAACA,CAAM,KAC/B,OAAI,IACF,KAAK,wBAAwB,SAAS,CACpC,UAAW,gBAAc,cAC3B,CAAC,CACH,CACF,EACC,UAAU,EAEb,KAAK,QAAQ,KAAK,oBAAoB,CACxC,CAEO,eAAsB,CACvB,KAAK,yBACP,KAAK,uBAAuB,YAAY,EACxC,KAAK,uBAAyB,OAC9B,KAAK,QAAQ,KAAK,oBAAoB,EAE1C,CAEO,kBAAyB,CAC9B,KAAK,cAAc,EACnB,KAAK,eAAe,EACpB,KAAK,QAAQ,KAAK,sBAAsB,CAC1C,CAEQ,wBAA0B,CAChCP,EACAQ,IACW,CACX,KAAM,CAAE,gBAAAL,CAAgB,EAAIH,EAC5B,OAAQ,KAAK,mBAAoB,CAC/B,KAAK,gBAAc,OAAQ,CACzB,MAAMS,EACJ,4CAA4C,EAC9C,OACEN,IAAoB,QACpBA,EAAkBM,GAElBD,EAAO,KACL,uBAAuBL,CAAe,sCAAsCM,CAA0B,EACxG,EACOA,GAEFN,GAAmBM,CAC5B,CACA,QACE,OACEN,IAAoB,QACpBA,EAAkB,qDAElBK,EAAO,KACL,uBAAuBL,CAAe,sCAAsC,mDAAiD,EAC/H,EACO,qDAGFA,GAAmB,2CAC9B,CACF,CACF",
6
6
  "names": ["DeviceSessionRefresher_exports", "__export", "DeviceSessionRefresher", "__toCommonJS", "import_rxjs", "import_DeviceModel", "import_DeviceSessionRefresherConst", "import_DeviceSessionEventDispatcher", "loggerModuleFactory", "refresherOptions", "_sessionEventDispatcher", "connectedDevice", "pollingInterval", "isBusy$", "event", "_", "isBusy", "logger", "defaultNanoPollingInterval"]
7
7
  }
@@ -1,2 +1,2 @@
1
- "use strict";var h=require("rxjs"),e=require("vitest"),d=require("../../../api/device/DeviceModel"),l=require("../../device-session/data/DeviceSessionRefresherConst"),p=require("../../device-session/model/DeviceSessionEventDispatcher"),i=require("./DeviceSessionRefresher");(0,e.describe)("DeviceSessionRefresher",()=>{let f,t,n;const c={deviceModel:{id:d.DeviceModelId.FLEX}},m={deviceModel:{id:d.DeviceModelId.NANO_S}},a=e.vi.fn(()=>n);let s;(0,e.beforeEach)(()=>{e.vi.useFakeTimers(),f=new h.Subject,t={listen:()=>f.asObservable(),dispatch:e.vi.fn()},n={info:e.vi.fn(),warn:e.vi.fn(),error:e.vi.fn(),debug:e.vi.fn(),subscribers:[]}}),(0,e.afterEach)(()=>{s?.stopRefresher(),e.vi.useRealTimers(),e.vi.restoreAllMocks()}),(0,e.it)("should not start refresher if disabled",()=>{const r={isRefresherDisabled:!0,pollingInterval:1e3};s=new i.DeviceSessionRefresher(a,r,t,c),s.startRefresher(),e.vi.advanceTimersByTime(2e3),(0,e.expect)(t.dispatch).not.toHaveBeenCalled()}),(0,e.it)("should warn and use minimum polling interval for default device when provided interval is too low",()=>{const r=l.DEVICE_SESSION_REFRESHER_MINIMUM_POLLING_INTERVAL-100,o={isRefresherDisabled:!1,pollingInterval:r};s=new i.DeviceSessionRefresher(a,o,t,c),s.startRefresher();const v=`Polling interval of ${r} is too low, setting to minimum as ${l.DEVICE_SESSION_REFRESHER_MINIMUM_POLLING_INTERVAL}`;(0,e.expect)(n.warn).toHaveBeenCalledWith(v)}),(0,e.it)("should warn and use minimum polling interval for NANO_S device when provided interval is too low",()=>{const r=l.DEVICE_SESSION_REFRESHER_POLLING_INTERVAL*2,o=r-100,v={isRefresherDisabled:!1,pollingInterval:o};s=new i.DeviceSessionRefresher(a,v,t,m),s.startRefresher();const R=`Polling interval of ${o} is too low, setting to minimum as ${r}`;(0,e.expect)(n.warn).toHaveBeenCalledWith(R)}),(0,e.it)("should not warn when provided polling interval is valid for default device",()=>{const o={isRefresherDisabled:!1,pollingInterval:l.DEVICE_SESSION_REFRESHER_MINIMUM_POLLING_INTERVAL+100};s=new i.DeviceSessionRefresher(a,o,t,c),s.startRefresher(),(0,e.expect)(n.warn).not.toHaveBeenCalled()}),(0,e.it)("should dispatch refresh event on timer ticks",()=>{const r=l.DEVICE_SESSION_REFRESHER_MINIMUM_POLLING_INTERVAL+100,o={isRefresherDisabled:!1,pollingInterval:r};s=new i.DeviceSessionRefresher(a,o,t,c),s.startRefresher(),f.next({eventName:p.SessionEvents.NEW_STATE});const v=r*2;e.vi.advanceTimersByTime(v*3),(0,e.expect)(t.dispatch.mock.calls.length).toBe(4),(0,e.expect)(t.dispatch.mock.calls[0][0]).toEqual({eventName:p.SessionEvents.REFRESH_NEEDED})}),(0,e.it)("should stop refresher",()=>{const r={isRefresherDisabled:!1,pollingInterval:1e3};s=new i.DeviceSessionRefresher(a,r,t,c),s.startRefresher(),t.dispatch.mockClear(),s.stopRefresher(),e.vi.advanceTimersByTime(2e3),(0,e.expect)(t.dispatch).not.toHaveBeenCalled(),(0,e.expect)(n.info).toHaveBeenCalledWith("Refresher stopped.")}),(0,e.it)("should restart refresher",()=>{const r={isRefresherDisabled:!1,pollingInterval:1e3};s=new i.DeviceSessionRefresher(a,r,t,c),s.startRefresher(),t.dispatch.mockClear(),e.vi.clearAllTimers(),s.restartRefresher(),(0,e.expect)(n.info).toHaveBeenCalledWith("Refresher stopped."),(0,e.expect)(n.info).toHaveBeenCalledWith("Refresher restarted."),f.next({eventName:p.SessionEvents.NEW_STATE}),e.vi.advanceTimersByTime(2e3),(0,e.expect)(t.dispatch.mock.calls.length).toBeGreaterThan(0)})});
1
+ "use strict";var h=require("rxjs"),e=require("vitest"),d=require("../../../api/device/DeviceModel"),l=require("../../device-session/data/DeviceSessionRefresherConst"),p=require("../../device-session/model/DeviceSessionEventDispatcher"),i=require("./DeviceSessionRefresher");(0,e.describe)("DeviceSessionRefresher",()=>{let f,t,n;const c={deviceModel:{id:d.DeviceModelId.FLEX}},m={deviceModel:{id:d.DeviceModelId.NANO_S}},a=e.vi.fn(()=>n);let s;(0,e.beforeEach)(()=>{e.vi.useFakeTimers(),f=new h.Subject,t={listen:()=>f.asObservable(),dispatch:e.vi.fn()},n={info:e.vi.fn(),warn:e.vi.fn(),error:e.vi.fn(),debug:e.vi.fn(),subscribers:[]}}),(0,e.afterEach)(()=>{s?.stopRefresher(),e.vi.useRealTimers(),e.vi.restoreAllMocks()}),(0,e.it)("should not start refresher if disabled",()=>{const r={isRefresherDisabled:!0,pollingInterval:1e3};s=new i.DeviceSessionRefresher(a,r,t,c),s.startRefresher(),e.vi.advanceTimersByTime(2e3),(0,e.expect)(t.dispatch).not.toHaveBeenCalled()}),(0,e.it)("should warn and use minimum polling interval for default device when provided interval is too low",()=>{const r=l.DEVICE_SESSION_REFRESHER_MINIMUM_POLLING_INTERVAL-100,o={isRefresherDisabled:!1,pollingInterval:r};s=new i.DeviceSessionRefresher(a,o,t,c),s.startRefresher();const v=`Polling interval of ${r} is too low, setting to minimum as ${l.DEVICE_SESSION_REFRESHER_MINIMUM_POLLING_INTERVAL}`;(0,e.expect)(n.warn).toHaveBeenCalledWith(v)}),(0,e.it)("should warn and use minimum polling interval for NANO_S device when provided interval is too low",()=>{const r=l.DEVICE_SESSION_REFRESHER_POLLING_INTERVAL*2,o=r-100,v={isRefresherDisabled:!1,pollingInterval:o};s=new i.DeviceSessionRefresher(a,v,t,m),s.startRefresher();const R=`Polling interval of ${o} is too low, setting to minimum as ${r}`;(0,e.expect)(n.warn).toHaveBeenCalledWith(R)}),(0,e.it)("should not warn when provided polling interval is valid for default device",()=>{const o={isRefresherDisabled:!1,pollingInterval:l.DEVICE_SESSION_REFRESHER_MINIMUM_POLLING_INTERVAL+100};s=new i.DeviceSessionRefresher(a,o,t,c),s.startRefresher(),(0,e.expect)(n.warn).not.toHaveBeenCalled()}),(0,e.it)("should dispatch refresh event on timer ticks",()=>{const r=l.DEVICE_SESSION_REFRESHER_MINIMUM_POLLING_INTERVAL+100,o={isRefresherDisabled:!1,pollingInterval:r};s=new i.DeviceSessionRefresher(a,o,t,c),s.startRefresher(),f.next({eventName:p.SessionEvents.NEW_STATE});const v=r;e.vi.advanceTimersByTime(v*3),(0,e.expect)(t.dispatch.mock.calls.length).toBe(4),(0,e.expect)(t.dispatch.mock.calls[0][0]).toEqual({eventName:p.SessionEvents.REFRESH_NEEDED})}),(0,e.it)("should stop refresher",()=>{const r={isRefresherDisabled:!1,pollingInterval:1e3};s=new i.DeviceSessionRefresher(a,r,t,c),s.startRefresher(),t.dispatch.mockClear(),s.stopRefresher(),e.vi.advanceTimersByTime(2e3),(0,e.expect)(t.dispatch).not.toHaveBeenCalled(),(0,e.expect)(n.info).toHaveBeenCalledWith("Refresher stopped.")}),(0,e.it)("should restart refresher",()=>{const r={isRefresherDisabled:!1,pollingInterval:1e3};s=new i.DeviceSessionRefresher(a,r,t,c),s.startRefresher(),t.dispatch.mockClear(),e.vi.clearAllTimers(),s.restartRefresher(),(0,e.expect)(n.info).toHaveBeenCalledWith("Refresher stopped."),(0,e.expect)(n.info).toHaveBeenCalledWith("Refresher restarted."),f.next({eventName:p.SessionEvents.NEW_STATE}),e.vi.advanceTimersByTime(2e3),(0,e.expect)(t.dispatch.mock.calls.length).toBeGreaterThan(0)})});
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 { Subject } from \"rxjs\";\nimport { afterEach, beforeEach, describe, expect, it, vi } from \"vitest\";\n\nimport { DeviceModelId } from \"@api/device/DeviceModel\";\nimport { type TransportConnectedDevice } from \"@api/transport/model/TransportConnectedDevice\";\nimport type { LoggerPublisherService } from \"@api/types\";\nimport {\n DEVICE_SESSION_REFRESHER_MINIMUM_POLLING_INTERVAL,\n DEVICE_SESSION_REFRESHER_POLLING_INTERVAL,\n} from \"@internal/device-session/data/DeviceSessionRefresherConst\";\nimport type {\n DeviceSessionEventDispatcher,\n NewEvent,\n} from \"@internal/device-session/model/DeviceSessionEventDispatcher\";\nimport { SessionEvents } from \"@internal/device-session/model/DeviceSessionEventDispatcher\";\n\nimport {\n DeviceSessionRefresher,\n type DeviceSessionRefresherOptions,\n} from \"./DeviceSessionRefresher\";\n\ndescribe(\"DeviceSessionRefresher\", () => {\n let subject: Subject<NewEvent>;\n let mockSessionEventDispatcher: DeviceSessionEventDispatcher;\n let mockLogger: LoggerPublisherService & {\n info: ReturnType<typeof vi.fn>;\n warn: ReturnType<typeof vi.fn>;\n error: ReturnType<typeof vi.fn>;\n debug: ReturnType<typeof vi.fn>;\n subscribers?: unknown[];\n };\n\n const stubDefaultDevice = {\n deviceModel: {\n id: DeviceModelId.FLEX,\n },\n } as TransportConnectedDevice;\n\n const stubNanoSDevice = {\n deviceModel: {\n id: DeviceModelId.NANO_S,\n },\n } as TransportConnectedDevice;\n\n const mockedLoggerModuleFactory = vi.fn(() => mockLogger);\n let refresher: DeviceSessionRefresher;\n\n beforeEach(() => {\n vi.useFakeTimers();\n subject = new Subject<NewEvent>();\n mockSessionEventDispatcher = {\n listen: () => subject.asObservable(),\n dispatch: vi.fn(),\n } as unknown as DeviceSessionEventDispatcher;\n mockLogger = {\n info: vi.fn(),\n warn: vi.fn(),\n error: vi.fn(),\n debug: vi.fn(),\n subscribers: [],\n };\n });\n\n afterEach(() => {\n refresher?.stopRefresher();\n vi.useRealTimers();\n vi.restoreAllMocks();\n });\n\n it(\"should not start refresher if disabled\", () => {\n const options: DeviceSessionRefresherOptions = {\n isRefresherDisabled: true,\n pollingInterval: 1000,\n };\n\n refresher = new DeviceSessionRefresher(\n mockedLoggerModuleFactory,\n options,\n mockSessionEventDispatcher,\n stubDefaultDevice,\n );\n refresher.startRefresher();\n vi.advanceTimersByTime(2000);\n\n expect(mockSessionEventDispatcher.dispatch).not.toHaveBeenCalled();\n });\n\n it(\"should warn and use minimum polling interval for default device when provided interval is too low\", () => {\n const lowInterval = DEVICE_SESSION_REFRESHER_MINIMUM_POLLING_INTERVAL - 100;\n const options: DeviceSessionRefresherOptions = {\n isRefresherDisabled: false,\n pollingInterval: lowInterval,\n };\n\n refresher = new DeviceSessionRefresher(\n mockedLoggerModuleFactory,\n options,\n mockSessionEventDispatcher,\n stubDefaultDevice,\n );\n refresher.startRefresher();\n\n const expectedMessage = `Polling interval of ${lowInterval} is too low, setting to minimum as ${DEVICE_SESSION_REFRESHER_MINIMUM_POLLING_INTERVAL}`;\n expect(mockLogger.warn).toHaveBeenCalledWith(expectedMessage);\n });\n\n it(\"should warn and use minimum polling interval for NANO_S device when provided interval is too low\", () => {\n const defaultNanoPollingInterval =\n DEVICE_SESSION_REFRESHER_POLLING_INTERVAL * 2;\n const lowInterval = defaultNanoPollingInterval - 100;\n const options: DeviceSessionRefresherOptions = {\n isRefresherDisabled: false,\n pollingInterval: lowInterval,\n };\n\n refresher = new DeviceSessionRefresher(\n mockedLoggerModuleFactory,\n options,\n mockSessionEventDispatcher,\n stubNanoSDevice,\n );\n refresher.startRefresher();\n\n const expectedMessage = `Polling interval of ${lowInterval} is too low, setting to minimum as ${defaultNanoPollingInterval}`;\n expect(mockLogger.warn).toHaveBeenCalledWith(expectedMessage);\n });\n\n it(\"should not warn when provided polling interval is valid for default device\", () => {\n const validInterval =\n DEVICE_SESSION_REFRESHER_MINIMUM_POLLING_INTERVAL + 100;\n const options: DeviceSessionRefresherOptions = {\n isRefresherDisabled: false,\n pollingInterval: validInterval,\n };\n\n refresher = new DeviceSessionRefresher(\n mockedLoggerModuleFactory,\n options,\n mockSessionEventDispatcher,\n stubDefaultDevice,\n );\n refresher.startRefresher();\n\n expect(mockLogger.warn).not.toHaveBeenCalled();\n });\n\n it(\"should dispatch refresh event on timer ticks\", () => {\n const validInterval =\n DEVICE_SESSION_REFRESHER_MINIMUM_POLLING_INTERVAL + 100;\n const options: DeviceSessionRefresherOptions = {\n isRefresherDisabled: false,\n pollingInterval: validInterval,\n };\n\n refresher = new DeviceSessionRefresher(\n mockedLoggerModuleFactory,\n options,\n mockSessionEventDispatcher,\n stubDefaultDevice,\n );\n refresher.startRefresher();\n\n // Trigger NEW_STATE event to start the refresher timer\n subject.next({ eventName: SessionEvents.NEW_STATE });\n\n const timerInterval = validInterval * 2;\n\n vi.advanceTimersByTime(timerInterval * 3);\n\n expect(\n (mockSessionEventDispatcher.dispatch as ReturnType<typeof vi.fn>).mock\n .calls.length,\n ).toBe(4);\n expect(\n (mockSessionEventDispatcher.dispatch as ReturnType<typeof vi.fn>).mock\n .calls[0]![0],\n ).toEqual({\n eventName: SessionEvents.REFRESH_NEEDED,\n });\n });\n\n it(\"should stop refresher\", () => {\n const options: DeviceSessionRefresherOptions = {\n isRefresherDisabled: false,\n pollingInterval: 1000,\n };\n refresher = new DeviceSessionRefresher(\n mockedLoggerModuleFactory,\n options,\n mockSessionEventDispatcher,\n stubDefaultDevice,\n );\n refresher.startRefresher();\n (\n mockSessionEventDispatcher.dispatch as ReturnType<typeof vi.fn>\n ).mockClear();\n\n refresher.stopRefresher();\n vi.advanceTimersByTime(2000);\n\n expect(mockSessionEventDispatcher.dispatch).not.toHaveBeenCalled();\n expect(mockLogger.info).toHaveBeenCalledWith(\"Refresher stopped.\");\n });\n\n it(\"should restart refresher\", () => {\n const options: DeviceSessionRefresherOptions = {\n isRefresherDisabled: false,\n pollingInterval: 1000,\n };\n refresher = new DeviceSessionRefresher(\n mockedLoggerModuleFactory,\n options,\n mockSessionEventDispatcher,\n stubDefaultDevice,\n );\n refresher.startRefresher();\n (\n mockSessionEventDispatcher.dispatch as ReturnType<typeof vi.fn>\n ).mockClear();\n vi.clearAllTimers();\n\n refresher.restartRefresher();\n expect(mockLogger.info).toHaveBeenCalledWith(\"Refresher stopped.\");\n expect(mockLogger.info).toHaveBeenCalledWith(\"Refresher restarted.\");\n\n // Trigger NEW_STATE event to start the refresher timer\n subject.next({ eventName: SessionEvents.NEW_STATE });\n\n vi.advanceTimersByTime(2000);\n expect(\n (mockSessionEventDispatcher.dispatch as ReturnType<typeof vi.fn>).mock\n .calls.length,\n ).toBeGreaterThan(0);\n });\n});\n"],
5
- "mappings": "aAAA,IAAAA,EAAwB,gBACxBC,EAAgE,kBAEhEC,EAA8B,mCAG9BC,EAGO,qEAKPC,EAA8B,uEAE9BC,EAGO,uCAEP,YAAS,yBAA0B,IAAM,CACvC,IAAIC,EACAC,EACAC,EAQJ,MAAMC,EAAoB,CACxB,YAAa,CACX,GAAI,gBAAc,IACpB,CACF,EAEMC,EAAkB,CACtB,YAAa,CACX,GAAI,gBAAc,MACpB,CACF,EAEMC,EAA4B,KAAG,GAAG,IAAMH,CAAU,EACxD,IAAII,KAEJ,cAAW,IAAM,CACf,KAAG,cAAc,EACjBN,EAAU,IAAI,UACdC,EAA6B,CAC3B,OAAQ,IAAMD,EAAQ,aAAa,EACnC,SAAU,KAAG,GAAG,CAClB,EACAE,EAAa,CACX,KAAM,KAAG,GAAG,EACZ,KAAM,KAAG,GAAG,EACZ,MAAO,KAAG,GAAG,EACb,MAAO,KAAG,GAAG,EACb,YAAa,CAAC,CAChB,CACF,CAAC,KAED,aAAU,IAAM,CACdI,GAAW,cAAc,EACzB,KAAG,cAAc,EACjB,KAAG,gBAAgB,CACrB,CAAC,KAED,MAAG,yCAA0C,IAAM,CACjD,MAAMC,EAAyC,CAC7C,oBAAqB,GACrB,gBAAiB,GACnB,EAEAD,EAAY,IAAI,yBACdD,EACAE,EACAN,EACAE,CACF,EACAG,EAAU,eAAe,EACzB,KAAG,oBAAoB,GAAI,KAE3B,UAAOL,EAA2B,QAAQ,EAAE,IAAI,iBAAiB,CACnE,CAAC,KAED,MAAG,oGAAqG,IAAM,CAC5G,MAAMO,EAAc,oDAAoD,IAClED,EAAyC,CAC7C,oBAAqB,GACrB,gBAAiBC,CACnB,EAEAF,EAAY,IAAI,yBACdD,EACAE,EACAN,EACAE,CACF,EACAG,EAAU,eAAe,EAEzB,MAAMG,EAAkB,uBAAuBD,CAAW,sCAAsC,mDAA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AC3B,UAAU,EAEZK,EAAU,cAAc,EACxB,KAAG,oBAAoB,GAAI,KAE3B,UAAOL,EAA2B,QAAQ,EAAE,IAAI,iBAAiB,KACjE,UAAOC,EAAW,IAAI,EAAE,qBAAqB,oBAAoB,CACnE,CAAC,KAED,MAAG,2BAA4B,IAAM,CACnC,MAAMK,EAAyC,CAC7C,oBAAqB,GACrB,gBAAiB,GACnB,EACAD,EAAY,IAAI,yBACdD,EACAE,EACAN,EACAE,CACF,EACAG,EAAU,eAAe,EAEvBL,EAA2B,SAC3B,UAAU,EACZ,KAAG,eAAe,EAElBK,EAAU,iBAAiB,KAC3B,UAAOJ,EAAW,IAAI,EAAE,qBAAqB,oBAAoB,KACjE,UAAOA,EAAW,IAAI,EAAE,qBAAqB,sBAAsB,EAGnEF,EAAQ,KAAK,CAAE,UAAW,gBAAc,SAAU,CAAC,EAEnD,KAAG,oBAAoB,GAAI,KAC3B,UACGC,EAA2B,SAAsC,KAC/D,MAAM,MACX,EAAE,gBAAgB,CAAC,CACrB,CAAC,CACH,CAAC",
4
+ "sourcesContent": ["import { Subject } from \"rxjs\";\nimport { afterEach, beforeEach, describe, expect, it, vi } from \"vitest\";\n\nimport { DeviceModelId } from \"@api/device/DeviceModel\";\nimport { type TransportConnectedDevice } from \"@api/transport/model/TransportConnectedDevice\";\nimport type { LoggerPublisherService } from \"@api/types\";\nimport {\n DEVICE_SESSION_REFRESHER_MINIMUM_POLLING_INTERVAL,\n DEVICE_SESSION_REFRESHER_POLLING_INTERVAL,\n} from \"@internal/device-session/data/DeviceSessionRefresherConst\";\nimport type {\n DeviceSessionEventDispatcher,\n NewEvent,\n} from \"@internal/device-session/model/DeviceSessionEventDispatcher\";\nimport { SessionEvents } from \"@internal/device-session/model/DeviceSessionEventDispatcher\";\n\nimport {\n DeviceSessionRefresher,\n type DeviceSessionRefresherOptions,\n} from \"./DeviceSessionRefresher\";\n\ndescribe(\"DeviceSessionRefresher\", () => {\n let subject: Subject<NewEvent>;\n let mockSessionEventDispatcher: DeviceSessionEventDispatcher;\n let mockLogger: LoggerPublisherService & {\n info: ReturnType<typeof vi.fn>;\n warn: ReturnType<typeof vi.fn>;\n error: ReturnType<typeof vi.fn>;\n debug: ReturnType<typeof vi.fn>;\n subscribers?: unknown[];\n };\n\n const stubDefaultDevice = {\n deviceModel: {\n id: DeviceModelId.FLEX,\n },\n } as TransportConnectedDevice;\n\n const stubNanoSDevice = {\n deviceModel: {\n id: DeviceModelId.NANO_S,\n },\n } as TransportConnectedDevice;\n\n const mockedLoggerModuleFactory = vi.fn(() => mockLogger);\n let refresher: DeviceSessionRefresher;\n\n beforeEach(() => {\n vi.useFakeTimers();\n subject = new Subject<NewEvent>();\n mockSessionEventDispatcher = {\n listen: () => subject.asObservable(),\n dispatch: vi.fn(),\n } as unknown as DeviceSessionEventDispatcher;\n mockLogger = {\n info: vi.fn(),\n warn: vi.fn(),\n error: vi.fn(),\n debug: vi.fn(),\n subscribers: [],\n };\n });\n\n afterEach(() => {\n refresher?.stopRefresher();\n vi.useRealTimers();\n vi.restoreAllMocks();\n });\n\n it(\"should not start refresher if disabled\", () => {\n const options: DeviceSessionRefresherOptions = {\n isRefresherDisabled: true,\n pollingInterval: 1000,\n };\n\n refresher = new DeviceSessionRefresher(\n mockedLoggerModuleFactory,\n options,\n mockSessionEventDispatcher,\n stubDefaultDevice,\n );\n refresher.startRefresher();\n vi.advanceTimersByTime(2000);\n\n expect(mockSessionEventDispatcher.dispatch).not.toHaveBeenCalled();\n });\n\n it(\"should warn and use minimum polling interval for default device when provided interval is too low\", () => {\n const lowInterval = DEVICE_SESSION_REFRESHER_MINIMUM_POLLING_INTERVAL - 100;\n const options: DeviceSessionRefresherOptions = {\n isRefresherDisabled: false,\n pollingInterval: lowInterval,\n };\n\n refresher = new DeviceSessionRefresher(\n mockedLoggerModuleFactory,\n options,\n mockSessionEventDispatcher,\n stubDefaultDevice,\n );\n refresher.startRefresher();\n\n const expectedMessage = `Polling interval of ${lowInterval} is too low, setting to minimum as ${DEVICE_SESSION_REFRESHER_MINIMUM_POLLING_INTERVAL}`;\n expect(mockLogger.warn).toHaveBeenCalledWith(expectedMessage);\n });\n\n it(\"should warn and use minimum polling interval for NANO_S device when provided interval is too low\", () => {\n const defaultNanoPollingInterval =\n DEVICE_SESSION_REFRESHER_POLLING_INTERVAL * 2;\n const lowInterval = defaultNanoPollingInterval - 100;\n const options: DeviceSessionRefresherOptions = {\n isRefresherDisabled: false,\n pollingInterval: lowInterval,\n };\n\n refresher = new DeviceSessionRefresher(\n mockedLoggerModuleFactory,\n options,\n mockSessionEventDispatcher,\n stubNanoSDevice,\n );\n refresher.startRefresher();\n\n const expectedMessage = `Polling interval of ${lowInterval} is too low, setting to minimum as ${defaultNanoPollingInterval}`;\n expect(mockLogger.warn).toHaveBeenCalledWith(expectedMessage);\n });\n\n it(\"should not warn when provided polling interval is valid for default device\", () => {\n const validInterval =\n DEVICE_SESSION_REFRESHER_MINIMUM_POLLING_INTERVAL + 100;\n const options: DeviceSessionRefresherOptions = {\n isRefresherDisabled: false,\n pollingInterval: validInterval,\n };\n\n refresher = new DeviceSessionRefresher(\n mockedLoggerModuleFactory,\n options,\n mockSessionEventDispatcher,\n stubDefaultDevice,\n );\n refresher.startRefresher();\n\n expect(mockLogger.warn).not.toHaveBeenCalled();\n });\n\n it(\"should dispatch refresh event on timer ticks\", () => {\n const validInterval =\n DEVICE_SESSION_REFRESHER_MINIMUM_POLLING_INTERVAL + 100;\n const options: DeviceSessionRefresherOptions = {\n isRefresherDisabled: false,\n pollingInterval: validInterval,\n };\n\n refresher = new DeviceSessionRefresher(\n mockedLoggerModuleFactory,\n options,\n mockSessionEventDispatcher,\n stubDefaultDevice,\n );\n refresher.startRefresher();\n\n // Trigger NEW_STATE event to start the refresher timer\n subject.next({ eventName: SessionEvents.NEW_STATE });\n\n const timerInterval = validInterval;\n\n vi.advanceTimersByTime(timerInterval * 3);\n\n expect(\n (mockSessionEventDispatcher.dispatch as ReturnType<typeof vi.fn>).mock\n .calls.length,\n ).toBe(4);\n expect(\n (mockSessionEventDispatcher.dispatch as ReturnType<typeof vi.fn>).mock\n .calls[0]![0],\n ).toEqual({\n eventName: SessionEvents.REFRESH_NEEDED,\n });\n });\n\n it(\"should stop refresher\", () => {\n const options: DeviceSessionRefresherOptions = {\n isRefresherDisabled: false,\n pollingInterval: 1000,\n };\n refresher = new DeviceSessionRefresher(\n mockedLoggerModuleFactory,\n options,\n mockSessionEventDispatcher,\n stubDefaultDevice,\n );\n refresher.startRefresher();\n (\n mockSessionEventDispatcher.dispatch as ReturnType<typeof vi.fn>\n ).mockClear();\n\n refresher.stopRefresher();\n vi.advanceTimersByTime(2000);\n\n expect(mockSessionEventDispatcher.dispatch).not.toHaveBeenCalled();\n expect(mockLogger.info).toHaveBeenCalledWith(\"Refresher stopped.\");\n });\n\n it(\"should restart refresher\", () => {\n const options: DeviceSessionRefresherOptions = {\n isRefresherDisabled: false,\n pollingInterval: 1000,\n };\n refresher = new DeviceSessionRefresher(\n mockedLoggerModuleFactory,\n options,\n mockSessionEventDispatcher,\n stubDefaultDevice,\n );\n refresher.startRefresher();\n (\n mockSessionEventDispatcher.dispatch as ReturnType<typeof vi.fn>\n ).mockClear();\n vi.clearAllTimers();\n\n refresher.restartRefresher();\n expect(mockLogger.info).toHaveBeenCalledWith(\"Refresher stopped.\");\n expect(mockLogger.info).toHaveBeenCalledWith(\"Refresher restarted.\");\n\n // Trigger NEW_STATE event to start the refresher timer\n subject.next({ eventName: SessionEvents.NEW_STATE });\n\n vi.advanceTimersByTime(2000);\n expect(\n (mockSessionEventDispatcher.dispatch as ReturnType<typeof vi.fn>).mock\n .calls.length,\n ).toBeGreaterThan(0);\n });\n});\n"],
5
+ "mappings": "aAAA,IAAAA,EAAwB,gBACxBC,EAAgE,kBAEhEC,EAA8B,mCAG9BC,EAGO,qEAKPC,EAA8B,uEAE9BC,EAGO,uCAEP,YAAS,yBAA0B,IAAM,CACvC,IAAIC,EACAC,EACAC,EAQJ,MAAM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AI,yBACdD,EACAE,EACAN,EACAE,CACF,EACAG,EAAU,eAAe,EAEvBL,EAA2B,SAC3B,UAAU,EACZ,KAAG,eAAe,EAElBK,EAAU,iBAAiB,KAC3B,UAAOJ,EAAW,IAAI,EAAE,qBAAqB,oBAAoB,KACjE,UAAOA,EAAW,IAAI,EAAE,qBAAqB,sBAAsB,EAGnEF,EAAQ,KAAK,CAAE,UAAW,gBAAc,SAAU,CAAC,EAEnD,KAAG,oBAAoB,GAAI,KAC3B,UACGC,EAA2B,SAAsC,KAC/D,MAAM,MACX,EAAE,gBAAgB,CAAC,CACrB,CAAC,CACH,CAAC",
6
6
  "names": ["import_rxjs", "import_vitest", "import_DeviceModel", "import_DeviceSessionRefresherConst", "import_DeviceSessionEventDispatcher", "import_DeviceSessionRefresher", "subject", "mockSessionEventDispatcher", "mockLogger", "stubDefaultDevice", "stubNanoSDevice", "mockedLoggerModuleFactory", "refresher", "options", "lowInterval", "expectedMessage", "defaultNanoPollingInterval", "validInterval", "timerInterval"]
7
7
  }
@@ -1,2 +1,2 @@
1
- "use strict";var y=Object.defineProperty;var h=Object.getOwnPropertyDescriptor;var b=Object.getOwnPropertyNames;var V=Object.prototype.hasOwnProperty;var P=(o,e)=>{for(var r in e)y(o,r,{get:e[r],enumerable:!0})},k=(o,e,r,t)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of b(e))!V.call(o,i)&&i!==r&&y(o,i,{get:()=>e[i],enumerable:!(t=h(e,i))||t.enumerable});return o};var I=o=>k(y({},"__esModule",{value:!0}),o),g=(o,e,r,t)=>{for(var i=t>1?void 0:t?h(e,r):e,a=o.length-1,p;a>=0;a--)(p=o[a])&&(i=(t?p(e,r,i):p(i))||i);return t&&i&&y(e,r,i),i},v=(o,e)=>(r,t)=>e(r,t,o);var T={};P(T,{HttpManagerApiDataSource:()=>l});module.exports=I(T);var u=require("inversify"),n=require("purify-ts"),d=require("../../../api/network/DmkNetworkClient"),A=require("../../../api/network/DmkNetworkClientError"),w=require("../../manager-api/di/managerApiTypes"),m=require("../../manager-api/model/Application"),_=require("../../manager-api/model/Const"),D=require("../../manager-api/model/Const"),f=require("../../manager-api/model/Errors"),c=require("./ManagerApiDto");const s=o=>o instanceof A.DmkNetworkClientError&&o.cause!==void 0?new f.HttpFetchApiError(o.cause):new f.HttpFetchApiError(o);let l=class{http;_provider=_.DEFAULT_PROVIDER;_firmwareDistributionSalt=D.DEFAULT_FIRMWARE_DISTRIBUTION_SALT;constructor({managerApiUrl:e,provider:r,firmwareDistributionSalt:t}){this.http=new d.DmkNetworkClient({baseUrl:e}),this._provider=r,this._firmwareDistributionSalt=t}setProvider(e){this._provider===e||e<1||(this._provider=e)}getProvider(){return this._provider}getAppList(e){const{targetId:r,firmwareVersionName:t}=e;return(0,n.EitherAsync)(()=>this.http.get("/v2/apps/by-target",{params:{target_id:r,provider:this._provider,firmware_version_name:t}})).chain(i=>this.mapApplicationDtoToApplication(i)).mapLeft(s)}getMcuList(){return(0,n.EitherAsync)(()=>this.http.get("/mcu_versions")).chain(e=>this.mapMcuDtoToMcu(e)).mapLeft(s)}getDeviceVersion(e){const{targetId:r}=e;return(0,n.EitherAsync)(()=>this.http.get("/get_device_version",{params:{target_id:r,provider:this._provider}})).chain(t=>this.mapDeviceVersionDto(t)).mapLeft(s)}getFirmwareVersion(e){const{deviceId:r,version:t}=e;return(0,n.EitherAsync)(()=>this.http.get("/get_firmware_version",{params:{device_version:r,version_name:t,provider:this._provider}})).chain(i=>this.mapFinalFirmwareDto(i)).mapLeft(s)}getFirmwareVersionById(e){return(0,n.EitherAsync)(()=>this.http.get(`/firmware_final_versions/${e}`)).chain(r=>this.mapFinalFirmwareDto(r)).mapLeft(s)}getOsuFirmwareVersion(e){const{deviceId:r,version:t}=e;return(0,n.EitherAsync)(()=>this.http.get("/get_osu_version",{params:{device_version:r,version_name:t,provider:this._provider}})).chain(i=>this.mapOsuFirmwareDto(i)).mapLeft(s)}getLatestFirmwareVersion(e){const r="34.27.0",{currentFinalFirmwareId:t,deviceId:i}=e;return(0,n.EitherAsync)(()=>this.http.get("/get_latest_firmware",{params:{current_se_firmware_final_version:t,device_version:i,provider:this._provider,salt:this._firmwareDistributionSalt,livecommonversion:r}})).chain(a=>this.mapLatestFirmwareDto(a)).mapLeft(s)}getAppsByHash(e){const{hashes:r}=e;return(0,n.EitherAsync)(()=>this.http.post("/v2/apps/hash",r)).chain(t=>this.mapNullableApplicationDtoToApplication(t)).mapLeft(s)}getLanguagePackages(e){const{deviceId:r,currentFinalFirmwareId:t}=e;return(0,n.EitherAsync)(()=>this.http.get("/language-packages",{params:{device_version:r,current_se_firmware_final_version:t}})).chain(i=>this.mapLanguagesDtoToLanguages(i)).mapLeft(s)}mapAppTypeDtoToAppType(e){if(e===null)return null;switch(e){case c.AppTypeDto.currency:return m.AppType.currency;case c.AppTypeDto.plugin:return m.AppType.plugin;case c.AppTypeDto.tool:return m.AppType.tool;case c.AppTypeDto.swap:return m.AppType.swap}}mapApplicationDtoToApplication(e){return(0,n.EitherAsync)(()=>Promise.resolve(e.map(r=>this.mapApplicationDto(r))))}mapNullableApplicationDtoToApplication(e){return(0,n.EitherAsync)(()=>Promise.resolve(e.map(r=>r===null?null:this.mapApplicationDto(r))))}mapApplicationDto(e){if(typeof e!="object"||typeof e.versionId!="number"||typeof e.versionName!="string"||e.versionDisplayName!==null&&typeof e.versionDisplayName!="string"||typeof e.version!="string"||e.currencyId!==null&&typeof e.currencyId!="string"||e.description!==null&&typeof e.description!="string"||e.applicationType!==null&&typeof e.applicationType!="string"||typeof e.dateModified!="string"||e.icon!==null&&typeof e.icon!="string"||e.authorName!==null&&typeof e.authorName!="string"||e.supportURL!==null&&typeof e.supportURL!="string"||e.contactURL!==null&&typeof e.contactURL!="string"||e.sourceURL!==null&&typeof e.sourceURL!="string"||e.compatibleWallets!==null&&typeof e.compatibleWallets!="string"||typeof e.hash!="string"||typeof e.perso!="string"||typeof e.firmware!="string"||typeof e.firmwareKey!="string"||typeof e.delete!="string"||typeof e.deleteKey!="string"||e.bytes!==null&&typeof e.bytes!="number"||e.warning!==null&&typeof e.warning!="string"||typeof e.isDevTools!="boolean"||e.category!==null&&typeof e.category!="number"||e.parent!==null&&typeof e.parent!="number"||e.parentName!==null&&typeof e.parentName!="string")throw new Error(`Incomplete application: ${JSON.stringify(e)}`);const{applicationType:r,hash:t,perso:i,firmware:a,firmwareKey:p,delete:F,deleteKey:E,...L}=e;return{...L,hash:t,perso:i,firmware:a,firmwareKey:p,delete:F,deleteKey:E,applicationType:this.mapAppTypeDtoToAppType(r)}}mapMcuDtoToMcu(e){return(0,n.EitherAsync)(()=>Promise.resolve(e.map(r=>{if(typeof r!="object"||typeof r.id!="number"||typeof r.name!="string")throw new Error(`Incomplete MCU version: ${JSON.stringify(r)}`);return{id:r.id,name:r.name}})))}mapDeviceVersionDto(e){return(0,n.EitherAsync)(()=>{if(typeof e!="object"||typeof e.id!="number")throw new Error(`Incomplete device version: ${JSON.stringify(e)}`);const r={id:e.id};return Promise.resolve(r)})}mapFinalFirmwareDto(e){return(0,n.EitherAsync)(()=>{if(typeof e!="object"||typeof e.id!="number"||typeof e.version!="string"||typeof e.perso!="string"||e.firmware!==null&&typeof e.firmware!="string"||e.firmware_key!==null&&typeof e.firmware_key!="string"||e.hash!==null&&typeof e.hash!="string"||e.bytes!==null&&typeof e.bytes!="number"||!Array.isArray(e.mcu_versions))throw new Error(`Incomplete final firmware: ${JSON.stringify(e)}`);const r={id:e.id,version:e.version,perso:e.perso,firmware:e.firmware,firmwareKey:e.firmware_key,hash:e.hash,bytes:e.bytes,mcuVersions:e.mcu_versions};return Promise.resolve(r)})}mapLatestFirmwareDto(e){return(0,n.EitherAsync)(()=>{if(e.result!=="success"||!e.se_firmware_osu_version)throw new Error(`Latest firmware could not be retrieved: ${e.result}`);const r=e.se_firmware_osu_version;return Promise.resolve(r)}).chain(r=>this.mapOsuFirmwareDto(r))}mapOsuFirmwareDto(e){return(0,n.EitherAsync)(()=>{if(typeof e!="object"||typeof e.id!="number"||typeof e.perso!="string"||typeof e.firmware!="string"||typeof e.firmware_key!="string"||e.hash!==null&&typeof e.hash!="string"||typeof e.next_se_firmware_final_version!="number")throw new Error(`Incomplete latest firmware: ${JSON.stringify(e)}`);const r={id:e.id,perso:e.perso,firmware:e.firmware,firmwareKey:e.firmware_key,hash:e.hash,nextFinalFirmware:e.next_se_firmware_final_version};return Promise.resolve(r)})}mapLanguagesDtoToLanguages(e){return(0,n.EitherAsync)(()=>Promise.resolve(e.map(r=>this.mapLanguageDto(r))))}mapLanguageDto(e){if(typeof e!="object"||typeof e.language!="string"||typeof e.languagePackageVersionId!="number"||typeof e.version!="string"||typeof e.language_package_id!="number"||typeof e.apdu_install_url!="string"||typeof e.apdu_uninstall_url!="string"||typeof e.bytes!="number"||typeof e.date_creation!="string"||typeof e.date_last_modified!="string")throw new Error(`Incomplete language version: ${JSON.stringify(e)}`);return{language:e.language,languagePackageVersionId:e.languagePackageVersionId,version:e.version,languagePackageId:e.language_package_id,apduInstallUrl:e.apdu_install_url,apduUninstallUrl:e.apdu_uninstall_url,bytes:e.bytes,dateCreation:e.date_creation,dateLastModified:e.date_last_modified}}};l=g([(0,u.injectable)(),v(0,(0,u.inject)(w.managerApiTypes.DmkConfig))],l);0&&(module.exports={HttpManagerApiDataSource});
1
+ "use strict";var y=Object.defineProperty;var h=Object.getOwnPropertyDescriptor;var b=Object.getOwnPropertyNames;var V=Object.prototype.hasOwnProperty;var P=(n,e)=>{for(var r in e)y(n,r,{get:e[r],enumerable:!0})},k=(n,e,r,t)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of b(e))!V.call(n,i)&&i!==r&&y(n,i,{get:()=>e[i],enumerable:!(t=h(e,i))||t.enumerable});return n};var I=n=>k(y({},"__esModule",{value:!0}),n),g=(n,e,r,t)=>{for(var i=t>1?void 0:t?h(e,r):e,a=n.length-1,p;a>=0;a--)(p=n[a])&&(i=(t?p(e,r,i):p(i))||i);return t&&i&&y(e,r,i),i},v=(n,e)=>(r,t)=>e(r,t,n);var T={};P(T,{HttpManagerApiDataSource:()=>l});module.exports=I(T);var u=require("inversify"),o=require("purify-ts"),d=require("../../../api/network/DmkNetworkClient"),A=require("../../../api/network/DmkNetworkClientError"),_=require("../../manager-api/di/managerApiTypes"),m=require("../../manager-api/model/Application"),w=require("../../manager-api/model/Const"),D=require("../../manager-api/model/Const"),f=require("../../manager-api/model/Errors"),c=require("./ManagerApiDto");const s=n=>n instanceof A.DmkNetworkClientError&&n.cause!==void 0?new f.HttpFetchApiError(n.cause):new f.HttpFetchApiError(n);let l=class{http;_provider=w.DEFAULT_PROVIDER;_firmwareDistributionSalt=D.DEFAULT_FIRMWARE_DISTRIBUTION_SALT;constructor({managerApiUrl:e,provider:r,firmwareDistributionSalt:t}){this.http=new d.DmkNetworkClient({baseUrl:e}),this._provider=r,this._firmwareDistributionSalt=t}setProvider(e){this._provider===e||e<1||(this._provider=e)}getProvider(){return this._provider}getAppList(e){const{targetId:r,firmwareVersionName:t}=e;return(0,o.EitherAsync)(()=>this.http.get("/v2/apps/by-target",{params:{target_id:r,provider:this._provider,firmware_version_name:t}})).chain(i=>this.mapApplicationDtoToApplication(i)).mapLeft(s)}getMcuList(){return(0,o.EitherAsync)(()=>this.http.get("/mcu_versions")).chain(e=>this.mapMcuDtoToMcu(e)).mapLeft(s)}getDeviceVersion(e){const{targetId:r}=e;return(0,o.EitherAsync)(()=>this.http.get("/get_device_version",{params:{target_id:r,provider:this._provider}})).chain(t=>this.mapDeviceVersionDto(t)).mapLeft(s)}getFirmwareVersion(e){const{deviceId:r,version:t}=e;return(0,o.EitherAsync)(()=>this.http.get("/get_firmware_version",{params:{device_version:r,version_name:t,provider:this._provider}})).chain(i=>this.mapFinalFirmwareDto(i)).mapLeft(s)}getFirmwareVersionById(e){return(0,o.EitherAsync)(()=>this.http.get(`/firmware_final_versions/${e}`)).chain(r=>this.mapFinalFirmwareDto(r)).mapLeft(s)}getOsuFirmwareVersion(e){const{deviceId:r,version:t}=e;return(0,o.EitherAsync)(()=>this.http.get("/get_osu_version",{params:{device_version:r,version_name:t,provider:this._provider}})).chain(i=>this.mapOsuFirmwareDto(i)).mapLeft(s)}getLatestFirmwareVersion(e){const r="34.27.0",{currentFinalFirmwareId:t,deviceId:i}=e;return(0,o.EitherAsync)(()=>this.http.get("/get_latest_firmware",{params:{current_se_firmware_final_version:t,device_version:i,provider:this._provider,salt:this._firmwareDistributionSalt,livecommonversion:r}})).chain(a=>this.mapLatestFirmwareDto(a)).mapLeft(s)}getAppsByHash(e){const{hashes:r}=e;return(0,o.EitherAsync)(()=>this.http.post("/v2/apps/hash",r)).chain(t=>this.mapNullableApplicationDtoToApplication(t)).mapLeft(s)}getLanguagePackages(e){const{deviceId:r,currentFinalFirmwareId:t}=e;return(0,o.EitherAsync)(()=>this.http.get("/language-packages",{params:{device_version:r,current_se_firmware_final_version:t}})).chain(i=>this.mapLanguagesDtoToLanguages(i)).mapLeft(s)}mapAppTypeDtoToAppType(e){if(e===null)return null;switch(e){case c.AppTypeDto.currency:return m.AppType.currency;case c.AppTypeDto.plugin:return m.AppType.plugin;case c.AppTypeDto.tool:return m.AppType.tool;case c.AppTypeDto.swap:return m.AppType.swap}}mapApplicationDtoToApplication(e){return(0,o.EitherAsync)(()=>Promise.resolve(e.map(r=>this.mapApplicationDto(r))))}mapNullableApplicationDtoToApplication(e){return(0,o.EitherAsync)(()=>Promise.resolve(e.map(r=>r===null?null:this.mapApplicationDto(r))))}mapApplicationDto(e){if(typeof e!="object"||typeof e.versionId!="number"||typeof e.versionName!="string"||e.versionDisplayName!==null&&typeof e.versionDisplayName!="string"||typeof e.version!="string"||e.currencyId!==null&&typeof e.currencyId!="string"||e.description!==null&&typeof e.description!="string"||e.applicationType!==null&&typeof e.applicationType!="string"||typeof e.dateModified!="string"||e.icon!==null&&typeof e.icon!="string"||e.authorName!==null&&typeof e.authorName!="string"||e.supportURL!==null&&typeof e.supportURL!="string"||e.contactURL!==null&&typeof e.contactURL!="string"||e.sourceURL!==null&&typeof e.sourceURL!="string"||e.compatibleWallets!==null&&typeof e.compatibleWallets!="string"||typeof e.hash!="string"||typeof e.perso!="string"||typeof e.firmware!="string"||typeof e.firmwareKey!="string"||typeof e.delete!="string"||typeof e.deleteKey!="string"||e.bytes!==null&&typeof e.bytes!="number"||e.warning!==null&&typeof e.warning!="string"||typeof e.isDevTools!="boolean"||e.category!==null&&typeof e.category!="number"||e.parent!==null&&typeof e.parent!="number"||e.parentName!==null&&typeof e.parentName!="string")throw new Error(`Incomplete application: ${JSON.stringify(e)}`);const{applicationType:r,hash:t,perso:i,firmware:a,firmwareKey:p,delete:F,deleteKey:E,...L}=e;return{...L,hash:t,perso:i,firmware:a,firmwareKey:p,delete:F,deleteKey:E,applicationType:this.mapAppTypeDtoToAppType(r)}}mapMcuDtoToMcu(e){return(0,o.EitherAsync)(()=>Promise.resolve(e.map(r=>{if(typeof r!="object"||typeof r.id!="number"||typeof r.name!="string"||typeof r.from_bootloader_version!="string")throw new Error(`Incomplete MCU version: ${JSON.stringify(r)}`);return{id:r.id,name:r.name,fromBootloaderVersion:r.from_bootloader_version,providers:r.providers}})))}mapDeviceVersionDto(e){return(0,o.EitherAsync)(()=>{if(typeof e!="object"||typeof e.id!="number")throw new Error(`Incomplete device version: ${JSON.stringify(e)}`);const r={id:e.id};return Promise.resolve(r)})}mapFinalFirmwareDto(e){return(0,o.EitherAsync)(()=>{if(typeof e!="object"||typeof e.id!="number"||typeof e.version!="string"||typeof e.perso!="string"||e.firmware!==null&&typeof e.firmware!="string"||e.firmware_key!==null&&typeof e.firmware_key!="string"||e.hash!==null&&typeof e.hash!="string"||e.bytes!==null&&typeof e.bytes!="number"||!Array.isArray(e.mcu_versions))throw new Error(`Incomplete final firmware: ${JSON.stringify(e)}`);const r={id:e.id,version:e.version,perso:e.perso,firmware:e.firmware,firmwareKey:e.firmware_key,hash:e.hash,bytes:e.bytes,mcuVersions:e.mcu_versions};return Promise.resolve(r)})}mapLatestFirmwareDto(e){return(0,o.EitherAsync)(()=>{if(e.result==="null")return Promise.resolve(null);if(e.result!=="success"||!e.se_firmware_osu_version)throw new Error(`Latest firmware could not be retrieved: ${e.result}`);const r=e.se_firmware_osu_version;return Promise.resolve(r)}).chain(r=>r===null?(0,o.EitherAsync)(()=>Promise.resolve(o.Nothing)):this.mapOsuFirmwareDto(r).map(t=>(0,o.Just)(t)))}mapOsuFirmwareDto(e){return(0,o.EitherAsync)(()=>{if(typeof e!="object"||typeof e.id!="number"||e.notes!==null&&typeof e.notes!="string"||typeof e.perso!="string"||typeof e.firmware!="string"||typeof e.firmware_key!="string"||e.hash!==null&&typeof e.hash!="string"||typeof e.next_se_firmware_final_version!="number")throw new Error(`Incomplete latest firmware: ${JSON.stringify(e)}`);const r={id:e.id,notes:e.notes,perso:e.perso,firmware:e.firmware,firmwareKey:e.firmware_key,hash:e.hash,nextFinalFirmware:e.next_se_firmware_final_version};return Promise.resolve(r)})}mapLanguagesDtoToLanguages(e){return(0,o.EitherAsync)(()=>Promise.resolve(e.map(r=>this.mapLanguageDto(r))))}mapLanguageDto(e){if(typeof e!="object"||typeof e.language!="string"||typeof e.languagePackageVersionId!="number"||typeof e.version!="string"||typeof e.language_package_id!="number"||typeof e.apdu_install_url!="string"||typeof e.apdu_uninstall_url!="string"||typeof e.bytes!="number"||typeof e.date_creation!="string"||typeof e.date_last_modified!="string")throw new Error(`Incomplete language version: ${JSON.stringify(e)}`);return{language:e.language,languagePackageVersionId:e.languagePackageVersionId,version:e.version,languagePackageId:e.language_package_id,apduInstallUrl:e.apdu_install_url,apduUninstallUrl:e.apdu_uninstall_url,bytes:e.bytes,dateCreation:e.date_creation,dateLastModified:e.date_last_modified}}};l=g([(0,u.injectable)(),v(0,(0,u.inject)(_.managerApiTypes.DmkConfig))],l);0&&(module.exports={HttpManagerApiDataSource});
2
2
  //# sourceMappingURL=HttpManagerApiDataSource.js.map