@ledgerhq/device-signer-kit-ethereum 0.0.0-rn-hid-20250221112139 → 0.0.0-rn-ble-logs-20250416162013

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 (188) hide show
  1. package/README.md +14 -2
  2. package/lib/cjs/api/app-binder/GetConfigCommandTypes.js +2 -0
  3. package/lib/cjs/api/app-binder/GetConfigCommandTypes.js.map +7 -0
  4. package/lib/cjs/api/app-binder/SignTransactionDeviceActionTypes.js +1 -1
  5. package/lib/cjs/api/app-binder/SignTransactionDeviceActionTypes.js.map +3 -3
  6. package/lib/cjs/api/app-binder/SignTypedDataDeviceActionTypes.js +1 -1
  7. package/lib/cjs/api/app-binder/SignTypedDataDeviceActionTypes.js.map +3 -3
  8. package/lib/cjs/api/index.js +1 -1
  9. package/lib/cjs/api/index.js.map +3 -3
  10. package/lib/cjs/internal/app-binder/EthAppBinder.test.js +1 -1
  11. package/lib/cjs/internal/app-binder/EthAppBinder.test.js.map +2 -2
  12. package/lib/cjs/internal/app-binder/command/GetAppConfigurationCommand.js +2 -0
  13. package/lib/cjs/internal/app-binder/command/GetAppConfigurationCommand.js.map +7 -0
  14. package/lib/cjs/internal/app-binder/command/GetAppConfigurationCommand.test.js +2 -0
  15. package/lib/cjs/internal/app-binder/command/GetAppConfigurationCommand.test.js.map +7 -0
  16. package/lib/cjs/internal/app-binder/command/ProvideWeb3CheckCommand.js +2 -0
  17. package/lib/cjs/internal/app-binder/command/ProvideWeb3CheckCommand.js.map +7 -0
  18. package/lib/cjs/internal/app-binder/command/ProvideWeb3CheckCommand.test.js +2 -0
  19. package/lib/cjs/internal/app-binder/command/ProvideWeb3CheckCommand.test.js.map +7 -0
  20. package/lib/cjs/internal/app-binder/command/SendEIP712FilteringCommand.js +1 -1
  21. package/lib/cjs/internal/app-binder/command/SendEIP712FilteringCommand.js.map +2 -2
  22. package/lib/cjs/internal/app-binder/command/SendEIP712FilteringCommand.test.js +1 -1
  23. package/lib/cjs/internal/app-binder/command/SendEIP712FilteringCommand.test.js.map +3 -3
  24. package/lib/cjs/internal/app-binder/command/Web3CheckOptInCommand.js +2 -0
  25. package/lib/cjs/internal/app-binder/command/Web3CheckOptInCommand.js.map +7 -0
  26. package/lib/cjs/internal/app-binder/command/Web3CheckOptInCommand.test.js +2 -0
  27. package/lib/cjs/internal/app-binder/command/Web3CheckOptInCommand.test.js.map +7 -0
  28. package/lib/cjs/internal/app-binder/constant/plugins.js +1 -1
  29. package/lib/cjs/internal/app-binder/constant/plugins.js.map +2 -2
  30. package/lib/cjs/internal/app-binder/device-action/SignTransaction/SignTransactionDeviceAction.js +1 -1
  31. package/lib/cjs/internal/app-binder/device-action/SignTransaction/SignTransactionDeviceAction.js.map +3 -3
  32. package/lib/cjs/internal/app-binder/device-action/SignTransaction/SignTransactionDeviceAction.test.js +1 -1
  33. package/lib/cjs/internal/app-binder/device-action/SignTransaction/SignTransactionDeviceAction.test.js.map +3 -3
  34. package/lib/cjs/internal/app-binder/device-action/SignTypedData/SignTypedDataDeviceAction.js +1 -1
  35. package/lib/cjs/internal/app-binder/device-action/SignTypedData/SignTypedDataDeviceAction.js.map +3 -3
  36. package/lib/cjs/internal/app-binder/device-action/SignTypedData/SignTypedDataDeviceAction.test.js +1 -1
  37. package/lib/cjs/internal/app-binder/device-action/SignTypedData/SignTypedDataDeviceAction.test.js.map +3 -3
  38. package/lib/cjs/internal/app-binder/device-action/__test-utils__/makeInternalApi.js +1 -1
  39. package/lib/cjs/internal/app-binder/device-action/__test-utils__/makeInternalApi.js.map +3 -3
  40. package/lib/cjs/internal/app-binder/task/BuildEIP712ContextTask.js +1 -1
  41. package/lib/cjs/internal/app-binder/task/BuildEIP712ContextTask.js.map +3 -3
  42. package/lib/cjs/internal/app-binder/task/BuildEIP712ContextTask.test.js +1 -1
  43. package/lib/cjs/internal/app-binder/task/BuildEIP712ContextTask.test.js.map +3 -3
  44. package/lib/cjs/internal/app-binder/task/BuildTransactionContextTask.js +1 -1
  45. package/lib/cjs/internal/app-binder/task/BuildTransactionContextTask.js.map +3 -3
  46. package/lib/cjs/internal/app-binder/task/BuildTransactionContextTask.test.js +1 -1
  47. package/lib/cjs/internal/app-binder/task/BuildTransactionContextTask.test.js.map +3 -3
  48. package/lib/cjs/internal/app-binder/task/GetWeb3CheckTask.js +2 -0
  49. package/lib/cjs/internal/app-binder/task/GetWeb3CheckTask.js.map +7 -0
  50. package/lib/cjs/internal/app-binder/task/GetWeb3CheckTask.test.js +2 -0
  51. package/lib/cjs/internal/app-binder/task/GetWeb3CheckTask.test.js.map +7 -0
  52. package/lib/cjs/internal/app-binder/task/ProvideEIP712ContextTask.js +1 -1
  53. package/lib/cjs/internal/app-binder/task/ProvideEIP712ContextTask.js.map +3 -3
  54. package/lib/cjs/internal/app-binder/task/ProvideEIP712ContextTask.test.js +1 -1
  55. package/lib/cjs/internal/app-binder/task/ProvideEIP712ContextTask.test.js.map +3 -3
  56. package/lib/cjs/internal/app-binder/task/ProvideTransactionContextTask.js +1 -1
  57. package/lib/cjs/internal/app-binder/task/ProvideTransactionContextTask.js.map +3 -3
  58. package/lib/cjs/internal/app-binder/task/ProvideTransactionContextTask.test.js +1 -1
  59. package/lib/cjs/internal/app-binder/task/ProvideTransactionContextTask.test.js.map +3 -3
  60. package/lib/cjs/internal/app-binder/task/ProvideTransactionFieldDescriptionTask.js +1 -1
  61. package/lib/cjs/internal/app-binder/task/ProvideTransactionFieldDescriptionTask.js.map +3 -3
  62. package/lib/cjs/internal/app-binder/task/ProvideTransactionGenericContextTask.js +1 -1
  63. package/lib/cjs/internal/app-binder/task/ProvideTransactionGenericContextTask.js.map +3 -3
  64. package/lib/cjs/internal/app-binder/task/ProvideTransactionGenericContextTask.test.js +1 -1
  65. package/lib/cjs/internal/app-binder/task/ProvideTransactionGenericContextTask.test.js.map +2 -2
  66. package/lib/cjs/internal/shared/utils/ApplicationChecker.js +2 -0
  67. package/lib/cjs/internal/shared/utils/ApplicationChecker.js.map +7 -0
  68. package/lib/cjs/internal/shared/utils/ApplicationChecker.test.js +2 -0
  69. package/lib/cjs/internal/shared/utils/ApplicationChecker.test.js.map +7 -0
  70. package/lib/cjs/package.json +2 -2
  71. package/lib/esm/api/app-binder/GetConfigCommandTypes.js +1 -0
  72. package/lib/esm/api/app-binder/GetConfigCommandTypes.js.map +7 -0
  73. package/lib/esm/api/app-binder/SignTransactionDeviceActionTypes.js +1 -0
  74. package/lib/esm/api/app-binder/SignTransactionDeviceActionTypes.js.map +4 -4
  75. package/lib/esm/api/app-binder/SignTypedDataDeviceActionTypes.js +1 -0
  76. package/lib/esm/api/app-binder/SignTypedDataDeviceActionTypes.js.map +4 -4
  77. package/lib/esm/api/index.js +1 -1
  78. package/lib/esm/api/index.js.map +3 -3
  79. package/lib/esm/internal/app-binder/EthAppBinder.test.js +1 -1
  80. package/lib/esm/internal/app-binder/EthAppBinder.test.js.map +2 -2
  81. package/lib/esm/internal/app-binder/command/GetAppConfigurationCommand.js +2 -0
  82. package/lib/esm/internal/app-binder/command/GetAppConfigurationCommand.js.map +7 -0
  83. package/lib/esm/internal/app-binder/command/GetAppConfigurationCommand.test.js +2 -0
  84. package/lib/esm/internal/app-binder/command/GetAppConfigurationCommand.test.js.map +7 -0
  85. package/lib/esm/internal/app-binder/command/ProvideWeb3CheckCommand.js +2 -0
  86. package/lib/esm/internal/app-binder/command/ProvideWeb3CheckCommand.js.map +7 -0
  87. package/lib/esm/internal/app-binder/command/ProvideWeb3CheckCommand.test.js +2 -0
  88. package/lib/esm/internal/app-binder/command/ProvideWeb3CheckCommand.test.js.map +7 -0
  89. package/lib/esm/internal/app-binder/command/SendEIP712FilteringCommand.js +1 -1
  90. package/lib/esm/internal/app-binder/command/SendEIP712FilteringCommand.js.map +2 -2
  91. package/lib/esm/internal/app-binder/command/SendEIP712FilteringCommand.test.js +1 -1
  92. package/lib/esm/internal/app-binder/command/SendEIP712FilteringCommand.test.js.map +3 -3
  93. package/lib/esm/internal/app-binder/command/Web3CheckOptInCommand.js +2 -0
  94. package/lib/esm/internal/app-binder/command/Web3CheckOptInCommand.js.map +7 -0
  95. package/lib/esm/internal/app-binder/command/Web3CheckOptInCommand.test.js +2 -0
  96. package/lib/esm/internal/app-binder/command/Web3CheckOptInCommand.test.js.map +7 -0
  97. package/lib/esm/internal/app-binder/constant/plugins.js +1 -1
  98. package/lib/esm/internal/app-binder/constant/plugins.js.map +2 -2
  99. package/lib/esm/internal/app-binder/device-action/SignTransaction/SignTransactionDeviceAction.js +1 -1
  100. package/lib/esm/internal/app-binder/device-action/SignTransaction/SignTransactionDeviceAction.js.map +3 -3
  101. package/lib/esm/internal/app-binder/device-action/SignTransaction/SignTransactionDeviceAction.test.js +1 -1
  102. package/lib/esm/internal/app-binder/device-action/SignTransaction/SignTransactionDeviceAction.test.js.map +3 -3
  103. package/lib/esm/internal/app-binder/device-action/SignTypedData/SignTypedDataDeviceAction.js +1 -1
  104. package/lib/esm/internal/app-binder/device-action/SignTypedData/SignTypedDataDeviceAction.js.map +3 -3
  105. package/lib/esm/internal/app-binder/device-action/SignTypedData/SignTypedDataDeviceAction.test.js +1 -1
  106. package/lib/esm/internal/app-binder/device-action/SignTypedData/SignTypedDataDeviceAction.test.js.map +3 -3
  107. package/lib/esm/internal/app-binder/device-action/__test-utils__/makeInternalApi.js +1 -1
  108. package/lib/esm/internal/app-binder/device-action/__test-utils__/makeInternalApi.js.map +3 -3
  109. package/lib/esm/internal/app-binder/task/BuildEIP712ContextTask.js +1 -1
  110. package/lib/esm/internal/app-binder/task/BuildEIP712ContextTask.js.map +3 -3
  111. package/lib/esm/internal/app-binder/task/BuildEIP712ContextTask.test.js +1 -1
  112. package/lib/esm/internal/app-binder/task/BuildEIP712ContextTask.test.js.map +3 -3
  113. package/lib/esm/internal/app-binder/task/BuildTransactionContextTask.js +1 -1
  114. package/lib/esm/internal/app-binder/task/BuildTransactionContextTask.js.map +3 -3
  115. package/lib/esm/internal/app-binder/task/BuildTransactionContextTask.test.js +1 -1
  116. package/lib/esm/internal/app-binder/task/BuildTransactionContextTask.test.js.map +3 -3
  117. package/lib/esm/internal/app-binder/task/GetWeb3CheckTask.js +2 -0
  118. package/lib/esm/internal/app-binder/task/GetWeb3CheckTask.js.map +7 -0
  119. package/lib/esm/internal/app-binder/task/GetWeb3CheckTask.test.js +2 -0
  120. package/lib/esm/internal/app-binder/task/GetWeb3CheckTask.test.js.map +7 -0
  121. package/lib/esm/internal/app-binder/task/ProvideEIP712ContextTask.js +1 -1
  122. package/lib/esm/internal/app-binder/task/ProvideEIP712ContextTask.js.map +3 -3
  123. package/lib/esm/internal/app-binder/task/ProvideEIP712ContextTask.test.js +1 -1
  124. package/lib/esm/internal/app-binder/task/ProvideEIP712ContextTask.test.js.map +3 -3
  125. package/lib/esm/internal/app-binder/task/ProvideTransactionContextTask.js +1 -1
  126. package/lib/esm/internal/app-binder/task/ProvideTransactionContextTask.js.map +3 -3
  127. package/lib/esm/internal/app-binder/task/ProvideTransactionContextTask.test.js +1 -1
  128. package/lib/esm/internal/app-binder/task/ProvideTransactionContextTask.test.js.map +3 -3
  129. package/lib/esm/internal/app-binder/task/ProvideTransactionFieldDescriptionTask.js +1 -1
  130. package/lib/esm/internal/app-binder/task/ProvideTransactionFieldDescriptionTask.js.map +3 -3
  131. package/lib/esm/internal/app-binder/task/ProvideTransactionGenericContextTask.js +1 -1
  132. package/lib/esm/internal/app-binder/task/ProvideTransactionGenericContextTask.js.map +3 -3
  133. package/lib/esm/internal/app-binder/task/ProvideTransactionGenericContextTask.test.js +1 -1
  134. package/lib/esm/internal/app-binder/task/ProvideTransactionGenericContextTask.test.js.map +2 -2
  135. package/lib/esm/internal/shared/utils/ApplicationChecker.js +2 -0
  136. package/lib/esm/internal/shared/utils/ApplicationChecker.js.map +7 -0
  137. package/lib/esm/internal/shared/utils/ApplicationChecker.test.js +2 -0
  138. package/lib/esm/internal/shared/utils/ApplicationChecker.test.js.map +7 -0
  139. package/lib/esm/package.json +2 -2
  140. package/lib/types/api/app-binder/GetConfigCommandTypes.d.ts +7 -0
  141. package/lib/types/api/app-binder/GetConfigCommandTypes.d.ts.map +1 -0
  142. package/lib/types/api/app-binder/SignTransactionDeviceActionTypes.d.ts +15 -3
  143. package/lib/types/api/app-binder/SignTransactionDeviceActionTypes.d.ts.map +1 -1
  144. package/lib/types/api/app-binder/SignTypedDataDeviceActionTypes.d.ts +14 -1
  145. package/lib/types/api/app-binder/SignTypedDataDeviceActionTypes.d.ts.map +1 -1
  146. package/lib/types/api/index.d.ts +2 -2
  147. package/lib/types/api/index.d.ts.map +1 -1
  148. package/lib/types/internal/app-binder/command/GetAppConfigurationCommand.d.ts +10 -0
  149. package/lib/types/internal/app-binder/command/GetAppConfigurationCommand.d.ts.map +1 -0
  150. package/lib/types/internal/app-binder/command/GetAppConfigurationCommand.test.d.ts +2 -0
  151. package/lib/types/internal/app-binder/command/GetAppConfigurationCommand.test.d.ts.map +1 -0
  152. package/lib/types/internal/app-binder/command/ProvideWeb3CheckCommand.d.ts +17 -0
  153. package/lib/types/internal/app-binder/command/ProvideWeb3CheckCommand.d.ts.map +1 -0
  154. package/lib/types/internal/app-binder/command/ProvideWeb3CheckCommand.test.d.ts +2 -0
  155. package/lib/types/internal/app-binder/command/ProvideWeb3CheckCommand.test.d.ts.map +1 -0
  156. package/lib/types/internal/app-binder/command/SendEIP712FilteringCommand.d.ts +8 -1
  157. package/lib/types/internal/app-binder/command/SendEIP712FilteringCommand.d.ts.map +1 -1
  158. package/lib/types/internal/app-binder/command/Web3CheckOptInCommand.d.ts +15 -0
  159. package/lib/types/internal/app-binder/command/Web3CheckOptInCommand.d.ts.map +1 -0
  160. package/lib/types/internal/app-binder/command/Web3CheckOptInCommand.test.d.ts +2 -0
  161. package/lib/types/internal/app-binder/command/Web3CheckOptInCommand.test.d.ts.map +1 -0
  162. package/lib/types/internal/app-binder/constant/plugins.d.ts.map +1 -1
  163. package/lib/types/internal/app-binder/device-action/SignTransaction/SignTransactionDeviceAction.d.ts +9 -4
  164. package/lib/types/internal/app-binder/device-action/SignTransaction/SignTransactionDeviceAction.d.ts.map +1 -1
  165. package/lib/types/internal/app-binder/device-action/SignTypedData/SignTypedDataDeviceAction.d.ts +7 -0
  166. package/lib/types/internal/app-binder/device-action/SignTypedData/SignTypedDataDeviceAction.d.ts.map +1 -1
  167. package/lib/types/internal/app-binder/device-action/__test-utils__/makeInternalApi.d.ts.map +1 -1
  168. package/lib/types/internal/app-binder/task/BuildEIP712ContextTask.d.ts +10 -5
  169. package/lib/types/internal/app-binder/task/BuildEIP712ContextTask.d.ts.map +1 -1
  170. package/lib/types/internal/app-binder/task/BuildTransactionContextTask.d.ts +8 -3
  171. package/lib/types/internal/app-binder/task/BuildTransactionContextTask.d.ts.map +1 -1
  172. package/lib/types/internal/app-binder/task/GetWeb3CheckTask.d.ts +30 -0
  173. package/lib/types/internal/app-binder/task/GetWeb3CheckTask.d.ts.map +1 -0
  174. package/lib/types/internal/app-binder/task/GetWeb3CheckTask.test.d.ts +2 -0
  175. package/lib/types/internal/app-binder/task/GetWeb3CheckTask.test.d.ts.map +1 -0
  176. package/lib/types/internal/app-binder/task/ProvideEIP712ContextTask.d.ts +7 -2
  177. package/lib/types/internal/app-binder/task/ProvideEIP712ContextTask.d.ts.map +1 -1
  178. package/lib/types/internal/app-binder/task/ProvideTransactionContextTask.d.ts +3 -2
  179. package/lib/types/internal/app-binder/task/ProvideTransactionContextTask.d.ts.map +1 -1
  180. package/lib/types/internal/app-binder/task/ProvideTransactionFieldDescriptionTask.d.ts.map +1 -1
  181. package/lib/types/internal/app-binder/task/ProvideTransactionGenericContextTask.d.ts +1 -0
  182. package/lib/types/internal/app-binder/task/ProvideTransactionGenericContextTask.d.ts.map +1 -1
  183. package/lib/types/internal/shared/utils/ApplicationChecker.d.ts +13 -0
  184. package/lib/types/internal/shared/utils/ApplicationChecker.d.ts.map +1 -0
  185. package/lib/types/internal/shared/utils/ApplicationChecker.test.d.ts +2 -0
  186. package/lib/types/internal/shared/utils/ApplicationChecker.test.d.ts.map +1 -0
  187. package/lib/types/tsconfig.prod.tsbuildinfo +1 -1
  188. package/package.json +8 -8
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../../src/internal/app-binder/task/ProvideTransactionContextTask.test.ts"],
4
- "sourcesContent": ["import { ClearSignContextType } from \"@ledgerhq/context-module\";\nimport {\n CommandResultFactory,\n type UnknownDeviceExchangeError,\n} from \"@ledgerhq/device-management-kit\";\n\nimport { ProvideNFTInformationCommand } from \"@internal/app-binder/command/ProvideNFTInformationCommand\";\nimport { ProvideTokenInformationCommand } from \"@internal/app-binder/command/ProvideTokenInformationCommand\";\nimport { SetExternalPluginCommand } from \"@internal/app-binder/command/SetExternalPluginCommand\";\nimport { SetPluginCommand } from \"@internal/app-binder/command/SetPluginCommand\";\nimport { type EthErrorCodes } from \"@internal/app-binder/command/utils/ethAppErrors\";\nimport { makeDeviceActionInternalApiMock } from \"@internal/app-binder/device-action/__test-utils__/makeInternalApi\";\n\nimport {\n ProvideTransactionContextTask,\n type ProvideTransactionContextTaskArgs,\n} from \"./ProvideTransactionContextTask\";\n\ndescribe(\"ProvideTransactionContextTask\", () => {\n const api = makeDeviceActionInternalApiMock();\n const successResult = CommandResultFactory<void, EthErrorCodes>({\n data: undefined,\n });\n const errorResult = CommandResultFactory<void, EthErrorCodes>({\n data: undefined,\n error: {} as UnknownDeviceExchangeError,\n });\n\n beforeEach(() => {\n vi.resetAllMocks();\n });\n\n describe(\"run\", () => {\n const args: ProvideTransactionContextTaskArgs = {\n clearSignContexts: [\n {\n type: ClearSignContextType.PLUGIN,\n payload: \"706c7567696e\", // \"plugin\"\n },\n {\n type: ClearSignContextType.EXTERNAL_PLUGIN,\n payload: \"65787465726e616c506c7567696e\", // \"externalPlugin\"\n },\n {\n type: ClearSignContextType.NFT,\n payload: \"6e6674\", // \"nft\"\n },\n {\n type: ClearSignContextType.TOKEN,\n payload: \"746f6b656e\", // \"token\"\n },\n ],\n };\n afterEach(() => {\n vi.restoreAllMocks();\n });\n it(\"should send relative commands when receiving ClearSignContexts of type not trustedName\", async () => {\n api.sendCommand.mockResolvedValue(successResult);\n // GIVEN\n const task = new ProvideTransactionContextTask(api, args);\n // WHEN\n await task.run();\n // THEN\n expect(api.sendCommand).toHaveBeenCalledTimes(4);\n expect(api.sendCommand).toHaveBeenNthCalledWith(\n args.clearSignContexts.findIndex(\n (c) => c.type === ClearSignContextType.PLUGIN,\n ) + 1,\n expect.objectContaining(\n new SetPluginCommand({ payload: \"706c7567696e\" }),\n ),\n );\n expect(api.sendCommand).toHaveBeenNthCalledWith(\n args.clearSignContexts.findIndex(\n (c) => c.type === ClearSignContextType.EXTERNAL_PLUGIN,\n ) + 1,\n expect.objectContaining(\n new SetExternalPluginCommand({\n payload: \"65787465726e616c506c7567696e\",\n }),\n ),\n );\n expect(api.sendCommand).toHaveBeenNthCalledWith(\n args.clearSignContexts.findIndex(\n (c) => c.type === ClearSignContextType.NFT,\n ) + 1,\n expect.objectContaining(\n new ProvideNFTInformationCommand({ payload: \"6e6674\" }),\n ),\n );\n expect(api.sendCommand).toHaveBeenNthCalledWith(\n args.clearSignContexts.findIndex(\n (c) => c.type === ClearSignContextType.TOKEN,\n ) + 1,\n expect.objectContaining(\n new ProvideTokenInformationCommand({ payload: \"746f6b656e\" }),\n ),\n );\n });\n it(\"should return the command error result and stop when the command fails\", async () => {\n api.sendCommand.mockReset();\n api.sendCommand.mockResolvedValueOnce(errorResult);\n // GIVEN\n const task = new ProvideTransactionContextTask(api, args);\n // WHEN\n const result = await task.run();\n // THEN\n expect(api.sendCommand).toHaveBeenCalledTimes(1);\n expect(result.isJust()).toBe(true);\n expect(result.extract()).toStrictEqual(errorResult);\n });\n });\n});\n"],
5
- "mappings": "AAAA,OAAS,wBAAAA,MAA4B,2BACrC,OACE,wBAAAC,MAEK,kCAEP,OAAS,gCAAAC,MAAoC,4DAC7C,OAAS,kCAAAC,MAAsC,8DAC/C,OAAS,4BAAAC,MAA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QAAS,CAAC,CACxD,CACF,EACA,OAAOM,EAAI,WAAW,EAAE,wBACtBG,EAAK,kBAAkB,UACpBC,GAAMA,EAAE,OAASZ,EAAqB,KACzC,EAAI,EACJ,OAAO,iBACL,IAAIG,EAA+B,CAAE,QAAS,YAAa,CAAC,CAC9D,CACF,CACF,CAAC,EACD,GAAG,yEAA0E,SAAY,CACvFK,EAAI,YAAY,UAAU,EAC1BA,EAAI,YAAY,sBAAsBE,CAAW,EAIjD,MAAMG,EAAS,MAFF,IAAIN,EAA8BC,EAAKG,CAAI,EAE9B,IAAI,EAE9B,OAAOH,EAAI,WAAW,EAAE,sBAAsB,CAAC,EAC/C,OAAOK,EAAO,OAAO,CAAC,EAAE,KAAK,EAAI,EACjC,OAAOA,EAAO,QAAQ,CAAC,EAAE,cAAcH,CAAW,CACpD,CAAC,CACH,CAAC,CACH,CAAC",
6
- "names": ["ClearSignContextType", "CommandResultFactory", "ProvideNFTInformationCommand", "ProvideTokenInformationCommand", "SetExternalPluginCommand", "SetPluginCommand", "makeDeviceActionInternalApiMock", "ProvideTransactionContextTask", "api", "successResult", "errorResult", "args", "c", "result"]
4
+ "sourcesContent": ["import { ClearSignContextType } from \"@ledgerhq/context-module\";\nimport {\n CommandResultFactory,\n hexaStringToBuffer,\n LoadCertificateCommand,\n type UnknownDeviceExchangeError,\n} from \"@ledgerhq/device-management-kit\";\n\nimport { ProvideNFTInformationCommand } from \"@internal/app-binder/command/ProvideNFTInformationCommand\";\nimport { ProvideTokenInformationCommand } from \"@internal/app-binder/command/ProvideTokenInformationCommand\";\nimport { ProvideWeb3CheckCommand } from \"@internal/app-binder/command/ProvideWeb3CheckCommand\";\nimport { SetExternalPluginCommand } from \"@internal/app-binder/command/SetExternalPluginCommand\";\nimport { SetPluginCommand } from \"@internal/app-binder/command/SetPluginCommand\";\nimport { type EthErrorCodes } from \"@internal/app-binder/command/utils/ethAppErrors\";\nimport { makeDeviceActionInternalApiMock } from \"@internal/app-binder/device-action/__test-utils__/makeInternalApi\";\n\nimport {\n ProvideTransactionContextTask,\n type ProvideTransactionContextTaskArgs,\n} from \"./ProvideTransactionContextTask\";\n\ndescribe(\"ProvideTransactionContextTask\", () => {\n const api = makeDeviceActionInternalApiMock();\n const successResult = CommandResultFactory<void, EthErrorCodes>({\n data: undefined,\n });\n const errorResult = CommandResultFactory<void, EthErrorCodes>({\n data: undefined,\n error: {} as UnknownDeviceExchangeError,\n });\n\n beforeEach(() => {\n vi.resetAllMocks();\n });\n\n describe(\"run\", () => {\n const args: ProvideTransactionContextTaskArgs = {\n clearSignContexts: [\n {\n type: ClearSignContextType.PLUGIN,\n payload: \"706c7567696e\", // \"plugin\"\n },\n {\n type: ClearSignContextType.EXTERNAL_PLUGIN,\n payload: \"65787465726e616c506c7567696e\", // \"externalPlugin\"\n },\n {\n type: ClearSignContextType.NFT,\n payload: \"6e6674\", // \"nft\"\n },\n {\n type: ClearSignContextType.TOKEN,\n payload: \"746f6b656e\", // \"token\"\n },\n ],\n web3Check: null,\n };\n\n beforeEach(() => {\n vi.resetAllMocks();\n });\n\n it(\"should send relative commands when receiving ClearSignContexts of type not trustedName\", async () => {\n api.sendCommand.mockResolvedValue(successResult);\n // GIVEN\n const task = new ProvideTransactionContextTask(api, args);\n // WHEN\n await task.run();\n // THEN\n expect(api.sendCommand).toHaveBeenCalledTimes(4);\n expect(api.sendCommand).toHaveBeenNthCalledWith(\n args.clearSignContexts.findIndex(\n (c) => c.type === ClearSignContextType.PLUGIN,\n ) + 1,\n expect.objectContaining(\n new SetPluginCommand({ payload: \"706c7567696e\" }),\n ),\n );\n expect(api.sendCommand).toHaveBeenNthCalledWith(\n args.clearSignContexts.findIndex(\n (c) => c.type === ClearSignContextType.EXTERNAL_PLUGIN,\n ) + 1,\n expect.objectContaining(\n new SetExternalPluginCommand({\n payload: \"65787465726e616c506c7567696e\",\n }),\n ),\n );\n expect(api.sendCommand).toHaveBeenNthCalledWith(\n args.clearSignContexts.findIndex(\n (c) => c.type === ClearSignContextType.NFT,\n ) + 1,\n expect.objectContaining(\n new ProvideNFTInformationCommand({ payload: \"6e6674\" }),\n ),\n );\n expect(api.sendCommand).toHaveBeenNthCalledWith(\n args.clearSignContexts.findIndex(\n (c) => c.type === ClearSignContextType.TOKEN,\n ) + 1,\n expect.objectContaining(\n new ProvideTokenInformationCommand({ payload: \"746f6b656e\" }),\n ),\n );\n });\n\n it(\"should return the command error result and stop when the command fails\", async () => {\n api.sendCommand.mockResolvedValueOnce(errorResult);\n // GIVEN\n const task = new ProvideTransactionContextTask(api, args);\n // WHEN\n const result = await task.run();\n // THEN\n expect(api.sendCommand).toHaveBeenCalledTimes(1);\n expect(result.isJust()).toBe(true);\n expect(result.extract()).toStrictEqual(errorResult);\n });\n\n it(\"should send the web3Check command when it is provided\", async () => {\n api.sendCommand.mockResolvedValue(successResult);\n // GIVEN\n const task = new ProvideTransactionContextTask(api, {\n ...args,\n web3Check: {\n type: ClearSignContextType.WEB3_CHECK,\n payload: \"0x01020304\",\n certificate: {\n payload: new Uint8Array(),\n keyUsageNumber: 1,\n },\n },\n });\n // WHEN\n const result = await task.run();\n // THEN\n expect(api.sendCommand).toHaveBeenCalledTimes(6);\n expect(api.sendCommand).toHaveBeenNthCalledWith(\n 1,\n expect.objectContaining(\n new LoadCertificateCommand({\n certificate: new Uint8Array(),\n keyUsage: 1,\n }),\n ),\n );\n expect(api.sendCommand).toHaveBeenNthCalledWith(\n 2,\n expect.objectContaining(\n new ProvideWeb3CheckCommand({\n payload: hexaStringToBuffer(\"0x000401020304\")!,\n isFirstChunk: true,\n }),\n ),\n );\n expect(result.isJust()).toBe(false);\n });\n });\n});\n"],
5
+ "mappings": "AAAA,OAAS,wBAAAA,MAA4B,2BACrC,OACE,wBAAAC,EACA,sBAAAC,EACA,0BAAAC,MAEK,kCAEP,OAAS,gCAAAC,MAAoC,4DAC7C,OAAS,kCAAAC,MAAsC,8DAC/C,OAAS,2BAAAC,MAA+B,uDACxC,OAAS,4BAAAC,MAAgC,wDACzC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AS,CAAC,CACxD,CACF,EACA,OAAOO,EAAI,WAAW,EAAE,wBACtBG,EAAK,kBAAkB,UACpBC,GAAMA,EAAE,OAASf,EAAqB,KACzC,EAAI,EACJ,OAAO,iBACL,IAAIK,EAA+B,CAAE,QAAS,YAAa,CAAC,CAC9D,CACF,CACF,CAAC,EAED,GAAG,yEAA0E,SAAY,CACvFM,EAAI,YAAY,sBAAsBE,CAAW,EAIjD,MAAMG,EAAS,MAFF,IAAIN,EAA8BC,EAAKG,CAAI,EAE9B,IAAI,EAE9B,OAAOH,EAAI,WAAW,EAAE,sBAAsB,CAAC,EAC/C,OAAOK,EAAO,OAAO,CAAC,EAAE,KAAK,EAAI,EACjC,OAAOA,EAAO,QAAQ,CAAC,EAAE,cAAcH,CAAW,CACpD,CAAC,EAED,GAAG,wDAAyD,SAAY,CACtEF,EAAI,YAAY,kBAAkBC,CAAa,EAc/C,MAAMI,EAAS,MAZF,IAAIN,EAA8BC,EAAK,CAClD,GAAGG,EACH,UAAW,CACT,KAAMd,EAAqB,WAC3B,QAAS,aACT,YAAa,CACX,QAAS,IAAI,WACb,eAAgB,CAClB,CACF,CACF,CAAC,EAEyB,IAAI,EAE9B,OAAOW,EAAI,WAAW,EAAE,sBAAsB,CAAC,EAC/C,OAAOA,EAAI,WAAW,EAAE,wBACtB,EACA,OAAO,iBACL,IAAIR,EAAuB,CACzB,YAAa,IAAI,WACjB,SAAU,CACZ,CAAC,CACH,CACF,EACA,OAAOQ,EAAI,WAAW,EAAE,wBACtB,EACA,OAAO,iBACL,IAAIL,EAAwB,CAC1B,QAASJ,EAAmB,gBAAgB,EAC5C,aAAc,EAChB,CAAC,CACH,CACF,EACA,OAAOc,EAAO,OAAO,CAAC,EAAE,KAAK,EAAK,CACpC,CAAC,CACH,CAAC,CACH,CAAC",
6
+ "names": ["ClearSignContextType", "CommandResultFactory", "hexaStringToBuffer", "LoadCertificateCommand", "ProvideNFTInformationCommand", "ProvideTokenInformationCommand", "ProvideWeb3CheckCommand", "SetExternalPluginCommand", "SetPluginCommand", "makeDeviceActionInternalApiMock", "ProvideTransactionContextTask", "api", "successResult", "errorResult", "args", "c", "result"]
7
7
  }
@@ -1,2 +1,2 @@
1
- import{ClearSignContextType as n}from"@ledgerhq/context-module";import{bufferToHexaString as u,CommandResultFactory as C,InvalidStatusWordError as m,isSuccessCommandResult as a,LoadCertificateCommand as p}from"@ledgerhq/device-management-kit";import{Just as s,Nothing as d}from"purify-ts";import{GetChallengeCommand as l}from"../../app-binder/command/GetChallengeCommand";import{ProvideEnumCommand as f}from"../../app-binder/command/ProvideEnumCommand";import{ProvideNFTInformationCommand as h}from"../../app-binder/command/ProvideNFTInformationCommand";import{ProvideTokenInformationCommand as T}from"../../app-binder/command/ProvideTokenInformationCommand";import{ProvideTransactionFieldDescriptionCommand as v}from"../../app-binder/command/ProvideTransactionFieldDescriptionCommand";import{ProvideTrustedNameCommand as y}from"../../app-binder/command/ProvideTrustedNameCommand";import{SendPayloadInChunksTask as c}from"./SendPayloadInChunksTask";class A{constructor(e,r){this.api=e;this.args=r}async run(){const{field:e}=this.args;if(await this.loadCertificate(e.certificate),e.reference!==void 0&&"value"in e.reference&&e.reference.value!==void 0&&await this.getAndProvideContext({type:e.reference.type,chainId:this.args.chainId,address:e.reference.value}),e.reference!==void 0&&e.reference.valuePath!==void 0){const t=this.args.transactionParser.extractValue(this.args.serializedTransaction,e.reference.valuePath);if(t.isRight())for(const o of t.extract()){const i=await this.provideContextReference(e.reference,o);if(i.isJust())return i}}const r=await this.provideContext({...e});return a(r)?d:s(r)}async loadCertificate(e){e&&await this.api.sendCommand(new p({keyUsage:e.keyUsageNumber,certificate:e.payload}))}async provideContextReference(e,r){if(e.type===n.ENUM)return this.provideEnumContextReference(e,r);const t=u(r.slice(Math.max(0,r.length-20)));return e.type===n.TRUSTED_NAME?this.provideTustedNameContextReference(e,t):this.getAndProvideContext({type:e.type,chainId:this.args.chainId,address:t})}async provideEnumContextReference(e,r){const t=r[r.length-1];if(!t)return d;const o=this.args.transactionEnums.find(i=>i.value===t&&i.id===e.id);if(o){await this.loadCertificate(o.certificate);const i=await this.provideContext(o);if(!a(i))return s(i)}return d}async provideTustedNameContextReference(e,r){const t=await this.api.sendCommand(new l);return a(t)?this.getAndProvideContext({type:e.type,chainId:this.args.chainId,address:r,challenge:t.data.challenge,types:e.types,sources:e.sources}):s(t)}async getAndProvideContext(e){const r=await this.args.contextModule.getContext(e);if(r.type!==n.ERROR){const t=await this.provideContext(r);if(!a(t))return s(t)}return d}async provideContext({type:e,payload:r}){switch(e){case n.NFT:return await this.api.sendCommand(new h({payload:r}));case n.TOKEN:return await this.api.sendCommand(new T({payload:r}));case n.TRUSTED_NAME:return new c(this.api,{payload:r,commandFactory:t=>new y({data:t.chunkedData,isFirstChunk:t.isFirstChunk})}).run();case n.ENUM:return new c(this.api,{payload:r,commandFactory:t=>new f({data:t.chunkedData,isFirstChunk:t.isFirstChunk})}).run();case n.TRANSACTION_FIELD_DESCRIPTION:return new c(this.api,{payload:r,commandFactory:t=>new v({data:t.chunkedData,isFirstChunk:t.isFirstChunk})}).run();case n.TRANSACTION_INFO:case n.PLUGIN:case n.EXTERNAL_PLUGIN:return C({error:new m(`The context type [${e}] is not valid as a transaction field or metadata`)});default:{const t=e;return C({error:new m(`The context type [${t}] is not covered`)})}}}}export{A as ProvideTransactionFieldDescriptionTask};
1
+ import{ClearSignContextType as n}from"@ledgerhq/context-module";import{bufferToHexaString as u,CommandResultFactory as C,InvalidStatusWordError as m,isSuccessCommandResult as a,LoadCertificateCommand as p}from"@ledgerhq/device-management-kit";import{Just as s,Nothing as d}from"purify-ts";import{GetChallengeCommand as l}from"../../app-binder/command/GetChallengeCommand";import{ProvideEnumCommand as f}from"../../app-binder/command/ProvideEnumCommand";import{ProvideNFTInformationCommand as h}from"../../app-binder/command/ProvideNFTInformationCommand";import{ProvideTokenInformationCommand as T}from"../../app-binder/command/ProvideTokenInformationCommand";import{ProvideTransactionFieldDescriptionCommand as v}from"../../app-binder/command/ProvideTransactionFieldDescriptionCommand";import{ProvideTrustedNameCommand as y}from"../../app-binder/command/ProvideTrustedNameCommand";import{ProvideWeb3CheckCommand as x}from"../../app-binder/command/ProvideWeb3CheckCommand";import{SendPayloadInChunksTask as c}from"./SendPayloadInChunksTask";class D{constructor(e,r){this.api=e;this.args=r}async run(){const{field:e}=this.args;if(await this.loadCertificate(e.certificate),e.reference!==void 0&&"value"in e.reference&&e.reference.value!==void 0&&await this.getAndProvideContext({type:e.reference.type,chainId:this.args.chainId,address:e.reference.value}),e.reference!==void 0&&e.reference.valuePath!==void 0){const t=this.args.transactionParser.extractValue(this.args.serializedTransaction,e.reference.valuePath);if(t.isRight())for(const o of t.extract()){const i=await this.provideContextReference(e.reference,o);if(i.isJust())return i}}const r=await this.provideContext({...e});return a(r)?d:s(r)}async loadCertificate(e){e&&await this.api.sendCommand(new p({keyUsage:e.keyUsageNumber,certificate:e.payload}))}async provideContextReference(e,r){if(e.type===n.ENUM)return this.provideEnumContextReference(e,r);const t=u(r.slice(Math.max(0,r.length-20)));return e.type===n.TRUSTED_NAME?this.provideTustedNameContextReference(e,t):this.getAndProvideContext({type:e.type,chainId:this.args.chainId,address:t})}async provideEnumContextReference(e,r){const t=r[r.length-1];if(!t)return d;const o=this.args.transactionEnums.find(i=>i.value===t&&i.id===e.id);if(o){await this.loadCertificate(o.certificate);const i=await this.provideContext(o);if(!a(i))return s(i)}return d}async provideTustedNameContextReference(e,r){const t=await this.api.sendCommand(new l);return a(t)?this.getAndProvideContext({type:e.type,chainId:this.args.chainId,address:r,challenge:t.data.challenge,types:e.types,sources:e.sources}):s(t)}async getAndProvideContext(e){const r=await this.args.contextModule.getContext(e);if(r.type!==n.ERROR){const t=await this.provideContext(r);if(!a(t))return s(t)}return d}async provideContext({type:e,payload:r}){switch(e){case n.NFT:return await this.api.sendCommand(new h({payload:r}));case n.TOKEN:return await this.api.sendCommand(new T({payload:r}));case n.TRUSTED_NAME:return new c(this.api,{payload:r,commandFactory:t=>new y({data:t.chunkedData,isFirstChunk:t.isFirstChunk})}).run();case n.ENUM:return new c(this.api,{payload:r,commandFactory:t=>new f({data:t.chunkedData,isFirstChunk:t.isFirstChunk})}).run();case n.TRANSACTION_FIELD_DESCRIPTION:return new c(this.api,{payload:r,commandFactory:t=>new v({data:t.chunkedData,isFirstChunk:t.isFirstChunk})}).run();case n.TRANSACTION_INFO:case n.PLUGIN:case n.EXTERNAL_PLUGIN:return C({error:new m(`The context type [${e}] is not valid as a transaction field or metadata`)});case n.WEB3_CHECK:return new c(this.api,{payload:r,commandFactory:t=>new x({payload:t.chunkedData,isFirstChunk:t.isFirstChunk})}).run();default:{const t=e;return C({error:new m(`The context type [${t}] is not covered`)})}}}}export{D as ProvideTransactionFieldDescriptionTask};
2
2
  //# sourceMappingURL=ProvideTransactionFieldDescriptionTask.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../../src/internal/app-binder/task/ProvideTransactionFieldDescriptionTask.ts"],
4
- "sourcesContent": ["import {\n type ClearSignContextReference,\n type ClearSignContextSuccess,\n type ClearSignContextSuccessType,\n ClearSignContextType,\n type ContextModule,\n type PkiCertificate,\n type TransactionFieldContext,\n} from \"@ledgerhq/context-module\";\nimport {\n bufferToHexaString,\n type CommandErrorResult,\n type CommandResult,\n CommandResultFactory,\n type HexaString,\n type InternalApi,\n InvalidStatusWordError,\n isSuccessCommandResult,\n LoadCertificateCommand,\n} from \"@ledgerhq/device-management-kit\";\nimport { Just, type Maybe, Nothing } from \"purify-ts\";\n\nimport { GetChallengeCommand } from \"@internal/app-binder/command/GetChallengeCommand\";\nimport { ProvideEnumCommand } from \"@internal/app-binder/command/ProvideEnumCommand\";\nimport { ProvideNFTInformationCommand } from \"@internal/app-binder/command/ProvideNFTInformationCommand\";\nimport {\n ProvideTokenInformationCommand,\n type ProvideTokenInformationCommandResponse,\n} from \"@internal/app-binder/command/ProvideTokenInformationCommand\";\nimport { ProvideTransactionFieldDescriptionCommand } from \"@internal/app-binder/command/ProvideTransactionFieldDescriptionCommand\";\nimport { ProvideTrustedNameCommand } from \"@internal/app-binder/command/ProvideTrustedNameCommand\";\nimport { type EthErrorCodes } from \"@internal/app-binder/command/utils/ethAppErrors\";\nimport { type TransactionParserService } from \"@internal/transaction/service/parser/TransactionParserService\";\n\nimport { type ProvideTransactionGenericContextTaskErrorCodes } from \"./ProvideTransactionGenericContextTask\";\nimport { SendPayloadInChunksTask } from \"./SendPayloadInChunksTask\";\n\nexport type ProvideTransactionFieldDescriptionTaskArgs = {\n field: ClearSignContextSuccess<\n Exclude<ClearSignContextSuccessType, ClearSignContextType.ENUM>\n >;\n serializedTransaction: Uint8Array;\n chainId: number;\n transactionParser: TransactionParserService;\n contextModule: ContextModule;\n transactionEnums: ClearSignContextSuccess<ClearSignContextType.ENUM>[];\n};\n\nexport type ProvideTransactionFieldDescriptionTaskErrorCodes =\n void | EthErrorCodes;\n\n/**\n * This task is responsible for providing the transaction context to the device.\n *\n */\nexport class ProvideTransactionFieldDescriptionTask {\n constructor(\n private api: InternalApi,\n private args: ProvideTransactionFieldDescriptionTaskArgs,\n ) {}\n\n async run(): Promise<\n Maybe<\n CommandErrorResult<\n ProvideTransactionFieldDescriptionTaskErrorCodes | EthErrorCodes\n >\n >\n > {\n const { field } = this.args;\n\n // If a certificate is provided, start by loading it to the device\n await this.loadCertificate(field.certificate);\n\n // if the reference is a string, it means it is a direct address\n // and we don't need to extract the value from the transaction\n // as it is already provided in the reference\n if (\n field.reference !== undefined &&\n \"value\" in field.reference &&\n field.reference.value !== undefined\n ) {\n await this.getAndProvideContext({\n type: field.reference.type,\n chainId: this.args.chainId,\n address: field.reference.value,\n });\n }\n\n // if the reference is a path, it means we need to extract the value\n // from the transaction and provide it to the device\n if (\n field.reference !== undefined &&\n field.reference.valuePath !== undefined\n ) {\n // iterate on each reference and provide the context\n const referenceValues = this.args.transactionParser.extractValue(\n this.args.serializedTransaction,\n field.reference.valuePath,\n );\n\n if (referenceValues.isRight()) {\n for (const value of referenceValues.extract()) {\n const provideReferenceResult = await this.provideContextReference(\n field.reference,\n value,\n );\n if (provideReferenceResult.isJust()) {\n return provideReferenceResult;\n }\n }\n }\n }\n\n const transactionFieldResult = await this.provideContext({ ...field });\n if (!isSuccessCommandResult(transactionFieldResult)) {\n return Just(transactionFieldResult);\n }\n\n return Nothing;\n }\n\n /**\n * This method will load the certificate to the device if it is provided.\n *\n * @param {PkiCertificate | undefined} certificate The certificate to load to the device.\n * @returns A promise that resolves when the certificate is loaded.\n */\n private async loadCertificate(\n certificate: PkiCertificate | undefined,\n ): Promise<void> {\n if (!certificate) return;\n\n await this.api.sendCommand(\n new LoadCertificateCommand({\n keyUsage: certificate.keyUsageNumber,\n certificate: certificate.payload,\n }),\n );\n }\n\n /**\n * This method will provide the context reference to the device.\n *\n * @param {ClearSignContextReference} reference The reference to provide.\n * @param {Uint8Array} value The value of the reference.\n * @returns A promise that resolves when the context is provided.\n */\n private async provideContextReference(\n reference: ClearSignContextReference,\n value: Uint8Array,\n ): Promise<\n Maybe<\n CommandErrorResult<\n ProvideTransactionGenericContextTaskErrorCodes | EthErrorCodes\n >\n >\n > {\n if (reference.type === ClearSignContextType.ENUM) {\n return this.provideEnumContextReference(reference, value);\n }\n\n const address = bufferToHexaString(\n value.slice(Math.max(0, value.length - 20)),\n );\n\n if (reference.type === ClearSignContextType.TRUSTED_NAME) {\n return this.provideTustedNameContextReference(reference, address);\n }\n\n return this.getAndProvideContext({\n type: reference.type,\n chainId: this.args.chainId,\n address,\n });\n }\n\n /**\n * This method will provide the enum context reference to the device\n * if the enum value is found in the transaction enums mapping.\n *\n * Note: We do not need to call the context module to get the enum context\n * as it is already provided with transactionEnums mapping.\n *\n * @param {ClearSignContextReference<ClearSignContextType.ENUM>} reference The enum reference to provide.\n * @param {Uint8Array} value The value of the enum.\n * @returns A promise that resolves when the context is provided.\n */\n private async provideEnumContextReference(\n reference: ClearSignContextReference<ClearSignContextType.ENUM>,\n value: Uint8Array,\n ): Promise<\n Maybe<CommandErrorResult<ProvideTransactionGenericContextTaskErrorCodes>>\n > {\n const enumValue = value[value.length - 1];\n if (!enumValue) return Nothing;\n\n const enumDescriptor = this.args.transactionEnums.find(\n (enumContext) =>\n enumContext.value === enumValue && enumContext.id === reference.id,\n );\n if (enumDescriptor) {\n await this.loadCertificate(enumDescriptor.certificate);\n\n const provideEnumResult = await this.provideContext(enumDescriptor);\n if (!isSuccessCommandResult(provideEnumResult)) {\n return Just(provideEnumResult);\n }\n }\n return Nothing;\n }\n\n /**\n * This method will provide the trusted name context reference to the device.\n *\n * Note: We need to call the context module to get the trusted name context\n * with a challenge to ensure the trusted name is valid.\n *\n * @param {ClearSignContextReference<ClearSignContextType.TRUSTED_NAME>} reference The trusted name reference to provide.\n * @param {HexaString} address The address of the trusted name.\n * @returns A promise that resolves when the context is provided.\n */\n private async provideTustedNameContextReference(\n reference: ClearSignContextReference<ClearSignContextType.TRUSTED_NAME>,\n address: HexaString,\n ): Promise<\n Maybe<\n CommandErrorResult<\n ProvideTransactionGenericContextTaskErrorCodes | EthErrorCodes\n >\n >\n > {\n const getChallengeResult = await this.api.sendCommand(\n new GetChallengeCommand(),\n );\n if (!isSuccessCommandResult(getChallengeResult)) {\n return Just(getChallengeResult);\n }\n\n return this.getAndProvideContext({\n type: reference.type,\n chainId: this.args.chainId,\n address,\n challenge: getChallengeResult.data.challenge,\n types: reference.types,\n sources: reference.sources,\n });\n }\n\n /**\n * This method will get the context from the context module\n * and provide it to the device.\n *\n * @param {TransactionFieldContext} field The field to provide.\n * @returns A promise that resolves when the context is provided.\n */\n private async getAndProvideContext(\n field: TransactionFieldContext,\n ): Promise<\n Maybe<CommandErrorResult<ProvideTransactionGenericContextTaskErrorCodes>>\n > {\n const context = await this.args.contextModule.getContext(field);\n if (context.type !== ClearSignContextType.ERROR) {\n const provideReferenceResult = await this.provideContext(context);\n if (!isSuccessCommandResult(provideReferenceResult)) {\n return Just(provideReferenceResult);\n }\n }\n return Nothing;\n }\n\n /**\n * This method will send a command according to the clear sign context type\n * and return the command result if only one command is sent,\n * otherwise it will return the result of the command.\n *\n * @param {ClearSignContextSuccess} context The clear sign context to provide.\n * @returns A promise that resolves when the command return a command response.\n */\n private async provideContext({\n type,\n payload,\n }: ClearSignContextSuccess): Promise<\n CommandResult<\n void | ProvideTokenInformationCommandResponse,\n ProvideTransactionGenericContextTaskErrorCodes\n >\n > {\n switch (type) {\n case ClearSignContextType.NFT:\n return await this.api.sendCommand(\n new ProvideNFTInformationCommand({ payload }),\n );\n case ClearSignContextType.TOKEN:\n return await this.api.sendCommand(\n new ProvideTokenInformationCommand({ payload }),\n );\n case ClearSignContextType.TRUSTED_NAME:\n return new SendPayloadInChunksTask(this.api, {\n payload,\n commandFactory: (args) =>\n new ProvideTrustedNameCommand({\n data: args.chunkedData,\n isFirstChunk: args.isFirstChunk,\n }),\n }).run();\n case ClearSignContextType.ENUM:\n return new SendPayloadInChunksTask(this.api, {\n payload,\n commandFactory: (args) =>\n new ProvideEnumCommand({\n data: args.chunkedData,\n isFirstChunk: args.isFirstChunk,\n }),\n }).run();\n case ClearSignContextType.TRANSACTION_FIELD_DESCRIPTION:\n return new SendPayloadInChunksTask(this.api, {\n payload,\n commandFactory: (args) =>\n new ProvideTransactionFieldDescriptionCommand({\n data: args.chunkedData,\n isFirstChunk: args.isFirstChunk,\n }),\n }).run();\n case ClearSignContextType.TRANSACTION_INFO:\n case ClearSignContextType.PLUGIN:\n case ClearSignContextType.EXTERNAL_PLUGIN:\n return CommandResultFactory({\n error: new InvalidStatusWordError(\n `The context type [${type}] is not valid as a transaction field or metadata`,\n ),\n });\n default: {\n const uncoveredType: never = type;\n return CommandResultFactory({\n error: new InvalidStatusWordError(\n `The context type [${uncoveredType}] is not covered`,\n ),\n });\n }\n }\n }\n}\n"],
5
- "mappings": "AAAA,OAIE,wBAAAA,MAIK,2BACP,OACE,sBAAAC,EAGA,wBAAAC,EAGA,0BAAAC,EACA,0BAAAC,EACA,0BAAAC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"InvalidStatusWordError", "isSuccessCommandResult", "LoadCertificateCommand", "Just", "Nothing", "GetChallengeCommand", "ProvideEnumCommand", "ProvideNFTInformationCommand", "ProvideTokenInformationCommand", "ProvideTransactionFieldDescriptionCommand", "ProvideTrustedNameCommand", "SendPayloadInChunksTask", "ProvideTransactionFieldDescriptionTask", "api", "args", "field", "referenceValues", "value", "provideReferenceResult", "transactionFieldResult", "certificate", "reference", "address", "enumValue", "enumDescriptor", "enumContext", "provideEnumResult", "getChallengeResult", "context", "type", "payload", "uncoveredType"]
4
+ "sourcesContent": ["import {\n type ClearSignContextReference,\n type ClearSignContextSuccess,\n type ClearSignContextSuccessType,\n ClearSignContextType,\n type ContextModule,\n type PkiCertificate,\n type TransactionFieldContext,\n} from \"@ledgerhq/context-module\";\nimport {\n bufferToHexaString,\n type CommandErrorResult,\n type CommandResult,\n CommandResultFactory,\n type HexaString,\n type InternalApi,\n InvalidStatusWordError,\n isSuccessCommandResult,\n LoadCertificateCommand,\n} from \"@ledgerhq/device-management-kit\";\nimport { Just, type Maybe, Nothing } from \"purify-ts\";\n\nimport { GetChallengeCommand } from \"@internal/app-binder/command/GetChallengeCommand\";\nimport { ProvideEnumCommand } from \"@internal/app-binder/command/ProvideEnumCommand\";\nimport { ProvideNFTInformationCommand } from \"@internal/app-binder/command/ProvideNFTInformationCommand\";\nimport {\n ProvideTokenInformationCommand,\n type ProvideTokenInformationCommandResponse,\n} from \"@internal/app-binder/command/ProvideTokenInformationCommand\";\nimport { ProvideTransactionFieldDescriptionCommand } from \"@internal/app-binder/command/ProvideTransactionFieldDescriptionCommand\";\nimport { ProvideTrustedNameCommand } from \"@internal/app-binder/command/ProvideTrustedNameCommand\";\nimport { ProvideWeb3CheckCommand } from \"@internal/app-binder/command/ProvideWeb3CheckCommand\";\nimport { type EthErrorCodes } from \"@internal/app-binder/command/utils/ethAppErrors\";\nimport { type TransactionParserService } from \"@internal/transaction/service/parser/TransactionParserService\";\n\nimport { type ProvideTransactionGenericContextTaskErrorCodes } from \"./ProvideTransactionGenericContextTask\";\nimport { SendPayloadInChunksTask } from \"./SendPayloadInChunksTask\";\n\nexport type ProvideTransactionFieldDescriptionTaskArgs = {\n field: ClearSignContextSuccess<\n Exclude<ClearSignContextSuccessType, ClearSignContextType.ENUM>\n >;\n serializedTransaction: Uint8Array;\n chainId: number;\n transactionParser: TransactionParserService;\n contextModule: ContextModule;\n transactionEnums: ClearSignContextSuccess<ClearSignContextType.ENUM>[];\n};\n\nexport type ProvideTransactionFieldDescriptionTaskErrorCodes =\n void | EthErrorCodes;\n\n/**\n * This task is responsible for providing the transaction context to the device.\n *\n */\nexport class ProvideTransactionFieldDescriptionTask {\n constructor(\n private api: InternalApi,\n private args: ProvideTransactionFieldDescriptionTaskArgs,\n ) {}\n\n async run(): Promise<\n Maybe<\n CommandErrorResult<\n ProvideTransactionFieldDescriptionTaskErrorCodes | EthErrorCodes\n >\n >\n > {\n const { field } = this.args;\n\n // If a certificate is provided, start by loading it to the device\n await this.loadCertificate(field.certificate);\n\n // if the reference is a string, it means it is a direct address\n // and we don't need to extract the value from the transaction\n // as it is already provided in the reference\n if (\n field.reference !== undefined &&\n \"value\" in field.reference &&\n field.reference.value !== undefined\n ) {\n await this.getAndProvideContext({\n type: field.reference.type,\n chainId: this.args.chainId,\n address: field.reference.value,\n });\n }\n\n // if the reference is a path, it means we need to extract the value\n // from the transaction and provide it to the device\n if (\n field.reference !== undefined &&\n field.reference.valuePath !== undefined\n ) {\n // iterate on each reference and provide the context\n const referenceValues = this.args.transactionParser.extractValue(\n this.args.serializedTransaction,\n field.reference.valuePath,\n );\n\n if (referenceValues.isRight()) {\n for (const value of referenceValues.extract()) {\n const provideReferenceResult = await this.provideContextReference(\n field.reference,\n value,\n );\n if (provideReferenceResult.isJust()) {\n return provideReferenceResult;\n }\n }\n }\n }\n\n const transactionFieldResult = await this.provideContext({ ...field });\n if (!isSuccessCommandResult(transactionFieldResult)) {\n return Just(transactionFieldResult);\n }\n\n return Nothing;\n }\n\n /**\n * This method will load the certificate to the device if it is provided.\n *\n * @param {PkiCertificate | undefined} certificate The certificate to load to the device.\n * @returns A promise that resolves when the certificate is loaded.\n */\n private async loadCertificate(\n certificate: PkiCertificate | undefined,\n ): Promise<void> {\n if (!certificate) return;\n\n await this.api.sendCommand(\n new LoadCertificateCommand({\n keyUsage: certificate.keyUsageNumber,\n certificate: certificate.payload,\n }),\n );\n }\n\n /**\n * This method will provide the context reference to the device.\n *\n * @param {ClearSignContextReference} reference The reference to provide.\n * @param {Uint8Array} value The value of the reference.\n * @returns A promise that resolves when the context is provided.\n */\n private async provideContextReference(\n reference: ClearSignContextReference,\n value: Uint8Array,\n ): Promise<\n Maybe<\n CommandErrorResult<\n ProvideTransactionGenericContextTaskErrorCodes | EthErrorCodes\n >\n >\n > {\n if (reference.type === ClearSignContextType.ENUM) {\n return this.provideEnumContextReference(reference, value);\n }\n\n const address = bufferToHexaString(\n value.slice(Math.max(0, value.length - 20)),\n );\n\n if (reference.type === ClearSignContextType.TRUSTED_NAME) {\n return this.provideTustedNameContextReference(reference, address);\n }\n\n return this.getAndProvideContext({\n type: reference.type,\n chainId: this.args.chainId,\n address,\n });\n }\n\n /**\n * This method will provide the enum context reference to the device\n * if the enum value is found in the transaction enums mapping.\n *\n * Note: We do not need to call the context module to get the enum context\n * as it is already provided with transactionEnums mapping.\n *\n * @param {ClearSignContextReference<ClearSignContextType.ENUM>} reference The enum reference to provide.\n * @param {Uint8Array} value The value of the enum.\n * @returns A promise that resolves when the context is provided.\n */\n private async provideEnumContextReference(\n reference: ClearSignContextReference<ClearSignContextType.ENUM>,\n value: Uint8Array,\n ): Promise<\n Maybe<CommandErrorResult<ProvideTransactionGenericContextTaskErrorCodes>>\n > {\n const enumValue = value[value.length - 1];\n if (!enumValue) return Nothing;\n\n const enumDescriptor = this.args.transactionEnums.find(\n (enumContext) =>\n enumContext.value === enumValue && enumContext.id === reference.id,\n );\n if (enumDescriptor) {\n await this.loadCertificate(enumDescriptor.certificate);\n\n const provideEnumResult = await this.provideContext(enumDescriptor);\n if (!isSuccessCommandResult(provideEnumResult)) {\n return Just(provideEnumResult);\n }\n }\n return Nothing;\n }\n\n /**\n * This method will provide the trusted name context reference to the device.\n *\n * Note: We need to call the context module to get the trusted name context\n * with a challenge to ensure the trusted name is valid.\n *\n * @param {ClearSignContextReference<ClearSignContextType.TRUSTED_NAME>} reference The trusted name reference to provide.\n * @param {HexaString} address The address of the trusted name.\n * @returns A promise that resolves when the context is provided.\n */\n private async provideTustedNameContextReference(\n reference: ClearSignContextReference<ClearSignContextType.TRUSTED_NAME>,\n address: HexaString,\n ): Promise<\n Maybe<\n CommandErrorResult<\n ProvideTransactionGenericContextTaskErrorCodes | EthErrorCodes\n >\n >\n > {\n const getChallengeResult = await this.api.sendCommand(\n new GetChallengeCommand(),\n );\n if (!isSuccessCommandResult(getChallengeResult)) {\n return Just(getChallengeResult);\n }\n\n return this.getAndProvideContext({\n type: reference.type,\n chainId: this.args.chainId,\n address,\n challenge: getChallengeResult.data.challenge,\n types: reference.types,\n sources: reference.sources,\n });\n }\n\n /**\n * This method will get the context from the context module\n * and provide it to the device.\n *\n * @param {TransactionFieldContext} field The field to provide.\n * @returns A promise that resolves when the context is provided.\n */\n private async getAndProvideContext(\n field: TransactionFieldContext,\n ): Promise<\n Maybe<CommandErrorResult<ProvideTransactionGenericContextTaskErrorCodes>>\n > {\n const context = await this.args.contextModule.getContext(field);\n if (context.type !== ClearSignContextType.ERROR) {\n const provideReferenceResult = await this.provideContext(context);\n if (!isSuccessCommandResult(provideReferenceResult)) {\n return Just(provideReferenceResult);\n }\n }\n return Nothing;\n }\n\n /**\n * This method will send a command according to the clear sign context type\n * and return the command result if only one command is sent,\n * otherwise it will return the result of the command.\n *\n * @param {ClearSignContextSuccess} context The clear sign context to provide.\n * @returns A promise that resolves when the command return a command response.\n */\n private async provideContext({\n type,\n payload,\n }: ClearSignContextSuccess): Promise<\n CommandResult<\n void | ProvideTokenInformationCommandResponse,\n ProvideTransactionGenericContextTaskErrorCodes\n >\n > {\n switch (type) {\n case ClearSignContextType.NFT:\n return await this.api.sendCommand(\n new ProvideNFTInformationCommand({ payload }),\n );\n case ClearSignContextType.TOKEN:\n return await this.api.sendCommand(\n new ProvideTokenInformationCommand({ payload }),\n );\n case ClearSignContextType.TRUSTED_NAME:\n return new SendPayloadInChunksTask(this.api, {\n payload,\n commandFactory: (args) =>\n new ProvideTrustedNameCommand({\n data: args.chunkedData,\n isFirstChunk: args.isFirstChunk,\n }),\n }).run();\n case ClearSignContextType.ENUM:\n return new SendPayloadInChunksTask(this.api, {\n payload,\n commandFactory: (args) =>\n new ProvideEnumCommand({\n data: args.chunkedData,\n isFirstChunk: args.isFirstChunk,\n }),\n }).run();\n case ClearSignContextType.TRANSACTION_FIELD_DESCRIPTION:\n return new SendPayloadInChunksTask(this.api, {\n payload,\n commandFactory: (args) =>\n new ProvideTransactionFieldDescriptionCommand({\n data: args.chunkedData,\n isFirstChunk: args.isFirstChunk,\n }),\n }).run();\n case ClearSignContextType.TRANSACTION_INFO:\n case ClearSignContextType.PLUGIN:\n case ClearSignContextType.EXTERNAL_PLUGIN:\n return CommandResultFactory({\n error: new InvalidStatusWordError(\n `The context type [${type}] is not valid as a transaction field or metadata`,\n ),\n });\n case ClearSignContextType.WEB3_CHECK:\n return new SendPayloadInChunksTask(this.api, {\n payload,\n commandFactory: (args) =>\n new ProvideWeb3CheckCommand({\n payload: args.chunkedData,\n isFirstChunk: args.isFirstChunk,\n }),\n }).run();\n default: {\n const uncoveredType: never = type;\n return CommandResultFactory({\n error: new InvalidStatusWordError(\n `The context type [${uncoveredType}] is not covered`,\n ),\n });\n }\n }\n }\n}\n"],
5
+ "mappings": "AAAA,OAIE,wBAAAA,MAIK,2BACP,OACE,sBAAAC,EAGA,wBAAAC,EAGA,0BAAAC,EACA,0BAAAC,EACA,0BAAAC,MACK,kCACP,OAAS,QAAAC,EAAkB,WAAAC,MAAe,YAE1C,OAAS,uBAAAC,MAA2B,mDAC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/B,EAAqB,CAC1B,MAAO,IAAIC,EACT,qBAAqBgC,CAAa,kBACpC,CACF,CAAC,CACH,CACF,CACF,CACF",
6
+ "names": ["ClearSignContextType", "bufferToHexaString", "CommandResultFactory", "InvalidStatusWordError", "isSuccessCommandResult", "LoadCertificateCommand", "Just", "Nothing", "GetChallengeCommand", "ProvideEnumCommand", "ProvideNFTInformationCommand", "ProvideTokenInformationCommand", "ProvideTransactionFieldDescriptionCommand", "ProvideTrustedNameCommand", "ProvideWeb3CheckCommand", "SendPayloadInChunksTask", "ProvideTransactionFieldDescriptionTask", "api", "args", "field", "referenceValues", "value", "provideReferenceResult", "transactionFieldResult", "certificate", "reference", "address", "enumValue", "enumDescriptor", "enumContext", "provideEnumResult", "getChallengeResult", "context", "type", "payload", "uncoveredType"]
7
7
  }
@@ -1,2 +1,2 @@
1
- import{ByteArrayBuilder as c,isSuccessCommandResult as o,LoadCertificateCommand as d}from"@ledgerhq/device-management-kit";import{DerivationPathUtils as l}from"@ledgerhq/signer-utils";import{Just as s,Nothing as m}from"purify-ts";import{ProvideTransactionInformationCommand as C}from"../../app-binder/command/ProvideTransactionInformationCommand";import{StoreTransactionCommand as p}from"../../app-binder/command/StoreTransactionCommand";import{ProvideTransactionFieldDescriptionTask as u}from"./ProvideTransactionFieldDescriptionTask";import{SendCommandInChunksTask as y}from"./SendCommandInChunksTask";import{SendPayloadInChunksTask as h}from"./SendPayloadInChunksTask";class E{constructor(a,n){this.api=a;this.args=n}async run(){const a=l.splitPath(this.args.derivationPath),n=new c;n.add8BitUIntToData(a.length),a.forEach(t=>{n.add32BitUIntToData(t)}),n.addBufferToData(this.args.serializedTransaction);const e=await new y(this.api,{data:n.build(),commandFactory:t=>new p({serializedTransaction:t.chunkedData,isFirstChunk:t.isFirstChunk})}).run();if(!o(e))return s(e);if(this.args.context.transactionInfoCertificate){const{keyUsageNumber:t,payload:r}=this.args.context.transactionInfoCertificate;await this.api.sendCommand(new d({keyUsage:t,certificate:r}))}const i=await new h(this.api,{payload:this.args.context.transactionInfo,commandFactory:t=>new C({data:t.chunkedData,isFirstChunk:t.isFirstChunk})}).run();if(!o(i))return s(i);for(const t of this.args.context.transactionFields){const r=await new u(this.api,{field:t,serializedTransaction:this.args.serializedTransaction,chainId:this.args.chainId,transactionParser:this.args.transactionParser,contextModule:this.args.contextModule,transactionEnums:this.args.context.transactionEnums}).run();if(r.isJust())return r}return m}}export{E as ProvideTransactionGenericContextTask};
1
+ import{ByteArrayBuilder as d,isSuccessCommandResult as o,LoadCertificateCommand as l}from"@ledgerhq/device-management-kit";import{DerivationPathUtils as C}from"@ledgerhq/signer-utils";import{Just as s,Nothing as m}from"purify-ts";import{ProvideTransactionInformationCommand as p}from"../../app-binder/command/ProvideTransactionInformationCommand";import{StoreTransactionCommand as u}from"../../app-binder/command/StoreTransactionCommand";import{ProvideTransactionFieldDescriptionTask as y}from"./ProvideTransactionFieldDescriptionTask";import{SendCommandInChunksTask as h}from"./SendCommandInChunksTask";import{SendPayloadInChunksTask as f}from"./SendPayloadInChunksTask";class w{constructor(a,e){this.api=a;this.args=e}async run(){const a=C.splitPath(this.args.derivationPath),e=new d;e.add8BitUIntToData(a.length),a.forEach(t=>{e.add32BitUIntToData(t)}),e.addBufferToData(this.args.serializedTransaction);const r=await new h(this.api,{data:e.build(),commandFactory:t=>new u({serializedTransaction:t.chunkedData,isFirstChunk:t.isFirstChunk})}).run();if(!o(r))return s(r);if(this.args.context.transactionInfoCertificate){const{keyUsageNumber:t,payload:n}=this.args.context.transactionInfoCertificate;await this.api.sendCommand(new l({keyUsage:t,certificate:n}))}const i=await new f(this.api,{payload:this.args.context.transactionInfo,commandFactory:t=>new p({data:t.chunkedData,isFirstChunk:t.isFirstChunk})}).run();if(!o(i))return s(i);const c=this.args.web3Check?[...this.args.context.transactionFields,this.args.web3Check]:this.args.context.transactionFields;for(const t of c){const n=await new y(this.api,{field:t,serializedTransaction:this.args.serializedTransaction,chainId:this.args.chainId,transactionParser:this.args.transactionParser,contextModule:this.args.contextModule,transactionEnums:this.args.context.transactionEnums}).run();if(n.isJust())return n}return m}}export{w as ProvideTransactionGenericContextTask};
2
2
  //# sourceMappingURL=ProvideTransactionGenericContextTask.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../../src/internal/app-binder/task/ProvideTransactionGenericContextTask.ts"],
4
- "sourcesContent": ["import {\n type ClearSignContextSuccess,\n type ClearSignContextSuccessType,\n type ClearSignContextType,\n type ContextModule,\n type PkiCertificate,\n} from \"@ledgerhq/context-module\";\nimport {\n ByteArrayBuilder,\n type CommandErrorResult,\n type InternalApi,\n isSuccessCommandResult,\n LoadCertificateCommand,\n} from \"@ledgerhq/device-management-kit\";\nimport { DerivationPathUtils } from \"@ledgerhq/signer-utils\";\nimport { Just, type Maybe, Nothing } from \"purify-ts\";\n\nimport { ProvideTransactionInformationCommand } from \"@internal/app-binder/command/ProvideTransactionInformationCommand\";\nimport { StoreTransactionCommand } from \"@internal/app-binder/command/StoreTransactionCommand\";\nimport { type EthErrorCodes } from \"@internal/app-binder/command/utils/ethAppErrors\";\nimport { type TransactionParserService } from \"@internal/transaction/service/parser/TransactionParserService\";\n\nimport { ProvideTransactionFieldDescriptionTask } from \"./ProvideTransactionFieldDescriptionTask\";\nimport { SendCommandInChunksTask } from \"./SendCommandInChunksTask\";\nimport { SendPayloadInChunksTask } from \"./SendPayloadInChunksTask\";\n\nexport type GenericContext = {\n readonly transactionInfo: string;\n readonly transactionInfoCertificate: PkiCertificate;\n readonly transactionFields: ClearSignContextSuccess<\n Exclude<ClearSignContextSuccessType, ClearSignContextType.ENUM>\n >[];\n readonly transactionEnums: ClearSignContextSuccess<ClearSignContextType.ENUM>[];\n};\n\nexport type ProvideTransactionGenericContextTaskArgs = {\n readonly contextModule: ContextModule;\n readonly transactionParser: TransactionParserService;\n readonly chainId: number;\n readonly derivationPath: string;\n readonly serializedTransaction: Uint8Array;\n readonly context: GenericContext;\n};\n\nexport type ProvideTransactionGenericContextTaskErrorCodes =\n void | EthErrorCodes;\n\nexport class ProvideTransactionGenericContextTask {\n constructor(\n private api: InternalApi,\n private args: ProvideTransactionGenericContextTaskArgs,\n ) {}\n\n async run(): Promise<\n Maybe<CommandErrorResult<ProvideTransactionGenericContextTaskErrorCodes>>\n > {\n // Store the transaction in the device memory\n const paths = DerivationPathUtils.splitPath(this.args.derivationPath);\n const builder = new ByteArrayBuilder();\n builder.add8BitUIntToData(paths.length);\n paths.forEach((path) => {\n builder.add32BitUIntToData(path);\n });\n builder.addBufferToData(this.args.serializedTransaction);\n const storeTransactionResult = await new SendCommandInChunksTask(this.api, {\n data: builder.build(),\n commandFactory: (args) =>\n new StoreTransactionCommand({\n serializedTransaction: args.chunkedData,\n isFirstChunk: args.isFirstChunk,\n }),\n }).run();\n\n if (!isSuccessCommandResult(storeTransactionResult)) {\n return Just(storeTransactionResult);\n }\n\n if (this.args.context.transactionInfoCertificate) {\n const { keyUsageNumber: keyUsage, payload: certificate } =\n this.args.context.transactionInfoCertificate;\n await this.api.sendCommand(\n new LoadCertificateCommand({\n keyUsage,\n certificate,\n }),\n );\n }\n\n // Provide the transaction information\n const transactionInfoResult = await new SendPayloadInChunksTask(this.api, {\n payload: this.args.context.transactionInfo,\n commandFactory: (args) =>\n new ProvideTransactionInformationCommand({\n data: args.chunkedData,\n isFirstChunk: args.isFirstChunk,\n }),\n }).run();\n\n if (!isSuccessCommandResult(transactionInfoResult)) {\n return Just(transactionInfoResult);\n }\n\n // Provide the transaction field description and according metadata reference\n for (const field of this.args.context.transactionFields) {\n const result = await new ProvideTransactionFieldDescriptionTask(\n this.api,\n {\n field,\n serializedTransaction: this.args.serializedTransaction,\n chainId: this.args.chainId,\n transactionParser: this.args.transactionParser,\n contextModule: this.args.contextModule,\n transactionEnums: this.args.context.transactionEnums,\n },\n ).run();\n\n if (result.isJust()) {\n return result;\n }\n }\n\n return Nothing;\n }\n}\n"],
5
- "mappings": "AAOA,OACE,oBAAAA,EAGA,0BAAA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AqB,EAC/C,OAAOhB,EAAKgB,CAAqB,EAInC,UAAWC,KAAS,KAAK,KAAK,QAAQ,kBAAmB,CACvD,MAAMC,EAAS,MAAM,IAAId,EACvB,KAAK,IACL,CACE,MAAAa,EACA,sBAAuB,KAAK,KAAK,sBACjC,QAAS,KAAK,KAAK,QACnB,kBAAmB,KAAK,KAAK,kBAC7B,cAAe,KAAK,KAAK,cACzB,iBAAkB,KAAK,KAAK,QAAQ,gBACtC,CACF,EAAE,IAAI,EAEN,GAAIC,EAAO,OAAO,EAChB,OAAOA,CAEX,CAEA,OAAOjB,CACT,CACF",
6
- "names": ["ByteArrayBuilder", "isSuccessCommandResult", "LoadCertificateCommand", "DerivationPathUtils", "Just", "Nothing", "ProvideTransactionInformationCommand", "StoreTransactionCommand", "ProvideTransactionFieldDescriptionTask", "SendCommandInChunksTask", "SendPayloadInChunksTask", "ProvideTransactionGenericContextTask", "api", "args", "paths", "builder", "path", "storeTransactionResult", "keyUsage", "certificate", "transactionInfoResult", "field", "result"]
4
+ "sourcesContent": ["import {\n type ClearSignContextSuccess,\n type ClearSignContextSuccessType,\n type ClearSignContextType,\n type ContextModule,\n type PkiCertificate,\n} from \"@ledgerhq/context-module\";\nimport {\n ByteArrayBuilder,\n type CommandErrorResult,\n type InternalApi,\n isSuccessCommandResult,\n LoadCertificateCommand,\n} from \"@ledgerhq/device-management-kit\";\nimport { DerivationPathUtils } from \"@ledgerhq/signer-utils\";\nimport { Just, type Maybe, Nothing } from \"purify-ts\";\n\nimport { ProvideTransactionInformationCommand } from \"@internal/app-binder/command/ProvideTransactionInformationCommand\";\nimport { StoreTransactionCommand } from \"@internal/app-binder/command/StoreTransactionCommand\";\nimport { type EthErrorCodes } from \"@internal/app-binder/command/utils/ethAppErrors\";\nimport { type TransactionParserService } from \"@internal/transaction/service/parser/TransactionParserService\";\n\nimport { ProvideTransactionFieldDescriptionTask } from \"./ProvideTransactionFieldDescriptionTask\";\nimport { SendCommandInChunksTask } from \"./SendCommandInChunksTask\";\nimport { SendPayloadInChunksTask } from \"./SendPayloadInChunksTask\";\n\nexport type GenericContext = {\n readonly transactionInfo: string;\n readonly transactionInfoCertificate: PkiCertificate;\n readonly transactionFields: ClearSignContextSuccess<\n Exclude<ClearSignContextSuccessType, ClearSignContextType.ENUM>\n >[];\n readonly transactionEnums: ClearSignContextSuccess<ClearSignContextType.ENUM>[];\n};\n\nexport type ProvideTransactionGenericContextTaskArgs = {\n readonly contextModule: ContextModule;\n readonly transactionParser: TransactionParserService;\n readonly chainId: number;\n readonly derivationPath: string;\n readonly serializedTransaction: Uint8Array;\n readonly context: GenericContext;\n readonly web3Check: ClearSignContextSuccess<ClearSignContextType.WEB3_CHECK> | null;\n};\n\nexport type ProvideTransactionGenericContextTaskErrorCodes =\n void | EthErrorCodes;\n\nexport class ProvideTransactionGenericContextTask {\n constructor(\n private api: InternalApi,\n private args: ProvideTransactionGenericContextTaskArgs,\n ) {}\n\n async run(): Promise<\n Maybe<CommandErrorResult<ProvideTransactionGenericContextTaskErrorCodes>>\n > {\n // Store the transaction in the device memory\n const paths = DerivationPathUtils.splitPath(this.args.derivationPath);\n const builder = new ByteArrayBuilder();\n builder.add8BitUIntToData(paths.length);\n paths.forEach((path) => {\n builder.add32BitUIntToData(path);\n });\n builder.addBufferToData(this.args.serializedTransaction);\n const storeTransactionResult = await new SendCommandInChunksTask(this.api, {\n data: builder.build(),\n commandFactory: (args) =>\n new StoreTransactionCommand({\n serializedTransaction: args.chunkedData,\n isFirstChunk: args.isFirstChunk,\n }),\n }).run();\n\n if (!isSuccessCommandResult(storeTransactionResult)) {\n return Just(storeTransactionResult);\n }\n\n if (this.args.context.transactionInfoCertificate) {\n const { keyUsageNumber: keyUsage, payload: certificate } =\n this.args.context.transactionInfoCertificate;\n await this.api.sendCommand(\n new LoadCertificateCommand({\n keyUsage,\n certificate,\n }),\n );\n }\n\n // Provide the transaction information\n const transactionInfoResult = await new SendPayloadInChunksTask(this.api, {\n payload: this.args.context.transactionInfo,\n commandFactory: (args) =>\n new ProvideTransactionInformationCommand({\n data: args.chunkedData,\n isFirstChunk: args.isFirstChunk,\n }),\n }).run();\n\n if (!isSuccessCommandResult(transactionInfoResult)) {\n return Just(transactionInfoResult);\n }\n\n // If there is a web3 check, add it to the transactionField array\n const fields = this.args.web3Check\n ? [...this.args.context.transactionFields, this.args.web3Check]\n : this.args.context.transactionFields;\n\n // Provide the transaction field description and according metadata reference\n for (const field of fields) {\n const result = await new ProvideTransactionFieldDescriptionTask(\n this.api,\n {\n field,\n serializedTransaction: this.args.serializedTransaction,\n chainId: this.args.chainId,\n transactionParser: this.args.transactionParser,\n contextModule: this.args.contextModule,\n transactionEnums: this.args.context.transactionEnums,\n },\n ).run();\n\n if (result.isJust()) {\n return result;\n }\n }\n\n return Nothing;\n }\n}\n"],
5
+ "mappings": "AAOA,OACE,oBAAAA,EAGA,0BAAAC,EACA,0BAAAC,MACK,kCACP,OAAS,uBAAAC,MAA2B,yBACpC,OAAS,QAAAC,EAAkB,WAAAC,MAAe,YAE1C,OAAS,wCAAAC,MAA4C,oEACrD,OAAS,2BAAAC,MAA+B,uDAIxC,OAAS,0CAAAC,MAA8C,2CACvD,OAAS,2BAAAC,MAA+B,4BACxC,OAAS,2BAAAC,MAA+B,4BAwBjC,MAAMC,CAAqC,CAChD,YACUC,EACAC,EACR,CAFQ,SAAAD,EACA,UAAAC,CACP,CAEH,MAAM,KAEJ,CAEA,MAAMC,EAAQX,EAAoB,UAAU,KAAK,KAAK,cAAc,EAC9DY,EAAU,IAAIf,EACpBe,EAAQ,kBAAkBD,EAAM,MAAM,EACtCA,EAAM,QAASE,GAAS,CACtBD,EAAQ,mBAAmBC,CAAI,CACjC,CAAC,EACDD,EAAQ,gBAAgB,KAAK,KAAK,qBAAqB,EACvD,MAAME,EAAyB,MAAM,IAAIR,EAAwB,KAAK,IAAK,CACzE,KAAMM,EAAQ,MAAM,EACpB,eAAiBF,GACf,IAAIN,EAAwB,CAC1B,sBAAuBM,EAAK,YAC5B,aAAcA,EAAK,YACrB,CAAC,CACL,CAAC,EAAE,IAAI,EAEP,GAAI,CAACZ,EAAuBgB,CAAsB,EAChD,OAAOb,EAAKa,CAAsB,EAGpC,GAAI,KAAK,KAAK,QAAQ,2BAA4B,CAChD,KAAM,CAAE,eAAgBC,EAAU,QAASC,CAAY,EACrD,KAAK,KAAK,QAAQ,2BACpB,MAAM,KAAK,IAAI,YACb,IAAIjB,EAAuB,CACzB,SAAAgB,EACA,YAAAC,CACF,CAAC,CACH,CACF,CAGA,MAAMC,EAAwB,MAAM,IAAIV,EAAwB,KAAK,IAAK,CACxE,QAAS,KAAK,KAAK,QAAQ,gBAC3B,eAAiBG,GACf,IAAIP,EAAqC,CACvC,KAAMO,EAAK,YACX,aAAcA,EAAK,YACrB,CAAC,CACL,CAAC,EAAE,IAAI,EAEP,GAAI,CAACZ,EAAuBmB,CAAqB,EAC/C,OAAOhB,EAAKgB,CAAqB,EAInC,MAAMC,EAAS,KAAK,KAAK,UACrB,CAAC,GAAG,KAAK,KAAK,QAAQ,kBAAmB,KAAK,KAAK,SAAS,EAC5D,KAAK,KAAK,QAAQ,kBAGtB,UAAWC,KAASD,EAAQ,CAC1B,MAAME,EAAS,MAAM,IAAIf,EACvB,KAAK,IACL,CACE,MAAAc,EACA,sBAAuB,KAAK,KAAK,sBACjC,QAAS,KAAK,KAAK,QACnB,kBAAmB,KAAK,KAAK,kBAC7B,cAAe,KAAK,KAAK,cACzB,iBAAkB,KAAK,KAAK,QAAQ,gBACtC,CACF,EAAE,IAAI,EAEN,GAAIC,EAAO,OAAO,EAChB,OAAOA,CAEX,CAEA,OAAOlB,CACT,CACF",
6
+ "names": ["ByteArrayBuilder", "isSuccessCommandResult", "LoadCertificateCommand", "DerivationPathUtils", "Just", "Nothing", "ProvideTransactionInformationCommand", "StoreTransactionCommand", "ProvideTransactionFieldDescriptionTask", "SendCommandInChunksTask", "SendPayloadInChunksTask", "ProvideTransactionGenericContextTask", "api", "args", "paths", "builder", "path", "storeTransactionResult", "keyUsage", "certificate", "transactionInfoResult", "fields", "field", "result"]
7
7
  }
@@ -1,2 +1,2 @@
1
- import{CommandResultFactory as e,InvalidStatusWordError as r}from"@ledgerhq/device-management-kit";import{Just as u,Nothing as m}from"purify-ts";import{makeDeviceActionInternalApiMock as S}from"../../app-binder/device-action/__test-utils__/makeInternalApi";import{ProvideTransactionFieldDescriptionTask as i}from"./ProvideTransactionFieldDescriptionTask";import{ProvideTransactionGenericContextTask as a}from"./ProvideTransactionGenericContextTask";import{SendCommandInChunksTask as s}from"./SendCommandInChunksTask";import{SendPayloadInChunksTask as c}from"./SendPayloadInChunksTask";describe("ProvideTransactionGenericContextTask",()=>{const C="44/60'/0'/0'/0/0",v=new Uint8Array([18,52]),d="0x5678",y=[],l=[],x=1,T={},k={},p={keyUsageNumber:0,payload:new Uint8Array([18,52])},t={derivationPath:C,serializedTransaction:v,context:{transactionInfo:d,transactionInfoCertificate:p,transactionFields:y,transactionEnums:l},chainId:x,transactionParser:T,contextModule:k},n=S();describe("run",()=>{beforeEach(()=>{vi.resetAllMocks()}),describe("should return an error",()=>{it("when storeTransactionResult fail",async()=>{vi.spyOn(s.prototype,"run").mockResolvedValue(e({error:new r("storeTransactionError")})),vi.spyOn(n,"sendCommand").mockResolvedValueOnce(e({data:void 0}));const o=await new a(n,t).run();expect(o).toEqual(u(e({error:new r("storeTransactionError")})))}),it("when provideTransactionInformationResult fail",async()=>{vi.spyOn(s.prototype,"run").mockResolvedValue(e({data:"0x1234"})),vi.spyOn(c.prototype,"run").mockResolvedValue(e({error:new r("provideTransactionInformationError")})),vi.spyOn(n,"sendCommand").mockResolvedValueOnce(e({data:void 0}));const o=await new a(n,t).run();expect(o).toEqual(u(e({error:new r("provideTransactionInformationError")})))}),it("when ProvideTransactionGenericContextTask fail",async()=>{vi.spyOn(s.prototype,"run").mockResolvedValue(e({data:"0x1234"})),vi.spyOn(c.prototype,"run").mockResolvedValue(e({data:"0x5678"})),vi.spyOn(i.prototype,"run").mockResolvedValue(u(e({error:new r("provideTransactionGenericContextTaskError")}))),vi.spyOn(n,"sendCommand").mockResolvedValueOnce(e({data:void 0}));const o=await new a(n,{...t,context:{transactionInfo:d,transactionInfoCertificate:p,transactionFields:[{}],transactionEnums:l}}).run();expect(o).toEqual(u(e({error:new r("provideTransactionGenericContextTaskError")})))})}),it("should call ProvideTransactionFieldDescriptionTask for each field",async()=>{const o=["field-1","field-2"];vi.spyOn(s.prototype,"run").mockResolvedValue(e({data:"0x1234"})),vi.spyOn(c.prototype,"run").mockResolvedValue(e({data:"0x5678"})),vi.spyOn(i.prototype,"run").mockResolvedValue(m),vi.spyOn(n,"sendCommand").mockResolvedValueOnce(e({data:void 0})),await new a(n,{...t,context:{transactionInfo:d,transactionInfoCertificate:p,transactionFields:o,transactionEnums:l}}).run(),expect(i.prototype.run).toHaveBeenCalledTimes(2)}),it("should return Nothing when all fields are provided",async()=>{vi.spyOn(s.prototype,"run").mockResolvedValue(e({data:"0x1234"})),vi.spyOn(c.prototype,"run").mockResolvedValue(e({data:"0x5678"})),vi.spyOn(i.prototype,"run").mockResolvedValue(m),vi.spyOn(n,"sendCommand").mockResolvedValueOnce(e({data:void 0}));const o=await new a(n,t).run();expect(o).toEqual(m)}),it("should load the transaction info certificate",async()=>{vi.spyOn(s.prototype,"run").mockResolvedValue(e({data:"0x1234"})),vi.spyOn(c.prototype,"run").mockResolvedValue(e({data:"0x5678"})),vi.spyOn(i.prototype,"run").mockResolvedValue(m),await new a(n,{...t,context:{transactionInfo:d,transactionInfoCertificate:p,transactionFields:y,transactionEnums:l}}).run(),expect(n.sendCommand).toHaveBeenCalledTimes(1)})})});
1
+ import{CommandResultFactory as e,InvalidStatusWordError as r}from"@ledgerhq/device-management-kit";import{Just as u,Nothing as m}from"purify-ts";import{makeDeviceActionInternalApiMock as S}from"../../app-binder/device-action/__test-utils__/makeInternalApi";import{ProvideTransactionFieldDescriptionTask as i}from"./ProvideTransactionFieldDescriptionTask";import{ProvideTransactionGenericContextTask as a}from"./ProvideTransactionGenericContextTask";import{SendCommandInChunksTask as s}from"./SendCommandInChunksTask";import{SendPayloadInChunksTask as c}from"./SendPayloadInChunksTask";describe("ProvideTransactionGenericContextTask",()=>{const y="44/60'/0'/0'/0/0",v=new Uint8Array([18,52]),l="0x5678",C=[],d=[],x=1,T={},k={},p={keyUsageNumber:0,payload:new Uint8Array([18,52])},t={derivationPath:y,serializedTransaction:v,context:{transactionInfo:l,transactionInfoCertificate:p,transactionFields:C,transactionEnums:d},chainId:x,transactionParser:T,contextModule:k,web3Check:null},n=S();describe("run",()=>{beforeEach(()=>{vi.resetAllMocks()}),describe("should return an error",()=>{it("when storeTransactionResult fail",async()=>{vi.spyOn(s.prototype,"run").mockResolvedValue(e({error:new r("storeTransactionError")})),vi.spyOn(n,"sendCommand").mockResolvedValueOnce(e({data:void 0}));const o=await new a(n,t).run();expect(o).toEqual(u(e({error:new r("storeTransactionError")})))}),it("when provideTransactionInformationResult fail",async()=>{vi.spyOn(s.prototype,"run").mockResolvedValue(e({data:"0x1234"})),vi.spyOn(c.prototype,"run").mockResolvedValue(e({error:new r("provideTransactionInformationError")})),vi.spyOn(n,"sendCommand").mockResolvedValueOnce(e({data:void 0}));const o=await new a(n,t).run();expect(o).toEqual(u(e({error:new r("provideTransactionInformationError")})))}),it("when ProvideTransactionGenericContextTask fail",async()=>{vi.spyOn(s.prototype,"run").mockResolvedValue(e({data:"0x1234"})),vi.spyOn(c.prototype,"run").mockResolvedValue(e({data:"0x5678"})),vi.spyOn(i.prototype,"run").mockResolvedValue(u(e({error:new r("provideTransactionGenericContextTaskError")}))),vi.spyOn(n,"sendCommand").mockResolvedValueOnce(e({data:void 0}));const o=await new a(n,{...t,context:{transactionInfo:l,transactionInfoCertificate:p,transactionFields:[{}],transactionEnums:d}}).run();expect(o).toEqual(u(e({error:new r("provideTransactionGenericContextTaskError")})))})}),it("should call ProvideTransactionFieldDescriptionTask for each field",async()=>{const o=["field-1","field-2"];vi.spyOn(s.prototype,"run").mockResolvedValue(e({data:"0x1234"})),vi.spyOn(c.prototype,"run").mockResolvedValue(e({data:"0x5678"})),vi.spyOn(i.prototype,"run").mockResolvedValue(m),vi.spyOn(n,"sendCommand").mockResolvedValueOnce(e({data:void 0})),await new a(n,{...t,context:{transactionInfo:l,transactionInfoCertificate:p,transactionFields:o,transactionEnums:d}}).run(),expect(i.prototype.run).toHaveBeenCalledTimes(2)}),it("should return Nothing when all fields are provided",async()=>{vi.spyOn(s.prototype,"run").mockResolvedValue(e({data:"0x1234"})),vi.spyOn(c.prototype,"run").mockResolvedValue(e({data:"0x5678"})),vi.spyOn(i.prototype,"run").mockResolvedValue(m),vi.spyOn(n,"sendCommand").mockResolvedValueOnce(e({data:void 0}));const o=await new a(n,t).run();expect(o).toEqual(m)}),it("should load the transaction info certificate",async()=>{vi.spyOn(s.prototype,"run").mockResolvedValue(e({data:"0x1234"})),vi.spyOn(c.prototype,"run").mockResolvedValue(e({data:"0x5678"})),vi.spyOn(i.prototype,"run").mockResolvedValue(m),await new a(n,{...t,context:{transactionInfo:l,transactionInfoCertificate:p,transactionFields:C,transactionEnums:d}}).run(),expect(n.sendCommand).toHaveBeenCalledTimes(1)})})});
2
2
  //# sourceMappingURL=ProvideTransactionGenericContextTask.test.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../../src/internal/app-binder/task/ProvideTransactionGenericContextTask.test.ts"],
4
- "sourcesContent": ["import {\n type ClearSignContextSuccess,\n type ClearSignContextSuccessType,\n type ClearSignContextType,\n type ContextModule,\n type PkiCertificate,\n} from \"@ledgerhq/context-module\";\nimport {\n type CommandErrorResult,\n CommandResultFactory,\n InvalidStatusWordError,\n} from \"@ledgerhq/device-management-kit\";\nimport { Just, Nothing } from \"purify-ts\";\n\nimport { makeDeviceActionInternalApiMock } from \"@internal/app-binder/device-action/__test-utils__/makeInternalApi\";\nimport { type TransactionParserService } from \"@internal/transaction/service/parser/TransactionParserService\";\n\nimport { ProvideTransactionFieldDescriptionTask } from \"./ProvideTransactionFieldDescriptionTask\";\nimport {\n ProvideTransactionGenericContextTask,\n type ProvideTransactionGenericContextTaskArgs,\n} from \"./ProvideTransactionGenericContextTask\";\nimport { SendCommandInChunksTask } from \"./SendCommandInChunksTask\";\nimport { SendPayloadInChunksTask } from \"./SendPayloadInChunksTask\";\n\ndescribe(\"ProvideTransactionGenericContextTask\", () => {\n const derivationPath = \"44/60'/0'/0'/0/0\";\n const serializedTransaction = new Uint8Array([0x12, 0x34]);\n const transactionInfo = \"0x5678\";\n const transactionFields: ClearSignContextSuccess<\n Exclude<ClearSignContextSuccessType, ClearSignContextType.ENUM>\n >[] = [];\n const transactionEnums: ClearSignContextSuccess<ClearSignContextType.ENUM>[] =\n [];\n const chainId = 1;\n const transactionParser = {} as TransactionParserService;\n const contextModule = {} as ContextModule;\n const transactionInfoCertificate: PkiCertificate = {\n keyUsageNumber: 0,\n payload: new Uint8Array([0x12, 0x34]),\n };\n\n const defaultArgs: ProvideTransactionGenericContextTaskArgs = {\n derivationPath,\n serializedTransaction,\n context: {\n transactionInfo,\n transactionInfoCertificate,\n transactionFields,\n transactionEnums,\n },\n chainId,\n transactionParser,\n contextModule,\n };\n\n const apiMock = makeDeviceActionInternalApiMock();\n\n describe(\"run\", () => {\n beforeEach(() => {\n vi.resetAllMocks();\n });\n\n describe(\"should return an error\", () => {\n it(\"when storeTransactionResult fail\", async () => {\n // GIVEN\n vi.spyOn(SendCommandInChunksTask.prototype, \"run\").mockResolvedValue(\n CommandResultFactory({\n error: new InvalidStatusWordError(\"storeTransactionError\"),\n }),\n );\n // loadCertificateCommand\n vi.spyOn(apiMock, \"sendCommand\").mockResolvedValueOnce(\n CommandResultFactory({\n data: undefined,\n }),\n );\n\n // WHEN\n const result = await new ProvideTransactionGenericContextTask(\n apiMock,\n defaultArgs,\n ).run();\n\n // THEN\n expect(result).toEqual(\n Just(\n CommandResultFactory({\n error: new InvalidStatusWordError(\"storeTransactionError\"),\n }),\n ),\n );\n });\n\n it(\"when provideTransactionInformationResult fail\", async () => {\n // GIVEN\n vi.spyOn(SendCommandInChunksTask.prototype, \"run\").mockResolvedValue(\n CommandResultFactory({\n data: \"0x1234\",\n }),\n );\n vi.spyOn(SendPayloadInChunksTask.prototype, \"run\").mockResolvedValue(\n CommandResultFactory({\n error: new InvalidStatusWordError(\n \"provideTransactionInformationError\",\n ),\n }),\n );\n // loadCertificateCommand\n vi.spyOn(apiMock, \"sendCommand\").mockResolvedValueOnce(\n CommandResultFactory({\n data: undefined,\n }),\n );\n\n // WHEN\n const result = await new ProvideTransactionGenericContextTask(\n apiMock,\n defaultArgs,\n ).run();\n\n // THEN\n expect(result).toEqual(\n Just(\n CommandResultFactory({\n error: new InvalidStatusWordError(\n \"provideTransactionInformationError\",\n ),\n }),\n ),\n );\n });\n\n it(\"when ProvideTransactionGenericContextTask fail\", async () => {\n // GIVEN\n vi.spyOn(SendCommandInChunksTask.prototype, \"run\").mockResolvedValue(\n CommandResultFactory({\n data: \"0x1234\",\n }),\n );\n vi.spyOn(SendPayloadInChunksTask.prototype, \"run\").mockResolvedValue(\n CommandResultFactory({\n data: \"0x5678\",\n }),\n );\n vi.spyOn(\n ProvideTransactionFieldDescriptionTask.prototype,\n \"run\",\n ).mockResolvedValue(\n Just(\n CommandResultFactory({\n error: new InvalidStatusWordError(\n \"provideTransactionGenericContextTaskError\",\n ),\n }) as CommandErrorResult,\n ),\n );\n // loadCertificateCommand\n vi.spyOn(apiMock, \"sendCommand\").mockResolvedValueOnce(\n CommandResultFactory({\n data: undefined,\n }),\n );\n\n // WHEN\n const result = await new ProvideTransactionGenericContextTask(apiMock, {\n ...defaultArgs,\n context: {\n transactionInfo,\n transactionInfoCertificate,\n transactionFields: [\n {} as ClearSignContextSuccess<ClearSignContextType.TRANSACTION_INFO>,\n ],\n transactionEnums,\n },\n }).run();\n\n // THEN\n expect(result).toEqual(\n Just(\n CommandResultFactory({\n error: new InvalidStatusWordError(\n \"provideTransactionGenericContextTaskError\",\n ),\n }),\n ),\n );\n });\n });\n\n it(\"should call ProvideTransactionFieldDescriptionTask for each field\", async () => {\n // GIVEN\n const fields: ClearSignContextSuccess<ClearSignContextType.TRANSACTION_FIELD_DESCRIPTION>[] =\n [\n \"field-1\" as unknown as ClearSignContextSuccess<ClearSignContextType.TRANSACTION_FIELD_DESCRIPTION>,\n \"field-2\" as unknown as ClearSignContextSuccess<ClearSignContextType.TRANSACTION_FIELD_DESCRIPTION>,\n ];\n vi.spyOn(SendCommandInChunksTask.prototype, \"run\").mockResolvedValue(\n CommandResultFactory({\n data: \"0x1234\",\n }),\n );\n vi.spyOn(SendPayloadInChunksTask.prototype, \"run\").mockResolvedValue(\n CommandResultFactory({\n data: \"0x5678\",\n }),\n );\n vi.spyOn(\n ProvideTransactionFieldDescriptionTask.prototype,\n \"run\",\n ).mockResolvedValue(Nothing);\n // loadCertificateCommand\n vi.spyOn(apiMock, \"sendCommand\").mockResolvedValueOnce(\n CommandResultFactory({\n data: undefined,\n }),\n );\n\n // WHEN\n await new ProvideTransactionGenericContextTask(apiMock, {\n ...defaultArgs,\n context: {\n transactionInfo,\n transactionInfoCertificate,\n transactionFields: fields,\n transactionEnums,\n },\n }).run();\n\n // THEN\n expect(\n ProvideTransactionFieldDescriptionTask.prototype.run,\n ).toHaveBeenCalledTimes(2);\n });\n\n it(\"should return Nothing when all fields are provided\", async () => {\n // GIVEN\n vi.spyOn(SendCommandInChunksTask.prototype, \"run\").mockResolvedValue(\n CommandResultFactory({\n data: \"0x1234\",\n }),\n );\n vi.spyOn(SendPayloadInChunksTask.prototype, \"run\").mockResolvedValue(\n CommandResultFactory({\n data: \"0x5678\",\n }),\n );\n vi.spyOn(\n ProvideTransactionFieldDescriptionTask.prototype,\n \"run\",\n ).mockResolvedValue(Nothing);\n // loadCertificateCommand\n vi.spyOn(apiMock, \"sendCommand\").mockResolvedValueOnce(\n CommandResultFactory({\n data: undefined,\n }),\n );\n\n // WHEN\n const result = await new ProvideTransactionGenericContextTask(\n apiMock,\n defaultArgs,\n ).run();\n\n // THEN\n expect(result).toEqual(Nothing);\n });\n\n it(\"should load the transaction info certificate\", async () => {\n // GIVEN\n vi.spyOn(SendCommandInChunksTask.prototype, \"run\").mockResolvedValue(\n CommandResultFactory({\n data: \"0x1234\",\n }),\n );\n vi.spyOn(SendPayloadInChunksTask.prototype, \"run\").mockResolvedValue(\n CommandResultFactory({\n data: \"0x5678\",\n }),\n );\n vi.spyOn(\n ProvideTransactionFieldDescriptionTask.prototype,\n \"run\",\n ).mockResolvedValue(Nothing);\n\n // WHEN\n await new ProvideTransactionGenericContextTask(apiMock, {\n ...defaultArgs,\n context: {\n transactionInfo,\n transactionInfoCertificate,\n transactionFields,\n transactionEnums,\n },\n }).run();\n\n // THEN\n expect(apiMock.sendCommand).toHaveBeenCalledTimes(1);\n });\n });\n});\n"],
5
- "mappings": "AAOA,OAEE,wBAAAA,EACA,0BAAAC,MACK,kCACP,OAAS,QAAAC,EAAM,WAAAC,MAAe,YAE9B,OAAS,mCAAAC,MAAuC,oEAGhD,OAAS,0CAAAC,MAA8C,2CACvD,OACE,wCAAAC,MAEK,yCACP,OAAS,2BAAAC,MAA+B,4BACxC,OAAS,2BAAAC,MAA+B,4BAExC,SAAS,uCAAwC,IAAM,CACrD,MAAMC,EAAiB,mBACjBC,EAAwB,IAAI,WAAW,CAAC,GAAM,EAAI,CAAC,EACnDC,EAAkB,SAClBC,EAEA,CAAC,EACDC,EACJ,CAAC,EACGC,EAAU,EACVC,EAAoB,CAAC,EACrBC,EAAgB,CAAC,EACjBC,EAA6C,CACjD,eAAgB,EAChB,QAAS,IAAI,WAAW,CAAC,GAAM,EAAI,CAAC,CACtC,EAEMC,EAAwD,CAC5D,eAAAT,EACA,sBAAAC,EACA,QAAS,CACP,gBAAAC,EACA,2BAAAM,EACA,kBAAAL,EACA,iBAAAC,CACF,EACA,QAAAC,EACA,kBAAAC,EACA,cAAAC,CACF,EAEMG,EAAUf,EAAgC,EAEhD,S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EAAE,kBAAkBF,CAAO,EAE3B,GAAG,MAAMgB,EAAS,aAAa,EAAE,sBAC/BnB,EAAqB,CACnB,KAAM,MACR,CAAC,CACH,EAGA,MAAMoB,EAAS,MAAM,IAAId,EACvBa,EACAD,CACF,EAAE,IAAI,EAGN,OAAOE,CAAM,EAAE,QAAQjB,CAAO,CAChC,CAAC,EAED,GAAG,+CAAgD,SAAY,CAE7D,GAAG,MAAMI,EAAwB,UAAW,KAAK,EAAE,kBACjDP,EAAqB,CACnB,KAAM,QACR,CAAC,CACH,EACA,GAAG,MAAMQ,EAAwB,UAAW,KAAK,EAAE,kBACjDR,EAAqB,CACnB,KAAM,QACR,CAAC,CACH,EACA,GAAG,MACDK,EAAuC,UACvC,KACF,EAAE,kBAAkBF,CAAO,EAG3B,MAAM,IAAIG,EAAqCa,EAAS,CACtD,GAAGD,EACH,QAAS,CACP,gBAAAP,EACA,2BAAAM,EACA,kBAAAL,EACA,iBAAAC,CACF,CACF,CAAC,EAAE,IAAI,EAGP,OAAOM,EAAQ,WAAW,EAAE,sBAAsB,CAAC,CACrD,CAAC,CACH,CAAC,CACH,CAAC",
4
+ "sourcesContent": ["import {\n type ClearSignContextSuccess,\n type ClearSignContextSuccessType,\n type ClearSignContextType,\n type ContextModule,\n type PkiCertificate,\n} from \"@ledgerhq/context-module\";\nimport {\n type CommandErrorResult,\n CommandResultFactory,\n InvalidStatusWordError,\n} from \"@ledgerhq/device-management-kit\";\nimport { Just, Nothing } from \"purify-ts\";\n\nimport { makeDeviceActionInternalApiMock } from \"@internal/app-binder/device-action/__test-utils__/makeInternalApi\";\nimport { type TransactionParserService } from \"@internal/transaction/service/parser/TransactionParserService\";\n\nimport { ProvideTransactionFieldDescriptionTask } from \"./ProvideTransactionFieldDescriptionTask\";\nimport {\n ProvideTransactionGenericContextTask,\n type ProvideTransactionGenericContextTaskArgs,\n} from \"./ProvideTransactionGenericContextTask\";\nimport { SendCommandInChunksTask } from \"./SendCommandInChunksTask\";\nimport { SendPayloadInChunksTask } from \"./SendPayloadInChunksTask\";\n\ndescribe(\"ProvideTransactionGenericContextTask\", () => {\n const derivationPath = \"44/60'/0'/0'/0/0\";\n const serializedTransaction = new Uint8Array([0x12, 0x34]);\n const transactionInfo = \"0x5678\";\n const transactionFields: ClearSignContextSuccess<\n Exclude<ClearSignContextSuccessType, ClearSignContextType.ENUM>\n >[] = [];\n const transactionEnums: ClearSignContextSuccess<ClearSignContextType.ENUM>[] =\n [];\n const chainId = 1;\n const transactionParser = {} as TransactionParserService;\n const contextModule = {} as ContextModule;\n const transactionInfoCertificate: PkiCertificate = {\n keyUsageNumber: 0,\n payload: new Uint8Array([0x12, 0x34]),\n };\n\n const defaultArgs: ProvideTransactionGenericContextTaskArgs = {\n derivationPath,\n serializedTransaction,\n context: {\n transactionInfo,\n transactionInfoCertificate,\n transactionFields,\n transactionEnums,\n },\n chainId,\n transactionParser,\n contextModule,\n web3Check: null,\n };\n\n const apiMock = makeDeviceActionInternalApiMock();\n\n describe(\"run\", () => {\n beforeEach(() => {\n vi.resetAllMocks();\n });\n\n describe(\"should return an error\", () => {\n it(\"when storeTransactionResult fail\", async () => {\n // GIVEN\n vi.spyOn(SendCommandInChunksTask.prototype, \"run\").mockResolvedValue(\n CommandResultFactory({\n error: new InvalidStatusWordError(\"storeTransactionError\"),\n }),\n );\n // loadCertificateCommand\n vi.spyOn(apiMock, \"sendCommand\").mockResolvedValueOnce(\n CommandResultFactory({\n data: undefined,\n }),\n );\n\n // WHEN\n const result = await new ProvideTransactionGenericContextTask(\n apiMock,\n defaultArgs,\n ).run();\n\n // THEN\n expect(result).toEqual(\n Just(\n CommandResultFactory({\n error: new InvalidStatusWordError(\"storeTransactionError\"),\n }),\n ),\n );\n });\n\n it(\"when provideTransactionInformationResult fail\", async () => {\n // GIVEN\n vi.spyOn(SendCommandInChunksTask.prototype, \"run\").mockResolvedValue(\n CommandResultFactory({\n data: \"0x1234\",\n }),\n );\n vi.spyOn(SendPayloadInChunksTask.prototype, \"run\").mockResolvedValue(\n CommandResultFactory({\n error: new InvalidStatusWordError(\n \"provideTransactionInformationError\",\n ),\n }),\n );\n // loadCertificateCommand\n vi.spyOn(apiMock, \"sendCommand\").mockResolvedValueOnce(\n CommandResultFactory({\n data: undefined,\n }),\n );\n\n // WHEN\n const result = await new ProvideTransactionGenericContextTask(\n apiMock,\n defaultArgs,\n ).run();\n\n // THEN\n expect(result).toEqual(\n Just(\n CommandResultFactory({\n error: new InvalidStatusWordError(\n \"provideTransactionInformationError\",\n ),\n }),\n ),\n );\n });\n\n it(\"when ProvideTransactionGenericContextTask fail\", async () => {\n // GIVEN\n vi.spyOn(SendCommandInChunksTask.prototype, \"run\").mockResolvedValue(\n CommandResultFactory({\n data: \"0x1234\",\n }),\n );\n vi.spyOn(SendPayloadInChunksTask.prototype, \"run\").mockResolvedValue(\n CommandResultFactory({\n data: \"0x5678\",\n }),\n );\n vi.spyOn(\n ProvideTransactionFieldDescriptionTask.prototype,\n \"run\",\n ).mockResolvedValue(\n Just(\n CommandResultFactory({\n error: new InvalidStatusWordError(\n \"provideTransactionGenericContextTaskError\",\n ),\n }) as CommandErrorResult,\n ),\n );\n // loadCertificateCommand\n vi.spyOn(apiMock, \"sendCommand\").mockResolvedValueOnce(\n CommandResultFactory({\n data: undefined,\n }),\n );\n\n // WHEN\n const result = await new ProvideTransactionGenericContextTask(apiMock, {\n ...defaultArgs,\n context: {\n transactionInfo,\n transactionInfoCertificate,\n transactionFields: [\n {} as ClearSignContextSuccess<ClearSignContextType.TRANSACTION_INFO>,\n ],\n transactionEnums,\n },\n }).run();\n\n // THEN\n expect(result).toEqual(\n Just(\n CommandResultFactory({\n error: new InvalidStatusWordError(\n \"provideTransactionGenericContextTaskError\",\n ),\n }),\n ),\n );\n });\n });\n\n it(\"should call ProvideTransactionFieldDescriptionTask for each field\", async () => {\n // GIVEN\n const fields: ClearSignContextSuccess<ClearSignContextType.TRANSACTION_FIELD_DESCRIPTION>[] =\n [\n \"field-1\" as unknown as ClearSignContextSuccess<ClearSignContextType.TRANSACTION_FIELD_DESCRIPTION>,\n \"field-2\" as unknown as ClearSignContextSuccess<ClearSignContextType.TRANSACTION_FIELD_DESCRIPTION>,\n ];\n vi.spyOn(SendCommandInChunksTask.prototype, \"run\").mockResolvedValue(\n CommandResultFactory({\n data: \"0x1234\",\n }),\n );\n vi.spyOn(SendPayloadInChunksTask.prototype, \"run\").mockResolvedValue(\n CommandResultFactory({\n data: \"0x5678\",\n }),\n );\n vi.spyOn(\n ProvideTransactionFieldDescriptionTask.prototype,\n \"run\",\n ).mockResolvedValue(Nothing);\n // loadCertificateCommand\n vi.spyOn(apiMock, \"sendCommand\").mockResolvedValueOnce(\n CommandResultFactory({\n data: undefined,\n }),\n );\n\n // WHEN\n await new ProvideTransactionGenericContextTask(apiMock, {\n ...defaultArgs,\n context: {\n transactionInfo,\n transactionInfoCertificate,\n transactionFields: fields,\n transactionEnums,\n },\n }).run();\n\n // THEN\n expect(\n ProvideTransactionFieldDescriptionTask.prototype.run,\n ).toHaveBeenCalledTimes(2);\n });\n\n it(\"should return Nothing when all fields are provided\", async () => {\n // GIVEN\n vi.spyOn(SendCommandInChunksTask.prototype, \"run\").mockResolvedValue(\n CommandResultFactory({\n data: \"0x1234\",\n }),\n );\n vi.spyOn(SendPayloadInChunksTask.prototype, \"run\").mockResolvedValue(\n CommandResultFactory({\n data: \"0x5678\",\n }),\n );\n vi.spyOn(\n ProvideTransactionFieldDescriptionTask.prototype,\n \"run\",\n ).mockResolvedValue(Nothing);\n // loadCertificateCommand\n vi.spyOn(apiMock, \"sendCommand\").mockResolvedValueOnce(\n CommandResultFactory({\n data: undefined,\n }),\n );\n\n // WHEN\n const result = await new ProvideTransactionGenericContextTask(\n apiMock,\n defaultArgs,\n ).run();\n\n // THEN\n expect(result).toEqual(Nothing);\n });\n\n it(\"should load the transaction info certificate\", async () => {\n // GIVEN\n vi.spyOn(SendCommandInChunksTask.prototype, \"run\").mockResolvedValue(\n CommandResultFactory({\n data: \"0x1234\",\n }),\n );\n vi.spyOn(SendPayloadInChunksTask.prototype, \"run\").mockResolvedValue(\n CommandResultFactory({\n data: \"0x5678\",\n }),\n );\n vi.spyOn(\n ProvideTransactionFieldDescriptionTask.prototype,\n \"run\",\n ).mockResolvedValue(Nothing);\n\n // WHEN\n await new ProvideTransactionGenericContextTask(apiMock, {\n ...defaultArgs,\n context: {\n transactionInfo,\n transactionInfoCertificate,\n transactionFields,\n transactionEnums,\n },\n }).run();\n\n // THEN\n expect(apiMock.sendCommand).toHaveBeenCalledTimes(1);\n });\n });\n});\n"],
5
+ "mappings": "AAOA,OAEE,wBAAAA,EACA,0BAAAC,MACK,kCACP,OAAS,QAAAC,EAAM,WAAAC,MAAe,YAE9B,OAAS,mCAAAC,MAAuC,oEAGhD,OAAS,0CAAAC,MAA8C,2CACvD,OACE,wCAAAC,MAEK,yCACP,OAAS,2BAAAC,MAA+B,4BACxC,OAAS,2BAAAC,MAA+B,4BAExC,SAAS,uCAAwC,IAAM,CACrD,MAAMC,EAAiB,mBACjBC,EAAwB,IAAI,WAAW,CAAC,GAAM,EAAI,CAAC,EACnDC,EAAkB,SAClBC,EAEA,CAAC,EACDC,EACJ,CAAC,EACGC,EAAU,EACVC,EAAoB,CAAC,EACrBC,EAAgB,CAAC,EACjBC,EAA6C,CACjD,eAAgB,EAChB,QAAS,IAAI,WAAW,CAAC,GAAM,EAAI,CAAC,CACtC,EAEMC,EAAwD,CAC5D,eAAAT,EACA,sBAAAC,EACA,QAAS,CACP,gBAAAC,EACA,2BAAAM,EACA,kBAAAL,EACA,iBAAAC,CACF,EACA,QAAAC,EACA,kBAAAC,EACA,cAAAC,EACA,UAAW,IACb,EAEMG,EAAUf,EAAgC,EAEhD,SAAS,MAAO,IAAM,CACpB,WAAW,IAAM,CACf,GAAG,cAAc,CACnB,CAAC,EAED,SAAS,yBAA0B,IAAM,CACvC,GAAG,mCAAoC,SAAY,CAEjD,GAAG,MAAMG,EAAwB,UAAW,KAAK,EAAE,kBAC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AAI,EAGN,OAAOE,CAAM,EAAE,QAAQjB,CAAO,CAChC,CAAC,EAED,GAAG,+CAAgD,SAAY,CAE7D,GAAG,MAAMI,EAAwB,UAAW,KAAK,EAAE,kBACjDP,EAAqB,CACnB,KAAM,QACR,CAAC,CACH,EACA,GAAG,MAAMQ,EAAwB,UAAW,KAAK,EAAE,kBACjDR,EAAqB,CACnB,KAAM,QACR,CAAC,CACH,EACA,GAAG,MACDK,EAAuC,UACvC,KACF,EAAE,kBAAkBF,CAAO,EAG3B,MAAM,IAAIG,EAAqCa,EAAS,CACtD,GAAGD,EACH,QAAS,CACP,gBAAAP,EACA,2BAAAM,EACA,kBAAAL,EACA,iBAAAC,CACF,CACF,CAAC,EAAE,IAAI,EAGP,OAAOM,EAAQ,WAAW,EAAE,sBAAsB,CAAC,CACrD,CAAC,CACH,CAAC,CACH,CAAC",
6
6
  "names": ["CommandResultFactory", "InvalidStatusWordError", "Just", "Nothing", "makeDeviceActionInternalApiMock", "ProvideTransactionFieldDescriptionTask", "ProvideTransactionGenericContextTask", "SendCommandInChunksTask", "SendPayloadInChunksTask", "derivationPath", "serializedTransaction", "transactionInfo", "transactionFields", "transactionEnums", "chainId", "transactionParser", "contextModule", "transactionInfoCertificate", "defaultArgs", "apiMock", "result", "fields"]
7
7
  }
@@ -0,0 +1,2 @@
1
+ import{DeviceSessionStateType as s}from"@ledgerhq/device-management-kit";import{gt as t,gte as o}from"semver";import{ETHEREUM_PLUGINS as r}from"../../app-binder/constant/plugins";class m{isCompatible=!0;version="0.0.1";modelId;constructor(e,i){if(this.modelId=e.deviceModelId,e.sessionStateType===s.Connected){this.isCompatible=!1;return}if(e.currentApp.name!=="Ethereum"&&!r.includes(e.currentApp.name)){this.isCompatible=!1;return}e.currentApp.name==="Ethereum"?this.version=e.currentApp.version:e.currentApp.name==="Exchange"?this.isCompatible=!1:this.version=i.version}withMinVersionInclusive(e){return o(this.version,e)||(this.isCompatible=!1),this}withMinVersionExclusive(e){return t(this.version,e)||(this.isCompatible=!1),this}excludeDeviceModel(e){return this.modelId===e&&(this.isCompatible=!1),this}check(){return this.isCompatible}}export{m as ApplicationChecker};
2
+ //# sourceMappingURL=ApplicationChecker.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../../../src/internal/shared/utils/ApplicationChecker.ts"],
4
+ "sourcesContent": ["import {\n type DeviceModelId,\n type DeviceSessionState,\n DeviceSessionStateType,\n} from \"@ledgerhq/device-management-kit\";\nimport { gt, gte } from \"semver\";\n\nimport { type GetConfigCommandResponse } from \"@api/app-binder/GetConfigCommandTypes\";\nimport { ETHEREUM_PLUGINS } from \"@internal/app-binder/constant/plugins\";\n\nexport class ApplicationChecker {\n private isCompatible: boolean = true;\n private version: string = \"0.0.1\";\n private modelId: DeviceModelId;\n\n constructor(\n deviceState: DeviceSessionState,\n appConfig: GetConfigCommandResponse,\n ) {\n this.modelId = deviceState.deviceModelId;\n\n // If device is not ready or app is unexpected, checker cannot be successful\n if (deviceState.sessionStateType === DeviceSessionStateType.Connected) {\n this.isCompatible = false;\n return;\n }\n if (\n deviceState.currentApp.name !== \"Ethereum\" &&\n !ETHEREUM_PLUGINS.includes(deviceState.currentApp.name)\n ) {\n this.isCompatible = false;\n return;\n }\n if (deviceState.currentApp.name === \"Ethereum\") {\n this.version = deviceState.currentApp.version;\n } else if (deviceState.currentApp.name === \"Exchange\") {\n // Exchanges flows are not compatibles with ethereum features appart from SignTx\n this.isCompatible = false;\n } else {\n // Fallback on appConfig version if a plugin is running.\n // It won't contain release candidate suffix but it should be enough for that edge case.\n this.version = appConfig.version;\n }\n }\n\n withMinVersionInclusive(version: string): ApplicationChecker {\n if (!gte(this.version, version)) {\n this.isCompatible = false;\n }\n return this;\n }\n\n withMinVersionExclusive(version: string): ApplicationChecker {\n if (!gt(this.version, version)) {\n this.isCompatible = false;\n }\n return this;\n }\n\n excludeDeviceModel(modelId: DeviceModelId): ApplicationChecker {\n if (this.modelId === modelId) {\n this.isCompatible = false;\n }\n return this;\n }\n\n check(): boolean {\n return this.isCompatible;\n }\n}\n"],
5
+ "mappings": "AAAA,OAGE,0BAAAA,MACK,kCACP,OAAS,MAAAC,EAAI,OAAAC,MAAW,SAGxB,OAAS,oBAAAC,MAAwB,wCAE1B,MAAMC,CAAmB,CACtB,aAAwB,GACxB,QAAkB,QAClB,QAER,YACEC,EACAC,EACA,CAIA,GAHA,KAAK,QAAUD,EAAY,cAGvBA,EAAY,mBAAqBL,EAAuB,UAAW,CACrE,KAAK,aAAe,GACpB,MACF,CACA,GACEK,EAAY,WAAW,OAAS,YAChC,CAACF,EAAiB,SAASE,EAAY,WAAW,IAAI,EACtD,CACA,KAAK,aAAe,GACpB,MACF,CACIA,EAAY,WAAW,OAAS,WAClC,KAAK,QAAUA,EAAY,WAAW,QAC7BA,EAAY,WAAW,OAAS,WAEzC,KAAK,aAAe,GAIpB,KAAK,QAAUC,EAAU,OAE7B,CAEA,wBAAwBC,EAAqC,CAC3D,OAAKL,EAAI,KAAK,QAASK,CAAO,IAC5B,KAAK,aAAe,IAEf,IACT,CAEA,wBAAwBA,EAAqC,CAC3D,OAAKN,EAAG,KAAK,QAASM,CAAO,IAC3B,KAAK,aAAe,IAEf,IACT,CAEA,mBAAmBC,EAA4C,CAC7D,OAAI,KAAK,UAAYA,IACnB,KAAK,aAAe,IAEf,IACT,CAEA,OAAiB,CACf,OAAO,KAAK,YACd,CACF",
6
+ "names": ["DeviceSessionStateType", "gt", "gte", "ETHEREUM_PLUGINS", "ApplicationChecker", "deviceState", "appConfig", "version", "modelId"]
7
+ }
@@ -0,0 +1,2 @@
1
+ import{DeviceModelId as c,DeviceSessionStateType as i,DeviceStatus as o}from"@ledgerhq/device-management-kit";import{ApplicationChecker as l}from"./ApplicationChecker";describe("ApplicationChecker",()=>{function s(e){return{blindSigningEnabled:!1,web3ChecksEnabled:!1,web3ChecksOptIn:!1,version:e}}it("should pass the check for exclusive version",()=>{const e={sessionStateType:i.ReadyWithoutSecureChannel,deviceStatus:o.CONNECTED,installedApps:[],currentApp:{name:"Ethereum",version:"1.13.0-rc"},deviceModelId:c.FLEX,isSecureConnectionAllowed:!1},t=s("1.13.0"),n=new l(e,t).withMinVersionExclusive("1.12.0").check();expect(n).toStrictEqual(!0)}),it("should reject the check for exclusive version",()=>{const e={sessionStateType:i.ReadyWithoutSecureChannel,deviceStatus:o.CONNECTED,installedApps:[],currentApp:{name:"Ethereum",version:"1.12.0"},deviceModelId:c.FLEX,isSecureConnectionAllowed:!1},t=s("1.12.0"),n=new l(e,t).withMinVersionExclusive("1.12.0").check();expect(n).toStrictEqual(!1)}),it("should pass the check for inclusive version",()=>{const e={sessionStateType:i.ReadyWithoutSecureChannel,deviceStatus:o.CONNECTED,installedApps:[],currentApp:{name:"Ethereum",version:"1.12.0"},deviceModelId:c.FLEX,isSecureConnectionAllowed:!1},t=s("1.10.0"),n=new l(e,t).withMinVersionInclusive("1.12.0").check();expect(n).toStrictEqual(!0)}),it("should reject the check for inclusive version",()=>{const e={sessionStateType:i.ReadyWithoutSecureChannel,deviceStatus:o.CONNECTED,installedApps:[],currentApp:{name:"Ethereum",version:"1.11.0"},deviceModelId:c.FLEX,isSecureConnectionAllowed:!1},t=s("1.11.0"),n=new l(e,t).withMinVersionInclusive("1.12.0").check();expect(n).toStrictEqual(!1)}),it("should pass the check for excluded device",()=>{const e={sessionStateType:i.ReadyWithoutSecureChannel,deviceStatus:o.CONNECTED,installedApps:[],currentApp:{name:"Ethereum",version:"1.11.0"},deviceModelId:c.FLEX,isSecureConnectionAllowed:!1},t=s("1.11.0"),n=new l(e,t).excludeDeviceModel(c.NANO_S).check();expect(n).toStrictEqual(!0)}),it("should reject the check for excluded device",()=>{const e={sessionStateType:i.ReadyWithoutSecureChannel,deviceStatus:o.CONNECTED,installedApps:[],currentApp:{name:"Ethereum",version:"1.11.0"},deviceModelId:c.FLEX,isSecureConnectionAllowed:!1},t=s("1.11.0"),n=new l(e,t).excludeDeviceModel(c.FLEX).check();expect(n).toStrictEqual(!1)}),it("should pass the check for chained condition",()=>{const e={sessionStateType:i.ReadyWithoutSecureChannel,deviceStatus:o.CONNECTED,installedApps:[],currentApp:{name:"Ethereum",version:"1.11.0"},deviceModelId:c.FLEX,isSecureConnectionAllowed:!1},t=s("1.11.0"),n=new l(e,t).withMinVersionInclusive("1.11.0").excludeDeviceModel(c.NANO_S).check();expect(n).toStrictEqual(!0)}),it("should reject the check for chained condition",()=>{const e={sessionStateType:i.ReadyWithoutSecureChannel,deviceStatus:o.CONNECTED,installedApps:[],currentApp:{name:"Ethereum",version:"1.10.0"},deviceModelId:c.FLEX,isSecureConnectionAllowed:!1},t=s("1.10.0"),n=new l(e,t).withMinVersionInclusive("1.11.0").excludeDeviceModel(c.NANO_S).check();expect(n).toStrictEqual(!1)}),it("exchange app should not be compatible with eth features",()=>{const e={sessionStateType:i.ReadyWithoutSecureChannel,deviceStatus:o.CONNECTED,installedApps:[],currentApp:{name:"Exchange",version:"1.11.0-rc"},deviceModelId:c.FLEX,isSecureConnectionAllowed:!1},t=s("1.13.0"),n=new l(e,t).check();expect(n).toStrictEqual(!1)}),it("should pass the check in plugins",()=>{const e={sessionStateType:i.ReadyWithoutSecureChannel,deviceStatus:o.CONNECTED,installedApps:[],currentApp:{name:"1inch",version:"1.11.0-rc"},deviceModelId:c.FLEX,isSecureConnectionAllowed:!1},t=s("1.13.0"),n=new l(e,t).withMinVersionExclusive("1.12.0").check();expect(n).toStrictEqual(!0)}),it("should reject the check in unknexpected app",()=>{const e={sessionStateType:i.ReadyWithoutSecureChannel,deviceStatus:o.CONNECTED,installedApps:[],currentApp:{name:"Bitcoin",version:"1.13.0-rc"},deviceModelId:c.FLEX,isSecureConnectionAllowed:!1},t=s("1.13.0"),n=new l(e,t).withMinVersionExclusive("1.12.0").check();expect(n).toStrictEqual(!1)}),it("should reject the check in unknexpected state",()=>{const e={sessionStateType:i.Connected,deviceStatus:o.CONNECTED,installedApps:[],currentApp:{name:"Bitcoin",version:"1.13.0-rc"},deviceModelId:c.FLEX,isSecureConnectionAllowed:!1},t=s("1.13.0"),n=new l(e,t).withMinVersionExclusive("1.12.0").check();expect(n).toStrictEqual(!1)})});
2
+ //# sourceMappingURL=ApplicationChecker.test.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../../../src/internal/shared/utils/ApplicationChecker.test.ts"],
4
+ "sourcesContent": ["import {\n DeviceModelId,\n DeviceSessionStateType,\n DeviceStatus,\n} from \"@ledgerhq/device-management-kit\";\n\nimport type { GetConfigCommandResponse } from \"@api/app-binder/GetConfigCommandTypes\";\n\nimport { ApplicationChecker } from \"./ApplicationChecker\";\n\ndescribe(\"ApplicationChecker\", () => {\n function createAppConfig(version: string): GetConfigCommandResponse {\n return {\n blindSigningEnabled: false,\n web3ChecksEnabled: false,\n web3ChecksOptIn: false,\n version,\n };\n }\n\n it(\"should pass the check for exclusive version\", () => {\n // GIVEN\n const state = {\n sessionStateType: DeviceSessionStateType.ReadyWithoutSecureChannel,\n deviceStatus: DeviceStatus.CONNECTED,\n installedApps: [],\n currentApp: { name: \"Ethereum\", version: \"1.13.0-rc\" },\n deviceModelId: DeviceModelId.FLEX,\n isSecureConnectionAllowed: false,\n };\n const config = createAppConfig(\"1.13.0\");\n // WHEN\n const result = new ApplicationChecker(state, config)\n .withMinVersionExclusive(\"1.12.0\")\n .check();\n // THEN\n expect(result).toStrictEqual(true);\n });\n\n it(\"should reject the check for exclusive version\", () => {\n // GIVEN\n const state = {\n sessionStateType: DeviceSessionStateType.ReadyWithoutSecureChannel,\n deviceStatus: DeviceStatus.CONNECTED,\n installedApps: [],\n currentApp: { name: \"Ethereum\", version: \"1.12.0\" },\n deviceModelId: DeviceModelId.FLEX,\n isSecureConnectionAllowed: false,\n };\n const config = createAppConfig(\"1.12.0\");\n // WHEN\n const result = new ApplicationChecker(state, config)\n .withMinVersionExclusive(\"1.12.0\")\n .check();\n // THEN\n expect(result).toStrictEqual(false);\n });\n\n it(\"should pass the check for inclusive version\", () => {\n // GIVEN\n const state = {\n sessionStateType: DeviceSessionStateType.ReadyWithoutSecureChannel,\n deviceStatus: DeviceStatus.CONNECTED,\n installedApps: [],\n currentApp: { name: \"Ethereum\", version: \"1.12.0\" },\n deviceModelId: DeviceModelId.FLEX,\n isSecureConnectionAllowed: false,\n };\n const config = createAppConfig(\"1.10.0\");\n // WHEN\n const result = new ApplicationChecker(state, config)\n .withMinVersionInclusive(\"1.12.0\")\n .check();\n // THEN\n expect(result).toStrictEqual(true);\n });\n\n it(\"should reject the check for inclusive version\", () => {\n // GIVEN\n const state = {\n sessionStateType: DeviceSessionStateType.ReadyWithoutSecureChannel,\n deviceStatus: DeviceStatus.CONNECTED,\n installedApps: [],\n currentApp: { name: \"Ethereum\", version: \"1.11.0\" },\n deviceModelId: DeviceModelId.FLEX,\n isSecureConnectionAllowed: false,\n };\n const config = createAppConfig(\"1.11.0\");\n // WHEN\n const result = new ApplicationChecker(state, config)\n .withMinVersionInclusive(\"1.12.0\")\n .check();\n // THEN\n expect(result).toStrictEqual(false);\n });\n\n it(\"should pass the check for excluded device\", () => {\n // GIVEN\n const state = {\n sessionStateType: DeviceSessionStateType.ReadyWithoutSecureChannel,\n deviceStatus: DeviceStatus.CONNECTED,\n installedApps: [],\n currentApp: { name: \"Ethereum\", version: \"1.11.0\" },\n deviceModelId: DeviceModelId.FLEX,\n isSecureConnectionAllowed: false,\n };\n const config = createAppConfig(\"1.11.0\");\n // WHEN\n const result = new ApplicationChecker(state, config)\n .excludeDeviceModel(DeviceModelId.NANO_S)\n .check();\n // THEN\n expect(result).toStrictEqual(true);\n });\n\n it(\"should reject the check for excluded device\", () => {\n // GIVEN\n const state = {\n sessionStateType: DeviceSessionStateType.ReadyWithoutSecureChannel,\n deviceStatus: DeviceStatus.CONNECTED,\n installedApps: [],\n currentApp: { name: \"Ethereum\", version: \"1.11.0\" },\n deviceModelId: DeviceModelId.FLEX,\n isSecureConnectionAllowed: false,\n };\n const config = createAppConfig(\"1.11.0\");\n // WHEN\n const result = new ApplicationChecker(state, config)\n .excludeDeviceModel(DeviceModelId.FLEX)\n .check();\n // THEN\n expect(result).toStrictEqual(false);\n });\n\n it(\"should pass the check for chained condition\", () => {\n // GIVEN\n const state = {\n sessionStateType: DeviceSessionStateType.ReadyWithoutSecureChannel,\n deviceStatus: DeviceStatus.CONNECTED,\n installedApps: [],\n currentApp: { name: \"Ethereum\", version: \"1.11.0\" },\n deviceModelId: DeviceModelId.FLEX,\n isSecureConnectionAllowed: false,\n };\n const config = createAppConfig(\"1.11.0\");\n // WHEN\n const result = new ApplicationChecker(state, config)\n .withMinVersionInclusive(\"1.11.0\")\n .excludeDeviceModel(DeviceModelId.NANO_S)\n .check();\n // THEN\n expect(result).toStrictEqual(true);\n });\n\n it(\"should reject the check for chained condition\", () => {\n // GIVEN\n const state = {\n sessionStateType: DeviceSessionStateType.ReadyWithoutSecureChannel,\n deviceStatus: DeviceStatus.CONNECTED,\n installedApps: [],\n currentApp: { name: \"Ethereum\", version: \"1.10.0\" },\n deviceModelId: DeviceModelId.FLEX,\n isSecureConnectionAllowed: false,\n };\n const config = createAppConfig(\"1.10.0\");\n // WHEN\n const result = new ApplicationChecker(state, config)\n .withMinVersionInclusive(\"1.11.0\")\n .excludeDeviceModel(DeviceModelId.NANO_S)\n .check();\n // THEN\n expect(result).toStrictEqual(false);\n });\n\n it(\"exchange app should not be compatible with eth features\", () => {\n // GIVEN\n const state = {\n sessionStateType: DeviceSessionStateType.ReadyWithoutSecureChannel,\n deviceStatus: DeviceStatus.CONNECTED,\n installedApps: [],\n currentApp: { name: \"Exchange\", version: \"1.11.0-rc\" },\n deviceModelId: DeviceModelId.FLEX,\n isSecureConnectionAllowed: false,\n };\n const config = createAppConfig(\"1.13.0\");\n // WHEN\n const result = new ApplicationChecker(state, config).check();\n // THEN\n expect(result).toStrictEqual(false);\n });\n\n it(\"should pass the check in plugins\", () => {\n // GIVEN\n const state = {\n sessionStateType: DeviceSessionStateType.ReadyWithoutSecureChannel,\n deviceStatus: DeviceStatus.CONNECTED,\n installedApps: [],\n currentApp: { name: \"1inch\", version: \"1.11.0-rc\" },\n deviceModelId: DeviceModelId.FLEX,\n isSecureConnectionAllowed: false,\n };\n const config = createAppConfig(\"1.13.0\");\n // WHEN\n const result = new ApplicationChecker(state, config)\n .withMinVersionExclusive(\"1.12.0\")\n .check();\n // THEN\n expect(result).toStrictEqual(true);\n });\n\n it(\"should reject the check in unknexpected app\", () => {\n // GIVEN\n const state = {\n sessionStateType: DeviceSessionStateType.ReadyWithoutSecureChannel,\n deviceStatus: DeviceStatus.CONNECTED,\n installedApps: [],\n currentApp: { name: \"Bitcoin\", version: \"1.13.0-rc\" },\n deviceModelId: DeviceModelId.FLEX,\n isSecureConnectionAllowed: false,\n };\n const config = createAppConfig(\"1.13.0\");\n // WHEN\n const result = new ApplicationChecker(state, config)\n .withMinVersionExclusive(\"1.12.0\")\n .check();\n // THEN\n expect(result).toStrictEqual(false);\n });\n\n it(\"should reject the check in unknexpected state\", () => {\n // GIVEN\n const state = {\n sessionStateType: DeviceSessionStateType.Connected,\n deviceStatus: DeviceStatus.CONNECTED,\n installedApps: [],\n currentApp: { name: \"Bitcoin\", version: \"1.13.0-rc\" },\n deviceModelId: DeviceModelId.FLEX,\n isSecureConnectionAllowed: false,\n };\n const config = createAppConfig(\"1.13.0\");\n // WHEN\n const result = new ApplicationChecker(state, config)\n .withMinVersionExclusive(\"1.12.0\")\n .check();\n // THEN\n expect(result).toStrictEqual(false);\n });\n});\n"],
5
+ "mappings": "AAAA,OACE,iBAAAA,EACA,0BAAAC,EACA,gBAAAC,MACK,kCAIP,OAAS,sBAAAC,MAA0B,uBAEnC,SAAS,qBAAsB,IAAM,CACnC,SAASC,EAAgBC,EAA2C,CAClE,MAAO,CACL,oBAAqB,GACrB,kBAAmB,GACnB,gBAAiB,GACjB,QAAAA,CACF,CACF,CAEA,GAAG,8CAA+C,IAAM,CAEtD,MAAMC,EAAQ,CACZ,iBAAkBL,EAA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M,EAChD,wBAAwB,QAAQ,EAChC,MAAM,EAET,OAAOC,CAAM,EAAE,cAAc,EAAK,CACpC,CAAC,EAED,GAAG,gDAAiD,IAAM,CAExD,MAAMF,EAAQ,CACZ,iBAAkBL,EAAuB,UACzC,aAAcC,EAAa,UAC3B,cAAe,CAAC,EAChB,WAAY,CAAE,KAAM,UAAW,QAAS,WAAY,EACpD,cAAeF,EAAc,KAC7B,0BAA2B,EAC7B,EACMO,EAASH,EAAgB,QAAQ,EAEjCI,EAAS,IAAIL,EAAmBG,EAAOC,CAAM,EAChD,wBAAwB,QAAQ,EAChC,MAAM,EAET,OAAOC,CAAM,EAAE,cAAc,EAAK,CACpC,CAAC,CACH,CAAC",
6
+ "names": ["DeviceModelId", "DeviceSessionStateType", "DeviceStatus", "ApplicationChecker", "createAppConfig", "version", "state", "config", "result"]
7
+ }
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ledgerhq/device-signer-kit-ethereum",
3
- "version": "1.2.0",
3
+ "version": "1.3.3",
4
4
  "private": false,
5
5
  "license": "Apache-2.0",
6
6
  "exports": {
@@ -53,7 +53,7 @@
53
53
  "@ledgerhq/tsconfig-dsdk": "workspace:*",
54
54
  "@ledgerhq/vitest-config-dmk": "workspace:*",
55
55
  "@types/semver": "^7.5.8",
56
- "rxjs": "^7.8.1",
56
+ "rxjs": "^7.8.2",
57
57
  "ts-node": "^10.9.2"
58
58
  },
59
59
  "peerDependencies": {
@@ -0,0 +1,7 @@
1
+ export type GetConfigCommandResponse = {
2
+ readonly blindSigningEnabled: boolean;
3
+ readonly web3ChecksEnabled: boolean;
4
+ readonly web3ChecksOptIn: boolean;
5
+ readonly version: string;
6
+ };
7
+ //# sourceMappingURL=GetConfigCommandTypes.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"GetConfigCommandTypes.d.ts","sourceRoot":"","sources":["../../../../src/api/app-binder/GetConfigCommandTypes.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,wBAAwB,GAAG;IACrC,QAAQ,CAAC,mBAAmB,EAAE,OAAO,CAAC;IACtC,QAAQ,CAAC,iBAAiB,EAAE,OAAO,CAAC;IACpC,QAAQ,CAAC,eAAe,EAAE,OAAO,CAAC;IAClC,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;CAC1B,CAAC"}
@@ -1,5 +1,6 @@
1
- import { type ClearSignContextSuccess, type ContextModule } from "@ledgerhq/context-module";
1
+ import { type ClearSignContextSuccess, type ClearSignContextType, type ContextModule } from "@ledgerhq/context-module";
2
2
  import { type CommandErrorResult, type DeviceActionState, type ExecuteDeviceActionReturnType, type OpenAppDAError, type OpenAppDARequiredInteraction, type UserInteractionRequired } from "@ledgerhq/device-management-kit";
3
+ import { type GetConfigCommandResponse } from "../app-binder/GetConfigCommandTypes";
3
4
  import { type Signature } from "../model/Signature";
4
5
  import { type TransactionOptions } from "../model/TransactionOptions";
5
6
  import { type TransactionType } from "../model/TransactionType";
@@ -7,6 +8,15 @@ import { type EthErrorCodes } from "../../internal/app-binder/command/utils/ethA
7
8
  import { type GenericContext } from "../../internal/app-binder/task/ProvideTransactionGenericContextTask";
8
9
  import { type TransactionMapperService } from "../../internal/transaction/service/mapper/TransactionMapperService";
9
10
  import { type TransactionParserService } from "../../internal/transaction/service/parser/TransactionParserService";
11
+ export declare enum SignTransactionDAStep {
12
+ OPEN_APP = "signer.eth.steps.openApp",
13
+ GET_APP_CONFIG = "signer.eth.steps.getAppConfig",
14
+ WEB3_CHECKS_OPT_IN = "signer.eth.steps.web3ChecksOptIn",
15
+ BUILD_CONTEXT = "signer.eth.steps.buildContext",
16
+ PROVIDE_CONTEXT = "signer.eth.steps.provideContext",
17
+ PROVIDE_GENERIC_CONTEXT = "signer.eth.steps.provideGenericContext",
18
+ SIGN_TRANSACTION = "signer.eth.steps.signTransaction"
19
+ }
10
20
  export type SignTransactionDAOutput = Signature;
11
21
  export type SignTransactionDAInput = {
12
22
  readonly derivationPath: string;
@@ -17,15 +27,17 @@ export type SignTransactionDAInput = {
17
27
  readonly options: TransactionOptions;
18
28
  };
19
29
  export type SignTransactionDAError = OpenAppDAError | CommandErrorResult<EthErrorCodes>["error"];
20
- type SignTransactionDARequiredInteraction = OpenAppDARequiredInteraction | UserInteractionRequired.SignTransaction;
30
+ type SignTransactionDARequiredInteraction = OpenAppDARequiredInteraction | UserInteractionRequired.Web3ChecksOptIn | UserInteractionRequired.SignTransaction;
21
31
  export type SignTransactionDAIntermediateValue = {
22
32
  requiredUserInteraction: SignTransactionDARequiredInteraction;
33
+ step: SignTransactionDAStep;
23
34
  };
24
35
  export type SignTransactionDAState = DeviceActionState<SignTransactionDAOutput, SignTransactionDAError, SignTransactionDAIntermediateValue>;
25
36
  export type SignTransactionDAInternalState = {
26
37
  readonly error: SignTransactionDAError | null;
27
- readonly challenge: string | null;
38
+ readonly appConfig: GetConfigCommandResponse | null;
28
39
  readonly clearSignContexts: ClearSignContextSuccess[] | GenericContext | null;
40
+ readonly web3Check: ClearSignContextSuccess<ClearSignContextType.WEB3_CHECK> | null;
29
41
  readonly serializedTransaction: Uint8Array | null;
30
42
  readonly chainId: number | null;
31
43
  readonly transactionType: TransactionType | null;
@@ -1 +1 @@
1
- {"version":3,"file":"SignTransactionDeviceActionTypes.d.ts","sourceRoot":"","sources":["../../../../src/api/app-binder/SignTransactionDeviceActionTypes.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,uBAAuB,EAC5B,KAAK,aAAa,EACnB,MAAM,0BAA0B,CAAC;AAClC,OAAO,EACL,KAAK,kBAAkB,EACvB,KAAK,iBAAiB,EACtB,KAAK,6BAA6B,EAClC,KAAK,cAAc,EACnB,KAAK,4BAA4B,EACjC,KAAK,uBAAuB,EAC7B,MAAM,iCAAiC,CAAC;AAEzC,OAAO,EAAE,KAAK,SAAS,EAAE,MAAM,sBAAsB,CAAC;AACtD,OAAO,EAAE,KAAK,kBAAkB,EAAE,MAAM,+BAA+B,CAAC;AACxE,OAAO,EAAE,KAAK,eAAe,EAAE,M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AI,CAAC;IAClD,QAAQ,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI,CAAC;IAChC,QAAQ,CAAC,eAAe,EAAE,eAAe,GAAG,IAAI,CAAC;IACjD,QAAQ,CAAC,QAAQ,EAAE,OAAO,CAAC;IAC3B,QAAQ,CAAC,SAAS,EAAE,SAAS,GAAG,IAAI,CAAC;CACtC,CAAC;AAEF,MAAM,MAAM,2BAA2B,GAAG,6BAA6B,CACrE,uBAAuB,EACvB,sBAAsB,EACtB,kCAAkC,CACnC,CAAC"}
1
+ {"version":3,"file":"SignTransactionDeviceActionTypes.d.ts","sourceRoot":"","sources":["../../../../src/api/app-binder/SignTransactionDeviceActionTypes.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,uBAAuB,EAC5B,KAAK,oBAAoB,EACzB,KAAK,aAAa,EACnB,MAAM,0BAA0B,CAAC;AAClC,OAAO,EACL,KAAK,kBAAkB,EACvB,KAAK,iBAAiB,EACtB,KAAK,6BAA6B,EAClC,KAAK,cAAc,EACnB,KAAK,4BAA4B,EACjC,KAAK,uBAAuB,EAC7B,MAAM,iCAAiC,CAAC;AAEzC,OAAO,EAAE,KAAK,wBAAwB,EAAE,MAAM,uCAAuC,CAAC;AACtF,OAAO,EAAE,KAAK,SAAS,EAAE,MAAM,sBAAsB,CAAC;AACtD,OAAO,EAAE,KAAK,kBAAkB,EAAE,MAAM,+BAA+B,CAAC;AACxE,OAAO,EAAE,KAAK,eAAe,EAAE,MAAM,4BAA4B,CAAC;AAClE,OAAO,EAAE,KAAK,aAAa,EAAE,MAAM,iDAAiD,CAAC;AACrF,OAAO,EAAE,KAAK,cAAc,EAAE,MAAM,gEAAgE,CAAC;AACrG,OAAO,EAAE,KAAK,wBAAwB,EAAE,MAAM,+DAA+D,CAAC;AAC9G,OAAO,EAAE,KAAK,wBAAwB,EAAE,MAAM,+DAA+D,CAAC;AAE9G,oBAAY,qBAAqB;IAC/B,QAAQ,6BAA6B;IACrC,cAAc,kCAAkC;IA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AAU,GAAG,IAAI,CAAC;IAClD,QAAQ,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI,CAAC;IAChC,QAAQ,CAAC,eAAe,EAAE,eAAe,GAAG,IAAI,CAAC;IACjD,QAAQ,CAAC,QAAQ,EAAE,OAAO,CAAC;IAC3B,QAAQ,CAAC,SAAS,EAAE,SAAS,GAAG,IAAI,CAAC;CACtC,CAAC;AAEF,MAAM,MAAM,2BAA2B,GAAG,6BAA6B,CACrE,uBAAuB,EACvB,sBAAsB,EACtB,kCAAkC,CACnC,CAAC"}
@@ -1,10 +1,21 @@
1
1
  import { type ContextModule } from "@ledgerhq/context-module";
2
2
  import { type CommandErrorResult, type DeviceActionState, type ExecuteDeviceActionReturnType, type OpenAppDAError, type OpenAppDARequiredInteraction, type UserInteractionRequired } from "@ledgerhq/device-management-kit";
3
+ import { type GetConfigCommandResponse } from "../app-binder/GetConfigCommandTypes";
3
4
  import { type Signature } from "../model/Signature";
4
5
  import { type TypedData } from "../model/TypedData";
5
6
  import { type EthErrorCodes } from "../../internal/app-binder/command/utils/ethAppErrors";
6
7
  import type { ProvideEIP712ContextTaskArgs } from "../../internal/app-binder/task/ProvideEIP712ContextTask";
7
8
  import { type TypedDataParserService } from "../../internal/typed-data/service/TypedDataParserService";
9
+ export declare enum SignTypedDataDAStateStep {
10
+ OPEN_APP = "signer.eth.steps.openApp",
11
+ GET_APP_CONFIG = "signer.eth.steps.getAppConfig",
12
+ WEB3_CHECKS_OPT_IN = "signer.eth.steps.web3ChecksOptIn",
13
+ BUILD_CONTEXT = "signer.eth.steps.buildContext",
14
+ PROVIDE_CONTEXT = "signer.eth.steps.provideContext",
15
+ PROVIDE_GENERIC_CONTEXT = "signer.eth.steps.provideGenericContext",
16
+ SIGN_TYPED_DATA = "signer.eth.steps.signTypedData",
17
+ SIGN_TYPED_DATA_LEGACY = "signer.eth.steps.signTypedDataLegacy"
18
+ }
8
19
  export type SignTypedDataDAOutput = Signature;
9
20
  export type SignTypedDataDAInput = {
10
21
  readonly derivationPath: string;
@@ -13,13 +24,15 @@ export type SignTypedDataDAInput = {
13
24
  readonly contextModule: ContextModule;
14
25
  };
15
26
  export type SignTypedDataDAError = OpenAppDAError | CommandErrorResult<EthErrorCodes>["error"];
16
- type SignTypedDataDARequiredInteraction = OpenAppDARequiredInteraction | UserInteractionRequired.SignTypedData;
27
+ type SignTypedDataDARequiredInteraction = OpenAppDARequiredInteraction | UserInteractionRequired.Web3ChecksOptIn | UserInteractionRequired.SignTypedData;
17
28
  export type SignTypedDataDAIntermediateValue = {
18
29
  requiredUserInteraction: SignTypedDataDARequiredInteraction;
30
+ step: SignTypedDataDAStateStep;
19
31
  };
20
32
  export type SignTypedDataDAState = DeviceActionState<SignTypedDataDAOutput, SignTypedDataDAError, SignTypedDataDAIntermediateValue>;
21
33
  export type SignTypedDataDAInternalState = {
22
34
  readonly error: SignTypedDataDAError | null;
35
+ readonly appConfig: GetConfigCommandResponse | null;
23
36
  readonly typedDataContext: ProvideEIP712ContextTaskArgs | null;
24
37
  readonly signature: Signature | null;
25
38
  };
@@ -1 +1 @@
1
- {"version":3,"file":"SignTypedDataDeviceActionTypes.d.ts","sourceRoot":"","sources":["../../../../src/api/app-binder/SignTypedDataDeviceActionTypes.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,aAAa,EAAE,MAAM,0BAA0B,CAAC;AAC9D,OAAO,EACL,KAAK,kBAAkB,EACvB,KAAK,iBAAiB,EACtB,KAAK,6BAA6B,EAClC,KAAK,cAAc,EACnB,KAAK,4BAA4B,EACjC,KAAK,uBAAuB,EAC7B,MAAM,iCAAiC,CAAC;AAEzC,OAAO,EAAE,KAAK,SAAS,EAAE,MAAM,sBAAsB,CAAC;AACtD,OAAO,EAAE,KAAK,SAAS,EAAE,MAAM,sBAAsB,CAAC;AACtD,OAAO,EAAE,KAAK,aAAa,EAAE,MAAM,iDAAiD,CAAC;AACrF,OAAO,KAAK,EAAE,4BAA4B,EAAE,MAAM,oDAAoD,CAA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B,GAAG,iBAAiB,CAClD,qBAAqB,EACrB,oBAAoB,EACpB,gCAAgC,CACjC,CAAC;AAEF,MAAM,MAAM,4BAA4B,GAAG;IACzC,QAAQ,CAAC,KAAK,EAAE,oBAAoB,GAAG,IAAI,CAAC;IAC5C,QAAQ,CAAC,SAAS,EAAE,wBAAwB,GAAG,IAAI,CAAC;IACpD,QAAQ,CAAC,gBAAgB,EAAE,4BAA4B,GAAG,IAAI,CAAC;IAC/D,QAAQ,CAAC,SAAS,EAAE,SAAS,GAAG,IAAI,CAAC;CACtC,CAAC;AAEF,MAAM,MAAM,yBAAyB,GAAG,6BAA6B,CACnE,qBAAqB,EACrB,oBAAoB,EACpB,gCAAgC,CACjC,CAAC"}
@@ -1,7 +1,7 @@
1
1
  export * from "./app-binder/GetAddressDeviceActionTypes";
2
2
  export type { SignPersonalMessageDAError, SignPersonalMessageDAIntermediateValue, SignPersonalMessageDAOutput, } from "./app-binder/SignPersonalMessageDeviceActionTypes";
3
- export type { SignTransactionDAError, SignTransactionDAInput, SignTransactionDAIntermediateValue, SignTransactionDAOutput, SignTransactionDAState, } from "./app-binder/SignTransactionDeviceActionTypes";
4
- export { type SignTypedDataDAError, type SignTypedDataDAInput, type SignTypedDataDAIntermediateValue, type SignTypedDataDAOutput, type SignTypedDataDAState, } from "./app-binder/SignTypedDataDeviceActionTypes";
3
+ export { type SignTransactionDAError, type SignTransactionDAInput, type SignTransactionDAIntermediateValue, type SignTransactionDAOutput, type SignTransactionDAState, SignTransactionDAStep, } from "./app-binder/SignTransactionDeviceActionTypes";
4
+ export { type SignTypedDataDAError, type SignTypedDataDAInput, type SignTypedDataDAIntermediateValue, type SignTypedDataDAOutput, type SignTypedDataDAState, SignTypedDataDAStateStep, } from "./app-binder/SignTypedDataDeviceActionTypes";
5
5
  export * from "./model/Address";
6
6
  export * from "./model/AddressOptions";
7
7
  export * from "./model/Signature";
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/api/index.ts"],"names":[],"mappings":"AAAA,cAAc,6CAA6C,CAAC;AAC5D,YAAY,EACV,0BAA0B,EAC1B,sCAAsC,EACtC,2BAA2B,GAC5B,MAAM,sDAAsD,CAAC;AAC9D,YAAY,EACV,sBAAsB,EACtB,sBAAsB,EACtB,kCAAkC,EAClC,uBAAuB,EACvB,sBAAsB,GACvB,MAAM,kDAAkD,CAAC;AAC1D,OAAO,EACL,KAAK,oBAAoB,EACzB,KAAK,oBAAoB,EACzB,KAAK,gCAAgC,EACrC,KAAK,qBAAqB,EAC1B,KAAK,oBAAoB,GAC1B,MAAM,gDAAgD,CAAC;AACxD,cAAc,oBAAoB,CAAC;AACnC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,sBAAsB,CAAC;AACrC,cAAc,+BAA+B,CAAC;AAC9C,cAAc,4BAA4B,CAAC;AAC3C,cAAc,sBAAsB,CAAC;AACrC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,uBAAuB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/api/index.ts"],"names":[],"mappings":"AAAA,cAAc,6CAA6C,CAAC;AAC5D,YAAY,EACV,0BAA0B,EAC1B,sCAAsC,EACtC,2BAA2B,GAC5B,MAAM,sDAAsD,CAAC;AAC9D,OAAO,EACL,KAAK,sBAAsB,EAC3B,KAAK,sBAAsB,EAC3B,KAAK,kCAAkC,EACvC,KAAK,uBAAuB,EAC5B,KAAK,sBAAsB,EAC3B,qBAAqB,GACtB,MAAM,kDAAkD,CAAC;AAC1D,OAAO,EACL,KAAK,oBAAoB,EACzB,KAAK,oBAAoB,EACzB,KAAK,gCAAgC,EACrC,KAAK,qBAAqB,EAC1B,KAAK,oBAAoB,EACzB,wBAAwB,GACzB,MAAM,gDAAgD,CAAC;AACxD,cAAc,oBAAoB,CAAC;AACnC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,sBAAsB,CAAC;AACrC,cAAc,+BAA+B,CAAC;AAC9C,cAAc,4BAA4B,CAAC;AAC3C,cAAc,sBAAsB,CAAC;AACrC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,uBAAuB,CAAC"}
@@ -0,0 +1,10 @@
1
+ import { type Apdu, type ApduResponse, type Command, type CommandResult } from "@ledgerhq/device-management-kit";
2
+ import { type GetConfigCommandResponse as GetAppConfigurationCommandResponse } from "../../../api/app-binder/GetConfigCommandTypes";
3
+ import { type EthErrorCodes } from "./utils/ethAppErrors";
4
+ export declare class GetAppConfiguration implements Command<GetAppConfigurationCommandResponse, void, EthErrorCodes> {
5
+ private readonly errorHelper;
6
+ constructor();
7
+ getApdu(): Apdu;
8
+ parseResponse(response: ApduResponse): CommandResult<GetAppConfigurationCommandResponse, EthErrorCodes>;
9
+ }
10
+ //# sourceMappingURL=GetAppConfigurationCommand.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"GetAppConfigurationCommand.d.ts","sourceRoot":"","sources":["../../../../../src/internal/app-binder/command/GetAppConfigurationCommand.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,IAAI,EAIT,KAAK,YAAY,EACjB,KAAK,OAAO,EACZ,KAAK,aAAa,EAGnB,MAAM,iCAAiC,CAAC;AAIzC,OAAO,EAAE,KAAK,wBAAwB,IAAI,kCAAkC,EAAE,MAAM,uCAAuC,CAAC;AAE5H,OAAO,EAGL,KAAK,aAAa,EACnB,MAAM,sBAAsB,CAAC;AAE9B,qBAAa,mBACX,YAAW,OAAO,CAAC,kCAAkC,EAAE,IAAI,EAAE,aAAa,CAAC;IAE3E,OAAO,CAAC,QAAQ,CAAC,WAAW,CAGiB;;IAI7C,OAAO,IAAI,IAAI;IAWf,aAAa,CACX,QAAQ,EAAE,YAAY,GACrB,aAAa,CAAC,kCAAkC,EAAE,aAAa,CAAC;CAuCpE"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=GetAppConfigurationCommand.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"GetAppConfigurationCommand.test.d.ts","sourceRoot":"","sources":["../../../../../src/internal/app-binder/command/GetAppConfigurationCommand.test.ts"],"names":[],"mappings":""}