@ledgerhq/device-management-kit 1.0.1 → 1.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +63 -28
- package/lib/cjs/package.json +1 -1
- package/lib/cjs/src/api/DeviceManagementKit.js +1 -1
- package/lib/cjs/src/api/DeviceManagementKit.js.map +2 -2
- package/lib/cjs/src/api/apdu/utils/ApduBuilder.js +1 -1
- package/lib/cjs/src/api/apdu/utils/ApduBuilder.js.map +3 -3
- package/lib/cjs/src/api/command/os/GetBackgroundImageSizeCommand.js +2 -0
- package/lib/cjs/src/api/command/os/GetBackgroundImageSizeCommand.js.map +7 -0
- package/lib/cjs/src/api/command/os/GetBackgroundImageSizeCommand.test.js +2 -0
- package/lib/cjs/src/api/command/os/GetBackgroundImageSizeCommand.test.js.map +7 -0
- package/lib/cjs/src/api/device-action/DeviceAction.js +1 -1
- package/lib/cjs/src/api/device-action/DeviceAction.js.map +1 -1
- package/lib/cjs/src/api/device-action/__test-utils__/makeInternalApi.js +1 -1
- package/lib/cjs/src/api/device-action/__test-utils__/makeInternalApi.js.map +3 -3
- package/lib/cjs/src/api/device-action/__test-utils__/setupTestMachine.js +1 -1
- package/lib/cjs/src/api/device-action/__test-utils__/setupTestMachine.js.map +3 -3
- package/lib/cjs/src/api/device-action/model/UserInteractionRequired.js +1 -1
- package/lib/cjs/src/api/device-action/model/UserInteractionRequired.js.map +2 -2
- package/lib/cjs/src/api/device-action/os/CallTaskInAppDeviceAction/CallTaskInAppDeviceAction.js +1 -1
- package/lib/cjs/src/api/device-action/os/CallTaskInAppDeviceAction/CallTaskInAppDeviceAction.js.map +3 -3
- package/lib/cjs/src/api/device-action/os/CallTaskInAppDeviceAction/CallTaskInAppDeviceAction.test.js +1 -1
- package/lib/cjs/src/api/device-action/os/CallTaskInAppDeviceAction/CallTaskInAppDeviceAction.test.js.map +3 -3
- package/lib/cjs/src/api/device-action/os/CallTaskInAppDeviceAction/CallTaskInAppDeviceActionTypes.js +1 -1
- package/lib/cjs/src/api/device-action/os/CallTaskInAppDeviceAction/CallTaskInAppDeviceActionTypes.js.map +3 -3
- package/lib/cjs/src/api/device-action/os/GetDeviceMetadata/GetDeviceMetadataDeviceAction.js +1 -1
- package/lib/cjs/src/api/device-action/os/GetDeviceMetadata/GetDeviceMetadataDeviceAction.js.map +2 -2
- package/lib/cjs/src/api/device-action/os/GetDeviceMetadata/GetDeviceMetadataDeviceAction.test.js +1 -1
- package/lib/cjs/src/api/device-action/os/GetDeviceMetadata/GetDeviceMetadataDeviceAction.test.js.map +3 -3
- package/lib/cjs/src/api/device-action/os/GetDeviceMetadata/types.js +1 -1
- package/lib/cjs/src/api/device-action/os/GetDeviceMetadata/types.js.map +3 -3
- package/lib/cjs/src/api/device-action/os/GetDeviceStatus/GetDeviceStatusDeviceAction.js +1 -1
- package/lib/cjs/src/api/device-action/os/GetDeviceStatus/GetDeviceStatusDeviceAction.js.map +3 -3
- package/lib/cjs/src/api/device-action/os/GetDeviceStatus/GetDeviceStatusDeviceAction.test.js +1 -1
- package/lib/cjs/src/api/device-action/os/GetDeviceStatus/GetDeviceStatusDeviceAction.test.js.map +3 -3
- package/lib/cjs/src/api/device-action/os/GetDeviceStatus/types.js +1 -1
- package/lib/cjs/src/api/device-action/os/GetDeviceStatus/types.js.map +3 -3
- package/lib/cjs/src/api/device-action/os/GoToDashboard/GoToDashboardDeviceAction.js +1 -1
- package/lib/cjs/src/api/device-action/os/GoToDashboard/GoToDashboardDeviceAction.js.map +3 -3
- package/lib/cjs/src/api/device-action/os/GoToDashboard/GoToDashboardDeviceAction.test.js +1 -1
- package/lib/cjs/src/api/device-action/os/GoToDashboard/GoToDashboardDeviceAction.test.js.map +3 -3
- package/lib/cjs/src/api/device-action/os/GoToDashboard/types.js +1 -1
- package/lib/cjs/src/api/device-action/os/GoToDashboard/types.js.map +3 -3
- package/lib/cjs/src/api/device-action/os/InstallOrUpdateApps/InstallOrUpdateAppsDeviceAction.js +1 -1
- package/lib/cjs/src/api/device-action/os/InstallOrUpdateApps/InstallOrUpdateAppsDeviceAction.js.map +2 -2
- package/lib/cjs/src/api/device-action/os/InstallOrUpdateApps/InstallOrUpdateAppsDeviceAction.test.js +1 -1
- package/lib/cjs/src/api/device-action/os/InstallOrUpdateApps/InstallOrUpdateAppsDeviceAction.test.js.map +2 -2
- package/lib/cjs/src/api/device-action/os/InstallOrUpdateApps/types.js +1 -1
- package/lib/cjs/src/api/device-action/os/InstallOrUpdateApps/types.js.map +3 -3
- package/lib/cjs/src/api/device-action/os/ListApps/ListAppsDeviceAction.js +1 -1
- package/lib/cjs/src/api/device-action/os/ListApps/ListAppsDeviceAction.js.map +3 -3
- package/lib/cjs/src/api/device-action/os/ListApps/ListAppsDeviceAction.test.js +1 -1
- package/lib/cjs/src/api/device-action/os/ListApps/ListAppsDeviceAction.test.js.map +3 -3
- package/lib/cjs/src/api/device-action/os/ListApps/types.js +1 -1
- package/lib/cjs/src/api/device-action/os/ListApps/types.js.map +3 -3
- package/lib/cjs/src/api/device-action/os/ListAppsWithMetadata/ListAppsWithMetadataDeviceAction.js +1 -1
- package/lib/cjs/src/api/device-action/os/ListAppsWithMetadata/ListAppsWithMetadataDeviceAction.js.map +3 -3
- package/lib/cjs/src/api/device-action/os/ListAppsWithMetadata/ListAppsWithMetadataDeviceAction.test.js +1 -1
- package/lib/cjs/src/api/device-action/os/ListAppsWithMetadata/ListAppsWithMetadataDeviceAction.test.js.map +3 -3
- package/lib/cjs/src/api/device-action/os/ListAppsWithMetadata/types.js +1 -1
- package/lib/cjs/src/api/device-action/os/ListAppsWithMetadata/types.js.map +3 -3
- package/lib/cjs/src/api/device-action/os/OpenAppDeviceAction/OpenAppDeviceAction.js +1 -1
- package/lib/cjs/src/api/device-action/os/OpenAppDeviceAction/OpenAppDeviceAction.js.map +3 -3
- package/lib/cjs/src/api/device-action/os/OpenAppDeviceAction/OpenAppDeviceAction.test.js +1 -1
- package/lib/cjs/src/api/device-action/os/OpenAppDeviceAction/OpenAppDeviceAction.test.js.map +3 -3
- package/lib/cjs/src/api/device-action/os/OpenAppDeviceAction/types.js +1 -1
- package/lib/cjs/src/api/device-action/os/OpenAppDeviceAction/types.js.map +3 -3
- package/lib/cjs/src/api/device-action/os/OpenAppWithDependencies/OpenAppWithDependenciesDeviceAction.js +1 -1
- package/lib/cjs/src/api/device-action/os/OpenAppWithDependencies/OpenAppWithDependenciesDeviceAction.js.map +3 -3
- package/lib/cjs/src/api/device-action/os/OpenAppWithDependencies/OpenAppWithDependenciesDeviceAction.test.js +1 -1
- package/lib/cjs/src/api/device-action/os/OpenAppWithDependencies/OpenAppWithDependenciesDeviceAction.test.js.map +3 -3
- package/lib/cjs/src/api/device-action/os/OpenAppWithDependencies/types.js +1 -1
- package/lib/cjs/src/api/device-action/os/OpenAppWithDependencies/types.js.map +3 -3
- package/lib/cjs/src/api/device-action/os/SendCommandInAppDeviceAction/SendCommandInAppDeviceAction.js +1 -1
- package/lib/cjs/src/api/device-action/os/SendCommandInAppDeviceAction/SendCommandInAppDeviceAction.js.map +3 -3
- package/lib/cjs/src/api/device-action/os/SendCommandInAppDeviceAction/SendCommandInAppDeviceAction.test.js +1 -1
- package/lib/cjs/src/api/device-action/os/SendCommandInAppDeviceAction/SendCommandInAppDeviceAction.test.js.map +3 -3
- package/lib/cjs/src/api/device-action/os/SendCommandInAppDeviceAction/SendCommandInAppDeviceActionTypes.js +1 -1
- package/lib/cjs/src/api/device-action/os/SendCommandInAppDeviceAction/SendCommandInAppDeviceActionTypes.js.map +3 -3
- package/lib/cjs/src/api/device-action/task/GetFirmwareMetadataTask.js +1 -1
- package/lib/cjs/src/api/device-action/task/GetFirmwareMetadataTask.js.map +3 -3
- package/lib/cjs/src/api/device-action/xstate-utils/XStateDeviceAction.js +1 -1
- package/lib/cjs/src/api/device-action/xstate-utils/XStateDeviceAction.js.map +3 -3
- package/lib/cjs/src/api/index.js +1 -1
- package/lib/cjs/src/api/index.js.map +3 -3
- package/lib/cjs/src/api/logger-publisher/utils/noopLoggerFactory.js +2 -0
- package/lib/cjs/src/api/logger-publisher/utils/noopLoggerFactory.js.map +7 -0
- package/lib/cjs/src/api/logger-publisher/utils/noopLoggerFactory.test.js +2 -0
- package/lib/cjs/src/api/logger-publisher/utils/noopLoggerFactory.test.js.map +7 -0
- package/lib/cjs/src/api/logger-subscriber/service/WebLogsExporterLogger.test.js +1 -1
- package/lib/cjs/src/api/logger-subscriber/service/WebLogsExporterLogger.test.js.map +2 -2
- package/lib/cjs/src/api/secure-channel/task/ConnectToSecureChannelTask.js +1 -1
- package/lib/cjs/src/api/secure-channel/task/ConnectToSecureChannelTask.js.map +3 -3
- package/lib/cjs/src/api/transport/model/DeviceConnectionStateMachine.js +1 -1
- package/lib/cjs/src/api/transport/model/DeviceConnectionStateMachine.js.map +3 -3
- package/lib/cjs/src/api/transport/model/DeviceConnectionStateMachine.test.js +1 -1
- package/lib/cjs/src/api/transport/model/DeviceConnectionStateMachine.test.js.map +3 -3
- package/lib/cjs/src/api/transport/model/Errors.js +1 -1
- package/lib/cjs/src/api/transport/model/Errors.js.map +3 -3
- package/lib/cjs/src/api/types.js +1 -1
- package/lib/cjs/src/api/types.js.map +1 -1
- package/lib/cjs/src/api/utils/ApplicationChecker.js +2 -0
- package/lib/cjs/src/api/utils/ApplicationChecker.js.map +7 -0
- package/lib/cjs/src/api/utils/ApplicationChecker.test.js +2 -0
- package/lib/cjs/src/api/utils/ApplicationChecker.test.js.map +7 -0
- package/lib/cjs/src/api/utils/ApplicationResolver.js +2 -0
- package/lib/cjs/src/api/utils/ApplicationResolver.js.map +7 -0
- package/lib/cjs/src/api/utils/Base64String.js +1 -1
- package/lib/cjs/src/api/utils/Base64String.js.map +3 -3
- package/lib/cjs/src/api/utils/Base64String.test.js +1 -1
- package/lib/cjs/src/api/utils/Base64String.test.js.map +3 -3
- package/lib/cjs/src/internal/device-session/di/deviceSessionModule.js +1 -1
- package/lib/cjs/src/internal/device-session/di/deviceSessionModule.js.map +3 -3
- package/lib/cjs/src/internal/device-session/di/deviceSessionTypes.js +1 -1
- package/lib/cjs/src/internal/device-session/di/deviceSessionTypes.js.map +2 -2
- package/lib/cjs/src/internal/device-session/model/DevicePinger.js +1 -1
- package/lib/cjs/src/internal/device-session/model/DevicePinger.js.map +2 -2
- package/lib/cjs/src/internal/device-session/model/DevicePinger.test.js +1 -1
- package/lib/cjs/src/internal/device-session/model/DevicePinger.test.js.map +2 -2
- package/lib/cjs/src/internal/device-session/model/DeviceSession.js +1 -1
- package/lib/cjs/src/internal/device-session/model/DeviceSession.js.map +3 -3
- package/lib/cjs/src/internal/device-session/model/DeviceSession.test.js +1 -1
- package/lib/cjs/src/internal/device-session/model/DeviceSession.test.js.map +3 -3
- package/lib/cjs/src/internal/device-session/model/DeviceSessionEventDispatcher.js +1 -1
- package/lib/cjs/src/internal/device-session/model/DeviceSessionEventDispatcher.js.map +2 -2
- package/lib/cjs/src/internal/device-session/model/DeviceSessionRefresher.js +1 -1
- package/lib/cjs/src/internal/device-session/model/DeviceSessionRefresher.js.map +3 -3
- package/lib/cjs/src/internal/device-session/model/DeviceSessionRefresher.test.js +1 -1
- package/lib/cjs/src/internal/device-session/model/DeviceSessionRefresher.test.js.map +2 -2
- package/lib/cjs/src/internal/device-session/model/DeviceSessionStateHandler.js +1 -1
- package/lib/cjs/src/internal/device-session/model/DeviceSessionStateHandler.js.map +3 -3
- package/lib/cjs/src/internal/device-session/model/DeviceSessionStateHandler.test.js +1 -1
- package/lib/cjs/src/internal/device-session/model/DeviceSessionStateHandler.test.js.map +2 -2
- package/lib/cjs/src/internal/device-session/service/IntentQueueService.js +2 -0
- package/lib/cjs/src/internal/device-session/service/IntentQueueService.js.map +7 -0
- package/lib/cjs/src/internal/device-session/service/IntentQueueService.test.js +2 -0
- package/lib/cjs/src/internal/device-session/service/IntentQueueService.test.js.map +7 -0
- package/lib/cjs/src/internal/device-session/use-case/UnsafeBypassIntentQueueUseCase.js +2 -0
- package/lib/cjs/src/internal/device-session/use-case/UnsafeBypassIntentQueueUseCase.js.map +7 -0
- package/lib/cjs/src/internal/discovery/use-case/ConnectUseCase.test.js +1 -1
- package/lib/cjs/src/internal/discovery/use-case/ConnectUseCase.test.js.map +3 -3
- package/lib/cjs/src/internal/send/use-case/SendApduUseCase.test.js +1 -1
- package/lib/cjs/src/internal/send/use-case/SendApduUseCase.test.js.map +3 -3
- package/lib/esm/package.json +1 -1
- package/lib/esm/src/api/DeviceManagementKit.js +1 -1
- package/lib/esm/src/api/DeviceManagementKit.js.map +2 -2
- package/lib/esm/src/api/apdu/utils/ApduBuilder.js +1 -1
- package/lib/esm/src/api/apdu/utils/ApduBuilder.js.map +3 -3
- package/lib/esm/src/api/command/os/GetBackgroundImageSizeCommand.js +2 -0
- package/lib/esm/src/api/command/os/GetBackgroundImageSizeCommand.js.map +7 -0
- package/lib/esm/src/api/command/os/GetBackgroundImageSizeCommand.test.js +2 -0
- package/lib/esm/src/api/command/os/GetBackgroundImageSizeCommand.test.js.map +7 -0
- package/lib/esm/src/api/device-action/__test-utils__/makeInternalApi.js +1 -1
- package/lib/esm/src/api/device-action/__test-utils__/makeInternalApi.js.map +3 -3
- package/lib/esm/src/api/device-action/__test-utils__/setupTestMachine.js +1 -1
- package/lib/esm/src/api/device-action/__test-utils__/setupTestMachine.js.map +3 -3
- package/lib/esm/src/api/device-action/model/UserInteractionRequired.js +1 -1
- package/lib/esm/src/api/device-action/model/UserInteractionRequired.js.map +2 -2
- package/lib/esm/src/api/device-action/os/CallTaskInAppDeviceAction/CallTaskInAppDeviceAction.js +1 -1
- package/lib/esm/src/api/device-action/os/CallTaskInAppDeviceAction/CallTaskInAppDeviceAction.js.map +3 -3
- package/lib/esm/src/api/device-action/os/CallTaskInAppDeviceAction/CallTaskInAppDeviceAction.test.js +1 -1
- package/lib/esm/src/api/device-action/os/CallTaskInAppDeviceAction/CallTaskInAppDeviceAction.test.js.map +3 -3
- package/lib/esm/src/api/device-action/os/CallTaskInAppDeviceAction/CallTaskInAppDeviceActionTypes.js +1 -0
- package/lib/esm/src/api/device-action/os/CallTaskInAppDeviceAction/CallTaskInAppDeviceActionTypes.js.map +4 -4
- package/lib/esm/src/api/device-action/os/GetDeviceMetadata/GetDeviceMetadataDeviceAction.js +1 -1
- package/lib/esm/src/api/device-action/os/GetDeviceMetadata/GetDeviceMetadataDeviceAction.js.map +3 -3
- package/lib/esm/src/api/device-action/os/GetDeviceMetadata/GetDeviceMetadataDeviceAction.test.js +1 -1
- package/lib/esm/src/api/device-action/os/GetDeviceMetadata/GetDeviceMetadataDeviceAction.test.js.map +3 -3
- package/lib/esm/src/api/device-action/os/GetDeviceMetadata/types.js +1 -0
- package/lib/esm/src/api/device-action/os/GetDeviceMetadata/types.js.map +4 -4
- package/lib/esm/src/api/device-action/os/GetDeviceStatus/GetDeviceStatusDeviceAction.js +1 -1
- package/lib/esm/src/api/device-action/os/GetDeviceStatus/GetDeviceStatusDeviceAction.js.map +3 -3
- package/lib/esm/src/api/device-action/os/GetDeviceStatus/GetDeviceStatusDeviceAction.test.js +1 -1
- package/lib/esm/src/api/device-action/os/GetDeviceStatus/GetDeviceStatusDeviceAction.test.js.map +3 -3
- package/lib/esm/src/api/device-action/os/GetDeviceStatus/types.js +1 -0
- package/lib/esm/src/api/device-action/os/GetDeviceStatus/types.js.map +4 -4
- package/lib/esm/src/api/device-action/os/GoToDashboard/GoToDashboardDeviceAction.js +1 -1
- package/lib/esm/src/api/device-action/os/GoToDashboard/GoToDashboardDeviceAction.js.map +3 -3
- package/lib/esm/src/api/device-action/os/GoToDashboard/GoToDashboardDeviceAction.test.js +1 -1
- package/lib/esm/src/api/device-action/os/GoToDashboard/GoToDashboardDeviceAction.test.js.map +3 -3
- package/lib/esm/src/api/device-action/os/GoToDashboard/types.js +1 -0
- package/lib/esm/src/api/device-action/os/GoToDashboard/types.js.map +4 -4
- package/lib/esm/src/api/device-action/os/InstallOrUpdateApps/InstallOrUpdateAppsDeviceAction.js +1 -1
- package/lib/esm/src/api/device-action/os/InstallOrUpdateApps/InstallOrUpdateAppsDeviceAction.js.map +3 -3
- package/lib/esm/src/api/device-action/os/InstallOrUpdateApps/InstallOrUpdateAppsDeviceAction.test.js +1 -1
- package/lib/esm/src/api/device-action/os/InstallOrUpdateApps/InstallOrUpdateAppsDeviceAction.test.js.map +3 -3
- package/lib/esm/src/api/device-action/os/InstallOrUpdateApps/types.js +1 -0
- package/lib/esm/src/api/device-action/os/InstallOrUpdateApps/types.js.map +4 -4
- package/lib/esm/src/api/device-action/os/ListApps/ListAppsDeviceAction.js +1 -1
- package/lib/esm/src/api/device-action/os/ListApps/ListAppsDeviceAction.js.map +3 -3
- package/lib/esm/src/api/device-action/os/ListApps/ListAppsDeviceAction.test.js +1 -1
- package/lib/esm/src/api/device-action/os/ListApps/ListAppsDeviceAction.test.js.map +3 -3
- package/lib/esm/src/api/device-action/os/ListApps/types.js +1 -0
- package/lib/esm/src/api/device-action/os/ListApps/types.js.map +4 -4
- package/lib/esm/src/api/device-action/os/ListAppsWithMetadata/ListAppsWithMetadataDeviceAction.js +1 -1
- package/lib/esm/src/api/device-action/os/ListAppsWithMetadata/ListAppsWithMetadataDeviceAction.js.map +3 -3
- package/lib/esm/src/api/device-action/os/ListAppsWithMetadata/ListAppsWithMetadataDeviceAction.test.js +1 -1
- package/lib/esm/src/api/device-action/os/ListAppsWithMetadata/ListAppsWithMetadataDeviceAction.test.js.map +3 -3
- package/lib/esm/src/api/device-action/os/ListAppsWithMetadata/types.js +1 -0
- package/lib/esm/src/api/device-action/os/ListAppsWithMetadata/types.js.map +4 -4
- package/lib/esm/src/api/device-action/os/OpenAppDeviceAction/OpenAppDeviceAction.js +1 -1
- package/lib/esm/src/api/device-action/os/OpenAppDeviceAction/OpenAppDeviceAction.js.map +3 -3
- package/lib/esm/src/api/device-action/os/OpenAppDeviceAction/OpenAppDeviceAction.test.js +1 -1
- package/lib/esm/src/api/device-action/os/OpenAppDeviceAction/OpenAppDeviceAction.test.js.map +3 -3
- package/lib/esm/src/api/device-action/os/OpenAppDeviceAction/types.js +1 -0
- package/lib/esm/src/api/device-action/os/OpenAppDeviceAction/types.js.map +4 -4
- package/lib/esm/src/api/device-action/os/OpenAppWithDependencies/OpenAppWithDependenciesDeviceAction.js +1 -1
- package/lib/esm/src/api/device-action/os/OpenAppWithDependencies/OpenAppWithDependenciesDeviceAction.js.map +3 -3
- package/lib/esm/src/api/device-action/os/OpenAppWithDependencies/OpenAppWithDependenciesDeviceAction.test.js +1 -1
- package/lib/esm/src/api/device-action/os/OpenAppWithDependencies/OpenAppWithDependenciesDeviceAction.test.js.map +3 -3
- package/lib/esm/src/api/device-action/os/OpenAppWithDependencies/types.js +1 -0
- package/lib/esm/src/api/device-action/os/OpenAppWithDependencies/types.js.map +4 -4
- package/lib/esm/src/api/device-action/os/SendCommandInAppDeviceAction/SendCommandInAppDeviceAction.js +1 -1
- package/lib/esm/src/api/device-action/os/SendCommandInAppDeviceAction/SendCommandInAppDeviceAction.js.map +3 -3
- package/lib/esm/src/api/device-action/os/SendCommandInAppDeviceAction/SendCommandInAppDeviceAction.test.js +1 -1
- package/lib/esm/src/api/device-action/os/SendCommandInAppDeviceAction/SendCommandInAppDeviceAction.test.js.map +3 -3
- package/lib/esm/src/api/device-action/os/SendCommandInAppDeviceAction/SendCommandInAppDeviceActionTypes.js +1 -0
- package/lib/esm/src/api/device-action/os/SendCommandInAppDeviceAction/SendCommandInAppDeviceActionTypes.js.map +4 -4
- package/lib/esm/src/api/device-action/task/GetFirmwareMetadataTask.js +1 -1
- package/lib/esm/src/api/device-action/task/GetFirmwareMetadataTask.js.map +3 -3
- package/lib/esm/src/api/device-action/xstate-utils/XStateDeviceAction.js +1 -1
- package/lib/esm/src/api/device-action/xstate-utils/XStateDeviceAction.js.map +3 -3
- package/lib/esm/src/api/index.js +1 -1
- package/lib/esm/src/api/index.js.map +3 -3
- package/lib/esm/src/api/logger-publisher/utils/noopLoggerFactory.js +2 -0
- package/lib/esm/src/api/logger-publisher/utils/noopLoggerFactory.js.map +7 -0
- package/lib/esm/src/api/logger-publisher/utils/noopLoggerFactory.test.js +2 -0
- package/lib/esm/src/api/logger-publisher/utils/noopLoggerFactory.test.js.map +7 -0
- package/lib/esm/src/api/logger-subscriber/service/WebLogsExporterLogger.test.js +1 -1
- package/lib/esm/src/api/logger-subscriber/service/WebLogsExporterLogger.test.js.map +3 -3
- package/lib/esm/src/api/secure-channel/task/ConnectToSecureChannelTask.js +1 -1
- package/lib/esm/src/api/secure-channel/task/ConnectToSecureChannelTask.js.map +3 -3
- package/lib/esm/src/api/transport/model/DeviceConnectionStateMachine.js +1 -1
- package/lib/esm/src/api/transport/model/DeviceConnectionStateMachine.js.map +3 -3
- package/lib/esm/src/api/transport/model/DeviceConnectionStateMachine.test.js +1 -1
- package/lib/esm/src/api/transport/model/DeviceConnectionStateMachine.test.js.map +3 -3
- package/lib/esm/src/api/transport/model/Errors.js +1 -1
- package/lib/esm/src/api/transport/model/Errors.js.map +3 -3
- package/lib/esm/src/api/utils/ApplicationChecker.js +2 -0
- package/lib/esm/src/api/utils/ApplicationChecker.js.map +7 -0
- package/lib/esm/src/api/utils/ApplicationChecker.test.js +2 -0
- package/lib/esm/src/api/utils/ApplicationChecker.test.js.map +7 -0
- package/lib/esm/src/api/utils/ApplicationResolver.js +1 -0
- package/lib/esm/src/api/utils/ApplicationResolver.js.map +7 -0
- package/lib/esm/src/api/utils/Base64String.js +1 -1
- package/lib/esm/src/api/utils/Base64String.js.map +3 -3
- package/lib/esm/src/api/utils/Base64String.test.js +1 -1
- package/lib/esm/src/api/utils/Base64String.test.js.map +3 -3
- package/lib/esm/src/internal/device-session/di/deviceSessionModule.js +1 -1
- package/lib/esm/src/internal/device-session/di/deviceSessionModule.js.map +3 -3
- package/lib/esm/src/internal/device-session/di/deviceSessionTypes.js +1 -1
- package/lib/esm/src/internal/device-session/di/deviceSessionTypes.js.map +2 -2
- package/lib/esm/src/internal/device-session/model/DevicePinger.js +1 -1
- package/lib/esm/src/internal/device-session/model/DevicePinger.js.map +2 -2
- package/lib/esm/src/internal/device-session/model/DevicePinger.test.js +1 -1
- package/lib/esm/src/internal/device-session/model/DevicePinger.test.js.map +2 -2
- package/lib/esm/src/internal/device-session/model/DeviceSession.js +1 -1
- package/lib/esm/src/internal/device-session/model/DeviceSession.js.map +3 -3
- package/lib/esm/src/internal/device-session/model/DeviceSession.test.js +1 -1
- package/lib/esm/src/internal/device-session/model/DeviceSession.test.js.map +3 -3
- package/lib/esm/src/internal/device-session/model/DeviceSessionEventDispatcher.js +1 -1
- package/lib/esm/src/internal/device-session/model/DeviceSessionEventDispatcher.js.map +2 -2
- package/lib/esm/src/internal/device-session/model/DeviceSessionRefresher.js +1 -1
- package/lib/esm/src/internal/device-session/model/DeviceSessionRefresher.js.map +3 -3
- package/lib/esm/src/internal/device-session/model/DeviceSessionRefresher.test.js +1 -1
- package/lib/esm/src/internal/device-session/model/DeviceSessionRefresher.test.js.map +2 -2
- package/lib/esm/src/internal/device-session/model/DeviceSessionStateHandler.js +1 -1
- package/lib/esm/src/internal/device-session/model/DeviceSessionStateHandler.js.map +3 -3
- package/lib/esm/src/internal/device-session/model/DeviceSessionStateHandler.test.js +1 -1
- package/lib/esm/src/internal/device-session/model/DeviceSessionStateHandler.test.js.map +2 -2
- package/lib/esm/src/internal/device-session/service/IntentQueueService.js +2 -0
- package/lib/esm/src/internal/device-session/service/IntentQueueService.js.map +7 -0
- package/lib/esm/src/internal/device-session/service/IntentQueueService.test.js +2 -0
- package/lib/esm/src/internal/device-session/service/IntentQueueService.test.js.map +7 -0
- package/lib/esm/src/internal/device-session/use-case/UnsafeBypassIntentQueueUseCase.js +2 -0
- package/lib/esm/src/internal/device-session/use-case/UnsafeBypassIntentQueueUseCase.js.map +7 -0
- package/lib/esm/src/internal/discovery/use-case/ConnectUseCase.test.js +1 -1
- package/lib/esm/src/internal/discovery/use-case/ConnectUseCase.test.js.map +3 -3
- package/lib/esm/src/internal/send/use-case/SendApduUseCase.test.js +1 -1
- package/lib/esm/src/internal/send/use-case/SendApduUseCase.test.js.map +3 -3
- package/lib/types/src/api/DeviceManagementKit.d.ts +10 -0
- package/lib/types/src/api/DeviceManagementKit.d.ts.map +1 -1
- package/lib/types/src/api/apdu/utils/ApduBuilder.d.ts +7 -0
- package/lib/types/src/api/apdu/utils/ApduBuilder.d.ts.map +1 -1
- package/lib/types/src/api/command/os/GetBackgroundImageSizeCommand.d.ts +17 -0
- package/lib/types/src/api/command/os/GetBackgroundImageSizeCommand.d.ts.map +1 -0
- package/lib/types/src/api/command/os/GetBackgroundImageSizeCommand.test.d.ts +2 -0
- package/lib/types/src/api/command/os/GetBackgroundImageSizeCommand.test.d.ts.map +1 -0
- package/lib/types/src/api/device-action/DeviceAction.d.ts +2 -1
- package/lib/types/src/api/device-action/DeviceAction.d.ts.map +1 -1
- package/lib/types/src/api/device-action/__test-utils__/makeInternalApi.d.ts.map +1 -1
- package/lib/types/src/api/device-action/__test-utils__/setupTestMachine.d.ts.map +1 -1
- package/lib/types/src/api/device-action/model/UserInteractionRequired.d.ts +4 -1
- package/lib/types/src/api/device-action/model/UserInteractionRequired.d.ts.map +1 -1
- package/lib/types/src/api/device-action/os/CallTaskInAppDeviceAction/CallTaskInAppDeviceAction.d.ts.map +1 -1
- package/lib/types/src/api/device-action/os/CallTaskInAppDeviceAction/CallTaskInAppDeviceActionTypes.d.ts +9 -1
- package/lib/types/src/api/device-action/os/CallTaskInAppDeviceAction/CallTaskInAppDeviceActionTypes.d.ts.map +1 -1
- package/lib/types/src/api/device-action/os/GetDeviceMetadata/GetDeviceMetadataDeviceAction.d.ts.map +1 -1
- package/lib/types/src/api/device-action/os/GetDeviceMetadata/types.d.ts +13 -2
- package/lib/types/src/api/device-action/os/GetDeviceMetadata/types.d.ts.map +1 -1
- package/lib/types/src/api/device-action/os/GetDeviceStatus/GetDeviceStatusDeviceAction.d.ts.map +1 -1
- package/lib/types/src/api/device-action/os/GetDeviceStatus/types.d.ts +6 -0
- package/lib/types/src/api/device-action/os/GetDeviceStatus/types.d.ts.map +1 -1
- package/lib/types/src/api/device-action/os/GoToDashboard/GoToDashboardDeviceAction.d.ts +1 -1
- package/lib/types/src/api/device-action/os/GoToDashboard/GoToDashboardDeviceAction.d.ts.map +1 -1
- package/lib/types/src/api/device-action/os/GoToDashboard/types.d.ts +9 -1
- package/lib/types/src/api/device-action/os/GoToDashboard/types.d.ts.map +1 -1
- package/lib/types/src/api/device-action/os/InstallOrUpdateApps/InstallOrUpdateAppsDeviceAction.d.ts.map +1 -1
- package/lib/types/src/api/device-action/os/InstallOrUpdateApps/types.d.ts +9 -1
- package/lib/types/src/api/device-action/os/InstallOrUpdateApps/types.d.ts.map +1 -1
- package/lib/types/src/api/device-action/os/ListApps/ListAppsDeviceAction.d.ts.map +1 -1
- package/lib/types/src/api/device-action/os/ListApps/types.d.ts +6 -0
- package/lib/types/src/api/device-action/os/ListApps/types.d.ts.map +1 -1
- package/lib/types/src/api/device-action/os/ListAppsWithMetadata/ListAppsWithMetadataDeviceAction.d.ts.map +1 -1
- package/lib/types/src/api/device-action/os/ListAppsWithMetadata/types.d.ts +8 -1
- package/lib/types/src/api/device-action/os/ListAppsWithMetadata/types.d.ts.map +1 -1
- package/lib/types/src/api/device-action/os/OpenAppDeviceAction/OpenAppDeviceAction.d.ts.map +1 -1
- package/lib/types/src/api/device-action/os/OpenAppDeviceAction/types.d.ts +12 -2
- package/lib/types/src/api/device-action/os/OpenAppDeviceAction/types.d.ts.map +1 -1
- package/lib/types/src/api/device-action/os/OpenAppWithDependencies/OpenAppWithDependenciesDeviceAction.d.ts.map +1 -1
- package/lib/types/src/api/device-action/os/OpenAppWithDependencies/types.d.ts +8 -0
- package/lib/types/src/api/device-action/os/OpenAppWithDependencies/types.d.ts.map +1 -1
- package/lib/types/src/api/device-action/os/SendCommandInAppDeviceAction/SendCommandInAppDeviceAction.d.ts.map +1 -1
- package/lib/types/src/api/device-action/os/SendCommandInAppDeviceAction/SendCommandInAppDeviceActionTypes.d.ts +9 -1
- package/lib/types/src/api/device-action/os/SendCommandInAppDeviceAction/SendCommandInAppDeviceActionTypes.d.ts.map +1 -1
- package/lib/types/src/api/device-action/xstate-utils/XStateDeviceAction.d.ts +10 -1
- package/lib/types/src/api/device-action/xstate-utils/XStateDeviceAction.d.ts.map +1 -1
- package/lib/types/src/api/index.d.ts +11 -4
- package/lib/types/src/api/index.d.ts.map +1 -1
- package/lib/types/src/api/logger-publisher/utils/noopLoggerFactory.d.ts +12 -0
- package/lib/types/src/api/logger-publisher/utils/noopLoggerFactory.d.ts.map +1 -0
- package/lib/types/src/api/logger-publisher/utils/noopLoggerFactory.test.d.ts +2 -0
- package/lib/types/src/api/logger-publisher/utils/noopLoggerFactory.test.d.ts.map +1 -0
- package/lib/types/src/api/secure-channel/task/ConnectToSecureChannelTask.d.ts.map +1 -1
- package/lib/types/src/api/transport/model/DeviceConnectionStateMachine.d.ts +1 -0
- package/lib/types/src/api/transport/model/DeviceConnectionStateMachine.d.ts.map +1 -1
- package/lib/types/src/api/transport/model/Errors.d.ts +5 -0
- package/lib/types/src/api/transport/model/Errors.d.ts.map +1 -1
- package/lib/types/src/api/types.d.ts +1 -0
- package/lib/types/src/api/types.d.ts.map +1 -1
- package/lib/types/src/api/utils/ApplicationChecker.d.ts +14 -0
- package/lib/types/src/api/utils/ApplicationChecker.d.ts.map +1 -0
- package/lib/types/src/api/utils/ApplicationChecker.test.d.ts +2 -0
- package/lib/types/src/api/utils/ApplicationChecker.test.d.ts.map +1 -0
- package/lib/types/src/api/utils/ApplicationResolver.d.ts +12 -0
- package/lib/types/src/api/utils/ApplicationResolver.d.ts.map +1 -0
- package/lib/types/src/api/utils/Base64String.d.ts +1 -0
- package/lib/types/src/api/utils/Base64String.d.ts.map +1 -1
- package/lib/types/src/internal/device-session/di/deviceSessionModule.d.ts.map +1 -1
- package/lib/types/src/internal/device-session/di/deviceSessionTypes.d.ts +1 -0
- package/lib/types/src/internal/device-session/di/deviceSessionTypes.d.ts.map +1 -1
- package/lib/types/src/internal/device-session/model/DeviceSession.d.ts +13 -2
- package/lib/types/src/internal/device-session/model/DeviceSession.d.ts.map +1 -1
- package/lib/types/src/internal/device-session/model/DeviceSessionEventDispatcher.d.ts +3 -1
- package/lib/types/src/internal/device-session/model/DeviceSessionEventDispatcher.d.ts.map +1 -1
- package/lib/types/src/internal/device-session/model/DeviceSessionRefresher.d.ts +0 -1
- package/lib/types/src/internal/device-session/model/DeviceSessionRefresher.d.ts.map +1 -1
- package/lib/types/src/internal/device-session/model/DeviceSessionStateHandler.d.ts +1 -0
- package/lib/types/src/internal/device-session/model/DeviceSessionStateHandler.d.ts.map +1 -1
- package/lib/types/src/internal/device-session/service/IntentQueueService.d.ts +101 -0
- package/lib/types/src/internal/device-session/service/IntentQueueService.d.ts.map +1 -0
- package/lib/types/src/internal/device-session/service/IntentQueueService.test.d.ts +2 -0
- package/lib/types/src/internal/device-session/service/IntentQueueService.test.d.ts.map +1 -0
- package/lib/types/src/internal/device-session/use-case/UnsafeBypassIntentQueueUseCase.d.ts +19 -0
- package/lib/types/src/internal/device-session/use-case/UnsafeBypassIntentQueueUseCase.d.ts.map +1 -0
- package/lib/types/tsconfig.prod.tsbuildinfo +1 -1
- package/package.json +4 -4
- package/lib/cjs/src/api/command/os/GetCustomImageSizeCommand.js +0 -2
- package/lib/cjs/src/api/command/os/GetCustomImageSizeCommand.js.map +0 -7
- package/lib/cjs/src/api/command/os/GetCustomImageSizeCommand.test.js +0 -2
- package/lib/cjs/src/api/command/os/GetCustomImageSizeCommand.test.js.map +0 -7
- package/lib/cjs/src/internal/device-session/service/MutexService.js +0 -2
- package/lib/cjs/src/internal/device-session/service/MutexService.js.map +0 -7
- package/lib/cjs/src/internal/device-session/service/MutexService.test.js +0 -2
- package/lib/cjs/src/internal/device-session/service/MutexService.test.js.map +0 -7
- package/lib/esm/src/api/command/os/GetCustomImageSizeCommand.js +0 -2
- package/lib/esm/src/api/command/os/GetCustomImageSizeCommand.js.map +0 -7
- package/lib/esm/src/api/command/os/GetCustomImageSizeCommand.test.js +0 -2
- package/lib/esm/src/api/command/os/GetCustomImageSizeCommand.test.js.map +0 -7
- package/lib/esm/src/internal/device-session/service/MutexService.js +0 -2
- package/lib/esm/src/internal/device-session/service/MutexService.js.map +0 -7
- package/lib/esm/src/internal/device-session/service/MutexService.test.js +0 -2
- package/lib/esm/src/internal/device-session/service/MutexService.test.js.map +0 -7
- package/lib/types/src/api/command/os/GetCustomImageSizeCommand.d.ts +0 -17
- package/lib/types/src/api/command/os/GetCustomImageSizeCommand.d.ts.map +0 -1
- package/lib/types/src/api/command/os/GetCustomImageSizeCommand.test.d.ts +0 -2
- package/lib/types/src/api/command/os/GetCustomImageSizeCommand.test.d.ts.map +0 -1
- package/lib/types/src/internal/device-session/service/MutexService.d.ts +0 -6
- package/lib/types/src/internal/device-session/service/MutexService.d.ts.map +0 -1
- package/lib/types/src/internal/device-session/service/MutexService.test.d.ts +0 -2
- package/lib/types/src/internal/device-session/service/MutexService.test.d.ts.map +0 -1
package/README.md
CHANGED
|
@@ -21,6 +21,9 @@
|
|
|
21
21
|
- [Executing a device action](#executing-a-device-action)
|
|
22
22
|
- [Open App Device Action](#open-app-device-action)
|
|
23
23
|
- [Example in React](#example-in-react)
|
|
24
|
+
- [Developer tools](#developer-tools)
|
|
25
|
+
- [Web, Node.js or Electron app](#web-nodejs-or-electron-app)
|
|
26
|
+
- [React Native app (with Rozenite)](#react-native-app-with-rozenite)
|
|
24
27
|
|
|
25
28
|
## Description
|
|
26
29
|
|
|
@@ -372,12 +375,19 @@ Check [the sample app](https://github.com/LedgerHQ/device-sdk-ts/tree/develop/ap
|
|
|
372
375
|
|
|
373
376
|
## Developer tools
|
|
374
377
|
|
|
375
|
-
|
|
376
|
-
For now they allow to view logs from the Device Management Kit. They will have more advanced features soon.
|
|
378
|
+
Developer tools are available to help debug your DMK integration:
|
|
377
379
|
|
|
378
|
-
|
|
380
|
+
- **Real-time logging** — View DMK logs with filtering by level and tag
|
|
381
|
+
- **Device session inspector** — Monitor connected devices and their states
|
|
382
|
+
- **Device discovery** — Discover and connect to devices from the dashboard
|
|
383
|
+
- **APDU sender** — Send raw APDU commands to devices
|
|
384
|
+
- **DMK configuration** — View and modify settings like the My Ledger API provider
|
|
379
385
|
|
|
380
|
-
|
|
386
|
+
### Web, Node.js or Electron app
|
|
387
|
+
|
|
388
|
+
For web apps, Node.js apps, Electron apps, or any JavaScript runtime with WebSocket support (including React Native), use the WebSocket-based devtools with the Electron dashboard app.
|
|
389
|
+
|
|
390
|
+
> **React Native users:** This setup also works for React Native apps. However, if you have [Rozenite](https://www.rozenite.dev/) set up in your app, we recommend the [Rozenite-based devtools](#react-native-app-with-rozenite) instead — it provides a more integrated experience directly within the React Native DevTools, with less setup required.
|
|
381
391
|
|
|
382
392
|
#### Set up
|
|
383
393
|
|
|
@@ -388,24 +398,33 @@ Install those packages:
|
|
|
388
398
|
- `@ledgerhq/device-management-kit-devtools-websocket-connector`
|
|
389
399
|
|
|
390
400
|
```ts
|
|
391
|
-
import {
|
|
401
|
+
import {
|
|
402
|
+
DevToolsLogger,
|
|
403
|
+
DevToolsDmkInspector,
|
|
404
|
+
} from "@ledgerhq/device-management-kit-devtools-core";
|
|
392
405
|
import { DEFAULT_CLIENT_WS_URL } from "@ledgerhq/device-management-kit-devtools-websocket-common";
|
|
393
|
-
import {
|
|
406
|
+
import { DevToolsWebSocketConnector } from "@ledgerhq/device-management-kit-devtools-websocket-connector";
|
|
394
407
|
|
|
395
|
-
//
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
url: DEFAULT_CLIENT_WS_URL,
|
|
400
|
-
});
|
|
401
|
-
return new DevToolsLogger(devToolsWebSocketConnector);
|
|
402
|
-
}
|
|
408
|
+
// Create the connector (shared between logger and inspector)
|
|
409
|
+
const connector = DevToolsWebSocketConnector.getInstance().connect({
|
|
410
|
+
url: DEFAULT_CLIENT_WS_URL,
|
|
411
|
+
});
|
|
403
412
|
|
|
404
|
-
//
|
|
405
|
-
new
|
|
413
|
+
// Create the logger (before DMK is built)
|
|
414
|
+
const devToolsLogger = new DevToolsLogger(connector);
|
|
415
|
+
|
|
416
|
+
// Build the DMK with the logger
|
|
417
|
+
const dmk = new DeviceManagementKitBuilder()
|
|
406
418
|
//...
|
|
407
|
-
.addLogger(
|
|
419
|
+
.addLogger(devToolsLogger)
|
|
408
420
|
.build();
|
|
421
|
+
|
|
422
|
+
// Optional: Enable inspector for device sessions and DMK interaction
|
|
423
|
+
// This must be done AFTER the DMK is built
|
|
424
|
+
const inspector = new DevToolsDmkInspector(connector, dmk);
|
|
425
|
+
|
|
426
|
+
// Clean up when done (e.g., on app unmount)
|
|
427
|
+
// inspector.destroy();
|
|
409
428
|
```
|
|
410
429
|
|
|
411
430
|
#### Usage
|
|
@@ -427,24 +446,40 @@ Install those packages:
|
|
|
427
446
|
- `@ledgerhq/device-management-kit-devtools-rozenite`
|
|
428
447
|
|
|
429
448
|
```ts
|
|
430
|
-
import {
|
|
431
|
-
|
|
449
|
+
import {
|
|
450
|
+
DevToolsLogger,
|
|
451
|
+
DevToolsDmkInspector,
|
|
452
|
+
} from "@ledgerhq/device-management-kit-devtools-core";
|
|
453
|
+
import {
|
|
454
|
+
RozeniteConnector,
|
|
455
|
+
useRozeniteConnector,
|
|
456
|
+
} from "@ledgerhq/device-management-kit-devtools-rozenite";
|
|
432
457
|
|
|
433
|
-
//
|
|
434
|
-
|
|
435
|
-
const connector = RozeniteConnector.getInstance();
|
|
436
|
-
return new DevToolsLogger(connector);
|
|
437
|
-
}
|
|
458
|
+
// Create the connector (shared between logger and inspector)
|
|
459
|
+
const connector = RozeniteConnector.getInstance();
|
|
438
460
|
|
|
439
|
-
//
|
|
440
|
-
new
|
|
461
|
+
// Create the logger (before DMK is built)
|
|
462
|
+
const devToolsLogger = new DevToolsLogger(connector);
|
|
463
|
+
|
|
464
|
+
// Build the DMK with the logger
|
|
465
|
+
const dmk = new DeviceManagementKitBuilder()
|
|
441
466
|
//...
|
|
442
|
-
.addLogger(
|
|
467
|
+
.addLogger(devToolsLogger)
|
|
443
468
|
.build();
|
|
469
|
+
|
|
470
|
+
// Optional: Enable inspector for device sessions and DMK interaction
|
|
471
|
+
// This must be done AFTER the DMK is built
|
|
472
|
+
const inspector = new DevToolsDmkInspector(connector, dmk);
|
|
473
|
+
|
|
474
|
+
// Clean up when done (e.g., on app unmount)
|
|
475
|
+
// inspector.destroy();
|
|
476
|
+
|
|
477
|
+
// At the root of your React app, call this hook to initialise the connection
|
|
478
|
+
useRozeniteConnector();
|
|
444
479
|
```
|
|
445
480
|
|
|
446
481
|
#### Usage
|
|
447
482
|
|
|
448
483
|
1. Run your React Native app
|
|
449
484
|
2. [Open the React Native DevTools](https://reactnative.dev/docs/react-native-devtools)
|
|
450
|
-
3. Navigate to the DMK
|
|
485
|
+
3. Navigate to the DMK DevTools tab
|
package/lib/cjs/package.json
CHANGED
|
@@ -64,5 +64,5 @@
|
|
|
64
64
|
"watch:builds": "pnpm ldmk-tool watch --entryPoints index.ts,src/**/*.ts --tsconfig tsconfig.prod.json",
|
|
65
65
|
"watch:types": "concurrently \"tsc --watch -p tsconfig.prod.json\" \"tsc-alias --watch -p tsconfig.prod.json\""
|
|
66
66
|
},
|
|
67
|
-
"version": "1.0
|
|
67
|
+
"version": "1.2.0"
|
|
68
68
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";var
|
|
1
|
+
"use strict";var a=Object.defineProperty;var g=Object.getOwnPropertyDescriptor;var U=Object.getOwnPropertyNames;var y=Object.prototype.hasOwnProperty;var S=(t,e)=>{for(var n in e)a(t,n,{get:e[n],enumerable:!0})},A=(t,e,n,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of U(e))!y.call(t,r)&&r!==n&&a(t,r,{get:()=>e[r],enumerable:!(i=g(e,r))||i.enumerable});return t};var f=t=>A(a({},"__esModule",{value:!0}),t);var h={};S(h,{DeviceManagementKit:()=>l});module.exports=f(h);var p=require("./command/di/commandTypes"),m=require("../internal/config/di/configTypes"),o=require("../internal/device-session/di/deviceSessionTypes"),s=require("../internal/discovery/di/discoveryTypes"),C=require("../internal/logger-publisher/di/loggerTypes"),c=require("../internal/manager-api/di/managerApiTypes"),v=require("../internal/send/di/sendTypes"),u=require("../internal/transport/di/transportDiTypes"),d=require("../../src/di"),D=require("./device-action/di/deviceActionTypes");class l{container;constructor({stub:e,transports:n,loggers:i,config:r}={}){this.container=(0,d.makeContainer)({stub:e,transports:n,loggers:i,config:r})}getVersion(){return this.container.get(m.configTypes.GetDmkVersionUseCase).getDmkVersion()}startDiscovering(e){return this.container.get(s.discoveryTypes.StartDiscoveringUseCase).execute(e)}stopDiscovering(){return this.container.get(s.discoveryTypes.StopDiscoveringUseCase).execute()}listenToAvailableDevices(e){return this.container.get(s.discoveryTypes.ListenToAvailableDevicesUseCase).execute(e)}async reconnect(e){return this.container.get(s.discoveryTypes.ReconnectUseCase).execute(e)}connect(e){return this.container.get(s.discoveryTypes.ConnectUseCase).execute(e)}disconnect(e){return this.container.get(s.discoveryTypes.DisconnectUseCase).execute(e)}sendApdu(e){return this.container.get(v.sendTypes.SendApduUseCase).execute(e)}sendCommand(e){return this.container.get(p.commandTypes.SendCommandUseCase).execute(e)}executeDeviceAction(e){return this.container.get(D.deviceActionTypes.ExecuteDeviceActionUseCase).execute(e)}getConnectedDevice(e){return this.container.get(s.discoveryTypes.GetConnectedDeviceUseCase).execute(e)}getDeviceSessionState(e){return this.container.get(o.deviceSessionTypes.GetDeviceSessionStateUseCase).execute(e)}close(){return this.container.get(o.deviceSessionTypes.CloseSessionsUseCase).execute()}listConnectedDevices(){return this.container.get(s.discoveryTypes.ListConnectedDevicesUseCase).execute()}listenToConnectedDevice(){return this.container.get(s.discoveryTypes.ListenToConnectedDeviceUseCase).execute()}disableDeviceSessionRefresher(e){return this.container.get(o.deviceSessionTypes.DisableDeviceSessionRefresherUseCase).execute(e)}_unsafeBypassIntentQueue(e){return this.container.get(o.deviceSessionTypes.UnsafeBypassIntentQueueUseCase).execute(e)}setProvider(e){return this.container.get(c.managerApiTypes.SetProviderUseCase).execute(e)}getProvider(){return this.container.get(c.managerApiTypes.ManagerApiDataSource).getProvider()}isEnvironmentSupported(){return this.container.get(u.transportDiTypes.TransportService).getAllTransports().some(e=>e.isSupported())}getLoggerFactory(){return this.container.get(C.loggerTypes.LoggerPublisherServiceFactory)}}0&&(module.exports={DeviceManagementKit});
|
|
2
2
|
//# sourceMappingURL=DeviceManagementKit.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../src/api/DeviceManagementKit.ts"],
|
|
4
|
-
"sourcesContent": ["import { type Container, type Factory } from \"inversify\";\nimport { type Observable } from \"rxjs\";\n\nimport { commandTypes } from \"@api/command/di/commandTypes\";\nimport { type CommandResult } from \"@api/command/model/CommandResult\";\nimport {\n type SendCommandUseCase,\n type SendCommandUseCaseArgs,\n} from \"@api/command/use-case/SendCommandUseCase\";\nimport {\n type ExecuteDeviceActionUseCase,\n type ExecuteDeviceActionUseCaseArgs,\n} from \"@api/device-action/use-case/ExecuteDeviceActionUseCase\";\nimport { type ApduResponse } from \"@api/device-session/ApduResponse\";\nimport { type DeviceSessionState } from \"@api/device-session/DeviceSessionState\";\nimport { type DeviceSessionId } from \"@api/device-session/types\";\nimport { type ConnectedDevice } from \"@api/transport/model/ConnectedDevice\";\nimport {\n type ConnectUseCaseArgs,\n type DisconnectUseCaseArgs,\n type DiscoveredDevice,\n type GetConnectedDeviceUseCaseArgs,\n type LoggerPublisherService,\n type SendApduUseCaseArgs,\n type StartDiscoveringUseCaseArgs,\n} from \"@api/types\";\nimport { configTypes } from \"@internal/config/di/configTypes\";\nimport { type GetDmkVersionUseCase } from \"@internal/config/use-case/GetDmkVersionUseCase\";\nimport { deviceSessionTypes } from \"@internal/device-session/di/deviceSessionTypes\";\nimport { type CloseSessionsUseCase } from \"@internal/device-session/use-case/CloseSessionsUseCase\";\nimport { type GetDeviceSessionStateUseCase } from \"@internal/device-session/use-case/GetDeviceSessionStateUseCase\";\nimport { discoveryTypes } from \"@internal/discovery/di/discoveryTypes\";\nimport { type ConnectUseCase } from \"@internal/discovery/use-case/ConnectUseCase\";\nimport { type DisconnectUseCase } from \"@internal/discovery/use-case/DisconnectUseCase\";\nimport { type GetConnectedDeviceUseCase } from \"@internal/discovery/use-case/GetConnectedDeviceUseCase\";\nimport { type ListConnectedDevicesUseCase } from \"@internal/discovery/use-case/ListConnectedDevicesUseCase\";\nimport {\n type ListenToAvailableDevicesUseCase,\n type ListenToAvailableDevicesUseCaseArgs,\n} from \"@internal/discovery/use-case/ListenToAvailableDevicesUseCase\";\nimport { type ListenToConnectedDeviceUseCase } from \"@internal/discovery/use-case/ListenToConnectedDeviceUseCase\";\nimport {\n type ReconnectUseCase,\n type ReconnectUseCaseArgs,\n} from \"@internal/discovery/use-case/ReconnectUseCase\";\nimport type { StartDiscoveringUseCase } from \"@internal/discovery/use-case/StartDiscoveringUseCase\";\nimport type { StopDiscoveringUseCase } from \"@internal/discovery/use-case/StopDiscoveringUseCase\";\nimport { loggerTypes } from \"@internal/logger-publisher/di/loggerTypes\";\nimport { type ManagerApiDataSource } from \"@internal/manager-api/data/ManagerApiDataSource\";\nimport { managerApiTypes } from \"@internal/manager-api/di/managerApiTypes\";\nimport { type SetProviderUseCase } from \"@internal/manager-api/use-case/SetProviderUseCase\";\nimport { sendTypes } from \"@internal/send/di/sendTypes\";\nimport { type SendApduUseCase } from \"@internal/send/use-case/SendApduUseCase\";\nimport { transportDiTypes } from \"@internal/transport/di/transportDiTypes\";\nimport { type TransportService } from \"@internal/transport/service/TransportService\";\nimport { makeContainer, type MakeContainerProps } from \"@root/src/di\";\n\nimport {\n type DeviceActionIntermediateValue,\n type ExecuteDeviceActionReturnType,\n} from \"./device-action/DeviceAction\";\nimport { deviceActionTypes } from \"./device-action/di/deviceActionTypes\";\nimport { type DisableDeviceSessionRefresherUseCase } from \"./device-session/use-case/DisableDeviceSessionRefresher\";\nimport { type DmkError } from \"./Error\";\n\n/**\n * The main class to interact with the Device Management Kit.\n *\n * NB: do not instantiate this class directly, instead, use `LedgerDMKBuilder`.\n */\nexport class DeviceManagementKit {\n readonly container: Container;\n /** @internal */\n constructor({\n stub,\n transports,\n loggers,\n config,\n }: Partial<MakeContainerProps> = {}) {\n // NOTE: MakeContainerProps might not be the exact type here\n // For the init of the project this is sufficient, but we might need to\n // update the constructor arguments as we go (we might have more than just the container config)\n this.container = makeContainer({\n stub,\n transports,\n loggers,\n config,\n });\n }\n\n /**\n * Returns a promise resolving to the version of the SDK.\n */\n getVersion(): Promise<string> {\n return this.container\n .get<GetDmkVersionUseCase>(configTypes.GetDmkVersionUseCase)\n .getDmkVersion();\n }\n\n /**\n * Starts discovering devices connected.\n *\n * For the WeHID implementation, this use-case needs to be called as a result\n * of an user interaction (button \"click\" event for ex).\n *\n * @param {StartDiscoveringUseCaseArgs} args - The transport to use for discover, or undefined to discover from all transports.\n * @returns {Observable<DiscoveredDevice>} An observable of discovered devices.\n */\n startDiscovering(\n args: StartDiscoveringUseCaseArgs,\n ): Observable<DiscoveredDevice> {\n return this.container\n .get<StartDiscoveringUseCase>(discoveryTypes.StartDiscoveringUseCase)\n .execute(args);\n }\n\n /**\n * Stops discovering devices connected.\n */\n stopDiscovering() {\n return this.container\n .get<StopDiscoveringUseCase>(discoveryTypes.StopDiscoveringUseCase)\n .execute();\n }\n\n /**\n * Listen to list of known discovered devices (and later BLE).\n * @param {ListenToAvailableDevicesUseCaseArgs} args - The transport to use for discover, or undefined to discover from all transports.\n * @returns {Observable<DiscoveredDevice[]>} An observable of known discovered devices.\n */\n listenToAvailableDevices(\n args: ListenToAvailableDevicesUseCaseArgs,\n ): Observable<DiscoveredDevice[]> {\n return this.container\n .get<ListenToAvailableDevicesUseCase>(\n discoveryTypes.ListenToAvailableDevicesUseCase,\n )\n .execute(args);\n }\n\n /**\n * Reconnects a device session by disconnecting and reconnecting to the device.\n *\n * @param args - The arguments for reconnecting the device session.\n * - `device`: The connected device.\n * - `sessionRefresherOptions` (optional): Configuration for session refreshing.\n * - `isRefresherDisabled`: Whether the refresher is disabled.\n * - `pollingInterval`: The refresh interval in milliseconds\n * @returns The session ID to use for further communication with the device.\n */\n async reconnect(args: ReconnectUseCaseArgs): Promise<DeviceSessionId> {\n return this.container\n .get<ReconnectUseCase>(discoveryTypes.ReconnectUseCase)\n .execute(args);\n }\n\n /**\n * Connects to a device previously discovered with `DeviceManagementKit.startDiscovering`.\n * Creates a new device session which:\n * - Represents the connection to the device.\n * - Is terminated upon disconnection of the device.\n * - Exposes the device state through an observable (see `DeviceManagementKit.getDeviceSessionState`)\n * - Should be used for all subsequent communication with the device.\n *\n * @param {ConnectUseCaseArgs} args - The arguments for connecting to the device.\n * - `device`: The discovered device obtained from `StartDiscoveringUseCase`.\n * - `sessionRefresherOptions` (optional): Configuration for session refreshing.\n * - `isRefresherDisabled`: Whether the refresher is disabled.\n * - `pollingInterval`: The refresh interval in milliseconds\n * @returns The session ID to use for further communication with the device.\n */\n connect(args: ConnectUseCaseArgs): Promise<DeviceSessionId> {\n return this.container\n .get<ConnectUseCase>(discoveryTypes.ConnectUseCase)\n .execute(args);\n }\n\n /**\n * Disconnects to a discovered device.\n *\n * @param {DisconnectUseCaseArgs} args - The session ID to disconnect.\n */\n disconnect(args: DisconnectUseCaseArgs): Promise<void> {\n return this.container\n .get<DisconnectUseCase>(discoveryTypes.DisconnectUseCase)\n .execute(args);\n }\n\n /**\n * Sends an APDU command to a device through a device session.\n *\n * @param {SendApduUseCaseArgs} args - The device session ID and APDU command to send.\n */\n sendApdu(args: SendApduUseCaseArgs): Promise<ApduResponse> {\n return this.container\n .get<SendApduUseCase>(sendTypes.SendApduUseCase)\n .execute(args);\n }\n\n /**\n * Sends a command to a device through a device session.\n *\n * @param {SendCommandUseCaseArgs<Response, Args, ErrorCodes>} args - The device session ID, command, command error codes and command parameters to send.\n * @returns A promise resolving with the response from the command.\n */\n sendCommand<Response, Args, ErrorCodes>(\n args: SendCommandUseCaseArgs<Response, Args, ErrorCodes>,\n ): Promise<CommandResult<Response, ErrorCodes>> {\n return this.container\n .get<SendCommandUseCase>(commandTypes.SendCommandUseCase)\n .execute(args);\n }\n\n executeDeviceAction<\n Output,\n Input,\n Error extends DmkError,\n IntermediateValue extends DeviceActionIntermediateValue,\n >(\n args: ExecuteDeviceActionUseCaseArgs<\n Output,\n Input,\n Error,\n IntermediateValue\n >,\n ): ExecuteDeviceActionReturnType<Output, Error, IntermediateValue> {\n return this.container\n .get<ExecuteDeviceActionUseCase>(\n deviceActionTypes.ExecuteDeviceActionUseCase,\n )\n .execute(args);\n }\n\n /**\n * Gets the connected from its device session ID.\n *\n * @param {GetConnectedDeviceUseCaseArgs} args - The device session ID.\n * @returns {ConnectedDevice} The connected device.\n */\n getConnectedDevice(args: GetConnectedDeviceUseCaseArgs): ConnectedDevice {\n return this.container\n .get<GetConnectedDeviceUseCase>(discoveryTypes.GetConnectedDeviceUseCase)\n .execute(args);\n }\n\n /**\n * Gets the device state of a session.\n *\n * @param {{ sessionId: DeviceSessionId }} args - The device session ID.\n * @returns {Observable<DeviceSessionState>} An observable of the session device state.\n */\n getDeviceSessionState(args: {\n sessionId: DeviceSessionId;\n }): Observable<DeviceSessionState> {\n return this.container\n .get<GetDeviceSessionStateUseCase>(\n deviceSessionTypes.GetDeviceSessionStateUseCase,\n )\n .execute(args);\n }\n\n /**\n * Close the Device Management kit.\n *\n */\n close() {\n return this.container\n .get<CloseSessionsUseCase>(deviceSessionTypes.CloseSessionsUseCase)\n .execute();\n }\n\n /**\n * Lists all connected devices.\n *\n * @returns {ConnectedDevice[]} The list of device sessions.\n */\n listConnectedDevices(): ConnectedDevice[] {\n return this.container\n .get<ListConnectedDevicesUseCase>(\n discoveryTypes.ListConnectedDevicesUseCase,\n )\n .execute();\n }\n\n /**\n * Listen to connected device.\n *\n * @returns {Observable<ConnectedDevice>} An observable of connected device.\n */\n listenToConnectedDevice(): Observable<ConnectedDevice> {\n return this.container\n .get<ListenToConnectedDeviceUseCase>(\n discoveryTypes.ListenToConnectedDeviceUseCase,\n )\n .execute();\n }\n\n /**\n * Disable the device session refresher.\n *\n * @param {DisableDeviceSessionRefresherUseCaseArgs} args - The device session ID and a string to identify the blocker.\n * @returns {() => void} A function to reenable the device session refresher.\n */\n disableDeviceSessionRefresher(args: {\n sessionId: DeviceSessionId;\n blockerId: string;\n }): () => void {\n return this.container\n .get<DisableDeviceSessionRefresherUseCase>(\n deviceSessionTypes.DisableDeviceSessionRefresherUseCase,\n )\n .execute(args);\n }\n /**\n * Sets the provider for the manager API.\n *\n * @param {number} provider - The provider to set.\n */\n setProvider(provider: number): void {\n return this.container\n .get<SetProviderUseCase>(managerApiTypes.SetProviderUseCase)\n .execute(provider);\n }\n\n /**\n * Returns the current provider value from the manager API data source.\n */\n getProvider(): number {\n return this.container\n .get<ManagerApiDataSource>(managerApiTypes.ManagerApiDataSource)\n .getProvider();\n }\n\n /**\n * Check if the current environment is supported by any transport.\n */\n isEnvironmentSupported(): boolean {\n return this.container\n .get<TransportService>(transportDiTypes.TransportService)\n .getAllTransports()\n .some((transport) => transport.isSupported());\n }\n\n /**\n * Returns the DMK logger factory with configured logger subscribers.\n */\n getLoggerFactory(): Factory<LoggerPublisherService> {\n return this.container.get(loggerTypes.LoggerPublisherServiceFactory);\n }\n}\n"],
|
|
5
|
-
"mappings": "yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,yBAAAE,IAAA,eAAAC,EAAAH,GAGA,IAAAI,EAA6B,wCAuB7BC,EAA4B,2CAE5BC,EAAmC,
|
|
4
|
+
"sourcesContent": ["import { type Container, type Factory } from \"inversify\";\nimport { type Observable } from \"rxjs\";\n\nimport { commandTypes } from \"@api/command/di/commandTypes\";\nimport { type CommandResult } from \"@api/command/model/CommandResult\";\nimport {\n type SendCommandUseCase,\n type SendCommandUseCaseArgs,\n} from \"@api/command/use-case/SendCommandUseCase\";\nimport {\n type ExecuteDeviceActionUseCase,\n type ExecuteDeviceActionUseCaseArgs,\n} from \"@api/device-action/use-case/ExecuteDeviceActionUseCase\";\nimport { type ApduResponse } from \"@api/device-session/ApduResponse\";\nimport { type DeviceSessionState } from \"@api/device-session/DeviceSessionState\";\nimport { type DeviceSessionId } from \"@api/device-session/types\";\nimport { type ConnectedDevice } from \"@api/transport/model/ConnectedDevice\";\nimport {\n type ConnectUseCaseArgs,\n type DisconnectUseCaseArgs,\n type DiscoveredDevice,\n type GetConnectedDeviceUseCaseArgs,\n type LoggerPublisherService,\n type SendApduUseCaseArgs,\n type StartDiscoveringUseCaseArgs,\n} from \"@api/types\";\nimport { configTypes } from \"@internal/config/di/configTypes\";\nimport { type GetDmkVersionUseCase } from \"@internal/config/use-case/GetDmkVersionUseCase\";\nimport { deviceSessionTypes } from \"@internal/device-session/di/deviceSessionTypes\";\nimport { type CloseSessionsUseCase } from \"@internal/device-session/use-case/CloseSessionsUseCase\";\nimport { type GetDeviceSessionStateUseCase } from \"@internal/device-session/use-case/GetDeviceSessionStateUseCase\";\nimport {\n type UnsafeBypassIntentQueueUseCase,\n type UnsafeBypassIntentQueueUseCaseArgs,\n} from \"@internal/device-session/use-case/UnsafeBypassIntentQueueUseCase\";\nimport { discoveryTypes } from \"@internal/discovery/di/discoveryTypes\";\nimport { type ConnectUseCase } from \"@internal/discovery/use-case/ConnectUseCase\";\nimport { type DisconnectUseCase } from \"@internal/discovery/use-case/DisconnectUseCase\";\nimport { type GetConnectedDeviceUseCase } from \"@internal/discovery/use-case/GetConnectedDeviceUseCase\";\nimport { type ListConnectedDevicesUseCase } from \"@internal/discovery/use-case/ListConnectedDevicesUseCase\";\nimport {\n type ListenToAvailableDevicesUseCase,\n type ListenToAvailableDevicesUseCaseArgs,\n} from \"@internal/discovery/use-case/ListenToAvailableDevicesUseCase\";\nimport { type ListenToConnectedDeviceUseCase } from \"@internal/discovery/use-case/ListenToConnectedDeviceUseCase\";\nimport {\n type ReconnectUseCase,\n type ReconnectUseCaseArgs,\n} from \"@internal/discovery/use-case/ReconnectUseCase\";\nimport type { StartDiscoveringUseCase } from \"@internal/discovery/use-case/StartDiscoveringUseCase\";\nimport type { StopDiscoveringUseCase } from \"@internal/discovery/use-case/StopDiscoveringUseCase\";\nimport { loggerTypes } from \"@internal/logger-publisher/di/loggerTypes\";\nimport { type ManagerApiDataSource } from \"@internal/manager-api/data/ManagerApiDataSource\";\nimport { managerApiTypes } from \"@internal/manager-api/di/managerApiTypes\";\nimport { type SetProviderUseCase } from \"@internal/manager-api/use-case/SetProviderUseCase\";\nimport { sendTypes } from \"@internal/send/di/sendTypes\";\nimport { type SendApduUseCase } from \"@internal/send/use-case/SendApduUseCase\";\nimport { transportDiTypes } from \"@internal/transport/di/transportDiTypes\";\nimport { type TransportService } from \"@internal/transport/service/TransportService\";\nimport { makeContainer, type MakeContainerProps } from \"@root/src/di\";\n\nimport {\n type DeviceActionIntermediateValue,\n type ExecuteDeviceActionReturnType,\n} from \"./device-action/DeviceAction\";\nimport { deviceActionTypes } from \"./device-action/di/deviceActionTypes\";\nimport { type DisableDeviceSessionRefresherUseCase } from \"./device-session/use-case/DisableDeviceSessionRefresher\";\nimport { type DmkError } from \"./Error\";\n\n/**\n * The main class to interact with the Device Management Kit.\n *\n * NB: do not instantiate this class directly, instead, use `LedgerDMKBuilder`.\n */\nexport class DeviceManagementKit {\n readonly container: Container;\n /** @internal */\n constructor({\n stub,\n transports,\n loggers,\n config,\n }: Partial<MakeContainerProps> = {}) {\n // NOTE: MakeContainerProps might not be the exact type here\n // For the init of the project this is sufficient, but we might need to\n // update the constructor arguments as we go (we might have more than just the container config)\n this.container = makeContainer({\n stub,\n transports,\n loggers,\n config,\n });\n }\n\n /**\n * Returns a promise resolving to the version of the SDK.\n */\n getVersion(): Promise<string> {\n return this.container\n .get<GetDmkVersionUseCase>(configTypes.GetDmkVersionUseCase)\n .getDmkVersion();\n }\n\n /**\n * Starts discovering devices connected.\n *\n * For the WeHID implementation, this use-case needs to be called as a result\n * of an user interaction (button \"click\" event for ex).\n *\n * @param {StartDiscoveringUseCaseArgs} args - The transport to use for discover, or undefined to discover from all transports.\n * @returns {Observable<DiscoveredDevice>} An observable of discovered devices.\n */\n startDiscovering(\n args: StartDiscoveringUseCaseArgs,\n ): Observable<DiscoveredDevice> {\n return this.container\n .get<StartDiscoveringUseCase>(discoveryTypes.StartDiscoveringUseCase)\n .execute(args);\n }\n\n /**\n * Stops discovering devices connected.\n */\n stopDiscovering() {\n return this.container\n .get<StopDiscoveringUseCase>(discoveryTypes.StopDiscoveringUseCase)\n .execute();\n }\n\n /**\n * Listen to list of known discovered devices (and later BLE).\n * @param {ListenToAvailableDevicesUseCaseArgs} args - The transport to use for discover, or undefined to discover from all transports.\n * @returns {Observable<DiscoveredDevice[]>} An observable of known discovered devices.\n */\n listenToAvailableDevices(\n args: ListenToAvailableDevicesUseCaseArgs,\n ): Observable<DiscoveredDevice[]> {\n return this.container\n .get<ListenToAvailableDevicesUseCase>(\n discoveryTypes.ListenToAvailableDevicesUseCase,\n )\n .execute(args);\n }\n\n /**\n * Reconnects a device session by disconnecting and reconnecting to the device.\n *\n * @param args - The arguments for reconnecting the device session.\n * - `device`: The connected device.\n * - `sessionRefresherOptions` (optional): Configuration for session refreshing.\n * - `isRefresherDisabled`: Whether the refresher is disabled.\n * - `pollingInterval`: The refresh interval in milliseconds\n * @returns The session ID to use for further communication with the device.\n */\n async reconnect(args: ReconnectUseCaseArgs): Promise<DeviceSessionId> {\n return this.container\n .get<ReconnectUseCase>(discoveryTypes.ReconnectUseCase)\n .execute(args);\n }\n\n /**\n * Connects to a device previously discovered with `DeviceManagementKit.startDiscovering`.\n * Creates a new device session which:\n * - Represents the connection to the device.\n * - Is terminated upon disconnection of the device.\n * - Exposes the device state through an observable (see `DeviceManagementKit.getDeviceSessionState`)\n * - Should be used for all subsequent communication with the device.\n *\n * @param {ConnectUseCaseArgs} args - The arguments for connecting to the device.\n * - `device`: The discovered device obtained from `StartDiscoveringUseCase`.\n * - `sessionRefresherOptions` (optional): Configuration for session refreshing.\n * - `isRefresherDisabled`: Whether the refresher is disabled.\n * - `pollingInterval`: The refresh interval in milliseconds\n * @returns The session ID to use for further communication with the device.\n */\n connect(args: ConnectUseCaseArgs): Promise<DeviceSessionId> {\n return this.container\n .get<ConnectUseCase>(discoveryTypes.ConnectUseCase)\n .execute(args);\n }\n\n /**\n * Disconnects to a discovered device.\n *\n * @param {DisconnectUseCaseArgs} args - The session ID to disconnect.\n */\n disconnect(args: DisconnectUseCaseArgs): Promise<void> {\n return this.container\n .get<DisconnectUseCase>(discoveryTypes.DisconnectUseCase)\n .execute(args);\n }\n\n /**\n * Sends an APDU command to a device through a device session.\n *\n * @param {SendApduUseCaseArgs} args - The device session ID and APDU command to send.\n */\n sendApdu(args: SendApduUseCaseArgs): Promise<ApduResponse> {\n return this.container\n .get<SendApduUseCase>(sendTypes.SendApduUseCase)\n .execute(args);\n }\n\n /**\n * Sends a command to a device through a device session.\n *\n * @param {SendCommandUseCaseArgs<Response, Args, ErrorCodes>} args - The device session ID, command, command error codes and command parameters to send.\n * @returns A promise resolving with the response from the command.\n */\n sendCommand<Response, Args, ErrorCodes>(\n args: SendCommandUseCaseArgs<Response, Args, ErrorCodes>,\n ): Promise<CommandResult<Response, ErrorCodes>> {\n return this.container\n .get<SendCommandUseCase>(commandTypes.SendCommandUseCase)\n .execute(args);\n }\n\n executeDeviceAction<\n Output,\n Input,\n Error extends DmkError,\n IntermediateValue extends DeviceActionIntermediateValue,\n >(\n args: ExecuteDeviceActionUseCaseArgs<\n Output,\n Input,\n Error,\n IntermediateValue\n >,\n ): ExecuteDeviceActionReturnType<Output, Error, IntermediateValue> {\n return this.container\n .get<ExecuteDeviceActionUseCase>(\n deviceActionTypes.ExecuteDeviceActionUseCase,\n )\n .execute(args);\n }\n\n /**\n * Gets the connected from its device session ID.\n *\n * @param {GetConnectedDeviceUseCaseArgs} args - The device session ID.\n * @returns {ConnectedDevice} The connected device.\n */\n getConnectedDevice(args: GetConnectedDeviceUseCaseArgs): ConnectedDevice {\n return this.container\n .get<GetConnectedDeviceUseCase>(discoveryTypes.GetConnectedDeviceUseCase)\n .execute(args);\n }\n\n /**\n * Gets the device state of a session.\n *\n * @param {{ sessionId: DeviceSessionId }} args - The device session ID.\n * @returns {Observable<DeviceSessionState>} An observable of the session device state.\n */\n getDeviceSessionState(args: {\n sessionId: DeviceSessionId;\n }): Observable<DeviceSessionState> {\n return this.container\n .get<GetDeviceSessionStateUseCase>(\n deviceSessionTypes.GetDeviceSessionStateUseCase,\n )\n .execute(args);\n }\n\n /**\n * Close the Device Management kit.\n *\n */\n close() {\n return this.container\n .get<CloseSessionsUseCase>(deviceSessionTypes.CloseSessionsUseCase)\n .execute();\n }\n\n /**\n * Lists all connected devices.\n *\n * @returns {ConnectedDevice[]} The list of device sessions.\n */\n listConnectedDevices(): ConnectedDevice[] {\n return this.container\n .get<ListConnectedDevicesUseCase>(\n discoveryTypes.ListConnectedDevicesUseCase,\n )\n .execute();\n }\n\n /**\n * Listen to connected device.\n *\n * @returns {Observable<ConnectedDevice>} An observable of connected device.\n */\n listenToConnectedDevice(): Observable<ConnectedDevice> {\n return this.container\n .get<ListenToConnectedDeviceUseCase>(\n discoveryTypes.ListenToConnectedDeviceUseCase,\n )\n .execute();\n }\n\n /**\n * Disable the device session refresher.\n *\n * @param {DisableDeviceSessionRefresherUseCaseArgs} args - The device session ID and a string to identify the blocker.\n * @returns {() => void} A function to reenable the device session refresher.\n */\n disableDeviceSessionRefresher(args: {\n sessionId: DeviceSessionId;\n blockerId: string;\n }): () => void {\n return this.container\n .get<DisableDeviceSessionRefresherUseCase>(\n deviceSessionTypes.DisableDeviceSessionRefresherUseCase,\n )\n .execute(args);\n }\n\n /**\n * UNSAFE: Bypasses the intent queue for a device session.\n * This allows all intents (sendApdu, sendCommand, executeDeviceAction) to execute\n * directly without being queued. Use with extreme caution as this can lead to\n * race conditions and concurrent execution issues.\n *\n * @param {UnsafeBypassIntentQueueUseCaseArgs} args - The device session ID and bypass flag.\n */\n _unsafeBypassIntentQueue(args: UnsafeBypassIntentQueueUseCaseArgs): void {\n return this.container\n .get<UnsafeBypassIntentQueueUseCase>(\n deviceSessionTypes.UnsafeBypassIntentQueueUseCase,\n )\n .execute(args);\n }\n /**\n * Sets the provider for the manager API.\n *\n * @param {number} provider - The provider to set.\n */\n setProvider(provider: number): void {\n return this.container\n .get<SetProviderUseCase>(managerApiTypes.SetProviderUseCase)\n .execute(provider);\n }\n\n /**\n * Returns the current provider value from the manager API data source.\n */\n getProvider(): number {\n return this.container\n .get<ManagerApiDataSource>(managerApiTypes.ManagerApiDataSource)\n .getProvider();\n }\n\n /**\n * Check if the current environment is supported by any transport.\n */\n isEnvironmentSupported(): boolean {\n return this.container\n .get<TransportService>(transportDiTypes.TransportService)\n .getAllTransports()\n .some((transport) => transport.isSupported());\n }\n\n /**\n * Returns the DMK logger factory with configured logger subscribers.\n */\n getLoggerFactory(): Factory<LoggerPublisherService> {\n return this.container.get(loggerTypes.LoggerPublisherServiceFactory);\n }\n}\n"],
|
|
5
|
+
"mappings": "yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,yBAAAE,IAAA,eAAAC,EAAAH,GAGA,IAAAI,EAA6B,wCAuB7BC,EAA4B,2CAE5BC,EAAmC,0DAOnCC,EAA+B,iDAgB/BC,EAA4B,qDAE5BC,EAAgC,oDAEhCC,EAA0B,uCAE1BC,EAAiC,mDAEjCC,EAAuD,wBAMvDC,EAAkC,gDAS3B,MAAMX,CAAoB,CACtB,UAET,YAAY,CACV,KAAAY,EACA,WAAAC,EACA,QAAAC,EACA,OAAAC,CACF,EAAiC,CAAC,EAAG,CAInC,KAAK,aAAY,iBAAc,CAC7B,KAAAH,EACA,WAAAC,EACA,QAAAC,EACA,OAAAC,CACF,CAAC,CACH,CAKA,YAA8B,CAC5B,OAAO,KAAK,UACT,IAA0B,cAAY,oBAAoB,EAC1D,cAAc,CACnB,CAWA,iBACEC,EAC8B,CAC9B,OAAO,KAAK,UACT,IAA6B,iBAAe,uBAAuB,EACnE,QAAQA,CAAI,CACjB,CAKA,iBAAkB,CAChB,OAAO,KAAK,UACT,IAA4B,iBAAe,sBAAsB,EACjE,QAAQ,CACb,CAOA,yBACEA,EACgC,CAChC,OAAO,KAAK,UACT,IACC,iBAAe,+BACjB,EACC,QAAQA,CAAI,CACjB,CAYA,MAAM,UAAUA,EAAsD,CACpE,OAAO,KAAK,UACT,IAAsB,iBAAe,gBAAgB,EACrD,QAAQA,CAAI,CACjB,CAiBA,QAAQA,EAAoD,CAC1D,OAAO,KAAK,UACT,IAAoB,iBAAe,cAAc,EACjD,QAAQA,CAAI,CACjB,CAOA,WAAWA,EAA4C,CACrD,OAAO,KAAK,UACT,IAAuB,iBAAe,iBAAiB,EACvD,QAAQA,CAAI,CACjB,CAOA,SAASA,EAAkD,CACzD,OAAO,KAAK,UACT,IAAqB,YAAU,eAAe,EAC9C,QAAQA,CAAI,CACjB,CAQA,YACEA,EAC8C,CAC9C,OAAO,KAAK,UACT,IAAwB,eAAa,kBAAkB,EACvD,QAAQA,CAAI,CACjB,CAEA,oBAMEA,EAMiE,CACjE,OAAO,KAAK,UACT,IACC,oBAAkB,0BACpB,EACC,QAAQA,CAAI,CACjB,CAQA,mBAAmBA,EAAsD,CACvE,OAAO,KAAK,UACT,IAA+B,iBAAe,yBAAyB,EACvE,QAAQA,CAAI,CACjB,CAQA,sBAAsBA,EAEa,CACjC,OAAO,KAAK,UACT,IACC,qBAAmB,4BACrB,EACC,QAAQA,CAAI,CACjB,CAMA,OAAQ,CACN,OAAO,KAAK,UACT,IAA0B,qBAAmB,oBAAoB,EACjE,QAAQ,CACb,CAOA,sBAA0C,CACxC,OAAO,KAAK,UACT,IACC,iBAAe,2BACjB,EACC,QAAQ,CACb,CAOA,yBAAuD,CACrD,OAAO,KAAK,UACT,IACC,iBAAe,8BACjB,EACC,QAAQ,CACb,CAQA,8BAA8BA,EAGf,CACb,OAAO,KAAK,UACT,IACC,qBAAmB,oCACrB,EACC,QAAQA,CAAI,CACjB,CAUA,yBAAyBA,EAAgD,CACvE,OAAO,KAAK,UACT,IACC,qBAAmB,8BACrB,EACC,QAAQA,CAAI,CACjB,CAMA,YAAYC,EAAwB,CAClC,OAAO,KAAK,UACT,IAAwB,kBAAgB,kBAAkB,EAC1D,QAAQA,CAAQ,CACrB,CAKA,aAAsB,CACpB,OAAO,KAAK,UACT,IAA0B,kBAAgB,oBAAoB,EAC9D,YAAY,CACjB,CAKA,wBAAkC,CAChC,OAAO,KAAK,UACT,IAAsB,mBAAiB,gBAAgB,EACvD,iBAAiB,EACjB,KAAMC,GAAcA,EAAU,YAAY,CAAC,CAChD,CAKA,kBAAoD,CAClD,OAAO,KAAK,UAAU,IAAI,cAAY,6BAA6B,CACrE,CACF",
|
|
6
6
|
"names": ["DeviceManagementKit_exports", "__export", "DeviceManagementKit", "__toCommonJS", "import_commandTypes", "import_configTypes", "import_deviceSessionTypes", "import_discoveryTypes", "import_loggerTypes", "import_managerApiTypes", "import_sendTypes", "import_transportDiTypes", "import_di", "import_deviceActionTypes", "stub", "transports", "loggers", "config", "args", "provider", "transport"]
|
|
7
7
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";var i=Object.defineProperty;var s=Object.getOwnPropertyDescriptor;var p=Object.getOwnPropertyNames;var l=Object.prototype.hasOwnProperty;var A=(r,t)=>{for(var
|
|
1
|
+
"use strict";var i=Object.defineProperty;var s=Object.getOwnPropertyDescriptor;var p=Object.getOwnPropertyNames;var l=Object.prototype.hasOwnProperty;var A=(r,t)=>{for(var a in t)i(r,a,{get:t[a],enumerable:!0})},h=(r,t,a,d)=>{if(t&&typeof t=="object"||typeof t=="function")for(let e of p(t))!l.call(r,e)&&e!==a&&i(r,e,{get:()=>t[e],enumerable:!(d=s(t,e))||d.enumerable});return r};var B=r=>h(i({},"__esModule",{value:!0}),r);var f={};A(f,{APDU_MAX_PAYLOAD:()=>n,APDU_MAX_SIZE:()=>c,ApduBuilder:()=>b,HEADER_LENGTH:()=>m});module.exports=B(f);var u=require("../../apdu/model/Apdu"),o=require("./ByteArrayBuilder");const m=5,n=255,c=n+5;class b{_ins;_cla;_p1;p2;data=new o.ByteArrayBuilder(n);constructor({ins:t,cla:a,p1:d,p2:e}){this._cla=a&255,this._ins=t&255,this._p1=d&255,this.p2=e&255}build=()=>new u.Apdu(this._cla,this._ins,this._p1,this.p2,this.data.build());add8BitUIntToData=t=>(this.data.add8BitUIntToData(t),this);add16BitUIntToData=t=>(this.data.add16BitUIntToData(t),this);add32BitUIntToData=t=>(this.data.add32BitUIntToData(t),this);add64BitUIntToData=(t,a=!0)=>(this.data.add64BitUIntToData(t,a),this);addBufferToData=t=>(this.data.addBufferToData(t),this);addHexaStringToData=t=>(this.data.addHexaStringToData(t),this);addAsciiStringToData=t=>(this.data.addAsciiStringToData(t),this);encodeInLVFromHexa=t=>(this.data.encodeInLVFromHexa(t),this);encodeInLVFromBuffer=t=>(this.data.encodeInLVFromBuffer(t),this);encodeInLVFromAscii=t=>(this.data.encodeInLVFromAscii(t),this);getAvailablePayloadLength=()=>this.data.getAvailablePayloadLength();getErrors=()=>this.data.getErrors()}0&&(module.exports={APDU_MAX_PAYLOAD,APDU_MAX_SIZE,ApduBuilder,HEADER_LENGTH});
|
|
2
2
|
//# sourceMappingURL=ApduBuilder.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../../src/api/apdu/utils/ApduBuilder.ts"],
|
|
4
|
-
"sourcesContent": ["import { Apdu } from \"@api/apdu/model/Apdu\";\n\nimport { type AppBuilderError } from \"./AppBuilderError\";\nimport { ByteArrayBuilder } from \"./ByteArrayBuilder\";\n\nexport const HEADER_LENGTH = 5;\nexport const APDU_MAX_PAYLOAD = 255;\nexport const APDU_MAX_SIZE = APDU_MAX_PAYLOAD + 5;\n\nexport type ApduBuilderArgs = {\n readonly ins: number;\n readonly cla: number;\n readonly p1: number;\n readonly p2: number;\n};\n\n/**\n * ApduBuilder is a utility class to help build APDU commands.\n * It allows to easily add data to the data field of the APDU command\n * and to encode this data in different formats.\n *\n * @example\n * ```\n * const apduBuilder = new ApduBuilder({ ins: 0x01, cla: 0x02, p1: 0x03, p2: 0x04 })\n * .add8BitUIntToData(0x05)\n * .add16BitUIntToData(0x0607)\n * .addHexaStringToData(\"0x0809\")\n * .addAsciiStringToData(\"hello\")\n *\n * const apdu = apduBuilder.build();\n * const builderErrors = apduBuilder.getErrors();\n * ```\n */\nexport class ApduBuilder {\n private readonly _ins: number;\n private readonly _cla: number;\n private readonly _p1: number;\n private readonly p2: number;\n private data: ByteArrayBuilder = new ByteArrayBuilder(APDU_MAX_PAYLOAD);\n\n constructor({ ins, cla, p1, p2 }: ApduBuilderArgs) {\n this._cla = cla & 0xff;\n this._ins = ins & 0xff;\n this._p1 = p1 & 0xff;\n this.p2 = p2 & 0xff;\n }\n\n // ==========\n // Public API\n // ==========\n\n /**\n * Build a new Apdu instance with the current state of the builder\n * @returns {Apdu} - Returns a new Apdu instance\n */\n build = (): Apdu =>\n new Apdu(this._cla, this._ins, this._p1, this.p2, this.data.build());\n\n /**\n * Add a 8-bit unsigned integer to the data field (max value 0xff = 255)\n * @param value?: number - The value to add to the data\n * @returns {ApduBuilder} - Returns the current instance of ApduBuilder\n */\n add8BitUIntToData = (value: number): ApduBuilder => {\n this.data.add8BitUIntToData(value);\n return this;\n };\n\n /**\n * Add a 16-bit unsigned integer to the data field (max value 0xffff = 65535)\n * @param value: number - The value to add to the data\n * @returns {ApduBuilder} - Returns the current instance of ApduBuilder\n */\n add16BitUIntToData = (value: number): ApduBuilder => {\n this.data.add16BitUIntToData(value);\n return this;\n };\n\n /**\n * Add a 32-bit unsigned integer to the data field (max value 0xffffffff = 4294967295)\n * @param value: number - The value to add to the data\n * @returns {ApduBuilder} - Returns the current instance of ApduBuilder\n */\n add32BitUIntToData = (value: number): ApduBuilder => {\n this.data.add32BitUIntToData(value);\n return this;\n };\n\n /**\n * Add a Uint8Array to the data field if it has enough remaining space\n * @param value: Uint8Array - The value to add to the data\n * @returns {ApduBuilder} - Returns the current instance of ApduBuilder\n */\n addBufferToData = (value: Uint8Array): ApduBuilder => {\n this.data.addBufferToData(value);\n return this;\n };\n\n /**\n * Add a string to the data field if it has enough remaining space\n * and it can be formatted as a hexadecimal string\n * @param value: string - The value to add to the data\n * @returns {ApduBuilder} - Returns the current instance of ApduBuilder\n */\n addHexaStringToData = (value: string): ApduBuilder => {\n this.data.addHexaStringToData(value);\n return this;\n };\n\n /**\n * Add an ascii string to the data field if it has enough remaining space\n * @param value: string - The value to add to the data\n * @returns {ApduBuilder} - Returns the current instance of ApduBuilder\n */\n addAsciiStringToData = (value: string): ApduBuilder => {\n this.data.addAsciiStringToData(value);\n return this;\n };\n\n /**\n * Add a Length-Value encoded hexadecimal string to the data field if it has enough remaining space\n * Length-Value encoding is a way to encode data in a binary format with the first byte\n * being the length of the data and the following bytes being the data itself\n * @param value: string - The value to add to the data\n * @returns {ApduBuilder} - Returns the current instance of ApduBuilder\n */\n encodeInLVFromHexa = (value: string): ApduBuilder => {\n this.data.encodeInLVFromHexa(value);\n return this;\n };\n\n /**\n * Add a Length-Value encoded buffer to the data field if it has enough remaining space\n * Length-Value encoding is a way to encode data in a binary format with the first byte\n * being the length of the data and the following bytes being the data itself\n * @param value: Uint8Array - The value to add to the data\n * @returns {ApduBuilder} - Returns the current instance of ApduBuilder\n */\n encodeInLVFromBuffer = (value: Uint8Array): ApduBuilder => {\n this.data.encodeInLVFromBuffer(value);\n return this;\n };\n\n /**\n * Add a Length-Value encoded ascii string to the data field if it has enough remaining space\n * Length-Value encoding is a way to encode data in a binary format with the first byte\n * being the length of the data and the following bytes being the data itself\n * @param value: string - The value to add to the data\n * @returns {ApduBuilder} - Returns the current instance of ApduBuilder\n */\n encodeInLVFromAscii = (value: string): ApduBuilder => {\n this.data.encodeInLVFromAscii(value);\n return this;\n };\n\n /**\n * Returns the remaining payload length\n * @returns {number}\n */\n getAvailablePayloadLength = (): number =>\n this.data.getAvailablePayloadLength();\n\n /**\n * Returns the current errors\n * @returns {AppBuilderError[]} - Returns an array of errors\n */\n getErrors = (): AppBuilderError[] => this.data.getErrors();\n}\n"],
|
|
5
|
-
"mappings": "yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,sBAAAE,EAAA,kBAAAC,EAAA,gBAAAC,EAAA,kBAAAC,IAAA,eAAAC,EAAAN,GAAA,IAAAO,EAAqB,gCAGrBC,EAAiC,8BAE1B,MAAMH,EAAgB,EAChBH,EAAmB,IACnBC,EAAgBD,EAAmB,EA0BzC,MAAME,CAAY,CACN,KACA,KACA,IACA,GACT,KAAyB,IAAI,mBAAiBF,CAAgB,EAEtE,YAAY,CAAE,IAAAO,EAAK,IAAAC,EAAK,GAAAC,EAAI,GAAAC,CAAG,EAAoB,CACjD,KAAK,KAAOF,EAAM,IAClB,KAAK,KAAOD,EAAM,IAClB,KAAK,IAAME,EAAK,IAChB,KAAK,GAAKC,EAAK,GACjB,CAUA,MAAQ,IACN,IAAI,OAAK,KAAK,KAAM,KAAK,KAAM,KAAK,IAAK,KAAK,GAAI,KAAK,KAAK,MAAM,CAAC,EAOrE,kBAAqBC,IACnB,KAAK,KAAK,kBAAkBA,CAAK,EAC1B,MAQT,mBAAsBA,IACpB,KAAK,KAAK,mBAAmBA,CAAK,EAC3B,MAQT,mBAAsBA,IACpB,KAAK,KAAK,mBAAmBA,CAAK,EAC3B,MAQT,
|
|
6
|
-
"names": ["ApduBuilder_exports", "__export", "APDU_MAX_PAYLOAD", "APDU_MAX_SIZE", "ApduBuilder", "HEADER_LENGTH", "__toCommonJS", "import_Apdu", "import_ByteArrayBuilder", "ins", "cla", "p1", "p2", "value"]
|
|
4
|
+
"sourcesContent": ["import { Apdu } from \"@api/apdu/model/Apdu\";\n\nimport { type AppBuilderError } from \"./AppBuilderError\";\nimport { ByteArrayBuilder } from \"./ByteArrayBuilder\";\n\nexport const HEADER_LENGTH = 5;\nexport const APDU_MAX_PAYLOAD = 255;\nexport const APDU_MAX_SIZE = APDU_MAX_PAYLOAD + 5;\n\nexport type ApduBuilderArgs = {\n readonly ins: number;\n readonly cla: number;\n readonly p1: number;\n readonly p2: number;\n};\n\n/**\n * ApduBuilder is a utility class to help build APDU commands.\n * It allows to easily add data to the data field of the APDU command\n * and to encode this data in different formats.\n *\n * @example\n * ```\n * const apduBuilder = new ApduBuilder({ ins: 0x01, cla: 0x02, p1: 0x03, p2: 0x04 })\n * .add8BitUIntToData(0x05)\n * .add16BitUIntToData(0x0607)\n * .addHexaStringToData(\"0x0809\")\n * .addAsciiStringToData(\"hello\")\n *\n * const apdu = apduBuilder.build();\n * const builderErrors = apduBuilder.getErrors();\n * ```\n */\nexport class ApduBuilder {\n private readonly _ins: number;\n private readonly _cla: number;\n private readonly _p1: number;\n private readonly p2: number;\n private data: ByteArrayBuilder = new ByteArrayBuilder(APDU_MAX_PAYLOAD);\n\n constructor({ ins, cla, p1, p2 }: ApduBuilderArgs) {\n this._cla = cla & 0xff;\n this._ins = ins & 0xff;\n this._p1 = p1 & 0xff;\n this.p2 = p2 & 0xff;\n }\n\n // ==========\n // Public API\n // ==========\n\n /**\n * Build a new Apdu instance with the current state of the builder\n * @returns {Apdu} - Returns a new Apdu instance\n */\n build = (): Apdu =>\n new Apdu(this._cla, this._ins, this._p1, this.p2, this.data.build());\n\n /**\n * Add a 8-bit unsigned integer to the data field (max value 0xff = 255)\n * @param value?: number - The value to add to the data\n * @returns {ApduBuilder} - Returns the current instance of ApduBuilder\n */\n add8BitUIntToData = (value: number): ApduBuilder => {\n this.data.add8BitUIntToData(value);\n return this;\n };\n\n /**\n * Add a 16-bit unsigned integer to the data field (max value 0xffff = 65535)\n * @param value: number - The value to add to the data\n * @returns {ApduBuilder} - Returns the current instance of ApduBuilder\n */\n add16BitUIntToData = (value: number): ApduBuilder => {\n this.data.add16BitUIntToData(value);\n return this;\n };\n\n /**\n * Add a 32-bit unsigned integer to the data field (max value 0xffffffff = 4294967295)\n * @param value: number - The value to add to the data\n * @returns {ApduBuilder} - Returns the current instance of ApduBuilder\n */\n add32BitUIntToData = (value: number): ApduBuilder => {\n this.data.add32BitUIntToData(value);\n return this;\n };\n\n /**\n * Add a 64-bit unsigned integer to the data field in big-endian (max value 0xffffffffffffffff)\n * @param value: number | bigint - The value to add to the data\n * @param bigEndian: boolean - True for big-endian (default), false for little-endian\n * @returns {ApduBuilder} - Returns the current instance of ApduBuilder\n */\n add64BitUIntToData = (\n value: number | bigint,\n bigEndian: boolean = true,\n ): ApduBuilder => {\n this.data.add64BitUIntToData(value, bigEndian);\n return this;\n };\n\n /**\n * Add a Uint8Array to the data field if it has enough remaining space\n * @param value: Uint8Array - The value to add to the data\n * @returns {ApduBuilder} - Returns the current instance of ApduBuilder\n */\n addBufferToData = (value: Uint8Array): ApduBuilder => {\n this.data.addBufferToData(value);\n return this;\n };\n\n /**\n * Add a string to the data field if it has enough remaining space\n * and it can be formatted as a hexadecimal string\n * @param value: string - The value to add to the data\n * @returns {ApduBuilder} - Returns the current instance of ApduBuilder\n */\n addHexaStringToData = (value: string): ApduBuilder => {\n this.data.addHexaStringToData(value);\n return this;\n };\n\n /**\n * Add an ascii string to the data field if it has enough remaining space\n * @param value: string - The value to add to the data\n * @returns {ApduBuilder} - Returns the current instance of ApduBuilder\n */\n addAsciiStringToData = (value: string): ApduBuilder => {\n this.data.addAsciiStringToData(value);\n return this;\n };\n\n /**\n * Add a Length-Value encoded hexadecimal string to the data field if it has enough remaining space\n * Length-Value encoding is a way to encode data in a binary format with the first byte\n * being the length of the data and the following bytes being the data itself\n * @param value: string - The value to add to the data\n * @returns {ApduBuilder} - Returns the current instance of ApduBuilder\n */\n encodeInLVFromHexa = (value: string): ApduBuilder => {\n this.data.encodeInLVFromHexa(value);\n return this;\n };\n\n /**\n * Add a Length-Value encoded buffer to the data field if it has enough remaining space\n * Length-Value encoding is a way to encode data in a binary format with the first byte\n * being the length of the data and the following bytes being the data itself\n * @param value: Uint8Array - The value to add to the data\n * @returns {ApduBuilder} - Returns the current instance of ApduBuilder\n */\n encodeInLVFromBuffer = (value: Uint8Array): ApduBuilder => {\n this.data.encodeInLVFromBuffer(value);\n return this;\n };\n\n /**\n * Add a Length-Value encoded ascii string to the data field if it has enough remaining space\n * Length-Value encoding is a way to encode data in a binary format with the first byte\n * being the length of the data and the following bytes being the data itself\n * @param value: string - The value to add to the data\n * @returns {ApduBuilder} - Returns the current instance of ApduBuilder\n */\n encodeInLVFromAscii = (value: string): ApduBuilder => {\n this.data.encodeInLVFromAscii(value);\n return this;\n };\n\n /**\n * Returns the remaining payload length\n * @returns {number}\n */\n getAvailablePayloadLength = (): number =>\n this.data.getAvailablePayloadLength();\n\n /**\n * Returns the current errors\n * @returns {AppBuilderError[]} - Returns an array of errors\n */\n getErrors = (): AppBuilderError[] => this.data.getErrors();\n}\n"],
|
|
5
|
+
"mappings": "yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,sBAAAE,EAAA,kBAAAC,EAAA,gBAAAC,EAAA,kBAAAC,IAAA,eAAAC,EAAAN,GAAA,IAAAO,EAAqB,gCAGrBC,EAAiC,8BAE1B,MAAMH,EAAgB,EAChBH,EAAmB,IACnBC,EAAgBD,EAAmB,EA0BzC,MAAME,CAAY,CACN,KACA,KACA,IACA,GACT,KAAyB,IAAI,mBAAiBF,CAAgB,EAEtE,YAAY,CAAE,IAAAO,EAAK,IAAAC,EAAK,GAAAC,EAAI,GAAAC,CAAG,EAAoB,CACjD,KAAK,KAAOF,EAAM,IAClB,KAAK,KAAOD,EAAM,IAClB,KAAK,IAAME,EAAK,IAChB,KAAK,GAAKC,EAAK,GACjB,CAUA,MAAQ,IACN,IAAI,OAAK,KAAK,KAAM,KAAK,KAAM,KAAK,IAAK,KAAK,GAAI,KAAK,KAAK,MAAM,CAAC,EAOrE,kBAAqBC,IACnB,KAAK,KAAK,kBAAkBA,CAAK,EAC1B,MAQT,mBAAsBA,IACpB,KAAK,KAAK,mBAAmBA,CAAK,EAC3B,MAQT,mBAAsBA,IACpB,KAAK,KAAK,mBAAmBA,CAAK,EAC3B,MAST,mBAAqB,CACnBA,EACAC,EAAqB,MAErB,KAAK,KAAK,mBAAmBD,EAAOC,CAAS,EACtC,MAQT,gBAAmBD,IACjB,KAAK,KAAK,gBAAgBA,CAAK,EACxB,MAST,oBAAuBA,IACrB,KAAK,KAAK,oBAAoBA,CAAK,EAC5B,MAQT,qBAAwBA,IACtB,KAAK,KAAK,qBAAqBA,CAAK,EAC7B,MAUT,mBAAsBA,IACpB,KAAK,KAAK,mBAAmBA,CAAK,EAC3B,MAUT,qBAAwBA,IACtB,KAAK,KAAK,qBAAqBA,CAAK,EAC7B,MAUT,oBAAuBA,IACrB,KAAK,KAAK,oBAAoBA,CAAK,EAC5B,MAOT,0BAA4B,IAC1B,KAAK,KAAK,0BAA0B,EAMtC,UAAY,IAAyB,KAAK,KAAK,UAAU,CAC3D",
|
|
6
|
+
"names": ["ApduBuilder_exports", "__export", "APDU_MAX_PAYLOAD", "APDU_MAX_SIZE", "ApduBuilder", "HEADER_LENGTH", "__toCommonJS", "import_Apdu", "import_ByteArrayBuilder", "ins", "cla", "p1", "p2", "value", "bigEndian"]
|
|
7
7
|
}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use strict";var n=Object.defineProperty;var I=Object.getOwnPropertyDescriptor;var E=Object.getOwnPropertyNames;var S=Object.prototype.hasOwnProperty;var B=(r,e)=>{for(var o in e)n(r,o,{get:e[o],enumerable:!0})},f=(r,e,o,t)=>{if(e&&typeof e=="object"||typeof e=="function")for(let m of E(e))!S.call(r,m)&&m!==o&&n(r,m,{get:()=>e[m],enumerable:!(t=I(e,m))||t.enumerable});return r};var z=r=>f(n({},"__esModule",{value:!0}),r);var G={};B(G,{GetBackgroundImageSizeCommand:()=>k,GetBackgroundImageSizeCommandError:()=>l});module.exports=z(G);var s=require("../../apdu/utils/ApduBuilder"),i=require("../../apdu/utils/ApduParser"),g=require("../../command/Errors"),a=require("../../command/model/CommandResult"),u=require("../../command/utils/CommandErrors"),p=require("../../command/utils/CommandUtils"),c=require("../../command/utils/GlobalCommandError"),C=require("../../Error");const d={"662e":{message:"Invalid state, no background image loaded."},"662f":{message:"Invalid state, device is in recovery mode."}};class l extends C.DeviceExchangeError{constructor({message:e,errorCode:o}){super({message:e,errorCode:o,tag:"GetBackgroundImageSizeCommandError"})}}class k{name="getBackgroundImageSize";getApdu(){const e={cla:224,ins:100,p1:0,p2:0};return new s.ApduBuilder(e).build()}parseResponse(e){const o=new i.ApduParser(e);if(!p.CommandUtils.isSuccessResponse(e)){const m=o.encodeToHexaString(e.statusCode);return(0,u.isCommandErrorCode)(m,d)?(0,a.CommandResultFactory)({error:new l({...d[m],errorCode:m})}):(0,a.CommandResultFactory)({error:c.GlobalCommandErrorHandler.handle(e)})}const t=o.extract32BitUInt();return t===void 0?(0,a.CommandResultFactory)({error:new g.InvalidStatusWordError("Didn't receive any size")}):(0,a.CommandResultFactory)({data:t})}}0&&(module.exports={GetBackgroundImageSizeCommand,GetBackgroundImageSizeCommandError});
|
|
2
|
+
//# sourceMappingURL=GetBackgroundImageSizeCommand.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../../../src/api/command/os/GetBackgroundImageSizeCommand.ts"],
|
|
4
|
+
"sourcesContent": ["import { type Apdu } from \"@api/apdu/model/Apdu\";\nimport { ApduBuilder, type ApduBuilderArgs } from \"@api/apdu/utils/ApduBuilder\";\nimport { ApduParser } from \"@api/apdu/utils/ApduParser\";\nimport { type Command } from \"@api/command/Command\";\nimport { InvalidStatusWordError } from \"@api/command/Errors\";\nimport {\n type CommandResult,\n CommandResultFactory,\n} from \"@api/command/model/CommandResult\";\nimport {\n type CommandErrors,\n isCommandErrorCode,\n} from \"@api/command/utils/CommandErrors\";\nimport { CommandUtils } from \"@api/command/utils/CommandUtils\";\nimport { GlobalCommandErrorHandler } from \"@api/command/utils/GlobalCommandError\";\nimport { type ApduResponse } from \"@api/device-session/ApduResponse\";\nimport { type CommandErrorArgs, DeviceExchangeError } from \"@api/Error\";\n\nexport type GetBackgroundImageSizeResponse = number;\n\nexport type GetBackgroundImageSizeErrorCodes = \"662e\" | \"662f\";\n\nconst IMAGE_SIZE_ERRORS: CommandErrors<GetBackgroundImageSizeErrorCodes> = {\n \"662e\": { message: \"Invalid state, no background image loaded.\" },\n \"662f\": { message: \"Invalid state, device is in recovery mode.\" },\n};\n\nexport type GetBackgroundImageSizeCommandResult = CommandResult<\n GetBackgroundImageSizeResponse,\n GetBackgroundImageSizeErrorCodes\n>;\n\nexport class GetBackgroundImageSizeCommandError extends DeviceExchangeError<GetBackgroundImageSizeErrorCodes> {\n constructor({\n message,\n errorCode,\n }: CommandErrorArgs<GetBackgroundImageSizeErrorCodes>) {\n super({ message, errorCode, tag: \"GetBackgroundImageSizeCommandError\" });\n }\n}\n\nexport class GetBackgroundImageSizeCommand\n implements\n Command<\n GetBackgroundImageSizeResponse,\n void,\n GetBackgroundImageSizeErrorCodes\n >\n{\n readonly name = \"getBackgroundImageSize\";\n\n getApdu(): Apdu {\n const apduArgs: ApduBuilderArgs = {\n cla: 0xe0,\n ins: 0x64,\n p1: 0x00,\n p2: 0x00,\n };\n return new ApduBuilder(apduArgs).build();\n }\n\n parseResponse(\n apduResponse: ApduResponse,\n ): GetBackgroundImageSizeCommandResult {\n const parser = new ApduParser(apduResponse);\n\n if (!CommandUtils.isSuccessResponse(apduResponse)) {\n const errorCode = parser.encodeToHexaString(apduResponse.statusCode);\n if (isCommandErrorCode(errorCode, IMAGE_SIZE_ERRORS)) {\n return CommandResultFactory({\n error: new GetBackgroundImageSizeCommandError({\n ...IMAGE_SIZE_ERRORS[errorCode],\n errorCode,\n }),\n });\n }\n return CommandResultFactory({\n error: GlobalCommandErrorHandler.handle(apduResponse),\n });\n }\n\n const size = parser.extract32BitUInt();\n if (size === undefined) {\n return CommandResultFactory({\n error: new InvalidStatusWordError(\"Didn't receive any size\"),\n });\n }\n\n return CommandResultFactory({\n data: size,\n });\n }\n}\n"],
|
|
5
|
+
"mappings": "yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,mCAAAE,EAAA,uCAAAC,IAAA,eAAAC,EAAAJ,GACA,IAAAK,EAAkD,uCAClDC,EAA2B,sCAE3BC,EAAuC,+BACvCC,EAGO,4CACPC,EAGO,4CACPC,EAA6B,2CAC7BC,EAA0C,iDAE1CC,EAA2D,sBAM3D,MAAMC,EAAqE,CACzE,OAAQ,CAAE,QAAS,4CAA6C,EAChE,OAAQ,CAAE,QAAS,4CAA6C,CAClE,EAOO,MAAMV,UAA2C,qBAAsD,CAC5G,YAAY,CACV,QAAAW,EACA,UAAAC,CACF,EAAuD,CACrD,MAAM,CAAE,QAAAD,EAAS,UAAAC,EAAW,IAAK,oCAAqC,CAAC,CACzE,CACF,CAEO,MAAMb,CAOb,CACW,KAAO,yBAEhB,SAAgB,CACd,MAAMc,EAA4B,CAChC,IAAK,IACL,IAAK,IACL,GAAI,EACJ,GAAI,CACN,EACA,OAAO,IAAI,cAAYA,CAAQ,EAAE,MAAM,CACzC,CAEA,cACEC,EACqC,CACrC,MAAMC,EAAS,IAAI,aAAWD,CAAY,EAE1C,GAAI,CAAC,eAAa,kBAAkBA,CAAY,EAAG,CACjD,MAAMF,EAAYG,EAAO,mBAAmBD,EAAa,UAAU,EACnE,SAAI,sBAAmBF,EAAWF,CAAiB,KAC1C,wBAAqB,CAC1B,MAAO,IAAIV,EAAmC,CAC5C,GAAGU,EAAkBE,CAAS,EAC9B,UAAAA,CACF,CAAC,CACH,CAAC,KAEI,wBAAqB,CAC1B,MAAO,4BAA0B,OAAOE,CAAY,CACtD,CAAC,CACH,CAEA,MAAME,EAAOD,EAAO,iBAAiB,EACrC,OAAIC,IAAS,UACJ,wBAAqB,CAC1B,MAAO,IAAI,yBAAuB,yBAAyB,CAC7D,CAAC,KAGI,wBAAqB,CAC1B,KAAMA,CACR,CAAC,CACH,CACF",
|
|
6
|
+
"names": ["GetBackgroundImageSizeCommand_exports", "__export", "GetBackgroundImageSizeCommand", "GetBackgroundImageSizeCommandError", "__toCommonJS", "import_ApduBuilder", "import_ApduParser", "import_Errors", "import_CommandResult", "import_CommandErrors", "import_CommandUtils", "import_GlobalCommandError", "import_Error", "IMAGE_SIZE_ERRORS", "message", "errorCode", "apduArgs", "apduResponse", "parser", "size"]
|
|
7
|
+
}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use strict";var d=require("../../command/Errors"),a=require("../../command/model/CommandResult"),o=require("../../command/model/CommandResult"),n=require("../../command/os/GetBackgroundImageSizeCommand"),s=require("../../device-session/ApduResponse");const i=new Uint8Array([224,100,0,0,0]);describe("GetBackgroundImageSizeCommand",()=>{let t;beforeEach(()=>{t=new n.GetBackgroundImageSizeCommand}),describe("name",()=>{it("should be 'getBackgroundImageSize'",()=>{expect(t.name).toBe("getBackgroundImageSize")})}),it("should return the correct APDU",()=>{const r=t.getApdu();expect(r.getRawApdu()).toStrictEqual(i)}),it("should parse result successfully",()=>{const r=new s.ApduResponse({statusCode:new Uint8Array([144,0]),data:new Uint8Array([0,0,137,233])}),e=t.parseResponse(r);expect(e).toStrictEqual((0,a.CommandResultFactory)({data:35305}))}),it("should fail on invalid size",()=>{const r=new s.ApduResponse({statusCode:new Uint8Array([144,0]),data:new Uint8Array([233])}),e=t.parseResponse(r);expect(e).toStrictEqual((0,a.CommandResultFactory)({error:new d.InvalidStatusWordError("Didn't receive any size")}))}),it("should return error on no image loaded (662e)",()=>{const r=new s.ApduResponse({statusCode:new Uint8Array([102,46]),data:new Uint8Array([])}),e=t.parseResponse(r);expect((0,o.isSuccessCommandResult)(e)).toBe(!1),(0,o.isSuccessCommandResult)(e)||(expect(e.error).toBeInstanceOf(n.GetBackgroundImageSizeCommandError),expect(e.error.message).toBe("Invalid state, no background image loaded."))}),it("should return error on recovery mode (662f)",()=>{const r=new s.ApduResponse({statusCode:new Uint8Array([102,47]),data:new Uint8Array([])}),e=t.parseResponse(r);expect((0,o.isSuccessCommandResult)(e)).toBe(!1),(0,o.isSuccessCommandResult)(e)||(expect(e.error).toBeInstanceOf(n.GetBackgroundImageSizeCommandError),expect(e.error.message).toBe("Invalid state, device is in recovery mode."))}),it("should return global error on unknown status code",()=>{const r=new s.ApduResponse({statusCode:new Uint8Array([110,0]),data:new Uint8Array([])}),e=t.parseResponse(r);expect((0,o.isSuccessCommandResult)(e)).toBe(!1)})});
|
|
2
|
+
//# sourceMappingURL=GetBackgroundImageSizeCommand.test.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../../../src/api/command/os/GetBackgroundImageSizeCommand.test.ts"],
|
|
4
|
+
"sourcesContent": ["import { InvalidStatusWordError } from \"@api/command/Errors\";\nimport { CommandResultFactory } from \"@api/command/model/CommandResult\";\nimport { isSuccessCommandResult } from \"@api/command/model/CommandResult\";\nimport {\n GetBackgroundImageSizeCommand,\n GetBackgroundImageSizeCommandError,\n} from \"@api/command/os/GetBackgroundImageSizeCommand\";\nimport { ApduResponse } from \"@api/device-session/ApduResponse\";\n\nconst IMAGE_SIZE_APDU = new Uint8Array([0xe0, 0x64, 0x00, 0x00, 0x00]);\n\ndescribe(\"GetBackgroundImageSizeCommand\", () => {\n let command: GetBackgroundImageSizeCommand;\n\n beforeEach(() => {\n command = new GetBackgroundImageSizeCommand();\n });\n\n describe(\"name\", () => {\n it(\"should be 'getBackgroundImageSize'\", () => {\n expect(command.name).toBe(\"getBackgroundImageSize\");\n });\n });\n\n it(\"should return the correct APDU\", () => {\n const apdu = command.getApdu();\n expect(apdu.getRawApdu()).toStrictEqual(IMAGE_SIZE_APDU);\n });\n\n it(\"should parse result successfully\", () => {\n const response: ApduResponse = new ApduResponse({\n statusCode: new Uint8Array([0x90, 0x00]),\n data: new Uint8Array([0x00, 0x00, 0x89, 0xe9]),\n });\n const result = command.parseResponse(response);\n expect(result).toStrictEqual(\n CommandResultFactory({\n data: 35305,\n }),\n );\n });\n\n it(\"should fail on invalid size\", () => {\n const response: ApduResponse = new ApduResponse({\n statusCode: new Uint8Array([0x90, 0x00]),\n data: new Uint8Array([0xe9]),\n });\n const result = command.parseResponse(response);\n expect(result).toStrictEqual(\n CommandResultFactory({\n error: new InvalidStatusWordError(\"Didn't receive any size\"),\n }),\n );\n });\n\n it(\"should return error on no image loaded (662e)\", () => {\n const response: ApduResponse = new ApduResponse({\n statusCode: new Uint8Array([0x66, 0x2e]),\n data: new Uint8Array([]),\n });\n const result = command.parseResponse(response);\n expect(isSuccessCommandResult(result)).toBe(false);\n if (!isSuccessCommandResult(result)) {\n expect(result.error).toBeInstanceOf(GetBackgroundImageSizeCommandError);\n expect((result.error as GetBackgroundImageSizeCommandError).message).toBe(\n \"Invalid state, no background image loaded.\",\n );\n }\n });\n\n it(\"should return error on recovery mode (662f)\", () => {\n const response: ApduResponse = new ApduResponse({\n statusCode: new Uint8Array([0x66, 0x2f]),\n data: new Uint8Array([]),\n });\n const result = command.parseResponse(response);\n expect(isSuccessCommandResult(result)).toBe(false);\n if (!isSuccessCommandResult(result)) {\n expect(result.error).toBeInstanceOf(GetBackgroundImageSizeCommandError);\n expect((result.error as GetBackgroundImageSizeCommandError).message).toBe(\n \"Invalid state, device is in recovery mode.\",\n );\n }\n });\n\n it(\"should return global error on unknown status code\", () => {\n const response: ApduResponse = new ApduResponse({\n statusCode: new Uint8Array([0x6e, 0x00]),\n data: new Uint8Array([]),\n });\n const result = command.parseResponse(response);\n expect(isSuccessCommandResult(result)).toBe(false);\n });\n});\n"],
|
|
5
|
+
"mappings": "aAAA,IAAAA,EAAuC,+BACvCC,EAAqC,4CACrCA,EAAuC,4CACvCC,EAGO,yDACPC,EAA6B,4CAE7B,MAAMC,EAAkB,IAAI,WAAW,CAAC,IAAM,IAAM,EAAM,EAAM,CAAI,CAAC,EAErE,SAAS,gCAAiC,IAAM,CAC9C,IAAIC,EAEJ,WAAW,IAAM,CACfA,EAAU,IAAI,+BAChB,CAAC,EAED,SAAS,OAAQ,IAAM,CACrB,GAAG,qCAAsC,IAAM,CAC7C,OAAOA,EAAQ,IAAI,EAAE,KAAK,wBAAwB,CACpD,CAAC,CACH,CAAC,EAED,GAAG,iCAAkC,IAAM,CACzC,MAAMC,EAAOD,EAAQ,QAAQ,EAC7B,OAAOC,EAAK,WAAW,CAAC,EAAE,cAAcF,CAAe,CACzD,CAAC,EAED,GAAG,mCAAoC,IAAM,CAC3C,MAAMG,EAAyB,IAAI,eAAa,CAC9C,WAAY,IAAI,WAAW,CAAC,IAAM,CAAI,CAAC,EACvC,KAAM,IAAI,WAAW,CAAC,EAAM,EAAM,IAAM,GAAI,CAAC,CAC/C,CAAC,EACKC,EAASH,EAAQ,cAAcE,CAAQ,EAC7C,OAAOC,CAAM,EAAE,iBACb,wBAAqB,CACnB,KAAM,KACR,CAAC,CACH,CACF,CAAC,EAED,GAAG,8BAA+B,IAAM,CACtC,MAAMD,EAAyB,IAAI,eAAa,CAC9C,WAAY,IAAI,WAAW,CAAC,IAAM,CAAI,CAAC,EACvC,KAAM,IAAI,WAAW,CAAC,GAAI,CAAC,CAC7B,CAAC,EACKC,EAASH,EAAQ,cAAcE,CAAQ,EAC7C,OAAOC,CAAM,EAAE,iBACb,wBAAqB,CACnB,MAAO,IAAI,yBAAuB,yBAAyB,CAC7D,CAAC,CACH,CACF,CAAC,EAED,GAAG,gDAAiD,IAAM,CACxD,MAAMD,EAAyB,IAAI,eAAa,CAC9C,WAAY,IAAI,WAAW,CAAC,IAAM,EAAI,CAAC,EACvC,KAAM,IAAI,WAAW,CAAC,CAAC,CACzB,CAAC,EACKC,EAASH,EAAQ,cAAcE,CAAQ,EAC7C,UAAO,0BAAuBC,CAAM,CAAC,EAAE,KAAK,EAAK,KAC5C,0BAAuBA,CAAM,IAChC,OAAOA,EAAO,KAAK,EAAE,eAAe,oCAAkC,EACtE,OAAQA,EAAO,MAA6C,OAAO,EAAE,KACnE,4CACF,EAEJ,CAAC,EAED,GAAG,8CAA+C,IAAM,CACtD,MAAMD,EAAyB,IAAI,eAAa,CAC9C,WAAY,IAAI,WAAW,CAAC,IAAM,EAAI,CAAC,EACvC,KAAM,IAAI,WAAW,CAAC,CAAC,CACzB,CAAC,EACKC,EAASH,EAAQ,cAAcE,CAAQ,EAC7C,UAAO,0BAAuBC,CAAM,CAAC,EAAE,KAAK,EAAK,KAC5C,0BAAuBA,CAAM,IAChC,OAAOA,EAAO,KAAK,EAAE,eAAe,oCAAkC,EACtE,OAAQA,EAAO,MAA6C,OAAO,EAAE,KACnE,4CACF,EAEJ,CAAC,EAED,GAAG,oDAAqD,IAAM,CAC5D,MAAMD,EAAyB,IAAI,eAAa,CAC9C,WAAY,IAAI,WAAW,CAAC,IAAM,CAAI,CAAC,EACvC,KAAM,IAAI,WAAW,CAAC,CAAC,CACzB,CAAC,EACKC,EAASH,EAAQ,cAAcE,CAAQ,EAC7C,UAAO,0BAAuBC,CAAM,CAAC,EAAE,KAAK,EAAK,CACnD,CAAC,CACH,CAAC",
|
|
6
|
+
"names": ["import_Errors", "import_CommandResult", "import_GetBackgroundImageSizeCommand", "import_ApduResponse", "IMAGE_SIZE_APDU", "command", "apdu", "response", "result"]
|
|
7
|
+
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";var i=Object.defineProperty;var a=Object.getOwnPropertyDescriptor;var
|
|
1
|
+
"use strict";var i=Object.defineProperty;var a=Object.getOwnPropertyDescriptor;var p=Object.getOwnPropertyNames;var s=Object.prototype.hasOwnProperty;var m=(r,e,n,o)=>{if(e&&typeof e=="object"||typeof e=="function")for(let t of p(e))!s.call(r,t)&&t!==n&&i(r,t,{get:()=>e[t],enumerable:!(o=a(e,t))||o.enumerable});return r};var c=r=>m(i({},"__esModule",{value:!0}),r);var d={};module.exports=c(d);
|
|
2
2
|
//# sourceMappingURL=DeviceAction.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../src/api/device-action/DeviceAction.ts"],
|
|
4
|
-
"sourcesContent": ["import { type Either } from \"purify-ts\";\nimport { type Observable } from \"rxjs\";\n\nimport { type Command } from \"@api/command/Command\";\nimport { type CommandResult } from \"@api/command/model/CommandResult\";\nimport { type TransportDeviceModel } from \"@api/device-model/model/DeviceModel\";\nimport { type ApduResponse } from \"@api/device-session/ApduResponse\";\nimport { type DeviceSessionState } from \"@api/device-session/DeviceSessionState\";\nimport { type DmkError } from \"@api/Error\";\nimport { type ManagerApiService } from \"@internal/manager-api/service/ManagerApiService\";\nimport { type SecureChannelService } from \"@internal/secure-channel/service/SecureChannelService\";\n\nimport { type DeviceActionState } from \"./model/DeviceActionState\";\n\nexport type InternalApi = {\n readonly sendApdu: (\n apdu: Uint8Array,\n ) => Promise<Either<DmkError, ApduResponse>>;\n readonly sendCommand: <Response, Args, ErrorStatusCodes>(\n command: Command<Response, Args, ErrorStatusCodes>,\n abortTimeout?: number,\n ) => Promise<CommandResult<Response, ErrorStatusCodes>>;\n readonly getDeviceModel: () => TransportDeviceModel;\n readonly getDeviceSessionState: () => DeviceSessionState;\n readonly getDeviceSessionStateObservable: () => Observable<DeviceSessionState>;\n readonly setDeviceSessionState: (\n state: DeviceSessionState,\n ) => DeviceSessionState;\n readonly
|
|
4
|
+
"sourcesContent": ["import { type Either } from \"purify-ts\";\nimport { type Observable } from \"rxjs\";\n\nimport { type Command } from \"@api/command/Command\";\nimport { type CommandResult } from \"@api/command/model/CommandResult\";\nimport { type TransportDeviceModel } from \"@api/device-model/model/DeviceModel\";\nimport { type ApduResponse } from \"@api/device-session/ApduResponse\";\nimport { type DeviceSessionState } from \"@api/device-session/DeviceSessionState\";\nimport { type DmkError } from \"@api/Error\";\nimport { type LoggerPublisherService } from \"@api/logger-publisher/service/LoggerPublisherService\";\nimport { type ManagerApiService } from \"@internal/manager-api/service/ManagerApiService\";\nimport { type SecureChannelService } from \"@internal/secure-channel/service/SecureChannelService\";\n\nimport { type DeviceActionState } from \"./model/DeviceActionState\";\n\nexport type InternalApi = {\n readonly sendApdu: (\n apdu: Uint8Array,\n ) => Promise<Either<DmkError, ApduResponse>>;\n readonly sendCommand: <Response, Args, ErrorStatusCodes>(\n command: Command<Response, Args, ErrorStatusCodes>,\n abortTimeout?: number,\n ) => Promise<CommandResult<Response, ErrorStatusCodes>>;\n readonly getDeviceModel: () => TransportDeviceModel;\n readonly getDeviceSessionState: () => DeviceSessionState;\n readonly getDeviceSessionStateObservable: () => Observable<DeviceSessionState>;\n readonly setDeviceSessionState: (\n state: DeviceSessionState,\n ) => DeviceSessionState;\n readonly getManagerApiService: () => ManagerApiService;\n readonly getSecureChannelService: () => SecureChannelService;\n readonly loggerFactory?: (tag: string) => LoggerPublisherService;\n};\n\nexport type DeviceActionIntermediateValue = {\n readonly requiredUserInteraction: string;\n};\n\nexport type ExecuteDeviceActionReturnType<Output, Error, IntermediateValue> = {\n readonly observable: Observable<\n DeviceActionState<Output, Error, IntermediateValue>\n >;\n cancel(): void;\n};\n\nexport interface DeviceAction<\n Output,\n Input,\n Error extends DmkError,\n IntermediateValue extends DeviceActionIntermediateValue,\n> {\n readonly input: Input;\n\n _execute(\n params: InternalApi,\n ): ExecuteDeviceActionReturnType<Output, Error, IntermediateValue>;\n}\n"],
|
|
5
5
|
"mappings": "+WAAA,IAAAA,EAAA,kBAAAC,EAAAD",
|
|
6
6
|
"names": ["DeviceAction_exports", "__toCommonJS"]
|
|
7
7
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";var
|
|
1
|
+
"use strict";var i=Object.defineProperty;var r=Object.getOwnPropertyDescriptor;var a=Object.getOwnPropertyNames;var v=Object.prototype.hasOwnProperty;var S=(e,t)=>{for(var o in t)i(e,o,{get:t[o],enumerable:!0})},p=(e,t,o,c)=>{if(t&&typeof t=="object"||typeof t=="function")for(let n of a(t))!v.call(e,n)&&n!==o&&i(e,n,{get:()=>t[n],enumerable:!(c=r(t,n))||c.enumerable});return e};var M=e=>p(i({},"__esModule",{value:!0}),e);var y={};S(y,{makeDeviceActionInternalApiMock:()=>b});module.exports=M(y);var s=require("../../../internal/logger-publisher/service/DefaultLoggerPublisherService");const g=vi.fn(),f=vi.fn(),k=vi.fn(),l=vi.fn(),d=vi.fn(),m=vi.fn(),D=vi.fn(),u=vi.fn(),A=vi.fn(e=>new s.DefaultLoggerPublisherService([],e));function b(){return{sendApdu:g,sendCommand:f,getDeviceModel:k,getDeviceSessionState:l,getDeviceSessionStateObservable:d,setDeviceSessionState:m,getManagerApiService:D,getSecureChannelService:u,loggerFactory:A}}0&&(module.exports={makeDeviceActionInternalApiMock});
|
|
2
2
|
//# sourceMappingURL=makeInternalApi.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../../src/api/device-action/__test-utils__/makeInternalApi.ts"],
|
|
4
|
-
"sourcesContent": ["import { type Mocked } from \"vitest\";\n\nimport { type InternalApi } from \"@api/device-action/DeviceAction\";\n\nconst sendApduMock = vi.fn();\nconst sendCommandMock = vi.fn();\nconst apiGetDeviceModelMock = vi.fn();\nconst apiGetDeviceSessionStateMock = vi.fn();\nconst apiGetDeviceSessionStateObservableMock = vi.fn();\nconst setDeviceSessionStateMock = vi.fn();\nconst getManagerApiServiceMock = vi.fn();\nconst getSecureChannelServiceMock = vi.fn();\nconst
|
|
5
|
-
"mappings": "yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,qCAAAE,IAAA,eAAAC,EAAAH,
|
|
6
|
-
"names": ["makeInternalApi_exports", "__export", "makeDeviceActionInternalApiMock", "__toCommonJS", "sendApduMock", "sendCommandMock", "apiGetDeviceModelMock", "apiGetDeviceSessionStateMock", "apiGetDeviceSessionStateObservableMock", "setDeviceSessionStateMock", "getManagerApiServiceMock", "getSecureChannelServiceMock", "
|
|
4
|
+
"sourcesContent": ["import { type Mocked } from \"vitest\";\n\nimport { type InternalApi } from \"@api/device-action/DeviceAction\";\nimport { DefaultLoggerPublisherService } from \"@internal/logger-publisher/service/DefaultLoggerPublisherService\";\n\nconst sendApduMock = vi.fn();\nconst sendCommandMock = vi.fn();\nconst apiGetDeviceModelMock = vi.fn();\nconst apiGetDeviceSessionStateMock = vi.fn();\nconst apiGetDeviceSessionStateObservableMock = vi.fn();\nconst setDeviceSessionStateMock = vi.fn();\nconst getManagerApiServiceMock = vi.fn();\nconst getSecureChannelServiceMock = vi.fn();\nconst loggerFactoryMock = vi.fn(\n (tag) => new DefaultLoggerPublisherService([], tag),\n);\n\nexport function makeDeviceActionInternalApiMock(): Mocked<InternalApi> {\n return {\n sendApdu: sendApduMock,\n sendCommand: sendCommandMock,\n getDeviceModel: apiGetDeviceModelMock,\n getDeviceSessionState: apiGetDeviceSessionStateMock,\n getDeviceSessionStateObservable: apiGetDeviceSessionStateObservableMock,\n setDeviceSessionState: setDeviceSessionStateMock,\n getManagerApiService: getManagerApiServiceMock,\n getSecureChannelService: getSecureChannelServiceMock,\n loggerFactory: loggerFactoryMock,\n };\n}\n"],
|
|
5
|
+
"mappings": "yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,qCAAAE,IAAA,eAAAC,EAAAH,GAGA,IAAAI,EAA8C,4EAE9C,MAAMC,EAAe,GAAG,GAAG,EACrBC,EAAkB,GAAG,GAAG,EACxBC,EAAwB,GAAG,GAAG,EAC9BC,EAA+B,GAAG,GAAG,EACrCC,EAAyC,GAAG,GAAG,EAC/CC,EAA4B,GAAG,GAAG,EAClCC,EAA2B,GAAG,GAAG,EACjCC,EAA8B,GAAG,GAAG,EACpCC,EAAoB,GAAG,GAC1BC,GAAQ,IAAI,gCAA8B,CAAC,EAAGA,CAAG,CACpD,EAEO,SAASZ,GAAuD,CACrE,MAAO,CACL,SAAUG,EACV,YAAaC,EACb,eAAgBC,EAChB,sBAAuBC,EACvB,gCAAiCC,EACjC,sBAAuBC,EACvB,qBAAsBC,EACtB,wBAAyBC,EACzB,cAAeC,CACjB,CACF",
|
|
6
|
+
"names": ["makeInternalApi_exports", "__export", "makeDeviceActionInternalApiMock", "__toCommonJS", "import_DefaultLoggerPublisherService", "sendApduMock", "sendCommandMock", "apiGetDeviceModelMock", "apiGetDeviceSessionStateMock", "apiGetDeviceSessionStateObservableMock", "setDeviceSessionStateMock", "getManagerApiServiceMock", "getSecureChannelServiceMock", "loggerFactoryMock", "tag"]
|
|
7
7
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";var
|
|
1
|
+
"use strict";var m=Object.defineProperty;var S=Object.getOwnPropertyDescriptor;var O=Object.getOwnPropertyNames;var U=Object.prototype.hasOwnProperty;var T=(e,t)=>{for(var o in t)m(e,o,{get:t[o],enumerable:!0})},G=(e,t,o,s)=>{if(t&&typeof t=="object"||typeof t=="function")for(let p of O(t))!U.call(e,p)&&p!==o&&m(e,p,{get:()=>t[p],enumerable:!(s=S(t,p))||s.enumerable});return e};var E=e=>G(m({},"__esModule",{value:!0}),e);var q={};T(q,{setupGetDeviceMetadataMock:()=>V,setupGetDeviceStatusMock:()=>b,setupGoToDashboardMock:()=>C,setupInstallOrUpdateAppsMock:()=>L,setupListAppsMock:()=>h,setupListInstalledAppsMock:()=>g,setupOpenAppMock:()=>_});module.exports=E(q);var a=require("purify-ts"),n=require("xstate"),i=require("../../device-action/model/UserInteractionRequired"),r=require("../../device-action/os/Errors"),c=require("../../device-action/os/GetDeviceMetadata/GetDeviceMetadataDeviceAction"),d=require("../../device-action/os/GetDeviceMetadata/types"),l=require("../../device-action/os/GetDeviceStatus/GetDeviceStatusDeviceAction"),A=require("../../device-action/os/GetDeviceStatus/types"),u=require("../../device-action/os/GoToDashboard/GoToDashboardDeviceAction"),f=require("../../device-action/os/GoToDashboard/types"),k=require("../../device-action/os/InstallOrUpdateApps/InstallOrUpdateAppsDeviceAction"),D=require("../../device-action/os/ListApps/ListAppsDeviceAction"),I=require("../../device-action/os/ListApps/types"),y=require("../../device-action/os/OpenAppDeviceAction/OpenAppDeviceAction"),M=require("../../device-action/os/OpenAppDeviceAction/types"),v=require("../../secure-channel/device-action/ListInstalledApps/ListInstalledAppsDeviceAction");const h=(e,t=!1)=>{D.ListAppsDeviceAction.mockImplementation(()=>({makeStateMachine:vi.fn().mockImplementation(()=>(0,n.createMachine)({id:"MockListAppsDeviceAction",initial:"ready",states:{ready:{after:{0:"done"},entry:(0,n.assign)({intermediateValue:()=>({requiredUserInteraction:i.UserInteractionRequired.AllowListApps,step:I.listAppsDAStateStep.LIST_APPS})})},done:{type:"final"}},output:()=>t?(0,a.Left)(new r.UnknownDAError("ListApps failed")):(0,a.Right)(e)}))}))},V=(e,t=!1)=>{c.GetDeviceMetadataDeviceAction.mockImplementation(()=>({makeStateMachine:vi.fn().mockImplementation(()=>(0,n.createMachine)({id:"MockGetDeviceMetadataDeviceAction",initial:"ready",states:{ready:{after:{0:"done"},entry:(0,n.assign)({intermediateValue:()=>({requiredUserInteraction:i.UserInteractionRequired.None,step:d.getDeviceMetadataDAStateStep.GET_DEVICE_METADATA})})},done:{type:"final"}},output:()=>t?(0,a.Left)(new r.UnknownDAError("GetDeviceMetadata failed")):(0,a.Right)(e)}))}))},L=(e,t,o=!1)=>{k.InstallOrUpdateAppsDeviceAction.mockImplementation(()=>({makeStateMachine:vi.fn().mockImplementation(()=>(0,n.createMachine)({id:"MockInstallOrUpdateAppsDeviceAction",initial:"ready",states:{ready:{after:{0:"done"},entry:(0,n.assign)({intermediateValue:()=>t})},done:{type:"final"}},output:()=>o?(0,a.Left)(new r.UnknownDAError("InstallOrUpdateApps failed")):(0,a.Right)(e)}))}))},_=(e=!1)=>{y.OpenAppDeviceAction.mockImplementation(()=>({makeStateMachine:vi.fn().mockImplementation(()=>(0,n.createMachine)({initial:"ready",states:{ready:{entry:(0,n.assign)({intermediateValue:{requiredUserInteraction:i.UserInteractionRequired.ConfirmOpenApp,step:M.openAppDAStateStep.GET_DEVICE_STATUS}}),after:{0:"done"}},done:{type:"final"}},output:()=>e?(0,a.Left)(new r.UnknownDAError("OpenApp failed")):(0,a.Right)(void 0)}))}))},C=(e=!1)=>{u.GoToDashboardDeviceAction.mockImplementation(()=>({makeStateMachine:vi.fn().mockImplementation(()=>(0,n.createMachine)({id:"MockGoToDashboardDeviceAction",initial:"ready",states:{ready:{after:{0:"done"},entry:(0,n.assign)({intermediateValue:()=>({requiredUserInteraction:i.UserInteractionRequired.None,step:f.goToDashboardDAStateStep.GET_DEVICE_STATUS})})},done:{type:"final"}},output:()=>e?(0,a.Left)(new r.UnknownDAError("GoToDashboard failed")):(0,a.Right)(void 0)}))}))},b=(e=[{currentApp:"BOLOS",currentAppVersion:"1.0.0"}])=>{const t=vi.fn();for(const o of e)t.mockImplementationOnce(()=>"currentApp"in o?(0,a.Right)(o):(0,a.Left)(o));l.GetDeviceStatusDeviceAction.mockImplementation(()=>({makeStateMachine:vi.fn().mockImplementation(()=>(0,n.createMachine)({id:"MockGetDeviceStatusDeviceAction",initial:"ready",states:{ready:{after:{0:"done"},entry:(0,n.assign)({intermediateValue:()=>({requiredUserInteraction:i.UserInteractionRequired.None,step:A.getDeviceStatusDAStateStep.ONBOARD_CHECK})})},done:{type:"final"}},output:t}))}))},g=(e=[])=>{v.ListInstalledAppsDeviceAction.mockImplementation(()=>({makeStateMachine:vi.fn().mockImplementation(()=>(0,n.createMachine)({id:"MockListInstalledAppsDeviceAction",initial:"ready",states:{ready:{after:{0:"done"},entry:(0,n.assign)({intermediateValue:()=>({requiredUserInteraction:i.UserInteractionRequired.None})})},done:{type:"final"}},output:e.reduce((t,o)=>t.mockImplementationOnce(()=>"installedApps"in o?(0,a.Right)(o):(0,a.Left)(o)),vi.fn()).mockImplementation(()=>(0,a.Right)([]))}))}))};0&&(module.exports={setupGetDeviceMetadataMock,setupGetDeviceStatusMock,setupGoToDashboardMock,setupInstallOrUpdateAppsMock,setupListAppsMock,setupListInstalledAppsMock,setupOpenAppMock});
|
|
2
2
|
//# sourceMappingURL=setupTestMachine.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../../src/api/device-action/__test-utils__/setupTestMachine.ts"],
|
|
4
|
-
"sourcesContent": ["import { Left, Right } from \"purify-ts\";\nimport { type Mock } from \"vitest\";\nimport { assign, createMachine } from \"xstate\";\n\nimport { UserInteractionRequired } from \"@api/device-action/model/UserInteractionRequired\";\nimport { UnknownDAError } from \"@api/device-action/os/Errors\";\nimport { GetDeviceMetadataDeviceAction } from \"@api/device-action/os/GetDeviceMetadata/GetDeviceMetadataDeviceAction\";\nimport {
|
|
5
|
-
"mappings": "yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,gCAAAE,EAAA,6BAAAC,EAAA,2BAAAC,EAAA,iCAAAC,EAAA,sBAAAC,EAAA,+BAAAC,EAAA,qBAAAC,IAAA,eAAAC,EAAAT,GAAA,IAAAU,EAA4B,qBAE5BC,EAAsC,kBAEtCC,EAAwC,4DACxCC,EAA+B,wCAC/BC,EAA8C,
|
|
6
|
-
"names": ["setupTestMachine_exports", "__export", "setupGetDeviceMetadataMock", "setupGetDeviceStatusMock", "setupGoToDashboardMock", "setupInstallOrUpdateAppsMock", "setupListAppsMock", "setupListInstalledAppsMock", "setupOpenAppMock", "__toCommonJS", "import_purify_ts", "import_xstate", "import_UserInteractionRequired", "import_Errors", "import_GetDeviceMetadataDeviceAction", "import_GetDeviceStatusDeviceAction", "import_GoToDashboardDeviceAction", "import_InstallOrUpdateAppsDeviceAction", "import_ListAppsDeviceAction", "import_OpenAppDeviceAction", "import_ListInstalledAppsDeviceAction", "apps", "error", "metadata", "result", "intermediateValue", "outputs", "outputFn", "output", "mockFn"]
|
|
4
|
+
"sourcesContent": ["import { Left, Right } from \"purify-ts\";\nimport { type Mock } from \"vitest\";\nimport { assign, createMachine } from \"xstate\";\n\nimport { UserInteractionRequired } from \"@api/device-action/model/UserInteractionRequired\";\nimport { UnknownDAError } from \"@api/device-action/os/Errors\";\nimport { GetDeviceMetadataDeviceAction } from \"@api/device-action/os/GetDeviceMetadata/GetDeviceMetadataDeviceAction\";\nimport {\n type GetDeviceMetadataDAOutput,\n getDeviceMetadataDAStateStep,\n} from \"@api/device-action/os/GetDeviceMetadata/types\";\nimport { GetDeviceStatusDeviceAction } from \"@api/device-action/os/GetDeviceStatus/GetDeviceStatusDeviceAction\";\nimport { getDeviceStatusDAStateStep } from \"@api/device-action/os/GetDeviceStatus/types\";\nimport { GoToDashboardDeviceAction } from \"@api/device-action/os/GoToDashboard/GoToDashboardDeviceAction\";\nimport { goToDashboardDAStateStep } from \"@api/device-action/os/GoToDashboard/types\";\nimport { InstallOrUpdateAppsDeviceAction } from \"@api/device-action/os/InstallOrUpdateApps/InstallOrUpdateAppsDeviceAction\";\nimport {\n type InstallOrUpdateAppsDAIntermediateValue,\n type InstallOrUpdateAppsDAOutput,\n} from \"@api/device-action/os/InstallOrUpdateApps/types\";\nimport { ListAppsDeviceAction } from \"@api/device-action/os/ListApps/ListAppsDeviceAction\";\nimport { listAppsDAStateStep } from \"@api/device-action/os/ListApps/types\";\nimport { OpenAppDeviceAction } from \"@api/device-action/os/OpenAppDeviceAction/OpenAppDeviceAction\";\nimport { openAppDAStateStep } from \"@api/device-action/os/OpenAppDeviceAction/types\";\nimport { type DmkError } from \"@api/Error\";\nimport { ListInstalledAppsDeviceAction } from \"@api/secure-channel/device-action/ListInstalledApps/ListInstalledAppsDeviceAction\";\nimport { type InstalledApp } from \"@api/secure-channel/device-action/ListInstalledApps/types\";\n\nimport { type BTC_APP } from \"./data\";\n\ntype App = typeof BTC_APP;\n\nexport const setupListAppsMock = (apps: App[], error = false) => {\n (ListAppsDeviceAction as Mock).mockImplementation(() => ({\n makeStateMachine: vi.fn().mockImplementation(() =>\n createMachine({\n id: \"MockListAppsDeviceAction\",\n initial: \"ready\",\n states: {\n ready: {\n after: {\n 0: \"done\",\n },\n entry: assign({\n intermediateValue: () => ({\n requiredUserInteraction: UserInteractionRequired.AllowListApps,\n step: listAppsDAStateStep.LIST_APPS,\n }),\n }),\n },\n done: {\n type: \"final\",\n },\n },\n output: () => {\n return error\n ? Left(new UnknownDAError(\"ListApps failed\"))\n : Right(apps);\n },\n }),\n ),\n }));\n};\n\nexport const setupGetDeviceMetadataMock = (\n metadata: GetDeviceMetadataDAOutput,\n error = false,\n) => {\n (GetDeviceMetadataDeviceAction as Mock).mockImplementation(() => ({\n makeStateMachine: vi.fn().mockImplementation(() =>\n createMachine({\n id: \"MockGetDeviceMetadataDeviceAction\",\n initial: \"ready\",\n states: {\n ready: {\n after: {\n 0: \"done\",\n },\n entry: assign({\n intermediateValue: () => ({\n requiredUserInteraction: UserInteractionRequired.None,\n step: getDeviceMetadataDAStateStep.GET_DEVICE_METADATA,\n }),\n }),\n },\n done: {\n type: \"final\",\n },\n },\n output: () => {\n return error\n ? Left(new UnknownDAError(\"GetDeviceMetadata failed\"))\n : Right(metadata);\n },\n }),\n ),\n }));\n};\n\nexport const setupInstallOrUpdateAppsMock = (\n result: InstallOrUpdateAppsDAOutput,\n intermediateValue: InstallOrUpdateAppsDAIntermediateValue,\n error = false,\n) => {\n (InstallOrUpdateAppsDeviceAction as Mock).mockImplementation(() => ({\n makeStateMachine: vi.fn().mockImplementation(() =>\n createMachine({\n id: \"MockInstallOrUpdateAppsDeviceAction\",\n initial: \"ready\",\n states: {\n ready: {\n after: {\n 0: \"done\",\n },\n entry: assign({\n intermediateValue: () => intermediateValue,\n }),\n },\n done: {\n type: \"final\",\n },\n },\n output: () => {\n return error\n ? Left(new UnknownDAError(\"InstallOrUpdateApps failed\"))\n : Right(result);\n },\n }),\n ),\n }));\n};\n\nexport const setupOpenAppMock = (error: boolean = false) => {\n (OpenAppDeviceAction as Mock).mockImplementation(() => ({\n makeStateMachine: vi.fn().mockImplementation(() =>\n createMachine({\n initial: \"ready\",\n states: {\n ready: {\n entry: assign({\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.ConfirmOpenApp,\n step: openAppDAStateStep.GET_DEVICE_STATUS,\n },\n }),\n after: {\n 0: \"done\",\n },\n },\n done: {\n type: \"final\",\n },\n },\n output: () => {\n return error\n ? Left(new UnknownDAError(\"OpenApp failed\"))\n : Right(undefined);\n },\n }),\n ),\n }));\n};\n\nexport const setupGoToDashboardMock = (error: boolean = false) => {\n (GoToDashboardDeviceAction as Mock).mockImplementation(() => ({\n makeStateMachine: vi.fn().mockImplementation(() =>\n createMachine({\n id: \"MockGoToDashboardDeviceAction\",\n initial: \"ready\",\n states: {\n ready: {\n after: {\n 0: \"done\",\n },\n entry: assign({\n intermediateValue: () => ({\n requiredUserInteraction: UserInteractionRequired.None,\n step: goToDashboardDAStateStep.GET_DEVICE_STATUS,\n }),\n }),\n },\n done: {\n type: \"final\",\n },\n },\n output: () => {\n return error\n ? Left(new UnknownDAError(\"GoToDashboard failed\"))\n : Right(undefined);\n },\n }),\n ),\n }));\n};\n\nexport const setupGetDeviceStatusMock = (\n outputs: ReadonlyArray<\n { currentApp: string; currentAppVersion: string } | DmkError\n > = [\n {\n currentApp: \"BOLOS\",\n currentAppVersion: \"1.0.0\",\n },\n ],\n) => {\n const outputFn = vi.fn();\n\n for (const output of outputs) {\n outputFn.mockImplementationOnce(() =>\n \"currentApp\" in output ? Right(output) : Left(output),\n );\n }\n (GetDeviceStatusDeviceAction as Mock).mockImplementation(() => ({\n makeStateMachine: vi.fn().mockImplementation(() =>\n createMachine({\n id: \"MockGetDeviceStatusDeviceAction\",\n initial: \"ready\",\n states: {\n ready: {\n after: {\n 0: \"done\",\n },\n entry: assign({\n intermediateValue: () => ({\n requiredUserInteraction: UserInteractionRequired.None,\n step: getDeviceStatusDAStateStep.ONBOARD_CHECK,\n }),\n }),\n },\n done: {\n type: \"final\",\n },\n },\n output: outputFn,\n }),\n ),\n }));\n};\n\nexport const setupListInstalledAppsMock = (\n outputs: Array<{ installedApps: InstalledApp[] } | DmkError> = [],\n) => {\n (ListInstalledAppsDeviceAction as Mock).mockImplementation(() => ({\n makeStateMachine: vi.fn().mockImplementation(() =>\n createMachine({\n id: \"MockListInstalledAppsDeviceAction\",\n initial: \"ready\",\n states: {\n ready: {\n after: {\n 0: \"done\",\n },\n entry: assign({\n intermediateValue: () => ({\n requiredUserInteraction: UserInteractionRequired.None,\n }),\n }),\n },\n done: {\n type: \"final\",\n },\n },\n output: outputs\n .reduce(\n (mockFn, output) =>\n mockFn.mockImplementationOnce(() =>\n \"installedApps\" in output ? Right(output) : Left(output),\n ),\n vi.fn(),\n )\n .mockImplementation(() => Right([])),\n }),\n ),\n }));\n};\n"],
|
|
5
|
+
"mappings": "yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,gCAAAE,EAAA,6BAAAC,EAAA,2BAAAC,EAAA,iCAAAC,EAAA,sBAAAC,EAAA,+BAAAC,EAAA,qBAAAC,IAAA,eAAAC,EAAAT,GAAA,IAAAU,EAA4B,qBAE5BC,EAAsC,kBAEtCC,EAAwC,4DACxCC,EAA+B,wCAC/BC,EAA8C,iFAC9CC,EAGO,yDACPC,EAA4C,6EAC5CD,EAA2C,uDAC3CE,EAA0C,yEAC1CF,EAAyC,qDACzCG,EAAgD,qFAKhDC,EAAqC,+DACrCJ,EAAoC,gDACpCK,EAAoC,yEACpCL,EAAmC,2DAEnCM,EAA8C,6FAOvC,MAAMf,EAAoB,CAACgB,EAAaC,EAAQ,KAAU,CAC9D,uBAA8B,mBAAmB,KAAO,CACvD,iBAAkB,GAAG,GAAG,EAAE,mBAAmB,OAC3C,iBAAc,CACZ,GAAI,2BACJ,QAAS,QACT,OAAQ,CACN,MAAO,CACL,MAAO,CACL,EAAG,MACL,EACA,SAAO,UAAO,CACZ,kBAAmB,KAAO,CACxB,wBAAyB,0BAAwB,cACjD,KAAM,sBAAoB,SAC5B,EACF,CAAC,CACH,EACA,KAAM,CACJ,KAAM,OACR,CACF,EACA,OAAQ,IACCA,KACH,QAAK,IAAI,iBAAe,iBAAiB,CAAC,KAC1C,SAAMD,CAAI,CAElB,CAAC,CACH,CACF,EAAE,CACJ,EAEapB,EAA6B,CACxCsB,EACAD,EAAQ,KACL,CACF,gCAAuC,mBAAmB,KAAO,CAChE,iBAAkB,GAAG,GAAG,EAAE,mBAAmB,OAC3C,iBAAc,CACZ,GAAI,oCACJ,QAAS,QACT,OAAQ,CACN,MAAO,CACL,MAAO,CACL,EAAG,MACL,EACA,SAAO,UAAO,CACZ,kBAAmB,KAAO,CACxB,wBAAyB,0BAAwB,KACjD,KAAM,+BAA6B,mBACrC,EACF,CAAC,CACH,EACA,KAAM,CACJ,KAAM,OACR,CACF,EACA,OAAQ,IACCA,KACH,QAAK,IAAI,iBAAe,0BAA0B,CAAC,KACnD,SAAMC,CAAQ,CAEtB,CAAC,CACH,CACF,EAAE,CACJ,EAEanB,EAA+B,CAC1CoB,EACAC,EACAH,EAAQ,KACL,CACF,kCAAyC,mBAAmB,KAAO,CAClE,iBAAkB,GAAG,GAAG,EAAE,mBAAmB,OAC3C,iBAAc,CACZ,GAAI,sCACJ,QAAS,QACT,OAAQ,CACN,MAAO,CACL,MAAO,CACL,EAAG,MACL,EACA,SAAO,UAAO,CACZ,kBAAmB,IAAMG,CAC3B,CAAC,CACH,EACA,KAAM,CACJ,KAAM,OACR,CACF,EACA,OAAQ,IACCH,KACH,QAAK,IAAI,iBAAe,4BAA4B,CAAC,KACrD,SAAME,CAAM,CAEpB,CAAC,CACH,CACF,EAAE,CACJ,EAEajB,EAAmB,CAACe,EAAiB,KAAU,CACzD,sBAA6B,mBAAmB,KAAO,CACtD,iBAAkB,GAAG,GAAG,EAAE,mBAAmB,OAC3C,iBAAc,CACZ,QAAS,QACT,OAAQ,CACN,MAAO,CACL,SAAO,UAAO,CACZ,kBAAmB,CACjB,wBAAyB,0BAAwB,eACjD,KAAM,qBAAmB,iBAC3B,CACF,CAAC,EACD,MAAO,CACL,EAAG,MACL,CACF,EACA,KAAM,CACJ,KAAM,OACR,CACF,EACA,OAAQ,IACCA,KACH,QAAK,IAAI,iBAAe,gBAAgB,CAAC,KACzC,SAAM,MAAS,CAEvB,CAAC,CACH,CACF,EAAE,CACJ,EAEanB,EAAyB,CAACmB,EAAiB,KAAU,CAC/D,4BAAmC,mBAAmB,KAAO,CAC5D,iBAAkB,GAAG,GAAG,EAAE,mBAAmB,OAC3C,iBAAc,CACZ,GAAI,gCACJ,QAAS,QACT,OAAQ,CACN,MAAO,CACL,MAAO,CACL,EAAG,MACL,EACA,SAAO,UAAO,CACZ,kBAAmB,KAAO,CACxB,wBAAyB,0BAAwB,KACjD,KAAM,2BAAyB,iBACjC,EACF,CAAC,CACH,EACA,KAAM,CACJ,KAAM,OACR,CACF,EACA,OAAQ,IACCA,KACH,QAAK,IAAI,iBAAe,sBAAsB,CAAC,KAC/C,SAAM,MAAS,CAEvB,CAAC,CACH,CACF,EAAE,CACJ,EAEapB,EAA2B,CACtCwB,EAEI,CACF,CACE,WAAY,QACZ,kBAAmB,OACrB,CACF,IACG,CACH,MAAMC,EAAW,GAAG,GAAG,EAEvB,UAAWC,KAAUF,EACnBC,EAAS,uBAAuB,IAC9B,eAAgBC,KAAS,SAAMA,CAAM,KAAI,QAAKA,CAAM,CACtD,EAED,8BAAqC,mBAAmB,KAAO,CAC9D,iBAAkB,GAAG,GAAG,EAAE,mBAAmB,OAC3C,iBAAc,CACZ,GAAI,kCACJ,QAAS,QACT,OAAQ,CACN,MAAO,CACL,MAAO,CACL,EAAG,MACL,EACA,SAAO,UAAO,CACZ,kBAAmB,KAAO,CACxB,wBAAyB,0BAAwB,KACjD,KAAM,6BAA2B,aACnC,EACF,CAAC,CACH,EACA,KAAM,CACJ,KAAM,OACR,CACF,EACA,OAAQD,CACV,CAAC,CACH,CACF,EAAE,CACJ,EAEarB,EAA6B,CACxCoB,EAA+D,CAAC,IAC7D,CACF,gCAAuC,mBAAmB,KAAO,CAChE,iBAAkB,GAAG,GAAG,EAAE,mBAAmB,OAC3C,iBAAc,CACZ,GAAI,oCACJ,QAAS,QACT,OAAQ,CACN,MAAO,CACL,MAAO,CACL,EAAG,MACL,EACA,SAAO,UAAO,CACZ,kBAAmB,KAAO,CACxB,wBAAyB,0BAAwB,IACnD,EACF,CAAC,CACH,EACA,KAAM,CACJ,KAAM,OACR,CACF,EACA,OAAQA,EACL,OACC,CAACG,EAAQD,IACPC,EAAO,uBAAuB,IAC5B,kBAAmBD,KAAS,SAAMA,CAAM,KAAI,QAAKA,CAAM,CACzD,EACF,GAAG,GAAG,CACR,EACC,mBAAmB,OAAM,SAAM,CAAC,CAAC,CAAC,CACvC,CAAC,CACH,CACF,EAAE,CACJ",
|
|
6
|
+
"names": ["setupTestMachine_exports", "__export", "setupGetDeviceMetadataMock", "setupGetDeviceStatusMock", "setupGoToDashboardMock", "setupInstallOrUpdateAppsMock", "setupListAppsMock", "setupListInstalledAppsMock", "setupOpenAppMock", "__toCommonJS", "import_purify_ts", "import_xstate", "import_UserInteractionRequired", "import_Errors", "import_GetDeviceMetadataDeviceAction", "import_types", "import_GetDeviceStatusDeviceAction", "import_GoToDashboardDeviceAction", "import_InstallOrUpdateAppsDeviceAction", "import_ListAppsDeviceAction", "import_OpenAppDeviceAction", "import_ListInstalledAppsDeviceAction", "apps", "error", "metadata", "result", "intermediateValue", "outputs", "outputFn", "output", "mockFn"]
|
|
7
7
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";var
|
|
1
|
+
"use strict";var p=Object.defineProperty;var i=Object.getOwnPropertyDescriptor;var n=Object.getOwnPropertyNames;var A=Object.prototype.hasOwnProperty;var C=(g,m)=>{for(var a in m)p(g,a,{get:m[a],enumerable:!0})},v=(g,m,a,f)=>{if(m&&typeof m=="object"||typeof m=="function")for(let l of n(m))!A.call(g,l)&&l!==a&&p(g,l,{get:()=>m[l],enumerable:!(f=i(m,l))||f.enumerable});return g};var w=g=>v(p({},"__esModule",{value:!0}),g);var y={};C(y,{UserInteractionRequired:()=>s});module.exports=w(y);var s=(o=>(o.None="none",o.UnlockDevice="unlock-device",o.AllowSecureConnection="allow-secure-connection",o.ConfirmOpenApp="confirm-open-app",o.SignTransaction="sign-transaction",o.SignTypedData="sign-typed-data",o.AllowListApps="allow-list-apps",o.VerifyAddress="verify-address",o.SignPersonalMessage="sign-personal-message",o.SignDelegationAuthorization="sign-delegation-authorization",o.Web3ChecksOptIn="web3-checks-opt-in",o.VerifySafeAddress="verify-safe-address",o.RegisterWallet="register-wallet",o.ConfirmLoadImage="confirm-load-image",o.ConfirmCommitImage="confirm-commit-image",o.ConfirmRemoveImage="confirm-remove-image",o))(s||{});0&&(module.exports={UserInteractionRequired});
|
|
2
2
|
//# sourceMappingURL=UserInteractionRequired.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../../src/api/device-action/model/UserInteractionRequired.ts"],
|
|
4
|
-
"sourcesContent": ["/**\n * The user interaction required on the device to move further in a device action.\n * This is used to inform the users about the action they need to take on the device.\n */\nexport enum UserInteractionRequired {\n None = \"none\",\n UnlockDevice = \"unlock-device\",\n AllowSecureConnection = \"allow-secure-connection\",\n ConfirmOpenApp = \"confirm-open-app\",\n SignTransaction = \"sign-transaction\",\n SignTypedData = \"sign-typed-data\",\n AllowListApps = \"allow-list-apps\",\n VerifyAddress = \"verify-address\",\n SignPersonalMessage = \"sign-personal-message\",\n SignDelegationAuthorization = \"sign-delegation-authorization\",\n Web3ChecksOptIn = \"web3-checks-opt-in\",\n VerifySafeAddress = \"verify-safe-address\",\n RegisterWallet = \"register-wallet\",\n}\n"],
|
|
5
|
-
"mappings": "yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,6BAAAE,IAAA,eAAAC,EAAAH,GAIO,IAAKE,OACVA,EAAA,KAAO,OACPA,EAAA,aAAe,gBACfA,EAAA,sBAAwB,0BACxBA,EAAA,eAAiB,mBACjBA,EAAA,gBAAkB,mBAClBA,EAAA,cAAgB,kBAChBA,EAAA,cAAgB,kBAChBA,EAAA,cAAgB,iBAChBA,EAAA,oBAAsB,wBACtBA,EAAA,4BAA8B,gCAC9BA,EAAA,gBAAkB,qBAClBA,EAAA,kBAAoB,sBACpBA,EAAA,eAAiB,
|
|
4
|
+
"sourcesContent": ["/**\n * The user interaction required on the device to move further in a device action.\n * This is used to inform the users about the action they need to take on the device.\n */\nexport enum UserInteractionRequired {\n None = \"none\",\n UnlockDevice = \"unlock-device\",\n AllowSecureConnection = \"allow-secure-connection\",\n ConfirmOpenApp = \"confirm-open-app\",\n SignTransaction = \"sign-transaction\",\n SignTypedData = \"sign-typed-data\",\n AllowListApps = \"allow-list-apps\",\n VerifyAddress = \"verify-address\",\n SignPersonalMessage = \"sign-personal-message\",\n SignDelegationAuthorization = \"sign-delegation-authorization\",\n Web3ChecksOptIn = \"web3-checks-opt-in\",\n VerifySafeAddress = \"verify-safe-address\",\n RegisterWallet = \"register-wallet\",\n ConfirmLoadImage = \"confirm-load-image\",\n ConfirmCommitImage = \"confirm-commit-image\",\n ConfirmRemoveImage = \"confirm-remove-image\",\n}\n"],
|
|
5
|
+
"mappings": "yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,6BAAAE,IAAA,eAAAC,EAAAH,GAIO,IAAKE,OACVA,EAAA,KAAO,OACPA,EAAA,aAAe,gBACfA,EAAA,sBAAwB,0BACxBA,EAAA,eAAiB,mBACjBA,EAAA,gBAAkB,mBAClBA,EAAA,cAAgB,kBAChBA,EAAA,cAAgB,kBAChBA,EAAA,cAAgB,iBAChBA,EAAA,oBAAsB,wBACtBA,EAAA,4BAA8B,gCAC9BA,EAAA,gBAAkB,qBAClBA,EAAA,kBAAoB,sBACpBA,EAAA,eAAiB,kBACjBA,EAAA,iBAAmB,qBACnBA,EAAA,mBAAqB,uBACrBA,EAAA,mBAAqB,uBAhBXA,OAAA",
|
|
6
6
|
"names": ["UserInteractionRequired_exports", "__export", "UserInteractionRequired", "__toCommonJS"]
|
|
7
7
|
}
|
package/lib/cjs/src/api/device-action/os/CallTaskInAppDeviceAction/CallTaskInAppDeviceAction.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";var
|
|
1
|
+
"use strict";var i=Object.defineProperty;var T=Object.getOwnPropertyDescriptor;var I=Object.getOwnPropertyNames;var C=Object.prototype.hasOwnProperty;var m=(r,t)=>{for(var s in t)i(r,s,{get:t[s],enumerable:!0})},d=(r,t,s,e)=>{if(t&&typeof t=="object"||typeof t=="function")for(let n of I(t))!C.call(r,n)&&n!==s&&i(r,n,{get:()=>t[n],enumerable:!(e=T(t,n))||e.enumerable});return r};var S=r=>d(i({},"__esModule",{value:!0}),r);var E={};m(E,{CallTaskInAppDeviceAction:()=>D});module.exports=S(E);var o=require("purify-ts"),a=require("xstate"),c=require("../../../command/model/CommandResult"),l=require("../../../device-action/model/UserInteractionRequired"),u=require("../../../device-action/os/Errors"),k=require("../../../device-action/os/OpenAppDeviceAction/OpenAppDeviceAction"),A=require("../../../device-action/xstate-utils/XStateDeviceAction"),p=require("./CallTaskInAppDeviceActionTypes");class D extends A.XStateDeviceAction{makeStateMachine(t){const{callTask:s}=this.extractDependencies(t);return(0,a.setup)({types:{input:{},context:{},output:{}},actors:{callTask:(0,a.fromPromise)(s),openAppStateMachine:new k.OpenAppDeviceAction({input:{appName:this.input.appName}}).makeStateMachine(t)},guards:{skipOpenApp:()=>this.input.skipOpenApp,noInternalError:({context:e})=>e._internalState.error===null},actions:{assignErrorFromEvent:(0,a.assign)({_internalState:e=>({...e.context._internalState,error:e.event.error})})}}).createMachine({id:"CallTaskInAppDeviceAction",initial:"InitialState",context:({input:e})=>({input:e,intermediateValue:{requiredUserInteraction:l.UserInteractionRequired.None,step:p.callTaskInAppDAStateStep.OPEN_APP},_internalState:{taskResponse:null,error:null}}),states:{InitialState:{always:[{target:"CallTask",guard:"skipOpenApp"},"OpenAppDeviceAction"]},OpenAppDeviceAction:{invoke:{id:"openAppStateMachine",input:{appName:this.input.appName},src:"openAppStateMachine",onSnapshot:{actions:(0,a.assign)({intermediateValue:e=>e.event.snapshot.context.intermediateValue})},onDone:{actions:(0,a.assign)({_internalState:e=>e.event.output.caseOf({Right:()=>e.context._internalState,Left:n=>({...e.context._internalState,error:n})})}),target:"CheckOpenAppDeviceActionResult"}}},CheckOpenAppDeviceActionResult:{always:[{target:"CallTask",guard:"noInternalError"},"Error"]},CallTask:{entry:(0,a.assign)({intermediateValue:{requiredUserInteraction:this.input.requiredUserInteraction,step:p.callTaskInAppDAStateStep.CALL_TASK}}),exit:(0,a.assign)({intermediateValue:{requiredUserInteraction:l.UserInteractionRequired.None,step:p.callTaskInAppDAStateStep.CALL_TASK}}),invoke:{id:"callTask",src:"callTask",input:e=>e.context.input.task,onDone:{target:"CallTaskResultCheck",actions:[(0,a.assign)({_internalState:({event:e,context:n})=>(0,c.isSuccessCommandResult)(e.output)?{...n._internalState,taskResponse:e.output.data}:{...n._internalState,error:e.output.error}})]},onError:{target:"Error",actions:"assignErrorFromEvent"}}},CallTaskResultCheck:{always:[{target:"Success",guard:"noInternalError"},"Error"]},Success:{type:"final"},Error:{type:"final"}},output:({context:e})=>e._internalState.taskResponse?(0,o.Right)(e._internalState.taskResponse):(0,o.Left)(e._internalState.error||new u.UnknownDAError("No error in final state"))})}extractDependencies(t){return{callTask:s=>s.input(t)}}}0&&(module.exports={CallTaskInAppDeviceAction});
|
|
2
2
|
//# sourceMappingURL=CallTaskInAppDeviceAction.js.map
|