@ledgerhq/device-management-kit 1.0.1 → 1.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +63 -28
- package/lib/cjs/package.json +1 -1
- package/lib/cjs/src/api/DeviceManagementKit.js +1 -1
- package/lib/cjs/src/api/DeviceManagementKit.js.map +2 -2
- package/lib/cjs/src/api/apdu/utils/ApduBuilder.js +1 -1
- package/lib/cjs/src/api/apdu/utils/ApduBuilder.js.map +3 -3
- package/lib/cjs/src/api/command/os/GetBackgroundImageSizeCommand.js +2 -0
- package/lib/cjs/src/api/command/os/GetBackgroundImageSizeCommand.js.map +7 -0
- package/lib/cjs/src/api/command/os/GetBackgroundImageSizeCommand.test.js +2 -0
- package/lib/cjs/src/api/command/os/GetBackgroundImageSizeCommand.test.js.map +7 -0
- package/lib/cjs/src/api/device-action/DeviceAction.js +1 -1
- package/lib/cjs/src/api/device-action/DeviceAction.js.map +1 -1
- package/lib/cjs/src/api/device-action/__test-utils__/makeInternalApi.js +1 -1
- package/lib/cjs/src/api/device-action/__test-utils__/makeInternalApi.js.map +3 -3
- package/lib/cjs/src/api/device-action/__test-utils__/setupTestMachine.js +1 -1
- package/lib/cjs/src/api/device-action/__test-utils__/setupTestMachine.js.map +3 -3
- package/lib/cjs/src/api/device-action/model/UserInteractionRequired.js +1 -1
- package/lib/cjs/src/api/device-action/model/UserInteractionRequired.js.map +2 -2
- package/lib/cjs/src/api/device-action/os/CallTaskInAppDeviceAction/CallTaskInAppDeviceAction.js +1 -1
- package/lib/cjs/src/api/device-action/os/CallTaskInAppDeviceAction/CallTaskInAppDeviceAction.js.map +3 -3
- package/lib/cjs/src/api/device-action/os/CallTaskInAppDeviceAction/CallTaskInAppDeviceAction.test.js +1 -1
- package/lib/cjs/src/api/device-action/os/CallTaskInAppDeviceAction/CallTaskInAppDeviceAction.test.js.map +3 -3
- package/lib/cjs/src/api/device-action/os/CallTaskInAppDeviceAction/CallTaskInAppDeviceActionTypes.js +1 -1
- package/lib/cjs/src/api/device-action/os/CallTaskInAppDeviceAction/CallTaskInAppDeviceActionTypes.js.map +3 -3
- package/lib/cjs/src/api/device-action/os/GetDeviceMetadata/GetDeviceMetadataDeviceAction.js +1 -1
- package/lib/cjs/src/api/device-action/os/GetDeviceMetadata/GetDeviceMetadataDeviceAction.js.map +2 -2
- package/lib/cjs/src/api/device-action/os/GetDeviceMetadata/GetDeviceMetadataDeviceAction.test.js +1 -1
- package/lib/cjs/src/api/device-action/os/GetDeviceMetadata/GetDeviceMetadataDeviceAction.test.js.map +3 -3
- package/lib/cjs/src/api/device-action/os/GetDeviceMetadata/types.js +1 -1
- package/lib/cjs/src/api/device-action/os/GetDeviceMetadata/types.js.map +3 -3
- package/lib/cjs/src/api/device-action/os/GetDeviceStatus/GetDeviceStatusDeviceAction.js +1 -1
- package/lib/cjs/src/api/device-action/os/GetDeviceStatus/GetDeviceStatusDeviceAction.js.map +3 -3
- package/lib/cjs/src/api/device-action/os/GetDeviceStatus/GetDeviceStatusDeviceAction.test.js +1 -1
- package/lib/cjs/src/api/device-action/os/GetDeviceStatus/GetDeviceStatusDeviceAction.test.js.map +3 -3
- package/lib/cjs/src/api/device-action/os/GetDeviceStatus/types.js +1 -1
- package/lib/cjs/src/api/device-action/os/GetDeviceStatus/types.js.map +3 -3
- package/lib/cjs/src/api/device-action/os/GoToDashboard/GoToDashboardDeviceAction.js +1 -1
- package/lib/cjs/src/api/device-action/os/GoToDashboard/GoToDashboardDeviceAction.js.map +3 -3
- package/lib/cjs/src/api/device-action/os/GoToDashboard/GoToDashboardDeviceAction.test.js +1 -1
- package/lib/cjs/src/api/device-action/os/GoToDashboard/GoToDashboardDeviceAction.test.js.map +3 -3
- package/lib/cjs/src/api/device-action/os/GoToDashboard/types.js +1 -1
- package/lib/cjs/src/api/device-action/os/GoToDashboard/types.js.map +3 -3
- package/lib/cjs/src/api/device-action/os/InstallOrUpdateApps/InstallOrUpdateAppsDeviceAction.js +1 -1
- package/lib/cjs/src/api/device-action/os/InstallOrUpdateApps/InstallOrUpdateAppsDeviceAction.js.map +2 -2
- package/lib/cjs/src/api/device-action/os/InstallOrUpdateApps/InstallOrUpdateAppsDeviceAction.test.js +1 -1
- package/lib/cjs/src/api/device-action/os/InstallOrUpdateApps/InstallOrUpdateAppsDeviceAction.test.js.map +2 -2
- package/lib/cjs/src/api/device-action/os/InstallOrUpdateApps/types.js +1 -1
- package/lib/cjs/src/api/device-action/os/InstallOrUpdateApps/types.js.map +3 -3
- package/lib/cjs/src/api/device-action/os/ListApps/ListAppsDeviceAction.js +1 -1
- package/lib/cjs/src/api/device-action/os/ListApps/ListAppsDeviceAction.js.map +3 -3
- package/lib/cjs/src/api/device-action/os/ListApps/ListAppsDeviceAction.test.js +1 -1
- package/lib/cjs/src/api/device-action/os/ListApps/ListAppsDeviceAction.test.js.map +3 -3
- package/lib/cjs/src/api/device-action/os/ListApps/types.js +1 -1
- package/lib/cjs/src/api/device-action/os/ListApps/types.js.map +3 -3
- package/lib/cjs/src/api/device-action/os/ListAppsWithMetadata/ListAppsWithMetadataDeviceAction.js +1 -1
- package/lib/cjs/src/api/device-action/os/ListAppsWithMetadata/ListAppsWithMetadataDeviceAction.js.map +3 -3
- package/lib/cjs/src/api/device-action/os/ListAppsWithMetadata/ListAppsWithMetadataDeviceAction.test.js +1 -1
- package/lib/cjs/src/api/device-action/os/ListAppsWithMetadata/ListAppsWithMetadataDeviceAction.test.js.map +3 -3
- package/lib/cjs/src/api/device-action/os/ListAppsWithMetadata/types.js +1 -1
- package/lib/cjs/src/api/device-action/os/ListAppsWithMetadata/types.js.map +3 -3
- package/lib/cjs/src/api/device-action/os/OpenAppDeviceAction/OpenAppDeviceAction.js +1 -1
- package/lib/cjs/src/api/device-action/os/OpenAppDeviceAction/OpenAppDeviceAction.js.map +3 -3
- package/lib/cjs/src/api/device-action/os/OpenAppDeviceAction/OpenAppDeviceAction.test.js +1 -1
- package/lib/cjs/src/api/device-action/os/OpenAppDeviceAction/OpenAppDeviceAction.test.js.map +3 -3
- package/lib/cjs/src/api/device-action/os/OpenAppDeviceAction/types.js +1 -1
- package/lib/cjs/src/api/device-action/os/OpenAppDeviceAction/types.js.map +3 -3
- package/lib/cjs/src/api/device-action/os/OpenAppWithDependencies/OpenAppWithDependenciesDeviceAction.js +1 -1
- package/lib/cjs/src/api/device-action/os/OpenAppWithDependencies/OpenAppWithDependenciesDeviceAction.js.map +3 -3
- package/lib/cjs/src/api/device-action/os/OpenAppWithDependencies/OpenAppWithDependenciesDeviceAction.test.js +1 -1
- package/lib/cjs/src/api/device-action/os/OpenAppWithDependencies/OpenAppWithDependenciesDeviceAction.test.js.map +3 -3
- package/lib/cjs/src/api/device-action/os/OpenAppWithDependencies/types.js +1 -1
- package/lib/cjs/src/api/device-action/os/OpenAppWithDependencies/types.js.map +3 -3
- package/lib/cjs/src/api/device-action/os/SendCommandInAppDeviceAction/SendCommandInAppDeviceAction.js +1 -1
- package/lib/cjs/src/api/device-action/os/SendCommandInAppDeviceAction/SendCommandInAppDeviceAction.js.map +3 -3
- package/lib/cjs/src/api/device-action/os/SendCommandInAppDeviceAction/SendCommandInAppDeviceAction.test.js +1 -1
- package/lib/cjs/src/api/device-action/os/SendCommandInAppDeviceAction/SendCommandInAppDeviceAction.test.js.map +3 -3
- package/lib/cjs/src/api/device-action/os/SendCommandInAppDeviceAction/SendCommandInAppDeviceActionTypes.js +1 -1
- package/lib/cjs/src/api/device-action/os/SendCommandInAppDeviceAction/SendCommandInAppDeviceActionTypes.js.map +3 -3
- package/lib/cjs/src/api/device-action/task/GetFirmwareMetadataTask.js +1 -1
- package/lib/cjs/src/api/device-action/task/GetFirmwareMetadataTask.js.map +3 -3
- package/lib/cjs/src/api/device-action/xstate-utils/XStateDeviceAction.js +1 -1
- package/lib/cjs/src/api/device-action/xstate-utils/XStateDeviceAction.js.map +3 -3
- package/lib/cjs/src/api/index.js +1 -1
- package/lib/cjs/src/api/index.js.map +3 -3
- package/lib/cjs/src/api/logger-publisher/utils/noopLoggerFactory.js +2 -0
- package/lib/cjs/src/api/logger-publisher/utils/noopLoggerFactory.js.map +7 -0
- package/lib/cjs/src/api/logger-publisher/utils/noopLoggerFactory.test.js +2 -0
- package/lib/cjs/src/api/logger-publisher/utils/noopLoggerFactory.test.js.map +7 -0
- package/lib/cjs/src/api/logger-subscriber/service/WebLogsExporterLogger.test.js +1 -1
- package/lib/cjs/src/api/logger-subscriber/service/WebLogsExporterLogger.test.js.map +2 -2
- package/lib/cjs/src/api/secure-channel/task/ConnectToSecureChannelTask.js +1 -1
- package/lib/cjs/src/api/secure-channel/task/ConnectToSecureChannelTask.js.map +3 -3
- package/lib/cjs/src/api/transport/model/DeviceConnectionStateMachine.js +1 -1
- package/lib/cjs/src/api/transport/model/DeviceConnectionStateMachine.js.map +3 -3
- package/lib/cjs/src/api/transport/model/DeviceConnectionStateMachine.test.js +1 -1
- package/lib/cjs/src/api/transport/model/DeviceConnectionStateMachine.test.js.map +3 -3
- package/lib/cjs/src/api/transport/model/Errors.js +1 -1
- package/lib/cjs/src/api/transport/model/Errors.js.map +3 -3
- package/lib/cjs/src/api/types.js +1 -1
- package/lib/cjs/src/api/types.js.map +1 -1
- package/lib/cjs/src/api/utils/ApplicationChecker.js +2 -0
- package/lib/cjs/src/api/utils/ApplicationChecker.js.map +7 -0
- package/lib/cjs/src/api/utils/ApplicationChecker.test.js +2 -0
- package/lib/cjs/src/api/utils/ApplicationChecker.test.js.map +7 -0
- package/lib/cjs/src/api/utils/ApplicationResolver.js +2 -0
- package/lib/cjs/src/api/utils/ApplicationResolver.js.map +7 -0
- package/lib/cjs/src/api/utils/Base64String.js +1 -1
- package/lib/cjs/src/api/utils/Base64String.js.map +3 -3
- package/lib/cjs/src/api/utils/Base64String.test.js +1 -1
- package/lib/cjs/src/api/utils/Base64String.test.js.map +3 -3
- package/lib/cjs/src/internal/device-session/di/deviceSessionModule.js +1 -1
- package/lib/cjs/src/internal/device-session/di/deviceSessionModule.js.map +3 -3
- package/lib/cjs/src/internal/device-session/di/deviceSessionTypes.js +1 -1
- package/lib/cjs/src/internal/device-session/di/deviceSessionTypes.js.map +2 -2
- package/lib/cjs/src/internal/device-session/model/DevicePinger.js +1 -1
- package/lib/cjs/src/internal/device-session/model/DevicePinger.js.map +2 -2
- package/lib/cjs/src/internal/device-session/model/DevicePinger.test.js +1 -1
- package/lib/cjs/src/internal/device-session/model/DevicePinger.test.js.map +2 -2
- package/lib/cjs/src/internal/device-session/model/DeviceSession.js +1 -1
- package/lib/cjs/src/internal/device-session/model/DeviceSession.js.map +3 -3
- package/lib/cjs/src/internal/device-session/model/DeviceSession.test.js +1 -1
- package/lib/cjs/src/internal/device-session/model/DeviceSession.test.js.map +3 -3
- package/lib/cjs/src/internal/device-session/model/DeviceSessionEventDispatcher.js +1 -1
- package/lib/cjs/src/internal/device-session/model/DeviceSessionEventDispatcher.js.map +2 -2
- package/lib/cjs/src/internal/device-session/model/DeviceSessionRefresher.js +1 -1
- package/lib/cjs/src/internal/device-session/model/DeviceSessionRefresher.js.map +3 -3
- package/lib/cjs/src/internal/device-session/model/DeviceSessionRefresher.test.js +1 -1
- package/lib/cjs/src/internal/device-session/model/DeviceSessionRefresher.test.js.map +2 -2
- package/lib/cjs/src/internal/device-session/model/DeviceSessionStateHandler.js +1 -1
- package/lib/cjs/src/internal/device-session/model/DeviceSessionStateHandler.js.map +3 -3
- package/lib/cjs/src/internal/device-session/model/DeviceSessionStateHandler.test.js +1 -1
- package/lib/cjs/src/internal/device-session/model/DeviceSessionStateHandler.test.js.map +2 -2
- package/lib/cjs/src/internal/device-session/service/IntentQueueService.js +2 -0
- package/lib/cjs/src/internal/device-session/service/IntentQueueService.js.map +7 -0
- package/lib/cjs/src/internal/device-session/service/IntentQueueService.test.js +2 -0
- package/lib/cjs/src/internal/device-session/service/IntentQueueService.test.js.map +7 -0
- package/lib/cjs/src/internal/device-session/use-case/UnsafeBypassIntentQueueUseCase.js +2 -0
- package/lib/cjs/src/internal/device-session/use-case/UnsafeBypassIntentQueueUseCase.js.map +7 -0
- package/lib/cjs/src/internal/discovery/use-case/ConnectUseCase.test.js +1 -1
- package/lib/cjs/src/internal/discovery/use-case/ConnectUseCase.test.js.map +3 -3
- package/lib/cjs/src/internal/send/use-case/SendApduUseCase.test.js +1 -1
- package/lib/cjs/src/internal/send/use-case/SendApduUseCase.test.js.map +3 -3
- package/lib/esm/package.json +1 -1
- package/lib/esm/src/api/DeviceManagementKit.js +1 -1
- package/lib/esm/src/api/DeviceManagementKit.js.map +2 -2
- package/lib/esm/src/api/apdu/utils/ApduBuilder.js +1 -1
- package/lib/esm/src/api/apdu/utils/ApduBuilder.js.map +3 -3
- package/lib/esm/src/api/command/os/GetBackgroundImageSizeCommand.js +2 -0
- package/lib/esm/src/api/command/os/GetBackgroundImageSizeCommand.js.map +7 -0
- package/lib/esm/src/api/command/os/GetBackgroundImageSizeCommand.test.js +2 -0
- package/lib/esm/src/api/command/os/GetBackgroundImageSizeCommand.test.js.map +7 -0
- package/lib/esm/src/api/device-action/__test-utils__/makeInternalApi.js +1 -1
- package/lib/esm/src/api/device-action/__test-utils__/makeInternalApi.js.map +3 -3
- package/lib/esm/src/api/device-action/__test-utils__/setupTestMachine.js +1 -1
- package/lib/esm/src/api/device-action/__test-utils__/setupTestMachine.js.map +3 -3
- package/lib/esm/src/api/device-action/model/UserInteractionRequired.js +1 -1
- package/lib/esm/src/api/device-action/model/UserInteractionRequired.js.map +2 -2
- package/lib/esm/src/api/device-action/os/CallTaskInAppDeviceAction/CallTaskInAppDeviceAction.js +1 -1
- package/lib/esm/src/api/device-action/os/CallTaskInAppDeviceAction/CallTaskInAppDeviceAction.js.map +3 -3
- package/lib/esm/src/api/device-action/os/CallTaskInAppDeviceAction/CallTaskInAppDeviceAction.test.js +1 -1
- package/lib/esm/src/api/device-action/os/CallTaskInAppDeviceAction/CallTaskInAppDeviceAction.test.js.map +3 -3
- package/lib/esm/src/api/device-action/os/CallTaskInAppDeviceAction/CallTaskInAppDeviceActionTypes.js +1 -0
- package/lib/esm/src/api/device-action/os/CallTaskInAppDeviceAction/CallTaskInAppDeviceActionTypes.js.map +4 -4
- package/lib/esm/src/api/device-action/os/GetDeviceMetadata/GetDeviceMetadataDeviceAction.js +1 -1
- package/lib/esm/src/api/device-action/os/GetDeviceMetadata/GetDeviceMetadataDeviceAction.js.map +3 -3
- package/lib/esm/src/api/device-action/os/GetDeviceMetadata/GetDeviceMetadataDeviceAction.test.js +1 -1
- package/lib/esm/src/api/device-action/os/GetDeviceMetadata/GetDeviceMetadataDeviceAction.test.js.map +3 -3
- package/lib/esm/src/api/device-action/os/GetDeviceMetadata/types.js +1 -0
- package/lib/esm/src/api/device-action/os/GetDeviceMetadata/types.js.map +4 -4
- package/lib/esm/src/api/device-action/os/GetDeviceStatus/GetDeviceStatusDeviceAction.js +1 -1
- package/lib/esm/src/api/device-action/os/GetDeviceStatus/GetDeviceStatusDeviceAction.js.map +3 -3
- package/lib/esm/src/api/device-action/os/GetDeviceStatus/GetDeviceStatusDeviceAction.test.js +1 -1
- package/lib/esm/src/api/device-action/os/GetDeviceStatus/GetDeviceStatusDeviceAction.test.js.map +3 -3
- package/lib/esm/src/api/device-action/os/GetDeviceStatus/types.js +1 -0
- package/lib/esm/src/api/device-action/os/GetDeviceStatus/types.js.map +4 -4
- package/lib/esm/src/api/device-action/os/GoToDashboard/GoToDashboardDeviceAction.js +1 -1
- package/lib/esm/src/api/device-action/os/GoToDashboard/GoToDashboardDeviceAction.js.map +3 -3
- package/lib/esm/src/api/device-action/os/GoToDashboard/GoToDashboardDeviceAction.test.js +1 -1
- package/lib/esm/src/api/device-action/os/GoToDashboard/GoToDashboardDeviceAction.test.js.map +3 -3
- package/lib/esm/src/api/device-action/os/GoToDashboard/types.js +1 -0
- package/lib/esm/src/api/device-action/os/GoToDashboard/types.js.map +4 -4
- package/lib/esm/src/api/device-action/os/InstallOrUpdateApps/InstallOrUpdateAppsDeviceAction.js +1 -1
- package/lib/esm/src/api/device-action/os/InstallOrUpdateApps/InstallOrUpdateAppsDeviceAction.js.map +3 -3
- package/lib/esm/src/api/device-action/os/InstallOrUpdateApps/InstallOrUpdateAppsDeviceAction.test.js +1 -1
- package/lib/esm/src/api/device-action/os/InstallOrUpdateApps/InstallOrUpdateAppsDeviceAction.test.js.map +3 -3
- package/lib/esm/src/api/device-action/os/InstallOrUpdateApps/types.js +1 -0
- package/lib/esm/src/api/device-action/os/InstallOrUpdateApps/types.js.map +4 -4
- package/lib/esm/src/api/device-action/os/ListApps/ListAppsDeviceAction.js +1 -1
- package/lib/esm/src/api/device-action/os/ListApps/ListAppsDeviceAction.js.map +3 -3
- package/lib/esm/src/api/device-action/os/ListApps/ListAppsDeviceAction.test.js +1 -1
- package/lib/esm/src/api/device-action/os/ListApps/ListAppsDeviceAction.test.js.map +3 -3
- package/lib/esm/src/api/device-action/os/ListApps/types.js +1 -0
- package/lib/esm/src/api/device-action/os/ListApps/types.js.map +4 -4
- package/lib/esm/src/api/device-action/os/ListAppsWithMetadata/ListAppsWithMetadataDeviceAction.js +1 -1
- package/lib/esm/src/api/device-action/os/ListAppsWithMetadata/ListAppsWithMetadataDeviceAction.js.map +3 -3
- package/lib/esm/src/api/device-action/os/ListAppsWithMetadata/ListAppsWithMetadataDeviceAction.test.js +1 -1
- package/lib/esm/src/api/device-action/os/ListAppsWithMetadata/ListAppsWithMetadataDeviceAction.test.js.map +3 -3
- package/lib/esm/src/api/device-action/os/ListAppsWithMetadata/types.js +1 -0
- package/lib/esm/src/api/device-action/os/ListAppsWithMetadata/types.js.map +4 -4
- package/lib/esm/src/api/device-action/os/OpenAppDeviceAction/OpenAppDeviceAction.js +1 -1
- package/lib/esm/src/api/device-action/os/OpenAppDeviceAction/OpenAppDeviceAction.js.map +3 -3
- package/lib/esm/src/api/device-action/os/OpenAppDeviceAction/OpenAppDeviceAction.test.js +1 -1
- package/lib/esm/src/api/device-action/os/OpenAppDeviceAction/OpenAppDeviceAction.test.js.map +3 -3
- package/lib/esm/src/api/device-action/os/OpenAppDeviceAction/types.js +1 -0
- package/lib/esm/src/api/device-action/os/OpenAppDeviceAction/types.js.map +4 -4
- package/lib/esm/src/api/device-action/os/OpenAppWithDependencies/OpenAppWithDependenciesDeviceAction.js +1 -1
- package/lib/esm/src/api/device-action/os/OpenAppWithDependencies/OpenAppWithDependenciesDeviceAction.js.map +3 -3
- package/lib/esm/src/api/device-action/os/OpenAppWithDependencies/OpenAppWithDependenciesDeviceAction.test.js +1 -1
- package/lib/esm/src/api/device-action/os/OpenAppWithDependencies/OpenAppWithDependenciesDeviceAction.test.js.map +3 -3
- package/lib/esm/src/api/device-action/os/OpenAppWithDependencies/types.js +1 -0
- package/lib/esm/src/api/device-action/os/OpenAppWithDependencies/types.js.map +4 -4
- package/lib/esm/src/api/device-action/os/SendCommandInAppDeviceAction/SendCommandInAppDeviceAction.js +1 -1
- package/lib/esm/src/api/device-action/os/SendCommandInAppDeviceAction/SendCommandInAppDeviceAction.js.map +3 -3
- package/lib/esm/src/api/device-action/os/SendCommandInAppDeviceAction/SendCommandInAppDeviceAction.test.js +1 -1
- package/lib/esm/src/api/device-action/os/SendCommandInAppDeviceAction/SendCommandInAppDeviceAction.test.js.map +3 -3
- package/lib/esm/src/api/device-action/os/SendCommandInAppDeviceAction/SendCommandInAppDeviceActionTypes.js +1 -0
- package/lib/esm/src/api/device-action/os/SendCommandInAppDeviceAction/SendCommandInAppDeviceActionTypes.js.map +4 -4
- package/lib/esm/src/api/device-action/task/GetFirmwareMetadataTask.js +1 -1
- package/lib/esm/src/api/device-action/task/GetFirmwareMetadataTask.js.map +3 -3
- package/lib/esm/src/api/device-action/xstate-utils/XStateDeviceAction.js +1 -1
- package/lib/esm/src/api/device-action/xstate-utils/XStateDeviceAction.js.map +3 -3
- package/lib/esm/src/api/index.js +1 -1
- package/lib/esm/src/api/index.js.map +3 -3
- package/lib/esm/src/api/logger-publisher/utils/noopLoggerFactory.js +2 -0
- package/lib/esm/src/api/logger-publisher/utils/noopLoggerFactory.js.map +7 -0
- package/lib/esm/src/api/logger-publisher/utils/noopLoggerFactory.test.js +2 -0
- package/lib/esm/src/api/logger-publisher/utils/noopLoggerFactory.test.js.map +7 -0
- package/lib/esm/src/api/logger-subscriber/service/WebLogsExporterLogger.test.js +1 -1
- package/lib/esm/src/api/logger-subscriber/service/WebLogsExporterLogger.test.js.map +3 -3
- package/lib/esm/src/api/secure-channel/task/ConnectToSecureChannelTask.js +1 -1
- package/lib/esm/src/api/secure-channel/task/ConnectToSecureChannelTask.js.map +3 -3
- package/lib/esm/src/api/transport/model/DeviceConnectionStateMachine.js +1 -1
- package/lib/esm/src/api/transport/model/DeviceConnectionStateMachine.js.map +3 -3
- package/lib/esm/src/api/transport/model/DeviceConnectionStateMachine.test.js +1 -1
- package/lib/esm/src/api/transport/model/DeviceConnectionStateMachine.test.js.map +3 -3
- package/lib/esm/src/api/transport/model/Errors.js +1 -1
- package/lib/esm/src/api/transport/model/Errors.js.map +3 -3
- package/lib/esm/src/api/utils/ApplicationChecker.js +2 -0
- package/lib/esm/src/api/utils/ApplicationChecker.js.map +7 -0
- package/lib/esm/src/api/utils/ApplicationChecker.test.js +2 -0
- package/lib/esm/src/api/utils/ApplicationChecker.test.js.map +7 -0
- package/lib/esm/src/api/utils/ApplicationResolver.js +1 -0
- package/lib/esm/src/api/utils/ApplicationResolver.js.map +7 -0
- package/lib/esm/src/api/utils/Base64String.js +1 -1
- package/lib/esm/src/api/utils/Base64String.js.map +3 -3
- package/lib/esm/src/api/utils/Base64String.test.js +1 -1
- package/lib/esm/src/api/utils/Base64String.test.js.map +3 -3
- package/lib/esm/src/internal/device-session/di/deviceSessionModule.js +1 -1
- package/lib/esm/src/internal/device-session/di/deviceSessionModule.js.map +3 -3
- package/lib/esm/src/internal/device-session/di/deviceSessionTypes.js +1 -1
- package/lib/esm/src/internal/device-session/di/deviceSessionTypes.js.map +2 -2
- package/lib/esm/src/internal/device-session/model/DevicePinger.js +1 -1
- package/lib/esm/src/internal/device-session/model/DevicePinger.js.map +2 -2
- package/lib/esm/src/internal/device-session/model/DevicePinger.test.js +1 -1
- package/lib/esm/src/internal/device-session/model/DevicePinger.test.js.map +2 -2
- package/lib/esm/src/internal/device-session/model/DeviceSession.js +1 -1
- package/lib/esm/src/internal/device-session/model/DeviceSession.js.map +3 -3
- package/lib/esm/src/internal/device-session/model/DeviceSession.test.js +1 -1
- package/lib/esm/src/internal/device-session/model/DeviceSession.test.js.map +3 -3
- package/lib/esm/src/internal/device-session/model/DeviceSessionEventDispatcher.js +1 -1
- package/lib/esm/src/internal/device-session/model/DeviceSessionEventDispatcher.js.map +2 -2
- package/lib/esm/src/internal/device-session/model/DeviceSessionRefresher.js +1 -1
- package/lib/esm/src/internal/device-session/model/DeviceSessionRefresher.js.map +3 -3
- package/lib/esm/src/internal/device-session/model/DeviceSessionRefresher.test.js +1 -1
- package/lib/esm/src/internal/device-session/model/DeviceSessionRefresher.test.js.map +2 -2
- package/lib/esm/src/internal/device-session/model/DeviceSessionStateHandler.js +1 -1
- package/lib/esm/src/internal/device-session/model/DeviceSessionStateHandler.js.map +3 -3
- package/lib/esm/src/internal/device-session/model/DeviceSessionStateHandler.test.js +1 -1
- package/lib/esm/src/internal/device-session/model/DeviceSessionStateHandler.test.js.map +2 -2
- package/lib/esm/src/internal/device-session/service/IntentQueueService.js +2 -0
- package/lib/esm/src/internal/device-session/service/IntentQueueService.js.map +7 -0
- package/lib/esm/src/internal/device-session/service/IntentQueueService.test.js +2 -0
- package/lib/esm/src/internal/device-session/service/IntentQueueService.test.js.map +7 -0
- package/lib/esm/src/internal/device-session/use-case/UnsafeBypassIntentQueueUseCase.js +2 -0
- package/lib/esm/src/internal/device-session/use-case/UnsafeBypassIntentQueueUseCase.js.map +7 -0
- package/lib/esm/src/internal/discovery/use-case/ConnectUseCase.test.js +1 -1
- package/lib/esm/src/internal/discovery/use-case/ConnectUseCase.test.js.map +3 -3
- package/lib/esm/src/internal/send/use-case/SendApduUseCase.test.js +1 -1
- package/lib/esm/src/internal/send/use-case/SendApduUseCase.test.js.map +3 -3
- package/lib/types/src/api/DeviceManagementKit.d.ts +10 -0
- package/lib/types/src/api/DeviceManagementKit.d.ts.map +1 -1
- package/lib/types/src/api/apdu/utils/ApduBuilder.d.ts +7 -0
- package/lib/types/src/api/apdu/utils/ApduBuilder.d.ts.map +1 -1
- package/lib/types/src/api/command/os/GetBackgroundImageSizeCommand.d.ts +17 -0
- package/lib/types/src/api/command/os/GetBackgroundImageSizeCommand.d.ts.map +1 -0
- package/lib/types/src/api/command/os/GetBackgroundImageSizeCommand.test.d.ts +2 -0
- package/lib/types/src/api/command/os/GetBackgroundImageSizeCommand.test.d.ts.map +1 -0
- package/lib/types/src/api/device-action/DeviceAction.d.ts +2 -1
- package/lib/types/src/api/device-action/DeviceAction.d.ts.map +1 -1
- package/lib/types/src/api/device-action/__test-utils__/makeInternalApi.d.ts.map +1 -1
- package/lib/types/src/api/device-action/__test-utils__/setupTestMachine.d.ts.map +1 -1
- package/lib/types/src/api/device-action/model/UserInteractionRequired.d.ts +4 -1
- package/lib/types/src/api/device-action/model/UserInteractionRequired.d.ts.map +1 -1
- package/lib/types/src/api/device-action/os/CallTaskInAppDeviceAction/CallTaskInAppDeviceAction.d.ts.map +1 -1
- package/lib/types/src/api/device-action/os/CallTaskInAppDeviceAction/CallTaskInAppDeviceActionTypes.d.ts +9 -1
- package/lib/types/src/api/device-action/os/CallTaskInAppDeviceAction/CallTaskInAppDeviceActionTypes.d.ts.map +1 -1
- package/lib/types/src/api/device-action/os/GetDeviceMetadata/GetDeviceMetadataDeviceAction.d.ts.map +1 -1
- package/lib/types/src/api/device-action/os/GetDeviceMetadata/types.d.ts +13 -2
- package/lib/types/src/api/device-action/os/GetDeviceMetadata/types.d.ts.map +1 -1
- package/lib/types/src/api/device-action/os/GetDeviceStatus/GetDeviceStatusDeviceAction.d.ts.map +1 -1
- package/lib/types/src/api/device-action/os/GetDeviceStatus/types.d.ts +6 -0
- package/lib/types/src/api/device-action/os/GetDeviceStatus/types.d.ts.map +1 -1
- package/lib/types/src/api/device-action/os/GoToDashboard/GoToDashboardDeviceAction.d.ts +1 -1
- package/lib/types/src/api/device-action/os/GoToDashboard/GoToDashboardDeviceAction.d.ts.map +1 -1
- package/lib/types/src/api/device-action/os/GoToDashboard/types.d.ts +9 -1
- package/lib/types/src/api/device-action/os/GoToDashboard/types.d.ts.map +1 -1
- package/lib/types/src/api/device-action/os/InstallOrUpdateApps/InstallOrUpdateAppsDeviceAction.d.ts.map +1 -1
- package/lib/types/src/api/device-action/os/InstallOrUpdateApps/types.d.ts +9 -1
- package/lib/types/src/api/device-action/os/InstallOrUpdateApps/types.d.ts.map +1 -1
- package/lib/types/src/api/device-action/os/ListApps/ListAppsDeviceAction.d.ts.map +1 -1
- package/lib/types/src/api/device-action/os/ListApps/types.d.ts +6 -0
- package/lib/types/src/api/device-action/os/ListApps/types.d.ts.map +1 -1
- package/lib/types/src/api/device-action/os/ListAppsWithMetadata/ListAppsWithMetadataDeviceAction.d.ts.map +1 -1
- package/lib/types/src/api/device-action/os/ListAppsWithMetadata/types.d.ts +8 -1
- package/lib/types/src/api/device-action/os/ListAppsWithMetadata/types.d.ts.map +1 -1
- package/lib/types/src/api/device-action/os/OpenAppDeviceAction/OpenAppDeviceAction.d.ts.map +1 -1
- package/lib/types/src/api/device-action/os/OpenAppDeviceAction/types.d.ts +12 -2
- package/lib/types/src/api/device-action/os/OpenAppDeviceAction/types.d.ts.map +1 -1
- package/lib/types/src/api/device-action/os/OpenAppWithDependencies/OpenAppWithDependenciesDeviceAction.d.ts.map +1 -1
- package/lib/types/src/api/device-action/os/OpenAppWithDependencies/types.d.ts +8 -0
- package/lib/types/src/api/device-action/os/OpenAppWithDependencies/types.d.ts.map +1 -1
- package/lib/types/src/api/device-action/os/SendCommandInAppDeviceAction/SendCommandInAppDeviceAction.d.ts.map +1 -1
- package/lib/types/src/api/device-action/os/SendCommandInAppDeviceAction/SendCommandInAppDeviceActionTypes.d.ts +9 -1
- package/lib/types/src/api/device-action/os/SendCommandInAppDeviceAction/SendCommandInAppDeviceActionTypes.d.ts.map +1 -1
- package/lib/types/src/api/device-action/xstate-utils/XStateDeviceAction.d.ts +10 -1
- package/lib/types/src/api/device-action/xstate-utils/XStateDeviceAction.d.ts.map +1 -1
- package/lib/types/src/api/index.d.ts +11 -4
- package/lib/types/src/api/index.d.ts.map +1 -1
- package/lib/types/src/api/logger-publisher/utils/noopLoggerFactory.d.ts +12 -0
- package/lib/types/src/api/logger-publisher/utils/noopLoggerFactory.d.ts.map +1 -0
- package/lib/types/src/api/logger-publisher/utils/noopLoggerFactory.test.d.ts +2 -0
- package/lib/types/src/api/logger-publisher/utils/noopLoggerFactory.test.d.ts.map +1 -0
- package/lib/types/src/api/secure-channel/task/ConnectToSecureChannelTask.d.ts.map +1 -1
- package/lib/types/src/api/transport/model/DeviceConnectionStateMachine.d.ts +1 -0
- package/lib/types/src/api/transport/model/DeviceConnectionStateMachine.d.ts.map +1 -1
- package/lib/types/src/api/transport/model/Errors.d.ts +5 -0
- package/lib/types/src/api/transport/model/Errors.d.ts.map +1 -1
- package/lib/types/src/api/types.d.ts +1 -0
- package/lib/types/src/api/types.d.ts.map +1 -1
- package/lib/types/src/api/utils/ApplicationChecker.d.ts +14 -0
- package/lib/types/src/api/utils/ApplicationChecker.d.ts.map +1 -0
- package/lib/types/src/api/utils/ApplicationChecker.test.d.ts +2 -0
- package/lib/types/src/api/utils/ApplicationChecker.test.d.ts.map +1 -0
- package/lib/types/src/api/utils/ApplicationResolver.d.ts +12 -0
- package/lib/types/src/api/utils/ApplicationResolver.d.ts.map +1 -0
- package/lib/types/src/api/utils/Base64String.d.ts +1 -0
- package/lib/types/src/api/utils/Base64String.d.ts.map +1 -1
- package/lib/types/src/internal/device-session/di/deviceSessionModule.d.ts.map +1 -1
- package/lib/types/src/internal/device-session/di/deviceSessionTypes.d.ts +1 -0
- package/lib/types/src/internal/device-session/di/deviceSessionTypes.d.ts.map +1 -1
- package/lib/types/src/internal/device-session/model/DeviceSession.d.ts +13 -2
- package/lib/types/src/internal/device-session/model/DeviceSession.d.ts.map +1 -1
- package/lib/types/src/internal/device-session/model/DeviceSessionEventDispatcher.d.ts +3 -1
- package/lib/types/src/internal/device-session/model/DeviceSessionEventDispatcher.d.ts.map +1 -1
- package/lib/types/src/internal/device-session/model/DeviceSessionRefresher.d.ts +0 -1
- package/lib/types/src/internal/device-session/model/DeviceSessionRefresher.d.ts.map +1 -1
- package/lib/types/src/internal/device-session/model/DeviceSessionStateHandler.d.ts +1 -0
- package/lib/types/src/internal/device-session/model/DeviceSessionStateHandler.d.ts.map +1 -1
- package/lib/types/src/internal/device-session/service/IntentQueueService.d.ts +101 -0
- package/lib/types/src/internal/device-session/service/IntentQueueService.d.ts.map +1 -0
- package/lib/types/src/internal/device-session/service/IntentQueueService.test.d.ts +2 -0
- package/lib/types/src/internal/device-session/service/IntentQueueService.test.d.ts.map +1 -0
- package/lib/types/src/internal/device-session/use-case/UnsafeBypassIntentQueueUseCase.d.ts +19 -0
- package/lib/types/src/internal/device-session/use-case/UnsafeBypassIntentQueueUseCase.d.ts.map +1 -0
- package/lib/types/tsconfig.prod.tsbuildinfo +1 -1
- package/package.json +4 -4
- package/lib/cjs/src/api/command/os/GetCustomImageSizeCommand.js +0 -2
- package/lib/cjs/src/api/command/os/GetCustomImageSizeCommand.js.map +0 -7
- package/lib/cjs/src/api/command/os/GetCustomImageSizeCommand.test.js +0 -2
- package/lib/cjs/src/api/command/os/GetCustomImageSizeCommand.test.js.map +0 -7
- package/lib/cjs/src/internal/device-session/service/MutexService.js +0 -2
- package/lib/cjs/src/internal/device-session/service/MutexService.js.map +0 -7
- package/lib/cjs/src/internal/device-session/service/MutexService.test.js +0 -2
- package/lib/cjs/src/internal/device-session/service/MutexService.test.js.map +0 -7
- package/lib/esm/src/api/command/os/GetCustomImageSizeCommand.js +0 -2
- package/lib/esm/src/api/command/os/GetCustomImageSizeCommand.js.map +0 -7
- package/lib/esm/src/api/command/os/GetCustomImageSizeCommand.test.js +0 -2
- package/lib/esm/src/api/command/os/GetCustomImageSizeCommand.test.js.map +0 -7
- package/lib/esm/src/internal/device-session/service/MutexService.js +0 -2
- package/lib/esm/src/internal/device-session/service/MutexService.js.map +0 -7
- package/lib/esm/src/internal/device-session/service/MutexService.test.js +0 -2
- package/lib/esm/src/internal/device-session/service/MutexService.test.js.map +0 -7
- package/lib/types/src/api/command/os/GetCustomImageSizeCommand.d.ts +0 -17
- package/lib/types/src/api/command/os/GetCustomImageSizeCommand.d.ts.map +0 -1
- package/lib/types/src/api/command/os/GetCustomImageSizeCommand.test.d.ts +0 -2
- package/lib/types/src/api/command/os/GetCustomImageSizeCommand.test.d.ts.map +0 -1
- package/lib/types/src/internal/device-session/service/MutexService.d.ts +0 -6
- package/lib/types/src/internal/device-session/service/MutexService.d.ts.map +0 -1
- package/lib/types/src/internal/device-session/service/MutexService.test.d.ts +0 -2
- package/lib/types/src/internal/device-session/service/MutexService.test.d.ts.map +0 -1
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";var
|
|
1
|
+
"use strict";var t=require("purify-ts"),p=require("../../../api/transport/model/Errors"),D=require("../../../api/transport/model/TransportConnectedDevice.stub"),k=require("../../logger-publisher/service/DefaultLoggerPublisherService"),v=require("./ConnectUseCase");vi.mock("uuid",()=>({v4:vi.fn().mockReturnValue("fakeSessionId")}));let o,e,r,n,a,d;const f="fakeSessionId",u="fakeSessionIdConnectedDevice";describe("ConnectUseCase",()=>{const i={id:"device-id",deviceModel:{},transport:"USB",name:"TEST"},l=(0,D.connectedDeviceStubBuilder)({id:"1"}),S={...l,sessionId:u,modelId:"model-id",name:"device-name",type:"MOCK"},g="logger-tag";beforeEach(()=>{r=new k.DefaultLoggerPublisherService([],g),o={connect:vi.fn()},e={getTransport:vi.fn()},n={addDeviceSession:vi.fn(),removeDeviceSession:vi.fn(),getDeviceSessionByDeviceId:vi.fn()},a={},d={}}),afterAll(()=>{vi.restoreAllMocks()}),test("should throw an error when transport connection fails",async()=>{const c=new p.UnknownDeviceError;vi.mocked(e.getTransport).mockReturnValue(t.Maybe.of(o)),vi.mocked(o.connect).mockResolvedValue((0,t.Left)(c));const s=new v.ConnectUseCase(e,n,()=>r,a,d);await expect(s.execute({device:i})).rejects.toBe(c),expect(e.getTransport).toHaveBeenCalledWith("USB"),expect(o.connect).toHaveBeenCalledWith({deviceId:i.id,onDisconnect:expect.any(Function)})}),test("should successfully connect and return a deviceSession id",async()=>{vi.mocked(e.getTransport).mockReturnValue(t.Maybe.of(o)),vi.mocked(o.connect).mockResolvedValue((0,t.Right)(l)),vi.mocked(n.addDeviceSession).mockImplementation(m=>(vi.spyOn(m,"initialiseSession").mockResolvedValue(void 0),n));const s=await new v.ConnectUseCase(e,n,()=>r,a,d).execute({device:i});expect(s).toBe(f),expect(e.getTransport).toHaveBeenCalledWith("USB"),expect(o.connect).toHaveBeenCalledWith({deviceId:i.id,onDisconnect:expect.any(Function)}),expect(n.addDeviceSession).toHaveBeenCalledWith(expect.objectContaining({id:f}))}),test("should reconnect with existing sessionId when connecting to a ConnectedDevice",async()=>{vi.mocked(e.getTransport).mockReturnValue(t.Maybe.of(o)),vi.mocked(o.connect).mockResolvedValue((0,t.Right)(l)),vi.mocked(n.addDeviceSession).mockImplementation(m=>(vi.spyOn(m,"initialiseSession").mockResolvedValue(void 0),n));const s=await new v.ConnectUseCase(e,n,()=>r,a,d).execute({device:S});expect(s).toBe(u),expect(e.getTransport).toHaveBeenCalledWith("USB"),expect(o.connect).toHaveBeenCalledWith({deviceId:S.id,onDisconnect:expect.any(Function)}),expect(n.addDeviceSession).toHaveBeenCalledWith(expect.objectContaining({id:u}))}),test("should throw an error when transport is not supported",async()=>{vi.mocked(e.getTransport).mockReturnValue(t.Maybe.empty());const c=new v.ConnectUseCase(e,n,()=>r,a,d);await expect(c.execute({device:i})).rejects.toBeInstanceOf(p.TransportNotSupportedError),expect(e.getTransport).toHaveBeenCalledWith("USB")})});
|
|
2
2
|
//# sourceMappingURL=ConnectUseCase.test.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../../src/internal/discovery/use-case/ConnectUseCase.test.ts"],
|
|
4
|
-
"sourcesContent": ["import { Left, Maybe, Right } from \"purify-ts\";\n\nimport { type DeviceModel, type DeviceModelId } from \"@api/device/DeviceModel\";\nimport { type
|
|
5
|
-
"mappings": "aAAA,IAAAA,EAAmC,qBAOnCC,
|
|
6
|
-
"names": ["import_purify_ts", "
|
|
4
|
+
"sourcesContent": ["import { Left, Maybe, Right } from \"purify-ts\";\n\nimport { type DeviceModel, type DeviceModelId } from \"@api/device/DeviceModel\";\nimport { type ConnectionType } from \"@api/discovery/ConnectionType\";\nimport { type LoggerPublisherService } from \"@api/logger-publisher/service/LoggerPublisherService\";\nimport { type ConnectedDevice } from \"@api/transport/model/ConnectedDevice\";\nimport { type DiscoveredDevice } from \"@api/transport/model/DiscoveredDevice\";\nimport {\n TransportNotSupportedError,\n UnknownDeviceError,\n} from \"@api/transport/model/Errors\";\nimport { type Transport } from \"@api/transport/model/Transport\";\nimport { connectedDeviceStubBuilder } from \"@api/transport/model/TransportConnectedDevice.stub\";\nimport { type DeviceSessionService } from \"@internal/device-session/service/DeviceSessionService\";\nimport { DefaultLoggerPublisherService } from \"@internal/logger-publisher/service/DefaultLoggerPublisherService\";\nimport { type ManagerApiService } from \"@internal/manager-api/service/ManagerApiService\";\nimport { type SecureChannelService } from \"@internal/secure-channel/service/SecureChannelService\";\nimport { type TransportService } from \"@internal/transport/service/TransportService\";\n\nimport { ConnectUseCase } from \"./ConnectUseCase\";\n\nvi.mock(\"uuid\", () => ({\n v4: vi.fn().mockReturnValue(\"fakeSessionId\"),\n}));\n\nlet transport: Transport;\nlet transportService: TransportService;\nlet logger: LoggerPublisherService;\nlet sessionService: DeviceSessionService;\nlet managerApi: ManagerApiService;\nlet secureChannel: SecureChannelService;\nconst fakeSessionId = \"fakeSessionId\";\nconst fakeSessionIdConnectedDevice = \"fakeSessionIdConnectedDevice\";\n\ndescribe(\"ConnectUseCase\", () => {\n const stubDiscoveredDevice: DiscoveredDevice = {\n id: \"device-id\",\n deviceModel: {} as DeviceModel,\n transport: \"USB\",\n name: \"TEST\",\n };\n const stubTransportConnectedDevice = connectedDeviceStubBuilder({ id: \"1\" });\n const stubConnectedDevice: ConnectedDevice = {\n ...stubTransportConnectedDevice,\n sessionId: fakeSessionIdConnectedDevice,\n modelId: \"model-id\" as DeviceModelId,\n name: \"device-name\",\n type: \"MOCK\" as ConnectionType,\n };\n const tag = \"logger-tag\";\n\n beforeEach(() => {\n logger = new DefaultLoggerPublisherService([], tag);\n\n // Mock Transport\n transport = {\n connect: vi.fn(),\n } as unknown as Transport;\n\n // Mock TransportService\n transportService = {\n getTransport: vi.fn(),\n } as unknown as TransportService;\n\n // Mock DeviceSessionService\n sessionService = {\n addDeviceSession: vi.fn(),\n removeDeviceSession: vi.fn(),\n getDeviceSessionByDeviceId: vi.fn(),\n } as unknown as DeviceSessionService;\n\n // Mock ManagerApiService\n managerApi = {} as ManagerApiService;\n\n // Mock SecureChannelService\n secureChannel = {} as SecureChannelService;\n });\n\n afterAll(() => {\n vi.restoreAllMocks();\n });\n\n test(\"should throw an error when transport connection fails\", async () => {\n // given\n const connectionError = new UnknownDeviceError();\n vi.mocked(transportService.getTransport).mockReturnValue(\n Maybe.of(transport),\n );\n vi.mocked(transport.connect).mockResolvedValue(Left(connectionError));\n\n const usecase = new ConnectUseCase(\n transportService,\n sessionService,\n () => logger,\n managerApi,\n secureChannel,\n );\n\n // when/then\n await expect(\n usecase.execute({ device: stubDiscoveredDevice }),\n ).rejects.toBe(connectionError);\n\n expect(transportService.getTransport).toHaveBeenCalledWith(\"USB\");\n expect(transport.connect).toHaveBeenCalledWith({\n deviceId: stubDiscoveredDevice.id,\n onDisconnect: expect.any(Function),\n });\n });\n\n test(\"should successfully connect and return a deviceSession id\", async () => {\n // given\n vi.mocked(transportService.getTransport).mockReturnValue(\n Maybe.of(transport),\n );\n vi.mocked(transport.connect).mockResolvedValue(\n Right(stubTransportConnectedDevice),\n );\n\n // Spy on addDeviceSession to capture the created session and mock its behavior\n vi.mocked(sessionService.addDeviceSession).mockImplementation(\n (deviceSession) => {\n // Mock the initialiseSession to avoid real initialization\n vi.spyOn(deviceSession, \"initialiseSession\").mockResolvedValue(\n undefined,\n );\n return sessionService;\n },\n );\n\n const usecase = new ConnectUseCase(\n transportService,\n sessionService,\n () => logger,\n managerApi,\n secureChannel,\n );\n\n // when\n const sessionId = await usecase.execute({\n device: stubDiscoveredDevice,\n });\n\n // then\n expect(sessionId).toBe(fakeSessionId);\n expect(transportService.getTransport).toHaveBeenCalledWith(\"USB\");\n expect(transport.connect).toHaveBeenCalledWith({\n deviceId: stubDiscoveredDevice.id,\n onDisconnect: expect.any(Function),\n });\n expect(sessionService.addDeviceSession).toHaveBeenCalledWith(\n expect.objectContaining({\n id: fakeSessionId,\n }),\n );\n });\n\n test(\"should reconnect with existing sessionId when connecting to a ConnectedDevice\", async () => {\n // given\n vi.mocked(transportService.getTransport).mockReturnValue(\n Maybe.of(transport),\n );\n vi.mocked(transport.connect).mockResolvedValue(\n Right(stubTransportConnectedDevice),\n );\n\n // Spy on addDeviceSession to capture the created session and mock its behavior\n vi.mocked(sessionService.addDeviceSession).mockImplementation(\n (deviceSession) => {\n // Mock the initialiseSession to avoid real initialization\n vi.spyOn(deviceSession, \"initialiseSession\").mockResolvedValue(\n undefined,\n );\n return sessionService;\n },\n );\n\n const usecase = new ConnectUseCase(\n transportService,\n sessionService,\n () => logger,\n managerApi,\n secureChannel,\n );\n\n // when\n const sessionId = await usecase.execute({\n device: stubConnectedDevice,\n });\n\n // then\n expect(sessionId).toBe(fakeSessionIdConnectedDevice);\n expect(transportService.getTransport).toHaveBeenCalledWith(\"USB\");\n expect(transport.connect).toHaveBeenCalledWith({\n deviceId: stubConnectedDevice.id,\n onDisconnect: expect.any(Function),\n });\n expect(sessionService.addDeviceSession).toHaveBeenCalledWith(\n expect.objectContaining({\n id: fakeSessionIdConnectedDevice,\n }),\n );\n });\n\n test(\"should throw an error when transport is not supported\", async () => {\n // given\n vi.mocked(transportService.getTransport).mockReturnValue(Maybe.empty());\n\n const usecase = new ConnectUseCase(\n transportService,\n sessionService,\n () => logger,\n managerApi,\n secureChannel,\n );\n\n // when/then\n await expect(\n usecase.execute({ device: stubDiscoveredDevice }),\n ).rejects.toBeInstanceOf(TransportNotSupportedError);\n\n expect(transportService.getTransport).toHaveBeenCalledWith(\"USB\");\n });\n});\n"],
|
|
5
|
+
"mappings": "aAAA,IAAAA,EAAmC,qBAOnCC,EAGO,uCAEPC,EAA2C,8DAE3CC,EAA8C,4EAK9CC,EAA+B,4BAE/B,GAAG,KAAK,OAAQ,KAAO,CACrB,GAAI,GAAG,GAAG,EAAE,gBAAgB,eAAe,CAC7C,EAAE,EAEF,IAAIC,EACAC,EACAC,EACAC,EACAC,EACAC,EACJ,MAAMC,EAAgB,gBAChBC,EAA+B,+BAErC,SAAS,iBAAkB,IAAM,CAC/B,MAAMC,EAAyC,CAC7C,GAAI,YACJ,YAAa,CAAC,EACd,UAAW,MACX,KAAM,MACR,EACMC,KAA+B,8BAA2B,CAAE,GAAI,GAAI,CAAC,EACrEC,EAAuC,CAC3C,GAAGD,EACH,UAAWF,EACX,QAAS,WACT,KAAM,cACN,KAAM,MACR,EACMI,EAAM,aAEZ,WAAW,IAAM,CACfT,EAAS,IAAI,gCAA8B,CAAC,EAAGS,CAAG,EAGlDX,EAAY,CACV,QAAS,GAAG,GAAG,CACjB,EAGAC,EAAmB,CACjB,aAAc,GAAG,GAAG,CACtB,EAGAE,EAAiB,CACf,iBAAkB,GAAG,GAAG,EACxB,oBAAqB,GAAG,GAAG,EAC3B,2BAA4B,GAAG,GAAG,CACpC,EAGAC,EAAa,CAAC,EAGdC,EAAgB,CAAC,CACnB,CAAC,EAED,SAAS,IAAM,CACb,GAAG,gBAAgB,CACrB,CAAC,EAED,KAAK,wDAAyD,SAAY,CAExE,MAAMO,EAAkB,IAAI,qBAC5B,GAAG,OAAOX,EAAiB,YAAY,EAAE,gBACvC,QAAM,GAAGD,CAAS,CACpB,EACA,GAAG,OAAOA,EAAU,OAAO,EAAE,qBAAkB,QAAKY,CAAe,CAAC,EAEpE,MAAMC,EAAU,IAAI,iBAClBZ,EACAE,EACA,IAAMD,EACNE,EACAC,CACF,EAGA,MAAM,OACJQ,EAAQ,QAAQ,CAAE,OAAQL,CAAqB,CAAC,CAClD,EAAE,QAAQ,KAAKI,CAAe,EAE9B,OAAOX,EAAiB,YAAY,EAAE,qBAAqB,KAAK,EAChE,OAAOD,EAAU,OAAO,EAAE,qBAAqB,CAC7C,SAAUQ,EAAqB,GAC/B,aAAc,OAAO,IAAI,QAAQ,CACnC,CAAC,CACH,CAAC,EAED,KAAK,4DAA6D,SAAY,CAE5E,GAAG,OAAOP,EAAiB,YAAY,EAAE,gBACvC,QAAM,GAAGD,CAAS,CACpB,EACA,GAAG,OAAOA,EAAU,OAAO,EAAE,qBAC3B,SAAMS,CAA4B,CACpC,EAGA,GAAG,OAAON,EAAe,gBAAgB,EAAE,mBACxCW,IAEC,GAAG,MAAMA,EAAe,mBAAmB,EAAE,kBAC3C,MACF,EACOX,EAEX,EAWA,MAAMY,EAAY,MATF,IAAI,iBAClBd,EACAE,EACA,IAAMD,EACNE,EACAC,CACF,EAGgC,QAAQ,CACtC,OAAQG,CACV,CAAC,EAGD,OAAOO,CAAS,EAAE,KAAKT,CAAa,EACpC,OAAOL,EAAiB,YAAY,EAAE,qBAAqB,KAAK,EAChE,OAAOD,EAAU,OAAO,EAAE,qBAAqB,CAC7C,SAAUQ,EAAqB,GAC/B,aAAc,OAAO,IAAI,QAAQ,CACnC,CAAC,EACD,OAAOL,EAAe,gBAAgB,EAAE,qBACtC,OAAO,iBAAiB,CACtB,GAAIG,CACN,CAAC,CACH,CACF,CAAC,EAED,KAAK,gFAAiF,SAAY,CAEhG,GAAG,OAAOL,EAAiB,YAAY,EAAE,gBACvC,QAAM,GAAGD,CAAS,CACpB,EACA,GAAG,OAAOA,EAAU,OAAO,EAAE,qBAC3B,SAAMS,CAA4B,CACpC,EAGA,GAAG,OAAON,EAAe,gBAAgB,EAAE,mBACxCW,IAEC,GAAG,MAAMA,EAAe,mBAAmB,EAAE,kBAC3C,MACF,EACOX,EAEX,EAWA,MAAMY,EAAY,MATF,IAAI,iBAClBd,EACAE,EACA,IAAMD,EACNE,EACAC,CACF,EAGgC,QAAQ,CACtC,OAAQK,CACV,CAAC,EAGD,OAAOK,CAAS,EAAE,KAAKR,CAA4B,EACnD,OAAON,EAAiB,YAAY,EAAE,qBAAqB,KAAK,EAChE,OAAOD,EAAU,OAAO,EAAE,qBAAqB,CAC7C,SAAUU,EAAoB,GAC9B,aAAc,OAAO,IAAI,QAAQ,CACnC,CAAC,EACD,OAAOP,EAAe,gBAAgB,EAAE,qBACtC,OAAO,iBAAiB,CACtB,GAAII,CACN,CAAC,CACH,CACF,CAAC,EAED,KAAK,wDAAyD,SAAY,CAExE,GAAG,OAAON,EAAiB,YAAY,EAAE,gBAAgB,QAAM,MAAM,CAAC,EAEtE,MAAMY,EAAU,IAAI,iBAClBZ,EACAE,EACA,IAAMD,EACNE,EACAC,CACF,EAGA,MAAM,OACJQ,EAAQ,QAAQ,CAAE,OAAQL,CAAqB,CAAC,CAClD,EAAE,QAAQ,eAAe,4BAA0B,EAEnD,OAAOP,EAAiB,YAAY,EAAE,qBAAqB,KAAK,CAClE,CAAC,CACH,CAAC",
|
|
6
|
+
"names": ["import_purify_ts", "import_Errors", "import_TransportConnectedDevice", "import_DefaultLoggerPublisherService", "import_ConnectUseCase", "transport", "transportService", "logger", "sessionService", "managerApi", "secureChannel", "fakeSessionId", "fakeSessionIdConnectedDevice", "stubDiscoveredDevice", "stubTransportConnectedDevice", "stubConnectedDevice", "tag", "connectionError", "usecase", "deviceSession", "sessionId"]
|
|
7
7
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";var
|
|
1
|
+
"use strict";var n=require("purify-ts"),v=require("../../../api/device-session/ApduResponse"),d=require("../../device-session/model/Errors"),p=require("../../logger-publisher/service/DefaultLoggerPublisherService"),c=require("../../send/use-case/SendApduUseCase");let r,e,o;const t="fakeSessionId";describe("SendApduUseCase",()=>{beforeEach(()=>{r=new p.DefaultLoggerPublisherService([],"send-apdu-use-case"),o={sendApdu:vi.fn()},e={getDeviceSessionById:vi.fn()}}),it("should send an APDU to a connected device",async()=>{const s=new Uint8Array([0,1,2,3]),i=new v.ApduResponse({statusCode:new Uint8Array([144,0]),data:new Uint8Array([])});vi.mocked(e.getDeviceSessionById).mockReturnValue((0,n.Right)(o)),vi.mocked(o.sendApdu).mockResolvedValue((0,n.Right)(i));const u=await new c.SendApduUseCase(e,()=>r).execute({sessionId:t,apdu:s});expect(e.getDeviceSessionById).toHaveBeenCalledWith(t),expect(o.sendApdu).toHaveBeenCalledWith(s,{abortTimeout:void 0,triggersDisconnection:void 0}),expect(u).toBe(i)}),it("should throw an error if the deviceSession is not found",async()=>{const s=new d.DeviceSessionNotFound;vi.mocked(e.getDeviceSessionById).mockReturnValue((0,n.Left)(s));const a=new c.SendApduUseCase(e,()=>r).execute({sessionId:t,apdu:new Uint8Array([0,1,2,3])});await expect(a).rejects.toBe(s),expect(e.getDeviceSessionById).toHaveBeenCalledWith(t)}),it("should throw an error if the apdu receiver failed",async()=>{const s=new Uint8Array([0,1,2,3]),i=new d.ReceiverApduError;vi.mocked(e.getDeviceSessionById).mockReturnValue((0,n.Right)(o)),vi.mocked(o.sendApdu).mockResolvedValue((0,n.Left)(i));const u=new c.SendApduUseCase(e,()=>r).execute({sessionId:t,apdu:s});await expect(u).rejects.toBe(i),expect(e.getDeviceSessionById).toHaveBeenCalledWith(t),expect(o.sendApdu).toHaveBeenCalledWith(s,{abortTimeout:void 0,triggersDisconnection:void 0})})});
|
|
2
2
|
//# sourceMappingURL=SendApduUseCase.test.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../../src/internal/send/use-case/SendApduUseCase.test.ts"],
|
|
4
|
-
"sourcesContent": ["import { Left } from \"purify-ts\";\n\nimport {
|
|
5
|
-
"mappings": "aAAA,IAAAA,
|
|
6
|
-
"names": ["import_purify_ts", "
|
|
4
|
+
"sourcesContent": ["import { Left, Right } from \"purify-ts\";\n\nimport { ApduResponse } from \"@api/device-session/ApduResponse\";\nimport { type LoggerPublisherService } from \"@api/logger-publisher/service/LoggerPublisherService\";\nimport { type DeviceSession } from \"@internal/device-session/model/DeviceSession\";\nimport {\n DeviceSessionNotFound,\n ReceiverApduError,\n} from \"@internal/device-session/model/Errors\";\nimport { type DeviceSessionService } from \"@internal/device-session/service/DeviceSessionService\";\nimport { DefaultLoggerPublisherService } from \"@internal/logger-publisher/service/DefaultLoggerPublisherService\";\nimport { SendApduUseCase } from \"@internal/send/use-case/SendApduUseCase\";\n\nlet logger: LoggerPublisherService;\nlet sessionService: DeviceSessionService;\nlet mockDeviceSession: DeviceSession;\nconst fakeSessionId = \"fakeSessionId\";\n\ndescribe(\"SendApduUseCase\", () => {\n beforeEach(() => {\n logger = new DefaultLoggerPublisherService([], \"send-apdu-use-case\");\n\n // Mock DeviceSession with sendApdu method\n mockDeviceSession = {\n sendApdu: vi.fn(),\n } as unknown as DeviceSession;\n\n // Mock DeviceSessionService\n sessionService = {\n getDeviceSessionById: vi.fn(),\n } as unknown as DeviceSessionService;\n });\n\n it(\"should send an APDU to a connected device\", async () => {\n // given\n const apdu = new Uint8Array([0x00, 0x01, 0x02, 0x03]);\n const expectedResponse = new ApduResponse({\n statusCode: new Uint8Array([0x90, 0x00]),\n data: new Uint8Array([]),\n });\n\n vi.mocked(sessionService.getDeviceSessionById).mockReturnValue(\n Right(mockDeviceSession),\n );\n vi.mocked(mockDeviceSession.sendApdu).mockResolvedValue(\n Right(expectedResponse),\n );\n\n const useCase = new SendApduUseCase(sessionService, () => logger);\n\n // when\n const response = await useCase.execute({\n sessionId: fakeSessionId,\n apdu,\n });\n\n // then\n expect(sessionService.getDeviceSessionById).toHaveBeenCalledWith(\n fakeSessionId,\n );\n expect(mockDeviceSession.sendApdu).toHaveBeenCalledWith(apdu, {\n abortTimeout: undefined,\n triggersDisconnection: undefined,\n });\n expect(response).toBe(expectedResponse);\n });\n\n it(\"should throw an error if the deviceSession is not found\", async () => {\n // given\n const notFoundError = new DeviceSessionNotFound();\n vi.mocked(sessionService.getDeviceSessionById).mockReturnValue(\n Left(notFoundError),\n );\n\n const useCase = new SendApduUseCase(sessionService, () => logger);\n\n // when\n const response = useCase.execute({\n sessionId: fakeSessionId,\n apdu: new Uint8Array([0x00, 0x01, 0x02, 0x03]),\n });\n\n // then\n await expect(response).rejects.toBe(notFoundError);\n expect(sessionService.getDeviceSessionById).toHaveBeenCalledWith(\n fakeSessionId,\n );\n });\n\n it(\"should throw an error if the apdu receiver failed\", async () => {\n // given\n const apdu = new Uint8Array([0x00, 0x01, 0x02, 0x03]);\n const receiverError = new ReceiverApduError();\n\n vi.mocked(sessionService.getDeviceSessionById).mockReturnValue(\n Right(mockDeviceSession),\n );\n vi.mocked(mockDeviceSession.sendApdu).mockResolvedValue(\n Left(receiverError),\n );\n\n const useCase = new SendApduUseCase(sessionService, () => logger);\n\n // when\n const response = useCase.execute({\n sessionId: fakeSessionId,\n apdu,\n });\n\n // then\n await expect(response).rejects.toBe(receiverError);\n expect(sessionService.getDeviceSessionById).toHaveBeenCalledWith(\n fakeSessionId,\n );\n expect(mockDeviceSession.sendApdu).toHaveBeenCalledWith(apdu, {\n abortTimeout: undefined,\n triggersDisconnection: undefined,\n });\n });\n});\n"],
|
|
5
|
+
"mappings": "aAAA,IAAAA,EAA4B,qBAE5BC,EAA6B,4CAG7BC,EAGO,iDAEPC,EAA8C,4EAC9CC,EAAgC,mDAEhC,IAAIC,EACAC,EACAC,EACJ,MAAMC,EAAgB,gBAEtB,SAAS,kBAAmB,IAAM,CAChC,WAAW,IAAM,CACfH,EAAS,IAAI,gCAA8B,CAAC,EAAG,oBAAoB,EAGnEE,EAAoB,CAClB,SAAU,GAAG,GAAG,CAClB,EAGAD,EAAiB,CACf,qBAAsB,GAAG,GAAG,CAC9B,CACF,CAAC,EAED,GAAG,4CAA6C,SAAY,CAE1D,MAAMG,EAAO,IAAI,WAAW,CAAC,EAAM,EAAM,EAAM,CAAI,CAAC,EAC9CC,EAAmB,IAAI,eAAa,CACxC,WAAY,IAAI,WAAW,CAAC,IAAM,CAAI,CAAC,EACvC,KAAM,IAAI,WAAW,CAAC,CAAC,CACzB,CAAC,EAED,GAAG,OAAOJ,EAAe,oBAAoB,EAAE,mBAC7C,SAAMC,CAAiB,CACzB,EACA,GAAG,OAAOA,EAAkB,QAAQ,EAAE,qBACpC,SAAMG,CAAgB,CACxB,EAKA,MAAMC,EAAW,MAHD,IAAI,kBAAgBL,EAAgB,IAAMD,CAAM,EAGjC,QAAQ,CACrC,UAAWG,EACX,KAAAC,CACF,CAAC,EAGD,OAAOH,EAAe,oBAAoB,EAAE,qBAC1CE,CACF,EACA,OAAOD,EAAkB,QAAQ,EAAE,qBAAqBE,EAAM,CAC5D,aAAc,OACd,sBAAuB,MACzB,CAAC,EACD,OAAOE,CAAQ,EAAE,KAAKD,CAAgB,CACxC,CAAC,EAED,GAAG,0DAA2D,SAAY,CAExE,MAAME,EAAgB,IAAI,wBAC1B,GAAG,OAAON,EAAe,oBAAoB,EAAE,mBAC7C,QAAKM,CAAa,CACpB,EAKA,MAAMD,EAHU,IAAI,kBAAgBL,EAAgB,IAAMD,CAAM,EAGvC,QAAQ,CAC/B,UAAWG,EACX,KAAM,IAAI,WAAW,CAAC,EAAM,EAAM,EAAM,CAAI,CAAC,CAC/C,CAAC,EAGD,MAAM,OAAOG,CAAQ,EAAE,QAAQ,KAAKC,CAAa,EACjD,OAAON,EAAe,oBAAoB,EAAE,qBAC1CE,CACF,CACF,CAAC,EAED,GAAG,oDAAqD,SAAY,CAElE,MAAMC,EAAO,IAAI,WAAW,CAAC,EAAM,EAAM,EAAM,CAAI,CAAC,EAC9CI,EAAgB,IAAI,oBAE1B,GAAG,OAAOP,EAAe,oBAAoB,EAAE,mBAC7C,SAAMC,CAAiB,CACzB,EACA,GAAG,OAAOA,EAAkB,QAAQ,EAAE,qBACpC,QAAKM,CAAa,CACpB,EAKA,MAAMF,EAHU,IAAI,kBAAgBL,EAAgB,IAAMD,CAAM,EAGvC,QAAQ,CAC/B,UAAWG,EACX,KAAAC,CACF,CAAC,EAGD,MAAM,OAAOE,CAAQ,EAAE,QAAQ,KAAKE,CAAa,EACjD,OAAOP,EAAe,oBAAoB,EAAE,qBAC1CE,CACF,EACA,OAAOD,EAAkB,QAAQ,EAAE,qBAAqBE,EAAM,CAC5D,aAAc,OACd,sBAAuB,MACzB,CAAC,CACH,CAAC,CACH,CAAC",
|
|
6
|
+
"names": ["import_purify_ts", "import_ApduResponse", "import_Errors", "import_DefaultLoggerPublisherService", "import_SendApduUseCase", "logger", "sessionService", "mockDeviceSession", "fakeSessionId", "apdu", "expectedResponse", "response", "notFoundError", "receiverError"]
|
|
7
7
|
}
|
package/lib/esm/package.json
CHANGED
|
@@ -64,5 +64,5 @@
|
|
|
64
64
|
"watch:builds": "pnpm ldmk-tool watch --entryPoints index.ts,src/**/*.ts --tsconfig tsconfig.prod.json",
|
|
65
65
|
"watch:types": "concurrently \"tsc --watch -p tsconfig.prod.json\" \"tsc-alias --watch -p tsconfig.prod.json\""
|
|
66
66
|
},
|
|
67
|
-
"version": "1.0
|
|
67
|
+
"version": "1.2.0"
|
|
68
68
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{commandTypes as
|
|
1
|
+
import{commandTypes as a}from"./command/di/commandTypes";import{configTypes as c}from"../internal/config/di/configTypes";import{deviceSessionTypes as t}from"../internal/device-session/di/deviceSessionTypes";import{discoveryTypes as s}from"../internal/discovery/di/discoveryTypes";import{loggerTypes as p}from"../internal/logger-publisher/di/loggerTypes";import{managerApiTypes as r}from"../internal/manager-api/di/managerApiTypes";import{sendTypes as m}from"../internal/send/di/sendTypes";import{transportDiTypes as C}from"../internal/transport/di/transportDiTypes";import{makeContainer as v}from"../../src/di";import{deviceActionTypes as u}from"./device-action/di/deviceActionTypes";class b{container;constructor({stub:e,transports:n,loggers:o,config:i}={}){this.container=v({stub:e,transports:n,loggers:o,config:i})}getVersion(){return this.container.get(c.GetDmkVersionUseCase).getDmkVersion()}startDiscovering(e){return this.container.get(s.StartDiscoveringUseCase).execute(e)}stopDiscovering(){return this.container.get(s.StopDiscoveringUseCase).execute()}listenToAvailableDevices(e){return this.container.get(s.ListenToAvailableDevicesUseCase).execute(e)}async reconnect(e){return this.container.get(s.ReconnectUseCase).execute(e)}connect(e){return this.container.get(s.ConnectUseCase).execute(e)}disconnect(e){return this.container.get(s.DisconnectUseCase).execute(e)}sendApdu(e){return this.container.get(m.SendApduUseCase).execute(e)}sendCommand(e){return this.container.get(a.SendCommandUseCase).execute(e)}executeDeviceAction(e){return this.container.get(u.ExecuteDeviceActionUseCase).execute(e)}getConnectedDevice(e){return this.container.get(s.GetConnectedDeviceUseCase).execute(e)}getDeviceSessionState(e){return this.container.get(t.GetDeviceSessionStateUseCase).execute(e)}close(){return this.container.get(t.CloseSessionsUseCase).execute()}listConnectedDevices(){return this.container.get(s.ListConnectedDevicesUseCase).execute()}listenToConnectedDevice(){return this.container.get(s.ListenToConnectedDeviceUseCase).execute()}disableDeviceSessionRefresher(e){return this.container.get(t.DisableDeviceSessionRefresherUseCase).execute(e)}_unsafeBypassIntentQueue(e){return this.container.get(t.UnsafeBypassIntentQueueUseCase).execute(e)}setProvider(e){return this.container.get(r.SetProviderUseCase).execute(e)}getProvider(){return this.container.get(r.ManagerApiDataSource).getProvider()}isEnvironmentSupported(){return this.container.get(C.TransportService).getAllTransports().some(e=>e.isSupported())}getLoggerFactory(){return this.container.get(p.LoggerPublisherServiceFactory)}}export{b as DeviceManagementKit};
|
|
2
2
|
//# sourceMappingURL=DeviceManagementKit.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../src/api/DeviceManagementKit.ts"],
|
|
4
|
-
"sourcesContent": ["import { type Container, type Factory } from \"inversify\";\nimport { type Observable } from \"rxjs\";\n\nimport { commandTypes } from \"@api/command/di/commandTypes\";\nimport { type CommandResult } from \"@api/command/model/CommandResult\";\nimport {\n type SendCommandUseCase,\n type SendCommandUseCaseArgs,\n} from \"@api/command/use-case/SendCommandUseCase\";\nimport {\n type ExecuteDeviceActionUseCase,\n type ExecuteDeviceActionUseCaseArgs,\n} from \"@api/device-action/use-case/ExecuteDeviceActionUseCase\";\nimport { type ApduResponse } from \"@api/device-session/ApduResponse\";\nimport { type DeviceSessionState } from \"@api/device-session/DeviceSessionState\";\nimport { type DeviceSessionId } from \"@api/device-session/types\";\nimport { type ConnectedDevice } from \"@api/transport/model/ConnectedDevice\";\nimport {\n type ConnectUseCaseArgs,\n type DisconnectUseCaseArgs,\n type DiscoveredDevice,\n type GetConnectedDeviceUseCaseArgs,\n type LoggerPublisherService,\n type SendApduUseCaseArgs,\n type StartDiscoveringUseCaseArgs,\n} from \"@api/types\";\nimport { configTypes } from \"@internal/config/di/configTypes\";\nimport { type GetDmkVersionUseCase } from \"@internal/config/use-case/GetDmkVersionUseCase\";\nimport { deviceSessionTypes } from \"@internal/device-session/di/deviceSessionTypes\";\nimport { type CloseSessionsUseCase } from \"@internal/device-session/use-case/CloseSessionsUseCase\";\nimport { type GetDeviceSessionStateUseCase } from \"@internal/device-session/use-case/GetDeviceSessionStateUseCase\";\nimport { discoveryTypes } from \"@internal/discovery/di/discoveryTypes\";\nimport { type ConnectUseCase } from \"@internal/discovery/use-case/ConnectUseCase\";\nimport { type DisconnectUseCase } from \"@internal/discovery/use-case/DisconnectUseCase\";\nimport { type GetConnectedDeviceUseCase } from \"@internal/discovery/use-case/GetConnectedDeviceUseCase\";\nimport { type ListConnectedDevicesUseCase } from \"@internal/discovery/use-case/ListConnectedDevicesUseCase\";\nimport {\n type ListenToAvailableDevicesUseCase,\n type ListenToAvailableDevicesUseCaseArgs,\n} from \"@internal/discovery/use-case/ListenToAvailableDevicesUseCase\";\nimport { type ListenToConnectedDeviceUseCase } from \"@internal/discovery/use-case/ListenToConnectedDeviceUseCase\";\nimport {\n type ReconnectUseCase,\n type ReconnectUseCaseArgs,\n} from \"@internal/discovery/use-case/ReconnectUseCase\";\nimport type { StartDiscoveringUseCase } from \"@internal/discovery/use-case/StartDiscoveringUseCase\";\nimport type { StopDiscoveringUseCase } from \"@internal/discovery/use-case/StopDiscoveringUseCase\";\nimport { loggerTypes } from \"@internal/logger-publisher/di/loggerTypes\";\nimport { type ManagerApiDataSource } from \"@internal/manager-api/data/ManagerApiDataSource\";\nimport { managerApiTypes } from \"@internal/manager-api/di/managerApiTypes\";\nimport { type SetProviderUseCase } from \"@internal/manager-api/use-case/SetProviderUseCase\";\nimport { sendTypes } from \"@internal/send/di/sendTypes\";\nimport { type SendApduUseCase } from \"@internal/send/use-case/SendApduUseCase\";\nimport { transportDiTypes } from \"@internal/transport/di/transportDiTypes\";\nimport { type TransportService } from \"@internal/transport/service/TransportService\";\nimport { makeContainer, type MakeContainerProps } from \"@root/src/di\";\n\nimport {\n type DeviceActionIntermediateValue,\n type ExecuteDeviceActionReturnType,\n} from \"./device-action/DeviceAction\";\nimport { deviceActionTypes } from \"./device-action/di/deviceActionTypes\";\nimport { type DisableDeviceSessionRefresherUseCase } from \"./device-session/use-case/DisableDeviceSessionRefresher\";\nimport { type DmkError } from \"./Error\";\n\n/**\n * The main class to interact with the Device Management Kit.\n *\n * NB: do not instantiate this class directly, instead, use `LedgerDMKBuilder`.\n */\nexport class DeviceManagementKit {\n readonly container: Container;\n /** @internal */\n constructor({\n stub,\n transports,\n loggers,\n config,\n }: Partial<MakeContainerProps> = {}) {\n // NOTE: MakeContainerProps might not be the exact type here\n // For the init of the project this is sufficient, but we might need to\n // update the constructor arguments as we go (we might have more than just the container config)\n this.container = makeContainer({\n stub,\n transports,\n loggers,\n config,\n });\n }\n\n /**\n * Returns a promise resolving to the version of the SDK.\n */\n getVersion(): Promise<string> {\n return this.container\n .get<GetDmkVersionUseCase>(configTypes.GetDmkVersionUseCase)\n .getDmkVersion();\n }\n\n /**\n * Starts discovering devices connected.\n *\n * For the WeHID implementation, this use-case needs to be called as a result\n * of an user interaction (button \"click\" event for ex).\n *\n * @param {StartDiscoveringUseCaseArgs} args - The transport to use for discover, or undefined to discover from all transports.\n * @returns {Observable<DiscoveredDevice>} An observable of discovered devices.\n */\n startDiscovering(\n args: StartDiscoveringUseCaseArgs,\n ): Observable<DiscoveredDevice> {\n return this.container\n .get<StartDiscoveringUseCase>(discoveryTypes.StartDiscoveringUseCase)\n .execute(args);\n }\n\n /**\n * Stops discovering devices connected.\n */\n stopDiscovering() {\n return this.container\n .get<StopDiscoveringUseCase>(discoveryTypes.StopDiscoveringUseCase)\n .execute();\n }\n\n /**\n * Listen to list of known discovered devices (and later BLE).\n * @param {ListenToAvailableDevicesUseCaseArgs} args - The transport to use for discover, or undefined to discover from all transports.\n * @returns {Observable<DiscoveredDevice[]>} An observable of known discovered devices.\n */\n listenToAvailableDevices(\n args: ListenToAvailableDevicesUseCaseArgs,\n ): Observable<DiscoveredDevice[]> {\n return this.container\n .get<ListenToAvailableDevicesUseCase>(\n discoveryTypes.ListenToAvailableDevicesUseCase,\n )\n .execute(args);\n }\n\n /**\n * Reconnects a device session by disconnecting and reconnecting to the device.\n *\n * @param args - The arguments for reconnecting the device session.\n * - `device`: The connected device.\n * - `sessionRefresherOptions` (optional): Configuration for session refreshing.\n * - `isRefresherDisabled`: Whether the refresher is disabled.\n * - `pollingInterval`: The refresh interval in milliseconds\n * @returns The session ID to use for further communication with the device.\n */\n async reconnect(args: ReconnectUseCaseArgs): Promise<DeviceSessionId> {\n return this.container\n .get<ReconnectUseCase>(discoveryTypes.ReconnectUseCase)\n .execute(args);\n }\n\n /**\n * Connects to a device previously discovered with `DeviceManagementKit.startDiscovering`.\n * Creates a new device session which:\n * - Represents the connection to the device.\n * - Is terminated upon disconnection of the device.\n * - Exposes the device state through an observable (see `DeviceManagementKit.getDeviceSessionState`)\n * - Should be used for all subsequent communication with the device.\n *\n * @param {ConnectUseCaseArgs} args - The arguments for connecting to the device.\n * - `device`: The discovered device obtained from `StartDiscoveringUseCase`.\n * - `sessionRefresherOptions` (optional): Configuration for session refreshing.\n * - `isRefresherDisabled`: Whether the refresher is disabled.\n * - `pollingInterval`: The refresh interval in milliseconds\n * @returns The session ID to use for further communication with the device.\n */\n connect(args: ConnectUseCaseArgs): Promise<DeviceSessionId> {\n return this.container\n .get<ConnectUseCase>(discoveryTypes.ConnectUseCase)\n .execute(args);\n }\n\n /**\n * Disconnects to a discovered device.\n *\n * @param {DisconnectUseCaseArgs} args - The session ID to disconnect.\n */\n disconnect(args: DisconnectUseCaseArgs): Promise<void> {\n return this.container\n .get<DisconnectUseCase>(discoveryTypes.DisconnectUseCase)\n .execute(args);\n }\n\n /**\n * Sends an APDU command to a device through a device session.\n *\n * @param {SendApduUseCaseArgs} args - The device session ID and APDU command to send.\n */\n sendApdu(args: SendApduUseCaseArgs): Promise<ApduResponse> {\n return this.container\n .get<SendApduUseCase>(sendTypes.SendApduUseCase)\n .execute(args);\n }\n\n /**\n * Sends a command to a device through a device session.\n *\n * @param {SendCommandUseCaseArgs<Response, Args, ErrorCodes>} args - The device session ID, command, command error codes and command parameters to send.\n * @returns A promise resolving with the response from the command.\n */\n sendCommand<Response, Args, ErrorCodes>(\n args: SendCommandUseCaseArgs<Response, Args, ErrorCodes>,\n ): Promise<CommandResult<Response, ErrorCodes>> {\n return this.container\n .get<SendCommandUseCase>(commandTypes.SendCommandUseCase)\n .execute(args);\n }\n\n executeDeviceAction<\n Output,\n Input,\n Error extends DmkError,\n IntermediateValue extends DeviceActionIntermediateValue,\n >(\n args: ExecuteDeviceActionUseCaseArgs<\n Output,\n Input,\n Error,\n IntermediateValue\n >,\n ): ExecuteDeviceActionReturnType<Output, Error, IntermediateValue> {\n return this.container\n .get<ExecuteDeviceActionUseCase>(\n deviceActionTypes.ExecuteDeviceActionUseCase,\n )\n .execute(args);\n }\n\n /**\n * Gets the connected from its device session ID.\n *\n * @param {GetConnectedDeviceUseCaseArgs} args - The device session ID.\n * @returns {ConnectedDevice} The connected device.\n */\n getConnectedDevice(args: GetConnectedDeviceUseCaseArgs): ConnectedDevice {\n return this.container\n .get<GetConnectedDeviceUseCase>(discoveryTypes.GetConnectedDeviceUseCase)\n .execute(args);\n }\n\n /**\n * Gets the device state of a session.\n *\n * @param {{ sessionId: DeviceSessionId }} args - The device session ID.\n * @returns {Observable<DeviceSessionState>} An observable of the session device state.\n */\n getDeviceSessionState(args: {\n sessionId: DeviceSessionId;\n }): Observable<DeviceSessionState> {\n return this.container\n .get<GetDeviceSessionStateUseCase>(\n deviceSessionTypes.GetDeviceSessionStateUseCase,\n )\n .execute(args);\n }\n\n /**\n * Close the Device Management kit.\n *\n */\n close() {\n return this.container\n .get<CloseSessionsUseCase>(deviceSessionTypes.CloseSessionsUseCase)\n .execute();\n }\n\n /**\n * Lists all connected devices.\n *\n * @returns {ConnectedDevice[]} The list of device sessions.\n */\n listConnectedDevices(): ConnectedDevice[] {\n return this.container\n .get<ListConnectedDevicesUseCase>(\n discoveryTypes.ListConnectedDevicesUseCase,\n )\n .execute();\n }\n\n /**\n * Listen to connected device.\n *\n * @returns {Observable<ConnectedDevice>} An observable of connected device.\n */\n listenToConnectedDevice(): Observable<ConnectedDevice> {\n return this.container\n .get<ListenToConnectedDeviceUseCase>(\n discoveryTypes.ListenToConnectedDeviceUseCase,\n )\n .execute();\n }\n\n /**\n * Disable the device session refresher.\n *\n * @param {DisableDeviceSessionRefresherUseCaseArgs} args - The device session ID and a string to identify the blocker.\n * @returns {() => void} A function to reenable the device session refresher.\n */\n disableDeviceSessionRefresher(args: {\n sessionId: DeviceSessionId;\n blockerId: string;\n }): () => void {\n return this.container\n .get<DisableDeviceSessionRefresherUseCase>(\n deviceSessionTypes.DisableDeviceSessionRefresherUseCase,\n )\n .execute(args);\n }\n /**\n * Sets the provider for the manager API.\n *\n * @param {number} provider - The provider to set.\n */\n setProvider(provider: number): void {\n return this.container\n .get<SetProviderUseCase>(managerApiTypes.SetProviderUseCase)\n .execute(provider);\n }\n\n /**\n * Returns the current provider value from the manager API data source.\n */\n getProvider(): number {\n return this.container\n .get<ManagerApiDataSource>(managerApiTypes.ManagerApiDataSource)\n .getProvider();\n }\n\n /**\n * Check if the current environment is supported by any transport.\n */\n isEnvironmentSupported(): boolean {\n return this.container\n .get<TransportService>(transportDiTypes.TransportService)\n .getAllTransports()\n .some((transport) => transport.isSupported());\n }\n\n /**\n * Returns the DMK logger factory with configured logger subscribers.\n */\n getLoggerFactory(): Factory<LoggerPublisherService> {\n return this.container.get(loggerTypes.LoggerPublisherServiceFactory);\n }\n}\n"],
|
|
5
|
-
"mappings": "AAGA,OAAS,gBAAAA,MAAoB,+BAuB7B,OAAS,eAAAC,MAAmB,kCAE5B,OAAS,sBAAAC,MAA0B,
|
|
4
|
+
"sourcesContent": ["import { type Container, type Factory } from \"inversify\";\nimport { type Observable } from \"rxjs\";\n\nimport { commandTypes } from \"@api/command/di/commandTypes\";\nimport { type CommandResult } from \"@api/command/model/CommandResult\";\nimport {\n type SendCommandUseCase,\n type SendCommandUseCaseArgs,\n} from \"@api/command/use-case/SendCommandUseCase\";\nimport {\n type ExecuteDeviceActionUseCase,\n type ExecuteDeviceActionUseCaseArgs,\n} from \"@api/device-action/use-case/ExecuteDeviceActionUseCase\";\nimport { type ApduResponse } from \"@api/device-session/ApduResponse\";\nimport { type DeviceSessionState } from \"@api/device-session/DeviceSessionState\";\nimport { type DeviceSessionId } from \"@api/device-session/types\";\nimport { type ConnectedDevice } from \"@api/transport/model/ConnectedDevice\";\nimport {\n type ConnectUseCaseArgs,\n type DisconnectUseCaseArgs,\n type DiscoveredDevice,\n type GetConnectedDeviceUseCaseArgs,\n type LoggerPublisherService,\n type SendApduUseCaseArgs,\n type StartDiscoveringUseCaseArgs,\n} from \"@api/types\";\nimport { configTypes } from \"@internal/config/di/configTypes\";\nimport { type GetDmkVersionUseCase } from \"@internal/config/use-case/GetDmkVersionUseCase\";\nimport { deviceSessionTypes } from \"@internal/device-session/di/deviceSessionTypes\";\nimport { type CloseSessionsUseCase } from \"@internal/device-session/use-case/CloseSessionsUseCase\";\nimport { type GetDeviceSessionStateUseCase } from \"@internal/device-session/use-case/GetDeviceSessionStateUseCase\";\nimport {\n type UnsafeBypassIntentQueueUseCase,\n type UnsafeBypassIntentQueueUseCaseArgs,\n} from \"@internal/device-session/use-case/UnsafeBypassIntentQueueUseCase\";\nimport { discoveryTypes } from \"@internal/discovery/di/discoveryTypes\";\nimport { type ConnectUseCase } from \"@internal/discovery/use-case/ConnectUseCase\";\nimport { type DisconnectUseCase } from \"@internal/discovery/use-case/DisconnectUseCase\";\nimport { type GetConnectedDeviceUseCase } from \"@internal/discovery/use-case/GetConnectedDeviceUseCase\";\nimport { type ListConnectedDevicesUseCase } from \"@internal/discovery/use-case/ListConnectedDevicesUseCase\";\nimport {\n type ListenToAvailableDevicesUseCase,\n type ListenToAvailableDevicesUseCaseArgs,\n} from \"@internal/discovery/use-case/ListenToAvailableDevicesUseCase\";\nimport { type ListenToConnectedDeviceUseCase } from \"@internal/discovery/use-case/ListenToConnectedDeviceUseCase\";\nimport {\n type ReconnectUseCase,\n type ReconnectUseCaseArgs,\n} from \"@internal/discovery/use-case/ReconnectUseCase\";\nimport type { StartDiscoveringUseCase } from \"@internal/discovery/use-case/StartDiscoveringUseCase\";\nimport type { StopDiscoveringUseCase } from \"@internal/discovery/use-case/StopDiscoveringUseCase\";\nimport { loggerTypes } from \"@internal/logger-publisher/di/loggerTypes\";\nimport { type ManagerApiDataSource } from \"@internal/manager-api/data/ManagerApiDataSource\";\nimport { managerApiTypes } from \"@internal/manager-api/di/managerApiTypes\";\nimport { type SetProviderUseCase } from \"@internal/manager-api/use-case/SetProviderUseCase\";\nimport { sendTypes } from \"@internal/send/di/sendTypes\";\nimport { type SendApduUseCase } from \"@internal/send/use-case/SendApduUseCase\";\nimport { transportDiTypes } from \"@internal/transport/di/transportDiTypes\";\nimport { type TransportService } from \"@internal/transport/service/TransportService\";\nimport { makeContainer, type MakeContainerProps } from \"@root/src/di\";\n\nimport {\n type DeviceActionIntermediateValue,\n type ExecuteDeviceActionReturnType,\n} from \"./device-action/DeviceAction\";\nimport { deviceActionTypes } from \"./device-action/di/deviceActionTypes\";\nimport { type DisableDeviceSessionRefresherUseCase } from \"./device-session/use-case/DisableDeviceSessionRefresher\";\nimport { type DmkError } from \"./Error\";\n\n/**\n * The main class to interact with the Device Management Kit.\n *\n * NB: do not instantiate this class directly, instead, use `LedgerDMKBuilder`.\n */\nexport class DeviceManagementKit {\n readonly container: Container;\n /** @internal */\n constructor({\n stub,\n transports,\n loggers,\n config,\n }: Partial<MakeContainerProps> = {}) {\n // NOTE: MakeContainerProps might not be the exact type here\n // For the init of the project this is sufficient, but we might need to\n // update the constructor arguments as we go (we might have more than just the container config)\n this.container = makeContainer({\n stub,\n transports,\n loggers,\n config,\n });\n }\n\n /**\n * Returns a promise resolving to the version of the SDK.\n */\n getVersion(): Promise<string> {\n return this.container\n .get<GetDmkVersionUseCase>(configTypes.GetDmkVersionUseCase)\n .getDmkVersion();\n }\n\n /**\n * Starts discovering devices connected.\n *\n * For the WeHID implementation, this use-case needs to be called as a result\n * of an user interaction (button \"click\" event for ex).\n *\n * @param {StartDiscoveringUseCaseArgs} args - The transport to use for discover, or undefined to discover from all transports.\n * @returns {Observable<DiscoveredDevice>} An observable of discovered devices.\n */\n startDiscovering(\n args: StartDiscoveringUseCaseArgs,\n ): Observable<DiscoveredDevice> {\n return this.container\n .get<StartDiscoveringUseCase>(discoveryTypes.StartDiscoveringUseCase)\n .execute(args);\n }\n\n /**\n * Stops discovering devices connected.\n */\n stopDiscovering() {\n return this.container\n .get<StopDiscoveringUseCase>(discoveryTypes.StopDiscoveringUseCase)\n .execute();\n }\n\n /**\n * Listen to list of known discovered devices (and later BLE).\n * @param {ListenToAvailableDevicesUseCaseArgs} args - The transport to use for discover, or undefined to discover from all transports.\n * @returns {Observable<DiscoveredDevice[]>} An observable of known discovered devices.\n */\n listenToAvailableDevices(\n args: ListenToAvailableDevicesUseCaseArgs,\n ): Observable<DiscoveredDevice[]> {\n return this.container\n .get<ListenToAvailableDevicesUseCase>(\n discoveryTypes.ListenToAvailableDevicesUseCase,\n )\n .execute(args);\n }\n\n /**\n * Reconnects a device session by disconnecting and reconnecting to the device.\n *\n * @param args - The arguments for reconnecting the device session.\n * - `device`: The connected device.\n * - `sessionRefresherOptions` (optional): Configuration for session refreshing.\n * - `isRefresherDisabled`: Whether the refresher is disabled.\n * - `pollingInterval`: The refresh interval in milliseconds\n * @returns The session ID to use for further communication with the device.\n */\n async reconnect(args: ReconnectUseCaseArgs): Promise<DeviceSessionId> {\n return this.container\n .get<ReconnectUseCase>(discoveryTypes.ReconnectUseCase)\n .execute(args);\n }\n\n /**\n * Connects to a device previously discovered with `DeviceManagementKit.startDiscovering`.\n * Creates a new device session which:\n * - Represents the connection to the device.\n * - Is terminated upon disconnection of the device.\n * - Exposes the device state through an observable (see `DeviceManagementKit.getDeviceSessionState`)\n * - Should be used for all subsequent communication with the device.\n *\n * @param {ConnectUseCaseArgs} args - The arguments for connecting to the device.\n * - `device`: The discovered device obtained from `StartDiscoveringUseCase`.\n * - `sessionRefresherOptions` (optional): Configuration for session refreshing.\n * - `isRefresherDisabled`: Whether the refresher is disabled.\n * - `pollingInterval`: The refresh interval in milliseconds\n * @returns The session ID to use for further communication with the device.\n */\n connect(args: ConnectUseCaseArgs): Promise<DeviceSessionId> {\n return this.container\n .get<ConnectUseCase>(discoveryTypes.ConnectUseCase)\n .execute(args);\n }\n\n /**\n * Disconnects to a discovered device.\n *\n * @param {DisconnectUseCaseArgs} args - The session ID to disconnect.\n */\n disconnect(args: DisconnectUseCaseArgs): Promise<void> {\n return this.container\n .get<DisconnectUseCase>(discoveryTypes.DisconnectUseCase)\n .execute(args);\n }\n\n /**\n * Sends an APDU command to a device through a device session.\n *\n * @param {SendApduUseCaseArgs} args - The device session ID and APDU command to send.\n */\n sendApdu(args: SendApduUseCaseArgs): Promise<ApduResponse> {\n return this.container\n .get<SendApduUseCase>(sendTypes.SendApduUseCase)\n .execute(args);\n }\n\n /**\n * Sends a command to a device through a device session.\n *\n * @param {SendCommandUseCaseArgs<Response, Args, ErrorCodes>} args - The device session ID, command, command error codes and command parameters to send.\n * @returns A promise resolving with the response from the command.\n */\n sendCommand<Response, Args, ErrorCodes>(\n args: SendCommandUseCaseArgs<Response, Args, ErrorCodes>,\n ): Promise<CommandResult<Response, ErrorCodes>> {\n return this.container\n .get<SendCommandUseCase>(commandTypes.SendCommandUseCase)\n .execute(args);\n }\n\n executeDeviceAction<\n Output,\n Input,\n Error extends DmkError,\n IntermediateValue extends DeviceActionIntermediateValue,\n >(\n args: ExecuteDeviceActionUseCaseArgs<\n Output,\n Input,\n Error,\n IntermediateValue\n >,\n ): ExecuteDeviceActionReturnType<Output, Error, IntermediateValue> {\n return this.container\n .get<ExecuteDeviceActionUseCase>(\n deviceActionTypes.ExecuteDeviceActionUseCase,\n )\n .execute(args);\n }\n\n /**\n * Gets the connected from its device session ID.\n *\n * @param {GetConnectedDeviceUseCaseArgs} args - The device session ID.\n * @returns {ConnectedDevice} The connected device.\n */\n getConnectedDevice(args: GetConnectedDeviceUseCaseArgs): ConnectedDevice {\n return this.container\n .get<GetConnectedDeviceUseCase>(discoveryTypes.GetConnectedDeviceUseCase)\n .execute(args);\n }\n\n /**\n * Gets the device state of a session.\n *\n * @param {{ sessionId: DeviceSessionId }} args - The device session ID.\n * @returns {Observable<DeviceSessionState>} An observable of the session device state.\n */\n getDeviceSessionState(args: {\n sessionId: DeviceSessionId;\n }): Observable<DeviceSessionState> {\n return this.container\n .get<GetDeviceSessionStateUseCase>(\n deviceSessionTypes.GetDeviceSessionStateUseCase,\n )\n .execute(args);\n }\n\n /**\n * Close the Device Management kit.\n *\n */\n close() {\n return this.container\n .get<CloseSessionsUseCase>(deviceSessionTypes.CloseSessionsUseCase)\n .execute();\n }\n\n /**\n * Lists all connected devices.\n *\n * @returns {ConnectedDevice[]} The list of device sessions.\n */\n listConnectedDevices(): ConnectedDevice[] {\n return this.container\n .get<ListConnectedDevicesUseCase>(\n discoveryTypes.ListConnectedDevicesUseCase,\n )\n .execute();\n }\n\n /**\n * Listen to connected device.\n *\n * @returns {Observable<ConnectedDevice>} An observable of connected device.\n */\n listenToConnectedDevice(): Observable<ConnectedDevice> {\n return this.container\n .get<ListenToConnectedDeviceUseCase>(\n discoveryTypes.ListenToConnectedDeviceUseCase,\n )\n .execute();\n }\n\n /**\n * Disable the device session refresher.\n *\n * @param {DisableDeviceSessionRefresherUseCaseArgs} args - The device session ID and a string to identify the blocker.\n * @returns {() => void} A function to reenable the device session refresher.\n */\n disableDeviceSessionRefresher(args: {\n sessionId: DeviceSessionId;\n blockerId: string;\n }): () => void {\n return this.container\n .get<DisableDeviceSessionRefresherUseCase>(\n deviceSessionTypes.DisableDeviceSessionRefresherUseCase,\n )\n .execute(args);\n }\n\n /**\n * UNSAFE: Bypasses the intent queue for a device session.\n * This allows all intents (sendApdu, sendCommand, executeDeviceAction) to execute\n * directly without being queued. Use with extreme caution as this can lead to\n * race conditions and concurrent execution issues.\n *\n * @param {UnsafeBypassIntentQueueUseCaseArgs} args - The device session ID and bypass flag.\n */\n _unsafeBypassIntentQueue(args: UnsafeBypassIntentQueueUseCaseArgs): void {\n return this.container\n .get<UnsafeBypassIntentQueueUseCase>(\n deviceSessionTypes.UnsafeBypassIntentQueueUseCase,\n )\n .execute(args);\n }\n /**\n * Sets the provider for the manager API.\n *\n * @param {number} provider - The provider to set.\n */\n setProvider(provider: number): void {\n return this.container\n .get<SetProviderUseCase>(managerApiTypes.SetProviderUseCase)\n .execute(provider);\n }\n\n /**\n * Returns the current provider value from the manager API data source.\n */\n getProvider(): number {\n return this.container\n .get<ManagerApiDataSource>(managerApiTypes.ManagerApiDataSource)\n .getProvider();\n }\n\n /**\n * Check if the current environment is supported by any transport.\n */\n isEnvironmentSupported(): boolean {\n return this.container\n .get<TransportService>(transportDiTypes.TransportService)\n .getAllTransports()\n .some((transport) => transport.isSupported());\n }\n\n /**\n * Returns the DMK logger factory with configured logger subscribers.\n */\n getLoggerFactory(): Factory<LoggerPublisherService> {\n return this.container.get(loggerTypes.LoggerPublisherServiceFactory);\n }\n}\n"],
|
|
5
|
+
"mappings": "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",
|
|
6
6
|
"names": ["commandTypes", "configTypes", "deviceSessionTypes", "discoveryTypes", "loggerTypes", "managerApiTypes", "sendTypes", "transportDiTypes", "makeContainer", "deviceActionTypes", "DeviceManagementKit", "stub", "transports", "loggers", "config", "args", "provider", "transport"]
|
|
7
7
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{Apdu as i}from"../../apdu/model/Apdu";import{ByteArrayBuilder as n}from"./ByteArrayBuilder";const p=5,
|
|
1
|
+
import{Apdu as i}from"../../apdu/model/Apdu";import{ByteArrayBuilder as n}from"./ByteArrayBuilder";const p=5,a=255,l=a+5;class A{_ins;_cla;_p1;p2;data=new n(a);constructor({ins:t,cla:r,p1:e,p2:d}){this._cla=r&255,this._ins=t&255,this._p1=e&255,this.p2=d&255}build=()=>new i(this._cla,this._ins,this._p1,this.p2,this.data.build());add8BitUIntToData=t=>(this.data.add8BitUIntToData(t),this);add16BitUIntToData=t=>(this.data.add16BitUIntToData(t),this);add32BitUIntToData=t=>(this.data.add32BitUIntToData(t),this);add64BitUIntToData=(t,r=!0)=>(this.data.add64BitUIntToData(t,r),this);addBufferToData=t=>(this.data.addBufferToData(t),this);addHexaStringToData=t=>(this.data.addHexaStringToData(t),this);addAsciiStringToData=t=>(this.data.addAsciiStringToData(t),this);encodeInLVFromHexa=t=>(this.data.encodeInLVFromHexa(t),this);encodeInLVFromBuffer=t=>(this.data.encodeInLVFromBuffer(t),this);encodeInLVFromAscii=t=>(this.data.encodeInLVFromAscii(t),this);getAvailablePayloadLength=()=>this.data.getAvailablePayloadLength();getErrors=()=>this.data.getErrors()}export{a as APDU_MAX_PAYLOAD,l as APDU_MAX_SIZE,A as ApduBuilder,p as HEADER_LENGTH};
|
|
2
2
|
//# sourceMappingURL=ApduBuilder.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../../src/api/apdu/utils/ApduBuilder.ts"],
|
|
4
|
-
"sourcesContent": ["import { Apdu } from \"@api/apdu/model/Apdu\";\n\nimport { type AppBuilderError } from \"./AppBuilderError\";\nimport { ByteArrayBuilder } from \"./ByteArrayBuilder\";\n\nexport const HEADER_LENGTH = 5;\nexport const APDU_MAX_PAYLOAD = 255;\nexport const APDU_MAX_SIZE = APDU_MAX_PAYLOAD + 5;\n\nexport type ApduBuilderArgs = {\n readonly ins: number;\n readonly cla: number;\n readonly p1: number;\n readonly p2: number;\n};\n\n/**\n * ApduBuilder is a utility class to help build APDU commands.\n * It allows to easily add data to the data field of the APDU command\n * and to encode this data in different formats.\n *\n * @example\n * ```\n * const apduBuilder = new ApduBuilder({ ins: 0x01, cla: 0x02, p1: 0x03, p2: 0x04 })\n * .add8BitUIntToData(0x05)\n * .add16BitUIntToData(0x0607)\n * .addHexaStringToData(\"0x0809\")\n * .addAsciiStringToData(\"hello\")\n *\n * const apdu = apduBuilder.build();\n * const builderErrors = apduBuilder.getErrors();\n * ```\n */\nexport class ApduBuilder {\n private readonly _ins: number;\n private readonly _cla: number;\n private readonly _p1: number;\n private readonly p2: number;\n private data: ByteArrayBuilder = new ByteArrayBuilder(APDU_MAX_PAYLOAD);\n\n constructor({ ins, cla, p1, p2 }: ApduBuilderArgs) {\n this._cla = cla & 0xff;\n this._ins = ins & 0xff;\n this._p1 = p1 & 0xff;\n this.p2 = p2 & 0xff;\n }\n\n // ==========\n // Public API\n // ==========\n\n /**\n * Build a new Apdu instance with the current state of the builder\n * @returns {Apdu} - Returns a new Apdu instance\n */\n build = (): Apdu =>\n new Apdu(this._cla, this._ins, this._p1, this.p2, this.data.build());\n\n /**\n * Add a 8-bit unsigned integer to the data field (max value 0xff = 255)\n * @param value?: number - The value to add to the data\n * @returns {ApduBuilder} - Returns the current instance of ApduBuilder\n */\n add8BitUIntToData = (value: number): ApduBuilder => {\n this.data.add8BitUIntToData(value);\n return this;\n };\n\n /**\n * Add a 16-bit unsigned integer to the data field (max value 0xffff = 65535)\n * @param value: number - The value to add to the data\n * @returns {ApduBuilder} - Returns the current instance of ApduBuilder\n */\n add16BitUIntToData = (value: number): ApduBuilder => {\n this.data.add16BitUIntToData(value);\n return this;\n };\n\n /**\n * Add a 32-bit unsigned integer to the data field (max value 0xffffffff = 4294967295)\n * @param value: number - The value to add to the data\n * @returns {ApduBuilder} - Returns the current instance of ApduBuilder\n */\n add32BitUIntToData = (value: number): ApduBuilder => {\n this.data.add32BitUIntToData(value);\n return this;\n };\n\n /**\n * Add a Uint8Array to the data field if it has enough remaining space\n * @param value: Uint8Array - The value to add to the data\n * @returns {ApduBuilder} - Returns the current instance of ApduBuilder\n */\n addBufferToData = (value: Uint8Array): ApduBuilder => {\n this.data.addBufferToData(value);\n return this;\n };\n\n /**\n * Add a string to the data field if it has enough remaining space\n * and it can be formatted as a hexadecimal string\n * @param value: string - The value to add to the data\n * @returns {ApduBuilder} - Returns the current instance of ApduBuilder\n */\n addHexaStringToData = (value: string): ApduBuilder => {\n this.data.addHexaStringToData(value);\n return this;\n };\n\n /**\n * Add an ascii string to the data field if it has enough remaining space\n * @param value: string - The value to add to the data\n * @returns {ApduBuilder} - Returns the current instance of ApduBuilder\n */\n addAsciiStringToData = (value: string): ApduBuilder => {\n this.data.addAsciiStringToData(value);\n return this;\n };\n\n /**\n * Add a Length-Value encoded hexadecimal string to the data field if it has enough remaining space\n * Length-Value encoding is a way to encode data in a binary format with the first byte\n * being the length of the data and the following bytes being the data itself\n * @param value: string - The value to add to the data\n * @returns {ApduBuilder} - Returns the current instance of ApduBuilder\n */\n encodeInLVFromHexa = (value: string): ApduBuilder => {\n this.data.encodeInLVFromHexa(value);\n return this;\n };\n\n /**\n * Add a Length-Value encoded buffer to the data field if it has enough remaining space\n * Length-Value encoding is a way to encode data in a binary format with the first byte\n * being the length of the data and the following bytes being the data itself\n * @param value: Uint8Array - The value to add to the data\n * @returns {ApduBuilder} - Returns the current instance of ApduBuilder\n */\n encodeInLVFromBuffer = (value: Uint8Array): ApduBuilder => {\n this.data.encodeInLVFromBuffer(value);\n return this;\n };\n\n /**\n * Add a Length-Value encoded ascii string to the data field if it has enough remaining space\n * Length-Value encoding is a way to encode data in a binary format with the first byte\n * being the length of the data and the following bytes being the data itself\n * @param value: string - The value to add to the data\n * @returns {ApduBuilder} - Returns the current instance of ApduBuilder\n */\n encodeInLVFromAscii = (value: string): ApduBuilder => {\n this.data.encodeInLVFromAscii(value);\n return this;\n };\n\n /**\n * Returns the remaining payload length\n * @returns {number}\n */\n getAvailablePayloadLength = (): number =>\n this.data.getAvailablePayloadLength();\n\n /**\n * Returns the current errors\n * @returns {AppBuilderError[]} - Returns an array of errors\n */\n getErrors = (): AppBuilderError[] => this.data.getErrors();\n}\n"],
|
|
5
|
-
"mappings": "AAAA,OAAS,QAAAA,MAAY,uBAGrB,OAAS,oBAAAC,MAAwB,qBAE1B,MAAMC,EAAgB,EAChBC,EAAmB,IACnBC,EAAgBD,EAAmB,EA0BzC,MAAME,CAAY,CACN,KACA,KACA,IACA,GACT,KAAyB,IAAIJ,EAAiBE,CAAgB,EAEtE,YAAY,CAAE,IAAAG,EAAK,IAAAC,EAAK,GAAAC,EAAI,GAAAC,CAAG,EAAoB,CACjD,KAAK,KAAOF,EAAM,IAClB,KAAK,KAAOD,EAAM,IAClB,KAAK,IAAME,EAAK,IAChB,KAAK,GAAKC,EAAK,GACjB,CAUA,MAAQ,IACN,IAAIT,EAAK,KAAK,KAAM,KAAK,KAAM,KAAK,IAAK,KAAK,GAAI,KAAK,KAAK,MAAM,CAAC,EAOrE,kBAAqBU,IACnB,KAAK,KAAK,kBAAkBA,CAAK,EAC1B,MAQT,mBAAsBA,IACpB,KAAK,KAAK,mBAAmBA,CAAK,EAC3B,MAQT,mBAAsBA,IACpB,KAAK,KAAK,mBAAmBA,CAAK,EAC3B,MAQT,
|
|
6
|
-
"names": ["Apdu", "ByteArrayBuilder", "HEADER_LENGTH", "APDU_MAX_PAYLOAD", "APDU_MAX_SIZE", "ApduBuilder", "ins", "cla", "p1", "p2", "value"]
|
|
4
|
+
"sourcesContent": ["import { Apdu } from \"@api/apdu/model/Apdu\";\n\nimport { type AppBuilderError } from \"./AppBuilderError\";\nimport { ByteArrayBuilder } from \"./ByteArrayBuilder\";\n\nexport const HEADER_LENGTH = 5;\nexport const APDU_MAX_PAYLOAD = 255;\nexport const APDU_MAX_SIZE = APDU_MAX_PAYLOAD + 5;\n\nexport type ApduBuilderArgs = {\n readonly ins: number;\n readonly cla: number;\n readonly p1: number;\n readonly p2: number;\n};\n\n/**\n * ApduBuilder is a utility class to help build APDU commands.\n * It allows to easily add data to the data field of the APDU command\n * and to encode this data in different formats.\n *\n * @example\n * ```\n * const apduBuilder = new ApduBuilder({ ins: 0x01, cla: 0x02, p1: 0x03, p2: 0x04 })\n * .add8BitUIntToData(0x05)\n * .add16BitUIntToData(0x0607)\n * .addHexaStringToData(\"0x0809\")\n * .addAsciiStringToData(\"hello\")\n *\n * const apdu = apduBuilder.build();\n * const builderErrors = apduBuilder.getErrors();\n * ```\n */\nexport class ApduBuilder {\n private readonly _ins: number;\n private readonly _cla: number;\n private readonly _p1: number;\n private readonly p2: number;\n private data: ByteArrayBuilder = new ByteArrayBuilder(APDU_MAX_PAYLOAD);\n\n constructor({ ins, cla, p1, p2 }: ApduBuilderArgs) {\n this._cla = cla & 0xff;\n this._ins = ins & 0xff;\n this._p1 = p1 & 0xff;\n this.p2 = p2 & 0xff;\n }\n\n // ==========\n // Public API\n // ==========\n\n /**\n * Build a new Apdu instance with the current state of the builder\n * @returns {Apdu} - Returns a new Apdu instance\n */\n build = (): Apdu =>\n new Apdu(this._cla, this._ins, this._p1, this.p2, this.data.build());\n\n /**\n * Add a 8-bit unsigned integer to the data field (max value 0xff = 255)\n * @param value?: number - The value to add to the data\n * @returns {ApduBuilder} - Returns the current instance of ApduBuilder\n */\n add8BitUIntToData = (value: number): ApduBuilder => {\n this.data.add8BitUIntToData(value);\n return this;\n };\n\n /**\n * Add a 16-bit unsigned integer to the data field (max value 0xffff = 65535)\n * @param value: number - The value to add to the data\n * @returns {ApduBuilder} - Returns the current instance of ApduBuilder\n */\n add16BitUIntToData = (value: number): ApduBuilder => {\n this.data.add16BitUIntToData(value);\n return this;\n };\n\n /**\n * Add a 32-bit unsigned integer to the data field (max value 0xffffffff = 4294967295)\n * @param value: number - The value to add to the data\n * @returns {ApduBuilder} - Returns the current instance of ApduBuilder\n */\n add32BitUIntToData = (value: number): ApduBuilder => {\n this.data.add32BitUIntToData(value);\n return this;\n };\n\n /**\n * Add a 64-bit unsigned integer to the data field in big-endian (max value 0xffffffffffffffff)\n * @param value: number | bigint - The value to add to the data\n * @param bigEndian: boolean - True for big-endian (default), false for little-endian\n * @returns {ApduBuilder} - Returns the current instance of ApduBuilder\n */\n add64BitUIntToData = (\n value: number | bigint,\n bigEndian: boolean = true,\n ): ApduBuilder => {\n this.data.add64BitUIntToData(value, bigEndian);\n return this;\n };\n\n /**\n * Add a Uint8Array to the data field if it has enough remaining space\n * @param value: Uint8Array - The value to add to the data\n * @returns {ApduBuilder} - Returns the current instance of ApduBuilder\n */\n addBufferToData = (value: Uint8Array): ApduBuilder => {\n this.data.addBufferToData(value);\n return this;\n };\n\n /**\n * Add a string to the data field if it has enough remaining space\n * and it can be formatted as a hexadecimal string\n * @param value: string - The value to add to the data\n * @returns {ApduBuilder} - Returns the current instance of ApduBuilder\n */\n addHexaStringToData = (value: string): ApduBuilder => {\n this.data.addHexaStringToData(value);\n return this;\n };\n\n /**\n * Add an ascii string to the data field if it has enough remaining space\n * @param value: string - The value to add to the data\n * @returns {ApduBuilder} - Returns the current instance of ApduBuilder\n */\n addAsciiStringToData = (value: string): ApduBuilder => {\n this.data.addAsciiStringToData(value);\n return this;\n };\n\n /**\n * Add a Length-Value encoded hexadecimal string to the data field if it has enough remaining space\n * Length-Value encoding is a way to encode data in a binary format with the first byte\n * being the length of the data and the following bytes being the data itself\n * @param value: string - The value to add to the data\n * @returns {ApduBuilder} - Returns the current instance of ApduBuilder\n */\n encodeInLVFromHexa = (value: string): ApduBuilder => {\n this.data.encodeInLVFromHexa(value);\n return this;\n };\n\n /**\n * Add a Length-Value encoded buffer to the data field if it has enough remaining space\n * Length-Value encoding is a way to encode data in a binary format with the first byte\n * being the length of the data and the following bytes being the data itself\n * @param value: Uint8Array - The value to add to the data\n * @returns {ApduBuilder} - Returns the current instance of ApduBuilder\n */\n encodeInLVFromBuffer = (value: Uint8Array): ApduBuilder => {\n this.data.encodeInLVFromBuffer(value);\n return this;\n };\n\n /**\n * Add a Length-Value encoded ascii string to the data field if it has enough remaining space\n * Length-Value encoding is a way to encode data in a binary format with the first byte\n * being the length of the data and the following bytes being the data itself\n * @param value: string - The value to add to the data\n * @returns {ApduBuilder} - Returns the current instance of ApduBuilder\n */\n encodeInLVFromAscii = (value: string): ApduBuilder => {\n this.data.encodeInLVFromAscii(value);\n return this;\n };\n\n /**\n * Returns the remaining payload length\n * @returns {number}\n */\n getAvailablePayloadLength = (): number =>\n this.data.getAvailablePayloadLength();\n\n /**\n * Returns the current errors\n * @returns {AppBuilderError[]} - Returns an array of errors\n */\n getErrors = (): AppBuilderError[] => this.data.getErrors();\n}\n"],
|
|
5
|
+
"mappings": "AAAA,OAAS,QAAAA,MAAY,uBAGrB,OAAS,oBAAAC,MAAwB,qBAE1B,MAAMC,EAAgB,EAChBC,EAAmB,IACnBC,EAAgBD,EAAmB,EA0BzC,MAAME,CAAY,CACN,KACA,KACA,IACA,GACT,KAAyB,IAAIJ,EAAiBE,CAAgB,EAEtE,YAAY,CAAE,IAAAG,EAAK,IAAAC,EAAK,GAAAC,EAAI,GAAAC,CAAG,EAAoB,CACjD,KAAK,KAAOF,EAAM,IAClB,KAAK,KAAOD,EAAM,IAClB,KAAK,IAAME,EAAK,IAChB,KAAK,GAAKC,EAAK,GACjB,CAUA,MAAQ,IACN,IAAIT,EAAK,KAAK,KAAM,KAAK,KAAM,KAAK,IAAK,KAAK,GAAI,KAAK,KAAK,MAAM,CAAC,EAOrE,kBAAqBU,IACnB,KAAK,KAAK,kBAAkBA,CAAK,EAC1B,MAQT,mBAAsBA,IACpB,KAAK,KAAK,mBAAmBA,CAAK,EAC3B,MAQT,mBAAsBA,IACpB,KAAK,KAAK,mBAAmBA,CAAK,EAC3B,MAST,mBAAqB,CACnBA,EACAC,EAAqB,MAErB,KAAK,KAAK,mBAAmBD,EAAOC,CAAS,EACtC,MAQT,gBAAmBD,IACjB,KAAK,KAAK,gBAAgBA,CAAK,EACxB,MAST,oBAAuBA,IACrB,KAAK,KAAK,oBAAoBA,CAAK,EAC5B,MAQT,qBAAwBA,IACtB,KAAK,KAAK,qBAAqBA,CAAK,EAC7B,MAUT,mBAAsBA,IACpB,KAAK,KAAK,mBAAmBA,CAAK,EAC3B,MAUT,qBAAwBA,IACtB,KAAK,KAAK,qBAAqBA,CAAK,EAC7B,MAUT,oBAAuBA,IACrB,KAAK,KAAK,oBAAoBA,CAAK,EAC5B,MAOT,0BAA4B,IAC1B,KAAK,KAAK,0BAA0B,EAMtC,UAAY,IAAyB,KAAK,KAAK,UAAU,CAC3D",
|
|
6
|
+
"names": ["Apdu", "ByteArrayBuilder", "HEADER_LENGTH", "APDU_MAX_PAYLOAD", "APDU_MAX_SIZE", "ApduBuilder", "ins", "cla", "p1", "p2", "value", "bigEndian"]
|
|
7
7
|
}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{ApduBuilder as d}from"../../apdu/utils/ApduBuilder";import{ApduParser as s}from"../../apdu/utils/ApduParser";import{InvalidStatusWordError as i}from"../../command/Errors";import{CommandResultFactory as o}from"../../command/model/CommandResult";import{isCommandErrorCode as g}from"../../command/utils/CommandErrors";import{CommandUtils as u}from"../../command/utils/CommandUtils";import{GlobalCommandErrorHandler as p}from"../../command/utils/GlobalCommandError";import{DeviceExchangeError as c}from"../../Error";const a={"662e":{message:"Invalid state, no background image loaded."},"662f":{message:"Invalid state, device is in recovery mode."}};class C extends c{constructor({message:e,errorCode:r}){super({message:e,errorCode:r,tag:"GetBackgroundImageSizeCommandError"})}}class G{name="getBackgroundImageSize";getApdu(){const e={cla:224,ins:100,p1:0,p2:0};return new d(e).build()}parseResponse(e){const r=new s(e);if(!u.isSuccessResponse(e)){const m=r.encodeToHexaString(e.statusCode);return g(m,a)?o({error:new C({...a[m],errorCode:m})}):o({error:p.handle(e)})}const t=r.extract32BitUInt();return t===void 0?o({error:new i("Didn't receive any size")}):o({data:t})}}export{G as GetBackgroundImageSizeCommand,C as GetBackgroundImageSizeCommandError};
|
|
2
|
+
//# sourceMappingURL=GetBackgroundImageSizeCommand.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../../../src/api/command/os/GetBackgroundImageSizeCommand.ts"],
|
|
4
|
+
"sourcesContent": ["import { type Apdu } from \"@api/apdu/model/Apdu\";\nimport { ApduBuilder, type ApduBuilderArgs } from \"@api/apdu/utils/ApduBuilder\";\nimport { ApduParser } from \"@api/apdu/utils/ApduParser\";\nimport { type Command } from \"@api/command/Command\";\nimport { InvalidStatusWordError } from \"@api/command/Errors\";\nimport {\n type CommandResult,\n CommandResultFactory,\n} from \"@api/command/model/CommandResult\";\nimport {\n type CommandErrors,\n isCommandErrorCode,\n} from \"@api/command/utils/CommandErrors\";\nimport { CommandUtils } from \"@api/command/utils/CommandUtils\";\nimport { GlobalCommandErrorHandler } from \"@api/command/utils/GlobalCommandError\";\nimport { type ApduResponse } from \"@api/device-session/ApduResponse\";\nimport { type CommandErrorArgs, DeviceExchangeError } from \"@api/Error\";\n\nexport type GetBackgroundImageSizeResponse = number;\n\nexport type GetBackgroundImageSizeErrorCodes = \"662e\" | \"662f\";\n\nconst IMAGE_SIZE_ERRORS: CommandErrors<GetBackgroundImageSizeErrorCodes> = {\n \"662e\": { message: \"Invalid state, no background image loaded.\" },\n \"662f\": { message: \"Invalid state, device is in recovery mode.\" },\n};\n\nexport type GetBackgroundImageSizeCommandResult = CommandResult<\n GetBackgroundImageSizeResponse,\n GetBackgroundImageSizeErrorCodes\n>;\n\nexport class GetBackgroundImageSizeCommandError extends DeviceExchangeError<GetBackgroundImageSizeErrorCodes> {\n constructor({\n message,\n errorCode,\n }: CommandErrorArgs<GetBackgroundImageSizeErrorCodes>) {\n super({ message, errorCode, tag: \"GetBackgroundImageSizeCommandError\" });\n }\n}\n\nexport class GetBackgroundImageSizeCommand\n implements\n Command<\n GetBackgroundImageSizeResponse,\n void,\n GetBackgroundImageSizeErrorCodes\n >\n{\n readonly name = \"getBackgroundImageSize\";\n\n getApdu(): Apdu {\n const apduArgs: ApduBuilderArgs = {\n cla: 0xe0,\n ins: 0x64,\n p1: 0x00,\n p2: 0x00,\n };\n return new ApduBuilder(apduArgs).build();\n }\n\n parseResponse(\n apduResponse: ApduResponse,\n ): GetBackgroundImageSizeCommandResult {\n const parser = new ApduParser(apduResponse);\n\n if (!CommandUtils.isSuccessResponse(apduResponse)) {\n const errorCode = parser.encodeToHexaString(apduResponse.statusCode);\n if (isCommandErrorCode(errorCode, IMAGE_SIZE_ERRORS)) {\n return CommandResultFactory({\n error: new GetBackgroundImageSizeCommandError({\n ...IMAGE_SIZE_ERRORS[errorCode],\n errorCode,\n }),\n });\n }\n return CommandResultFactory({\n error: GlobalCommandErrorHandler.handle(apduResponse),\n });\n }\n\n const size = parser.extract32BitUInt();\n if (size === undefined) {\n return CommandResultFactory({\n error: new InvalidStatusWordError(\"Didn't receive any size\"),\n });\n }\n\n return CommandResultFactory({\n data: size,\n });\n }\n}\n"],
|
|
5
|
+
"mappings": "AACA,OAAS,eAAAA,MAAyC,8BAClD,OAAS,cAAAC,MAAkB,6BAE3B,OAAS,0BAAAC,MAA8B,sBACvC,OAEE,wBAAAC,MACK,mCACP,OAEE,sBAAAC,MACK,mCACP,OAAS,gBAAAC,MAAoB,kCAC7B,OAAS,6BAAAC,MAAiC,wCAE1C,OAAgC,uBAAAC,MAA2B,aAM3D,MAAMC,EAAqE,CACzE,OAAQ,CAAE,QAAS,4CAA6C,EAChE,OAAQ,CAAE,QAAS,4CAA6C,CAClE,EAOO,MAAMC,UAA2CF,CAAsD,CAC5G,YAAY,CACV,QAAAG,EACA,UAAAC,CACF,EAAuD,CACrD,MAAM,CAAE,QAAAD,EAAS,UAAAC,EAAW,IAAK,oCAAqC,CAAC,CACzE,CACF,CAEO,MAAMC,CAOb,CACW,KAAO,yBAEhB,SAAgB,CACd,MAAMC,EAA4B,CAChC,IAAK,IACL,IAAK,IACL,GAAI,EACJ,GAAI,CACN,EACA,OAAO,IAAIb,EAAYa,CAAQ,EAAE,MAAM,CACzC,CAEA,cACEC,EACqC,CACrC,MAAMC,EAAS,IAAId,EAAWa,CAAY,EAE1C,GAAI,CAACT,EAAa,kBAAkBS,CAAY,EAAG,CACjD,MAAMH,EAAYI,EAAO,mBAAmBD,EAAa,UAAU,EACnE,OAAIV,EAAmBO,EAAWH,CAAiB,EAC1CL,EAAqB,CAC1B,MAAO,IAAIM,EAAmC,CAC5C,GAAGD,EAAkBG,CAAS,EAC9B,UAAAA,CACF,CAAC,CACH,CAAC,EAEIR,EAAqB,CAC1B,MAAOG,EAA0B,OAAOQ,CAAY,CACtD,CAAC,CACH,CAEA,MAAME,EAAOD,EAAO,iBAAiB,EACrC,OAAIC,IAAS,OACJb,EAAqB,CAC1B,MAAO,IAAID,EAAuB,yBAAyB,CAC7D,CAAC,EAGIC,EAAqB,CAC1B,KAAMa,CACR,CAAC,CACH,CACF",
|
|
6
|
+
"names": ["ApduBuilder", "ApduParser", "InvalidStatusWordError", "CommandResultFactory", "isCommandErrorCode", "CommandUtils", "GlobalCommandErrorHandler", "DeviceExchangeError", "IMAGE_SIZE_ERRORS", "GetBackgroundImageSizeCommandError", "message", "errorCode", "GetBackgroundImageSizeCommand", "apduArgs", "apduResponse", "parser", "size"]
|
|
7
|
+
}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{InvalidStatusWordError as d}from"../../command/Errors";import{CommandResultFactory as n}from"../../command/model/CommandResult";import{isSuccessCommandResult as o}from"../../command/model/CommandResult";import{GetBackgroundImageSizeCommand as i,GetBackgroundImageSizeCommandError as a}from"../../command/os/GetBackgroundImageSizeCommand";import{ApduResponse as s}from"../../device-session/ApduResponse";const c=new Uint8Array([224,100,0,0,0]);describe("GetBackgroundImageSizeCommand",()=>{let t;beforeEach(()=>{t=new i}),describe("name",()=>{it("should be 'getBackgroundImageSize'",()=>{expect(t.name).toBe("getBackgroundImageSize")})}),it("should return the correct APDU",()=>{const r=t.getApdu();expect(r.getRawApdu()).toStrictEqual(c)}),it("should parse result successfully",()=>{const r=new s({statusCode:new Uint8Array([144,0]),data:new Uint8Array([0,0,137,233])}),e=t.parseResponse(r);expect(e).toStrictEqual(n({data:35305}))}),it("should fail on invalid size",()=>{const r=new s({statusCode:new Uint8Array([144,0]),data:new Uint8Array([233])}),e=t.parseResponse(r);expect(e).toStrictEqual(n({error:new d("Didn't receive any size")}))}),it("should return error on no image loaded (662e)",()=>{const r=new s({statusCode:new Uint8Array([102,46]),data:new Uint8Array([])}),e=t.parseResponse(r);expect(o(e)).toBe(!1),o(e)||(expect(e.error).toBeInstanceOf(a),expect(e.error.message).toBe("Invalid state, no background image loaded."))}),it("should return error on recovery mode (662f)",()=>{const r=new s({statusCode:new Uint8Array([102,47]),data:new Uint8Array([])}),e=t.parseResponse(r);expect(o(e)).toBe(!1),o(e)||(expect(e.error).toBeInstanceOf(a),expect(e.error.message).toBe("Invalid state, device is in recovery mode."))}),it("should return global error on unknown status code",()=>{const r=new s({statusCode:new Uint8Array([110,0]),data:new Uint8Array([])}),e=t.parseResponse(r);expect(o(e)).toBe(!1)})});
|
|
2
|
+
//# sourceMappingURL=GetBackgroundImageSizeCommand.test.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../../../src/api/command/os/GetBackgroundImageSizeCommand.test.ts"],
|
|
4
|
+
"sourcesContent": ["import { InvalidStatusWordError } from \"@api/command/Errors\";\nimport { CommandResultFactory } from \"@api/command/model/CommandResult\";\nimport { isSuccessCommandResult } from \"@api/command/model/CommandResult\";\nimport {\n GetBackgroundImageSizeCommand,\n GetBackgroundImageSizeCommandError,\n} from \"@api/command/os/GetBackgroundImageSizeCommand\";\nimport { ApduResponse } from \"@api/device-session/ApduResponse\";\n\nconst IMAGE_SIZE_APDU = new Uint8Array([0xe0, 0x64, 0x00, 0x00, 0x00]);\n\ndescribe(\"GetBackgroundImageSizeCommand\", () => {\n let command: GetBackgroundImageSizeCommand;\n\n beforeEach(() => {\n command = new GetBackgroundImageSizeCommand();\n });\n\n describe(\"name\", () => {\n it(\"should be 'getBackgroundImageSize'\", () => {\n expect(command.name).toBe(\"getBackgroundImageSize\");\n });\n });\n\n it(\"should return the correct APDU\", () => {\n const apdu = command.getApdu();\n expect(apdu.getRawApdu()).toStrictEqual(IMAGE_SIZE_APDU);\n });\n\n it(\"should parse result successfully\", () => {\n const response: ApduResponse = new ApduResponse({\n statusCode: new Uint8Array([0x90, 0x00]),\n data: new Uint8Array([0x00, 0x00, 0x89, 0xe9]),\n });\n const result = command.parseResponse(response);\n expect(result).toStrictEqual(\n CommandResultFactory({\n data: 35305,\n }),\n );\n });\n\n it(\"should fail on invalid size\", () => {\n const response: ApduResponse = new ApduResponse({\n statusCode: new Uint8Array([0x90, 0x00]),\n data: new Uint8Array([0xe9]),\n });\n const result = command.parseResponse(response);\n expect(result).toStrictEqual(\n CommandResultFactory({\n error: new InvalidStatusWordError(\"Didn't receive any size\"),\n }),\n );\n });\n\n it(\"should return error on no image loaded (662e)\", () => {\n const response: ApduResponse = new ApduResponse({\n statusCode: new Uint8Array([0x66, 0x2e]),\n data: new Uint8Array([]),\n });\n const result = command.parseResponse(response);\n expect(isSuccessCommandResult(result)).toBe(false);\n if (!isSuccessCommandResult(result)) {\n expect(result.error).toBeInstanceOf(GetBackgroundImageSizeCommandError);\n expect((result.error as GetBackgroundImageSizeCommandError).message).toBe(\n \"Invalid state, no background image loaded.\",\n );\n }\n });\n\n it(\"should return error on recovery mode (662f)\", () => {\n const response: ApduResponse = new ApduResponse({\n statusCode: new Uint8Array([0x66, 0x2f]),\n data: new Uint8Array([]),\n });\n const result = command.parseResponse(response);\n expect(isSuccessCommandResult(result)).toBe(false);\n if (!isSuccessCommandResult(result)) {\n expect(result.error).toBeInstanceOf(GetBackgroundImageSizeCommandError);\n expect((result.error as GetBackgroundImageSizeCommandError).message).toBe(\n \"Invalid state, device is in recovery mode.\",\n );\n }\n });\n\n it(\"should return global error on unknown status code\", () => {\n const response: ApduResponse = new ApduResponse({\n statusCode: new Uint8Array([0x6e, 0x00]),\n data: new Uint8Array([]),\n });\n const result = command.parseResponse(response);\n expect(isSuccessCommandResult(result)).toBe(false);\n });\n});\n"],
|
|
5
|
+
"mappings": "AAAA,OAAS,0BAAAA,MAA8B,sBACvC,OAAS,wBAAAC,MAA4B,mCACrC,OAAS,0BAAAC,MAA8B,mCACvC,OACE,iCAAAC,EACA,sCAAAC,MACK,gDACP,OAAS,gBAAAC,MAAoB,mCAE7B,MAAMC,EAAkB,IAAI,WAAW,CAAC,IAAM,IAAM,EAAM,EAAM,CAAI,CAAC,EAErE,SAAS,gCAAiC,IAAM,CAC9C,IAAIC,EAEJ,WAAW,IAAM,CACfA,EAAU,IAAIJ,CAChB,CAAC,EAED,SAAS,OAAQ,IAAM,CACrB,GAAG,qCAAsC,IAAM,CAC7C,OAAOI,EAAQ,IAAI,EAAE,KAAK,wBAAwB,CACpD,CAAC,CACH,CAAC,EAED,GAAG,iCAAkC,IAAM,CACzC,MAAMC,EAAOD,EAAQ,QAAQ,EAC7B,OAAOC,EAAK,WAAW,CAAC,EAAE,cAAcF,CAAe,CACzD,CAAC,EAED,GAAG,mCAAoC,IAAM,CAC3C,MAAMG,EAAyB,IAAIJ,EAAa,CAC9C,WAAY,IAAI,WAAW,CAAC,IAAM,CAAI,CAAC,EACvC,KAAM,IAAI,WAAW,CAAC,EAAM,EAAM,IAAM,GAAI,CAAC,CAC/C,CAAC,EACKK,EAASH,EAAQ,cAAcE,CAAQ,EAC7C,OAAOC,CAAM,EAAE,cACbT,EAAqB,CACnB,KAAM,KACR,CAAC,CACH,CACF,CAAC,EAED,GAAG,8BAA+B,IAAM,CACtC,MAAMQ,EAAyB,IAAIJ,EAAa,CAC9C,WAAY,IAAI,WAAW,CAAC,IAAM,CAAI,CAAC,EACvC,KAAM,IAAI,WAAW,CAAC,GAAI,CAAC,CAC7B,CAAC,EACKK,EAASH,EAAQ,cAAcE,CAAQ,EAC7C,OAAOC,CAAM,EAAE,cACbT,EAAqB,CACnB,MAAO,IAAID,EAAuB,yBAAyB,CAC7D,CAAC,CACH,CACF,CAAC,EAED,GAAG,gDAAiD,IAAM,CACxD,MAAMS,EAAyB,IAAIJ,EAAa,CAC9C,WAAY,IAAI,WAAW,CAAC,IAAM,EAAI,CAAC,EACvC,KAAM,IAAI,WAAW,CAAC,CAAC,CACzB,CAAC,EACKK,EAASH,EAAQ,cAAcE,CAAQ,EAC7C,OAAOP,EAAuBQ,CAAM,CAAC,EAAE,KAAK,EAAK,EAC5CR,EAAuBQ,CAAM,IAChC,OAAOA,EAAO,KAAK,EAAE,eAAeN,CAAkC,EACtE,OAAQM,EAAO,MAA6C,OAAO,EAAE,KACnE,4CACF,EAEJ,CAAC,EAED,GAAG,8CAA+C,IAAM,CACtD,MAAMD,EAAyB,IAAIJ,EAAa,CAC9C,WAAY,IAAI,WAAW,CAAC,IAAM,EAAI,CAAC,EACvC,KAAM,IAAI,WAAW,CAAC,CAAC,CACzB,CAAC,EACKK,EAASH,EAAQ,cAAcE,CAAQ,EAC7C,OAAOP,EAAuBQ,CAAM,CAAC,EAAE,KAAK,EAAK,EAC5CR,EAAuBQ,CAAM,IAChC,OAAOA,EAAO,KAAK,EAAE,eAAeN,CAAkC,EACtE,OAAQM,EAAO,MAA6C,OAAO,EAAE,KACnE,4CACF,EAEJ,CAAC,EAED,GAAG,oDAAqD,IAAM,CAC5D,MAAMD,EAAyB,IAAIJ,EAAa,CAC9C,WAAY,IAAI,WAAW,CAAC,IAAM,CAAI,CAAC,EACvC,KAAM,IAAI,WAAW,CAAC,CAAC,CACzB,CAAC,EACKK,EAASH,EAAQ,cAAcE,CAAQ,EAC7C,OAAOP,EAAuBQ,CAAM,CAAC,EAAE,KAAK,EAAK,CACnD,CAAC,CACH,CAAC",
|
|
6
|
+
"names": ["InvalidStatusWordError", "CommandResultFactory", "isSuccessCommandResult", "GetBackgroundImageSizeCommand", "GetBackgroundImageSizeCommandError", "ApduResponse", "IMAGE_SIZE_APDU", "command", "apdu", "response", "result"]
|
|
7
|
+
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
const
|
|
1
|
+
import{DefaultLoggerPublisherService as t}from"../../../internal/logger-publisher/service/DefaultLoggerPublisherService";const n=vi.fn(),o=vi.fn(),i=vi.fn(),c=vi.fn(),s=vi.fn(),r=vi.fn(),a=vi.fn(),v=vi.fn(),S=vi.fn(e=>new t([],e));function M(){return{sendApdu:n,sendCommand:o,getDeviceModel:i,getDeviceSessionState:c,getDeviceSessionStateObservable:s,setDeviceSessionState:r,getManagerApiService:a,getSecureChannelService:v,loggerFactory:S}}export{M as makeDeviceActionInternalApiMock};
|
|
2
2
|
//# sourceMappingURL=makeInternalApi.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../../src/api/device-action/__test-utils__/makeInternalApi.ts"],
|
|
4
|
-
"sourcesContent": ["import { type Mocked } from \"vitest\";\n\nimport { type InternalApi } from \"@api/device-action/DeviceAction\";\n\nconst sendApduMock = vi.fn();\nconst sendCommandMock = vi.fn();\nconst apiGetDeviceModelMock = vi.fn();\nconst apiGetDeviceSessionStateMock = vi.fn();\nconst apiGetDeviceSessionStateObservableMock = vi.fn();\nconst setDeviceSessionStateMock = vi.fn();\nconst getManagerApiServiceMock = vi.fn();\nconst getSecureChannelServiceMock = vi.fn();\nconst
|
|
5
|
-
"mappings": "
|
|
6
|
-
"names": ["sendApduMock", "sendCommandMock", "apiGetDeviceModelMock", "apiGetDeviceSessionStateMock", "apiGetDeviceSessionStateObservableMock", "setDeviceSessionStateMock", "getManagerApiServiceMock", "getSecureChannelServiceMock", "
|
|
4
|
+
"sourcesContent": ["import { type Mocked } from \"vitest\";\n\nimport { type InternalApi } from \"@api/device-action/DeviceAction\";\nimport { DefaultLoggerPublisherService } from \"@internal/logger-publisher/service/DefaultLoggerPublisherService\";\n\nconst sendApduMock = vi.fn();\nconst sendCommandMock = vi.fn();\nconst apiGetDeviceModelMock = vi.fn();\nconst apiGetDeviceSessionStateMock = vi.fn();\nconst apiGetDeviceSessionStateObservableMock = vi.fn();\nconst setDeviceSessionStateMock = vi.fn();\nconst getManagerApiServiceMock = vi.fn();\nconst getSecureChannelServiceMock = vi.fn();\nconst loggerFactoryMock = vi.fn(\n (tag) => new DefaultLoggerPublisherService([], tag),\n);\n\nexport function makeDeviceActionInternalApiMock(): Mocked<InternalApi> {\n return {\n sendApdu: sendApduMock,\n sendCommand: sendCommandMock,\n getDeviceModel: apiGetDeviceModelMock,\n getDeviceSessionState: apiGetDeviceSessionStateMock,\n getDeviceSessionStateObservable: apiGetDeviceSessionStateObservableMock,\n setDeviceSessionState: setDeviceSessionStateMock,\n getManagerApiService: getManagerApiServiceMock,\n getSecureChannelService: getSecureChannelServiceMock,\n loggerFactory: loggerFactoryMock,\n };\n}\n"],
|
|
5
|
+
"mappings": "AAGA,OAAS,iCAAAA,MAAqC,mEAE9C,MAAMC,EAAe,GAAG,GAAG,EACrBC,EAAkB,GAAG,GAAG,EACxBC,EAAwB,GAAG,GAAG,EAC9BC,EAA+B,GAAG,GAAG,EACrCC,EAAyC,GAAG,GAAG,EAC/CC,EAA4B,GAAG,GAAG,EAClCC,EAA2B,GAAG,GAAG,EACjCC,EAA8B,GAAG,GAAG,EACpCC,EAAoB,GAAG,GAC1BC,GAAQ,IAAIV,EAA8B,CAAC,EAAGU,CAAG,CACpD,EAEO,SAASC,GAAuD,CACrE,MAAO,CACL,SAAUV,EACV,YAAaC,EACb,eAAgBC,EAChB,sBAAuBC,EACvB,gCAAiCC,EACjC,sBAAuBC,EACvB,qBAAsBC,EACtB,wBAAyBC,EACzB,cAAeC,CACjB,CACF",
|
|
6
|
+
"names": ["DefaultLoggerPublisherService", "sendApduMock", "sendCommandMock", "apiGetDeviceModelMock", "apiGetDeviceSessionStateMock", "apiGetDeviceSessionStateObservableMock", "setDeviceSessionStateMock", "getManagerApiServiceMock", "getSecureChannelServiceMock", "loggerFactoryMock", "tag", "makeDeviceActionInternalApiMock"]
|
|
7
7
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{Left as o,Right as
|
|
1
|
+
import{Left as o,Right as n}from"purify-ts";import{assign as i,createMachine as r}from"xstate";import{UserInteractionRequired as p}from"../../device-action/model/UserInteractionRequired";import{UnknownDAError as m}from"../../device-action/os/Errors";import{GetDeviceMetadataDeviceAction as s}from"../../device-action/os/GetDeviceMetadata/GetDeviceMetadataDeviceAction";import{getDeviceMetadataDAStateStep as c}from"../../device-action/os/GetDeviceMetadata/types";import{GetDeviceStatusDeviceAction as d}from"../../device-action/os/GetDeviceStatus/GetDeviceStatusDeviceAction";import{getDeviceStatusDAStateStep as l}from"../../device-action/os/GetDeviceStatus/types";import{GoToDashboardDeviceAction as A}from"../../device-action/os/GoToDashboard/GoToDashboardDeviceAction";import{goToDashboardDAStateStep as u}from"../../device-action/os/GoToDashboard/types";import{InstallOrUpdateAppsDeviceAction as f}from"../../device-action/os/InstallOrUpdateApps/InstallOrUpdateAppsDeviceAction";import{ListAppsDeviceAction as k}from"../../device-action/os/ListApps/ListAppsDeviceAction";import{listAppsDAStateStep as D}from"../../device-action/os/ListApps/types";import{OpenAppDeviceAction as I}from"../../device-action/os/OpenAppDeviceAction/OpenAppDeviceAction";import{openAppDAStateStep as y}from"../../device-action/os/OpenAppDeviceAction/types";import{ListInstalledAppsDeviceAction as M}from"../../secure-channel/device-action/ListInstalledApps/ListInstalledAppsDeviceAction";const x=(e,t=!1)=>{k.mockImplementation(()=>({makeStateMachine:vi.fn().mockImplementation(()=>r({id:"MockListAppsDeviceAction",initial:"ready",states:{ready:{after:{0:"done"},entry:i({intermediateValue:()=>({requiredUserInteraction:p.AllowListApps,step:D.LIST_APPS})})},done:{type:"final"}},output:()=>t?o(new m("ListApps failed")):n(e)}))}))},P=(e,t=!1)=>{s.mockImplementation(()=>({makeStateMachine:vi.fn().mockImplementation(()=>r({id:"MockGetDeviceMetadataDeviceAction",initial:"ready",states:{ready:{after:{0:"done"},entry:i({intermediateValue:()=>({requiredUserInteraction:p.None,step:c.GET_DEVICE_METADATA})})},done:{type:"final"}},output:()=>t?o(new m("GetDeviceMetadata failed")):n(e)}))}))},N=(e,t,a=!1)=>{f.mockImplementation(()=>({makeStateMachine:vi.fn().mockImplementation(()=>r({id:"MockInstallOrUpdateAppsDeviceAction",initial:"ready",states:{ready:{after:{0:"done"},entry:i({intermediateValue:()=>t})},done:{type:"final"}},output:()=>a?o(new m("InstallOrUpdateApps failed")):n(e)}))}))},B=(e=!1)=>{I.mockImplementation(()=>({makeStateMachine:vi.fn().mockImplementation(()=>r({initial:"ready",states:{ready:{entry:i({intermediateValue:{requiredUserInteraction:p.ConfirmOpenApp,step:y.GET_DEVICE_STATUS}}),after:{0:"done"}},done:{type:"final"}},output:()=>e?o(new m("OpenApp failed")):n(void 0)}))}))},R=(e=!1)=>{A.mockImplementation(()=>({makeStateMachine:vi.fn().mockImplementation(()=>r({id:"MockGoToDashboardDeviceAction",initial:"ready",states:{ready:{after:{0:"done"},entry:i({intermediateValue:()=>({requiredUserInteraction:p.None,step:u.GET_DEVICE_STATUS})})},done:{type:"final"}},output:()=>e?o(new m("GoToDashboard failed")):n(void 0)}))}))},F=(e=[{currentApp:"BOLOS",currentAppVersion:"1.0.0"}])=>{const t=vi.fn();for(const a of e)t.mockImplementationOnce(()=>"currentApp"in a?n(a):o(a));d.mockImplementation(()=>({makeStateMachine:vi.fn().mockImplementation(()=>r({id:"MockGetDeviceStatusDeviceAction",initial:"ready",states:{ready:{after:{0:"done"},entry:i({intermediateValue:()=>({requiredUserInteraction:p.None,step:l.ONBOARD_CHECK})})},done:{type:"final"}},output:t}))}))},H=(e=[])=>{M.mockImplementation(()=>({makeStateMachine:vi.fn().mockImplementation(()=>r({id:"MockListInstalledAppsDeviceAction",initial:"ready",states:{ready:{after:{0:"done"},entry:i({intermediateValue:()=>({requiredUserInteraction:p.None})})},done:{type:"final"}},output:e.reduce((t,a)=>t.mockImplementationOnce(()=>"installedApps"in a?n(a):o(a)),vi.fn()).mockImplementation(()=>n([]))}))}))};export{P as setupGetDeviceMetadataMock,F as setupGetDeviceStatusMock,R as setupGoToDashboardMock,N as setupInstallOrUpdateAppsMock,x as setupListAppsMock,H as setupListInstalledAppsMock,B as setupOpenAppMock};
|
|
2
2
|
//# sourceMappingURL=setupTestMachine.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../../src/api/device-action/__test-utils__/setupTestMachine.ts"],
|
|
4
|
-
"sourcesContent": ["import { Left, Right } from \"purify-ts\";\nimport { type Mock } from \"vitest\";\nimport { assign, createMachine } from \"xstate\";\n\nimport { UserInteractionRequired } from \"@api/device-action/model/UserInteractionRequired\";\nimport { UnknownDAError } from \"@api/device-action/os/Errors\";\nimport { GetDeviceMetadataDeviceAction } from \"@api/device-action/os/GetDeviceMetadata/GetDeviceMetadataDeviceAction\";\nimport {
|
|
5
|
-
"mappings": "AAAA,OAAS,QAAAA,EAAM,SAAAC,MAAa,YAE5B,OAAS,UAAAC,EAAQ,iBAAAC,MAAqB,SAEtC,OAAS,2BAAAC,MAA+B,mDACxC,OAAS,kBAAAC,MAAsB,+BAC/B,OAAS,iCAAAC,MAAqC,
|
|
6
|
-
"names": ["Left", "Right", "assign", "createMachine", "UserInteractionRequired", "UnknownDAError", "GetDeviceMetadataDeviceAction", "GetDeviceStatusDeviceAction", "GoToDashboardDeviceAction", "InstallOrUpdateAppsDeviceAction", "ListAppsDeviceAction", "OpenAppDeviceAction", "ListInstalledAppsDeviceAction", "setupListAppsMock", "apps", "error", "setupGetDeviceMetadataMock", "metadata", "setupInstallOrUpdateAppsMock", "result", "intermediateValue", "setupOpenAppMock", "setupGoToDashboardMock", "setupGetDeviceStatusMock", "outputs", "outputFn", "output", "setupListInstalledAppsMock", "mockFn"]
|
|
4
|
+
"sourcesContent": ["import { Left, Right } from \"purify-ts\";\nimport { type Mock } from \"vitest\";\nimport { assign, createMachine } from \"xstate\";\n\nimport { UserInteractionRequired } from \"@api/device-action/model/UserInteractionRequired\";\nimport { UnknownDAError } from \"@api/device-action/os/Errors\";\nimport { GetDeviceMetadataDeviceAction } from \"@api/device-action/os/GetDeviceMetadata/GetDeviceMetadataDeviceAction\";\nimport {\n type GetDeviceMetadataDAOutput,\n getDeviceMetadataDAStateStep,\n} from \"@api/device-action/os/GetDeviceMetadata/types\";\nimport { GetDeviceStatusDeviceAction } from \"@api/device-action/os/GetDeviceStatus/GetDeviceStatusDeviceAction\";\nimport { getDeviceStatusDAStateStep } from \"@api/device-action/os/GetDeviceStatus/types\";\nimport { GoToDashboardDeviceAction } from \"@api/device-action/os/GoToDashboard/GoToDashboardDeviceAction\";\nimport { goToDashboardDAStateStep } from \"@api/device-action/os/GoToDashboard/types\";\nimport { InstallOrUpdateAppsDeviceAction } from \"@api/device-action/os/InstallOrUpdateApps/InstallOrUpdateAppsDeviceAction\";\nimport {\n type InstallOrUpdateAppsDAIntermediateValue,\n type InstallOrUpdateAppsDAOutput,\n} from \"@api/device-action/os/InstallOrUpdateApps/types\";\nimport { ListAppsDeviceAction } from \"@api/device-action/os/ListApps/ListAppsDeviceAction\";\nimport { listAppsDAStateStep } from \"@api/device-action/os/ListApps/types\";\nimport { OpenAppDeviceAction } from \"@api/device-action/os/OpenAppDeviceAction/OpenAppDeviceAction\";\nimport { openAppDAStateStep } from \"@api/device-action/os/OpenAppDeviceAction/types\";\nimport { type DmkError } from \"@api/Error\";\nimport { ListInstalledAppsDeviceAction } from \"@api/secure-channel/device-action/ListInstalledApps/ListInstalledAppsDeviceAction\";\nimport { type InstalledApp } from \"@api/secure-channel/device-action/ListInstalledApps/types\";\n\nimport { type BTC_APP } from \"./data\";\n\ntype App = typeof BTC_APP;\n\nexport const setupListAppsMock = (apps: App[], error = false) => {\n (ListAppsDeviceAction as Mock).mockImplementation(() => ({\n makeStateMachine: vi.fn().mockImplementation(() =>\n createMachine({\n id: \"MockListAppsDeviceAction\",\n initial: \"ready\",\n states: {\n ready: {\n after: {\n 0: \"done\",\n },\n entry: assign({\n intermediateValue: () => ({\n requiredUserInteraction: UserInteractionRequired.AllowListApps,\n step: listAppsDAStateStep.LIST_APPS,\n }),\n }),\n },\n done: {\n type: \"final\",\n },\n },\n output: () => {\n return error\n ? Left(new UnknownDAError(\"ListApps failed\"))\n : Right(apps);\n },\n }),\n ),\n }));\n};\n\nexport const setupGetDeviceMetadataMock = (\n metadata: GetDeviceMetadataDAOutput,\n error = false,\n) => {\n (GetDeviceMetadataDeviceAction as Mock).mockImplementation(() => ({\n makeStateMachine: vi.fn().mockImplementation(() =>\n createMachine({\n id: \"MockGetDeviceMetadataDeviceAction\",\n initial: \"ready\",\n states: {\n ready: {\n after: {\n 0: \"done\",\n },\n entry: assign({\n intermediateValue: () => ({\n requiredUserInteraction: UserInteractionRequired.None,\n step: getDeviceMetadataDAStateStep.GET_DEVICE_METADATA,\n }),\n }),\n },\n done: {\n type: \"final\",\n },\n },\n output: () => {\n return error\n ? Left(new UnknownDAError(\"GetDeviceMetadata failed\"))\n : Right(metadata);\n },\n }),\n ),\n }));\n};\n\nexport const setupInstallOrUpdateAppsMock = (\n result: InstallOrUpdateAppsDAOutput,\n intermediateValue: InstallOrUpdateAppsDAIntermediateValue,\n error = false,\n) => {\n (InstallOrUpdateAppsDeviceAction as Mock).mockImplementation(() => ({\n makeStateMachine: vi.fn().mockImplementation(() =>\n createMachine({\n id: \"MockInstallOrUpdateAppsDeviceAction\",\n initial: \"ready\",\n states: {\n ready: {\n after: {\n 0: \"done\",\n },\n entry: assign({\n intermediateValue: () => intermediateValue,\n }),\n },\n done: {\n type: \"final\",\n },\n },\n output: () => {\n return error\n ? Left(new UnknownDAError(\"InstallOrUpdateApps failed\"))\n : Right(result);\n },\n }),\n ),\n }));\n};\n\nexport const setupOpenAppMock = (error: boolean = false) => {\n (OpenAppDeviceAction as Mock).mockImplementation(() => ({\n makeStateMachine: vi.fn().mockImplementation(() =>\n createMachine({\n initial: \"ready\",\n states: {\n ready: {\n entry: assign({\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.ConfirmOpenApp,\n step: openAppDAStateStep.GET_DEVICE_STATUS,\n },\n }),\n after: {\n 0: \"done\",\n },\n },\n done: {\n type: \"final\",\n },\n },\n output: () => {\n return error\n ? Left(new UnknownDAError(\"OpenApp failed\"))\n : Right(undefined);\n },\n }),\n ),\n }));\n};\n\nexport const setupGoToDashboardMock = (error: boolean = false) => {\n (GoToDashboardDeviceAction as Mock).mockImplementation(() => ({\n makeStateMachine: vi.fn().mockImplementation(() =>\n createMachine({\n id: \"MockGoToDashboardDeviceAction\",\n initial: \"ready\",\n states: {\n ready: {\n after: {\n 0: \"done\",\n },\n entry: assign({\n intermediateValue: () => ({\n requiredUserInteraction: UserInteractionRequired.None,\n step: goToDashboardDAStateStep.GET_DEVICE_STATUS,\n }),\n }),\n },\n done: {\n type: \"final\",\n },\n },\n output: () => {\n return error\n ? Left(new UnknownDAError(\"GoToDashboard failed\"))\n : Right(undefined);\n },\n }),\n ),\n }));\n};\n\nexport const setupGetDeviceStatusMock = (\n outputs: ReadonlyArray<\n { currentApp: string; currentAppVersion: string } | DmkError\n > = [\n {\n currentApp: \"BOLOS\",\n currentAppVersion: \"1.0.0\",\n },\n ],\n) => {\n const outputFn = vi.fn();\n\n for (const output of outputs) {\n outputFn.mockImplementationOnce(() =>\n \"currentApp\" in output ? Right(output) : Left(output),\n );\n }\n (GetDeviceStatusDeviceAction as Mock).mockImplementation(() => ({\n makeStateMachine: vi.fn().mockImplementation(() =>\n createMachine({\n id: \"MockGetDeviceStatusDeviceAction\",\n initial: \"ready\",\n states: {\n ready: {\n after: {\n 0: \"done\",\n },\n entry: assign({\n intermediateValue: () => ({\n requiredUserInteraction: UserInteractionRequired.None,\n step: getDeviceStatusDAStateStep.ONBOARD_CHECK,\n }),\n }),\n },\n done: {\n type: \"final\",\n },\n },\n output: outputFn,\n }),\n ),\n }));\n};\n\nexport const setupListInstalledAppsMock = (\n outputs: Array<{ installedApps: InstalledApp[] } | DmkError> = [],\n) => {\n (ListInstalledAppsDeviceAction as Mock).mockImplementation(() => ({\n makeStateMachine: vi.fn().mockImplementation(() =>\n createMachine({\n id: \"MockListInstalledAppsDeviceAction\",\n initial: \"ready\",\n states: {\n ready: {\n after: {\n 0: \"done\",\n },\n entry: assign({\n intermediateValue: () => ({\n requiredUserInteraction: UserInteractionRequired.None,\n }),\n }),\n },\n done: {\n type: \"final\",\n },\n },\n output: outputs\n .reduce(\n (mockFn, output) =>\n mockFn.mockImplementationOnce(() =>\n \"installedApps\" in output ? Right(output) : Left(output),\n ),\n vi.fn(),\n )\n .mockImplementation(() => Right([])),\n }),\n ),\n }));\n};\n"],
|
|
5
|
+
"mappings": "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",
|
|
6
|
+
"names": ["Left", "Right", "assign", "createMachine", "UserInteractionRequired", "UnknownDAError", "GetDeviceMetadataDeviceAction", "getDeviceMetadataDAStateStep", "GetDeviceStatusDeviceAction", "getDeviceStatusDAStateStep", "GoToDashboardDeviceAction", "goToDashboardDAStateStep", "InstallOrUpdateAppsDeviceAction", "ListAppsDeviceAction", "listAppsDAStateStep", "OpenAppDeviceAction", "openAppDAStateStep", "ListInstalledAppsDeviceAction", "setupListAppsMock", "apps", "error", "setupGetDeviceMetadataMock", "metadata", "setupInstallOrUpdateAppsMock", "result", "intermediateValue", "setupOpenAppMock", "setupGoToDashboardMock", "setupGetDeviceStatusMock", "outputs", "outputFn", "output", "setupListInstalledAppsMock", "mockFn"]
|
|
7
7
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
var
|
|
1
|
+
var m=(o=>(o.None="none",o.UnlockDevice="unlock-device",o.AllowSecureConnection="allow-secure-connection",o.ConfirmOpenApp="confirm-open-app",o.SignTransaction="sign-transaction",o.SignTypedData="sign-typed-data",o.AllowListApps="allow-list-apps",o.VerifyAddress="verify-address",o.SignPersonalMessage="sign-personal-message",o.SignDelegationAuthorization="sign-delegation-authorization",o.Web3ChecksOptIn="web3-checks-opt-in",o.VerifySafeAddress="verify-safe-address",o.RegisterWallet="register-wallet",o.ConfirmLoadImage="confirm-load-image",o.ConfirmCommitImage="confirm-commit-image",o.ConfirmRemoveImage="confirm-remove-image",o))(m||{});export{m as UserInteractionRequired};
|
|
2
2
|
//# sourceMappingURL=UserInteractionRequired.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../../src/api/device-action/model/UserInteractionRequired.ts"],
|
|
4
|
-
"sourcesContent": ["/**\n * The user interaction required on the device to move further in a device action.\n * This is used to inform the users about the action they need to take on the device.\n */\nexport enum UserInteractionRequired {\n None = \"none\",\n UnlockDevice = \"unlock-device\",\n AllowSecureConnection = \"allow-secure-connection\",\n ConfirmOpenApp = \"confirm-open-app\",\n SignTransaction = \"sign-transaction\",\n SignTypedData = \"sign-typed-data\",\n AllowListApps = \"allow-list-apps\",\n VerifyAddress = \"verify-address\",\n SignPersonalMessage = \"sign-personal-message\",\n SignDelegationAuthorization = \"sign-delegation-authorization\",\n Web3ChecksOptIn = \"web3-checks-opt-in\",\n VerifySafeAddress = \"verify-safe-address\",\n RegisterWallet = \"register-wallet\",\n}\n"],
|
|
5
|
-
"mappings": "AAIO,IAAKA,OACVA,EAAA,KAAO,OACPA,EAAA,aAAe,gBACfA,EAAA,sBAAwB,0BACxBA,EAAA,eAAiB,mBACjBA,EAAA,gBAAkB,mBAClBA,EAAA,cAAgB,kBAChBA,EAAA,cAAgB,kBAChBA,EAAA,cAAgB,iBAChBA,EAAA,oBAAsB,wBACtBA,EAAA,4BAA8B,gCAC9BA,EAAA,gBAAkB,qBAClBA,EAAA,kBAAoB,sBACpBA,EAAA,eAAiB,
|
|
4
|
+
"sourcesContent": ["/**\n * The user interaction required on the device to move further in a device action.\n * This is used to inform the users about the action they need to take on the device.\n */\nexport enum UserInteractionRequired {\n None = \"none\",\n UnlockDevice = \"unlock-device\",\n AllowSecureConnection = \"allow-secure-connection\",\n ConfirmOpenApp = \"confirm-open-app\",\n SignTransaction = \"sign-transaction\",\n SignTypedData = \"sign-typed-data\",\n AllowListApps = \"allow-list-apps\",\n VerifyAddress = \"verify-address\",\n SignPersonalMessage = \"sign-personal-message\",\n SignDelegationAuthorization = \"sign-delegation-authorization\",\n Web3ChecksOptIn = \"web3-checks-opt-in\",\n VerifySafeAddress = \"verify-safe-address\",\n RegisterWallet = \"register-wallet\",\n ConfirmLoadImage = \"confirm-load-image\",\n ConfirmCommitImage = \"confirm-commit-image\",\n ConfirmRemoveImage = \"confirm-remove-image\",\n}\n"],
|
|
5
|
+
"mappings": "AAIO,IAAKA,OACVA,EAAA,KAAO,OACPA,EAAA,aAAe,gBACfA,EAAA,sBAAwB,0BACxBA,EAAA,eAAiB,mBACjBA,EAAA,gBAAkB,mBAClBA,EAAA,cAAgB,kBAChBA,EAAA,cAAgB,kBAChBA,EAAA,cAAgB,iBAChBA,EAAA,oBAAsB,wBACtBA,EAAA,4BAA8B,gCAC9BA,EAAA,gBAAkB,qBAClBA,EAAA,kBAAoB,sBACpBA,EAAA,eAAiB,kBACjBA,EAAA,iBAAmB,qBACnBA,EAAA,mBAAqB,uBACrBA,EAAA,mBAAqB,uBAhBXA,OAAA",
|
|
6
6
|
"names": ["UserInteractionRequired"]
|
|
7
7
|
}
|
package/lib/esm/src/api/device-action/os/CallTaskInAppDeviceAction/CallTaskInAppDeviceAction.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{Left as
|
|
1
|
+
import{Left as o,Right as i}from"purify-ts";import{assign as t,fromPromise as l,setup as c}from"xstate";import{isSuccessCommandResult as u}from"../../../command/model/CommandResult";import{UserInteractionRequired as p}from"../../../device-action/model/UserInteractionRequired";import{UnknownDAError as k}from"../../../device-action/os/Errors";import{OpenAppDeviceAction as A}from"../../../device-action/os/OpenAppDeviceAction/OpenAppDeviceAction";import{XStateDeviceAction as T}from"../../../device-action/xstate-utils/XStateDeviceAction";import{callTaskInAppDAStateStep as s}from"./CallTaskInAppDeviceActionTypes";class h extends T{makeStateMachine(a){const{callTask:r}=this.extractDependencies(a);return c({types:{input:{},context:{},output:{}},actors:{callTask:l(r),openAppStateMachine:new A({input:{appName:this.input.appName}}).makeStateMachine(a)},guards:{skipOpenApp:()=>this.input.skipOpenApp,noInternalError:({context:e})=>e._internalState.error===null},actions:{assignErrorFromEvent:t({_internalState:e=>({...e.context._internalState,error:e.event.error})})}}).createMachine({id:"CallTaskInAppDeviceAction",initial:"InitialState",context:({input:e})=>({input:e,intermediateValue:{requiredUserInteraction:p.None,step:s.OPEN_APP},_internalState:{taskResponse:null,error:null}}),states:{InitialState:{always:[{target:"CallTask",guard:"skipOpenApp"},"OpenAppDeviceAction"]},OpenAppDeviceAction:{invoke:{id:"openAppStateMachine",input:{appName:this.input.appName},src:"openAppStateMachine",onSnapshot:{actions:t({intermediateValue:e=>e.event.snapshot.context.intermediateValue})},onDone:{actions:t({_internalState:e=>e.event.output.caseOf({Right:()=>e.context._internalState,Left:n=>({...e.context._internalState,error:n})})}),target:"CheckOpenAppDeviceActionResult"}}},CheckOpenAppDeviceActionResult:{always:[{target:"CallTask",guard:"noInternalError"},"Error"]},CallTask:{entry:t({intermediateValue:{requiredUserInteraction:this.input.requiredUserInteraction,step:s.CALL_TASK}}),exit:t({intermediateValue:{requiredUserInteraction:p.None,step:s.CALL_TASK}}),invoke:{id:"callTask",src:"callTask",input:e=>e.context.input.task,onDone:{target:"CallTaskResultCheck",actions:[t({_internalState:({event:e,context:n})=>u(e.output)?{...n._internalState,taskResponse:e.output.data}:{...n._internalState,error:e.output.error}})]},onError:{target:"Error",actions:"assignErrorFromEvent"}}},CallTaskResultCheck:{always:[{target:"Success",guard:"noInternalError"},"Error"]},Success:{type:"final"},Error:{type:"final"}},output:({context:e})=>e._internalState.taskResponse?i(e._internalState.taskResponse):o(e._internalState.error||new k("No error in final state"))})}extractDependencies(a){return{callTask:r=>r.input(a)}}}export{h as CallTaskInAppDeviceAction};
|
|
2
2
|
//# sourceMappingURL=CallTaskInAppDeviceAction.js.map
|