@ledgerhq/device-management-kit 0.0.0-develop-20260902001426 → 0.0.0-develop-20260904001312
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 +1 -1
- package/lib/cjs/src/api/command/os/GetOsVersionCommand.js +1 -1
- package/lib/cjs/src/api/command/os/GetOsVersionCommand.js.map +3 -3
- package/lib/cjs/src/api/command/os/GetOsVersionCommand.test.js +1 -1
- package/lib/cjs/src/api/command/os/GetOsVersionCommand.test.js.map +3 -3
- package/lib/cjs/src/api/command/os/SecureElementFlagsParser.js +1 -1
- package/lib/cjs/src/api/command/os/SecureElementFlagsParser.js.map +3 -3
- package/lib/cjs/src/api/command/os/SecureElementFlagsParser.test.js +1 -1
- package/lib/cjs/src/api/command/os/SecureElementFlagsParser.test.js.map +3 -3
- package/lib/cjs/src/api/command/os/__mocks__/GetOsVersionCommand.js +1 -1
- package/lib/cjs/src/api/command/os/__mocks__/GetOsVersionCommand.js.map +3 -3
- package/lib/cjs/src/api/device/SecureElementFlags.js +1 -1
- package/lib/cjs/src/api/device/SecureElementFlags.js.map +3 -3
- package/lib/cjs/src/api/index.js +1 -1
- package/lib/cjs/src/api/index.js.map +3 -3
- package/lib/cjs/src/api/utils/ApplicationChecker.js +1 -1
- package/lib/cjs/src/api/utils/ApplicationChecker.js.map +3 -3
- package/lib/cjs/src/api/utils/ApplicationChecker.test.js +1 -1
- package/lib/cjs/src/api/utils/ApplicationChecker.test.js.map +2 -2
- package/lib/esm/package.json +1 -1
- package/lib/esm/src/api/command/os/GetOsVersionCommand.js +1 -1
- package/lib/esm/src/api/command/os/GetOsVersionCommand.js.map +3 -3
- package/lib/esm/src/api/command/os/GetOsVersionCommand.test.js +1 -1
- package/lib/esm/src/api/command/os/GetOsVersionCommand.test.js.map +3 -3
- package/lib/esm/src/api/command/os/SecureElementFlagsParser.js +1 -1
- package/lib/esm/src/api/command/os/SecureElementFlagsParser.js.map +3 -3
- package/lib/esm/src/api/command/os/SecureElementFlagsParser.test.js +1 -1
- package/lib/esm/src/api/command/os/SecureElementFlagsParser.test.js.map +3 -3
- package/lib/esm/src/api/command/os/__mocks__/GetOsVersionCommand.js +1 -1
- package/lib/esm/src/api/command/os/__mocks__/GetOsVersionCommand.js.map +3 -3
- package/lib/esm/src/api/device/SecureElementFlags.js +1 -0
- package/lib/esm/src/api/device/SecureElementFlags.js.map +4 -4
- package/lib/esm/src/api/index.js +1 -1
- package/lib/esm/src/api/index.js.map +3 -3
- package/lib/esm/src/api/utils/ApplicationChecker.js +1 -1
- package/lib/esm/src/api/utils/ApplicationChecker.js.map +3 -3
- package/lib/esm/src/api/utils/ApplicationChecker.test.js +1 -1
- package/lib/esm/src/api/utils/ApplicationChecker.test.js.map +2 -2
- package/lib/types/src/api/command/os/GetOsVersionCommand.d.ts +2 -2
- package/lib/types/src/api/command/os/GetOsVersionCommand.d.ts.map +1 -1
- package/lib/types/src/api/command/os/SecureElementFlagsParser.d.ts +0 -3
- package/lib/types/src/api/command/os/SecureElementFlagsParser.d.ts.map +1 -1
- package/lib/types/src/api/command/os/__mocks__/GetOsVersionCommand.d.ts.map +1 -1
- package/lib/types/src/api/device/SecureElementFlags.d.ts +65 -3
- package/lib/types/src/api/device/SecureElementFlags.d.ts.map +1 -1
- package/lib/types/src/api/index.d.ts +2 -1
- package/lib/types/src/api/index.d.ts.map +1 -1
- package/lib/types/src/api/utils/ApplicationChecker.d.ts +17 -0
- package/lib/types/src/api/utils/ApplicationChecker.d.ts.map +1 -1
- package/lib/types/tsconfig.prod.tsbuildinfo +1 -1
- package/package.json +4 -4
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../src/api/index.ts"],
|
|
4
|
-
"sourcesContent": ["\"use strict\";\n\nexport { Apdu } from \"@api/apdu/model/Apdu\";\nexport { APDU_MAX_PAYLOAD, ApduBuilder } from \"@api/apdu/utils/ApduBuilder\";\nexport { ApduParser } from \"@api/apdu/utils/ApduParser\";\nexport * from \"@api/apdu/utils/AppBuilderError\";\nexport { ByteArrayBuilder } from \"@api/apdu/utils/ByteArrayBuilder\";\nexport { ByteArrayParser } from \"@api/apdu/utils/ByteArrayParser\";\nexport { type Command } from \"@api/command/Command\";\nexport {\n InvalidResponseFormatError,\n InvalidStatusWordError,\n} from \"@api/command/Errors\";\nexport {\n CommandResultFactory,\n CommandResultStatus,\n isSuccessCommandResult,\n} from \"@api/command/model/CommandResult\";\nexport { CloseAppCommand } from \"@api/command/os/CloseAppCommand\";\nexport {\n DeleteLanguagePackCommand,\n type DeleteLanguagePackCommandArgs,\n DeleteLanguagePackCommandError,\n type DeleteLanguagePackCommandResult,\n type DeleteLanguagePackErrorCodes,\n} from \"@api/command/os/DeleteLanguagePackCommand\";\nexport {\n GetAppAndVersionCommand,\n type GetAppAndVersionResponse,\n} from \"@api/command/os/GetAppAndVersionCommand\";\nexport {\n GetBackgroundImageSizeCommand,\n GetBackgroundImageSizeCommandError,\n type GetBackgroundImageSizeCommandResult,\n type GetBackgroundImageSizeErrorCodes,\n type GetBackgroundImageSizeResponse,\n} from \"@api/command/os/GetBackgroundImageSizeCommand\";\nexport {\n BatteryStatusType,\n type GetBatteryStatusArgs,\n GetBatteryStatusCommand,\n type GetBatteryStatusResponse,\n} from \"@api/command/os/GetBatteryStatusCommand\";\nexport {\n GetOsVersionCommand,\n type GetOsVersionResponse,\n} from \"@api/command/os/GetOsVersionCommand\";\nexport {\n type ListAppsArgs,\n ListAppsCommand,\n type ListAppsErrorCodes,\n type ListAppsResponse,\n} from \"@api/command/os/ListAppsCommand\";\nexport {\n ListLanguagePackCommand,\n type ListLanguagePackCommandArgs,\n ListLanguagePackCommandError,\n type ListLanguagePackCommandResult,\n type ListLanguagePackErrorCodes,\n type ListLanguagePackResponse,\n} from \"@api/command/os/ListLanguagePackCommand\";\nexport {\n type LoadCertificateArgs,\n LoadCertificateCommand,\n type LoadCertificateErrorCodes,\n} from \"@api/command/os/LoadCertificateCommand\";\nexport {\n type OpenAppArgs,\n OpenAppCommand,\n} from \"@api/command/os/OpenAppCommand\";\nexport { isCommandErrorCode } from \"@api/command/utils/CommandErrors\";\nexport { CommandUtils } from \"@api/command/utils/CommandUtils\";\nexport {\n GLOBAL_ERRORS,\n GlobalCommandError,\n GlobalCommandErrorHandler,\n} from \"@api/command/utils/GlobalCommandError\";\nexport {\n DeviceModel,\n DeviceModelId,\n LEDGER_VENDOR_ID,\n} from \"@api/device/DeviceModel\";\nexport { DeviceStatus } from \"@api/device/DeviceStatus\";\nexport { type InternalApi } from \"@api/device-action/DeviceAction\";\nexport {\n type DeviceActionState,\n DeviceActionStatus,\n} from \"@api/device-action/model/DeviceActionState\";\nexport { UserInteractionRequired } from \"@api/device-action/model/UserInteractionRequired\";\nexport { CallTaskInAppDeviceAction } from \"@api/device-action/os/CallTaskInAppDeviceAction/CallTaskInAppDeviceAction\";\nexport { DEFAULT_UNLOCK_TIMEOUT_MS } from \"@api/device-action/os/Const\";\nexport {\n AppAlreadyInstalledDAError,\n DeleteLanguagePackDAError,\n DeviceLockedError,\n DeviceNotOnboardedError,\n OutOfMemoryDAError,\n RefusedByUserDAError,\n UnknownDAError,\n UnsupportedFirmwareDAError,\n} from \"@api/device-action/os/Errors\";\nexport { GetDeviceMetadataDeviceAction } from \"@api/device-action/os/GetDeviceMetadata/GetDeviceMetadataDeviceAction\";\nexport { GetDeviceStatusDeviceAction } from \"@api/device-action/os/GetDeviceStatus/GetDeviceStatusDeviceAction\";\nexport { GoToDashboardDeviceAction } from \"@api/device-action/os/GoToDashboard/GoToDashboardDeviceAction\";\nexport type {\n GoToDashboardDAError,\n GoToDashboardDAInput,\n GoToDashboardDAIntermediateValue,\n GoToDashboardDAOutput,\n GoToDashboardDARequiredInteraction,\n GoToDashboardDAState,\n} from \"@api/device-action/os/GoToDashboard/types\";\nexport { InstallLanguagePackageDeviceAction } from \"@api/device-action/os/InstallLanguagePackage/InstallLanguagePackageDeviceAction\";\nexport { InstallOrUpdateAppsDeviceAction } from \"@api/device-action/os/InstallOrUpdateApps/InstallOrUpdateAppsDeviceAction\";\nexport { ListAppsDeviceAction } from \"@api/device-action/os/ListApps/ListAppsDeviceAction\";\nexport { ListAppsWithMetadataDeviceAction } from \"@api/device-action/os/ListAppsWithMetadata/ListAppsWithMetadataDeviceAction\";\nexport { OpenAppDeviceAction } from \"@api/device-action/os/OpenAppDeviceAction/OpenAppDeviceAction\";\nexport { OpenAppWithDependenciesDeviceAction } from \"@api/device-action/os/OpenAppWithDependencies/OpenAppWithDependenciesDeviceAction\";\nexport { SendCommandInAppDeviceAction } from \"@api/device-action/os/SendCommandInAppDeviceAction/SendCommandInAppDeviceAction\";\nexport type {\n WaitForAppAndVersionDAError,\n WaitForAppAndVersionDAInput,\n WaitForAppAndVersionDAIntermediateValue,\n WaitForAppAndVersionDAOutput,\n WaitForAppAndVersionDARequiredInteraction,\n WaitForAppAndVersionDAState,\n} from \"@api/device-action/os/WaitForAppAndVersion/types\";\nexport { WaitForAppAndVersionDeviceAction } from \"@api/device-action/os/WaitForAppAndVersion/WaitForAppAndVersionDeviceAction\";\nexport {\n GetApplicationsMetadataTaskError,\n InvalidGetFirmwareMetadataResponseError,\n} from \"@api/device-action/task/Errors\";\nexport {\n type DeviceActionStateMachine,\n XStateDeviceAction,\n} from \"@api/device-action/xstate-utils/XStateDeviceAction\";\nexport { StaticDeviceModelDataSource } from \"@api/device-model/data/StaticDeviceModelDataSource\";\nexport { BleDeviceInfos } from \"@api/device-model/model/BleDeviceInfos\";\nexport { TransportDeviceModel } from \"@api/device-model/model/DeviceModel\";\nexport { ApduResponse } from \"@api/device-session/ApduResponse\";\nexport * from \"@api/device-session/data/FramerConst\";\nexport {\n type DeviceSessionState,\n DeviceSessionStateType,\n} from \"@api/device-session/DeviceSessionState\";\nexport {\n DmkResultFactory,\n DmkResultStatus,\n isSuccessDmkResult,\n} from \"@api/model/DmkResult\";\nexport { GenuineCheckDeviceAction } from \"@api/secure-channel/device-action/GenuineCheck/GenuineCheckDeviceAction\";\nexport { InstallAppDeviceAction } from \"@api/secure-channel/device-action/InstallApp/InstallAppDeviceAction\";\nexport { ListInstalledAppsDeviceAction } from \"@api/secure-channel/device-action/ListInstalledApps/ListInstalledAppsDeviceAction\";\nexport type { InstalledApp } from \"@api/secure-channel/device-action/ListInstalledApps/types\";\nexport { UninstallAppDeviceAction } from \"@api/secure-channel/device-action/UninstallApp/UninstallAppDeviceAction\";\nexport { ConnectToSecureChannelTask } from \"@api/secure-channel/task/ConnectToSecureChannelTask\";\nexport { SecureChannelEventType } from \"@api/secure-channel/task/types\";\nexport { SecureChannelError } from \"@internal/secure-channel/model/Errors\";\n// TODO: remove from exported\nexport { defaultApduReceiverServiceStubBuilder } from \"@api/device-session/service/DefaultApduReceiverService.stub\";\nexport { defaultApduSenderServiceStubBuilder } from \"@api/device-session/service/DefaultApduSenderService.stub\";\nexport { FramerUtils } from \"@api/device-session/utils/FramerUtils\";\nexport { DeviceManagementKit } from \"@api/DeviceManagementKit\";\nexport { DeviceManagementKitBuilder } from \"@api/DeviceManagementKitBuilder\";\nexport * from \"@api/Error\";\nexport {\n noopLogger,\n noopLoggerFactory,\n} from \"@api/logger-publisher/utils/noopLoggerFactory\";\nexport { LogLevel } from \"@api/logger-subscriber/model/LogLevel\";\nexport { ConsoleLogger } from \"@api/logger-subscriber/service/ConsoleLogger\";\nexport { DefaultLogTagFormatter } from \"@api/logger-subscriber/service/DefaultLogTagFormatter\";\nexport { type LogTagFormatter } from \"@api/logger-subscriber/service/LogTagFormatter\";\nexport { WebLogsExporterLogger } from \"@api/logger-subscriber/service/WebLogsExporterLogger\";\nexport {\n DmkNetworkClient,\n type DmkNetworkClientOptions,\n type DmkNetworkResponse,\n type DmkQueryParams,\n type DmkQueryParamValue,\n type DmkRequestConfig,\n type DmkResponseType,\n} from \"@api/network/DmkNetworkClient\";\nexport { DmkNetworkClientError } from \"@api/network/DmkNetworkClientError\";\nexport { ConnectedDevice } from \"@api/transport/model/ConnectedDevice\";\nexport {\n DeviceConnectionStateMachine,\n type DeviceConnectionStateMachineParams,\n} from \"@api/transport/model/DeviceConnectionStateMachine\";\nexport * from \"@api/transport/model/Errors\";\nexport { TransportConnectedDevice } from \"@api/transport/model/TransportConnectedDevice\";\nexport { connectedDeviceStubBuilder } from \"@api/transport/model/TransportConnectedDevice.stub\";\nexport * from \"@api/types\";\nexport { formatApduReceivedLog, formatApduSentLog } from \"@api/utils/apduLogs\";\nexport { ApplicationChecker } from \"@api/utils/ApplicationChecker\";\nexport {\n type AppConfig,\n type ApplicationResolver,\n type ResolvedApp,\n} from \"@api/utils/ApplicationResolver\";\nexport { isDashboardName } from \"@api/utils/AppName\";\nexport {\n base64StringToBuffer,\n bufferToBase64String,\n isBase64String,\n} from \"@api/utils/Base64String\";\nexport {\n bufferToHexaString,\n hexaStringToBuffer,\n isHexaString,\n} from \"@api/utils/HexaString\";\n"],
|
|
5
|
-
"mappings": "meAAA,IAAAA,EAAA,GAAAC,GAAAD,EAAA
|
|
6
|
-
"names": ["api_exports", "__export", "__toCommonJS", "import_Apdu", "import_ApduBuilder", "import_ApduParser", "__reExport", "import_ByteArrayBuilder", "import_ByteArrayParser", "import_Errors", "import_CommandResult", "import_CloseAppCommand", "import_DeleteLanguagePackCommand", "import_GetAppAndVersionCommand", "import_GetBackgroundImageSizeCommand", "import_GetBatteryStatusCommand", "import_GetOsVersionCommand", "import_ListAppsCommand", "import_ListLanguagePackCommand", "import_LoadCertificateCommand", "import_OpenAppCommand", "import_CommandErrors", "import_CommandUtils", "import_GlobalCommandError", "import_DeviceModel", "import_DeviceStatus", "import_DeviceActionState", "import_UserInteractionRequired", "import_CallTaskInAppDeviceAction", "import_Const", "import_GetDeviceMetadataDeviceAction", "import_GetDeviceStatusDeviceAction", "import_GoToDashboardDeviceAction", "import_InstallLanguagePackageDeviceAction", "import_InstallOrUpdateAppsDeviceAction", "import_ListAppsDeviceAction", "import_ListAppsWithMetadataDeviceAction", "import_OpenAppDeviceAction", "import_OpenAppWithDependenciesDeviceAction", "import_SendCommandInAppDeviceAction", "import_WaitForAppAndVersionDeviceAction", "import_XStateDeviceAction", "import_StaticDeviceModelDataSource", "import_BleDeviceInfos", "import_ApduResponse", "import_DeviceSessionState", "import_DmkResult", "import_GenuineCheckDeviceAction", "import_InstallAppDeviceAction", "import_ListInstalledAppsDeviceAction", "import_UninstallAppDeviceAction", "import_ConnectToSecureChannelTask", "import_types", "import_DefaultApduReceiverService", "import_DefaultApduSenderService", "import_FramerUtils", "import_DeviceManagementKit", "import_DeviceManagementKitBuilder", "import_noopLoggerFactory", "import_LogLevel", "import_ConsoleLogger", "import_DefaultLogTagFormatter", "import_WebLogsExporterLogger", "import_DmkNetworkClient", "import_DmkNetworkClientError", "import_ConnectedDevice", "import_DeviceConnectionStateMachine", "import_TransportConnectedDevice", "import_apduLogs", "import_ApplicationChecker", "import_AppName", "import_Base64String", "import_HexaString"]
|
|
4
|
+
"sourcesContent": ["\"use strict\";\n\nexport { Apdu } from \"@api/apdu/model/Apdu\";\nexport { APDU_MAX_PAYLOAD, ApduBuilder } from \"@api/apdu/utils/ApduBuilder\";\nexport { ApduParser } from \"@api/apdu/utils/ApduParser\";\nexport * from \"@api/apdu/utils/AppBuilderError\";\nexport { ByteArrayBuilder } from \"@api/apdu/utils/ByteArrayBuilder\";\nexport { ByteArrayParser } from \"@api/apdu/utils/ByteArrayParser\";\nexport { type Command } from \"@api/command/Command\";\nexport {\n InvalidResponseFormatError,\n InvalidStatusWordError,\n} from \"@api/command/Errors\";\nexport {\n CommandResultFactory,\n CommandResultStatus,\n isSuccessCommandResult,\n} from \"@api/command/model/CommandResult\";\nexport { CloseAppCommand } from \"@api/command/os/CloseAppCommand\";\nexport {\n DeleteLanguagePackCommand,\n type DeleteLanguagePackCommandArgs,\n DeleteLanguagePackCommandError,\n type DeleteLanguagePackCommandResult,\n type DeleteLanguagePackErrorCodes,\n} from \"@api/command/os/DeleteLanguagePackCommand\";\nexport {\n GetAppAndVersionCommand,\n type GetAppAndVersionResponse,\n} from \"@api/command/os/GetAppAndVersionCommand\";\nexport {\n GetBackgroundImageSizeCommand,\n GetBackgroundImageSizeCommandError,\n type GetBackgroundImageSizeCommandResult,\n type GetBackgroundImageSizeErrorCodes,\n type GetBackgroundImageSizeResponse,\n} from \"@api/command/os/GetBackgroundImageSizeCommand\";\nexport {\n BatteryStatusType,\n type GetBatteryStatusArgs,\n GetBatteryStatusCommand,\n type GetBatteryStatusResponse,\n} from \"@api/command/os/GetBatteryStatusCommand\";\nexport {\n GetOsVersionCommand,\n type GetOsVersionCommandResult,\n type GetOsVersionResponse,\n} from \"@api/command/os/GetOsVersionCommand\";\nexport {\n type ListAppsArgs,\n ListAppsCommand,\n type ListAppsErrorCodes,\n type ListAppsResponse,\n} from \"@api/command/os/ListAppsCommand\";\nexport {\n ListLanguagePackCommand,\n type ListLanguagePackCommandArgs,\n ListLanguagePackCommandError,\n type ListLanguagePackCommandResult,\n type ListLanguagePackErrorCodes,\n type ListLanguagePackResponse,\n} from \"@api/command/os/ListLanguagePackCommand\";\nexport {\n type LoadCertificateArgs,\n LoadCertificateCommand,\n type LoadCertificateErrorCodes,\n} from \"@api/command/os/LoadCertificateCommand\";\nexport {\n type OpenAppArgs,\n OpenAppCommand,\n} from \"@api/command/os/OpenAppCommand\";\nexport { isCommandErrorCode } from \"@api/command/utils/CommandErrors\";\nexport { CommandUtils } from \"@api/command/utils/CommandUtils\";\nexport {\n GLOBAL_ERRORS,\n GlobalCommandError,\n GlobalCommandErrorHandler,\n} from \"@api/command/utils/GlobalCommandError\";\nexport {\n DeviceModel,\n DeviceModelId,\n LEDGER_VENDOR_ID,\n} from \"@api/device/DeviceModel\";\nexport { DeviceStatus } from \"@api/device/DeviceStatus\";\nexport {\n type DeviceGeneralState,\n type EndorsementInformation,\n OnboardingState,\n type OnboardingStatus,\n type SecureElementFlags,\n type SeedWordCount,\n type WordsInformation,\n} from \"@api/device/SecureElementFlags\";\nexport { type InternalApi } from \"@api/device-action/DeviceAction\";\nexport {\n type DeviceActionState,\n DeviceActionStatus,\n} from \"@api/device-action/model/DeviceActionState\";\nexport { UserInteractionRequired } from \"@api/device-action/model/UserInteractionRequired\";\nexport { CallTaskInAppDeviceAction } from \"@api/device-action/os/CallTaskInAppDeviceAction/CallTaskInAppDeviceAction\";\nexport { DEFAULT_UNLOCK_TIMEOUT_MS } from \"@api/device-action/os/Const\";\nexport {\n AppAlreadyInstalledDAError,\n DeleteLanguagePackDAError,\n DeviceLockedError,\n DeviceNotOnboardedError,\n OutOfMemoryDAError,\n RefusedByUserDAError,\n UnknownDAError,\n UnsupportedFirmwareDAError,\n} from \"@api/device-action/os/Errors\";\nexport { GetDeviceMetadataDeviceAction } from \"@api/device-action/os/GetDeviceMetadata/GetDeviceMetadataDeviceAction\";\nexport { GetDeviceStatusDeviceAction } from \"@api/device-action/os/GetDeviceStatus/GetDeviceStatusDeviceAction\";\nexport { GoToDashboardDeviceAction } from \"@api/device-action/os/GoToDashboard/GoToDashboardDeviceAction\";\nexport type {\n GoToDashboardDAError,\n GoToDashboardDAInput,\n GoToDashboardDAIntermediateValue,\n GoToDashboardDAOutput,\n GoToDashboardDARequiredInteraction,\n GoToDashboardDAState,\n} from \"@api/device-action/os/GoToDashboard/types\";\nexport { InstallLanguagePackageDeviceAction } from \"@api/device-action/os/InstallLanguagePackage/InstallLanguagePackageDeviceAction\";\nexport { InstallOrUpdateAppsDeviceAction } from \"@api/device-action/os/InstallOrUpdateApps/InstallOrUpdateAppsDeviceAction\";\nexport { ListAppsDeviceAction } from \"@api/device-action/os/ListApps/ListAppsDeviceAction\";\nexport { ListAppsWithMetadataDeviceAction } from \"@api/device-action/os/ListAppsWithMetadata/ListAppsWithMetadataDeviceAction\";\nexport { OpenAppDeviceAction } from \"@api/device-action/os/OpenAppDeviceAction/OpenAppDeviceAction\";\nexport { OpenAppWithDependenciesDeviceAction } from \"@api/device-action/os/OpenAppWithDependencies/OpenAppWithDependenciesDeviceAction\";\nexport { SendCommandInAppDeviceAction } from \"@api/device-action/os/SendCommandInAppDeviceAction/SendCommandInAppDeviceAction\";\nexport type {\n WaitForAppAndVersionDAError,\n WaitForAppAndVersionDAInput,\n WaitForAppAndVersionDAIntermediateValue,\n WaitForAppAndVersionDAOutput,\n WaitForAppAndVersionDARequiredInteraction,\n WaitForAppAndVersionDAState,\n} from \"@api/device-action/os/WaitForAppAndVersion/types\";\nexport { WaitForAppAndVersionDeviceAction } from \"@api/device-action/os/WaitForAppAndVersion/WaitForAppAndVersionDeviceAction\";\nexport {\n GetApplicationsMetadataTaskError,\n InvalidGetFirmwareMetadataResponseError,\n} from \"@api/device-action/task/Errors\";\nexport {\n type DeviceActionStateMachine,\n XStateDeviceAction,\n} from \"@api/device-action/xstate-utils/XStateDeviceAction\";\nexport { StaticDeviceModelDataSource } from \"@api/device-model/data/StaticDeviceModelDataSource\";\nexport { BleDeviceInfos } from \"@api/device-model/model/BleDeviceInfos\";\nexport { TransportDeviceModel } from \"@api/device-model/model/DeviceModel\";\nexport { ApduResponse } from \"@api/device-session/ApduResponse\";\nexport * from \"@api/device-session/data/FramerConst\";\nexport {\n type DeviceSessionState,\n DeviceSessionStateType,\n} from \"@api/device-session/DeviceSessionState\";\nexport {\n DmkResultFactory,\n DmkResultStatus,\n isSuccessDmkResult,\n} from \"@api/model/DmkResult\";\nexport { GenuineCheckDeviceAction } from \"@api/secure-channel/device-action/GenuineCheck/GenuineCheckDeviceAction\";\nexport { InstallAppDeviceAction } from \"@api/secure-channel/device-action/InstallApp/InstallAppDeviceAction\";\nexport { ListInstalledAppsDeviceAction } from \"@api/secure-channel/device-action/ListInstalledApps/ListInstalledAppsDeviceAction\";\nexport type { InstalledApp } from \"@api/secure-channel/device-action/ListInstalledApps/types\";\nexport { UninstallAppDeviceAction } from \"@api/secure-channel/device-action/UninstallApp/UninstallAppDeviceAction\";\nexport { ConnectToSecureChannelTask } from \"@api/secure-channel/task/ConnectToSecureChannelTask\";\nexport { SecureChannelEventType } from \"@api/secure-channel/task/types\";\nexport { SecureChannelError } from \"@internal/secure-channel/model/Errors\";\n// TODO: remove from exported\nexport { defaultApduReceiverServiceStubBuilder } from \"@api/device-session/service/DefaultApduReceiverService.stub\";\nexport { defaultApduSenderServiceStubBuilder } from \"@api/device-session/service/DefaultApduSenderService.stub\";\nexport { FramerUtils } from \"@api/device-session/utils/FramerUtils\";\nexport { DeviceManagementKit } from \"@api/DeviceManagementKit\";\nexport { DeviceManagementKitBuilder } from \"@api/DeviceManagementKitBuilder\";\nexport * from \"@api/Error\";\nexport {\n noopLogger,\n noopLoggerFactory,\n} from \"@api/logger-publisher/utils/noopLoggerFactory\";\nexport { LogLevel } from \"@api/logger-subscriber/model/LogLevel\";\nexport { ConsoleLogger } from \"@api/logger-subscriber/service/ConsoleLogger\";\nexport { DefaultLogTagFormatter } from \"@api/logger-subscriber/service/DefaultLogTagFormatter\";\nexport { type LogTagFormatter } from \"@api/logger-subscriber/service/LogTagFormatter\";\nexport { WebLogsExporterLogger } from \"@api/logger-subscriber/service/WebLogsExporterLogger\";\nexport {\n DmkNetworkClient,\n type DmkNetworkClientOptions,\n type DmkNetworkResponse,\n type DmkQueryParams,\n type DmkQueryParamValue,\n type DmkRequestConfig,\n type DmkResponseType,\n} from \"@api/network/DmkNetworkClient\";\nexport { DmkNetworkClientError } from \"@api/network/DmkNetworkClientError\";\nexport { ConnectedDevice } from \"@api/transport/model/ConnectedDevice\";\nexport {\n DeviceConnectionStateMachine,\n type DeviceConnectionStateMachineParams,\n} from \"@api/transport/model/DeviceConnectionStateMachine\";\nexport * from \"@api/transport/model/Errors\";\nexport { TransportConnectedDevice } from \"@api/transport/model/TransportConnectedDevice\";\nexport { connectedDeviceStubBuilder } from \"@api/transport/model/TransportConnectedDevice.stub\";\nexport * from \"@api/types\";\nexport { formatApduReceivedLog, formatApduSentLog } from \"@api/utils/apduLogs\";\nexport { ApplicationChecker } from \"@api/utils/ApplicationChecker\";\nexport {\n type AppConfig,\n type ApplicationResolver,\n type ResolvedApp,\n} from \"@api/utils/ApplicationResolver\";\nexport { isDashboardName } from \"@api/utils/AppName\";\nexport {\n base64StringToBuffer,\n bufferToBase64String,\n isBase64String,\n} from \"@api/utils/Base64String\";\nexport {\n bufferToHexaString,\n hexaStringToBuffer,\n isHexaString,\n} from \"@api/utils/HexaString\";\n"],
|
|
5
|
+
"mappings": "meAAA,IAAAA,EAAA,GAAAC,GAAAD,EAAA,siKAAAE,GAAAF,GAEA,IAAAG,EAAqB,gCACrBC,EAA8C,uCAC9CC,EAA2B,sCAC3BC,EAAAN,EAAc,2CALd,gBAMA,IAAAO,EAAiC,4CACjCC,EAAgC,2CAEhCC,EAGO,+BACPC,EAIO,4CACPC,EAAgC,2CAChCC,EAMO,qDACPC,EAGO,mDACPC,EAMO,yDACPC,EAKO,mDACPC,EAIO,+CACPC,EAKO,2CACPC,EAOO,mDACPC,EAIO,kDACPC,EAGO,0CACPC,EAAmC,4CACnCC,EAA6B,2CAC7BC,EAIO,iDACPC,EAIO,mCACPC,EAA6B,oCAC7BC,EAQO,0CAEPC,EAGO,sDACPC,EAAwC,4DACxCC,EAA0C,qFAC1CC,EAA0C,uCAC1CrB,EASO,wCACPsB,EAA8C,iFAC9CC,EAA4C,6EAC5CC,EAA0C,yEAS1CC,EAAmD,2FACnDC,EAAgD,qFAChDC,EAAqC,+DACrCC,EAAiD,uFACjDC,EAAoC,yEACpCC,EAAoD,6FACpDC,EAA6C,2FAS7CC,EAAiD,uFACjDhC,EAGO,0CACPiC,GAGO,8DACPC,GAA4C,8DAC5CC,GAA+B,kDAC/BpB,GAAqC,+CACrCqB,GAA6B,4CAC7BvC,EAAAN,EAAc,gDAtJd,gBAuJA,IAAA8C,GAGO,kDACPC,EAIO,gCACPC,GAAyC,mFACzCC,GAAuC,+EACvCC,GAA8C,6FAE9CC,GAAyC,mFACzCC,GAA2C,+DAC3CC,GAAuC,0CACvC5C,GAAmC,iDAEnC6C,GAAsD,uEACtDC,GAAoD,qEACpDC,GAA4B,iDAC5BC,GAAoC,oCACpCC,GAA2C,2CAC3CpD,EAAAN,EAAc,sBA9Kd,gBA+KA,IAAA2D,EAGO,yDACPC,GAAyB,iDACzBC,GAA8B,wDAC9BC,GAAuC,iEAEvCC,GAAsC,gEACtCC,GAQO,yCACPC,GAAsC,8CACtCC,GAAgC,gDAChCC,GAGO,6DACP7D,EAAAN,EAAc,uCAvMd,gBAwMA,IAAAoE,GAAyC,yDACzCA,GAA2C,8DAC3C9D,EAAAN,EAAc,sBA1Md,gBA2MA,IAAAqE,EAAyD,+BACzDC,GAAmC,yCAMnCC,GAAgC,8BAChCC,EAIO,mCACPC,EAIO",
|
|
6
|
+
"names": ["api_exports", "__export", "__toCommonJS", "import_Apdu", "import_ApduBuilder", "import_ApduParser", "__reExport", "import_ByteArrayBuilder", "import_ByteArrayParser", "import_Errors", "import_CommandResult", "import_CloseAppCommand", "import_DeleteLanguagePackCommand", "import_GetAppAndVersionCommand", "import_GetBackgroundImageSizeCommand", "import_GetBatteryStatusCommand", "import_GetOsVersionCommand", "import_ListAppsCommand", "import_ListLanguagePackCommand", "import_LoadCertificateCommand", "import_OpenAppCommand", "import_CommandErrors", "import_CommandUtils", "import_GlobalCommandError", "import_DeviceModel", "import_DeviceStatus", "import_SecureElementFlags", "import_DeviceActionState", "import_UserInteractionRequired", "import_CallTaskInAppDeviceAction", "import_Const", "import_GetDeviceMetadataDeviceAction", "import_GetDeviceStatusDeviceAction", "import_GoToDashboardDeviceAction", "import_InstallLanguagePackageDeviceAction", "import_InstallOrUpdateAppsDeviceAction", "import_ListAppsDeviceAction", "import_ListAppsWithMetadataDeviceAction", "import_OpenAppDeviceAction", "import_OpenAppWithDependenciesDeviceAction", "import_SendCommandInAppDeviceAction", "import_WaitForAppAndVersionDeviceAction", "import_XStateDeviceAction", "import_StaticDeviceModelDataSource", "import_BleDeviceInfos", "import_ApduResponse", "import_DeviceSessionState", "import_DmkResult", "import_GenuineCheckDeviceAction", "import_InstallAppDeviceAction", "import_ListInstalledAppsDeviceAction", "import_UninstallAppDeviceAction", "import_ConnectToSecureChannelTask", "import_types", "import_DefaultApduReceiverService", "import_DefaultApduSenderService", "import_FramerUtils", "import_DeviceManagementKit", "import_DeviceManagementKitBuilder", "import_noopLoggerFactory", "import_LogLevel", "import_ConsoleLogger", "import_DefaultLogTagFormatter", "import_WebLogsExporterLogger", "import_DmkNetworkClient", "import_DmkNetworkClientError", "import_ConnectedDevice", "import_DeviceConnectionStateMachine", "import_TransportConnectedDevice", "import_apduLogs", "import_ApplicationChecker", "import_AppName", "import_Base64String", "import_HexaString"]
|
|
7
7
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";var
|
|
1
|
+
"use strict";var n=Object.defineProperty;var p=Object.getOwnPropertyDescriptor;var l=Object.getOwnPropertyNames;var c=Object.prototype.hasOwnProperty;var a=(s,e)=>{for(var i in e)n(s,i,{get:e[i],enumerable:!0})},h=(s,e,i,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of l(e))!c.call(s,o)&&o!==i&&n(s,o,{get:()=>e[o],enumerable:!(r=p(e,o))||r.enumerable});return s};var d=s=>h(n({},"__esModule",{value:!0}),s);var u={};a(u,{ApplicationChecker:()=>m});module.exports=d(u);var t=require("semver");class m{isCompatible;version;modelId;appName;constructor(e,i,r){this.modelId=e.deviceModelId,this.appName="currentApp"in e?e.currentApp.name:void 0;const o=r.resolve(e,i);this.isCompatible=o.isCompatible,this.version=o.version}withMinVersionInclusive(e){return(0,t.gte)(this.version,e)||(this.isCompatible=!1),this}withMinVersionExclusive(e){return(0,t.gt)(this.version,e)||(this.isCompatible=!1),this}withMinVersionInclusiveAcceptingPrerelease(e){const i=(0,t.valid)((0,t.coerce)(this.version)),r=(0,t.valid)((0,t.coerce)(e));return(i===null||r===null||!(0,t.gte)(i,r))&&(this.isCompatible=!1),this}excludeDeviceModel(e){return this.modelId===e&&(this.isCompatible=!1),this}excludeDeviceModels(...e){for(const i of e)this.excludeDeviceModel(i);return this}excludeApp(e){return this.appName===e&&(this.isCompatible=!1),this}excludeApps(...e){for(const i of e)this.excludeApp(i);return this}check(){return this.isCompatible}}0&&(module.exports={ApplicationChecker});
|
|
2
2
|
//# sourceMappingURL=ApplicationChecker.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../src/api/utils/ApplicationChecker.ts"],
|
|
4
|
-
"sourcesContent": ["import { gt, gte } from \"semver\";\n\nimport { type DeviceModelId } from \"@api/device/DeviceModel\";\nimport { type DeviceSessionState } from \"@api/device-session/DeviceSessionState\";\n\nimport {\n type AppConfig,\n type ApplicationResolver,\n} from \"./ApplicationResolver\";\n\nexport class ApplicationChecker {\n private isCompatible: boolean;\n private version: string;\n private modelId: DeviceModelId;\n private readonly appName: string | undefined;\n\n constructor(\n deviceState: DeviceSessionState,\n appConfig: AppConfig,\n resolver: ApplicationResolver,\n ) {\n this.modelId = deviceState.deviceModelId;\n this.appName =\n \"currentApp\" in deviceState ? deviceState.currentApp.name : undefined;\n const resolved = resolver.resolve(deviceState, appConfig);\n this.isCompatible = resolved.isCompatible;\n this.version = resolved.version;\n }\n\n withMinVersionInclusive(version: string): ApplicationChecker {\n if (!gte(this.version, version)) this.isCompatible = false;\n return this;\n }\n\n withMinVersionExclusive(version: string): ApplicationChecker {\n if (!gt(this.version, version)) this.isCompatible = false;\n return this;\n }\n\n excludeDeviceModel(modelId: DeviceModelId): ApplicationChecker {\n if (this.modelId === modelId) this.isCompatible = false;\n return this;\n }\n\n excludeDeviceModels(...modelIds: DeviceModelId[]): ApplicationChecker {\n for (const id of modelIds) this.excludeDeviceModel(id);\n return this;\n }\n\n excludeApp(name: string): ApplicationChecker {\n if (this.appName === name) this.isCompatible = false;\n return this;\n }\n\n excludeApps(...names: string[]): ApplicationChecker {\n for (const name of names) this.excludeApp(name);\n return this;\n }\n\n check(): boolean {\n return this.isCompatible;\n }\n}\n"],
|
|
5
|
-
"mappings": "yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,wBAAAE,IAAA,eAAAC,EAAAH,GAAA,IAAAI,
|
|
6
|
-
"names": ["ApplicationChecker_exports", "__export", "ApplicationChecker", "__toCommonJS", "import_semver", "deviceState", "appConfig", "resolver", "resolved", "version", "modelId", "modelIds", "id", "name", "names"]
|
|
4
|
+
"sourcesContent": ["import { coerce, gt, gte, valid } from \"semver\";\n\nimport { type DeviceModelId } from \"@api/device/DeviceModel\";\nimport { type DeviceSessionState } from \"@api/device-session/DeviceSessionState\";\n\nimport {\n type AppConfig,\n type ApplicationResolver,\n} from \"./ApplicationResolver\";\n\nexport class ApplicationChecker {\n private isCompatible: boolean;\n private version: string;\n private modelId: DeviceModelId;\n private readonly appName: string | undefined;\n\n constructor(\n deviceState: DeviceSessionState,\n appConfig: AppConfig,\n resolver: ApplicationResolver,\n ) {\n this.modelId = deviceState.deviceModelId;\n this.appName =\n \"currentApp\" in deviceState ? deviceState.currentApp.name : undefined;\n const resolved = resolver.resolve(deviceState, appConfig);\n this.isCompatible = resolved.isCompatible;\n this.version = resolved.version;\n }\n\n withMinVersionInclusive(version: string): ApplicationChecker {\n if (!gte(this.version, version)) this.isCompatible = false;\n return this;\n }\n\n withMinVersionExclusive(version: string): ApplicationChecker {\n if (!gt(this.version, version)) this.isCompatible = false;\n return this;\n }\n\n /**\n * Like {@link withMinVersionInclusive}, but compares only the release core:\n * prerelease and build tags are stripped from both sides first, so an app\n * reporting `1.23.0-rc2` or `1.23.0-dev` satisfies a `1.23.0` minimum.\n *\n * This accepts a prerelease *of* the minimum, not any prerelease: the core\n * still has to clear the bar, so `1.22.9-rc5` fails a `1.23.0` minimum just\n * as `1.22.9` does. A version neither side can parse fails the check, so an\n * unknown version never passes.\n *\n * Use this when a feature lands in a given release and devices running its\n * release candidates must not be locked out \u2014 device versions reach the SDK\n * verbatim, tags included (`GET APP AND VERSION` yields strings such as\n * `1.4.0-rc2`). Prefer the strict {@link withMinVersionInclusive} when a\n * prerelease genuinely cannot be trusted to carry the feature.\n */\n withMinVersionInclusiveAcceptingPrerelease(\n version: string,\n ): ApplicationChecker {\n const actual = valid(coerce(this.version));\n const minimum = valid(coerce(version));\n if (actual === null || minimum === null || !gte(actual, minimum)) {\n this.isCompatible = false;\n }\n return this;\n }\n\n excludeDeviceModel(modelId: DeviceModelId): ApplicationChecker {\n if (this.modelId === modelId) this.isCompatible = false;\n return this;\n }\n\n excludeDeviceModels(...modelIds: DeviceModelId[]): ApplicationChecker {\n for (const id of modelIds) this.excludeDeviceModel(id);\n return this;\n }\n\n excludeApp(name: string): ApplicationChecker {\n if (this.appName === name) this.isCompatible = false;\n return this;\n }\n\n excludeApps(...names: string[]): ApplicationChecker {\n for (const name of names) this.excludeApp(name);\n return this;\n }\n\n check(): boolean {\n return this.isCompatible;\n }\n}\n"],
|
|
5
|
+
"mappings": "yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,wBAAAE,IAAA,eAAAC,EAAAH,GAAA,IAAAI,EAAuC,kBAUhC,MAAMF,CAAmB,CACtB,aACA,QACA,QACS,QAEjB,YACEG,EACAC,EACAC,EACA,CACA,KAAK,QAAUF,EAAY,cAC3B,KAAK,QACH,eAAgBA,EAAcA,EAAY,WAAW,KAAO,OAC9D,MAAMG,EAAWD,EAAS,QAAQF,EAAaC,CAAS,EACxD,KAAK,aAAeE,EAAS,aAC7B,KAAK,QAAUA,EAAS,OAC1B,CAEA,wBAAwBC,EAAqC,CAC3D,SAAK,OAAI,KAAK,QAASA,CAAO,IAAG,KAAK,aAAe,IAC9C,IACT,CAEA,wBAAwBA,EAAqC,CAC3D,SAAK,MAAG,KAAK,QAASA,CAAO,IAAG,KAAK,aAAe,IAC7C,IACT,CAkBA,2CACEA,EACoB,CACpB,MAAMC,KAAS,YAAM,UAAO,KAAK,OAAO,CAAC,EACnCC,KAAU,YAAM,UAAOF,CAAO,CAAC,EACrC,OAAIC,IAAW,MAAQC,IAAY,MAAQ,IAAC,OAAID,EAAQC,CAAO,KAC7D,KAAK,aAAe,IAEf,IACT,CAEA,mBAAmBC,EAA4C,CAC7D,OAAI,KAAK,UAAYA,IAAS,KAAK,aAAe,IAC3C,IACT,CAEA,uBAAuBC,EAA+C,CACpE,UAAWC,KAAMD,EAAU,KAAK,mBAAmBC,CAAE,EACrD,OAAO,IACT,CAEA,WAAWC,EAAkC,CAC3C,OAAI,KAAK,UAAYA,IAAM,KAAK,aAAe,IACxC,IACT,CAEA,eAAeC,EAAqC,CAClD,UAAWD,KAAQC,EAAO,KAAK,WAAWD,CAAI,EAC9C,OAAO,IACT,CAEA,OAAiB,CACf,OAAO,KAAK,YACd,CACF",
|
|
6
|
+
"names": ["ApplicationChecker_exports", "__export", "ApplicationChecker", "__toCommonJS", "import_semver", "deviceState", "appConfig", "resolver", "resolved", "version", "actual", "minimum", "modelId", "modelIds", "id", "name", "names"]
|
|
7
7
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";var
|
|
1
|
+
"use strict";var c=require("../device/DeviceModel"),n=require("../device/DeviceStatus"),l=require("../device-session/DeviceSessionState"),i=require("./ApplicationChecker");describe("ApplicationChecker",()=>{function s(e=c.DeviceModelId.FLEX){return{sessionStateType:l.DeviceSessionStateType.ReadyWithoutSecureChannel,deviceStatus:n.DeviceStatus.CONNECTED,installedApps:[],currentApp:{name:"TestApp",version:"1.0.0"},deviceModelId:e,isSecureConnectionAllowed:!1}}function o(e){return{resolve:()=>e}}const r={version:"1.0.0"};it("should pass check when resolved as compatible",()=>{const e=o({isCompatible:!0,version:"1.12.0"}),t=new i.ApplicationChecker(s(),r,e).check();expect(t).toStrictEqual(!0)}),it("should reject check when resolved as incompatible",()=>{const e=o({isCompatible:!1,version:"0.0.1"}),t=new i.ApplicationChecker(s(),r,e).check();expect(t).toStrictEqual(!1)}),it("should pass with min version inclusive when version matches",()=>{const e=o({isCompatible:!0,version:"1.12.0"}),t=new i.ApplicationChecker(s(),r,e).withMinVersionInclusive("1.12.0").check();expect(t).toStrictEqual(!0)}),it("should reject with min version inclusive when version is too low",()=>{const e=o({isCompatible:!0,version:"1.11.0"}),t=new i.ApplicationChecker(s(),r,e).withMinVersionInclusive("1.12.0").check();expect(t).toStrictEqual(!1)}),it("should pass with min version exclusive when version is greater",()=>{const e=o({isCompatible:!0,version:"1.13.0"}),t=new i.ApplicationChecker(s(),r,e).withMinVersionExclusive("1.12.0").check();expect(t).toStrictEqual(!0)}),it("should reject with min version exclusive when version is equal",()=>{const e=o({isCompatible:!0,version:"1.12.0"}),t=new i.ApplicationChecker(s(),r,e).withMinVersionExclusive("1.12.0").check();expect(t).toStrictEqual(!1)}),it("should pass when device model is not excluded",()=>{const e=o({isCompatible:!0,version:"1.12.0"}),t=new i.ApplicationChecker(s(c.DeviceModelId.FLEX),r,e).excludeDeviceModel(c.DeviceModelId.NANO_S).check();expect(t).toStrictEqual(!0)}),it("should reject when device model is excluded",()=>{const e=o({isCompatible:!0,version:"1.12.0"}),t=new i.ApplicationChecker(s(c.DeviceModelId.FLEX),r,e).excludeDeviceModel(c.DeviceModelId.FLEX).check();expect(t).toStrictEqual(!1)}),it("should pass with chained conditions when all are met",()=>{const e=o({isCompatible:!0,version:"1.12.0"}),t=new i.ApplicationChecker(s(),r,e).withMinVersionInclusive("1.11.0").excludeDeviceModel(c.DeviceModelId.NANO_S).check();expect(t).toStrictEqual(!0)}),it("should reject with chained conditions when one fails",()=>{const e=o({isCompatible:!0,version:"1.10.0"}),t=new i.ApplicationChecker(s(),r,e).withMinVersionInclusive("1.11.0").excludeDeviceModel(c.DeviceModelId.NANO_S).check();expect(t).toStrictEqual(!1)}),describe("withMinVersionInclusiveAcceptingPrerelease",()=>{it("should accept a release candidate of the minimum",()=>{const e=o({isCompatible:!0,version:"1.23.0-rc2"}),t=new i.ApplicationChecker(s(),r,e).withMinVersionInclusiveAcceptingPrerelease("1.23.0").check();expect(t).toStrictEqual(!0)}),it("should accept a dev build of the minimum",()=>{const e=o({isCompatible:!0,version:"1.23.0-dev"}),t=new i.ApplicationChecker(s(),r,e).withMinVersionInclusiveAcceptingPrerelease("1.23.0").check();expect(t).toStrictEqual(!0)}),it("should accept a plain version equal to the minimum",()=>{const e=o({isCompatible:!0,version:"1.23.0"}),t=new i.ApplicationChecker(s(),r,e).withMinVersionInclusiveAcceptingPrerelease("1.23.0").check();expect(t).toStrictEqual(!0)}),it("should accept a plain version above the minimum",()=>{const e=o({isCompatible:!0,version:"1.24.0"}),t=new i.ApplicationChecker(s(),r,e).withMinVersionInclusiveAcceptingPrerelease("1.23.0").check();expect(t).toStrictEqual(!0)}),it("should reject a plain version below the minimum",()=>{const e=o({isCompatible:!0,version:"1.22.9"}),t=new i.ApplicationChecker(s(),r,e).withMinVersionInclusiveAcceptingPrerelease("1.23.0").check();expect(t).toStrictEqual(!1)}),it("should reject a prerelease whose release core is below the minimum",()=>{const e=o({isCompatible:!0,version:"1.22.9-rc5"}),t=new i.ApplicationChecker(s(),r,e).withMinVersionInclusiveAcceptingPrerelease("1.23.0").check();expect(t).toStrictEqual(!1)}),it("should reject a version that cannot be parsed",()=>{const e=o({isCompatible:!0,version:"not-a-version"}),t=new i.ApplicationChecker(s(),r,e).withMinVersionInclusiveAcceptingPrerelease("1.23.0").check();expect(t).toStrictEqual(!1)}),it("should reject a minimum that cannot be parsed",()=>{const e=o({isCompatible:!0,version:"1.23.0"}),t=new i.ApplicationChecker(s(),r,e).withMinVersionInclusiveAcceptingPrerelease("not-a-version").check();expect(t).toStrictEqual(!1)}),it("should not override incompatible resolution",()=>{const e=o({isCompatible:!1,version:"1.23.0-rc2"}),t=new i.ApplicationChecker(s(),r,e).withMinVersionInclusiveAcceptingPrerelease("1.23.0").check();expect(t).toStrictEqual(!1)})}),it("should not override incompatible resolution even if constraints pass",()=>{const e=o({isCompatible:!1,version:"1.15.0"}),t=new i.ApplicationChecker(s(),r,e).withMinVersionInclusive("1.12.0").check();expect(t).toStrictEqual(!1)})});
|
|
2
2
|
//# sourceMappingURL=ApplicationChecker.test.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../src/api/utils/ApplicationChecker.test.ts"],
|
|
4
|
-
"sourcesContent": ["import { DeviceModelId } from \"@api/device/DeviceModel\";\nimport { DeviceStatus } from \"@api/device/DeviceStatus\";\nimport { DeviceSessionStateType } from \"@api/device-session/DeviceSessionState\";\n\nimport { ApplicationChecker } from \"./ApplicationChecker\";\nimport {\n type ApplicationResolver,\n type ResolvedApp,\n} from \"./ApplicationResolver\";\n\ndescribe(\"ApplicationChecker\", () => {\n function createReadyState(modelId: DeviceModelId = DeviceModelId.FLEX) {\n return {\n sessionStateType: DeviceSessionStateType.ReadyWithoutSecureChannel,\n deviceStatus: DeviceStatus.CONNECTED,\n installedApps: [],\n currentApp: { name: \"TestApp\", version: \"1.0.0\" },\n deviceModelId: modelId,\n isSecureConnectionAllowed: false,\n };\n }\n\n function createMockResolver(resolved: ResolvedApp): ApplicationResolver {\n return {\n resolve: () => resolved,\n };\n }\n\n const appConfig = { version: \"1.0.0\" };\n\n it(\"should pass check when resolved as compatible\", () => {\n const resolver = createMockResolver({\n isCompatible: true,\n version: \"1.12.0\",\n });\n const result = new ApplicationChecker(\n createReadyState(),\n appConfig,\n resolver,\n ).check();\n expect(result).toStrictEqual(true);\n });\n\n it(\"should reject check when resolved as incompatible\", () => {\n const resolver = createMockResolver({\n isCompatible: false,\n version: \"0.0.1\",\n });\n const result = new ApplicationChecker(\n createReadyState(),\n appConfig,\n resolver,\n ).check();\n expect(result).toStrictEqual(false);\n });\n\n it(\"should pass with min version inclusive when version matches\", () => {\n const resolver = createMockResolver({\n isCompatible: true,\n version: \"1.12.0\",\n });\n const result = new ApplicationChecker(\n createReadyState(),\n appConfig,\n resolver,\n )\n .withMinVersionInclusive(\"1.12.0\")\n .check();\n expect(result).toStrictEqual(true);\n });\n\n it(\"should reject with min version inclusive when version is too low\", () => {\n const resolver = createMockResolver({\n isCompatible: true,\n version: \"1.11.0\",\n });\n const result = new ApplicationChecker(\n createReadyState(),\n appConfig,\n resolver,\n )\n .withMinVersionInclusive(\"1.12.0\")\n .check();\n expect(result).toStrictEqual(false);\n });\n\n it(\"should pass with min version exclusive when version is greater\", () => {\n const resolver = createMockResolver({\n isCompatible: true,\n version: \"1.13.0\",\n });\n const result = new ApplicationChecker(\n createReadyState(),\n appConfig,\n resolver,\n )\n .withMinVersionExclusive(\"1.12.0\")\n .check();\n expect(result).toStrictEqual(true);\n });\n\n it(\"should reject with min version exclusive when version is equal\", () => {\n const resolver = createMockResolver({\n isCompatible: true,\n version: \"1.12.0\",\n });\n const result = new ApplicationChecker(\n createReadyState(),\n appConfig,\n resolver,\n )\n .withMinVersionExclusive(\"1.12.0\")\n .check();\n expect(result).toStrictEqual(false);\n });\n\n it(\"should pass when device model is not excluded\", () => {\n const resolver = createMockResolver({\n isCompatible: true,\n version: \"1.12.0\",\n });\n const result = new ApplicationChecker(\n createReadyState(DeviceModelId.FLEX),\n appConfig,\n resolver,\n )\n .excludeDeviceModel(DeviceModelId.NANO_S)\n .check();\n expect(result).toStrictEqual(true);\n });\n\n it(\"should reject when device model is excluded\", () => {\n const resolver = createMockResolver({\n isCompatible: true,\n version: \"1.12.0\",\n });\n const result = new ApplicationChecker(\n createReadyState(DeviceModelId.FLEX),\n appConfig,\n resolver,\n )\n .excludeDeviceModel(DeviceModelId.FLEX)\n .check();\n expect(result).toStrictEqual(false);\n });\n\n it(\"should pass with chained conditions when all are met\", () => {\n const resolver = createMockResolver({\n isCompatible: true,\n version: \"1.12.0\",\n });\n const result = new ApplicationChecker(\n createReadyState(),\n appConfig,\n resolver,\n )\n .withMinVersionInclusive(\"1.11.0\")\n .excludeDeviceModel(DeviceModelId.NANO_S)\n .check();\n expect(result).toStrictEqual(true);\n });\n\n it(\"should reject with chained conditions when one fails\", () => {\n const resolver = createMockResolver({\n isCompatible: true,\n version: \"1.10.0\",\n });\n const result = new ApplicationChecker(\n createReadyState(),\n appConfig,\n resolver,\n )\n .withMinVersionInclusive(\"1.11.0\")\n .excludeDeviceModel(DeviceModelId.NANO_S)\n .check();\n expect(result).toStrictEqual(false);\n });\n\n it(\"should not override incompatible resolution even if constraints pass\", () => {\n const resolver = createMockResolver({\n isCompatible: false,\n version: \"1.15.0\",\n });\n const result = new ApplicationChecker(\n createReadyState(),\n appConfig,\n resolver,\n )\n .withMinVersionInclusive(\"1.12.0\")\n .check();\n expect(result).toStrictEqual(false);\n });\n});\n"],
|
|
5
|
-
"mappings": "aAAA,IAAAA,EAA8B,mCAC9BC,EAA6B,oCAC7BC,EAAuC,kDAEvCC,EAAmC,gCAMnC,SAAS,qBAAsB,IAAM,CACnC,SAASC,EAAiBC,EAAyB,gBAAc,KAAM,CACrE,MAAO,CACL,iBAAkB,yBAAuB,0BACzC,aAAc,eAAa,UAC3B,cAAe,CAAC,EAChB,WAAY,CAAE,KAAM,UAAW,QAAS,OAAQ,EAChD,cAAeA,EACf,0BAA2B,EAC7B,CACF,CAEA,SAASC,EAAmBC,EAA4C,CACtE,MAAO,CACL,QAAS,IAAMA,CACjB,CACF,CAEA,MAAMC,EAAY,CAAE,QAAS,OAAQ,EAErC,GAAG,gDAAiD,IAAM,CACxD,MAAMC,EAAWH,EAAmB,CAClC,aAAc,GACd,QAAS,QACX,CAAC,EACKI,EAAS,IAAI,qBACjBN,EAAiB,EACjBI,EACAC,CACF,EAAE,MAAM,EACR,OAAOC,CAAM,EAAE,cAAc,EAAI,CACnC,CAAC,EAED,GAAG,oDAAqD,IAAM,CAC5D,MAAMD,EAAWH,EAAmB,CAClC,aAAc,GACd,QAAS,OACX,CAAC,EACKI,EAAS,IAAI,qBACjBN,EAAiB,EACjBI,EACAC,CACF,EAAE,MAAM,EACR,OAAOC,CAAM,EAAE,cAAc,EAAK,CACpC,CAAC,EAED,GAAG,8DAA+D,IAAM,CACtE,MAAMD,EAAWH,EAAmB,CAClC,aAAc,GACd,QAAS,QACX,CAAC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CAAM,EAAE,cAAc,EAAK,CACpC,CAAC,EAED,GAAG,uDAAwD,IAAM,CAC/D,MAAMD,EAAWH,EAAmB,CAClC,aAAc,GACd,QAAS,QACX,CAAC,EACKI,EAAS,IAAI,qBACjBN,EAAiB,EACjBI,EACAC,CACF,EACG,wBAAwB,QAAQ,EAChC,mBAAmB,gBAAc,MAAM,EACvC,MAAM,EACT,OAAOC,CAAM,EAAE,cAAc,EAAI,CACnC,CAAC,EAED,GAAG,uDAAwD,IAAM,CAC/D,MAAMD,EAAWH,EAAmB,CAClC,aAAc,GACd,QAAS,QACX,CAAC,EACKI,EAAS,IAAI,qBACjBN,EAAiB,EACjBI,EACAC,CACF,EACG,wBAAwB,QAAQ,EAChC,mBAAmB,gBAAc,MAAM,EACvC,MAAM,EACT,OAAOC,CAAM,EAAE,cAAc,EAAK,CACpC,CAAC,EAED,GAAG,uEAAwE,IAAM,CAC/E,MAAMD,EAAWH,EAAmB,CAClC,aAAc,GACd,QAAS,QACX,CAAC,EACKI,EAAS,IAAI,qBACjBN,EAAiB,EACjBI,EACAC,CACF,EACG,wBAAwB,QAAQ,EAChC,MAAM,EACT,OAAOC,CAAM,EAAE,cAAc,EAAK,CACpC,CAAC,CACH,CAAC",
|
|
4
|
+
"sourcesContent": ["import { DeviceModelId } from \"@api/device/DeviceModel\";\nimport { DeviceStatus } from \"@api/device/DeviceStatus\";\nimport { DeviceSessionStateType } from \"@api/device-session/DeviceSessionState\";\n\nimport { ApplicationChecker } from \"./ApplicationChecker\";\nimport {\n type ApplicationResolver,\n type ResolvedApp,\n} from \"./ApplicationResolver\";\n\ndescribe(\"ApplicationChecker\", () => {\n function createReadyState(modelId: DeviceModelId = DeviceModelId.FLEX) {\n return {\n sessionStateType: DeviceSessionStateType.ReadyWithoutSecureChannel,\n deviceStatus: DeviceStatus.CONNECTED,\n installedApps: [],\n currentApp: { name: \"TestApp\", version: \"1.0.0\" },\n deviceModelId: modelId,\n isSecureConnectionAllowed: false,\n };\n }\n\n function createMockResolver(resolved: ResolvedApp): ApplicationResolver {\n return {\n resolve: () => resolved,\n };\n }\n\n const appConfig = { version: \"1.0.0\" };\n\n it(\"should pass check when resolved as compatible\", () => {\n const resolver = createMockResolver({\n isCompatible: true,\n version: \"1.12.0\",\n });\n const result = new ApplicationChecker(\n createReadyState(),\n appConfig,\n resolver,\n ).check();\n expect(result).toStrictEqual(true);\n });\n\n it(\"should reject check when resolved as incompatible\", () => {\n const resolver = createMockResolver({\n isCompatible: false,\n version: \"0.0.1\",\n });\n const result = new ApplicationChecker(\n createReadyState(),\n appConfig,\n resolver,\n ).check();\n expect(result).toStrictEqual(false);\n });\n\n it(\"should pass with min version inclusive when version matches\", () => {\n const resolver = createMockResolver({\n isCompatible: true,\n version: \"1.12.0\",\n });\n const result = new ApplicationChecker(\n createReadyState(),\n appConfig,\n resolver,\n )\n .withMinVersionInclusive(\"1.12.0\")\n .check();\n expect(result).toStrictEqual(true);\n });\n\n it(\"should reject with min version inclusive when version is too low\", () => {\n const resolver = createMockResolver({\n isCompatible: true,\n version: \"1.11.0\",\n });\n const result = new ApplicationChecker(\n createReadyState(),\n appConfig,\n resolver,\n )\n .withMinVersionInclusive(\"1.12.0\")\n .check();\n expect(result).toStrictEqual(false);\n });\n\n it(\"should pass with min version exclusive when version is greater\", () => {\n const resolver = createMockResolver({\n isCompatible: true,\n version: \"1.13.0\",\n });\n const result = new ApplicationChecker(\n createReadyState(),\n appConfig,\n resolver,\n )\n .withMinVersionExclusive(\"1.12.0\")\n .check();\n expect(result).toStrictEqual(true);\n });\n\n it(\"should reject with min version exclusive when version is equal\", () => {\n const resolver = createMockResolver({\n isCompatible: true,\n version: \"1.12.0\",\n });\n const result = new ApplicationChecker(\n createReadyState(),\n appConfig,\n resolver,\n )\n .withMinVersionExclusive(\"1.12.0\")\n .check();\n expect(result).toStrictEqual(false);\n });\n\n it(\"should pass when device model is not excluded\", () => {\n const resolver = createMockResolver({\n isCompatible: true,\n version: \"1.12.0\",\n });\n const result = new ApplicationChecker(\n createReadyState(DeviceModelId.FLEX),\n appConfig,\n resolver,\n )\n .excludeDeviceModel(DeviceModelId.NANO_S)\n .check();\n expect(result).toStrictEqual(true);\n });\n\n it(\"should reject when device model is excluded\", () => {\n const resolver = createMockResolver({\n isCompatible: true,\n version: \"1.12.0\",\n });\n const result = new ApplicationChecker(\n createReadyState(DeviceModelId.FLEX),\n appConfig,\n resolver,\n )\n .excludeDeviceModel(DeviceModelId.FLEX)\n .check();\n expect(result).toStrictEqual(false);\n });\n\n it(\"should pass with chained conditions when all are met\", () => {\n const resolver = createMockResolver({\n isCompatible: true,\n version: \"1.12.0\",\n });\n const result = new ApplicationChecker(\n createReadyState(),\n appConfig,\n resolver,\n )\n .withMinVersionInclusive(\"1.11.0\")\n .excludeDeviceModel(DeviceModelId.NANO_S)\n .check();\n expect(result).toStrictEqual(true);\n });\n\n it(\"should reject with chained conditions when one fails\", () => {\n const resolver = createMockResolver({\n isCompatible: true,\n version: \"1.10.0\",\n });\n const result = new ApplicationChecker(\n createReadyState(),\n appConfig,\n resolver,\n )\n .withMinVersionInclusive(\"1.11.0\")\n .excludeDeviceModel(DeviceModelId.NANO_S)\n .check();\n expect(result).toStrictEqual(false);\n });\n\n describe(\"withMinVersionInclusiveAcceptingPrerelease\", () => {\n it(\"should accept a release candidate of the minimum\", () => {\n const resolver = createMockResolver({\n isCompatible: true,\n version: \"1.23.0-rc2\",\n });\n const result = new ApplicationChecker(\n createReadyState(),\n appConfig,\n resolver,\n )\n .withMinVersionInclusiveAcceptingPrerelease(\"1.23.0\")\n .check();\n expect(result).toStrictEqual(true);\n });\n\n it(\"should accept a dev build of the minimum\", () => {\n const resolver = createMockResolver({\n isCompatible: true,\n version: \"1.23.0-dev\",\n });\n const result = new ApplicationChecker(\n createReadyState(),\n appConfig,\n resolver,\n )\n .withMinVersionInclusiveAcceptingPrerelease(\"1.23.0\")\n .check();\n expect(result).toStrictEqual(true);\n });\n\n it(\"should accept a plain version equal to the minimum\", () => {\n const resolver = createMockResolver({\n isCompatible: true,\n version: \"1.23.0\",\n });\n const result = new ApplicationChecker(\n createReadyState(),\n appConfig,\n resolver,\n )\n .withMinVersionInclusiveAcceptingPrerelease(\"1.23.0\")\n .check();\n expect(result).toStrictEqual(true);\n });\n\n it(\"should accept a plain version above the minimum\", () => {\n const resolver = createMockResolver({\n isCompatible: true,\n version: \"1.24.0\",\n });\n const result = new ApplicationChecker(\n createReadyState(),\n appConfig,\n resolver,\n )\n .withMinVersionInclusiveAcceptingPrerelease(\"1.23.0\")\n .check();\n expect(result).toStrictEqual(true);\n });\n\n it(\"should reject a plain version below the minimum\", () => {\n const resolver = createMockResolver({\n isCompatible: true,\n version: \"1.22.9\",\n });\n const result = new ApplicationChecker(\n createReadyState(),\n appConfig,\n resolver,\n )\n .withMinVersionInclusiveAcceptingPrerelease(\"1.23.0\")\n .check();\n expect(result).toStrictEqual(false);\n });\n\n it(\"should reject a prerelease whose release core is below the minimum\", () => {\n const resolver = createMockResolver({\n isCompatible: true,\n version: \"1.22.9-rc5\",\n });\n const result = new ApplicationChecker(\n createReadyState(),\n appConfig,\n resolver,\n )\n .withMinVersionInclusiveAcceptingPrerelease(\"1.23.0\")\n .check();\n expect(result).toStrictEqual(false);\n });\n\n it(\"should reject a version that cannot be parsed\", () => {\n const resolver = createMockResolver({\n isCompatible: true,\n version: \"not-a-version\",\n });\n const result = new ApplicationChecker(\n createReadyState(),\n appConfig,\n resolver,\n )\n .withMinVersionInclusiveAcceptingPrerelease(\"1.23.0\")\n .check();\n expect(result).toStrictEqual(false);\n });\n\n it(\"should reject a minimum that cannot be parsed\", () => {\n const resolver = createMockResolver({\n isCompatible: true,\n version: \"1.23.0\",\n });\n const result = new ApplicationChecker(\n createReadyState(),\n appConfig,\n resolver,\n )\n .withMinVersionInclusiveAcceptingPrerelease(\"not-a-version\")\n .check();\n expect(result).toStrictEqual(false);\n });\n\n it(\"should not override incompatible resolution\", () => {\n const resolver = createMockResolver({\n isCompatible: false,\n version: \"1.23.0-rc2\",\n });\n const result = new ApplicationChecker(\n createReadyState(),\n appConfig,\n resolver,\n )\n .withMinVersionInclusiveAcceptingPrerelease(\"1.23.0\")\n .check();\n expect(result).toStrictEqual(false);\n });\n });\n\n it(\"should not override incompatible resolution even if constraints pass\", () => {\n const resolver = createMockResolver({\n isCompatible: false,\n version: \"1.15.0\",\n });\n const result = new ApplicationChecker(\n createReadyState(),\n appConfig,\n resolver,\n )\n .withMinVersionInclusive(\"1.12.0\")\n .check();\n expect(result).toStrictEqual(false);\n });\n});\n"],
|
|
5
|
+
"mappings": "aAAA,IAAAA,EAA8B,mCAC9BC,EAA6B,oCAC7BC,EAAuC,kDAEvCC,EAAmC,gCAMnC,SAAS,qBAAsB,IAAM,CACnC,SAASC,EAAiBC,EAAyB,gBAAc,KAAM,CACrE,MAAO,CACL,iBAAkB,yBAAuB,0BACzC,aAAc,eAAa,UAC3B,cAAe,CAAC,EAChB,WAAY,CAAE,KAAM,UAAW,QAAS,OAAQ,EAChD,cAAeA,EACf,0BAA2B,EAC7B,CACF,CAEA,SAASC,EAAmBC,EAA4C,CACtE,MAAO,CACL,QAAS,IAAMA,CACjB,CACF,CAEA,MAAMC,EAAY,CAAE,QAAS,OAAQ,EAErC,GAAG,gDAAiD,IAAM,CACxD,MAAMC,EAAWH,EAAmB,CAClC,aAAc,GACd,QAAS,QACX,CAAC,EACKI,EAAS,IAAI,qBACjBN,EAAiB,EACjBI,EACAC,CACF,EAAE,MAAM,EACR,OAAOC,CAAM,EAAE,cAAc,EAAI,CACnC,CAAC,EAED,GAAG,oDAAqD,IAAM,CAC5D,MAAMD,EAAWH,EAAmB,CAClC,aAAc,GACd,QAAS,OACX,CAAC,EACKI,EAAS,IAAI,qBACjBN,EAAiB,EACjBI,EACAC,CACF,EAAE,MAAM,EACR,OAAOC,CAAM,EAAE,cAAc,EAAK,CACpC,CAAC,EAED,GAAG,8DAA+D,IAAM,CACtE,MAAMD,EAAWH,EAAmB,CAClC,aAAc,GACd,QAA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ACF,EACG,2CAA2C,QAAQ,EACnD,MAAM,EACT,OAAOC,CAAM,EAAE,cAAc,EAAK,CACpC,CAAC,CACH,CAAC,EAED,GAAG,uEAAwE,IAAM,CAC/E,MAAMD,EAAWH,EAAmB,CAClC,aAAc,GACd,QAAS,QACX,CAAC,EACKI,EAAS,IAAI,qBACjBN,EAAiB,EACjBI,EACAC,CACF,EACG,wBAAwB,QAAQ,EAChC,MAAM,EACT,OAAOC,CAAM,EAAE,cAAc,EAAK,CACpC,CAAC,CACH,CAAC",
|
|
6
6
|
"names": ["import_DeviceModel", "import_DeviceStatus", "import_DeviceSessionState", "import_ApplicationChecker", "createReadyState", "modelId", "createMockResolver", "resolved", "appConfig", "resolver", "result"]
|
|
7
7
|
}
|
package/lib/esm/package.json
CHANGED
|
@@ -62,5 +62,5 @@
|
|
|
62
62
|
"watch:builds": "pnpm ldmk-tool watch --entryPoints index.ts,src/**/*.ts --tsconfig tsconfig.prod.json",
|
|
63
63
|
"watch:types": "concurrently \"tsc --watch -p tsconfig.prod.json\" \"tsc-alias --watch -p tsconfig.prod.json\""
|
|
64
64
|
},
|
|
65
|
-
"version": "0.0.0-develop-
|
|
65
|
+
"version": "0.0.0-develop-20260904001312"
|
|
66
66
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{coerce as
|
|
1
|
+
import{coerce as c,gte as s}from"semver";import{ApduBuilder as O}from"../../apdu/utils/ApduBuilder";import{ApduParser as F}from"../../apdu/utils/ApduParser";import{InvalidStatusWordError as b}from"../../command/Errors";import{CommandResultFactory as g}from"../../command/model/CommandResult";import{CommandUtils as N}from"../../command/utils/CommandUtils";import{GlobalCommandErrorHandler as E}from"../../command/utils/GlobalCommandError";import{DeviceModelId as t}from"../../device/DeviceModel";import{SecureElementFlagsParser as w}from"./SecureElementFlagsParser";class X{name="getOsVersion";args=void 0;getApdu(){const r={cla:224,ins:1,p1:0,p2:0};return new O(r).build()}parseResponse(r,n){if(!N.isSuccessResponse(r))return g({error:E.handle(r)});const e=new F(r),d=e.extract32BitUInt();if(d===void 0)return g({error:new b("Missing target ID in OS version")});let a=e.encodeToString(e.extractFieldLVEncoded()),m=e.extractFieldLVEncoded()??new Uint8Array(0);const l=new w(m),I={...l.generalDeviceState(),...l.endorsementInformation(),...l.wordsInformation(),...l.onboardingStatus()};a||(a="0.0.0",m=new Uint8Array);const S=(d&4026531840)!==805306368,v=a.includes("-osu");let i="",V="",p="",f="",y,u,A,x;if(S){p=a,y=d;const o=e.extractFieldLVEncoded();o&&(o.length>=5?(i=e.encodeToString(o),u=parseInt(e.encodeToHexaString(e.extractFieldLVEncoded()),16)):u=parseInt(e.encodeToHexaString(o),16))}else{if(i=a,u=d,V=e.encodeToString(e.extractFieldLVEncoded()),this.isBootloaderVersionSupported(i,n)&&(p=e.encodeToString(e.extractFieldLVEncoded())),this.isHardwareVersionSupported(i,n)?f=e.encodeToHexaString(e.extractFieldLVEncoded()):f="00",this.isLocalizationSupported(i,n)){const o=e.extractFieldLVEncoded();o!==void 0&&(A=parseInt(e.encodeToHexaString(o),16))}if(this.isRecoverSupported(i,n)){const o=e.extractFieldLVEncoded();o!==void 0&&(x=parseInt(e.encodeToHexaString(o),16))}}return g({data:{isBootloader:S,isOsu:v,targetId:d,seTargetId:u,mcuTargetId:y,seVersion:i,seFlags:m,mcuSephVersion:V,mcuBootloaderVersion:p,hwVersion:f,langId:A,recoverState:x,secureElementFlags:I}})}isBootloaderVersionSupported(r,n){const e=c(r)??"";switch(n){case t.NANO_S:case t.NANO_X:return s(e,"2.0.0");default:return!0}}isHardwareVersionSupported(r,n){const e=c(r)??"";switch(n){case t.NANO_X:return s(e,"2.0.0");default:return!1}}isLocalizationSupported(r,n){const e=c(r)??"";switch(n){case t.NANO_S:return!1;case t.NANO_SP:return s(e,"1.1.0");case t.NANO_X:return s(e,"2.1.0");default:return!0}}isRecoverSupported(r,n){const e=c(r)??"";switch(n){case t.NANO_S:return!1;case t.NANO_SP:return s(e,"1.1.2");case t.NANO_X:return s(e,"2.2.3");case t.STAX:return s(e,"1.4.0");case t.FLEX:return s(e,"1.0.1");default:return!0}}}export{X as GetOsVersionCommand};
|
|
2
2
|
//# sourceMappingURL=GetOsVersionCommand.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../../src/api/command/os/GetOsVersionCommand.ts"],
|
|
4
|
-
"sourcesContent": ["import { coerce, gte } from \"semver\";\n\nimport { type Apdu } from \"@api/apdu/model/Apdu\";\nimport { ApduBuilder, type ApduBuilderArgs } from \"@api/apdu/utils/ApduBuilder\";\nimport { ApduParser } from \"@api/apdu/utils/ApduParser\";\nimport { type Command } from \"@api/command/Command\";\nimport { InvalidStatusWordError } from \"@api/command/Errors\";\nimport {\n type CommandResult,\n CommandResultFactory,\n} from \"@api/command/model/CommandResult\";\nimport { CommandUtils } from \"@api/command/utils/CommandUtils\";\nimport { GlobalCommandErrorHandler } from \"@api/command/utils/GlobalCommandError\";\nimport { DeviceModelId } from \"@api/device/DeviceModel\";\nimport {
|
|
5
|
-
"mappings": "AAAA,OAAS,UAAAA,EAAQ,OAAAC,MAAW,SAG5B,OAAS,eAAAC,MAAyC,8BAClD,OAAS,cAAAC,MAAkB,6BAE3B,OAAS,0BAAAC,MAA8B,sBACvC,OAEE,wBAAAC,MACK,mCACP,OAAS,gBAAAC,MAAoB,kCAC7B,OAAS,6BAAAC,MAAiC,wCAC1C,OAAS,iBAAAC,MAAqB,
|
|
6
|
-
"names": ["coerce", "gte", "ApduBuilder", "ApduParser", "InvalidStatusWordError", "CommandResultFactory", "CommandUtils", "GlobalCommandErrorHandler", "DeviceModelId", "SecureElementFlagsParser", "GetOsVersionCommand", "getOsVersionApduArgs", "apduResponse", "deviceModelId", "parser", "targetId", "version", "seFlags", "secureElementFlags", "isBootloader", "isOsu", "seVersion", "mcuSephVersion", "mcuBootloaderVersion", "hwVersion", "mcuTargetId", "seTargetId", "langId", "recoverState", "seData", "langIdBuffer", "recoverStateBuffer"]
|
|
4
|
+
"sourcesContent": ["import { coerce, gte } from \"semver\";\n\nimport { type Apdu } from \"@api/apdu/model/Apdu\";\nimport { ApduBuilder, type ApduBuilderArgs } from \"@api/apdu/utils/ApduBuilder\";\nimport { ApduParser } from \"@api/apdu/utils/ApduParser\";\nimport { type Command } from \"@api/command/Command\";\nimport { InvalidStatusWordError } from \"@api/command/Errors\";\nimport {\n type CommandResult,\n CommandResultFactory,\n} from \"@api/command/model/CommandResult\";\nimport { CommandUtils } from \"@api/command/utils/CommandUtils\";\nimport { GlobalCommandErrorHandler } from \"@api/command/utils/GlobalCommandError\";\nimport { DeviceModelId } from \"@api/device/DeviceModel\";\nimport { type SecureElementFlags } from \"@api/device/SecureElementFlags\";\nimport { type ApduResponse } from \"@api/device-session/ApduResponse\";\n\nimport { SecureElementFlagsParser } from \"./SecureElementFlagsParser\";\n\n/**\n * Response of the GetOsVersionCommand.\n */\nexport type GetOsVersionResponse = {\n /**\n * Indicated if the device is running in bootloader mode.\n * It can happens during a firmware update process.\n */\n readonly isBootloader: boolean;\n\n /**\n * Indicated if the device firmware is an OS Updater (OSU).\n * It can happens during a firmware update process.\n */\n readonly isOsu: boolean;\n\n /**\n * Target identifier.\n */\n readonly targetId: number;\n\n /**\n * Target identifier of the secure element.\n * Not always available when the device is in bootloader mode.\n */\n readonly seTargetId: number | undefined;\n\n /**\n * Target identifier of the microcontroller unit (MCU).\n * Only available when the device is in bootloader mode.\n */\n readonly mcuTargetId: number | undefined;\n\n /**\n * Version of BOLOS on the secure element (SE).\n * {@link https://developers.ledger.com/docs/device-app/architecture/bolos/hardware-architecture | Hardware Architecture}\n */\n readonly seVersion: string;\n\n /**\n * Secure element flags.\n * Used to represent the current state of the secure element.\n */\n readonly seFlags: Uint8Array;\n\n /**\n * Version of the microcontroller unit (MCU) SEPH, which is the SE-MCU link protocol.\n * {@link https://developers.ledger.com/docs/device-app/architecture/bolos/hardware-architecture | Hardware Architecture}\n */\n readonly mcuSephVersion: string;\n\n /**\n * Version of the MCU bootloader.\n */\n readonly mcuBootloaderVersion: string;\n\n /**\n * Hardware revision version.\n * Only available for Ledger Nano X in which case it's \"00\" or \"01\".\n */\n readonly hwVersion: string;\n\n /**\n * Identifier of the installed language pack.\n * Can be one of:\n * - \"00\": English\n * - \"01\": French\n * - \"02\": Spanish\n * - \"03\": Portuguese\n * - \"04\": German\n * - \"05\": Russian\n * - \"06\": Turkish\n */\n readonly langId: number | undefined;\n\n /**\n * State for Ledger Recover. // [SHOULD] Add more information about this field\n */\n readonly recoverState: number | undefined;\n\n /**\n * The parsed secure element flags.\n */\n readonly secureElementFlags: SecureElementFlags;\n};\n\nexport type GetOsVersionCommandResult = CommandResult<GetOsVersionResponse>;\n\n/**\n * Command to get information about the device firmware.\n */\nexport class GetOsVersionCommand implements Command<GetOsVersionResponse> {\n readonly name = \"getOsVersion\";\n readonly args = undefined;\n\n getApdu(): Apdu {\n const getOsVersionApduArgs: ApduBuilderArgs = {\n cla: 0xe0,\n ins: 0x01,\n p1: 0x00,\n p2: 0x00,\n };\n return new ApduBuilder(getOsVersionApduArgs).build();\n }\n\n parseResponse(\n apduResponse: ApduResponse,\n deviceModelId: DeviceModelId,\n ): GetOsVersionCommandResult {\n if (!CommandUtils.isSuccessResponse(apduResponse)) {\n return CommandResultFactory({\n error: GlobalCommandErrorHandler.handle(apduResponse),\n });\n }\n const parser = new ApduParser(apduResponse);\n const targetId = parser.extract32BitUInt();\n if (targetId === undefined) {\n return CommandResultFactory({\n error: new InvalidStatusWordError(\"Missing target ID in OS version\"),\n });\n }\n\n let version = parser.encodeToString(parser.extractFieldLVEncoded());\n let seFlags = parser.extractFieldLVEncoded() ?? new Uint8Array(0);\n const seFlagsParser = new SecureElementFlagsParser(seFlags);\n const secureElementFlags = {\n ...seFlagsParser.generalDeviceState(),\n ...seFlagsParser.endorsementInformation(),\n ...seFlagsParser.wordsInformation(),\n ...seFlagsParser.onboardingStatus(),\n };\n\n // Handle old firmwares with no version\n if (!version) {\n version = \"0.0.0\";\n seFlags = new Uint8Array();\n }\n\n const isBootloader = (targetId & 0xf0000000) !== 0x30000000;\n const isOsu = version.includes(\"-osu\");\n let seVersion: string = \"\";\n let mcuSephVersion: string = \"\";\n let mcuBootloaderVersion: string = \"\";\n let hwVersion: string = \"\";\n let mcuTargetId: number | undefined = undefined;\n let seTargetId: number | undefined = undefined;\n let langId: number | undefined = undefined;\n let recoverState: number | undefined = undefined;\n\n if (isBootloader) {\n mcuBootloaderVersion = version;\n mcuTargetId = targetId;\n\n const seData = parser.extractFieldLVEncoded();\n if (seData) {\n if (seData.length >= 5) {\n // It means it's a version followed by the seTargetId\n seVersion = parser.encodeToString(seData);\n seTargetId = parseInt(\n parser.encodeToHexaString(parser.extractFieldLVEncoded()),\n 16,\n );\n } else {\n // It's the seTargetId\n seTargetId = parseInt(parser.encodeToHexaString(seData), 16);\n }\n }\n } else {\n seVersion = version;\n seTargetId = targetId;\n\n mcuSephVersion = parser.encodeToString(parser.extractFieldLVEncoded());\n\n if (this.isBootloaderVersionSupported(seVersion, deviceModelId)) {\n mcuBootloaderVersion = parser.encodeToString(\n parser.extractFieldLVEncoded(),\n );\n }\n\n if (this.isHardwareVersionSupported(seVersion, deviceModelId)) {\n hwVersion = parser.encodeToHexaString(parser.extractFieldLVEncoded());\n } else {\n hwVersion = \"00\";\n }\n\n if (this.isLocalizationSupported(seVersion, deviceModelId)) {\n const langIdBuffer = parser.extractFieldLVEncoded();\n if (langIdBuffer !== undefined) {\n langId = parseInt(parser.encodeToHexaString(langIdBuffer), 16);\n }\n }\n\n if (this.isRecoverSupported(seVersion, deviceModelId)) {\n const recoverStateBuffer = parser.extractFieldLVEncoded();\n if (recoverStateBuffer !== undefined) {\n recoverState = parseInt(\n parser.encodeToHexaString(recoverStateBuffer),\n 16,\n );\n }\n }\n }\n\n return CommandResultFactory({\n data: {\n isBootloader,\n isOsu,\n targetId,\n seTargetId,\n mcuTargetId,\n seVersion,\n seFlags,\n mcuSephVersion,\n mcuBootloaderVersion,\n hwVersion,\n langId,\n recoverState,\n secureElementFlags,\n },\n });\n }\n\n private isBootloaderVersionSupported(\n seVersion: string,\n deviceModelId: DeviceModelId,\n ): boolean {\n const version = coerce(seVersion) ?? \"\";\n switch (deviceModelId) {\n case DeviceModelId.NANO_S:\n case DeviceModelId.NANO_X:\n return gte(version, \"2.0.0\");\n default:\n return true;\n }\n }\n\n private isHardwareVersionSupported(\n seVersion: string,\n deviceModelId: DeviceModelId,\n ): boolean {\n const version = coerce(seVersion) ?? \"\";\n switch (deviceModelId) {\n case DeviceModelId.NANO_X:\n return gte(version, \"2.0.0\");\n default:\n return false;\n }\n }\n\n private isLocalizationSupported(\n seVersion: string,\n deviceModelId: DeviceModelId,\n ): boolean {\n const version = coerce(seVersion) ?? \"\";\n switch (deviceModelId) {\n case DeviceModelId.NANO_S:\n return false;\n case DeviceModelId.NANO_SP:\n return gte(version, \"1.1.0\");\n case DeviceModelId.NANO_X:\n return gte(version, \"2.1.0\");\n default:\n return true;\n }\n }\n\n private isRecoverSupported(\n seVersion: string,\n deviceModelId: DeviceModelId,\n ): boolean {\n const version = coerce(seVersion) ?? \"\";\n switch (deviceModelId) {\n case DeviceModelId.NANO_S:\n return false;\n case DeviceModelId.NANO_SP:\n return gte(version, \"1.1.2\");\n case DeviceModelId.NANO_X:\n return gte(version, \"2.2.3\");\n case DeviceModelId.STAX:\n return gte(version, \"1.4.0\");\n case DeviceModelId.FLEX:\n return gte(version, \"1.0.1\");\n default:\n return true;\n }\n }\n}\n"],
|
|
5
|
+
"mappings": "AAAA,OAAS,UAAAA,EAAQ,OAAAC,MAAW,SAG5B,OAAS,eAAAC,MAAyC,8BAClD,OAAS,cAAAC,MAAkB,6BAE3B,OAAS,0BAAAC,MAA8B,sBACvC,OAEE,wBAAAC,MACK,mCACP,OAAS,gBAAAC,MAAoB,kCAC7B,OAAS,6BAAAC,MAAiC,wCAC1C,OAAS,iBAAAC,MAAqB,0BAI9B,OAAS,4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EAAOsB,CAAS,GAAK,GACrC,OAAQT,EAAe,CACrB,KAAKL,EAAc,OACjB,MAAO,GACT,KAAKA,EAAc,QACjB,OAAOP,EAAIe,EAAS,OAAO,EAC7B,KAAKR,EAAc,OACjB,OAAOP,EAAIe,EAAS,OAAO,EAC7B,QACE,MAAO,EACX,CACF,CAEQ,mBACNM,EACAT,EACS,CACT,MAAMG,EAAUhB,EAAOsB,CAAS,GAAK,GACrC,OAAQT,EAAe,CACrB,KAAKL,EAAc,OACjB,MAAO,GACT,KAAKA,EAAc,QACjB,OAAOP,EAAIe,EAAS,OAAO,EAC7B,KAAKR,EAAc,OACjB,OAAOP,EAAIe,EAAS,OAAO,EAC7B,KAAKR,EAAc,KACjB,OAAOP,EAAIe,EAAS,OAAO,EAC7B,KAAKR,EAAc,KACjB,OAAOP,EAAIe,EAAS,OAAO,EAC7B,QACE,MAAO,EACX,CACF,CACF",
|
|
6
|
+
"names": ["coerce", "gte", "ApduBuilder", "ApduParser", "InvalidStatusWordError", "CommandResultFactory", "CommandUtils", "GlobalCommandErrorHandler", "DeviceModelId", "SecureElementFlagsParser", "GetOsVersionCommand", "getOsVersionApduArgs", "apduResponse", "deviceModelId", "parser", "targetId", "version", "seFlags", "seFlagsParser", "secureElementFlags", "isBootloader", "isOsu", "seVersion", "mcuSephVersion", "mcuBootloaderVersion", "hwVersion", "mcuTargetId", "seTargetId", "langId", "recoverState", "seData", "langIdBuffer", "recoverStateBuffer"]
|
|
7
7
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{CommandResultFactory as o,isSuccessCommandResult as
|
|
1
|
+
import{CommandResultFactory as o,isSuccessCommandResult as a}from"../../command/model/CommandResult";import{DeviceModelId as r}from"../../device/DeviceModel";import{OnboardingState as n}from"../../device/SecureElementFlags";import{ApduResponse as x}from"../../device-session/ApduResponse";import{getOsVersionCommandResponseMockBuilder as d}from"./__mocks__/GetOsVersionCommand";import{GetOsVersionCommand as u}from"./GetOsVersionCommand";const p=Uint8Array.from([224,1,0,0,0]),l=Uint8Array.from([51,0,0,4,5,50,46,50,46,51,4,230,0,0,0,4,50,46,51,48,4,49,46,49,54,1,0,1,0,1,0,144,0]),f=new x({statusCode:Uint8Array.from([144,0]),data:l}),S=new x({statusCode:Uint8Array.from([144,0]),data:Uint8Array.from([51,0,0,4,5,50,46,50,46,51,0,4,50,46,51,48,4,49,46,49,54,1,0,1,0,1,0,144,0])}),m=Uint8Array.from([51,16,0,4,5,49,46,49,46,49,4,230,0,0,0,4,52,46,48,51,4,51,46,49,50,1,0,1,0,144,0]),A=new x({statusCode:Uint8Array.from([144,0]),data:m}),O=Uint8Array.from([51,32,0,4,5,49,46,51,46,48,4,230,0,0,0,4,53,46,50,52,4,48,46,52,56,1,0,1,0,144,0]),E=new x({statusCode:Uint8Array.from([144,0]),data:O}),_=Uint8Array.from([5,1,0,3,4,49,46,49,54,4,244,216,170,67,5,50,46,50,46,51,4,51,0,0,4,144,0]),h=new x({statusCode:Uint8Array.from([144,0]),data:_}),N=Uint8Array.from([51,0,0,4,0,4,238,0,0,0,4,50,46,51,48,1,1,1,0,1,0,144,0]),C=new x({statusCode:Uint8Array.from([144,0]),data:N});describe("GetOsVersionCommand",()=>{let s;beforeEach(()=>{s=new u}),describe("name",()=>{it("should be 'getOsVersion'",()=>{expect(s.name).toBe("getOsVersion")})}),describe("getApdu",()=>{it("should return the GetOsVersion apdu",()=>{const e=s.getApdu();expect(e.getRawApdu()).toStrictEqual(p)})}),describe("parseResponse",()=>{describe("Nano X",()=>{it("should parse the LNX response",()=>{const e=s.parseResponse(f,r.NANO_X),t=o({data:d(r.NANO_X)});expect(e).toStrictEqual(t)}),it("should default parsed flags when the response contains empty SE flags",()=>{const e=s.parseResponse(S,r.NANO_X);expect(a(e)).toBe(!0),a(e)&&(expect(e.data.seFlags).toStrictEqual(new Uint8Array),expect(e.data.secureElementFlags).toStrictEqual({isPinValidated:!1,hasMcuSerialNumber:!1,hasValidCertificate:!1,isCustomAuthorityConnectionAllowed:!1,isSecureConnectionAllowed:!1,isOnboarded:!1,isMcuCodeSigned:!1,isInRecoveryMode:!1,hasEndorsementCertificateInSlot1:!1,hasEndorsementCertificateInSlot2:!1,numberOfWords:24,currentWordIndex:0,onboardingState:n.Unknown}))}),it.each([[11,n.DeviceIsReady],[16,n.RestoreWithRk]])("should parse SE flag byte 4 0x%s as %s",(e,t)=>{const c=Uint8Array.from(l);c[14]=e;const i=s.parseResponse(new x({statusCode:Uint8Array.from([144,0]),data:c}),r.NANO_X);expect(a(i)).toBe(!0),a(i)&&(expect(i.data.seFlags).toStrictEqual(new Uint8Array([230,0,0,e])),expect(i.data.secureElementFlags.onboardingState).toBe(t))})}),describe("Nano S Plus",()=>{it("should parse the LNSP response",()=>{const e=s.parseResponse(A,r.NANO_SP),t=o({data:d(r.NANO_SP)});expect(e).toStrictEqual(t)})}),describe("Stax",()=>{it("should parse the STAX response",()=>{const e=s.parseResponse(E,r.STAX),t=o({data:d(r.STAX)});expect(e).toStrictEqual(t)})}),describe("Bootloader",()=>{it("should parse the bootloader response",()=>{const e=s.parseResponse(h,r.STAX),t=o({data:{isBootloader:!0,isOsu:!1,targetId:83951619,seTargetId:855638020,seVersion:"2.2.3",seFlags:new Uint8Array([244,216,170,67]),mcuTargetId:83951619,mcuSephVersion:"",mcuBootloaderVersion:"1.16",hwVersion:"",langId:void 0,recoverState:void 0,secureElementFlags:{isPinValidated:!0,hasMcuSerialNumber:!0,hasValidCertificate:!0,isCustomAuthorityConnectionAllowed:!0,isSecureConnectionAllowed:!1,isOnboarded:!0,isMcuCodeSigned:!1,isInRecoveryMode:!1,hasEndorsementCertificateInSlot1:!1,hasEndorsementCertificateInSlot2:!1,numberOfWords:18,currentWordIndex:10,onboardingState:n.Unknown}}});expect(e).toStrictEqual(t)})}),describe("Old firmware",()=>{it("should parse the old firmware response",()=>{const e=s.parseResponse(C,r.NANO_X),t=o({data:{isBootloader:!1,isOsu:!1,targetId:855638020,seTargetId:855638020,seVersion:"0.0.0",seFlags:new Uint8Array,mcuTargetId:void 0,mcuSephVersion:"2.30",mcuBootloaderVersion:"",hwVersion:"00",langId:void 0,recoverState:void 0,secureElementFlags:{isPinValidated:!0,hasMcuSerialNumber:!0,hasValidCertificate:!0,isCustomAuthorityConnectionAllowed:!1,isSecureConnectionAllowed:!0,isOnboarded:!0,isMcuCodeSigned:!0,isInRecoveryMode:!1,hasEndorsementCertificateInSlot1:!1,hasEndorsementCertificateInSlot2:!1,numberOfWords:24,currentWordIndex:0,onboardingState:n.Unknown}}});expect(e).toStrictEqual(t)})}),describe("Error handling",()=>{it("should return an error if the response is not successful",()=>{const e=new x({statusCode:Uint8Array.from([110,128]),data:Uint8Array.from([])}),t=s.parseResponse(e,r.NANO_S);expect(a(t)).toBeFalsy()})})})});
|
|
2
2
|
//# sourceMappingURL=GetOsVersionCommand.test.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../../src/api/command/os/GetOsVersionCommand.test.ts"],
|
|
4
|
-
"sourcesContent": ["import {\n CommandResultFactory,\n isSuccessCommandResult,\n} from \"@api/command/model/CommandResult\";\nimport { DeviceModelId } from \"@api/device/DeviceModel\";\nimport { ApduResponse } from \"@api/device-session/ApduResponse\";\n\nimport { getOsVersionCommandResponseMockBuilder } from \"./__mocks__/GetOsVersionCommand\";\nimport { GetOsVersionCommand } from \"./GetOsVersionCommand\";\n\nconst GET_OS_VERSION_APDU = Uint8Array.from([0xe0, 0x01, 0x00, 0x00, 0x00]);\n\nconst LNX_RESPONSE_DATA_GOOD = Uint8Array.from([\n 0x33, 0x00, 0x00, 0x04, 0x05, 0x32, 0x2e, 0x32, 0x2e, 0x33, 0x04, 0xe6, 0x00,\n 0x00, 0x00, 0x04, 0x32, 0x2e, 0x33, 0x30, 0x04, 0x31, 0x2e, 0x31, 0x36, 0x01,\n 0x00, 0x01, 0x00, 0x01, 0x00, 0x90, 0x00,\n]);\nconst LNX_RESPONSE_GOOD = new ApduResponse({\n statusCode: Uint8Array.from([0x90, 0x00]),\n data: LNX_RESPONSE_DATA_GOOD,\n});\n\nconst LNSP_REPONSE_DATA_GOOD = Uint8Array.from([\n 0x33, 0x10, 0x00, 0x04, 0x05, 0x31, 0x2e, 0x31, 0x2e, 0x31, 0x04, 0xe6, 0x00,\n 0x00, 0x00, 0x04, 0x34, 0x2e, 0x30, 0x33, 0x04, 0x33, 0x2e, 0x31, 0x32, 0x01,\n 0x00, 0x01, 0x00, 0x90, 0x00,\n]);\nconst LNSP_RESPONSE_GOOD = new ApduResponse({\n statusCode: Uint8Array.from([0x90, 0x00]),\n data: LNSP_REPONSE_DATA_GOOD,\n});\n\nconst STAX_RESPONSE_DATA_GOOD = Uint8Array.from([\n 0x33, 0x20, 0x00, 0x04, 0x05, 0x31, 0x2e, 0x33, 0x2e, 0x30, 0x04, 0xe6, 0x00,\n 0x00, 0x00, 0x04, 0x35, 0x2e, 0x32, 0x34, 0x04, 0x30, 0x2e, 0x34, 0x38, 0x01,\n 0x00, 0x01, 0x00, 0x90, 0x00,\n]);\nconst STAX_RESPONSE_GOOD = new ApduResponse({\n statusCode: Uint8Array.from([0x90, 0x00]),\n data: STAX_RESPONSE_DATA_GOOD,\n});\n\nconst BL_RESPONSE_DATA_GOOD = Uint8Array.from([\n 0x05, 0x01, 0x00, 0x03, 0x04, 0x31, 0x2e, 0x31, 0x36, 0x04, 0xf4, 0xd8, 0xaa,\n 0x43, 0x05, 0x32, 0x2e, 0x32, 0x2e, 0x33, 0x04, 0x33, 0x00, 0x00, 0x04, 0x90,\n 0x00,\n]);\nconst BL_RESPONSE_GOOD = new ApduResponse({\n statusCode: Uint8Array.from([0x90, 0x00]),\n data: BL_RESPONSE_DATA_GOOD,\n});\n\nconst OLD_FM_RESPONSE_DATA_GOOD = Uint8Array.from([\n 0x33, 0x00, 0x00, 0x04, 0x00, 0x04, 0xee, 0x00, 0x00, 0x00, 0x04, 0x32, 0x2e,\n 0x33, 0x30, 0x01, 0x01, 0x01, 0x00, 0x01, 0x00, 0x90, 0x00,\n]);\nconst OLD_FM_RESPONSE_GOOD = new ApduResponse({\n statusCode: Uint8Array.from([0x90, 0x00]),\n data: OLD_FM_RESPONSE_DATA_GOOD,\n});\n\ndescribe(\"GetOsVersionCommand\", () => {\n let command: GetOsVersionCommand;\n\n beforeEach(() => {\n command = new GetOsVersionCommand();\n });\n\n describe(\"name\", () => {\n it(\"should be 'getOsVersion'\", () => {\n expect(command.name).toBe(\"getOsVersion\");\n });\n });\n\n describe(\"getApdu\", () => {\n it(\"should return the GetOsVersion apdu\", () => {\n const apdu = command.getApdu();\n expect(apdu.getRawApdu()).toStrictEqual(GET_OS_VERSION_APDU);\n });\n });\n\n describe(\"parseResponse\", () => {\n describe(\"Nano X\", () => {\n it(\"should parse the LNX response\", () => {\n const parsed = command.parseResponse(\n LNX_RESPONSE_GOOD,\n DeviceModelId.NANO_X,\n );\n\n const expected = CommandResultFactory({\n data: getOsVersionCommandResponseMockBuilder(DeviceModelId.NANO_X),\n });\n\n expect(parsed).toStrictEqual(expected);\n });\n });\n\n describe(\"Nano S Plus\", () => {\n it(\"should parse the LNSP response\", () => {\n const parsed = command.parseResponse(\n LNSP_RESPONSE_GOOD,\n DeviceModelId.NANO_SP,\n );\n\n const expected = CommandResultFactory({\n data: getOsVersionCommandResponseMockBuilder(DeviceModelId.NANO_SP),\n });\n\n expect(parsed).toStrictEqual(expected);\n });\n });\n\n describe(\"Stax\", () => {\n it(\"should parse the STAX response\", () => {\n const parsed = command.parseResponse(\n STAX_RESPONSE_GOOD,\n DeviceModelId.STAX,\n );\n\n const expected = CommandResultFactory({\n data: getOsVersionCommandResponseMockBuilder(DeviceModelId.STAX),\n });\n\n expect(parsed).toStrictEqual(expected);\n });\n });\n\n describe(\"Bootloader\", () => {\n it(\"should parse the bootloader response\", () => {\n const parsed = command.parseResponse(\n BL_RESPONSE_GOOD,\n DeviceModelId.STAX,\n );\n\n const expected = CommandResultFactory({\n data: {\n isBootloader: true,\n isOsu: false,\n targetId: 83951619,\n seTargetId: 855638020,\n seVersion: \"2.2.3\",\n seFlags: new Uint8Array([0xf4, 0xd8, 0xaa, 0x43]),\n mcuTargetId: 83951619,\n mcuSephVersion: \"\",\n mcuBootloaderVersion: \"1.16\",\n hwVersion: \"\",\n langId: undefined,\n recoverState: undefined,\n secureElementFlags: {\n isPinValidated: true,\n hasMcuSerialNumber: true,\n hasValidCertificate: true,\n isCustomAuthorityConnectionAllowed: true,\n isSecureConnectionAllowed: false,\n isOnboarded: true,\n isMcuCodeSigned: false,\n isInRecoveryMode: false,\n },\n },\n });\n\n expect(parsed).toStrictEqual(expected);\n });\n });\n\n describe(\"Old firmware\", () => {\n it(\"should parse the old firmware response\", () => {\n const parsed = command.parseResponse(\n OLD_FM_RESPONSE_GOOD,\n DeviceModelId.NANO_X,\n );\n\n const expected = CommandResultFactory({\n data: {\n isBootloader: false,\n isOsu: false,\n targetId: 855638020,\n seTargetId: 855638020,\n seVersion: \"0.0.0\",\n seFlags: new Uint8Array(),\n mcuTargetId: undefined,\n mcuSephVersion: \"2.30\",\n mcuBootloaderVersion: \"\",\n hwVersion: \"00\",\n langId: undefined,\n recoverState: undefined,\n secureElementFlags: {\n isPinValidated: true,\n hasMcuSerialNumber: true,\n hasValidCertificate: true,\n isCustomAuthorityConnectionAllowed: false,\n isSecureConnectionAllowed: true,\n isOnboarded: true,\n isMcuCodeSigned: true,\n isInRecoveryMode: false,\n },\n },\n });\n\n expect(parsed).toStrictEqual(expected);\n });\n });\n\n describe(\"Error handling\", () => {\n it(\"should return an error if the response is not successful\", () => {\n const response = new ApduResponse({\n statusCode: Uint8Array.from([0x6e, 0x80]),\n data: Uint8Array.from([]),\n });\n const result = command.parseResponse(response, DeviceModelId.NANO_S);\n\n expect(isSuccessCommandResult(result)).toBeFalsy();\n });\n });\n });\n});\n"],
|
|
5
|
-
"mappings": "AAAA,OACE,wBAAAA,EACA,0BAAAC,MACK,mCACP,OAAS,iBAAAC,MAAqB,0BAC9B,OAAS,gBAAAC,MAAoB,mCAE7B,OAAS,0CAAAC,MAA8C,kCACvD,OAAS,uBAAAC,MAA2B,wBAEpC,MAAMC,EAAsB,WAAW,KAAK,CAAC,IAAM,EAAM,EAAM,EAAM,CAAI,CAAC,EAEpEC,EAAyB,WAAW,KAAK,CAC7C,GAAM,EAAM,EAAM,EAAM,EAAM,GAAM,GAAM,GAAM,GAAM,GAAM,EAAM,IAAM,EACxE,EAAM,EAAM,EAAM,GAAM,GAAM,GAAM,GAAM,EAAM,GAAM,GAAM,GAAM,GAAM,EACxE,EAAM,EAAM,EAAM,EAAM,EAAM,IAAM,CACtC,CAAC,EACKC,EAAoB,IAAIL,EAAa,CACzC,WAAY,WAAW,KAAK,CAAC,IAAM,CAAI,CAAC,EACxC,KAAMI,CACR,CAAC,EAEKE,EAAyB,WAAW,KAAK,CAC7C,GAAM,GAAM,EAAM,EAAM,EAAM,GAAM,GAAM,GAAM,GAAM,GAAM,EAAM,IAAM,EACxE,EAAM,EAAM,EAAM,GAAM,GAAM,GAAM,GAAM,EAAM,GAAM,GAAM,GAAM,GAAM,EACxE,EAAM,EAAM,EAAM,IAAM,CAC1B,CAAC,EACKC,EAAqB,
|
|
6
|
-
"names": ["CommandResultFactory", "isSuccessCommandResult", "DeviceModelId", "ApduResponse", "getOsVersionCommandResponseMockBuilder", "GetOsVersionCommand", "GET_OS_VERSION_APDU", "LNX_RESPONSE_DATA_GOOD", "LNX_RESPONSE_GOOD", "LNSP_REPONSE_DATA_GOOD", "LNSP_RESPONSE_GOOD", "STAX_RESPONSE_DATA_GOOD", "STAX_RESPONSE_GOOD", "BL_RESPONSE_DATA_GOOD", "BL_RESPONSE_GOOD", "OLD_FM_RESPONSE_DATA_GOOD", "OLD_FM_RESPONSE_GOOD", "command", "apdu", "parsed", "expected", "response", "result"]
|
|
4
|
+
"sourcesContent": ["import {\n CommandResultFactory,\n isSuccessCommandResult,\n} from \"@api/command/model/CommandResult\";\nimport { DeviceModelId } from \"@api/device/DeviceModel\";\nimport { OnboardingState } from \"@api/device/SecureElementFlags\";\nimport { ApduResponse } from \"@api/device-session/ApduResponse\";\n\nimport { getOsVersionCommandResponseMockBuilder } from \"./__mocks__/GetOsVersionCommand\";\nimport { GetOsVersionCommand } from \"./GetOsVersionCommand\";\n\nconst GET_OS_VERSION_APDU = Uint8Array.from([0xe0, 0x01, 0x00, 0x00, 0x00]);\n\nconst LNX_RESPONSE_DATA_GOOD = Uint8Array.from([\n 0x33, 0x00, 0x00, 0x04, 0x05, 0x32, 0x2e, 0x32, 0x2e, 0x33, 0x04, 0xe6, 0x00,\n 0x00, 0x00, 0x04, 0x32, 0x2e, 0x33, 0x30, 0x04, 0x31, 0x2e, 0x31, 0x36, 0x01,\n 0x00, 0x01, 0x00, 0x01, 0x00, 0x90, 0x00,\n]);\nconst LNX_RESPONSE_GOOD = new ApduResponse({\n statusCode: Uint8Array.from([0x90, 0x00]),\n data: LNX_RESPONSE_DATA_GOOD,\n});\n\nconst LNX_RESPONSE_WITH_EMPTY_SE_FLAGS = new ApduResponse({\n statusCode: Uint8Array.from([0x90, 0x00]),\n data: Uint8Array.from([\n 0x33, 0x00, 0x00, 0x04, 0x05, 0x32, 0x2e, 0x32, 0x2e, 0x33, 0x00, 0x04,\n 0x32, 0x2e, 0x33, 0x30, 0x04, 0x31, 0x2e, 0x31, 0x36, 0x01, 0x00, 0x01,\n 0x00, 0x01, 0x00, 0x90, 0x00,\n ]),\n});\n\nconst LNSP_REPONSE_DATA_GOOD = Uint8Array.from([\n 0x33, 0x10, 0x00, 0x04, 0x05, 0x31, 0x2e, 0x31, 0x2e, 0x31, 0x04, 0xe6, 0x00,\n 0x00, 0x00, 0x04, 0x34, 0x2e, 0x30, 0x33, 0x04, 0x33, 0x2e, 0x31, 0x32, 0x01,\n 0x00, 0x01, 0x00, 0x90, 0x00,\n]);\nconst LNSP_RESPONSE_GOOD = new ApduResponse({\n statusCode: Uint8Array.from([0x90, 0x00]),\n data: LNSP_REPONSE_DATA_GOOD,\n});\n\nconst STAX_RESPONSE_DATA_GOOD = Uint8Array.from([\n 0x33, 0x20, 0x00, 0x04, 0x05, 0x31, 0x2e, 0x33, 0x2e, 0x30, 0x04, 0xe6, 0x00,\n 0x00, 0x00, 0x04, 0x35, 0x2e, 0x32, 0x34, 0x04, 0x30, 0x2e, 0x34, 0x38, 0x01,\n 0x00, 0x01, 0x00, 0x90, 0x00,\n]);\nconst STAX_RESPONSE_GOOD = new ApduResponse({\n statusCode: Uint8Array.from([0x90, 0x00]),\n data: STAX_RESPONSE_DATA_GOOD,\n});\n\nconst BL_RESPONSE_DATA_GOOD = Uint8Array.from([\n 0x05, 0x01, 0x00, 0x03, 0x04, 0x31, 0x2e, 0x31, 0x36, 0x04, 0xf4, 0xd8, 0xaa,\n 0x43, 0x05, 0x32, 0x2e, 0x32, 0x2e, 0x33, 0x04, 0x33, 0x00, 0x00, 0x04, 0x90,\n 0x00,\n]);\nconst BL_RESPONSE_GOOD = new ApduResponse({\n statusCode: Uint8Array.from([0x90, 0x00]),\n data: BL_RESPONSE_DATA_GOOD,\n});\n\nconst OLD_FM_RESPONSE_DATA_GOOD = Uint8Array.from([\n 0x33, 0x00, 0x00, 0x04, 0x00, 0x04, 0xee, 0x00, 0x00, 0x00, 0x04, 0x32, 0x2e,\n 0x33, 0x30, 0x01, 0x01, 0x01, 0x00, 0x01, 0x00, 0x90, 0x00,\n]);\nconst OLD_FM_RESPONSE_GOOD = new ApduResponse({\n statusCode: Uint8Array.from([0x90, 0x00]),\n data: OLD_FM_RESPONSE_DATA_GOOD,\n});\n\ndescribe(\"GetOsVersionCommand\", () => {\n let command: GetOsVersionCommand;\n\n beforeEach(() => {\n command = new GetOsVersionCommand();\n });\n\n describe(\"name\", () => {\n it(\"should be 'getOsVersion'\", () => {\n expect(command.name).toBe(\"getOsVersion\");\n });\n });\n\n describe(\"getApdu\", () => {\n it(\"should return the GetOsVersion apdu\", () => {\n const apdu = command.getApdu();\n expect(apdu.getRawApdu()).toStrictEqual(GET_OS_VERSION_APDU);\n });\n });\n\n describe(\"parseResponse\", () => {\n describe(\"Nano X\", () => {\n it(\"should parse the LNX response\", () => {\n const parsed = command.parseResponse(\n LNX_RESPONSE_GOOD,\n DeviceModelId.NANO_X,\n );\n\n const expected = CommandResultFactory({\n data: getOsVersionCommandResponseMockBuilder(DeviceModelId.NANO_X),\n });\n\n expect(parsed).toStrictEqual(expected);\n });\n\n it(\"should default parsed flags when the response contains empty SE flags\", () => {\n const parsed = command.parseResponse(\n LNX_RESPONSE_WITH_EMPTY_SE_FLAGS,\n DeviceModelId.NANO_X,\n );\n\n expect(isSuccessCommandResult(parsed)).toBe(true);\n if (!isSuccessCommandResult(parsed)) {\n return;\n }\n expect(parsed.data.seFlags).toStrictEqual(new Uint8Array());\n expect(parsed.data.secureElementFlags).toStrictEqual({\n isPinValidated: false,\n hasMcuSerialNumber: false,\n hasValidCertificate: false,\n isCustomAuthorityConnectionAllowed: false,\n isSecureConnectionAllowed: false,\n isOnboarded: false,\n isMcuCodeSigned: false,\n isInRecoveryMode: false,\n hasEndorsementCertificateInSlot1: false,\n hasEndorsementCertificateInSlot2: false,\n numberOfWords: 24,\n currentWordIndex: 0,\n onboardingState: OnboardingState.Unknown,\n });\n });\n\n it.each([\n [0x0b, OnboardingState.DeviceIsReady],\n [0x10, OnboardingState.RestoreWithRk],\n ] as const)(\n \"should parse SE flag byte 4 0x%s as %s\",\n (onboardingByte, onboardingState) => {\n const data = Uint8Array.from(LNX_RESPONSE_DATA_GOOD);\n data[14] = onboardingByte;\n const parsed = command.parseResponse(\n new ApduResponse({\n statusCode: Uint8Array.from([0x90, 0x00]),\n data,\n }),\n DeviceModelId.NANO_X,\n );\n\n expect(isSuccessCommandResult(parsed)).toBe(true);\n if (!isSuccessCommandResult(parsed)) {\n return;\n }\n expect(parsed.data.seFlags).toStrictEqual(\n new Uint8Array([0xe6, 0x00, 0x00, onboardingByte]),\n );\n expect(parsed.data.secureElementFlags.onboardingState).toBe(\n onboardingState,\n );\n },\n );\n });\n\n describe(\"Nano S Plus\", () => {\n it(\"should parse the LNSP response\", () => {\n const parsed = command.parseResponse(\n LNSP_RESPONSE_GOOD,\n DeviceModelId.NANO_SP,\n );\n\n const expected = CommandResultFactory({\n data: getOsVersionCommandResponseMockBuilder(DeviceModelId.NANO_SP),\n });\n\n expect(parsed).toStrictEqual(expected);\n });\n });\n\n describe(\"Stax\", () => {\n it(\"should parse the STAX response\", () => {\n const parsed = command.parseResponse(\n STAX_RESPONSE_GOOD,\n DeviceModelId.STAX,\n );\n\n const expected = CommandResultFactory({\n data: getOsVersionCommandResponseMockBuilder(DeviceModelId.STAX),\n });\n\n expect(parsed).toStrictEqual(expected);\n });\n });\n\n describe(\"Bootloader\", () => {\n it(\"should parse the bootloader response\", () => {\n const parsed = command.parseResponse(\n BL_RESPONSE_GOOD,\n DeviceModelId.STAX,\n );\n\n const expected = CommandResultFactory({\n data: {\n isBootloader: true,\n isOsu: false,\n targetId: 83951619,\n seTargetId: 855638020,\n seVersion: \"2.2.3\",\n seFlags: new Uint8Array([0xf4, 0xd8, 0xaa, 0x43]),\n mcuTargetId: 83951619,\n mcuSephVersion: \"\",\n mcuBootloaderVersion: \"1.16\",\n hwVersion: \"\",\n langId: undefined,\n recoverState: undefined,\n secureElementFlags: {\n isPinValidated: true,\n hasMcuSerialNumber: true,\n hasValidCertificate: true,\n isCustomAuthorityConnectionAllowed: true,\n isSecureConnectionAllowed: false,\n isOnboarded: true,\n isMcuCodeSigned: false,\n isInRecoveryMode: false,\n hasEndorsementCertificateInSlot1: false,\n hasEndorsementCertificateInSlot2: false,\n numberOfWords: 18,\n currentWordIndex: 10,\n onboardingState: OnboardingState.Unknown,\n },\n },\n });\n\n expect(parsed).toStrictEqual(expected);\n });\n });\n\n describe(\"Old firmware\", () => {\n it(\"should parse the old firmware response\", () => {\n const parsed = command.parseResponse(\n OLD_FM_RESPONSE_GOOD,\n DeviceModelId.NANO_X,\n );\n\n const expected = CommandResultFactory({\n data: {\n isBootloader: false,\n isOsu: false,\n targetId: 855638020,\n seTargetId: 855638020,\n seVersion: \"0.0.0\",\n seFlags: new Uint8Array(),\n mcuTargetId: undefined,\n mcuSephVersion: \"2.30\",\n mcuBootloaderVersion: \"\",\n hwVersion: \"00\",\n langId: undefined,\n recoverState: undefined,\n secureElementFlags: {\n isPinValidated: true,\n hasMcuSerialNumber: true,\n hasValidCertificate: true,\n isCustomAuthorityConnectionAllowed: false,\n isSecureConnectionAllowed: true,\n isOnboarded: true,\n isMcuCodeSigned: true,\n isInRecoveryMode: false,\n hasEndorsementCertificateInSlot1: false,\n hasEndorsementCertificateInSlot2: false,\n numberOfWords: 24,\n currentWordIndex: 0,\n onboardingState: OnboardingState.Unknown,\n },\n },\n });\n\n expect(parsed).toStrictEqual(expected);\n });\n });\n\n describe(\"Error handling\", () => {\n it(\"should return an error if the response is not successful\", () => {\n const response = new ApduResponse({\n statusCode: Uint8Array.from([0x6e, 0x80]),\n data: Uint8Array.from([]),\n });\n const result = command.parseResponse(response, DeviceModelId.NANO_S);\n\n expect(isSuccessCommandResult(result)).toBeFalsy();\n });\n });\n });\n});\n"],
|
|
5
|
+
"mappings": "AAAA,OACE,wBAAAA,EACA,0BAAAC,MACK,mCACP,OAAS,iBAAAC,MAAqB,0BAC9B,OAAS,mBAAAC,MAAuB,iCAChC,OAAS,gBAAAC,MAAoB,mCAE7B,OAAS,0CAAAC,MAA8C,kCACvD,OAAS,uBAAAC,MAA2B,wBAEpC,MAAMC,EAAsB,WAAW,KAAK,CAAC,IAAM,EAAM,EAAM,EAAM,CAAI,CAAC,EAEpEC,EAAyB,WAAW,KAAK,CAC7C,GAAM,EAAM,EAAM,EAAM,EAAM,GAAM,GAAM,GAAM,GAAM,GAAM,EAAM,IAAM,EACxE,EAAM,EAAM,EAAM,GAAM,GAAM,GAAM,GAAM,EAAM,GAAM,GAAM,GAAM,GAAM,EACxE,EAAM,EAAM,EAAM,EAAM,EAAM,IAAM,CACtC,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AAE,cAAcC,CAAQ,CACvC,CAAC,CACH,CAAC,EAED,SAAS,iBAAkB,IAAM,CAC/B,GAAG,2DAA4D,IAAM,CACnE,MAAMI,EAAW,IAAItB,EAAa,CAChC,WAAY,WAAW,KAAK,CAAC,IAAM,GAAI,CAAC,EACxC,KAAM,WAAW,KAAK,CAAC,CAAC,CAC1B,CAAC,EACKuB,EAASR,EAAQ,cAAcO,EAAUxB,EAAc,MAAM,EAEnE,OAAOD,EAAuB0B,CAAM,CAAC,EAAE,UAAU,CACnD,CAAC,CACH,CAAC,CACH,CAAC,CACH,CAAC",
|
|
6
|
+
"names": ["CommandResultFactory", "isSuccessCommandResult", "DeviceModelId", "OnboardingState", "ApduResponse", "getOsVersionCommandResponseMockBuilder", "GetOsVersionCommand", "GET_OS_VERSION_APDU", "LNX_RESPONSE_DATA_GOOD", "LNX_RESPONSE_GOOD", "LNX_RESPONSE_WITH_EMPTY_SE_FLAGS", "LNSP_REPONSE_DATA_GOOD", "LNSP_RESPONSE_GOOD", "STAX_RESPONSE_DATA_GOOD", "STAX_RESPONSE_GOOD", "BL_RESPONSE_DATA_GOOD", "BL_RESPONSE_GOOD", "OLD_FM_RESPONSE_DATA_GOOD", "OLD_FM_RESPONSE_GOOD", "command", "apdu", "parsed", "expected", "onboardingByte", "onboardingState", "data", "response", "result"]
|
|
7
7
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
|
|
1
|
+
import{OnboardingState as t}from"../../device/SecureElementFlags";const r={1:t.WelcomeScreen1,2:t.WelcomeScreen2,3:t.WelcomeScreen3,4:t.WelcomeScreen4,5:t.WelcomeScreenReminder,6:t.SetupChoice,7:t.NewDevice,8:t.ConfirmNewDevice,9:t.RestoreRecoveryPhrase,10:t.SafetyWarning,11:t.DeviceIsReady,12:t.ChooseName,13:t.RestoreRecoverBackup,14:t.SetupRestoreChoice,15:t.OnboardingStatusCheck,16:t.RestoreWithRk};class a{seFlags;constructor(e){this.seFlags=new Uint8Array(4),this.seFlags.set(e.subarray(0,this.seFlags.length))}generalDeviceState(){const e=this.seFlags[0]??0;return{isPinValidated:this._checkNthBitInByte(e,1),hasMcuSerialNumber:this._checkNthBitInByte(e,2),hasValidCertificate:this._checkNthBitInByte(e,3),isCustomAuthorityConnectionAllowed:this._checkNthBitInByte(e,4),isSecureConnectionAllowed:this._checkNthBitInByte(e,5),isOnboarded:this._checkNthBitInByte(e,6),isMcuCodeSigned:this._checkNthBitInByte(e,7),isInRecoveryMode:this._checkNthBitInByte(e,8)}}endorsementInformation(){const e=this.seFlags[1]??0;return{hasEndorsementCertificateInSlot1:(e&1)!==0,hasEndorsementCertificateInSlot2:(e&2)!==0}}wordsInformation(){const e=this.seFlags[2]??0,n=e>>5&3;return{numberOfWords:[24,18,12,void 0][n],currentWordIndex:e&31}}onboardingStatus(){const e=this.seFlags[3]??0;return{onboardingState:r[e]??t.Unknown}}_checkNthBitInByte(e,n){return(e>>8-n&1)===1}}export{a as SecureElementFlagsParser};
|
|
2
2
|
//# sourceMappingURL=SecureElementFlagsParser.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../../src/api/command/os/SecureElementFlagsParser.ts"],
|
|
4
|
-
"sourcesContent": ["import {\n type DeviceGeneralState,\n type EndorsementInformation,\n type OnboardingStatus,\n type WordsInformation,\n} from \"@api/device/SecureElementFlags\";\n\n/**\n * Secure element flags parser class.\n */\nexport class SecureElementFlagsParser {\n /**\n * Creates an instance of SecureElementFlags parser.\n * @param seFlags - The secure element flags as an Uint8Array, it comes from the response of the GetOsVersionCommand.\n */\n constructor(
|
|
5
|
-
"mappings": "
|
|
6
|
-
"names": ["SecureElementFlagsParser", "seFlags", "firstByte", "
|
|
4
|
+
"sourcesContent": ["import {\n type DeviceGeneralState,\n type EndorsementInformation,\n OnboardingState,\n type OnboardingStatus,\n type SeedWordCount,\n type WordsInformation,\n} from \"@api/device/SecureElementFlags\";\n\nconst ONBOARDING_STATE_BY_VALUE: Readonly<Record<number, OnboardingState>> = {\n 0x01: OnboardingState.WelcomeScreen1,\n 0x02: OnboardingState.WelcomeScreen2,\n 0x03: OnboardingState.WelcomeScreen3,\n 0x04: OnboardingState.WelcomeScreen4,\n 0x05: OnboardingState.WelcomeScreenReminder,\n 0x06: OnboardingState.SetupChoice,\n 0x07: OnboardingState.NewDevice,\n 0x08: OnboardingState.ConfirmNewDevice,\n 0x09: OnboardingState.RestoreRecoveryPhrase,\n 0x0a: OnboardingState.SafetyWarning,\n 0x0b: OnboardingState.DeviceIsReady,\n 0x0c: OnboardingState.ChooseName,\n 0x0d: OnboardingState.RestoreRecoverBackup,\n 0x0e: OnboardingState.SetupRestoreChoice,\n 0x0f: OnboardingState.OnboardingStatusCheck,\n 0x10: OnboardingState.RestoreWithRk,\n};\n\n/**\n * Secure element flags parser class.\n */\nexport class SecureElementFlagsParser {\n private readonly seFlags: Uint8Array;\n\n /**\n * Creates an instance of SecureElementFlags parser.\n * @param seFlags - The secure element flags as an Uint8Array, it comes from the response of the GetOsVersionCommand.\n */\n constructor(seFlags: Uint8Array) {\n this.seFlags = new Uint8Array(4);\n this.seFlags.set(seFlags.subarray(0, this.seFlags.length));\n }\n\n /**\n * Retrieves the general device state based on the secure element flags, which is the first byte of the flags.\n * @returns {DeviceGeneralState}\n */\n generalDeviceState(): DeviceGeneralState {\n const firstByte = this.seFlags[0] ?? 0x00;\n\n return {\n isPinValidated: this._checkNthBitInByte(firstByte, 1),\n hasMcuSerialNumber: this._checkNthBitInByte(firstByte, 2),\n hasValidCertificate: this._checkNthBitInByte(firstByte, 3),\n isCustomAuthorityConnectionAllowed: this._checkNthBitInByte(firstByte, 4),\n isSecureConnectionAllowed: this._checkNthBitInByte(firstByte, 5),\n isOnboarded: this._checkNthBitInByte(firstByte, 6),\n isMcuCodeSigned: this._checkNthBitInByte(firstByte, 7),\n isInRecoveryMode: this._checkNthBitInByte(firstByte, 8),\n };\n }\n\n /**\n * Retrieves the endorsement information based on the secure element flags, which is the second byte of the flags.\n * @returns {EndorsementInformation}\n */\n endorsementInformation(): EndorsementInformation {\n const secondByte = this.seFlags[1] ?? 0x00;\n\n return {\n hasEndorsementCertificateInSlot1: (secondByte & 0x01) !== 0,\n hasEndorsementCertificateInSlot2: (secondByte & 0x02) !== 0,\n };\n }\n\n /**\n * Retrieves the words information based on the secure element flags, which is the third byte of the flags.\n * @returns {WordsInformation}\n */\n wordsInformation(): WordsInformation {\n const thirdByte = this.seFlags[2] ?? 0x00;\n const wordCountValue = (thirdByte >> 5) & 0x03;\n const wordCounts: ReadonlyArray<SeedWordCount | undefined> = [\n 24,\n 18,\n 12,\n undefined,\n ];\n\n return {\n numberOfWords: wordCounts[wordCountValue],\n currentWordIndex: thirdByte & 0x1f,\n };\n }\n\n /**\n * Retrieves the onboarding status based on the secure element flags, which is the fourth byte of the flags.\n * @returns {OnboardingStatus}\n */\n onboardingStatus(): OnboardingStatus {\n const value = this.seFlags[3] ?? 0x00;\n\n return {\n onboardingState:\n ONBOARDING_STATE_BY_VALUE[value] ?? OnboardingState.Unknown,\n };\n }\n\n /**\n * Check the nth bit in a byte, returns true if the bit is set, false otherwise.\n * @param byte - The byte to check.\n * @param n - The bit number to check.\n * @returns {boolean} - True if the bit is set, false otherwise.\n */\n _checkNthBitInByte(byte: number, n: number): boolean {\n return ((byte >> (8 - n)) & 1) === 1;\n }\n}\n"],
|
|
5
|
+
"mappings": "AAAA,OAGE,mBAAAA,MAIK,iCAEP,MAAMC,EAAuE,CAC3E,EAAMD,EAAgB,eACtB,EAAMA,EAAgB,eACtB,EAAMA,EAAgB,eACtB,EAAMA,EAAgB,eACtB,EAAMA,EAAgB,sBACtB,EAAMA,EAAgB,YACtB,EAAMA,EAAgB,UACtB,EAAMA,EAAgB,iBACtB,EAAMA,EAAgB,sBACtB,GAAMA,EAAgB,cACtB,GAAMA,EAAgB,cACtB,GAAMA,EAAgB,WACtB,GAAMA,EAAgB,qBACtB,GAAMA,EAAgB,mB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stByte", "secondByte", "thirdByte", "wordCountValue", "value", "byte"]
|
|
7
7
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{describe as
|
|
1
|
+
import{describe as c,expect as o,it as a}from"vitest";import{OnboardingState as e}from"../../device/SecureElementFlags";import{SecureElementFlagsParser as s}from"./SecureElementFlagsParser";c("SecureElementFlagsParser",()=>{a("should default missing secure element flag bytes to zero",()=>{const r=new s(new Uint8Array([224]));o(r.generalDeviceState().isPinValidated).toBe(!0),o(r.endorsementInformation()).toEqual({hasEndorsementCertificateInSlot1:!1,hasEndorsementCertificateInSlot2:!1}),o(r.wordsInformation()).toEqual({numberOfWords:24,currentWordIndex:0}),o(r.onboardingStatus()).toEqual({onboardingState:e.Unknown})}),a("should correctly parse the general device state",()=>{const r=new Uint8Array([170,0,0,0]),t=new s(r),n={isPinValidated:!0,hasMcuSerialNumber:!1,hasValidCertificate:!0,isCustomAuthorityConnectionAllowed:!1,isSecureConnectionAllowed:!0,isOnboarded:!1,isMcuCodeSigned:!0,isInRecoveryMode:!1};o(t.generalDeviceState()).toEqual(n)}),a.each([[0,!1,!1],[1,!0,!1],[2,!1,!0],[3,!0,!0]])("should parse endorsement information value %#",(r,t,n)=>{const i=new s(new Uint8Array([0,r,0,0]));o(i.endorsementInformation()).toEqual({hasEndorsementCertificateInSlot1:t,hasEndorsementCertificateInSlot2:n})}),a.each([[0,24,0],[37,18,5],[81,12,17],[127,void 0,31]])("should parse words information value %#",(r,t,n)=>{const i=new s(new Uint8Array([0,0,r,0]));o(i.wordsInformation()).toEqual({numberOfWords:t,currentWordIndex:n})}),a("should ignore the reserved most-significant bit in words information",()=>{const r=new s(new Uint8Array([0,0,165,0]));o(r.wordsInformation()).toEqual({numberOfWords:18,currentWordIndex:5})}),c("onboardingStatus",()=>{a.each([[0,e.Unknown],[1,e.WelcomeScreen1],[2,e.WelcomeScreen2],[3,e.WelcomeScreen3],[4,e.WelcomeScreen4],[5,e.WelcomeScreenReminder],[6,e.SetupChoice],[7,e.NewDevice],[8,e.ConfirmNewDevice],[9,e.RestoreRecoveryPhrase],[10,e.SafetyWarning],[11,e.DeviceIsReady],[12,e.ChooseName],[13,e.RestoreRecoverBackup],[14,e.SetupRestoreChoice],[15,e.OnboardingStatusCheck],[16,e.RestoreWithRk],[17,e.Unknown],[67,e.Unknown],[255,e.Unknown]])("should parse byte 0x%s as %s",(r,t)=>{const n=new s(new Uint8Array([0,0,0,r]));o(n.onboardingStatus()).toEqual({onboardingState:t})}),a("should always expose a defined onboarding state so it survives serialization",()=>{const t=new s(new Uint8Array([0,0,0,0])).onboardingStatus();o(t.onboardingState).toBe(e.Unknown),o(JSON.parse(JSON.stringify(t))).toEqual({onboardingState:e.Unknown})}),a("should map every documented GET VERSION byte to a distinct OnboardingState",()=>{const t=Array.from({length:16},(n,i)=>i+1).map(n=>new s(new Uint8Array([0,0,0,n])).onboardingStatus().onboardingState);o(t).toEqual(Object.values(e).filter(n=>n!==e.Unknown))})}),a("should correctly check the nth bit in a byte",()=>{const r=new Uint8Array([0,0,0,0]),t=new s(r),n=170;o(t._checkNthBitInByte(n,1)).toBe(!0),o(t._checkNthBitInByte(n,2)).toBe(!1),o(t._checkNthBitInByte(n,3)).toBe(!0),o(t._checkNthBitInByte(n,4)).toBe(!1),o(t._checkNthBitInByte(n,5)).toBe(!0),o(t._checkNthBitInByte(n,6)).toBe(!1),o(t._checkNthBitInByte(n,7)).toBe(!0),o(t._checkNthBitInByte(n,8)).toBe(!1)})});
|
|
2
2
|
//# sourceMappingURL=SecureElementFlagsParser.test.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../../src/api/command/os/SecureElementFlagsParser.test.ts"],
|
|
4
|
-
"sourcesContent": ["import { describe, expect, it } from \"vitest\";\n\nimport {
|
|
5
|
-
"mappings": "AAAA,OAAS,YAAAA,EAAU,UAAAC,EAAQ,MAAAC,MAAU,
|
|
6
|
-
"names": ["describe", "expect", "it", "
|
|
4
|
+
"sourcesContent": ["import { describe, expect, it } from \"vitest\";\n\nimport {\n type DeviceGeneralState,\n OnboardingState,\n} from \"@api/device/SecureElementFlags\";\n\nimport { SecureElementFlagsParser } from \"./SecureElementFlagsParser\";\n\ndescribe(\"SecureElementFlagsParser\", () => {\n it(\"should default missing secure element flag bytes to zero\", () => {\n const parser = new SecureElementFlagsParser(new Uint8Array([0xe0]));\n\n expect(parser.generalDeviceState().isPinValidated).toBe(true);\n expect(parser.endorsementInformation()).toEqual({\n hasEndorsementCertificateInSlot1: false,\n hasEndorsementCertificateInSlot2: false,\n });\n expect(parser.wordsInformation()).toEqual({\n numberOfWords: 24,\n currentWordIndex: 0,\n });\n expect(parser.onboardingStatus()).toEqual({\n onboardingState: OnboardingState.Unknown,\n });\n });\n\n it(\"should correctly parse the general device state\", () => {\n const seFlags = new Uint8Array([0b10101010, 0x00, 0x00, 0x00]);\n const parser = new SecureElementFlagsParser(seFlags);\n const expectedState: DeviceGeneralState = {\n isPinValidated: true,\n hasMcuSerialNumber: false,\n hasValidCertificate: true,\n isCustomAuthorityConnectionAllowed: false,\n isSecureConnectionAllowed: true,\n isOnboarded: false,\n isMcuCodeSigned: true,\n isInRecoveryMode: false,\n };\n expect(parser.generalDeviceState()).toEqual(expectedState);\n });\n\n it.each([\n [0x00, false, false],\n [0x01, true, false],\n [0x02, false, true],\n [0x03, true, true],\n ])(\n \"should parse endorsement information value %#\",\n (value, hasSlot1, hasSlot2) => {\n const parser = new SecureElementFlagsParser(\n new Uint8Array([0x00, value, 0x00, 0x00]),\n );\n\n expect(parser.endorsementInformation()).toEqual({\n hasEndorsementCertificateInSlot1: hasSlot1,\n hasEndorsementCertificateInSlot2: hasSlot2,\n });\n },\n );\n\n it.each([\n [0b00000000, 24, 0],\n [0b00100101, 18, 5],\n [0b01010001, 12, 17],\n [0b01111111, undefined, 31],\n ])(\n \"should parse words information value %#\",\n (value, numberOfWords, currentWordIndex) => {\n const parser = new SecureElementFlagsParser(\n new Uint8Array([0x00, 0x00, value, 0x00]),\n );\n\n expect(parser.wordsInformation()).toEqual({\n numberOfWords,\n currentWordIndex,\n });\n },\n );\n\n it(\"should ignore the reserved most-significant bit in words information\", () => {\n const parser = new SecureElementFlagsParser(\n new Uint8Array([0x00, 0x00, 0b10100101, 0x00]),\n );\n\n expect(parser.wordsInformation()).toEqual({\n numberOfWords: 18,\n currentWordIndex: 5,\n });\n });\n\n describe(\"onboardingStatus\", () => {\n it.each([\n [0x00, OnboardingState.Unknown],\n [0x01, OnboardingState.WelcomeScreen1],\n [0x02, OnboardingState.WelcomeScreen2],\n [0x03, OnboardingState.WelcomeScreen3],\n [0x04, OnboardingState.WelcomeScreen4],\n [0x05, OnboardingState.WelcomeScreenReminder],\n [0x06, OnboardingState.SetupChoice],\n [0x07, OnboardingState.NewDevice],\n [0x08, OnboardingState.ConfirmNewDevice],\n [0x09, OnboardingState.RestoreRecoveryPhrase],\n [0x0a, OnboardingState.SafetyWarning],\n [0x0b, OnboardingState.DeviceIsReady],\n [0x0c, OnboardingState.ChooseName],\n [0x0d, OnboardingState.RestoreRecoverBackup],\n [0x0e, OnboardingState.SetupRestoreChoice],\n [0x0f, OnboardingState.OnboardingStatusCheck],\n [0x10, OnboardingState.RestoreWithRk],\n [0x11, OnboardingState.Unknown],\n [0x43, OnboardingState.Unknown],\n [0xff, OnboardingState.Unknown],\n ] as const)(\"should parse byte 0x%s as %s\", (value, onboardingState) => {\n const parser = new SecureElementFlagsParser(\n new Uint8Array([0x00, 0x00, 0x00, value]),\n );\n\n expect(parser.onboardingStatus()).toEqual({ onboardingState });\n });\n\n it(\"should always expose a defined onboarding state so it survives serialization\", () => {\n const parser = new SecureElementFlagsParser(\n new Uint8Array([0x00, 0x00, 0x00, 0x00]),\n );\n\n const status = parser.onboardingStatus();\n\n expect(status.onboardingState).toBe(OnboardingState.Unknown);\n expect(JSON.parse(JSON.stringify(status))).toEqual({\n onboardingState: OnboardingState.Unknown,\n });\n });\n\n it(\"should map every documented GET VERSION byte to a distinct OnboardingState\", () => {\n const documentedBytes = Array.from(\n { length: 0x10 },\n (_, index) => index + 1,\n );\n const parsedStates = documentedBytes.map(\n (value) =>\n new SecureElementFlagsParser(\n new Uint8Array([0x00, 0x00, 0x00, value]),\n ).onboardingStatus().onboardingState,\n );\n\n expect(parsedStates).toEqual(\n Object.values(OnboardingState).filter(\n (state) => state !== OnboardingState.Unknown,\n ),\n );\n });\n });\n\n it(\"should correctly check the nth bit in a byte\", () => {\n const seFlags = new Uint8Array([0x00, 0x00, 0x00, 0x00]);\n const parser = new SecureElementFlagsParser(seFlags);\n const byte = 0b10101010;\n expect(parser._checkNthBitInByte(byte, 1)).toBe(true);\n expect(parser._checkNthBitInByte(byte, 2)).toBe(false);\n expect(parser._checkNthBitInByte(byte, 3)).toBe(true);\n expect(parser._checkNthBitInByte(byte, 4)).toBe(false);\n expect(parser._checkNthBitInByte(byte, 5)).toBe(true);\n expect(parser._checkNthBitInByte(byte, 6)).toBe(false);\n expect(parser._checkNthBitInByte(byte, 7)).toBe(true);\n expect(parser._checkNthBitInByte(byte, 8)).toBe(false);\n });\n});\n"],
|
|
5
|
+
"mappings": "AAAA,OAAS,YAAAA,EAAU,UAAAC,EAAQ,MAAAC,MAAU,SAErC,OAEE,mBAAAC,MACK,iCAEP,OAAS,4BAAAC,MAAgC,6BAEzCJ,EAAS,2BAA4B,IAAM,CACzCE,EAAG,2DAA4D,IAAM,CACnE,MAAMG,EAAS,IAAID,EAAyB,IAAI,WAAW,CAAC,GAAI,CAAC,CAAC,EAElEH,EAAOI,EAAO,mBAAmB,EAAE,cAAc,EAAE,KAAK,EAAI,EAC5DJ,EAAOI,EAAO,uBAAuB,CAAC,EAAE,QAAQ,CAC9C,iCAAkC,GAClC,iCAAkC,EACpC,CAAC,EACDJ,EAAOI,EAAO,iBAAiB,CAAC,EAAE,QAAQ,CACxC,cAAe,GACf,iBAAkB,CACpB,CAAC,EACDJ,EAAOI,EAAO,iBAA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it", "OnboardingState", "SecureElementFlagsParser", "parser", "seFlags", "expectedState", "value", "hasSlot1", "hasSlot2", "numberOfWords", "currentWordIndex", "onboardingState", "status", "parsedStates", "_", "index", "state", "byte"]
|
|
7
7
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{DeviceModelId as e}from"../../../device/DeviceModel";const
|
|
1
|
+
import{DeviceModelId as e}from"../../../device/DeviceModel";import{OnboardingState as s}from"../../../device/SecureElementFlags";const a=(r=e.NANO_SP,n={})=>({[e.NANO_SP]:{isBootloader:!1,isOsu:!1,targetId:856686596,seTargetId:856686596,seVersion:"1.1.1",seFlags:new Uint8Array([230,0,0,0]),mcuTargetId:void 0,mcuSephVersion:"4.03",mcuBootloaderVersion:"3.12",hwVersion:"00",langId:0,recoverState:void 0,secureElementFlags:{isPinValidated:!0,hasMcuSerialNumber:!0,hasValidCertificate:!0,isCustomAuthorityConnectionAllowed:!1,isSecureConnectionAllowed:!1,isOnboarded:!0,isMcuCodeSigned:!0,isInRecoveryMode:!1,hasEndorsementCertificateInSlot1:!1,hasEndorsementCertificateInSlot2:!1,numberOfWords:24,currentWordIndex:0,onboardingState:s.Unknown},...n},[e.NANO_S]:{isBootloader:!1,isOsu:!1,targetId:858783748,seTargetId:858783748,seVersion:"1.1.1",seFlags:new Uint8Array([230,0,0,0]),mcuTargetId:void 0,mcuSephVersion:"6.4.0",mcuBootloaderVersion:"5.4.0",hwVersion:"00",langId:0,recoverState:void 0,secureElementFlags:{isPinValidated:!0,hasMcuSerialNumber:!0,hasValidCertificate:!0,isCustomAuthorityConnectionAllowed:!1,isSecureConnectionAllowed:!1,isOnboarded:!0,isMcuCodeSigned:!0,isInRecoveryMode:!1,hasEndorsementCertificateInSlot1:!1,hasEndorsementCertificateInSlot2:!1,numberOfWords:24,currentWordIndex:0,onboardingState:s.Unknown},...n},[e.NANO_X]:{isBootloader:!1,isOsu:!1,targetId:855638020,seTargetId:855638020,seVersion:"2.2.3",seFlags:new Uint8Array([230,0,0,0]),mcuTargetId:void 0,mcuSephVersion:"2.30",mcuBootloaderVersion:"1.16",hwVersion:"00",langId:0,recoverState:0,secureElementFlags:{isPinValidated:!0,hasMcuSerialNumber:!0,hasValidCertificate:!0,isCustomAuthorityConnectionAllowed:!1,isSecureConnectionAllowed:!1,isOnboarded:!0,isMcuCodeSigned:!0,isInRecoveryMode:!1,hasEndorsementCertificateInSlot1:!1,hasEndorsementCertificateInSlot2:!1,numberOfWords:24,currentWordIndex:0,onboardingState:s.Unknown},...n},[e.STAX]:{isBootloader:!1,isOsu:!1,targetId:857735172,seTargetId:857735172,seVersion:"1.3.0",seFlags:new Uint8Array([230,0,0,0]),mcuTargetId:void 0,mcuSephVersion:"5.24",mcuBootloaderVersion:"0.48",hwVersion:"00",langId:0,recoverState:void 0,secureElementFlags:{isPinValidated:!0,hasMcuSerialNumber:!0,hasValidCertificate:!0,isCustomAuthorityConnectionAllowed:!1,isSecureConnectionAllowed:!1,isOnboarded:!0,isMcuCodeSigned:!0,isInRecoveryMode:!1,hasEndorsementCertificateInSlot1:!1,hasEndorsementCertificateInSlot2:!1,numberOfWords:24,currentWordIndex:0,onboardingState:s.Unknown},...n},[e.FLEX]:{isBootloader:!1,isOsu:!1,targetId:858783748,seTargetId:858783748,seVersion:"1.1.1",seFlags:new Uint8Array([230,0,0,0]),mcuTargetId:void 0,mcuSephVersion:"6.4.0",mcuBootloaderVersion:"5.4.0",hwVersion:"00",langId:0,recoverState:0,secureElementFlags:{isPinValidated:!0,hasMcuSerialNumber:!0,hasValidCertificate:!0,isCustomAuthorityConnectionAllowed:!1,isSecureConnectionAllowed:!1,isOnboarded:!0,isMcuCodeSigned:!0,isInRecoveryMode:!1,hasEndorsementCertificateInSlot1:!1,hasEndorsementCertificateInSlot2:!1,numberOfWords:24,currentWordIndex:0,onboardingState:s.Unknown},...n},[e.APEX]:{isBootloader:!1,isOsu:!1,targetId:858783748,seTargetId:858783748,seVersion:"1.1.1",seFlags:new Uint8Array([230,0,0,0]),mcuTargetId:void 0,mcuSephVersion:"6.4.0",mcuBootloaderVersion:"5.4.0",hwVersion:"00",langId:0,recoverState:0,secureElementFlags:{isPinValidated:!0,hasMcuSerialNumber:!0,hasValidCertificate:!0,isCustomAuthorityConnectionAllowed:!1,isSecureConnectionAllowed:!1,isOnboarded:!0,isMcuCodeSigned:!0,isInRecoveryMode:!1,hasEndorsementCertificateInSlot1:!1,hasEndorsementCertificateInSlot2:!1,numberOfWords:24,currentWordIndex:0,onboardingState:s.Unknown}}})[r];export{a as getOsVersionCommandResponseMockBuilder};
|
|
2
2
|
//# sourceMappingURL=GetOsVersionCommand.js.map
|