@ledgerhq/device-management-kit 0.0.0-io-revamp-20250715160954 → 0.0.0-ledger-button-20250806141658
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/cjs/package.json +0 -1
- package/lib/cjs/src/api/DeviceManagementKit.test.js +1 -1
- package/lib/cjs/src/api/DeviceManagementKit.test.js.map +2 -2
- package/lib/cjs/src/api/apdu/utils/ByteArrayBuilder.js +1 -1
- package/lib/cjs/src/api/apdu/utils/ByteArrayBuilder.js.map +3 -3
- package/lib/cjs/src/api/apdu/utils/ByteArrayBuilder.test.js +1 -1
- package/lib/cjs/src/api/apdu/utils/ByteArrayBuilder.test.js.map +2 -2
- package/lib/cjs/src/api/apdu/utils/ByteArrayParser.js +1 -1
- package/lib/cjs/src/api/apdu/utils/ByteArrayParser.js.map +3 -3
- package/lib/cjs/src/api/command/di/commandModule.js +1 -1
- package/lib/cjs/src/api/command/di/commandModule.js.map +3 -3
- package/lib/cjs/src/api/command/di/commandModule.test.js +1 -1
- package/lib/cjs/src/api/command/di/commandModule.test.js.map +2 -2
- package/lib/cjs/src/api/command/os/__mocks__/GetOsVersionCommand.js +1 -1
- package/lib/cjs/src/api/command/os/__mocks__/GetOsVersionCommand.js.map +2 -2
- package/lib/cjs/src/api/device/DeviceModel.js +1 -1
- package/lib/cjs/src/api/device/DeviceModel.js.map +2 -2
- package/lib/cjs/src/api/device-action/di/deviceActionModule.js +1 -1
- package/lib/cjs/src/api/device-action/di/deviceActionModule.js.map +3 -3
- package/lib/cjs/src/api/device-action/di/deviceActionModule.test.js +1 -1
- package/lib/cjs/src/api/device-action/di/deviceActionModule.test.js.map +2 -2
- package/lib/cjs/src/api/device-action/model/UserInteractionRequired.js +1 -1
- package/lib/cjs/src/api/device-action/model/UserInteractionRequired.js.map +2 -2
- package/lib/cjs/src/api/device-action/os/CallTaskInAppDeviceAction/CallTaskInAppDeviceAction.js +1 -1
- package/lib/cjs/src/api/device-action/os/CallTaskInAppDeviceAction/CallTaskInAppDeviceAction.js.map +2 -2
- package/lib/cjs/src/api/device-action/os/CallTaskInAppDeviceAction/CallTaskInAppDeviceActionTypes.js.map +1 -1
- package/lib/cjs/src/api/device-action/os/OpenAppDeviceAction/OpenAppDeviceAction.js +1 -1
- package/lib/cjs/src/api/device-action/os/OpenAppDeviceAction/OpenAppDeviceAction.js.map +2 -2
- package/lib/cjs/src/api/device-action/os/OpenAppDeviceAction/OpenAppDeviceAction.test.js +1 -1
- package/lib/cjs/src/api/device-action/os/OpenAppDeviceAction/OpenAppDeviceAction.test.js.map +2 -2
- package/lib/cjs/src/api/device-action/os/OpenAppDeviceAction/types.js +1 -1
- package/lib/cjs/src/api/device-action/os/OpenAppDeviceAction/types.js.map +1 -1
- package/lib/cjs/src/api/device-action/os/OpenAppWithDependencies/OpenAppWithDependenciesDeviceAction.js +1 -1
- package/lib/cjs/src/api/device-action/os/OpenAppWithDependencies/OpenAppWithDependenciesDeviceAction.js.map +2 -2
- package/lib/cjs/src/api/device-action/os/OpenAppWithDependencies/types.js.map +1 -1
- package/lib/cjs/src/api/device-action/os/SendCommandInAppDeviceAction/SendCommandInAppDeviceAction.js +1 -1
- package/lib/cjs/src/api/device-action/os/SendCommandInAppDeviceAction/SendCommandInAppDeviceAction.js.map +2 -2
- package/lib/cjs/src/api/device-action/os/SendCommandInAppDeviceAction/SendCommandInAppDeviceActionTypes.js +1 -1
- package/lib/cjs/src/api/device-action/os/SendCommandInAppDeviceAction/SendCommandInAppDeviceActionTypes.js.map +1 -1
- package/lib/cjs/src/api/device-model/data/StaticDeviceModelDataSource.js +1 -1
- package/lib/cjs/src/api/device-model/data/StaticDeviceModelDataSource.js.map +2 -2
- package/lib/cjs/src/api/device-model/data/StaticDeviceModelDataSource.test.js +1 -1
- package/lib/cjs/src/api/device-model/data/StaticDeviceModelDataSource.test.js.map +2 -2
- package/lib/cjs/src/api/device-model/model/DeviceModel.js +1 -1
- package/lib/cjs/src/api/device-model/model/DeviceModel.js.map +2 -2
- package/lib/cjs/src/api/transport/model/DeviceConnectionStateMachine.js +1 -1
- package/lib/cjs/src/api/transport/model/DeviceConnectionStateMachine.js.map +3 -3
- package/lib/cjs/src/di.js +1 -1
- package/lib/cjs/src/di.js.map +2 -2
- package/lib/cjs/src/internal/config/di/configModule.js +1 -1
- package/lib/cjs/src/internal/config/di/configModule.js.map +3 -3
- package/lib/cjs/src/internal/config/di/configModule.test.js +1 -1
- package/lib/cjs/src/internal/config/di/configModule.test.js.map +2 -2
- package/lib/cjs/src/internal/device-model/di/deviceModelModule.js +1 -1
- package/lib/cjs/src/internal/device-model/di/deviceModelModule.js.map +3 -3
- package/lib/cjs/src/internal/device-model/di/deviceModelModule.test.js +1 -1
- package/lib/cjs/src/internal/device-model/di/deviceModelModule.test.js.map +2 -2
- package/lib/cjs/src/internal/device-session/di/deviceSessionModule.js +1 -1
- package/lib/cjs/src/internal/device-session/di/deviceSessionModule.js.map +3 -3
- package/lib/cjs/src/internal/device-session/di/deviceSessionModule.test.js +1 -1
- package/lib/cjs/src/internal/device-session/di/deviceSessionModule.test.js.map +2 -2
- package/lib/cjs/src/internal/device-session/service/DefaultApduSenderService.js +1 -1
- package/lib/cjs/src/internal/device-session/service/DefaultApduSenderService.js.map +2 -2
- package/lib/cjs/src/internal/device-session/service/DefaultApduSenderService.test.js +1 -1
- package/lib/cjs/src/internal/device-session/service/DefaultApduSenderService.test.js.map +2 -2
- package/lib/cjs/src/internal/discovery/di/discoveryModule.js +1 -1
- package/lib/cjs/src/internal/discovery/di/discoveryModule.js.map +3 -3
- package/lib/cjs/src/internal/discovery/di/discoveryModule.test.js +1 -1
- package/lib/cjs/src/internal/discovery/di/discoveryModule.test.js.map +2 -2
- package/lib/cjs/src/internal/logger-publisher/di/loggerModule.js +1 -1
- package/lib/cjs/src/internal/logger-publisher/di/loggerModule.js.map +3 -3
- package/lib/cjs/src/internal/logger-publisher/di/loggerModule.test.js +1 -1
- package/lib/cjs/src/internal/logger-publisher/di/loggerModule.test.js.map +2 -2
- package/lib/cjs/src/internal/manager-api/di/managerApiModule.js +1 -1
- package/lib/cjs/src/internal/manager-api/di/managerApiModule.js.map +3 -3
- package/lib/cjs/src/internal/manager-api/di/managerApiModule.test.js +1 -1
- package/lib/cjs/src/internal/manager-api/di/managerApiModule.test.js.map +2 -2
- package/lib/cjs/src/internal/secure-channel/di/secureChannelModule.js +1 -1
- package/lib/cjs/src/internal/secure-channel/di/secureChannelModule.js.map +3 -3
- package/lib/cjs/src/internal/secure-channel/di/secureChannelModule.test.js +1 -1
- package/lib/cjs/src/internal/secure-channel/di/secureChannelModule.test.js.map +2 -2
- package/lib/cjs/src/internal/send/di/sendModule.js +1 -1
- package/lib/cjs/src/internal/send/di/sendModule.js.map +3 -3
- package/lib/cjs/src/internal/send/di/sendModule.test.js +1 -1
- package/lib/cjs/src/internal/send/di/sendModule.test.js.map +2 -2
- package/lib/cjs/src/internal/send/use-case/SendApduUseCase.js.map +2 -2
- package/lib/cjs/src/internal/transport/di/transportModule.js +1 -1
- package/lib/cjs/src/internal/transport/di/transportModule.js.map +3 -3
- package/lib/cjs/src/internal/transport/di/transportModule.test.js +1 -1
- package/lib/cjs/src/internal/transport/di/transportModule.test.js.map +2 -2
- package/lib/esm/package.json +0 -1
- package/lib/esm/src/api/DeviceManagementKit.test.js +1 -1
- package/lib/esm/src/api/DeviceManagementKit.test.js.map +2 -2
- package/lib/esm/src/api/apdu/utils/ByteArrayBuilder.js +1 -1
- package/lib/esm/src/api/apdu/utils/ByteArrayBuilder.js.map +3 -3
- package/lib/esm/src/api/apdu/utils/ByteArrayBuilder.test.js +1 -1
- package/lib/esm/src/api/apdu/utils/ByteArrayBuilder.test.js.map +2 -2
- package/lib/esm/src/api/apdu/utils/ByteArrayParser.js +1 -1
- package/lib/esm/src/api/apdu/utils/ByteArrayParser.js.map +3 -3
- package/lib/esm/src/api/command/di/commandModule.js +1 -1
- package/lib/esm/src/api/command/di/commandModule.js.map +3 -3
- package/lib/esm/src/api/command/di/commandModule.test.js +1 -1
- package/lib/esm/src/api/command/di/commandModule.test.js.map +2 -2
- package/lib/esm/src/api/command/os/__mocks__/GetOsVersionCommand.js +1 -1
- package/lib/esm/src/api/command/os/__mocks__/GetOsVersionCommand.js.map +2 -2
- package/lib/esm/src/api/device/DeviceModel.js +1 -1
- package/lib/esm/src/api/device/DeviceModel.js.map +2 -2
- package/lib/esm/src/api/device-action/di/deviceActionModule.js +1 -1
- package/lib/esm/src/api/device-action/di/deviceActionModule.js.map +3 -3
- package/lib/esm/src/api/device-action/di/deviceActionModule.test.js +1 -1
- package/lib/esm/src/api/device-action/di/deviceActionModule.test.js.map +2 -2
- package/lib/esm/src/api/device-action/model/UserInteractionRequired.js +1 -1
- package/lib/esm/src/api/device-action/model/UserInteractionRequired.js.map +2 -2
- package/lib/esm/src/api/device-action/os/CallTaskInAppDeviceAction/CallTaskInAppDeviceAction.js +1 -1
- package/lib/esm/src/api/device-action/os/CallTaskInAppDeviceAction/CallTaskInAppDeviceAction.js.map +2 -2
- package/lib/esm/src/api/device-action/os/OpenAppDeviceAction/OpenAppDeviceAction.js +1 -1
- package/lib/esm/src/api/device-action/os/OpenAppDeviceAction/OpenAppDeviceAction.js.map +2 -2
- package/lib/esm/src/api/device-action/os/OpenAppDeviceAction/OpenAppDeviceAction.test.js +1 -1
- package/lib/esm/src/api/device-action/os/OpenAppDeviceAction/OpenAppDeviceAction.test.js.map +2 -2
- package/lib/esm/src/api/device-action/os/OpenAppWithDependencies/OpenAppWithDependenciesDeviceAction.js +1 -1
- package/lib/esm/src/api/device-action/os/OpenAppWithDependencies/OpenAppWithDependenciesDeviceAction.js.map +2 -2
- package/lib/esm/src/api/device-action/os/SendCommandInAppDeviceAction/SendCommandInAppDeviceAction.js +1 -1
- package/lib/esm/src/api/device-action/os/SendCommandInAppDeviceAction/SendCommandInAppDeviceAction.js.map +2 -2
- package/lib/esm/src/api/device-model/data/StaticDeviceModelDataSource.js +1 -1
- package/lib/esm/src/api/device-model/data/StaticDeviceModelDataSource.js.map +2 -2
- package/lib/esm/src/api/device-model/data/StaticDeviceModelDataSource.test.js +1 -1
- package/lib/esm/src/api/device-model/data/StaticDeviceModelDataSource.test.js.map +2 -2
- package/lib/esm/src/api/device-model/model/DeviceModel.js +1 -1
- package/lib/esm/src/api/device-model/model/DeviceModel.js.map +2 -2
- package/lib/esm/src/api/transport/model/DeviceConnectionStateMachine.js +1 -1
- package/lib/esm/src/api/transport/model/DeviceConnectionStateMachine.js.map +3 -3
- package/lib/esm/src/di.js +1 -1
- package/lib/esm/src/di.js.map +2 -2
- package/lib/esm/src/internal/config/di/configModule.js +1 -1
- package/lib/esm/src/internal/config/di/configModule.js.map +3 -3
- package/lib/esm/src/internal/config/di/configModule.test.js +1 -1
- package/lib/esm/src/internal/config/di/configModule.test.js.map +2 -2
- package/lib/esm/src/internal/device-model/di/deviceModelModule.js +1 -1
- package/lib/esm/src/internal/device-model/di/deviceModelModule.js.map +3 -3
- package/lib/esm/src/internal/device-model/di/deviceModelModule.test.js +1 -1
- package/lib/esm/src/internal/device-model/di/deviceModelModule.test.js.map +2 -2
- package/lib/esm/src/internal/device-session/di/deviceSessionModule.js +1 -1
- package/lib/esm/src/internal/device-session/di/deviceSessionModule.js.map +3 -3
- package/lib/esm/src/internal/device-session/di/deviceSessionModule.test.js +1 -1
- package/lib/esm/src/internal/device-session/di/deviceSessionModule.test.js.map +2 -2
- package/lib/esm/src/internal/device-session/service/DefaultApduSenderService.js +1 -1
- package/lib/esm/src/internal/device-session/service/DefaultApduSenderService.js.map +2 -2
- package/lib/esm/src/internal/device-session/service/DefaultApduSenderService.test.js +1 -1
- package/lib/esm/src/internal/device-session/service/DefaultApduSenderService.test.js.map +2 -2
- package/lib/esm/src/internal/discovery/di/discoveryModule.js +1 -1
- package/lib/esm/src/internal/discovery/di/discoveryModule.js.map +3 -3
- package/lib/esm/src/internal/discovery/di/discoveryModule.test.js +1 -1
- package/lib/esm/src/internal/discovery/di/discoveryModule.test.js.map +2 -2
- package/lib/esm/src/internal/logger-publisher/di/loggerModule.js +1 -1
- package/lib/esm/src/internal/logger-publisher/di/loggerModule.js.map +3 -3
- package/lib/esm/src/internal/logger-publisher/di/loggerModule.test.js +1 -1
- package/lib/esm/src/internal/logger-publisher/di/loggerModule.test.js.map +2 -2
- package/lib/esm/src/internal/manager-api/di/managerApiModule.js +1 -1
- package/lib/esm/src/internal/manager-api/di/managerApiModule.js.map +3 -3
- package/lib/esm/src/internal/manager-api/di/managerApiModule.test.js +1 -1
- package/lib/esm/src/internal/manager-api/di/managerApiModule.test.js.map +2 -2
- package/lib/esm/src/internal/secure-channel/di/secureChannelModule.js +1 -1
- package/lib/esm/src/internal/secure-channel/di/secureChannelModule.js.map +3 -3
- package/lib/esm/src/internal/secure-channel/di/secureChannelModule.test.js +1 -1
- package/lib/esm/src/internal/secure-channel/di/secureChannelModule.test.js.map +2 -2
- package/lib/esm/src/internal/send/di/sendModule.js +1 -1
- package/lib/esm/src/internal/send/di/sendModule.js.map +3 -3
- package/lib/esm/src/internal/send/di/sendModule.test.js +1 -1
- package/lib/esm/src/internal/send/di/sendModule.test.js.map +2 -2
- package/lib/esm/src/internal/send/use-case/SendApduUseCase.js.map +2 -2
- package/lib/esm/src/internal/transport/di/transportModule.js +1 -1
- package/lib/esm/src/internal/transport/di/transportModule.js.map +3 -3
- package/lib/esm/src/internal/transport/di/transportModule.test.js +1 -1
- package/lib/esm/src/internal/transport/di/transportModule.test.js.map +2 -2
- package/lib/types/src/api/apdu/utils/ApduBuilder.d.ts.map +1 -1
- package/lib/types/src/api/apdu/utils/ApduParser.d.ts.map +1 -1
- package/lib/types/src/api/apdu/utils/ByteArrayBuilder.d.ts +28 -0
- package/lib/types/src/api/apdu/utils/ByteArrayBuilder.d.ts.map +1 -1
- package/lib/types/src/api/apdu/utils/ByteArrayParser.d.ts +1 -0
- package/lib/types/src/api/apdu/utils/ByteArrayParser.d.ts.map +1 -1
- package/lib/types/src/api/command/di/commandModule.d.ts.map +1 -1
- package/lib/types/src/api/command/os/__mocks__/GetOsVersionCommand.d.ts.map +1 -1
- package/lib/types/src/api/command/utils/CommandErrors.d.ts.map +1 -1
- package/lib/types/src/api/device/DeviceModel.d.ts +2 -1
- package/lib/types/src/api/device/DeviceModel.d.ts.map +1 -1
- package/lib/types/src/api/device-action/__test-utils__/setupTestMachine.d.ts.map +1 -1
- package/lib/types/src/api/device-action/di/deviceActionModule.d.ts.map +1 -1
- package/lib/types/src/api/device-action/model/UserInteractionRequired.d.ts +1 -0
- package/lib/types/src/api/device-action/model/UserInteractionRequired.d.ts.map +1 -1
- package/lib/types/src/api/device-action/os/CallTaskInAppDeviceAction/CallTaskInAppDeviceAction.d.ts.map +1 -1
- package/lib/types/src/api/device-action/os/CallTaskInAppDeviceAction/CallTaskInAppDeviceActionTypes.d.ts +0 -1
- package/lib/types/src/api/device-action/os/CallTaskInAppDeviceAction/CallTaskInAppDeviceActionTypes.d.ts.map +1 -1
- package/lib/types/src/api/device-action/os/OpenAppDeviceAction/OpenAppDeviceAction.d.ts.map +1 -1
- package/lib/types/src/api/device-action/os/OpenAppDeviceAction/types.d.ts +0 -1
- package/lib/types/src/api/device-action/os/OpenAppDeviceAction/types.d.ts.map +1 -1
- package/lib/types/src/api/device-action/os/OpenAppWithDependencies/OpenAppWithDependenciesDeviceAction.d.ts.map +1 -1
- package/lib/types/src/api/device-action/os/OpenAppWithDependencies/types.d.ts +0 -1
- package/lib/types/src/api/device-action/os/OpenAppWithDependencies/types.d.ts.map +1 -1
- package/lib/types/src/api/device-action/os/SendCommandInAppDeviceAction/SendCommandInAppDeviceAction.d.ts.map +1 -1
- package/lib/types/src/api/device-action/os/SendCommandInAppDeviceAction/SendCommandInAppDeviceActionTypes.d.ts +0 -1
- package/lib/types/src/api/device-action/os/SendCommandInAppDeviceAction/SendCommandInAppDeviceActionTypes.d.ts.map +1 -1
- package/lib/types/src/api/device-model/data/StaticDeviceModelDataSource.d.ts.map +1 -1
- package/lib/types/src/api/device-model/model/DeviceModel.d.ts.map +1 -1
- package/lib/types/src/api/device-session/service/DefaultApduReceiverService.stub.d.ts.map +1 -1
- package/lib/types/src/api/device-session/service/DefaultApduSenderService.stub.d.ts.map +1 -1
- package/lib/types/src/api/transport/model/DeviceConnectionStateMachine.d.ts.map +1 -1
- package/lib/types/src/api/utils/AppName.d.ts.map +1 -1
- package/lib/types/src/api/utils/HexaString.d.ts.map +1 -1
- package/lib/types/src/di.d.ts.map +1 -1
- package/lib/types/src/internal/config/di/configModule.d.ts.map +1 -1
- package/lib/types/src/internal/device-model/di/deviceModelModule.d.ts.map +1 -1
- package/lib/types/src/internal/device-session/di/deviceSessionModule.d.ts.map +1 -1
- package/lib/types/src/internal/device-session/model/DeviceSession.stub.d.ts.map +1 -1
- package/lib/types/src/internal/device-session/utils/deviceSessionUtils.d.ts.map +1 -1
- package/lib/types/src/internal/discovery/di/discoveryModule.d.ts.map +1 -1
- package/lib/types/src/internal/logger-publisher/di/loggerModule.d.ts.map +1 -1
- package/lib/types/src/internal/manager-api/di/managerApiModule.d.ts.map +1 -1
- package/lib/types/src/internal/secure-channel/di/secureChannelModule.d.ts.map +1 -1
- package/lib/types/src/internal/send/di/sendModule.d.ts.map +1 -1
- package/lib/types/src/internal/send/use-case/SendApduUseCase.d.ts.map +1 -1
- package/lib/types/src/internal/transport/di/transportModule.d.ts.map +1 -1
- package/lib/types/tsconfig.prod.tsbuildinfo +1 -1
- package/package.json +4 -5
@@ -1,7 +1,7 @@
|
|
1
1
|
{
|
2
2
|
"version": 3,
|
3
3
|
"sources": ["../../../../../../src/api/apdu/utils/ByteArrayParser.ts"],
|
4
|
-
"sourcesContent": ["import { bufferToHexaString, type HexaString } from \"@api/utils/HexaString\";\n\nexport type TaggedField = {\n readonly tag: number;\n readonly value: Uint8Array;\n};\n\n/**\n * ByteArrayParser is a utility class to help parse a byte array.\n *\n * It provides methods to extract fields of different types from the buffer.\n *\n * @example\n * ```\n * const parser = new ByteArrayParser(buffer);\n * const targetId = parser.encodeToHexaString(parser.extractFieldByLength(4));\n * const seVersion = parser.encodeToString(parser.extractFieldLVEncoded());\n * ```\n */\nexport class ByteArrayParser {\n private index: number = 0;\n\n constructor(private readonly buffer: Uint8Array) {}\n\n // ==========\n // Public API\n // ==========\n\n /**\n * Test if the length is greater than the response length\n * @param length: number\n * @returns {boolean} - Returns false if the length is greater than the response length\n */\n testMinimalLength(length: number): boolean {\n return length <= this.buffer.length - this.index;\n }\n\n /**\n * Extract a single byte from the response\n * @returns {number | undefined} - Returns the byte extracted from the response\n */\n extract8BitUInt(): number | undefined {\n if (this.outOfRange(1)) return;\n return this.buffer[this.index++];\n }\n\n /**\n * Extract a 16-bit unsigned integer from the response\n * @param bigEndian: boolean - True to decode in big endian, false for little endian\n * @returns {number | undefined} - Returns the 16-bit unsigned integer extracted from the response\n */\n extract16BitUInt(bigEndian: boolean = true): number | undefined {\n const value = this.extractNumber(16n, false, bigEndian);\n return value === undefined ? undefined : Number(value);\n }\n\n /**\n * Extract a 16-bit signed integer from the response\n * @param bigEndian: boolean - True to decode in big endian, false for little endian\n * @returns {number | undefined} - Returns the 16-bit signed integer extracted from the response\n */\n extract16BitInt(bigEndian: boolean = true): number | undefined {\n const value = this.extractNumber(16n, true, bigEndian);\n return value === undefined ? undefined : Number(value);\n }\n\n /**\n * Extract a 32-bit unsigned integer from the response\n * @param bigEndian: boolean - True to decode in big endian, false for little endian\n * @returns {number | undefined} - Returns the 32-bit unsigned integer extracted from the response\n */\n extract32BitUInt(bigEndian: boolean = true): number | undefined {\n const value = this.extractNumber(32n, false, bigEndian);\n return value === undefined ? undefined : Number(value);\n }\n\n /**\n * Extract a 32-bit signed integer from the response\n * @param bigEndian: boolean - True to decode in big endian, false for little endian\n * @returns {number | undefined} - Returns the 32-bit signed integer extracted from the response\n */\n extract32BitInt(bigEndian: boolean = true): number | undefined {\n const value = this.extractNumber(32n, true, bigEndian);\n return value === undefined ? undefined : Number(value);\n }\n\n /**\n * Extract a 64-bit unsigned integer from the response\n * @param bigEndian: boolean - True to decode in big endian, false for little endian\n * @returns {number | undefined} - Returns the 64-bit unsigned integer extracted from the response\n */\n extract64BitUInt(bigEndian: boolean = true): bigint | undefined {\n return this.extractNumber(64n, false, bigEndian);\n }\n\n /**\n * Extract a 64-bit signed integer from the response\n * @param bigEndian: boolean - True to decode in big endian, false for little endian\n * @returns {number | undefined} - Returns the 64-bit signed integer extracted from the response\n */\n extract64BitInt(bigEndian: boolean = true): bigint | undefined {\n return this.extractNumber(64n, true, bigEndian);\n }\n\n /**\n * Extract a 128-bit unsigned integer from the response\n * @param bigEndian: boolean - True to decode in big endian, false for little endian\n * @returns {number | undefined} - Returns the 128-bit unsigned integer extracted from the response\n */\n extract128BitUInt(bigEndian: boolean = true): bigint | undefined {\n return this.extractNumber(128n, false, bigEndian);\n }\n\n /**\n * Extract a 128-bit signed integer from the response\n * @param bigEndian: boolean - True to decode in big endian, false for little endian\n * @returns {number | undefined} - Returns the 128-bit signed integer extracted from the response\n */\n extract128BitInt(bigEndian: boolean = true): bigint | undefined {\n return this.extractNumber(128n, true, bigEndian);\n }\n\n /**\n * Extract a 256-bit unsigned integer from the response\n * @param bigEndian: boolean - True to decode in big endian, false for little endian\n * @returns {number | undefined} - Returns the 256-bit unsigned integer extracted from the response\n */\n extract256BitUInt(bigEndian: boolean = true): bigint | undefined {\n return this.extractNumber(256n, false, bigEndian);\n }\n\n /**\n * Extract a 256-bit signed integer from the response\n * @param bigEndian: boolean - True to decode in big endian, false for little endian\n * @returns {number | undefined} - Returns the 256-bit signed integer extracted from the response\n */\n extract256BitInt(bigEndian: boolean = true): bigint | undefined {\n return this.extractNumber(256n, true, bigEndian);\n }\n\n /**\n * Extract a field of a specified length from the response\n * @param length: number - The length of the field to extract\n * @returns {Uint8Array | undefined} - Returns the field extracted from the response\n */\n extractFieldByLength(length: number): Uint8Array | undefined {\n if (this.outOfRange(length)) return;\n if (length === 0) return new Uint8Array();\n const field = this.buffer.slice(this.index, this.index + length);\n this.index += length;\n return field;\n }\n\n /**\n * Extract a field from the response that is length-value encoded\n * @returns {Uint8Array | undefined} - Returns the field extracted from the response\n */\n extractFieldLVEncoded(): Uint8Array | undefined {\n // extract Length field\n const length = this.extract8BitUInt();\n if (length === undefined) return;\n else if (length === 0) return new Uint8Array();\n const field = this.extractFieldByLength(length);\n // if the field is inconsistent then roll back to the initial point\n if (field === undefined) this.index--;\n return field;\n }\n\n /**\n * Extract a field from the response that is tag-length-value encoded\n * @returns {TaggedField | undefined} - Returns the field extracted from the response\n */\n extractFieldTLVEncoded(): TaggedField | undefined {\n if (this.outOfRange(2)) return;\n\n const tag = this.extract8BitUInt();\n const value = this.extractFieldLVEncoded();\n\n if (tag === undefined || value === undefined) {\n this.index--;\n return;\n }\n return { tag, value };\n }\n\n /**\n * Encode a value to a hexadecimal string\n * @param value {Uint8Array} - The value to encode\n * @param prefix {boolean} - Whether to add a prefix to the encoded value\n * @returns {string} - The encoded value as a hexadecimal string\n */\n encodeToHexaString(value?: Uint8Array, prefix?: false): string;\n encodeToHexaString(value?: Uint8Array, prefix?: true): HexaString;\n encodeToHexaString(\n value?: Uint8Array,\n prefix: boolean = false,\n ): HexaString | string {\n if (value === undefined || value.length === 0) return \"\";\n const result = bufferToHexaString(value);\n return prefix ? result : result.slice(2);\n }\n\n /**\n * Encode a value to an ASCII string\n * @param value {Uint8Array} - The value to encode\n * @returns {string} - The encoded value as an ASCII string\n */\n encodeToString(value?: Uint8Array): string {\n let result = \"\";\n let index = 0;\n\n if (!value) return result;\n\n while (index <= value.length) {\n const item = value[index];\n if (item) result += String.fromCharCode(item);\n index++;\n }\n\n return result;\n }\n\n /**\n * Get the current index of the parser\n * @returns {number} - The current index of the parser\n */\n getCurrentIndex(): number {\n return this.index;\n }\n\n /**\n * Reset the index of the parser to 0\n */\n resetIndex() {\n this.index = 0;\n }\n\n /**\n * Get the remaining length of the response\n * @returns {number} - The remaining length of the response\n */\n getUnparsedRemainingLength(): number {\n return this.buffer.length - this.index;\n }\n\n // ===========\n // Private API\n // ===========\n\n /**\n * Check whether the expected length is out of range\n * @param length: number\n * @returns {boolean} - Returns true if the expected length is out of range\n */\n private outOfRange(length: number): boolean {\n return this.index + length > this.buffer.length;\n }\n\n /**\n * Extract a number from the buffer\n * @param sizeInBits: bigint - The number size in bits, for example 16 for a uint16\n * @param signed: boolean - True is the number can be signed and converted to two's compliment\n * @param bigEndian: boolean - True to decode in big endian, false for little endian\n * @returns {bigint | undefined} - Returns the number extracted from the buffer\n */\n private extractNumber(\n sizeInBits: bigint,\n signed: boolean,\n bigEndian: boolean,\n ): bigint | undefined {\n // Check the range\n const sizeInBytes: number = Number(sizeInBits) / 8;\n if (this.outOfRange(sizeInBytes)) return;\n\n // Compute the number\n let value: bigint = 0n;\n if (bigEndian) {\n for (let i = 0; i < sizeInBytes; i++) {\n value = (value << 8n) | BigInt(this.buffer[i + this.index]!);\n }\n } else {\n for (let i = sizeInBytes - 1; i >= 0; i--) {\n value = (value << 8n) | BigInt(this.buffer[i + this.index]!);\n }\n }\n\n // Convert the value to two's complement if it is negative\n // https://en.wikipedia.org/wiki/Two%27s_complement\n if (signed) {\n const limit = 1n << (sizeInBits - 1n);\n if (value & limit) {\n value -= limit << 1n;\n }\n }\n\n this.index += sizeInBytes;\n return value;\n }\n}\n"],
|
5
|
-
"mappings": "AAAA,OAAS,sBAAAA,MAA2C,
|
6
|
-
"names": ["bufferToHexaString", "ByteArrayParser", "buffer", "length", "bigEndian", "value", "field", "tag", "prefix", "result", "index", "item", "sizeInBits", "signed", "sizeInBytes", "i", "limit"]
|
4
|
+
"sourcesContent": ["import { bufferToHexaString, type HexaString } from \"@api/utils/HexaString\";\n\nexport type TaggedField = {\n readonly tag: number;\n readonly value: Uint8Array;\n readonly tlv: Uint8Array;\n};\n\n/**\n * ByteArrayParser is a utility class to help parse a byte array.\n *\n * It provides methods to extract fields of different types from the buffer.\n *\n * @example\n * ```\n * const parser = new ByteArrayParser(buffer);\n * const targetId = parser.encodeToHexaString(parser.extractFieldByLength(4));\n * const seVersion = parser.encodeToString(parser.extractFieldLVEncoded());\n * ```\n */\nexport class ByteArrayParser {\n private index: number = 0;\n\n constructor(private readonly buffer: Uint8Array) {}\n\n // ==========\n // Public API\n // ==========\n\n /**\n * Test if the length is greater than the response length\n * @param length: number\n * @returns {boolean} - Returns false if the length is greater than the response length\n */\n testMinimalLength(length: number): boolean {\n return length <= this.buffer.length - this.index;\n }\n\n /**\n * Extract a single byte from the response\n * @returns {number | undefined} - Returns the byte extracted from the response\n */\n extract8BitUInt(): number | undefined {\n if (this.outOfRange(1)) return;\n return this.buffer[this.index++];\n }\n\n /**\n * Extract a 16-bit unsigned integer from the response\n * @param bigEndian: boolean - True to decode in big endian, false for little endian\n * @returns {number | undefined} - Returns the 16-bit unsigned integer extracted from the response\n */\n extract16BitUInt(bigEndian: boolean = true): number | undefined {\n const value = this.extractNumber(16n, false, bigEndian);\n return value === undefined ? undefined : Number(value);\n }\n\n /**\n * Extract a 16-bit signed integer from the response\n * @param bigEndian: boolean - True to decode in big endian, false for little endian\n * @returns {number | undefined} - Returns the 16-bit signed integer extracted from the response\n */\n extract16BitInt(bigEndian: boolean = true): number | undefined {\n const value = this.extractNumber(16n, true, bigEndian);\n return value === undefined ? undefined : Number(value);\n }\n\n /**\n * Extract a 32-bit unsigned integer from the response\n * @param bigEndian: boolean - True to decode in big endian, false for little endian\n * @returns {number | undefined} - Returns the 32-bit unsigned integer extracted from the response\n */\n extract32BitUInt(bigEndian: boolean = true): number | undefined {\n const value = this.extractNumber(32n, false, bigEndian);\n return value === undefined ? undefined : Number(value);\n }\n\n /**\n * Extract a 32-bit signed integer from the response\n * @param bigEndian: boolean - True to decode in big endian, false for little endian\n * @returns {number | undefined} - Returns the 32-bit signed integer extracted from the response\n */\n extract32BitInt(bigEndian: boolean = true): number | undefined {\n const value = this.extractNumber(32n, true, bigEndian);\n return value === undefined ? undefined : Number(value);\n }\n\n /**\n * Extract a 64-bit unsigned integer from the response\n * @param bigEndian: boolean - True to decode in big endian, false for little endian\n * @returns {number | undefined} - Returns the 64-bit unsigned integer extracted from the response\n */\n extract64BitUInt(bigEndian: boolean = true): bigint | undefined {\n return this.extractNumber(64n, false, bigEndian);\n }\n\n /**\n * Extract a 64-bit signed integer from the response\n * @param bigEndian: boolean - True to decode in big endian, false for little endian\n * @returns {number | undefined} - Returns the 64-bit signed integer extracted from the response\n */\n extract64BitInt(bigEndian: boolean = true): bigint | undefined {\n return this.extractNumber(64n, true, bigEndian);\n }\n\n /**\n * Extract a 128-bit unsigned integer from the response\n * @param bigEndian: boolean - True to decode in big endian, false for little endian\n * @returns {number | undefined} - Returns the 128-bit unsigned integer extracted from the response\n */\n extract128BitUInt(bigEndian: boolean = true): bigint | undefined {\n return this.extractNumber(128n, false, bigEndian);\n }\n\n /**\n * Extract a 128-bit signed integer from the response\n * @param bigEndian: boolean - True to decode in big endian, false for little endian\n * @returns {number | undefined} - Returns the 128-bit signed integer extracted from the response\n */\n extract128BitInt(bigEndian: boolean = true): bigint | undefined {\n return this.extractNumber(128n, true, bigEndian);\n }\n\n /**\n * Extract a 256-bit unsigned integer from the response\n * @param bigEndian: boolean - True to decode in big endian, false for little endian\n * @returns {number | undefined} - Returns the 256-bit unsigned integer extracted from the response\n */\n extract256BitUInt(bigEndian: boolean = true): bigint | undefined {\n return this.extractNumber(256n, false, bigEndian);\n }\n\n /**\n * Extract a 256-bit signed integer from the response\n * @param bigEndian: boolean - True to decode in big endian, false for little endian\n * @returns {number | undefined} - Returns the 256-bit signed integer extracted from the response\n */\n extract256BitInt(bigEndian: boolean = true): bigint | undefined {\n return this.extractNumber(256n, true, bigEndian);\n }\n\n /**\n * Extract a field of a specified length from the response\n * @param length: number - The length of the field to extract\n * @returns {Uint8Array | undefined} - Returns the field extracted from the response\n */\n extractFieldByLength(length: number): Uint8Array | undefined {\n if (this.outOfRange(length)) return;\n if (length === 0) return new Uint8Array();\n const field = this.buffer.slice(this.index, this.index + length);\n this.index += length;\n return field;\n }\n\n /**\n * Extract a field from the response that is length-value encoded\n * @returns {Uint8Array | undefined} - Returns the field extracted from the response\n */\n extractFieldLVEncoded(): Uint8Array | undefined {\n // extract Length field\n const length = this.extract8BitUInt();\n if (length === undefined) return;\n else if (length === 0) return new Uint8Array();\n const field = this.extractFieldByLength(length);\n // if the field is inconsistent then roll back to the initial point\n if (field === undefined) this.index--;\n return field;\n }\n\n /**\n * Extract a field from the response that is tag-length-value encoded\n * @returns {TaggedField | undefined} - Returns the field extracted from the response\n */\n extractFieldTLVEncoded(): TaggedField | undefined {\n if (this.outOfRange(2)) return;\n\n const startIndex = this.index;\n const tag = this.extract8BitUInt();\n const value = this.extractFieldLVEncoded();\n\n if (tag === undefined || value === undefined) {\n this.index--;\n return;\n }\n const endIndex = this.index;\n return { tag, value, tlv: this.buffer.slice(startIndex, endIndex) };\n }\n\n /**\n * Encode a value to a hexadecimal string\n * @param value {Uint8Array} - The value to encode\n * @param prefix {boolean} - Whether to add a prefix to the encoded value\n * @returns {string} - The encoded value as a hexadecimal string\n */\n encodeToHexaString(value?: Uint8Array, prefix?: false): string;\n encodeToHexaString(value?: Uint8Array, prefix?: true): HexaString;\n encodeToHexaString(\n value?: Uint8Array,\n prefix: boolean = false,\n ): HexaString | string {\n if (value === undefined || value.length === 0) return \"\";\n const result = bufferToHexaString(value);\n return prefix ? result : result.slice(2);\n }\n\n /**\n * Encode a value to an ASCII string\n * @param value {Uint8Array} - The value to encode\n * @returns {string} - The encoded value as an ASCII string\n */\n encodeToString(value?: Uint8Array): string {\n let result = \"\";\n let index = 0;\n\n if (!value) return result;\n\n while (index <= value.length) {\n const item = value[index];\n if (item) result += String.fromCharCode(item);\n index++;\n }\n\n return result;\n }\n\n /**\n * Get the current index of the parser\n * @returns {number} - The current index of the parser\n */\n getCurrentIndex(): number {\n return this.index;\n }\n\n /**\n * Reset the index of the parser to 0\n */\n resetIndex() {\n this.index = 0;\n }\n\n /**\n * Get the remaining length of the response\n * @returns {number} - The remaining length of the response\n */\n getUnparsedRemainingLength(): number {\n return this.buffer.length - this.index;\n }\n\n // ===========\n // Private API\n // ===========\n\n /**\n * Check whether the expected length is out of range\n * @param length: number\n * @returns {boolean} - Returns true if the expected length is out of range\n */\n private outOfRange(length: number): boolean {\n return this.index + length > this.buffer.length;\n }\n\n /**\n * Extract a number from the buffer\n * @param sizeInBits: bigint - The number size in bits, for example 16 for a uint16\n * @param signed: boolean - True is the number can be signed and converted to two's compliment\n * @param bigEndian: boolean - True to decode in big endian, false for little endian\n * @returns {bigint | undefined} - Returns the number extracted from the buffer\n */\n private extractNumber(\n sizeInBits: bigint,\n signed: boolean,\n bigEndian: boolean,\n ): bigint | undefined {\n // Check the range\n const sizeInBytes: number = Number(sizeInBits) / 8;\n if (this.outOfRange(sizeInBytes)) return;\n\n // Compute the number\n let value: bigint = 0n;\n if (bigEndian) {\n for (let i = 0; i < sizeInBytes; i++) {\n value = (value << 8n) | BigInt(this.buffer[i + this.index]!);\n }\n } else {\n for (let i = sizeInBytes - 1; i >= 0; i--) {\n value = (value << 8n) | BigInt(this.buffer[i + this.index]!);\n }\n }\n\n // Convert the value to two's complement if it is negative\n // https://en.wikipedia.org/wiki/Two%27s_complement\n if (signed) {\n const limit = 1n << (sizeInBits - 1n);\n if (value & limit) {\n value -= limit << 1n;\n }\n }\n\n this.index += sizeInBytes;\n return value;\n }\n}\n"],
|
5
|
+
"mappings": "AAAA,OAAS,sBAAAA,MAA2C,wBAoB7C,MAAMC,CAAgB,CAG3B,YAA6BC,EAAoB,CAApB,YAAAA,CAAqB,CAF1C,MAAgB,EAaxB,kBAAkBC,EAAyB,CACzC,OAAOA,GAAU,KAAK,OAAO,OAAS,KAAK,KAC7C,CAMA,iBAAsC,CACpC,GAAI,MAAK,WAAW,CAAC,EACrB,OAAO,KAAK,OAAO,KAAK,OAAO,CACjC,CAOA,iBAAiBC,EAAqB,GAA0B,CAC9D,MAAMC,EAAQ,KAAK,cAAc,IAAK,GAAOD,CAAS,EACtD,OAAOC,IAAU,O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AAK,CAAE,MAG7D,SAASA,EAAID,EAAc,EAAGC,GAAK,EAAGA,IACpCZ,EAASA,GAAS,GAAM,OAAO,KAAK,OAAOY,EAAI,KAAK,KAAK,CAAE,EAM/D,GAAIF,EAAQ,CACV,MAAMG,EAAQ,IAAOJ,EAAa,GAC9BT,EAAQa,IACVb,GAASa,GAAS,GAEtB,CAEA,YAAK,OAASF,EACPX,CACT,CACF",
|
6
|
+
"names": ["bufferToHexaString", "ByteArrayParser", "buffer", "length", "bigEndian", "value", "field", "startIndex", "tag", "endIndex", "prefix", "result", "index", "item", "sizeInBits", "signed", "sizeInBytes", "i", "limit"]
|
7
7
|
}
|
@@ -1,2 +1,2 @@
|
|
1
|
-
import{ContainerModule as
|
1
|
+
import{ContainerModule as n}from"inversify";import{SendCommandUseCase as d}from"../../command/use-case/SendCommandUseCase";import{StubUseCase as r}from"../../../../src/di.stub";import{commandTypes as o}from"./commandTypes";const i=({stub:e=!1}={})=>new n(({bind:m,rebindSync:a})=>{m(o.SendCommandUseCase).to(d),e&&a(o.SendCommandUseCase).to(r)});export{i as commandModuleFactory};
|
2
2
|
//# sourceMappingURL=commandModule.js.map
|
@@ -1,7 +1,7 @@
|
|
1
1
|
{
|
2
2
|
"version": 3,
|
3
3
|
"sources": ["../../../../../../src/api/command/di/commandModule.ts"],
|
4
|
-
"sourcesContent": ["import { ContainerModule } from \"inversify\";\n\nimport { SendCommandUseCase } from \"@api/command/use-case/SendCommandUseCase\";\nimport { StubUseCase } from \"@root/src/di.stub\";\n\nimport { commandTypes } from \"./commandTypes\";\n\ntype CommandModuleArgs = Partial<{\n readonly stub: boolean;\n}>;\n\nexport const commandModuleFactory = ({\n stub = false,\n}: CommandModuleArgs = {}) =>\n new ContainerModule(
|
5
|
-
"mappings": "AAAA,OAAS,mBAAAA,MAAuB,YAEhC,OAAS,sBAAAC,MAA0B,2CACnC,OAAS,eAAAC,MAAmB,oBAE5B,OAAS,gBAAAC,MAAoB,iBAMtB,MAAMC,EAAuB,CAAC,CACnC,KAAAC,EAAO,EACT,EAAuB,CAAC,IACtB,IAAIL,
|
6
|
-
"names": ["ContainerModule", "SendCommandUseCase", "StubUseCase", "commandTypes", "commandModuleFactory", "stub", "bind", "
|
4
|
+
"sourcesContent": ["import { ContainerModule } from \"inversify\";\n\nimport { SendCommandUseCase } from \"@api/command/use-case/SendCommandUseCase\";\nimport { StubUseCase } from \"@root/src/di.stub\";\n\nimport { commandTypes } from \"./commandTypes\";\n\ntype CommandModuleArgs = Partial<{\n readonly stub: boolean;\n}>;\n\nexport const commandModuleFactory = ({\n stub = false,\n}: CommandModuleArgs = {}) =>\n new ContainerModule(({ bind, rebindSync }) => {\n bind(commandTypes.SendCommandUseCase).to(SendCommandUseCase);\n if (stub) {\n rebindSync(commandTypes.SendCommandUseCase).to(StubUseCase);\n }\n });\n"],
|
5
|
+
"mappings": "AAAA,OAAS,mBAAAA,MAAuB,YAEhC,OAAS,sBAAAC,MAA0B,2CACnC,OAAS,eAAAC,MAAmB,oBAE5B,OAAS,gBAAAC,MAAoB,iBAMtB,MAAMC,EAAuB,CAAC,CACnC,KAAAC,EAAO,EACT,EAAuB,CAAC,IACtB,IAAIL,EAAgB,CAAC,CAAE,KAAAM,EAAM,WAAAC,CAAW,IAAM,CAC5CD,EAAKH,EAAa,kBAAkB,EAAE,GAAGF,CAAkB,EACvDI,GACFE,EAAWJ,EAAa,kBAAkB,EAAE,GAAGD,CAAW,CAE9D,CAAC",
|
6
|
+
"names": ["ContainerModule", "SendCommandUseCase", "StubUseCase", "commandTypes", "commandModuleFactory", "stub", "bind", "rebindSync"]
|
7
7
|
}
|
@@ -1,2 +1,2 @@
|
|
1
|
-
import{Container as n}from"inversify";import{SendCommandUseCase as r}from"../../command/use-case/SendCommandUseCase";import{deviceSessionModuleFactory as a}from"../../../internal/device-session/di/deviceSessionModule";import{loggerModuleFactory as s}from"../../../internal/logger-publisher/di/loggerModule";import{StubUseCase as c}from"../../../../src/di.stub";import{commandModuleFactory as d}from"./commandModule";import{commandTypes as m}from"./commandTypes";describe("commandModuleFactory",()=>{describe("Default",()=>{let e,o;beforeEach(()=>{o=d(),e=new n,e.
|
1
|
+
import{Container as n}from"inversify";import{SendCommandUseCase as r}from"../../command/use-case/SendCommandUseCase";import{deviceSessionModuleFactory as a}from"../../../internal/device-session/di/deviceSessionModule";import{loggerModuleFactory as s}from"../../../internal/logger-publisher/di/loggerModule";import{StubUseCase as c}from"../../../../src/di.stub";import{commandModuleFactory as d}from"./commandModule";import{commandTypes as m}from"./commandTypes";describe("commandModuleFactory",()=>{describe("Default",()=>{let e,o;beforeEach(()=>{o=d(),e=new n,e.loadSync(o,a(),s())}),it("should return the config module",()=>{expect(o).toBeDefined()}),it("should return non-stubbed sendCommand usecase",()=>{const t=e.get(m.SendCommandUseCase);expect(t).toBeInstanceOf(r)})}),describe("Stubbed",()=>{let e,o;beforeEach(()=>{o=d({stub:!0}),e=new n,e.loadSync(o)}),it("should return the config module",()=>{expect(o).toBeDefined()}),it("should return stubbed sendCommand usecase",()=>{const t=e.get(m.SendCommandUseCase);expect(t).toBeInstanceOf(c)})})});
|
2
2
|
//# sourceMappingURL=commandModule.test.js.map
|
@@ -1,7 +1,7 @@
|
|
1
1
|
{
|
2
2
|
"version": 3,
|
3
3
|
"sources": ["../../../../../../src/api/command/di/commandModule.test.ts"],
|
4
|
-
"sourcesContent": ["import { Container } from \"inversify\";\n\nimport { SendCommandUseCase } from \"@api/command/use-case/SendCommandUseCase\";\nimport { deviceSessionModuleFactory } from \"@internal/device-session/di/deviceSessionModule\";\nimport { loggerModuleFactory } from \"@internal/logger-publisher/di/loggerModule\";\nimport { StubUseCase } from \"@root/src/di.stub\";\n\nimport { commandModuleFactory } from \"./commandModule\";\nimport { commandTypes } from \"./commandTypes\";\n\ndescribe(\"commandModuleFactory\", () => {\n describe(\"Default\", () => {\n let container: Container;\n let mod: ReturnType<typeof commandModuleFactory>;\n beforeEach(() => {\n mod = commandModuleFactory();\n container = new Container();\n container.
|
5
|
-
"mappings": "AAAA,OAAS,aAAAA,MAAiB,YAE1B,OAAS,sBAAAC,MAA0B,2CACnC,OAAS,8BAAAC,MAAkC,kDAC3C,OAAS,uBAAAC,MAA2B,6CACpC,OAAS,eAAAC,MAAmB,oBAE5B,OAAS,wBAAAC,MAA4B,kBACrC,OAAS,gBAAAC,MAAoB,iBAE7B,SAAS,uBAAwB,IAAM,CACrC,SAAS,UAAW,IAAM,CACxB,IAAIC,EACAC,EACJ,WAAW,IAAM,CACfA,EAAMH,EAAqB,EAC3BE,EAAY,IAAIP,EAChBO,EAAU,
|
4
|
+
"sourcesContent": ["import { Container } from \"inversify\";\n\nimport { SendCommandUseCase } from \"@api/command/use-case/SendCommandUseCase\";\nimport { deviceSessionModuleFactory } from \"@internal/device-session/di/deviceSessionModule\";\nimport { loggerModuleFactory } from \"@internal/logger-publisher/di/loggerModule\";\nimport { StubUseCase } from \"@root/src/di.stub\";\n\nimport { commandModuleFactory } from \"./commandModule\";\nimport { commandTypes } from \"./commandTypes\";\n\ndescribe(\"commandModuleFactory\", () => {\n describe(\"Default\", () => {\n let container: Container;\n let mod: ReturnType<typeof commandModuleFactory>;\n beforeEach(() => {\n mod = commandModuleFactory();\n container = new Container();\n container.loadSync(\n mod,\n deviceSessionModuleFactory(),\n loggerModuleFactory(),\n );\n });\n\n it(\"should return the config module\", () => {\n expect(mod).toBeDefined();\n });\n\n it(\"should return non-stubbed sendCommand usecase\", () => {\n const sendCommandUseCase = container.get<SendCommandUseCase>(\n commandTypes.SendCommandUseCase,\n );\n expect(sendCommandUseCase).toBeInstanceOf(SendCommandUseCase);\n });\n });\n\n describe(\"Stubbed\", () => {\n let container: Container;\n let mod: ReturnType<typeof commandModuleFactory>;\n beforeEach(() => {\n mod = commandModuleFactory({ stub: true });\n container = new Container();\n container.loadSync(mod);\n });\n\n it(\"should return the config module\", () => {\n expect(mod).toBeDefined();\n });\n\n it(\"should return stubbed sendCommand usecase\", () => {\n const sendCommandUseCase = container.get(commandTypes.SendCommandUseCase);\n expect(sendCommandUseCase).toBeInstanceOf(StubUseCase);\n });\n });\n});\n"],
|
5
|
+
"mappings": "AAAA,OAAS,aAAAA,MAAiB,YAE1B,OAAS,sBAAAC,MAA0B,2CACnC,OAAS,8BAAAC,MAAkC,kDAC3C,OAAS,uBAAAC,MAA2B,6CACpC,OAAS,eAAAC,MAAmB,oBAE5B,OAAS,wBAAAC,MAA4B,kBACrC,OAAS,gBAAAC,MAAoB,iBAE7B,SAAS,uBAAwB,IAAM,CACrC,SAAS,UAAW,IAAM,CACxB,IAAIC,EACAC,EACJ,WAAW,IAAM,CACfA,EAAMH,EAAqB,EAC3BE,EAAY,IAAIP,EAChBO,EAAU,SACRC,EACAN,EAA2B,EAC3BC,EAAoB,CACtB,CACF,CAAC,EAED,GAAG,kCAAmC,IAAM,CAC1C,OAAOK,CAAG,EAAE,YAAY,CAC1B,CAAC,EAED,GAAG,gDAAiD,IAAM,CACxD,MAAMC,EAAqBF,EAAU,IACnCD,EAAa,kBACf,EACA,OAAOG,CAAkB,EAAE,eAAeR,CAAkB,CAC9D,CAAC,CACH,CAAC,EAED,SAAS,UAAW,IAAM,CACxB,IAAIM,EACAC,EACJ,WAAW,IAAM,CACfA,EAAMH,EAAqB,CAAE,KAAM,EAAK,CAAC,EACzCE,EAAY,IAAIP,EAChBO,EAAU,SAASC,CAAG,CACxB,CAAC,EAED,GAAG,kCAAmC,IAAM,CAC1C,OAAOA,CAAG,EAAE,YAAY,CAC1B,CAAC,EAED,GAAG,4CAA6C,IAAM,CACpD,MAAMC,EAAqBF,EAAU,IAAID,EAAa,kBAAkB,EACxE,OAAOG,CAAkB,EAAE,eAAeL,CAAW,CACvD,CAAC,CACH,CAAC,CACH,CAAC",
|
6
6
|
"names": ["Container", "SendCommandUseCase", "deviceSessionModuleFactory", "loggerModuleFactory", "StubUseCase", "commandModuleFactory", "commandTypes", "container", "mod", "sendCommandUseCase"]
|
7
7
|
}
|
@@ -1,2 +1,2 @@
|
|
1
|
-
import{DeviceModelId as e}from"../../../device/DeviceModel";const o=(r=e.NANO_SP,s={})=>({[e.NANO_SP]:{isBootloader:!1,isOsu:!1,targetId:856686596,seTargetId:856686596,seVersion:"1.1.1",seFlags:new Uint8Array([230,0,0,0]),mcuTargetId:void 0,mcuSephVersion:"4.03",mcuBootloaderVersion:"3.12",hwVersion:"00",langId:0,recoverState:void 0,secureElementFlags:{isPinValidated:!0,hasMcuSerialNumber:!0,hasValidCertificate:!0,isCustomAuthorityConnectionAllowed:!1,isSecureConnectionAllowed:!1,isOnboarded:!0,isMcuCodeSigned:!0,isInRecoveryMode:!1},...s},[e.NANO_S]:{isBootloader:!1,isOsu:!1,targetId:858783748,seTargetId:858783748,seVersion:"1.1.1",seFlags:new Uint8Array([230,0,0,0]),mcuTargetId:void 0,mcuSephVersion:"6.4.0",mcuBootloaderVersion:"5.4.0",hwVersion:"00",langId:0,recoverState:void 0,secureElementFlags:{isPinValidated:!0,hasMcuSerialNumber:!0,hasValidCertificate:!0,isCustomAuthorityConnectionAllowed:!1,isSecureConnectionAllowed:!1,isOnboarded:!0,isMcuCodeSigned:!0,isInRecoveryMode:!1},...s},[e.NANO_X]:{isBootloader:!1,isOsu:!1,targetId:855638020,seTargetId:855638020,seVersion:"2.2.3",seFlags:new Uint8Array([230,0,0,0]),mcuTargetId:void 0,mcuSephVersion:"2.30",mcuBootloaderVersion:"1.16",hwVersion:"00",langId:0,recoverState:0,secureElementFlags:{isPinValidated:!0,hasMcuSerialNumber:!0,hasValidCertificate:!0,isCustomAuthorityConnectionAllowed:!1,isSecureConnectionAllowed:!1,isOnboarded:!0,isMcuCodeSigned:!0,isInRecoveryMode:!1}},[e.STAX]:{isBootloader:!1,isOsu:!1,targetId:857735172,seTargetId:857735172,seVersion:"1.3.0",seFlags:new Uint8Array([230,0,0,0]),mcuTargetId:void 0,mcuSephVersion:"5.24",mcuBootloaderVersion:"0.48",hwVersion:"00",langId:0,recoverState:void 0,secureElementFlags:{isPinValidated:!0,hasMcuSerialNumber:!0,hasValidCertificate:!0,isCustomAuthorityConnectionAllowed:!1,isSecureConnectionAllowed:!1,isOnboarded:!0,isMcuCodeSigned:!0,isInRecoveryMode:!1},...s},[e.FLEX]:{isBootloader:!1,isOsu:!1,targetId:858783748,seTargetId:858783748,seVersion:"1.1.1",seFlags:new Uint8Array([230,0,0,0]),mcuTargetId:void 0,mcuSephVersion:"6.4.0",mcuBootloaderVersion:"5.4.0",hwVersion:"00",langId:0,recoverState:0,secureElementFlags:{isPinValidated:!0,hasMcuSerialNumber:!0,hasValidCertificate:!0,isCustomAuthorityConnectionAllowed:!1,isSecureConnectionAllowed:!1,isOnboarded:!0,isMcuCodeSigned:!0,isInRecoveryMode:!1},...s}})[r];export{o as getOsVersionCommandResponseMockBuilder};
|
1
|
+
import{DeviceModelId as e}from"../../../device/DeviceModel";const o=(r=e.NANO_SP,s={})=>({[e.NANO_SP]:{isBootloader:!1,isOsu:!1,targetId:856686596,seTargetId:856686596,seVersion:"1.1.1",seFlags:new Uint8Array([230,0,0,0]),mcuTargetId:void 0,mcuSephVersion:"4.03",mcuBootloaderVersion:"3.12",hwVersion:"00",langId:0,recoverState:void 0,secureElementFlags:{isPinValidated:!0,hasMcuSerialNumber:!0,hasValidCertificate:!0,isCustomAuthorityConnectionAllowed:!1,isSecureConnectionAllowed:!1,isOnboarded:!0,isMcuCodeSigned:!0,isInRecoveryMode:!1},...s},[e.NANO_S]:{isBootloader:!1,isOsu:!1,targetId:858783748,seTargetId:858783748,seVersion:"1.1.1",seFlags:new Uint8Array([230,0,0,0]),mcuTargetId:void 0,mcuSephVersion:"6.4.0",mcuBootloaderVersion:"5.4.0",hwVersion:"00",langId:0,recoverState:void 0,secureElementFlags:{isPinValidated:!0,hasMcuSerialNumber:!0,hasValidCertificate:!0,isCustomAuthorityConnectionAllowed:!1,isSecureConnectionAllowed:!1,isOnboarded:!0,isMcuCodeSigned:!0,isInRecoveryMode:!1},...s},[e.NANO_X]:{isBootloader:!1,isOsu:!1,targetId:855638020,seTargetId:855638020,seVersion:"2.2.3",seFlags:new Uint8Array([230,0,0,0]),mcuTargetId:void 0,mcuSephVersion:"2.30",mcuBootloaderVersion:"1.16",hwVersion:"00",langId:0,recoverState:0,secureElementFlags:{isPinValidated:!0,hasMcuSerialNumber:!0,hasValidCertificate:!0,isCustomAuthorityConnectionAllowed:!1,isSecureConnectionAllowed:!1,isOnboarded:!0,isMcuCodeSigned:!0,isInRecoveryMode:!1}},[e.STAX]:{isBootloader:!1,isOsu:!1,targetId:857735172,seTargetId:857735172,seVersion:"1.3.0",seFlags:new Uint8Array([230,0,0,0]),mcuTargetId:void 0,mcuSephVersion:"5.24",mcuBootloaderVersion:"0.48",hwVersion:"00",langId:0,recoverState:void 0,secureElementFlags:{isPinValidated:!0,hasMcuSerialNumber:!0,hasValidCertificate:!0,isCustomAuthorityConnectionAllowed:!1,isSecureConnectionAllowed:!1,isOnboarded:!0,isMcuCodeSigned:!0,isInRecoveryMode:!1},...s},[e.FLEX]:{isBootloader:!1,isOsu:!1,targetId:858783748,seTargetId:858783748,seVersion:"1.1.1",seFlags:new Uint8Array([230,0,0,0]),mcuTargetId:void 0,mcuSephVersion:"6.4.0",mcuBootloaderVersion:"5.4.0",hwVersion:"00",langId:0,recoverState:0,secureElementFlags:{isPinValidated:!0,hasMcuSerialNumber:!0,hasValidCertificate:!0,isCustomAuthorityConnectionAllowed:!1,isSecureConnectionAllowed:!1,isOnboarded:!0,isMcuCodeSigned:!0,isInRecoveryMode:!1},...s},[e.APEX]:{isBootloader:!1,isOsu:!1,targetId:858783748,seTargetId:858783748,seVersion:"1.1.1",seFlags:new Uint8Array([230,0,0,0]),mcuTargetId:void 0,mcuSephVersion:"6.4.0",mcuBootloaderVersion:"5.4.0",hwVersion:"00",langId:0,recoverState:0,secureElementFlags:{isPinValidated:!0,hasMcuSerialNumber:!0,hasValidCertificate:!0,isCustomAuthorityConnectionAllowed:!1,isSecureConnectionAllowed:!1,isOnboarded:!0,isMcuCodeSigned:!0,isInRecoveryMode:!1}}})[r];export{o as getOsVersionCommandResponseMockBuilder};
|
2
2
|
//# sourceMappingURL=GetOsVersionCommand.js.map
|
@@ -1,7 +1,7 @@
|
|
1
1
|
{
|
2
2
|
"version": 3,
|
3
3
|
"sources": ["../../../../../../../src/api/command/os/__mocks__/GetOsVersionCommand.ts"],
|
4
|
-
"sourcesContent": ["import { type GetOsVersionResponse } from \"@api/command/os/GetOsVersionCommand\";\nimport { DeviceModelId } from \"@api/device/DeviceModel\";\n\nexport const getOsVersionCommandResponseMockBuilder = (\n deviceModelId: DeviceModelId = DeviceModelId.NANO_SP,\n props: Partial<GetOsVersionResponse> = {},\n): GetOsVersionResponse =>\n ({\n [DeviceModelId.NANO_SP]: {\n isBootloader: false,\n isOsu: false,\n targetId: 856686596,\n seTargetId: 856686596,\n seVersion: \"1.1.1\",\n seFlags: new Uint8Array([0xe6, 0x00, 0x00, 0x00]),\n mcuTargetId: undefined,\n mcuSephVersion: \"4.03\",\n mcuBootloaderVersion: \"3.12\",\n hwVersion: \"00\",\n langId: 0,\n recoverState: undefined,\n secureElementFlags: {\n isPinValidated: true,\n hasMcuSerialNumber: true,\n hasValidCertificate: true,\n isCustomAuthorityConnectionAllowed: false,\n isSecureConnectionAllowed: false,\n isOnboarded: true,\n isMcuCodeSigned: true,\n isInRecoveryMode: false,\n },\n ...props,\n },\n [DeviceModelId.NANO_S]: {\n isBootloader: false,\n isOsu: false,\n targetId: 858783748,\n seTargetId: 858783748,\n seVersion: \"1.1.1\",\n seFlags: new Uint8Array([0xe6, 0x00, 0x00, 0x00]),\n mcuTargetId: undefined,\n mcuSephVersion: \"6.4.0\",\n mcuBootloaderVersion: \"5.4.0\",\n hwVersion: \"00\",\n langId: 0,\n recoverState: undefined,\n secureElementFlags: {\n isPinValidated: true,\n hasMcuSerialNumber: true,\n hasValidCertificate: true,\n isCustomAuthorityConnectionAllowed: false,\n isSecureConnectionAllowed: false,\n isOnboarded: true,\n isMcuCodeSigned: true,\n isInRecoveryMode: false,\n },\n ...props,\n },\n [DeviceModelId.NANO_X]: {\n isBootloader: false,\n isOsu: false,\n targetId: 855638020,\n seTargetId: 855638020,\n seVersion: \"2.2.3\",\n seFlags: new Uint8Array([0xe6, 0x00, 0x00, 0x00]),\n mcuTargetId: undefined,\n mcuSephVersion: \"2.30\",\n mcuBootloaderVersion: \"1.16\",\n hwVersion: \"00\",\n langId: 0,\n recoverState: 0,\n secureElementFlags: {\n isPinValidated: true,\n hasMcuSerialNumber: true,\n hasValidCertificate: true,\n isCustomAuthorityConnectionAllowed: false,\n isSecureConnectionAllowed: false,\n isOnboarded: true,\n isMcuCodeSigned: true,\n isInRecoveryMode: false,\n },\n },\n [DeviceModelId.STAX]: {\n isBootloader: false,\n isOsu: false,\n targetId: 857735172,\n seTargetId: 857735172,\n seVersion: \"1.3.0\",\n seFlags: new Uint8Array([0xe6, 0x00, 0x00, 0x00]),\n mcuTargetId: undefined,\n mcuSephVersion: \"5.24\",\n mcuBootloaderVersion: \"0.48\",\n hwVersion: \"00\",\n langId: 0,\n recoverState: undefined,\n secureElementFlags: {\n isPinValidated: true,\n hasMcuSerialNumber: true,\n hasValidCertificate: true,\n isCustomAuthorityConnectionAllowed: false,\n isSecureConnectionAllowed: false,\n isOnboarded: true,\n isMcuCodeSigned: true,\n isInRecoveryMode: false,\n },\n ...props,\n },\n [DeviceModelId.FLEX]: {\n isBootloader: false,\n isOsu: false,\n targetId: 858783748,\n seTargetId: 858783748,\n seVersion: \"1.1.1\",\n seFlags: new Uint8Array([0xe6, 0x00, 0x00, 0x00]),\n mcuTargetId: undefined,\n mcuSephVersion: \"6.4.0\",\n mcuBootloaderVersion: \"5.4.0\",\n hwVersion: \"00\",\n langId: 0,\n recoverState: 0,\n secureElementFlags: {\n isPinValidated: true,\n hasMcuSerialNumber: true,\n hasValidCertificate: true,\n isCustomAuthorityConnectionAllowed: false,\n isSecureConnectionAllowed: false,\n isOnboarded: true,\n isMcuCodeSigned: true,\n isInRecoveryMode: false,\n },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EACA,CAACA,EAAc,IAAI,EAAG,CACpB,aAAc,GACd,MAAO,GACP,SAAU,UACV,WAAY,UACZ,UAAW,QACX,QAAS,IAAI,WAAW,CAAC,IAAM,EAAM,EAAM,CAAI,CAAC,EAChD,YAAa,OACb,eAAgB,OAChB,qBAAsB,OACtB,UAAW,KACX,OAAQ,EACR,aAAc,OACd,mBAAoB,CAClB,eAAgB,GAChB,mBAAoB,GACpB,oBAAqB,GACrB,mCAAoC,GACpC,0BAA2B,GAC3B,YAAa,GACb,gBAAiB,GACjB,iBAAkB,EACpB,EACA,GAAGG,CACL,EACA,CAACH,EAAc,IAAI,EAAG,CACpB,aAAc,GACd,MAAO,GACP,SAAU,UACV,WAAY,UACZ,UAAW,QACX,QAAS,IAAI,WAAW,CAAC,IAAM,EAAM,EAAM,CAAI,CAAC,EAChD,YAAa,OACb,eAAgB,QAChB,qBAAsB,QACtB,UAAW,KACX,OAAQ,EACR,aAAc,EACd,mBAAoB,CAClB,eAAgB,GAChB,mBAAoB,GACpB,oBAAqB,GACrB,mCAAoC,GACpC,0BAA2B,GAC3B,YAAa,GACb,gBAAiB,GACjB,iBAAkB,EACpB,EACA,GAAGG,CACL,CACF,
|
4
|
+
"sourcesContent": ["import { type GetOsVersionResponse } from \"@api/command/os/GetOsVersionCommand\";\nimport { DeviceModelId } from \"@api/device/DeviceModel\";\n\nexport const getOsVersionCommandResponseMockBuilder = (\n deviceModelId: DeviceModelId = DeviceModelId.NANO_SP,\n props: Partial<GetOsVersionResponse> = {},\n): GetOsVersionResponse =>\n ({\n [DeviceModelId.NANO_SP]: {\n isBootloader: false,\n isOsu: false,\n targetId: 856686596,\n seTargetId: 856686596,\n seVersion: \"1.1.1\",\n seFlags: new Uint8Array([0xe6, 0x00, 0x00, 0x00]),\n mcuTargetId: undefined,\n mcuSephVersion: \"4.03\",\n mcuBootloaderVersion: \"3.12\",\n hwVersion: \"00\",\n langId: 0,\n recoverState: undefined,\n secureElementFlags: {\n isPinValidated: true,\n hasMcuSerialNumber: true,\n hasValidCertificate: true,\n isCustomAuthorityConnectionAllowed: false,\n isSecureConnectionAllowed: false,\n isOnboarded: true,\n isMcuCodeSigned: true,\n isInRecoveryMode: false,\n },\n ...props,\n },\n [DeviceModelId.NANO_S]: {\n isBootloader: false,\n isOsu: false,\n targetId: 858783748,\n seTargetId: 858783748,\n seVersion: \"1.1.1\",\n seFlags: new Uint8Array([0xe6, 0x00, 0x00, 0x00]),\n mcuTargetId: undefined,\n mcuSephVersion: \"6.4.0\",\n mcuBootloaderVersion: \"5.4.0\",\n hwVersion: \"00\",\n langId: 0,\n recoverState: undefined,\n secureElementFlags: {\n isPinValidated: true,\n hasMcuSerialNumber: true,\n hasValidCertificate: true,\n isCustomAuthorityConnectionAllowed: false,\n isSecureConnectionAllowed: false,\n isOnboarded: true,\n isMcuCodeSigned: true,\n isInRecoveryMode: false,\n },\n ...props,\n },\n [DeviceModelId.NANO_X]: {\n isBootloader: false,\n isOsu: false,\n targetId: 855638020,\n seTargetId: 855638020,\n seVersion: \"2.2.3\",\n seFlags: new Uint8Array([0xe6, 0x00, 0x00, 0x00]),\n mcuTargetId: undefined,\n mcuSephVersion: \"2.30\",\n mcuBootloaderVersion: \"1.16\",\n hwVersion: \"00\",\n langId: 0,\n recoverState: 0,\n secureElementFlags: {\n isPinValidated: true,\n hasMcuSerialNumber: true,\n hasValidCertificate: true,\n isCustomAuthorityConnectionAllowed: false,\n isSecureConnectionAllowed: false,\n isOnboarded: true,\n isMcuCodeSigned: true,\n isInRecoveryMode: false,\n },\n },\n [DeviceModelId.STAX]: {\n isBootloader: false,\n isOsu: false,\n targetId: 857735172,\n seTargetId: 857735172,\n seVersion: \"1.3.0\",\n seFlags: new Uint8Array([0xe6, 0x00, 0x00, 0x00]),\n mcuTargetId: undefined,\n mcuSephVersion: \"5.24\",\n mcuBootloaderVersion: \"0.48\",\n hwVersion: \"00\",\n langId: 0,\n recoverState: undefined,\n secureElementFlags: {\n isPinValidated: true,\n hasMcuSerialNumber: true,\n hasValidCertificate: true,\n isCustomAuthorityConnectionAllowed: false,\n isSecureConnectionAllowed: false,\n isOnboarded: true,\n isMcuCodeSigned: true,\n isInRecoveryMode: false,\n },\n ...props,\n },\n [DeviceModelId.FLEX]: {\n isBootloader: false,\n isOsu: false,\n targetId: 858783748,\n seTargetId: 858783748,\n seVersion: \"1.1.1\",\n seFlags: new Uint8Array([0xe6, 0x00, 0x00, 0x00]),\n mcuTargetId: undefined,\n mcuSephVersion: \"6.4.0\",\n mcuBootloaderVersion: \"5.4.0\",\n hwVersion: \"00\",\n langId: 0,\n recoverState: 0,\n secureElementFlags: {\n isPinValidated: true,\n hasMcuSerialNumber: true,\n hasValidCertificate: true,\n isCustomAuthorityConnectionAllowed: false,\n isSecureConnectionAllowed: false,\n isOnboarded: true,\n isMcuCodeSigned: true,\n isInRecoveryMode: false,\n },\n ...props,\n },\n [DeviceModelId.APEX]: {\n isBootloader: false,\n isOsu: false,\n targetId: 858783748,\n seTargetId: 858783748,\n seVersion: \"1.1.1\",\n seFlags: new Uint8Array([0xe6, 0x00, 0x00, 0x00]),\n mcuTargetId: undefined,\n mcuSephVersion: \"6.4.0\",\n mcuBootloaderVersion: \"5.4.0\",\n hwVersion: \"00\",\n langId: 0,\n recoverState: 0,\n secureElementFlags: {\n isPinValidated: true,\n hasMcuSerialNumber: true,\n hasValidCertificate: true,\n isCustomAuthorityConnectionAllowed: false,\n isSecureConnectionAllowed: false,\n isOnboarded: true,\n isMcuCodeSigned: true,\n isInRecoveryMode: false,\n },\n },\n })[deviceModelId];\n"],
|
5
|
+
"mappings": "AACA,OAAS,iBAAAA,MAAqB,0BAEvB,MAAMC,EAAyC,CACpDC,EAA+BF,EAAc,QAC7CG,EAAuC,CAAC,KAEvC,CACC,CAACH,EAAc,OAAO,EAAG,CACvB,aAAc,GACd,MAAO,GACP,SAAU,UACV,WAAY,UACZ,UAAW,QACX,QAAS,IAAI,WAAW,CAAC,IAAM,EAAM,EAAM,CAAI,CAAC,EAChD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AA2B,GAC3B,YAAa,GACb,gBAAiB,GACjB,iBAAkB,EACpB,EACA,GAAGG,CACL,EACA,CAACH,EAAc,IAAI,EAAG,CACpB,aAAc,GACd,MAAO,GACP,SAAU,UACV,WAAY,UACZ,UAAW,QACX,QAAS,IAAI,WAAW,CAAC,IAAM,EAAM,EAAM,CAAI,CAAC,EAChD,YAAa,OACb,eAAgB,QAChB,qBAAsB,QACtB,UAAW,KACX,OAAQ,EACR,aAAc,EACd,mBAAoB,CAClB,eAAgB,GAChB,mBAAoB,GACpB,oBAAqB,GACrB,mCAAoC,GACpC,0BAA2B,GAC3B,YAAa,GACb,gBAAiB,GACjB,iBAAkB,EACpB,EACA,GAAGG,CACL,EACA,CAACH,EAAc,IAAI,EAAG,CACpB,aAAc,GACd,MAAO,GACP,SAAU,UACV,WAAY,UACZ,UAAW,QACX,QAAS,IAAI,WAAW,CAAC,IAAM,EAAM,EAAM,CAAI,CAAC,EAChD,YAAa,OACb,eAAgB,QAChB,qBAAsB,QACtB,UAAW,KACX,OAAQ,EACR,aAAc,EACd,mBAAoB,CAClB,eAAgB,GAChB,mBAAoB,GACpB,oBAAqB,GACrB,mCAAoC,GACpC,0BAA2B,GAC3B,YAAa,GACb,gBAAiB,GACjB,iBAAkB,EACpB,CACF,CACF,GAAGE,CAAa",
|
6
6
|
"names": ["DeviceModelId", "getOsVersionCommandResponseMockBuilder", "deviceModelId", "props"]
|
7
7
|
}
|
@@ -1,2 +1,2 @@
|
|
1
|
-
var t=(e=>(e.NANO_S="nanoS",e.NANO_SP="nanoSP",e.NANO_X="nanoX",e.STAX="stax",e.FLEX="flex",e))(t||{});class
|
1
|
+
var t=(e=>(e.NANO_S="nanoS",e.NANO_SP="nanoSP",e.NANO_X="nanoX",e.STAX="stax",e.FLEX="flex",e.APEX="apex",e))(t||{});class i{id;model;name;constructor({id:n,model:o,name:r}){this.id=n,this.model=o,this.name=r}}const l=11415;export{i as DeviceModel,t as DeviceModelId,l as LEDGER_VENDOR_ID};
|
2
2
|
//# sourceMappingURL=DeviceModel.js.map
|
@@ -1,7 +1,7 @@
|
|
1
1
|
{
|
2
2
|
"version": 3,
|
3
3
|
"sources": ["../../../../../src/api/device/DeviceModel.ts"],
|
4
|
-
"sourcesContent": ["export enum DeviceModelId {\n NANO_S = \"nanoS\",\n NANO_SP = \"nanoSP\",\n NANO_X = \"nanoX\",\n STAX = \"stax\",\n FLEX = \"flex\",\n}\n\n/**\n * Unique identifier for a device.\n *\n * NB: This identifier is generated at runtime and is not persisted. It cannot\n * be used to identify a device across sessions.\n * There is in fact no way to identify a device across sessions, which is a\n * privacy feature of Ledger devices.\n */\nexport type DeviceId = string;\n\nexport type DeviceModelArgs = {\n readonly id: DeviceId;\n readonly model: DeviceModelId;\n readonly name: string;\n};\n\nexport class DeviceModel {\n public readonly id: DeviceId;\n public readonly model: DeviceModelId;\n public readonly name: string;\n\n constructor({ id, model, name }: DeviceModelArgs) {\n this.id = id;\n this.model = model;\n this.name = name;\n }\n}\n\nexport const LEDGER_VENDOR_ID = 0x2c97;\n"],
|
5
|
-
"mappings": "AAAO,IAAKA,OACVA,EAAA,OAAS,QACTA,EAAA,QAAU,SACVA,EAAA,OAAS,QACTA,EAAA,KAAO,OACPA,EAAA,KAAO,
|
4
|
+
"sourcesContent": ["export enum DeviceModelId {\n NANO_S = \"nanoS\",\n NANO_SP = \"nanoSP\",\n NANO_X = \"nanoX\",\n STAX = \"stax\",\n FLEX = \"flex\",\n APEX = \"apex\",\n}\n\n/**\n * Unique identifier for a device.\n *\n * NB: This identifier is generated at runtime and is not persisted. It cannot\n * be used to identify a device across sessions.\n * There is in fact no way to identify a device across sessions, which is a\n * privacy feature of Ledger devices.\n */\nexport type DeviceId = string;\n\nexport type DeviceModelArgs = {\n readonly id: DeviceId;\n readonly model: DeviceModelId;\n readonly name: string;\n};\n\nexport class DeviceModel {\n public readonly id: DeviceId;\n public readonly model: DeviceModelId;\n public readonly name: string;\n\n constructor({ id, model, name }: DeviceModelArgs) {\n this.id = id;\n this.model = model;\n this.name = name;\n }\n}\n\nexport const LEDGER_VENDOR_ID = 0x2c97;\n"],
|
5
|
+
"mappings": "AAAO,IAAKA,OACVA,EAAA,OAAS,QACTA,EAAA,QAAU,SACVA,EAAA,OAAS,QACTA,EAAA,KAAO,OACPA,EAAA,KAAO,OACPA,EAAA,KAAO,OANGA,OAAA,IAyBL,MAAMC,CAAY,CACP,GACA,MACA,KAEhB,YAAY,CAAE,GAAAC,EAAI,MAAAC,EAAO,KAAAC,CAAK,EAAoB,CAChD,KAAK,GAAKF,EACV,KAAK,MAAQC,EACb,KAAK,KAAOC,CACd,CACF,CAEO,MAAMC,EAAmB",
|
6
6
|
"names": ["DeviceModelId", "DeviceModel", "id", "model", "name", "LEDGER_VENDOR_ID"]
|
7
7
|
}
|
@@ -1,2 +1,2 @@
|
|
1
|
-
import{ContainerModule as
|
1
|
+
import{ContainerModule as c}from"inversify";import{ExecuteDeviceActionUseCase as r}from"../../device-action/use-case/ExecuteDeviceActionUseCase";import{StubUseCase as s}from"../../../../src/di.stub";import{deviceActionTypes as e}from"./deviceActionTypes";const l=({stub:o=!1}={})=>new c(({bind:t,rebindSync:i})=>{t(e.ExecuteDeviceActionUseCase).to(r),o&&i(e.ExecuteDeviceActionUseCase).to(s)});export{l as deviceActionModuleFactory};
|
2
2
|
//# sourceMappingURL=deviceActionModule.js.map
|
@@ -1,7 +1,7 @@
|
|
1
1
|
{
|
2
2
|
"version": 3,
|
3
3
|
"sources": ["../../../../../../src/api/device-action/di/deviceActionModule.ts"],
|
4
|
-
"sourcesContent": ["import { ContainerModule } from \"inversify\";\n\nimport { ExecuteDeviceActionUseCase } from \"@api/device-action/use-case/ExecuteDeviceActionUseCase\";\nimport { StubUseCase } from \"@root/src/di.stub\";\n\nimport { deviceActionTypes } from \"./deviceActionTypes\";\n\ntype DeviceActionModuleArgs = Partial<{\n readonly stub: boolean;\n}>;\n\nexport const deviceActionModuleFactory = ({\n stub = false,\n}: DeviceActionModuleArgs = {}) =>\n new ContainerModule(
|
5
|
-
"mappings": "AAAA,OAAS,mBAAAA,MAAuB,YAEhC,OAAS,8BAAAC,MAAkC,yDAC3C,OAAS,eAAAC,MAAmB,oBAE5B,OAAS,qBAAAC,MAAyB,sBAM3B,MAAMC,EAA4B,CAAC,CACxC,KAAAC,EAAO,EACT,EAA4B,CAAC,IAC3B,IAAIL,
|
6
|
-
"names": ["ContainerModule", "ExecuteDeviceActionUseCase", "StubUseCase", "deviceActionTypes", "deviceActionModuleFactory", "stub", "bind", "
|
4
|
+
"sourcesContent": ["import { ContainerModule } from \"inversify\";\n\nimport { ExecuteDeviceActionUseCase } from \"@api/device-action/use-case/ExecuteDeviceActionUseCase\";\nimport { StubUseCase } from \"@root/src/di.stub\";\n\nimport { deviceActionTypes } from \"./deviceActionTypes\";\n\ntype DeviceActionModuleArgs = Partial<{\n readonly stub: boolean;\n}>;\n\nexport const deviceActionModuleFactory = ({\n stub = false,\n}: DeviceActionModuleArgs = {}) =>\n new ContainerModule(({ bind, rebindSync }) => {\n bind(deviceActionTypes.ExecuteDeviceActionUseCase).to(\n ExecuteDeviceActionUseCase,\n );\n if (stub) {\n rebindSync(deviceActionTypes.ExecuteDeviceActionUseCase).to(StubUseCase);\n }\n });\n"],
|
5
|
+
"mappings": "AAAA,OAAS,mBAAAA,MAAuB,YAEhC,OAAS,8BAAAC,MAAkC,yDAC3C,OAAS,eAAAC,MAAmB,oBAE5B,OAAS,qBAAAC,MAAyB,sBAM3B,MAAMC,EAA4B,CAAC,CACxC,KAAAC,EAAO,EACT,EAA4B,CAAC,IAC3B,IAAIL,EAAgB,CAAC,CAAE,KAAAM,EAAM,WAAAC,CAAW,IAAM,CAC5CD,EAAKH,EAAkB,0BAA0B,EAAE,GACjDF,CACF,EACII,GACFE,EAAWJ,EAAkB,0BAA0B,EAAE,GAAGD,CAAW,CAE3E,CAAC",
|
6
|
+
"names": ["ContainerModule", "ExecuteDeviceActionUseCase", "StubUseCase", "deviceActionTypes", "deviceActionModuleFactory", "stub", "bind", "rebindSync"]
|
7
7
|
}
|
@@ -1,2 +1,2 @@
|
|
1
|
-
import{Container as c}from"inversify";import{ExecuteDeviceActionUseCase as r}from"../../device-action/use-case/ExecuteDeviceActionUseCase";import{deviceSessionModuleFactory as s}from"../../../internal/device-session/di/deviceSessionModule";import{loggerModuleFactory as u}from"../../../internal/logger-publisher/di/loggerModule";import{StubUseCase as d}from"../../../../src/di.stub";import{deviceActionModuleFactory as i}from"./deviceActionModule";import{deviceActionTypes as n}from"./deviceActionTypes";describe("deviceActionModule",()=>{describe("Default",()=>{let e,t;beforeEach(()=>{t=i(),e=new c,e.
|
1
|
+
import{Container as c}from"inversify";import{ExecuteDeviceActionUseCase as r}from"../../device-action/use-case/ExecuteDeviceActionUseCase";import{deviceSessionModuleFactory as s}from"../../../internal/device-session/di/deviceSessionModule";import{loggerModuleFactory as u}from"../../../internal/logger-publisher/di/loggerModule";import{StubUseCase as d}from"../../../../src/di.stub";import{deviceActionModuleFactory as i}from"./deviceActionModule";import{deviceActionTypes as n}from"./deviceActionTypes";describe("deviceActionModule",()=>{describe("Default",()=>{let e,t;beforeEach(()=>{t=i(),e=new c,e.loadSync(t,s(),u())}),it("should return the config module",()=>{expect(t).toBeDefined()}),it("should return non-stubbed executeDeviceAction usecase",()=>{const o=e.get(n.ExecuteDeviceActionUseCase);expect(o).toBeInstanceOf(r)})}),describe("Stubbed",()=>{let e,t;beforeEach(()=>{t=i({stub:!0}),e=new c,e.loadSync(t)}),it("should return the config module",()=>{expect(t).toBeDefined()}),it("should return stubbed executeDeviceAction usecase",()=>{const o=e.get(n.ExecuteDeviceActionUseCase);expect(o).toBeInstanceOf(d)})})});
|
2
2
|
//# sourceMappingURL=deviceActionModule.test.js.map
|
@@ -1,7 +1,7 @@
|
|
1
1
|
{
|
2
2
|
"version": 3,
|
3
3
|
"sources": ["../../../../../../src/api/device-action/di/deviceActionModule.test.ts"],
|
4
|
-
"sourcesContent": ["import { Container } from \"inversify\";\n\nimport { ExecuteDeviceActionUseCase } from \"@api/device-action/use-case/ExecuteDeviceActionUseCase\";\nimport { deviceSessionModuleFactory } from \"@internal/device-session/di/deviceSessionModule\";\nimport { loggerModuleFactory } from \"@internal/logger-publisher/di/loggerModule\";\nimport { StubUseCase } from \"@root/src/di.stub\";\n\nimport { deviceActionModuleFactory } from \"./deviceActionModule\";\nimport { deviceActionTypes } from \"./deviceActionTypes\";\n\ndescribe(\"deviceActionModule\", () => {\n describe(\"Default\", () => {\n let container: Container;\n let mod: ReturnType<typeof deviceActionModuleFactory>;\n beforeEach(() => {\n mod = deviceActionModuleFactory();\n container = new Container();\n container.
|
5
|
-
"mappings": "AAAA,OAAS,aAAAA,MAAiB,YAE1B,OAAS,8BAAAC,MAAkC,yDAC3C,OAAS,8BAAAC,MAAkC,kDAC3C,OAAS,uBAAAC,MAA2B,6CACpC,OAAS,eAAAC,MAAmB,oBAE5B,OAAS,6BAAAC,MAAiC,uBAC1C,OAAS,qBAAAC,MAAyB,sBAElC,SAAS,qBAAsB,IAAM,CACnC,SAAS,UAAW,IAAM,CACxB,IAAIC,EACAC,EACJ,WAAW,IAAM,CACfA,EAAMH,EAA0B,EAChCE,EAAY,IAAIP,EAChBO,EAAU,
|
4
|
+
"sourcesContent": ["import { Container } from \"inversify\";\n\nimport { ExecuteDeviceActionUseCase } from \"@api/device-action/use-case/ExecuteDeviceActionUseCase\";\nimport { deviceSessionModuleFactory } from \"@internal/device-session/di/deviceSessionModule\";\nimport { loggerModuleFactory } from \"@internal/logger-publisher/di/loggerModule\";\nimport { StubUseCase } from \"@root/src/di.stub\";\n\nimport { deviceActionModuleFactory } from \"./deviceActionModule\";\nimport { deviceActionTypes } from \"./deviceActionTypes\";\n\ndescribe(\"deviceActionModule\", () => {\n describe(\"Default\", () => {\n let container: Container;\n let mod: ReturnType<typeof deviceActionModuleFactory>;\n beforeEach(() => {\n mod = deviceActionModuleFactory();\n container = new Container();\n container.loadSync(\n mod,\n deviceSessionModuleFactory(),\n loggerModuleFactory(),\n );\n });\n\n it(\"should return the config module\", () => {\n expect(mod).toBeDefined();\n });\n\n it(\"should return non-stubbed executeDeviceAction usecase\", () => {\n const executeDeviceActionUseCase =\n container.get<ExecuteDeviceActionUseCase>(\n deviceActionTypes.ExecuteDeviceActionUseCase,\n );\n expect(executeDeviceActionUseCase).toBeInstanceOf(\n ExecuteDeviceActionUseCase,\n );\n });\n });\n\n describe(\"Stubbed\", () => {\n let container: Container;\n let mod: ReturnType<typeof deviceActionModuleFactory>;\n beforeEach(() => {\n mod = deviceActionModuleFactory({ stub: true });\n container = new Container();\n container.loadSync(mod);\n });\n\n it(\"should return the config module\", () => {\n expect(mod).toBeDefined();\n });\n\n it(\"should return stubbed executeDeviceAction usecase\", () => {\n const executeDeviceActionUseCase = container.get(\n deviceActionTypes.ExecuteDeviceActionUseCase,\n );\n expect(executeDeviceActionUseCase).toBeInstanceOf(StubUseCase);\n });\n });\n});\n"],
|
5
|
+
"mappings": "AAAA,OAAS,aAAAA,MAAiB,YAE1B,OAAS,8BAAAC,MAAkC,yDAC3C,OAAS,8BAAAC,MAAkC,kDAC3C,OAAS,uBAAAC,MAA2B,6CACpC,OAAS,eAAAC,MAAmB,oBAE5B,OAAS,6BAAAC,MAAiC,uBAC1C,OAAS,qBAAAC,MAAyB,sBAElC,SAAS,qBAAsB,IAAM,CACnC,SAAS,UAAW,IAAM,CACxB,IAAIC,EACAC,EACJ,WAAW,IAAM,CACfA,EAAMH,EAA0B,EAChCE,EAAY,IAAIP,EAChBO,EAAU,SACRC,EACAN,EAA2B,EAC3BC,EAAoB,CACtB,CACF,CAAC,EAED,GAAG,kCAAmC,IAAM,CAC1C,OAAOK,CAAG,EAAE,YAAY,CAC1B,CAAC,EAED,GAAG,wDAAyD,IAAM,CAChE,MAAMC,EACJF,EAAU,IACRD,EAAkB,0BACpB,EACF,OAAOG,CAA0B,EAAE,eACjCR,CACF,CACF,CAAC,CACH,CAAC,EAED,SAAS,UAAW,IAAM,CACxB,IAAIM,EACAC,EACJ,WAAW,IAAM,CACfA,EAAMH,EAA0B,CAAE,KAAM,EAAK,CAAC,EAC9CE,EAAY,IAAIP,EAChBO,EAAU,SAASC,CAAG,CACxB,CAAC,EAED,GAAG,kCAAmC,IAAM,CAC1C,OAAOA,CAAG,EAAE,YAAY,CAC1B,CAAC,EAED,GAAG,oDAAqD,IAAM,CAC5D,MAAMC,EAA6BF,EAAU,IAC3CD,EAAkB,0BACpB,EACA,OAAOG,CAA0B,EAAE,eAAeL,CAAW,CAC/D,CAAC,CACH,CAAC,CACH,CAAC",
|
6
6
|
"names": ["Container", "ExecuteDeviceActionUseCase", "deviceSessionModuleFactory", "loggerModuleFactory", "StubUseCase", "deviceActionModuleFactory", "deviceActionTypes", "container", "mod", "executeDeviceActionUseCase"]
|
7
7
|
}
|
@@ -1,2 +1,2 @@
|
|
1
|
-
var
|
1
|
+
var p=(o=>(o.None="none",o.UnlockDevice="unlock-device",o.AllowSecureConnection="allow-secure-connection",o.ConfirmOpenApp="confirm-open-app",o.SignTransaction="sign-transaction",o.SignTypedData="sign-typed-data",o.AllowListApps="allow-list-apps",o.VerifyAddress="verify-address",o.SignPersonalMessage="sign-personal-message",o.SignDelegationAuthorization="sign-delegation-authorization",o.Web3ChecksOptIn="web3-checks-opt-in",o))(p||{});export{p as UserInteractionRequired};
|
2
2
|
//# sourceMappingURL=UserInteractionRequired.js.map
|
@@ -1,7 +1,7 @@
|
|
1
1
|
{
|
2
2
|
"version": 3,
|
3
3
|
"sources": ["../../../../../../src/api/device-action/model/UserInteractionRequired.ts"],
|
4
|
-
"sourcesContent": ["/**\n * The user interaction required on the device to move further in a device action.\n * This is used to inform the users about the action they need to take on the device.\n */\nexport enum UserInteractionRequired {\n None = \"none\",\n UnlockDevice = \"unlock-device\",\n AllowSecureConnection = \"allow-secure-connection\",\n ConfirmOpenApp = \"confirm-open-app\",\n SignTransaction = \"sign-transaction\",\n SignTypedData = \"sign-typed-data\",\n AllowListApps = \"allow-list-apps\",\n VerifyAddress = \"verify-address\",\n SignPersonalMessage = \"sign-personal-message\",\n Web3ChecksOptIn = \"web3-checks-opt-in\",\n}\n"],
|
5
|
-
"mappings": "AAIO,IAAKA,OACVA,EAAA,KAAO,OACPA,EAAA,aAAe,gBACfA,EAAA,sBAAwB,0BACxBA,EAAA,eAAiB,mBACjBA,EAAA,gBAAkB,mBAClBA,EAAA,cAAgB,kBAChBA,EAAA,cAAgB,kBAChBA,EAAA,cAAgB,iBAChBA,EAAA,oBAAsB,wBACtBA,EAAA,gBAAkB,
|
4
|
+
"sourcesContent": ["/**\n * The user interaction required on the device to move further in a device action.\n * This is used to inform the users about the action they need to take on the device.\n */\nexport enum UserInteractionRequired {\n None = \"none\",\n UnlockDevice = \"unlock-device\",\n AllowSecureConnection = \"allow-secure-connection\",\n ConfirmOpenApp = \"confirm-open-app\",\n SignTransaction = \"sign-transaction\",\n SignTypedData = \"sign-typed-data\",\n AllowListApps = \"allow-list-apps\",\n VerifyAddress = \"verify-address\",\n SignPersonalMessage = \"sign-personal-message\",\n SignDelegationAuthorization = \"sign-delegation-authorization\",\n Web3ChecksOptIn = \"web3-checks-opt-in\",\n}\n"],
|
5
|
+
"mappings": "AAIO,IAAKA,OACVA,EAAA,KAAO,OACPA,EAAA,aAAe,gBACfA,EAAA,sBAAwB,0BACxBA,EAAA,eAAiB,mBACjBA,EAAA,gBAAkB,mBAClBA,EAAA,cAAgB,kBAChBA,EAAA,cAAgB,kBAChBA,EAAA,cAAgB,iBAChBA,EAAA,oBAAsB,wBACtBA,EAAA,4BAA8B,gCAC9BA,EAAA,gBAAkB,qBAXRA,OAAA",
|
6
6
|
"names": ["UserInteractionRequired"]
|
7
7
|
}
|
package/lib/esm/src/api/device-action/os/CallTaskInAppDeviceAction/CallTaskInAppDeviceAction.js
CHANGED
@@ -1,2 +1,2 @@
|
|
1
|
-
import{Left as p,Right as o}from"purify-ts";import{assign as t,fromPromise as i,setup as l}from"xstate";import{isSuccessCommandResult as c}from"../../../command/model/CommandResult";import{UserInteractionRequired as s}from"../../../device-action/model/UserInteractionRequired";import{UnknownDAError as u}from"../../../device-action/os/Errors";import{OpenAppDeviceAction as k}from"../../../device-action/os/OpenAppDeviceAction/OpenAppDeviceAction";import{XStateDeviceAction as A}from"../../../device-action/xstate-utils/XStateDeviceAction";class R extends A{makeStateMachine(a){const{callTask:r}=this.extractDependencies(a);return l({types:{input:{},context:{},output:{}},actors:{callTask:i(r),openAppStateMachine:new k({input:{appName:this.input.appName
|
1
|
+
import{Left as p,Right as o}from"purify-ts";import{assign as t,fromPromise as i,setup as l}from"xstate";import{isSuccessCommandResult as c}from"../../../command/model/CommandResult";import{UserInteractionRequired as s}from"../../../device-action/model/UserInteractionRequired";import{UnknownDAError as u}from"../../../device-action/os/Errors";import{OpenAppDeviceAction as k}from"../../../device-action/os/OpenAppDeviceAction/OpenAppDeviceAction";import{XStateDeviceAction as A}from"../../../device-action/xstate-utils/XStateDeviceAction";class R extends A{makeStateMachine(a){const{callTask:r}=this.extractDependencies(a);return l({types:{input:{},context:{},output:{}},actors:{callTask:i(r),openAppStateMachine:new k({input:{appName:this.input.appName}}).makeStateMachine(a)},guards:{skipOpenApp:()=>this.input.skipOpenApp,noInternalError:({context:e})=>e._internalState.error===null},actions:{assignErrorFromEvent:t({_internalState:e=>({...e.context._internalState,error:e.event.error})})}}).createMachine({id:"CallTaskInAppDeviceAction",initial:"InitialState",context:({input:e})=>({input:e,intermediateValue:{requiredUserInteraction:s.None},_internalState:{taskResponse:null,error:null}}),states:{InitialState:{always:[{target:"CallTask",guard:"skipOpenApp"},"OpenAppDeviceAction"]},OpenAppDeviceAction:{invoke:{id:"openAppStateMachine",input:{appName:this.input.appName},src:"openAppStateMachine",onSnapshot:{actions:t({intermediateValue:e=>e.event.snapshot.context.intermediateValue})},onDone:{actions:t({_internalState:e=>e.event.output.caseOf({Right:()=>e.context._internalState,Left:n=>({...e.context._internalState,error:n})})}),target:"CheckOpenAppDeviceActionResult"}}},CheckOpenAppDeviceActionResult:{always:[{target:"CallTask",guard:"noInternalError"},"Error"]},CallTask:{entry:t({intermediateValue:{requiredUserInteraction:this.input.requiredUserInteraction}}),exit:t({intermediateValue:{requiredUserInteraction:s.None}}),invoke:{id:"callTask",src:"callTask",input:e=>e.context.input.task,onDone:{target:"CallTaskResultCheck",actions:[t({_internalState:({event:e,context:n})=>c(e.output)?{...n._internalState,taskResponse:e.output.data}:{...n._internalState,error:e.output.error}})]},onError:{target:"Error",actions:"assignErrorFromEvent"}}},CallTaskResultCheck:{always:[{target:"Success",guard:"noInternalError"},"Error"]},Success:{type:"final"},Error:{type:"final"}},output:({context:e})=>e._internalState.taskResponse?o(e._internalState.taskResponse):p(e._internalState.error||new u("No error in final state"))})}extractDependencies(a){return{callTask:r=>r.input(a)}}}export{R as CallTaskInAppDeviceAction};
|
2
2
|
//# sourceMappingURL=CallTaskInAppDeviceAction.js.map
|
package/lib/esm/src/api/device-action/os/CallTaskInAppDeviceAction/CallTaskInAppDeviceAction.js.map
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
{
|
2
2
|
"version": 3,
|
3
3
|
"sources": ["../../../../../../../src/api/device-action/os/CallTaskInAppDeviceAction/CallTaskInAppDeviceAction.ts"],
|
4
|
-
"sourcesContent": ["import { Left, Right } from \"purify-ts\";\nimport { assign, fromPromise, setup } from \"xstate\";\n\nimport {\n type CommandResult,\n isSuccessCommandResult,\n} from \"@api/command/model/CommandResult\";\nimport { type InternalApi } from \"@api/device-action/DeviceAction\";\nimport { UserInteractionRequired } from \"@api/device-action/model/UserInteractionRequired\";\nimport { UnknownDAError } from \"@api/device-action/os/Errors\";\nimport { OpenAppDeviceAction } from \"@api/device-action/os/OpenAppDeviceAction/OpenAppDeviceAction\";\nimport { type StateMachineTypes } from \"@api/device-action/xstate-utils/StateMachineTypes\";\nimport {\n type DeviceActionStateMachine,\n XStateDeviceAction,\n} from \"@api/device-action/xstate-utils/XStateDeviceAction\";\n\nimport {\n type CallTaskInAppDAError,\n type CallTaskInAppDAInput,\n type CallTaskInAppDAIntermediateValue,\n type CallTaskInAppDAInternalState,\n type CallTaskInAppDAOutput,\n} from \"./CallTaskInAppDeviceActionTypes\";\n\n/**\n * Tries to open an app on the device, and if it is successful, calls a task\n * in the app.\n * The output will be the result of the task.\n *\n * ```ts\n * input: {\n * appName: string;\n * task: (internalApi: InternalApi) => Promise<CommandResult<TaskResponse, TaskErrorCodes>>;\n * requiredUserInteraction: UserInteraction;\n * }\n * ```\n *\n * Example of usage:\n *\n * ```ts\n * const deviceAction = new CallTaskInAppDeviceAction({\n * input: {\n * appName: \"MyApp\",\n * task: async (internalApi: InternalApi) => internalApi.sendCommand(new MyAppSpecificCommand()),\n * requiredUserInteraction: UserInteractionRequired.None,\n * },\n * });\n * dmk.executeDeviceAction({ sessionId: \"mySessionId\", deviceAction });\n * ```\n */\nexport class CallTaskInAppDeviceAction<\n TaskResponse,\n TaskErrorCodes,\n UserInteraction extends UserInteractionRequired,\n> extends XStateDeviceAction<\n CallTaskInAppDAOutput<TaskResponse>,\n CallTaskInAppDAInput<TaskResponse, TaskErrorCodes, UserInteraction>,\n CallTaskInAppDAError<TaskErrorCodes>,\n CallTaskInAppDAIntermediateValue<UserInteraction>,\n CallTaskInAppDAInternalState<TaskResponse, TaskErrorCodes>\n> {\n makeStateMachine(\n internalAPI: InternalApi,\n ): DeviceActionStateMachine<\n CallTaskInAppDAOutput<TaskResponse>,\n CallTaskInAppDAInput<TaskResponse, TaskErrorCodes, UserInteraction>,\n CallTaskInAppDAError<TaskErrorCodes>,\n CallTaskInAppDAIntermediateValue<UserInteraction>,\n CallTaskInAppDAInternalState<TaskResponse, TaskErrorCodes>\n > {\n type types = StateMachineTypes<\n CallTaskInAppDAOutput<TaskResponse>,\n CallTaskInAppDAInput<TaskResponse, TaskErrorCodes, UserInteraction>,\n CallTaskInAppDAError<TaskErrorCodes>,\n CallTaskInAppDAIntermediateValue<UserInteraction>,\n CallTaskInAppDAInternalState<TaskResponse, TaskErrorCodes>\n >;\n\n const { callTask } = this.extractDependencies(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 callTask: fromPromise(callTask),\n openAppStateMachine: new OpenAppDeviceAction({\n input: {\n appName: this.input.appName,\n
|
5
|
-
"mappings": "AAAA,OAAS,QAAAA,EAAM,SAAAC,MAAa,YAC5B,OAAS,UAAAC,EAAQ,eAAAC,EAAa,SAAAC,MAAa,SAE3C,OAEE,0BAAAC,MACK,mCAEP,OAAS,2BAAAC,MAA+B,mDACxC,OAAS,kBAAAC,MAAsB,+BAC/B,OAAS,uBAAAC,MAA2B,gEAEpC,OAEE,sBAAAC,MACK,qDAoCA,MAAMC,UAIHD,CAMR,CACA,iBACEE,EAOA,CASA,KAAM,CAAE,SAAAC,CAAS,EAAI,KAAK,oBAAoBD,CAAW,EAEzD,OAAOP,EAAM,CACX,MAAO,CACL,MAAO,CAAC,EACR,QAAS,CAAC,EACV,OAAQ,CAAC,CACX,EACA,OAAQ,CACN,SAAUD,EAAYS,CAAQ,EAC9B,oBAAqB,IAAIJ,EAAoB,CAC3C,MAAO,CACL,QAAS,KAAK,MAAM,
|
4
|
+
"sourcesContent": ["import { Left, Right } from \"purify-ts\";\nimport { assign, fromPromise, setup } from \"xstate\";\n\nimport {\n type CommandResult,\n isSuccessCommandResult,\n} from \"@api/command/model/CommandResult\";\nimport { type InternalApi } from \"@api/device-action/DeviceAction\";\nimport { UserInteractionRequired } from \"@api/device-action/model/UserInteractionRequired\";\nimport { UnknownDAError } from \"@api/device-action/os/Errors\";\nimport { OpenAppDeviceAction } from \"@api/device-action/os/OpenAppDeviceAction/OpenAppDeviceAction\";\nimport { type StateMachineTypes } from \"@api/device-action/xstate-utils/StateMachineTypes\";\nimport {\n type DeviceActionStateMachine,\n XStateDeviceAction,\n} from \"@api/device-action/xstate-utils/XStateDeviceAction\";\n\nimport {\n type CallTaskInAppDAError,\n type CallTaskInAppDAInput,\n type CallTaskInAppDAIntermediateValue,\n type CallTaskInAppDAInternalState,\n type CallTaskInAppDAOutput,\n} from \"./CallTaskInAppDeviceActionTypes\";\n\n/**\n * Tries to open an app on the device, and if it is successful, calls a task\n * in the app.\n * The output will be the result of the task.\n *\n * ```ts\n * input: {\n * appName: string;\n * task: (internalApi: InternalApi) => Promise<CommandResult<TaskResponse, TaskErrorCodes>>;\n * requiredUserInteraction: UserInteraction;\n * }\n * ```\n *\n * Example of usage:\n *\n * ```ts\n * const deviceAction = new CallTaskInAppDeviceAction({\n * input: {\n * appName: \"MyApp\",\n * task: async (internalApi: InternalApi) => internalApi.sendCommand(new MyAppSpecificCommand()),\n * requiredUserInteraction: UserInteractionRequired.None,\n * },\n * });\n * dmk.executeDeviceAction({ sessionId: \"mySessionId\", deviceAction });\n * ```\n */\nexport class CallTaskInAppDeviceAction<\n TaskResponse,\n TaskErrorCodes,\n UserInteraction extends UserInteractionRequired,\n> extends XStateDeviceAction<\n CallTaskInAppDAOutput<TaskResponse>,\n CallTaskInAppDAInput<TaskResponse, TaskErrorCodes, UserInteraction>,\n CallTaskInAppDAError<TaskErrorCodes>,\n CallTaskInAppDAIntermediateValue<UserInteraction>,\n CallTaskInAppDAInternalState<TaskResponse, TaskErrorCodes>\n> {\n makeStateMachine(\n internalAPI: InternalApi,\n ): DeviceActionStateMachine<\n CallTaskInAppDAOutput<TaskResponse>,\n CallTaskInAppDAInput<TaskResponse, TaskErrorCodes, UserInteraction>,\n CallTaskInAppDAError<TaskErrorCodes>,\n CallTaskInAppDAIntermediateValue<UserInteraction>,\n CallTaskInAppDAInternalState<TaskResponse, TaskErrorCodes>\n > {\n type types = StateMachineTypes<\n CallTaskInAppDAOutput<TaskResponse>,\n CallTaskInAppDAInput<TaskResponse, TaskErrorCodes, UserInteraction>,\n CallTaskInAppDAError<TaskErrorCodes>,\n CallTaskInAppDAIntermediateValue<UserInteraction>,\n CallTaskInAppDAInternalState<TaskResponse, TaskErrorCodes>\n >;\n\n const { callTask } = this.extractDependencies(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 callTask: fromPromise(callTask),\n openAppStateMachine: new OpenAppDeviceAction({\n input: {\n appName: this.input.appName,\n },\n }).makeStateMachine(internalAPI),\n },\n guards: {\n skipOpenApp: () => this.input.skipOpenApp,\n noInternalError: ({ context }) => context._internalState.error === null,\n },\n actions: {\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 id: \"CallTaskInAppDeviceAction\",\n initial: \"InitialState\",\n context: ({ input }) => {\n return {\n input: input,\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.None,\n },\n _internalState: {\n taskResponse: null,\n error: null,\n },\n };\n },\n states: {\n InitialState: {\n always: [\n {\n target: \"CallTask\",\n guard: \"skipOpenApp\",\n },\n \"OpenAppDeviceAction\",\n ],\n },\n OpenAppDeviceAction: {\n invoke: {\n id: \"openAppStateMachine\",\n input: {\n appName: this.input.appName,\n },\n src: \"openAppStateMachine\",\n onSnapshot: {\n actions: assign({\n intermediateValue: (_) =>\n _.event.snapshot.context.intermediateValue,\n }),\n },\n onDone: {\n actions: assign({\n _internalState: (_) => {\n return _.event.output.caseOf<\n CallTaskInAppDAInternalState<TaskResponse, TaskErrorCodes>\n >({\n Right: () => _.context._internalState,\n Left: (error) => ({\n ..._.context._internalState,\n error,\n }),\n });\n },\n }),\n target: \"CheckOpenAppDeviceActionResult\",\n },\n },\n },\n CheckOpenAppDeviceActionResult: {\n always: [\n {\n target: \"CallTask\",\n guard: \"noInternalError\",\n },\n \"Error\",\n ],\n },\n CallTask: {\n entry: assign({\n intermediateValue: {\n requiredUserInteraction: this.input.requiredUserInteraction,\n },\n }),\n exit: assign({\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.None,\n },\n }),\n invoke: {\n id: \"callTask\",\n src: \"callTask\",\n input: (_: { context: types[\"context\"] }) => _.context.input.task,\n onDone: {\n target: \"CallTaskResultCheck\",\n actions: [\n assign({\n _internalState: ({ event, context }) => {\n if (isSuccessCommandResult(event.output)) {\n return {\n ...context._internalState,\n taskResponse: event.output.data,\n };\n }\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 CallTaskResultCheck: {\n always: [\n {\n target: \"Success\",\n guard: \"noInternalError\",\n },\n \"Error\",\n ],\n },\n Success: {\n type: \"final\",\n },\n Error: {\n type: \"final\",\n },\n },\n output: ({ context }) =>\n context._internalState.taskResponse\n ? Right(context._internalState.taskResponse)\n : Left(\n context._internalState.error ||\n new UnknownDAError(\"No error in final state\"),\n ),\n });\n }\n\n extractDependencies(internalApi: InternalApi) {\n return {\n callTask: (_: {\n input: (\n internalApi: InternalApi,\n ) => Promise<CommandResult<TaskResponse, TaskErrorCodes>>;\n }): Promise<CommandResult<TaskResponse, TaskErrorCodes>> =>\n _.input(internalApi),\n };\n }\n}\n"],
|
5
|
+
"mappings": "AAAA,OAAS,QAAAA,EAAM,SAAAC,MAAa,YAC5B,OAAS,UAAAC,EAAQ,eAAAC,EAAa,SAAAC,MAAa,SAE3C,OAEE,0BAAAC,MACK,mCAEP,OAAS,2BAAAC,MAA+B,mDACxC,OAAS,kBAAAC,MAAsB,+BAC/B,OAAS,uBAAAC,MAA2B,gEAEpC,OAEE,sBAAAC,MACK,qDAoCA,MAAMC,UAIHD,CAMR,CACA,iBACEE,EAOA,CASA,KAAM,CAAE,SAAAC,CAAS,EAAI,KAAK,oBAAoBD,CAAW,EAEzD,OAAOP,EAAM,CACX,MAAO,CACL,MAAO,CAAC,EACR,QAAS,CAAC,EACV,OAAQ,CAAC,CACX,EACA,OAAQ,CACN,SAAUD,EAAYS,CAAQ,EAC9B,oBAAqB,IAAIJ,EAAoB,CAC3C,MAAO,CACL,QAAS,K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J,IAAK,WACL,MAAQQ,GAAqCA,EAAE,QAAQ,MAAM,KAC7D,OAAQ,CACN,OAAQ,sBACR,QAAS,CACPZ,EAAO,CACL,eAAgB,CAAC,CAAE,MAAAe,EAAO,QAAAJ,CAAQ,IAC5BR,EAAuBY,EAAM,MAAM,EAC9B,CACL,GAAGJ,EAAQ,eACX,aAAcI,EAAM,OAAO,IAC7B,EAEK,CACL,GAAGJ,EAAQ,eACX,MAAOI,EAAM,OAAO,KACtB,CAEJ,CAAC,CACH,CACF,EACA,QAAS,CACP,OAAQ,QACR,QAAS,sBACX,CACF,CACF,EACA,oBAAqB,CACnB,OAAQ,CACN,CACE,OAAQ,UACR,MAAO,iBACT,EACA,OACF,CACF,EACA,QAAS,CACP,KAAM,OACR,EACA,MAAO,CACL,KAAM,OACR,CACF,EACA,OAAQ,CAAC,CAAE,QAAAJ,CAAQ,IACjBA,EAAQ,eAAe,aACnBZ,EAAMY,EAAQ,eAAe,YAAY,EACzCb,EACEa,EAAQ,eAAe,OACrB,IAAIN,EAAe,yBAAyB,CAChD,CACR,CAAC,CACH,CAEA,oBAAoBW,EAA0B,CAC5C,MAAO,CACL,SAAWJ,GAKTA,EAAE,MAAMI,CAAW,CACvB,CACF,CACF",
|
6
6
|
"names": ["Left", "Right", "assign", "fromPromise", "setup", "isSuccessCommandResult", "UserInteractionRequired", "UnknownDAError", "OpenAppDeviceAction", "XStateDeviceAction", "CallTaskInAppDeviceAction", "internalAPI", "callTask", "context", "_", "input", "error", "event", "internalApi"]
|
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";import{isDashboardName as
|
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 x}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,isDashboardOpen:({context:e})=>{if(e._internalState.currentlyRunningApp===null)throw new Error("context.currentlyRunningApp === null");return x(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\";\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+31Cc3IC2iDCBIPW4K2O2KMLKxwQiKUyNRAwxWKUOJu3TaDFsw28bkExmsgnU-Rp0zp4QZUXoDFCABsyBwylhCBxiHqOHE9WBeBB6GAGGlCLQ8g7abNNf8mfrDcbTebLdaEE7gUbokJhBGuaUjvCbCSCdZNI5UQqhg1cQhNOprAxND4XP0xZTHI01SEPX9GTqfaQw-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jKl6ErIBDUmCenATwA2RM7rknUm4FUhV-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,kBAAmB,IAAMH,EAAkB,EAC3C,mBAAoB,CAAC,CAAE,QAAAI,CAAQ,IACzBA,EAAQ,eAAe,sBAAwB,KAAa,GAE9DA,EAAQ,eAAe,
|
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 === context.input.appName\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+31Cc3IC2iDCBIPW4K2O2KMLKxwQiKUyNRAwxWKUOJu3TaDFsw28bkExmsgnU-Rp0zp4QZUXoDFCABsyBwylhCBxiHqOHE9WBeBB6GAGGlCLQ8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cbsC4Hwa6i9eQHgQgmCkIlBjKmcEFUY24ejaSTMeCkHxPgYFoBAOAcgA5u1um3XkABaHeEoKEEkKvQwQJ4XjKl6ErIBDUmCenATwA2RM7rknUm4FUhV-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,kBAAmB,IAAMH,EAAkB,EAC3C,mBAAoB,CAAC,CAAE,QAAAI,CAAQ,IACzB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jE,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
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
|
}
|