@ledgerhq/device-management-kit 0.0.0-wrong-error-when-in-experimental-provider-20251021162636 → 0.0.0-zzz-solana-20251204140055
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/cjs/package.json +45 -40
- package/lib/cjs/src/api/DeviceManagementKit.js +1 -1
- package/lib/cjs/src/api/DeviceManagementKit.js.map +2 -2
- package/lib/cjs/src/api/DeviceManagementKit.test.js +1 -1
- package/lib/cjs/src/api/DeviceManagementKit.test.js.map +2 -2
- package/lib/cjs/src/api/command/Command.js +1 -1
- package/lib/cjs/src/api/command/Command.js.map +1 -1
- package/lib/cjs/src/api/command/Errors.js +1 -1
- package/lib/cjs/src/api/command/Errors.js.map +3 -3
- package/lib/cjs/src/api/command/model/CommandResult.js +1 -1
- package/lib/cjs/src/api/command/model/CommandResult.js.map +1 -1
- package/lib/cjs/src/api/command/os/CloseAppCommand.js +1 -1
- package/lib/cjs/src/api/command/os/CloseAppCommand.js.map +2 -2
- package/lib/cjs/src/api/command/os/CloseAppCommand.test.js +1 -1
- package/lib/cjs/src/api/command/os/CloseAppCommand.test.js.map +2 -2
- package/lib/cjs/src/api/command/os/GetAppAndVersionCommand.js +1 -1
- package/lib/cjs/src/api/command/os/GetAppAndVersionCommand.js.map +2 -2
- package/lib/cjs/src/api/command/os/GetAppAndVersionCommand.test.js +1 -1
- package/lib/cjs/src/api/command/os/GetAppAndVersionCommand.test.js.map +2 -2
- package/lib/cjs/src/api/command/os/GetBatteryStatusCommand.js +1 -1
- package/lib/cjs/src/api/command/os/GetBatteryStatusCommand.js.map +2 -2
- package/lib/cjs/src/api/command/os/GetBatteryStatusCommand.test.js +1 -1
- package/lib/cjs/src/api/command/os/GetBatteryStatusCommand.test.js.map +3 -3
- package/lib/cjs/src/api/command/os/GetCustomImageSizeCommand.js +1 -1
- package/lib/cjs/src/api/command/os/GetCustomImageSizeCommand.js.map +2 -2
- package/lib/cjs/src/api/command/os/GetCustomImageSizeCommand.test.js +1 -1
- package/lib/cjs/src/api/command/os/GetCustomImageSizeCommand.test.js.map +2 -2
- package/lib/cjs/src/api/command/os/GetOsVersionCommand.js +1 -1
- package/lib/cjs/src/api/command/os/GetOsVersionCommand.js.map +2 -2
- package/lib/cjs/src/api/command/os/GetOsVersionCommand.test.js +1 -1
- package/lib/cjs/src/api/command/os/GetOsVersionCommand.test.js.map +2 -2
- package/lib/cjs/src/api/command/os/ListAppsCommand.js +1 -1
- package/lib/cjs/src/api/command/os/ListAppsCommand.js.map +2 -2
- package/lib/cjs/src/api/command/os/ListAppsCommand.test.js +1 -1
- package/lib/cjs/src/api/command/os/ListAppsCommand.test.js.map +2 -2
- package/lib/cjs/src/api/command/os/ListLanguagePackCommand.js +1 -1
- package/lib/cjs/src/api/command/os/ListLanguagePackCommand.js.map +2 -2
- package/lib/cjs/src/api/command/os/ListLanguagePackCommand.test.js +1 -1
- package/lib/cjs/src/api/command/os/ListLanguagePackCommand.test.js.map +2 -2
- package/lib/cjs/src/api/command/os/LoadCertificateCommand.js +1 -1
- package/lib/cjs/src/api/command/os/LoadCertificateCommand.js.map +2 -2
- package/lib/cjs/src/api/command/os/LoadCertificateCommand.test.js +1 -1
- package/lib/cjs/src/api/command/os/LoadCertificateCommand.test.js.map +3 -3
- package/lib/cjs/src/api/command/os/OpenAppCommand.js +1 -1
- package/lib/cjs/src/api/command/os/OpenAppCommand.js.map +2 -2
- package/lib/cjs/src/api/command/os/OpenAppCommand.test.js +1 -1
- package/lib/cjs/src/api/command/os/OpenAppCommand.test.js.map +2 -2
- package/lib/cjs/src/api/command/use-case/SendCommandUseCase.test.js +1 -1
- package/lib/cjs/src/api/command/use-case/SendCommandUseCase.test.js.map +2 -2
- 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 +2 -2
- package/lib/cjs/src/api/device-action/os/Errors.js +1 -1
- package/lib/cjs/src/api/device-action/os/Errors.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/types.js +1 -1
- package/lib/cjs/src/api/device-action/os/GetDeviceMetadata/types.js.map +1 -1
- 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/types.js +1 -1
- package/lib/cjs/src/api/device-action/os/InstallOrUpdateApps/types.js.map +1 -1
- 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 +2 -2
- 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 +1 -1
- 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 +2 -2
- package/lib/cjs/src/api/device-action/task/BuildAppsInstallPlanTask.js +1 -1
- package/lib/cjs/src/api/device-action/task/BuildAppsInstallPlanTask.js.map +2 -2
- package/lib/cjs/src/api/device-action/task/BuildAppsInstallPlanTask.test.js +1 -1
- package/lib/cjs/src/api/device-action/task/BuildAppsInstallPlanTask.test.js.map +2 -2
- package/lib/cjs/src/api/device-action/task/GetFirmwareMetadataTask.js +1 -1
- package/lib/cjs/src/api/device-action/task/GetFirmwareMetadataTask.js.map +2 -2
- package/lib/cjs/src/api/device-action/task/GetFirmwareMetadataTask.test.js +1 -1
- package/lib/cjs/src/api/device-action/task/GetFirmwareMetadataTask.test.js.map +2 -2
- package/lib/cjs/src/api/index.js +1 -1
- package/lib/cjs/src/api/index.js.map +2 -2
- package/lib/cjs/src/api/logger-subscriber/service/ConsoleLogger.js +1 -1
- package/lib/cjs/src/api/logger-subscriber/service/ConsoleLogger.js.map +3 -3
- package/lib/cjs/src/api/secure-channel/device-action/GenuineCheck/GenuineCheckDeviceAction.js +1 -1
- package/lib/cjs/src/api/secure-channel/device-action/GenuineCheck/GenuineCheckDeviceAction.js.map +2 -2
- package/lib/cjs/src/api/secure-channel/device-action/GenuineCheck/types.js.map +1 -1
- package/lib/cjs/src/api/secure-channel/device-action/InstallApp/InstallAppDeviceAction.js +1 -1
- package/lib/cjs/src/api/secure-channel/device-action/InstallApp/InstallAppDeviceAction.js.map +2 -2
- package/lib/cjs/src/api/secure-channel/device-action/InstallApp/types.js.map +1 -1
- package/lib/cjs/src/api/secure-channel/device-action/ListInstalledApps/ListInstalledAppsDeviceAction.js +1 -1
- package/lib/cjs/src/api/secure-channel/device-action/ListInstalledApps/ListInstalledAppsDeviceAction.js.map +2 -2
- package/lib/cjs/src/api/secure-channel/device-action/ListInstalledApps/types.js +1 -1
- package/lib/cjs/src/api/secure-channel/device-action/ListInstalledApps/types.js.map +2 -2
- package/lib/cjs/src/api/secure-channel/device-action/UninstallApp/UninstallAppDeviceAction.js +1 -1
- package/lib/cjs/src/api/secure-channel/device-action/UninstallApp/UninstallAppDeviceAction.js.map +2 -2
- package/lib/cjs/src/api/secure-channel/device-action/UninstallApp/types.js.map +1 -1
- 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/secure-channel/task/ConnectToSecureChannelTask.test.js +1 -1
- package/lib/cjs/src/api/secure-channel/task/ConnectToSecureChannelTask.test.js.map +3 -3
- package/lib/cjs/src/api/secure-channel/task/types.js +1 -1
- package/lib/cjs/src/api/secure-channel/task/types.js.map +2 -2
- package/lib/cjs/src/api/secure-channel/utils.js +1 -1
- package/lib/cjs/src/api/secure-channel/utils.js.map +3 -3
- package/lib/cjs/src/api/secure-channel/utils.test.js +1 -1
- package/lib/cjs/src/api/secure-channel/utils.test.js.map +3 -3
- package/lib/cjs/src/api/transport/model/ConnectedDevice.js +1 -1
- package/lib/cjs/src/api/transport/model/ConnectedDevice.js.map +3 -3
- package/lib/cjs/src/api/transport/model/TransportConnectedDevice.js +1 -1
- package/lib/cjs/src/api/transport/model/TransportConnectedDevice.js.map +3 -3
- package/lib/cjs/src/internal/crypto/CryptoService.js +2 -0
- package/lib/cjs/src/internal/crypto/CryptoService.js.map +7 -0
- package/lib/cjs/src/internal/crypto/NobleCryptoService.js +2 -0
- package/lib/cjs/src/internal/crypto/NobleCryptoService.js.map +7 -0
- package/lib/cjs/src/internal/crypto/NobleCryptoService.test.js +2 -0
- package/lib/cjs/src/internal/crypto/NobleCryptoService.test.js.map +7 -0
- 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/service/DefaultDeviceSessionService.js +1 -1
- package/lib/cjs/src/internal/device-session/service/DefaultDeviceSessionService.js.map +3 -3
- package/lib/cjs/src/internal/device-session/service/DefaultDeviceSessionService.test.js +1 -1
- package/lib/cjs/src/internal/device-session/service/DefaultDeviceSessionService.test.js.map +3 -3
- package/lib/cjs/src/internal/device-session/service/DeviceSessionService.js +1 -1
- package/lib/cjs/src/internal/device-session/service/DeviceSessionService.js.map +1 -1
- package/lib/cjs/src/internal/discovery/di/discoveryModule.js +1 -1
- package/lib/cjs/src/internal/discovery/di/discoveryModule.js.map +3 -3
- package/lib/cjs/src/internal/discovery/di/discoveryModule.test.js +1 -1
- package/lib/cjs/src/internal/discovery/di/discoveryModule.test.js.map +3 -3
- package/lib/cjs/src/internal/discovery/di/discoveryTypes.js +1 -1
- package/lib/cjs/src/internal/discovery/di/discoveryTypes.js.map +2 -2
- package/lib/cjs/src/internal/discovery/use-case/ConnectUseCase.js +1 -1
- package/lib/cjs/src/internal/discovery/use-case/ConnectUseCase.js.map +3 -3
- package/lib/cjs/src/internal/discovery/use-case/ConnectUseCase.test.js +1 -1
- package/lib/cjs/src/internal/discovery/use-case/ConnectUseCase.test.js.map +3 -3
- package/lib/cjs/src/internal/discovery/use-case/DisconnectUseCase.js +1 -1
- package/lib/cjs/src/internal/discovery/use-case/DisconnectUseCase.js.map +3 -3
- package/lib/cjs/src/internal/discovery/use-case/ReconnectUseCase.js +2 -0
- package/lib/cjs/src/internal/discovery/use-case/ReconnectUseCase.js.map +7 -0
- package/lib/cjs/src/internal/discovery/use-case/ReconnectUseCase.test.js +2 -0
- package/lib/cjs/src/internal/discovery/use-case/ReconnectUseCase.test.js.map +7 -0
- package/lib/cjs/src/internal/manager-api/data/ManagerApiDataSource.js.map +1 -1
- package/lib/esm/package.json +45 -40
- package/lib/esm/src/api/DeviceManagementKit.js +1 -1
- package/lib/esm/src/api/DeviceManagementKit.js.map +2 -2
- package/lib/esm/src/api/DeviceManagementKit.test.js +1 -1
- package/lib/esm/src/api/DeviceManagementKit.test.js.map +2 -2
- package/lib/esm/src/api/command/Errors.js +1 -1
- package/lib/esm/src/api/command/Errors.js.map +3 -3
- package/lib/esm/src/api/command/model/CommandResult.js +1 -1
- package/lib/esm/src/api/command/model/CommandResult.js.map +1 -1
- package/lib/esm/src/api/command/os/CloseAppCommand.js +1 -1
- package/lib/esm/src/api/command/os/CloseAppCommand.js.map +2 -2
- package/lib/esm/src/api/command/os/CloseAppCommand.test.js +1 -1
- package/lib/esm/src/api/command/os/CloseAppCommand.test.js.map +2 -2
- package/lib/esm/src/api/command/os/GetAppAndVersionCommand.js +1 -1
- package/lib/esm/src/api/command/os/GetAppAndVersionCommand.js.map +2 -2
- package/lib/esm/src/api/command/os/GetAppAndVersionCommand.test.js +1 -1
- package/lib/esm/src/api/command/os/GetAppAndVersionCommand.test.js.map +2 -2
- package/lib/esm/src/api/command/os/GetBatteryStatusCommand.js +1 -1
- package/lib/esm/src/api/command/os/GetBatteryStatusCommand.js.map +2 -2
- package/lib/esm/src/api/command/os/GetBatteryStatusCommand.test.js +1 -1
- package/lib/esm/src/api/command/os/GetBatteryStatusCommand.test.js.map +3 -3
- package/lib/esm/src/api/command/os/GetCustomImageSizeCommand.js +1 -1
- package/lib/esm/src/api/command/os/GetCustomImageSizeCommand.js.map +2 -2
- package/lib/esm/src/api/command/os/GetCustomImageSizeCommand.test.js +1 -1
- package/lib/esm/src/api/command/os/GetCustomImageSizeCommand.test.js.map +2 -2
- package/lib/esm/src/api/command/os/GetOsVersionCommand.js +1 -1
- package/lib/esm/src/api/command/os/GetOsVersionCommand.js.map +2 -2
- package/lib/esm/src/api/command/os/GetOsVersionCommand.test.js +1 -1
- package/lib/esm/src/api/command/os/GetOsVersionCommand.test.js.map +2 -2
- package/lib/esm/src/api/command/os/ListAppsCommand.js +1 -1
- package/lib/esm/src/api/command/os/ListAppsCommand.js.map +2 -2
- package/lib/esm/src/api/command/os/ListAppsCommand.test.js +1 -1
- package/lib/esm/src/api/command/os/ListAppsCommand.test.js.map +2 -2
- package/lib/esm/src/api/command/os/ListLanguagePackCommand.js +1 -1
- package/lib/esm/src/api/command/os/ListLanguagePackCommand.js.map +2 -2
- package/lib/esm/src/api/command/os/ListLanguagePackCommand.test.js +1 -1
- package/lib/esm/src/api/command/os/ListLanguagePackCommand.test.js.map +2 -2
- package/lib/esm/src/api/command/os/LoadCertificateCommand.js +1 -1
- package/lib/esm/src/api/command/os/LoadCertificateCommand.js.map +2 -2
- package/lib/esm/src/api/command/os/LoadCertificateCommand.test.js +1 -1
- package/lib/esm/src/api/command/os/LoadCertificateCommand.test.js.map +3 -3
- package/lib/esm/src/api/command/os/OpenAppCommand.js +1 -1
- package/lib/esm/src/api/command/os/OpenAppCommand.js.map +2 -2
- package/lib/esm/src/api/command/os/OpenAppCommand.test.js +1 -1
- package/lib/esm/src/api/command/os/OpenAppCommand.test.js.map +2 -2
- package/lib/esm/src/api/command/use-case/SendCommandUseCase.test.js +1 -1
- package/lib/esm/src/api/command/use-case/SendCommandUseCase.test.js.map +2 -2
- 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 +2 -2
- package/lib/esm/src/api/device-action/os/Errors.js +1 -1
- package/lib/esm/src/api/device-action/os/Errors.js.map +3 -3
- 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 +2 -2
- 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 +2 -2
- 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 +2 -2
- 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 +2 -2
- package/lib/esm/src/api/device-action/task/BuildAppsInstallPlanTask.js +1 -1
- package/lib/esm/src/api/device-action/task/BuildAppsInstallPlanTask.js.map +3 -3
- package/lib/esm/src/api/device-action/task/BuildAppsInstallPlanTask.test.js +1 -1
- package/lib/esm/src/api/device-action/task/BuildAppsInstallPlanTask.test.js.map +3 -3
- 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/task/GetFirmwareMetadataTask.test.js +1 -1
- package/lib/esm/src/api/device-action/task/GetFirmwareMetadataTask.test.js.map +3 -3
- package/lib/esm/src/api/index.js +1 -1
- package/lib/esm/src/api/index.js.map +3 -3
- package/lib/esm/src/api/logger-subscriber/service/ConsoleLogger.js +1 -1
- package/lib/esm/src/api/logger-subscriber/service/ConsoleLogger.js.map +3 -3
- package/lib/esm/src/api/secure-channel/device-action/GenuineCheck/GenuineCheckDeviceAction.js +1 -1
- package/lib/esm/src/api/secure-channel/device-action/GenuineCheck/GenuineCheckDeviceAction.js.map +2 -2
- package/lib/esm/src/api/secure-channel/device-action/InstallApp/InstallAppDeviceAction.js +1 -1
- package/lib/esm/src/api/secure-channel/device-action/InstallApp/InstallAppDeviceAction.js.map +2 -2
- package/lib/esm/src/api/secure-channel/device-action/ListInstalledApps/ListInstalledAppsDeviceAction.js +1 -1
- package/lib/esm/src/api/secure-channel/device-action/ListInstalledApps/ListInstalledAppsDeviceAction.js.map +2 -2
- package/lib/esm/src/api/secure-channel/device-action/ListInstalledApps/types.js.map +2 -2
- package/lib/esm/src/api/secure-channel/device-action/UninstallApp/UninstallAppDeviceAction.js +1 -1
- package/lib/esm/src/api/secure-channel/device-action/UninstallApp/UninstallAppDeviceAction.js.map +2 -2
- 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/secure-channel/task/ConnectToSecureChannelTask.test.js +1 -1
- package/lib/esm/src/api/secure-channel/task/ConnectToSecureChannelTask.test.js.map +3 -3
- package/lib/esm/src/api/secure-channel/task/types.js +1 -1
- package/lib/esm/src/api/secure-channel/task/types.js.map +2 -2
- package/lib/esm/src/api/secure-channel/utils.js +1 -1
- package/lib/esm/src/api/secure-channel/utils.js.map +3 -3
- package/lib/esm/src/api/secure-channel/utils.test.js +1 -1
- package/lib/esm/src/api/secure-channel/utils.test.js.map +3 -3
- package/lib/esm/src/api/transport/model/ConnectedDevice.js +1 -1
- package/lib/esm/src/api/transport/model/ConnectedDevice.js.map +3 -3
- package/lib/esm/src/api/transport/model/TransportConnectedDevice.js +1 -1
- package/lib/esm/src/api/transport/model/TransportConnectedDevice.js.map +3 -3
- package/lib/esm/src/internal/crypto/CryptoService.js +1 -0
- package/lib/esm/src/internal/crypto/CryptoService.js.map +7 -0
- package/lib/esm/src/internal/crypto/NobleCryptoService.js +2 -0
- package/lib/esm/src/internal/crypto/NobleCryptoService.js.map +7 -0
- package/lib/esm/src/internal/crypto/NobleCryptoService.test.js +2 -0
- package/lib/esm/src/internal/crypto/NobleCryptoService.test.js.map +7 -0
- 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/service/DefaultDeviceSessionService.js +1 -1
- package/lib/esm/src/internal/device-session/service/DefaultDeviceSessionService.js.map +3 -3
- package/lib/esm/src/internal/device-session/service/DefaultDeviceSessionService.test.js +1 -1
- package/lib/esm/src/internal/device-session/service/DefaultDeviceSessionService.test.js.map +3 -3
- package/lib/esm/src/internal/discovery/di/discoveryModule.js +1 -1
- package/lib/esm/src/internal/discovery/di/discoveryModule.js.map +3 -3
- package/lib/esm/src/internal/discovery/di/discoveryModule.test.js +1 -1
- package/lib/esm/src/internal/discovery/di/discoveryModule.test.js.map +3 -3
- package/lib/esm/src/internal/discovery/di/discoveryTypes.js +1 -1
- package/lib/esm/src/internal/discovery/di/discoveryTypes.js.map +2 -2
- package/lib/esm/src/internal/discovery/use-case/ConnectUseCase.js +1 -1
- package/lib/esm/src/internal/discovery/use-case/ConnectUseCase.js.map +3 -3
- package/lib/esm/src/internal/discovery/use-case/ConnectUseCase.test.js +1 -1
- package/lib/esm/src/internal/discovery/use-case/ConnectUseCase.test.js.map +3 -3
- package/lib/esm/src/internal/discovery/use-case/DisconnectUseCase.js +1 -1
- package/lib/esm/src/internal/discovery/use-case/DisconnectUseCase.js.map +3 -3
- package/lib/esm/src/internal/discovery/use-case/ReconnectUseCase.js +2 -0
- package/lib/esm/src/internal/discovery/use-case/ReconnectUseCase.js.map +7 -0
- package/lib/esm/src/internal/discovery/use-case/ReconnectUseCase.test.js +2 -0
- package/lib/esm/src/internal/discovery/use-case/ReconnectUseCase.test.js.map +7 -0
- package/lib/types/src/api/DeviceManagementKit.d.ts +12 -0
- package/lib/types/src/api/DeviceManagementKit.d.ts.map +1 -1
- package/lib/types/src/api/command/Command.d.ts +4 -0
- package/lib/types/src/api/command/Command.d.ts.map +1 -1
- package/lib/types/src/api/command/Errors.d.ts +2 -2
- package/lib/types/src/api/command/Errors.d.ts.map +1 -1
- package/lib/types/src/api/command/model/CommandResult.d.ts +3 -3
- package/lib/types/src/api/command/model/CommandResult.d.ts.map +1 -1
- package/lib/types/src/api/command/os/CloseAppCommand.d.ts +1 -0
- package/lib/types/src/api/command/os/CloseAppCommand.d.ts.map +1 -1
- package/lib/types/src/api/command/os/GetAppAndVersionCommand.d.ts +1 -0
- package/lib/types/src/api/command/os/GetAppAndVersionCommand.d.ts.map +1 -1
- package/lib/types/src/api/command/os/GetBatteryStatusCommand.d.ts +1 -0
- package/lib/types/src/api/command/os/GetBatteryStatusCommand.d.ts.map +1 -1
- package/lib/types/src/api/command/os/GetCustomImageSizeCommand.d.ts +1 -0
- package/lib/types/src/api/command/os/GetCustomImageSizeCommand.d.ts.map +1 -1
- package/lib/types/src/api/command/os/GetOsVersionCommand.d.ts +1 -0
- package/lib/types/src/api/command/os/GetOsVersionCommand.d.ts.map +1 -1
- package/lib/types/src/api/command/os/ListAppsCommand.d.ts +1 -0
- package/lib/types/src/api/command/os/ListAppsCommand.d.ts.map +1 -1
- package/lib/types/src/api/command/os/ListLanguagePackCommand.d.ts +1 -0
- package/lib/types/src/api/command/os/ListLanguagePackCommand.d.ts.map +1 -1
- package/lib/types/src/api/command/os/LoadCertificateCommand.d.ts +1 -0
- package/lib/types/src/api/command/os/LoadCertificateCommand.d.ts.map +1 -1
- package/lib/types/src/api/command/os/OpenAppCommand.d.ts +1 -0
- package/lib/types/src/api/command/os/OpenAppCommand.d.ts.map +1 -1
- package/lib/types/src/api/device-action/os/Errors.d.ts +5 -0
- package/lib/types/src/api/device-action/os/Errors.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 +1 -0
- package/lib/types/src/api/device-action/os/GetDeviceMetadata/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 +3 -2
- package/lib/types/src/api/device-action/os/InstallOrUpdateApps/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 +1 -0
- package/lib/types/src/api/device-action/os/OpenAppWithDependencies/types.d.ts.map +1 -1
- package/lib/types/src/api/device-action/task/BuildAppsInstallPlanTask.d.ts +2 -2
- package/lib/types/src/api/device-action/task/BuildAppsInstallPlanTask.d.ts.map +1 -1
- package/lib/types/src/api/index.d.ts +1 -1
- package/lib/types/src/api/index.d.ts.map +1 -1
- package/lib/types/src/api/logger-subscriber/service/ConsoleLogger.d.ts +1 -0
- package/lib/types/src/api/logger-subscriber/service/ConsoleLogger.d.ts.map +1 -1
- package/lib/types/src/api/secure-channel/device-action/GenuineCheck/GenuineCheckDeviceAction.d.ts.map +1 -1
- package/lib/types/src/api/secure-channel/device-action/GenuineCheck/types.d.ts +1 -0
- package/lib/types/src/api/secure-channel/device-action/GenuineCheck/types.d.ts.map +1 -1
- package/lib/types/src/api/secure-channel/device-action/InstallApp/InstallAppDeviceAction.d.ts.map +1 -1
- package/lib/types/src/api/secure-channel/device-action/InstallApp/types.d.ts +1 -0
- package/lib/types/src/api/secure-channel/device-action/InstallApp/types.d.ts.map +1 -1
- package/lib/types/src/api/secure-channel/device-action/ListInstalledApps/ListInstalledAppsDeviceAction.d.ts.map +1 -1
- package/lib/types/src/api/secure-channel/device-action/ListInstalledApps/types.d.ts +1 -0
- package/lib/types/src/api/secure-channel/device-action/ListInstalledApps/types.d.ts.map +1 -1
- package/lib/types/src/api/secure-channel/device-action/UninstallApp/UninstallAppDeviceAction.d.ts.map +1 -1
- package/lib/types/src/api/secure-channel/device-action/UninstallApp/types.d.ts +1 -0
- package/lib/types/src/api/secure-channel/device-action/UninstallApp/types.d.ts.map +1 -1
- package/lib/types/src/api/secure-channel/task/ConnectToSecureChannelTask.d.ts +4 -0
- package/lib/types/src/api/secure-channel/task/ConnectToSecureChannelTask.d.ts.map +1 -1
- package/lib/types/src/api/secure-channel/task/types.d.ts +7 -0
- package/lib/types/src/api/secure-channel/task/types.d.ts.map +1 -1
- package/lib/types/src/api/secure-channel/utils.d.ts +18 -1
- package/lib/types/src/api/secure-channel/utils.d.ts.map +1 -1
- package/lib/types/src/api/transport/model/ConnectedDevice.d.ts +3 -2
- package/lib/types/src/api/transport/model/ConnectedDevice.d.ts.map +1 -1
- package/lib/types/src/api/transport/model/TransportConnectedDevice.d.ts +3 -1
- package/lib/types/src/api/transport/model/TransportConnectedDevice.d.ts.map +1 -1
- package/lib/types/src/internal/crypto/CryptoService.d.ts +12 -0
- package/lib/types/src/internal/crypto/CryptoService.d.ts.map +1 -0
- package/lib/types/src/internal/crypto/NobleCryptoService.d.ts +8 -0
- package/lib/types/src/internal/crypto/NobleCryptoService.d.ts.map +1 -0
- package/lib/types/src/internal/crypto/NobleCryptoService.test.d.ts +2 -0
- package/lib/types/src/internal/crypto/NobleCryptoService.test.d.ts.map +1 -0
- package/lib/types/src/internal/device-session/model/DeviceSession.d.ts.map +1 -1
- package/lib/types/src/internal/device-session/service/DefaultDeviceSessionService.d.ts +7 -5
- package/lib/types/src/internal/device-session/service/DefaultDeviceSessionService.d.ts.map +1 -1
- package/lib/types/src/internal/device-session/service/DeviceSessionService.d.ts +28 -1
- package/lib/types/src/internal/device-session/service/DeviceSessionService.d.ts.map +1 -1
- package/lib/types/src/internal/discovery/di/discoveryModule.d.ts.map +1 -1
- package/lib/types/src/internal/discovery/di/discoveryTypes.d.ts +1 -0
- package/lib/types/src/internal/discovery/di/discoveryTypes.d.ts.map +1 -1
- package/lib/types/src/internal/discovery/use-case/ConnectUseCase.d.ts +3 -2
- package/lib/types/src/internal/discovery/use-case/ConnectUseCase.d.ts.map +1 -1
- package/lib/types/src/internal/discovery/use-case/DisconnectUseCase.d.ts.map +1 -1
- package/lib/types/src/internal/discovery/use-case/ReconnectUseCase.d.ts +32 -0
- package/lib/types/src/internal/discovery/use-case/ReconnectUseCase.d.ts.map +1 -0
- package/lib/types/src/internal/discovery/use-case/ReconnectUseCase.test.d.ts +2 -0
- package/lib/types/src/internal/discovery/use-case/ReconnectUseCase.test.d.ts.map +1 -0
- package/lib/types/src/internal/manager-api/data/ManagerApiDataSource.d.ts +1 -1
- package/lib/types/tsconfig.prod.tsbuildinfo +1 -1
- package/package.json +33 -28
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../../src/api/secure-channel/task/ConnectToSecureChannelTask.test.ts"],
|
|
4
|
-
"sourcesContent": ["import WebSocket from \"isomorphic-ws\";\nimport { Right } from \"purify-ts\";\nimport { describe, it, vi } from \"vitest\";\n\nimport { type InternalApi } from \"@api/index\";\nimport {\n type SecureChannelEvent,\n SecureChannelEventType,\n} from \"@api/secure-channel/task/types\";\nimport {\n SecureChannelError,\n SecureChannelErrorType,\n} from \"@internal/secure-channel/model/Errors\";\n\nimport {\n ConnectToSecureChannelTask,\n type ConnectToSecureChannelTaskArgs,\n} from \"./ConnectToSecureChannelTask\";\n\nvi.mock(\"isomorphic-ws\", () => ({\n ...vi.importActual(\"isomorphic-ws\"),\n __esModule: true,\n default: class {\n onopen: (() => void) | null = null;\n onmessage: ((event: { data: string }) => void) | null = null;\n send = vi.fn();\n close = vi.fn();\n url: string;\n constructor(url: string) {\n this.url = url;\n }\n },\n}));\n\nconst TEST_DELAY = 5;\n\ndescribe(\"ConnectToSecureChannelTask\", () => {\n let mockWebSocket: WebSocket;\n let mockInternalApi: InternalApi;\n let taskArgs: ConnectToSecureChannelTaskArgs;\n let task: ConnectToSecureChannelTask;\n const sendApduFn = vi.fn();\n const mockMessage = {\n uuid: \"5b776c8d-8af2-48c0-8250-04edca2ef5e9\",\n session: \"39ce749e-00a4-4c31-a697-1dc1a29e2cab\",\n query: \"success\",\n nonce: 15,\n };\n\n beforeEach(() => {\n // vi.useFakeTimers({ shouldAdvanceTime: true });\n\n mockWebSocket = new WebSocket(\"wss://test-host.com\");\n mockInternalApi = {\n sendApdu: sendApduFn,\n disableRefresher: (_: unknown) => vi.fn(),\n } as unknown as InternalApi;\n taskArgs = { connection: Right(mockWebSocket) };\n task = new ConnectToSecureChannelTask(mockInternalApi, taskArgs);\n });\n\n afterEach(() => {\n vi.resetAllMocks();\n });\n\n it(\"should emit Opened event on WebSocket open\", async () => {\n const events: SecureChannelEvent[] = [];\n const obs = task.run();\n obs.subscribe((e) => events.push(e));\n\n expect(mockWebSocket.onopen).toBeDefined();\n mockWebSocket.onopen!({\n type: \"open\",\n target: {} as WebSocket,\n });\n\n await new Promise((resolve) => setTimeout(resolve, TEST_DELAY));\n\n expect(events).toStrictEqual([{ type: SecureChannelEventType.Opened }]);\n });\n\n it(\"Error on wrongly formatted message\", async () => {\n const events: SecureChannelEvent[] = [];\n const obs = task.run();\n obs.subscribe({\n next: (event) => {\n events.push(event);\n },\n });\n\n expect(mockWebSocket.onmessage).toBeDefined();\n mockWebSocket.onmessage!({\n data: \"invalidData\",\n type: \"\",\n target: {} as WebSocket,\n });\n\n await new Promise((resolve) => setTimeout(resolve, TEST_DELAY));\n\n expect(events).toStrictEqual([\n {\n type: SecureChannelEventType.Error,\n error: new SecureChannelError({\n url: \"wss://test-host.com\",\n errorMessage: \"Invalid message received: invalidData\",\n }),\n },\n ]);\n });\n\n it(\"should handle incoming EXCHANGE message including requesting user permission\", async () => {\n sendApduFn.mockResolvedValue(\n Right({\n data: new Uint8Array([0x90, 0x00]),\n statusCode: new Uint8Array([0x90, 0x00]),\n }),\n );\n\n const sendSpy = vi.spyOn(mockWebSocket, \"send\");\n vi.spyOn(task, \"isSecureConnectionAllowed\").mockReturnValueOnce(false);\n\n const events: SecureChannelEvent[] = [];\n const obs = task.run();\n obs.subscribe({\n next: (event) => {\n events.push(event);\n },\n });\n\n expect(mockWebSocket.onmessage).toBeDefined();\n mockWebSocket.onmessage!({\n data: JSON.stringify({\n ...mockMessage,\n query: \"exchange\",\n nonce: 1,\n data: \"e051000000\",\n }),\n type: \"\",\n target: {} as WebSocket,\n });\n\n await new Promise((resolve) => setTimeout(resolve, TEST_DELAY));\n\n expect(sendSpy).toHaveBeenCalledExactlyOnceWith(\n JSON.stringify({\n nonce: 1,\n response: \"success\",\n data: \"9000\",\n }),\n );\n expect(events).toStrictEqual([\n {\n type: SecureChannelEventType.PreExchange,\n payload: {\n nonce: 1,\n apdu: new Uint8Array([0xe0, 0x51, 0x00, 0x00, 0x00]),\n },\n },\n {\n type: SecureChannelEventType.PermissionRequested,\n },\n {\n type: SecureChannelEventType.Exchange,\n payload: {\n nonce: 1,\n apdu: new Uint8Array([0xe0, 0x51, 0x00, 0x00, 0x00]),\n data: new Uint8Array([0x90, 0x00]),\n status: new Uint8Array([0x90, 0x00]),\n },\n },\n {\n type: SecureChannelEventType.PermissionGranted,\n },\n ]);\n });\n\n it(\"should handle incoming EXCHANGE message with a device error\", async () => {\n sendApduFn.mockResolvedValue(\n Right({\n data: new Uint8Array([]),\n statusCode: new Uint8Array([0x55, 0x15]),\n }),\n );\n\n const sendSpy = vi.spyOn(mockWebSocket, \"send\");\n const events: SecureChannelEvent[] = [];\n const obs = task.run();\n obs.subscribe({\n next: (event) => {\n events.push(event);\n },\n });\n\n expect(mockWebSocket.onmessage).toBeDefined();\n mockWebSocket.onmessage!({\n data: JSON.stringify({\n ...mockMessage,\n query: \"exchange\",\n nonce: 1,\n data: \"e053000000\",\n }),\n type: \"\",\n target: {} as WebSocket,\n });\n\n await new Promise((resolve) => setTimeout(resolve, TEST_DELAY));\n\n expect(sendSpy).toHaveBeenCalledExactlyOnceWith(\n JSON.stringify({\n nonce: 1,\n response: \"error\",\n data: \"\",\n }),\n );\n expect(events).toStrictEqual([\n {\n type: SecureChannelEventType.PreExchange,\n payload: {\n nonce: 1,\n apdu: new Uint8Array([0xe0, 0x53, 0x00, 0x00, 0x00]),\n },\n },\n {\n type: SecureChannelEventType.Error,\n error: new SecureChannelError(\n {\n url: \"wss://test-host.com\",\n errorMessage: \"Device is locked\",\n },\n SecureChannelErrorType.DeviceLocked,\n ),\n },\n ]);\n });\n\n it(\"should handle incoming BULK message\", async () => {\n sendApduFn.mockResolvedValue(\n Right({\n data: new Uint8Array([0x90, 0x00]),\n statusCode: new Uint8Array([0x90, 0x00]),\n }),\n );\n const completeFn: () => void = vi.fn();\n const obs = task.run();\n const events: SecureChannelEvent[] = [];\n obs.subscribe({\n next: (event: SecureChannelEvent) => {\n events.push(event);\n },\n complete: () => completeFn(),\n });\n\n expect(mockWebSocket.onmessage).toBeDefined();\n mockWebSocket.onmessage!({\n data: JSON.stringify({\n ...mockMessage,\n query: \"bulk\",\n nonce: 1,\n data: [\"0000000100\", \"0000000200\", \"0000000300\"],\n }),\n type: \"\",\n target: {} as WebSocket,\n });\n\n await new Promise((resolve) => setTimeout(resolve, TEST_DELAY));\n\n expect(sendApduFn).toHaveBeenCalledTimes(3);\n expect(events).toStrictEqual([\n {\n type: SecureChannelEventType.Progress,\n payload: { progress: 0.33, index: 0, total: 3 },\n },\n {\n type: SecureChannelEventType.Progress,\n payload: { progress: 0.67, index: 1, total: 3 },\n },\n {\n type: SecureChannelEventType.Progress,\n payload: { progress: 1.0, index: 2, total: 3 },\n },\n ]);\n expect(completeFn).toHaveBeenCalledOnce();\n });\n\n it(\"should handle incoming BULK message with a device error\", async () => {\n sendApduFn.mockResolvedValue(\n Right({\n data: new Uint8Array([]),\n statusCode: new Uint8Array([0x55, 0x01]),\n }),\n );\n const completeFn: () => void = vi.fn();\n const obs = task.run();\n const events: SecureChannelEvent[] = [];\n obs.subscribe({\n next: (event: SecureChannelEvent) => {\n events.push(event);\n },\n complete: () => completeFn(),\n });\n\n expect(mockWebSocket.onmessage).toBeDefined();\n mockWebSocket.onmessage!({\n data: JSON.stringify({\n ...mockMessage,\n query: \"bulk\",\n nonce: 1,\n data: [\"0000000100\", \"0000000200\", \"0000000300\"],\n }),\n type: \"\",\n target: {} as WebSocket,\n });\n\n await new Promise((resolve) => setTimeout(resolve, TEST_DELAY));\n\n expect(sendApduFn).toHaveBeenCalledTimes(1);\n expect(events).toStrictEqual([\n {\n type: SecureChannelEventType.Error,\n error: new SecureChannelError(\n {\n url: \"wss://test-host.com\",\n errorMessage: \"User refused on the device\",\n },\n SecureChannelErrorType.RefusedByUser,\n ),\n },\n ]);\n expect(completeFn).toHaveBeenCalledOnce();\n });\n\n it(\"should handle incoming SUCCESS message\", () => {\n const completeFn: () => void = vi.fn();\n const events: SecureChannelEvent[] = [];\n const observable = task.run();\n observable.subscribe({\n next: (event: SecureChannelEvent) => events.push(event),\n complete: () => completeFn(),\n });\n\n mockWebSocket.onmessage!({\n data: JSON.stringify({\n ...mockMessage,\n query: \"success\",\n nonce: 1,\n result: \"success result\",\n }),\n type: \"\",\n target: {} as WebSocket,\n });\n\n expect(events).toStrictEqual([\n { type: SecureChannelEventType.Result, payload: \"success result\" },\n ]);\n expect(completeFn).toHaveBeenCalledOnce();\n });\n\n it(\"should handle incoming WARNING message\", () => {\n const events: SecureChannelEvent[] = [];\n const observable = task.run();\n observable.subscribe({\n next: (event: SecureChannelEvent) => events.push(event),\n });\n\n expect(mockWebSocket.onmessage).toBeDefined();\n mockWebSocket.onmessage!({\n data: JSON.stringify({\n ...mockMessage,\n query: \"warning\",\n nonce: 1,\n data: \"warning message\",\n }),\n type: \"\",\n target: {} as WebSocket,\n });\n\n expect(events).toStrictEqual([\n {\n type: SecureChannelEventType.Warning,\n payload: { message: \"warning message\" },\n },\n ]);\n });\n\n it(\"should handle incoming ERROR message\", () => {\n const events: SecureChannelEvent[] = [];\n const observable = task.run();\n observable.subscribe({\n next: (event: SecureChannelEvent) => events.push(event),\n });\n\n expect(mockWebSocket.onmessage).toBeDefined();\n mockWebSocket.onmessage!({\n data: JSON.stringify({\n ...mockMessage,\n query: \"error\",\n data: \"My error\",\n }),\n type: \"\",\n target: {} as WebSocket,\n });\n\n expect(events).toStrictEqual([\n {\n type: SecureChannelEventType.Error,\n error: new SecureChannelError({\n url: \"wss://test-host.com\",\n errorMessage: \"My error\",\n }),\n },\n ]);\n });\n});\n"],
|
|
5
|
-
"mappings": "wdAAA,IAAAA,EAAsB,4BACtBC,EAAsB,qBACtBC,EAAiC,kBAGjCC,EAGO,0CACPC,EAGO,iDAEPC,EAGO,wCAEP,KAAG,KAAK,gBAAiB,KAAO,CAC9B,GAAG,KAAG,aAAa,eAAe,EAClC,WAAY,GACZ,QAAS,KAAM,CACb,OAA8B,KAC9B,UAAwD,KACxD,KAAO,KAAG,GAAG,EACb,MAAQ,KAAG,GAAG,EACd,IACA,YAAYC,EAAa,CACvB,KAAK,IAAMA,CACb,CACF,CACF,EAAE,EAEF,MAAMC,EAAa,KAEnB,YAAS,6BAA8B,IAAM,CAC3C,IAAIC,EACAC,EACAC,EACAC,EACJ,MAAMC,EAAa,KAAG,GAAG,EACnBC,EAAc,CAClB,KAAM,uCACN,QAAS,uCACT,MAAO,UACP,MAAO,EACT,EAEA,WAAW,IAAM,CAGfL,EAAgB,IAAI,EAAAM,QAAU,qBAAqB,EACnD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,EAAe,MAAM,EAC9C,KAAG,MAAMG,EAAM,2BAA2B,EAAE,oBAAoB,EAAK,EAErE,MAAMK,EAA+B,CAAC,EAC1BL,EAAK,IAAI,EACjB,UAAU,CACZ,KAAOQ,GAAU,CACfH,EAAO,KAAKG,CAAK,CACnB,CACF,CAAC,EAED,OAAOX,EAAc,SAAS,EAAE,YAAY,EAC5CA,EAAc,UAAW,CACvB,KAAM,KAAK,UAAU,CACnB,GAAGK,EACH,MAAO,WACP,MAAO,EACP,KAAM,YACR,CAAC,EACD,KAAM,GACN,OAAQ,CAAC,CACX,CAAC,EAED,MAAM,IAAI,QAASK,GAAY,WAAWA,EAASX,CAAU,CAAC,EAE9D,OAAOa,CAAO,EAAE,gCACd,KAAK,UAAU,CACb,MAAO,EACP,SAAU,UACV,KAAM,MACR,CAAC,CACH,EACA,OAAOJ,CAAM,EAAE,cAAc,CAC3B,CACE,KAAM,yBAAuB,YAC7B,QAAS,CACP,MAAO,EACP,KAAM,IAAI,WAAW,CAAC,IAAM,GAAM,EAAM,EAAM,CAAI,CAAC,CACrD,CACF,EACA,CACE,KAAM,yBAAuB,mBAC/B,EACA,CACE,KAAM,yBAAuB,SAC7B,QAAS,CACP,MAAO,EACP,KAAM,IAAI,WAAW,CAAC,IAAM,GAAM,EAAM,EAAM,CAAI,CAAC,EACnD,KAAM,IAAI,WAAW,CAAC,IAAM,CAAI,CAAC,EACjC,OAAQ,IAAI,WAAW,CAAC,IAAM,CAAI,CAAC,CACrC,CACF,EACA,CACE,KAAM,yBAAuB,iBAC/B,CACF,CAAC,CACH,CAAC,KAED,MAAG,8DAA+D,SAAY,
|
|
6
|
-
"names": ["import_isomorphic_ws", "import_purify_ts", "import_vitest", "import_types", "import_Errors", "import_ConnectToSecureChannelTask", "url", "TEST_DELAY", "mockWebSocket", "mockInternalApi", "taskArgs", "task", "sendApduFn", "mockMessage", "WebSocket", "_", "events", "e", "resolve", "event", "sendSpy", "completeFn", "obs"]
|
|
4
|
+
"sourcesContent": ["import WebSocket from \"isomorphic-ws\";\nimport { Right } from \"purify-ts\";\nimport { describe, it, vi } from \"vitest\";\n\nimport { type InternalApi } from \"@api/index\";\nimport {\n type SecureChannelEvent,\n SecureChannelEventType,\n} from \"@api/secure-channel/task/types\";\nimport {\n SecureChannelError,\n SecureChannelErrorType,\n} from \"@internal/secure-channel/model/Errors\";\n\nimport {\n ConnectToSecureChannelTask,\n type ConnectToSecureChannelTaskArgs,\n} from \"./ConnectToSecureChannelTask\";\n\nvi.mock(\"isomorphic-ws\", () => ({\n ...vi.importActual(\"isomorphic-ws\"),\n __esModule: true,\n default: class {\n onopen: (() => void) | null = null;\n onmessage: ((event: { data: string }) => void) | null = null;\n send = vi.fn();\n close = vi.fn();\n url: string;\n constructor(url: string) {\n this.url = url;\n }\n },\n}));\n\nconst TEST_DELAY = 5;\n\ndescribe(\"ConnectToSecureChannelTask\", () => {\n let mockWebSocket: WebSocket;\n let mockInternalApi: InternalApi;\n let taskArgs: ConnectToSecureChannelTaskArgs;\n let task: ConnectToSecureChannelTask;\n const sendApduFn = vi.fn();\n const mockMessage = {\n uuid: \"5b776c8d-8af2-48c0-8250-04edca2ef5e9\",\n session: \"39ce749e-00a4-4c31-a697-1dc1a29e2cab\",\n query: \"success\",\n nonce: 15,\n };\n\n beforeEach(() => {\n // vi.useFakeTimers({ shouldAdvanceTime: true });\n\n mockWebSocket = new WebSocket(\"wss://test-host.com\");\n mockInternalApi = {\n sendApdu: sendApduFn,\n disableRefresher: (_: unknown) => vi.fn(),\n } as unknown as InternalApi;\n taskArgs = { connection: Right(mockWebSocket) };\n task = new ConnectToSecureChannelTask(mockInternalApi, taskArgs);\n });\n\n afterEach(() => {\n vi.resetAllMocks();\n });\n\n it(\"should emit Opened event on WebSocket open\", async () => {\n const events: SecureChannelEvent[] = [];\n const obs = task.run();\n obs.subscribe((e) => events.push(e));\n\n expect(mockWebSocket.onopen).toBeDefined();\n mockWebSocket.onopen!({\n type: \"open\",\n target: {} as WebSocket,\n });\n\n await new Promise((resolve) => setTimeout(resolve, TEST_DELAY));\n\n expect(events).toStrictEqual([{ type: SecureChannelEventType.Opened }]);\n });\n\n it(\"Error on wrongly formatted message\", async () => {\n const events: SecureChannelEvent[] = [];\n const obs = task.run();\n obs.subscribe({\n next: (event) => {\n events.push(event);\n },\n });\n\n expect(mockWebSocket.onmessage).toBeDefined();\n mockWebSocket.onmessage!({\n data: \"invalidData\",\n type: \"\",\n target: {} as WebSocket,\n });\n\n await new Promise((resolve) => setTimeout(resolve, TEST_DELAY));\n\n expect(events).toStrictEqual([\n {\n type: SecureChannelEventType.Error,\n error: new SecureChannelError({\n url: \"wss://test-host.com\",\n errorMessage: \"Invalid message received: invalidData\",\n }),\n },\n ]);\n });\n\n it(\"should handle incoming EXCHANGE message including requesting user permission\", async () => {\n sendApduFn.mockResolvedValue(\n Right({\n data: new Uint8Array([0x90, 0x00]),\n statusCode: new Uint8Array([0x90, 0x00]),\n }),\n );\n\n const sendSpy = vi.spyOn(mockWebSocket, \"send\");\n vi.spyOn(task, \"isSecureConnectionAllowed\").mockReturnValueOnce(false);\n\n const events: SecureChannelEvent[] = [];\n const obs = task.run();\n obs.subscribe({\n next: (event) => {\n events.push(event);\n },\n });\n\n expect(mockWebSocket.onmessage).toBeDefined();\n mockWebSocket.onmessage!({\n data: JSON.stringify({\n ...mockMessage,\n query: \"exchange\",\n nonce: 1,\n data: \"e051000000\",\n }),\n type: \"\",\n target: {} as WebSocket,\n });\n\n await new Promise((resolve) => setTimeout(resolve, TEST_DELAY));\n\n expect(sendSpy).toHaveBeenCalledExactlyOnceWith(\n JSON.stringify({\n nonce: 1,\n response: \"success\",\n data: \"9000\",\n }),\n );\n expect(events).toStrictEqual([\n {\n type: SecureChannelEventType.PreExchange,\n payload: {\n nonce: 1,\n apdu: new Uint8Array([0xe0, 0x51, 0x00, 0x00, 0x00]),\n },\n },\n {\n type: SecureChannelEventType.PermissionRequested,\n },\n {\n type: SecureChannelEventType.Exchange,\n payload: {\n nonce: 1,\n apdu: new Uint8Array([0xe0, 0x51, 0x00, 0x00, 0x00]),\n data: new Uint8Array([0x90, 0x00]),\n status: new Uint8Array([0x90, 0x00]),\n },\n },\n {\n type: SecureChannelEventType.PermissionGranted,\n },\n ]);\n });\n\n it(\"should capture and emit device ID on first GetCertificate APDU\", async () => {\n // Mock response for GetCertificate\n const mockResponse = new Uint8Array([\n 0x07, 0x4a, 0x07, 0xa1, 0x52, 0xe6, 0xbb, 0xc1, 0x41, 0x04, 0x1c, 0x74,\n 0x7a, 0x4e, 0x08, 0x1b, 0x5c, 0x1e, 0xd0, 0x27, 0xfc, 0xaf, 0x80, 0xda,\n 0xda, 0x1f, 0x84, 0xfc, 0x8e, 0x43, 0x60, 0xcb, 0x53, 0xc4, 0xb6, 0x9e,\n 0x63, 0xcb, 0x91, 0xb7, 0xca, 0xd3, 0x15, 0x63, 0x68, 0x59, 0x1b, 0xfb,\n 0x05, 0x8f, 0x72, 0x0f, 0x97, 0xaf, 0xc4, 0x73, 0xf9, 0x78, 0x55, 0xfb,\n 0x96, 0xe4, 0x54, 0xd4, 0x80, 0x18, 0x16, 0x00, 0x34, 0x9f, 0xd8, 0xdc,\n 0x12, 0x51, 0x46, 0x30, 0x44, 0x02, 0x20, 0x7e, 0x3c, 0xdd, 0x1d, 0x15,\n 0x08, 0xf6, 0x8d, 0x16, 0x63, 0x4a, 0x3a, 0x1e, 0xe1, 0x97, 0xc4, 0x50,\n 0xc9, 0x17, 0x65, 0xe5, 0xe2, 0x48, 0x24, 0x17, 0xb2, 0x5e, 0xe3, 0xa0,\n 0x19, 0x81, 0xc8, 0x02, 0x20, 0x59, 0x79, 0x5d, 0x09, 0x29, 0xc7, 0xd8,\n 0x4b, 0xad, 0xad, 0xe5, 0x05, 0x0e, 0x3b, 0x21, 0x19, 0x7d, 0xaa, 0xff,\n 0xa3, 0x29, 0xea, 0x07, 0xd5, 0xb4, 0x29, 0x1c, 0xa6, 0xe9, 0x2a, 0x72,\n 0xd9,\n ]);\n\n sendApduFn.mockResolvedValue(\n Right({\n data: mockResponse,\n statusCode: new Uint8Array([0x90, 0x00]),\n }),\n );\n\n // Mock crypto service\n const mockDeviceId = new Uint8Array([0xaa, 0xbb, 0xcc, 0xdd]);\n const mockCryptoService = {\n sha3_256: vi.fn().mockReturnValue(mockDeviceId),\n };\n\n const taskWithMockCrypto = new ConnectToSecureChannelTask(mockInternalApi, {\n connection: Right(mockWebSocket),\n cryptoService: mockCryptoService,\n });\n\n const events: SecureChannelEvent[] = [];\n const obs = taskWithMockCrypto.run();\n obs.subscribe({\n next: (event) => {\n events.push(event);\n },\n });\n\n expect(mockWebSocket.onmessage).toBeDefined();\n // Send GetCertificate APDU (e052000000)\n mockWebSocket.onmessage!({\n data: JSON.stringify({\n ...mockMessage,\n query: \"exchange\",\n nonce: 1,\n data: \"e052000000\",\n }),\n type: \"\",\n target: {} as WebSocket,\n });\n\n await new Promise((resolve) => setTimeout(resolve, TEST_DELAY));\n\n // Verify the mock crypto service was called\n expect(mockCryptoService.sha3_256).toHaveBeenCalledWith(\n Uint8Array.from([\n 0x04, 0x1c, 0x74, 0x7a, 0x4e, 0x08, 0x1b, 0x5c, 0x1e, 0xd0, 0x27, 0xfc,\n 0xaf, 0x80, 0xda, 0xda, 0x1f, 0x84, 0xfc, 0x8e, 0x43, 0x60, 0xcb, 0x53,\n 0xc4, 0xb6, 0x9e, 0x63, 0xcb, 0x91, 0xb7, 0xca, 0xd3, 0x15, 0x63, 0x68,\n 0x59, 0x1b, 0xfb, 0x05, 0x8f, 0x72, 0x0f, 0x97, 0xaf, 0xc4, 0x73, 0xf9,\n 0x78, 0x55, 0xfb, 0x96, 0xe4, 0x54, 0xd4, 0x80, 0x18, 0x16, 0x00, 0x34,\n 0x9f, 0xd8, 0xdc, 0x12, 0x51,\n ]),\n );\n\n // Verify the device ID from the mock crypto service was emitted\n const deviceIdEvent = events.find(\n (e) => e.type === SecureChannelEventType.DeviceId,\n );\n expect(deviceIdEvent).toBeDefined();\n expect(deviceIdEvent?.payload?.deviceId).toBe(mockDeviceId);\n });\n\n it(\"should handle incoming EXCHANGE message with a device error\", async () => {\n sendApduFn.mockResolvedValue(\n Right({\n data: new Uint8Array([]),\n statusCode: new Uint8Array([0x55, 0x15]),\n }),\n );\n\n const sendSpy = vi.spyOn(mockWebSocket, \"send\");\n const events: SecureChannelEvent[] = [];\n const obs = task.run();\n obs.subscribe({\n next: (event) => {\n events.push(event);\n },\n });\n\n expect(mockWebSocket.onmessage).toBeDefined();\n mockWebSocket.onmessage!({\n data: JSON.stringify({\n ...mockMessage,\n query: \"exchange\",\n nonce: 1,\n data: \"e053000000\",\n }),\n type: \"\",\n target: {} as WebSocket,\n });\n\n await new Promise((resolve) => setTimeout(resolve, TEST_DELAY));\n\n expect(sendSpy).toHaveBeenCalledExactlyOnceWith(\n JSON.stringify({\n nonce: 1,\n response: \"error\",\n data: \"\",\n }),\n );\n expect(events).toStrictEqual([\n {\n type: SecureChannelEventType.PreExchange,\n payload: {\n nonce: 1,\n apdu: new Uint8Array([0xe0, 0x53, 0x00, 0x00, 0x00]),\n },\n },\n {\n type: SecureChannelEventType.Error,\n error: new SecureChannelError(\n {\n url: \"wss://test-host.com\",\n errorMessage: \"Device is locked\",\n },\n SecureChannelErrorType.DeviceLocked,\n ),\n },\n ]);\n });\n\n it(\"should handle incoming BULK message\", async () => {\n sendApduFn.mockResolvedValue(\n Right({\n data: new Uint8Array([0x90, 0x00]),\n statusCode: new Uint8Array([0x90, 0x00]),\n }),\n );\n const completeFn: () => void = vi.fn();\n const obs = task.run();\n const events: SecureChannelEvent[] = [];\n obs.subscribe({\n next: (event: SecureChannelEvent) => {\n events.push(event);\n },\n complete: () => completeFn(),\n });\n\n expect(mockWebSocket.onmessage).toBeDefined();\n mockWebSocket.onmessage!({\n data: JSON.stringify({\n ...mockMessage,\n query: \"bulk\",\n nonce: 1,\n data: [\"0000000100\", \"0000000200\", \"0000000300\"],\n }),\n type: \"\",\n target: {} as WebSocket,\n });\n\n await new Promise((resolve) => setTimeout(resolve, TEST_DELAY));\n\n expect(sendApduFn).toHaveBeenCalledTimes(3);\n expect(events).toStrictEqual([\n {\n type: SecureChannelEventType.Progress,\n payload: { progress: 0.33, index: 0, total: 3 },\n },\n {\n type: SecureChannelEventType.Progress,\n payload: { progress: 0.67, index: 1, total: 3 },\n },\n {\n type: SecureChannelEventType.Progress,\n payload: { progress: 1.0, index: 2, total: 3 },\n },\n ]);\n expect(completeFn).toHaveBeenCalledOnce();\n });\n\n it(\"should handle incoming BULK message with a device error\", async () => {\n sendApduFn.mockResolvedValue(\n Right({\n data: new Uint8Array([]),\n statusCode: new Uint8Array([0x55, 0x01]),\n }),\n );\n const completeFn: () => void = vi.fn();\n const obs = task.run();\n const events: SecureChannelEvent[] = [];\n obs.subscribe({\n next: (event: SecureChannelEvent) => {\n events.push(event);\n },\n complete: () => completeFn(),\n });\n\n expect(mockWebSocket.onmessage).toBeDefined();\n mockWebSocket.onmessage!({\n data: JSON.stringify({\n ...mockMessage,\n query: \"bulk\",\n nonce: 1,\n data: [\"0000000100\", \"0000000200\", \"0000000300\"],\n }),\n type: \"\",\n target: {} as WebSocket,\n });\n\n await new Promise((resolve) => setTimeout(resolve, TEST_DELAY));\n\n expect(sendApduFn).toHaveBeenCalledTimes(1);\n expect(events).toStrictEqual([\n {\n type: SecureChannelEventType.Error,\n error: new SecureChannelError(\n {\n url: \"wss://test-host.com\",\n errorMessage: \"User refused on the device\",\n },\n SecureChannelErrorType.RefusedByUser,\n ),\n },\n ]);\n expect(completeFn).toHaveBeenCalledOnce();\n });\n\n it(\"should handle incoming SUCCESS message\", () => {\n const completeFn: () => void = vi.fn();\n const events: SecureChannelEvent[] = [];\n const observable = task.run();\n observable.subscribe({\n next: (event: SecureChannelEvent) => events.push(event),\n complete: () => completeFn(),\n });\n\n mockWebSocket.onmessage!({\n data: JSON.stringify({\n ...mockMessage,\n query: \"success\",\n nonce: 1,\n result: \"success result\",\n }),\n type: \"\",\n target: {} as WebSocket,\n });\n\n expect(events).toStrictEqual([\n { type: SecureChannelEventType.Result, payload: \"success result\" },\n ]);\n expect(completeFn).toHaveBeenCalledOnce();\n });\n\n it(\"should handle incoming WARNING message\", () => {\n const events: SecureChannelEvent[] = [];\n const observable = task.run();\n observable.subscribe({\n next: (event: SecureChannelEvent) => events.push(event),\n });\n\n expect(mockWebSocket.onmessage).toBeDefined();\n mockWebSocket.onmessage!({\n data: JSON.stringify({\n ...mockMessage,\n query: \"warning\",\n nonce: 1,\n data: \"warning message\",\n }),\n type: \"\",\n target: {} as WebSocket,\n });\n\n expect(events).toStrictEqual([\n {\n type: SecureChannelEventType.Warning,\n payload: { message: \"warning message\" },\n },\n ]);\n });\n\n it(\"should handle incoming ERROR message\", () => {\n const events: SecureChannelEvent[] = [];\n const observable = task.run();\n observable.subscribe({\n next: (event: SecureChannelEvent) => events.push(event),\n });\n\n expect(mockWebSocket.onmessage).toBeDefined();\n mockWebSocket.onmessage!({\n data: JSON.stringify({\n ...mockMessage,\n query: \"error\",\n data: \"My error\",\n }),\n type: \"\",\n target: {} as WebSocket,\n });\n\n expect(events).toStrictEqual([\n {\n type: SecureChannelEventType.Error,\n error: new SecureChannelError({\n url: \"wss://test-host.com\",\n errorMessage: \"My error\",\n }),\n },\n ]);\n });\n});\n"],
|
|
5
|
+
"mappings": "wdAAA,IAAAA,EAAsB,4BACtBC,EAAsB,qBACtBC,EAAiC,kBAGjCC,EAGO,0CACPC,EAGO,iDAEPC,EAGO,wCAEP,KAAG,KAAK,gBAAiB,KAAO,CAC9B,GAAG,KAAG,aAAa,eAAe,EAClC,WAAY,GACZ,QAAS,KAAM,CACb,OAA8B,KAC9B,UAAwD,KACxD,KAAO,KAAG,GAAG,EACb,MAAQ,KAAG,GAAG,EACd,IACA,YAAYC,EAAa,CACvB,KAAK,IAAMA,CACb,CACF,CACF,EAAE,EAEF,MAAMC,EAAa,KAEnB,YAAS,6BAA8B,IAAM,CAC3C,IAAIC,EACAC,EACAC,EACAC,EACJ,M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BAAuB,MAC7B,MAAO,IAAI,qBAAmB,CAC5B,IAAK,sBACL,aAAc,UAChB,CAAC,CACH,CACF,CAAC,CACH,CAAC,CACH,CAAC",
|
|
6
|
+
"names": ["import_isomorphic_ws", "import_purify_ts", "import_vitest", "import_types", "import_Errors", "import_ConnectToSecureChannelTask", "url", "TEST_DELAY", "mockWebSocket", "mockInternalApi", "taskArgs", "task", "sendApduFn", "mockMessage", "WebSocket", "_", "events", "e", "resolve", "event", "sendSpy", "mockResponse", "mockDeviceId", "mockCryptoService", "taskWithMockCrypto", "deviceIdEvent", "completeFn", "obs"]
|
|
7
7
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";var o=Object.defineProperty;var g=Object.getOwnPropertyDescriptor;var u=Object.getOwnPropertyNames;var x=Object.prototype.hasOwnProperty;var P=(n,r)=>{for(var
|
|
1
|
+
"use strict";var o=Object.defineProperty;var g=Object.getOwnPropertyDescriptor;var u=Object.getOwnPropertyNames;var x=Object.prototype.hasOwnProperty;var P=(n,r)=>{for(var a in r)o(n,a,{get:r[a],enumerable:!0})},h=(n,r,a,d)=>{if(r&&typeof r=="object"||typeof r=="function")for(let s of u(r))!x.call(n,s)&&s!==a&&o(n,s,{get:()=>r[s],enumerable:!(d=g(r,s))||d.enumerable});return n};var E=n=>h(o({},"__esModule",{value:!0}),n);var v={};P(v,{InMessageQueryEnum:()=>l,OutMessageResponseEnum:()=>c,SecureChannelEventType:()=>y,SecureChannelOperationEnum:()=>i});module.exports=E(v);var i=(t=>(t.GenuineCheck="GenuineCheck",t.ListInstalledApps="ListInstalledApps",t.UpdateMcu="UpdateMcu",t.UpdateFirmware="UpdateFirmware",t.InstallApp="InstallApp",t.UninstallApp="UninstallApp",t))(i||{}),l=(p=>(p.EXCHANGE="exchange",p.BULK="bulk",p.ERROR="error",p.WARNING="warning",p.SUCCESS="success",p))(l||{}),c=(a=>(a.SUCCESS="success",a.ERROR="error",a))(c||{}),y=(e=>(e.Opened="opened",e.Closed="closed",e.PermissionRequested="permission-requested",e.PermissionGranted="permission-granted",e.PreExchange="pre-exchange",e.Exchange="exchange",e.DeviceId="device-id",e.Progress="progress",e.Warning="warning",e.Error="error",e.Result="result",e))(y||{});0&&(module.exports={InMessageQueryEnum,OutMessageResponseEnum,SecureChannelEventType,SecureChannelOperationEnum});
|
|
2
2
|
//# sourceMappingURL=types.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../../src/api/secure-channel/task/types.ts"],
|
|
4
|
-
"sourcesContent": ["import { type SecureChannelError } from \"@internal/secure-channel/model/Errors\";\n\nexport enum SecureChannelOperationEnum {\n GenuineCheck = \"GenuineCheck\",\n ListInstalledApps = \"ListInstalledApps\",\n UpdateMcu = \"UpdateMcu\",\n UpdateFirmware = \"UpdateFirmware\",\n InstallApp = \"InstallApp\",\n UninstallApp = \"UninstallApp\",\n}\n\n/**\n * The message that will be received from the server by the secure channel.\n */\nexport type InMessageType = {\n uuid: string;\n session: string;\n query: InMessageQueryEnum;\n nonce: number;\n data: unknown;\n result?: unknown;\n};\n\nexport enum InMessageQueryEnum {\n EXCHANGE = \"exchange\",\n BULK = \"bulk\",\n ERROR = \"error\",\n WARNING = \"warning\",\n SUCCESS = \"success\",\n}\n\n/**\n * The message that will be sent to the server by the secure channel.\n */\nexport type OutMessageType = {\n nonce: number;\n response: OutMessageResponseEnum;\n data: string;\n};\n\nexport enum OutMessageResponseEnum {\n SUCCESS = \"success\",\n ERROR = \"error\",\n}\n\n/**\n * The all event types that can be emitted to the client by the secure channel.\n *\n */\nexport enum SecureChannelEventType {\n Opened = \"opened\",\n Closed = \"closed\",\n PermissionRequested = \"permission-requested\",\n PermissionGranted = \"permission-granted\",\n PreExchange = \"pre-exchange\",\n Exchange = \"exchange\",\n Progress = \"progress\",\n Warning = \"warning\",\n Error = \"error\",\n Result = \"result\",\n}\n\n/**\n * The possible payload that will be sent to the client when a secure channel event occurs.\n */\nexport type SecureChannelEventPayload = {\n PreExchange: { nonce: number; apdu: Uint8Array };\n Exchange: {\n nonce: number;\n apdu: Uint8Array;\n data: Uint8Array;\n status: Uint8Array;\n };\n Progress: { progress: number; index: number; total: number };\n Warning: { message: string };\n Result: unknown;\n};\n\n/**\n * The event type that will be emitted to the client when a secure channel event occurs.\n */\nexport type SecureChannelEvent =\n | {\n type: SecureChannelEventType.Opened;\n }\n | {\n type: SecureChannelEventType.Closed;\n }\n | {\n type: SecureChannelEventType.PermissionRequested;\n }\n | {\n type: SecureChannelEventType.PermissionGranted;\n }\n | {\n type: SecureChannelEventType.PreExchange;\n payload: SecureChannelEventPayload[\"PreExchange\"];\n }\n | {\n type: SecureChannelEventType.Exchange;\n payload: SecureChannelEventPayload[\"Exchange\"];\n }\n | {\n type: SecureChannelEventType.Progress;\n payload: SecureChannelEventPayload[\"Progress\"];\n }\n | {\n type: SecureChannelEventType.Warning;\n payload: SecureChannelEventPayload[\"Warning\"];\n }\n | {\n type: SecureChannelEventType.Error;\n error: SecureChannelError;\n }\n | {\n type: SecureChannelEventType.Result;\n payload: SecureChannelEventPayload[\"Result\"];\n };\n"],
|
|
5
|
-
"mappings": "yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,wBAAAE,EAAA,2BAAAC,EAAA,2BAAAC,EAAA,+BAAAC,IAAA,eAAAC,EAAAN,GAEO,IAAKK,OACVA,EAAA,aAAe,eACfA,EAAA,kBAAoB,oBACpBA,EAAA,UAAY,YACZA,EAAA,eAAiB,iBACjBA,EAAA,WAAa,aACbA,EAAA,aAAe,eANLA,OAAA,IAqBAH,OACVA,EAAA,SAAW,WACXA,EAAA,KAAO,OACPA,EAAA,MAAQ,QACRA,EAAA,QAAU,UACVA,EAAA,QAAU,UALAA,OAAA,IAiBAC,OACVA,EAAA,QAAU,UACVA,EAAA,MAAQ,QAFEA,OAAA,IASAC,OACVA,EAAA,OAAS,SACTA,EAAA,OAAS,SACTA,EAAA,oBAAsB,uBACtBA,EAAA,kBAAoB,qBACpBA,EAAA,YAAc,eACdA,EAAA,SAAW,WACXA,EAAA,SAAW,WACXA,EAAA,QAAU,UACVA,EAAA,MAAQ,QACRA,EAAA,OAAS,
|
|
4
|
+
"sourcesContent": ["import { type SecureChannelError } from \"@internal/secure-channel/model/Errors\";\n\nexport enum SecureChannelOperationEnum {\n GenuineCheck = \"GenuineCheck\",\n ListInstalledApps = \"ListInstalledApps\",\n UpdateMcu = \"UpdateMcu\",\n UpdateFirmware = \"UpdateFirmware\",\n InstallApp = \"InstallApp\",\n UninstallApp = \"UninstallApp\",\n}\n\n/**\n * The message that will be received from the server by the secure channel.\n */\nexport type InMessageType = {\n uuid: string;\n session: string;\n query: InMessageQueryEnum;\n nonce: number;\n data: unknown;\n result?: unknown;\n};\n\nexport enum InMessageQueryEnum {\n EXCHANGE = \"exchange\",\n BULK = \"bulk\",\n ERROR = \"error\",\n WARNING = \"warning\",\n SUCCESS = \"success\",\n}\n\n/**\n * The message that will be sent to the server by the secure channel.\n */\nexport type OutMessageType = {\n nonce: number;\n response: OutMessageResponseEnum;\n data: string;\n};\n\nexport enum OutMessageResponseEnum {\n SUCCESS = \"success\",\n ERROR = \"error\",\n}\n\n/**\n * The all event types that can be emitted to the client by the secure channel.\n *\n */\nexport enum SecureChannelEventType {\n Opened = \"opened\",\n Closed = \"closed\",\n PermissionRequested = \"permission-requested\",\n PermissionGranted = \"permission-granted\",\n PreExchange = \"pre-exchange\",\n Exchange = \"exchange\",\n DeviceId = \"device-id\",\n Progress = \"progress\",\n Warning = \"warning\",\n Error = \"error\",\n Result = \"result\",\n}\n\n/**\n * The possible payload that will be sent to the client when a secure channel event occurs.\n */\nexport type SecureChannelEventPayload = {\n PreExchange: { nonce: number; apdu: Uint8Array };\n Exchange: {\n nonce: number;\n apdu: Uint8Array;\n data: Uint8Array;\n status: Uint8Array;\n };\n DeviceId: { deviceId: Uint8Array };\n Progress: { progress: number; index: number; total: number };\n Warning: { message: string };\n Result: unknown;\n};\n\n/**\n * The event type that will be emitted to the client when a secure channel event occurs.\n */\nexport type SecureChannelEvent =\n | {\n type: SecureChannelEventType.Opened;\n }\n | {\n type: SecureChannelEventType.Closed;\n }\n | {\n type: SecureChannelEventType.PermissionRequested;\n }\n | {\n type: SecureChannelEventType.PermissionGranted;\n }\n | {\n type: SecureChannelEventType.PreExchange;\n payload: SecureChannelEventPayload[\"PreExchange\"];\n }\n | {\n type: SecureChannelEventType.Exchange;\n payload: SecureChannelEventPayload[\"Exchange\"];\n }\n | {\n type: SecureChannelEventType.DeviceId;\n payload: SecureChannelEventPayload[\"DeviceId\"];\n }\n | {\n type: SecureChannelEventType.Progress;\n payload: SecureChannelEventPayload[\"Progress\"];\n }\n | {\n type: SecureChannelEventType.Warning;\n payload: SecureChannelEventPayload[\"Warning\"];\n }\n | {\n type: SecureChannelEventType.Error;\n error: SecureChannelError;\n }\n | {\n type: SecureChannelEventType.Result;\n payload: SecureChannelEventPayload[\"Result\"];\n };\n"],
|
|
5
|
+
"mappings": "yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,wBAAAE,EAAA,2BAAAC,EAAA,2BAAAC,EAAA,+BAAAC,IAAA,eAAAC,EAAAN,GAEO,IAAKK,OACVA,EAAA,aAAe,eACfA,EAAA,kBAAoB,oBACpBA,EAAA,UAAY,YACZA,EAAA,eAAiB,iBACjBA,EAAA,WAAa,aACbA,EAAA,aAAe,eANLA,OAAA,IAqBAH,OACVA,EAAA,SAAW,WACXA,EAAA,KAAO,OACPA,EAAA,MAAQ,QACRA,EAAA,QAAU,UACVA,EAAA,QAAU,UALAA,OAAA,IAiBAC,OACVA,EAAA,QAAU,UACVA,EAAA,MAAQ,QAFEA,OAAA,IASAC,OACVA,EAAA,OAAS,SACTA,EAAA,OAAS,SACTA,EAAA,oBAAsB,uBACtBA,EAAA,kBAAoB,qBACpBA,EAAA,YAAc,eACdA,EAAA,SAAW,WACXA,EAAA,SAAW,YACXA,EAAA,SAAW,WACXA,EAAA,QAAU,UACVA,EAAA,MAAQ,QACRA,EAAA,OAAS,SAXCA,OAAA",
|
|
6
6
|
"names": ["types_exports", "__export", "InMessageQueryEnum", "OutMessageResponseEnum", "SecureChannelEventType", "SecureChannelOperationEnum", "__toCommonJS"]
|
|
7
7
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";var
|
|
1
|
+
"use strict";var i=Object.defineProperty;var c=Object.getOwnPropertyDescriptor;var a=Object.getOwnPropertyNames;var p=Object.prototype.hasOwnProperty;var s=(e,r)=>{for(var t in r)i(e,t,{get:r[t],enumerable:!0})},d=(e,r,t,o)=>{if(r&&typeof r=="object"||typeof r=="function")for(let n of a(r))!p.call(e,n)&&n!==t&&i(e,n,{get:()=>r[n],enumerable:!(o=c(r,n))||o.enumerable});return e};var x=e=>d(i({},"__esModule",{value:!0}),e);var A={};s(A,{extractPublicKey:()=>m,isDeviceGenuine:()=>E,isGetCertificateApdu:()=>f,willRequestPermission:()=>y});module.exports=x(A);var u=require("../apdu/utils/ApduParser"),l=require("../secure-channel/constants");function y(e){return e[0]===224&&e[1]===81}function f(e){return e[0]===224&&e[1]===82}function m(e){try{const r=new u.ApduParser(e);return r.extractFieldLVEncoded()?r.extractFieldLVEncoded()??null:null}catch{return null}}function E(e){return e===l.GENUINE_DEVICE_RESULT}0&&(module.exports={extractPublicKey,isDeviceGenuine,isGetCertificateApdu,willRequestPermission});
|
|
2
2
|
//# sourceMappingURL=utils.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../src/api/secure-channel/utils.ts"],
|
|
4
|
-
"sourcesContent": ["import { type
|
|
5
|
-
"mappings": "yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,
|
|
6
|
-
"names": ["utils_exports", "__export", "isDeviceGenuine", "willRequestPermission", "__toCommonJS", "import_constants", "apdu", "payload"]
|
|
4
|
+
"sourcesContent": ["import { ApduParser } from \"@api/apdu/utils/ApduParser\";\nimport { type ApduResponse } from \"@api/device-session/ApduResponse\";\nimport { GENUINE_DEVICE_RESULT } from \"@api/secure-channel/constants\";\nimport { type SecureChannelEventPayload } from \"@api/secure-channel/task/types\";\n\n/**\n * Checks if the given APDU command will request permission.\n *\n * This method checks if the first byte of the APDU command is `0xe0` and the second byte is `0x51`.\n *\n * @param apdu - The APDU command as a Uint8Array.\n * @returns `true` if the APDU command will request permission, otherwise `false`.\n */\nexport function willRequestPermission(apdu: Uint8Array): boolean {\n return apdu[0] === 0xe0 && apdu[1] === 0x51;\n}\n\n/**\n * Checks if the given APDU command is a GetCertificate command.\n *\n * This method checks if the first byte of the APDU command is `0xe0` and the second byte is `0x52`.\n *\n * @param apdu - The APDU command as a Uint8Array.\n * @returns `true` if the APDU command is a GetCertificate command, otherwise `false`.\n */\nexport function isGetCertificateApdu(apdu: Uint8Array): boolean {\n return apdu[0] === 0xe0 && apdu[1] === 0x52;\n}\n\n/**\n * Extract the public key from a GetCertificate response.\n *\n * @param apduResponse - The APDU response containing the certificate data.\n * @returns The extracted public key as a Uint8Array, or null if extraction fails.\n */\nexport function extractPublicKey(\n apduResponse: ApduResponse,\n): Uint8Array | null {\n try {\n const parser = new ApduParser(apduResponse);\n\n // Skip header (length-value encoded)\n const header = parser.extractFieldLVEncoded();\n if (!header) {\n return null;\n }\n\n // Extract public key (length-value encoded)\n const publicKey = parser.extractFieldLVEncoded();\n return publicKey ?? null;\n } catch (_error) {\n return null;\n }\n}\n\n/**\n * Checks if the device is genuine.\n *\n * @param payload - The payload of the result secure channel event.\n * The payload has already been stringified, so that the type check is not necessary.\n * @returns `true` if the device is genuine, otherwise `false`.\n */\nexport function isDeviceGenuine(payload: SecureChannelEventPayload[\"Result\"]) {\n return payload === GENUINE_DEVICE_RESULT;\n}\n"],
|
|
5
|
+
"mappings": "yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,sBAAAE,EAAA,oBAAAC,EAAA,yBAAAC,EAAA,0BAAAC,IAAA,eAAAC,EAAAN,GAAA,IAAAO,EAA2B,sCAE3BC,EAAsC,yCAW/B,SAASH,EAAsBI,EAA2B,CAC/D,OAAOA,EAAK,CAAC,IAAM,KAAQA,EAAK,CAAC,IAAM,EACzC,CAUO,SAASL,EAAqBK,EAA2B,CAC9D,OAAOA,EAAK,CAAC,IAAM,KAAQA,EAAK,CAAC,IAAM,EACzC,CAQO,SAASP,EACdQ,EACmB,CACnB,GAAI,CACF,MAAMC,EAAS,IAAI,aAAWD,CAAY,EAI1C,OADeC,EAAO,sBAAsB,EAM1BA,EAAO,sBAAsB,GAC3B,KALX,IAMX,MAAiB,CACf,OAAO,IACT,CACF,CASO,SAASR,EAAgBS,EAA8C,CAC5E,OAAOA,IAAY,uBACrB",
|
|
6
|
+
"names": ["utils_exports", "__export", "extractPublicKey", "isDeviceGenuine", "isGetCertificateApdu", "willRequestPermission", "__toCommonJS", "import_ApduParser", "import_constants", "apdu", "apduResponse", "parser", "payload"]
|
|
7
7
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";var e=require("./utils");describe("willRequestPermission",()=>{it("should return true if the APDU is a permission request",()=>{const
|
|
1
|
+
"use strict";var n=require("../device-session/ApduResponse"),e=require("./utils");describe("willRequestPermission",()=>{it("should return true if the APDU is a permission request",()=>{const x=new Uint8Array([224,81,0,0,0]);expect((0,e.willRequestPermission)(x)).toBe(!0)}),it("should return false if the APDU is not a permission request",()=>{const x=new Uint8Array([224,82,0,0,0]);expect((0,e.willRequestPermission)(x)).toBe(!1)})});describe("isGetCertificateApdu",()=>{it("should return true if the APDU is a GetCertificate command",()=>{const x=new Uint8Array([224,82,0,0,0]);expect((0,e.isGetCertificateApdu)(x)).toBe(!0)}),it("should return true for GetCertificate with different P1 and P2",()=>{const x=new Uint8Array([224,82,128,1,0]);expect((0,e.isGetCertificateApdu)(x)).toBe(!0)}),it("should return false if the APDU is not a GetCertificate command",()=>{const x=new Uint8Array([224,81,0,0,0]);expect((0,e.isGetCertificateApdu)(x)).toBe(!1)})});describe("extractPublicKey",()=>{it("should extract public key from a valid GetCertificate response",()=>{const x=new Uint8Array([7,74,7,161,82,230,187,193,65,4,28,116,122,78,8,27,92,30,208,39,252,175,128,218,218,31,132,252,142,67,96,203,83,196,182,158,99,203,145,183,202,211,21,99,104,89,27,251,5,143,114,15,151,175,196,115,249,120,85,251,150,228,84,212,128,24,22,0,52,159,216,220,18,81,70,48,68,2,32,126,60,221,29,21,8,246,141,22,99,74,58,30,225,151,196,80,201,23,101,229,226,72,36,23,178,94,227,160,25,129,200,2,32,89,121,93,9,41,199,216,75,173,173,229,5,14,59,33,25,125,170,255,163,41,234,7,213,180,41,28,166,233,42,114,217]),i=new n.ApduResponse({statusCode:new Uint8Array([144,0]),data:x}),t=(0,e.extractPublicKey)(i);expect(t).not.toBeNull(),expect(t?.length).toBe(65),expect(t?.[0]).toBe(4),expect(t?.[64]).toBe(81)}),it("should return null for invalid response with missing header",()=>{const x=new n.ApduResponse({statusCode:new Uint8Array([144,0]),data:new Uint8Array([])}),i=(0,e.extractPublicKey)(x);expect(i).toBeNull()}),it("should return null for invalid response with missing public key",()=>{const x=new Uint8Array([7,74,7,161,82,230,187,193]),i=new n.ApduResponse({statusCode:new Uint8Array([144,0]),data:x}),t=(0,e.extractPublicKey)(i);expect(t).toBeNull()})});describe("isDeviceGenuine",()=>{it("should return true if the device is genuine",()=>{expect((0,e.isDeviceGenuine)("0000")).toBe(!0)}),it("should return false if the device is not genuine",()=>{expect((0,e.isDeviceGenuine)("not genuine")).toBe(!1)})});
|
|
2
2
|
//# sourceMappingURL=utils.test.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../src/api/secure-channel/utils.test.ts"],
|
|
4
|
-
"sourcesContent": ["import { isDeviceGenuine
|
|
5
|
-
"mappings": "aAAA,IAAAA,
|
|
6
|
-
"names": ["import_utils", "apdu"]
|
|
4
|
+
"sourcesContent": ["import { ApduResponse } from \"@api/device-session/ApduResponse\";\n\nimport {\n extractPublicKey,\n isDeviceGenuine,\n isGetCertificateApdu,\n willRequestPermission,\n} from \"./utils\";\n\ndescribe(\"willRequestPermission\", () => {\n it(\"should return true if the APDU is a permission request\", () => {\n const apdu = new Uint8Array([0xe0, 0x51, 0x00, 0x00, 0x00]);\n expect(willRequestPermission(apdu)).toBe(true);\n });\n it(\"should return false if the APDU is not a permission request\", () => {\n const apdu = new Uint8Array([0xe0, 0x52, 0x00, 0x00, 0x00]);\n expect(willRequestPermission(apdu)).toBe(false);\n });\n});\n\ndescribe(\"isGetCertificateApdu\", () => {\n it(\"should return true if the APDU is a GetCertificate command\", () => {\n const apdu = new Uint8Array([0xe0, 0x52, 0x00, 0x00, 0x00]);\n expect(isGetCertificateApdu(apdu)).toBe(true);\n });\n it(\"should return true for GetCertificate with different P1 and P2\", () => {\n const apdu = new Uint8Array([0xe0, 0x52, 0x80, 0x01, 0x00]);\n expect(isGetCertificateApdu(apdu)).toBe(true);\n });\n it(\"should return false if the APDU is not a GetCertificate command\", () => {\n const apdu = new Uint8Array([0xe0, 0x51, 0x00, 0x00, 0x00]);\n expect(isGetCertificateApdu(apdu)).toBe(false);\n });\n});\n\ndescribe(\"extractPublicKey\", () => {\n it(\"should extract public key from a valid GetCertificate response\", () => {\n const responseData = new Uint8Array([\n 0x07, 0x4a, 0x07, 0xa1, 0x52, 0xe6, 0xbb, 0xc1, 0x41, 0x04, 0x1c, 0x74,\n 0x7a, 0x4e, 0x08, 0x1b, 0x5c, 0x1e, 0xd0, 0x27, 0xfc, 0xaf, 0x80, 0xda,\n 0xda, 0x1f, 0x84, 0xfc, 0x8e, 0x43, 0x60, 0xcb, 0x53, 0xc4, 0xb6, 0x9e,\n 0x63, 0xcb, 0x91, 0xb7, 0xca, 0xd3, 0x15, 0x63, 0x68, 0x59, 0x1b, 0xfb,\n 0x05, 0x8f, 0x72, 0x0f, 0x97, 0xaf, 0xc4, 0x73, 0xf9, 0x78, 0x55, 0xfb,\n 0x96, 0xe4, 0x54, 0xd4, 0x80, 0x18, 0x16, 0x00, 0x34, 0x9f, 0xd8, 0xdc,\n 0x12, 0x51, 0x46, 0x30, 0x44, 0x02, 0x20, 0x7e, 0x3c, 0xdd, 0x1d, 0x15,\n 0x08, 0xf6, 0x8d, 0x16, 0x63, 0x4a, 0x3a, 0x1e, 0xe1, 0x97, 0xc4, 0x50,\n 0xc9, 0x17, 0x65, 0xe5, 0xe2, 0x48, 0x24, 0x17, 0xb2, 0x5e, 0xe3, 0xa0,\n 0x19, 0x81, 0xc8, 0x02, 0x20, 0x59, 0x79, 0x5d, 0x09, 0x29, 0xc7, 0xd8,\n 0x4b, 0xad, 0xad, 0xe5, 0x05, 0x0e, 0x3b, 0x21, 0x19, 0x7d, 0xaa, 0xff,\n 0xa3, 0x29, 0xea, 0x07, 0xd5, 0xb4, 0x29, 0x1c, 0xa6, 0xe9, 0x2a, 0x72,\n 0xd9,\n ]);\n\n const response = new ApduResponse({\n statusCode: new Uint8Array([0x90, 0x00]),\n data: responseData,\n });\n\n const publicKey = extractPublicKey(response);\n\n expect(publicKey).not.toBeNull();\n expect(publicKey?.length).toBe(65);\n expect(publicKey?.[0]).toBe(0x04);\n expect(publicKey?.[64]).toBe(0x51);\n });\n\n it(\"should return null for invalid response with missing header\", () => {\n const response = new ApduResponse({\n statusCode: new Uint8Array([0x90, 0x00]),\n data: new Uint8Array([]),\n });\n\n const publicKey = extractPublicKey(response);\n\n expect(publicKey).toBeNull();\n });\n\n it(\"should return null for invalid response with missing public key\", () => {\n const responseData = new Uint8Array([\n 0x07, 0x4a, 0x07, 0xa1, 0x52, 0xe6, 0xbb, 0xc1,\n ]);\n\n const response = new ApduResponse({\n statusCode: new Uint8Array([0x90, 0x00]),\n data: responseData,\n });\n\n const publicKey = extractPublicKey(response);\n\n expect(publicKey).toBeNull();\n });\n});\n\ndescribe(\"isDeviceGenuine\", () => {\n it(\"should return true if the device is genuine\", () => {\n const payload = \"0000\";\n expect(isDeviceGenuine(payload)).toBe(true);\n });\n it(\"should return false if the device is not genuine\", () => {\n const payload = \"not genuine\";\n expect(isDeviceGenuine(payload)).toBe(false);\n });\n});\n"],
|
|
5
|
+
"mappings": "aAAA,IAAAA,EAA6B,4CAE7BC,EAKO,mBAEP,SAAS,wBAAyB,IAAM,CACtC,GAAG,yDAA0D,IAAM,CACjE,MAAMC,EAAO,IAAI,WAAW,CAAC,IAAM,GAAM,EAAM,EAAM,CAAI,CAAC,EAC1D,UAAO,yBAAsBA,CAAI,CAAC,EAAE,KAAK,EAAI,CAC/C,CAAC,EACD,GAAG,8DAA+D,IAAM,CACtE,MAAMA,EAAO,IAAI,WAAW,CAAC,IAAM,GAAM,EAAM,EAAM,CAAI,CAAC,EAC1D,UAAO,yBAAsBA,CAAI,CAAC,EAAE,KAAK,EAAK,CAChD,CAAC,CACH,CAAC,EAED,SAAS,uBAAwB,IAAM,CACrC,GAAG,6DAA8D,IAAM,CACrE,MAAMA,EAAO,IAAI,WAAW,CAAC,IAAM,GAAM,EAAM,EAAM,CAAI,CAAC,EAC1D,UAAO,wBAAqBA,CAAI,CAAC,EAAE,KAAK,EAAI,CAC9C,CAAC,EACD,GAAG,iEAAkE,IAAM,CACzE,MAAMA,EAAO,IAAI,WAAW,CAAC,IAAM,GAAM,IAAM,EAAM,CAAI,CAAC,EAC1D,UAAO,wBAAqBA,CAAI,CAAC,EAAE,KAAK,EAAI,CAC9C,CAAC,EACD,GAAG,kEAAmE,IAAM,CAC1E,MAAMA,EAAO,IAAI,WAAW,CAAC,IAAM,GAAM,EAAM,EAAM,CAAI,CAAC,EAC1D,UAAO,wBAAqBA,CAAI,CAAC,EAAE,KAAK,EAAK,CAC/C,CAAC,CACH,CAAC,EAED,SAAS,mBAAoB,IAAM,CACjC,GAAG,iEAAkE,IAAM,CACzE,MAAMC,EAAe,IAAI,WAAW,CAClC,EAAM,GAAM,EAAM,IAAM,GAAM,IAAM,IAAM,IAAM,GAAM,EAAM,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AAI,CAAC,EACvC,KAAM,IAAI,WAAW,CAAC,CAAC,CACzB,CAAC,EAEKC,KAAY,oBAAiBD,CAAQ,EAE3C,OAAOC,CAAS,EAAE,SAAS,CAC7B,CAAC,EAED,GAAG,kEAAmE,IAAM,CAC1E,MAAMF,EAAe,IAAI,WAAW,CAClC,EAAM,GAAM,EAAM,IAAM,GAAM,IAAM,IAAM,GAC5C,CAAC,EAEKC,EAAW,IAAI,eAAa,CAChC,WAAY,IAAI,WAAW,CAAC,IAAM,CAAI,CAAC,EACvC,KAAMD,CACR,CAAC,EAEKE,KAAY,oBAAiBD,CAAQ,EAE3C,OAAOC,CAAS,EAAE,SAAS,CAC7B,CAAC,CACH,CAAC,EAED,SAAS,kBAAmB,IAAM,CAChC,GAAG,8CAA+C,IAAM,CAEtD,UAAO,mBADS,MACc,CAAC,EAAE,KAAK,EAAI,CAC5C,CAAC,EACD,GAAG,mDAAoD,IAAM,CAE3D,UAAO,mBADS,aACc,CAAC,EAAE,KAAK,EAAK,CAC7C,CAAC,CACH,CAAC",
|
|
6
|
+
"names": ["import_ApduResponse", "import_utils", "apdu", "responseData", "response", "publicKey"]
|
|
7
7
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";var
|
|
1
|
+
"use strict";var r=Object.defineProperty;var p=Object.getOwnPropertyDescriptor;var l=Object.getOwnPropertyNames;var a=Object.prototype.hasOwnProperty;var y=(o,e)=>{for(var t in e)r(o,t,{get:e[t],enumerable:!0})},v=(o,e,t,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of l(e))!a.call(o,n)&&n!==t&&r(o,n,{get:()=>e[n],enumerable:!(i=p(e,n))||i.enumerable});return o};var D=o=>v(r({},"__esModule",{value:!0}),o);var m={};y(m,{ConnectedDevice:()=>I});module.exports=D(m);class I{id;sessionId;modelId;name;type;transport;constructor({transportConnectedDevice:{id:e,deviceModel:{id:t,productName:i},type:n,transport:d,name:s},sessionId:c}){this.id=e,this.sessionId=c,this.modelId=t,this.name=s??i,this.type=n,this.transport=d}}0&&(module.exports={ConnectedDevice});
|
|
2
2
|
//# sourceMappingURL=ConnectedDevice.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../../src/api/transport/model/ConnectedDevice.ts"],
|
|
4
|
-
"sourcesContent": ["import { type DeviceId, type DeviceModelId } from \"@api/device/DeviceModel\";\nimport { type ConnectionType } from \"@api/discovery/ConnectionType\";\nimport { type TransportConnectedDevice } from \"@api/transport/model/TransportConnectedDevice\";\nimport { type DeviceSessionId } from \"@api/types\";\n\ntype ConnectedDeviceConstructorArgs = {\n readonly sessionId: DeviceSessionId;\n readonly transportConnectedDevice: TransportConnectedDevice;\n};\n\nexport class ConnectedDevice {\n public readonly id: DeviceId;\n public readonly sessionId: DeviceSessionId;\n public readonly modelId: DeviceModelId;\n public readonly name: string;\n public readonly type: ConnectionType;\n\n constructor({\n transportConnectedDevice: {\n id,\n deviceModel: { id: deviceModelId, productName
|
|
5
|
-
"mappings": "yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,qBAAAE,IAAA,eAAAC,EAAAH,GAUO,MAAME,CAAgB,CACX,GACA,UACA,QACA,KACA,
|
|
6
|
-
"names": ["ConnectedDevice_exports", "__export", "ConnectedDevice", "__toCommonJS", "id", "deviceModelId", "
|
|
4
|
+
"sourcesContent": ["import { type DeviceId, type DeviceModelId } from \"@api/device/DeviceModel\";\nimport { type ConnectionType } from \"@api/discovery/ConnectionType\";\nimport { type TransportConnectedDevice } from \"@api/transport/model/TransportConnectedDevice\";\nimport { type DeviceSessionId, type TransportIdentifier } from \"@api/types\";\n\ntype ConnectedDeviceConstructorArgs = {\n readonly sessionId: DeviceSessionId;\n readonly transportConnectedDevice: TransportConnectedDevice;\n};\n\nexport class ConnectedDevice {\n public readonly id: DeviceId;\n public readonly sessionId: DeviceSessionId;\n public readonly modelId: DeviceModelId;\n public readonly name: string;\n public readonly type: ConnectionType;\n public readonly transport: TransportIdentifier;\n\n constructor({\n transportConnectedDevice: {\n id,\n deviceModel: { id: deviceModelId, productName },\n type,\n transport,\n name,\n },\n sessionId,\n }: ConnectedDeviceConstructorArgs) {\n this.id = id;\n this.sessionId = sessionId;\n this.modelId = deviceModelId;\n this.name = name ?? productName;\n this.type = type;\n this.transport = transport;\n }\n}\n"],
|
|
5
|
+
"mappings": "yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,qBAAAE,IAAA,eAAAC,EAAAH,GAUO,MAAME,CAAgB,CACX,GACA,UACA,QACA,KACA,KACA,UAEhB,YAAY,CACV,yBAA0B,CACxB,GAAAE,EACA,YAAa,CAAE,GAAIC,EAAe,YAAAC,CAAY,EAC9C,KAAAC,EACA,UAAAC,EACA,KAAAC,CACF,EACA,UAAAC,CACF,EAAmC,CACjC,KAAK,GAAKN,EACV,KAAK,UAAYM,EACjB,KAAK,QAAUL,EACf,KAAK,KAAOI,GAAQH,EACpB,KAAK,KAAOC,EACZ,KAAK,UAAYC,CACnB,CACF",
|
|
6
|
+
"names": ["ConnectedDevice_exports", "__export", "ConnectedDevice", "__toCommonJS", "id", "deviceModelId", "productName", "type", "transport", "name", "sessionId"]
|
|
7
7
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";var p=Object.defineProperty;var
|
|
1
|
+
"use strict";var p=Object.defineProperty;var c=Object.getOwnPropertyDescriptor;var s=Object.getOwnPropertyNames;var y=Object.prototype.hasOwnProperty;var a=(t,e)=>{for(var r in e)p(t,r,{get:e[r],enumerable:!0})},l=(t,e,r,o)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of s(e))!y.call(t,n)&&n!==r&&p(t,n,{get:()=>e[n],enumerable:!(o=c(e,n))||o.enumerable});return t};var u=t=>l(p({},"__esModule",{value:!0}),t);var T={};a(T,{TransportConnectedDevice:()=>m});module.exports=u(T);class m{id;deviceModel;sendApdu;type;transport;name;constructor({id:e,deviceModel:r,type:o,transport:n,sendApdu:i,name:d}){this.id=e,this.deviceModel=r,this.sendApdu=i,this.type=o,this.transport=n,this.name=d}}0&&(module.exports={TransportConnectedDevice});
|
|
2
2
|
//# sourceMappingURL=TransportConnectedDevice.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../../src/api/transport/model/TransportConnectedDevice.ts"],
|
|
4
|
-
"sourcesContent": ["import { type DeviceId } from \"@api/device/DeviceModel\";\nimport { type TransportDeviceModel } from \"@api/device-model/model/DeviceModel\";\nimport { type ConnectionType } from \"@api/discovery/ConnectionType\";\nimport { type SendApduFnType } from \"@api/transport/model/DeviceConnection\";\nimport { type TransportIdentifier } from \"@api/transport/model/TransportIdentifier\";\n\n/**\n * The internal connected device.\n */\nexport type ConnectedDeviceConstructorArgs = {\n id: DeviceId;\n deviceModel: TransportDeviceModel;\n type: ConnectionType;\n transport: TransportIdentifier;\n sendApdu: SendApduFnType;\n};\n\nexport class TransportConnectedDevice {\n public readonly id: DeviceId;\n public readonly deviceModel: TransportDeviceModel;\n public readonly sendApdu: SendApduFnType;\n public readonly type: ConnectionType;\n public readonly transport: TransportIdentifier;\n\n constructor({\n id,\n deviceModel,\n type,\n transport,\n sendApdu,\n }: ConnectedDeviceConstructorArgs) {\n this.id = id;\n this.deviceModel = deviceModel;\n this.sendApdu = sendApdu;\n this.type = type;\n this.transport = transport;\n }\n}\n"],
|
|
5
|
-
"mappings": "yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,8BAAAE,IAAA,eAAAC,EAAAH,
|
|
6
|
-
"names": ["TransportConnectedDevice_exports", "__export", "TransportConnectedDevice", "__toCommonJS", "id", "deviceModel", "type", "transport", "sendApdu"]
|
|
4
|
+
"sourcesContent": ["import { type DeviceId } from \"@api/device/DeviceModel\";\nimport { type TransportDeviceModel } from \"@api/device-model/model/DeviceModel\";\nimport { type ConnectionType } from \"@api/discovery/ConnectionType\";\nimport { type SendApduFnType } from \"@api/transport/model/DeviceConnection\";\nimport { type TransportIdentifier } from \"@api/transport/model/TransportIdentifier\";\n\n/**\n * The internal connected device.\n */\nexport type ConnectedDeviceConstructorArgs = {\n id: DeviceId;\n deviceModel: TransportDeviceModel;\n type: ConnectionType;\n transport: TransportIdentifier;\n sendApdu: SendApduFnType;\n name?: string;\n};\n\nexport class TransportConnectedDevice {\n public readonly id: DeviceId;\n public readonly deviceModel: TransportDeviceModel;\n public readonly sendApdu: SendApduFnType;\n public readonly type: ConnectionType;\n public readonly transport: TransportIdentifier;\n public readonly name?: string;\n\n constructor({\n id,\n deviceModel,\n type,\n transport,\n sendApdu,\n name,\n }: ConnectedDeviceConstructorArgs) {\n this.id = id;\n this.deviceModel = deviceModel;\n this.sendApdu = sendApdu;\n this.type = type;\n this.transport = transport;\n this.name = name;\n }\n}\n"],
|
|
5
|
+
"mappings": "yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,8BAAAE,IAAA,eAAAC,EAAAH,GAkBO,MAAME,CAAyB,CACpB,GACA,YACA,SACA,KACA,UACA,KAEhB,YAAY,CACV,GAAAE,EACA,YAAAC,EACA,KAAAC,EACA,UAAAC,EACA,SAAAC,EACA,KAAAC,CACF,EAAmC,CACjC,KAAK,GAAKL,EACV,KAAK,YAAcC,EACnB,KAAK,SAAWG,EAChB,KAAK,KAAOF,EACZ,KAAK,UAAYC,EACjB,KAAK,KAAOE,CACd,CACF",
|
|
6
|
+
"names": ["TransportConnectedDevice_exports", "__export", "TransportConnectedDevice", "__toCommonJS", "id", "deviceModel", "type", "transport", "sendApdu", "name"]
|
|
7
7
|
}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use strict";var i=Object.defineProperty;var y=Object.getOwnPropertyDescriptor;var c=Object.getOwnPropertyNames;var o=Object.prototype.hasOwnProperty;var p=(a,r,n,e)=>{if(r&&typeof r=="object"||typeof r=="function")for(let t of c(r))!o.call(a,t)&&t!==n&&i(a,t,{get:()=>r[t],enumerable:!(e=y(r,t))||e.enumerable});return a};var A=a=>p(i({},"__esModule",{value:!0}),a);var U={};module.exports=A(U);
|
|
2
|
+
//# sourceMappingURL=CryptoService.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../../src/internal/crypto/CryptoService.ts"],
|
|
4
|
+
"sourcesContent": ["/**\n * Simple crypto service abstraction for hashing operations\n */\nexport interface CryptoService {\n /**\n * Compute SHA3-256 hash of the input data\n * @param data - The input data to hash\n * @returns The SHA3-256 hash as a Uint8Array (32 bytes)\n */\n sha3_256(data: Uint8Array): Uint8Array;\n}\n"],
|
|
5
|
+
"mappings": "+WAAA,IAAAA,EAAA,kBAAAC,EAAAD",
|
|
6
|
+
"names": ["CryptoService_exports", "__toCommonJS"]
|
|
7
|
+
}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use strict";var i=Object.defineProperty;var y=Object.getOwnPropertyDescriptor;var a=Object.getOwnPropertyNames;var s=Object.prototype.hasOwnProperty;var c=(e,r)=>{for(var o in r)i(e,o,{get:r[o],enumerable:!0})},n=(e,r,o,p)=>{if(r&&typeof r=="object"||typeof r=="function")for(let t of a(r))!s.call(e,t)&&t!==o&&i(e,t,{get:()=>r[t],enumerable:!(p=y(r,t))||p.enumerable});return e};var l=e=>n(i({},"__esModule",{value:!0}),e);var C={};c(C,{NobleCryptoService:()=>v});module.exports=l(C);var m=require("@noble/hashes/sha3");class v{sha3_256(r){return(0,m.sha3_256)(r)}}0&&(module.exports={NobleCryptoService});
|
|
2
|
+
//# sourceMappingURL=NobleCryptoService.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../../src/internal/crypto/NobleCryptoService.ts"],
|
|
4
|
+
"sourcesContent": ["import { sha3_256 } from \"@noble/hashes/sha3\";\n\nimport { type CryptoService } from \"./CryptoService\";\n\n/**\n * Noble implementation of the crypto service\n */\nexport class NobleCryptoService implements CryptoService {\n sha3_256(data: Uint8Array): Uint8Array {\n return sha3_256(data);\n }\n}\n"],
|
|
5
|
+
"mappings": "yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,wBAAAE,IAAA,eAAAC,EAAAH,GAAA,IAAAI,EAAyB,8BAOlB,MAAMF,CAA4C,CACvD,SAASG,EAA8B,CACrC,SAAO,YAASA,CAAI,CACtB,CACF",
|
|
6
|
+
"names": ["NobleCryptoService_exports", "__export", "NobleCryptoService", "__toCommonJS", "import_sha3", "data"]
|
|
7
|
+
}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use strict";var e=require("./NobleCryptoService");describe("NobleCryptoService",()=>{let x;beforeEach(()=>{x=new e.NobleCryptoService}),describe("sha3_256",()=>{it("should compute SHA3-256 hash",()=>{const r=new Uint8Array([1,2,3,4]),c=x.sha3_256(r);expect(c).toStrictEqual(new Uint8Array([150,109,189,203,208,224,52,143,170,28,203,206,90,98,184,231,59,13,8,149,93,102,109,184,34,67,179,3,217,189,149,2]))})})});
|
|
2
|
+
//# sourceMappingURL=NobleCryptoService.test.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../../src/internal/crypto/NobleCryptoService.test.ts"],
|
|
4
|
+
"sourcesContent": ["import { NobleCryptoService } from \"./NobleCryptoService\";\n\ndescribe(\"NobleCryptoService\", () => {\n let cryptoService: NobleCryptoService;\n\n beforeEach(() => {\n cryptoService = new NobleCryptoService();\n });\n\n describe(\"sha3_256\", () => {\n it(\"should compute SHA3-256 hash\", () => {\n const input = new Uint8Array([0x01, 0x02, 0x03, 0x04]);\n const hash = cryptoService.sha3_256(input);\n\n expect(hash).toStrictEqual(\n new Uint8Array([\n 0x96, 0x6d, 0xbd, 0xcb, 0xd0, 0xe0, 0x34, 0x8f, 0xaa, 0x1c, 0xcb,\n 0xce, 0x5a, 0x62, 0xb8, 0xe7, 0x3b, 0x0d, 0x08, 0x95, 0x5d, 0x66,\n 0x6d, 0xb8, 0x22, 0x43, 0xb3, 0x03, 0xd9, 0xbd, 0x95, 0x02,\n ]),\n );\n });\n });\n});\n"],
|
|
5
|
+
"mappings": "aAAA,IAAAA,EAAmC,gCAEnC,SAAS,qBAAsB,IAAM,CACnC,IAAIC,EAEJ,WAAW,IAAM,CACfA,EAAgB,IAAI,oBACtB,CAAC,EAED,SAAS,WAAY,IAAM,CACzB,GAAG,+BAAgC,IAAM,CACvC,MAAMC,EAAQ,IAAI,WAAW,CAAC,EAAM,EAAM,EAAM,CAAI,CAAC,EAC/CC,EAAOF,EAAc,SAASC,CAAK,EAEzC,OAAOC,CAAI,EAAE,cACX,IAAI,WAAW,CACb,IAAM,IAAM,IAAM,IAAM,IAAM,IAAM,GAAM,IAAM,IAAM,GAAM,IAC5D,IAAM,GAAM,GAAM,IAAM,IAAM,GAAM,GAAM,EAAM,IAAM,GAAM,IAC5D,IAAM,IAAM,GAAM,GAAM,IAAM,EAAM,IAAM,IAAM,IAAM,CACxD,CAAC,CACH,CACF,CAAC,CACH,CAAC,CACH,CAAC",
|
|
6
|
+
"names": ["import_NobleCryptoService", "cryptoService", "input", "hash"]
|
|
7
|
+
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";var
|
|
1
|
+
"use strict";var p=Object.defineProperty;var C=Object.getOwnPropertyDescriptor;var R=Object.getOwnPropertyNames;var A=Object.prototype.hasOwnProperty;var y=(n,e)=>{for(var i in e)p(n,i,{get:e[i],enumerable:!0})},T=(n,e,i,s)=>{if(e&&typeof e=="object"||typeof e=="function")for(let t of R(e))!A.call(n,t)&&t!==i&&p(n,t,{get:()=>e[t],enumerable:!(s=C(e,t))||s.enumerable});return n};var O=n=>T(p({},"__esModule",{value:!0}),n);var x={};y(x,{DeviceSession:()=>I});module.exports=O(x);var h=require("rxjs"),S=require("uuid"),u=require("../../../api/command/utils/CommandUtils"),d=require("../../../api/device/DeviceStatus"),m=require("../../../api/device-session/DeviceSessionState"),a=require("../../../api/index"),l=require("../../device-session/data/DeviceSessionRefresherConst"),D=require("../../device-session/service/MutexService"),_=require("../../device-session/service/RefresherService"),g=require("./DevicePinger"),o=require("./DeviceSessionEventDispatcher"),f=require("./DeviceSessionRefresher"),E=require("./DeviceSessionStateHandler");class I{_id;_connectedDevice;_deviceState;_managerApiService;_secureChannelService;_logger;_refresherOptions;_pinger;_deviceSessionRefresher;_refresherService;_commandMutex=new D.MutexService;_sessionEventDispatcher=new o.DeviceSessionEventDispatcher;constructor({connectedDevice:e,id:i=(0,S.v4)()},s,t,r,c){this._id=i,this._connectedDevice=e,this._logger=s("device-session"),this._managerApiService=t,this._secureChannelService=r,this._refresherOptions={...l.DEVICE_SESSION_REFRESHER_DEFAULT_OPTIONS,...c},this._deviceState=new h.BehaviorSubject({sessionStateType:m.DeviceSessionStateType.Connected,deviceStatus:d.DeviceStatus.CONNECTED,deviceModelId:this._connectedDevice.deviceModel.id}),this._pinger=new g.DevicePinger(s,e,this._sessionEventDispatcher,(v,b)=>this.sendCommand(v,b)),this._deviceSessionRefresher=new f.DeviceSessionRefresher(s,this._refresherOptions,this._sessionEventDispatcher,this._connectedDevice),new E.DeviceSessionStateHandler(s,this._sessionEventDispatcher,this._connectedDevice,this._deviceState,v=>this.setDeviceSessionState(v)),this._refresherService=new _.RefresherService(s,{start:()=>this._deviceSessionRefresher.restartRefresher(),stop:()=>this._deviceSessionRefresher.stopRefresher()})}async initialiseSession(){try{await this._pinger.ping()}catch(e){throw this._logger.error("Error while initialising session",{data:{error:e}}),e}finally{this._refresherOptions.isRefresherDisabled||this._deviceSessionRefresher.startRefresher()}}get id(){return this._id}get connectedDevice(){return this._connectedDevice}get state(){return this._deviceState.asObservable()}getDeviceSessionState(){return this._deviceState.getValue()}setDeviceSessionState(e){this._deviceState.next(e)}async sendApdu(e,i={isPolling:!1,triggersDisconnection:!1,abortTimeout:void 0}){const s=await this._commandMutex.lock();try{this._sessionEventDispatcher.dispatch({eventName:o.SessionEvents.DEVICE_STATE_UPDATE_BUSY}),this._logger.debug(`[exchange] => ${(0,a.bufferToHexaString)(e,!1)}`);const t=await this._connectedDevice.sendApdu(e,i.triggersDisconnection,i.abortTimeout);return t.ifRight(r=>{this._logger.debug(`[exchange] <= ${(0,a.bufferToHexaString)(r.data,!1)}${(0,a.bufferToHexaString)(r.statusCode,!1)}`),u.CommandUtils.isLockedDeviceResponse(r)?this._sessionEventDispatcher.dispatch({eventName:o.SessionEvents.DEVICE_STATE_UPDATE_LOCKED}):this._sessionEventDispatcher.dispatch({eventName:o.SessionEvents.DEVICE_STATE_UPDATE_CONNECTED})}).ifLeft(()=>{this._sessionEventDispatcher.dispatch({eventName:o.SessionEvents.DEVICE_STATE_UPDATE_CONNECTED})}),t}finally{s()}}async sendCommand(e,i){this._logger.debug(`[sendCommand] ${e.name}`);const s=e.getApdu();return(await this.sendApdu(s.getRawApdu(),{isPolling:!1,triggersDisconnection:e.triggersDisconnection??!1,abortTimeout:i})).caseOf({Left:r=>{throw this._logger.error("[sendCommand] error",{data:{err:r}}),r},Right:r=>{const c=e.parseResponse(r,this._connectedDevice.deviceModel.id);return this._logger.debug("[sendCommand] result",{data:{result:c}}),c}})}executeDeviceAction(e){const{observable:i,cancel:s}=e._execute({sendApdu:async t=>this.sendApdu(t),sendCommand:async(t,r)=>this.sendCommand(t,r),getDeviceModel:()=>this._connectedDevice.deviceModel,getDeviceSessionState:()=>this._deviceState.getValue(),getDeviceSessionStateObservable:()=>this.state,setDeviceSessionState:t=>(this.setDeviceSessionState(t),this._deviceState.getValue()),disableRefresher:t=>this._refresherService.disableRefresher(t),getManagerApiService:()=>this._managerApiService,getSecureChannelService:()=>this._secureChannelService});return{observable:i,cancel:s}}close(){this._updateDeviceStatus(d.DeviceStatus.NOT_CONNECTED),this._deviceState.complete(),this._deviceSessionRefresher.stopRefresher()}disableRefresher(e){return this._refresherService.disableRefresher(e)}_updateDeviceStatus(e){const i=this._deviceState.getValue();this._deviceState.next({...i,deviceStatus:e})}}0&&(module.exports={DeviceSession});
|
|
2
2
|
//# sourceMappingURL=DeviceSession.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../../src/internal/device-session/model/DeviceSession.ts"],
|
|
4
|
-
"sourcesContent": ["import { type Either } from \"purify-ts\";\nimport { BehaviorSubject, type Observable } from \"rxjs\";\nimport { v4 as uuidv4 } from \"uuid\";\n\nimport { type Command } from \"@api/command/Command\";\nimport { type CommandResult } from \"@api/command/model/CommandResult\";\nimport { CommandUtils } from \"@api/command/utils/CommandUtils\";\nimport { DeviceStatus } from \"@api/device/DeviceStatus\";\nimport {\n type DeviceAction,\n type DeviceActionIntermediateValue,\n type ExecuteDeviceActionReturnType,\n} from \"@api/device-action/DeviceAction\";\nimport { type ApduResponse } from \"@api/device-session/ApduResponse\";\nimport {\n type DeviceSessionState,\n DeviceSessionStateType,\n} from \"@api/device-session/DeviceSessionState\";\nimport { type DeviceSessionId } from \"@api/device-session/types\";\nimport { type DmkError } from \"@api/Error\";\nimport { type LoggerPublisherService } from \"@api/logger-publisher/service/LoggerPublisherService\";\nimport { type TransportConnectedDevice } from \"@api/transport/model/TransportConnectedDevice\";\nimport { DEVICE_SESSION_REFRESHER_DEFAULT_OPTIONS } from \"@internal/device-session/data/DeviceSessionRefresherConst\";\nimport { MutexService } from \"@internal/device-session/service/MutexService\";\nimport { RefresherService } from \"@internal/device-session/service/RefresherService\";\nimport { type ManagerApiService } from \"@internal/manager-api/service/ManagerApiService\";\nimport { type SecureChannelService } from \"@internal/secure-channel/service/SecureChannelService\";\n\nimport { DevicePinger } from \"./DevicePinger\";\nimport {\n DeviceSessionEventDispatcher,\n SessionEvents,\n} from \"./DeviceSessionEventDispatcher\";\nimport { DeviceSessionRefresher } from \"./DeviceSessionRefresher\";\nimport { DeviceSessionStateHandler } from \"./DeviceSessionStateHandler\";\n\nexport type SessionConstructorArgs = {\n connectedDevice: TransportConnectedDevice;\n id?: DeviceSessionId;\n};\n\nexport type DeviceSessionRefresherOptions = {\n isRefresherDisabled: boolean;\n pollingInterval?: number;\n};\n\ntype SendApduOptions = {\n isPolling?: boolean;\n triggersDisconnection?: boolean;\n abortTimeout?: number;\n};\n\n/**\n * Represents a session with a device.\n */\nexport class DeviceSession {\n private readonly _id: DeviceSessionId;\n private readonly _connectedDevice: TransportConnectedDevice;\n private readonly _deviceState: BehaviorSubject<DeviceSessionState>;\n private readonly _managerApiService: ManagerApiService;\n private readonly _secureChannelService: SecureChannelService;\n private readonly _logger: LoggerPublisherService;\n private readonly _refresherOptions: DeviceSessionRefresherOptions;\n private _pinger: DevicePinger;\n private _deviceSessionRefresher: DeviceSessionRefresher;\n private readonly _refresherService: RefresherService;\n private _commandMutex = new MutexService();\n private _sessionEventDispatcher = new DeviceSessionEventDispatcher();\n\n constructor(\n { connectedDevice, id = uuidv4() }: SessionConstructorArgs,\n loggerModuleFactory: (tag: string) => LoggerPublisherService,\n managerApiService: ManagerApiService,\n secureChannelService: SecureChannelService,\n deviceSessionRefresherOptions: DeviceSessionRefresherOptions | undefined,\n ) {\n this._id = id;\n this._connectedDevice = connectedDevice;\n this._logger = loggerModuleFactory(\"device-session\");\n this._managerApiService = managerApiService;\n this._secureChannelService = secureChannelService;\n this._refresherOptions = {\n ...DEVICE_SESSION_REFRESHER_DEFAULT_OPTIONS,\n ...deviceSessionRefresherOptions,\n };\n this._deviceState = new BehaviorSubject<DeviceSessionState>({\n sessionStateType: DeviceSessionStateType.Connected,\n deviceStatus: DeviceStatus.CONNECTED,\n deviceModelId: this._connectedDevice.deviceModel.id,\n });\n\n this._pinger = new DevicePinger(\n loggerModuleFactory,\n connectedDevice,\n this._sessionEventDispatcher,\n (command, abortTimeout) => this.sendCommand(command, abortTimeout),\n );\n this._deviceSessionRefresher = new DeviceSessionRefresher(\n loggerModuleFactory,\n this._refresherOptions,\n this._sessionEventDispatcher,\n this._connectedDevice,\n );\n new DeviceSessionStateHandler(\n loggerModuleFactory,\n this._sessionEventDispatcher,\n this._connectedDevice,\n this._deviceState,\n (state) => this.setDeviceSessionState(state),\n );\n\n this._refresherService = new RefresherService(loggerModuleFactory, {\n start: () => this._deviceSessionRefresher.restartRefresher(),\n stop: () => this._deviceSessionRefresher.stopRefresher(),\n });\n }\n\n public async initialiseSession(): Promise<void> {\n try {\n await this._pinger.ping();\n } catch (error) {\n this._logger.error(\"Error while initialising session\", {\n data: { error },\n });\n throw error;\n } finally {\n if (!this._refresherOptions.isRefresherDisabled) {\n this._deviceSessionRefresher.startRefresher();\n }\n }\n }\n\n public get id(): DeviceSessionId {\n return this._id;\n }\n\n public get connectedDevice(): TransportConnectedDevice {\n return this._connectedDevice;\n }\n\n public get state(): Observable<DeviceSessionState> {\n return this._deviceState.asObservable();\n }\n\n public getDeviceSessionState(): DeviceSessionState {\n return this._deviceState.getValue();\n }\n\n public setDeviceSessionState(state: DeviceSessionState): void {\n this._deviceState.next(state);\n }\n\n public async sendApdu(\n rawApdu: Uint8Array,\n options: SendApduOptions = {\n isPolling: false,\n triggersDisconnection: false,\n abortTimeout: undefined,\n },\n ): Promise<Either<DmkError, ApduResponse>> {\n const release = await this._commandMutex.lock();\n\n try {\n this._sessionEventDispatcher.dispatch({\n eventName: SessionEvents.DEVICE_STATE_UPDATE_BUSY,\n });\n const result = await this._connectedDevice.sendApdu(\n rawApdu,\n options.triggersDisconnection,\n options.abortTimeout,\n );\n\n result\n .ifRight((response: ApduResponse) => {\n if (CommandUtils.isLockedDeviceResponse(response)) {\n this._sessionEventDispatcher.dispatch({\n eventName: SessionEvents.DEVICE_STATE_UPDATE_LOCKED,\n });\n } else {\n this._sessionEventDispatcher.dispatch({\n eventName: SessionEvents.DEVICE_STATE_UPDATE_CONNECTED,\n });\n }\n })\n .ifLeft(() => {\n this._sessionEventDispatcher.dispatch({\n eventName: SessionEvents.DEVICE_STATE_UPDATE_CONNECTED,\n });\n });\n return result;\n } finally {\n release();\n }\n }\n\n public async sendCommand<Response, Args, ErrorStatusCodes>(\n command: Command<Response, Args, ErrorStatusCodes>,\n abortTimeout?: number,\n ): Promise<CommandResult<Response, ErrorStatusCodes>> {\n const apdu = command.getApdu();\n\n const response = await this.sendApdu(apdu.getRawApdu(), {\n isPolling: false,\n triggersDisconnection: command.triggersDisconnection ?? false,\n abortTimeout,\n });\n\n return response.caseOf({\n Left: (err) => {\n throw err;\n },\n Right: (r)
|
|
5
|
-
"mappings": "yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,mBAAAE,IAAA,eAAAC,EAAAH,GACA,IAAAI,EAAiD,gBACjDC,EAA6B,gBAI7BC,EAA6B,2CAC7BC,EAA6B,oCAO7BC,EAGO,
|
|
6
|
-
"names": ["DeviceSession_exports", "__export", "DeviceSession", "__toCommonJS", "import_rxjs", "import_uuid", "import_CommandUtils", "import_DeviceStatus", "import_DeviceSessionState", "import_DeviceSessionRefresherConst", "import_MutexService", "import_RefresherService", "import_DevicePinger", "import_DeviceSessionEventDispatcher", "import_DeviceSessionRefresher", "import_DeviceSessionStateHandler", "connectedDevice", "id", "uuidv4", "loggerModuleFactory", "managerApiService", "secureChannelService", "deviceSessionRefresherOptions", "command", "abortTimeout", "state", "error", "rawApdu", "options", "release", "result", "response", "apdu", "err", "deviceAction", "observable", "cancel", "blockerId", "deviceStatus"]
|
|
4
|
+
"sourcesContent": ["import { type Either } from \"purify-ts\";\nimport { BehaviorSubject, type Observable } from \"rxjs\";\nimport { v4 as uuidv4 } from \"uuid\";\n\nimport { type Command } from \"@api/command/Command\";\nimport { type CommandResult } from \"@api/command/model/CommandResult\";\nimport { CommandUtils } from \"@api/command/utils/CommandUtils\";\nimport { DeviceStatus } from \"@api/device/DeviceStatus\";\nimport {\n type DeviceAction,\n type DeviceActionIntermediateValue,\n type ExecuteDeviceActionReturnType,\n} from \"@api/device-action/DeviceAction\";\nimport { type ApduResponse } from \"@api/device-session/ApduResponse\";\nimport {\n type DeviceSessionState,\n DeviceSessionStateType,\n} from \"@api/device-session/DeviceSessionState\";\nimport { type DeviceSessionId } from \"@api/device-session/types\";\nimport { type DmkError } from \"@api/Error\";\nimport { bufferToHexaString } from \"@api/index\";\nimport { type LoggerPublisherService } from \"@api/logger-publisher/service/LoggerPublisherService\";\nimport { type TransportConnectedDevice } from \"@api/transport/model/TransportConnectedDevice\";\nimport { DEVICE_SESSION_REFRESHER_DEFAULT_OPTIONS } from \"@internal/device-session/data/DeviceSessionRefresherConst\";\nimport { MutexService } from \"@internal/device-session/service/MutexService\";\nimport { RefresherService } from \"@internal/device-session/service/RefresherService\";\nimport { type ManagerApiService } from \"@internal/manager-api/service/ManagerApiService\";\nimport { type SecureChannelService } from \"@internal/secure-channel/service/SecureChannelService\";\n\nimport { DevicePinger } from \"./DevicePinger\";\nimport {\n DeviceSessionEventDispatcher,\n SessionEvents,\n} from \"./DeviceSessionEventDispatcher\";\nimport { DeviceSessionRefresher } from \"./DeviceSessionRefresher\";\nimport { DeviceSessionStateHandler } from \"./DeviceSessionStateHandler\";\n\nexport type SessionConstructorArgs = {\n connectedDevice: TransportConnectedDevice;\n id?: DeviceSessionId;\n};\n\nexport type DeviceSessionRefresherOptions = {\n isRefresherDisabled: boolean;\n pollingInterval?: number;\n};\n\ntype SendApduOptions = {\n isPolling?: boolean;\n triggersDisconnection?: boolean;\n abortTimeout?: number;\n};\n\n/**\n * Represents a session with a device.\n */\nexport class DeviceSession {\n private readonly _id: DeviceSessionId;\n private readonly _connectedDevice: TransportConnectedDevice;\n private readonly _deviceState: BehaviorSubject<DeviceSessionState>;\n private readonly _managerApiService: ManagerApiService;\n private readonly _secureChannelService: SecureChannelService;\n private readonly _logger: LoggerPublisherService;\n private readonly _refresherOptions: DeviceSessionRefresherOptions;\n private _pinger: DevicePinger;\n private _deviceSessionRefresher: DeviceSessionRefresher;\n private readonly _refresherService: RefresherService;\n private _commandMutex = new MutexService();\n private _sessionEventDispatcher = new DeviceSessionEventDispatcher();\n\n constructor(\n { connectedDevice, id = uuidv4() }: SessionConstructorArgs,\n loggerModuleFactory: (tag: string) => LoggerPublisherService,\n managerApiService: ManagerApiService,\n secureChannelService: SecureChannelService,\n deviceSessionRefresherOptions: DeviceSessionRefresherOptions | undefined,\n ) {\n this._id = id;\n this._connectedDevice = connectedDevice;\n this._logger = loggerModuleFactory(\"device-session\");\n this._managerApiService = managerApiService;\n this._secureChannelService = secureChannelService;\n this._refresherOptions = {\n ...DEVICE_SESSION_REFRESHER_DEFAULT_OPTIONS,\n ...deviceSessionRefresherOptions,\n };\n this._deviceState = new BehaviorSubject<DeviceSessionState>({\n sessionStateType: DeviceSessionStateType.Connected,\n deviceStatus: DeviceStatus.CONNECTED,\n deviceModelId: this._connectedDevice.deviceModel.id,\n });\n\n this._pinger = new DevicePinger(\n loggerModuleFactory,\n connectedDevice,\n this._sessionEventDispatcher,\n (command, abortTimeout) => this.sendCommand(command, abortTimeout),\n );\n this._deviceSessionRefresher = new DeviceSessionRefresher(\n loggerModuleFactory,\n this._refresherOptions,\n this._sessionEventDispatcher,\n this._connectedDevice,\n );\n new DeviceSessionStateHandler(\n loggerModuleFactory,\n this._sessionEventDispatcher,\n this._connectedDevice,\n this._deviceState,\n (state) => this.setDeviceSessionState(state),\n );\n\n this._refresherService = new RefresherService(loggerModuleFactory, {\n start: () => this._deviceSessionRefresher.restartRefresher(),\n stop: () => this._deviceSessionRefresher.stopRefresher(),\n });\n }\n\n public async initialiseSession(): Promise<void> {\n try {\n await this._pinger.ping();\n } catch (error) {\n this._logger.error(\"Error while initialising session\", {\n data: { error },\n });\n throw error;\n } finally {\n if (!this._refresherOptions.isRefresherDisabled) {\n this._deviceSessionRefresher.startRefresher();\n }\n }\n }\n\n public get id(): DeviceSessionId {\n return this._id;\n }\n\n public get connectedDevice(): TransportConnectedDevice {\n return this._connectedDevice;\n }\n\n public get state(): Observable<DeviceSessionState> {\n return this._deviceState.asObservable();\n }\n\n public getDeviceSessionState(): DeviceSessionState {\n return this._deviceState.getValue();\n }\n\n public setDeviceSessionState(state: DeviceSessionState): void {\n this._deviceState.next(state);\n }\n\n public async sendApdu(\n rawApdu: Uint8Array,\n options: SendApduOptions = {\n isPolling: false,\n triggersDisconnection: false,\n abortTimeout: undefined,\n },\n ): Promise<Either<DmkError, ApduResponse>> {\n const release = await this._commandMutex.lock();\n\n try {\n this._sessionEventDispatcher.dispatch({\n eventName: SessionEvents.DEVICE_STATE_UPDATE_BUSY,\n });\n\n this._logger.debug(`[exchange] => ${bufferToHexaString(rawApdu, false)}`);\n const result = await this._connectedDevice.sendApdu(\n rawApdu,\n options.triggersDisconnection,\n options.abortTimeout,\n );\n\n result\n .ifRight((response: ApduResponse) => {\n this._logger.debug(\n `[exchange] <= ${bufferToHexaString(response.data, false)}${bufferToHexaString(response.statusCode, false)}`,\n );\n if (CommandUtils.isLockedDeviceResponse(response)) {\n this._sessionEventDispatcher.dispatch({\n eventName: SessionEvents.DEVICE_STATE_UPDATE_LOCKED,\n });\n } else {\n this._sessionEventDispatcher.dispatch({\n eventName: SessionEvents.DEVICE_STATE_UPDATE_CONNECTED,\n });\n }\n })\n .ifLeft(() => {\n this._sessionEventDispatcher.dispatch({\n eventName: SessionEvents.DEVICE_STATE_UPDATE_CONNECTED,\n });\n });\n return result;\n } finally {\n release();\n }\n }\n\n public async sendCommand<Response, Args, ErrorStatusCodes>(\n command: Command<Response, Args, ErrorStatusCodes>,\n abortTimeout?: number,\n ): Promise<CommandResult<Response, ErrorStatusCodes>> {\n this._logger.debug(`[sendCommand] ${command.name}`);\n const apdu = command.getApdu();\n\n const response = await this.sendApdu(apdu.getRawApdu(), {\n isPolling: false,\n triggersDisconnection: command.triggersDisconnection ?? false,\n abortTimeout,\n });\n\n return response.caseOf({\n Left: (err) => {\n this._logger.error(\"[sendCommand] error\", { data: { err } });\n throw err;\n },\n Right: (r) => {\n const result = command.parseResponse(\n r,\n this._connectedDevice.deviceModel.id,\n );\n this._logger.debug(\"[sendCommand] result\", { data: { result } });\n return result;\n },\n });\n }\n\n public executeDeviceAction<\n Output,\n Input,\n E extends DmkError,\n IntermediateValue extends DeviceActionIntermediateValue,\n >(\n deviceAction: DeviceAction<Output, Input, E, IntermediateValue>,\n ): ExecuteDeviceActionReturnType<Output, E, IntermediateValue> {\n const { observable, cancel } = deviceAction._execute({\n sendApdu: async (apdu: Uint8Array) => this.sendApdu(apdu),\n sendCommand: async <Response, ErrorStatusCodes, Args>(\n command: Command<Response, ErrorStatusCodes, Args>,\n abortTimeout?: number,\n ) => this.sendCommand(command, abortTimeout),\n getDeviceModel: () => this._connectedDevice.deviceModel,\n getDeviceSessionState: () => this._deviceState.getValue(),\n getDeviceSessionStateObservable: () => this.state,\n setDeviceSessionState: (state: DeviceSessionState) => {\n this.setDeviceSessionState(state);\n return this._deviceState.getValue();\n },\n disableRefresher: (blockerId: string) =>\n this._refresherService.disableRefresher(blockerId),\n getManagerApiService: () => this._managerApiService,\n getSecureChannelService: () => this._secureChannelService,\n });\n return { observable, cancel };\n }\n\n public close(): void {\n this._updateDeviceStatus(DeviceStatus.NOT_CONNECTED);\n this._deviceState.complete();\n this._deviceSessionRefresher.stopRefresher();\n }\n\n public disableRefresher(id: string): () => void {\n return this._refresherService.disableRefresher(id);\n }\n\n private _updateDeviceStatus(deviceStatus: DeviceStatus): void {\n const state = this._deviceState.getValue();\n this._deviceState.next({ ...state, deviceStatus });\n }\n}\n"],
|
|
5
|
+
"mappings": "yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,mBAAAE,IAAA,eAAAC,EAAAH,GACA,IAAAI,EAAiD,gBACjDC,EAA6B,gBAI7BC,EAA6B,2CAC7BC,EAA6B,oCAO7BC,EAGO,kDAGPC,EAAmC,sBAGnCC,EAAyD,qEACzDC,EAA6B,yDAC7BC,EAAiC,6DAIjCC,EAA6B,0BAC7BC,EAGO,0CACPC,EAAuC,oCACvCC,EAA0C,uCAqBnC,MAAMd,CAAc,CACR,IACA,iBACA,aACA,mBACA,sBACA,QACA,kBACT,QACA,wB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A,MAAQ,GAAM,CACZ,MAAMH,EAASP,EAAQ,cACrB,EACA,KAAK,iBAAiB,YAAY,EACpC,EACA,YAAK,QAAQ,MAAM,uBAAwB,CAAE,KAAM,CAAE,OAAAO,CAAO,CAAE,CAAC,EACxDA,CACT,CACF,CAAC,CACH,CAEO,oBAMLI,EAC6D,CAC7D,KAAM,CAAE,WAAAC,EAAY,OAAAC,CAAO,EAAIF,EAAa,SAAS,CACnD,SAAU,MAAOF,GAAqB,KAAK,SAASA,CAAI,EACxD,YAAa,MACXT,EACAC,IACG,KAAK,YAAYD,EAASC,CAAY,EAC3C,eAAgB,IAAM,KAAK,iBAAiB,YAC5C,sBAAuB,IAAM,KAAK,aAAa,SAAS,EACxD,gCAAiC,IAAM,KAAK,MAC5C,sBAAwBC,IACtB,KAAK,sBAAsBA,CAAK,EACzB,KAAK,aAAa,SAAS,GAEpC,iBAAmBY,GACjB,KAAK,kBAAkB,iBAAiBA,CAAS,EACnD,qBAAsB,IAAM,KAAK,mBACjC,wBAAyB,IAAM,KAAK,qBACtC,CAAC,EACD,MAAO,CAAE,WAAAF,EAAY,OAAAC,CAAO,CAC9B,CAEO,OAAc,CACnB,KAAK,oBAAoB,eAAa,aAAa,EACnD,KAAK,aAAa,SAAS,EAC3B,KAAK,wBAAwB,cAAc,CAC7C,CAEO,iBAAiBnB,EAAwB,CAC9C,OAAO,KAAK,kBAAkB,iBAAiBA,CAAE,CACnD,CAEQ,oBAAoBqB,EAAkC,CAC5D,MAAMb,EAAQ,KAAK,aAAa,SAAS,EACzC,KAAK,aAAa,KAAK,CAAE,GAAGA,EAAO,aAAAa,CAAa,CAAC,CACnD,CACF",
|
|
6
|
+
"names": ["DeviceSession_exports", "__export", "DeviceSession", "__toCommonJS", "import_rxjs", "import_uuid", "import_CommandUtils", "import_DeviceStatus", "import_DeviceSessionState", "import_api", "import_DeviceSessionRefresherConst", "import_MutexService", "import_RefresherService", "import_DevicePinger", "import_DeviceSessionEventDispatcher", "import_DeviceSessionRefresher", "import_DeviceSessionStateHandler", "connectedDevice", "id", "uuidv4", "loggerModuleFactory", "managerApiService", "secureChannelService", "deviceSessionRefresherOptions", "command", "abortTimeout", "state", "error", "rawApdu", "options", "release", "result", "response", "apdu", "err", "deviceAction", "observable", "cancel", "blockerId", "deviceStatus"]
|
|
7
7
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";var n=Object.defineProperty;var
|
|
1
|
+
"use strict";var n=Object.defineProperty;var S=Object.getOwnPropertyDescriptor;var D=Object.getOwnPropertyNames;var b=Object.prototype.hasOwnProperty;var f=(o,e)=>{for(var s in e)n(o,s,{get:e[s],enumerable:!0})},_=(o,e,s,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of D(e))!b.call(o,r)&&r!==s&&n(o,r,{get:()=>e[r],enumerable:!(i=S(e,r))||i.enumerable});return o};var p=o=>_(n({},"__esModule",{value:!0}),o),a=(o,e,s,i)=>{for(var r=i>1?void 0:i?S(e,s):e,v=o.length-1,h;v>=0;v--)(h=o[v])&&(r=(i?h(e,s,r):h(r))||r);return i&&r&&n(e,s,r),r},l=(o,e)=>(s,i)=>e(s,i,o);var y={};f(y,{DefaultDeviceSessionService:()=>t});module.exports=p(y);var c=require("inversify"),d=require("purify-ts"),u=require("rxjs"),g=require("../../device-session/model/Errors"),m=require("../../logger-publisher/di/loggerTypes");let t=class{_sessions;_sessionsSubject;_logger;constructor(e){this._sessions=[],this._sessionsSubject=new u.ReplaySubject,this._logger=e("DeviceSessionService")}get sessionsObs(){return this._sessionsSubject.asObservable()}addDeviceSession(e){return this._sessions.find(i=>i.id===e.id)?(this._logger.warn("DeviceSession already exists",{data:{deviceSession:e}}),this):(this._sessions.push(e),this._sessionsSubject.next(e),this._logger.info("DeviceSession added",{data:{sessionId:e.id}}),this)}removeDeviceSession(e){const s=this._sessions.find(i=>i.id===e);return s?(s.close(),this._sessions=this._sessions.filter(i=>i.id!==e),this._logger.info("DeviceSession removed",{data:{sessionId:e}}),this):(this._logger.warn("DeviceSession not found",{data:{sessionId:e}}),this)}getDeviceSessionById(e){return d.Maybe.fromNullable(this._sessions.find(s=>s.id===e)).toEither(new g.DeviceSessionNotFound)}getDeviceSessionsByDeviceId(e){return d.Maybe.fromPredicate(({length:s})=>s>0,this._sessions.filter(s=>s.connectedDevice.id===e)).toEither(new g.DeviceSessionNotFound)}getDeviceSessions(){return this._sessions}};t=a([(0,c.injectable)(),l(0,(0,c.inject)(m.loggerTypes.LoggerPublisherServiceFactory))],t);0&&(module.exports={DefaultDeviceSessionService});
|
|
2
2
|
//# sourceMappingURL=DefaultDeviceSessionService.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../../src/internal/device-session/service/DefaultDeviceSessionService.ts"],
|
|
4
|
-
"sourcesContent": ["import { inject, injectable } from \"inversify\";\nimport { Maybe } from \"purify-ts\";\nimport { Observable, ReplaySubject } from \"rxjs\";\n\nimport { LoggerPublisherService } from \"@api/logger-publisher/service/LoggerPublisherService\";\nimport { DeviceSession } from \"@internal/device-session/model/DeviceSession\";\nimport { DeviceSessionNotFound } from \"@internal/device-session/model/Errors\";\nimport { DeviceSessionService } from \"@internal/device-session/service/DeviceSessionService\";\nimport { loggerTypes } from \"@internal/logger-publisher/di/loggerTypes\";\n\n@injectable()\nexport class DefaultDeviceSessionService implements DeviceSessionService {\n private _sessions: DeviceSession[];\n private readonly
|
|
5
|
-
"mappings": "okBAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,iCAAAE,IAAA,eAAAC,EAAAH,GAAA,IAAAI,EAAmC,qBACnCC,
|
|
6
|
-
"names": ["DefaultDeviceSessionService_exports", "__export", "DefaultDeviceSessionService", "__toCommonJS", "import_inversify", "import_purify_ts", "import_rxjs", "import_Errors", "import_loggerTypes", "DefaultDeviceSessionService", "loggerModuleFactory", "deviceSession", "sessionId", "found", "deviceId", "__decorateClass", "__decorateParam"]
|
|
4
|
+
"sourcesContent": ["import { inject, injectable } from \"inversify\";\nimport { Either, Maybe } from \"purify-ts\";\nimport { Observable, ReplaySubject } from \"rxjs\";\n\nimport { LoggerPublisherService } from \"@api/logger-publisher/service/LoggerPublisherService\";\nimport { DeviceId } from \"@api/types\";\nimport { DeviceSession } from \"@internal/device-session/model/DeviceSession\";\nimport { DeviceSessionNotFound } from \"@internal/device-session/model/Errors\";\nimport { DeviceSessionService } from \"@internal/device-session/service/DeviceSessionService\";\nimport { loggerTypes } from \"@internal/logger-publisher/di/loggerTypes\";\n\n@injectable()\nexport class DefaultDeviceSessionService implements DeviceSessionService {\n private _sessions: DeviceSession[];\n private readonly _sessionsSubject: ReplaySubject<DeviceSession>;\n private readonly _logger: LoggerPublisherService;\n\n constructor(\n @inject(loggerTypes.LoggerPublisherServiceFactory)\n loggerModuleFactory: (tag: string) => LoggerPublisherService,\n ) {\n this._sessions = [];\n this._sessionsSubject = new ReplaySubject();\n this._logger = loggerModuleFactory(\"DeviceSessionService\");\n }\n\n public get sessionsObs(): Observable<DeviceSession> {\n return this._sessionsSubject.asObservable();\n }\n\n addDeviceSession(deviceSession: DeviceSession): DeviceSessionService {\n const found = this._sessions.find((s) => s.id === deviceSession.id);\n if (found) {\n this._logger.warn(\"DeviceSession already exists\", {\n data: { deviceSession },\n });\n return this;\n }\n this._sessions.push(deviceSession);\n this._sessionsSubject.next(deviceSession);\n this._logger.info(\"DeviceSession added\", {\n data: { sessionId: deviceSession.id },\n });\n return this;\n }\n\n removeDeviceSession(sessionId: string): DeviceSessionService {\n const found = this._sessions.find((s) => s.id === sessionId);\n if (found) {\n found.close();\n this._sessions = this._sessions.filter((s) => s.id !== sessionId);\n this._logger.info(\"DeviceSession removed\", { data: { sessionId } });\n return this;\n }\n this._logger.warn(\"DeviceSession not found\", { data: { sessionId } });\n return this;\n }\n\n getDeviceSessionById(\n sessionId: string,\n ): Either<DeviceSessionNotFound, DeviceSession> {\n return Maybe.fromNullable(\n this._sessions.find((s) => s.id === sessionId),\n ).toEither(new DeviceSessionNotFound());\n }\n\n getDeviceSessionsByDeviceId(\n deviceId: DeviceId,\n ): Either<DeviceSessionNotFound, DeviceSession[]> {\n return Maybe.fromPredicate(\n ({ length }) => length > 0,\n this._sessions.filter((s) => s.connectedDevice.id === deviceId),\n ).toEither(new DeviceSessionNotFound());\n }\n\n getDeviceSessions(): DeviceSession[] {\n return this._sessions;\n }\n}\n"],
|
|
5
|
+
"mappings": "okBAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,iCAAAE,IAAA,eAAAC,EAAAH,GAAA,IAAAI,EAAmC,qBACnCC,EAA8B,qBAC9BC,EAA0C,gBAK1CC,EAAsC,iDAEtCC,EAA4B,qDAGrB,IAAMC,EAAN,KAAkE,CAC/D,UACS,iBACA,QAEjB,YAEEC,EACA,CACA,KAAK,UAAY,CAAC,EAClB,KAAK,iBAAmB,IAAI,gBAC5B,KAAK,QAAUA,EAAoB,sBAAsB,CAC3D,CAEA,IAAW,aAAyC,CAClD,OAAO,KAAK,iBAAiB,aAAa,CAC5C,CAEA,iBAAiBC,EAAoD,CAEnE,OADc,KAAK,UAAU,KAAMC,GAAMA,EAAE,KAAOD,EAAc,EAAE,GAEhE,KAAK,QAAQ,KAAK,+BAAgC,CAChD,KAAM,CAAE,cAAAA,CAAc,CACxB,CAAC,EACM,OAET,KAAK,UAAU,KAAKA,CAAa,EACjC,KAAK,iBAAiB,KAAKA,CAAa,EACxC,KAAK,QAAQ,KAAK,sBAAuB,CACvC,KAAM,CAAE,UAAWA,EAAc,EAAG,CACtC,CAAC,EACM,KACT,CAEA,oBAAoBE,EAAyC,CAC3D,MAAMC,EAAQ,KAAK,UAAU,KAAMF,GAAMA,EAAE,KAAOC,CAAS,EAC3D,OAAIC,GACFA,EAAM,MAAM,EACZ,KAAK,UAAY,KAAK,UAAU,OAAQF,GAAMA,EAAE,KAAOC,CAAS,EAChE,KAAK,QAAQ,KAAK,wBAAyB,CAAE,KAAM,CAAE,UAAAA,CAAU,CAAE,CAAC,EAC3D,OAET,KAAK,QAAQ,KAAK,0BAA2B,CAAE,KAAM,CAAE,UAAAA,CAAU,CAAE,CAAC,EAC7D,KACT,CAEA,qBACEA,EAC8C,CAC9C,OAAO,QAAM,aACX,KAAK,UAAU,KAAM,GAAM,EAAE,KAAOA,CAAS,CAC/C,EAAE,SAAS,IAAI,uBAAuB,CACxC,CAEA,4BACEE,EACgD,CAChD,OAAO,QAAM,cACX,CAAC,CAAE,OAAAC,CAAO,IAAMA,EAAS,EACzB,KAAK,UAAU,OAAQ,GAAM,EAAE,gBAAgB,KAAOD,CAAQ,CAChE,EAAE,SAAS,IAAI,uBAAuB,CACxC,CAEA,mBAAqC,CACnC,OAAO,KAAK,SACd,CACF,EAlEaN,EAANQ,EAAA,IADN,cAAW,EAOPC,EAAA,eAAO,cAAY,6BAA6B,IANxCT",
|
|
6
|
+
"names": ["DefaultDeviceSessionService_exports", "__export", "DefaultDeviceSessionService", "__toCommonJS", "import_inversify", "import_purify_ts", "import_rxjs", "import_Errors", "import_loggerTypes", "DefaultDeviceSessionService", "loggerModuleFactory", "deviceSession", "s", "sessionId", "found", "deviceId", "length", "__decorateClass", "__decorateParam"]
|
|
7
7
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";var
|
|
1
|
+
"use strict";var s=require("purify-ts"),f=require("rxjs"),u=require("../../../api/transport/model/TransportConnectedDevice.stub"),r=require("../../device-session/data/DeviceSessionRefresherConst"),a=require("../../device-session/model/DeviceSession.stub"),p=require("../../device-session/model/Errors"),h=require("../../logger-publisher/service/DefaultLoggerPublisherService"),b=require("../../manager-api/data/AxiosManagerApiDataSource"),x=require("../../manager-api/service/DefaultManagerApiService"),E=require("../../secure-channel/data/DefaultSecureChannelDataSource"),y=require("../../secure-channel/service/DefaultSecureChannelService"),I=require("./DefaultDeviceSessionService");vi.mock("@internal/logger-publisher/service/DefaultLoggerPublisherService");vi.mock("@internal/manager-api/data/AxiosManagerApiDataSource");let e,o,i,d,S,m,c,g,n;describe("DefaultDeviceSessionService",()=>{o=new h.DefaultLoggerPublisherService([],"deviceSession"),m=new b.AxiosManagerApiDataSource({}),c=new x.DefaultManagerApiService(m),g=new E.DefaultSecureChannelDataSource({}),n=new y.DefaultSecureChannelService(g),beforeEach(()=>{vi.restoreAllMocks(),e=new I.DefaultDeviceSessionService(()=>o),i=(0,a.deviceSessionStubBuilder)({},()=>o,c,n,r.DEVICE_SESSION_REFRESHER_DEFAULT_OPTIONS)}),afterEach(()=>{i.close()}),it("should have an empty DeviceSession list",()=>{expect(e.getDeviceSessions()).toEqual([])}),describe("DeviceSessionService addDeviceSession",()=>{it("should add a DeviceSession if it does not already exist",()=>{e.addDeviceSession(i),expect(e.getDeviceSessions()).toEqual([i])}),it("should not add a DeviceSession if it already exists",()=>{e.addDeviceSession(i),e.addDeviceSession(i),expect(e.getDeviceSessions()).toEqual([i])})}),describe("DeviceSessionService removeDeviceSession",()=>{it("should remove the DeviceSession of given ID",()=>{e.addDeviceSession(i),e.removeDeviceSession(i.id),expect(e.getDeviceSessions()).toEqual([])}),it("should not remove the DeviceSession of given ID if it does not exist",()=>{e.addDeviceSession(i),e.removeDeviceSession("non-existent-id"),expect(e.getDeviceSessions()).toEqual([i])})}),describe("DeviceSessionService getDeviceSessionById",()=>{it("should get the DeviceSession of given ID if it exists",()=>{e.addDeviceSession(i),expect(e.getDeviceSessionById(i.id)).toEqual(s.Either.of(i))}),it("should not get the DeviceSession if it does not exist",()=>{e.addDeviceSession(i),expect(e.getDeviceSessionById("non-existent-id")).toEqual((0,s.Left)(new p.DeviceSessionNotFound))})}),describe("DeviceSessionService getDeviceSessionsByDeviceId",()=>{it("should not get device sessions by deviceId if none exist",()=>{e.addDeviceSession(i),expect(e.getDeviceSessionsByDeviceId("non-existent-device-id")).toEqual((0,s.Left)(new p.DeviceSessionNotFound))}),it("should get a single device session by deviceId",()=>{e.addDeviceSession(i),expect(e.getDeviceSessionsByDeviceId(i.connectedDevice.id)).toEqual(s.Either.of([i]))}),it("should get device sessions by deviceId",()=>{e.addDeviceSession(i),d=(0,a.deviceSessionStubBuilder)({connectedDevice:(0,u.connectedDeviceStubBuilder)({id:"device-1"}),id:"session-1"},()=>o,c,n,r.DEVICE_SESSION_REFRESHER_DEFAULT_OPTIONS),S=(0,a.deviceSessionStubBuilder)({connectedDevice:(0,u.connectedDeviceStubBuilder)({id:"device-1"}),id:"session-2"},()=>o,c,n,r.DEVICE_SESSION_REFRESHER_DEFAULT_OPTIONS),e.addDeviceSession(d),e.addDeviceSession(S),expect(e.getDeviceSessionsByDeviceId("device-1")).toEqual(s.Either.of([d,S])),d.close(),S.close()})}),it("should get all sessions",()=>{e.addDeviceSession(i),expect(e.getDeviceSessions()).toEqual([i])}),it("should retrieve sessionObs",()=>{expect(e.sessionsObs).toBeInstanceOf(f.Observable)}),it("should emit new session",()=>new Promise((t,v)=>{const D=e.sessionsObs.subscribe({next(l){try{expect(l).toStrictEqual(i),D.unsubscribe(),t()}catch(A){v(A)}}});e.addDeviceSession(i)})),it("should emit previous added session",()=>{const t=(0,a.deviceSessionStubBuilder)({id:"last-session"},()=>o,c,n,r.DEVICE_SESSION_REFRESHER_DEFAULT_OPTIONS),v=[];e.addDeviceSession(i),e.addDeviceSession(t);const D=e.sessionsObs.subscribe({next(l){v.push(l)}});t.close(),expect(v).toEqual([i,t]),D.unsubscribe()})});
|
|
2
2
|
//# sourceMappingURL=DefaultDeviceSessionService.test.js.map
|