@ledgerhq/device-management-kit 0.0.0-test-recursive-stack-20251002122259 → 0.0.0-test-attest-npmjs-1-20251120163531

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 (236) hide show
  1. package/lib/cjs/package.json +1 -1
  2. package/lib/cjs/src/api/DeviceManagementKit.js +1 -1
  3. package/lib/cjs/src/api/DeviceManagementKit.js.map +2 -2
  4. package/lib/cjs/src/api/DeviceManagementKit.test.js +1 -1
  5. package/lib/cjs/src/api/DeviceManagementKit.test.js.map +2 -2
  6. package/lib/cjs/src/api/command/Command.js +1 -1
  7. package/lib/cjs/src/api/command/Command.js.map +1 -1
  8. package/lib/cjs/src/api/command/Errors.js +1 -1
  9. package/lib/cjs/src/api/command/Errors.js.map +3 -3
  10. package/lib/cjs/src/api/command/model/CommandResult.js +1 -1
  11. package/lib/cjs/src/api/command/model/CommandResult.js.map +2 -2
  12. package/lib/cjs/src/api/command/os/CloseAppCommand.js +1 -1
  13. package/lib/cjs/src/api/command/os/CloseAppCommand.js.map +2 -2
  14. package/lib/cjs/src/api/command/os/CloseAppCommand.test.js +1 -1
  15. package/lib/cjs/src/api/command/os/CloseAppCommand.test.js.map +2 -2
  16. package/lib/cjs/src/api/command/os/GetAppAndVersionCommand.js +1 -1
  17. package/lib/cjs/src/api/command/os/GetAppAndVersionCommand.js.map +2 -2
  18. package/lib/cjs/src/api/command/os/GetAppAndVersionCommand.test.js +1 -1
  19. package/lib/cjs/src/api/command/os/GetAppAndVersionCommand.test.js.map +2 -2
  20. package/lib/cjs/src/api/command/os/GetBatteryStatusCommand.js +1 -1
  21. package/lib/cjs/src/api/command/os/GetBatteryStatusCommand.js.map +2 -2
  22. package/lib/cjs/src/api/command/os/GetBatteryStatusCommand.test.js +1 -1
  23. package/lib/cjs/src/api/command/os/GetBatteryStatusCommand.test.js.map +3 -3
  24. package/lib/cjs/src/api/command/os/GetCustomImageSizeCommand.js +1 -1
  25. package/lib/cjs/src/api/command/os/GetCustomImageSizeCommand.js.map +2 -2
  26. package/lib/cjs/src/api/command/os/GetCustomImageSizeCommand.test.js +1 -1
  27. package/lib/cjs/src/api/command/os/GetCustomImageSizeCommand.test.js.map +2 -2
  28. package/lib/cjs/src/api/command/os/GetOsVersionCommand.js +1 -1
  29. package/lib/cjs/src/api/command/os/GetOsVersionCommand.js.map +2 -2
  30. package/lib/cjs/src/api/command/os/GetOsVersionCommand.test.js +1 -1
  31. package/lib/cjs/src/api/command/os/GetOsVersionCommand.test.js.map +2 -2
  32. package/lib/cjs/src/api/command/os/ListAppsCommand.js +1 -1
  33. package/lib/cjs/src/api/command/os/ListAppsCommand.js.map +2 -2
  34. package/lib/cjs/src/api/command/os/ListAppsCommand.test.js +1 -1
  35. package/lib/cjs/src/api/command/os/ListAppsCommand.test.js.map +2 -2
  36. package/lib/cjs/src/api/command/os/ListLanguagePackCommand.js +1 -1
  37. package/lib/cjs/src/api/command/os/ListLanguagePackCommand.js.map +2 -2
  38. package/lib/cjs/src/api/command/os/ListLanguagePackCommand.test.js +1 -1
  39. package/lib/cjs/src/api/command/os/ListLanguagePackCommand.test.js.map +2 -2
  40. package/lib/cjs/src/api/command/os/LoadCertificateCommand.js +1 -1
  41. package/lib/cjs/src/api/command/os/LoadCertificateCommand.js.map +2 -2
  42. package/lib/cjs/src/api/command/os/LoadCertificateCommand.test.js +1 -1
  43. package/lib/cjs/src/api/command/os/LoadCertificateCommand.test.js.map +3 -3
  44. package/lib/cjs/src/api/command/os/OpenAppCommand.js +1 -1
  45. package/lib/cjs/src/api/command/os/OpenAppCommand.js.map +2 -2
  46. package/lib/cjs/src/api/command/os/OpenAppCommand.test.js +1 -1
  47. package/lib/cjs/src/api/command/os/OpenAppCommand.test.js.map +2 -2
  48. package/lib/cjs/src/api/command/use-case/SendCommandUseCase.test.js +1 -1
  49. package/lib/cjs/src/api/command/use-case/SendCommandUseCase.test.js.map +2 -2
  50. package/lib/cjs/src/api/device-action/model/UserInteractionRequired.js +1 -1
  51. package/lib/cjs/src/api/device-action/model/UserInteractionRequired.js.map +2 -2
  52. package/lib/cjs/src/api/device-action/os/CallTaskInAppDeviceAction/CallTaskInAppDeviceAction.test.js +1 -1
  53. package/lib/cjs/src/api/device-action/os/CallTaskInAppDeviceAction/CallTaskInAppDeviceAction.test.js.map +2 -2
  54. package/lib/cjs/src/api/device-action/os/SendCommandInAppDeviceAction/SendCommandInAppDeviceAction.test.js +1 -1
  55. package/lib/cjs/src/api/device-action/os/SendCommandInAppDeviceAction/SendCommandInAppDeviceAction.test.js.map +2 -2
  56. package/lib/cjs/src/api/device-action/task/GetFirmwareMetadataTask.js +1 -1
  57. package/lib/cjs/src/api/device-action/task/GetFirmwareMetadataTask.js.map +2 -2
  58. package/lib/cjs/src/api/device-action/task/GetFirmwareMetadataTask.test.js +1 -1
  59. package/lib/cjs/src/api/device-action/task/GetFirmwareMetadataTask.test.js.map +2 -2
  60. package/lib/cjs/src/api/device-action/xstate-utils/XStateDeviceAction.js +1 -1
  61. package/lib/cjs/src/api/device-action/xstate-utils/XStateDeviceAction.js.map +2 -2
  62. package/lib/cjs/src/api/index.js +1 -1
  63. package/lib/cjs/src/api/index.js.map +2 -2
  64. package/lib/cjs/src/api/logger-subscriber/service/ConsoleLogger.js +1 -1
  65. package/lib/cjs/src/api/logger-subscriber/service/ConsoleLogger.js.map +3 -3
  66. package/lib/cjs/src/api/transport/model/ConnectedDevice.js +1 -1
  67. package/lib/cjs/src/api/transport/model/ConnectedDevice.js.map +3 -3
  68. package/lib/cjs/src/api/transport/model/TransportConnectedDevice.js +1 -1
  69. package/lib/cjs/src/api/transport/model/TransportConnectedDevice.js.map +3 -3
  70. package/lib/cjs/src/internal/device-session/model/DeviceSession.js +1 -1
  71. package/lib/cjs/src/internal/device-session/model/DeviceSession.js.map +3 -3
  72. package/lib/cjs/src/internal/device-session/service/DefaultDeviceSessionService.js +1 -1
  73. package/lib/cjs/src/internal/device-session/service/DefaultDeviceSessionService.js.map +3 -3
  74. package/lib/cjs/src/internal/device-session/service/DefaultDeviceSessionService.test.js +1 -1
  75. package/lib/cjs/src/internal/device-session/service/DefaultDeviceSessionService.test.js.map +3 -3
  76. package/lib/cjs/src/internal/device-session/service/DeviceSessionService.js +1 -1
  77. package/lib/cjs/src/internal/device-session/service/DeviceSessionService.js.map +1 -1
  78. package/lib/cjs/src/internal/discovery/di/discoveryModule.js +1 -1
  79. package/lib/cjs/src/internal/discovery/di/discoveryModule.js.map +3 -3
  80. package/lib/cjs/src/internal/discovery/di/discoveryModule.test.js +1 -1
  81. package/lib/cjs/src/internal/discovery/di/discoveryModule.test.js.map +3 -3
  82. package/lib/cjs/src/internal/discovery/di/discoveryTypes.js +1 -1
  83. package/lib/cjs/src/internal/discovery/di/discoveryTypes.js.map +2 -2
  84. package/lib/cjs/src/internal/discovery/use-case/ConnectUseCase.js +1 -1
  85. package/lib/cjs/src/internal/discovery/use-case/ConnectUseCase.js.map +3 -3
  86. package/lib/cjs/src/internal/discovery/use-case/ConnectUseCase.test.js +1 -1
  87. package/lib/cjs/src/internal/discovery/use-case/ConnectUseCase.test.js.map +3 -3
  88. package/lib/cjs/src/internal/discovery/use-case/DisconnectUseCase.js +1 -1
  89. package/lib/cjs/src/internal/discovery/use-case/DisconnectUseCase.js.map +3 -3
  90. package/lib/cjs/src/internal/discovery/use-case/ReconnectUseCase.js +2 -0
  91. package/lib/cjs/src/internal/discovery/use-case/ReconnectUseCase.js.map +7 -0
  92. package/lib/cjs/src/internal/discovery/use-case/ReconnectUseCase.test.js +2 -0
  93. package/lib/cjs/src/internal/discovery/use-case/ReconnectUseCase.test.js.map +7 -0
  94. package/lib/esm/package.json +1 -1
  95. package/lib/esm/src/api/DeviceManagementKit.js +1 -1
  96. package/lib/esm/src/api/DeviceManagementKit.js.map +2 -2
  97. package/lib/esm/src/api/DeviceManagementKit.test.js +1 -1
  98. package/lib/esm/src/api/DeviceManagementKit.test.js.map +2 -2
  99. package/lib/esm/src/api/command/Errors.js +1 -1
  100. package/lib/esm/src/api/command/Errors.js.map +3 -3
  101. package/lib/esm/src/api/command/model/CommandResult.js.map +2 -2
  102. package/lib/esm/src/api/command/os/CloseAppCommand.js +1 -1
  103. package/lib/esm/src/api/command/os/CloseAppCommand.js.map +2 -2
  104. package/lib/esm/src/api/command/os/CloseAppCommand.test.js +1 -1
  105. package/lib/esm/src/api/command/os/CloseAppCommand.test.js.map +2 -2
  106. package/lib/esm/src/api/command/os/GetAppAndVersionCommand.js +1 -1
  107. package/lib/esm/src/api/command/os/GetAppAndVersionCommand.js.map +2 -2
  108. package/lib/esm/src/api/command/os/GetAppAndVersionCommand.test.js +1 -1
  109. package/lib/esm/src/api/command/os/GetAppAndVersionCommand.test.js.map +2 -2
  110. package/lib/esm/src/api/command/os/GetBatteryStatusCommand.js +1 -1
  111. package/lib/esm/src/api/command/os/GetBatteryStatusCommand.js.map +2 -2
  112. package/lib/esm/src/api/command/os/GetBatteryStatusCommand.test.js +1 -1
  113. package/lib/esm/src/api/command/os/GetBatteryStatusCommand.test.js.map +3 -3
  114. package/lib/esm/src/api/command/os/GetCustomImageSizeCommand.js +1 -1
  115. package/lib/esm/src/api/command/os/GetCustomImageSizeCommand.js.map +2 -2
  116. package/lib/esm/src/api/command/os/GetCustomImageSizeCommand.test.js +1 -1
  117. package/lib/esm/src/api/command/os/GetCustomImageSizeCommand.test.js.map +2 -2
  118. package/lib/esm/src/api/command/os/GetOsVersionCommand.js +1 -1
  119. package/lib/esm/src/api/command/os/GetOsVersionCommand.js.map +2 -2
  120. package/lib/esm/src/api/command/os/GetOsVersionCommand.test.js +1 -1
  121. package/lib/esm/src/api/command/os/GetOsVersionCommand.test.js.map +2 -2
  122. package/lib/esm/src/api/command/os/ListAppsCommand.js +1 -1
  123. package/lib/esm/src/api/command/os/ListAppsCommand.js.map +2 -2
  124. package/lib/esm/src/api/command/os/ListAppsCommand.test.js +1 -1
  125. package/lib/esm/src/api/command/os/ListAppsCommand.test.js.map +2 -2
  126. package/lib/esm/src/api/command/os/ListLanguagePackCommand.js +1 -1
  127. package/lib/esm/src/api/command/os/ListLanguagePackCommand.js.map +2 -2
  128. package/lib/esm/src/api/command/os/ListLanguagePackCommand.test.js +1 -1
  129. package/lib/esm/src/api/command/os/ListLanguagePackCommand.test.js.map +2 -2
  130. package/lib/esm/src/api/command/os/LoadCertificateCommand.js +1 -1
  131. package/lib/esm/src/api/command/os/LoadCertificateCommand.js.map +2 -2
  132. package/lib/esm/src/api/command/os/LoadCertificateCommand.test.js +1 -1
  133. package/lib/esm/src/api/command/os/LoadCertificateCommand.test.js.map +3 -3
  134. package/lib/esm/src/api/command/os/OpenAppCommand.js +1 -1
  135. package/lib/esm/src/api/command/os/OpenAppCommand.js.map +2 -2
  136. package/lib/esm/src/api/command/os/OpenAppCommand.test.js +1 -1
  137. package/lib/esm/src/api/command/os/OpenAppCommand.test.js.map +2 -2
  138. package/lib/esm/src/api/command/use-case/SendCommandUseCase.test.js +1 -1
  139. package/lib/esm/src/api/command/use-case/SendCommandUseCase.test.js.map +2 -2
  140. package/lib/esm/src/api/device-action/model/UserInteractionRequired.js +1 -1
  141. package/lib/esm/src/api/device-action/model/UserInteractionRequired.js.map +2 -2
  142. package/lib/esm/src/api/device-action/os/CallTaskInAppDeviceAction/CallTaskInAppDeviceAction.test.js +1 -1
  143. package/lib/esm/src/api/device-action/os/CallTaskInAppDeviceAction/CallTaskInAppDeviceAction.test.js.map +2 -2
  144. package/lib/esm/src/api/device-action/os/SendCommandInAppDeviceAction/SendCommandInAppDeviceAction.test.js +1 -1
  145. package/lib/esm/src/api/device-action/os/SendCommandInAppDeviceAction/SendCommandInAppDeviceAction.test.js.map +2 -2
  146. package/lib/esm/src/api/device-action/task/GetFirmwareMetadataTask.js +1 -1
  147. package/lib/esm/src/api/device-action/task/GetFirmwareMetadataTask.js.map +3 -3
  148. package/lib/esm/src/api/device-action/task/GetFirmwareMetadataTask.test.js +1 -1
  149. package/lib/esm/src/api/device-action/task/GetFirmwareMetadataTask.test.js.map +3 -3
  150. package/lib/esm/src/api/device-action/xstate-utils/XStateDeviceAction.js +1 -1
  151. package/lib/esm/src/api/device-action/xstate-utils/XStateDeviceAction.js.map +2 -2
  152. package/lib/esm/src/api/index.js +1 -1
  153. package/lib/esm/src/api/index.js.map +3 -3
  154. package/lib/esm/src/api/logger-subscriber/service/ConsoleLogger.js +1 -1
  155. package/lib/esm/src/api/logger-subscriber/service/ConsoleLogger.js.map +3 -3
  156. package/lib/esm/src/api/transport/model/ConnectedDevice.js +1 -1
  157. package/lib/esm/src/api/transport/model/ConnectedDevice.js.map +3 -3
  158. package/lib/esm/src/api/transport/model/TransportConnectedDevice.js +1 -1
  159. package/lib/esm/src/api/transport/model/TransportConnectedDevice.js.map +3 -3
  160. package/lib/esm/src/internal/device-session/model/DeviceSession.js +1 -1
  161. package/lib/esm/src/internal/device-session/model/DeviceSession.js.map +3 -3
  162. package/lib/esm/src/internal/device-session/service/DefaultDeviceSessionService.js +1 -1
  163. package/lib/esm/src/internal/device-session/service/DefaultDeviceSessionService.js.map +3 -3
  164. package/lib/esm/src/internal/device-session/service/DefaultDeviceSessionService.test.js +1 -1
  165. package/lib/esm/src/internal/device-session/service/DefaultDeviceSessionService.test.js.map +3 -3
  166. package/lib/esm/src/internal/discovery/di/discoveryModule.js +1 -1
  167. package/lib/esm/src/internal/discovery/di/discoveryModule.js.map +3 -3
  168. package/lib/esm/src/internal/discovery/di/discoveryModule.test.js +1 -1
  169. package/lib/esm/src/internal/discovery/di/discoveryModule.test.js.map +3 -3
  170. package/lib/esm/src/internal/discovery/di/discoveryTypes.js +1 -1
  171. package/lib/esm/src/internal/discovery/di/discoveryTypes.js.map +2 -2
  172. package/lib/esm/src/internal/discovery/use-case/ConnectUseCase.js +1 -1
  173. package/lib/esm/src/internal/discovery/use-case/ConnectUseCase.js.map +3 -3
  174. package/lib/esm/src/internal/discovery/use-case/ConnectUseCase.test.js +1 -1
  175. package/lib/esm/src/internal/discovery/use-case/ConnectUseCase.test.js.map +3 -3
  176. package/lib/esm/src/internal/discovery/use-case/DisconnectUseCase.js +1 -1
  177. package/lib/esm/src/internal/discovery/use-case/DisconnectUseCase.js.map +3 -3
  178. package/lib/esm/src/internal/discovery/use-case/ReconnectUseCase.js +2 -0
  179. package/lib/esm/src/internal/discovery/use-case/ReconnectUseCase.js.map +7 -0
  180. package/lib/esm/src/internal/discovery/use-case/ReconnectUseCase.test.js +2 -0
  181. package/lib/esm/src/internal/discovery/use-case/ReconnectUseCase.test.js.map +7 -0
  182. package/lib/types/src/api/DeviceManagementKit.d.ts +12 -0
  183. package/lib/types/src/api/DeviceManagementKit.d.ts.map +1 -1
  184. package/lib/types/src/api/command/Command.d.ts +4 -0
  185. package/lib/types/src/api/command/Command.d.ts.map +1 -1
  186. package/lib/types/src/api/command/Errors.d.ts +5 -0
  187. package/lib/types/src/api/command/Errors.d.ts.map +1 -1
  188. package/lib/types/src/api/command/model/CommandResult.d.ts +3 -3
  189. package/lib/types/src/api/command/model/CommandResult.d.ts.map +1 -1
  190. package/lib/types/src/api/command/os/CloseAppCommand.d.ts +1 -0
  191. package/lib/types/src/api/command/os/CloseAppCommand.d.ts.map +1 -1
  192. package/lib/types/src/api/command/os/GetAppAndVersionCommand.d.ts +1 -0
  193. package/lib/types/src/api/command/os/GetAppAndVersionCommand.d.ts.map +1 -1
  194. package/lib/types/src/api/command/os/GetBatteryStatusCommand.d.ts +1 -0
  195. package/lib/types/src/api/command/os/GetBatteryStatusCommand.d.ts.map +1 -1
  196. package/lib/types/src/api/command/os/GetCustomImageSizeCommand.d.ts +1 -0
  197. package/lib/types/src/api/command/os/GetCustomImageSizeCommand.d.ts.map +1 -1
  198. package/lib/types/src/api/command/os/GetOsVersionCommand.d.ts +1 -0
  199. package/lib/types/src/api/command/os/GetOsVersionCommand.d.ts.map +1 -1
  200. package/lib/types/src/api/command/os/ListAppsCommand.d.ts +1 -0
  201. package/lib/types/src/api/command/os/ListAppsCommand.d.ts.map +1 -1
  202. package/lib/types/src/api/command/os/ListLanguagePackCommand.d.ts +1 -0
  203. package/lib/types/src/api/command/os/ListLanguagePackCommand.d.ts.map +1 -1
  204. package/lib/types/src/api/command/os/LoadCertificateCommand.d.ts +1 -0
  205. package/lib/types/src/api/command/os/LoadCertificateCommand.d.ts.map +1 -1
  206. package/lib/types/src/api/command/os/OpenAppCommand.d.ts +1 -0
  207. package/lib/types/src/api/command/os/OpenAppCommand.d.ts.map +1 -1
  208. package/lib/types/src/api/device-action/model/UserInteractionRequired.d.ts +2 -1
  209. package/lib/types/src/api/device-action/model/UserInteractionRequired.d.ts.map +1 -1
  210. package/lib/types/src/api/device-action/task/GetFirmwareMetadataTask.d.ts.map +1 -1
  211. package/lib/types/src/api/device-action/xstate-utils/XStateDeviceAction.d.ts.map +1 -1
  212. package/lib/types/src/api/index.d.ts +1 -1
  213. package/lib/types/src/api/index.d.ts.map +1 -1
  214. package/lib/types/src/api/logger-subscriber/service/ConsoleLogger.d.ts +1 -0
  215. package/lib/types/src/api/logger-subscriber/service/ConsoleLogger.d.ts.map +1 -1
  216. package/lib/types/src/api/transport/model/ConnectedDevice.d.ts +3 -2
  217. package/lib/types/src/api/transport/model/ConnectedDevice.d.ts.map +1 -1
  218. package/lib/types/src/api/transport/model/TransportConnectedDevice.d.ts +3 -1
  219. package/lib/types/src/api/transport/model/TransportConnectedDevice.d.ts.map +1 -1
  220. package/lib/types/src/internal/device-session/model/DeviceSession.d.ts.map +1 -1
  221. package/lib/types/src/internal/device-session/service/DefaultDeviceSessionService.d.ts +7 -5
  222. package/lib/types/src/internal/device-session/service/DefaultDeviceSessionService.d.ts.map +1 -1
  223. package/lib/types/src/internal/device-session/service/DeviceSessionService.d.ts +28 -1
  224. package/lib/types/src/internal/device-session/service/DeviceSessionService.d.ts.map +1 -1
  225. package/lib/types/src/internal/discovery/di/discoveryModule.d.ts.map +1 -1
  226. package/lib/types/src/internal/discovery/di/discoveryTypes.d.ts +1 -0
  227. package/lib/types/src/internal/discovery/di/discoveryTypes.d.ts.map +1 -1
  228. package/lib/types/src/internal/discovery/use-case/ConnectUseCase.d.ts +3 -2
  229. package/lib/types/src/internal/discovery/use-case/ConnectUseCase.d.ts.map +1 -1
  230. package/lib/types/src/internal/discovery/use-case/DisconnectUseCase.d.ts.map +1 -1
  231. package/lib/types/src/internal/discovery/use-case/ReconnectUseCase.d.ts +32 -0
  232. package/lib/types/src/internal/discovery/use-case/ReconnectUseCase.d.ts.map +1 -0
  233. package/lib/types/src/internal/discovery/use-case/ReconnectUseCase.test.d.ts +2 -0
  234. package/lib/types/src/internal/discovery/use-case/ReconnectUseCase.test.d.ts.map +1 -0
  235. package/lib/types/tsconfig.prod.tsbuildinfo +1 -1
  236. package/package.json +3 -3
@@ -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{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 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};
2
2
  //# sourceMappingURL=GetOsVersionCommand.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../../../src/api/command/os/GetOsVersionCommand.ts"],
4
- "sourcesContent": ["import { coerce, gte } from \"semver\";\n\nimport { type Apdu } from \"@api/apdu/model/Apdu\";\nimport { ApduBuilder, type ApduBuilderArgs } from \"@api/apdu/utils/ApduBuilder\";\nimport { ApduParser } from \"@api/apdu/utils/ApduParser\";\nimport { type Command } from \"@api/command/Command\";\nimport { InvalidStatusWordError } from \"@api/command/Errors\";\nimport {\n type CommandResult,\n CommandResultFactory,\n} from \"@api/command/model/CommandResult\";\nimport { CommandUtils } from \"@api/command/utils/CommandUtils\";\nimport { GlobalCommandErrorHandler } from \"@api/command/utils/GlobalCommandError\";\nimport { DeviceModelId } from \"@api/device/DeviceModel\";\nimport {\n type DeviceGeneralState,\n type EndorsementInformation,\n type OnboardingStatus,\n type WordsInformation,\n} from \"@api/device/SecureElementFlags\";\nimport { type ApduResponse } from \"@api/device-session/ApduResponse\";\n\nimport { SecureElementFlagsParser } from \"./SecureElementFlagsParser\";\n\n/**\n * Response of the GetOsVersionCommand.\n */\nexport type GetOsVersionResponse = {\n /**\n * Indicated if the device is running in bootloader mode.\n * It can happens during a firmware update process.\n */\n readonly isBootloader: boolean;\n\n /**\n * Indicated if the device firmware is an OS Updater (OSU).\n * It can happens during a firmware update process.\n */\n readonly isOsu: boolean;\n\n /**\n * Target identifier.\n */\n readonly targetId: number;\n\n /**\n * Target identifier of the secure element.\n * Not always available when the device is in bootloader mode.\n */\n readonly seTargetId: number | undefined;\n\n /**\n * Target identifier of the microcontroller unit (MCU).\n * Only available when the device is in bootloader mode.\n */\n readonly mcuTargetId: number | undefined;\n\n /**\n * Version of BOLOS on the secure element (SE).\n * {@link https://developers.ledger.com/docs/device-app/architecture/bolos/hardware-architecture | Hardware Architecture}\n */\n readonly seVersion: string;\n\n /**\n * Secure element flags.\n * Used to represent the current state of the secure element.\n */\n readonly seFlags: Uint8Array;\n\n /**\n * Version of the microcontroller unit (MCU) SEPH, which is the SE-MCU link protocol.\n * {@link https://developers.ledger.com/docs/device-app/architecture/bolos/hardware-architecture | Hardware Architecture}\n */\n readonly mcuSephVersion: string;\n\n /**\n * Version of the MCU bootloader.\n */\n readonly mcuBootloaderVersion: string;\n\n /**\n * Hardware revision version.\n * Only available for Ledger Nano X in which case it's \"00\" or \"01\".\n */\n readonly hwVersion: string;\n\n /**\n * Identifier of the installed language pack.\n * Can be one of:\n * - \"00\": English\n * - \"01\": French\n * - \"02\": Spanish\n * - \"03\": Portuguese\n * - \"04\": German\n * - \"05\": Russian\n * - \"06\": Turkish\n */\n readonly langId: number | undefined;\n\n /**\n * State for Ledger Recover. // [SHOULD] Add more information about this field\n */\n readonly recoverState: number | undefined;\n\n /**\n * The parsed secure element flags.\n */\n readonly secureElementFlags: DeviceGeneralState &\n EndorsementInformation &\n WordsInformation &\n OnboardingStatus;\n};\n\nexport type GetOsVersionCommandResult = CommandResult<GetOsVersionResponse>;\n\n/**\n * Command to get information about the device firmware.\n */\nexport class GetOsVersionCommand implements Command<GetOsVersionResponse> {\n readonly args = undefined;\n\n getApdu(): Apdu {\n const getOsVersionApduArgs: ApduBuilderArgs = {\n cla: 0xe0,\n ins: 0x01,\n p1: 0x00,\n p2: 0x00,\n };\n return new ApduBuilder(getOsVersionApduArgs).build();\n }\n\n parseResponse(\n apduResponse: ApduResponse,\n deviceModelId: DeviceModelId,\n ): GetOsVersionCommandResult {\n if (!CommandUtils.isSuccessResponse(apduResponse)) {\n return CommandResultFactory({\n error: GlobalCommandErrorHandler.handle(apduResponse),\n });\n }\n const parser = new ApduParser(apduResponse);\n const targetId = parser.extract32BitUInt();\n if (targetId === undefined) {\n return CommandResultFactory({\n error: new InvalidStatusWordError(\"Missing target ID in OS version\"),\n });\n }\n\n let version = parser.encodeToString(parser.extractFieldLVEncoded());\n let seFlags = parser.extractFieldLVEncoded() ?? new Uint8Array(0);\n const seFlagsParser = new SecureElementFlagsParser(seFlags);\n // This is the parsed secure element flags.\n const secureElementFlags = { ...seFlagsParser.generalDeviceState() };\n\n // Handle old firmwares with no version\n if (!version) {\n version = \"0.0.0\";\n seFlags = new Uint8Array();\n }\n\n const isBootloader = (targetId & 0xf0000000) !== 0x30000000;\n const isOsu = version.includes(\"-osu\");\n let seVersion: string = \"\";\n let mcuSephVersion: string = \"\";\n let mcuBootloaderVersion: string = \"\";\n let hwVersion: string = \"\";\n let mcuTargetId: number | undefined = undefined;\n let seTargetId: number | undefined = undefined;\n let langId: number | undefined = undefined;\n let recoverState: number | undefined = undefined;\n\n if (isBootloader) {\n mcuBootloaderVersion = version;\n mcuTargetId = targetId;\n\n const seData = parser.extractFieldLVEncoded();\n if (seData) {\n if (seData.length >= 5) {\n // It means it's a version followed by the seTargetId\n seVersion = parser.encodeToString(seData);\n seTargetId = parseInt(\n parser.encodeToHexaString(parser.extractFieldLVEncoded()),\n 16,\n );\n } else {\n // It's the seTargetId\n seTargetId = parseInt(parser.encodeToHexaString(seData), 16);\n }\n }\n } else {\n seVersion = version;\n seTargetId = targetId;\n\n mcuSephVersion = parser.encodeToString(parser.extractFieldLVEncoded());\n\n if (this.isBootloaderVersionSupported(seVersion, deviceModelId)) {\n mcuBootloaderVersion = parser.encodeToString(\n parser.extractFieldLVEncoded(),\n );\n }\n\n if (this.isHardwareVersionSupported(seVersion, deviceModelId)) {\n hwVersion = parser.encodeToHexaString(parser.extractFieldLVEncoded());\n } else {\n hwVersion = \"00\";\n }\n\n if (this.isLocalizationSupported(seVersion, deviceModelId)) {\n const langIdBuffer = parser.extractFieldLVEncoded();\n if (langIdBuffer !== undefined) {\n langId = parseInt(parser.encodeToHexaString(langIdBuffer), 16);\n }\n }\n\n if (this.isRecoverSupported(seVersion, deviceModelId)) {\n const recoverStateBuffer = parser.extractFieldLVEncoded();\n if (recoverStateBuffer !== undefined) {\n recoverState = parseInt(\n parser.encodeToHexaString(recoverStateBuffer),\n 16,\n );\n }\n }\n }\n\n return CommandResultFactory({\n data: {\n isBootloader,\n isOsu,\n targetId,\n seTargetId,\n mcuTargetId,\n seVersion,\n seFlags,\n mcuSephVersion,\n mcuBootloaderVersion,\n hwVersion,\n langId,\n recoverState,\n secureElementFlags,\n },\n });\n }\n\n private isBootloaderVersionSupported(\n seVersion: string,\n deviceModelId: DeviceModelId,\n ): boolean {\n const version = coerce(seVersion) ?? \"\";\n switch (deviceModelId) {\n case DeviceModelId.NANO_S:\n case DeviceModelId.NANO_X:\n return gte(version, \"2.0.0\");\n default:\n return true;\n }\n }\n\n private isHardwareVersionSupported(\n seVersion: string,\n deviceModelId: DeviceModelId,\n ): boolean {\n const version = coerce(seVersion) ?? \"\";\n switch (deviceModelId) {\n case DeviceModelId.NANO_X:\n return gte(version, \"2.0.0\");\n default:\n return false;\n }\n }\n\n private isLocalizationSupported(\n seVersion: string,\n deviceModelId: DeviceModelId,\n ): boolean {\n const version = coerce(seVersion) ?? \"\";\n switch (deviceModelId) {\n case DeviceModelId.NANO_S:\n return false;\n case DeviceModelId.NANO_SP:\n return gte(version, \"1.1.0\");\n case DeviceModelId.NANO_X:\n return gte(version, \"2.1.0\");\n default:\n return true;\n }\n }\n\n private isRecoverSupported(\n seVersion: string,\n deviceModelId: DeviceModelId,\n ): boolean {\n const version = coerce(seVersion) ?? \"\";\n switch (deviceModelId) {\n case DeviceModelId.NANO_S:\n return false;\n case DeviceModelId.NANO_SP:\n return gte(version, \"1.1.2\");\n case DeviceModelId.NANO_X:\n return gte(version, \"2.2.3\");\n case DeviceModelId.STAX:\n return gte(version, \"1.4.0\");\n case DeviceModelId.FLEX:\n return gte(version, \"1.0.1\");\n default:\n return true;\n }\n }\n}\n"],
5
- "mappings": "AAAA,OAAS,UAAAA,EAAQ,OAAAC,MAAW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OACjB,OAAOP,EAAIe,EAAS,OAAO,EAC7B,QACE,MAAO,EACX,CACF,CAEQ,wBACNK,EACAR,EACS,CACT,MAAMG,EAAUhB,EAAOqB,CAAS,GAAK,GACrC,OAAQR,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,mBACNK,EACAR,EACS,CACT,MAAMG,EAAUhB,EAAOqB,CAAS,GAAK,GACrC,OAAQR,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",
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,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,IA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,EACA,SAAAL,EACA,WAAAW,EACA,YAAAD,EACA,UAAAJ,EACA,QAAAJ,EACA,eAAAK,EACA,qBAAAC,EACA,UAAAC,EACA,OAAAG,EACA,aAAAC,EACA,mBAAAV,CACF,CACF,CAAC,CACH,CAEQ,6BACNG,EACAR,EACS,CACT,MAAMG,EAAUhB,EAAOqB,CAAS,GAAK,GACrC,OAAQR,EAAe,CACrB,KAAKL,EAAc,OACnB,KAAKA,EAAc,OACjB,OAAOP,EAAIe,EAAS,OAAO,EAC7B,QACE,MAAO,EACX,CACF,CAEQ,2BACNK,EACAR,EACS,CACT,MAAMG,EAAUhB,EAAOqB,CAAS,GAAK,GACrC,OAAQR,EAAe,CACrB,KAAKL,EAAc,OACjB,OAAOP,EAAIe,EAAS,OAAO,EAC7B,QACE,MAAO,EACX,CACF,CAEQ,wBACNK,EACAR,EACS,CACT,MAAMG,EAAUhB,EAAOqB,CAAS,GAAK,GACrC,OAAQR,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,mBACNK,EACAR,EACS,CACT,MAAMG,EAAUhB,EAAOqB,CAAS,GAAK,GACrC,OAAQR,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
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"]
7
7
  }
@@ -1,2 +1,2 @@
1
- import{CommandResultFactory as o,isSuccessCommandResult as n}from"../../command/model/CommandResult";import{DeviceModelId as t}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}),S=Uint8Array.from([51,32,0,4,5,49,46,51,46,48,4,230,0,0,0,4,53,46,50,52,4,48,46,52,56,1,0,1,0,144,0]),m=new r({statusCode:Uint8Array.from([144,0]),data:S}),O=Uint8Array.from([5,1,0,3,4,49,46,49,54,4,244,216,170,67,5,50,46,50,46,51,4,51,0,0,4,144,0]),A=new r({statusCode:Uint8Array.from([144,0]),data:O}),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("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,t.NANO_X),x=o({data:a(t.NANO_X)});expect(e).toStrictEqual(x)})}),describe("Nano S Plus",()=>{it("should parse the LNSP response",()=>{const e=s.parseResponse(p,t.NANO_SP),x=o({data:a(t.NANO_SP)});expect(e).toStrictEqual(x)})}),describe("Stax",()=>{it("should parse the STAX response",()=>{const e=s.parseResponse(m,t.STAX),x=o({data:a(t.STAX)});expect(e).toStrictEqual(x)})}),describe("Bootloader",()=>{it("should parse the bootloader response",()=>{const e=s.parseResponse(A,t.STAX),x=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(x)})}),describe("Old firmware",()=>{it("should parse the old firmware response",()=>{const e=s.parseResponse(_,t.NANO_X),x=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(x)})}),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([])}),x=s.parseResponse(e,t.NANO_S);expect(n(x)).toBeFalsy()})})})});
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()})})})});
2
2
  //# sourceMappingURL=GetOsVersionCommand.test.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../../../src/api/command/os/GetOsVersionCommand.test.ts"],
4
- "sourcesContent": ["import {\n CommandResultFactory,\n isSuccessCommandResult,\n} from \"@api/command/model/CommandResult\";\nimport { DeviceModelId } from \"@api/device/DeviceModel\";\nimport { ApduResponse } from \"@api/device-session/ApduResponse\";\n\nimport { getOsVersionCommandResponseMockBuilder } from \"./__mocks__/GetOsVersionCommand\";\nimport { GetOsVersionCommand } from \"./GetOsVersionCommand\";\n\nconst GET_OS_VERSION_APDU = Uint8Array.from([0xe0, 0x01, 0x00, 0x00, 0x00]);\n\nconst LNX_RESPONSE_DATA_GOOD = Uint8Array.from([\n 0x33, 0x00, 0x00, 0x04, 0x05, 0x32, 0x2e, 0x32, 0x2e, 0x33, 0x04, 0xe6, 0x00,\n 0x00, 0x00, 0x04, 0x32, 0x2e, 0x33, 0x30, 0x04, 0x31, 0x2e, 0x31, 0x36, 0x01,\n 0x00, 0x01, 0x00, 0x01, 0x00, 0x90, 0x00,\n]);\nconst LNX_RESPONSE_GOOD = new ApduResponse({\n statusCode: Uint8Array.from([0x90, 0x00]),\n data: LNX_RESPONSE_DATA_GOOD,\n});\n\nconst LNSP_REPONSE_DATA_GOOD = Uint8Array.from([\n 0x33, 0x10, 0x00, 0x04, 0x05, 0x31, 0x2e, 0x31, 0x2e, 0x31, 0x04, 0xe6, 0x00,\n 0x00, 0x00, 0x04, 0x34, 0x2e, 0x30, 0x33, 0x04, 0x33, 0x2e, 0x31, 0x32, 0x01,\n 0x00, 0x01, 0x00, 0x90, 0x00,\n]);\nconst LNSP_RESPONSE_GOOD = new ApduResponse({\n statusCode: Uint8Array.from([0x90, 0x00]),\n data: LNSP_REPONSE_DATA_GOOD,\n});\n\nconst STAX_RESPONSE_DATA_GOOD = Uint8Array.from([\n 0x33, 0x20, 0x00, 0x04, 0x05, 0x31, 0x2e, 0x33, 0x2e, 0x30, 0x04, 0xe6, 0x00,\n 0x00, 0x00, 0x04, 0x35, 0x2e, 0x32, 0x34, 0x04, 0x30, 0x2e, 0x34, 0x38, 0x01,\n 0x00, 0x01, 0x00, 0x90, 0x00,\n]);\nconst STAX_RESPONSE_GOOD = new ApduResponse({\n statusCode: Uint8Array.from([0x90, 0x00]),\n data: STAX_RESPONSE_DATA_GOOD,\n});\n\nconst BL_RESPONSE_DATA_GOOD = Uint8Array.from([\n 0x05, 0x01, 0x00, 0x03, 0x04, 0x31, 0x2e, 0x31, 0x36, 0x04, 0xf4, 0xd8, 0xaa,\n 0x43, 0x05, 0x32, 0x2e, 0x32, 0x2e, 0x33, 0x04, 0x33, 0x00, 0x00, 0x04, 0x90,\n 0x00,\n]);\nconst BL_RESPONSE_GOOD = new ApduResponse({\n statusCode: Uint8Array.from([0x90, 0x00]),\n data: BL_RESPONSE_DATA_GOOD,\n});\n\nconst OLD_FM_RESPONSE_DATA_GOOD = Uint8Array.from([\n 0x33, 0x00, 0x00, 0x04, 0x00, 0x04, 0xee, 0x00, 0x00, 0x00, 0x04, 0x32, 0x2e,\n 0x33, 0x30, 0x01, 0x01, 0x01, 0x00, 0x01, 0x00, 0x90, 0x00,\n]);\nconst OLD_FM_RESPONSE_GOOD = new ApduResponse({\n statusCode: Uint8Array.from([0x90, 0x00]),\n data: OLD_FM_RESPONSE_DATA_GOOD,\n});\n\ndescribe(\"GetOsVersionCommand\", () => {\n let command: GetOsVersionCommand;\n\n beforeEach(() => {\n command = new GetOsVersionCommand();\n });\n\n describe(\"getApdu\", () => {\n it(\"should return the GetOsVersion apdu\", () => {\n const apdu = command.getApdu();\n expect(apdu.getRawApdu()).toStrictEqual(GET_OS_VERSION_APDU);\n });\n });\n\n describe(\"parseResponse\", () => {\n describe(\"Nano X\", () => {\n it(\"should parse the LNX response\", () => {\n const parsed = command.parseResponse(\n LNX_RESPONSE_GOOD,\n DeviceModelId.NANO_X,\n );\n\n const expected = CommandResultFactory({\n data: getOsVersionCommandResponseMockBuilder(DeviceModelId.NANO_X),\n });\n\n expect(parsed).toStrictEqual(expected);\n });\n });\n\n describe(\"Nano S Plus\", () => {\n it(\"should parse the LNSP response\", () => {\n const parsed = command.parseResponse(\n LNSP_RESPONSE_GOOD,\n DeviceModelId.NANO_SP,\n );\n\n const expected = CommandResultFactory({\n data: getOsVersionCommandResponseMockBuilder(DeviceModelId.NANO_SP),\n });\n\n expect(parsed).toStrictEqual(expected);\n });\n });\n\n describe(\"Stax\", () => {\n it(\"should parse the STAX response\", () => {\n const parsed = command.parseResponse(\n STAX_RESPONSE_GOOD,\n DeviceModelId.STAX,\n );\n\n const expected = CommandResultFactory({\n data: getOsVersionCommandResponseMockBuilder(DeviceModelId.STAX),\n });\n\n expect(parsed).toStrictEqual(expected);\n });\n });\n\n describe(\"Bootloader\", () => {\n it(\"should parse the bootloader response\", () => {\n const parsed = command.parseResponse(\n BL_RESPONSE_GOOD,\n DeviceModelId.STAX,\n );\n\n const expected = CommandResultFactory({\n data: {\n isBootloader: true,\n isOsu: false,\n targetId: 83951619,\n seTargetId: 855638020,\n seVersion: \"2.2.3\",\n seFlags: new Uint8Array([0xf4, 0xd8, 0xaa, 0x43]),\n mcuTargetId: 83951619,\n mcuSephVersion: \"\",\n mcuBootloaderVersion: \"1.16\",\n hwVersion: \"\",\n langId: undefined,\n recoverState: undefined,\n secureElementFlags: {\n isPinValidated: true,\n hasMcuSerialNumber: true,\n hasValidCertificate: true,\n isCustomAuthorityConnectionAllowed: true,\n isSecureConnectionAllowed: false,\n isOnboarded: true,\n isMcuCodeSigned: false,\n isInRecoveryMode: false,\n },\n },\n });\n\n expect(parsed).toStrictEqual(expected);\n });\n });\n\n describe(\"Old firmware\", () => {\n it(\"should parse the old firmware response\", () => {\n const parsed = command.parseResponse(\n OLD_FM_RESPONSE_GOOD,\n DeviceModelId.NANO_X,\n );\n\n const expected = CommandResultFactory({\n data: {\n isBootloader: false,\n isOsu: false,\n targetId: 855638020,\n seTargetId: 855638020,\n seVersion: \"0.0.0\",\n seFlags: new Uint8Array(),\n mcuTargetId: undefined,\n mcuSephVersion: \"2.30\",\n mcuBootloaderVersion: \"\",\n hwVersion: \"00\",\n langId: undefined,\n recoverState: undefined,\n secureElementFlags: {\n isPinValidated: true,\n hasMcuSerialNumber: true,\n hasValidCertificate: true,\n isCustomAuthorityConnectionAllowed: false,\n isSecureConnectionAllowed: true,\n isOnboarded: true,\n isMcuCodeSigned: true,\n isInRecoveryMode: false,\n },\n },\n });\n\n expect(parsed).toStrictEqual(expected);\n });\n });\n\n describe(\"Error handling\", () => {\n it(\"should return an error if the response is not successful\", () => {\n const response = new ApduResponse({\n statusCode: Uint8Array.from([0x6e, 0x80]),\n data: Uint8Array.from([]),\n });\n const result = command.parseResponse(response, DeviceModelId.NANO_S);\n\n expect(isSuccessCommandResult(result)).toBeFalsy();\n });\n });\n });\n});\n"],
5
- "mappings": "AAAA,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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rBD,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",
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 });\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eAAgB,OAChB,qBAAsB,GACtB,UAAW,KACX,OAAQ,OACR,aAAc,OACd,mBAAoB,CAClB,eAAgB,GAChB,mBAAoB,GACpB,oBAAqB,GACrB,mCAAoC,GACpC,0BAA2B,GAC3B,YAAa,GACb,gBAAiB,GACjB,iBAAkB,EACpB,CACF,CACF,CAAC,EAED,OAAOmB,CAAM,EAAE,cAAcC,CAAQ,CACvC,CAAC,CACH,CAAC,EAED,SAAS,iBAAkB,IAAM,CAC/B,GAAG,2DAA4D,IAAM,CACnE,MAAMC,EAAW,IAAIlB,EAAa,CAChC,WAAY,WAAW,KAAK,CAAC,IAAM,GAAI,CAAC,EACxC,KAAM,WAAW,KAAK,CAAC,CAAC,CAC1B,CAAC,EACKmB,EAASL,EAAQ,cAAcI,EAAUnB,EAAc,MAAM,EAEnE,OAAOD,EAAuBqB,CAAM,CAAC,EAAE,UAAU,CACnD,CAAC,CACH,CAAC,CACH,CAAC,CACH,CAAC",
6
6
  "names": ["CommandResultFactory", "isSuccessCommandResult", "DeviceModelId", "ApduResponse", "getOsVersionCommandResponseMockBuilder", "GetOsVersionCommand", "GET_OS_VERSION_APDU", "LNX_RESPONSE_DATA_GOOD", "LNX_RESPONSE_GOOD", "LNSP_REPONSE_DATA_GOOD", "LNSP_RESPONSE_GOOD", "STAX_RESPONSE_DATA_GOOD", "STAX_RESPONSE_GOOD", "BL_RESPONSE_DATA_GOOD", "BL_RESPONSE_GOOD", "OLD_FM_RESPONSE_DATA_GOOD", "OLD_FM_RESPONSE_GOOD", "command", "apdu", "parsed", "expected", "response", "result"]
7
7
  }
@@ -1,2 +1,2 @@
1
- import{ApduBuilder as l}from"../../apdu/utils/ApduBuilder";import{ApduParser as A}from"../../apdu/utils/ApduParser";import{CommandResultFactory as o}from"../../command/model/CommandResult";import{isCommandErrorCode as c}from"../../command/utils/CommandErrors";import{CommandUtils as u}from"../../command/utils/CommandUtils";import{GlobalCommandErrorHandler as C}from"../../command/utils/GlobalCommandError";import{DeviceExchangeError as g}from"../../Error";const p={6624:{message:"Invalid state (List applications command must be sent)"}};class x extends g{constructor({message:e,errorCode:s}){super({message:e,errorCode:s,tag:"ListAppsCommandError"})}}class S{args;constructor(e={isContinue:!1}){this.args=e}getApdu(){const e={cla:224,ins:this.args.isContinue?223:222,p1:0,p2:0};return new l(e).build()}parseResponse(e){const s=[],r=new A(e);if(!u.isSuccessResponse(e)){const t=r.encodeToHexaString(e.statusCode);return c(t,p)?o({error:new x({...p[t],errorCode:t})}):o({error:C.handle(e)})}if(e.data.length<=0)return o({data:[]});for(r.extract8BitUInt();r.getUnparsedRemainingLength()>0;){const t=r.extract8BitUInt(),a=r.extract16BitUInt();r.extract16BitUInt();const i=r.encodeToHexaString(r.extractFieldByLength(32)),d=r.encodeToHexaString(r.extractFieldByLength(32)),m=r.encodeToString(r.extractFieldLVEncoded());s.push({appEntryLength:t,appSizeInBlocks:a,appCodeHash:i,appFullHash:d,appName:m})}return o({data:s})}}export{S as ListAppsCommand,x as ListAppsCommandError};
1
+ import{ApduBuilder as l}from"../../apdu/utils/ApduBuilder";import{ApduParser as A}from"../../apdu/utils/ApduParser";import{CommandResultFactory as o}from"../../command/model/CommandResult";import{isCommandErrorCode as c}from"../../command/utils/CommandErrors";import{CommandUtils as u}from"../../command/utils/CommandUtils";import{GlobalCommandErrorHandler as C}from"../../command/utils/GlobalCommandError";import{DeviceExchangeError as g}from"../../Error";const p={6624:{message:"Invalid state (List applications command must be sent)"}};class x extends g{constructor({message:e,errorCode:s}){super({message:e,errorCode:s,tag:"ListAppsCommandError"})}}class S{name="listApps";args;constructor(e={isContinue:!1}){this.args=e}getApdu(){const e={cla:224,ins:this.args.isContinue?223:222,p1:0,p2:0};return new l(e).build()}parseResponse(e){const s=[],r=new A(e);if(!u.isSuccessResponse(e)){const t=r.encodeToHexaString(e.statusCode);return c(t,p)?o({error:new x({...p[t],errorCode:t})}):o({error:C.handle(e)})}if(e.data.length<=0)return o({data:[]});for(r.extract8BitUInt();r.getUnparsedRemainingLength()>0;){const t=r.extract8BitUInt(),a=r.extract16BitUInt();r.extract16BitUInt();const i=r.encodeToHexaString(r.extractFieldByLength(32)),d=r.encodeToHexaString(r.extractFieldByLength(32)),m=r.encodeToString(r.extractFieldLVEncoded());s.push({appEntryLength:t,appSizeInBlocks:a,appCodeHash:i,appFullHash:d,appName:m})}return o({data:s})}}export{S as ListAppsCommand,x as ListAppsCommandError};
2
2
  //# sourceMappingURL=ListAppsCommand.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../../../src/api/command/os/ListAppsCommand.ts"],
4
- "sourcesContent": ["import { type Apdu } from \"@api/apdu/model/Apdu\";\nimport { ApduBuilder, type ApduBuilderArgs } from \"@api/apdu/utils/ApduBuilder\";\nimport { ApduParser } from \"@api/apdu/utils/ApduParser\";\nimport { type Command } from \"@api/command/Command\";\nimport {\n type CommandResult,\n CommandResultFactory,\n} from \"@api/command/model/CommandResult\";\nimport {\n type CommandErrors,\n isCommandErrorCode,\n} from \"@api/command/utils/CommandErrors\";\nimport { CommandUtils } from \"@api/command/utils/CommandUtils\";\nimport { GlobalCommandErrorHandler } from \"@api/command/utils/GlobalCommandError\";\nimport { type ApduResponse } from \"@api/device-session/ApduResponse\";\nimport { type CommandErrorArgs, DeviceExchangeError } from \"@api/Error\";\n\nexport type AppResponse = {\n readonly appEntryLength: number;\n readonly appSizeInBlocks: number;\n readonly appCodeHash: string;\n readonly appFullHash: string;\n readonly appName: string;\n};\n\nexport type ListAppsResponse = AppResponse[];\n\nexport type ListAppsArgs = {\n readonly isContinue: boolean;\n};\n\nexport type ListAppsErrorCodes = \"6624\";\n\nconst LIST_APP_ERRORS: CommandErrors<ListAppsErrorCodes> = {\n \"6624\": { message: \"Invalid state (List applications command must be sent)\" },\n};\n\nexport type ListAppsCommandResult = CommandResult<\n ListAppsResponse,\n ListAppsErrorCodes\n>;\n\nexport class ListAppsCommandError extends DeviceExchangeError<ListAppsErrorCodes> {\n constructor({ message, errorCode }: CommandErrorArgs<ListAppsErrorCodes>) {\n super({ message, errorCode, tag: \"ListAppsCommandError\" });\n }\n}\n\nexport class ListAppsCommand\n implements Command<ListAppsResponse, ListAppsArgs, ListAppsErrorCodes>\n{\n readonly args: ListAppsArgs;\n\n constructor(args = { isContinue: false }) {\n this.args = args;\n }\n\n getApdu(): Apdu {\n const listAppApduArgs: ApduBuilderArgs = {\n cla: 0xe0,\n ins: this.args.isContinue ? 0xdf : 0xde,\n p1: 0x00,\n p2: 0x00,\n };\n return new ApduBuilder(listAppApduArgs).build();\n }\n\n parseResponse(apduResponse: ApduResponse): ListAppsCommandResult {\n const res = [];\n const parser = new ApduParser(apduResponse);\n\n if (!CommandUtils.isSuccessResponse(apduResponse)) {\n const errorCode = parser.encodeToHexaString(apduResponse.statusCode);\n if (isCommandErrorCode(errorCode, LIST_APP_ERRORS)) {\n return CommandResultFactory({\n error: new ListAppsCommandError({\n ...LIST_APP_ERRORS[errorCode],\n errorCode,\n }),\n });\n }\n return CommandResultFactory({\n error: GlobalCommandErrorHandler.handle(apduResponse),\n });\n }\n\n if (apduResponse.data.length <= 0) {\n return CommandResultFactory({\n data: [],\n });\n }\n\n // [NOTE] version of parsing, not used for now, skipping 1 byte\n parser.extract8BitUInt()!;\n\n while (parser.getUnparsedRemainingLength() > 0) {\n const appEntryLength = parser.extract8BitUInt()!;\n const appSizeInBlocks = parser.extract16BitUInt()!;\n parser.extract16BitUInt()!; // Skip 2 bytes (flags, missing in doc for now)\n const appCodeHash = parser.encodeToHexaString(\n parser.extractFieldByLength(0x20), // 32 bytes\n );\n const appFullHash = parser.encodeToHexaString(\n parser.extractFieldByLength(0x20), // 32 bytes\n );\n\n const appName = parser.encodeToString(parser.extractFieldLVEncoded());\n\n res.push({\n appEntryLength,\n appSizeInBlocks,\n appCodeHash,\n appFullHash,\n appName,\n });\n }\n\n return CommandResultFactory({\n data: res,\n });\n }\n}\n"],
5
- "mappings": "AACA,OAAS,eAAAA,MAAyC,8BAClD,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ChDA,EAAO,iBAAiB,EACxB,MAAMG,EAAcH,EAAO,mBACzBA,EAAO,qBAAqB,EAAI,CAClC,EACMI,EAAcJ,EAAO,mBACzBA,EAAO,qBAAqB,EAAI,CAClC,EAEMK,EAAUL,EAAO,eAAeA,EAAO,sBAAsB,CAAC,EAEpED,EAAI,KAAK,CACP,eAAAE,EACA,gBAAAC,EACA,YAAAC,EACA,YAAAC,EACA,QAAAC,CACF,CAAC,CACH,CAEA,OAAOnB,EAAqB,CAC1B,KAAMa,CACR,CAAC,CACH,CACF",
4
+ "sourcesContent": ["import { type Apdu } from \"@api/apdu/model/Apdu\";\nimport { ApduBuilder, type ApduBuilderArgs } from \"@api/apdu/utils/ApduBuilder\";\nimport { ApduParser } from \"@api/apdu/utils/ApduParser\";\nimport { type Command } from \"@api/command/Command\";\nimport {\n type CommandResult,\n CommandResultFactory,\n} from \"@api/command/model/CommandResult\";\nimport {\n type CommandErrors,\n isCommandErrorCode,\n} from \"@api/command/utils/CommandErrors\";\nimport { CommandUtils } from \"@api/command/utils/CommandUtils\";\nimport { GlobalCommandErrorHandler } from \"@api/command/utils/GlobalCommandError\";\nimport { type ApduResponse } from \"@api/device-session/ApduResponse\";\nimport { type CommandErrorArgs, DeviceExchangeError } from \"@api/Error\";\n\nexport type AppResponse = {\n readonly appEntryLength: number;\n readonly appSizeInBlocks: number;\n readonly appCodeHash: string;\n readonly appFullHash: string;\n readonly appName: string;\n};\n\nexport type ListAppsResponse = AppResponse[];\n\nexport type ListAppsArgs = {\n readonly isContinue: boolean;\n};\n\nexport type ListAppsErrorCodes = \"6624\";\n\nconst LIST_APP_ERRORS: CommandErrors<ListAppsErrorCodes> = {\n \"6624\": { message: \"Invalid state (List applications command must be sent)\" },\n};\n\nexport type ListAppsCommandResult = CommandResult<\n ListAppsResponse,\n ListAppsErrorCodes\n>;\n\nexport class ListAppsCommandError extends DeviceExchangeError<ListAppsErrorCodes> {\n constructor({ message, errorCode }: CommandErrorArgs<ListAppsErrorCodes>) {\n super({ message, errorCode, tag: \"ListAppsCommandError\" });\n }\n}\n\nexport class ListAppsCommand\n implements Command<ListAppsResponse, ListAppsArgs, ListAppsErrorCodes>\n{\n readonly name = \"listApps\";\n readonly args: ListAppsArgs;\n\n constructor(args = { isContinue: false }) {\n this.args = args;\n }\n\n getApdu(): Apdu {\n const listAppApduArgs: ApduBuilderArgs = {\n cla: 0xe0,\n ins: this.args.isContinue ? 0xdf : 0xde,\n p1: 0x00,\n p2: 0x00,\n };\n return new ApduBuilder(listAppApduArgs).build();\n }\n\n parseResponse(apduResponse: ApduResponse): ListAppsCommandResult {\n const res = [];\n const parser = new ApduParser(apduResponse);\n\n if (!CommandUtils.isSuccessResponse(apduResponse)) {\n const errorCode = parser.encodeToHexaString(apduResponse.statusCode);\n if (isCommandErrorCode(errorCode, LIST_APP_ERRORS)) {\n return CommandResultFactory({\n error: new ListAppsCommandError({\n ...LIST_APP_ERRORS[errorCode],\n errorCode,\n }),\n });\n }\n return CommandResultFactory({\n error: GlobalCommandErrorHandler.handle(apduResponse),\n });\n }\n\n if (apduResponse.data.length <= 0) {\n return CommandResultFactory({\n data: [],\n });\n }\n\n // [NOTE] version of parsing, not used for now, skipping 1 byte\n parser.extract8BitUInt()!;\n\n while (parser.getUnparsedRemainingLength() > 0) {\n const appEntryLength = parser.extract8BitUInt()!;\n const appSizeInBlocks = parser.extract16BitUInt()!;\n parser.extract16BitUInt()!; // Skip 2 bytes (flags, missing in doc for now)\n const appCodeHash = parser.encodeToHexaString(\n parser.extractFieldByLength(0x20), // 32 bytes\n );\n const appFullHash = parser.encodeToHexaString(\n parser.extractFieldByLength(0x20), // 32 bytes\n );\n\n const appName = parser.encodeToString(parser.extractFieldLVEncoded());\n\n res.push({\n appEntryLength,\n appSizeInBlocks,\n appCodeHash,\n appFullHash,\n appName,\n });\n }\n\n return CommandResultFactory({\n data: res,\n });\n }\n}\n"],
5
+ "mappings": "AACA,OAAS,eAAAA,MAAyC,8BAClD,OAAS,cAAAC,MAA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AAO,iBAAiB,EACxB,MAAMG,EAAcH,EAAO,mBACzBA,EAAO,qBAAqB,EAAI,CAClC,EACMI,EAAcJ,EAAO,mBACzBA,EAAO,qBAAqB,EAAI,CAClC,EAEMK,EAAUL,EAAO,eAAeA,EAAO,sBAAsB,CAAC,EAEpED,EAAI,KAAK,CACP,eAAAE,EACA,gBAAAC,EACA,YAAAC,EACA,YAAAC,EACA,QAAAC,CACF,CAAC,CACH,CAEA,OAAOnB,EAAqB,CAC1B,KAAMa,CACR,CAAC,CACH,CACF",
6
6
  "names": ["ApduBuilder", "ApduParser", "CommandResultFactory", "isCommandErrorCode", "CommandUtils", "GlobalCommandErrorHandler", "DeviceExchangeError", "LIST_APP_ERRORS", "ListAppsCommandError", "message", "errorCode", "ListAppsCommand", "args", "listAppApduArgs", "apduResponse", "res", "parser", "appEntryLength", "appSizeInBlocks", "appCodeHash", "appFullHash", "appName"]
7
7
  }
@@ -1,2 +1,2 @@
1
- import{CommandResultFactory as s,isSuccessCommandResult as r}from"../../command/model/CommandResult";import{ApduResponse as a}from"../../device-session/ApduResponse";import{ListAppsCommand as d,ListAppsCommandError as p}from"./ListAppsCommand";const o=Uint8Array.from([224,222,0,0,0]),c=Uint8Array.from([224,223,0,0,0]),f=Uint8Array.from([1,77,0,19,202,80,162,37,158,3,169,137,73,84,31,243,218,241,134,41,163,15,177,105,175,24,210,113,43,168,184,41,111,241,197,49,15,165,169,126,255,168,22,115,123,175,73,99,90,66,53,112,18,115,75,144,158,39,150,212,231,241,75,44,205,156,164,118,40,52,7,66,105,116,99,111,105,110]),n=[{appEntryLength:77,appSizeInBlocks:19,appCodeHash:"a2259e03a98949541ff3daf18629a30fb169af18d2712ba8b8296ff1c5310fa5",appFullHash:"a97effa816737baf49635a42357012734b909e2796d4e7f14b2ccd9ca4762834",appName:"Bitcoin"}],b=Uint8Array.from([1,77,0,19,202,80,162,37,158,3,169,137,73,84,31,243,218,241,134,41,163,15,177,105,175,24,210,113,43,168,184,41,111,241,197,49,15,165,169,126,255,168,22,115,123,175,73,99,90,66,53,112,18,115,75,144,158,39,150,212,231,241,75,44,205,156,164,118,40,52,7,66,105,116,99,111,105,110,78,0,19,202,64,51,149,37,57,143,228,95,115,200,183,89,238,224,26,124,225,113,61,24,84,77,86,238,72,100,224,73,185,102,230,41,77,199,160,148,112,247,163,120,81,168,172,249,138,218,191,62,44,47,31,126,222,253,49,198,181,77,193,199,220,41,145,216,83,8,69,116,104,101,114,101,117,109]),i=[{appEntryLength:77,appSizeInBlocks:19,appCodeHash:"a2259e03a98949541ff3daf18629a30fb169af18d2712ba8b8296ff1c5310fa5",appFullHash:"a97effa816737baf49635a42357012734b909e2796d4e7f14b2ccd9ca4762834",appName:"Bitcoin"},{appEntryLength:78,appSizeInBlocks:19,appCodeHash:"339525398fe45f73c8b759eee01a7ce1713d18544d56ee4864e049b966e6294d",appFullHash:"c7a09470f7a37851a8acf98adabf3e2c2f1f7edefd31c6b54dc1c7dc2991d853",appName:"Ethereum"}],u=Uint8Array.from([1,77,0,1,202,64,220,134,34,156,121,10,224,62,185,19,9,238,28,148,96,10,109,223,73,10,157,105,11,251,10,47,2,2,14,187,76,31,180,194,230,27,174,27,171,43,115,71,223,59,59,26,47,217,241,251,175,251,58,165,248,170,35,62,210,191,170,188,193,62,7,80,111,108,121,103,111,110]),A=[{appEntryLength:77,appSizeInBlocks:1,appCodeHash:"dc86229c790ae03eb91309ee1c94600a6ddf490a9d690bfb0a2f02020ebb4c1f",appFullHash:"b4c2e61bae1bab2b7347df3b3b1a2fd9f1fbaffb3aa5f8aa233ed2bfaabcc13e",appName:"Polygon"}],l=Uint8Array.from([1,89,0,1,202,64,251,43,125,38,37,215,24,132,39,7,5,83,16,128,194,24,40,121,221,30,217,227,75,22,186,228,208,118,155,69,215,216,215,91,55,95,106,51,161,230,117,121,38,154,22,239,68,36,163,217,32,82,21,182,21,43,106,216,188,201,14,60,50,249,19,66,105,110,97,110,99,101,32,83,109,97,114,116,32,67,104,97,105,110,76,0,14,202,0,254,230,25,86,26,175,67,41,98,12,2,216,72,142,63,117,164,53,51,23,34,245,97,21,121,247,83,151,128,148,209,20,204,191,178,86,114,154,158,40,116,183,35,214,76,228,135,243,87,239,167,22,178,208,205,52,152,151,233,110,116,32,42,202,6,83,111,108,97,110,97]),E=[{appEntryLength:89,appSizeInBlocks:1,appCodeHash:"fb2b7d2625d71884270705531080c2182879dd1ed9e34b16bae4d0769b45d7d8",appFullHash:"d75b375f6a33a1e67579269a16ef4424a3d9205215b6152b6ad8bcc90e3c32f9",appName:"Binance Smart Chain"},{appEntryLength:76,appSizeInBlocks:14,appCodeHash:"fee619561aaf4329620c02d8488e3f75a435331722f5611579f753978094d114",appFullHash:"ccbfb256729a9e2874b723d64ce487f357efa716b2d0cd349897e96e74202aca",appName:"Solana"}];describe("ListAppCommand",()=>{let e;describe("first list app command",()=>{beforeEach(()=>{e=new d}),describe("getApdu",()=>{it("should return the ListApp APDU",()=>{const x=e.getApdu();expect(x.getRawApdu()).toStrictEqual(o)})}),describe("parseResponse",()=>{it("should parse the response with no apps",()=>{const x=new a({statusCode:Uint8Array.from([144,0]),data:new Uint8Array});expect(e.parseResponse(x)).toStrictEqual(s({data:[]}))}),it("should parse the response with 1 app",()=>{const x=new a({statusCode:Uint8Array.from([144,0]),data:f});expect(e.parseResponse(x)).toStrictEqual(s({data:n}))}),it("should parse the response with 2 apps",()=>{const x=new a({statusCode:Uint8Array.from([144,0]),data:b});expect(e.parseResponse(x)).toStrictEqual(s({data:i}))})}),describe("errors",()=>{it("should return error command result if the response status code is not success",()=>{const x=new a({statusCode:Uint8Array.from([106,130]),data:new Uint8Array}),t=e.parseResponse(x);expect(r(t)).toBe(!1)}),it("should return an error",()=>{const x=new a({statusCode:Uint8Array.from([85,1]),data:new Uint8Array}),t=e.parseResponse(x);expect(r(t)).toBe(!1)})})}),describe("continue list app command",()=>{beforeEach(()=>{e=new d({isContinue:!0})}),describe("getApdu",()=>{it("should return the Continue ListApp APDU",()=>{const x=e.getApdu();expect(x.getRawApdu()).toStrictEqual(c)})}),describe("parseResponse",()=>{it("should parse the response with 1 app",()=>{const x=new a({statusCode:Uint8Array.from([144,0]),data:u});expect(e.parseResponse(x)).toStrictEqual(s({data:A}))}),it("should parse the response with 2 apps",()=>{const x=new a({statusCode:Uint8Array.from([144,0]),data:l});expect(e.parseResponse(x)).toStrictEqual(s({data:E}))}),it("should parse the response when reaching the end of the list",()=>{const x=new a({statusCode:Uint8Array.from([144,0]),data:new Uint8Array});expect(e.parseResponse(x)).toStrictEqual(s({data:[]}))})}),describe("errors",()=>{it("should throw if ListApp wasn't called before",()=>{const x=new a({statusCode:Uint8Array.from([102,36]),data:new Uint8Array}),t=e.parseResponse(x);expect(r(t)).toBe(!1),expect(t.error).toBeInstanceOf(p)})})})});
1
+ import{CommandResultFactory as s,isSuccessCommandResult as r}from"../../command/model/CommandResult";import{ApduResponse as a}from"../../device-session/ApduResponse";import{ListAppsCommand as p,ListAppsCommandError as d}from"./ListAppsCommand";const o=Uint8Array.from([224,222,0,0,0]),c=Uint8Array.from([224,223,0,0,0]),f=Uint8Array.from([1,77,0,19,202,80,162,37,158,3,169,137,73,84,31,243,218,241,134,41,163,15,177,105,175,24,210,113,43,168,184,41,111,241,197,49,15,165,169,126,255,168,22,115,123,175,73,99,90,66,53,112,18,115,75,144,158,39,150,212,231,241,75,44,205,156,164,118,40,52,7,66,105,116,99,111,105,110]),n=[{appEntryLength:77,appSizeInBlocks:19,appCodeHash:"a2259e03a98949541ff3daf18629a30fb169af18d2712ba8b8296ff1c5310fa5",appFullHash:"a97effa816737baf49635a42357012734b909e2796d4e7f14b2ccd9ca4762834",appName:"Bitcoin"}],b=Uint8Array.from([1,77,0,19,202,80,162,37,158,3,169,137,73,84,31,243,218,241,134,41,163,15,177,105,175,24,210,113,43,168,184,41,111,241,197,49,15,165,169,126,255,168,22,115,123,175,73,99,90,66,53,112,18,115,75,144,158,39,150,212,231,241,75,44,205,156,164,118,40,52,7,66,105,116,99,111,105,110,78,0,19,202,64,51,149,37,57,143,228,95,115,200,183,89,238,224,26,124,225,113,61,24,84,77,86,238,72,100,224,73,185,102,230,41,77,199,160,148,112,247,163,120,81,168,172,249,138,218,191,62,44,47,31,126,222,253,49,198,181,77,193,199,220,41,145,216,83,8,69,116,104,101,114,101,117,109]),i=[{appEntryLength:77,appSizeInBlocks:19,appCodeHash:"a2259e03a98949541ff3daf18629a30fb169af18d2712ba8b8296ff1c5310fa5",appFullHash:"a97effa816737baf49635a42357012734b909e2796d4e7f14b2ccd9ca4762834",appName:"Bitcoin"},{appEntryLength:78,appSizeInBlocks:19,appCodeHash:"339525398fe45f73c8b759eee01a7ce1713d18544d56ee4864e049b966e6294d",appFullHash:"c7a09470f7a37851a8acf98adabf3e2c2f1f7edefd31c6b54dc1c7dc2991d853",appName:"Ethereum"}],u=Uint8Array.from([1,77,0,1,202,64,220,134,34,156,121,10,224,62,185,19,9,238,28,148,96,10,109,223,73,10,157,105,11,251,10,47,2,2,14,187,76,31,180,194,230,27,174,27,171,43,115,71,223,59,59,26,47,217,241,251,175,251,58,165,248,170,35,62,210,191,170,188,193,62,7,80,111,108,121,103,111,110]),A=[{appEntryLength:77,appSizeInBlocks:1,appCodeHash:"dc86229c790ae03eb91309ee1c94600a6ddf490a9d690bfb0a2f02020ebb4c1f",appFullHash:"b4c2e61bae1bab2b7347df3b3b1a2fd9f1fbaffb3aa5f8aa233ed2bfaabcc13e",appName:"Polygon"}],l=Uint8Array.from([1,89,0,1,202,64,251,43,125,38,37,215,24,132,39,7,5,83,16,128,194,24,40,121,221,30,217,227,75,22,186,228,208,118,155,69,215,216,215,91,55,95,106,51,161,230,117,121,38,154,22,239,68,36,163,217,32,82,21,182,21,43,106,216,188,201,14,60,50,249,19,66,105,110,97,110,99,101,32,83,109,97,114,116,32,67,104,97,105,110,76,0,14,202,0,254,230,25,86,26,175,67,41,98,12,2,216,72,142,63,117,164,53,51,23,34,245,97,21,121,247,83,151,128,148,209,20,204,191,178,86,114,154,158,40,116,183,35,214,76,228,135,243,87,239,167,22,178,208,205,52,152,151,233,110,116,32,42,202,6,83,111,108,97,110,97]),m=[{appEntryLength:89,appSizeInBlocks:1,appCodeHash:"fb2b7d2625d71884270705531080c2182879dd1ed9e34b16bae4d0769b45d7d8",appFullHash:"d75b375f6a33a1e67579269a16ef4424a3d9205215b6152b6ad8bcc90e3c32f9",appName:"Binance Smart Chain"},{appEntryLength:76,appSizeInBlocks:14,appCodeHash:"fee619561aaf4329620c02d8488e3f75a435331722f5611579f753978094d114",appFullHash:"ccbfb256729a9e2874b723d64ce487f357efa716b2d0cd349897e96e74202aca",appName:"Solana"}];describe("ListAppCommand",()=>{let e;describe("name",()=>{it("should be 'listApps'",()=>{expect(new p().name).toBe("listApps")})}),describe("first list app command",()=>{beforeEach(()=>{e=new p}),describe("getApdu",()=>{it("should return the ListApp APDU",()=>{const x=e.getApdu();expect(x.getRawApdu()).toStrictEqual(o)})}),describe("parseResponse",()=>{it("should parse the response with no apps",()=>{const x=new a({statusCode:Uint8Array.from([144,0]),data:new Uint8Array});expect(e.parseResponse(x)).toStrictEqual(s({data:[]}))}),it("should parse the response with 1 app",()=>{const x=new a({statusCode:Uint8Array.from([144,0]),data:f});expect(e.parseResponse(x)).toStrictEqual(s({data:n}))}),it("should parse the response with 2 apps",()=>{const x=new a({statusCode:Uint8Array.from([144,0]),data:b});expect(e.parseResponse(x)).toStrictEqual(s({data:i}))})}),describe("errors",()=>{it("should return error command result if the response status code is not success",()=>{const x=new a({statusCode:Uint8Array.from([106,130]),data:new Uint8Array}),t=e.parseResponse(x);expect(r(t)).toBe(!1)}),it("should return an error",()=>{const x=new a({statusCode:Uint8Array.from([85,1]),data:new Uint8Array}),t=e.parseResponse(x);expect(r(t)).toBe(!1)})})}),describe("continue list app command",()=>{beforeEach(()=>{e=new p({isContinue:!0})}),describe("getApdu",()=>{it("should return the Continue ListApp APDU",()=>{const x=e.getApdu();expect(x.getRawApdu()).toStrictEqual(c)})}),describe("parseResponse",()=>{it("should parse the response with 1 app",()=>{const x=new a({statusCode:Uint8Array.from([144,0]),data:u});expect(e.parseResponse(x)).toStrictEqual(s({data:A}))}),it("should parse the response with 2 apps",()=>{const x=new a({statusCode:Uint8Array.from([144,0]),data:l});expect(e.parseResponse(x)).toStrictEqual(s({data:m}))}),it("should parse the response when reaching the end of the list",()=>{const x=new a({statusCode:Uint8Array.from([144,0]),data:new Uint8Array});expect(e.parseResponse(x)).toStrictEqual(s({data:[]}))})}),describe("errors",()=>{it("should throw if ListApp wasn't called before",()=>{const x=new a({statusCode:Uint8Array.from([102,36]),data:new Uint8Array}),t=e.parseResponse(x);expect(r(t)).toBe(!1),expect(t.error).toBeInstanceOf(d)})})})});
2
2
  //# sourceMappingURL=ListAppsCommand.test.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../../../src/api/command/os/ListAppsCommand.test.ts"],
4
- "sourcesContent": ["import {\n type CommandErrorResult,\n CommandResultFactory,\n isSuccessCommandResult,\n} from \"@api/command/model/CommandResult\";\nimport { ApduResponse } from \"@api/device-session/ApduResponse\";\n\nimport {\n ListAppsCommand,\n ListAppsCommandError,\n type ListAppsErrorCodes,\n} from \"./ListAppsCommand\";\n\n// [NOTE] EXAMPLES CREATED USING A NANO X\n\nconst LIST_APP_APDU = Uint8Array.from([0xe0, 0xde, 0x00, 0x00, 0x00]);\nconst CONTINUE_LIST_APP_ADPU = Uint8Array.from([0xe0, 0xdf, 0x00, 0x00, 0x00]);\n\n// only BITCOIN installed\nconst LIST_APP_RESPONSE_1_APP = Uint8Array.from([\n 0x01, 0x4d, 0x00, 0x13, 0xca, 0x50, 0xa2, 0x25, 0x9e, 0x03, 0xa9, 0x89, 0x49,\n 0x54, 0x1f, 0xf3, 0xda, 0xf1, 0x86, 0x29, 0xa3, 0x0f, 0xb1, 0x69, 0xaf, 0x18,\n 0xd2, 0x71, 0x2b, 0xa8, 0xb8, 0x29, 0x6f, 0xf1, 0xc5, 0x31, 0x0f, 0xa5, 0xa9,\n 0x7e, 0xff, 0xa8, 0x16, 0x73, 0x7b, 0xaf, 0x49, 0x63, 0x5a, 0x42, 0x35, 0x70,\n 0x12, 0x73, 0x4b, 0x90, 0x9e, 0x27, 0x96, 0xd4, 0xe7, 0xf1, 0x4b, 0x2c, 0xcd,\n 0x9c, 0xa4, 0x76, 0x28, 0x34, 0x07, 0x42, 0x69, 0x74, 0x63, 0x6f, 0x69, 0x6e,\n]);\nconst LIST_APP_RESPONSE_1_APP_EXPECTED = [\n {\n appEntryLength: 77,\n appSizeInBlocks: 19,\n appCodeHash:\n \"a2259e03a98949541ff3daf18629a30fb169af18d2712ba8b8296ff1c5310fa5\",\n appFullHash:\n \"a97effa816737baf49635a42357012734b909e2796d4e7f14b2ccd9ca4762834\",\n appName: \"Bitcoin\",\n },\n];\n\n// BITCOIN & ETHEREUM installed\nconst LIST_APP_RESPONSE_2_APPS = Uint8Array.from([\n 0x01, 0x4d, 0x00, 0x13, 0xca, 0x50, 0xa2, 0x25, 0x9e, 0x03, 0xa9, 0x89, 0x49,\n 0x54, 0x1f, 0xf3, 0xda, 0xf1, 0x86, 0x29, 0xa3, 0x0f, 0xb1, 0x69, 0xaf, 0x18,\n 0xd2, 0x71, 0x2b, 0xa8, 0xb8, 0x29, 0x6f, 0xf1, 0xc5, 0x31, 0x0f, 0xa5, 0xa9,\n 0x7e, 0xff, 0xa8, 0x16, 0x73, 0x7b, 0xaf, 0x49, 0x63, 0x5a, 0x42, 0x35, 0x70,\n 0x12, 0x73, 0x4b, 0x90, 0x9e, 0x27, 0x96, 0xd4, 0xe7, 0xf1, 0x4b, 0x2c, 0xcd,\n 0x9c, 0xa4, 0x76, 0x28, 0x34, 0x07, 0x42, 0x69, 0x74, 0x63, 0x6f, 0x69, 0x6e,\n 0x4e, 0x00, 0x13, 0xca, 0x40, 0x33, 0x95, 0x25, 0x39, 0x8f, 0xe4, 0x5f, 0x73,\n 0xc8, 0xb7, 0x59, 0xee, 0xe0, 0x1a, 0x7c, 0xe1, 0x71, 0x3d, 0x18, 0x54, 0x4d,\n 0x56, 0xee, 0x48, 0x64, 0xe0, 0x49, 0xb9, 0x66, 0xe6, 0x29, 0x4d, 0xc7, 0xa0,\n 0x94, 0x70, 0xf7, 0xa3, 0x78, 0x51, 0xa8, 0xac, 0xf9, 0x8a, 0xda, 0xbf, 0x3e,\n 0x2c, 0x2f, 0x1f, 0x7e, 0xde, 0xfd, 0x31, 0xc6, 0xb5, 0x4d, 0xc1, 0xc7, 0xdc,\n 0x29, 0x91, 0xd8, 0x53, 0x08, 0x45, 0x74, 0x68, 0x65, 0x72, 0x65, 0x75, 0x6d,\n]);\nconst LIST_APP_RESPONSE_2_APPS_EXPECTED = [\n {\n appEntryLength: 77,\n appSizeInBlocks: 19,\n appCodeHash:\n \"a2259e03a98949541ff3daf18629a30fb169af18d2712ba8b8296ff1c5310fa5\",\n appFullHash:\n \"a97effa816737baf49635a42357012734b909e2796d4e7f14b2ccd9ca4762834\",\n appName: \"Bitcoin\",\n },\n {\n appEntryLength: 78,\n appSizeInBlocks: 19,\n appCodeHash:\n \"339525398fe45f73c8b759eee01a7ce1713d18544d56ee4864e049b966e6294d\",\n appFullHash:\n \"c7a09470f7a37851a8acf98adabf3e2c2f1f7edefd31c6b54dc1c7dc2991d853\",\n appName: \"Ethereum\",\n },\n];\n\n// POLYGON as the last installed app\nconst LIST_APP_RESPONSE_CONTINUE_1_APP = Uint8Array.from([\n 0x01, 0x4d, 0x00, 0x01, 0xca, 0x40, 0xdc, 0x86, 0x22, 0x9c, 0x79, 0x0a, 0xe0,\n 0x3e, 0xb9, 0x13, 0x09, 0xee, 0x1c, 0x94, 0x60, 0x0a, 0x6d, 0xdf, 0x49, 0x0a,\n 0x9d, 0x69, 0x0b, 0xfb, 0x0a, 0x2f, 0x02, 0x02, 0x0e, 0xbb, 0x4c, 0x1f, 0xb4,\n 0xc2, 0xe6, 0x1b, 0xae, 0x1b, 0xab, 0x2b, 0x73, 0x47, 0xdf, 0x3b, 0x3b, 0x1a,\n 0x2f, 0xd9, 0xf1, 0xfb, 0xaf, 0xfb, 0x3a, 0xa5, 0xf8, 0xaa, 0x23, 0x3e, 0xd2,\n 0xbf, 0xaa, 0xbc, 0xc1, 0x3e, 0x07, 0x50, 0x6f, 0x6c, 0x79, 0x67, 0x6f, 0x6e,\n]);\nconst LIST_APP_RESPONSE_CONTINUE_1_APP_EXPECTED = [\n {\n appEntryLength: 77,\n appSizeInBlocks: 1,\n appCodeHash:\n \"dc86229c790ae03eb91309ee1c94600a6ddf490a9d690bfb0a2f02020ebb4c1f\",\n appFullHash:\n \"b4c2e61bae1bab2b7347df3b3b1a2fd9f1fbaffb3aa5f8aa233ed2bfaabcc13e\",\n appName: \"Polygon\",\n },\n];\n\n// BINANCE SMART CHAIN & SOLANA installed\nconst LIST_APP_RESPONSE_CONTINUE_2_APPS = Uint8Array.from([\n 0x01, 0x59, 0x00, 0x01, 0xca, 0x40, 0xfb, 0x2b, 0x7d, 0x26, 0x25, 0xd7, 0x18,\n 0x84, 0x27, 0x07, 0x05, 0x53, 0x10, 0x80, 0xc2, 0x18, 0x28, 0x79, 0xdd, 0x1e,\n 0xd9, 0xe3, 0x4b, 0x16, 0xba, 0xe4, 0xd0, 0x76, 0x9b, 0x45, 0xd7, 0xd8, 0xd7,\n 0x5b, 0x37, 0x5f, 0x6a, 0x33, 0xa1, 0xe6, 0x75, 0x79, 0x26, 0x9a, 0x16, 0xef,\n 0x44, 0x24, 0xa3, 0xd9, 0x20, 0x52, 0x15, 0xb6, 0x15, 0x2b, 0x6a, 0xd8, 0xbc,\n 0xc9, 0x0e, 0x3c, 0x32, 0xf9, 0x13, 0x42, 0x69, 0x6e, 0x61, 0x6e, 0x63, 0x65,\n 0x20, 0x53, 0x6d, 0x61, 0x72, 0x74, 0x20, 0x43, 0x68, 0x61, 0x69, 0x6e, 0x4c,\n 0x00, 0x0e, 0xca, 0x00, 0xfe, 0xe6, 0x19, 0x56, 0x1a, 0xaf, 0x43, 0x29, 0x62,\n 0x0c, 0x02, 0xd8, 0x48, 0x8e, 0x3f, 0x75, 0xa4, 0x35, 0x33, 0x17, 0x22, 0xf5,\n 0x61, 0x15, 0x79, 0xf7, 0x53, 0x97, 0x80, 0x94, 0xd1, 0x14, 0xcc, 0xbf, 0xb2,\n 0x56, 0x72, 0x9a, 0x9e, 0x28, 0x74, 0xb7, 0x23, 0xd6, 0x4c, 0xe4, 0x87, 0xf3,\n 0x57, 0xef, 0xa7, 0x16, 0xb2, 0xd0, 0xcd, 0x34, 0x98, 0x97, 0xe9, 0x6e, 0x74,\n 0x20, 0x2a, 0xca, 0x06, 0x53, 0x6f, 0x6c, 0x61, 0x6e, 0x61,\n]);\nconst LIST_APP_RESPONSE_CONTINUE_2_APPS_EXPECTED = [\n {\n appEntryLength: 89,\n appSizeInBlocks: 1,\n appCodeHash:\n \"fb2b7d2625d71884270705531080c2182879dd1ed9e34b16bae4d0769b45d7d8\",\n appFullHash:\n \"d75b375f6a33a1e67579269a16ef4424a3d9205215b6152b6ad8bcc90e3c32f9\",\n appName: \"Binance Smart Chain\",\n },\n {\n appEntryLength: 76,\n appSizeInBlocks: 14,\n appCodeHash:\n \"fee619561aaf4329620c02d8488e3f75a435331722f5611579f753978094d114\",\n appFullHash:\n \"ccbfb256729a9e2874b723d64ce487f357efa716b2d0cd349897e96e74202aca\",\n appName: \"Solana\",\n },\n];\n\ndescribe(\"ListAppCommand\", () => {\n let command: ListAppsCommand;\n\n describe(\"first list app command\", () => {\n beforeEach(() => {\n command = new ListAppsCommand();\n });\n\n describe(\"getApdu\", () => {\n it(\"should return the ListApp APDU\", () => {\n const apdu = command.getApdu();\n expect(apdu.getRawApdu()).toStrictEqual(LIST_APP_APDU);\n });\n });\n\n describe(\"parseResponse\", () => {\n it(\"should parse the response with no apps\", () => {\n const response = new ApduResponse({\n statusCode: Uint8Array.from([0x90, 0x00]),\n data: new Uint8Array(),\n });\n\n expect(command.parseResponse(response)).toStrictEqual(\n CommandResultFactory({ data: [] }),\n );\n });\n\n it(\"should parse the response with 1 app\", () => {\n const response = new ApduResponse({\n statusCode: Uint8Array.from([0x90, 0x00]),\n data: LIST_APP_RESPONSE_1_APP,\n });\n\n expect(command.parseResponse(response)).toStrictEqual(\n CommandResultFactory({ data: LIST_APP_RESPONSE_1_APP_EXPECTED }),\n );\n });\n\n it(\"should parse the response with 2 apps\", () => {\n const response = new ApduResponse({\n statusCode: Uint8Array.from([0x90, 0x00]),\n data: LIST_APP_RESPONSE_2_APPS,\n });\n\n expect(command.parseResponse(response)).toStrictEqual(\n CommandResultFactory({ data: LIST_APP_RESPONSE_2_APPS_EXPECTED }),\n );\n });\n });\n\n describe(\"errors\", () => {\n it(\"should return error command result if the response status code is not success\", () => {\n const response = new ApduResponse({\n statusCode: Uint8Array.from([0x6a, 0x82]),\n data: new Uint8Array(),\n });\n const result = command.parseResponse(response);\n\n expect(isSuccessCommandResult(result)).toBe(false);\n });\n\n it(\"should return an error\", () => {\n const response = new ApduResponse({\n statusCode: Uint8Array.from([0x55, 0x01]),\n data: new Uint8Array(),\n });\n\n // when\n const result = command.parseResponse(response);\n\n expect(isSuccessCommandResult(result)).toBe(false);\n });\n });\n });\n\n describe(\"continue list app command\", () => {\n beforeEach(() => {\n command = new ListAppsCommand({ isContinue: true });\n });\n\n describe(\"getApdu\", () => {\n it(\"should return the Continue ListApp APDU\", () => {\n const apdu = command.getApdu();\n expect(apdu.getRawApdu()).toStrictEqual(CONTINUE_LIST_APP_ADPU);\n });\n });\n\n describe(\"parseResponse\", () => {\n it(\"should parse the response with 1 app\", () => {\n const response = new ApduResponse({\n statusCode: Uint8Array.from([0x90, 0x00]),\n data: LIST_APP_RESPONSE_CONTINUE_1_APP,\n });\n\n expect(command.parseResponse(response)).toStrictEqual(\n CommandResultFactory({\n data: LIST_APP_RESPONSE_CONTINUE_1_APP_EXPECTED,\n }),\n );\n });\n\n it(\"should parse the response with 2 apps\", () => {\n const response = new ApduResponse({\n statusCode: Uint8Array.from([0x90, 0x00]),\n data: LIST_APP_RESPONSE_CONTINUE_2_APPS,\n });\n\n expect(command.parseResponse(response)).toStrictEqual(\n CommandResultFactory({\n data: LIST_APP_RESPONSE_CONTINUE_2_APPS_EXPECTED,\n }),\n );\n });\n\n it(\"should parse the response when reaching the end of the list\", () => {\n const response = new ApduResponse({\n statusCode: Uint8Array.from([0x90, 0x00]),\n data: new Uint8Array(),\n });\n\n expect(command.parseResponse(response)).toStrictEqual(\n CommandResultFactory({ data: [] }),\n );\n });\n });\n\n describe(\"errors\", () => {\n it(\"should throw if ListApp wasn't called before\", () => {\n const response = new ApduResponse({\n statusCode: Uint8Array.from([0x66, 0x24]),\n data: new Uint8Array(),\n });\n const result = command.parseResponse(\n response,\n ) as CommandErrorResult<ListAppsErrorCodes>;\n\n expect(isSuccessCommandResult(result)).toBe(false);\n expect(result.error).toBeInstanceOf(ListAppsCommandError);\n });\n });\n });\n});\n"],
5
- "mappings": "AAAA,OAEE,wBAAAA,EACA,0BAAAC,MACK,mCACP,OAAS,gBAAAC,MAAoB,mCAE7B,OACE,mBAAAC,EACA,wBAAAC,MAEK,oBAIP,MAAMC,EAAgB,WAAW,KAAK,CAAC,IAAM,IAAM,EAAM,EAAM,CAAI,CAAC,EAC9DC,EAAyB,WAAW,KAAK,CAAC,IAAM,IAAM,EAAM,EAAM,CAAI,CAAC,EAGvEC,EAA0B,WAAW,KAAK,CAC9C,EAAM,GAAM,EAAM,GAAM,IAAM,GAAM,IAAM,GAAM,IAAM,EAAM,IAAM,IAAM,GACxE,GAAM,GAAM,IAAM,IAAM,IAAM,IAAM,GAAM,IAAM,GAAM,IAAM,IAAM,IAAM,GACxE,IAAM,IAAM,GAAM,IAAM,IAAM,GAAM,IAAM,IAAM,IAAM,GAAM,GAAM,IAAM,IACxE,IAAM,IAAM,IAAM,GAAM,IAAM,IAAM,IAAM,GAAM,GAAM,GAAM,GAAM,GAAM,IACxE,GAAM,IAAM,GAAM,IAAM,IAAM,GAAM,IAAM,IA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E,cAAcV,CAAsB,CAChE,CAAC,CACH,CAAC,EAED,SAAS,gBAAiB,IAAM,CAC9B,GAAG,uCAAwC,IAAM,CAC/C,MAAMW,EAAW,IAAIf,EAAa,CAChC,WAAY,WAAW,KAAK,CAAC,IAAM,CAAI,CAAC,EACxC,KAAMS,CACR,CAAC,EAED,OAAOI,EAAQ,cAAcE,CAAQ,CAAC,EAAE,cACtCjB,EAAqB,CACnB,KAAMY,CACR,CAAC,CACH,CACF,CAAC,EAED,GAAG,wCAAyC,IAAM,CAChD,MAAMK,EAAW,IAAIf,EAAa,CAChC,WAAY,WAAW,KAAK,CAAC,IAAM,CAAI,CAAC,EACxC,KAAMW,CACR,CAAC,EAED,OAAOE,EAAQ,cAAcE,CAAQ,CAAC,EAAE,cACtCjB,EAAqB,CACnB,KAAMc,CACR,CAAC,CACH,CACF,CAAC,EAED,GAAG,8DAA+D,IAAM,CACtE,MAAMG,EAAW,IAAIf,EAAa,CAChC,WAAY,WAAW,KAAK,CAAC,IAAM,CAAI,CAAC,EACxC,KAAM,IAAI,UACZ,CAAC,EAED,OAAOa,EAAQ,cAAcE,CAAQ,CAAC,EAAE,cACtCjB,EAAqB,CAAE,KAAM,CAAC,CAAE,CAAC,CACnC,CACF,CAAC,CACH,CAAC,EAED,SAAS,SAAU,IAAM,CACvB,GAAG,+CAAgD,IAAM,CACvD,MAAMiB,EAAW,IAAIf,EAAa,CAChC,WAAY,WAAW,KAAK,CAAC,IAAM,EAAI,CAAC,EACxC,KAAM,IAAI,UACZ,CAAC,EACKgB,EAASH,EAAQ,cACrBE,CACF,EAEA,OAAOhB,EAAuBiB,CAAM,CAAC,EAAE,KAAK,EAAK,EACjD,OAAOA,EAAO,KAAK,EAAE,eAAed,CAAoB,CAC1D,CAAC,CACH,CAAC,CACH,CAAC,CACH,CAAC",
4
+ "sourcesContent": ["import {\n type CommandErrorResult,\n CommandResultFactory,\n isSuccessCommandResult,\n} from \"@api/command/model/CommandResult\";\nimport { ApduResponse } from \"@api/device-session/ApduResponse\";\n\nimport {\n ListAppsCommand,\n ListAppsCommandError,\n type ListAppsErrorCodes,\n} from \"./ListAppsCommand\";\n\n// [NOTE] EXAMPLES CREATED USING A NANO X\n\nconst LIST_APP_APDU = Uint8Array.from([0xe0, 0xde, 0x00, 0x00, 0x00]);\nconst CONTINUE_LIST_APP_ADPU = Uint8Array.from([0xe0, 0xdf, 0x00, 0x00, 0x00]);\n\n// only BITCOIN installed\nconst LIST_APP_RESPONSE_1_APP = Uint8Array.from([\n 0x01, 0x4d, 0x00, 0x13, 0xca, 0x50, 0xa2, 0x25, 0x9e, 0x03, 0xa9, 0x89, 0x49,\n 0x54, 0x1f, 0xf3, 0xda, 0xf1, 0x86, 0x29, 0xa3, 0x0f, 0xb1, 0x69, 0xaf, 0x18,\n 0xd2, 0x71, 0x2b, 0xa8, 0xb8, 0x29, 0x6f, 0xf1, 0xc5, 0x31, 0x0f, 0xa5, 0xa9,\n 0x7e, 0xff, 0xa8, 0x16, 0x73, 0x7b, 0xaf, 0x49, 0x63, 0x5a, 0x42, 0x35, 0x70,\n 0x12, 0x73, 0x4b, 0x90, 0x9e, 0x27, 0x96, 0xd4, 0xe7, 0xf1, 0x4b, 0x2c, 0xcd,\n 0x9c, 0xa4, 0x76, 0x28, 0x34, 0x07, 0x42, 0x69, 0x74, 0x63, 0x6f, 0x69, 0x6e,\n]);\nconst LIST_APP_RESPONSE_1_APP_EXPECTED = [\n {\n appEntryLength: 77,\n appSizeInBlocks: 19,\n appCodeHash:\n \"a2259e03a98949541ff3daf18629a30fb169af18d2712ba8b8296ff1c5310fa5\",\n appFullHash:\n \"a97effa816737baf49635a42357012734b909e2796d4e7f14b2ccd9ca4762834\",\n appName: \"Bitcoin\",\n },\n];\n\n// BITCOIN & ETHEREUM installed\nconst LIST_APP_RESPONSE_2_APPS = Uint8Array.from([\n 0x01, 0x4d, 0x00, 0x13, 0xca, 0x50, 0xa2, 0x25, 0x9e, 0x03, 0xa9, 0x89, 0x49,\n 0x54, 0x1f, 0xf3, 0xda, 0xf1, 0x86, 0x29, 0xa3, 0x0f, 0xb1, 0x69, 0xaf, 0x18,\n 0xd2, 0x71, 0x2b, 0xa8, 0xb8, 0x29, 0x6f, 0xf1, 0xc5, 0x31, 0x0f, 0xa5, 0xa9,\n 0x7e, 0xff, 0xa8, 0x16, 0x73, 0x7b, 0xaf, 0x49, 0x63, 0x5a, 0x42, 0x35, 0x70,\n 0x12, 0x73, 0x4b, 0x90, 0x9e, 0x27, 0x96, 0xd4, 0xe7, 0xf1, 0x4b, 0x2c, 0xcd,\n 0x9c, 0xa4, 0x76, 0x28, 0x34, 0x07, 0x42, 0x69, 0x74, 0x63, 0x6f, 0x69, 0x6e,\n 0x4e, 0x00, 0x13, 0xca, 0x40, 0x33, 0x95, 0x25, 0x39, 0x8f, 0xe4, 0x5f, 0x73,\n 0xc8, 0xb7, 0x59, 0xee, 0xe0, 0x1a, 0x7c, 0xe1, 0x71, 0x3d, 0x18, 0x54, 0x4d,\n 0x56, 0xee, 0x48, 0x64, 0xe0, 0x49, 0xb9, 0x66, 0xe6, 0x29, 0x4d, 0xc7, 0xa0,\n 0x94, 0x70, 0xf7, 0xa3, 0x78, 0x51, 0xa8, 0xac, 0xf9, 0x8a, 0xda, 0xbf, 0x3e,\n 0x2c, 0x2f, 0x1f, 0x7e, 0xde, 0xfd, 0x31, 0xc6, 0xb5, 0x4d, 0xc1, 0xc7, 0xdc,\n 0x29, 0x91, 0xd8, 0x53, 0x08, 0x45, 0x74, 0x68, 0x65, 0x72, 0x65, 0x75, 0x6d,\n]);\nconst LIST_APP_RESPONSE_2_APPS_EXPECTED = [\n {\n appEntryLength: 77,\n appSizeInBlocks: 19,\n appCodeHash:\n \"a2259e03a98949541ff3daf18629a30fb169af18d2712ba8b8296ff1c5310fa5\",\n appFullHash:\n \"a97effa816737baf49635a42357012734b909e2796d4e7f14b2ccd9ca4762834\",\n appName: \"Bitcoin\",\n },\n {\n appEntryLength: 78,\n appSizeInBlocks: 19,\n appCodeHash:\n \"339525398fe45f73c8b759eee01a7ce1713d18544d56ee4864e049b966e6294d\",\n appFullHash:\n \"c7a09470f7a37851a8acf98adabf3e2c2f1f7edefd31c6b54dc1c7dc2991d853\",\n appName: \"Ethereum\",\n },\n];\n\n// POLYGON as the last installed app\nconst LIST_APP_RESPONSE_CONTINUE_1_APP = Uint8Array.from([\n 0x01, 0x4d, 0x00, 0x01, 0xca, 0x40, 0xdc, 0x86, 0x22, 0x9c, 0x79, 0x0a, 0xe0,\n 0x3e, 0xb9, 0x13, 0x09, 0xee, 0x1c, 0x94, 0x60, 0x0a, 0x6d, 0xdf, 0x49, 0x0a,\n 0x9d, 0x69, 0x0b, 0xfb, 0x0a, 0x2f, 0x02, 0x02, 0x0e, 0xbb, 0x4c, 0x1f, 0xb4,\n 0xc2, 0xe6, 0x1b, 0xae, 0x1b, 0xab, 0x2b, 0x73, 0x47, 0xdf, 0x3b, 0x3b, 0x1a,\n 0x2f, 0xd9, 0xf1, 0xfb, 0xaf, 0xfb, 0x3a, 0xa5, 0xf8, 0xaa, 0x23, 0x3e, 0xd2,\n 0xbf, 0xaa, 0xbc, 0xc1, 0x3e, 0x07, 0x50, 0x6f, 0x6c, 0x79, 0x67, 0x6f, 0x6e,\n]);\nconst LIST_APP_RESPONSE_CONTINUE_1_APP_EXPECTED = [\n {\n appEntryLength: 77,\n appSizeInBlocks: 1,\n appCodeHash:\n \"dc86229c790ae03eb91309ee1c94600a6ddf490a9d690bfb0a2f02020ebb4c1f\",\n appFullHash:\n \"b4c2e61bae1bab2b7347df3b3b1a2fd9f1fbaffb3aa5f8aa233ed2bfaabcc13e\",\n appName: \"Polygon\",\n },\n];\n\n// BINANCE SMART CHAIN & SOLANA installed\nconst LIST_APP_RESPONSE_CONTINUE_2_APPS = Uint8Array.from([\n 0x01, 0x59, 0x00, 0x01, 0xca, 0x40, 0xfb, 0x2b, 0x7d, 0x26, 0x25, 0xd7, 0x18,\n 0x84, 0x27, 0x07, 0x05, 0x53, 0x10, 0x80, 0xc2, 0x18, 0x28, 0x79, 0xdd, 0x1e,\n 0xd9, 0xe3, 0x4b, 0x16, 0xba, 0xe4, 0xd0, 0x76, 0x9b, 0x45, 0xd7, 0xd8, 0xd7,\n 0x5b, 0x37, 0x5f, 0x6a, 0x33, 0xa1, 0xe6, 0x75, 0x79, 0x26, 0x9a, 0x16, 0xef,\n 0x44, 0x24, 0xa3, 0xd9, 0x20, 0x52, 0x15, 0xb6, 0x15, 0x2b, 0x6a, 0xd8, 0xbc,\n 0xc9, 0x0e, 0x3c, 0x32, 0xf9, 0x13, 0x42, 0x69, 0x6e, 0x61, 0x6e, 0x63, 0x65,\n 0x20, 0x53, 0x6d, 0x61, 0x72, 0x74, 0x20, 0x43, 0x68, 0x61, 0x69, 0x6e, 0x4c,\n 0x00, 0x0e, 0xca, 0x00, 0xfe, 0xe6, 0x19, 0x56, 0x1a, 0xaf, 0x43, 0x29, 0x62,\n 0x0c, 0x02, 0xd8, 0x48, 0x8e, 0x3f, 0x75, 0xa4, 0x35, 0x33, 0x17, 0x22, 0xf5,\n 0x61, 0x15, 0x79, 0xf7, 0x53, 0x97, 0x80, 0x94, 0xd1, 0x14, 0xcc, 0xbf, 0xb2,\n 0x56, 0x72, 0x9a, 0x9e, 0x28, 0x74, 0xb7, 0x23, 0xd6, 0x4c, 0xe4, 0x87, 0xf3,\n 0x57, 0xef, 0xa7, 0x16, 0xb2, 0xd0, 0xcd, 0x34, 0x98, 0x97, 0xe9, 0x6e, 0x74,\n 0x20, 0x2a, 0xca, 0x06, 0x53, 0x6f, 0x6c, 0x61, 0x6e, 0x61,\n]);\nconst LIST_APP_RESPONSE_CONTINUE_2_APPS_EXPECTED = [\n {\n appEntryLength: 89,\n appSizeInBlocks: 1,\n appCodeHash:\n \"fb2b7d2625d71884270705531080c2182879dd1ed9e34b16bae4d0769b45d7d8\",\n appFullHash:\n \"d75b375f6a33a1e67579269a16ef4424a3d9205215b6152b6ad8bcc90e3c32f9\",\n appName: \"Binance Smart Chain\",\n },\n {\n appEntryLength: 76,\n appSizeInBlocks: 14,\n appCodeHash:\n \"fee619561aaf4329620c02d8488e3f75a435331722f5611579f753978094d114\",\n appFullHash:\n \"ccbfb256729a9e2874b723d64ce487f357efa716b2d0cd349897e96e74202aca\",\n appName: \"Solana\",\n },\n];\n\ndescribe(\"ListAppCommand\", () => {\n let command: ListAppsCommand;\n\n describe(\"name\", () => {\n it(\"should be 'listApps'\", () => {\n expect(new ListAppsCommand().name).toBe(\"listApps\");\n });\n });\n\n describe(\"first list app command\", () => {\n beforeEach(() => {\n command = new ListAppsCommand();\n });\n\n describe(\"getApdu\", () => {\n it(\"should return the ListApp APDU\", () => {\n const apdu = command.getApdu();\n expect(apdu.getRawApdu()).toStrictEqual(LIST_APP_APDU);\n });\n });\n\n describe(\"parseResponse\", () => {\n it(\"should parse the response with no apps\", () => {\n const response = new ApduResponse({\n statusCode: Uint8Array.from([0x90, 0x00]),\n data: new Uint8Array(),\n });\n\n expect(command.parseResponse(response)).toStrictEqual(\n CommandResultFactory({ data: [] }),\n );\n });\n\n it(\"should parse the response with 1 app\", () => {\n const response = new ApduResponse({\n statusCode: Uint8Array.from([0x90, 0x00]),\n data: LIST_APP_RESPONSE_1_APP,\n });\n\n expect(command.parseResponse(response)).toStrictEqual(\n CommandResultFactory({ data: LIST_APP_RESPONSE_1_APP_EXPECTED }),\n );\n });\n\n it(\"should parse the response with 2 apps\", () => {\n const response = new ApduResponse({\n statusCode: Uint8Array.from([0x90, 0x00]),\n data: LIST_APP_RESPONSE_2_APPS,\n });\n\n expect(command.parseResponse(response)).toStrictEqual(\n CommandResultFactory({ data: LIST_APP_RESPONSE_2_APPS_EXPECTED }),\n );\n });\n });\n\n describe(\"errors\", () => {\n it(\"should return error command result if the response status code is not success\", () => {\n const response = new ApduResponse({\n statusCode: Uint8Array.from([0x6a, 0x82]),\n data: new Uint8Array(),\n });\n const result = command.parseResponse(response);\n\n expect(isSuccessCommandResult(result)).toBe(false);\n });\n\n it(\"should return an error\", () => {\n const response = new ApduResponse({\n statusCode: Uint8Array.from([0x55, 0x01]),\n data: new Uint8Array(),\n });\n\n // when\n const result = command.parseResponse(response);\n\n expect(isSuccessCommandResult(result)).toBe(false);\n });\n });\n });\n\n describe(\"continue list app command\", () => {\n beforeEach(() => {\n command = new ListAppsCommand({ isContinue: true });\n });\n\n describe(\"getApdu\", () => {\n it(\"should return the Continue ListApp APDU\", () => {\n const apdu = command.getApdu();\n expect(apdu.getRawApdu()).toStrictEqual(CONTINUE_LIST_APP_ADPU);\n });\n });\n\n describe(\"parseResponse\", () => {\n it(\"should parse the response with 1 app\", () => {\n const response = new ApduResponse({\n statusCode: Uint8Array.from([0x90, 0x00]),\n data: LIST_APP_RESPONSE_CONTINUE_1_APP,\n });\n\n expect(command.parseResponse(response)).toStrictEqual(\n CommandResultFactory({\n data: LIST_APP_RESPONSE_CONTINUE_1_APP_EXPECTED,\n }),\n );\n });\n\n it(\"should parse the response with 2 apps\", () => {\n const response = new ApduResponse({\n statusCode: Uint8Array.from([0x90, 0x00]),\n data: LIST_APP_RESPONSE_CONTINUE_2_APPS,\n });\n\n expect(command.parseResponse(response)).toStrictEqual(\n CommandResultFactory({\n data: LIST_APP_RESPONSE_CONTINUE_2_APPS_EXPECTED,\n }),\n );\n });\n\n it(\"should parse the response when reaching the end of the list\", () => {\n const response = new ApduResponse({\n statusCode: Uint8Array.from([0x90, 0x00]),\n data: new Uint8Array(),\n });\n\n expect(command.parseResponse(response)).toStrictEqual(\n CommandResultFactory({ data: [] }),\n );\n });\n });\n\n describe(\"errors\", () => {\n it(\"should throw if ListApp wasn't called before\", () => {\n const response = new ApduResponse({\n statusCode: Uint8Array.from([0x66, 0x24]),\n data: new Uint8Array(),\n });\n const result = command.parseResponse(\n response,\n ) as CommandErrorResult<ListAppsErrorCodes>;\n\n expect(isSuccessCommandResult(result)).toBe(false);\n expect(result.error).toBeInstanceOf(ListAppsCommandError);\n });\n });\n });\n});\n"],
5
+ "mappings": "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,CAAQ,CAAC,EAAE,cACtCjB,EAAqB,CACnB,KAAMc,CACR,CAAC,CACH,CACF,CAAC,EAED,GAAG,8DAA+D,IAAM,CACtE,MAAMG,EAAW,IAAIf,EAAa,CAChC,WAAY,WAAW,KAAK,CAAC,IAAM,CAAI,CAAC,EACxC,KAAM,IAAI,UACZ,CAAC,EAED,OAAOa,EAAQ,cAAcE,CAAQ,CAAC,EAAE,cACtCjB,EAAqB,CAAE,KAAM,CAAC,CAAE,CAAC,CACnC,CACF,CAAC,CACH,CAAC,EAED,SAAS,SAAU,IAAM,CACvB,GAAG,+CAAgD,IAAM,CACvD,MAAMiB,EAAW,IAAIf,EAAa,CAChC,WAAY,WAAW,KAAK,CAAC,IAAM,EAAI,CAAC,EACxC,KAAM,IAAI,UACZ,CAAC,EACKgB,EAASH,EAAQ,cACrBE,CACF,EAEA,OAAOhB,EAAuBiB,CAAM,CAAC,EAAE,KAAK,EAAK,EACjD,OAAOA,EAAO,KAAK,EAAE,eAAed,CAAoB,CAC1D,CAAC,CACH,CAAC,CACH,CAAC,CACH,CAAC",
6
6
  "names": ["CommandResultFactory", "isSuccessCommandResult", "ApduResponse", "ListAppsCommand", "ListAppsCommandError", "LIST_APP_APDU", "CONTINUE_LIST_APP_ADPU", "LIST_APP_RESPONSE_1_APP", "LIST_APP_RESPONSE_1_APP_EXPECTED", "LIST_APP_RESPONSE_2_APPS", "LIST_APP_RESPONSE_2_APPS_EXPECTED", "LIST_APP_RESPONSE_CONTINUE_1_APP", "LIST_APP_RESPONSE_CONTINUE_1_APP_EXPECTED", "LIST_APP_RESPONSE_CONTINUE_2_APPS", "LIST_APP_RESPONSE_CONTINUE_2_APPS_EXPECTED", "command", "apdu", "response", "result"]
7
7
  }
@@ -1,2 +1,2 @@
1
- import{ApduBuilder as p}from"../../apdu/utils/ApduBuilder";import{ApduParser as c}from"../../apdu/utils/ApduParser";import{InvalidStatusWordError as s}from"../../command/Errors";import{CommandResultFactory as o}from"../../command/model/CommandResult";import{isCommandErrorCode as L}from"../../command/utils/CommandErrors";import{CommandUtils as C}from"../../command/utils/CommandUtils";import{GlobalCommandErrorHandler as l}from"../../command/utils/GlobalCommandError";import{DeviceExchangeError as f}from"../../Error";import{bufferToHexaString as d}from"../../utils/HexaString";const i={"662d":{message:"Invalid LIST_ARG, first command must be sent with P1_LIST_LANGUAGE_PACKS_FIRST."}};class A extends f{constructor({message:r,errorCode:e}){super({message:r,errorCode:e,tag:"ListLanguagePackCommandError"})}}class _{constructor(r){this.args=r}getApdu(){const r={cla:224,ins:52,p1:this.args.firstChunk?0:1,p2:0};return new p(r).build()}parseResponse(r){const e=new c(r);if(!C.isSuccessResponse(r)){const a=e.encodeToHexaString(r.statusCode);return L(a,i)?o({error:new A({...i[a],errorCode:a})}):o({error:l.handle(r)})}if(e.extract8BitUInt()===void 0)return o({data:void 0});e.extract8BitUInt();const t=e.extractFieldLVEncoded();if(t===void 0)return o({error:new s("Failed to get language pack id")});const n=e.extractFieldLVEncoded();if(n===void 0)return o({error:new s("Failed to get language pack size")});const u=parseInt(d(t),16),g=parseInt(d(n),16);return o({data:{id:u,size:g}})}}export{_ as ListLanguagePackCommand,A as ListLanguagePackCommandError};
1
+ import{ApduBuilder as p}from"../../apdu/utils/ApduBuilder";import{ApduParser as c}from"../../apdu/utils/ApduParser";import{InvalidStatusWordError as s}from"../../command/Errors";import{CommandResultFactory as a}from"../../command/model/CommandResult";import{isCommandErrorCode as L}from"../../command/utils/CommandErrors";import{CommandUtils as l}from"../../command/utils/CommandUtils";import{GlobalCommandErrorHandler as C}from"../../command/utils/GlobalCommandError";import{DeviceExchangeError as f}from"../../Error";import{bufferToHexaString as d}from"../../utils/HexaString";const i={"662d":{message:"Invalid LIST_ARG, first command must be sent with P1_LIST_LANGUAGE_PACKS_FIRST."}};class A extends f{constructor({message:r,errorCode:e}){super({message:r,errorCode:e,tag:"ListLanguagePackCommandError"})}}class _{constructor(r){this.args=r}name="listLanguagePack";getApdu(){const r={cla:224,ins:52,p1:this.args.firstChunk?0:1,p2:0};return new p(r).build()}parseResponse(r){const e=new c(r);if(!l.isSuccessResponse(r)){const o=e.encodeToHexaString(r.statusCode);return L(o,i)?a({error:new A({...i[o],errorCode:o})}):a({error:C.handle(r)})}if(e.extract8BitUInt()===void 0)return a({data:void 0});e.extract8BitUInt();const t=e.extractFieldLVEncoded();if(t===void 0)return a({error:new s("Failed to get language pack id")});const n=e.extractFieldLVEncoded();if(n===void 0)return a({error:new s("Failed to get language pack size")});const u=parseInt(d(t),16),g=parseInt(d(n),16);return a({data:{id:u,size:g}})}}export{_ as ListLanguagePackCommand,A as ListLanguagePackCommandError};
2
2
  //# sourceMappingURL=ListLanguagePackCommand.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../../../src/api/command/os/ListLanguagePackCommand.ts"],
4
- "sourcesContent": ["import { type Apdu } from \"@api/apdu/model/Apdu\";\nimport { ApduBuilder, type ApduBuilderArgs } from \"@api/apdu/utils/ApduBuilder\";\nimport { ApduParser } from \"@api/apdu/utils/ApduParser\";\nimport { type Command } from \"@api/command/Command\";\nimport { InvalidStatusWordError } from \"@api/command/Errors\";\nimport {\n type CommandResult,\n CommandResultFactory,\n} from \"@api/command/model/CommandResult\";\nimport {\n type CommandErrors,\n isCommandErrorCode,\n} from \"@api/command/utils/CommandErrors\";\nimport { CommandUtils } from \"@api/command/utils/CommandUtils\";\nimport { GlobalCommandErrorHandler } from \"@api/command/utils/GlobalCommandError\";\nimport { type ApduResponse } from \"@api/device-session/ApduResponse\";\nimport { type CommandErrorArgs, DeviceExchangeError } from \"@api/Error\";\nimport { bufferToHexaString } from \"@api/utils/HexaString\";\n\nexport type ListLanguagePackCommandArgs = {\n readonly firstChunk: boolean;\n};\n\nexport type ListLanguagePackResponse =\n | {\n readonly id: number;\n readonly size: number;\n }\n | undefined;\n\nexport type ListLanguagePackErrorCodes = \"662d\";\n\nconst LANGUAGE_PACK_ERRORS: CommandErrors<ListLanguagePackErrorCodes> = {\n \"662d\": {\n message:\n \"Invalid LIST_ARG, first command must be sent with P1_LIST_LANGUAGE_PACKS_FIRST.\",\n },\n};\n\nexport type ListLanguagePackCommandResult = CommandResult<\n ListLanguagePackResponse,\n ListLanguagePackErrorCodes\n>;\n\nexport class ListLanguagePackCommandError extends DeviceExchangeError<ListLanguagePackErrorCodes> {\n constructor({\n message,\n errorCode,\n }: CommandErrorArgs<ListLanguagePackErrorCodes>) {\n super({ message, errorCode, tag: \"ListLanguagePackCommandError\" });\n }\n}\n\nexport class ListLanguagePackCommand\n implements\n Command<\n ListLanguagePackResponse,\n ListLanguagePackCommandArgs,\n ListLanguagePackErrorCodes\n >\n{\n constructor(private args: ListLanguagePackCommandArgs) {}\n\n getApdu(): Apdu {\n const apduArgs: ApduBuilderArgs = {\n cla: 0xe0,\n ins: 0x34,\n p1: this.args.firstChunk ? 0x00 : 0x01,\n p2: 0x00,\n };\n return new ApduBuilder(apduArgs).build();\n }\n\n parseResponse(apduResponse: ApduResponse): ListLanguagePackCommandResult {\n const parser = new ApduParser(apduResponse);\n\n if (!CommandUtils.isSuccessResponse(apduResponse)) {\n const errorCode = parser.encodeToHexaString(apduResponse.statusCode);\n if (isCommandErrorCode(errorCode, LANGUAGE_PACK_ERRORS)) {\n return CommandResultFactory({\n error: new ListLanguagePackCommandError({\n ...LANGUAGE_PACK_ERRORS[errorCode],\n errorCode,\n }),\n });\n }\n return CommandResultFactory({\n error: GlobalCommandErrorHandler.handle(apduResponse),\n });\n }\n\n const tlvVersion = parser.extract8BitUInt();\n if (tlvVersion === undefined) {\n // No more language package\n return CommandResultFactory({\n data: undefined,\n });\n }\n\n parser.extract8BitUInt(); // total length\n const idBuffer = parser.extractFieldLVEncoded();\n if (idBuffer === undefined) {\n return CommandResultFactory({\n error: new InvalidStatusWordError(\"Failed to get language pack id\"),\n });\n }\n\n const sizeBuffer = parser.extractFieldLVEncoded();\n if (sizeBuffer === undefined) {\n return CommandResultFactory({\n error: new InvalidStatusWordError(\"Failed to get language pack size\"),\n });\n }\n\n const id = parseInt(bufferToHexaString(idBuffer), 16);\n const size = parseInt(bufferToHexaString(sizeBuffer), 16);\n return CommandResultFactory({\n data: { id, size },\n });\n }\n}\n"],
5
- "mappings": "AACA,OAAS,eAAAA,MAAyC,8BAClD,OAAS,cAAAC,MAAkB,6BAE3B,OAAS,0BAAAC,MAA8B,sBACvC,OAEE,wBAAAC,MACK,mCACP,OAEE,sBAAAC,MACK,mCACP,OAAS,gBAAAC,MAAoB,kCAC7B,OAAS,6BAAAC,MAAiC,wCAE1C,OAAgC,uBAAAC,MAA2B,aAC3D,OAAS,sBAAAC,MAA0B,wBAenC,MAAMC,EAAkE,CACtE,OAAQ,CACN,QACE,iFACJ,CACF,EAOO,MAAMC,UAAqCH,CAAgD,CAChG,YAAY,CACV,QAAAI,EACA,UAAAC,CACF,EAAiD,CAC/C,MAAM,CAAE,QAAAD,EAAS,UAAAC,EAAW,IAAK,8BAA+B,CAAC,CACnE,CACF,CAEO,MAAMC,CAOb,CACE,YAAoBC,EAAmC,CAAnC,UAAAA,CAAoC,CAExD,SAAgB,CACd,MAAMC,EAA4B,CAChC,IAAK,IACL,IAAK,GACL,GAAI,KAAK,KAAK,WAAa,EAAO,EAClC,GAAI,CACN,EACA,OAAO,IAAIf,EAAYe,CAAQ,EAAE,MAAM,CACzC,CAEA,cAAcC,EAA2D,CACvE,MAAMC,EAAS,IAAIhB,EAAWe,CAAY,EAE1C,GAAI,CAACX,EAAa,kBAAkBW,CAAY,EAAG,CACjD,MAAMJ,EAAYK,EAAO,mBAAmBD,EAAa,UAAU,EACnE,OAAIZ,EAAmBQ,EAAWH,CAAoB,EAC7CN,EAAqB,CAC1B,MAAO,IAAIO,EAA6B,CACtC,GAAGD,EAAqBG,CAAS,EACjC,UAAAA,CACF,CAAC,CACH,CAAC,EAEIT,EAAqB,CAC1B,MAAOG,EAA0B,OAAOU,CAAY,CACtD,CAAC,CACH,CAGA,GADmBC,EAAO,gBAAgB,IACvB,OAEjB,OAAOd,EAAqB,CAC1B,KAAM,MACR,CAAC,EAGHc,EAAO,gBAAgB,EACvB,MAAMC,EAAWD,EAAO,sBAAsB,EAC9C,GAAIC,IAAa,OACf,OAAOf,EAAqB,CAC1B,MAAO,IAAID,EAAuB,gCAAgC,CACpE,CAAC,EAGH,MAAMiB,EAAaF,EAAO,sBAAsB,EAChD,GAAIE,IAAe,OACjB,OAAOhB,EAAqB,CAC1B,MAAO,IAAID,EAAuB,kCAAkC,CACtE,CAAC,EAGH,MAAMkB,EAAK,SAASZ,EAAmBU,CAAQ,EAAG,EAAE,EAC9CG,EAAO,SAASb,EAAmBW,CAAU,EAAG,EAAE,EACxD,OAAOhB,EAAqB,CAC1B,KAAM,CAAE,GAAAiB,EAAI,KAAAC,CAAK,CACnB,CAAC,CACH,CACF",
4
+ "sourcesContent": ["import { type Apdu } from \"@api/apdu/model/Apdu\";\nimport { ApduBuilder, type ApduBuilderArgs } from \"@api/apdu/utils/ApduBuilder\";\nimport { ApduParser } from \"@api/apdu/utils/ApduParser\";\nimport { type Command } from \"@api/command/Command\";\nimport { InvalidStatusWordError } from \"@api/command/Errors\";\nimport {\n type CommandResult,\n CommandResultFactory,\n} from \"@api/command/model/CommandResult\";\nimport {\n type CommandErrors,\n isCommandErrorCode,\n} from \"@api/command/utils/CommandErrors\";\nimport { CommandUtils } from \"@api/command/utils/CommandUtils\";\nimport { GlobalCommandErrorHandler } from \"@api/command/utils/GlobalCommandError\";\nimport { type ApduResponse } from \"@api/device-session/ApduResponse\";\nimport { type CommandErrorArgs, DeviceExchangeError } from \"@api/Error\";\nimport { bufferToHexaString } from \"@api/utils/HexaString\";\n\nexport type ListLanguagePackCommandArgs = {\n readonly firstChunk: boolean;\n};\n\nexport type ListLanguagePackResponse =\n | {\n readonly id: number;\n readonly size: number;\n }\n | undefined;\n\nexport type ListLanguagePackErrorCodes = \"662d\";\n\nconst LANGUAGE_PACK_ERRORS: CommandErrors<ListLanguagePackErrorCodes> = {\n \"662d\": {\n message:\n \"Invalid LIST_ARG, first command must be sent with P1_LIST_LANGUAGE_PACKS_FIRST.\",\n },\n};\n\nexport type ListLanguagePackCommandResult = CommandResult<\n ListLanguagePackResponse,\n ListLanguagePackErrorCodes\n>;\n\nexport class ListLanguagePackCommandError extends DeviceExchangeError<ListLanguagePackErrorCodes> {\n constructor({\n message,\n errorCode,\n }: CommandErrorArgs<ListLanguagePackErrorCodes>) {\n super({ message, errorCode, tag: \"ListLanguagePackCommandError\" });\n }\n}\n\nexport class ListLanguagePackCommand\n implements\n Command<\n ListLanguagePackResponse,\n ListLanguagePackCommandArgs,\n ListLanguagePackErrorCodes\n >\n{\n readonly name = \"listLanguagePack\";\n\n constructor(private args: ListLanguagePackCommandArgs) {}\n\n getApdu(): Apdu {\n const apduArgs: ApduBuilderArgs = {\n cla: 0xe0,\n ins: 0x34,\n p1: this.args.firstChunk ? 0x00 : 0x01,\n p2: 0x00,\n };\n return new ApduBuilder(apduArgs).build();\n }\n\n parseResponse(apduResponse: ApduResponse): ListLanguagePackCommandResult {\n const parser = new ApduParser(apduResponse);\n\n if (!CommandUtils.isSuccessResponse(apduResponse)) {\n const errorCode = parser.encodeToHexaString(apduResponse.statusCode);\n if (isCommandErrorCode(errorCode, LANGUAGE_PACK_ERRORS)) {\n return CommandResultFactory({\n error: new ListLanguagePackCommandError({\n ...LANGUAGE_PACK_ERRORS[errorCode],\n errorCode,\n }),\n });\n }\n return CommandResultFactory({\n error: GlobalCommandErrorHandler.handle(apduResponse),\n });\n }\n\n const tlvVersion = parser.extract8BitUInt();\n if (tlvVersion === undefined) {\n // No more language package\n return CommandResultFactory({\n data: undefined,\n });\n }\n\n parser.extract8BitUInt(); // total length\n const idBuffer = parser.extractFieldLVEncoded();\n if (idBuffer === undefined) {\n return CommandResultFactory({\n error: new InvalidStatusWordError(\"Failed to get language pack id\"),\n });\n }\n\n const sizeBuffer = parser.extractFieldLVEncoded();\n if (sizeBuffer === undefined) {\n return CommandResultFactory({\n error: new InvalidStatusWordError(\"Failed to get language pack size\"),\n });\n }\n\n const id = parseInt(bufferToHexaString(idBuffer), 16);\n const size = parseInt(bufferToHexaString(sizeBuffer), 16);\n return CommandResultFactory({\n data: { id, size },\n });\n }\n}\n"],
5
+ "mappings": "AACA,OAAS,eAAAA,MAAyC,8BAClD,OAAS,cAAAC,MAAkB,6BAE3B,OAAS,0BAAAC,MAA8B,sBACvC,OAEE,wBAAAC,MACK,mCACP,OAEE,sBAAAC,MACK,mCACP,OAAS,gBAAAC,MAAoB,kCAC7B,OAAS,6BAAAC,MAAiC,wCAE1C,OAAgC,uBAAAC,MAA2B,aAC3D,OAAS,sBAAAC,MAA0B,wBAenC,MAAMC,EAAkE,CACtE,OAAQ,CACN,QACE,iFACJ,CACF,EAOO,MAAMC,UAAqCH,CAAgD,CAChG,YAAY,CACV,QAAAI,EACA,UAAAC,CACF,EAAiD,CAC/C,MAAM,CAAE,QAAAD,EAAS,UAAAC,EAAW,IAAK,8BAA+B,CAAC,CACnE,CACF,CAEO,MAAMC,CAOb,CAGE,YAAoBC,EAAmC,CAAnC,UAAAA,CAAoC,CAF/C,KAAO,mBAIhB,SAAgB,CACd,MAAMC,EAA4B,CAChC,IAAK,IACL,IAAK,GACL,GAAI,KAAK,KAAK,WAAa,EAAO,EAClC,GAAI,CACN,EACA,OAAO,IAAIf,EAAYe,CAAQ,EAAE,MAAM,CACzC,CAEA,cAAcC,EAA2D,CACvE,MAAMC,EAAS,IAAIhB,EAAWe,CAAY,EAE1C,GAAI,CAACX,EAAa,kBAAkBW,CAAY,EAAG,CACjD,MAAMJ,EAAYK,EAAO,mBAAmBD,EAAa,UAAU,EACnE,OAAIZ,EAAmBQ,EAAWH,CAAoB,EAC7CN,EAAqB,CAC1B,MAAO,IAAIO,EAA6B,CACtC,GAAGD,EAAqBG,CAAS,EACjC,UAAAA,CACF,CAAC,CACH,CAAC,EAEIT,EAAqB,CAC1B,MAAOG,EAA0B,OAAOU,CAAY,CACtD,CAAC,CACH,CAGA,GADmBC,EAAO,gBAAgB,IACvB,OAEjB,OAAOd,EAAqB,CAC1B,KAAM,MACR,CAAC,EAGHc,EAAO,gBAAgB,EACvB,MAAMC,EAAWD,EAAO,sBAAsB,EAC9C,GAAIC,IAAa,OACf,OAAOf,EAAqB,CAC1B,MAAO,IAAID,EAAuB,gCAAgC,CACpE,CAAC,EAGH,MAAMiB,EAAaF,EAAO,sBAAsB,EAChD,GAAIE,IAAe,OACjB,OAAOhB,EAAqB,CAC1B,MAAO,IAAID,EAAuB,kCAAkC,CACtE,CAAC,EAGH,MAAMkB,EAAK,SAASZ,EAAmBU,CAAQ,EAAG,EAAE,EAC9CG,EAAO,SAASb,EAAmBW,CAAU,EAAG,EAAE,EACxD,OAAOhB,EAAqB,CAC1B,KAAM,CAAE,GAAAiB,EAAI,KAAAC,CAAK,CACnB,CAAC,CACH,CACF",
6
6
  "names": ["ApduBuilder", "ApduParser", "InvalidStatusWordError", "CommandResultFactory", "isCommandErrorCode", "CommandUtils", "GlobalCommandErrorHandler", "DeviceExchangeError", "bufferToHexaString", "LANGUAGE_PACK_ERRORS", "ListLanguagePackCommandError", "message", "errorCode", "ListLanguagePackCommand", "args", "apduArgs", "apduResponse", "parser", "idBuffer", "sizeBuffer", "id", "size"]
7
7
  }
@@ -1,2 +1,2 @@
1
- import{InvalidStatusWordError as a}from"../../command/Errors";import{CommandResultFactory as r}from"../../command/model/CommandResult";import{isSuccessCommandResult as u}from"../../command/model/CommandResult";import{ListLanguagePackCommand as o}from"../../command/os/ListLanguagePackCommand";import{ApduResponse as n}from"../../device-session/ApduResponse";const i=new Uint8Array([224,52,0,0,0]),d=new Uint8Array([224,52,1,0,0]);describe("ListLanguagePackCommand",()=>{let t;beforeEach(()=>{t=new o({firstChunk:!0})}),it("should return the correct APDU",()=>{const e=t.getApdu();expect(e.getRawApdu()).toStrictEqual(i)}),it("should return the correct next chunks APDU",()=>{t=new o({firstChunk:!1});const e=t.getApdu();expect(e.getRawApdu()).toStrictEqual(d)}),it("should parse result successfully",()=>{const e=new n({statusCode:new Uint8Array([144,0]),data:new Uint8Array([1,15,1,1,4,0,0,80,0,5,48,46,48,46,52,0])}),s=t.parseResponse(e);expect(s).toStrictEqual(r({data:{id:1,size:20480}}))}),it("should parse empty result successfully",()=>{const e=new n({statusCode:new Uint8Array([144,0]),data:new Uint8Array([])}),s=t.parseResponse(e);expect(s).toStrictEqual(r({data:void 0}))}),it("should fail on invalid id",()=>{const e=new n({statusCode:new Uint8Array([144,0]),data:new Uint8Array([1,15])}),s=t.parseResponse(e);expect(s).toStrictEqual(r({error:new a("Failed to get language pack id")}))}),it("should fail on invalid size",()=>{const e=new n({statusCode:new Uint8Array([144,0]),data:new Uint8Array([1,15,1,1])}),s=t.parseResponse(e);expect(s).toStrictEqual(r({error:new a("Failed to get language pack size")}))}),it("should fail on device error",()=>{const e=new n({statusCode:new Uint8Array([102,45]),data:new Uint8Array([])}),s=t.parseResponse(e);expect(u(s)).toBeFalsy()})});
1
+ import{InvalidStatusWordError as r}from"../../command/Errors";import{CommandResultFactory as a}from"../../command/model/CommandResult";import{isSuccessCommandResult as u}from"../../command/model/CommandResult";import{ListLanguagePackCommand as o}from"../../command/os/ListLanguagePackCommand";import{ApduResponse as n}from"../../device-session/ApduResponse";const i=new Uint8Array([224,52,0,0,0]),d=new Uint8Array([224,52,1,0,0]);describe("ListLanguagePackCommand",()=>{let t;beforeEach(()=>{t=new o({firstChunk:!0})}),describe("name",()=>{it("should be 'listLanguagePack'",()=>{expect(t.name).toBe("listLanguagePack")})}),it("should return the correct APDU",()=>{const e=t.getApdu();expect(e.getRawApdu()).toStrictEqual(i)}),it("should return the correct next chunks APDU",()=>{t=new o({firstChunk:!1});const e=t.getApdu();expect(e.getRawApdu()).toStrictEqual(d)}),it("should parse result successfully",()=>{const e=new n({statusCode:new Uint8Array([144,0]),data:new Uint8Array([1,15,1,1,4,0,0,80,0,5,48,46,48,46,52,0])}),s=t.parseResponse(e);expect(s).toStrictEqual(a({data:{id:1,size:20480}}))}),it("should parse empty result successfully",()=>{const e=new n({statusCode:new Uint8Array([144,0]),data:new Uint8Array([])}),s=t.parseResponse(e);expect(s).toStrictEqual(a({data:void 0}))}),it("should fail on invalid id",()=>{const e=new n({statusCode:new Uint8Array([144,0]),data:new Uint8Array([1,15])}),s=t.parseResponse(e);expect(s).toStrictEqual(a({error:new r("Failed to get language pack id")}))}),it("should fail on invalid size",()=>{const e=new n({statusCode:new Uint8Array([144,0]),data:new Uint8Array([1,15,1,1])}),s=t.parseResponse(e);expect(s).toStrictEqual(a({error:new r("Failed to get language pack size")}))}),it("should fail on device error",()=>{const e=new n({statusCode:new Uint8Array([102,45]),data:new Uint8Array([])}),s=t.parseResponse(e);expect(u(s)).toBeFalsy()})});
2
2
  //# sourceMappingURL=ListLanguagePackCommand.test.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../../../src/api/command/os/ListLanguagePackCommand.test.ts"],
4
- "sourcesContent": ["import { InvalidStatusWordError } from \"@api/command/Errors\";\nimport { CommandResultFactory } from \"@api/command/model/CommandResult\";\nimport { isSuccessCommandResult } from \"@api/command/model/CommandResult\";\nimport { ListLanguagePackCommand } from \"@api/command/os/ListLanguagePackCommand\";\nimport { ApduResponse } from \"@api/device-session/ApduResponse\";\n\nconst LIST_LANGUAGE_PACK_APDU = new Uint8Array([0xe0, 0x34, 0x00, 0x00, 0x00]);\nconst LIST_LANGUAGE_PACK_CONTINUE_APDU = new Uint8Array([\n 0xe0, 0x34, 0x01, 0x00, 0x00,\n]);\n\ndescribe(\"ListLanguagePackCommand\", () => {\n let command: ListLanguagePackCommand;\n\n beforeEach(() => {\n command = new ListLanguagePackCommand({ firstChunk: true });\n });\n\n it(\"should return the correct APDU\", () => {\n const apdu = command.getApdu();\n expect(apdu.getRawApdu()).toStrictEqual(LIST_LANGUAGE_PACK_APDU);\n });\n\n it(\"should return the correct next chunks APDU\", () => {\n command = new ListLanguagePackCommand({ firstChunk: false });\n const apdu = command.getApdu();\n expect(apdu.getRawApdu()).toStrictEqual(LIST_LANGUAGE_PACK_CONTINUE_APDU);\n });\n\n it(\"should parse result successfully\", () => {\n const response: ApduResponse = new ApduResponse({\n statusCode: new Uint8Array([0x90, 0x00]),\n data: new Uint8Array([\n 0x01, 0x0f, 0x01, 0x01, 0x04, 0x00, 0x00, 0x50, 0x00, 0x05, 0x30, 0x2e,\n 0x30, 0x2e, 0x34, 0x00,\n ]),\n });\n const result = command.parseResponse(response);\n expect(result).toStrictEqual(\n CommandResultFactory({\n data: {\n id: 1,\n size: 20480,\n },\n }),\n );\n });\n\n it(\"should parse empty result successfully\", () => {\n const response: ApduResponse = new ApduResponse({\n statusCode: new Uint8Array([0x90, 0x00]),\n data: new Uint8Array([]),\n });\n const result = command.parseResponse(response);\n expect(result).toStrictEqual(\n CommandResultFactory({\n data: undefined,\n }),\n );\n });\n\n it(\"should fail on invalid id\", () => {\n const response: ApduResponse = new ApduResponse({\n statusCode: new Uint8Array([0x90, 0x00]),\n data: new Uint8Array([0x01, 0x0f]),\n });\n const result = command.parseResponse(response);\n expect(result).toStrictEqual(\n CommandResultFactory({\n error: new InvalidStatusWordError(\"Failed to get language pack id\"),\n }),\n );\n });\n\n it(\"should fail on invalid size\", () => {\n const response: ApduResponse = new ApduResponse({\n statusCode: new Uint8Array([0x90, 0x00]),\n data: new Uint8Array([0x01, 0x0f, 0x01, 0x01]),\n });\n const result = command.parseResponse(response);\n expect(result).toStrictEqual(\n CommandResultFactory({\n error: new InvalidStatusWordError(\"Failed to get language pack size\"),\n }),\n );\n });\n\n it(\"should fail on device error\", () => {\n const response: ApduResponse = new ApduResponse({\n statusCode: new Uint8Array([0x66, 0x2d]),\n data: new Uint8Array([]),\n });\n const result = command.parseResponse(response);\n expect(isSuccessCommandResult(result)).toBeFalsy();\n });\n});\n"],
5
- "mappings": "AAAA,OAAS,0BAAAA,MAA8B,sBACvC,OAAS,wBAAAC,MAA4B,mCACrC,OAAS,0BAAAC,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OAAOC,CAAM,EAAE,cACbT,EAAqB,CACnB,KAAM,MACR,CAAC,CACH,CACF,CAAC,EAED,GAAG,4BAA6B,IAAM,CACpC,MAAMQ,EAAyB,IAAIL,EAAa,CAC9C,WAAY,IAAI,WAAW,CAAC,IAAM,CAAI,CAAC,EACvC,KAAM,IAAI,WAAW,CAAC,EAAM,EAAI,CAAC,CACnC,CAAC,EACKM,EAASH,EAAQ,cAAcE,CAAQ,EAC7C,OAAOC,CAAM,EAAE,cACbT,EAAqB,CACnB,MAAO,IAAID,EAAuB,gCAAgC,CACpE,CAAC,CACH,CACF,CAAC,EAED,GAAG,8BAA+B,IAAM,CACtC,MAAMS,EAAyB,IAAIL,EAAa,CAC9C,WAAY,IAAI,WAAW,CAAC,IAAM,CAAI,CAAC,EACvC,KAAM,IAAI,WAAW,CAAC,EAAM,GAAM,EAAM,CAAI,CAAC,CAC/C,CAAC,EACKM,EAASH,EAAQ,cAAcE,CAAQ,EAC7C,OAAOC,CAAM,EAAE,cACbT,EAAqB,CACnB,MAAO,IAAID,EAAuB,kCAAkC,CACtE,CAAC,CACH,CACF,CAAC,EAED,GAAG,8BAA+B,IAAM,CACtC,MAAMS,EAAyB,IAAIL,EAAa,CAC9C,WAAY,IAAI,WAAW,CAAC,IAAM,EAAI,CAAC,EACvC,KAAM,IAAI,WAAW,CAAC,CAAC,CACzB,CAAC,EACKM,EAASH,EAAQ,cAAcE,CAAQ,EAC7C,OAAOP,EAAuBQ,CAAM,CAAC,EAAE,UAAU,CACnD,CAAC,CACH,CAAC",
4
+ "sourcesContent": ["import { InvalidStatusWordError } from \"@api/command/Errors\";\nimport { CommandResultFactory } from \"@api/command/model/CommandResult\";\nimport { isSuccessCommandResult } from \"@api/command/model/CommandResult\";\nimport { ListLanguagePackCommand } from \"@api/command/os/ListLanguagePackCommand\";\nimport { ApduResponse } from \"@api/device-session/ApduResponse\";\n\nconst LIST_LANGUAGE_PACK_APDU = new Uint8Array([0xe0, 0x34, 0x00, 0x00, 0x00]);\nconst LIST_LANGUAGE_PACK_CONTINUE_APDU = new Uint8Array([\n 0xe0, 0x34, 0x01, 0x00, 0x00,\n]);\n\ndescribe(\"ListLanguagePackCommand\", () => {\n let command: ListLanguagePackCommand;\n\n beforeEach(() => {\n command = new ListLanguagePackCommand({ firstChunk: true });\n });\n\n describe(\"name\", () => {\n it(\"should be 'listLanguagePack'\", () => {\n expect(command.name).toBe(\"listLanguagePack\");\n });\n });\n\n it(\"should return the correct APDU\", () => {\n const apdu = command.getApdu();\n expect(apdu.getRawApdu()).toStrictEqual(LIST_LANGUAGE_PACK_APDU);\n });\n\n it(\"should return the correct next chunks APDU\", () => {\n command = new ListLanguagePackCommand({ firstChunk: false });\n const apdu = command.getApdu();\n expect(apdu.getRawApdu()).toStrictEqual(LIST_LANGUAGE_PACK_CONTINUE_APDU);\n });\n\n it(\"should parse result successfully\", () => {\n const response: ApduResponse = new ApduResponse({\n statusCode: new Uint8Array([0x90, 0x00]),\n data: new Uint8Array([\n 0x01, 0x0f, 0x01, 0x01, 0x04, 0x00, 0x00, 0x50, 0x00, 0x05, 0x30, 0x2e,\n 0x30, 0x2e, 0x34, 0x00,\n ]),\n });\n const result = command.parseResponse(response);\n expect(result).toStrictEqual(\n CommandResultFactory({\n data: {\n id: 1,\n size: 20480,\n },\n }),\n );\n });\n\n it(\"should parse empty result successfully\", () => {\n const response: ApduResponse = new ApduResponse({\n statusCode: new Uint8Array([0x90, 0x00]),\n data: new Uint8Array([]),\n });\n const result = command.parseResponse(response);\n expect(result).toStrictEqual(\n CommandResultFactory({\n data: undefined,\n }),\n );\n });\n\n it(\"should fail on invalid id\", () => {\n const response: ApduResponse = new ApduResponse({\n statusCode: new Uint8Array([0x90, 0x00]),\n data: new Uint8Array([0x01, 0x0f]),\n });\n const result = command.parseResponse(response);\n expect(result).toStrictEqual(\n CommandResultFactory({\n error: new InvalidStatusWordError(\"Failed to get language pack id\"),\n }),\n );\n });\n\n it(\"should fail on invalid size\", () => {\n const response: ApduResponse = new ApduResponse({\n statusCode: new Uint8Array([0x90, 0x00]),\n data: new Uint8Array([0x01, 0x0f, 0x01, 0x01]),\n });\n const result = command.parseResponse(response);\n expect(result).toStrictEqual(\n CommandResultFactory({\n error: new InvalidStatusWordError(\"Failed to get language pack size\"),\n }),\n );\n });\n\n it(\"should fail on device error\", () => {\n const response: ApduResponse = new ApduResponse({\n statusCode: new Uint8Array([0x66, 0x2d]),\n data: new Uint8Array([]),\n });\n const result = command.parseResponse(response);\n expect(isSuccessCommandResult(result)).toBeFalsy();\n });\n});\n"],
5
+ "mappings": "AAAA,OAAS,0BAAAA,MAA8B,sBACvC,OAAS,wBAAAC,MAA4B,mCACrC,OAAS,0BAAAC,MAA8B,mCACvC,OAAS,2BAAAC,MAA+B,0CACxC,OAAS,gBAAAC,MAAoB,mCAE7B,MAAMC,EAA0B,IAAI,WAAW,CAAC,IAAM,GAAM,EAAM,EAAM,CAAI,CAAC,EACvEC,EAAmC,IAAI,WAAW,CACtD,IAAM,GAAM,EAAM,EAAM,CAC1B,CAAC,EAED,SAAS,0BAA2B,IAAM,CACxC,IAAIC,EAEJ,WAAW,IAAM,CACfA,EAAU,IAAIJ,EAAwB,CAAE,WAAY,EAAK,CAAC,CAC5D,CAAC,EAED,SAAS,OAAQ,IAAM,CACrB,GAAG,+BAAgC,IAAM,CACvC,OAAOI,EAAQ,IAAI,EAAE,KAAK,kBAAkB,CAC9C,CAAC,CACH,CAAC,EAED,GAAG,iCAAkC,IAAM,CACzC,MAAMC,EAAOD,EAAQ,QAAQ,EAC7B,OAAOC,EAAK,WAAW,CAAC,EAAE,cAAcH,CAAuB,CACjE,CAAC,EAED,GAAG,6CAA8C,IAAM,CACrDE,EAAU,IAAIJ,EAAwB,CAAE,WAAY,EAAM,CAAC,EAC3D,MAAMK,EAAOD,EAAQ,QAAQ,EAC7B,OAAOC,EAAK,WAAW,CAAC,EAAE,cAAcF,CAAgC,CAC1E,CAAC,EAED,GAAG,mCAAoC,IAAM,CAC3C,MA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,CACH,CACF,CAAC,EAED,GAAG,8BAA+B,IAAM,CACtC,MAAMS,EAAyB,IAAIL,EAAa,CAC9C,WAAY,IAAI,WAAW,CAAC,IAAM,EAAI,CAAC,EACvC,KAAM,IAAI,WAAW,CAAC,CAAC,CACzB,CAAC,EACKM,EAASH,EAAQ,cAAcE,CAAQ,EAC7C,OAAOP,EAAuBQ,CAAM,CAAC,EAAE,UAAU,CACnD,CAAC,CACH,CAAC",
6
6
  "names": ["InvalidStatusWordError", "CommandResultFactory", "isSuccessCommandResult", "ListLanguagePackCommand", "ApduResponse", "LIST_LANGUAGE_PACK_APDU", "LIST_LANGUAGE_PACK_CONTINUE_APDU", "command", "apdu", "response", "result"]
7
7
  }
@@ -1,2 +1,2 @@
1
- import{ApduBuilder as i}from"../../apdu/utils/ApduBuilder";import{ApduParser as n}from"../../apdu/utils/ApduParser";import{CommandResultFactory as t}from"../../command/model/CommandResult";import{isCommandErrorCode as d}from"../../command/utils/CommandErrors";import{CommandUtils as m}from"../../command/utils/CommandUtils";import{GlobalCommandErrorHandler as c}from"../../command/utils/GlobalCommandError";import{DeviceExchangeError as f}from"../../Error";const a={"422f":{message:"Incorrect structure type"},4230:{message:"Incorrect certificate version"},4231:{message:"Incorrect certificate validity"},4232:{message:"Incorrect certificate validity index"},4233:{message:"Unknown signer key ID"},4234:{message:"Unknown signature algorithm"},4235:{message:"Unknown public key ID"},4236:{message:"Unknown public key usage"},4237:{message:"Incorrect elliptic curve ID"},4238:{message:"Incorrect signature algorithm associated to the public key"},4239:{message:"Unknown target device"},"422d":{message:"Unknown certificate tag"},3301:{message:"Failed to hash data"},"422e":{message:"expected_key_usage doesn't match certificate key usage"},5720:{message:"Failed to verify signature"},4118:{message:"trusted_name buffer is too small to contain the trusted name"},ffff:{message:"Cryptography-related error"}};class g extends f{constructor({message:e,errorCode:o}){super({tag:"ProvidePkiCertificateCommandError",message:e,errorCode:o})}}class k{args;triggersDisconnection=!1;constructor(e){this.args=e}getApdu(){const e={cla:176,ins:6,p1:this.args.keyUsage,p2:0};return new i(e).addBufferToData(this.args.certificate).build()}parseResponse(e){if(m.isSuccessResponse(e))return t({data:void 0});const r=new n(e).encodeToHexaString(e.statusCode);return d(r,a)?t({error:new g({...a[r],errorCode:r})}):t({error:c.handle(e)})}}export{k as LoadCertificateCommand,g as LoadCertificateCommandError};
1
+ import{ApduBuilder as i}from"../../apdu/utils/ApduBuilder";import{ApduParser as n}from"../../apdu/utils/ApduParser";import{CommandResultFactory as t}from"../../command/model/CommandResult";import{isCommandErrorCode as d}from"../../command/utils/CommandErrors";import{CommandUtils as m}from"../../command/utils/CommandUtils";import{GlobalCommandErrorHandler as c}from"../../command/utils/GlobalCommandError";import{DeviceExchangeError as f}from"../../Error";const a={"422f":{message:"Incorrect structure type"},4230:{message:"Incorrect certificate version"},4231:{message:"Incorrect certificate validity"},4232:{message:"Incorrect certificate validity index"},4233:{message:"Unknown signer key ID"},4234:{message:"Unknown signature algorithm"},4235:{message:"Unknown public key ID"},4236:{message:"Unknown public key usage"},4237:{message:"Incorrect elliptic curve ID"},4238:{message:"Incorrect signature algorithm associated to the public key"},4239:{message:"Unknown target device"},"422d":{message:"Unknown certificate tag"},3301:{message:"Failed to hash data"},"422e":{message:"expected_key_usage doesn't match certificate key usage"},5720:{message:"Failed to verify signature"},4118:{message:"trusted_name buffer is too small to contain the trusted name"},ffff:{message:"Cryptography-related error"}};class g extends f{constructor({message:e,errorCode:o}){super({tag:"ProvidePkiCertificateCommandError",message:e,errorCode:o})}}class k{name="loadCertificate";args;triggersDisconnection=!1;constructor(e){this.args=e}getApdu(){const e={cla:176,ins:6,p1:this.args.keyUsage,p2:0};return new i(e).addBufferToData(this.args.certificate).build()}parseResponse(e){if(m.isSuccessResponse(e))return t({data:void 0});const r=new n(e).encodeToHexaString(e.statusCode);return d(r,a)?t({error:new g({...a[r],errorCode:r})}):t({error:c.handle(e)})}}export{k as LoadCertificateCommand,g as LoadCertificateCommandError};
2
2
  //# sourceMappingURL=LoadCertificateCommand.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../../../src/api/command/os/LoadCertificateCommand.ts"],
4
- "sourcesContent": ["import { type Apdu } from \"@api/apdu/model/Apdu\";\nimport { ApduBuilder, type ApduBuilderArgs } from \"@api/apdu/utils/ApduBuilder\";\nimport { ApduParser } from \"@api/apdu/utils/ApduParser\";\nimport {\n type CommandResult,\n CommandResultFactory,\n} from \"@api/command/model/CommandResult\";\nimport {\n type CommandErrors,\n isCommandErrorCode,\n} from \"@api/command/utils/CommandErrors\";\nimport { CommandUtils } from \"@api/command/utils/CommandUtils\";\nimport { GlobalCommandErrorHandler } from \"@api/command/utils/GlobalCommandError\";\nimport { type ApduResponse } from \"@api/device-session/ApduResponse\";\nimport { DeviceExchangeError } from \"@api/Error\";\nimport { type Command, type CommandErrorArgs } from \"@api/types\";\n\nexport type LoadCertificateArgs = {\n readonly keyUsage: number;\n readonly certificate: Uint8Array;\n};\n\nexport type LoadCertificateErrorCodes =\n | \"422f\"\n | \"4230\"\n | \"4231\"\n | \"4232\"\n | \"4233\"\n | \"4234\"\n | \"4235\"\n | \"4236\"\n | \"4237\"\n | \"4238\"\n | \"4239\"\n | \"422d\"\n | \"3301\"\n | \"422e\"\n | \"5720\"\n | \"4118\"\n | \"ffff\";\n\nconst LOAD_CERTIFICATE_ERRORS: CommandErrors<LoadCertificateErrorCodes> = {\n \"422f\": { message: \"Incorrect structure type\" },\n \"4230\": { message: \"Incorrect certificate version\" },\n \"4231\": { message: \"Incorrect certificate validity\" },\n \"4232\": { message: \"Incorrect certificate validity index\" },\n \"4233\": { message: \"Unknown signer key ID\" },\n \"4234\": { message: \"Unknown signature algorithm\" },\n \"4235\": { message: \"Unknown public key ID\" },\n \"4236\": { message: \"Unknown public key usage\" },\n \"4237\": { message: \"Incorrect elliptic curve ID\" },\n \"4238\": {\n message: \"Incorrect signature algorithm associated to the public key\",\n },\n \"4239\": { message: \"Unknown target device\" },\n \"422d\": { message: \"Unknown certificate tag\" },\n \"3301\": { message: \"Failed to hash data\" },\n \"422e\": {\n message: \"expected_key_usage doesn't match certificate key usage\",\n },\n \"5720\": { message: \"Failed to verify signature\" },\n \"4118\": {\n message: \"trusted_name buffer is too small to contain the trusted name\",\n },\n ffff: { message: \"Cryptography-related error\" },\n};\n\nexport class LoadCertificateCommandError extends DeviceExchangeError<LoadCertificateErrorCodes> {\n constructor({\n message,\n errorCode,\n }: CommandErrorArgs<LoadCertificateErrorCodes>) {\n super({ tag: \"ProvidePkiCertificateCommandError\", message, errorCode });\n }\n}\n\nexport type LoadCertificateCommandResult = CommandResult<\n void,\n LoadCertificateErrorCodes\n>;\n\n/**\n * The command to load a certificate on the device.\n */\nexport class LoadCertificateCommand\n implements Command<void, LoadCertificateArgs, LoadCertificateErrorCodes>\n{\n readonly args: LoadCertificateArgs;\n readonly triggersDisconnection = false;\n\n constructor(args: LoadCertificateArgs) {\n this.args = args;\n }\n\n getApdu(): Apdu {\n const providePkiApduArgs: ApduBuilderArgs = {\n cla: 0xb0,\n ins: 0x06,\n p1: this.args.keyUsage,\n p2: 0x00,\n };\n return new ApduBuilder(providePkiApduArgs)\n .addBufferToData(this.args.certificate)\n .build();\n }\n\n parseResponse(apduResponse: ApduResponse): LoadCertificateCommandResult {\n if (CommandUtils.isSuccessResponse(apduResponse)) {\n return CommandResultFactory({\n data: undefined,\n });\n }\n const parser = new ApduParser(apduResponse);\n const errorCode = parser.encodeToHexaString(apduResponse.statusCode);\n if (isCommandErrorCode(errorCode, LOAD_CERTIFICATE_ERRORS)) {\n return CommandResultFactory({\n error: new LoadCertificateCommandError({\n ...LOAD_CERTIFICATE_ERRORS[errorCode],\n errorCode,\n }),\n });\n }\n return CommandResultFactory({\n error: GlobalCommandErrorHandler.handle(apduResponse),\n });\n }\n}\n"],
5
- "mappings": "AACA,OAAS,eAAAA,MAAyC,8BAClD,OAAS,cAAAC,MAAkB,6BAC3B,OAEE,wBAAAC,MACK,mCACP,OAEE,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IAAIT,EAAWa,CAAY,EACjB,mBAAmBA,EAAa,UAAU,EACnE,OAAIX,EAAmBO,EAAWH,CAAuB,EAChDL,EAAqB,CAC1B,MAAO,IAAIM,EAA4B,CACrC,GAAGD,EAAwBG,CAAS,EACpC,UAAAA,CACF,CAAC,CACH,CAAC,EAEIR,EAAqB,CAC1B,MAAOG,EAA0B,OAAOS,CAAY,CACtD,CAAC,CACH,CACF",
4
+ "sourcesContent": ["import { type Apdu } from \"@api/apdu/model/Apdu\";\nimport { ApduBuilder, type ApduBuilderArgs } from \"@api/apdu/utils/ApduBuilder\";\nimport { ApduParser } from \"@api/apdu/utils/ApduParser\";\nimport {\n type CommandResult,\n CommandResultFactory,\n} from \"@api/command/model/CommandResult\";\nimport {\n type CommandErrors,\n isCommandErrorCode,\n} from \"@api/command/utils/CommandErrors\";\nimport { CommandUtils } from \"@api/command/utils/CommandUtils\";\nimport { GlobalCommandErrorHandler } from \"@api/command/utils/GlobalCommandError\";\nimport { type ApduResponse } from \"@api/device-session/ApduResponse\";\nimport { DeviceExchangeError } from \"@api/Error\";\nimport { type Command, type CommandErrorArgs } from \"@api/types\";\n\nexport type LoadCertificateArgs = {\n readonly keyUsage: number;\n readonly certificate: Uint8Array;\n};\n\nexport type LoadCertificateErrorCodes =\n | \"422f\"\n | \"4230\"\n | \"4231\"\n | \"4232\"\n | \"4233\"\n | \"4234\"\n | \"4235\"\n | \"4236\"\n | \"4237\"\n | \"4238\"\n | \"4239\"\n | \"422d\"\n | \"3301\"\n | \"422e\"\n | \"5720\"\n | \"4118\"\n | \"ffff\";\n\nconst LOAD_CERTIFICATE_ERRORS: CommandErrors<LoadCertificateErrorCodes> = {\n \"422f\": { message: \"Incorrect structure type\" },\n \"4230\": { message: \"Incorrect certificate version\" },\n \"4231\": { message: \"Incorrect certificate validity\" },\n \"4232\": { message: \"Incorrect certificate validity index\" },\n \"4233\": { message: \"Unknown signer key ID\" },\n \"4234\": { message: \"Unknown signature algorithm\" },\n \"4235\": { message: \"Unknown public key ID\" },\n \"4236\": { message: \"Unknown public key usage\" },\n \"4237\": { message: \"Incorrect elliptic curve ID\" },\n \"4238\": {\n message: \"Incorrect signature algorithm associated to the public key\",\n },\n \"4239\": { message: \"Unknown target device\" },\n \"422d\": { message: \"Unknown certificate tag\" },\n \"3301\": { message: \"Failed to hash data\" },\n \"422e\": {\n message: \"expected_key_usage doesn't match certificate key usage\",\n },\n \"5720\": { message: \"Failed to verify signature\" },\n \"4118\": {\n message: \"trusted_name buffer is too small to contain the trusted name\",\n },\n ffff: { message: \"Cryptography-related error\" },\n};\n\nexport class LoadCertificateCommandError extends DeviceExchangeError<LoadCertificateErrorCodes> {\n constructor({\n message,\n errorCode,\n }: CommandErrorArgs<LoadCertificateErrorCodes>) {\n super({ tag: \"ProvidePkiCertificateCommandError\", message, errorCode });\n }\n}\n\nexport type LoadCertificateCommandResult = CommandResult<\n void,\n LoadCertificateErrorCodes\n>;\n\n/**\n * The command to load a certificate on the device.\n */\nexport class LoadCertificateCommand\n implements Command<void, LoadCertificateArgs, LoadCertificateErrorCodes>\n{\n readonly name = \"loadCertificate\";\n readonly args: LoadCertificateArgs;\n readonly triggersDisconnection = false;\n\n constructor(args: LoadCertificateArgs) {\n this.args = args;\n }\n\n getApdu(): Apdu {\n const providePkiApduArgs: ApduBuilderArgs = {\n cla: 0xb0,\n ins: 0x06,\n p1: this.args.keyUsage,\n p2: 0x00,\n };\n return new ApduBuilder(providePkiApduArgs)\n .addBufferToData(this.args.certificate)\n .build();\n }\n\n parseResponse(apduResponse: ApduResponse): LoadCertificateCommandResult {\n if (CommandUtils.isSuccessResponse(apduResponse)) {\n return CommandResultFactory({\n data: undefined,\n });\n }\n const parser = new ApduParser(apduResponse);\n const errorCode = parser.encodeToHexaString(apduResponse.statusCode);\n if (isCommandErrorCode(errorCode, LOAD_CERTIFICATE_ERRORS)) {\n return CommandResultFactory({\n error: new LoadCertificateCommandError({\n ...LOAD_CERTIFICATE_ERRORS[errorCode],\n errorCode,\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AAIb,EAAYa,CAAkB,EACtC,gBAAgB,KAAK,KAAK,WAAW,EACrC,MAAM,CACX,CAEA,cAAcC,EAA0D,CACtE,GAAIV,EAAa,kBAAkBU,CAAY,EAC7C,OAAOZ,EAAqB,CAC1B,KAAM,MACR,CAAC,EAGH,MAAMQ,EADS,IAAIT,EAAWa,CAAY,EACjB,mBAAmBA,EAAa,UAAU,EACnE,OAAIX,EAAmBO,EAAWH,CAAuB,EAChDL,EAAqB,CAC1B,MAAO,IAAIM,EAA4B,CACrC,GAAGD,EAAwBG,CAAS,EACpC,UAAAA,CACF,CAAC,CACH,CAAC,EAEIR,EAAqB,CAC1B,MAAOG,EAA0B,OAAOS,CAAY,CACtD,CAAC,CACH,CACF",
6
6
  "names": ["ApduBuilder", "ApduParser", "CommandResultFactory", "isCommandErrorCode", "CommandUtils", "GlobalCommandErrorHandler", "DeviceExchangeError", "LOAD_CERTIFICATE_ERRORS", "LoadCertificateCommandError", "message", "errorCode", "LoadCertificateCommand", "args", "providePkiApduArgs", "apduResponse"]
7
7
  }
@@ -1,2 +1,2 @@
1
- import{CommandResultFactory as n,isSuccessCommandResult as o}from"../../command/model/CommandResult";import{LoadCertificateCommand as a,LoadCertificateCommandError as c}from"../../command/os/LoadCertificateCommand";import{GlobalCommandError as i}from"../../command/utils/GlobalCommandError";import{hexaStringToBuffer as d}from"../../utils/HexaString";describe("LoadCertificateCommand",()=>{describe("getApdu",()=>{it("should return the APDU with key equal to 1",()=>{const r={keyUsage:66,certificate:new Uint8Array([1,2,3])},e=new a(r).getApdu();expect(e.cla).toBe(176),expect(e.ins).toBe(6),expect(e.p1).toBe(66),expect(e.p2).toBe(0),expect(e.data).toStrictEqual(new Uint8Array([1,2,3]))})}),describe("parseResponse",()=>{let r;beforeEach(()=>{r=new a({keyUsage:1,certificate:new Uint8Array})}),it("should return success if the response status code is success",()=>{const t={statusCode:new Uint8Array([144,0]),data:new Uint8Array},e=r.parseResponse(t);expect(e).toStrictEqual(n({data:void 0}))}),describe("errors",()=>{it("should return error command result if the device is locked",()=>{const t={statusCode:new Uint8Array([85,21]),data:new Uint8Array},e=r.parseResponse(t);o(e)?assert.fail("Expected error command result"):expect(e.error).toBeInstanceOf(i)}),it.each(["422f","4230","4231","4232","4233","4234","4235","4236","4237","4238","4239","422d","3301","422e","5720","4118","ffff"])("should return a ProvidePkiCertificateCommandError if the response is a %s specific error code",t=>{const e={statusCode:d(t),data:new Uint8Array},s=r.parseResponse(e);o(s)?assert.fail("Expected error command result"):(expect(s.error).toBeInstanceOf(c),expect(s.error.errorCode).toBe(t))})})})});
1
+ import{CommandResultFactory as n,isSuccessCommandResult as a}from"../../command/model/CommandResult";import{LoadCertificateCommand as s,LoadCertificateCommandError as c}from"../../command/os/LoadCertificateCommand";import{GlobalCommandError as i}from"../../command/utils/GlobalCommandError";import{hexaStringToBuffer as d}from"../../utils/HexaString";describe("LoadCertificateCommand",()=>{describe("name",()=>{it("should be 'loadCertificate'",()=>{const t=new s({keyUsage:1,certificate:new Uint8Array});expect(t.name).toBe("loadCertificate")})}),describe("getApdu",()=>{it("should return the APDU with key equal to 1",()=>{const t={keyUsage:66,certificate:new Uint8Array([1,2,3])},e=new s(t).getApdu();expect(e.cla).toBe(176),expect(e.ins).toBe(6),expect(e.p1).toBe(66),expect(e.p2).toBe(0),expect(e.data).toStrictEqual(new Uint8Array([1,2,3]))})}),describe("parseResponse",()=>{let t;beforeEach(()=>{t=new s({keyUsage:1,certificate:new Uint8Array})}),it("should return success if the response status code is success",()=>{const r={statusCode:new Uint8Array([144,0]),data:new Uint8Array},e=t.parseResponse(r);expect(e).toStrictEqual(n({data:void 0}))}),describe("errors",()=>{it("should return error command result if the device is locked",()=>{const r={statusCode:new Uint8Array([85,21]),data:new Uint8Array},e=t.parseResponse(r);a(e)?assert.fail("Expected error command result"):expect(e.error).toBeInstanceOf(i)}),it.each(["422f","4230","4231","4232","4233","4234","4235","4236","4237","4238","4239","422d","3301","422e","5720","4118","ffff"])("should return a ProvidePkiCertificateCommandError if the response is a %s specific error code",r=>{const e={statusCode:d(r),data:new Uint8Array},o=t.parseResponse(e);a(o)?assert.fail("Expected error command result"):(expect(o.error).toBeInstanceOf(c),expect(o.error.errorCode).toBe(r))})})})});
2
2
  //# sourceMappingURL=LoadCertificateCommand.test.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../../../src/api/command/os/LoadCertificateCommand.test.ts"],
4
- "sourcesContent": ["import {\n CommandResultFactory,\n isSuccessCommandResult,\n} from \"@api/command/model/CommandResult\";\nimport {\n LoadCertificateCommand,\n LoadCertificateCommandError,\n} from \"@api/command/os/LoadCertificateCommand\";\nimport { GlobalCommandError } from \"@api/command/utils/GlobalCommandError\";\nimport { hexaStringToBuffer } from \"@api/utils/HexaString\";\n\ndescribe(\"LoadCertificateCommand\", () => {\n describe(\"getApdu\", () => {\n it(\"should return the APDU with key equal to 1\", () => {\n // GIVEN\n const args = {\n keyUsage: 0x42,\n certificate: new Uint8Array([0x01, 0x02, 0x03]),\n };\n const command = new LoadCertificateCommand(args);\n\n // WHEN\n const apdu = command.getApdu();\n\n // THEN\n expect(apdu.cla).toBe(0xb0);\n expect(apdu.ins).toBe(0x06);\n expect(apdu.p1).toBe(0x42);\n expect(apdu.p2).toBe(0x00);\n expect(apdu.data).toStrictEqual(new Uint8Array([0x01, 0x02, 0x03]));\n });\n });\n\n describe(\"parseResponse\", () => {\n let command: LoadCertificateCommand;\n\n beforeEach(() => {\n command = new LoadCertificateCommand({\n keyUsage: 0x01,\n certificate: new Uint8Array(),\n });\n });\n\n it(\"should return success if the response status code is success\", () => {\n // GIVEN\n const response = {\n statusCode: new Uint8Array([0x90, 0x00]),\n data: new Uint8Array(),\n };\n\n // WHEN\n const result = command.parseResponse(response);\n\n // THEN\n expect(result).toStrictEqual(CommandResultFactory({ data: undefined }));\n });\n\n describe(\"errors\", () => {\n it(\"should return error command result if the device is locked\", () => {\n // GIVEN\n const response = {\n statusCode: new Uint8Array([0x55, 0x15]),\n data: new Uint8Array(),\n };\n\n // WHEN\n const result = command.parseResponse(response);\n\n // THEN\n if (isSuccessCommandResult(result)) {\n assert.fail(\"Expected error command result\");\n } else {\n expect(result.error).toBeInstanceOf(GlobalCommandError);\n }\n });\n\n it.each([\n \"422f\",\n \"4230\",\n \"4231\",\n \"4232\",\n \"4233\",\n \"4234\",\n \"4235\",\n \"4236\",\n \"4237\",\n \"4238\",\n \"4239\",\n \"422d\",\n \"3301\",\n \"422e\",\n \"5720\",\n \"4118\",\n \"ffff\",\n ])(\n \"should return a ProvidePkiCertificateCommandError if the response is a %s specific error code\",\n (errorCode) => {\n // GIVEN\n const response = {\n statusCode: hexaStringToBuffer(errorCode)!,\n data: new Uint8Array(),\n };\n\n // WHEN\n const result = command.parseResponse(response);\n\n // THEN\n if (isSuccessCommandResult(result)) {\n assert.fail(\"Expected error command result\");\n } else {\n expect(result.error).toBeInstanceOf(LoadCertificateCommandError);\n // @ts-expect-error intended\n expect(result.error.errorCode).toBe(errorCode);\n }\n },\n );\n });\n });\n});\n"],
5
- "mappings": "AAAA,OACE,wBAAAA,EACA,0BAAAC,MACK,mCACP,OACE,0BAAAC,EACA,+BAAAC,MACK,yCACP,OAAS,sBAAAC,MAA0B,wCACnC,OAAS,sBAAAC,MAA0B,wBAEnC,SAAS,yBAA0B,IAAM,CACvC,SAAS,UAAW,IAAM,CACxB,GAAG,6CAA8C,IAAM,CAErD,MAAMC,EAAO,CACX,SAAU,GACV,YAAa,IAAI,WAAW,CAAC,EAAM,EAAM,CAAI,CAAC,CAChD,EAIMC,EAHU,IAAIL,EAAuBI,CAAI,EAG1B,QAAQ,EAG7B,OAAOC,EAAK,GAAG,EAAE,KAAK,GAAI,EAC1B,OAAOA,EAAK,GAAG,EAAE,KAAK,CAAI,EAC1B,OAAOA,EAAK,EAAE,EAAE,KAAK,EAAI,EACzB,OAAOA,EAAK,EAAE,EAAE,KAAK,CAAI,EACzB,OAAOA,EAAK,IAAI,EAAE,cAAc,IAAI,WAAW,CAAC,EAAM,EAAM,CAAI,CAAC,CAAC,CACpE,CAAC,CACH,CAAC,EAED,SAAS,gBAAiB,IAAM,CAC9B,IAAIC,EAEJ,WAAW,IAAM,CACfA,EAAU,IAAIN,EAAuB,CACnC,SAAU,EACV,YAAa,IAAI,UACnB,CAAC,CACH,CAAC,EAED,GAAG,+DAAgE,IAAM,CAEvE,MAAMO,EAAW,CACf,WAAY,IAAI,WAAW,CAAC,IAAM,CAAI,CAAC,EACvC,KAAM,IAAI,UACZ,EAGMC,EAASF,EAAQ,cAAcC,CAAQ,EAG7C,OAAOC,CAAM,EAAE,cAAcV,EAAqB,CAAE,KAAM,MAAU,CAAC,CAAC,CACxE,CAAC,EAED,SAAS,SAAU,IAAM,CACvB,GAAG,6DAA8D,IAAM,CAErE,MAAMS,EAAW,CACf,WAAY,IAAI,WAAW,CAAC,GAAM,EAAI,CAAC,EACvC,KAAM,IAAI,UACZ,EAGMC,EAASF,EAAQ,cAAcC,CAAQ,EAGzCR,EAAuBS,CAAM,EAC/B,OAAO,KAAK,+BAA+B,EAE3C,OAAOA,EAAO,KAAK,EAAE,eAAeN,CAAkB,CAE1D,CAAC,EAED,GAAG,KAAK,CACN,OACA,OACA,OACA,OACA,OACA,OACA,OACA,OACA,OACA,OACA,OACA,OACA,OACA,OACA,OACA,OACA,MACF,CAAC,EACC,gGACCO,GAAc,CAEb,MAAMF,EAAW,CACf,WAAYJ,EAAmBM,CAAS,EACxC,KAAM,IAAI,UACZ,EAGMD,EAASF,EAAQ,cAAcC,CAAQ,EAGzCR,EAAuBS,CAAM,EAC/B,OAAO,KAAK,+BAA+B,GAE3C,OAAOA,EAAO,KAAK,EAAE,eAAeP,CAA2B,EAE/D,OAAOO,EAAO,MAAM,SAAS,EAAE,KAAKC,CAAS,EAEjD,CACF,CACF,CAAC,CACH,CAAC,CACH,CAAC",
6
- "names": ["CommandResultFactory", "isSuccessCommandResult", "LoadCertificateCommand", "LoadCertificateCommandError", "GlobalCommandError", "hexaStringToBuffer", "args", "apdu", "command", "response", "result", "errorCode"]
4
+ "sourcesContent": ["import {\n CommandResultFactory,\n isSuccessCommandResult,\n} from \"@api/command/model/CommandResult\";\nimport {\n LoadCertificateCommand,\n LoadCertificateCommandError,\n} from \"@api/command/os/LoadCertificateCommand\";\nimport { GlobalCommandError } from \"@api/command/utils/GlobalCommandError\";\nimport { hexaStringToBuffer } from \"@api/utils/HexaString\";\n\ndescribe(\"LoadCertificateCommand\", () => {\n describe(\"name\", () => {\n it(\"should be 'loadCertificate'\", () => {\n const command = new LoadCertificateCommand({\n keyUsage: 0x01,\n certificate: new Uint8Array(),\n });\n expect(command.name).toBe(\"loadCertificate\");\n });\n });\n\n describe(\"getApdu\", () => {\n it(\"should return the APDU with key equal to 1\", () => {\n // GIVEN\n const args = {\n keyUsage: 0x42,\n certificate: new Uint8Array([0x01, 0x02, 0x03]),\n };\n const command = new LoadCertificateCommand(args);\n\n // WHEN\n const apdu = command.getApdu();\n\n // THEN\n expect(apdu.cla).toBe(0xb0);\n expect(apdu.ins).toBe(0x06);\n expect(apdu.p1).toBe(0x42);\n expect(apdu.p2).toBe(0x00);\n expect(apdu.data).toStrictEqual(new Uint8Array([0x01, 0x02, 0x03]));\n });\n });\n\n describe(\"parseResponse\", () => {\n let command: LoadCertificateCommand;\n\n beforeEach(() => {\n command = new LoadCertificateCommand({\n keyUsage: 0x01,\n certificate: new Uint8Array(),\n });\n });\n\n it(\"should return success if the response status code is success\", () => {\n // GIVEN\n const response = {\n statusCode: new Uint8Array([0x90, 0x00]),\n data: new Uint8Array(),\n };\n\n // WHEN\n const result = command.parseResponse(response);\n\n // THEN\n expect(result).toStrictEqual(CommandResultFactory({ data: undefined }));\n });\n\n describe(\"errors\", () => {\n it(\"should return error command result if the device is locked\", () => {\n // GIVEN\n const response = {\n statusCode: new Uint8Array([0x55, 0x15]),\n data: new Uint8Array(),\n };\n\n // WHEN\n const result = command.parseResponse(response);\n\n // THEN\n if (isSuccessCommandResult(result)) {\n assert.fail(\"Expected error command result\");\n } else {\n expect(result.error).toBeInstanceOf(GlobalCommandError);\n }\n });\n\n it.each([\n \"422f\",\n \"4230\",\n \"4231\",\n \"4232\",\n \"4233\",\n \"4234\",\n \"4235\",\n \"4236\",\n \"4237\",\n \"4238\",\n \"4239\",\n \"422d\",\n \"3301\",\n \"422e\",\n \"5720\",\n \"4118\",\n \"ffff\",\n ])(\n \"should return a ProvidePkiCertificateCommandError if the response is a %s specific error code\",\n (errorCode) => {\n // GIVEN\n const response = {\n statusCode: hexaStringToBuffer(errorCode)!,\n data: new Uint8Array(),\n };\n\n // WHEN\n const result = command.parseResponse(response);\n\n // THEN\n if (isSuccessCommandResult(result)) {\n assert.fail(\"Expected error command result\");\n } else {\n expect(result.error).toBeInstanceOf(LoadCertificateCommandError);\n // @ts-expect-error intended\n expect(result.error.errorCode).toBe(errorCode);\n }\n },\n );\n });\n });\n});\n"],
5
+ "mappings": "AAAA,OACE,wBAAAA,EACA,0BAAAC,MACK,mCACP,OACE,0BAAAC,EACA,+BAAAC,MACK,yCACP,OAAS,sBAAAC,MAA0B,wCACnC,OAAS,sBAAAC,MAA0B,wBAEnC,SAAS,yBAA0B,IAAM,CACvC,SAAS,OAAQ,IAAM,CACrB,GAAG,8BAA+B,IAAM,CACtC,MAAMC,EAAU,IAAIJ,EAAuB,CACzC,SAAU,EACV,YAAa,IAAI,UACnB,CAAC,EACD,OAAOI,EAAQ,IAAI,EAAE,KAAK,iBAAiB,CAC7C,CAAC,CACH,CAAC,EAED,SAAS,UAAW,IAAM,CACxB,GAAG,6CAA8C,IAAM,CAErD,MAAMC,EAAO,CACX,SAAU,GACV,YAAa,IAAI,WAAW,CAAC,EAAM,EAAM,CAAI,CAAC,CAChD,EAIMC,EAHU,IAAIN,EAAuBK,CAAI,EAG1B,QAAQ,EAG7B,OAAOC,EAAK,GAAG,EAAE,KAAK,GAAI,EAC1B,OAAOA,EAAK,GAAG,EAAE,KAAK,CAAI,EAC1B,OAAOA,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,CACF,CACF,CAAC,CACH,CAAC,CACH,CAAC",
6
+ "names": ["CommandResultFactory", "isSuccessCommandResult", "LoadCertificateCommand", "LoadCertificateCommandError", "GlobalCommandError", "hexaStringToBuffer", "command", "args", "apdu", "response", "result", "errorCode"]
7
7
  }
@@ -1,2 +1,2 @@
1
- import{ApduBuilder as m}from"../../apdu/utils/ApduBuilder";import{ApduParser as t}from"../../apdu/utils/ApduParser";import{CommandResultFactory as o}from"../../command/model/CommandResult";import{isCommandErrorCode as d}from"../../command/utils/CommandErrors";import{CommandUtils as a}from"../../command/utils/CommandUtils";import{GlobalCommandErrorHandler as i}from"../../command/utils/GlobalCommandError";import{DeviceExchangeError as A}from"../../Error";const n={"670a":{message:"No app name provided"},6807:{message:"Unknown application name"}};class u extends A{constructor({message:r,errorCode:p}){super({tag:"OpenAppCommandError",message:r,errorCode:p})}}class f{args;triggersDisconnection=!0;constructor(r){this.args=r}getApdu(){const r={cla:224,ins:216,p1:0,p2:0};return new m(r).addAsciiStringToData(this.args.appName).build()}parseResponse(r){if(a.isSuccessResponse(r))return o({data:void 0});const e=new t(r).encodeToHexaString(r.statusCode);return d(e,n)?o({error:new u({...n[e],errorCode:e})}):o({error:i.handle(r)})}}export{f as OpenAppCommand,u as OpenAppCommandError};
1
+ import{ApduBuilder as s}from"../../apdu/utils/ApduBuilder";import{ApduParser as t}from"../../apdu/utils/ApduParser";import{CommandResultFactory as o}from"../../command/model/CommandResult";import{isCommandErrorCode as d}from"../../command/utils/CommandErrors";import{CommandUtils as a}from"../../command/utils/CommandUtils";import{GlobalCommandErrorHandler as i}from"../../command/utils/GlobalCommandError";import{DeviceExchangeError as A}from"../../Error";const n={"670a":{message:"No app name provided"},6807:{message:"Unknown application name"}};class u extends A{constructor({message:r,errorCode:p}){super({tag:"OpenAppCommandError",message:r,errorCode:p})}}class f{name="openApp";args;triggersDisconnection=!0;constructor(r){this.args=r}getApdu(){const r={cla:224,ins:216,p1:0,p2:0};return new s(r).addAsciiStringToData(this.args.appName).build()}parseResponse(r){if(a.isSuccessResponse(r))return o({data:void 0});const e=new t(r).encodeToHexaString(r.statusCode);return d(e,n)?o({error:new u({...n[e],errorCode:e})}):o({error:i.handle(r)})}}export{f as OpenAppCommand,u as OpenAppCommandError};
2
2
  //# sourceMappingURL=OpenAppCommand.js.map