@ledgerhq/device-management-kit 0.0.0-develop-20260618004058 → 0.0.0-develop-20260620003450

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.
Files changed (26) hide show
  1. package/lib/cjs/package.json +1 -1
  2. package/lib/cjs/src/api/device-action/__test-utils__/setupTestMachine.js +1 -1
  3. package/lib/cjs/src/api/device-action/__test-utils__/setupTestMachine.js.map +3 -3
  4. package/lib/cjs/src/api/device-action/os/GetDeviceStatus/GetDeviceStatusDeviceAction.js +1 -1
  5. package/lib/cjs/src/api/device-action/os/GetDeviceStatus/GetDeviceStatusDeviceAction.js.map +3 -3
  6. package/lib/cjs/src/api/device-action/os/GetDeviceStatus/GetDeviceStatusDeviceAction.test.js +1 -1
  7. package/lib/cjs/src/api/device-action/os/GetDeviceStatus/GetDeviceStatusDeviceAction.test.js.map +3 -3
  8. package/lib/cjs/src/api/device-action/os/GetDeviceStatus/types.js +1 -1
  9. package/lib/cjs/src/api/device-action/os/GetDeviceStatus/types.js.map +2 -2
  10. package/lib/esm/package.json +1 -1
  11. package/lib/esm/src/api/device-action/__test-utils__/setupTestMachine.js +1 -1
  12. package/lib/esm/src/api/device-action/__test-utils__/setupTestMachine.js.map +3 -3
  13. package/lib/esm/src/api/device-action/os/GetDeviceStatus/GetDeviceStatusDeviceAction.js +1 -1
  14. package/lib/esm/src/api/device-action/os/GetDeviceStatus/GetDeviceStatusDeviceAction.js.map +3 -3
  15. package/lib/esm/src/api/device-action/os/GetDeviceStatus/GetDeviceStatusDeviceAction.test.js +1 -1
  16. package/lib/esm/src/api/device-action/os/GetDeviceStatus/GetDeviceStatusDeviceAction.test.js.map +3 -3
  17. package/lib/esm/src/api/device-action/os/GetDeviceStatus/types.js +1 -1
  18. package/lib/esm/src/api/device-action/os/GetDeviceStatus/types.js.map +2 -2
  19. package/lib/types/src/api/device-action/__test-utils__/setupTestMachine.d.ts +3 -0
  20. package/lib/types/src/api/device-action/__test-utils__/setupTestMachine.d.ts.map +1 -1
  21. package/lib/types/src/api/device-action/os/GetDeviceStatus/GetDeviceStatusDeviceAction.d.ts +0 -9
  22. package/lib/types/src/api/device-action/os/GetDeviceStatus/GetDeviceStatusDeviceAction.d.ts.map +1 -1
  23. package/lib/types/src/api/device-action/os/GetDeviceStatus/types.d.ts +4 -4
  24. package/lib/types/src/api/device-action/os/GetDeviceStatus/types.d.ts.map +1 -1
  25. package/lib/types/tsconfig.prod.tsbuildinfo +1 -1
  26. package/package.json +1 -1
@@ -62,5 +62,5 @@
62
62
  "watch:builds": "pnpm ldmk-tool watch --entryPoints index.ts,src/**/*.ts --tsconfig tsconfig.prod.json",
63
63
  "watch:types": "concurrently \"tsc --watch -p tsconfig.prod.json\" \"tsc-alias --watch -p tsconfig.prod.json\""
64
64
  },
65
- "version": "0.0.0-develop-20260618004058"
65
+ "version": "0.0.0-develop-20260620003450"
66
66
  }
@@ -1,2 +1,2 @@
1
- "use strict";var m=Object.defineProperty;var S=Object.getOwnPropertyDescriptor;var O=Object.getOwnPropertyNames;var U=Object.prototype.hasOwnProperty;var T=(e,t)=>{for(var o in t)m(e,o,{get:t[o],enumerable:!0})},G=(e,t,o,s)=>{if(t&&typeof t=="object"||typeof t=="function")for(let p of O(t))!U.call(e,p)&&p!==o&&m(e,p,{get:()=>t[p],enumerable:!(s=S(t,p))||s.enumerable});return e};var E=e=>G(m({},"__esModule",{value:!0}),e);var q={};T(q,{setupGetDeviceMetadataMock:()=>V,setupGetDeviceStatusMock:()=>b,setupGoToDashboardMock:()=>C,setupInstallOrUpdateAppsMock:()=>L,setupListAppsMock:()=>h,setupListInstalledAppsMock:()=>g,setupOpenAppMock:()=>_});module.exports=E(q);var a=require("purify-ts"),n=require("xstate"),i=require("../../device-action/model/UserInteractionRequired"),r=require("../../device-action/os/Errors"),c=require("../../device-action/os/GetDeviceMetadata/GetDeviceMetadataDeviceAction"),d=require("../../device-action/os/GetDeviceMetadata/types"),l=require("../../device-action/os/GetDeviceStatus/GetDeviceStatusDeviceAction"),A=require("../../device-action/os/GetDeviceStatus/types"),u=require("../../device-action/os/GoToDashboard/GoToDashboardDeviceAction"),f=require("../../device-action/os/GoToDashboard/types"),k=require("../../device-action/os/InstallOrUpdateApps/InstallOrUpdateAppsDeviceAction"),D=require("../../device-action/os/ListApps/ListAppsDeviceAction"),I=require("../../device-action/os/ListApps/types"),y=require("../../device-action/os/OpenAppDeviceAction/OpenAppDeviceAction"),M=require("../../device-action/os/OpenAppDeviceAction/types"),v=require("../../secure-channel/device-action/ListInstalledApps/ListInstalledAppsDeviceAction");const h=(e,t=!1)=>{D.ListAppsDeviceAction.mockImplementation(()=>({makeStateMachine:vi.fn().mockImplementation(()=>(0,n.createMachine)({id:"MockListAppsDeviceAction",initial:"ready",states:{ready:{after:{0:"done"},entry:(0,n.assign)({intermediateValue:()=>({requiredUserInteraction:i.UserInteractionRequired.AllowListApps,step:I.listAppsDAStateStep.LIST_APPS})})},done:{type:"final"}},output:()=>t?(0,a.Left)(new r.UnknownDAError("ListApps failed")):(0,a.Right)(e)}))}))},V=(e,t=!1)=>{c.GetDeviceMetadataDeviceAction.mockImplementation(()=>({makeStateMachine:vi.fn().mockImplementation(()=>(0,n.createMachine)({id:"MockGetDeviceMetadataDeviceAction",initial:"ready",states:{ready:{after:{0:"done"},entry:(0,n.assign)({intermediateValue:()=>({requiredUserInteraction:i.UserInteractionRequired.None,step:d.getDeviceMetadataDAStateStep.GET_DEVICE_METADATA})})},done:{type:"final"}},output:()=>t?(0,a.Left)(new r.UnknownDAError("GetDeviceMetadata failed")):(0,a.Right)(e)}))}))},L=(e,t,o=!1)=>{k.InstallOrUpdateAppsDeviceAction.mockImplementation(()=>({makeStateMachine:vi.fn().mockImplementation(()=>(0,n.createMachine)({id:"MockInstallOrUpdateAppsDeviceAction",initial:"ready",states:{ready:{after:{0:"done"},entry:(0,n.assign)({intermediateValue:()=>t})},done:{type:"final"}},output:()=>o?(0,a.Left)(new r.UnknownDAError("InstallOrUpdateApps failed")):(0,a.Right)(e)}))}))},_=(e=!1)=>{y.OpenAppDeviceAction.mockImplementation(()=>({makeStateMachine:vi.fn().mockImplementation(()=>(0,n.createMachine)({initial:"ready",states:{ready:{entry:(0,n.assign)({intermediateValue:{requiredUserInteraction:i.UserInteractionRequired.ConfirmOpenApp,step:M.openAppDAStateStep.GET_DEVICE_STATUS}}),after:{0:"done"}},done:{type:"final"}},output:()=>e?(0,a.Left)(new r.UnknownDAError("OpenApp failed")):(0,a.Right)(void 0)}))}))},C=(e=!1)=>{u.GoToDashboardDeviceAction.mockImplementation(()=>({makeStateMachine:vi.fn().mockImplementation(()=>(0,n.createMachine)({id:"MockGoToDashboardDeviceAction",initial:"ready",states:{ready:{after:{0:"done"},entry:(0,n.assign)({intermediateValue:()=>({requiredUserInteraction:i.UserInteractionRequired.None,step:f.goToDashboardDAStateStep.GET_DEVICE_STATUS})})},done:{type:"final"}},output:()=>e?(0,a.Left)(new r.UnknownDAError("GoToDashboard failed")):(0,a.Right)(void 0)}))}))},b=(e=[{currentApp:"BOLOS",currentAppVersion:"1.0.0"}])=>{const t=vi.fn();for(const o of e)t.mockImplementationOnce(()=>"currentApp"in o?(0,a.Right)(o):(0,a.Left)(o));l.GetDeviceStatusDeviceAction.mockImplementation(()=>({makeStateMachine:vi.fn().mockImplementation(()=>(0,n.createMachine)({id:"MockGetDeviceStatusDeviceAction",initial:"ready",states:{ready:{after:{0:"done"},entry:(0,n.assign)({intermediateValue:()=>({requiredUserInteraction:i.UserInteractionRequired.None,step:A.getDeviceStatusDAStateStep.ONBOARD_CHECK})})},done:{type:"final"}},output:t}))}))},g=(e=[])=>{v.ListInstalledAppsDeviceAction.mockImplementation(()=>({makeStateMachine:vi.fn().mockImplementation(()=>(0,n.createMachine)({id:"MockListInstalledAppsDeviceAction",initial:"ready",states:{ready:{after:{0:"done"},entry:(0,n.assign)({intermediateValue:()=>({requiredUserInteraction:i.UserInteractionRequired.None})})},done:{type:"final"}},output:e.reduce((t,o)=>t.mockImplementationOnce(()=>"installedApps"in o?(0,a.Right)(o):(0,a.Left)(o)),vi.fn()).mockImplementation(()=>(0,a.Right)([]))}))}))};0&&(module.exports={setupGetDeviceMetadataMock,setupGetDeviceStatusMock,setupGoToDashboardMock,setupInstallOrUpdateAppsMock,setupListAppsMock,setupListInstalledAppsMock,setupOpenAppMock});
1
+ "use strict";var s=Object.defineProperty;var V=Object.getOwnPropertyDescriptor;var E=Object.getOwnPropertyNames;var G=Object.prototype.hasOwnProperty;var U=(e,t)=>{for(var a in t)s(e,a,{get:t[a],enumerable:!0})},T=(e,t,a,c)=>{if(t&&typeof t=="object"||typeof t=="function")for(let p of E(t))!G.call(e,p)&&p!==a&&s(e,p,{get:()=>t[p],enumerable:!(c=V(t,p))||c.enumerable});return e};var _=e=>T(s({},"__esModule",{value:!0}),e);var g={};U(g,{setupGetDeviceMetadataMock:()=>L,setupGetDeviceStatusMock:()=>w,setupGoToDashboardMock:()=>q,setupInstallOrUpdateAppsMock:()=>N,setupListAppsMock:()=>h,setupListInstalledAppsMock:()=>x,setupOpenAppMock:()=>P,setupWaitForAppAndVersionMock:()=>R});module.exports=_(g);var n=require("purify-ts"),o=require("xstate"),i=require("../../device-action/model/UserInteractionRequired"),r=require("../../device-action/os/Errors"),d=require("../../device-action/os/GetDeviceMetadata/GetDeviceMetadataDeviceAction"),l=require("../../device-action/os/GetDeviceMetadata/types"),A=require("../../device-action/os/GetDeviceStatus/GetDeviceStatusDeviceAction"),f=require("../../device-action/os/GetDeviceStatus/types"),u=require("../../device-action/os/GoToDashboard/GoToDashboardDeviceAction"),k=require("../../device-action/os/GoToDashboard/types"),D=require("../../device-action/os/InstallOrUpdateApps/InstallOrUpdateAppsDeviceAction"),I=require("../../device-action/os/ListApps/ListAppsDeviceAction"),y=require("../../device-action/os/ListApps/types"),M=require("../../device-action/os/OpenAppDeviceAction/OpenAppDeviceAction"),v=require("../../device-action/os/OpenAppDeviceAction/types"),m=require("../../device-action/os/WaitForAppAndVersion/types"),S=require("../../device-action/os/WaitForAppAndVersion/WaitForAppAndVersionDeviceAction"),O=require("../../secure-channel/device-action/ListInstalledApps/ListInstalledAppsDeviceAction");const h=(e,t=!1)=>{I.ListAppsDeviceAction.mockImplementation(()=>({makeStateMachine:vi.fn().mockImplementation(()=>(0,o.createMachine)({id:"MockListAppsDeviceAction",initial:"ready",states:{ready:{after:{0:"done"},entry:(0,o.assign)({intermediateValue:()=>({requiredUserInteraction:i.UserInteractionRequired.AllowListApps,step:y.listAppsDAStateStep.LIST_APPS})})},done:{type:"final"}},output:()=>t?(0,n.Left)(new r.UnknownDAError("ListApps failed")):(0,n.Right)(e)}))}))},L=(e,t=!1)=>{d.GetDeviceMetadataDeviceAction.mockImplementation(()=>({makeStateMachine:vi.fn().mockImplementation(()=>(0,o.createMachine)({id:"MockGetDeviceMetadataDeviceAction",initial:"ready",states:{ready:{after:{0:"done"},entry:(0,o.assign)({intermediateValue:()=>({requiredUserInteraction:i.UserInteractionRequired.None,step:l.getDeviceMetadataDAStateStep.GET_DEVICE_METADATA})})},done:{type:"final"}},output:()=>t?(0,n.Left)(new r.UnknownDAError("GetDeviceMetadata failed")):(0,n.Right)(e)}))}))},N=(e,t,a=!1)=>{D.InstallOrUpdateAppsDeviceAction.mockImplementation(()=>({makeStateMachine:vi.fn().mockImplementation(()=>(0,o.createMachine)({id:"MockInstallOrUpdateAppsDeviceAction",initial:"ready",states:{ready:{after:{0:"done"},entry:(0,o.assign)({intermediateValue:()=>t})},done:{type:"final"}},output:()=>a?(0,n.Left)(new r.UnknownDAError("InstallOrUpdateApps failed")):(0,n.Right)(e)}))}))},P=(e=!1)=>{M.OpenAppDeviceAction.mockImplementation(()=>({makeStateMachine:vi.fn().mockImplementation(()=>(0,o.createMachine)({initial:"ready",states:{ready:{entry:(0,o.assign)({intermediateValue:{requiredUserInteraction:i.UserInteractionRequired.ConfirmOpenApp,step:v.openAppDAStateStep.GET_DEVICE_STATUS}}),after:{0:"done"}},done:{type:"final"}},output:()=>e?(0,n.Left)(new r.UnknownDAError("OpenApp failed")):(0,n.Right)(void 0)}))}))},q=(e=!1)=>{u.GoToDashboardDeviceAction.mockImplementation(()=>({makeStateMachine:vi.fn().mockImplementation(()=>(0,o.createMachine)({id:"MockGoToDashboardDeviceAction",initial:"ready",states:{ready:{after:{0:"done"},entry:(0,o.assign)({intermediateValue:()=>({requiredUserInteraction:i.UserInteractionRequired.None,step:k.goToDashboardDAStateStep.GET_DEVICE_STATUS})})},done:{type:"final"}},output:()=>e?(0,n.Left)(new r.UnknownDAError("GoToDashboard failed")):(0,n.Right)(void 0)}))}))},w=(e=[{currentApp:"BOLOS",currentAppVersion:"1.0.0"}])=>{const t=vi.fn();for(const a of e)t.mockImplementationOnce(()=>"currentApp"in a?(0,n.Right)(a):(0,n.Left)(a));A.GetDeviceStatusDeviceAction.mockImplementation(()=>({makeStateMachine:vi.fn().mockImplementation(()=>(0,o.createMachine)({id:"MockGetDeviceStatusDeviceAction",initial:"ready",states:{ready:{after:{0:"done"},entry:(0,o.assign)({intermediateValue:()=>({requiredUserInteraction:i.UserInteractionRequired.None,step:f.getDeviceStatusDAStateStep.ONBOARD_CHECK})})},done:{type:"final"}},output:t}))}))},x=(e=[])=>{O.ListInstalledAppsDeviceAction.mockImplementation(()=>({makeStateMachine:vi.fn().mockImplementation(()=>(0,o.createMachine)({id:"MockListInstalledAppsDeviceAction",initial:"ready",states:{ready:{after:{0:"done"},entry:(0,o.assign)({intermediateValue:()=>({requiredUserInteraction:i.UserInteractionRequired.None})})},done:{type:"final"}},output:e.reduce((t,a)=>t.mockImplementationOnce(()=>"installedApps"in a?(0,n.Right)(a):(0,n.Left)(a)),vi.fn()).mockImplementation(()=>(0,n.Right)([]))}))}))},R=(e,t=i.UserInteractionRequired.None)=>{S.WaitForAppAndVersionDeviceAction.mockImplementation(()=>({makeStateMachine:vi.fn().mockImplementation(()=>(0,o.createMachine)({id:"MockWaitForAppAndVersionDeviceAction",initial:"ready",context:{intermediateValue:{requiredUserInteraction:i.UserInteractionRequired.None,step:m.waitForAppAndVersionDAStateStep.GET_APP_AND_VERSION}},states:{ready:{after:{0:"done"},entry:(0,o.assign)({intermediateValue:()=>({requiredUserInteraction:t,step:m.waitForAppAndVersionDAStateStep.GET_APP_AND_VERSION})})},done:{type:"final"}},output:()=>"_tag"in e?(0,n.Left)(e):(0,n.Right)(e)}))}))};0&&(module.exports={setupGetDeviceMetadataMock,setupGetDeviceStatusMock,setupGoToDashboardMock,setupInstallOrUpdateAppsMock,setupListAppsMock,setupListInstalledAppsMock,setupOpenAppMock,setupWaitForAppAndVersionMock});
2
2
  //# sourceMappingURL=setupTestMachine.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../../../src/api/device-action/__test-utils__/setupTestMachine.ts"],
4
- "sourcesContent": ["import { Left, Right } from \"purify-ts\";\nimport { type Mock } from \"vitest\";\nimport { assign, createMachine } from \"xstate\";\n\nimport { UserInteractionRequired } from \"@api/device-action/model/UserInteractionRequired\";\nimport { UnknownDAError } from \"@api/device-action/os/Errors\";\nimport { GetDeviceMetadataDeviceAction } from \"@api/device-action/os/GetDeviceMetadata/GetDeviceMetadataDeviceAction\";\nimport {\n type GetDeviceMetadataDAOutput,\n getDeviceMetadataDAStateStep,\n} from \"@api/device-action/os/GetDeviceMetadata/types\";\nimport { GetDeviceStatusDeviceAction } from \"@api/device-action/os/GetDeviceStatus/GetDeviceStatusDeviceAction\";\nimport { getDeviceStatusDAStateStep } from \"@api/device-action/os/GetDeviceStatus/types\";\nimport { GoToDashboardDeviceAction } from \"@api/device-action/os/GoToDashboard/GoToDashboardDeviceAction\";\nimport { goToDashboardDAStateStep } from \"@api/device-action/os/GoToDashboard/types\";\nimport { InstallOrUpdateAppsDeviceAction } from \"@api/device-action/os/InstallOrUpdateApps/InstallOrUpdateAppsDeviceAction\";\nimport {\n type InstallOrUpdateAppsDAIntermediateValue,\n type InstallOrUpdateAppsDAOutput,\n} from \"@api/device-action/os/InstallOrUpdateApps/types\";\nimport { ListAppsDeviceAction } from \"@api/device-action/os/ListApps/ListAppsDeviceAction\";\nimport { listAppsDAStateStep } from \"@api/device-action/os/ListApps/types\";\nimport { OpenAppDeviceAction } from \"@api/device-action/os/OpenAppDeviceAction/OpenAppDeviceAction\";\nimport { openAppDAStateStep } from \"@api/device-action/os/OpenAppDeviceAction/types\";\nimport { type DmkError } from \"@api/Error\";\nimport { ListInstalledAppsDeviceAction } from \"@api/secure-channel/device-action/ListInstalledApps/ListInstalledAppsDeviceAction\";\nimport { type InstalledApp } from \"@api/secure-channel/device-action/ListInstalledApps/types\";\n\nimport { type BTC_APP } from \"./data\";\n\ntype App = typeof BTC_APP;\n\nexport const setupListAppsMock = (apps: App[], error = false) => {\n (ListAppsDeviceAction as Mock).mockImplementation(() => ({\n makeStateMachine: vi.fn().mockImplementation(() =>\n createMachine({\n id: \"MockListAppsDeviceAction\",\n initial: \"ready\",\n states: {\n ready: {\n after: {\n 0: \"done\",\n },\n entry: assign({\n intermediateValue: () => ({\n requiredUserInteraction: UserInteractionRequired.AllowListApps,\n step: listAppsDAStateStep.LIST_APPS,\n }),\n }),\n },\n done: {\n type: \"final\",\n },\n },\n output: () => {\n return error\n ? Left(new UnknownDAError(\"ListApps failed\"))\n : Right(apps);\n },\n }),\n ),\n }));\n};\n\nexport const setupGetDeviceMetadataMock = (\n metadata: GetDeviceMetadataDAOutput,\n error = false,\n) => {\n (GetDeviceMetadataDeviceAction as Mock).mockImplementation(() => ({\n makeStateMachine: vi.fn().mockImplementation(() =>\n createMachine({\n id: \"MockGetDeviceMetadataDeviceAction\",\n initial: \"ready\",\n states: {\n ready: {\n after: {\n 0: \"done\",\n },\n entry: assign({\n intermediateValue: () => ({\n requiredUserInteraction: UserInteractionRequired.None,\n step: getDeviceMetadataDAStateStep.GET_DEVICE_METADATA,\n }),\n }),\n },\n done: {\n type: \"final\",\n },\n },\n output: () => {\n return error\n ? Left(new UnknownDAError(\"GetDeviceMetadata failed\"))\n : Right(metadata);\n },\n }),\n ),\n }));\n};\n\nexport const setupInstallOrUpdateAppsMock = (\n result: InstallOrUpdateAppsDAOutput,\n intermediateValue: InstallOrUpdateAppsDAIntermediateValue,\n error = false,\n) => {\n (InstallOrUpdateAppsDeviceAction as Mock).mockImplementation(() => ({\n makeStateMachine: vi.fn().mockImplementation(() =>\n createMachine({\n id: \"MockInstallOrUpdateAppsDeviceAction\",\n initial: \"ready\",\n states: {\n ready: {\n after: {\n 0: \"done\",\n },\n entry: assign({\n intermediateValue: () => intermediateValue,\n }),\n },\n done: {\n type: \"final\",\n },\n },\n output: () => {\n return error\n ? Left(new UnknownDAError(\"InstallOrUpdateApps failed\"))\n : Right(result);\n },\n }),\n ),\n }));\n};\n\nexport const setupOpenAppMock = (error: boolean = false) => {\n (OpenAppDeviceAction as Mock).mockImplementation(() => ({\n makeStateMachine: vi.fn().mockImplementation(() =>\n createMachine({\n initial: \"ready\",\n states: {\n ready: {\n entry: assign({\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.ConfirmOpenApp,\n step: openAppDAStateStep.GET_DEVICE_STATUS,\n },\n }),\n after: {\n 0: \"done\",\n },\n },\n done: {\n type: \"final\",\n },\n },\n output: () => {\n return error\n ? Left(new UnknownDAError(\"OpenApp failed\"))\n : Right(undefined);\n },\n }),\n ),\n }));\n};\n\nexport const setupGoToDashboardMock = (error: boolean = false) => {\n (GoToDashboardDeviceAction as Mock).mockImplementation(() => ({\n makeStateMachine: vi.fn().mockImplementation(() =>\n createMachine({\n id: \"MockGoToDashboardDeviceAction\",\n initial: \"ready\",\n states: {\n ready: {\n after: {\n 0: \"done\",\n },\n entry: assign({\n intermediateValue: () => ({\n requiredUserInteraction: UserInteractionRequired.None,\n step: goToDashboardDAStateStep.GET_DEVICE_STATUS,\n }),\n }),\n },\n done: {\n type: \"final\",\n },\n },\n output: () => {\n return error\n ? Left(new UnknownDAError(\"GoToDashboard failed\"))\n : Right(undefined);\n },\n }),\n ),\n }));\n};\n\nexport const setupGetDeviceStatusMock = (\n outputs: ReadonlyArray<\n { currentApp: string; currentAppVersion: string } | DmkError\n > = [\n {\n currentApp: \"BOLOS\",\n currentAppVersion: \"1.0.0\",\n },\n ],\n) => {\n const outputFn = vi.fn();\n\n for (const output of outputs) {\n outputFn.mockImplementationOnce(() =>\n \"currentApp\" in output ? Right(output) : Left(output),\n );\n }\n (GetDeviceStatusDeviceAction as Mock).mockImplementation(() => ({\n makeStateMachine: vi.fn().mockImplementation(() =>\n createMachine({\n id: \"MockGetDeviceStatusDeviceAction\",\n initial: \"ready\",\n states: {\n ready: {\n after: {\n 0: \"done\",\n },\n entry: assign({\n intermediateValue: () => ({\n requiredUserInteraction: UserInteractionRequired.None,\n step: getDeviceStatusDAStateStep.ONBOARD_CHECK,\n }),\n }),\n },\n done: {\n type: \"final\",\n },\n },\n output: outputFn,\n }),\n ),\n }));\n};\n\nexport const setupListInstalledAppsMock = (\n outputs: Array<{ installedApps: InstalledApp[] } | DmkError> = [],\n) => {\n (ListInstalledAppsDeviceAction as Mock).mockImplementation(() => ({\n makeStateMachine: vi.fn().mockImplementation(() =>\n createMachine({\n id: \"MockListInstalledAppsDeviceAction\",\n initial: \"ready\",\n states: {\n ready: {\n after: {\n 0: \"done\",\n },\n entry: assign({\n intermediateValue: () => ({\n requiredUserInteraction: UserInteractionRequired.None,\n }),\n }),\n },\n done: {\n type: \"final\",\n },\n },\n output: outputs\n .reduce(\n (mockFn, output) =>\n mockFn.mockImplementationOnce(() =>\n \"installedApps\" in output ? Right(output) : Left(output),\n ),\n vi.fn(),\n )\n .mockImplementation(() => Right([])),\n }),\n ),\n }));\n};\n"],
5
- "mappings": "yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,gCAAAE,EAAA,6BAAAC,EAAA,2BAAAC,EAAA,iCAAAC,EAAA,sBAAAC,EAAA,+BAAAC,EAAA,qBAAAC,IAAA,eAAAC,EAAAT,GAAA,IAAAU,EAA4B,qBAE5BC,EAAsC,kBAEtCC,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ACH,MAAMC,EAAW,GAAG,GAAG,EAEvB,UAAWC,KAAUF,EACnBC,EAAS,uBAAuB,IAC9B,eAAgBC,KAAS,SAAMA,CAAM,KAAI,QAAKA,CAAM,CACtD,EAED,8BAAqC,mBAAmB,KAAO,CAC9D,iBAAkB,GAAG,GAAG,EAAE,mBAAmB,OAC3C,iBAAc,CACZ,GAAI,kCACJ,QAAS,QACT,OAAQ,CACN,MAAO,CACL,MAAO,CACL,EAAG,MACL,EACA,SAAO,UAAO,CACZ,kBAAmB,KAAO,CACxB,wBAAyB,0BAAwB,KACjD,KAAM,6BAA2B,aACnC,EACF,CAAC,CACH,EACA,KAAM,CACJ,KAAM,OACR,CACF,EACA,OAAQD,CACV,CAAC,CACH,CACF,EAAE,CACJ,EAEarB,EAA6B,CACxCoB,EAA+D,CAAC,IAC7D,CACF,gCAAuC,mBAAmB,KAAO,CAChE,iBAAkB,GAAG,GAAG,EAAE,mBAAmB,OAC3C,iBAAc,CACZ,GAAI,oCACJ,QAAS,QACT,OAAQ,CACN,MAAO,CACL,MAAO,CACL,EAAG,MACL,EACA,SAAO,UAAO,CACZ,kBAAmB,KAAO,CACxB,wBAAyB,0BAAwB,IACnD,EACF,CAAC,CACH,EACA,KAAM,CACJ,KAAM,OACR,CACF,EACA,OAAQA,EACL,OACC,CAACG,EAAQD,IACPC,EAAO,uBAAuB,IAC5B,kBAAmBD,KAAS,SAAMA,CAAM,KAAI,QAAKA,CAAM,CACzD,EACF,GAAG,GAAG,CACR,EACC,mBAAmB,OAAM,SAAM,CAAC,CAAC,CAAC,CACvC,CAAC,CACH,CACF,EAAE,CACJ",
6
- "names": ["setupTestMachine_exports", "__export", "setupGetDeviceMetadataMock", "setupGetDeviceStatusMock", "setupGoToDashboardMock", "setupInstallOrUpdateAppsMock", "setupListAppsMock", "setupListInstalledAppsMock", "setupOpenAppMock", "__toCommonJS", "import_purify_ts", "import_xstate", "import_UserInteractionRequired", "import_Errors", "import_GetDeviceMetadataDeviceAction", "import_types", "import_GetDeviceStatusDeviceAction", "import_GoToDashboardDeviceAction", "import_InstallOrUpdateAppsDeviceAction", "import_ListAppsDeviceAction", "import_OpenAppDeviceAction", "import_ListInstalledAppsDeviceAction", "apps", "error", "metadata", "result", "intermediateValue", "outputs", "outputFn", "output", "mockFn"]
4
+ "sourcesContent": ["import { Left, Right } from \"purify-ts\";\nimport { type Mock } from \"vitest\";\nimport { assign, createMachine } from \"xstate\";\n\nimport { type GetAppAndVersionResponse } from \"@api/command/os/GetAppAndVersionCommand\";\nimport { UserInteractionRequired } from \"@api/device-action/model/UserInteractionRequired\";\nimport { UnknownDAError } from \"@api/device-action/os/Errors\";\nimport { GetDeviceMetadataDeviceAction } from \"@api/device-action/os/GetDeviceMetadata/GetDeviceMetadataDeviceAction\";\nimport {\n type GetDeviceMetadataDAOutput,\n getDeviceMetadataDAStateStep,\n} from \"@api/device-action/os/GetDeviceMetadata/types\";\nimport { GetDeviceStatusDeviceAction } from \"@api/device-action/os/GetDeviceStatus/GetDeviceStatusDeviceAction\";\nimport { getDeviceStatusDAStateStep } from \"@api/device-action/os/GetDeviceStatus/types\";\nimport { GoToDashboardDeviceAction } from \"@api/device-action/os/GoToDashboard/GoToDashboardDeviceAction\";\nimport { goToDashboardDAStateStep } from \"@api/device-action/os/GoToDashboard/types\";\nimport { InstallOrUpdateAppsDeviceAction } from \"@api/device-action/os/InstallOrUpdateApps/InstallOrUpdateAppsDeviceAction\";\nimport {\n type InstallOrUpdateAppsDAIntermediateValue,\n type InstallOrUpdateAppsDAOutput,\n} from \"@api/device-action/os/InstallOrUpdateApps/types\";\nimport { ListAppsDeviceAction } from \"@api/device-action/os/ListApps/ListAppsDeviceAction\";\nimport { listAppsDAStateStep } from \"@api/device-action/os/ListApps/types\";\nimport { OpenAppDeviceAction } from \"@api/device-action/os/OpenAppDeviceAction/OpenAppDeviceAction\";\nimport { openAppDAStateStep } from \"@api/device-action/os/OpenAppDeviceAction/types\";\nimport { waitForAppAndVersionDAStateStep } from \"@api/device-action/os/WaitForAppAndVersion/types\";\nimport { WaitForAppAndVersionDeviceAction } from \"@api/device-action/os/WaitForAppAndVersion/WaitForAppAndVersionDeviceAction\";\nimport { type DmkError } from \"@api/Error\";\nimport { ListInstalledAppsDeviceAction } from \"@api/secure-channel/device-action/ListInstalledApps/ListInstalledAppsDeviceAction\";\nimport { type InstalledApp } from \"@api/secure-channel/device-action/ListInstalledApps/types\";\n\nimport { type BTC_APP } from \"./data\";\n\ntype App = typeof BTC_APP;\n\nexport const setupListAppsMock = (apps: App[], error = false) => {\n (ListAppsDeviceAction as Mock).mockImplementation(() => ({\n makeStateMachine: vi.fn().mockImplementation(() =>\n createMachine({\n id: \"MockListAppsDeviceAction\",\n initial: \"ready\",\n states: {\n ready: {\n after: {\n 0: \"done\",\n },\n entry: assign({\n intermediateValue: () => ({\n requiredUserInteraction: UserInteractionRequired.AllowListApps,\n step: listAppsDAStateStep.LIST_APPS,\n }),\n }),\n },\n done: {\n type: \"final\",\n },\n },\n output: () => {\n return error\n ? Left(new UnknownDAError(\"ListApps failed\"))\n : Right(apps);\n },\n }),\n ),\n }));\n};\n\nexport const setupGetDeviceMetadataMock = (\n metadata: GetDeviceMetadataDAOutput,\n error = false,\n) => {\n (GetDeviceMetadataDeviceAction as Mock).mockImplementation(() => ({\n makeStateMachine: vi.fn().mockImplementation(() =>\n createMachine({\n id: \"MockGetDeviceMetadataDeviceAction\",\n initial: \"ready\",\n states: {\n ready: {\n after: {\n 0: \"done\",\n },\n entry: assign({\n intermediateValue: () => ({\n requiredUserInteraction: UserInteractionRequired.None,\n step: getDeviceMetadataDAStateStep.GET_DEVICE_METADATA,\n }),\n }),\n },\n done: {\n type: \"final\",\n },\n },\n output: () => {\n return error\n ? Left(new UnknownDAError(\"GetDeviceMetadata failed\"))\n : Right(metadata);\n },\n }),\n ),\n }));\n};\n\nexport const setupInstallOrUpdateAppsMock = (\n result: InstallOrUpdateAppsDAOutput,\n intermediateValue: InstallOrUpdateAppsDAIntermediateValue,\n error = false,\n) => {\n (InstallOrUpdateAppsDeviceAction as Mock).mockImplementation(() => ({\n makeStateMachine: vi.fn().mockImplementation(() =>\n createMachine({\n id: \"MockInstallOrUpdateAppsDeviceAction\",\n initial: \"ready\",\n states: {\n ready: {\n after: {\n 0: \"done\",\n },\n entry: assign({\n intermediateValue: () => intermediateValue,\n }),\n },\n done: {\n type: \"final\",\n },\n },\n output: () => {\n return error\n ? Left(new UnknownDAError(\"InstallOrUpdateApps failed\"))\n : Right(result);\n },\n }),\n ),\n }));\n};\n\nexport const setupOpenAppMock = (error: boolean = false) => {\n (OpenAppDeviceAction as Mock).mockImplementation(() => ({\n makeStateMachine: vi.fn().mockImplementation(() =>\n createMachine({\n initial: \"ready\",\n states: {\n ready: {\n entry: assign({\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.ConfirmOpenApp,\n step: openAppDAStateStep.GET_DEVICE_STATUS,\n },\n }),\n after: {\n 0: \"done\",\n },\n },\n done: {\n type: \"final\",\n },\n },\n output: () => {\n return error\n ? Left(new UnknownDAError(\"OpenApp failed\"))\n : Right(undefined);\n },\n }),\n ),\n }));\n};\n\nexport const setupGoToDashboardMock = (error: boolean = false) => {\n (GoToDashboardDeviceAction as Mock).mockImplementation(() => ({\n makeStateMachine: vi.fn().mockImplementation(() =>\n createMachine({\n id: \"MockGoToDashboardDeviceAction\",\n initial: \"ready\",\n states: {\n ready: {\n after: {\n 0: \"done\",\n },\n entry: assign({\n intermediateValue: () => ({\n requiredUserInteraction: UserInteractionRequired.None,\n step: goToDashboardDAStateStep.GET_DEVICE_STATUS,\n }),\n }),\n },\n done: {\n type: \"final\",\n },\n },\n output: () => {\n return error\n ? Left(new UnknownDAError(\"GoToDashboard failed\"))\n : Right(undefined);\n },\n }),\n ),\n }));\n};\n\nexport const setupGetDeviceStatusMock = (\n outputs: ReadonlyArray<\n { currentApp: string; currentAppVersion: string } | DmkError\n > = [\n {\n currentApp: \"BOLOS\",\n currentAppVersion: \"1.0.0\",\n },\n ],\n) => {\n const outputFn = vi.fn();\n\n for (const output of outputs) {\n outputFn.mockImplementationOnce(() =>\n \"currentApp\" in output ? Right(output) : Left(output),\n );\n }\n (GetDeviceStatusDeviceAction as Mock).mockImplementation(() => ({\n makeStateMachine: vi.fn().mockImplementation(() =>\n createMachine({\n id: \"MockGetDeviceStatusDeviceAction\",\n initial: \"ready\",\n states: {\n ready: {\n after: {\n 0: \"done\",\n },\n entry: assign({\n intermediateValue: () => ({\n requiredUserInteraction: UserInteractionRequired.None,\n step: getDeviceStatusDAStateStep.ONBOARD_CHECK,\n }),\n }),\n },\n done: {\n type: \"final\",\n },\n },\n output: outputFn,\n }),\n ),\n }));\n};\n\nexport const setupListInstalledAppsMock = (\n outputs: Array<{ installedApps: InstalledApp[] } | DmkError> = [],\n) => {\n (ListInstalledAppsDeviceAction as Mock).mockImplementation(() => ({\n makeStateMachine: vi.fn().mockImplementation(() =>\n createMachine({\n id: \"MockListInstalledAppsDeviceAction\",\n initial: \"ready\",\n states: {\n ready: {\n after: {\n 0: \"done\",\n },\n entry: assign({\n intermediateValue: () => ({\n requiredUserInteraction: UserInteractionRequired.None,\n }),\n }),\n },\n done: {\n type: \"final\",\n },\n },\n output: outputs\n .reduce(\n (mockFn, output) =>\n mockFn.mockImplementationOnce(() =>\n \"installedApps\" in output ? Right(output) : Left(output),\n ),\n vi.fn(),\n )\n .mockImplementation(() => Right([])),\n }),\n ),\n }));\n};\n\nexport const setupWaitForAppAndVersionMock = (\n output: GetAppAndVersionResponse | DmkError,\n requiredUserInteraction: UserInteractionRequired = UserInteractionRequired.None,\n) => {\n (WaitForAppAndVersionDeviceAction as unknown as Mock).mockImplementation(\n () => ({\n makeStateMachine: vi.fn().mockImplementation(() =>\n createMachine({\n id: \"MockWaitForAppAndVersionDeviceAction\",\n initial: \"ready\",\n context: {\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.None,\n step: waitForAppAndVersionDAStateStep.GET_APP_AND_VERSION,\n },\n },\n states: {\n ready: {\n after: {\n 0: \"done\",\n },\n entry: assign({\n intermediateValue: () => ({\n requiredUserInteraction,\n step: waitForAppAndVersionDAStateStep.GET_APP_AND_VERSION,\n }),\n }),\n },\n done: {\n type: \"final\",\n },\n },\n output: () => (\"_tag\" in output ? Left(output) : Right(output)),\n }),\n ),\n }),\n );\n};\n"],
5
+ "mappings": "yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,gCAAAE,EAAA,6BAAAC,EAAA,2BAAAC,EAAA,iCAAAC,EAAA,sBAAAC,EAAA,+BAAAC,EAAA,qBAAAC,EAAA,kCAAAC,IAAA,eAAAC,EAAAV,GAAA,IAAAW,EAA4B,qBAE5BC,EAAsC,kBAGtCC,EAAwC,4DACxCC,EAA+B,wCAC/BC,EAA8C,iFAC9CC,EAGO,yDACPC,EAA4C,6EAC5CD,EAA2C,uDAC3CE,EAA0C,yEAC1CF,EAAyC,qDACzCG,EAAgD,qFAKhDC,EAAqC,+DACrCJ,EAAoC,gDACpCK,EAAoC,yEACpCL,EAAmC,2DACnCA,EAAgD,4DAChDM,EAAiD,uFAEjDC,EAA8C,6FAOvC,MAAMjB,EAAoB,CAACkB,EAAaC,EAAQ,KAAU,CAC9D,uBAA8B,mBAAmB,KAAO,CACvD,iBAAkB,GAAG,GAAG,EAAE,mBAAmB,OAC3C,iBAAc,CACZ,GAAI,2BACJ,QAAS,QACT,OAAQ,CACN,MAAO,CACL,MAAO,CACL,EAAG,MACL,EACA,SAAO,UAAO,CACZ,kBAAmB,KAAO,CACxB,wBAAyB,0BAAwB,cACjD,KAAM,sBAAoB,SAC5B,EACF,CAAC,CACH,EACA,KAAM,CACJ,KAAM,OACR,CACF,EACA,OAAQ,IACCA,KACH,QAAK,IAAI,iBAAe,iBAAiB,CAAC,KAC1C,SAAMD,CAAI,CAElB,CAAC,CACH,CACF,EAAE,CACJ,EAEatB,EAA6B,CACxCwB,EACAD,EAAQ,KACL,CACF,gCAAuC,mBAAmB,KAAO,CAChE,iBAAkB,GAAG,G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CACJ,KAAM,OACR,CACF,EACA,OAAQA,EACL,OACC,CAACG,EAAQD,IACPC,EAAO,uBAAuB,IAC5B,kBAAmBD,KAAS,SAAMA,CAAM,KAAI,QAAKA,CAAM,CACzD,EACF,GAAG,GAAG,CACR,EACC,mBAAmB,OAAM,SAAM,CAAC,CAAC,CAAC,CACvC,CAAC,CACH,CACF,EAAE,CACJ,EAEatB,EAAgC,CAC3CsB,EACAE,EAAmD,0BAAwB,OACxE,CACF,mCAAqD,mBACpD,KAAO,CACL,iBAAkB,GAAG,GAAG,EAAE,mBAAmB,OAC3C,iBAAc,CACZ,GAAI,uCACJ,QAAS,QACT,QAAS,CACP,kBAAmB,CACjB,wBAAyB,0BAAwB,KACjD,KAAM,kCAAgC,mBACxC,CACF,EACA,OAAQ,CACN,MAAO,CACL,MAAO,CACL,EAAG,MACL,EACA,SAAO,UAAO,CACZ,kBAAmB,KAAO,CACxB,wBAAAA,EACA,KAAM,kCAAgC,mBACxC,EACF,CAAC,CACH,EACA,KAAM,CACJ,KAAM,OACR,CACF,EACA,OAAQ,IAAO,SAAUF,KAAS,QAAKA,CAAM,KAAI,SAAMA,CAAM,CAC/D,CAAC,CACH,CACF,EACF,CACF",
6
+ "names": ["setupTestMachine_exports", "__export", "setupGetDeviceMetadataMock", "setupGetDeviceStatusMock", "setupGoToDashboardMock", "setupInstallOrUpdateAppsMock", "setupListAppsMock", "setupListInstalledAppsMock", "setupOpenAppMock", "setupWaitForAppAndVersionMock", "__toCommonJS", "import_purify_ts", "import_xstate", "import_UserInteractionRequired", "import_Errors", "import_GetDeviceMetadataDeviceAction", "import_types", "import_GetDeviceStatusDeviceAction", "import_GoToDashboardDeviceAction", "import_InstallOrUpdateAppsDeviceAction", "import_ListAppsDeviceAction", "import_OpenAppDeviceAction", "import_WaitForAppAndVersionDeviceAction", "import_ListInstalledAppsDeviceAction", "apps", "error", "metadata", "result", "intermediateValue", "outputs", "outputFn", "output", "mockFn", "requiredUserInteraction"]
7
7
  }
@@ -1,2 +1,2 @@
1
- "use strict";var g=Object.defineProperty;var x=Object.getOwnPropertyDescriptor;var M=Object.getOwnPropertyNames;var I=Object.prototype.hasOwnProperty;var N=(o,r)=>{for(var s in r)g(o,s,{get:r[s],enumerable:!0})},R=(o,r,s,u)=>{if(r&&typeof r=="object"||typeof r=="function")for(let i of M(r))!I.call(o,i)&&i!==s&&g(o,i,{get:()=>r[i],enumerable:!(u=x(r,i))||u.enumerable});return o};var F=o=>R(g({},"__esModule",{value:!0}),o);var L={};N(L,{GetDeviceStatusDeviceAction:()=>_});module.exports=F(L);var m=require("purify-ts"),n=require("rxjs"),k=require("rxjs/operators"),t=require("xstate"),S=require("../../../command/model/CommandResult"),V=require("../../../command/os/GetAppAndVersionCommand"),E=require("../../../command/os/GetOsVersionCommand"),f=require("../../../device/DeviceStatus"),l=require("../../../device-action/model/UserInteractionRequired"),C=require("../../../device-action/os/Const"),v=require("../../../device-action/os/Errors"),h=require("../../../device-action/xstate-utils/XStateDeviceAction"),p=require("../../../device-session/DeviceSessionState"),A=require("../../../utils/AppName"),D=require("./types");const T=o=>({mcu:o.mcuSephVersion,bootloader:o.mcuBootloaderVersion,os:o.seVersion,metadata:o});class _ extends h.XStateDeviceAction{makeStateMachine(r){const{getAppAndVersion:s,getOsVersion:u,getDeviceSessionState:i,setDeviceSessionState:c,waitForDeviceUnlock:y}=this.extractDependencies(r),O=this.input.unlockTimeout??C.DEFAULT_UNLOCK_TIMEOUT_MS,G=this.input.allowNonOnboardedDevice??!0,b=e=>{const a=i();a.sessionStateType!==p.DeviceSessionStateType.Connected&&c({...a,firmwareVersion:T(e),isSecureConnectionAllowed:e.secureElementFlags.isSecureConnectionAllowed})};return(0,t.setup)({types:{input:{unlockTimeout:O,allowNonOnboardedDevice:G},context:{},output:{}},actors:{getAppAndVersion:(0,t.fromPromise)(s),getOsVersion:(0,t.fromPromise)(u),waitForDeviceUnlock:(0,t.fromObservable)(y)},guards:{isCurrentAppBolos:({context:e})=>(0,A.isDashboardName)(e._internalState.currentApp),isOnboardedFromOsVersion:({context:e})=>e._internalState.osVersionMetadata?.secureElementFlags.isOnboarded===!0,isAllowedNonOnboardedDevice:({context:e})=>{const a=e._internalState.osVersionMetadata?.secureElementFlags;return e.input.allowNonOnboardedDevice===!0&&a?.isOnboarded===!1},isDeviceLocked:({context:e})=>e._internalState.locked,hasError:({context:e})=>e._internalState.error!==null},actions:{assignErrorDeviceNotOnboarded:(0,t.assign)({_internalState:e=>({...e.context._internalState,error:new v.DeviceNotOnboardedError})}),assignErrorDeviceLocked:(0,t.assign)({_internalState:e=>({...e.context._internalState,error:new v.DeviceLockedError}),intermediateValue:{requiredUserInteraction:l.UserInteractionRequired.UnlockDevice,step:D.getDeviceStatusDAStateStep.UNLOCK_DEVICE}}),assignErrorFromEvent:(0,t.assign)({_internalState:e=>({...e.context._internalState,error:e.event.error})}),assignNoUserActionNeeded:(0,t.assign)({intermediateValue:e=>({...e.context.intermediateValue,requiredUserInteraction:l.UserInteractionRequired.None})}),assignUserActionUnlockNeeded:(0,t.assign)({intermediateValue:e=>({...e.context.intermediateValue,requiredUserInteraction:l.UserInteractionRequired.UnlockDevice,step:D.getDeviceStatusDAStateStep.UNLOCK_DEVICE})})}}).createMachine({id:"GetDeviceStatusDeviceAction",initial:"DeviceReady",context:e=>{const a=i(),{sessionStateType:d}=a;return{input:{unlockTimeout:e.input.unlockTimeout,allowNonOnboardedDevice:e.input.allowNonOnboardedDevice??!0},intermediateValue:{requiredUserInteraction:l.UserInteractionRequired.None,step:D.getDeviceStatusDAStateStep.ONBOARD_CHECK},_internalState:{onboarded:!1,locked:!1,currentApp:d===p.DeviceSessionStateType.ReadyWithoutSecureChannel?a.currentApp.name:null,currentAppVersion:null,osVersionMetadata:null,error:null}}},states:{DeviceReady:{always:{target:"AppAndVersionCheck"}},AppAndVersionCheck:{invoke:{src:"getAppAndVersion",onDone:{target:"ApplicationAvailableResultCheck",actions:(0,t.assign)({_internalState:e=>{if((0,S.isSuccessCommandResult)(e.event.output)){const a=i();return a.sessionStateType!==p.DeviceSessionStateType.Connected?c({...a,currentApp:e.event.output.data}):c({deviceModelId:a.deviceModelId,sessionStateType:p.DeviceSessionStateType.ReadyWithoutSecureChannel,deviceStatus:f.DeviceStatus.CONNECTED,currentApp:e.event.output.data,installedApps:[],isSecureConnectionAllowed:!1}),{...e.context._internalState,locked:!1,currentApp:e.event.output.data.name,currentAppVersion:e.event.output.data.version}}if("errorCode"in e.event.output.error){if(e.event.output.error.errorCode==="5515")return{...e.context._internalState,locked:!0};if(e.event.output.error.errorCode==="6e00")return{...e.context._internalState,locked:!1,currentApp:A.LEDGER_OS_NAME,currentAppVersion:"0.0.0"}}return{...e.context._internalState,error:e.event.output.error}}})},onError:{target:"Error",actions:"assignErrorFromEvent"}}},ApplicationAvailableResultCheck:{always:[{guard:"hasError",target:"Error"},{target:"UserActionUnlockDevice",guard:"isDeviceLocked"},{target:"OnboardingCheck"}]},OnboardingCheck:{always:[{guard:"isCurrentAppBolos",target:"GetOsVersion"},{target:"Success",actions:(0,t.assign)({_internalState:e=>({...e.context._internalState,onboarded:!0})})}]},GetOsVersion:{invoke:{src:"getOsVersion",onDone:{target:"OnboardingResultCheck",actions:(0,t.assign)({_internalState:e=>(0,S.isSuccessCommandResult)(e.event.output)?(b(e.event.output.data),{...e.context._internalState,osVersionMetadata:e.event.output.data}):{...e.context._internalState,error:e.event.output.error}})},onError:{target:"Error",actions:"assignErrorFromEvent"}}},OnboardingResultCheck:{always:[{guard:"hasError",target:"Error"},{guard:"isOnboardedFromOsVersion",target:"Success",actions:(0,t.assign)({_internalState:e=>({...e.context._internalState,onboarded:!0})})},{guard:"isAllowedNonOnboardedDevice",target:"Success"},{target:"Error",actions:"assignErrorDeviceNotOnboarded"}]},UserActionUnlockDevice:{entry:"assignUserActionUnlockNeeded",exit:"assignNoUserActionNeeded",invoke:{id:"UserActionUnlockDevice",src:"waitForDeviceUnlock",input:e=>({unlockTimeout:O}),onDone:{target:"AppAndVersionCheck",actions:(0,t.assign)({_internalState:e=>({...e.context._internalState,locked:!1})})},onError:{target:"Error",actions:"assignErrorDeviceLocked"}}},Success:{type:"final"},Error:{type:"final"}},output:e=>{const{context:a}=e,{error:d,currentApp:w,currentAppVersion:U}=a._internalState;return d?(0,m.Left)(d):(0,m.Right)({currentApp:w,currentAppVersion:U})}})}extractDependencies(r){return{getAppAndVersion:()=>r.sendCommand(new V.GetAppAndVersionCommand),getOsVersion:()=>r.sendCommand(new E.GetOsVersionCommand),waitForDeviceUnlock:({input:i})=>(0,n.interval)(1e3).pipe((0,n.switchMap)(()=>(0,n.from)(r.sendCommand(new V.GetAppAndVersionCommand))),(0,n.mergeMap)(c=>!(0,S.isSuccessCommandResult)(c)&&"errorCode"in c.error&&c.error.errorCode==="5515"?n.EMPTY:(0,n.of)(void 0)),(0,n.take)(1),(0,k.timeout)(i.unlockTimeout)),getDeviceSessionState:()=>r.getDeviceSessionState(),setDeviceSessionState:i=>r.setDeviceSessionState(i)}}}0&&(module.exports={GetDeviceStatusDeviceAction});
1
+ "use strict";var l=Object.defineProperty;var b=Object.getOwnPropertyDescriptor;var C=Object.getOwnPropertyNames;var w=Object.prototype.hasOwnProperty;var x=(r,t)=>{for(var i in t)l(r,i,{get:t[i],enumerable:!0})},F=(r,t,i,c)=>{if(t&&typeof t=="object"||typeof t=="function")for(let a of C(t))!w.call(r,a)&&a!==i&&l(r,a,{get:()=>t[a],enumerable:!(c=b(t,a))||c.enumerable});return r};var R=r=>F(l({},"__esModule",{value:!0}),r);var _={};x(_,{GetDeviceStatusDeviceAction:()=>T});module.exports=R(_);var p=require("purify-ts"),o=require("xstate"),m=require("../../../command/model/CommandResult"),v=require("../../../command/os/GetOsVersionCommand"),A=require("../../../device/DeviceStatus"),d=require("../../../device-action/model/UserInteractionRequired"),V=require("../../../device-action/os/Const"),O=require("../../../device-action/os/Errors"),g=require("../../../device-action/os/WaitForAppAndVersion/WaitForAppAndVersionDeviceAction"),y=require("../../../device-action/xstate-utils/XStateDeviceAction"),u=require("../../../device-session/DeviceSessionState"),h=require("../../../utils/AppName"),S=require("./types");const N=r=>({mcu:r.mcuSephVersion,bootloader:r.mcuBootloaderVersion,os:r.seVersion,metadata:r});class T extends y.XStateDeviceAction{makeStateMachine(t){const{getOsVersion:i,getDeviceSessionState:c,setDeviceSessionState:a}=this.extractDependencies(t),D=this.input.unlockTimeout??V.DEFAULT_UNLOCK_TIMEOUT_MS,E=this.input.allowNonOnboardedDevice??!0,G=e=>{const n=c();n.sessionStateType!==u.DeviceSessionStateType.Connected&&a({...n,firmwareVersion:N(e),isSecureConnectionAllowed:e.secureElementFlags.isSecureConnectionAllowed})},f=new g.WaitForAppAndVersionDeviceAction({input:{unlockTimeout:D}}).makeStateMachine(t);return(0,o.setup)({types:{input:{unlockTimeout:D,allowNonOnboardedDevice:E},context:{},output:{}},actors:{waitForAppAndVersion:f,getOsVersion:(0,o.fromPromise)(i)},guards:{isCurrentAppBolos:({context:e})=>(0,h.isDashboardName)(e._internalState.currentApp),isOnboardedFromOsVersion:({context:e})=>e._internalState.osVersionMetadata?.secureElementFlags.isOnboarded===!0,isAllowedNonOnboardedDevice:({context:e})=>{const n=e._internalState.osVersionMetadata?.secureElementFlags;return e.input.allowNonOnboardedDevice===!0&&n?.isOnboarded===!1},hasError:({context:e})=>e._internalState.error!==null},actions:{assignErrorDeviceNotOnboarded:(0,o.assign)({_internalState:e=>({...e.context._internalState,error:new O.DeviceNotOnboardedError})}),assignErrorFromEvent:(0,o.assign)({_internalState:e=>({...e.context._internalState,error:e.event.error})})}}).createMachine({id:"GetDeviceStatusDeviceAction",initial:"DeviceReady",context:e=>{const n=c(),{sessionStateType:s}=n;return{input:{unlockTimeout:e.input.unlockTimeout,allowNonOnboardedDevice:e.input.allowNonOnboardedDevice??!0},intermediateValue:{requiredUserInteraction:d.UserInteractionRequired.None,step:S.getDeviceStatusDAStateStep.WAIT_FOR_APP_AND_VERSION},_internalState:{onboarded:!1,currentApp:s===u.DeviceSessionStateType.ReadyWithoutSecureChannel?n.currentApp.name:null,currentAppVersion:null,osVersionMetadata:null,error:null}}},states:{DeviceReady:{always:{target:"WaitForAppAndVersion"}},WaitForAppAndVersion:{invoke:{src:"waitForAppAndVersion",input:e=>({unlockTimeout:e.context.input.unlockTimeout}),onSnapshot:{actions:(0,o.assign)({intermediateValue:e=>({...e.context.intermediateValue,requiredUserInteraction:e.event.snapshot.context.intermediateValue.requiredUserInteraction})})},onDone:{target:"WaitForAppAndVersionResultCheck",actions:(0,o.assign)({_internalState:e=>e.event.output.caseOf({Left:n=>({...e.context._internalState,error:n}),Right:n=>{const s=c();return s.sessionStateType!==u.DeviceSessionStateType.Connected?a({...s,currentApp:n}):a({deviceModelId:s.deviceModelId,sessionStateType:u.DeviceSessionStateType.ReadyWithoutSecureChannel,deviceStatus:A.DeviceStatus.CONNECTED,currentApp:n,installedApps:[],isSecureConnectionAllowed:!1}),{...e.context._internalState,currentApp:n.name,currentAppVersion:n.version}}})})},onError:{target:"Error",actions:"assignErrorFromEvent"}}},WaitForAppAndVersionResultCheck:{always:[{guard:"hasError",target:"Error"},{target:"OnboardingCheck"}]},OnboardingCheck:{entry:(0,o.assign)({intermediateValue:e=>({...e.context.intermediateValue,requiredUserInteraction:d.UserInteractionRequired.None,step:S.getDeviceStatusDAStateStep.ONBOARD_CHECK})}),always:[{guard:"isCurrentAppBolos",target:"GetOsVersion"},{target:"Success",actions:(0,o.assign)({_internalState:e=>({...e.context._internalState,onboarded:!0})})}]},GetOsVersion:{invoke:{src:"getOsVersion",onDone:{target:"OnboardingResultCheck",actions:(0,o.assign)({_internalState:e=>(0,m.isSuccessCommandResult)(e.event.output)?(G(e.event.output.data),{...e.context._internalState,osVersionMetadata:e.event.output.data}):{...e.context._internalState,error:e.event.output.error}})},onError:{target:"Error",actions:"assignErrorFromEvent"}}},OnboardingResultCheck:{always:[{guard:"hasError",target:"Error"},{guard:"isOnboardedFromOsVersion",target:"Success",actions:(0,o.assign)({_internalState:e=>({...e.context._internalState,onboarded:!0})})},{guard:"isAllowedNonOnboardedDevice",target:"Success"},{target:"Error",actions:"assignErrorDeviceNotOnboarded"}]},Success:{type:"final"},Error:{type:"final"}},output:e=>{const{context:n}=e,{error:s,currentApp:I,currentAppVersion:M}=n._internalState;return s?(0,p.Left)(s):(0,p.Right)({currentApp:I,currentAppVersion:M})}})}extractDependencies(t){return{getOsVersion:()=>t.sendCommand(new v.GetOsVersionCommand),getDeviceSessionState:()=>t.getDeviceSessionState(),setDeviceSessionState:i=>t.setDeviceSessionState(i)}}}0&&(module.exports={GetDeviceStatusDeviceAction});
2
2
  //# sourceMappingURL=GetDeviceStatusDeviceAction.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../../../../src/api/device-action/os/GetDeviceStatus/GetDeviceStatusDeviceAction.ts"],
4
- "sourcesContent": ["import { Left, Right } from \"purify-ts\";\nimport {\n EMPTY,\n from,\n interval,\n mergeMap,\n type Observable,\n of,\n switchMap,\n take,\n} from \"rxjs\";\nimport { timeout } from \"rxjs/operators\";\nimport { assign, fromObservable, fromPromise, setup } from \"xstate\";\n\nimport { isSuccessCommandResult } from \"@api/command/model/CommandResult\";\nimport {\n GetAppAndVersionCommand,\n type GetAppAndVersionCommandResult,\n} from \"@api/command/os/GetAppAndVersionCommand\";\nimport {\n GetOsVersionCommand,\n type GetOsVersionCommandResult,\n type GetOsVersionResponse,\n} from \"@api/command/os/GetOsVersionCommand\";\nimport { DeviceStatus } from \"@api/device/DeviceStatus\";\nimport { type InternalApi } from \"@api/device-action/DeviceAction\";\nimport { UserInteractionRequired } from \"@api/device-action/model/UserInteractionRequired\";\nimport { DEFAULT_UNLOCK_TIMEOUT_MS } from \"@api/device-action/os/Const\";\nimport {\n DeviceLockedError,\n DeviceNotOnboardedError,\n} from \"@api/device-action/os/Errors\";\nimport { type StateMachineTypes } from \"@api/device-action/xstate-utils/StateMachineTypes\";\nimport {\n type DeviceActionStateMachine,\n XStateDeviceAction,\n} from \"@api/device-action/xstate-utils/XStateDeviceAction\";\nimport {\n type DeviceSessionState,\n DeviceSessionStateType,\n type FirmwareVersion,\n} from \"@api/device-session/DeviceSessionState\";\nimport { isDashboardName, LEDGER_OS_NAME } from \"@api/utils/AppName\";\n\nimport {\n type GetDeviceStatusDAError,\n type GetDeviceStatusDAInput,\n type GetDeviceStatusDAIntermediateValue,\n type GetDeviceStatusDAOutput,\n getDeviceStatusDAStateStep,\n} from \"./types\";\n\ntype GetDeviceStatusMachineInternalState = {\n readonly onboarded: boolean;\n readonly locked: boolean;\n readonly currentApp: string | null;\n readonly currentAppVersion: string | null;\n readonly osVersionMetadata: GetOsVersionResponse | null;\n readonly error: GetDeviceStatusDAError | null;\n};\n\nexport type MachineDependencies = {\n readonly getAppAndVersion: () => Promise<GetAppAndVersionCommandResult>;\n readonly getOsVersion: () => Promise<GetOsVersionCommandResult>;\n readonly getDeviceSessionState: () => DeviceSessionState;\n readonly waitForDeviceUnlock: (args: {\n input: { unlockTimeout: number };\n }) => Observable<void>;\n readonly setDeviceSessionState: (\n state: DeviceSessionState,\n ) => DeviceSessionState;\n};\n\nconst firmwareVersionFromOsVersion = (\n data: GetOsVersionResponse,\n): FirmwareVersion => ({\n mcu: data.mcuSephVersion,\n bootloader: data.mcuBootloaderVersion,\n os: data.seVersion,\n metadata: data,\n});\n\nexport type ExtractMachineDependencies = (\n internalApi: InternalApi,\n) => MachineDependencies;\n\nexport class GetDeviceStatusDeviceAction extends XStateDeviceAction<\n GetDeviceStatusDAOutput,\n GetDeviceStatusDAInput,\n GetDeviceStatusDAError,\n GetDeviceStatusDAIntermediateValue,\n GetDeviceStatusMachineInternalState\n> {\n makeStateMachine(\n internalApi: InternalApi,\n ): DeviceActionStateMachine<\n GetDeviceStatusDAOutput,\n GetDeviceStatusDAInput,\n GetDeviceStatusDAError,\n GetDeviceStatusDAIntermediateValue,\n GetDeviceStatusMachineInternalState\n > {\n type types = StateMachineTypes<\n GetDeviceStatusDAOutput,\n GetDeviceStatusDAInput,\n GetDeviceStatusDAError,\n GetDeviceStatusDAIntermediateValue,\n GetDeviceStatusMachineInternalState\n >;\n\n const {\n getAppAndVersion,\n getOsVersion,\n getDeviceSessionState,\n setDeviceSessionState,\n waitForDeviceUnlock,\n } = this.extractDependencies(internalApi);\n\n const unlockTimeout = this.input.unlockTimeout ?? DEFAULT_UNLOCK_TIMEOUT_MS;\n const allowNonOnboardedDevice = this.input.allowNonOnboardedDevice ?? true;\n\n const updateSessionFromOsVersion = (data: GetOsVersionResponse) => {\n const currentState = getDeviceSessionState();\n if (currentState.sessionStateType === DeviceSessionStateType.Connected) {\n return;\n }\n setDeviceSessionState({\n ...currentState,\n firmwareVersion: firmwareVersionFromOsVersion(data),\n isSecureConnectionAllowed:\n data.secureElementFlags.isSecureConnectionAllowed,\n });\n };\n\n return setup({\n types: {\n input: {\n unlockTimeout,\n allowNonOnboardedDevice,\n } as types[\"input\"],\n context: {} as types[\"context\"],\n output: {} as types[\"output\"],\n },\n actors: {\n getAppAndVersion: fromPromise(getAppAndVersion),\n getOsVersion: fromPromise(getOsVersion),\n waitForDeviceUnlock: fromObservable(waitForDeviceUnlock),\n },\n guards: {\n isCurrentAppBolos: ({ context }) =>\n isDashboardName(context._internalState.currentApp),\n isOnboardedFromOsVersion: ({ context }) =>\n context._internalState.osVersionMetadata?.secureElementFlags\n .isOnboarded === true,\n isAllowedNonOnboardedDevice: ({ context }) => {\n const secureElementFlags =\n context._internalState.osVersionMetadata?.secureElementFlags;\n return (\n context.input.allowNonOnboardedDevice === true &&\n secureElementFlags?.isOnboarded === false\n );\n },\n isDeviceLocked: ({ context }) => context._internalState.locked,\n hasError: ({ context }) => context._internalState.error !== null,\n },\n actions: {\n assignErrorDeviceNotOnboarded: assign({\n _internalState: (_) => ({\n ..._.context._internalState,\n error: new DeviceNotOnboardedError(),\n }),\n }),\n assignErrorDeviceLocked: assign({\n _internalState: (_) => ({\n ..._.context._internalState,\n error: new DeviceLockedError(),\n }),\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.UnlockDevice,\n step: getDeviceStatusDAStateStep.UNLOCK_DEVICE,\n },\n }),\n assignErrorFromEvent: assign({\n _internalState: (_) => ({\n ..._.context._internalState,\n error: _.event[\"error\"], // NOTE: it should never happen, the error is not typed anymore here\n }),\n }),\n assignNoUserActionNeeded: assign({\n intermediateValue: (_) =>\n ({\n ..._.context.intermediateValue,\n requiredUserInteraction: UserInteractionRequired.None,\n }) satisfies types[\"context\"][\"intermediateValue\"],\n }),\n assignUserActionUnlockNeeded: assign({\n intermediateValue: (_) =>\n ({\n ..._.context.intermediateValue,\n requiredUserInteraction: UserInteractionRequired.UnlockDevice,\n step: getDeviceStatusDAStateStep.UNLOCK_DEVICE,\n }) satisfies types[\"context\"][\"intermediateValue\"],\n }),\n },\n }).createMachine({\n /** @xstate-layout N4IgpgJg5mDOIC5QHEwBcAiYBuBLAxmAMpoCGaArrFnoQIL5q4D2AdgHQ0FgBKYpEAJ4BiANoAGALqJQAB2axcTNjJAAPRAFoArAHZx7AIwAmQ7oCcugMyHzANmMAWYwBoQgxI8vsAHOJM+VuLmVj5e2gC+EW6omDjcJORUXPSMLBwA8qwARsykAE4QuKxQAMIAFmD4ANZiUqryisqsqhoImo4O7OGhPj4h5n6Obh4IunZ2RoZ+ena6nYaGUTHoKcRklNTxqc3sWbkFRSUVVbWihtJIII1K6a1aVtoGTxOOjtbv84YjiObik7ofPM7GFDP9jNofMsQLE1olNmsGLsADLMGrFMqVGp1S5yBS3FRXNqaOzadjiHx2KyORbzcRBczmH4IbTOdjaabaKmdGy6XSRaIw1bbdZJLa0MBI9LsVHo45Ys4XBr45r3dps-n0ubaGxgx6PZlWULkkLBGmDCzGYzQ2Ei+HJEVStjsACqsDA+SdrBdrAANmjqmthBA2GB2MVsMxqmG3R6vT7-TU1hJcdcVXciYgglZycYQiYqRTQoZtMynDmbM4aW8rHYzD4BSs4hL7eLuF7Xe7PWk2AmA0GPflmPl2LJfeQAGbDgC2nbjPe9fv7IpTyqaGdAbXmxnZPkMNNM820VuZ+8M7Dsb3MznpwW31sFtpbGwdEo7dFksjorAgADUPYobAnNiIasGGEZRmGT4JC+bY7NKH5fj+-75IBrDAdUCAQfg5DpCmq5XDcqqZmMjgGDY-yGJeejjFRzJ2P47DZoEJb+Hyx42sKz5ioiC7sIh35-gB6QYcIg7DqO45oFO+SztBhCtrxuwCchwlAQqWGsJGOHNPh9SEemhKbogdLsIMTjmPuNF1nYZaOBW+5OPu9l1oCjZCs2ME8Y6fGIb6BC4WwdDYKQuDjtkvq8HAFC+mgokEXi65GeoiBguYZJOPSJa6Hm1hGsyuglkxxiUjYVjXlq7nyaKCI+cpn7+Tp6TBaF4WRXwsAxXFCpiEqBlJS0JFAo4vg+BCe55e8-QFUVVglVShjlWRtZ2FEgqsMwEBwKo1WKXVG5pgNaokmRZmQg4fyLHR7ieCNpjGPyx7aNo6UNo4nGeQpsFKdKax8AIoyJQSg3Ge0L07q9F3+Istk3Qg1IjUaZ7GNS-LlU4H1wt9+3OvseSFBiGFrsDx01mZ15mHooReFaVj0fZ5Jci5zissYIKY3a2NvnxsrVITCrE8RoMdDucxWgx1jpZCELDHDgKTC9jg6mNXKLDSHPcbV3O7LG3bNH2SYioLB3EmCI1-HuVL6Cj4hU6eNjsIVD3UrWfKXVCj5cV5Wvtr5n6CShaFE-1JMkWzPgXpCjh+Faw3Mjq5jdOlJhGvo-RzRr3uvr79VjgFzQtWFpARVFnWxcHQNCylCBm+eKPjJL4jWMEdNww4O46vSFVsfyD5Nlj3na9KRAUPghCwPAIdV20QIR7e-RzOYbNK98cN7ndgR-BSzgo+YmdfYPOfSgAovkQ75MbyVtItehmSrJgcijz2uHD+pmXyQSQnyVLs2tQA */\n id: \"GetDeviceStatusDeviceAction\",\n initial: \"DeviceReady\",\n context: (_) => {\n const sessionState = getDeviceSessionState();\n const { sessionStateType } = sessionState;\n return {\n input: {\n unlockTimeout: _.input.unlockTimeout,\n allowNonOnboardedDevice: _.input.allowNonOnboardedDevice ?? true,\n },\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.None,\n step: getDeviceStatusDAStateStep.ONBOARD_CHECK,\n },\n _internalState: {\n onboarded: false,\n locked: false,\n currentApp:\n sessionStateType ===\n DeviceSessionStateType.ReadyWithoutSecureChannel\n ? sessionState.currentApp.name\n : null,\n currentAppVersion: null,\n osVersionMetadata: null,\n error: null,\n },\n };\n },\n states: {\n DeviceReady: {\n always: {\n target: \"AppAndVersionCheck\",\n },\n },\n AppAndVersionCheck: {\n // We check the current app and version using the getAppAndVersion\n // command. This command is supported both on the dashboard (BOLOS)\n // and inside applications, so it is used to determine the currently\n // running app before deciding whether to read the OS version.\n invoke: {\n src: \"getAppAndVersion\",\n onDone: {\n target: \"ApplicationAvailableResultCheck\",\n actions: assign({\n _internalState: (_) => {\n if (isSuccessCommandResult(_.event.output)) {\n const state: DeviceSessionState = getDeviceSessionState();\n if (\n state.sessionStateType !==\n DeviceSessionStateType.Connected\n ) {\n // Update the current app\n setDeviceSessionState({\n ...state,\n currentApp: _.event.output.data,\n });\n } else {\n // The device can be set to Ready if GetAppAndVersionCommand was successful.\n // The firmware version and secure connection flag are enriched later from\n // the OS version, which can only be read on the dashboard.\n setDeviceSessionState({\n deviceModelId: state.deviceModelId,\n sessionStateType:\n DeviceSessionStateType.ReadyWithoutSecureChannel,\n deviceStatus: DeviceStatus.CONNECTED,\n currentApp: _.event.output.data,\n installedApps: [],\n isSecureConnectionAllowed: false,\n });\n }\n return {\n ..._.context._internalState,\n locked: false,\n currentApp: _.event.output.data.name,\n currentAppVersion: _.event.output.data.version,\n };\n }\n if (\"errorCode\" in _.event.output.error) {\n if (_.event.output.error.errorCode === \"5515\") {\n // Locked device error\n return {\n ..._.context._internalState,\n locked: true,\n };\n } else if (_.event.output.error.errorCode === \"6e00\") {\n // CLA not supported\n // GetAppAndVersion should always be supported by the firmware or any app.\n // But on old firmware versions, that APDU was not supported in the dashboard.\n // On those firmwares, it fails with CLA_NOT_SUPPORTED in BOLOS, and INS_NOT_SUPPORTED\n // in applications. Therefore if CLA is not supported, we can consider we're on the\n // dashboard on an old firmware. We should therefore return that information to\n // ensure the user can still update his firmware and is not blocked at this step.\n return {\n ..._.context._internalState,\n locked: false,\n currentApp: LEDGER_OS_NAME,\n currentAppVersion: \"0.0.0\",\n };\n }\n }\n return {\n ..._.context._internalState,\n error: _.event.output.error,\n };\n },\n }),\n },\n onError: {\n target: \"Error\",\n actions: \"assignErrorFromEvent\",\n },\n },\n },\n ApplicationAvailableResultCheck: {\n always: [\n {\n guard: \"hasError\",\n target: \"Error\",\n },\n {\n target: \"UserActionUnlockDevice\",\n guard: \"isDeviceLocked\",\n },\n {\n target: \"OnboardingCheck\",\n },\n ],\n },\n OnboardingCheck: {\n always: [\n {\n // The OS version (and thus the onboarding flag) can only be read\n // on the dashboard. If we are inside an application, fetching it\n // would fail, so we only fetch it when the current app is BOLOS.\n guard: \"isCurrentAppBolos\",\n target: \"GetOsVersion\",\n },\n {\n // A non-BOLOS application can only run on an onboarded device, so\n // if an app is open we can safely consider the device onboarded\n // without reading the OS version.\n target: \"Success\",\n actions: assign({\n _internalState: (_) => ({\n ..._.context._internalState,\n onboarded: true,\n }),\n }),\n },\n ],\n },\n GetOsVersion: {\n invoke: {\n src: \"getOsVersion\",\n onDone: {\n target: \"OnboardingResultCheck\",\n actions: assign({\n _internalState: (_) => {\n if (isSuccessCommandResult(_.event.output)) {\n updateSessionFromOsVersion(_.event.output.data);\n return {\n ..._.context._internalState,\n osVersionMetadata: _.event.output.data,\n };\n }\n return {\n ..._.context._internalState,\n error: _.event.output.error,\n };\n },\n }),\n },\n onError: {\n target: \"Error\",\n actions: \"assignErrorFromEvent\",\n },\n },\n },\n OnboardingResultCheck: {\n always: [\n {\n guard: \"hasError\",\n target: \"Error\",\n },\n {\n guard: \"isOnboardedFromOsVersion\",\n target: \"Success\",\n actions: assign({\n _internalState: (_) => ({\n ..._.context._internalState,\n onboarded: true,\n }),\n }),\n },\n {\n guard: \"isAllowedNonOnboardedDevice\",\n target: \"Success\",\n },\n {\n target: \"Error\",\n actions: \"assignErrorDeviceNotOnboarded\",\n },\n ],\n },\n UserActionUnlockDevice: {\n // we wait for the device to be unlocked (default timeout is 15s)\n entry: \"assignUserActionUnlockNeeded\",\n exit: \"assignNoUserActionNeeded\",\n invoke: {\n id: \"UserActionUnlockDevice\",\n src: \"waitForDeviceUnlock\",\n input: (_) => ({\n unlockTimeout,\n }),\n onDone: {\n target: \"AppAndVersionCheck\",\n actions: assign({\n _internalState: (_) => ({\n ..._.context._internalState,\n locked: false,\n }),\n }),\n },\n onError: {\n target: \"Error\",\n actions: \"assignErrorDeviceLocked\",\n },\n },\n },\n Success: {\n type: \"final\",\n },\n Error: {\n type: \"final\",\n },\n },\n output: (args) => {\n // TODO: instead we should rely on the current state (\"Success\" or \"Error\")\n const { context } = args;\n const { error, currentApp, currentAppVersion } = context._internalState;\n if (error) {\n return Left(error);\n }\n return Right<GetDeviceStatusDAOutput>({\n currentApp: currentApp!,\n currentAppVersion: currentAppVersion!,\n });\n },\n });\n }\n\n extractDependencies(internalApi: InternalApi): MachineDependencies {\n const getAppAndVersion = () => {\n return internalApi.sendCommand(new GetAppAndVersionCommand());\n };\n\n const waitForDeviceUnlock = ({\n input,\n }: {\n input: { unlockTimeout: number };\n }) =>\n interval(1000).pipe(\n switchMap(() =>\n from(internalApi.sendCommand(new GetAppAndVersionCommand())),\n ),\n mergeMap((output) => {\n const isLocked =\n !isSuccessCommandResult(output) &&\n \"errorCode\" in output.error &&\n output.error.errorCode === \"5515\";\n if (isLocked) {\n return EMPTY; // Continue the polling\n }\n return of(undefined); // Complete the observable\n }),\n take(1),\n timeout(input.unlockTimeout),\n );\n\n return {\n getAppAndVersion,\n getOsVersion: () => internalApi.sendCommand(new GetOsVersionCommand()),\n waitForDeviceUnlock,\n getDeviceSessionState: () => internalApi.getDeviceSessionState(),\n setDeviceSessionState: (state: DeviceSessionState) =>\n internalApi.setDeviceSessionState(state),\n };\n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d,CAAE,MAAAC,EAAO,WAAAC,EAAY,kBAAAC,CAAkB,EAAIT,EAAQ,eACzD,OAAIO,KACK,QAAKA,CAAK,KAEZ,SAA+B,CACpC,WAAYC,EACZ,kBAAmBC,CACrB,CAAC,CACH,CACF,CAAC,CACH,CAEA,oBAAoBnB,EAA+C,CA4BjE,MAAO,CACL,iBA5BuB,IAChBA,EAAY,YAAY,IAAI,yBAAyB,EA4B5D,aAAc,IAAMA,EAAY,YAAY,IAAI,qBAAqB,EACrE,oBA1B0B,CAAC,CAC3B,MAAAoB,CACF,OAGE,YAAS,GAAI,EAAE,QACb,aAAU,OACR,QAAKpB,EAAY,YAAY,IAAI,yBAAyB,CAAC,CAC7D,KACA,YAAUqB,GAEN,IAAC,0BAAuBA,CAAM,GAC9B,cAAeA,EAAO,OACtBA,EAAO,MAAM,YAAc,OAEpB,WAEF,MAAG,MAAS,CACpB,KACD,QAAK,CAAC,KACN,WAAQD,EAAM,aAAa,CAC7B,EAMA,sBAAuB,IAAMpB,EAAY,sBAAsB,EAC/D,sBAAwBe,GACtBf,EAAY,sBAAsBe,CAAK,CAC3C,CACF,CACF",
6
- "names": ["GetDeviceStatusDeviceAction_exports", "__export", "GetDeviceStatusDeviceAction", "__toCommonJS", "import_purify_ts", "import_rxjs", "import_operators", "import_xstate", "import_CommandResult", "import_GetAppAndVersionCommand", "import_GetOsVersionCommand", "import_DeviceStatus", "import_UserInteractionRequired", "import_Const", "import_Errors", "import_XStateDeviceAction", "import_DeviceSessionState", "import_AppName", "import_types", "firmwareVersionFromOsVersion", "data", "internalApi", "getAppAndVersion", "getOsVersion", "getDeviceSessionState", "setDeviceSessionState", "waitForDeviceUnlock", "unlockTimeout", "allowNonOnboardedDevice", "updateSessionFromOsVersion", "currentState", "context", "secureElementFlags", "_", "sessionState", "sessionStateType", "state", "args", "error", "currentApp", "currentAppVersion", "input", "output"]
4
+ "sourcesContent": ["import { Left, Right } from \"purify-ts\";\nimport { assign, fromPromise, setup } from \"xstate\";\n\nimport { isSuccessCommandResult } from \"@api/command/model/CommandResult\";\nimport {\n GetOsVersionCommand,\n type GetOsVersionCommandResult,\n type GetOsVersionResponse,\n} from \"@api/command/os/GetOsVersionCommand\";\nimport { DeviceStatus } from \"@api/device/DeviceStatus\";\nimport { type InternalApi } from \"@api/device-action/DeviceAction\";\nimport { UserInteractionRequired } from \"@api/device-action/model/UserInteractionRequired\";\nimport { DEFAULT_UNLOCK_TIMEOUT_MS } from \"@api/device-action/os/Const\";\nimport { DeviceNotOnboardedError } from \"@api/device-action/os/Errors\";\nimport { WaitForAppAndVersionDeviceAction } from \"@api/device-action/os/WaitForAppAndVersion/WaitForAppAndVersionDeviceAction\";\nimport { type StateMachineTypes } from \"@api/device-action/xstate-utils/StateMachineTypes\";\nimport {\n type DeviceActionStateMachine,\n XStateDeviceAction,\n} from \"@api/device-action/xstate-utils/XStateDeviceAction\";\nimport {\n type DeviceSessionState,\n DeviceSessionStateType,\n type FirmwareVersion,\n} from \"@api/device-session/DeviceSessionState\";\nimport { isDashboardName } from \"@api/utils/AppName\";\n\nimport {\n type GetDeviceStatusDAError,\n type GetDeviceStatusDAInput,\n type GetDeviceStatusDAIntermediateValue,\n type GetDeviceStatusDAOutput,\n getDeviceStatusDAStateStep,\n} from \"./types\";\n\ntype GetDeviceStatusMachineInternalState = {\n readonly onboarded: boolean;\n readonly currentApp: string | null;\n readonly currentAppVersion: string | null;\n readonly osVersionMetadata: GetOsVersionResponse | null;\n readonly error: GetDeviceStatusDAError | null;\n};\n\nexport type MachineDependencies = {\n readonly getOsVersion: () => Promise<GetOsVersionCommandResult>;\n readonly getDeviceSessionState: () => DeviceSessionState;\n readonly setDeviceSessionState: (\n state: DeviceSessionState,\n ) => DeviceSessionState;\n};\n\nconst firmwareVersionFromOsVersion = (\n data: GetOsVersionResponse,\n): FirmwareVersion => ({\n mcu: data.mcuSephVersion,\n bootloader: data.mcuBootloaderVersion,\n os: data.seVersion,\n metadata: data,\n});\n\nexport type ExtractMachineDependencies = (\n internalApi: InternalApi,\n) => MachineDependencies;\n\nexport class GetDeviceStatusDeviceAction extends XStateDeviceAction<\n GetDeviceStatusDAOutput,\n GetDeviceStatusDAInput,\n GetDeviceStatusDAError,\n GetDeviceStatusDAIntermediateValue,\n GetDeviceStatusMachineInternalState\n> {\n makeStateMachine(\n internalApi: InternalApi,\n ): DeviceActionStateMachine<\n GetDeviceStatusDAOutput,\n GetDeviceStatusDAInput,\n GetDeviceStatusDAError,\n GetDeviceStatusDAIntermediateValue,\n GetDeviceStatusMachineInternalState\n > {\n type types = StateMachineTypes<\n GetDeviceStatusDAOutput,\n GetDeviceStatusDAInput,\n GetDeviceStatusDAError,\n GetDeviceStatusDAIntermediateValue,\n GetDeviceStatusMachineInternalState\n >;\n\n const { getOsVersion, getDeviceSessionState, setDeviceSessionState } =\n this.extractDependencies(internalApi);\n\n const unlockTimeout = this.input.unlockTimeout ?? DEFAULT_UNLOCK_TIMEOUT_MS;\n const allowNonOnboardedDevice = this.input.allowNonOnboardedDevice ?? true;\n\n const updateSessionFromOsVersion = (data: GetOsVersionResponse) => {\n const currentState = getDeviceSessionState();\n if (currentState.sessionStateType === DeviceSessionStateType.Connected) {\n return;\n }\n setDeviceSessionState({\n ...currentState,\n firmwareVersion: firmwareVersionFromOsVersion(data),\n isSecureConnectionAllowed:\n data.secureElementFlags.isSecureConnectionAllowed,\n });\n };\n\n const waitForAppAndVersion = new WaitForAppAndVersionDeviceAction({\n input: {\n unlockTimeout,\n },\n }).makeStateMachine(internalApi);\n\n return setup({\n types: {\n input: {\n unlockTimeout,\n allowNonOnboardedDevice,\n } as types[\"input\"],\n context: {} as types[\"context\"],\n output: {} as types[\"output\"],\n },\n actors: {\n waitForAppAndVersion,\n getOsVersion: fromPromise(getOsVersion),\n },\n guards: {\n isCurrentAppBolos: ({ context }) =>\n isDashboardName(context._internalState.currentApp),\n isOnboardedFromOsVersion: ({ context }) =>\n context._internalState.osVersionMetadata?.secureElementFlags\n .isOnboarded === true,\n isAllowedNonOnboardedDevice: ({ context }) => {\n const secureElementFlags =\n context._internalState.osVersionMetadata?.secureElementFlags;\n return (\n context.input.allowNonOnboardedDevice === true &&\n secureElementFlags?.isOnboarded === false\n );\n },\n hasError: ({ context }) => context._internalState.error !== null,\n },\n actions: {\n assignErrorDeviceNotOnboarded: assign({\n _internalState: (_) => ({\n ..._.context._internalState,\n error: new DeviceNotOnboardedError(),\n }),\n }),\n assignErrorFromEvent: assign({\n _internalState: (_) => ({\n ..._.context._internalState,\n error: _.event[\"error\"], // NOTE: it should never happen, the error is not typed anymore here\n }),\n }),\n },\n }).createMachine({\n /** @xstate-layout N4IgpgJg5mDOIC5QHEwBcAiYBuBLAxmAMpoCGaArrFnoQIL5q4D2AdgHQ0FgBKYpEAJ4BiANoAGALqJQAB2axcTNjJAAPRAFoArAHZx7AIwAmQ7oCcugMyHzANmMAWYwBoQgxI8vsAHOJM+VuLmVj5e2gC+EW6omDjcJORUXPSMLBwA8qwARsykAE4QuKxQAMIAFmD4ANZiUqryisqsqhoImo4O7OGhPj4h5n6Obh4IunZ2RoZ+ena6nYaGUTHoKcRklNTxqc3sWbkFRSUVVbWihtJIII1K6a1aVtoGTxOOjtbv84YjiObik7ofPM7GFDP9jNofMsQLE1olNmsGLsADLMGrFMqVGp1S5yBS3FRXNqaOzadjiHx2KyORbzcRBczmH4IbTOdjaabaKmdGy6XSRaIw1bbdZJLa0MBI9LsVHo45Ys4XBr45r3dps-n0ubaGxgx6PZlWULkkLBGmDCzGYzQ2Ei+HJEVStjsACqsDA+SdrBdrAANmjqmthBA2GB2MVsMxqmG3R6vT7-TU1hJcdcVXciYgglZycYQiYqRTQoZtMynDmbM4aW8rHYzD4BSs4hL7eLuF7Xe7PWk2AmA0GPflmPl2LJfeQAGbDgC2nbjPe9fv7IpTyqaGdAbXmxnZPkMNNM820VuZ+8M7Dsb3MznpwW31sFtpbGwdEo7dFksjorAgADUPYobAnNiIasGGEZRmGT4JC+bY7NKH5fj+-75IBrDAdUCAQfg5DpCmq5XDcqqZmMjgGDY-yGJeejjFRzJ2P47DZoEJb+Hyx42sKz5ioiC7sIh35-gB6QYcIg7DqO45oFO+SztBhCtrxuwCchwlAQqWGsJGOHNPh9SEemhKbogdLsIMTjmPuNF1nYZaOBW+5OPu9l1oCjZCs2ME8Y6fGIb6BC4WwdDYKQuDjtkvq8HAFC+mgokEXi65GeoiBguYZJOPSJa6Hm1hGsyuglkxxiUjYVjXlq7nyaKCI+cpn7+Tp6TBaF4WRXwsAxXFCpiEqBlJS0JFAo4vg+BCe55e8-QFUVVglVShjlWRtZ2FEgqsMwEBwKo1WKXVG5pgNaokmRZmQg4fyLHR7ieCNpjGPyx7aNo6UNo4nGeQpsFKdKax8AIoyJQSg3Ge0L07q9F3+Istk3Qg1IjUaZ7GNS-LlU4H1wt9+3OvseSFBiGFrsDx01mZ15mHooReFaVj0fZ5Jci5zissYIKY3a2NvnxsrVITCrE8RoMdDucxWgx1jpZCELDHDgKTC9jg6mNXKLDSHPcbV3O7LG3bNH2SYioLB3EmCI1-HuVL6Cj4hU6eNjsIVD3UrWfKXVCj5cV5Wvtr5n6CShaFE-1JMkWzPgXpCjh+Faw3Mjq5jdOlJhGvo-RzRr3uvr79VjgFzQtWFpARVFnWxcHQNCylCBm+eKPjJL4jWMEdNww4O46vSFVsfyD5Nlj3na9KRAUPghCwPAIdV20QIR7e-RzOYbNK98cN7ndgR-BSzgo+YmdfYPOfSgAovkQ75MbyVtItehmSrJgcijz2uHD+pmXyQSQnyVLs2tQA */\n id: \"GetDeviceStatusDeviceAction\",\n initial: \"DeviceReady\",\n context: (_) => {\n const sessionState = getDeviceSessionState();\n const { sessionStateType } = sessionState;\n return {\n input: {\n unlockTimeout: _.input.unlockTimeout,\n allowNonOnboardedDevice: _.input.allowNonOnboardedDevice ?? true,\n },\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.None,\n step: getDeviceStatusDAStateStep.WAIT_FOR_APP_AND_VERSION,\n },\n _internalState: {\n onboarded: false,\n currentApp:\n sessionStateType ===\n DeviceSessionStateType.ReadyWithoutSecureChannel\n ? sessionState.currentApp.name\n : null,\n currentAppVersion: null,\n osVersionMetadata: null,\n error: null,\n },\n };\n },\n states: {\n DeviceReady: {\n always: {\n target: \"WaitForAppAndVersion\",\n },\n },\n WaitForAppAndVersion: {\n // We check the current app and version using the getAppAndVersion\n // command. This command is supported both on the dashboard (BOLOS)\n // and inside applications, so it is used to determine the currently\n // running app before deciding whether to read the OS version.\n invoke: {\n src: \"waitForAppAndVersion\",\n input: (_) => ({\n unlockTimeout: _.context.input.unlockTimeout,\n }),\n onSnapshot: {\n actions: assign({\n intermediateValue: (_) => ({\n ..._.context.intermediateValue,\n requiredUserInteraction:\n _.event.snapshot.context.intermediateValue\n .requiredUserInteraction,\n }),\n }),\n },\n onDone: {\n target: \"WaitForAppAndVersionResultCheck\",\n actions: assign({\n _internalState: (_): GetDeviceStatusMachineInternalState => {\n return _.event.output.caseOf<GetDeviceStatusMachineInternalState>(\n {\n Left: (error) => ({\n ..._.context._internalState,\n error,\n }),\n Right: (output) => {\n const state: DeviceSessionState =\n getDeviceSessionState();\n if (\n state.sessionStateType !==\n DeviceSessionStateType.Connected\n ) {\n // Update the current app\n setDeviceSessionState({\n ...state,\n currentApp: output,\n });\n } else {\n setDeviceSessionState({\n deviceModelId: state.deviceModelId,\n sessionStateType:\n DeviceSessionStateType.ReadyWithoutSecureChannel,\n deviceStatus: DeviceStatus.CONNECTED,\n currentApp: output,\n installedApps: [],\n isSecureConnectionAllowed: false,\n });\n }\n return {\n ..._.context._internalState,\n currentApp: output.name,\n currentAppVersion: output.version,\n };\n },\n },\n );\n },\n }),\n },\n onError: {\n target: \"Error\",\n actions: \"assignErrorFromEvent\",\n },\n },\n },\n WaitForAppAndVersionResultCheck: {\n always: [\n {\n guard: \"hasError\",\n target: \"Error\",\n },\n {\n target: \"OnboardingCheck\",\n },\n ],\n },\n OnboardingCheck: {\n entry: assign({\n intermediateValue: (_) => ({\n ..._.context.intermediateValue,\n requiredUserInteraction: UserInteractionRequired.None,\n step: getDeviceStatusDAStateStep.ONBOARD_CHECK,\n }),\n }),\n always: [\n {\n // The OS version (and thus the onboarding flag) can only be read\n // on the dashboard. If we are inside an application, fetching it\n // would fail, so we only fetch it when the current app is BOLOS.\n guard: \"isCurrentAppBolos\",\n target: \"GetOsVersion\",\n },\n {\n // A non-BOLOS application can only run on an onboarded device, so\n // if an app is open we can safely consider the device onboarded\n // without reading the OS version.\n target: \"Success\",\n actions: assign({\n _internalState: (_) => ({\n ..._.context._internalState,\n onboarded: true,\n }),\n }),\n },\n ],\n },\n GetOsVersion: {\n invoke: {\n src: \"getOsVersion\",\n onDone: {\n target: \"OnboardingResultCheck\",\n actions: assign({\n _internalState: (_) => {\n if (isSuccessCommandResult(_.event.output)) {\n updateSessionFromOsVersion(_.event.output.data);\n return {\n ..._.context._internalState,\n osVersionMetadata: _.event.output.data,\n };\n }\n return {\n ..._.context._internalState,\n error: _.event.output.error,\n };\n },\n }),\n },\n onError: {\n target: \"Error\",\n actions: \"assignErrorFromEvent\",\n },\n },\n },\n OnboardingResultCheck: {\n always: [\n {\n guard: \"hasError\",\n target: \"Error\",\n },\n {\n guard: \"isOnboardedFromOsVersion\",\n target: \"Success\",\n actions: assign({\n _internalState: (_) => ({\n ..._.context._internalState,\n onboarded: true,\n }),\n }),\n },\n {\n guard: \"isAllowedNonOnboardedDevice\",\n target: \"Success\",\n },\n {\n target: \"Error\",\n actions: \"assignErrorDeviceNotOnboarded\",\n },\n ],\n },\n Success: {\n type: \"final\",\n },\n Error: {\n type: \"final\",\n },\n },\n output: (args) => {\n // TODO: instead we should rely on the current state (\"Success\" or \"Error\")\n const { context } = args;\n const { error, currentApp, currentAppVersion } = context._internalState;\n if (error) {\n return Left(error);\n }\n return Right<GetDeviceStatusDAOutput>({\n currentApp: currentApp!,\n currentAppVersion: currentAppVersion!,\n });\n },\n });\n }\n\n extractDependencies(internalApi: InternalApi): MachineDependencies {\n return {\n getOsVersion: () => internalApi.sendCommand(new GetOsVersionCommand()),\n getDeviceSessionState: () => internalApi.getDeviceSessionState(),\n setDeviceSessionState: (state: DeviceSessionState) =>\n internalApi.setDeviceSessionState(state),\n };\n }\n}\n"],
5
+ "mappings": "yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,iCAAAE,IAAA,eAAAC,EAAAH,GAAA,IAAAI,EAA4B,qBAC5BC,EAA2C,kBAE3CC,EAAuC,4CACvCC,EAIO,+CACPC,EAA6B,oCAE7BC,EAAwC,4DACxCC,EAA0C,uCAC1CC,EAAwC,wCACxCC,EAAiD,uFAEjDC,EAGO,8DACPC,EAIO,kDACPC,EAAgC,8BAEhCC,EAMO,mBAkBP,MAAMC,EACJC,IACqB,CACrB,IAAKA,EAAK,eACV,WAAYA,EAAK,qBACjB,GAAIA,EAAK,UACT,SAAUA,CACZ,GAMO,MAAMhB,UAAoC,oBAM/C,CACA,iBACEiB,EAOA,CASA,KAAM,CAAE,aAAAC,EAAc,sBAAAC,EAAuB,sBAAAC,CAAsB,EACjE,KAAK,oBAAoBH,CAAW,EAEhCI,EAAgB,KAAK,MAAM,eAAiB,4BAC5CC,EAA0B,KAAK,MAAM,yBAA2B,GAEhEC,EAA8BP,GAA+B,CACjE,MAAMQ,EAAeL,EAAsB,EACvCK,EAAa,mBAAqB,yBAAuB,WAG7DJ,EAAsB,CACpB,GAAGI,EACH,gBAAiBT,EAA6BC,CAAI,EAClD,0BACEA,EAAK,mBAAmB,yBAC5B,CAAC,CACH,EAEMS,EAAuB,IAAI,mCAAiC,CAChE,MAAO,CACL,cAAAJ,CACF,CACF,CAAC,EAAE,iBAAiBJ,CAAW,EAE/B,SAAO,SAAM,CACX,MAAO,CACL,MAAO,CACL,cAAAI,EACA,wBAAAC,CACF,EACA,QAAS,CAAC,EACV,OAAQ,CAAC,CACX,EACA,OAAQ,CACN,qBAAAG,EACA,gBAAc,eAAYP,CAAY,CACxC,EACA,OAAQ,CACN,kBAAmB,CAAC,CAAE,QAAA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AAE,MAAM,OAAO,IACpC,GAEK,CACL,GAAGA,EAAE,QAAQ,eACb,MAAOA,EAAE,MAAM,OAAO,KACxB,CAEJ,CAAC,CACH,EACA,QAAS,CACP,OAAQ,QACR,QAAS,sBACX,CACF,CACF,EACA,sBAAuB,CACrB,OAAQ,CACN,CACE,MAAO,WACP,OAAQ,OACV,EACA,CACE,MAAO,2BACP,OAAQ,UACR,WAAS,UAAO,CACd,eAAiBA,IAAO,CACtB,GAAGA,EAAE,QAAQ,eACb,UAAW,EACb,EACF,CAAC,CACH,EACA,CACE,MAAO,8BACP,OAAQ,SACV,EACA,CACE,OAAQ,QACR,QAAS,+BACX,CACF,CACF,EACA,QAAS,CACP,KAAM,OACR,EACA,MAAO,CACL,KAAM,OACR,CACF,EACA,OAASM,GAAS,CAEhB,KAAM,CAAE,QAAAR,CAAQ,EAAIQ,EACd,CAAE,MAAAH,EAAO,WAAAI,EAAY,kBAAAC,CAAkB,EAAIV,EAAQ,eACzD,OAAIK,KACK,QAAKA,CAAK,KAEZ,SAA+B,CACpC,WAAYI,EACZ,kBAAmBC,CACrB,CAAC,CACH,CACF,CAAC,CACH,CAEA,oBAAoBnB,EAA+C,CACjE,MAAO,CACL,aAAc,IAAMA,EAAY,YAAY,IAAI,qBAAqB,EACrE,sBAAuB,IAAMA,EAAY,sBAAsB,EAC/D,sBAAwBgB,GACtBhB,EAAY,sBAAsBgB,CAAK,CAC3C,CACF,CACF",
6
+ "names": ["GetDeviceStatusDeviceAction_exports", "__export", "GetDeviceStatusDeviceAction", "__toCommonJS", "import_purify_ts", "import_xstate", "import_CommandResult", "import_GetOsVersionCommand", "import_DeviceStatus", "import_UserInteractionRequired", "import_Const", "import_Errors", "import_WaitForAppAndVersionDeviceAction", "import_XStateDeviceAction", "import_DeviceSessionState", "import_AppName", "import_types", "firmwareVersionFromOsVersion", "data", "internalApi", "getOsVersion", "getDeviceSessionState", "setDeviceSessionState", "unlockTimeout", "allowNonOnboardedDevice", "updateSessionFromOsVersion", "currentState", "waitForAppAndVersion", "context", "secureElementFlags", "_", "sessionState", "sessionStateType", "error", "output", "state", "args", "currentApp", "currentAppVersion"]
7
7
  }
@@ -1,2 +1,2 @@
1
- "use strict";var k=require("rxjs"),w=require("../../../command/model/CommandResult"),f=require("../../../command/os/__mocks__/GetOsVersionCommand"),E=require("../../../command/utils/GlobalCommandError"),l=require("../../../device/DeviceModel"),i=require("../../../device/DeviceStatus"),a=require("../../../device-action/__test-utils__/makeInternalApi"),u=require("../../../device-action/__test-utils__/testDeviceActionStates"),c=require("../../../device-action/model/DeviceActionState"),L=require("../../../device-action/model/UserInteractionRequired"),C=require("../../../device-action/os/Errors"),s=require("../../../device-session/DeviceSessionState"),d=require("./GetDeviceStatusDeviceAction"),P=require("./types");const h=(p={},D=l.DeviceModelId.NANO_X)=>(0,w.CommandResultFactory)({data:(0,f.getOsVersionCommandResponseMockBuilder)(D,p)}),O=(p,D)=>(0,w.CommandResultFactory)({data:{name:p,version:D}}),I=()=>(0,w.CommandResultFactory)({error:new E.GlobalCommandError({...E.GLOBAL_ERRORS[5515],errorCode:"5515"})}),S=()=>({intermediateValue:{requiredUserInteraction:L.UserInteractionRequired.None,step:P.getDeviceStatusDAStateStep.ONBOARD_CHECK},status:c.DeviceActionStatus.Pending}),V=()=>[S(),S()],b=()=>({intermediateValue:{requiredUserInteraction:L.UserInteractionRequired.UnlockDevice,step:P.getDeviceStatusDAStateStep.UNLOCK_DEVICE},status:c.DeviceActionStatus.Pending}),x=()=>({intermediateValue:{requiredUserInteraction:L.UserInteractionRequired.None,step:P.getDeviceStatusDAStateStep.UNLOCK_DEVICE},status:c.DeviceActionStatus.Pending});describe("GetDeviceStatusDeviceAction",()=>{const p=vi.fn(),D=vi.fn(),v=vi.fn(),y=vi.fn(),g=vi.fn();function A(){return{getAppAndVersion:p,getOsVersion:D,getDeviceSessionState:v,waitForDeviceUnlock:y,setDeviceSessionState:g}}const{sendCommand:R,getDeviceSessionState:N,getDeviceSessionStateObservable:G}=(0,a.makeDeviceActionInternalApiMock)();beforeEach(()=>{vi.resetAllMocks(),D.mockResolvedValue(h())}),describe("without overriding `extractDependencies`",()=>{it("should run the device action with an unlocked device",()=>new Promise((n,o)=>{const e=new d.GetDeviceStatusDeviceAction({input:{unlockTimeout:500}});N.mockReturnValue({sessionStateType:s.DeviceSessionStateType.Connected,deviceStatus:i.DeviceStatus.CONNECTED,deviceModelId:l.DeviceModelId.NANO_X}),R.mockImplementation(r=>r.name==="getOsVersion"?Promise.resolve(h()):Promise.resolve(O("BOLOS","1.0.0")));const t=[...V(),{output:{currentApp:"BOLOS",currentAppVersion:"1.0.0"},status:c.DeviceActionStatus.Completed}];(0,u.testDeviceActionStates)(e,t,(0,a.makeDeviceActionInternalApiMock)(),{onDone:n,onError:o})})),it("should run the device action with a locked device",()=>new Promise((n,o)=>{const e=new d.GetDeviceStatusDeviceAction({input:{unlockTimeout:1500}});N.mockReturnValue({sessionStateType:s.DeviceSessionStateType.ReadyWithoutSecureChannel,deviceStatus:i.DeviceStatus.LOCKED,currentApp:{name:"mockedCurrentApp",version:"1.0.0"},installedApps:[],deviceModelId:l.DeviceModelId.NANO_X,isSecureConnectionAllowed:!1});let t=0;R.mockImplementation(m=>m.name==="getOsVersion"?Promise.resolve(h()):(t+=1,t===1?Promise.resolve(I()):Promise.resolve(O("BOLOS","1.0.0"))));const r=[S(),b(),x(),x(),{output:{currentApp:"BOLOS",currentAppVersion:"1.0.0"},status:c.DeviceActionStatus.Completed}];(0,u.testDeviceActionStates)(e,r,(0,a.makeDeviceActionInternalApiMock)(),{onDone:n,onError:o})})),it("should timeout with a locked device",()=>new Promise((n,o)=>{const e=new d.GetDeviceStatusDeviceAction({input:{unlockTimeout:200}});N.mockReturnValue({sessionStateType:s.DeviceSessionStateType.ReadyWithoutSecureChannel,deviceStatus:i.DeviceStatus.LOCKED,currentApp:{name:"mockedCurrentApp",version:"1.0.0"},installedApps:[],deviceModelId:l.DeviceModelId.NANO_X,isSecureConnectionAllowed:!1}),R.mockImplementation(r=>r.name==="getOsVersion"?Promise.resolve(h()):Promise.resolve(I()));const t=[S(),b(),{error:new C.DeviceLockedError("Device locked."),status:c.DeviceActionStatus.Error}];(0,u.testDeviceActionStates)(e,t,(0,a.makeDeviceActionInternalApiMock)(),{onDone:n,onError:o})})),it("should run the device action with an old firmware not supporting GetAppAndVersion",()=>new Promise((n,o)=>{const e=new d.GetDeviceStatusDeviceAction({input:{unlockTimeout:500}});N.mockReturnValue({sessionStateType:s.DeviceSessionStateType.Connected,deviceStatus:i.DeviceStatus.CONNECTED,deviceModelId:l.DeviceModelId.NANO_X}),R.mockImplementation(r=>r.name==="getOsVersion"?Promise.resolve(h()):Promise.resolve((0,w.CommandResultFactory)({error:new E.GlobalCommandError({...E.GLOBAL_ERRORS["6e00"],errorCode:"6e00"})})));const t=[...V(),{output:{currentApp:"BOLOS",currentAppVersion:"0.0.0"},status:c.DeviceActionStatus.Completed}];(0,u.testDeviceActionStates)(e,t,(0,a.makeDeviceActionInternalApiMock)(),{onDone:n,onError:o})}))}),describe("success cases",()=>{it("should return the device status if the device is unlocked",()=>new Promise((n,o)=>{v.mockReturnValue({sessionStateType:s.DeviceSessionStateType.ReadyWithoutSecureChannel,deviceStatus:i.DeviceStatus.CONNECTED,currentApp:{name:"mockedCurrentApp",version:"1.0.0"}}),p.mockResolvedValue(O("BOLOS","1.0.0"));const e=new d.GetDeviceStatusDeviceAction({input:{unlockTimeout:void 0}});vi.spyOn(e,"extractDependencies").mockReturnValue(A());const t=[...V(),{status:c.DeviceActionStatus.Completed,output:{currentApp:"BOLOS",currentAppVersion:"1.0.0"}}];(0,u.testDeviceActionStates)(e,t,(0,a.makeDeviceActionInternalApiMock)(),{onDone:()=>{expect(g).toHaveBeenCalledWith({sessionStateType:s.DeviceSessionStateType.ReadyWithoutSecureChannel,deviceStatus:i.DeviceStatus.CONNECTED,currentApp:{name:"BOLOS",version:"1.0.0"}}),n()},onError:o})})),it("should return the device status and update session if the device is not ready",()=>new Promise((n,o)=>{let e={sessionStateType:s.DeviceSessionStateType.Connected,deviceStatus:i.DeviceStatus.CONNECTED,deviceModelId:l.DeviceModelId.NANO_X};v.mockImplementation(()=>e),g.mockImplementation(T=>(e=T,T)),p.mockResolvedValue(O("BOLOS","1.0.0"));const t=new d.GetDeviceStatusDeviceAction({input:{unlockTimeout:void 0}});vi.spyOn(t,"extractDependencies").mockReturnValue(A());const r=(0,f.getOsVersionCommandResponseMockBuilder)(l.DeviceModelId.NANO_X),m=[...V(),{status:c.DeviceActionStatus.Completed,output:{currentApp:"BOLOS",currentAppVersion:"1.0.0"}}];(0,u.testDeviceActionStates)(t,m,(0,a.makeDeviceActionInternalApiMock)(),{onDone:()=>{expect(g).toHaveBeenCalledWith({deviceModelId:l.DeviceModelId.NANO_X,sessionStateType:s.DeviceSessionStateType.ReadyWithoutSecureChannel,deviceStatus:i.DeviceStatus.CONNECTED,currentApp:{name:"BOLOS",version:"1.0.0"},installedApps:[],isSecureConnectionAllowed:r.secureElementFlags.isSecureConnectionAllowed,firmwareVersion:{mcu:r.mcuSephVersion,bootloader:r.mcuBootloaderVersion,os:r.seVersion,metadata:r}}),n()},onError:o})})),it("should not fetch the OS version when an app other than BOLOS is open",()=>new Promise((n,o)=>{v.mockReturnValue({sessionStateType:s.DeviceSessionStateType.Connected,deviceStatus:i.DeviceStatus.CONNECTED,deviceModelId:l.DeviceModelId.NANO_X}),p.mockResolvedValue(O("Bitcoin","2.1.0"));const e=new d.GetDeviceStatusDeviceAction({input:{unlockTimeout:void 0}});vi.spyOn(e,"extractDependencies").mockReturnValue(A());const t=[S(),{status:c.DeviceActionStatus.Completed,output:{currentApp:"Bitcoin",currentAppVersion:"2.1.0"}}];(0,u.testDeviceActionStates)(e,t,(0,a.makeDeviceActionInternalApiMock)(),{onDone:()=>{expect(D).not.toHaveBeenCalled(),n()},onError:o})})),it("GIVEN a non-onboarded device WHEN checking the device status THEN it returns the device status by default",()=>new Promise((n,o)=>{v.mockReturnValue({sessionStateType:s.DeviceSessionStateType.ReadyWithoutSecureChannel,deviceStatus:i.DeviceStatus.CONNECTED,currentApp:{name:"BOLOS",version:"1.0.0"},installedApps:[],deviceModelId:l.DeviceModelId.NANO_X,isSecureConnectionAllowed:!1}),p.mockResolvedValue(O("BOLOS","1.0.0")),D.mockResolvedValue(h({secureElementFlags:{...(0,f.getOsVersionCommandResponseMockBuilder)().secureElementFlags,isOnboarded:!1}}));const e=new d.GetDeviceStatusDeviceAction({input:{unlockTimeout:void 0}});vi.spyOn(e,"extractDependencies").mockReturnValue(A());const t=[...V(),{status:c.DeviceActionStatus.Completed,output:{currentApp:"BOLOS",currentAppVersion:"1.0.0"}}];(0,u.testDeviceActionStates)(e,t,(0,a.makeDeviceActionInternalApiMock)(),{onDone:n,onError:o})})),it("should return the device status if the device is locked and the user unlocks the device",()=>new Promise((n,o)=>{v.mockReturnValue({sessionStateType:s.DeviceSessionStateType.ReadyWithoutSecureChannel,deviceStatus:i.DeviceStatus.LOCKED,currentApp:{name:"mockedCurrentApp",version:"1.0.0"}}),p.mockResolvedValueOnce(I()).mockResolvedValueOnce(O("BOLOS","1.0.0")),y.mockImplementation(()=>new k.Observable(r=>{const m=(0,k.interval)(50).subscribe({next:T=>{T>2?(r.next({sessionStateType:s.DeviceSessionStateType.ReadyWithoutSecureChannel,deviceStatus:i.DeviceStatus.CONNECTED,currentApp:{name:"mockedCurrentApp",version:"1.0.0"}}),r.complete()):r.next({sessionStateType:s.DeviceSessionStateType.ReadyWithoutSecureChannel,deviceStatus:i.DeviceStatus.LOCKED,currentApp:{name:"mockedCurrentApp",version:"1.0.0"}})}});return()=>{m.unsubscribe()}}));const e=new d.GetDeviceStatusDeviceAction({input:{unlockTimeout:500}});vi.spyOn(e,"extractDependencies").mockReturnValue(A());const t=[S(),b(),x(),x(),{status:c.DeviceActionStatus.Completed,output:{currentApp:"BOLOS",currentAppVersion:"1.0.0"}}];(0,u.testDeviceActionStates)(e,t,(0,a.makeDeviceActionInternalApiMock)(),{onDone:n,onError:o})}))}),describe("errors cases",()=>{it("GIVEN a non-onboarded device and the non-onboarded allowance is disabled WHEN checking the device status THEN it returns a not-onboarded error",()=>new Promise((n,o)=>{v.mockReturnValue({sessionStateType:s.DeviceSessionStateType.ReadyWithoutSecureChannel,deviceStatus:i.DeviceStatus.CONNECTED,currentApp:{name:"BOLOS",version:"1.0.0"},installedApps:[],deviceModelId:l.DeviceModelId.NANO_X,isSecureConnectionAllowed:!1}),p.mockResolvedValue(O("BOLOS","1.0.0")),D.mockResolvedValue(h({secureElementFlags:{...(0,f.getOsVersionCommandResponseMockBuilder)().secureElementFlags,isOnboarded:!1}}));const e=new d.GetDeviceStatusDeviceAction({input:{unlockTimeout:500,allowNonOnboardedDevice:!1}});vi.spyOn(e,"extractDependencies").mockReturnValue(A());const t=[...V(),{error:new C.DeviceNotOnboardedError,status:c.DeviceActionStatus.Error}];(0,u.testDeviceActionStates)(e,t,(0,a.makeDeviceActionInternalApiMock)(),{onDone:n,onError:o})})),it("should end in an error if the device is locked and the user does not unlock",()=>new Promise((n,o)=>{v.mockReturnValue({sessionStateType:s.DeviceSessionStateType.ReadyWithoutSecureChannel,deviceStatus:i.DeviceStatus.LOCKED,currentApp:{name:"mockedCurrentApp",version:"1.0.0"}}),p.mockResolvedValue(I()),y.mockImplementation(()=>new k.Observable(r=>{r.error(new C.DeviceLockedError("Device locked."))})),G.mockImplementation(()=>new k.Observable(r=>{const m=(0,k.interval)(200).subscribe({next:()=>{r.next({sessionStateType:s.DeviceSessionStateType.ReadyWithoutSecureChannel,deviceStatus:i.DeviceStatus.LOCKED,currentApp:{name:"mockedCurrentApp",version:"1.0.0"},installedApps:[],deviceModelId:l.DeviceModelId.NANO_X,isSecureConnectionAllowed:!1})}});return()=>{m.unsubscribe()}}));const e=new d.GetDeviceStatusDeviceAction({input:{unlockTimeout:500}});vi.spyOn(e,"extractDependencies").mockReturnValue(A());const t=[S(),b(),{error:new C.DeviceLockedError("Device locked."),status:c.DeviceActionStatus.Error}];(0,u.testDeviceActionStates)(e,t,(0,a.makeDeviceActionInternalApiMock)(),{onDone:n,onError:o})})),it("should end in an error if the GetAppAndVersion command fails",()=>new Promise((n,o)=>{v.mockReturnValue({sessionStateType:s.DeviceSessionStateType.ReadyWithoutSecureChannel,deviceStatus:i.DeviceStatus.LOCKED,currentApp:{name:"mockedCurrentApp",version:"1.0.0"}});const e=new E.GlobalCommandError({...E.GLOBAL_ERRORS[5501],errorCode:"5501"});p.mockResolvedValue((0,w.CommandResultFactory)({error:e})),y.mockImplementation(()=>new k.Observable(m=>{m.complete()}));const t=new d.GetDeviceStatusDeviceAction({input:{unlockTimeout:500}});vi.spyOn(t,"extractDependencies").mockReturnValue(A());const r=[S(),{error:e,status:c.DeviceActionStatus.Error}];(0,u.testDeviceActionStates)(t,r,(0,a.makeDeviceActionInternalApiMock)(),{onDone:n,onError:o})})),it("should end in an error if getAppAndVersion actor throws an error",()=>new Promise((n,o)=>{v.mockReturnValue({sessionStateType:s.DeviceSessionStateType.ReadyWithoutSecureChannel,deviceStatus:i.DeviceStatus.LOCKED,currentApp:{name:"mockedCurrentApp",version:"1.0.0"}}),p.mockImplementation(()=>{throw new C.UnknownDAError("error")}),y.mockImplementation(()=>new k.Observable(r=>{r.complete()}));const e=new d.GetDeviceStatusDeviceAction({input:{unlockTimeout:500}});vi.spyOn(e,"extractDependencies").mockReturnValue(A());const t=[S(),{error:new C.UnknownDAError("error"),status:c.DeviceActionStatus.Error}];(0,u.testDeviceActionStates)(e,t,(0,a.makeDeviceActionInternalApiMock)(),{onDone:n,onError:o})}))}),it("should emit a stopped state if the action is cancelled",()=>new Promise((n,o)=>{N.mockReturnValue({sessionStateType:s.DeviceSessionStateType.ReadyWithoutSecureChannel,deviceStatus:i.DeviceStatus.CONNECTED,currentApp:{name:"mockedCurrentApp",version:"1.0.0"},installedApps:[],deviceModelId:l.DeviceModelId.NANO_X,isSecureConnectionAllowed:!1}),R.mockImplementation(m=>m.name==="getOsVersion"?Promise.resolve(h()):Promise.resolve(O("BOLOS","1.0.0")));const e=new d.GetDeviceStatusDeviceAction({input:{unlockTimeout:500}}),t=[S(),{status:c.DeviceActionStatus.Stopped}],{cancel:r}=(0,u.testDeviceActionStates)(e,t,(0,a.makeDeviceActionInternalApiMock)(),{onDone:n,onError:o});r()}))});
1
+ "use strict";var N=require("../../../command/model/CommandResult"),E=require("../../../command/os/__mocks__/GetOsVersionCommand"),V=require("../../../command/utils/GlobalCommandError"),A=require("../../../device/DeviceModel"),u=require("../../../device/DeviceStatus"),a=require("../../../device-action/__test-utils__/makeInternalApi"),d=require("../../../device-action/__test-utils__/setupTestMachine"),p=require("../../../device-action/__test-utils__/testDeviceActionStates"),r=require("../../../device-action/model/DeviceActionState"),k=require("../../../device-action/model/UserInteractionRequired"),h=require("../../../device-action/os/Errors"),l=require("../../../device-session/DeviceSessionState"),v=require("./GetDeviceStatusDeviceAction"),f=require("./types");vi.mock("@api/device-action/os/WaitForAppAndVersion/WaitForAppAndVersionDeviceAction");const C=(s={},c=A.DeviceModelId.NANO_X)=>(0,N.CommandResultFactory)({data:(0,E.getOsVersionCommandResponseMockBuilder)(c,s)}),m=(s,c)=>({name:s,version:c}),O=(s=k.UserInteractionRequired.None)=>({intermediateValue:{requiredUserInteraction:s,step:f.getDeviceStatusDAStateStep.ONBOARD_CHECK},status:r.DeviceActionStatus.Pending}),n=(s=k.UserInteractionRequired.None)=>({intermediateValue:{requiredUserInteraction:s,step:f.getDeviceStatusDAStateStep.WAIT_FOR_APP_AND_VERSION},status:r.DeviceActionStatus.Pending});describe("GetDeviceStatusDeviceAction",()=>{const s=vi.fn(),c=vi.fn(),R=vi.fn();function D(){return{getOsVersion:s,getDeviceSessionState:c,setDeviceSessionState:R}}const{sendCommand:y,getDeviceSessionState:w}=(0,a.makeDeviceActionInternalApiMock)();beforeEach(()=>{vi.resetAllMocks(),s.mockResolvedValue(C())}),describe("without overriding `extractDependencies`",()=>{it("should run the device action with the device on the dashboard",()=>new Promise((o,i)=>{(0,d.setupWaitForAppAndVersionMock)(m("BOLOS","1.0.0")),w.mockReturnValue({sessionStateType:l.DeviceSessionStateType.Connected,deviceStatus:u.DeviceStatus.CONNECTED,deviceModelId:A.DeviceModelId.NANO_X}),y.mockResolvedValue(C());const e=new v.GetDeviceStatusDeviceAction({input:{unlockTimeout:500}}),t=[n(),n(),O(),{output:{currentApp:"BOLOS",currentAppVersion:"1.0.0"},status:r.DeviceActionStatus.Completed}];(0,p.testDeviceActionStates)(e,t,(0,a.makeDeviceActionInternalApiMock)(),{onDone:o,onError:i})})),it("should run the device action when the device needs to be unlocked",()=>new Promise((o,i)=>{(0,d.setupWaitForAppAndVersionMock)(m("BOLOS","1.0.0"),k.UserInteractionRequired.UnlockDevice),w.mockReturnValue({sessionStateType:l.DeviceSessionStateType.Connected,deviceStatus:u.DeviceStatus.LOCKED,deviceModelId:A.DeviceModelId.NANO_X}),y.mockResolvedValue(C());const e=new v.GetDeviceStatusDeviceAction({input:{unlockTimeout:500}}),t=[n(),n(k.UserInteractionRequired.UnlockDevice),O(),{output:{currentApp:"BOLOS",currentAppVersion:"1.0.0"},status:r.DeviceActionStatus.Completed}];(0,p.testDeviceActionStates)(e,t,(0,a.makeDeviceActionInternalApiMock)(),{onDone:o,onError:i})}))}),describe("success cases",()=>{it("should return the device status if the device is on the dashboard",()=>new Promise((o,i)=>{(0,d.setupWaitForAppAndVersionMock)(m("BOLOS","1.0.0")),c.mockReturnValue({sessionStateType:l.DeviceSessionStateType.ReadyWithoutSecureChannel,deviceStatus:u.DeviceStatus.CONNECTED,currentApp:{name:"mockedCurrentApp",version:"1.0.0"}});const e=new v.GetDeviceStatusDeviceAction({input:{unlockTimeout:void 0}});vi.spyOn(e,"extractDependencies").mockReturnValue(D());const t=[n(),n(),O(),{status:r.DeviceActionStatus.Completed,output:{currentApp:"BOLOS",currentAppVersion:"1.0.0"}}];(0,p.testDeviceActionStates)(e,t,(0,a.makeDeviceActionInternalApiMock)(),{onDone:o,onError:i})})),it("should return the device status and update the session firmware version",()=>new Promise((o,i)=>{(0,d.setupWaitForAppAndVersionMock)(m("BOLOS","1.0.0"));let e={sessionStateType:l.DeviceSessionStateType.ReadyWithoutSecureChannel,deviceStatus:u.DeviceStatus.CONNECTED,currentApp:{name:"BOLOS",version:"1.0.0"},installedApps:[],deviceModelId:A.DeviceModelId.NANO_X,isSecureConnectionAllowed:!1};c.mockImplementation(()=>e),R.mockImplementation(T=>(e=T,T));const t=new v.GetDeviceStatusDeviceAction({input:{unlockTimeout:void 0}});vi.spyOn(t,"extractDependencies").mockReturnValue(D());const S=(0,E.getOsVersionCommandResponseMockBuilder)(A.DeviceModelId.NANO_X),g=[n(),n(),O(),{status:r.DeviceActionStatus.Completed,output:{currentApp:"BOLOS",currentAppVersion:"1.0.0"}}];(0,p.testDeviceActionStates)(t,g,(0,a.makeDeviceActionInternalApiMock)(),{onDone:()=>{expect(R).toHaveBeenCalledWith(expect.objectContaining({isSecureConnectionAllowed:S.secureElementFlags.isSecureConnectionAllowed,firmwareVersion:{mcu:S.mcuSephVersion,bootloader:S.mcuBootloaderVersion,os:S.seVersion,metadata:S}})),o()},onError:i})})),it("should not fetch the OS version when an app other than BOLOS is open",()=>new Promise((o,i)=>{(0,d.setupWaitForAppAndVersionMock)(m("Bitcoin","2.1.0")),c.mockReturnValue({sessionStateType:l.DeviceSessionStateType.Connected,deviceStatus:u.DeviceStatus.CONNECTED,deviceModelId:A.DeviceModelId.NANO_X});const e=new v.GetDeviceStatusDeviceAction({input:{unlockTimeout:void 0}});vi.spyOn(e,"extractDependencies").mockReturnValue(D());const t=[n(),n(),{status:r.DeviceActionStatus.Completed,output:{currentApp:"Bitcoin",currentAppVersion:"2.1.0"}}];(0,p.testDeviceActionStates)(e,t,(0,a.makeDeviceActionInternalApiMock)(),{onDone:()=>{expect(s).not.toHaveBeenCalled(),o()},onError:i})})),it("GIVEN a non-onboarded device WHEN checking the device status THEN it returns the device status by default",()=>new Promise((o,i)=>{(0,d.setupWaitForAppAndVersionMock)(m("BOLOS","1.0.0")),c.mockReturnValue({sessionStateType:l.DeviceSessionStateType.ReadyWithoutSecureChannel,deviceStatus:u.DeviceStatus.CONNECTED,currentApp:{name:"BOLOS",version:"1.0.0"},installedApps:[],deviceModelId:A.DeviceModelId.NANO_X,isSecureConnectionAllowed:!1}),s.mockResolvedValue(C({secureElementFlags:{...(0,E.getOsVersionCommandResponseMockBuilder)().secureElementFlags,isOnboarded:!1}}));const e=new v.GetDeviceStatusDeviceAction({input:{unlockTimeout:void 0}});vi.spyOn(e,"extractDependencies").mockReturnValue(D());const t=[n(),n(),O(),{status:r.DeviceActionStatus.Completed,output:{currentApp:"BOLOS",currentAppVersion:"1.0.0"}}];(0,p.testDeviceActionStates)(e,t,(0,a.makeDeviceActionInternalApiMock)(),{onDone:o,onError:i})})),it("should surface the unlock interaction then return the device status",()=>new Promise((o,i)=>{(0,d.setupWaitForAppAndVersionMock)(m("BOLOS","1.0.0"),k.UserInteractionRequired.UnlockDevice),c.mockReturnValue({sessionStateType:l.DeviceSessionStateType.ReadyWithoutSecureChannel,deviceStatus:u.DeviceStatus.LOCKED,currentApp:{name:"mockedCurrentApp",version:"1.0.0"}});const e=new v.GetDeviceStatusDeviceAction({input:{unlockTimeout:500}});vi.spyOn(e,"extractDependencies").mockReturnValue(D());const t=[n(),n(k.UserInteractionRequired.UnlockDevice),O(),{status:r.DeviceActionStatus.Completed,output:{currentApp:"BOLOS",currentAppVersion:"1.0.0"}}];(0,p.testDeviceActionStates)(e,t,(0,a.makeDeviceActionInternalApiMock)(),{onDone:o,onError:i})}))}),describe("errors cases",()=>{it("GIVEN a non-onboarded device and the non-onboarded allowance is disabled WHEN checking the device status THEN it returns a not-onboarded error",()=>new Promise((o,i)=>{(0,d.setupWaitForAppAndVersionMock)(m("BOLOS","1.0.0")),c.mockReturnValue({sessionStateType:l.DeviceSessionStateType.ReadyWithoutSecureChannel,deviceStatus:u.DeviceStatus.CONNECTED,currentApp:{name:"BOLOS",version:"1.0.0"},installedApps:[],deviceModelId:A.DeviceModelId.NANO_X,isSecureConnectionAllowed:!1}),s.mockResolvedValue(C({secureElementFlags:{...(0,E.getOsVersionCommandResponseMockBuilder)().secureElementFlags,isOnboarded:!1}}));const e=new v.GetDeviceStatusDeviceAction({input:{unlockTimeout:500,allowNonOnboardedDevice:!1}});vi.spyOn(e,"extractDependencies").mockReturnValue(D());const t=[n(),n(),O(),{error:new h.DeviceNotOnboardedError,status:r.DeviceActionStatus.Error}];(0,p.testDeviceActionStates)(e,t,(0,a.makeDeviceActionInternalApiMock)(),{onDone:o,onError:i})})),it("should end in an error if the device is locked and the user does not unlock",()=>new Promise((o,i)=>{(0,d.setupWaitForAppAndVersionMock)(new h.DeviceLockedError("Device locked."),k.UserInteractionRequired.UnlockDevice),c.mockReturnValue({sessionStateType:l.DeviceSessionStateType.ReadyWithoutSecureChannel,deviceStatus:u.DeviceStatus.LOCKED,currentApp:{name:"mockedCurrentApp",version:"1.0.0"}});const e=new v.GetDeviceStatusDeviceAction({input:{unlockTimeout:500}});vi.spyOn(e,"extractDependencies").mockReturnValue(D());const t=[n(),n(k.UserInteractionRequired.UnlockDevice),{error:new h.DeviceLockedError("Device locked."),status:r.DeviceActionStatus.Error}];(0,p.testDeviceActionStates)(e,t,(0,a.makeDeviceActionInternalApiMock)(),{onDone:o,onError:i})})),it("should end in an error if the WaitForAppAndVersion sub-action fails",()=>new Promise((o,i)=>{const e=new V.GlobalCommandError({...V.GLOBAL_ERRORS[5501],errorCode:"5501"});(0,d.setupWaitForAppAndVersionMock)(e),c.mockReturnValue({sessionStateType:l.DeviceSessionStateType.ReadyWithoutSecureChannel,deviceStatus:u.DeviceStatus.LOCKED,currentApp:{name:"mockedCurrentApp",version:"1.0.0"}});const t=new v.GetDeviceStatusDeviceAction({input:{unlockTimeout:500}});vi.spyOn(t,"extractDependencies").mockReturnValue(D());const S=[n(),n(),{error:e,status:r.DeviceActionStatus.Error}];(0,p.testDeviceActionStates)(t,S,(0,a.makeDeviceActionInternalApiMock)(),{onDone:o,onError:i})})),it("should end in an error if the GetOsVersion command fails",()=>new Promise((o,i)=>{(0,d.setupWaitForAppAndVersionMock)(m("BOLOS","1.0.0")),c.mockReturnValue({sessionStateType:l.DeviceSessionStateType.ReadyWithoutSecureChannel,deviceStatus:u.DeviceStatus.CONNECTED,currentApp:{name:"BOLOS",version:"1.0.0"}});const e=new V.GlobalCommandError({...V.GLOBAL_ERRORS[5501],errorCode:"5501"});s.mockResolvedValue((0,N.CommandResultFactory)({error:e}));const t=new v.GetDeviceStatusDeviceAction({input:{unlockTimeout:500}});vi.spyOn(t,"extractDependencies").mockReturnValue(D());const S=[n(),n(),O(),{error:e,status:r.DeviceActionStatus.Error}];(0,p.testDeviceActionStates)(t,S,(0,a.makeDeviceActionInternalApiMock)(),{onDone:o,onError:i})})),it("should end in an error if the getOsVersion actor throws an error",()=>new Promise((o,i)=>{(0,d.setupWaitForAppAndVersionMock)(m("BOLOS","1.0.0")),c.mockReturnValue({sessionStateType:l.DeviceSessionStateType.ReadyWithoutSecureChannel,deviceStatus:u.DeviceStatus.CONNECTED,currentApp:{name:"BOLOS",version:"1.0.0"}}),s.mockImplementation(()=>{throw new h.UnknownDAError("error")});const e=new v.GetDeviceStatusDeviceAction({input:{unlockTimeout:500}});vi.spyOn(e,"extractDependencies").mockReturnValue(D());const t=[n(),n(),O(),{error:new h.UnknownDAError("error"),status:r.DeviceActionStatus.Error}];(0,p.testDeviceActionStates)(e,t,(0,a.makeDeviceActionInternalApiMock)(),{onDone:o,onError:i})}))}),it("should emit a stopped state if the action is cancelled",()=>new Promise((o,i)=>{(0,d.setupWaitForAppAndVersionMock)(m("BOLOS","1.0.0")),w.mockReturnValue({sessionStateType:l.DeviceSessionStateType.ReadyWithoutSecureChannel,deviceStatus:u.DeviceStatus.CONNECTED,currentApp:{name:"mockedCurrentApp",version:"1.0.0"},installedApps:[],deviceModelId:A.DeviceModelId.NANO_X,isSecureConnectionAllowed:!1}),y.mockResolvedValue(C());const e=new v.GetDeviceStatusDeviceAction({input:{unlockTimeout:500}}),t=[n(),n(),{status:r.DeviceActionStatus.Stopped}],{cancel:S}=(0,p.testDeviceActionStates)(e,t,(0,a.makeDeviceActionInternalApiMock)(),{onDone:o,onError:i});S()}))});
2
2
  //# sourceMappingURL=GetDeviceStatusDeviceAction.test.js.map
@@ -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 { getOsVersionCommandResponseMockBuilder } from \"@api/command/os/__mocks__/GetOsVersionCommand\";\nimport { type GetOsVersionResponse } from \"@api/command/os/GetOsVersionCommand\";\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 {\n type GetDeviceStatusDAState,\n getDeviceStatusDAStateStep,\n} from \"./types\";\n\nconst osVersionCommandResult = (\n props: Partial<GetOsVersionResponse> = {},\n deviceModelId: DeviceModelId = DeviceModelId.NANO_X,\n) =>\n CommandResultFactory({\n data: getOsVersionCommandResponseMockBuilder(deviceModelId, props),\n });\n\nconst appAndVersionResult = (name: string, version: string) =>\n CommandResultFactory({\n data: {\n name,\n version,\n },\n });\n\nconst lockedErrorResult = () =>\n CommandResultFactory({\n error: new GlobalCommandError({\n ...GLOBAL_ERRORS[\"5515\"],\n errorCode: \"5515\",\n }),\n });\n\nconst onboardCheckPendingState = (): GetDeviceStatusDAState => ({\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.None,\n step: getDeviceStatusDAStateStep.ONBOARD_CHECK,\n },\n status: DeviceActionStatus.Pending,\n});\n\nconst onboardCheckPendingStatesWithOsVersionFetch =\n (): Array<GetDeviceStatusDAState> => [\n onboardCheckPendingState(),\n onboardCheckPendingState(),\n ];\n\nconst unlockRequestedPendingState = (): GetDeviceStatusDAState => ({\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.UnlockDevice,\n step: getDeviceStatusDAStateStep.UNLOCK_DEVICE,\n },\n status: DeviceActionStatus.Pending,\n});\n\nconst unlockResolvedPendingState = (): GetDeviceStatusDAState => ({\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.None,\n step: getDeviceStatusDAStateStep.UNLOCK_DEVICE,\n },\n status: DeviceActionStatus.Pending,\n});\n\ndescribe(\"GetDeviceStatusDeviceAction\", () => {\n const getAppAndVersionMock = vi.fn();\n const getOsVersionMock = vi.fn();\n const getDeviceSessionStateMock = vi.fn();\n const waitForDeviceUnlockMock = vi.fn();\n const setDeviceSessionState = vi.fn();\n\n function extractDependenciesMock() {\n return {\n getAppAndVersion: getAppAndVersionMock,\n getOsVersion: getOsVersionMock,\n getDeviceSessionState: getDeviceSessionStateMock,\n waitForDeviceUnlock: waitForDeviceUnlockMock,\n setDeviceSessionState: setDeviceSessionState,\n };\n }\n\n const {\n sendCommand: sendCommandMock,\n getDeviceSessionState: apiGetDeviceSessionStateMock,\n getDeviceSessionStateObservable: apiGetDeviceSessionStateObservableMock,\n } = makeDeviceActionInternalApiMock();\n beforeEach(() => {\n vi.resetAllMocks();\n getOsVersionMock.mockResolvedValue(osVersionCommandResult());\n });\n\n describe(\"without overriding `extractDependencies`\", () => {\n it(\"should run the device action with an unlocked device\", () =>\n new Promise<void>((resolve, reject) => {\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.NANO_X,\n });\n\n // GetAppAndVersion is called first to determine the current app, then\n // GetOsVersion is called because the app is BOLOS (dashboard).\n sendCommandMock.mockImplementation((command) =>\n command.name === \"getOsVersion\"\n ? Promise.resolve(osVersionCommandResult())\n : Promise.resolve(appAndVersionResult(\"BOLOS\", \"1.0.0\")),\n );\n\n const expectedStates: Array<GetDeviceStatusDAState> = [\n ...onboardCheckPendingStatesWithOsVersionFetch(),\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 {\n onDone: resolve,\n onError: reject,\n },\n );\n }));\n\n it(\"should run the device action with a locked device\", () =>\n new Promise<void>((resolve, reject) => {\n const getDeviceStateDeviceAction = new GetDeviceStatusDeviceAction({\n input: { unlockTimeout: 1500 },\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.NANO_X,\n isSecureConnectionAllowed: false,\n });\n\n // First GetAppAndVersion fails because the device is locked, then it\n // succeeds (BOLOS) once unlocked, then GetOsVersion is fetched.\n let appCall = 0;\n sendCommandMock.mockImplementation((command) => {\n if (command.name === \"getOsVersion\") {\n return Promise.resolve(osVersionCommandResult());\n }\n appCall += 1;\n if (appCall === 1) {\n return Promise.resolve(lockedErrorResult());\n }\n return Promise.resolve(appAndVersionResult(\"BOLOS\", \"1.0.0\"));\n });\n\n const expectedStates: Array<GetDeviceStatusDAState> = [\n onboardCheckPendingState(),\n unlockRequestedPendingState(),\n unlockResolvedPendingState(),\n unlockResolvedPendingState(),\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 {\n onDone: resolve,\n onError: reject,\n },\n );\n }));\n\n it(\"should timeout with a locked device\", () =>\n new Promise<void>((resolve, reject) => {\n const getDeviceStateDeviceAction = new GetDeviceStatusDeviceAction({\n input: { unlockTimeout: 200 },\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.NANO_X,\n isSecureConnectionAllowed: false,\n });\n\n // GetAppAndVersion always reports a locked device, so the unlock\n // polling times out.\n sendCommandMock.mockImplementation((command) =>\n command.name === \"getOsVersion\"\n ? Promise.resolve(osVersionCommandResult())\n : Promise.resolve(lockedErrorResult()),\n );\n\n const expectedStates: Array<GetDeviceStatusDAState> = [\n onboardCheckPendingState(),\n unlockRequestedPendingState(),\n {\n error: new DeviceLockedError(\"Device locked.\"),\n status: DeviceActionStatus.Error,\n },\n ];\n\n testDeviceActionStates(\n getDeviceStateDeviceAction,\n expectedStates,\n makeDeviceActionInternalApiMock(),\n {\n onDone: resolve,\n onError: reject,\n },\n );\n }));\n\n it(\"should run the device action with an old firmware not supporting GetAppAndVersion\", () =>\n new Promise<void>((resolve, reject) => {\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.NANO_X,\n });\n\n // GetAppAndVersion is not supported (CLA_NOT_SUPPORTED), which means we\n // are on the dashboard of an old firmware: the current app is BOLOS so\n // the OS version can still be fetched.\n sendCommandMock.mockImplementation((command) =>\n command.name === \"getOsVersion\"\n ? Promise.resolve(osVersionCommandResult())\n : Promise.resolve(\n CommandResultFactory({\n error: new GlobalCommandError({\n ...GLOBAL_ERRORS[\"6e00\"],\n errorCode: \"6e00\",\n }),\n }),\n ),\n );\n\n const expectedStates: Array<GetDeviceStatusDAState> = [\n ...onboardCheckPendingStatesWithOsVersionFetch(),\n {\n output: {\n currentApp: \"BOLOS\",\n currentAppVersion: \"0.0.0\",\n },\n status: DeviceActionStatus.Completed,\n },\n ];\n\n testDeviceActionStates(\n getDeviceStateDeviceAction,\n expectedStates,\n makeDeviceActionInternalApiMock(),\n {\n onDone: resolve,\n onError: reject,\n },\n );\n }));\n });\n\n describe(\"success cases\", () => {\n it(\"should return the device status if the device is unlocked\", () =>\n new Promise<void>((resolve, reject) => {\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 appAndVersionResult(\"BOLOS\", \"1.0.0\"),\n );\n\n const getDeviceStateDeviceAction = new GetDeviceStatusDeviceAction({\n input: { unlockTimeout: undefined },\n });\n\n vi.spyOn(\n getDeviceStateDeviceAction,\n \"extractDependencies\",\n ).mockReturnValue(extractDependenciesMock());\n\n const expectedStates: Array<GetDeviceStatusDAState> = [\n ...onboardCheckPendingStatesWithOsVersionFetch(),\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 {\n onDone: () => {\n // Session should be updated with current app\n expect(setDeviceSessionState).toHaveBeenCalledWith({\n sessionStateType:\n DeviceSessionStateType.ReadyWithoutSecureChannel,\n deviceStatus: DeviceStatus.CONNECTED,\n currentApp: {\n name: \"BOLOS\",\n version: \"1.0.0\",\n },\n });\n resolve();\n },\n onError: reject,\n },\n );\n }));\n\n it(\"should return the device status and update session if the device is not ready\", () =>\n new Promise<void>((resolve, reject) => {\n // The session state is stateful so the firmware version enrichment from\n // the OS version (which reads back the ready state) can be observed.\n let sessionState: object = {\n sessionStateType: DeviceSessionStateType.Connected,\n deviceStatus: DeviceStatus.CONNECTED,\n deviceModelId: DeviceModelId.NANO_X,\n };\n getDeviceSessionStateMock.mockImplementation(() => sessionState);\n setDeviceSessionState.mockImplementation((state) => {\n sessionState = state;\n return state;\n });\n\n getAppAndVersionMock.mockResolvedValue(\n appAndVersionResult(\"BOLOS\", \"1.0.0\"),\n );\n\n const getDeviceStateDeviceAction = new GetDeviceStatusDeviceAction({\n input: { unlockTimeout: undefined },\n });\n\n vi.spyOn(\n getDeviceStateDeviceAction,\n \"extractDependencies\",\n ).mockReturnValue(extractDependenciesMock());\n\n const osVersionData = getOsVersionCommandResponseMockBuilder(\n DeviceModelId.NANO_X,\n );\n const expectedStates: Array<GetDeviceStatusDAState> = [\n ...onboardCheckPendingStatesWithOsVersionFetch(),\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 {\n onDone: () => {\n // Session should be set as ready if GetAppAndVersionCommand was successful\n // and then enriched with the firmware version from the OS version.\n expect(setDeviceSessionState).toHaveBeenCalledWith({\n deviceModelId: DeviceModelId.NANO_X,\n sessionStateType:\n DeviceSessionStateType.ReadyWithoutSecureChannel,\n deviceStatus: DeviceStatus.CONNECTED,\n currentApp: {\n name: \"BOLOS\",\n version: \"1.0.0\",\n },\n installedApps: [],\n isSecureConnectionAllowed:\n osVersionData.secureElementFlags.isSecureConnectionAllowed,\n firmwareVersion: {\n mcu: osVersionData.mcuSephVersion,\n bootloader: osVersionData.mcuBootloaderVersion,\n os: osVersionData.seVersion,\n metadata: osVersionData,\n },\n });\n resolve();\n },\n onError: reject,\n },\n );\n }));\n\n it(\"should not fetch the OS version when an app other than BOLOS is open\", () =>\n new Promise<void>((resolve, reject) => {\n getDeviceSessionStateMock.mockReturnValue({\n sessionStateType: DeviceSessionStateType.Connected,\n deviceStatus: DeviceStatus.CONNECTED,\n deviceModelId: DeviceModelId.NANO_X,\n });\n\n // An application is open: the device is necessarily onboarded and the\n // OS version cannot be read outside of the dashboard.\n getAppAndVersionMock.mockResolvedValue(\n appAndVersionResult(\"Bitcoin\", \"2.1.0\"),\n );\n\n const getDeviceStateDeviceAction = new GetDeviceStatusDeviceAction({\n input: { unlockTimeout: undefined },\n });\n\n vi.spyOn(\n getDeviceStateDeviceAction,\n \"extractDependencies\",\n ).mockReturnValue(extractDependenciesMock());\n\n const expectedStates: Array<GetDeviceStatusDAState> = [\n onboardCheckPendingState(),\n {\n status: DeviceActionStatus.Completed,\n output: {\n currentApp: \"Bitcoin\",\n currentAppVersion: \"2.1.0\",\n },\n },\n ];\n\n testDeviceActionStates(\n getDeviceStateDeviceAction,\n expectedStates,\n makeDeviceActionInternalApiMock(),\n {\n onDone: () => {\n expect(getOsVersionMock).not.toHaveBeenCalled();\n resolve();\n },\n onError: reject,\n },\n );\n }));\n\n it(\"GIVEN a non-onboarded device WHEN checking the device status THEN it returns the device status by default\", () =>\n new Promise<void>((resolve, reject) => {\n // GIVEN\n getDeviceSessionStateMock.mockReturnValue({\n sessionStateType: DeviceSessionStateType.ReadyWithoutSecureChannel,\n deviceStatus: DeviceStatus.CONNECTED,\n currentApp: { name: \"BOLOS\", version: \"1.0.0\" },\n installedApps: [],\n deviceModelId: DeviceModelId.NANO_X,\n isSecureConnectionAllowed: false,\n });\n getAppAndVersionMock.mockResolvedValue(\n appAndVersionResult(\"BOLOS\", \"1.0.0\"),\n );\n getOsVersionMock.mockResolvedValue(\n osVersionCommandResult({\n secureElementFlags: {\n ...getOsVersionCommandResponseMockBuilder().secureElementFlags,\n isOnboarded: false,\n },\n }),\n );\n\n const getDeviceStateDeviceAction = new GetDeviceStatusDeviceAction({\n input: { unlockTimeout: undefined },\n });\n\n vi.spyOn(\n getDeviceStateDeviceAction,\n \"extractDependencies\",\n ).mockReturnValue(extractDependenciesMock());\n\n const expectedStates: Array<GetDeviceStatusDAState> = [\n ...onboardCheckPendingStatesWithOsVersionFetch(),\n {\n status: DeviceActionStatus.Completed,\n output: {\n currentApp: \"BOLOS\",\n currentAppVersion: \"1.0.0\",\n },\n },\n ];\n\n // WHEN\n testDeviceActionStates(\n getDeviceStateDeviceAction,\n expectedStates,\n makeDeviceActionInternalApiMock(),\n {\n // THEN\n onDone: resolve,\n onError: reject,\n },\n );\n }));\n\n it(\"should return the device status if the device is locked and the user unlocks the device\", () =>\n new Promise<void>((resolve, reject) => {\n getDeviceSessionStateMock.mockReturnValue({\n sessionStateType: DeviceSessionStateType.ReadyWithoutSecureChannel,\n deviceStatus: DeviceStatus.LOCKED,\n currentApp: { name: \"mockedCurrentApp\", version: \"1.0.0\" },\n });\n\n getAppAndVersionMock\n .mockResolvedValueOnce(lockedErrorResult())\n .mockResolvedValueOnce(appAndVersionResult(\"BOLOS\", \"1.0.0\"));\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: {\n name: \"mockedCurrentApp\",\n version: \"1.0.0\",\n },\n });\n o.complete();\n } else {\n o.next({\n sessionStateType:\n DeviceSessionStateType.ReadyWithoutSecureChannel,\n deviceStatus: DeviceStatus.LOCKED,\n currentApp: {\n name: \"mockedCurrentApp\",\n version: \"1.0.0\",\n },\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 vi.spyOn(\n getDeviceStateDeviceAction,\n \"extractDependencies\",\n ).mockReturnValue(extractDependenciesMock());\n\n const expectedStates: Array<GetDeviceStatusDAState> = [\n onboardCheckPendingState(),\n unlockRequestedPendingState(),\n unlockResolvedPendingState(),\n unlockResolvedPendingState(),\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 {\n onDone: resolve,\n onError: reject,\n },\n );\n }));\n });\n\n describe(\"errors cases\", () => {\n it(\"GIVEN a non-onboarded device and the non-onboarded allowance is disabled WHEN checking the device status THEN it returns a not-onboarded error\", () =>\n new Promise<void>((resolve, reject) => {\n // GIVEN\n getDeviceSessionStateMock.mockReturnValue({\n sessionStateType: DeviceSessionStateType.ReadyWithoutSecureChannel,\n deviceStatus: DeviceStatus.CONNECTED,\n currentApp: { name: \"BOLOS\", version: \"1.0.0\" },\n installedApps: [],\n deviceModelId: DeviceModelId.NANO_X,\n isSecureConnectionAllowed: false,\n });\n // A non-onboarded device sits on the dashboard (BOLOS), so the app check\n // succeeds and the OS version reveals the onboarding status.\n getAppAndVersionMock.mockResolvedValue(\n appAndVersionResult(\"BOLOS\", \"1.0.0\"),\n );\n getOsVersionMock.mockResolvedValue(\n osVersionCommandResult({\n secureElementFlags: {\n ...getOsVersionCommandResponseMockBuilder().secureElementFlags,\n isOnboarded: false,\n },\n }),\n );\n\n const getDeviceStateDeviceAction = new GetDeviceStatusDeviceAction({\n input: {\n unlockTimeout: 500,\n allowNonOnboardedDevice: false,\n },\n });\n\n vi.spyOn(\n getDeviceStateDeviceAction,\n \"extractDependencies\",\n ).mockReturnValue(extractDependenciesMock());\n\n const expectedStates: Array<GetDeviceStatusDAState> = [\n ...onboardCheckPendingStatesWithOsVersionFetch(),\n {\n error: new DeviceNotOnboardedError(),\n status: DeviceActionStatus.Error,\n },\n ];\n\n // WHEN\n testDeviceActionStates(\n getDeviceStateDeviceAction,\n expectedStates,\n makeDeviceActionInternalApiMock(),\n {\n // THEN\n onDone: resolve,\n onError: reject,\n },\n );\n }));\n\n it(\"should end in an error if the device is locked and the user does not unlock\", () =>\n new Promise<void>((resolve, reject) => {\n getDeviceSessionStateMock.mockReturnValue({\n sessionStateType: DeviceSessionStateType.ReadyWithoutSecureChannel,\n deviceStatus: DeviceStatus.LOCKED,\n currentApp: { name: \"mockedCurrentApp\", version: \"1.0.0\" },\n });\n\n getAppAndVersionMock.mockResolvedValue(lockedErrorResult());\n\n waitForDeviceUnlockMock.mockImplementation(\n () =>\n new Observable((o) => {\n o.error(new DeviceLockedError(\"Device locked.\"));\n }),\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.NANO_X,\n isSecureConnectionAllowed: false,\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 vi.spyOn(\n getDeviceStateDeviceAction,\n \"extractDependencies\",\n ).mockReturnValue(extractDependenciesMock());\n\n const expectedStates: Array<GetDeviceStatusDAState> = [\n onboardCheckPendingState(),\n unlockRequestedPendingState(),\n {\n error: new DeviceLockedError(\"Device locked.\"),\n status: DeviceActionStatus.Error,\n },\n ];\n\n testDeviceActionStates(\n getDeviceStateDeviceAction,\n expectedStates,\n makeDeviceActionInternalApiMock(),\n {\n onDone: resolve,\n onError: reject,\n },\n );\n }));\n\n it(\"should end in an error if the GetAppAndVersion command fails\", () =>\n new Promise<void>((resolve, reject) => {\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 o.complete();\n }),\n );\n\n const getDeviceStateDeviceAction = new GetDeviceStatusDeviceAction({\n input: { unlockTimeout: 500 },\n });\n\n vi.spyOn(\n getDeviceStateDeviceAction,\n \"extractDependencies\",\n ).mockReturnValue(extractDependenciesMock());\n\n const expectedStates: Array<GetDeviceStatusDAState> = [\n onboardCheckPendingState(),\n {\n error,\n status: DeviceActionStatus.Error,\n },\n ];\n\n testDeviceActionStates(\n getDeviceStateDeviceAction,\n expectedStates,\n makeDeviceActionInternalApiMock(),\n {\n onDone: resolve,\n onError: reject,\n },\n );\n }));\n\n it(\"should end in an error if getAppAndVersion actor throws an error\", () =>\n new Promise<void>((resolve, reject) => {\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 vi.spyOn(\n getDeviceStateDeviceAction,\n \"extractDependencies\",\n ).mockReturnValue(extractDependenciesMock());\n\n const expectedStates: Array<GetDeviceStatusDAState> = [\n onboardCheckPendingState(),\n {\n error: new UnknownDAError(\"error\"),\n status: DeviceActionStatus.Error,\n },\n ];\n\n testDeviceActionStates(\n getDeviceStateDeviceAction,\n expectedStates,\n makeDeviceActionInternalApiMock(),\n {\n onDone: resolve,\n onError: reject,\n },\n );\n }));\n });\n\n it(\"should emit a stopped state if the action is cancelled\", () =>\n new Promise<void>((resolve, reject) => {\n apiGetDeviceSessionStateMock.mockReturnValue({\n sessionStateType: DeviceSessionStateType.ReadyWithoutSecureChannel,\n deviceStatus: DeviceStatus.CONNECTED,\n currentApp: { name: \"mockedCurrentApp\", version: \"1.0.0\" },\n installedApps: [],\n deviceModelId: DeviceModelId.NANO_X,\n isSecureConnectionAllowed: false,\n });\n\n sendCommandMock.mockImplementation((command) =>\n command.name === \"getOsVersion\"\n ? Promise.resolve(osVersionCommandResult())\n : Promise.resolve(appAndVersionResult(\"BOLOS\", \"1.0.0\")),\n );\n\n const getDeviceStateDeviceAction = new GetDeviceStatusDeviceAction({\n input: { unlockTimeout: 500 },\n });\n\n const expectedStates: Array<GetDeviceStatusDAState> = [\n onboardCheckPendingState(),\n {\n status: DeviceActionStatus.Stopped,\n },\n ];\n\n const { cancel } = testDeviceActionStates(\n getDeviceStateDeviceAction,\n expectedStates,\n makeDeviceActionInternalApiMock(),\n {\n onDone: resolve,\n onError: reject,\n },\n );\n cancel();\n }));\n});\n"],
5
- "mappings": "aAAA,IAAAA,EAAqC,gBAErCC,EAAqC,4CACrCC,EAAuD,yDAEvDC,EAGO,iDACPC,EAA8B,mCAC9BC,EAA6B,oCAC7BC,EAAgD,6DAChDC,EAAuC,oEACvCC,EAAmC,sDACnCC,EAAwC,4DACxCC,EAIO,wCACPC,EAAuC,kDAEvCC,EAA4C,yCAC5CC,EAGO,mBAEP,MAAMC,EAAyB,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,IAAI,iBAAe,OAAO,EACjC,OAAQ,qBAAmB,KAC7B,CACF,KAEA,0BACEe,EACAE,KACA,mCAAgC,EAChC,CACE,OAAQJ,EACR,QAASC,CACX,CACF,CACF,CAAC,CAAC,CACN,CAAC,EAED,GAAG,yDAA0D,IAC3D,IAAI,QAAc,CAACD,EAASC,IAAW,CACrCH,EAA6B,gBAAgB,CAC3C,iBAAkB,yBAAuB,0BACzC,aAAc,eAAa,UAC3B,WAAY,CAAE,KAAM,mBAAoB,QAAS,OAAQ,EACzD,cAAe,CAAC,EAChB,cAAe,gBAAc,OAC7B,0BAA2B,EAC7B,CAAC,EAEDD,EAAgB,mBAAoBM,GAClCA,EAAQ,OAAS,eACb,QAAQ,QAAQvB,EAAuB,CAAC,EACxC,QAAQ,QAAQG,EAAoB,QAAS,OAAO,CAAC,CAC3D,EAEA,MAAMmB,EAA6B,IAAI,8BAA4B,CACjE,MAAO,CAAE,cAAe,GAAI,CAC9B,CAAC,EAEKE,EAAgD,CACpDjB,EAAyB,EACzB,CACE,OAAQ,qBAAmB,OAC7B,CACF,EAEM,CAAE,OAAA0B,CAAO,KAAI,0BACjBX,EACAE,KACA,mCAAgC,EAChC,CACE,OAAQJ,EACR,QAASC,CACX,CACF,EACAY,EAAO,CACT,CAAC,CAAC,CACN,CAAC",
6
- "names": ["import_rxjs", "import_CommandResult", "import_GetOsVersionCommand", "import_GlobalCommandError", "import_DeviceModel", "import_DeviceStatus", "import_makeInternalApi", "import_testDeviceActionStates", "import_DeviceActionState", "import_UserInteractionRequired", "import_Errors", "import_DeviceSessionState", "import_GetDeviceStatusDeviceAction", "import_types", "osVersionCommandResult", "props", "deviceModelId", "appAndVersionResult", "name", "version", "lockedErrorResult", "onboardCheckPendingState", "onboardCheckPendingStatesWithOsVersionFetch", "unlockRequestedPendingState", "unlockResolvedPendingState", "getAppAndVersionMock", "getOsVersionMock", "getDeviceSessionStateMock", "waitForDeviceUnlockMock", "setDeviceSessionState", "extractDependenciesMock", "sendCommandMock", "apiGetDeviceSessionStateMock", "apiGetDeviceSessionStateObservableMock", "resolve", "reject", "getDeviceStateDeviceAction", "command", "expectedStates", "appCall", "sessionState", "state", "osVersionData", "o", "inner", "i", "error", "cancel"]
4
+ "sourcesContent": ["import { CommandResultFactory } from \"@api/command/model/CommandResult\";\nimport { getOsVersionCommandResponseMockBuilder } from \"@api/command/os/__mocks__/GetOsVersionCommand\";\nimport { type GetAppAndVersionResponse } from \"@api/command/os/GetAppAndVersionCommand\";\nimport { type GetOsVersionResponse } from \"@api/command/os/GetOsVersionCommand\";\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 { setupWaitForAppAndVersionMock } from \"@api/device-action/__test-utils__/setupTestMachine\";\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 {\n type GetDeviceStatusDARequiredInteraction,\n type GetDeviceStatusDAState,\n getDeviceStatusDAStateStep,\n} from \"./types\";\n\nvi.mock(\n \"@api/device-action/os/WaitForAppAndVersion/WaitForAppAndVersionDeviceAction\",\n);\n\nconst osVersionCommandResult = (\n props: Partial<GetOsVersionResponse> = {},\n deviceModelId: DeviceModelId = DeviceModelId.NANO_X,\n) =>\n CommandResultFactory({\n data: getOsVersionCommandResponseMockBuilder(deviceModelId, props),\n });\n\nconst appAndVersion = (\n name: string,\n version: string,\n): GetAppAndVersionResponse => ({\n name,\n version,\n});\n\nconst onboardCheckPendingState = (\n requiredUserInteraction: GetDeviceStatusDARequiredInteraction = UserInteractionRequired.None,\n): GetDeviceStatusDAState => ({\n intermediateValue: {\n requiredUserInteraction,\n step: getDeviceStatusDAStateStep.ONBOARD_CHECK,\n },\n status: DeviceActionStatus.Pending,\n});\n\nconst waitForAppAndVersionPendingState = (\n requiredUserInteraction: GetDeviceStatusDARequiredInteraction = UserInteractionRequired.None,\n): GetDeviceStatusDAState => ({\n intermediateValue: {\n requiredUserInteraction,\n step: getDeviceStatusDAStateStep.WAIT_FOR_APP_AND_VERSION,\n },\n status: DeviceActionStatus.Pending,\n});\n\ndescribe(\"GetDeviceStatusDeviceAction\", () => {\n const getOsVersionMock = vi.fn();\n const getDeviceSessionStateMock = vi.fn();\n const setDeviceSessionState = vi.fn();\n\n function extractDependenciesMock() {\n return {\n getOsVersion: getOsVersionMock,\n getDeviceSessionState: getDeviceSessionStateMock,\n setDeviceSessionState: setDeviceSessionState,\n };\n }\n\n const {\n sendCommand: sendCommandMock,\n getDeviceSessionState: apiGetDeviceSessionStateMock,\n } = makeDeviceActionInternalApiMock();\n\n beforeEach(() => {\n vi.resetAllMocks();\n getOsVersionMock.mockResolvedValue(osVersionCommandResult());\n });\n\n describe(\"without overriding `extractDependencies`\", () => {\n it(\"should run the device action with the device on the dashboard\", () =>\n new Promise<void>((resolve, reject) => {\n setupWaitForAppAndVersionMock(appAndVersion(\"BOLOS\", \"1.0.0\"));\n\n apiGetDeviceSessionStateMock.mockReturnValue({\n sessionStateType: DeviceSessionStateType.Connected,\n deviceStatus: DeviceStatus.CONNECTED,\n deviceModelId: DeviceModelId.NANO_X,\n });\n\n // The current app is BOLOS (dashboard), so the OS version is fetched.\n sendCommandMock.mockResolvedValue(osVersionCommandResult());\n\n const getDeviceStateDeviceAction = new GetDeviceStatusDeviceAction({\n input: { unlockTimeout: 500 },\n });\n\n const expectedStates: Array<GetDeviceStatusDAState> = [\n waitForAppAndVersionPendingState(),\n waitForAppAndVersionPendingState(),\n onboardCheckPendingState(),\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 {\n onDone: resolve,\n onError: reject,\n },\n );\n }));\n\n it(\"should run the device action when the device needs to be unlocked\", () =>\n new Promise<void>((resolve, reject) => {\n setupWaitForAppAndVersionMock(\n appAndVersion(\"BOLOS\", \"1.0.0\"),\n UserInteractionRequired.UnlockDevice,\n );\n\n apiGetDeviceSessionStateMock.mockReturnValue({\n sessionStateType: DeviceSessionStateType.Connected,\n deviceStatus: DeviceStatus.LOCKED,\n deviceModelId: DeviceModelId.NANO_X,\n });\n\n sendCommandMock.mockResolvedValue(osVersionCommandResult());\n\n const getDeviceStateDeviceAction = new GetDeviceStatusDeviceAction({\n input: { unlockTimeout: 500 },\n });\n\n const expectedStates: Array<GetDeviceStatusDAState> = [\n waitForAppAndVersionPendingState(),\n waitForAppAndVersionPendingState(\n UserInteractionRequired.UnlockDevice,\n ),\n onboardCheckPendingState(),\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 {\n onDone: resolve,\n onError: reject,\n },\n );\n }));\n });\n\n describe(\"success cases\", () => {\n it(\"should return the device status if the device is on the dashboard\", () =>\n new Promise<void>((resolve, reject) => {\n setupWaitForAppAndVersionMock(appAndVersion(\"BOLOS\", \"1.0.0\"));\n\n getDeviceSessionStateMock.mockReturnValue({\n sessionStateType: DeviceSessionStateType.ReadyWithoutSecureChannel,\n deviceStatus: DeviceStatus.CONNECTED,\n currentApp: { name: \"mockedCurrentApp\", version: \"1.0.0\" },\n });\n\n const getDeviceStateDeviceAction = new GetDeviceStatusDeviceAction({\n input: { unlockTimeout: undefined },\n });\n\n vi.spyOn(\n getDeviceStateDeviceAction,\n \"extractDependencies\",\n ).mockReturnValue(extractDependenciesMock());\n\n const expectedStates: Array<GetDeviceStatusDAState> = [\n waitForAppAndVersionPendingState(),\n waitForAppAndVersionPendingState(),\n onboardCheckPendingState(),\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 {\n onDone: resolve,\n onError: reject,\n },\n );\n }));\n\n it(\"should return the device status and update the session firmware version\", () =>\n new Promise<void>((resolve, reject) => {\n setupWaitForAppAndVersionMock(appAndVersion(\"BOLOS\", \"1.0.0\"));\n\n // The session must already be ready (not Connected) for the firmware\n // version enrichment from the OS version to be applied. The session\n // state is stateful so the enrichment can be observed.\n let sessionState: object = {\n sessionStateType: DeviceSessionStateType.ReadyWithoutSecureChannel,\n deviceStatus: DeviceStatus.CONNECTED,\n currentApp: { name: \"BOLOS\", version: \"1.0.0\" },\n installedApps: [],\n deviceModelId: DeviceModelId.NANO_X,\n isSecureConnectionAllowed: false,\n };\n getDeviceSessionStateMock.mockImplementation(() => sessionState);\n setDeviceSessionState.mockImplementation((state) => {\n sessionState = state;\n return state;\n });\n\n const getDeviceStateDeviceAction = new GetDeviceStatusDeviceAction({\n input: { unlockTimeout: undefined },\n });\n\n vi.spyOn(\n getDeviceStateDeviceAction,\n \"extractDependencies\",\n ).mockReturnValue(extractDependenciesMock());\n\n const osVersionData = getOsVersionCommandResponseMockBuilder(\n DeviceModelId.NANO_X,\n );\n const expectedStates: Array<GetDeviceStatusDAState> = [\n waitForAppAndVersionPendingState(),\n waitForAppAndVersionPendingState(),\n onboardCheckPendingState(),\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 {\n onDone: () => {\n // Session should be enriched with the firmware version from the OS version.\n expect(setDeviceSessionState).toHaveBeenCalledWith(\n expect.objectContaining({\n isSecureConnectionAllowed:\n osVersionData.secureElementFlags.isSecureConnectionAllowed,\n firmwareVersion: {\n mcu: osVersionData.mcuSephVersion,\n bootloader: osVersionData.mcuBootloaderVersion,\n os: osVersionData.seVersion,\n metadata: osVersionData,\n },\n }),\n );\n resolve();\n },\n onError: reject,\n },\n );\n }));\n\n it(\"should not fetch the OS version when an app other than BOLOS is open\", () =>\n new Promise<void>((resolve, reject) => {\n setupWaitForAppAndVersionMock(appAndVersion(\"Bitcoin\", \"2.1.0\"));\n\n getDeviceSessionStateMock.mockReturnValue({\n sessionStateType: DeviceSessionStateType.Connected,\n deviceStatus: DeviceStatus.CONNECTED,\n deviceModelId: DeviceModelId.NANO_X,\n });\n\n const getDeviceStateDeviceAction = new GetDeviceStatusDeviceAction({\n input: { unlockTimeout: undefined },\n });\n\n vi.spyOn(\n getDeviceStateDeviceAction,\n \"extractDependencies\",\n ).mockReturnValue(extractDependenciesMock());\n\n const expectedStates: Array<GetDeviceStatusDAState> = [\n waitForAppAndVersionPendingState(),\n waitForAppAndVersionPendingState(),\n {\n status: DeviceActionStatus.Completed,\n output: {\n currentApp: \"Bitcoin\",\n currentAppVersion: \"2.1.0\",\n },\n },\n ];\n\n testDeviceActionStates(\n getDeviceStateDeviceAction,\n expectedStates,\n makeDeviceActionInternalApiMock(),\n {\n onDone: () => {\n expect(getOsVersionMock).not.toHaveBeenCalled();\n resolve();\n },\n onError: reject,\n },\n );\n }));\n\n it(\"GIVEN a non-onboarded device WHEN checking the device status THEN it returns the device status by default\", () =>\n new Promise<void>((resolve, reject) => {\n // GIVEN\n setupWaitForAppAndVersionMock(appAndVersion(\"BOLOS\", \"1.0.0\"));\n\n getDeviceSessionStateMock.mockReturnValue({\n sessionStateType: DeviceSessionStateType.ReadyWithoutSecureChannel,\n deviceStatus: DeviceStatus.CONNECTED,\n currentApp: { name: \"BOLOS\", version: \"1.0.0\" },\n installedApps: [],\n deviceModelId: DeviceModelId.NANO_X,\n isSecureConnectionAllowed: false,\n });\n\n getOsVersionMock.mockResolvedValue(\n osVersionCommandResult({\n secureElementFlags: {\n ...getOsVersionCommandResponseMockBuilder().secureElementFlags,\n isOnboarded: false,\n },\n }),\n );\n\n const getDeviceStateDeviceAction = new GetDeviceStatusDeviceAction({\n input: { unlockTimeout: undefined },\n });\n\n vi.spyOn(\n getDeviceStateDeviceAction,\n \"extractDependencies\",\n ).mockReturnValue(extractDependenciesMock());\n\n const expectedStates: Array<GetDeviceStatusDAState> = [\n waitForAppAndVersionPendingState(),\n waitForAppAndVersionPendingState(),\n onboardCheckPendingState(),\n {\n status: DeviceActionStatus.Completed,\n output: {\n currentApp: \"BOLOS\",\n currentAppVersion: \"1.0.0\",\n },\n },\n ];\n\n // WHEN\n testDeviceActionStates(\n getDeviceStateDeviceAction,\n expectedStates,\n makeDeviceActionInternalApiMock(),\n {\n // THEN\n onDone: resolve,\n onError: reject,\n },\n );\n }));\n\n it(\"should surface the unlock interaction then return the device status\", () =>\n new Promise<void>((resolve, reject) => {\n setupWaitForAppAndVersionMock(\n appAndVersion(\"BOLOS\", \"1.0.0\"),\n UserInteractionRequired.UnlockDevice,\n );\n\n getDeviceSessionStateMock.mockReturnValue({\n sessionStateType: DeviceSessionStateType.ReadyWithoutSecureChannel,\n deviceStatus: DeviceStatus.LOCKED,\n currentApp: { name: \"mockedCurrentApp\", version: \"1.0.0\" },\n });\n\n const getDeviceStateDeviceAction = new GetDeviceStatusDeviceAction({\n input: { unlockTimeout: 500 },\n });\n\n vi.spyOn(\n getDeviceStateDeviceAction,\n \"extractDependencies\",\n ).mockReturnValue(extractDependenciesMock());\n\n const expectedStates: Array<GetDeviceStatusDAState> = [\n waitForAppAndVersionPendingState(),\n waitForAppAndVersionPendingState(\n UserInteractionRequired.UnlockDevice,\n ),\n onboardCheckPendingState(),\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 {\n onDone: resolve,\n onError: reject,\n },\n );\n }));\n });\n\n describe(\"errors cases\", () => {\n it(\"GIVEN a non-onboarded device and the non-onboarded allowance is disabled WHEN checking the device status THEN it returns a not-onboarded error\", () =>\n new Promise<void>((resolve, reject) => {\n // GIVEN\n setupWaitForAppAndVersionMock(appAndVersion(\"BOLOS\", \"1.0.0\"));\n\n getDeviceSessionStateMock.mockReturnValue({\n sessionStateType: DeviceSessionStateType.ReadyWithoutSecureChannel,\n deviceStatus: DeviceStatus.CONNECTED,\n currentApp: { name: \"BOLOS\", version: \"1.0.0\" },\n installedApps: [],\n deviceModelId: DeviceModelId.NANO_X,\n isSecureConnectionAllowed: false,\n });\n\n // The device sits on the dashboard (BOLOS), so the OS version reveals\n // the onboarding status.\n getOsVersionMock.mockResolvedValue(\n osVersionCommandResult({\n secureElementFlags: {\n ...getOsVersionCommandResponseMockBuilder().secureElementFlags,\n isOnboarded: false,\n },\n }),\n );\n\n const getDeviceStateDeviceAction = new GetDeviceStatusDeviceAction({\n input: {\n unlockTimeout: 500,\n allowNonOnboardedDevice: false,\n },\n });\n\n vi.spyOn(\n getDeviceStateDeviceAction,\n \"extractDependencies\",\n ).mockReturnValue(extractDependenciesMock());\n\n const expectedStates: Array<GetDeviceStatusDAState> = [\n waitForAppAndVersionPendingState(),\n waitForAppAndVersionPendingState(),\n onboardCheckPendingState(),\n {\n error: new DeviceNotOnboardedError(),\n status: DeviceActionStatus.Error,\n },\n ];\n\n // WHEN\n testDeviceActionStates(\n getDeviceStateDeviceAction,\n expectedStates,\n makeDeviceActionInternalApiMock(),\n {\n // THEN\n onDone: resolve,\n onError: reject,\n },\n );\n }));\n\n it(\"should end in an error if the device is locked and the user does not unlock\", () =>\n new Promise<void>((resolve, reject) => {\n setupWaitForAppAndVersionMock(\n new DeviceLockedError(\"Device locked.\"),\n UserInteractionRequired.UnlockDevice,\n );\n\n getDeviceSessionStateMock.mockReturnValue({\n sessionStateType: DeviceSessionStateType.ReadyWithoutSecureChannel,\n deviceStatus: DeviceStatus.LOCKED,\n currentApp: { name: \"mockedCurrentApp\", version: \"1.0.0\" },\n });\n\n const getDeviceStateDeviceAction = new GetDeviceStatusDeviceAction({\n input: { unlockTimeout: 500 },\n });\n\n vi.spyOn(\n getDeviceStateDeviceAction,\n \"extractDependencies\",\n ).mockReturnValue(extractDependenciesMock());\n\n const expectedStates: Array<GetDeviceStatusDAState> = [\n waitForAppAndVersionPendingState(),\n waitForAppAndVersionPendingState(\n UserInteractionRequired.UnlockDevice,\n ),\n {\n error: new DeviceLockedError(\"Device locked.\"),\n status: DeviceActionStatus.Error,\n },\n ];\n\n testDeviceActionStates(\n getDeviceStateDeviceAction,\n expectedStates,\n makeDeviceActionInternalApiMock(),\n {\n onDone: resolve,\n onError: reject,\n },\n );\n }));\n\n it(\"should end in an error if the WaitForAppAndVersion sub-action fails\", () =>\n new Promise<void>((resolve, reject) => {\n const error = new GlobalCommandError({\n ...GLOBAL_ERRORS[\"5501\"],\n errorCode: \"5501\",\n });\n\n setupWaitForAppAndVersionMock(error);\n\n getDeviceSessionStateMock.mockReturnValue({\n sessionStateType: DeviceSessionStateType.ReadyWithoutSecureChannel,\n deviceStatus: DeviceStatus.LOCKED,\n currentApp: { name: \"mockedCurrentApp\", version: \"1.0.0\" },\n });\n\n const getDeviceStateDeviceAction = new GetDeviceStatusDeviceAction({\n input: { unlockTimeout: 500 },\n });\n\n vi.spyOn(\n getDeviceStateDeviceAction,\n \"extractDependencies\",\n ).mockReturnValue(extractDependenciesMock());\n\n const expectedStates: Array<GetDeviceStatusDAState> = [\n waitForAppAndVersionPendingState(),\n waitForAppAndVersionPendingState(),\n {\n error,\n status: DeviceActionStatus.Error,\n },\n ];\n\n testDeviceActionStates(\n getDeviceStateDeviceAction,\n expectedStates,\n makeDeviceActionInternalApiMock(),\n {\n onDone: resolve,\n onError: reject,\n },\n );\n }));\n\n it(\"should end in an error if the GetOsVersion command fails\", () =>\n new Promise<void>((resolve, reject) => {\n setupWaitForAppAndVersionMock(appAndVersion(\"BOLOS\", \"1.0.0\"));\n\n getDeviceSessionStateMock.mockReturnValue({\n sessionStateType: DeviceSessionStateType.ReadyWithoutSecureChannel,\n deviceStatus: DeviceStatus.CONNECTED,\n currentApp: { name: \"BOLOS\", version: \"1.0.0\" },\n });\n\n const error = new GlobalCommandError({\n ...GLOBAL_ERRORS[\"5501\"],\n errorCode: \"5501\",\n });\n\n getOsVersionMock.mockResolvedValue(CommandResultFactory({ error }));\n\n const getDeviceStateDeviceAction = new GetDeviceStatusDeviceAction({\n input: { unlockTimeout: 500 },\n });\n\n vi.spyOn(\n getDeviceStateDeviceAction,\n \"extractDependencies\",\n ).mockReturnValue(extractDependenciesMock());\n\n const expectedStates: Array<GetDeviceStatusDAState> = [\n waitForAppAndVersionPendingState(),\n waitForAppAndVersionPendingState(),\n onboardCheckPendingState(),\n {\n error,\n status: DeviceActionStatus.Error,\n },\n ];\n\n testDeviceActionStates(\n getDeviceStateDeviceAction,\n expectedStates,\n makeDeviceActionInternalApiMock(),\n {\n onDone: resolve,\n onError: reject,\n },\n );\n }));\n\n it(\"should end in an error if the getOsVersion actor throws an error\", () =>\n new Promise<void>((resolve, reject) => {\n setupWaitForAppAndVersionMock(appAndVersion(\"BOLOS\", \"1.0.0\"));\n\n getDeviceSessionStateMock.mockReturnValue({\n sessionStateType: DeviceSessionStateType.ReadyWithoutSecureChannel,\n deviceStatus: DeviceStatus.CONNECTED,\n currentApp: { name: \"BOLOS\", version: \"1.0.0\" },\n });\n\n getOsVersionMock.mockImplementation(() => {\n throw new UnknownDAError(\"error\");\n });\n\n const getDeviceStateDeviceAction = new GetDeviceStatusDeviceAction({\n input: { unlockTimeout: 500 },\n });\n\n vi.spyOn(\n getDeviceStateDeviceAction,\n \"extractDependencies\",\n ).mockReturnValue(extractDependenciesMock());\n\n const expectedStates: Array<GetDeviceStatusDAState> = [\n waitForAppAndVersionPendingState(),\n waitForAppAndVersionPendingState(),\n onboardCheckPendingState(),\n {\n error: new UnknownDAError(\"error\"),\n status: DeviceActionStatus.Error,\n },\n ];\n\n testDeviceActionStates(\n getDeviceStateDeviceAction,\n expectedStates,\n makeDeviceActionInternalApiMock(),\n {\n onDone: resolve,\n onError: reject,\n },\n );\n }));\n });\n\n it(\"should emit a stopped state if the action is cancelled\", () =>\n new Promise<void>((resolve, reject) => {\n setupWaitForAppAndVersionMock(appAndVersion(\"BOLOS\", \"1.0.0\"));\n\n apiGetDeviceSessionStateMock.mockReturnValue({\n sessionStateType: DeviceSessionStateType.ReadyWithoutSecureChannel,\n deviceStatus: DeviceStatus.CONNECTED,\n currentApp: { name: \"mockedCurrentApp\", version: \"1.0.0\" },\n installedApps: [],\n deviceModelId: DeviceModelId.NANO_X,\n isSecureConnectionAllowed: false,\n });\n\n sendCommandMock.mockResolvedValue(osVersionCommandResult());\n\n const getDeviceStateDeviceAction = new GetDeviceStatusDeviceAction({\n input: { unlockTimeout: 500 },\n });\n\n const expectedStates: Array<GetDeviceStatusDAState> = [\n waitForAppAndVersionPendingState(),\n waitForAppAndVersionPendingState(),\n {\n status: DeviceActionStatus.Stopped,\n },\n ];\n\n const { cancel } = testDeviceActionStates(\n getDeviceStateDeviceAction,\n expectedStates,\n makeDeviceActionInternalApiMock(),\n {\n onDone: resolve,\n onError: reject,\n },\n );\n cancel();\n }));\n});\n"],
5
+ "mappings": "aAAA,IAAAA,EAAqC,4CACrCC,EAAuD,yDAGvDC,EAGO,iDACPC,EAA8B,mCAC9BC,EAA6B,oCAC7BC,EAAgD,6DAChDC,EAA8C,8DAC9CC,EAAuC,oEACvCC,EAAmC,sDACnCC,EAAwC,4DACxCC,EAIO,wCACPC,EAAuC,kDAEvCC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ED,GAAG,MACDA,EACA,qBACF,EAAE,gBAAgBL,EAAwB,CAAC,EAE3C,MAAMM,EAAgD,CACpDV,EAAiC,EACjCA,EAAiC,EACjCF,EAAyB,EACzB,CACE,MAAO,IAAI,iBAAe,OAAO,EACjC,OAAQ,qBAAmB,KAC7B,CACF,KAEA,0BACEW,EACAC,KACA,mCAAgC,EAChC,CACE,OAAQH,EACR,QAASC,CACX,CACF,CACF,CAAC,CAAC,CACN,CAAC,EAED,GAAG,yDAA0D,IAC3D,IAAI,QAAc,CAACD,EAASC,IAAW,IACrC,iCAA8Bb,EAAc,QAAS,OAAO,CAAC,EAE7DW,EAA6B,gBAAgB,CAC3C,iBAAkB,yBAAuB,0BACzC,aAAc,eAAa,UAC3B,WAAY,CAAE,KAAM,mBAAoB,QAAS,OAAQ,EACzD,cAAe,CAAC,EAChB,cAAe,gBAAc,OAC7B,0BAA2B,EAC7B,CAAC,EAEDD,EAAgB,kBAAkBb,EAAuB,CAAC,EAE1D,MAAMiB,EAA6B,IAAI,8BAA4B,CACjE,MAAO,CAAE,cAAe,GAAI,CAC9B,CAAC,EAEKC,EAAgD,CACpDV,EAAiC,EACjCA,EAAiC,EACjC,CACE,OAAQ,qBAAmB,OAC7B,CACF,EAEM,CAAE,OAAAe,CAAO,KAAI,0BACjBN,EACAC,KACA,mCAAgC,EAChC,CACE,OAAQH,EACR,QAASC,CACX,CACF,EACAO,EAAO,CACT,CAAC,CAAC,CACN,CAAC",
6
+ "names": ["import_CommandResult", "import_GetOsVersionCommand", "import_GlobalCommandError", "import_DeviceModel", "import_DeviceStatus", "import_makeInternalApi", "import_setupTestMachine", "import_testDeviceActionStates", "import_DeviceActionState", "import_UserInteractionRequired", "import_Errors", "import_DeviceSessionState", "import_GetDeviceStatusDeviceAction", "import_types", "osVersionCommandResult", "props", "deviceModelId", "appAndVersion", "name", "version", "onboardCheckPendingState", "requiredUserInteraction", "waitForAppAndVersionPendingState", "getOsVersionMock", "getDeviceSessionStateMock", "setDeviceSessionState", "extractDependenciesMock", "sendCommandMock", "apiGetDeviceSessionStateMock", "resolve", "reject", "getDeviceStateDeviceAction", "expectedStates", "sessionState", "state", "osVersionData", "error", "cancel"]
7
7
  }
@@ -1,2 +1,2 @@
1
- "use strict";var i=Object.defineProperty;var n=Object.getOwnPropertyDescriptor;var c=Object.getOwnPropertyNames;var D=Object.prototype.hasOwnProperty;var p=(t,e)=>{for(var o in e)i(t,o,{get:e[o],enumerable:!0})},u=(t,e,o,a)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of c(e))!D.call(t,r)&&r!==o&&i(t,r,{get:()=>e[r],enumerable:!(a=n(e,r))||a.enumerable});return t};var s=t=>u(i({},"__esModule",{value:!0}),t);var v={};p(v,{getDeviceStatusDAStateStep:()=>S});module.exports=s(v);const S=Object.freeze({ONBOARD_CHECK:"os.getDeviceStatus.steps.onboardCheck",UNLOCK_DEVICE:"os.getDeviceStatus.steps.unlockDevice"});0&&(module.exports={getDeviceStatusDAStateStep});
1
+ "use strict";var i=Object.defineProperty;var p=Object.getOwnPropertyDescriptor;var n=Object.getOwnPropertyNames;var D=Object.prototype.hasOwnProperty;var c=(t,e)=>{for(var o in e)i(t,o,{get:e[o],enumerable:!0})},s=(t,e,o,a)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of n(e))!D.call(t,r)&&r!==o&&i(t,r,{get:()=>e[r],enumerable:!(a=p(e,r))||a.enumerable});return t};var u=t=>s(i({},"__esModule",{value:!0}),t);var S={};c(S,{getDeviceStatusDAStateStep:()=>A});module.exports=u(S);const A=Object.freeze({WAIT_FOR_APP_AND_VERSION:"os.getDeviceStatus.steps.waitForAppAndVersion",ONBOARD_CHECK:"os.getDeviceStatus.steps.onboardCheck"});0&&(module.exports={getDeviceStatusDAStateStep});
2
2
  //# sourceMappingURL=types.js.map