@ledgerhq/device-management-kit 0.0.0-rnble-transport-20250226091520 → 0.0.0-rnble-transport-20250307123452
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 +2 -2
- package/lib/cjs/src/api/DeviceManagementKit.js +1 -1
- package/lib/cjs/src/api/DeviceManagementKit.js.map +2 -2
- 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/command/os/GetOsVersionCommand.js +1 -1
- package/lib/cjs/src/api/command/os/GetOsVersionCommand.js.map +3 -3
- package/lib/cjs/src/api/command/os/SecureElementFlagsParser.js +2 -0
- package/lib/cjs/src/api/command/os/SecureElementFlagsParser.js.map +7 -0
- package/lib/cjs/src/api/command/os/SecureElementFlagsParser.test.js +2 -0
- package/lib/cjs/src/api/command/os/SecureElementFlagsParser.test.js.map +7 -0
- package/lib/cjs/src/api/command/os/__mocks__/GetOsVersionCommand.js +1 -1
- package/lib/cjs/src/api/command/os/__mocks__/GetOsVersionCommand.js.map +2 -2
- package/lib/cjs/src/api/device/SecureElementFlags.js +2 -0
- package/lib/cjs/src/api/device/SecureElementFlags.js.map +7 -0
- package/lib/cjs/src/api/device-action/DeviceAction.js +1 -1
- package/lib/cjs/src/api/device-action/DeviceAction.js.map +1 -1
- package/lib/cjs/src/api/device-action/__test-utils__/makeInternalApi.js +1 -1
- package/lib/cjs/src/api/device-action/__test-utils__/makeInternalApi.js.map +3 -3
- package/lib/cjs/src/api/device-action/os/GetDeviceStatus/GetDeviceStatusDeviceAction.test.js +1 -1
- package/lib/cjs/src/api/device-action/os/GetDeviceStatus/GetDeviceStatusDeviceAction.test.js.map +2 -2
- 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 +2 -2
- package/lib/cjs/src/api/device-action/os/ListAppsWithMetadata/ListAppsWithMetadataDeviceAction.js +1 -1
- package/lib/cjs/src/api/device-action/os/ListAppsWithMetadata/ListAppsWithMetadataDeviceAction.js.map +3 -3
- package/lib/cjs/src/api/device-action/os/ListAppsWithMetadata/ListAppsWithMetadataDeviceAction.test.js +1 -1
- package/lib/cjs/src/api/device-action/os/ListAppsWithMetadata/ListAppsWithMetadataDeviceAction.test.js.map +3 -3
- package/lib/cjs/src/api/device-action/os/OpenAppDeviceAction/OpenAppDeviceAction.test.js +1 -1
- package/lib/cjs/src/api/device-action/os/OpenAppDeviceAction/OpenAppDeviceAction.test.js.map +2 -2
- package/lib/cjs/src/api/device-session/DeviceSessionState.js +1 -1
- package/lib/cjs/src/api/device-session/DeviceSessionState.js.map +1 -1
- package/lib/cjs/src/api/device-session/use-case/DisableDeviceSessionRefresher.js +2 -0
- package/lib/cjs/src/api/device-session/use-case/DisableDeviceSessionRefresher.js.map +7 -0
- package/lib/cjs/src/api/device-session/use-case/DisableDeviceSessionRefresher.test.js +2 -0
- package/lib/cjs/src/api/device-session/use-case/DisableDeviceSessionRefresher.test.js.map +7 -0
- package/lib/cjs/src/api/index.js +1 -1
- package/lib/cjs/src/api/index.js.map +3 -3
- package/lib/cjs/src/api/secure-channel/constants.js +2 -0
- package/lib/cjs/src/api/secure-channel/constants.js.map +7 -0
- package/lib/cjs/src/api/secure-channel/device-action/GenuineCheck/GenuineCheckDeviceAction.js +2 -0
- package/lib/cjs/src/api/secure-channel/device-action/GenuineCheck/GenuineCheckDeviceAction.js.map +7 -0
- package/lib/cjs/src/api/secure-channel/device-action/GenuineCheck/GenuineCheckDeviceAction.test.js +2 -0
- package/lib/cjs/src/api/secure-channel/device-action/GenuineCheck/GenuineCheckDeviceAction.test.js.map +7 -0
- package/lib/cjs/src/api/secure-channel/device-action/GenuineCheck/types.js +2 -0
- package/lib/cjs/src/api/secure-channel/device-action/GenuineCheck/types.js.map +7 -0
- package/lib/cjs/src/api/secure-channel/task/ConnectToSecureChannelTask.js +2 -0
- package/lib/cjs/src/api/secure-channel/task/ConnectToSecureChannelTask.js.map +7 -0
- package/lib/cjs/src/api/secure-channel/task/ConnectToSecureChannelTask.test.js +2 -0
- package/lib/cjs/src/api/secure-channel/task/ConnectToSecureChannelTask.test.js.map +7 -0
- package/lib/cjs/src/api/secure-channel/task/types.js +2 -0
- package/lib/cjs/src/api/secure-channel/task/types.js.map +7 -0
- package/lib/cjs/src/api/secure-channel/utils.js +2 -0
- package/lib/cjs/src/api/secure-channel/utils.js.map +7 -0
- package/lib/cjs/src/api/secure-channel/utils.test.js +2 -0
- package/lib/cjs/src/api/secure-channel/utils.test.js.map +7 -0
- package/lib/cjs/src/api/transport/model/DeviceConnectionStateMachine.js +1 -1
- package/lib/cjs/src/api/transport/model/DeviceConnectionStateMachine.js.map +3 -3
- package/lib/cjs/src/api/transport/model/Errors.js.map +2 -2
- package/lib/cjs/src/api/types.js +1 -1
- package/lib/cjs/src/api/types.js.map +1 -1
- package/lib/cjs/src/internal/device-session/di/deviceSessionModule.js +1 -1
- package/lib/cjs/src/internal/device-session/di/deviceSessionModule.js.map +3 -3
- package/lib/cjs/src/internal/device-session/di/deviceSessionTypes.js +1 -1
- package/lib/cjs/src/internal/device-session/di/deviceSessionTypes.js.map +2 -2
- package/lib/cjs/src/internal/device-session/model/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/DeviceSessionRefresher.js +1 -1
- package/lib/cjs/src/internal/device-session/model/DeviceSessionRefresher.js.map +2 -2
- package/lib/cjs/src/internal/device-session/service/DefaultApduSenderService.js +1 -1
- package/lib/cjs/src/internal/device-session/service/DefaultApduSenderService.js.map +2 -2
- package/lib/cjs/src/internal/device-session/service/RefresherService.js +2 -0
- package/lib/cjs/src/internal/device-session/service/RefresherService.js.map +7 -0
- package/lib/cjs/src/internal/device-session/service/RefresherService.test.js +2 -0
- package/lib/cjs/src/internal/device-session/service/RefresherService.test.js.map +7 -0
- package/lib/cjs/src/internal/discovery/use-case/ListenToAvailableDevicesUseCase.js +1 -1
- package/lib/cjs/src/internal/discovery/use-case/ListenToAvailableDevicesUseCase.js.map +3 -3
- package/lib/cjs/src/internal/discovery/use-case/ListenToAvailableDevicesUseCase.test.js +1 -1
- package/lib/cjs/src/internal/discovery/use-case/ListenToAvailableDevicesUseCase.test.js.map +3 -3
- package/lib/cjs/src/internal/secure-channel/data/DefaultSecureChannelDataSource.js +1 -1
- package/lib/cjs/src/internal/secure-channel/data/DefaultSecureChannelDataSource.js.map +2 -2
- package/lib/cjs/src/internal/secure-channel/data/SecureChannelDataSource.js.map +1 -1
- package/lib/cjs/src/internal/secure-channel/model/Errors.js +1 -1
- package/lib/cjs/src/internal/secure-channel/model/Errors.js.map +3 -3
- package/lib/cjs/src/internal/secure-channel/service/DefaultSecureChannelService.js +1 -1
- package/lib/cjs/src/internal/secure-channel/service/DefaultSecureChannelService.js.map +3 -3
- package/lib/cjs/src/internal/secure-channel/service/SecureChannelService.js.map +1 -1
- package/lib/esm/package.json +2 -2
- package/lib/esm/src/api/DeviceManagementKit.js +1 -1
- package/lib/esm/src/api/DeviceManagementKit.js.map +2 -2
- 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/command/os/GetOsVersionCommand.js +1 -1
- package/lib/esm/src/api/command/os/GetOsVersionCommand.js.map +3 -3
- package/lib/esm/src/api/command/os/SecureElementFlagsParser.js +2 -0
- package/lib/esm/src/api/command/os/SecureElementFlagsParser.js.map +7 -0
- package/lib/esm/src/api/command/os/SecureElementFlagsParser.test.js +2 -0
- package/lib/esm/src/api/command/os/SecureElementFlagsParser.test.js.map +7 -0
- package/lib/esm/src/api/command/os/__mocks__/GetOsVersionCommand.js +1 -1
- package/lib/esm/src/api/command/os/__mocks__/GetOsVersionCommand.js.map +2 -2
- package/lib/esm/src/api/device/SecureElementFlags.js +1 -0
- package/lib/esm/src/api/device/SecureElementFlags.js.map +7 -0
- package/lib/esm/src/api/device-action/__test-utils__/makeInternalApi.js +1 -1
- package/lib/esm/src/api/device-action/__test-utils__/makeInternalApi.js.map +3 -3
- package/lib/esm/src/api/device-action/os/GetDeviceStatus/GetDeviceStatusDeviceAction.test.js +1 -1
- package/lib/esm/src/api/device-action/os/GetDeviceStatus/GetDeviceStatusDeviceAction.test.js.map +2 -2
- 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 +2 -2
- package/lib/esm/src/api/device-action/os/ListAppsWithMetadata/ListAppsWithMetadataDeviceAction.js +1 -1
- package/lib/esm/src/api/device-action/os/ListAppsWithMetadata/ListAppsWithMetadataDeviceAction.js.map +3 -3
- package/lib/esm/src/api/device-action/os/ListAppsWithMetadata/ListAppsWithMetadataDeviceAction.test.js +1 -1
- package/lib/esm/src/api/device-action/os/ListAppsWithMetadata/ListAppsWithMetadataDeviceAction.test.js.map +3 -3
- package/lib/esm/src/api/device-action/os/OpenAppDeviceAction/OpenAppDeviceAction.test.js +1 -1
- package/lib/esm/src/api/device-action/os/OpenAppDeviceAction/OpenAppDeviceAction.test.js.map +2 -2
- package/lib/esm/src/api/device-session/DeviceSessionState.js.map +1 -1
- package/lib/esm/src/api/device-session/use-case/DisableDeviceSessionRefresher.js +2 -0
- package/lib/esm/src/api/device-session/use-case/DisableDeviceSessionRefresher.js.map +7 -0
- package/lib/esm/src/api/device-session/use-case/DisableDeviceSessionRefresher.test.js +2 -0
- package/lib/esm/src/api/device-session/use-case/DisableDeviceSessionRefresher.test.js.map +7 -0
- package/lib/esm/src/api/index.js +1 -1
- package/lib/esm/src/api/index.js.map +3 -3
- package/lib/esm/src/api/secure-channel/constants.js +2 -0
- package/lib/esm/src/api/secure-channel/constants.js.map +7 -0
- package/lib/esm/src/api/secure-channel/device-action/GenuineCheck/GenuineCheckDeviceAction.js +2 -0
- package/lib/esm/src/api/secure-channel/device-action/GenuineCheck/GenuineCheckDeviceAction.js.map +7 -0
- package/lib/esm/src/api/secure-channel/device-action/GenuineCheck/GenuineCheckDeviceAction.test.js +2 -0
- package/lib/esm/src/api/secure-channel/device-action/GenuineCheck/GenuineCheckDeviceAction.test.js.map +7 -0
- package/lib/esm/src/api/secure-channel/device-action/GenuineCheck/types.js +1 -0
- package/lib/esm/src/api/secure-channel/device-action/GenuineCheck/types.js.map +7 -0
- package/lib/esm/src/api/secure-channel/task/ConnectToSecureChannelTask.js +2 -0
- package/lib/esm/src/api/secure-channel/task/ConnectToSecureChannelTask.js.map +7 -0
- package/lib/esm/src/api/secure-channel/task/ConnectToSecureChannelTask.test.js +2 -0
- package/lib/esm/src/api/secure-channel/task/ConnectToSecureChannelTask.test.js.map +7 -0
- package/lib/esm/src/api/secure-channel/task/types.js +2 -0
- package/lib/esm/src/api/secure-channel/task/types.js.map +7 -0
- package/lib/esm/src/api/secure-channel/utils.js +2 -0
- package/lib/esm/src/api/secure-channel/utils.js.map +7 -0
- package/lib/esm/src/api/secure-channel/utils.test.js +2 -0
- package/lib/esm/src/api/secure-channel/utils.test.js.map +7 -0
- package/lib/esm/src/api/transport/model/DeviceConnectionStateMachine.js +1 -1
- package/lib/esm/src/api/transport/model/DeviceConnectionStateMachine.js.map +3 -3
- package/lib/esm/src/api/transport/model/Errors.js.map +2 -2
- package/lib/esm/src/internal/device-session/di/deviceSessionModule.js +1 -1
- package/lib/esm/src/internal/device-session/di/deviceSessionModule.js.map +3 -3
- package/lib/esm/src/internal/device-session/di/deviceSessionTypes.js +1 -1
- package/lib/esm/src/internal/device-session/di/deviceSessionTypes.js.map +2 -2
- package/lib/esm/src/internal/device-session/model/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/DeviceSessionRefresher.js +1 -1
- package/lib/esm/src/internal/device-session/model/DeviceSessionRefresher.js.map +2 -2
- package/lib/esm/src/internal/device-session/service/DefaultApduSenderService.js +1 -1
- package/lib/esm/src/internal/device-session/service/DefaultApduSenderService.js.map +2 -2
- package/lib/esm/src/internal/device-session/service/RefresherService.js +2 -0
- package/lib/esm/src/internal/device-session/service/RefresherService.js.map +7 -0
- package/lib/esm/src/internal/device-session/service/RefresherService.test.js +2 -0
- package/lib/esm/src/internal/device-session/service/RefresherService.test.js.map +7 -0
- package/lib/esm/src/internal/discovery/use-case/ListenToAvailableDevicesUseCase.js +1 -1
- package/lib/esm/src/internal/discovery/use-case/ListenToAvailableDevicesUseCase.js.map +3 -3
- package/lib/esm/src/internal/discovery/use-case/ListenToAvailableDevicesUseCase.test.js +1 -1
- package/lib/esm/src/internal/discovery/use-case/ListenToAvailableDevicesUseCase.test.js.map +3 -3
- package/lib/esm/src/internal/secure-channel/data/DefaultSecureChannelDataSource.js +1 -1
- package/lib/esm/src/internal/secure-channel/data/DefaultSecureChannelDataSource.js.map +2 -2
- package/lib/esm/src/internal/secure-channel/model/Errors.js +1 -1
- package/lib/esm/src/internal/secure-channel/model/Errors.js.map +3 -3
- package/lib/esm/src/internal/secure-channel/service/DefaultSecureChannelService.js +1 -1
- package/lib/esm/src/internal/secure-channel/service/DefaultSecureChannelService.js.map +3 -3
- package/lib/types/src/api/DeviceManagementKit.d.ts +10 -8
- package/lib/types/src/api/DeviceManagementKit.d.ts.map +1 -1
- package/lib/types/src/api/command/os/GetOsVersionCommand.d.ts +8 -2
- package/lib/types/src/api/command/os/GetOsVersionCommand.d.ts.map +1 -1
- package/lib/types/src/api/command/os/SecureElementFlagsParser.d.ts +43 -0
- package/lib/types/src/api/command/os/SecureElementFlagsParser.d.ts.map +1 -0
- package/lib/types/src/api/command/os/SecureElementFlagsParser.test.d.ts +2 -0
- package/lib/types/src/api/command/os/SecureElementFlagsParser.test.d.ts.map +1 -0
- package/lib/types/src/api/command/os/__mocks__/GetOsVersionCommand.d.ts.map +1 -1
- package/lib/types/src/api/device/SecureElementFlags.d.ts +41 -0
- package/lib/types/src/api/device/SecureElementFlags.d.ts.map +1 -0
- package/lib/types/src/api/device-action/DeviceAction.d.ts +1 -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.map +1 -1
- package/lib/types/src/api/device-action/os/ListAppsWithMetadata/ListAppsWithMetadataDeviceAction.d.ts +1 -1
- package/lib/types/src/api/device-action/os/ListAppsWithMetadata/ListAppsWithMetadataDeviceAction.d.ts.map +1 -1
- package/lib/types/src/api/device-session/DeviceSessionState.d.ts +4 -0
- package/lib/types/src/api/device-session/DeviceSessionState.d.ts.map +1 -1
- package/lib/types/src/api/device-session/use-case/{ToggleDeviceSessionRefresher.d.ts → DisableDeviceSessionRefresher.d.ts} +6 -6
- package/lib/types/src/api/device-session/use-case/DisableDeviceSessionRefresher.d.ts.map +1 -0
- package/lib/types/src/api/device-session/use-case/DisableDeviceSessionRefresher.test.d.ts +2 -0
- package/lib/types/src/api/device-session/use-case/DisableDeviceSessionRefresher.test.d.ts.map +1 -0
- package/lib/types/src/api/index.d.ts +1 -0
- package/lib/types/src/api/index.d.ts.map +1 -1
- package/lib/types/src/api/secure-channel/constants.d.ts +2 -0
- package/lib/types/src/api/secure-channel/constants.d.ts.map +1 -0
- package/lib/types/src/api/secure-channel/device-action/GenuineCheck/GenuineCheckDeviceAction.d.ts +8 -0
- package/lib/types/src/api/secure-channel/device-action/GenuineCheck/GenuineCheckDeviceAction.d.ts.map +1 -0
- package/lib/types/src/api/secure-channel/device-action/GenuineCheck/GenuineCheckDeviceAction.test.d.ts +1 -0
- package/lib/types/src/api/secure-channel/device-action/GenuineCheck/GenuineCheckDeviceAction.test.d.ts.map +1 -0
- package/lib/types/src/api/secure-channel/device-action/GenuineCheck/types.d.ts +50 -0
- package/lib/types/src/api/secure-channel/device-action/GenuineCheck/types.d.ts.map +1 -0
- package/lib/types/src/api/secure-channel/task/ConnectToSecureChannelTask.d.ts +23 -0
- package/lib/types/src/api/secure-channel/task/ConnectToSecureChannelTask.d.ts.map +1 -0
- package/lib/types/src/api/secure-channel/task/ConnectToSecureChannelTask.test.d.ts +2 -0
- package/lib/types/src/api/secure-channel/task/ConnectToSecureChannelTask.test.d.ts.map +1 -0
- package/lib/types/src/api/secure-channel/task/types.d.ts +105 -0
- package/lib/types/src/api/secure-channel/task/types.d.ts.map +1 -0
- package/lib/types/src/api/secure-channel/utils.d.ts +30 -0
- package/lib/types/src/api/secure-channel/utils.d.ts.map +1 -0
- package/lib/types/src/api/secure-channel/utils.test.d.ts +2 -0
- package/lib/types/src/api/secure-channel/utils.test.d.ts.map +1 -0
- package/lib/types/src/api/transport/model/DeviceConnectionStateMachine.d.ts.map +1 -1
- package/lib/types/src/api/transport/model/Errors.d.ts.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/internal/device-session/di/deviceSessionTypes.d.ts +1 -1
- package/lib/types/src/internal/device-session/model/DeviceSession.d.ts +4 -3
- package/lib/types/src/internal/device-session/model/DeviceSession.d.ts.map +1 -1
- package/lib/types/src/internal/device-session/model/DeviceSessionRefresher.d.ts.map +1 -1
- package/lib/types/src/internal/device-session/service/RefresherService.d.ts +10 -0
- package/lib/types/src/internal/device-session/service/RefresherService.d.ts.map +1 -0
- package/lib/types/src/internal/device-session/service/RefresherService.test.d.ts +2 -0
- package/lib/types/src/internal/device-session/service/RefresherService.test.d.ts.map +1 -0
- package/lib/types/src/internal/discovery/use-case/ListenToAvailableDevicesUseCase.d.ts +14 -3
- package/lib/types/src/internal/discovery/use-case/ListenToAvailableDevicesUseCase.d.ts.map +1 -1
- package/lib/types/src/internal/secure-channel/data/DefaultSecureChannelDataSource.d.ts +3 -3
- package/lib/types/src/internal/secure-channel/data/DefaultSecureChannelDataSource.d.ts.map +1 -1
- package/lib/types/src/internal/secure-channel/data/SecureChannelDataSource.d.ts +13 -13
- package/lib/types/src/internal/secure-channel/data/SecureChannelDataSource.d.ts.map +1 -1
- package/lib/types/src/internal/secure-channel/model/Errors.d.ts +6 -0
- package/lib/types/src/internal/secure-channel/model/Errors.d.ts.map +1 -1
- package/lib/types/src/internal/secure-channel/service/DefaultSecureChannelService.d.ts +3 -3
- package/lib/types/src/internal/secure-channel/service/DefaultSecureChannelService.d.ts.map +1 -1
- package/lib/types/src/internal/secure-channel/service/SecureChannelService.d.ts +1 -0
- package/lib/types/src/internal/secure-channel/service/SecureChannelService.d.ts.map +1 -1
- package/lib/types/tsconfig.prod.tsbuildinfo +1 -1
- package/package.json +3 -3
- package/lib/cjs/src/api/device-session/use-case/ToggleDeviceSessionRefresher.js +0 -2
- package/lib/cjs/src/api/device-session/use-case/ToggleDeviceSessionRefresher.js.map +0 -7
- package/lib/cjs/src/api/device-session/use-case/ToggleDeviceSessionRefresher.test.js +0 -2
- package/lib/cjs/src/api/device-session/use-case/ToggleDeviceSessionRefresher.test.js.map +0 -7
- package/lib/esm/src/api/device-session/use-case/ToggleDeviceSessionRefresher.js +0 -2
- package/lib/esm/src/api/device-session/use-case/ToggleDeviceSessionRefresher.js.map +0 -7
- package/lib/esm/src/api/device-session/use-case/ToggleDeviceSessionRefresher.test.js +0 -2
- package/lib/esm/src/api/device-session/use-case/ToggleDeviceSessionRefresher.test.js.map +0 -7
- package/lib/types/src/api/device-session/use-case/ToggleDeviceSessionRefresher.d.ts.map +0 -1
- package/lib/types/src/api/device-session/use-case/ToggleDeviceSessionRefresher.test.d.ts +0 -2
- package/lib/types/src/api/device-session/use-case/ToggleDeviceSessionRefresher.test.d.ts.map +0 -1
@@ -1,7 +1,7 @@
|
|
1
1
|
{
|
2
2
|
"version": 3,
|
3
3
|
"sources": ["../../../../../../../src/api/device-action/os/ListAppsWithMetadata/ListAppsWithMetadataDeviceAction.test.ts"],
|
4
|
-
"sourcesContent": ["import { Left, Right } from \"purify-ts\";\n\nimport { DeviceStatus } from \"@api/device/DeviceStatus\";\nimport {\n BTC_APP,\n BTC_APP_METADATA,\n CUSTOM_LOCK_SCREEN_APP,\n CUSTOM_LOCK_SCREEN_APP_METADATA,\n ETH_APP,\n ETH_APP_METADATA,\n} from \"@api/device-action/__test-utils__/data\";\nimport { makeDeviceActionInternalApiMock } from \"@api/device-action/__test-utils__/makeInternalApi\";\nimport { setupListAppsMock } from \"@api/device-action/__test-utils__/setupTestMachine\";\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 { UnknownDAError } from \"@api/device-action/os/Errors\";\nimport { DeviceSessionStateType } from \"@api/device-session/DeviceSessionState\";\nimport { HttpFetchApiError } from \"@internal/manager-api/model/Errors\";\nimport { type ManagerApiService } from \"@internal/manager-api/service/ManagerApiService\";\n\nimport { ListAppsWithMetadataDeviceAction } from \"./ListAppsWithMetadataDeviceAction\";\nimport { type ListAppsWithMetadataDAState } from \"./types\";\n\nvi.mock(\"@api/device-action/os/ListApps/ListAppsDeviceAction\");\n\ndescribe(\"ListAppsWithMetadataDeviceAction\", () => {\n const { getManagerApiService: getManagerApiServiceMock } =\n makeDeviceActionInternalApiMock();\n\n const saveSessionStateMock = vi.fn();\n const getDeviceSessionStateMock = vi.fn();\n const getAppsByHashMock = vi.fn();\n\n function extractDependenciesMock() {\n return {\n getAppsByHash: getAppsByHashMock,\n getDeviceSessionState: getDeviceSessionStateMock,\n saveSessionState: saveSessionStateMock,\n };\n }\n\n beforeEach(() => {\n vi.resetAllMocks();\n });\n\n describe(\"success case\", () => {\n it(\"should run the device actions with no apps installed\", () =>\n new Promise<void>((resolve, reject) => {\n setupListAppsMock([]);\n const listAppsWithMetadataDeviceAction =\n new ListAppsWithMetadataDeviceAction({\n input: {},\n });\n\n getManagerApiServiceMock.mockReturnValue({\n getAppsByHash: vi.fn().mockResolvedValue(Right([])),\n } as unknown as ManagerApiService);\n\n const expectedStates: Array<ListAppsWithMetadataDAState> = [\n {\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.None,\n },\n status: DeviceActionStatus.Pending, // Ready\n },\n {\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.AllowListApps,\n },\n status: DeviceActionStatus.Pending, // ListAppsDeviceAction\n },\n {\n status: DeviceActionStatus.Completed,\n output: [],\n },\n ];\n\n testDeviceActionStates(\n listAppsWithMetadataDeviceAction,\n expectedStates,\n makeDeviceActionInternalApiMock(),\n {\n onDone: resolve,\n onError: reject,\n },\n );\n }));\n\n it(\"should run the device actions with 1 app installed\", () =>\n new Promise<void>((resolve, reject) => {\n setupListAppsMock([BTC_APP]);\n const listAppsWithMetadataDeviceAction =\n new ListAppsWithMetadataDeviceAction({\n input: {},\n });\n\n getManagerApiServiceMock.mockReturnValue({\n getAppsByHash: vi.fn().mockResolvedValue(Right([BTC_APP_METADATA])),\n } as unknown as ManagerApiService);\n\n const expectedStates: Array<ListAppsWithMetadataDAState> = [\n {\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.None,\n },\n status: DeviceActionStatus.Pending, // Ready\n },\n {\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.AllowListApps,\n },\n status: DeviceActionStatus.Pending, // ListAppsDeviceAction\n },\n {\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.None,\n },\n status: DeviceActionStatus.Pending, // FetchMetadata\n },\n {\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.None,\n },\n status: DeviceActionStatus.Pending, // SaveSession\n },\n {\n status: DeviceActionStatus.Completed,\n output: [BTC_APP_METADATA],\n },\n ];\n\n testDeviceActionStates(\n listAppsWithMetadataDeviceAction,\n expectedStates,\n makeDeviceActionInternalApiMock(),\n {\n onDone: resolve,\n onError: reject,\n },\n );\n }));\n\n it(\"should run the device actions with 2 apps installed\", () =>\n new Promise<void>((resolve, reject) => {\n setupListAppsMock([BTC_APP, ETH_APP]);\n const listAppsWithMetadataDeviceAction =\n new ListAppsWithMetadataDeviceAction({\n input: {},\n });\n\n getManagerApiServiceMock.mockReturnValue({\n getAppsByHash: vi\n .fn()\n .mockResolvedValue(Right([BTC_APP_METADATA, ETH_APP_METADATA])),\n } as unknown as ManagerApiService);\n\n const expectedStates: Array<ListAppsWithMetadataDAState> = [\n {\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.None,\n },\n status: DeviceActionStatus.Pending, // Ready\n },\n {\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.AllowListApps,\n },\n status: DeviceActionStatus.Pending, // ListAppsDeviceAction\n },\n {\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.None,\n },\n status: DeviceActionStatus.Pending, // FetchMetadata\n },\n {\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.None,\n },\n status: DeviceActionStatus.Pending, // SaveSession\n },\n {\n status: DeviceActionStatus.Completed,\n output: [BTC_APP_METADATA, ETH_APP_METADATA],\n },\n ];\n\n testDeviceActionStates(\n listAppsWithMetadataDeviceAction,\n expectedStates,\n makeDeviceActionInternalApiMock(),\n {\n onDone: resolve,\n onError: reject,\n },\n );\n }));\n\n it(\"should run the device actions with 1 app installed and a custom lock screen\", () =>\n new Promise<void>((resolve, reject) => {\n setupListAppsMock([BTC_APP, CUSTOM_LOCK_SCREEN_APP]);\n const listAppsWithMetadataDeviceAction =\n new ListAppsWithMetadataDeviceAction({\n input: {},\n });\n\n getManagerApiServiceMock.mockReturnValue({\n getAppsByHash: vi\n .fn()\n .mockResolvedValue(\n Right([BTC_APP_METADATA, CUSTOM_LOCK_SCREEN_APP_METADATA]),\n ),\n } as unknown as ManagerApiService);\n\n const expectedStates: Array<ListAppsWithMetadataDAState> = [\n {\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.None,\n },\n status: DeviceActionStatus.Pending, // Ready\n },\n {\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.AllowListApps,\n },\n status: DeviceActionStatus.Pending, // ListAppsDeviceAction\n },\n {\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.None,\n },\n status: DeviceActionStatus.Pending, // FetchMetadata\n },\n {\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.None,\n },\n status: DeviceActionStatus.Pending, // SaveSession\n },\n {\n status: DeviceActionStatus.Completed,\n output: [BTC_APP_METADATA, CUSTOM_LOCK_SCREEN_APP_METADATA],\n },\n ];\n\n testDeviceActionStates(\n listAppsWithMetadataDeviceAction,\n expectedStates,\n makeDeviceActionInternalApiMock(),\n {\n onDone: resolve,\n onError: reject,\n },\n );\n }));\n });\n\n describe(\"error case\", () => {\n it(\"should error when ListApps fails\", () =>\n new Promise<void>((resolve, reject) => {\n setupListAppsMock([], true);\n const listAppsWithMetadataDeviceAction =\n new ListAppsWithMetadataDeviceAction({\n input: {},\n });\n\n const expectedStates: Array<ListAppsWithMetadataDAState> = [\n {\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.None,\n },\n status: DeviceActionStatus.Pending, // Ready\n },\n {\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.AllowListApps,\n },\n status: DeviceActionStatus.Pending, // ListAppsDeviceAction\n },\n {\n status: DeviceActionStatus.Error,\n error: new UnknownDAError(\"ListApps failed\"),\n },\n ];\n\n testDeviceActionStates(\n listAppsWithMetadataDeviceAction,\n expectedStates,\n makeDeviceActionInternalApiMock(),\n {\n onDone: resolve,\n onError: reject,\n },\n );\n }));\n\n it(\"should error when getAppsByHash rejects\", () =>\n new Promise<void>((resolve, reject) => {\n setupListAppsMock([BTC_APP]);\n const listAppsWithMetadataDeviceAction =\n new ListAppsWithMetadataDeviceAction({\n input: {},\n });\n\n getManagerApiServiceMock.mockReturnValue({\n getAppsByHash: vi\n .fn()\n .mockRejectedValue(new UnknownDAError(\"getAppsByHash failed\")),\n } as unknown as ManagerApiService);\n\n const expectedStates: Array<ListAppsWithMetadataDAState> = [\n {\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.None,\n },\n status: DeviceActionStatus.Pending, // Ready\n },\n {\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.AllowListApps,\n },\n status: DeviceActionStatus.Pending, // ListAppsDeviceAction\n },\n {\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.None,\n },\n status: DeviceActionStatus.Pending, // FetchMetadata\n },\n {\n status: DeviceActionStatus.Error,\n error: new UnknownDAError(\"getAppsByHash failed\"),\n },\n ];\n\n testDeviceActionStates(\n listAppsWithMetadataDeviceAction,\n expectedStates,\n makeDeviceActionInternalApiMock(),\n {\n onDone: resolve,\n onError: reject,\n },\n );\n }));\n\n it(\"should error when getAppsByHash fails but error is known\", () =>\n new Promise<void>((resolve, reject) => {\n setupListAppsMock([BTC_APP]);\n const listAppsWithMetadataDeviceAction =\n new ListAppsWithMetadataDeviceAction({\n input: {},\n });\n\n const error = new HttpFetchApiError(new Error(\"Failed to fetch data\"));\n\n getManagerApiServiceMock.mockReturnValue({\n getAppsByHash: vi.fn().mockResolvedValue(Left(error)),\n } as unknown as ManagerApiService);\n\n const expectedStates: Array<ListAppsWithMetadataDAState> = [\n {\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.None,\n },\n status: DeviceActionStatus.Pending, // Ready\n },\n {\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.AllowListApps,\n },\n status: DeviceActionStatus.Pending, // ListAppsDeviceAction\n },\n {\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.None,\n },\n status: DeviceActionStatus.Pending, // FetchMetadata\n },\n {\n status: DeviceActionStatus.Error,\n error,\n },\n ];\n\n testDeviceActionStates(\n listAppsWithMetadataDeviceAction,\n expectedStates,\n makeDeviceActionInternalApiMock(),\n {\n onDone: resolve,\n onError: reject,\n },\n );\n }));\n\n it(\"should error when SaveSession fails\", () =>\n new Promise<void>((resolve, reject) => {\n setupListAppsMock([BTC_APP]);\n const listAppsWithMetadataDeviceAction =\n new ListAppsWithMetadataDeviceAction({\n input: {},\n });\n\n getAppsByHashMock.mockImplementation(async () =>\n Promise.resolve(Right([BTC_APP_METADATA])),\n );\n\n vi.spyOn(\n listAppsWithMetadataDeviceAction,\n \"extractDependencies\",\n ).mockReturnValue(extractDependenciesMock());\n\n getDeviceSessionStateMock.mockReturnValue({\n sessionStateType: DeviceSessionStateType.ReadyWithoutSecureChannel,\n deviceStatus: DeviceStatus.CONNECTED,\n currentApp: \"BOLOS\",\n installedApps: [],\n });\n\n saveSessionStateMock.mockImplementation(() => {\n throw new UnknownDAError(\"SaveSession failed\");\n });\n\n const expectedStates: Array<ListAppsWithMetadataDAState> = [\n {\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.None,\n },\n status: DeviceActionStatus.Pending, // Ready\n },\n {\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.AllowListApps,\n },\n status: DeviceActionStatus.Pending, // ListAppsDeviceAction\n },\n {\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.None,\n },\n status: DeviceActionStatus.Pending, // FetchMetadata\n },\n {\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.None,\n },\n status: DeviceActionStatus.Pending, // SaveSession\n },\n {\n status: DeviceActionStatus.Error,\n error: new UnknownDAError(\"SaveSession failed\"),\n },\n ];\n\n testDeviceActionStates(\n listAppsWithMetadataDeviceAction,\n expectedStates,\n makeDeviceActionInternalApiMock(),\n {\n onDone: resolve,\n onError: reject,\n },\n );\n }));\n });\n});\n"],
|
5
|
-
"mappings": "AAAA,OAAS,QAAAA,EAAM,SAAAC,MAAa,YAE5B,OAAS,gBAAAC,MAAoB,2BAC7B,OACE,WAAAC,EACA,oBAAAC,EACA,0BAAAC,EACA,mCAAAC,EACA,WAAAC,EACA,oBAAAC,MACK,yCACP,OAAS,mCAAAC,MAAuC,oDAChD,OAAS,qBAAAC,MAAyB,qDAClC,OAAS,0BAAAC,MAA8B,2DACvC,OAAS,sBAAAC,MAA0B,6CACnC,OAAS,2BAAAC,MAA+B,mDACxC,OAAS,kBAAAC,MAAsB,+BAC/B,OAAS,0BAAAC,MAA8B,yCACvC,OAAS,qBAAAC,MAAyB,qCAGlC,OAAS,oCAAAC,MAAwC,qCAGjD,GAAG,KAAK,qDAAqD,EAE7D,SAAS,mCAAoC,IAAM,CACjD,KAAM,CAAE,qBAAsBC,CAAyB,EACrDT,EAAgC,EAE5BU,
|
6
|
-
"names": ["Left", "Right", "DeviceStatus", "BTC_APP", "BTC_APP_METADATA", "CUSTOM_LOCK_SCREEN_APP", "CUSTOM_LOCK_SCREEN_APP_METADATA", "ETH_APP", "ETH_APP_METADATA", "makeDeviceActionInternalApiMock", "setupListAppsMock", "testDeviceActionStates", "DeviceActionStatus", "UserInteractionRequired", "UnknownDAError", "DeviceSessionStateType", "HttpFetchApiError", "ListAppsWithMetadataDeviceAction", "getManagerApiServiceMock", "
|
4
|
+
"sourcesContent": ["import { Left, Right } from \"purify-ts\";\n\nimport { DeviceStatus } from \"@api/device/DeviceStatus\";\nimport {\n BTC_APP,\n BTC_APP_METADATA,\n CUSTOM_LOCK_SCREEN_APP,\n CUSTOM_LOCK_SCREEN_APP_METADATA,\n ETH_APP,\n ETH_APP_METADATA,\n} from \"@api/device-action/__test-utils__/data\";\nimport { makeDeviceActionInternalApiMock } from \"@api/device-action/__test-utils__/makeInternalApi\";\nimport { setupListAppsMock } from \"@api/device-action/__test-utils__/setupTestMachine\";\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 { UnknownDAError } from \"@api/device-action/os/Errors\";\nimport { DeviceSessionStateType } from \"@api/device-session/DeviceSessionState\";\nimport { HttpFetchApiError } from \"@internal/manager-api/model/Errors\";\nimport { type ManagerApiService } from \"@internal/manager-api/service/ManagerApiService\";\n\nimport { ListAppsWithMetadataDeviceAction } from \"./ListAppsWithMetadataDeviceAction\";\nimport { type ListAppsWithMetadataDAState } from \"./types\";\n\nvi.mock(\"@api/device-action/os/ListApps/ListAppsDeviceAction\");\n\ndescribe(\"ListAppsWithMetadataDeviceAction\", () => {\n const { getManagerApiService: getManagerApiServiceMock } =\n makeDeviceActionInternalApiMock();\n\n const setDeviceSessionStateMock = vi.fn();\n const getDeviceSessionStateMock = vi.fn();\n const getAppsByHashMock = vi.fn();\n\n function extractDependenciesMock() {\n return {\n getAppsByHash: getAppsByHashMock,\n getDeviceSessionState: getDeviceSessionStateMock,\n setDeviceSessionState: setDeviceSessionStateMock,\n };\n }\n\n beforeEach(() => {\n vi.resetAllMocks();\n });\n\n describe(\"success case\", () => {\n it(\"should run the device actions with no apps installed\", () =>\n new Promise<void>((resolve, reject) => {\n setupListAppsMock([]);\n const listAppsWithMetadataDeviceAction =\n new ListAppsWithMetadataDeviceAction({\n input: {},\n });\n\n getManagerApiServiceMock.mockReturnValue({\n getAppsByHash: vi.fn().mockResolvedValue(Right([])),\n } as unknown as ManagerApiService);\n\n const expectedStates: Array<ListAppsWithMetadataDAState> = [\n {\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.None,\n },\n status: DeviceActionStatus.Pending, // Ready\n },\n {\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.AllowListApps,\n },\n status: DeviceActionStatus.Pending, // ListAppsDeviceAction\n },\n {\n status: DeviceActionStatus.Completed,\n output: [],\n },\n ];\n\n testDeviceActionStates(\n listAppsWithMetadataDeviceAction,\n expectedStates,\n makeDeviceActionInternalApiMock(),\n {\n onDone: resolve,\n onError: reject,\n },\n );\n }));\n\n it(\"should run the device actions with 1 app installed\", () =>\n new Promise<void>((resolve, reject) => {\n setupListAppsMock([BTC_APP]);\n const listAppsWithMetadataDeviceAction =\n new ListAppsWithMetadataDeviceAction({\n input: {},\n });\n\n getManagerApiServiceMock.mockReturnValue({\n getAppsByHash: vi.fn().mockResolvedValue(Right([BTC_APP_METADATA])),\n } as unknown as ManagerApiService);\n\n const expectedStates: Array<ListAppsWithMetadataDAState> = [\n {\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.None,\n },\n status: DeviceActionStatus.Pending, // Ready\n },\n {\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.AllowListApps,\n },\n status: DeviceActionStatus.Pending, // ListAppsDeviceAction\n },\n {\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.None,\n },\n status: DeviceActionStatus.Pending, // FetchMetadata\n },\n {\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.None,\n },\n status: DeviceActionStatus.Pending, // SaveSession\n },\n {\n status: DeviceActionStatus.Completed,\n output: [BTC_APP_METADATA],\n },\n ];\n\n testDeviceActionStates(\n listAppsWithMetadataDeviceAction,\n expectedStates,\n makeDeviceActionInternalApiMock(),\n {\n onDone: resolve,\n onError: reject,\n },\n );\n }));\n\n it(\"should run the device actions with 2 apps installed\", () =>\n new Promise<void>((resolve, reject) => {\n setupListAppsMock([BTC_APP, ETH_APP]);\n const listAppsWithMetadataDeviceAction =\n new ListAppsWithMetadataDeviceAction({\n input: {},\n });\n\n getManagerApiServiceMock.mockReturnValue({\n getAppsByHash: vi\n .fn()\n .mockResolvedValue(Right([BTC_APP_METADATA, ETH_APP_METADATA])),\n } as unknown as ManagerApiService);\n\n const expectedStates: Array<ListAppsWithMetadataDAState> = [\n {\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.None,\n },\n status: DeviceActionStatus.Pending, // Ready\n },\n {\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.AllowListApps,\n },\n status: DeviceActionStatus.Pending, // ListAppsDeviceAction\n },\n {\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.None,\n },\n status: DeviceActionStatus.Pending, // FetchMetadata\n },\n {\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.None,\n },\n status: DeviceActionStatus.Pending, // SaveSession\n },\n {\n status: DeviceActionStatus.Completed,\n output: [BTC_APP_METADATA, ETH_APP_METADATA],\n },\n ];\n\n testDeviceActionStates(\n listAppsWithMetadataDeviceAction,\n expectedStates,\n makeDeviceActionInternalApiMock(),\n {\n onDone: resolve,\n onError: reject,\n },\n );\n }));\n\n it(\"should run the device actions with 1 app installed and a custom lock screen\", () =>\n new Promise<void>((resolve, reject) => {\n setupListAppsMock([BTC_APP, CUSTOM_LOCK_SCREEN_APP]);\n const listAppsWithMetadataDeviceAction =\n new ListAppsWithMetadataDeviceAction({\n input: {},\n });\n\n getManagerApiServiceMock.mockReturnValue({\n getAppsByHash: vi\n .fn()\n .mockResolvedValue(\n Right([BTC_APP_METADATA, CUSTOM_LOCK_SCREEN_APP_METADATA]),\n ),\n } as unknown as ManagerApiService);\n\n const expectedStates: Array<ListAppsWithMetadataDAState> = [\n {\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.None,\n },\n status: DeviceActionStatus.Pending, // Ready\n },\n {\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.AllowListApps,\n },\n status: DeviceActionStatus.Pending, // ListAppsDeviceAction\n },\n {\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.None,\n },\n status: DeviceActionStatus.Pending, // FetchMetadata\n },\n {\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.None,\n },\n status: DeviceActionStatus.Pending, // SaveSession\n },\n {\n status: DeviceActionStatus.Completed,\n output: [BTC_APP_METADATA, CUSTOM_LOCK_SCREEN_APP_METADATA],\n },\n ];\n\n testDeviceActionStates(\n listAppsWithMetadataDeviceAction,\n expectedStates,\n makeDeviceActionInternalApiMock(),\n {\n onDone: resolve,\n onError: reject,\n },\n );\n }));\n });\n\n describe(\"error case\", () => {\n it(\"should error when ListApps fails\", () =>\n new Promise<void>((resolve, reject) => {\n setupListAppsMock([], true);\n const listAppsWithMetadataDeviceAction =\n new ListAppsWithMetadataDeviceAction({\n input: {},\n });\n\n const expectedStates: Array<ListAppsWithMetadataDAState> = [\n {\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.None,\n },\n status: DeviceActionStatus.Pending, // Ready\n },\n {\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.AllowListApps,\n },\n status: DeviceActionStatus.Pending, // ListAppsDeviceAction\n },\n {\n status: DeviceActionStatus.Error,\n error: new UnknownDAError(\"ListApps failed\"),\n },\n ];\n\n testDeviceActionStates(\n listAppsWithMetadataDeviceAction,\n expectedStates,\n makeDeviceActionInternalApiMock(),\n {\n onDone: resolve,\n onError: reject,\n },\n );\n }));\n\n it(\"should error when getAppsByHash rejects\", () =>\n new Promise<void>((resolve, reject) => {\n setupListAppsMock([BTC_APP]);\n const listAppsWithMetadataDeviceAction =\n new ListAppsWithMetadataDeviceAction({\n input: {},\n });\n\n getManagerApiServiceMock.mockReturnValue({\n getAppsByHash: vi\n .fn()\n .mockRejectedValue(new UnknownDAError(\"getAppsByHash failed\")),\n } as unknown as ManagerApiService);\n\n const expectedStates: Array<ListAppsWithMetadataDAState> = [\n {\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.None,\n },\n status: DeviceActionStatus.Pending, // Ready\n },\n {\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.AllowListApps,\n },\n status: DeviceActionStatus.Pending, // ListAppsDeviceAction\n },\n {\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.None,\n },\n status: DeviceActionStatus.Pending, // FetchMetadata\n },\n {\n status: DeviceActionStatus.Error,\n error: new UnknownDAError(\"getAppsByHash failed\"),\n },\n ];\n\n testDeviceActionStates(\n listAppsWithMetadataDeviceAction,\n expectedStates,\n makeDeviceActionInternalApiMock(),\n {\n onDone: resolve,\n onError: reject,\n },\n );\n }));\n\n it(\"should error when getAppsByHash fails but error is known\", () =>\n new Promise<void>((resolve, reject) => {\n setupListAppsMock([BTC_APP]);\n const listAppsWithMetadataDeviceAction =\n new ListAppsWithMetadataDeviceAction({\n input: {},\n });\n\n const error = new HttpFetchApiError(new Error(\"Failed to fetch data\"));\n\n getManagerApiServiceMock.mockReturnValue({\n getAppsByHash: vi.fn().mockResolvedValue(Left(error)),\n } as unknown as ManagerApiService);\n\n const expectedStates: Array<ListAppsWithMetadataDAState> = [\n {\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.None,\n },\n status: DeviceActionStatus.Pending, // Ready\n },\n {\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.AllowListApps,\n },\n status: DeviceActionStatus.Pending, // ListAppsDeviceAction\n },\n {\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.None,\n },\n status: DeviceActionStatus.Pending, // FetchMetadata\n },\n {\n status: DeviceActionStatus.Error,\n error,\n },\n ];\n\n testDeviceActionStates(\n listAppsWithMetadataDeviceAction,\n expectedStates,\n makeDeviceActionInternalApiMock(),\n {\n onDone: resolve,\n onError: reject,\n },\n );\n }));\n\n it(\"should error when SaveSession fails\", () =>\n new Promise<void>((resolve, reject) => {\n setupListAppsMock([BTC_APP]);\n const listAppsWithMetadataDeviceAction =\n new ListAppsWithMetadataDeviceAction({\n input: {},\n });\n\n getAppsByHashMock.mockImplementation(async () =>\n Promise.resolve(Right([BTC_APP_METADATA])),\n );\n\n vi.spyOn(\n listAppsWithMetadataDeviceAction,\n \"extractDependencies\",\n ).mockReturnValue(extractDependenciesMock());\n\n getDeviceSessionStateMock.mockReturnValue({\n sessionStateType: DeviceSessionStateType.ReadyWithoutSecureChannel,\n deviceStatus: DeviceStatus.CONNECTED,\n currentApp: \"BOLOS\",\n installedApps: [],\n });\n\n setDeviceSessionStateMock.mockImplementation(() => {\n throw new UnknownDAError(\"SaveSession failed\");\n });\n\n const expectedStates: Array<ListAppsWithMetadataDAState> = [\n {\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.None,\n },\n status: DeviceActionStatus.Pending, // Ready\n },\n {\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.AllowListApps,\n },\n status: DeviceActionStatus.Pending, // ListAppsDeviceAction\n },\n {\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.None,\n },\n status: DeviceActionStatus.Pending, // FetchMetadata\n },\n {\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.None,\n },\n status: DeviceActionStatus.Pending, // SaveSession\n },\n {\n status: DeviceActionStatus.Error,\n error: new UnknownDAError(\"SaveSession failed\"),\n },\n ];\n\n testDeviceActionStates(\n listAppsWithMetadataDeviceAction,\n expectedStates,\n makeDeviceActionInternalApiMock(),\n {\n onDone: resolve,\n onError: reject,\n },\n );\n }));\n });\n});\n"],
|
5
|
+
"mappings": "AAAA,OAAS,QAAAA,EAAM,SAAAC,MAAa,YAE5B,OAAS,gBAAAC,MAAoB,2BAC7B,OACE,WAAAC,EACA,oBAAAC,EACA,0BAAAC,EACA,mCAAAC,EACA,WAAAC,EACA,oBAAAC,MACK,yCACP,OAAS,mCAAAC,MAAuC,oDAChD,OAAS,qBAAAC,MAAyB,qDAClC,OAAS,0BAAAC,MAA8B,2DACvC,OAAS,sBAAAC,MAA0B,6CACnC,OAAS,2BAAAC,MAA+B,mDACxC,OAAS,kBAAAC,MAAsB,+BAC/B,OAAS,0BAAAC,MAA8B,yCACvC,OAAS,qBAAAC,MAAyB,qCAGlC,OAAS,oCAAAC,MAAwC,qCAGjD,GAAG,KAAK,qDAAqD,EAE7D,SAAS,mCAAoC,IAAM,CACjD,KAAM,CAAE,qBAAsBC,CAAyB,EACrDT,EAAgC,EAE5BU,EAA4B,GAAG,GAAG,EAClCC,EAA4B,GAAG,GAAG,EAClCC,EAAoB,GAAG,GAAG,EAEhC,SAASC,GAA0B,CACjC,MAAO,CACL,cAAeD,EACf,sBAAuBD,EACvB,sBAAuBD,CACzB,CACF,CAEA,WAAW,IAAM,CACf,GAAG,cAAc,CACnB,CAAC,EAED,SAAS,eAAgB,IAAM,CAC7B,GAAG,uDAAwD,IACzD,IAAI,QAAc,CAACI,EAASC,IAAW,CACrCd,EAAkB,CAAC,CAAC,EACpB,MAAMe,EACJ,IAAIR,EAAiC,CACnC,MAAO,CAAC,CACV,CAAC,EAEHC,EAAyB,gBAAgB,CACvC,cAAe,GAAG,GAAG,EAAE,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,oBAAoB,CAC/C,CAAC,EAED,MAAMY,EAAqD,CACzD,CACE,kBAAmB,CACjB,wBAAyBb,EAAwB,IACnD,EACA,OAAQD,EAAmB,OAC7B,EACA,CACE,kBAAmB,CACjB,wBAAyBC,EAAwB,aACnD,EACA,OAAQD,EAAmB,OAC7B,EACA,CACE,kBAAmB,CACjB,wBAAyBC,EAAwB,IACnD,EACA,OAAQD,EAAmB,OAC7B,EACA,CACE,kBAAmB,CACjB,wBAAyBC,EAAwB,IACnD,EACA,OAAQD,EAAmB,OAC7B,EACA,CACE,OAAQA,EAAmB,MAC3B,MAAO,IAAIE,EAAe,oBAAoB,CAChD,CACF,EAEAH,EACEc,EACAC,EACAjB,EAAgC,EAChC,CACE,OAAQc,EACR,QAASC,CACX,CACF,CACF,CAAC,CAAC,CACN,CAAC,CACH,CAAC",
|
6
|
+
"names": ["Left", "Right", "DeviceStatus", "BTC_APP", "BTC_APP_METADATA", "CUSTOM_LOCK_SCREEN_APP", "CUSTOM_LOCK_SCREEN_APP_METADATA", "ETH_APP", "ETH_APP_METADATA", "makeDeviceActionInternalApiMock", "setupListAppsMock", "testDeviceActionStates", "DeviceActionStatus", "UserInteractionRequired", "UnknownDAError", "DeviceSessionStateType", "HttpFetchApiError", "ListAppsWithMetadataDeviceAction", "getManagerApiServiceMock", "setDeviceSessionStateMock", "getDeviceSessionStateMock", "getAppsByHashMock", "extractDependenciesMock", "resolve", "reject", "listAppsWithMetadataDeviceAction", "expectedStates", "error"]
|
7
7
|
}
|
@@ -1,2 +1,2 @@
|
|
1
|
-
import{lastValueFrom as y}from"rxjs";import{InvalidStatusWordError as v}from"../../../command/Errors";import{CommandResultFactory as l}from"../../../command/model/CommandResult";import{DeviceModelId as w}from"../../../device/DeviceModel";import{DeviceStatus as a}from"../../../device/DeviceStatus";import{makeDeviceActionInternalApiMock as p}from"../../../device-action/__test-utils__/makeInternalApi";import{setupGetDeviceStatusMock as A}from"../../../device-action/__test-utils__/setupTestMachine";import{testDeviceActionStates as u}from"../../../device-action/__test-utils__/testDeviceActionStates";import{DeviceActionStatus as e}from"../../../device-action/model/DeviceActionState";import{UserInteractionRequired as t}from"../../../device-action/model/UserInteractionRequired";import{DeviceLockedError as C,DeviceNotOnboardedError as R,UnknownDAError as D}from"../../../device-action/os/Errors";import{DeviceSessionStateType as s}from"../../../device-session/DeviceSessionState";import{OpenAppDeviceAction as d}from"./OpenAppDeviceAction";vi.mock("@api/device-action/os/GetDeviceStatus/GetDeviceStatusDeviceAction");describe("OpenAppDeviceAction",()=>{const O=vi.fn(),S=vi.fn(),V=vi.fn(),c=vi.fn(),h=vi.fn(),k=vi.fn();function m(){return{getDeviceSessionState:c,setDeviceSessionState:h,getAppAndVersion:O,openApp:S,closeApp:V,isDeviceOnboarded:k}}const{getDeviceSessionState:E}=p();beforeEach(()=>{vi.resetAllMocks(),k.mockReturnValue(!0)}),describe("without overriding `extractDependencies`",()=>{it("should end if the required application is opened",()=>new Promise((r,o)=>{E.mockReturnValue({sessionStateType:s.ReadyWithoutSecureChannel,deviceStatus:a.CONNECTED,currentApp:{name:"Bitcoin",version:"1.0.0"},installedApps:[],deviceModelId:w.NANO_X}),A([{currentApp:"Bitcoin",currentAppVersion:"0.0.0"}]);const n=new d({input:{appName:"Bitcoin"}}),i=[{status:e.Pending,intermediateValue:{requiredUserInteraction:t.None}},{status:e.Pending,intermediateValue:{requiredUserInteraction:t.None}},{status:e.Completed,output:void 0}];u(n,i,p(),{onDone:r,onError:o})}))}),describe("success cases",()=>{it("should end in a success if the app is already opened",()=>new Promise((r,o)=>{c.mockReturnValue({sessionStateType:s.ReadyWithoutSecureChannel,deviceStatus:a.CONNECTED,currentApp:{name:"Bitcoin",version:"1.0.0"}}),A([{currentApp:"Bitcoin",currentAppVersion:"1.0.0"}]);const n=new d({input:{appName:"Bitcoin",unlockTimeout:void 0}});vi.spyOn(n,"extractDependencies").mockReturnValue(m());const i=[{status:e.Pending,intermediateValue:{requiredUserInteraction:t.None}},{status:e.Pending,intermediateValue:{requiredUserInteraction:t.None}},{status:e.Completed,output:void 0}];u(n,i,p(),{onDone:r,onError:o})})),it("should end in a success if a compatible app is already opened",()=>new Promise((r,o)=>{c.mockReturnValue({sessionStateType:s.ReadyWithoutSecureChannel,deviceStatus:a.CONNECTED,currentApp:{name:"Bitcoin Testnet",version:"1.0.0"}}),A([{currentApp:"Bitcoin Testnet",currentAppVersion:"1.0.0"}]);const n=new d({input:{appName:"Bitcoin",unlockTimeout:void 0,compatibleAppNames:["Bitcoin Testnet"]}});vi.spyOn(n,"extractDependencies").mockReturnValue(m());const i=[{status:e.Pending,intermediateValue:{requiredUserInteraction:t.None}},{status:e.Pending,intermediateValue:{requiredUserInteraction:t.None}},{status:e.Completed,output:void 0}];u(n,i,p(),{onDone:r,onError:o})})),it("should end in a success if the dashboard is open and open app succeeds",()=>new Promise((r,o)=>{c.mockReturnValue({sessionStateType:s.ReadyWithoutSecureChannel,deviceStatus:a.CONNECTED,currentApp:{name:"BOLOS",version:"0.0.0"}}),A([{currentApp:"Bitcoin",currentAppVersion:"1.0.0"}]),S.mockResolvedValue(l({data:void 0}));const n=new d({input:{appName:"Bitcoin"}});vi.spyOn(n,"extractDependencies").mockReturnValue(m());const i=[{status:e.Pending,intermediateValue:{requiredUserInteraction:t.None}},{status:e.Pending,intermediateValue:{requiredUserInteraction:t.None}},{status:e.Completed,output:void 0}],{observable:N}=u(n,i,p(),{onDone:r,onError:o});y(N).then(()=>{expect(h).toHaveBeenCalledWith({deviceStatus:a.CONNECTED,sessionStateType:s.ReadyWithoutSecureChannel,currentApp:{name:"Bitcoin",version:"1.0.0"}})})})),it("should end in a success if another app is open, close app succeeds and open app succeeds",()=>new Promise((r,o)=>{c.mockReturnValue({sessionStateType:s.ReadyWithoutSecureChannel,deviceStatus:a.CONNECTED,currentApp:{name:"AnotherApp",version:"0.0.0"}}),A([{currentApp:"AnotherApp",currentAppVersion:"0.0.0"},{currentApp:"Bitcoin",currentAppVersion:"1.0.0"}]),V.mockResolvedValue(l({data:void 0})),S.mockResolvedValue(l({data:void 0}));const n=new d({input:{appName:"Bitcoin"}});vi.spyOn(n,"extractDependencies").mockReturnValue(m());const i=[{status:e.Pending,intermediateValue:{requiredUserInteraction:t.None}},{status:e.Pending,intermediateValue:{requiredUserInteraction:t.None}},{status:e.Pending,intermediateValue:{requiredUserInteraction:t.None}},{status:e.Pending,intermediateValue:{requiredUserInteraction:t.ConfirmOpenApp}},{status:e.Pending,intermediateValue:{requiredUserInteraction:t.None}},{status:e.Pending,intermediateValue:{requiredUserInteraction:t.None}},{status:e.Completed,output:void 0}],{observable:N}=u(n,i,p(),{onDone:r,onError:o});y(N).then(()=>{expect(h).toHaveBeenCalledWith({currentApp:{name:"Bitcoin",version:"1.0.0"},deviceStatus:a.CONNECTED,sessionStateType:s.ReadyWithoutSecureChannel})})}))}),describe("errors cases",()=>{it("should end in an error if the device is not onboarded",()=>new Promise((r,o)=>{c.mockReturnValue({sessionStateType:s.ReadyWithoutSecureChannel,deviceStatus:a.CONNECTED,currentApp:{name:"mockedCurrentApp",version:"1.0.0"}}),k.mockReturnValue(!1);const n=new d({input:{appName:"Bitcoin"}});vi.spyOn(n,"extractDependencies").mockReturnValue(m());const i=[{error:new R,status:e.Error}];u(n,i,p(),{onDone:r,onError:o})})),it("should end in an error if the device is locked",()=>new Promise((r,o)=>{c.mockReturnValue({sessionStateType:s.ReadyWithoutSecureChannel,deviceStatus:a.LOCKED,currentApp:{name:"mockedCurrentApp",version:"1.0.0"}}),A([new C]);const n=new d({input:{appName:"Bitcoin"}});vi.spyOn(n,"extractDependencies").mockReturnValue(m());const i=[{status:e.Pending,intermediateValue:{requiredUserInteraction:t.None}},{status:e.Pending,intermediateValue:{requiredUserInteraction:t.None}},{status:e.Error,error:new C}];u(n,i,p(),{onDone:r,onError:o})})),it("should end in an error if getAppAndVersion returns an error",()=>new Promise((r,o)=>{c.mockReturnValue({sessionStateType:s.ReadyWithoutSecureChannel,deviceStatus:a.CONNECTED,currentApp:{name:"mockedCurrentApp",version:"1.0.0"}}),A([new v("mocked error")]);const n=new d({input:{appName:"Bitcoin"}});vi.spyOn(n,"extractDependencies").mockReturnValue(m());const i=[{status:e.Pending,intermediateValue:{requiredUserInteraction:t.None}},{status:e.Pending,intermediateValue:{requiredUserInteraction:t.None}},{status:e.Error,error:new v("mocked error")}];u(n,i,p(),{onDone:r,onError:o})})),it("should end in an error if the dashboard is open and open app returns an error",()=>new Promise((r,o)=>{c.mockReturnValue(l({data:{sessionStateType:s.ReadyWithoutSecureChannel,deviceStatus:a.CONNECTED,currentApp:{name:"BOLOS",version:"0.0.0"}}})),O.mockResolvedValue(l({data:{name:"BOLOS",version:"0.0.0"}})),A([{currentApp:"BOLOS",currentAppVersion:"0.0.0"}]),S.mockResolvedValue(l({error:new v("mocked error")}));const n=new d({input:{appName:"Bitcoin"}});vi.spyOn(n,"extractDependencies").mockReturnValue(m());const i=[{status:e.Pending,intermediateValue:{requiredUserInteraction:t.None}},{status:e.Pending,intermediateValue:{requiredUserInteraction:t.None}},{status:e.Pending,intermediateValue:{requiredUserInteraction:t.ConfirmOpenApp}},{status:e.Error,error:new v("mocked error")}];u(n,i,p(),{onDone:r,onError:o})})),it("should end in an error if another app is open, and close app returns an error",()=>new Promise((r,o)=>{c.mockReturnValue({sessionStateType:s.ReadyWithoutSecureChannel,deviceStatus:a.CONNECTED,currentApp:{name:"AnotherApp",version:"0.0.0"}}),A([{currentApp:"AnotherApp",currentAppVersion:"0.0.0"}]),V.mockResolvedValue(l({error:new v("mocked error")}));const n=new d({input:{appName:"Bitcoin"}});vi.spyOn(n,"extractDependencies").mockReturnValue(m());const i=[{status:e.Pending,intermediateValue:{requiredUserInteraction:t.None}},{status:e.Pending,intermediateValue:{requiredUserInteraction:t.None}},{status:e.Pending,intermediateValue:{requiredUserInteraction:t.None}},{status:e.Error,error:new v("mocked error")}];u(n,i,p(),{onDone:r,onError:o})})),it("should end in an error if another app is open, close app succeeds but open app returns an error",()=>new Promise((r,o)=>{c.mockReturnValue({sessionStateType:s.ReadyWithoutSecureChannel,deviceStatus:a.CONNECTED,currentApp:{name:"AnotherApp",version:"0.0.0"}}),A([{currentApp:"AnotherApp",currentAppVersion:"0.0.0"}]),V.mockResolvedValue(l({data:void 0})),S.mockResolvedValue(l({error:new v("mocked error")}));const n=new d({input:{appName:"Bitcoin"}});vi.spyOn(n,"extractDependencies").mockReturnValue(m());const i=[{status:e.Pending,intermediateValue:{requiredUserInteraction:t.None}},{status:e.Pending,intermediateValue:{requiredUserInteraction:t.None}},{status:e.Pending,intermediateValue:{requiredUserInteraction:t.None}},{status:e.Pending,intermediateValue:{requiredUserInteraction:t.ConfirmOpenApp}},{status:e.Error,error:new v("mocked error")}];u(n,i,p(),{onDone:r,onError:o})})),it("should end in an error if getAppAndVersion actor throws an error",()=>new Promise((r,o)=>{c.mockReturnValue({sessionStateType:s.ReadyWithoutSecureChannel,deviceStatus:a.CONNECTED,currentApp:{name:"mockedCurrentApp",version:"1.0.0"}}),A([new D("Unknown error")]);const n=new d({input:{appName:"Bitcoin"}});vi.spyOn(n,"extractDependencies").mockReturnValue(m());const i=[{status:e.Pending,intermediateValue:{requiredUserInteraction:t.None}},{status:e.Pending,intermediateValue:{requiredUserInteraction:t.None}},{status:e.Error,error:new D("Unknown error")}];u(n,i,p(),{onDone:r,onError:o})})),it("should end in an error if openApp actor throws an error",()=>new Promise((r,o)=>{c.mockReturnValue(l({data:{sessionStateType:s.ReadyWithoutSecureChannel,deviceStatus:a.CONNECTED,currentApp:{name:"BOLOS",version:"0.0.0"}}})),A([{currentApp:"BOLOS",currentAppVersion:"0.0.0"}]),S.mockImplementation(()=>{throw new D("Unknown error")});const n=new d({input:{appName:"Bitcoin"}});vi.spyOn(n,"extractDependencies").mockReturnValue(m());const i=[{status:e.Pending,intermediateValue:{requiredUserInteraction:t.None}},{status:e.Pending,intermediateValue:{requiredUserInteraction:t.None}},{status:e.Pending,intermediateValue:{requiredUserInteraction:t.ConfirmOpenApp}},{status:e.Error,error:new D("Unknown error")}];u(n,i,p(),{onDone:r,onError:o})})),it("should end in an error if closeApp actor throws an error",()=>new Promise((r,o)=>{c.mockReturnValue(l({data:{sessionStateType:s.ReadyWithoutSecureChannel,deviceStatus:a.CONNECTED,currentApp:{name:"BOLOS",version:"0.0.0"}}})),A([{currentApp:"anApp",currentAppVersion:"0.0.0"}]),V.mockImplementation(()=>{throw new D("Unknown error")});const n=new d({input:{appName:"Bitcoin"}});vi.spyOn(n,"extractDependencies").mockReturnValue(m());const i=[{status:e.Pending,intermediateValue:{requiredUserInteraction:t.None}},{status:e.Pending,intermediateValue:{requiredUserInteraction:t.None}},{status:e.Pending,intermediateValue:{requiredUserInteraction:t.None}},{status:e.Error,error:new D("Unknown error")}];u(n,i,p(),{onDone:r,onError:o})})),it("should emit a stopped state if the action is cancelled",()=>new Promise((r,o)=>{c.mockReturnValue({sessionStateType:s.ReadyWithoutSecureChannel,deviceStatus:a.CONNECTED,currentApp:{name:"AnotherApp",version:"0.0.0"}}),A([{currentApp:"AnotherApp",currentAppVersion:"0.0.0"}]);const n=new d({input:{appName:"Bitcoin"}});vi.spyOn(n,"extractDependencies").mockReturnValue(m());const i=[{status:e.Pending,intermediateValue:{requiredUserInteraction:t.None}},{status:e.Pending,intermediateValue:{requiredUserInteraction:t.None}},{status:e.Stopped}],{cancel:N}=u(n,i,p(),{onDone:r,onError:o});N()}))})});
|
1
|
+
import{lastValueFrom as y}from"rxjs";import{InvalidStatusWordError as v}from"../../../command/Errors";import{CommandResultFactory as l}from"../../../command/model/CommandResult";import{DeviceModelId as w}from"../../../device/DeviceModel";import{DeviceStatus as a}from"../../../device/DeviceStatus";import{makeDeviceActionInternalApiMock as p}from"../../../device-action/__test-utils__/makeInternalApi";import{setupGetDeviceStatusMock as A}from"../../../device-action/__test-utils__/setupTestMachine";import{testDeviceActionStates as u}from"../../../device-action/__test-utils__/testDeviceActionStates";import{DeviceActionStatus as e}from"../../../device-action/model/DeviceActionState";import{UserInteractionRequired as t}from"../../../device-action/model/UserInteractionRequired";import{DeviceLockedError as C,DeviceNotOnboardedError as R,UnknownDAError as D}from"../../../device-action/os/Errors";import{DeviceSessionStateType as s}from"../../../device-session/DeviceSessionState";import{OpenAppDeviceAction as d}from"./OpenAppDeviceAction";vi.mock("@api/device-action/os/GetDeviceStatus/GetDeviceStatusDeviceAction");describe("OpenAppDeviceAction",()=>{const O=vi.fn(),S=vi.fn(),V=vi.fn(),c=vi.fn(),h=vi.fn(),k=vi.fn();function m(){return{getDeviceSessionState:c,setDeviceSessionState:h,getAppAndVersion:O,openApp:S,closeApp:V,isDeviceOnboarded:k}}const{getDeviceSessionState:E}=p();beforeEach(()=>{vi.resetAllMocks(),k.mockReturnValue(!0)}),describe("without overriding `extractDependencies`",()=>{it("should end if the required application is opened",()=>new Promise((r,o)=>{E.mockReturnValue({sessionStateType:s.ReadyWithoutSecureChannel,deviceStatus:a.CONNECTED,currentApp:{name:"Bitcoin",version:"1.0.0"},installedApps:[],deviceModelId:w.NANO_X,isSecureConnectionAllowed:!1}),A([{currentApp:"Bitcoin",currentAppVersion:"0.0.0"}]);const n=new d({input:{appName:"Bitcoin"}}),i=[{status:e.Pending,intermediateValue:{requiredUserInteraction:t.None}},{status:e.Pending,intermediateValue:{requiredUserInteraction:t.None}},{status:e.Completed,output:void 0}];u(n,i,p(),{onDone:r,onError:o})}))}),describe("success cases",()=>{it("should end in a success if the app is already opened",()=>new Promise((r,o)=>{c.mockReturnValue({sessionStateType:s.ReadyWithoutSecureChannel,deviceStatus:a.CONNECTED,currentApp:{name:"Bitcoin",version:"1.0.0"}}),A([{currentApp:"Bitcoin",currentAppVersion:"1.0.0"}]);const n=new d({input:{appName:"Bitcoin",unlockTimeout:void 0}});vi.spyOn(n,"extractDependencies").mockReturnValue(m());const i=[{status:e.Pending,intermediateValue:{requiredUserInteraction:t.None}},{status:e.Pending,intermediateValue:{requiredUserInteraction:t.None}},{status:e.Completed,output:void 0}];u(n,i,p(),{onDone:r,onError:o})})),it("should end in a success if a compatible app is already opened",()=>new Promise((r,o)=>{c.mockReturnValue({sessionStateType:s.ReadyWithoutSecureChannel,deviceStatus:a.CONNECTED,currentApp:{name:"Bitcoin Testnet",version:"1.0.0"}}),A([{currentApp:"Bitcoin Testnet",currentAppVersion:"1.0.0"}]);const n=new d({input:{appName:"Bitcoin",unlockTimeout:void 0,compatibleAppNames:["Bitcoin Testnet"]}});vi.spyOn(n,"extractDependencies").mockReturnValue(m());const i=[{status:e.Pending,intermediateValue:{requiredUserInteraction:t.None}},{status:e.Pending,intermediateValue:{requiredUserInteraction:t.None}},{status:e.Completed,output:void 0}];u(n,i,p(),{onDone:r,onError:o})})),it("should end in a success if the dashboard is open and open app succeeds",()=>new Promise((r,o)=>{c.mockReturnValue({sessionStateType:s.ReadyWithoutSecureChannel,deviceStatus:a.CONNECTED,currentApp:{name:"BOLOS",version:"0.0.0"}}),A([{currentApp:"Bitcoin",currentAppVersion:"1.0.0"}]),S.mockResolvedValue(l({data:void 0}));const n=new d({input:{appName:"Bitcoin"}});vi.spyOn(n,"extractDependencies").mockReturnValue(m());const i=[{status:e.Pending,intermediateValue:{requiredUserInteraction:t.None}},{status:e.Pending,intermediateValue:{requiredUserInteraction:t.None}},{status:e.Completed,output:void 0}],{observable:N}=u(n,i,p(),{onDone:r,onError:o});y(N).then(()=>{expect(h).toHaveBeenCalledWith({deviceStatus:a.CONNECTED,sessionStateType:s.ReadyWithoutSecureChannel,currentApp:{name:"Bitcoin",version:"1.0.0"}})})})),it("should end in a success if another app is open, close app succeeds and open app succeeds",()=>new Promise((r,o)=>{c.mockReturnValue({sessionStateType:s.ReadyWithoutSecureChannel,deviceStatus:a.CONNECTED,currentApp:{name:"AnotherApp",version:"0.0.0"}}),A([{currentApp:"AnotherApp",currentAppVersion:"0.0.0"},{currentApp:"Bitcoin",currentAppVersion:"1.0.0"}]),V.mockResolvedValue(l({data:void 0})),S.mockResolvedValue(l({data:void 0}));const n=new d({input:{appName:"Bitcoin"}});vi.spyOn(n,"extractDependencies").mockReturnValue(m());const i=[{status:e.Pending,intermediateValue:{requiredUserInteraction:t.None}},{status:e.Pending,intermediateValue:{requiredUserInteraction:t.None}},{status:e.Pending,intermediateValue:{requiredUserInteraction:t.None}},{status:e.Pending,intermediateValue:{requiredUserInteraction:t.ConfirmOpenApp}},{status:e.Pending,intermediateValue:{requiredUserInteraction:t.None}},{status:e.Pending,intermediateValue:{requiredUserInteraction:t.None}},{status:e.Completed,output:void 0}],{observable:N}=u(n,i,p(),{onDone:r,onError:o});y(N).then(()=>{expect(h).toHaveBeenCalledWith({currentApp:{name:"Bitcoin",version:"1.0.0"},deviceStatus:a.CONNECTED,sessionStateType:s.ReadyWithoutSecureChannel})})}))}),describe("errors cases",()=>{it("should end in an error if the device is not onboarded",()=>new Promise((r,o)=>{c.mockReturnValue({sessionStateType:s.ReadyWithoutSecureChannel,deviceStatus:a.CONNECTED,currentApp:{name:"mockedCurrentApp",version:"1.0.0"}}),k.mockReturnValue(!1);const n=new d({input:{appName:"Bitcoin"}});vi.spyOn(n,"extractDependencies").mockReturnValue(m());const i=[{error:new R,status:e.Error}];u(n,i,p(),{onDone:r,onError:o})})),it("should end in an error if the device is locked",()=>new Promise((r,o)=>{c.mockReturnValue({sessionStateType:s.ReadyWithoutSecureChannel,deviceStatus:a.LOCKED,currentApp:{name:"mockedCurrentApp",version:"1.0.0"}}),A([new C]);const n=new d({input:{appName:"Bitcoin"}});vi.spyOn(n,"extractDependencies").mockReturnValue(m());const i=[{status:e.Pending,intermediateValue:{requiredUserInteraction:t.None}},{status:e.Pending,intermediateValue:{requiredUserInteraction:t.None}},{status:e.Error,error:new C}];u(n,i,p(),{onDone:r,onError:o})})),it("should end in an error if getAppAndVersion returns an error",()=>new Promise((r,o)=>{c.mockReturnValue({sessionStateType:s.ReadyWithoutSecureChannel,deviceStatus:a.CONNECTED,currentApp:{name:"mockedCurrentApp",version:"1.0.0"}}),A([new v("mocked error")]);const n=new d({input:{appName:"Bitcoin"}});vi.spyOn(n,"extractDependencies").mockReturnValue(m());const i=[{status:e.Pending,intermediateValue:{requiredUserInteraction:t.None}},{status:e.Pending,intermediateValue:{requiredUserInteraction:t.None}},{status:e.Error,error:new v("mocked error")}];u(n,i,p(),{onDone:r,onError:o})})),it("should end in an error if the dashboard is open and open app returns an error",()=>new Promise((r,o)=>{c.mockReturnValue(l({data:{sessionStateType:s.ReadyWithoutSecureChannel,deviceStatus:a.CONNECTED,currentApp:{name:"BOLOS",version:"0.0.0"}}})),O.mockResolvedValue(l({data:{name:"BOLOS",version:"0.0.0"}})),A([{currentApp:"BOLOS",currentAppVersion:"0.0.0"}]),S.mockResolvedValue(l({error:new v("mocked error")}));const n=new d({input:{appName:"Bitcoin"}});vi.spyOn(n,"extractDependencies").mockReturnValue(m());const i=[{status:e.Pending,intermediateValue:{requiredUserInteraction:t.None}},{status:e.Pending,intermediateValue:{requiredUserInteraction:t.None}},{status:e.Pending,intermediateValue:{requiredUserInteraction:t.ConfirmOpenApp}},{status:e.Error,error:new v("mocked error")}];u(n,i,p(),{onDone:r,onError:o})})),it("should end in an error if another app is open, and close app returns an error",()=>new Promise((r,o)=>{c.mockReturnValue({sessionStateType:s.ReadyWithoutSecureChannel,deviceStatus:a.CONNECTED,currentApp:{name:"AnotherApp",version:"0.0.0"}}),A([{currentApp:"AnotherApp",currentAppVersion:"0.0.0"}]),V.mockResolvedValue(l({error:new v("mocked error")}));const n=new d({input:{appName:"Bitcoin"}});vi.spyOn(n,"extractDependencies").mockReturnValue(m());const i=[{status:e.Pending,intermediateValue:{requiredUserInteraction:t.None}},{status:e.Pending,intermediateValue:{requiredUserInteraction:t.None}},{status:e.Pending,intermediateValue:{requiredUserInteraction:t.None}},{status:e.Error,error:new v("mocked error")}];u(n,i,p(),{onDone:r,onError:o})})),it("should end in an error if another app is open, close app succeeds but open app returns an error",()=>new Promise((r,o)=>{c.mockReturnValue({sessionStateType:s.ReadyWithoutSecureChannel,deviceStatus:a.CONNECTED,currentApp:{name:"AnotherApp",version:"0.0.0"}}),A([{currentApp:"AnotherApp",currentAppVersion:"0.0.0"}]),V.mockResolvedValue(l({data:void 0})),S.mockResolvedValue(l({error:new v("mocked error")}));const n=new d({input:{appName:"Bitcoin"}});vi.spyOn(n,"extractDependencies").mockReturnValue(m());const i=[{status:e.Pending,intermediateValue:{requiredUserInteraction:t.None}},{status:e.Pending,intermediateValue:{requiredUserInteraction:t.None}},{status:e.Pending,intermediateValue:{requiredUserInteraction:t.None}},{status:e.Pending,intermediateValue:{requiredUserInteraction:t.ConfirmOpenApp}},{status:e.Error,error:new v("mocked error")}];u(n,i,p(),{onDone:r,onError:o})})),it("should end in an error if getAppAndVersion actor throws an error",()=>new Promise((r,o)=>{c.mockReturnValue({sessionStateType:s.ReadyWithoutSecureChannel,deviceStatus:a.CONNECTED,currentApp:{name:"mockedCurrentApp",version:"1.0.0"}}),A([new D("Unknown error")]);const n=new d({input:{appName:"Bitcoin"}});vi.spyOn(n,"extractDependencies").mockReturnValue(m());const i=[{status:e.Pending,intermediateValue:{requiredUserInteraction:t.None}},{status:e.Pending,intermediateValue:{requiredUserInteraction:t.None}},{status:e.Error,error:new D("Unknown error")}];u(n,i,p(),{onDone:r,onError:o})})),it("should end in an error if openApp actor throws an error",()=>new Promise((r,o)=>{c.mockReturnValue(l({data:{sessionStateType:s.ReadyWithoutSecureChannel,deviceStatus:a.CONNECTED,currentApp:{name:"BOLOS",version:"0.0.0"}}})),A([{currentApp:"BOLOS",currentAppVersion:"0.0.0"}]),S.mockImplementation(()=>{throw new D("Unknown error")});const n=new d({input:{appName:"Bitcoin"}});vi.spyOn(n,"extractDependencies").mockReturnValue(m());const i=[{status:e.Pending,intermediateValue:{requiredUserInteraction:t.None}},{status:e.Pending,intermediateValue:{requiredUserInteraction:t.None}},{status:e.Pending,intermediateValue:{requiredUserInteraction:t.ConfirmOpenApp}},{status:e.Error,error:new D("Unknown error")}];u(n,i,p(),{onDone:r,onError:o})})),it("should end in an error if closeApp actor throws an error",()=>new Promise((r,o)=>{c.mockReturnValue(l({data:{sessionStateType:s.ReadyWithoutSecureChannel,deviceStatus:a.CONNECTED,currentApp:{name:"BOLOS",version:"0.0.0"}}})),A([{currentApp:"anApp",currentAppVersion:"0.0.0"}]),V.mockImplementation(()=>{throw new D("Unknown error")});const n=new d({input:{appName:"Bitcoin"}});vi.spyOn(n,"extractDependencies").mockReturnValue(m());const i=[{status:e.Pending,intermediateValue:{requiredUserInteraction:t.None}},{status:e.Pending,intermediateValue:{requiredUserInteraction:t.None}},{status:e.Pending,intermediateValue:{requiredUserInteraction:t.None}},{status:e.Error,error:new D("Unknown error")}];u(n,i,p(),{onDone:r,onError:o})})),it("should emit a stopped state if the action is cancelled",()=>new Promise((r,o)=>{c.mockReturnValue({sessionStateType:s.ReadyWithoutSecureChannel,deviceStatus:a.CONNECTED,currentApp:{name:"AnotherApp",version:"0.0.0"}}),A([{currentApp:"AnotherApp",currentAppVersion:"0.0.0"}]);const n=new d({input:{appName:"Bitcoin"}});vi.spyOn(n,"extractDependencies").mockReturnValue(m());const i=[{status:e.Pending,intermediateValue:{requiredUserInteraction:t.None}},{status:e.Pending,intermediateValue:{requiredUserInteraction:t.None}},{status:e.Stopped}],{cancel:N}=u(n,i,p(),{onDone:r,onError:o});N()}))})});
|
2
2
|
//# sourceMappingURL=OpenAppDeviceAction.test.js.map
|
package/lib/esm/src/api/device-action/os/OpenAppDeviceAction/OpenAppDeviceAction.test.js.map
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
{
|
2
2
|
"version": 3,
|
3
3
|
"sources": ["../../../../../../../src/api/device-action/os/OpenAppDeviceAction/OpenAppDeviceAction.test.ts"],
|
4
|
-
"sourcesContent": ["import { lastValueFrom } from \"rxjs\";\n\nimport { InvalidStatusWordError } from \"@api/command/Errors\";\nimport { CommandResultFactory } from \"@api/command/model/CommandResult\";\nimport { DeviceModelId } from \"@api/device/DeviceModel\";\nimport { DeviceStatus } from \"@api/device/DeviceStatus\";\nimport { makeDeviceActionInternalApiMock } from \"@api/device-action/__test-utils__/makeInternalApi\";\nimport { setupGetDeviceStatusMock } from \"@api/device-action/__test-utils__/setupTestMachine\";\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 { OpenAppDeviceAction } from \"./OpenAppDeviceAction\";\nimport type { OpenAppDAState } from \"./types\";\n\nvi.mock(\"@api/device-action/os/GetDeviceStatus/GetDeviceStatusDeviceAction\");\n\ndescribe(\"OpenAppDeviceAction\", () => {\n const getAppAndVersionMock = vi.fn();\n const openAppMock = vi.fn();\n const closeAppMock = vi.fn();\n const getDeviceSessionStateMock = vi.fn();\n const setDeviceSessionStateMock = vi.fn();\n const isDeviceOnboardedMock = vi.fn();\n\n function extractDependenciesMock() {\n return {\n getDeviceSessionState: getDeviceSessionStateMock,\n setDeviceSessionState: setDeviceSessionStateMock,\n getAppAndVersion: getAppAndVersionMock,\n openApp: openAppMock,\n closeApp: closeAppMock,\n isDeviceOnboarded: isDeviceOnboardedMock,\n };\n }\n\n const { getDeviceSessionState: apiGetDeviceSessionStateMock } =\n makeDeviceActionInternalApiMock();\n\n beforeEach(() => {\n vi.resetAllMocks();\n isDeviceOnboardedMock.mockReturnValue(true);\n });\n\n describe(\"without overriding `extractDependencies`\", () => {\n it(\"should end if the required application is opened\", () =>\n new Promise<void>((resolve, reject) => {\n apiGetDeviceSessionStateMock.mockReturnValue({\n sessionStateType: DeviceSessionStateType.ReadyWithoutSecureChannel,\n deviceStatus: DeviceStatus.CONNECTED,\n currentApp: { name: \"Bitcoin\", version: \"1.0.0\" },\n installedApps: [],\n deviceModelId: DeviceModelId.NANO_X,\n });\n setupGetDeviceStatusMock([\n {\n currentApp: \"Bitcoin\",\n currentAppVersion: \"0.0.0\",\n },\n ]);\n\n const openAppDeviceAction = new OpenAppDeviceAction({\n input: { appName: \"Bitcoin\" },\n });\n\n const expectedStates: Array<OpenAppDAState> = [\n {\n status: DeviceActionStatus.Pending, // get onboarding status\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.None,\n },\n },\n {\n status: DeviceActionStatus.Pending, // get device status\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.None,\n },\n },\n {\n status: DeviceActionStatus.Completed,\n output: undefined,\n },\n ];\n\n testDeviceActionStates(\n openAppDeviceAction,\n expectedStates,\n makeDeviceActionInternalApiMock(),\n {\n onDone: resolve,\n onError: reject,\n },\n );\n }));\n });\n\n describe(\"success cases\", () => {\n it(\"should end in a success if the app is already opened\", () =>\n new Promise<void>((resolve, reject) => {\n getDeviceSessionStateMock.mockReturnValue({\n sessionStateType: DeviceSessionStateType.ReadyWithoutSecureChannel,\n deviceStatus: DeviceStatus.CONNECTED,\n currentApp: { name: \"Bitcoin\", version: \"1.0.0\" },\n });\n\n setupGetDeviceStatusMock([\n {\n currentApp: \"Bitcoin\",\n currentAppVersion: \"1.0.0\",\n },\n ]);\n const openAppDeviceAction = new OpenAppDeviceAction({\n input: { appName: \"Bitcoin\", unlockTimeout: undefined },\n });\n vi.spyOn(openAppDeviceAction, \"extractDependencies\").mockReturnValue(\n extractDependenciesMock(),\n );\n\n const expectedStates: Array<OpenAppDAState> = [\n {\n status: DeviceActionStatus.Pending, // get onboarding status\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.None,\n },\n },\n {\n status: DeviceActionStatus.Pending, // get app and version\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.None,\n },\n },\n {\n status: DeviceActionStatus.Completed,\n output: undefined,\n },\n ];\n\n testDeviceActionStates(\n openAppDeviceAction,\n expectedStates,\n makeDeviceActionInternalApiMock(),\n {\n onDone: resolve,\n onError: reject,\n },\n );\n }));\n\n it(\"should end in a success if a compatible app is already opened\", () =>\n new Promise<void>((resolve, reject) => {\n getDeviceSessionStateMock.mockReturnValue({\n sessionStateType: DeviceSessionStateType.ReadyWithoutSecureChannel,\n deviceStatus: DeviceStatus.CONNECTED,\n currentApp: {\n name: \"Bitcoin Testnet\",\n version: \"1.0.0\",\n },\n });\n\n setupGetDeviceStatusMock([\n {\n currentApp: \"Bitcoin Testnet\",\n currentAppVersion: \"1.0.0\",\n },\n ]);\n const openAppDeviceAction = new OpenAppDeviceAction({\n input: {\n appName: \"Bitcoin\",\n unlockTimeout: undefined,\n compatibleAppNames: [\"Bitcoin Testnet\"],\n },\n });\n vi.spyOn(openAppDeviceAction, \"extractDependencies\").mockReturnValue(\n extractDependenciesMock(),\n );\n\n const expectedStates: Array<OpenAppDAState> = [\n {\n status: DeviceActionStatus.Pending, // get onboarding status\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.None,\n },\n },\n {\n status: DeviceActionStatus.Pending, // get app and version\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.None,\n },\n },\n {\n status: DeviceActionStatus.Completed,\n output: undefined,\n },\n ];\n\n testDeviceActionStates(\n openAppDeviceAction,\n expectedStates,\n makeDeviceActionInternalApiMock(),\n {\n onDone: resolve,\n onError: reject,\n },\n );\n }));\n\n it(\"should end in a success if the dashboard is open and open app succeeds\", () =>\n new Promise<void>((resolve, reject) => {\n getDeviceSessionStateMock.mockReturnValue({\n sessionStateType: DeviceSessionStateType.ReadyWithoutSecureChannel,\n deviceStatus: DeviceStatus.CONNECTED,\n currentApp: { name: \"BOLOS\", version: \"0.0.0\" },\n });\n\n setupGetDeviceStatusMock([\n {\n currentApp: \"Bitcoin\",\n currentAppVersion: \"1.0.0\",\n },\n ]);\n\n openAppMock.mockResolvedValue(\n CommandResultFactory({ data: undefined }),\n );\n\n const openAppDeviceAction = new OpenAppDeviceAction({\n input: { appName: \"Bitcoin\" },\n });\n vi.spyOn(openAppDeviceAction, \"extractDependencies\").mockReturnValue(\n extractDependenciesMock(),\n );\n\n const expectedStates: Array<OpenAppDAState> = [\n {\n status: DeviceActionStatus.Pending, // get app and version\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.None,\n },\n },\n {\n status: DeviceActionStatus.Pending, // get app and version\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.None,\n },\n },\n {\n status: DeviceActionStatus.Completed,\n output: undefined,\n },\n ];\n\n const { observable } = testDeviceActionStates(\n openAppDeviceAction,\n expectedStates,\n makeDeviceActionInternalApiMock(),\n {\n onDone: resolve,\n onError: reject,\n },\n );\n\n lastValueFrom(observable).then(() => {\n expect(setDeviceSessionStateMock).toHaveBeenCalledWith({\n deviceStatus: DeviceStatus.CONNECTED,\n sessionStateType: DeviceSessionStateType.ReadyWithoutSecureChannel,\n currentApp: { name: \"Bitcoin\", version: \"1.0.0\" },\n });\n });\n }));\n\n it(\"should end in a success if another app is open, close app succeeds and open app succeeds\", () =>\n new Promise<void>((resolve, reject) => {\n getDeviceSessionStateMock.mockReturnValue({\n sessionStateType: DeviceSessionStateType.ReadyWithoutSecureChannel,\n deviceStatus: DeviceStatus.CONNECTED,\n currentApp: { name: \"AnotherApp\", version: \"0.0.0\" },\n });\n setupGetDeviceStatusMock([\n {\n currentApp: \"AnotherApp\",\n currentAppVersion: \"0.0.0\",\n },\n { currentApp: \"Bitcoin\", currentAppVersion: \"1.0.0\" },\n ]);\n closeAppMock.mockResolvedValue(\n CommandResultFactory({ data: undefined }),\n );\n openAppMock.mockResolvedValue(\n CommandResultFactory({ data: undefined }),\n );\n\n const openAppDeviceAction = new OpenAppDeviceAction({\n input: { appName: \"Bitcoin\" },\n });\n vi.spyOn(openAppDeviceAction, \"extractDependencies\").mockReturnValue(\n extractDependenciesMock(),\n );\n\n const expectedStates: Array<OpenAppDAState> = [\n {\n status: DeviceActionStatus.Pending, // get app and version\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.None,\n },\n },\n {\n status: DeviceActionStatus.Pending, // close app\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.None,\n },\n },\n {\n status: DeviceActionStatus.Pending, // get device status\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.None,\n },\n },\n {\n status: DeviceActionStatus.Pending, // open app\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.ConfirmOpenApp,\n },\n },\n {\n status: DeviceActionStatus.Pending, // get app and version\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.None,\n },\n },\n {\n status: DeviceActionStatus.Pending, // get app and version\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.None,\n },\n },\n {\n status: DeviceActionStatus.Completed,\n output: undefined,\n },\n ];\n\n const { observable } = testDeviceActionStates(\n openAppDeviceAction,\n expectedStates,\n makeDeviceActionInternalApiMock(),\n {\n onDone: resolve,\n onError: reject,\n },\n );\n\n lastValueFrom(observable).then(() => {\n expect(setDeviceSessionStateMock).toHaveBeenCalledWith({\n currentApp: { name: \"Bitcoin\", version: \"1.0.0\" },\n deviceStatus: DeviceStatus.CONNECTED,\n sessionStateType: DeviceSessionStateType.ReadyWithoutSecureChannel,\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.CONNECTED,\n currentApp: { name: \"mockedCurrentApp\", version: \"1.0.0\" },\n });\n isDeviceOnboardedMock.mockReturnValue(false);\n\n const openAppDeviceAction = new OpenAppDeviceAction({\n input: { appName: \"Bitcoin\" },\n });\n\n vi.spyOn(openAppDeviceAction, \"extractDependencies\").mockReturnValue(\n extractDependenciesMock(),\n );\n\n const expectedStates: Array<OpenAppDAState> = [\n {\n error: new DeviceNotOnboardedError(),\n status: DeviceActionStatus.Error,\n },\n ];\n\n testDeviceActionStates(\n openAppDeviceAction,\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\", () =>\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 setupGetDeviceStatusMock([new DeviceLockedError()]);\n\n const openAppDeviceAction = new OpenAppDeviceAction({\n input: { appName: \"Bitcoin\" },\n });\n\n vi.spyOn(openAppDeviceAction, \"extractDependencies\").mockReturnValue(\n extractDependenciesMock(),\n );\n\n const expectedStates: Array<OpenAppDAState> = [\n {\n status: DeviceActionStatus.Pending,\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.None,\n },\n },\n {\n status: DeviceActionStatus.Pending,\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.None,\n },\n },\n {\n status: DeviceActionStatus.Error,\n error: new DeviceLockedError(),\n },\n ];\n\n testDeviceActionStates(\n openAppDeviceAction,\n expectedStates,\n makeDeviceActionInternalApiMock(),\n {\n onDone: resolve,\n onError: reject,\n },\n );\n }));\n\n it(\"should end in an error if getAppAndVersion returns an error\", () =>\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 setupGetDeviceStatusMock([new InvalidStatusWordError(\"mocked error\")]);\n\n const openAppDeviceAction = new OpenAppDeviceAction({\n input: { appName: \"Bitcoin\" },\n });\n\n vi.spyOn(openAppDeviceAction, \"extractDependencies\").mockReturnValue(\n extractDependenciesMock(),\n );\n\n const expectedStates: Array<OpenAppDAState> = [\n {\n status: DeviceActionStatus.Pending, // get app and version\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.None,\n },\n },\n {\n status: DeviceActionStatus.Pending, // get device status\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.None,\n },\n },\n {\n status: DeviceActionStatus.Error,\n error: new InvalidStatusWordError(\"mocked error\"),\n },\n ];\n\n testDeviceActionStates(\n openAppDeviceAction,\n expectedStates,\n makeDeviceActionInternalApiMock(),\n {\n onDone: resolve,\n onError: reject,\n },\n );\n }));\n\n it(\"should end in an error if the dashboard is open and open app returns an error\", () =>\n new Promise<void>((resolve, reject) => {\n getDeviceSessionStateMock.mockReturnValue(\n CommandResultFactory({\n data: {\n sessionStateType:\n DeviceSessionStateType.ReadyWithoutSecureChannel,\n deviceStatus: DeviceStatus.CONNECTED,\n currentApp: { name: \"BOLOS\", version: \"0.0.0\" },\n },\n }),\n );\n getAppAndVersionMock.mockResolvedValue(\n CommandResultFactory({\n data: {\n name: \"BOLOS\",\n version: \"0.0.0\",\n },\n }),\n );\n setupGetDeviceStatusMock([\n {\n currentApp: \"BOLOS\",\n currentAppVersion: \"0.0.0\",\n },\n ]);\n openAppMock.mockResolvedValue(\n CommandResultFactory({\n error: new InvalidStatusWordError(\"mocked error\"),\n }),\n );\n\n const openAppDeviceAction = new OpenAppDeviceAction({\n input: { appName: \"Bitcoin\" },\n });\n vi.spyOn(openAppDeviceAction, \"extractDependencies\").mockReturnValue(\n extractDependenciesMock(),\n );\n\n const expectedStates: Array<OpenAppDAState> = [\n {\n status: DeviceActionStatus.Pending, // get onboarded status\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.None,\n },\n },\n {\n status: DeviceActionStatus.Pending, // get device status\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.None,\n },\n },\n {\n status: DeviceActionStatus.Pending, // open app\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.ConfirmOpenApp,\n },\n },\n {\n status: DeviceActionStatus.Error,\n error: new InvalidStatusWordError(\"mocked error\"),\n },\n ];\n\n testDeviceActionStates(\n openAppDeviceAction,\n expectedStates,\n makeDeviceActionInternalApiMock(),\n {\n onDone: resolve,\n onError: reject,\n },\n );\n }));\n\n it(\"should end in an error if another app is open, and close app returns an error\", () =>\n new Promise<void>((resolve, reject) => {\n getDeviceSessionStateMock.mockReturnValue({\n sessionStateType: DeviceSessionStateType.ReadyWithoutSecureChannel,\n deviceStatus: DeviceStatus.CONNECTED,\n currentApp: { name: \"AnotherApp\", version: \"0.0.0\" },\n });\n setupGetDeviceStatusMock([\n {\n currentApp: \"AnotherApp\",\n currentAppVersion: \"0.0.0\",\n },\n ]);\n closeAppMock.mockResolvedValue(\n CommandResultFactory({\n error: new InvalidStatusWordError(\"mocked error\"),\n }),\n );\n\n const openAppDeviceAction = new OpenAppDeviceAction({\n input: { appName: \"Bitcoin\" },\n });\n vi.spyOn(openAppDeviceAction, \"extractDependencies\").mockReturnValue(\n extractDependenciesMock(),\n );\n\n const expectedStates: Array<OpenAppDAState> = [\n {\n status: DeviceActionStatus.Pending, // get onboarded status\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.None,\n },\n },\n {\n status: DeviceActionStatus.Pending, // get device status\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.None,\n },\n },\n {\n status: DeviceActionStatus.Pending, // close app\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.None,\n },\n },\n {\n status: DeviceActionStatus.Error,\n error: new InvalidStatusWordError(\"mocked error\"),\n },\n ];\n\n testDeviceActionStates(\n openAppDeviceAction,\n expectedStates,\n makeDeviceActionInternalApiMock(),\n {\n onDone: resolve,\n onError: reject,\n },\n );\n }));\n\n it(\"should end in an error if another app is open, close app succeeds but open app returns an error\", () =>\n new Promise<void>((resolve, reject) => {\n getDeviceSessionStateMock.mockReturnValue({\n sessionStateType: DeviceSessionStateType.ReadyWithoutSecureChannel,\n deviceStatus: DeviceStatus.CONNECTED,\n currentApp: { name: \"AnotherApp\", version: \"0.0.0\" },\n });\n setupGetDeviceStatusMock([\n {\n currentApp: \"AnotherApp\",\n currentAppVersion: \"0.0.0\",\n },\n ]);\n closeAppMock.mockResolvedValue(\n CommandResultFactory({ data: undefined }),\n );\n openAppMock.mockResolvedValue(\n CommandResultFactory({\n error: new InvalidStatusWordError(\"mocked error\"),\n }),\n );\n\n const openAppDeviceAction = new OpenAppDeviceAction({\n input: { appName: \"Bitcoin\" },\n });\n vi.spyOn(openAppDeviceAction, \"extractDependencies\").mockReturnValue(\n extractDependenciesMock(),\n );\n\n const expectedStates: Array<OpenAppDAState> = [\n {\n status: DeviceActionStatus.Pending, // get onboarded status\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.None,\n },\n },\n {\n status: DeviceActionStatus.Pending, // get device status\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.None,\n },\n },\n {\n status: DeviceActionStatus.Pending, // close app\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.None,\n },\n },\n {\n status: DeviceActionStatus.Pending, // open app\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.ConfirmOpenApp,\n },\n },\n {\n status: DeviceActionStatus.Error,\n error: new InvalidStatusWordError(\"mocked error\"),\n },\n ];\n\n testDeviceActionStates(\n openAppDeviceAction,\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.CONNECTED,\n currentApp: { name: \"mockedCurrentApp\", version: \"1.0.0\" },\n });\n\n setupGetDeviceStatusMock([new UnknownDAError(\"Unknown error\")]);\n\n const openAppDeviceAction = new OpenAppDeviceAction({\n input: { appName: \"Bitcoin\" },\n });\n\n vi.spyOn(openAppDeviceAction, \"extractDependencies\").mockReturnValue(\n extractDependenciesMock(),\n );\n\n const expectedStates: Array<OpenAppDAState> = [\n {\n status: DeviceActionStatus.Pending, // get onboarded status\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.None,\n },\n },\n {\n status: DeviceActionStatus.Pending, // get device status\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.None,\n },\n },\n {\n status: DeviceActionStatus.Error,\n error: new UnknownDAError(\"Unknown error\"),\n },\n ];\n\n testDeviceActionStates(\n openAppDeviceAction,\n expectedStates,\n makeDeviceActionInternalApiMock(),\n {\n onDone: resolve,\n onError: reject,\n },\n );\n }));\n\n it(\"should end in an error if openApp actor throws an error\", () =>\n new Promise<void>((resolve, reject) => {\n getDeviceSessionStateMock.mockReturnValue(\n CommandResultFactory({\n data: {\n sessionStateType:\n DeviceSessionStateType.ReadyWithoutSecureChannel,\n deviceStatus: DeviceStatus.CONNECTED,\n currentApp: { name: \"BOLOS\", version: \"0.0.0\" },\n },\n }),\n );\n setupGetDeviceStatusMock([\n {\n currentApp: \"BOLOS\",\n currentAppVersion: \"0.0.0\",\n },\n ]);\n openAppMock.mockImplementation(() => {\n throw new UnknownDAError(\"Unknown error\");\n });\n\n const openAppDeviceAction = new OpenAppDeviceAction({\n input: { appName: \"Bitcoin\" },\n });\n vi.spyOn(openAppDeviceAction, \"extractDependencies\").mockReturnValue(\n extractDependenciesMock(),\n );\n\n const expectedStates: Array<OpenAppDAState> = [\n {\n status: DeviceActionStatus.Pending, // get device onboarded\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.None,\n },\n },\n {\n status: DeviceActionStatus.Pending, // get device status\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.None,\n },\n },\n {\n status: DeviceActionStatus.Pending, // open app\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.ConfirmOpenApp,\n },\n },\n {\n status: DeviceActionStatus.Error,\n error: new UnknownDAError(\"Unknown error\"),\n },\n ];\n\n testDeviceActionStates(\n openAppDeviceAction,\n expectedStates,\n makeDeviceActionInternalApiMock(),\n {\n onDone: resolve,\n onError: reject,\n },\n );\n }));\n\n it(\"should end in an error if closeApp actor throws an error\", () =>\n new Promise<void>((resolve, reject) => {\n getDeviceSessionStateMock.mockReturnValue(\n CommandResultFactory({\n data: {\n sessionStateType:\n DeviceSessionStateType.ReadyWithoutSecureChannel,\n deviceStatus: DeviceStatus.CONNECTED,\n currentApp: { name: \"BOLOS\", version: \"0.0.0\" },\n },\n }),\n );\n setupGetDeviceStatusMock([\n {\n currentApp: \"anApp\",\n currentAppVersion: \"0.0.0\",\n },\n ]);\n closeAppMock.mockImplementation(() => {\n throw new UnknownDAError(\"Unknown error\");\n });\n\n const openAppDeviceAction = new OpenAppDeviceAction({\n input: { appName: \"Bitcoin\" },\n });\n vi.spyOn(openAppDeviceAction, \"extractDependencies\").mockReturnValue(\n extractDependenciesMock(),\n );\n\n const expectedStates: Array<OpenAppDAState> = [\n {\n status: DeviceActionStatus.Pending, // get onboarded status\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.None,\n },\n },\n {\n status: DeviceActionStatus.Pending, // get device status\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.None,\n },\n },\n {\n status: DeviceActionStatus.Pending, // close app\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.None,\n },\n },\n {\n status: DeviceActionStatus.Error,\n error: new UnknownDAError(\"Unknown error\"),\n },\n ];\n\n testDeviceActionStates(\n openAppDeviceAction,\n expectedStates,\n makeDeviceActionInternalApiMock(),\n {\n onDone: resolve,\n onError: reject,\n },\n );\n }));\n\n it(\"should emit a stopped state if the action is cancelled\", () =>\n new Promise<void>((resolve, reject) => {\n getDeviceSessionStateMock.mockReturnValue({\n sessionStateType: DeviceSessionStateType.ReadyWithoutSecureChannel,\n deviceStatus: DeviceStatus.CONNECTED,\n currentApp: { name: \"AnotherApp\", version: \"0.0.0\" },\n });\n setupGetDeviceStatusMock([\n {\n currentApp: \"AnotherApp\",\n currentAppVersion: \"0.0.0\",\n },\n ]);\n\n const openAppDeviceAction = new OpenAppDeviceAction({\n input: { appName: \"Bitcoin\" },\n });\n vi.spyOn(openAppDeviceAction, \"extractDependencies\").mockReturnValue(\n extractDependenciesMock(),\n );\n\n const expectedStates: Array<OpenAppDAState> = [\n {\n status: DeviceActionStatus.Pending, // get device onboarded\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.None,\n },\n },\n {\n status: DeviceActionStatus.Pending, // get device status\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.None,\n },\n },\n {\n status: DeviceActionStatus.Stopped,\n },\n ];\n\n const { cancel } = testDeviceActionStates(\n openAppDeviceAction,\n expectedStates,\n makeDeviceActionInternalApiMock(),\n {\n onDone: resolve,\n onError: reject,\n },\n );\n cancel();\n }));\n });\n});\n"],
|
5
|
-
"mappings": "AAAA,OAAS,iBAAAA,MAAqB,OAE9B,OAAS,0BAAAC,MAA8B,sBACvC,OAAS,wBAAAC,MAA4B,mCACrC,OAAS,iBAAAC,MAAqB,0BAC9B,OAAS,gBAAAC,MAAoB,2BAC7B,OAAS,mCAAAC,MAAuC,oDAChD,OAAS,4BAAAC,MAAgC,qDACzC,OAAS,0BAAAC,MAA8B,2DACvC,OAAS,sBAAAC,MAA0B,6CACnC,OAAS,2BAAAC,MAA+B,mDACxC,OACE,qBAAAC,EACA,2BAAAC,EACA,kBAAAC,MACK,+BACP,OAAS,0BAAAC,MAA8B,yCAEvC,OAAS,uBAAAC,MAA2B,wBAGpC,GAAG,KAAK,mEAAmE,EAE3E,SAAS,sBAAuB,IAAM,CACpC,MAAMC,EAAuB,GAAG,GAAG,EAC7BC,EAAc,GAAG,GAAG,EACpBC,EAAe,GAAG,GAAG,EACrBC,EAA4B,GAAG,GAAG,EAClCC,EAA4B,GAAG,GAAG,EAClCC,EAAwB,GAAG,GAAG,EAEpC,SAASC,GAA0B,CACjC,MAAO,CACL,sBAAuBH,EACvB,sBAAuBC,EACvB,iBAAkBJ,EAClB,QAASC,EACT,SAAUC,EACV,kBAAmBG,CACrB,CACF,CAEA,KAAM,CAAE,sBAAuBE,CAA6B,EAC1DjB,EAAgC,EAElC,WAAW,IAAM,CACf,GAAG,cAAc,EACjBe,EAAsB,gBAAgB,EAAI,CAC5C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QD,EAAmB,OAC7B,CACF,EAEM,CAAE,OAAAoB,CAAO,EAAIrB,EACjBkB,EACAC,EACArB,EAAgC,EAChC,CACE,OAAQkB,EACR,QAASC,CACX,CACF,EACAI,EAAO,CACT,CAAC,CAAC,CACN,CAAC,CACH,CAAC",
|
4
|
+
"sourcesContent": ["import { lastValueFrom } from \"rxjs\";\n\nimport { InvalidStatusWordError } from \"@api/command/Errors\";\nimport { CommandResultFactory } from \"@api/command/model/CommandResult\";\nimport { DeviceModelId } from \"@api/device/DeviceModel\";\nimport { DeviceStatus } from \"@api/device/DeviceStatus\";\nimport { makeDeviceActionInternalApiMock } from \"@api/device-action/__test-utils__/makeInternalApi\";\nimport { setupGetDeviceStatusMock } from \"@api/device-action/__test-utils__/setupTestMachine\";\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 { OpenAppDeviceAction } from \"./OpenAppDeviceAction\";\nimport type { OpenAppDAState } from \"./types\";\n\nvi.mock(\"@api/device-action/os/GetDeviceStatus/GetDeviceStatusDeviceAction\");\n\ndescribe(\"OpenAppDeviceAction\", () => {\n const getAppAndVersionMock = vi.fn();\n const openAppMock = vi.fn();\n const closeAppMock = vi.fn();\n const getDeviceSessionStateMock = vi.fn();\n const setDeviceSessionStateMock = vi.fn();\n const isDeviceOnboardedMock = vi.fn();\n\n function extractDependenciesMock() {\n return {\n getDeviceSessionState: getDeviceSessionStateMock,\n setDeviceSessionState: setDeviceSessionStateMock,\n getAppAndVersion: getAppAndVersionMock,\n openApp: openAppMock,\n closeApp: closeAppMock,\n isDeviceOnboarded: isDeviceOnboardedMock,\n };\n }\n\n const { getDeviceSessionState: apiGetDeviceSessionStateMock } =\n makeDeviceActionInternalApiMock();\n\n beforeEach(() => {\n vi.resetAllMocks();\n isDeviceOnboardedMock.mockReturnValue(true);\n });\n\n describe(\"without overriding `extractDependencies`\", () => {\n it(\"should end if the required application is opened\", () =>\n new Promise<void>((resolve, reject) => {\n apiGetDeviceSessionStateMock.mockReturnValue({\n sessionStateType: DeviceSessionStateType.ReadyWithoutSecureChannel,\n deviceStatus: DeviceStatus.CONNECTED,\n currentApp: { name: \"Bitcoin\", version: \"1.0.0\" },\n installedApps: [],\n deviceModelId: DeviceModelId.NANO_X,\n isSecureConnectionAllowed: false,\n });\n setupGetDeviceStatusMock([\n {\n currentApp: \"Bitcoin\",\n currentAppVersion: \"0.0.0\",\n },\n ]);\n\n const openAppDeviceAction = new OpenAppDeviceAction({\n input: { appName: \"Bitcoin\" },\n });\n\n const expectedStates: Array<OpenAppDAState> = [\n {\n status: DeviceActionStatus.Pending, // get onboarding status\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.None,\n },\n },\n {\n status: DeviceActionStatus.Pending, // get device status\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.None,\n },\n },\n {\n status: DeviceActionStatus.Completed,\n output: undefined,\n },\n ];\n\n testDeviceActionStates(\n openAppDeviceAction,\n expectedStates,\n makeDeviceActionInternalApiMock(),\n {\n onDone: resolve,\n onError: reject,\n },\n );\n }));\n });\n\n describe(\"success cases\", () => {\n it(\"should end in a success if the app is already opened\", () =>\n new Promise<void>((resolve, reject) => {\n getDeviceSessionStateMock.mockReturnValue({\n sessionStateType: DeviceSessionStateType.ReadyWithoutSecureChannel,\n deviceStatus: DeviceStatus.CONNECTED,\n currentApp: { name: \"Bitcoin\", version: \"1.0.0\" },\n });\n\n setupGetDeviceStatusMock([\n {\n currentApp: \"Bitcoin\",\n currentAppVersion: \"1.0.0\",\n },\n ]);\n const openAppDeviceAction = new OpenAppDeviceAction({\n input: { appName: \"Bitcoin\", unlockTimeout: undefined },\n });\n vi.spyOn(openAppDeviceAction, \"extractDependencies\").mockReturnValue(\n extractDependenciesMock(),\n );\n\n const expectedStates: Array<OpenAppDAState> = [\n {\n status: DeviceActionStatus.Pending, // get onboarding status\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.None,\n },\n },\n {\n status: DeviceActionStatus.Pending, // get app and version\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.None,\n },\n },\n {\n status: DeviceActionStatus.Completed,\n output: undefined,\n },\n ];\n\n testDeviceActionStates(\n openAppDeviceAction,\n expectedStates,\n makeDeviceActionInternalApiMock(),\n {\n onDone: resolve,\n onError: reject,\n },\n );\n }));\n\n it(\"should end in a success if a compatible app is already opened\", () =>\n new Promise<void>((resolve, reject) => {\n getDeviceSessionStateMock.mockReturnValue({\n sessionStateType: DeviceSessionStateType.ReadyWithoutSecureChannel,\n deviceStatus: DeviceStatus.CONNECTED,\n currentApp: {\n name: \"Bitcoin Testnet\",\n version: \"1.0.0\",\n },\n });\n\n setupGetDeviceStatusMock([\n {\n currentApp: \"Bitcoin Testnet\",\n currentAppVersion: \"1.0.0\",\n },\n ]);\n const openAppDeviceAction = new OpenAppDeviceAction({\n input: {\n appName: \"Bitcoin\",\n unlockTimeout: undefined,\n compatibleAppNames: [\"Bitcoin Testnet\"],\n },\n });\n vi.spyOn(openAppDeviceAction, \"extractDependencies\").mockReturnValue(\n extractDependenciesMock(),\n );\n\n const expectedStates: Array<OpenAppDAState> = [\n {\n status: DeviceActionStatus.Pending, // get onboarding status\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.None,\n },\n },\n {\n status: DeviceActionStatus.Pending, // get app and version\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.None,\n },\n },\n {\n status: DeviceActionStatus.Completed,\n output: undefined,\n },\n ];\n\n testDeviceActionStates(\n openAppDeviceAction,\n expectedStates,\n makeDeviceActionInternalApiMock(),\n {\n onDone: resolve,\n onError: reject,\n },\n );\n }));\n\n it(\"should end in a success if the dashboard is open and open app succeeds\", () =>\n new Promise<void>((resolve, reject) => {\n getDeviceSessionStateMock.mockReturnValue({\n sessionStateType: DeviceSessionStateType.ReadyWithoutSecureChannel,\n deviceStatus: DeviceStatus.CONNECTED,\n currentApp: { name: \"BOLOS\", version: \"0.0.0\" },\n });\n\n setupGetDeviceStatusMock([\n {\n currentApp: \"Bitcoin\",\n currentAppVersion: \"1.0.0\",\n },\n ]);\n\n openAppMock.mockResolvedValue(\n CommandResultFactory({ data: undefined }),\n );\n\n const openAppDeviceAction = new OpenAppDeviceAction({\n input: { appName: \"Bitcoin\" },\n });\n vi.spyOn(openAppDeviceAction, \"extractDependencies\").mockReturnValue(\n extractDependenciesMock(),\n );\n\n const expectedStates: Array<OpenAppDAState> = [\n {\n status: DeviceActionStatus.Pending, // get app and version\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.None,\n },\n },\n {\n status: DeviceActionStatus.Pending, // get app and version\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.None,\n },\n },\n {\n status: DeviceActionStatus.Completed,\n output: undefined,\n },\n ];\n\n const { observable } = testDeviceActionStates(\n openAppDeviceAction,\n expectedStates,\n makeDeviceActionInternalApiMock(),\n {\n onDone: resolve,\n onError: reject,\n },\n );\n\n lastValueFrom(observable).then(() => {\n expect(setDeviceSessionStateMock).toHaveBeenCalledWith({\n deviceStatus: DeviceStatus.CONNECTED,\n sessionStateType: DeviceSessionStateType.ReadyWithoutSecureChannel,\n currentApp: { name: \"Bitcoin\", version: \"1.0.0\" },\n });\n });\n }));\n\n it(\"should end in a success if another app is open, close app succeeds and open app succeeds\", () =>\n new Promise<void>((resolve, reject) => {\n getDeviceSessionStateMock.mockReturnValue({\n sessionStateType: DeviceSessionStateType.ReadyWithoutSecureChannel,\n deviceStatus: DeviceStatus.CONNECTED,\n currentApp: { name: \"AnotherApp\", version: \"0.0.0\" },\n });\n setupGetDeviceStatusMock([\n {\n currentApp: \"AnotherApp\",\n currentAppVersion: \"0.0.0\",\n },\n { currentApp: \"Bitcoin\", currentAppVersion: \"1.0.0\" },\n ]);\n closeAppMock.mockResolvedValue(\n CommandResultFactory({ data: undefined }),\n );\n openAppMock.mockResolvedValue(\n CommandResultFactory({ data: undefined }),\n );\n\n const openAppDeviceAction = new OpenAppDeviceAction({\n input: { appName: \"Bitcoin\" },\n });\n vi.spyOn(openAppDeviceAction, \"extractDependencies\").mockReturnValue(\n extractDependenciesMock(),\n );\n\n const expectedStates: Array<OpenAppDAState> = [\n {\n status: DeviceActionStatus.Pending, // get app and version\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.None,\n },\n },\n {\n status: DeviceActionStatus.Pending, // close app\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.None,\n },\n },\n {\n status: DeviceActionStatus.Pending, // get device status\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.None,\n },\n },\n {\n status: DeviceActionStatus.Pending, // open app\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.ConfirmOpenApp,\n },\n },\n {\n status: DeviceActionStatus.Pending, // get app and version\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.None,\n },\n },\n {\n status: DeviceActionStatus.Pending, // get app and version\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.None,\n },\n },\n {\n status: DeviceActionStatus.Completed,\n output: undefined,\n },\n ];\n\n const { observable } = testDeviceActionStates(\n openAppDeviceAction,\n expectedStates,\n makeDeviceActionInternalApiMock(),\n {\n onDone: resolve,\n onError: reject,\n },\n );\n\n lastValueFrom(observable).then(() => {\n expect(setDeviceSessionStateMock).toHaveBeenCalledWith({\n currentApp: { name: \"Bitcoin\", version: \"1.0.0\" },\n deviceStatus: DeviceStatus.CONNECTED,\n sessionStateType: DeviceSessionStateType.ReadyWithoutSecureChannel,\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.CONNECTED,\n currentApp: { name: \"mockedCurrentApp\", version: \"1.0.0\" },\n });\n isDeviceOnboardedMock.mockReturnValue(false);\n\n const openAppDeviceAction = new OpenAppDeviceAction({\n input: { appName: \"Bitcoin\" },\n });\n\n vi.spyOn(openAppDeviceAction, \"extractDependencies\").mockReturnValue(\n extractDependenciesMock(),\n );\n\n const expectedStates: Array<OpenAppDAState> = [\n {\n error: new DeviceNotOnboardedError(),\n status: DeviceActionStatus.Error,\n },\n ];\n\n testDeviceActionStates(\n openAppDeviceAction,\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\", () =>\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 setupGetDeviceStatusMock([new DeviceLockedError()]);\n\n const openAppDeviceAction = new OpenAppDeviceAction({\n input: { appName: \"Bitcoin\" },\n });\n\n vi.spyOn(openAppDeviceAction, \"extractDependencies\").mockReturnValue(\n extractDependenciesMock(),\n );\n\n const expectedStates: Array<OpenAppDAState> = [\n {\n status: DeviceActionStatus.Pending,\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.None,\n },\n },\n {\n status: DeviceActionStatus.Pending,\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.None,\n },\n },\n {\n status: DeviceActionStatus.Error,\n error: new DeviceLockedError(),\n },\n ];\n\n testDeviceActionStates(\n openAppDeviceAction,\n expectedStates,\n makeDeviceActionInternalApiMock(),\n {\n onDone: resolve,\n onError: reject,\n },\n );\n }));\n\n it(\"should end in an error if getAppAndVersion returns an error\", () =>\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 setupGetDeviceStatusMock([new InvalidStatusWordError(\"mocked error\")]);\n\n const openAppDeviceAction = new OpenAppDeviceAction({\n input: { appName: \"Bitcoin\" },\n });\n\n vi.spyOn(openAppDeviceAction, \"extractDependencies\").mockReturnValue(\n extractDependenciesMock(),\n );\n\n const expectedStates: Array<OpenAppDAState> = [\n {\n status: DeviceActionStatus.Pending, // get app and version\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.None,\n },\n },\n {\n status: DeviceActionStatus.Pending, // get device status\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.None,\n },\n },\n {\n status: DeviceActionStatus.Error,\n error: new InvalidStatusWordError(\"mocked error\"),\n },\n ];\n\n testDeviceActionStates(\n openAppDeviceAction,\n expectedStates,\n makeDeviceActionInternalApiMock(),\n {\n onDone: resolve,\n onError: reject,\n },\n );\n }));\n\n it(\"should end in an error if the dashboard is open and open app returns an error\", () =>\n new Promise<void>((resolve, reject) => {\n getDeviceSessionStateMock.mockReturnValue(\n CommandResultFactory({\n data: {\n sessionStateType:\n DeviceSessionStateType.ReadyWithoutSecureChannel,\n deviceStatus: DeviceStatus.CONNECTED,\n currentApp: { name: \"BOLOS\", version: \"0.0.0\" },\n },\n }),\n );\n getAppAndVersionMock.mockResolvedValue(\n CommandResultFactory({\n data: {\n name: \"BOLOS\",\n version: \"0.0.0\",\n },\n }),\n );\n setupGetDeviceStatusMock([\n {\n currentApp: \"BOLOS\",\n currentAppVersion: \"0.0.0\",\n },\n ]);\n openAppMock.mockResolvedValue(\n CommandResultFactory({\n error: new InvalidStatusWordError(\"mocked error\"),\n }),\n );\n\n const openAppDeviceAction = new OpenAppDeviceAction({\n input: { appName: \"Bitcoin\" },\n });\n vi.spyOn(openAppDeviceAction, \"extractDependencies\").mockReturnValue(\n extractDependenciesMock(),\n );\n\n const expectedStates: Array<OpenAppDAState> = [\n {\n status: DeviceActionStatus.Pending, // get onboarded status\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.None,\n },\n },\n {\n status: DeviceActionStatus.Pending, // get device status\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.None,\n },\n },\n {\n status: DeviceActionStatus.Pending, // open app\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.ConfirmOpenApp,\n },\n },\n {\n status: DeviceActionStatus.Error,\n error: new InvalidStatusWordError(\"mocked error\"),\n },\n ];\n\n testDeviceActionStates(\n openAppDeviceAction,\n expectedStates,\n makeDeviceActionInternalApiMock(),\n {\n onDone: resolve,\n onError: reject,\n },\n );\n }));\n\n it(\"should end in an error if another app is open, and close app returns an error\", () =>\n new Promise<void>((resolve, reject) => {\n getDeviceSessionStateMock.mockReturnValue({\n sessionStateType: DeviceSessionStateType.ReadyWithoutSecureChannel,\n deviceStatus: DeviceStatus.CONNECTED,\n currentApp: { name: \"AnotherApp\", version: \"0.0.0\" },\n });\n setupGetDeviceStatusMock([\n {\n currentApp: \"AnotherApp\",\n currentAppVersion: \"0.0.0\",\n },\n ]);\n closeAppMock.mockResolvedValue(\n CommandResultFactory({\n error: new InvalidStatusWordError(\"mocked error\"),\n }),\n );\n\n const openAppDeviceAction = new OpenAppDeviceAction({\n input: { appName: \"Bitcoin\" },\n });\n vi.spyOn(openAppDeviceAction, \"extractDependencies\").mockReturnValue(\n extractDependenciesMock(),\n );\n\n const expectedStates: Array<OpenAppDAState> = [\n {\n status: DeviceActionStatus.Pending, // get onboarded status\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.None,\n },\n },\n {\n status: DeviceActionStatus.Pending, // get device status\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.None,\n },\n },\n {\n status: DeviceActionStatus.Pending, // close app\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.None,\n },\n },\n {\n status: DeviceActionStatus.Error,\n error: new InvalidStatusWordError(\"mocked error\"),\n },\n ];\n\n testDeviceActionStates(\n openAppDeviceAction,\n expectedStates,\n makeDeviceActionInternalApiMock(),\n {\n onDone: resolve,\n onError: reject,\n },\n );\n }));\n\n it(\"should end in an error if another app is open, close app succeeds but open app returns an error\", () =>\n new Promise<void>((resolve, reject) => {\n getDeviceSessionStateMock.mockReturnValue({\n sessionStateType: DeviceSessionStateType.ReadyWithoutSecureChannel,\n deviceStatus: DeviceStatus.CONNECTED,\n currentApp: { name: \"AnotherApp\", version: \"0.0.0\" },\n });\n setupGetDeviceStatusMock([\n {\n currentApp: \"AnotherApp\",\n currentAppVersion: \"0.0.0\",\n },\n ]);\n closeAppMock.mockResolvedValue(\n CommandResultFactory({ data: undefined }),\n );\n openAppMock.mockResolvedValue(\n CommandResultFactory({\n error: new InvalidStatusWordError(\"mocked error\"),\n }),\n );\n\n const openAppDeviceAction = new OpenAppDeviceAction({\n input: { appName: \"Bitcoin\" },\n });\n vi.spyOn(openAppDeviceAction, \"extractDependencies\").mockReturnValue(\n extractDependenciesMock(),\n );\n\n const expectedStates: Array<OpenAppDAState> = [\n {\n status: DeviceActionStatus.Pending, // get onboarded status\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.None,\n },\n },\n {\n status: DeviceActionStatus.Pending, // get device status\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.None,\n },\n },\n {\n status: DeviceActionStatus.Pending, // close app\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.None,\n },\n },\n {\n status: DeviceActionStatus.Pending, // open app\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.ConfirmOpenApp,\n },\n },\n {\n status: DeviceActionStatus.Error,\n error: new InvalidStatusWordError(\"mocked error\"),\n },\n ];\n\n testDeviceActionStates(\n openAppDeviceAction,\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.CONNECTED,\n currentApp: { name: \"mockedCurrentApp\", version: \"1.0.0\" },\n });\n\n setupGetDeviceStatusMock([new UnknownDAError(\"Unknown error\")]);\n\n const openAppDeviceAction = new OpenAppDeviceAction({\n input: { appName: \"Bitcoin\" },\n });\n\n vi.spyOn(openAppDeviceAction, \"extractDependencies\").mockReturnValue(\n extractDependenciesMock(),\n );\n\n const expectedStates: Array<OpenAppDAState> = [\n {\n status: DeviceActionStatus.Pending, // get onboarded status\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.None,\n },\n },\n {\n status: DeviceActionStatus.Pending, // get device status\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.None,\n },\n },\n {\n status: DeviceActionStatus.Error,\n error: new UnknownDAError(\"Unknown error\"),\n },\n ];\n\n testDeviceActionStates(\n openAppDeviceAction,\n expectedStates,\n makeDeviceActionInternalApiMock(),\n {\n onDone: resolve,\n onError: reject,\n },\n );\n }));\n\n it(\"should end in an error if openApp actor throws an error\", () =>\n new Promise<void>((resolve, reject) => {\n getDeviceSessionStateMock.mockReturnValue(\n CommandResultFactory({\n data: {\n sessionStateType:\n DeviceSessionStateType.ReadyWithoutSecureChannel,\n deviceStatus: DeviceStatus.CONNECTED,\n currentApp: { name: \"BOLOS\", version: \"0.0.0\" },\n },\n }),\n );\n setupGetDeviceStatusMock([\n {\n currentApp: \"BOLOS\",\n currentAppVersion: \"0.0.0\",\n },\n ]);\n openAppMock.mockImplementation(() => {\n throw new UnknownDAError(\"Unknown error\");\n });\n\n const openAppDeviceAction = new OpenAppDeviceAction({\n input: { appName: \"Bitcoin\" },\n });\n vi.spyOn(openAppDeviceAction, \"extractDependencies\").mockReturnValue(\n extractDependenciesMock(),\n );\n\n const expectedStates: Array<OpenAppDAState> = [\n {\n status: DeviceActionStatus.Pending, // get device onboarded\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.None,\n },\n },\n {\n status: DeviceActionStatus.Pending, // get device status\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.None,\n },\n },\n {\n status: DeviceActionStatus.Pending, // open app\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.ConfirmOpenApp,\n },\n },\n {\n status: DeviceActionStatus.Error,\n error: new UnknownDAError(\"Unknown error\"),\n },\n ];\n\n testDeviceActionStates(\n openAppDeviceAction,\n expectedStates,\n makeDeviceActionInternalApiMock(),\n {\n onDone: resolve,\n onError: reject,\n },\n );\n }));\n\n it(\"should end in an error if closeApp actor throws an error\", () =>\n new Promise<void>((resolve, reject) => {\n getDeviceSessionStateMock.mockReturnValue(\n CommandResultFactory({\n data: {\n sessionStateType:\n DeviceSessionStateType.ReadyWithoutSecureChannel,\n deviceStatus: DeviceStatus.CONNECTED,\n currentApp: { name: \"BOLOS\", version: \"0.0.0\" },\n },\n }),\n );\n setupGetDeviceStatusMock([\n {\n currentApp: \"anApp\",\n currentAppVersion: \"0.0.0\",\n },\n ]);\n closeAppMock.mockImplementation(() => {\n throw new UnknownDAError(\"Unknown error\");\n });\n\n const openAppDeviceAction = new OpenAppDeviceAction({\n input: { appName: \"Bitcoin\" },\n });\n vi.spyOn(openAppDeviceAction, \"extractDependencies\").mockReturnValue(\n extractDependenciesMock(),\n );\n\n const expectedStates: Array<OpenAppDAState> = [\n {\n status: DeviceActionStatus.Pending, // get onboarded status\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.None,\n },\n },\n {\n status: DeviceActionStatus.Pending, // get device status\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.None,\n },\n },\n {\n status: DeviceActionStatus.Pending, // close app\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.None,\n },\n },\n {\n status: DeviceActionStatus.Error,\n error: new UnknownDAError(\"Unknown error\"),\n },\n ];\n\n testDeviceActionStates(\n openAppDeviceAction,\n expectedStates,\n makeDeviceActionInternalApiMock(),\n {\n onDone: resolve,\n onError: reject,\n },\n );\n }));\n\n it(\"should emit a stopped state if the action is cancelled\", () =>\n new Promise<void>((resolve, reject) => {\n getDeviceSessionStateMock.mockReturnValue({\n sessionStateType: DeviceSessionStateType.ReadyWithoutSecureChannel,\n deviceStatus: DeviceStatus.CONNECTED,\n currentApp: { name: \"AnotherApp\", version: \"0.0.0\" },\n });\n setupGetDeviceStatusMock([\n {\n currentApp: \"AnotherApp\",\n currentAppVersion: \"0.0.0\",\n },\n ]);\n\n const openAppDeviceAction = new OpenAppDeviceAction({\n input: { appName: \"Bitcoin\" },\n });\n vi.spyOn(openAppDeviceAction, \"extractDependencies\").mockReturnValue(\n extractDependenciesMock(),\n );\n\n const expectedStates: Array<OpenAppDAState> = [\n {\n status: DeviceActionStatus.Pending, // get device onboarded\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.None,\n },\n },\n {\n status: DeviceActionStatus.Pending, // get device status\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.None,\n },\n },\n {\n status: DeviceActionStatus.Stopped,\n },\n ];\n\n const { cancel } = testDeviceActionStates(\n openAppDeviceAction,\n expectedStates,\n makeDeviceActionInternalApiMock(),\n {\n onDone: resolve,\n onError: reject,\n },\n );\n cancel();\n }));\n });\n});\n"],
|
5
|
+
"mappings": "AAAA,OAAS,iBAAAA,MAAqB,OAE9B,OAAS,0BAAAC,MAA8B,sBACvC,OAAS,wBAAAC,MAA4B,mCACrC,OAAS,iBAAAC,MAAqB,0BAC9B,OAAS,gBAAAC,MAAoB,2BAC7B,OAAS,mCAAAC,MAAuC,oDAChD,OAAS,4BAAAC,MAAgC,qDACzC,OAAS,0BAAAC,MAA8B,2DACvC,OAAS,sBAAAC,MAA0B,6CACnC,OAAS,2BAAAC,MAA+B,mDACxC,OACE,qBAAAC,EACA,2BAAAC,EACA,kBAAAC,MACK,+BACP,OAAS,0BAAAC,MAA8B,yCAEvC,OAAS,uBAAAC,MAA2B,wBAGpC,GAAG,KAAK,mEAAmE,EAE3E,SAAS,sBAAuB,IAAM,CAC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E,KAAM,aAAc,QAAS,OAAQ,CACrD,CAAC,EACDE,EAAyB,CACvB,CACE,WAAY,aACZ,kBAAmB,OACrB,CACF,CAAC,EAED,MAAMmB,EAAsB,IAAIX,EAAoB,CAClD,MAAO,CAAE,QAAS,SAAU,CAC9B,CAAC,EACD,GAAG,MAAMW,EAAqB,qBAAqB,EAAE,gBACnDJ,EAAwB,CAC1B,EAEA,MAAMK,EAAwC,CAC5C,CACE,OAAQlB,EAAmB,QAC3B,kBAAmB,CACjB,wBAAyBC,EAAwB,IACnD,CACF,EACA,CACE,OAAQD,EAAmB,QAC3B,kBAAmB,CACjB,wBAAyBC,EAAwB,IACnD,CACF,EACA,CACE,OAAQD,EAAmB,OAC7B,CACF,EAEM,CAAE,OAAAoB,CAAO,EAAIrB,EACjBkB,EACAC,EACArB,EAAgC,EAChC,CACE,OAAQkB,EACR,QAASC,CACX,CACF,EACAI,EAAO,CACT,CAAC,CAAC,CACN,CAAC,CACH,CAAC",
|
6
6
|
"names": ["lastValueFrom", "InvalidStatusWordError", "CommandResultFactory", "DeviceModelId", "DeviceStatus", "makeDeviceActionInternalApiMock", "setupGetDeviceStatusMock", "testDeviceActionStates", "DeviceActionStatus", "UserInteractionRequired", "DeviceLockedError", "DeviceNotOnboardedError", "UnknownDAError", "DeviceSessionStateType", "OpenAppDeviceAction", "getAppAndVersionMock", "openAppMock", "closeAppMock", "getDeviceSessionStateMock", "setDeviceSessionStateMock", "isDeviceOnboardedMock", "extractDependenciesMock", "apiGetDeviceSessionStateMock", "resolve", "reject", "openAppDeviceAction", "expectedStates", "observable", "cancel"]
|
7
7
|
}
|
@@ -1,7 +1,7 @@
|
|
1
1
|
{
|
2
2
|
"version": 3,
|
3
3
|
"sources": ["../../../../../src/api/device-session/DeviceSessionState.ts"],
|
4
|
-
"sourcesContent": ["import { type GetAppAndVersionResponse } from \"@api/command/os/GetAppAndVersionCommand\";\nimport { type BatteryStatusFlags } from \"@api/command/os/GetBatteryStatusCommand\";\nimport { type DeviceModelId } from \"@api/device/DeviceModel\";\nimport { type DeviceStatus } from \"@api/device/DeviceStatus\";\nimport { type Application } from \"@internal/manager-api/model/Application\";\n\n/**\n * The battery status of a device.\n */\nexport type BatteryStatus = {\n readonly level: number;\n readonly voltage: number;\n readonly temperature: number;\n readonly current: number;\n readonly status: BatteryStatusFlags;\n};\n\n/**\n * The firmware version of a device.\n */\nexport type FirmwareVersion = {\n /**\n * Microcontroller Unit version\n */\n readonly mcu: string;\n\n /**\n * Bootloader version\n */\n readonly bootloader: string;\n\n /**\n * Operating System version\n */\n readonly os: string;\n};\n\n/**\n * The current application running on a device. Alias of GetAppAndVersionResponse.\n */\nexport type RunningApp = GetAppAndVersionResponse;\n\n/**\n * The state types of a device session.\n */\nexport enum DeviceSessionStateType {\n Connected,\n ReadyWithoutSecureChannel,\n ReadyWithSecureChannel,\n}\n\ntype DeviceSessionBaseState = {\n readonly sessionStateType: DeviceSessionStateType;\n\n /**\n * The status of the device.\n */\n readonly deviceStatus: DeviceStatus;\n\n /**\n * The model of the device.\n */\n readonly deviceModelId: DeviceModelId;\n\n /**\n * The name of the device.\n */\n readonly deviceName?: string;\n};\n\ntype DeviceSessionReadyState = {\n /**\n * The battery status of the device.\n * TODO: This should not be optional, but it is not in the current implementation.\n */\n readonly batteryStatus?: BatteryStatus;\n\n /**\n * The firmware version of the device.\n * TODO: This should not be optional, but it is not in the current implementation.\n */\n readonly firmwareVersion?: FirmwareVersion;\n\n /**\n * The current application running on the device.\n */\n readonly currentApp: RunningApp;\n\n /**\n * The current applications installed on the device.\n */\n readonly installedApps: Application[];\n};\n\n/**\n * The state of a connected device session.\n */\nexport type ConnectedState = DeviceSessionBaseState & {\n /**\n * The type of the device session state.\n */\n readonly sessionStateType: DeviceSessionStateType.Connected;\n};\n\n/**\n * The state of a device session when it is ready without a secure channel.\n */\nexport type ReadyWithoutSecureChannelState = DeviceSessionBaseState &\n DeviceSessionReadyState & {\n /**\n * The type of the device session state.\n */\n readonly sessionStateType: DeviceSessionStateType.ReadyWithoutSecureChannel;\n };\n\n/**\n * The state of a device session when it is ready with a secure channel.\n */\nexport type ReadyWithSecureChannelState = DeviceSessionBaseState &\n DeviceSessionReadyState & {\n /**\n * The type of the device session state.\n */\n readonly sessionStateType: DeviceSessionStateType.ReadyWithSecureChannel;\n };\n\n/**\n * The state of a device session.\n */\nexport type DeviceSessionState =\n | ConnectedState\n | ReadyWithoutSecureChannelState\n | ReadyWithSecureChannelState;\n"],
|
4
|
+
"sourcesContent": ["import { type GetAppAndVersionResponse } from \"@api/command/os/GetAppAndVersionCommand\";\nimport { type BatteryStatusFlags } from \"@api/command/os/GetBatteryStatusCommand\";\nimport { type DeviceModelId } from \"@api/device/DeviceModel\";\nimport { type DeviceStatus } from \"@api/device/DeviceStatus\";\nimport { type Application } from \"@internal/manager-api/model/Application\";\n\n/**\n * The battery status of a device.\n */\nexport type BatteryStatus = {\n readonly level: number;\n readonly voltage: number;\n readonly temperature: number;\n readonly current: number;\n readonly status: BatteryStatusFlags;\n};\n\n/**\n * The firmware version of a device.\n */\nexport type FirmwareVersion = {\n /**\n * Microcontroller Unit version\n */\n readonly mcu: string;\n\n /**\n * Bootloader version\n */\n readonly bootloader: string;\n\n /**\n * Operating System version\n */\n readonly os: string;\n};\n\n/**\n * The current application running on a device. Alias of GetAppAndVersionResponse.\n */\nexport type RunningApp = GetAppAndVersionResponse;\n\n/**\n * The state types of a device session.\n */\nexport enum DeviceSessionStateType {\n Connected,\n ReadyWithoutSecureChannel,\n ReadyWithSecureChannel,\n}\n\ntype DeviceSessionBaseState = {\n readonly sessionStateType: DeviceSessionStateType;\n\n /**\n * The status of the device.\n */\n readonly deviceStatus: DeviceStatus;\n\n /**\n * The model of the device.\n */\n readonly deviceModelId: DeviceModelId;\n\n /**\n * The name of the device.\n */\n readonly deviceName?: string;\n};\n\ntype DeviceSessionReadyState = {\n /**\n * The battery status of the device.\n * TODO: This should not be optional, but it is not in the current implementation.\n */\n readonly batteryStatus?: BatteryStatus;\n\n /**\n * The firmware version of the device.\n * TODO: This should not be optional, but it is not in the current implementation.\n */\n readonly firmwareVersion?: FirmwareVersion;\n\n /**\n * The current application running on the device.\n */\n readonly currentApp: RunningApp;\n\n /**\n * The current applications installed on the device.\n */\n readonly installedApps: Application[];\n\n /**\n * The device is allowed to establish a secure connection.\n */\n readonly isSecureConnectionAllowed: boolean;\n};\n\n/**\n * The state of a connected device session.\n */\nexport type ConnectedState = DeviceSessionBaseState & {\n /**\n * The type of the device session state.\n */\n readonly sessionStateType: DeviceSessionStateType.Connected;\n};\n\n/**\n * The state of a device session when it is ready without a secure channel.\n */\nexport type ReadyWithoutSecureChannelState = DeviceSessionBaseState &\n DeviceSessionReadyState & {\n /**\n * The type of the device session state.\n */\n readonly sessionStateType: DeviceSessionStateType.ReadyWithoutSecureChannel;\n };\n\n/**\n * The state of a device session when it is ready with a secure channel.\n */\nexport type ReadyWithSecureChannelState = DeviceSessionBaseState &\n DeviceSessionReadyState & {\n /**\n * The type of the device session state.\n */\n readonly sessionStateType: DeviceSessionStateType.ReadyWithSecureChannel;\n };\n\n/**\n * The state of a device session.\n */\nexport type DeviceSessionState =\n | ConnectedState\n | ReadyWithoutSecureChannelState\n | ReadyWithSecureChannelState;\n"],
|
5
5
|
"mappings": "AA6CO,IAAKA,OACVA,IAAA,yBACAA,IAAA,yDACAA,IAAA,mDAHUA,OAAA",
|
6
6
|
"names": ["DeviceSessionStateType"]
|
7
7
|
}
|
@@ -0,0 +1,2 @@
|
|
1
|
+
var p=Object.defineProperty;var l=Object.getOwnPropertyDescriptor;var v=(o,r,i,s)=>{for(var e=s>1?void 0:s?l(r,i):r,c=o.length-1,g;c>=0;c--)(g=o[c])&&(e=(s?g(r,i,e):g(e))||e);return s&&e&&p(r,i,e),e},n=(o,r)=>(i,s)=>r(i,s,o);import{inject as S,injectable as a}from"inversify";import{deviceSessionTypes as m}from"../../../internal/device-session/di/deviceSessionTypes";import{loggerTypes as d}from"../../../internal/logger-publisher/di/loggerTypes";let t=class{constructor(r,i){this._sessionService=r;this._logger=i("DisableDeviceSessionRefresherUseCase")}_logger;execute({sessionId:r,blockerId:i}){return this._sessionService.getDeviceSessionById(r).caseOf({Left:e=>{throw this._logger.error("Error getting device session",{data:{error:e}}),e},Right:e=>e.disableRefresher(i)})}};t=v([a(),n(0,S(m.DeviceSessionService)),n(1,S(d.LoggerPublisherServiceFactory))],t);export{t as DisableDeviceSessionRefresherUseCase};
|
2
|
+
//# sourceMappingURL=DisableDeviceSessionRefresher.js.map
|
@@ -0,0 +1,7 @@
|
|
1
|
+
{
|
2
|
+
"version": 3,
|
3
|
+
"sources": ["../../../../../../src/api/device-session/use-case/DisableDeviceSessionRefresher.ts"],
|
4
|
+
"sourcesContent": ["import { inject, injectable } from \"inversify\";\n\nimport { type DeviceSessionId } from \"@api/device-session/types\";\nimport { LoggerPublisherService } from \"@api/logger-publisher/service/LoggerPublisherService\";\nimport { deviceSessionTypes } from \"@internal/device-session/di/deviceSessionTypes\";\nimport { type DeviceSessionService } from \"@internal/device-session/service/DeviceSessionService\";\nimport { loggerTypes } from \"@internal/logger-publisher/di/loggerTypes\";\n\nexport type DisableDeviceSessionRefresherUseCaseArgs = {\n sessionId: DeviceSessionId;\n blockerId: string;\n};\n\n/**\n * Disable the device session refresher.\n */\n@injectable()\nexport class DisableDeviceSessionRefresherUseCase {\n private readonly _logger: LoggerPublisherService;\n constructor(\n @inject(deviceSessionTypes.DeviceSessionService)\n private readonly _sessionService: DeviceSessionService,\n @inject(loggerTypes.LoggerPublisherServiceFactory)\n loggerFactory: (tag: string) => LoggerPublisherService,\n ) {\n this._logger = loggerFactory(\"DisableDeviceSessionRefresherUseCase\");\n }\n\n execute({ sessionId, blockerId }: DisableDeviceSessionRefresherUseCaseArgs) {\n const errorOrDeviceSession =\n this._sessionService.getDeviceSessionById(sessionId);\n\n return errorOrDeviceSession.caseOf({\n Left: (error) => {\n this._logger.error(\"Error getting device session\", { data: { error } });\n throw error;\n },\n // Return a function that can be used to reenable the refresher\n Right: (deviceSession) => deviceSession.disableRefresher(blockerId),\n });\n }\n}\n"],
|
5
|
+
"mappings": "iOAAA,OAAS,UAAAA,EAAQ,cAAAC,MAAkB,YAInC,OAAS,sBAAAC,MAA0B,iDAEnC,OAAS,eAAAC,MAAmB,4CAWrB,IAAMC,EAAN,KAA2C,CAEhD,YAEmBC,EAEjBC,EACA,CAHiB,qBAAAD,EAIjB,KAAK,QAAUC,EAAc,sCAAsC,CACrE,CARiB,QAUjB,QAAQ,CAAE,UAAAC,EAAW,UAAAC,CAAU,EAA6C,CAI1E,OAFE,KAAK,gBAAgB,qBAAqBD,CAAS,EAEzB,OAAO,CACjC,KAAOE,GAAU,CACf,WAAK,QAAQ,MAAM,+BAAgC,CAAE,KAAM,CAAE,MAAAA,CAAM,CAAE,CAAC,EAChEA,CACR,EAEA,MAAQC,GAAkBA,EAAc,iBAAiBF,CAAS,CACpE,CAAC,CACH,CACF,EAxBaJ,EAANO,EAAA,CADNC,EAAW,EAIPC,EAAA,EAAAC,EAAOC,EAAmB,oBAAoB,GAE9CF,EAAA,EAAAC,EAAOE,EAAY,6BAA6B,IALxCZ",
|
6
|
+
"names": ["inject", "injectable", "deviceSessionTypes", "loggerTypes", "DisableDeviceSessionRefresherUseCase", "_sessionService", "loggerFactory", "sessionId", "blockerId", "error", "deviceSession", "__decorateClass", "injectable", "__decorateParam", "inject", "deviceSessionTypes", "loggerTypes"]
|
7
|
+
}
|
@@ -0,0 +1,2 @@
|
|
1
|
+
import{deviceSessionStubBuilder as f}from"../../../internal/device-session/model/DeviceSession.stub";import{DeviceSessionNotFound as l}from"../../../internal/device-session/model/Errors";import{DefaultDeviceSessionService as S}from"../../../internal/device-session/service/DefaultDeviceSessionService";import{DefaultLoggerPublisherService as m}from"../../../internal/logger-publisher/service/DefaultLoggerPublisherService";import{AxiosManagerApiDataSource as v}from"../../../internal/manager-api/data/AxiosManagerApiDataSource";import{DefaultManagerApiService as d}from"../../../internal/manager-api/service/DefaultManagerApiService";import{DefaultSecureChannelDataSource as u}from"../../../internal/secure-channel/data/DefaultSecureChannelDataSource";import{DefaultSecureChannelService as p}from"../../../internal/secure-channel/service/DefaultSecureChannelService";import{DisableDeviceSessionRefresherUseCase as n}from"./DisableDeviceSessionRefresher";vi.mock("uuid",()=>({v4:()=>"fakeUuid"}));let e,r,i,o,t,c;describe("DisableDeviceSessionRefresherUseCase",()=>{beforeEach(()=>{e=new m([],"get-connected-device-use-case-test"),r=new S(()=>e),t=new d(new v({})),c=new p(new u({}))}),afterEach(()=>{vi.clearAllMocks()}),describe("execute",()=>{it("should disable the device session refresher and return a function to reenable it",()=>{o=f({id:"fakeSessionId"},()=>e,t,c),r.addDeviceSession(o),i=new n(r,()=>e);const s=vi.spyOn(o,"disableRefresher"),a=i.execute({sessionId:"fakeSessionId",blockerId:"fakeBlockerId"});expect(s).toHaveBeenCalledWith("fakeBlockerId"),a(),o.close()}),it("should throw error when deviceSession is not found",()=>{i=new n(r,()=>e);try{i.execute({sessionId:"fakeSessionId",blockerId:"fakeBlockerId"})}catch(s){expect(s).toBeInstanceOf(l)}})})});
|
2
|
+
//# sourceMappingURL=DisableDeviceSessionRefresher.test.js.map
|
@@ -0,0 +1,7 @@
|
|
1
|
+
{
|
2
|
+
"version": 3,
|
3
|
+
"sources": ["../../../../../../src/api/device-session/use-case/DisableDeviceSessionRefresher.test.ts"],
|
4
|
+
"sourcesContent": ["import { type DmkConfig } from \"@api/DmkConfig\";\nimport { type LoggerPublisherService } from \"@api/logger-publisher/service/LoggerPublisherService\";\nimport { type DeviceSession } from \"@internal/device-session/model/DeviceSession\";\nimport { deviceSessionStubBuilder } from \"@internal/device-session/model/DeviceSession.stub\";\nimport { DeviceSessionNotFound } from \"@internal/device-session/model/Errors\";\nimport { DefaultDeviceSessionService } from \"@internal/device-session/service/DefaultDeviceSessionService\";\nimport { type DeviceSessionService } from \"@internal/device-session/service/DeviceSessionService\";\nimport { DefaultLoggerPublisherService } from \"@internal/logger-publisher/service/DefaultLoggerPublisherService\";\nimport { AxiosManagerApiDataSource } from \"@internal/manager-api/data/AxiosManagerApiDataSource\";\nimport { DefaultManagerApiService } from \"@internal/manager-api/service/DefaultManagerApiService\";\nimport { type ManagerApiService } from \"@internal/manager-api/service/ManagerApiService\";\nimport { DefaultSecureChannelDataSource } from \"@internal/secure-channel/data/DefaultSecureChannelDataSource\";\nimport { DefaultSecureChannelService } from \"@internal/secure-channel/service/DefaultSecureChannelService\";\nimport { type SecureChannelService } from \"@internal/secure-channel/service/SecureChannelService\";\n\nimport { DisableDeviceSessionRefresherUseCase } from \"./DisableDeviceSessionRefresher\";\n\nvi.mock(\"uuid\", () => ({\n v4: () => \"fakeUuid\",\n}));\n\nlet logger: LoggerPublisherService;\nlet sessionService: DeviceSessionService;\nlet useCase: DisableDeviceSessionRefresherUseCase;\nlet deviceSession: DeviceSession;\nlet managerApi: ManagerApiService;\nlet secureChannel: SecureChannelService;\ndescribe(\"DisableDeviceSessionRefresherUseCase\", () => {\n beforeEach(() => {\n logger = new DefaultLoggerPublisherService(\n [],\n \"get-connected-device-use-case-test\",\n );\n sessionService = new DefaultDeviceSessionService(() => logger);\n managerApi = new DefaultManagerApiService(\n new AxiosManagerApiDataSource({} as DmkConfig),\n );\n secureChannel = new DefaultSecureChannelService(\n new DefaultSecureChannelDataSource({} as DmkConfig),\n );\n });\n\n afterEach(() => {\n vi.clearAllMocks();\n });\n\n describe(\"execute\", () => {\n it(\"should disable the device session refresher and return a function to reenable it\", () => {\n // given\n deviceSession = deviceSessionStubBuilder(\n { id: \"fakeSessionId\" },\n () => logger,\n managerApi,\n secureChannel,\n );\n sessionService.addDeviceSession(deviceSession);\n useCase = new DisableDeviceSessionRefresherUseCase(\n sessionService,\n () => logger,\n );\n\n const spy = vi.spyOn(deviceSession, \"disableRefresher\");\n\n // when\n const reenableRefresher = useCase.execute({\n sessionId: \"fakeSessionId\",\n blockerId: \"fakeBlockerId\",\n });\n\n // then\n expect(spy).toHaveBeenCalledWith(\"fakeBlockerId\");\n reenableRefresher();\n deviceSession.close();\n });\n\n it(\"should throw error when deviceSession is not found\", () => {\n // given\n useCase = new DisableDeviceSessionRefresherUseCase(\n sessionService,\n () => logger,\n );\n\n // when\n try {\n useCase.execute({\n sessionId: \"fakeSessionId\",\n blockerId: \"fakeBlockerId\",\n });\n } catch (error) {\n // then\n expect(error).toBeInstanceOf(DeviceSessionNotFound);\n }\n });\n });\n});\n"],
|
5
|
+
"mappings": "AAGA,OAAS,4BAAAA,MAAgC,oDACzC,OAAS,yBAAAC,MAA6B,wCACtC,OAAS,+BAAAC,MAAmC,+DAE5C,OAAS,iCAAAC,MAAqC,mEAC9C,OAAS,6BAAAC,MAAiC,uDAC1C,OAAS,4BAAAC,MAAgC,yDAEzC,OAAS,kCAAAC,MAAsC,+DAC/C,OAAS,+BAAAC,MAAmC,+DAG5C,OAAS,wCAAAC,MAA4C,kCAErD,GAAG,KAAK,OAAQ,KAAO,CACrB,GAAI,IAAM,UACZ,EAAE,EAEF,IAAIC,EACAC,EACAC,EACAC,EACAC,EACAC,EACJ,SAAS,uCAAwC,IAAM,CACrD,WAAW,IAAM,CACfL,EAAS,IAAIN,EACX,CAAC,EACD,oCACF,EACAO,EAAiB,IAAIR,EAA4B,IAAMO,CAAM,EAC7DI,EAAa,IAAIR,EACf,IAAID,EAA0B,CAAC,CAAc,CAC/C,EACAU,EAAgB,IAAIP,EAClB,IAAID,EAA+B,CAAC,CAAc,CACpD,CACF,CAAC,EAED,UAAU,IAAM,CACd,GAAG,cAAc,CACnB,CAAC,EAED,SAAS,UAAW,IAAM,CACxB,GAAG,mFAAoF,IAAM,CAE3FM,EAAgBZ,EACd,CAAE,GAAI,eAAgB,EACtB,IAAMS,EACNI,EACAC,CACF,EACAJ,EAAe,iBAAiBE,CAAa,EAC7CD,EAAU,IAAIH,EACZE,EACA,IAAMD,CACR,EAEA,MAAMM,EAAM,GAAG,MAAMH,EAAe,kBAAkB,EAGhDI,EAAoBL,EAAQ,QAAQ,CACxC,UAAW,gBACX,UAAW,eACb,CAAC,EAGD,OAAOI,CAAG,EAAE,qBAAqB,eAAe,EAChDC,EAAkB,EAClBJ,EAAc,MAAM,CACtB,CAAC,EAED,GAAG,qDAAsD,IAAM,CAE7DD,EAAU,IAAIH,EACZE,EACA,IAAMD,CACR,EAGA,GAAI,CACFE,EAAQ,QAAQ,CACd,UAAW,gBACX,UAAW,eACb,CAAC,CACH,OAASM,EAAO,CAEd,OAAOA,CAAK,EAAE,eAAehB,CAAqB,CACpD,CACF,CAAC,CACH,CAAC,CACH,CAAC",
|
6
|
+
"names": ["deviceSessionStubBuilder", "DeviceSessionNotFound", "DefaultDeviceSessionService", "DefaultLoggerPublisherService", "AxiosManagerApiDataSource", "DefaultManagerApiService", "DefaultSecureChannelDataSource", "DefaultSecureChannelService", "DisableDeviceSessionRefresherUseCase", "logger", "sessionService", "useCase", "deviceSession", "managerApi", "secureChannel", "spy", "reenableRefresher", "error"]
|
7
|
+
}
|
package/lib/esm/src/api/index.js
CHANGED
@@ -1,2 +1,2 @@
|
|
1
|
-
import{Apdu as r}from"./apdu/model/Apdu";import{APDU_MAX_PAYLOAD as p,ApduBuilder as
|
1
|
+
import{Apdu as r}from"./apdu/model/Apdu";import{APDU_MAX_PAYLOAD as p,ApduBuilder as i}from"./apdu/utils/ApduBuilder";import{ApduParser as n}from"./apdu/utils/ApduParser";export*from"./apdu/utils/AppBuilderError";import{ByteArrayBuilder as f}from"./apdu/utils/ByteArrayBuilder";import{ByteArrayParser as x}from"./apdu/utils/ByteArrayParser";import{InvalidStatusWordError as A}from"./command/Errors";import{CommandResultFactory as D,CommandResultStatus as v,isSuccessCommandResult as S}from"./command/model/CommandResult";import{CloseAppCommand as C}from"./command/os/CloseAppCommand";import{GetAppAndVersionCommand as g}from"./command/os/GetAppAndVersionCommand";import{BatteryStatusType as L,GetBatteryStatusCommand as G}from"./command/os/GetBatteryStatusCommand";import{GetOsVersionCommand as E}from"./command/os/GetOsVersionCommand";import{ListAppsCommand as b}from"./command/os/ListAppsCommand";import{LoadCertificateCommand as I}from"./command/os/LoadCertificateCommand";import{OpenAppCommand as h}from"./command/os/OpenAppCommand";import{isCommandErrorCode as V}from"./command/utils/CommandErrors";import{CommandUtils as _}from"./command/utils/CommandUtils";import{GlobalCommandError as H,GlobalCommandErrorHandler as W}from"./command/utils/GlobalCommandError";import{DeviceModel as K,DeviceModelId as X,LEDGER_VENDOR_ID as q}from"./device/DeviceModel";import{DeviceStatus as N}from"./device/DeviceStatus";import{DeviceActionStatus as j}from"./device-action/model/DeviceActionState";import{UserInteractionRequired as J}from"./device-action/model/UserInteractionRequired";import{CallTaskInAppDeviceAction as Z}from"./device-action/os/CallTaskInAppDeviceAction/CallTaskInAppDeviceAction";import{UnknownDAError as ee}from"./device-action/os/Errors";import{GetDeviceStatusDeviceAction as re}from"./device-action/os/GetDeviceStatus/GetDeviceStatusDeviceAction";import{GoToDashboardDeviceAction as pe}from"./device-action/os/GoToDashboard/GoToDashboardDeviceAction";import{ListAppsDeviceAction as me}from"./device-action/os/ListApps/ListAppsDeviceAction";import{ListAppsWithMetadataDeviceAction as ae}from"./device-action/os/ListAppsWithMetadata/ListAppsWithMetadataDeviceAction";import{OpenAppDeviceAction as fe}from"./device-action/os/OpenAppDeviceAction/OpenAppDeviceAction";import{SendCommandInAppDeviceAction as xe}from"./device-action/os/SendCommandInAppDeviceAction/SendCommandInAppDeviceAction";import{XStateDeviceAction as Ae}from"./device-action/xstate-utils/XStateDeviceAction";import{StaticDeviceModelDataSource as De}from"./device-model/data/StaticDeviceModelDataSource";import{BleDeviceInfos as Se}from"./device-model/model/BleDeviceInfos";import{TransportDeviceModel as Ce}from"./device-model/model/DeviceModel";import{ApduResponse as ge}from"./device-session/ApduResponse";export*from"./device-session/data/FramerConst";import{DeviceSessionStateType as Ge}from"./device-session/DeviceSessionState";import{GenuineCheckDeviceAction as Ee}from"./secure-channel/device-action/GenuineCheck/GenuineCheckDeviceAction";import{defaultApduReceiverServiceStubBuilder as be}from"./device-session/service/DefaultApduReceiverService.stub";import{defaultApduSenderServiceStubBuilder as Ie}from"./device-session/service/DefaultApduSenderService.stub";import{FramerUtils as he}from"./device-session/utils/FramerUtils";import{DeviceManagementKit as Ve}from"./DeviceManagementKit";import{DeviceManagementKitBuilder as _e}from"./DeviceManagementKitBuilder";export*from"./Error";import{LogLevel as We}from"./logger-subscriber/model/LogLevel";import{ConsoleLogger as Ke}from"./logger-subscriber/service/ConsoleLogger";import{WebLogsExporterLogger as qe}from"./logger-subscriber/service/WebLogsExporterLogger";import{ConnectedDevice as Ne}from"./transport/model/ConnectedDevice";import{DeviceConnectionStateMachine as je}from"./transport/model/DeviceConnectionStateMachine";export*from"./transport/model/Errors";import{TransportConnectedDevice as Qe}from"./transport/model/TransportConnectedDevice";import{connectedDeviceStubBuilder as $e}from"./transport/model/TransportConnectedDevice.stub";export*from"./types";import{base64StringToBuffer as ro,isBase64String as to}from"./utils/Base64String";import{bufferToHexaString as io,hexaStringToBuffer as mo,isHexaString as no}from"./utils/HexaString";export{p as APDU_MAX_PAYLOAD,r as Apdu,i as ApduBuilder,n as ApduParser,ge as ApduResponse,L as BatteryStatusType,Se as BleDeviceInfos,f as ByteArrayBuilder,x as ByteArrayParser,Z as CallTaskInAppDeviceAction,C as CloseAppCommand,D as CommandResultFactory,v as CommandResultStatus,_ as CommandUtils,Ne as ConnectedDevice,Ke as ConsoleLogger,j as DeviceActionStatus,je as DeviceConnectionStateMachine,Ve as DeviceManagementKit,_e as DeviceManagementKitBuilder,K as DeviceModel,X as DeviceModelId,Ge as DeviceSessionStateType,N as DeviceStatus,he as FramerUtils,Ee as GenuineCheckDeviceAction,g as GetAppAndVersionCommand,G as GetBatteryStatusCommand,re as GetDeviceStatusDeviceAction,E as GetOsVersionCommand,H as GlobalCommandError,W as GlobalCommandErrorHandler,pe as GoToDashboardDeviceAction,A as InvalidStatusWordError,q as LEDGER_VENDOR_ID,b as ListAppsCommand,me as ListAppsDeviceAction,ae as ListAppsWithMetadataDeviceAction,I as LoadCertificateCommand,We as LogLevel,h as OpenAppCommand,fe as OpenAppDeviceAction,xe as SendCommandInAppDeviceAction,De as StaticDeviceModelDataSource,Qe as TransportConnectedDevice,Ce as TransportDeviceModel,ee as UnknownDAError,J as UserInteractionRequired,qe as WebLogsExporterLogger,Ae as XStateDeviceAction,ro as base64StringToBuffer,io as bufferToHexaString,$e as connectedDeviceStubBuilder,be as defaultApduReceiverServiceStubBuilder,Ie as defaultApduSenderServiceStubBuilder,mo as hexaStringToBuffer,to as isBase64String,V as isCommandErrorCode,no as isHexaString,S as isSuccessCommandResult};
|
2
2
|
//# sourceMappingURL=index.js.map
|
@@ -1,7 +1,7 @@
|
|
1
1
|
{
|
2
2
|
"version": 3,
|
3
3
|
"sources": ["../../../../src/api/index.ts"],
|
4
|
-
"sourcesContent": ["\"use strict\";\n\nexport { Apdu } from \"@api/apdu/model/Apdu\";\nexport { APDU_MAX_PAYLOAD, ApduBuilder } from \"@api/apdu/utils/ApduBuilder\";\nexport { ApduParser } from \"@api/apdu/utils/ApduParser\";\nexport * from \"@api/apdu/utils/AppBuilderError\";\nexport { ByteArrayBuilder } from \"@api/apdu/utils/ByteArrayBuilder\";\nexport { ByteArrayParser } from \"@api/apdu/utils/ByteArrayParser\";\nexport { InvalidStatusWordError } from \"@api/command/Errors\";\nexport {\n CommandResultFactory,\n CommandResultStatus,\n isSuccessCommandResult,\n} from \"@api/command/model/CommandResult\";\nexport { CloseAppCommand } from \"@api/command/os/CloseAppCommand\";\nexport {\n GetAppAndVersionCommand,\n type GetAppAndVersionResponse,\n} from \"@api/command/os/GetAppAndVersionCommand\";\nexport {\n BatteryStatusType,\n type GetBatteryStatusArgs,\n GetBatteryStatusCommand,\n type GetBatteryStatusResponse,\n} from \"@api/command/os/GetBatteryStatusCommand\";\nexport {\n GetOsVersionCommand,\n type GetOsVersionResponse,\n} from \"@api/command/os/GetOsVersionCommand\";\nexport {\n type ListAppsArgs,\n ListAppsCommand,\n type ListAppsErrorCodes,\n type ListAppsResponse,\n} from \"@api/command/os/ListAppsCommand\";\nexport {\n type LoadCertificateArgs,\n LoadCertificateCommand,\n type LoadCertificateErrorCodes,\n} from \"@api/command/os/LoadCertificateCommand\";\nexport {\n type OpenAppArgs,\n OpenAppCommand,\n} from \"@api/command/os/OpenAppCommand\";\nexport { isCommandErrorCode } from \"@api/command/utils/CommandErrors\";\nexport { CommandUtils } from \"@api/command/utils/CommandUtils\";\nexport {\n GlobalCommandError,\n GlobalCommandErrorHandler,\n} from \"@api/command/utils/GlobalCommandError\";\nexport {\n DeviceModel,\n DeviceModelId,\n LEDGER_VENDOR_ID,\n} from \"@api/device/DeviceModel\";\nexport { DeviceStatus } from \"@api/device/DeviceStatus\";\nexport { type InternalApi } from \"@api/device-action/DeviceAction\";\nexport {\n type DeviceActionState,\n DeviceActionStatus,\n} from \"@api/device-action/model/DeviceActionState\";\nexport { UserInteractionRequired } from \"@api/device-action/model/UserInteractionRequired\";\nexport { CallTaskInAppDeviceAction } from \"@api/device-action/os/CallTaskInAppDeviceAction/CallTaskInAppDeviceAction\";\nexport { UnknownDAError } from \"@api/device-action/os/Errors\";\nexport { GetDeviceStatusDeviceAction } from \"@api/device-action/os/GetDeviceStatus/GetDeviceStatusDeviceAction\";\nexport { GoToDashboardDeviceAction } from \"@api/device-action/os/GoToDashboard/GoToDashboardDeviceAction\";\nexport { ListAppsDeviceAction } from \"@api/device-action/os/ListApps/ListAppsDeviceAction\";\nexport { ListAppsWithMetadataDeviceAction } from \"@api/device-action/os/ListAppsWithMetadata/ListAppsWithMetadataDeviceAction\";\nexport { OpenAppDeviceAction } from \"@api/device-action/os/OpenAppDeviceAction/OpenAppDeviceAction\";\nexport { SendCommandInAppDeviceAction } from \"@api/device-action/os/SendCommandInAppDeviceAction/SendCommandInAppDeviceAction\";\nexport {\n type DeviceActionStateMachine,\n XStateDeviceAction,\n} from \"@api/device-action/xstate-utils/XStateDeviceAction\";\nexport { StaticDeviceModelDataSource } from \"@api/device-model/data/StaticDeviceModelDataSource\";\nexport { BleDeviceInfos } from \"@api/device-model/model/BleDeviceInfos\";\nexport { TransportDeviceModel } from \"@api/device-model/model/DeviceModel\";\nexport { ApduResponse } from \"@api/device-session/ApduResponse\";\nexport * from \"@api/device-session/data/FramerConst\";\nexport {\n type DeviceSessionState,\n DeviceSessionStateType,\n} from \"@api/device-session/DeviceSessionState\";\n// TODO: remove from exported\nexport { defaultApduReceiverServiceStubBuilder } from \"@api/device-session/service/DefaultApduReceiverService.stub\";\nexport { defaultApduSenderServiceStubBuilder } from \"@api/device-session/service/DefaultApduSenderService.stub\";\nexport { FramerUtils } from \"@api/device-session/utils/FramerUtils\";\nexport { DeviceManagementKit } from \"@api/DeviceManagementKit\";\nexport { DeviceManagementKitBuilder } from \"@api/DeviceManagementKitBuilder\";\nexport * from \"@api/Error\";\nexport { LogLevel } from \"@api/logger-subscriber/model/LogLevel\";\nexport { ConsoleLogger } from \"@api/logger-subscriber/service/ConsoleLogger\";\nexport { WebLogsExporterLogger } from \"@api/logger-subscriber/service/WebLogsExporterLogger\";\nexport { ConnectedDevice } from \"@api/transport/model/ConnectedDevice\";\nexport { DeviceConnectionStateMachine } from \"@api/transport/model/DeviceConnectionStateMachine\";\nexport * from \"@api/transport/model/Errors\";\nexport { TransportConnectedDevice } from \"@api/transport/model/TransportConnectedDevice\";\nexport { connectedDeviceStubBuilder } from \"@api/transport/model/TransportConnectedDevice.stub\";\nexport * from \"@api/types\";\nexport { base64StringToBuffer, isBase64String } from \"@api/utils/Base64String\";\nexport {\n bufferToHexaString,\n hexaStringToBuffer,\n isHexaString,\n} from \"@api/utils/HexaString\";\n"],
|
5
|
-
"mappings": "AAEA,OAAS,QAAAA,MAAY,uBACrB,OAAS,oBAAAC,EAAkB,eAAAC,MAAmB,8BAC9C,OAAS,cAAAC,MAAkB,6BAC3B,WAAc,kCACd,OAAS,oBAAAC,MAAwB,mCACjC,OAAS,mBAAAC,MAAuB,kCAChC,OAAS,0BAAAC,MAA8B,sBACvC,OACE,wBAAAC,EACA,uBAAAC,EACA,0BAAAC,MACK,mCACP,OAAS,mBAAAC,MAAuB,kCAChC,OACE,2BAAAC,MAEK,0CACP,OACE,qBAAAC,EAEA,2BAAAC,MAEK,0CACP,OACE,uBAAAC,MAEK,sCACP,OAEE,mBAAAC,MAGK,kCACP,OAEE,0BAAAC,MAEK,yCACP,OAEE,kBAAAC,MACK,iCACP,OAAS,sBAAAC,MAA0B,mCACnC,OAAS,gBAAAC,MAAoB,kCAC7B,OACE,sBAAAC,EACA,6BAAAC,MACK,wCACP,OACE,eAAAC,EACA,iBAAAC,EACA,oBAAAC,MACK,0BACP,OAAS,gBAAAC,MAAoB,2BAE7B,OAEE,sBAAAC,MACK,6CACP,OAAS,2BAAAC,MAA+B,mDACxC,OAAS,6BAAAC,MAAiC,4EAC1C,OAAS,kBAAAC,OAAsB,+BAC/B,OAAS,+BAAAC,OAAmC,oEAC5C,OAAS,6BAAAC,OAAiC,gEAC1C,OAAS,wBAAAC,OAA4B,sDACrC,OAAS,oCAAAC,OAAwC,8EACjD,OAAS,uBAAAC,OAA2B,gEACpC,OAAS,gCAAAC,OAAoC,kFAC7C,OAEE,sBAAAC,OACK,qDACP,OAAS,+BAAAC,OAAmC,qDAC5C,OAAS,kBAAAC,OAAsB,yCAC/B,OAAS,wBAAAC,OAA4B,sCACrC,OAAS,gBAAAC,OAAoB,mCAC7B,WAAc,uCACd,OAEE,0BAAAC,OACK,
|
6
|
-
"names": ["Apdu", "APDU_MAX_PAYLOAD", "ApduBuilder", "ApduParser", "ByteArrayBuilder", "ByteArrayParser", "InvalidStatusWordError", "CommandResultFactory", "CommandResultStatus", "isSuccessCommandResult", "CloseAppCommand", "GetAppAndVersionCommand", "BatteryStatusType", "GetBatteryStatusCommand", "GetOsVersionCommand", "ListAppsCommand", "LoadCertificateCommand", "OpenAppCommand", "isCommandErrorCode", "CommandUtils", "GlobalCommandError", "GlobalCommandErrorHandler", "DeviceModel", "DeviceModelId", "LEDGER_VENDOR_ID", "DeviceStatus", "DeviceActionStatus", "UserInteractionRequired", "CallTaskInAppDeviceAction", "UnknownDAError", "GetDeviceStatusDeviceAction", "GoToDashboardDeviceAction", "ListAppsDeviceAction", "ListAppsWithMetadataDeviceAction", "OpenAppDeviceAction", "SendCommandInAppDeviceAction", "XStateDeviceAction", "StaticDeviceModelDataSource", "BleDeviceInfos", "TransportDeviceModel", "ApduResponse", "DeviceSessionStateType", "defaultApduReceiverServiceStubBuilder", "defaultApduSenderServiceStubBuilder", "FramerUtils", "DeviceManagementKit", "DeviceManagementKitBuilder", "LogLevel", "ConsoleLogger", "WebLogsExporterLogger", "ConnectedDevice", "DeviceConnectionStateMachine", "TransportConnectedDevice", "connectedDeviceStubBuilder", "base64StringToBuffer", "isBase64String", "bufferToHexaString", "hexaStringToBuffer", "isHexaString"]
|
4
|
+
"sourcesContent": ["\"use strict\";\n\nexport { Apdu } from \"@api/apdu/model/Apdu\";\nexport { APDU_MAX_PAYLOAD, ApduBuilder } from \"@api/apdu/utils/ApduBuilder\";\nexport { ApduParser } from \"@api/apdu/utils/ApduParser\";\nexport * from \"@api/apdu/utils/AppBuilderError\";\nexport { ByteArrayBuilder } from \"@api/apdu/utils/ByteArrayBuilder\";\nexport { ByteArrayParser } from \"@api/apdu/utils/ByteArrayParser\";\nexport { InvalidStatusWordError } from \"@api/command/Errors\";\nexport {\n CommandResultFactory,\n CommandResultStatus,\n isSuccessCommandResult,\n} from \"@api/command/model/CommandResult\";\nexport { CloseAppCommand } from \"@api/command/os/CloseAppCommand\";\nexport {\n GetAppAndVersionCommand,\n type GetAppAndVersionResponse,\n} from \"@api/command/os/GetAppAndVersionCommand\";\nexport {\n BatteryStatusType,\n type GetBatteryStatusArgs,\n GetBatteryStatusCommand,\n type GetBatteryStatusResponse,\n} from \"@api/command/os/GetBatteryStatusCommand\";\nexport {\n GetOsVersionCommand,\n type GetOsVersionResponse,\n} from \"@api/command/os/GetOsVersionCommand\";\nexport {\n type ListAppsArgs,\n ListAppsCommand,\n type ListAppsErrorCodes,\n type ListAppsResponse,\n} from \"@api/command/os/ListAppsCommand\";\nexport {\n type LoadCertificateArgs,\n LoadCertificateCommand,\n type LoadCertificateErrorCodes,\n} from \"@api/command/os/LoadCertificateCommand\";\nexport {\n type OpenAppArgs,\n OpenAppCommand,\n} from \"@api/command/os/OpenAppCommand\";\nexport { isCommandErrorCode } from \"@api/command/utils/CommandErrors\";\nexport { CommandUtils } from \"@api/command/utils/CommandUtils\";\nexport {\n GlobalCommandError,\n GlobalCommandErrorHandler,\n} from \"@api/command/utils/GlobalCommandError\";\nexport {\n DeviceModel,\n DeviceModelId,\n LEDGER_VENDOR_ID,\n} from \"@api/device/DeviceModel\";\nexport { DeviceStatus } from \"@api/device/DeviceStatus\";\nexport { type InternalApi } from \"@api/device-action/DeviceAction\";\nexport {\n type DeviceActionState,\n DeviceActionStatus,\n} from \"@api/device-action/model/DeviceActionState\";\nexport { UserInteractionRequired } from \"@api/device-action/model/UserInteractionRequired\";\nexport { CallTaskInAppDeviceAction } from \"@api/device-action/os/CallTaskInAppDeviceAction/CallTaskInAppDeviceAction\";\nexport { UnknownDAError } from \"@api/device-action/os/Errors\";\nexport { GetDeviceStatusDeviceAction } from \"@api/device-action/os/GetDeviceStatus/GetDeviceStatusDeviceAction\";\nexport { GoToDashboardDeviceAction } from \"@api/device-action/os/GoToDashboard/GoToDashboardDeviceAction\";\nexport { ListAppsDeviceAction } from \"@api/device-action/os/ListApps/ListAppsDeviceAction\";\nexport { ListAppsWithMetadataDeviceAction } from \"@api/device-action/os/ListAppsWithMetadata/ListAppsWithMetadataDeviceAction\";\nexport { OpenAppDeviceAction } from \"@api/device-action/os/OpenAppDeviceAction/OpenAppDeviceAction\";\nexport { SendCommandInAppDeviceAction } from \"@api/device-action/os/SendCommandInAppDeviceAction/SendCommandInAppDeviceAction\";\nexport {\n type DeviceActionStateMachine,\n XStateDeviceAction,\n} from \"@api/device-action/xstate-utils/XStateDeviceAction\";\nexport { StaticDeviceModelDataSource } from \"@api/device-model/data/StaticDeviceModelDataSource\";\nexport { BleDeviceInfos } from \"@api/device-model/model/BleDeviceInfos\";\nexport { TransportDeviceModel } from \"@api/device-model/model/DeviceModel\";\nexport { ApduResponse } from \"@api/device-session/ApduResponse\";\nexport * from \"@api/device-session/data/FramerConst\";\nexport {\n type DeviceSessionState,\n DeviceSessionStateType,\n} from \"@api/device-session/DeviceSessionState\";\nexport { GenuineCheckDeviceAction } from \"@api/secure-channel/device-action/GenuineCheck/GenuineCheckDeviceAction\";\n// TODO: remove from exported\nexport { defaultApduReceiverServiceStubBuilder } from \"@api/device-session/service/DefaultApduReceiverService.stub\";\nexport { defaultApduSenderServiceStubBuilder } from \"@api/device-session/service/DefaultApduSenderService.stub\";\nexport { FramerUtils } from \"@api/device-session/utils/FramerUtils\";\nexport { DeviceManagementKit } from \"@api/DeviceManagementKit\";\nexport { DeviceManagementKitBuilder } from \"@api/DeviceManagementKitBuilder\";\nexport * from \"@api/Error\";\nexport { LogLevel } from \"@api/logger-subscriber/model/LogLevel\";\nexport { ConsoleLogger } from \"@api/logger-subscriber/service/ConsoleLogger\";\nexport { WebLogsExporterLogger } from \"@api/logger-subscriber/service/WebLogsExporterLogger\";\nexport { ConnectedDevice } from \"@api/transport/model/ConnectedDevice\";\nexport { DeviceConnectionStateMachine } from \"@api/transport/model/DeviceConnectionStateMachine\";\nexport * from \"@api/transport/model/Errors\";\nexport { TransportConnectedDevice } from \"@api/transport/model/TransportConnectedDevice\";\nexport { connectedDeviceStubBuilder } from \"@api/transport/model/TransportConnectedDevice.stub\";\nexport * from \"@api/types\";\nexport { base64StringToBuffer, isBase64String } from \"@api/utils/Base64String\";\nexport {\n bufferToHexaString,\n hexaStringToBuffer,\n isHexaString,\n} from \"@api/utils/HexaString\";\n"],
|
5
|
+
"mappings": "AAEA,OAAS,QAAAA,MAAY,uBACrB,OAAS,oBAAAC,EAAkB,eAAAC,MAAmB,8BAC9C,OAAS,cAAAC,MAAkB,6BAC3B,W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AC9B,OAAS,yBAAAC,OAA6B,uDACtC,OAAS,mBAAAC,OAAuB,uCAChC,OAAS,gCAAAC,OAAoC,oDAC7C,WAAc,8BACd,OAAS,4BAAAC,OAAgC,gDACzC,OAAS,8BAAAC,OAAkC,qDAC3C,WAAc,aACd,OAAS,wBAAAC,GAAsB,kBAAAC,OAAsB,0BACrD,OACE,sBAAAC,GACA,sBAAAC,GACA,gBAAAC,OACK",
|
6
|
+
"names": ["Apdu", "APDU_MAX_PAYLOAD", "ApduBuilder", "ApduParser", "ByteArrayBuilder", "ByteArrayParser", "InvalidStatusWordError", "CommandResultFactory", "CommandResultStatus", "isSuccessCommandResult", "CloseAppCommand", "GetAppAndVersionCommand", "BatteryStatusType", "GetBatteryStatusCommand", "GetOsVersionCommand", "ListAppsCommand", "LoadCertificateCommand", "OpenAppCommand", "isCommandErrorCode", "CommandUtils", "GlobalCommandError", "GlobalCommandErrorHandler", "DeviceModel", "DeviceModelId", "LEDGER_VENDOR_ID", "DeviceStatus", "DeviceActionStatus", "UserInteractionRequired", "CallTaskInAppDeviceAction", "UnknownDAError", "GetDeviceStatusDeviceAction", "GoToDashboardDeviceAction", "ListAppsDeviceAction", "ListAppsWithMetadataDeviceAction", "OpenAppDeviceAction", "SendCommandInAppDeviceAction", "XStateDeviceAction", "StaticDeviceModelDataSource", "BleDeviceInfos", "TransportDeviceModel", "ApduResponse", "DeviceSessionStateType", "GenuineCheckDeviceAction", "defaultApduReceiverServiceStubBuilder", "defaultApduSenderServiceStubBuilder", "FramerUtils", "DeviceManagementKit", "DeviceManagementKitBuilder", "LogLevel", "ConsoleLogger", "WebLogsExporterLogger", "ConnectedDevice", "DeviceConnectionStateMachine", "TransportConnectedDevice", "connectedDeviceStubBuilder", "base64StringToBuffer", "isBase64String", "bufferToHexaString", "hexaStringToBuffer", "isHexaString"]
|
7
7
|
}
|