@ledgerhq/device-management-kit 0.0.0-io-revamp-20250710095731 → 0.0.0-io-revamp-20250715160954
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/cjs/src/api/command/utils/GlobalCommandError.js +1 -1
- package/lib/cjs/src/api/command/utils/GlobalCommandError.js.map +2 -2
- package/lib/cjs/src/api/device-action/os/GetDeviceStatus/GetDeviceStatusDeviceAction.js +1 -1
- package/lib/cjs/src/api/device-action/os/GetDeviceStatus/GetDeviceStatusDeviceAction.js.map +2 -2
- package/lib/cjs/src/api/device-action/os/GetDeviceStatus/GetDeviceStatusDeviceAction.test.js +1 -1
- package/lib/cjs/src/api/device-action/os/GetDeviceStatus/GetDeviceStatusDeviceAction.test.js.map +2 -2
- package/lib/cjs/src/api/device-action/os/GoToDashboard/GoToDashboardDeviceAction.js +1 -1
- package/lib/cjs/src/api/device-action/os/GoToDashboard/GoToDashboardDeviceAction.js.map +3 -3
- package/lib/cjs/src/api/device-action/os/OpenAppDeviceAction/OpenAppDeviceAction.js +1 -1
- package/lib/cjs/src/api/device-action/os/OpenAppDeviceAction/OpenAppDeviceAction.js.map +3 -3
- package/lib/cjs/src/api/utils/AppName.js +2 -0
- package/lib/cjs/src/api/utils/AppName.js.map +7 -0
- package/lib/cjs/src/api/utils/AppName.test.js +2 -0
- package/lib/cjs/src/api/utils/AppName.test.js.map +7 -0
- package/lib/esm/src/api/command/utils/GlobalCommandError.js +1 -1
- package/lib/esm/src/api/command/utils/GlobalCommandError.js.map +2 -2
- package/lib/esm/src/api/device-action/os/GetDeviceStatus/GetDeviceStatusDeviceAction.js +1 -1
- package/lib/esm/src/api/device-action/os/GetDeviceStatus/GetDeviceStatusDeviceAction.js.map +2 -2
- package/lib/esm/src/api/device-action/os/GetDeviceStatus/GetDeviceStatusDeviceAction.test.js +1 -1
- package/lib/esm/src/api/device-action/os/GetDeviceStatus/GetDeviceStatusDeviceAction.test.js.map +2 -2
- package/lib/esm/src/api/device-action/os/GoToDashboard/GoToDashboardDeviceAction.js +1 -1
- package/lib/esm/src/api/device-action/os/GoToDashboard/GoToDashboardDeviceAction.js.map +3 -3
- package/lib/esm/src/api/device-action/os/OpenAppDeviceAction/OpenAppDeviceAction.js +1 -1
- package/lib/esm/src/api/device-action/os/OpenAppDeviceAction/OpenAppDeviceAction.js.map +3 -3
- package/lib/esm/src/api/utils/AppName.js +2 -0
- package/lib/esm/src/api/utils/AppName.js.map +7 -0
- package/lib/esm/src/api/utils/AppName.test.js +2 -0
- package/lib/esm/src/api/utils/AppName.test.js.map +7 -0
- package/lib/types/src/api/command/utils/GlobalCommandError.d.ts +1 -1
- package/lib/types/src/api/command/utils/GlobalCommandError.d.ts.map +1 -1
- package/lib/types/src/api/device-action/os/GetDeviceStatus/GetDeviceStatusDeviceAction.d.ts.map +1 -1
- package/lib/types/src/api/device-action/os/GoToDashboard/GoToDashboardDeviceAction.d.ts.map +1 -1
- package/lib/types/src/api/device-action/os/OpenAppDeviceAction/OpenAppDeviceAction.d.ts.map +1 -1
- package/lib/types/src/api/utils/AppName.d.ts +2 -0
- package/lib/types/src/api/utils/AppName.d.ts.map +1 -0
- package/lib/types/src/api/utils/AppName.test.d.ts +2 -0
- package/lib/types/src/api/utils/AppName.test.d.ts.map +1 -0
- package/lib/types/tsconfig.prod.tsbuildinfo +1 -1
- package/package.json +3 -3
@@ -1,7 +1,7 @@
|
|
1
1
|
{
|
2
2
|
"version": 3,
|
3
3
|
"sources": ["../../../../../../../src/api/device-action/os/GoToDashboard/GoToDashboardDeviceAction.ts"],
|
4
|
-
"sourcesContent": ["import { Left, Right } from \"purify-ts\";\nimport { assign, fromPromise, setup } from \"xstate\";\n\nimport { isSuccessCommandResult } from \"@api/command/model/CommandResult\";\nimport {\n CloseAppCommand,\n type CloseAppCommandResult,\n} from \"@api/command/os/CloseAppCommand\";\nimport {\n GetAppAndVersionCommand,\n type GetAppAndVersionCommandResult,\n} from \"@api/command/os/GetAppAndVersionCommand\";\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 { UnknownDAError } from \"@api/device-action/os/Errors\";\nimport { GetDeviceStatusDeviceAction } from \"@api/device-action/os/GetDeviceStatus/GetDeviceStatusDeviceAction\";\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} from \"@api/device-session/DeviceSessionState\";\n\nimport type {\n GoToDashboardDAError,\n GoToDashboardDAInput,\n GoToDashboardDAIntermediateValue,\n GoToDashboardDAOutput,\n} from \"./types\";\n\ntype GoToDashboardMachineInternalState = {\n readonly currentApp: string | null;\n readonly error: GoToDashboardDAError | null;\n};\n\nexport type MachineDependencies = {\n readonly getAppAndVersion: () => Promise<GetAppAndVersionCommandResult>;\n readonly closeApp: () => Promise<CloseAppCommandResult>;\n readonly getDeviceSessionState: () => DeviceSessionState;\n readonly setDeviceSessionState: (\n state: DeviceSessionState,\n ) => DeviceSessionState;\n};\n\nexport type ExtractMachineDependencies = (\n internalApi: InternalApi,\n) => MachineDependencies;\n\nexport class GoToDashboardDeviceAction extends XStateDeviceAction<\n GoToDashboardDAOutput,\n GoToDashboardDAInput,\n GoToDashboardDAError,\n GoToDashboardDAIntermediateValue,\n GoToDashboardMachineInternalState\n> {\n makeStateMachine(\n internalApi: InternalApi,\n ): DeviceActionStateMachine<\n GoToDashboardDAOutput,\n GoToDashboardDAInput,\n GoToDashboardDAError,\n GoToDashboardDAIntermediateValue,\n GoToDashboardMachineInternalState\n > {\n type types = StateMachineTypes<\n GoToDashboardDAOutput,\n GoToDashboardDAInput,\n GoToDashboardDAError,\n GoToDashboardDAIntermediateValue,\n GoToDashboardMachineInternalState\n >;\n\n const {\n getDeviceSessionState,\n setDeviceSessionState,\n closeApp,\n getAppAndVersion,\n } = this.extractDependencies(internalApi);\n\n const unlockTimeout = this.input.unlockTimeout ?? DEFAULT_UNLOCK_TIMEOUT_MS;\n\n const getDeviceStatusMachine = new GetDeviceStatusDeviceAction({\n input: {\n unlockTimeout,\n },\n }).makeStateMachine(internalApi);\n return setup({\n types: {\n input: {\n unlockTimeout,\n } as types[\"input\"],\n context: {} as types[\"context\"],\n output: {} as types[\"output\"],\n },\n actors: {\n getAppAndVersion: fromPromise(getAppAndVersion),\n closeApp: fromPromise(closeApp),\n getDeviceStatus: getDeviceStatusMachine,\n },\n guards: {\n hasError: ({ context }: { context: types[\"context\"] }) => {\n return context._internalState.error !== null;\n },\n isDashboardOpen: ({ context }: { context: types[\"context\"] }) =>\n context._internalState.currentApp === \"BOLOS\",\n },\n actions: {\n // assignGetDeviceStatusUnknownError: assign({\n // _internalState: (_) => ({\n // ..._.context._internalState,\n // error: new UnknownDAError(\"GetDeviceUnknownStatusError\"),\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 N4IgpgJg5mDOIC5QHED2AVVARAhrAFgEao4BOEWYAbgJYDGYAgnQC42oB2AdJbQwEpgcEAJ4BiANoAGALqJQAB1SwabTvJAAPRAHYAjFwDMATikA2MwA5DOnQBYArGeOGANCBGI9VrlcvmpRyknQwcAXzD3NExcAmIyCmp6JlZ2bmQwFl5kgGUWHBYAV1gxCE4wLhoOKlQAawqIJIY8guLpOSQQJRU1Dg1tBAAmOy49QYcpHQdBvR0pMcszO3dPBEM7My4HYz1pqWNLPRsdJYiojGw8IhJybIZmXq4AYXwwOlq7sBaikvaNbtUaX6iDsgy2g3Wdksjn8JlBDhWiAchk2OkMgysB2RzlBZxA0UucRuiT4KUeLzeHyaX3yP0keg6im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HQZGweSR7qhDLcMTqN9vcDkhR0AwsCq1Gq1GhyIxWvsSYWMZ-I9mTJGEbXsx7Av4Qb7ecsR48ACirHsRXmMBjIi2JaRwEIDzeWtsDMmgUdCthwjadSaJFiWBumEIAA */\n id: \"GoToDashboardDeviceAction\",\n initial: \"DeviceReady\",\n context: (_) => {\n const sessionState = getDeviceSessionState();\n return {\n input: {\n unlockTimeout: _.input.unlockTimeout,\n },\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.None,\n },\n _internalState: {\n currentApp:\n \"currentApp\" in sessionState\n ? sessionState.currentApp.name\n : null,\n error: null,\n },\n };\n },\n states: {\n DeviceReady: {\n always: {\n target: \"GetDeviceStatus\",\n },\n },\n GetDeviceStatus: {\n // We run the GetDeviceStatus flow to get information about the device state\n invoke: {\n id: \"deviceStatus\",\n src: \"getDeviceStatus\",\n input: (_) => ({\n unlockTimeout: _.context.input.unlockTimeout,\n }),\n onSnapshot: {\n actions: assign({\n intermediateValue: (_) =>\n _.event.snapshot.context.intermediateValue,\n }),\n },\n onDone: {\n target: \"CheckDeviceStatus\",\n actions: assign({\n _internalState: (_) => {\n return _.event.output.caseOf<GoToDashboardMachineInternalState>(\n {\n Right: (output) => ({\n ..._.context._internalState,\n currentApp: output.currentApp,\n }),\n Left: (error) => ({\n ..._.context._internalState,\n error,\n }),\n },\n );\n },\n }),\n },\n // NOTE: The way we handle our DeviceActions means that we should never as we return an Either\n // onError: {\n // target: \"Error\",\n // actions: \"assignGetDeviceStatusUnknownError\",\n // },\n },\n },\n CheckDeviceStatus: {\n // We check the device status to see if we can have an error\n always: [\n {\n target: \"Error\",\n guard: \"hasError\",\n },\n {\n target: \"DashboardCheck\",\n },\n ],\n },\n DashboardCheck: {\n // We check if the dashboard is open\n always: [\n {\n target: \"Success\",\n guard: \"isDashboardOpen\",\n },\n {\n target: \"Error\",\n guard: \"hasError\",\n },\n {\n target: \"Error\",\n guard: (_) => {\n return _.context._internalState.currentApp === null;\n },\n actions: assign({\n _internalState: (_) => ({\n ..._.context._internalState,\n error: new UnknownDAError(\"currentApp === null\"),\n }),\n }),\n },\n {\n target: \"CloseApp\",\n },\n ],\n },\n CloseApp: {\n invoke: {\n src: \"closeApp\",\n onDone: {\n target: \"CloseAppCheck\",\n actions: assign({\n _internalState: (_) => {\n if (isSuccessCommandResult(_.event.output)) {\n return _.context._internalState;\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 CloseAppCheck: {\n always: [\n {\n target: \"Error\",\n guard: \"hasError\",\n },\n {\n target: \"GetAppAndVersion\",\n reenter: true,\n },\n ],\n },\n GetAppAndVersion: {\n invoke: {\n src: \"getAppAndVersion\",\n onDone: {\n target: \"DashboardCheck\",\n actions: assign({\n _internalState: (_) => {\n if (isSuccessCommandResult(_.event.output)) {\n const state: DeviceSessionState = getDeviceSessionState();\n // Narrow the type to ReadyWithoutSecureChannelState or ReadyWithSecureChannelState\n if (\n state.sessionStateType !==\n DeviceSessionStateType.Connected\n ) {\n setDeviceSessionState({\n ...state,\n currentApp: _.event.output.data,\n });\n }\n return {\n ..._.context._internalState,\n currentApp: _.event.output.data.name,\n };\n }\n return {\n ..._.context._internalState,\n error: _.event.output.error,\n };\n },\n }),\n },\n },\n },\n Success: {\n type: \"final\",\n },\n Error: {\n type: \"final\",\n },\n },\n output: (_) => {\n if (_.context._internalState.error) {\n return Left(_.context._internalState.error);\n }\n\n return Right(undefined);\n },\n });\n }\n\n extractDependencies(internalApi: InternalApi): MachineDependencies {\n const closeApp = async () => internalApi.sendCommand(new CloseAppCommand());\n const getAppAndVersion = async () =>\n internalApi.sendCommand(new GetAppAndVersionCommand());\n\n return {\n closeApp,\n getAppAndVersion,\n getDeviceSessionState: () => internalApi.getDeviceSessionState(),\n setDeviceSessionState: (state: DeviceSessionState) =>\n internalApi.setDeviceSessionState(state),\n };\n }\n}\n"],
|
5
|
-
"mappings": "AAAA,OAAS,QAAAA,EAAM,SAAAC,MAAa,YAC5B,OAAS,UAAAC,EAAQ,eAAAC,EAAa,SAAAC,MAAa,SAE3C,OAAS,0BAAAC,MAA8B,mCACvC,OACE,mBAAAC,MAEK,kCACP,OACE,2BAAAC,MAEK,0CAEP,OAAS,2BAAAC,MAA+B,mDACxC,OAAS,6BAAAC,MAAiC,8BAC1C,OAAS,kBAAAC,MAAsB,+BAC/B,OAAS,+BAAAC,MAAmC,oEAE5C,OAEE,sBAAAC,MACK,qDACP,OAEE,0BAAAC,MACK,
|
6
|
-
"names": ["Left", "Right", "assign", "fromPromise", "setup", "isSuccessCommandResult", "CloseAppCommand", "GetAppAndVersionCommand", "UserInteractionRequired", "DEFAULT_UNLOCK_TIMEOUT_MS", "UnknownDAError", "GetDeviceStatusDeviceAction", "XStateDeviceAction", "DeviceSessionStateType", "GoToDashboardDeviceAction", "internalApi", "getDeviceSessionState", "setDeviceSessionState", "closeApp", "getAppAndVersion", "unlockTimeout", "getDeviceStatusMachine", "context", "_", "sessionState", "output", "error", "state"]
|
4
|
+
"sourcesContent": ["import { Left, Right } from \"purify-ts\";\nimport { assign, fromPromise, setup } from \"xstate\";\n\nimport { isSuccessCommandResult } from \"@api/command/model/CommandResult\";\nimport {\n CloseAppCommand,\n type CloseAppCommandResult,\n} from \"@api/command/os/CloseAppCommand\";\nimport {\n GetAppAndVersionCommand,\n type GetAppAndVersionCommandResult,\n} from \"@api/command/os/GetAppAndVersionCommand\";\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 { UnknownDAError } from \"@api/device-action/os/Errors\";\nimport { GetDeviceStatusDeviceAction } from \"@api/device-action/os/GetDeviceStatus/GetDeviceStatusDeviceAction\";\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} from \"@api/device-session/DeviceSessionState\";\nimport { isDashboardName } from \"@api/utils/AppName\";\n\nimport type {\n GoToDashboardDAError,\n GoToDashboardDAInput,\n GoToDashboardDAIntermediateValue,\n GoToDashboardDAOutput,\n} from \"./types\";\n\ntype GoToDashboardMachineInternalState = {\n readonly currentApp: string | null;\n readonly error: GoToDashboardDAError | null;\n};\n\nexport type MachineDependencies = {\n readonly getAppAndVersion: () => Promise<GetAppAndVersionCommandResult>;\n readonly closeApp: () => Promise<CloseAppCommandResult>;\n readonly getDeviceSessionState: () => DeviceSessionState;\n readonly setDeviceSessionState: (\n state: DeviceSessionState,\n ) => DeviceSessionState;\n};\n\nexport type ExtractMachineDependencies = (\n internalApi: InternalApi,\n) => MachineDependencies;\n\nexport class GoToDashboardDeviceAction extends XStateDeviceAction<\n GoToDashboardDAOutput,\n GoToDashboardDAInput,\n GoToDashboardDAError,\n GoToDashboardDAIntermediateValue,\n GoToDashboardMachineInternalState\n> {\n makeStateMachine(\n internalApi: InternalApi,\n ): DeviceActionStateMachine<\n GoToDashboardDAOutput,\n GoToDashboardDAInput,\n GoToDashboardDAError,\n GoToDashboardDAIntermediateValue,\n GoToDashboardMachineInternalState\n > {\n type types = StateMachineTypes<\n GoToDashboardDAOutput,\n GoToDashboardDAInput,\n GoToDashboardDAError,\n GoToDashboardDAIntermediateValue,\n GoToDashboardMachineInternalState\n >;\n\n const {\n getDeviceSessionState,\n setDeviceSessionState,\n closeApp,\n getAppAndVersion,\n } = this.extractDependencies(internalApi);\n\n const unlockTimeout = this.input.unlockTimeout ?? DEFAULT_UNLOCK_TIMEOUT_MS;\n\n const getDeviceStatusMachine = new GetDeviceStatusDeviceAction({\n input: {\n unlockTimeout,\n },\n }).makeStateMachine(internalApi);\n return setup({\n types: {\n input: {\n unlockTimeout,\n } as types[\"input\"],\n context: {} as types[\"context\"],\n output: {} as types[\"output\"],\n },\n actors: {\n getAppAndVersion: fromPromise(getAppAndVersion),\n closeApp: fromPromise(closeApp),\n getDeviceStatus: getDeviceStatusMachine,\n },\n guards: {\n hasError: ({ context }: { context: types[\"context\"] }) => {\n return context._internalState.error !== null;\n },\n isDashboardOpen: ({ context }: { context: types[\"context\"] }) =>\n context._internalState.currentApp !== null &&\n isDashboardName(context._internalState.currentApp),\n },\n actions: {\n // assignGetDeviceStatusUnknownError: assign({\n // _internalState: (_) => ({\n // ..._.context._internalState,\n // error: new UnknownDAError(\"GetDeviceUnknownStatusError\"),\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 N4IgpgJg5mDOIC5QHED2AVVARAhrAFgEao4BOEWYAbgJYDGYAgnQC42oB2AdJbQwEpgcEAJ4BiANoAGALqJQAB1SwabTvJAAPRAHYAjFwDMATikA2MwA5DOnQBYArGeOGANCBGI9VrlcvmpRyknQwcAXzD3NExcAmIyCmp6JlZ2bmQwFl5kgGUWHBYAV1gxCE4wLhoOKlQAawqIJIY8guLpOSQQJRU1Dg1tBAAmOy49QYcpHQdBvR0pMcszO3dPBEM7My4HYz1pqWNLPRsdJYiojGw8IhJybIZmXq4AYXwwOlq7sBaikvaNbtUaX6iDsgy2g3Wdksjn8JlBDhWiAchk2OkMgysB2RzlBZxA0UucRuiT4KUeLzeHyaX3yP0keg6imUgPUnQGgxmo3hdkcemMwwcG0RCGxXDRGMsWJRxlxkXxF1i1wSnweaR4V3i5Ap70ksn+zN6wIQfMsYsG0LMg2MZlm60mwucDi4HMli0GgX0zjxBMVmpJyVVnHVRIS2tq9MZXQNQLZII5XEcoQx5kO3mWHkQjud5oOlo93mM3oVGuJKtSQd9xLDkkGkYBhtjCEtxi41h5fJs+ysOgdOjBE2Gw1sUmC5qLMRLyupge4ldDrx1EkMdejrNAA2sTu8jsO0Lsej5wr7prsoTGs2CJz748JStu0-L3CeABtlEwFApSuVKtU6hUfZO96kjOzyvrA74KAgVQ1HQBRpO0fydPWMbrl4kwGFMzizMYcyCsK-gjE4OiWBC-jGDK+g3nOQEBo+oFvowH5iGApCkKgpBcAoz4FAAZuxAC2XAASGNH3HRL4MR+UG-rBvQIXqSGrn0jaHGCNocoYko2BiUzCvymyadsdg6Dh+zTFRgH+mJ5JgRB1aIUyPQoVoaHEWKegjsYDgOGi9hjMKHmGAYdg7KCVhLOagoWSJVlkmqEngYxCj2Qy+pOWuLnGuMUhcNagoHMZgqhMYAVSEFCahRKEWWFFcrCXesUgRkLBJYwHAQAAaixKicF+HAVNBf5CcWMVlo8zWte1XWkD1HDSTBcGcPJK7pcpqEIARCZQsMqZSDM+7Cg4limjaXnbHMlhzIYERyhwqCNPAnT1X6Y3OchGUDAAtDKvj6NYgQohYljCsMRjzIYASTN2NjXXVI0Na9FbUoIwirI5LJrZloJcCOI52GVZihD5goIhmxoHq24OQycl02NFCMPuNmSfN8xRpRjRqfRsv16P9p4WFYIOGIYCYjgex1mD5oLrPTL2M-FC5UqSrOPejDbrbMraniZ+4nGV6J6OmqwbJsl3jPY2wQ2YaKy6W8sVpZYbs+rmUzDl4y84T7rBDyZgOvsWvqd4EI67bU7AeJtlJc7zkbnyYrBORxGaVCDh6PhhtGAcJjjPye3EWHolxUGCV2YrMcfWhFi5TyjgUYb9h+2TFG+GMIUhRyUy7IXjV0RNH5tZ13VvUpRpjOYYpBWZCxzOnZNHQZGweSR7qhDLcMTqN9vcDkhR0AwsCq1Gq1GhyIxWvsSYWMZ-I9mTJGEbXsx7Av4Qb7ecsR48ACirHsRXmMBjIi2JaRwEIDzeWtsDMmgUdCthwjadSaJFiWBumEIAA */\n id: \"GoToDashboardDeviceAction\",\n initial: \"DeviceReady\",\n context: (_) => {\n const sessionState = getDeviceSessionState();\n return {\n input: {\n unlockTimeout: _.input.unlockTimeout,\n },\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.None,\n },\n _internalState: {\n currentApp:\n \"currentApp\" in sessionState\n ? sessionState.currentApp.name\n : null,\n error: null,\n },\n };\n },\n states: {\n DeviceReady: {\n always: {\n target: \"GetDeviceStatus\",\n },\n },\n GetDeviceStatus: {\n // We run the GetDeviceStatus flow to get information about the device state\n invoke: {\n id: \"deviceStatus\",\n src: \"getDeviceStatus\",\n input: (_) => ({\n unlockTimeout: _.context.input.unlockTimeout,\n }),\n onSnapshot: {\n actions: assign({\n intermediateValue: (_) =>\n _.event.snapshot.context.intermediateValue,\n }),\n },\n onDone: {\n target: \"CheckDeviceStatus\",\n actions: assign({\n _internalState: (_) => {\n return _.event.output.caseOf<GoToDashboardMachineInternalState>(\n {\n Right: (output) => ({\n ..._.context._internalState,\n currentApp: output.currentApp,\n }),\n Left: (error) => ({\n ..._.context._internalState,\n error,\n }),\n },\n );\n },\n }),\n },\n // NOTE: The way we handle our DeviceActions means that we should never as we return an Either\n // onError: {\n // target: \"Error\",\n // actions: \"assignGetDeviceStatusUnknownError\",\n // },\n },\n },\n CheckDeviceStatus: {\n // We check the device status to see if we can have an error\n always: [\n {\n target: \"Error\",\n guard: \"hasError\",\n },\n {\n target: \"DashboardCheck\",\n },\n ],\n },\n DashboardCheck: {\n // We check if the dashboard is open\n always: [\n {\n target: \"Success\",\n guard: \"isDashboardOpen\",\n },\n {\n target: \"Error\",\n guard: \"hasError\",\n },\n {\n target: \"Error\",\n guard: (_) => {\n return _.context._internalState.currentApp === null;\n },\n actions: assign({\n _internalState: (_) => ({\n ..._.context._internalState,\n error: new UnknownDAError(\"currentApp === null\"),\n }),\n }),\n },\n {\n target: \"CloseApp\",\n },\n ],\n },\n CloseApp: {\n invoke: {\n src: \"closeApp\",\n onDone: {\n target: \"CloseAppCheck\",\n actions: assign({\n _internalState: (_) => {\n if (isSuccessCommandResult(_.event.output)) {\n return _.context._internalState;\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 CloseAppCheck: {\n always: [\n {\n target: \"Error\",\n guard: \"hasError\",\n },\n {\n target: \"GetAppAndVersion\",\n reenter: true,\n },\n ],\n },\n GetAppAndVersion: {\n invoke: {\n src: \"getAppAndVersion\",\n onDone: {\n target: \"DashboardCheck\",\n actions: assign({\n _internalState: (_) => {\n if (isSuccessCommandResult(_.event.output)) {\n const state: DeviceSessionState = getDeviceSessionState();\n // Narrow the type to ReadyWithoutSecureChannelState or ReadyWithSecureChannelState\n if (\n state.sessionStateType !==\n DeviceSessionStateType.Connected\n ) {\n setDeviceSessionState({\n ...state,\n currentApp: _.event.output.data,\n });\n }\n return {\n ..._.context._internalState,\n currentApp: _.event.output.data.name,\n };\n }\n return {\n ..._.context._internalState,\n error: _.event.output.error,\n };\n },\n }),\n },\n },\n },\n Success: {\n type: \"final\",\n },\n Error: {\n type: \"final\",\n },\n },\n output: (_) => {\n if (_.context._internalState.error) {\n return Left(_.context._internalState.error);\n }\n\n return Right(undefined);\n },\n });\n }\n\n extractDependencies(internalApi: InternalApi): MachineDependencies {\n const closeApp = async () => internalApi.sendCommand(new CloseAppCommand());\n const getAppAndVersion = async () =>\n internalApi.sendCommand(new GetAppAndVersionCommand());\n\n return {\n closeApp,\n getAppAndVersion,\n getDeviceSessionState: () => internalApi.getDeviceSessionState(),\n setDeviceSessionState: (state: DeviceSessionState) =>\n internalApi.setDeviceSessionState(state),\n };\n }\n}\n"],
|
5
|
+
"mappings": "AAAA,OAAS,QAAAA,EAAM,SAAAC,MAAa,YAC5B,OAAS,UAAAC,EAAQ,eAAAC,EAAa,SAAAC,MAAa,SAE3C,OAAS,0BAAAC,MAA8B,mCACvC,OACE,mBAAAC,MAEK,kCACP,OACE,2BAAAC,MAEK,0CAEP,OAAS,2BAAAC,MAA+B,mDACxC,OAAS,6BAAAC,MAAiC,8BAC1C,OAAS,kBAAAC,MAAsB,+BAC/B,OAAS,+BAAAC,MAA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CACN,IAAK,mBACL,OAAQ,CACN,OAAQ,iBACR,QAAStB,EAAO,CACd,eAAiBsB,GAAM,CACrB,GAAInB,EAAuBmB,EAAE,MAAM,MAAM,EAAG,CAC1C,MAAMI,EAA4BX,EAAsB,EAExD,OACEW,EAAM,mBACNf,EAAuB,WAEvBK,EAAsB,CACpB,GAAGU,EACH,WAAYJ,EAAE,MAAM,OAAO,IAC7B,CAAC,EAEI,CACL,GAAGA,EAAE,QAAQ,eACb,WAAYA,EAAE,MAAM,OAAO,KAAK,IAClC,CACF,CACA,MAAO,CACL,GAAGA,EAAE,QAAQ,eACb,MAAOA,EAAE,MAAM,OAAO,KACxB,CACF,CACF,CAAC,CACH,CACF,CACF,EACA,QAAS,CACP,KAAM,OACR,EACA,MAAO,CACL,KAAM,OACR,CACF,EACA,OAASA,GACHA,EAAE,QAAQ,eAAe,MACpBxB,EAAKwB,EAAE,QAAQ,eAAe,KAAK,EAGrCvB,EAAM,MAAS,CAE1B,CAAC,CACH,CAEA,oBAAoBe,EAA+C,CAKjE,MAAO,CACL,SALe,SAAYA,EAAY,YAAY,IAAIV,CAAiB,EAMxE,iBALuB,SACvBU,EAAY,YAAY,IAAIT,CAAyB,EAKrD,sBAAuB,IAAMS,EAAY,sBAAsB,EAC/D,sBAAwBY,GACtBZ,EAAY,sBAAsBY,CAAK,CAC3C,CACF,CACF",
|
6
|
+
"names": ["Left", "Right", "assign", "fromPromise", "setup", "isSuccessCommandResult", "CloseAppCommand", "GetAppAndVersionCommand", "UserInteractionRequired", "DEFAULT_UNLOCK_TIMEOUT_MS", "UnknownDAError", "GetDeviceStatusDeviceAction", "XStateDeviceAction", "DeviceSessionStateType", "isDashboardName", "GoToDashboardDeviceAction", "internalApi", "getDeviceSessionState", "setDeviceSessionState", "closeApp", "getAppAndVersion", "unlockTimeout", "getDeviceStatusMachine", "context", "_", "sessionState", "output", "error", "state"]
|
7
7
|
}
|
@@ -1,2 +1,2 @@
|
|
1
|
-
import{Left as D,Right as g}from"purify-ts";import{assign as t,fromPromise as c,setup as y}from"xstate";import{isSuccessCommandResult as u}from"../../../command/model/CommandResult";import{CloseAppCommand as O}from"../../../command/os/CloseAppCommand";import{OpenAppCommand as v}from"../../../command/os/OpenAppCommand";import{UserInteractionRequired as i}from"../../../device-action/model/UserInteractionRequired";import{DEFAULT_UNLOCK_TIMEOUT_MS as h}from"../../../device-action/os/Const";import{DeviceNotOnboardedError as E}from"../../../device-action/os/Errors";import{GetDeviceStatusDeviceAction as f}from"../../../device-action/os/GetDeviceStatus/GetDeviceStatusDeviceAction";import{XStateDeviceAction as R}from"../../../device-action/xstate-utils/XStateDeviceAction";import{DeviceSessionStateType as l}from"../../../device-session/DeviceSessionState";import{DeviceDisconnectedWhileSendingError as C}from"../../../transport/model/Errors";class
|
1
|
+
import{Left as D,Right as g}from"purify-ts";import{assign as t,fromPromise as c,setup as y}from"xstate";import{isSuccessCommandResult as u}from"../../../command/model/CommandResult";import{CloseAppCommand as O}from"../../../command/os/CloseAppCommand";import{OpenAppCommand as v}from"../../../command/os/OpenAppCommand";import{UserInteractionRequired as i}from"../../../device-action/model/UserInteractionRequired";import{DEFAULT_UNLOCK_TIMEOUT_MS as h}from"../../../device-action/os/Const";import{DeviceNotOnboardedError as E}from"../../../device-action/os/Errors";import{GetDeviceStatusDeviceAction as f}from"../../../device-action/os/GetDeviceStatus/GetDeviceStatusDeviceAction";import{XStateDeviceAction as R}from"../../../device-action/xstate-utils/XStateDeviceAction";import{DeviceSessionStateType as l}from"../../../device-session/DeviceSessionState";import{DeviceDisconnectedWhileSendingError as C}from"../../../transport/model/Errors";import{isDashboardName as N}from"../../../utils/AppName";class W extends R{makeStateMachine(r){const{closeApp:o,openApp:s,getDeviceSessionState:a,isDeviceOnboarded:A,setDeviceSessionState:d}=this.extractDependencies(r),S=this.input.unlockTimeout??h,m=new f({input:{unlockTimeout:S}}).makeStateMachine(r);return y({types:{input:{},context:{},output:{}},actors:{closeApp:c(o),openApp:c(s),getDeviceStatus:m},guards:{isDeviceOnboarded:()=>A(),isRequestedAppOpen:({context:e})=>e._internalState.currentlyRunningApp===null?!1:e._internalState.currentlyRunningApp===e.input.appName||e.input.compatibleAppNames!==void 0&&e.input.compatibleAppNames.includes(e._internalState.currentlyRunningApp),isDashboardOpen:({context:e})=>{if(e._internalState.currentlyRunningApp===null)throw new Error("context.currentlyRunningApp === null");return N(e._internalState.currentlyRunningApp)},hasDisconnectedWhileSending:({context:e})=>e._internalState.error!==null&&e._internalState.error instanceof C,hasError:({context:e})=>e._internalState.error!==null},actions:{assignErrorDeviceNotOnboarded:t({_internalState:e=>({...e.context._internalState,error:new E})}),assignUserActionNeededOpenApp:t({intermediateValue:e=>({...e.context.intermediateValue,requiredUserInteraction:i.ConfirmOpenApp})}),assignNoUserActionNeeded:t({intermediateValue:e=>({...e.context.intermediateValue,requiredUserInteraction:i.None})}),assignErrorFromEvent:t({_internalState:e=>({...e.context._internalState,error:e.event.error})}),assignNoError:t({_internalState:e=>({...e.context._internalState,error:null})})}}).createMachine({id:"OpenAppDeviceAction",initial:"DeviceReady",context:({input:e})=>{const n=a(),{sessionStateType:p}=n;return{input:e,intermediateValue:{requiredUserInteraction:i.None},_internalState:{error:null,currentlyRunningApp:p===l.ReadyWithoutSecureChannel?n.currentApp.name:null}}},states:{DeviceReady:{always:{target:"OnboardingCheck"}},OnboardingCheck:{always:[{target:"GetDeviceStatus",guard:{type:"isDeviceOnboarded"}},{target:"Error",actions:"assignErrorDeviceNotOnboarded"}]},GetDeviceStatus:{invoke:{id:"deviceStatus",src:"getDeviceStatus",input:e=>({unlockTimeout:e.context.input.unlockTimeout}),onSnapshot:{actions:t({intermediateValue:e=>e.event.snapshot.context.intermediateValue})},onDone:{target:"CheckDeviceStatus",actions:t({_internalState:e=>e.event.output.caseOf({Right:n=>{const p=a();return p.sessionStateType!==l.Connected&&d({...p,currentApp:{name:n.currentApp,version:n.currentAppVersion}}),{...e.context._internalState,currentlyRunningApp:n.currentApp}},Left:n=>({...e.context._internalState,currentlyRunningApp:null,error:n})})})},onError:{target:"Error",actions:[t({_internalState:e=>({...e.context._internalState,currentlyRunningApp:null})}),"assignErrorFromEvent"]}}},CheckDeviceStatus:{always:[{target:"ApplicationReady",guard:"isRequestedAppOpen",actions:"assignNoError"},{target:"Error",guard:"hasError"},{target:"DashboardCheck"}]},DashboardCheck:{always:[{target:"OpenApplication",guard:"isDashboardOpen"},"CloseApplication"]},OpenApplication:{entry:"assignUserActionNeededOpenApp",exit:"assignNoUserActionNeeded",invoke:{src:"openApp",input:({context:e})=>({appName:e.input.appName}),onDone:{target:"OpenApplicationResultCheck",actions:t({_internalState:e=>u(e.event.output)?{...e.context._internalState,currentlyRunningApp:e.context.input.appName}:{...e.context._internalState,error:e.event.output.error}})},onError:{target:"OpenApplicationResultCheck",actions:"assignErrorFromEvent"}}},OpenApplicationResultCheck:{always:[{target:"GetDeviceStatus",guard:"hasDisconnectedWhileSending"},{target:"Error",guard:"hasError"},{target:"GetDeviceStatus"}]},CloseApplication:{invoke:{src:"closeApp",onDone:{target:"CloseApplicationResultCheck",actions:t({_internalState:e=>u(e.event.output)?{...e.context._internalState,currentlyRunningApp:"BOLOS"}:{...e.context._internalState,error:e.event.output.error}})},onError:{target:"Error",actions:"assignErrorFromEvent"}}},CloseApplicationResultCheck:{always:[{target:"Error",guard:"hasError"},{target:"OpenApplication"}]},ApplicationReady:{always:"Success"},Success:{type:"final",actions:"assignNoError"},Error:{type:"final"}},output:({context:e})=>e._internalState.error?D(e._internalState.error):g(void 0)})}extractDependencies(r){return{closeApp:async()=>r.sendCommand(new O),openApp:async a=>r.sendCommand(new v({appName:a.input.appName})),getDeviceSessionState:()=>r.getDeviceSessionState(),setDeviceSessionState:a=>r.setDeviceSessionState(a),isDeviceOnboarded:()=>!0}}}export{W as OpenAppDeviceAction};
|
2
2
|
//# sourceMappingURL=OpenAppDeviceAction.js.map
|
@@ -1,7 +1,7 @@
|
|
1
1
|
{
|
2
2
|
"version": 3,
|
3
3
|
"sources": ["../../../../../../../src/api/device-action/os/OpenAppDeviceAction/OpenAppDeviceAction.ts"],
|
4
|
-
"sourcesContent": ["import { Left, Right } from \"purify-ts\";\nimport { assign, fromPromise, setup } from \"xstate\";\n\nimport { isSuccessCommandResult } from \"@api/command/model/CommandResult\";\nimport {\n CloseAppCommand,\n type CloseAppCommandResult,\n} from \"@api/command/os/CloseAppCommand\";\nimport {\n OpenAppCommand,\n type OpenAppCommandResult,\n} from \"@api/command/os/OpenAppCommand\";\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 { GetDeviceStatusDeviceAction } from \"@api/device-action/os/GetDeviceStatus/GetDeviceStatusDeviceAction\";\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} from \"@api/device-session/DeviceSessionState\";\nimport { DeviceDisconnectedWhileSendingError } from \"@api/transport/model/Errors\";\n\nimport {\n type OpenAppDAError,\n type OpenAppDAInput,\n type OpenAppDAIntermediateValue,\n type OpenAppDAOutput,\n} from \"./types\";\n\ntype OpenAppStateMachineInternalState = {\n readonly currentlyRunningApp: string | null;\n readonly error: OpenAppDAError | null;\n};\n\nexport type MachineDependencies = {\n readonly closeApp: () => Promise<CloseAppCommandResult>;\n readonly openApp: (arg0: {\n input: { appName: string };\n }) => Promise<OpenAppCommandResult>;\n readonly getDeviceSessionState: () => DeviceSessionState;\n readonly setDeviceSessionState: (state: DeviceSessionState) => void;\n readonly isDeviceOnboarded: () => boolean;\n};\n\nexport type ExtractMachineDependencies = (\n internalApi: InternalApi,\n) => MachineDependencies;\n\n/**\n * Opens a given app on the device.\n *\n * It checks if the device is onboarded, unlocked, and which app is currently open.\n * If the current app is the dashboard, it will directly open the requested app.\n * If another app is opened, it will close the current app and open the requested app.\n *\n * Example of usage:\n *\n * ```ts\n * const deviceAction = new OpenAppDeviceAction({\n * input: {\n * appName: \"MyApp\",\n * },\n * });\n * dmk.executeDeviceAction({ sessionId: \"mySessionId\", deviceAction });\n * ```\n */\nexport class OpenAppDeviceAction extends XStateDeviceAction<\n OpenAppDAOutput,\n OpenAppDAInput,\n OpenAppDAError,\n OpenAppDAIntermediateValue,\n OpenAppStateMachineInternalState\n> {\n makeStateMachine(\n internalApi: InternalApi,\n ): DeviceActionStateMachine<\n OpenAppDAOutput,\n OpenAppDAInput,\n OpenAppDAError,\n OpenAppDAIntermediateValue,\n OpenAppStateMachineInternalState\n > {\n type types = StateMachineTypes<\n OpenAppDAOutput,\n OpenAppDAInput,\n OpenAppDAError,\n OpenAppDAIntermediateValue,\n OpenAppStateMachineInternalState\n >;\n\n const {\n closeApp,\n openApp,\n getDeviceSessionState,\n isDeviceOnboarded,\n setDeviceSessionState,\n } = this.extractDependencies(internalApi);\n\n const unlockTimeout = this.input.unlockTimeout ?? DEFAULT_UNLOCK_TIMEOUT_MS;\n\n const getDeviceStatusMachine = new GetDeviceStatusDeviceAction({\n input: {\n unlockTimeout,\n },\n }).makeStateMachine(internalApi);\n\n return setup({\n types: {\n input: {} as types[\"input\"],\n context: {} as types[\"context\"],\n output: {} as types[\"output\"],\n },\n actors: {\n closeApp: fromPromise(closeApp),\n openApp: fromPromise(openApp),\n getDeviceStatus: getDeviceStatusMachine,\n },\n guards: {\n isDeviceOnboarded: () => isDeviceOnboarded(), // TODO: we don't have this info for now, this can be derived from the \"flags\" obtained in the getVersion command\n isRequestedAppOpen: ({ context }: { context: types[\"context\"] }) => {\n if (context._internalState.currentlyRunningApp === null) return false;\n return (\n context._internalState.currentlyRunningApp ===\n context.input.appName ||\n (context.input.compatibleAppNames !== undefined &&\n context.input.compatibleAppNames.includes(\n context._internalState.currentlyRunningApp,\n ))\n );\n },\n isDashboardOpen: ({ context }: { context: types[\"context\"] }) => {\n if (context._internalState.currentlyRunningApp === null)\n throw new Error(\"context.currentlyRunningApp === null\");\n return context._internalState.currentlyRunningApp === \"BOLOS\";\n },\n hasDisconnectedWhileSending: ({ context }) =>\n context._internalState.error !== null &&\n context._internalState.error instanceof\n DeviceDisconnectedWhileSendingError,\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 assignUserActionNeededOpenApp: assign({\n intermediateValue: (_) =>\n ({\n ..._.context.intermediateValue,\n requiredUserInteraction: UserInteractionRequired.ConfirmOpenApp,\n }) satisfies types[\"context\"][\"intermediateValue\"],\n }),\n assignNoUserActionNeeded: assign({\n intermediateValue: (_) =>\n ({\n ..._.context.intermediateValue,\n requiredUserInteraction: UserInteractionRequired.None,\n }) satisfies types[\"context\"][\"intermediateValue\"],\n }),\n assignErrorFromEvent: assign({\n _internalState: (_) => ({\n ..._.context._internalState,\n error: _.event[\"error\"], // FIXME: add a typeguard\n }),\n }),\n assignNoError: assign({\n _internalState: (_) => ({\n ..._.context._internalState,\n error: null,\n }),\n }),\n },\n }).createMachine({\n /** @xstate-layout N4IgpgJg5mDOIC5QHkAOYB2BBVqAiYAbgJYDGYWpALsQPYYB0BJ5ASmAIYQCeAxANoAGALqJQqWrGI16YkAA9EARhWCGADgAsAZm1b1SwUoDspgDQhuiAEzX1DbQE5tJlQDYlm414CsAXz8LNEwcfCIyCmo6RmQMACNaDgAnCGIMKABhAAswUgBrARE5CSkZDDlFBCUPbQYfZx91H0FtTRNjCysEbWM1bTdHAzcfH2q9awCg9GxcZgjKMoZYhOTU9Ozcgv4lUSQQEuloiuUauoamlrbzSxtBNTu7pW1BEe1rJUmQYJmwlkjFgAytHyaUyOXyhV24kkh1ke0q7w8DDcxmqjkM1l6Kh8nUQ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LnR11d1x955xJ1cKeIAZ6dGEJqJKk4qqq3ttdF-XIc67zrdue3CLVG4gqZyMpbGG4bhBeoq9b-mB7jaTZYT+JU86sX05z5R2wLxlG78oKYpNKW16mx9x6EkhWdGKTSvXgLrFKSENcbsC4Hwa6i9eQHgQgmCkIlBjKmcEFUY24ejaSTMeCkHxPgYFoBAOAcgA5u1um3XkABaHeEoKEEkKvQwQJ4XjKl6ErIBDUmCenATwA2RM7rknUm4FUhV-oiTJFTCUth05j0xJVFUTxt7sIOssRIKRQRyV4bdWOTNkTqDekqAwbxNDIUzFIhwzhZHVHkf0akZ9rKFx1CyPI6j2SaJjsoUsBIBimB8MMeUZJqFdH6PYDwKYBjwQaEYpRtlOYzlfC2NxS8bB6HsM4RUIwiSH0VNxAy6lkL1EEjTYUtisLn1ISAhuDZZxvhvpsRJmVX51FJFlZ4-Qk5wUYcxR2BTTIGUKtEvCoDpwaMUobbqugUzIg8PmEwIiTJ9yqAMaUW90IngCaIgZcUEpJVUa1Vxoy+GVGMbvZiuVf5IM8CoTZOpNZDL4eQjcIlDLIRRH5FhoxDyIGFMiASe8IoFlGNchaS0waxNqfkepG4tACiMGeQw6IiQeBGncMaMycxEl8eoIFu0fiVPbg87qSE3q6MVBpehPQ4K6G+uoZUJIVB7laNiq+2s4DkRGYTLRygs6GSQtmO4iIaWljgvUBgip-K5RErofOdiYocLBZwHhBzOWSkKqKz6Lw3i6U+QgPchlTB7xTPBeCWVHDYoAMqflIOQWA8AlXuO6KMQylImipgMi4BZzhDIKkpM0FEypRimplXNWyABRMuSRIXjNaKvHQ3h0Q0reCYT+3khGNEKgqIRxgAgBCAA */\n id: \"OpenAppDeviceAction\",\n initial: \"DeviceReady\",\n context: ({ input }) => {\n const sessionState = getDeviceSessionState();\n const { sessionStateType } = sessionState;\n return {\n input,\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.None,\n },\n _internalState: {\n error: null,\n currentlyRunningApp:\n sessionStateType ===\n DeviceSessionStateType.ReadyWithoutSecureChannel\n ? sessionState.currentApp.name\n : null,\n },\n };\n },\n states: {\n DeviceReady: {\n // check device capabilities & status known\n always: {\n target: \"OnboardingCheck\",\n },\n },\n\n OnboardingCheck: {\n // check onboarding status provided by device session\n always: [\n {\n target: \"GetDeviceStatus\",\n guard: {\n type: \"isDeviceOnboarded\",\n },\n },\n {\n target: \"Error\",\n actions: \"assignErrorDeviceNotOnboarded\",\n },\n ],\n },\n\n GetDeviceStatus: {\n // We run the GetDeviceStatus flow to get information about the device state\n invoke: {\n id: \"deviceStatus\",\n src: \"getDeviceStatus\",\n input: (_) => ({\n unlockTimeout: _.context.input.unlockTimeout,\n }),\n onSnapshot: {\n actions: assign({\n intermediateValue: (_) =>\n _.event.snapshot.context.intermediateValue,\n }),\n },\n onDone: {\n target: \"CheckDeviceStatus\",\n actions: assign({\n _internalState: (_) => {\n return _.event.output.caseOf<OpenAppStateMachineInternalState>(\n {\n Right: (output) => {\n const state: DeviceSessionState =\n getDeviceSessionState();\n\n if (\n state.sessionStateType !==\n DeviceSessionStateType.Connected\n ) {\n setDeviceSessionState({\n ...state,\n currentApp: {\n name: output.currentApp,\n version: output.currentAppVersion,\n },\n });\n }\n return {\n ..._.context._internalState,\n currentlyRunningApp: output.currentApp,\n };\n },\n Left: (error) => ({\n ..._.context._internalState,\n currentlyRunningApp: null,\n error,\n }),\n },\n );\n },\n }),\n },\n onError: {\n target: \"Error\",\n actions: [\n assign({\n _internalState: (_) => ({\n ..._.context._internalState,\n currentlyRunningApp: null,\n }),\n }),\n \"assignErrorFromEvent\",\n ],\n },\n },\n },\n CheckDeviceStatus: {\n // We check the device status to see if we can have an error\n always: [\n {\n target: \"ApplicationReady\",\n guard: \"isRequestedAppOpen\",\n // If target app is currently opened, we can ignore errors\n actions: \"assignNoError\",\n },\n {\n target: \"Error\",\n guard: \"hasError\",\n },\n {\n target: \"DashboardCheck\",\n },\n ],\n },\n\n DashboardCheck: {\n // Is the current application the dashboard\n always: [\n {\n target: \"OpenApplication\",\n guard: \"isDashboardOpen\",\n },\n \"CloseApplication\",\n ],\n },\n\n OpenApplication: {\n // execute openApp command,\n entry: \"assignUserActionNeededOpenApp\",\n exit: \"assignNoUserActionNeeded\",\n invoke: {\n src: \"openApp\",\n input: ({ context }) => ({ appName: context.input.appName }),\n onDone: {\n target: \"OpenApplicationResultCheck\",\n actions: assign({\n _internalState: (_) => {\n if (isSuccessCommandResult(_.event.output)) {\n return {\n ..._.context._internalState,\n currentlyRunningApp: _.context.input.appName,\n };\n } else {\n return {\n ..._.context._internalState,\n error: _.event.output.error,\n };\n }\n },\n }),\n },\n onError: {\n target: \"OpenApplicationResultCheck\",\n actions: \"assignErrorFromEvent\",\n },\n },\n },\n\n OpenApplicationResultCheck: {\n always: [\n {\n // When an APDU triggers a disconnection, some transports may possibly\n // be closed on device side before the APDU response could be received,\n // especially on BLE transports.\n // Therefore when a disconnection occurs while sending, we should verify\n // the device status because it may have been successfully executed.\n target: \"GetDeviceStatus\",\n guard: \"hasDisconnectedWhileSending\",\n },\n {\n target: \"Error\",\n guard: \"hasError\",\n },\n { target: \"GetDeviceStatus\" },\n ],\n },\n\n CloseApplication: {\n invoke: {\n src: \"closeApp\",\n onDone: {\n target: \"CloseApplicationResultCheck\",\n actions: assign({\n _internalState: (_) => {\n if (isSuccessCommandResult(_.event.output)) {\n return {\n ..._.context._internalState,\n currentlyRunningApp: \"BOLOS\",\n };\n } else {\n return {\n ..._.context._internalState,\n error: _.event.output.error,\n };\n }\n },\n }),\n },\n onError: {\n target: \"Error\",\n actions: \"assignErrorFromEvent\",\n },\n },\n },\n CloseApplicationResultCheck: {\n always: [\n {\n target: \"Error\",\n guard: \"hasError\",\n },\n { target: \"OpenApplication\" },\n ],\n },\n\n ApplicationReady: {\n // application is ready to be used\n always: \"Success\",\n },\n\n // success state\n Success: {\n type: \"final\",\n actions: \"assignNoError\", // TODO, we should not need this\n },\n\n // error state\n Error: {\n type: \"final\",\n },\n },\n output: ({ context }) =>\n context._internalState.error // TODO: instead we should rely on the current state (\"Success\" or \"Error\")\n ? Left(context._internalState.error)\n : Right(undefined),\n });\n }\n\n extractDependencies(internalApi: InternalApi): MachineDependencies {\n const closeApp = async () => internalApi.sendCommand(new CloseAppCommand());\n const openApp = async (arg0: { input: { appName: string } }) =>\n internalApi.sendCommand(\n new OpenAppCommand({ appName: arg0.input.appName }),\n );\n\n return {\n closeApp,\n openApp,\n getDeviceSessionState: () => internalApi.getDeviceSessionState(),\n setDeviceSessionState: (state: DeviceSessionState) =>\n internalApi.setDeviceSessionState(state),\n isDeviceOnboarded: () => true, // TODO: we don't have this info for now, this can be derived from the \"flags\" obtained in the getVersion command\n };\n }\n}\n"],
|
5
|
-
"mappings": "AAAA,OAAS,QAAAA,EAAM,SAAAC,MAAa,YAC5B,OAAS,UAAAC,EAAQ,eAAAC,EAAa,SAAAC,MAAa,SAE3C,OAAS,0BAAAC,MAA8B,mCACvC,OACE,mBAAAC,MAEK,kCACP,OACE,kBAAAC,MAEK,iCAEP,OAAS,2BAAAC,MAA+B,mDACxC,OAAS,6BAAAC,MAAiC,8BAC1C,OAAS,2BAAAC,MAA+B,+BACxC,OAAS,+BAAAC,MAAmC,oEAE5C,OAEE,sBAAAC,MACK,qDACP,OAEE,0BAAAC,MACK,yCACP,OAAS,uCAAAC,MAA2C,
|
6
|
-
"names": ["Left", "Right", "assign", "fromPromise", "setup", "isSuccessCommandResult", "CloseAppCommand", "OpenAppCommand", "UserInteractionRequired", "DEFAULT_UNLOCK_TIMEOUT_MS", "DeviceNotOnboardedError", "GetDeviceStatusDeviceAction", "XStateDeviceAction", "DeviceSessionStateType", "DeviceDisconnectedWhileSendingError", "OpenAppDeviceAction", "internalApi", "closeApp", "openApp", "getDeviceSessionState", "isDeviceOnboarded", "setDeviceSessionState", "unlockTimeout", "getDeviceStatusMachine", "context", "_", "input", "sessionState", "sessionStateType", "output", "state", "error", "arg0"]
|
4
|
+
"sourcesContent": ["import { Left, Right } from \"purify-ts\";\nimport { assign, fromPromise, setup } from \"xstate\";\n\nimport { isSuccessCommandResult } from \"@api/command/model/CommandResult\";\nimport {\n CloseAppCommand,\n type CloseAppCommandResult,\n} from \"@api/command/os/CloseAppCommand\";\nimport {\n OpenAppCommand,\n type OpenAppCommandResult,\n} from \"@api/command/os/OpenAppCommand\";\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 { GetDeviceStatusDeviceAction } from \"@api/device-action/os/GetDeviceStatus/GetDeviceStatusDeviceAction\";\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} from \"@api/device-session/DeviceSessionState\";\nimport { DeviceDisconnectedWhileSendingError } from \"@api/transport/model/Errors\";\nimport { isDashboardName } from \"@api/utils/AppName\";\n\nimport {\n type OpenAppDAError,\n type OpenAppDAInput,\n type OpenAppDAIntermediateValue,\n type OpenAppDAOutput,\n} from \"./types\";\n\ntype OpenAppStateMachineInternalState = {\n readonly currentlyRunningApp: string | null;\n readonly error: OpenAppDAError | null;\n};\n\nexport type MachineDependencies = {\n readonly closeApp: () => Promise<CloseAppCommandResult>;\n readonly openApp: (arg0: {\n input: { appName: string };\n }) => Promise<OpenAppCommandResult>;\n readonly getDeviceSessionState: () => DeviceSessionState;\n readonly setDeviceSessionState: (state: DeviceSessionState) => void;\n readonly isDeviceOnboarded: () => boolean;\n};\n\nexport type ExtractMachineDependencies = (\n internalApi: InternalApi,\n) => MachineDependencies;\n\n/**\n * Opens a given app on the device.\n *\n * It checks if the device is onboarded, unlocked, and which app is currently open.\n * If the current app is the dashboard, it will directly open the requested app.\n * If another app is opened, it will close the current app and open the requested app.\n *\n * Example of usage:\n *\n * ```ts\n * const deviceAction = new OpenAppDeviceAction({\n * input: {\n * appName: \"MyApp\",\n * },\n * });\n * dmk.executeDeviceAction({ sessionId: \"mySessionId\", deviceAction });\n * ```\n */\nexport class OpenAppDeviceAction extends XStateDeviceAction<\n OpenAppDAOutput,\n OpenAppDAInput,\n OpenAppDAError,\n OpenAppDAIntermediateValue,\n OpenAppStateMachineInternalState\n> {\n makeStateMachine(\n internalApi: InternalApi,\n ): DeviceActionStateMachine<\n OpenAppDAOutput,\n OpenAppDAInput,\n OpenAppDAError,\n OpenAppDAIntermediateValue,\n OpenAppStateMachineInternalState\n > {\n type types = StateMachineTypes<\n OpenAppDAOutput,\n OpenAppDAInput,\n OpenAppDAError,\n OpenAppDAIntermediateValue,\n OpenAppStateMachineInternalState\n >;\n\n const {\n closeApp,\n openApp,\n getDeviceSessionState,\n isDeviceOnboarded,\n setDeviceSessionState,\n } = this.extractDependencies(internalApi);\n\n const unlockTimeout = this.input.unlockTimeout ?? DEFAULT_UNLOCK_TIMEOUT_MS;\n\n const getDeviceStatusMachine = new GetDeviceStatusDeviceAction({\n input: {\n unlockTimeout,\n },\n }).makeStateMachine(internalApi);\n\n return setup({\n types: {\n input: {} as types[\"input\"],\n context: {} as types[\"context\"],\n output: {} as types[\"output\"],\n },\n actors: {\n closeApp: fromPromise(closeApp),\n openApp: fromPromise(openApp),\n getDeviceStatus: getDeviceStatusMachine,\n },\n guards: {\n isDeviceOnboarded: () => isDeviceOnboarded(), // TODO: we don't have this info for now, this can be derived from the \"flags\" obtained in the getVersion command\n isRequestedAppOpen: ({ context }: { context: types[\"context\"] }) => {\n if (context._internalState.currentlyRunningApp === null) return false;\n return (\n context._internalState.currentlyRunningApp ===\n context.input.appName ||\n (context.input.compatibleAppNames !== undefined &&\n context.input.compatibleAppNames.includes(\n context._internalState.currentlyRunningApp,\n ))\n );\n },\n isDashboardOpen: ({ context }: { context: types[\"context\"] }) => {\n if (context._internalState.currentlyRunningApp === null)\n throw new Error(\"context.currentlyRunningApp === null\");\n return isDashboardName(context._internalState.currentlyRunningApp);\n },\n hasDisconnectedWhileSending: ({ context }) =>\n context._internalState.error !== null &&\n context._internalState.error instanceof\n DeviceDisconnectedWhileSendingError,\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 assignUserActionNeededOpenApp: assign({\n intermediateValue: (_) =>\n ({\n ..._.context.intermediateValue,\n requiredUserInteraction: UserInteractionRequired.ConfirmOpenApp,\n }) satisfies types[\"context\"][\"intermediateValue\"],\n }),\n assignNoUserActionNeeded: assign({\n intermediateValue: (_) =>\n ({\n ..._.context.intermediateValue,\n requiredUserInteraction: UserInteractionRequired.None,\n }) satisfies types[\"context\"][\"intermediateValue\"],\n }),\n assignErrorFromEvent: assign({\n _internalState: (_) => ({\n ..._.context._internalState,\n error: _.event[\"error\"], // FIXME: add a typeguard\n }),\n }),\n assignNoError: assign({\n _internalState: (_) => ({\n ..._.context._internalState,\n error: null,\n }),\n }),\n },\n }).createMachine({\n /** @xstate-layout N4IgpgJg5mDOIC5QHkAOYB2BBVqAiYAbgJYDGYWpALsQPYYB0BJ5ASmAIYQCeAxANoAGALqJQqWrGI16YkAA9EARhWCGADgAsAZm1b1SwUoDspgDQhuiAEzX1DbQE5tJlQDYlm414CsAXz8LNEwcfCIyCmo6RmQMACNaDgAnCGIMKABhAAswUgBrARE5CSkZDDlFBCUPbQYfZx91H0FtTRNjCysEbWM1bTdHAzcfH2q9awCg9GxcZgjKMoZYhOTU9Ozcgv4lUSQQEuloiuUauoamlrbzSxtBNTu7pW1BEe1rJUmQYJmwlkjFgAytHyaUyOXyhV24kkh1ke0q7w8DDcxmqjkM1l6Kh8nUQzR8DEEjjcz3UxKUjiMbk+31Cc3IC2iDCBIPW4K2O2KMLKxwQiKUyNRAwxWKUOJu3TaDFsw28bkExm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aTZYT+JU86sX05z5R2wLxlG78oKYpNKW16mx9x6EkhWdGKTSvXgLrFKSENcbsC4Hwa6i9eQHgQgmCkIlBjKmcEFUY24ejaSTMeCkHxPgYFoBAOAcgA5u1um3XkABaHeEoKEEkKvQwQJ4XjKl6ErIBDUmCenATwA2RM7rknUm4FUhV-oiTJFTCUth05j0xJVFUTxt7sIOssRIKRQRyV4bdWOTNkTqDekqAwbxNDIUzFIhwzhZHVHkf0akZ9rKFx1CyPI6j2SaJjsoUsBIBimB8MMeUZJqFdH6PYDwKYBjwQaEYpRtlOYzlfC2NxS8bB6HsM4RUIwiSH0VNxAy6lkL1EEjTYUtisLn1ISAhuDZZxvhvpsRJmVX51FJFlZ4-Qk5wUYcxR2BTTIGUKtEvCoDpwaMUobbqugUzIg8PmEwIiTJ9yqAMaUW90IngCaIgZcUEpJVUa1Vxoy+GVGMbvZiuVf5IM8CoTZOpNZDL4eQjcIlDLIRRH5FhoxDyIGFMiASe8IoFlGNchaS0waxNqfkepG4tACiMGeQw6IiQeBGncMaMycxEl8eoIFu0fiVPbg87qSE3q6MVBpehPQ4K6G+uoZUJIVB7laNiq+2s4DkRGYTLRygs6GSQtmO4iIaWljgvUBgip-K5RErofOdiYocLBZwHhBzOWSkKqKz6Lw3i6U+QgPchlTB7xTPBeCWVHDYoAMqflIOQWA8AlXuO6KMQylImipgMi4BZzhDIKkpM0FEypRimplXNWyABRMuSRIXjNaKvHQ3h0Q0reCYT+3khGNEKgqIRxgAgBCAA */\n id: \"OpenAppDeviceAction\",\n initial: \"DeviceReady\",\n context: ({ input }) => {\n const sessionState = getDeviceSessionState();\n const { sessionStateType } = sessionState;\n return {\n input,\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.None,\n },\n _internalState: {\n error: null,\n currentlyRunningApp:\n sessionStateType ===\n DeviceSessionStateType.ReadyWithoutSecureChannel\n ? sessionState.currentApp.name\n : null,\n },\n };\n },\n states: {\n DeviceReady: {\n // check device capabilities & status known\n always: {\n target: \"OnboardingCheck\",\n },\n },\n\n OnboardingCheck: {\n // check onboarding status provided by device session\n always: [\n {\n target: \"GetDeviceStatus\",\n guard: {\n type: \"isDeviceOnboarded\",\n },\n },\n {\n target: \"Error\",\n actions: \"assignErrorDeviceNotOnboarded\",\n },\n ],\n },\n\n GetDeviceStatus: {\n // We run the GetDeviceStatus flow to get information about the device state\n invoke: {\n id: \"deviceStatus\",\n src: \"getDeviceStatus\",\n input: (_) => ({\n unlockTimeout: _.context.input.unlockTimeout,\n }),\n onSnapshot: {\n actions: assign({\n intermediateValue: (_) =>\n _.event.snapshot.context.intermediateValue,\n }),\n },\n onDone: {\n target: \"CheckDeviceStatus\",\n actions: assign({\n _internalState: (_) => {\n return _.event.output.caseOf<OpenAppStateMachineInternalState>(\n {\n Right: (output) => {\n const state: DeviceSessionState =\n getDeviceSessionState();\n\n if (\n state.sessionStateType !==\n DeviceSessionStateType.Connected\n ) {\n setDeviceSessionState({\n ...state,\n currentApp: {\n name: output.currentApp,\n version: output.currentAppVersion,\n },\n });\n }\n return {\n ..._.context._internalState,\n currentlyRunningApp: output.currentApp,\n };\n },\n Left: (error) => ({\n ..._.context._internalState,\n currentlyRunningApp: null,\n error,\n }),\n },\n );\n },\n }),\n },\n onError: {\n target: \"Error\",\n actions: [\n assign({\n _internalState: (_) => ({\n ..._.context._internalState,\n currentlyRunningApp: null,\n }),\n }),\n \"assignErrorFromEvent\",\n ],\n },\n },\n },\n CheckDeviceStatus: {\n // We check the device status to see if we can have an error\n always: [\n {\n target: \"ApplicationReady\",\n guard: \"isRequestedAppOpen\",\n // If target app is currently opened, we can ignore errors\n actions: \"assignNoError\",\n },\n {\n target: \"Error\",\n guard: \"hasError\",\n },\n {\n target: \"DashboardCheck\",\n },\n ],\n },\n\n DashboardCheck: {\n // Is the current application the dashboard\n always: [\n {\n target: \"OpenApplication\",\n guard: \"isDashboardOpen\",\n },\n \"CloseApplication\",\n ],\n },\n\n OpenApplication: {\n // execute openApp command,\n entry: \"assignUserActionNeededOpenApp\",\n exit: \"assignNoUserActionNeeded\",\n invoke: {\n src: \"openApp\",\n input: ({ context }) => ({ appName: context.input.appName }),\n onDone: {\n target: \"OpenApplicationResultCheck\",\n actions: assign({\n _internalState: (_) => {\n if (isSuccessCommandResult(_.event.output)) {\n return {\n ..._.context._internalState,\n currentlyRunningApp: _.context.input.appName,\n };\n } else {\n return {\n ..._.context._internalState,\n error: _.event.output.error,\n };\n }\n },\n }),\n },\n onError: {\n target: \"OpenApplicationResultCheck\",\n actions: \"assignErrorFromEvent\",\n },\n },\n },\n\n OpenApplicationResultCheck: {\n always: [\n {\n // When an APDU triggers a disconnection, some transports may possibly\n // be closed on device side before the APDU response could be received,\n // especially on BLE transports.\n // Therefore when a disconnection occurs while sending, we should verify\n // the device status because it may have been successfully executed.\n target: \"GetDeviceStatus\",\n guard: \"hasDisconnectedWhileSending\",\n },\n {\n target: \"Error\",\n guard: \"hasError\",\n },\n { target: \"GetDeviceStatus\" },\n ],\n },\n\n CloseApplication: {\n invoke: {\n src: \"closeApp\",\n onDone: {\n target: \"CloseApplicationResultCheck\",\n actions: assign({\n _internalState: (_) => {\n if (isSuccessCommandResult(_.event.output)) {\n return {\n ..._.context._internalState,\n currentlyRunningApp: \"BOLOS\",\n };\n } else {\n return {\n ..._.context._internalState,\n error: _.event.output.error,\n };\n }\n },\n }),\n },\n onError: {\n target: \"Error\",\n actions: \"assignErrorFromEvent\",\n },\n },\n },\n CloseApplicationResultCheck: {\n always: [\n {\n target: \"Error\",\n guard: \"hasError\",\n },\n { target: \"OpenApplication\" },\n ],\n },\n\n ApplicationReady: {\n // application is ready to be used\n always: \"Success\",\n },\n\n // success state\n Success: {\n type: \"final\",\n actions: \"assignNoError\", // TODO, we should not need this\n },\n\n // error state\n Error: {\n type: \"final\",\n },\n },\n output: ({ context }) =>\n context._internalState.error // TODO: instead we should rely on the current state (\"Success\" or \"Error\")\n ? Left(context._internalState.error)\n : Right(undefined),\n });\n }\n\n extractDependencies(internalApi: InternalApi): MachineDependencies {\n const closeApp = async () => internalApi.sendCommand(new CloseAppCommand());\n const openApp = async (arg0: { input: { appName: string } }) =>\n internalApi.sendCommand(\n new OpenAppCommand({ appName: arg0.input.appName }),\n );\n\n return {\n closeApp,\n openApp,\n getDeviceSessionState: () => internalApi.getDeviceSessionState(),\n setDeviceSessionState: (state: DeviceSessionState) =>\n internalApi.setDeviceSessionState(state),\n isDeviceOnboarded: () => true, // TODO: we don't have this info for now, this can be derived from the \"flags\" obtained in the getVersion command\n };\n }\n}\n"],
|
5
|
+
"mappings": "AAAA,OAAS,QAAAA,EAAM,SAAAC,MAAa,YAC5B,OAAS,UAAAC,EAAQ,eAAAC,EAAa,SAAAC,MAAa,SAE3C,OAAS,0BAAAC,MAA8B,mCACvC,OACE,mBAAAC,MAEK,kCACP,OACE,kBAAAC,MAEK,iCAEP,OAAS,2BAAAC,MAA+B,mDACxC,OAAS,6BAAAC,MAAiC,8BAC1C,OAAS,2BAAAC,MAA+B,+BACxC,OAAS,+BAAAC,MAAmC,oEAE5C,OAEE,sBAAAC,MACK,qDACP,OAEE,0BAAAC,MACK,yCACP,OAAS,uCAAAC,MAA2C,8BACpD,OAAS,mBAAAC,MAAuB,qBA8CzB,MAAMC,UAA4BJ,CAMvC,CACA,iBACEK,EAOA,CASA,KAAM,CACJ,SAAAC,EACA,QAAAC,EACA,sBAAAC,EACA,kBAAAC,EACA,sBAAAC,CACF,EAAI,KAAK,oBAAoBL,CAAW,EAElCM,EAAgB,KAAK,MAAM,eAAiBd,EAE5Ce,EAAyB,IAAIb,EAA4B,CAC7D,MAAO,CACL,cAAAY,CACF,CACF,CAAC,EAAE,iBAAiBN,CAAW,EAE/B,OAAOb,EAAM,CACX,MAAO,CACL,MAAO,CAAC,EACR,QAAS,CAAC,EACV,OAAQ,CAAC,CACX,EACA,OAAQ,CACN,SAAUD,EAAYe,CAAQ,EAC9B,QAASf,EAAYgB,CAAO,EAC5B,gBAAiBK,CACnB,EACA,OAAQ,CACN,kBAAm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AAC,CAAE,QAAAD,CAAQ,IACjBA,EAAQ,eAAe,MACnBzB,EAAKyB,EAAQ,eAAe,KAAK,EACjCxB,EAAM,MAAS,CACvB,CAAC,CACH,CAEA,oBAAoBgB,EAA+C,CAOjE,MAAO,CACL,SAPe,SAAYA,EAAY,YAAY,IAAIX,CAAiB,EAQxE,QAPc,MAAO2B,GACrBhB,EAAY,YACV,IAAIV,EAAe,CAAE,QAAS0B,EAAK,MAAM,OAAQ,CAAC,CACpD,EAKA,sBAAuB,IAAMhB,EAAY,sBAAsB,EAC/D,sBAAwBc,GACtBd,EAAY,sBAAsBc,CAAK,EACzC,kBAAmB,IAAM,EAC3B,CACF,CACF",
|
6
|
+
"names": ["Left", "Right", "assign", "fromPromise", "setup", "isSuccessCommandResult", "CloseAppCommand", "OpenAppCommand", "UserInteractionRequired", "DEFAULT_UNLOCK_TIMEOUT_MS", "DeviceNotOnboardedError", "GetDeviceStatusDeviceAction", "XStateDeviceAction", "DeviceSessionStateType", "DeviceDisconnectedWhileSendingError", "isDashboardName", "OpenAppDeviceAction", "internalApi", "closeApp", "openApp", "getDeviceSessionState", "isDeviceOnboarded", "setDeviceSessionState", "unlockTimeout", "getDeviceStatusMachine", "context", "_", "input", "sessionState", "sessionStateType", "output", "state", "error", "arg0"]
|
7
7
|
}
|
@@ -0,0 +1,7 @@
|
|
1
|
+
{
|
2
|
+
"version": 3,
|
3
|
+
"sources": ["../../../../../src/api/utils/AppName.ts"],
|
4
|
+
"sourcesContent": ["const DASHBOARD_NAMES = [\"BOLOS\", \"OLOS\", \"OLOS\\u0000\"];\n\nexport const isDashboardName = (name: string) => DASHBOARD_NAMES.includes(name);\n"],
|
5
|
+
"mappings": "AAAA,MAAMA,EAAkB,CAAC,QAAS,OAAQ,QAAY,EAEzCC,EAAmBC,GAAiBF,EAAgB,SAASE,CAAI",
|
6
|
+
"names": ["DASHBOARD_NAMES", "isDashboardName", "name"]
|
7
|
+
}
|
@@ -0,0 +1,2 @@
|
|
1
|
+
import{isDashboardName as t}from"./AppName";describe("AppName",()=>{describe("isDashboardName",()=>{it("should return true if the value is BOLOS",()=>{const e=t("BOLOS");expect(e).toBeTruthy()}),it("should return true if the value is OLOS",()=>{const e=t("OLOS\0");expect(e).toBeTruthy()}),it("should return false if the value is Bitcoin",()=>{const e=t("Bitcoin");expect(e).toBeFalsy()})})});
|
2
|
+
//# sourceMappingURL=AppName.test.js.map
|
@@ -0,0 +1,7 @@
|
|
1
|
+
{
|
2
|
+
"version": 3,
|
3
|
+
"sources": ["../../../../../src/api/utils/AppName.test.ts"],
|
4
|
+
"sourcesContent": ["import { isDashboardName } from \"./AppName\";\n\ndescribe(\"AppName\", () => {\n describe(\"isDashboardName\", () => {\n it(\"should return true if the value is BOLOS\", () => {\n // GIVEN\n const value = \"BOLOS\";\n\n // WHEN\n const result = isDashboardName(value);\n\n // THEN\n expect(result).toBeTruthy();\n });\n\n it(\"should return true if the value is OLOS\", () => {\n // GIVEN\n const value = \"OLOS\\0\";\n\n // WHEN\n const result = isDashboardName(value);\n\n // THEN\n expect(result).toBeTruthy();\n });\n\n it(\"should return false if the value is Bitcoin\", () => {\n // GIVEN\n const value = \"Bitcoin\";\n\n // WHEN\n const result = isDashboardName(value);\n\n // THEN\n expect(result).toBeFalsy();\n });\n });\n});\n"],
|
5
|
+
"mappings": "AAAA,OAAS,mBAAAA,MAAuB,YAEhC,SAAS,UAAW,IAAM,CACxB,SAAS,kBAAmB,IAAM,CAChC,GAAG,2CAA4C,IAAM,CAKnD,MAAMC,EAASD,EAHD,OAGsB,EAGpC,OAAOC,CAAM,EAAE,WAAW,CAC5B,CAAC,EAED,GAAG,0CAA2C,IAAM,CAKlD,MAAMA,EAASD,EAHD,QAGsB,EAGpC,OAAOC,CAAM,EAAE,WAAW,CAC5B,CAAC,EAED,GAAG,8CAA+C,IAAM,CAKtD,MAAMA,EAASD,EAHD,SAGsB,EAGpC,OAAOC,CAAM,EAAE,UAAU,CAC3B,CAAC,CACH,CAAC,CACH,CAAC",
|
6
|
+
"names": ["isDashboardName", "result"]
|
7
|
+
}
|
@@ -4,7 +4,7 @@ import { type CommandErrors } from "./CommandErrors";
|
|
4
4
|
/**
|
5
5
|
* Status word list of global errors that any command could result
|
6
6
|
*/
|
7
|
-
export type GlobalCommandErrorStatusCode = "5515" | "5501" | "5502" | "5223";
|
7
|
+
export type GlobalCommandErrorStatusCode = "5515" | "5501" | "5502" | "5223" | "6e00" | "6d00";
|
8
8
|
/**
|
9
9
|
* Global command error class
|
10
10
|
*/
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"GlobalCommandError.d.ts","sourceRoot":"","sources":["../../../../../../src/api/command/utils/GlobalCommandError.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,YAAY,EAAE,MAAM,kCAAkC,CAAC;AACrE,OAAO,EACL,KAAK,gBAAgB,EACrB,mBAAmB,EACnB,0BAA0B,EAC3B,MAAM,YAAY,CAAC;AAEpB,OAAO,EAAE,KAAK,aAAa,EAAsB,MAAM,iBAAiB,CAAC;AAEzE;;GAEG;AACH,MAAM,MAAM,4BAA4B,
|
1
|
+
{"version":3,"file":"GlobalCommandError.d.ts","sourceRoot":"","sources":["../../../../../../src/api/command/utils/GlobalCommandError.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,YAAY,EAAE,MAAM,kCAAkC,CAAC;AACrE,OAAO,EACL,KAAK,gBAAgB,EACrB,mBAAmB,EACnB,0BAA0B,EAC3B,MAAM,YAAY,CAAC;AAEpB,OAAO,EAAE,KAAK,aAAa,EAAsB,MAAM,iBAAiB,CAAC;AAEzE;;GAEG;AACH,MAAM,MAAM,4BAA4B,GACpC,MAAM,GACN,MAAM,GACN,MAAM,GACN,MAAM,GACN,MAAM,GACN,MAAM,CAAC;AAEX;;GAEG;AACH,qBAAa,kBAAmB,SAAQ,mBAAmB,CAAC,4BAA4B,CAAC;gBAC3E,IAAI,EAAE,gBAAgB,CAAC,4BAA4B,CAAC;CAGjE;AAED;;GAEG;AACH,eAAO,MAAM,aAAa,EAAE,aAAa,CAAC,4BAA4B,CAOrE,CAAC;AAEF;;GAEG;AACH,qBAAa,yBAAyB;IACpC;;;OAGG;IACH,MAAM,CAAC,MAAM,CACX,YAAY,EAAE,YAAY,GACzB,kBAAkB,GAAG,0BAA0B;CAWnD"}
|
package/lib/types/src/api/device-action/os/GetDeviceStatus/GetDeviceStatusDeviceAction.d.ts.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"GetDeviceStatusDeviceAction.d.ts","sourceRoot":"","sources":["../../../../../../../src/api/device-action/os/GetDeviceStatus/GetDeviceStatusDeviceAction.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,MAAM,MAAM,CAAC;AAKlC,OAAO,EAEL,KAAK,6BAA6B,EACnC,MAAM,yCAAyC,CAAC;AAEjD,OAAO,EAAE,KAAK,WAAW,EAAE,MAAM,iCAAiC,CAAC;AAQnE,OAAO,EACL,KAAK,wBAAwB,EAC7B,kBAAkB,EACnB,MAAM,oDAAoD,CAAC;AAC5D,OAAO,EACL,KAAK,kBAAkB,EAExB,MAAM,wCAAwC,CAAC;AAEhD,OAAO,EACL,KAAK,sBAAsB,EAC3B,KAAK,sBAAsB,EAC3B,KAAK,kCAAkC,EACvC,KAAK,uBAAuB,EAC7B,MAAM,SAAS,CAAC;AAEjB,KAAK,mCAAmC,GAAG;IACzC,QAAQ,CAAC,SAAS,EAAE,OAAO,CAAC;IAC5B,QAAQ,CAAC,MAAM,EAAE,OAAO,CAAC;IACzB,QAAQ,CAAC,UAAU,EAAE,MAAM,GAAG,IAAI,CAAC;IACnC,QAAQ,CAAC,iBAAiB,EAAE,MAAM,GAAG,IAAI,CAAC;IAC1C,QAAQ,CAAC,KAAK,EAAE,sBAAsB,GAAG,IAAI,CAAC;CAC/C,CAAC;AAEF,MAAM,MAAM,mBAAmB,GAAG;IAChC,QAAQ,CAAC,gBAAgB,EAAE,MAAM,OAAO,CAAC,6BAA6B,CAAC,CAAC;IACxE,QAAQ,CAAC,qBAAqB,EAAE,MAAM,kBAAkB,CAAC;IACzD,QAAQ,CAAC,mBAAmB,EAAE,CAAC,IAAI,EAAE;QACnC,KAAK,EAAE;YAAE,aAAa,EAAE,MAAM,CAAA;SAAE,CAAC;KAClC,KAAK,UAAU,CAAC,IAAI,CAAC,CAAC;IACvB,QAAQ,CAAC,qBAAqB,EAAE,CAC9B,KAAK,EAAE,kBAAkB,KACtB,kBAAkB,CAAC;IACxB,QAAQ,CAAC,iBAAiB,EAAE,MAAM,OAAO,CAAC;CAC3C,CAAC;AAEF,MAAM,MAAM,0BAA0B,GAAG,CACvC,WAAW,EAAE,WAAW,KACrB,mBAAmB,CAAC;AAEzB,qBAAa,2BAA4B,SAAQ,kBAAkB,CACjE,uBAAuB,EACvB,sBAAsB,EACtB,sBAAsB,EACtB,kCAAkC,EAClC,mCAAmC,CACpC;IACC,gBAAgB,CACd,WAAW,EAAE,WAAW,GACvB,wBAAwB,CACzB,uBAAuB,EACvB,sBAAsB,EACtB,sBAAsB,EACtB,kCAAkC,EAClC,mCAAmC,CACpC;
|
1
|
+
{"version":3,"file":"GetDeviceStatusDeviceAction.d.ts","sourceRoot":"","sources":["../../../../../../../src/api/device-action/os/GetDeviceStatus/GetDeviceStatusDeviceAction.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,MAAM,MAAM,CAAC;AAKlC,OAAO,EAEL,KAAK,6BAA6B,EACnC,MAAM,yCAAyC,CAAC;AAEjD,OAAO,EAAE,KAAK,WAAW,EAAE,MAAM,iCAAiC,CAAC;AAQnE,OAAO,EACL,KAAK,wBAAwB,EAC7B,kBAAkB,EACnB,MAAM,oDAAoD,CAAC;AAC5D,OAAO,EACL,KAAK,kBAAkB,EAExB,MAAM,wCAAwC,CAAC;AAEhD,OAAO,EACL,KAAK,sBAAsB,EAC3B,KAAK,sBAAsB,EAC3B,KAAK,kCAAkC,EACvC,KAAK,uBAAuB,EAC7B,MAAM,SAAS,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["../../../../../../../src/api/device-action/os/GoToDashboard/GoToDashboardDeviceAction.ts"],"names":[],"mappings":"AAIA,OAAO,EAEL,KAAK,qBAAqB,EAC3B,MAAM,iCAAiC,CAAC;AACzC,OAAO,EAEL,KAAK,6BAA6B,EACnC,MAAM,yCAAyC,CAAC;AACjD,OAAO,EAAE,KAAK,WAAW,EAAE,MAAM,iCAAiC,CAAC;AAMnE,OAAO,EACL,KAAK,wBAAwB,EAC7B,kBAAkB,EACnB,MAAM,oDAAoD,CAAC;AAC5D,OAAO,EACL,KAAK,kBAAkB,EAExB,MAAM,wCAAwC,CAAC;
|
1
|
+
{"version":3,"file":"GoToDashboardDeviceAction.d.ts","sourceRoot":"","sources":["../../../../../../../src/api/device-action/os/GoToDashboard/GoToDashboardDeviceAction.ts"],"names":[],"mappings":"AAIA,OAAO,EAEL,KAAK,qBAAqB,EAC3B,MAAM,iCAAiC,CAAC;AACzC,OAAO,EAEL,KAAK,6BAA6B,EACnC,MAAM,yCAAyC,CAAC;AACjD,OAAO,EAAE,KAAK,WAAW,EAAE,MAAM,iCAAiC,CAAC;AAMnE,OAAO,EACL,KAAK,wBAAwB,EAC7B,kBAAkB,EACnB,MAAM,oDAAoD,CAAC;AAC5D,OAAO,EACL,KAAK,kBAAkB,EAExB,MAAM,wCAAwC,CAAC;AAGhD,OAAO,KAAK,EACV,oBAAoB,EACpB,oBAAoB,EACpB,gCAAgC,EAChC,qBAAqB,EACtB,MAAM,SAAS,CAAC;AAEjB,KAAK,iCAAiC,GAAG;IACvC,QAAQ,CAAC,UAAU,EAAE,MAAM,GAAG,IAAI,CAAC;IACnC,QAAQ,CAAC,KAAK,EAAE,oBAAoB,GAAG,IAAI,CAAC;CAC7C,CAAC;AAEF,MAAM,MAAM,mBAAmB,GAAG;IAChC,QAAQ,CAAC,gBAAgB,EAAE,MAAM,OAAO,CAAC,6BAA6B,CAAC,CAAC;IACxE,QAAQ,CAAC,QAAQ,EAAE,MAAM,OAAO,CAAC,qBAAqB,CAAC,CAAC;IACxD,QAAQ,CAAC,qBAAqB,EAAE,MAAM,kBAAkB,CAAC;IACzD,QAAQ,CAAC,qBAAqB,EAAE,CAC9B,KAAK,EAAE,kBAAkB,KACtB,kBAAkB,CAAC;CACzB,CAAC;AAEF,MAAM,MAAM,0BAA0B,GAAG,CACvC,WAAW,EAAE,WAAW,KACrB,mBAAmB,CAAC;AAEzB,qBAAa,yBAA0B,SAAQ,kBAAkB,CAC/D,qBAAqB,EACrB,oBAAoB,EACpB,oBAAoB,EACpB,gCAAgC,EAChC,iCAAiC,CAClC;IACC,gBAAgB,CACd,WAAW,EAAE,WAAW,GACvB,wBAAwB,CACzB,qBAAqB,EACrB,oBAAoB,EACpB,oBAAoB,EACpB,gCAAgC,EAChC,iCAAiC,CAClC;IA2PD,mBAAmB,CAAC,WAAW,EAAE,WAAW,GAAG,mBAAmB;CAanE"}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"OpenAppDeviceAction.d.ts","sourceRoot":"","sources":["../../../../../../../src/api/device-action/os/OpenAppDeviceAction/OpenAppDeviceAction.ts"],"names":[],"mappings":"AAIA,OAAO,EAEL,KAAK,qBAAqB,EAC3B,MAAM,iCAAiC,CAAC;AACzC,OAAO,EAEL,KAAK,oBAAoB,EAC1B,MAAM,gCAAgC,CAAC;AACxC,OAAO,EAAE,KAAK,WAAW,EAAE,MAAM,iCAAiC,CAAC;AAMnE,OAAO,EACL,KAAK,wBAAwB,EAC7B,kBAAkB,EACnB,MAAM,oDAAoD,CAAC;AAC5D,OAAO,EACL,KAAK,kBAAkB,EAExB,MAAM,wCAAwC,CAAC;
|
1
|
+
{"version":3,"file":"OpenAppDeviceAction.d.ts","sourceRoot":"","sources":["../../../../../../../src/api/device-action/os/OpenAppDeviceAction/OpenAppDeviceAction.ts"],"names":[],"mappings":"AAIA,OAAO,EAEL,KAAK,qBAAqB,EAC3B,MAAM,iCAAiC,CAAC;AACzC,OAAO,EAEL,KAAK,oBAAoB,EAC1B,MAAM,gC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A0B,EAC1B,gCAAgC,CACjC;IA0VD,mBAAmB,CAAC,WAAW,EAAE,WAAW,GAAG,mBAAmB;CAgBnE"}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"AppName.d.ts","sourceRoot":"","sources":["../../../../../src/api/utils/AppName.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,eAAe,SAAU,MAAM,YAAmC,CAAC"}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"AppName.test.d.ts","sourceRoot":"","sources":["../../../../../src/api/utils/AppName.test.ts"],"names":[],"mappings":""}
|