@ledgerhq/device-management-kit 0.9.2 → 0.11.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 +2 -2
- package/lib/cjs/src/api/DeviceManagementKit.test.js +1 -1
- package/lib/cjs/src/api/DeviceManagementKit.test.js.map +2 -2
- package/lib/cjs/src/api/command/Command.js +1 -1
- package/lib/cjs/src/api/command/Command.js.map +1 -1
- package/lib/cjs/src/api/command/Errors.js +1 -1
- package/lib/cjs/src/api/command/Errors.js.map +3 -3
- package/lib/cjs/src/api/command/model/CommandResult.js +1 -1
- package/lib/cjs/src/api/command/model/CommandResult.js.map +2 -2
- package/lib/cjs/src/api/command/os/CloseAppCommand.js +1 -1
- package/lib/cjs/src/api/command/os/CloseAppCommand.js.map +2 -2
- package/lib/cjs/src/api/command/os/CloseAppCommand.test.js +1 -1
- package/lib/cjs/src/api/command/os/CloseAppCommand.test.js.map +2 -2
- package/lib/cjs/src/api/command/os/GetAppAndVersionCommand.js +1 -1
- package/lib/cjs/src/api/command/os/GetAppAndVersionCommand.js.map +2 -2
- package/lib/cjs/src/api/command/os/GetAppAndVersionCommand.test.js +1 -1
- package/lib/cjs/src/api/command/os/GetAppAndVersionCommand.test.js.map +2 -2
- package/lib/cjs/src/api/command/os/GetBatteryStatusCommand.js +1 -1
- package/lib/cjs/src/api/command/os/GetBatteryStatusCommand.js.map +2 -2
- package/lib/cjs/src/api/command/os/GetBatteryStatusCommand.test.js +1 -1
- package/lib/cjs/src/api/command/os/GetBatteryStatusCommand.test.js.map +3 -3
- package/lib/cjs/src/api/command/os/GetCustomImageSizeCommand.js +1 -1
- package/lib/cjs/src/api/command/os/GetCustomImageSizeCommand.js.map +2 -2
- package/lib/cjs/src/api/command/os/GetCustomImageSizeCommand.test.js +1 -1
- package/lib/cjs/src/api/command/os/GetCustomImageSizeCommand.test.js.map +2 -2
- package/lib/cjs/src/api/command/os/GetOsVersionCommand.js +1 -1
- package/lib/cjs/src/api/command/os/GetOsVersionCommand.js.map +2 -2
- package/lib/cjs/src/api/command/os/GetOsVersionCommand.test.js +1 -1
- package/lib/cjs/src/api/command/os/GetOsVersionCommand.test.js.map +2 -2
- package/lib/cjs/src/api/command/os/ListAppsCommand.js +1 -1
- package/lib/cjs/src/api/command/os/ListAppsCommand.js.map +2 -2
- package/lib/cjs/src/api/command/os/ListAppsCommand.test.js +1 -1
- package/lib/cjs/src/api/command/os/ListAppsCommand.test.js.map +2 -2
- package/lib/cjs/src/api/command/os/ListLanguagePackCommand.js +1 -1
- package/lib/cjs/src/api/command/os/ListLanguagePackCommand.js.map +2 -2
- package/lib/cjs/src/api/command/os/ListLanguagePackCommand.test.js +1 -1
- package/lib/cjs/src/api/command/os/ListLanguagePackCommand.test.js.map +2 -2
- package/lib/cjs/src/api/command/os/LoadCertificateCommand.js +1 -1
- package/lib/cjs/src/api/command/os/LoadCertificateCommand.js.map +2 -2
- package/lib/cjs/src/api/command/os/LoadCertificateCommand.test.js +1 -1
- package/lib/cjs/src/api/command/os/LoadCertificateCommand.test.js.map +3 -3
- package/lib/cjs/src/api/command/os/OpenAppCommand.js +1 -1
- package/lib/cjs/src/api/command/os/OpenAppCommand.js.map +2 -2
- package/lib/cjs/src/api/command/os/OpenAppCommand.test.js +1 -1
- package/lib/cjs/src/api/command/os/OpenAppCommand.test.js.map +2 -2
- package/lib/cjs/src/api/command/use-case/SendCommandUseCase.test.js +1 -1
- package/lib/cjs/src/api/command/use-case/SendCommandUseCase.test.js.map +2 -2
- package/lib/cjs/src/api/device-action/os/CallTaskInAppDeviceAction/CallTaskInAppDeviceAction.test.js +1 -1
- package/lib/cjs/src/api/device-action/os/CallTaskInAppDeviceAction/CallTaskInAppDeviceAction.test.js.map +2 -2
- package/lib/cjs/src/api/device-action/os/SendCommandInAppDeviceAction/SendCommandInAppDeviceAction.test.js +1 -1
- package/lib/cjs/src/api/device-action/os/SendCommandInAppDeviceAction/SendCommandInAppDeviceAction.test.js.map +2 -2
- package/lib/cjs/src/api/device-action/task/GetFirmwareMetadataTask.js +1 -1
- package/lib/cjs/src/api/device-action/task/GetFirmwareMetadataTask.js.map +2 -2
- package/lib/cjs/src/api/device-action/task/GetFirmwareMetadataTask.test.js +1 -1
- package/lib/cjs/src/api/device-action/task/GetFirmwareMetadataTask.test.js.map +2 -2
- package/lib/cjs/src/api/index.js +1 -1
- package/lib/cjs/src/api/index.js.map +2 -2
- package/lib/cjs/src/api/transport/model/ConnectedDevice.js +1 -1
- package/lib/cjs/src/api/transport/model/ConnectedDevice.js.map +3 -3
- package/lib/cjs/src/api/transport/model/TransportConnectedDevice.js +1 -1
- package/lib/cjs/src/api/transport/model/TransportConnectedDevice.js.map +3 -3
- package/lib/cjs/src/internal/device-session/model/DeviceSession.js +1 -1
- package/lib/cjs/src/internal/device-session/model/DeviceSession.js.map +2 -2
- package/lib/cjs/src/internal/discovery/di/discoveryModule.js +1 -1
- package/lib/cjs/src/internal/discovery/di/discoveryModule.js.map +3 -3
- package/lib/cjs/src/internal/discovery/di/discoveryModule.test.js +1 -1
- package/lib/cjs/src/internal/discovery/di/discoveryModule.test.js.map +3 -3
- package/lib/cjs/src/internal/discovery/di/discoveryTypes.js +1 -1
- package/lib/cjs/src/internal/discovery/di/discoveryTypes.js.map +2 -2
- package/lib/cjs/src/internal/discovery/use-case/ConnectUseCase.js +1 -1
- package/lib/cjs/src/internal/discovery/use-case/ConnectUseCase.js.map +3 -3
- package/lib/cjs/src/internal/discovery/use-case/ConnectUseCase.test.js +1 -1
- package/lib/cjs/src/internal/discovery/use-case/ConnectUseCase.test.js.map +3 -3
- package/lib/cjs/src/internal/discovery/use-case/DisconnectUseCase.js +1 -1
- package/lib/cjs/src/internal/discovery/use-case/DisconnectUseCase.js.map +3 -3
- package/lib/cjs/src/internal/discovery/use-case/ReconnectUseCase.js +2 -0
- package/lib/cjs/src/internal/discovery/use-case/ReconnectUseCase.js.map +7 -0
- package/lib/cjs/src/internal/discovery/use-case/ReconnectUseCase.test.js +2 -0
- package/lib/cjs/src/internal/discovery/use-case/ReconnectUseCase.test.js.map +7 -0
- package/lib/esm/package.json +1 -1
- package/lib/esm/src/api/DeviceManagementKit.js +1 -1
- package/lib/esm/src/api/DeviceManagementKit.js.map +2 -2
- package/lib/esm/src/api/DeviceManagementKit.test.js +1 -1
- package/lib/esm/src/api/DeviceManagementKit.test.js.map +2 -2
- package/lib/esm/src/api/command/Errors.js +1 -1
- package/lib/esm/src/api/command/Errors.js.map +3 -3
- package/lib/esm/src/api/command/model/CommandResult.js.map +2 -2
- package/lib/esm/src/api/command/os/CloseAppCommand.js +1 -1
- package/lib/esm/src/api/command/os/CloseAppCommand.js.map +2 -2
- package/lib/esm/src/api/command/os/CloseAppCommand.test.js +1 -1
- package/lib/esm/src/api/command/os/CloseAppCommand.test.js.map +2 -2
- package/lib/esm/src/api/command/os/GetAppAndVersionCommand.js +1 -1
- package/lib/esm/src/api/command/os/GetAppAndVersionCommand.js.map +2 -2
- package/lib/esm/src/api/command/os/GetAppAndVersionCommand.test.js +1 -1
- package/lib/esm/src/api/command/os/GetAppAndVersionCommand.test.js.map +2 -2
- package/lib/esm/src/api/command/os/GetBatteryStatusCommand.js +1 -1
- package/lib/esm/src/api/command/os/GetBatteryStatusCommand.js.map +2 -2
- package/lib/esm/src/api/command/os/GetBatteryStatusCommand.test.js +1 -1
- package/lib/esm/src/api/command/os/GetBatteryStatusCommand.test.js.map +3 -3
- package/lib/esm/src/api/command/os/GetCustomImageSizeCommand.js +1 -1
- package/lib/esm/src/api/command/os/GetCustomImageSizeCommand.js.map +2 -2
- package/lib/esm/src/api/command/os/GetCustomImageSizeCommand.test.js +1 -1
- package/lib/esm/src/api/command/os/GetCustomImageSizeCommand.test.js.map +2 -2
- package/lib/esm/src/api/command/os/GetOsVersionCommand.js +1 -1
- package/lib/esm/src/api/command/os/GetOsVersionCommand.js.map +2 -2
- package/lib/esm/src/api/command/os/GetOsVersionCommand.test.js +1 -1
- package/lib/esm/src/api/command/os/GetOsVersionCommand.test.js.map +2 -2
- package/lib/esm/src/api/command/os/ListAppsCommand.js +1 -1
- package/lib/esm/src/api/command/os/ListAppsCommand.js.map +2 -2
- package/lib/esm/src/api/command/os/ListAppsCommand.test.js +1 -1
- package/lib/esm/src/api/command/os/ListAppsCommand.test.js.map +2 -2
- package/lib/esm/src/api/command/os/ListLanguagePackCommand.js +1 -1
- package/lib/esm/src/api/command/os/ListLanguagePackCommand.js.map +2 -2
- package/lib/esm/src/api/command/os/ListLanguagePackCommand.test.js +1 -1
- package/lib/esm/src/api/command/os/ListLanguagePackCommand.test.js.map +2 -2
- package/lib/esm/src/api/command/os/LoadCertificateCommand.js +1 -1
- package/lib/esm/src/api/command/os/LoadCertificateCommand.js.map +2 -2
- package/lib/esm/src/api/command/os/LoadCertificateCommand.test.js +1 -1
- package/lib/esm/src/api/command/os/LoadCertificateCommand.test.js.map +3 -3
- package/lib/esm/src/api/command/os/OpenAppCommand.js +1 -1
- package/lib/esm/src/api/command/os/OpenAppCommand.js.map +2 -2
- package/lib/esm/src/api/command/os/OpenAppCommand.test.js +1 -1
- package/lib/esm/src/api/command/os/OpenAppCommand.test.js.map +2 -2
- package/lib/esm/src/api/command/use-case/SendCommandUseCase.test.js +1 -1
- package/lib/esm/src/api/command/use-case/SendCommandUseCase.test.js.map +2 -2
- package/lib/esm/src/api/device-action/os/CallTaskInAppDeviceAction/CallTaskInAppDeviceAction.test.js +1 -1
- package/lib/esm/src/api/device-action/os/CallTaskInAppDeviceAction/CallTaskInAppDeviceAction.test.js.map +2 -2
- package/lib/esm/src/api/device-action/os/SendCommandInAppDeviceAction/SendCommandInAppDeviceAction.test.js +1 -1
- package/lib/esm/src/api/device-action/os/SendCommandInAppDeviceAction/SendCommandInAppDeviceAction.test.js.map +2 -2
- package/lib/esm/src/api/device-action/task/GetFirmwareMetadataTask.js +1 -1
- package/lib/esm/src/api/device-action/task/GetFirmwareMetadataTask.js.map +3 -3
- package/lib/esm/src/api/device-action/task/GetFirmwareMetadataTask.test.js +1 -1
- package/lib/esm/src/api/device-action/task/GetFirmwareMetadataTask.test.js.map +3 -3
- package/lib/esm/src/api/index.js +1 -1
- package/lib/esm/src/api/index.js.map +3 -3
- package/lib/esm/src/api/transport/model/ConnectedDevice.js +1 -1
- package/lib/esm/src/api/transport/model/ConnectedDevice.js.map +3 -3
- package/lib/esm/src/api/transport/model/TransportConnectedDevice.js +1 -1
- package/lib/esm/src/api/transport/model/TransportConnectedDevice.js.map +3 -3
- package/lib/esm/src/internal/device-session/model/DeviceSession.js +1 -1
- package/lib/esm/src/internal/device-session/model/DeviceSession.js.map +2 -2
- package/lib/esm/src/internal/discovery/di/discoveryModule.js +1 -1
- package/lib/esm/src/internal/discovery/di/discoveryModule.js.map +3 -3
- package/lib/esm/src/internal/discovery/di/discoveryModule.test.js +1 -1
- package/lib/esm/src/internal/discovery/di/discoveryModule.test.js.map +3 -3
- package/lib/esm/src/internal/discovery/di/discoveryTypes.js +1 -1
- package/lib/esm/src/internal/discovery/di/discoveryTypes.js.map +2 -2
- package/lib/esm/src/internal/discovery/use-case/ConnectUseCase.js +1 -1
- package/lib/esm/src/internal/discovery/use-case/ConnectUseCase.js.map +3 -3
- package/lib/esm/src/internal/discovery/use-case/ConnectUseCase.test.js +1 -1
- package/lib/esm/src/internal/discovery/use-case/ConnectUseCase.test.js.map +3 -3
- package/lib/esm/src/internal/discovery/use-case/DisconnectUseCase.js +1 -1
- package/lib/esm/src/internal/discovery/use-case/DisconnectUseCase.js.map +3 -3
- package/lib/esm/src/internal/discovery/use-case/ReconnectUseCase.js +2 -0
- package/lib/esm/src/internal/discovery/use-case/ReconnectUseCase.js.map +7 -0
- package/lib/esm/src/internal/discovery/use-case/ReconnectUseCase.test.js +2 -0
- package/lib/esm/src/internal/discovery/use-case/ReconnectUseCase.test.js.map +7 -0
- package/lib/types/src/api/DeviceManagementKit.d.ts +12 -0
- package/lib/types/src/api/DeviceManagementKit.d.ts.map +1 -1
- package/lib/types/src/api/command/Command.d.ts +4 -0
- package/lib/types/src/api/command/Command.d.ts.map +1 -1
- package/lib/types/src/api/command/Errors.d.ts +5 -0
- package/lib/types/src/api/command/Errors.d.ts.map +1 -1
- package/lib/types/src/api/command/model/CommandResult.d.ts +3 -3
- package/lib/types/src/api/command/model/CommandResult.d.ts.map +1 -1
- package/lib/types/src/api/command/os/CloseAppCommand.d.ts +1 -0
- package/lib/types/src/api/command/os/CloseAppCommand.d.ts.map +1 -1
- package/lib/types/src/api/command/os/GetAppAndVersionCommand.d.ts +1 -0
- package/lib/types/src/api/command/os/GetAppAndVersionCommand.d.ts.map +1 -1
- package/lib/types/src/api/command/os/GetBatteryStatusCommand.d.ts +1 -0
- package/lib/types/src/api/command/os/GetBatteryStatusCommand.d.ts.map +1 -1
- package/lib/types/src/api/command/os/GetCustomImageSizeCommand.d.ts +1 -0
- package/lib/types/src/api/command/os/GetCustomImageSizeCommand.d.ts.map +1 -1
- package/lib/types/src/api/command/os/GetOsVersionCommand.d.ts +1 -0
- package/lib/types/src/api/command/os/GetOsVersionCommand.d.ts.map +1 -1
- package/lib/types/src/api/command/os/ListAppsCommand.d.ts +1 -0
- package/lib/types/src/api/command/os/ListAppsCommand.d.ts.map +1 -1
- package/lib/types/src/api/command/os/ListLanguagePackCommand.d.ts +1 -0
- package/lib/types/src/api/command/os/ListLanguagePackCommand.d.ts.map +1 -1
- package/lib/types/src/api/command/os/LoadCertificateCommand.d.ts +1 -0
- package/lib/types/src/api/command/os/LoadCertificateCommand.d.ts.map +1 -1
- package/lib/types/src/api/command/os/OpenAppCommand.d.ts +1 -0
- package/lib/types/src/api/command/os/OpenAppCommand.d.ts.map +1 -1
- package/lib/types/src/api/device-action/task/GetFirmwareMetadataTask.d.ts.map +1 -1
- package/lib/types/src/api/index.d.ts +1 -1
- package/lib/types/src/api/index.d.ts.map +1 -1
- package/lib/types/src/api/transport/model/ConnectedDevice.d.ts +3 -2
- package/lib/types/src/api/transport/model/ConnectedDevice.d.ts.map +1 -1
- package/lib/types/src/api/transport/model/TransportConnectedDevice.d.ts +3 -1
- package/lib/types/src/api/transport/model/TransportConnectedDevice.d.ts.map +1 -1
- package/lib/types/src/internal/device-session/model/DeviceSession.d.ts.map +1 -1
- package/lib/types/src/internal/discovery/di/discoveryModule.d.ts.map +1 -1
- package/lib/types/src/internal/discovery/di/discoveryTypes.d.ts +1 -0
- package/lib/types/src/internal/discovery/di/discoveryTypes.d.ts.map +1 -1
- package/lib/types/src/internal/discovery/use-case/ConnectUseCase.d.ts +3 -2
- package/lib/types/src/internal/discovery/use-case/ConnectUseCase.d.ts.map +1 -1
- package/lib/types/src/internal/discovery/use-case/DisconnectUseCase.d.ts.map +1 -1
- package/lib/types/src/internal/discovery/use-case/ReconnectUseCase.d.ts +32 -0
- package/lib/types/src/internal/discovery/use-case/ReconnectUseCase.d.ts.map +1 -0
- package/lib/types/src/internal/discovery/use-case/ReconnectUseCase.test.d.ts +2 -0
- package/lib/types/src/internal/discovery/use-case/ReconnectUseCase.test.d.ts.map +1 -0
- package/lib/types/tsconfig.prod.tsbuildinfo +1 -1
- package/package.json +3 -3
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";var n=require("purify-ts"),
|
|
1
|
+
"use strict";var n=require("purify-ts"),s=require("../../command/Errors"),e=require("../../command/model/CommandResult"),v=require("../../device-action/__test-utils__/makeInternalApi"),m=require("./GetFirmwareMetadataTask");describe("GetFirmwareMetadataTask",()=>{const a=(0,v.makeDeviceActionInternalApiMock)(),o={mcuSephVersion:"mcu_version",mcuBootloaderVersion:"bl_version",seVersion:"se_version"},w=97,u={id:7},i={id:361,version:"1.6.0",perso:"perso_11"},l={id:362,perso:"perso_11"},d={id:363,version:"1.7.0",perso:"perso_11",mcuVersions:[1]},V=[{id:3,name:"other_version"},{id:1,name:"mcu_version"}],r={getDeviceVersion:vi.fn(),getFirmwareVersion:vi.fn(),getLatestFirmwareVersion:vi.fn(),getNextFirmwareVersion:vi.fn(),getMcuList:vi.fn()};beforeEach(()=>{vi.clearAllMocks(),a.getManagerApiService.mockReturnValue(r),r.getDeviceVersion.mockReturnValue((0,n.EitherAsync)(async()=>u)),r.getFirmwareVersion.mockReturnValue((0,n.EitherAsync)(async()=>i)),r.getLatestFirmwareVersion.mockReturnValue((0,n.EitherAsync)(async()=>l)),r.getNextFirmwareVersion.mockReturnValue((0,n.EitherAsync)(async()=>d)),r.getMcuList.mockReturnValue((0,n.EitherAsync)(async()=>V))}),it("success with no firmware update available",async()=>{a.sendCommand.mockResolvedValueOnce((0,e.CommandResultFactory)({data:o})).mockResolvedValueOnce((0,e.CommandResultFactory)({data:w})),r.getLatestFirmwareVersion.mockReturnValueOnce((0,n.EitherAsync)(async({throwE:c})=>{c(new Error("error"))}));const t=await new m.GetFirmwareMetadataTask(a).run();expect(t).toStrictEqual((0,e.CommandResultFactory)({data:{deviceVersion:u,firmware:i,firmwareVersion:{mcu:"mcu_version",bootloader:"bl_version",os:"se_version",metadata:o},firmwareUpdateContext:{currentFirmware:i,availableUpdate:void 0},customImage:{size:w}}}))}),it("success with a firmware update available",async()=>{a.sendCommand.mockResolvedValueOnce((0,e.CommandResultFactory)({data:o})).mockResolvedValueOnce((0,e.CommandResultFactory)({error:new s.InvalidStatusWordError("error")}));const t=await new m.GetFirmwareMetadataTask(a).run();expect(t).toStrictEqual((0,e.CommandResultFactory)({data:{deviceVersion:u,firmware:i,firmwareVersion:{mcu:"mcu_version",bootloader:"bl_version",os:"se_version",metadata:o},firmwareUpdateContext:{currentFirmware:i,availableUpdate:{osuFirmware:l,finalFirmware:d,mcuUpdateRequired:!1}},customImage:{}}})),expect(r.getDeviceVersion).toHaveBeenCalledWith(o),expect(r.getFirmwareVersion).toHaveBeenCalledWith(o,u),expect(r.getLatestFirmwareVersion).toHaveBeenCalledWith(i,u),expect(r.getNextFirmwareVersion).toHaveBeenCalledWith(l)}),it("success with a firmware update available and MCU update",async()=>{a.sendCommand.mockResolvedValueOnce((0,e.CommandResultFactory)({data:o})).mockResolvedValueOnce((0,e.CommandResultFactory)({error:new s.InvalidStatusWordError("error")}));const t={...d,mcuVersions:[3]};r.getNextFirmwareVersion.mockReturnValue((0,n.EitherAsync)(async()=>t));const c=await new m.GetFirmwareMetadataTask(a).run();expect(c).toStrictEqual((0,e.CommandResultFactory)({data:{deviceVersion:u,firmware:i,firmwareVersion:{mcu:"mcu_version",bootloader:"bl_version",os:"se_version",metadata:o},firmwareUpdateContext:{currentFirmware:i,availableUpdate:{osuFirmware:l,finalFirmware:t,mcuUpdateRequired:!0}},customImage:{}}}))}),it("should fail when OS version cannot be retrieved",async()=>{a.sendCommand.mockResolvedValueOnce((0,e.CommandResultFactory)({error:new s.InvalidStatusWordError("error")}));const t=await new m.GetFirmwareMetadataTask(a).run();expect(t).toStrictEqual((0,e.CommandResultFactory)({error:new s.InvalidStatusWordError("error")}))}),it("should fail if device version cannot be fetched with InvalidGetFirmwareMetadataResponseError",async()=>{a.sendCommand.mockResolvedValueOnce((0,e.CommandResultFactory)({data:o})),r.getDeviceVersion.mockReturnValueOnce((0,n.EitherAsync)(async({throwE:c})=>{c(new Error("error"))}));const t=await new m.GetFirmwareMetadataTask(a).run();expect(t).toStrictEqual((0,e.CommandResultFactory)({error:new s.InvalidGetFirmwareMetadataResponseError}))}),it("should fail if firmware version cannot be fetched with InvalidGetFirmwareMetadataResponseError",async()=>{a.sendCommand.mockResolvedValueOnce((0,e.CommandResultFactory)({data:o})),r.getFirmwareVersion.mockReturnValueOnce((0,n.EitherAsync)(async({throwE:c})=>{c(new Error("error"))}));const t=await new m.GetFirmwareMetadataTask(a).run();expect(t).toStrictEqual((0,e.CommandResultFactory)({error:new s.InvalidGetFirmwareMetadataResponseError}))})});
|
|
2
2
|
//# sourceMappingURL=GetFirmwareMetadataTask.test.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../../src/api/device-action/task/GetFirmwareMetadataTask.test.ts"],
|
|
4
|
-
"sourcesContent": ["import { EitherAsync } from \"purify-ts\";\n\nimport {
|
|
5
|
-
"mappings": "aAAA,IAAAA,EAA4B,qBAE5BC,
|
|
4
|
+
"sourcesContent": ["import { EitherAsync } from \"purify-ts\";\n\nimport {\n InvalidGetFirmwareMetadataResponseError,\n InvalidStatusWordError,\n} from \"@api/command/Errors\";\nimport { CommandResultFactory } from \"@api/command/model/CommandResult\";\nimport { type GetOsVersionResponse } from \"@api/command/os/GetOsVersionCommand\";\nimport { makeDeviceActionInternalApiMock } from \"@api/device-action/__test-utils__/makeInternalApi\";\nimport {\n type FinalFirmware,\n type McuFirmware,\n type OsuFirmware,\n} from \"@internal/manager-api/model/Firmware\";\nimport { type ManagerApiService } from \"@internal/manager-api/service/ManagerApiService\";\n\nimport { GetFirmwareMetadataTask } from \"./GetFirmwareMetadataTask\";\n\ndescribe(\"GetFirmwareMetadataTask\", () => {\n const apiMock = makeDeviceActionInternalApiMock();\n const OS_VERSION = {\n mcuSephVersion: \"mcu_version\",\n mcuBootloaderVersion: \"bl_version\",\n seVersion: \"se_version\",\n } as GetOsVersionResponse;\n\n const CUSTOM_IMAGE_SIZE = 97;\n\n const DEVICE_VERSION = {\n id: 7,\n };\n\n const FIRMWARE_VERSION = {\n id: 361,\n version: \"1.6.0\",\n perso: \"perso_11\",\n } as FinalFirmware;\n\n const OSU_VERSION = {\n id: 362,\n perso: \"perso_11\",\n } as OsuFirmware;\n\n const NEXT_FIRMWARE_VERSION = {\n id: 363,\n version: \"1.7.0\",\n perso: \"perso_11\",\n mcuVersions: [1],\n } as FinalFirmware;\n\n const MCUS = [\n {\n id: 3,\n name: \"other_version\",\n },\n {\n id: 1,\n name: \"mcu_version\",\n },\n ] as McuFirmware[];\n\n const MANAGER_MOCK = {\n getDeviceVersion: vi.fn(),\n getFirmwareVersion: vi.fn(),\n getLatestFirmwareVersion: vi.fn(),\n getNextFirmwareVersion: vi.fn(),\n getMcuList: vi.fn(),\n };\n\n beforeEach(() => {\n vi.clearAllMocks();\n\n apiMock.getManagerApiService.mockReturnValue(\n MANAGER_MOCK as unknown as ManagerApiService,\n );\n MANAGER_MOCK.getDeviceVersion.mockReturnValue(\n EitherAsync(async () => DEVICE_VERSION),\n );\n MANAGER_MOCK.getFirmwareVersion.mockReturnValue(\n EitherAsync(async () => FIRMWARE_VERSION),\n );\n MANAGER_MOCK.getLatestFirmwareVersion.mockReturnValue(\n EitherAsync(async () => OSU_VERSION),\n );\n MANAGER_MOCK.getNextFirmwareVersion.mockReturnValue(\n EitherAsync(async () => NEXT_FIRMWARE_VERSION),\n );\n MANAGER_MOCK.getMcuList.mockReturnValue(EitherAsync(async () => MCUS));\n });\n\n it(\"success with no firmware update available\", async () => {\n // GIVEN\n apiMock.sendCommand\n .mockResolvedValueOnce(CommandResultFactory({ data: OS_VERSION }))\n .mockResolvedValueOnce(CommandResultFactory({ data: CUSTOM_IMAGE_SIZE }));\n MANAGER_MOCK.getLatestFirmwareVersion.mockReturnValueOnce(\n EitherAsync(async ({ throwE }) => {\n throwE(new Error(\"error\"));\n }),\n );\n\n // WHEN\n const result = await new GetFirmwareMetadataTask(apiMock).run();\n\n // THEN\n expect(result).toStrictEqual(\n CommandResultFactory({\n data: {\n deviceVersion: DEVICE_VERSION,\n firmware: FIRMWARE_VERSION,\n firmwareVersion: {\n mcu: \"mcu_version\",\n bootloader: \"bl_version\",\n os: \"se_version\",\n metadata: OS_VERSION,\n },\n firmwareUpdateContext: {\n currentFirmware: FIRMWARE_VERSION,\n availableUpdate: undefined,\n },\n customImage: { size: CUSTOM_IMAGE_SIZE },\n },\n }),\n );\n });\n\n it(\"success with a firmware update available\", async () => {\n // GIVEN\n apiMock.sendCommand\n .mockResolvedValueOnce(CommandResultFactory({ data: OS_VERSION }))\n .mockResolvedValueOnce(\n CommandResultFactory({ error: new InvalidStatusWordError(\"error\") }),\n );\n\n // WHEN\n const result = await new GetFirmwareMetadataTask(apiMock).run();\n\n // THEN\n expect(result).toStrictEqual(\n CommandResultFactory({\n data: {\n deviceVersion: DEVICE_VERSION,\n firmware: FIRMWARE_VERSION,\n firmwareVersion: {\n mcu: \"mcu_version\",\n bootloader: \"bl_version\",\n os: \"se_version\",\n metadata: OS_VERSION,\n },\n firmwareUpdateContext: {\n currentFirmware: FIRMWARE_VERSION,\n availableUpdate: {\n osuFirmware: OSU_VERSION,\n finalFirmware: NEXT_FIRMWARE_VERSION,\n mcuUpdateRequired: false,\n },\n },\n customImage: {},\n },\n }),\n );\n expect(MANAGER_MOCK.getDeviceVersion).toHaveBeenCalledWith(OS_VERSION);\n expect(MANAGER_MOCK.getFirmwareVersion).toHaveBeenCalledWith(\n OS_VERSION,\n DEVICE_VERSION,\n );\n expect(MANAGER_MOCK.getLatestFirmwareVersion).toHaveBeenCalledWith(\n FIRMWARE_VERSION,\n DEVICE_VERSION,\n );\n expect(MANAGER_MOCK.getNextFirmwareVersion).toHaveBeenCalledWith(\n OSU_VERSION,\n );\n });\n\n it(\"success with a firmware update available and MCU update\", async () => {\n // GIVEN\n apiMock.sendCommand\n .mockResolvedValueOnce(CommandResultFactory({ data: OS_VERSION }))\n .mockResolvedValueOnce(\n CommandResultFactory({ error: new InvalidStatusWordError(\"error\") }),\n );\n const nextFirmware = {\n ...NEXT_FIRMWARE_VERSION,\n mcuVersions: [3],\n };\n MANAGER_MOCK.getNextFirmwareVersion.mockReturnValue(\n EitherAsync(async () => nextFirmware),\n );\n\n // WHEN\n const result = await new GetFirmwareMetadataTask(apiMock).run();\n\n // THEN\n expect(result).toStrictEqual(\n CommandResultFactory({\n data: {\n deviceVersion: DEVICE_VERSION,\n firmware: FIRMWARE_VERSION,\n firmwareVersion: {\n mcu: \"mcu_version\",\n bootloader: \"bl_version\",\n os: \"se_version\",\n metadata: OS_VERSION,\n },\n firmwareUpdateContext: {\n currentFirmware: FIRMWARE_VERSION,\n availableUpdate: {\n osuFirmware: OSU_VERSION,\n finalFirmware: nextFirmware,\n mcuUpdateRequired: true,\n },\n },\n customImage: {},\n },\n }),\n );\n });\n\n it(\"should fail when OS version cannot be retrieved\", async () => {\n // GIVEN\n apiMock.sendCommand.mockResolvedValueOnce(\n CommandResultFactory({ error: new InvalidStatusWordError(\"error\") }),\n );\n\n // WHEN\n const result = await new GetFirmwareMetadataTask(apiMock).run();\n\n // THEN\n expect(result).toStrictEqual(\n CommandResultFactory({ error: new InvalidStatusWordError(\"error\") }),\n );\n });\n\n it(\"should fail if device version cannot be fetched with InvalidGetFirmwareMetadataResponseError\", async () => {\n // GIVEN\n apiMock.sendCommand.mockResolvedValueOnce(\n CommandResultFactory({ data: OS_VERSION }),\n );\n MANAGER_MOCK.getDeviceVersion.mockReturnValueOnce(\n EitherAsync(async ({ throwE }) => {\n throwE(new Error(\"error\"));\n }),\n );\n\n // WHEN\n const result = await new GetFirmwareMetadataTask(apiMock).run();\n\n // THEN\n expect(result).toStrictEqual(\n CommandResultFactory({\n error: new InvalidGetFirmwareMetadataResponseError(),\n }),\n );\n });\n\n it(\"should fail if firmware version cannot be fetched with InvalidGetFirmwareMetadataResponseError\", async () => {\n // GIVEN\n apiMock.sendCommand.mockResolvedValueOnce(\n CommandResultFactory({ data: OS_VERSION }),\n );\n MANAGER_MOCK.getFirmwareVersion.mockReturnValueOnce(\n EitherAsync(async ({ throwE }) => {\n throwE(new Error(\"error\"));\n }),\n );\n\n // WHEN\n const result = await new GetFirmwareMetadataTask(apiMock).run();\n\n // THEN\n expect(result).toStrictEqual(\n CommandResultFactory({\n error: new InvalidGetFirmwareMetadataResponseError(),\n }),\n );\n });\n});\n"],
|
|
5
|
+
"mappings": "aAAA,IAAAA,EAA4B,qBAE5BC,EAGO,+BACPC,EAAqC,4CAErCC,EAAgD,6DAQhDC,EAAwC,qCAExC,SAAS,0BAA2B,IAAM,CACxC,MAAMC,KAAU,mCAAgC,EAC1CC,EAAa,CACjB,eAAgB,cAChB,qBAAsB,aACtB,UAAW,Y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B,MAAO,IAAI,yCACb,CAAC,CACH,CACF,CAAC,CACH,CAAC",
|
|
6
6
|
"names": ["import_purify_ts", "import_Errors", "import_CommandResult", "import_makeInternalApi", "import_GetFirmwareMetadataTask", "apiMock", "OS_VERSION", "CUSTOM_IMAGE_SIZE", "DEVICE_VERSION", "FIRMWARE_VERSION", "OSU_VERSION", "NEXT_FIRMWARE_VERSION", "MCUS", "MANAGER_MOCK", "throwE", "result", "nextFirmware"]
|
|
7
7
|
}
|
package/lib/cjs/src/api/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";var
|
|
1
|
+
"use strict";var l=Object.defineProperty;var xe=Object.getOwnPropertyDescriptor;var de=Object.getOwnPropertyNames;var Ae=Object.prototype.hasOwnProperty;var De=(p,o)=>{for(var i in o)l(p,i,{get:o[i],enumerable:!0})},D=(p,o,i,v)=>{if(o&&typeof o=="object"||typeof o=="function")for(let s of de(o))!Ae.call(p,s)&&s!==i&&l(p,s,{get:()=>o[s],enumerable:!(v=xe(o,s))||v.enumerable});return p},r=(p,o,i)=>(D(p,o,"default"),i&&D(i,o,"default"));var le=p=>D(l({},"__esModule",{value:!0}),p);var e={};De(e,{APDU_MAX_PAYLOAD:()=>c.APDU_MAX_PAYLOAD,Apdu:()=>u.Apdu,ApduBuilder:()=>c.ApduBuilder,ApduParser:()=>S.ApduParser,ApduResponse:()=>Y.ApduResponse,AppAlreadyInstalledDAError:()=>t.AppAlreadyInstalledDAError,BatteryStatusType:()=>x.BatteryStatusType,BleDeviceInfos:()=>q.BleDeviceInfos,ByteArrayBuilder:()=>C.ByteArrayBuilder,ByteArrayParser:()=>y.ByteArrayParser,CallTaskInAppDeviceAction:()=>T.CallTaskInAppDeviceAction,CloseAppCommand:()=>E.CloseAppCommand,CommandResultFactory:()=>n.CommandResultFactory,CommandResultStatus:()=>n.CommandResultStatus,CommandUtils:()=>I.CommandUtils,ConnectedDevice:()=>ae.ConnectedDevice,ConsoleLogger:()=>ne.ConsoleLogger,DeviceActionStatus:()=>b.DeviceActionStatus,DeviceConnectionStateMachine:()=>se.DeviceConnectionStateMachine,DeviceLockedError:()=>t.DeviceLockedError,DeviceManagementKit:()=>te.DeviceManagementKit,DeviceManagementKitBuilder:()=>pe.DeviceManagementKitBuilder,DeviceModel:()=>m.DeviceModel,DeviceModelId:()=>m.DeviceModelId,DeviceSessionStateType:()=>j.DeviceSessionStateType,DeviceStatus:()=>O.DeviceStatus,FramerUtils:()=>oe.FramerUtils,GenuineCheckDeviceAction:()=>z.GenuineCheckDeviceAction,GetAppAndVersionCommand:()=>L.GetAppAndVersionCommand,GetBatteryStatusCommand:()=>x.GetBatteryStatusCommand,GetDeviceMetadataDeviceAction:()=>U.GetDeviceMetadataDeviceAction,GetDeviceStatusDeviceAction:()=>P.GetDeviceStatusDeviceAction,GetOsVersionCommand:()=>g.GetOsVersionCommand,GlobalCommandError:()=>d.GlobalCommandError,GlobalCommandErrorHandler:()=>d.GlobalCommandErrorHandler,GoToDashboardDeviceAction:()=>V.GoToDashboardDeviceAction,InstallAppDeviceAction:()=>J.InstallAppDeviceAction,InstallOrUpdateAppsDeviceAction:()=>k.InstallOrUpdateAppsDeviceAction,InvalidGetFirmwareMetadataResponseError:()=>f.InvalidGetFirmwareMetadataResponseError,InvalidStatusWordError:()=>f.InvalidStatusWordError,LEDGER_VENDOR_ID:()=>m.LEDGER_VENDOR_ID,ListAppsCommand:()=>B.ListAppsCommand,ListAppsDeviceAction:()=>F.ListAppsDeviceAction,ListAppsWithMetadataDeviceAction:()=>W.ListAppsWithMetadataDeviceAction,ListInstalledAppsDeviceAction:()=>Q.ListInstalledAppsDeviceAction,LoadCertificateCommand:()=>G.LoadCertificateCommand,LogLevel:()=>ie.LogLevel,OpenAppCommand:()=>M.OpenAppCommand,OpenAppDeviceAction:()=>_.OpenAppDeviceAction,OpenAppWithDependenciesDeviceAction:()=>w.OpenAppWithDependenciesDeviceAction,OutOfMemoryDAError:()=>t.OutOfMemoryDAError,RefusedByUserDAError:()=>t.RefusedByUserDAError,SecureChannelError:()=>$.SecureChannelError,SendCommandInAppDeviceAction:()=>H.SendCommandInAppDeviceAction,StaticDeviceModelDataSource:()=>X.StaticDeviceModelDataSource,TransportConnectedDevice:()=>ce.TransportConnectedDevice,TransportDeviceModel:()=>N.TransportDeviceModel,UninstallAppDeviceAction:()=>Z.UninstallAppDeviceAction,UnknownDAError:()=>t.UnknownDAError,UnsupportedFirmwareDAError:()=>t.UnsupportedFirmwareDAError,UserInteractionRequired:()=>h.UserInteractionRequired,WebLogsExporterLogger:()=>me.WebLogsExporterLogger,XStateDeviceAction:()=>K.XStateDeviceAction,base64StringToBuffer:()=>A.base64StringToBuffer,bufferToHexaString:()=>a.bufferToHexaString,connectedDeviceStubBuilder:()=>fe.connectedDeviceStubBuilder,defaultApduReceiverServiceStubBuilder:()=>ee.defaultApduReceiverServiceStubBuilder,defaultApduSenderServiceStubBuilder:()=>re.defaultApduSenderServiceStubBuilder,hexaStringToBuffer:()=>a.hexaStringToBuffer,isBase64String:()=>A.isBase64String,isCommandErrorCode:()=>R.isCommandErrorCode,isHexaString:()=>a.isHexaString,isSuccessCommandResult:()=>n.isSuccessCommandResult});module.exports=le(e);var u=require("./apdu/model/Apdu"),c=require("./apdu/utils/ApduBuilder"),S=require("./apdu/utils/ApduParser");r(e,require("./apdu/utils/AppBuilderError"),module.exports);var C=require("./apdu/utils/ByteArrayBuilder"),y=require("./apdu/utils/ByteArrayParser"),f=require("./command/Errors"),n=require("./command/model/CommandResult"),E=require("./command/os/CloseAppCommand"),L=require("./command/os/GetAppAndVersionCommand"),x=require("./command/os/GetBatteryStatusCommand"),g=require("./command/os/GetOsVersionCommand"),B=require("./command/os/ListAppsCommand"),G=require("./command/os/LoadCertificateCommand"),M=require("./command/os/OpenAppCommand"),R=require("./command/utils/CommandErrors"),I=require("./command/utils/CommandUtils"),d=require("./command/utils/GlobalCommandError"),m=require("./device/DeviceModel"),O=require("./device/DeviceStatus"),b=require("./device-action/model/DeviceActionState"),h=require("./device-action/model/UserInteractionRequired"),T=require("./device-action/os/CallTaskInAppDeviceAction/CallTaskInAppDeviceAction"),t=require("./device-action/os/Errors"),U=require("./device-action/os/GetDeviceMetadata/GetDeviceMetadataDeviceAction"),P=require("./device-action/os/GetDeviceStatus/GetDeviceStatusDeviceAction"),V=require("./device-action/os/GoToDashboard/GoToDashboardDeviceAction"),k=require("./device-action/os/InstallOrUpdateApps/InstallOrUpdateAppsDeviceAction"),F=require("./device-action/os/ListApps/ListAppsDeviceAction"),W=require("./device-action/os/ListAppsWithMetadata/ListAppsWithMetadataDeviceAction"),_=require("./device-action/os/OpenAppDeviceAction/OpenAppDeviceAction"),w=require("./device-action/os/OpenAppWithDependencies/OpenAppWithDependenciesDeviceAction"),H=require("./device-action/os/SendCommandInAppDeviceAction/SendCommandInAppDeviceAction"),K=require("./device-action/xstate-utils/XStateDeviceAction"),X=require("./device-model/data/StaticDeviceModelDataSource"),q=require("./device-model/model/BleDeviceInfos"),N=require("./device-model/model/DeviceModel"),Y=require("./device-session/ApduResponse");r(e,require("./device-session/data/FramerConst"),module.exports);var j=require("./device-session/DeviceSessionState"),z=require("./secure-channel/device-action/GenuineCheck/GenuineCheckDeviceAction"),J=require("./secure-channel/device-action/InstallApp/InstallAppDeviceAction"),Q=require("./secure-channel/device-action/ListInstalledApps/ListInstalledAppsDeviceAction"),Z=require("./secure-channel/device-action/UninstallApp/UninstallAppDeviceAction"),$=require("../internal/secure-channel/model/Errors"),ee=require("./device-session/service/DefaultApduReceiverService.stub"),re=require("./device-session/service/DefaultApduSenderService.stub"),oe=require("./device-session/utils/FramerUtils"),te=require("./DeviceManagementKit"),pe=require("./DeviceManagementKitBuilder");r(e,require("./Error"),module.exports);var ie=require("./logger-subscriber/model/LogLevel"),ne=require("./logger-subscriber/service/ConsoleLogger"),me=require("./logger-subscriber/service/WebLogsExporterLogger"),ae=require("./transport/model/ConnectedDevice"),se=require("./transport/model/DeviceConnectionStateMachine");r(e,require("./transport/model/Errors"),module.exports);var ce=require("./transport/model/TransportConnectedDevice"),fe=require("./transport/model/TransportConnectedDevice.stub");r(e,require("./types"),module.exports);var A=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,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 {
|
|
5
|
-
"mappings": "meAAA,IAAAA,EAAA,GAAAC,GAAAD,EAAA,
|
|
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,4+GAAAE,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,EAAmC,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,EAAqD,mCACrDC,EAIO",
|
|
6
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"]
|
|
7
7
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";var
|
|
1
|
+
"use strict";var r=Object.defineProperty;var p=Object.getOwnPropertyDescriptor;var l=Object.getOwnPropertyNames;var a=Object.prototype.hasOwnProperty;var y=(o,e)=>{for(var t in e)r(o,t,{get:e[t],enumerable:!0})},v=(o,e,t,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of l(e))!a.call(o,n)&&n!==t&&r(o,n,{get:()=>e[n],enumerable:!(i=p(e,n))||i.enumerable});return o};var D=o=>v(r({},"__esModule",{value:!0}),o);var m={};y(m,{ConnectedDevice:()=>I});module.exports=D(m);class I{id;sessionId;modelId;name;type;transport;constructor({transportConnectedDevice:{id:e,deviceModel:{id:t,productName:i},type:n,transport:d,name:s},sessionId:c}){this.id=e,this.sessionId=c,this.modelId=t,this.name=s??i,this.type=n,this.transport=d}}0&&(module.exports={ConnectedDevice});
|
|
2
2
|
//# sourceMappingURL=ConnectedDevice.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../../src/api/transport/model/ConnectedDevice.ts"],
|
|
4
|
-
"sourcesContent": ["import { type DeviceId, type DeviceModelId } from \"@api/device/DeviceModel\";\nimport { type ConnectionType } from \"@api/discovery/ConnectionType\";\nimport { type TransportConnectedDevice } from \"@api/transport/model/TransportConnectedDevice\";\nimport { type DeviceSessionId } from \"@api/types\";\n\ntype ConnectedDeviceConstructorArgs = {\n readonly sessionId: DeviceSessionId;\n readonly transportConnectedDevice: TransportConnectedDevice;\n};\n\nexport class ConnectedDevice {\n public readonly id: DeviceId;\n public readonly sessionId: DeviceSessionId;\n public readonly modelId: DeviceModelId;\n public readonly name: string;\n public readonly type: ConnectionType;\n\n constructor({\n transportConnectedDevice: {\n id,\n deviceModel: { id: deviceModelId, productName
|
|
5
|
-
"mappings": "yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,qBAAAE,IAAA,eAAAC,EAAAH,GAUO,MAAME,CAAgB,CACX,GACA,UACA,QACA,KACA,
|
|
6
|
-
"names": ["ConnectedDevice_exports", "__export", "ConnectedDevice", "__toCommonJS", "id", "deviceModelId", "
|
|
4
|
+
"sourcesContent": ["import { type DeviceId, type DeviceModelId } from \"@api/device/DeviceModel\";\nimport { type ConnectionType } from \"@api/discovery/ConnectionType\";\nimport { type TransportConnectedDevice } from \"@api/transport/model/TransportConnectedDevice\";\nimport { type DeviceSessionId, type TransportIdentifier } from \"@api/types\";\n\ntype ConnectedDeviceConstructorArgs = {\n readonly sessionId: DeviceSessionId;\n readonly transportConnectedDevice: TransportConnectedDevice;\n};\n\nexport class ConnectedDevice {\n public readonly id: DeviceId;\n public readonly sessionId: DeviceSessionId;\n public readonly modelId: DeviceModelId;\n public readonly name: string;\n public readonly type: ConnectionType;\n public readonly transport: TransportIdentifier;\n\n constructor({\n transportConnectedDevice: {\n id,\n deviceModel: { id: deviceModelId, productName },\n type,\n transport,\n name,\n },\n sessionId,\n }: ConnectedDeviceConstructorArgs) {\n this.id = id;\n this.sessionId = sessionId;\n this.modelId = deviceModelId;\n this.name = name ?? productName;\n this.type = type;\n this.transport = transport;\n }\n}\n"],
|
|
5
|
+
"mappings": "yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,qBAAAE,IAAA,eAAAC,EAAAH,GAUO,MAAME,CAAgB,CACX,GACA,UACA,QACA,KACA,KACA,UAEhB,YAAY,CACV,yBAA0B,CACxB,GAAAE,EACA,YAAa,CAAE,GAAIC,EAAe,YAAAC,CAAY,EAC9C,KAAAC,EACA,UAAAC,EACA,KAAAC,CACF,EACA,UAAAC,CACF,EAAmC,CACjC,KAAK,GAAKN,EACV,KAAK,UAAYM,EACjB,KAAK,QAAUL,EACf,KAAK,KAAOI,GAAQH,EACpB,KAAK,KAAOC,EACZ,KAAK,UAAYC,CACnB,CACF",
|
|
6
|
+
"names": ["ConnectedDevice_exports", "__export", "ConnectedDevice", "__toCommonJS", "id", "deviceModelId", "productName", "type", "transport", "name", "sessionId"]
|
|
7
7
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";var p=Object.defineProperty;var
|
|
1
|
+
"use strict";var p=Object.defineProperty;var c=Object.getOwnPropertyDescriptor;var s=Object.getOwnPropertyNames;var y=Object.prototype.hasOwnProperty;var a=(t,e)=>{for(var r in e)p(t,r,{get:e[r],enumerable:!0})},l=(t,e,r,o)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of s(e))!y.call(t,n)&&n!==r&&p(t,n,{get:()=>e[n],enumerable:!(o=c(e,n))||o.enumerable});return t};var u=t=>l(p({},"__esModule",{value:!0}),t);var T={};a(T,{TransportConnectedDevice:()=>m});module.exports=u(T);class m{id;deviceModel;sendApdu;type;transport;name;constructor({id:e,deviceModel:r,type:o,transport:n,sendApdu:i,name:d}){this.id=e,this.deviceModel=r,this.sendApdu=i,this.type=o,this.transport=n,this.name=d}}0&&(module.exports={TransportConnectedDevice});
|
|
2
2
|
//# sourceMappingURL=TransportConnectedDevice.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../../src/api/transport/model/TransportConnectedDevice.ts"],
|
|
4
|
-
"sourcesContent": ["import { type DeviceId } from \"@api/device/DeviceModel\";\nimport { type TransportDeviceModel } from \"@api/device-model/model/DeviceModel\";\nimport { type ConnectionType } from \"@api/discovery/ConnectionType\";\nimport { type SendApduFnType } from \"@api/transport/model/DeviceConnection\";\nimport { type TransportIdentifier } from \"@api/transport/model/TransportIdentifier\";\n\n/**\n * The internal connected device.\n */\nexport type ConnectedDeviceConstructorArgs = {\n id: DeviceId;\n deviceModel: TransportDeviceModel;\n type: ConnectionType;\n transport: TransportIdentifier;\n sendApdu: SendApduFnType;\n};\n\nexport class TransportConnectedDevice {\n public readonly id: DeviceId;\n public readonly deviceModel: TransportDeviceModel;\n public readonly sendApdu: SendApduFnType;\n public readonly type: ConnectionType;\n public readonly transport: TransportIdentifier;\n\n constructor({\n id,\n deviceModel,\n type,\n transport,\n sendApdu,\n }: ConnectedDeviceConstructorArgs) {\n this.id = id;\n this.deviceModel = deviceModel;\n this.sendApdu = sendApdu;\n this.type = type;\n this.transport = transport;\n }\n}\n"],
|
|
5
|
-
"mappings": "yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,8BAAAE,IAAA,eAAAC,EAAAH,
|
|
6
|
-
"names": ["TransportConnectedDevice_exports", "__export", "TransportConnectedDevice", "__toCommonJS", "id", "deviceModel", "type", "transport", "sendApdu"]
|
|
4
|
+
"sourcesContent": ["import { type DeviceId } from \"@api/device/DeviceModel\";\nimport { type TransportDeviceModel } from \"@api/device-model/model/DeviceModel\";\nimport { type ConnectionType } from \"@api/discovery/ConnectionType\";\nimport { type SendApduFnType } from \"@api/transport/model/DeviceConnection\";\nimport { type TransportIdentifier } from \"@api/transport/model/TransportIdentifier\";\n\n/**\n * The internal connected device.\n */\nexport type ConnectedDeviceConstructorArgs = {\n id: DeviceId;\n deviceModel: TransportDeviceModel;\n type: ConnectionType;\n transport: TransportIdentifier;\n sendApdu: SendApduFnType;\n name?: string;\n};\n\nexport class TransportConnectedDevice {\n public readonly id: DeviceId;\n public readonly deviceModel: TransportDeviceModel;\n public readonly sendApdu: SendApduFnType;\n public readonly type: ConnectionType;\n public readonly transport: TransportIdentifier;\n public readonly name?: string;\n\n constructor({\n id,\n deviceModel,\n type,\n transport,\n sendApdu,\n name,\n }: ConnectedDeviceConstructorArgs) {\n this.id = id;\n this.deviceModel = deviceModel;\n this.sendApdu = sendApdu;\n this.type = type;\n this.transport = transport;\n this.name = name;\n }\n}\n"],
|
|
5
|
+
"mappings": "yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,8BAAAE,IAAA,eAAAC,EAAAH,GAkBO,MAAME,CAAyB,CACpB,GACA,YACA,SACA,KACA,UACA,KAEhB,YAAY,CACV,GAAAE,EACA,YAAAC,EACA,KAAAC,EACA,UAAAC,EACA,SAAAC,EACA,KAAAC,CACF,EAAmC,CACjC,KAAK,GAAKL,EACV,KAAK,YAAcC,EACnB,KAAK,SAAWG,EAChB,KAAK,KAAOF,EACZ,KAAK,UAAYC,EACjB,KAAK,KAAOE,CACd,CACF",
|
|
6
|
+
"names": ["TransportConnectedDevice_exports", "__export", "TransportConnectedDevice", "__toCommonJS", "id", "deviceModel", "type", "transport", "sendApdu", "name"]
|
|
7
7
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";var
|
|
1
|
+
"use strict";var p=Object.defineProperty;var C=Object.getOwnPropertyDescriptor;var R=Object.getOwnPropertyNames;var A=Object.prototype.hasOwnProperty;var y=(n,e)=>{for(var i in e)p(n,i,{get:e[i],enumerable:!0})},T=(n,e,i,s)=>{if(e&&typeof e=="object"||typeof e=="function")for(let t of R(e))!A.call(n,t)&&t!==i&&p(n,t,{get:()=>e[t],enumerable:!(s=C(e,t))||s.enumerable});return n};var O=n=>T(p({},"__esModule",{value:!0}),n);var x={};y(x,{DeviceSession:()=>I});module.exports=O(x);var h=require("rxjs"),S=require("uuid"),u=require("../../../api/command/utils/CommandUtils"),d=require("../../../api/device/DeviceStatus"),m=require("../../../api/device-session/DeviceSessionState"),a=require("../../../api/index"),l=require("../../device-session/data/DeviceSessionRefresherConst"),D=require("../../device-session/service/MutexService"),_=require("../../device-session/service/RefresherService"),g=require("./DevicePinger"),o=require("./DeviceSessionEventDispatcher"),f=require("./DeviceSessionRefresher"),E=require("./DeviceSessionStateHandler");class I{_id;_connectedDevice;_deviceState;_managerApiService;_secureChannelService;_logger;_refresherOptions;_pinger;_deviceSessionRefresher;_refresherService;_commandMutex=new D.MutexService;_sessionEventDispatcher=new o.DeviceSessionEventDispatcher;constructor({connectedDevice:e,id:i=(0,S.v4)()},s,t,r,c){this._id=i,this._connectedDevice=e,this._logger=s("device-session"),this._managerApiService=t,this._secureChannelService=r,this._refresherOptions={...l.DEVICE_SESSION_REFRESHER_DEFAULT_OPTIONS,...c},this._deviceState=new h.BehaviorSubject({sessionStateType:m.DeviceSessionStateType.Connected,deviceStatus:d.DeviceStatus.CONNECTED,deviceModelId:this._connectedDevice.deviceModel.id}),this._pinger=new g.DevicePinger(s,e,this._sessionEventDispatcher,(v,b)=>this.sendCommand(v,b)),this._deviceSessionRefresher=new f.DeviceSessionRefresher(s,this._refresherOptions,this._sessionEventDispatcher,this._connectedDevice),new E.DeviceSessionStateHandler(s,this._sessionEventDispatcher,this._connectedDevice,this._deviceState,v=>this.setDeviceSessionState(v)),this._refresherService=new _.RefresherService(s,{start:()=>this._deviceSessionRefresher.restartRefresher(),stop:()=>this._deviceSessionRefresher.stopRefresher()})}async initialiseSession(){try{await this._pinger.ping()}catch(e){throw this._logger.error("Error while initialising session",{data:{error:e}}),e}finally{this._refresherOptions.isRefresherDisabled||this._deviceSessionRefresher.startRefresher()}}get id(){return this._id}get connectedDevice(){return this._connectedDevice}get state(){return this._deviceState.asObservable()}getDeviceSessionState(){return this._deviceState.getValue()}setDeviceSessionState(e){this._deviceState.next(e)}async sendApdu(e,i={isPolling:!1,triggersDisconnection:!1,abortTimeout:void 0}){const s=await this._commandMutex.lock();try{this._sessionEventDispatcher.dispatch({eventName:o.SessionEvents.DEVICE_STATE_UPDATE_BUSY}),this._logger.debug(`[exchange] => ${(0,a.bufferToHexaString)(e,!1)}`);const t=await this._connectedDevice.sendApdu(e,i.triggersDisconnection,i.abortTimeout);return t.ifRight(r=>{this._logger.debug(`[exchange] <= ${(0,a.bufferToHexaString)(r.data,!1)}${(0,a.bufferToHexaString)(r.statusCode,!1)}`),u.CommandUtils.isLockedDeviceResponse(r)?this._sessionEventDispatcher.dispatch({eventName:o.SessionEvents.DEVICE_STATE_UPDATE_LOCKED}):this._sessionEventDispatcher.dispatch({eventName:o.SessionEvents.DEVICE_STATE_UPDATE_CONNECTED})}).ifLeft(()=>{this._sessionEventDispatcher.dispatch({eventName:o.SessionEvents.DEVICE_STATE_UPDATE_CONNECTED})}),t}finally{s()}}async sendCommand(e,i){this._logger.debug(`[sendCommand] ${e.name}`);const s=e.getApdu();return(await this.sendApdu(s.getRawApdu(),{isPolling:!1,triggersDisconnection:e.triggersDisconnection??!1,abortTimeout:i})).caseOf({Left:r=>{throw this._logger.error("[sendCommand] error",{data:{err:r}}),r},Right:r=>{const c=e.parseResponse(r,this._connectedDevice.deviceModel.id);return this._logger.debug("[sendCommand] result",{data:{result:c}}),c}})}executeDeviceAction(e){const{observable:i,cancel:s}=e._execute({sendApdu:async t=>this.sendApdu(t),sendCommand:async(t,r)=>this.sendCommand(t,r),getDeviceModel:()=>this._connectedDevice.deviceModel,getDeviceSessionState:()=>this._deviceState.getValue(),getDeviceSessionStateObservable:()=>this.state,setDeviceSessionState:t=>(this.setDeviceSessionState(t),this._deviceState.getValue()),disableRefresher:t=>this._refresherService.disableRefresher(t),getManagerApiService:()=>this._managerApiService,getSecureChannelService:()=>this._secureChannelService});return{observable:i,cancel:s}}close(){this._updateDeviceStatus(d.DeviceStatus.NOT_CONNECTED),this._deviceState.complete(),this._deviceSessionRefresher.stopRefresher()}disableRefresher(e){return this._refresherService.disableRefresher(e)}_updateDeviceStatus(e){const i=this._deviceState.getValue();this._deviceState.next({...i,deviceStatus:e})}}0&&(module.exports={DeviceSession});
|
|
2
2
|
//# sourceMappingURL=DeviceSession.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../../src/internal/device-session/model/DeviceSession.ts"],
|
|
4
|
-
"sourcesContent": ["import { type Either } from \"purify-ts\";\nimport { BehaviorSubject, type Observable } from \"rxjs\";\nimport { v4 as uuidv4 } from \"uuid\";\n\nimport { type Command } from \"@api/command/Command\";\nimport { type CommandResult } from \"@api/command/model/CommandResult\";\nimport { CommandUtils } from \"@api/command/utils/CommandUtils\";\nimport { DeviceStatus } from \"@api/device/DeviceStatus\";\nimport {\n type DeviceAction,\n type DeviceActionIntermediateValue,\n type ExecuteDeviceActionReturnType,\n} from \"@api/device-action/DeviceAction\";\nimport { type ApduResponse } from \"@api/device-session/ApduResponse\";\nimport {\n type DeviceSessionState,\n DeviceSessionStateType,\n} from \"@api/device-session/DeviceSessionState\";\nimport { type DeviceSessionId } from \"@api/device-session/types\";\nimport { type DmkError } from \"@api/Error\";\nimport { bufferToHexaString } from \"@api/index\";\nimport { type LoggerPublisherService } from \"@api/logger-publisher/service/LoggerPublisherService\";\nimport { type TransportConnectedDevice } from \"@api/transport/model/TransportConnectedDevice\";\nimport { DEVICE_SESSION_REFRESHER_DEFAULT_OPTIONS } from \"@internal/device-session/data/DeviceSessionRefresherConst\";\nimport { MutexService } from \"@internal/device-session/service/MutexService\";\nimport { RefresherService } from \"@internal/device-session/service/RefresherService\";\nimport { type ManagerApiService } from \"@internal/manager-api/service/ManagerApiService\";\nimport { type SecureChannelService } from \"@internal/secure-channel/service/SecureChannelService\";\n\nimport { DevicePinger } from \"./DevicePinger\";\nimport {\n DeviceSessionEventDispatcher,\n SessionEvents,\n} from \"./DeviceSessionEventDispatcher\";\nimport { DeviceSessionRefresher } from \"./DeviceSessionRefresher\";\nimport { DeviceSessionStateHandler } from \"./DeviceSessionStateHandler\";\n\nexport type SessionConstructorArgs = {\n connectedDevice: TransportConnectedDevice;\n id?: DeviceSessionId;\n};\n\nexport type DeviceSessionRefresherOptions = {\n isRefresherDisabled: boolean;\n pollingInterval?: number;\n};\n\ntype SendApduOptions = {\n isPolling?: boolean;\n triggersDisconnection?: boolean;\n abortTimeout?: number;\n};\n\n/**\n * Represents a session with a device.\n */\nexport class DeviceSession {\n private readonly _id: DeviceSessionId;\n private readonly _connectedDevice: TransportConnectedDevice;\n private readonly _deviceState: BehaviorSubject<DeviceSessionState>;\n private readonly _managerApiService: ManagerApiService;\n private readonly _secureChannelService: SecureChannelService;\n private readonly _logger: LoggerPublisherService;\n private readonly _refresherOptions: DeviceSessionRefresherOptions;\n private _pinger: DevicePinger;\n private _deviceSessionRefresher: DeviceSessionRefresher;\n private readonly _refresherService: RefresherService;\n private _commandMutex = new MutexService();\n private _sessionEventDispatcher = new DeviceSessionEventDispatcher();\n\n constructor(\n { connectedDevice, id = uuidv4() }: SessionConstructorArgs,\n loggerModuleFactory: (tag: string) => LoggerPublisherService,\n managerApiService: ManagerApiService,\n secureChannelService: SecureChannelService,\n deviceSessionRefresherOptions: DeviceSessionRefresherOptions | undefined,\n ) {\n this._id = id;\n this._connectedDevice = connectedDevice;\n this._logger = loggerModuleFactory(\"device-session\");\n this._managerApiService = managerApiService;\n this._secureChannelService = secureChannelService;\n this._refresherOptions = {\n ...DEVICE_SESSION_REFRESHER_DEFAULT_OPTIONS,\n ...deviceSessionRefresherOptions,\n };\n this._deviceState = new BehaviorSubject<DeviceSessionState>({\n sessionStateType: DeviceSessionStateType.Connected,\n deviceStatus: DeviceStatus.CONNECTED,\n deviceModelId: this._connectedDevice.deviceModel.id,\n });\n\n this._pinger = new DevicePinger(\n loggerModuleFactory,\n connectedDevice,\n this._sessionEventDispatcher,\n (command, abortTimeout) => this.sendCommand(command, abortTimeout),\n );\n this._deviceSessionRefresher = new DeviceSessionRefresher(\n loggerModuleFactory,\n this._refresherOptions,\n this._sessionEventDispatcher,\n this._connectedDevice,\n );\n new DeviceSessionStateHandler(\n loggerModuleFactory,\n this._sessionEventDispatcher,\n this._connectedDevice,\n this._deviceState,\n (state) => this.setDeviceSessionState(state),\n );\n\n this._refresherService = new RefresherService(loggerModuleFactory, {\n start: () => this._deviceSessionRefresher.restartRefresher(),\n stop: () => this._deviceSessionRefresher.stopRefresher(),\n });\n }\n\n public async initialiseSession(): Promise<void> {\n try {\n await this._pinger.ping();\n } catch (error) {\n this._logger.error(\"Error while initialising session\", {\n data: { error },\n });\n throw error;\n } finally {\n if (!this._refresherOptions.isRefresherDisabled) {\n this._deviceSessionRefresher.startRefresher();\n }\n }\n }\n\n public get id(): DeviceSessionId {\n return this._id;\n }\n\n public get connectedDevice(): TransportConnectedDevice {\n return this._connectedDevice;\n }\n\n public get state(): Observable<DeviceSessionState> {\n return this._deviceState.asObservable();\n }\n\n public getDeviceSessionState(): DeviceSessionState {\n return this._deviceState.getValue();\n }\n\n public setDeviceSessionState(state: DeviceSessionState): void {\n this._deviceState.next(state);\n }\n\n public async sendApdu(\n rawApdu: Uint8Array,\n options: SendApduOptions = {\n isPolling: false,\n triggersDisconnection: false,\n abortTimeout: undefined,\n },\n ): Promise<Either<DmkError, ApduResponse>> {\n const release = await this._commandMutex.lock();\n\n try {\n this._sessionEventDispatcher.dispatch({\n eventName: SessionEvents.DEVICE_STATE_UPDATE_BUSY,\n });\n\n this._logger.debug(`[exchange] => ${bufferToHexaString(rawApdu, false)}`);\n const result = await this._connectedDevice.sendApdu(\n rawApdu,\n options.triggersDisconnection,\n options.abortTimeout,\n );\n\n result\n .ifRight((response: ApduResponse) => {\n this._logger.debug(\n `[exchange] <= ${bufferToHexaString(response.data, false)}${bufferToHexaString(response.statusCode, false)}`,\n );\n if (CommandUtils.isLockedDeviceResponse(response)) {\n this._sessionEventDispatcher.dispatch({\n eventName: SessionEvents.DEVICE_STATE_UPDATE_LOCKED,\n });\n } else {\n this._sessionEventDispatcher.dispatch({\n eventName: SessionEvents.DEVICE_STATE_UPDATE_CONNECTED,\n });\n }\n })\n .ifLeft(() => {\n this._sessionEventDispatcher.dispatch({\n eventName: SessionEvents.DEVICE_STATE_UPDATE_CONNECTED,\n });\n });\n return result;\n } finally {\n release();\n }\n }\n\n public async sendCommand<Response, Args, ErrorStatusCodes>(\n command: Command<Response, Args, ErrorStatusCodes>,\n abortTimeout?: number,\n ): Promise<CommandResult<Response, ErrorStatusCodes>> {\n const apdu = command.getApdu();\n\n const response = await this.sendApdu(apdu.getRawApdu(), {\n isPolling: false,\n triggersDisconnection: command.triggersDisconnection ?? false,\n abortTimeout,\n });\n\n return response.caseOf({\n Left: (err) => {\n throw err;\n },\n Right: (r)
|
|
5
|
-
"mappings": "yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,mBAAAE,IAAA,eAAAC,EAAAH,GACA,IAAAI,EAAiD,gBACjDC,EAA6B,gBAI7BC,EAA6B,2CAC7BC,EAA6B,oCAO7BC,EAGO,kDAGPC,EAAmC,sBAGnCC,EAAyD,qEACzDC,EAA6B,yDAC7BC,EAAiC,6DAIjCC,EAA6B,0BAC7BC,EAGO,0CACPC,EAAuC,oCACvCC,EAA0C,uCAqBnC,MAAMd,CAAc,CACR,IACA,iBACA,aACA,mBACA,sBACA,QACA,kBACT,QACA,wBACS,kBACT,cAAgB,IAAI,eACpB,wBAA0B,IAAI,+BAEtC,YACE,CAAE,gBAAAe,EAAiB,GAAAC,KAAK,EAAAC,IAAO,CAAE,EACjCC,EACAC,EACAC,EACAC,EACA,CACA,KAAK,IAAML,EACX,KAAK,iBAAmBD,EACxB,KAAK,QAAUG,EAAoB,gBAAgB,EACnD,KAAK,mBAAqBC,EAC1B,KAAK,sBAAwBC,EAC7B,KAAK,kBAAoB,CACvB,GAAG,2CACH,GAAGC,CACL,EACA,KAAK,aAAe,IAAI,kBAAoC,CAC1D,iBAAkB,yBAAuB,UACzC,aAAc,eAAa,UAC3B,cAAe,KAAK,iBAAiB,YAAY,EACnD,CAAC,EAED,KAAK,QAAU,IAAI,eACjBH,EACAH,EACA,KAAK,wBACL,CAACO,EAASC,IAAiB,KAAK,YAAYD,EAASC,CAAY,CACnE,EACA,KAAK,wBAA0B,IAAI,yBACjCL,EACA,KAAK,kBACL,KAAK,wBACL,KAAK,gBACP,EACA,IAAI,4BACFA,EACA,KAAK,wBACL,KAAK,iBACL,KAAK,aACJM,GAAU,KAAK,sBAAsBA,CAAK,CAC7C,EAEA,KAAK,kBAAoB,IAAI,mBAAiBN,EAAqB,CACjE,MAAO,IAAM,KAAK,wBAAwB,iBAAiB,EAC3D,KAAM,IAAM,KAAK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,6BAC3B,CAAC,CACH,CAAC,EACID,CACT,QAAE,CACAD,EAAQ,CACV,CACF,CAEA,MAAa,YACXN,EACAC,EACoD,CACpD,
|
|
4
|
+
"sourcesContent": ["import { type Either } from \"purify-ts\";\nimport { BehaviorSubject, type Observable } from \"rxjs\";\nimport { v4 as uuidv4 } from \"uuid\";\n\nimport { type Command } from \"@api/command/Command\";\nimport { type CommandResult } from \"@api/command/model/CommandResult\";\nimport { CommandUtils } from \"@api/command/utils/CommandUtils\";\nimport { DeviceStatus } from \"@api/device/DeviceStatus\";\nimport {\n type DeviceAction,\n type DeviceActionIntermediateValue,\n type ExecuteDeviceActionReturnType,\n} from \"@api/device-action/DeviceAction\";\nimport { type ApduResponse } from \"@api/device-session/ApduResponse\";\nimport {\n type DeviceSessionState,\n DeviceSessionStateType,\n} from \"@api/device-session/DeviceSessionState\";\nimport { type DeviceSessionId } from \"@api/device-session/types\";\nimport { type DmkError } from \"@api/Error\";\nimport { bufferToHexaString } from \"@api/index\";\nimport { type LoggerPublisherService } from \"@api/logger-publisher/service/LoggerPublisherService\";\nimport { type TransportConnectedDevice } from \"@api/transport/model/TransportConnectedDevice\";\nimport { DEVICE_SESSION_REFRESHER_DEFAULT_OPTIONS } from \"@internal/device-session/data/DeviceSessionRefresherConst\";\nimport { MutexService } from \"@internal/device-session/service/MutexService\";\nimport { RefresherService } from \"@internal/device-session/service/RefresherService\";\nimport { type ManagerApiService } from \"@internal/manager-api/service/ManagerApiService\";\nimport { type SecureChannelService } from \"@internal/secure-channel/service/SecureChannelService\";\n\nimport { DevicePinger } from \"./DevicePinger\";\nimport {\n DeviceSessionEventDispatcher,\n SessionEvents,\n} from \"./DeviceSessionEventDispatcher\";\nimport { DeviceSessionRefresher } from \"./DeviceSessionRefresher\";\nimport { DeviceSessionStateHandler } from \"./DeviceSessionStateHandler\";\n\nexport type SessionConstructorArgs = {\n connectedDevice: TransportConnectedDevice;\n id?: DeviceSessionId;\n};\n\nexport type DeviceSessionRefresherOptions = {\n isRefresherDisabled: boolean;\n pollingInterval?: number;\n};\n\ntype SendApduOptions = {\n isPolling?: boolean;\n triggersDisconnection?: boolean;\n abortTimeout?: number;\n};\n\n/**\n * Represents a session with a device.\n */\nexport class DeviceSession {\n private readonly _id: DeviceSessionId;\n private readonly _connectedDevice: TransportConnectedDevice;\n private readonly _deviceState: BehaviorSubject<DeviceSessionState>;\n private readonly _managerApiService: ManagerApiService;\n private readonly _secureChannelService: SecureChannelService;\n private readonly _logger: LoggerPublisherService;\n private readonly _refresherOptions: DeviceSessionRefresherOptions;\n private _pinger: DevicePinger;\n private _deviceSessionRefresher: DeviceSessionRefresher;\n private readonly _refresherService: RefresherService;\n private _commandMutex = new MutexService();\n private _sessionEventDispatcher = new DeviceSessionEventDispatcher();\n\n constructor(\n { connectedDevice, id = uuidv4() }: SessionConstructorArgs,\n loggerModuleFactory: (tag: string) => LoggerPublisherService,\n managerApiService: ManagerApiService,\n secureChannelService: SecureChannelService,\n deviceSessionRefresherOptions: DeviceSessionRefresherOptions | undefined,\n ) {\n this._id = id;\n this._connectedDevice = connectedDevice;\n this._logger = loggerModuleFactory(\"device-session\");\n this._managerApiService = managerApiService;\n this._secureChannelService = secureChannelService;\n this._refresherOptions = {\n ...DEVICE_SESSION_REFRESHER_DEFAULT_OPTIONS,\n ...deviceSessionRefresherOptions,\n };\n this._deviceState = new BehaviorSubject<DeviceSessionState>({\n sessionStateType: DeviceSessionStateType.Connected,\n deviceStatus: DeviceStatus.CONNECTED,\n deviceModelId: this._connectedDevice.deviceModel.id,\n });\n\n this._pinger = new DevicePinger(\n loggerModuleFactory,\n connectedDevice,\n this._sessionEventDispatcher,\n (command, abortTimeout) => this.sendCommand(command, abortTimeout),\n );\n this._deviceSessionRefresher = new DeviceSessionRefresher(\n loggerModuleFactory,\n this._refresherOptions,\n this._sessionEventDispatcher,\n this._connectedDevice,\n );\n new DeviceSessionStateHandler(\n loggerModuleFactory,\n this._sessionEventDispatcher,\n this._connectedDevice,\n this._deviceState,\n (state) => this.setDeviceSessionState(state),\n );\n\n this._refresherService = new RefresherService(loggerModuleFactory, {\n start: () => this._deviceSessionRefresher.restartRefresher(),\n stop: () => this._deviceSessionRefresher.stopRefresher(),\n });\n }\n\n public async initialiseSession(): Promise<void> {\n try {\n await this._pinger.ping();\n } catch (error) {\n this._logger.error(\"Error while initialising session\", {\n data: { error },\n });\n throw error;\n } finally {\n if (!this._refresherOptions.isRefresherDisabled) {\n this._deviceSessionRefresher.startRefresher();\n }\n }\n }\n\n public get id(): DeviceSessionId {\n return this._id;\n }\n\n public get connectedDevice(): TransportConnectedDevice {\n return this._connectedDevice;\n }\n\n public get state(): Observable<DeviceSessionState> {\n return this._deviceState.asObservable();\n }\n\n public getDeviceSessionState(): DeviceSessionState {\n return this._deviceState.getValue();\n }\n\n public setDeviceSessionState(state: DeviceSessionState): void {\n this._deviceState.next(state);\n }\n\n public async sendApdu(\n rawApdu: Uint8Array,\n options: SendApduOptions = {\n isPolling: false,\n triggersDisconnection: false,\n abortTimeout: undefined,\n },\n ): Promise<Either<DmkError, ApduResponse>> {\n const release = await this._commandMutex.lock();\n\n try {\n this._sessionEventDispatcher.dispatch({\n eventName: SessionEvents.DEVICE_STATE_UPDATE_BUSY,\n });\n\n this._logger.debug(`[exchange] => ${bufferToHexaString(rawApdu, false)}`);\n const result = await this._connectedDevice.sendApdu(\n rawApdu,\n options.triggersDisconnection,\n options.abortTimeout,\n );\n\n result\n .ifRight((response: ApduResponse) => {\n this._logger.debug(\n `[exchange] <= ${bufferToHexaString(response.data, false)}${bufferToHexaString(response.statusCode, false)}`,\n );\n if (CommandUtils.isLockedDeviceResponse(response)) {\n this._sessionEventDispatcher.dispatch({\n eventName: SessionEvents.DEVICE_STATE_UPDATE_LOCKED,\n });\n } else {\n this._sessionEventDispatcher.dispatch({\n eventName: SessionEvents.DEVICE_STATE_UPDATE_CONNECTED,\n });\n }\n })\n .ifLeft(() => {\n this._sessionEventDispatcher.dispatch({\n eventName: SessionEvents.DEVICE_STATE_UPDATE_CONNECTED,\n });\n });\n return result;\n } finally {\n release();\n }\n }\n\n public async sendCommand<Response, Args, ErrorStatusCodes>(\n command: Command<Response, Args, ErrorStatusCodes>,\n abortTimeout?: number,\n ): Promise<CommandResult<Response, ErrorStatusCodes>> {\n this._logger.debug(`[sendCommand] ${command.name}`);\n const apdu = command.getApdu();\n\n const response = await this.sendApdu(apdu.getRawApdu(), {\n isPolling: false,\n triggersDisconnection: command.triggersDisconnection ?? false,\n abortTimeout,\n });\n\n return response.caseOf({\n Left: (err) => {\n this._logger.error(\"[sendCommand] error\", { data: { err } });\n throw err;\n },\n Right: (r) => {\n const result = command.parseResponse(\n r,\n this._connectedDevice.deviceModel.id,\n );\n this._logger.debug(\"[sendCommand] result\", { data: { result } });\n return result;\n },\n });\n }\n\n public executeDeviceAction<\n Output,\n Input,\n E extends DmkError,\n IntermediateValue extends DeviceActionIntermediateValue,\n >(\n deviceAction: DeviceAction<Output, Input, E, IntermediateValue>,\n ): ExecuteDeviceActionReturnType<Output, E, IntermediateValue> {\n const { observable, cancel } = deviceAction._execute({\n sendApdu: async (apdu: Uint8Array) => this.sendApdu(apdu),\n sendCommand: async <Response, ErrorStatusCodes, Args>(\n command: Command<Response, ErrorStatusCodes, Args>,\n abortTimeout?: number,\n ) => this.sendCommand(command, abortTimeout),\n getDeviceModel: () => this._connectedDevice.deviceModel,\n getDeviceSessionState: () => this._deviceState.getValue(),\n getDeviceSessionStateObservable: () => this.state,\n setDeviceSessionState: (state: DeviceSessionState) => {\n this.setDeviceSessionState(state);\n return this._deviceState.getValue();\n },\n disableRefresher: (blockerId: string) =>\n this._refresherService.disableRefresher(blockerId),\n getManagerApiService: () => this._managerApiService,\n getSecureChannelService: () => this._secureChannelService,\n });\n return { observable, cancel };\n }\n\n public close(): void {\n this._updateDeviceStatus(DeviceStatus.NOT_CONNECTED);\n this._deviceState.complete();\n this._deviceSessionRefresher.stopRefresher();\n }\n\n public disableRefresher(id: string): () => void {\n return this._refresherService.disableRefresher(id);\n }\n\n private _updateDeviceStatus(deviceStatus: DeviceStatus): void {\n const state = this._deviceState.getValue();\n this._deviceState.next({ ...state, deviceStatus });\n }\n}\n"],
|
|
5
|
+
"mappings": "yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,mBAAAE,IAAA,eAAAC,EAAAH,GACA,IAAAI,EAAiD,gBACjDC,EAA6B,gBAI7BC,EAA6B,2CAC7BC,EAA6B,oCAO7BC,EAGO,kDAGPC,EAAmC,sBAGnCC,EAAyD,qEACzDC,EAA6B,yDAC7BC,EAAiC,6DAIjCC,EAA6B,0BAC7BC,EAGO,0CACPC,EAAuC,oCACvCC,EAA0C,uCAqBnC,MAAMd,CAAc,CACR,IACA,iBACA,aACA,mBACA,sBACA,QACA,kBACT,QACA,wBACS,kBACT,cAAgB,IAAI,eACpB,wBAA0B,IAAI,+BAEtC,YACE,CAAE,gBAAAe,EAAiB,GAAAC,KAAK,EAAAC,IAAO,CAAE,EACjCC,EACAC,EACAC,EACAC,EACA,CACA,KAAK,IAAML,EACX,KAAK,iBAAmBD,EACxB,KAAK,QAAUG,EAAoB,gBAAgB,EACnD,KAAK,mBAAqBC,EAC1B,KAAK,sBAAwBC,EAC7B,KAAK,kBAAoB,CACvB,GAAG,2CACH,GAAGC,CACL,EACA,KAAK,aAAe,IAAI,kBAAoC,CAC1D,iBAAkB,yBAAuB,UACzC,aAAc,eAAa,UAC3B,cAAe,KAAK,iBAAiB,YAAY,EACnD,CAAC,EAED,KAAK,QAAU,IAAI,eACjBH,EACAH,EACA,KAAK,wBACL,CAACO,EAASC,IAAiB,KAAK,YAAYD,EAASC,CAAY,CACnE,EACA,KAAK,wBAA0B,IAAI,yBACjCL,EACA,KAAK,kBACL,KAAK,wBACL,KAAK,gBACP,EACA,IAAI,4BACFA,EACA,KAAK,wBACL,KAAK,iBACL,KAAK,aACJM,GAAU,KAAK,sBAAsBA,CAAK,CAC7C,EAEA,KAAK,kBAAoB,IAAI,mBAAiBN,EAAqB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AAa,aAAa,EACnD,KAAK,aAAa,SAAS,EAC3B,KAAK,wBAAwB,cAAc,CAC7C,CAEO,iBAAiBnB,EAAwB,CAC9C,OAAO,KAAK,kBAAkB,iBAAiBA,CAAE,CACnD,CAEQ,oBAAoBqB,EAAkC,CAC5D,MAAMb,EAAQ,KAAK,aAAa,SAAS,EACzC,KAAK,aAAa,KAAK,CAAE,GAAGA,EAAO,aAAAa,CAAa,CAAC,CACnD,CACF",
|
|
6
6
|
"names": ["DeviceSession_exports", "__export", "DeviceSession", "__toCommonJS", "import_rxjs", "import_uuid", "import_CommandUtils", "import_DeviceStatus", "import_DeviceSessionState", "import_api", "import_DeviceSessionRefresherConst", "import_MutexService", "import_RefresherService", "import_DevicePinger", "import_DeviceSessionEventDispatcher", "import_DeviceSessionRefresher", "import_DeviceSessionStateHandler", "connectedDevice", "id", "uuidv4", "loggerModuleFactory", "managerApiService", "secureChannelService", "deviceSessionRefresherOptions", "command", "abortTimeout", "state", "error", "rawApdu", "options", "release", "result", "response", "apdu", "err", "deviceAction", "observable", "cancel", "blockerId", "deviceStatus"]
|
|
7
7
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";var C=Object.defineProperty;var
|
|
1
|
+
"use strict";var C=Object.defineProperty;var T=Object.getOwnPropertyDescriptor;var g=Object.getOwnPropertyNames;var u=Object.prototype.hasOwnProperty;var A=(t,e)=>{for(var s in e)C(t,s,{get:e[s],enumerable:!0})},F=(t,e,s,c)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of g(e))!u.call(t,i)&&i!==s&&C(t,i,{get:()=>e[i],enumerable:!(c=T(e,i))||c.enumerable});return t};var G=t=>F(C({},"__esModule",{value:!0}),t);var P={};A(P,{discoveryModuleFactory:()=>M});module.exports=G(P);var r=require("inversify"),n=require("../../discovery/use-case/ConnectUseCase"),U=require("../../discovery/use-case/DisconnectUseCase"),m=require("../../discovery/use-case/GetConnectedDeviceUseCase"),v=require("../../discovery/use-case/ListConnectedDevicesUseCase"),D=require("../../discovery/use-case/ListenToAvailableDevicesUseCase"),p=require("../../discovery/use-case/ListenToConnectedDeviceUseCase"),f=require("../../discovery/use-case/ReconnectUseCase"),l=require("../../discovery/use-case/StartDiscoveringUseCase"),L=require("../../discovery/use-case/StopDiscoveringUseCase"),a=require("../../../../src/di.stub"),o=require("./discoveryTypes");const M=({stub:t=!1})=>new r.ContainerModule(({bind:e,rebindSync:s})=>{e(o.discoveryTypes.ConnectUseCase).to(n.ConnectUseCase),e(o.discoveryTypes.DisconnectUseCase).to(U.DisconnectUseCase),e(o.discoveryTypes.ReconnectUseCase).to(f.ReconnectUseCase),e(o.discoveryTypes.StartDiscoveringUseCase).to(l.StartDiscoveringUseCase),e(o.discoveryTypes.StopDiscoveringUseCase).to(L.StopDiscoveringUseCase),e(o.discoveryTypes.GetConnectedDeviceUseCase).to(m.GetConnectedDeviceUseCase),e(o.discoveryTypes.ListenToAvailableDevicesUseCase).to(D.ListenToAvailableDevicesUseCase),e(o.discoveryTypes.ListenToConnectedDeviceUseCase).to(p.ListenToConnectedDeviceUseCase),e(o.discoveryTypes.ListConnectedDevicesUseCase).to(v.ListConnectedDevicesUseCase),t&&(s(o.discoveryTypes.ConnectUseCase).to(a.StubUseCase),s(o.discoveryTypes.DisconnectUseCase).to(a.StubUseCase),s(o.discoveryTypes.StartDiscoveringUseCase).to(a.StubUseCase),s(o.discoveryTypes.StopDiscoveringUseCase).to(a.StubUseCase),s(o.discoveryTypes.GetConnectedDeviceUseCase).to(a.StubUseCase),s(o.discoveryTypes.ListenToAvailableDevicesUseCase).to(a.StubUseCase),s(o.discoveryTypes.ListenToConnectedDeviceUseCase).to(a.StubUseCase),s(o.discoveryTypes.ListConnectedDevicesUseCase).to(a.StubUseCase))});0&&(module.exports={discoveryModuleFactory});
|
|
2
2
|
//# sourceMappingURL=discoveryModule.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../../src/internal/discovery/di/discoveryModule.ts"],
|
|
4
|
-
"sourcesContent": ["import { ContainerModule } from \"inversify\";\n\nimport { ConnectUseCase } from \"@internal/discovery/use-case/ConnectUseCase\";\nimport { DisconnectUseCase } from \"@internal/discovery/use-case/DisconnectUseCase\";\nimport { GetConnectedDeviceUseCase } from \"@internal/discovery/use-case/GetConnectedDeviceUseCase\";\nimport { ListConnectedDevicesUseCase } from \"@internal/discovery/use-case/ListConnectedDevicesUseCase\";\nimport { ListenToAvailableDevicesUseCase } from \"@internal/discovery/use-case/ListenToAvailableDevicesUseCase\";\nimport { ListenToConnectedDeviceUseCase } from \"@internal/discovery/use-case/ListenToConnectedDeviceUseCase\";\nimport { StartDiscoveringUseCase } from \"@internal/discovery/use-case/StartDiscoveringUseCase\";\nimport { StopDiscoveringUseCase } from \"@internal/discovery/use-case/StopDiscoveringUseCase\";\nimport { StubUseCase } from \"@root/src/di.stub\";\n\nimport { discoveryTypes } from \"./discoveryTypes\";\n\ntype FactoryProps = {\n stub: boolean;\n};\n\nexport const discoveryModuleFactory = ({ stub = false }: FactoryProps) =>\n new ContainerModule(({ bind, rebindSync }) => {\n bind(discoveryTypes.ConnectUseCase).to(ConnectUseCase);\n bind(discoveryTypes.DisconnectUseCase).to(DisconnectUseCase);\n bind(discoveryTypes.StartDiscoveringUseCase).to(StartDiscoveringUseCase);\n bind(discoveryTypes.StopDiscoveringUseCase).to(StopDiscoveringUseCase);\n bind(discoveryTypes.GetConnectedDeviceUseCase).to(\n GetConnectedDeviceUseCase,\n );\n bind(discoveryTypes.ListenToAvailableDevicesUseCase).to(\n ListenToAvailableDevicesUseCase,\n );\n bind(discoveryTypes.ListenToConnectedDeviceUseCase).to(\n ListenToConnectedDeviceUseCase,\n );\n bind(discoveryTypes.ListConnectedDevicesUseCase).to(\n ListConnectedDevicesUseCase,\n );\n\n if (stub) {\n rebindSync(discoveryTypes.ConnectUseCase).to(StubUseCase);\n rebindSync(discoveryTypes.DisconnectUseCase).to(StubUseCase);\n rebindSync(discoveryTypes.StartDiscoveringUseCase).to(StubUseCase);\n rebindSync(discoveryTypes.StopDiscoveringUseCase).to(StubUseCase);\n rebindSync(discoveryTypes.GetConnectedDeviceUseCase).to(StubUseCase);\n rebindSync(discoveryTypes.ListenToAvailableDevicesUseCase).to(\n StubUseCase,\n );\n rebindSync(discoveryTypes.ListenToConnectedDeviceUseCase).to(StubUseCase);\n rebindSync(discoveryTypes.ListConnectedDevicesUseCase).to(StubUseCase);\n }\n });\n"],
|
|
5
|
-
"mappings": "yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,4BAAAE,IAAA,eAAAC,EAAAH,GAAA,IAAAI,EAAgC,qBAEhCC,EAA+B,uDAC/BC,EAAkC,0DAClCC,EAA0C,kEAC1CC,EAA4C,oEAC5CC,EAAgD,wEAChDC,EAA+C,uEAC/CC,EAAwC,gEACxCC,EAAuC,+DACvCC,EAA4B,6BAE5BC,EAA+B,4BAMxB,
|
|
6
|
-
"names": ["discoveryModule_exports", "__export", "discoveryModuleFactory", "__toCommonJS", "import_inversify", "import_ConnectUseCase", "import_DisconnectUseCase", "import_GetConnectedDeviceUseCase", "import_ListConnectedDevicesUseCase", "import_ListenToAvailableDevicesUseCase", "import_ListenToConnectedDeviceUseCase", "import_StartDiscoveringUseCase", "import_StopDiscoveringUseCase", "import_di", "import_discoveryTypes", "stub", "bind", "rebindSync"]
|
|
4
|
+
"sourcesContent": ["import { ContainerModule } from \"inversify\";\n\nimport { ConnectUseCase } from \"@internal/discovery/use-case/ConnectUseCase\";\nimport { DisconnectUseCase } from \"@internal/discovery/use-case/DisconnectUseCase\";\nimport { GetConnectedDeviceUseCase } from \"@internal/discovery/use-case/GetConnectedDeviceUseCase\";\nimport { ListConnectedDevicesUseCase } from \"@internal/discovery/use-case/ListConnectedDevicesUseCase\";\nimport { ListenToAvailableDevicesUseCase } from \"@internal/discovery/use-case/ListenToAvailableDevicesUseCase\";\nimport { ListenToConnectedDeviceUseCase } from \"@internal/discovery/use-case/ListenToConnectedDeviceUseCase\";\nimport { ReconnectUseCase } from \"@internal/discovery/use-case/ReconnectUseCase\";\nimport { StartDiscoveringUseCase } from \"@internal/discovery/use-case/StartDiscoveringUseCase\";\nimport { StopDiscoveringUseCase } from \"@internal/discovery/use-case/StopDiscoveringUseCase\";\nimport { StubUseCase } from \"@root/src/di.stub\";\n\nimport { discoveryTypes } from \"./discoveryTypes\";\n\ntype FactoryProps = {\n stub: boolean;\n};\n\nexport const discoveryModuleFactory = ({ stub = false }: FactoryProps) =>\n new ContainerModule(({ bind, rebindSync }) => {\n bind(discoveryTypes.ConnectUseCase).to(ConnectUseCase);\n bind(discoveryTypes.DisconnectUseCase).to(DisconnectUseCase);\n bind(discoveryTypes.ReconnectUseCase).to(ReconnectUseCase);\n bind(discoveryTypes.StartDiscoveringUseCase).to(StartDiscoveringUseCase);\n bind(discoveryTypes.StopDiscoveringUseCase).to(StopDiscoveringUseCase);\n bind(discoveryTypes.GetConnectedDeviceUseCase).to(\n GetConnectedDeviceUseCase,\n );\n bind(discoveryTypes.ListenToAvailableDevicesUseCase).to(\n ListenToAvailableDevicesUseCase,\n );\n bind(discoveryTypes.ListenToConnectedDeviceUseCase).to(\n ListenToConnectedDeviceUseCase,\n );\n bind(discoveryTypes.ListConnectedDevicesUseCase).to(\n ListConnectedDevicesUseCase,\n );\n\n if (stub) {\n rebindSync(discoveryTypes.ConnectUseCase).to(StubUseCase);\n rebindSync(discoveryTypes.DisconnectUseCase).to(StubUseCase);\n rebindSync(discoveryTypes.StartDiscoveringUseCase).to(StubUseCase);\n rebindSync(discoveryTypes.StopDiscoveringUseCase).to(StubUseCase);\n rebindSync(discoveryTypes.GetConnectedDeviceUseCase).to(StubUseCase);\n rebindSync(discoveryTypes.ListenToAvailableDevicesUseCase).to(\n StubUseCase,\n );\n rebindSync(discoveryTypes.ListenToConnectedDeviceUseCase).to(StubUseCase);\n rebindSync(discoveryTypes.ListConnectedDevicesUseCase).to(StubUseCase);\n }\n });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AC",
|
|
6
|
+
"names": ["discoveryModule_exports", "__export", "discoveryModuleFactory", "__toCommonJS", "import_inversify", "import_ConnectUseCase", "import_DisconnectUseCase", "import_GetConnectedDeviceUseCase", "import_ListConnectedDevicesUseCase", "import_ListenToAvailableDevicesUseCase", "import_ListenToConnectedDeviceUseCase", "import_ReconnectUseCase", "import_StartDiscoveringUseCase", "import_StopDiscoveringUseCase", "import_di", "import_discoveryTypes", "stub", "bind", "rebindSync"]
|
|
7
7
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";var r=require("inversify"),n=require("../../../api/transport/model/__mocks__/TransportMock"),c=require("../../device-model/di/deviceModelModule"),i=require("../../device-session/di/deviceSessionModule"),a=require("../../discovery/use-case/ConnectUseCase"),m=require("../../discovery/use-case/DisconnectUseCase"),p=require("../../discovery/use-case/ListConnectedDevicesUseCase"),f=require("../../discovery/use-case/ListenToAvailableDevicesUseCase"),l=require("../../discovery/use-case/StartDiscoveringUseCase"),d=require("../../discovery/use-case/StopDiscoveringUseCase"),
|
|
1
|
+
"use strict";var r=require("inversify"),n=require("../../../api/transport/model/__mocks__/TransportMock"),c=require("../../device-model/di/deviceModelModule"),i=require("../../device-session/di/deviceSessionModule"),a=require("../../discovery/use-case/ConnectUseCase"),m=require("../../discovery/use-case/DisconnectUseCase"),p=require("../../discovery/use-case/ListConnectedDevicesUseCase"),f=require("../../discovery/use-case/ListenToAvailableDevicesUseCase"),l=require("../../discovery/use-case/ReconnectUseCase"),C=require("../../discovery/use-case/StartDiscoveringUseCase"),d=require("../../discovery/use-case/StopDiscoveringUseCase"),U=require("../../logger-publisher/di/loggerModule"),v=require("../../manager-api/di/managerApiModule"),g=require("../../secure-channel/di/secureChannelModule"),u=require("../../transport/di/transportModule"),y=require("./discoveryModule"),o=require("./discoveryTypes");describe("discoveryModuleFactory",()=>{let e,t,s;beforeEach(()=>{t=(0,y.discoveryModuleFactory)({stub:!1}),e=new r.Container,s=new n.TransportMock,e.loadSync(t,(0,U.loggerModuleFactory)(),(0,c.deviceModelModuleFactory)({stub:!1}),(0,i.deviceSessionModuleFactory)(),(0,u.transportModuleFactory)({transports:[vi.fn().mockImplementation(()=>s)]}),(0,v.managerApiModuleFactory)({config:{managerApiUrl:"http://fake.url",mockUrl:"http://fake-mock.url"}}),(0,g.secureChannelModuleFactory)({config:{webSocketUrl:"http://fake-websocket.url"}}))}),it("should return the device module",()=>{expect(t).toBeDefined()}),it("should return none mocked use cases",()=>{const D=e.get(o.discoveryTypes.StartDiscoveringUseCase);expect(D).toBeInstanceOf(C.StartDiscoveringUseCase);const k=e.get(o.discoveryTypes.StopDiscoveringUseCase);expect(k).toBeInstanceOf(d.StopDiscoveringUseCase);const M=e.get(o.discoveryTypes.DisconnectUseCase);expect(M).toBeInstanceOf(m.DisconnectUseCase);const b=e.get(o.discoveryTypes.ConnectUseCase);expect(b).toBeInstanceOf(a.ConnectUseCase);const F=e.get(o.discoveryTypes.ListenToAvailableDevicesUseCase);expect(F).toBeInstanceOf(f.ListenToAvailableDevicesUseCase);const h=e.get(o.discoveryTypes.ListConnectedDevicesUseCase);expect(h).toBeInstanceOf(p.ListConnectedDevicesUseCase);const x=e.get(o.discoveryTypes.ReconnectUseCase);expect(x).toBeInstanceOf(l.ReconnectUseCase)})});
|
|
2
2
|
//# sourceMappingURL=discoveryModule.test.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../../src/internal/discovery/di/discoveryModule.test.ts"],
|
|
4
|
-
"sourcesContent": ["import { Container } from \"inversify\";\n\nimport { TransportMock } from \"@api/transport/model/__mocks__/TransportMock\";\nimport { type DmkConfig, type Transport } from \"@api/types\";\nimport { deviceModelModuleFactory } from \"@internal/device-model/di/deviceModelModule\";\nimport { deviceSessionModuleFactory } from \"@internal/device-session/di/deviceSessionModule\";\nimport { ConnectUseCase } from \"@internal/discovery/use-case/ConnectUseCase\";\nimport { DisconnectUseCase } from \"@internal/discovery/use-case/DisconnectUseCase\";\nimport { ListConnectedDevicesUseCase } from \"@internal/discovery/use-case/ListConnectedDevicesUseCase\";\nimport { ListenToAvailableDevicesUseCase } from \"@internal/discovery/use-case/ListenToAvailableDevicesUseCase\";\nimport { StartDiscoveringUseCase } from \"@internal/discovery/use-case/StartDiscoveringUseCase\";\nimport { StopDiscoveringUseCase } from \"@internal/discovery/use-case/StopDiscoveringUseCase\";\nimport { loggerModuleFactory } from \"@internal/logger-publisher/di/loggerModule\";\nimport { managerApiModuleFactory } from \"@internal/manager-api/di/managerApiModule\";\nimport { secureChannelModuleFactory } from \"@internal/secure-channel/di/secureChannelModule\";\nimport { transportModuleFactory } from \"@internal/transport/di/transportModule\";\n\nimport { discoveryModuleFactory } from \"./discoveryModule\";\nimport { discoveryTypes } from \"./discoveryTypes\";\n\ndescribe(\"discoveryModuleFactory\", () => {\n let container: Container;\n let mod: ReturnType<typeof discoveryModuleFactory>;\n let transport: Transport;\n beforeEach(() => {\n mod = discoveryModuleFactory({ stub: false });\n container = new Container();\n transport = new TransportMock();\n\n container.loadSync(\n mod,\n // The following modules are injected into discovery module\n loggerModuleFactory(),\n deviceModelModuleFactory({ stub: false }),\n deviceSessionModuleFactory(),\n transportModuleFactory({\n transports: [vi.fn().mockImplementation(() => transport)],\n }),\n managerApiModuleFactory({\n config: {\n managerApiUrl: \"http://fake.url\",\n mockUrl: \"http://fake-mock.url\",\n } as DmkConfig,\n }),\n secureChannelModuleFactory({\n config: {\n webSocketUrl: \"http://fake-websocket.url\",\n } as DmkConfig,\n }),\n );\n });\n it(\"should return the device module\", () => {\n expect(mod).toBeDefined();\n });\n\n it(\"should return none mocked use cases\", () => {\n const startDiscoveringUseCase = container.get(\n discoveryTypes.StartDiscoveringUseCase,\n );\n expect(startDiscoveringUseCase).toBeInstanceOf(StartDiscoveringUseCase);\n\n const stopDiscoveringUseCase = container.get(\n discoveryTypes.StopDiscoveringUseCase,\n );\n expect(stopDiscoveringUseCase).toBeInstanceOf(StopDiscoveringUseCase);\n\n const disconnectUseCase = container.get(discoveryTypes.DisconnectUseCase);\n expect(disconnectUseCase).toBeInstanceOf(DisconnectUseCase);\n\n const connectUseCase = container.get(discoveryTypes.ConnectUseCase);\n expect(connectUseCase).toBeInstanceOf(ConnectUseCase);\n\n const listenToAvailableDevicesUseCase = container.get(\n discoveryTypes.ListenToAvailableDevicesUseCase,\n );\n expect(listenToAvailableDevicesUseCase).toBeInstanceOf(\n ListenToAvailableDevicesUseCase,\n );\n const listConnectedDevicesUseCase = container.get(\n discoveryTypes.ListConnectedDevicesUseCase,\n );\n expect(listConnectedDevicesUseCase).toBeInstanceOf(\n ListConnectedDevicesUseCase,\n );\n });\n});\n"],
|
|
5
|
-
"mappings": "aAAA,IAAAA,EAA0B,qBAE1BC,EAA8B,wDAE9BC,EAAyC,uDACzCC,EAA2C,2DAC3CC,EAA+B,uDAC/BC,EAAkC,0DAClCC,EAA4C,oEAC5CC,EAAgD,wEAChDC,EAAwC,gEACxCC,EAAuC,+DACvCC,EAAoC,sDACpCC,EAAwC,qDACxCC,EAA2C,2DAC3CC,EAAuC,kDAEvCC,EAAuC,6BACvCC,EAA+B,4BAE/B,SAAS,yBAA0B,IAAM,CACvC,IAAIC,EACAC,EACAC,EACJ,WAAW,IAAM,CACfD,KAAM,0BAAuB,CAAE,KAAM,EAAM,CAAC,EAC5CD,EAAY,IAAI,YAChBE,EAAY,IAAI,gBAEhBF,EAAU,SACRC,KAEA,uBAAoB,KACpB,4BAAyB,CAAE,KAAM,EAAM,CAAC,KACxC,8BAA2B,KAC3B,0BAAuB,CACrB,WAAY,CAAC,GAAG,GAAG,EAAE,mBAAmB,IAAMC,CAAS,CAAC,CAC1D,CAAC,KACD,2BAAwB,CACtB,OAAQ,CACN,cAAe,kBACf,QAAS,sBACX,CACF,CAAC,KACD,8BAA2B,CACzB,OAAQ,CACN,aAAc,2BAChB,CACF,CAAC,CACH,CACF,CAAC,EACD,GAAG,kCAAmC,IAAM,CAC1C,OAAOD,CAAG,EAAE,YAAY,CAC1B,CAAC,EAED,GAAG,sCAAuC,IAAM,CAC9C,MAAME,EAA0BH,EAAU,IACxC,iBAAe,uBACjB,EACA,OAAOG,CAAuB,EAAE,eAAe,yBAAuB,EAEtE,MAAMC,EAAyBJ,EAAU,IACvC,iBAAe,sBACjB,EACA,OAAOI,CAAsB,EAAE,eAAe,wBAAsB,EAEpE,MAAMC,EAAoBL,EAAU,IAAI,iBAAe,iBAAiB,EACxE,OAAOK,CAAiB,EAAE,eAAe,mBAAiB,EAE1D,MAAMC,EAAiBN,EAAU,IAAI,iBAAe,cAAc,EAClE,OAAOM,CAAc,EAAE,eAAe,gBAAc,EAEpD,MAAMC,EAAkCP,EAAU,IAChD,iBAAe,+BACjB,EACA,OAAOO,CAA+B,EAAE,eACtC,iCACF,EACA,MAAMC,EAA8BR,EAAU,IAC5C,iBAAe,2BACjB,EACA,OAAOQ,CAA2B,EAAE,eAClC,6BACF,
|
|
6
|
-
"names": ["import_inversify", "import_TransportMock", "import_deviceModelModule", "import_deviceSessionModule", "import_ConnectUseCase", "import_DisconnectUseCase", "import_ListConnectedDevicesUseCase", "import_ListenToAvailableDevicesUseCase", "import_StartDiscoveringUseCase", "import_StopDiscoveringUseCase", "import_loggerModule", "import_managerApiModule", "import_secureChannelModule", "import_transportModule", "import_discoveryModule", "import_discoveryTypes", "container", "mod", "transport", "startDiscoveringUseCase", "stopDiscoveringUseCase", "disconnectUseCase", "connectUseCase", "listenToAvailableDevicesUseCase", "listConnectedDevicesUseCase"]
|
|
4
|
+
"sourcesContent": ["import { Container } from \"inversify\";\n\nimport { TransportMock } from \"@api/transport/model/__mocks__/TransportMock\";\nimport { type DmkConfig, type Transport } from \"@api/types\";\nimport { deviceModelModuleFactory } from \"@internal/device-model/di/deviceModelModule\";\nimport { deviceSessionModuleFactory } from \"@internal/device-session/di/deviceSessionModule\";\nimport { ConnectUseCase } from \"@internal/discovery/use-case/ConnectUseCase\";\nimport { DisconnectUseCase } from \"@internal/discovery/use-case/DisconnectUseCase\";\nimport { ListConnectedDevicesUseCase } from \"@internal/discovery/use-case/ListConnectedDevicesUseCase\";\nimport { ListenToAvailableDevicesUseCase } from \"@internal/discovery/use-case/ListenToAvailableDevicesUseCase\";\nimport { ReconnectUseCase } from \"@internal/discovery/use-case/ReconnectUseCase\";\nimport { StartDiscoveringUseCase } from \"@internal/discovery/use-case/StartDiscoveringUseCase\";\nimport { StopDiscoveringUseCase } from \"@internal/discovery/use-case/StopDiscoveringUseCase\";\nimport { loggerModuleFactory } from \"@internal/logger-publisher/di/loggerModule\";\nimport { managerApiModuleFactory } from \"@internal/manager-api/di/managerApiModule\";\nimport { secureChannelModuleFactory } from \"@internal/secure-channel/di/secureChannelModule\";\nimport { transportModuleFactory } from \"@internal/transport/di/transportModule\";\n\nimport { discoveryModuleFactory } from \"./discoveryModule\";\nimport { discoveryTypes } from \"./discoveryTypes\";\n\ndescribe(\"discoveryModuleFactory\", () => {\n let container: Container;\n let mod: ReturnType<typeof discoveryModuleFactory>;\n let transport: Transport;\n beforeEach(() => {\n mod = discoveryModuleFactory({ stub: false });\n container = new Container();\n transport = new TransportMock();\n\n container.loadSync(\n mod,\n // The following modules are injected into discovery module\n loggerModuleFactory(),\n deviceModelModuleFactory({ stub: false }),\n deviceSessionModuleFactory(),\n transportModuleFactory({\n transports: [vi.fn().mockImplementation(() => transport)],\n }),\n managerApiModuleFactory({\n config: {\n managerApiUrl: \"http://fake.url\",\n mockUrl: \"http://fake-mock.url\",\n } as DmkConfig,\n }),\n secureChannelModuleFactory({\n config: {\n webSocketUrl: \"http://fake-websocket.url\",\n } as DmkConfig,\n }),\n );\n });\n it(\"should return the device module\", () => {\n expect(mod).toBeDefined();\n });\n\n it(\"should return none mocked use cases\", () => {\n const startDiscoveringUseCase = container.get(\n discoveryTypes.StartDiscoveringUseCase,\n );\n expect(startDiscoveringUseCase).toBeInstanceOf(StartDiscoveringUseCase);\n\n const stopDiscoveringUseCase = container.get(\n discoveryTypes.StopDiscoveringUseCase,\n );\n expect(stopDiscoveringUseCase).toBeInstanceOf(StopDiscoveringUseCase);\n\n const disconnectUseCase = container.get(discoveryTypes.DisconnectUseCase);\n expect(disconnectUseCase).toBeInstanceOf(DisconnectUseCase);\n\n const connectUseCase = container.get(discoveryTypes.ConnectUseCase);\n expect(connectUseCase).toBeInstanceOf(ConnectUseCase);\n\n const listenToAvailableDevicesUseCase = container.get(\n discoveryTypes.ListenToAvailableDevicesUseCase,\n );\n expect(listenToAvailableDevicesUseCase).toBeInstanceOf(\n ListenToAvailableDevicesUseCase,\n );\n const listConnectedDevicesUseCase = container.get(\n discoveryTypes.ListConnectedDevicesUseCase,\n );\n expect(listConnectedDevicesUseCase).toBeInstanceOf(\n ListConnectedDevicesUseCase,\n );\n const reconnectUseCase = container.get(discoveryTypes.ReconnectUseCase);\n expect(reconnectUseCase).toBeInstanceOf(ReconnectUseCase);\n });\n});\n"],
|
|
5
|
+
"mappings": "aAAA,IAAAA,EAA0B,qBAE1BC,EAA8B,wDAE9BC,EAAyC,uDACzCC,EAA2C,2DAC3CC,EAA+B,uDAC/BC,EAAkC,0DAClCC,EAA4C,oEAC5CC,EAAgD,wEAChDC,EAAiC,yDACjCC,EAAwC,gEACxCC,EAAuC,+DACvCC,EAAoC,sDACpCC,EAAwC,qDACxCC,EAA2C,2DAC3CC,EAAuC,kDAEvCC,EAAuC,6BACvCC,EAA+B,4BAE/B,SAAS,yBAA0B,IAAM,CACvC,IAAIC,EACAC,EACAC,EACJ,WAAW,IAAM,CACfD,KAAM,0BAAuB,CAAE,KAAM,EAAM,CAAC,EAC5CD,EAAY,IAAI,YAChBE,EAAY,IAAI,gBAEhBF,EAAU,SACRC,KAEA,uBAAoB,KACpB,4BAAyB,CAAE,KAAM,EAAM,CAAC,KACxC,8BAA2B,KAC3B,0BAAuB,CACrB,WAAY,CAAC,GAAG,GAAG,EAAE,mBAAmB,IAAMC,CAAS,CAAC,CAC1D,CAAC,KACD,2BAAwB,CACtB,OAAQ,CACN,cAAe,kBACf,QAAS,sBACX,CACF,CAAC,KACD,8BAA2B,CACzB,OAAQ,CACN,aAAc,2BAChB,CACF,CAAC,CACH,CACF,CAAC,EACD,GAAG,kCAAmC,IAAM,CAC1C,OAAOD,CAAG,EAAE,YAAY,CAC1B,CAAC,EAED,GAAG,sCAAuC,IAAM,CAC9C,MAAME,EAA0BH,EAAU,IACxC,iBAAe,uBACjB,EACA,OAAOG,CAAuB,EAAE,eAAe,yBAAuB,EAEtE,MAAMC,EAAyBJ,EAAU,IACvC,iBAAe,sBACjB,EACA,OAAOI,CAAsB,EAAE,eAAe,wBAAsB,EAEpE,MAAMC,EAAoBL,EAAU,IAAI,iBAAe,iBAAiB,EACxE,OAAOK,CAAiB,EAAE,eAAe,mBAAiB,EAE1D,MAAMC,EAAiBN,EAAU,IAAI,iBAAe,cAAc,EAClE,OAAOM,CAAc,EAAE,eAAe,gBAAc,EAEpD,MAAMC,EAAkCP,EAAU,IAChD,iBAAe,+BACjB,EACA,OAAOO,CAA+B,EAAE,eACtC,iCACF,EACA,MAAMC,EAA8BR,EAAU,IAC5C,iBAAe,2BACjB,EACA,OAAOQ,CAA2B,EAAE,eAClC,6BACF,EACA,MAAMC,EAAmBT,EAAU,IAAI,iBAAe,gBAAgB,EACtE,OAAOS,CAAgB,EAAE,eAAe,kBAAgB,CAC1D,CAAC,CACH,CAAC",
|
|
6
|
+
"names": ["import_inversify", "import_TransportMock", "import_deviceModelModule", "import_deviceSessionModule", "import_ConnectUseCase", "import_DisconnectUseCase", "import_ListConnectedDevicesUseCase", "import_ListenToAvailableDevicesUseCase", "import_ReconnectUseCase", "import_StartDiscoveringUseCase", "import_StopDiscoveringUseCase", "import_loggerModule", "import_managerApiModule", "import_secureChannelModule", "import_transportModule", "import_discoveryModule", "import_discoveryTypes", "container", "mod", "transport", "startDiscoveringUseCase", "stopDiscoveringUseCase", "disconnectUseCase", "connectUseCase", "listenToAvailableDevicesUseCase", "listConnectedDevicesUseCase", "reconnectUseCase"]
|
|
7
7
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";var
|
|
1
|
+
"use strict";var c=Object.defineProperty;var i=Object.getOwnPropertyDescriptor;var C=Object.getOwnPropertyNames;var a=Object.prototype.hasOwnProperty;var U=(s,e)=>{for(var n in e)c(s,n,{get:e[n],enumerable:!0})},r=(s,e,n,t)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of C(e))!a.call(s,o)&&o!==n&&c(s,o,{get:()=>e[o],enumerable:!(t=i(e,o))||t.enumerable});return s};var v=s=>r(c({},"__esModule",{value:!0}),s);var l={};U(l,{discoveryTypes:()=>D});module.exports=v(l);const D={StartDiscoveringUseCase:Symbol.for("StartDiscoveringUseCase"),StopDiscoveringUseCase:Symbol.for("StopDiscoveringUseCase"),ConnectUseCase:Symbol.for("ConnectUseCase"),DisconnectUseCase:Symbol.for("DisconnectUseCase"),GetConnectedDeviceUseCase:Symbol.for("GetConnectedDeviceUseCase"),ListenToAvailableDevicesUseCase:Symbol.for("ListenToAvailableDevicesUseCase"),ListenToConnectedDeviceUseCase:Symbol.for("ListenToConnectedDeviceUseCase"),ListConnectedDevicesUseCase:Symbol.for("ListConnectedDevicesUseCase"),ReconnectUseCase:Symbol.for("ReconnectUseCase")};0&&(module.exports={discoveryTypes});
|
|
2
2
|
//# sourceMappingURL=discoveryTypes.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../../src/internal/discovery/di/discoveryTypes.ts"],
|
|
4
|
-
"sourcesContent": ["export const discoveryTypes = {\n StartDiscoveringUseCase: Symbol.for(\"StartDiscoveringUseCase\"),\n StopDiscoveringUseCase: Symbol.for(\"StopDiscoveringUseCase\"),\n ConnectUseCase: Symbol.for(\"ConnectUseCase\"),\n DisconnectUseCase: Symbol.for(\"DisconnectUseCase\"),\n GetConnectedDeviceUseCase: Symbol.for(\"GetConnectedDeviceUseCase\"),\n ListenToAvailableDevicesUseCase: Symbol.for(\n \"ListenToAvailableDevicesUseCase\",\n ),\n ListenToConnectedDeviceUseCase: Symbol.for(\"ListenToConnectedDeviceUseCase\"),\n ListConnectedDevicesUseCase: Symbol.for(\"ListConnectedDevicesUseCase\"),\n};\n"],
|
|
5
|
-
"mappings": "yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,oBAAAE,IAAA,eAAAC,EAAAH,GAAO,MAAME,EAAiB,CAC5B,wBAAyB,OAAO,IAAI,yBAAyB,EAC7D,uBAAwB,OAAO,IAAI,wBAAwB,EAC3D,eAAgB,OAAO,IAAI,gBAAgB,EAC3C,kBAAmB,OAAO,IAAI,mBAAmB,EACjD,0BAA2B,OAAO,IAAI,2BAA2B,EACjE,gCAAiC,OAAO,IACtC,iCACF,EACA,+BAAgC,OAAO,IAAI,gCAAgC,EAC3E,4BAA6B,OAAO,IAAI,6BAA6B,
|
|
4
|
+
"sourcesContent": ["export const discoveryTypes = {\n StartDiscoveringUseCase: Symbol.for(\"StartDiscoveringUseCase\"),\n StopDiscoveringUseCase: Symbol.for(\"StopDiscoveringUseCase\"),\n ConnectUseCase: Symbol.for(\"ConnectUseCase\"),\n DisconnectUseCase: Symbol.for(\"DisconnectUseCase\"),\n GetConnectedDeviceUseCase: Symbol.for(\"GetConnectedDeviceUseCase\"),\n ListenToAvailableDevicesUseCase: Symbol.for(\n \"ListenToAvailableDevicesUseCase\",\n ),\n ListenToConnectedDeviceUseCase: Symbol.for(\"ListenToConnectedDeviceUseCase\"),\n ListConnectedDevicesUseCase: Symbol.for(\"ListConnectedDevicesUseCase\"),\n ReconnectUseCase: Symbol.for(\"ReconnectUseCase\"),\n};\n"],
|
|
5
|
+
"mappings": "yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,oBAAAE,IAAA,eAAAC,EAAAH,GAAO,MAAME,EAAiB,CAC5B,wBAAyB,OAAO,IAAI,yBAAyB,EAC7D,uBAAwB,OAAO,IAAI,wBAAwB,EAC3D,eAAgB,OAAO,IAAI,gBAAgB,EAC3C,kBAAmB,OAAO,IAAI,mBAAmB,EACjD,0BAA2B,OAAO,IAAI,2BAA2B,EACjE,gCAAiC,OAAO,IACtC,iCACF,EACA,+BAAgC,OAAO,IAAI,gCAAgC,EAC3E,4BAA6B,OAAO,IAAI,6BAA6B,EACrE,iBAAkB,OAAO,IAAI,kBAAkB,CACjD",
|
|
6
6
|
"names": ["discoveryTypes_exports", "__export", "discoveryTypes", "__toCommonJS"]
|
|
7
7
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";var
|
|
1
|
+
"use strict";var p=Object.defineProperty;var S=Object.getOwnPropertyDescriptor;var _=Object.getOwnPropertyNames;var A=Object.prototype.hasOwnProperty;var C=(n,e)=>{for(var s in e)p(n,s,{get:e[s],enumerable:!0})},T=(n,e,s,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of _(e))!A.call(n,r)&&r!==s&&p(n,r,{get:()=>e[r],enumerable:!(i=S(e,r))||i.enumerable});return n};var I=n=>T(p({},"__esModule",{value:!0}),n),m=(n,e,s,i)=>{for(var r=i>1?void 0:i?S(e,s):e,o=n.length-1,t;o>=0;o--)(t=n[o])&&(r=(i?t(e,s,r):t(r))||r);return i&&r&&p(e,s,r),r},a=(n,e)=>(s,i)=>e(s,i,n);var E={};C(E,{ConnectUseCase:()=>v});module.exports=I(E);var c=require("inversify"),g=require("purify-ts"),h=require("../../../api/transport/model/Errors"),d=require("../../device-session/di/deviceSessionTypes"),l=require("../../device-session/model/DeviceSession"),D=require("../../logger-publisher/di/loggerTypes"),f=require("../../manager-api/di/managerApiTypes"),y=require("../../secure-channel/di/secureChannelTypes"),u=require("../../transport/di/transportDiTypes");let v=class{_transportService;_sessionService;_loggerFactory;_managerApi;_secureChannel;_logger;constructor(e,s,i,r,o){this._sessionService=s,this._transportService=e,this._loggerFactory=i,this._logger=i("ConnectUseCase"),this._managerApi=r,this._secureChannel=o}handleDeviceDisconnect(e){this._sessionService.getDeviceSessionByDeviceId(e).map(i=>{this._sessionService.removeDeviceSession(i.id)})}async execute({device:e,sessionRefresherOptions:s}){const i=this._transportService.getTransport(e.transport),r="sessionId"in e?e.sessionId:void 0;return g.EitherAsync.liftEither(i.toEither(new h.TransportNotSupportedError(new Error("Unknown transport")))).chain(async o=>o.connect({deviceId:e.id,onDisconnect:t=>this.handleDeviceDisconnect(t)})).ifLeft(o=>{this._logger.error("Error connecting to device",{data:{deviceId:e.id,error:o}})}).map(async o=>{const t=new l.DeviceSession({connectedDevice:o,id:r},this._loggerFactory,this._managerApi,this._secureChannel,s);return this._sessionService.addDeviceSession(t),await t.initialiseSession(),t.id}).caseOf({Left:o=>{throw o},Right:o=>o})}};v=m([(0,c.injectable)(),a(0,(0,c.inject)(u.transportDiTypes.TransportService)),a(1,(0,c.inject)(d.deviceSessionTypes.DeviceSessionService)),a(2,(0,c.inject)(D.loggerTypes.LoggerPublisherServiceFactory)),a(3,(0,c.inject)(f.managerApiTypes.ManagerApiService)),a(4,(0,c.inject)(y.secureChannelTypes.SecureChannelService))],v);0&&(module.exports={ConnectUseCase});
|
|
2
2
|
//# sourceMappingURL=ConnectUseCase.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../../src/internal/discovery/use-case/ConnectUseCase.ts"],
|
|
4
|
-
"sourcesContent": ["import { inject, injectable } from \"inversify\";\nimport { EitherAsync } from \"purify-ts\";\n\nimport { DeviceSessionId } from \"@api/device-session/types\";\nimport { LoggerPublisherService } from \"@api/logger-publisher/service/LoggerPublisherService\";\nimport { DiscoveredDevice } from \"@api/transport/model/DiscoveredDevice\";\nimport { TransportNotSupportedError } from \"@api/transport/model/Errors\";\nimport { DeviceId } from \"@api/types\";\nimport { deviceSessionTypes } from \"@internal/device-session/di/deviceSessionTypes\";\nimport {\n DeviceSession,\n DeviceSessionRefresherOptions,\n} from \"@internal/device-session/model/DeviceSession\";\nimport type { DeviceSessionService } from \"@internal/device-session/service/DeviceSessionService\";\nimport { loggerTypes } from \"@internal/logger-publisher/di/loggerTypes\";\nimport { managerApiTypes } from \"@internal/manager-api/di/managerApiTypes\";\nimport type { ManagerApiService } from \"@internal/manager-api/service/ManagerApiService\";\nimport { secureChannelTypes } from \"@internal/secure-channel/di/secureChannelTypes\";\nimport type { SecureChannelService } from \"@internal/secure-channel/service/SecureChannelService\";\nimport { transportDiTypes } from \"@internal/transport/di/transportDiTypes\";\nimport { type TransportService } from \"@internal/transport/service/TransportService\";\n\n/**\n * The arguments for the ConnectUseCase.\n */\nexport type ConnectUseCaseArgs = {\n /**\n *
|
|
5
|
-
"mappings": "okBAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,oBAAAE,IAAA,eAAAC,EAAAH,GAAA,IAAAI,EAAmC,qBACnCC,EAA4B,
|
|
6
|
-
"names": ["ConnectUseCase_exports", "__export", "ConnectUseCase", "__toCommonJS", "import_inversify", "import_purify_ts", "import_Errors", "import_deviceSessionTypes", "import_DeviceSession", "import_loggerTypes", "import_managerApiTypes", "import_secureChannelTypes", "import_transportDiTypes", "ConnectUseCase", "transportService", "sessionService", "loggerFactory", "managerApi", "secureChannel", "deviceId", "deviceSession", "device", "sessionRefresherOptions", "transport", "t", "dId", "error", "connectedDevice", "s", "__decorateClass", "__decorateParam"]
|
|
4
|
+
"sourcesContent": ["import { inject, injectable } from \"inversify\";\nimport { EitherAsync } from \"purify-ts\";\n\nimport { DeviceSessionId } from \"@api/device-session/types\";\nimport { LoggerPublisherService } from \"@api/logger-publisher/service/LoggerPublisherService\";\nimport { ConnectedDevice } from \"@api/transport/model/ConnectedDevice\";\nimport { DiscoveredDevice } from \"@api/transport/model/DiscoveredDevice\";\nimport { TransportNotSupportedError } from \"@api/transport/model/Errors\";\nimport { DeviceId } from \"@api/types\";\nimport { deviceSessionTypes } from \"@internal/device-session/di/deviceSessionTypes\";\nimport {\n DeviceSession,\n DeviceSessionRefresherOptions,\n} from \"@internal/device-session/model/DeviceSession\";\nimport type { DeviceSessionService } from \"@internal/device-session/service/DeviceSessionService\";\nimport { loggerTypes } from \"@internal/logger-publisher/di/loggerTypes\";\nimport { managerApiTypes } from \"@internal/manager-api/di/managerApiTypes\";\nimport type { ManagerApiService } from \"@internal/manager-api/service/ManagerApiService\";\nimport { secureChannelTypes } from \"@internal/secure-channel/di/secureChannelTypes\";\nimport type { SecureChannelService } from \"@internal/secure-channel/service/SecureChannelService\";\nimport { transportDiTypes } from \"@internal/transport/di/transportDiTypes\";\nimport { type TransportService } from \"@internal/transport/service/TransportService\";\n\n/**\n * The arguments for the ConnectUseCase.\n */\nexport type ConnectUseCaseArgs = {\n /**\n * Discovered device or connected device.\n */\n device: DiscoveredDevice | ConnectedDevice;\n\n /**\n * sessionRefresherOptions - optional\n * isRefresherDisabled - whether the refresher is disabled\n * pollingInterval - optional - the refresh interval in milliseconds\n */\n sessionRefresherOptions?: DeviceSessionRefresherOptions;\n};\n\n/**\n * Connects to a discovered device.\n */\n@injectable()\nexport class ConnectUseCase {\n private readonly _transportService: TransportService;\n private readonly _sessionService: DeviceSessionService;\n private readonly _loggerFactory: (tag: string) => LoggerPublisherService;\n private readonly _managerApi: ManagerApiService;\n private readonly _secureChannel: SecureChannelService;\n private readonly _logger: LoggerPublisherService;\n\n constructor(\n @inject(transportDiTypes.TransportService)\n transportService: TransportService,\n @inject(deviceSessionTypes.DeviceSessionService)\n sessionService: DeviceSessionService,\n @inject(loggerTypes.LoggerPublisherServiceFactory)\n loggerFactory: (tag: string) => LoggerPublisherService,\n @inject(managerApiTypes.ManagerApiService)\n managerApi: ManagerApiService,\n @inject(secureChannelTypes.SecureChannelService)\n secureChannel: SecureChannelService,\n ) {\n this._sessionService = sessionService;\n this._transportService = transportService;\n this._loggerFactory = loggerFactory;\n this._logger = loggerFactory(\"ConnectUseCase\");\n this._managerApi = managerApi;\n this._secureChannel = secureChannel;\n }\n\n private handleDeviceDisconnect(deviceId: DeviceId) {\n const deviceSessionOrError =\n this._sessionService.getDeviceSessionByDeviceId(deviceId);\n deviceSessionOrError.map((deviceSession) => {\n this._sessionService.removeDeviceSession(deviceSession.id);\n });\n }\n\n async execute({\n device,\n sessionRefresherOptions,\n }: ConnectUseCaseArgs): Promise<DeviceSessionId> {\n const transport = this._transportService.getTransport(device.transport);\n // In case of a connected device, we reconnect using the same session id.\n // If not provided, a new device session id will be generated.\n const deviceSessionId =\n \"sessionId\" in device ? device.sessionId : undefined;\n\n return EitherAsync.liftEither(\n transport.toEither(\n new TransportNotSupportedError(new Error(\"Unknown transport\")),\n ),\n )\n .chain(async (t) => {\n return t.connect({\n deviceId: device.id,\n onDisconnect: (dId) => this.handleDeviceDisconnect(dId),\n });\n })\n .ifLeft((error) => {\n this._logger.error(\"Error connecting to device\", {\n data: { deviceId: device.id, error },\n });\n })\n .map(async (connectedDevice) => {\n const deviceSession = new DeviceSession(\n { connectedDevice, id: deviceSessionId },\n this._loggerFactory,\n this._managerApi,\n this._secureChannel,\n sessionRefresherOptions,\n );\n this._sessionService.addDeviceSession(deviceSession);\n await deviceSession.initialiseSession();\n return deviceSession.id;\n })\n .caseOf({\n Left: (error) => {\n throw error;\n },\n Right: (s) => s,\n });\n }\n}\n"],
|
|
5
|
+
"mappings": "okBAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,oBAAAE,IAAA,eAAAC,EAAAH,GAAA,IAAAI,EAAmC,qBACnCC,EAA4B,qBAM5BC,EAA2C,uCAE3CC,EAAmC,0DACnCC,EAGO,wDAEPC,EAA4B,qDAC5BC,EAAgC,oDAEhCC,EAAmC,0DAEnCC,EAAiC,mDAwB1B,IAAMC,EAAN,KAAqB,CACT,kBACA,gBACA,eACA,YACA,eACA,QAEjB,YAEEC,EAEAC,EAEAC,EAEAC,EAEAC,EACA,CACA,KAAK,gBAAkBH,EACvB,KAAK,kBAAoBD,EACzB,KAAK,eAAiBE,EACtB,KAAK,QAAUA,EAAc,gBAAgB,EAC7C,KAAK,YAAcC,EACn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ConnectUseCase", "__toCommonJS", "import_inversify", "import_purify_ts", "import_Errors", "import_deviceSessionTypes", "import_DeviceSession", "import_loggerTypes", "import_managerApiTypes", "import_secureChannelTypes", "import_transportDiTypes", "ConnectUseCase", "transportService", "sessionService", "loggerFactory", "managerApi", "secureChannel", "deviceId", "deviceSession", "device", "sessionRefresherOptions", "transport", "deviceSessionId", "t", "dId", "error", "connectedDevice", "s", "__decorateClass", "__decorateParam"]
|
|
7
7
|
}
|