@ledgerhq/device-management-kit 0.10.0 → 0.11.1
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/command/Command.js +1 -1
- package/lib/cjs/src/api/command/Command.js.map +1 -1
- 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/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/device-session/service/DefaultDeviceSessionService.js +1 -1
- package/lib/cjs/src/internal/device-session/service/DefaultDeviceSessionService.js.map +3 -3
- package/lib/cjs/src/internal/device-session/service/DefaultDeviceSessionService.test.js +1 -1
- package/lib/cjs/src/internal/device-session/service/DefaultDeviceSessionService.test.js.map +3 -3
- package/lib/cjs/src/internal/device-session/service/DeviceSessionService.js +1 -1
- package/lib/cjs/src/internal/device-session/service/DeviceSessionService.js.map +1 -1
- 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/esm/package.json +1 -1
- 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/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/device-session/service/DefaultDeviceSessionService.js +1 -1
- package/lib/esm/src/internal/device-session/service/DefaultDeviceSessionService.js.map +3 -3
- package/lib/esm/src/internal/device-session/service/DefaultDeviceSessionService.test.js +1 -1
- package/lib/esm/src/internal/device-session/service/DefaultDeviceSessionService.test.js.map +3 -3
- 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/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/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/transport/model/ConnectedDevice.d.ts +1 -1
- 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/device-session/service/DefaultDeviceSessionService.d.ts +7 -5
- package/lib/types/src/internal/device-session/service/DefaultDeviceSessionService.d.ts.map +1 -1
- package/lib/types/src/internal/device-session/service/DeviceSessionService.d.ts +28 -1
- package/lib/types/src/internal/device-session/service/DeviceSessionService.d.ts.map +1 -1
- package/lib/types/src/internal/discovery/use-case/ConnectUseCase.d.ts.map +1 -1
- 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/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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,WAAW,KAAK,CAAC,IAAM,CAAI,CAAC,EACxC,KAAMQ,CACR,CAAC,EAEKE,EAAwB,WAAW,KAAK,CAC5C,EAAM,EAAM,EAAM,EAAM,EAAM,GAAM,GAAM,GAAM,GAAM,EAAM,IAAM,IAAM,IACxE,GAAM,EAAM,GAAM,GAAM,GAAM,GAAM,GAAM,EAAM,GAAM,EAAM,EAAM,EAAM,IACxE,CACF,CAAC,EACKC,EAAmB,IAAIX,EAAa,CACxC,WAAY,WAAW,KAAK,CAAC,IAAM,CAAI,CAAC,EACxC,KAAMU,CACR,CAAC,EAEKE,EAA4B,WAAW,KAAK,CAChD,GAAM,EAAM,EAAM,EAAM,EAAM,EAAM,IAAM,EAAM,EAAM,EAAM,EAAM,GAAM,GACxE,GAAM,GAAM,EAAM,EAAM,EAAM,EAAM,EAAM,EAAM,IAAM,CACxD,CAAC,EACKC,EAAuB,IAAIb,EAAa,CAC5C,WAAY,WAAW,KAAK,CAAC,IAAM,CAAI,CAAC,EACxC,KAAMY,CACR,CAAC,EAED,SAAS,sBAAuB,IAAM,CACpC,IAAIE,EAEJ,WAAW,IAAM,CACfA,EAAU,IAAIZ,CAChB,CAAC,EAED,SAAS,UAAW,IAAM,CACxB,GAAG,sCAAuC,IAAM,CAC9C,
|
|
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, DeviceMod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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,OAAOmB,CAAM,EAAE,cAAcC,CAAQ,CACvC,CAAC,CACH,CAAC,EAED,SAAS,iBAAkB,IAAM,CAC/B,GAAG,2DAA4D,IAAM,CACnE,MAAMC,EAAW,IAAIlB,EAAa,CAChC,WAAY,WAAW,KAAK,CAAC,IAAM,GAAI,CAAC,EACxC,KAAM,WAAW,KAAK,CAAC,CAAC,CAC1B,CAAC,EACKmB,EAASL,EAAQ,cAAcI,EAAUnB,EAAc,MAAM,EAEnE,OAAOD,EAAuBqB,CAAM,CAAC,EAAE,UAAU,CACnD,CAAC,CACH,CAAC,CACH,CAAC,CACH,CAAC",
|
|
6
6
|
"names": ["CommandResultFactory", "isSuccessCommandResult", "DeviceModelId", "ApduResponse", "getOsVersionCommandResponseMockBuilder", "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
|
-
import{ApduBuilder as l}from"../../apdu/utils/ApduBuilder";import{ApduParser as A}from"../../apdu/utils/ApduParser";import{CommandResultFactory as o}from"../../command/model/CommandResult";import{isCommandErrorCode as c}from"../../command/utils/CommandErrors";import{CommandUtils as u}from"../../command/utils/CommandUtils";import{GlobalCommandErrorHandler as C}from"../../command/utils/GlobalCommandError";import{DeviceExchangeError as g}from"../../Error";const p={6624:{message:"Invalid state (List applications command must be sent)"}};class x extends g{constructor({message:e,errorCode:s}){super({message:e,errorCode:s,tag:"ListAppsCommandError"})}}class S{args;constructor(e={isContinue:!1}){this.args=e}getApdu(){const e={cla:224,ins:this.args.isContinue?223:222,p1:0,p2:0};return new l(e).build()}parseResponse(e){const s=[],r=new A(e);if(!u.isSuccessResponse(e)){const t=r.encodeToHexaString(e.statusCode);return c(t,p)?o({error:new x({...p[t],errorCode:t})}):o({error:C.handle(e)})}if(e.data.length<=0)return o({data:[]});for(r.extract8BitUInt();r.getUnparsedRemainingLength()>0;){const t=r.extract8BitUInt(),a=r.extract16BitUInt();r.extract16BitUInt();const i=r.encodeToHexaString(r.extractFieldByLength(32)),d=r.encodeToHexaString(r.extractFieldByLength(32)),m=r.encodeToString(r.extractFieldLVEncoded());s.push({appEntryLength:t,appSizeInBlocks:a,appCodeHash:i,appFullHash:d,appName:m})}return o({data:s})}}export{S as ListAppsCommand,x as ListAppsCommandError};
|
|
1
|
+
import{ApduBuilder as l}from"../../apdu/utils/ApduBuilder";import{ApduParser as A}from"../../apdu/utils/ApduParser";import{CommandResultFactory as o}from"../../command/model/CommandResult";import{isCommandErrorCode as c}from"../../command/utils/CommandErrors";import{CommandUtils as u}from"../../command/utils/CommandUtils";import{GlobalCommandErrorHandler as C}from"../../command/utils/GlobalCommandError";import{DeviceExchangeError as g}from"../../Error";const p={6624:{message:"Invalid state (List applications command must be sent)"}};class x extends g{constructor({message:e,errorCode:s}){super({message:e,errorCode:s,tag:"ListAppsCommandError"})}}class S{name="listApps";args;constructor(e={isContinue:!1}){this.args=e}getApdu(){const e={cla:224,ins:this.args.isContinue?223:222,p1:0,p2:0};return new l(e).build()}parseResponse(e){const s=[],r=new A(e);if(!u.isSuccessResponse(e)){const t=r.encodeToHexaString(e.statusCode);return c(t,p)?o({error:new x({...p[t],errorCode:t})}):o({error:C.handle(e)})}if(e.data.length<=0)return o({data:[]});for(r.extract8BitUInt();r.getUnparsedRemainingLength()>0;){const t=r.extract8BitUInt(),a=r.extract16BitUInt();r.extract16BitUInt();const i=r.encodeToHexaString(r.extractFieldByLength(32)),d=r.encodeToHexaString(r.extractFieldByLength(32)),m=r.encodeToString(r.extractFieldLVEncoded());s.push({appEntryLength:t,appSizeInBlocks:a,appCodeHash:i,appFullHash:d,appName:m})}return o({data:s})}}export{S as ListAppsCommand,x as 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 appEntry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,CACT,CAAC,EAMH,IAFAc,EAAO,gBAAgB,EAEhBA,EAAO,2BAA2B,EAAI,GAAG,CAC9C,MAAMC,EAAiBD,EAAO,gBAAgB,EACxCE,EAAkBF,EAAO,iBAAiB,EAChDA,EAAO,iBAAiB,EACxB,MAAMG,EAAcH,EAAO,mBACzBA,EAAO,qBAAqB,EAAI,CAClC,EACMI,EAAcJ,EAAO,mBACzBA,EAAO,qBAAqB,EAAI,CAClC,EAEMK,EAAUL,EAAO,eAAeA,EAAO,sBAAsB,CAAC,EAEpED,EAAI,KAAK,CACP,eAAAE,EACA,gBAAAC,EACA,YAAAC,EACA,YAAAC,EACA,QAAAC,CACF,CAAC,CACH,CAEA,OAAOnB,EAAqB,CAC1B,KAAMa,CACR,CAAC,CACH,CACF",
|
|
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 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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AM,CAAC,CACT,CAAC,EAMH,IAFAc,EAAO,gBAAgB,EAEhBA,EAAO,2BAA2B,EAAI,GAAG,CAC9C,MAAMC,EAAiBD,EAAO,gBAAgB,EACxCE,EAAkBF,EAAO,iBAAiB,EAChDA,EAAO,iBAAiB,EACxB,MAAMG,EAAcH,EAAO,mBACzBA,EAAO,qBAAqB,EAAI,CAClC,EACMI,EAAcJ,EAAO,mBACzBA,EAAO,qBAAqB,EAAI,CAClC,EAEMK,EAAUL,EAAO,eAAeA,EAAO,sBAAsB,CAAC,EAEpED,EAAI,KAAK,CACP,eAAAE,EACA,gBAAAC,EACA,YAAAC,EACA,YAAAC,EACA,QAAAC,CACF,CAAC,CACH,CAEA,OAAOnB,EAAqB,CAC1B,KAAMa,CACR,CAAC,CACH,CACF",
|
|
6
6
|
"names": ["ApduBuilder", "ApduParser", "CommandResultFactory", "isCommandErrorCode", "CommandUtils", "GlobalCommandErrorHandler", "DeviceExchangeError", "LIST_APP_ERRORS", "ListAppsCommandError", "message", "errorCode", "ListAppsCommand", "args", "listAppApduArgs", "apduResponse", "res", "parser", "appEntryLength", "appSizeInBlocks", "appCodeHash", "appFullHash", "appName"]
|
|
7
7
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{CommandResultFactory as s,isSuccessCommandResult as r}from"../../command/model/CommandResult";import{ApduResponse as a}from"../../device-session/ApduResponse";import{ListAppsCommand as
|
|
1
|
+
import{CommandResultFactory as s,isSuccessCommandResult as r}from"../../command/model/CommandResult";import{ApduResponse as a}from"../../device-session/ApduResponse";import{ListAppsCommand as p,ListAppsCommandError as d}from"./ListAppsCommand";const o=Uint8Array.from([224,222,0,0,0]),c=Uint8Array.from([224,223,0,0,0]),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]),n=[{appEntryLength:77,appSizeInBlocks:19,appCodeHash:"a2259e03a98949541ff3daf18629a30fb169af18d2712ba8b8296ff1c5310fa5",appFullHash:"a97effa816737baf49635a42357012734b909e2796d4e7f14b2ccd9ca4762834",appName:"Bitcoin"}],b=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]),i=[{appEntryLength:77,appSizeInBlocks:19,appCodeHash:"a2259e03a98949541ff3daf18629a30fb169af18d2712ba8b8296ff1c5310fa5",appFullHash:"a97effa816737baf49635a42357012734b909e2796d4e7f14b2ccd9ca4762834",appName:"Bitcoin"},{appEntryLength:78,appSizeInBlocks:19,appCodeHash:"339525398fe45f73c8b759eee01a7ce1713d18544d56ee4864e049b966e6294d",appFullHash:"c7a09470f7a37851a8acf98adabf3e2c2f1f7edefd31c6b54dc1c7dc2991d853",appName:"Ethereum"}],u=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]),A=[{appEntryLength:77,appSizeInBlocks:1,appCodeHash:"dc86229c790ae03eb91309ee1c94600a6ddf490a9d690bfb0a2f02020ebb4c1f",appFullHash:"b4c2e61bae1bab2b7347df3b3b1a2fd9f1fbaffb3aa5f8aa233ed2bfaabcc13e",appName:"Polygon"}],l=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]),m=[{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 p().name).toBe("listApps")})}),describe("first list app command",()=>{beforeEach(()=>{e=new p}),describe("getApdu",()=>{it("should return the ListApp APDU",()=>{const x=e.getApdu();expect(x.getRawApdu()).toStrictEqual(o)})}),describe("parseResponse",()=>{it("should parse the response with no apps",()=>{const x=new a({statusCode:Uint8Array.from([144,0]),data:new Uint8Array});expect(e.parseResponse(x)).toStrictEqual(s({data:[]}))}),it("should parse the response with 1 app",()=>{const x=new a({statusCode:Uint8Array.from([144,0]),data:f});expect(e.parseResponse(x)).toStrictEqual(s({data:n}))}),it("should parse the response with 2 apps",()=>{const x=new a({statusCode:Uint8Array.from([144,0]),data:b});expect(e.parseResponse(x)).toStrictEqual(s({data:i}))})}),describe("errors",()=>{it("should return error command result if the response status code is not success",()=>{const x=new a({statusCode:Uint8Array.from([106,130]),data:new Uint8Array}),t=e.parseResponse(x);expect(r(t)).toBe(!1)}),it("should return an error",()=>{const x=new a({statusCode:Uint8Array.from([85,1]),data:new Uint8Array}),t=e.parseResponse(x);expect(r(t)).toBe(!1)})})}),describe("continue list app command",()=>{beforeEach(()=>{e=new p({isContinue:!0})}),describe("getApdu",()=>{it("should return the Continue ListApp APDU",()=>{const x=e.getApdu();expect(x.getRawApdu()).toStrictEqual(c)})}),describe("parseResponse",()=>{it("should parse the response with 1 app",()=>{const x=new a({statusCode:Uint8Array.from([144,0]),data:u});expect(e.parseResponse(x)).toStrictEqual(s({data:A}))}),it("should parse the response with 2 apps",()=>{const x=new a({statusCode:Uint8Array.from([144,0]),data:l});expect(e.parseResponse(x)).toStrictEqual(s({data:m}))}),it("should parse the response when reaching the end of the list",()=>{const x=new a({statusCode:Uint8Array.from([144,0]),data:new Uint8Array});expect(e.parseResponse(x)).toStrictEqual(s({data:[]}))})}),describe("errors",()=>{it("should throw if ListApp wasn't called before",()=>{const x=new a({statusCode:Uint8Array.from([102,36]),data:new Uint8Array}),t=e.parseResponse(x);expect(r(t)).toBe(!1),expect(t.error).toBeInstanceOf(d)})})})});
|
|
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,OAEE,wBAAAA,EACA,0BAAAC,MACK,mCACP,OAAS,gBAAAC,MAAoB,mCAE7B,OACE,mBAAAC,EACA,wBAAAC,MAEK,oBAIP,MAAMC,EAAgB,WAAW,KAAK,CAAC,IAAM,IAAM,EAAM,EAAM,CAAI,CAAC,EAC9DC,EAAyB,WAA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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(\"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(is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CAChC,WAAY,WAAW,KAAK,CAAC,IAAM,CAAI,CAAC,EACxC,KAAMW,CACR,CAAC,EAED,OAAOE,EAAQ,cAAcE,CAAQ,CAAC,EAAE,cACtCjB,EAAqB,CACnB,KAAMc,CACR,CAAC,CACH,CACF,CAAC,EAED,GAAG,8DAA+D,IAAM,CACtE,MAAMG,EAAW,IAAIf,EAAa,CAChC,WAAY,WAAW,KAAK,CAAC,IAAM,CAAI,CAAC,EACxC,KAAM,IAAI,UACZ,CAAC,EAED,OAAOa,EAAQ,cAAcE,CAAQ,CAAC,EAAE,cACtCjB,EAAqB,CAAE,KAAM,CAAC,CAAE,CAAC,CACnC,CACF,CAAC,CACH,CAAC,EAED,SAAS,SAAU,IAAM,CACvB,GAAG,+CAAgD,IAAM,CACvD,MAAMiB,EAAW,IAAIf,EAAa,CAChC,WAAY,WAAW,KAAK,CAAC,IAAM,EAAI,CAAC,EACxC,KAAM,IAAI,UACZ,CAAC,EACKgB,EAASH,EAAQ,cACrBE,CACF,EAEA,OAAOhB,EAAuBiB,CAAM,CAAC,EAAE,KAAK,EAAK,EACjD,OAAOA,EAAO,KAAK,EAAE,eAAed,CAAoB,CAC1D,CAAC,CACH,CAAC,CACH,CAAC,CACH,CAAC",
|
|
6
6
|
"names": ["CommandResultFactory", "isSuccessCommandResult", "ApduResponse", "ListAppsCommand", "ListAppsCommandError", "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
|
-
import{ApduBuilder as p}from"../../apdu/utils/ApduBuilder";import{ApduParser as c}from"../../apdu/utils/ApduParser";import{InvalidStatusWordError as s}from"../../command/Errors";import{CommandResultFactory as
|
|
1
|
+
import{ApduBuilder as p}from"../../apdu/utils/ApduBuilder";import{ApduParser as c}from"../../apdu/utils/ApduParser";import{InvalidStatusWordError as s}from"../../command/Errors";import{CommandResultFactory as a}from"../../command/model/CommandResult";import{isCommandErrorCode as L}from"../../command/utils/CommandErrors";import{CommandUtils as l}from"../../command/utils/CommandUtils";import{GlobalCommandErrorHandler as C}from"../../command/utils/GlobalCommandError";import{DeviceExchangeError as f}from"../../Error";import{bufferToHexaString as d}from"../../utils/HexaString";const i={"662d":{message:"Invalid LIST_ARG, first command must be sent with P1_LIST_LANGUAGE_PACKS_FIRST."}};class A extends f{constructor({message:r,errorCode:e}){super({message:r,errorCode:e,tag:"ListLanguagePackCommandError"})}}class _{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(r).build()}parseResponse(r){const e=new c(r);if(!l.isSuccessResponse(r)){const o=e.encodeToHexaString(r.statusCode);return L(o,i)?a({error:new A({...i[o],errorCode:o})}):a({error:C.handle(r)})}if(e.extract8BitUInt()===void 0)return a({data:void 0});e.extract8BitUInt();const t=e.extractFieldLVEncoded();if(t===void 0)return a({error:new s("Failed to get language pack id")});const n=e.extractFieldLVEncoded();if(n===void 0)return a({error:new s("Failed to get language pack size")});const u=parseInt(d(t),16),g=parseInt(d(n),16);return a({data:{id:u,size:g}})}}export{_ as ListLanguagePackCommand,A as 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": "AACA,OAAS,eAAAA,MAAyC,8BAClD,OAAS,cAAAC,MAAkB,6BAE3B,OAAS,0BAAAC,MAA8B,sBACvC,OAEE,wBAAAC,MACK,mCACP,OAEE,sBAAAC,MACK,mCACP,OAAS,gBAAAC,MAAoB,kCAC7B,OAAS,6BAAAC,MAAiC,wCAE1C,OAAgC,uBAAAC,MAA2B,aAC3D,OAAS,sBAAAC,MAA0B,wBAenC,MAAMC,EAAkE,CACtE,OAAQ,CACN,QACE,iFACJ,CACF,EAOO,MAAMC,UAAqCH,CAAgD,CAChG,YAAY,CACV,QAAAI,EACA,UAAAC,CACF,EAAiD,CAC/C,MAAM,CAAE,QAAAD,EAAS,UAAAC,EAAW,IAAK,8BAA+B,CAAC,CACnE,CACF,CAEO,MAAMC,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": "AACA,OAAS,eAAAA,MAAyC,8BAClD,OAAS,cAAAC,MAAkB,6BAE3B,OAAS,0BAAAC,MAA8B,sBACvC,OAEE,wBAAAC,MACK,mCACP,OAEE,sBAAAC,MACK,mCACP,OAAS,gBAAAC,MAAoB,kCAC7B,OAAS,6BAAAC,MAAiC,wCAE1C,OAAgC,uBAAAC,MAA2B,aAC3D,OAAS,sBAAAC,MAA0B,wBAenC,MAAMC,EAAkE,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AG,EAAE,EACxD,OAAOhB,EAAqB,CAC1B,KAAM,CAAE,GAAAiB,EAAI,KAAAC,CAAK,CACnB,CAAC,CACH,CACF",
|
|
6
6
|
"names": ["ApduBuilder", "ApduParser", "InvalidStatusWordError", "CommandResultFactory", "isCommandErrorCode", "CommandUtils", "GlobalCommandErrorHandler", "DeviceExchangeError", "bufferToHexaString", "LANGUAGE_PACK_ERRORS", "ListLanguagePackCommandError", "message", "errorCode", "ListLanguagePackCommand", "args", "apduArgs", "apduResponse", "parser", "idBuffer", "sizeBuffer", "id", "size"]
|
|
7
7
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{InvalidStatusWordError as
|
|
1
|
+
import{InvalidStatusWordError as r}from"../../command/Errors";import{CommandResultFactory as a}from"../../command/model/CommandResult";import{isSuccessCommandResult as u}from"../../command/model/CommandResult";import{ListLanguagePackCommand as o}from"../../command/os/ListLanguagePackCommand";import{ApduResponse as n}from"../../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({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({firstChunk:!1});const e=t.getApdu();expect(e.getRawApdu()).toStrictEqual(d)}),it("should parse result successfully",()=>{const e=new n({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(a({data:{id:1,size:20480}}))}),it("should parse empty result successfully",()=>{const e=new n({statusCode:new Uint8Array([144,0]),data:new Uint8Array([])}),s=t.parseResponse(e);expect(s).toStrictEqual(a({data:void 0}))}),it("should fail on invalid id",()=>{const e=new n({statusCode:new Uint8Array([144,0]),data:new Uint8Array([1,15])}),s=t.parseResponse(e);expect(s).toStrictEqual(a({error:new r("Failed to get language pack id")}))}),it("should fail on invalid size",()=>{const e=new n({statusCode:new Uint8Array([144,0]),data:new Uint8Array([1,15,1,1])}),s=t.parseResponse(e);expect(s).toStrictEqual(a({error:new r("Failed to get language pack size")}))}),it("should fail on device error",()=>{const e=new n({statusCode:new Uint8Array([102,45]),data:new Uint8Array([])}),s=t.parseResponse(e);expect(u(s)).toBeFalsy()})});
|
|
2
2
|
//# sourceMappingURL=ListLanguagePackCommand.test.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../../src/api/command/os/ListLanguagePackCommand.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 { ListLanguagePackCommand } from \"@api/command/os/ListLanguagePackCommand\";\nimport { ApduResponse } from \"@api/device-session/ApduResponse\";\n\nconst LIST_LANGUAGE_PACK_APDU = new Uint8Array([0xe0, 0x34, 0x00, 0x00, 0x00]);\nconst LIST_LANGUAGE_PACK_CONTINUE_APDU = new Uint8Array([\n 0xe0, 0x34, 0x01, 0x00, 0x00,\n]);\n\ndescribe(\"ListLanguagePackCommand\", () => {\n let command: ListLanguagePackCommand;\n\n beforeEach(() => {\n command = new ListLanguagePackCommand({ firstChunk: true });\n });\n\n it(\"should return the correct APDU\", () => {\n const apdu = command.getApdu();\n expect(apdu.getRawApdu()).toStrictEqual(LIST_LANGUAGE_PACK_APDU);\n });\n\n it(\"should return the correct next chunks APDU\", () => {\n command = new ListLanguagePackCommand({ firstChunk: false });\n const apdu = command.getApdu();\n expect(apdu.getRawApdu()).toStrictEqual(LIST_LANGUAGE_PACK_CONTINUE_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([\n 0x01, 0x0f, 0x01, 0x01, 0x04, 0x00, 0x00, 0x50, 0x00, 0x05, 0x30, 0x2e,\n 0x30, 0x2e, 0x34, 0x00,\n ]),\n });\n const result = command.parseResponse(response);\n expect(result).toStrictEqual(\n CommandResultFactory({\n data: {\n id: 1,\n size: 20480,\n },\n }),\n );\n });\n\n it(\"should parse empty result successfully\", () => {\n const response: ApduResponse = new ApduResponse({\n statusCode: new Uint8Array([0x90, 0x00]),\n data: new Uint8Array([]),\n });\n const result = command.parseResponse(response);\n expect(result).toStrictEqual(\n CommandResultFactory({\n data: undefined,\n }),\n );\n });\n\n it(\"should fail on invalid id\", () => {\n const response: ApduResponse = new ApduResponse({\n statusCode: new Uint8Array([0x90, 0x00]),\n data: new Uint8Array([0x01, 0x0f]),\n });\n const result = command.parseResponse(response);\n expect(result).toStrictEqual(\n CommandResultFactory({\n error: new InvalidStatusWordError(\"Failed to get language pack id\"),\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([0x01, 0x0f, 0x01, 0x01]),\n });\n const result = command.parseResponse(response);\n expect(result).toStrictEqual(\n CommandResultFactory({\n error: new InvalidStatusWordError(\"Failed to get language pack size\"),\n }),\n );\n });\n\n it(\"should fail on device error\", () => {\n const response: ApduResponse = new ApduResponse({\n statusCode: new Uint8Array([0x66, 0x2d]),\n data: new Uint8Array([]),\n });\n const result = command.parseResponse(response);\n expect(isSuccessCommandResult(result)).toBeFalsy();\n });\n});\n"],
|
|
5
|
-
"mappings": "AAAA,OAAS,0BAAAA,MAA8B,sBACvC,OAAS,wBAAAC,MAA4B,mCACrC,OAAS,0BAAAC,MAA8B,mCACvC,OAAS,2BAAAC,MAA+B,0CACxC,OAAS,gBAAAC,MAAoB,mCAE7B,MAAMC,EAA0B,IAAI,WAAW,CAAC,IAAM,GAAM,EAAM,EAAM,CAAI,CAAC,EACvEC,EAAmC,IAAI,WAAW,CACtD,IAAM,GAAM,EAAM,EAAM,CAC1B,CAAC,EAED,SAAS,0BAA2B,IAAM,CACxC,IAAIC,EAEJ,WAAW,IAAM,CACfA,EAAU,IAAIJ,EAAwB,CAAE,WAAY,EAAK,CAAC,CAC5D,CAAC,EAED,GAAG,iCAAkC,IAAM,CACzC,
|
|
4
|
+
"sourcesContent": ["import { InvalidStatusWordError } from \"@api/command/Errors\";\nimport { CommandResultFactory } from \"@api/command/model/CommandResult\";\nimport { isSuccessCommandResult } from \"@api/command/model/CommandResult\";\nimport { ListLanguagePackCommand } from \"@api/command/os/ListLanguagePackCommand\";\nimport { ApduResponse } from \"@api/device-session/ApduResponse\";\n\nconst LIST_LANGUAGE_PACK_APDU = new Uint8Array([0xe0, 0x34, 0x00, 0x00, 0x00]);\nconst LIST_LANGUAGE_PACK_CONTINUE_APDU = new Uint8Array([\n 0xe0, 0x34, 0x01, 0x00, 0x00,\n]);\n\ndescribe(\"ListLanguagePackCommand\", () => {\n let command: ListLanguagePackCommand;\n\n beforeEach(() => {\n command = new ListLanguagePackCommand({ firstChunk: true });\n });\n\n describe(\"name\", () => {\n it(\"should be 'listLanguagePack'\", () => {\n expect(command.name).toBe(\"listLanguagePack\");\n });\n });\n\n it(\"should return the correct APDU\", () => {\n const apdu = command.getApdu();\n expect(apdu.getRawApdu()).toStrictEqual(LIST_LANGUAGE_PACK_APDU);\n });\n\n it(\"should return the correct next chunks APDU\", () => {\n command = new ListLanguagePackCommand({ firstChunk: false });\n const apdu = command.getApdu();\n expect(apdu.getRawApdu()).toStrictEqual(LIST_LANGUAGE_PACK_CONTINUE_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([\n 0x01, 0x0f, 0x01, 0x01, 0x04, 0x00, 0x00, 0x50, 0x00, 0x05, 0x30, 0x2e,\n 0x30, 0x2e, 0x34, 0x00,\n ]),\n });\n const result = command.parseResponse(response);\n expect(result).toStrictEqual(\n CommandResultFactory({\n data: {\n id: 1,\n size: 20480,\n },\n }),\n );\n });\n\n it(\"should parse empty result successfully\", () => {\n const response: ApduResponse = new ApduResponse({\n statusCode: new Uint8Array([0x90, 0x00]),\n data: new Uint8Array([]),\n });\n const result = command.parseResponse(response);\n expect(result).toStrictEqual(\n CommandResultFactory({\n data: undefined,\n }),\n );\n });\n\n it(\"should fail on invalid id\", () => {\n const response: ApduResponse = new ApduResponse({\n statusCode: new Uint8Array([0x90, 0x00]),\n data: new Uint8Array([0x01, 0x0f]),\n });\n const result = command.parseResponse(response);\n expect(result).toStrictEqual(\n CommandResultFactory({\n error: new InvalidStatusWordError(\"Failed to get language pack id\"),\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([0x01, 0x0f, 0x01, 0x01]),\n });\n const result = command.parseResponse(response);\n expect(result).toStrictEqual(\n CommandResultFactory({\n error: new InvalidStatusWordError(\"Failed to get language pack size\"),\n }),\n );\n });\n\n it(\"should fail on device error\", () => {\n const response: ApduResponse = new ApduResponse({\n statusCode: new Uint8Array([0x66, 0x2d]),\n data: new Uint8Array([]),\n });\n const result = command.parseResponse(response);\n expect(isSuccessCommandResult(result)).toBeFalsy();\n });\n});\n"],
|
|
5
|
+
"mappings": "AAAA,OAAS,0BAAAA,MAA8B,sBACvC,OAAS,wBAAAC,MAA4B,mCACrC,OAAS,0BAAAC,MAA8B,mCACvC,OAAS,2BAAAC,MAA+B,0CACxC,OAAS,gBAAAC,MAAoB,mCAE7B,MAAMC,EAA0B,IAAI,WAAW,CAAC,IAAM,GAAM,EAAM,EAAM,CAAI,CAAC,EACvEC,EAAmC,IAAI,WAAW,CACtD,IAAM,GAAM,EAAM,EAAM,CAC1B,CAAC,EAED,SAAS,0BAA2B,IAAM,CACxC,IAAIC,EAEJ,WAAW,IAAM,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I,WAAW,CAAC,IAAM,CAAI,CAAC,EACvC,KAAM,IAAI,WAAW,CAAC,EAAM,EAAI,CAAC,CACnC,CAAC,EACKM,EAASH,EAAQ,cAAcE,CAAQ,EAC7C,OAAOC,CAAM,EAAE,cACbT,EAAqB,CACnB,MAAO,IAAID,EAAuB,gCAAgC,CACpE,CAAC,CACH,CACF,CAAC,EAED,GAAG,8BAA+B,IAAM,CACtC,MAAMS,EAAyB,IAAIL,EAAa,CAC9C,WAAY,IAAI,WAAW,CAAC,IAAM,CAAI,CAAC,EACvC,KAAM,IAAI,WAAW,CAAC,EAAM,GAAM,EAAM,CAAI,CAAC,CAC/C,CAAC,EACKM,EAASH,EAAQ,cAAcE,CAAQ,EAC7C,OAAOC,CAAM,EAAE,cACbT,EAAqB,CACnB,MAAO,IAAID,EAAuB,kCAAkC,CACtE,CAAC,CACH,CACF,CAAC,EAED,GAAG,8BAA+B,IAAM,CACtC,MAAMS,EAAyB,IAAIL,EAAa,CAC9C,WAAY,IAAI,WAAW,CAAC,IAAM,EAAI,CAAC,EACvC,KAAM,IAAI,WAAW,CAAC,CAAC,CACzB,CAAC,EACKM,EAASH,EAAQ,cAAcE,CAAQ,EAC7C,OAAOP,EAAuBQ,CAAM,CAAC,EAAE,UAAU,CACnD,CAAC,CACH,CAAC",
|
|
6
6
|
"names": ["InvalidStatusWordError", "CommandResultFactory", "isSuccessCommandResult", "ListLanguagePackCommand", "ApduResponse", "LIST_LANGUAGE_PACK_APDU", "LIST_LANGUAGE_PACK_CONTINUE_APDU", "command", "apdu", "response", "result"]
|
|
7
7
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{ApduBuilder as i}from"../../apdu/utils/ApduBuilder";import{ApduParser as n}from"../../apdu/utils/ApduParser";import{CommandResultFactory as t}from"../../command/model/CommandResult";import{isCommandErrorCode as d}from"../../command/utils/CommandErrors";import{CommandUtils as m}from"../../command/utils/CommandUtils";import{GlobalCommandErrorHandler as c}from"../../command/utils/GlobalCommandError";import{DeviceExchangeError as f}from"../../Error";const a={"422f":{message:"Incorrect structure type"},4230:{message:"Incorrect certificate version"},4231:{message:"Incorrect certificate validity"},4232:{message:"Incorrect certificate validity index"},4233:{message:"Unknown signer key ID"},4234:{message:"Unknown signature algorithm"},4235:{message:"Unknown public key ID"},4236:{message:"Unknown public key usage"},4237:{message:"Incorrect elliptic curve ID"},4238:{message:"Incorrect signature algorithm associated to the public key"},4239:{message:"Unknown target device"},"422d":{message:"Unknown certificate tag"},3301:{message:"Failed to hash data"},"422e":{message:"expected_key_usage doesn't match certificate key usage"},5720:{message:"Failed to verify signature"},4118:{message:"trusted_name buffer is too small to contain the trusted name"},ffff:{message:"Cryptography-related error"}};class g extends f{constructor({message:e,errorCode:o}){super({tag:"ProvidePkiCertificateCommandError",message:e,errorCode:o})}}class k{args;triggersDisconnection=!1;constructor(e){this.args=e}getApdu(){const e={cla:176,ins:6,p1:this.args.keyUsage,p2:0};return new i(e).addBufferToData(this.args.certificate).build()}parseResponse(e){if(m.isSuccessResponse(e))return t({data:void 0});const r=new n(e).encodeToHexaString(e.statusCode);return d(r,a)?t({error:new g({...a[r],errorCode:r})}):t({error:c.handle(e)})}}export{k as LoadCertificateCommand,g as LoadCertificateCommandError};
|
|
1
|
+
import{ApduBuilder as i}from"../../apdu/utils/ApduBuilder";import{ApduParser as n}from"../../apdu/utils/ApduParser";import{CommandResultFactory as t}from"../../command/model/CommandResult";import{isCommandErrorCode as d}from"../../command/utils/CommandErrors";import{CommandUtils as m}from"../../command/utils/CommandUtils";import{GlobalCommandErrorHandler as c}from"../../command/utils/GlobalCommandError";import{DeviceExchangeError as f}from"../../Error";const a={"422f":{message:"Incorrect structure type"},4230:{message:"Incorrect certificate version"},4231:{message:"Incorrect certificate validity"},4232:{message:"Incorrect certificate validity index"},4233:{message:"Unknown signer key ID"},4234:{message:"Unknown signature algorithm"},4235:{message:"Unknown public key ID"},4236:{message:"Unknown public key usage"},4237:{message:"Incorrect elliptic curve ID"},4238:{message:"Incorrect signature algorithm associated to the public key"},4239:{message:"Unknown target device"},"422d":{message:"Unknown certificate tag"},3301:{message:"Failed to hash data"},"422e":{message:"expected_key_usage doesn't match certificate key usage"},5720:{message:"Failed to verify signature"},4118:{message:"trusted_name buffer is too small to contain the trusted name"},ffff:{message:"Cryptography-related error"}};class g extends f{constructor({message:e,errorCode:o}){super({tag:"ProvidePkiCertificateCommandError",message:e,errorCode:o})}}class k{name="loadCertificate";args;triggersDisconnection=!1;constructor(e){this.args=e}getApdu(){const e={cla:176,ins:6,p1:this.args.keyUsage,p2:0};return new i(e).addBufferToData(this.args.certificate).build()}parseResponse(e){if(m.isSuccessResponse(e))return t({data:void 0});const r=new n(e).encodeToHexaString(e.statusCode);return d(r,a)?t({error:new g({...a[r],errorCode:r})}):t({error:c.handle(e)})}}export{k as LoadCertificateCommand,g as LoadCertificateCommandError};
|
|
2
2
|
//# sourceMappingURL=LoadCertificateCommand.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../../src/api/command/os/LoadCertificateCommand.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 {\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 { DeviceExchangeError } from \"@api/Error\";\nimport { type Command, type CommandErrorArgs } from \"@api/types\";\n\nexport type LoadCertificateArgs = {\n readonly keyUsage: number;\n readonly certificate: Uint8Array;\n};\n\nexport type LoadCertificateErrorCodes =\n | \"422f\"\n | \"4230\"\n | \"4231\"\n | \"4232\"\n | \"4233\"\n | \"4234\"\n | \"4235\"\n | \"4236\"\n | \"4237\"\n | \"4238\"\n | \"4239\"\n | \"422d\"\n | \"3301\"\n | \"422e\"\n | \"5720\"\n | \"4118\"\n | \"ffff\";\n\nconst LOAD_CERTIFICATE_ERRORS: CommandErrors<LoadCertificateErrorCodes> = {\n \"422f\": { message: \"Incorrect structure type\" },\n \"4230\": { message: \"Incorrect certificate version\" },\n \"4231\": { message: \"Incorrect certificate validity\" },\n \"4232\": { message: \"Incorrect certificate validity index\" },\n \"4233\": { message: \"Unknown signer key ID\" },\n \"4234\": { message: \"Unknown signature algorithm\" },\n \"4235\": { message: \"Unknown public key ID\" },\n \"4236\": { message: \"Unknown public key usage\" },\n \"4237\": { message: \"Incorrect elliptic curve ID\" },\n \"4238\": {\n message: \"Incorrect signature algorithm associated to the public key\",\n },\n \"4239\": { message: \"Unknown target device\" },\n \"422d\": { message: \"Unknown certificate tag\" },\n \"3301\": { message: \"Failed to hash data\" },\n \"422e\": {\n message: \"expected_key_usage doesn't match certificate key usage\",\n },\n \"5720\": { message: \"Failed to verify signature\" },\n \"4118\": {\n message: \"trusted_name buffer is too small to contain the trusted name\",\n },\n ffff: { message: \"Cryptography-related error\" },\n};\n\nexport class LoadCertificateCommandError extends DeviceExchangeError<LoadCertificateErrorCodes> {\n constructor({\n message,\n errorCode,\n }: CommandErrorArgs<LoadCertificateErrorCodes>) {\n super({ tag: \"ProvidePkiCertificateCommandError\", message, errorCode });\n }\n}\n\nexport type LoadCertificateCommandResult = CommandResult<\n void,\n LoadCertificateErrorCodes\n>;\n\n/**\n * The command to load a certificate on the device.\n */\nexport class LoadCertificateCommand\n implements Command<void, LoadCertificateArgs, LoadCertificateErrorCodes>\n{\n readonly args: LoadCertificateArgs;\n readonly triggersDisconnection = false;\n\n constructor(args: LoadCertificateArgs) {\n this.args = args;\n }\n\n getApdu(): Apdu {\n const providePkiApduArgs: ApduBuilderArgs = {\n cla: 0xb0,\n ins: 0x06,\n p1: this.args.keyUsage,\n p2: 0x00,\n };\n return new ApduBuilder(providePkiApduArgs)\n .addBufferToData(this.args.certificate)\n .build();\n }\n\n parseResponse(apduResponse: ApduResponse): LoadCertificateCommandResult {\n if (CommandUtils.isSuccessResponse(apduResponse)) {\n return CommandResultFactory({\n data: undefined,\n });\n }\n const parser = new ApduParser(apduResponse);\n const errorCode = parser.encodeToHexaString(apduResponse.statusCode);\n if (isCommandErrorCode(errorCode, LOAD_CERTIFICATE_ERRORS)) {\n return CommandResultFactory({\n error: new LoadCertificateCommandError({\n ...LOAD_CERTIFICATE_ERRORS[errorCode],\n errorCode,\n }),\n });\n }\n return CommandResultFactory({\n error: GlobalCommandErrorHandler.handle(apduResponse),\n });\n }\n}\n"],
|
|
5
|
-
"mappings": "AACA,OAAS,eAAAA,MAAyC,8BAClD,OAAS,cAAAC,MAAkB,6BAC3B,OAEE,wBAAAC,MACK,mCACP,OAEE,sBAAAC,MACK,mCACP,OAAS,gBAAAC,MAAoB,kCAC7B,OAAS,6BAAAC,MAAiC,wCAE1C,OAAS,uBAAAC,MAA2B,aA2BpC,MAAMC,EAAoE,CACxE,OAAQ,CAAE,QAAS,0BAA2B,EAC9C,KAAQ,CAAE,QAAS,+BAAgC,EACnD,KAAQ,CAAE,QAAS,gCAAiC,EACpD,KAAQ,CAAE,QAAS,sCAAuC,EAC1D,KAAQ,CAAE,QAAS,uBAAwB,EAC3C,KAAQ,CAAE,QAAS,6BAA8B,EACjD,KAAQ,CAAE,QAAS,uBAAwB,EAC3C,KAAQ,CAAE,QAAS,0BAA2B,EAC9C,KAAQ,CAAE,QAAS,6BAA8B,EACjD,KAAQ,CACN,QAAS,4DACX,EACA,KAAQ,CAAE,QAAS,uBAAwB,EAC3C,OAAQ,CAAE,QAAS,yBAA0B,EAC7C,KAAQ,CAAE,QAAS,qBAAsB,EACzC,OAAQ,CACN,QAAS,wDACX,EACA,KAAQ,CAAE,QAAS,4BAA6B,EAChD,KAAQ,CACN,QAAS,8DACX,EACA,KAAM,CAAE,QAAS,4BAA6B,CAChD,EAEO,MAAMC,UAAoCF,CAA+C,CAC9F,YAAY,CACV,QAAAG,EACA,UAAAC,CACF,EAAgD,CAC9C,MAAM,CAAE,IAAK,oCAAqC,QAAAD,EAAS,UAAAC,CAAU,CAAC,CACxE,CACF,CAUO,MAAMC,CAEb,CACW,KACA,sBAAwB,GAEjC,YAAYC,EAA2B,CACrC,KAAK,KAAOA,CACd,CAEA,SAAgB,CACd,MAAMC,EAAsC,CAC1C,IAAK,IACL,IAAK,EACL,GAAI,KAAK,KAAK,SACd,GAAI,CACN,EACA,OAAO,IAAIb,EAAYa,CAAkB,EACtC,gBAAgB,KAAK,KAAK,WAAW,EACrC,MAAM,CACX,CAEA,cAAcC,EAA0D,CACtE,GAAIV,EAAa,kBAAkBU,CAAY,EAC7C,OAAOZ,EAAqB,CAC1B,KAAM,MACR,CAAC,EAGH,MAAMQ,EADS,IAAIT,EAAWa,CAAY,EACjB,mBAAmBA,EAAa,UAAU,EACnE,OAAIX,EAAmBO,EAAWH,CAAuB,EAChDL,EAAqB,CAC1B,MAAO,IAAIM,EAA4B,CACrC,GAAGD,EAAwBG,CAAS,EACpC,UAAAA,CACF,CAAC,CACH,CAAC,EAEIR,EAAqB,CAC1B,MAAOG,EAA0B,OAAOS,CAAY,CACtD,CAAC,CACH,CACF",
|
|
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 {\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 { DeviceExchangeError } from \"@api/Error\";\nimport { type Command, type CommandErrorArgs } from \"@api/types\";\n\nexport type LoadCertificateArgs = {\n readonly keyUsage: number;\n readonly certificate: Uint8Array;\n};\n\nexport type LoadCertificateErrorCodes =\n | \"422f\"\n | \"4230\"\n | \"4231\"\n | \"4232\"\n | \"4233\"\n | \"4234\"\n | \"4235\"\n | \"4236\"\n | \"4237\"\n | \"4238\"\n | \"4239\"\n | \"422d\"\n | \"3301\"\n | \"422e\"\n | \"5720\"\n | \"4118\"\n | \"ffff\";\n\nconst LOAD_CERTIFICATE_ERRORS: CommandErrors<LoadCertificateErrorCodes> = {\n \"422f\": { message: \"Incorrect structure type\" },\n \"4230\": { message: \"Incorrect certificate version\" },\n \"4231\": { message: \"Incorrect certificate validity\" },\n \"4232\": { message: \"Incorrect certificate validity index\" },\n \"4233\": { message: \"Unknown signer key ID\" },\n \"4234\": { message: \"Unknown signature algorithm\" },\n \"4235\": { message: \"Unknown public key ID\" },\n \"4236\": { message: \"Unknown public key usage\" },\n \"4237\": { message: \"Incorrect elliptic curve ID\" },\n \"4238\": {\n message: \"Incorrect signature algorithm associated to the public key\",\n },\n \"4239\": { message: \"Unknown target device\" },\n \"422d\": { message: \"Unknown certificate tag\" },\n \"3301\": { message: \"Failed to hash data\" },\n \"422e\": {\n message: \"expected_key_usage doesn't match certificate key usage\",\n },\n \"5720\": { message: \"Failed to verify signature\" },\n \"4118\": {\n message: \"trusted_name buffer is too small to contain the trusted name\",\n },\n ffff: { message: \"Cryptography-related error\" },\n};\n\nexport class LoadCertificateCommandError extends DeviceExchangeError<LoadCertificateErrorCodes> {\n constructor({\n message,\n errorCode,\n }: CommandErrorArgs<LoadCertificateErrorCodes>) {\n super({ tag: \"ProvidePkiCertificateCommandError\", message, errorCode });\n }\n}\n\nexport type LoadCertificateCommandResult = CommandResult<\n void,\n LoadCertificateErrorCodes\n>;\n\n/**\n * The command to load a certificate on the device.\n */\nexport class LoadCertificateCommand\n implements Command<void, LoadCertificateArgs, LoadCertificateErrorCodes>\n{\n readonly name = \"loadCertificate\";\n readonly args: LoadCertificateArgs;\n readonly triggersDisconnection = false;\n\n constructor(args: LoadCertificateArgs) {\n this.args = args;\n }\n\n getApdu(): Apdu {\n const providePkiApduArgs: ApduBuilderArgs = {\n cla: 0xb0,\n ins: 0x06,\n p1: this.args.keyUsage,\n p2: 0x00,\n };\n return new ApduBuilder(providePkiApduArgs)\n .addBufferToData(this.args.certificate)\n .build();\n }\n\n parseResponse(apduResponse: ApduResponse): LoadCertificateCommandResult {\n if (CommandUtils.isSuccessResponse(apduResponse)) {\n return CommandResultFactory({\n data: undefined,\n });\n }\n const parser = new ApduParser(apduResponse);\n const errorCode = parser.encodeToHexaString(apduResponse.statusCode);\n if (isCommandErrorCode(errorCode, LOAD_CERTIFICATE_ERRORS)) {\n return CommandResultFactory({\n error: new LoadCertificateCommandError({\n ...LOAD_CERTIFICATE_ERRORS[errorCode],\n errorCode,\n }),\n });\n }\n return CommandResultFactory({\n error: GlobalCommandErrorHandler.handle(apduResponse),\n });\n }\n}\n"],
|
|
5
|
+
"mappings": "AACA,OAAS,eAAAA,MAAyC,8BAClD,OAAS,cAAAC,MAAkB,6BAC3B,OAEE,wBAAAC,MACK,mCACP,OAEE,sBAAAC,MACK,mCACP,OAAS,gBAAAC,MAAoB,kCAC7B,OAAS,6BAAAC,MAAiC,wCAE1C,OAAS,uBAAAC,MAA2B,aA2BpC,MAAMC,EAAoE,CACxE,OAAQ,CAAE,QAAS,0BAA2B,EAC9C,KAAQ,CAAE,QAAS,+BAAgC,EACnD,KAAQ,CAAE,QAAS,gCAAiC,EACpD,KAAQ,CAAE,QAAS,sCAAuC,EAC1D,KAAQ,CAAE,QAAS,uBAAwB,EAC3C,KAAQ,CAAE,QAAS,6BAA8B,EACjD,KAAQ,CAAE,QAAS,uBAAwB,EAC3C,KAAQ,CAAE,QAAS,0BAA2B,EAC9C,KAAQ,CAAE,QAAS,6BAA8B,EACjD,KAAQ,CACN,QAAS,4DACX,EACA,KAAQ,CAAE,QAAS,uBAAwB,EAC3C,OAAQ,CAAE,QAAS,yBAA0B,EAC7C,KAAQ,CAAE,QAAS,qBAAsB,EACzC,OAAQ,CACN,QAAS,wDACX,EACA,KAAQ,CAAE,QAAS,4BAA6B,EAChD,KAAQ,CACN,QAAS,8DACX,EACA,KAAM,CAAE,QAAS,4BAA6B,CAChD,EAEO,MAAMC,UAAoCF,CAA+C,CAC9F,YAAY,CACV,QAAAG,EACA,UAAAC,CACF,EAAgD,CAC9C,MAAM,CAAE,IAAK,oCAAqC,QAAAD,EAAS,UAAAC,CAAU,CAAC,CACxE,CACF,CAUO,MAAMC,CAEb,CACW,KAAO,kBACP,KACA,sBAAwB,GAEjC,YAAYC,EAA2B,CACrC,KAAK,KAAOA,CACd,CAEA,SAAgB,CACd,MAAMC,EAAsC,CAC1C,IAAK,IACL,IAAK,EACL,GAAI,KAAK,KAAK,SACd,GAAI,CACN,EACA,OAAO,IAAIb,EAAYa,CAAkB,EACtC,gBAAgB,KAAK,KAAK,WAAW,EACrC,MAAM,CACX,CAEA,cAAcC,EAA0D,CACtE,GAAIV,EAAa,kBAAkBU,CAAY,EAC7C,OAAOZ,EAAqB,CAC1B,KAAM,MACR,CAAC,EAGH,MAAMQ,EADS,IAAIT,EAAWa,CAAY,EACjB,mBAAmBA,EAAa,UAAU,EACnE,OAAIX,EAAmBO,EAAWH,CAAuB,EAChDL,EAAqB,CAC1B,MAAO,IAAIM,EAA4B,CACrC,GAAGD,EAAwBG,CAAS,EACpC,UAAAA,CACF,CAAC,CACH,CAAC,EAEIR,EAAqB,CAC1B,MAAOG,EAA0B,OAAOS,CAAY,CACtD,CAAC,CACH,CACF",
|
|
6
6
|
"names": ["ApduBuilder", "ApduParser", "CommandResultFactory", "isCommandErrorCode", "CommandUtils", "GlobalCommandErrorHandler", "DeviceExchangeError", "LOAD_CERTIFICATE_ERRORS", "LoadCertificateCommandError", "message", "errorCode", "LoadCertificateCommand", "args", "providePkiApduArgs", "apduResponse"]
|
|
7
7
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{CommandResultFactory as n,isSuccessCommandResult as
|
|
1
|
+
import{CommandResultFactory as n,isSuccessCommandResult as a}from"../../command/model/CommandResult";import{LoadCertificateCommand as s,LoadCertificateCommandError as c}from"../../command/os/LoadCertificateCommand";import{GlobalCommandError as i}from"../../command/utils/GlobalCommandError";import{hexaStringToBuffer as d}from"../../utils/HexaString";describe("LoadCertificateCommand",()=>{describe("name",()=>{it("should be 'loadCertificate'",()=>{const t=new s({keyUsage:1,certificate:new Uint8Array});expect(t.name).toBe("loadCertificate")})}),describe("getApdu",()=>{it("should return the APDU with key equal to 1",()=>{const t={keyUsage:66,certificate:new Uint8Array([1,2,3])},e=new s(t).getApdu();expect(e.cla).toBe(176),expect(e.ins).toBe(6),expect(e.p1).toBe(66),expect(e.p2).toBe(0),expect(e.data).toStrictEqual(new Uint8Array([1,2,3]))})}),describe("parseResponse",()=>{let t;beforeEach(()=>{t=new s({keyUsage:1,certificate:new Uint8Array})}),it("should return success if the response status code is success",()=>{const r={statusCode:new Uint8Array([144,0]),data:new Uint8Array},e=t.parseResponse(r);expect(e).toStrictEqual(n({data:void 0}))}),describe("errors",()=>{it("should return error command result if the device is locked",()=>{const r={statusCode:new Uint8Array([85,21]),data:new Uint8Array},e=t.parseResponse(r);a(e)?assert.fail("Expected error command result"):expect(e.error).toBeInstanceOf(i)}),it.each(["422f","4230","4231","4232","4233","4234","4235","4236","4237","4238","4239","422d","3301","422e","5720","4118","ffff"])("should return a ProvidePkiCertificateCommandError if the response is a %s specific error code",r=>{const e={statusCode:d(r),data:new Uint8Array},o=t.parseResponse(e);a(o)?assert.fail("Expected error command result"):(expect(o.error).toBeInstanceOf(c),expect(o.error.errorCode).toBe(r))})})})});
|
|
2
2
|
//# sourceMappingURL=LoadCertificateCommand.test.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../../src/api/command/os/LoadCertificateCommand.test.ts"],
|
|
4
|
-
"sourcesContent": ["import {\n CommandResultFactory,\n isSuccessCommandResult,\n} from \"@api/command/model/CommandResult\";\nimport {\n LoadCertificateCommand,\n LoadCertificateCommandError,\n} from \"@api/command/os/LoadCertificateCommand\";\nimport { GlobalCommandError } from \"@api/command/utils/GlobalCommandError\";\nimport { hexaStringToBuffer } from \"@api/utils/HexaString\";\n\ndescribe(\"LoadCertificateCommand\", () => {\n describe(\"getApdu\", () => {\n it(\"should return the APDU with key equal to 1\", () => {\n // GIVEN\n const args = {\n keyUsage: 0x42,\n certificate: new Uint8Array([0x01, 0x02, 0x03]),\n };\n const command = new LoadCertificateCommand(args);\n\n // WHEN\n const apdu = command.getApdu();\n\n // THEN\n expect(apdu.cla).toBe(0xb0);\n expect(apdu.ins).toBe(0x06);\n expect(apdu.p1).toBe(0x42);\n expect(apdu.p2).toBe(0x00);\n expect(apdu.data).toStrictEqual(new Uint8Array([0x01, 0x02, 0x03]));\n });\n });\n\n describe(\"parseResponse\", () => {\n let command: LoadCertificateCommand;\n\n beforeEach(() => {\n command = new LoadCertificateCommand({\n keyUsage: 0x01,\n certificate: new Uint8Array(),\n });\n });\n\n it(\"should return success if the response status code is success\", () => {\n // GIVEN\n const response = {\n statusCode: new Uint8Array([0x90, 0x00]),\n data: new Uint8Array(),\n };\n\n // WHEN\n const result = command.parseResponse(response);\n\n // THEN\n expect(result).toStrictEqual(CommandResultFactory({ data: undefined }));\n });\n\n describe(\"errors\", () => {\n it(\"should return error command result if the device is locked\", () => {\n // GIVEN\n const response = {\n statusCode: new Uint8Array([0x55, 0x15]),\n data: new Uint8Array(),\n };\n\n // WHEN\n const result = command.parseResponse(response);\n\n // THEN\n if (isSuccessCommandResult(result)) {\n assert.fail(\"Expected error command result\");\n } else {\n expect(result.error).toBeInstanceOf(GlobalCommandError);\n }\n });\n\n it.each([\n \"422f\",\n \"4230\",\n \"4231\",\n \"4232\",\n \"4233\",\n \"4234\",\n \"4235\",\n \"4236\",\n \"4237\",\n \"4238\",\n \"4239\",\n \"422d\",\n \"3301\",\n \"422e\",\n \"5720\",\n \"4118\",\n \"ffff\",\n ])(\n \"should return a ProvidePkiCertificateCommandError if the response is a %s specific error code\",\n (errorCode) => {\n // GIVEN\n const response = {\n statusCode: hexaStringToBuffer(errorCode)!,\n data: new Uint8Array(),\n };\n\n // WHEN\n const result = command.parseResponse(response);\n\n // THEN\n if (isSuccessCommandResult(result)) {\n assert.fail(\"Expected error command result\");\n } else {\n expect(result.error).toBeInstanceOf(LoadCertificateCommandError);\n // @ts-expect-error intended\n expect(result.error.errorCode).toBe(errorCode);\n }\n },\n );\n });\n });\n});\n"],
|
|
5
|
-
"mappings": "AAAA,OACE,wBAAAA,EACA,0BAAAC,MACK,mCACP,OACE,0BAAAC,EACA,+BAAAC,MACK,yCACP,OAAS,sBAAAC,MAA0B,wCACnC,OAAS,sBAAAC,MAA0B,wBAEnC,SAAS,yBAA0B,IAAM,CACvC,SAAS,UAAW,IAAM,CACxB,GAAG,6CAA8C,IAAM,CAErD,MAAMC,EAAO,CACX,SAAU,GACV,YAAa,IAAI,WAAW,CAAC,EAAM,EAAM,CAAI,CAAC,CAChD,EAIMC,EAHU,
|
|
6
|
-
"names": ["CommandResultFactory", "isSuccessCommandResult", "LoadCertificateCommand", "LoadCertificateCommandError", "GlobalCommandError", "hexaStringToBuffer", "
|
|
4
|
+
"sourcesContent": ["import {\n CommandResultFactory,\n isSuccessCommandResult,\n} from \"@api/command/model/CommandResult\";\nimport {\n LoadCertificateCommand,\n LoadCertificateCommandError,\n} from \"@api/command/os/LoadCertificateCommand\";\nimport { GlobalCommandError } from \"@api/command/utils/GlobalCommandError\";\nimport { hexaStringToBuffer } from \"@api/utils/HexaString\";\n\ndescribe(\"LoadCertificateCommand\", () => {\n describe(\"name\", () => {\n it(\"should be 'loadCertificate'\", () => {\n const command = new LoadCertificateCommand({\n keyUsage: 0x01,\n certificate: new Uint8Array(),\n });\n expect(command.name).toBe(\"loadCertificate\");\n });\n });\n\n describe(\"getApdu\", () => {\n it(\"should return the APDU with key equal to 1\", () => {\n // GIVEN\n const args = {\n keyUsage: 0x42,\n certificate: new Uint8Array([0x01, 0x02, 0x03]),\n };\n const command = new LoadCertificateCommand(args);\n\n // WHEN\n const apdu = command.getApdu();\n\n // THEN\n expect(apdu.cla).toBe(0xb0);\n expect(apdu.ins).toBe(0x06);\n expect(apdu.p1).toBe(0x42);\n expect(apdu.p2).toBe(0x00);\n expect(apdu.data).toStrictEqual(new Uint8Array([0x01, 0x02, 0x03]));\n });\n });\n\n describe(\"parseResponse\", () => {\n let command: LoadCertificateCommand;\n\n beforeEach(() => {\n command = new LoadCertificateCommand({\n keyUsage: 0x01,\n certificate: new Uint8Array(),\n });\n });\n\n it(\"should return success if the response status code is success\", () => {\n // GIVEN\n const response = {\n statusCode: new Uint8Array([0x90, 0x00]),\n data: new Uint8Array(),\n };\n\n // WHEN\n const result = command.parseResponse(response);\n\n // THEN\n expect(result).toStrictEqual(CommandResultFactory({ data: undefined }));\n });\n\n describe(\"errors\", () => {\n it(\"should return error command result if the device is locked\", () => {\n // GIVEN\n const response = {\n statusCode: new Uint8Array([0x55, 0x15]),\n data: new Uint8Array(),\n };\n\n // WHEN\n const result = command.parseResponse(response);\n\n // THEN\n if (isSuccessCommandResult(result)) {\n assert.fail(\"Expected error command result\");\n } else {\n expect(result.error).toBeInstanceOf(GlobalCommandError);\n }\n });\n\n it.each([\n \"422f\",\n \"4230\",\n \"4231\",\n \"4232\",\n \"4233\",\n \"4234\",\n \"4235\",\n \"4236\",\n \"4237\",\n \"4238\",\n \"4239\",\n \"422d\",\n \"3301\",\n \"422e\",\n \"5720\",\n \"4118\",\n \"ffff\",\n ])(\n \"should return a ProvidePkiCertificateCommandError if the response is a %s specific error code\",\n (errorCode) => {\n // GIVEN\n const response = {\n statusCode: hexaStringToBuffer(errorCode)!,\n data: new Uint8Array(),\n };\n\n // WHEN\n const result = command.parseResponse(response);\n\n // THEN\n if (isSuccessCommandResult(result)) {\n assert.fail(\"Expected error command result\");\n } else {\n expect(result.error).toBeInstanceOf(LoadCertificateCommandError);\n // @ts-expect-error intended\n expect(result.error.errorCode).toBe(errorCode);\n }\n },\n );\n });\n });\n});\n"],
|
|
5
|
+
"mappings": "AAAA,OACE,wBAAAA,EACA,0BAAAC,MACK,mCACP,OACE,0BAAAC,EACA,+BAAAC,MACK,yCACP,OAAS,sBAAAC,MAA0B,wCACnC,OAAS,sBAAAC,MAA0B,wBAEnC,SAAS,yBAA0B,IAAM,CACvC,SAAS,OAAQ,IAAM,CACrB,GAAG,8BAA+B,IAAM,CACtC,MAAMC,EAAU,IAAIJ,EAAuB,CACzC,SAAU,EACV,YAAa,IAAI,UACnB,CAAC,EACD,OAAOI,EAAQ,IAAI,EAAE,KAAK,iBAAiB,CAC7C,CAAC,CACH,CAAC,EAED,SAAS,UAAW,IAAM,CACxB,GAAG,6CAA8C,IAAM,CAErD,MAAMC,EAAO,CACX,SAAU,GACV,YAAa,IAAI,WAAW,CAAC,EAAM,EAAM,CAAI,CAAC,CAChD,EAIMC,EAHU,IAAIN,EAAuBK,CAAI,EAG1B,QAAQ,EAG7B,OAAOC,EAAK,GAAG,EAAE,KAAK,GAAI,EAC1B,OAAOA,EAAK,GAAG,EAAE,KAAK,CAAI,EAC1B,OAAOA,EAAK,EAAE,EAAE,KAAK,EAAI,EACzB,OAAOA,EAAK,EAAE,EAAE,KAAK,CAAI,EACzB,OAAOA,EAAK,IAAI,EAAE,cAAc,IAAI,WAAW,CAAC,EAAM,EAAM,CAAI,CAAC,CAAC,CACpE,CAAC,CACH,CAAC,EAED,SAAS,gBAAiB,IAAM,CAC9B,IAAIF,EAEJ,WAAW,IAAM,CACfA,EAAU,IAAIJ,EAAuB,CACnC,SAAU,EACV,YAAa,IAAI,UACnB,CAAC,CACH,CAAC,EAED,GAAG,+DAAgE,IAAM,CAEvE,MAAMO,EAAW,CACf,WAAY,IAAI,WAAW,CAAC,IAAM,CAAI,CAAC,EACvC,KAAM,IAAI,UACZ,EAGMC,EAASJ,EAAQ,cAAcG,CAAQ,EAG7C,OAAOC,CAAM,EAAE,cAAcV,EAAqB,CAAE,KAAM,MAAU,CAAC,CAAC,CACxE,CAAC,EAED,SAAS,SAAU,IAAM,CACvB,GAAG,6DAA8D,IAAM,CAErE,MAAMS,EAAW,CACf,WAAY,IAAI,WAAW,CAAC,GAAM,EAAI,CAAC,EACvC,KAAM,IAAI,UACZ,EAGMC,EAASJ,EAAQ,cAAcG,CAAQ,EAGzCR,EAAuBS,CAAM,EAC/B,OAAO,KAAK,+BAA+B,EAE3C,OAAOA,EAAO,KAAK,EAAE,eAAeN,CAAkB,CAE1D,CAAC,EAED,GAAG,KAAK,CACN,OACA,OACA,OACA,OACA,OACA,OACA,OACA,OACA,OACA,OACA,OACA,OACA,OACA,OACA,OACA,OACA,MACF,CAAC,EACC,gGACCO,GAAc,CAEb,MAAMF,EAAW,CACf,WAAYJ,EAAmBM,CAAS,EACxC,KAAM,IAAI,UACZ,EAGMD,EAASJ,EAAQ,cAAcG,CAAQ,EAGzCR,EAAuBS,CAAM,EAC/B,OAAO,KAAK,+BAA+B,GAE3C,OAAOA,EAAO,KAAK,EAAE,eAAeP,CAA2B,EAE/D,OAAOO,EAAO,MAAM,SAAS,EAAE,KAAKC,CAAS,EAEjD,CACF,CACF,CAAC,CACH,CAAC,CACH,CAAC",
|
|
6
|
+
"names": ["CommandResultFactory", "isSuccessCommandResult", "LoadCertificateCommand", "LoadCertificateCommandError", "GlobalCommandError", "hexaStringToBuffer", "command", "args", "apdu", "response", "result", "errorCode"]
|
|
7
7
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{ApduBuilder as
|
|
1
|
+
import{ApduBuilder as s}from"../../apdu/utils/ApduBuilder";import{ApduParser as t}from"../../apdu/utils/ApduParser";import{CommandResultFactory as o}from"../../command/model/CommandResult";import{isCommandErrorCode as d}from"../../command/utils/CommandErrors";import{CommandUtils as a}from"../../command/utils/CommandUtils";import{GlobalCommandErrorHandler as i}from"../../command/utils/GlobalCommandError";import{DeviceExchangeError as A}from"../../Error";const n={"670a":{message:"No app name provided"},6807:{message:"Unknown application name"}};class u extends A{constructor({message:r,errorCode:p}){super({tag:"OpenAppCommandError",message:r,errorCode:p})}}class f{name="openApp";args;triggersDisconnection=!0;constructor(r){this.args=r}getApdu(){const r={cla:224,ins:216,p1:0,p2:0};return new s(r).addAsciiStringToData(this.args.appName).build()}parseResponse(r){if(a.isSuccessResponse(r))return o({data:void 0});const e=new t(r).encodeToHexaString(r.statusCode);return d(e,n)?o({error:new u({...n[e],errorCode:e})}):o({error:i.handle(r)})}}export{f as OpenAppCommand,u as OpenAppCommandError};
|
|
2
2
|
//# sourceMappingURL=OpenAppCommand.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../../src/api/command/os/OpenAppCommand.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 OpenAppArgs = {\n readonly appName: string;\n};\n\nexport type OpenAppErrorCodes = \"670a\" | \"6807\";\n\nconst OPEN_APP_ERRORS: CommandErrors<OpenAppErrorCodes> = {\n \"670a\": { message: \"No app name provided\" },\n \"6807\": { message: \"Unknown application name\" },\n};\n\nexport class OpenAppCommandError extends DeviceExchangeError<OpenAppErrorCodes> {\n constructor({ message, errorCode }: CommandErrorArgs<OpenAppErrorCodes>) {\n super({ tag: \"OpenAppCommandError\", message, errorCode });\n }\n}\n\nexport type OpenAppCommandResult = CommandResult<void, OpenAppErrorCodes>;\n\n/**\n * The command to open an application on the device.\n */\nexport class OpenAppCommand\n implements Command<void, OpenAppArgs, OpenAppErrorCodes>\n{\n readonly args: OpenAppArgs;\n\n readonly triggersDisconnection = true;\n\n constructor(args: OpenAppArgs) {\n this.args = args;\n }\n\n getApdu(): Apdu {\n const openAppApduArgs: ApduBuilderArgs = {\n cla: 0xe0,\n ins: 0xd8,\n p1: 0x00,\n p2: 0x00,\n };\n return new ApduBuilder(openAppApduArgs)\n .addAsciiStringToData(this.args.appName)\n .build();\n }\n\n parseResponse(\n apduResponse: ApduResponse,\n ): CommandResult<void, OpenAppErrorCodes> {\n if (CommandUtils.isSuccessResponse(apduResponse)) {\n return CommandResultFactory({\n data: undefined,\n });\n }\n const parser = new ApduParser(apduResponse);\n const errorCode = parser.encodeToHexaString(apduResponse.statusCode);\n if (isCommandErrorCode(errorCode, OPEN_APP_ERRORS)) {\n return CommandResultFactory({\n error: new OpenAppCommandError({\n ...OPEN_APP_ERRORS[errorCode],\n errorCode,\n }),\n });\n }\n return CommandResultFactory({\n error: GlobalCommandErrorHandler.handle(apduResponse),\n });\n }\n}\n"],
|
|
5
|
-
"mappings": "AACA,OAAS,eAAAA,MAAyC,8BAClD,OAAS,cAAAC,MAAkB,6BAE3B,OAEE,wBAAAC,MACK,mCACP,OAEE,sBAAAC,MACK,mCACP,OAAS,gBAAAC,MAAoB,kCAC7B,OAAS,6BAAAC,MAAiC,wCAE1C,OAAgC,uBAAAC,MAA2B,aAQ3D,MAAMC,EAAoD,CACxD,OAAQ,CAAE,QAAS,sBAAuB,EAC1C,KAAQ,CAAE,QAAS,0BAA2B,CAChD,EAEO,MAAMC,UAA4BF,CAAuC,CAC9E,YAAY,CAAE,QAAAG,EAAS,UAAAC,CAAU,EAAwC,CACvE,MAAM,CAAE,IAAK,sBAAuB,QAAAD,EAAS,UAAAC,CAAU,CAAC,CAC1D,CACF,CAOO,MAAMC,CAEb,CACW,KAEA,sBAAwB,GAEjC,YAAYC,EAAmB,CAC7B,KAAK,KAAOA,CACd,CAEA,SAAgB,CACd,MAAMC,EAAmC,CACvC,IAAK,IACL,IAAK,IACL,GAAI,EACJ,GAAI,CACN,EACA,OAAO,IAAIb,EAAYa,CAAe,EACnC,qBAAqB,KAAK,KAAK,OAAO,EACtC,MAAM,CACX,CAEA,cACEC,EACwC,CACxC,GAAIV,EAAa,kBAAkBU,CAAY,EAC7C,OAAOZ,EAAqB,CAC1B,KAAM,MACR,CAAC,EAGH,MAAMQ,EADS,IAAIT,EAAWa,CAAY,EACjB,mBAAmBA,EAAa,UAAU,EACnE,OAAIX,EAAmBO,EAAWH,CAAe,EACxCL,EAAqB,CAC1B,MAAO,IAAIM,EAAoB,CAC7B,GAAGD,EAAgBG,CAAS,EAC5B,UAAAA,CACF,CAAC,CACH,CAAC,EAEIR,EAAqB,CAC1B,MAAOG,EAA0B,OAAOS,CAAY,CACtD,CAAC,CACH,CACF",
|
|
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 OpenAppArgs = {\n readonly appName: string;\n};\n\nexport type OpenAppErrorCodes = \"670a\" | \"6807\";\n\nconst OPEN_APP_ERRORS: CommandErrors<OpenAppErrorCodes> = {\n \"670a\": { message: \"No app name provided\" },\n \"6807\": { message: \"Unknown application name\" },\n};\n\nexport class OpenAppCommandError extends DeviceExchangeError<OpenAppErrorCodes> {\n constructor({ message, errorCode }: CommandErrorArgs<OpenAppErrorCodes>) {\n super({ tag: \"OpenAppCommandError\", message, errorCode });\n }\n}\n\nexport type OpenAppCommandResult = CommandResult<void, OpenAppErrorCodes>;\n\n/**\n * The command to open an application on the device.\n */\nexport class OpenAppCommand\n implements Command<void, OpenAppArgs, OpenAppErrorCodes>\n{\n readonly name = \"openApp\";\n readonly args: OpenAppArgs;\n\n readonly triggersDisconnection = true;\n\n constructor(args: OpenAppArgs) {\n this.args = args;\n }\n\n getApdu(): Apdu {\n const openAppApduArgs: ApduBuilderArgs = {\n cla: 0xe0,\n ins: 0xd8,\n p1: 0x00,\n p2: 0x00,\n };\n return new ApduBuilder(openAppApduArgs)\n .addAsciiStringToData(this.args.appName)\n .build();\n }\n\n parseResponse(\n apduResponse: ApduResponse,\n ): CommandResult<void, OpenAppErrorCodes> {\n if (CommandUtils.isSuccessResponse(apduResponse)) {\n return CommandResultFactory({\n data: undefined,\n });\n }\n const parser = new ApduParser(apduResponse);\n const errorCode = parser.encodeToHexaString(apduResponse.statusCode);\n if (isCommandErrorCode(errorCode, OPEN_APP_ERRORS)) {\n return CommandResultFactory({\n error: new OpenAppCommandError({\n ...OPEN_APP_ERRORS[errorCode],\n errorCode,\n }),\n });\n }\n return CommandResultFactory({\n error: GlobalCommandErrorHandler.handle(apduResponse),\n });\n }\n}\n"],
|
|
5
|
+
"mappings": "AACA,OAAS,eAAAA,MAAyC,8BAClD,OAAS,cAAAC,MAAkB,6BAE3B,OAEE,wBAAAC,MACK,mCACP,OAEE,sBAAAC,MACK,mCACP,OAAS,gBAAAC,MAAoB,kCAC7B,OAAS,6BAAAC,MAAiC,wCAE1C,OAAgC,uBAAAC,MAA2B,aAQ3D,MAAMC,EAAoD,CACxD,OAAQ,CAAE,QAAS,sBAAuB,EAC1C,KAAQ,CAAE,QAAS,0BAA2B,CAChD,EAEO,MAAMC,UAA4BF,CAAuC,CAC9E,YAAY,CAAE,QAAAG,EAAS,UAAAC,CAAU,EAAwC,CACvE,MAAM,CAAE,IAAK,sBAAuB,QAAAD,EAAS,UAAAC,CAAU,CAAC,CAC1D,CACF,CAOO,MAAMC,CAEb,CACW,KAAO,UACP,KAEA,sBAAwB,GAEjC,YAAYC,EAAmB,CAC7B,KAAK,KAAOA,CACd,CAEA,SAAgB,CACd,MAAMC,EAAmC,CACvC,IAAK,IACL,IAAK,IACL,GAAI,EACJ,GAAI,CACN,EACA,OAAO,IAAIb,EAAYa,CAAe,EACnC,qBAAqB,KAAK,KAAK,OAAO,EACtC,MAAM,CACX,CAEA,cACEC,EACwC,CACxC,GAAIV,EAAa,kBAAkBU,CAAY,EAC7C,OAAOZ,EAAqB,CAC1B,KAAM,MACR,CAAC,EAGH,MAAMQ,EADS,IAAIT,EAAWa,CAAY,EACjB,mBAAmBA,EAAa,UAAU,EACnE,OAAIX,EAAmBO,EAAWH,CAAe,EACxCL,EAAqB,CAC1B,MAAO,IAAIM,EAAoB,CAC7B,GAAGD,EAAgBG,CAAS,EAC5B,UAAAA,CACF,CAAC,CACH,CAAC,EAEIR,EAAqB,CAC1B,MAAOG,EAA0B,OAAOS,CAAY,CACtD,CAAC,CACH,CACF",
|
|
6
6
|
"names": ["ApduBuilder", "ApduParser", "CommandResultFactory", "isCommandErrorCode", "CommandUtils", "GlobalCommandErrorHandler", "DeviceExchangeError", "OPEN_APP_ERRORS", "OpenAppCommandError", "message", "errorCode", "OpenAppCommand", "args", "openAppApduArgs", "apduResponse"]
|
|
7
7
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{ApduResponse as p}from"../../device-session/ApduResponse";import{isSuccessCommandResult as t}from"../../../../src";import{OpenAppCommand as
|
|
1
|
+
import{ApduResponse as p}from"../../device-session/ApduResponse";import{isSuccessCommandResult as t}from"../../../../src";import{OpenAppCommand as o,OpenAppCommandError as s}from"./OpenAppCommand";describe("OpenAppCommand",()=>{const n="MyApp";describe("name",()=>{it("should be 'openApp'",()=>{expect(new o({appName:n}).name).toBe("openApp")})}),it("should return the correct APDU for opening an application",()=>{const e=Uint8Array.from([224,216,0,0,5,77,121,65,112,112]),r=new o({appName:n}).getApdu();expect(r.getRawApdu()).toStrictEqual(e)}),it("should not throw error when command is successful",()=>{const e=new p({statusCode:new Uint8Array([144,0]),data:new Uint8Array([])});expect(()=>new o({appName:n}).parseResponse(e)).not.toThrow()}),describe("errors",()=>{it("should return a handled open app error if no name provided",()=>{const e=new p({statusCode:new Uint8Array([103,10]),data:new Uint8Array([])}),r=new o({appName:n}).parseResponse(e);expect(t(r)).toBe(!1),expect(r.error).toBeInstanceOf(s)}),it("should return a handled open app error if unknown application name",()=>{const e=new p({statusCode:new Uint8Array([104,7]),data:new Uint8Array([])}),r=new o({appName:n}).parseResponse(e);expect(t(r)).toBe(!1),expect(r.error).toBeInstanceOf(s)})})});
|
|
2
2
|
//# sourceMappingURL=OpenAppCommand.test.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../../src/api/command/os/OpenAppCommand.test.ts"],
|
|
4
|
-
"sourcesContent": ["import { type CommandErrorResult } from \"@api/command/model/CommandResult\";\nimport { ApduResponse } from \"@api/device-session/ApduResponse\";\nimport { isSuccessCommandResult } from \"@root/src\";\n\nimport {\n OpenAppCommand,\n OpenAppCommandError,\n type OpenAppErrorCodes,\n} from \"./OpenAppCommand\";\n\ndescribe(\"OpenAppCommand\", () => {\n const appName = \"MyApp\";\n it(\"should return the correct APDU for opening an application\", () => {\n const expectedApdu = Uint8Array.from([\n 0xe0, 0xd8, 0x00, 0x00, 0x05, 0x4d, 0x79, 0x41, 0x70, 0x70,\n ]);\n const apdu = new OpenAppCommand({ appName }).getApdu();\n expect(apdu.getRawApdu()).toStrictEqual(expectedApdu);\n });\n\n it(\"should not throw error when command is successful\", () => {\n const apduResponse: ApduResponse = new ApduResponse({\n statusCode: new Uint8Array([0x90, 0x00]),\n data: new Uint8Array([]),\n });\n expect(() =>\n new OpenAppCommand({ appName }).parseResponse(apduResponse),\n ).not.toThrow();\n });\n\n describe(\"errors\", () => {\n it(\"should return a handled open app error if no name provided\", () => {\n const apduResponse: ApduResponse = new ApduResponse({\n statusCode: new Uint8Array([0x67, 0x0a]),\n data: new Uint8Array([]),\n });\n const result = new OpenAppCommand({ appName }).parseResponse(\n apduResponse,\n ) as CommandErrorResult<OpenAppErrorCodes>;\n expect(isSuccessCommandResult(result)).toBe(false);\n expect(result.error).toBeInstanceOf(OpenAppCommandError);\n });\n it(\"should return a handled open app error if unknown application name\", () => {\n const apduResponse: ApduResponse = new ApduResponse({\n statusCode: new Uint8Array([0x68, 0x07]),\n data: new Uint8Array([]),\n });\n const result = new OpenAppCommand({ appName }).parseResponse(\n apduResponse,\n ) as CommandErrorResult<OpenAppErrorCodes>;\n expect(isSuccessCommandResult(result)).toBe(false);\n expect(result.error).toBeInstanceOf(OpenAppCommandError);\n });\n });\n});\n"],
|
|
5
|
-
"mappings": "AACA,OAAS,gBAAAA,MAAoB,mCAC7B,OAAS,0BAAAC,MAA8B,YAEvC,OACE,kBAAAC,EACA,uBAAAC,MAEK,mBAEP,SAAS,iBAAkB,IAAM,CAC/B,MAAMC,EAAU,
|
|
4
|
+
"sourcesContent": ["import { type CommandErrorResult } from \"@api/command/model/CommandResult\";\nimport { ApduResponse } from \"@api/device-session/ApduResponse\";\nimport { isSuccessCommandResult } from \"@root/src\";\n\nimport {\n OpenAppCommand,\n OpenAppCommandError,\n type OpenAppErrorCodes,\n} from \"./OpenAppCommand\";\n\ndescribe(\"OpenAppCommand\", () => {\n const appName = \"MyApp\";\n\n describe(\"name\", () => {\n it(\"should be 'openApp'\", () => {\n expect(new OpenAppCommand({ appName }).name).toBe(\"openApp\");\n });\n });\n\n it(\"should return the correct APDU for opening an application\", () => {\n const expectedApdu = Uint8Array.from([\n 0xe0, 0xd8, 0x00, 0x00, 0x05, 0x4d, 0x79, 0x41, 0x70, 0x70,\n ]);\n const apdu = new OpenAppCommand({ appName }).getApdu();\n expect(apdu.getRawApdu()).toStrictEqual(expectedApdu);\n });\n\n it(\"should not throw error when command is successful\", () => {\n const apduResponse: ApduResponse = new ApduResponse({\n statusCode: new Uint8Array([0x90, 0x00]),\n data: new Uint8Array([]),\n });\n expect(() =>\n new OpenAppCommand({ appName }).parseResponse(apduResponse),\n ).not.toThrow();\n });\n\n describe(\"errors\", () => {\n it(\"should return a handled open app error if no name provided\", () => {\n const apduResponse: ApduResponse = new ApduResponse({\n statusCode: new Uint8Array([0x67, 0x0a]),\n data: new Uint8Array([]),\n });\n const result = new OpenAppCommand({ appName }).parseResponse(\n apduResponse,\n ) as CommandErrorResult<OpenAppErrorCodes>;\n expect(isSuccessCommandResult(result)).toBe(false);\n expect(result.error).toBeInstanceOf(OpenAppCommandError);\n });\n it(\"should return a handled open app error if unknown application name\", () => {\n const apduResponse: ApduResponse = new ApduResponse({\n statusCode: new Uint8Array([0x68, 0x07]),\n data: new Uint8Array([]),\n });\n const result = new OpenAppCommand({ appName }).parseResponse(\n apduResponse,\n ) as CommandErrorResult<OpenAppErrorCodes>;\n expect(isSuccessCommandResult(result)).toBe(false);\n expect(result.error).toBeInstanceOf(OpenAppCommandError);\n });\n });\n});\n"],
|
|
5
|
+
"mappings": "AACA,OAAS,gBAAAA,MAAoB,mCAC7B,OAAS,0BAAAC,MAA8B,YAEvC,OACE,kBAAAC,EACA,uBAAAC,MAEK,mBAEP,SAAS,iBAAkB,IAAM,CAC/B,MAAMC,EAAU,QAEhB,SAAS,OAAQ,IAAM,CACrB,GAAG,sBAAuB,IAAM,CAC9B,OAAO,IAAIF,EAA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,KAAK,EAAK,EACjD,OAAOA,EAAO,KAAK,EAAE,eAAeL,CAAmB,CACzD,CAAC,CACH,CAAC,CACH,CAAC",
|
|
6
6
|
"names": ["ApduResponse", "isSuccessCommandResult", "OpenAppCommand", "OpenAppCommandError", "appName", "expectedApdu", "apdu", "apduResponse", "result"]
|
|
7
7
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{Left as p}from"purify-ts";import{CommandResultStatus as
|
|
1
|
+
import{Left as p}from"purify-ts";import{CommandResultStatus as n}from"../../command/model/CommandResult";import{DEVICE_SESSION_REFRESHER_DEFAULT_OPTIONS as f}from"../../../internal/device-session/data/DeviceSessionRefresherConst";import{deviceSessionStubBuilder as v}from"../../../internal/device-session/model/DeviceSession.stub";import{DefaultDeviceSessionService as l}from"../../../internal/device-session/service/DefaultDeviceSessionService";import{DefaultLoggerPublisherService as g}from"../../../internal/logger-publisher/service/DefaultLoggerPublisherService";import{AxiosManagerApiDataSource as D}from"../../../internal/manager-api/data/AxiosManagerApiDataSource";import{DefaultManagerApiService as C}from"../../../internal/manager-api/service/DefaultManagerApiService";import{DefaultSecureChannelDataSource as h}from"../../../internal/secure-channel/data/DefaultSecureChannelDataSource";import{DefaultSecureChannelService as y}from"../../../internal/secure-channel/service/DefaultSecureChannelService";import{SendCommandUseCase as i}from"./SendCommandUseCase";let o,t,a,c,m,u;const S="fakeSessionId";let r={name:"testCommand",getApdu:vi.fn(),parseResponse:vi.fn()};describe("SendCommandUseCase",()=>{beforeEach(()=>{o=new g([],"send-command-use-case"),t=new l(()=>o),c=new D({}),a=new C(c),u=new h({}),m=new y(u),r={name:"testCommand",getApdu:vi.fn(),parseResponse:vi.fn()}}),afterEach(()=>{vi.restoreAllMocks()}),it("should send a command to a connected device",async()=>{const e=v({},()=>o,a,m,f);t.addDeviceSession(e);const s=new i(t,()=>o);vi.spyOn(e,"sendCommand").mockResolvedValue({status:n.Success,data:void 0});const d=await s.execute({sessionId:S,command:r});e.close(),expect(d).toStrictEqual({status:n.Success,data:void 0})}),it("should throw an error if the session is not found",async()=>{const e=new i(t,()=>o);vi.spyOn(t,"getDeviceSessionById").mockReturnValue(p({_tag:"DeviceSessionNotFound"}));const s=e.execute({sessionId:S,command:r});await expect(s).rejects.toMatchObject({_tag:"DeviceSessionNotFound"})})});
|
|
2
2
|
//# sourceMappingURL=SendCommandUseCase.test.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../../src/api/command/use-case/SendCommandUseCase.test.ts"],
|
|
4
|
-
"sourcesContent": ["import { Left } from \"purify-ts\";\n\nimport { type Command } from \"@api/command/Command\";\nimport { CommandResultStatus } from \"@api/command/model/CommandResult\";\nimport { type DmkConfig } from \"@api/DmkConfig\";\nimport { type LoggerPublisherService } from \"@api/logger-publisher/service/LoggerPublisherService\";\nimport { DEVICE_SESSION_REFRESHER_DEFAULT_OPTIONS } from \"@internal/device-session/data/DeviceSessionRefresherConst\";\nimport { deviceSessionStubBuilder } from \"@internal/device-session/model/DeviceSession.stub\";\nimport { DefaultDeviceSessionService } from \"@internal/device-session/service/DefaultDeviceSessionService\";\nimport { type DeviceSessionService } from \"@internal/device-session/service/DeviceSessionService\";\nimport { DefaultLoggerPublisherService } from \"@internal/logger-publisher/service/DefaultLoggerPublisherService\";\nimport { AxiosManagerApiDataSource } from \"@internal/manager-api/data/AxiosManagerApiDataSource\";\nimport { type ManagerApiDataSource } from \"@internal/manager-api/data/ManagerApiDataSource\";\nimport { DefaultManagerApiService } from \"@internal/manager-api/service/DefaultManagerApiService\";\nimport { type ManagerApiService } from \"@internal/manager-api/service/ManagerApiService\";\nimport { DefaultSecureChannelDataSource } from \"@internal/secure-channel/data/DefaultSecureChannelDataSource\";\nimport { type SecureChannelDataSource } from \"@internal/secure-channel/data/SecureChannelDataSource\";\nimport { DefaultSecureChannelService } from \"@internal/secure-channel/service/DefaultSecureChannelService\";\nimport { type SecureChannelService } from \"@internal/secure-channel/service/SecureChannelService\";\n\nimport { SendCommandUseCase } from \"./SendCommandUseCase\";\n\nlet logger: LoggerPublisherService;\nlet sessionService: DeviceSessionService;\nlet managerApi: ManagerApiService;\nlet managerApiDataSource: ManagerApiDataSource;\nlet secureChannel: SecureChannelService;\nlet secureChannelDataSource: SecureChannelDataSource;\nconst fakeSessionId = \"fakeSessionId\";\nlet command: Command<{ status: string }
|
|
5
|
-
"mappings": "AAAA,OAAS,QAAAA,MAAY,YAGrB,OAAS,uBAAAC,MAA2B,mCAGpC,OAAS,4CAAAC,MAAgD,4DACzD,OAAS,4BAAAC,MAAgC,oDACzC,OAAS,+BAAAC,MAAmC,+DAE5C,OAAS,iCAAAC,MAAqC,mEAC9C,OAAS,6BAAAC,MAAiC,uDAE1C,OAAS,4BAAAC,MAAgC,yDAEzC,OAAS,kCAAAC,MAAsC,+DAE/C,OAAS,+BAAAC,MAAmC,+DAG5C,OAAS,sBAAAC,MAA0B,uBAEnC,IAAIC,EACAC,EACAC,EACAC,EACAC,EACAC,EACJ,MAAMC,EAAgB,gBACtB,IAAIC,
|
|
4
|
+
"sourcesContent": ["import { Left } from \"purify-ts\";\n\nimport { type Command } from \"@api/command/Command\";\nimport { CommandResultStatus } from \"@api/command/model/CommandResult\";\nimport { type DmkConfig } from \"@api/DmkConfig\";\nimport { type LoggerPublisherService } from \"@api/logger-publisher/service/LoggerPublisherService\";\nimport { DEVICE_SESSION_REFRESHER_DEFAULT_OPTIONS } from \"@internal/device-session/data/DeviceSessionRefresherConst\";\nimport { deviceSessionStubBuilder } from \"@internal/device-session/model/DeviceSession.stub\";\nimport { DefaultDeviceSessionService } from \"@internal/device-session/service/DefaultDeviceSessionService\";\nimport { type DeviceSessionService } from \"@internal/device-session/service/DeviceSessionService\";\nimport { DefaultLoggerPublisherService } from \"@internal/logger-publisher/service/DefaultLoggerPublisherService\";\nimport { AxiosManagerApiDataSource } from \"@internal/manager-api/data/AxiosManagerApiDataSource\";\nimport { type ManagerApiDataSource } from \"@internal/manager-api/data/ManagerApiDataSource\";\nimport { DefaultManagerApiService } from \"@internal/manager-api/service/DefaultManagerApiService\";\nimport { type ManagerApiService } from \"@internal/manager-api/service/ManagerApiService\";\nimport { DefaultSecureChannelDataSource } from \"@internal/secure-channel/data/DefaultSecureChannelDataSource\";\nimport { type SecureChannelDataSource } from \"@internal/secure-channel/data/SecureChannelDataSource\";\nimport { DefaultSecureChannelService } from \"@internal/secure-channel/service/DefaultSecureChannelService\";\nimport { type SecureChannelService } from \"@internal/secure-channel/service/SecureChannelService\";\n\nimport { SendCommandUseCase } from \"./SendCommandUseCase\";\n\nlet logger: LoggerPublisherService;\nlet sessionService: DeviceSessionService;\nlet managerApi: ManagerApiService;\nlet managerApiDataSource: ManagerApiDataSource;\nlet secureChannel: SecureChannelService;\nlet secureChannelDataSource: SecureChannelDataSource;\nconst fakeSessionId = \"fakeSessionId\";\nlet command: Command<{ status: string }, void, void> = {\n name: \"testCommand\",\n getApdu: vi.fn(),\n parseResponse: vi.fn(),\n};\n\ndescribe(\"SendCommandUseCase\", () => {\n beforeEach(() => {\n logger = new DefaultLoggerPublisherService([], \"send-command-use-case\");\n sessionService = new DefaultDeviceSessionService(() => logger);\n managerApiDataSource = new AxiosManagerApiDataSource({} as DmkConfig);\n managerApi = new DefaultManagerApiService(managerApiDataSource);\n secureChannelDataSource = new DefaultSecureChannelDataSource(\n {} as DmkConfig,\n );\n secureChannel = new DefaultSecureChannelService(secureChannelDataSource);\n command = {\n name: \"testCommand\",\n getApdu: vi.fn(),\n parseResponse: vi.fn(),\n };\n });\n\n afterEach(() => {\n vi.restoreAllMocks();\n });\n\n it(\"should send a command to a connected device\", async () => {\n const deviceSession = deviceSessionStubBuilder(\n {},\n () => logger,\n managerApi,\n secureChannel,\n DEVICE_SESSION_REFRESHER_DEFAULT_OPTIONS,\n );\n sessionService.addDeviceSession(deviceSession);\n const useCase = new SendCommandUseCase(sessionService, () => logger);\n\n vi.spyOn(deviceSession, \"sendCommand\").mockResolvedValue({\n status: CommandResultStatus.Success,\n data: undefined,\n });\n\n const response = await useCase.execute<{ status: string }, void, void>({\n sessionId: fakeSessionId,\n command,\n });\n\n deviceSession.close();\n\n expect(response).toStrictEqual({\n status: CommandResultStatus.Success,\n data: undefined,\n });\n });\n\n it(\"should throw an error if the session is not found\", async () => {\n const useCase = new SendCommandUseCase(sessionService, () => logger);\n vi.spyOn(sessionService, \"getDeviceSessionById\").mockReturnValue(\n Left({ _tag: \"DeviceSessionNotFound\" }),\n );\n\n const res = useCase.execute<{ status: string }, void, void>({\n sessionId: fakeSessionId,\n command,\n });\n\n await expect(res).rejects.toMatchObject({ _tag: \"DeviceSessionNotFound\" });\n });\n});\n"],
|
|
5
|
+
"mappings": "AAAA,OAAS,QAAAA,MAAY,YAGrB,OAAS,uBAAAC,MAA2B,mCAGpC,OAAS,4CAAAC,MAAgD,4DACzD,OAAS,4BAAAC,MAAgC,oDACzC,OAAS,+BAAAC,MAAmC,+DAE5C,OAAS,iCAAAC,MAAqC,mEAC9C,OAAS,6BAAAC,MAAiC,uDAE1C,OAAS,4BAAAC,MAAgC,yDAEzC,OAAS,kCAAAC,MAAsC,+DAE/C,OAAS,+BAAAC,MAAmC,+DAG5C,OAAS,sBAAAC,MAA0B,uBAEnC,IAAIC,EACAC,EACAC,EACAC,EACAC,EACAC,EACJ,MAAMC,EAAgB,gBACtB,IAAIC,EAAmD,CACrD,KAAM,cACN,QAAS,GAAG,GAAG,EACf,cAAe,GAAG,GAAG,CACvB,EAEA,SAAS,qBAAsB,IAAM,CACnC,WAAW,IAAM,CACfP,EAAS,IAAIN,EAA8B,CAAC,EAAG,uBAAuB,EACtEO,EAAiB,IAAIR,EAA4B,IAAMO,CAAM,EAC7DG,EAAuB,IAAIR,EAA0B,CAAC,CAAc,EACpEO,EAAa,IAAIN,EAAyBO,CAAoB,EAC9DE,EAA0B,IAAIR,EAC5B,CAAC,CACH,EACAO,EAAgB,IAAIN,EAA4BO,CAAuB,EACvEE,EAAU,CACR,KAAM,cACN,QAAS,GAAG,GAAG,EACf,cAAe,GAAG,GAAG,CACvB,CACF,CAAC,EAED,UAAU,IAAM,CACd,GAAG,gBAAgB,CACrB,CAAC,EAED,GAAG,8CAA+C,SAAY,CAC5D,MAAMC,EAAgBhB,EACpB,CAAC,EACD,IAAMQ,EACNE,EACAE,EACAb,CACF,EACAU,EAAe,iBAAiBO,CAAa,EAC7C,MAAMC,EAAU,IAAIV,EAAmBE,EAAgB,IAAMD,CAAM,EAEnE,GAAG,MAAMQ,EAAe,aAAa,EAAE,kBAAkB,CACvD,OAAQlB,EAAoB,QAC5B,KAAM,MACR,CAAC,EAED,MAAMoB,EAAW,MAAMD,EAAQ,QAAwC,CACrE,UAAWH,EACX,QAAAC,CACF,CAAC,EAEDC,EAAc,MAAM,EAEpB,OAAOE,CAAQ,EAAE,cAAc,CAC7B,OAAQpB,EAAoB,QAC5B,KAAM,MACR,CAAC,CACH,CAAC,EAED,GAAG,oDAAqD,SAAY,CAClE,MAAMmB,EAAU,IAAIV,EAAmBE,EAAgB,IAAMD,CAAM,EACnE,GAAG,MAAMC,EAAgB,sBAAsB,EAAE,gBAC/CZ,EAAK,CAAE,KAAM,uBAAwB,CAAC,CACxC,EAEA,MAAMsB,EAAMF,EAAQ,QAAwC,CAC1D,UAAWH,EACX,QAAAC,CACF,CAAC,EAED,MAAM,OAAOI,CAAG,EAAE,QAAQ,cAAc,CAAE,KAAM,uBAAwB,CAAC,CAC3E,CAAC,CACH,CAAC",
|
|
6
6
|
"names": ["Left", "CommandResultStatus", "DEVICE_SESSION_REFRESHER_DEFAULT_OPTIONS", "deviceSessionStubBuilder", "DefaultDeviceSessionService", "DefaultLoggerPublisherService", "AxiosManagerApiDataSource", "DefaultManagerApiService", "DefaultSecureChannelDataSource", "DefaultSecureChannelService", "SendCommandUseCase", "logger", "sessionService", "managerApi", "managerApiDataSource", "secureChannel", "secureChannelDataSource", "fakeSessionId", "command", "deviceSession", "useCase", "response", "res"]
|
|
7
7
|
}
|