@ledgerhq/device-management-kit 0.13.0 → 1.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +79 -0
- package/lib/cjs/package.json +1 -1
- package/lib/cjs/src/api/DeviceManagementKit.js +1 -1
- package/lib/cjs/src/api/DeviceManagementKit.js.map +3 -3
- package/lib/cjs/src/api/device-action/model/UserInteractionRequired.js +1 -1
- package/lib/cjs/src/api/device-action/model/UserInteractionRequired.js.map +2 -2
- package/lib/cjs/src/api/device-action/xstate-utils/XStateDeviceAction.js +1 -1
- package/lib/cjs/src/api/device-action/xstate-utils/XStateDeviceAction.js.map +3 -3
- package/lib/cjs/src/api/device-model/data/StaticDeviceModelDataSource.js +1 -1
- package/lib/cjs/src/api/device-model/data/StaticDeviceModelDataSource.js.map +2 -2
- package/lib/cjs/src/api/device-model/data/StaticDeviceModelDataSource.test.js +1 -1
- package/lib/cjs/src/api/device-model/data/StaticDeviceModelDataSource.test.js.map +3 -3
- package/lib/cjs/src/api/index.js +1 -1
- package/lib/cjs/src/api/index.js.map +3 -3
- package/lib/cjs/src/api/logger-subscriber/model/LogSubscriberOptions.js +1 -1
- package/lib/cjs/src/api/logger-subscriber/model/LogSubscriberOptions.js.map +1 -1
- package/lib/cjs/src/api/logger-subscriber/service/ConsoleLogger.js +1 -1
- package/lib/cjs/src/api/logger-subscriber/service/ConsoleLogger.js.map +2 -2
- package/lib/cjs/src/api/logger-subscriber/service/ConsoleLogger.test.js +1 -1
- package/lib/cjs/src/api/logger-subscriber/service/ConsoleLogger.test.js.map +2 -2
- package/lib/cjs/src/api/logger-subscriber/service/DefaultLogTagFormatter.js +2 -0
- package/lib/cjs/src/api/logger-subscriber/service/DefaultLogTagFormatter.js.map +7 -0
- package/lib/cjs/src/api/logger-subscriber/service/DefaultLogTagFormatter.test.js +2 -0
- package/lib/cjs/src/api/logger-subscriber/service/DefaultLogTagFormatter.test.js.map +7 -0
- package/lib/cjs/src/api/logger-subscriber/service/LogTagFormatter.js +2 -0
- package/lib/cjs/src/api/logger-subscriber/service/LogTagFormatter.js.map +7 -0
- package/lib/cjs/src/api/utils/apduLogs.js +2 -0
- package/lib/cjs/src/api/utils/apduLogs.js.map +7 -0
- package/lib/cjs/src/api/utils/apduLogs.test.js +2 -0
- package/lib/cjs/src/api/utils/apduLogs.test.js.map +7 -0
- package/lib/cjs/src/internal/device-session/model/DeviceSession.js +1 -1
- package/lib/cjs/src/internal/device-session/model/DeviceSession.js.map +3 -3
- package/lib/cjs/src/internal/device-session/model/DeviceSession.test.js +2 -0
- package/lib/cjs/src/internal/device-session/model/DeviceSession.test.js.map +7 -0
- package/lib/cjs/src/internal/discovery/use-case/ConnectUseCase.js +1 -1
- package/lib/cjs/src/internal/discovery/use-case/ConnectUseCase.js.map +3 -3
- package/lib/cjs/src/internal/logger-publisher/service/DefaultLoggerPublisherService.js +1 -1
- package/lib/cjs/src/internal/logger-publisher/service/DefaultLoggerPublisherService.js.map +3 -3
- package/lib/cjs/src/internal/logger-publisher/service/DefaultLoggerPublisherService.test.js +1 -1
- package/lib/cjs/src/internal/logger-publisher/service/DefaultLoggerPublisherService.test.js.map +3 -3
- package/lib/cjs/src/internal/logger-publisher/service/sanitiseData.js +2 -0
- package/lib/cjs/src/internal/logger-publisher/service/sanitiseData.js.map +7 -0
- package/lib/cjs/src/internal/logger-publisher/service/sanitiseData.test.js +2 -0
- package/lib/cjs/src/internal/logger-publisher/service/sanitiseData.test.js.map +7 -0
- package/lib/esm/package.json +1 -1
- package/lib/esm/src/api/DeviceManagementKit.js +1 -1
- package/lib/esm/src/api/DeviceManagementKit.js.map +3 -3
- package/lib/esm/src/api/device-action/model/UserInteractionRequired.js +1 -1
- package/lib/esm/src/api/device-action/model/UserInteractionRequired.js.map +2 -2
- package/lib/esm/src/api/device-action/xstate-utils/XStateDeviceAction.js +1 -1
- package/lib/esm/src/api/device-action/xstate-utils/XStateDeviceAction.js.map +3 -3
- package/lib/esm/src/api/device-model/data/StaticDeviceModelDataSource.js +1 -1
- package/lib/esm/src/api/device-model/data/StaticDeviceModelDataSource.js.map +2 -2
- package/lib/esm/src/api/device-model/data/StaticDeviceModelDataSource.test.js +1 -1
- package/lib/esm/src/api/device-model/data/StaticDeviceModelDataSource.test.js.map +3 -3
- package/lib/esm/src/api/index.js +1 -1
- package/lib/esm/src/api/index.js.map +3 -3
- package/lib/esm/src/api/logger-subscriber/service/ConsoleLogger.js +1 -1
- package/lib/esm/src/api/logger-subscriber/service/ConsoleLogger.js.map +2 -2
- package/lib/esm/src/api/logger-subscriber/service/ConsoleLogger.test.js +1 -1
- package/lib/esm/src/api/logger-subscriber/service/ConsoleLogger.test.js.map +2 -2
- package/lib/esm/src/api/logger-subscriber/service/DefaultLogTagFormatter.js +2 -0
- package/lib/esm/src/api/logger-subscriber/service/DefaultLogTagFormatter.js.map +7 -0
- package/lib/esm/src/api/logger-subscriber/service/DefaultLogTagFormatter.test.js +2 -0
- package/lib/esm/src/api/logger-subscriber/service/DefaultLogTagFormatter.test.js.map +7 -0
- package/lib/esm/src/api/logger-subscriber/service/LogTagFormatter.js +1 -0
- package/lib/esm/src/api/logger-subscriber/service/LogTagFormatter.js.map +7 -0
- package/lib/esm/src/api/utils/apduLogs.js +2 -0
- package/lib/esm/src/api/utils/apduLogs.js.map +7 -0
- package/lib/esm/src/api/utils/apduLogs.test.js +2 -0
- package/lib/esm/src/api/utils/apduLogs.test.js.map +7 -0
- package/lib/esm/src/internal/device-session/model/DeviceSession.js +1 -1
- package/lib/esm/src/internal/device-session/model/DeviceSession.js.map +3 -3
- package/lib/esm/src/internal/device-session/model/DeviceSession.test.js +2 -0
- package/lib/esm/src/internal/device-session/model/DeviceSession.test.js.map +7 -0
- package/lib/esm/src/internal/discovery/use-case/ConnectUseCase.js +1 -1
- package/lib/esm/src/internal/discovery/use-case/ConnectUseCase.js.map +3 -3
- package/lib/esm/src/internal/logger-publisher/service/DefaultLoggerPublisherService.js +1 -1
- package/lib/esm/src/internal/logger-publisher/service/DefaultLoggerPublisherService.js.map +3 -3
- package/lib/esm/src/internal/logger-publisher/service/DefaultLoggerPublisherService.test.js +1 -1
- package/lib/esm/src/internal/logger-publisher/service/DefaultLoggerPublisherService.test.js.map +3 -3
- package/lib/esm/src/internal/logger-publisher/service/sanitiseData.js +2 -0
- package/lib/esm/src/internal/logger-publisher/service/sanitiseData.js.map +7 -0
- package/lib/esm/src/internal/logger-publisher/service/sanitiseData.test.js +2 -0
- package/lib/esm/src/internal/logger-publisher/service/sanitiseData.test.js.map +7 -0
- package/lib/types/src/api/DeviceManagementKit.d.ts +6 -2
- package/lib/types/src/api/DeviceManagementKit.d.ts.map +1 -1
- package/lib/types/src/api/device-action/model/UserInteractionRequired.d.ts +2 -1
- package/lib/types/src/api/device-action/model/UserInteractionRequired.d.ts.map +1 -1
- package/lib/types/src/api/device-action/xstate-utils/XStateDeviceAction.d.ts +4 -0
- package/lib/types/src/api/device-action/xstate-utils/XStateDeviceAction.d.ts.map +1 -1
- package/lib/types/src/api/device-model/data/StaticDeviceModelDataSource.d.ts +3 -0
- package/lib/types/src/api/device-model/data/StaticDeviceModelDataSource.d.ts.map +1 -1
- package/lib/types/src/api/index.d.ts +3 -0
- package/lib/types/src/api/index.d.ts.map +1 -1
- package/lib/types/src/api/logger-subscriber/model/LogSubscriberOptions.d.ts +1 -0
- package/lib/types/src/api/logger-subscriber/model/LogSubscriberOptions.d.ts.map +1 -1
- package/lib/types/src/api/logger-subscriber/service/DefaultLogTagFormatter.d.ts +10 -0
- package/lib/types/src/api/logger-subscriber/service/DefaultLogTagFormatter.d.ts.map +1 -0
- package/lib/types/src/api/logger-subscriber/service/DefaultLogTagFormatter.test.d.ts +2 -0
- package/lib/types/src/api/logger-subscriber/service/DefaultLogTagFormatter.test.d.ts.map +1 -0
- package/lib/types/src/api/logger-subscriber/service/LogTagFormatter.d.ts +9 -0
- package/lib/types/src/api/logger-subscriber/service/LogTagFormatter.d.ts.map +1 -0
- package/lib/types/src/api/utils/apduLogs.d.ts +17 -0
- package/lib/types/src/api/utils/apduLogs.d.ts.map +1 -0
- package/lib/types/src/api/utils/apduLogs.test.d.ts +2 -0
- package/lib/types/src/api/utils/apduLogs.test.d.ts.map +1 -0
- package/lib/types/src/internal/device-session/model/DeviceSession.d.ts.map +1 -1
- package/lib/types/src/internal/device-session/model/DeviceSession.test.d.ts +2 -0
- package/lib/types/src/internal/device-session/model/DeviceSession.test.d.ts.map +1 -0
- package/lib/types/src/internal/discovery/use-case/ConnectUseCase.d.ts.map +1 -1
- package/lib/types/src/internal/logger-publisher/service/DefaultLoggerPublisherService.d.ts +5 -2
- package/lib/types/src/internal/logger-publisher/service/DefaultLoggerPublisherService.d.ts.map +1 -1
- package/lib/types/src/internal/logger-publisher/service/sanitiseData.d.ts +6 -0
- package/lib/types/src/internal/logger-publisher/service/sanitiseData.d.ts.map +1 -0
- package/lib/types/src/internal/logger-publisher/service/sanitiseData.test.d.ts +2 -0
- package/lib/types/src/internal/logger-publisher/service/sanitiseData.test.d.ts.map +1 -0
- package/lib/types/tsconfig.prod.tsbuildinfo +1 -1
- package/package.json +3 -3
|
@@ -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 {\n InvalidGetFirmwareMetadataResponseError,\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 GetAppAndVersionCommand,\n type GetAppAndVersionResponse,\n} from \"@api/command/os/GetAppAndVersionCommand\";\nexport {\n BatteryStatusType,\n type GetBatteryStatusArgs,\n GetBatteryStatusCommand,\n type GetBatteryStatusResponse,\n} from \"@api/command/os/GetBatteryStatusCommand\";\nexport {\n GetOsVersionCommand,\n type GetOsVersionResponse,\n} from \"@api/command/os/GetOsVersionCommand\";\nexport {\n type ListAppsArgs,\n ListAppsCommand,\n type ListAppsErrorCodes,\n type ListAppsResponse,\n} from \"@api/command/os/ListAppsCommand\";\nexport {\n type LoadCertificateArgs,\n LoadCertificateCommand,\n type LoadCertificateErrorCodes,\n} from \"@api/command/os/LoadCertificateCommand\";\nexport {\n type OpenAppArgs,\n OpenAppCommand,\n} from \"@api/command/os/OpenAppCommand\";\nexport { isCommandErrorCode } from \"@api/command/utils/CommandErrors\";\nexport { CommandUtils } from \"@api/command/utils/CommandUtils\";\nexport {\n GlobalCommandError,\n GlobalCommandErrorHandler,\n} from \"@api/command/utils/GlobalCommandError\";\nexport {\n DeviceModel,\n DeviceModelId,\n LEDGER_VENDOR_ID,\n} from \"@api/device/DeviceModel\";\nexport { DeviceStatus } from \"@api/device/DeviceStatus\";\nexport { type InternalApi } from \"@api/device-action/DeviceAction\";\nexport {\n type DeviceActionState,\n DeviceActionStatus,\n} from \"@api/device-action/model/DeviceActionState\";\nexport { UserInteractionRequired } from \"@api/device-action/model/UserInteractionRequired\";\nexport { CallTaskInAppDeviceAction } from \"@api/device-action/os/CallTaskInAppDeviceAction/CallTaskInAppDeviceAction\";\nexport {\n AppAlreadyInstalledDAError,\n DeviceLockedError,\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 { 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 {\n type DeviceActionStateMachine,\n XStateDeviceAction,\n} from \"@api/device-action/xstate-utils/XStateDeviceAction\";\nexport { StaticDeviceModelDataSource } from \"@api/device-model/data/StaticDeviceModelDataSource\";\nexport { BleDeviceInfos } from \"@api/device-model/model/BleDeviceInfos\";\nexport { TransportDeviceModel } from \"@api/device-model/model/DeviceModel\";\nexport { ApduResponse } from \"@api/device-session/ApduResponse\";\nexport * from \"@api/device-session/data/FramerConst\";\nexport {\n type DeviceSessionState,\n DeviceSessionStateType,\n} from \"@api/device-session/DeviceSessionState\";\nexport { GenuineCheckDeviceAction } from \"@api/secure-channel/device-action/GenuineCheck/GenuineCheckDeviceAction\";\nexport { InstallAppDeviceAction } from \"@api/secure-channel/device-action/InstallApp/InstallAppDeviceAction\";\nexport { ListInstalledAppsDeviceAction } from \"@api/secure-channel/device-action/ListInstalledApps/ListInstalledAppsDeviceAction\";\nexport { UninstallAppDeviceAction } from \"@api/secure-channel/device-action/UninstallApp/UninstallAppDeviceAction\";\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 { LogLevel } from \"@api/logger-subscriber/model/LogLevel\";\nexport { ConsoleLogger } from \"@api/logger-subscriber/service/ConsoleLogger\";\nexport { WebLogsExporterLogger } from \"@api/logger-subscriber/service/WebLogsExporterLogger\";\nexport { ConnectedDevice } from \"@api/transport/model/ConnectedDevice\";\nexport {\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 { base64StringToBuffer, isBase64String } 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_GetAppAndVersionCommand", "import_GetBatteryStatusCommand", "import_GetOsVersionCommand", "import_ListAppsCommand", "import_LoadCertificateCommand", "import_OpenAppCommand", "import_CommandErrors", "import_CommandUtils", "import_GlobalCommandError", "import_DeviceModel", "import_DeviceStatus", "import_DeviceActionState", "import_UserInteractionRequired", "import_CallTaskInAppDeviceAction", "import_GetDeviceMetadataDeviceAction", "import_GetDeviceStatusDeviceAction", "import_GoToDashboardDeviceAction", "import_InstallOrUpdateAppsDeviceAction", "import_ListAppsDeviceAction", "import_ListAppsWithMetadataDeviceAction", "import_OpenAppDeviceAction", "import_OpenAppWithDependenciesDeviceAction", "import_SendCommandInAppDeviceAction", "import_XStateDeviceAction", "import_StaticDeviceModelDataSource", "import_BleDeviceInfos", "import_ApduResponse", "import_DeviceSessionState", "import_GenuineCheckDeviceAction", "import_InstallAppDeviceAction", "import_ListInstalledAppsDeviceAction", "import_UninstallAppDeviceAction", "import_DefaultApduReceiverService", "import_DefaultApduSenderService", "import_FramerUtils", "import_DeviceManagementKit", "import_DeviceManagementKitBuilder", "import_LogLevel", "import_ConsoleLogger", "import_WebLogsExporterLogger", "import_ConnectedDevice", "import_DeviceConnectionStateMachine", "import_TransportConnectedDevice", "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 {\n InvalidGetFirmwareMetadataResponseError,\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 GetAppAndVersionCommand,\n type GetAppAndVersionResponse,\n} from \"@api/command/os/GetAppAndVersionCommand\";\nexport {\n BatteryStatusType,\n type GetBatteryStatusArgs,\n GetBatteryStatusCommand,\n type GetBatteryStatusResponse,\n} from \"@api/command/os/GetBatteryStatusCommand\";\nexport {\n GetOsVersionCommand,\n type GetOsVersionResponse,\n} from \"@api/command/os/GetOsVersionCommand\";\nexport {\n type ListAppsArgs,\n ListAppsCommand,\n type ListAppsErrorCodes,\n type ListAppsResponse,\n} from \"@api/command/os/ListAppsCommand\";\nexport {\n type LoadCertificateArgs,\n LoadCertificateCommand,\n type LoadCertificateErrorCodes,\n} from \"@api/command/os/LoadCertificateCommand\";\nexport {\n type OpenAppArgs,\n OpenAppCommand,\n} from \"@api/command/os/OpenAppCommand\";\nexport { isCommandErrorCode } from \"@api/command/utils/CommandErrors\";\nexport { CommandUtils } from \"@api/command/utils/CommandUtils\";\nexport {\n GlobalCommandError,\n GlobalCommandErrorHandler,\n} from \"@api/command/utils/GlobalCommandError\";\nexport {\n DeviceModel,\n DeviceModelId,\n LEDGER_VENDOR_ID,\n} from \"@api/device/DeviceModel\";\nexport { DeviceStatus } from \"@api/device/DeviceStatus\";\nexport { type InternalApi } from \"@api/device-action/DeviceAction\";\nexport {\n type DeviceActionState,\n DeviceActionStatus,\n} from \"@api/device-action/model/DeviceActionState\";\nexport { UserInteractionRequired } from \"@api/device-action/model/UserInteractionRequired\";\nexport { CallTaskInAppDeviceAction } from \"@api/device-action/os/CallTaskInAppDeviceAction/CallTaskInAppDeviceAction\";\nexport {\n AppAlreadyInstalledDAError,\n DeviceLockedError,\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 { 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 {\n type DeviceActionStateMachine,\n XStateDeviceAction,\n} from \"@api/device-action/xstate-utils/XStateDeviceAction\";\nexport { StaticDeviceModelDataSource } from \"@api/device-model/data/StaticDeviceModelDataSource\";\nexport { BleDeviceInfos } from \"@api/device-model/model/BleDeviceInfos\";\nexport { TransportDeviceModel } from \"@api/device-model/model/DeviceModel\";\nexport { ApduResponse } from \"@api/device-session/ApduResponse\";\nexport * from \"@api/device-session/data/FramerConst\";\nexport {\n type DeviceSessionState,\n DeviceSessionStateType,\n} from \"@api/device-session/DeviceSessionState\";\nexport { GenuineCheckDeviceAction } from \"@api/secure-channel/device-action/GenuineCheck/GenuineCheckDeviceAction\";\nexport { InstallAppDeviceAction } from \"@api/secure-channel/device-action/InstallApp/InstallAppDeviceAction\";\nexport { ListInstalledAppsDeviceAction } from \"@api/secure-channel/device-action/ListInstalledApps/ListInstalledAppsDeviceAction\";\nexport { UninstallAppDeviceAction } from \"@api/secure-channel/device-action/UninstallApp/UninstallAppDeviceAction\";\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 { 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 { 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 { base64StringToBuffer, isBase64String } 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,8nHAAAE,GAAAF,GAEA,IAAAG,EAAqB,gCACrBC,EAA8C,uCAC9CC,EAA2B,sCAC3BC,EAAAN,EAAc,2CALd,gBAMA,IAAAO,EAAiC,4CACjCC,EAAgC,2CAChCC,EAGO,+BACPC,EAIO,4CACPC,EAAgC,2CAChCC,EAGO,mDACPC,EAKO,mDACPC,EAGO,+CACPC,EAKO,2CACPC,EAIO,kDACPC,EAGO,0CACPC,EAAmC,4CACnCC,EAA6B,2CAC7BC,EAGO,iDACPC,EAIO,mCACPC,EAA6B,oCAE7BC,EAGO,sDACPC,EAAwC,4DACxCC,EAA0C,qFAC1ChB,EAOO,wCACPiB,EAA8C,iFAC9CC,EAA4C,6EAC5CC,EAA0C,yEAC1CC,EAAgD,qFAChDC,EAAqC,+DACrCC,EAAiD,uFACjDC,EAAoC,yEACpCC,EAAoD,6FACpDC,EAA6C,2FAC7CC,EAGO,8DACPC,EAA4C,8DAC5CC,EAA+B,kDAC/BhB,EAAqC,+CACrCiB,EAA6B,4CAC7BhC,EAAAN,EAAc,gDA3Fd,gBA4FA,IAAAuC,EAGO,kDACPC,EAAyC,mFACzCC,EAAuC,+EACvCC,EAA8C,6FAC9CC,EAAyC,mFACzClC,GAAmC,iDAEnCmC,GAAsD,uEACtDC,GAAoD,qEACpDC,GAA4B,iDAC5BC,GAAoC,oCACpCC,GAA2C,2CAC3C1C,EAAAN,EAAc,sBA3Gd,gBA4GA,IAAAiD,GAAyB,iDACzBC,GAA8B,wDAC9BC,GAAuC,iEAEvCC,GAAsC,gEACtCC,GAAgC,gDAChCC,GAGO,6DACPhD,EAAAN,EAAc,uCAtHd,gBAuHA,IAAAuD,GAAyC,yDACzCA,GAA2C,8DAC3CjD,EAAAN,EAAc,sBAzHd,gBA0HA,IAAAwD,EAAyD,+BACzDC,EAAqD,mCACrDC,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_GetAppAndVersionCommand", "import_GetBatteryStatusCommand", "import_GetOsVersionCommand", "import_ListAppsCommand", "import_LoadCertificateCommand", "import_OpenAppCommand", "import_CommandErrors", "import_CommandUtils", "import_GlobalCommandError", "import_DeviceModel", "import_DeviceStatus", "import_DeviceActionState", "import_UserInteractionRequired", "import_CallTaskInAppDeviceAction", "import_GetDeviceMetadataDeviceAction", "import_GetDeviceStatusDeviceAction", "import_GoToDashboardDeviceAction", "import_InstallOrUpdateAppsDeviceAction", "import_ListAppsDeviceAction", "import_ListAppsWithMetadataDeviceAction", "import_OpenAppDeviceAction", "import_OpenAppWithDependenciesDeviceAction", "import_SendCommandInAppDeviceAction", "import_XStateDeviceAction", "import_StaticDeviceModelDataSource", "import_BleDeviceInfos", "import_ApduResponse", "import_DeviceSessionState", "import_GenuineCheckDeviceAction", "import_InstallAppDeviceAction", "import_ListInstalledAppsDeviceAction", "import_UninstallAppDeviceAction", "import_DefaultApduReceiverService", "import_DefaultApduSenderService", "import_FramerUtils", "import_DeviceManagementKit", "import_DeviceManagementKitBuilder", "import_LogLevel", "import_ConsoleLogger", "import_DefaultLogTagFormatter", "import_WebLogsExporterLogger", "import_ConnectedDevice", "import_DeviceConnectionStateMachine", "import_TransportConnectedDevice", "import_apduLogs", "import_Base64String", "import_HexaString"]
|
|
7
7
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";var
|
|
1
|
+
"use strict";var a=Object.defineProperty;var g=Object.getOwnPropertyDescriptor;var i=Object.getOwnPropertyNames;var s=Object.prototype.hasOwnProperty;var p=(t,r,n,o)=>{if(r&&typeof r=="object"||typeof r=="function")for(let e of i(r))!s.call(t,e)&&e!==n&&a(t,e,{get:()=>r[e],enumerable:!(o=g(r,e))||o.enumerable});return t};var b=t=>p(a({},"__esModule",{value:!0}),t);var y={};module.exports=b(y);
|
|
2
2
|
//# sourceMappingURL=LogSubscriberOptions.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../../src/api/logger-subscriber/model/LogSubscriberOptions.ts"],
|
|
4
|
-
"sourcesContent": ["export type LogSubscriberData = Record<string, unknown>;\n\nexport type LogSubscriberOptions = {\n readonly tag: string;\n readonly timestamp: number;\n readonly data?: LogSubscriberData;\n};\n"],
|
|
4
|
+
"sourcesContent": ["export type LogSubscriberData = Record<string, unknown>;\n\n// Tag can be a single string or an array of strings for hierarchical tags\nexport type LogTag = string | string[];\n\nexport type LogSubscriberOptions = {\n // Formatted tag string (subscribers always receive a formatted string)\n readonly tag: string;\n readonly timestamp: number;\n readonly data?: LogSubscriberData;\n};\n"],
|
|
5
5
|
"mappings": "+WAAA,IAAAA,EAAA,kBAAAC,EAAAD",
|
|
6
6
|
"names": ["LogSubscriberOptions_exports", "__toCommonJS"]
|
|
7
7
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";var l=Object.defineProperty;var g=Object.getOwnPropertyDescriptor;var s=Object.getOwnPropertyNames;var c=Object.prototype.hasOwnProperty;var L=(o,e)=>{for(var a in e)l(o,a,{get:e[a],enumerable:!0})},h=(o,e,a,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of s(e))!c.call(o,r)&&r!==a&&l(o,r,{get:()=>e[r],enumerable:!(i=g(e,r))||i.enumerable});return o};var n=o=>h(l({},"__esModule",{value:!0}),o);var v={};L(v,{ConsoleLogger:()=>b});module.exports=n(v);var t=require("../../logger-subscriber/model/LogLevel");class b{maxLevel;constructor(e=t.LogLevel.Debug){this.maxLevel=e}log(e,a,i){const r
|
|
1
|
+
"use strict";var l=Object.defineProperty;var g=Object.getOwnPropertyDescriptor;var s=Object.getOwnPropertyNames;var c=Object.prototype.hasOwnProperty;var L=(o,e)=>{for(var a in e)l(o,a,{get:e[a],enumerable:!0})},h=(o,e,a,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of s(e))!c.call(o,r)&&r!==a&&l(o,r,{get:()=>e[r],enumerable:!(i=g(e,r))||i.enumerable});return o};var n=o=>h(l({},"__esModule",{value:!0}),o);var v={};L(v,{ConsoleLogger:()=>b});module.exports=n(v);var t=require("../../logger-subscriber/model/LogLevel");class b{maxLevel;constructor(e=t.LogLevel.Debug){this.maxLevel=e}log(e,a,i){const r=i.tag;switch(e){case t.LogLevel.Info:{this.maxLevel>=t.LogLevel.Info&&this.logWithData(r,console.info,a,i);break}case t.LogLevel.Warning:{this.maxLevel>=t.LogLevel.Warning&&this.logWithData(r,console.warn,a,i);break}case t.LogLevel.Debug:{this.maxLevel>=t.LogLevel.Debug&&this.logWithData(r,console.debug,a,i);break}case t.LogLevel.Error:{this.maxLevel>=t.LogLevel.Error&&this.logWithData(r,console.error,a,i);break}case t.LogLevel.Fatal:{this.maxLevel>=t.LogLevel.Fatal&&this.logWithData(r,console.error,a,i);break}default:this.logWithData(r,console.log,a,i)}}logWithData(e,a,i,r){r.data?a(e,i,r.data):a(e,i)}}0&&(module.exports={ConsoleLogger});
|
|
2
2
|
//# sourceMappingURL=ConsoleLogger.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../../src/api/logger-subscriber/service/ConsoleLogger.ts"],
|
|
4
|
-
"sourcesContent": ["import { LogLevel } from \"@api/logger-subscriber/model/LogLevel\";\nimport { type LogSubscriberOptions } from \"@api/logger-subscriber/model/LogSubscriberOptions\";\nimport { type LoggerSubscriberService } from \"@api/logger-subscriber/service/LoggerSubscriberService\";\n\nexport class ConsoleLogger implements LoggerSubscriberService {\n private readonly maxLevel: LogLevel;\n\n constructor(level: LogLevel = LogLevel.Debug) {\n this.maxLevel = level;\n }\n\n log(\n level: LogLevel | null,\n message: string,\n options: LogSubscriberOptions,\n ): void {\n const tag =
|
|
5
|
-
"mappings": "yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,mBAAAE,IAAA,eAAAC,EAAAH,GAAA,IAAAI,EAAyB,iDAIlB,MAAMF,CAAiD,CAC3C,SAEjB,YAAYG,EAAkB,WAAS,MAAO,CAC5C,KAAK,SAAWA,CAClB,CAEA,IACEA,EACAC,EACAC,EACM,CACN,MAAMC,
|
|
4
|
+
"sourcesContent": ["import { LogLevel } from \"@api/logger-subscriber/model/LogLevel\";\nimport { type LogSubscriberOptions } from \"@api/logger-subscriber/model/LogSubscriberOptions\";\nimport { type LoggerSubscriberService } from \"@api/logger-subscriber/service/LoggerSubscriberService\";\n\nexport class ConsoleLogger implements LoggerSubscriberService {\n private readonly maxLevel: LogLevel;\n\n constructor(level: LogLevel = LogLevel.Debug) {\n this.maxLevel = level;\n }\n\n log(\n level: LogLevel | null,\n message: string,\n options: LogSubscriberOptions,\n ): void {\n const tag = options.tag;\n\n switch (level) {\n case LogLevel.Info: {\n if (this.maxLevel >= LogLevel.Info) {\n this.logWithData(tag, console.info, message, options);\n }\n break;\n }\n case LogLevel.Warning: {\n if (this.maxLevel >= LogLevel.Warning) {\n this.logWithData(tag, console.warn, message, options);\n }\n break;\n }\n case LogLevel.Debug: {\n if (this.maxLevel >= LogLevel.Debug) {\n this.logWithData(tag, console.debug, message, options);\n }\n break;\n }\n case LogLevel.Error: {\n if (this.maxLevel >= LogLevel.Error) {\n this.logWithData(tag, console.error, message, options);\n }\n break;\n }\n case LogLevel.Fatal: {\n if (this.maxLevel >= LogLevel.Fatal) {\n this.logWithData(tag, console.error, message, options);\n }\n break;\n }\n default:\n this.logWithData(tag, console.log, message, options);\n }\n }\n\n private logWithData(\n tag: string,\n logFunction: (...args: unknown[]) => void,\n message: string,\n options: LogSubscriberOptions,\n ): void {\n if (options.data) {\n logFunction(tag, message, options.data);\n } else {\n logFunction(tag, message);\n }\n }\n}\n"],
|
|
5
|
+
"mappings": "yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,mBAAAE,IAAA,eAAAC,EAAAH,GAAA,IAAAI,EAAyB,iDAIlB,MAAMF,CAAiD,CAC3C,SAEjB,YAAYG,EAAkB,WAAS,MAAO,CAC5C,KAAK,SAAWA,CAClB,CAEA,IACEA,EACAC,EACAC,EACM,CACN,MAAMC,EAAMD,EAAQ,IAEpB,OAAQF,EAAO,CACb,KAAK,WAAS,KAAM,CACd,KAAK,UAAY,WAAS,MAC5B,KAAK,YAAYG,EAAK,QAAQ,KAAMF,EAASC,CAAO,EAEtD,KACF,CACA,KAAK,WAAS,QAAS,CACjB,KAAK,UAAY,WAAS,SAC5B,KAAK,YAAYC,EAAK,QAAQ,KAAMF,EAASC,CAAO,EAEtD,KACF,CACA,KAAK,WAAS,MAAO,CACf,KAAK,UAAY,WAAS,OAC5B,KAAK,YAAYC,EAAK,QAAQ,MAAOF,EAASC,CAAO,EAEvD,KACF,CACA,KAAK,WAAS,MAAO,CACf,KAAK,UAAY,WAAS,OAC5B,KAAK,YAAYC,EAAK,QAAQ,MAAOF,EAASC,CAAO,EAEvD,KACF,CACA,KAAK,WAAS,MAAO,CACf,KAAK,UAAY,WAAS,OAC5B,KAAK,YAAYC,EAAK,QAAQ,MAAOF,EAASC,CAAO,EAEvD,KACF,CACA,QACE,KAAK,YAAYC,EAAK,QAAQ,IAAKF,EAASC,CAAO,CACvD,CACF,CAEQ,YACNC,EACAC,EACAH,EACAC,EACM,CACFA,EAAQ,KACVE,EAAYD,EAAKF,EAASC,EAAQ,IAAI,EAEtCE,EAAYD,EAAKF,CAAO,CAE5B,CACF",
|
|
6
6
|
"names": ["ConsoleLogger_exports", "__export", "ConsoleLogger", "__toCommonJS", "import_LogLevel", "level", "message", "options", "tag", "logFunction"]
|
|
7
7
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";var t=require("../../logger-subscriber/model/LogLevel"),g=require("./ConsoleLogger");const d=vi.spyOn(console,"warn").mockImplementation(vi.fn()),n=vi.spyOn(console,"info").mockImplementation(vi.fn()),r=vi.spyOn(console,"debug").mockImplementation(vi.fn()),a=vi.spyOn(console,"error").mockImplementation(vi.fn()),s=vi.spyOn(console,"log").mockImplementation(vi.fn());let o;const e={data:{key:"value"},timestamp:1,tag:"tag"},l="message";describe("ConsoleLogger",()=>{afterAll(()=>{vi.restoreAllMocks()}),describe("default level (LogLevel.DEBUG)",()=>{beforeEach(()=>{vi.clearAllMocks(),o=new g.ConsoleLogger}),describe("log",()=>{it("should log Info level",()=>{o.log(t.LogLevel.Info,l,e),expect(n).toHaveBeenCalledWith(
|
|
1
|
+
"use strict";var t=require("../../logger-subscriber/model/LogLevel"),g=require("./ConsoleLogger");const d=vi.spyOn(console,"warn").mockImplementation(vi.fn()),n=vi.spyOn(console,"info").mockImplementation(vi.fn()),r=vi.spyOn(console,"debug").mockImplementation(vi.fn()),a=vi.spyOn(console,"error").mockImplementation(vi.fn()),s=vi.spyOn(console,"log").mockImplementation(vi.fn());let o;const e={data:{key:"value"},timestamp:1,tag:"[tag]"},l="message";describe("ConsoleLogger",()=>{afterAll(()=>{vi.restoreAllMocks()}),describe("default level (LogLevel.DEBUG)",()=>{beforeEach(()=>{vi.clearAllMocks(),o=new g.ConsoleLogger}),describe("log",()=>{it("should log Info level",()=>{o.log(t.LogLevel.Info,l,e),expect(n).toHaveBeenCalledWith(e.tag,l,e.data)}),it("should log Info level with a custom tag",()=>{const i="[custom-tag]";o.log(t.LogLevel.Info,l,{...e,tag:i}),expect(n).toHaveBeenCalledWith(i,l,e.data)}),it("should log Warn level",()=>{o.log(t.LogLevel.Warning,l,e),expect(d).toHaveBeenCalledWith(e.tag,l,e.data)}),it("should log Debug level",()=>{o.log(t.LogLevel.Debug,l,e),expect(r).toHaveBeenCalledWith(e.tag,l,e.data)}),it("should log Fatal level",()=>{o.log(t.LogLevel.Fatal,l,e),expect(a).toHaveBeenCalledWith(e.tag,l,e.data)}),it("should default to Log level if none present",()=>{o.log(null,l,e),expect(s).toHaveBeenCalledWith(e.tag,l,e.data)}),it("should log Error level",()=>{o.log(t.LogLevel.Error,l,e),expect(a).toHaveBeenCalledWith(e.tag,l,e.data)})})}),describe("custom level (LogLevel.Info)",()=>{beforeEach(()=>{vi.clearAllMocks(),o=new g.ConsoleLogger(t.LogLevel.Info)}),describe("log",()=>{it("should log Info level",()=>{o.log(t.LogLevel.Info,l,e),expect(n).toHaveBeenCalledWith(e.tag,l,e.data)}),it("should log Info level with a custom tag",()=>{const i="[custom-tag]";o.log(t.LogLevel.Info,l,{...e,tag:i}),expect(n).toHaveBeenCalledWith(i,l,e.data)}),it("should log Warn level",()=>{o.log(t.LogLevel.Warning,l,e),expect(d).toHaveBeenCalledWith(e.tag,l,e.data)}),it("should not log Debug level",()=>{o.log(t.LogLevel.Debug,l,e),expect(r).not.toHaveBeenCalled()}),it("should default to Log level if none present",()=>{o.log(null,l,e),expect(s).toHaveBeenCalledWith(e.tag,l,e.data)}),it("should log Error level",()=>{o.log(t.LogLevel.Error,l,e),expect(a).toHaveBeenCalledWith(e.tag,l,e.data)}),it("should log Fatal level",()=>{o.log(t.LogLevel.Fatal,l,e),expect(a).toHaveBeenCalledWith(e.tag,l,e.data)})})}),describe("custom level (LogLevel.Warning)",()=>{beforeEach(()=>{vi.clearAllMocks(),o=new g.ConsoleLogger(t.LogLevel.Warning)}),describe("log",()=>{it("should not log Info level",()=>{o.log(t.LogLevel.Info,l,e),expect(n).not.toHaveBeenCalled()}),it("should log Warn level",()=>{o.log(t.LogLevel.Warning,l,e),expect(d).toHaveBeenCalledWith(e.tag,l,e.data)}),it("should not log Debug level",()=>{o.log(t.LogLevel.Debug,l,e),expect(r).not.toHaveBeenCalled()}),it("should default to Log level if none present",()=>{o.log(null,l,e),expect(s).toHaveBeenCalledWith(e.tag,l,e.data)}),it("should log Error level",()=>{o.log(t.LogLevel.Error,l,e),expect(a).toHaveBeenCalledWith(e.tag,l,e.data)}),it("should log Fatal level",()=>{o.log(t.LogLevel.Fatal,l,e),expect(a).toHaveBeenCalledWith(e.tag,l,e.data)})})}),describe("custom level (LogLevel.Error)",()=>{beforeEach(()=>{vi.clearAllMocks(),o=new g.ConsoleLogger(t.LogLevel.Error)}),describe("log",()=>{it("should not log Info level",()=>{o.log(t.LogLevel.Info,l,e),expect(n).not.toHaveBeenCalled()}),it("should not log Warn level",()=>{o.log(t.LogLevel.Warning,l,e),expect(d).not.toHaveBeenCalled()}),it("should not log Debug level",()=>{o.log(t.LogLevel.Debug,l,e),expect(r).not.toHaveBeenCalled()}),it("should default to Log level if none present",()=>{o.log(null,l,e),expect(s).toHaveBeenCalledWith(e.tag,l,e.data)}),it("should log Error level",()=>{o.log(t.LogLevel.Error,l,e),expect(a).toHaveBeenCalledWith(e.tag,l,e.data)}),it("should log Fatal level",()=>{o.log(t.LogLevel.Fatal,l,e),expect(a).toHaveBeenCalledWith(e.tag,l,e.data)})})}),describe("custom level (LogLevel.Fatal)",()=>{beforeEach(()=>{vi.clearAllMocks(),o=new g.ConsoleLogger(t.LogLevel.Fatal)}),describe("log",()=>{it("should not log Info level",()=>{o.log(t.LogLevel.Info,l,e),expect(n).not.toHaveBeenCalled()}),it("should not log Warn level",()=>{o.log(t.LogLevel.Warning,l,e),expect(d).not.toHaveBeenCalled()}),it("should not log Debug level",()=>{o.log(t.LogLevel.Debug,l,e),expect(r).not.toHaveBeenCalled()}),it("should log Fatal level",()=>{o.log(t.LogLevel.Fatal,l,e),expect(a).toHaveBeenCalledWith(e.tag,l,e.data)})})})});
|
|
2
2
|
//# sourceMappingURL=ConsoleLogger.test.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../../src/api/logger-subscriber/service/ConsoleLogger.test.ts"],
|
|
4
|
-
"sourcesContent": ["import { LogLevel } from \"@api/logger-subscriber/model/LogLevel\";\nimport { type LogSubscriberOptions } from \"@api/logger-subscriber/model/LogSubscriberOptions\";\n\nimport { ConsoleLogger } from \"./ConsoleLogger\";\n\nconst warn = vi.spyOn(console, \"warn\").mockImplementation(vi.fn());\nconst info = vi.spyOn(console, \"info\").mockImplementation(vi.fn());\nconst debug = vi.spyOn(console, \"debug\").mockImplementation(vi.fn());\nconst error = vi.spyOn(console, \"error\").mockImplementation(vi.fn());\nconst log = vi.spyOn(console, \"log\").mockImplementation(vi.fn());\n\nlet logger: ConsoleLogger;\nconst options: LogSubscriberOptions = {\n data: { key: \"value\" },\n timestamp: 1,\n tag: \"tag\",\n};\nconst message = \"message\";\n\ndescribe(\"ConsoleLogger\", () => {\n afterAll(() => {\n vi.restoreAllMocks();\n });\n\n describe(\"default level (LogLevel.DEBUG)\", () => {\n beforeEach(() => {\n vi.clearAllMocks();\n logger = new ConsoleLogger();\n });\n\n describe(\"log\", () => {\n it(\"should log Info level\", () => {\n logger.log(LogLevel.Info, message, options);\n expect(info).toHaveBeenCalledWith(
|
|
5
|
-
"mappings": "aAAA,IAAAA,EAAyB,iDAGzBC,EAA8B,2BAE9B,MAAMC,EAAO,GAAG,MAAM,QAAS,MAAM,EAAE,mBAAmB,GAAG,GAAG,CAAC,EAC3DC,EAAO,GAAG,MAAM,QAAS,MAAM,EAAE,mBAAmB,GAAG,GAAG,CAAC,EAC3DC,EAAQ,GAAG,MAAM,QAAS,OAAO,EAAE,mBAAmB,GAAG,GAAG,CAAC,EAC7DC,EAAQ,GAAG,MAAM,QAAS,OAAO,EAAE,mBAAmB,GAAG,GAAG,CAAC,EAC7DC,EAAM,GAAG,MAAM,QAAS,KAAK,EAAE,mBAAmB,GAAG,GAAG,CAAC,EAE/D,IAAIC,
|
|
4
|
+
"sourcesContent": ["import { LogLevel } from \"@api/logger-subscriber/model/LogLevel\";\nimport { type LogSubscriberOptions } from \"@api/logger-subscriber/model/LogSubscriberOptions\";\n\nimport { ConsoleLogger } from \"./ConsoleLogger\";\n\nconst warn = vi.spyOn(console, \"warn\").mockImplementation(vi.fn());\nconst info = vi.spyOn(console, \"info\").mockImplementation(vi.fn());\nconst debug = vi.spyOn(console, \"debug\").mockImplementation(vi.fn());\nconst error = vi.spyOn(console, \"error\").mockImplementation(vi.fn());\nconst log = vi.spyOn(console, \"log\").mockImplementation(vi.fn());\n\nlet logger: ConsoleLogger;\n// Tags are pre-formatted by the publisher before reaching subscribers\nconst options: LogSubscriberOptions = {\n data: { key: \"value\" },\n timestamp: 1,\n tag: \"[tag]\",\n};\nconst message = \"message\";\n\ndescribe(\"ConsoleLogger\", () => {\n afterAll(() => {\n vi.restoreAllMocks();\n });\n\n describe(\"default level (LogLevel.DEBUG)\", () => {\n beforeEach(() => {\n vi.clearAllMocks();\n logger = new ConsoleLogger();\n });\n\n describe(\"log\", () => {\n it(\"should log Info level\", () => {\n logger.log(LogLevel.Info, message, options);\n expect(info).toHaveBeenCalledWith(options.tag, message, options.data);\n });\n\n it(\"should log Info level with a custom tag\", () => {\n const tag = \"[custom-tag]\";\n logger.log(LogLevel.Info, message, { ...options, tag });\n expect(info).toHaveBeenCalledWith(tag, message, options.data);\n });\n\n it(\"should log Warn level\", () => {\n logger.log(LogLevel.Warning, message, options);\n expect(warn).toHaveBeenCalledWith(options.tag, message, options.data);\n });\n\n it(\"should log Debug level\", () => {\n logger.log(LogLevel.Debug, message, options);\n expect(debug).toHaveBeenCalledWith(options.tag, message, options.data);\n });\n\n it(\"should log Fatal level\", () => {\n logger.log(LogLevel.Fatal, message, options);\n expect(error).toHaveBeenCalledWith(options.tag, message, options.data);\n });\n\n it(\"should default to Log level if none present\", () => {\n logger.log(null, message, options);\n expect(log).toHaveBeenCalledWith(options.tag, message, options.data);\n });\n\n it(\"should log Error level\", () => {\n logger.log(LogLevel.Error, message, options);\n expect(error).toHaveBeenCalledWith(options.tag, message, options.data);\n });\n });\n });\n\n describe(\"custom level (LogLevel.Info)\", () => {\n beforeEach(() => {\n vi.clearAllMocks();\n logger = new ConsoleLogger(LogLevel.Info);\n });\n\n describe(\"log\", () => {\n it(\"should log Info level\", () => {\n logger.log(LogLevel.Info, message, options);\n expect(info).toHaveBeenCalledWith(options.tag, message, options.data);\n });\n\n it(\"should log Info level with a custom tag\", () => {\n const tag = \"[custom-tag]\";\n logger.log(LogLevel.Info, message, { ...options, tag });\n expect(info).toHaveBeenCalledWith(tag, message, options.data);\n });\n\n it(\"should log Warn level\", () => {\n logger.log(LogLevel.Warning, message, options);\n expect(warn).toHaveBeenCalledWith(options.tag, message, options.data);\n });\n\n it(\"should not log Debug level\", () => {\n logger.log(LogLevel.Debug, message, options);\n expect(debug).not.toHaveBeenCalled();\n });\n\n it(\"should default to Log level if none present\", () => {\n logger.log(null, message, options);\n expect(log).toHaveBeenCalledWith(options.tag, message, options.data);\n });\n\n it(\"should log Error level\", () => {\n logger.log(LogLevel.Error, message, options);\n expect(error).toHaveBeenCalledWith(options.tag, message, options.data);\n });\n\n it(\"should log Fatal level\", () => {\n logger.log(LogLevel.Fatal, message, options);\n expect(error).toHaveBeenCalledWith(options.tag, message, options.data);\n });\n });\n });\n\n describe(\"custom level (LogLevel.Warning)\", () => {\n beforeEach(() => {\n vi.clearAllMocks();\n logger = new ConsoleLogger(LogLevel.Warning);\n });\n\n describe(\"log\", () => {\n it(\"should not log Info level\", () => {\n logger.log(LogLevel.Info, message, options);\n expect(info).not.toHaveBeenCalled();\n });\n\n it(\"should log Warn level\", () => {\n logger.log(LogLevel.Warning, message, options);\n expect(warn).toHaveBeenCalledWith(options.tag, message, options.data);\n });\n\n it(\"should not log Debug level\", () => {\n logger.log(LogLevel.Debug, message, options);\n expect(debug).not.toHaveBeenCalled();\n });\n\n it(\"should default to Log level if none present\", () => {\n logger.log(null, message, options);\n expect(log).toHaveBeenCalledWith(options.tag, message, options.data);\n });\n\n it(\"should log Error level\", () => {\n logger.log(LogLevel.Error, message, options);\n expect(error).toHaveBeenCalledWith(options.tag, message, options.data);\n });\n\n it(\"should log Fatal level\", () => {\n logger.log(LogLevel.Fatal, message, options);\n expect(error).toHaveBeenCalledWith(options.tag, message, options.data);\n });\n });\n });\n\n describe(\"custom level (LogLevel.Error)\", () => {\n beforeEach(() => {\n vi.clearAllMocks();\n logger = new ConsoleLogger(LogLevel.Error);\n });\n\n describe(\"log\", () => {\n it(\"should not log Info level\", () => {\n logger.log(LogLevel.Info, message, options);\n expect(info).not.toHaveBeenCalled();\n });\n\n it(\"should not log Warn level\", () => {\n logger.log(LogLevel.Warning, message, options);\n expect(warn).not.toHaveBeenCalled();\n });\n\n it(\"should not log Debug level\", () => {\n logger.log(LogLevel.Debug, message, options);\n expect(debug).not.toHaveBeenCalled();\n });\n\n it(\"should default to Log level if none present\", () => {\n logger.log(null, message, options);\n expect(log).toHaveBeenCalledWith(options.tag, message, options.data);\n });\n\n it(\"should log Error level\", () => {\n logger.log(LogLevel.Error, message, options);\n expect(error).toHaveBeenCalledWith(options.tag, message, options.data);\n });\n\n it(\"should log Fatal level\", () => {\n logger.log(LogLevel.Fatal, message, options);\n expect(error).toHaveBeenCalledWith(options.tag, message, options.data);\n });\n });\n });\n\n describe(\"custom level (LogLevel.Fatal)\", () => {\n beforeEach(() => {\n vi.clearAllMocks();\n logger = new ConsoleLogger(LogLevel.Fatal);\n });\n\n describe(\"log\", () => {\n it(\"should not log Info level\", () => {\n logger.log(LogLevel.Info, message, options);\n expect(info).not.toHaveBeenCalled();\n });\n\n it(\"should not log Warn level\", () => {\n logger.log(LogLevel.Warning, message, options);\n expect(warn).not.toHaveBeenCalled();\n });\n\n it(\"should not log Debug level\", () => {\n logger.log(LogLevel.Debug, message, options);\n expect(debug).not.toHaveBeenCalled();\n });\n\n it(\"should log Fatal level\", () => {\n logger.log(LogLevel.Fatal, message, options);\n expect(error).toHaveBeenCalledWith(options.tag, message, options.data);\n });\n });\n });\n});\n"],
|
|
5
|
+
"mappings": "aAAA,IAAAA,EAAyB,iDAGzBC,EAA8B,2BAE9B,MAAMC,EAAO,GAAG,MAAM,QAAS,MAAM,EAAE,mBAAmB,GAAG,GAAG,CAAC,EAC3DC,EAAO,GAAG,MAAM,QAAS,MAAM,EAAE,mBAAmB,GAAG,GAAG,CAAC,EAC3DC,EAAQ,GAAG,MAAM,QAAS,OAAO,EAAE,mBAAmB,GAAG,GAAG,CAAC,EAC7DC,EAAQ,GAAG,MAAM,QAAS,OAAO,EAAE,mBAAmB,GAAG,GAAG,CAAC,EAC7DC,EAAM,GAAG,MAAM,QAAS,KAAK,EAAE,mBAAmB,GAAG,GAAG,CAAC,EAE/D,IAAIC,EAEJ,MAAMC,EAAgC,CACpC,KAAM,CAAE,IAAK,OAAQ,EACrB,UAAW,EACX,IAAK,OACP,EACMC,EAAU,UAEhB,SAAS,gBAAiB,IAAM,CAC9B,SAAS,IAAM,CACb,GAAG,gBAAgB,CACrB,CAAC,EAED,SAAS,iCAAkC,IAAM,CAC/C,WAAW,IAAM,CACf,GAAG,cAAc,EACjBF,EAAS,IAAI,eACf,CAAC,EAED,SAAS,MAAO,IAAM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,EAASD,EAAQ,IAAI,CACvE,CAAC,CACH,CAAC,CACH,CAAC,CACH,CAAC",
|
|
6
6
|
"names": ["import_LogLevel", "import_ConsoleLogger", "warn", "info", "debug", "error", "log", "logger", "options", "message", "tag"]
|
|
7
7
|
}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use strict";var e=Object.defineProperty;var g=Object.getOwnPropertyDescriptor;var i=Object.getOwnPropertyNames;var p=Object.prototype.hasOwnProperty;var f=(o,r)=>{for(var t in r)e(o,t,{get:r[t],enumerable:!0})},n=(o,r,t,m)=>{if(r&&typeof r=="object"||typeof r=="function")for(let a of i(r))!p.call(o,a)&&a!==t&&e(o,a,{get:()=>r[a],enumerable:!(m=g(r,a))||m.enumerable});return o};var s=o=>n(e({},"__esModule",{value:!0}),o);var T={};f(T,{DefaultLogTagFormatter:()=>L});module.exports=s(T);class L{format(r){return Array.isArray(r)?r.map(t=>`[${t}]`).join(" "):`[${r}]`}}0&&(module.exports={DefaultLogTagFormatter});
|
|
2
|
+
//# sourceMappingURL=DefaultLogTagFormatter.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../../../src/api/logger-subscriber/service/DefaultLogTagFormatter.ts"],
|
|
4
|
+
"sourcesContent": ["import { type LogTag } from \"@api/logger-subscriber/model/LogSubscriberOptions\";\n\nimport { type LogTagFormatter } from \"./LogTagFormatter\";\n\n/**\n * Default implementation of LogTagFormatter.\n * Formats tags as \"[tag1] [tag2] [tag3]\" for arrays, or \"[tag]\" for strings.\n */\nexport class DefaultLogTagFormatter implements LogTagFormatter {\n format(tag: LogTag): string {\n if (Array.isArray(tag)) {\n return tag.map((t) => `[${t}]`).join(\" \");\n }\n return `[${tag}]`;\n }\n}\n"],
|
|
5
|
+
"mappings": "yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,4BAAAE,IAAA,eAAAC,EAAAH,GAQO,MAAME,CAAkD,CAC7D,OAAOE,EAAqB,CAC1B,OAAI,MAAM,QAAQA,CAAG,EACZA,EAAI,IAAK,GAAM,IAAI,CAAC,GAAG,EAAE,KAAK,GAAG,EAEnC,IAAIA,CAAG,GAChB,CACF",
|
|
6
|
+
"names": ["DefaultLogTagFormatter_exports", "__export", "DefaultLogTagFormatter", "__toCommonJS", "tag"]
|
|
7
|
+
}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use strict";var t=require("vitest"),e=require("./DefaultLogTagFormatter");(0,t.describe)("DefaultLogTagFormatter",()=>{const a=new e.DefaultLogTagFormatter;(0,t.describe)("format",()=>{(0,t.it)("should format a single string tag with brackets",()=>{(0,t.expect)(a.format("myTag")).toBe("[myTag]")}),(0,t.it)("should format an empty string tag with brackets",()=>{(0,t.expect)(a.format("")).toBe("[]")}),(0,t.it)("should format a single element array with brackets",()=>{(0,t.expect)(a.format(["myTag"])).toBe("[myTag]")}),(0,t.it)("should format multiple tags with brackets separated by spaces",()=>{(0,t.expect)(a.format(["tag1","tag2","tag3"])).toBe("[tag1] [tag2] [tag3]")}),(0,t.it)("should format an empty array as empty string",()=>{(0,t.expect)(a.format([])).toBe("")}),(0,t.it)("should handle tags with special characters",()=>{(0,t.expect)(a.format(["SignerEth","ContextModule","loader"])).toBe("[SignerEth] [ContextModule] [loader]")})})});
|
|
2
|
+
//# sourceMappingURL=DefaultLogTagFormatter.test.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../../../src/api/logger-subscriber/service/DefaultLogTagFormatter.test.ts"],
|
|
4
|
+
"sourcesContent": ["import { describe, expect, it } from \"vitest\";\n\nimport { DefaultLogTagFormatter } from \"./DefaultLogTagFormatter\";\n\ndescribe(\"DefaultLogTagFormatter\", () => {\n const formatter = new DefaultLogTagFormatter();\n\n describe(\"format\", () => {\n it(\"should format a single string tag with brackets\", () => {\n expect(formatter.format(\"myTag\")).toBe(\"[myTag]\");\n });\n\n it(\"should format an empty string tag with brackets\", () => {\n expect(formatter.format(\"\")).toBe(\"[]\");\n });\n\n it(\"should format a single element array with brackets\", () => {\n expect(formatter.format([\"myTag\"])).toBe(\"[myTag]\");\n });\n\n it(\"should format multiple tags with brackets separated by spaces\", () => {\n expect(formatter.format([\"tag1\", \"tag2\", \"tag3\"])).toBe(\n \"[tag1] [tag2] [tag3]\",\n );\n });\n\n it(\"should format an empty array as empty string\", () => {\n expect(formatter.format([])).toBe(\"\");\n });\n\n it(\"should handle tags with special characters\", () => {\n expect(formatter.format([\"SignerEth\", \"ContextModule\", \"loader\"])).toBe(\n \"[SignerEth] [ContextModule] [loader]\",\n );\n });\n });\n});\n"],
|
|
5
|
+
"mappings": "aAAA,IAAAA,EAAqC,kBAErCC,EAAuC,uCAEvC,YAAS,yBAA0B,IAAM,CACvC,MAAMC,EAAY,IAAI,4BAEtB,YAAS,SAAU,IAAM,IACvB,MAAG,kDAAmD,IAAM,IAC1D,UAAOA,EAAU,OAAO,OAAO,CAAC,EAAE,KAAK,SAAS,CAClD,CAAC,KAED,MAAG,kDAAmD,IAAM,IAC1D,UAAOA,EAAU,OAAO,EAAE,CAAC,EAAE,KAAK,IAAI,CACxC,CAAC,KAED,MAAG,qDAAsD,IAAM,IAC7D,UAAOA,EAAU,OAAO,CAAC,OAAO,CAAC,CAAC,EAAE,KAAK,SAAS,CACpD,CAAC,KAED,MAAG,gEAAiE,IAAM,IACxE,UAAOA,EAAU,OAAO,CAAC,OAAQ,OAAQ,MAAM,CAAC,CAAC,EAAE,KACjD,sBACF,CACF,CAAC,KAED,MAAG,+CAAgD,IAAM,IACvD,UAAOA,EAAU,OAAO,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,CACtC,CAAC,KAED,MAAG,6CAA8C,IAAM,IACrD,UAAOA,EAAU,OAAO,CAAC,YAAa,gBAAiB,QAAQ,CAAC,CAAC,EAAE,KACjE,sCACF,CACF,CAAC,CACH,CAAC,CACH,CAAC",
|
|
6
|
+
"names": ["import_vitest", "import_DefaultLogTagFormatter", "formatter"]
|
|
7
|
+
}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use strict";var a=Object.defineProperty;var m=Object.getOwnPropertyDescriptor;var f=Object.getOwnPropertyNames;var i=Object.prototype.hasOwnProperty;var p=(g,t,e,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of f(t))!i.call(g,o)&&o!==e&&a(g,o,{get:()=>t[o],enumerable:!(r=m(t,o))||r.enumerable});return g};var L=g=>p(a({},"__esModule",{value:!0}),g);var T={};module.exports=L(T);
|
|
2
|
+
//# sourceMappingURL=LogTagFormatter.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../../../src/api/logger-subscriber/service/LogTagFormatter.ts"],
|
|
4
|
+
"sourcesContent": ["import { type LogTag } from \"@api/logger-subscriber/model/LogSubscriberOptions\";\n\n/**\n * Interface for formatting log tags.\n * Allows different formatting strategies to be injected into subscribers.\n */\nexport interface LogTagFormatter {\n format(tag: LogTag): string;\n}\n"],
|
|
5
|
+
"mappings": "+WAAA,IAAAA,EAAA,kBAAAC,EAAAD",
|
|
6
|
+
"names": ["LogTagFormatter_exports", "__toCommonJS"]
|
|
7
|
+
}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use strict";var a=Object.defineProperty;var i=Object.getOwnPropertyDescriptor;var s=Object.getOwnPropertyNames;var u=Object.prototype.hasOwnProperty;var p=(e,r)=>{for(var o in r)a(e,o,{get:r[o],enumerable:!0})},g=(e,r,o,f)=>{if(r&&typeof r=="object"||typeof r=="function")for(let t of s(r))!u.call(e,t)&&t!==o&&a(e,t,{get:()=>r[t],enumerable:!(f=i(r,t))||f.enumerable});return e};var d=e=>g(a({},"__esModule",{value:!0}),e);var l={};p(l,{formatApduReceivedLog:()=>c,formatApduSendingLog:()=>A,formatApduSentLog:()=>m});module.exports=d(l);var n=require("./HexaString");function A(e){return`[will send APDU] ~...> ${(0,n.bufferToHexaString)(e,!1)}`}function m(e){return`[exchange] => ${(0,n.bufferToHexaString)(e,!1)}`}function c(e){return`[exchange] <= ${(0,n.bufferToHexaString)(e.data,!1)}${(0,n.bufferToHexaString)(e.statusCode,!1)}`}0&&(module.exports={formatApduReceivedLog,formatApduSendingLog,formatApduSentLog});
|
|
2
|
+
//# sourceMappingURL=apduLogs.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../../src/api/utils/apduLogs.ts"],
|
|
4
|
+
"sourcesContent": ["import { type ApduResponse } from \"@api/device-session/ApduResponse\";\n\nimport { bufferToHexaString } from \"./HexaString\";\n\n/**\n * Formats the log message for an APDU that is about to be sent.\n * Only call this at the device session layer, before calling sendApdu on the connected device.\n */\nexport function formatApduSendingLog(apdu: Uint8Array): string {\n return `[will send APDU] ~...> ${bufferToHexaString(apdu, false)}`;\n}\n\n/**\n * Formats the log message for an APDU that was sent.\n * Only call this at the transport layer, after the APDU sending logic has been executed\n * without any error.\n */\nexport function formatApduSentLog(apdu: Uint8Array): string {\n return `[exchange] => ${bufferToHexaString(apdu, false)}`;\n}\n\n/**\n * Formats the log message for an APDU response received from the device.\n */\nexport function formatApduReceivedLog(apduResponse: ApduResponse): string {\n return `[exchange] <= ${bufferToHexaString(apduResponse.data, false)}${bufferToHexaString(apduResponse.statusCode, false)}`;\n}\n"],
|
|
5
|
+
"mappings": "yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,2BAAAE,EAAA,yBAAAC,EAAA,sBAAAC,IAAA,eAAAC,EAAAL,GAEA,IAAAM,EAAmC,wBAM5B,SAASH,EAAqBI,EAA0B,CAC7D,MAAO,6BAA0B,sBAAmBA,EAAM,EAAK,CAAC,EAClE,CAOO,SAASH,EAAkBG,EAA0B,CAC1D,MAAO,oBAAiB,sBAAmBA,EAAM,EAAK,CAAC,EACzD,CAKO,SAASL,EAAsBM,EAAoC,CACxE,MAAO,oBAAiB,sBAAmBA,EAAa,KAAM,EAAK,CAAC,MAAG,sBAAmBA,EAAa,WAAY,EAAK,CAAC,EAC3H",
|
|
6
|
+
"names": ["apduLogs_exports", "__export", "formatApduReceivedLog", "formatApduSendingLog", "formatApduSentLog", "__toCommonJS", "import_HexaString", "apdu", "apduResponse"]
|
|
7
|
+
}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use strict";var o=require("vitest"),e=require("./apduLogs");(0,o.describe)("apduLogs",()=>{(0,o.describe)("formatApduSendingLog",()=>{(0,o.it)("should format APDU with correct format before sending",()=>{const t=Uint8Array.from([224,1,0,0,4]);(0,o.expect)((0,e.formatApduSendingLog)(t)).toBe("[will send APDU] ~...> e001000004")}),(0,o.it)("should handle empty APDU",()=>{const t=Uint8Array.from([]);(0,o.expect)((0,e.formatApduSendingLog)(t)).toBe("[will send APDU] ~...> ")})}),(0,o.describe)("formatApduSentLog",()=>{(0,o.it)("should format APDU with correct format after sending",()=>{const t=Uint8Array.from([224,1,0,0,4]);(0,o.expect)((0,e.formatApduSentLog)(t)).toBe("[exchange] => e001000004")}),(0,o.it)("should handle empty APDU",()=>{const t=Uint8Array.from([]);(0,o.expect)((0,e.formatApduSentLog)(t)).toBe("[exchange] => ")})}),(0,o.describe)("formatApduReceivedLog",()=>{(0,o.it)("should format APDU response with data and status code",()=>{const t={data:Uint8Array.from([1,2,3]),statusCode:Uint8Array.from([144,0])};(0,o.expect)((0,e.formatApduReceivedLog)(t)).toBe("[exchange] <= 0102039000")}),(0,o.it)("should format APDU response with only status code when data is empty",()=>{const t={data:Uint8Array.from([]),statusCode:Uint8Array.from([144,0])};(0,o.expect)((0,e.formatApduReceivedLog)(t)).toBe("[exchange] <= 9000")}),(0,o.it)("should format error status code correctly",()=>{const t={data:Uint8Array.from([]),statusCode:Uint8Array.from([105,133])};(0,o.expect)((0,e.formatApduReceivedLog)(t)).toBe("[exchange] <= 6985")})})});
|
|
2
|
+
//# sourceMappingURL=apduLogs.test.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../../src/api/utils/apduLogs.test.ts"],
|
|
4
|
+
"sourcesContent": ["import { describe, expect, it } from \"vitest\";\n\nimport {\n formatApduReceivedLog,\n formatApduSendingLog,\n formatApduSentLog,\n} from \"./apduLogs\";\n\ndescribe(\"apduLogs\", () => {\n describe(\"formatApduSendingLog\", () => {\n it(\"should format APDU with correct format before sending\", () => {\n const apdu = Uint8Array.from([0xe0, 0x01, 0x00, 0x00, 0x04]);\n expect(formatApduSendingLog(apdu)).toBe(\n \"[will send APDU] ~...> e001000004\",\n );\n });\n\n it(\"should handle empty APDU\", () => {\n const apdu = Uint8Array.from([]);\n expect(formatApduSendingLog(apdu)).toBe(\"[will send APDU] ~...> \");\n });\n });\n\n describe(\"formatApduSentLog\", () => {\n it(\"should format APDU with correct format after sending\", () => {\n const apdu = Uint8Array.from([0xe0, 0x01, 0x00, 0x00, 0x04]);\n expect(formatApduSentLog(apdu)).toBe(\"[exchange] => e001000004\");\n });\n\n it(\"should handle empty APDU\", () => {\n const apdu = Uint8Array.from([]);\n expect(formatApduSentLog(apdu)).toBe(\"[exchange] => \");\n });\n });\n\n describe(\"formatApduReceivedLog\", () => {\n it(\"should format APDU response with data and status code\", () => {\n const apduResponse = {\n data: Uint8Array.from([0x01, 0x02, 0x03]),\n statusCode: Uint8Array.from([0x90, 0x00]),\n };\n expect(formatApduReceivedLog(apduResponse)).toBe(\n \"[exchange] <= 0102039000\",\n );\n });\n\n it(\"should format APDU response with only status code when data is empty\", () => {\n const apduResponse = {\n data: Uint8Array.from([]),\n statusCode: Uint8Array.from([0x90, 0x00]),\n };\n expect(formatApduReceivedLog(apduResponse)).toBe(\"[exchange] <= 9000\");\n });\n\n it(\"should format error status code correctly\", () => {\n const apduResponse = {\n data: Uint8Array.from([]),\n statusCode: Uint8Array.from([0x69, 0x85]),\n };\n expect(formatAp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KAAK,oBAAoB,CACvE,CAAC,KAED,MAAG,4CAA6C,IAAM,CACpD,MAAMA,EAAe,CACnB,KAAM,WAAW,KAAK,CAAC,CAAC,EACxB,WAAY,WAAW,KAAK,CAAC,IAAM,GAAI,CAAC,CAC1C,KACA,aAAO,yBAAsBA,CAAY,CAAC,EAAE,KAAK,oBAAoB,CACvE,CAAC,CACH,CAAC,CACH,CAAC",
|
|
6
|
+
"names": ["import_vitest", "import_apduLogs", "apdu", "apduResponse"]
|
|
7
|
+
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";var p=Object.defineProperty;var C=Object.getOwnPropertyDescriptor;var
|
|
1
|
+
"use strict";var p=Object.defineProperty;var C=Object.getOwnPropertyDescriptor;var A=Object.getOwnPropertyNames;var R=Object.prototype.hasOwnProperty;var y=(n,e)=>{for(var t in e)p(n,t,{get:e[t],enumerable:!0})},T=(n,e,t,s)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of A(e))!R.call(n,i)&&i!==t&&p(n,i,{get:()=>e[i],enumerable:!(s=C(e,i))||s.enumerable});return n};var O=n=>T(p({},"__esModule",{value:!0}),n);var P={};y(P,{DeviceSession:()=>I});module.exports=O(P);var d=require("rxjs"),h=require("uuid"),S=require("../../../api/command/utils/CommandUtils"),v=require("../../../api/device/DeviceStatus"),u=require("../../../api/device-session/DeviceSessionState"),m=require("../../../api/utils/apduLogs"),l=require("../../device-session/data/DeviceSessionRefresherConst"),D=require("../../device-session/service/MutexService"),_=require("../../device-session/service/RefresherService"),g=require("./DevicePinger"),o=require("./DeviceSessionEventDispatcher"),f=require("./DeviceSessionRefresher"),E=require("./DeviceSessionStateHandler");class I{_id;_connectedDevice;_deviceState;_managerApiService;_secureChannelService;_logger;_refresherOptions;_pinger;_deviceSessionRefresher;_refresherService;_commandMutex=new D.MutexService;_sessionEventDispatcher=new o.DeviceSessionEventDispatcher;constructor({connectedDevice:e,id:t=(0,h.v4)()},s,i,r,c){this._id=t,this._connectedDevice=e,this._logger=s("device-session"),this._managerApiService=i,this._secureChannelService=r,this._refresherOptions={...l.DEVICE_SESSION_REFRESHER_DEFAULT_OPTIONS,...c},this._deviceState=new d.BehaviorSubject({sessionStateType:u.DeviceSessionStateType.Connected,deviceStatus:v.DeviceStatus.CONNECTED,deviceModelId:this._connectedDevice.deviceModel.id}),this._pinger=new g.DevicePinger(s,e,this._sessionEventDispatcher,(a,b)=>this.sendCommand(a,b)),this._deviceSessionRefresher=new f.DeviceSessionRefresher(s,this._refresherOptions,this._sessionEventDispatcher,this._connectedDevice),new E.DeviceSessionStateHandler(s,this._sessionEventDispatcher,this._connectedDevice,this._deviceState,a=>this.setDeviceSessionState(a)),this._refresherService=new _.RefresherService(s,{start:()=>this._deviceSessionRefresher.restartRefresher(),stop:()=>this._deviceSessionRefresher.stopRefresher()})}async initialiseSession(){try{await this._pinger.ping()}catch(e){throw this._logger.error("Error while initialising session",{data:{error:e}}),e}finally{this._refresherOptions.isRefresherDisabled||this._deviceSessionRefresher.startRefresher()}}get id(){return this._id}get connectedDevice(){return this._connectedDevice}get state(){return this._deviceState.asObservable()}getDeviceSessionState(){return this._deviceState.getValue()}setDeviceSessionState(e){this._deviceState.next(e)}async sendApdu(e,t={isPolling:!1,triggersDisconnection:!1,abortTimeout:void 0}){const s=await this._commandMutex.lock();try{this._sessionEventDispatcher.dispatch({eventName:o.SessionEvents.DEVICE_STATE_UPDATE_BUSY}),this._logger.debug((0,m.formatApduSendingLog)(e));const i=await this._connectedDevice.sendApdu(e,t.triggersDisconnection,t.abortTimeout);return i.ifRight(r=>{S.CommandUtils.isLockedDeviceResponse(r)?this._sessionEventDispatcher.dispatch({eventName:o.SessionEvents.DEVICE_STATE_UPDATE_LOCKED}):this._sessionEventDispatcher.dispatch({eventName:o.SessionEvents.DEVICE_STATE_UPDATE_CONNECTED})}).ifLeft(()=>{this._sessionEventDispatcher.dispatch({eventName:o.SessionEvents.DEVICE_STATE_UPDATE_CONNECTED})}),i}finally{s()}}async sendCommand(e,t){this._logger.debug(`[sendCommand] ${e.name}`);const s=e.getApdu();return(await this.sendApdu(s.getRawApdu(),{isPolling:!1,triggersDisconnection:e.triggersDisconnection??!1,abortTimeout:t})).caseOf({Left:r=>{throw this._logger.error("[sendCommand] error",{data:{err:r}}),r},Right:r=>{const c=e.parseResponse(r,this._connectedDevice.deviceModel.id);return this._logger.debug("[sendCommand] result",{data:{result:c}}),c}})}executeDeviceAction(e){const{observable:t,cancel:s}=e._execute({sendApdu:async i=>this.sendApdu(i),sendCommand:async(i,r)=>this.sendCommand(i,r),getDeviceModel:()=>this._connectedDevice.deviceModel,getDeviceSessionState:()=>this._deviceState.getValue(),getDeviceSessionStateObservable:()=>this.state,setDeviceSessionState:i=>(this.setDeviceSessionState(i),this._deviceState.getValue()),disableRefresher:i=>this._refresherService.disableRefresher(i),getManagerApiService:()=>this._managerApiService,getSecureChannelService:()=>this._secureChannelService});return{observable:t,cancel:s}}close(){this._updateDeviceStatus(v.DeviceStatus.NOT_CONNECTED),this._deviceState.complete(),this._deviceSessionRefresher.stopRefresher(),this._pinger.unsubscribe()}disableRefresher(e){return this._refresherService.disableRefresher(e)}_updateDeviceStatus(e){const t=this._deviceState.getValue();this._deviceState.next({...t,deviceStatus:e})}}0&&(module.exports={DeviceSession});
|
|
2
2
|
//# sourceMappingURL=DeviceSession.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../../src/internal/device-session/model/DeviceSession.ts"],
|
|
4
|
-
"sourcesContent": ["import { type Either } from \"purify-ts\";\nimport { BehaviorSubject, type Observable } from \"rxjs\";\nimport { v4 as uuidv4 } from \"uuid\";\n\nimport { type Command } from \"@api/command/Command\";\nimport { type CommandResult } from \"@api/command/model/CommandResult\";\nimport { CommandUtils } from \"@api/command/utils/CommandUtils\";\nimport { DeviceStatus } from \"@api/device/DeviceStatus\";\nimport {\n type DeviceAction,\n type DeviceActionIntermediateValue,\n type ExecuteDeviceActionReturnType,\n} from \"@api/device-action/DeviceAction\";\nimport { type ApduResponse } from \"@api/device-session/ApduResponse\";\nimport {\n type DeviceSessionState,\n DeviceSessionStateType,\n} from \"@api/device-session/DeviceSessionState\";\nimport { type DeviceSessionId } from \"@api/device-session/types\";\nimport { type DmkError } from \"@api/Error\";\nimport {
|
|
5
|
-
"mappings": "yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,mBAAAE,IAAA,eAAAC,EAAAH,GACA,IAAAI,EAAiD,gBACjDC,EAA6B,gBAI7BC,EAA6B,2CAC7BC,EAA6B,oCAO7BC,EAGO,
|
|
6
|
-
"names": ["DeviceSession_exports", "__export", "DeviceSession", "__toCommonJS", "import_rxjs", "import_uuid", "import_CommandUtils", "import_DeviceStatus", "import_DeviceSessionState", "
|
|
4
|
+
"sourcesContent": ["import { type Either } from \"purify-ts\";\nimport { BehaviorSubject, type Observable } from \"rxjs\";\nimport { v4 as uuidv4 } from \"uuid\";\n\nimport { type Command } from \"@api/command/Command\";\nimport { type CommandResult } from \"@api/command/model/CommandResult\";\nimport { CommandUtils } from \"@api/command/utils/CommandUtils\";\nimport { DeviceStatus } from \"@api/device/DeviceStatus\";\nimport {\n type DeviceAction,\n type DeviceActionIntermediateValue,\n type ExecuteDeviceActionReturnType,\n} from \"@api/device-action/DeviceAction\";\nimport { type ApduResponse } from \"@api/device-session/ApduResponse\";\nimport {\n type DeviceSessionState,\n DeviceSessionStateType,\n} from \"@api/device-session/DeviceSessionState\";\nimport { type DeviceSessionId } from \"@api/device-session/types\";\nimport { type DmkError } from \"@api/Error\";\nimport { type LoggerPublisherService } from \"@api/logger-publisher/service/LoggerPublisherService\";\nimport { type TransportConnectedDevice } from \"@api/transport/model/TransportConnectedDevice\";\nimport { formatApduSendingLog } from \"@api/utils/apduLogs\";\nimport { DEVICE_SESSION_REFRESHER_DEFAULT_OPTIONS } from \"@internal/device-session/data/DeviceSessionRefresherConst\";\nimport { MutexService } from \"@internal/device-session/service/MutexService\";\nimport { RefresherService } from \"@internal/device-session/service/RefresherService\";\nimport { type ManagerApiService } from \"@internal/manager-api/service/ManagerApiService\";\nimport { type SecureChannelService } from \"@internal/secure-channel/service/SecureChannelService\";\n\nimport { DevicePinger } from \"./DevicePinger\";\nimport {\n DeviceSessionEventDispatcher,\n SessionEvents,\n} from \"./DeviceSessionEventDispatcher\";\nimport { DeviceSessionRefresher } from \"./DeviceSessionRefresher\";\nimport { DeviceSessionStateHandler } from \"./DeviceSessionStateHandler\";\n\nexport type SessionConstructorArgs = {\n connectedDevice: TransportConnectedDevice;\n id?: DeviceSessionId;\n};\n\nexport type DeviceSessionRefresherOptions = {\n isRefresherDisabled: boolean;\n pollingInterval?: number;\n};\n\ntype SendApduOptions = {\n isPolling?: boolean;\n triggersDisconnection?: boolean;\n abortTimeout?: number;\n};\n\n/**\n * Represents a session with a device.\n */\nexport class DeviceSession {\n private readonly _id: DeviceSessionId;\n private readonly _connectedDevice: TransportConnectedDevice;\n private readonly _deviceState: BehaviorSubject<DeviceSessionState>;\n private readonly _managerApiService: ManagerApiService;\n private readonly _secureChannelService: SecureChannelService;\n private readonly _logger: LoggerPublisherService;\n private readonly _refresherOptions: DeviceSessionRefresherOptions;\n private _pinger: DevicePinger;\n private _deviceSessionRefresher: DeviceSessionRefresher;\n private readonly _refresherService: RefresherService;\n private _commandMutex = new MutexService();\n private _sessionEventDispatcher = new DeviceSessionEventDispatcher();\n\n constructor(\n { connectedDevice, id = uuidv4() }: SessionConstructorArgs,\n loggerModuleFactory: (tag: string) => LoggerPublisherService,\n managerApiService: ManagerApiService,\n secureChannelService: SecureChannelService,\n deviceSessionRefresherOptions: DeviceSessionRefresherOptions | undefined,\n ) {\n this._id = id;\n this._connectedDevice = connectedDevice;\n this._logger = loggerModuleFactory(\"device-session\");\n this._managerApiService = managerApiService;\n this._secureChannelService = secureChannelService;\n this._refresherOptions = {\n ...DEVICE_SESSION_REFRESHER_DEFAULT_OPTIONS,\n ...deviceSessionRefresherOptions,\n };\n this._deviceState = new BehaviorSubject<DeviceSessionState>({\n sessionStateType: DeviceSessionStateType.Connected,\n deviceStatus: DeviceStatus.CONNECTED,\n deviceModelId: this._connectedDevice.deviceModel.id,\n });\n\n this._pinger = new DevicePinger(\n loggerModuleFactory,\n connectedDevice,\n this._sessionEventDispatcher,\n (command, abortTimeout) => this.sendCommand(command, abortTimeout),\n );\n this._deviceSessionRefresher = new DeviceSessionRefresher(\n loggerModuleFactory,\n this._refresherOptions,\n this._sessionEventDispatcher,\n this._connectedDevice,\n );\n new DeviceSessionStateHandler(\n loggerModuleFactory,\n this._sessionEventDispatcher,\n this._connectedDevice,\n this._deviceState,\n (state) => this.setDeviceSessionState(state),\n );\n\n this._refresherService = new RefresherService(loggerModuleFactory, {\n start: () => this._deviceSessionRefresher.restartRefresher(),\n stop: () => this._deviceSessionRefresher.stopRefresher(),\n });\n }\n\n public async initialiseSession(): Promise<void> {\n try {\n await this._pinger.ping();\n } catch (error) {\n this._logger.error(\"Error while initialising session\", {\n data: { error },\n });\n throw error;\n } finally {\n if (!this._refresherOptions.isRefresherDisabled) {\n this._deviceSessionRefresher.startRefresher();\n }\n }\n }\n\n public get id(): DeviceSessionId {\n return this._id;\n }\n\n public get connectedDevice(): TransportConnectedDevice {\n return this._connectedDevice;\n }\n\n public get state(): Observable<DeviceSessionState> {\n return this._deviceState.asObservable();\n }\n\n public getDeviceSessionState(): DeviceSessionState {\n return this._deviceState.getValue();\n }\n\n public setDeviceSessionState(state: DeviceSessionState): void {\n this._deviceState.next(state);\n }\n\n public async sendApdu(\n rawApdu: Uint8Array,\n options: SendApduOptions = {\n isPolling: false,\n triggersDisconnection: false,\n abortTimeout: undefined,\n },\n ): Promise<Either<DmkError, ApduResponse>> {\n const release = await this._commandMutex.lock();\n\n try {\n this._sessionEventDispatcher.dispatch({\n eventName: SessionEvents.DEVICE_STATE_UPDATE_BUSY,\n });\n\n this._logger.debug(formatApduSendingLog(rawApdu));\n const result = await this._connectedDevice.sendApdu(\n rawApdu,\n options.triggersDisconnection,\n options.abortTimeout,\n );\n\n result\n .ifRight((response: ApduResponse) => {\n if (CommandUtils.isLockedDeviceResponse(response)) {\n this._sessionEventDispatcher.dispatch({\n eventName: SessionEvents.DEVICE_STATE_UPDATE_LOCKED,\n });\n } else {\n this._sessionEventDispatcher.dispatch({\n eventName: SessionEvents.DEVICE_STATE_UPDATE_CONNECTED,\n });\n }\n })\n .ifLeft(() => {\n this._sessionEventDispatcher.dispatch({\n eventName: SessionEvents.DEVICE_STATE_UPDATE_CONNECTED,\n });\n });\n return result;\n } finally {\n release();\n }\n }\n\n public async sendCommand<Response, Args, ErrorStatusCodes>(\n command: Command<Response, Args, ErrorStatusCodes>,\n abortTimeout?: number,\n ): Promise<CommandResult<Response, ErrorStatusCodes>> {\n this._logger.debug(`[sendCommand] ${command.name}`);\n const apdu = command.getApdu();\n\n const response = await this.sendApdu(apdu.getRawApdu(), {\n isPolling: false,\n triggersDisconnection: command.triggersDisconnection ?? false,\n abortTimeout,\n });\n\n return response.caseOf({\n Left: (err) => {\n this._logger.error(\"[sendCommand] error\", { data: { err } });\n throw err;\n },\n Right: (r) => {\n const result = command.parseResponse(\n r,\n this._connectedDevice.deviceModel.id,\n );\n this._logger.debug(\"[sendCommand] result\", { data: { result } });\n return result;\n },\n });\n }\n\n public executeDeviceAction<\n Output,\n Input,\n E extends DmkError,\n IntermediateValue extends DeviceActionIntermediateValue,\n >(\n deviceAction: DeviceAction<Output, Input, E, IntermediateValue>,\n ): ExecuteDeviceActionReturnType<Output, E, IntermediateValue> {\n const { observable, cancel } = deviceAction._execute({\n sendApdu: async (apdu: Uint8Array) => this.sendApdu(apdu),\n sendCommand: async <Response, ErrorStatusCodes, Args>(\n command: Command<Response, ErrorStatusCodes, Args>,\n abortTimeout?: number,\n ) => this.sendCommand(command, abortTimeout),\n getDeviceModel: () => this._connectedDevice.deviceModel,\n getDeviceSessionState: () => this._deviceState.getValue(),\n getDeviceSessionStateObservable: () => this.state,\n setDeviceSessionState: (state: DeviceSessionState) => {\n this.setDeviceSessionState(state);\n return this._deviceState.getValue();\n },\n disableRefresher: (blockerId: string) =>\n this._refresherService.disableRefresher(blockerId),\n getManagerApiService: () => this._managerApiService,\n getSecureChannelService: () => this._secureChannelService,\n });\n return { observable, cancel };\n }\n\n public close(): void {\n this._updateDeviceStatus(DeviceStatus.NOT_CONNECTED);\n this._deviceState.complete();\n this._deviceSessionRefresher.stopRefresher();\n this._pinger.unsubscribe();\n }\n\n public disableRefresher(id: string): () => void {\n return this._refresherService.disableRefresher(id);\n }\n\n private _updateDeviceStatus(deviceStatus: DeviceStatus): void {\n const state = this._deviceState.getValue();\n this._deviceState.next({ ...state, deviceStatus });\n }\n}\n"],
|
|
5
|
+
"mappings": "yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,mBAAAE,IAAA,eAAAC,EAAAH,GACA,IAAAI,EAAiD,gBACjDC,EAA6B,gBAI7BC,EAA6B,2CAC7BC,EAA6B,oCAO7BC,EAGO,kDAKPC,EAAqC,+BACrCC,EAAyD,qEACzDC,EAA6B,yDAC7BC,EAAiC,6DAIjCC,EAA6B,0BAC7BC,EAGO,0CACPC,EAAuC,oCACvCC,EAA0C,uCAqBnC,MAAMd,CAAc,CACR,IACA,iBACA,aACA,mBACA,sBACA,QACA,kBACT,QACA,wBACS,kBACT,cAAgB,IAAI,eACpB,wBAA0B,IAAI,+BAEtC,YACE,CAAE,gBAAAe,EAAiB,GAAAC,KAAK,EAAAC,IAAO,CAAE,EACjCC,EACAC,EACAC,EACAC,EACA,CACA,KAAK,IAAML,EACX,KAAK,iBAAmBD,EACxB,KAAK,QAAUG,EAAoB,gBAAgB,EACnD,KAAK,mBAAqBC,EAC1B,KAAK,sBAAwBC,EAC7B,KAAK,kBAAoB,CACvB,GAAG,2CACH,GAAGC,CACL,EACA,KAAK,aAAe,IAAI,kBAAoC,CAC1D,iBAAkB,yBAAuB,UACzC,aAAc,eAAa,UAC3B,cAAe,KAAK,iBAAiB,YAA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iBAAmBY,GACjB,KAAK,kBAAkB,iBAAiBA,CAAS,EACnD,qBAAsB,IAAM,KAAK,mBACjC,wBAAyB,IAAM,KAAK,qBACtC,CAAC,EACD,MAAO,CAAE,WAAAF,EAAY,OAAAC,CAAO,CAC9B,CAEO,OAAc,CACnB,KAAK,oBAAoB,eAAa,aAAa,EACnD,KAAK,aAAa,SAAS,EAC3B,KAAK,wBAAwB,cAAc,EAC3C,KAAK,QAAQ,YAAY,CAC3B,CAEO,iBAAiBnB,EAAwB,CAC9C,OAAO,KAAK,kBAAkB,iBAAiBA,CAAE,CACnD,CAEQ,oBAAoBqB,EAAkC,CAC5D,MAAMb,EAAQ,KAAK,aAAa,SAAS,EACzC,KAAK,aAAa,KAAK,CAAE,GAAGA,EAAO,aAAAa,CAAa,CAAC,CACnD,CACF",
|
|
6
|
+
"names": ["DeviceSession_exports", "__export", "DeviceSession", "__toCommonJS", "import_rxjs", "import_uuid", "import_CommandUtils", "import_DeviceStatus", "import_DeviceSessionState", "import_apduLogs", "import_DeviceSessionRefresherConst", "import_MutexService", "import_RefresherService", "import_DevicePinger", "import_DeviceSessionEventDispatcher", "import_DeviceSessionRefresher", "import_DeviceSessionStateHandler", "connectedDevice", "id", "uuidv4", "loggerModuleFactory", "managerApiService", "secureChannelService", "deviceSessionRefresherOptions", "command", "abortTimeout", "state", "error", "rawApdu", "options", "release", "result", "response", "apdu", "err", "deviceAction", "observable", "cancel", "blockerId", "deviceStatus"]
|
|
7
7
|
}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use strict";var o=require("../../../api/index"),n=require("../../device-session/data/DeviceSessionRefresherConst"),r=require("../../logger-publisher/service/DefaultLoggerPublisherService"),i=require("../../manager-api/data/AxiosManagerApiDataSource"),s=require("../../manager-api/service/DefaultManagerApiService"),c=require("../../secure-channel/data/DefaultSecureChannelDataSource"),t=require("../../secure-channel/service/DefaultSecureChannelService"),a=require("./DeviceSession");describe("DeviceSession",()=>{it("should unsubscribe pinger from event subscriber when session is closed",()=>{const m=new r.DefaultLoggerPublisherService([],"DeviceSession"),u=new i.AxiosManagerApiDataSource({}),p=new s.DefaultManagerApiService(u),S=new c.DefaultSecureChannelDataSource({}),f=new t.DefaultSecureChannelService(S),D=n.DEVICE_SESSION_REFRESHER_DEFAULT_OPTIONS,e=new a.DeviceSession({connectedDevice:(0,o.connectedDeviceStubBuilder)()},()=>m,p,f,D),l=vi.spyOn(e._pinger,"unsubscribe").mockImplementation(()=>{});e.close(),expect(l).toHaveBeenCalled()})});
|
|
2
|
+
//# sourceMappingURL=DeviceSession.test.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../../../src/internal/device-session/model/DeviceSession.test.ts"],
|
|
4
|
+
"sourcesContent": ["import { type DmkConfig } from \"@api/DmkConfig\";\nimport { connectedDeviceStubBuilder } from \"@api/index\";\nimport { DEVICE_SESSION_REFRESHER_DEFAULT_OPTIONS } from \"@internal/device-session/data/DeviceSessionRefresherConst\";\nimport { DefaultLoggerPublisherService } from \"@internal/logger-publisher/service/DefaultLoggerPublisherService\";\nimport { AxiosManagerApiDataSource } from \"@internal/manager-api/data/AxiosManagerApiDataSource\";\nimport { DefaultManagerApiService } from \"@internal/manager-api/service/DefaultManagerApiService\";\nimport { DefaultSecureChannelDataSource } from \"@internal/secure-channel/data/DefaultSecureChannelDataSource\";\nimport { DefaultSecureChannelService } from \"@internal/secure-channel/service/DefaultSecureChannelService\";\n\nimport { DeviceSession } from \"./DeviceSession\";\n\ndescribe(\"DeviceSession\", () => {\n it(\"should unsubscribe pinger from event subscriber when session is closed\", () => {\n // ARRANGE\n const logger = new DefaultLoggerPublisherService([], \"DeviceSession\");\n const managerApiDataSource = new AxiosManagerApiDataSource({} as DmkConfig);\n const managerApi = new DefaultManagerApiService(managerApiDataSource);\n const secureChannelDataSource = new DefaultSecureChannelDataSource(\n {} as DmkConfig,\n );\n const secureChannel = new DefaultSecureChannelService(\n secureChannelDataSource,\n );\n const deviceSessionRefresherOptions =\n DEVICE_SESSION_REFRESHER_DEFAULT_OPTIONS;\n const deviceSession = new DeviceSession(\n { connectedDevice: connectedDeviceStubBuilder() },\n () => logger,\n managerApi,\n secureChannel,\n deviceSessionRefresherOptions,\n );\n const unsubscribe = vi\n .spyOn(deviceSession[\"_pinger\"], \"unsubscribe\")\n .mockImplementation(() => {});\n\n // ACT\n deviceSession.close();\n\n // ASSERT\n expect(unsubscribe).toHaveBeenCalled();\n });\n});\n"],
|
|
5
|
+
"mappings": "aACA,IAAAA,EAA2C,sBAC3CC,EAAyD,qEACzDC,EAA8C,4EAC9CC,EAA0C,gEAC1CC,EAAyC,kEACzCC,EAA+C,wEAC/CC,EAA4C,wEAE5CC,EAA8B,2BAE9B,SAAS,gBAAiB,IAAM,CAC9B,GAAG,yEAA0E,IAAM,CAEjF,MAAMC,EAAS,IAAI,gCAA8B,CAAC,EAAG,eAAe,EAC9DC,EAAuB,IAAI,4BAA0B,CAAC,CAAc,EACpEC,EAAa,IAAI,2BAAyBD,CAAoB,EAC9DE,EAA0B,IAAI,iCAClC,CAAC,CACH,EACMC,EAAgB,IAAI,8BACxBD,CACF,EACME,EACJ,2CACIC,EAAgB,IAAI,gBACxB,CAAE,mBAAiB,8BAA2B,CAAE,EAChD,IAAMN,EACNE,EACAE,EACAC,CACF,EACME,EAAc,GACjB,MAAMD,EAAc,QAAY,aAAa,EAC7C,mBAAmB,IAAM,CAAC,CAAC,EAG9BA,EAAc,MAAM,EAGpB,OAAOC,CAAW,EAAE,iBAAiB,CACvC,CAAC,CACH,CAAC",
|
|
6
|
+
"names": ["import_api", "import_DeviceSessionRefresherConst", "import_DefaultLoggerPublisherService", "import_AxiosManagerApiDataSource", "import_DefaultManagerApiService", "import_DefaultSecureChannelDataSource", "import_DefaultSecureChannelService", "import_DeviceSession", "logger", "managerApiDataSource", "managerApi", "secureChannelDataSource", "secureChannel", "deviceSessionRefresherOptions", "deviceSession", "unsubscribe"]
|
|
7
|
+
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";var p=Object.defineProperty;var S=Object.getOwnPropertyDescriptor;var _=Object.getOwnPropertyNames;var A=Object.prototype.hasOwnProperty;var C=(n,e)=>{for(var s in e)p(n,s,{get:e[s],enumerable:!0})},T=(n,e,s,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of _(e))!A.call(n,i)&&i!==s&&p(n,i,{get:()=>e[i],enumerable:!(r=S(e,i))||r.enumerable});return n};var I=n=>T(p({},"__esModule",{value:!0}),n),g=(n,e,s,r)=>{for(var i=r>1?void 0:r?S(e,s):e,o=n.length-1,t;o>=0;o--)(t=n[o])&&(i=(r?t(e,s,i):t(i))||i);return r&&i&&p(e,s,i),i},a=(n,e)=>(s,r)=>e(s,r,n);var E={};C(E,{ConnectUseCase:()=>v});module.exports=I(E);var c=require("inversify"),m=require("purify-ts"),h=require("../../../api/transport/model/Errors"),
|
|
1
|
+
"use strict";var p=Object.defineProperty;var S=Object.getOwnPropertyDescriptor;var _=Object.getOwnPropertyNames;var A=Object.prototype.hasOwnProperty;var C=(n,e)=>{for(var s in e)p(n,s,{get:e[s],enumerable:!0})},T=(n,e,s,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of _(e))!A.call(n,i)&&i!==s&&p(n,i,{get:()=>e[i],enumerable:!(r=S(e,i))||r.enumerable});return n};var I=n=>T(p({},"__esModule",{value:!0}),n),g=(n,e,s,r)=>{for(var i=r>1?void 0:r?S(e,s):e,o=n.length-1,t;o>=0;o--)(t=n[o])&&(i=(r?t(e,s,i):t(i))||i);return r&&i&&p(e,s,i),i},a=(n,e)=>(s,r)=>e(s,r,n);var E={};C(E,{ConnectUseCase:()=>v});module.exports=I(E);var c=require("inversify"),m=require("purify-ts"),h=require("../../../api/transport/model/Errors"),l=require("../../device-session/di/deviceSessionTypes"),d=require("../../device-session/model/DeviceSession"),f=require("../../logger-publisher/di/loggerTypes"),D=require("../../manager-api/di/managerApiTypes"),y=require("../../secure-channel/di/secureChannelTypes"),u=require("../../transport/di/transportDiTypes");let v=class{_transportService;_sessionService;_loggerFactory;_managerApi;_secureChannel;_logger;constructor(e,s,r,i,o){this._sessionService=s,this._transportService=e,this._loggerFactory=r,this._logger=r("ConnectUseCase"),this._managerApi=i,this._secureChannel=o}handleDeviceDisconnect(e){this._sessionService.getDeviceSessionsByDeviceId(e).ifRight(s=>{s.forEach(r=>{this._sessionService.removeDeviceSession(r.id),this._logger.info("Session removed",{data:{deviceId:e,sessionId:r.id}})})})}async execute({device:e,sessionRefresherOptions:s}){const r=this._transportService.getTransport(e.transport),i="sessionId"in e?e.sessionId:void 0;return m.EitherAsync.liftEither(r.toEither(new h.TransportNotSupportedError(new Error("Unknown transport")))).chain(async o=>o.connect({deviceId:e.id,onDisconnect:t=>this.handleDeviceDisconnect(t)})).ifLeft(o=>{this._logger.error("Error connecting to device")}).map(async o=>{const t=new d.DeviceSession({connectedDevice:o,id:i},this._loggerFactory,this._managerApi,this._secureChannel,s);return this._sessionService.addDeviceSession(t),await t.initialiseSession(),t.id}).caseOf({Left:o=>{throw o},Right:o=>o})}};v=g([(0,c.injectable)(),a(0,(0,c.inject)(u.transportDiTypes.TransportService)),a(1,(0,c.inject)(l.deviceSessionTypes.DeviceSessionService)),a(2,(0,c.inject)(f.loggerTypes.LoggerPublisherServiceFactory)),a(3,(0,c.inject)(D.managerApiTypes.ManagerApiService)),a(4,(0,c.inject)(y.secureChannelTypes.SecureChannelService))],v);0&&(module.exports={ConnectUseCase});
|
|
2
2
|
//# sourceMappingURL=ConnectUseCase.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../../src/internal/discovery/use-case/ConnectUseCase.ts"],
|
|
4
|
-
"sourcesContent": ["import { inject, injectable } from \"inversify\";\nimport { EitherAsync } from \"purify-ts\";\n\nimport { DeviceSessionId } from \"@api/device-session/types\";\nimport { LoggerPublisherService } from \"@api/logger-publisher/service/LoggerPublisherService\";\nimport { ConnectedDevice } from \"@api/transport/model/ConnectedDevice\";\nimport { DiscoveredDevice } from \"@api/transport/model/DiscoveredDevice\";\nimport { TransportNotSupportedError } from \"@api/transport/model/Errors\";\nimport { DeviceId } from \"@api/types\";\nimport { deviceSessionTypes } from \"@internal/device-session/di/deviceSessionTypes\";\nimport {\n DeviceSession,\n DeviceSessionRefresherOptions,\n} from \"@internal/device-session/model/DeviceSession\";\nimport type { DeviceSessionService } from \"@internal/device-session/service/DeviceSessionService\";\nimport { loggerTypes } from \"@internal/logger-publisher/di/loggerTypes\";\nimport { managerApiTypes } from \"@internal/manager-api/di/managerApiTypes\";\nimport type { ManagerApiService } from \"@internal/manager-api/service/ManagerApiService\";\nimport { secureChannelTypes } from \"@internal/secure-channel/di/secureChannelTypes\";\nimport type { SecureChannelService } from \"@internal/secure-channel/service/SecureChannelService\";\nimport { transportDiTypes } from \"@internal/transport/di/transportDiTypes\";\nimport { type TransportService } from \"@internal/transport/service/TransportService\";\n\n/**\n * The arguments for the ConnectUseCase.\n */\nexport type ConnectUseCaseArgs = {\n /**\n * Discovered device or connected device.\n */\n device: DiscoveredDevice | ConnectedDevice;\n\n /**\n * sessionRefresherOptions - optional\n * isRefresherDisabled - whether the refresher is disabled\n * pollingInterval - optional - the refresh interval in milliseconds\n */\n sessionRefresherOptions?: DeviceSessionRefresherOptions;\n};\n\n/**\n * Connects to a discovered device.\n */\n@injectable()\nexport class ConnectUseCase {\n private readonly _transportService: TransportService;\n private readonly _sessionService: DeviceSessionService;\n private readonly _loggerFactory: (tag: string) => LoggerPublisherService;\n private readonly _managerApi: ManagerApiService;\n private readonly _secureChannel: SecureChannelService;\n private readonly _logger: LoggerPublisherService;\n\n constructor(\n @inject(transportDiTypes.TransportService)\n transportService: TransportService,\n @inject(deviceSessionTypes.DeviceSessionService)\n sessionService: DeviceSessionService,\n @inject(loggerTypes.LoggerPublisherServiceFactory)\n loggerFactory: (tag: string) => LoggerPublisherService,\n @inject(managerApiTypes.ManagerApiService)\n managerApi: ManagerApiService,\n @inject(secureChannelTypes.SecureChannelService)\n secureChannel: SecureChannelService,\n ) {\n this._sessionService = sessionService;\n this._transportService = transportService;\n this._loggerFactory = loggerFactory;\n this._logger = loggerFactory(\"ConnectUseCase\");\n this._managerApi = managerApi;\n this._secureChannel = secureChannel;\n }\n\n private handleDeviceDisconnect(deviceId: DeviceId) {\n this._sessionService\n .getDeviceSessionsByDeviceId(deviceId)\n .ifRight((deviceSessions) => {\n deviceSessions.forEach((deviceSession) => {\n this._sessionService.removeDeviceSession(deviceSession.id);\n this._logger.info(\"Session removed\", {\n data: { deviceId, sessionId: deviceSession.id },\n });\n });\n });\n }\n\n async execute({\n device,\n sessionRefresherOptions,\n }: ConnectUseCaseArgs): Promise<DeviceSessionId> {\n const transport = this._transportService.getTransport(device.transport);\n // In case of a connected device, we reconnect using the same session id.\n // If not provided, a new device session id will be generated.\n const deviceSessionId =\n \"sessionId\" in device ? device.sessionId : undefined;\n\n return EitherAsync.liftEither(\n transport.toEither(\n new TransportNotSupportedError(new Error(\"Unknown transport\")),\n ),\n )\n .chain(async (t) => {\n return t.connect({\n deviceId: device.id,\n onDisconnect: (dId) => this.handleDeviceDisconnect(dId),\n });\n })\n .ifLeft((
|
|
5
|
-
"mappings": "okBAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,oBAAAE,IAAA,eAAAC,EAAAH,GAAA,IAAAI,EAAmC,qBACnCC,EAA4B,qBAM5BC,EAA2C,uCAE3CC,EAAmC,0DACnCC,EAGO,wDAEPC,EAA4B,qDAC5BC,EAAgC,oDAEhCC,EAAmC,0DAEnCC,EAAiC,mDAwB1B,IAAMC,EAAN,KAAqB,CACT,kBACA,gBACA,eACA,YACA,eACA,QAEjB,YAEEC,EAEAC,EAEAC,EAEAC,EAEAC,EACA,CACA,KAAK,gBAAkBH,EACvB,KAAK,kBAAoBD,EACzB,KAAK,eAAiBE,EACtB,KAAK,QAAUA,EAAc,gBAAgB,EAC7C,KAAK,YAAcC,EACnB,KAAK,eAAiBC,CACxB,CAEQ,uBAAuBC,EAAoB,CACjD,KAAK,gBACF,4BAA4BA,CAAQ,EACpC,QAASC,GAAmB,CAC3BA,EAAe,QAASC,GAAkB,CACxC,KAAK,gBAAgB,oBAAoBA,EAAc,EAAE,EACzD,KAAK,QAAQ,KAAK,kBAAmB,CACnC,KAAM,CAAE,SAAAF,EAAU,UAAWE,EAAc,EAAG,CAChD,CAAC,CACH,CAAC,CACH,CAAC,CACL,CAEA,MAAM,QAAQ,CACZ,OAAAC,EACA,wBAAAC,CACF,EAAiD,CAC/C,MAAMC,EAAY,KAAK,kBAAkB,aAAaF,EAAO,SAAS,EAGhEG,EACJ,cAAeH,EAASA,EAAO,UAAY,OAE7C,OAAO,cAAY,WACjBE,EAAU,SACR,IAAI,6BAA2B,IAAI,MAAM,mBAAmB,CAAC,CAC/D,CACF,EACG,MAAM,MAAOE,GACLA,EAAE,QAAQ,CACf,SAAUJ,EAAO,GACjB,aAAeK,GAAQ,KAAK,uBAAuBA,CAAG,CACxD,CAAC,CACF,EACA,OAAQC,
|
|
6
|
-
"names": ["ConnectUseCase_exports", "__export", "ConnectUseCase", "__toCommonJS", "import_inversify", "import_purify_ts", "import_Errors", "import_deviceSessionTypes", "import_DeviceSession", "import_loggerTypes", "import_managerApiTypes", "import_secureChannelTypes", "import_transportDiTypes", "ConnectUseCase", "transportService", "sessionService", "loggerFactory", "managerApi", "secureChannel", "deviceId", "deviceSessions", "deviceSession", "device", "sessionRefresherOptions", "transport", "deviceSessionId", "t", "dId", "
|
|
4
|
+
"sourcesContent": ["import { inject, injectable } from \"inversify\";\nimport { EitherAsync } from \"purify-ts\";\n\nimport { DeviceSessionId } from \"@api/device-session/types\";\nimport { LoggerPublisherService } from \"@api/logger-publisher/service/LoggerPublisherService\";\nimport { ConnectedDevice } from \"@api/transport/model/ConnectedDevice\";\nimport { DiscoveredDevice } from \"@api/transport/model/DiscoveredDevice\";\nimport { TransportNotSupportedError } from \"@api/transport/model/Errors\";\nimport { DeviceId } from \"@api/types\";\nimport { deviceSessionTypes } from \"@internal/device-session/di/deviceSessionTypes\";\nimport {\n DeviceSession,\n DeviceSessionRefresherOptions,\n} from \"@internal/device-session/model/DeviceSession\";\nimport type { DeviceSessionService } from \"@internal/device-session/service/DeviceSessionService\";\nimport { loggerTypes } from \"@internal/logger-publisher/di/loggerTypes\";\nimport { managerApiTypes } from \"@internal/manager-api/di/managerApiTypes\";\nimport type { ManagerApiService } from \"@internal/manager-api/service/ManagerApiService\";\nimport { secureChannelTypes } from \"@internal/secure-channel/di/secureChannelTypes\";\nimport type { SecureChannelService } from \"@internal/secure-channel/service/SecureChannelService\";\nimport { transportDiTypes } from \"@internal/transport/di/transportDiTypes\";\nimport { type TransportService } from \"@internal/transport/service/TransportService\";\n\n/**\n * The arguments for the ConnectUseCase.\n */\nexport type ConnectUseCaseArgs = {\n /**\n * Discovered device or connected device.\n */\n device: DiscoveredDevice | ConnectedDevice;\n\n /**\n * sessionRefresherOptions - optional\n * isRefresherDisabled - whether the refresher is disabled\n * pollingInterval - optional - the refresh interval in milliseconds\n */\n sessionRefresherOptions?: DeviceSessionRefresherOptions;\n};\n\n/**\n * Connects to a discovered device.\n */\n@injectable()\nexport class ConnectUseCase {\n private readonly _transportService: TransportService;\n private readonly _sessionService: DeviceSessionService;\n private readonly _loggerFactory: (tag: string) => LoggerPublisherService;\n private readonly _managerApi: ManagerApiService;\n private readonly _secureChannel: SecureChannelService;\n private readonly _logger: LoggerPublisherService;\n\n constructor(\n @inject(transportDiTypes.TransportService)\n transportService: TransportService,\n @inject(deviceSessionTypes.DeviceSessionService)\n sessionService: DeviceSessionService,\n @inject(loggerTypes.LoggerPublisherServiceFactory)\n loggerFactory: (tag: string) => LoggerPublisherService,\n @inject(managerApiTypes.ManagerApiService)\n managerApi: ManagerApiService,\n @inject(secureChannelTypes.SecureChannelService)\n secureChannel: SecureChannelService,\n ) {\n this._sessionService = sessionService;\n this._transportService = transportService;\n this._loggerFactory = loggerFactory;\n this._logger = loggerFactory(\"ConnectUseCase\");\n this._managerApi = managerApi;\n this._secureChannel = secureChannel;\n }\n\n private handleDeviceDisconnect(deviceId: DeviceId) {\n this._sessionService\n .getDeviceSessionsByDeviceId(deviceId)\n .ifRight((deviceSessions) => {\n deviceSessions.forEach((deviceSession) => {\n this._sessionService.removeDeviceSession(deviceSession.id);\n this._logger.info(\"Session removed\", {\n data: { deviceId, sessionId: deviceSession.id },\n });\n });\n });\n }\n\n async execute({\n device,\n sessionRefresherOptions,\n }: ConnectUseCaseArgs): Promise<DeviceSessionId> {\n const transport = this._transportService.getTransport(device.transport);\n // In case of a connected device, we reconnect using the same session id.\n // If not provided, a new device session id will be generated.\n const deviceSessionId =\n \"sessionId\" in device ? device.sessionId : undefined;\n\n return EitherAsync.liftEither(\n transport.toEither(\n new TransportNotSupportedError(new Error(\"Unknown transport\")),\n ),\n )\n .chain(async (t) => {\n return t.connect({\n deviceId: device.id,\n onDisconnect: (dId) => this.handleDeviceDisconnect(dId),\n });\n })\n .ifLeft((_) => {\n this._logger.error(\"Error connecting to device\");\n })\n .map(async (connectedDevice) => {\n const deviceSession = new DeviceSession(\n { connectedDevice, id: deviceSessionId },\n this._loggerFactory,\n this._managerApi,\n this._secureChannel,\n sessionRefresherOptions,\n );\n this._sessionService.addDeviceSession(deviceSession);\n await deviceSession.initialiseSession();\n return deviceSession.id;\n })\n .caseOf({\n Left: (error) => {\n throw error;\n },\n Right: (s) => s,\n });\n }\n}\n"],
|
|
5
|
+
"mappings": "okBAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,oBAAAE,IAAA,eAAAC,EAAAH,GAAA,IAAAI,EAAmC,qBACnCC,EAA4B,qBAM5BC,EAA2C,uCAE3CC,EAAmC,0DACnCC,EAGO,wDAEPC,EAA4B,qDAC5BC,EAAgC,oDAEhCC,EAAmC,0DAEnCC,EAAiC,mDAwB1B,IAAMC,EAAN,KAAqB,CACT,kBACA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ANmB,EAAA,IADN,cAAW,EAUPC,EAAA,eAAO,mBAAiB,gBAAgB,GAExCA,EAAA,eAAO,qBAAmB,oBAAoB,GAE9CA,EAAA,eAAO,cAAY,6BAA6B,GAEhDA,EAAA,eAAO,kBAAgB,iBAAiB,GAExCA,EAAA,eAAO,qBAAmB,oBAAoB,IAjBtCpB",
|
|
6
|
+
"names": ["ConnectUseCase_exports", "__export", "ConnectUseCase", "__toCommonJS", "import_inversify", "import_purify_ts", "import_Errors", "import_deviceSessionTypes", "import_DeviceSession", "import_loggerTypes", "import_managerApiTypes", "import_secureChannelTypes", "import_transportDiTypes", "ConnectUseCase", "transportService", "sessionService", "loggerFactory", "managerApi", "secureChannel", "deviceId", "deviceSessions", "deviceSession", "device", "sessionRefresherOptions", "transport", "deviceSessionId", "t", "dId", "_", "connectedDevice", "error", "s", "__decorateClass", "__decorateParam"]
|
|
7
7
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";var n=Object.defineProperty;var
|
|
1
|
+
"use strict";var n=Object.defineProperty;var b=Object.getOwnPropertyDescriptor;var d=Object.getOwnPropertyNames;var f=Object.prototype.hasOwnProperty;var v=(s,r)=>{for(var t in r)n(s,t,{get:r[t],enumerable:!0})},O=(s,r,t,i)=>{if(r&&typeof r=="object"||typeof r=="function")for(let o of d(r))!f.call(s,o)&&o!==t&&n(s,o,{get:()=>r[o],enumerable:!(i=b(r,o))||i.enumerable});return s};var T=s=>O(n({},"__esModule",{value:!0}),s),p=(s,r,t,i)=>{for(var o=i>1?void 0:i?b(r,t):r,g=s.length-1,e;g>=0;g--)(e=s[g])&&(o=(i?e(r,t,o):e(o))||o);return i&&o&&n(r,t,o),o};var F={};v(F,{DefaultLoggerPublisherService:()=>m});module.exports=T(F);var L=require("inversify"),a=require("../../../api/logger-subscriber/model/LogLevel"),c=require("../../../api/logger-subscriber/service/DefaultLogTagFormatter"),h=require("../../logger-publisher/service/sanitiseData");let m=class{subscribers;tag;tagFormatter;constructor(r,t,i=new c.DefaultLogTagFormatter){this.subscribers=r,this.tag=t,this.tagFormatter=i}_log(r,t,i){const o=i?.data?(0,h.sanitiseData)(i.data):void 0,g=i?.tag??this.tag,e=this.tagFormatter.format(g);this.subscribers.forEach(u=>{const l={timestamp:i?.timestamp??Date.now(),tag:e,data:o};u.log(r,t,l)})}info(r,t){this._log(a.LogLevel.Info,r,t)}warn(r,t){this._log(a.LogLevel.Warning,r,t)}debug(r,t){this._log(a.LogLevel.Debug,r,t)}error(r,t){this._log(a.LogLevel.Error,r,t)}};m=p([(0,L.injectable)()],m);0&&(module.exports={DefaultLoggerPublisherService});
|
|
2
2
|
//# sourceMappingURL=DefaultLoggerPublisherService.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../../src/internal/logger-publisher/service/DefaultLoggerPublisherService.ts"],
|
|
4
|
-
"sourcesContent": ["import { injectable } from \"inversify\";\n\nimport { LoggerPublisherService } from \"@api/logger-publisher/service/LoggerPublisherService\";\nimport { LogLevel } from \"@api/logger-subscriber/model/LogLevel\";\nimport { LogSubscriberOptions } from \"@api/logger-subscriber/model/LogSubscriberOptions\";\nimport { LoggerSubscriberService } from \"@api/logger-subscriber/service/LoggerSubscriberService\";\nimport { LogPublisherOptions } from \"@internal/logger-publisher/model/LogPublisherOptions\";\n\n@injectable()\nexport class DefaultLoggerPublisherService implements LoggerPublisherService {\n subscribers: LoggerSubscriberService[];\n tag:
|
|
5
|
-
"mappings": "2iBAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,mCAAAE,IAAA,eAAAC,EAAAH,GAAA,IAAAI,EAA2B,qBAG3BC,EAAyB,
|
|
6
|
-
"names": ["DefaultLoggerPublisherService_exports", "__export", "DefaultLoggerPublisherService", "__toCommonJS", "import_inversify", "import_LogLevel", "DefaultLoggerPublisherService", "subscribers", "tag", "level", "message", "options", "subscriber", "subscriberOptions", "__decorateClass"]
|
|
4
|
+
"sourcesContent": ["import { injectable } from \"inversify\";\n\nimport { LoggerPublisherService } from \"@api/logger-publisher/service/LoggerPublisherService\";\nimport { LogLevel } from \"@api/logger-subscriber/model/LogLevel\";\nimport {\n type LogSubscriberOptions,\n type LogTag,\n} from \"@api/logger-subscriber/model/LogSubscriberOptions\";\nimport { DefaultLogTagFormatter } from \"@api/logger-subscriber/service/DefaultLogTagFormatter\";\nimport { LoggerSubscriberService } from \"@api/logger-subscriber/service/LoggerSubscriberService\";\nimport { type LogTagFormatter } from \"@api/logger-subscriber/service/LogTagFormatter\";\nimport { LogPublisherOptions } from \"@internal/logger-publisher/model/LogPublisherOptions\";\nimport { sanitiseData } from \"@internal/logger-publisher/service/sanitiseData\";\n\n@injectable()\nexport class DefaultLoggerPublisherService implements LoggerPublisherService {\n subscribers: LoggerSubscriberService[];\n tag: LogTag;\n private readonly tagFormatter: LogTagFormatter;\n\n constructor(\n subscribers: LoggerSubscriberService[],\n tag: LogTag,\n tagFormatter: LogTagFormatter = new DefaultLogTagFormatter(),\n ) {\n this.subscribers = subscribers;\n this.tag = tag;\n this.tagFormatter = tagFormatter;\n }\n\n _log(level: LogLevel, message: string, options?: LogPublisherOptions): void {\n const sanitisedData = options?.data\n ? sanitiseData(options.data)\n : undefined;\n\n // Format the tag from options if provided, otherwise use the instance tag\n const tagToFormat = options?.tag ?? this.tag;\n const formattedTag = this.tagFormatter.format(tagToFormat);\n\n this.subscribers.forEach((subscriber) => {\n const subscriberOptions: LogSubscriberOptions = {\n timestamp: options?.timestamp ?? Date.now(),\n tag: formattedTag,\n data: sanitisedData,\n };\n subscriber.log(level, message, subscriberOptions);\n });\n }\n\n info(message: string, options?: LogPublisherOptions): void {\n this._log(LogLevel.Info, message, options);\n }\n\n warn(message: string, options?: LogPublisherOptions): void {\n this._log(LogLevel.Warning, message, options);\n }\n\n debug(message: string, options?: LogPublisherOptions): void {\n this._log(LogLevel.Debug, message, options);\n }\n\n error(message: string, options?: LogPublisherOptions): void {\n this._log(LogLevel.Error, message, options);\n }\n}\n"],
|
|
5
|
+
"mappings": "2iBAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,mCAAAE,IAAA,eAAAC,EAAAH,GAAA,IAAAI,EAA2B,qBAG3BC,EAAyB,iDAKzBC,EAAuC,iEAIvCC,EAA6B,2DAGtB,IAAMC,EAAN,KAAsE,CAC3E,YACA,IACiB,aAEjB,YACEC,EACAC,EACAC,EAAgC,IAAI,yBACpC,CACA,KAAK,YAAcF,EACnB,KAAK,IAAMC,EACX,KAAK,aAAeC,CACtB,CAEA,KAAKC,EAAiBC,EAAiBC,EAAqC,CAC1E,MAAMC,EAAgBD,GAAS,QAC3B,gBAAaA,EAAQ,IAAI,EACzB,OAGEE,EAAcF,GAAS,KAAO,KAAK,IACnCG,EAAe,KAAK,aAAa,OAAOD,CAAW,EAEzD,KAAK,YAAY,QAASE,GAAe,CACvC,MAAMC,EAA0C,CAC9C,UAAWL,GAAS,WAAa,KAAK,IAAI,EAC1C,IAAKG,EACL,KAAMF,CACR,EACAG,EAAW,IAAIN,EAAOC,EAASM,CAAiB,CAClD,CAAC,CACH,CAEA,KAAKN,EAAiBC,EAAqC,CACzD,KAAK,KAAK,WAAS,KAAMD,EAASC,CAAO,CAC3C,CAEA,KAAKD,EAAiBC,EAAqC,CACzD,KAAK,KAAK,WAAS,QAASD,EAASC,CAAO,CAC9C,CAEA,MAAMD,EAAiBC,EAAqC,CAC1D,KAAK,KAAK,WAAS,MAAOD,EAASC,CAAO,CAC5C,CAEA,MAAMD,EAAiBC,EAAqC,CAC1D,KAAK,KAAK,WAAS,MAAOD,EAASC,CAAO,CAC5C,CACF,EAjDaN,EAANY,EAAA,IADN,cAAW,GACCZ",
|
|
6
|
+
"names": ["DefaultLoggerPublisherService_exports", "__export", "DefaultLoggerPublisherService", "__toCommonJS", "import_inversify", "import_LogLevel", "import_DefaultLogTagFormatter", "import_sanitiseData", "DefaultLoggerPublisherService", "subscribers", "tag", "tagFormatter", "level", "message", "options", "sanitisedData", "tagToFormat", "formattedTag", "subscriber", "subscriberOptions", "__decorateClass"]
|
|
7
7
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";var l=require("../../../api/logger-subscriber/model/LogLevel"),
|
|
1
|
+
"use strict";var l=require("../../../api/logger-subscriber/model/LogLevel"),r=require("../../../api/logger-subscriber/service/ConsoleLogger"),a=require("./DefaultLoggerPublisherService");vi.mock("@api/logger-subscriber/service/ConsoleLogger");vi.useFakeTimers().setSystemTime(new Date("2024-01-01"));let o,s;const e="message",c="logger-tag",g=`[${c}]`,t={data:{key:"value"}},n={tag:g,timestamp:Date.now(),...t};describe("LoggerPublisherService",()=>{beforeEach(()=>{vi.clearAllMocks(),s=new r.ConsoleLogger,o=new a.DefaultLoggerPublisherService([s],c)}),it("should call subscriber.log with the correct log object",()=>{o.info(e,t),expect(s.log).toHaveBeenCalledWith(l.LogLevel.Info,e,n)}),it("should call subscriber.log with the correct log object when a tag is provided in options",()=>{const i="new-tag";o.info(e,{...t,tag:i}),expect(s.log).toHaveBeenCalledWith(l.LogLevel.Info,e,{...n,tag:`[${i}]`})}),it("should call subscriber.log with the correct log object when a timestamp is provided",()=>{o.info(e,{...t,timestamp:1}),expect(s.log).toHaveBeenCalledWith(l.LogLevel.Info,e,{...n,timestamp:1})}),it("should call _log with the correct LogLevel",()=>{const i=vi.spyOn(o,"_log").mockImplementation(vi.fn());o.info(e,t),expect(i).toHaveBeenCalledWith(l.LogLevel.Info,e,t)}),it("should have the correct LogLevel",()=>{const i=vi.spyOn(o,"_log").mockImplementation(vi.fn());o.debug(e,t),expect(i).toHaveBeenCalledWith(l.LogLevel.Debug,e,t)}),it("should have the correct LogLevel",()=>{const i=vi.spyOn(o,"_log").mockImplementation(vi.fn());o.warn(e,t),expect(i).toHaveBeenCalledWith(l.LogLevel.Warning,e,t)}),it("should have the correct LogLevel",()=>{const i=vi.spyOn(o,"_log").mockImplementation(vi.fn());o.error(e,t),expect(i).toHaveBeenCalledWith(l.LogLevel.Error,e,t)})});
|
|
2
2
|
//# sourceMappingURL=DefaultLoggerPublisherService.test.js.map
|