@ledgerhq/device-management-kit 0.9.2 → 0.11.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/cjs/package.json +1 -1
- package/lib/cjs/src/api/DeviceManagementKit.js +1 -1
- package/lib/cjs/src/api/DeviceManagementKit.js.map +2 -2
- package/lib/cjs/src/api/DeviceManagementKit.test.js +1 -1
- package/lib/cjs/src/api/DeviceManagementKit.test.js.map +2 -2
- package/lib/cjs/src/api/command/Command.js +1 -1
- package/lib/cjs/src/api/command/Command.js.map +1 -1
- package/lib/cjs/src/api/command/Errors.js +1 -1
- package/lib/cjs/src/api/command/Errors.js.map +3 -3
- package/lib/cjs/src/api/command/model/CommandResult.js +1 -1
- package/lib/cjs/src/api/command/model/CommandResult.js.map +2 -2
- package/lib/cjs/src/api/command/os/CloseAppCommand.js +1 -1
- package/lib/cjs/src/api/command/os/CloseAppCommand.js.map +2 -2
- package/lib/cjs/src/api/command/os/CloseAppCommand.test.js +1 -1
- package/lib/cjs/src/api/command/os/CloseAppCommand.test.js.map +2 -2
- package/lib/cjs/src/api/command/os/GetAppAndVersionCommand.js +1 -1
- package/lib/cjs/src/api/command/os/GetAppAndVersionCommand.js.map +2 -2
- package/lib/cjs/src/api/command/os/GetAppAndVersionCommand.test.js +1 -1
- package/lib/cjs/src/api/command/os/GetAppAndVersionCommand.test.js.map +2 -2
- package/lib/cjs/src/api/command/os/GetBatteryStatusCommand.js +1 -1
- package/lib/cjs/src/api/command/os/GetBatteryStatusCommand.js.map +2 -2
- package/lib/cjs/src/api/command/os/GetBatteryStatusCommand.test.js +1 -1
- package/lib/cjs/src/api/command/os/GetBatteryStatusCommand.test.js.map +3 -3
- package/lib/cjs/src/api/command/os/GetCustomImageSizeCommand.js +1 -1
- package/lib/cjs/src/api/command/os/GetCustomImageSizeCommand.js.map +2 -2
- package/lib/cjs/src/api/command/os/GetCustomImageSizeCommand.test.js +1 -1
- package/lib/cjs/src/api/command/os/GetCustomImageSizeCommand.test.js.map +2 -2
- package/lib/cjs/src/api/command/os/GetOsVersionCommand.js +1 -1
- package/lib/cjs/src/api/command/os/GetOsVersionCommand.js.map +2 -2
- package/lib/cjs/src/api/command/os/GetOsVersionCommand.test.js +1 -1
- package/lib/cjs/src/api/command/os/GetOsVersionCommand.test.js.map +2 -2
- package/lib/cjs/src/api/command/os/ListAppsCommand.js +1 -1
- package/lib/cjs/src/api/command/os/ListAppsCommand.js.map +2 -2
- package/lib/cjs/src/api/command/os/ListAppsCommand.test.js +1 -1
- package/lib/cjs/src/api/command/os/ListAppsCommand.test.js.map +2 -2
- package/lib/cjs/src/api/command/os/ListLanguagePackCommand.js +1 -1
- package/lib/cjs/src/api/command/os/ListLanguagePackCommand.js.map +2 -2
- package/lib/cjs/src/api/command/os/ListLanguagePackCommand.test.js +1 -1
- package/lib/cjs/src/api/command/os/ListLanguagePackCommand.test.js.map +2 -2
- package/lib/cjs/src/api/command/os/LoadCertificateCommand.js +1 -1
- package/lib/cjs/src/api/command/os/LoadCertificateCommand.js.map +2 -2
- package/lib/cjs/src/api/command/os/LoadCertificateCommand.test.js +1 -1
- package/lib/cjs/src/api/command/os/LoadCertificateCommand.test.js.map +3 -3
- package/lib/cjs/src/api/command/os/OpenAppCommand.js +1 -1
- package/lib/cjs/src/api/command/os/OpenAppCommand.js.map +2 -2
- package/lib/cjs/src/api/command/os/OpenAppCommand.test.js +1 -1
- package/lib/cjs/src/api/command/os/OpenAppCommand.test.js.map +2 -2
- package/lib/cjs/src/api/command/use-case/SendCommandUseCase.test.js +1 -1
- package/lib/cjs/src/api/command/use-case/SendCommandUseCase.test.js.map +2 -2
- package/lib/cjs/src/api/device-action/os/CallTaskInAppDeviceAction/CallTaskInAppDeviceAction.test.js +1 -1
- package/lib/cjs/src/api/device-action/os/CallTaskInAppDeviceAction/CallTaskInAppDeviceAction.test.js.map +2 -2
- package/lib/cjs/src/api/device-action/os/SendCommandInAppDeviceAction/SendCommandInAppDeviceAction.test.js +1 -1
- package/lib/cjs/src/api/device-action/os/SendCommandInAppDeviceAction/SendCommandInAppDeviceAction.test.js.map +2 -2
- package/lib/cjs/src/api/device-action/task/GetFirmwareMetadataTask.js +1 -1
- package/lib/cjs/src/api/device-action/task/GetFirmwareMetadataTask.js.map +2 -2
- package/lib/cjs/src/api/device-action/task/GetFirmwareMetadataTask.test.js +1 -1
- package/lib/cjs/src/api/device-action/task/GetFirmwareMetadataTask.test.js.map +2 -2
- package/lib/cjs/src/api/index.js +1 -1
- package/lib/cjs/src/api/index.js.map +2 -2
- package/lib/cjs/src/api/transport/model/ConnectedDevice.js +1 -1
- package/lib/cjs/src/api/transport/model/ConnectedDevice.js.map +3 -3
- package/lib/cjs/src/api/transport/model/TransportConnectedDevice.js +1 -1
- package/lib/cjs/src/api/transport/model/TransportConnectedDevice.js.map +3 -3
- package/lib/cjs/src/internal/device-session/model/DeviceSession.js +1 -1
- package/lib/cjs/src/internal/device-session/model/DeviceSession.js.map +2 -2
- package/lib/cjs/src/internal/discovery/di/discoveryModule.js +1 -1
- package/lib/cjs/src/internal/discovery/di/discoveryModule.js.map +3 -3
- package/lib/cjs/src/internal/discovery/di/discoveryModule.test.js +1 -1
- package/lib/cjs/src/internal/discovery/di/discoveryModule.test.js.map +3 -3
- package/lib/cjs/src/internal/discovery/di/discoveryTypes.js +1 -1
- package/lib/cjs/src/internal/discovery/di/discoveryTypes.js.map +2 -2
- package/lib/cjs/src/internal/discovery/use-case/ConnectUseCase.js +1 -1
- package/lib/cjs/src/internal/discovery/use-case/ConnectUseCase.js.map +3 -3
- package/lib/cjs/src/internal/discovery/use-case/ConnectUseCase.test.js +1 -1
- package/lib/cjs/src/internal/discovery/use-case/ConnectUseCase.test.js.map +3 -3
- package/lib/cjs/src/internal/discovery/use-case/DisconnectUseCase.js +1 -1
- package/lib/cjs/src/internal/discovery/use-case/DisconnectUseCase.js.map +3 -3
- package/lib/cjs/src/internal/discovery/use-case/ReconnectUseCase.js +2 -0
- package/lib/cjs/src/internal/discovery/use-case/ReconnectUseCase.js.map +7 -0
- package/lib/cjs/src/internal/discovery/use-case/ReconnectUseCase.test.js +2 -0
- package/lib/cjs/src/internal/discovery/use-case/ReconnectUseCase.test.js.map +7 -0
- package/lib/esm/package.json +1 -1
- package/lib/esm/src/api/DeviceManagementKit.js +1 -1
- package/lib/esm/src/api/DeviceManagementKit.js.map +2 -2
- package/lib/esm/src/api/DeviceManagementKit.test.js +1 -1
- package/lib/esm/src/api/DeviceManagementKit.test.js.map +2 -2
- package/lib/esm/src/api/command/Errors.js +1 -1
- package/lib/esm/src/api/command/Errors.js.map +3 -3
- package/lib/esm/src/api/command/model/CommandResult.js.map +2 -2
- package/lib/esm/src/api/command/os/CloseAppCommand.js +1 -1
- package/lib/esm/src/api/command/os/CloseAppCommand.js.map +2 -2
- package/lib/esm/src/api/command/os/CloseAppCommand.test.js +1 -1
- package/lib/esm/src/api/command/os/CloseAppCommand.test.js.map +2 -2
- package/lib/esm/src/api/command/os/GetAppAndVersionCommand.js +1 -1
- package/lib/esm/src/api/command/os/GetAppAndVersionCommand.js.map +2 -2
- package/lib/esm/src/api/command/os/GetAppAndVersionCommand.test.js +1 -1
- package/lib/esm/src/api/command/os/GetAppAndVersionCommand.test.js.map +2 -2
- package/lib/esm/src/api/command/os/GetBatteryStatusCommand.js +1 -1
- package/lib/esm/src/api/command/os/GetBatteryStatusCommand.js.map +2 -2
- package/lib/esm/src/api/command/os/GetBatteryStatusCommand.test.js +1 -1
- package/lib/esm/src/api/command/os/GetBatteryStatusCommand.test.js.map +3 -3
- package/lib/esm/src/api/command/os/GetCustomImageSizeCommand.js +1 -1
- package/lib/esm/src/api/command/os/GetCustomImageSizeCommand.js.map +2 -2
- package/lib/esm/src/api/command/os/GetCustomImageSizeCommand.test.js +1 -1
- package/lib/esm/src/api/command/os/GetCustomImageSizeCommand.test.js.map +2 -2
- package/lib/esm/src/api/command/os/GetOsVersionCommand.js +1 -1
- package/lib/esm/src/api/command/os/GetOsVersionCommand.js.map +2 -2
- package/lib/esm/src/api/command/os/GetOsVersionCommand.test.js +1 -1
- package/lib/esm/src/api/command/os/GetOsVersionCommand.test.js.map +2 -2
- package/lib/esm/src/api/command/os/ListAppsCommand.js +1 -1
- package/lib/esm/src/api/command/os/ListAppsCommand.js.map +2 -2
- package/lib/esm/src/api/command/os/ListAppsCommand.test.js +1 -1
- package/lib/esm/src/api/command/os/ListAppsCommand.test.js.map +2 -2
- package/lib/esm/src/api/command/os/ListLanguagePackCommand.js +1 -1
- package/lib/esm/src/api/command/os/ListLanguagePackCommand.js.map +2 -2
- package/lib/esm/src/api/command/os/ListLanguagePackCommand.test.js +1 -1
- package/lib/esm/src/api/command/os/ListLanguagePackCommand.test.js.map +2 -2
- package/lib/esm/src/api/command/os/LoadCertificateCommand.js +1 -1
- package/lib/esm/src/api/command/os/LoadCertificateCommand.js.map +2 -2
- package/lib/esm/src/api/command/os/LoadCertificateCommand.test.js +1 -1
- package/lib/esm/src/api/command/os/LoadCertificateCommand.test.js.map +3 -3
- package/lib/esm/src/api/command/os/OpenAppCommand.js +1 -1
- package/lib/esm/src/api/command/os/OpenAppCommand.js.map +2 -2
- package/lib/esm/src/api/command/os/OpenAppCommand.test.js +1 -1
- package/lib/esm/src/api/command/os/OpenAppCommand.test.js.map +2 -2
- package/lib/esm/src/api/command/use-case/SendCommandUseCase.test.js +1 -1
- package/lib/esm/src/api/command/use-case/SendCommandUseCase.test.js.map +2 -2
- package/lib/esm/src/api/device-action/os/CallTaskInAppDeviceAction/CallTaskInAppDeviceAction.test.js +1 -1
- package/lib/esm/src/api/device-action/os/CallTaskInAppDeviceAction/CallTaskInAppDeviceAction.test.js.map +2 -2
- package/lib/esm/src/api/device-action/os/SendCommandInAppDeviceAction/SendCommandInAppDeviceAction.test.js +1 -1
- package/lib/esm/src/api/device-action/os/SendCommandInAppDeviceAction/SendCommandInAppDeviceAction.test.js.map +2 -2
- package/lib/esm/src/api/device-action/task/GetFirmwareMetadataTask.js +1 -1
- package/lib/esm/src/api/device-action/task/GetFirmwareMetadataTask.js.map +3 -3
- package/lib/esm/src/api/device-action/task/GetFirmwareMetadataTask.test.js +1 -1
- package/lib/esm/src/api/device-action/task/GetFirmwareMetadataTask.test.js.map +3 -3
- package/lib/esm/src/api/index.js +1 -1
- package/lib/esm/src/api/index.js.map +3 -3
- package/lib/esm/src/api/transport/model/ConnectedDevice.js +1 -1
- package/lib/esm/src/api/transport/model/ConnectedDevice.js.map +3 -3
- package/lib/esm/src/api/transport/model/TransportConnectedDevice.js +1 -1
- package/lib/esm/src/api/transport/model/TransportConnectedDevice.js.map +3 -3
- package/lib/esm/src/internal/device-session/model/DeviceSession.js +1 -1
- package/lib/esm/src/internal/device-session/model/DeviceSession.js.map +2 -2
- package/lib/esm/src/internal/discovery/di/discoveryModule.js +1 -1
- package/lib/esm/src/internal/discovery/di/discoveryModule.js.map +3 -3
- package/lib/esm/src/internal/discovery/di/discoveryModule.test.js +1 -1
- package/lib/esm/src/internal/discovery/di/discoveryModule.test.js.map +3 -3
- package/lib/esm/src/internal/discovery/di/discoveryTypes.js +1 -1
- package/lib/esm/src/internal/discovery/di/discoveryTypes.js.map +2 -2
- package/lib/esm/src/internal/discovery/use-case/ConnectUseCase.js +1 -1
- package/lib/esm/src/internal/discovery/use-case/ConnectUseCase.js.map +3 -3
- package/lib/esm/src/internal/discovery/use-case/ConnectUseCase.test.js +1 -1
- package/lib/esm/src/internal/discovery/use-case/ConnectUseCase.test.js.map +3 -3
- package/lib/esm/src/internal/discovery/use-case/DisconnectUseCase.js +1 -1
- package/lib/esm/src/internal/discovery/use-case/DisconnectUseCase.js.map +3 -3
- package/lib/esm/src/internal/discovery/use-case/ReconnectUseCase.js +2 -0
- package/lib/esm/src/internal/discovery/use-case/ReconnectUseCase.js.map +7 -0
- package/lib/esm/src/internal/discovery/use-case/ReconnectUseCase.test.js +2 -0
- package/lib/esm/src/internal/discovery/use-case/ReconnectUseCase.test.js.map +7 -0
- package/lib/types/src/api/DeviceManagementKit.d.ts +12 -0
- package/lib/types/src/api/DeviceManagementKit.d.ts.map +1 -1
- package/lib/types/src/api/command/Command.d.ts +4 -0
- package/lib/types/src/api/command/Command.d.ts.map +1 -1
- package/lib/types/src/api/command/Errors.d.ts +5 -0
- package/lib/types/src/api/command/Errors.d.ts.map +1 -1
- package/lib/types/src/api/command/model/CommandResult.d.ts +3 -3
- package/lib/types/src/api/command/model/CommandResult.d.ts.map +1 -1
- package/lib/types/src/api/command/os/CloseAppCommand.d.ts +1 -0
- package/lib/types/src/api/command/os/CloseAppCommand.d.ts.map +1 -1
- package/lib/types/src/api/command/os/GetAppAndVersionCommand.d.ts +1 -0
- package/lib/types/src/api/command/os/GetAppAndVersionCommand.d.ts.map +1 -1
- package/lib/types/src/api/command/os/GetBatteryStatusCommand.d.ts +1 -0
- package/lib/types/src/api/command/os/GetBatteryStatusCommand.d.ts.map +1 -1
- package/lib/types/src/api/command/os/GetCustomImageSizeCommand.d.ts +1 -0
- package/lib/types/src/api/command/os/GetCustomImageSizeCommand.d.ts.map +1 -1
- package/lib/types/src/api/command/os/GetOsVersionCommand.d.ts +1 -0
- package/lib/types/src/api/command/os/GetOsVersionCommand.d.ts.map +1 -1
- package/lib/types/src/api/command/os/ListAppsCommand.d.ts +1 -0
- package/lib/types/src/api/command/os/ListAppsCommand.d.ts.map +1 -1
- package/lib/types/src/api/command/os/ListLanguagePackCommand.d.ts +1 -0
- package/lib/types/src/api/command/os/ListLanguagePackCommand.d.ts.map +1 -1
- package/lib/types/src/api/command/os/LoadCertificateCommand.d.ts +1 -0
- package/lib/types/src/api/command/os/LoadCertificateCommand.d.ts.map +1 -1
- package/lib/types/src/api/command/os/OpenAppCommand.d.ts +1 -0
- package/lib/types/src/api/command/os/OpenAppCommand.d.ts.map +1 -1
- package/lib/types/src/api/device-action/task/GetFirmwareMetadataTask.d.ts.map +1 -1
- package/lib/types/src/api/index.d.ts +1 -1
- package/lib/types/src/api/index.d.ts.map +1 -1
- package/lib/types/src/api/transport/model/ConnectedDevice.d.ts +3 -2
- package/lib/types/src/api/transport/model/ConnectedDevice.d.ts.map +1 -1
- package/lib/types/src/api/transport/model/TransportConnectedDevice.d.ts +3 -1
- package/lib/types/src/api/transport/model/TransportConnectedDevice.d.ts.map +1 -1
- package/lib/types/src/internal/device-session/model/DeviceSession.d.ts.map +1 -1
- package/lib/types/src/internal/discovery/di/discoveryModule.d.ts.map +1 -1
- package/lib/types/src/internal/discovery/di/discoveryTypes.d.ts +1 -0
- package/lib/types/src/internal/discovery/di/discoveryTypes.d.ts.map +1 -1
- package/lib/types/src/internal/discovery/use-case/ConnectUseCase.d.ts +3 -2
- package/lib/types/src/internal/discovery/use-case/ConnectUseCase.d.ts.map +1 -1
- package/lib/types/src/internal/discovery/use-case/DisconnectUseCase.d.ts.map +1 -1
- package/lib/types/src/internal/discovery/use-case/ReconnectUseCase.d.ts +32 -0
- package/lib/types/src/internal/discovery/use-case/ReconnectUseCase.d.ts.map +1 -0
- package/lib/types/src/internal/discovery/use-case/ReconnectUseCase.test.d.ts +2 -0
- package/lib/types/src/internal/discovery/use-case/ReconnectUseCase.test.d.ts.map +1 -0
- package/lib/types/tsconfig.prod.tsbuildinfo +1 -1
- package/package.json +3 -3
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../../src/api/command/os/GetBatteryStatusCommand.test.ts"],
|
|
4
|
-
"sourcesContent": ["import {\n CommandResultFactory,\n isSuccessCommandResult,\n} from \"@api/command/model/CommandResult\";\nimport { ApduResponse } from \"@api/device-session/ApduResponse\";\n\nimport {\n BatteryStatusType,\n ChargingMode,\n GetBatteryStatusCommand,\n} from \"./GetBatteryStatusCommand\";\n\nconst GET_BATTERY_STATUS_APDU_PERCENTAGE = Uint8Array.from([\n 0xe0, 0x10, 0x00, 0x00, 0x00,\n]);\nconst GET_BATTERY_STATUS_APDU_VOLTAGE = Uint8Array.from([\n 0xe0, 0x10, 0x00, 0x01, 0x00,\n]);\nconst GET_BATTERY_STATUS_APDU_TEMPERATURE = Uint8Array.from([\n 0xe0, 0x10, 0x00, 0x02, 0x00,\n]);\nconst GET_BATTERY_STATUS_APDU_CURRENT = Uint8Array.from([\n 0xe0, 0x10, 0x00, 0x03, 0x00,\n]);\nconst GET_BATTERY_STATUS_APDU_FLAGS = Uint8Array.from([\n 0xe0, 0x10, 0x00, 0x04, 0x00,\n]);\n\nconst PERCENTAGE_RESPONSE_HEX = Uint8Array.from([0x37, 0x90, 0x00]);\nconst VOLTAGE_RESPONSE_HEX = Uint8Array.from([0x0f, 0xff, 0x90, 0x00]);\nconst TEMPERATURE_RESPONSE_HEX = Uint8Array.from([0x10, 0x90, 0x00]);\nconst FLAGS_RESPONSE_HEX = Uint8Array.from([\n 0x00, 0x00, 0x00, 0x0f, 0x90, 0x00,\n]);\nconst FAILED_RESPONSE_HEX = Uint8Array.from([0x67, 0x00]);\n\ndescribe(\"GetBatteryStatus\", () => {\n describe(\"getApdu\", () => {\n it(\"should return the GetBatteryStatus APDU\", () => {\n expect(\n new GetBatteryStatusCommand({\n statusType: BatteryStatusType.BATTERY_PERCENTAGE,\n })\n .getApdu()\n .getRawApdu(),\n ).toStrictEqual(GET_BATTERY_STATUS_APDU_PERCENTAGE);\n expect(\n new GetBatteryStatusCommand({\n statusType: BatteryStatusType.BATTERY_VOLTAGE,\n })\n .getApdu()\n .getRawApdu(),\n ).toStrictEqual(GET_BATTERY_STATUS_APDU_VOLTAGE);\n expect(\n new GetBatteryStatusCommand({\n statusType: BatteryStatusType.BATTERY_TEMPERATURE,\n })\n .getApdu()\n .getRawApdu(),\n ).toStrictEqual(GET_BATTERY_STATUS_APDU_TEMPERATURE);\n expect(\n new GetBatteryStatusCommand({\n statusType: BatteryStatusType.BATTERY_CURRENT,\n })\n .getApdu()\n .getRawApdu(),\n ).toStrictEqual(GET_BATTERY_STATUS_APDU_CURRENT);\n expect(\n new GetBatteryStatusCommand({\n statusType: BatteryStatusType.BATTERY_FLAGS,\n })\n .getApdu()\n .getRawApdu(),\n ).toStrictEqual(GET_BATTERY_STATUS_APDU_FLAGS);\n });\n });\n describe(\"parseResponse\", () => {\n it(\"should parse the response when querying percentage\", () => {\n const PERCENTAGE_RESPONSE = new ApduResponse({\n statusCode: PERCENTAGE_RESPONSE_HEX.slice(-2),\n data: PERCENTAGE_RESPONSE_HEX.slice(0, -2),\n });\n const command = new GetBatteryStatusCommand({\n statusType: BatteryStatusType.BATTERY_PERCENTAGE,\n });\n const parsed = command.parseResponse(PERCENTAGE_RESPONSE);\n expect(parsed).toStrictEqual(CommandResultFactory({ data: 55 }));\n });\n it(\"should parse the response when querying voltage\", () => {\n const VOLTAGE_RESPONSE = new ApduResponse({\n statusCode: VOLTAGE_RESPONSE_HEX.slice(-2),\n data: VOLTAGE_RESPONSE_HEX.slice(0, -2),\n });\n const command = new GetBatteryStatusCommand({\n statusType: BatteryStatusType.BATTERY_VOLTAGE,\n });\n const parsed = command.parseResponse(VOLTAGE_RESPONSE);\n expect(parsed).toStrictEqual(CommandResultFactory({ data: 4095 }));\n });\n it(\"should parse the response when querying temperature\", () => {\n const TEMPERATURE_RESPONSE = new ApduResponse({\n statusCode: TEMPERATURE_RESPONSE_HEX.slice(-2),\n data: TEMPERATURE_RESPONSE_HEX.slice(0, -2),\n });\n const command = new GetBatteryStatusCommand({\n statusType: BatteryStatusType.BATTERY_TEMPERATURE,\n });\n const parsed = command.parseResponse(TEMPERATURE_RESPONSE);\n expect(parsed).toStrictEqual(CommandResultFactory({ data: 16 }));\n });\n it(\"should parse the response when querying flags\", () => {\n const FLAGS_RESPONSE = new ApduResponse({\n statusCode: FLAGS_RESPONSE_HEX.slice(-2),\n data: FLAGS_RESPONSE_HEX.slice(0, -2),\n });\n const command = new GetBatteryStatusCommand({\n statusType: BatteryStatusType.BATTERY_FLAGS,\n });\n const parsed = command.parseResponse(FLAGS_RESPONSE);\n expect(parsed).toStrictEqual(\n CommandResultFactory({\n data: {\n charging: ChargingMode.USB,\n issueCharging: false,\n issueTemperature: false,\n issueBattery: false,\n },\n }),\n );\n });\n it(\"should return an error if the response returned unsupported format\", () => {\n const FAILED_RESPONSE = new ApduResponse({\n statusCode: FAILED_RESPONSE_HEX.slice(-2),\n data: FAILED_RESPONSE_HEX.slice(0, -2),\n });\n const command = new GetBatteryStatusCommand({\n statusType: BatteryStatusType.BATTERY_PERCENTAGE,\n });\n const result = command.parseResponse(FAILED_RESPONSE);\n expect(isSuccessCommandResult(result)).toBeFalsy();\n });\n });\n});\n"],
|
|
5
|
-
"mappings": "aAAA,IAAAA,EAGO,4CACPC,EAA6B,4CAE7BC,EAIO,qCAEP,MAAMC,EAAqC,WAAW,KAAK,CACzD,IAAM,GAAM,EAAM,EAAM,CAC1B,CAAC,EACKC,EAAkC,WAAW,KAAK,CACtD,IAAM,GAAM,EAAM,EAAM,CAC1B,CAAC,EACKC,EAAsC,WAAW,KAAK,CAC1D,IAAM,GAAM,EAAM,EAAM,CAC1B,CAAC,EACKC,EAAkC,WAAW,KAAK,CACtD,IAAM,GAAM,EAAM,EAAM,CAC1B,CAAC,EACKC,EAAgC,WAAW,KAAK,CACpD,IAAM,GAAM,EAAM,EAAM,CAC1B,CAAC,EAEKC,EAA0B,WAAW,KAAK,CAAC,GAAM,IAAM,CAAI,CAAC,EAC5DC,EAAuB,WAAW,KAAK,CAAC,GAAM,IAAM,IAAM,CAAI,CAAC,EAC/DC,EAA2B,WAAW,KAAK,CAAC,GAAM,IAAM,CAAI,CAAC,EAC7DC,EAAqB,WAAW,KAAK,CACzC,EAAM,EAAM,EAAM,GAAM,IAAM,CAChC,CAAC,EACKC,EAAsB,WAAW,KAAK,CAAC,IAAM,CAAI,CAAC,EAExD,SAAS,mBAAoB,IAAM,CACjC,SAAS,UAAW,IAAM,CACxB,GAAG,0CAA2C,IAAM,CAClD,OACE,IAAI,0BAAwB,CAC1B,WAAY,oBAAkB,kBAChC,CAAC,EACE,QAAQ,EACR,WAAW,CAChB,EAAE,
|
|
6
|
-
"names": ["import_CommandResult", "import_ApduResponse", "import_GetBatteryStatusCommand", "GET_BATTERY_STATUS_APDU_PERCENTAGE", "GET_BATTERY_STATUS_APDU_VOLTAGE", "GET_BATTERY_STATUS_APDU_TEMPERATURE", "GET_BATTERY_STATUS_APDU_CURRENT", "GET_BATTERY_STATUS_APDU_FLAGS", "PERCENTAGE_RESPONSE_HEX", "VOLTAGE_RESPONSE_HEX", "TEMPERATURE_RESPONSE_HEX", "FLAGS_RESPONSE_HEX", "FAILED_RESPONSE_HEX", "PERCENTAGE_RESPONSE", "parsed", "VOLTAGE_RESPONSE", "TEMPERATURE_RESPONSE", "FLAGS_RESPONSE", "FAILED_RESPONSE", "result"]
|
|
4
|
+
"sourcesContent": ["import {\n CommandResultFactory,\n isSuccessCommandResult,\n} from \"@api/command/model/CommandResult\";\nimport { ApduResponse } from \"@api/device-session/ApduResponse\";\n\nimport {\n BatteryStatusType,\n ChargingMode,\n GetBatteryStatusCommand,\n} from \"./GetBatteryStatusCommand\";\n\nconst GET_BATTERY_STATUS_APDU_PERCENTAGE = Uint8Array.from([\n 0xe0, 0x10, 0x00, 0x00, 0x00,\n]);\nconst GET_BATTERY_STATUS_APDU_VOLTAGE = Uint8Array.from([\n 0xe0, 0x10, 0x00, 0x01, 0x00,\n]);\nconst GET_BATTERY_STATUS_APDU_TEMPERATURE = Uint8Array.from([\n 0xe0, 0x10, 0x00, 0x02, 0x00,\n]);\nconst GET_BATTERY_STATUS_APDU_CURRENT = Uint8Array.from([\n 0xe0, 0x10, 0x00, 0x03, 0x00,\n]);\nconst GET_BATTERY_STATUS_APDU_FLAGS = Uint8Array.from([\n 0xe0, 0x10, 0x00, 0x04, 0x00,\n]);\n\nconst PERCENTAGE_RESPONSE_HEX = Uint8Array.from([0x37, 0x90, 0x00]);\nconst VOLTAGE_RESPONSE_HEX = Uint8Array.from([0x0f, 0xff, 0x90, 0x00]);\nconst TEMPERATURE_RESPONSE_HEX = Uint8Array.from([0x10, 0x90, 0x00]);\nconst FLAGS_RESPONSE_HEX = Uint8Array.from([\n 0x00, 0x00, 0x00, 0x0f, 0x90, 0x00,\n]);\nconst FAILED_RESPONSE_HEX = Uint8Array.from([0x67, 0x00]);\n\ndescribe(\"GetBatteryStatus\", () => {\n describe(\"name\", () => {\n it(\"should be 'getBatteryStatus'\", () => {\n const command = new GetBatteryStatusCommand({\n statusType: BatteryStatusType.BATTERY_PERCENTAGE,\n });\n expect(command.name).toBe(\"getBatteryStatus\");\n });\n });\n\n describe(\"getApdu\", () => {\n it(\"should return the GetBatteryStatus APDU\", () => {\n expect(\n new GetBatteryStatusCommand({\n statusType: BatteryStatusType.BATTERY_PERCENTAGE,\n })\n .getApdu()\n .getRawApdu(),\n ).toStrictEqual(GET_BATTERY_STATUS_APDU_PERCENTAGE);\n expect(\n new GetBatteryStatusCommand({\n statusType: BatteryStatusType.BATTERY_VOLTAGE,\n })\n .getApdu()\n .getRawApdu(),\n ).toStrictEqual(GET_BATTERY_STATUS_APDU_VOLTAGE);\n expect(\n new GetBatteryStatusCommand({\n statusType: BatteryStatusType.BATTERY_TEMPERATURE,\n })\n .getApdu()\n .getRawApdu(),\n ).toStrictEqual(GET_BATTERY_STATUS_APDU_TEMPERATURE);\n expect(\n new GetBatteryStatusCommand({\n statusType: BatteryStatusType.BATTERY_CURRENT,\n })\n .getApdu()\n .getRawApdu(),\n ).toStrictEqual(GET_BATTERY_STATUS_APDU_CURRENT);\n expect(\n new GetBatteryStatusCommand({\n statusType: BatteryStatusType.BATTERY_FLAGS,\n })\n .getApdu()\n .getRawApdu(),\n ).toStrictEqual(GET_BATTERY_STATUS_APDU_FLAGS);\n });\n });\n describe(\"parseResponse\", () => {\n it(\"should parse the response when querying percentage\", () => {\n const PERCENTAGE_RESPONSE = new ApduResponse({\n statusCode: PERCENTAGE_RESPONSE_HEX.slice(-2),\n data: PERCENTAGE_RESPONSE_HEX.slice(0, -2),\n });\n const command = new GetBatteryStatusCommand({\n statusType: BatteryStatusType.BATTERY_PERCENTAGE,\n });\n const parsed = command.parseResponse(PERCENTAGE_RESPONSE);\n expect(parsed).toStrictEqual(CommandResultFactory({ data: 55 }));\n });\n it(\"should parse the response when querying voltage\", () => {\n const VOLTAGE_RESPONSE = new ApduResponse({\n statusCode: VOLTAGE_RESPONSE_HEX.slice(-2),\n data: VOLTAGE_RESPONSE_HEX.slice(0, -2),\n });\n const command = new GetBatteryStatusCommand({\n statusType: BatteryStatusType.BATTERY_VOLTAGE,\n });\n const parsed = command.parseResponse(VOLTAGE_RESPONSE);\n expect(parsed).toStrictEqual(CommandResultFactory({ data: 4095 }));\n });\n it(\"should parse the response when querying temperature\", () => {\n const TEMPERATURE_RESPONSE = new ApduResponse({\n statusCode: TEMPERATURE_RESPONSE_HEX.slice(-2),\n data: TEMPERATURE_RESPONSE_HEX.slice(0, -2),\n });\n const command = new GetBatteryStatusCommand({\n statusType: BatteryStatusType.BATTERY_TEMPERATURE,\n });\n const parsed = command.parseResponse(TEMPERATURE_RESPONSE);\n expect(parsed).toStrictEqual(CommandResultFactory({ data: 16 }));\n });\n it(\"should parse the response when querying flags\", () => {\n const FLAGS_RESPONSE = new ApduResponse({\n statusCode: FLAGS_RESPONSE_HEX.slice(-2),\n data: FLAGS_RESPONSE_HEX.slice(0, -2),\n });\n const command = new GetBatteryStatusCommand({\n statusType: BatteryStatusType.BATTERY_FLAGS,\n });\n const parsed = command.parseResponse(FLAGS_RESPONSE);\n expect(parsed).toStrictEqual(\n CommandResultFactory({\n data: {\n charging: ChargingMode.USB,\n issueCharging: false,\n issueTemperature: false,\n issueBattery: false,\n },\n }),\n );\n });\n it(\"should return an error if the response returned unsupported format\", () => {\n const FAILED_RESPONSE = new ApduResponse({\n statusCode: FAILED_RESPONSE_HEX.slice(-2),\n data: FAILED_RESPONSE_HEX.slice(0, -2),\n });\n const command = new GetBatteryStatusCommand({\n statusType: BatteryStatusType.BATTERY_PERCENTAGE,\n });\n const result = command.parseResponse(FAILED_RESPONSE);\n expect(isSuccessC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AAoB,EACzD,OAAOF,CAAM,EAAE,iBAAc,wBAAqB,CAAE,KAAM,EAAG,CAAC,CAAC,CACjE,CAAC,EACD,GAAG,gDAAiD,IAAM,CACxD,MAAMG,EAAiB,IAAI,eAAa,CACtC,WAAYP,EAAmB,MAAM,EAAE,EACvC,KAAMA,EAAmB,MAAM,EAAG,EAAE,CACtC,CAAC,EAIKI,EAHU,IAAI,0BAAwB,CAC1C,WAAY,oBAAkB,aAChC,CAAC,EACsB,cAAcG,CAAc,EACnD,OAAOH,CAAM,EAAE,iBACb,wBAAqB,CACnB,KAAM,CACJ,SAAU,eAAa,IACvB,cAAe,GACf,iBAAkB,GAClB,aAAc,EAChB,CACF,CAAC,CACH,CACF,CAAC,EACD,GAAG,qEAAsE,IAAM,CAC7E,MAAMI,EAAkB,IAAI,eAAa,CACvC,WAAYP,EAAoB,MAAM,EAAE,EACxC,KAAMA,EAAoB,MAAM,EAAG,EAAE,CACvC,CAAC,EAIKQ,EAHU,IAAI,0BAAwB,CAC1C,WAAY,oBAAkB,kBAChC,CAAC,EACsB,cAAcD,CAAe,EACpD,UAAO,0BAAuBC,CAAM,CAAC,EAAE,UAAU,CACnD,CAAC,CACH,CAAC,CACH,CAAC",
|
|
6
|
+
"names": ["import_CommandResult", "import_ApduResponse", "import_GetBatteryStatusCommand", "GET_BATTERY_STATUS_APDU_PERCENTAGE", "GET_BATTERY_STATUS_APDU_VOLTAGE", "GET_BATTERY_STATUS_APDU_TEMPERATURE", "GET_BATTERY_STATUS_APDU_CURRENT", "GET_BATTERY_STATUS_APDU_FLAGS", "PERCENTAGE_RESPONSE_HEX", "VOLTAGE_RESPONSE_HEX", "TEMPERATURE_RESPONSE_HEX", "FLAGS_RESPONSE_HEX", "FAILED_RESPONSE_HEX", "command", "PERCENTAGE_RESPONSE", "parsed", "VOLTAGE_RESPONSE", "TEMPERATURE_RESPONSE", "FLAGS_RESPONSE", "FAILED_RESPONSE", "result"]
|
|
7
7
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";var a=Object.defineProperty;var
|
|
1
|
+
"use strict";var a=Object.defineProperty;var I=Object.getOwnPropertyDescriptor;var E=Object.getOwnPropertyNames;var S=Object.prototype.hasOwnProperty;var f=(r,e)=>{for(var o in e)a(r,o,{get:e[o],enumerable:!0})},z=(r,e,o,t)=>{if(e&&typeof e=="object"||typeof e=="function")for(let m of E(e))!S.call(r,m)&&m!==o&&a(r,m,{get:()=>e[m],enumerable:!(t=I(e,m))||t.enumerable});return r};var G=r=>z(a({},"__esModule",{value:!0}),r);var y={};f(y,{GetCustomImageSizeCommand:()=>A,GetCustomImageSizeCommandError:()=>c});module.exports=G(y);var d=require("../../apdu/utils/ApduBuilder"),i=require("../../apdu/utils/ApduParser"),u=require("../../command/Errors"),s=require("../../command/model/CommandResult"),p=require("../../command/utils/CommandErrors"),C=require("../../command/utils/CommandUtils"),g=require("../../command/utils/GlobalCommandError"),l=require("../../Error");const n={"662e":{message:"Invalid state, no background image loaded."},"662f":{message:"Invalid state, device is in recovery mode."}};class c extends l.DeviceExchangeError{constructor({message:e,errorCode:o}){super({message:e,errorCode:o,tag:"GetCustomImageSizeCommandError"})}}class A{name="getCustomImageSize";getApdu(){const e={cla:224,ins:100,p1:0,p2:0};return new d.ApduBuilder(e).build()}parseResponse(e){const o=new i.ApduParser(e);if(!C.CommandUtils.isSuccessResponse(e)){const m=o.encodeToHexaString(e.statusCode);return(0,p.isCommandErrorCode)(m,n)?(0,s.CommandResultFactory)({error:new c({...n[m],errorCode:m})}):(0,s.CommandResultFactory)({error:g.GlobalCommandErrorHandler.handle(e)})}const t=o.extract32BitUInt();return t===void 0?(0,s.CommandResultFactory)({error:new u.InvalidStatusWordError("Didn't receive any size")}):(0,s.CommandResultFactory)({data:t})}}0&&(module.exports={GetCustomImageSizeCommand,GetCustomImageSizeCommandError});
|
|
2
2
|
//# sourceMappingURL=GetCustomImageSizeCommand.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../../src/api/command/os/GetCustomImageSizeCommand.ts"],
|
|
4
|
-
"sourcesContent": ["import { type Apdu } from \"@api/apdu/model/Apdu\";\nimport { ApduBuilder, type ApduBuilderArgs } from \"@api/apdu/utils/ApduBuilder\";\nimport { ApduParser } from \"@api/apdu/utils/ApduParser\";\nimport { type Command } from \"@api/command/Command\";\nimport { InvalidStatusWordError } from \"@api/command/Errors\";\nimport {\n type CommandResult,\n CommandResultFactory,\n} from \"@api/command/model/CommandResult\";\nimport {\n type CommandErrors,\n isCommandErrorCode,\n} from \"@api/command/utils/CommandErrors\";\nimport { CommandUtils } from \"@api/command/utils/CommandUtils\";\nimport { GlobalCommandErrorHandler } from \"@api/command/utils/GlobalCommandError\";\nimport { type ApduResponse } from \"@api/device-session/ApduResponse\";\nimport { type CommandErrorArgs, DeviceExchangeError } from \"@api/Error\";\n\nexport type GetCustomImageSizeResponse = number;\n\nexport type GetCustomImageSizeErrorCodes = \"662e\" | \"662f\";\n\nconst IMAGE_SIZE_ERRORS: CommandErrors<GetCustomImageSizeErrorCodes> = {\n \"662e\": { message: \"Invalid state, no background image loaded.\" },\n \"662f\": { message: \"Invalid state, device is in recovery mode.\" },\n};\n\nexport type GetCustomImageSizeCommandResult = CommandResult<\n GetCustomImageSizeResponse,\n GetCustomImageSizeErrorCodes\n>;\n\nexport class GetCustomImageSizeCommandError extends DeviceExchangeError<GetCustomImageSizeErrorCodes> {\n constructor({\n message,\n errorCode,\n }: CommandErrorArgs<GetCustomImageSizeErrorCodes>) {\n super({ message, errorCode, tag: \"GetCustomImageSizeCommandError\" });\n }\n}\n\nexport class GetCustomImageSizeCommand\n implements\n Command<GetCustomImageSizeResponse, void, GetCustomImageSizeErrorCodes>\n{\n getApdu(): Apdu {\n const apduArgs: ApduBuilderArgs = {\n cla: 0xe0,\n ins: 0x64,\n p1: 0x00,\n p2: 0x00,\n };\n return new ApduBuilder(apduArgs).build();\n }\n\n parseResponse(apduResponse: ApduResponse): GetCustomImageSizeCommandResult {\n const parser = new ApduParser(apduResponse);\n\n if (!CommandUtils.isSuccessResponse(apduResponse)) {\n const errorCode = parser.encodeToHexaString(apduResponse.statusCode);\n if (isCommandErrorCode(errorCode, IMAGE_SIZE_ERRORS)) {\n return CommandResultFactory({\n error: new GetCustomImageSizeCommandError({\n ...IMAGE_SIZE_ERRORS[errorCode],\n errorCode,\n }),\n });\n }\n return CommandResultFactory({\n error: GlobalCommandErrorHandler.handle(apduResponse),\n });\n }\n\n const size = parser.extract32BitUInt();\n if (size === undefined) {\n return CommandResultFactory({\n error: new InvalidStatusWordError(\"Didn't receive any size\"),\n });\n }\n\n return CommandResultFactory({\n data: size,\n });\n }\n}\n"],
|
|
5
|
-
"mappings": "yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,+BAAAE,EAAA,mCAAAC,IAAA,eAAAC,EAAAJ,GACA,IAAAK,EAAkD,uCAClDC,EAA2B,sCAE3BC,EAAuC,+BACvCC,EAGO,4CACPC,EAGO,4CACPC,EAA6B,2CAC7BC,EAA0C,iDAE1CC,EAA2D,sBAM3D,MAAMC,EAAiE,CACrE,OAAQ,CAAE,QAAS,4CAA6C,EAChE,OAAQ,CAAE,QAAS,4CAA6C,CAClE,EAOO,MAAMV,UAAuC,qBAAkD,CACpG,YAAY,CACV,QAAAW,EACA,UAAAC,CACF,EAAmD,CACjD,MAAM,CAAE,QAAAD,EAAS,UAAAC,EAAW,IAAK,gCAAiC,CAAC,CACrE,CACF,CAEO,MAAMb,CAGb,
|
|
4
|
+
"sourcesContent": ["import { type Apdu } from \"@api/apdu/model/Apdu\";\nimport { ApduBuilder, type ApduBuilderArgs } from \"@api/apdu/utils/ApduBuilder\";\nimport { ApduParser } from \"@api/apdu/utils/ApduParser\";\nimport { type Command } from \"@api/command/Command\";\nimport { InvalidStatusWordError } from \"@api/command/Errors\";\nimport {\n type CommandResult,\n CommandResultFactory,\n} from \"@api/command/model/CommandResult\";\nimport {\n type CommandErrors,\n isCommandErrorCode,\n} from \"@api/command/utils/CommandErrors\";\nimport { CommandUtils } from \"@api/command/utils/CommandUtils\";\nimport { GlobalCommandErrorHandler } from \"@api/command/utils/GlobalCommandError\";\nimport { type ApduResponse } from \"@api/device-session/ApduResponse\";\nimport { type CommandErrorArgs, DeviceExchangeError } from \"@api/Error\";\n\nexport type GetCustomImageSizeResponse = number;\n\nexport type GetCustomImageSizeErrorCodes = \"662e\" | \"662f\";\n\nconst IMAGE_SIZE_ERRORS: CommandErrors<GetCustomImageSizeErrorCodes> = {\n \"662e\": { message: \"Invalid state, no background image loaded.\" },\n \"662f\": { message: \"Invalid state, device is in recovery mode.\" },\n};\n\nexport type GetCustomImageSizeCommandResult = CommandResult<\n GetCustomImageSizeResponse,\n GetCustomImageSizeErrorCodes\n>;\n\nexport class GetCustomImageSizeCommandError extends DeviceExchangeError<GetCustomImageSizeErrorCodes> {\n constructor({\n message,\n errorCode,\n }: CommandErrorArgs<GetCustomImageSizeErrorCodes>) {\n super({ message, errorCode, tag: \"GetCustomImageSizeCommandError\" });\n }\n}\n\nexport class GetCustomImageSizeCommand\n implements\n Command<GetCustomImageSizeResponse, void, GetCustomImageSizeErrorCodes>\n{\n readonly name = \"getCustomImageSize\";\n\n getApdu(): Apdu {\n const apduArgs: ApduBuilderArgs = {\n cla: 0xe0,\n ins: 0x64,\n p1: 0x00,\n p2: 0x00,\n };\n return new ApduBuilder(apduArgs).build();\n }\n\n parseResponse(apduResponse: ApduResponse): GetCustomImageSizeCommandResult {\n const parser = new ApduParser(apduResponse);\n\n if (!CommandUtils.isSuccessResponse(apduResponse)) {\n const errorCode = parser.encodeToHexaString(apduResponse.statusCode);\n if (isCommandErrorCode(errorCode, IMAGE_SIZE_ERRORS)) {\n return CommandResultFactory({\n error: new GetCustomImageSizeCommandError({\n ...IMAGE_SIZE_ERRORS[errorCode],\n errorCode,\n }),\n });\n }\n return CommandResultFactory({\n error: GlobalCommandErrorHandler.handle(apduResponse),\n });\n }\n\n const size = parser.extract32BitUInt();\n if (size === undefined) {\n return CommandResultFactory({\n error: new InvalidStatusWordError(\"Didn't receive any size\"),\n });\n }\n\n return CommandResultFactory({\n data: size,\n });\n }\n}\n"],
|
|
5
|
+
"mappings": "yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,+BAAAE,EAAA,mCAAAC,IAAA,eAAAC,EAAAJ,GACA,IAAAK,EAAkD,uCAClDC,EAA2B,sCAE3BC,EAAuC,+BACvCC,EAGO,4CACPC,EAGO,4CACPC,EAA6B,2CAC7BC,EAA0C,iDAE1CC,EAA2D,sBAM3D,MAAMC,EAAiE,CACrE,OAAQ,CAAE,QAAS,4CAA6C,EAChE,OAAQ,CAAE,QAAS,4CAA6C,CAClE,EAOO,MAAMV,UAAuC,qBAAkD,CACpG,YAAY,CACV,QAAAW,EACA,UAAAC,CACF,EAAmD,CACjD,MAAM,CAAE,QAAAD,EAAS,UAAAC,EAAW,IAAK,gCAAiC,CAAC,CACrE,CACF,CAEO,MAAMb,CAGb,CACW,KAAO,qBAEhB,SAAgB,CACd,MAAMc,EAA4B,CAChC,IAAK,IACL,IAAK,IACL,GAAI,EACJ,GAAI,CACN,EACA,OAAO,IAAI,cAAYA,CAAQ,EAAE,MAAM,CACzC,CAEA,cAAcC,EAA6D,CACzE,MAAMC,EAAS,IAAI,aAAWD,CAAY,EAE1C,GAAI,CAAC,eAAa,kBAAkBA,CAAY,EAAG,CACjD,MAAMF,EAAYG,EAAO,mBAAmBD,EAAa,UAAU,EACnE,SAAI,sBAAmBF,EAAWF,CAAiB,KAC1C,wBAAqB,CAC1B,MAAO,IAAIV,EAA+B,CACxC,GAAGU,EAAkBE,CAAS,EAC9B,UAAAA,CACF,CAAC,CACH,CAAC,KAEI,wBAAqB,CAC1B,MAAO,4BAA0B,OAAOE,CAAY,CACtD,CAAC,CACH,CAEA,MAAME,EAAOD,EAAO,iBAAiB,EACrC,OAAIC,IAAS,UACJ,wBAAqB,CAC1B,MAAO,IAAI,yBAAuB,yBAAyB,CAC7D,CAAC,KAGI,wBAAqB,CAC1B,KAAMA,CACR,CAAC,CACH,CACF",
|
|
6
6
|
"names": ["GetCustomImageSizeCommand_exports", "__export", "GetCustomImageSizeCommand", "GetCustomImageSizeCommandError", "__toCommonJS", "import_ApduBuilder", "import_ApduParser", "import_Errors", "import_CommandResult", "import_CommandErrors", "import_CommandUtils", "import_GlobalCommandError", "import_Error", "IMAGE_SIZE_ERRORS", "message", "errorCode", "apduArgs", "apduResponse", "parser", "size"]
|
|
7
7
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";var n=require("../../command/Errors"),r=require("../../command/model/CommandResult"),a=require("../../command/model/CommandResult"),i=require("../../command/os/GetCustomImageSizeCommand"),o=require("../../device-session/ApduResponse");const
|
|
1
|
+
"use strict";var n=require("../../command/Errors"),r=require("../../command/model/CommandResult"),a=require("../../command/model/CommandResult"),i=require("../../command/os/GetCustomImageSizeCommand"),o=require("../../device-session/ApduResponse");const m=new Uint8Array([224,100,0,0,0]);describe("GetCustomImageSizeCommand",()=>{let t;beforeEach(()=>{t=new i.GetCustomImageSizeCommand}),describe("name",()=>{it("should be 'getCustomImageSize'",()=>{expect(t.name).toBe("getCustomImageSize")})}),it("should return the correct APDU",()=>{const e=t.getApdu();expect(e.getRawApdu()).toStrictEqual(m)}),it("should parse result successfully",()=>{const e=new o.ApduResponse({statusCode:new Uint8Array([144,0]),data:new Uint8Array([0,0,137,233])}),s=t.parseResponse(e);expect(s).toStrictEqual((0,r.CommandResultFactory)({data:35305}))}),it("should fail on invalid size",()=>{const e=new o.ApduResponse({statusCode:new Uint8Array([144,0]),data:new Uint8Array([233])}),s=t.parseResponse(e);expect(s).toStrictEqual((0,r.CommandResultFactory)({error:new n.InvalidStatusWordError("Didn't receive any size")}))}),it("should fail on device error",()=>{const e=new o.ApduResponse({statusCode:new Uint8Array([102,46]),data:new Uint8Array([])}),s=t.parseResponse(e);expect((0,a.isSuccessCommandResult)(s)).toBeFalsy()})});
|
|
2
2
|
//# sourceMappingURL=GetCustomImageSizeCommand.test.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../../src/api/command/os/GetCustomImageSizeCommand.test.ts"],
|
|
4
|
-
"sourcesContent": ["import { InvalidStatusWordError } from \"@api/command/Errors\";\nimport { CommandResultFactory } from \"@api/command/model/CommandResult\";\nimport { isSuccessCommandResult } from \"@api/command/model/CommandResult\";\nimport { GetCustomImageSizeCommand } from \"@api/command/os/GetCustomImageSizeCommand\";\nimport { ApduResponse } from \"@api/device-session/ApduResponse\";\n\nconst IMAGE_SIZE_APDU = new Uint8Array([0xe0, 0x64, 0x00, 0x00, 0x00]);\n\ndescribe(\"GetCustomImageSizeCommand\", () => {\n let command: GetCustomImageSizeCommand;\n\n beforeEach(() => {\n command = new GetCustomImageSizeCommand();\n });\n\n it(\"should return the correct APDU\", () => {\n const apdu = command.getApdu();\n expect(apdu.getRawApdu()).toStrictEqual(IMAGE_SIZE_APDU);\n });\n\n it(\"should parse result successfully\", () => {\n const response: ApduResponse = new ApduResponse({\n statusCode: new Uint8Array([0x90, 0x00]),\n data: new Uint8Array([0x00, 0x00, 0x89, 0xe9]),\n });\n const result = command.parseResponse(response);\n expect(result).toStrictEqual(\n CommandResultFactory({\n data: 35305,\n }),\n );\n });\n\n it(\"should fail on invalid size\", () => {\n const response: ApduResponse = new ApduResponse({\n statusCode: new Uint8Array([0x90, 0x00]),\n data: new Uint8Array([0xe9]),\n });\n const result = command.parseResponse(response);\n expect(result).toStrictEqual(\n CommandResultFactory({\n error: new InvalidStatusWordError(\"Didn't receive any size\"),\n }),\n );\n });\n\n it(\"should fail on device error\", () => {\n const response: ApduResponse = new ApduResponse({\n statusCode: new Uint8Array([0x66, 0x2e]),\n data: new Uint8Array([]),\n });\n const result = command.parseResponse(response);\n expect(isSuccessCommandResult(result)).toBeFalsy();\n });\n});\n"],
|
|
5
|
-
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CAAC",
|
|
4
|
+
"sourcesContent": ["import { InvalidStatusWordError } from \"@api/command/Errors\";\nimport { CommandResultFactory } from \"@api/command/model/CommandResult\";\nimport { isSuccessCommandResult } from \"@api/command/model/CommandResult\";\nimport { GetCustomImageSizeCommand } from \"@api/command/os/GetCustomImageSizeCommand\";\nimport { ApduResponse } from \"@api/device-session/ApduResponse\";\n\nconst IMAGE_SIZE_APDU = new Uint8Array([0xe0, 0x64, 0x00, 0x00, 0x00]);\n\ndescribe(\"GetCustomImageSizeCommand\", () => {\n let command: GetCustomImageSizeCommand;\n\n beforeEach(() => {\n command = new GetCustomImageSizeCommand();\n });\n\n describe(\"name\", () => {\n it(\"should be 'getCustomImageSize'\", () => {\n expect(command.name).toBe(\"getCustomImageSize\");\n });\n });\n\n it(\"should return the correct APDU\", () => {\n const apdu = command.getApdu();\n expect(apdu.getRawApdu()).toStrictEqual(IMAGE_SIZE_APDU);\n });\n\n it(\"should parse result successfully\", () => {\n const response: ApduResponse = new ApduResponse({\n statusCode: new Uint8Array([0x90, 0x00]),\n data: new Uint8Array([0x00, 0x00, 0x89, 0xe9]),\n });\n const result = command.parseResponse(response);\n expect(result).toStrictEqual(\n CommandResultFactory({\n data: 35305,\n }),\n );\n });\n\n it(\"should fail on invalid size\", () => {\n const response: ApduResponse = new ApduResponse({\n statusCode: new Uint8Array([0x90, 0x00]),\n data: new Uint8Array([0xe9]),\n });\n const result = command.parseResponse(response);\n expect(result).toStrictEqual(\n CommandResultFactory({\n error: new InvalidStatusWordError(\"Didn't receive any size\"),\n }),\n );\n });\n\n it(\"should fail on device error\", () => {\n const response: ApduResponse = new ApduResponse({\n statusCode: new Uint8Array([0x66, 0x2e]),\n data: new Uint8Array([]),\n });\n const result = command.parseResponse(response);\n expect(isSuccessCommandResult(result)).toBeFalsy();\n });\n});\n"],
|
|
5
|
+
"mappings": "aAAA,IAAAA,EAAuC,+BACvCC,EAAqC,4CACrCA,EAAuC,4CACvCC,EAA0C,qDAC1CC,EAA6B,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EAAE,UAAU,CACnD,CAAC,CACH,CAAC",
|
|
6
6
|
"names": ["import_Errors", "import_CommandResult", "import_GetCustomImageSizeCommand", "import_ApduResponse", "IMAGE_SIZE_APDU", "command", "apdu", "response", "result"]
|
|
7
7
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";var g=Object.defineProperty;var w=Object.getOwnPropertyDescriptor;var T=Object.getOwnPropertyNames;var B=Object.prototype.hasOwnProperty;var L=(d,r)=>{for(var n in r)g(d,n,{get:r[n],enumerable:!0})},R=(d,r,n,e)=>{if(r&&typeof r=="object"||typeof r=="function")for(let s of T(r))!B.call(d,s)&&s!==n&&g(d,s,{get:()=>r[s],enumerable:!(e=w(r,s))||e.enumerable});return d};var D=d=>R(g({},"__esModule",{value:!0}),d);var G={};L(G,{GetOsVersionCommand:()=>C});module.exports=D(G);var t=require("semver"),I=require("../../apdu/utils/ApduBuilder"),v=require("../../apdu/utils/ApduParser"),O=require("../../command/Errors"),c=require("../../command/model/CommandResult"),b=require("../../command/utils/CommandUtils"),F=require("../../command/utils/GlobalCommandError"),o=require("../../device/DeviceModel"),N=require("./SecureElementFlagsParser");class C{args=void 0;getApdu(){const r={cla:224,ins:1,p1:0,p2:0};return new I.ApduBuilder(r).build()}parseResponse(r,n){if(!b.CommandUtils.isSuccessResponse(r))return(0,c.CommandResultFactory)({error:F.GlobalCommandErrorHandler.handle(r)});const e=new v.ApduParser(r),s=e.extract32BitUInt();if(s===void 0)return(0,c.CommandResultFactory)({error:new O.InvalidStatusWordError("Missing target ID in OS version")});let l=e.encodeToString(e.extractFieldLVEncoded()),m=e.extractFieldLVEncoded()??new Uint8Array(0);const E={...new N.SecureElementFlagsParser(m).generalDeviceState()};l||(l="0.0.0",m=new Uint8Array);const S=(s&4026531840)!==805306368,h=l.includes("-osu");let a="",y="",p="",f="",V,u,A,x;if(S){p=l,V=s;const i=e.extractFieldLVEncoded();i&&(i.length>=5?(a=e.encodeToString(i),u=parseInt(e.encodeToHexaString(e.extractFieldLVEncoded()),16)):u=parseInt(e.encodeToHexaString(i),16))}else{if(a=l,u=s,y=e.encodeToString(e.extractFieldLVEncoded()),this.isBootloaderVersionSupported(a,n)&&(p=e.encodeToString(e.extractFieldLVEncoded())),this.isHardwareVersionSupported(a,n)?f=e.encodeToHexaString(e.extractFieldLVEncoded()):f="00",this.isLocalizationSupported(a,n)){const i=e.extractFieldLVEncoded();i!==void 0&&(A=parseInt(e.encodeToHexaString(i),16))}if(this.isRecoverSupported(a,n)){const i=e.extractFieldLVEncoded();i!==void 0&&(x=parseInt(e.encodeToHexaString(i),16))}}return(0,c.CommandResultFactory)({data:{isBootloader:S,isOsu:h,targetId:s,seTargetId:u,mcuTargetId:V,seVersion:a,seFlags:m,mcuSephVersion:y,mcuBootloaderVersion:p,hwVersion:f,langId:A,recoverState:x,secureElementFlags:E}})}isBootloaderVersionSupported(r,n){const e=(0,t.coerce)(r)??"";switch(n){case o.DeviceModelId.NANO_S:case o.DeviceModelId.NANO_X:return(0,t.gte)(e,"2.0.0");default:return!0}}isHardwareVersionSupported(r,n){const e=(0,t.coerce)(r)??"";switch(n){case o.DeviceModelId.NANO_X:return(0,t.gte)(e,"2.0.0");default:return!1}}isLocalizationSupported(r,n){const e=(0,t.coerce)(r)??"";switch(n){case o.DeviceModelId.NANO_S:return!1;case o.DeviceModelId.NANO_SP:return(0,t.gte)(e,"1.1.0");case o.DeviceModelId.NANO_X:return(0,t.gte)(e,"2.1.0");default:return!0}}isRecoverSupported(r,n){const e=(0,t.coerce)(r)??"";switch(n){case o.DeviceModelId.NANO_S:return!1;case o.DeviceModelId.NANO_SP:return(0,t.gte)(e,"1.1.2");case o.DeviceModelId.NANO_X:return(0,t.gte)(e,"2.2.3");case o.DeviceModelId.STAX:return(0,t.gte)(e,"1.4.0");case o.DeviceModelId.FLEX:return(0,t.gte)(e,"1.0.1");default:return!0}}}0&&(module.exports={GetOsVersionCommand});
|
|
1
|
+
"use strict";var g=Object.defineProperty;var w=Object.getOwnPropertyDescriptor;var T=Object.getOwnPropertyNames;var B=Object.prototype.hasOwnProperty;var L=(d,r)=>{for(var n in r)g(d,n,{get:r[n],enumerable:!0})},R=(d,r,n,e)=>{if(r&&typeof r=="object"||typeof r=="function")for(let s of T(r))!B.call(d,s)&&s!==n&&g(d,s,{get:()=>r[s],enumerable:!(e=w(r,s))||e.enumerable});return d};var D=d=>R(g({},"__esModule",{value:!0}),d);var G={};L(G,{GetOsVersionCommand:()=>C});module.exports=D(G);var t=require("semver"),I=require("../../apdu/utils/ApduBuilder"),v=require("../../apdu/utils/ApduParser"),O=require("../../command/Errors"),c=require("../../command/model/CommandResult"),b=require("../../command/utils/CommandUtils"),F=require("../../command/utils/GlobalCommandError"),o=require("../../device/DeviceModel"),N=require("./SecureElementFlagsParser");class C{name="getOsVersion";args=void 0;getApdu(){const r={cla:224,ins:1,p1:0,p2:0};return new I.ApduBuilder(r).build()}parseResponse(r,n){if(!b.CommandUtils.isSuccessResponse(r))return(0,c.CommandResultFactory)({error:F.GlobalCommandErrorHandler.handle(r)});const e=new v.ApduParser(r),s=e.extract32BitUInt();if(s===void 0)return(0,c.CommandResultFactory)({error:new O.InvalidStatusWordError("Missing target ID in OS version")});let l=e.encodeToString(e.extractFieldLVEncoded()),m=e.extractFieldLVEncoded()??new Uint8Array(0);const E={...new N.SecureElementFlagsParser(m).generalDeviceState()};l||(l="0.0.0",m=new Uint8Array);const S=(s&4026531840)!==805306368,h=l.includes("-osu");let a="",y="",p="",f="",V,u,A,x;if(S){p=l,V=s;const i=e.extractFieldLVEncoded();i&&(i.length>=5?(a=e.encodeToString(i),u=parseInt(e.encodeToHexaString(e.extractFieldLVEncoded()),16)):u=parseInt(e.encodeToHexaString(i),16))}else{if(a=l,u=s,y=e.encodeToString(e.extractFieldLVEncoded()),this.isBootloaderVersionSupported(a,n)&&(p=e.encodeToString(e.extractFieldLVEncoded())),this.isHardwareVersionSupported(a,n)?f=e.encodeToHexaString(e.extractFieldLVEncoded()):f="00",this.isLocalizationSupported(a,n)){const i=e.extractFieldLVEncoded();i!==void 0&&(A=parseInt(e.encodeToHexaString(i),16))}if(this.isRecoverSupported(a,n)){const i=e.extractFieldLVEncoded();i!==void 0&&(x=parseInt(e.encodeToHexaString(i),16))}}return(0,c.CommandResultFactory)({data:{isBootloader:S,isOsu:h,targetId:s,seTargetId:u,mcuTargetId:V,seVersion:a,seFlags:m,mcuSephVersion:y,mcuBootloaderVersion:p,hwVersion:f,langId:A,recoverState:x,secureElementFlags:E}})}isBootloaderVersionSupported(r,n){const e=(0,t.coerce)(r)??"";switch(n){case o.DeviceModelId.NANO_S:case o.DeviceModelId.NANO_X:return(0,t.gte)(e,"2.0.0");default:return!0}}isHardwareVersionSupported(r,n){const e=(0,t.coerce)(r)??"";switch(n){case o.DeviceModelId.NANO_X:return(0,t.gte)(e,"2.0.0");default:return!1}}isLocalizationSupported(r,n){const e=(0,t.coerce)(r)??"";switch(n){case o.DeviceModelId.NANO_S:return!1;case o.DeviceModelId.NANO_SP:return(0,t.gte)(e,"1.1.0");case o.DeviceModelId.NANO_X:return(0,t.gte)(e,"2.1.0");default:return!0}}isRecoverSupported(r,n){const e=(0,t.coerce)(r)??"";switch(n){case o.DeviceModelId.NANO_S:return!1;case o.DeviceModelId.NANO_SP:return(0,t.gte)(e,"1.1.2");case o.DeviceModelId.NANO_X:return(0,t.gte)(e,"2.2.3");case o.DeviceModelId.STAX:return(0,t.gte)(e,"1.4.0");case o.DeviceModelId.FLEX:return(0,t.gte)(e,"1.0.1");default:return!0}}}0&&(module.exports={GetOsVersionCommand});
|
|
2
2
|
//# sourceMappingURL=GetOsVersionCommand.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../../src/api/command/os/GetOsVersionCommand.ts"],
|
|
4
|
-
"sourcesContent": ["import { coerce, gte } from \"semver\";\n\nimport { type Apdu } from \"@api/apdu/model/Apdu\";\nimport { ApduBuilder, type ApduBuilderArgs } from \"@api/apdu/utils/ApduBuilder\";\nimport { ApduParser } from \"@api/apdu/utils/ApduParser\";\nimport { type Command } from \"@api/command/Command\";\nimport { InvalidStatusWordError } from \"@api/command/Errors\";\nimport {\n type CommandResult,\n CommandResultFactory,\n} from \"@api/command/model/CommandResult\";\nimport { CommandUtils } from \"@api/command/utils/CommandUtils\";\nimport { GlobalCommandErrorHandler } from \"@api/command/utils/GlobalCommandError\";\nimport { DeviceModelId } from \"@api/device/DeviceModel\";\nimport {\n type DeviceGeneralState,\n type EndorsementInformation,\n type OnboardingStatus,\n type WordsInformation,\n} from \"@api/device/SecureElementFlags\";\nimport { type ApduResponse } from \"@api/device-session/ApduResponse\";\n\nimport { SecureElementFlagsParser } from \"./SecureElementFlagsParser\";\n\n/**\n * Response of the GetOsVersionCommand.\n */\nexport type GetOsVersionResponse = {\n /**\n * Indicated if the device is running in bootloader mode.\n * It can happens during a firmware update process.\n */\n readonly isBootloader: boolean;\n\n /**\n * Indicated if the device firmware is an OS Updater (OSU).\n * It can happens during a firmware update process.\n */\n readonly isOsu: boolean;\n\n /**\n * Target identifier.\n */\n readonly targetId: number;\n\n /**\n * Target identifier of the secure element.\n * Not always available when the device is in bootloader mode.\n */\n readonly seTargetId: number | undefined;\n\n /**\n * Target identifier of the microcontroller unit (MCU).\n * Only available when the device is in bootloader mode.\n */\n readonly mcuTargetId: number | undefined;\n\n /**\n * Version of BOLOS on the secure element (SE).\n * {@link https://developers.ledger.com/docs/device-app/architecture/bolos/hardware-architecture | Hardware Architecture}\n */\n readonly seVersion: string;\n\n /**\n * Secure element flags.\n * Used to represent the current state of the secure element.\n */\n readonly seFlags: Uint8Array;\n\n /**\n * Version of the microcontroller unit (MCU) SEPH, which is the SE-MCU link protocol.\n * {@link https://developers.ledger.com/docs/device-app/architecture/bolos/hardware-architecture | Hardware Architecture}\n */\n readonly mcuSephVersion: string;\n\n /**\n * Version of the MCU bootloader.\n */\n readonly mcuBootloaderVersion: string;\n\n /**\n * Hardware revision version.\n * Only available for Ledger Nano X in which case it's \"00\" or \"01\".\n */\n readonly hwVersion: string;\n\n /**\n * Identifier of the installed language pack.\n * Can be one of:\n * - \"00\": English\n * - \"01\": French\n * - \"02\": Spanish\n * - \"03\": Portuguese\n * - \"04\": German\n * - \"05\": Russian\n * - \"06\": Turkish\n */\n readonly langId: number | undefined;\n\n /**\n * State for Ledger Recover. // [SHOULD] Add more information about this field\n */\n readonly recoverState: number | undefined;\n\n /**\n * The parsed secure element flags.\n */\n readonly secureElementFlags: DeviceGeneralState &\n EndorsementInformation &\n WordsInformation &\n OnboardingStatus;\n};\n\nexport type GetOsVersionCommandResult = CommandResult<GetOsVersionResponse>;\n\n/**\n * Command to get information about the device firmware.\n */\nexport class GetOsVersionCommand implements Command<GetOsVersionResponse> {\n readonly args = undefined;\n\n getApdu(): Apdu {\n const getOsVersionApduArgs: ApduBuilderArgs = {\n cla: 0xe0,\n ins: 0x01,\n p1: 0x00,\n p2: 0x00,\n };\n return new ApduBuilder(getOsVersionApduArgs).build();\n }\n\n parseResponse(\n apduResponse: ApduResponse,\n deviceModelId: DeviceModelId,\n ): GetOsVersionCommandResult {\n if (!CommandUtils.isSuccessResponse(apduResponse)) {\n return CommandResultFactory({\n error: GlobalCommandErrorHandler.handle(apduResponse),\n });\n }\n const parser = new ApduParser(apduResponse);\n const targetId = parser.extract32BitUInt();\n if (targetId === undefined) {\n return CommandResultFactory({\n error: new InvalidStatusWordError(\"Missing target ID in OS version\"),\n });\n }\n\n let version = parser.encodeToString(parser.extractFieldLVEncoded());\n let seFlags = parser.extractFieldLVEncoded() ?? new Uint8Array(0);\n const seFlagsParser = new SecureElementFlagsParser(seFlags);\n // This is the parsed secure element flags.\n const secureElementFlags = { ...seFlagsParser.generalDeviceState() };\n\n // Handle old firmwares with no version\n if (!version) {\n version = \"0.0.0\";\n seFlags = new Uint8Array();\n }\n\n const isBootloader = (targetId & 0xf0000000) !== 0x30000000;\n const isOsu = version.includes(\"-osu\");\n let seVersion: string = \"\";\n let mcuSephVersion: string = \"\";\n let mcuBootloaderVersion: string = \"\";\n let hwVersion: string = \"\";\n let mcuTargetId: number | undefined = undefined;\n let seTargetId: number | undefined = undefined;\n let langId: number | undefined = undefined;\n let recoverState: number | undefined = undefined;\n\n if (isBootloader) {\n mcuBootloaderVersion = version;\n mcuTargetId = targetId;\n\n const seData = parser.extractFieldLVEncoded();\n if (seData) {\n if (seData.length >= 5) {\n // It means it's a version followed by the seTargetId\n seVersion = parser.encodeToString(seData);\n seTargetId = parseInt(\n parser.encodeToHexaString(parser.extractFieldLVEncoded()),\n 16,\n );\n } else {\n // It's the seTargetId\n seTargetId = parseInt(parser.encodeToHexaString(seData), 16);\n }\n }\n } else {\n seVersion = version;\n seTargetId = targetId;\n\n mcuSephVersion = parser.encodeToString(parser.extractFieldLVEncoded());\n\n if (this.isBootloaderVersionSupported(seVersion, deviceModelId)) {\n mcuBootloaderVersion = parser.encodeToString(\n parser.extractFieldLVEncoded(),\n );\n }\n\n if (this.isHardwareVersionSupported(seVersion, deviceModelId)) {\n hwVersion = parser.encodeToHexaString(parser.extractFieldLVEncoded());\n } else {\n hwVersion = \"00\";\n }\n\n if (this.isLocalizationSupported(seVersion, deviceModelId)) {\n const langIdBuffer = parser.extractFieldLVEncoded();\n if (langIdBuffer !== undefined) {\n langId = parseInt(parser.encodeToHexaString(langIdBuffer), 16);\n }\n }\n\n if (this.isRecoverSupported(seVersion, deviceModelId)) {\n const recoverStateBuffer = parser.extractFieldLVEncoded();\n if (recoverStateBuffer !== undefined) {\n recoverState = parseInt(\n parser.encodeToHexaString(recoverStateBuffer),\n 16,\n );\n }\n }\n }\n\n return CommandResultFactory({\n data: {\n isBootloader,\n isOsu,\n targetId,\n seTargetId,\n mcuTargetId,\n seVersion,\n seFlags,\n mcuSephVersion,\n mcuBootloaderVersion,\n hwVersion,\n langId,\n recoverState,\n secureElementFlags,\n },\n });\n }\n\n private isBootloaderVersionSupported(\n seVersion: string,\n deviceModelId: DeviceModelId,\n ): boolean {\n const version = coerce(seVersion) ?? \"\";\n switch (deviceModelId) {\n case DeviceModelId.NANO_S:\n case DeviceModelId.NANO_X:\n return gte(version, \"2.0.0\");\n default:\n return true;\n }\n }\n\n private isHardwareVersionSupported(\n seVersion: string,\n deviceModelId: DeviceModelId,\n ): boolean {\n const version = coerce(seVersion) ?? \"\";\n switch (deviceModelId) {\n case DeviceModelId.NANO_X:\n return gte(version, \"2.0.0\");\n default:\n return false;\n }\n }\n\n private isLocalizationSupported(\n seVersion: string,\n deviceModelId: DeviceModelId,\n ): boolean {\n const version = coerce(seVersion) ?? \"\";\n switch (deviceModelId) {\n case DeviceModelId.NANO_S:\n return false;\n case DeviceModelId.NANO_SP:\n return gte(version, \"1.1.0\");\n case DeviceModelId.NANO_X:\n return gte(version, \"2.1.0\");\n default:\n return true;\n }\n }\n\n private isRecoverSupported(\n seVersion: string,\n deviceModelId: DeviceModelId,\n ): boolean {\n const version = coerce(seVersion) ?? \"\";\n switch (deviceModelId) {\n case DeviceModelId.NANO_S:\n return false;\n case DeviceModelId.NANO_SP:\n return gte(version, \"1.1.2\");\n case DeviceModelId.NANO_X:\n return gte(version, \"2.2.3\");\n case DeviceModelId.STAX:\n return gte(version, \"1.4.0\");\n case DeviceModelId.FLEX:\n return gte(version, \"1.0.1\");\n default:\n return true;\n }\n }\n}\n"],
|
|
5
|
-
"mappings": "yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,yBAAAE,IAAA,eAAAC,EAAAH,GAAA,IAAAI,EAA4B,kBAG5BC,EAAkD,uCAClDC,EAA2B,sCAE3BC,EAAuC,+BACvCC,EAGO,4CACPC,EAA6B,2CAC7BC,EAA0C,iDAC1CC,EAA8B,mCAS9BC,EAAyC,sCAgGlC,MAAMV,CAA6D,CAC/D,KAAO,OAEhB,SAAgB,CACd,MAAMW,EAAwC,CAC5C,IAAK,IACL,IAAK,EACL,GAAI,EACJ,GAAI,CACN,EACA,OAAO,IAAI,cAAYA,CAAoB,EA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Ac,OACjB,MAAO,GACT,KAAK,gBAAc,QACjB,SAAO,OAAIG,EAAS,OAAO,EAC7B,KAAK,gBAAc,OACjB,SAAO,OAAIA,EAAS,OAAO,EAC7B,KAAK,gBAAc,KACjB,SAAO,OAAIA,EAAS,OAAO,EAC7B,KAAK,gBAAc,KACjB,SAAO,OAAIA,EAAS,OAAO,EAC7B,QACE,MAAO,EACX,CACF,CACF",
|
|
4
|
+
"sourcesContent": ["import { coerce, gte } from \"semver\";\n\nimport { type Apdu } from \"@api/apdu/model/Apdu\";\nimport { ApduBuilder, type ApduBuilderArgs } from \"@api/apdu/utils/ApduBuilder\";\nimport { ApduParser } from \"@api/apdu/utils/ApduParser\";\nimport { type Command } from \"@api/command/Command\";\nimport { InvalidStatusWordError } from \"@api/command/Errors\";\nimport {\n type CommandResult,\n CommandResultFactory,\n} from \"@api/command/model/CommandResult\";\nimport { CommandUtils } from \"@api/command/utils/CommandUtils\";\nimport { GlobalCommandErrorHandler } from \"@api/command/utils/GlobalCommandError\";\nimport { DeviceModelId } from \"@api/device/DeviceModel\";\nimport {\n type DeviceGeneralState,\n type EndorsementInformation,\n type OnboardingStatus,\n type WordsInformation,\n} from \"@api/device/SecureElementFlags\";\nimport { type ApduResponse } from \"@api/device-session/ApduResponse\";\n\nimport { SecureElementFlagsParser } from \"./SecureElementFlagsParser\";\n\n/**\n * Response of the GetOsVersionCommand.\n */\nexport type GetOsVersionResponse = {\n /**\n * Indicated if the device is running in bootloader mode.\n * It can happens during a firmware update process.\n */\n readonly isBootloader: boolean;\n\n /**\n * Indicated if the device firmware is an OS Updater (OSU).\n * It can happens during a firmware update process.\n */\n readonly isOsu: boolean;\n\n /**\n * Target identifier.\n */\n readonly targetId: number;\n\n /**\n * Target identifier of the secure element.\n * Not always available when the device is in bootloader mode.\n */\n readonly seTargetId: number | undefined;\n\n /**\n * Target identifier of the microcontroller unit (MCU).\n * Only available when the device is in bootloader mode.\n */\n readonly mcuTargetId: number | undefined;\n\n /**\n * Version of BOLOS on the secure element (SE).\n * {@link https://developers.ledger.com/docs/device-app/architecture/bolos/hardware-architecture | Hardware Architecture}\n */\n readonly seVersion: string;\n\n /**\n * Secure element flags.\n * Used to represent the current state of the secure element.\n */\n readonly seFlags: Uint8Array;\n\n /**\n * Version of the microcontroller unit (MCU) SEPH, which is the SE-MCU link protocol.\n * {@link https://developers.ledger.com/docs/device-app/architecture/bolos/hardware-architecture | Hardware Architecture}\n */\n readonly mcuSephVersion: string;\n\n /**\n * Version of the MCU bootloader.\n */\n readonly mcuBootloaderVersion: string;\n\n /**\n * Hardware revision version.\n * Only available for Ledger Nano X in which case it's \"00\" or \"01\".\n */\n readonly hwVersion: string;\n\n /**\n * Identifier of the installed language pack.\n * Can be one of:\n * - \"00\": English\n * - \"01\": French\n * - \"02\": Spanish\n * - \"03\": Portuguese\n * - \"04\": German\n * - \"05\": Russian\n * - \"06\": Turkish\n */\n readonly langId: number | undefined;\n\n /**\n * State for Ledger Recover. // [SHOULD] Add more information about this field\n */\n readonly recoverState: number | undefined;\n\n /**\n * The parsed secure element flags.\n */\n readonly secureElementFlags: DeviceGeneralState &\n EndorsementInformation &\n WordsInformation &\n OnboardingStatus;\n};\n\nexport type GetOsVersionCommandResult = CommandResult<GetOsVersionResponse>;\n\n/**\n * Command to get information about the device firmware.\n */\nexport class GetOsVersionCommand implements Command<GetOsVersionResponse> {\n readonly name = \"getOsVersion\";\n readonly args = undefined;\n\n getApdu(): Apdu {\n const getOsVersionApduArgs: ApduBuilderArgs = {\n cla: 0xe0,\n ins: 0x01,\n p1: 0x00,\n p2: 0x00,\n };\n return new ApduBuilder(getOsVersionApduArgs).build();\n }\n\n parseResponse(\n apduResponse: ApduResponse,\n deviceModelId: DeviceModelId,\n ): GetOsVersionCommandResult {\n if (!CommandUtils.isSuccessResponse(apduResponse)) {\n return CommandResultFactory({\n error: GlobalCommandErrorHandler.handle(apduResponse),\n });\n }\n const parser = new ApduParser(apduResponse);\n const targetId = parser.extract32BitUInt();\n if (targetId === undefined) {\n return CommandResultFactory({\n error: new InvalidStatusWordError(\"Missing target ID in OS version\"),\n });\n }\n\n let version = parser.encodeToString(parser.extractFieldLVEncoded());\n let seFlags = parser.extractFieldLVEncoded() ?? new Uint8Array(0);\n const seFlagsParser = new SecureElementFlagsParser(seFlags);\n // This is the parsed secure element flags.\n const secureElementFlags = { ...seFlagsParser.generalDeviceState() };\n\n // Handle old firmwares with no version\n if (!version) {\n version = \"0.0.0\";\n seFlags = new Uint8Array();\n }\n\n const isBootloader = (targetId & 0xf0000000) !== 0x30000000;\n const isOsu = version.includes(\"-osu\");\n let seVersion: string = \"\";\n let mcuSephVersion: string = \"\";\n let mcuBootloaderVersion: string = \"\";\n let hwVersion: string = \"\";\n let mcuTargetId: number | undefined = undefined;\n let seTargetId: number | undefined = undefined;\n let langId: number | undefined = undefined;\n let recoverState: number | undefined = undefined;\n\n if (isBootloader) {\n mcuBootloaderVersion = version;\n mcuTargetId = targetId;\n\n const seData = parser.extractFieldLVEncoded();\n if (seData) {\n if (seData.length >= 5) {\n // It means it's a version followed by the seTargetId\n seVersion = parser.encodeToString(seData);\n seTargetId = parseInt(\n parser.encodeToHexaString(parser.extractFieldLVEncoded()),\n 16,\n );\n } else {\n // It's the seTargetId\n seTargetId = parseInt(parser.encodeToHexaString(seData), 16);\n }\n }\n } else {\n seVersion = version;\n seTargetId = targetId;\n\n mcuSephVersion = parser.encodeToString(parser.extractFieldLVEncoded());\n\n if (this.isBootloaderVersionSupported(seVersion, deviceModelId)) {\n mcuBootloaderVersion = parser.encodeToString(\n parser.extractFieldLVEncoded(),\n );\n }\n\n if (this.isHardwareVersionSupported(seVersion, deviceModelId)) {\n hwVersion = parser.encodeToHexaString(parser.extractFieldLVEncoded());\n } else {\n hwVersion = \"00\";\n }\n\n if (this.isLocalizationSupported(seVersion, deviceModelId)) {\n const langIdBuffer = parser.extractFieldLVEncoded();\n if (langIdBuffer !== undefined) {\n langId = parseInt(parser.encodeToHexaString(langIdBuffer), 16);\n }\n }\n\n if (this.isRecoverSupported(seVersion, deviceModelId)) {\n const recoverStateBuffer = parser.extractFieldLVEncoded();\n if (recoverStateBuffer !== undefined) {\n recoverState = parseInt(\n parser.encodeToHexaString(recoverStateBuffer),\n 16,\n );\n }\n }\n }\n\n return CommandResultFactory({\n data: {\n isBootloader,\n isOsu,\n targetId,\n seTargetId,\n mcuTargetId,\n seVersion,\n seFlags,\n mcuSephVersion,\n mcuBootloaderVersion,\n hwVersion,\n langId,\n recoverState,\n secureElementFlags,\n },\n });\n }\n\n private isBootloaderVersionSupported(\n seVersion: string,\n deviceModelId: DeviceModelId,\n ): boolean {\n const version = coerce(seVersion) ?? \"\";\n switch (deviceModelId) {\n case DeviceModelId.NANO_S:\n case DeviceModelId.NANO_X:\n return gte(version, \"2.0.0\");\n default:\n return true;\n }\n }\n\n private isHardwareVersionSupported(\n seVersion: string,\n deviceModelId: DeviceModelId,\n ): boolean {\n const version = coerce(seVersion) ?? \"\";\n switch (deviceModelId) {\n case DeviceModelId.NANO_X:\n return gte(version, \"2.0.0\");\n default:\n return false;\n }\n }\n\n private isLocalizationSupported(\n seVersion: string,\n deviceModelId: DeviceModelId,\n ): boolean {\n const version = coerce(seVersion) ?? \"\";\n switch (deviceModelId) {\n case DeviceModelId.NANO_S:\n return false;\n case DeviceModelId.NANO_SP:\n return gte(version, \"1.1.0\");\n case DeviceModelId.NANO_X:\n return gte(version, \"2.1.0\");\n default:\n return true;\n }\n }\n\n private isRecoverSupported(\n seVersion: string,\n deviceModelId: DeviceModelId,\n ): boolean {\n const version = coerce(seVersion) ?? \"\";\n switch (deviceModelId) {\n case DeviceModelId.NANO_S:\n return false;\n case DeviceModelId.NANO_SP:\n return gte(version, \"1.1.2\");\n case DeviceModelId.NANO_X:\n return gte(version, \"2.2.3\");\n case DeviceModelId.STAX:\n return gte(version, \"1.4.0\");\n case DeviceModelId.FLEX:\n return gte(version, \"1.0.1\");\n default:\n return true;\n }\n }\n}\n"],
|
|
5
|
+
"mappings": "y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AAIG,EAAS,OAAO,EAC7B,QACE,MAAO,EACX,CACF,CAEQ,wBACNK,EACAR,EACS,CACT,MAAMG,KAAU,UAAOK,CAAS,GAAK,GACrC,OAAQR,EAAe,CACrB,KAAK,gBAAc,OACjB,MAAO,GACT,KAAK,gBAAc,QACjB,SAAO,OAAIG,EAAS,OAAO,EAC7B,KAAK,gBAAc,OACjB,SAAO,OAAIA,EAAS,OAAO,EAC7B,QACE,MAAO,EACX,CACF,CAEQ,mBACNK,EACAR,EACS,CACT,MAAMG,KAAU,UAAOK,CAAS,GAAK,GACrC,OAAQR,EAAe,CACrB,KAAK,gBAAc,OACjB,MAAO,GACT,KAAK,gBAAc,QACjB,SAAO,OAAIG,EAAS,OAAO,EAC7B,KAAK,gBAAc,OACjB,SAAO,OAAIA,EAAS,OAAO,EAC7B,KAAK,gBAAc,KACjB,SAAO,OAAIA,EAAS,OAAO,EAC7B,KAAK,gBAAc,KACjB,SAAO,OAAIA,EAAS,OAAO,EAC7B,QACE,MAAO,EACX,CACF,CACF",
|
|
6
6
|
"names": ["GetOsVersionCommand_exports", "__export", "GetOsVersionCommand", "__toCommonJS", "import_semver", "import_ApduBuilder", "import_ApduParser", "import_Errors", "import_CommandResult", "import_CommandUtils", "import_GlobalCommandError", "import_DeviceModel", "import_SecureElementFlagsParser", "getOsVersionApduArgs", "apduResponse", "deviceModelId", "parser", "targetId", "version", "seFlags", "secureElementFlags", "isBootloader", "isOsu", "seVersion", "mcuSephVersion", "mcuBootloaderVersion", "hwVersion", "mcuTargetId", "seTargetId", "langId", "recoverState", "seData", "langIdBuffer", "recoverStateBuffer"]
|
|
7
7
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";var r=require("../../command/model/CommandResult"),
|
|
1
|
+
"use strict";var r=require("../../command/model/CommandResult"),s=require("../../device/DeviceModel"),o=require("../../device-session/ApduResponse"),a=require("./__mocks__/GetOsVersionCommand"),n=require("./GetOsVersionCommand");const d=Uint8Array.from([224,1,0,0,0]),i=Uint8Array.from([51,0,0,4,5,50,46,50,46,51,4,230,0,0,0,4,50,46,51,48,4,49,46,49,54,1,0,1,0,1,0,144,0]),c=new o.ApduResponse({statusCode:Uint8Array.from([144,0]),data:i}),u=Uint8Array.from([51,16,0,4,5,49,46,49,46,49,4,230,0,0,0,4,52,46,48,51,4,51,46,49,50,1,0,1,0,144,0]),l=new o.ApduResponse({statusCode:Uint8Array.from([144,0]),data:u}),p=Uint8Array.from([51,32,0,4,5,49,46,51,46,48,4,230,0,0,0,4,53,46,50,52,4,48,46,52,56,1,0,1,0,144,0]),m=new o.ApduResponse({statusCode:Uint8Array.from([144,0]),data:p}),O=Uint8Array.from([5,1,0,3,4,49,46,49,54,4,244,216,170,67,5,50,46,50,46,51,4,51,0,0,4,144,0]),S=new o.ApduResponse({statusCode:Uint8Array.from([144,0]),data:O}),A=Uint8Array.from([51,0,0,4,0,4,238,0,0,0,4,50,46,51,48,1,1,1,0,1,0,144,0]),f=new o.ApduResponse({statusCode:Uint8Array.from([144,0]),data:A});describe("GetOsVersionCommand",()=>{let x;beforeEach(()=>{x=new n.GetOsVersionCommand}),describe("name",()=>{it("should be 'getOsVersion'",()=>{expect(x.name).toBe("getOsVersion")})}),describe("getApdu",()=>{it("should return the GetOsVersion apdu",()=>{const e=x.getApdu();expect(e.getRawApdu()).toStrictEqual(d)})}),describe("parseResponse",()=>{describe("Nano X",()=>{it("should parse the LNX response",()=>{const e=x.parseResponse(c,s.DeviceModelId.NANO_X),t=(0,r.CommandResultFactory)({data:(0,a.getOsVersionCommandResponseMockBuilder)(s.DeviceModelId.NANO_X)});expect(e).toStrictEqual(t)})}),describe("Nano S Plus",()=>{it("should parse the LNSP response",()=>{const e=x.parseResponse(l,s.DeviceModelId.NANO_SP),t=(0,r.CommandResultFactory)({data:(0,a.getOsVersionCommandResponseMockBuilder)(s.DeviceModelId.NANO_SP)});expect(e).toStrictEqual(t)})}),describe("Stax",()=>{it("should parse the STAX response",()=>{const e=x.parseResponse(m,s.DeviceModelId.STAX),t=(0,r.CommandResultFactory)({data:(0,a.getOsVersionCommandResponseMockBuilder)(s.DeviceModelId.STAX)});expect(e).toStrictEqual(t)})}),describe("Bootloader",()=>{it("should parse the bootloader response",()=>{const e=x.parseResponse(S,s.DeviceModelId.STAX),t=(0,r.CommandResultFactory)({data:{isBootloader:!0,isOsu:!1,targetId:83951619,seTargetId:855638020,seVersion:"2.2.3",seFlags:new Uint8Array([244,216,170,67]),mcuTargetId:83951619,mcuSephVersion:"",mcuBootloaderVersion:"1.16",hwVersion:"",langId:void 0,recoverState:void 0,secureElementFlags:{isPinValidated:!0,hasMcuSerialNumber:!0,hasValidCertificate:!0,isCustomAuthorityConnectionAllowed:!0,isSecureConnectionAllowed:!1,isOnboarded:!0,isMcuCodeSigned:!1,isInRecoveryMode:!1}}});expect(e).toStrictEqual(t)})}),describe("Old firmware",()=>{it("should parse the old firmware response",()=>{const e=x.parseResponse(f,s.DeviceModelId.NANO_X),t=(0,r.CommandResultFactory)({data:{isBootloader:!1,isOsu:!1,targetId:855638020,seTargetId:855638020,seVersion:"0.0.0",seFlags:new Uint8Array,mcuTargetId:void 0,mcuSephVersion:"2.30",mcuBootloaderVersion:"",hwVersion:"00",langId:void 0,recoverState:void 0,secureElementFlags:{isPinValidated:!0,hasMcuSerialNumber:!0,hasValidCertificate:!0,isCustomAuthorityConnectionAllowed:!1,isSecureConnectionAllowed:!0,isOnboarded:!0,isMcuCodeSigned:!0,isInRecoveryMode:!1}}});expect(e).toStrictEqual(t)})}),describe("Error handling",()=>{it("should return an error if the response is not successful",()=>{const e=new o.ApduResponse({statusCode:Uint8Array.from([110,128]),data:Uint8Array.from([])}),t=x.parseResponse(e,s.DeviceModelId.NANO_S);expect((0,r.isSuccessCommandResult)(t)).toBeFalsy()})})})});
|
|
2
2
|
//# sourceMappingURL=GetOsVersionCommand.test.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../../src/api/command/os/GetOsVersionCommand.test.ts"],
|
|
4
|
-
"sourcesContent": ["import {\n CommandResultFactory,\n isSuccessCommandResult,\n} from \"@api/command/model/CommandResult\";\nimport { DeviceModelId } from \"@api/device/DeviceModel\";\nimport { ApduResponse } from \"@api/device-session/ApduResponse\";\n\nimport { getOsVersionCommandResponseMockBuilder } from \"./__mocks__/GetOsVersionCommand\";\nimport { GetOsVersionCommand } from \"./GetOsVersionCommand\";\n\nconst GET_OS_VERSION_APDU = Uint8Array.from([0xe0, 0x01, 0x00, 0x00, 0x00]);\n\nconst LNX_RESPONSE_DATA_GOOD = Uint8Array.from([\n 0x33, 0x00, 0x00, 0x04, 0x05, 0x32, 0x2e, 0x32, 0x2e, 0x33, 0x04, 0xe6, 0x00,\n 0x00, 0x00, 0x04, 0x32, 0x2e, 0x33, 0x30, 0x04, 0x31, 0x2e, 0x31, 0x36, 0x01,\n 0x00, 0x01, 0x00, 0x01, 0x00, 0x90, 0x00,\n]);\nconst LNX_RESPONSE_GOOD = new ApduResponse({\n statusCode: Uint8Array.from([0x90, 0x00]),\n data: LNX_RESPONSE_DATA_GOOD,\n});\n\nconst LNSP_REPONSE_DATA_GOOD = Uint8Array.from([\n 0x33, 0x10, 0x00, 0x04, 0x05, 0x31, 0x2e, 0x31, 0x2e, 0x31, 0x04, 0xe6, 0x00,\n 0x00, 0x00, 0x04, 0x34, 0x2e, 0x30, 0x33, 0x04, 0x33, 0x2e, 0x31, 0x32, 0x01,\n 0x00, 0x01, 0x00, 0x90, 0x00,\n]);\nconst LNSP_RESPONSE_GOOD = new ApduResponse({\n statusCode: Uint8Array.from([0x90, 0x00]),\n data: LNSP_REPONSE_DATA_GOOD,\n});\n\nconst STAX_RESPONSE_DATA_GOOD = Uint8Array.from([\n 0x33, 0x20, 0x00, 0x04, 0x05, 0x31, 0x2e, 0x33, 0x2e, 0x30, 0x04, 0xe6, 0x00,\n 0x00, 0x00, 0x04, 0x35, 0x2e, 0x32, 0x34, 0x04, 0x30, 0x2e, 0x34, 0x38, 0x01,\n 0x00, 0x01, 0x00, 0x90, 0x00,\n]);\nconst STAX_RESPONSE_GOOD = new ApduResponse({\n statusCode: Uint8Array.from([0x90, 0x00]),\n data: STAX_RESPONSE_DATA_GOOD,\n});\n\nconst BL_RESPONSE_DATA_GOOD = Uint8Array.from([\n 0x05, 0x01, 0x00, 0x03, 0x04, 0x31, 0x2e, 0x31, 0x36, 0x04, 0xf4, 0xd8, 0xaa,\n 0x43, 0x05, 0x32, 0x2e, 0x32, 0x2e, 0x33, 0x04, 0x33, 0x00, 0x00, 0x04, 0x90,\n 0x00,\n]);\nconst BL_RESPONSE_GOOD = new ApduResponse({\n statusCode: Uint8Array.from([0x90, 0x00]),\n data: BL_RESPONSE_DATA_GOOD,\n});\n\nconst OLD_FM_RESPONSE_DATA_GOOD = Uint8Array.from([\n 0x33, 0x00, 0x00, 0x04, 0x00, 0x04, 0xee, 0x00, 0x00, 0x00, 0x04, 0x32, 0x2e,\n 0x33, 0x30, 0x01, 0x01, 0x01, 0x00, 0x01, 0x00, 0x90, 0x00,\n]);\nconst OLD_FM_RESPONSE_GOOD = new ApduResponse({\n statusCode: Uint8Array.from([0x90, 0x00]),\n data: OLD_FM_RESPONSE_DATA_GOOD,\n});\n\ndescribe(\"GetOsVersionCommand\", () => {\n let command: GetOsVersionCommand;\n\n beforeEach(() => {\n command = new GetOsVersionCommand();\n });\n\n describe(\"getApdu\", () => {\n it(\"should return the GetOsVersion apdu\", () => {\n const apdu = command.getApdu();\n expect(apdu.getRawApdu()).toStrictEqual(GET_OS_VERSION_APDU);\n });\n });\n\n describe(\"parseResponse\", () => {\n describe(\"Nano X\", () => {\n it(\"should parse the LNX response\", () => {\n const parsed = command.parseResponse(\n LNX_RESPONSE_GOOD,\n DeviceModelId.NANO_X,\n );\n\n const expected = CommandResultFactory({\n data: getOsVersionCommandResponseMockBuilder(DeviceModelId.NANO_X),\n });\n\n expect(parsed).toStrictEqual(expected);\n });\n });\n\n describe(\"Nano S Plus\", () => {\n it(\"should parse the LNSP response\", () => {\n const parsed = command.parseResponse(\n LNSP_RESPONSE_GOOD,\n DeviceModelId.NANO_SP,\n );\n\n const expected = CommandResultFactory({\n data: getOsVersionCommandResponseMockBuilder(DeviceModelId.NANO_SP),\n });\n\n expect(parsed).toStrictEqual(expected);\n });\n });\n\n describe(\"Stax\", () => {\n it(\"should parse the STAX response\", () => {\n const parsed = command.parseResponse(\n STAX_RESPONSE_GOOD,\n DeviceModelId.STAX,\n );\n\n const expected = CommandResultFactory({\n data: getOsVersionCommandResponseMockBuilder(DeviceModelId.STAX),\n });\n\n expect(parsed).toStrictEqual(expected);\n });\n });\n\n describe(\"Bootloader\", () => {\n it(\"should parse the bootloader response\", () => {\n const parsed = command.parseResponse(\n BL_RESPONSE_GOOD,\n DeviceModelId.STAX,\n );\n\n const expected = CommandResultFactory({\n data: {\n isBootloader: true,\n isOsu: false,\n targetId: 83951619,\n seTargetId: 855638020,\n seVersion: \"2.2.3\",\n seFlags: new Uint8Array([0xf4, 0xd8, 0xaa, 0x43]),\n mcuTargetId: 83951619,\n mcuSephVersion: \"\",\n mcuBootloaderVersion: \"1.16\",\n hwVersion: \"\",\n langId: undefined,\n recoverState: undefined,\n secureElementFlags: {\n isPinValidated: true,\n hasMcuSerialNumber: true,\n hasValidCertificate: true,\n isCustomAuthorityConnectionAllowed: true,\n isSecureConnectionAllowed: false,\n isOnboarded: true,\n isMcuCodeSigned: false,\n isInRecoveryMode: false,\n },\n },\n });\n\n expect(parsed).toStrictEqual(expected);\n });\n });\n\n describe(\"Old firmware\", () => {\n it(\"should parse the old firmware response\", () => {\n const parsed = command.parseResponse(\n OLD_FM_RESPONSE_GOOD,\n DeviceModelId.NANO_X,\n );\n\n const expected = CommandResultFactory({\n data: {\n isBootloader: false,\n isOsu: false,\n targetId: 855638020,\n seTargetId: 855638020,\n seVersion: \"0.0.0\",\n seFlags: new Uint8Array(),\n mcuTargetId: undefined,\n mcuSephVersion: \"2.30\",\n mcuBootloaderVersion: \"\",\n hwVersion: \"00\",\n langId: undefined,\n recoverState: undefined,\n secureElementFlags: {\n isPinValidated: true,\n hasMcuSerialNumber: true,\n hasValidCertificate: true,\n isCustomAuthorityConnectionAllowed: false,\n isSecureConnectionAllowed: true,\n isOnboarded: true,\n isMcuCodeSigned: true,\n isInRecoveryMode: false,\n },\n },\n });\n\n expect(parsed).toStrictEqual(expected);\n });\n });\n\n describe(\"Error handling\", () => {\n it(\"should return an error if the response is not successful\", () => {\n const response = new ApduResponse({\n statusCode: Uint8Array.from([0x6e, 0x80]),\n data: Uint8Array.from([]),\n });\n const result = command.parseResponse(response, DeviceModelId.NANO_S);\n\n expect(isSuccessCommandResult(result)).toBeFalsy();\n });\n });\n });\n});\n"],
|
|
5
|
-
"mappings": "aAAA,IAAAA,EAGO,4CACPC,EAA8B,mCAC9BC,EAA6B,4CAE7BC,EAAuD,2CACvDA,EAAoC,iCAEpC,MAAMC,EAAsB,WAAW,KAAK,CAAC,IAAM,EAAM,EAAM,EAAM,CAAI,CAAC,EAEpEC,EAAyB,WAAW,KAAK,CAC7C,GAAM,EAAM,EAAM,EAAM,EAAM,GAAM,GAAM,GAAM,GAAM,GAAM,EAAM,IAAM,EACxE,EAAM,EAAM,EAAM,GAAM,GAAM,GAAM,GAAM,EAAM,GAAM,GAAM,GAAM,GAAM,EACxE,EAAM,EAAM,EAAM,EAAM,EAAM,IAAM,CACtC,CAAC,EACKC,EAAoB,IAAI,eAAa,CACzC,WAAY,WAAW,KAAK,CAAC,IAAM,CAAI,CAAC,EACxC,KAAMD,CACR,CAAC,EAEKE,EAAyB,WAAW,KAAK,CAC7C,GAAM,GAAM,EAAM,EAAM,EAAM,GAAM,GAAM,GAAM,GAAM,GAAM,EAAM,IAAM,EACxE,EAAM,EAAM,EAAM,GAAM,GAAM,GAAM,GAAM,EAAM,GAAM,GAAM,GAAM,GAAM,EACxE,EAAM,EAAM,EAAM,IAAM,CAC1B,CAAC,EACKC,EAAqB,I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AQ,CACvC,CAAC,CACH,CAAC,EAED,SAAS,eAAgB,IAAM,CAC7B,GAAG,yCAA0C,IAAM,CACjD,MAAMD,EAASF,EAAQ,cACrBD,EACA,gBAAc,MAChB,EAEMI,KAAW,wBAAqB,CACpC,KAAM,CACJ,aAAc,GACd,MAAO,GACP,SAAU,UACV,WAAY,UACZ,UAAW,QACX,QAAS,IAAI,WACb,YAAa,OACb,eAAgB,OAChB,qBAAsB,GACtB,UAAW,KACX,OAAQ,OACR,aAAc,OACd,mBAAoB,CAClB,eAAgB,GAChB,mBAAoB,GACpB,oBAAqB,GACrB,mCAAoC,GACpC,0BAA2B,GAC3B,YAAa,GACb,gBAAiB,GACjB,iBAAkB,EACpB,CACF,CACF,CAAC,EAED,OAAOD,CAAM,EAAE,cAAcC,CAAQ,CACvC,CAAC,CACH,CAAC,EAED,SAAS,iBAAkB,IAAM,CAC/B,GAAG,2DAA4D,IAAM,CACnE,MAAMC,EAAW,IAAI,eAAa,CAChC,WAAY,WAAW,KAAK,CAAC,IAAM,GAAI,CAAC,EACxC,KAAM,WAAW,KAAK,CAAC,CAAC,CAC1B,CAAC,EACKC,EAASL,EAAQ,cAAcI,EAAU,gBAAc,MAAM,EAEnE,UAAO,0BAAuBC,CAAM,CAAC,EAAE,UAAU,CACnD,CAAC,CACH,CAAC,CACH,CAAC,CACH,CAAC",
|
|
4
|
+
"sourcesContent": ["import {\n CommandResultFactory,\n isSuccessCommandResult,\n} from \"@api/command/model/CommandResult\";\nimport { DeviceModelId } from \"@api/device/DeviceModel\";\nimport { ApduResponse } from \"@api/device-session/ApduResponse\";\n\nimport { getOsVersionCommandResponseMockBuilder } from \"./__mocks__/GetOsVersionCommand\";\nimport { GetOsVersionCommand } from \"./GetOsVersionCommand\";\n\nconst GET_OS_VERSION_APDU = Uint8Array.from([0xe0, 0x01, 0x00, 0x00, 0x00]);\n\nconst LNX_RESPONSE_DATA_GOOD = Uint8Array.from([\n 0x33, 0x00, 0x00, 0x04, 0x05, 0x32, 0x2e, 0x32, 0x2e, 0x33, 0x04, 0xe6, 0x00,\n 0x00, 0x00, 0x04, 0x32, 0x2e, 0x33, 0x30, 0x04, 0x31, 0x2e, 0x31, 0x36, 0x01,\n 0x00, 0x01, 0x00, 0x01, 0x00, 0x90, 0x00,\n]);\nconst LNX_RESPONSE_GOOD = new ApduResponse({\n statusCode: Uint8Array.from([0x90, 0x00]),\n data: LNX_RESPONSE_DATA_GOOD,\n});\n\nconst LNSP_REPONSE_DATA_GOOD = Uint8Array.from([\n 0x33, 0x10, 0x00, 0x04, 0x05, 0x31, 0x2e, 0x31, 0x2e, 0x31, 0x04, 0xe6, 0x00,\n 0x00, 0x00, 0x04, 0x34, 0x2e, 0x30, 0x33, 0x04, 0x33, 0x2e, 0x31, 0x32, 0x01,\n 0x00, 0x01, 0x00, 0x90, 0x00,\n]);\nconst LNSP_RESPONSE_GOOD = new ApduResponse({\n statusCode: Uint8Array.from([0x90, 0x00]),\n data: LNSP_REPONSE_DATA_GOOD,\n});\n\nconst STAX_RESPONSE_DATA_GOOD = Uint8Array.from([\n 0x33, 0x20, 0x00, 0x04, 0x05, 0x31, 0x2e, 0x33, 0x2e, 0x30, 0x04, 0xe6, 0x00,\n 0x00, 0x00, 0x04, 0x35, 0x2e, 0x32, 0x34, 0x04, 0x30, 0x2e, 0x34, 0x38, 0x01,\n 0x00, 0x01, 0x00, 0x90, 0x00,\n]);\nconst STAX_RESPONSE_GOOD = new ApduResponse({\n statusCode: Uint8Array.from([0x90, 0x00]),\n data: STAX_RESPONSE_DATA_GOOD,\n});\n\nconst BL_RESPONSE_DATA_GOOD = Uint8Array.from([\n 0x05, 0x01, 0x00, 0x03, 0x04, 0x31, 0x2e, 0x31, 0x36, 0x04, 0xf4, 0xd8, 0xaa,\n 0x43, 0x05, 0x32, 0x2e, 0x32, 0x2e, 0x33, 0x04, 0x33, 0x00, 0x00, 0x04, 0x90,\n 0x00,\n]);\nconst BL_RESPONSE_GOOD = new ApduResponse({\n statusCode: Uint8Array.from([0x90, 0x00]),\n data: BL_RESPONSE_DATA_GOOD,\n});\n\nconst OLD_FM_RESPONSE_DATA_GOOD = Uint8Array.from([\n 0x33, 0x00, 0x00, 0x04, 0x00, 0x04, 0xee, 0x00, 0x00, 0x00, 0x04, 0x32, 0x2e,\n 0x33, 0x30, 0x01, 0x01, 0x01, 0x00, 0x01, 0x00, 0x90, 0x00,\n]);\nconst OLD_FM_RESPONSE_GOOD = new ApduResponse({\n statusCode: Uint8Array.from([0x90, 0x00]),\n data: OLD_FM_RESPONSE_DATA_GOOD,\n});\n\ndescribe(\"GetOsVersionCommand\", () => {\n let command: GetOsVersionCommand;\n\n beforeEach(() => {\n command = new GetOsVersionCommand();\n });\n\n describe(\"name\", () => {\n it(\"should be 'getOsVersion'\", () => {\n expect(command.name).toBe(\"getOsVersion\");\n });\n });\n\n describe(\"getApdu\", () => {\n it(\"should return the GetOsVersion apdu\", () => {\n const apdu = command.getApdu();\n expect(apdu.getRawApdu()).toStrictEqual(GET_OS_VERSION_APDU);\n });\n });\n\n describe(\"parseResponse\", () => {\n describe(\"Nano X\", () => {\n it(\"should parse the LNX response\", () => {\n const parsed = command.parseResponse(\n LNX_RESPONSE_GOOD,\n DeviceModelId.NANO_X,\n );\n\n const expected = CommandResultFactory({\n data: getOsVersionCommandResponseMockBuilder(DeviceModelId.NANO_X),\n });\n\n expect(parsed).toStrictEqual(expected);\n });\n });\n\n describe(\"Nano S Plus\", () => {\n it(\"should parse the LNSP response\", () => {\n const parsed = command.parseResponse(\n LNSP_RESPONSE_GOOD,\n DeviceModelId.NANO_SP,\n );\n\n const expected = CommandResultFactory({\n data: getOsVersionCommandResponseMockBuilder(DeviceModelId.NANO_SP),\n });\n\n expect(parsed).toStrictEqual(expected);\n });\n });\n\n describe(\"Stax\", () => {\n it(\"should parse the STAX response\", () => {\n const parsed = command.parseResponse(\n STAX_RESPONSE_GOOD,\n DeviceModelId.STAX,\n );\n\n const expected = CommandResultFactory({\n data: getOsVersionCommandResponseMockBuilder(DeviceModelId.STAX),\n });\n\n expect(parsed).toStrictEqual(expected);\n });\n });\n\n describe(\"Bootloader\", () => {\n it(\"should parse the bootloader response\", () => {\n const parsed = command.parseResponse(\n BL_RESPONSE_GOOD,\n DeviceModelId.STAX,\n );\n\n const expected = CommandResultFactory({\n data: {\n isBootloader: true,\n isOsu: false,\n targetId: 83951619,\n seTargetId: 855638020,\n seVersion: \"2.2.3\",\n seFlags: new Uint8Array([0xf4, 0xd8, 0xaa, 0x43]),\n mcuTargetId: 83951619,\n mcuSephVersion: \"\",\n mcuBootloaderVersion: \"1.16\",\n hwVersion: \"\",\n langId: undefined,\n recoverState: undefined,\n secureElementFlags: {\n isPinValidated: true,\n hasMcuSerialNumber: true,\n hasValidCertificate: true,\n isCustomAuthorityConnectionAllowed: true,\n isSecureConnectionAllowed: false,\n isOnboarded: true,\n isMcuCodeSigned: false,\n isInRecoveryMode: false,\n },\n },\n });\n\n expect(parsed).toStrictEqual(expected);\n });\n });\n\n describe(\"Old firmware\", () => {\n it(\"should parse the old firmware response\", () => {\n const parsed = command.parseResponse(\n OLD_FM_RESPONSE_GOOD,\n DeviceModelId.NANO_X,\n );\n\n const expected = CommandResultFactory({\n data: {\n isBootloader: false,\n isOsu: false,\n targetId: 855638020,\n seTargetId: 855638020,\n seVersion: \"0.0.0\",\n seFlags: new Uint8Array(),\n mcuTargetId: undefined,\n mcuSephVersion: \"2.30\",\n mcuBootloaderVersion: \"\",\n hwVersion: \"00\",\n langId: undefined,\n recoverState: undefined,\n secureElementFlags: {\n isPinValidated: true,\n hasMcuSerialNumber: true,\n hasValidCertificate: true,\n isCustomAuthorityConnectionAllowed: false,\n isSecureConnectionAllowed: true,\n isOnboarded: true,\n isMcuCodeSigned: true,\n isInRecoveryMode: false,\n },\n },\n });\n\n expect(parsed).toStrictEqual(expected);\n });\n });\n\n describe(\"Error handling\", () => {\n it(\"should return an error if the response is not successful\", () => {\n const response = new ApduResponse({\n statusCode: Uint8Array.from([0x6e, 0x80]),\n data: Uint8Array.from([]),\n });\n const result = command.parseResponse(response, DeviceModelId.NANO_S);\n\n expect(isSuccessCommandResult(result)).toBeFalsy();\n });\n });\n });\n});\n"],
|
|
5
|
+
"mappings": "aAAA,IAAAA,EAGO,4CACPC,EAA8B,mCAC9BC,EAA6B,4CAE7BC,EAAuD,2CACvDA,EAAoC,iCAEpC,MAAMC,EAAsB,WAAW,KAAK,CAAC,IAAM,EAAM,EAAM,EAAM,CAAI,CAAC,EAEpEC,EAAyB,WAAW,KAAK,CAC7C,GAAM,EAAM,EAAM,EAAM,EAAM,GAAM,GAAM,GAAM,GAAM,GAAM,EAAM,IAAM,EACxE,EAAM,EAAM,EAAM,GAAM,GAAM,GAAM,GAAM,EAAM,GAAM,GAAM,GAAM,GAAM,EACxE,EAAM,EAAM,EAAM,EAAM,EAAM,IAAM,CACtC,CAAC,EACKC,EAAoB,IAAI,eAAa,CACzC,WAAY,WAAW,KAAK,CAAC,IAAM,CAAI,CAAC,EACxC,KAAMD,CACR,CAAC,EAEKE,EAAyB,WAAW,KAAK,CAC7C,GAAM,GAAM,EAAM,EAAM,EAAM,GAAM,GAAM,GAAM,GAAM,GAAM,EAAM,IAAM,EACxE,EAAM,EAAM,EAAM,GAAM,GAAM,GAAM,GAAM,EAAM,GAAM,GAAM,GAAM,GAAM,EACxE,EAAM,EAAM,EAAM,IAAM,CAC1B,CAAC,EACKC,EAAqB,IAAI,eAAa,CAC1C,WAAY,WAAW,KAAK,CAAC,IAAM,CAAI,CAAC,EACxC,KAAMD,CACR,CAAC,EAEKE,EAA0B,WAAW,KAAK,CAC9C,GAAM,GAAM,EAAM,EAAM,EAAM,GAAM,GAAM,GAAM,GAAM,GAAM,EAAM,IAAM,EACxE,EAAM,EAAM,EAAM,GAAM,GAAM,GAAM,GAAM,EAAM,GAAM,GAAM,GAAM,GAAM,EACxE,EAAM,EAAM,EAAM,IAAM,CAC1B,CAAC,EACKC,EAAqB,IAAI,eAAa,CAC1C,WAAY,WAAW,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,WACb,YAAa,OACb,eAAgB,OAChB,qBAAsB,GACtB,UAAW,KACX,OAAQ,OACR,aAAc,OACd,mBAAoB,CAClB,eAAgB,GAChB,mBAAoB,GACpB,oBAAqB,GACrB,mCAAoC,GACpC,0BAA2B,GAC3B,YAAa,GACb,gBAAiB,GACjB,iBAAkB,EACpB,CACF,CACF,CAAC,EAED,OAAOD,CAAM,EAAE,cAAcC,CAAQ,CACvC,CAAC,CACH,CAAC,EAED,SAAS,iBAAkB,IAAM,CAC/B,GAAG,2DAA4D,IAAM,CACnE,MAAMC,EAAW,IAAI,eAAa,CAChC,WAAY,WAAW,KAAK,CAAC,IAAM,GAAI,CAAC,EACxC,KAAM,WAAW,KAAK,CAAC,CAAC,CAC1B,CAAC,EACKC,EAASL,EAAQ,cAAcI,EAAU,gBAAc,MAAM,EAEnE,UAAO,0BAAuBC,CAAM,CAAC,EAAE,UAAU,CACnD,CAAC,CACH,CAAC,CACH,CAAC,CACH,CAAC",
|
|
6
6
|
"names": ["import_CommandResult", "import_DeviceModel", "import_ApduResponse", "import_GetOsVersionCommand", "GET_OS_VERSION_APDU", "LNX_RESPONSE_DATA_GOOD", "LNX_RESPONSE_GOOD", "LNSP_REPONSE_DATA_GOOD", "LNSP_RESPONSE_GOOD", "STAX_RESPONSE_DATA_GOOD", "STAX_RESPONSE_GOOD", "BL_RESPONSE_DATA_GOOD", "BL_RESPONSE_GOOD", "OLD_FM_RESPONSE_DATA_GOOD", "OLD_FM_RESPONSE_GOOD", "command", "apdu", "parsed", "expected", "response", "result"]
|
|
7
7
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";var n=Object.defineProperty;var
|
|
1
|
+
"use strict";var n=Object.defineProperty;var L=Object.getOwnPropertyDescriptor;var E=Object.getOwnPropertyNames;var h=Object.prototype.hasOwnProperty;var f=(s,r)=>{for(var o in r)n(s,o,{get:r[o],enumerable:!0})},R=(s,r,o,e)=>{if(r&&typeof r=="object"||typeof r=="function")for(let t of E(r))!h.call(s,t)&&t!==o&&n(s,t,{get:()=>r[t],enumerable:!(e=L(r,t))||e.enumerable});return s};var B=s=>R(n({},"__esModule",{value:!0}),s);var H={};f(H,{ListAppsCommand:()=>S,ListAppsCommandError:()=>u});module.exports=B(H);var i=require("../../apdu/utils/ApduBuilder"),d=require("../../apdu/utils/ApduParser"),p=require("../../command/model/CommandResult"),m=require("../../command/utils/CommandErrors"),l=require("../../command/utils/CommandUtils"),A=require("../../command/utils/GlobalCommandError"),c=require("../../Error");const a={6624:{message:"Invalid state (List applications command must be sent)"}};class u extends c.DeviceExchangeError{constructor({message:r,errorCode:o}){super({message:r,errorCode:o,tag:"ListAppsCommandError"})}}class S{name="listApps";args;constructor(r={isContinue:!1}){this.args=r}getApdu(){const r={cla:224,ins:this.args.isContinue?223:222,p1:0,p2:0};return new i.ApduBuilder(r).build()}parseResponse(r){const o=[],e=new d.ApduParser(r);if(!l.CommandUtils.isSuccessResponse(r)){const t=e.encodeToHexaString(r.statusCode);return(0,m.isCommandErrorCode)(t,a)?(0,p.CommandResultFactory)({error:new u({...a[t],errorCode:t})}):(0,p.CommandResultFactory)({error:A.GlobalCommandErrorHandler.handle(r)})}if(r.data.length<=0)return(0,p.CommandResultFactory)({data:[]});for(e.extract8BitUInt();e.getUnparsedRemainingLength()>0;){const t=e.extract8BitUInt(),C=e.extract16BitUInt();e.extract16BitUInt();const g=e.encodeToHexaString(e.extractFieldByLength(32)),x=e.encodeToHexaString(e.extractFieldByLength(32)),y=e.encodeToString(e.extractFieldLVEncoded());o.push({appEntryLength:t,appSizeInBlocks:C,appCodeHash:g,appFullHash:x,appName:y})}return(0,p.CommandResultFactory)({data:o})}}0&&(module.exports={ListAppsCommand,ListAppsCommandError});
|
|
2
2
|
//# sourceMappingURL=ListAppsCommand.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../../src/api/command/os/ListAppsCommand.ts"],
|
|
4
|
-
"sourcesContent": ["import { type Apdu } from \"@api/apdu/model/Apdu\";\nimport { ApduBuilder, type ApduBuilderArgs } from \"@api/apdu/utils/ApduBuilder\";\nimport { ApduParser } from \"@api/apdu/utils/ApduParser\";\nimport { type Command } from \"@api/command/Command\";\nimport {\n type CommandResult,\n CommandResultFactory,\n} from \"@api/command/model/CommandResult\";\nimport {\n type CommandErrors,\n isCommandErrorCode,\n} from \"@api/command/utils/CommandErrors\";\nimport { CommandUtils } from \"@api/command/utils/CommandUtils\";\nimport { GlobalCommandErrorHandler } from \"@api/command/utils/GlobalCommandError\";\nimport { type ApduResponse } from \"@api/device-session/ApduResponse\";\nimport { type CommandErrorArgs, DeviceExchangeError } from \"@api/Error\";\n\nexport type AppResponse = {\n readonly appEntryLength: number;\n readonly appSizeInBlocks: number;\n readonly appCodeHash: string;\n readonly appFullHash: string;\n readonly appName: string;\n};\n\nexport type ListAppsResponse = AppResponse[];\n\nexport type ListAppsArgs = {\n readonly isContinue: boolean;\n};\n\nexport type ListAppsErrorCodes = \"6624\";\n\nconst LIST_APP_ERRORS: CommandErrors<ListAppsErrorCodes> = {\n \"6624\": { message: \"Invalid state (List applications command must be sent)\" },\n};\n\nexport type ListAppsCommandResult = CommandResult<\n ListAppsResponse,\n ListAppsErrorCodes\n>;\n\nexport class ListAppsCommandError extends DeviceExchangeError<ListAppsErrorCodes> {\n constructor({ message, errorCode }: CommandErrorArgs<ListAppsErrorCodes>) {\n super({ message, errorCode, tag: \"ListAppsCommandError\" });\n }\n}\n\nexport class ListAppsCommand\n implements Command<ListAppsResponse, ListAppsArgs, ListAppsErrorCodes>\n{\n readonly args: ListAppsArgs;\n\n constructor(args = { isContinue: false }) {\n this.args = args;\n }\n\n getApdu(): Apdu {\n const listAppApduArgs: ApduBuilderArgs = {\n cla: 0xe0,\n ins: this.args.isContinue ? 0xdf : 0xde,\n p1: 0x00,\n p2: 0x00,\n };\n return new ApduBuilder(listAppApduArgs).build();\n }\n\n parseResponse(apduResponse: ApduResponse): ListAppsCommandResult {\n const res = [];\n const parser = new ApduParser(apduResponse);\n\n if (!CommandUtils.isSuccessResponse(apduResponse)) {\n const errorCode = parser.encodeToHexaString(apduResponse.statusCode);\n if (isCommandErrorCode(errorCode, LIST_APP_ERRORS)) {\n return CommandResultFactory({\n error: new ListAppsCommandError({\n ...LIST_APP_ERRORS[errorCode],\n errorCode,\n }),\n });\n }\n return CommandResultFactory({\n error: GlobalCommandErrorHandler.handle(apduResponse),\n });\n }\n\n if (apduResponse.data.length <= 0) {\n return CommandResultFactory({\n data: [],\n });\n }\n\n // [NOTE] version of parsing, not used for now, skipping 1 byte\n parser.extract8BitUInt()!;\n\n while (parser.getUnparsedRemainingLength() > 0) {\n const appEntryLength = parser.extract8BitUInt()!;\n const appSizeInBlocks = parser.extract16BitUInt()!;\n parser.extract16BitUInt()!; // Skip 2 bytes (flags, missing in doc for now)\n const appCodeHash = parser.encodeToHexaString(\n parser.extractFieldByLength(0x20), // 32 bytes\n );\n const appFullHash = parser.encodeToHexaString(\n parser.extractFieldByLength(0x20), // 32 bytes\n );\n\n const appName = parser.encodeToString(parser.extractFieldLVEncoded());\n\n res.push({\n appEntryLength,\n appSizeInBlocks,\n appCodeHash,\n appFullHash,\n appName,\n });\n }\n\n return CommandResultFactory({\n data: res,\n });\n }\n}\n"],
|
|
5
|
-
"mappings": "yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,qBAAAE,EAAA,yBAAAC,IAAA,eAAAC,EAAAJ,GACA,IAAAK,EAAkD,uCAClDC,EAA2B,sCAE3BC,EAGO,4CACPC,EAGO,4CACPC,EAA6B,2CAC7BC,EAA0C,iDAE1CC,EAA2D,sBAkB3D,MAAMC,EAAqD,CACzD,KAAQ,CAAE,QAAS,wDAAyD,CAC9E,EAOO,MAAMT,UAA6B,qBAAwC,CAChF,YAAY,CAAE,QAAAU,EAAS,UAAAC,CAAU,EAAyC,CACxE,MAAM,CAAE,QAAAD,EAAS,UAAAC,EAAW,IAAK,sBAAu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du } from \"@api/apdu/model/Apdu\";\nimport { ApduBuilder, type ApduBuilderArgs } from \"@api/apdu/utils/ApduBuilder\";\nimport { ApduParser } from \"@api/apdu/utils/ApduParser\";\nimport { type Command } from \"@api/command/Command\";\nimport {\n type CommandResult,\n CommandResultFactory,\n} from \"@api/command/model/CommandResult\";\nimport {\n type CommandErrors,\n isCommandErrorCode,\n} from \"@api/command/utils/CommandErrors\";\nimport { CommandUtils } from \"@api/command/utils/CommandUtils\";\nimport { GlobalCommandErrorHandler } from \"@api/command/utils/GlobalCommandError\";\nimport { type ApduResponse } from \"@api/device-session/ApduResponse\";\nimport { type CommandErrorArgs, DeviceExchangeError } from \"@api/Error\";\n\nexport type AppResponse = {\n readonly appEntryLength: number;\n readonly appSizeInBlocks: number;\n readonly appCodeHash: string;\n readonly appFullHash: string;\n readonly appName: string;\n};\n\nexport type ListAppsResponse = AppResponse[];\n\nexport type ListAppsArgs = {\n readonly isContinue: boolean;\n};\n\nexport type ListAppsErrorCodes = \"6624\";\n\nconst LIST_APP_ERRORS: CommandErrors<ListAppsErrorCodes> = {\n \"6624\": { message: \"Invalid state (List applications command must be sent)\" },\n};\n\nexport type ListAppsCommandResult = CommandResult<\n ListAppsResponse,\n ListAppsErrorCodes\n>;\n\nexport class ListAppsCommandError extends DeviceExchangeError<ListAppsErrorCodes> {\n constructor({ message, errorCode }: CommandErrorArgs<ListAppsErrorCodes>) {\n super({ message, errorCode, tag: \"ListAppsCommandError\" });\n }\n}\n\nexport class ListAppsCommand\n implements Command<ListAppsResponse, ListAppsArgs, ListAppsErrorCodes>\n{\n readonly name = \"listApps\";\n readonly args: ListAppsArgs;\n\n constructor(args = { isContinue: false }) {\n this.args = args;\n }\n\n getApdu(): Apdu {\n const listAppApduArgs: ApduBuilderArgs = {\n cla: 0xe0,\n ins: this.args.isContinue ? 0xdf : 0xde,\n p1: 0x00,\n p2: 0x00,\n };\n return new ApduBuilder(listAppApduArgs).build();\n }\n\n parseResponse(apduResponse: ApduResponse): ListAppsCommandResult {\n const res = [];\n const parser = new ApduParser(apduResponse);\n\n if (!CommandUtils.isSuccessResponse(apduResponse)) {\n const errorCode = parser.encodeToHexaString(apduResponse.statusCode);\n if (isCommandErrorCode(errorCode, LIST_APP_ERRORS)) {\n return CommandResultFactory({\n error: new ListAppsCommandError({\n ...LIST_APP_ERRORS[errorCode],\n errorCode,\n }),\n });\n }\n return CommandResultFactory({\n error: GlobalCommandErrorHandler.handle(apduResponse),\n });\n }\n\n if (apduResponse.data.length <= 0) {\n return CommandResultFactory({\n data: [],\n });\n }\n\n // [NOTE] version of parsing, not used for now, skipping 1 byte\n parser.extract8BitUInt()!;\n\n while (parser.getUnparsedRemainingLength() > 0) {\n const appEntryLength = parser.extract8BitUInt()!;\n const appSizeInBlocks = parser.extract16BitUInt()!;\n parser.extract16BitUInt()!; // Skip 2 bytes (flags, missing in doc for now)\n const appCodeHash = parser.encodeToHexaString(\n parser.extractFieldByLength(0x20), // 32 bytes\n );\n const appFullHash = parser.encodeToHexaString(\n parser.extractFieldByLength(0x20), // 32 bytes\n );\n\n const appName = parser.encodeToString(parser.extractFieldLVEncoded());\n\n res.push({\n appEntryLength,\n appSizeInBlocks,\n appCodeHash,\n appFullHash,\n appName,\n });\n }\n\n return CommandResultFactory({\n data: res,\n });\n }\n}\n"],
|
|
5
|
+
"mappings": "yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,qBAAAE,EAAA,yBAAAC,IAAA,eAAAC,EAAAJ,GACA,IAAAK,EAAkD,uCAClDC,EAA2B,sCAE3BC,EAGO,4CACPC,EAGO,4CACPC,EAA6B,2CAC7BC,EAA0C,iDAE1CC,EAA2D,sBAkB3D,MAAMC,EAAqD,CACzD,KAAQ,CAAE,QAAS,wDAAyD,CAC9E,EAOO,MAAMT,UAA6B,qBAAwC,CAChF,YAAY,CAAE,QAAAU,EAAS,UAAAC,CAAU,EAAyC,CACxE,MAAM,CAAE,QAAAD,EAAS,UAAAC,EAAW,IAAK,sBAAuB,C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sCommand_exports", "__export", "ListAppsCommand", "ListAppsCommandError", "__toCommonJS", "import_ApduBuilder", "import_ApduParser", "import_CommandResult", "import_CommandErrors", "import_CommandUtils", "import_GlobalCommandError", "import_Error", "LIST_APP_ERRORS", "message", "errorCode", "args", "listAppApduArgs", "apduResponse", "res", "parser", "appEntryLength", "appSizeInBlocks", "appCodeHash", "appFullHash", "appName"]
|
|
7
7
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";var a=require("../../command/model/CommandResult"),t=require("../../device-session/ApduResponse"),r=require("./ListAppsCommand");const
|
|
1
|
+
"use strict";var a=require("../../command/model/CommandResult"),t=require("../../device-session/ApduResponse"),r=require("./ListAppsCommand");const p=Uint8Array.from([224,222,0,0,0]),d=Uint8Array.from([224,223,0,0,0]),o=Uint8Array.from([1,77,0,19,202,80,162,37,158,3,169,137,73,84,31,243,218,241,134,41,163,15,177,105,175,24,210,113,43,168,184,41,111,241,197,49,15,165,169,126,255,168,22,115,123,175,73,99,90,66,53,112,18,115,75,144,158,39,150,212,231,241,75,44,205,156,164,118,40,52,7,66,105,116,99,111,105,110]),c=[{appEntryLength:77,appSizeInBlocks:19,appCodeHash:"a2259e03a98949541ff3daf18629a30fb169af18d2712ba8b8296ff1c5310fa5",appFullHash:"a97effa816737baf49635a42357012734b909e2796d4e7f14b2ccd9ca4762834",appName:"Bitcoin"}],f=Uint8Array.from([1,77,0,19,202,80,162,37,158,3,169,137,73,84,31,243,218,241,134,41,163,15,177,105,175,24,210,113,43,168,184,41,111,241,197,49,15,165,169,126,255,168,22,115,123,175,73,99,90,66,53,112,18,115,75,144,158,39,150,212,231,241,75,44,205,156,164,118,40,52,7,66,105,116,99,111,105,110,78,0,19,202,64,51,149,37,57,143,228,95,115,200,183,89,238,224,26,124,225,113,61,24,84,77,86,238,72,100,224,73,185,102,230,41,77,199,160,148,112,247,163,120,81,168,172,249,138,218,191,62,44,47,31,126,222,253,49,198,181,77,193,199,220,41,145,216,83,8,69,116,104,101,114,101,117,109]),n=[{appEntryLength:77,appSizeInBlocks:19,appCodeHash:"a2259e03a98949541ff3daf18629a30fb169af18d2712ba8b8296ff1c5310fa5",appFullHash:"a97effa816737baf49635a42357012734b909e2796d4e7f14b2ccd9ca4762834",appName:"Bitcoin"},{appEntryLength:78,appSizeInBlocks:19,appCodeHash:"339525398fe45f73c8b759eee01a7ce1713d18544d56ee4864e049b966e6294d",appFullHash:"c7a09470f7a37851a8acf98adabf3e2c2f1f7edefd31c6b54dc1c7dc2991d853",appName:"Ethereum"}],b=Uint8Array.from([1,77,0,1,202,64,220,134,34,156,121,10,224,62,185,19,9,238,28,148,96,10,109,223,73,10,157,105,11,251,10,47,2,2,14,187,76,31,180,194,230,27,174,27,171,43,115,71,223,59,59,26,47,217,241,251,175,251,58,165,248,170,35,62,210,191,170,188,193,62,7,80,111,108,121,103,111,110]),i=[{appEntryLength:77,appSizeInBlocks:1,appCodeHash:"dc86229c790ae03eb91309ee1c94600a6ddf490a9d690bfb0a2f02020ebb4c1f",appFullHash:"b4c2e61bae1bab2b7347df3b3b1a2fd9f1fbaffb3aa5f8aa233ed2bfaabcc13e",appName:"Polygon"}],u=Uint8Array.from([1,89,0,1,202,64,251,43,125,38,37,215,24,132,39,7,5,83,16,128,194,24,40,121,221,30,217,227,75,22,186,228,208,118,155,69,215,216,215,91,55,95,106,51,161,230,117,121,38,154,22,239,68,36,163,217,32,82,21,182,21,43,106,216,188,201,14,60,50,249,19,66,105,110,97,110,99,101,32,83,109,97,114,116,32,67,104,97,105,110,76,0,14,202,0,254,230,25,86,26,175,67,41,98,12,2,216,72,142,63,117,164,53,51,23,34,245,97,21,121,247,83,151,128,148,209,20,204,191,178,86,114,154,158,40,116,183,35,214,76,228,135,243,87,239,167,22,178,208,205,52,152,151,233,110,116,32,42,202,6,83,111,108,97,110,97]),A=[{appEntryLength:89,appSizeInBlocks:1,appCodeHash:"fb2b7d2625d71884270705531080c2182879dd1ed9e34b16bae4d0769b45d7d8",appFullHash:"d75b375f6a33a1e67579269a16ef4424a3d9205215b6152b6ad8bcc90e3c32f9",appName:"Binance Smart Chain"},{appEntryLength:76,appSizeInBlocks:14,appCodeHash:"fee619561aaf4329620c02d8488e3f75a435331722f5611579f753978094d114",appFullHash:"ccbfb256729a9e2874b723d64ce487f357efa716b2d0cd349897e96e74202aca",appName:"Solana"}];describe("ListAppCommand",()=>{let e;describe("name",()=>{it("should be 'listApps'",()=>{expect(new r.ListAppsCommand().name).toBe("listApps")})}),describe("first list app command",()=>{beforeEach(()=>{e=new r.ListAppsCommand}),describe("getApdu",()=>{it("should return the ListApp APDU",()=>{const x=e.getApdu();expect(x.getRawApdu()).toStrictEqual(p)})}),describe("parseResponse",()=>{it("should parse the response with no apps",()=>{const x=new t.ApduResponse({statusCode:Uint8Array.from([144,0]),data:new Uint8Array});expect(e.parseResponse(x)).toStrictEqual((0,a.CommandResultFactory)({data:[]}))}),it("should parse the response with 1 app",()=>{const x=new t.ApduResponse({statusCode:Uint8Array.from([144,0]),data:o});expect(e.parseResponse(x)).toStrictEqual((0,a.CommandResultFactory)({data:c}))}),it("should parse the response with 2 apps",()=>{const x=new t.ApduResponse({statusCode:Uint8Array.from([144,0]),data:f});expect(e.parseResponse(x)).toStrictEqual((0,a.CommandResultFactory)({data:n}))})}),describe("errors",()=>{it("should return error command result if the response status code is not success",()=>{const x=new t.ApduResponse({statusCode:Uint8Array.from([106,130]),data:new Uint8Array}),s=e.parseResponse(x);expect((0,a.isSuccessCommandResult)(s)).toBe(!1)}),it("should return an error",()=>{const x=new t.ApduResponse({statusCode:Uint8Array.from([85,1]),data:new Uint8Array}),s=e.parseResponse(x);expect((0,a.isSuccessCommandResult)(s)).toBe(!1)})})}),describe("continue list app command",()=>{beforeEach(()=>{e=new r.ListAppsCommand({isContinue:!0})}),describe("getApdu",()=>{it("should return the Continue ListApp APDU",()=>{const x=e.getApdu();expect(x.getRawApdu()).toStrictEqual(d)})}),describe("parseResponse",()=>{it("should parse the response with 1 app",()=>{const x=new t.ApduResponse({statusCode:Uint8Array.from([144,0]),data:b});expect(e.parseResponse(x)).toStrictEqual((0,a.CommandResultFactory)({data:i}))}),it("should parse the response with 2 apps",()=>{const x=new t.ApduResponse({statusCode:Uint8Array.from([144,0]),data:u});expect(e.parseResponse(x)).toStrictEqual((0,a.CommandResultFactory)({data:A}))}),it("should parse the response when reaching the end of the list",()=>{const x=new t.ApduResponse({statusCode:Uint8Array.from([144,0]),data:new Uint8Array});expect(e.parseResponse(x)).toStrictEqual((0,a.CommandResultFactory)({data:[]}))})}),describe("errors",()=>{it("should throw if ListApp wasn't called before",()=>{const x=new t.ApduResponse({statusCode:Uint8Array.from([102,36]),data:new Uint8Array}),s=e.parseResponse(x);expect((0,a.isSuccessCommandResult)(s)).toBe(!1),expect(s.error).toBeInstanceOf(r.ListAppsCommandError)})})})});
|
|
2
2
|
//# sourceMappingURL=ListAppsCommand.test.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../../src/api/command/os/ListAppsCommand.test.ts"],
|
|
4
|
-
"sourcesContent": ["import {\n type CommandErrorResult,\n CommandResultFactory,\n isSuccessCommandResult,\n} from \"@api/command/model/CommandResult\";\nimport { ApduResponse } from \"@api/device-session/ApduResponse\";\n\nimport {\n ListAppsCommand,\n ListAppsCommandError,\n type ListAppsErrorCodes,\n} from \"./ListAppsCommand\";\n\n// [NOTE] EXAMPLES CREATED USING A NANO X\n\nconst LIST_APP_APDU = Uint8Array.from([0xe0, 0xde, 0x00, 0x00, 0x00]);\nconst CONTINUE_LIST_APP_ADPU = Uint8Array.from([0xe0, 0xdf, 0x00, 0x00, 0x00]);\n\n// only BITCOIN installed\nconst LIST_APP_RESPONSE_1_APP = Uint8Array.from([\n 0x01, 0x4d, 0x00, 0x13, 0xca, 0x50, 0xa2, 0x25, 0x9e, 0x03, 0xa9, 0x89, 0x49,\n 0x54, 0x1f, 0xf3, 0xda, 0xf1, 0x86, 0x29, 0xa3, 0x0f, 0xb1, 0x69, 0xaf, 0x18,\n 0xd2, 0x71, 0x2b, 0xa8, 0xb8, 0x29, 0x6f, 0xf1, 0xc5, 0x31, 0x0f, 0xa5, 0xa9,\n 0x7e, 0xff, 0xa8, 0x16, 0x73, 0x7b, 0xaf, 0x49, 0x63, 0x5a, 0x42, 0x35, 0x70,\n 0x12, 0x73, 0x4b, 0x90, 0x9e, 0x27, 0x96, 0xd4, 0xe7, 0xf1, 0x4b, 0x2c, 0xcd,\n 0x9c, 0xa4, 0x76, 0x28, 0x34, 0x07, 0x42, 0x69, 0x74, 0x63, 0x6f, 0x69, 0x6e,\n]);\nconst LIST_APP_RESPONSE_1_APP_EXPECTED = [\n {\n appEntryLength: 77,\n appSizeInBlocks: 19,\n appCodeHash:\n \"a2259e03a98949541ff3daf18629a30fb169af18d2712ba8b8296ff1c5310fa5\",\n appFullHash:\n \"a97effa816737baf49635a42357012734b909e2796d4e7f14b2ccd9ca4762834\",\n appName: \"Bitcoin\",\n },\n];\n\n// BITCOIN & ETHEREUM installed\nconst LIST_APP_RESPONSE_2_APPS = Uint8Array.from([\n 0x01, 0x4d, 0x00, 0x13, 0xca, 0x50, 0xa2, 0x25, 0x9e, 0x03, 0xa9, 0x89, 0x49,\n 0x54, 0x1f, 0xf3, 0xda, 0xf1, 0x86, 0x29, 0xa3, 0x0f, 0xb1, 0x69, 0xaf, 0x18,\n 0xd2, 0x71, 0x2b, 0xa8, 0xb8, 0x29, 0x6f, 0xf1, 0xc5, 0x31, 0x0f, 0xa5, 0xa9,\n 0x7e, 0xff, 0xa8, 0x16, 0x73, 0x7b, 0xaf, 0x49, 0x63, 0x5a, 0x42, 0x35, 0x70,\n 0x12, 0x73, 0x4b, 0x90, 0x9e, 0x27, 0x96, 0xd4, 0xe7, 0xf1, 0x4b, 0x2c, 0xcd,\n 0x9c, 0xa4, 0x76, 0x28, 0x34, 0x07, 0x42, 0x69, 0x74, 0x63, 0x6f, 0x69, 0x6e,\n 0x4e, 0x00, 0x13, 0xca, 0x40, 0x33, 0x95, 0x25, 0x39, 0x8f, 0xe4, 0x5f, 0x73,\n 0xc8, 0xb7, 0x59, 0xee, 0xe0, 0x1a, 0x7c, 0xe1, 0x71, 0x3d, 0x18, 0x54, 0x4d,\n 0x56, 0xee, 0x48, 0x64, 0xe0, 0x49, 0xb9, 0x66, 0xe6, 0x29, 0x4d, 0xc7, 0xa0,\n 0x94, 0x70, 0xf7, 0xa3, 0x78, 0x51, 0xa8, 0xac, 0xf9, 0x8a, 0xda, 0xbf, 0x3e,\n 0x2c, 0x2f, 0x1f, 0x7e, 0xde, 0xfd, 0x31, 0xc6, 0xb5, 0x4d, 0xc1, 0xc7, 0xdc,\n 0x29, 0x91, 0xd8, 0x53, 0x08, 0x45, 0x74, 0x68, 0x65, 0x72, 0x65, 0x75, 0x6d,\n]);\nconst LIST_APP_RESPONSE_2_APPS_EXPECTED = [\n {\n appEntryLength: 77,\n appSizeInBlocks: 19,\n appCodeHash:\n \"a2259e03a98949541ff3daf18629a30fb169af18d2712ba8b8296ff1c5310fa5\",\n appFullHash:\n \"a97effa816737baf49635a42357012734b909e2796d4e7f14b2ccd9ca4762834\",\n appName: \"Bitcoin\",\n },\n {\n appEntryLength: 78,\n appSizeInBlocks: 19,\n appCodeHash:\n \"339525398fe45f73c8b759eee01a7ce1713d18544d56ee4864e049b966e6294d\",\n appFullHash:\n \"c7a09470f7a37851a8acf98adabf3e2c2f1f7edefd31c6b54dc1c7dc2991d853\",\n appName: \"Ethereum\",\n },\n];\n\n// POLYGON as the last installed app\nconst LIST_APP_RESPONSE_CONTINUE_1_APP = Uint8Array.from([\n 0x01, 0x4d, 0x00, 0x01, 0xca, 0x40, 0xdc, 0x86, 0x22, 0x9c, 0x79, 0x0a, 0xe0,\n 0x3e, 0xb9, 0x13, 0x09, 0xee, 0x1c, 0x94, 0x60, 0x0a, 0x6d, 0xdf, 0x49, 0x0a,\n 0x9d, 0x69, 0x0b, 0xfb, 0x0a, 0x2f, 0x02, 0x02, 0x0e, 0xbb, 0x4c, 0x1f, 0xb4,\n 0xc2, 0xe6, 0x1b, 0xae, 0x1b, 0xab, 0x2b, 0x73, 0x47, 0xdf, 0x3b, 0x3b, 0x1a,\n 0x2f, 0xd9, 0xf1, 0xfb, 0xaf, 0xfb, 0x3a, 0xa5, 0xf8, 0xaa, 0x23, 0x3e, 0xd2,\n 0xbf, 0xaa, 0xbc, 0xc1, 0x3e, 0x07, 0x50, 0x6f, 0x6c, 0x79, 0x67, 0x6f, 0x6e,\n]);\nconst LIST_APP_RESPONSE_CONTINUE_1_APP_EXPECTED = [\n {\n appEntryLength: 77,\n appSizeInBlocks: 1,\n appCodeHash:\n \"dc86229c790ae03eb91309ee1c94600a6ddf490a9d690bfb0a2f02020ebb4c1f\",\n appFullHash:\n \"b4c2e61bae1bab2b7347df3b3b1a2fd9f1fbaffb3aa5f8aa233ed2bfaabcc13e\",\n appName: \"Polygon\",\n },\n];\n\n// BINANCE SMART CHAIN & SOLANA installed\nconst LIST_APP_RESPONSE_CONTINUE_2_APPS = Uint8Array.from([\n 0x01, 0x59, 0x00, 0x01, 0xca, 0x40, 0xfb, 0x2b, 0x7d, 0x26, 0x25, 0xd7, 0x18,\n 0x84, 0x27, 0x07, 0x05, 0x53, 0x10, 0x80, 0xc2, 0x18, 0x28, 0x79, 0xdd, 0x1e,\n 0xd9, 0xe3, 0x4b, 0x16, 0xba, 0xe4, 0xd0, 0x76, 0x9b, 0x45, 0xd7, 0xd8, 0xd7,\n 0x5b, 0x37, 0x5f, 0x6a, 0x33, 0xa1, 0xe6, 0x75, 0x79, 0x26, 0x9a, 0x16, 0xef,\n 0x44, 0x24, 0xa3, 0xd9, 0x20, 0x52, 0x15, 0xb6, 0x15, 0x2b, 0x6a, 0xd8, 0xbc,\n 0xc9, 0x0e, 0x3c, 0x32, 0xf9, 0x13, 0x42, 0x69, 0x6e, 0x61, 0x6e, 0x63, 0x65,\n 0x20, 0x53, 0x6d, 0x61, 0x72, 0x74, 0x20, 0x43, 0x68, 0x61, 0x69, 0x6e, 0x4c,\n 0x00, 0x0e, 0xca, 0x00, 0xfe, 0xe6, 0x19, 0x56, 0x1a, 0xaf, 0x43, 0x29, 0x62,\n 0x0c, 0x02, 0xd8, 0x48, 0x8e, 0x3f, 0x75, 0xa4, 0x35, 0x33, 0x17, 0x22, 0xf5,\n 0x61, 0x15, 0x79, 0xf7, 0x53, 0x97, 0x80, 0x94, 0xd1, 0x14, 0xcc, 0xbf, 0xb2,\n 0x56, 0x72, 0x9a, 0x9e, 0x28, 0x74, 0xb7, 0x23, 0xd6, 0x4c, 0xe4, 0x87, 0xf3,\n 0x57, 0xef, 0xa7, 0x16, 0xb2, 0xd0, 0xcd, 0x34, 0x98, 0x97, 0xe9, 0x6e, 0x74,\n 0x20, 0x2a, 0xca, 0x06, 0x53, 0x6f, 0x6c, 0x61, 0x6e, 0x61,\n]);\nconst LIST_APP_RESPONSE_CONTINUE_2_APPS_EXPECTED = [\n {\n appEntryLength: 89,\n appSizeInBlocks: 1,\n appCodeHash:\n \"fb2b7d2625d71884270705531080c2182879dd1ed9e34b16bae4d0769b45d7d8\",\n appFullHash:\n \"d75b375f6a33a1e67579269a16ef4424a3d9205215b6152b6ad8bcc90e3c32f9\",\n appName: \"Binance Smart Chain\",\n },\n {\n appEntryLength: 76,\n appSizeInBlocks: 14,\n appCodeHash:\n \"fee619561aaf4329620c02d8488e3f75a435331722f5611579f753978094d114\",\n appFullHash:\n \"ccbfb256729a9e2874b723d64ce487f357efa716b2d0cd349897e96e74202aca\",\n appName: \"Solana\",\n },\n];\n\ndescribe(\"ListAppCommand\", () => {\n let command: ListAppsCommand;\n\n describe(\"first list app command\", () => {\n beforeEach(() => {\n command = new ListAppsCommand();\n });\n\n describe(\"getApdu\", () => {\n it(\"should return the ListApp APDU\", () => {\n const apdu = command.getApdu();\n expect(apdu.getRawApdu()).toStrictEqual(LIST_APP_APDU);\n });\n });\n\n describe(\"parseResponse\", () => {\n it(\"should parse the response with no apps\", () => {\n const response = new ApduResponse({\n statusCode: Uint8Array.from([0x90, 0x00]),\n data: new Uint8Array(),\n });\n\n expect(command.parseResponse(response)).toStrictEqual(\n CommandResultFactory({ data: [] }),\n );\n });\n\n it(\"should parse the response with 1 app\", () => {\n const response = new ApduResponse({\n statusCode: Uint8Array.from([0x90, 0x00]),\n data: LIST_APP_RESPONSE_1_APP,\n });\n\n expect(command.parseResponse(response)).toStrictEqual(\n CommandResultFactory({ data: LIST_APP_RESPONSE_1_APP_EXPECTED }),\n );\n });\n\n it(\"should parse the response with 2 apps\", () => {\n const response = new ApduResponse({\n statusCode: Uint8Array.from([0x90, 0x00]),\n data: LIST_APP_RESPONSE_2_APPS,\n });\n\n expect(command.parseResponse(response)).toStrictEqual(\n CommandResultFactory({ data: LIST_APP_RESPONSE_2_APPS_EXPECTED }),\n );\n });\n });\n\n describe(\"errors\", () => {\n it(\"should return error command result if the response status code is not success\", () => {\n const response = new ApduResponse({\n statusCode: Uint8Array.from([0x6a, 0x82]),\n data: new Uint8Array(),\n });\n const result = command.parseResponse(response);\n\n expect(isSuccessCommandResult(result)).toBe(false);\n });\n\n it(\"should return an error\", () => {\n const response = new ApduResponse({\n statusCode: Uint8Array.from([0x55, 0x01]),\n data: new Uint8Array(),\n });\n\n // when\n const result = command.parseResponse(response);\n\n expect(isSuccessCommandResult(result)).toBe(false);\n });\n });\n });\n\n describe(\"continue list app command\", () => {\n beforeEach(() => {\n command = new ListAppsCommand({ isContinue: true });\n });\n\n describe(\"getApdu\", () => {\n it(\"should return the Continue ListApp APDU\", () => {\n const apdu = command.getApdu();\n expect(apdu.getRawApdu()).toStrictEqual(CONTINUE_LIST_APP_ADPU);\n });\n });\n\n describe(\"parseResponse\", () => {\n it(\"should parse the response with 1 app\", () => {\n const response = new ApduResponse({\n statusCode: Uint8Array.from([0x90, 0x00]),\n data: LIST_APP_RESPONSE_CONTINUE_1_APP,\n });\n\n expect(command.parseResponse(response)).toStrictEqual(\n CommandResultFactory({\n data: LIST_APP_RESPONSE_CONTINUE_1_APP_EXPECTED,\n }),\n );\n });\n\n it(\"should parse the response with 2 apps\", () => {\n const response = new ApduResponse({\n statusCode: Uint8Array.from([0x90, 0x00]),\n data: LIST_APP_RESPONSE_CONTINUE_2_APPS,\n });\n\n expect(command.parseResponse(response)).toStrictEqual(\n CommandResultFactory({\n data: LIST_APP_RESPONSE_CONTINUE_2_APPS_EXPECTED,\n }),\n );\n });\n\n it(\"should parse the response when reaching the end of the list\", () => {\n const response = new ApduResponse({\n statusCode: Uint8Array.from([0x90, 0x00]),\n data: new Uint8Array(),\n });\n\n expect(command.parseResponse(response)).toStrictEqual(\n CommandResultFactory({ data: [] }),\n );\n });\n });\n\n describe(\"errors\", () => {\n it(\"should throw if ListApp wasn't called before\", () => {\n const response = new ApduResponse({\n statusCode: Uint8Array.from([0x66, 0x24]),\n data: new Uint8Array(),\n });\n const result = command.parseResponse(\n response,\n ) as CommandErrorResult<ListAppsErrorCodes>;\n\n expect(isSuccessCommandResult(result)).toBe(false);\n expect(result.error).toBeInstanceOf(ListAppsCommandError);\n });\n });\n });\n});\n"],
|
|
5
|
-
"mappings": "aAAA,IAAAA,EAIO,4CACPC,EAA6B,4CAE7BC,EAIO,6BAIP,MAAMC,EAAgB,WAAW,KAAK,CAAC,IAAM,IAAM,EAAM,EAAM,CAAI,CAAC,EAC9DC,EAAyB,WAAW,KAAK,CAAC,IAAM,IAAM,EAAM,EAAM,CAAI,CAAC,EAGvEC,EAA0B,WAAW,KAAK,CAC9C,EAAM,GAAM,EAAM,GAAM,IAAM,GAAM,IAAM,GAAM,IAAM,EAAM,IAAM,IAAM,GACxE,GAAM,GAAM,IAAM,IAAM,IAAM,IAAM,GAAM,IAAM,GAAM,IAAM,IAAM,IAAM,GACxE,IAAM,IAAM,GAAM,IAAM,IAAM,GAAM,IAAM,IAAM,IAAM,GAAM,GAAM,IAAM,IACxE,IAAM,IAAM,IAAM,GAAM,IAAM,IAAM,IAAM,GAAM,GA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essCommandResult,\n} from \"@api/command/model/CommandResult\";\nimport { ApduResponse } from \"@api/device-session/ApduResponse\";\n\nimport {\n ListAppsCommand,\n ListAppsCommandError,\n type ListAppsErrorCodes,\n} from \"./ListAppsCommand\";\n\n// [NOTE] EXAMPLES CREATED USING A NANO X\n\nconst LIST_APP_APDU = Uint8Array.from([0xe0, 0xde, 0x00, 0x00, 0x00]);\nconst CONTINUE_LIST_APP_ADPU = Uint8Array.from([0xe0, 0xdf, 0x00, 0x00, 0x00]);\n\n// only BITCOIN installed\nconst LIST_APP_RESPONSE_1_APP = Uint8Array.from([\n 0x01, 0x4d, 0x00, 0x13, 0xca, 0x50, 0xa2, 0x25, 0x9e, 0x03, 0xa9, 0x89, 0x49,\n 0x54, 0x1f, 0xf3, 0xda, 0xf1, 0x86, 0x29, 0xa3, 0x0f, 0xb1, 0x69, 0xaf, 0x18,\n 0xd2, 0x71, 0x2b, 0xa8, 0xb8, 0x29, 0x6f, 0xf1, 0xc5, 0x31, 0x0f, 0xa5, 0xa9,\n 0x7e, 0xff, 0xa8, 0x16, 0x73, 0x7b, 0xaf, 0x49, 0x63, 0x5a, 0x42, 0x35, 0x70,\n 0x12, 0x73, 0x4b, 0x90, 0x9e, 0x27, 0x96, 0xd4, 0xe7, 0xf1, 0x4b, 0x2c, 0xcd,\n 0x9c, 0xa4, 0x76, 0x28, 0x34, 0x07, 0x42, 0x69, 0x74, 0x63, 0x6f, 0x69, 0x6e,\n]);\nconst LIST_APP_RESPONSE_1_APP_EXPECTED = [\n {\n appEntryLength: 77,\n appSizeInBlocks: 19,\n appCodeHash:\n \"a2259e03a98949541ff3daf18629a30fb169af18d2712ba8b8296ff1c5310fa5\",\n appFullHash:\n \"a97effa816737baf49635a42357012734b909e2796d4e7f14b2ccd9ca4762834\",\n appName: \"Bitcoin\",\n },\n];\n\n// BITCOIN & ETHEREUM installed\nconst LIST_APP_RESPONSE_2_APPS = Uint8Array.from([\n 0x01, 0x4d, 0x00, 0x13, 0xca, 0x50, 0xa2, 0x25, 0x9e, 0x03, 0xa9, 0x89, 0x49,\n 0x54, 0x1f, 0xf3, 0xda, 0xf1, 0x86, 0x29, 0xa3, 0x0f, 0xb1, 0x69, 0xaf, 0x18,\n 0xd2, 0x71, 0x2b, 0xa8, 0xb8, 0x29, 0x6f, 0xf1, 0xc5, 0x31, 0x0f, 0xa5, 0xa9,\n 0x7e, 0xff, 0xa8, 0x16, 0x73, 0x7b, 0xaf, 0x49, 0x63, 0x5a, 0x42, 0x35, 0x70,\n 0x12, 0x73, 0x4b, 0x90, 0x9e, 0x27, 0x96, 0xd4, 0xe7, 0xf1, 0x4b, 0x2c, 0xcd,\n 0x9c, 0xa4, 0x76, 0x28, 0x34, 0x07, 0x42, 0x69, 0x74, 0x63, 0x6f, 0x69, 0x6e,\n 0x4e, 0x00, 0x13, 0xca, 0x40, 0x33, 0x95, 0x25, 0x39, 0x8f, 0xe4, 0x5f, 0x73,\n 0xc8, 0xb7, 0x59, 0xee, 0xe0, 0x1a, 0x7c, 0xe1, 0x71, 0x3d, 0x18, 0x54, 0x4d,\n 0x56, 0xee, 0x48, 0x64, 0xe0, 0x49, 0xb9, 0x66, 0xe6, 0x29, 0x4d, 0xc7, 0xa0,\n 0x94, 0x70, 0xf7, 0xa3, 0x78, 0x51, 0xa8, 0xac, 0xf9, 0x8a, 0xda, 0xbf, 0x3e,\n 0x2c, 0x2f, 0x1f, 0x7e, 0xde, 0xfd, 0x31, 0xc6, 0xb5, 0x4d, 0xc1, 0xc7, 0xdc,\n 0x29, 0x91, 0xd8, 0x53, 0x08, 0x45, 0x74, 0x68, 0x65, 0x72, 0x65, 0x75, 0x6d,\n]);\nconst LIST_APP_RESPONSE_2_APPS_EXPECTED = [\n {\n appEntryLength: 77,\n appSizeInBlocks: 19,\n appCodeHash:\n \"a2259e03a98949541ff3daf18629a30fb169af18d2712ba8b8296ff1c5310fa5\",\n appFullHash:\n \"a97effa816737baf49635a42357012734b909e2796d4e7f14b2ccd9ca4762834\",\n appName: \"Bitcoin\",\n },\n {\n appEntryLength: 78,\n appSizeInBlocks: 19,\n appCodeHash:\n \"339525398fe45f73c8b759eee01a7ce1713d18544d56ee4864e049b966e6294d\",\n appFullHash:\n \"c7a09470f7a37851a8acf98adabf3e2c2f1f7edefd31c6b54dc1c7dc2991d853\",\n appName: \"Ethereum\",\n },\n];\n\n// POLYGON as the last installed app\nconst LIST_APP_RESPONSE_CONTINUE_1_APP = Uint8Array.from([\n 0x01, 0x4d, 0x00, 0x01, 0xca, 0x40, 0xdc, 0x86, 0x22, 0x9c, 0x79, 0x0a, 0xe0,\n 0x3e, 0xb9, 0x13, 0x09, 0xee, 0x1c, 0x94, 0x60, 0x0a, 0x6d, 0xdf, 0x49, 0x0a,\n 0x9d, 0x69, 0x0b, 0xfb, 0x0a, 0x2f, 0x02, 0x02, 0x0e, 0xbb, 0x4c, 0x1f, 0xb4,\n 0xc2, 0xe6, 0x1b, 0xae, 0x1b, 0xab, 0x2b, 0x73, 0x47, 0xdf, 0x3b, 0x3b, 0x1a,\n 0x2f, 0xd9, 0xf1, 0xfb, 0xaf, 0xfb, 0x3a, 0xa5, 0xf8, 0xaa, 0x23, 0x3e, 0xd2,\n 0xbf, 0xaa, 0xbc, 0xc1, 0x3e, 0x07, 0x50, 0x6f, 0x6c, 0x79, 0x67, 0x6f, 0x6e,\n]);\nconst LIST_APP_RESPONSE_CONTINUE_1_APP_EXPECTED = [\n {\n appEntryLength: 77,\n appSizeInBlocks: 1,\n appCodeHash:\n \"dc86229c790ae03eb91309ee1c94600a6ddf490a9d690bfb0a2f02020ebb4c1f\",\n appFullHash:\n \"b4c2e61bae1bab2b7347df3b3b1a2fd9f1fbaffb3aa5f8aa233ed2bfaabcc13e\",\n appName: \"Polygon\",\n },\n];\n\n// BINANCE SMART CHAIN & SOLANA installed\nconst LIST_APP_RESPONSE_CONTINUE_2_APPS = Uint8Array.from([\n 0x01, 0x59, 0x00, 0x01, 0xca, 0x40, 0xfb, 0x2b, 0x7d, 0x26, 0x25, 0xd7, 0x18,\n 0x84, 0x27, 0x07, 0x05, 0x53, 0x10, 0x80, 0xc2, 0x18, 0x28, 0x79, 0xdd, 0x1e,\n 0xd9, 0xe3, 0x4b, 0x16, 0xba, 0xe4, 0xd0, 0x76, 0x9b, 0x45, 0xd7, 0xd8, 0xd7,\n 0x5b, 0x37, 0x5f, 0x6a, 0x33, 0xa1, 0xe6, 0x75, 0x79, 0x26, 0x9a, 0x16, 0xef,\n 0x44, 0x24, 0xa3, 0xd9, 0x20, 0x52, 0x15, 0xb6, 0x15, 0x2b, 0x6a, 0xd8, 0xbc,\n 0xc9, 0x0e, 0x3c, 0x32, 0xf9, 0x13, 0x42, 0x69, 0x6e, 0x61, 0x6e, 0x63, 0x65,\n 0x20, 0x53, 0x6d, 0x61, 0x72, 0x74, 0x20, 0x43, 0x68, 0x61, 0x69, 0x6e, 0x4c,\n 0x00, 0x0e, 0xca, 0x00, 0xfe, 0xe6, 0x19, 0x56, 0x1a, 0xaf, 0x43, 0x29, 0x62,\n 0x0c, 0x02, 0xd8, 0x48, 0x8e, 0x3f, 0x75, 0xa4, 0x35, 0x33, 0x17, 0x22, 0xf5,\n 0x61, 0x15, 0x79, 0xf7, 0x53, 0x97, 0x80, 0x94, 0xd1, 0x14, 0xcc, 0xbf, 0xb2,\n 0x56, 0x72, 0x9a, 0x9e, 0x28, 0x74, 0xb7, 0x23, 0xd6, 0x4c, 0xe4, 0x87, 0xf3,\n 0x57, 0xef, 0xa7, 0x16, 0xb2, 0xd0, 0xcd, 0x34, 0x98, 0x97, 0xe9, 0x6e, 0x74,\n 0x20, 0x2a, 0xca, 0x06, 0x53, 0x6f, 0x6c, 0x61, 0x6e, 0x61,\n]);\nconst LIST_APP_RESPONSE_CONTINUE_2_APPS_EXPECTED = [\n {\n appEntryLength: 89,\n appSizeInBlocks: 1,\n appCodeHash:\n \"fb2b7d2625d71884270705531080c2182879dd1ed9e34b16bae4d0769b45d7d8\",\n appFullHash:\n \"d75b375f6a33a1e67579269a16ef4424a3d9205215b6152b6ad8bcc90e3c32f9\",\n appName: \"Binance Smart Chain\",\n },\n {\n appEntryLength: 76,\n appSizeInBlocks: 14,\n appCodeHash:\n \"fee619561aaf4329620c02d8488e3f75a435331722f5611579f753978094d114\",\n appFullHash:\n \"ccbfb256729a9e2874b723d64ce487f357efa716b2d0cd349897e96e74202aca\",\n appName: \"Solana\",\n },\n];\n\ndescribe(\"ListAppCommand\", () => {\n let command: ListAppsCommand;\n\n describe(\"name\", () => {\n it(\"should be 'listApps'\", () => {\n expect(new ListAppsCommand().name).toBe(\"listApps\");\n });\n });\n\n describe(\"first list app command\", () => {\n beforeEach(() => {\n command = new ListAppsCommand();\n });\n\n describe(\"getApdu\", () => {\n it(\"should return the ListApp APDU\", () => {\n const apdu = command.getApdu();\n expect(apdu.getRawApdu()).toStrictEqual(LIST_APP_APDU);\n });\n });\n\n describe(\"parseResponse\", () => {\n it(\"should parse the response with no apps\", () => {\n const response = new ApduResponse({\n statusCode: Uint8Array.from([0x90, 0x00]),\n data: new Uint8Array(),\n });\n\n expect(command.parseResponse(response)).toStrictEqual(\n CommandResultFactory({ data: [] }),\n );\n });\n\n it(\"should parse the response with 1 app\", () => {\n const response = new ApduResponse({\n statusCode: Uint8Array.from([0x90, 0x00]),\n data: LIST_APP_RESPONSE_1_APP,\n });\n\n expect(command.parseResponse(response)).toStrictEqual(\n CommandResultFactory({ data: LIST_APP_RESPONSE_1_APP_EXPECTED }),\n );\n });\n\n it(\"should parse the response with 2 apps\", () => {\n const response = new ApduResponse({\n statusCode: Uint8Array.from([0x90, 0x00]),\n data: LIST_APP_RESPONSE_2_APPS,\n });\n\n expect(command.parseResponse(response)).toStrictEqual(\n CommandResultFactory({ data: LIST_APP_RESPONSE_2_APPS_EXPECTED }),\n );\n });\n });\n\n describe(\"errors\", () => {\n it(\"should return error command result if the response status code is not success\", () => {\n const response = new ApduResponse({\n statusCode: Uint8Array.from([0x6a, 0x82]),\n data: new Uint8Array(),\n });\n const result = command.parseResponse(response);\n\n expect(isSuccessCommandResult(result)).toBe(false);\n });\n\n it(\"should return an error\", () => {\n const response = new ApduResponse({\n statusCode: Uint8Array.from([0x55, 0x01]),\n data: new Uint8Array(),\n });\n\n // when\n const result = command.parseResponse(response);\n\n expect(isSuccessCommandResult(result)).toBe(false);\n });\n });\n });\n\n describe(\"continue list app command\", () => {\n beforeEach(() => {\n command = new ListAppsCommand({ isContinue: true });\n });\n\n describe(\"getApdu\", () => {\n it(\"should return the Continue ListApp APDU\", () => {\n const apdu = command.getApdu();\n expect(apdu.getRawApdu()).toStrictEqual(CONTINUE_LIST_APP_ADPU);\n });\n });\n\n describe(\"parseResponse\", () => {\n it(\"should parse the response with 1 app\", () => {\n const response = new ApduResponse({\n statusCode: Uint8Array.from([0x90, 0x00]),\n data: LIST_APP_RESPONSE_CONTINUE_1_APP,\n });\n\n expect(command.parseResponse(response)).toStrictEqual(\n CommandResultFactory({\n data: LIST_APP_RESPONSE_CONTINUE_1_APP_EXPECTED,\n }),\n );\n });\n\n it(\"should parse the response with 2 apps\", () => {\n const response = new ApduResponse({\n statusCode: Uint8Array.from([0x90, 0x00]),\n data: LIST_APP_RESPONSE_CONTINUE_2_APPS,\n });\n\n expect(command.parseResponse(response)).toStrictEqual(\n CommandResultFactory({\n data: LIST_APP_RESPONSE_CONTINUE_2_APPS_EXPECTED,\n }),\n );\n });\n\n it(\"should parse the response when reaching the end of the list\", () => {\n const response = new ApduResponse({\n statusCode: Uint8Array.from([0x90, 0x00]),\n data: new Uint8Array(),\n });\n\n expect(command.parseResponse(response)).toStrictEqual(\n CommandResultFactory({ data: [] }),\n );\n });\n });\n\n describe(\"errors\", () => {\n it(\"should throw if ListApp wasn't called before\", () => {\n const response = new ApduResponse({\n statusCode: Uint8Array.from([0x66, 0x24]),\n data: new Uint8Array(),\n });\n const result = command.parseResponse(\n response,\n ) as CommandErrorResult<ListAppsErrorCodes>;\n\n expect(isSuccessCommandResult(result)).toBe(false);\n expect(result.error).toBe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,iBACtC,wBAAqB,CACnB,KAAMH,CACR,CAAC,CACH,CACF,CAAC,EAED,GAAG,8DAA+D,IAAM,CACtE,MAAMG,EAAW,IAAI,eAAa,CAChC,WAAY,WAAW,KAAK,CAAC,IAAM,CAAI,CAAC,EACxC,KAAM,IAAI,UACZ,CAAC,EAED,OAAOF,EAAQ,cAAcE,CAAQ,CAAC,EAAE,iBACtC,wBAAqB,CAAE,KAAM,CAAC,CAAE,CAAC,CACnC,CACF,CAAC,CACH,CAAC,EAED,SAAS,SAAU,IAAM,CACvB,GAAG,+CAAgD,IAAM,CACvD,MAAMA,EAAW,IAAI,eAAa,CAChC,WAAY,WAAW,KAAK,CAAC,IAAM,EAAI,CAAC,EACxC,KAAM,IAAI,UACZ,CAAC,EACKC,EAASH,EAAQ,cACrBE,CACF,EAEA,UAAO,0BAAuBC,CAAM,CAAC,EAAE,KAAK,EAAK,EACjD,OAAOA,EAAO,KAAK,EAAE,eAAe,sBAAoB,CAC1D,CAAC,CACH,CAAC,CACH,CAAC,CACH,CAAC",
|
|
6
6
|
"names": ["import_CommandResult", "import_ApduResponse", "import_ListAppsCommand", "LIST_APP_APDU", "CONTINUE_LIST_APP_ADPU", "LIST_APP_RESPONSE_1_APP", "LIST_APP_RESPONSE_1_APP_EXPECTED", "LIST_APP_RESPONSE_2_APPS", "LIST_APP_RESPONSE_2_APPS_EXPECTED", "LIST_APP_RESPONSE_CONTINUE_1_APP", "LIST_APP_RESPONSE_CONTINUE_1_APP_EXPECTED", "LIST_APP_RESPONSE_CONTINUE_2_APPS", "LIST_APP_RESPONSE_CONTINUE_2_APPS_EXPECTED", "command", "apdu", "response", "result"]
|
|
7
7
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";var d=Object.defineProperty;var P=Object.getOwnPropertyDescriptor;var x=Object.getOwnPropertyNames;var y=Object.prototype.hasOwnProperty;var R=(
|
|
1
|
+
"use strict";var d=Object.defineProperty;var P=Object.getOwnPropertyDescriptor;var x=Object.getOwnPropertyNames;var y=Object.prototype.hasOwnProperty;var R=(a,r)=>{for(var e in r)d(a,e,{get:r[e],enumerable:!0})},I=(a,r,e,n)=>{if(r&&typeof r=="object"||typeof r=="function")for(let o of x(r))!y.call(a,o)&&o!==e&&d(a,o,{get:()=>r[o],enumerable:!(n=P(r,o))||n.enumerable});return a};var S=a=>I(d({},"__esModule",{value:!0}),a);var B={};R(B,{ListLanguagePackCommand:()=>b,ListLanguagePackCommandError:()=>A});module.exports=S(B);var p=require("../../apdu/utils/ApduBuilder"),c=require("../../apdu/utils/ApduParser"),i=require("../../command/Errors"),t=require("../../command/model/CommandResult"),L=require("../../command/utils/CommandErrors"),l=require("../../command/utils/CommandUtils"),C=require("../../command/utils/GlobalCommandError"),f=require("../../Error"),m=require("../../utils/HexaString");const g={"662d":{message:"Invalid LIST_ARG, first command must be sent with P1_LIST_LANGUAGE_PACKS_FIRST."}};class A extends f.DeviceExchangeError{constructor({message:r,errorCode:e}){super({message:r,errorCode:e,tag:"ListLanguagePackCommandError"})}}class b{constructor(r){this.args=r}name="listLanguagePack";getApdu(){const r={cla:224,ins:52,p1:this.args.firstChunk?0:1,p2:0};return new p.ApduBuilder(r).build()}parseResponse(r){const e=new c.ApduParser(r);if(!l.CommandUtils.isSuccessResponse(r)){const s=e.encodeToHexaString(r.statusCode);return(0,L.isCommandErrorCode)(s,g)?(0,t.CommandResultFactory)({error:new A({...g[s],errorCode:s})}):(0,t.CommandResultFactory)({error:C.GlobalCommandErrorHandler.handle(r)})}if(e.extract8BitUInt()===void 0)return(0,t.CommandResultFactory)({data:void 0});e.extract8BitUInt();const o=e.extractFieldLVEncoded();if(o===void 0)return(0,t.CommandResultFactory)({error:new i.InvalidStatusWordError("Failed to get language pack id")});const u=e.extractFieldLVEncoded();if(u===void 0)return(0,t.CommandResultFactory)({error:new i.InvalidStatusWordError("Failed to get language pack size")});const k=parseInt((0,m.bufferToHexaString)(o),16),E=parseInt((0,m.bufferToHexaString)(u),16);return(0,t.CommandResultFactory)({data:{id:k,size:E}})}}0&&(module.exports={ListLanguagePackCommand,ListLanguagePackCommandError});
|
|
2
2
|
//# sourceMappingURL=ListLanguagePackCommand.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../../src/api/command/os/ListLanguagePackCommand.ts"],
|
|
4
|
-
"sourcesContent": ["import { type Apdu } from \"@api/apdu/model/Apdu\";\nimport { ApduBuilder, type ApduBuilderArgs } from \"@api/apdu/utils/ApduBuilder\";\nimport { ApduParser } from \"@api/apdu/utils/ApduParser\";\nimport { type Command } from \"@api/command/Command\";\nimport { InvalidStatusWordError } from \"@api/command/Errors\";\nimport {\n type CommandResult,\n CommandResultFactory,\n} from \"@api/command/model/CommandResult\";\nimport {\n type CommandErrors,\n isCommandErrorCode,\n} from \"@api/command/utils/CommandErrors\";\nimport { CommandUtils } from \"@api/command/utils/CommandUtils\";\nimport { GlobalCommandErrorHandler } from \"@api/command/utils/GlobalCommandError\";\nimport { type ApduResponse } from \"@api/device-session/ApduResponse\";\nimport { type CommandErrorArgs, DeviceExchangeError } from \"@api/Error\";\nimport { bufferToHexaString } from \"@api/utils/HexaString\";\n\nexport type ListLanguagePackCommandArgs = {\n readonly firstChunk: boolean;\n};\n\nexport type ListLanguagePackResponse =\n | {\n readonly id: number;\n readonly size: number;\n }\n | undefined;\n\nexport type ListLanguagePackErrorCodes = \"662d\";\n\nconst LANGUAGE_PACK_ERRORS: CommandErrors<ListLanguagePackErrorCodes> = {\n \"662d\": {\n message:\n \"Invalid LIST_ARG, first command must be sent with P1_LIST_LANGUAGE_PACKS_FIRST.\",\n },\n};\n\nexport type ListLanguagePackCommandResult = CommandResult<\n ListLanguagePackResponse,\n ListLanguagePackErrorCodes\n>;\n\nexport class ListLanguagePackCommandError extends DeviceExchangeError<ListLanguagePackErrorCodes> {\n constructor({\n message,\n errorCode,\n }: CommandErrorArgs<ListLanguagePackErrorCodes>) {\n super({ message, errorCode, tag: \"ListLanguagePackCommandError\" });\n }\n}\n\nexport class ListLanguagePackCommand\n implements\n Command<\n ListLanguagePackResponse,\n ListLanguagePackCommandArgs,\n ListLanguagePackErrorCodes\n >\n{\n constructor(private args: ListLanguagePackCommandArgs) {}\n\n getApdu(): Apdu {\n const apduArgs: ApduBuilderArgs = {\n cla: 0xe0,\n ins: 0x34,\n p1: this.args.firstChunk ? 0x00 : 0x01,\n p2: 0x00,\n };\n return new ApduBuilder(apduArgs).build();\n }\n\n parseResponse(apduResponse: ApduResponse): ListLanguagePackCommandResult {\n const parser = new ApduParser(apduResponse);\n\n if (!CommandUtils.isSuccessResponse(apduResponse)) {\n const errorCode = parser.encodeToHexaString(apduResponse.statusCode);\n if (isCommandErrorCode(errorCode, LANGUAGE_PACK_ERRORS)) {\n return CommandResultFactory({\n error: new ListLanguagePackCommandError({\n ...LANGUAGE_PACK_ERRORS[errorCode],\n errorCode,\n }),\n });\n }\n return CommandResultFactory({\n error: GlobalCommandErrorHandler.handle(apduResponse),\n });\n }\n\n const tlvVersion = parser.extract8BitUInt();\n if (tlvVersion === undefined) {\n // No more language package\n return CommandResultFactory({\n data: undefined,\n });\n }\n\n parser.extract8BitUInt(); // total length\n const idBuffer = parser.extractFieldLVEncoded();\n if (idBuffer === undefined) {\n return CommandResultFactory({\n error: new InvalidStatusWordError(\"Failed to get language pack id\"),\n });\n }\n\n const sizeBuffer = parser.extractFieldLVEncoded();\n if (sizeBuffer === undefined) {\n return CommandResultFactory({\n error: new InvalidStatusWordError(\"Failed to get language pack size\"),\n });\n }\n\n const id = parseInt(bufferToHexaString(idBuffer), 16);\n const size = parseInt(bufferToHexaString(sizeBuffer), 16);\n return CommandResultFactory({\n data: { id, size },\n });\n }\n}\n"],
|
|
5
|
-
"mappings": "yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,6BAAAE,EAAA,iCAAAC,IAAA,eAAAC,EAAAJ,GACA,IAAAK,EAAkD,uCAClDC,EAA2B,sCAE3BC,EAAuC,+BACvCC,EAGO,4CACPC,EAGO,4CACPC,EAA6B,2CAC7BC,EAA0C,iDAE1CC,EAA2D,sBAC3DC,EAAmC,iCAenC,MAAMC,EAAkE,CACtE,OAAQ,CACN,QACE,iFACJ,CACF,EAOO,MAAMX,UAAqC,qBAAgD,CAChG,YAAY,CACV,QAAAY,EACA,UAAAC,CACF,EAAiD,CAC/C,MAAM,CAAE,QAAAD,EAAS,UAAAC,EAAW,IAAK,8BAA+B,CAAC,CACnE,CACF,CAEO,MAAMd,CAOb,
|
|
4
|
+
"sourcesContent": ["import { type Apdu } from \"@api/apdu/model/Apdu\";\nimport { ApduBuilder, type ApduBuilderArgs } from \"@api/apdu/utils/ApduBuilder\";\nimport { ApduParser } from \"@api/apdu/utils/ApduParser\";\nimport { type Command } from \"@api/command/Command\";\nimport { InvalidStatusWordError } from \"@api/command/Errors\";\nimport {\n type CommandResult,\n CommandResultFactory,\n} from \"@api/command/model/CommandResult\";\nimport {\n type CommandErrors,\n isCommandErrorCode,\n} from \"@api/command/utils/CommandErrors\";\nimport { CommandUtils } from \"@api/command/utils/CommandUtils\";\nimport { GlobalCommandErrorHandler } from \"@api/command/utils/GlobalCommandError\";\nimport { type ApduResponse } from \"@api/device-session/ApduResponse\";\nimport { type CommandErrorArgs, DeviceExchangeError } from \"@api/Error\";\nimport { bufferToHexaString } from \"@api/utils/HexaString\";\n\nexport type ListLanguagePackCommandArgs = {\n readonly firstChunk: boolean;\n};\n\nexport type ListLanguagePackResponse =\n | {\n readonly id: number;\n readonly size: number;\n }\n | undefined;\n\nexport type ListLanguagePackErrorCodes = \"662d\";\n\nconst LANGUAGE_PACK_ERRORS: CommandErrors<ListLanguagePackErrorCodes> = {\n \"662d\": {\n message:\n \"Invalid LIST_ARG, first command must be sent with P1_LIST_LANGUAGE_PACKS_FIRST.\",\n },\n};\n\nexport type ListLanguagePackCommandResult = CommandResult<\n ListLanguagePackResponse,\n ListLanguagePackErrorCodes\n>;\n\nexport class ListLanguagePackCommandError extends DeviceExchangeError<ListLanguagePackErrorCodes> {\n constructor({\n message,\n errorCode,\n }: CommandErrorArgs<ListLanguagePackErrorCodes>) {\n super({ message, errorCode, tag: \"ListLanguagePackCommandError\" });\n }\n}\n\nexport class ListLanguagePackCommand\n implements\n Command<\n ListLanguagePackResponse,\n ListLanguagePackCommandArgs,\n ListLanguagePackErrorCodes\n >\n{\n readonly name = \"listLanguagePack\";\n\n constructor(private args: ListLanguagePackCommandArgs) {}\n\n getApdu(): Apdu {\n const apduArgs: ApduBuilderArgs = {\n cla: 0xe0,\n ins: 0x34,\n p1: this.args.firstChunk ? 0x00 : 0x01,\n p2: 0x00,\n };\n return new ApduBuilder(apduArgs).build();\n }\n\n parseResponse(apduResponse: ApduResponse): ListLanguagePackCommandResult {\n const parser = new ApduParser(apduResponse);\n\n if (!CommandUtils.isSuccessResponse(apduResponse)) {\n const errorCode = parser.encodeToHexaString(apduResponse.statusCode);\n if (isCommandErrorCode(errorCode, LANGUAGE_PACK_ERRORS)) {\n return CommandResultFactory({\n error: new ListLanguagePackCommandError({\n ...LANGUAGE_PACK_ERRORS[errorCode],\n errorCode,\n }),\n });\n }\n return CommandResultFactory({\n error: GlobalCommandErrorHandler.handle(apduResponse),\n });\n }\n\n const tlvVersion = parser.extract8BitUInt();\n if (tlvVersion === undefined) {\n // No more language package\n return CommandResultFactory({\n data: undefined,\n });\n }\n\n parser.extract8BitUInt(); // total length\n const idBuffer = parser.extractFieldLVEncoded();\n if (idBuffer === undefined) {\n return CommandResultFactory({\n error: new InvalidStatusWordError(\"Failed to get language pack id\"),\n });\n }\n\n const sizeBuffer = parser.extractFieldLVEncoded();\n if (sizeBuffer === undefined) {\n return CommandResultFactory({\n error: new InvalidStatusWordError(\"Failed to get language pack size\"),\n });\n }\n\n const id = parseInt(bufferToHexaString(idBuffer), 16);\n const size = parseInt(bufferToHexaString(sizeBuffer), 16);\n return CommandResultFactory({\n data: { id, size },\n });\n }\n}\n"],
|
|
5
|
+
"mappings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I,yBAAuB,gCAAgC,CACpE,CAAC,EAGH,MAAMC,EAAaF,EAAO,sBAAsB,EAChD,GAAIE,IAAe,OACjB,SAAO,wBAAqB,CAC1B,MAAO,IAAI,yBAAuB,kCAAkC,CACtE,CAAC,EAGH,MAAMC,EAAK,YAAS,sBAAmBF,CAAQ,EAAG,EAAE,EAC9CG,EAAO,YAAS,sBAAmBF,CAAU,EAAG,EAAE,EACxD,SAAO,wBAAqB,CAC1B,KAAM,CAAE,GAAAC,EAAI,KAAAC,CAAK,CACnB,CAAC,CACH,CACF",
|
|
6
6
|
"names": ["ListLanguagePackCommand_exports", "__export", "ListLanguagePackCommand", "ListLanguagePackCommandError", "__toCommonJS", "import_ApduBuilder", "import_ApduParser", "import_Errors", "import_CommandResult", "import_CommandErrors", "import_CommandUtils", "import_GlobalCommandError", "import_Error", "import_HexaString", "LANGUAGE_PACK_ERRORS", "message", "errorCode", "args", "apduArgs", "apduResponse", "parser", "idBuffer", "sizeBuffer", "id", "size"]
|
|
7
7
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";var
|
|
1
|
+
"use strict";var r=require("../../command/Errors"),a=require("../../command/model/CommandResult"),u=require("../../command/model/CommandResult"),o=require("../../command/os/ListLanguagePackCommand"),n=require("../../device-session/ApduResponse");const i=new Uint8Array([224,52,0,0,0]),d=new Uint8Array([224,52,1,0,0]);describe("ListLanguagePackCommand",()=>{let t;beforeEach(()=>{t=new o.ListLanguagePackCommand({firstChunk:!0})}),describe("name",()=>{it("should be 'listLanguagePack'",()=>{expect(t.name).toBe("listLanguagePack")})}),it("should return the correct APDU",()=>{const e=t.getApdu();expect(e.getRawApdu()).toStrictEqual(i)}),it("should return the correct next chunks APDU",()=>{t=new o.ListLanguagePackCommand({firstChunk:!1});const e=t.getApdu();expect(e.getRawApdu()).toStrictEqual(d)}),it("should parse result successfully",()=>{const e=new n.ApduResponse({statusCode:new Uint8Array([144,0]),data:new Uint8Array([1,15,1,1,4,0,0,80,0,5,48,46,48,46,52,0])}),s=t.parseResponse(e);expect(s).toStrictEqual((0,a.CommandResultFactory)({data:{id:1,size:20480}}))}),it("should parse empty result successfully",()=>{const e=new n.ApduResponse({statusCode:new Uint8Array([144,0]),data:new Uint8Array([])}),s=t.parseResponse(e);expect(s).toStrictEqual((0,a.CommandResultFactory)({data:void 0}))}),it("should fail on invalid id",()=>{const e=new n.ApduResponse({statusCode:new Uint8Array([144,0]),data:new Uint8Array([1,15])}),s=t.parseResponse(e);expect(s).toStrictEqual((0,a.CommandResultFactory)({error:new r.InvalidStatusWordError("Failed to get language pack id")}))}),it("should fail on invalid size",()=>{const e=new n.ApduResponse({statusCode:new Uint8Array([144,0]),data:new Uint8Array([1,15,1,1])}),s=t.parseResponse(e);expect(s).toStrictEqual((0,a.CommandResultFactory)({error:new r.InvalidStatusWordError("Failed to get language pack size")}))}),it("should fail on device error",()=>{const e=new n.ApduResponse({statusCode:new Uint8Array([102,45]),data:new Uint8Array([])}),s=t.parseResponse(e);expect((0,u.isSuccessCommandResult)(s)).toBeFalsy()})});
|
|
2
2
|
//# sourceMappingURL=ListLanguagePackCommand.test.js.map
|