@ledgerhq/device-management-kit 0.0.0-develop-20250106155719 → 0.0.0-webhid-20250124103640
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 +4 -1
- 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/DeviceManagementKitBuilder.js +1 -1
- package/lib/cjs/src/api/DeviceManagementKitBuilder.js.map +2 -2
- package/lib/cjs/src/api/DmkConfig.js +1 -1
- package/lib/cjs/src/api/DmkConfig.js.map +1 -1
- package/lib/cjs/src/api/command/model/CommandResult.js.map +1 -1
- 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/command/utils/CommandUtils.js +1 -1
- package/lib/cjs/src/api/command/utils/CommandUtils.js.map +2 -2
- package/lib/cjs/src/api/device-action/DeviceAction.js.map +1 -1
- package/lib/cjs/src/api/device-action/__test-utils__/makeInternalApi.js +1 -1
- package/lib/cjs/src/api/device-action/__test-utils__/makeInternalApi.js.map +3 -3
- package/lib/cjs/src/api/device-action/os/GetDeviceStatus/GetDeviceStatusDeviceAction.test.js +1 -1
- package/lib/cjs/src/api/device-action/os/GetDeviceStatus/GetDeviceStatusDeviceAction.test.js.map +3 -3
- package/lib/cjs/src/api/device-action/os/GoToDashboard/GoToDashboardDeviceAction.test.js +1 -1
- package/lib/cjs/src/api/device-action/os/GoToDashboard/GoToDashboardDeviceAction.test.js.map +3 -3
- package/lib/cjs/src/api/device-action/os/ListAppsWithMetadata/ListAppsWithMetadataDeviceAction.js +1 -1
- package/lib/cjs/src/api/device-action/os/ListAppsWithMetadata/ListAppsWithMetadataDeviceAction.js.map +2 -2
- package/lib/cjs/src/api/device-action/os/ListAppsWithMetadata/ListAppsWithMetadataDeviceAction.test.js +1 -1
- package/lib/cjs/src/api/device-action/os/ListAppsWithMetadata/ListAppsWithMetadataDeviceAction.test.js.map +3 -3
- package/lib/cjs/src/api/device-action/os/OpenAppDeviceAction/OpenAppDeviceAction.js +1 -1
- package/lib/cjs/src/api/device-action/os/OpenAppDeviceAction/OpenAppDeviceAction.js.map +2 -2
- package/lib/cjs/src/api/device-action/os/OpenAppDeviceAction/OpenAppDeviceAction.test.js +1 -1
- package/lib/cjs/src/api/device-action/os/OpenAppDeviceAction/OpenAppDeviceAction.test.js.map +3 -3
- package/lib/cjs/src/api/device-action/os/OpenAppDeviceAction/types.js +1 -1
- package/lib/cjs/src/api/device-action/os/OpenAppDeviceAction/types.js.map +1 -1
- package/lib/cjs/src/api/device-action/os/SendCommandInAppDeviceAction/SendCommandInAppDeviceAction.js +1 -1
- package/lib/cjs/src/api/device-action/os/SendCommandInAppDeviceAction/SendCommandInAppDeviceAction.js.map +2 -2
- package/lib/cjs/src/api/device-action/os/SendCommandInAppDeviceAction/SendCommandInAppDeviceActionTypes.js +1 -1
- package/lib/cjs/src/api/device-action/os/SendCommandInAppDeviceAction/SendCommandInAppDeviceActionTypes.js.map +1 -1
- package/lib/cjs/src/api/device-session/DeviceSessionState.js +1 -1
- package/lib/cjs/src/api/device-session/DeviceSessionState.js.map +2 -2
- package/lib/cjs/src/api/device-session/use-case/ToggleDeviceSessionRefresher.test.js +1 -1
- package/lib/cjs/src/api/device-session/use-case/ToggleDeviceSessionRefresher.test.js.map +2 -2
- package/lib/cjs/src/api/types.js.map +1 -1
- package/lib/cjs/src/di.js +1 -1
- package/lib/cjs/src/di.js.map +2 -2
- package/lib/cjs/src/internal/device-session/model/DeviceSession.js +1 -1
- package/lib/cjs/src/internal/device-session/model/DeviceSession.js.map +3 -3
- package/lib/cjs/src/internal/device-session/service/DefaultDeviceSessionService.test.js +1 -1
- package/lib/cjs/src/internal/device-session/service/DefaultDeviceSessionService.test.js.map +2 -2
- package/lib/cjs/src/internal/device-session/use-case/CloseSessionsUseCase.test.js +1 -1
- package/lib/cjs/src/internal/device-session/use-case/CloseSessionsUseCase.test.js.map +2 -2
- package/lib/cjs/src/internal/device-session/use-case/GetDeviceSessionStateUseCase.test.js +1 -1
- package/lib/cjs/src/internal/device-session/use-case/GetDeviceSessionStateUseCase.test.js.map +2 -2
- package/lib/cjs/src/internal/discovery/di/discoveryModule.test.js +1 -1
- package/lib/cjs/src/internal/discovery/di/discoveryModule.test.js.map +2 -2
- 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 +2 -2
- package/lib/cjs/src/internal/discovery/use-case/DisconnectUseCase.test.js +1 -1
- package/lib/cjs/src/internal/discovery/use-case/DisconnectUseCase.test.js.map +2 -2
- package/lib/cjs/src/internal/discovery/use-case/GetConnectedDeviceUseCase.test.js +1 -1
- package/lib/cjs/src/internal/discovery/use-case/GetConnectedDeviceUseCase.test.js.map +2 -2
- package/lib/cjs/src/internal/discovery/use-case/ListConnectedDevicesUseCase.test.js +1 -1
- package/lib/cjs/src/internal/discovery/use-case/ListConnectedDevicesUseCase.test.js.map +2 -2
- package/lib/cjs/src/internal/discovery/use-case/ListenToConnectedDeviceUseCase.test.js +1 -1
- package/lib/cjs/src/internal/discovery/use-case/ListenToConnectedDeviceUseCase.test.js.map +2 -2
- package/lib/cjs/src/internal/manager-api/data/AxiosManagerApiDataSource.js +1 -1
- package/lib/cjs/src/internal/manager-api/data/AxiosManagerApiDataSource.js.map +3 -3
- package/lib/cjs/src/internal/manager-api/data/AxiosManagerApiDataSource.test.js +1 -1
- package/lib/cjs/src/internal/manager-api/data/AxiosManagerApiDataSource.test.js.map +3 -3
- package/lib/cjs/src/internal/manager-api/data/ManagerApiDataSource.js +1 -1
- package/lib/cjs/src/internal/manager-api/data/ManagerApiDataSource.js.map +1 -1
- package/lib/cjs/src/internal/manager-api/data/__mocks__/AxiosManagerApiDataSource.js +1 -1
- package/lib/cjs/src/internal/manager-api/data/__mocks__/AxiosManagerApiDataSource.js.map +2 -2
- package/lib/cjs/src/internal/manager-api/di/managerApiModule.test.js +1 -1
- package/lib/cjs/src/internal/manager-api/di/managerApiModule.test.js.map +2 -2
- package/lib/cjs/src/internal/manager-api/model/Const.js +1 -1
- package/lib/cjs/src/internal/manager-api/model/Const.js.map +3 -3
- package/lib/cjs/src/internal/manager-api/model/Errors.js +1 -1
- package/lib/cjs/src/internal/manager-api/model/Errors.js.map +3 -3
- package/lib/cjs/src/internal/manager-api/model/Params.js +2 -0
- package/lib/cjs/src/internal/manager-api/model/Params.js.map +7 -0
- package/lib/cjs/src/internal/manager-api/service/DefaultManagerApiService.test.js +1 -1
- package/lib/cjs/src/internal/manager-api/service/DefaultManagerApiService.test.js.map +3 -3
- package/lib/cjs/src/internal/send/use-case/SendApduUseCase.test.js +1 -1
- package/lib/cjs/src/internal/send/use-case/SendApduUseCase.test.js.map +2 -2
- package/lib/cjs/src/internal/transport/di/transportModule.test.js +1 -1
- package/lib/cjs/src/internal/transport/di/transportModule.test.js.map +2 -2
- package/lib/esm/package.json +4 -1
- 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/DeviceManagementKitBuilder.js +1 -1
- package/lib/esm/src/api/DeviceManagementKitBuilder.js.map +3 -3
- package/lib/esm/src/api/command/model/CommandResult.js.map +1 -1
- 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/command/utils/CommandUtils.js +1 -1
- package/lib/esm/src/api/command/utils/CommandUtils.js.map +2 -2
- package/lib/esm/src/api/device-action/__test-utils__/makeInternalApi.js +1 -1
- package/lib/esm/src/api/device-action/__test-utils__/makeInternalApi.js.map +3 -3
- package/lib/esm/src/api/device-action/os/GetDeviceStatus/GetDeviceStatusDeviceAction.test.js +1 -1
- package/lib/esm/src/api/device-action/os/GetDeviceStatus/GetDeviceStatusDeviceAction.test.js.map +3 -3
- package/lib/esm/src/api/device-action/os/GoToDashboard/GoToDashboardDeviceAction.test.js +1 -1
- package/lib/esm/src/api/device-action/os/GoToDashboard/GoToDashboardDeviceAction.test.js.map +3 -3
- package/lib/esm/src/api/device-action/os/ListAppsWithMetadata/ListAppsWithMetadataDeviceAction.js +1 -1
- package/lib/esm/src/api/device-action/os/ListAppsWithMetadata/ListAppsWithMetadataDeviceAction.js.map +2 -2
- package/lib/esm/src/api/device-action/os/ListAppsWithMetadata/ListAppsWithMetadataDeviceAction.test.js +1 -1
- package/lib/esm/src/api/device-action/os/ListAppsWithMetadata/ListAppsWithMetadataDeviceAction.test.js.map +3 -3
- package/lib/esm/src/api/device-action/os/OpenAppDeviceAction/OpenAppDeviceAction.js +1 -1
- package/lib/esm/src/api/device-action/os/OpenAppDeviceAction/OpenAppDeviceAction.js.map +2 -2
- package/lib/esm/src/api/device-action/os/OpenAppDeviceAction/OpenAppDeviceAction.test.js +1 -1
- package/lib/esm/src/api/device-action/os/OpenAppDeviceAction/OpenAppDeviceAction.test.js.map +3 -3
- package/lib/esm/src/api/device-action/os/SendCommandInAppDeviceAction/SendCommandInAppDeviceAction.js +1 -1
- package/lib/esm/src/api/device-action/os/SendCommandInAppDeviceAction/SendCommandInAppDeviceAction.js.map +2 -2
- package/lib/esm/src/api/device-session/DeviceSessionState.js.map +2 -2
- package/lib/esm/src/api/device-session/use-case/ToggleDeviceSessionRefresher.test.js +1 -1
- package/lib/esm/src/api/device-session/use-case/ToggleDeviceSessionRefresher.test.js.map +2 -2
- package/lib/esm/src/di.js +1 -1
- package/lib/esm/src/di.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 +3 -3
- package/lib/esm/src/internal/device-session/service/DefaultDeviceSessionService.test.js +1 -1
- package/lib/esm/src/internal/device-session/service/DefaultDeviceSessionService.test.js.map +2 -2
- package/lib/esm/src/internal/device-session/use-case/CloseSessionsUseCase.test.js +1 -1
- package/lib/esm/src/internal/device-session/use-case/CloseSessionsUseCase.test.js.map +2 -2
- package/lib/esm/src/internal/device-session/use-case/GetDeviceSessionStateUseCase.test.js +1 -1
- package/lib/esm/src/internal/device-session/use-case/GetDeviceSessionStateUseCase.test.js.map +2 -2
- package/lib/esm/src/internal/discovery/di/discoveryModule.test.js +1 -1
- package/lib/esm/src/internal/discovery/di/discoveryModule.test.js.map +2 -2
- 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 +2 -2
- package/lib/esm/src/internal/discovery/use-case/DisconnectUseCase.test.js +1 -1
- package/lib/esm/src/internal/discovery/use-case/DisconnectUseCase.test.js.map +2 -2
- package/lib/esm/src/internal/discovery/use-case/GetConnectedDeviceUseCase.test.js +1 -1
- package/lib/esm/src/internal/discovery/use-case/GetConnectedDeviceUseCase.test.js.map +2 -2
- package/lib/esm/src/internal/discovery/use-case/ListConnectedDevicesUseCase.test.js +1 -1
- package/lib/esm/src/internal/discovery/use-case/ListConnectedDevicesUseCase.test.js.map +2 -2
- package/lib/esm/src/internal/discovery/use-case/ListenToConnectedDeviceUseCase.test.js +1 -1
- package/lib/esm/src/internal/discovery/use-case/ListenToConnectedDeviceUseCase.test.js.map +2 -2
- package/lib/esm/src/internal/manager-api/data/AxiosManagerApiDataSource.js +1 -1
- package/lib/esm/src/internal/manager-api/data/AxiosManagerApiDataSource.js.map +3 -3
- package/lib/esm/src/internal/manager-api/data/AxiosManagerApiDataSource.test.js +1 -1
- package/lib/esm/src/internal/manager-api/data/AxiosManagerApiDataSource.test.js.map +3 -3
- package/lib/esm/src/internal/manager-api/data/__mocks__/AxiosManagerApiDataSource.js +1 -1
- package/lib/esm/src/internal/manager-api/data/__mocks__/AxiosManagerApiDataSource.js.map +2 -2
- package/lib/esm/src/internal/manager-api/di/managerApiModule.test.js +1 -1
- package/lib/esm/src/internal/manager-api/di/managerApiModule.test.js.map +2 -2
- package/lib/esm/src/internal/manager-api/model/Const.js +1 -1
- package/lib/esm/src/internal/manager-api/model/Const.js.map +3 -3
- package/lib/esm/src/internal/manager-api/model/Errors.js +1 -1
- package/lib/esm/src/internal/manager-api/model/Errors.js.map +3 -3
- package/lib/esm/src/internal/manager-api/model/Params.js +1 -0
- package/lib/esm/src/internal/manager-api/model/Params.js.map +7 -0
- package/lib/esm/src/internal/manager-api/service/DefaultManagerApiService.test.js +1 -1
- package/lib/esm/src/internal/manager-api/service/DefaultManagerApiService.test.js.map +3 -3
- package/lib/esm/src/internal/send/use-case/SendApduUseCase.test.js +1 -1
- package/lib/esm/src/internal/send/use-case/SendApduUseCase.test.js.map +2 -2
- package/lib/esm/src/internal/transport/di/transportModule.test.js +1 -1
- package/lib/esm/src/internal/transport/di/transportModule.test.js.map +2 -2
- package/lib/types/src/api/DeviceManagementKitBuilder.d.ts.map +1 -1
- package/lib/types/src/api/DmkConfig.d.ts +1 -0
- package/lib/types/src/api/DmkConfig.d.ts.map +1 -1
- package/lib/types/src/api/command/model/CommandResult.d.ts +1 -2
- package/lib/types/src/api/command/model/CommandResult.d.ts.map +1 -1
- package/lib/types/src/api/device-action/DeviceAction.d.ts +1 -1
- package/lib/types/src/api/device-action/DeviceAction.d.ts.map +1 -1
- package/lib/types/src/api/device-action/os/ListAppsWithMetadata/ListAppsWithMetadataDeviceAction.d.ts.map +1 -1
- package/lib/types/src/api/device-action/os/OpenAppDeviceAction/OpenAppDeviceAction.d.ts.map +1 -1
- package/lib/types/src/api/device-action/os/OpenAppDeviceAction/types.d.ts +1 -0
- package/lib/types/src/api/device-action/os/OpenAppDeviceAction/types.d.ts.map +1 -1
- package/lib/types/src/api/device-action/os/SendCommandInAppDeviceAction/SendCommandInAppDeviceAction.d.ts.map +1 -1
- package/lib/types/src/api/device-action/os/SendCommandInAppDeviceAction/SendCommandInAppDeviceActionTypes.d.ts +1 -0
- package/lib/types/src/api/device-action/os/SendCommandInAppDeviceAction/SendCommandInAppDeviceActionTypes.d.ts.map +1 -1
- package/lib/types/src/api/device-session/DeviceSessionState.d.ts +5 -0
- package/lib/types/src/api/device-session/DeviceSessionState.d.ts.map +1 -1
- package/lib/types/src/api/transport/model/Errors.d.ts +26 -26
- package/lib/types/src/api/transport/model/Errors.d.ts.map +1 -1
- package/lib/types/src/api/types.d.ts +1 -1
- package/lib/types/src/api/types.d.ts.map +1 -1
- package/lib/types/src/di.d.ts.map +1 -1
- package/lib/types/src/internal/device-session/model/DeviceSession.d.ts.map +1 -1
- package/lib/types/src/internal/manager-api/data/AxiosManagerApiDataSource.d.ts +15 -5
- package/lib/types/src/internal/manager-api/data/AxiosManagerApiDataSource.d.ts.map +1 -1
- package/lib/types/src/internal/manager-api/data/ManagerApiDataSource.d.ts +70 -2
- package/lib/types/src/internal/manager-api/data/ManagerApiDataSource.d.ts.map +1 -1
- package/lib/types/src/internal/manager-api/data/__mocks__/AxiosManagerApiDataSource.d.ts +6 -0
- package/lib/types/src/internal/manager-api/data/__mocks__/AxiosManagerApiDataSource.d.ts.map +1 -1
- package/lib/types/src/internal/manager-api/model/Const.d.ts +1 -0
- package/lib/types/src/internal/manager-api/model/Const.d.ts.map +1 -1
- package/lib/types/src/internal/manager-api/model/Errors.d.ts +6 -0
- package/lib/types/src/internal/manager-api/model/Errors.d.ts.map +1 -1
- package/lib/types/src/internal/manager-api/model/Params.d.ts +86 -0
- package/lib/types/src/internal/manager-api/model/Params.d.ts.map +1 -0
- package/lib/types/tsconfig.prod.tsbuildinfo +1 -1
- package/package.json +5 -2
package/lib/cjs/package.json
CHANGED
@@ -37,11 +37,13 @@
|
|
37
37
|
"axios": "^1.7.9",
|
38
38
|
"inversify": "^6.2.1",
|
39
39
|
"inversify-logger-middleware": "^3.1.0",
|
40
|
+
"isomorphic-ws": "^5.0.0",
|
40
41
|
"purify-ts": "^2.1.0",
|
41
42
|
"reflect-metadata": "^0.2.2",
|
42
43
|
"semver": "^7.6.3",
|
43
44
|
"uuid": "^11.0.3",
|
44
|
-
"
|
45
|
+
"ws": "^8.18.0",
|
46
|
+
"xstate": "^5.19.2"
|
45
47
|
},
|
46
48
|
"peerDependencies": {
|
47
49
|
"rxjs": "^7.8.1"
|
@@ -54,6 +56,7 @@
|
|
54
56
|
"@ledgerhq/tsconfig-dsdk": "workspace:*",
|
55
57
|
"@types/semver": "^7.5.8",
|
56
58
|
"@types/uuid": "^10.0.0",
|
59
|
+
"@types/ws": "^8.5.13",
|
57
60
|
"rxjs": "^7.8.1",
|
58
61
|
"ts-node": "^10.9.2"
|
59
62
|
}
|
@@ -1,2 +1,2 @@
|
|
1
|
-
"use strict";var D=Object.create;var a=Object.defineProperty;var C=Object.getOwnPropertyDescriptor;var b=Object.getOwnPropertyNames;var
|
1
|
+
"use strict";var D=Object.create;var a=Object.defineProperty;var C=Object.getOwnPropertyDescriptor;var b=Object.getOwnPropertyNames;var S=Object.getPrototypeOf,x=Object.prototype.hasOwnProperty;var U=(t,o,n,r)=>{if(o&&typeof o=="object"||typeof o=="function")for(let i of b(o))!x.call(t,i)&&i!==n&&a(t,i,{get:()=>o[i],enumerable:!(r=C(o,i))||r.enumerable});return t};var k=(t,o,n)=>(n=t!=null?D(S(t)):{},U(o||!t||!t.__esModule?a(n,"default",{value:t,enumerable:!0}):n,t));var m=require("../internal/config/data/LocalConfigDataSource.stub"),p=require("../internal/config/di/configTypes"),f=require("../internal/device-session/di/deviceSessionTypes"),s=require("../internal/discovery/di/discoveryTypes"),l=require("../internal/send/di/sendTypes"),u=k(require("../../package.json")),h=require("../../src/di.stub"),g=require("./command/di/commandTypes"),v=require("./logger-subscriber/service/ConsoleLogger"),c=require("./DeviceManagementKit");jest.mock("./logger-subscriber/service/ConsoleLogger");let e,d;describe("DeviceManagementKit",()=>{describe("clean",()=>{beforeEach(()=>{d=new v.ConsoleLogger,e=new c.DeviceManagementKit({stub:!1,loggers:[d],config:{managerApiUrl:"http://fake.url",mockUrl:"http://fake-mock.url",webSocketUrl:"http://fake-websocket.url"}})}),it("should create an instance",()=>{expect(e).toBeDefined(),expect(e).toBeInstanceOf(c.DeviceManagementKit)}),it("should return a clean `version`",async()=>{expect(await e.getVersion()).toBe(u.default.version)}),it("should have startDiscovery method",()=>{expect(e.startDiscovering).toBeDefined()}),it("should have stopDiscovery method",()=>{expect(e.stopDiscovering).toBeDefined()}),it("should have connect method",()=>{expect(e.connect).toBeDefined()}),it("should have sendApdu method",()=>{expect(e.sendApdu).toBeDefined()}),it("should have getConnectedDevice method",()=>{expect(e.getConnectedDevice).toBeDefined()}),it("should have sendCommand method",()=>{expect(e.sendCommand).toBeDefined()}),it("should have listConnectedDevices method",()=>{expect(e.listConnectedDevices).toBeDefined()}),it("should have listenToConnectedDevice method",()=>{expect(e.listenToConnectedDevice).toBeDefined()}),it("should have toggleDeviceSessionRefresher method",()=>{expect(e.toggleDeviceSessionRefresher).toBeDefined()})}),describe("stubbed",()=>{beforeEach(()=>{e=new c.DeviceManagementKit({stub:!0,loggers:[],config:{managerApiUrl:"http://fake.url",mockUrl:"http://fake-mock.url",webSocketUrl:"http://fake-websocket.url"}})}),it("should create a stubbed dmk",()=>{expect(e).toBeDefined(),expect(e).toBeInstanceOf(c.DeviceManagementKit)}),it("should return a stubbed config",()=>{expect(e.container.get(p.configTypes.LocalConfigDataSource)).toBeInstanceOf(m.StubLocalConfigDataSource)}),it("should return a stubbed version",async()=>{expect(await e.getVersion()).toBe("0.0.0-stub.1")}),it.each([[s.discoveryTypes.StartDiscoveringUseCase],[s.discoveryTypes.StopDiscoveringUseCase],[s.discoveryTypes.ConnectUseCase],[l.sendTypes.SendApduUseCase],[g.commandTypes.SendCommandUseCase],[s.discoveryTypes.GetConnectedDeviceUseCase],[s.discoveryTypes.DisconnectUseCase],[f.deviceSessionTypes.GetDeviceSessionStateUseCase],[s.discoveryTypes.ListConnectedDevicesUseCase],[s.discoveryTypes.ListenToConnectedDeviceUseCase]])("should have %p use case",t=>{const o=e.container.get(t);expect(o).toBeInstanceOf(h.StubUseCase),expect(o.execute()).toBe("stub")})})});
|
2
2
|
//# sourceMappingURL=DeviceManagementKit.test.js.map
|
@@ -1,7 +1,7 @@
|
|
1
1
|
{
|
2
2
|
"version": 3,
|
3
3
|
"sources": ["../../../../src/api/DeviceManagementKit.test.ts"],
|
4
|
-
"sourcesContent": ["import { type interfaces } from \"inversify\";\n\nimport { type LocalConfigDataSource } from \"@internal/config/data/ConfigDataSource\";\nimport { StubLocalConfigDataSource } from \"@internal/config/data/LocalConfigDataSource.stub\";\nimport { configTypes } from \"@internal/config/di/configTypes\";\nimport { deviceSessionTypes } from \"@internal/device-session/di/deviceSessionTypes\";\nimport { discoveryTypes } from \"@internal/discovery/di/discoveryTypes\";\nimport { sendTypes } from \"@internal/send/di/sendTypes\";\nimport pkg from \"@root/package.json\";\nimport { StubUseCase } from \"@root/src/di.stub\";\n\nimport { commandTypes } from \"./command/di/commandTypes\";\nimport { ConsoleLogger } from \"./logger-subscriber/service/ConsoleLogger\";\nimport { DeviceManagementKit } from \"./DeviceManagementKit\";\n\njest.mock(\"./logger-subscriber/service/ConsoleLogger\");\n\nlet dmk: DeviceManagementKit;\nlet logger: ConsoleLogger;\ndescribe(\"DeviceManagementKit\", () => {\n describe(\"clean\", () => {\n beforeEach(() => {\n logger = new ConsoleLogger();\n dmk = new DeviceManagementKit({\n stub: false,\n loggers: [logger],\n config: {\n managerApiUrl: \"http://fake.url\",\n mockUrl: \"http://fake-mock.url\",\n },\n });\n });\n\n it(\"should create an instance\", () => {\n expect(dmk).toBeDefined();\n expect(dmk).toBeInstanceOf(DeviceManagementKit);\n });\n\n it(\"should return a clean `version`\", async () => {\n expect(await dmk.getVersion()).toBe(pkg.version);\n });\n\n it(\"should have startDiscovery method\", () => {\n expect(dmk.startDiscovering).toBeDefined();\n });\n\n it(\"should have stopDiscovery method\", () => {\n expect(dmk.stopDiscovering).toBeDefined();\n });\n\n it(\"should have connect method\", () => {\n expect(dmk.connect).toBeDefined();\n });\n\n it(\"should have sendApdu method\", () => {\n expect(dmk.sendApdu).toBeDefined();\n });\n\n it(\"should have getConnectedDevice method\", () => {\n expect(dmk.getConnectedDevice).toBeDefined();\n });\n\n it(\"should have sendCommand method\", () => {\n expect(dmk.sendCommand).toBeDefined();\n });\n\n it(\"should have listConnectedDevices method\", () => {\n expect(dmk.listConnectedDevices).toBeDefined();\n });\n\n it(\"should have listenToConnectedDevice method\", () => {\n expect(dmk.listenToConnectedDevice).toBeDefined();\n });\n\n it(\"should have toggleDeviceSessionRefresher method\", () => {\n expect(dmk.toggleDeviceSessionRefresher).toBeDefined();\n });\n });\n\n describe(\"stubbed\", () => {\n beforeEach(() => {\n dmk = new DeviceManagementKit({\n stub: true,\n loggers: [],\n config: {\n managerApiUrl: \"http://fake.url\",\n mockUrl: \"http://fake-mock.url\",\n },\n });\n });\n\n it(\"should create a stubbed dmk\", () => {\n expect(dmk).toBeDefined();\n expect(dmk).toBeInstanceOf(DeviceManagementKit);\n });\n\n it(\"should return a stubbed config\", () => {\n expect(\n dmk.container.get<LocalConfigDataSource>(\n configTypes.LocalConfigDataSource,\n ),\n ).toBeInstanceOf(StubLocalConfigDataSource);\n });\n\n it(\"should return a stubbed version\", async () => {\n expect(await dmk.getVersion()).toBe(\"0.0.0-stub.1\");\n });\n\n it.each([\n [discoveryTypes.StartDiscoveringUseCase],\n [discoveryTypes.StopDiscoveringUseCase],\n [discoveryTypes.ConnectUseCase],\n [sendTypes.SendApduUseCase],\n [commandTypes.SendCommandUseCase],\n [discoveryTypes.GetConnectedDeviceUseCase],\n [discoveryTypes.DisconnectUseCase],\n [deviceSessionTypes.GetDeviceSessionStateUseCase],\n [discoveryTypes.ListConnectedDevicesUseCase],\n [discoveryTypes.ListenToConnectedDeviceUseCase],\n ])(\n \"should have %p use case\",\n (diSymbol: interfaces.ServiceIdentifier<StubUseCase>) => {\n const uc = dmk.container.get<StubUseCase>(diSymbol);\n expect(uc).toBeInstanceOf(StubUseCase);\n expect(uc.execute()).toBe(\"stub\");\n },\n );\n });\n});\n"],
|
5
|
-
"mappings": "wdAGA,IAAAA,EAA0C,4DAC1CC,EAA4B,2CAC5BC,EAAmC,0DACnCC,EAA+B,iDAC/BC,EAA0B,uCAC1BC,EAAgB,iCAChBC,EAA4B,6BAE5BC,EAA6B,qCAC7BC,EAA8B,qDAC9BC,EAAoC,iCAEpC,KAAK,KAAK,2CAA2C,EAErD,IAAIC,EACAC,EACJ,SAAS,sBAAuB,IAAM,CACpC,SAAS,QAAS,IAAM,CACtB,WAAW,IAAM,CACfA,EAAS,IAAI,gBACbD,EAAM,IAAI,sBAAoB,CAC5B,KAAM,GACN,QAAS,CAACC,CAAM,EAChB,OAAQ,CACN,cAAe,kBACf,QAAS,
|
4
|
+
"sourcesContent": ["import { type interfaces } from \"inversify\";\n\nimport { type LocalConfigDataSource } from \"@internal/config/data/ConfigDataSource\";\nimport { StubLocalConfigDataSource } from \"@internal/config/data/LocalConfigDataSource.stub\";\nimport { configTypes } from \"@internal/config/di/configTypes\";\nimport { deviceSessionTypes } from \"@internal/device-session/di/deviceSessionTypes\";\nimport { discoveryTypes } from \"@internal/discovery/di/discoveryTypes\";\nimport { sendTypes } from \"@internal/send/di/sendTypes\";\nimport pkg from \"@root/package.json\";\nimport { StubUseCase } from \"@root/src/di.stub\";\n\nimport { commandTypes } from \"./command/di/commandTypes\";\nimport { ConsoleLogger } from \"./logger-subscriber/service/ConsoleLogger\";\nimport { DeviceManagementKit } from \"./DeviceManagementKit\";\n\njest.mock(\"./logger-subscriber/service/ConsoleLogger\");\n\nlet dmk: DeviceManagementKit;\nlet logger: ConsoleLogger;\ndescribe(\"DeviceManagementKit\", () => {\n describe(\"clean\", () => {\n beforeEach(() => {\n logger = new ConsoleLogger();\n dmk = new DeviceManagementKit({\n stub: false,\n loggers: [logger],\n config: {\n managerApiUrl: \"http://fake.url\",\n mockUrl: \"http://fake-mock.url\",\n webSocketUrl: \"http://fake-websocket.url\",\n },\n });\n });\n\n it(\"should create an instance\", () => {\n expect(dmk).toBeDefined();\n expect(dmk).toBeInstanceOf(DeviceManagementKit);\n });\n\n it(\"should return a clean `version`\", async () => {\n expect(await dmk.getVersion()).toBe(pkg.version);\n });\n\n it(\"should have startDiscovery method\", () => {\n expect(dmk.startDiscovering).toBeDefined();\n });\n\n it(\"should have stopDiscovery method\", () => {\n expect(dmk.stopDiscovering).toBeDefined();\n });\n\n it(\"should have connect method\", () => {\n expect(dmk.connect).toBeDefined();\n });\n\n it(\"should have sendApdu method\", () => {\n expect(dmk.sendApdu).toBeDefined();\n });\n\n it(\"should have getConnectedDevice method\", () => {\n expect(dmk.getConnectedDevice).toBeDefined();\n });\n\n it(\"should have sendCommand method\", () => {\n expect(dmk.sendCommand).toBeDefined();\n });\n\n it(\"should have listConnectedDevices method\", () => {\n expect(dmk.listConnectedDevices).toBeDefined();\n });\n\n it(\"should have listenToConnectedDevice method\", () => {\n expect(dmk.listenToConnectedDevice).toBeDefined();\n });\n\n it(\"should have toggleDeviceSessionRefresher method\", () => {\n expect(dmk.toggleDeviceSessionRefresher).toBeDefined();\n });\n });\n\n describe(\"stubbed\", () => {\n beforeEach(() => {\n dmk = new DeviceManagementKit({\n stub: true,\n loggers: [],\n config: {\n managerApiUrl: \"http://fake.url\",\n mockUrl: \"http://fake-mock.url\",\n webSocketUrl: \"http://fake-websocket.url\",\n },\n });\n });\n\n it(\"should create a stubbed dmk\", () => {\n expect(dmk).toBeDefined();\n expect(dmk).toBeInstanceOf(DeviceManagementKit);\n });\n\n it(\"should return a stubbed config\", () => {\n expect(\n dmk.container.get<LocalConfigDataSource>(\n configTypes.LocalConfigDataSource,\n ),\n ).toBeInstanceOf(StubLocalConfigDataSource);\n });\n\n it(\"should return a stubbed version\", async () => {\n expect(await dmk.getVersion()).toBe(\"0.0.0-stub.1\");\n });\n\n it.each([\n [discoveryTypes.StartDiscoveringUseCase],\n [discoveryTypes.StopDiscoveringUseCase],\n [discoveryTypes.ConnectUseCase],\n [sendTypes.SendApduUseCase],\n [commandTypes.SendCommandUseCase],\n [discoveryTypes.GetConnectedDeviceUseCase],\n [discoveryTypes.DisconnectUseCase],\n [deviceSessionTypes.GetDeviceSessionStateUseCase],\n [discoveryTypes.ListConnectedDevicesUseCase],\n [discoveryTypes.ListenToConnectedDeviceUseCase],\n ])(\n \"should have %p use case\",\n (diSymbol: interfaces.ServiceIdentifier<StubUseCase>) => {\n const uc = dmk.container.get<StubUseCase>(diSymbol);\n expect(uc).toBeInstanceOf(StubUseCase);\n expect(uc.execute()).toBe(\"stub\");\n },\n );\n });\n});\n"],
|
5
|
+
"mappings": "wdAGA,IAAAA,EAA0C,4DAC1CC,EAA4B,2CAC5BC,EAAmC,0DACnCC,EAA+B,iDAC/BC,EAA0B,uCAC1BC,EAAgB,iCAChBC,EAA4B,6BAE5BC,EAA6B,qCAC7BC,EAA8B,qDAC9BC,EAAoC,iCAEpC,KAAK,KAAK,2CAA2C,EAErD,IAAIC,EACAC,EACJ,SAAS,sBAAuB,IAAM,CACpC,SAAS,QAAS,IAAM,CACtB,WAAW,IAAM,CACfA,EAAS,IAAI,gBACbD,EAAM,IAAI,sBAAoB,CAC5B,KAAM,GACN,QAAS,CAACC,CAAM,EAChB,OAAQ,CACN,cAAe,kBACf,QAAS,uBACT,aAAc,2BAChB,CACF,CAAC,CACH,CAAC,EAED,GAAG,4BAA6B,IAAM,CACpC,OAAOD,CAAG,EAAE,YAAY,EACxB,OAAOA,CAAG,EAAE,eAAe,qBAAmB,CAChD,CAAC,EAED,GAAG,kCAAmC,SAAY,CAChD,OAAO,MAAMA,EAAI,WAAW,CAAC,EAAE,KAAK,EAAAE,QAAI,OAAO,CACjD,CAAC,EAED,GAAG,oCAAqC,IAAM,CAC5C,OAAOF,EAAI,gBAAgB,EAAE,YAAY,CAC3C,CAAC,EAED,GAAG,mCAAoC,IAAM,CAC3C,OAAOA,EAAI,eAAe,EAAE,YAAY,CAC1C,CAAC,EAED,GAAG,6BAA8B,IAAM,CACrC,OAAOA,EAAI,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Ae,2BAA2B,EAC3C,CAAC,iBAAe,8BAA8B,CAChD,CAAC,EACC,0BACCG,GAAwD,CACvD,MAAMC,EAAKJ,EAAI,UAAU,IAAiBG,CAAQ,EAClD,OAAOC,CAAE,EAAE,eAAe,aAAW,EACrC,OAAOA,EAAG,QAAQ,CAAC,EAAE,KAAK,MAAM,CAClC,CACF,CACF,CAAC,CACH,CAAC",
|
6
6
|
"names": ["import_LocalConfigDataSource", "import_configTypes", "import_deviceSessionTypes", "import_discoveryTypes", "import_sendTypes", "import_package", "import_di", "import_commandTypes", "import_ConsoleLogger", "import_DeviceManagementKit", "dmk", "logger", "pkg", "diSymbol", "uc"]
|
7
7
|
}
|
@@ -1,2 +1,2 @@
|
|
1
|
-
"use strict";var s=Object.defineProperty;var g=Object.getOwnPropertyDescriptor;var
|
1
|
+
"use strict";var s=Object.defineProperty;var g=Object.getOwnPropertyDescriptor;var c=Object.getOwnPropertyNames;var p=Object.prototype.hasOwnProperty;var m=(e,r)=>{for(var o in r)s(e,o,{get:r[o],enumerable:!0})},u=(e,r,o,a)=>{if(r&&typeof r=="object"||typeof r=="function")for(let i of c(r))!p.call(e,i)&&i!==o&&s(e,i,{get:()=>r[i],enumerable:!(a=g(r,i))||a.enumerable});return e};var l=e=>u(s({},"__esModule",{value:!0}),e);var h={};m(h,{DeviceManagementKitBuilder:()=>f});module.exports=l(h);var t=require("../internal/manager-api/model/Const"),n=require("./DeviceManagementKit");class f{stub=!1;loggers=[];transports=[];config={managerApiUrl:t.DEFAULT_MANAGER_API_BASE_URL,mockUrl:t.DEFAULT_MOCK_SERVER_BASE_URL,webSocketUrl:t.DEFAULT_WEB_SOCKET_BASE_URL};build(){return new n.DeviceManagementKit({stub:this.stub,transports:this.transports,loggers:this.loggers,config:this.config})}setStub(r){return this.stub=r,this}addTransport(r){return this.transports.push(r),this}addLogger(r){return this.loggers.push(r),this}addConfig(r){return this.config={...this.config,...r},this}}0&&(module.exports={DeviceManagementKitBuilder});
|
2
2
|
//# sourceMappingURL=DeviceManagementKitBuilder.js.map
|
@@ -1,7 +1,7 @@
|
|
1
1
|
{
|
2
2
|
"version": 3,
|
3
3
|
"sources": ["../../../../src/api/DeviceManagementKitBuilder.ts"],
|
4
|
-
"sourcesContent": ["import {\n DEFAULT_MANAGER_API_BASE_URL,\n DEFAULT_MOCK_SERVER_BASE_URL,\n} from \"@internal/manager-api/model/Const\";\n\nimport { type LoggerSubscriberService } from \"./logger-subscriber/service/LoggerSubscriberService\";\nimport { type TransportFactory } from \"./transport/model/Transport\";\nimport { DeviceManagementKit } from \"./DeviceManagementKit\";\nimport { type DmkConfig } from \"./DmkConfig\";\n\n/**\n * Builder for the `DeviceManagementKit` class.\n *\n * @example\n * ```\n * const dmk = new LedgerDeviceManagementKitBuilder()\n * .setStub(false)\n * .addTransport((args) => transportFactory(args))\n * .addTransport(transportFactory)\n * .addLogger(myLogger)\n * .build();\n * ```\n */\nexport class DeviceManagementKitBuilder {\n private stub = false;\n private readonly loggers: LoggerSubscriberService[] = [];\n private readonly transports: TransportFactory[] = [];\n private config: DmkConfig = {\n managerApiUrl: DEFAULT_MANAGER_API_BASE_URL,\n mockUrl: DEFAULT_MOCK_SERVER_BASE_URL,\n };\n\n build(): DeviceManagementKit {\n return new DeviceManagementKit({\n stub: this.stub,\n transports: this.transports,\n loggers: this.loggers,\n config: this.config,\n });\n }\n\n setStub(stubbed: boolean): DeviceManagementKitBuilder {\n this.stub = stubbed;\n return this;\n }\n\n addTransport(transport: TransportFactory): DeviceManagementKitBuilder {\n this.transports.push(transport);\n return this;\n }\n\n /**\n * Add a logger to the SDK that will receive its logs\n */\n addLogger(logger: LoggerSubscriberService): DeviceManagementKitBuilder {\n this.loggers.push(logger);\n return this;\n }\n\n addConfig(config: Partial<DmkConfig>): DeviceManagementKitBuilder {\n this.config = {\n ...this.config,\n ...config,\n };\n return this;\n }\n}\n"],
|
5
|
-
"mappings": "yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,gCAAAE,IAAA,eAAAC,EAAAH,GAAA,IAAAI,
|
4
|
+
"sourcesContent": ["import {\n DEFAULT_MANAGER_API_BASE_URL,\n DEFAULT_MOCK_SERVER_BASE_URL,\n DEFAULT_WEB_SOCKET_BASE_URL,\n} from \"@internal/manager-api/model/Const\";\n\nimport { type LoggerSubscriberService } from \"./logger-subscriber/service/LoggerSubscriberService\";\nimport { type TransportFactory } from \"./transport/model/Transport\";\nimport { DeviceManagementKit } from \"./DeviceManagementKit\";\nimport { type DmkConfig } from \"./DmkConfig\";\n\n/**\n * Builder for the `DeviceManagementKit` class.\n *\n * @example\n * ```\n * const dmk = new LedgerDeviceManagementKitBuilder()\n * .setStub(false)\n * .addTransport((args) => transportFactory(args))\n * .addTransport(transportFactory)\n * .addLogger(myLogger)\n * .build();\n * ```\n */\nexport class DeviceManagementKitBuilder {\n private stub = false;\n private readonly loggers: LoggerSubscriberService[] = [];\n private readonly transports: TransportFactory[] = [];\n private config: DmkConfig = {\n managerApiUrl: DEFAULT_MANAGER_API_BASE_URL,\n mockUrl: DEFAULT_MOCK_SERVER_BASE_URL,\n webSocketUrl: DEFAULT_WEB_SOCKET_BASE_URL,\n };\n\n build(): DeviceManagementKit {\n return new DeviceManagementKit({\n stub: this.stub,\n transports: this.transports,\n loggers: this.loggers,\n config: this.config,\n });\n }\n\n setStub(stubbed: boolean): DeviceManagementKitBuilder {\n this.stub = stubbed;\n return this;\n }\n\n addTransport(transport: TransportFactory): DeviceManagementKitBuilder {\n this.transports.push(transport);\n return this;\n }\n\n /**\n * Add a logger to the SDK that will receive its logs\n */\n addLogger(logger: LoggerSubscriberService): DeviceManagementKitBuilder {\n this.loggers.push(logger);\n return this;\n }\n\n addConfig(config: Partial<DmkConfig>): DeviceManagementKitBuilder {\n this.config = {\n ...this.config,\n ...config,\n };\n return this;\n }\n}\n"],
|
5
|
+
"mappings": "yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,gCAAAE,IAAA,eAAAC,EAAAH,GAAA,IAAAI,EAIO,6CAIPC,EAAoC,iCAgB7B,MAAMH,CAA2B,CAC9B,KAAO,GACE,QAAqC,CAAC,EACtC,WAAiC,CAAC,EAC3C,OAAoB,CAC1B,cAAe,+BACf,QAAS,+BACT,aAAc,6BAChB,EAEA,OAA6B,CAC3B,OAAO,IAAI,sBAAoB,CAC7B,KAAM,KAAK,KACX,WAAY,KAAK,WACjB,QAAS,KAAK,QACd,OAAQ,KAAK,MACf,CAAC,CACH,CAEA,QAAQI,EAA8C,CACpD,YAAK,KAAOA,EACL,IACT,CAEA,aAAaC,EAAyD,CACpE,YAAK,WAAW,KAAKA,CAAS,EACvB,IACT,CAKA,UAAUC,EAA6D,CACrE,YAAK,QAAQ,KAAKA,CAAM,EACjB,IACT,CAEA,UAAUC,EAAwD,CAChE,YAAK,OAAS,CACZ,GAAG,KAAK,OACR,GAAGA,CACL,EACO,IACT,CACF",
|
6
6
|
"names": ["DeviceManagementKitBuilder_exports", "__export", "DeviceManagementKitBuilder", "__toCommonJS", "import_Const", "import_DeviceManagementKit", "stubbed", "transport", "logger", "config"]
|
7
7
|
}
|
@@ -1,2 +1,2 @@
|
|
1
|
-
"use strict";var
|
1
|
+
"use strict";var i=Object.defineProperty;var o=Object.getOwnPropertyDescriptor;var k=Object.getOwnPropertyNames;var l=Object.prototype.hasOwnProperty;var m=(t,r,n,g)=>{if(r&&typeof r=="object"||typeof r=="function")for(let e of k(r))!l.call(t,e)&&e!==n&&i(t,e,{get:()=>r[e],enumerable:!(g=o(r,e))||g.enumerable});return t};var p=t=>m(i({},"__esModule",{value:!0}),t);var s={};module.exports=p(s);
|
2
2
|
//# sourceMappingURL=DmkConfig.js.map
|
@@ -1,7 +1,7 @@
|
|
1
1
|
{
|
2
2
|
"version": 3,
|
3
3
|
"sources": ["../../../../src/api/DmkConfig.ts"],
|
4
|
-
"sourcesContent": ["export type DmkConfig = {\n mockUrl: string;\n managerApiUrl: string;\n};\n"],
|
4
|
+
"sourcesContent": ["export type DmkConfig = {\n mockUrl: string;\n managerApiUrl: string;\n webSocketUrl: string;\n};\n"],
|
5
5
|
"mappings": "+WAAA,IAAAA,EAAA,kBAAAC,EAAAD",
|
6
6
|
"names": ["DmkConfig_exports", "__toCommonJS"]
|
7
7
|
}
|
@@ -1,7 +1,7 @@
|
|
1
1
|
{
|
2
2
|
"version": 3,
|
3
3
|
"sources": ["../../../../../../src/api/command/model/CommandResult.ts"],
|
4
|
-
"sourcesContent": ["import {\n type InvalidBatteryDataError,\n type InvalidBatteryStatusTypeError,\n type InvalidResponseFormatError,\n type InvalidStatusWordError,\n} from \"@api/command/Errors\";\nimport { type GlobalCommandErrorStatusCode } from \"@api/command/utils/GlobalCommandError\";\nimport {\n type DeviceExchangeError,\n type UnknownDeviceExchangeError,\n} from \"@api/Error\";\n\nexport enum CommandResultStatus {\n Error = \"ERROR\",\n Success = \"SUCCESS\",\n}\
|
4
|
+
"sourcesContent": ["import {\n type InvalidBatteryDataError,\n type InvalidBatteryStatusTypeError,\n type InvalidResponseFormatError,\n type InvalidStatusWordError,\n} from \"@api/command/Errors\";\nimport { type GlobalCommandErrorStatusCode } from \"@api/command/utils/GlobalCommandError\";\nimport {\n type DeviceExchangeError,\n type UnknownDeviceExchangeError,\n} from \"@api/Error\";\n\nexport enum CommandResultStatus {\n Error = \"ERROR\",\n Success = \"SUCCESS\",\n}\nexport type CommandSuccessResult<Data> = {\n status: CommandResultStatus.Success;\n data: Data;\n};\nexport type CommandErrorResult<SpecificErrorCodes = void> = {\n error:\n | DeviceExchangeError<SpecificErrorCodes | GlobalCommandErrorStatusCode>\n | InvalidBatteryDataError\n | InvalidBatteryStatusTypeError\n | InvalidResponseFormatError\n | InvalidStatusWordError\n | UnknownDeviceExchangeError;\n status: CommandResultStatus.Error;\n};\nexport type CommandResult<Data, SpecificErrorCodes = void> =\n | CommandSuccessResult<Data>\n | CommandErrorResult<SpecificErrorCodes>;\n\nexport function CommandResultFactory<Data, SpecificErrorCodes = void>({\n data,\n error,\n}:\n | { data: Data; error?: undefined }\n | {\n data?: undefined;\n error:\n | DeviceExchangeError<SpecificErrorCodes>\n | InvalidBatteryDataError\n | InvalidBatteryStatusTypeError\n | InvalidResponseFormatError\n | InvalidStatusWordError\n | UnknownDeviceExchangeError;\n }): CommandResult<Data, SpecificErrorCodes> {\n if (error) {\n return {\n status: CommandResultStatus.Error,\n error,\n };\n }\n return {\n status: CommandResultStatus.Success,\n data,\n };\n}\n\nexport function isSuccessCommandResult<Data, StatusCode>(\n result: CommandResult<Data, StatusCode>,\n): result is CommandSuccessResult<Data> {\n return result.status === CommandResultStatus.Success;\n}\n"],
|
5
5
|
"mappings": "yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,0BAAAE,EAAA,wBAAAC,EAAA,2BAAAC,IAAA,eAAAC,EAAAL,GAYO,IAAKG,OACVA,EAAA,MAAQ,QACRA,EAAA,QAAU,UAFAA,OAAA,IAsBL,SAASD,EAAsD,CACpE,KAAAI,EACA,MAAAC,CACF,EAWgD,CAC9C,OAAIA,EACK,CACL,OAAQ,QACR,MAAAA,CACF,EAEK,CACL,OAAQ,UACR,KAAAD,CACF,CACF,CAEO,SAASF,EACdI,EACsC,CACtC,OAAOA,EAAO,SAAW,SAC3B",
|
6
6
|
"names": ["CommandResult_exports", "__export", "CommandResultFactory", "CommandResultStatus", "isSuccessCommandResult", "__toCommonJS", "data", "error", "result"]
|
7
7
|
}
|
@@ -1,2 +1,2 @@
|
|
1
|
-
"use strict";var d=require("purify-ts"),r=require("../../command/model/CommandResult"),u=require("../../../internal/device-session/model/DeviceSession.stub"),p=require("../../../internal/device-session/service/DefaultDeviceSessionService"),S=require("../../../internal/logger-publisher/service/DefaultLoggerPublisherService"),f=require("../../../internal/manager-api/data/AxiosManagerApiDataSource"),
|
1
|
+
"use strict";var d=require("purify-ts"),r=require("../../command/model/CommandResult"),u=require("../../../internal/device-session/model/DeviceSession.stub"),p=require("../../../internal/device-session/service/DefaultDeviceSessionService"),S=require("../../../internal/logger-publisher/service/DefaultLoggerPublisherService"),f=require("../../../internal/manager-api/data/AxiosManagerApiDataSource"),g=require("../../../internal/manager-api/service/DefaultManagerApiService"),a=require("./SendCommandUseCase");let s,o,n,c;const m="fakeSessionId";let i;describe("SendCommandUseCase",()=>{beforeEach(()=>{s=new S.DefaultLoggerPublisherService([],"send-command-use-case"),o=new p.DefaultDeviceSessionService(()=>s),c=new f.AxiosManagerApiDataSource({}),n=new g.DefaultManagerApiService(c),i={getApdu:jest.fn(),parseResponse:jest.fn()}}),afterEach(()=>{jest.restoreAllMocks()}),it("should send a command to a connected device",async()=>{const e=(0,u.deviceSessionStubBuilder)({},()=>s,n);o.addDeviceSession(e);const t=new a.SendCommandUseCase(o,()=>s);jest.spyOn(e,"sendCommand").mockResolvedValue({status:r.CommandResultStatus.Success,data:void 0});const v=await t.execute({sessionId:m,command:i});e.close(),expect(v).toStrictEqual({status:r.CommandResultStatus.Success,data:void 0})}),it("should throw an error if the session is not found",async()=>{const e=new a.SendCommandUseCase(o,()=>s);jest.spyOn(o,"getDeviceSessionById").mockReturnValue((0,d.Left)({_tag:"DeviceSessionNotFound"}));const t=e.execute({sessionId:m,command:i});await expect(t).rejects.toMatchObject({_tag:"DeviceSessionNotFound"})})});
|
2
2
|
//# sourceMappingURL=SendCommandUseCase.test.js.map
|
@@ -1,7 +1,7 @@
|
|
1
1
|
{
|
2
2
|
"version": 3,
|
3
3
|
"sources": ["../../../../../../src/api/command/use-case/SendCommandUseCase.test.ts"],
|
4
|
-
"sourcesContent": ["import { Left } from \"purify-ts\";\n\nimport { type Command } from \"@api/command/Command\";\nimport { CommandResultStatus } from \"@api/command/model/CommandResult\";\nimport { type LoggerPublisherService } from \"@api/logger-publisher/service/LoggerPublisherService\";\nimport { deviceSessionStubBuilder } from \"@internal/device-session/model/DeviceSession.stub\";\nimport { DefaultDeviceSessionService } from \"@internal/device-session/service/DefaultDeviceSessionService\";\nimport { type DeviceSessionService } from \"@internal/device-session/service/DeviceSessionService\";\nimport { DefaultLoggerPublisherService } from \"@internal/logger-publisher/service/DefaultLoggerPublisherService\";\nimport { AxiosManagerApiDataSource } from \"@internal/manager-api/data/AxiosManagerApiDataSource\";\nimport { type ManagerApiDataSource } from \"@internal/manager-api/data/ManagerApiDataSource\";\nimport { DefaultManagerApiService } from \"@internal/manager-api/service/DefaultManagerApiService\";\nimport { type ManagerApiService } from \"@internal/manager-api/service/ManagerApiService\";\n\nimport { SendCommandUseCase } from \"./SendCommandUseCase\";\n\nlet logger: LoggerPublisherService;\nlet sessionService: DeviceSessionService;\nlet managerApi: ManagerApiService;\nlet managerApiDataSource: ManagerApiDataSource;\nconst fakeSessionId = \"fakeSessionId\";\nlet command: Command<{ status: string }>;\n\ndescribe(\"SendCommandUseCase\", () => {\n beforeEach(() => {\n logger = new DefaultLoggerPublisherService([], \"send-command-use-case\");\n sessionService = new DefaultDeviceSessionService(() => logger);\n managerApiDataSource = new AxiosManagerApiDataSource({
|
5
|
-
"mappings": "aAAA,IAAAA,EAAqB,qBAGrBC,EAAoC,
|
4
|
+
"sourcesContent": ["import { Left } from \"purify-ts\";\n\nimport { type Command } from \"@api/command/Command\";\nimport { CommandResultStatus } from \"@api/command/model/CommandResult\";\nimport { type DmkConfig } from \"@api/DmkConfig\";\nimport { type LoggerPublisherService } from \"@api/logger-publisher/service/LoggerPublisherService\";\nimport { deviceSessionStubBuilder } from \"@internal/device-session/model/DeviceSession.stub\";\nimport { DefaultDeviceSessionService } from \"@internal/device-session/service/DefaultDeviceSessionService\";\nimport { type DeviceSessionService } from \"@internal/device-session/service/DeviceSessionService\";\nimport { DefaultLoggerPublisherService } from \"@internal/logger-publisher/service/DefaultLoggerPublisherService\";\nimport { AxiosManagerApiDataSource } from \"@internal/manager-api/data/AxiosManagerApiDataSource\";\nimport { type ManagerApiDataSource } from \"@internal/manager-api/data/ManagerApiDataSource\";\nimport { DefaultManagerApiService } from \"@internal/manager-api/service/DefaultManagerApiService\";\nimport { type ManagerApiService } from \"@internal/manager-api/service/ManagerApiService\";\n\nimport { SendCommandUseCase } from \"./SendCommandUseCase\";\n\nlet logger: LoggerPublisherService;\nlet sessionService: DeviceSessionService;\nlet managerApi: ManagerApiService;\nlet managerApiDataSource: ManagerApiDataSource;\nconst fakeSessionId = \"fakeSessionId\";\nlet command: Command<{ status: string }>;\n\ndescribe(\"SendCommandUseCase\", () => {\n beforeEach(() => {\n logger = new DefaultLoggerPublisherService([], \"send-command-use-case\");\n sessionService = new DefaultDeviceSessionService(() => logger);\n managerApiDataSource = new AxiosManagerApiDataSource({} as DmkConfig);\n managerApi = new DefaultManagerApiService(managerApiDataSource);\n command = {\n getApdu: jest.fn(),\n parseResponse: jest.fn(),\n };\n });\n\n afterEach(() => {\n jest.restoreAllMocks();\n });\n\n it(\"should send a command to a connected device\", async () => {\n const deviceSession = deviceSessionStubBuilder(\n {},\n () => logger,\n managerApi,\n );\n sessionService.addDeviceSession(deviceSession);\n const useCase = new SendCommandUseCase(sessionService, () => logger);\n\n jest.spyOn(deviceSession, \"sendCommand\").mockResolvedValue({\n status: CommandResultStatus.Success,\n data: undefined,\n });\n\n const response = await useCase.execute<{ status: string }, void, void>({\n sessionId: fakeSessionId,\n command,\n });\n\n deviceSession.close();\n\n expect(response).toStrictEqual({\n status: CommandResultStatus.Success,\n data: undefined,\n });\n });\n\n it(\"should throw an error if the session is not found\", async () => {\n const useCase = new SendCommandUseCase(sessionService, () => logger);\n jest\n .spyOn(sessionService, \"getDeviceSessionById\")\n .mockReturnValue(Left({ _tag: \"DeviceSessionNotFound\" }));\n\n const res = useCase.execute<{ status: string }, void, void>({\n sessionId: fakeSessionId,\n command,\n });\n\n await expect(res).rejects.toMatchObject({ _tag: \"DeviceSessionNotFound\" });\n });\n});\n"],
|
5
|
+
"mappings": "aAAA,IAAAA,EAAqB,qBAGrBC,EAAoC,4CAGpCC,EAAyC,6DACzCC,EAA4C,wEAE5CC,EAA8C,4EAC9CC,EAA0C,gEAE1CC,EAAyC,kEAGzCC,EAAmC,gCAEnC,IAAIC,EACAC,EAC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", "import_DefaultLoggerPublisherService", "import_AxiosManagerApiDataSource", "import_DefaultManagerApiService", "import_SendCommandUseCase", "logger", "sessionService", "managerApi", "managerApiDataSource", "fakeSessionId", "command", "deviceSession", "useCase", "response", "res"]
|
7
7
|
}
|
@@ -1,2 +1,2 @@
|
|
1
|
-
"use strict";var
|
1
|
+
"use strict";var n=Object.defineProperty;var a=Object.getOwnPropertyDescriptor;var c=Object.getOwnPropertyNames;var u=Object.prototype.hasOwnProperty;var o=(s,e)=>{for(var r in e)n(s,r,{get:e[r],enumerable:!0})},l=(s,e,r,p)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of c(e))!u.call(s,i)&&i!==r&&n(s,i,{get:()=>e[i],enumerable:!(p=a(e,i))||p.enumerable});return s};var d=s=>l(n({},"__esModule",{value:!0}),s);var f={};o(f,{CommandUtils:()=>t});module.exports=d(f);class t{static isValidStatusCode(e){return e.length===2}static isSuccessResponse({statusCode:e}){return t.isValidStatusCode(e)?e[0]===144&&e[1]===0:!1}static isLockedDeviceResponse({statusCode:e}){return t.isValidStatusCode(e)?e[0]===85&&e[1]===21:!1}}0&&(module.exports={CommandUtils});
|
2
2
|
//# sourceMappingURL=CommandUtils.js.map
|
@@ -1,7 +1,7 @@
|
|
1
1
|
{
|
2
2
|
"version": 3,
|
3
3
|
"sources": ["../../../../../../src/api/command/utils/CommandUtils.ts"],
|
4
|
-
"sourcesContent": ["import { type ApduResponse } from \"@api/device-session/ApduResponse\";\n\nexport class CommandUtils {\n static isValidStatusCode(statusCode: Uint8Array) {\n return statusCode.length === 2;\n }\n\n static isSuccessResponse({ statusCode }: ApduResponse) {\n if (!
|
5
|
-
"mappings": "yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,kBAAAE,IAAA,eAAAC,EAAAH,GAEO,MAAME,CAAa,CACxB,OAAO,kBAAkBE,EAAwB,CAC/C,OAAOA,EAAW,SAAW,CAC/B,CAEA,OAAO,kBAAkB,CAAE,WAAAA,CAAW,EAAiB,CACrD,
|
4
|
+
"sourcesContent": ["import { type ApduResponse } from \"@api/device-session/ApduResponse\";\n\nexport class CommandUtils {\n static isValidStatusCode(statusCode: Uint8Array) {\n return statusCode.length === 2;\n }\n\n static isSuccessResponse({ statusCode }: ApduResponse) {\n if (!CommandUtils.isValidStatusCode(statusCode)) {\n return false;\n }\n\n return statusCode[0] === 0x90 && statusCode[1] === 0x00;\n }\n\n static isLockedDeviceResponse({ statusCode }: ApduResponse) {\n if (!CommandUtils.isValidStatusCode(statusCode)) {\n return false;\n }\n\n return statusCode[0] === 0x55 && statusCode[1] === 0x15;\n }\n}\n"],
|
5
|
+
"mappings": "yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,kBAAAE,IAAA,eAAAC,EAAAH,GAEO,MAAME,CAAa,CACxB,OAAO,kBAAkBE,EAAwB,CAC/C,OAAOA,EAAW,SAAW,CAC/B,CAEA,OAAO,kBAAkB,CAAE,WAAAA,CAAW,EAAiB,CACrD,OAAKF,EAAa,kBAAkBE,CAAU,EAIvCA,EAAW,CAAC,IAAM,KAAQA,EAAW,CAAC,IAAM,EAH1C,EAIX,CAEA,OAAO,uBAAuB,CAAE,WAAAA,CAAW,EAAiB,CAC1D,OAAKF,EAAa,kBAAkBE,CAAU,EAIvCA,EAAW,CAAC,IAAM,IAAQA,EAAW,CAAC,IAAM,GAH1C,EAIX,CACF",
|
6
6
|
"names": ["CommandUtils_exports", "__export", "CommandUtils", "__toCommonJS", "statusCode"]
|
7
7
|
}
|
@@ -1,7 +1,7 @@
|
|
1
1
|
{
|
2
2
|
"version": 3,
|
3
3
|
"sources": ["../../../../../src/api/device-action/DeviceAction.ts"],
|
4
|
-
"sourcesContent": ["import { type Observable } from \"rxjs\";\n\nimport { type Command } from \"@api/command/Command\";\nimport { type CommandResult } from \"@api/command/model/CommandResult\";\nimport { type DeviceSessionState } from \"@api/device-session/DeviceSessionState\";\nimport { type DmkError } from \"@api/Error\";\nimport { type ManagerApiService } from \"@internal/manager-api/service/ManagerApiService\";\n\nimport { type DeviceActionState } from \"./model/DeviceActionState\";\n\nexport type InternalApi = {\n readonly sendCommand: <Response, Args, ErrorStatusCodes>(\n command: Command<Response, Args, ErrorStatusCodes>,\n ) => Promise<CommandResult<Response, ErrorStatusCodes>>;\n readonly getDeviceSessionState: () => DeviceSessionState;\n readonly getDeviceSessionStateObservable: () => Observable<DeviceSessionState>;\n readonly setDeviceSessionState: (\n state: DeviceSessionState,\n ) => DeviceSessionState;\n
|
4
|
+
"sourcesContent": ["import { type Observable } from \"rxjs\";\n\nimport { type Command } from \"@api/command/Command\";\nimport { type CommandResult } from \"@api/command/model/CommandResult\";\nimport { type DeviceSessionState } from \"@api/device-session/DeviceSessionState\";\nimport { type DmkError } from \"@api/Error\";\nimport { type ManagerApiService } from \"@internal/manager-api/service/ManagerApiService\";\n\nimport { type DeviceActionState } from \"./model/DeviceActionState\";\n\nexport type InternalApi = {\n readonly sendCommand: <Response, Args, ErrorStatusCodes>(\n command: Command<Response, Args, ErrorStatusCodes>,\n ) => Promise<CommandResult<Response, ErrorStatusCodes>>;\n readonly getDeviceSessionState: () => DeviceSessionState;\n readonly getDeviceSessionStateObservable: () => Observable<DeviceSessionState>;\n readonly setDeviceSessionState: (\n state: DeviceSessionState,\n ) => DeviceSessionState;\n readonly getManagerApiService: () => ManagerApiService;\n};\n\nexport type DeviceActionIntermediateValue = {\n readonly requiredUserInteraction: string;\n};\n\nexport type ExecuteDeviceActionReturnType<Output, Error, IntermediateValue> = {\n readonly observable: Observable<\n DeviceActionState<Output, Error, IntermediateValue>\n >;\n cancel(): void;\n};\n\nexport interface DeviceAction<\n Output,\n Input,\n Error extends DmkError,\n IntermediateValue extends DeviceActionIntermediateValue,\n> {\n readonly input: Input;\n\n _execute(\n params: InternalApi,\n ): ExecuteDeviceActionReturnType<Output, Error, IntermediateValue>;\n}\n"],
|
5
5
|
"mappings": "+WAAA,IAAAA,EAAA,kBAAAC,EAAAD",
|
6
6
|
"names": ["DeviceAction_exports", "__toCommonJS"]
|
7
7
|
}
|
@@ -1,2 +1,2 @@
|
|
1
|
-
"use strict";var
|
1
|
+
"use strict";var i=Object.defineProperty;var c=Object.getOwnPropertyDescriptor;var a=Object.getOwnPropertyNames;var r=Object.prototype.hasOwnProperty;var S=(t,e)=>{for(var s in e)i(t,s,{get:e[s],enumerable:!0})},v=(t,e,s,o)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of a(e))!r.call(t,n)&&n!==s&&i(t,n,{get:()=>e[n],enumerable:!(o=c(e,n))||o.enumerable});return t};var p=t=>v(i({},"__esModule",{value:!0}),t);var j={};S(j,{makeDeviceActionInternalApiMock:()=>g});module.exports=p(j);const M=jest.fn(),k=jest.fn(),f=jest.fn(),m=jest.fn(),D=jest.fn();function g(){return{sendCommand:M,getDeviceSessionState:k,getDeviceSessionStateObservable:f,setDeviceSessionState:m,getManagerApiService:D}}0&&(module.exports={makeDeviceActionInternalApiMock});
|
2
2
|
//# sourceMappingURL=makeInternalApi.js.map
|
@@ -1,7 +1,7 @@
|
|
1
1
|
{
|
2
2
|
"version": 3,
|
3
3
|
"sources": ["../../../../../../src/api/device-action/__test-utils__/makeInternalApi.ts"],
|
4
|
-
"sourcesContent": ["import { type InternalApi } from \"@api/device-action/DeviceAction\";\n\nconst sendCommandMock = jest.fn();\nconst apiGetDeviceSessionStateMock = jest.fn();\nconst apiGetDeviceSessionStateObservableMock = jest.fn();\nconst setDeviceSessionStateMock = jest.fn();\nconst
|
5
|
-
"mappings": "yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,qCAAAE,IAAA,eAAAC,EAAAH,GAEA,MAAMI,EAAkB,KAAK,GAAG,EAC1BC,EAA+B,KAAK,GAAG,EACvCC,EAAyC,KAAK,GAAG,EACjDC,EAA4B,KAAK,GAAG,EACpCC,
|
6
|
-
"names": ["makeInternalApi_exports", "__export", "makeDeviceActionInternalApiMock", "__toCommonJS", "sendCommandMock", "apiGetDeviceSessionStateMock", "apiGetDeviceSessionStateObservableMock", "setDeviceSessionStateMock", "
|
4
|
+
"sourcesContent": ["import { type InternalApi } from \"@api/device-action/DeviceAction\";\n\nconst sendCommandMock = jest.fn();\nconst apiGetDeviceSessionStateMock = jest.fn();\nconst apiGetDeviceSessionStateObservableMock = jest.fn();\nconst setDeviceSessionStateMock = jest.fn();\nconst getManagerApiServiceMock = jest.fn();\n\nexport function makeDeviceActionInternalApiMock(): jest.Mocked<InternalApi> {\n return {\n sendCommand: sendCommandMock,\n getDeviceSessionState: apiGetDeviceSessionStateMock,\n getDeviceSessionStateObservable: apiGetDeviceSessionStateObservableMock,\n setDeviceSessionState: setDeviceSessionStateMock,\n getManagerApiService: getManagerApiServiceMock,\n };\n}\n"],
|
5
|
+
"mappings": "yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,qCAAAE,IAAA,eAAAC,EAAAH,GAEA,MAAMI,EAAkB,KAAK,GAAG,EAC1BC,EAA+B,KAAK,GAAG,EACvCC,EAAyC,KAAK,GAAG,EACjDC,EAA4B,KAAK,GAAG,EACpCC,EAA2B,KAAK,GAAG,EAElC,SAASN,GAA4D,CAC1E,MAAO,CACL,YAAaE,EACb,sBAAuBC,EACvB,gCAAiCC,EACjC,sBAAuBC,EACvB,qBAAsBC,CACxB,CACF",
|
6
|
+
"names": ["makeInternalApi_exports", "__export", "makeDeviceActionInternalApiMock", "__toCommonJS", "sendCommandMock", "apiGetDeviceSessionStateMock", "apiGetDeviceSessionStateObservableMock", "setDeviceSessionStateMock", "getManagerApiServiceMock"]
|
7
7
|
}
|
package/lib/cjs/src/api/device-action/os/GetDeviceStatus/GetDeviceStatusDeviceAction.test.js
CHANGED
@@ -1,2 +1,2 @@
|
|
1
|
-
"use strict";var u=require("rxjs"),
|
1
|
+
"use strict";var u=require("rxjs"),v=require("../../../command/model/CommandResult"),y=require("../../../command/utils/GlobalCommandError"),S=require("../../../device/DeviceModel"),i=require("../../../device/DeviceStatus"),a=require("../../../device-action/__test-utils__/makeInternalApi"),d=require("../../../device-action/__test-utils__/testDeviceActionStates"),t=require("../../../device-action/model/DeviceActionState"),c=require("../../../device-action/model/UserInteractionRequired"),D=require("../../../device-action/os/Errors"),o=require("../../../device-session/DeviceSessionState"),p=require("./GetDeviceStatusDeviceAction");describe("GetDeviceStatusDeviceAction",()=>{const k=jest.fn(),l=jest.fn(),h=jest.fn(),f=jest.fn(),O=jest.fn();function A(){return{getAppAndVersion:k,getDeviceSessionState:l,waitForDeviceUnlock:h,setDeviceSessionState:f,isDeviceOnboarded:O}}const{sendCommand:R,getDeviceSessionState:V,getDeviceSessionStateObservable:E}=(0,a.makeDeviceActionInternalApiMock)();beforeEach(()=>{jest.resetAllMocks(),O.mockReturnValue(!0)}),describe("without overriding `extractDependencies`",()=>{it("should run the device action with an unlocked device",r=>{const e=new p.GetDeviceStatusDeviceAction({input:{unlockTimeout:500}});V.mockReturnValue({sessionStateType:o.DeviceSessionStateType.Connected,deviceStatus:i.DeviceStatus.CONNECTED,deviceModelId:S.DeviceModelId.FLEX}),R.mockResolvedValue((0,v.CommandResultFactory)({data:{name:"BOLOS",version:"1.0.0"}}));const n=[{intermediateValue:{requiredUserInteraction:c.UserInteractionRequired.None},status:t.DeviceActionStatus.Pending},{output:{currentApp:"BOLOS",currentAppVersion:"1.0.0"},status:t.DeviceActionStatus.Completed}];(0,d.testDeviceActionStates)(e,n,(0,a.makeDeviceActionInternalApiMock)(),r)}),it("should run the device action with a locked device",r=>{const e=new p.GetDeviceStatusDeviceAction({input:{unlockTimeout:500}});V.mockReturnValue({sessionStateType:o.DeviceSessionStateType.ReadyWithoutSecureChannel,deviceStatus:i.DeviceStatus.LOCKED,currentApp:{name:"mockedCurrentApp",version:"1.0.0"},installedApps:[],deviceModelId:S.DeviceModelId.FLEX}),E.mockImplementation(()=>new u.Observable(s=>{const m=(0,u.interval)(50).subscribe({next:C=>{C>2?(s.next({sessionStateType:o.DeviceSessionStateType.ReadyWithoutSecureChannel,deviceStatus:i.DeviceStatus.CONNECTED,currentApp:{name:"mockedCurrentApp",version:"1.0.0"},installedApps:[],deviceModelId:S.DeviceModelId.FLEX}),s.complete()):s.next({sessionStateType:o.DeviceSessionStateType.ReadyWithoutSecureChannel,deviceStatus:i.DeviceStatus.LOCKED,currentApp:{name:"mockedCurrentApp",version:"1.0.0"},installedApps:[],deviceModelId:S.DeviceModelId.FLEX})}});return()=>{m.unsubscribe()}})),R.mockResolvedValue((0,v.CommandResultFactory)({data:{name:"BOLOS",version:"1.0.0"}}));const n=[{intermediateValue:{requiredUserInteraction:c.UserInteractionRequired.UnlockDevice},status:t.DeviceActionStatus.Pending},{intermediateValue:{requiredUserInteraction:c.UserInteractionRequired.None},status:t.DeviceActionStatus.Pending},{output:{currentApp:"BOLOS",currentAppVersion:"1.0.0"},status:t.DeviceActionStatus.Completed}];(0,d.testDeviceActionStates)(e,n,(0,a.makeDeviceActionInternalApiMock)(),r)})}),describe("success cases",()=>{it("should return the device status if the device is unlocked",r=>{l.mockReturnValue({sessionStateType:o.DeviceSessionStateType.ReadyWithoutSecureChannel,deviceStatus:i.DeviceStatus.CONNECTED,currentApp:{name:"mockedCurrentApp",version:"1.0.0"}}),k.mockResolvedValue((0,v.CommandResultFactory)({data:{name:"BOLOS",version:"1.0.0"}}));const e=new p.GetDeviceStatusDeviceAction({input:{unlockTimeout:void 0}});jest.spyOn(e,"extractDependencies").mockReturnValue(A());const n=[{intermediateValue:{requiredUserInteraction:c.UserInteractionRequired.None},status:t.DeviceActionStatus.Pending},{status:t.DeviceActionStatus.Completed,output:{currentApp:"BOLOS",currentAppVersion:"1.0.0"}}];(0,d.testDeviceActionStates)(e,n,(0,a.makeDeviceActionInternalApiMock)(),r)}),it("should return the device status if the device is locked and the user unlocks the device",r=>{l.mockReturnValue({sessionStateType:o.DeviceSessionStateType.ReadyWithoutSecureChannel,deviceStatus:i.DeviceStatus.LOCKED,currentApp:{name:"mockedCurrentApp",version:"1.0.0"}}),k.mockResolvedValue((0,v.CommandResultFactory)({data:{name:"BOLOS",version:"1.0.0"}})),h.mockImplementation(()=>new u.Observable(s=>{const m=(0,u.interval)(50).subscribe({next:C=>{C>2?(s.next({sessionStateType:o.DeviceSessionStateType.ReadyWithoutSecureChannel,deviceStatus:i.DeviceStatus.CONNECTED,currentApp:{name:"mockedCurrentApp",version:"1.0.0"}}),s.complete()):s.next({sessionStateType:o.DeviceSessionStateType.ReadyWithoutSecureChannel,deviceStatus:i.DeviceStatus.LOCKED,currentApp:{name:"mockedCurrentApp",version:"1.0.0"}})}});return()=>{m.unsubscribe()}}));const e=new p.GetDeviceStatusDeviceAction({input:{unlockTimeout:500}});jest.spyOn(e,"extractDependencies").mockReturnValue(A());const n=[{intermediateValue:{requiredUserInteraction:c.UserInteractionRequired.UnlockDevice},status:t.DeviceActionStatus.Pending},{intermediateValue:{requiredUserInteraction:c.UserInteractionRequired.None},status:t.DeviceActionStatus.Pending},{status:t.DeviceActionStatus.Completed,output:{currentApp:"BOLOS",currentAppVersion:"1.0.0"}}];(0,d.testDeviceActionStates)(e,n,(0,a.makeDeviceActionInternalApiMock)(),r)})}),describe("errors cases",()=>{it("should end in an error if the device is not onboarded",r=>{l.mockReturnValue({sessionStateType:o.DeviceSessionStateType.ReadyWithoutSecureChannel,deviceStatus:i.DeviceStatus.LOCKED,currentApp:{name:"mockedCurrentApp",version:"1.0.0"}}),O.mockReturnValue(!1);const e=new p.GetDeviceStatusDeviceAction({input:{unlockTimeout:500}});jest.spyOn(e,"extractDependencies").mockReturnValue(A());const n=[{error:new D.DeviceNotOnboardedError,status:t.DeviceActionStatus.Error}];(0,d.testDeviceActionStates)(e,n,(0,a.makeDeviceActionInternalApiMock)(),r)}),it("should end in an error if the device is locked and the user does not unlock",r=>{l.mockReturnValue({sessionStateType:o.DeviceSessionStateType.ReadyWithoutSecureChannel,deviceStatus:i.DeviceStatus.LOCKED,currentApp:{name:"mockedCurrentApp",version:"1.0.0"}}),E.mockImplementation(()=>new u.Observable(s=>{const m=(0,u.interval)(200).subscribe({next:()=>{s.next({sessionStateType:o.DeviceSessionStateType.ReadyWithoutSecureChannel,deviceStatus:i.DeviceStatus.LOCKED,currentApp:{name:"mockedCurrentApp",version:"1.0.0"},installedApps:[],deviceModelId:S.DeviceModelId.FLEX})}});return()=>{m.unsubscribe()}}));const e=new p.GetDeviceStatusDeviceAction({input:{unlockTimeout:500}});jest.spyOn(e,"extractDependencies").mockReturnValue(A());const n=[{intermediateValue:{requiredUserInteraction:c.UserInteractionRequired.UnlockDevice},status:t.DeviceActionStatus.Pending},{error:new D.DeviceLockedError("Device locked."),status:t.DeviceActionStatus.Error}];(0,d.testDeviceActionStates)(e,n,(0,a.makeDeviceActionInternalApiMock)(),r)}),it("should end in an error if the GetAppAndVersion command fails",r=>{l.mockReturnValue({sessionStateType:o.DeviceSessionStateType.ReadyWithoutSecureChannel,deviceStatus:i.DeviceStatus.LOCKED,currentApp:{name:"mockedCurrentApp",version:"1.0.0"}});const e=new y.GlobalCommandError({...y.GLOBAL_ERRORS[5501],errorCode:"5501"});k.mockResolvedValue((0,v.CommandResultFactory)({error:e})),h.mockImplementation(()=>new u.Observable(m=>{const C=(0,u.interval)(50).subscribe({next:b=>{b>2?(m.next({sessionStateType:o.DeviceSessionStateType.ReadyWithoutSecureChannel,deviceStatus:i.DeviceStatus.CONNECTED,currentApp:{name:"mockedCurrentApp",version:"1.0.0"}}),m.complete()):m.next({sessionStateType:o.DeviceSessionStateType.ReadyWithoutSecureChannel,deviceStatus:i.DeviceStatus.LOCKED,currentApp:{name:"mockedCurrentApp",version:"1.0.0"}})}});return()=>{C.unsubscribe()}}));const n=new p.GetDeviceStatusDeviceAction({input:{unlockTimeout:500}});jest.spyOn(n,"extractDependencies").mockReturnValue(A());const s=[{intermediateValue:{requiredUserInteraction:c.UserInteractionRequired.UnlockDevice},status:t.DeviceActionStatus.Pending},{intermediateValue:{requiredUserInteraction:c.UserInteractionRequired.None},status:t.DeviceActionStatus.Pending},{error:e,status:t.DeviceActionStatus.Error}];(0,d.testDeviceActionStates)(n,s,(0,a.makeDeviceActionInternalApiMock)(),r)}),it("should end in an error if getAppAndVersion actor throws an error",r=>{l.mockReturnValue({sessionStateType:o.DeviceSessionStateType.ReadyWithoutSecureChannel,deviceStatus:i.DeviceStatus.LOCKED,currentApp:{name:"mockedCurrentApp",version:"1.0.0"}}),k.mockImplementation(()=>{throw new D.UnknownDAError("error")}),h.mockImplementation(()=>new u.Observable(s=>{s.complete()}));const e=new p.GetDeviceStatusDeviceAction({input:{unlockTimeout:500}});jest.spyOn(e,"extractDependencies").mockReturnValue(A());const n=[{intermediateValue:{requiredUserInteraction:c.UserInteractionRequired.UnlockDevice},status:t.DeviceActionStatus.Pending},{intermediateValue:{requiredUserInteraction:c.UserInteractionRequired.None},status:t.DeviceActionStatus.Pending},{error:new D.UnknownDAError("error"),status:t.DeviceActionStatus.Error}];(0,d.testDeviceActionStates)(e,n,(0,a.makeDeviceActionInternalApiMock)(),r)})}),it("should emit a stopped state if the action is cancelled",r=>{V.mockReturnValue({sessionStateType:o.DeviceSessionStateType.ReadyWithoutSecureChannel,deviceStatus:i.DeviceStatus.CONNECTED,currentApp:{name:"mockedCurrentApp",version:"1.0.0"},installedApps:[],deviceModelId:S.DeviceModelId.FLEX}),R.mockResolvedValue((0,v.CommandResultFactory)({data:{name:"BOLOS",version:"1.0.0"}}));const e=new p.GetDeviceStatusDeviceAction({input:{unlockTimeout:500}}),n=[{status:t.DeviceActionStatus.Pending,intermediateValue:{requiredUserInteraction:c.UserInteractionRequired.None}},{status:t.DeviceActionStatus.Stopped}],{cancel:s}=(0,d.testDeviceActionStates)(e,n,(0,a.makeDeviceActionInternalApiMock)(),r);s()})});
|
2
2
|
//# sourceMappingURL=GetDeviceStatusDeviceAction.test.js.map
|
package/lib/cjs/src/api/device-action/os/GetDeviceStatus/GetDeviceStatusDeviceAction.test.js.map
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
{
|
2
2
|
"version": 3,
|
3
3
|
"sources": ["../../../../../../../src/api/device-action/os/GetDeviceStatus/GetDeviceStatusDeviceAction.test.ts"],
|
4
|
-
"sourcesContent": ["import { interval, Observable } from \"rxjs\";\n\nimport { CommandResultFactory } from \"@api/command/model/CommandResult\";\nimport {\n GLOBAL_ERRORS,\n GlobalCommandError,\n} from \"@api/command/utils/GlobalCommandError\";\nimport { DeviceStatus } from \"@api/device/DeviceStatus\";\nimport { makeDeviceActionInternalApiMock } from \"@api/device-action/__test-utils__/makeInternalApi\";\nimport { testDeviceActionStates } from \"@api/device-action/__test-utils__/testDeviceActionStates\";\nimport { DeviceActionStatus } from \"@api/device-action/model/DeviceActionState\";\nimport { UserInteractionRequired } from \"@api/device-action/model/UserInteractionRequired\";\nimport {\n DeviceLockedError,\n DeviceNotOnboardedError,\n UnknownDAError,\n} from \"@api/device-action/os/Errors\";\nimport { DeviceSessionStateType } from \"@api/device-session/DeviceSessionState\";\n\nimport { GetDeviceStatusDeviceAction } from \"./GetDeviceStatusDeviceAction\";\nimport { type GetDeviceStatusDAState } from \"./types\";\n\ndescribe(\"GetDeviceStatusDeviceAction\", () => {\n const getAppAndVersionMock = jest.fn();\n const getDeviceSessionStateMock = jest.fn();\n const waitForDeviceUnlockMock = jest.fn();\n const setDeviceSessionState = jest.fn();\n const isDeviceOnboardedMock = jest.fn();\n\n function extractDependenciesMock() {\n return {\n getAppAndVersion: getAppAndVersionMock,\n getDeviceSessionState: getDeviceSessionStateMock,\n waitForDeviceUnlock: waitForDeviceUnlockMock,\n setDeviceSessionState: setDeviceSessionState,\n isDeviceOnboarded: isDeviceOnboardedMock,\n };\n }\n\n const {\n sendCommand: sendCommandMock,\n getDeviceSessionState: apiGetDeviceSessionStateMock,\n getDeviceSessionStateObservable: apiGetDeviceSessionStateObservableMock,\n } = makeDeviceActionInternalApiMock();\n beforeEach(() => {\n jest.resetAllMocks();\n isDeviceOnboardedMock.mockReturnValue(true);\n });\n\n describe(\"without overriding `extractDependencies`\", () => {\n it(\"should run the device action with an unlocked device\", (done) => {\n const getDeviceStateDeviceAction = new GetDeviceStatusDeviceAction({\n input: { unlockTimeout: 500 },\n });\n\n apiGetDeviceSessionStateMock.mockReturnValue({\n sessionStateType: DeviceSessionStateType.Connected,\n deviceStatus: DeviceStatus.CONNECTED,\n });\n\n sendCommandMock.mockResolvedValue(\n CommandResultFactory({\n data: {\n name: \"BOLOS\",\n version: \"1.0.0\",\n },\n }),\n );\n\n const expectedStates: Array<GetDeviceStatusDAState> = [\n {\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.None,\n },\n status: DeviceActionStatus.Pending,\n },\n {\n output: {\n currentApp: \"BOLOS\",\n currentAppVersion: \"1.0.0\",\n },\n status: DeviceActionStatus.Completed,\n },\n ];\n\n testDeviceActionStates(\n getDeviceStateDeviceAction,\n expectedStates,\n makeDeviceActionInternalApiMock(),\n done,\n );\n });\n\n it(\"should run the device action with a locked device\", (done) => {\n const getDeviceStateDeviceAction = new GetDeviceStatusDeviceAction({\n input: { unlockTimeout: 500 },\n });\n\n apiGetDeviceSessionStateMock.mockReturnValue({\n sessionStateType: DeviceSessionStateType.ReadyWithoutSecureChannel,\n deviceStatus: DeviceStatus.LOCKED,\n currentApp: { name: \"mockedCurrentApp\", version: \"1.0.0\" },\n installedApps: [],\n });\n\n apiGetDeviceSessionStateObservableMock.mockImplementation(\n () =>\n new Observable((o) => {\n const inner = interval(50).subscribe({\n next: (i) => {\n if (i > 2) {\n o.next({\n sessionStateType:\n DeviceSessionStateType.ReadyWithoutSecureChannel,\n deviceStatus: DeviceStatus.CONNECTED,\n currentApp: { name: \"mockedCurrentApp\", version: \"1.0.0\" },\n installedApps: [],\n });\n o.complete();\n } else {\n o.next({\n sessionStateType:\n DeviceSessionStateType.ReadyWithoutSecureChannel,\n deviceStatus: DeviceStatus.LOCKED,\n currentApp: { name: \"mockedCurrentApp\", version: \"1.0.0\" },\n installedApps: [],\n });\n }\n },\n });\n\n return () => {\n inner.unsubscribe();\n };\n }),\n );\n\n sendCommandMock.mockResolvedValue(\n CommandResultFactory({\n data: {\n name: \"BOLOS\",\n version: \"1.0.0\",\n },\n }),\n );\n\n const expectedStates: Array<GetDeviceStatusDAState> = [\n {\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.UnlockDevice,\n },\n status: DeviceActionStatus.Pending,\n },\n {\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.None,\n },\n status: DeviceActionStatus.Pending,\n },\n {\n output: {\n currentApp: \"BOLOS\",\n currentAppVersion: \"1.0.0\",\n },\n status: DeviceActionStatus.Completed,\n },\n ];\n\n testDeviceActionStates(\n getDeviceStateDeviceAction,\n expectedStates,\n makeDeviceActionInternalApiMock(),\n done,\n );\n });\n });\n\n describe(\"success cases\", () => {\n it(\"should return the device status if the device is unlocked\", (done) => {\n getDeviceSessionStateMock.mockReturnValue({\n sessionStateType: DeviceSessionStateType.ReadyWithoutSecureChannel,\n deviceStatus: DeviceStatus.CONNECTED,\n currentApp: { name: \"mockedCurrentApp\", version: \"1.0.0\" },\n });\n\n getAppAndVersionMock.mockResolvedValue(\n CommandResultFactory({\n data: {\n name: \"BOLOS\",\n version: \"1.0.0\",\n },\n }),\n );\n\n const getDeviceStateDeviceAction = new GetDeviceStatusDeviceAction({\n input: { unlockTimeout: undefined },\n });\n\n jest\n .spyOn(getDeviceStateDeviceAction, \"extractDependencies\")\n .mockReturnValue(extractDependenciesMock());\n\n const expectedStates: Array<GetDeviceStatusDAState> = [\n {\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.None,\n },\n status: DeviceActionStatus.Pending,\n },\n {\n status: DeviceActionStatus.Completed,\n output: {\n currentApp: \"BOLOS\",\n currentAppVersion: \"1.0.0\",\n },\n },\n ];\n\n testDeviceActionStates(\n getDeviceStateDeviceAction,\n expectedStates,\n makeDeviceActionInternalApiMock(),\n done,\n );\n });\n\n it(\"should return the device status if the device is locked and the user unlocks the device\", (done) => {\n getDeviceSessionStateMock.mockReturnValue({\n sessionStateType: DeviceSessionStateType.ReadyWithoutSecureChannel,\n deviceStatus: DeviceStatus.LOCKED,\n currentApp: { name: \"mockedCurrentApp\", version: \"1.0.0\" },\n });\n\n getAppAndVersionMock.mockResolvedValue(\n CommandResultFactory({\n data: {\n name: \"BOLOS\",\n version: \"1.0.0\",\n },\n }),\n );\n\n waitForDeviceUnlockMock.mockImplementation(\n () =>\n new Observable((o) => {\n const inner = interval(50).subscribe({\n next: (i) => {\n if (i > 2) {\n o.next({\n sessionStateType:\n DeviceSessionStateType.ReadyWithoutSecureChannel,\n deviceStatus: DeviceStatus.CONNECTED,\n currentApp: { name: \"mockedCurrentApp\", version: \"1.0.0\" },\n });\n o.complete();\n } else {\n o.next({\n sessionStateType:\n DeviceSessionStateType.ReadyWithoutSecureChannel,\n deviceStatus: DeviceStatus.LOCKED,\n currentApp: { name: \"mockedCurrentApp\", version: \"1.0.0\" },\n });\n }\n },\n });\n\n return () => {\n inner.unsubscribe();\n };\n }),\n );\n\n const getDeviceStateDeviceAction = new GetDeviceStatusDeviceAction({\n input: { unlockTimeout: 500 },\n });\n\n jest\n .spyOn(getDeviceStateDeviceAction, \"extractDependencies\")\n .mockReturnValue(extractDependenciesMock());\n\n const expectedStates: Array<GetDeviceStatusDAState> = [\n {\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.UnlockDevice,\n },\n status: DeviceActionStatus.Pending,\n },\n {\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.None,\n },\n status: DeviceActionStatus.Pending,\n },\n {\n status: DeviceActionStatus.Completed,\n output: {\n currentApp: \"BOLOS\",\n currentAppVersion: \"1.0.0\",\n },\n },\n ];\n\n testDeviceActionStates(\n getDeviceStateDeviceAction,\n expectedStates,\n makeDeviceActionInternalApiMock(),\n done,\n );\n });\n });\n\n describe(\"errors cases\", () => {\n it(\"should end in an error if the device is not onboarded\", (done) => {\n getDeviceSessionStateMock.mockReturnValue({\n sessionStateType: DeviceSessionStateType.ReadyWithoutSecureChannel,\n deviceStatus: DeviceStatus.LOCKED,\n currentApp: { name: \"mockedCurrentApp\", version: \"1.0.0\" },\n });\n isDeviceOnboardedMock.mockReturnValue(false);\n\n const getDeviceStateDeviceAction = new GetDeviceStatusDeviceAction({\n input: { unlockTimeout: 500 },\n });\n\n jest\n .spyOn(getDeviceStateDeviceAction, \"extractDependencies\")\n .mockReturnValue(extractDependenciesMock());\n\n const expectedStates: Array<GetDeviceStatusDAState> = [\n {\n error: new DeviceNotOnboardedError(),\n status: DeviceActionStatus.Error,\n },\n ];\n\n testDeviceActionStates(\n getDeviceStateDeviceAction,\n expectedStates,\n makeDeviceActionInternalApiMock(),\n done,\n );\n });\n\n it(\"should end in an error if the device is locked and the user does not unlock\", (done) => {\n getDeviceSessionStateMock.mockReturnValue({\n sessionStateType: DeviceSessionStateType.ReadyWithoutSecureChannel,\n deviceStatus: DeviceStatus.LOCKED,\n currentApp: { name: \"mockedCurrentApp\", version: \"1.0.0\" },\n });\n\n apiGetDeviceSessionStateObservableMock.mockImplementation(\n () =>\n new Observable((o) => {\n const inner = interval(200).subscribe({\n next: () => {\n o.next({\n sessionStateType:\n DeviceSessionStateType.ReadyWithoutSecureChannel,\n deviceStatus: DeviceStatus.LOCKED,\n currentApp: { name: \"mockedCurrentApp\", version: \"1.0.0\" },\n installedApps: [],\n });\n },\n });\n\n return () => {\n inner.unsubscribe();\n };\n }),\n );\n\n const getDeviceStateDeviceAction = new GetDeviceStatusDeviceAction({\n input: { unlockTimeout: 500 },\n });\n\n jest\n .spyOn(getDeviceStateDeviceAction, \"extractDependencies\")\n .mockReturnValue(extractDependenciesMock());\n\n const expectedStates: Array<GetDeviceStatusDAState> = [\n {\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.UnlockDevice,\n },\n status: DeviceActionStatus.Pending,\n },\n {\n error: new DeviceLockedError(\"Device locked.\"),\n status: DeviceActionStatus.Error,\n },\n ];\n\n testDeviceActionStates(\n getDeviceStateDeviceAction,\n expectedStates,\n makeDeviceActionInternalApiMock(),\n done,\n );\n });\n\n it(\"should end in an error if the GetAppAndVersion command fails\", (done) => {\n getDeviceSessionStateMock.mockReturnValue({\n sessionStateType: DeviceSessionStateType.ReadyWithoutSecureChannel,\n deviceStatus: DeviceStatus.LOCKED,\n currentApp: { name: \"mockedCurrentApp\", version: \"1.0.0\" },\n });\n\n const error = new GlobalCommandError({\n ...GLOBAL_ERRORS[\"5501\"],\n errorCode: \"5501\",\n });\n\n getAppAndVersionMock.mockResolvedValue(CommandResultFactory({ error }));\n\n waitForDeviceUnlockMock.mockImplementation(\n () =>\n new Observable((o) => {\n const inner = interval(50).subscribe({\n next: (i) => {\n if (i > 2) {\n o.next({\n sessionStateType:\n DeviceSessionStateType.ReadyWithoutSecureChannel,\n deviceStatus: DeviceStatus.CONNECTED,\n currentApp: { name: \"mockedCurrentApp\", version: \"1.0.0\" },\n });\n o.complete();\n } else {\n o.next({\n sessionStateType:\n DeviceSessionStateType.ReadyWithoutSecureChannel,\n deviceStatus: DeviceStatus.LOCKED,\n currentApp: { name: \"mockedCurrentApp\", version: \"1.0.0\" },\n });\n }\n },\n });\n\n return () => {\n inner.unsubscribe();\n };\n }),\n );\n\n const getDeviceStateDeviceAction = new GetDeviceStatusDeviceAction({\n input: { unlockTimeout: 500 },\n });\n\n jest\n .spyOn(getDeviceStateDeviceAction, \"extractDependencies\")\n .mockReturnValue(extractDependenciesMock());\n\n const expectedStates: Array<GetDeviceStatusDAState> = [\n {\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.UnlockDevice,\n },\n status: DeviceActionStatus.Pending,\n },\n {\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.None,\n },\n status: DeviceActionStatus.Pending,\n },\n {\n error,\n status: DeviceActionStatus.Error,\n },\n ];\n\n testDeviceActionStates(\n getDeviceStateDeviceAction,\n expectedStates,\n makeDeviceActionInternalApiMock(),\n done,\n );\n });\n\n it(\"should end in an error if getAppAndVersion actor throws an error\", (done) => {\n getDeviceSessionStateMock.mockReturnValue({\n sessionStateType: DeviceSessionStateType.ReadyWithoutSecureChannel,\n deviceStatus: DeviceStatus.LOCKED,\n currentApp: { name: \"mockedCurrentApp\", version: \"1.0.0\" },\n });\n\n getAppAndVersionMock.mockImplementation(() => {\n throw new UnknownDAError(\"error\");\n });\n\n waitForDeviceUnlockMock.mockImplementation(\n () =>\n new Observable((o) => {\n o.complete();\n }),\n );\n\n const getDeviceStateDeviceAction = new GetDeviceStatusDeviceAction({\n input: { unlockTimeout: 500 },\n });\n\n jest\n .spyOn(getDeviceStateDeviceAction, \"extractDependencies\")\n .mockReturnValue(extractDependenciesMock());\n\n const expectedStates: Array<GetDeviceStatusDAState> = [\n {\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.UnlockDevice,\n },\n status: DeviceActionStatus.Pending,\n },\n {\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.None,\n },\n status: DeviceActionStatus.Pending,\n },\n {\n error: new UnknownDAError(\"error\"),\n status: DeviceActionStatus.Error,\n },\n ];\n\n testDeviceActionStates(\n getDeviceStateDeviceAction,\n expectedStates,\n makeDeviceActionInternalApiMock(),\n done,\n );\n });\n });\n\n it(\"should emit a stopped state if the action is cancelled\", (done) => {\n apiGetDeviceSessionStateMock.mockReturnValue({\n sessionStateType: DeviceSessionStateType.ReadyWithoutSecureChannel,\n deviceStatus: DeviceStatus.CONNECTED,\n currentApp: { name: \"mockedCurrentApp\", version: \"1.0.0\" },\n installedApps: [],\n });\n\n sendCommandMock.mockResolvedValue(\n CommandResultFactory({\n data: {\n name: \"BOLOS\",\n version: \"1.0.0\",\n },\n }),\n );\n\n const getDeviceStateDeviceAction = new GetDeviceStatusDeviceAction({\n input: { unlockTimeout: 500 },\n });\n\n const expectedStates: Array<GetDeviceStatusDAState> = [\n {\n status: DeviceActionStatus.Pending, // get app and version\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.None,\n },\n },\n {\n status: DeviceActionStatus.Stopped,\n },\n ];\n\n const { cancel } = testDeviceActionStates(\n getDeviceStateDeviceAction,\n expectedStates,\n makeDeviceActionInternalApiMock(),\n done,\n );\n cancel();\n });\n});\n"],
|
5
|
-
"mappings": "aAAA,IAAAA,EAAqC,gBAErCC,EAAqC,4CACrCC,EAGO,iDACPC,EAA6B,oCAC7BC,EAAgD,6DAChDC,EAAuC,oEACvCC,EAAmC,sDACnCC,EAAwC,4DACxCC,EAIO,wCACPC,EAAuC,kDAEvCC,EAA4C,yCAG5C,SAAS,8BAA+B,IAAM,CAC5C,MAAMC,EAAuB,KAAK,GAAG,EAC/BC,EAA4B,KAAK,GAAG,EACpCC,EAA0B,KAAK,GAAG,EAClCC,EAAwB,KAAK,GAAG,EAChCC,EAAwB,KAAK,GAAG,EAEtC,SAASC,GAA0B,CACjC,MAAO,CACL,iBAAkBL,EAClB,sBAAuBC,EACvB,oBAAqBC,EACrB,sBAAuBC,EACvB,kBAAmBC,CACrB,CACF,CAEA,KAAM,CACJ,YAAaE,EACb,sBAAuBC,EACvB,gCAAiCC,CACnC,KAAI,mCAAgC,EACpC,WAAW,IAAM,CACf,KAAK,cAAc,EACnBJ,EAAsB,gBAAgB,EAAI,CAC5C,CAAC,EAED,SAAS,2CAA4C,IAAM,CACzD,GAAG,uDAAyDK,GAAS,CACnE,MAAMC,EAA6B,IAAI,8BAA4B,CACjE,MAAO,CAAE,cAAe,GAAI,CAC9B,CAAC,EAEDH,EAA6B,gBAAgB,CAC3C,iBAAkB,yBAAuB,UACzC,aAAc,eAAa,
|
6
|
-
"names": ["import_rxjs", "import_CommandResult", "import_GlobalCommandError", "import_DeviceStatus", "import_makeInternalApi", "import_testDeviceActionStates", "import_DeviceActionState", "import_UserInteractionRequired", "import_Errors", "import_DeviceSessionState", "import_GetDeviceStatusDeviceAction", "getAppAndVersionMock", "getDeviceSessionStateMock", "waitForDeviceUnlockMock", "setDeviceSessionState", "isDeviceOnboardedMock", "extractDependenciesMock", "sendCommandMock", "apiGetDeviceSessionStateMock", "apiGetDeviceSessionStateObservableMock", "done", "getDeviceStateDeviceAction", "expectedStates", "
|
4
|
+
"sourcesContent": ["import { interval, Observable } from \"rxjs\";\n\nimport { CommandResultFactory } from \"@api/command/model/CommandResult\";\nimport {\n GLOBAL_ERRORS,\n GlobalCommandError,\n} from \"@api/command/utils/GlobalCommandError\";\nimport { DeviceModelId } from \"@api/device/DeviceModel\";\nimport { DeviceStatus } from \"@api/device/DeviceStatus\";\nimport { makeDeviceActionInternalApiMock } from \"@api/device-action/__test-utils__/makeInternalApi\";\nimport { testDeviceActionStates } from \"@api/device-action/__test-utils__/testDeviceActionStates\";\nimport { DeviceActionStatus } from \"@api/device-action/model/DeviceActionState\";\nimport { UserInteractionRequired } from \"@api/device-action/model/UserInteractionRequired\";\nimport {\n DeviceLockedError,\n DeviceNotOnboardedError,\n UnknownDAError,\n} from \"@api/device-action/os/Errors\";\nimport { DeviceSessionStateType } from \"@api/device-session/DeviceSessionState\";\n\nimport { GetDeviceStatusDeviceAction } from \"./GetDeviceStatusDeviceAction\";\nimport { type GetDeviceStatusDAState } from \"./types\";\n\ndescribe(\"GetDeviceStatusDeviceAction\", () => {\n const getAppAndVersionMock = jest.fn();\n const getDeviceSessionStateMock = jest.fn();\n const waitForDeviceUnlockMock = jest.fn();\n const setDeviceSessionState = jest.fn();\n const isDeviceOnboardedMock = jest.fn();\n\n function extractDependenciesMock() {\n return {\n getAppAndVersion: getAppAndVersionMock,\n getDeviceSessionState: getDeviceSessionStateMock,\n waitForDeviceUnlock: waitForDeviceUnlockMock,\n setDeviceSessionState: setDeviceSessionState,\n isDeviceOnboarded: isDeviceOnboardedMock,\n };\n }\n\n const {\n sendCommand: sendCommandMock,\n getDeviceSessionState: apiGetDeviceSessionStateMock,\n getDeviceSessionStateObservable: apiGetDeviceSessionStateObservableMock,\n } = makeDeviceActionInternalApiMock();\n beforeEach(() => {\n jest.resetAllMocks();\n isDeviceOnboardedMock.mockReturnValue(true);\n });\n\n describe(\"without overriding `extractDependencies`\", () => {\n it(\"should run the device action with an unlocked device\", (done) => {\n const getDeviceStateDeviceAction = new GetDeviceStatusDeviceAction({\n input: { unlockTimeout: 500 },\n });\n\n apiGetDeviceSessionStateMock.mockReturnValue({\n sessionStateType: DeviceSessionStateType.Connected,\n deviceStatus: DeviceStatus.CONNECTED,\n deviceModelId: DeviceModelId.FLEX,\n });\n\n sendCommandMock.mockResolvedValue(\n CommandResultFactory({\n data: {\n name: \"BOLOS\",\n version: \"1.0.0\",\n },\n }),\n );\n\n const expectedStates: Array<GetDeviceStatusDAState> = [\n {\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.None,\n },\n status: DeviceActionStatus.Pending,\n },\n {\n output: {\n currentApp: \"BOLOS\",\n currentAppVersion: \"1.0.0\",\n },\n status: DeviceActionStatus.Completed,\n },\n ];\n\n testDeviceActionStates(\n getDeviceStateDeviceAction,\n expectedStates,\n makeDeviceActionInternalApiMock(),\n done,\n );\n });\n\n it(\"should run the device action with a locked device\", (done) => {\n const getDeviceStateDeviceAction = new GetDeviceStatusDeviceAction({\n input: { unlockTimeout: 500 },\n });\n\n apiGetDeviceSessionStateMock.mockReturnValue({\n sessionStateType: DeviceSessionStateType.ReadyWithoutSecureChannel,\n deviceStatus: DeviceStatus.LOCKED,\n currentApp: { name: \"mockedCurrentApp\", version: \"1.0.0\" },\n installedApps: [],\n deviceModelId: DeviceModelId.FLEX,\n });\n\n apiGetDeviceSessionStateObservableMock.mockImplementation(\n () =>\n new Observable((o) => {\n const inner = interval(50).subscribe({\n next: (i) => {\n if (i > 2) {\n o.next({\n sessionStateType:\n DeviceSessionStateType.ReadyWithoutSecureChannel,\n deviceStatus: DeviceStatus.CONNECTED,\n currentApp: { name: \"mockedCurrentApp\", version: \"1.0.0\" },\n installedApps: [],\n deviceModelId: DeviceModelId.FLEX,\n });\n o.complete();\n } else {\n o.next({\n sessionStateType:\n DeviceSessionStateType.ReadyWithoutSecureChannel,\n deviceStatus: DeviceStatus.LOCKED,\n currentApp: { name: \"mockedCurrentApp\", version: \"1.0.0\" },\n installedApps: [],\n deviceModelId: DeviceModelId.FLEX,\n });\n }\n },\n });\n\n return () => {\n inner.unsubscribe();\n };\n }),\n );\n\n sendCommandMock.mockResolvedValue(\n CommandResultFactory({\n data: {\n name: \"BOLOS\",\n version: \"1.0.0\",\n },\n }),\n );\n\n const expectedStates: Array<GetDeviceStatusDAState> = [\n {\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.UnlockDevice,\n },\n status: DeviceActionStatus.Pending,\n },\n {\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.None,\n },\n status: DeviceActionStatus.Pending,\n },\n {\n output: {\n currentApp: \"BOLOS\",\n currentAppVersion: \"1.0.0\",\n },\n status: DeviceActionStatus.Completed,\n },\n ];\n\n testDeviceActionStates(\n getDeviceStateDeviceAction,\n expectedStates,\n makeDeviceActionInternalApiMock(),\n done,\n );\n });\n });\n\n describe(\"success cases\", () => {\n it(\"should return the device status if the device is unlocked\", (done) => {\n getDeviceSessionStateMock.mockReturnValue({\n sessionStateType: DeviceSessionStateType.ReadyWithoutSecureChannel,\n deviceStatus: DeviceStatus.CONNECTED,\n currentApp: { name: \"mockedCurrentApp\", version: \"1.0.0\" },\n });\n\n getAppAndVersionMock.mockResolvedValue(\n CommandResultFactory({\n data: {\n name: \"BOLOS\",\n version: \"1.0.0\",\n },\n }),\n );\n\n const getDeviceStateDeviceAction = new GetDeviceStatusDeviceAction({\n input: { unlockTimeout: undefined },\n });\n\n jest\n .spyOn(getDeviceStateDeviceAction, \"extractDependencies\")\n .mockReturnValue(extractDependenciesMock());\n\n const expectedStates: Array<GetDeviceStatusDAState> = [\n {\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.None,\n },\n status: DeviceActionStatus.Pending,\n },\n {\n status: DeviceActionStatus.Completed,\n output: {\n currentApp: \"BOLOS\",\n currentAppVersion: \"1.0.0\",\n },\n },\n ];\n\n testDeviceActionStates(\n getDeviceStateDeviceAction,\n expectedStates,\n makeDeviceActionInternalApiMock(),\n done,\n );\n });\n\n it(\"should return the device status if the device is locked and the user unlocks the device\", (done) => {\n getDeviceSessionStateMock.mockReturnValue({\n sessionStateType: DeviceSessionStateType.ReadyWithoutSecureChannel,\n deviceStatus: DeviceStatus.LOCKED,\n currentApp: { name: \"mockedCurrentApp\", version: \"1.0.0\" },\n });\n\n getAppAndVersionMock.mockResolvedValue(\n CommandResultFactory({\n data: {\n name: \"BOLOS\",\n version: \"1.0.0\",\n },\n }),\n );\n\n waitForDeviceUnlockMock.mockImplementation(\n () =>\n new Observable((o) => {\n const inner = interval(50).subscribe({\n next: (i) => {\n if (i > 2) {\n o.next({\n sessionStateType:\n DeviceSessionStateType.ReadyWithoutSecureChannel,\n deviceStatus: DeviceStatus.CONNECTED,\n currentApp: { name: \"mockedCurrentApp\", version: \"1.0.0\" },\n });\n o.complete();\n } else {\n o.next({\n sessionStateType:\n DeviceSessionStateType.ReadyWithoutSecureChannel,\n deviceStatus: DeviceStatus.LOCKED,\n currentApp: { name: \"mockedCurrentApp\", version: \"1.0.0\" },\n });\n }\n },\n });\n\n return () => {\n inner.unsubscribe();\n };\n }),\n );\n\n const getDeviceStateDeviceAction = new GetDeviceStatusDeviceAction({\n input: { unlockTimeout: 500 },\n });\n\n jest\n .spyOn(getDeviceStateDeviceAction, \"extractDependencies\")\n .mockReturnValue(extractDependenciesMock());\n\n const expectedStates: Array<GetDeviceStatusDAState> = [\n {\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.UnlockDevice,\n },\n status: DeviceActionStatus.Pending,\n },\n {\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.None,\n },\n status: DeviceActionStatus.Pending,\n },\n {\n status: DeviceActionStatus.Completed,\n output: {\n currentApp: \"BOLOS\",\n currentAppVersion: \"1.0.0\",\n },\n },\n ];\n\n testDeviceActionStates(\n getDeviceStateDeviceAction,\n expectedStates,\n makeDeviceActionInternalApiMock(),\n done,\n );\n });\n });\n\n describe(\"errors cases\", () => {\n it(\"should end in an error if the device is not onboarded\", (done) => {\n getDeviceSessionStateMock.mockReturnValue({\n sessionStateType: DeviceSessionStateType.ReadyWithoutSecureChannel,\n deviceStatus: DeviceStatus.LOCKED,\n currentApp: { name: \"mockedCurrentApp\", version: \"1.0.0\" },\n });\n isDeviceOnboardedMock.mockReturnValue(false);\n\n const getDeviceStateDeviceAction = new GetDeviceStatusDeviceAction({\n input: { unlockTimeout: 500 },\n });\n\n jest\n .spyOn(getDeviceStateDeviceAction, \"extractDependencies\")\n .mockReturnValue(extractDependenciesMock());\n\n const expectedStates: Array<GetDeviceStatusDAState> = [\n {\n error: new DeviceNotOnboardedError(),\n status: DeviceActionStatus.Error,\n },\n ];\n\n testDeviceActionStates(\n getDeviceStateDeviceAction,\n expectedStates,\n makeDeviceActionInternalApiMock(),\n done,\n );\n });\n\n it(\"should end in an error if the device is locked and the user does not unlock\", (done) => {\n getDeviceSessionStateMock.mockReturnValue({\n sessionStateType: DeviceSessionStateType.ReadyWithoutSecureChannel,\n deviceStatus: DeviceStatus.LOCKED,\n currentApp: { name: \"mockedCurrentApp\", version: \"1.0.0\" },\n });\n\n apiGetDeviceSessionStateObservableMock.mockImplementation(\n () =>\n new Observable((o) => {\n const inner = interval(200).subscribe({\n next: () => {\n o.next({\n sessionStateType:\n DeviceSessionStateType.ReadyWithoutSecureChannel,\n deviceStatus: DeviceStatus.LOCKED,\n currentApp: { name: \"mockedCurrentApp\", version: \"1.0.0\" },\n installedApps: [],\n deviceModelId: DeviceModelId.FLEX,\n });\n },\n });\n\n return () => {\n inner.unsubscribe();\n };\n }),\n );\n\n const getDeviceStateDeviceAction = new GetDeviceStatusDeviceAction({\n input: { unlockTimeout: 500 },\n });\n\n jest\n .spyOn(getDeviceStateDeviceAction, \"extractDependencies\")\n .mockReturnValue(extractDependenciesMock());\n\n const expectedStates: Array<GetDeviceStatusDAState> = [\n {\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.UnlockDevice,\n },\n status: DeviceActionStatus.Pending,\n },\n {\n error: new DeviceLockedError(\"Device locked.\"),\n status: DeviceActionStatus.Error,\n },\n ];\n\n testDeviceActionStates(\n getDeviceStateDeviceAction,\n expectedStates,\n makeDeviceActionInternalApiMock(),\n done,\n );\n });\n\n it(\"should end in an error if the GetAppAndVersion command fails\", (done) => {\n getDeviceSessionStateMock.mockReturnValue({\n sessionStateType: DeviceSessionStateType.ReadyWithoutSecureChannel,\n deviceStatus: DeviceStatus.LOCKED,\n currentApp: { name: \"mockedCurrentApp\", version: \"1.0.0\" },\n });\n\n const error = new GlobalCommandError({\n ...GLOBAL_ERRORS[\"5501\"],\n errorCode: \"5501\",\n });\n\n getAppAndVersionMock.mockResolvedValue(CommandResultFactory({ error }));\n\n waitForDeviceUnlockMock.mockImplementation(\n () =>\n new Observable((o) => {\n const inner = interval(50).subscribe({\n next: (i) => {\n if (i > 2) {\n o.next({\n sessionStateType:\n DeviceSessionStateType.ReadyWithoutSecureChannel,\n deviceStatus: DeviceStatus.CONNECTED,\n currentApp: { name: \"mockedCurrentApp\", version: \"1.0.0\" },\n });\n o.complete();\n } else {\n o.next({\n sessionStateType:\n DeviceSessionStateType.ReadyWithoutSecureChannel,\n deviceStatus: DeviceStatus.LOCKED,\n currentApp: { name: \"mockedCurrentApp\", version: \"1.0.0\" },\n });\n }\n },\n });\n\n return () => {\n inner.unsubscribe();\n };\n }),\n );\n\n const getDeviceStateDeviceAction = new GetDeviceStatusDeviceAction({\n input: { unlockTimeout: 500 },\n });\n\n jest\n .spyOn(getDeviceStateDeviceAction, \"extractDependencies\")\n .mockReturnValue(extractDependenciesMock());\n\n const expectedStates: Array<GetDeviceStatusDAState> = [\n {\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.UnlockDevice,\n },\n status: DeviceActionStatus.Pending,\n },\n {\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.None,\n },\n status: DeviceActionStatus.Pending,\n },\n {\n error,\n status: DeviceActionStatus.Error,\n },\n ];\n\n testDeviceActionStates(\n getDeviceStateDeviceAction,\n expectedStates,\n makeDeviceActionInternalApiMock(),\n done,\n );\n });\n\n it(\"should end in an error if getAppAndVersion actor throws an error\", (done) => {\n getDeviceSessionStateMock.mockReturnValue({\n sessionStateType: DeviceSessionStateType.ReadyWithoutSecureChannel,\n deviceStatus: DeviceStatus.LOCKED,\n currentApp: { name: \"mockedCurrentApp\", version: \"1.0.0\" },\n });\n\n getAppAndVersionMock.mockImplementation(() => {\n throw new UnknownDAError(\"error\");\n });\n\n waitForDeviceUnlockMock.mockImplementation(\n () =>\n new Observable((o) => {\n o.complete();\n }),\n );\n\n const getDeviceStateDeviceAction = new GetDeviceStatusDeviceAction({\n input: { unlockTimeout: 500 },\n });\n\n jest\n .spyOn(getDeviceStateDeviceAction, \"extractDependencies\")\n .mockReturnValue(extractDependenciesMock());\n\n const expectedStates: Array<GetDeviceStatusDAState> = [\n {\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.UnlockDevice,\n },\n status: DeviceActionStatus.Pending,\n },\n {\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.None,\n },\n status: DeviceActionStatus.Pending,\n },\n {\n error: new UnknownDAError(\"error\"),\n status: DeviceActionStatus.Error,\n },\n ];\n\n testDeviceActionStates(\n getDeviceStateDeviceAction,\n expectedStates,\n makeDeviceActionInternalApiMock(),\n done,\n );\n });\n });\n\n it(\"should emit a stopped state if the action is cancelled\", (done) => {\n apiGetDeviceSessionStateMock.mockReturnValue({\n sessionStateType: DeviceSessionStateType.ReadyWithoutSecureChannel,\n deviceStatus: DeviceStatus.CONNECTED,\n currentApp: { name: \"mockedCurrentApp\", version: \"1.0.0\" },\n installedApps: [],\n deviceModelId: DeviceModelId.FLEX,\n });\n\n sendCommandMock.mockResolvedValue(\n CommandResultFactory({\n data: {\n name: \"BOLOS\",\n version: \"1.0.0\",\n },\n }),\n );\n\n const getDeviceStateDeviceAction = new GetDeviceStatusDeviceAction({\n input: { unlockTimeout: 500 },\n });\n\n const expectedStates: Array<GetDeviceStatusDAState> = [\n {\n status: DeviceActionStatus.Pending, // get app and version\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.None,\n },\n },\n {\n status: DeviceActionStatus.Stopped,\n },\n ];\n\n const { cancel } = testDeviceActionStates(\n getDeviceStateDeviceAction,\n expectedStates,\n makeDeviceActionInternalApiMock(),\n done,\n );\n cancel();\n });\n});\n"],
|
5
|
+
"mappings": "aAAA,IAAAA,EAAqC,gBAErCC,EAAqC,4CACrCC,EAGO,iDACPC,EAA8B,mCAC9BC,EAA6B,oCAC7BC,EAAgD,6DAChDC,EAAuC,oEACvCC,EAAmC,sDACnCC,EAAwC,4DACxCC,EAIO,wCACPC,EAAuC,kDAEvCC,EAA4C,yCAG5C,SAAS,8BAA+B,IAAM,CAC5C,MAAMC,EAAuB,KAAK,GAAG,EAC/BC,EAA4B,KAAK,GAAG,EACpCC,EAA0B,KAAK,GAAG,EAClCC,EAAwB,KAAK,GAAG,EAChCC,EAAwB,KAAK,GAAG,EAEtC,SAASC,GAA0B,CACjC,MAAO,CACL,iBAAkBL,EAClB,sBAAuBC,EACvB,oBAAqBC,EACrB,sBAAuBC,EACvB,kBAAmBC,CACrB,CACF,CAEA,KAAM,CACJ,YAAaE,EACb,sBAAuBC,EACvB,gCAAiCC,CACnC,KAAI,mCAAgC,EACpC,WAAW,IAAM,CACf,KAAK,cAAc,EACnBJ,EAAsB,gBAAgB,EAAI,CAC5C,CAAC,EAED,SAAS,2CAA4C,IAAM,CACzD,GAAG,uDAAyDK,GAAS,CACnE,MAAMC,EAA6B,IAAI,8BAA4B,CACjE,MAAO,CAAE,cAAe,GAAI,CAC9B,CAAC,EAEDH,EAA6B,gBAAgB,CAC3C,iBAAkB,yBAAuB,UACzC,aAAc,eAAa,UAC3B,cAAe,gBAAc,IAC/B,CAAC,EAEDD,EAAgB,qBACd,wBAAqB,CACnB,KAAM,CACJ,KAAM,QACN,QAAS,OACX,CACF,CAAC,CACH,EAEA,MAAMK,EAAgD,CACpD,CACE,kBAAmB,CACjB,wBAAyB,0BAAwB,IACnD,EACA,OAAQ,qBAAmB,OAC7B,EACA,CACE,OAAQ,C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IACnD,EACA,OAAQ,qBAAmB,OAC7B,EACA,CACE,MAAO,IAAI,iBAAe,OAAO,EACjC,OAAQ,qBAAmB,KAC7B,CACF,KAEA,0BACED,EACAC,KACA,mCAAgC,EAChCF,CACF,CACF,CAAC,CACH,CAAC,EAED,GAAG,yDAA2DA,GAAS,CACrEF,EAA6B,gBAAgB,CAC3C,iBAAkB,yBAAuB,0BACzC,aAAc,eAAa,UAC3B,WAAY,CAAE,KAAM,mBAAoB,QAAS,OAAQ,EACzD,cAAe,CAAC,EAChB,cAAe,gBAAc,IAC/B,CAAC,EAEDD,EAAgB,qBACd,wBAAqB,CACnB,KAAM,CACJ,KAAM,QACN,QAAS,OACX,CACF,CAAC,CACH,EAEA,MAAMI,EAA6B,IAAI,8BAA4B,CACjE,MAAO,CAAE,cAAe,GAAI,CAC9B,CAAC,EAEKC,EAAgD,CACpD,CACE,OAAQ,qBAAmB,QAC3B,kBAAmB,CACjB,wBAAyB,0BAAwB,IACnD,CACF,EACA,CACE,OAAQ,qBAAmB,OAC7B,CACF,EAEM,CAAE,OAAAK,CAAO,KAAI,0BACjBN,EACAC,KACA,mCAAgC,EAChCF,CACF,EACAO,EAAO,CACT,CAAC,CACH,CAAC",
|
6
|
+
"names": ["import_rxjs", "import_CommandResult", "import_GlobalCommandError", "import_DeviceModel", "import_DeviceStatus", "import_makeInternalApi", "import_testDeviceActionStates", "import_DeviceActionState", "import_UserInteractionRequired", "import_Errors", "import_DeviceSessionState", "import_GetDeviceStatusDeviceAction", "getAppAndVersionMock", "getDeviceSessionStateMock", "waitForDeviceUnlockMock", "setDeviceSessionState", "isDeviceOnboardedMock", "extractDependenciesMock", "sendCommandMock", "apiGetDeviceSessionStateMock", "apiGetDeviceSessionStateObservableMock", "done", "getDeviceStateDeviceAction", "expectedStates", "o", "inner", "i", "error", "cancel"]
|
7
7
|
}
|
@@ -1,2 +1,2 @@
|
|
1
|
-
"use strict";var i=require("../../../command/model/CommandResult"),
|
1
|
+
"use strict";var i=require("../../../command/model/CommandResult"),V=require("../../../command/utils/GlobalCommandError"),S=require("../../../device/DeviceModel"),s=require("../../../device/DeviceStatus"),a=require("../../../device-action/__test-utils__/makeInternalApi"),c=require("../../../device-action/__test-utils__/setupTestMachine"),u=require("../../../device-action/__test-utils__/testDeviceActionStates"),e=require("../../../device-action/model/DeviceActionState"),t=require("../../../device-action/model/UserInteractionRequired"),v=require("../../../device-action/os/Errors"),d=require("../../../device-session/DeviceSessionState"),k=require("../../../../../src"),p=require("./GoToDashboardDeviceAction");jest.mock("@api/device-action/os/GetDeviceStatus/GetDeviceStatusDeviceAction");describe("GoToDashboardDeviceAction",()=>{const m=jest.fn(),D=jest.fn(),l=jest.fn(),N=jest.fn();function A(){return{closeApp:m,getAppAndVersion:D,getDeviceSessionState:l,setDeviceSessionState:N}}const{sendCommand:T,getDeviceSessionState:h}=(0,a.makeDeviceActionInternalApiMock)();beforeEach(()=>{jest.resetAllMocks()}),describe("without overriding `extractDependencies`",()=>{it("should run the device action with device already on dashboard",o=>{(0,c.setupGetDeviceStatusMock)();const n=new p.GoToDashboardDeviceAction({input:{unlockTimeout:500}});h.mockReturnValue({sessionStateType:d.DeviceSessionStateType.ReadyWithoutSecureChannel,deviceStatus:s.DeviceStatus.CONNECTED,currentApp:{name:"BOLOS",version:"1.5.0"},installedApps:[],deviceModelId:S.DeviceModelId.NANO_X});const r=[{intermediateValue:{requiredUserInteraction:t.UserInteractionRequired.None},status:e.DeviceActionStatus.Pending},{intermediateValue:{requiredUserInteraction:t.UserInteractionRequired.None},status:e.DeviceActionStatus.Pending},{output:void 0,status:e.DeviceActionStatus.Completed}];(0,u.testDeviceActionStates)(n,r,(0,a.makeDeviceActionInternalApiMock)(),o)}),it("should run the device action with device not on dashboard",o=>{(0,c.setupGetDeviceStatusMock)([{currentApp:"Bitcoin",currentAppVersion:"1.0.0"}]);const n=new p.GoToDashboardDeviceAction({input:{unlockTimeout:500}});h.mockReturnValue({sessionStateType:d.DeviceSessionStateType.ReadyWithoutSecureChannel,deviceStatus:s.DeviceStatus.CONNECTED,currentApp:{name:"Bitcoin",version:"1.0.0"},installedApps:[],deviceModelId:S.DeviceModelId.NANO_X}),T.mockResolvedValueOnce((0,i.CommandResultFactory)({data:void 0})).mockResolvedValueOnce((0,i.CommandResultFactory)({data:{name:"BOLOS",version:"1.5.0"}}));const r=[{intermediateValue:{requiredUserInteraction:t.UserInteractionRequired.None},status:e.DeviceActionStatus.Pending},{intermediateValue:{requiredUserInteraction:t.UserInteractionRequired.None},status:e.DeviceActionStatus.Pending},{intermediateValue:{requiredUserInteraction:t.UserInteractionRequired.None},status:e.DeviceActionStatus.Pending},{intermediateValue:{requiredUserInteraction:t.UserInteractionRequired.None},status:e.DeviceActionStatus.Pending},{output:void 0,status:e.DeviceActionStatus.Completed}];(0,u.testDeviceActionStates)(n,r,(0,a.makeDeviceActionInternalApiMock)(),o)})}),describe("success cases",()=>{it("should success if the device is already on dashboard",o=>{(0,c.setupGetDeviceStatusMock)();const n=new p.GoToDashboardDeviceAction({input:{unlockTimeout:500}});l.mockReturnValue({sessionStateType:d.DeviceSessionStateType.Connected,deviceStatus:s.DeviceStatus.CONNECTED,currentApp:{name:"BOLOS",version:"1.5.0"}}),D.mockReturnValue({app:"BOLOS",version:"1.5.0"}),jest.spyOn(n,"extractDependencies").mockReturnValue(A());const r=[{intermediateValue:{requiredUserInteraction:t.UserInteractionRequired.None},status:e.DeviceActionStatus.Pending},{intermediateValue:{requiredUserInteraction:t.UserInteractionRequired.None},status:e.DeviceActionStatus.Pending},{output:void 0,status:e.DeviceActionStatus.Completed}];(0,u.testDeviceActionStates)(n,r,(0,a.makeDeviceActionInternalApiMock)(),o)}),it("should success if the device is not on dashboard",o=>{(0,c.setupGetDeviceStatusMock)();const n=new p.GoToDashboardDeviceAction({input:{unlockTimeout:500}});jest.spyOn(n,"extractDependencies").mockReturnValue(A()),l.mockReturnValue({sessionStateType:d.DeviceSessionStateType.Connected,deviceStatus:s.DeviceStatus.CONNECTED}),m.mockResolvedValue((0,i.CommandResultFactory)({data:void 0})),D.mockReturnValue((0,i.CommandResultFactory)({data:{name:"BOLOS",version:"1.5.0"}}));const r=[{intermediateValue:{requiredUserInteraction:t.UserInteractionRequired.None},status:e.DeviceActionStatus.Pending},{intermediateValue:{requiredUserInteraction:t.UserInteractionRequired.None},status:e.DeviceActionStatus.Pending},{output:void 0,status:e.DeviceActionStatus.Completed}];(0,u.testDeviceActionStates)(n,r,(0,a.makeDeviceActionInternalApiMock)(),o)})}),describe("error cases",()=>{it("should return an error if GetDeviceStatus return an error",o=>{(0,c.setupGetDeviceStatusMock)([new v.UnknownDAError("Unknown error")]);const n=new p.GoToDashboardDeviceAction({input:{unlockTimeout:500}});h.mockReturnValue({sessionStateType:d.DeviceSessionStateType.ReadyWithoutSecureChannel,deviceStatus:s.DeviceStatus.CONNECTED,currentApp:{name:"BOLOS",version:"1.5.0"},installedApps:[],deviceModelId:S.DeviceModelId.NANO_X});const r=[{intermediateValue:{requiredUserInteraction:t.UserInteractionRequired.None},status:e.DeviceActionStatus.Pending},{intermediateValue:{requiredUserInteraction:t.UserInteractionRequired.None},status:e.DeviceActionStatus.Pending},{status:e.DeviceActionStatus.Error,error:new v.UnknownDAError("Unknown error")}];(0,u.testDeviceActionStates)(n,r,(0,a.makeDeviceActionInternalApiMock)(),o)}),describe("not on dashboard",()=>{it("should return an error if closeApp fails",o=>{(0,c.setupGetDeviceStatusMock)([{currentApp:"Bitcoin",currentAppVersion:"1.0.0"}]);const n=new p.GoToDashboardDeviceAction({input:{}});jest.spyOn(n,"extractDependencies").mockReturnValue(A()),l.mockReturnValue({sessionStateType:d.DeviceSessionStateType.Connected,deviceStatus:s.DeviceStatus.CONNECTED,currentApp:"Bitcoin"}),m.mockReturnValue((0,i.CommandResultFactory)({error:new k.UnknownDeviceExchangeError("Close app failed")}));const r=[{intermediateValue:{requiredUserInteraction:t.UserInteractionRequired.None},status:e.DeviceActionStatus.Pending},{intermediateValue:{requiredUserInteraction:t.UserInteractionRequired.None},status:e.DeviceActionStatus.Pending},{intermediateValue:{requiredUserInteraction:t.UserInteractionRequired.None},status:e.DeviceActionStatus.Pending},{status:e.DeviceActionStatus.Error,error:new k.UnknownDeviceExchangeError("Close app failed")}];(0,u.testDeviceActionStates)(n,r,(0,a.makeDeviceActionInternalApiMock)(),o)}),it("should return an error if getAppAndVersion fails",o=>{(0,c.setupGetDeviceStatusMock)([{currentApp:"Bitcoin",currentAppVersion:"1.0.0"}]);const n=new p.GoToDashboardDeviceAction({input:{unlockTimeout:500}}),r=new V.GlobalCommandError({...V.GLOBAL_ERRORS[5501],errorCode:"5501"});jest.spyOn(n,"extractDependencies").mockReturnValue(A()),l.mockReturnValue({sessionStateType:d.DeviceSessionStateType.Connected,deviceStatus:s.DeviceStatus.CONNECTED,currentApp:"Bitcoin"}),m.mockResolvedValue((0,i.CommandResultFactory)({data:void 0})),D.mockResolvedValue((0,i.CommandResultFactory)({error:r}));const g=[{intermediateValue:{requiredUserInteraction:t.UserInteractionRequired.None},status:e.DeviceActionStatus.Pending},{intermediateValue:{requiredUserInteraction:t.UserInteractionRequired.None},status:e.DeviceActionStatus.Pending},{intermediateValue:{requiredUserInteraction:t.UserInteractionRequired.None},status:e.DeviceActionStatus.Pending},{intermediateValue:{requiredUserInteraction:t.UserInteractionRequired.None},status:e.DeviceActionStatus.Pending},{status:e.DeviceActionStatus.Error,error:r}];(0,u.testDeviceActionStates)(n,g,(0,a.makeDeviceActionInternalApiMock)(),o)}),it("should return an error if getAppAndVersion does not return an app name",o=>{(0,c.setupGetDeviceStatusMock)([{currentApp:"Bitcoin",currentAppVersion:"1.0.0"}]);const n=new p.GoToDashboardDeviceAction({input:{unlockTimeout:500}});jest.spyOn(n,"extractDependencies").mockReturnValue(A()),l.mockReturnValue({sessionStateType:d.DeviceSessionStateType.Connected,deviceStatus:s.DeviceStatus.CONNECTED,currentApp:"Bitcoin"}),m.mockResolvedValue((0,i.CommandResultFactory)({data:void 0})),D.mockResolvedValue((0,i.CommandResultFactory)({data:{name:null,version:"1.0.0"}}));const r=[{intermediateValue:{requiredUserInteraction:t.UserInteractionRequired.None},status:e.DeviceActionStatus.Pending},{intermediateValue:{requiredUserInteraction:t.UserInteractionRequired.None},status:e.DeviceActionStatus.Pending},{intermediateValue:{requiredUserInteraction:t.UserInteractionRequired.None},status:e.DeviceActionStatus.Pending},{intermediateValue:{requiredUserInteraction:t.UserInteractionRequired.None},status:e.DeviceActionStatus.Pending},{status:e.DeviceActionStatus.Error,error:new v.UnknownDAError("currentApp === null")}];(0,u.testDeviceActionStates)(n,r,(0,a.makeDeviceActionInternalApiMock)(),o)})})})});
|
2
2
|
//# sourceMappingURL=GoToDashboardDeviceAction.test.js.map
|