@ledgerhq/device-management-kit 0.12.0 → 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/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/task/PredictOutOfMemoryTask.js +1 -1
- package/lib/cjs/src/api/device-action/task/PredictOutOfMemoryTask.js.map +3 -3
- package/lib/cjs/src/api/device-action/task/PredictOutOfMemoryTask.test.js +1 -1
- package/lib/cjs/src/api/device-action/task/PredictOutOfMemoryTask.test.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 +3 -3
- 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/device-model/model/DeviceModel.js +1 -1
- package/lib/cjs/src/api/device-model/model/DeviceModel.js.map +3 -3
- package/lib/cjs/src/api/device-model/model/DeviceModel.stub.js +1 -1
- package/lib/cjs/src/api/device-model/model/DeviceModel.stub.js.map +2 -2
- package/lib/cjs/src/api/index.js +1 -1
- package/lib/cjs/src/api/index.js.map +3 -3
- package/lib/cjs/src/api/utils/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/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/task/PredictOutOfMemoryTask.js +1 -1
- package/lib/esm/src/api/device-action/task/PredictOutOfMemoryTask.js.map +3 -3
- package/lib/esm/src/api/device-action/task/PredictOutOfMemoryTask.test.js +1 -1
- package/lib/esm/src/api/device-action/task/PredictOutOfMemoryTask.test.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 +3 -3
- 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/device-model/model/DeviceModel.js +1 -1
- package/lib/esm/src/api/device-model/model/DeviceModel.js.map +3 -3
- package/lib/esm/src/api/device-model/model/DeviceModel.stub.js +1 -1
- package/lib/esm/src/api/device-model/model/DeviceModel.stub.js.map +2 -2
- package/lib/esm/src/api/index.js +1 -1
- package/lib/esm/src/api/index.js.map +3 -3
- package/lib/esm/src/api/utils/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/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/task/PredictOutOfMemoryTask.d.ts +4 -3
- package/lib/types/src/api/device-action/task/PredictOutOfMemoryTask.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/device-model/model/DeviceModel.d.ts +44 -20
- package/lib/types/src/api/device-model/model/DeviceModel.d.ts.map +1 -1
- package/lib/types/src/api/device-model/model/DeviceModel.stub.d.ts.map +1 -1
- package/lib/types/src/api/index.d.ts +1 -0
- package/lib/types/src/api/index.d.ts.map +1 -1
- package/lib/types/src/api/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/tsconfig.prod.tsbuildinfo +1 -1
- package/package.json +4 -4
- package/lib/cjs/src/api/device-model/model/DeviceModel.test.js +0 -2
- package/lib/cjs/src/api/device-model/model/DeviceModel.test.js.map +0 -7
- package/lib/esm/src/api/device-model/model/DeviceModel.test.js +0 -2
- package/lib/esm/src/api/device-model/model/DeviceModel.test.js.map +0 -7
- package/lib/types/src/api/device-model/model/DeviceModel.test.d.ts +0 -2
- package/lib/types/src/api/device-model/model/DeviceModel.test.d.ts.map +0 -1
package/lib/cjs/src/api/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";var
|
|
1
|
+
"use strict";var u=Object.defineProperty;var de=Object.getOwnPropertyDescriptor;var Ae=Object.getOwnPropertyNames;var De=Object.prototype.hasOwnProperty;var le=(p,o)=>{for(var i in o)u(p,i,{get:o[i],enumerable:!0})},l=(p,o,i,v)=>{if(o&&typeof o=="object"||typeof o=="function")for(let s of Ae(o))!De.call(p,s)&&s!==i&&u(p,s,{get:()=>o[s],enumerable:!(v=de(o,s))||v.enumerable});return p},r=(p,o,i)=>(l(p,o,"default"),i&&l(i,o,"default"));var ue=p=>l(u({},"__esModule",{value:!0}),p);var e={};le(e,{APDU_MAX_PAYLOAD:()=>c.APDU_MAX_PAYLOAD,Apdu:()=>S.Apdu,ApduBuilder:()=>c.ApduBuilder,ApduParser:()=>C.ApduParser,ApduResponse:()=>j.ApduResponse,AppAlreadyInstalledDAError:()=>t.AppAlreadyInstalledDAError,BatteryStatusType:()=>x.BatteryStatusType,BleDeviceInfos:()=>N.BleDeviceInfos,ByteArrayBuilder:()=>y.ByteArrayBuilder,ByteArrayParser:()=>L.ByteArrayParser,CallTaskInAppDeviceAction:()=>U.CallTaskInAppDeviceAction,CloseAppCommand:()=>g.CloseAppCommand,CommandResultFactory:()=>n.CommandResultFactory,CommandResultStatus:()=>n.CommandResultStatus,CommandUtils:()=>O.CommandUtils,ConnectedDevice:()=>se.ConnectedDevice,ConsoleLogger:()=>me.ConsoleLogger,DeviceActionStatus:()=>h.DeviceActionStatus,DeviceConnectionStateMachine:()=>ce.DeviceConnectionStateMachine,DeviceLockedError:()=>t.DeviceLockedError,DeviceManagementKit:()=>pe.DeviceManagementKit,DeviceManagementKitBuilder:()=>ie.DeviceManagementKitBuilder,DeviceModel:()=>m.DeviceModel,DeviceModelId:()=>m.DeviceModelId,DeviceSessionStateType:()=>z.DeviceSessionStateType,DeviceStatus:()=>b.DeviceStatus,FramerUtils:()=>te.FramerUtils,GenuineCheckDeviceAction:()=>J.GenuineCheckDeviceAction,GetAppAndVersionCommand:()=>E.GetAppAndVersionCommand,GetBatteryStatusCommand:()=>x.GetBatteryStatusCommand,GetDeviceMetadataDeviceAction:()=>P.GetDeviceMetadataDeviceAction,GetDeviceStatusDeviceAction:()=>V.GetDeviceStatusDeviceAction,GetOsVersionCommand:()=>B.GetOsVersionCommand,GlobalCommandError:()=>d.GlobalCommandError,GlobalCommandErrorHandler:()=>d.GlobalCommandErrorHandler,GoToDashboardDeviceAction:()=>k.GoToDashboardDeviceAction,InstallAppDeviceAction:()=>Q.InstallAppDeviceAction,InstallOrUpdateAppsDeviceAction:()=>F.InstallOrUpdateAppsDeviceAction,InvalidGetFirmwareMetadataResponseError:()=>f.InvalidGetFirmwareMetadataResponseError,InvalidStatusWordError:()=>f.InvalidStatusWordError,LEDGER_VENDOR_ID:()=>m.LEDGER_VENDOR_ID,ListAppsCommand:()=>G.ListAppsCommand,ListAppsDeviceAction:()=>W.ListAppsDeviceAction,ListAppsWithMetadataDeviceAction:()=>_.ListAppsWithMetadataDeviceAction,ListInstalledAppsDeviceAction:()=>Z.ListInstalledAppsDeviceAction,LoadCertificateCommand:()=>R.LoadCertificateCommand,LogLevel:()=>ne.LogLevel,OpenAppCommand:()=>M.OpenAppCommand,OpenAppDeviceAction:()=>w.OpenAppDeviceAction,OpenAppWithDependenciesDeviceAction:()=>H.OpenAppWithDependenciesDeviceAction,OutOfMemoryDAError:()=>t.OutOfMemoryDAError,RefusedByUserDAError:()=>t.RefusedByUserDAError,SecureChannelError:()=>ee.SecureChannelError,SendCommandInAppDeviceAction:()=>K.SendCommandInAppDeviceAction,StaticDeviceModelDataSource:()=>q.StaticDeviceModelDataSource,TransportConnectedDevice:()=>fe.TransportConnectedDevice,TransportDeviceModel:()=>Y.TransportDeviceModel,UninstallAppDeviceAction:()=>$.UninstallAppDeviceAction,UnknownDAError:()=>t.UnknownDAError,UnsupportedFirmwareDAError:()=>t.UnsupportedFirmwareDAError,UserInteractionRequired:()=>T.UserInteractionRequired,WebLogsExporterLogger:()=>ae.WebLogsExporterLogger,XStateDeviceAction:()=>X.XStateDeviceAction,base64StringToBuffer:()=>D.base64StringToBuffer,bufferToHexaString:()=>a.bufferToHexaString,connectedDeviceStubBuilder:()=>xe.connectedDeviceStubBuilder,defaultApduReceiverServiceStubBuilder:()=>re.defaultApduReceiverServiceStubBuilder,defaultApduSenderServiceStubBuilder:()=>oe.defaultApduSenderServiceStubBuilder,formatApduReceivedLog:()=>A.formatApduReceivedLog,formatApduSentLog:()=>A.formatApduSentLog,hexaStringToBuffer:()=>a.hexaStringToBuffer,isBase64String:()=>D.isBase64String,isCommandErrorCode:()=>I.isCommandErrorCode,isHexaString:()=>a.isHexaString,isSuccessCommandResult:()=>n.isSuccessCommandResult});module.exports=ue(e);var S=require("./apdu/model/Apdu"),c=require("./apdu/utils/ApduBuilder"),C=require("./apdu/utils/ApduParser");r(e,require("./apdu/utils/AppBuilderError"),module.exports);var y=require("./apdu/utils/ByteArrayBuilder"),L=require("./apdu/utils/ByteArrayParser"),f=require("./command/Errors"),n=require("./command/model/CommandResult"),g=require("./command/os/CloseAppCommand"),E=require("./command/os/GetAppAndVersionCommand"),x=require("./command/os/GetBatteryStatusCommand"),B=require("./command/os/GetOsVersionCommand"),G=require("./command/os/ListAppsCommand"),R=require("./command/os/LoadCertificateCommand"),M=require("./command/os/OpenAppCommand"),I=require("./command/utils/CommandErrors"),O=require("./command/utils/CommandUtils"),d=require("./command/utils/GlobalCommandError"),m=require("./device/DeviceModel"),b=require("./device/DeviceStatus"),h=require("./device-action/model/DeviceActionState"),T=require("./device-action/model/UserInteractionRequired"),U=require("./device-action/os/CallTaskInAppDeviceAction/CallTaskInAppDeviceAction"),t=require("./device-action/os/Errors"),P=require("./device-action/os/GetDeviceMetadata/GetDeviceMetadataDeviceAction"),V=require("./device-action/os/GetDeviceStatus/GetDeviceStatusDeviceAction"),k=require("./device-action/os/GoToDashboard/GoToDashboardDeviceAction"),F=require("./device-action/os/InstallOrUpdateApps/InstallOrUpdateAppsDeviceAction"),W=require("./device-action/os/ListApps/ListAppsDeviceAction"),_=require("./device-action/os/ListAppsWithMetadata/ListAppsWithMetadataDeviceAction"),w=require("./device-action/os/OpenAppDeviceAction/OpenAppDeviceAction"),H=require("./device-action/os/OpenAppWithDependencies/OpenAppWithDependenciesDeviceAction"),K=require("./device-action/os/SendCommandInAppDeviceAction/SendCommandInAppDeviceAction"),X=require("./device-action/xstate-utils/XStateDeviceAction"),q=require("./device-model/data/StaticDeviceModelDataSource"),N=require("./device-model/model/BleDeviceInfos"),Y=require("./device-model/model/DeviceModel"),j=require("./device-session/ApduResponse");r(e,require("./device-session/data/FramerConst"),module.exports);var z=require("./device-session/DeviceSessionState"),J=require("./secure-channel/device-action/GenuineCheck/GenuineCheckDeviceAction"),Q=require("./secure-channel/device-action/InstallApp/InstallAppDeviceAction"),Z=require("./secure-channel/device-action/ListInstalledApps/ListInstalledAppsDeviceAction"),$=require("./secure-channel/device-action/UninstallApp/UninstallAppDeviceAction"),ee=require("../internal/secure-channel/model/Errors"),re=require("./device-session/service/DefaultApduReceiverService.stub"),oe=require("./device-session/service/DefaultApduSenderService.stub"),te=require("./device-session/utils/FramerUtils"),pe=require("./DeviceManagementKit"),ie=require("./DeviceManagementKitBuilder");r(e,require("./Error"),module.exports);var ne=require("./logger-subscriber/model/LogLevel"),me=require("./logger-subscriber/service/ConsoleLogger"),ae=require("./logger-subscriber/service/WebLogsExporterLogger"),se=require("./transport/model/ConnectedDevice"),ce=require("./transport/model/DeviceConnectionStateMachine");r(e,require("./transport/model/Errors"),module.exports);var fe=require("./transport/model/TransportConnectedDevice"),xe=require("./transport/model/TransportConnectedDevice.stub");r(e,require("./types"),module.exports);var A=require("./utils/apduLogs"),D=require("./utils/Base64String"),a=require("./utils/HexaString");0&&(module.exports={APDU_MAX_PAYLOAD,Apdu,ApduBuilder,ApduParser,ApduResponse,AppAlreadyInstalledDAError,BatteryStatusType,BleDeviceInfos,ByteArrayBuilder,ByteArrayParser,CallTaskInAppDeviceAction,CloseAppCommand,CommandResultFactory,CommandResultStatus,CommandUtils,ConnectedDevice,ConsoleLogger,DeviceActionStatus,DeviceConnectionStateMachine,DeviceLockedError,DeviceManagementKit,DeviceManagementKitBuilder,DeviceModel,DeviceModelId,DeviceSessionStateType,DeviceStatus,FramerUtils,GenuineCheckDeviceAction,GetAppAndVersionCommand,GetBatteryStatusCommand,GetDeviceMetadataDeviceAction,GetDeviceStatusDeviceAction,GetOsVersionCommand,GlobalCommandError,GlobalCommandErrorHandler,GoToDashboardDeviceAction,InstallAppDeviceAction,InstallOrUpdateAppsDeviceAction,InvalidGetFirmwareMetadataResponseError,InvalidStatusWordError,LEDGER_VENDOR_ID,ListAppsCommand,ListAppsDeviceAction,ListAppsWithMetadataDeviceAction,ListInstalledAppsDeviceAction,LoadCertificateCommand,LogLevel,OpenAppCommand,OpenAppDeviceAction,OpenAppWithDependenciesDeviceAction,OutOfMemoryDAError,RefusedByUserDAError,SecureChannelError,SendCommandInAppDeviceAction,StaticDeviceModelDataSource,TransportConnectedDevice,TransportDeviceModel,UninstallAppDeviceAction,UnknownDAError,UnsupportedFirmwareDAError,UserInteractionRequired,WebLogsExporterLogger,XStateDeviceAction,base64StringToBuffer,bufferToHexaString,connectedDeviceStubBuilder,defaultApduReceiverServiceStubBuilder,defaultApduSenderServiceStubBuilder,formatApduReceivedLog,formatApduSentLog,hexaStringToBuffer,isBase64String,isCommandErrorCode,isHexaString,isSuccessCommandResult,...require("./apdu/utils/AppBuilderError"),...require("./device-session/data/FramerConst"),...require("./Error"),...require("./transport/model/Errors"),...require("./types")});
|
|
2
2
|
//# sourceMappingURL=index.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../src/api/index.ts"],
|
|
4
|
-
"sourcesContent": ["\"use strict\";\n\nexport { Apdu } from \"@api/apdu/model/Apdu\";\nexport { APDU_MAX_PAYLOAD, ApduBuilder } from \"@api/apdu/utils/ApduBuilder\";\nexport { ApduParser } from \"@api/apdu/utils/ApduParser\";\nexport * from \"@api/apdu/utils/AppBuilderError\";\nexport { ByteArrayBuilder } from \"@api/apdu/utils/ByteArrayBuilder\";\nexport { ByteArrayParser } from \"@api/apdu/utils/ByteArrayParser\";\nexport {\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 { 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,ykHAAAE,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,GAAsC,gEACtCC,GAAgC,gDAChCC,GAGO,6DACP/C,EAAAN,EAAc,uCApHd,gBAqHA,IAAAsD,GAAyC,yDACzCA,GAA2C,8DAC3ChD,EAAAN,EAAc,sBAvHd,gBAwHA,IAAAuD,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_WebLogsExporterLogger", "import_ConnectedDevice", "import_DeviceConnectionStateMachine", "import_TransportConnectedDevice", "import_apduLogs", "import_Base64String", "import_HexaString"]
|
|
7
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(formatApduReceivedLog(apduResponse)).toBe(\"[exchange] <= 6985\");\n });\n });\n});\n"],
|
|
5
|
+
"mappings": "aAAA,IAAAA,EAAqC,kBAErCC,EAIO,yBAEP,YAAS,WAAY,IAAM,IACzB,YAAS,uBAAwB,IAAM,IACrC,MAAG,wDAAyD,IAAM,CAChE,MAAMC,EAAO,WAAW,KAAK,CAAC,IAAM,EAAM,EAAM,EAAM,CAAI,CAAC,KAC3D,aAAO,wBAAqBA,CAAI,CAAC,EAAE,KACjC,mCACF,CACF,CAAC,KAED,MAAG,2BAA4B,IAAM,CACnC,MAAMA,EAAO,WAAW,KAAK,CAAC,CAAC,KAC/B,aAAO,wBAAqBA,CAAI,CAAC,EAAE,KAAK,yBAAyB,CACnE,CAAC,CACH,CAAC,KAED,YAAS,oBAAqB,IAAM,IAClC,MAAG,uDAAwD,IAAM,CAC/D,MAAMA,EAAO,WAAW,KAAK,CAAC,IAAM,EAAM,EAAM,EAAM,CAAI,CAAC,KAC3D,aAAO,qBAAkBA,CAAI,CAAC,EAAE,KAAK,0BAA0B,CACjE,CAAC,KAED,MAAG,2BAA4B,IAAM,CACnC,MAAMA,EAAO,WAAW,KAAK,CAAC,CAAC,KAC/B,aAAO,qBAAkBA,CAAI,CAAC,EAAE,KAAK,gBAAgB,CACvD,CAAC,CACH,CAAC,KAED,YAAS,wBAAyB,IAAM,IACtC,MAAG,wDAAyD,IAAM,CAChE,MAAMC,EAAe,CACnB,KAAM,WAAW,KAAK,CAAC,EAAM,EAAM,CAAI,CAAC,EACxC,WAAY,WAAW,KAAK,CAAC,IAAM,CAAI,CAAC,CAC1C,KACA,aAAO,yBAAsBA,CAAY,CAAC,EAAE,KAC1C,0BACF,CACF,CAAC,KAED,MAAG,uEAAwE,IAAM,CAC/E,MAAMA,EAAe,CACnB,KAAM,WAAW,KAAK,CAAC,CAAC,EACxB,WAAY,WAAW,KAAK,CAAC,IAAM,CAAI,CAAC,CAC1C,KACA,aAAO,yBAAsBA,CAAY,CAAC,EAAE,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
|
|
1
|
+
"use strict";var p=Object.defineProperty;var b=Object.getOwnPropertyDescriptor;var A=Object.getOwnPropertyNames;var R=Object.prototype.hasOwnProperty;var y=(n,e)=>{for(var i in e)p(n,i,{get:e[i],enumerable:!0})},T=(n,e,i,s)=>{if(e&&typeof e=="object"||typeof e=="function")for(let t of A(e))!R.call(n,t)&&t!==i&&p(n,t,{get:()=>e[t],enumerable:!(s=b(e,t))||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:i=(0,h.v4)()},s,t,r,c){this._id=i,this._connectedDevice=e,this._logger=s("device-session"),this._managerApiService=t,this._secureChannelService=r,this._refresherOptions={...l.DEVICE_SESSION_REFRESHER_DEFAULT_OPTIONS,...c},this._deviceState=new 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,C)=>this.sendCommand(a,C)),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,i={isPolling:!1,triggersDisconnection:!1,abortTimeout:void 0}){const s=await this._commandMutex.lock();try{this._sessionEventDispatcher.dispatch({eventName:o.SessionEvents.DEVICE_STATE_UPDATE_BUSY}),this._logger.debug((0,m.formatApduSendingLog)(e));const t=await this._connectedDevice.sendApdu(e,i.triggersDisconnection,i.abortTimeout);return t.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})}),t}finally{s()}}async sendCommand(e,i){this._logger.debug(`[sendCommand] ${e.name}`);const s=e.getApdu();return(await this.sendApdu(s.getRawApdu(),{isPolling:!1,triggersDisconnection:e.triggersDisconnection??!1,abortTimeout:i})).caseOf({Left:r=>{throw this._logger.error("[sendCommand] error",{data:{err:r}}),r},Right:r=>{const c=e.parseResponse(r,this._connectedDevice.deviceModel.id);return this._logger.debug("[sendCommand] result",{data:{result:c}}),c}})}executeDeviceAction(e){const{observable:i,cancel:s}=e._execute({sendApdu:async t=>this.sendApdu(t),sendCommand:async(t,r)=>this.sendCommand(t,r),getDeviceModel:()=>this._connectedDevice.deviceModel,getDeviceSessionState:()=>this._deviceState.getValue(),getDeviceSessionStateObservable:()=>this.state,setDeviceSessionState:t=>(this.setDeviceSessionState(t),this._deviceState.getValue()),disableRefresher:t=>this._refresherService.disableRefresher(t),getManagerApiService:()=>this._managerApiService,getSecureChannelService:()=>this._secureChannelService});return{observable:i,cancel:s}}close(){this._updateDeviceStatus(v.DeviceStatus.NOT_CONNECTED),this._deviceState.complete(),this._deviceSessionRefresher.stopRefresher()}disableRefresher(e){return this._refresherService.disableRefresher(e)}_updateDeviceStatus(e){const i=this._deviceState.getValue();this._deviceState.next({...i,deviceStatus:e})}}0&&(module.exports={DeviceSession});
|
|
2
2
|
//# sourceMappingURL=DeviceSession.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../../src/internal/device-session/model/DeviceSession.ts"],
|
|
4
|
-
"sourcesContent": ["import { type Either } from \"purify-ts\";\nimport { BehaviorSubject, type Observable } from \"rxjs\";\nimport { v4 as uuidv4 } from \"uuid\";\n\nimport { type Command } from \"@api/command/Command\";\nimport { type CommandResult } from \"@api/command/model/CommandResult\";\nimport { CommandUtils } from \"@api/command/utils/CommandUtils\";\nimport { DeviceStatus } from \"@api/device/DeviceStatus\";\nimport {\n type DeviceAction,\n type DeviceActionIntermediateValue,\n type ExecuteDeviceActionReturnType,\n} from \"@api/device-action/DeviceAction\";\nimport { type ApduResponse } from \"@api/device-session/ApduResponse\";\nimport {\n type DeviceSessionState,\n DeviceSessionStateType,\n} from \"@api/device-session/DeviceSessionState\";\nimport { type DeviceSessionId } from \"@api/device-session/types\";\nimport { type DmkError } from \"@api/Error\";\nimport {
|
|
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 }\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": "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",
|
|
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
|
}
|
package/lib/esm/package.json
CHANGED
|
@@ -64,5 +64,5 @@
|
|
|
64
64
|
"watch:builds": "pnpm ldmk-tool watch --entryPoints index.ts,src/**/*.ts --tsconfig tsconfig.prod.json",
|
|
65
65
|
"watch:types": "concurrently \"tsc --watch -p tsconfig.prod.json\" \"tsc-alias --watch -p tsconfig.prod.json\""
|
|
66
66
|
},
|
|
67
|
-
"version": "0.
|
|
67
|
+
"version": "1.0.0"
|
|
68
68
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{commandTypes as c}from"./command/di/commandTypes";import{configTypes as a}from"../internal/config/di/configTypes";import{deviceSessionTypes as t}from"../internal/device-session/di/deviceSessionTypes";import{discoveryTypes as s}from"../internal/discovery/di/discoveryTypes";import{managerApiTypes as r}from"../internal/manager-api/di/managerApiTypes";import{sendTypes as
|
|
1
|
+
import{commandTypes as c}from"./command/di/commandTypes";import{configTypes as a}from"../internal/config/di/configTypes";import{deviceSessionTypes as t}from"../internal/device-session/di/deviceSessionTypes";import{discoveryTypes as s}from"../internal/discovery/di/discoveryTypes";import{loggerTypes as p}from"../internal/logger-publisher/di/loggerTypes";import{managerApiTypes as r}from"../internal/manager-api/di/managerApiTypes";import{sendTypes as m}from"../internal/send/di/sendTypes";import{transportDiTypes as C}from"../internal/transport/di/transportDiTypes";import{makeContainer as v}from"../../src/di";import{deviceActionTypes as d}from"./device-action/di/deviceActionTypes";class x{container;constructor({stub:e,transports:o,loggers:i,config:n}={}){this.container=v({stub:e,transports:o,loggers:i,config:n})}getVersion(){return this.container.get(a.GetDmkVersionUseCase).getDmkVersion()}startDiscovering(e){return this.container.get(s.StartDiscoveringUseCase).execute(e)}stopDiscovering(){return this.container.get(s.StopDiscoveringUseCase).execute()}listenToAvailableDevices(e){return this.container.get(s.ListenToAvailableDevicesUseCase).execute(e)}async reconnect(e){return this.container.get(s.ReconnectUseCase).execute(e)}connect(e){return this.container.get(s.ConnectUseCase).execute(e)}disconnect(e){return this.container.get(s.DisconnectUseCase).execute(e)}sendApdu(e){return this.container.get(m.SendApduUseCase).execute(e)}sendCommand(e){return this.container.get(c.SendCommandUseCase).execute(e)}executeDeviceAction(e){return this.container.get(d.ExecuteDeviceActionUseCase).execute(e)}getConnectedDevice(e){return this.container.get(s.GetConnectedDeviceUseCase).execute(e)}getDeviceSessionState(e){return this.container.get(t.GetDeviceSessionStateUseCase).execute(e)}close(){return this.container.get(t.CloseSessionsUseCase).execute()}listConnectedDevices(){return this.container.get(s.ListConnectedDevicesUseCase).execute()}listenToConnectedDevice(){return this.container.get(s.ListenToConnectedDeviceUseCase).execute()}disableDeviceSessionRefresher(e){return this.container.get(t.DisableDeviceSessionRefresherUseCase).execute(e)}setProvider(e){return this.container.get(r.SetProviderUseCase).execute(e)}getProvider(){return this.container.get(r.ManagerApiDataSource).getProvider()}isEnvironmentSupported(){return this.container.get(C.TransportService).getAllTransports().some(e=>e.isSupported())}getLoggerFactory(){return this.container.get(p.LoggerPublisherServiceFactory)}}export{x as DeviceManagementKit};
|
|
2
2
|
//# sourceMappingURL=DeviceManagementKit.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../src/api/DeviceManagementKit.ts"],
|
|
4
|
-
"sourcesContent": ["import { type Container } from \"inversify\";\nimport { type Observable } from \"rxjs\";\n\nimport { commandTypes } from \"@api/command/di/commandTypes\";\nimport { type CommandResult } from \"@api/command/model/CommandResult\";\nimport {\n type SendCommandUseCase,\n type SendCommandUseCaseArgs,\n} from \"@api/command/use-case/SendCommandUseCase\";\nimport {\n type ExecuteDeviceActionUseCase,\n type ExecuteDeviceActionUseCaseArgs,\n} from \"@api/device-action/use-case/ExecuteDeviceActionUseCase\";\nimport { type ApduResponse } from \"@api/device-session/ApduResponse\";\nimport { type DeviceSessionState } from \"@api/device-session/DeviceSessionState\";\nimport { type DeviceSessionId } from \"@api/device-session/types\";\nimport { type ConnectedDevice } from \"@api/transport/model/ConnectedDevice\";\nimport {\n type ConnectUseCaseArgs,\n type DisconnectUseCaseArgs,\n type DiscoveredDevice,\n type GetConnectedDeviceUseCaseArgs,\n type SendApduUseCaseArgs,\n type StartDiscoveringUseCaseArgs,\n} from \"@api/types\";\nimport { configTypes } from \"@internal/config/di/configTypes\";\nimport { type GetDmkVersionUseCase } from \"@internal/config/use-case/GetDmkVersionUseCase\";\nimport { deviceSessionTypes } from \"@internal/device-session/di/deviceSessionTypes\";\nimport { type CloseSessionsUseCase } from \"@internal/device-session/use-case/CloseSessionsUseCase\";\nimport { type GetDeviceSessionStateUseCase } from \"@internal/device-session/use-case/GetDeviceSessionStateUseCase\";\nimport { discoveryTypes } from \"@internal/discovery/di/discoveryTypes\";\nimport { type ConnectUseCase } from \"@internal/discovery/use-case/ConnectUseCase\";\nimport { type DisconnectUseCase } from \"@internal/discovery/use-case/DisconnectUseCase\";\nimport { type GetConnectedDeviceUseCase } from \"@internal/discovery/use-case/GetConnectedDeviceUseCase\";\nimport { type ListConnectedDevicesUseCase } from \"@internal/discovery/use-case/ListConnectedDevicesUseCase\";\nimport {\n type ListenToAvailableDevicesUseCase,\n type ListenToAvailableDevicesUseCaseArgs,\n} from \"@internal/discovery/use-case/ListenToAvailableDevicesUseCase\";\nimport { type ListenToConnectedDeviceUseCase } from \"@internal/discovery/use-case/ListenToConnectedDeviceUseCase\";\nimport {\n type ReconnectUseCase,\n type ReconnectUseCaseArgs,\n} from \"@internal/discovery/use-case/ReconnectUseCase\";\nimport type { StartDiscoveringUseCase } from \"@internal/discovery/use-case/StartDiscoveringUseCase\";\nimport type { StopDiscoveringUseCase } from \"@internal/discovery/use-case/StopDiscoveringUseCase\";\nimport { type ManagerApiDataSource } from \"@internal/manager-api/data/ManagerApiDataSource\";\nimport { managerApiTypes } from \"@internal/manager-api/di/managerApiTypes\";\nimport { type SetProviderUseCase } from \"@internal/manager-api/use-case/SetProviderUseCase\";\nimport { sendTypes } from \"@internal/send/di/sendTypes\";\nimport { type SendApduUseCase } from \"@internal/send/use-case/SendApduUseCase\";\nimport { transportDiTypes } from \"@internal/transport/di/transportDiTypes\";\nimport { type TransportService } from \"@internal/transport/service/TransportService\";\nimport { makeContainer, type MakeContainerProps } from \"@root/src/di\";\n\nimport {\n type DeviceActionIntermediateValue,\n type ExecuteDeviceActionReturnType,\n} from \"./device-action/DeviceAction\";\nimport { deviceActionTypes } from \"./device-action/di/deviceActionTypes\";\nimport { type DisableDeviceSessionRefresherUseCase } from \"./device-session/use-case/DisableDeviceSessionRefresher\";\nimport { type DmkError } from \"./Error\";\n\n/**\n * The main class to interact with the Device Management Kit.\n *\n * NB: do not instantiate this class directly, instead, use `LedgerDMKBuilder`.\n */\nexport class DeviceManagementKit {\n readonly container: Container;\n /** @internal */\n constructor({\n stub,\n transports,\n loggers,\n config,\n }: Partial<MakeContainerProps> = {}) {\n // NOTE: MakeContainerProps might not be the exact type here\n // For the init of the project this is sufficient, but we might need to\n // update the constructor arguments as we go (we might have more than just the container config)\n this.container = makeContainer({\n stub,\n transports,\n loggers,\n config,\n });\n }\n\n /**\n * Returns a promise resolving to the version of the SDK.\n */\n getVersion(): Promise<string> {\n return this.container\n .get<GetDmkVersionUseCase>(configTypes.GetDmkVersionUseCase)\n .getDmkVersion();\n }\n\n /**\n * Starts discovering devices connected.\n *\n * For the WeHID implementation, this use-case needs to be called as a result\n * of an user interaction (button \"click\" event for ex).\n *\n * @param {StartDiscoveringUseCaseArgs} args - The transport to use for discover, or undefined to discover from all transports.\n * @returns {Observable<DiscoveredDevice>} An observable of discovered devices.\n */\n startDiscovering(\n args: StartDiscoveringUseCaseArgs,\n ): Observable<DiscoveredDevice> {\n return this.container\n .get<StartDiscoveringUseCase>(discoveryTypes.StartDiscoveringUseCase)\n .execute(args);\n }\n\n /**\n * Stops discovering devices connected.\n */\n stopDiscovering() {\n return this.container\n .get<StopDiscoveringUseCase>(discoveryTypes.StopDiscoveringUseCase)\n .execute();\n }\n\n /**\n * Listen to list of known discovered devices (and later BLE).\n * @param {ListenToAvailableDevicesUseCaseArgs} args - The transport to use for discover, or undefined to discover from all transports.\n * @returns {Observable<DiscoveredDevice[]>} An observable of known discovered devices.\n */\n listenToAvailableDevices(\n args: ListenToAvailableDevicesUseCaseArgs,\n ): Observable<DiscoveredDevice[]> {\n return this.container\n .get<ListenToAvailableDevicesUseCase>(\n discoveryTypes.ListenToAvailableDevicesUseCase,\n )\n .execute(args);\n }\n\n /**\n * Reconnects a device session by disconnecting and reconnecting to the device.\n *\n * @param args - The arguments for reconnecting the device session.\n * - `device`: The connected device.\n * - `sessionRefresherOptions` (optional): Configuration for session refreshing.\n * - `isRefresherDisabled`: Whether the refresher is disabled.\n * - `pollingInterval`: The refresh interval in milliseconds\n * @returns The session ID to use for further communication with the device.\n */\n async reconnect(args: ReconnectUseCaseArgs): Promise<DeviceSessionId> {\n return this.container\n .get<ReconnectUseCase>(discoveryTypes.ReconnectUseCase)\n .execute(args);\n }\n\n /**\n * Connects to a device previously discovered with `DeviceManagementKit.startDiscovering`.\n * Creates a new device session which:\n * - Represents the connection to the device.\n * - Is terminated upon disconnection of the device.\n * - Exposes the device state through an observable (see `DeviceManagementKit.getDeviceSessionState`)\n * - Should be used for all subsequent communication with the device.\n *\n * @param {ConnectUseCaseArgs} args - The arguments for connecting to the device.\n * - `device`: The discovered device obtained from `StartDiscoveringUseCase`.\n * - `sessionRefresherOptions` (optional): Configuration for session refreshing.\n * - `isRefresherDisabled`: Whether the refresher is disabled.\n * - `pollingInterval`: The refresh interval in milliseconds\n * @returns The session ID to use for further communication with the device.\n */\n connect(args: ConnectUseCaseArgs): Promise<DeviceSessionId> {\n return this.container\n .get<ConnectUseCase>(discoveryTypes.ConnectUseCase)\n .execute(args);\n }\n\n /**\n * Disconnects to a discovered device.\n *\n * @param {DisconnectUseCaseArgs} args - The session ID to disconnect.\n */\n disconnect(args: DisconnectUseCaseArgs): Promise<void> {\n return this.container\n .get<DisconnectUseCase>(discoveryTypes.DisconnectUseCase)\n .execute(args);\n }\n\n /**\n * Sends an APDU command to a device through a device session.\n *\n * @param {SendApduUseCaseArgs} args - The device session ID and APDU command to send.\n */\n sendApdu(args: SendApduUseCaseArgs): Promise<ApduResponse> {\n return this.container\n .get<SendApduUseCase>(sendTypes.SendApduUseCase)\n .execute(args);\n }\n\n /**\n * Sends a command to a device through a device session.\n *\n * @param {SendCommandUseCaseArgs<Response, Args, ErrorCodes>} args - The device session ID, command, command error codes and command parameters to send.\n * @returns A promise resolving with the response from the command.\n */\n sendCommand<Response, Args, ErrorCodes>(\n args: SendCommandUseCaseArgs<Response, Args, ErrorCodes>,\n ): Promise<CommandResult<Response, ErrorCodes>> {\n return this.container\n .get<SendCommandUseCase>(commandTypes.SendCommandUseCase)\n .execute(args);\n }\n\n executeDeviceAction<\n Output,\n Input,\n Error extends DmkError,\n IntermediateValue extends DeviceActionIntermediateValue,\n >(\n args: ExecuteDeviceActionUseCaseArgs<\n Output,\n Input,\n Error,\n IntermediateValue\n >,\n ): ExecuteDeviceActionReturnType<Output, Error, IntermediateValue> {\n return this.container\n .get<ExecuteDeviceActionUseCase>(\n deviceActionTypes.ExecuteDeviceActionUseCase,\n )\n .execute(args);\n }\n\n /**\n * Gets the connected from its device session ID.\n *\n * @param {GetConnectedDeviceUseCaseArgs} args - The device session ID.\n * @returns {ConnectedDevice} The connected device.\n */\n getConnectedDevice(args: GetConnectedDeviceUseCaseArgs): ConnectedDevice {\n return this.container\n .get<GetConnectedDeviceUseCase>(discoveryTypes.GetConnectedDeviceUseCase)\n .execute(args);\n }\n\n /**\n * Gets the device state of a session.\n *\n * @param {{ sessionId: DeviceSessionId }} args - The device session ID.\n * @returns {Observable<DeviceSessionState>} An observable of the session device state.\n */\n getDeviceSessionState(args: {\n sessionId: DeviceSessionId;\n }): Observable<DeviceSessionState> {\n return this.container\n .get<GetDeviceSessionStateUseCase>(\n deviceSessionTypes.GetDeviceSessionStateUseCase,\n )\n .execute(args);\n }\n\n /**\n * Close the Device Management kit.\n *\n */\n close() {\n return this.container\n .get<CloseSessionsUseCase>(deviceSessionTypes.CloseSessionsUseCase)\n .execute();\n }\n\n /**\n * Lists all connected devices.\n *\n * @returns {ConnectedDevice[]} The list of device sessions.\n */\n listConnectedDevices(): ConnectedDevice[] {\n return this.container\n .get<ListConnectedDevicesUseCase>(\n discoveryTypes.ListConnectedDevicesUseCase,\n )\n .execute();\n }\n\n /**\n * Listen to connected device.\n *\n * @returns {Observable<ConnectedDevice>} An observable of connected device.\n */\n listenToConnectedDevice(): Observable<ConnectedDevice> {\n return this.container\n .get<ListenToConnectedDeviceUseCase>(\n discoveryTypes.ListenToConnectedDeviceUseCase,\n )\n .execute();\n }\n\n /**\n * Disable the device session refresher.\n *\n * @param {DisableDeviceSessionRefresherUseCaseArgs} args - The device session ID and a string to identify the blocker.\n * @returns {() => void} A function to reenable the device session refresher.\n */\n disableDeviceSessionRefresher(args: {\n sessionId: DeviceSessionId;\n blockerId: string;\n }): () => void {\n return this.container\n .get<DisableDeviceSessionRefresherUseCase>(\n deviceSessionTypes.DisableDeviceSessionRefresherUseCase,\n )\n .execute(args);\n }\n /**\n * Sets the provider for the manager API.\n *\n * @param {number} provider - The provider to set.\n */\n setProvider(provider: number): void {\n return this.container\n .get<SetProviderUseCase>(managerApiTypes.SetProviderUseCase)\n .execute(provider);\n }\n\n /**\n * Returns the current provider value from the manager API data source.\n */\n getProvider(): number {\n return this.container\n .get<ManagerApiDataSource>(managerApiTypes.ManagerApiDataSource)\n .getProvider();\n }\n\n /**\n * Check if the current environment is supported by any transport.\n */\n isEnvironmentSupported(): boolean {\n return this.container\n .get<TransportService>(transportDiTypes.TransportService)\n .getAllTransports()\n .some((transport) => transport.isSupported());\n }\n}\n"],
|
|
5
|
-
"mappings": "AAGA,OAAS,gBAAAA,MAAoB,+
|
|
6
|
-
"names": ["commandTypes", "configTypes", "deviceSessionTypes", "discoveryTypes", "managerApiTypes", "sendTypes", "transportDiTypes", "makeContainer", "deviceActionTypes", "DeviceManagementKit", "stub", "transports", "loggers", "config", "args", "provider", "transport"]
|
|
4
|
+
"sourcesContent": ["import { type Container, type Factory } from \"inversify\";\nimport { type Observable } from \"rxjs\";\n\nimport { commandTypes } from \"@api/command/di/commandTypes\";\nimport { type CommandResult } from \"@api/command/model/CommandResult\";\nimport {\n type SendCommandUseCase,\n type SendCommandUseCaseArgs,\n} from \"@api/command/use-case/SendCommandUseCase\";\nimport {\n type ExecuteDeviceActionUseCase,\n type ExecuteDeviceActionUseCaseArgs,\n} from \"@api/device-action/use-case/ExecuteDeviceActionUseCase\";\nimport { type ApduResponse } from \"@api/device-session/ApduResponse\";\nimport { type DeviceSessionState } from \"@api/device-session/DeviceSessionState\";\nimport { type DeviceSessionId } from \"@api/device-session/types\";\nimport { type ConnectedDevice } from \"@api/transport/model/ConnectedDevice\";\nimport {\n type ConnectUseCaseArgs,\n type DisconnectUseCaseArgs,\n type DiscoveredDevice,\n type GetConnectedDeviceUseCaseArgs,\n type LoggerPublisherService,\n type SendApduUseCaseArgs,\n type StartDiscoveringUseCaseArgs,\n} from \"@api/types\";\nimport { configTypes } from \"@internal/config/di/configTypes\";\nimport { type GetDmkVersionUseCase } from \"@internal/config/use-case/GetDmkVersionUseCase\";\nimport { deviceSessionTypes } from \"@internal/device-session/di/deviceSessionTypes\";\nimport { type CloseSessionsUseCase } from \"@internal/device-session/use-case/CloseSessionsUseCase\";\nimport { type GetDeviceSessionStateUseCase } from \"@internal/device-session/use-case/GetDeviceSessionStateUseCase\";\nimport { discoveryTypes } from \"@internal/discovery/di/discoveryTypes\";\nimport { type ConnectUseCase } from \"@internal/discovery/use-case/ConnectUseCase\";\nimport { type DisconnectUseCase } from \"@internal/discovery/use-case/DisconnectUseCase\";\nimport { type GetConnectedDeviceUseCase } from \"@internal/discovery/use-case/GetConnectedDeviceUseCase\";\nimport { type ListConnectedDevicesUseCase } from \"@internal/discovery/use-case/ListConnectedDevicesUseCase\";\nimport {\n type ListenToAvailableDevicesUseCase,\n type ListenToAvailableDevicesUseCaseArgs,\n} from \"@internal/discovery/use-case/ListenToAvailableDevicesUseCase\";\nimport { type ListenToConnectedDeviceUseCase } from \"@internal/discovery/use-case/ListenToConnectedDeviceUseCase\";\nimport {\n type ReconnectUseCase,\n type ReconnectUseCaseArgs,\n} from \"@internal/discovery/use-case/ReconnectUseCase\";\nimport type { StartDiscoveringUseCase } from \"@internal/discovery/use-case/StartDiscoveringUseCase\";\nimport type { StopDiscoveringUseCase } from \"@internal/discovery/use-case/StopDiscoveringUseCase\";\nimport { loggerTypes } from \"@internal/logger-publisher/di/loggerTypes\";\nimport { type ManagerApiDataSource } from \"@internal/manager-api/data/ManagerApiDataSource\";\nimport { managerApiTypes } from \"@internal/manager-api/di/managerApiTypes\";\nimport { type SetProviderUseCase } from \"@internal/manager-api/use-case/SetProviderUseCase\";\nimport { sendTypes } from \"@internal/send/di/sendTypes\";\nimport { type SendApduUseCase } from \"@internal/send/use-case/SendApduUseCase\";\nimport { transportDiTypes } from \"@internal/transport/di/transportDiTypes\";\nimport { type TransportService } from \"@internal/transport/service/TransportService\";\nimport { makeContainer, type MakeContainerProps } from \"@root/src/di\";\n\nimport {\n type DeviceActionIntermediateValue,\n type ExecuteDeviceActionReturnType,\n} from \"./device-action/DeviceAction\";\nimport { deviceActionTypes } from \"./device-action/di/deviceActionTypes\";\nimport { type DisableDeviceSessionRefresherUseCase } from \"./device-session/use-case/DisableDeviceSessionRefresher\";\nimport { type DmkError } from \"./Error\";\n\n/**\n * The main class to interact with the Device Management Kit.\n *\n * NB: do not instantiate this class directly, instead, use `LedgerDMKBuilder`.\n */\nexport class DeviceManagementKit {\n readonly container: Container;\n /** @internal */\n constructor({\n stub,\n transports,\n loggers,\n config,\n }: Partial<MakeContainerProps> = {}) {\n // NOTE: MakeContainerProps might not be the exact type here\n // For the init of the project this is sufficient, but we might need to\n // update the constructor arguments as we go (we might have more than just the container config)\n this.container = makeContainer({\n stub,\n transports,\n loggers,\n config,\n });\n }\n\n /**\n * Returns a promise resolving to the version of the SDK.\n */\n getVersion(): Promise<string> {\n return this.container\n .get<GetDmkVersionUseCase>(configTypes.GetDmkVersionUseCase)\n .getDmkVersion();\n }\n\n /**\n * Starts discovering devices connected.\n *\n * For the WeHID implementation, this use-case needs to be called as a result\n * of an user interaction (button \"click\" event for ex).\n *\n * @param {StartDiscoveringUseCaseArgs} args - The transport to use for discover, or undefined to discover from all transports.\n * @returns {Observable<DiscoveredDevice>} An observable of discovered devices.\n */\n startDiscovering(\n args: StartDiscoveringUseCaseArgs,\n ): Observable<DiscoveredDevice> {\n return this.container\n .get<StartDiscoveringUseCase>(discoveryTypes.StartDiscoveringUseCase)\n .execute(args);\n }\n\n /**\n * Stops discovering devices connected.\n */\n stopDiscovering() {\n return this.container\n .get<StopDiscoveringUseCase>(discoveryTypes.StopDiscoveringUseCase)\n .execute();\n }\n\n /**\n * Listen to list of known discovered devices (and later BLE).\n * @param {ListenToAvailableDevicesUseCaseArgs} args - The transport to use for discover, or undefined to discover from all transports.\n * @returns {Observable<DiscoveredDevice[]>} An observable of known discovered devices.\n */\n listenToAvailableDevices(\n args: ListenToAvailableDevicesUseCaseArgs,\n ): Observable<DiscoveredDevice[]> {\n return this.container\n .get<ListenToAvailableDevicesUseCase>(\n discoveryTypes.ListenToAvailableDevicesUseCase,\n )\n .execute(args);\n }\n\n /**\n * Reconnects a device session by disconnecting and reconnecting to the device.\n *\n * @param args - The arguments for reconnecting the device session.\n * - `device`: The connected device.\n * - `sessionRefresherOptions` (optional): Configuration for session refreshing.\n * - `isRefresherDisabled`: Whether the refresher is disabled.\n * - `pollingInterval`: The refresh interval in milliseconds\n * @returns The session ID to use for further communication with the device.\n */\n async reconnect(args: ReconnectUseCaseArgs): Promise<DeviceSessionId> {\n return this.container\n .get<ReconnectUseCase>(discoveryTypes.ReconnectUseCase)\n .execute(args);\n }\n\n /**\n * Connects to a device previously discovered with `DeviceManagementKit.startDiscovering`.\n * Creates a new device session which:\n * - Represents the connection to the device.\n * - Is terminated upon disconnection of the device.\n * - Exposes the device state through an observable (see `DeviceManagementKit.getDeviceSessionState`)\n * - Should be used for all subsequent communication with the device.\n *\n * @param {ConnectUseCaseArgs} args - The arguments for connecting to the device.\n * - `device`: The discovered device obtained from `StartDiscoveringUseCase`.\n * - `sessionRefresherOptions` (optional): Configuration for session refreshing.\n * - `isRefresherDisabled`: Whether the refresher is disabled.\n * - `pollingInterval`: The refresh interval in milliseconds\n * @returns The session ID to use for further communication with the device.\n */\n connect(args: ConnectUseCaseArgs): Promise<DeviceSessionId> {\n return this.container\n .get<ConnectUseCase>(discoveryTypes.ConnectUseCase)\n .execute(args);\n }\n\n /**\n * Disconnects to a discovered device.\n *\n * @param {DisconnectUseCaseArgs} args - The session ID to disconnect.\n */\n disconnect(args: DisconnectUseCaseArgs): Promise<void> {\n return this.container\n .get<DisconnectUseCase>(discoveryTypes.DisconnectUseCase)\n .execute(args);\n }\n\n /**\n * Sends an APDU command to a device through a device session.\n *\n * @param {SendApduUseCaseArgs} args - The device session ID and APDU command to send.\n */\n sendApdu(args: SendApduUseCaseArgs): Promise<ApduResponse> {\n return this.container\n .get<SendApduUseCase>(sendTypes.SendApduUseCase)\n .execute(args);\n }\n\n /**\n * Sends a command to a device through a device session.\n *\n * @param {SendCommandUseCaseArgs<Response, Args, ErrorCodes>} args - The device session ID, command, command error codes and command parameters to send.\n * @returns A promise resolving with the response from the command.\n */\n sendCommand<Response, Args, ErrorCodes>(\n args: SendCommandUseCaseArgs<Response, Args, ErrorCodes>,\n ): Promise<CommandResult<Response, ErrorCodes>> {\n return this.container\n .get<SendCommandUseCase>(commandTypes.SendCommandUseCase)\n .execute(args);\n }\n\n executeDeviceAction<\n Output,\n Input,\n Error extends DmkError,\n IntermediateValue extends DeviceActionIntermediateValue,\n >(\n args: ExecuteDeviceActionUseCaseArgs<\n Output,\n Input,\n Error,\n IntermediateValue\n >,\n ): ExecuteDeviceActionReturnType<Output, Error, IntermediateValue> {\n return this.container\n .get<ExecuteDeviceActionUseCase>(\n deviceActionTypes.ExecuteDeviceActionUseCase,\n )\n .execute(args);\n }\n\n /**\n * Gets the connected from its device session ID.\n *\n * @param {GetConnectedDeviceUseCaseArgs} args - The device session ID.\n * @returns {ConnectedDevice} The connected device.\n */\n getConnectedDevice(args: GetConnectedDeviceUseCaseArgs): ConnectedDevice {\n return this.container\n .get<GetConnectedDeviceUseCase>(discoveryTypes.GetConnectedDeviceUseCase)\n .execute(args);\n }\n\n /**\n * Gets the device state of a session.\n *\n * @param {{ sessionId: DeviceSessionId }} args - The device session ID.\n * @returns {Observable<DeviceSessionState>} An observable of the session device state.\n */\n getDeviceSessionState(args: {\n sessionId: DeviceSessionId;\n }): Observable<DeviceSessionState> {\n return this.container\n .get<GetDeviceSessionStateUseCase>(\n deviceSessionTypes.GetDeviceSessionStateUseCase,\n )\n .execute(args);\n }\n\n /**\n * Close the Device Management kit.\n *\n */\n close() {\n return this.container\n .get<CloseSessionsUseCase>(deviceSessionTypes.CloseSessionsUseCase)\n .execute();\n }\n\n /**\n * Lists all connected devices.\n *\n * @returns {ConnectedDevice[]} The list of device sessions.\n */\n listConnectedDevices(): ConnectedDevice[] {\n return this.container\n .get<ListConnectedDevicesUseCase>(\n discoveryTypes.ListConnectedDevicesUseCase,\n )\n .execute();\n }\n\n /**\n * Listen to connected device.\n *\n * @returns {Observable<ConnectedDevice>} An observable of connected device.\n */\n listenToConnectedDevice(): Observable<ConnectedDevice> {\n return this.container\n .get<ListenToConnectedDeviceUseCase>(\n discoveryTypes.ListenToConnectedDeviceUseCase,\n )\n .execute();\n }\n\n /**\n * Disable the device session refresher.\n *\n * @param {DisableDeviceSessionRefresherUseCaseArgs} args - The device session ID and a string to identify the blocker.\n * @returns {() => void} A function to reenable the device session refresher.\n */\n disableDeviceSessionRefresher(args: {\n sessionId: DeviceSessionId;\n blockerId: string;\n }): () => void {\n return this.container\n .get<DisableDeviceSessionRefresherUseCase>(\n deviceSessionTypes.DisableDeviceSessionRefresherUseCase,\n )\n .execute(args);\n }\n /**\n * Sets the provider for the manager API.\n *\n * @param {number} provider - The provider to set.\n */\n setProvider(provider: number): void {\n return this.container\n .get<SetProviderUseCase>(managerApiTypes.SetProviderUseCase)\n .execute(provider);\n }\n\n /**\n * Returns the current provider value from the manager API data source.\n */\n getProvider(): number {\n return this.container\n .get<ManagerApiDataSource>(managerApiTypes.ManagerApiDataSource)\n .getProvider();\n }\n\n /**\n * Check if the current environment is supported by any transport.\n */\n isEnvironmentSupported(): boolean {\n return this.container\n .get<TransportService>(transportDiTypes.TransportService)\n .getAllTransports()\n .some((transport) => transport.isSupported());\n }\n\n /**\n * Returns the DMK logger factory with configured logger subscribers.\n */\n getLoggerFactory(): Factory<LoggerPublisherService> {\n return this.container.get(loggerTypes.LoggerPublisherServiceFactory);\n }\n}\n"],
|
|
5
|
+
"mappings": "AAGA,OAAS,gBAAAA,MAAoB,+BAuB7B,OAAS,eAAAC,MAAmB,kCAE5B,OAAS,sBAAAC,MAA0B,iDAGnC,OAAS,kBAAAC,MAAsB,wCAgB/B,OAAS,eAAAC,MAAmB,4CAE5B,OAAS,mBAAAC,MAAuB,2CAEhC,OAAS,aAAAC,MAAiB,8BAE1B,OAAS,oBAAAC,MAAwB,0CAEjC,OAAS,iBAAAC,MAA8C,eAMvD,OAAS,qBAAAC,MAAyB,uCAS3B,MAAMC,CAAoB,CACtB,UAET,YAAY,CACV,KAAAC,EACA,WAAAC,EACA,QAAAC,EACA,OAAAC,CACF,EAAiC,CAAC,EAAG,CAInC,KAAK,UAAYN,EAAc,CAC7B,KAAAG,EACA,WAAAC,EACA,QAAAC,EACA,OAAAC,CACF,CAAC,CACH,CAKA,YAA8B,CAC5B,OAAO,KAAK,UACT,IAA0Bb,EAAY,oBAAoB,EAC1D,cAAc,CACnB,CAWA,iBACEc,EAC8B,CAC9B,OAAO,KAAK,UACT,IAA6BZ,EAAe,uBAAuB,EACnE,QAAQY,CAAI,CACjB,CAKA,iBAAkB,CAChB,OAAO,KAAK,UACT,IAA4BZ,EAAe,sBAAsB,EACjE,QAAQ,CACb,CAOA,yBACEY,EACgC,CAChC,OAAO,KAAK,UACT,IACCZ,EAAe,+BACjB,EACC,QAAQY,CAAI,CACjB,CAYA,MAAM,UAAUA,EAAsD,CACpE,OAAO,KAAK,UACT,IAAsBZ,EAAe,gBAAgB,EACrD,QAAQY,CAAI,CACjB,CAiBA,QAAQA,EAAoD,CAC1D,OAAO,KAAK,UACT,IAAoBZ,EAAe,cAAc,EACjD,QAAQY,CAAI,CACjB,CAOA,WAAWA,EAA4C,CACrD,OAAO,KAAK,UACT,IAAuBZ,EAAe,iBAAiB,EACvD,QAAQY,CAAI,CACjB,CAOA,SAASA,EAAkD,CACzD,OAAO,KAAK,UACT,IAAqBT,EAAU,eAAe,EAC9C,QAAQS,CAAI,CACjB,CAQA,YACEA,EAC8C,CAC9C,OAAO,KAAK,UACT,IAAwBf,EAAa,kBAAkB,EACvD,QAAQe,CAAI,CACjB,CAEA,oBAMEA,EAMiE,CACjE,OAAO,KAAK,UACT,IACCN,EAAkB,0BACpB,EACC,QAAQM,CAAI,CACjB,CAQA,mBAAmBA,EAAsD,CACvE,OAAO,KAAK,UACT,IAA+BZ,EAAe,yBAAyB,EACvE,QAAQY,CAAI,CACjB,CAQA,sBAAsBA,EAEa,CACjC,OAAO,KAAK,UACT,IACCb,EAAmB,4BACrB,EACC,QAAQa,CAAI,CACjB,CAMA,OAAQ,CACN,OAAO,KAAK,UACT,IAA0Bb,EAAmB,oBAAoB,EACjE,QAAQ,CACb,CAOA,sBAA0C,CACxC,OAAO,KAAK,UACT,IACCC,EAAe,2BACjB,EACC,QAAQ,CACb,CAOA,yBAAuD,CACrD,OAAO,KAAK,UACT,IACCA,EAAe,8BACjB,EACC,QAAQ,CACb,CAQA,8BAA8BY,EAGf,CACb,OAAO,KAAK,UACT,IACCb,EAAmB,oCACrB,EACC,QAAQa,CAAI,CACjB,CAMA,YAAYC,EAAwB,CAClC,OAAO,KAAK,UACT,IAAwBX,EAAgB,kBAAkB,EAC1D,QAAQW,CAAQ,CACrB,CAKA,aAAsB,CACpB,OAAO,KAAK,UACT,IAA0BX,EAAgB,oBAAoB,EAC9D,YAAY,CACjB,CAKA,wBAAkC,CAChC,OAAO,KAAK,UACT,IAAsBE,EAAiB,gBAAgB,EACvD,iBAAiB,EACjB,KAAMU,GAAcA,EAAU,YAAY,CAAC,CAChD,CAKA,kBAAoD,CAClD,OAAO,KAAK,UAAU,IAAIb,EAAY,6BAA6B,CACrE,CACF",
|
|
6
|
+
"names": ["commandTypes", "configTypes", "deviceSessionTypes", "discoveryTypes", "loggerTypes", "managerApiTypes", "sendTypes", "transportDiTypes", "makeContainer", "deviceActionTypes", "DeviceManagementKit", "stub", "transports", "loggers", "config", "args", "provider", "transport"]
|
|
7
7
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
var s=(
|
|
1
|
+
var s=(l=>(l.None="none",l.UnlockDevice="unlock-device",l.AllowSecureConnection="allow-secure-connection",l.ConfirmOpenApp="confirm-open-app",l.SignTransaction="sign-transaction",l.SignTypedData="sign-typed-data",l.AllowListApps="allow-list-apps",l.VerifyAddress="verify-address",l.SignPersonalMessage="sign-personal-message",l.SignDelegationAuthorization="sign-delegation-authorization",l.Web3ChecksOptIn="web3-checks-opt-in",l.VerifySafeAddress="verify-safe-address",l.RegisterWallet="register-wallet",l))(s||{});export{s as UserInteractionRequired};
|
|
2
2
|
//# sourceMappingURL=UserInteractionRequired.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../../src/api/device-action/model/UserInteractionRequired.ts"],
|
|
4
|
-
"sourcesContent": ["/**\n * The user interaction required on the device to move further in a device action.\n * This is used to inform the users about the action they need to take on the device.\n */\nexport enum UserInteractionRequired {\n None = \"none\",\n UnlockDevice = \"unlock-device\",\n AllowSecureConnection = \"allow-secure-connection\",\n ConfirmOpenApp = \"confirm-open-app\",\n SignTransaction = \"sign-transaction\",\n SignTypedData = \"sign-typed-data\",\n AllowListApps = \"allow-list-apps\",\n VerifyAddress = \"verify-address\",\n SignPersonalMessage = \"sign-personal-message\",\n SignDelegationAuthorization = \"sign-delegation-authorization\",\n Web3ChecksOptIn = \"web3-checks-opt-in\",\n VerifySafeAddress = \"verify-safe-address\",\n}\n"],
|
|
5
|
-
"mappings": "AAIO,IAAKA,OACVA,EAAA,KAAO,OACPA,EAAA,aAAe,gBACfA,EAAA,sBAAwB,0BACxBA,EAAA,eAAiB,mBACjBA,EAAA,gBAAkB,mBAClBA,EAAA,cAAgB,kBAChBA,EAAA,cAAgB,kBAChBA,EAAA,cAAgB,iBAChBA,EAAA,oBAAsB,wBACtBA,EAAA,4BAA8B,gCAC9BA,EAAA,gBAAkB,qBAClBA,EAAA,kBAAoB,
|
|
4
|
+
"sourcesContent": ["/**\n * The user interaction required on the device to move further in a device action.\n * This is used to inform the users about the action they need to take on the device.\n */\nexport enum UserInteractionRequired {\n None = \"none\",\n UnlockDevice = \"unlock-device\",\n AllowSecureConnection = \"allow-secure-connection\",\n ConfirmOpenApp = \"confirm-open-app\",\n SignTransaction = \"sign-transaction\",\n SignTypedData = \"sign-typed-data\",\n AllowListApps = \"allow-list-apps\",\n VerifyAddress = \"verify-address\",\n SignPersonalMessage = \"sign-personal-message\",\n SignDelegationAuthorization = \"sign-delegation-authorization\",\n Web3ChecksOptIn = \"web3-checks-opt-in\",\n VerifySafeAddress = \"verify-safe-address\",\n RegisterWallet = \"register-wallet\",\n}\n"],
|
|
5
|
+
"mappings": "AAIO,IAAKA,OACVA,EAAA,KAAO,OACPA,EAAA,aAAe,gBACfA,EAAA,sBAAwB,0BACxBA,EAAA,eAAiB,mBACjBA,EAAA,gBAAkB,mBAClBA,EAAA,cAAgB,kBAChBA,EAAA,cAAgB,kBAChBA,EAAA,cAAgB,iBAChBA,EAAA,oBAAsB,wBACtBA,EAAA,4BAA8B,gCAC9BA,EAAA,gBAAkB,qBAClBA,EAAA,kBAAoB,sBACpBA,EAAA,eAAiB,kBAbPA,OAAA",
|
|
6
6
|
"names": ["UserInteractionRequired"]
|
|
7
7
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{UnknownDAError as
|
|
1
|
+
import{UnknownDAError as d}from"../../device-action/os/Errors";import{DeviceSessionStateType as u}from"../../device-session/DeviceSessionState";class M{constructor(e,t){this.api=e;this.args=t;this.deviceModel=e.getDeviceModel()}deviceModel;run(){const e=this.api.getDeviceSessionState();if(e.sessionStateType===u.Connected)return{error:new d("Invalid device state")};const{firmwareUpdateContext:t,customImage:r,firmwareVersion:o,installedLanguages:n,installedApps:a}=e;if(t===void 0||r===void 0||o===void 0||n===void 0)return{error:new d("Device metadata not fetched")};const{blockSize:i,totalMemoryBlocks:l}=this.getMemoryConstants(o),c=this.getCurrentMemoryBlocksUsage({firmwareUpdateContext:t,customImage:r,installedApps:a,installedLanguages:n,blockSize:i}),m=this.getInstallPlanMemoryBlocksUsage(this.args.installPlan,i);return{outOfMemory:c+m>l}}getMemoryConstants(e){const t=this.deviceModel.getBlockSize({firmwareVersion:e.os}),r=Math.floor(this.deviceModel.memorySize/t);return{blockSize:t,totalMemoryBlocks:r}}getCurrentMemoryBlocksUsage({firmwareUpdateContext:e,customImage:t,installedApps:r,installedLanguages:o,blockSize:n}){const a=s=>Math.ceil(s/n),i=a(e.currentFirmware.bytes||0),l=a(t.size||0),c=r.reduce((s,p)=>s+a(p.bytes||0),0),m=o.reduce((s,p)=>s+a(p.size),0);return i+l+c+m}getInstallPlanMemoryBlocksUsage(e,t){const r=o=>Math.ceil(o/t);return e.reduce((o,n)=>o+r(n.bytes||0),0)}}export{M as PredictOutOfMemoryTask};
|
|
2
2
|
//# sourceMappingURL=PredictOutOfMemoryTask.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../../src/api/device-action/task/PredictOutOfMemoryTask.ts"],
|
|
4
|
-
"sourcesContent": ["import type { InternalApi } from \"@api/device-action/DeviceAction\";\nimport { UnknownDAError } from \"@api/device-action/os/Errors\";\nimport { DeviceSessionStateType } from \"@api/device-session/DeviceSessionState\";\nimport type { Application } from \"@internal/manager-api/model/Application\";\n\nexport type PredictOutOfMemoryTaskArgs = {\n installPlan: Application[];\n};\n\nexport type PredictOutOfMemoryTaskResult =\n | {\n outOfMemory: boolean;\n }\n | {\n error: UnknownDAError;\n };\n\nexport class PredictOutOfMemoryTask {\n private readonly
|
|
5
|
-
"mappings": "AACA,OAAS,kBAAAA,MAAsB,+
|
|
6
|
-
"names": ["UnknownDAError", "DeviceSessionStateType", "PredictOutOfMemoryTask", "api", "args", "
|
|
4
|
+
"sourcesContent": ["import type { InternalApi } from \"@api/device-action/DeviceAction\";\nimport { UnknownDAError } from \"@api/device-action/os/Errors\";\nimport { type TransportDeviceModel } from \"@api/device-model/model/DeviceModel\";\nimport {\n type CustomImage,\n DeviceSessionStateType,\n type FirmwareUpdateContext,\n type FirmwareVersion,\n type InstalledLanguagePackage,\n} from \"@api/device-session/DeviceSessionState\";\nimport type { Application } from \"@internal/manager-api/model/Application\";\n\nexport type PredictOutOfMemoryTaskArgs = {\n installPlan: Application[];\n};\n\nexport type PredictOutOfMemoryTaskResult =\n | {\n outOfMemory: boolean;\n }\n | {\n error: UnknownDAError;\n };\n\nexport class PredictOutOfMemoryTask {\n private readonly deviceModel: TransportDeviceModel;\n\n constructor(\n private readonly api: InternalApi,\n private readonly args: PredictOutOfMemoryTaskArgs,\n ) {\n this.deviceModel = api.getDeviceModel();\n }\n\n run(): PredictOutOfMemoryTaskResult {\n const deviceState = this.api.getDeviceSessionState();\n\n if (deviceState.sessionStateType === DeviceSessionStateType.Connected) {\n return { error: new UnknownDAError(\"Invalid device state\") };\n }\n\n const {\n firmwareUpdateContext,\n customImage,\n firmwareVersion,\n installedLanguages,\n installedApps,\n } = deviceState;\n\n if (\n firmwareUpdateContext === undefined ||\n customImage === undefined ||\n firmwareVersion === undefined ||\n installedLanguages === undefined\n ) {\n return { error: new UnknownDAError(\"Device metadata not fetched\") };\n }\n\n const { blockSize, totalMemoryBlocks } =\n this.getMemoryConstants(firmwareVersion);\n\n const currentMemoryBlocksUsage = this.getCurrentMemoryBlocksUsage({\n firmwareUpdateContext,\n customImage,\n installedApps,\n installedLanguages,\n blockSize,\n });\n\n const installPlanBlocksUsage = this.getInstallPlanMemoryBlocksUsage(\n this.args.installPlan,\n blockSize,\n );\n\n return {\n outOfMemory:\n currentMemoryBlocksUsage + installPlanBlocksUsage > totalMemoryBlocks,\n };\n }\n\n private getMemoryConstants(firmwareVersion: FirmwareVersion): {\n blockSize: number;\n totalMemoryBlocks: number;\n } {\n const blockSize = this.deviceModel.getBlockSize({\n firmwareVersion: firmwareVersion.os,\n });\n const totalMemoryBlocks = Math.floor(\n this.deviceModel.memorySize / blockSize,\n );\n return { blockSize, totalMemoryBlocks };\n }\n\n private getCurrentMemoryBlocksUsage({\n firmwareUpdateContext,\n customImage,\n installedApps,\n installedLanguages,\n blockSize,\n }: {\n firmwareUpdateContext: FirmwareUpdateContext;\n customImage: CustomImage;\n installedApps: Application[];\n installedLanguages: InstalledLanguagePackage[];\n blockSize: number;\n }): number {\n const bytesToBlocks = (size: number) => Math.ceil(size / blockSize);\n const firmwareBlocks = bytesToBlocks(\n firmwareUpdateContext.currentFirmware.bytes || 0,\n );\n const customImageBlocks = bytesToBlocks(customImage.size || 0);\n const applicationsBlocks = installedApps.reduce(\n (size, app) => size + bytesToBlocks(app.bytes || 0),\n 0,\n );\n const languagesBlocks = installedLanguages.reduce(\n (size, lang) => size + bytesToBlocks(lang.size),\n 0,\n );\n return (\n firmwareBlocks + customImageBlocks + applicationsBlocks + languagesBlocks\n );\n }\n\n private getInstallPlanMemoryBlocksUsage(\n installPlan: Application[],\n blockSize: number,\n ): number {\n const bytesToBlocks = (size: number) => Math.ceil(size / blockSize);\n return installPlan.reduce(\n (size, app) => size + bytesToBlocks(app.bytes || 0),\n 0,\n );\n }\n}\n"],
|
|
5
|
+
"mappings": "AACA,OAAS,kBAAAA,MAAsB,+BAE/B,OAEE,0BAAAC,MAIK,yCAeA,MAAMC,CAAuB,CAGlC,YACmBC,EACAC,EACjB,CAFiB,SAAAD,EACA,UAAAC,EAEjB,KAAK,YAAcD,EAAI,eAAe,CACxC,CAPiB,YASjB,KAAoC,CAClC,MAAME,EAAc,KAAK,IAAI,sBAAsB,EAEnD,GAAIA,EAAY,mBAAqBJ,EAAuB,UAC1D,MAAO,CAAE,MAAO,IAAID,EAAe,sBAAsB,CAAE,EAG7D,KAAM,CACJ,sBAAAM,EACA,YAAAC,EACA,gBAAAC,EACA,mBAAAC,EACA,cAAAC,CACF,EAAIL,EAEJ,GACEC,IAA0B,QAC1BC,IAAgB,QAChBC,IAAoB,QACpBC,IAAuB,OAEvB,MAAO,CAAE,MAAO,IAAIT,EAAe,6BAA6B,CAAE,EAGpE,KAAM,CAAE,UAAAW,EAAW,kBAAAC,CAAkB,EACnC,KAAK,mBAAmBJ,CAAe,EAEnCK,EAA2B,KAAK,4BAA4B,CAChE,sBAAAP,EACA,YAAAC,EACA,cAAAG,EACA,mBAAAD,EACA,UAAAE,CACF,CAAC,EAEKG,EAAyB,KAAK,gCAClC,KAAK,KAAK,YACVH,CACF,EAEA,MAAO,CACL,YACEE,EAA2BC,EAAyBF,CACxD,CACF,CAEQ,mBAAmBJ,EAGzB,CACA,MAAMG,EAAY,KAAK,YAAY,aAAa,CAC9C,gBAAiBH,EAAgB,EACnC,CAAC,EACKI,EAAoB,KAAK,MAC7B,KAAK,YAAY,WAAaD,CAChC,EACA,MAAO,CAAE,UAAAA,EAAW,kBAAAC,CAAkB,CACxC,CAEQ,4BAA4B,CAClC,sBAAAN,EACA,YAAAC,EACA,cAAAG,EACA,mBAAAD,EACA,UAAAE,CACF,EAMW,CACT,MAAMI,EAAiBC,GAAiB,KAAK,KAAKA,EAAOL,CAAS,EAC5DM,EAAiBF,EACrBT,EAAsB,gBAAgB,OAAS,CACjD,EACMY,EAAoBH,EAAcR,EAAY,MAAQ,CAAC,EACvDY,EAAqBT,EAAc,OACvC,CAACM,EAAMI,IAAQJ,EAAOD,EAAcK,EAAI,OAAS,CAAC,EAClD,CACF,EACMC,EAAkBZ,EAAmB,OACzC,CAACO,EAAMM,IAASN,EAAOD,EAAcO,EAAK,IAAI,EAC9C,CACF,EACA,OACEL,EAAiBC,EAAoBC,EAAqBE,CAE9D,CAEQ,gCACNE,EACAZ,EACQ,CACR,MAAMI,EAAiBC,GAAiB,KAAK,KAAKA,EAAOL,CAAS,EAClE,OAAOY,EAAY,OACjB,CAACP,EAAMI,IAAQJ,EAAOD,EAAcK,EAAI,OAAS,CAAC,EAClD,CACF,CACF,CACF",
|
|
6
|
+
"names": ["UnknownDAError", "DeviceSessionStateType", "PredictOutOfMemoryTask", "api", "args", "deviceState", "firmwareUpdateContext", "customImage", "firmwareVersion", "installedLanguages", "installedApps", "blockSize", "totalMemoryBlocks", "currentMemoryBlocksUsage", "installPlanBlocksUsage", "bytesToBlocks", "size", "firmwareBlocks", "customImageBlocks", "applicationsBlocks", "app", "languagesBlocks", "lang", "installPlan"]
|
|
7
7
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{DeviceStatus as n}from"../../device/DeviceStatus";import{makeDeviceActionInternalApiMock as
|
|
1
|
+
import i from"semver";import{DeviceStatus as n}from"../../device/DeviceStatus";import{makeDeviceActionInternalApiMock as c}from"../../device-action/__test-utils__/makeInternalApi";import{UnknownDAError as r}from"../../device-action/os/Errors";import{DeviceSessionStateType as s}from"../../device-session/DeviceSessionState";import{PredictOutOfMemoryTask as a}from"./PredictOutOfMemoryTask";describe("PredictOutOfMemoryTask",()=>{const e=c();beforeEach(()=>{vi.clearAllMocks(),e.getDeviceModel.mockReturnValue({memorySize:1569792,getBlockSize:()=>32})}),it("Success enough memory",()=>{e.getDeviceSessionState.mockReturnValueOnce({sessionStateType:s.ReadyWithoutSecureChannel,deviceStatus:n.CONNECTED,firmwareUpdateContext:{currentFirmware:{bytes:397824}},customImage:{size:51893},installedApps:[{bytes:305442},{bytes:514598},{bytes:271583}],installedLanguages:[{id:1,size:20480}],firmwareVersion:{os:"2.0.0"}});const t=new a(e,{installPlan:[{bytes:1324},{bytes:6559}]}).run();expect(t).toStrictEqual({outOfMemory:!1})}),it("Success not enough memory",()=>{e.getDeviceSessionState.mockReturnValueOnce({sessionStateType:s.ReadyWithoutSecureChannel,deviceStatus:n.CONNECTED,firmwareUpdateContext:{currentFirmware:{bytes:397824}},customImage:{size:51893},installedApps:[{bytes:305442},{bytes:514598},{bytes:271583}],installedLanguages:[{id:1,size:20480}],firmwareVersion:{os:"2.0.0"}});const t=new a(e,{installPlan:[{bytes:1324},{bytes:6559},{bytes:1}]}).run();expect(t).toStrictEqual({outOfMemory:!0})}),it("Success enough memory (recent Nano S, 2kB block size)",()=>{e.getDeviceModel.mockReturnValueOnce({memorySize:12*1024,getBlockSize:({firmwareVersion:o})=>i.lt(i.coerce(o)??"","2.0.0")?4*1024:2*1024}),e.getDeviceSessionState.mockReturnValueOnce({sessionStateType:s.ReadyWithoutSecureChannel,deviceStatus:n.CONNECTED,firmwareUpdateContext:{currentFirmware:{bytes:6*1024}},customImage:{size:0},installedApps:[],installedLanguages:[],firmwareVersion:{os:"2.0.0"}});const t=new a(e,{installPlan:[{bytes:6*1024}]}).run();expect(t).toStrictEqual({outOfMemory:!1})}),it("Success not enough memory (old Nano S, 4kB block size)",()=>{e.getDeviceModel.mockReturnValueOnce({memorySize:12*1024,getBlockSize:({firmwareVersion:o})=>i.lt(i.coerce(o)??"","2.0.0")?4*1024:2*1024}),e.getDeviceSessionState.mockReturnValueOnce({sessionStateType:s.ReadyWithoutSecureChannel,deviceStatus:n.CONNECTED,firmwareUpdateContext:{currentFirmware:{bytes:6*1024}},customImage:{size:0},installedApps:[],installedLanguages:[],firmwareVersion:{os:"1.0.0"}});const t=new a(e,{installPlan:[{bytes:6*1024}]}).run();expect(t).toStrictEqual({outOfMemory:!0})}),it("Success undefined sizes",()=>{e.getDeviceSessionState.mockReturnValueOnce({sessionStateType:s.ReadyWithoutSecureChannel,deviceStatus:n.CONNECTED,firmwareUpdateContext:{currentFirmware:{bytes:397824}},customImage:{},installedApps:[{bytes:305442},{bytes:null},{bytes:271583}],installedLanguages:[],firmwareVersion:{os:"2.0.0"}});const t=new a(e,{installPlan:[{bytes:1324},{bytes:6559}]}).run();expect(t).toStrictEqual({outOfMemory:!1})}),it("Error when device is in incorrect state",()=>{e.getDeviceSessionState.mockReturnValueOnce({sessionStateType:s.Connected,deviceStatus:n.CONNECTED});const t=new a(e,{installPlan:[{bytes:1324}]}).run();expect(t).toStrictEqual({error:new r("Invalid device state")})}),it("Error when device session was not populated",()=>{e.getDeviceSessionState.mockReturnValueOnce({sessionStateType:s.ReadyWithoutSecureChannel,deviceStatus:n.CONNECTED,installedApps:[]});const t=new a(e,{installPlan:[{bytes:1324}]}).run();expect(t).toStrictEqual({error:new r("Device metadata not fetched")})})});
|
|
2
2
|
//# sourceMappingURL=PredictOutOfMemoryTask.test.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../../src/api/device-action/task/PredictOutOfMemoryTask.test.ts"],
|
|
4
|
-
"sourcesContent": ["import { DeviceStatus } from \"@api/device/DeviceStatus\";\nimport { makeDeviceActionInternalApiMock } from \"@api/device-action/__test-utils__/makeInternalApi\";\nimport { UnknownDAError } from \"@api/device-action/os/Errors\";\nimport type { TransportDeviceModel } from \"@api/device-model/model/DeviceModel\";\nimport type { DeviceSessionState } from \"@api/device-session/DeviceSessionState\";\nimport { DeviceSessionStateType } from \"@api/device-session/DeviceSessionState\";\nimport type { Application } from \"@internal/manager-api/model/Application\";\nimport type { FinalFirmware } from \"@internal/manager-api/model/Firmware\";\n\nimport { PredictOutOfMemoryTask } from \"./PredictOutOfMemoryTask\";\n\ndescribe(\"PredictOutOfMemoryTask\", () => {\n const apiMock = makeDeviceActionInternalApiMock();\n\n beforeEach(() => {\n vi.clearAllMocks();\n apiMock.getDeviceModel.mockReturnValue({\n memorySize: 1569792,\n
|
|
5
|
-
"mappings": "AAAA,OAAS,
|
|
6
|
-
"names": ["DeviceStatus", "makeDeviceActionInternalApiMock", "UnknownDAError", "DeviceSessionStateType", "PredictOutOfMemoryTask", "apiMock", "result"]
|
|
4
|
+
"sourcesContent": ["import semver from \"semver\";\n\nimport { DeviceStatus } from \"@api/device/DeviceStatus\";\nimport { makeDeviceActionInternalApiMock } from \"@api/device-action/__test-utils__/makeInternalApi\";\nimport { UnknownDAError } from \"@api/device-action/os/Errors\";\nimport type { TransportDeviceModel } from \"@api/device-model/model/DeviceModel\";\nimport type { DeviceSessionState } from \"@api/device-session/DeviceSessionState\";\nimport { DeviceSessionStateType } from \"@api/device-session/DeviceSessionState\";\nimport type { Application } from \"@internal/manager-api/model/Application\";\nimport type { FinalFirmware } from \"@internal/manager-api/model/Firmware\";\n\nimport { PredictOutOfMemoryTask } from \"./PredictOutOfMemoryTask\";\n\ndescribe(\"PredictOutOfMemoryTask\", () => {\n const apiMock = makeDeviceActionInternalApiMock();\n\n beforeEach(() => {\n vi.clearAllMocks();\n apiMock.getDeviceModel.mockReturnValue({\n memorySize: 1569792,\n getBlockSize: () => 32,\n } as unknown as TransportDeviceModel);\n });\n\n it(\"Success enough memory\", () => {\n // GIVEN\n apiMock.getDeviceSessionState.mockReturnValueOnce({\n sessionStateType: DeviceSessionStateType.ReadyWithoutSecureChannel,\n deviceStatus: DeviceStatus.CONNECTED,\n firmwareUpdateContext: {\n currentFirmware: { bytes: 397824 } as FinalFirmware,\n },\n customImage: { size: 51893 },\n installedApps: [\n { bytes: 305442 },\n { bytes: 514598 },\n { bytes: 271583 },\n ] as unknown as Application[],\n installedLanguages: [{ id: 1, size: 20480 }],\n firmwareVersion: { os: \"2.0.0\" },\n } as unknown as DeviceSessionState);\n\n // WHEN\n const result = new PredictOutOfMemoryTask(apiMock, {\n installPlan: [\n { bytes: 1324 },\n { bytes: 6559 },\n ] as unknown as Application[],\n }).run();\n\n // THEN\n expect(result).toStrictEqual({\n outOfMemory: false,\n });\n });\n\n it(\"Success not enough memory\", () => {\n // GIVEN\n apiMock.getDeviceSessionState.mockReturnValueOnce({\n sessionStateType: DeviceSessionStateType.ReadyWithoutSecureChannel,\n deviceStatus: DeviceStatus.CONNECTED,\n firmwareUpdateContext: {\n currentFirmware: { bytes: 397824 } as FinalFirmware,\n },\n customImage: { size: 51893 },\n installedApps: [\n { bytes: 305442 },\n { bytes: 514598 },\n { bytes: 271583 },\n ] as unknown as Application[],\n installedLanguages: [{ id: 1, size: 20480 }],\n firmwareVersion: { os: \"2.0.0\" },\n } as unknown as DeviceSessionState);\n\n // WHEN\n const result = new PredictOutOfMemoryTask(apiMock, {\n installPlan: [\n { bytes: 1324 },\n { bytes: 6559 },\n { bytes: 1 },\n ] as unknown as Application[],\n }).run();\n\n // THEN\n expect(result).toStrictEqual({\n outOfMemory: true,\n });\n });\n\n it(\"Success enough memory (recent Nano S, 2kB block size)\", () => {\n // GIVEN\n apiMock.getDeviceModel.mockReturnValueOnce({\n memorySize: 12 * 1024,\n getBlockSize: ({ firmwareVersion }: { firmwareVersion: string }) => {\n return semver.lt(semver.coerce(firmwareVersion) ?? \"\", \"2.0.0\")\n ? 4 * 1024\n : 2 * 1024;\n },\n } as unknown as TransportDeviceModel);\n\n apiMock.getDeviceSessionState.mockReturnValueOnce({\n sessionStateType: DeviceSessionStateType.ReadyWithoutSecureChannel,\n deviceStatus: DeviceStatus.CONNECTED,\n firmwareUpdateContext: {\n currentFirmware: { bytes: 6 * 1024 } as FinalFirmware,\n },\n customImage: { size: 0 },\n installedApps: [],\n installedLanguages: [],\n firmwareVersion: { os: \"2.0.0\" },\n } as unknown as DeviceSessionState);\n\n // WHEN\n const result = new PredictOutOfMemoryTask(apiMock, {\n installPlan: [{ bytes: 6 * 1024 }] as unknown as Application[],\n }).run();\n\n // THEN\n // 6x2kB blocks of total memory (12kB total)\n // -3*2kB block for firmware (to fit 6kB)\n // -3*2kB block for install plan (to fit 6kB)\n // = 0 blocks left, enough memory\n expect(result).toStrictEqual({\n outOfMemory: false,\n });\n });\n\n it(\"Success not enough memory (old Nano S, 4kB block size)\", () => {\n // GIVEN\n apiMock.getDeviceModel.mockReturnValueOnce({\n memorySize: 12 * 1024,\n getBlockSize: ({ firmwareVersion }: { firmwareVersion: string }) => {\n return semver.lt(semver.coerce(firmwareVersion) ?? \"\", \"2.0.0\")\n ? 4 * 1024\n : 2 * 1024;\n },\n } as unknown as TransportDeviceModel);\n\n apiMock.getDeviceSessionState.mockReturnValueOnce({\n sessionStateType: DeviceSessionStateType.ReadyWithoutSecureChannel,\n deviceStatus: DeviceStatus.CONNECTED,\n firmwareUpdateContext: {\n currentFirmware: { bytes: 6 * 1024 } as FinalFirmware,\n },\n customImage: { size: 0 },\n installedApps: [],\n installedLanguages: [],\n firmwareVersion: { os: \"1.0.0\" },\n } as unknown as DeviceSessionState);\n\n // WHEN\n const result = new PredictOutOfMemoryTask(apiMock, {\n installPlan: [{ bytes: 6 * 1024 }] as unknown as Application[],\n }).run();\n\n // THEN\n // 3x4kB blocks of total memory (12kB total)\n // -2x4kB block for firmware (to fit 6kB)\n // -2x4kB blocks for install plan (to fit 6kB)\n // = -1 block left, not enough memory\n expect(result).toStrictEqual({\n outOfMemory: true,\n });\n });\n\n it(\"Success undefined sizes\", () => {\n // GIVEN\n apiMock.getDeviceSessionState.mockReturnValueOnce({\n sessionStateType: DeviceSessionStateType.ReadyWithoutSecureChannel,\n deviceStatus: DeviceStatus.CONNECTED,\n firmwareUpdateContext: {\n currentFirmware: { bytes: 397824 } as FinalFirmware,\n },\n customImage: {},\n installedApps: [\n { bytes: 305442 },\n { bytes: null },\n { bytes: 271583 },\n ] as unknown as Application[],\n installedLanguages: [],\n firmwareVersion: { os: \"2.0.0\" },\n } as unknown as DeviceSessionState);\n\n // WHEN\n const result = new PredictOutOfMemoryTask(apiMock, {\n installPlan: [\n { bytes: 1324 },\n { bytes: 6559 },\n ] as unknown as Application[],\n }).run();\n\n // THEN\n expect(result).toStrictEqual({\n outOfMemory: false,\n });\n });\n\n it(\"Error when device is in incorrect state\", () => {\n // GIVEN\n apiMock.getDeviceSessionState.mockReturnValueOnce({\n sessionStateType: DeviceSessionStateType.Connected,\n deviceStatus: DeviceStatus.CONNECTED,\n } as DeviceSessionState);\n\n // WHEN\n const result = new PredictOutOfMemoryTask(apiMock, {\n installPlan: [{ bytes: 1324 }] as unknown as Application[],\n }).run();\n\n // THEN\n expect(result).toStrictEqual({\n error: new UnknownDAError(\"Invalid device state\"),\n });\n });\n\n it(\"Error when device session was not populated\", () => {\n // GIVEN\n apiMock.getDeviceSessionState.mockReturnValueOnce({\n sessionStateType: DeviceSessionStateType.ReadyWithoutSecureChannel,\n deviceStatus: DeviceStatus.CONNECTED,\n installedApps: [],\n } as unknown as DeviceSessionState);\n\n // WHEN\n const result = new PredictOutOfMemoryTask(apiMock, {\n installPlan: [{ bytes: 1324 }] as unknown as Application[],\n }).run();\n\n // THEN\n expect(result).toStrictEqual({\n error: new UnknownDAError(\"Device metadata not fetched\"),\n });\n });\n});\n"],
|
|
5
|
+
"mappings": "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",
|
|
6
|
+
"names": ["semver", "DeviceStatus", "makeDeviceActionInternalApiMock", "UnknownDAError", "DeviceSessionStateType", "PredictOutOfMemoryTask", "apiMock", "result", "firmwareVersion"]
|
|
7
7
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
var n=Object.defineProperty;var v=Object.getOwnPropertyDescriptor;var
|
|
1
|
+
var n=Object.defineProperty;var v=Object.getOwnPropertyDescriptor;var f=(s,e,d)=>e in s?n(s,e,{enumerable:!0,configurable:!0,writable:!0,value:d}):s[e]=d;var m=(s,e,d,t)=>{for(var o=t>1?void 0:t?v(e,d):e,c=s.length-1,l;c>=0;c--)(l=s[c])&&(o=(t?l(e,d,o):l(o))||o);return t&&o&&n(e,d,o),o};var U=(s,e,d)=>f(s,typeof e!="symbol"?e+"":e,d);import{injectable as p}from"inversify";import b from"semver";import{DeviceModelId as r}from"../../device/DeviceModel";import{BleDeviceInfos as y}from"../../device-model/model/BleDeviceInfos";import{TransportDeviceModel as u}from"../../device-model/model/DeviceModel";let i=class{getAllDeviceModels(){return Object.values(i.deviceModelByIds)}getDeviceModel(e){return i.deviceModelByIds[e.id]}filterDeviceModels(e){return this.getAllDeviceModels().filter(d=>Object.entries(e).every(([t,o])=>d[t]===o))}getBluetoothServicesInfos(){return Object.values(i.deviceModelByIds).reduce((e,d)=>{const{bluetoothSpec:t}=d;return t?{...e,...t.reduce((o,c)=>({...o,[c.serviceUuid]:new y(d,c.serviceUuid,c.writeUuid,c.writeCmdUuid,c.notifyUuid)}),{})}:e},{})}getBluetoothServices(){return Object.values(i.deviceModelByIds).map(e=>(e.bluetoothSpec||[]).map(d=>d.serviceUuid)).flat().filter(e=>!!e)}};U(i,"deviceModelByIds",{[r.NANO_S]:new u({id:r.NANO_S,productName:"Ledger Nano S",usbProductId:16,bootloaderUsbProductId:1,usbOnly:!0,memorySize:320*1024,getBlockSize:e=>b.lt(b.coerce(e.firmwareVersion)??"","2.0.0")?4*1024:2*1024,masks:[823132160]}),[r.NANO_SP]:new u({id:r.NANO_SP,productName:"Ledger Nano S Plus",usbProductId:80,bootloaderUsbProductId:5,usbOnly:!0,memorySize:1533*1024,getBlockSize:()=>32,masks:[856686592]}),[r.NANO_X]:new u({id:r.NANO_X,productName:"Ledger Nano X",usbProductId:64,bootloaderUsbProductId:4,usbOnly:!1,memorySize:2*1024*1024,getBlockSize:()=>4*1024,masks:[855638016],bluetoothSpec:[{serviceUuid:"13d63400-2c97-0004-0000-4c6564676572",notifyUuid:"13d63400-2c97-0004-0001-4c6564676572",writeUuid:"13d63400-2c97-0004-0002-4c6564676572",writeCmdUuid:"13d63400-2c97-0004-0003-4c6564676572"}]}),[r.STAX]:new u({id:r.STAX,productName:"Ledger Stax",usbProductId:96,bootloaderUsbProductId:6,usbOnly:!1,memorySize:1533*1024,getBlockSize:()=>32,masks:[857735168],bluetoothSpec:[{serviceUuid:"13d63400-2c97-6004-0000-4c6564676572",notifyUuid:"13d63400-2c97-6004-0001-4c6564676572",writeUuid:"13d63400-2c97-6004-0002-4c6564676572",writeCmdUuid:"13d63400-2c97-6004-0003-4c6564676572"}]}),[r.FLEX]:new u({id:r.FLEX,productName:"Ledger Flex",usbProductId:112,bootloaderUsbProductId:7,usbOnly:!1,memorySize:1533*1024,getBlockSize:()=>32,masks:[858783744],bluetoothSpec:[{serviceUuid:"13d63400-2c97-3004-0000-4c6564676572",notifyUuid:"13d63400-2c97-3004-0001-4c6564676572",writeUuid:"13d63400-2c97-3004-0002-4c6564676572",writeCmdUuid:"13d63400-2c97-3004-0003-4c6564676572"}]}),[r.APEX]:new u({id:r.APEX,productName:"Ledger\xA0Nano\xA0Gen5",usbProductId:128,bootloaderUsbProductId:8,usbOnly:!1,memorySize:1533*1024,getBlockSize:()=>32,masks:[859832320],bluetoothSpec:[{serviceUuid:"13d63400-2c97-8004-0000-4c6564676572",notifyUuid:"13d63400-2c97-8004-0001-4c6564676572",writeUuid:"13d63400-2c97-8004-0002-4c6564676572",writeCmdUuid:"13d63400-2c97-8004-0003-4c6564676572"},{serviceUuid:"13d63400-2c97-9004-0000-4c6564676572",notifyUuid:"13d63400-2c97-9004-0001-4c6564676572",writeUuid:"13d63400-2c97-9004-0002-4c6564676572",writeCmdUuid:"13d63400-2c97-9004-0003-4c6564676572"}]})}),i=m([p()],i);export{i as StaticDeviceModelDataSource};
|
|
2
2
|
//# sourceMappingURL=StaticDeviceModelDataSource.js.map
|