@ledgerhq/device-management-kit 0.0.0-webhid-20250129103551 → 0.0.0-wip-20250214170223
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/lib/cjs/package.json +6 -5
- package/lib/cjs/src/api/DeviceManagementKit.test.js +1 -1
- package/lib/cjs/src/api/DeviceManagementKit.test.js.map +2 -2
- package/lib/cjs/src/api/DeviceManagementKitBuilder.js +1 -1
- package/lib/cjs/src/api/DeviceManagementKitBuilder.js.map +2 -2
- package/lib/cjs/src/api/DeviceManagementKitBuilder.test.js +1 -1
- package/lib/cjs/src/api/DeviceManagementKitBuilder.test.js.map +2 -2
- package/lib/cjs/src/api/apdu/utils/ByteArrayParser.test.js +1 -1
- package/lib/cjs/src/api/apdu/utils/ByteArrayParser.test.js.map +2 -2
- package/lib/cjs/src/api/command/os/LoadCertificateCommand.js +2 -0
- package/lib/cjs/src/api/command/os/LoadCertificateCommand.js.map +7 -0
- package/lib/cjs/src/api/command/os/LoadCertificateCommand.test.js +2 -0
- package/lib/cjs/src/api/command/os/LoadCertificateCommand.test.js.map +7 -0
- package/lib/cjs/src/api/command/use-case/SendCommandUseCase.test.js +1 -1
- package/lib/cjs/src/api/command/use-case/SendCommandUseCase.test.js.map +3 -3
- package/lib/cjs/src/api/command/utils/CommandUtils.js +1 -1
- package/lib/cjs/src/api/command/utils/CommandUtils.js.map +3 -3
- package/lib/cjs/src/api/command/utils/CommandUtils.test.js +1 -1
- package/lib/cjs/src/api/command/utils/CommandUtils.test.js.map +3 -3
- 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 +2 -2
- package/lib/cjs/src/api/device-action/__test-utils__/testDeviceActionStates.js +1 -1
- package/lib/cjs/src/api/device-action/__test-utils__/testDeviceActionStates.js.map +3 -3
- package/lib/cjs/src/api/device-action/os/CallTaskInAppDeviceAction/CallTaskInAppDeviceAction.js +2 -0
- package/lib/cjs/src/api/device-action/os/CallTaskInAppDeviceAction/CallTaskInAppDeviceAction.js.map +7 -0
- package/lib/cjs/src/api/device-action/os/CallTaskInAppDeviceAction/CallTaskInAppDeviceAction.test.js +2 -0
- package/lib/cjs/src/api/device-action/os/CallTaskInAppDeviceAction/CallTaskInAppDeviceAction.test.js.map +7 -0
- package/lib/cjs/src/api/device-action/os/CallTaskInAppDeviceAction/CallTaskInAppDeviceActionTypes.js +2 -0
- package/lib/cjs/src/api/device-action/os/CallTaskInAppDeviceAction/CallTaskInAppDeviceActionTypes.js.map +7 -0
- 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/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/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/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/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/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-session/use-case/ToggleDeviceSessionRefresher.test.js +1 -1
- package/lib/cjs/src/api/device-session/use-case/ToggleDeviceSessionRefresher.test.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-subscriber/service/ConsoleLogger.test.js +1 -1
- package/lib/cjs/src/api/logger-subscriber/service/ConsoleLogger.test.js.map +2 -2
- 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/logger-subscriber/service/__mocks__/ConsoleLogger.js +1 -1
- package/lib/cjs/src/api/logger-subscriber/service/__mocks__/ConsoleLogger.js.map +2 -2
- package/lib/cjs/src/api/transport/model/DeviceApduSender.js +2 -0
- package/lib/cjs/src/api/transport/model/DeviceApduSender.js.map +7 -0
- package/lib/cjs/src/api/transport/model/DeviceConnectionFactory.stub.js +1 -1
- package/lib/cjs/src/api/transport/model/DeviceConnectionFactory.stub.js.map +2 -2
- package/lib/cjs/src/api/transport/model/DeviceConnectionStateMachine.js +2 -0
- package/lib/cjs/src/api/transport/model/DeviceConnectionStateMachine.js.map +7 -0
- package/lib/cjs/src/api/transport/model/DiscoveredDevice.js +1 -1
- package/lib/cjs/src/api/transport/model/DiscoveredDevice.js.map +1 -1
- 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/transport/model/TransportConnectedDevice.stub.js +1 -1
- package/lib/cjs/src/api/transport/model/TransportConnectedDevice.stub.js.map +2 -2
- package/lib/cjs/src/api/transport/model/TransportDiscoveredDevice.js +1 -1
- package/lib/cjs/src/api/transport/model/TransportDiscoveredDevice.js.map +1 -1
- package/lib/cjs/src/api/transport/model/__mocks__/TransportMock.js +1 -1
- package/lib/cjs/src/api/transport/model/__mocks__/TransportMock.js.map +2 -2
- package/lib/cjs/src/api/types.js.map +1 -1
- package/lib/cjs/src/api/utils/Base64String.test.js +1 -1
- package/lib/cjs/src/api/utils/Base64String.test.js.map +2 -2
- package/lib/cjs/src/di.js +1 -1
- package/lib/cjs/src/di.js.map +3 -3
- package/lib/cjs/src/di.stub.js +1 -1
- package/lib/cjs/src/di.stub.js.map +2 -2
- package/lib/cjs/src/internal/config/data/LocalConfigDataSource.test.js +1 -1
- package/lib/cjs/src/internal/config/data/LocalConfigDataSource.test.js.map +3 -3
- package/lib/cjs/src/internal/config/data/RemoteConfigDataSource.test.js +1 -1
- package/lib/cjs/src/internal/config/data/RemoteConfigDataSource.test.js.map +2 -2
- package/lib/cjs/src/internal/config/data/__mocks__/LocalConfigDataSource.js +1 -1
- package/lib/cjs/src/internal/config/data/__mocks__/LocalConfigDataSource.js.map +2 -2
- package/lib/cjs/src/internal/config/data/__mocks__/RemoteConfigDataSource.js +1 -1
- package/lib/cjs/src/internal/config/data/__mocks__/RemoteConfigDataSource.js.map +2 -2
- package/lib/cjs/src/internal/config/service/DefaultConfigService.test.js +1 -1
- package/lib/cjs/src/internal/config/service/DefaultConfigService.test.js.map +2 -2
- package/lib/cjs/src/internal/config/use-case/GetDmkVersionUseCase.test.js +1 -1
- package/lib/cjs/src/internal/config/use-case/GetDmkVersionUseCase.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.stub.js +1 -1
- package/lib/cjs/src/internal/device-session/model/DeviceSession.stub.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/service/DefaultApduReceiverService.test.js +1 -1
- package/lib/cjs/src/internal/device-session/service/DefaultApduReceiverService.test.js.map +2 -2
- package/lib/cjs/src/internal/device-session/service/DefaultApduSenderService.test.js +1 -1
- package/lib/cjs/src/internal/device-session/service/DefaultApduSenderService.test.js.map +2 -2
- package/lib/cjs/src/internal/device-session/service/DefaultDeviceSessionService.test.js +1 -1
- package/lib/cjs/src/internal/device-session/service/DefaultDeviceSessionService.test.js.map +3 -3
- package/lib/cjs/src/internal/device-session/use-case/CloseSessionsUseCase.js +1 -1
- package/lib/cjs/src/internal/device-session/use-case/CloseSessionsUseCase.js.map +3 -3
- package/lib/cjs/src/internal/device-session/use-case/CloseSessionsUseCase.test.js +1 -1
- package/lib/cjs/src/internal/device-session/use-case/CloseSessionsUseCase.test.js.map +3 -3
- package/lib/cjs/src/internal/device-session/use-case/GetDeviceSessionStateUseCase.test.js +1 -1
- package/lib/cjs/src/internal/device-session/use-case/GetDeviceSessionStateUseCase.test.js.map +3 -3
- package/lib/cjs/src/internal/discovery/di/discoveryModule.test.js +1 -1
- package/lib/cjs/src/internal/discovery/di/discoveryModule.test.js.map +3 -3
- package/lib/cjs/src/internal/discovery/use-case/ConnectUseCase.js +1 -1
- package/lib/cjs/src/internal/discovery/use-case/ConnectUseCase.js.map +3 -3
- 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/discovery/use-case/DisconnectUseCase.test.js +1 -1
- package/lib/cjs/src/internal/discovery/use-case/DisconnectUseCase.test.js.map +3 -3
- package/lib/cjs/src/internal/discovery/use-case/GetConnectedDeviceUseCase.test.js +1 -1
- package/lib/cjs/src/internal/discovery/use-case/GetConnectedDeviceUseCase.test.js.map +3 -3
- package/lib/cjs/src/internal/discovery/use-case/ListConnectedDevicesUseCase.test.js +1 -1
- package/lib/cjs/src/internal/discovery/use-case/ListConnectedDevicesUseCase.test.js.map +3 -3
- package/lib/cjs/src/internal/discovery/use-case/ListenToConnectedDeviceUseCase.test.js +1 -1
- package/lib/cjs/src/internal/discovery/use-case/ListenToConnectedDeviceUseCase.test.js.map +3 -3
- package/lib/cjs/src/internal/discovery/use-case/ListenToKnownDevicesUseCase.js +1 -1
- package/lib/cjs/src/internal/discovery/use-case/ListenToKnownDevicesUseCase.js.map +3 -3
- package/lib/cjs/src/internal/discovery/use-case/ListenToKnownDevicesUseCase.test.js +1 -1
- package/lib/cjs/src/internal/discovery/use-case/ListenToKnownDevicesUseCase.test.js.map +3 -3
- package/lib/cjs/src/internal/discovery/use-case/StartDiscoveringUseCase.js +1 -1
- package/lib/cjs/src/internal/discovery/use-case/StartDiscoveringUseCase.js.map +2 -2
- package/lib/cjs/src/internal/discovery/use-case/StartDiscoveringUseCase.test.js +1 -1
- package/lib/cjs/src/internal/discovery/use-case/StartDiscoveringUseCase.test.js.map +3 -3
- package/lib/cjs/src/internal/discovery/use-case/StopDiscoveringUseCase.test.js +1 -1
- package/lib/cjs/src/internal/discovery/use-case/StopDiscoveringUseCase.test.js.map +2 -2
- package/lib/cjs/src/internal/logger-publisher/service/DefaultLoggerPublisherService.stub.js +1 -1
- package/lib/cjs/src/internal/logger-publisher/service/DefaultLoggerPublisherService.stub.js.map +2 -2
- package/lib/cjs/src/internal/logger-publisher/service/DefaultLoggerPublisherService.test.js +1 -1
- package/lib/cjs/src/internal/logger-publisher/service/DefaultLoggerPublisherService.test.js.map +2 -2
- package/lib/cjs/src/internal/manager-api/data/AxiosManagerApiDataSource.js +1 -1
- package/lib/cjs/src/internal/manager-api/data/AxiosManagerApiDataSource.js.map +3 -3
- package/lib/cjs/src/internal/manager-api/data/AxiosManagerApiDataSource.test.js +1 -1
- package/lib/cjs/src/internal/manager-api/data/AxiosManagerApiDataSource.test.js.map +3 -3
- package/lib/cjs/src/internal/manager-api/data/ManagerApiDataSource.js +1 -1
- package/lib/cjs/src/internal/manager-api/data/ManagerApiDataSource.js.map +1 -1
- package/lib/cjs/src/internal/manager-api/data/__mocks__/AxiosManagerApiDataSource.js +1 -1
- package/lib/cjs/src/internal/manager-api/data/__mocks__/AxiosManagerApiDataSource.js.map +2 -2
- package/lib/cjs/src/internal/manager-api/model/Const.js +1 -1
- package/lib/cjs/src/internal/manager-api/model/Const.js.map +3 -3
- package/lib/cjs/src/internal/manager-api/model/Errors.js +1 -1
- package/lib/cjs/src/internal/manager-api/model/Errors.js.map +3 -3
- package/lib/cjs/src/internal/manager-api/model/Firmware.js +1 -1
- package/lib/cjs/src/internal/manager-api/model/Firmware.js.map +1 -1
- package/lib/cjs/src/internal/manager-api/service/DefaultManagerApiService.js +1 -1
- package/lib/cjs/src/internal/manager-api/service/DefaultManagerApiService.js.map +2 -2
- package/lib/cjs/src/internal/manager-api/service/DefaultManagerApiService.test.js +1 -1
- package/lib/cjs/src/internal/manager-api/service/DefaultManagerApiService.test.js.map +2 -2
- package/lib/cjs/src/internal/secure-channel/data/DefaultSecureChannelDataSource.js +2 -0
- package/lib/cjs/src/internal/secure-channel/data/DefaultSecureChannelDataSource.js.map +7 -0
- package/lib/cjs/src/internal/secure-channel/data/DefaultSecureChannelDataSource.test.js +2 -0
- package/lib/cjs/src/internal/secure-channel/data/DefaultSecureChannelDataSource.test.js.map +7 -0
- package/lib/cjs/src/internal/secure-channel/data/SecureChannelDataSource.js +2 -0
- package/lib/cjs/src/internal/secure-channel/data/SecureChannelDataSource.js.map +7 -0
- package/lib/cjs/src/internal/secure-channel/data/__mocks__/DefaultSecureChannelDataSource.js +2 -0
- package/lib/cjs/src/internal/secure-channel/data/__mocks__/DefaultSecureChannelDataSource.js.map +7 -0
- package/lib/cjs/src/internal/secure-channel/di/secureChannelModule.js +2 -0
- package/lib/cjs/src/internal/secure-channel/di/secureChannelModule.js.map +7 -0
- package/lib/cjs/src/internal/secure-channel/di/secureChannelModule.test.js +2 -0
- package/lib/cjs/src/internal/secure-channel/di/secureChannelModule.test.js.map +7 -0
- package/lib/cjs/src/internal/secure-channel/di/secureChannelTypes.js +2 -0
- package/lib/cjs/src/internal/secure-channel/di/secureChannelTypes.js.map +7 -0
- package/lib/cjs/src/internal/secure-channel/model/Const.js +2 -0
- package/lib/cjs/src/internal/secure-channel/model/Const.js.map +7 -0
- package/lib/cjs/src/internal/secure-channel/model/Errors.js +2 -0
- package/lib/cjs/src/internal/secure-channel/model/Errors.js.map +7 -0
- package/lib/cjs/src/internal/{manager-api → secure-channel}/model/Params.js.map +1 -1
- package/lib/cjs/src/internal/secure-channel/service/DefaultSecureChannelService.js +2 -0
- package/lib/cjs/src/internal/secure-channel/service/DefaultSecureChannelService.js.map +7 -0
- package/lib/cjs/src/internal/secure-channel/service/DefaultSecureChannelService.test.js +2 -0
- package/lib/cjs/src/internal/secure-channel/service/DefaultSecureChannelService.test.js.map +7 -0
- package/lib/cjs/src/internal/secure-channel/service/SecureChannelService.js +2 -0
- package/lib/cjs/src/internal/secure-channel/service/SecureChannelService.js.map +7 -0
- 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/cjs/src/internal/transport/di/transportModule.test.js +1 -1
- package/lib/cjs/src/internal/transport/di/transportModule.test.js.map +2 -2
- package/lib/cjs/src/internal/transport/service/DefaultTransportService.js +1 -1
- package/lib/cjs/src/internal/transport/service/DefaultTransportService.js.map +3 -3
- package/lib/cjs/src/internal/transport/service/DefaultTransportService.test.js +1 -1
- package/lib/cjs/src/internal/transport/service/DefaultTransportService.test.js.map +2 -2
- package/lib/cjs/src/internal/transport/service/TransportService.js +1 -1
- package/lib/cjs/src/internal/transport/service/TransportService.js.map +1 -1
- package/lib/cjs/src/internal/transport/service/__mocks__/DefaultTransportService.js +1 -1
- package/lib/cjs/src/internal/transport/service/__mocks__/DefaultTransportService.js.map +2 -2
- package/lib/esm/package.json +6 -5
- package/lib/esm/src/api/DeviceManagementKit.test.js +1 -1
- package/lib/esm/src/api/DeviceManagementKit.test.js.map +2 -2
- package/lib/esm/src/api/DeviceManagementKitBuilder.js +1 -1
- package/lib/esm/src/api/DeviceManagementKitBuilder.js.map +2 -2
- package/lib/esm/src/api/DeviceManagementKitBuilder.test.js +1 -1
- package/lib/esm/src/api/DeviceManagementKitBuilder.test.js.map +2 -2
- package/lib/esm/src/api/apdu/utils/ByteArrayParser.test.js +1 -1
- package/lib/esm/src/api/apdu/utils/ByteArrayParser.test.js.map +2 -2
- package/lib/esm/src/api/command/os/LoadCertificateCommand.js +2 -0
- package/lib/esm/src/api/command/os/LoadCertificateCommand.js.map +7 -0
- package/lib/esm/src/api/command/os/LoadCertificateCommand.test.js +2 -0
- package/lib/esm/src/api/command/os/LoadCertificateCommand.test.js.map +7 -0
- package/lib/esm/src/api/command/use-case/SendCommandUseCase.test.js +1 -1
- package/lib/esm/src/api/command/use-case/SendCommandUseCase.test.js.map +3 -3
- package/lib/esm/src/api/command/utils/CommandUtils.js +1 -1
- package/lib/esm/src/api/command/utils/CommandUtils.js.map +3 -3
- package/lib/esm/src/api/command/utils/CommandUtils.test.js +1 -1
- package/lib/esm/src/api/command/utils/CommandUtils.test.js.map +3 -3
- 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 +2 -2
- package/lib/esm/src/api/device-action/__test-utils__/testDeviceActionStates.js +1 -1
- package/lib/esm/src/api/device-action/__test-utils__/testDeviceActionStates.js.map +3 -3
- package/lib/esm/src/api/device-action/os/CallTaskInAppDeviceAction/CallTaskInAppDeviceAction.js +2 -0
- package/lib/esm/src/api/device-action/os/CallTaskInAppDeviceAction/CallTaskInAppDeviceAction.js.map +7 -0
- package/lib/esm/src/api/device-action/os/CallTaskInAppDeviceAction/CallTaskInAppDeviceAction.test.js +2 -0
- package/lib/esm/src/api/device-action/os/CallTaskInAppDeviceAction/CallTaskInAppDeviceAction.test.js.map +7 -0
- package/lib/esm/src/api/device-action/os/CallTaskInAppDeviceAction/CallTaskInAppDeviceActionTypes.js +1 -0
- 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/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/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/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/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/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-session/use-case/ToggleDeviceSessionRefresher.test.js +1 -1
- package/lib/esm/src/api/device-session/use-case/ToggleDeviceSessionRefresher.test.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-subscriber/service/ConsoleLogger.test.js +1 -1
- package/lib/esm/src/api/logger-subscriber/service/ConsoleLogger.test.js.map +2 -2
- 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 +2 -2
- package/lib/esm/src/api/logger-subscriber/service/__mocks__/ConsoleLogger.js +1 -1
- package/lib/esm/src/api/logger-subscriber/service/__mocks__/ConsoleLogger.js.map +2 -2
- package/lib/esm/src/api/transport/model/DeviceApduSender.js +1 -0
- package/lib/esm/src/api/transport/model/DeviceApduSender.js.map +7 -0
- package/lib/esm/src/api/transport/model/DeviceConnectionFactory.stub.js +1 -1
- package/lib/esm/src/api/transport/model/DeviceConnectionFactory.stub.js.map +2 -2
- package/lib/esm/src/api/transport/model/DeviceConnectionStateMachine.js +2 -0
- package/lib/esm/src/api/transport/model/DeviceConnectionStateMachine.js.map +7 -0
- 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/transport/model/TransportConnectedDevice.stub.js +1 -1
- package/lib/esm/src/api/transport/model/TransportConnectedDevice.stub.js.map +2 -2
- package/lib/esm/src/api/transport/model/__mocks__/TransportMock.js +1 -1
- package/lib/esm/src/api/transport/model/__mocks__/TransportMock.js.map +2 -2
- package/lib/esm/src/api/utils/Base64String.test.js +1 -1
- package/lib/esm/src/api/utils/Base64String.test.js.map +2 -2
- package/lib/esm/src/di.js +1 -1
- package/lib/esm/src/di.js.map +3 -3
- package/lib/esm/src/di.stub.js +1 -1
- package/lib/esm/src/di.stub.js.map +2 -2
- package/lib/esm/src/internal/config/data/LocalConfigDataSource.test.js +1 -1
- package/lib/esm/src/internal/config/data/LocalConfigDataSource.test.js.map +3 -3
- package/lib/esm/src/internal/config/data/RemoteConfigDataSource.test.js +1 -1
- package/lib/esm/src/internal/config/data/RemoteConfigDataSource.test.js.map +2 -2
- package/lib/esm/src/internal/config/data/__mocks__/LocalConfigDataSource.js +1 -1
- package/lib/esm/src/internal/config/data/__mocks__/LocalConfigDataSource.js.map +2 -2
- package/lib/esm/src/internal/config/data/__mocks__/RemoteConfigDataSource.js +1 -1
- package/lib/esm/src/internal/config/data/__mocks__/RemoteConfigDataSource.js.map +2 -2
- package/lib/esm/src/internal/config/service/DefaultConfigService.test.js +1 -1
- package/lib/esm/src/internal/config/service/DefaultConfigService.test.js.map +2 -2
- package/lib/esm/src/internal/config/use-case/GetDmkVersionUseCase.test.js +1 -1
- package/lib/esm/src/internal/config/use-case/GetDmkVersionUseCase.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.stub.js +1 -1
- package/lib/esm/src/internal/device-session/model/DeviceSession.stub.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/service/DefaultApduReceiverService.test.js +1 -1
- package/lib/esm/src/internal/device-session/service/DefaultApduReceiverService.test.js.map +2 -2
- package/lib/esm/src/internal/device-session/service/DefaultApduSenderService.test.js +1 -1
- package/lib/esm/src/internal/device-session/service/DefaultApduSenderService.test.js.map +2 -2
- package/lib/esm/src/internal/device-session/service/DefaultDeviceSessionService.test.js +1 -1
- package/lib/esm/src/internal/device-session/service/DefaultDeviceSessionService.test.js.map +3 -3
- package/lib/esm/src/internal/device-session/use-case/CloseSessionsUseCase.js +1 -1
- package/lib/esm/src/internal/device-session/use-case/CloseSessionsUseCase.js.map +3 -3
- package/lib/esm/src/internal/device-session/use-case/CloseSessionsUseCase.test.js +1 -1
- package/lib/esm/src/internal/device-session/use-case/CloseSessionsUseCase.test.js.map +3 -3
- package/lib/esm/src/internal/device-session/use-case/GetDeviceSessionStateUseCase.test.js +1 -1
- package/lib/esm/src/internal/device-session/use-case/GetDeviceSessionStateUseCase.test.js.map +3 -3
- package/lib/esm/src/internal/discovery/di/discoveryModule.test.js +1 -1
- package/lib/esm/src/internal/discovery/di/discoveryModule.test.js.map +3 -3
- package/lib/esm/src/internal/discovery/use-case/ConnectUseCase.js +1 -1
- package/lib/esm/src/internal/discovery/use-case/ConnectUseCase.js.map +3 -3
- 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/discovery/use-case/DisconnectUseCase.test.js +1 -1
- package/lib/esm/src/internal/discovery/use-case/DisconnectUseCase.test.js.map +3 -3
- package/lib/esm/src/internal/discovery/use-case/GetConnectedDeviceUseCase.test.js +1 -1
- package/lib/esm/src/internal/discovery/use-case/GetConnectedDeviceUseCase.test.js.map +3 -3
- package/lib/esm/src/internal/discovery/use-case/ListConnectedDevicesUseCase.test.js +1 -1
- package/lib/esm/src/internal/discovery/use-case/ListConnectedDevicesUseCase.test.js.map +3 -3
- package/lib/esm/src/internal/discovery/use-case/ListenToConnectedDeviceUseCase.test.js +1 -1
- package/lib/esm/src/internal/discovery/use-case/ListenToConnectedDeviceUseCase.test.js.map +3 -3
- package/lib/esm/src/internal/discovery/use-case/ListenToKnownDevicesUseCase.js +1 -1
- package/lib/esm/src/internal/discovery/use-case/ListenToKnownDevicesUseCase.js.map +3 -3
- package/lib/esm/src/internal/discovery/use-case/ListenToKnownDevicesUseCase.test.js +1 -1
- package/lib/esm/src/internal/discovery/use-case/ListenToKnownDevicesUseCase.test.js.map +3 -3
- package/lib/esm/src/internal/discovery/use-case/StartDiscoveringUseCase.js +1 -1
- package/lib/esm/src/internal/discovery/use-case/StartDiscoveringUseCase.js.map +2 -2
- package/lib/esm/src/internal/discovery/use-case/StartDiscoveringUseCase.test.js +1 -1
- package/lib/esm/src/internal/discovery/use-case/StartDiscoveringUseCase.test.js.map +3 -3
- package/lib/esm/src/internal/discovery/use-case/StopDiscoveringUseCase.test.js +1 -1
- package/lib/esm/src/internal/discovery/use-case/StopDiscoveringUseCase.test.js.map +2 -2
- package/lib/esm/src/internal/logger-publisher/service/DefaultLoggerPublisherService.stub.js +1 -1
- package/lib/esm/src/internal/logger-publisher/service/DefaultLoggerPublisherService.stub.js.map +2 -2
- package/lib/esm/src/internal/logger-publisher/service/DefaultLoggerPublisherService.test.js +1 -1
- package/lib/esm/src/internal/logger-publisher/service/DefaultLoggerPublisherService.test.js.map +2 -2
- package/lib/esm/src/internal/manager-api/data/AxiosManagerApiDataSource.js +1 -1
- package/lib/esm/src/internal/manager-api/data/AxiosManagerApiDataSource.js.map +3 -3
- package/lib/esm/src/internal/manager-api/data/AxiosManagerApiDataSource.test.js +1 -1
- package/lib/esm/src/internal/manager-api/data/AxiosManagerApiDataSource.test.js.map +3 -3
- package/lib/esm/src/internal/manager-api/data/__mocks__/AxiosManagerApiDataSource.js +1 -1
- package/lib/esm/src/internal/manager-api/data/__mocks__/AxiosManagerApiDataSource.js.map +2 -2
- package/lib/esm/src/internal/manager-api/model/Const.js +1 -1
- package/lib/esm/src/internal/manager-api/model/Const.js.map +3 -3
- package/lib/esm/src/internal/manager-api/model/Errors.js +1 -1
- package/lib/esm/src/internal/manager-api/model/Errors.js.map +3 -3
- package/lib/esm/src/internal/manager-api/service/DefaultManagerApiService.js +1 -1
- package/lib/esm/src/internal/manager-api/service/DefaultManagerApiService.js.map +2 -2
- package/lib/esm/src/internal/manager-api/service/DefaultManagerApiService.test.js +1 -1
- package/lib/esm/src/internal/manager-api/service/DefaultManagerApiService.test.js.map +2 -2
- package/lib/esm/src/internal/secure-channel/data/DefaultSecureChannelDataSource.js +2 -0
- package/lib/esm/src/internal/secure-channel/data/DefaultSecureChannelDataSource.js.map +7 -0
- package/lib/esm/src/internal/secure-channel/data/DefaultSecureChannelDataSource.test.js +2 -0
- package/lib/esm/src/internal/secure-channel/data/DefaultSecureChannelDataSource.test.js.map +7 -0
- package/lib/esm/src/internal/secure-channel/data/SecureChannelDataSource.js +1 -0
- package/lib/esm/src/internal/secure-channel/data/SecureChannelDataSource.js.map +7 -0
- package/lib/esm/src/internal/secure-channel/data/__mocks__/DefaultSecureChannelDataSource.js +2 -0
- package/lib/esm/src/internal/secure-channel/data/__mocks__/DefaultSecureChannelDataSource.js.map +7 -0
- package/lib/esm/src/internal/secure-channel/di/secureChannelModule.js +2 -0
- package/lib/esm/src/internal/secure-channel/di/secureChannelModule.js.map +7 -0
- package/lib/esm/src/internal/secure-channel/di/secureChannelModule.test.js +2 -0
- package/lib/esm/src/internal/secure-channel/di/secureChannelModule.test.js.map +7 -0
- package/lib/esm/src/internal/secure-channel/di/secureChannelTypes.js +2 -0
- package/lib/esm/src/internal/secure-channel/di/secureChannelTypes.js.map +7 -0
- package/lib/esm/src/internal/secure-channel/model/Const.js +2 -0
- package/lib/esm/src/internal/secure-channel/model/Const.js.map +7 -0
- package/lib/esm/src/internal/secure-channel/model/Errors.js +2 -0
- package/lib/esm/src/internal/secure-channel/model/Errors.js.map +7 -0
- package/lib/esm/src/internal/secure-channel/model/Params.js.map +7 -0
- package/lib/esm/src/internal/secure-channel/service/DefaultSecureChannelService.js +2 -0
- package/lib/esm/src/internal/secure-channel/service/DefaultSecureChannelService.js.map +7 -0
- package/lib/esm/src/internal/secure-channel/service/DefaultSecureChannelService.test.js +2 -0
- package/lib/esm/src/internal/secure-channel/service/DefaultSecureChannelService.test.js.map +7 -0
- package/lib/esm/src/internal/secure-channel/service/SecureChannelService.js +1 -0
- package/lib/esm/src/internal/secure-channel/service/SecureChannelService.js.map +7 -0
- 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/esm/src/internal/transport/di/transportModule.test.js +1 -1
- package/lib/esm/src/internal/transport/di/transportModule.test.js.map +2 -2
- package/lib/esm/src/internal/transport/service/DefaultTransportService.js +1 -1
- package/lib/esm/src/internal/transport/service/DefaultTransportService.js.map +3 -3
- package/lib/esm/src/internal/transport/service/DefaultTransportService.test.js +1 -1
- package/lib/esm/src/internal/transport/service/DefaultTransportService.test.js.map +2 -2
- package/lib/esm/src/internal/transport/service/__mocks__/DefaultTransportService.js +1 -1
- package/lib/esm/src/internal/transport/service/__mocks__/DefaultTransportService.js.map +2 -2
- package/lib/types/src/api/DeviceManagementKit.d.ts +1 -1
- package/lib/types/src/api/command/os/LoadCertificateCommand.d.ts +25 -0
- package/lib/types/src/api/command/os/LoadCertificateCommand.d.ts.map +1 -0
- package/lib/types/src/api/command/os/LoadCertificateCommand.test.d.ts +2 -0
- package/lib/types/src/api/command/os/LoadCertificateCommand.test.d.ts.map +1 -0
- package/lib/types/src/api/command/utils/CommandUtils.d.ts +1 -0
- package/lib/types/src/api/command/utils/CommandUtils.d.ts.map +1 -1
- package/lib/types/src/api/device-action/DeviceAction.d.ts +5 -0
- 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 +2 -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/__test-utils__/testDeviceActionStates.d.ts +5 -2
- package/lib/types/src/api/device-action/__test-utils__/testDeviceActionStates.d.ts.map +1 -1
- package/lib/types/src/api/device-action/os/CallTaskInAppDeviceAction/CallTaskInAppDeviceAction.d.ts +40 -0
- package/lib/types/src/api/device-action/os/CallTaskInAppDeviceAction/CallTaskInAppDeviceAction.d.ts.map +1 -0
- package/lib/types/src/api/device-action/os/CallTaskInAppDeviceAction/CallTaskInAppDeviceAction.test.d.ts +2 -0
- package/lib/types/src/api/device-action/os/CallTaskInAppDeviceAction/CallTaskInAppDeviceAction.test.d.ts.map +1 -0
- package/lib/types/src/api/device-action/os/CallTaskInAppDeviceAction/CallTaskInAppDeviceActionTypes.d.ts +19 -0
- package/lib/types/src/api/device-action/os/CallTaskInAppDeviceAction/CallTaskInAppDeviceActionTypes.d.ts.map +1 -0
- package/lib/types/src/api/index.d.ts +3 -0
- package/lib/types/src/api/index.d.ts.map +1 -1
- package/lib/types/src/api/logger-subscriber/service/__mocks__/ConsoleLogger.d.ts +1 -1
- package/lib/types/src/api/logger-subscriber/service/__mocks__/ConsoleLogger.d.ts.map +1 -1
- package/lib/types/src/api/transport/model/DeviceApduSender.d.ts +17 -0
- package/lib/types/src/api/transport/model/DeviceApduSender.d.ts.map +1 -0
- package/lib/types/src/api/transport/model/DeviceConnectionFactory.stub.d.ts +1 -1
- package/lib/types/src/api/transport/model/DeviceConnectionFactory.stub.d.ts.map +1 -1
- package/lib/types/src/api/transport/model/DeviceConnectionStateMachine.d.ts +60 -0
- package/lib/types/src/api/transport/model/DeviceConnectionStateMachine.d.ts.map +1 -0
- package/lib/types/src/api/transport/model/DiscoveredDevice.d.ts +2 -0
- package/lib/types/src/api/transport/model/DiscoveredDevice.d.ts.map +1 -1
- package/lib/types/src/api/transport/model/Errors.d.ts +15 -0
- package/lib/types/src/api/transport/model/Errors.d.ts.map +1 -1
- package/lib/types/src/api/transport/model/TransportDiscoveredDevice.d.ts +2 -0
- package/lib/types/src/api/transport/model/TransportDiscoveredDevice.d.ts.map +1 -1
- package/lib/types/src/api/transport/model/__mocks__/TransportMock.d.ts +7 -7
- package/lib/types/src/api/transport/model/__mocks__/TransportMock.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/di.d.ts.map +1 -1
- package/lib/types/src/di.stub.d.ts +1 -1
- package/lib/types/src/di.stub.d.ts.map +1 -1
- package/lib/types/src/internal/config/data/__mocks__/LocalConfigDataSource.d.ts +1 -1
- package/lib/types/src/internal/config/data/__mocks__/LocalConfigDataSource.d.ts.map +1 -1
- package/lib/types/src/internal/config/data/__mocks__/RemoteConfigDataSource.d.ts +3 -3
- package/lib/types/src/internal/config/data/__mocks__/RemoteConfigDataSource.d.ts.map +1 -1
- package/lib/types/src/internal/device-session/model/DeviceSession.d.ts +10 -5
- package/lib/types/src/internal/device-session/model/DeviceSession.d.ts.map +1 -1
- package/lib/types/src/internal/device-session/model/DeviceSession.stub.d.ts +2 -1
- package/lib/types/src/internal/device-session/model/DeviceSession.stub.d.ts.map +1 -1
- package/lib/types/src/internal/device-session/use-case/CloseSessionsUseCase.d.ts +4 -2
- package/lib/types/src/internal/device-session/use-case/CloseSessionsUseCase.d.ts.map +1 -1
- package/lib/types/src/internal/discovery/use-case/ConnectUseCase.d.ts +3 -1
- package/lib/types/src/internal/discovery/use-case/ConnectUseCase.d.ts.map +1 -1
- package/lib/types/src/internal/discovery/use-case/ListenToKnownDevicesUseCase.d.ts.map +1 -1
- package/lib/types/src/internal/discovery/use-case/StartDiscoveringUseCase.d.ts.map +1 -1
- package/lib/types/src/internal/logger-publisher/service/DefaultLoggerPublisherService.stub.d.ts +5 -5
- package/lib/types/src/internal/logger-publisher/service/DefaultLoggerPublisherService.stub.d.ts.map +1 -1
- package/lib/types/src/internal/manager-api/data/AxiosManagerApiDataSource.d.ts +2 -11
- package/lib/types/src/internal/manager-api/data/AxiosManagerApiDataSource.d.ts.map +1 -1
- package/lib/types/src/internal/manager-api/data/ManagerApiDataSource.d.ts +2 -46
- package/lib/types/src/internal/manager-api/data/ManagerApiDataSource.d.ts.map +1 -1
- package/lib/types/src/internal/manager-api/data/__mocks__/AxiosManagerApiDataSource.d.ts +3 -9
- package/lib/types/src/internal/manager-api/data/__mocks__/AxiosManagerApiDataSource.d.ts.map +1 -1
- package/lib/types/src/internal/manager-api/model/Const.d.ts +0 -1
- package/lib/types/src/internal/manager-api/model/Const.d.ts.map +1 -1
- package/lib/types/src/internal/manager-api/model/Errors.d.ts +0 -6
- package/lib/types/src/internal/manager-api/model/Errors.d.ts.map +1 -1
- package/lib/types/src/internal/manager-api/model/Firmware.d.ts +4 -0
- package/lib/types/src/internal/manager-api/model/Firmware.d.ts.map +1 -1
- package/lib/types/src/internal/manager-api/service/DefaultManagerApiService.d.ts.map +1 -1
- package/lib/types/src/internal/secure-channel/data/DefaultSecureChannelDataSource.d.ts +18 -0
- package/lib/types/src/internal/secure-channel/data/DefaultSecureChannelDataSource.d.ts.map +1 -0
- package/lib/types/src/internal/secure-channel/data/DefaultSecureChannelDataSource.test.d.ts +2 -0
- package/lib/types/src/internal/secure-channel/data/DefaultSecureChannelDataSource.test.d.ts.map +1 -0
- package/lib/types/src/internal/secure-channel/data/SecureChannelDataSource.d.ts +52 -0
- package/lib/types/src/internal/secure-channel/data/SecureChannelDataSource.d.ts.map +1 -0
- package/lib/types/src/internal/secure-channel/data/__mocks__/DefaultSecureChannelDataSource.d.ts +10 -0
- package/lib/types/src/internal/secure-channel/data/__mocks__/DefaultSecureChannelDataSource.d.ts.map +1 -0
- package/lib/types/src/internal/secure-channel/di/secureChannelModule.d.ts +9 -0
- package/lib/types/src/internal/secure-channel/di/secureChannelModule.d.ts.map +1 -0
- package/lib/types/src/internal/secure-channel/di/secureChannelModule.test.d.ts +2 -0
- package/lib/types/src/internal/secure-channel/di/secureChannelModule.test.d.ts.map +1 -0
- package/lib/types/src/internal/secure-channel/di/secureChannelTypes.d.ts +6 -0
- package/lib/types/src/internal/secure-channel/di/secureChannelTypes.d.ts.map +1 -0
- package/lib/types/src/internal/secure-channel/model/Const.d.ts +2 -0
- package/lib/types/src/internal/secure-channel/model/Const.d.ts.map +1 -0
- package/lib/types/src/internal/secure-channel/model/Errors.d.ts +8 -0
- package/lib/types/src/internal/secure-channel/model/Errors.d.ts.map +1 -0
- package/lib/types/src/internal/secure-channel/model/Params.d.ts.map +1 -0
- package/lib/types/src/internal/secure-channel/service/DefaultSecureChannelService.d.ts +20 -0
- package/lib/types/src/internal/secure-channel/service/DefaultSecureChannelService.d.ts.map +1 -0
- package/lib/types/src/internal/secure-channel/service/DefaultSecureChannelService.test.d.ts +2 -0
- package/lib/types/src/internal/secure-channel/service/DefaultSecureChannelService.test.d.ts.map +1 -0
- package/lib/types/src/internal/secure-channel/service/SecureChannelService.d.ts +20 -0
- package/lib/types/src/internal/secure-channel/service/SecureChannelService.d.ts.map +1 -0
- package/lib/types/src/internal/transport/service/DefaultTransportService.d.ts +2 -0
- package/lib/types/src/internal/transport/service/DefaultTransportService.d.ts.map +1 -1
- package/lib/types/src/internal/transport/service/TransportService.d.ts +2 -0
- package/lib/types/src/internal/transport/service/TransportService.d.ts.map +1 -1
- package/lib/types/src/internal/transport/service/__mocks__/DefaultTransportService.d.ts +7 -6
- package/lib/types/src/internal/transport/service/__mocks__/DefaultTransportService.d.ts.map +1 -1
- package/lib/types/tsconfig.prod.tsbuildinfo +1 -1
- package/package.json +8 -7
- package/lib/types/src/internal/manager-api/model/Params.d.ts.map +0 -1
- /package/lib/cjs/src/internal/{manager-api → secure-channel}/model/Params.js +0 -0
- /package/lib/esm/src/{internal/manager-api/model/Params.js.map → api/device-action/os/CallTaskInAppDeviceAction/CallTaskInAppDeviceActionTypes.js.map} +0 -0
- /package/lib/esm/src/internal/{manager-api → secure-channel}/model/Params.js +0 -0
- /package/lib/types/src/internal/{manager-api → secure-channel}/model/Params.d.ts +0 -0
@@ -1,7 +1,7 @@
|
|
1
1
|
{
|
2
2
|
"version": 3,
|
3
3
|
"sources": ["../../../../../../src/api/command/utils/CommandUtils.test.ts"],
|
4
|
-
"sourcesContent": ["import { ApduResponse } from \"@api/device-session/ApduResponse\";\n\nimport { CommandUtils } from \"./CommandUtils\";\n\ndescribe(\"CommandUtils\", () => {\n describe(\"static isSuccessResponse\", () => {\n it(\"should return true if the status code is 0x9000\", () => {\n const response = new ApduResponse({\n statusCode: Uint8Array.from([0x90, 0x00]),\n data: Uint8Array.from([]),\n });\n\n expect(CommandUtils.isSuccessResponse(response)).toBe(true);\n });\n\n it(\"should return false if the status code is not 0x9000\", () => {\n const response = new ApduResponse({\n statusCode: Uint8Array.from([0x6e, 0x80]),\n data: Uint8Array.from([]),\n });\n\n expect(CommandUtils.isSuccessResponse(response)).toBe(false);\n });\n\n it(\"should return false if the status code is not 2 bytes long\", () => {\n const response = new ApduResponse({\n statusCode: Uint8Array.from([0x55]),\n data: Uint8Array.from([]),\n });\n\n expect(CommandUtils.isSuccessResponse(response)).toBe(false);\n });\n });\n\n describe(\"static isValidStatusCode\", () => {\n it(\"should return true if the status code is 2 bytes long\", () => {\n const statusCode = Uint8Array.from([0x90, 0x00]);\n\n expect(CommandUtils.isValidStatusCode(statusCode)).toBe(true);\n });\n\n it(\"should return false if the status code is not 2 bytes long\", () => {\n const statusCode = Uint8Array.from([0x90]);\n\n expect(CommandUtils.isValidStatusCode(statusCode)).toBe(false);\n });\n });\n\n describe(\"static isLockedDeviceResponse\", () => {\n it(\"should return true if the status code is 0x5515\", () => {\n const response = new ApduResponse({\n statusCode: Uint8Array.from([0x55, 0x15]),\n data: Uint8Array.from([]),\n });\n\n expect(CommandUtils.isLockedDeviceResponse(response)).toBe(true);\n });\n\n it(\"should return false if the status code is not 0x5515\", () => {\n const response = new ApduResponse({\n statusCode: Uint8Array.from([0x90, 0x00]),\n data: Uint8Array.from([]),\n });\n\n expect(CommandUtils.isLockedDeviceResponse(response)).toBe(false);\n });\n\n it(\"should return false if the status code is not 2 bytes long\", () => {\n const response = new ApduResponse({\n statusCode: Uint8Array.from([0x90]),\n data: Uint8Array.from([]),\n });\n\n expect(CommandUtils.isLockedDeviceResponse(response)).toBe(false);\n });\n });\n});\n"],
|
5
|
-
"mappings": "aAAA,IAAAA,EAA6B,4CAE7BC,EAA6B,0BAE7B,SAAS,eAAgB,IAAM,CAC7B,SAAS,2BAA4B,IAAM,CACzC,GAAG,kDAAmD,IAAM,CAC1D,MAAMC,EAAW,IAAI,eAAa,CAChC,WAAY,WAAW,KAAK,CAAC,IAAM,CAAI,CAAC,EACxC,KAAM,WAAW,KAAK,CAAC,CAAC,CAC1B,CAAC,EAED,OAAO,eAAa,kBAAkBA,CAAQ,CAAC,EAAE,KAAK,EAAI,CAC5D,CAAC,EAED,GAAG,uDAAwD,IAAM,CAC/D,MAAMA,EAAW,IAAI,eAAa,CAChC,WAAY,WAAW,KAAK,CAAC,IAAM,GAAI,CAAC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Y,WAAW,KAAK,CAAC,GAAI,CAAC,EAClC,KAAM,WAAW,KAAK,CAAC,CAAC,CAC1B,CAAC,EAED,OAAO,eAAa,uBAAuBA,CAAQ,CAAC,EAAE,KAAK,EAAK,CAClE,CAAC,CACH,CAAC,CACH,CAAC",
|
6
|
-
"names": ["import_ApduResponse", "import_CommandUtils", "response", "statusCode"]
|
4
|
+
"sourcesContent": ["import { CloseAppCommand } from \"@api/command/os/CloseAppCommand\";\nimport { GetAppAndVersionCommand } from \"@api/command/os/GetAppAndVersionCommand\";\nimport { OpenAppCommand } from \"@api/command/os/OpenAppCommand\";\nimport { ApduResponse } from \"@api/device-session/ApduResponse\";\n\nimport { CommandUtils } from \"./CommandUtils\";\n\ndescribe(\"CommandUtils\", () => {\n describe(\"static isSuccessResponse\", () => {\n it(\"should return true if the status code is 0x9000\", () => {\n const response = new ApduResponse({\n statusCode: Uint8Array.from([0x90, 0x00]),\n data: Uint8Array.from([]),\n });\n\n expect(CommandUtils.isSuccessResponse(response)).toBe(true);\n });\n\n it(\"should return false if the status code is not 0x9000\", () => {\n const response = new ApduResponse({\n statusCode: Uint8Array.from([0x6e, 0x80]),\n data: Uint8Array.from([]),\n });\n\n expect(CommandUtils.isSuccessResponse(response)).toBe(false);\n });\n\n it(\"should return false if the status code is not 2 bytes long\", () => {\n const response = new ApduResponse({\n statusCode: Uint8Array.from([0x55]),\n data: Uint8Array.from([]),\n });\n\n expect(CommandUtils.isSuccessResponse(response)).toBe(false);\n });\n });\n\n describe(\"static isValidStatusCode\", () => {\n it(\"should return true if the status code is 2 bytes long\", () => {\n const statusCode = Uint8Array.from([0x90, 0x00]);\n\n expect(CommandUtils.isValidStatusCode(statusCode)).toBe(true);\n });\n\n it(\"should return false if the status code is not 2 bytes long\", () => {\n const statusCode = Uint8Array.from([0x90]);\n\n expect(CommandUtils.isValidStatusCode(statusCode)).toBe(false);\n });\n });\n\n describe(\"static isLockedDeviceResponse\", () => {\n it(\"should return true if the status code is 0x5515\", () => {\n const response = new ApduResponse({\n statusCode: Uint8Array.from([0x55, 0x15]),\n data: Uint8Array.from([]),\n });\n\n expect(CommandUtils.isLockedDeviceResponse(response)).toBe(true);\n });\n\n it(\"should return false if the status code is not 0x5515\", () => {\n const response = new ApduResponse({\n statusCode: Uint8Array.from([0x90, 0x00]),\n data: Uint8Array.from([]),\n });\n\n expect(CommandUtils.isLockedDeviceResponse(response)).toBe(false);\n });\n\n it(\"should return false if the status code is not 2 bytes long\", () => {\n const response = new ApduResponse({\n statusCode: Uint8Array.from([0x90]),\n data: Uint8Array.from([]),\n });\n\n expect(CommandUtils.isLockedDeviceResponse(response)).toBe(false);\n });\n });\n\n describe(\"static isApduThatTriggersDisconnection\", () => {\n it(\"should return true if the APDU is openApp\", () => {\n const apdu = new OpenAppCommand({ appName: \"test\" })\n .getApdu()\n .getRawApdu();\n\n expect(CommandUtils.isApduThatTriggersDisconnection(apdu)).toBe(true);\n });\n\n it(\"should return true if the APDU is closeApp\", () => {\n const apdu = new CloseAppCommand().getApdu().getRawApdu();\n\n expect(CommandUtils.isApduThatTriggersDisconnection(apdu)).toBe(true);\n });\n\n it(\"should return false if the APDU is not a known one\", () => {\n const apdu = new GetAppAndVersionCommand().getApdu().getRawApdu();\n\n expect(CommandUtils.isApduThatTriggersDisconnection(apdu)).toBe(false);\n });\n });\n});\n"],
|
5
|
+
"mappings": "aAAA,IAAAA,EAAgC,2CAChCC,EAAwC,mDACxCC,EAA+B,0CAC/BC,EAA6B,4CAE7BC,EAA6B,0BAE7B,SAAS,eAAgB,IAAM,CAC7B,SAAS,2BAA4B,IAAM,CACzC,GAAG,kDAAmD,IAAM,CAC1D,MAAMC,EAAW,IAAI,eAAa,CAChC,WAAY,WAAW,KAAK,CAAC,IAAM,CAAI,CAAC,EACxC,KAAM,WAAW,KAAK,CAAC,CAAC,CAC1B,CAAC,EAED,OAAO,eAAa,kBAAkBA,CAAQ,CAAC,EAAE,KAAK,EAAI,CAC5D,CAAC,EAED,GAAG,uDAAwD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K,EAAK,CAClE,CAAC,EAED,GAAG,6DAA8D,IAAM,CACrE,MAAMA,EAAW,IAAI,eAAa,CAChC,WAAY,WAAW,KAAK,CAAC,GAAI,CAAC,EAClC,KAAM,WAAW,KAAK,CAAC,CAAC,CAC1B,CAAC,EAED,OAAO,eAAa,uBAAuBA,CAAQ,CAAC,EAAE,KAAK,EAAK,CAClE,CAAC,CACH,CAAC,EAED,SAAS,yCAA0C,IAAM,CACvD,GAAG,4CAA6C,IAAM,CACpD,MAAME,EAAO,IAAI,iBAAe,CAAE,QAAS,MAAO,CAAC,EAChD,QAAQ,EACR,WAAW,EAEd,OAAO,eAAa,gCAAgCA,CAAI,CAAC,EAAE,KAAK,EAAI,CACtE,CAAC,EAED,GAAG,6CAA8C,IAAM,CACrD,MAAMA,EAAO,IAAI,kBAAgB,EAAE,QAAQ,EAAE,WAAW,EAExD,OAAO,eAAa,gCAAgCA,CAAI,CAAC,EAAE,KAAK,EAAI,CACtE,CAAC,EAED,GAAG,qDAAsD,IAAM,CAC7D,MAAMA,EAAO,IAAI,0BAAwB,EAAE,QAAQ,EAAE,WAAW,EAEhE,OAAO,eAAa,gCAAgCA,CAAI,CAAC,EAAE,KAAK,EAAK,CACvE,CAAC,CACH,CAAC,CACH,CAAC",
|
6
|
+
"names": ["import_CloseAppCommand", "import_GetAppAndVersionCommand", "import_OpenAppCommand", "import_ApduResponse", "import_CommandUtils", "response", "statusCode", "apdu"]
|
7
7
|
}
|
@@ -1,2 +1,2 @@
|
|
1
|
-
"use strict";var
|
1
|
+
"use strict";var n=Object.defineProperty;var a=Object.getOwnPropertyDescriptor;var s=Object.getOwnPropertyNames;var p=Object.prototype.hasOwnProperty;var m=(t,e,i,o)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of s(e))!p.call(t,r)&&r!==i&&n(t,r,{get:()=>e[r],enumerable:!(o=a(e,r))||o.enumerable});return t};var c=t=>m(n({},"__esModule",{value:!0}),t);var d={};module.exports=c(d);
|
2
2
|
//# sourceMappingURL=DeviceAction.js.map
|
@@ -1,7 +1,7 @@
|
|
1
1
|
{
|
2
2
|
"version": 3,
|
3
3
|
"sources": ["../../../../../src/api/device-action/DeviceAction.ts"],
|
4
|
-
"sourcesContent": ["import { type Observable } from \"rxjs\";\n\nimport { type Command } from \"@api/command/Command\";\nimport { type CommandResult } from \"@api/command/model/CommandResult\";\nimport { type DeviceSessionState } from \"@api/device-session/DeviceSessionState\";\nimport { type DmkError } from \"@api/Error\";\nimport { type ManagerApiService } from \"@internal/manager-api/service/ManagerApiService\";\n\nimport { type DeviceActionState } from \"./model/DeviceActionState\";\n\nexport type InternalApi = {\n readonly sendCommand: <Response, Args, ErrorStatusCodes>(\n command: Command<Response, Args, ErrorStatusCodes>,\n ) => Promise<CommandResult<Response, ErrorStatusCodes>>;\n readonly getDeviceSessionState: () => DeviceSessionState;\n readonly getDeviceSessionStateObservable: () => Observable<DeviceSessionState>;\n readonly setDeviceSessionState: (\n state: DeviceSessionState,\n ) => DeviceSessionState;\n readonly getManagerApiService: () => ManagerApiService;\n};\n\nexport type DeviceActionIntermediateValue = {\n readonly requiredUserInteraction: string;\n};\n\nexport type ExecuteDeviceActionReturnType<Output, Error, IntermediateValue> = {\n readonly observable: Observable<\n DeviceActionState<Output, Error, IntermediateValue>\n >;\n cancel(): void;\n};\n\nexport interface DeviceAction<\n Output,\n Input,\n Error extends DmkError,\n IntermediateValue extends DeviceActionIntermediateValue,\n> {\n readonly input: Input;\n\n _execute(\n params: InternalApi,\n ): ExecuteDeviceActionReturnType<Output, Error, IntermediateValue>;\n}\n"],
|
4
|
+
"sourcesContent": ["import { type Either } from \"purify-ts\";\nimport { type Observable } from \"rxjs\";\n\nimport { type Command } from \"@api/command/Command\";\nimport { type CommandResult } from \"@api/command/model/CommandResult\";\nimport { type ApduResponse } from \"@api/device-session/ApduResponse\";\nimport { type DeviceSessionState } from \"@api/device-session/DeviceSessionState\";\nimport { type DmkError } from \"@api/Error\";\nimport { type ManagerApiService } from \"@internal/manager-api/service/ManagerApiService\";\nimport { type SecureChannelService } from \"@internal/secure-channel/service/SecureChannelService\";\n\nimport { type DeviceActionState } from \"./model/DeviceActionState\";\n\nexport type InternalApi = {\n readonly sendApdu: (\n apdu: Uint8Array,\n ) => Promise<Either<DmkError, ApduResponse>>;\n readonly sendCommand: <Response, Args, ErrorStatusCodes>(\n command: Command<Response, Args, ErrorStatusCodes>,\n ) => Promise<CommandResult<Response, ErrorStatusCodes>>;\n readonly getDeviceSessionState: () => DeviceSessionState;\n readonly getDeviceSessionStateObservable: () => Observable<DeviceSessionState>;\n readonly setDeviceSessionState: (\n state: DeviceSessionState,\n ) => DeviceSessionState;\n readonly getManagerApiService: () => ManagerApiService;\n readonly getSecureChannelService: () => SecureChannelService;\n};\n\nexport type DeviceActionIntermediateValue = {\n readonly requiredUserInteraction: string;\n};\n\nexport type ExecuteDeviceActionReturnType<Output, Error, IntermediateValue> = {\n readonly observable: Observable<\n DeviceActionState<Output, Error, IntermediateValue>\n >;\n cancel(): void;\n};\n\nexport interface DeviceAction<\n Output,\n Input,\n Error extends DmkError,\n IntermediateValue extends DeviceActionIntermediateValue,\n> {\n readonly input: Input;\n\n _execute(\n params: InternalApi,\n ): ExecuteDeviceActionReturnType<Output, Error, IntermediateValue>;\n}\n"],
|
5
5
|
"mappings": "+WAAA,IAAAA,EAAA,kBAAAC,EAAAD",
|
6
6
|
"names": ["DeviceAction_exports", "__toCommonJS"]
|
7
7
|
}
|
@@ -1,2 +1,2 @@
|
|
1
|
-
"use strict";var
|
1
|
+
"use strict";var c=Object.defineProperty;var s=Object.getOwnPropertyDescriptor;var a=Object.getOwnPropertyNames;var r=Object.prototype.hasOwnProperty;var v=(n,e)=>{for(var i in e)c(n,i,{get:e[i],enumerable:!0})},S=(n,e,i,o)=>{if(e&&typeof e=="object"||typeof e=="function")for(let t of a(e))!r.call(n,t)&&t!==i&&c(n,t,{get:()=>e[t],enumerable:!(o=s(e,t))||o.enumerable});return n};var p=n=>S(c({},"__esModule",{value:!0}),n);var D={};v(D,{makeDeviceActionInternalApiMock:()=>l});module.exports=p(D);const M=vi.fn(),k=vi.fn(),d=vi.fn(),f=vi.fn(),m=vi.fn(),g=vi.fn(),A=vi.fn();function l(){return{sendApdu:M,sendCommand:k,getDeviceSessionState:d,getDeviceSessionStateObservable:f,setDeviceSessionState:m,getManagerApiService:g,getSecureChannelService:A}}0&&(module.exports={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 InternalApi } from \"@api/device-action/DeviceAction\";\n\nconst sendCommandMock =
|
5
|
-
"mappings": "yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,qCAAAE,IAAA,eAAAC,EAAAH,
|
6
|
-
"names": ["makeInternalApi_exports", "__export", "makeDeviceActionInternalApiMock", "__toCommonJS", "sendCommandMock", "apiGetDeviceSessionStateMock", "apiGetDeviceSessionStateObservableMock", "setDeviceSessionStateMock", "getManagerApiServiceMock"]
|
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 apiGetDeviceSessionStateMock = vi.fn();\nconst apiGetDeviceSessionStateObservableMock = vi.fn();\nconst setDeviceSessionStateMock = vi.fn();\nconst getManagerApiServiceMock = vi.fn();\nconst getSecureChannelServiceMock = vi.fn();\n\nexport function makeDeviceActionInternalApiMock(): Mocked<InternalApi> {\n return {\n sendApdu: sendApduMock,\n sendCommand: sendCommandMock,\n getDeviceSessionState: apiGetDeviceSessionStateMock,\n getDeviceSessionStateObservable: apiGetDeviceSessionStateObservableMock,\n setDeviceSessionState: setDeviceSessionStateMock,\n getManagerApiService: getManagerApiServiceMock,\n getSecureChannelService: getSecureChannelServiceMock,\n };\n}\n"],
|
5
|
+
"mappings": "yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,qCAAAE,IAAA,eAAAC,EAAAH,GAIA,MAAMI,EAAe,GAAG,GAAG,EACrBC,EAAkB,GAAG,GAAG,EACxBC,EAA+B,GAAG,GAAG,EACrCC,EAAyC,GAAG,GAAG,EAC/CC,EAA4B,GAAG,GAAG,EAClCC,EAA2B,GAAG,GAAG,EACjCC,EAA8B,GAAG,GAAG,EAEnC,SAASR,GAAuD,CACrE,MAAO,CACL,SAAUE,EACV,YAAaC,EACb,sBAAuBC,EACvB,gCAAiCC,EACjC,sBAAuBC,EACvB,qBAAsBC,EACtB,wBAAyBC,CAC3B,CACF",
|
6
|
+
"names": ["makeInternalApi_exports", "__export", "makeDeviceActionInternalApiMock", "__toCommonJS", "sendApduMock", "sendCommandMock", "apiGetDeviceSessionStateMock", "apiGetDeviceSessionStateObservableMock", "setDeviceSessionStateMock", "getManagerApiServiceMock", "getSecureChannelServiceMock"]
|
7
7
|
}
|
@@ -1,2 +1,2 @@
|
|
1
|
-
"use strict";var p=Object.defineProperty;var f=Object.getOwnPropertyDescriptor;var l=Object.getOwnPropertyNames;var
|
1
|
+
"use strict";var p=Object.defineProperty;var f=Object.getOwnPropertyDescriptor;var l=Object.getOwnPropertyNames;var k=Object.prototype.hasOwnProperty;var A=(t,e)=>{for(var o in e)p(t,o,{get:e[o],enumerable:!0})},y=(t,e,o,m)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of l(e))!k.call(t,i)&&i!==o&&p(t,i,{get:()=>e[i],enumerable:!(m=f(e,i))||m.enumerable});return t};var D=t=>y(p({},"__esModule",{value:!0}),t);var h={};A(h,{setupGetDeviceStatusMock:()=>I,setupGoToDashboardMock:()=>v,setupListAppsMock:()=>M});module.exports=D(h);var r=require("purify-ts"),n=require("xstate"),a=require("../../device-action/model/UserInteractionRequired"),c=require("../../device-action/os/Errors"),s=require("../../device-action/os/GetDeviceStatus/GetDeviceStatusDeviceAction"),d=require("../../device-action/os/GoToDashboard/GoToDashboardDeviceAction"),u=require("../../device-action/os/ListApps/ListAppsDeviceAction");const M=(t,e=!1)=>{u.ListAppsDeviceAction.mockImplementation(()=>({makeStateMachine:vi.fn().mockImplementation(()=>(0,n.createMachine)({id:"MockListAppsDeviceAction",initial:"ready",states:{ready:{after:{0:"done"},entry:(0,n.assign)({intermediateValue:()=>({requiredUserInteraction:a.UserInteractionRequired.AllowListApps})})},done:{type:"final"}},output:()=>e?(0,r.Left)(new c.UnknownDAError("ListApps failed")):(0,r.Right)(t)}))}))},v=(t=!1)=>{d.GoToDashboardDeviceAction.mockImplementation(()=>({makeStateMachine:vi.fn().mockImplementation(()=>(0,n.createMachine)({id:"MockGoToDashboardDeviceAction",initial:"ready",states:{ready:{after:{0:"done"},entry:(0,n.assign)({intermediateValue:()=>({requiredUserInteraction:a.UserInteractionRequired.None})})},done:{type:"final"}},output:()=>t?(0,r.Left)(new c.UnknownDAError("GoToDashboard failed")):(0,r.Right)(void 0)}))}))},I=(t=[{currentApp:"BOLOS",currentAppVersion:"1.0.0"}])=>{const e=vi.fn();for(const o of t)e.mockImplementationOnce(()=>"currentApp"in o?(0,r.Right)(o):(0,r.Left)(o));s.GetDeviceStatusDeviceAction.mockImplementation(()=>({makeStateMachine:vi.fn().mockImplementation(()=>(0,n.createMachine)({id:"MockGetDeviceStatusDeviceAction",initial:"ready",states:{ready:{after:{0:"done"},entry:(0,n.assign)({intermediateValue:()=>({requiredUserInteraction:a.UserInteractionRequired.None})})},done:{type:"final"}},output:e}))}))};0&&(module.exports={setupGetDeviceStatusMock,setupGoToDashboardMock,setupListAppsMock});
|
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 { assign, createMachine } from \"xstate\";\n\nimport { UserInteractionRequired } from \"@api/device-action/model/UserInteractionRequired\";\nimport { UnknownDAError } from \"@api/device-action/os/Errors\";\nimport { GetDeviceStatusDeviceAction } from \"@api/device-action/os/GetDeviceStatus/GetDeviceStatusDeviceAction\";\nimport { GoToDashboardDeviceAction } from \"@api/device-action/os/GoToDashboard/GoToDashboardDeviceAction\";\nimport { ListAppsDeviceAction } from \"@api/device-action/os/ListApps/ListAppsDeviceAction\";\nimport { type DmkError } from \"@api/Error\";\n\nimport { type BTC_APP } from \"./data\";\n\ntype App = typeof BTC_APP;\n\nexport const setupListAppsMock = (apps: App[], error = false) => {\n (ListAppsDeviceAction as
|
5
|
-
"mappings": "yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,8BAAAE,EAAA,2BAAAC,EAAA,sBAAAC,IAAA,eAAAC,EAAAL,GAAA,IAAAM,EAA4B,
|
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 { GetDeviceStatusDeviceAction } from \"@api/device-action/os/GetDeviceStatus/GetDeviceStatusDeviceAction\";\nimport { GoToDashboardDeviceAction } from \"@api/device-action/os/GoToDashboard/GoToDashboardDeviceAction\";\nimport { ListAppsDeviceAction } from \"@api/device-action/os/ListApps/ListAppsDeviceAction\";\nimport { type DmkError } from \"@api/Error\";\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 }),\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 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 }),\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 }),\n }),\n },\n done: {\n type: \"final\",\n },\n },\n output: outputFn,\n }),\n ),\n }));\n};\n"],
|
5
|
+
"mappings": "yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,8BAAAE,EAAA,2BAAAC,EAAA,sBAAAC,IAAA,eAAAC,EAAAL,GAAA,IAAAM,EAA4B,qBAE5BC,EAAsC,kBAEtCC,EAAwC,4DACxCC,EAA+B,wCAC/BC,EAA4C,6EAC5CC,EAA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AAG,MACL,EACA,SAAO,UAAO,CACZ,kBAAmB,KAAO,CACxB,wBAAyB,0BAAwB,IACnD,EACF,CAAC,CACH,EACA,KAAM,CACJ,KAAM,OACR,CACF,EACA,OAAQD,CACV,CAAC,CACH,CACF,EAAE,CACJ",
|
6
6
|
"names": ["setupTestMachine_exports", "__export", "setupGetDeviceStatusMock", "setupGoToDashboardMock", "setupListAppsMock", "__toCommonJS", "import_purify_ts", "import_xstate", "import_UserInteractionRequired", "import_Errors", "import_GetDeviceStatusDeviceAction", "import_GoToDashboardDeviceAction", "import_ListAppsDeviceAction", "apps", "error", "outputs", "outputFn", "output"]
|
7
7
|
}
|
@@ -1,2 +1,2 @@
|
|
1
|
-
"use strict";var
|
1
|
+
"use strict";var c=Object.defineProperty;var m=Object.getOwnPropertyDescriptor;var s=Object.getOwnPropertyNames;var l=Object.prototype.hasOwnProperty;var v=(t,e)=>{for(var o in e)c(t,o,{get:e[o],enumerable:!0})},A=(t,e,o,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of s(e))!l.call(t,r)&&r!==o&&c(t,r,{get:()=>e[r],enumerable:!(n=m(e,r))||n.enumerable});return t};var d=t=>A(c({},"__esModule",{value:!0}),t);var I={};v(I,{testDeviceActionStates:()=>D});module.exports=d(I);function D(t,e,o,{onDone:n,onError:r}){const a=[],{observable:u,cancel:p}=t._execute(o);return u.subscribe({next:i=>{a.push(i)},error:i=>{r(i)},complete:()=>{try{expect(a).toEqual(e),n()}catch(i){r(i)}}}),{observable:u,cancel:p}}0&&(module.exports={testDeviceActionStates});
|
2
2
|
//# sourceMappingURL=testDeviceActionStates.js.map
|
@@ -1,7 +1,7 @@
|
|
1
1
|
{
|
2
2
|
"version": 3,
|
3
3
|
"sources": ["../../../../../../src/api/device-action/__test-utils__/testDeviceActionStates.ts"],
|
4
|
-
"sourcesContent": ["import {\n type DeviceAction,\n type DeviceActionIntermediateValue,\n type InternalApi,\n} from \"@api/device-action/DeviceAction\";\nimport { type DeviceActionState } from \"@api/device-action/model/DeviceActionState\";\nimport { type DmkError } from \"@api/Error\";\n\n/**\n * Test that the states emitted by a device action match the expected states.\n * @param deviceAction The device action to test.\n * @param expectedStates The expected states.\n * @param internalApi\n * @param
|
5
|
-
"mappings": "yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,4BAAAE,IAAA,eAAAC,EAAAH,GAeO,SAASE,EAMdE,EACAC,EACAC,
|
6
|
-
"names": ["testDeviceActionStates_exports", "__export", "testDeviceActionStates", "__toCommonJS", "deviceAction", "expectedStates", "internalApi", "
|
4
|
+
"sourcesContent": ["import {\n type DeviceAction,\n type DeviceActionIntermediateValue,\n type InternalApi,\n} from \"@api/device-action/DeviceAction\";\nimport { type DeviceActionState } from \"@api/device-action/model/DeviceActionState\";\nimport { type DmkError } from \"@api/Error\";\n\n/**\n * Test that the states emitted by a device action match the expected states.\n * @param deviceAction The device action to test.\n * @param expectedStates The expected states.\n * @param internalApi\n * @param callbacks { onDone, onError } The callbacks to call when the test is done or an error occurs.\n */\nexport function testDeviceActionStates<\n Output,\n Input,\n Error extends DmkError,\n IntermediateValue extends DeviceActionIntermediateValue,\n>(\n deviceAction: DeviceAction<Output, Input, Error, IntermediateValue>,\n expectedStates: Array<DeviceActionState<Output, Error, IntermediateValue>>,\n internalApi: InternalApi,\n {\n onDone,\n onError,\n }: {\n onDone: () => void;\n onError: (error: Error) => void;\n },\n) {\n const observedStates: Array<\n DeviceActionState<Output, Error, IntermediateValue>\n > = [];\n\n const { observable, cancel } = deviceAction._execute(internalApi);\n\n observable.subscribe({\n next: (state) => {\n observedStates.push(state);\n },\n error: (error) => {\n onError(error);\n },\n complete: () => {\n try {\n expect(observedStates).toEqual(expectedStates);\n onDone();\n } catch (e) {\n onError(e as Error);\n }\n },\n });\n\n return { observable, cancel };\n}\n"],
|
5
|
+
"mappings": "yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,4BAAAE,IAAA,eAAAC,EAAAH,GAeO,SAASE,EAMdE,EACAC,EACAC,EACA,CACE,OAAAC,EACA,QAAAC,CACF,EAIA,CACA,MAAMC,EAEF,CAAC,EAEC,CAAE,WAAAC,EAAY,OAAAC,CAAO,EAAIP,EAAa,SAASE,CAAW,EAEhE,OAAAI,EAAW,UAAU,CACnB,KAAOE,GAAU,CACfH,EAAe,KAAKG,CAAK,CAC3B,EACA,MAAQC,GAAU,CAChBL,EAAQK,CAAK,CACf,EACA,SAAU,IAAM,CACd,GAAI,CACF,OAAOJ,CAAc,EAAE,QAAQJ,CAAc,EAC7CE,EAAO,CACT,OAASO,EAAG,CACVN,EAAQM,CAAU,CACpB,CACF,CACF,CAAC,EAEM,CAAE,WAAAJ,EAAY,OAAAC,CAAO,CAC9B",
|
6
|
+
"names": ["testDeviceActionStates_exports", "__export", "testDeviceActionStates", "__toCommonJS", "deviceAction", "expectedStates", "internalApi", "onDone", "onError", "observedStates", "observable", "cancel", "state", "error", "e"]
|
7
7
|
}
|
package/lib/cjs/src/api/device-action/os/CallTaskInAppDeviceAction/CallTaskInAppDeviceAction.js
ADDED
@@ -0,0 +1,2 @@
|
|
1
|
+
"use strict";var o=Object.defineProperty;var A=Object.getOwnPropertyDescriptor;var T=Object.getOwnPropertyNames;var m=Object.prototype.hasOwnProperty;var I=(r,t)=>{for(var s in t)o(r,s,{get:t[s],enumerable:!0})},C=(r,t,s,e)=>{if(t&&typeof t=="object"||typeof t=="function")for(let n of T(t))!m.call(r,n)&&n!==s&&o(r,n,{get:()=>t[n],enumerable:!(e=A(t,n))||e.enumerable});return r};var d=r=>C(o({},"__esModule",{value:!0}),r);var S={};I(S,{CallTaskInAppDeviceAction:()=>D});module.exports=d(S);var p=require("purify-ts"),a=require("xstate"),l=require("../../../command/model/CommandResult"),i=require("../../../device-action/model/UserInteractionRequired"),c=require("../../../device-action/os/Errors"),u=require("../../../device-action/os/OpenAppDeviceAction/OpenAppDeviceAction"),k=require("../../../device-action/xstate-utils/XStateDeviceAction");class D extends k.XStateDeviceAction{makeStateMachine(t){const{callTask:s}=this.extractDependencies(t);return(0,a.setup)({types:{input:{},context:{},output:{}},actors:{callTask:(0,a.fromPromise)(s),openAppStateMachine:new u.OpenAppDeviceAction({input:{appName:this.input.appName,compatibleAppNames:this.input.compatibleAppNames}}).makeStateMachine(t)},guards:{noInternalError:({context:e})=>e._internalState.error===null},actions:{assignErrorFromEvent:(0,a.assign)({_internalState:e=>({...e.context._internalState,error:e.event.error})})}}).createMachine({id:"CallTaskInAppDeviceAction",initial:"OpenAppDeviceAction",context:({input:e})=>({input:e,intermediateValue:{requiredUserInteraction:i.UserInteractionRequired.None},_internalState:{taskResponse:null,error:null}}),states:{OpenAppDeviceAction:{invoke:{id:"openAppStateMachine",input:{appName:this.input.appName,compatibleAppNames:this.input.compatibleAppNames},src:"openAppStateMachine",onSnapshot:{actions:(0,a.assign)({intermediateValue:e=>e.event.snapshot.context.intermediateValue})},onDone:{actions:(0,a.assign)({_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:(0,a.assign)({intermediateValue:{requiredUserInteraction:this.input.requiredUserInteraction}}),exit:(0,a.assign)({intermediateValue:{requiredUserInteraction:i.UserInteractionRequired.None}}),invoke:{id:"callTask",src:"callTask",input:e=>e.context.input.task,onDone:{target:"CallTaskResultCheck",actions:[(0,a.assign)({_internalState:({event:e,context:n})=>(0,l.isSuccessCommandResult)(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?(0,p.Right)(e._internalState.taskResponse):(0,p.Left)(e._internalState.error||new c.UnknownDAError("No error in final state"))})}extractDependencies(t){return{callTask:s=>s.input(t)}}}0&&(module.exports={CallTaskInAppDeviceAction});
|
2
|
+
//# sourceMappingURL=CallTaskInAppDeviceAction.js.map
|
package/lib/cjs/src/api/device-action/os/CallTaskInAppDeviceAction/CallTaskInAppDeviceAction.js.map
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
{
|
2
|
+
"version": 3,
|
3
|
+
"sources": ["../../../../../../../src/api/device-action/os/CallTaskInAppDeviceAction/CallTaskInAppDeviceAction.ts"],
|
4
|
+
"sourcesContent": ["import { Left, Right } from \"purify-ts\";\nimport { assign, fromPromise, setup } from \"xstate\";\n\nimport {\n type CommandResult,\n isSuccessCommandResult,\n} from \"@api/command/model/CommandResult\";\nimport { type InternalApi } from \"@api/device-action/DeviceAction\";\nimport { UserInteractionRequired } from \"@api/device-action/model/UserInteractionRequired\";\nimport { UnknownDAError } from \"@api/device-action/os/Errors\";\nimport { OpenAppDeviceAction } from \"@api/device-action/os/OpenAppDeviceAction/OpenAppDeviceAction\";\nimport { type StateMachineTypes } from \"@api/device-action/xstate-utils/StateMachineTypes\";\nimport {\n type DeviceActionStateMachine,\n XStateDeviceAction,\n} from \"@api/device-action/xstate-utils/XStateDeviceAction\";\n\nimport {\n type CallTaskInAppDAError,\n type CallTaskInAppDAInput,\n type CallTaskInAppDAIntermediateValue,\n type CallTaskInAppDAInternalState,\n type CallTaskInAppDAOutput,\n} from \"./CallTaskInAppDeviceActionTypes\";\n\n/**\n * Tries to open an app on the device, and if it is successful, calls a task\n * in the app.\n * The output will be the result of the task.\n *\n * ```ts\n * input: {\n * appName: string;\n * task: (internalApi: InternalApi) => Promise<CommandResult<TaskResponse, TaskErrorCodes>>;\n * requiredUserInteraction: UserInteraction;\n * }\n * ```\n *\n * Example of usage:\n *\n * ```ts\n * const deviceAction = new CallTaskInAppDeviceAction({\n * input: {\n * appName: \"MyApp\",\n * task: async (internalApi: InternalApi) => internalApi.sendCommand(new MyAppSpecificCommand()),\n * requiredUserInteraction: UserInteractionRequired.None,\n * },\n * });\n * dmk.executeDeviceAction({ sessionId: \"mySessionId\", deviceAction });\n * ```\n */\nexport class CallTaskInAppDeviceAction<\n TaskResponse,\n TaskErrorCodes,\n UserInteraction extends UserInteractionRequired,\n> extends XStateDeviceAction<\n CallTaskInAppDAOutput<TaskResponse>,\n CallTaskInAppDAInput<TaskResponse, TaskErrorCodes, UserInteraction>,\n CallTaskInAppDAError<TaskErrorCodes>,\n CallTaskInAppDAIntermediateValue<UserInteraction>,\n CallTaskInAppDAInternalState<TaskResponse, TaskErrorCodes>\n> {\n makeStateMachine(\n internalAPI: InternalApi,\n ): DeviceActionStateMachine<\n CallTaskInAppDAOutput<TaskResponse>,\n CallTaskInAppDAInput<TaskResponse, TaskErrorCodes, UserInteraction>,\n CallTaskInAppDAError<TaskErrorCodes>,\n CallTaskInAppDAIntermediateValue<UserInteraction>,\n CallTaskInAppDAInternalState<TaskResponse, TaskErrorCodes>\n > {\n type types = StateMachineTypes<\n CallTaskInAppDAOutput<TaskResponse>,\n CallTaskInAppDAInput<TaskResponse, TaskErrorCodes, UserInteraction>,\n CallTaskInAppDAError<TaskErrorCodes>,\n CallTaskInAppDAIntermediateValue<UserInteraction>,\n CallTaskInAppDAInternalState<TaskResponse, TaskErrorCodes>\n >;\n\n const { callTask } = this.extractDependencies(internalAPI);\n\n return setup({\n types: {\n input: {} as types[\"input\"],\n context: {} as types[\"context\"],\n output: {} as types[\"output\"],\n },\n actors: {\n callTask: fromPromise(callTask),\n openAppStateMachine: new OpenAppDeviceAction({\n input: {\n appName: this.input.appName,\n compatibleAppNames: this.input.compatibleAppNames,\n },\n }).makeStateMachine(internalAPI),\n },\n guards: {\n noInternalError: ({ context }) => context._internalState.error === null,\n },\n actions: {\n assignErrorFromEvent: assign({\n _internalState: (_) => ({\n ..._.context._internalState,\n error: _.event[\"error\"], // NOTE: it should never happen, the error is not typed anymore here\n }),\n }),\n },\n }).createMachine({\n id: \"CallTaskInAppDeviceAction\",\n initial: \"OpenAppDeviceAction\",\n context: ({ input }) => {\n return {\n input: input,\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.None,\n },\n _internalState: {\n taskResponse: null,\n error: null,\n },\n };\n },\n states: {\n OpenAppDeviceAction: {\n invoke: {\n id: \"openAppStateMachine\",\n input: {\n appName: this.input.appName,\n compatibleAppNames: this.input.compatibleAppNames,\n },\n src: \"openAppStateMachine\",\n onSnapshot: {\n actions: assign({\n intermediateValue: (_) =>\n _.event.snapshot.context.intermediateValue,\n }),\n },\n onDone: {\n actions: assign({\n _internalState: (_) => {\n return _.event.output.caseOf<\n CallTaskInAppDAInternalState<TaskResponse, TaskErrorCodes>\n >({\n Right: () => _.context._internalState,\n Left: (error) => ({\n ..._.context._internalState,\n error,\n }),\n });\n },\n }),\n target: \"CheckOpenAppDeviceActionResult\",\n },\n },\n },\n CheckOpenAppDeviceActionResult: {\n always: [\n {\n target: \"CallTask\",\n guard: \"noInternalError\",\n },\n \"Error\",\n ],\n },\n CallTask: {\n entry: assign({\n intermediateValue: {\n requiredUserInteraction: this.input.requiredUserInteraction,\n },\n }),\n exit: assign({\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.None,\n },\n }),\n invoke: {\n id: \"callTask\",\n src: \"callTask\",\n input: (_: { context: types[\"context\"] }) => _.context.input.task,\n onDone: {\n target: \"CallTaskResultCheck\",\n actions: [\n assign({\n _internalState: ({ event, context }) => {\n if (isSuccessCommandResult(event.output)) {\n return {\n ...context._internalState,\n taskResponse: event.output.data,\n };\n }\n return {\n ...context._internalState,\n error: event.output.error,\n };\n },\n }),\n ],\n },\n onError: {\n target: \"Error\",\n actions: \"assignErrorFromEvent\",\n },\n },\n },\n CallTaskResultCheck: {\n always: [\n {\n target: \"Success\",\n guard: \"noInternalError\",\n },\n \"Error\",\n ],\n },\n Success: {\n type: \"final\",\n },\n Error: {\n type: \"final\",\n },\n },\n output: ({ context }) =>\n context._internalState.taskResponse\n ? Right(context._internalState.taskResponse)\n : Left(\n context._internalState.error ||\n new UnknownDAError(\"No error in final state\"),\n ),\n });\n }\n\n extractDependencies(internalApi: InternalApi) {\n return {\n callTask: (_: {\n input: (\n internalApi: InternalApi,\n ) => Promise<CommandResult<TaskResponse, TaskErrorCodes>>;\n }): Promise<CommandResult<TaskResponse, TaskErrorCodes>> =>\n _.input(internalApi),\n };\n }\n}\n"],
|
5
|
+
"mappings": "yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,+BAAAE,IAAA,eAAAC,EAAAH,GAAA,IAAAI,EAA4B,qBAC5BC,EAA2C,kBAE3CC,EAGO,4CAEPC,EAAwC,4DACxCC,EAA+B,wCAC/BC,EAAoC,yEAEpCC,EAGO,8DAoCA,MAAMR,UAIH,oBAMR,CACA,iBACES,EAOA,CASA,KAAM,CAAE,SAAAC,CAAS,EAAI,KAAK,oBAAoBD,CAAW,EAEzD,SAAO,SAAM,CACX,MAAO,CACL,MAAO,CAAC,EACR,QAAS,CAAC,EACV,OAAQ,CAAC,CACX,EACA,OAAQ,CACN,YAAU,eAAYC,CAAQ,EAC9B,oBAAqB,IAAI,sBAAoB,CAC3C,MAAO,CACL,QAAS,KAAK,MAAM,QACpB,mBAAoB,KAAK,MAAM,kBACjC,CACF,CAAC,EAAE,iBAAiBD,CAAW,CACjC,EACA,OAAQ,CACN,gBAAiB,CAAC,CAAE,QAAAE,CAAQ,IAAMA,EAAQ,eAAe,QAAU,IACrE,EACA,QAAS,CACP,wBAAsB,UAAO,CAC3B,eAAiBC,IAAO,CACtB,GAAGA,EAAE,QAAQ,eACb,MAAOA,EAAE,MAAM,KACjB,EACF,CAAC,CACH,CACF,CAAC,EAAE,cAAc,CACf,GAAI,4BACJ,QAAS,sBACT,QAAS,CAAC,CAAE,MAAAC,CAAM,KACT,CACL,MAAOA,EACP,kBAAmB,CACjB,wBAAyB,0BAAwB,IACnD,EACA,eAAgB,CACd,aAAc,KACd,MAAO,IACT,CACF,GAEF,OAAQ,CACN,oBAAqB,CACnB,OAAQ,CACN,GAAI,sBACJ,MAAO,CACL,QAAS,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,EAAQ,eAAe,OACrB,IAAI,iBAAe,yBAAyB,CAChD,CACR,CAAC,CACH,CAEA,oBAAoBK,EAA0B,CAC5C,MAAO,CACL,SAAWJ,GAKTA,EAAE,MAAMI,CAAW,CACvB,CACF,CACF",
|
6
|
+
"names": ["CallTaskInAppDeviceAction_exports", "__export", "CallTaskInAppDeviceAction", "__toCommonJS", "import_purify_ts", "import_xstate", "import_CommandResult", "import_UserInteractionRequired", "import_Errors", "import_OpenAppDeviceAction", "import_XStateDeviceAction", "internalAPI", "callTask", "context", "_", "input", "error", "event", "internalApi"]
|
7
|
+
}
|
package/lib/cjs/src/api/device-action/os/CallTaskInAppDeviceAction/CallTaskInAppDeviceAction.test.js
ADDED
@@ -0,0 +1,2 @@
|
|
1
|
+
"use strict";var k=require("purify-ts"),y=require("xstate"),w=require("../../../apdu/utils/ApduBuilder"),u=require("../../../command/model/CommandResult"),s=require("../../../device-action/__test-utils__/makeInternalApi"),A=require("../../../device-action/__test-utils__/testDeviceActionStates"),n=require("../../../device-action/model/DeviceActionState"),e=require("../../../device-action/model/UserInteractionRequired"),C=require("../../../device-action/os/Errors"),M=require("../../../device-action/os/OpenAppDeviceAction/OpenAppDeviceAction"),v=require("../../../../../src"),d=require("./CallTaskInAppDeviceAction");vi.mock("@api/device-action/os/OpenAppDeviceAction/OpenAppDeviceAction",async t=>{const o=await t();return{...o,OpenAppDeviceAction:vi.fn(()=>({...o.OpenAppDeviceAction,makeStateMachine:vi.fn()}))}});const l=t=>{M.OpenAppDeviceAction.mockImplementation(()=>({makeStateMachine:vi.fn().mockImplementation(()=>(0,y.createMachine)({initial:"pending",states:{pending:{entry:(0,y.assign)({intermediateValue:{requiredUserInteraction:e.UserInteractionRequired.ConfirmOpenApp}}),after:{0:"done"}},done:{type:"final"}},output:()=>t?(0,k.Left)(t):(0,k.Right)(void 0)}))}))};describe("CallTaskInAppDeviceAction",()=>{const t=vi.fn(),o=()=>({callTask:t}),{sendCommand:D}=(0,s.makeDeviceActionInternalApiMock)(),p={paramString:"aParameter",paramNumber:1234},I={aNumber:5678,aString:"mockedResponseString"};beforeEach(()=>{vi.resetAllMocks()}),describe("without mocking extractDependencies",()=>{it("should call sendCommand on internalApi with the correct parameters",async()=>{l(),D.mockResolvedValue((0,u.CommandResultFactory)({data:void 0}));const i=new d.CallTaskInAppDeviceAction({input:{task:async r=>await r.sendCommand(new c(p)),appName:"MyApp",requiredUserInteraction:e.UserInteractionRequired.VerifyAddress}});await new Promise((r,a)=>{i._execute((0,s.makeDeviceActionInternalApiMock)()).observable.subscribe({error:()=>a(),complete:()=>r(),next:()=>{}})}),expect(D).toHaveBeenCalledWith(new c(p))})}),describe("error cases",()=>{it("should error and output the error if the open app fails",()=>new Promise((i,r)=>{l(new C.UnknownDAError("Mocked error"));const a=[{status:n.DeviceActionStatus.Pending,intermediateValue:{requiredUserInteraction:e.UserInteractionRequired.None}},{status:n.DeviceActionStatus.Pending,intermediateValue:{requiredUserInteraction:e.UserInteractionRequired.ConfirmOpenApp}},{status:n.DeviceActionStatus.Error,error:new C.UnknownDAError("Mocked error")}];(0,A.testDeviceActionStates)(new d.CallTaskInAppDeviceAction({input:{task:async m=>await m.sendCommand(new c(p)),appName:"MyApp",requiredUserInteraction:e.UserInteractionRequired.VerifyAddress}}),a,(0,s.makeDeviceActionInternalApiMock)(),{onDone:i,onError:r})})),it("should error and output an error if the call task fails",()=>new Promise((i,r)=>{l(),t.mockResolvedValue((0,u.CommandResultFactory)({error:new v.UnknownDeviceExchangeError("Mocked error")}));const a=new d.CallTaskInAppDeviceAction({input:{task:async f=>await f.sendCommand(new c(p)),appName:"MyApp",requiredUserInteraction:e.UserInteractionRequired.VerifyAddress}});vi.spyOn(a,"extractDependencies").mockImplementation(o);const m=[{status:n.DeviceActionStatus.Pending,intermediateValue:{requiredUserInteraction:e.UserInteractionRequired.None}},{status:n.DeviceActionStatus.Pending,intermediateValue:{requiredUserInteraction:e.UserInteractionRequired.ConfirmOpenApp}},{status:n.DeviceActionStatus.Pending,intermediateValue:{requiredUserInteraction:e.UserInteractionRequired.VerifyAddress}},{status:n.DeviceActionStatus.Error,error:new v.UnknownDeviceExchangeError("Mocked error")}];(0,A.testDeviceActionStates)(a,m,(0,s.makeDeviceActionInternalApiMock)(),{onDone:i,onError:r})}))}),describe("success cases",()=>{it("should succeed and output the command result if the send command succeeds",()=>new Promise((i,r)=>{l(),t.mockResolvedValue((0,u.CommandResultFactory)({data:I}));const a=new d.CallTaskInAppDeviceAction({input:{task:async f=>await f.sendCommand(new c(p)),appName:"MyApp",requiredUserInteraction:e.UserInteractionRequired.VerifyAddress}});vi.spyOn(a,"extractDependencies").mockImplementation(o);const m=[{status:n.DeviceActionStatus.Pending,intermediateValue:{requiredUserInteraction:e.UserInteractionRequired.None}},{status:n.DeviceActionStatus.Pending,intermediateValue:{requiredUserInteraction:e.UserInteractionRequired.ConfirmOpenApp}},{status:n.DeviceActionStatus.Pending,intermediateValue:{requiredUserInteraction:e.UserInteractionRequired.VerifyAddress}},{status:n.DeviceActionStatus.Completed,output:I}];(0,A.testDeviceActionStates)(a,m,(0,s.makeDeviceActionInternalApiMock)(),{onDone:i,onError:r})}))})});class c{params;constructor(o){this.params=o}getApdu(){return new w.ApduBuilder({cla:0,ins:1,p1:2,p2:3}).add32BitUIntToData(this.params.paramNumber).addAsciiStringToData(this.params.paramString).build()}parseResponse(){return(0,u.CommandResultFactory)({data:{aNumber:1,aString:"aString"}})}}
|
2
|
+
//# sourceMappingURL=CallTaskInAppDeviceAction.test.js.map
|
@@ -0,0 +1,7 @@
|
|
1
|
+
{
|
2
|
+
"version": 3,
|
3
|
+
"sources": ["../../../../../../../src/api/device-action/os/CallTaskInAppDeviceAction/CallTaskInAppDeviceAction.test.ts"],
|
4
|
+
"sourcesContent": ["/* eslint @typescript-eslint/consistent-type-imports:0 */\nimport { Left, Right } from \"purify-ts\";\nimport { type Mock } from \"vitest\";\nimport { assign, createMachine } from \"xstate\";\n\nimport { type Apdu } from \"@api/apdu/model/Apdu\";\nimport { ApduBuilder } from \"@api/apdu/utils/ApduBuilder\";\nimport { CommandResultFactory } from \"@api/command/model/CommandResult\";\nimport { makeDeviceActionInternalApiMock } from \"@api/device-action/__test-utils__/makeInternalApi\";\nimport { testDeviceActionStates } from \"@api/device-action/__test-utils__/testDeviceActionStates\";\nimport {\n type DeviceActionState,\n DeviceActionStatus,\n} from \"@api/device-action/model/DeviceActionState\";\nimport { UserInteractionRequired } from \"@api/device-action/model/UserInteractionRequired\";\nimport { UnknownDAError } from \"@api/device-action/os/Errors\";\nimport { OpenAppDeviceAction } from \"@api/device-action/os/OpenAppDeviceAction/OpenAppDeviceAction\";\nimport { type Command } from \"@api/types\";\nimport { UnknownDeviceExchangeError } from \"@root/src\";\n\nimport { CallTaskInAppDeviceAction } from \"./CallTaskInAppDeviceAction\";\nimport {\n type CallTaskInAppDAError,\n type CallTaskInAppDAIntermediateValue,\n type CallTaskInAppDAOutput,\n} from \"./CallTaskInAppDeviceActionTypes\";\n\nvi.mock(\n \"@api/device-action/os/OpenAppDeviceAction/OpenAppDeviceAction\",\n async (importOriginal) => {\n const original =\n await importOriginal<\n typeof import(\"@api/device-action/os/OpenAppDeviceAction/OpenAppDeviceAction\")\n >();\n return {\n ...original,\n OpenAppDeviceAction: vi.fn(() => ({\n ...original.OpenAppDeviceAction,\n makeStateMachine: vi.fn(),\n })),\n };\n },\n);\n\nconst setupOpenAppDAMock = (error?: unknown) => {\n (OpenAppDeviceAction as Mock).mockImplementation(() => ({\n makeStateMachine: vi.fn().mockImplementation(() =>\n createMachine({\n initial: \"pending\",\n states: {\n pending: {\n entry: assign({\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.ConfirmOpenApp,\n },\n }),\n after: {\n 0: \"done\",\n },\n },\n done: {\n type: \"final\",\n },\n },\n output: () => (error ? Left(error) : Right(undefined)),\n }),\n ),\n }));\n};\n\ndescribe(\"CallTaskInAppDeviceAction\", () => {\n const callMyTask = vi.fn();\n\n const extractDependenciesMock = () => ({\n callTask: callMyTask,\n });\n\n const { sendCommand: apiSendCommandMock } = makeDeviceActionInternalApiMock();\n\n const commandParams = {\n paramString: \"aParameter\",\n paramNumber: 1234,\n };\n const mockedCommandResponse = {\n aNumber: 5678,\n aString: \"mockedResponseString\",\n };\n beforeEach(() => {\n vi.resetAllMocks();\n });\n\n describe(\"without mocking extractDependencies\", () => {\n it(\"should call sendCommand on internalApi with the correct parameters\", async () => {\n setupOpenAppDAMock();\n apiSendCommandMock.mockResolvedValue(\n CommandResultFactory({ data: undefined }),\n );\n\n const deviceAction = new CallTaskInAppDeviceAction({\n input: {\n task: async (internalApi) =>\n await internalApi.sendCommand(new TestCommand(commandParams)),\n appName: \"MyApp\",\n requiredUserInteraction: UserInteractionRequired.VerifyAddress,\n },\n });\n await new Promise<void>((resolve, reject) => {\n deviceAction\n ._execute(makeDeviceActionInternalApiMock())\n .observable.subscribe({\n error: () => reject(),\n complete: () => resolve(),\n next: () => {},\n });\n });\n\n expect(apiSendCommandMock).toHaveBeenCalledWith(\n new TestCommand(commandParams),\n );\n });\n });\n\n describe(\"error cases\", () => {\n it(\"should error and output the error if the open app fails\", () =>\n new Promise<void>((resolve, reject) => {\n setupOpenAppDAMock(new UnknownDAError(\"Mocked error\"));\n\n const expectedStates: MyCommandCallTaskDAState[] = [\n {\n status: DeviceActionStatus.Pending,\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.None,\n },\n },\n {\n status: DeviceActionStatus.Pending,\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.ConfirmOpenApp,\n },\n },\n {\n status: DeviceActionStatus.Error,\n error: new UnknownDAError(\"Mocked error\"),\n },\n ];\n\n testDeviceActionStates(\n new CallTaskInAppDeviceAction({\n input: {\n task: async (internalApi) =>\n await internalApi.sendCommand(new TestCommand(commandParams)),\n appName: \"MyApp\",\n requiredUserInteraction: UserInteractionRequired.VerifyAddress,\n },\n }),\n expectedStates,\n makeDeviceActionInternalApiMock(),\n {\n onDone: resolve,\n onError: reject,\n },\n );\n }));\n\n it(\"should error and output an error if the call task fails\", () =>\n new Promise<void>((resolve, reject) => {\n setupOpenAppDAMock();\n\n callMyTask.mockResolvedValue(\n CommandResultFactory({\n error: new UnknownDeviceExchangeError(\"Mocked error\"),\n }),\n );\n\n const deviceAction = new CallTaskInAppDeviceAction({\n input: {\n task: async (internalApi) =>\n await internalApi.sendCommand(new TestCommand(commandParams)),\n appName: \"MyApp\",\n requiredUserInteraction: UserInteractionRequired.VerifyAddress,\n },\n });\n\n vi.spyOn(deviceAction, \"extractDependencies\").mockImplementation(\n extractDependenciesMock,\n );\n\n const expectedStates: MyCommandCallTaskDAState[] = [\n {\n status: DeviceActionStatus.Pending,\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.None,\n },\n },\n {\n status: DeviceActionStatus.Pending,\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.ConfirmOpenApp,\n },\n },\n {\n status: DeviceActionStatus.Pending,\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.VerifyAddress,\n },\n },\n {\n status: DeviceActionStatus.Error,\n error: new UnknownDeviceExchangeError(\"Mocked error\"),\n },\n ];\n\n testDeviceActionStates(\n deviceAction,\n expectedStates,\n makeDeviceActionInternalApiMock(),\n {\n onDone: resolve,\n onError: reject,\n },\n );\n }));\n });\n\n describe(\"success cases\", () => {\n it(\"should succeed and output the command result if the send command succeeds\", () =>\n new Promise<void>((resolve, reject) => {\n setupOpenAppDAMock();\n\n callMyTask.mockResolvedValue(\n CommandResultFactory({ data: mockedCommandResponse }),\n );\n\n const deviceAction = new CallTaskInAppDeviceAction({\n input: {\n task: async (internalApi) =>\n await internalApi.sendCommand(new TestCommand(commandParams)),\n appName: \"MyApp\",\n requiredUserInteraction: UserInteractionRequired.VerifyAddress,\n },\n });\n\n vi.spyOn(deviceAction, \"extractDependencies\").mockImplementation(\n extractDependenciesMock,\n );\n\n const expectedStates: MyCommandCallTaskDAState[] = [\n {\n status: DeviceActionStatus.Pending,\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.None,\n },\n },\n {\n status: DeviceActionStatus.Pending,\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.ConfirmOpenApp,\n },\n },\n {\n status: DeviceActionStatus.Pending,\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.VerifyAddress,\n },\n },\n {\n status: DeviceActionStatus.Completed,\n output: mockedCommandResponse,\n },\n ];\n\n testDeviceActionStates(\n deviceAction,\n expectedStates,\n makeDeviceActionInternalApiMock(),\n {\n onDone: resolve,\n onError: reject,\n },\n );\n }));\n });\n});\n\ntype MyCommandResponse = {\n aNumber: number;\n aString: string;\n};\n\ntype MyCommandParams = {\n paramString: string;\n paramNumber: number;\n};\n\nclass TestCommand implements Command<MyCommandResponse, MyCommandParams> {\n params: MyCommandParams;\n constructor(params: MyCommandParams) {\n this.params = params;\n }\n getApdu(): Apdu {\n return new ApduBuilder({ cla: 0x00, ins: 0x01, p1: 0x02, p2: 0x03 })\n .add32BitUIntToData(this.params.paramNumber)\n .addAsciiStringToData(this.params.paramString)\n .build();\n }\n parseResponse() {\n return CommandResultFactory({ data: { aNumber: 1, aString: \"aString\" } });\n }\n}\n\ntype MyCommandCallTaskDAState = DeviceActionState<\n CallTaskInAppDAOutput<MyCommandResponse>,\n CallTaskInAppDAError<UnknownDAError>,\n CallTaskInAppDAIntermediateValue<\n UserInteractionRequired.None | UserInteractionRequired.VerifyAddress\n >\n>;\n"],
|
5
|
+
"mappings": "aACA,IAAAA,EAA4B,qBAE5BC,EAAsC,kBAGtCC,EAA4B,uCAC5BC,EAAqC,4CACrCC,EAAgD,6DAChDC,EAAuC,oEACvCC,EAGO,sDACPC,EAAwC,4DACxCC,EAA+B,wCAC/BC,EAAoC,yEAEpCC,EAA2C,qBAE3CC,EAA0C,uCAO1C,GAAG,KACD,gEACA,MAAOC,GAAmB,CACxB,MAAMC,EACJ,MAAMD,EAEJ,EACJ,MAAO,CACL,GAAGC,EACH,oBAAqB,GAAG,GAAG,KAAO,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C5C,MAAM,CACX,CACA,eAAgB,CACd,SAAO,wBAAqB,CAAE,KAAM,CAAE,QAAS,EAAG,QAAS,SAAU,CAAE,CAAC,CAC1E,CACF",
|
6
|
+
"names": ["import_purify_ts", "import_xstate", "import_ApduBuilder", "import_CommandResult", "import_makeInternalApi", "import_testDeviceActionStates", "import_DeviceActionState", "import_UserInteractionRequired", "import_Errors", "import_OpenAppDeviceAction", "import_src", "import_CallTaskInAppDeviceAction", "importOriginal", "original", "setupOpenAppDAMock", "error", "callMyTask", "extractDependenciesMock", "apiSendCommandMock", "commandParams", "mockedCommandResponse", "deviceAction", "internalApi", "TestCommand", "resolve", "reject", "expectedStates", "params"]
|
7
|
+
}
|
package/lib/cjs/src/api/device-action/os/CallTaskInAppDeviceAction/CallTaskInAppDeviceActionTypes.js
ADDED
@@ -0,0 +1,2 @@
|
|
1
|
+
"use strict";var o=Object.defineProperty;var s=Object.getOwnPropertyDescriptor;var t=Object.getOwnPropertyNames;var l=Object.prototype.hasOwnProperty;var A=(r,e,n,a)=>{if(e&&typeof e=="object"||typeof e=="function")for(let p of t(e))!l.call(r,p)&&p!==n&&o(r,p,{get:()=>e[p],enumerable:!(a=s(e,p))||a.enumerable});return r};var d=r=>A(o({},"__esModule",{value:!0}),r);var i={};module.exports=d(i);
|
2
|
+
//# sourceMappingURL=CallTaskInAppDeviceActionTypes.js.map
|
@@ -0,0 +1,7 @@
|
|
1
|
+
{
|
2
|
+
"version": 3,
|
3
|
+
"sources": ["../../../../../../../src/api/device-action/os/CallTaskInAppDeviceAction/CallTaskInAppDeviceActionTypes.ts"],
|
4
|
+
"sourcesContent": ["import {\n type CommandErrorResult,\n type CommandResult,\n} from \"@api/command/model/CommandResult\";\nimport { type InternalApi } from \"@api/device-action/DeviceAction\";\nimport {\n type OpenAppDAError,\n type OpenAppDAIntermediateValue,\n} from \"@api/device-action/os/OpenAppDeviceAction/types\";\n\nexport type CallTaskInAppDAOutput<TaskResponse> = TaskResponse;\n\nexport type CallTaskInAppDAInput<\n TaskResponse,\n TaskErrorCodes,\n UserInteraction,\n> = {\n readonly task: (\n internalApi: InternalApi,\n ) => Promise<CommandResult<TaskResponse, TaskErrorCodes>>;\n readonly appName: string;\n readonly requiredUserInteraction: UserInteraction;\n readonly compatibleAppNames?: string[];\n};\n\nexport type CallTaskInAppDAError<TaskErrorCodes = void> =\n | OpenAppDAError\n | CommandErrorResult<TaskErrorCodes>[\"error\"];\n\nexport type CallTaskInAppDAIntermediateValue<UserInteraction> =\n | { readonly requiredUserInteraction: UserInteraction }\n | OpenAppDAIntermediateValue;\n\nexport type CallTaskInAppDAInternalState<TaskResponse, TaskErrorCodes> = {\n readonly taskResponse: TaskResponse | null;\n readonly error: CallTaskInAppDAError<TaskErrorCodes> | null;\n};\n"],
|
5
|
+
"mappings": "+WAAA,IAAAA,EAAA,kBAAAC,EAAAD",
|
6
|
+
"names": ["CallTaskInAppDeviceActionTypes_exports", "__toCommonJS"]
|
7
|
+
}
|
package/lib/cjs/src/api/device-action/os/GetDeviceStatus/GetDeviceStatusDeviceAction.test.js
CHANGED
@@ -1,2 +1,2 @@
|
|
1
|
-
"use strict";var u=require("rxjs"),v=require("../../../command/model/CommandResult"),y=require("../../../command/utils/GlobalCommandError"),S=require("../../../device/DeviceModel"),i=require("../../../device/DeviceStatus"),a=require("../../../device-action/__test-utils__/makeInternalApi"),d=require("../../../device-action/__test-utils__/testDeviceActionStates"),t=require("../../../device-action/model/DeviceActionState"),c=require("../../../device-action/model/UserInteractionRequired"),D=require("../../../device-action/os/Errors"),o=require("../../../device-session/DeviceSessionState"),p=require("./GetDeviceStatusDeviceAction");describe("GetDeviceStatusDeviceAction",()=>{const k=jest.fn(),l=jest.fn(),h=jest.fn(),f=jest.fn(),O=jest.fn();function A(){return{getAppAndVersion:k,getDeviceSessionState:l,waitForDeviceUnlock:h,setDeviceSessionState:f,isDeviceOnboarded:O}}const{sendCommand:R,getDeviceSessionState:V,getDeviceSessionStateObservable:E}=(0,a.makeDeviceActionInternalApiMock)();beforeEach(()=>{jest.resetAllMocks(),O.mockReturnValue(!0)}),describe("without overriding `extractDependencies`",()=>{it("should run the device action with an unlocked device",r=>{const e=new p.GetDeviceStatusDeviceAction({input:{unlockTimeout:500}});V.mockReturnValue({sessionStateType:o.DeviceSessionStateType.Connected,deviceStatus:i.DeviceStatus.CONNECTED,deviceModelId:S.DeviceModelId.FLEX}),R.mockResolvedValue((0,v.CommandResultFactory)({data:{name:"BOLOS",version:"1.0.0"}}));const n=[{intermediateValue:{requiredUserInteraction:c.UserInteractionRequired.None},status:t.DeviceActionStatus.Pending},{output:{currentApp:"BOLOS",currentAppVersion:"1.0.0"},status:t.DeviceActionStatus.Completed}];(0,d.testDeviceActionStates)(e,n,(0,a.makeDeviceActionInternalApiMock)(),r)}),it("should run the device action with a locked device",r=>{const e=new p.GetDeviceStatusDeviceAction({input:{unlockTimeout:500}});V.mockReturnValue({sessionStateType:o.DeviceSessionStateType.ReadyWithoutSecureChannel,deviceStatus:i.DeviceStatus.LOCKED,currentApp:{name:"mockedCurrentApp",version:"1.0.0"},installedApps:[],deviceModelId:S.DeviceModelId.FLEX}),E.mockImplementation(()=>new u.Observable(s=>{const m=(0,u.interval)(50).subscribe({next:C=>{C>2?(s.next({sessionStateType:o.DeviceSessionStateType.ReadyWithoutSecureChannel,deviceStatus:i.DeviceStatus.CONNECTED,currentApp:{name:"mockedCurrentApp",version:"1.0.0"},installedApps:[],deviceModelId:S.DeviceModelId.FLEX}),s.complete()):s.next({sessionStateType:o.DeviceSessionStateType.ReadyWithoutSecureChannel,deviceStatus:i.DeviceStatus.LOCKED,currentApp:{name:"mockedCurrentApp",version:"1.0.0"},installedApps:[],deviceModelId:S.DeviceModelId.FLEX})}});return()=>{m.unsubscribe()}})),R.mockResolvedValue((0,v.CommandResultFactory)({data:{name:"BOLOS",version:"1.0.0"}}));const n=[{intermediateValue:{requiredUserInteraction:c.UserInteractionRequired.UnlockDevice},status:t.DeviceActionStatus.Pending},{intermediateValue:{requiredUserInteraction:c.UserInteractionRequired.None},status:t.DeviceActionStatus.Pending},{output:{currentApp:"BOLOS",currentAppVersion:"1.0.0"},status:t.DeviceActionStatus.Completed}];(0,d.testDeviceActionStates)(e,n,(0,a.makeDeviceActionInternalApiMock)(),r)})}),describe("success cases",()=>{it("should return the device status if the device is unlocked",r=>{l.mockReturnValue({sessionStateType:o.DeviceSessionStateType.ReadyWithoutSecureChannel,deviceStatus:i.DeviceStatus.CONNECTED,currentApp:{name:"mockedCurrentApp",version:"1.0.0"}}),k.mockResolvedValue((0,v.CommandResultFactory)({data:{name:"BOLOS",version:"1.0.0"}}));const e=new p.GetDeviceStatusDeviceAction({input:{unlockTimeout:void 0}});jest.spyOn(e,"extractDependencies").mockReturnValue(A());const n=[{intermediateValue:{requiredUserInteraction:c.UserInteractionRequired.None},status:t.DeviceActionStatus.Pending},{status:t.DeviceActionStatus.Completed,output:{currentApp:"BOLOS",currentAppVersion:"1.0.0"}}];(0,d.testDeviceActionStates)(e,n,(0,a.makeDeviceActionInternalApiMock)(),r)}),it("should return the device status if the device is locked and the user unlocks the device",r=>{l.mockReturnValue({sessionStateType:o.DeviceSessionStateType.ReadyWithoutSecureChannel,deviceStatus:i.DeviceStatus.LOCKED,currentApp:{name:"mockedCurrentApp",version:"1.0.0"}}),k.mockResolvedValue((0,v.CommandResultFactory)({data:{name:"BOLOS",version:"1.0.0"}})),h.mockImplementation(()=>new u.Observable(s=>{const m=(0,u.interval)(50).subscribe({next:C=>{C>2?(s.next({sessionStateType:o.DeviceSessionStateType.ReadyWithoutSecureChannel,deviceStatus:i.DeviceStatus.CONNECTED,currentApp:{name:"mockedCurrentApp",version:"1.0.0"}}),s.complete()):s.next({sessionStateType:o.DeviceSessionStateType.ReadyWithoutSecureChannel,deviceStatus:i.DeviceStatus.LOCKED,currentApp:{name:"mockedCurrentApp",version:"1.0.0"}})}});return()=>{m.unsubscribe()}}));const e=new p.GetDeviceStatusDeviceAction({input:{unlockTimeout:500}});jest.spyOn(e,"extractDependencies").mockReturnValue(A());const n=[{intermediateValue:{requiredUserInteraction:c.UserInteractionRequired.UnlockDevice},status:t.DeviceActionStatus.Pending},{intermediateValue:{requiredUserInteraction:c.UserInteractionRequired.None},status:t.DeviceActionStatus.Pending},{status:t.DeviceActionStatus.Completed,output:{currentApp:"BOLOS",currentAppVersion:"1.0.0"}}];(0,d.testDeviceActionStates)(e,n,(0,a.makeDeviceActionInternalApiMock)(),r)})}),describe("errors cases",()=>{it("should end in an error if the device is not onboarded",r=>{l.mockReturnValue({sessionStateType:o.DeviceSessionStateType.ReadyWithoutSecureChannel,deviceStatus:i.DeviceStatus.LOCKED,currentApp:{name:"mockedCurrentApp",version:"1.0.0"}}),O.mockReturnValue(!1);const e=new p.GetDeviceStatusDeviceAction({input:{unlockTimeout:500}});jest.spyOn(e,"extractDependencies").mockReturnValue(A());const n=[{error:new D.DeviceNotOnboardedError,status:t.DeviceActionStatus.Error}];(0,d.testDeviceActionStates)(e,n,(0,a.makeDeviceActionInternalApiMock)(),r)}),it("should end in an error if the device is locked and the user does not unlock",r=>{l.mockReturnValue({sessionStateType:o.DeviceSessionStateType.ReadyWithoutSecureChannel,deviceStatus:i.DeviceStatus.LOCKED,currentApp:{name:"mockedCurrentApp",version:"1.0.0"}}),E.mockImplementation(()=>new u.Observable(s=>{const m=(0,u.interval)(200).subscribe({next:()=>{s.next({sessionStateType:o.DeviceSessionStateType.ReadyWithoutSecureChannel,deviceStatus:i.DeviceStatus.LOCKED,currentApp:{name:"mockedCurrentApp",version:"1.0.0"},installedApps:[],deviceModelId:S.DeviceModelId.FLEX})}});return()=>{m.unsubscribe()}}));const e=new p.GetDeviceStatusDeviceAction({input:{unlockTimeout:500}});jest.spyOn(e,"extractDependencies").mockReturnValue(A());const n=[{intermediateValue:{requiredUserInteraction:c.UserInteractionRequired.UnlockDevice},status:t.DeviceActionStatus.Pending},{error:new D.DeviceLockedError("Device locked."),status:t.DeviceActionStatus.Error}];(0,d.testDeviceActionStates)(e,n,(0,a.makeDeviceActionInternalApiMock)(),r)}),it("should end in an error if the GetAppAndVersion command fails",r=>{l.mockReturnValue({sessionStateType:o.DeviceSessionStateType.ReadyWithoutSecureChannel,deviceStatus:i.DeviceStatus.LOCKED,currentApp:{name:"mockedCurrentApp",version:"1.0.0"}});const e=new y.GlobalCommandError({...y.GLOBAL_ERRORS[5501],errorCode:"5501"});k.mockResolvedValue((0,v.CommandResultFactory)({error:e})),h.mockImplementation(()=>new u.Observable(m=>{const C=(0,u.interval)(50).subscribe({next:b=>{b>2?(m.next({sessionStateType:o.DeviceSessionStateType.ReadyWithoutSecureChannel,deviceStatus:i.DeviceStatus.CONNECTED,currentApp:{name:"mockedCurrentApp",version:"1.0.0"}}),m.complete()):m.next({sessionStateType:o.DeviceSessionStateType.ReadyWithoutSecureChannel,deviceStatus:i.DeviceStatus.LOCKED,currentApp:{name:"mockedCurrentApp",version:"1.0.0"}})}});return()=>{C.unsubscribe()}}));const n=new p.GetDeviceStatusDeviceAction({input:{unlockTimeout:500}});jest.spyOn(n,"extractDependencies").mockReturnValue(A());const s=[{intermediateValue:{requiredUserInteraction:c.UserInteractionRequired.UnlockDevice},status:t.DeviceActionStatus.Pending},{intermediateValue:{requiredUserInteraction:c.UserInteractionRequired.None},status:t.DeviceActionStatus.Pending},{error:e,status:t.DeviceActionStatus.Error}];(0,d.testDeviceActionStates)(n,s,(0,a.makeDeviceActionInternalApiMock)(),r)}),it("should end in an error if getAppAndVersion actor throws an error",r=>{l.mockReturnValue({sessionStateType:o.DeviceSessionStateType.ReadyWithoutSecureChannel,deviceStatus:i.DeviceStatus.LOCKED,currentApp:{name:"mockedCurrentApp",version:"1.0.0"}}),k.mockImplementation(()=>{throw new D.UnknownDAError("error")}),h.mockImplementation(()=>new u.Observable(s=>{s.complete()}));const e=new p.GetDeviceStatusDeviceAction({input:{unlockTimeout:500}});jest.spyOn(e,"extractDependencies").mockReturnValue(A());const n=[{intermediateValue:{requiredUserInteraction:c.UserInteractionRequired.UnlockDevice},status:t.DeviceActionStatus.Pending},{intermediateValue:{requiredUserInteraction:c.UserInteractionRequired.None},status:t.DeviceActionStatus.Pending},{error:new D.UnknownDAError("error"),status:t.DeviceActionStatus.Error}];(0,d.testDeviceActionStates)(e,n,(0,a.makeDeviceActionInternalApiMock)(),r)})}),it("should emit a stopped state if the action is cancelled",r=>{V.mockReturnValue({sessionStateType:o.DeviceSessionStateType.ReadyWithoutSecureChannel,deviceStatus:i.DeviceStatus.CONNECTED,currentApp:{name:"mockedCurrentApp",version:"1.0.0"},installedApps:[],deviceModelId:S.DeviceModelId.FLEX}),R.mockResolvedValue((0,v.CommandResultFactory)({data:{name:"BOLOS",version:"1.0.0"}}));const e=new p.GetDeviceStatusDeviceAction({input:{unlockTimeout:500}}),n=[{status:t.DeviceActionStatus.Pending,intermediateValue:{requiredUserInteraction:c.UserInteractionRequired.None}},{status:t.DeviceActionStatus.Stopped}],{cancel:s}=(0,d.testDeviceActionStates)(e,n,(0,a.makeDeviceActionInternalApiMock)(),r);s()})});
|
1
|
+
"use strict";var d=require("rxjs"),S=require("../../../command/model/CommandResult"),y=require("../../../command/utils/GlobalCommandError"),D=require("../../../device/DeviceModel"),i=require("../../../device/DeviceStatus"),u=require("../../../device-action/__test-utils__/makeInternalApi"),p=require("../../../device-action/__test-utils__/testDeviceActionStates"),t=require("../../../device-action/model/DeviceActionState"),a=require("../../../device-action/model/UserInteractionRequired"),A=require("../../../device-action/os/Errors"),s=require("../../../device-session/DeviceSessionState"),m=require("./GetDeviceStatusDeviceAction");describe("GetDeviceStatusDeviceAction",()=>{const C=vi.fn(),l=vi.fn(),O=vi.fn(),f=vi.fn(),R=vi.fn();function k(){return{getAppAndVersion:C,getDeviceSessionState:l,waitForDeviceUnlock:O,setDeviceSessionState:f,isDeviceOnboarded:R}}const{sendCommand:V,getDeviceSessionState:E,getDeviceSessionStateObservable:w}=(0,u.makeDeviceActionInternalApiMock)();beforeEach(()=>{vi.resetAllMocks(),R.mockReturnValue(!0)}),describe("without overriding `extractDependencies`",()=>{it("should run the device action with an unlocked device",()=>new Promise((r,o)=>{const e=new m.GetDeviceStatusDeviceAction({input:{unlockTimeout:500}});E.mockReturnValue({sessionStateType:s.DeviceSessionStateType.Connected,deviceStatus:i.DeviceStatus.CONNECTED,deviceModelId:D.DeviceModelId.NANO_X}),V.mockResolvedValue((0,S.CommandResultFactory)({data:{name:"BOLOS",version:"1.0.0"}}));const n=[{intermediateValue:{requiredUserInteraction:a.UserInteractionRequired.None},status:t.DeviceActionStatus.Pending},{output:{currentApp:"BOLOS",currentAppVersion:"1.0.0"},status:t.DeviceActionStatus.Completed}];(0,p.testDeviceActionStates)(e,n,(0,u.makeDeviceActionInternalApiMock)(),{onDone:r,onError:o})})),it("should run the device action with a locked device",()=>new Promise((r,o)=>{const e=new m.GetDeviceStatusDeviceAction({input:{unlockTimeout:500}});E.mockReturnValue({sessionStateType:s.DeviceSessionStateType.ReadyWithoutSecureChannel,deviceStatus:i.DeviceStatus.LOCKED,currentApp:{name:"mockedCurrentApp",version:"1.0.0"},installedApps:[],deviceModelId:D.DeviceModelId.NANO_X}),w.mockImplementation(()=>new d.Observable(c=>{const v=(0,d.interval)(50).subscribe({next:h=>{h>2?(c.next({sessionStateType:s.DeviceSessionStateType.ReadyWithoutSecureChannel,deviceStatus:i.DeviceStatus.CONNECTED,currentApp:{name:"mockedCurrentApp",version:"1.0.0"},installedApps:[],deviceModelId:D.DeviceModelId.NANO_X}),c.complete()):c.next({sessionStateType:s.DeviceSessionStateType.ReadyWithoutSecureChannel,deviceStatus:i.DeviceStatus.LOCKED,currentApp:{name:"mockedCurrentApp",version:"1.0.0"},installedApps:[],deviceModelId:D.DeviceModelId.NANO_X})}});return()=>{v.unsubscribe()}})),V.mockResolvedValue((0,S.CommandResultFactory)({data:{name:"BOLOS",version:"1.0.0"}}));const n=[{intermediateValue:{requiredUserInteraction:a.UserInteractionRequired.UnlockDevice},status:t.DeviceActionStatus.Pending},{intermediateValue:{requiredUserInteraction:a.UserInteractionRequired.None},status:t.DeviceActionStatus.Pending},{output:{currentApp:"BOLOS",currentAppVersion:"1.0.0"},status:t.DeviceActionStatus.Completed}];(0,p.testDeviceActionStates)(e,n,(0,u.makeDeviceActionInternalApiMock)(),{onDone:r,onError:o})}))}),describe("success cases",()=>{it("should return the device status if the device is unlocked",()=>new Promise((r,o)=>{l.mockReturnValue({sessionStateType:s.DeviceSessionStateType.ReadyWithoutSecureChannel,deviceStatus:i.DeviceStatus.CONNECTED,currentApp:{name:"mockedCurrentApp",version:"1.0.0"}}),C.mockResolvedValue((0,S.CommandResultFactory)({data:{name:"BOLOS",version:"1.0.0"}}));const e=new m.GetDeviceStatusDeviceAction({input:{unlockTimeout:void 0}});vi.spyOn(e,"extractDependencies").mockReturnValue(k());const n=[{intermediateValue:{requiredUserInteraction:a.UserInteractionRequired.None},status:t.DeviceActionStatus.Pending},{status:t.DeviceActionStatus.Completed,output:{currentApp:"BOLOS",currentAppVersion:"1.0.0"}}];(0,p.testDeviceActionStates)(e,n,(0,u.makeDeviceActionInternalApiMock)(),{onDone:r,onError:o})})),it("should return the device status if the device is locked and the user unlocks the device",()=>new Promise((r,o)=>{l.mockReturnValue({sessionStateType:s.DeviceSessionStateType.ReadyWithoutSecureChannel,deviceStatus:i.DeviceStatus.LOCKED,currentApp:{name:"mockedCurrentApp",version:"1.0.0"}}),C.mockResolvedValue((0,S.CommandResultFactory)({data:{name:"BOLOS",version:"1.0.0"}})),O.mockImplementation(()=>new d.Observable(c=>{const v=(0,d.interval)(50).subscribe({next:h=>{h>2?(c.next({sessionStateType:s.DeviceSessionStateType.ReadyWithoutSecureChannel,deviceStatus:i.DeviceStatus.CONNECTED,currentApp:{name:"mockedCurrentApp",version:"1.0.0"}}),c.complete()):c.next({sessionStateType:s.DeviceSessionStateType.ReadyWithoutSecureChannel,deviceStatus:i.DeviceStatus.LOCKED,currentApp:{name:"mockedCurrentApp",version:"1.0.0"}})}});return()=>{v.unsubscribe()}}));const e=new m.GetDeviceStatusDeviceAction({input:{unlockTimeout:500}});vi.spyOn(e,"extractDependencies").mockReturnValue(k());const n=[{intermediateValue:{requiredUserInteraction:a.UserInteractionRequired.UnlockDevice},status:t.DeviceActionStatus.Pending},{intermediateValue:{requiredUserInteraction:a.UserInteractionRequired.None},status:t.DeviceActionStatus.Pending},{status:t.DeviceActionStatus.Completed,output:{currentApp:"BOLOS",currentAppVersion:"1.0.0"}}];(0,p.testDeviceActionStates)(e,n,(0,u.makeDeviceActionInternalApiMock)(),{onDone:r,onError:o})}))}),describe("errors cases",()=>{it("should end in an error if the device is not onboarded",()=>new Promise((r,o)=>{l.mockReturnValue({sessionStateType:s.DeviceSessionStateType.ReadyWithoutSecureChannel,deviceStatus:i.DeviceStatus.LOCKED,currentApp:{name:"mockedCurrentApp",version:"1.0.0"}}),R.mockReturnValue(!1);const e=new m.GetDeviceStatusDeviceAction({input:{unlockTimeout:500}});vi.spyOn(e,"extractDependencies").mockReturnValue(k());const n=[{error:new A.DeviceNotOnboardedError,status:t.DeviceActionStatus.Error}];(0,p.testDeviceActionStates)(e,n,(0,u.makeDeviceActionInternalApiMock)(),{onDone:r,onError:o})})),it("should end in an error if the device is locked and the user does not unlock",()=>new Promise((r,o)=>{l.mockReturnValue({sessionStateType:s.DeviceSessionStateType.ReadyWithoutSecureChannel,deviceStatus:i.DeviceStatus.LOCKED,currentApp:{name:"mockedCurrentApp",version:"1.0.0"}}),w.mockImplementation(()=>new d.Observable(c=>{const v=(0,d.interval)(200).subscribe({next:()=>{c.next({sessionStateType:s.DeviceSessionStateType.ReadyWithoutSecureChannel,deviceStatus:i.DeviceStatus.LOCKED,currentApp:{name:"mockedCurrentApp",version:"1.0.0"},installedApps:[],deviceModelId:D.DeviceModelId.NANO_X})}});return()=>{v.unsubscribe()}}));const e=new m.GetDeviceStatusDeviceAction({input:{unlockTimeout:500}});vi.spyOn(e,"extractDependencies").mockReturnValue(k());const n=[{intermediateValue:{requiredUserInteraction:a.UserInteractionRequired.UnlockDevice},status:t.DeviceActionStatus.Pending},{error:new A.DeviceLockedError("Device locked."),status:t.DeviceActionStatus.Error}];(0,p.testDeviceActionStates)(e,n,(0,u.makeDeviceActionInternalApiMock)(),{onDone:r,onError:o})})),it("should end in an error if the GetAppAndVersion command fails",()=>new Promise((r,o)=>{l.mockReturnValue({sessionStateType:s.DeviceSessionStateType.ReadyWithoutSecureChannel,deviceStatus:i.DeviceStatus.LOCKED,currentApp:{name:"mockedCurrentApp",version:"1.0.0"}});const e=new y.GlobalCommandError({...y.GLOBAL_ERRORS[5501],errorCode:"5501"});C.mockResolvedValue((0,S.CommandResultFactory)({error:e})),O.mockImplementation(()=>new d.Observable(v=>{const h=(0,d.interval)(50).subscribe({next:b=>{b>2?(v.next({sessionStateType:s.DeviceSessionStateType.ReadyWithoutSecureChannel,deviceStatus:i.DeviceStatus.CONNECTED,currentApp:{name:"mockedCurrentApp",version:"1.0.0"}}),v.complete()):v.next({sessionStateType:s.DeviceSessionStateType.ReadyWithoutSecureChannel,deviceStatus:i.DeviceStatus.LOCKED,currentApp:{name:"mockedCurrentApp",version:"1.0.0"}})}});return()=>{h.unsubscribe()}}));const n=new m.GetDeviceStatusDeviceAction({input:{unlockTimeout:500}});vi.spyOn(n,"extractDependencies").mockReturnValue(k());const c=[{intermediateValue:{requiredUserInteraction:a.UserInteractionRequired.UnlockDevice},status:t.DeviceActionStatus.Pending},{intermediateValue:{requiredUserInteraction:a.UserInteractionRequired.None},status:t.DeviceActionStatus.Pending},{error:e,status:t.DeviceActionStatus.Error}];(0,p.testDeviceActionStates)(n,c,(0,u.makeDeviceActionInternalApiMock)(),{onDone:r,onError:o})})),it("should end in an error if getAppAndVersion actor throws an error",()=>new Promise((r,o)=>{l.mockReturnValue({sessionStateType:s.DeviceSessionStateType.ReadyWithoutSecureChannel,deviceStatus:i.DeviceStatus.LOCKED,currentApp:{name:"mockedCurrentApp",version:"1.0.0"}}),C.mockImplementation(()=>{throw new A.UnknownDAError("error")}),O.mockImplementation(()=>new d.Observable(c=>{c.complete()}));const e=new m.GetDeviceStatusDeviceAction({input:{unlockTimeout:500}});vi.spyOn(e,"extractDependencies").mockReturnValue(k());const n=[{intermediateValue:{requiredUserInteraction:a.UserInteractionRequired.UnlockDevice},status:t.DeviceActionStatus.Pending},{intermediateValue:{requiredUserInteraction:a.UserInteractionRequired.None},status:t.DeviceActionStatus.Pending},{error:new A.UnknownDAError("error"),status:t.DeviceActionStatus.Error}];(0,p.testDeviceActionStates)(e,n,(0,u.makeDeviceActionInternalApiMock)(),{onDone:r,onError:o})}))}),it("should emit a stopped state if the action is cancelled",()=>new Promise((r,o)=>{E.mockReturnValue({sessionStateType:s.DeviceSessionStateType.ReadyWithoutSecureChannel,deviceStatus:i.DeviceStatus.CONNECTED,currentApp:{name:"mockedCurrentApp",version:"1.0.0"},installedApps:[],deviceModelId:D.DeviceModelId.NANO_X}),V.mockResolvedValue((0,S.CommandResultFactory)({data:{name:"BOLOS",version:"1.0.0"}}));const e=new m.GetDeviceStatusDeviceAction({input:{unlockTimeout:500}}),n=[{status:t.DeviceActionStatus.Pending,intermediateValue:{requiredUserInteraction:a.UserInteractionRequired.None}},{status:t.DeviceActionStatus.Stopped}],{cancel:c}=(0,p.testDeviceActionStates)(e,n,(0,u.makeDeviceActionInternalApiMock)(),{onDone:r,onError:o});c()}))});
|
2
2
|
//# sourceMappingURL=GetDeviceStatusDeviceAction.test.js.map
|
package/lib/cjs/src/api/device-action/os/GetDeviceStatus/GetDeviceStatusDeviceAction.test.js.map
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
{
|
2
2
|
"version": 3,
|
3
3
|
"sources": ["../../../../../../../src/api/device-action/os/GetDeviceStatus/GetDeviceStatusDeviceAction.test.ts"],
|
4
|
-
"sourcesContent": ["import { interval, Observable } from \"rxjs\";\n\nimport { CommandResultFactory } from \"@api/command/model/CommandResult\";\nimport {\n GLOBAL_ERRORS,\n GlobalCommandError,\n} from \"@api/command/utils/GlobalCommandError\";\nimport { DeviceModelId } from \"@api/device/DeviceModel\";\nimport { DeviceStatus } from \"@api/device/DeviceStatus\";\nimport { makeDeviceActionInternalApiMock } from \"@api/device-action/__test-utils__/makeInternalApi\";\nimport { testDeviceActionStates } from \"@api/device-action/__test-utils__/testDeviceActionStates\";\nimport { DeviceActionStatus } from \"@api/device-action/model/DeviceActionState\";\nimport { UserInteractionRequired } from \"@api/device-action/model/UserInteractionRequired\";\nimport {\n DeviceLockedError,\n DeviceNotOnboardedError,\n UnknownDAError,\n} from \"@api/device-action/os/Errors\";\nimport { DeviceSessionStateType } from \"@api/device-session/DeviceSessionState\";\n\nimport { GetDeviceStatusDeviceAction } from \"./GetDeviceStatusDeviceAction\";\nimport { type GetDeviceStatusDAState } from \"./types\";\n\ndescribe(\"GetDeviceStatusDeviceAction\", () => {\n const getAppAndVersionMock = jest.fn();\n const getDeviceSessionStateMock = jest.fn();\n const waitForDeviceUnlockMock = jest.fn();\n const setDeviceSessionState = jest.fn();\n const isDeviceOnboardedMock = jest.fn();\n\n function extractDependenciesMock() {\n return {\n getAppAndVersion: getAppAndVersionMock,\n getDeviceSessionState: getDeviceSessionStateMock,\n waitForDeviceUnlock: waitForDeviceUnlockMock,\n setDeviceSessionState: setDeviceSessionState,\n isDeviceOnboarded: isDeviceOnboardedMock,\n };\n }\n\n const {\n sendCommand: sendCommandMock,\n getDeviceSessionState: apiGetDeviceSessionStateMock,\n getDeviceSessionStateObservable: apiGetDeviceSessionStateObservableMock,\n } = makeDeviceActionInternalApiMock();\n beforeEach(() => {\n jest.resetAllMocks();\n isDeviceOnboardedMock.mockReturnValue(true);\n });\n\n describe(\"without overriding `extractDependencies`\", () => {\n it(\"should run the device action with an unlocked device\", (done) => {\n const getDeviceStateDeviceAction = new GetDeviceStatusDeviceAction({\n input: { unlockTimeout: 500 },\n });\n\n apiGetDeviceSessionStateMock.mockReturnValue({\n sessionStateType: DeviceSessionStateType.Connected,\n deviceStatus: DeviceStatus.CONNECTED,\n deviceModelId: DeviceModelId.FLEX,\n });\n\n sendCommandMock.mockResolvedValue(\n CommandResultFactory({\n data: {\n name: \"BOLOS\",\n version: \"1.0.0\",\n },\n }),\n );\n\n const expectedStates: Array<GetDeviceStatusDAState> = [\n {\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.None,\n },\n status: DeviceActionStatus.Pending,\n },\n {\n output: {\n currentApp: \"BOLOS\",\n currentAppVersion: \"1.0.0\",\n },\n status: DeviceActionStatus.Completed,\n },\n ];\n\n testDeviceActionStates(\n getDeviceStateDeviceAction,\n expectedStates,\n makeDeviceActionInternalApiMock(),\n done,\n );\n });\n\n it(\"should run the device action with a locked device\", (done) => {\n const getDeviceStateDeviceAction = new GetDeviceStatusDeviceAction({\n input: { unlockTimeout: 500 },\n });\n\n apiGetDeviceSessionStateMock.mockReturnValue({\n sessionStateType: DeviceSessionStateType.ReadyWithoutSecureChannel,\n deviceStatus: DeviceStatus.LOCKED,\n currentApp: { name: \"mockedCurrentApp\", version: \"1.0.0\" },\n installedApps: [],\n deviceModelId: DeviceModelId.FLEX,\n });\n\n apiGetDeviceSessionStateObservableMock.mockImplementation(\n () =>\n new Observable((o) => {\n const inner = interval(50).subscribe({\n next: (i) => {\n if (i > 2) {\n o.next({\n sessionStateType:\n DeviceSessionStateType.ReadyWithoutSecureChannel,\n deviceStatus: DeviceStatus.CONNECTED,\n currentApp: { name: \"mockedCurrentApp\", version: \"1.0.0\" },\n installedApps: [],\n deviceModelId: DeviceModelId.FLEX,\n });\n o.complete();\n } else {\n o.next({\n sessionStateType:\n DeviceSessionStateType.ReadyWithoutSecureChannel,\n deviceStatus: DeviceStatus.LOCKED,\n currentApp: { name: \"mockedCurrentApp\", version: \"1.0.0\" },\n installedApps: [],\n deviceModelId: DeviceModelId.FLEX,\n });\n }\n },\n });\n\n return () => {\n inner.unsubscribe();\n };\n }),\n );\n\n sendCommandMock.mockResolvedValue(\n CommandResultFactory({\n data: {\n name: \"BOLOS\",\n version: \"1.0.0\",\n },\n }),\n );\n\n const expectedStates: Array<GetDeviceStatusDAState> = [\n {\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.UnlockDevice,\n },\n status: DeviceActionStatus.Pending,\n },\n {\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.None,\n },\n status: DeviceActionStatus.Pending,\n },\n {\n output: {\n currentApp: \"BOLOS\",\n currentAppVersion: \"1.0.0\",\n },\n status: DeviceActionStatus.Completed,\n },\n ];\n\n testDeviceActionStates(\n getDeviceStateDeviceAction,\n expectedStates,\n makeDeviceActionInternalApiMock(),\n done,\n );\n });\n });\n\n describe(\"success cases\", () => {\n it(\"should return the device status if the device is unlocked\", (done) => {\n getDeviceSessionStateMock.mockReturnValue({\n sessionStateType: DeviceSessionStateType.ReadyWithoutSecureChannel,\n deviceStatus: DeviceStatus.CONNECTED,\n currentApp: { name: \"mockedCurrentApp\", version: \"1.0.0\" },\n });\n\n getAppAndVersionMock.mockResolvedValue(\n CommandResultFactory({\n data: {\n name: \"BOLOS\",\n version: \"1.0.0\",\n },\n }),\n );\n\n const getDeviceStateDeviceAction = new GetDeviceStatusDeviceAction({\n input: { unlockTimeout: undefined },\n });\n\n jest\n .spyOn(getDeviceStateDeviceAction, \"extractDependencies\")\n .mockReturnValue(extractDependenciesMock());\n\n const expectedStates: Array<GetDeviceStatusDAState> = [\n {\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.None,\n },\n status: DeviceActionStatus.Pending,\n },\n {\n status: DeviceActionStatus.Completed,\n output: {\n currentApp: \"BOLOS\",\n currentAppVersion: \"1.0.0\",\n },\n },\n ];\n\n testDeviceActionStates(\n getDeviceStateDeviceAction,\n expectedStates,\n makeDeviceActionInternalApiMock(),\n done,\n );\n });\n\n it(\"should return the device status if the device is locked and the user unlocks the device\", (done) => {\n getDeviceSessionStateMock.mockReturnValue({\n sessionStateType: DeviceSessionStateType.ReadyWithoutSecureChannel,\n deviceStatus: DeviceStatus.LOCKED,\n currentApp: { name: \"mockedCurrentApp\", version: \"1.0.0\" },\n });\n\n getAppAndVersionMock.mockResolvedValue(\n CommandResultFactory({\n data: {\n name: \"BOLOS\",\n version: \"1.0.0\",\n },\n }),\n );\n\n waitForDeviceUnlockMock.mockImplementation(\n () =>\n new Observable((o) => {\n const inner = interval(50).subscribe({\n next: (i) => {\n if (i > 2) {\n o.next({\n sessionStateType:\n DeviceSessionStateType.ReadyWithoutSecureChannel,\n deviceStatus: DeviceStatus.CONNECTED,\n currentApp: { name: \"mockedCurrentApp\", version: \"1.0.0\" },\n });\n o.complete();\n } else {\n o.next({\n sessionStateType:\n DeviceSessionStateType.ReadyWithoutSecureChannel,\n deviceStatus: DeviceStatus.LOCKED,\n currentApp: { name: \"mockedCurrentApp\", version: \"1.0.0\" },\n });\n }\n },\n });\n\n return () => {\n inner.unsubscribe();\n };\n }),\n );\n\n const getDeviceStateDeviceAction = new GetDeviceStatusDeviceAction({\n input: { unlockTimeout: 500 },\n });\n\n jest\n .spyOn(getDeviceStateDeviceAction, \"extractDependencies\")\n .mockReturnValue(extractDependenciesMock());\n\n const expectedStates: Array<GetDeviceStatusDAState> = [\n {\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.UnlockDevice,\n },\n status: DeviceActionStatus.Pending,\n },\n {\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.None,\n },\n status: DeviceActionStatus.Pending,\n },\n {\n status: DeviceActionStatus.Completed,\n output: {\n currentApp: \"BOLOS\",\n currentAppVersion: \"1.0.0\",\n },\n },\n ];\n\n testDeviceActionStates(\n getDeviceStateDeviceAction,\n expectedStates,\n makeDeviceActionInternalApiMock(),\n done,\n );\n });\n });\n\n describe(\"errors cases\", () => {\n it(\"should end in an error if the device is not onboarded\", (done) => {\n getDeviceSessionStateMock.mockReturnValue({\n sessionStateType: DeviceSessionStateType.ReadyWithoutSecureChannel,\n deviceStatus: DeviceStatus.LOCKED,\n currentApp: { name: \"mockedCurrentApp\", version: \"1.0.0\" },\n });\n isDeviceOnboardedMock.mockReturnValue(false);\n\n const getDeviceStateDeviceAction = new GetDeviceStatusDeviceAction({\n input: { unlockTimeout: 500 },\n });\n\n jest\n .spyOn(getDeviceStateDeviceAction, \"extractDependencies\")\n .mockReturnValue(extractDependenciesMock());\n\n const expectedStates: Array<GetDeviceStatusDAState> = [\n {\n error: new DeviceNotOnboardedError(),\n status: DeviceActionStatus.Error,\n },\n ];\n\n testDeviceActionStates(\n getDeviceStateDeviceAction,\n expectedStates,\n makeDeviceActionInternalApiMock(),\n done,\n );\n });\n\n it(\"should end in an error if the device is locked and the user does not unlock\", (done) => {\n getDeviceSessionStateMock.mockReturnValue({\n sessionStateType: DeviceSessionStateType.ReadyWithoutSecureChannel,\n deviceStatus: DeviceStatus.LOCKED,\n currentApp: { name: \"mockedCurrentApp\", version: \"1.0.0\" },\n });\n\n apiGetDeviceSessionStateObservableMock.mockImplementation(\n () =>\n new Observable((o) => {\n const inner = interval(200).subscribe({\n next: () => {\n o.next({\n sessionStateType:\n DeviceSessionStateType.ReadyWithoutSecureChannel,\n deviceStatus: DeviceStatus.LOCKED,\n currentApp: { name: \"mockedCurrentApp\", version: \"1.0.0\" },\n installedApps: [],\n deviceModelId: DeviceModelId.FLEX,\n });\n },\n });\n\n return () => {\n inner.unsubscribe();\n };\n }),\n );\n\n const getDeviceStateDeviceAction = new GetDeviceStatusDeviceAction({\n input: { unlockTimeout: 500 },\n });\n\n jest\n .spyOn(getDeviceStateDeviceAction, \"extractDependencies\")\n .mockReturnValue(extractDependenciesMock());\n\n const expectedStates: Array<GetDeviceStatusDAState> = [\n {\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.UnlockDevice,\n },\n status: DeviceActionStatus.Pending,\n },\n {\n error: new DeviceLockedError(\"Device locked.\"),\n status: DeviceActionStatus.Error,\n },\n ];\n\n testDeviceActionStates(\n getDeviceStateDeviceAction,\n expectedStates,\n makeDeviceActionInternalApiMock(),\n done,\n );\n });\n\n it(\"should end in an error if the GetAppAndVersion command fails\", (done) => {\n getDeviceSessionStateMock.mockReturnValue({\n sessionStateType: DeviceSessionStateType.ReadyWithoutSecureChannel,\n deviceStatus: DeviceStatus.LOCKED,\n currentApp: { name: \"mockedCurrentApp\", version: \"1.0.0\" },\n });\n\n const error = new GlobalCommandError({\n ...GLOBAL_ERRORS[\"5501\"],\n errorCode: \"5501\",\n });\n\n getAppAndVersionMock.mockResolvedValue(CommandResultFactory({ error }));\n\n waitForDeviceUnlockMock.mockImplementation(\n () =>\n new Observable((o) => {\n const inner = interval(50).subscribe({\n next: (i) => {\n if (i > 2) {\n o.next({\n sessionStateType:\n DeviceSessionStateType.ReadyWithoutSecureChannel,\n deviceStatus: DeviceStatus.CONNECTED,\n currentApp: { name: \"mockedCurrentApp\", version: \"1.0.0\" },\n });\n o.complete();\n } else {\n o.next({\n sessionStateType:\n DeviceSessionStateType.ReadyWithoutSecureChannel,\n deviceStatus: DeviceStatus.LOCKED,\n currentApp: { name: \"mockedCurrentApp\", version: \"1.0.0\" },\n });\n }\n },\n });\n\n return () => {\n inner.unsubscribe();\n };\n }),\n );\n\n const getDeviceStateDeviceAction = new GetDeviceStatusDeviceAction({\n input: { unlockTimeout: 500 },\n });\n\n jest\n .spyOn(getDeviceStateDeviceAction, \"extractDependencies\")\n .mockReturnValue(extractDependenciesMock());\n\n const expectedStates: Array<GetDeviceStatusDAState> = [\n {\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.UnlockDevice,\n },\n status: DeviceActionStatus.Pending,\n },\n {\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.None,\n },\n status: DeviceActionStatus.Pending,\n },\n {\n error,\n status: DeviceActionStatus.Error,\n },\n ];\n\n testDeviceActionStates(\n getDeviceStateDeviceAction,\n expectedStates,\n makeDeviceActionInternalApiMock(),\n done,\n );\n });\n\n it(\"should end in an error if getAppAndVersion actor throws an error\", (done) => {\n getDeviceSessionStateMock.mockReturnValue({\n sessionStateType: DeviceSessionStateType.ReadyWithoutSecureChannel,\n deviceStatus: DeviceStatus.LOCKED,\n currentApp: { name: \"mockedCurrentApp\", version: \"1.0.0\" },\n });\n\n getAppAndVersionMock.mockImplementation(() => {\n throw new UnknownDAError(\"error\");\n });\n\n waitForDeviceUnlockMock.mockImplementation(\n () =>\n new Observable((o) => {\n o.complete();\n }),\n );\n\n const getDeviceStateDeviceAction = new GetDeviceStatusDeviceAction({\n input: { unlockTimeout: 500 },\n });\n\n jest\n .spyOn(getDeviceStateDeviceAction, \"extractDependencies\")\n .mockReturnValue(extractDependenciesMock());\n\n const expectedStates: Array<GetDeviceStatusDAState> = [\n {\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.UnlockDevice,\n },\n status: DeviceActionStatus.Pending,\n },\n {\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.None,\n },\n status: DeviceActionStatus.Pending,\n },\n {\n error: new UnknownDAError(\"error\"),\n status: DeviceActionStatus.Error,\n },\n ];\n\n testDeviceActionStates(\n getDeviceStateDeviceAction,\n expectedStates,\n makeDeviceActionInternalApiMock(),\n done,\n );\n });\n });\n\n it(\"should emit a stopped state if the action is cancelled\", (done) => {\n apiGetDeviceSessionStateMock.mockReturnValue({\n sessionStateType: DeviceSessionStateType.ReadyWithoutSecureChannel,\n deviceStatus: DeviceStatus.CONNECTED,\n currentApp: { name: \"mockedCurrentApp\", version: \"1.0.0\" },\n installedApps: [],\n deviceModelId: DeviceModelId.FLEX,\n });\n\n sendCommandMock.mockResolvedValue(\n CommandResultFactory({\n data: {\n name: \"BOLOS\",\n version: \"1.0.0\",\n },\n }),\n );\n\n const getDeviceStateDeviceAction = new GetDeviceStatusDeviceAction({\n input: { unlockTimeout: 500 },\n });\n\n const expectedStates: Array<GetDeviceStatusDAState> = [\n {\n status: DeviceActionStatus.Pending, // get app and version\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.None,\n },\n },\n {\n status: DeviceActionStatus.Stopped,\n },\n ];\n\n const { cancel } = testDeviceActionStates(\n getDeviceStateDeviceAction,\n expectedStates,\n makeDeviceActionInternalApiMock(),\n done,\n );\n cancel();\n });\n});\n"],
|
5
|
-
"mappings": "aAAA,IAAAA,EAAqC,gBAErCC,EAAqC,4CACrCC,EAGO,iDACPC,EAA8B,mCAC9BC,EAA6B,oCAC7BC,EAAgD,6DAChDC,EAAuC,oEACvCC,EAAmC,sDACnCC,EAAwC,4DACxCC,EAIO,wCACPC,EAAuC,kDAEvCC,EAA4C,yCAG5C,SAAS,8BAA+B,IAAM,CAC5C,MAAMC,EAAuB,
|
6
|
-
"names": ["import_rxjs", "import_CommandResult", "import_GlobalCommandError", "import_DeviceModel", "import_DeviceStatus", "import_makeInternalApi", "import_testDeviceActionStates", "import_DeviceActionState", "import_UserInteractionRequired", "import_Errors", "import_DeviceSessionState", "import_GetDeviceStatusDeviceAction", "getAppAndVersionMock", "getDeviceSessionStateMock", "waitForDeviceUnlockMock", "setDeviceSessionState", "isDeviceOnboardedMock", "extractDependenciesMock", "sendCommandMock", "apiGetDeviceSessionStateMock", "apiGetDeviceSessionStateObservableMock", "
|
4
|
+
"sourcesContent": ["import { interval, Observable } from \"rxjs\";\n\nimport { CommandResultFactory } from \"@api/command/model/CommandResult\";\nimport {\n GLOBAL_ERRORS,\n GlobalCommandError,\n} from \"@api/command/utils/GlobalCommandError\";\nimport { DeviceModelId } from \"@api/device/DeviceModel\";\nimport { DeviceStatus } from \"@api/device/DeviceStatus\";\nimport { makeDeviceActionInternalApiMock } from \"@api/device-action/__test-utils__/makeInternalApi\";\nimport { testDeviceActionStates } from \"@api/device-action/__test-utils__/testDeviceActionStates\";\nimport { DeviceActionStatus } from \"@api/device-action/model/DeviceActionState\";\nimport { UserInteractionRequired } from \"@api/device-action/model/UserInteractionRequired\";\nimport {\n DeviceLockedError,\n DeviceNotOnboardedError,\n UnknownDAError,\n} from \"@api/device-action/os/Errors\";\nimport { DeviceSessionStateType } from \"@api/device-session/DeviceSessionState\";\n\nimport { GetDeviceStatusDeviceAction } from \"./GetDeviceStatusDeviceAction\";\nimport { type GetDeviceStatusDAState } from \"./types\";\n\ndescribe(\"GetDeviceStatusDeviceAction\", () => {\n const getAppAndVersionMock = vi.fn();\n const getDeviceSessionStateMock = vi.fn();\n const waitForDeviceUnlockMock = vi.fn();\n const setDeviceSessionState = vi.fn();\n const isDeviceOnboardedMock = vi.fn();\n\n function extractDependenciesMock() {\n return {\n getAppAndVersion: getAppAndVersionMock,\n getDeviceSessionState: getDeviceSessionStateMock,\n waitForDeviceUnlock: waitForDeviceUnlockMock,\n setDeviceSessionState: setDeviceSessionState,\n isDeviceOnboarded: isDeviceOnboardedMock,\n };\n }\n\n const {\n sendCommand: sendCommandMock,\n getDeviceSessionState: apiGetDeviceSessionStateMock,\n getDeviceSessionStateObservable: apiGetDeviceSessionStateObservableMock,\n } = makeDeviceActionInternalApiMock();\n beforeEach(() => {\n vi.resetAllMocks();\n isDeviceOnboardedMock.mockReturnValue(true);\n });\n\n describe(\"without overriding `extractDependencies`\", () => {\n it(\"should run the device action with an unlocked device\", () =>\n new Promise<void>((resolve, reject) => {\n const getDeviceStateDeviceAction = new GetDeviceStatusDeviceAction({\n input: { unlockTimeout: 500 },\n });\n\n apiGetDeviceSessionStateMock.mockReturnValue({\n sessionStateType: DeviceSessionStateType.Connected,\n deviceStatus: DeviceStatus.CONNECTED,\n deviceModelId: DeviceModelId.NANO_X,\n });\n\n sendCommandMock.mockResolvedValue(\n CommandResultFactory({\n data: {\n name: \"BOLOS\",\n version: \"1.0.0\",\n },\n }),\n );\n\n const expectedStates: Array<GetDeviceStatusDAState> = [\n {\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.None,\n },\n status: DeviceActionStatus.Pending,\n },\n {\n output: {\n currentApp: \"BOLOS\",\n currentAppVersion: \"1.0.0\",\n },\n status: DeviceActionStatus.Completed,\n },\n ];\n\n testDeviceActionStates(\n getDeviceStateDeviceAction,\n expectedStates,\n makeDeviceActionInternalApiMock(),\n {\n onDone: resolve,\n onError: reject,\n },\n );\n }));\n\n it(\"should run the device action with a locked device\", () =>\n new Promise<void>((resolve, reject) => {\n const getDeviceStateDeviceAction = new GetDeviceStatusDeviceAction({\n input: { unlockTimeout: 500 },\n });\n\n apiGetDeviceSessionStateMock.mockReturnValue({\n sessionStateType: DeviceSessionStateType.ReadyWithoutSecureChannel,\n deviceStatus: DeviceStatus.LOCKED,\n currentApp: { name: \"mockedCurrentApp\", version: \"1.0.0\" },\n installedApps: [],\n deviceModelId: DeviceModelId.NANO_X,\n });\n\n apiGetDeviceSessionStateObservableMock.mockImplementation(\n () =>\n new Observable((o) => {\n const inner = interval(50).subscribe({\n next: (i) => {\n if (i > 2) {\n o.next({\n sessionStateType:\n DeviceSessionStateType.ReadyWithoutSecureChannel,\n deviceStatus: DeviceStatus.CONNECTED,\n currentApp: {\n name: \"mockedCurrentApp\",\n version: \"1.0.0\",\n },\n installedApps: [],\n deviceModelId: DeviceModelId.NANO_X,\n });\n o.complete();\n } else {\n o.next({\n sessionStateType:\n DeviceSessionStateType.ReadyWithoutSecureChannel,\n deviceStatus: DeviceStatus.LOCKED,\n currentApp: {\n name: \"mockedCurrentApp\",\n version: \"1.0.0\",\n },\n installedApps: [],\n deviceModelId: DeviceModelId.NANO_X,\n });\n }\n },\n });\n\n return () => {\n inner.unsubscribe();\n };\n }),\n );\n\n sendCommandMock.mockResolvedValue(\n CommandResultFactory({\n data: {\n name: \"BOLOS\",\n version: \"1.0.0\",\n },\n }),\n );\n\n const expectedStates: Array<GetDeviceStatusDAState> = [\n {\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.UnlockDevice,\n },\n status: DeviceActionStatus.Pending,\n },\n {\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.None,\n },\n status: DeviceActionStatus.Pending,\n },\n {\n output: {\n currentApp: \"BOLOS\",\n currentAppVersion: \"1.0.0\",\n },\n status: DeviceActionStatus.Completed,\n },\n ];\n\n testDeviceActionStates(\n getDeviceStateDeviceAction,\n expectedStates,\n makeDeviceActionInternalApiMock(),\n {\n onDone: resolve,\n onError: reject,\n },\n );\n }));\n });\n\n describe(\"success cases\", () => {\n it(\"should return the device status if the device is unlocked\", () =>\n new Promise<void>((resolve, reject) => {\n getDeviceSessionStateMock.mockReturnValue({\n sessionStateType: DeviceSessionStateType.ReadyWithoutSecureChannel,\n deviceStatus: DeviceStatus.CONNECTED,\n currentApp: { name: \"mockedCurrentApp\", version: \"1.0.0\" },\n });\n\n getAppAndVersionMock.mockResolvedValue(\n CommandResultFactory({\n data: {\n name: \"BOLOS\",\n version: \"1.0.0\",\n },\n }),\n );\n\n const getDeviceStateDeviceAction = new GetDeviceStatusDeviceAction({\n input: { unlockTimeout: undefined },\n });\n\n vi.spyOn(\n getDeviceStateDeviceAction,\n \"extractDependencies\",\n ).mockReturnValue(extractDependenciesMock());\n\n const expectedStates: Array<GetDeviceStatusDAState> = [\n {\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.None,\n },\n status: DeviceActionStatus.Pending,\n },\n {\n status: DeviceActionStatus.Completed,\n output: {\n currentApp: \"BOLOS\",\n currentAppVersion: \"1.0.0\",\n },\n },\n ];\n\n testDeviceActionStates(\n getDeviceStateDeviceAction,\n expectedStates,\n makeDeviceActionInternalApiMock(),\n {\n onDone: resolve,\n onError: reject,\n },\n );\n }));\n\n it(\"should return the device status if the device is locked and the user unlocks the device\", () =>\n new Promise<void>((resolve, reject) => {\n getDeviceSessionStateMock.mockReturnValue({\n sessionStateType: DeviceSessionStateType.ReadyWithoutSecureChannel,\n deviceStatus: DeviceStatus.LOCKED,\n currentApp: { name: \"mockedCurrentApp\", version: \"1.0.0\" },\n });\n\n getAppAndVersionMock.mockResolvedValue(\n CommandResultFactory({\n data: {\n name: \"BOLOS\",\n version: \"1.0.0\",\n },\n }),\n );\n\n waitForDeviceUnlockMock.mockImplementation(\n () =>\n new Observable((o) => {\n const inner = interval(50).subscribe({\n next: (i) => {\n if (i > 2) {\n o.next({\n sessionStateType:\n DeviceSessionStateType.ReadyWithoutSecureChannel,\n deviceStatus: DeviceStatus.CONNECTED,\n currentApp: {\n name: \"mockedCurrentApp\",\n version: \"1.0.0\",\n },\n });\n o.complete();\n } else {\n o.next({\n sessionStateType:\n DeviceSessionStateType.ReadyWithoutSecureChannel,\n deviceStatus: DeviceStatus.LOCKED,\n currentApp: {\n name: \"mockedCurrentApp\",\n version: \"1.0.0\",\n },\n });\n }\n },\n });\n\n return () => {\n inner.unsubscribe();\n };\n }),\n );\n\n const getDeviceStateDeviceAction = new GetDeviceStatusDeviceAction({\n input: { unlockTimeout: 500 },\n });\n\n vi.spyOn(\n getDeviceStateDeviceAction,\n \"extractDependencies\",\n ).mockReturnValue(extractDependenciesMock());\n\n const expectedStates: Array<GetDeviceStatusDAState> = [\n {\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.UnlockDevice,\n },\n status: DeviceActionStatus.Pending,\n },\n {\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.None,\n },\n status: DeviceActionStatus.Pending,\n },\n {\n status: DeviceActionStatus.Completed,\n output: {\n currentApp: \"BOLOS\",\n currentAppVersion: \"1.0.0\",\n },\n },\n ];\n\n testDeviceActionStates(\n getDeviceStateDeviceAction,\n expectedStates,\n makeDeviceActionInternalApiMock(),\n {\n onDone: resolve,\n onError: reject,\n },\n );\n }));\n });\n\n describe(\"errors cases\", () => {\n it(\"should end in an error if the device is not onboarded\", () =>\n new Promise<void>((resolve, reject) => {\n getDeviceSessionStateMock.mockReturnValue({\n sessionStateType: DeviceSessionStateType.ReadyWithoutSecureChannel,\n deviceStatus: DeviceStatus.LOCKED,\n currentApp: { name: \"mockedCurrentApp\", version: \"1.0.0\" },\n });\n isDeviceOnboardedMock.mockReturnValue(false);\n\n const getDeviceStateDeviceAction = new GetDeviceStatusDeviceAction({\n input: { unlockTimeout: 500 },\n });\n\n vi.spyOn(\n getDeviceStateDeviceAction,\n \"extractDependencies\",\n ).mockReturnValue(extractDependenciesMock());\n\n const expectedStates: Array<GetDeviceStatusDAState> = [\n {\n error: new DeviceNotOnboardedError(),\n status: DeviceActionStatus.Error,\n },\n ];\n\n testDeviceActionStates(\n getDeviceStateDeviceAction,\n expectedStates,\n makeDeviceActionInternalApiMock(),\n {\n onDone: resolve,\n onError: reject,\n },\n );\n }));\n\n it(\"should end in an error if the device is locked and the user does not unlock\", () =>\n new Promise<void>((resolve, reject) => {\n getDeviceSessionStateMock.mockReturnValue({\n sessionStateType: DeviceSessionStateType.ReadyWithoutSecureChannel,\n deviceStatus: DeviceStatus.LOCKED,\n currentApp: { name: \"mockedCurrentApp\", version: \"1.0.0\" },\n });\n\n apiGetDeviceSessionStateObservableMock.mockImplementation(\n () =>\n new Observable((o) => {\n const inner = interval(200).subscribe({\n next: () => {\n o.next({\n sessionStateType:\n DeviceSessionStateType.ReadyWithoutSecureChannel,\n deviceStatus: DeviceStatus.LOCKED,\n currentApp: { name: \"mockedCurrentApp\", version: \"1.0.0\" },\n installedApps: [],\n deviceModelId: DeviceModelId.NANO_X,\n });\n },\n });\n\n return () => {\n inner.unsubscribe();\n };\n }),\n );\n\n const getDeviceStateDeviceAction = new GetDeviceStatusDeviceAction({\n input: { unlockTimeout: 500 },\n });\n\n vi.spyOn(\n getDeviceStateDeviceAction,\n \"extractDependencies\",\n ).mockReturnValue(extractDependenciesMock());\n\n const expectedStates: Array<GetDeviceStatusDAState> = [\n {\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.UnlockDevice,\n },\n status: DeviceActionStatus.Pending,\n },\n {\n error: new DeviceLockedError(\"Device locked.\"),\n status: DeviceActionStatus.Error,\n },\n ];\n\n testDeviceActionStates(\n getDeviceStateDeviceAction,\n expectedStates,\n makeDeviceActionInternalApiMock(),\n {\n onDone: resolve,\n onError: reject,\n },\n );\n }));\n\n it(\"should end in an error if the GetAppAndVersion command fails\", () =>\n new Promise<void>((resolve, reject) => {\n getDeviceSessionStateMock.mockReturnValue({\n sessionStateType: DeviceSessionStateType.ReadyWithoutSecureChannel,\n deviceStatus: DeviceStatus.LOCKED,\n currentApp: { name: \"mockedCurrentApp\", version: \"1.0.0\" },\n });\n\n const error = new GlobalCommandError({\n ...GLOBAL_ERRORS[\"5501\"],\n errorCode: \"5501\",\n });\n\n getAppAndVersionMock.mockResolvedValue(CommandResultFactory({ error }));\n\n waitForDeviceUnlockMock.mockImplementation(\n () =>\n new Observable((o) => {\n const inner = interval(50).subscribe({\n next: (i) => {\n if (i > 2) {\n o.next({\n sessionStateType:\n DeviceSessionStateType.ReadyWithoutSecureChannel,\n deviceStatus: DeviceStatus.CONNECTED,\n currentApp: {\n name: \"mockedCurrentApp\",\n version: \"1.0.0\",\n },\n });\n o.complete();\n } else {\n o.next({\n sessionStateType:\n DeviceSessionStateType.ReadyWithoutSecureChannel,\n deviceStatus: DeviceStatus.LOCKED,\n currentApp: {\n name: \"mockedCurrentApp\",\n version: \"1.0.0\",\n },\n });\n }\n },\n });\n\n return () => {\n inner.unsubscribe();\n };\n }),\n );\n\n const getDeviceStateDeviceAction = new GetDeviceStatusDeviceAction({\n input: { unlockTimeout: 500 },\n });\n\n vi.spyOn(\n getDeviceStateDeviceAction,\n \"extractDependencies\",\n ).mockReturnValue(extractDependenciesMock());\n\n const expectedStates: Array<GetDeviceStatusDAState> = [\n {\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.UnlockDevice,\n },\n status: DeviceActionStatus.Pending,\n },\n {\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.None,\n },\n status: DeviceActionStatus.Pending,\n },\n {\n error,\n status: DeviceActionStatus.Error,\n },\n ];\n\n testDeviceActionStates(\n getDeviceStateDeviceAction,\n expectedStates,\n makeDeviceActionInternalApiMock(),\n {\n onDone: resolve,\n onError: reject,\n },\n );\n }));\n\n it(\"should end in an error if getAppAndVersion actor throws an error\", () =>\n new Promise<void>((resolve, reject) => {\n getDeviceSessionStateMock.mockReturnValue({\n sessionStateType: DeviceSessionStateType.ReadyWithoutSecureChannel,\n deviceStatus: DeviceStatus.LOCKED,\n currentApp: { name: \"mockedCurrentApp\", version: \"1.0.0\" },\n });\n\n getAppAndVersionMock.mockImplementation(() => {\n throw new UnknownDAError(\"error\");\n });\n\n waitForDeviceUnlockMock.mockImplementation(\n () =>\n new Observable((o) => {\n o.complete();\n }),\n );\n\n const getDeviceStateDeviceAction = new GetDeviceStatusDeviceAction({\n input: { unlockTimeout: 500 },\n });\n\n vi.spyOn(\n getDeviceStateDeviceAction,\n \"extractDependencies\",\n ).mockReturnValue(extractDependenciesMock());\n\n const expectedStates: Array<GetDeviceStatusDAState> = [\n {\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.UnlockDevice,\n },\n status: DeviceActionStatus.Pending,\n },\n {\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.None,\n },\n status: DeviceActionStatus.Pending,\n },\n {\n error: new UnknownDAError(\"error\"),\n status: DeviceActionStatus.Error,\n },\n ];\n\n testDeviceActionStates(\n getDeviceStateDeviceAction,\n expectedStates,\n makeDeviceActionInternalApiMock(),\n {\n onDone: resolve,\n onError: reject,\n },\n );\n }));\n });\n\n it(\"should emit a stopped state if the action is cancelled\", () =>\n new Promise<void>((resolve, reject) => {\n apiGetDeviceSessionStateMock.mockReturnValue({\n sessionStateType: DeviceSessionStateType.ReadyWithoutSecureChannel,\n deviceStatus: DeviceStatus.CONNECTED,\n currentApp: { name: \"mockedCurrentApp\", version: \"1.0.0\" },\n installedApps: [],\n deviceModelId: DeviceModelId.NANO_X,\n });\n\n sendCommandMock.mockResolvedValue(\n CommandResultFactory({\n data: {\n name: \"BOLOS\",\n version: \"1.0.0\",\n },\n }),\n );\n\n const getDeviceStateDeviceAction = new GetDeviceStatusDeviceAction({\n input: { unlockTimeout: 500 },\n });\n\n const expectedStates: Array<GetDeviceStatusDAState> = [\n {\n status: DeviceActionStatus.Pending, // get app and version\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.None,\n },\n },\n {\n status: DeviceActionStatus.Stopped,\n },\n ];\n\n const { cancel } = testDeviceActionStates(\n getDeviceStateDeviceAction,\n expectedStates,\n makeDeviceActionInternalApiMock(),\n {\n onD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,SAAS,CACb,CAAC,CACL,EAEA,MAAMF,EAA6B,IAAI,8BAA4B,CACjE,MAAO,CAAE,cAAe,GAAI,CAC9B,CAAC,EAED,GAAG,MACDA,EACA,qBACF,EAAE,gBAAgBN,EAAwB,CAAC,EAE3C,MAAMO,EAAgD,CACpD,CACE,kBAAmB,CACjB,wBAAyB,0BAAwB,YACnD,EACA,OAAQ,qBAAmB,OAC7B,EACA,CACE,kBAAmB,CACjB,wBAAyB,0BAAwB,IACnD,EACA,OAAQ,qBAAmB,OAC7B,EACA,CACE,MAAO,IAAI,iBAAe,OAAO,EACjC,OAAQ,qBAAmB,KAC7B,CACF,KAEA,0BACED,EACAC,KACA,mCAAgC,EAChC,CACE,OAAQH,EACR,QAASC,CACX,CACF,CACF,CAAC,CAAC,CACN,CAAC,EAED,GAAG,yDAA0D,IAC3D,IAAI,QAAc,CAACD,EAASC,IAAW,CACrCH,EAA6B,gBAAgB,CAC3C,iBAAkB,yBAAuB,0BACzC,aAAc,eAAa,UAC3B,WAAY,CAAE,KAAM,mBAAoB,QAAS,OAAQ,EACzD,cAAe,CAAC,EAChB,cAAe,gBAAc,MAC/B,CAAC,EAEDD,EAAgB,qBACd,wBAAqB,CACnB,KAAM,CACJ,KAAM,QACN,QAAS,OACX,CACF,CAAC,CACH,EAEA,MAAMK,EAA6B,IAAI,8BAA4B,CACjE,MAAO,CAAE,cAAe,GAAI,CAC9B,CAAC,EAEKC,EAAgD,CACpD,CACE,OAAQ,qBAAmB,QAC3B,kBAAmB,CACjB,wBAAyB,0BAAwB,IACnD,CACF,EACA,CACE,OAAQ,qBAAmB,OAC7B,CACF,EAEM,CAAE,OAAAK,CAAO,KAAI,0BACjBN,EACAC,KACA,mCAAgC,EAChC,CACE,OAAQH,EACR,QAASC,CACX,CACF,EACAO,EAAO,CACT,CAAC,CAAC,CACN,CAAC",
|
6
|
+
"names": ["import_rxjs", "import_CommandResult", "import_GlobalCommandError", "import_DeviceModel", "import_DeviceStatus", "import_makeInternalApi", "import_testDeviceActionStates", "import_DeviceActionState", "import_UserInteractionRequired", "import_Errors", "import_DeviceSessionState", "import_GetDeviceStatusDeviceAction", "getAppAndVersionMock", "getDeviceSessionStateMock", "waitForDeviceUnlockMock", "setDeviceSessionState", "isDeviceOnboardedMock", "extractDependenciesMock", "sendCommandMock", "apiGetDeviceSessionStateMock", "apiGetDeviceSessionStateObservableMock", "resolve", "reject", "getDeviceStateDeviceAction", "expectedStates", "o", "inner", "i", "error", "cancel"]
|
7
7
|
}
|
@@ -1,2 +1,2 @@
|
|
1
|
-
"use strict";var
|
1
|
+
"use strict";var a=require("../../../command/model/CommandResult"),h=require("../../../command/utils/GlobalCommandError"),S=require("../../../device/DeviceModel"),c=require("../../../device/DeviceStatus"),s=require("../../../device-action/__test-utils__/makeInternalApi"),d=require("../../../device-action/__test-utils__/setupTestMachine"),u=require("../../../device-action/__test-utils__/testDeviceActionStates"),e=require("../../../device-action/model/DeviceActionState"),t=require("../../../device-action/model/UserInteractionRequired"),V=require("../../../device-action/os/Errors"),p=require("../../../device-session/DeviceSessionState"),N=require("../../../../../src"),m=require("./GoToDashboardDeviceAction");vi.mock("@api/device-action/os/GetDeviceStatus/GetDeviceStatusDeviceAction");describe("GoToDashboardDeviceAction",()=>{const v=vi.fn(),D=vi.fn(),l=vi.fn(),T=vi.fn();function A(){return{closeApp:v,getAppAndVersion:D,getDeviceSessionState:l,setDeviceSessionState:T}}const{sendCommand:g,getDeviceSessionState:k}=(0,s.makeDeviceActionInternalApiMock)();beforeEach(()=>{vi.resetAllMocks()}),describe("without overriding `extractDependencies`",()=>{it("should run the device action with device already on dashboard",()=>new Promise((r,i)=>{(0,d.setupGetDeviceStatusMock)();const n=new m.GoToDashboardDeviceAction({input:{unlockTimeout:500}});k.mockReturnValue({sessionStateType:p.DeviceSessionStateType.ReadyWithoutSecureChannel,deviceStatus:c.DeviceStatus.CONNECTED,currentApp:{name:"BOLOS",version:"1.5.0"},installedApps:[],deviceModelId:S.DeviceModelId.NANO_X});const o=[{intermediateValue:{requiredUserInteraction:t.UserInteractionRequired.None},status:e.DeviceActionStatus.Pending},{intermediateValue:{requiredUserInteraction:t.UserInteractionRequired.None},status:e.DeviceActionStatus.Pending},{output:void 0,status:e.DeviceActionStatus.Completed}];(0,u.testDeviceActionStates)(n,o,(0,s.makeDeviceActionInternalApiMock)(),{onDone:r,onError:i})})),it("should run the device action with device not on dashboard",()=>new Promise((r,i)=>{(0,d.setupGetDeviceStatusMock)([{currentApp:"Bitcoin",currentAppVersion:"1.0.0"}]);const n=new m.GoToDashboardDeviceAction({input:{unlockTimeout:500}});k.mockReturnValue({sessionStateType:p.DeviceSessionStateType.ReadyWithoutSecureChannel,deviceStatus:c.DeviceStatus.CONNECTED,currentApp:{name:"Bitcoin",version:"1.0.0"},installedApps:[],deviceModelId:S.DeviceModelId.NANO_X}),g.mockResolvedValueOnce((0,a.CommandResultFactory)({data:void 0})).mockResolvedValueOnce((0,a.CommandResultFactory)({data:{name:"BOLOS",version:"1.5.0"}}));const o=[{intermediateValue:{requiredUserInteraction:t.UserInteractionRequired.None},status:e.DeviceActionStatus.Pending},{intermediateValue:{requiredUserInteraction:t.UserInteractionRequired.None},status:e.DeviceActionStatus.Pending},{intermediateValue:{requiredUserInteraction:t.UserInteractionRequired.None},status:e.DeviceActionStatus.Pending},{intermediateValue:{requiredUserInteraction:t.UserInteractionRequired.None},status:e.DeviceActionStatus.Pending},{output:void 0,status:e.DeviceActionStatus.Completed}];(0,u.testDeviceActionStates)(n,o,(0,s.makeDeviceActionInternalApiMock)(),{onDone:r,onError:i})}))}),describe("success cases",()=>{it("should success if the device is already on dashboard",()=>new Promise((r,i)=>{(0,d.setupGetDeviceStatusMock)();const n=new m.GoToDashboardDeviceAction({input:{unlockTimeout:500}});l.mockReturnValue({sessionStateType:p.DeviceSessionStateType.Connected,deviceStatus:c.DeviceStatus.CONNECTED,currentApp:{name:"BOLOS",version:"1.5.0"}}),D.mockReturnValue({app:"BOLOS",version:"1.5.0"}),vi.spyOn(n,"extractDependencies").mockReturnValue(A());const o=[{intermediateValue:{requiredUserInteraction:t.UserInteractionRequired.None},status:e.DeviceActionStatus.Pending},{intermediateValue:{requiredUserInteraction:t.UserInteractionRequired.None},status:e.DeviceActionStatus.Pending},{output:void 0,status:e.DeviceActionStatus.Completed}];(0,u.testDeviceActionStates)(n,o,(0,s.makeDeviceActionInternalApiMock)(),{onDone:r,onError:i})})),it("should success if the device is not on dashboard",()=>new Promise((r,i)=>{(0,d.setupGetDeviceStatusMock)();const n=new m.GoToDashboardDeviceAction({input:{unlockTimeout:500}});vi.spyOn(n,"extractDependencies").mockReturnValue(A()),l.mockReturnValue({sessionStateType:p.DeviceSessionStateType.Connected,deviceStatus:c.DeviceStatus.CONNECTED}),v.mockResolvedValue((0,a.CommandResultFactory)({data:void 0})),D.mockReturnValue((0,a.CommandResultFactory)({data:{name:"BOLOS",version:"1.5.0"}}));const o=[{intermediateValue:{requiredUserInteraction:t.UserInteractionRequired.None},status:e.DeviceActionStatus.Pending},{intermediateValue:{requiredUserInteraction:t.UserInteractionRequired.None},status:e.DeviceActionStatus.Pending},{output:void 0,status:e.DeviceActionStatus.Completed}];(0,u.testDeviceActionStates)(n,o,(0,s.makeDeviceActionInternalApiMock)(),{onDone:r,onError:i})}))}),describe("error cases",()=>{it("should return an error if GetDeviceStatus return an error",()=>new Promise((r,i)=>{(0,d.setupGetDeviceStatusMock)([new V.UnknownDAError("Unknown error")]);const n=new m.GoToDashboardDeviceAction({input:{unlockTimeout:500}});k.mockReturnValue({sessionStateType:p.DeviceSessionStateType.ReadyWithoutSecureChannel,deviceStatus:c.DeviceStatus.CONNECTED,currentApp:{name:"BOLOS",version:"1.5.0"},installedApps:[],deviceModelId:S.DeviceModelId.NANO_X});const o=[{intermediateValue:{requiredUserInteraction:t.UserInteractionRequired.None},status:e.DeviceActionStatus.Pending},{intermediateValue:{requiredUserInteraction:t.UserInteractionRequired.None},status:e.DeviceActionStatus.Pending},{status:e.DeviceActionStatus.Error,error:new V.UnknownDAError("Unknown error")}];(0,u.testDeviceActionStates)(n,o,(0,s.makeDeviceActionInternalApiMock)(),{onDone:r,onError:i})})),describe("not on dashboard",()=>{it("should return an error if closeApp fails",()=>new Promise((r,i)=>{(0,d.setupGetDeviceStatusMock)([{currentApp:"Bitcoin",currentAppVersion:"1.0.0"}]);const n=new m.GoToDashboardDeviceAction({input:{}});vi.spyOn(n,"extractDependencies").mockReturnValue(A()),l.mockReturnValue({sessionStateType:p.DeviceSessionStateType.Connected,deviceStatus:c.DeviceStatus.CONNECTED,currentApp:"Bitcoin"}),v.mockReturnValue((0,a.CommandResultFactory)({error:new N.UnknownDeviceExchangeError("Close app failed")}));const o=[{intermediateValue:{requiredUserInteraction:t.UserInteractionRequired.None},status:e.DeviceActionStatus.Pending},{intermediateValue:{requiredUserInteraction:t.UserInteractionRequired.None},status:e.DeviceActionStatus.Pending},{intermediateValue:{requiredUserInteraction:t.UserInteractionRequired.None},status:e.DeviceActionStatus.Pending},{status:e.DeviceActionStatus.Error,error:new N.UnknownDeviceExchangeError("Close app failed")}];(0,u.testDeviceActionStates)(n,o,(0,s.makeDeviceActionInternalApiMock)(),{onDone:r,onError:i})})),it("should return an error if getAppAndVersion fails",()=>new Promise((r,i)=>{(0,d.setupGetDeviceStatusMock)([{currentApp:"Bitcoin",currentAppVersion:"1.0.0"}]);const n=new m.GoToDashboardDeviceAction({input:{unlockTimeout:500}}),o=new h.GlobalCommandError({...h.GLOBAL_ERRORS[5501],errorCode:"5501"});vi.spyOn(n,"extractDependencies").mockReturnValue(A()),l.mockReturnValue({sessionStateType:p.DeviceSessionStateType.Connected,deviceStatus:c.DeviceStatus.CONNECTED,currentApp:"Bitcoin"}),v.mockResolvedValue((0,a.CommandResultFactory)({data:void 0})),D.mockResolvedValue((0,a.CommandResultFactory)({error:o}));const f=[{intermediateValue:{requiredUserInteraction:t.UserInteractionRequired.None},status:e.DeviceActionStatus.Pending},{intermediateValue:{requiredUserInteraction:t.UserInteractionRequired.None},status:e.DeviceActionStatus.Pending},{intermediateValue:{requiredUserInteraction:t.UserInteractionRequired.None},status:e.DeviceActionStatus.Pending},{intermediateValue:{requiredUserInteraction:t.UserInteractionRequired.None},status:e.DeviceActionStatus.Pending},{status:e.DeviceActionStatus.Error,error:o}];(0,u.testDeviceActionStates)(n,f,(0,s.makeDeviceActionInternalApiMock)(),{onDone:r,onError:i})})),it("should return an error if getAppAndVersion does not return an app name",()=>new Promise((r,i)=>{(0,d.setupGetDeviceStatusMock)([{currentApp:"Bitcoin",currentAppVersion:"1.0.0"}]);const n=new m.GoToDashboardDeviceAction({input:{unlockTimeout:500}});vi.spyOn(n,"extractDependencies").mockReturnValue(A()),l.mockReturnValue({sessionStateType:p.DeviceSessionStateType.Connected,deviceStatus:c.DeviceStatus.CONNECTED,currentApp:"Bitcoin"}),v.mockResolvedValue((0,a.CommandResultFactory)({data:void 0})),D.mockResolvedValue((0,a.CommandResultFactory)({data:{name:null,version:"1.0.0"}}));const o=[{intermediateValue:{requiredUserInteraction:t.UserInteractionRequired.None},status:e.DeviceActionStatus.Pending},{intermediateValue:{requiredUserInteraction:t.UserInteractionRequired.None},status:e.DeviceActionStatus.Pending},{intermediateValue:{requiredUserInteraction:t.UserInteractionRequired.None},status:e.DeviceActionStatus.Pending},{intermediateValue:{requiredUserInteraction:t.UserInteractionRequired.None},status:e.DeviceActionStatus.Pending},{status:e.DeviceActionStatus.Error,error:new V.UnknownDAError("currentApp === null")}];(0,u.testDeviceActionStates)(n,o,(0,s.makeDeviceActionInternalApiMock)(),{onDone:r,onError:i})}))})})});
|
2
2
|
//# sourceMappingURL=GoToDashboardDeviceAction.test.js.map
|