@ledgerhq/device-management-kit 1.9.0 → 1.9.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.
Files changed (50) hide show
  1. package/lib/cjs/package.json +1 -1
  2. package/lib/cjs/src/api/command/os/GetOsVersionCommand.js +1 -1
  3. package/lib/cjs/src/api/command/os/GetOsVersionCommand.js.map +3 -3
  4. package/lib/cjs/src/api/command/os/GetOsVersionCommand.test.js +1 -1
  5. package/lib/cjs/src/api/command/os/GetOsVersionCommand.test.js.map +3 -3
  6. package/lib/cjs/src/api/command/os/SecureElementFlagsParser.js +1 -1
  7. package/lib/cjs/src/api/command/os/SecureElementFlagsParser.js.map +3 -3
  8. package/lib/cjs/src/api/command/os/SecureElementFlagsParser.test.js +1 -1
  9. package/lib/cjs/src/api/command/os/SecureElementFlagsParser.test.js.map +3 -3
  10. package/lib/cjs/src/api/command/os/__mocks__/GetOsVersionCommand.js +1 -1
  11. package/lib/cjs/src/api/command/os/__mocks__/GetOsVersionCommand.js.map +3 -3
  12. package/lib/cjs/src/api/device/SecureElementFlags.js +1 -1
  13. package/lib/cjs/src/api/device/SecureElementFlags.js.map +3 -3
  14. package/lib/cjs/src/api/index.js +1 -1
  15. package/lib/cjs/src/api/index.js.map +3 -3
  16. package/lib/cjs/src/internal/manager-api/data/HttpManagerApiDataSource.js +1 -1
  17. package/lib/cjs/src/internal/manager-api/data/HttpManagerApiDataSource.js.map +3 -3
  18. package/lib/cjs/src/internal/manager-api/data/HttpManagerApiDataSource.test.js +1 -1
  19. package/lib/cjs/src/internal/manager-api/data/HttpManagerApiDataSource.test.js.map +3 -3
  20. package/lib/esm/package.json +1 -1
  21. package/lib/esm/src/api/command/os/GetOsVersionCommand.js +1 -1
  22. package/lib/esm/src/api/command/os/GetOsVersionCommand.js.map +3 -3
  23. package/lib/esm/src/api/command/os/GetOsVersionCommand.test.js +1 -1
  24. package/lib/esm/src/api/command/os/GetOsVersionCommand.test.js.map +3 -3
  25. package/lib/esm/src/api/command/os/SecureElementFlagsParser.js +1 -1
  26. package/lib/esm/src/api/command/os/SecureElementFlagsParser.js.map +3 -3
  27. package/lib/esm/src/api/command/os/SecureElementFlagsParser.test.js +1 -1
  28. package/lib/esm/src/api/command/os/SecureElementFlagsParser.test.js.map +3 -3
  29. package/lib/esm/src/api/command/os/__mocks__/GetOsVersionCommand.js +1 -1
  30. package/lib/esm/src/api/command/os/__mocks__/GetOsVersionCommand.js.map +3 -3
  31. package/lib/esm/src/api/device/SecureElementFlags.js +1 -0
  32. package/lib/esm/src/api/device/SecureElementFlags.js.map +4 -4
  33. package/lib/esm/src/api/index.js +1 -1
  34. package/lib/esm/src/api/index.js.map +3 -3
  35. package/lib/esm/src/internal/manager-api/data/HttpManagerApiDataSource.js +1 -1
  36. package/lib/esm/src/internal/manager-api/data/HttpManagerApiDataSource.js.map +3 -3
  37. package/lib/esm/src/internal/manager-api/data/HttpManagerApiDataSource.test.js +1 -1
  38. package/lib/esm/src/internal/manager-api/data/HttpManagerApiDataSource.test.js.map +3 -3
  39. package/lib/types/src/api/command/os/GetOsVersionCommand.d.ts +2 -2
  40. package/lib/types/src/api/command/os/GetOsVersionCommand.d.ts.map +1 -1
  41. package/lib/types/src/api/command/os/SecureElementFlagsParser.d.ts +0 -3
  42. package/lib/types/src/api/command/os/SecureElementFlagsParser.d.ts.map +1 -1
  43. package/lib/types/src/api/command/os/__mocks__/GetOsVersionCommand.d.ts.map +1 -1
  44. package/lib/types/src/api/device/SecureElementFlags.d.ts +78 -3
  45. package/lib/types/src/api/device/SecureElementFlags.d.ts.map +1 -1
  46. package/lib/types/src/api/index.d.ts +2 -1
  47. package/lib/types/src/api/index.d.ts.map +1 -1
  48. package/lib/types/src/internal/manager-api/data/HttpManagerApiDataSource.d.ts.map +1 -1
  49. package/lib/types/tsconfig.prod.tsbuildinfo +1 -1
  50. package/package.json +4 -4
@@ -1,2 +1,2 @@
1
- import{coerce as u,gte as s}from"semver";import{ApduBuilder as v}from"../../apdu/utils/ApduBuilder";import{ApduParser as O}from"../../apdu/utils/ApduParser";import{InvalidStatusWordError as b}from"../../command/Errors";import{CommandResultFactory as f}from"../../command/model/CommandResult";import{CommandUtils as F}from"../../command/utils/CommandUtils";import{GlobalCommandErrorHandler as N}from"../../command/utils/GlobalCommandError";import{DeviceModelId as t}from"../../device/DeviceModel";import{SecureElementFlagsParser as E}from"./SecureElementFlagsParser";class P{name="getOsVersion";args=void 0;getApdu(){const r={cla:224,ins:1,p1:0,p2:0};return new v(r).build()}parseResponse(r,n){if(!F.isSuccessResponse(r))return f({error:N.handle(r)});const e=new O(r),d=e.extract32BitUInt();if(d===void 0)return f({error:new b("Missing target ID in OS version")});let a=e.encodeToString(e.extractFieldLVEncoded()),c=e.extractFieldLVEncoded()??new Uint8Array(0);const x={...new E(c).generalDeviceState()};a||(a="0.0.0",c=new Uint8Array);const g=(d&4026531840)!==805306368,I=a.includes("-osu");let i="",S="",m="",p="",y,l,V,A;if(g){m=a,y=d;const o=e.extractFieldLVEncoded();o&&(o.length>=5?(i=e.encodeToString(o),l=parseInt(e.encodeToHexaString(e.extractFieldLVEncoded()),16)):l=parseInt(e.encodeToHexaString(o),16))}else{if(i=a,l=d,S=e.encodeToString(e.extractFieldLVEncoded()),this.isBootloaderVersionSupported(i,n)&&(m=e.encodeToString(e.extractFieldLVEncoded())),this.isHardwareVersionSupported(i,n)?p=e.encodeToHexaString(e.extractFieldLVEncoded()):p="00",this.isLocalizationSupported(i,n)){const o=e.extractFieldLVEncoded();o!==void 0&&(V=parseInt(e.encodeToHexaString(o),16))}if(this.isRecoverSupported(i,n)){const o=e.extractFieldLVEncoded();o!==void 0&&(A=parseInt(e.encodeToHexaString(o),16))}}return f({data:{isBootloader:g,isOsu:I,targetId:d,seTargetId:l,mcuTargetId:y,seVersion:i,seFlags:c,mcuSephVersion:S,mcuBootloaderVersion:m,hwVersion:p,langId:V,recoverState:A,secureElementFlags:x}})}isBootloaderVersionSupported(r,n){const e=u(r)??"";switch(n){case t.NANO_S:case t.NANO_X:return s(e,"2.0.0");default:return!0}}isHardwareVersionSupported(r,n){const e=u(r)??"";switch(n){case t.NANO_X:return s(e,"2.0.0");default:return!1}}isLocalizationSupported(r,n){const e=u(r)??"";switch(n){case t.NANO_S:return!1;case t.NANO_SP:return s(e,"1.1.0");case t.NANO_X:return s(e,"2.1.0");default:return!0}}isRecoverSupported(r,n){const e=u(r)??"";switch(n){case t.NANO_S:return!1;case t.NANO_SP:return s(e,"1.1.2");case t.NANO_X:return s(e,"2.2.3");case t.STAX:return s(e,"1.4.0");case t.FLEX:return s(e,"1.0.1");default:return!0}}}export{P as GetOsVersionCommand};
1
+ import{coerce as c,gte as s}from"semver";import{ApduBuilder as O}from"../../apdu/utils/ApduBuilder";import{ApduParser as F}from"../../apdu/utils/ApduParser";import{InvalidStatusWordError as b}from"../../command/Errors";import{CommandResultFactory as g}from"../../command/model/CommandResult";import{CommandUtils as N}from"../../command/utils/CommandUtils";import{GlobalCommandErrorHandler as E}from"../../command/utils/GlobalCommandError";import{DeviceModelId as t}from"../../device/DeviceModel";import{SecureElementFlagsParser as w}from"./SecureElementFlagsParser";class X{name="getOsVersion";args=void 0;getApdu(){const r={cla:224,ins:1,p1:0,p2:0};return new O(r).build()}parseResponse(r,n){if(!N.isSuccessResponse(r))return g({error:E.handle(r)});const e=new F(r),d=e.extract32BitUInt();if(d===void 0)return g({error:new b("Missing target ID in OS version")});let a=e.encodeToString(e.extractFieldLVEncoded()),m=e.extractFieldLVEncoded()??new Uint8Array(0);const l=new w(m),I={...l.generalDeviceState(),...l.endorsementInformation(),...l.wordsInformation(),...l.onboardingStatus()};a||(a="0.0.0",m=new Uint8Array);const S=(d&4026531840)!==805306368,v=a.includes("-osu");let i="",V="",p="",f="",y,u,A,x;if(S){p=a,y=d;const o=e.extractFieldLVEncoded();o&&(o.length>=5?(i=e.encodeToString(o),u=parseInt(e.encodeToHexaString(e.extractFieldLVEncoded()),16)):u=parseInt(e.encodeToHexaString(o),16))}else{if(i=a,u=d,V=e.encodeToString(e.extractFieldLVEncoded()),this.isBootloaderVersionSupported(i,n)&&(p=e.encodeToString(e.extractFieldLVEncoded())),this.isHardwareVersionSupported(i,n)?f=e.encodeToHexaString(e.extractFieldLVEncoded()):f="00",this.isLocalizationSupported(i,n)){const o=e.extractFieldLVEncoded();o!==void 0&&(A=parseInt(e.encodeToHexaString(o),16))}if(this.isRecoverSupported(i,n)){const o=e.extractFieldLVEncoded();o!==void 0&&(x=parseInt(e.encodeToHexaString(o),16))}}return g({data:{isBootloader:S,isOsu:v,targetId:d,seTargetId:u,mcuTargetId:y,seVersion:i,seFlags:m,mcuSephVersion:V,mcuBootloaderVersion:p,hwVersion:f,langId:A,recoverState:x,secureElementFlags:I}})}isBootloaderVersionSupported(r,n){const e=c(r)??"";switch(n){case t.NANO_S:case t.NANO_X:return s(e,"2.0.0");default:return!0}}isHardwareVersionSupported(r,n){const e=c(r)??"";switch(n){case t.NANO_X:return s(e,"2.0.0");default:return!1}}isLocalizationSupported(r,n){const e=c(r)??"";switch(n){case t.NANO_S:return!1;case t.NANO_SP:return s(e,"1.1.0");case t.NANO_X:return s(e,"2.1.0");default:return!0}}isRecoverSupported(r,n){const e=c(r)??"";switch(n){case t.NANO_S:return!1;case t.NANO_SP:return s(e,"1.1.2");case t.NANO_X:return s(e,"2.2.3");case t.STAX:return s(e,"1.4.0");case t.FLEX:return s(e,"1.0.1");default:return!0}}}export{X as GetOsVersionCommand};
2
2
  //# sourceMappingURL=GetOsVersionCommand.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../../../src/api/command/os/GetOsVersionCommand.ts"],
4
- "sourcesContent": ["import { coerce, gte } from \"semver\";\n\nimport { type Apdu } from \"@api/apdu/model/Apdu\";\nimport { ApduBuilder, type ApduBuilderArgs } from \"@api/apdu/utils/ApduBuilder\";\nimport { ApduParser } from \"@api/apdu/utils/ApduParser\";\nimport { type Command } from \"@api/command/Command\";\nimport { InvalidStatusWordError } from \"@api/command/Errors\";\nimport {\n type CommandResult,\n CommandResultFactory,\n} from \"@api/command/model/CommandResult\";\nimport { CommandUtils } from \"@api/command/utils/CommandUtils\";\nimport { GlobalCommandErrorHandler } from \"@api/command/utils/GlobalCommandError\";\nimport { DeviceModelId } from \"@api/device/DeviceModel\";\nimport {\n type DeviceGeneralState,\n type EndorsementInformation,\n type OnboardingStatus,\n type WordsInformation,\n} from \"@api/device/SecureElementFlags\";\nimport { type ApduResponse } from \"@api/device-session/ApduResponse\";\n\nimport { SecureElementFlagsParser } from \"./SecureElementFlagsParser\";\n\n/**\n * Response of the GetOsVersionCommand.\n */\nexport type GetOsVersionResponse = {\n /**\n * Indicated if the device is running in bootloader mode.\n * It can happens during a firmware update process.\n */\n readonly isBootloader: boolean;\n\n /**\n * Indicated if the device firmware is an OS Updater (OSU).\n * It can happens during a firmware update process.\n */\n readonly isOsu: boolean;\n\n /**\n * Target identifier.\n */\n readonly targetId: number;\n\n /**\n * Target identifier of the secure element.\n * Not always available when the device is in bootloader mode.\n */\n readonly seTargetId: number | undefined;\n\n /**\n * Target identifier of the microcontroller unit (MCU).\n * Only available when the device is in bootloader mode.\n */\n readonly mcuTargetId: number | undefined;\n\n /**\n * Version of BOLOS on the secure element (SE).\n * {@link https://developers.ledger.com/docs/device-app/architecture/bolos/hardware-architecture | Hardware Architecture}\n */\n readonly seVersion: string;\n\n /**\n * Secure element flags.\n * Used to represent the current state of the secure element.\n */\n readonly seFlags: Uint8Array;\n\n /**\n * Version of the microcontroller unit (MCU) SEPH, which is the SE-MCU link protocol.\n * {@link https://developers.ledger.com/docs/device-app/architecture/bolos/hardware-architecture | Hardware Architecture}\n */\n readonly mcuSephVersion: string;\n\n /**\n * Version of the MCU bootloader.\n */\n readonly mcuBootloaderVersion: string;\n\n /**\n * Hardware revision version.\n * Only available for Ledger Nano X in which case it's \"00\" or \"01\".\n */\n readonly hwVersion: string;\n\n /**\n * Identifier of the installed language pack.\n * Can be one of:\n * - \"00\": English\n * - \"01\": French\n * - \"02\": Spanish\n * - \"03\": Portuguese\n * - \"04\": German\n * - \"05\": Russian\n * - \"06\": Turkish\n */\n readonly langId: number | undefined;\n\n /**\n * State for Ledger Recover. // [SHOULD] Add more information about this field\n */\n readonly recoverState: number | undefined;\n\n /**\n * The parsed secure element flags.\n */\n readonly secureElementFlags: DeviceGeneralState &\n EndorsementInformation &\n WordsInformation &\n OnboardingStatus;\n};\n\nexport type GetOsVersionCommandResult = CommandResult<GetOsVersionResponse>;\n\n/**\n * Command to get information about the device firmware.\n */\nexport class GetOsVersionCommand implements Command<GetOsVersionResponse> {\n readonly name = \"getOsVersion\";\n readonly args = undefined;\n\n getApdu(): Apdu {\n const getOsVersionApduArgs: ApduBuilderArgs = {\n cla: 0xe0,\n ins: 0x01,\n p1: 0x00,\n p2: 0x00,\n };\n return new ApduBuilder(getOsVersionApduArgs).build();\n }\n\n parseResponse(\n apduResponse: ApduResponse,\n deviceModelId: DeviceModelId,\n ): GetOsVersionCommandResult {\n if (!CommandUtils.isSuccessResponse(apduResponse)) {\n return CommandResultFactory({\n error: GlobalCommandErrorHandler.handle(apduResponse),\n });\n }\n const parser = new ApduParser(apduResponse);\n const targetId = parser.extract32BitUInt();\n if (targetId === undefined) {\n return CommandResultFactory({\n error: new InvalidStatusWordError(\"Missing target ID in OS version\"),\n });\n }\n\n let version = parser.encodeToString(parser.extractFieldLVEncoded());\n let seFlags = parser.extractFieldLVEncoded() ?? new Uint8Array(0);\n const seFlagsParser = new SecureElementFlagsParser(seFlags);\n // This is the parsed secure element flags.\n const secureElementFlags = { ...seFlagsParser.generalDeviceState() };\n\n // Handle old firmwares with no version\n if (!version) {\n version = \"0.0.0\";\n seFlags = new Uint8Array();\n }\n\n const isBootloader = (targetId & 0xf0000000) !== 0x30000000;\n const isOsu = version.includes(\"-osu\");\n let seVersion: string = \"\";\n let mcuSephVersion: string = \"\";\n let mcuBootloaderVersion: string = \"\";\n let hwVersion: string = \"\";\n let mcuTargetId: number | undefined = undefined;\n let seTargetId: number | undefined = undefined;\n let langId: number | undefined = undefined;\n let recoverState: number | undefined = undefined;\n\n if (isBootloader) {\n mcuBootloaderVersion = version;\n mcuTargetId = targetId;\n\n const seData = parser.extractFieldLVEncoded();\n if (seData) {\n if (seData.length >= 5) {\n // It means it's a version followed by the seTargetId\n seVersion = parser.encodeToString(seData);\n seTargetId = parseInt(\n parser.encodeToHexaString(parser.extractFieldLVEncoded()),\n 16,\n );\n } else {\n // It's the seTargetId\n seTargetId = parseInt(parser.encodeToHexaString(seData), 16);\n }\n }\n } else {\n seVersion = version;\n seTargetId = targetId;\n\n mcuSephVersion = parser.encodeToString(parser.extractFieldLVEncoded());\n\n if (this.isBootloaderVersionSupported(seVersion, deviceModelId)) {\n mcuBootloaderVersion = parser.encodeToString(\n parser.extractFieldLVEncoded(),\n );\n }\n\n if (this.isHardwareVersionSupported(seVersion, deviceModelId)) {\n hwVersion = parser.encodeToHexaString(parser.extractFieldLVEncoded());\n } else {\n hwVersion = \"00\";\n }\n\n if (this.isLocalizationSupported(seVersion, deviceModelId)) {\n const langIdBuffer = parser.extractFieldLVEncoded();\n if (langIdBuffer !== undefined) {\n langId = parseInt(parser.encodeToHexaString(langIdBuffer), 16);\n }\n }\n\n if (this.isRecoverSupported(seVersion, deviceModelId)) {\n const recoverStateBuffer = parser.extractFieldLVEncoded();\n if (recoverStateBuffer !== undefined) {\n recoverState = parseInt(\n parser.encodeToHexaString(recoverStateBuffer),\n 16,\n );\n }\n }\n }\n\n return CommandResultFactory({\n data: {\n isBootloader,\n isOsu,\n targetId,\n seTargetId,\n mcuTargetId,\n seVersion,\n seFlags,\n mcuSephVersion,\n mcuBootloaderVersion,\n hwVersion,\n langId,\n recoverState,\n secureElementFlags,\n },\n });\n }\n\n private isBootloaderVersionSupported(\n seVersion: string,\n deviceModelId: DeviceModelId,\n ): boolean {\n const version = coerce(seVersion) ?? \"\";\n switch (deviceModelId) {\n case DeviceModelId.NANO_S:\n case DeviceModelId.NANO_X:\n return gte(version, \"2.0.0\");\n default:\n return true;\n }\n }\n\n private isHardwareVersionSupported(\n seVersion: string,\n deviceModelId: DeviceModelId,\n ): boolean {\n const version = coerce(seVersion) ?? \"\";\n switch (deviceModelId) {\n case DeviceModelId.NANO_X:\n return gte(version, \"2.0.0\");\n default:\n return false;\n }\n }\n\n private isLocalizationSupported(\n seVersion: string,\n deviceModelId: DeviceModelId,\n ): boolean {\n const version = coerce(seVersion) ?? \"\";\n switch (deviceModelId) {\n case DeviceModelId.NANO_S:\n return false;\n case DeviceModelId.NANO_SP:\n return gte(version, \"1.1.0\");\n case DeviceModelId.NANO_X:\n return gte(version, \"2.1.0\");\n default:\n return true;\n }\n }\n\n private isRecoverSupported(\n seVersion: string,\n deviceModelId: DeviceModelId,\n ): boolean {\n const version = coerce(seVersion) ?? \"\";\n switch (deviceModelId) {\n case DeviceModelId.NANO_S:\n return false;\n case DeviceModelId.NANO_SP:\n return gte(version, \"1.1.2\");\n case DeviceModelId.NANO_X:\n return gte(version, \"2.2.3\");\n case DeviceModelId.STAX:\n return gte(version, \"1.4.0\");\n case DeviceModelId.FLEX:\n return gte(version, \"1.0.1\");\n default:\n return true;\n }\n }\n}\n"],
5
- "mappings": "AAAA,OAAS,UAAAA,EAAQ,OAAAC,MAAW,SAG5B,OAAS,eAAAC,MAAyC,8BAClD,OAAS,cAAAC,MAAkB,6BAE3B,OAAS,0BAAAC,MAA8B,sBACvC,OAEE,wBAAAC,MACK,mCACP,OAAS,gBAAAC,MAAoB,kCAC7B,OAAS,6BAAAC,MAAiC,wCAC1C,OAAS,iBAAAC,MAAqB,0BAS9B,OAAS,4BAAAC,MAAgC,6BAgGlC,MAAMC,CAA6D,CAC/D,KAAO,eACP,KAAO,OAEhB,SAAgB,CACd,MAAMC,EAAwC,CAC5C,IAAK,IACL,IAAK,EACL,GAAI,EACJ,GAAI,CACN,EACA,OAAO,IAAIT,EAAYS,CAAoB,EAAE,MAAM,CACrD,CAEA,cAC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OACjB,MAAO,GACT,KAAKA,EAAc,QACjB,OAAOP,EAAIe,EAAS,OAAO,EAC7B,KAAKR,EAAc,OACjB,OAAOP,EAAIe,EAAS,OAAO,EAC7B,KAAKR,EAAc,KACjB,OAAOP,EAAIe,EAAS,OAAO,EAC7B,KAAKR,EAAc,KACjB,OAAOP,EAAIe,EAAS,OAAO,EAC7B,QACE,MAAO,EACX,CACF,CACF",
6
- "names": ["coerce", "gte", "ApduBuilder", "ApduParser", "InvalidStatusWordError", "CommandResultFactory", "CommandUtils", "GlobalCommandErrorHandler", "DeviceModelId", "SecureElementFlagsParser", "GetOsVersionCommand", "getOsVersionApduArgs", "apduResponse", "deviceModelId", "parser", "targetId", "version", "seFlags", "secureElementFlags", "isBootloader", "isOsu", "seVersion", "mcuSephVersion", "mcuBootloaderVersion", "hwVersion", "mcuTargetId", "seTargetId", "langId", "recoverState", "seData", "langIdBuffer", "recoverStateBuffer"]
4
+ "sourcesContent": ["import { coerce, gte } from \"semver\";\n\nimport { type Apdu } from \"@api/apdu/model/Apdu\";\nimport { ApduBuilder, type ApduBuilderArgs } from \"@api/apdu/utils/ApduBuilder\";\nimport { ApduParser } from \"@api/apdu/utils/ApduParser\";\nimport { type Command } from \"@api/command/Command\";\nimport { InvalidStatusWordError } from \"@api/command/Errors\";\nimport {\n type CommandResult,\n CommandResultFactory,\n} from \"@api/command/model/CommandResult\";\nimport { CommandUtils } from \"@api/command/utils/CommandUtils\";\nimport { GlobalCommandErrorHandler } from \"@api/command/utils/GlobalCommandError\";\nimport { DeviceModelId } from \"@api/device/DeviceModel\";\nimport { type SecureElementFlags } from \"@api/device/SecureElementFlags\";\nimport { type ApduResponse } from \"@api/device-session/ApduResponse\";\n\nimport { SecureElementFlagsParser } from \"./SecureElementFlagsParser\";\n\n/**\n * Response of the GetOsVersionCommand.\n */\nexport type GetOsVersionResponse = {\n /**\n * Indicated if the device is running in bootloader mode.\n * It can happens during a firmware update process.\n */\n readonly isBootloader: boolean;\n\n /**\n * Indicated if the device firmware is an OS Updater (OSU).\n * It can happens during a firmware update process.\n */\n readonly isOsu: boolean;\n\n /**\n * Target identifier.\n */\n readonly targetId: number;\n\n /**\n * Target identifier of the secure element.\n * Not always available when the device is in bootloader mode.\n */\n readonly seTargetId: number | undefined;\n\n /**\n * Target identifier of the microcontroller unit (MCU).\n * Only available when the device is in bootloader mode.\n */\n readonly mcuTargetId: number | undefined;\n\n /**\n * Version of BOLOS on the secure element (SE).\n * {@link https://developers.ledger.com/docs/device-app/architecture/bolos/hardware-architecture | Hardware Architecture}\n */\n readonly seVersion: string;\n\n /**\n * Secure element flags.\n * Used to represent the current state of the secure element.\n */\n readonly seFlags: Uint8Array;\n\n /**\n * Version of the microcontroller unit (MCU) SEPH, which is the SE-MCU link protocol.\n * {@link https://developers.ledger.com/docs/device-app/architecture/bolos/hardware-architecture | Hardware Architecture}\n */\n readonly mcuSephVersion: string;\n\n /**\n * Version of the MCU bootloader.\n */\n readonly mcuBootloaderVersion: string;\n\n /**\n * Hardware revision version.\n * Only available for Ledger Nano X in which case it's \"00\" or \"01\".\n */\n readonly hwVersion: string;\n\n /**\n * Identifier of the installed language pack.\n * Can be one of:\n * - \"00\": English\n * - \"01\": French\n * - \"02\": Spanish\n * - \"03\": Portuguese\n * - \"04\": German\n * - \"05\": Russian\n * - \"06\": Turkish\n */\n readonly langId: number | undefined;\n\n /**\n * State for Ledger Recover. // [SHOULD] Add more information about this field\n */\n readonly recoverState: number | undefined;\n\n /**\n * The parsed secure element flags.\n */\n readonly secureElementFlags: SecureElementFlags;\n};\n\nexport type GetOsVersionCommandResult = CommandResult<GetOsVersionResponse>;\n\n/**\n * Command to get information about the device firmware.\n */\nexport class GetOsVersionCommand implements Command<GetOsVersionResponse> {\n readonly name = \"getOsVersion\";\n readonly args = undefined;\n\n getApdu(): Apdu {\n const getOsVersionApduArgs: ApduBuilderArgs = {\n cla: 0xe0,\n ins: 0x01,\n p1: 0x00,\n p2: 0x00,\n };\n return new ApduBuilder(getOsVersionApduArgs).build();\n }\n\n parseResponse(\n apduResponse: ApduResponse,\n deviceModelId: DeviceModelId,\n ): GetOsVersionCommandResult {\n if (!CommandUtils.isSuccessResponse(apduResponse)) {\n return CommandResultFactory({\n error: GlobalCommandErrorHandler.handle(apduResponse),\n });\n }\n const parser = new ApduParser(apduResponse);\n const targetId = parser.extract32BitUInt();\n if (targetId === undefined) {\n return CommandResultFactory({\n error: new InvalidStatusWordError(\"Missing target ID in OS version\"),\n });\n }\n\n let version = parser.encodeToString(parser.extractFieldLVEncoded());\n let seFlags = parser.extractFieldLVEncoded() ?? new Uint8Array(0);\n const seFlagsParser = new SecureElementFlagsParser(seFlags);\n const secureElementFlags = {\n ...seFlagsParser.generalDeviceState(),\n ...seFlagsParser.endorsementInformation(),\n ...seFlagsParser.wordsInformation(),\n ...seFlagsParser.onboardingStatus(),\n };\n\n // Handle old firmwares with no version\n if (!version) {\n version = \"0.0.0\";\n seFlags = new Uint8Array();\n }\n\n const isBootloader = (targetId & 0xf0000000) !== 0x30000000;\n const isOsu = version.includes(\"-osu\");\n let seVersion: string = \"\";\n let mcuSephVersion: string = \"\";\n let mcuBootloaderVersion: string = \"\";\n let hwVersion: string = \"\";\n let mcuTargetId: number | undefined = undefined;\n let seTargetId: number | undefined = undefined;\n let langId: number | undefined = undefined;\n let recoverState: number | undefined = undefined;\n\n if (isBootloader) {\n mcuBootloaderVersion = version;\n mcuTargetId = targetId;\n\n const seData = parser.extractFieldLVEncoded();\n if (seData) {\n if (seData.length >= 5) {\n // It means it's a version followed by the seTargetId\n seVersion = parser.encodeToString(seData);\n seTargetId = parseInt(\n parser.encodeToHexaString(parser.extractFieldLVEncoded()),\n 16,\n );\n } else {\n // It's the seTargetId\n seTargetId = parseInt(parser.encodeToHexaString(seData), 16);\n }\n }\n } else {\n seVersion = version;\n seTargetId = targetId;\n\n mcuSephVersion = parser.encodeToString(parser.extractFieldLVEncoded());\n\n if (this.isBootloaderVersionSupported(seVersion, deviceModelId)) {\n mcuBootloaderVersion = parser.encodeToString(\n parser.extractFieldLVEncoded(),\n );\n }\n\n if (this.isHardwareVersionSupported(seVersion, deviceModelId)) {\n hwVersion = parser.encodeToHexaString(parser.extractFieldLVEncoded());\n } else {\n hwVersion = \"00\";\n }\n\n if (this.isLocalizationSupported(seVersion, deviceModelId)) {\n const langIdBuffer = parser.extractFieldLVEncoded();\n if (langIdBuffer !== undefined) {\n langId = parseInt(parser.encodeToHexaString(langIdBuffer), 16);\n }\n }\n\n if (this.isRecoverSupported(seVersion, deviceModelId)) {\n const recoverStateBuffer = parser.extractFieldLVEncoded();\n if (recoverStateBuffer !== undefined) {\n recoverState = parseInt(\n parser.encodeToHexaString(recoverStateBuffer),\n 16,\n );\n }\n }\n }\n\n return CommandResultFactory({\n data: {\n isBootloader,\n isOsu,\n targetId,\n seTargetId,\n mcuTargetId,\n seVersion,\n seFlags,\n mcuSephVersion,\n mcuBootloaderVersion,\n hwVersion,\n langId,\n recoverState,\n secureElementFlags,\n },\n });\n }\n\n private isBootloaderVersionSupported(\n seVersion: string,\n deviceModelId: DeviceModelId,\n ): boolean {\n const version = coerce(seVersion) ?? \"\";\n switch (deviceModelId) {\n case DeviceModelId.NANO_S:\n case DeviceModelId.NANO_X:\n return gte(version, \"2.0.0\");\n default:\n return true;\n }\n }\n\n private isHardwareVersionSupported(\n seVersion: string,\n deviceModelId: DeviceModelId,\n ): boolean {\n const version = coerce(seVersion) ?? \"\";\n switch (deviceModelId) {\n case DeviceModelId.NANO_X:\n return gte(version, \"2.0.0\");\n default:\n return false;\n }\n }\n\n private isLocalizationSupported(\n seVersion: string,\n deviceModelId: DeviceModelId,\n ): boolean {\n const version = coerce(seVersion) ?? \"\";\n switch (deviceModelId) {\n case DeviceModelId.NANO_S:\n return false;\n case DeviceModelId.NANO_SP:\n return gte(version, \"1.1.0\");\n case DeviceModelId.NANO_X:\n return gte(version, \"2.1.0\");\n default:\n return true;\n }\n }\n\n private isRecoverSupported(\n seVersion: string,\n deviceModelId: DeviceModelId,\n ): boolean {\n const version = coerce(seVersion) ?? \"\";\n switch (deviceModelId) {\n case DeviceModelId.NANO_S:\n return false;\n case DeviceModelId.NANO_SP:\n return gte(version, \"1.1.2\");\n case DeviceModelId.NANO_X:\n return gte(version, \"2.2.3\");\n case DeviceModelId.STAX:\n return gte(version, \"1.4.0\");\n case DeviceModelId.FLEX:\n return gte(version, \"1.0.1\");\n default:\n return true;\n }\n }\n}\n"],
5
+ "mappings": "AAAA,OAAS,UAAAA,EAAQ,OAAAC,MAAW,SAG5B,OAAS,eAAAC,MAAyC,8BAClD,OAAS,cAAAC,MAAkB,6BAE3B,OAAS,0BAAAC,MAA8B,sBACvC,OAEE,wBAAAC,MACK,mCACP,OAAS,gBAAAC,MAAoB,kCAC7B,OAAS,6BAAAC,MAAiC,wCAC1C,OAAS,iBAAAC,MAAqB,0BAI9B,OAAS,4BAAAC,MAAgC,6BA6FlC,MAAMC,CAA6D,CAC/D,KAAO,eACP,KAAO,OAEhB,SAAgB,CACd,MAAMC,EAAwC,CAC5C,IAAK,IACL,IAAK,EACL,GAAI,EACJ,GAAI,CACN,EACA,OAAO,IAAIT,EAAYS,CAAoB,EAAE,MAAM,CACrD,CAEA,cACEC,EACAC,EAC2B,CAC3B,GAAI,CAACP,EAAa,kBAAkBM,CAAY,EAC9C,OAAOP,EAAqB,CAC1B,MAAOE,EAA0B,OAAOK,CAAY,CACtD,CAAC,EAEH,MAAME,EAAS,IAAIX,EAAWS,CAAY,EACpCG,EAAWD,EAAO,iBAAiB,EACzC,GAAIC,IAAa,OACf,OAAOV,EAAqB,CAC1B,MAAO,IAAID,EAAuB,iCAAiC,CACrE,CAAC,EAGH,IAAIY,EAAUF,EAAO,eAAeA,EAAO,sBAAsB,CAAC,EAC9DG,EAAUH,EAAO,sBAAsB,GAAK,IAAI,WAAW,CAAC,EAChE,MAAMI,EAAgB,IAAIT,EAAyBQ,CAAO,EACpDE,EAAqB,CACzB,GAAGD,EAAc,mBAAmB,EACpC,GAAGA,E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ACA,WAAAY,EACA,YAAAD,EACA,UAAAJ,EACA,QAAAL,EACA,eAAAM,EACA,qBAAAC,EACA,UAAAC,EACA,OAAAG,EACA,aAAAC,EACA,mBAAAV,CACF,CACF,CAAC,CACH,CAEQ,6BACNG,EACAT,EACS,CACT,MAAMG,EAAUhB,EAAOsB,CAAS,GAAK,GACrC,OAAQT,EAAe,CACrB,KAAKL,EAAc,OACnB,KAAKA,EAAc,OACjB,OAAOP,EAAIe,EAAS,OAAO,EAC7B,QACE,MAAO,EACX,CACF,CAEQ,2BACNM,EACAT,EACS,CACT,MAAMG,EAAUhB,EAAOsB,CAAS,GAAK,GACrC,OAAQT,EAAe,CACrB,KAAKL,EAAc,OACjB,OAAOP,EAAIe,EAAS,OAAO,EAC7B,QACE,MAAO,EACX,CACF,CAEQ,wBACNM,EACAT,EACS,CACT,MAAMG,EAAUhB,EAAOsB,CAAS,GAAK,GACrC,OAAQT,EAAe,CACrB,KAAKL,EAAc,OACjB,MAAO,GACT,KAAKA,EAAc,QACjB,OAAOP,EAAIe,EAAS,OAAO,EAC7B,KAAKR,EAAc,OACjB,OAAOP,EAAIe,EAAS,OAAO,EAC7B,QACE,MAAO,EACX,CACF,CAEQ,mBACNM,EACAT,EACS,CACT,MAAMG,EAAUhB,EAAOsB,CAAS,GAAK,GACrC,OAAQT,EAAe,CACrB,KAAKL,EAAc,OACjB,MAAO,GACT,KAAKA,EAAc,QACjB,OAAOP,EAAIe,EAAS,OAAO,EAC7B,KAAKR,EAAc,OACjB,OAAOP,EAAIe,EAAS,OAAO,EAC7B,KAAKR,EAAc,KACjB,OAAOP,EAAIe,EAAS,OAAO,EAC7B,KAAKR,EAAc,KACjB,OAAOP,EAAIe,EAAS,OAAO,EAC7B,QACE,MAAO,EACX,CACF,CACF",
6
+ "names": ["coerce", "gte", "ApduBuilder", "ApduParser", "InvalidStatusWordError", "CommandResultFactory", "CommandUtils", "GlobalCommandErrorHandler", "DeviceModelId", "SecureElementFlagsParser", "GetOsVersionCommand", "getOsVersionApduArgs", "apduResponse", "deviceModelId", "parser", "targetId", "version", "seFlags", "seFlagsParser", "secureElementFlags", "isBootloader", "isOsu", "seVersion", "mcuSephVersion", "mcuBootloaderVersion", "hwVersion", "mcuTargetId", "seTargetId", "langId", "recoverState", "seData", "langIdBuffer", "recoverStateBuffer"]
7
7
  }
@@ -1,2 +1,2 @@
1
- import{CommandResultFactory as o,isSuccessCommandResult as n}from"../../command/model/CommandResult";import{DeviceModelId as x}from"../../device/DeviceModel";import{ApduResponse as r}from"../../device-session/ApduResponse";import{getOsVersionCommandResponseMockBuilder as a}from"./__mocks__/GetOsVersionCommand";import{GetOsVersionCommand as d}from"./GetOsVersionCommand";const i=Uint8Array.from([224,1,0,0,0]),c=Uint8Array.from([51,0,0,4,5,50,46,50,46,51,4,230,0,0,0,4,50,46,51,48,4,49,46,49,54,1,0,1,0,1,0,144,0]),u=new r({statusCode:Uint8Array.from([144,0]),data:c}),l=Uint8Array.from([51,16,0,4,5,49,46,49,46,49,4,230,0,0,0,4,52,46,48,51,4,51,46,49,50,1,0,1,0,144,0]),p=new r({statusCode:Uint8Array.from([144,0]),data:l}),m=Uint8Array.from([51,32,0,4,5,49,46,51,46,48,4,230,0,0,0,4,53,46,50,52,4,48,46,52,56,1,0,1,0,144,0]),O=new r({statusCode:Uint8Array.from([144,0]),data:m}),S=Uint8Array.from([5,1,0,3,4,49,46,49,54,4,244,216,170,67,5,50,46,50,46,51,4,51,0,0,4,144,0]),A=new r({statusCode:Uint8Array.from([144,0]),data:S}),f=Uint8Array.from([51,0,0,4,0,4,238,0,0,0,4,50,46,51,48,1,1,1,0,1,0,144,0]),_=new r({statusCode:Uint8Array.from([144,0]),data:f});describe("GetOsVersionCommand",()=>{let s;beforeEach(()=>{s=new d}),describe("name",()=>{it("should be 'getOsVersion'",()=>{expect(s.name).toBe("getOsVersion")})}),describe("getApdu",()=>{it("should return the GetOsVersion apdu",()=>{const e=s.getApdu();expect(e.getRawApdu()).toStrictEqual(i)})}),describe("parseResponse",()=>{describe("Nano X",()=>{it("should parse the LNX response",()=>{const e=s.parseResponse(u,x.NANO_X),t=o({data:a(x.NANO_X)});expect(e).toStrictEqual(t)})}),describe("Nano S Plus",()=>{it("should parse the LNSP response",()=>{const e=s.parseResponse(p,x.NANO_SP),t=o({data:a(x.NANO_SP)});expect(e).toStrictEqual(t)})}),describe("Stax",()=>{it("should parse the STAX response",()=>{const e=s.parseResponse(O,x.STAX),t=o({data:a(x.STAX)});expect(e).toStrictEqual(t)})}),describe("Bootloader",()=>{it("should parse the bootloader response",()=>{const e=s.parseResponse(A,x.STAX),t=o({data:{isBootloader:!0,isOsu:!1,targetId:83951619,seTargetId:855638020,seVersion:"2.2.3",seFlags:new Uint8Array([244,216,170,67]),mcuTargetId:83951619,mcuSephVersion:"",mcuBootloaderVersion:"1.16",hwVersion:"",langId:void 0,recoverState:void 0,secureElementFlags:{isPinValidated:!0,hasMcuSerialNumber:!0,hasValidCertificate:!0,isCustomAuthorityConnectionAllowed:!0,isSecureConnectionAllowed:!1,isOnboarded:!0,isMcuCodeSigned:!1,isInRecoveryMode:!1}}});expect(e).toStrictEqual(t)})}),describe("Old firmware",()=>{it("should parse the old firmware response",()=>{const e=s.parseResponse(_,x.NANO_X),t=o({data:{isBootloader:!1,isOsu:!1,targetId:855638020,seTargetId:855638020,seVersion:"0.0.0",seFlags:new Uint8Array,mcuTargetId:void 0,mcuSephVersion:"2.30",mcuBootloaderVersion:"",hwVersion:"00",langId:void 0,recoverState:void 0,secureElementFlags:{isPinValidated:!0,hasMcuSerialNumber:!0,hasValidCertificate:!0,isCustomAuthorityConnectionAllowed:!1,isSecureConnectionAllowed:!0,isOnboarded:!0,isMcuCodeSigned:!0,isInRecoveryMode:!1}}});expect(e).toStrictEqual(t)})}),describe("Error handling",()=>{it("should return an error if the response is not successful",()=>{const e=new r({statusCode:Uint8Array.from([110,128]),data:Uint8Array.from([])}),t=s.parseResponse(e,x.NANO_S);expect(n(t)).toBeFalsy()})})})});
1
+ import{CommandResultFactory as x,isSuccessCommandResult as a}from"../../command/model/CommandResult";import{DeviceModelId as r}from"../../device/DeviceModel";import{OnboardingState as n,SeedWordCount as d}from"../../device/SecureElementFlags";import{ApduResponse as o}from"../../device-session/ApduResponse";import{getOsVersionCommandResponseMockBuilder as c}from"./__mocks__/GetOsVersionCommand";import{GetOsVersionCommand as S}from"./GetOsVersionCommand";const p=Uint8Array.from([224,1,0,0,0]),u=Uint8Array.from([51,0,0,4,5,50,46,50,46,51,4,230,0,0,0,4,50,46,51,48,4,49,46,49,54,1,0,1,0,1,0,144,0]),f=new o({statusCode:Uint8Array.from([144,0]),data:u}),m=new o({statusCode:Uint8Array.from([144,0]),data:Uint8Array.from([51,0,0,4,5,50,46,50,46,51,0,4,50,46,51,48,4,49,46,49,54,1,0,1,0,1,0,144,0])}),A=Uint8Array.from([51,16,0,4,5,49,46,49,46,49,4,230,0,0,0,4,52,46,48,51,4,51,46,49,50,1,0,1,0,144,0]),O=new o({statusCode:Uint8Array.from([144,0]),data:A}),E=Uint8Array.from([51,32,0,4,5,49,46,51,46,48,4,230,0,0,0,4,53,46,50,52,4,48,46,52,56,1,0,1,0,144,0]),h=new o({statusCode:Uint8Array.from([144,0]),data:E}),_=Uint8Array.from([5,1,0,3,4,49,46,49,54,4,244,216,170,67,5,50,46,50,46,51,4,51,0,0,4,144,0]),N=new o({statusCode:Uint8Array.from([144,0]),data:_}),C=Uint8Array.from([51,0,0,4,0,4,238,0,0,0,4,50,46,51,48,1,1,1,0,1,0,144,0]),g=new o({statusCode:Uint8Array.from([144,0]),data:C});describe("GetOsVersionCommand",()=>{let s;beforeEach(()=>{s=new S}),describe("name",()=>{it("should be 'getOsVersion'",()=>{expect(s.name).toBe("getOsVersion")})}),describe("getApdu",()=>{it("should return the GetOsVersion apdu",()=>{const e=s.getApdu();expect(e.getRawApdu()).toStrictEqual(p)})}),describe("parseResponse",()=>{describe("Nano X",()=>{it("should parse the LNX response",()=>{const e=s.parseResponse(f,r.NANO_X),t=x({data:c(r.NANO_X)});expect(e).toStrictEqual(t)}),it("should default parsed flags when the response contains empty SE flags",()=>{const e=s.parseResponse(m,r.NANO_X);expect(a(e)).toBe(!0),a(e)&&(expect(e.data.seFlags).toStrictEqual(new Uint8Array),expect(e.data.secureElementFlags).toStrictEqual({isPinValidated:!1,hasMcuSerialNumber:!1,hasValidCertificate:!1,isCustomAuthorityConnectionAllowed:!1,isSecureConnectionAllowed:!1,isOnboarded:!1,isMcuCodeSigned:!1,isInRecoveryMode:!1,hasEndorsementCertificateInSlot1:!1,hasEndorsementCertificateInSlot2:!1,numberOfWords:d.TwentyFour,currentWordIndex:0,onboardingState:n.WelcomeScreen1}))}),it.each([[11,n.DeviceIsReady],[16,n.RestoreWithRk]])("should parse SE flag byte 4 0x%s as %s",(e,t)=>{const l=Uint8Array.from(u);l[14]=e;const i=s.parseResponse(new o({statusCode:Uint8Array.from([144,0]),data:l}),r.NANO_X);expect(a(i)).toBe(!0),a(i)&&(expect(i.data.seFlags).toStrictEqual(new Uint8Array([230,0,0,e])),expect(i.data.secureElementFlags.onboardingState).toBe(t))})}),describe("Nano S Plus",()=>{it("should parse the LNSP response",()=>{const e=s.parseResponse(O,r.NANO_SP),t=x({data:c(r.NANO_SP)});expect(e).toStrictEqual(t)})}),describe("Stax",()=>{it("should parse the STAX response",()=>{const e=s.parseResponse(h,r.STAX),t=x({data:c(r.STAX)});expect(e).toStrictEqual(t)})}),describe("Bootloader",()=>{it("should parse the bootloader response",()=>{const e=s.parseResponse(N,r.STAX),t=x({data:{isBootloader:!0,isOsu:!1,targetId:83951619,seTargetId:855638020,seVersion:"2.2.3",seFlags:new Uint8Array([244,216,170,67]),mcuTargetId:83951619,mcuSephVersion:"",mcuBootloaderVersion:"1.16",hwVersion:"",langId:void 0,recoverState:void 0,secureElementFlags:{isPinValidated:!0,hasMcuSerialNumber:!0,hasValidCertificate:!0,isCustomAuthorityConnectionAllowed:!0,isSecureConnectionAllowed:!1,isOnboarded:!0,isMcuCodeSigned:!1,isInRecoveryMode:!1,hasEndorsementCertificateInSlot1:!1,hasEndorsementCertificateInSlot2:!1,numberOfWords:d.Eighteen,currentWordIndex:10,onboardingState:n.Unknown}}});expect(e).toStrictEqual(t)})}),describe("Old firmware",()=>{it("should parse the old firmware response",()=>{const e=s.parseResponse(g,r.NANO_X),t=x({data:{isBootloader:!1,isOsu:!1,targetId:855638020,seTargetId:855638020,seVersion:"0.0.0",seFlags:new Uint8Array,mcuTargetId:void 0,mcuSephVersion:"2.30",mcuBootloaderVersion:"",hwVersion:"00",langId:void 0,recoverState:void 0,secureElementFlags:{isPinValidated:!0,hasMcuSerialNumber:!0,hasValidCertificate:!0,isCustomAuthorityConnectionAllowed:!1,isSecureConnectionAllowed:!0,isOnboarded:!0,isMcuCodeSigned:!0,isInRecoveryMode:!1,hasEndorsementCertificateInSlot1:!1,hasEndorsementCertificateInSlot2:!1,numberOfWords:d.TwentyFour,currentWordIndex:0,onboardingState:n.WelcomeScreen1}}});expect(e).toStrictEqual(t)})}),describe("Error handling",()=>{it("should return an error if the response is not successful",()=>{const e=new o({statusCode:Uint8Array.from([110,128]),data:Uint8Array.from([])}),t=s.parseResponse(e,r.NANO_S);expect(a(t)).toBeFalsy()})})})});
2
2
  //# sourceMappingURL=GetOsVersionCommand.test.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../../../src/api/command/os/GetOsVersionCommand.test.ts"],
4
- "sourcesContent": ["import {\n CommandResultFactory,\n isSuccessCommandResult,\n} from \"@api/command/model/CommandResult\";\nimport { DeviceModelId } from \"@api/device/DeviceModel\";\nimport { ApduResponse } from \"@api/device-session/ApduResponse\";\n\nimport { getOsVersionCommandResponseMockBuilder } from \"./__mocks__/GetOsVersionCommand\";\nimport { GetOsVersionCommand } from \"./GetOsVersionCommand\";\n\nconst GET_OS_VERSION_APDU = Uint8Array.from([0xe0, 0x01, 0x00, 0x00, 0x00]);\n\nconst LNX_RESPONSE_DATA_GOOD = Uint8Array.from([\n 0x33, 0x00, 0x00, 0x04, 0x05, 0x32, 0x2e, 0x32, 0x2e, 0x33, 0x04, 0xe6, 0x00,\n 0x00, 0x00, 0x04, 0x32, 0x2e, 0x33, 0x30, 0x04, 0x31, 0x2e, 0x31, 0x36, 0x01,\n 0x00, 0x01, 0x00, 0x01, 0x00, 0x90, 0x00,\n]);\nconst LNX_RESPONSE_GOOD = new ApduResponse({\n statusCode: Uint8Array.from([0x90, 0x00]),\n data: LNX_RESPONSE_DATA_GOOD,\n});\n\nconst LNSP_REPONSE_DATA_GOOD = Uint8Array.from([\n 0x33, 0x10, 0x00, 0x04, 0x05, 0x31, 0x2e, 0x31, 0x2e, 0x31, 0x04, 0xe6, 0x00,\n 0x00, 0x00, 0x04, 0x34, 0x2e, 0x30, 0x33, 0x04, 0x33, 0x2e, 0x31, 0x32, 0x01,\n 0x00, 0x01, 0x00, 0x90, 0x00,\n]);\nconst LNSP_RESPONSE_GOOD = new ApduResponse({\n statusCode: Uint8Array.from([0x90, 0x00]),\n data: LNSP_REPONSE_DATA_GOOD,\n});\n\nconst STAX_RESPONSE_DATA_GOOD = Uint8Array.from([\n 0x33, 0x20, 0x00, 0x04, 0x05, 0x31, 0x2e, 0x33, 0x2e, 0x30, 0x04, 0xe6, 0x00,\n 0x00, 0x00, 0x04, 0x35, 0x2e, 0x32, 0x34, 0x04, 0x30, 0x2e, 0x34, 0x38, 0x01,\n 0x00, 0x01, 0x00, 0x90, 0x00,\n]);\nconst STAX_RESPONSE_GOOD = new ApduResponse({\n statusCode: Uint8Array.from([0x90, 0x00]),\n data: STAX_RESPONSE_DATA_GOOD,\n});\n\nconst BL_RESPONSE_DATA_GOOD = Uint8Array.from([\n 0x05, 0x01, 0x00, 0x03, 0x04, 0x31, 0x2e, 0x31, 0x36, 0x04, 0xf4, 0xd8, 0xaa,\n 0x43, 0x05, 0x32, 0x2e, 0x32, 0x2e, 0x33, 0x04, 0x33, 0x00, 0x00, 0x04, 0x90,\n 0x00,\n]);\nconst BL_RESPONSE_GOOD = new ApduResponse({\n statusCode: Uint8Array.from([0x90, 0x00]),\n data: BL_RESPONSE_DATA_GOOD,\n});\n\nconst OLD_FM_RESPONSE_DATA_GOOD = Uint8Array.from([\n 0x33, 0x00, 0x00, 0x04, 0x00, 0x04, 0xee, 0x00, 0x00, 0x00, 0x04, 0x32, 0x2e,\n 0x33, 0x30, 0x01, 0x01, 0x01, 0x00, 0x01, 0x00, 0x90, 0x00,\n]);\nconst OLD_FM_RESPONSE_GOOD = new ApduResponse({\n statusCode: Uint8Array.from([0x90, 0x00]),\n data: OLD_FM_RESPONSE_DATA_GOOD,\n});\n\ndescribe(\"GetOsVersionCommand\", () => {\n let command: GetOsVersionCommand;\n\n beforeEach(() => {\n command = new GetOsVersionCommand();\n });\n\n describe(\"name\", () => {\n it(\"should be 'getOsVersion'\", () => {\n expect(command.name).toBe(\"getOsVersion\");\n });\n });\n\n describe(\"getApdu\", () => {\n it(\"should return the GetOsVersion apdu\", () => {\n const apdu = command.getApdu();\n expect(apdu.getRawApdu()).toStrictEqual(GET_OS_VERSION_APDU);\n });\n });\n\n describe(\"parseResponse\", () => {\n describe(\"Nano X\", () => {\n it(\"should parse the LNX response\", () => {\n const parsed = command.parseResponse(\n LNX_RESPONSE_GOOD,\n DeviceModelId.NANO_X,\n );\n\n const expected = CommandResultFactory({\n data: getOsVersionCommandResponseMockBuilder(DeviceModelId.NANO_X),\n });\n\n expect(parsed).toStrictEqual(expected);\n });\n });\n\n describe(\"Nano S Plus\", () => {\n it(\"should parse the LNSP response\", () => {\n const parsed = command.parseResponse(\n LNSP_RESPONSE_GOOD,\n DeviceModelId.NANO_SP,\n );\n\n const expected = CommandResultFactory({\n data: getOsVersionCommandResponseMockBuilder(DeviceModelId.NANO_SP),\n });\n\n expect(parsed).toStrictEqual(expected);\n });\n });\n\n describe(\"Stax\", () => {\n it(\"should parse the STAX response\", () => {\n const parsed = command.parseResponse(\n STAX_RESPONSE_GOOD,\n DeviceModelId.STAX,\n );\n\n const expected = CommandResultFactory({\n data: getOsVersionCommandResponseMockBuilder(DeviceModelId.STAX),\n });\n\n expect(parsed).toStrictEqual(expected);\n });\n });\n\n describe(\"Bootloader\", () => {\n it(\"should parse the bootloader response\", () => {\n const parsed = command.parseResponse(\n BL_RESPONSE_GOOD,\n DeviceModelId.STAX,\n );\n\n const expected = CommandResultFactory({\n data: {\n isBootloader: true,\n isOsu: false,\n targetId: 83951619,\n seTargetId: 855638020,\n seVersion: \"2.2.3\",\n seFlags: new Uint8Array([0xf4, 0xd8, 0xaa, 0x43]),\n mcuTargetId: 83951619,\n mcuSephVersion: \"\",\n mcuBootloaderVersion: \"1.16\",\n hwVersion: \"\",\n langId: undefined,\n recoverState: undefined,\n secureElementFlags: {\n isPinValidated: true,\n hasMcuSerialNumber: true,\n hasValidCertificate: true,\n isCustomAuthorityConnectionAllowed: true,\n isSecureConnectionAllowed: false,\n isOnboarded: true,\n isMcuCodeSigned: false,\n isInRecoveryMode: false,\n },\n },\n });\n\n expect(parsed).toStrictEqual(expected);\n });\n });\n\n describe(\"Old firmware\", () => {\n it(\"should parse the old firmware response\", () => {\n const parsed = command.parseResponse(\n OLD_FM_RESPONSE_GOOD,\n DeviceModelId.NANO_X,\n );\n\n const expected = CommandResultFactory({\n data: {\n isBootloader: false,\n isOsu: false,\n targetId: 855638020,\n seTargetId: 855638020,\n seVersion: \"0.0.0\",\n seFlags: new Uint8Array(),\n mcuTargetId: undefined,\n mcuSephVersion: \"2.30\",\n mcuBootloaderVersion: \"\",\n hwVersion: \"00\",\n langId: undefined,\n recoverState: undefined,\n secureElementFlags: {\n isPinValidated: true,\n hasMcuSerialNumber: true,\n hasValidCertificate: true,\n isCustomAuthorityConnectionAllowed: false,\n isSecureConnectionAllowed: true,\n isOnboarded: true,\n isMcuCodeSigned: true,\n isInRecoveryMode: false,\n },\n },\n });\n\n expect(parsed).toStrictEqual(expected);\n });\n });\n\n describe(\"Error handling\", () => {\n it(\"should return an error if the response is not successful\", () => {\n const response = new ApduResponse({\n statusCode: Uint8Array.from([0x6e, 0x80]),\n data: Uint8Array.from([]),\n });\n const result = command.parseResponse(response, DeviceModelId.NANO_S);\n\n expect(isSuccessCommandResult(result)).toBeFalsy();\n });\n });\n });\n});\n"],
5
- "mappings": "AAAA,OACE,wBAAAA,EACA,0BAAAC,MACK,mCACP,OAAS,iBAAAC,MAAqB,0BAC9B,OAAS,gBAAAC,MAAoB,mCAE7B,OAAS,0CAAAC,MAA8C,kCACvD,OAAS,uBAAAC,MAA2B,wBAEpC,MAAMC,EAAsB,WAAW,KAAK,CAAC,IAAM,EAAM,EAAM,EAAM,CAAI,CAAC,EAEpEC,EAAyB,WAAW,KAAK,CAC7C,GAAM,EAAM,EAAM,EAAM,EAAM,GAAM,GAAM,GAAM,GAAM,GAAM,EAAM,IAAM,EACxE,EAAM,EAAM,EAAM,GAAM,GAAM,GAAM,GAAM,EAAM,GAAM,GAAM,GAAM,GAAM,EACxE,EAAM,EAAM,EAAM,EAAM,EAAM,IAAM,CACtC,CAAC,EACKC,EAAoB,IAAIL,EAAa,CACzC,WAAY,WAAW,KAAK,CAAC,IAAM,CAAI,CAAC,EACxC,KAAMI,CACR,CAAC,EAEKE,EAAyB,WAAW,KAAK,CAC7C,GAAM,GAAM,EAAM,EAAM,EAAM,GAAM,GAAM,GAAM,GAAM,GAAM,EAAM,IAAM,EACxE,EAAM,EAAM,EAAM,GAAM,GAAM,GAAM,GAAM,EAAM,GAAM,GAAM,GAAM,GAAM,EACxE,EAAM,EAAM,EAAM,IAAM,CAC1B,CAAC,EACKC,EAAqB,IAAIP,EAAa,CAC1C,WAAY,WAAW,KAAK,CAAC,IAAM,CAAI,CAAC,EACxC,KAAMM,CACR,CAAC,EAEKE,EAA0B,WAAW,KAAK,CAC9C,GAAM,GAAM,EAAM,EAAM,EAAM,GAAM,GAAM,GAAM,GAAM,GAAM,EAAM,IAAM,EACxE,EAAM,EAAM,EAAM,GAAM,GAAM,GAAM,GA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ASF,EAAQ,cACrBD,EACAd,EAAc,MAChB,EAEMkB,EAAWpB,EAAqB,CACpC,KAAM,CACJ,aAAc,GACd,MAAO,GACP,SAAU,UACV,WAAY,UACZ,UAAW,QACX,QAAS,IAAI,WACb,YAAa,OACb,eAAgB,OAChB,qBAAsB,GACtB,UAAW,KACX,OAAQ,OACR,aAAc,OACd,mBAAoB,CAClB,eAAgB,GAChB,mBAAoB,GACpB,oBAAqB,GACrB,mCAAoC,GACpC,0BAA2B,GAC3B,YAAa,GACb,gBAAiB,GACjB,iBAAkB,EACpB,CACF,CACF,CAAC,EAED,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
- "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"]
4
+ "sourcesContent": ["import {\n CommandResultFactory,\n isSuccessCommandResult,\n} from \"@api/command/model/CommandResult\";\nimport { DeviceModelId } from \"@api/device/DeviceModel\";\nimport { OnboardingState, SeedWordCount } from \"@api/device/SecureElementFlags\";\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 LNX_RESPONSE_WITH_EMPTY_SE_FLAGS = new ApduResponse({\n statusCode: Uint8Array.from([0x90, 0x00]),\n data: Uint8Array.from([\n 0x33, 0x00, 0x00, 0x04, 0x05, 0x32, 0x2e, 0x32, 0x2e, 0x33, 0x00, 0x04,\n 0x32, 0x2e, 0x33, 0x30, 0x04, 0x31, 0x2e, 0x31, 0x36, 0x01, 0x00, 0x01,\n 0x00, 0x01, 0x00, 0x90, 0x00,\n ]),\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 it(\"should default parsed flags when the response contains empty SE flags\", () => {\n const parsed = command.parseResponse(\n LNX_RESPONSE_WITH_EMPTY_SE_FLAGS,\n DeviceModelId.NANO_X,\n );\n\n expect(isSuccessCommandResult(parsed)).toBe(true);\n if (!isSuccessCommandResult(parsed)) {\n return;\n }\n expect(parsed.data.seFlags).toStrictEqual(new Uint8Array());\n expect(parsed.data.secureElementFlags).toStrictEqual({\n isPinValidated: false,\n hasMcuSerialNumber: false,\n hasValidCertificate: false,\n isCustomAuthorityConnectionAllowed: false,\n isSecureConnectionAllowed: false,\n isOnboarded: false,\n isMcuCodeSigned: false,\n isInRecoveryMode: false,\n hasEndorsementCertificateInSlot1: false,\n hasEndorsementCertificateInSlot2: false,\n numberOfWords: SeedWordCount.TwentyFour,\n currentWordIndex: 0,\n onboardingState: OnboardingState.WelcomeScreen1,\n });\n });\n\n it.each([\n [0x0b, OnboardingState.DeviceIsReady],\n [0x10, OnboardingState.RestoreWithRk],\n ] as const)(\n \"should parse SE flag byte 4 0x%s as %s\",\n (onboardingByte, onboardingState) => {\n const data = Uint8Array.from(LNX_RESPONSE_DATA_GOOD);\n data[14] = onboardingByte;\n const parsed = command.parseResponse(\n new ApduResponse({\n statusCode: Uint8Array.from([0x90, 0x00]),\n data,\n }),\n DeviceModelId.NANO_X,\n );\n\n expect(isSuccessCommandResult(parsed)).toBe(true);\n if (!isSuccessCommandResult(parsed)) {\n return;\n }\n expect(parsed.data.seFlags).toStrictEqual(\n new Uint8Array([0xe6, 0x00, 0x00, onboardingByte]),\n );\n expect(parsed.data.secureElementFlags.onboardingState).toBe(\n onboardingState,\n );\n },\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 hasEndorsementCertificateInSlot1: false,\n hasEndorsementCertificateInSlot2: false,\n numberOfWords: SeedWordCount.Eighteen,\n currentWordIndex: 10,\n onboardingState: OnboardingState.Unknown,\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 hasEndorsementCertificateInSlot1: false,\n hasEndorsementCertificateInSlot2: false,\n numberOfWords: SeedWordCount.TwentyFour,\n currentWordIndex: 0,\n onboardingState: OnboardingState.WelcomeScreen1,\n },\n },\n });\n\n expect(parsed).toStrictEqual(expected);\n });\n });\n\n describe(\"Error handling\", () => {\n it(\"should return an error if the response is not successful\", () => {\n const response = new ApduResponse({\n statusCode: Uint8Array.from([0x6e, 0x80]),\n data: Uint8Array.from([]),\n });\n const result = command.parseResponse(response, DeviceModelId.NANO_S);\n\n expect(isSuccessCommandResult(result)).toBeFalsy();\n });\n });\n });\n});\n"],
5
+ "mappings": "AAAA,OACE,wBAAAA,EACA,0BAAAC,MACK,mCACP,OAAS,iBAAAC,MAAqB,0BAC9B,OAAS,mBAAAC,EAAiB,iBAAAC,MAAqB,iCAC/C,OAAS,gBAAAC,MAAoB,mCAE7B,OAAS,0CAAAC,MAA8C,kCACvD,OAAS,uBAAAC,MAA2B,wBAEpC,MAAMC,EAAsB,WAAW,KAAK,CAAC,IAAM,EAAM,EAAM,EAAM,CAAI,CAAC,EAEpEC,EAAyB,WAAW,KAAK,CAC7C,GAAM,EAAM,EAAM,EAAM,EAAM,GAAM,GAAM,GAAM,GAAM,GAAM,EAAM,IAAM,EACxE,EAAM,EAAM,EAAM,GAAM,GAAM,GAAM,GAAM,EAAM,GAAM,GAAM,GAAM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AAc,WAC7B,iBAAkB,EAClB,gBAAiBD,EAAgB,cACnC,CACF,CACF,CAAC,EAED,OAAOmB,CAAM,EAAE,cAAcC,CAAQ,CACvC,CAAC,CACH,CAAC,EAED,SAAS,iBAAkB,IAAM,CAC/B,GAAG,2DAA4D,IAAM,CACnE,MAAMI,EAAW,IAAItB,EAAa,CAChC,WAAY,WAAW,KAAK,CAAC,IAAM,GAAI,CAAC,EACxC,KAAM,WAAW,KAAK,CAAC,CAAC,CAC1B,CAAC,EACKuB,EAASR,EAAQ,cAAcO,EAAUzB,EAAc,MAAM,EAEnE,OAAOD,EAAuB2B,CAAM,CAAC,EAAE,UAAU,CACnD,CAAC,CACH,CAAC,CACH,CAAC,CACH,CAAC",
6
+ "names": ["CommandResultFactory", "isSuccessCommandResult", "DeviceModelId", "OnboardingState", "SeedWordCount", "ApduResponse", "getOsVersionCommandResponseMockBuilder", "GetOsVersionCommand", "GET_OS_VERSION_APDU", "LNX_RESPONSE_DATA_GOOD", "LNX_RESPONSE_GOOD", "LNX_RESPONSE_WITH_EMPTY_SE_FLAGS", "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", "onboardingByte", "onboardingState", "data", "response", "result"]
7
7
  }
@@ -1,2 +1,2 @@
1
- class r{constructor(e){this.seFlags=e;if(this.seFlags.length!==4)throw new Error("Invalid secure element flags length")}generalDeviceState(){const e=this.seFlags[0]??0;return{isPinValidated:this._checkNthBitInByte(e,1),hasMcuSerialNumber:this._checkNthBitInByte(e,2),hasValidCertificate:this._checkNthBitInByte(e,3),isCustomAuthorityConnectionAllowed:this._checkNthBitInByte(e,4),isSecureConnectionAllowed:this._checkNthBitInByte(e,5),isOnboarded:this._checkNthBitInByte(e,6),isMcuCodeSigned:this._checkNthBitInByte(e,7),isInRecoveryMode:this._checkNthBitInByte(e,8)}}endorsementInformation(){throw new Error("Not implemented")}wordsInformation(){throw new Error("Not implemented")}onboardingStatus(){throw new Error("Not implemented")}_checkNthBitInByte(e,t){return(e>>8-t&1)===1}}export{r as SecureElementFlagsParser};
1
+ import{OnboardingState as t,SeedWordCount as r}from"../../device/SecureElementFlags";const o={0:t.WelcomeScreen1,1:t.WelcomeScreen2,2:t.WelcomeScreen3,3:t.WelcomeScreen4,4:t.WelcomeScreenReminder,5:t.SetupChoice,6:t.Pin,7:t.NewDevice,8:t.ConfirmNewDevice,9:t.RestoreRecoveryPhrase,10:t.SafetyWarning,11:t.DeviceIsReady,12:t.ChooseName,13:t.RestoreRecoverBackup,14:t.SetupRestoreChoice,15:t.OnboardingStatusCheck,16:t.RestoreWithRk};class c{seFlags;constructor(e){this.seFlags=new Uint8Array(4),this.seFlags.set(e.subarray(0,this.seFlags.length))}generalDeviceState(){const e=this.seFlags[0]??0;return{isPinValidated:this._checkNthBitInByte(e,1),hasMcuSerialNumber:this._checkNthBitInByte(e,2),hasValidCertificate:this._checkNthBitInByte(e,3),isCustomAuthorityConnectionAllowed:this._checkNthBitInByte(e,4),isSecureConnectionAllowed:this._checkNthBitInByte(e,5),isOnboarded:this._checkNthBitInByte(e,6),isMcuCodeSigned:this._checkNthBitInByte(e,7),isInRecoveryMode:this._checkNthBitInByte(e,8)}}endorsementInformation(){const e=this.seFlags[1]??0;return{hasEndorsementCertificateInSlot1:(e&1)!==0,hasEndorsementCertificateInSlot2:(e&2)!==0}}wordsInformation(){const e=this.seFlags[2]??0,n=e>>5&3;return{numberOfWords:[r.TwentyFour,r.Eighteen,r.Twelve,void 0][n],currentWordIndex:e&31}}onboardingStatus(){const e=this.seFlags[3]??0;return{onboardingState:o[e]??t.Unknown}}_checkNthBitInByte(e,n){return(e>>8-n&1)===1}}export{c as SecureElementFlagsParser};
2
2
  //# sourceMappingURL=SecureElementFlagsParser.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../../../src/api/command/os/SecureElementFlagsParser.ts"],
4
- "sourcesContent": ["import {\n type DeviceGeneralState,\n type EndorsementInformation,\n type OnboardingStatus,\n type WordsInformation,\n} from \"@api/device/SecureElementFlags\";\n\n/**\n * Secure element flags parser class.\n */\nexport class SecureElementFlagsParser {\n /**\n * Creates an instance of SecureElementFlags parser.\n * @param seFlags - The secure element flags as an Uint8Array, it comes from the response of the GetOsVersionCommand.\n */\n constructor(private readonly seFlags: Uint8Array) {\n if (this.seFlags.length !== 4) {\n throw new Error(\"Invalid secure element flags length\");\n }\n }\n\n /**\n * Retrieves the general device state based on the secure element flags, which is the first byte of the flags.\n * @returns {DeviceGeneralState}\n */\n generalDeviceState(): DeviceGeneralState {\n const firstByte = this.seFlags[0] ?? 0x00;\n\n return {\n isPinValidated: this._checkNthBitInByte(firstByte, 1),\n hasMcuSerialNumber: this._checkNthBitInByte(firstByte, 2),\n hasValidCertificate: this._checkNthBitInByte(firstByte, 3),\n isCustomAuthorityConnectionAllowed: this._checkNthBitInByte(firstByte, 4),\n isSecureConnectionAllowed: this._checkNthBitInByte(firstByte, 5),\n isOnboarded: this._checkNthBitInByte(firstByte, 6),\n isMcuCodeSigned: this._checkNthBitInByte(firstByte, 7),\n isInRecoveryMode: this._checkNthBitInByte(firstByte, 8),\n };\n }\n\n /**\n * Retrieves the endorsement information based on the secure element flags, which is the second byte of the flags.\n * @returns {EndorsementInformation}\n * @throws Will throw an error if the method is not implemented.\n */\n endorsementInformation(): EndorsementInformation {\n throw new Error(\"Not implemented\");\n }\n\n /**\n * Retrieves the words information based on the secure element flags, which is the third byte of the flags.\n * @returns {WordsInformation}\n * @throws Will throw an error if the method is not implemented.\n */\n wordsInformation(): WordsInformation {\n throw new Error(\"Not implemented\");\n }\n\n /**\n * Retrieves the onboarding status based on the secure element flags, which is the fourth byte of the flags.\n * @returns {OnboardingStatus}\n * @throws Will throw an error if the method is not implemented.\n */\n onboardingStatus(): OnboardingStatus {\n throw new Error(\"Not implemented\");\n }\n\n /**\n * Check the nth bit in a byte, returns true if the bit is set, false otherwise.\n * @param byte - The byte to check.\n * @param n - The bit number to check.\n * @returns {boolean} - True if the bit is set, false otherwise.\n */\n _checkNthBitInByte(byte: number, n: number): boolean {\n return ((byte >> (8 - n)) & 1) === 1;\n }\n}\n"],
5
- "mappings": "AAUO,MAAMA,CAAyB,CAKpC,YAA6BC,EAAqB,CAArB,aAAAA,EAC3B,GAAI,KAAK,QAAQ,SAAW,EAC1B,MAAM,IAAI,MAAM,qCAAqC,CAEzD,CAMA,oBAAyC,CACvC,MAAMC,EAAY,KAAK,QAAQ,CAAC,GAAK,EAErC,MAAO,CACL,eAAgB,KAAK,mBAAmBA,EAAW,CAAC,EACpD,mBAAoB,KAAK,mBAAmBA,EAAW,CAAC,EACxD,oBAAqB,KAAK,mBAAmBA,EAAW,CAAC,EACzD,mCAAoC,KAAK,mBAAmBA,EAAW,CAAC,EACxE,0BAA2B,KAAK,mBAAmBA,EAAW,CAAC,EAC/D,YAAa,KAAK,mBAAmBA,EAAW,CAAC,EACjD,gBAAiB,KAAK,mBAAmBA,EAAW,CAAC,EACrD,iBAAkB,KAAK,mBAAmBA,EAAW,CAAC,CACxD,CACF,CAOA,wBAAiD,CAC/C,MAAM,IAAI,MAAM,iBAAiB,CACnC,CAOA,kBAAqC,CACnC,MAAM,IAAI,MAAM,iBAAiB,CACnC,CAOA,kBAAqC,CACnC,MAAM,IAAI,MAAM,iBAAiB,CACnC,CAQA,mBAAmBC,EAAcC,EAAoB,CACnD,OAASD,GAAS,EAAIC,EAAM,KAAO,CACrC,CACF",
6
- "names": ["SecureElementFlagsParser", "seFlags", "firstByte", "byte", "n"]
4
+ "sourcesContent": ["import {\n type DeviceGeneralState,\n type EndorsementInformation,\n OnboardingState,\n type OnboardingStatus,\n SeedWordCount,\n type WordsInformation,\n} from \"@api/device/SecureElementFlags\";\n\nconst ONBOARDING_STATE_BY_VALUE: Readonly<Record<number, OnboardingState>> = {\n 0x00: OnboardingState.WelcomeScreen1,\n 0x01: OnboardingState.WelcomeScreen2,\n 0x02: OnboardingState.WelcomeScreen3,\n 0x03: OnboardingState.WelcomeScreen4,\n 0x04: OnboardingState.WelcomeScreenReminder,\n 0x05: OnboardingState.SetupChoice,\n 0x06: OnboardingState.Pin,\n 0x07: OnboardingState.NewDevice,\n 0x08: OnboardingState.ConfirmNewDevice,\n 0x09: OnboardingState.RestoreRecoveryPhrase,\n 0x0a: OnboardingState.SafetyWarning,\n 0x0b: OnboardingState.DeviceIsReady,\n 0x0c: OnboardingState.ChooseName,\n 0x0d: OnboardingState.RestoreRecoverBackup,\n 0x0e: OnboardingState.SetupRestoreChoice,\n 0x0f: OnboardingState.OnboardingStatusCheck,\n 0x10: OnboardingState.RestoreWithRk,\n};\n\n/**\n * Secure element flags parser class.\n */\nexport class SecureElementFlagsParser {\n private readonly seFlags: Uint8Array;\n\n /**\n * Creates an instance of SecureElementFlags parser.\n * @param seFlags - The secure element flags as an Uint8Array, it comes from the response of the GetOsVersionCommand.\n */\n constructor(seFlags: Uint8Array) {\n this.seFlags = new Uint8Array(4);\n this.seFlags.set(seFlags.subarray(0, this.seFlags.length));\n }\n\n /**\n * Retrieves the general device state based on the secure element flags, which is the first byte of the flags.\n * @returns {DeviceGeneralState}\n */\n generalDeviceState(): DeviceGeneralState {\n const firstByte = this.seFlags[0] ?? 0x00;\n\n return {\n isPinValidated: this._checkNthBitInByte(firstByte, 1),\n hasMcuSerialNumber: this._checkNthBitInByte(firstByte, 2),\n hasValidCertificate: this._checkNthBitInByte(firstByte, 3),\n isCustomAuthorityConnectionAllowed: this._checkNthBitInByte(firstByte, 4),\n isSecureConnectionAllowed: this._checkNthBitInByte(firstByte, 5),\n isOnboarded: this._checkNthBitInByte(firstByte, 6),\n isMcuCodeSigned: this._checkNthBitInByte(firstByte, 7),\n isInRecoveryMode: this._checkNthBitInByte(firstByte, 8),\n };\n }\n\n /**\n * Retrieves the endorsement information based on the secure element flags, which is the second byte of the flags.\n * @returns {EndorsementInformation}\n */\n endorsementInformation(): EndorsementInformation {\n const secondByte = this.seFlags[1] ?? 0x00;\n\n return {\n hasEndorsementCertificateInSlot1: (secondByte & 0x01) !== 0,\n hasEndorsementCertificateInSlot2: (secondByte & 0x02) !== 0,\n };\n }\n\n /**\n * Retrieves the words information based on the secure element flags, which is the third byte of the flags.\n * @returns {WordsInformation}\n */\n wordsInformation(): WordsInformation {\n const thirdByte = this.seFlags[2] ?? 0x00;\n const wordCountValue = (thirdByte >> 5) & 0x03;\n const wordCounts: ReadonlyArray<SeedWordCount | undefined> = [\n SeedWordCount.TwentyFour,\n SeedWordCount.Eighteen,\n SeedWordCount.Twelve,\n undefined,\n ];\n\n return {\n numberOfWords: wordCounts[wordCountValue],\n currentWordIndex: thirdByte & 0x1f,\n };\n }\n\n /**\n * Retrieves the onboarding status based on the secure element flags, which is the fourth byte of the flags.\n * @returns {OnboardingStatus}\n */\n onboardingStatus(): OnboardingStatus {\n const value = this.seFlags[3] ?? 0x00;\n\n return {\n onboardingState:\n ONBOARDING_STATE_BY_VALUE[value] ?? OnboardingState.Unknown,\n };\n }\n\n /**\n * Check the nth bit in a byte, returns true if the bit is set, false otherwise.\n * @param byte - The byte to check.\n * @param n - The bit number to check.\n * @returns {boolean} - True if the bit is set, false otherwise.\n */\n _checkNthBitInByte(byte: number, n: number): boolean {\n return ((byte >> (8 - n)) & 1) === 1;\n }\n}\n"],
5
+ "mappings": "AAAA,OAGE,mBAAAA,EAEA,iBAAAC,MAEK,iCAEP,MAAMC,EAAuE,CAC3E,EAAMF,EAAgB,eACtB,EAAMA,EAAgB,eACtB,EAAMA,EAAgB,eACtB,EAAMA,EAAgB,eACtB,EAAMA,EAAgB,sBACtB,EAAMA,EAAgB,YACtB,EAAMA,EAAgB,IACtB,EAAMA,EAAgB,UACtB,EAAMA,EAAgB,iBACtB,EAAMA,EAAgB,sBACtB,GAAMA,EAAgB,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,EAAI,EAAM,KAAO,CACrC,CACF",
6
+ "names": ["OnboardingState", "SeedWordCount", "ONBOARDING_STATE_BY_VALUE", "SecureElementFlagsParser", "seFlags", "firstByte", "secondByte", "thirdByte", "wordCountValue", "value", "byte"]
7
7
  }
@@ -1,2 +1,2 @@
1
- import{describe as a,expect as t,it as n}from"vitest";import{SecureElementFlagsParser as s}from"./SecureElementFlagsParser";a("SecureElementFlagsParser",()=>{n("should throw an error if the secure element flags length is not 4",()=>{t(()=>new s(new Uint8Array([0,1,2]))).toThrow("Invalid secure element flags length")}),n("should correctly parse the general device state",()=>{const o=new Uint8Array([170,0,0,0]),e=new s(o),r={isPinValidated:!0,hasMcuSerialNumber:!1,hasValidCertificate:!0,isCustomAuthorityConnectionAllowed:!1,isSecureConnectionAllowed:!0,isOnboarded:!1,isMcuCodeSigned:!0,isInRecoveryMode:!1};t(e.generalDeviceState()).toEqual(r)}),n("should throw an error for endorsementInformation method",()=>{const o=new Uint8Array([0,0,0,0]),e=new s(o);t(()=>e.endorsementInformation()).toThrow("Not implemented")}),n("should throw an error for wordsInformation method",()=>{const o=new Uint8Array([0,0,0,0]),e=new s(o);t(()=>e.wordsInformation()).toThrow("Not implemented")}),n("should throw an error for onboardingStatus method",()=>{const o=new Uint8Array([0,0,0,0]),e=new s(o);t(()=>e.onboardingStatus()).toThrow("Not implemented")}),n("should correctly check the nth bit in a byte",()=>{const o=new Uint8Array([0,0,0,0]),e=new s(o),r=170;t(e._checkNthBitInByte(r,1)).toBe(!0),t(e._checkNthBitInByte(r,2)).toBe(!1),t(e._checkNthBitInByte(r,3)).toBe(!0),t(e._checkNthBitInByte(r,4)).toBe(!1),t(e._checkNthBitInByte(r,5)).toBe(!0),t(e._checkNthBitInByte(r,6)).toBe(!1),t(e._checkNthBitInByte(r,7)).toBe(!0),t(e._checkNthBitInByte(r,8)).toBe(!1)})});
1
+ import{describe as d,expect as n,it as a}from"vitest";import{OnboardingState as t,SeedWordCount as i}from"../../device/SecureElementFlags";import{SecureElementFlagsParser as s}from"./SecureElementFlagsParser";d("SecureElementFlagsParser",()=>{a("should default missing secure element flag bytes to zero",()=>{const o=new s(new Uint8Array([224]));n(o.generalDeviceState().isPinValidated).toBe(!0),n(o.endorsementInformation()).toEqual({hasEndorsementCertificateInSlot1:!1,hasEndorsementCertificateInSlot2:!1}),n(o.wordsInformation()).toEqual({numberOfWords:i.TwentyFour,currentWordIndex:0}),n(o.onboardingStatus()).toEqual({onboardingState:t.WelcomeScreen1})}),a("should correctly parse the general device state",()=>{const o=new Uint8Array([170,0,0,0]),e=new s(o),r={isPinValidated:!0,hasMcuSerialNumber:!1,hasValidCertificate:!0,isCustomAuthorityConnectionAllowed:!1,isSecureConnectionAllowed:!0,isOnboarded:!1,isMcuCodeSigned:!0,isInRecoveryMode:!1};n(e.generalDeviceState()).toEqual(r)}),a.each([[0,!1,!1],[1,!0,!1],[2,!1,!0],[3,!0,!0]])("should parse endorsement information value %#",(o,e,r)=>{const c=new s(new Uint8Array([0,o,0,0]));n(c.endorsementInformation()).toEqual({hasEndorsementCertificateInSlot1:e,hasEndorsementCertificateInSlot2:r})}),a.each([[0,i.TwentyFour,0],[37,i.Eighteen,5],[81,i.Twelve,17],[127,void 0,31]])("should parse words information value %#",(o,e,r)=>{const c=new s(new Uint8Array([0,0,o,0]));n(c.wordsInformation()).toEqual({numberOfWords:e,currentWordIndex:r})}),a("should ignore the reserved most-significant bit in words information",()=>{const o=new s(new Uint8Array([0,0,165,0]));n(o.wordsInformation()).toEqual({numberOfWords:i.Eighteen,currentWordIndex:5})}),a("should expose numeric seed word counts so they survive serialization",()=>{const e=new s(new Uint8Array([0,0,0,0])).wordsInformation();n(e.numberOfWords).toBe(i.TwentyFour),n(JSON.parse(JSON.stringify(e))).toEqual({numberOfWords:i.TwentyFour,currentWordIndex:0})}),a("should keep SeedWordCount as 12 | 18 | 24, not an open numeric enum",()=>{const o=i.Twelve;n(o).toBe(12),n(typeof 15).toBe("number")}),d("onboardingStatus",()=>{a.each([[0,t.WelcomeScreen1],[1,t.WelcomeScreen2],[2,t.WelcomeScreen3],[3,t.WelcomeScreen4],[4,t.WelcomeScreenReminder],[5,t.SetupChoice],[6,t.Pin],[7,t.NewDevice],[8,t.ConfirmNewDevice],[9,t.RestoreRecoveryPhrase],[10,t.SafetyWarning],[11,t.DeviceIsReady],[12,t.ChooseName],[13,t.RestoreRecoverBackup],[14,t.SetupRestoreChoice],[15,t.OnboardingStatusCheck],[16,t.RestoreWithRk],[17,t.Unknown],[67,t.Unknown],[255,t.Unknown]])("should parse byte 0x%s as %s",(o,e)=>{const r=new s(new Uint8Array([0,0,0,o]));n(r.onboardingStatus()).toEqual({onboardingState:e})}),a("should always expose a defined onboarding state so it survives serialization",()=>{const e=new s(new Uint8Array([0,0,0,17])).onboardingStatus();n(e.onboardingState).toBe(t.Unknown),n(JSON.parse(JSON.stringify(e))).toEqual({onboardingState:t.Unknown})}),a("should map every documented GET VERSION byte to a distinct OnboardingState",()=>{const e=Array.from({length:17},(r,c)=>c).map(r=>new s(new Uint8Array([0,0,0,r])).onboardingStatus().onboardingState);n(e).toEqual(Object.values(t).filter(r=>r!==t.Unknown))})}),a("should correctly check the nth bit in a byte",()=>{const o=new Uint8Array([0,0,0,0]),e=new s(o),r=170;n(e._checkNthBitInByte(r,1)).toBe(!0),n(e._checkNthBitInByte(r,2)).toBe(!1),n(e._checkNthBitInByte(r,3)).toBe(!0),n(e._checkNthBitInByte(r,4)).toBe(!1),n(e._checkNthBitInByte(r,5)).toBe(!0),n(e._checkNthBitInByte(r,6)).toBe(!1),n(e._checkNthBitInByte(r,7)).toBe(!0),n(e._checkNthBitInByte(r,8)).toBe(!1)})});
2
2
  //# sourceMappingURL=SecureElementFlagsParser.test.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../../../src/api/command/os/SecureElementFlagsParser.test.ts"],
4
- "sourcesContent": ["import { describe, expect, it } from \"vitest\";\n\nimport { type DeviceGeneralState } from \"@api/device/SecureElementFlags\";\n\nimport { SecureElementFlagsParser } from \"./SecureElementFlagsParser\";\n\ndescribe(\"SecureElementFlagsParser\", () => {\n it(\"should throw an error if the secure element flags length is not 4\", () => {\n expect(\n () => new SecureElementFlagsParser(new Uint8Array([0x00, 0x01, 0x02])),\n ).toThrow(\"Invalid secure element flags length\");\n });\n\n it(\"should correctly parse the general device state\", () => {\n const seFlags = new Uint8Array([0b10101010, 0x00, 0x00, 0x00]);\n const parser = new SecureElementFlagsParser(seFlags);\n const expectedState: DeviceGeneralState = {\n isPinValidated: true,\n hasMcuSerialNumber: false,\n hasValidCertificate: true,\n isCustomAuthorityConnectionAllowed: false,\n isSecureConnectionAllowed: true,\n isOnboarded: false,\n isMcuCodeSigned: true,\n isInRecoveryMode: false,\n };\n expect(parser.generalDeviceState()).toEqual(expectedState);\n });\n\n it(\"should throw an error for endorsementInformation method\", () => {\n const seFlags = new Uint8Array([0x00, 0x00, 0x00, 0x00]);\n const parser = new SecureElementFlagsParser(seFlags);\n expect(() => parser.endorsementInformation()).toThrow(\"Not implemented\");\n });\n\n it(\"should throw an error for wordsInformation method\", () => {\n const seFlags = new Uint8Array([0x00, 0x00, 0x00, 0x00]);\n const parser = new SecureElementFlagsParser(seFlags);\n expect(() => parser.wordsInformation()).toThrow(\"Not implemented\");\n });\n\n it(\"should throw an error for onboardingStatus method\", () => {\n const seFlags = new Uint8Array([0x00, 0x00, 0x00, 0x00]);\n const parser = new SecureElementFlagsParser(seFlags);\n expect(() => parser.onboardingStatus()).toThrow(\"Not implemented\");\n });\n\n it(\"should correctly check the nth bit in a byte\", () => {\n const seFlags = new Uint8Array([0x00, 0x00, 0x00, 0x00]);\n const parser = new SecureElementFlagsParser(seFlags);\n const byte = 0b10101010;\n expect(parser._checkNthBitInByte(byte, 1)).toBe(true);\n expect(parser._checkNthBitInByte(byte, 2)).toBe(false);\n expect(parser._checkNthBitInByte(byte, 3)).toBe(true);\n expect(parser._checkNthBitInByte(byte, 4)).toBe(false);\n expect(parser._checkNthBitInByte(byte, 5)).toBe(true);\n expect(parser._checkNthBitInByte(byte, 6)).toBe(false);\n expect(parser._checkNthBitInByte(byte, 7)).toBe(true);\n expect(parser._checkNthBitInByte(byte, 8)).toBe(false);\n });\n});\n"],
5
- "mappings": "AAAA,OAAS,YAAAA,EAAU,UAAAC,EAAQ,MAAAC,MAAU,SAIrC,OAAS,4BAAAC,MAAgC,6BAEzCH,EAAS,2BAA4B,IAAM,CACzCE,EAAG,oEAAqE,IAAM,CAC5ED,EACE,IAAM,IAAIE,EAAyB,IAAI,WAAW,CAAC,EAAM,EAAM,CAAI,CAAC,CAAC,CACvE,EAAE,QAAQ,qCAAqC,CACjD,CAAC,EAEDD,EAAG,kDAAmD,IAAM,CAC1D,MAAME,EAAU,IAAI,WAAW,CAAC,IAAY,EAAM,EAAM,CAAI,CAAC,EACvDC,EAAS,IAAIF,EAAyBC,CAAO,EAC7CE,EAAoC,CACxC,eAAgB,GAChB,mBAAoB,GACpB,oBAAqB,GACrB,mCAAoC,GACpC,0BAA2B,GAC3B,YAAa,GACb,gBAAiB,GACjB,iBAAkB,EACpB,EACAL,EAAOI,EAAO,mBAAmB,CAAC,EAAE,QAAQC,CAAa,CAC3D,CAAC,EAEDJ,EAAG,0DAA2D,IAAM,CAClE,MAAME,EAAU,IAAI,WAAW,CAAC,EAAM,EAAM,EAAM,CAAI,CAAC,EACjDC,EAAS,IAAIF,EAAyBC,CAAO,EACnDH,EAAO,IAAMI,EAAO,uBAAuB,CAAC,EAAE,QAAQ,iBAAiB,CACzE,CAAC,EAEDH,EAAG,oDAAqD,IAAM,CAC5D,MAAME,EAAU,IAAI,WAAW,CAAC,EAAM,EAAM,EAAM,CAAI,CAAC,EACjDC,EAAS,IAAIF,EAAyBC,CAAO,EACnDH,EAAO,IAAMI,EAAO,iBAAiB,CAAC,EAAE,QAAQ,iBAAiB,CACnE,CAAC,EAEDH,EAAG,oDAAqD,IAAM,CAC5D,MAAME,EAAU,IAAI,WAAW,CAAC,EAAM,EAAM,EAAM,CAAI,CAAC,EACjDC,EAAS,IAAIF,EAAyBC,CAAO,EACnDH,EAAO,IAAMI,EAAO,iBAAiB,CAAC,EAAE,QAAQ,iBAAiB,CACnE,CAAC,EAEDH,EAAG,+CAAgD,IAAM,CACvD,MAAME,EAAU,IAAI,WAAW,CAAC,EAAM,EAAM,EAAM,CAAI,CAAC,EACjDC,EAAS,IAAIF,EAAyBC,CAAO,EAC7CG,EAAO,IACbN,EAAOI,EAAO,mBAAmBE,EAAM,CAAC,CAAC,EAAE,KAAK,EAAI,EACpDN,EAAOI,EAAO,mBAAmBE,EAAM,CAAC,CAAC,EAAE,KAAK,EAAK,EACrDN,EAAOI,EAAO,mBAAmBE,EAAM,CAAC,CAAC,EAAE,KAAK,EAAI,EACpDN,EAAOI,EAAO,mBAAmBE,EAAM,CAAC,CAAC,EAAE,KAAK,EAAK,EACrDN,EAAOI,EAAO,mBAAmBE,EAAM,CAAC,CAAC,EAAE,KAAK,EAAI,EACpDN,EAAOI,EAAO,mBAAmBE,EAAM,CAAC,CAAC,EAAE,KAAK,EAAK,EACrDN,EAAOI,EAAO,mBAAmBE,EAAM,CAAC,CAAC,EAAE,KAAK,EAAI,EACpDN,EAAOI,EAAO,mBAAmBE,EAAM,CAAC,CAAC,EAAE,KAAK,EAAK,CACvD,CAAC,CACH,CAAC",
6
- "names": ["describe", "expect", "it", "SecureElementFlagsParser", "seFlags", "parser", "expectedState", "byte"]
4
+ "sourcesContent": ["import { describe, expect, it } from \"vitest\";\n\nimport {\n type DeviceGeneralState,\n OnboardingState,\n SeedWordCount,\n} from \"@api/device/SecureElementFlags\";\n\nimport { SecureElementFlagsParser } from \"./SecureElementFlagsParser\";\n\ndescribe(\"SecureElementFlagsParser\", () => {\n it(\"should default missing secure element flag bytes to zero\", () => {\n const parser = new SecureElementFlagsParser(new Uint8Array([0xe0]));\n\n expect(parser.generalDeviceState().isPinValidated).toBe(true);\n expect(parser.endorsementInformation()).toEqual({\n hasEndorsementCertificateInSlot1: false,\n hasEndorsementCertificateInSlot2: false,\n });\n expect(parser.wordsInformation()).toEqual({\n numberOfWords: SeedWordCount.TwentyFour,\n currentWordIndex: 0,\n });\n expect(parser.onboardingStatus()).toEqual({\n onboardingState: OnboardingState.WelcomeScreen1,\n });\n });\n\n it(\"should correctly parse the general device state\", () => {\n const seFlags = new Uint8Array([0b10101010, 0x00, 0x00, 0x00]);\n const parser = new SecureElementFlagsParser(seFlags);\n const expectedState: DeviceGeneralState = {\n isPinValidated: true,\n hasMcuSerialNumber: false,\n hasValidCertificate: true,\n isCustomAuthorityConnectionAllowed: false,\n isSecureConnectionAllowed: true,\n isOnboarded: false,\n isMcuCodeSigned: true,\n isInRecoveryMode: false,\n };\n expect(parser.generalDeviceState()).toEqual(expectedState);\n });\n\n it.each([\n [0x00, false, false],\n [0x01, true, false],\n [0x02, false, true],\n [0x03, true, true],\n ])(\n \"should parse endorsement information value %#\",\n (value, hasSlot1, hasSlot2) => {\n const parser = new SecureElementFlagsParser(\n new Uint8Array([0x00, value, 0x00, 0x00]),\n );\n\n expect(parser.endorsementInformation()).toEqual({\n hasEndorsementCertificateInSlot1: hasSlot1,\n hasEndorsementCertificateInSlot2: hasSlot2,\n });\n },\n );\n\n it.each([\n [0b00000000, SeedWordCount.TwentyFour, 0],\n [0b00100101, SeedWordCount.Eighteen, 5],\n [0b01010001, SeedWordCount.Twelve, 17],\n [0b01111111, undefined, 31],\n ])(\n \"should parse words information value %#\",\n (value, numberOfWords, currentWordIndex) => {\n const parser = new SecureElementFlagsParser(\n new Uint8Array([0x00, 0x00, value, 0x00]),\n );\n\n expect(parser.wordsInformation()).toEqual({\n numberOfWords,\n currentWordIndex,\n });\n },\n );\n\n it(\"should ignore the reserved most-significant bit in words information\", () => {\n const parser = new SecureElementFlagsParser(\n new Uint8Array([0x00, 0x00, 0b10100101, 0x00]),\n );\n\n expect(parser.wordsInformation()).toEqual({\n numberOfWords: SeedWordCount.Eighteen,\n currentWordIndex: 5,\n });\n });\n\n it(\"should expose numeric seed word counts so they survive serialization\", () => {\n const parser = new SecureElementFlagsParser(\n new Uint8Array([0x00, 0x00, 0x00, 0x00]),\n );\n\n const words = parser.wordsInformation();\n\n expect(words.numberOfWords).toBe(SeedWordCount.TwentyFour);\n expect(JSON.parse(JSON.stringify(words))).toEqual({\n numberOfWords: SeedWordCount.TwentyFour,\n currentWordIndex: 0,\n });\n });\n\n it(\"should keep SeedWordCount as 12 | 18 | 24, not an open numeric enum\", () => {\n const valid: SeedWordCount = SeedWordCount.Twelve;\n expect(valid).toBe(12);\n\n // @ts-expect-error arbitrary numbers are not valid seed word counts\n const invalid: SeedWordCount = 15;\n expect(typeof invalid).toBe(\"number\");\n });\n\n describe(\"onboardingStatus\", () => {\n it.each([\n [0x00, OnboardingState.WelcomeScreen1],\n [0x01, OnboardingState.WelcomeScreen2],\n [0x02, OnboardingState.WelcomeScreen3],\n [0x03, OnboardingState.WelcomeScreen4],\n [0x04, OnboardingState.WelcomeScreenReminder],\n [0x05, OnboardingState.SetupChoice],\n [0x06, OnboardingState.Pin],\n [0x07, OnboardingState.NewDevice],\n [0x08, OnboardingState.ConfirmNewDevice],\n [0x09, OnboardingState.RestoreRecoveryPhrase],\n [0x0a, OnboardingState.SafetyWarning],\n [0x0b, OnboardingState.DeviceIsReady],\n [0x0c, OnboardingState.ChooseName],\n [0x0d, OnboardingState.RestoreRecoverBackup],\n [0x0e, OnboardingState.SetupRestoreChoice],\n [0x0f, OnboardingState.OnboardingStatusCheck],\n [0x10, OnboardingState.RestoreWithRk],\n [0x11, OnboardingState.Unknown],\n [0x43, OnboardingState.Unknown],\n [0xff, OnboardingState.Unknown],\n ] as const)(\"should parse byte 0x%s as %s\", (value, onboardingState) => {\n const parser = new SecureElementFlagsParser(\n new Uint8Array([0x00, 0x00, 0x00, value]),\n );\n\n expect(parser.onboardingStatus()).toEqual({ onboardingState });\n });\n\n it(\"should always expose a defined onboarding state so it survives serialization\", () => {\n const parser = new SecureElementFlagsParser(\n new Uint8Array([0x00, 0x00, 0x00, 0x11]),\n );\n\n const status = parser.onboardingStatus();\n\n expect(status.onboardingState).toBe(OnboardingState.Unknown);\n expect(JSON.parse(JSON.stringify(status))).toEqual({\n onboardingState: OnboardingState.Unknown,\n });\n });\n\n it(\"should map every documented GET VERSION byte to a distinct OnboardingState\", () => {\n const documentedBytes = Array.from({ length: 0x11 }, (_, index) => index);\n const parsedStates = documentedBytes.map(\n (value) =>\n new SecureElementFlagsParser(\n new Uint8Array([0x00, 0x00, 0x00, value]),\n ).onboardingStatus().onboardingState,\n );\n\n expect(parsedStates).toEqual(\n Object.values(OnboardingState).filter(\n (state) => state !== OnboardingState.Unknown,\n ),\n );\n });\n });\n\n it(\"should correctly check the nth bit in a byte\", () => {\n const seFlags = new Uint8Array([0x00, 0x00, 0x00, 0x00]);\n const parser = new SecureElementFlagsParser(seFlags);\n const byte = 0b10101010;\n expect(parser._checkNthBitInByte(byte, 1)).toBe(true);\n expect(parser._checkNthBitInByte(byte, 2)).toBe(false);\n expect(parser._checkNthBitInByte(byte, 3)).toBe(true);\n expect(parser._checkNthBitInByte(byte, 4)).toBe(false);\n expect(parser._checkNthBitInByte(byte, 5)).toBe(true);\n expect(parser._checkNthBitInByte(byte, 6)).toBe(false);\n expect(parser._checkNthBitInByte(byte, 7)).toBe(true);\n expect(parser._checkNthBitInByte(byte, 8)).toBe(false);\n });\n});\n"],
5
+ "mappings": "AAAA,OAAS,YAAAA,EAAU,UAAAC,EAAQ,MAAAC,MAAU,SAErC,OAEE,mBAAAC,EACA,iBAAAC,MACK,iCAEP,OAAS,4BAAAC,MAAgC,6BAEzCL,EAAS,2BAA4B,IAAM,CACzCE,EAAG,2DAA4D,IAAM,CACnE,MAAMI,EAAS,IAAID,EAAyB,IAAI,WAAW,CAAC,GAAI,CAAC,CAAC,EAElEJ,EAAOK,EAAO,mBAAmB,EAAE,cAAc,EAAE,KAAK,EAAI,EAC5DL,EAAOK,EAAO,uBAAuB,CAAC,EA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EAAM,EAAM,EAAM,CAAI,CAAC,EACjDD,EAAS,IAAID,EAAyBE,CAAO,EAC7Ce,EAAO,IACbrB,EAAOK,EAAO,mBAAmBgB,EAAM,CAAC,CAAC,EAAE,KAAK,EAAI,EACpDrB,EAAOK,EAAO,mBAAmBgB,EAAM,CAAC,CAAC,EAAE,KAAK,EAAK,EACrDrB,EAAOK,EAAO,mBAAmBgB,EAAM,CAAC,CAAC,EAAE,KAAK,EAAI,EACpDrB,EAAOK,EAAO,mBAAmBgB,EAAM,CAAC,CAAC,EAAE,KAAK,EAAK,EACrDrB,EAAOK,EAAO,mBAAmBgB,EAAM,CAAC,CAAC,EAAE,KAAK,EAAI,EACpDrB,EAAOK,EAAO,mBAAmBgB,EAAM,CAAC,CAAC,EAAE,KAAK,EAAK,EACrDrB,EAAOK,EAAO,mBAAmBgB,EAAM,CAAC,CAAC,EAAE,KAAK,EAAI,EACpDrB,EAAOK,EAAO,mBAAmBgB,EAAM,CAAC,CAAC,EAAE,KAAK,EAAK,CACvD,CAAC,CACH,CAAC",
6
+ "names": ["describe", "expect", "it", "OnboardingState", "SeedWordCount", "SecureElementFlagsParser", "parser", "seFlags", "expectedState", "value", "hasSlot1", "hasSlot2", "numberOfWords", "currentWordIndex", "words", "valid", "onboardingState", "status", "parsedStates", "_", "index", "state", "byte"]
7
7
  }
@@ -1,2 +1,2 @@
1
- import{DeviceModelId as e}from"../../../device/DeviceModel";const o=(r=e.NANO_SP,s={})=>({[e.NANO_SP]:{isBootloader:!1,isOsu:!1,targetId:856686596,seTargetId:856686596,seVersion:"1.1.1",seFlags:new Uint8Array([230,0,0,0]),mcuTargetId:void 0,mcuSephVersion:"4.03",mcuBootloaderVersion:"3.12",hwVersion:"00",langId:0,recoverState:void 0,secureElementFlags:{isPinValidated:!0,hasMcuSerialNumber:!0,hasValidCertificate:!0,isCustomAuthorityConnectionAllowed:!1,isSecureConnectionAllowed:!1,isOnboarded:!0,isMcuCodeSigned:!0,isInRecoveryMode:!1},...s},[e.NANO_S]:{isBootloader:!1,isOsu:!1,targetId:858783748,seTargetId:858783748,seVersion:"1.1.1",seFlags:new Uint8Array([230,0,0,0]),mcuTargetId:void 0,mcuSephVersion:"6.4.0",mcuBootloaderVersion:"5.4.0",hwVersion:"00",langId:0,recoverState:void 0,secureElementFlags:{isPinValidated:!0,hasMcuSerialNumber:!0,hasValidCertificate:!0,isCustomAuthorityConnectionAllowed:!1,isSecureConnectionAllowed:!1,isOnboarded:!0,isMcuCodeSigned:!0,isInRecoveryMode:!1},...s},[e.NANO_X]:{isBootloader:!1,isOsu:!1,targetId:855638020,seTargetId:855638020,seVersion:"2.2.3",seFlags:new Uint8Array([230,0,0,0]),mcuTargetId:void 0,mcuSephVersion:"2.30",mcuBootloaderVersion:"1.16",hwVersion:"00",langId:0,recoverState:0,secureElementFlags:{isPinValidated:!0,hasMcuSerialNumber:!0,hasValidCertificate:!0,isCustomAuthorityConnectionAllowed:!1,isSecureConnectionAllowed:!1,isOnboarded:!0,isMcuCodeSigned:!0,isInRecoveryMode:!1},...s},[e.STAX]:{isBootloader:!1,isOsu:!1,targetId:857735172,seTargetId:857735172,seVersion:"1.3.0",seFlags:new Uint8Array([230,0,0,0]),mcuTargetId:void 0,mcuSephVersion:"5.24",mcuBootloaderVersion:"0.48",hwVersion:"00",langId:0,recoverState:void 0,secureElementFlags:{isPinValidated:!0,hasMcuSerialNumber:!0,hasValidCertificate:!0,isCustomAuthorityConnectionAllowed:!1,isSecureConnectionAllowed:!1,isOnboarded:!0,isMcuCodeSigned:!0,isInRecoveryMode:!1},...s},[e.FLEX]:{isBootloader:!1,isOsu:!1,targetId:858783748,seTargetId:858783748,seVersion:"1.1.1",seFlags:new Uint8Array([230,0,0,0]),mcuTargetId:void 0,mcuSephVersion:"6.4.0",mcuBootloaderVersion:"5.4.0",hwVersion:"00",langId:0,recoverState:0,secureElementFlags:{isPinValidated:!0,hasMcuSerialNumber:!0,hasValidCertificate:!0,isCustomAuthorityConnectionAllowed:!1,isSecureConnectionAllowed:!1,isOnboarded:!0,isMcuCodeSigned:!0,isInRecoveryMode:!1},...s},[e.APEX]:{isBootloader:!1,isOsu:!1,targetId:858783748,seTargetId:858783748,seVersion:"1.1.1",seFlags:new Uint8Array([230,0,0,0]),mcuTargetId:void 0,mcuSephVersion:"6.4.0",mcuBootloaderVersion:"5.4.0",hwVersion:"00",langId:0,recoverState:0,secureElementFlags:{isPinValidated:!0,hasMcuSerialNumber:!0,hasValidCertificate:!0,isCustomAuthorityConnectionAllowed:!1,isSecureConnectionAllowed:!1,isOnboarded:!0,isMcuCodeSigned:!0,isInRecoveryMode:!1}}})[r];export{o as getOsVersionCommandResponseMockBuilder};
1
+ import{DeviceModelId as e}from"../../../device/DeviceModel";import{OnboardingState as r,SeedWordCount as t}from"../../../device/SecureElementFlags";const i=(o=e.NANO_SP,n={})=>({[e.NANO_SP]:{isBootloader:!1,isOsu:!1,targetId:856686596,seTargetId:856686596,seVersion:"1.1.1",seFlags:new Uint8Array([230,0,0,0]),mcuTargetId:void 0,mcuSephVersion:"4.03",mcuBootloaderVersion:"3.12",hwVersion:"00",langId:0,recoverState:void 0,secureElementFlags:{isPinValidated:!0,hasMcuSerialNumber:!0,hasValidCertificate:!0,isCustomAuthorityConnectionAllowed:!1,isSecureConnectionAllowed:!1,isOnboarded:!0,isMcuCodeSigned:!0,isInRecoveryMode:!1,hasEndorsementCertificateInSlot1:!1,hasEndorsementCertificateInSlot2:!1,numberOfWords:t.TwentyFour,currentWordIndex:0,onboardingState:r.WelcomeScreen1},...n},[e.NANO_S]:{isBootloader:!1,isOsu:!1,targetId:858783748,seTargetId:858783748,seVersion:"1.1.1",seFlags:new Uint8Array([230,0,0,0]),mcuTargetId:void 0,mcuSephVersion:"6.4.0",mcuBootloaderVersion:"5.4.0",hwVersion:"00",langId:0,recoverState:void 0,secureElementFlags:{isPinValidated:!0,hasMcuSerialNumber:!0,hasValidCertificate:!0,isCustomAuthorityConnectionAllowed:!1,isSecureConnectionAllowed:!1,isOnboarded:!0,isMcuCodeSigned:!0,isInRecoveryMode:!1,hasEndorsementCertificateInSlot1:!1,hasEndorsementCertificateInSlot2:!1,numberOfWords:t.TwentyFour,currentWordIndex:0,onboardingState:r.WelcomeScreen1},...n},[e.NANO_X]:{isBootloader:!1,isOsu:!1,targetId:855638020,seTargetId:855638020,seVersion:"2.2.3",seFlags:new Uint8Array([230,0,0,0]),mcuTargetId:void 0,mcuSephVersion:"2.30",mcuBootloaderVersion:"1.16",hwVersion:"00",langId:0,recoverState:0,secureElementFlags:{isPinValidated:!0,hasMcuSerialNumber:!0,hasValidCertificate:!0,isCustomAuthorityConnectionAllowed:!1,isSecureConnectionAllowed:!1,isOnboarded:!0,isMcuCodeSigned:!0,isInRecoveryMode:!1,hasEndorsementCertificateInSlot1:!1,hasEndorsementCertificateInSlot2:!1,numberOfWords:t.TwentyFour,currentWordIndex:0,onboardingState:r.WelcomeScreen1},...n},[e.STAX]:{isBootloader:!1,isOsu:!1,targetId:857735172,seTargetId:857735172,seVersion:"1.3.0",seFlags:new Uint8Array([230,0,0,0]),mcuTargetId:void 0,mcuSephVersion:"5.24",mcuBootloaderVersion:"0.48",hwVersion:"00",langId:0,recoverState:void 0,secureElementFlags:{isPinValidated:!0,hasMcuSerialNumber:!0,hasValidCertificate:!0,isCustomAuthorityConnectionAllowed:!1,isSecureConnectionAllowed:!1,isOnboarded:!0,isMcuCodeSigned:!0,isInRecoveryMode:!1,hasEndorsementCertificateInSlot1:!1,hasEndorsementCertificateInSlot2:!1,numberOfWords:t.TwentyFour,currentWordIndex:0,onboardingState:r.WelcomeScreen1},...n},[e.FLEX]:{isBootloader:!1,isOsu:!1,targetId:858783748,seTargetId:858783748,seVersion:"1.1.1",seFlags:new Uint8Array([230,0,0,0]),mcuTargetId:void 0,mcuSephVersion:"6.4.0",mcuBootloaderVersion:"5.4.0",hwVersion:"00",langId:0,recoverState:0,secureElementFlags:{isPinValidated:!0,hasMcuSerialNumber:!0,hasValidCertificate:!0,isCustomAuthorityConnectionAllowed:!1,isSecureConnectionAllowed:!1,isOnboarded:!0,isMcuCodeSigned:!0,isInRecoveryMode:!1,hasEndorsementCertificateInSlot1:!1,hasEndorsementCertificateInSlot2:!1,numberOfWords:t.TwentyFour,currentWordIndex:0,onboardingState:r.WelcomeScreen1},...n},[e.APEX]:{isBootloader:!1,isOsu:!1,targetId:858783748,seTargetId:858783748,seVersion:"1.1.1",seFlags:new Uint8Array([230,0,0,0]),mcuTargetId:void 0,mcuSephVersion:"6.4.0",mcuBootloaderVersion:"5.4.0",hwVersion:"00",langId:0,recoverState:0,secureElementFlags:{isPinValidated:!0,hasMcuSerialNumber:!0,hasValidCertificate:!0,isCustomAuthorityConnectionAllowed:!1,isSecureConnectionAllowed:!1,isOnboarded:!0,isMcuCodeSigned:!0,isInRecoveryMode:!1,hasEndorsementCertificateInSlot1:!1,hasEndorsementCertificateInSlot2:!1,numberOfWords:t.TwentyFour,currentWordIndex:0,onboardingState:r.WelcomeScreen1}}})[o];export{i as getOsVersionCommandResponseMockBuilder};
2
2
  //# sourceMappingURL=GetOsVersionCommand.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../../../../src/api/command/os/__mocks__/GetOsVersionCommand.ts"],
4
- "sourcesContent": ["import { type GetOsVersionResponse } from \"@api/command/os/GetOsVersionCommand\";\nimport { DeviceModelId } from \"@api/device/DeviceModel\";\n\nexport const getOsVersionCommandResponseMockBuilder = (\n deviceModelId: DeviceModelId = DeviceModelId.NANO_SP,\n props: Partial<GetOsVersionResponse> = {},\n): GetOsVersionResponse =>\n ({\n [DeviceModelId.NANO_SP]: {\n isBootloader: false,\n isOsu: false,\n targetId: 856686596,\n seTargetId: 856686596,\n seVersion: \"1.1.1\",\n seFlags: new Uint8Array([0xe6, 0x00, 0x00, 0x00]),\n mcuTargetId: undefined,\n mcuSephVersion: \"4.03\",\n mcuBootloaderVersion: \"3.12\",\n hwVersion: \"00\",\n langId: 0,\n recoverState: undefined,\n secureElementFlags: {\n isPinValidated: true,\n hasMcuSerialNumber: true,\n hasValidCertificate: true,\n isCustomAuthorityConnectionAllowed: false,\n isSecureConnectionAllowed: false,\n isOnboarded: true,\n isMcuCodeSigned: true,\n isInRecoveryMode: false,\n },\n ...props,\n },\n [DeviceModelId.NANO_S]: {\n isBootloader: false,\n isOsu: false,\n targetId: 858783748,\n seTargetId: 858783748,\n seVersion: \"1.1.1\",\n seFlags: new Uint8Array([0xe6, 0x00, 0x00, 0x00]),\n mcuTargetId: undefined,\n mcuSephVersion: \"6.4.0\",\n mcuBootloaderVersion: \"5.4.0\",\n hwVersion: \"00\",\n langId: 0,\n recoverState: undefined,\n secureElementFlags: {\n isPinValidated: true,\n hasMcuSerialNumber: true,\n hasValidCertificate: true,\n isCustomAuthorityConnectionAllowed: false,\n isSecureConnectionAllowed: false,\n isOnboarded: true,\n isMcuCodeSigned: true,\n isInRecoveryMode: false,\n },\n ...props,\n },\n [DeviceModelId.NANO_X]: {\n isBootloader: false,\n isOsu: false,\n targetId: 855638020,\n seTargetId: 855638020,\n seVersion: \"2.2.3\",\n seFlags: new Uint8Array([0xe6, 0x00, 0x00, 0x00]),\n mcuTargetId: undefined,\n mcuSephVersion: \"2.30\",\n mcuBootloaderVersion: \"1.16\",\n hwVersion: \"00\",\n langId: 0,\n recoverState: 0,\n secureElementFlags: {\n isPinValidated: true,\n hasMcuSerialNumber: true,\n hasValidCertificate: true,\n isCustomAuthorityConnectionAllowed: false,\n isSecureConnectionAllowed: false,\n isOnboarded: true,\n isMcuCodeSigned: true,\n isInRecoveryMode: false,\n },\n ...props,\n },\n [DeviceModelId.STAX]: {\n isBootloader: false,\n isOsu: false,\n targetId: 857735172,\n seTargetId: 857735172,\n seVersion: \"1.3.0\",\n seFlags: new Uint8Array([0xe6, 0x00, 0x00, 0x00]),\n mcuTargetId: undefined,\n mcuSephVersion: \"5.24\",\n mcuBootloaderVersion: \"0.48\",\n hwVersion: \"00\",\n langId: 0,\n recoverState: undefined,\n secureElementFlags: {\n isPinValidated: true,\n hasMcuSerialNumber: true,\n hasValidCertificate: true,\n isCustomAuthorityConnectionAllowed: false,\n isSecureConnectionAllowed: false,\n isOnboarded: true,\n isMcuCodeSigned: true,\n isInRecoveryMode: false,\n },\n ...props,\n },\n [DeviceModelId.FLEX]: {\n isBootloader: false,\n isOsu: false,\n targetId: 858783748,\n seTargetId: 858783748,\n seVersion: \"1.1.1\",\n seFlags: new Uint8Array([0xe6, 0x00, 0x00, 0x00]),\n mcuTargetId: undefined,\n mcuSephVersion: \"6.4.0\",\n mcuBootloaderVersion: \"5.4.0\",\n hwVersion: \"00\",\n langId: 0,\n recoverState: 0,\n secureElementFlags: {\n isPinValidated: true,\n hasMcuSerialNumber: true,\n hasValidCertificate: true,\n isCustomAuthorityConnectionAllowed: false,\n isSecureConnectionAllowed: false,\n isOnboarded: true,\n isMcuCodeSigned: true,\n isInRecoveryMode: false,\n },\n ...props,\n },\n [DeviceModelId.APEX]: {\n isBootloader: false,\n isOsu: false,\n targetId: 858783748,\n seTargetId: 858783748,\n seVersion: \"1.1.1\",\n seFlags: new Uint8Array([0xe6, 0x00, 0x00, 0x00]),\n mcuTargetId: undefined,\n mcuSephVersion: \"6.4.0\",\n mcuBootloaderVersion: \"5.4.0\",\n hwVersion: \"00\",\n langId: 0,\n recoverState: 0,\n secureElementFlags: {\n isPinValidated: true,\n hasMcuSerialNumber: true,\n hasValidCertificate: true,\n isCustomAuthorityConnectionAllowed: false,\n isSecureConnectionAllowed: false,\n isOnboarded: true,\n isMcuCodeSigned: true,\n isInRecoveryMode: false,\n },\n },\n })[deviceModelId];\n"],
5
- "mappings": "AACA,OAAS,iBAAAA,MAAqB,0BAEvB,MAAMC,EAAyC,CACpDC,EAA+BF,EAAc,QAC7CG,EAAuC,CAAC,KAEvC,CACC,CAACH,EAAc,OAAO,EAAG,CACvB,aAAc,GACd,MAAO,GACP,SAAU,UACV,WAAY,UACZ,UAAW,QACX,QAAS,IAAI,WAAW,CAA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ChB,mBAAoB,GACpB,oBAAqB,GACrB,mCAAoC,GACpC,0BAA2B,GAC3B,YAAa,GACb,gBAAiB,GACjB,iBAAkB,EACpB,EACA,GAAGG,CACL,EACA,CAACH,EAAc,IAAI,EAAG,CACpB,aAAc,GACd,MAAO,GACP,SAAU,UACV,WAAY,UACZ,UAAW,QACX,QAAS,IAAI,WAAW,CAAC,IAAM,EAAM,EAAM,CAAI,CAAC,EAChD,YAAa,OACb,eAAgB,QAChB,qBAAsB,QACtB,UAAW,KACX,OAAQ,EACR,aAAc,EACd,mBAAoB,CAClB,eAAgB,GAChB,mBAAoB,GACpB,oBAAqB,GACrB,mCAAoC,GACpC,0BAA2B,GAC3B,YAAa,GACb,gBAAiB,GACjB,iBAAkB,EACpB,EACA,GAAGG,CACL,EACA,CAACH,EAAc,IAAI,EAAG,CACpB,aAAc,GACd,MAAO,GACP,SAAU,UACV,WAAY,UACZ,UAAW,QACX,QAAS,IAAI,WAAW,CAAC,IAAM,EAAM,EAAM,CAAI,CAAC,EAChD,YAAa,OACb,eAAgB,QAChB,qBAAsB,QACtB,UAAW,KACX,OAAQ,EACR,aAAc,EACd,mBAAoB,CAClB,eAAgB,GAChB,mBAAoB,GACpB,oBAAqB,GACrB,mCAAoC,GACpC,0BAA2B,GAC3B,YAAa,GACb,gBAAiB,GACjB,iBAAkB,EACpB,CACF,CACF,GAAGE,CAAa",
6
- "names": ["DeviceModelId", "getOsVersionCommandResponseMockBuilder", "deviceModelId", "props"]
4
+ "sourcesContent": ["import { type GetOsVersionResponse } from \"@api/command/os/GetOsVersionCommand\";\nimport { DeviceModelId } from \"@api/device/DeviceModel\";\nimport { OnboardingState, SeedWordCount } from \"@api/device/SecureElementFlags\";\n\nexport const getOsVersionCommandResponseMockBuilder = (\n deviceModelId: DeviceModelId = DeviceModelId.NANO_SP,\n props: Partial<GetOsVersionResponse> = {},\n): GetOsVersionResponse =>\n ({\n [DeviceModelId.NANO_SP]: {\n isBootloader: false,\n isOsu: false,\n targetId: 856686596,\n seTargetId: 856686596,\n seVersion: \"1.1.1\",\n seFlags: new Uint8Array([0xe6, 0x00, 0x00, 0x00]),\n mcuTargetId: undefined,\n mcuSephVersion: \"4.03\",\n mcuBootloaderVersion: \"3.12\",\n hwVersion: \"00\",\n langId: 0,\n recoverState: undefined,\n secureElementFlags: {\n isPinValidated: true,\n hasMcuSerialNumber: true,\n hasValidCertificate: true,\n isCustomAuthorityConnectionAllowed: false,\n isSecureConnectionAllowed: false,\n isOnboarded: true,\n isMcuCodeSigned: true,\n isInRecoveryMode: false,\n hasEndorsementCertificateInSlot1: false,\n hasEndorsementCertificateInSlot2: false,\n numberOfWords: SeedWordCount.TwentyFour,\n currentWordIndex: 0,\n onboardingState: OnboardingState.WelcomeScreen1,\n },\n ...props,\n },\n [DeviceModelId.NANO_S]: {\n isBootloader: false,\n isOsu: false,\n targetId: 858783748,\n seTargetId: 858783748,\n seVersion: \"1.1.1\",\n seFlags: new Uint8Array([0xe6, 0x00, 0x00, 0x00]),\n mcuTargetId: undefined,\n mcuSephVersion: \"6.4.0\",\n mcuBootloaderVersion: \"5.4.0\",\n hwVersion: \"00\",\n langId: 0,\n recoverState: undefined,\n secureElementFlags: {\n isPinValidated: true,\n hasMcuSerialNumber: true,\n hasValidCertificate: true,\n isCustomAuthorityConnectionAllowed: false,\n isSecureConnectionAllowed: false,\n isOnboarded: true,\n isMcuCodeSigned: true,\n isInRecoveryMode: false,\n hasEndorsementCertificateInSlot1: false,\n hasEndorsementCertificateInSlot2: false,\n numberOfWords: SeedWordCount.TwentyFour,\n currentWordIndex: 0,\n onboardingState: OnboardingState.WelcomeScreen1,\n },\n ...props,\n },\n [DeviceModelId.NANO_X]: {\n isBootloader: false,\n isOsu: false,\n targetId: 855638020,\n seTargetId: 855638020,\n seVersion: \"2.2.3\",\n seFlags: new Uint8Array([0xe6, 0x00, 0x00, 0x00]),\n mcuTargetId: undefined,\n mcuSephVersion: \"2.30\",\n mcuBootloaderVersion: \"1.16\",\n hwVersion: \"00\",\n langId: 0,\n recoverState: 0,\n secureElementFlags: {\n isPinValidated: true,\n hasMcuSerialNumber: true,\n hasValidCertificate: true,\n isCustomAuthorityConnectionAllowed: false,\n isSecureConnectionAllowed: false,\n isOnboarded: true,\n isMcuCodeSigned: true,\n isInRecoveryMode: false,\n hasEndorsementCertificateInSlot1: false,\n hasEndorsementCertificateInSlot2: false,\n numberOfWords: SeedWordCount.TwentyFour,\n currentWordIndex: 0,\n onboardingState: OnboardingState.WelcomeScreen1,\n },\n ...props,\n },\n [DeviceModelId.STAX]: {\n isBootloader: false,\n isOsu: false,\n targetId: 857735172,\n seTargetId: 857735172,\n seVersion: \"1.3.0\",\n seFlags: new Uint8Array([0xe6, 0x00, 0x00, 0x00]),\n mcuTargetId: undefined,\n mcuSephVersion: \"5.24\",\n mcuBootloaderVersion: \"0.48\",\n hwVersion: \"00\",\n langId: 0,\n recoverState: undefined,\n secureElementFlags: {\n isPinValidated: true,\n hasMcuSerialNumber: true,\n hasValidCertificate: true,\n isCustomAuthorityConnectionAllowed: false,\n isSecureConnectionAllowed: false,\n isOnboarded: true,\n isMcuCodeSigned: true,\n isInRecoveryMode: false,\n hasEndorsementCertificateInSlot1: false,\n hasEndorsementCertificateInSlot2: false,\n numberOfWords: SeedWordCount.TwentyFour,\n currentWordIndex: 0,\n onboardingState: OnboardingState.WelcomeScreen1,\n },\n ...props,\n },\n [DeviceModelId.FLEX]: {\n isBootloader: false,\n isOsu: false,\n targetId: 858783748,\n seTargetId: 858783748,\n seVersion: \"1.1.1\",\n seFlags: new Uint8Array([0xe6, 0x00, 0x00, 0x00]),\n mcuTargetId: undefined,\n mcuSephVersion: \"6.4.0\",\n mcuBootloaderVersion: \"5.4.0\",\n hwVersion: \"00\",\n langId: 0,\n recoverState: 0,\n secureElementFlags: {\n isPinValidated: true,\n hasMcuSerialNumber: true,\n hasValidCertificate: true,\n isCustomAuthorityConnectionAllowed: false,\n isSecureConnectionAllowed: false,\n isOnboarded: true,\n isMcuCodeSigned: true,\n isInRecoveryMode: false,\n hasEndorsementCertificateInSlot1: false,\n hasEndorsementCertificateInSlot2: false,\n numberOfWords: SeedWordCount.TwentyFour,\n currentWordIndex: 0,\n onboardingState: OnboardingState.WelcomeScreen1,\n },\n ...props,\n },\n [DeviceModelId.APEX]: {\n isBootloader: false,\n isOsu: false,\n targetId: 858783748,\n seTargetId: 858783748,\n seVersion: \"1.1.1\",\n seFlags: new Uint8Array([0xe6, 0x00, 0x00, 0x00]),\n mcuTargetId: undefined,\n mcuSephVersion: \"6.4.0\",\n mcuBootloaderVersion: \"5.4.0\",\n hwVersion: \"00\",\n langId: 0,\n recoverState: 0,\n secureElementFlags: {\n isPinValidated: true,\n hasMcuSerialNumber: true,\n hasValidCertificate: true,\n isCustomAuthorityConnectionAllowed: false,\n isSecureConnectionAllowed: false,\n isOnboarded: true,\n isMcuCodeSigned: true,\n isInRecoveryMode: false,\n hasEndorsementCertificateInSlot1: false,\n hasEndorsementCertificateInSlot2: false,\n numberOfWords: SeedWordCount.TwentyFour,\n currentWordIndex: 0,\n onboardingState: OnboardingState.WelcomeScreen1,\n },\n },\n })[deviceModelId];\n"],
5
+ "mappings": "AACA,OAAS,iBAAAA,MAAqB,0BAC9B,OAAS,mBAAAC,EAAiB,iBAAAC,MAAqB,iCAExC,MAAMC,EAAyC,CACpDC,EAA+BJ,EAAc,QAC7CK,EAAuC,CAAC,KAEvC,CACC,CAACL,EAAc,OAAO,EAAG,CACvB,aAAc,GACd,MAAO,GACP,SAAU,UACV,WAAY,UACZ,UAAW,QACX,QAAS,IAAI,WAAW,CAAC,IAAM,EAAM,EAAM,CAAI,CAAC,EAChD,YAAa,OACb,eAAgB,OAChB,qBAAsB,OACtB,UAAW,KACX,OAAQ,EACR,aAAc,OACd,mBAAoB,CAClB,eAAgB,GAChB,mBAAoB,GACpB,oBAAqB,GACrB,mCAAoC,GACpC,0BAA2B,GAC3B,YAAa,GACb,gBAAiB,GACjB,iBAAkB,GAClB,iCAAkC,GAClC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eAAgB,GAChB,mBAAoB,GACpB,oBAAqB,GACrB,mCAAoC,GACpC,0BAA2B,GAC3B,YAAa,GACb,gBAAiB,GACjB,iBAAkB,GAClB,iCAAkC,GAClC,iCAAkC,GAClC,cAAeE,EAAc,WAC7B,iBAAkB,EAClB,gBAAiBD,EAAgB,cACnC,EACA,GAAGI,CACL,EACA,CAACL,EAAc,IAAI,EAAG,CACpB,aAAc,GACd,MAAO,GACP,SAAU,UACV,WAAY,UACZ,UAAW,QACX,QAAS,IAAI,WAAW,CAAC,IAAM,EAAM,EAAM,CAAI,CAAC,EAChD,YAAa,OACb,eAAgB,QAChB,qBAAsB,QACtB,UAAW,KACX,OAAQ,EACR,aAAc,EACd,mBAAoB,CAClB,eAAgB,GAChB,mBAAoB,GACpB,oBAAqB,GACrB,mCAAoC,GACpC,0BAA2B,GAC3B,YAAa,GACb,gBAAiB,GACjB,iBAAkB,GAClB,iCAAkC,GAClC,iCAAkC,GAClC,cAAeE,EAAc,WAC7B,iBAAkB,EAClB,gBAAiBD,EAAgB,cACnC,EACA,GAAGI,CACL,EACA,CAACL,EAAc,IAAI,EAAG,CACpB,aAAc,GACd,MAAO,GACP,SAAU,UACV,WAAY,UACZ,UAAW,QACX,QAAS,IAAI,WAAW,CAAC,IAAM,EAAM,EAAM,CAAI,CAAC,EAChD,YAAa,OACb,eAAgB,QAChB,qBAAsB,QACtB,UAAW,KACX,OAAQ,EACR,aAAc,EACd,mBAAoB,CAClB,eAAgB,GAChB,mBAAoB,GACpB,oBAAqB,GACrB,mCAAoC,GACpC,0BAA2B,GAC3B,YAAa,GACb,gBAAiB,GACjB,iBAAkB,GAClB,iCAAkC,GAClC,iCAAkC,GAClC,cAAeE,EAAc,WAC7B,iBAAkB,EAClB,gBAAiBD,EAAgB,cACnC,CACF,CACF,GAAGG,CAAa",
6
+ "names": ["DeviceModelId", "OnboardingState", "SeedWordCount", "getOsVersionCommandResponseMockBuilder", "deviceModelId", "props"]
7
7
  }
@@ -1 +1,2 @@
1
+ const r={Twelve:12,Eighteen:18,TwentyFour:24};var o=(e=>(e.Unknown="unknown",e.WelcomeScreen1="welcome-screen-1",e.WelcomeScreen2="welcome-screen-2",e.WelcomeScreen3="welcome-screen-3",e.WelcomeScreen4="welcome-screen-4",e.WelcomeScreenReminder="welcome-screen-reminder",e.SetupChoice="setup-choice",e.Pin="pin",e.NewDevice="new-device",e.ConfirmNewDevice="confirm-new-device",e.RestoreRecoveryPhrase="restore-recovery-phrase",e.SafetyWarning="safety-warning",e.DeviceIsReady="device-is-ready",e.ChooseName="choose-name",e.RestoreRecoverBackup="restore-recover-backup",e.SetupRestoreChoice="setup-restore-choice",e.OnboardingStatusCheck="onboarding-status-check",e.RestoreWithRk="restore-with-rk",e))(o||{});export{o as OnboardingState,r as SeedWordCount};
1
2
  //# sourceMappingURL=SecureElementFlags.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
- "sources": [],
4
- "sourcesContent": [],
5
- "mappings": "",
6
- "names": []
3
+ "sources": ["../../../../../src/api/device/SecureElementFlags.ts"],
4
+ "sourcesContent": ["/**\n * Represents the general state of a device, the information comes from the first byte of the secure element flags.\n */\nexport type DeviceGeneralState = {\n /**\n * Indicates whether the device's PIN has been validated.\n */\n isPinValidated: boolean;\n\n /**\n * Indicates whether the device has a MCU serial number.\n */\n hasMcuSerialNumber: boolean;\n\n /**\n * Indicates whether the device has a personalized valid Ledger certificate.\n */\n hasValidCertificate: boolean;\n\n /**\n * Indicates whether the device is allowed to connect with a custom certificate authority.\n */\n isCustomAuthorityConnectionAllowed: boolean;\n\n /**\n * Indicates whether the device is allowed to commnunicate with secure connection.\n */\n isSecureConnectionAllowed: boolean;\n\n /**\n * Indicates whether the device has been onboarded.\n */\n isOnboarded: boolean;\n\n /**\n * Indicates whether the MCU code on the device is signed.\n */\n isMcuCodeSigned: boolean;\n\n /**\n * Indicates whether the device is in recovery mode.\n */\n isInRecoveryMode: boolean;\n};\n\n/**\n * Represents which endorsement certificate slots are populated.\n * This information comes from the second byte of the secure element flags.\n */\nexport type EndorsementInformation = {\n hasEndorsementCertificateInSlot1: boolean;\n hasEndorsementCertificateInSlot2: boolean;\n};\n\n/**\n * Number of seed words selected during onboarding.\n * Values follow GET VERSION byte 3 (bits 5\u20136): 24, 18, or 12.\n *\n * Defined as a const object rather than a numeric enum so the type stays\n * `12 | 18 | 24` and is not assignable from an arbitrary `number`.\n */\nexport const SeedWordCount = {\n Twelve: 12,\n Eighteen: 18,\n TwentyFour: 24,\n} as const;\n\nexport type SeedWordCount = (typeof SeedWordCount)[keyof typeof SeedWordCount];\n\n/**\n * Represents the seed phrase setup progress.\n * This information comes from the third byte of the secure element flags.\n */\nexport type WordsInformation = {\n /**\n * Number of seed words selected by the user.\n * `undefined` represents a reserved or unknown encoding.\n */\n numberOfWords: SeedWordCount | undefined;\n /**\n * Zero-based index of the word currently being entered or confirmed.\n */\n currentWordIndex: number;\n};\n\n/**\n * Onboarding screen encoded in the fourth secure element flag byte.\n * Values follow GET VERSION byte 4 (0x00 to 0x10).\n */\nexport enum OnboardingState {\n /**\n * An encoding not covered by the specification (any byte outside 0x00\u20130x10),\n * which future firmware versions may introduce.\n */\n Unknown = \"unknown\",\n WelcomeScreen1 = \"welcome-screen-1\",\n WelcomeScreen2 = \"welcome-screen-2\",\n WelcomeScreen3 = \"welcome-screen-3\",\n WelcomeScreen4 = \"welcome-screen-4\",\n WelcomeScreenReminder = \"welcome-screen-reminder\",\n SetupChoice = \"setup-choice\",\n Pin = \"pin\",\n NewDevice = \"new-device\",\n ConfirmNewDevice = \"confirm-new-device\",\n RestoreRecoveryPhrase = \"restore-recovery-phrase\",\n SafetyWarning = \"safety-warning\",\n DeviceIsReady = \"device-is-ready\",\n ChooseName = \"choose-name\",\n RestoreRecoverBackup = \"restore-recover-backup\",\n SetupRestoreChoice = \"setup-restore-choice\",\n OnboardingStatusCheck = \"onboarding-status-check\",\n RestoreWithRk = \"restore-with-rk\",\n}\n\n/**\n * Represents the current onboarding state.\n * This information comes from the fourth byte of the secure element flags.\n */\nexport type OnboardingStatus = {\n /**\n * Parsed onboarding state, `OnboardingState.Unknown` for unmapped bytes.\n */\n onboardingState: OnboardingState;\n};\n\n/**\n * Parsed secure element flags from a Get OS version response.\n */\nexport type SecureElementFlags = DeviceGeneralState &\n EndorsementInformation &\n WordsInformation &\n OnboardingStatus;\n"],
5
+ "mappings": "AA6DO,MAAMA,EAAgB,CAC3B,OAAQ,GACR,SAAU,GACV,WAAY,EACd,EAwBO,IAAKC,OAKVA,EAAA,QAAU,UACVA,EAAA,eAAiB,mBACjBA,EAAA,eAAiB,mBACjBA,EAAA,eAAiB,mBACjBA,EAAA,eAAiB,mBACjBA,EAAA,sBAAwB,0BACxBA,EAAA,YAAc,eACdA,EAAA,IAAM,MACNA,EAAA,UAAY,aACZA,EAAA,iBAAmB,qBACnBA,EAAA,sBAAwB,0BACxBA,EAAA,cAAgB,iBAChBA,EAAA,cAAgB,kBAChBA,EAAA,WAAa,cACbA,EAAA,qBAAuB,yBACvBA,EAAA,mBAAqB,uBACrBA,EAAA,sBAAwB,0BACxBA,EAAA,cAAgB,kBAtBNA,OAAA",
6
+ "names": ["SeedWordCount", "OnboardingState"]
7
7
  }
@@ -1,2 +1,2 @@
1
- import{Apdu as r}from"./apdu/model/Apdu";import{APDU_MAX_PAYLOAD as p,ApduBuilder as a}from"./apdu/utils/ApduBuilder";import{ApduParser as i}from"./apdu/utils/ApduParser";export*from"./apdu/utils/AppBuilderError";import{ByteArrayBuilder as c}from"./apdu/utils/ByteArrayBuilder";import{ByteArrayParser as f}from"./apdu/utils/ByteArrayParser";import{InvalidResponseFormatError as D,InvalidStatusWordError as x}from"./command/Errors";import{CommandResultFactory as l,CommandResultStatus as g,isSuccessCommandResult as y}from"./command/model/CommandResult";import{CloseAppCommand as v}from"./command/os/CloseAppCommand";import{DeleteLanguagePackCommand as L,DeleteLanguagePackCommandError as k}from"./command/os/DeleteLanguagePackCommand";import{GetAppAndVersionCommand as R}from"./command/os/GetAppAndVersionCommand";import{GetBackgroundImageSizeCommand as I,GetBackgroundImageSizeCommandError as T}from"./command/os/GetBackgroundImageSizeCommand";import{BatteryStatusType as h,GetBatteryStatusCommand as P}from"./command/os/GetBatteryStatusCommand";import{GetOsVersionCommand as O}from"./command/os/GetOsVersionCommand";import{ListAppsCommand as M}from"./command/os/ListAppsCommand";import{ListLanguagePackCommand as U,ListLanguagePackCommandError as W}from"./command/os/ListLanguagePackCommand";import{LoadCertificateCommand as _}from"./command/os/LoadCertificateCommand";import{OpenAppCommand as z}from"./command/os/OpenAppCommand";import{isCommandErrorCode as H}from"./command/utils/CommandErrors";import{CommandUtils as Q}from"./command/utils/CommandUtils";import{GLOBAL_ERRORS as Y,GlobalCommandError as j,GlobalCommandErrorHandler as J}from"./command/utils/GlobalCommandError";import{DeviceModel as $,DeviceModelId as ee,LEDGER_VENDOR_ID as oe}from"./device/DeviceModel";import{DeviceStatus as te}from"./device/DeviceStatus";import{DeviceActionStatus as ae}from"./device-action/model/DeviceActionState";import{UserInteractionRequired as ie}from"./device-action/model/UserInteractionRequired";import{CallTaskInAppDeviceAction as se}from"./device-action/os/CallTaskInAppDeviceAction/CallTaskInAppDeviceAction";import{DEFAULT_UNLOCK_TIMEOUT_MS as de}from"./device-action/os/Const";import{AppAlreadyInstalledDAError as Ae,DeleteLanguagePackDAError as De,DeviceLockedError as xe,DeviceNotOnboardedError as ue,OutOfMemoryDAError as le,RefusedByUserDAError as ge,UnknownDAError as ye,UnsupportedFirmwareDAError as Ce}from"./device-action/os/Errors";import{GetDeviceMetadataDeviceAction as Se}from"./device-action/os/GetDeviceMetadata/GetDeviceMetadataDeviceAction";import{GetDeviceStatusDeviceAction as ke}from"./device-action/os/GetDeviceStatus/GetDeviceStatusDeviceAction";import{GoToDashboardDeviceAction as Re}from"./device-action/os/GoToDashboard/GoToDashboardDeviceAction";import{InstallLanguagePackageDeviceAction as Ie}from"./device-action/os/InstallLanguagePackage/InstallLanguagePackageDeviceAction";import{InstallOrUpdateAppsDeviceAction as Be}from"./device-action/os/InstallOrUpdateApps/InstallOrUpdateAppsDeviceAction";import{ListAppsDeviceAction as Pe}from"./device-action/os/ListApps/ListAppsDeviceAction";import{ListAppsWithMetadataDeviceAction as Oe}from"./device-action/os/ListAppsWithMetadata/ListAppsWithMetadataDeviceAction";import{OpenAppDeviceAction as Me}from"./device-action/os/OpenAppDeviceAction/OpenAppDeviceAction";import{OpenAppWithDependenciesDeviceAction as Ue}from"./device-action/os/OpenAppWithDependencies/OpenAppWithDependenciesDeviceAction";import{SendCommandInAppDeviceAction as Ne}from"./device-action/os/SendCommandInAppDeviceAction/SendCommandInAppDeviceAction";import{WaitForAppAndVersionDeviceAction as we}from"./device-action/os/WaitForAppAndVersion/WaitForAppAndVersionDeviceAction";import{GetApplicationsMetadataTaskError as qe,InvalidGetFirmwareMetadataResponseError as He}from"./device-action/task/Errors";import{XStateDeviceAction as Qe}from"./device-action/xstate-utils/XStateDeviceAction";import{StaticDeviceModelDataSource as Ye}from"./device-model/data/StaticDeviceModelDataSource";import{BleDeviceInfos as Je}from"./device-model/model/BleDeviceInfos";import{TransportDeviceModel as $e}from"./device-model/model/DeviceModel";import{ApduResponse as oo}from"./device-session/ApduResponse";export*from"./device-session/data/FramerConst";import{DeviceSessionStateType as po}from"./device-session/DeviceSessionState";import{DmkResultFactory as no,DmkResultStatus as io,isSuccessDmkResult as mo}from"./model/DmkResult";import{GenuineCheckDeviceAction as co}from"./secure-channel/device-action/GenuineCheck/GenuineCheckDeviceAction";import{InstallAppDeviceAction as Ao}from"./secure-channel/device-action/InstallApp/InstallAppDeviceAction";import{ListInstalledAppsDeviceAction as xo}from"./secure-channel/device-action/ListInstalledApps/ListInstalledAppsDeviceAction";import{UninstallAppDeviceAction as lo}from"./secure-channel/device-action/UninstallApp/UninstallAppDeviceAction";import{ConnectToSecureChannelTask as yo}from"./secure-channel/task/ConnectToSecureChannelTask";import{SecureChannelEventType as vo}from"./secure-channel/task/types";import{SecureChannelError as Lo}from"../internal/secure-channel/model/Errors";import{defaultApduReceiverServiceStubBuilder as Eo}from"./device-session/service/DefaultApduReceiverService.stub";import{defaultApduSenderServiceStubBuilder as Go}from"./device-session/service/DefaultApduSenderService.stub";import{FramerUtils as To}from"./device-session/utils/FramerUtils";import{DeviceManagementKit as ho}from"./DeviceManagementKit";import{DeviceManagementKitBuilder as bo}from"./DeviceManagementKitBuilder";export*from"./Error";import{noopLogger as Mo,noopLoggerFactory as Vo}from"./logger-publisher/utils/noopLoggerFactory";import{LogLevel as Wo}from"./logger-subscriber/model/LogLevel";import{ConsoleLogger as _o}from"./logger-subscriber/service/ConsoleLogger";import{DefaultLogTagFormatter as zo}from"./logger-subscriber/service/DefaultLogTagFormatter";import{WebLogsExporterLogger as Ho}from"./logger-subscriber/service/WebLogsExporterLogger";import{DmkNetworkClient as Qo}from"./network/DmkNetworkClient";import{DmkNetworkClientError as Yo}from"./network/DmkNetworkClientError";import{ConnectedDevice as Jo}from"./transport/model/ConnectedDevice";import{DeviceConnectionStateMachine as $o}from"./transport/model/DeviceConnectionStateMachine";export*from"./transport/model/Errors";import{TransportConnectedDevice as rr}from"./transport/model/TransportConnectedDevice";import{connectedDeviceStubBuilder as pr}from"./transport/model/TransportConnectedDevice.stub";export*from"./types";import{formatApduReceivedLog as ir,formatApduSentLog as mr}from"./utils/apduLogs";import{ApplicationChecker as cr}from"./utils/ApplicationChecker";import{isDashboardName as fr}from"./utils/AppName";import{base64StringToBuffer as Dr,bufferToBase64String as xr,isBase64String as ur}from"./utils/Base64String";import{bufferToHexaString as gr,hexaStringToBuffer as yr,isHexaString as Cr}from"./utils/HexaString";export{p as APDU_MAX_PAYLOAD,r as Apdu,a as ApduBuilder,i as ApduParser,oo as ApduResponse,Ae as AppAlreadyInstalledDAError,cr as ApplicationChecker,h as BatteryStatusType,Je as BleDeviceInfos,c as ByteArrayBuilder,f as ByteArrayParser,se as CallTaskInAppDeviceAction,v as CloseAppCommand,l as CommandResultFactory,g as CommandResultStatus,Q as CommandUtils,yo as ConnectToSecureChannelTask,Jo as ConnectedDevice,_o as ConsoleLogger,de as DEFAULT_UNLOCK_TIMEOUT_MS,zo as DefaultLogTagFormatter,L as DeleteLanguagePackCommand,k as DeleteLanguagePackCommandError,De as DeleteLanguagePackDAError,ae as DeviceActionStatus,$o as DeviceConnectionStateMachine,xe as DeviceLockedError,ho as DeviceManagementKit,bo as DeviceManagementKitBuilder,$ as DeviceModel,ee as DeviceModelId,ue as DeviceNotOnboardedError,po as DeviceSessionStateType,te as DeviceStatus,Qo as DmkNetworkClient,Yo as DmkNetworkClientError,no as DmkResultFactory,io as DmkResultStatus,To as FramerUtils,Y as GLOBAL_ERRORS,co as GenuineCheckDeviceAction,R as GetAppAndVersionCommand,qe as GetApplicationsMetadataTaskError,I as GetBackgroundImageSizeCommand,T as GetBackgroundImageSizeCommandError,P as GetBatteryStatusCommand,Se as GetDeviceMetadataDeviceAction,ke as GetDeviceStatusDeviceAction,O as GetOsVersionCommand,j as GlobalCommandError,J as GlobalCommandErrorHandler,Re as GoToDashboardDeviceAction,Ao as InstallAppDeviceAction,Ie as InstallLanguagePackageDeviceAction,Be as InstallOrUpdateAppsDeviceAction,He as InvalidGetFirmwareMetadataResponseError,D as InvalidResponseFormatError,x as InvalidStatusWordError,oe as LEDGER_VENDOR_ID,M as ListAppsCommand,Pe as ListAppsDeviceAction,Oe as ListAppsWithMetadataDeviceAction,xo as ListInstalledAppsDeviceAction,U as ListLanguagePackCommand,W as ListLanguagePackCommandError,_ as LoadCertificateCommand,Wo as LogLevel,z as OpenAppCommand,Me as OpenAppDeviceAction,Ue as OpenAppWithDependenciesDeviceAction,le as OutOfMemoryDAError,ge as RefusedByUserDAError,Lo as SecureChannelError,vo as SecureChannelEventType,Ne as SendCommandInAppDeviceAction,Ye as StaticDeviceModelDataSource,rr as TransportConnectedDevice,$e as TransportDeviceModel,lo as UninstallAppDeviceAction,ye as UnknownDAError,Ce as UnsupportedFirmwareDAError,ie as UserInteractionRequired,we as WaitForAppAndVersionDeviceAction,Ho as WebLogsExporterLogger,Qe as XStateDeviceAction,Dr as base64StringToBuffer,xr as bufferToBase64String,gr as bufferToHexaString,pr as connectedDeviceStubBuilder,Eo as defaultApduReceiverServiceStubBuilder,Go as defaultApduSenderServiceStubBuilder,ir as formatApduReceivedLog,mr as formatApduSentLog,yr as hexaStringToBuffer,ur as isBase64String,H as isCommandErrorCode,fr as isDashboardName,Cr as isHexaString,y as isSuccessCommandResult,mo as isSuccessDmkResult,Mo as noopLogger,Vo as noopLoggerFactory};
1
+ import{Apdu as r}from"./apdu/model/Apdu";import{APDU_MAX_PAYLOAD as p,ApduBuilder as a}from"./apdu/utils/ApduBuilder";import{ApduParser as i}from"./apdu/utils/ApduParser";export*from"./apdu/utils/AppBuilderError";import{ByteArrayBuilder as c}from"./apdu/utils/ByteArrayBuilder";import{ByteArrayParser as f}from"./apdu/utils/ByteArrayParser";import{InvalidResponseFormatError as D,InvalidStatusWordError as u}from"./command/Errors";import{CommandResultFactory as l,CommandResultStatus as g,isSuccessCommandResult as y}from"./command/model/CommandResult";import{CloseAppCommand as v}from"./command/os/CloseAppCommand";import{DeleteLanguagePackCommand as L,DeleteLanguagePackCommandError as k}from"./command/os/DeleteLanguagePackCommand";import{GetAppAndVersionCommand as R}from"./command/os/GetAppAndVersionCommand";import{GetBackgroundImageSizeCommand as I,GetBackgroundImageSizeCommandError as T}from"./command/os/GetBackgroundImageSizeCommand";import{BatteryStatusType as O,GetBatteryStatusCommand as b}from"./command/os/GetBatteryStatusCommand";import{GetOsVersionCommand as P}from"./command/os/GetOsVersionCommand";import{ListAppsCommand as M}from"./command/os/ListAppsCommand";import{ListLanguagePackCommand as W,ListLanguagePackCommandError as U}from"./command/os/ListLanguagePackCommand";import{LoadCertificateCommand as _}from"./command/os/LoadCertificateCommand";import{OpenAppCommand as z}from"./command/os/OpenAppCommand";import{isCommandErrorCode as H}from"./command/utils/CommandErrors";import{CommandUtils as Q}from"./command/utils/CommandUtils";import{GLOBAL_ERRORS as Y,GlobalCommandError as j,GlobalCommandErrorHandler as J}from"./command/utils/GlobalCommandError";import{DeviceModel as $,DeviceModelId as ee,LEDGER_VENDOR_ID as oe}from"./device/DeviceModel";import{DeviceStatus as te}from"./device/DeviceStatus";import{OnboardingState as ae,SeedWordCount as ne}from"./device/SecureElementFlags";import{DeviceActionStatus as me}from"./device-action/model/DeviceActionState";import{UserInteractionRequired as ce}from"./device-action/model/UserInteractionRequired";import{CallTaskInAppDeviceAction as fe}from"./device-action/os/CallTaskInAppDeviceAction/CallTaskInAppDeviceAction";import{DEFAULT_UNLOCK_TIMEOUT_MS as De}from"./device-action/os/Const";import{AppAlreadyInstalledDAError as xe,DeleteLanguagePackDAError as le,DeviceLockedError as ge,DeviceNotOnboardedError as ye,OutOfMemoryDAError as Ce,RefusedByUserDAError as ve,UnknownDAError as Se,UnsupportedFirmwareDAError as Le}from"./device-action/os/Errors";import{GetDeviceMetadataDeviceAction as Ee}from"./device-action/os/GetDeviceMetadata/GetDeviceMetadataDeviceAction";import{GetDeviceStatusDeviceAction as Ge}from"./device-action/os/GetDeviceStatus/GetDeviceStatusDeviceAction";import{GoToDashboardDeviceAction as Te}from"./device-action/os/GoToDashboard/GoToDashboardDeviceAction";import{InstallLanguagePackageDeviceAction as Oe}from"./device-action/os/InstallLanguagePackage/InstallLanguagePackageDeviceAction";import{InstallOrUpdateAppsDeviceAction as he}from"./device-action/os/InstallOrUpdateApps/InstallOrUpdateAppsDeviceAction";import{ListAppsDeviceAction as Fe}from"./device-action/os/ListApps/ListAppsDeviceAction";import{ListAppsWithMetadataDeviceAction as Ve}from"./device-action/os/ListAppsWithMetadata/ListAppsWithMetadataDeviceAction";import{OpenAppDeviceAction as Ue}from"./device-action/os/OpenAppDeviceAction/OpenAppDeviceAction";import{OpenAppWithDependenciesDeviceAction as _e}from"./device-action/os/OpenAppWithDependencies/OpenAppWithDependenciesDeviceAction";import{SendCommandInAppDeviceAction as ze}from"./device-action/os/SendCommandInAppDeviceAction/SendCommandInAppDeviceAction";import{WaitForAppAndVersionDeviceAction as He}from"./device-action/os/WaitForAppAndVersion/WaitForAppAndVersionDeviceAction";import{GetApplicationsMetadataTaskError as Qe,InvalidGetFirmwareMetadataResponseError as Xe}from"./device-action/task/Errors";import{XStateDeviceAction as je}from"./device-action/xstate-utils/XStateDeviceAction";import{StaticDeviceModelDataSource as Ze}from"./device-model/data/StaticDeviceModelDataSource";import{BleDeviceInfos as eo}from"./device-model/model/BleDeviceInfos";import{TransportDeviceModel as ro}from"./device-model/model/DeviceModel";import{ApduResponse as po}from"./device-session/ApduResponse";export*from"./device-session/data/FramerConst";import{DeviceSessionStateType as io}from"./device-session/DeviceSessionState";import{DmkResultFactory as so,DmkResultStatus as co,isSuccessDmkResult as fo}from"./model/DmkResult";import{GenuineCheckDeviceAction as Do}from"./secure-channel/device-action/GenuineCheck/GenuineCheckDeviceAction";import{InstallAppDeviceAction as xo}from"./secure-channel/device-action/InstallApp/InstallAppDeviceAction";import{ListInstalledAppsDeviceAction as go}from"./secure-channel/device-action/ListInstalledApps/ListInstalledAppsDeviceAction";import{UninstallAppDeviceAction as Co}from"./secure-channel/device-action/UninstallApp/UninstallAppDeviceAction";import{ConnectToSecureChannelTask as So}from"./secure-channel/task/ConnectToSecureChannelTask";import{SecureChannelEventType as ko}from"./secure-channel/task/types";import{SecureChannelError as Ro}from"../internal/secure-channel/model/Errors";import{defaultApduReceiverServiceStubBuilder as Io}from"./device-session/service/DefaultApduReceiverService.stub";import{defaultApduSenderServiceStubBuilder as Bo}from"./device-session/service/DefaultApduSenderService.stub";import{FramerUtils as bo}from"./device-session/utils/FramerUtils";import{DeviceManagementKit as Po}from"./DeviceManagementKit";import{DeviceManagementKitBuilder as Mo}from"./DeviceManagementKitBuilder";export*from"./Error";import{noopLogger as Uo,noopLoggerFactory as No}from"./logger-publisher/utils/noopLoggerFactory";import{LogLevel as wo}from"./logger-subscriber/model/LogLevel";import{ConsoleLogger as qo}from"./logger-subscriber/service/ConsoleLogger";import{DefaultLogTagFormatter as Ko}from"./logger-subscriber/service/DefaultLogTagFormatter";import{WebLogsExporterLogger as Xo}from"./logger-subscriber/service/WebLogsExporterLogger";import{DmkNetworkClient as jo}from"./network/DmkNetworkClient";import{DmkNetworkClientError as Zo}from"./network/DmkNetworkClientError";import{ConnectedDevice as er}from"./transport/model/ConnectedDevice";import{DeviceConnectionStateMachine as rr}from"./transport/model/DeviceConnectionStateMachine";export*from"./transport/model/Errors";import{TransportConnectedDevice as ar}from"./transport/model/TransportConnectedDevice";import{connectedDeviceStubBuilder as ir}from"./transport/model/TransportConnectedDevice.stub";export*from"./types";import{formatApduReceivedLog as cr,formatApduSentLog as dr}from"./utils/apduLogs";import{ApplicationChecker as Ar}from"./utils/ApplicationChecker";import{isDashboardName as ur}from"./utils/AppName";import{base64StringToBuffer as lr,bufferToBase64String as gr,isBase64String as yr}from"./utils/Base64String";import{bufferToHexaString as vr,hexaStringToBuffer as Sr,isHexaString as Lr}from"./utils/HexaString";export{p as APDU_MAX_PAYLOAD,r as Apdu,a as ApduBuilder,i as ApduParser,po as ApduResponse,xe as AppAlreadyInstalledDAError,Ar as ApplicationChecker,O as BatteryStatusType,eo as BleDeviceInfos,c as ByteArrayBuilder,f as ByteArrayParser,fe as CallTaskInAppDeviceAction,v as CloseAppCommand,l as CommandResultFactory,g as CommandResultStatus,Q as CommandUtils,So as ConnectToSecureChannelTask,er as ConnectedDevice,qo as ConsoleLogger,De as DEFAULT_UNLOCK_TIMEOUT_MS,Ko as DefaultLogTagFormatter,L as DeleteLanguagePackCommand,k as DeleteLanguagePackCommandError,le as DeleteLanguagePackDAError,me as DeviceActionStatus,rr as DeviceConnectionStateMachine,ge as DeviceLockedError,Po as DeviceManagementKit,Mo as DeviceManagementKitBuilder,$ as DeviceModel,ee as DeviceModelId,ye as DeviceNotOnboardedError,io as DeviceSessionStateType,te as DeviceStatus,jo as DmkNetworkClient,Zo as DmkNetworkClientError,so as DmkResultFactory,co as DmkResultStatus,bo as FramerUtils,Y as GLOBAL_ERRORS,Do as GenuineCheckDeviceAction,R as GetAppAndVersionCommand,Qe as GetApplicationsMetadataTaskError,I as GetBackgroundImageSizeCommand,T as GetBackgroundImageSizeCommandError,b as GetBatteryStatusCommand,Ee as GetDeviceMetadataDeviceAction,Ge as GetDeviceStatusDeviceAction,P as GetOsVersionCommand,j as GlobalCommandError,J as GlobalCommandErrorHandler,Te as GoToDashboardDeviceAction,xo as InstallAppDeviceAction,Oe as InstallLanguagePackageDeviceAction,he as InstallOrUpdateAppsDeviceAction,Xe as InvalidGetFirmwareMetadataResponseError,D as InvalidResponseFormatError,u as InvalidStatusWordError,oe as LEDGER_VENDOR_ID,M as ListAppsCommand,Fe as ListAppsDeviceAction,Ve as ListAppsWithMetadataDeviceAction,go as ListInstalledAppsDeviceAction,W as ListLanguagePackCommand,U as ListLanguagePackCommandError,_ as LoadCertificateCommand,wo as LogLevel,ae as OnboardingState,z as OpenAppCommand,Ue as OpenAppDeviceAction,_e as OpenAppWithDependenciesDeviceAction,Ce as OutOfMemoryDAError,ve as RefusedByUserDAError,Ro as SecureChannelError,ko as SecureChannelEventType,ne as SeedWordCount,ze as SendCommandInAppDeviceAction,Ze as StaticDeviceModelDataSource,ar as TransportConnectedDevice,ro as TransportDeviceModel,Co as UninstallAppDeviceAction,Se as UnknownDAError,Le as UnsupportedFirmwareDAError,ce as UserInteractionRequired,He as WaitForAppAndVersionDeviceAction,Xo as WebLogsExporterLogger,je as XStateDeviceAction,lr as base64StringToBuffer,gr as bufferToBase64String,vr as bufferToHexaString,ir as connectedDeviceStubBuilder,Io as defaultApduReceiverServiceStubBuilder,Bo as defaultApduSenderServiceStubBuilder,cr as formatApduReceivedLog,dr as formatApduSentLog,Sr as hexaStringToBuffer,yr as isBase64String,H as isCommandErrorCode,ur as isDashboardName,Lr as isHexaString,y as isSuccessCommandResult,fo as isSuccessDmkResult,Uo as noopLogger,No as noopLoggerFactory};
2
2
  //# sourceMappingURL=index.js.map