@ledgerhq/device-signer-kit-ethereum 1.8.0 → 1.9.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (231) hide show
  1. package/README.md +59 -1
  2. package/lib/cjs/api/SignerEth.js +1 -1
  3. package/lib/cjs/api/SignerEth.js.map +1 -1
  4. package/lib/cjs/api/SignerEthBuilder.test.js +1 -1
  5. package/lib/cjs/api/SignerEthBuilder.test.js.map +2 -2
  6. package/lib/cjs/api/app-binder/SignTransactionDeviceActionTypes.js +1 -1
  7. package/lib/cjs/api/app-binder/SignTransactionDeviceActionTypes.js.map +2 -2
  8. package/lib/cjs/api/app-binder/SignTypedDataDeviceActionTypes.js +1 -1
  9. package/lib/cjs/api/app-binder/SignTypedDataDeviceActionTypes.js.map +2 -2
  10. package/lib/cjs/api/app-binder/VerifySafeAddressDeviceActionTypes.js +2 -0
  11. package/lib/cjs/api/app-binder/VerifySafeAddressDeviceActionTypes.js.map +7 -0
  12. package/lib/cjs/api/model/SafeAddressOptions.js +2 -0
  13. package/lib/cjs/api/model/SafeAddressOptions.js.map +7 -0
  14. package/lib/cjs/internal/DefaultSignerEth.js +1 -1
  15. package/lib/cjs/internal/DefaultSignerEth.js.map +3 -3
  16. package/lib/cjs/internal/app-binder/EthAppBinder.js +1 -1
  17. package/lib/cjs/internal/app-binder/EthAppBinder.js.map +3 -3
  18. package/lib/cjs/internal/app-binder/EthAppBinder.test.js +1 -1
  19. package/lib/cjs/internal/app-binder/EthAppBinder.test.js.map +2 -2
  20. package/lib/cjs/internal/app-binder/command/ProvideSafeAccountCommand.js +2 -0
  21. package/lib/cjs/internal/app-binder/command/ProvideSafeAccountCommand.js.map +7 -0
  22. package/lib/cjs/internal/app-binder/command/ProvideSafeAccountCommand.test.js +2 -0
  23. package/lib/cjs/internal/app-binder/command/ProvideSafeAccountCommand.test.js.map +7 -0
  24. package/lib/cjs/internal/app-binder/device-action/SignTransaction/SignTransactionDeviceAction.js +1 -1
  25. package/lib/cjs/internal/app-binder/device-action/SignTransaction/SignTransactionDeviceAction.js.map +3 -3
  26. package/lib/cjs/internal/app-binder/device-action/SignTransaction/SignTransactionDeviceAction.test.js +1 -1
  27. package/lib/cjs/internal/app-binder/device-action/SignTransaction/SignTransactionDeviceAction.test.js.map +3 -3
  28. package/lib/cjs/internal/app-binder/device-action/SignTypedData/SignTypedDataDeviceAction.js +1 -1
  29. package/lib/cjs/internal/app-binder/device-action/SignTypedData/SignTypedDataDeviceAction.js.map +3 -3
  30. package/lib/cjs/internal/app-binder/device-action/SignTypedData/SignTypedDataDeviceAction.test.js +1 -1
  31. package/lib/cjs/internal/app-binder/device-action/SignTypedData/SignTypedDataDeviceAction.test.js.map +3 -3
  32. package/lib/cjs/internal/app-binder/device-action/VerifySafeAddress/VerifySafeAddress.js +2 -0
  33. package/lib/cjs/internal/app-binder/device-action/VerifySafeAddress/VerifySafeAddress.js.map +7 -0
  34. package/lib/cjs/internal/app-binder/device-action/VerifySafeAddress/VerifySafeAddress.test.js +2 -0
  35. package/lib/cjs/internal/app-binder/device-action/VerifySafeAddress/VerifySafeAddress.test.js.map +7 -0
  36. package/lib/cjs/internal/app-binder/task/BuildBaseContexts.js +1 -1
  37. package/lib/cjs/internal/app-binder/task/BuildBaseContexts.js.map +3 -3
  38. package/lib/cjs/internal/app-binder/task/BuildBaseContexts.test.js +1 -1
  39. package/lib/cjs/internal/app-binder/task/BuildBaseContexts.test.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/BuildSafeAddressContextTask.js +2 -0
  45. package/lib/cjs/internal/app-binder/task/BuildSafeAddressContextTask.js.map +7 -0
  46. package/lib/cjs/internal/app-binder/task/BuildSafeAddressContextTask.test.js +2 -0
  47. package/lib/cjs/internal/app-binder/task/BuildSafeAddressContextTask.test.js.map +7 -0
  48. package/lib/cjs/internal/app-binder/task/BuildSubcontextsTask.js +1 -1
  49. package/lib/cjs/internal/app-binder/task/BuildSubcontextsTask.js.map +2 -2
  50. package/lib/cjs/internal/app-binder/task/BuildSubcontextsTask.test.js +1 -1
  51. package/lib/cjs/internal/app-binder/task/BuildSubcontextsTask.test.js.map +2 -2
  52. package/lib/cjs/internal/app-binder/task/ProvideContextTask.js +2 -0
  53. package/lib/cjs/internal/app-binder/task/ProvideContextTask.js.map +7 -0
  54. package/lib/cjs/internal/app-binder/task/ProvideContextTask.test.js +2 -0
  55. package/lib/cjs/internal/app-binder/task/ProvideContextTask.test.js.map +7 -0
  56. package/lib/cjs/internal/app-binder/task/ProvideEIP712ContextTask.js +1 -1
  57. package/lib/cjs/internal/app-binder/task/ProvideEIP712ContextTask.js.map +3 -3
  58. package/lib/cjs/internal/app-binder/task/ProvideEIP712ContextTask.test.js +1 -1
  59. package/lib/cjs/internal/app-binder/task/ProvideEIP712ContextTask.test.js.map +3 -3
  60. package/lib/cjs/internal/app-binder/task/ProvideTransactionContextsTask.js +2 -0
  61. package/lib/cjs/internal/app-binder/task/ProvideTransactionContextsTask.js.map +7 -0
  62. package/lib/cjs/internal/app-binder/task/ProvideTransactionContextsTask.test.js +2 -0
  63. package/lib/cjs/internal/app-binder/task/ProvideTransactionContextsTask.test.js.map +7 -0
  64. package/lib/cjs/internal/di.js +1 -1
  65. package/lib/cjs/internal/di.js.map +3 -3
  66. package/lib/cjs/internal/safe/di/safeModule.js +2 -0
  67. package/lib/cjs/internal/safe/di/safeModule.js.map +7 -0
  68. package/lib/cjs/internal/safe/di/safeModule.test.js +2 -0
  69. package/lib/cjs/internal/safe/di/safeModule.test.js.map +7 -0
  70. package/lib/cjs/internal/safe/di/safeTypes.js +2 -0
  71. package/lib/cjs/internal/safe/di/safeTypes.js.map +7 -0
  72. package/lib/cjs/internal/safe/use-case/VerifySafeAddressUseCase.js +2 -0
  73. package/lib/cjs/internal/safe/use-case/VerifySafeAddressUseCase.js.map +7 -0
  74. package/lib/cjs/internal/safe/use-case/VerifySafeAddressUseCase.test.js +2 -0
  75. package/lib/cjs/internal/safe/use-case/VerifySafeAddressUseCase.test.js.map +7 -0
  76. package/lib/cjs/package.json +2 -2
  77. package/lib/esm/api/SignerEthBuilder.test.js +1 -1
  78. package/lib/esm/api/SignerEthBuilder.test.js.map +2 -2
  79. package/lib/esm/api/app-binder/SignTransactionDeviceActionTypes.js +1 -1
  80. package/lib/esm/api/app-binder/SignTransactionDeviceActionTypes.js.map +2 -2
  81. package/lib/esm/api/app-binder/SignTypedDataDeviceActionTypes.js +1 -1
  82. package/lib/esm/api/app-binder/SignTypedDataDeviceActionTypes.js.map +2 -2
  83. package/lib/esm/api/app-binder/VerifySafeAddressDeviceActionTypes.js +2 -0
  84. package/lib/esm/api/app-binder/VerifySafeAddressDeviceActionTypes.js.map +7 -0
  85. package/lib/esm/api/model/SafeAddressOptions.js +1 -0
  86. package/lib/esm/api/model/SafeAddressOptions.js.map +7 -0
  87. package/lib/esm/internal/DefaultSignerEth.js +1 -1
  88. package/lib/esm/internal/DefaultSignerEth.js.map +3 -3
  89. package/lib/esm/internal/app-binder/EthAppBinder.js +1 -1
  90. package/lib/esm/internal/app-binder/EthAppBinder.js.map +3 -3
  91. package/lib/esm/internal/app-binder/EthAppBinder.test.js +1 -1
  92. package/lib/esm/internal/app-binder/EthAppBinder.test.js.map +2 -2
  93. package/lib/esm/internal/app-binder/command/ProvideSafeAccountCommand.js +2 -0
  94. package/lib/esm/internal/app-binder/command/ProvideSafeAccountCommand.js.map +7 -0
  95. package/lib/esm/internal/app-binder/command/ProvideSafeAccountCommand.test.js +2 -0
  96. package/lib/esm/internal/app-binder/command/ProvideSafeAccountCommand.test.js.map +7 -0
  97. package/lib/esm/internal/app-binder/device-action/SignTransaction/SignTransactionDeviceAction.js +1 -1
  98. package/lib/esm/internal/app-binder/device-action/SignTransaction/SignTransactionDeviceAction.js.map +3 -3
  99. package/lib/esm/internal/app-binder/device-action/SignTransaction/SignTransactionDeviceAction.test.js +1 -1
  100. package/lib/esm/internal/app-binder/device-action/SignTransaction/SignTransactionDeviceAction.test.js.map +3 -3
  101. package/lib/esm/internal/app-binder/device-action/SignTypedData/SignTypedDataDeviceAction.js +1 -1
  102. package/lib/esm/internal/app-binder/device-action/SignTypedData/SignTypedDataDeviceAction.js.map +3 -3
  103. package/lib/esm/internal/app-binder/device-action/SignTypedData/SignTypedDataDeviceAction.test.js +1 -1
  104. package/lib/esm/internal/app-binder/device-action/SignTypedData/SignTypedDataDeviceAction.test.js.map +3 -3
  105. package/lib/esm/internal/app-binder/device-action/VerifySafeAddress/VerifySafeAddress.js +2 -0
  106. package/lib/esm/internal/app-binder/device-action/VerifySafeAddress/VerifySafeAddress.js.map +7 -0
  107. package/lib/esm/internal/app-binder/device-action/VerifySafeAddress/VerifySafeAddress.test.js +2 -0
  108. package/lib/esm/internal/app-binder/device-action/VerifySafeAddress/VerifySafeAddress.test.js.map +7 -0
  109. package/lib/esm/internal/app-binder/task/BuildBaseContexts.js +1 -1
  110. package/lib/esm/internal/app-binder/task/BuildBaseContexts.js.map +3 -3
  111. package/lib/esm/internal/app-binder/task/BuildBaseContexts.test.js +1 -1
  112. package/lib/esm/internal/app-binder/task/BuildBaseContexts.test.js.map +3 -3
  113. package/lib/esm/internal/app-binder/task/BuildEIP712ContextTask.js +1 -1
  114. package/lib/esm/internal/app-binder/task/BuildEIP712ContextTask.js.map +3 -3
  115. package/lib/esm/internal/app-binder/task/BuildEIP712ContextTask.test.js +1 -1
  116. package/lib/esm/internal/app-binder/task/BuildEIP712ContextTask.test.js.map +3 -3
  117. package/lib/esm/internal/app-binder/task/BuildSafeAddressContextTask.js +2 -0
  118. package/lib/esm/internal/app-binder/task/BuildSafeAddressContextTask.js.map +7 -0
  119. package/lib/esm/internal/app-binder/task/BuildSafeAddressContextTask.test.js +2 -0
  120. package/lib/esm/internal/app-binder/task/BuildSafeAddressContextTask.test.js.map +7 -0
  121. package/lib/esm/internal/app-binder/task/BuildSubcontextsTask.js +1 -1
  122. package/lib/esm/internal/app-binder/task/BuildSubcontextsTask.js.map +2 -2
  123. package/lib/esm/internal/app-binder/task/BuildSubcontextsTask.test.js +1 -1
  124. package/lib/esm/internal/app-binder/task/BuildSubcontextsTask.test.js.map +2 -2
  125. package/lib/esm/internal/app-binder/task/ProvideContextTask.js +2 -0
  126. package/lib/esm/internal/app-binder/task/ProvideContextTask.js.map +7 -0
  127. package/lib/esm/internal/app-binder/task/ProvideContextTask.test.js +2 -0
  128. package/lib/esm/internal/app-binder/task/ProvideContextTask.test.js.map +7 -0
  129. package/lib/esm/internal/app-binder/task/ProvideEIP712ContextTask.js +1 -1
  130. package/lib/esm/internal/app-binder/task/ProvideEIP712ContextTask.js.map +3 -3
  131. package/lib/esm/internal/app-binder/task/ProvideEIP712ContextTask.test.js +1 -1
  132. package/lib/esm/internal/app-binder/task/ProvideEIP712ContextTask.test.js.map +3 -3
  133. package/lib/esm/internal/app-binder/task/ProvideTransactionContextsTask.js +2 -0
  134. package/lib/esm/internal/app-binder/task/ProvideTransactionContextsTask.js.map +7 -0
  135. package/lib/esm/internal/app-binder/task/ProvideTransactionContextsTask.test.js +2 -0
  136. package/lib/esm/internal/app-binder/task/ProvideTransactionContextsTask.test.js.map +7 -0
  137. package/lib/esm/internal/di.js +1 -1
  138. package/lib/esm/internal/di.js.map +3 -3
  139. package/lib/esm/internal/safe/di/safeModule.js +2 -0
  140. package/lib/esm/internal/safe/di/safeModule.js.map +7 -0
  141. package/lib/esm/internal/safe/di/safeModule.test.js +2 -0
  142. package/lib/esm/internal/safe/di/safeModule.test.js.map +7 -0
  143. package/lib/esm/internal/safe/di/safeTypes.js +2 -0
  144. package/lib/esm/internal/safe/di/safeTypes.js.map +7 -0
  145. package/lib/esm/internal/safe/use-case/VerifySafeAddressUseCase.js +2 -0
  146. package/lib/esm/internal/safe/use-case/VerifySafeAddressUseCase.js.map +7 -0
  147. package/lib/esm/internal/safe/use-case/VerifySafeAddressUseCase.test.js +2 -0
  148. package/lib/esm/internal/safe/use-case/VerifySafeAddressUseCase.test.js.map +7 -0
  149. package/lib/esm/package.json +2 -2
  150. package/lib/types/api/SignerEth.d.ts +3 -0
  151. package/lib/types/api/SignerEth.d.ts.map +1 -1
  152. package/lib/types/api/app-binder/SignTransactionDeviceActionTypes.d.ts +1 -0
  153. package/lib/types/api/app-binder/SignTransactionDeviceActionTypes.d.ts.map +1 -1
  154. package/lib/types/api/app-binder/SignTypedDataDeviceActionTypes.d.ts +2 -0
  155. package/lib/types/api/app-binder/SignTypedDataDeviceActionTypes.d.ts.map +1 -1
  156. package/lib/types/api/app-binder/VerifySafeAddressDeviceActionTypes.d.ts +30 -0
  157. package/lib/types/api/app-binder/VerifySafeAddressDeviceActionTypes.d.ts.map +1 -0
  158. package/lib/types/api/model/SafeAddressOptions.d.ts +5 -0
  159. package/lib/types/api/model/SafeAddressOptions.d.ts.map +1 -0
  160. package/lib/types/internal/DefaultSignerEth.d.ts +3 -0
  161. package/lib/types/internal/DefaultSignerEth.d.ts.map +1 -1
  162. package/lib/types/internal/app-binder/EthAppBinder.d.ts +6 -0
  163. package/lib/types/internal/app-binder/EthAppBinder.d.ts.map +1 -1
  164. package/lib/types/internal/app-binder/command/ProvideSafeAccountCommand.d.ts +34 -0
  165. package/lib/types/internal/app-binder/command/ProvideSafeAccountCommand.d.ts.map +1 -0
  166. package/lib/types/internal/app-binder/command/ProvideSafeAccountCommand.test.d.ts +2 -0
  167. package/lib/types/internal/app-binder/command/ProvideSafeAccountCommand.test.d.ts.map +1 -0
  168. package/lib/types/internal/app-binder/device-action/SignTransaction/SignTransactionDeviceAction.d.ts +7 -3
  169. package/lib/types/internal/app-binder/device-action/SignTransaction/SignTransactionDeviceAction.d.ts.map +1 -1
  170. package/lib/types/internal/app-binder/device-action/SignTypedData/SignTypedDataDeviceAction.d.ts +5 -0
  171. package/lib/types/internal/app-binder/device-action/SignTypedData/SignTypedDataDeviceAction.d.ts.map +1 -1
  172. package/lib/types/internal/app-binder/device-action/VerifySafeAddress/VerifySafeAddress.d.ts +20 -0
  173. package/lib/types/internal/app-binder/device-action/VerifySafeAddress/VerifySafeAddress.d.ts.map +1 -0
  174. package/lib/types/internal/app-binder/device-action/VerifySafeAddress/VerifySafeAddress.test.d.ts +2 -0
  175. package/lib/types/internal/app-binder/device-action/VerifySafeAddress/VerifySafeAddress.test.d.ts.map +1 -0
  176. package/lib/types/internal/app-binder/task/BuildBaseContexts.d.ts +4 -6
  177. package/lib/types/internal/app-binder/task/BuildBaseContexts.d.ts.map +1 -1
  178. package/lib/types/internal/app-binder/task/BuildEIP712ContextTask.d.ts +3 -3
  179. package/lib/types/internal/app-binder/task/BuildEIP712ContextTask.d.ts.map +1 -1
  180. package/lib/types/internal/app-binder/task/BuildSafeAddressContextTask.d.ts +19 -0
  181. package/lib/types/internal/app-binder/task/BuildSafeAddressContextTask.d.ts.map +1 -0
  182. package/lib/types/internal/app-binder/task/BuildSafeAddressContextTask.test.d.ts +2 -0
  183. package/lib/types/internal/app-binder/task/BuildSafeAddressContextTask.test.d.ts.map +1 -0
  184. package/lib/types/internal/app-binder/task/BuildSubcontextsTask.d.ts.map +1 -1
  185. package/lib/types/internal/app-binder/task/ProvideContextTask.d.ts +22 -0
  186. package/lib/types/internal/app-binder/task/ProvideContextTask.d.ts.map +1 -0
  187. package/lib/types/internal/app-binder/task/ProvideContextTask.test.d.ts +2 -0
  188. package/lib/types/internal/app-binder/task/ProvideContextTask.test.d.ts.map +1 -0
  189. package/lib/types/internal/app-binder/task/ProvideEIP712ContextTask.d.ts +4 -4
  190. package/lib/types/internal/app-binder/task/ProvideEIP712ContextTask.d.ts.map +1 -1
  191. package/lib/types/internal/app-binder/task/ProvideTransactionContextsTask.d.ts +36 -0
  192. package/lib/types/internal/app-binder/task/ProvideTransactionContextsTask.d.ts.map +1 -0
  193. package/lib/types/internal/app-binder/task/ProvideTransactionContextsTask.test.d.ts +2 -0
  194. package/lib/types/internal/app-binder/task/ProvideTransactionContextsTask.test.d.ts.map +1 -0
  195. package/lib/types/internal/di.d.ts.map +1 -1
  196. package/lib/types/internal/safe/di/safeModule.d.ts +3 -0
  197. package/lib/types/internal/safe/di/safeModule.d.ts.map +1 -0
  198. package/lib/types/internal/safe/di/safeModule.test.d.ts +2 -0
  199. package/lib/types/internal/safe/di/safeModule.test.d.ts.map +1 -0
  200. package/lib/types/internal/safe/di/safeTypes.d.ts +4 -0
  201. package/lib/types/internal/safe/di/safeTypes.d.ts.map +1 -0
  202. package/lib/types/internal/safe/use-case/VerifySafeAddressUseCase.d.ts +9 -0
  203. package/lib/types/internal/safe/use-case/VerifySafeAddressUseCase.d.ts.map +1 -0
  204. package/lib/types/internal/safe/use-case/VerifySafeAddressUseCase.test.d.ts +2 -0
  205. package/lib/types/internal/safe/use-case/VerifySafeAddressUseCase.test.d.ts.map +1 -0
  206. package/lib/types/tsconfig.prod.tsbuildinfo +1 -1
  207. package/package.json +5 -5
  208. package/lib/cjs/internal/app-binder/task/GetWeb3CheckTask.js +0 -2
  209. package/lib/cjs/internal/app-binder/task/GetWeb3CheckTask.js.map +0 -7
  210. package/lib/cjs/internal/app-binder/task/GetWeb3CheckTask.test.js +0 -2
  211. package/lib/cjs/internal/app-binder/task/GetWeb3CheckTask.test.js.map +0 -7
  212. package/lib/cjs/internal/app-binder/task/ProvideContextsTask.js +0 -2
  213. package/lib/cjs/internal/app-binder/task/ProvideContextsTask.js.map +0 -7
  214. package/lib/cjs/internal/app-binder/task/ProvideContextsTask.test.js +0 -2
  215. package/lib/cjs/internal/app-binder/task/ProvideContextsTask.test.js.map +0 -7
  216. package/lib/esm/internal/app-binder/task/GetWeb3CheckTask.js +0 -2
  217. package/lib/esm/internal/app-binder/task/GetWeb3CheckTask.js.map +0 -7
  218. package/lib/esm/internal/app-binder/task/GetWeb3CheckTask.test.js +0 -2
  219. package/lib/esm/internal/app-binder/task/GetWeb3CheckTask.test.js.map +0 -7
  220. package/lib/esm/internal/app-binder/task/ProvideContextsTask.js +0 -2
  221. package/lib/esm/internal/app-binder/task/ProvideContextsTask.js.map +0 -7
  222. package/lib/esm/internal/app-binder/task/ProvideContextsTask.test.js +0 -2
  223. package/lib/esm/internal/app-binder/task/ProvideContextsTask.test.js.map +0 -7
  224. package/lib/types/internal/app-binder/task/GetWeb3CheckTask.d.ts +0 -29
  225. package/lib/types/internal/app-binder/task/GetWeb3CheckTask.d.ts.map +0 -1
  226. package/lib/types/internal/app-binder/task/GetWeb3CheckTask.test.d.ts +0 -2
  227. package/lib/types/internal/app-binder/task/GetWeb3CheckTask.test.d.ts.map +0 -1
  228. package/lib/types/internal/app-binder/task/ProvideContextsTask.d.ts +0 -44
  229. package/lib/types/internal/app-binder/task/ProvideContextsTask.d.ts.map +0 -1
  230. package/lib/types/internal/app-binder/task/ProvideContextsTask.test.d.ts +0 -2
  231. package/lib/types/internal/app-binder/task/ProvideContextsTask.test.d.ts.map +0 -1
@@ -1,2 +1,2 @@
1
- "use strict";var n=require("@ledgerhq/context-module"),t=require("@ledgerhq/device-management-kit"),S=require("ethers"),d=require("../../../api/model/ClearSigningType"),y=require("../../app-binder/device-action/__test-utils__/makeInternalApi"),s=require("./BuildBaseContexts"),g=require("./GetWeb3CheckTask");describe("BuildBaseContexts",()=>{const l={getFieldContext:vi.fn(),getContexts:vi.fn(),getTypedDataFilters:vi.fn(),getWeb3Checks:vi.fn(),getSolanaContext:vi.fn()},x={domain:"domain-name.eth"},C=(0,t.hexaStringToBuffer)(S.Transaction.from({chainId:1n,nonce:0,data:"0x"}).unsignedSerialized),r={keyUsageNumber:1,payload:new Uint8Array([1,2,3])};let c;const a=(0,y.makeDeviceActionInternalApiMock)(),i=vi.fn();function u(e){return{blindSigningEnabled:!1,web3ChecksEnabled:e,web3ChecksOptIn:!1,version:"1.13.0"}}beforeEach(()=>{vi.resetAllMocks(),a.sendCommand.mockResolvedValue((0,t.CommandResultFactory)({data:{challenge:"challenge"}})),i.mockReturnValue({run:async()=>Promise.resolve({web3Check:null})}),c={contextModule:l,subset:{chainId:1,to:void 0,data:"0x",selector:"0x"},transaction:C,options:x,appConfig:u(!1),derivationPath:"44'/60'/0'/0/0"}}),it("should init with a default GetWeb3CheckTaskFactory",()=>{const e=new s.BuildBaseContexts(a,c);expect(e.getWeb3ChecksFactory).toBeDefined(),expect(e.getWeb3ChecksFactory(a,{contextModule:c.contextModule,derivationPath:c.derivationPath,subset:c.subset,transaction:c.transaction})).toBeInstanceOf(g.GetWeb3CheckTask)}),it("should build the transaction context without clear sign contexts",async()=>{const e=[],o=[];l.getContexts.mockResolvedValueOnce(e),a.getDeviceSessionState.mockReturnValueOnce({sessionStateType:t.DeviceSessionStateType.ReadyWithoutSecureChannel,deviceStatus:t.DeviceStatus.CONNECTED,installedApps:[],currentApp:{name:"Ethereum",version:"1.12.0"},deviceModelId:t.DeviceModelId.FLEX,isSecureConnectionAllowed:!1});const p=await new s.BuildBaseContexts(a,{...c,appConfig:u(!0)},i).run();expect(p).toEqual({clearSignContexts:e,clearSignContextsOptional:o,clearSigningType:d.ClearSigningType.BASIC})}),it("should build the transaction context with web3checks",async()=>{const e=[],o=[],p={type:n.ClearSignContextType.WEB3_CHECK,payload:"web3Check"};i.mockReturnValueOnce({run:async()=>Promise.resolve({web3Check:p})}),l.getContexts.mockResolvedValueOnce([...e]),a.getDeviceSessionState.mockReturnValueOnce({sessionStateType:t.DeviceSessionStateType.ReadyWithoutSecureChannel,deviceStatus:t.DeviceStatus.CONNECTED,installedApps:[],currentApp:{name:"Ethereum",version:"1.12.0"},deviceModelId:t.DeviceModelId.FLEX,isSecureConnectionAllowed:!1});const E=await new s.BuildBaseContexts(a,{...c,appConfig:u(!0)},i).run();expect(E).toEqual({clearSignContexts:[p,...e],clearSignContextsOptional:o,clearSigningType:d.ClearSigningType.BASIC})}),it("should build the transaction context with web3checks and generic-parser clear sign contexts",async()=>{const e=[{type:n.ClearSignContextType.TRANSACTION_INFO,payload:"payload-1",certificate:r},{type:n.ClearSignContextType.TRANSACTION_FIELD_DESCRIPTION,payload:"payload-2"},{type:n.ClearSignContextType.ENUM,payload:"payload-3",id:1,value:2,certificate:r},{type:n.ClearSignContextType.TRANSACTION_FIELD_DESCRIPTION,payload:"payload-4"}],o={type:n.ClearSignContextType.WEB3_CHECK,payload:"web3Check"};i.mockReturnValueOnce({run:async()=>Promise.resolve({web3Check:o})}),l.getContexts.mockResolvedValueOnce([...e]),a.getDeviceSessionState.mockReturnValueOnce({sessionStateType:t.DeviceSessionStateType.ReadyWithoutSecureChannel,deviceStatus:t.DeviceStatus.CONNECTED,installedApps:[],currentApp:{name:"Ethereum",version:"1.15.0"},deviceModelId:t.DeviceModelId.FLEX,isSecureConnectionAllowed:!1});const p=await new s.BuildBaseContexts(a,{...c,appConfig:u(!0)},i).run();expect(p).toEqual({clearSignContexts:[o,e[0],e[1],e[3]],clearSignContextsOptional:[e[2]],clearSigningType:d.ClearSigningType.EIP7730})}),it("should build the transaction context with web3checks and generic-parser clear sign contexts in the correct order",async()=>{const e=[{type:n.ClearSignContextType.ENUM,payload:"payload-3",id:1,value:2,certificate:r},{type:n.ClearSignContextType.TRANSACTION_FIELD_DESCRIPTION,payload:"payload-4"},{type:n.ClearSignContextType.TRANSACTION_FIELD_DESCRIPTION,payload:"payload-2"},{type:n.ClearSignContextType.TRANSACTION_INFO,payload:"payload-1",certificate:r}],o={type:n.ClearSignContextType.WEB3_CHECK,payload:"web3Check"};i.mockReturnValueOnce({run:async()=>Promise.resolve({web3Check:o})}),l.getContexts.mockResolvedValueOnce([...e]),a.getDeviceSessionState.mockReturnValueOnce({sessionStateType:t.DeviceSessionStateType.ReadyWithoutSecureChannel,deviceStatus:t.DeviceStatus.CONNECTED,installedApps:[],currentApp:{name:"Ethereum",version:"1.15.0"},deviceModelId:t.DeviceModelId.FLEX,isSecureConnectionAllowed:!1});const p=await new s.BuildBaseContexts(a,{...c,appConfig:u(!0)},i).run();expect(p).toEqual({clearSignContexts:[o,e[3],e[1],e[2]],clearSignContextsOptional:[e[0]],clearSigningType:d.ClearSigningType.EIP7730})}),it("should build the transaction context with clear sign contexts",async()=>{const e=[{type:n.ClearSignContextType.TOKEN,payload:"payload-1"},{type:n.ClearSignContextType.NFT,payload:"payload-2"}],o={type:n.ClearSignContextType.WEB3_CHECK,payload:"web3Check"};i.mockReturnValueOnce({run:async()=>Promise.resolve({web3Check:o})}),l.getContexts.mockResolvedValueOnce(e),a.getDeviceSessionState.mockReturnValueOnce({sessionStateType:t.DeviceSessionStateType.ReadyWithoutSecureChannel,deviceStatus:t.DeviceStatus.CONNECTED,installedApps:[],currentApp:{name:"Ethereum",version:"1.12.0"},deviceModelId:t.DeviceModelId.FLEX,isSecureConnectionAllowed:!1});const p=await new s.BuildBaseContexts(a,c,i).run();expect(p).toEqual({clearSignContexts:e,clearSignContextsOptional:[],clearSigningType:d.ClearSigningType.BASIC})}),it("should build the transaction context with generic-parser context",async()=>{const e=[{type:n.ClearSignContextType.TRANSACTION_INFO,payload:"payload-1",certificate:r},{type:n.ClearSignContextType.TRANSACTION_FIELD_DESCRIPTION,payload:"payload-2"},{type:n.ClearSignContextType.ENUM,payload:"payload-3",id:1,value:2,certificate:r},{type:n.ClearSignContextType.TRANSACTION_FIELD_DESCRIPTION,payload:"payload-4"}];l.getContexts.mockResolvedValueOnce(e),a.getDeviceSessionState.mockReturnValueOnce({sessionStateType:t.DeviceSessionStateType.ReadyWithoutSecureChannel,deviceStatus:t.DeviceStatus.CONNECTED,installedApps:[],currentApp:{name:"Ethereum",version:"1.15.0"},deviceModelId:t.DeviceModelId.FLEX,isSecureConnectionAllowed:!1});const o=await new s.BuildBaseContexts(a,c,i).run();expect(o).toEqual({clearSignContexts:[e[0],e[1],e[3]],clearSignContextsOptional:[e[2]],clearSigningType:d.ClearSigningType.EIP7730})}),it("should build the transaction context with proxy delegate call context",async()=>{const e=[{type:n.ClearSignContextType.TRANSACTION_INFO,payload:"payload-1",certificate:r},{type:n.ClearSignContextType.PROXY_INFO,payload:"payload-2"}],o=[];l.getContexts.mockResolvedValueOnce(e),a.getDeviceSessionState.mockReturnValueOnce({sessionStateType:t.DeviceSessionStateType.ReadyWithoutSecureChannel,deviceStatus:t.DeviceStatus.CONNECTED,installedApps:[],currentApp:{name:"Ethereum",version:"1.15.0"},deviceModelId:t.DeviceModelId.FLEX,isSecureConnectionAllowed:!1});const p=await new s.BuildBaseContexts(a,c,i).run();expect(p).toEqual({clearSignContexts:[e[1],e[0]],clearSignContextsOptional:o,clearSigningType:d.ClearSigningType.EIP7730})}),it("should call the web3checks factory with correct parameters",async()=>{const e=[];l.getContexts.mockResolvedValueOnce(e),a.getDeviceSessionState.mockReturnValueOnce({sessionStateType:t.DeviceSessionStateType.ReadyWithoutSecureChannel,deviceStatus:t.DeviceStatus.CONNECTED,installedApps:[],currentApp:{name:"Ethereum",version:"1.12.0"},deviceModelId:t.DeviceModelId.FLEX,isSecureConnectionAllowed:!1}),await new s.BuildBaseContexts(a,{...c,appConfig:u(!0)},i).run(),expect(i).toHaveBeenCalledWith(a,{contextModule:l,derivationPath:"44'/60'/0'/0/0",subset:c.subset,transaction:C})}),it("should call the context module with the correct parameters",async()=>{const e=[];l.getContexts.mockResolvedValueOnce(e),a.getDeviceSessionState.mockReturnValueOnce({sessionStateType:t.DeviceSessionStateType.ReadyWithoutSecureChannel,deviceStatus:t.DeviceStatus.CONNECTED,installedApps:[],currentApp:{name:"Ethereum",version:"1.12.0"},deviceModelId:t.DeviceModelId.FLEX,isSecureConnectionAllowed:!1}),await new s.BuildBaseContexts(a,c,i).run(),expect(l.getContexts).toHaveBeenCalledWith({deviceModelId:t.DeviceModelId.FLEX,challenge:"challenge",domain:"domain-name.eth",...c.subset},void 0)}),it("should call the context module without challenge for Nano S",async()=>{const e=[];l.getContexts.mockResolvedValueOnce(e),a.getDeviceSessionState.mockReturnValueOnce({sessionStateType:t.DeviceSessionStateType.ReadyWithoutSecureChannel,deviceStatus:t.DeviceStatus.CONNECTED,installedApps:[],currentApp:{name:"Ethereum",version:"1.12.0"},deviceModelId:t.DeviceModelId.NANO_S,isSecureConnectionAllowed:!1}),await new s.BuildBaseContexts(a,c,i).run(),expect(l.getContexts).toHaveBeenCalledWith({deviceModelId:t.DeviceModelId.NANO_S,domain:"domain-name.eth",...c.subset},void 0)}),it("should call the context module without context on error",async()=>{const e=[];l.getContexts.mockResolvedValueOnce(e),a.getDeviceSessionState.mockReturnValueOnce({sessionStateType:t.DeviceSessionStateType.ReadyWithoutSecureChannel,deviceStatus:t.DeviceStatus.CONNECTED,installedApps:[],currentApp:{name:"Ethereum",version:"1.12.0"},deviceModelId:t.DeviceModelId.FLEX,isSecureConnectionAllowed:!1}),a.sendCommand.mockResolvedValueOnce((0,t.CommandResultFactory)({error:new t.UnknownDeviceExchangeError})),await new s.BuildBaseContexts(a,c,i).run(),expect(l.getContexts).toHaveBeenCalledWith({deviceModelId:t.DeviceModelId.FLEX,challenge:void 0,domain:"domain-name.eth",...c.subset},void 0)}),it("should exclude error contexts from the result",async()=>{const e=[{type:n.ClearSignContextType.ERROR,error:new Error("error")},{type:n.ClearSignContextType.TOKEN,payload:"payload-1"},{type:n.ClearSignContextType.ERROR,error:new Error("error")},{type:n.ClearSignContextType.NFT,payload:"payload-2"}];l.getContexts.mockResolvedValueOnce(e),a.getDeviceSessionState.mockReturnValueOnce({sessionStateType:t.DeviceSessionStateType.ReadyWithoutSecureChannel,deviceStatus:t.DeviceStatus.CONNECTED,installedApps:[],currentApp:{name:"Ethereum",version:"1.12.0"},deviceModelId:t.DeviceModelId.FLEX,isSecureConnectionAllowed:!1});const o=await new s.BuildBaseContexts(a,c,i).run();expect(o).toEqual({clearSignContexts:[e[1],e[3]],clearSignContextsOptional:[],clearSigningType:d.ClearSigningType.BASIC})}),it("should exclude generic-parser contexts from the result on old apps",async()=>{const e=[{type:n.ClearSignContextType.TRANSACTION_INFO,payload:"transaction_info",certificate:r},{type:n.ClearSignContextType.TOKEN,payload:"payload-1"},{type:n.ClearSignContextType.TRANSACTION_FIELD_DESCRIPTION,payload:"transaction_field"},{type:n.ClearSignContextType.NFT,payload:"payload-2"},{type:n.ClearSignContextType.ENUM,payload:"enum",id:1,value:2,certificate:r}];l.getContexts.mockResolvedValueOnce(e),a.getDeviceSessionState.mockReturnValueOnce({sessionStateType:t.DeviceSessionStateType.ReadyWithoutSecureChannel,deviceStatus:t.DeviceStatus.CONNECTED,installedApps:[],currentApp:{name:"Ethereum",version:"1.12.0"},deviceModelId:t.DeviceModelId.FLEX,isSecureConnectionAllowed:!1});const o=await new s.BuildBaseContexts(a,c,i).run();expect(o).toEqual({clearSignContexts:[e[1],e[3]],clearSignContextsOptional:[],clearSigningType:d.ClearSigningType.BASIC})}),it("should exclude generic-parser contexts from the result if no transaction_info was found",async()=>{const e=[{type:n.ClearSignContextType.TRANSACTION_FIELD_DESCRIPTION,payload:"transaction_field"},{type:n.ClearSignContextType.TOKEN,payload:"payload-1"},{type:n.ClearSignContextType.ENUM,payload:"enum",id:1,value:2},{type:n.ClearSignContextType.NFT,payload:"payload-2"}];l.getContexts.mockResolvedValueOnce(e),a.getDeviceSessionState.mockReturnValueOnce({sessionStateType:t.DeviceSessionStateType.ReadyWithoutSecureChannel,deviceStatus:t.DeviceStatus.CONNECTED,installedApps:[],currentApp:{name:"Ethereum",version:"1.14.0"},deviceModelId:t.DeviceModelId.FLEX,isSecureConnectionAllowed:!1});const o=await new s.BuildBaseContexts(a,c,i).run();expect(o).toEqual({clearSignContexts:[e[1],e[3]],clearSignContextsOptional:[],clearSigningType:d.ClearSigningType.BASIC})}),it("should exclude legacy contexts from the result for generic-parser transactions",async()=>{const e=[{type:n.ClearSignContextType.TOKEN,payload:"payload-1"},{type:n.ClearSignContextType.TRANSACTION_INFO,payload:"payload-2",certificate:r},{type:n.ClearSignContextType.EXTERNAL_PLUGIN,payload:"payload-3"},{type:n.ClearSignContextType.TRANSACTION_FIELD_DESCRIPTION,payload:"payload-4"},{type:n.ClearSignContextType.ENUM,payload:"payload-5",id:1,value:2,certificate:r}];l.getContexts.mockResolvedValueOnce(e),a.getDeviceSessionState.mockReturnValueOnce({sessionStateType:t.DeviceSessionStateType.ReadyWithoutSecureChannel,deviceStatus:t.DeviceStatus.CONNECTED,installedApps:[],currentApp:{name:"Ethereum",version:"1.15.0"},deviceModelId:t.DeviceModelId.FLEX,isSecureConnectionAllowed:!1});const o=await new s.BuildBaseContexts(a,c,i).run();expect(o).toEqual({clearSignContexts:[e[1],e[3]],clearSignContextsOptional:[e[4]],clearSigningType:d.ClearSigningType.EIP7730})}),it("should exclude generic-parser contexts with a nano s device",async()=>{const e=[{type:n.ClearSignContextType.TOKEN,payload:"payload-1"},{type:n.ClearSignContextType.TRANSACTION_INFO,payload:"payload-2",certificate:r},{type:n.ClearSignContextType.TRANSACTION_FIELD_DESCRIPTION,payload:"payload-3"},{type:n.ClearSignContextType.ENUM,payload:"payload-4",id:1,value:2,certificate:r}];l.getContexts.mockResolvedValueOnce(e),a.getDeviceSessionState.mockReturnValueOnce({sessionStateType:t.DeviceSessionStateType.ReadyWithoutSecureChannel,deviceStatus:t.DeviceStatus.CONNECTED,installedApps:[],currentApp:{name:"Ethereum",version:"1.14.0"},deviceModelId:t.DeviceModelId.NANO_S,isSecureConnectionAllowed:!1});const o=await new s.BuildBaseContexts(a,c,i).run();expect(o).toEqual({clearSignContexts:[e[0]],clearSignContextsOptional:[],clearSigningType:d.ClearSigningType.BASIC})}),it("should exclude generic-parser contexts with an old app version",async()=>{const e=[{type:n.ClearSignContextType.TOKEN,payload:"payload-1"},{type:n.ClearSignContextType.TRANSACTION_INFO,payload:"payload-2",certificate:r},{type:n.ClearSignContextType.TRANSACTION_FIELD_DESCRIPTION,payload:"payload-3"},{type:n.ClearSignContextType.ENUM,payload:"payload-4",id:1,value:2,certificate:r}];l.getContexts.mockResolvedValueOnce(e),a.getDeviceSessionState.mockReturnValueOnce({sessionStateType:t.DeviceSessionStateType.ReadyWithoutSecureChannel,deviceStatus:t.DeviceStatus.CONNECTED,installedApps:[],currentApp:{name:"Ethereum",version:"1.12.0"},deviceModelId:t.DeviceModelId.FLEX,isSecureConnectionAllowed:!1});const o=await new s.BuildBaseContexts(a,c,i).run();expect(o).toEqual({clearSignContexts:[e[0]],clearSignContextsOptional:[],clearSigningType:d.ClearSigningType.BASIC})}),it("should exclude generic-parser contexts with a non ready device",async()=>{const e=[{type:n.ClearSignContextType.TOKEN,payload:"payload-1"},{type:n.ClearSignContextType.TRANSACTION_INFO,payload:"payload-2",certificate:r},{type:n.ClearSignContextType.TRANSACTION_FIELD_DESCRIPTION,payload:"payload-3"},{type:n.ClearSignContextType.ENUM,payload:"payload-4",id:1,value:2,certificate:r}];l.getContexts.mockResolvedValueOnce(e),a.getDeviceSessionState.mockReturnValueOnce({sessionStateType:t.DeviceSessionStateType.Connected,deviceStatus:t.DeviceStatus.NOT_CONNECTED,deviceModelId:t.DeviceModelId.FLEX});const o=await new s.BuildBaseContexts(a,c,i).run();expect(o).toEqual({clearSignContexts:[e[0]],clearSignContextsOptional:[],clearSigningType:d.ClearSigningType.BASIC})}),it("should return no clear sign context if the transaction info certificate is missing",async()=>{const e=[{type:n.ClearSignContextType.TRANSACTION_INFO,payload:"payload-1"},{type:n.ClearSignContextType.TRANSACTION_FIELD_DESCRIPTION,payload:"payload-2"},{type:n.ClearSignContextType.ENUM,payload:"payload-3",id:1,value:2}];l.getContexts.mockResolvedValueOnce(e),a.getDeviceSessionState.mockReturnValueOnce({sessionStateType:t.DeviceSessionStateType.ReadyWithoutSecureChannel,deviceStatus:t.DeviceStatus.CONNECTED,installedApps:[],currentApp:{name:"Ethereum",version:"1.17.0"},deviceModelId:t.DeviceModelId.FLEX,isSecureConnectionAllowed:!1});const o=await new s.BuildBaseContexts(a,c,i).run();expect(o).toEqual({clearSignContexts:[],clearSignContextsOptional:[],clearSigningType:d.ClearSigningType.BASIC})}),it("should not return web3check if the transaction is undefined",async()=>{const e=[];l.getContexts.mockResolvedValueOnce(e),a.getDeviceSessionState.mockReturnValueOnce({sessionStateType:t.DeviceSessionStateType.ReadyWithoutSecureChannel,deviceStatus:t.DeviceStatus.CONNECTED,installedApps:[],currentApp:{name:"Ethereum",version:"1.17.0"},deviceModelId:t.DeviceModelId.FLEX,isSecureConnectionAllowed:!1}),await new s.BuildBaseContexts(a,{...c,transaction:void 0},i).run(),expect(i).not.toHaveBeenCalled()})});
1
+ "use strict";var n=require("@ledgerhq/context-module"),t=require("@ledgerhq/device-management-kit"),C=require("ethers"),r=require("../../../api/model/ClearSigningType"),S=require("../../app-binder/device-action/__test-utils__/makeInternalApi"),i=require("./BuildBaseContexts");describe("BuildBaseContexts",()=>{const l={getFieldContext:vi.fn(),getContexts:vi.fn(),getTypedDataFilters:vi.fn(),getSolanaContext:vi.fn()},y={domain:"domain-name.eth"},u=(0,t.hexaStringToBuffer)(C.Transaction.from({chainId:1n,nonce:0,data:"0x"}).unsignedSerialized),s={keyUsageNumber:1,payload:new Uint8Array([1,2,3])};let c;const a=(0,S.makeDeviceActionInternalApiMock)();function p(e){return{blindSigningEnabled:!1,web3ChecksEnabled:e,web3ChecksOptIn:!1,version:"1.13.0"}}beforeEach(()=>{vi.resetAllMocks(),a.sendCommand.mockResolvedValue((0,t.CommandResultFactory)({data:{challenge:"challenge"}})),c={contextModule:l,subset:{chainId:1,to:void 0,data:"0x",selector:"0x"},transaction:u,options:y,appConfig:p(!1)}}),it("should build the transaction context without clear sign contexts",async()=>{const e=[],o=[];l.getContexts.mockResolvedValueOnce(e),a.getDeviceSessionState.mockReturnValueOnce({sessionStateType:t.DeviceSessionStateType.ReadyWithoutSecureChannel,deviceStatus:t.DeviceStatus.CONNECTED,installedApps:[],currentApp:{name:"Ethereum",version:"1.12.0"},deviceModelId:t.DeviceModelId.FLEX,isSecureConnectionAllowed:!1});const d=await new i.BuildBaseContexts(a,{...c,appConfig:p(!0)}).run();expect(d).toEqual({clearSignContexts:e,clearSignContextsOptional:o,clearSigningType:r.ClearSigningType.BASIC})}),it("should build the transaction context with transaction check and generic-parser clear sign contexts",async()=>{const e=[{type:n.ClearSignContextType.TRANSACTION_INFO,payload:"payload-1",certificate:s},{type:n.ClearSignContextType.TRANSACTION_FIELD_DESCRIPTION,payload:"payload-2"},{type:n.ClearSignContextType.ENUM,payload:"payload-3",id:1,value:2,certificate:s},{type:n.ClearSignContextType.TRANSACTION_FIELD_DESCRIPTION,payload:"payload-4"}],o={type:n.ClearSignContextType.TRANSACTION_CHECK,payload:"transactionCheck"};l.getContexts.mockResolvedValueOnce([...e,o]),a.getDeviceSessionState.mockReturnValueOnce({sessionStateType:t.DeviceSessionStateType.ReadyWithoutSecureChannel,deviceStatus:t.DeviceStatus.CONNECTED,installedApps:[],currentApp:{name:"Ethereum",version:"1.15.0"},deviceModelId:t.DeviceModelId.FLEX,isSecureConnectionAllowed:!1});const d=await new i.BuildBaseContexts(a,{...c,appConfig:p(!0)}).run();expect(d).toEqual({clearSignContexts:[o,e[0],e[1],e[3]],clearSignContextsOptional:[e[2]],clearSigningType:r.ClearSigningType.EIP7730})}),it("should build the transaction context with transaction check and generic-parser clear sign contexts in the correct order",async()=>{const e=[{type:n.ClearSignContextType.ENUM,payload:"payload-3",id:1,value:2,certificate:s},{type:n.ClearSignContextType.TRANSACTION_FIELD_DESCRIPTION,payload:"payload-4"},{type:n.ClearSignContextType.TRANSACTION_FIELD_DESCRIPTION,payload:"payload-2"},{type:n.ClearSignContextType.TRANSACTION_INFO,payload:"payload-1",certificate:s}],o={type:n.ClearSignContextType.TRANSACTION_CHECK,payload:"transactionCheck"};l.getContexts.mockResolvedValueOnce([...e,o]),a.getDeviceSessionState.mockReturnValueOnce({sessionStateType:t.DeviceSessionStateType.ReadyWithoutSecureChannel,deviceStatus:t.DeviceStatus.CONNECTED,installedApps:[],currentApp:{name:"Ethereum",version:"1.15.0"},deviceModelId:t.DeviceModelId.FLEX,isSecureConnectionAllowed:!1});const d=await new i.BuildBaseContexts(a,{...c,appConfig:p(!0)}).run();expect(d).toEqual({clearSignContexts:[o,e[3],e[1],e[2]],clearSignContextsOptional:[e[0]],clearSigningType:r.ClearSigningType.EIP7730})}),it("should build the transaction context with clear sign contexts",async()=>{const e=[{type:n.ClearSignContextType.TRANSACTION_CHECK,payload:"transactionCheck"},{type:n.ClearSignContextType.TOKEN,payload:"payload-1"},{type:n.ClearSignContextType.NFT,payload:"payload-2"}];l.getContexts.mockResolvedValueOnce(e),a.getDeviceSessionState.mockReturnValueOnce({sessionStateType:t.DeviceSessionStateType.ReadyWithoutSecureChannel,deviceStatus:t.DeviceStatus.CONNECTED,installedApps:[],currentApp:{name:"Ethereum",version:"1.12.0"},deviceModelId:t.DeviceModelId.FLEX,isSecureConnectionAllowed:!1});const o=await new i.BuildBaseContexts(a,c).run();expect(o).toEqual({clearSignContexts:e,clearSignContextsOptional:[],clearSigningType:r.ClearSigningType.BASIC})}),it("should build the transaction context with generic-parser context",async()=>{const e=[{type:n.ClearSignContextType.TRANSACTION_INFO,payload:"payload-1",certificate:s},{type:n.ClearSignContextType.TRANSACTION_FIELD_DESCRIPTION,payload:"payload-2"},{type:n.ClearSignContextType.ENUM,payload:"payload-3",id:1,value:2,certificate:s},{type:n.ClearSignContextType.TRANSACTION_FIELD_DESCRIPTION,payload:"payload-4"}];l.getContexts.mockResolvedValueOnce(e),a.getDeviceSessionState.mockReturnValueOnce({sessionStateType:t.DeviceSessionStateType.ReadyWithoutSecureChannel,deviceStatus:t.DeviceStatus.CONNECTED,installedApps:[],currentApp:{name:"Ethereum",version:"1.15.0"},deviceModelId:t.DeviceModelId.FLEX,isSecureConnectionAllowed:!1});const o=await new i.BuildBaseContexts(a,c).run();expect(o).toEqual({clearSignContexts:[e[0],e[1],e[3]],clearSignContextsOptional:[e[2]],clearSigningType:r.ClearSigningType.EIP7730})}),it("should build the transaction context with proxy delegate call context",async()=>{const e=[{type:n.ClearSignContextType.TRANSACTION_INFO,payload:"payload-1",certificate:s},{type:n.ClearSignContextType.PROXY_INFO,payload:"payload-2"}],o=[];l.getContexts.mockResolvedValueOnce(e),a.getDeviceSessionState.mockReturnValueOnce({sessionStateType:t.DeviceSessionStateType.ReadyWithoutSecureChannel,deviceStatus:t.DeviceStatus.CONNECTED,installedApps:[],currentApp:{name:"Ethereum",version:"1.15.0"},deviceModelId:t.DeviceModelId.FLEX,isSecureConnectionAllowed:!1});const d=await new i.BuildBaseContexts(a,c).run();expect(d).toEqual({clearSignContexts:[e[1],e[0]],clearSignContextsOptional:o,clearSigningType:r.ClearSigningType.EIP7730})}),it("should call the context module with the correct parameters if transaction check is enabled",async()=>{const e=[];l.getContexts.mockResolvedValueOnce(e),a.getDeviceSessionState.mockReturnValueOnce({sessionStateType:t.DeviceSessionStateType.ReadyWithoutSecureChannel,deviceStatus:t.DeviceStatus.CONNECTED,installedApps:[],currentApp:{name:"Ethereum",version:"1.12.0"},deviceModelId:t.DeviceModelId.FLEX,isSecureConnectionAllowed:!1}),await new i.BuildBaseContexts(a,{...c,appConfig:p(!0)}).run(),expect(l.getContexts).toHaveBeenCalledWith({deviceModelId:t.DeviceModelId.FLEX,challenge:"challenge",domain:"domain-name.eth",transaction:u,...c.subset},i.BASE_CONTEXT_TYPES_FILTER)}),it("should call the context module with the correct parameters if transaction check is disabled",async()=>{const e=[];l.getContexts.mockResolvedValueOnce(e),a.getDeviceSessionState.mockReturnValueOnce({sessionStateType:t.DeviceSessionStateType.ReadyWithoutSecureChannel,deviceStatus:t.DeviceStatus.CONNECTED,installedApps:[],currentApp:{name:"Ethereum",version:"1.12.0"},deviceModelId:t.DeviceModelId.FLEX,isSecureConnectionAllowed:!1}),await new i.BuildBaseContexts(a,{...c,appConfig:p(!1)}).run(),expect(l.getContexts).toHaveBeenCalledWith({deviceModelId:t.DeviceModelId.FLEX,challenge:"challenge",domain:"domain-name.eth",...c.subset},i.BASE_CONTEXT_TYPES_FILTER)}),it("should call the context module without challenge for Nano S",async()=>{const e=[];l.getContexts.mockResolvedValueOnce(e),a.getDeviceSessionState.mockReturnValueOnce({sessionStateType:t.DeviceSessionStateType.ReadyWithoutSecureChannel,deviceStatus:t.DeviceStatus.CONNECTED,installedApps:[],currentApp:{name:"Ethereum",version:"1.12.0"},deviceModelId:t.DeviceModelId.NANO_S,isSecureConnectionAllowed:!1}),await new i.BuildBaseContexts(a,c).run(),expect(l.getContexts).toHaveBeenCalledWith({deviceModelId:t.DeviceModelId.NANO_S,domain:"domain-name.eth",challenge:void 0,...c.subset},i.BASE_CONTEXT_TYPES_FILTER)}),it("should exclude error contexts from the result",async()=>{const e=[{type:n.ClearSignContextType.ERROR,error:new Error("error")},{type:n.ClearSignContextType.TOKEN,payload:"payload-1"},{type:n.ClearSignContextType.ERROR,error:new Error("error")},{type:n.ClearSignContextType.NFT,payload:"payload-2"}];l.getContexts.mockResolvedValueOnce(e),a.getDeviceSessionState.mockReturnValueOnce({sessionStateType:t.DeviceSessionStateType.ReadyWithoutSecureChannel,deviceStatus:t.DeviceStatus.CONNECTED,installedApps:[],currentApp:{name:"Ethereum",version:"1.12.0"},deviceModelId:t.DeviceModelId.FLEX,isSecureConnectionAllowed:!1});const o=await new i.BuildBaseContexts(a,c).run();expect(o).toEqual({clearSignContexts:[e[1],e[3]],clearSignContextsOptional:[],clearSigningType:r.ClearSigningType.BASIC})}),it("should exclude generic-parser contexts from the result on old apps",async()=>{const e=[{type:n.ClearSignContextType.TRANSACTION_INFO,payload:"transaction_info",certificate:s},{type:n.ClearSignContextType.TOKEN,payload:"payload-1"},{type:n.ClearSignContextType.TRANSACTION_FIELD_DESCRIPTION,payload:"transaction_field"},{type:n.ClearSignContextType.NFT,payload:"payload-2"},{type:n.ClearSignContextType.ENUM,payload:"enum",id:1,value:2,certificate:s}];l.getContexts.mockResolvedValueOnce(e),a.getDeviceSessionState.mockReturnValueOnce({sessionStateType:t.DeviceSessionStateType.ReadyWithoutSecureChannel,deviceStatus:t.DeviceStatus.CONNECTED,installedApps:[],currentApp:{name:"Ethereum",version:"1.12.0"},deviceModelId:t.DeviceModelId.FLEX,isSecureConnectionAllowed:!1});const o=await new i.BuildBaseContexts(a,c).run();expect(o).toEqual({clearSignContexts:[e[1],e[3]],clearSignContextsOptional:[],clearSigningType:r.ClearSigningType.BASIC})}),it("should exclude generic-parser contexts from the result if no transaction_info was found",async()=>{const e=[{type:n.ClearSignContextType.TRANSACTION_FIELD_DESCRIPTION,payload:"transaction_field"},{type:n.ClearSignContextType.TOKEN,payload:"payload-1"},{type:n.ClearSignContextType.ENUM,payload:"enum",id:1,value:2},{type:n.ClearSignContextType.NFT,payload:"payload-2"}];l.getContexts.mockResolvedValueOnce(e),a.getDeviceSessionState.mockReturnValueOnce({sessionStateType:t.DeviceSessionStateType.ReadyWithoutSecureChannel,deviceStatus:t.DeviceStatus.CONNECTED,installedApps:[],currentApp:{name:"Ethereum",version:"1.14.0"},deviceModelId:t.DeviceModelId.FLEX,isSecureConnectionAllowed:!1});const o=await new i.BuildBaseContexts(a,c).run();expect(o).toEqual({clearSignContexts:[e[1],e[3]],clearSignContextsOptional:[],clearSigningType:r.ClearSigningType.BASIC})}),it("should exclude legacy contexts from the result for generic-parser transactions",async()=>{const e=[{type:n.ClearSignContextType.TOKEN,payload:"payload-1"},{type:n.ClearSignContextType.TRANSACTION_INFO,payload:"payload-2",certificate:s},{type:n.ClearSignContextType.EXTERNAL_PLUGIN,payload:"payload-3"},{type:n.ClearSignContextType.TRANSACTION_FIELD_DESCRIPTION,payload:"payload-4"},{type:n.ClearSignContextType.ENUM,payload:"payload-5",id:1,value:2,certificate:s}];l.getContexts.mockResolvedValueOnce(e),a.getDeviceSessionState.mockReturnValueOnce({sessionStateType:t.DeviceSessionStateType.ReadyWithoutSecureChannel,deviceStatus:t.DeviceStatus.CONNECTED,installedApps:[],currentApp:{name:"Ethereum",version:"1.15.0"},deviceModelId:t.DeviceModelId.FLEX,isSecureConnectionAllowed:!1});const o=await new i.BuildBaseContexts(a,c).run();expect(o).toEqual({clearSignContexts:[e[1],e[3]],clearSignContextsOptional:[e[4]],clearSigningType:r.ClearSigningType.EIP7730})}),it("should exclude generic-parser contexts with a nano s device",async()=>{const e=[{type:n.ClearSignContextType.TOKEN,payload:"payload-1"},{type:n.ClearSignContextType.TRANSACTION_INFO,payload:"payload-2",certificate:s},{type:n.ClearSignContextType.TRANSACTION_FIELD_DESCRIPTION,payload:"payload-3"},{type:n.ClearSignContextType.ENUM,payload:"payload-4",id:1,value:2,certificate:s}];l.getContexts.mockResolvedValueOnce(e),a.getDeviceSessionState.mockReturnValueOnce({sessionStateType:t.DeviceSessionStateType.ReadyWithoutSecureChannel,deviceStatus:t.DeviceStatus.CONNECTED,installedApps:[],currentApp:{name:"Ethereum",version:"1.14.0"},deviceModelId:t.DeviceModelId.NANO_S,isSecureConnectionAllowed:!1});const o=await new i.BuildBaseContexts(a,c).run();expect(o).toEqual({clearSignContexts:[e[0]],clearSignContextsOptional:[],clearSigningType:r.ClearSigningType.BASIC})}),it("should exclude generic-parser contexts with an old app version",async()=>{const e=[{type:n.ClearSignContextType.TOKEN,payload:"payload-1"},{type:n.ClearSignContextType.TRANSACTION_INFO,payload:"payload-2",certificate:s},{type:n.ClearSignContextType.TRANSACTION_FIELD_DESCRIPTION,payload:"payload-3"},{type:n.ClearSignContextType.ENUM,payload:"payload-4",id:1,value:2,certificate:s}];l.getContexts.mockResolvedValueOnce(e),a.getDeviceSessionState.mockReturnValueOnce({sessionStateType:t.DeviceSessionStateType.ReadyWithoutSecureChannel,deviceStatus:t.DeviceStatus.CONNECTED,installedApps:[],currentApp:{name:"Ethereum",version:"1.12.0"},deviceModelId:t.DeviceModelId.FLEX,isSecureConnectionAllowed:!1});const o=await new i.BuildBaseContexts(a,c).run();expect(o).toEqual({clearSignContexts:[e[0]],clearSignContextsOptional:[],clearSigningType:r.ClearSigningType.BASIC})}),it("should exclude generic-parser contexts with a non ready device",async()=>{const e=[{type:n.ClearSignContextType.TOKEN,payload:"payload-1"},{type:n.ClearSignContextType.TRANSACTION_INFO,payload:"payload-2",certificate:s},{type:n.ClearSignContextType.TRANSACTION_FIELD_DESCRIPTION,payload:"payload-3"},{type:n.ClearSignContextType.ENUM,payload:"payload-4",id:1,value:2,certificate:s}];l.getContexts.mockResolvedValueOnce(e),a.getDeviceSessionState.mockReturnValueOnce({sessionStateType:t.DeviceSessionStateType.Connected,deviceStatus:t.DeviceStatus.NOT_CONNECTED,deviceModelId:t.DeviceModelId.FLEX});const o=await new i.BuildBaseContexts(a,c).run();expect(o).toEqual({clearSignContexts:[e[0]],clearSignContextsOptional:[],clearSigningType:r.ClearSigningType.BASIC})}),it("should return no clear sign context if the transaction info certificate is missing",async()=>{const e=[{type:n.ClearSignContextType.TRANSACTION_INFO,payload:"payload-1"},{type:n.ClearSignContextType.TRANSACTION_FIELD_DESCRIPTION,payload:"payload-2"},{type:n.ClearSignContextType.ENUM,payload:"payload-3",id:1,value:2}];l.getContexts.mockResolvedValueOnce(e),a.getDeviceSessionState.mockReturnValueOnce({sessionStateType:t.DeviceSessionStateType.ReadyWithoutSecureChannel,deviceStatus:t.DeviceStatus.CONNECTED,installedApps:[],currentApp:{name:"Ethereum",version:"1.17.0"},deviceModelId:t.DeviceModelId.FLEX,isSecureConnectionAllowed:!1});const o=await new i.BuildBaseContexts(a,c).run();expect(o).toEqual({clearSignContexts:[],clearSignContextsOptional:[],clearSigningType:r.ClearSigningType.BASIC})})});
2
2
  //# sourceMappingURL=BuildBaseContexts.test.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../../src/internal/app-binder/task/BuildBaseContexts.test.ts"],
4
- "sourcesContent": ["import {\n type ClearSignContext,\n ClearSignContextType,\n type PkiCertificate,\n} from \"@ledgerhq/context-module\";\nimport {\n CommandResultFactory,\n DeviceModelId,\n DeviceSessionStateType,\n DeviceStatus,\n hexaStringToBuffer,\n UnknownDeviceExchangeError,\n} from \"@ledgerhq/device-management-kit\";\nimport { Transaction } from \"ethers\";\n\nimport type { GetConfigCommandResponse } from \"@api/app-binder/GetConfigCommandTypes\";\nimport { ClearSigningType } from \"@api/model/ClearSigningType\";\nimport { makeDeviceActionInternalApiMock } from \"@internal/app-binder/device-action/__test-utils__/makeInternalApi\";\n\nimport {\n BuildBaseContexts,\n type BuildBaseContextsArgs,\n} from \"./BuildBaseContexts\";\nimport { GetWeb3CheckTask } from \"./GetWeb3CheckTask\";\n\ndescribe(\"BuildBaseContexts\", () => {\n const contextModuleMock = {\n getFieldContext: vi.fn(),\n getContexts: vi.fn(),\n getTypedDataFilters: vi.fn(),\n getWeb3Checks: vi.fn(),\n getSolanaContext: vi.fn(),\n };\n const defaultOptions = {\n domain: \"domain-name.eth\",\n };\n const defaultTransaction: Uint8Array = hexaStringToBuffer(\n Transaction.from({\n chainId: 1n,\n nonce: 0,\n data: \"0x\",\n }).unsignedSerialized,\n )!;\n const defaultCertificate: PkiCertificate = {\n keyUsageNumber: 1,\n payload: new Uint8Array([0x01, 0x02, 0x03]),\n };\n\n let defaultArgs: BuildBaseContextsArgs;\n const apiMock = makeDeviceActionInternalApiMock();\n const getWeb3ChecksFactoryMock = vi.fn();\n\n function createAppConfig(\n web3ChecksEnabled: boolean,\n ): GetConfigCommandResponse {\n return {\n blindSigningEnabled: false,\n web3ChecksEnabled,\n web3ChecksOptIn: false,\n version: \"1.13.0\",\n };\n }\n\n beforeEach(() => {\n vi.resetAllMocks();\n apiMock.sendCommand.mockResolvedValue(\n CommandResultFactory({ data: { challenge: \"challenge\" } }),\n );\n getWeb3ChecksFactoryMock.mockReturnValue({\n run: async () => Promise.resolve({ web3Check: null }),\n });\n\n defaultArgs = {\n contextModule: contextModuleMock,\n subset: { chainId: 1, to: undefined, data: \"0x\", selector: \"0x\" },\n transaction: defaultTransaction,\n options: defaultOptions,\n appConfig: createAppConfig(false),\n derivationPath: \"44'/60'/0'/0/0\",\n };\n });\n\n it(\"should init with a default GetWeb3CheckTaskFactory\", () => {\n // GIVEN\n const task = new BuildBaseContexts(apiMock, defaultArgs);\n\n // THEN\n expect(task[\"getWeb3ChecksFactory\"]).toBeDefined();\n expect(\n task[\"getWeb3ChecksFactory\"](apiMock, {\n contextModule: defaultArgs.contextModule,\n derivationPath: defaultArgs.derivationPath,\n subset: defaultArgs.subset,\n transaction: defaultArgs.transaction!,\n }),\n ).toBeInstanceOf(GetWeb3CheckTask);\n });\n\n it(\"should build the transaction context without clear sign contexts\", async () => {\n // GIVEN\n const clearSignContexts: ClearSignContext[] = [];\n const clearSignContextsOptional: ClearSignContext[] = [];\n contextModuleMock.getContexts.mockResolvedValueOnce(clearSignContexts);\n apiMock.getDeviceSessionState.mockReturnValueOnce({\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\n // WHEN\n const result = await new BuildBaseContexts(\n apiMock,\n { ...defaultArgs, appConfig: createAppConfig(true) },\n getWeb3ChecksFactoryMock,\n ).run();\n\n // THEN\n expect(result).toEqual({\n clearSignContexts,\n clearSignContextsOptional,\n clearSigningType: ClearSigningType.BASIC,\n });\n });\n\n it(\"should build the transaction context with web3checks\", async () => {\n // GIVEN\n const clearSignContexts: ClearSignContext[] = [];\n const clearSignContextsOptional: ClearSignContext[] = [];\n const expectedWeb3Check = {\n type: ClearSignContextType.WEB3_CHECK,\n payload: \"web3Check\",\n };\n getWeb3ChecksFactoryMock.mockReturnValueOnce({\n run: async () => Promise.resolve({ web3Check: expectedWeb3Check }),\n });\n contextModuleMock.getContexts.mockResolvedValueOnce([...clearSignContexts]);\n apiMock.getDeviceSessionState.mockReturnValueOnce({\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\n // WHEN\n const result = await new BuildBaseContexts(\n apiMock,\n { ...defaultArgs, appConfig: createAppConfig(true) },\n getWeb3ChecksFactoryMock,\n ).run();\n\n // THEN\n expect(result).toEqual({\n clearSignContexts: [expectedWeb3Check, ...clearSignContexts],\n clearSignContextsOptional,\n clearSigningType: ClearSigningType.BASIC,\n });\n });\n\n it(\"should build the transaction context with web3checks and generic-parser clear sign contexts\", async () => {\n // GIVEN\n const clearSignContexts: ClearSignContext[] = [\n {\n type: ClearSignContextType.TRANSACTION_INFO,\n payload: \"payload-1\",\n certificate: defaultCertificate,\n },\n {\n type: ClearSignContextType.TRANSACTION_FIELD_DESCRIPTION,\n payload: \"payload-2\",\n },\n {\n type: ClearSignContextType.ENUM,\n payload: \"payload-3\",\n id: 1,\n value: 2,\n certificate: defaultCertificate,\n },\n {\n type: ClearSignContextType.TRANSACTION_FIELD_DESCRIPTION,\n payload: \"payload-4\",\n },\n ];\n const expectedWeb3Check = {\n type: ClearSignContextType.WEB3_CHECK,\n payload: \"web3Check\",\n };\n getWeb3ChecksFactoryMock.mockReturnValueOnce({\n run: async () => Promise.resolve({ web3Check: expectedWeb3Check }),\n });\n contextModuleMock.getContexts.mockResolvedValueOnce([...clearSignContexts]);\n apiMock.getDeviceSessionState.mockReturnValueOnce({\n sessionStateType: DeviceSessionStateType.ReadyWithoutSecureChannel,\n deviceStatus: DeviceStatus.CONNECTED,\n installedApps: [],\n currentApp: { name: \"Ethereum\", version: \"1.15.0\" },\n deviceModelId: DeviceModelId.FLEX,\n isSecureConnectionAllowed: false,\n });\n\n // WHEN\n const result = await new BuildBaseContexts(\n apiMock,\n { ...defaultArgs, appConfig: createAppConfig(true) },\n getWeb3ChecksFactoryMock,\n ).run();\n\n // THEN\n expect(result).toEqual({\n clearSignContexts: [\n expectedWeb3Check,\n clearSignContexts[0],\n clearSignContexts[1],\n clearSignContexts[3],\n ],\n clearSignContextsOptional: [clearSignContexts[2]],\n clearSigningType: ClearSigningType.EIP7730,\n });\n });\n\n it(\"should build the transaction context with web3checks and generic-parser clear sign contexts in the correct order\", async () => {\n // GIVEN\n const clearSignContexts: ClearSignContext[] = [\n {\n type: ClearSignContextType.ENUM,\n payload: \"payload-3\",\n id: 1,\n value: 2,\n certificate: defaultCertificate,\n },\n {\n type: ClearSignContextType.TRANSACTION_FIELD_DESCRIPTION,\n payload: \"payload-4\",\n },\n {\n type: ClearSignContextType.TRANSACTION_FIELD_DESCRIPTION,\n payload: \"payload-2\",\n },\n {\n type: ClearSignContextType.TRANSACTION_INFO,\n payload: \"payload-1\",\n certificate: defaultCertificate,\n },\n ];\n const expectedWeb3Check = {\n type: ClearSignContextType.WEB3_CHECK,\n payload: \"web3Check\",\n };\n getWeb3ChecksFactoryMock.mockReturnValueOnce({\n run: async () => Promise.resolve({ web3Check: expectedWeb3Check }),\n });\n contextModuleMock.getContexts.mockResolvedValueOnce([...clearSignContexts]);\n apiMock.getDeviceSessionState.mockReturnValueOnce({\n sessionStateType: DeviceSessionStateType.ReadyWithoutSecureChannel,\n deviceStatus: DeviceStatus.CONNECTED,\n installedApps: [],\n currentApp: { name: \"Ethereum\", version: \"1.15.0\" },\n deviceModelId: DeviceModelId.FLEX,\n isSecureConnectionAllowed: false,\n });\n\n // WHEN\n const result = await new BuildBaseContexts(\n apiMock,\n { ...defaultArgs, appConfig: createAppConfig(true) },\n getWeb3ChecksFactoryMock,\n ).run();\n\n // THEN\n expect(result).toEqual({\n clearSignContexts: [\n expectedWeb3Check, // web3 check\n clearSignContexts[3], // transaction info\n clearSignContexts[1], // transaction field description\n clearSignContexts[2], // transaction field description\n ],\n clearSignContextsOptional: [clearSignContexts[0]], // enum\n clearSigningType: ClearSigningType.EIP7730,\n });\n });\n\n it(\"should build the transaction context with clear sign contexts\", async () => {\n // GIVEN\n const clearSignContexts: ClearSignContext[] = [\n {\n type: ClearSignContextType.TOKEN,\n payload: \"payload-1\",\n },\n {\n type: ClearSignContextType.NFT,\n payload: \"payload-2\",\n },\n ];\n const expectedWeb3Check = {\n type: ClearSignContextType.WEB3_CHECK,\n payload: \"web3Check\",\n };\n getWeb3ChecksFactoryMock.mockReturnValueOnce({\n run: async () => Promise.resolve({ web3Check: expectedWeb3Check }),\n });\n contextModuleMock.getContexts.mockResolvedValueOnce(clearSignContexts);\n apiMock.getDeviceSessionState.mockReturnValueOnce({\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\n // WHEN\n const result = await new BuildBaseContexts(\n apiMock,\n defaultArgs,\n getWeb3ChecksFactoryMock,\n ).run();\n\n // THEN\n expect(result).toEqual({\n clearSignContexts,\n clearSignContextsOptional: [],\n clearSigningType: ClearSigningType.BASIC,\n });\n });\n\n it(\"should build the transaction context with generic-parser context\", async () => {\n // GIVEN\n const clearSignContexts: ClearSignContext[] = [\n {\n type: ClearSignContextType.TRANSACTION_INFO,\n payload: \"payload-1\",\n certificate: defaultCertificate,\n },\n {\n type: ClearSignContextType.TRANSACTION_FIELD_DESCRIPTION,\n payload: \"payload-2\",\n },\n {\n type: ClearSignContextType.ENUM,\n payload: \"payload-3\",\n id: 1,\n value: 2,\n certificate: defaultCertificate,\n },\n {\n type: ClearSignContextType.TRANSACTION_FIELD_DESCRIPTION,\n payload: \"payload-4\",\n },\n ];\n contextModuleMock.getContexts.mockResolvedValueOnce(clearSignContexts);\n apiMock.getDeviceSessionState.mockReturnValueOnce({\n sessionStateType: DeviceSessionStateType.ReadyWithoutSecureChannel,\n deviceStatus: DeviceStatus.CONNECTED,\n installedApps: [],\n currentApp: { name: \"Ethereum\", version: \"1.15.0\" },\n deviceModelId: DeviceModelId.FLEX,\n isSecureConnectionAllowed: false,\n });\n\n // WHEN\n const result = await new BuildBaseContexts(\n apiMock,\n defaultArgs,\n getWeb3ChecksFactoryMock,\n ).run();\n\n // THEN\n expect(result).toEqual({\n clearSignContexts: [\n clearSignContexts[0],\n clearSignContexts[1],\n clearSignContexts[3],\n ],\n clearSignContextsOptional: [clearSignContexts[2]],\n clearSigningType: ClearSigningType.EIP7730,\n });\n });\n\n it(\"should build the transaction context with proxy delegate call context\", async () => {\n // GIVEN\n const clearSignContexts: ClearSignContext[] = [\n {\n type: ClearSignContextType.TRANSACTION_INFO,\n payload: \"payload-1\",\n certificate: defaultCertificate,\n },\n {\n type: ClearSignContextType.PROXY_INFO,\n payload: \"payload-2\",\n },\n ];\n const clearSignContextsOptional: ClearSignContext[] = [];\n contextModuleMock.getContexts.mockResolvedValueOnce(clearSignContexts);\n apiMock.getDeviceSessionState.mockReturnValueOnce({\n sessionStateType: DeviceSessionStateType.ReadyWithoutSecureChannel,\n deviceStatus: DeviceStatus.CONNECTED,\n installedApps: [],\n currentApp: { name: \"Ethereum\", version: \"1.15.0\" },\n deviceModelId: DeviceModelId.FLEX,\n isSecureConnectionAllowed: false,\n });\n\n // WHEN\n const result = await new BuildBaseContexts(\n apiMock,\n defaultArgs,\n getWeb3ChecksFactoryMock,\n ).run();\n\n // THEN\n expect(result).toEqual({\n clearSignContexts: [clearSignContexts[1], clearSignContexts[0]],\n clearSignContextsOptional,\n clearSigningType: ClearSigningType.EIP7730,\n });\n });\n\n it(\"should call the web3checks factory with correct parameters\", async () => {\n // GIVEN\n const clearSignContexts: ClearSignContext[] = [];\n contextModuleMock.getContexts.mockResolvedValueOnce(clearSignContexts);\n apiMock.getDeviceSessionState.mockReturnValueOnce({\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\n // WHEN\n await new BuildBaseContexts(\n apiMock,\n { ...defaultArgs, appConfig: createAppConfig(true) },\n getWeb3ChecksFactoryMock,\n ).run();\n\n // THEN\n expect(getWeb3ChecksFactoryMock).toHaveBeenCalledWith(apiMock, {\n contextModule: contextModuleMock,\n derivationPath: \"44'/60'/0'/0/0\",\n subset: defaultArgs.subset,\n transaction: defaultTransaction,\n });\n });\n\n it(\"should call the context module with the correct parameters\", async () => {\n // GIVEN\n const clearSignContexts: ClearSignContext[] = [];\n contextModuleMock.getContexts.mockResolvedValueOnce(clearSignContexts);\n apiMock.getDeviceSessionState.mockReturnValueOnce({\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\n // WHEN\n await new BuildBaseContexts(\n apiMock,\n defaultArgs,\n getWeb3ChecksFactoryMock,\n ).run();\n\n // THEN\n expect(contextModuleMock.getContexts).toHaveBeenCalledWith(\n {\n deviceModelId: DeviceModelId.FLEX,\n challenge: \"challenge\",\n domain: \"domain-name.eth\",\n ...defaultArgs.subset,\n },\n undefined,\n );\n });\n\n it(\"should call the context module without challenge for Nano S\", async () => {\n // GIVEN\n const clearSignContexts: ClearSignContext[] = [];\n contextModuleMock.getContexts.mockResolvedValueOnce(clearSignContexts);\n apiMock.getDeviceSessionState.mockReturnValueOnce({\n sessionStateType: DeviceSessionStateType.ReadyWithoutSecureChannel,\n deviceStatus: DeviceStatus.CONNECTED,\n installedApps: [],\n currentApp: { name: \"Ethereum\", version: \"1.12.0\" },\n deviceModelId: DeviceModelId.NANO_S,\n isSecureConnectionAllowed: false,\n });\n\n // WHEN\n await new BuildBaseContexts(\n apiMock,\n defaultArgs,\n getWeb3ChecksFactoryMock,\n ).run();\n\n // THEN\n expect(contextModuleMock.getContexts).toHaveBeenCalledWith(\n {\n deviceModelId: DeviceModelId.NANO_S,\n domain: \"domain-name.eth\",\n ...defaultArgs.subset,\n },\n undefined,\n );\n });\n\n it(\"should call the context module without context on error\", async () => {\n // GIVEN\n const clearSignContexts: ClearSignContext[] = [];\n contextModuleMock.getContexts.mockResolvedValueOnce(clearSignContexts);\n apiMock.getDeviceSessionState.mockReturnValueOnce({\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 apiMock.sendCommand.mockResolvedValueOnce(\n CommandResultFactory({ error: new UnknownDeviceExchangeError() }),\n );\n\n // WHEN\n await new BuildBaseContexts(\n apiMock,\n defaultArgs,\n getWeb3ChecksFactoryMock,\n ).run();\n\n // THEN\n expect(contextModuleMock.getContexts).toHaveBeenCalledWith(\n {\n deviceModelId: DeviceModelId.FLEX,\n challenge: undefined,\n domain: \"domain-name.eth\",\n ...defaultArgs.subset,\n },\n undefined,\n );\n });\n\n it(\"should exclude error contexts from the result\", async () => {\n // GIVEN\n const clearSignContexts: ClearSignContext[] = [\n {\n type: ClearSignContextType.ERROR,\n error: new Error(\"error\"),\n },\n {\n type: ClearSignContextType.TOKEN,\n payload: \"payload-1\",\n },\n {\n type: ClearSignContextType.ERROR,\n error: new Error(\"error\"),\n },\n {\n type: ClearSignContextType.NFT,\n payload: \"payload-2\",\n },\n ];\n contextModuleMock.getContexts.mockResolvedValueOnce(clearSignContexts);\n apiMock.getDeviceSessionState.mockReturnValueOnce({\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\n // WHEN\n const result = await new BuildBaseContexts(\n apiMock,\n defaultArgs,\n getWeb3ChecksFactoryMock,\n ).run();\n\n // THEN\n expect(result).toEqual({\n clearSignContexts: [clearSignContexts[1], clearSignContexts[3]],\n clearSignContextsOptional: [],\n clearSigningType: ClearSigningType.BASIC,\n });\n });\n\n it(\"should exclude generic-parser contexts from the result on old apps\", async () => {\n // GIVEN\n const clearSignContexts: ClearSignContext[] = [\n {\n type: ClearSignContextType.TRANSACTION_INFO,\n payload: \"transaction_info\",\n certificate: defaultCertificate,\n },\n {\n type: ClearSignContextType.TOKEN,\n payload: \"payload-1\",\n },\n {\n type: ClearSignContextType.TRANSACTION_FIELD_DESCRIPTION,\n payload: \"transaction_field\",\n },\n {\n type: ClearSignContextType.NFT,\n payload: \"payload-2\",\n },\n {\n type: ClearSignContextType.ENUM,\n payload: \"enum\",\n id: 1,\n value: 2,\n certificate: defaultCertificate,\n },\n ];\n contextModuleMock.getContexts.mockResolvedValueOnce(clearSignContexts);\n apiMock.getDeviceSessionState.mockReturnValueOnce({\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\n // WHEN\n const result = await new BuildBaseContexts(\n apiMock,\n defaultArgs,\n getWeb3ChecksFactoryMock,\n ).run();\n\n // THEN\n expect(result).toEqual({\n clearSignContexts: [clearSignContexts[1], clearSignContexts[3]],\n clearSignContextsOptional: [],\n clearSigningType: ClearSigningType.BASIC,\n });\n });\n\n it(\"should exclude generic-parser contexts from the result if no transaction_info was found\", async () => {\n // GIVEN\n const clearSignContexts: ClearSignContext[] = [\n {\n type: ClearSignContextType.TRANSACTION_FIELD_DESCRIPTION,\n payload: \"transaction_field\",\n },\n {\n type: ClearSignContextType.TOKEN,\n payload: \"payload-1\",\n },\n {\n type: ClearSignContextType.ENUM,\n payload: \"enum\",\n id: 1,\n value: 2,\n },\n {\n type: ClearSignContextType.NFT,\n payload: \"payload-2\",\n },\n ];\n contextModuleMock.getContexts.mockResolvedValueOnce(clearSignContexts);\n apiMock.getDeviceSessionState.mockReturnValueOnce({\n sessionStateType: DeviceSessionStateType.ReadyWithoutSecureChannel,\n deviceStatus: DeviceStatus.CONNECTED,\n installedApps: [],\n currentApp: { name: \"Ethereum\", version: \"1.14.0\" },\n deviceModelId: DeviceModelId.FLEX,\n isSecureConnectionAllowed: false,\n });\n\n // WHEN\n const result = await new BuildBaseContexts(\n apiMock,\n defaultArgs,\n getWeb3ChecksFactoryMock,\n ).run();\n\n // THEN\n expect(result).toEqual({\n clearSignContexts: [clearSignContexts[1], clearSignContexts[3]],\n clearSignContextsOptional: [],\n clearSigningType: ClearSigningType.BASIC,\n });\n });\n\n it(\"should exclude legacy contexts from the result for generic-parser transactions\", async () => {\n // GIVEN\n const clearSignContexts: ClearSignContext[] = [\n {\n type: ClearSignContextType.TOKEN,\n payload: \"payload-1\",\n },\n {\n type: ClearSignContextType.TRANSACTION_INFO,\n payload: \"payload-2\",\n certificate: defaultCertificate,\n },\n {\n type: ClearSignContextType.EXTERNAL_PLUGIN,\n payload: \"payload-3\",\n },\n {\n type: ClearSignContextType.TRANSACTION_FIELD_DESCRIPTION,\n payload: \"payload-4\",\n },\n {\n type: ClearSignContextType.ENUM,\n payload: \"payload-5\",\n id: 1,\n value: 2,\n certificate: defaultCertificate,\n },\n ];\n contextModuleMock.getContexts.mockResolvedValueOnce(clearSignContexts);\n apiMock.getDeviceSessionState.mockReturnValueOnce({\n sessionStateType: DeviceSessionStateType.ReadyWithoutSecureChannel,\n deviceStatus: DeviceStatus.CONNECTED,\n installedApps: [],\n currentApp: { name: \"Ethereum\", version: \"1.15.0\" },\n deviceModelId: DeviceModelId.FLEX,\n isSecureConnectionAllowed: false,\n });\n\n // WHEN\n const result = await new BuildBaseContexts(\n apiMock,\n defaultArgs,\n getWeb3ChecksFactoryMock,\n ).run();\n\n // THEN\n expect(result).toEqual({\n clearSignContexts: [clearSignContexts[1], clearSignContexts[3]],\n clearSignContextsOptional: [clearSignContexts[4]],\n clearSigningType: ClearSigningType.EIP7730,\n });\n });\n\n it(\"should exclude generic-parser contexts with a nano s device\", async () => {\n // GIVEN\n const clearSignContexts: ClearSignContext[] = [\n {\n type: ClearSignContextType.TOKEN,\n payload: \"payload-1\",\n },\n {\n type: ClearSignContextType.TRANSACTION_INFO,\n payload: \"payload-2\",\n certificate: defaultCertificate,\n },\n {\n type: ClearSignContextType.TRANSACTION_FIELD_DESCRIPTION,\n payload: \"payload-3\",\n },\n {\n type: ClearSignContextType.ENUM,\n payload: \"payload-4\",\n id: 1,\n value: 2,\n certificate: defaultCertificate,\n },\n ];\n contextModuleMock.getContexts.mockResolvedValueOnce(clearSignContexts);\n apiMock.getDeviceSessionState.mockReturnValueOnce({\n sessionStateType: DeviceSessionStateType.ReadyWithoutSecureChannel,\n deviceStatus: DeviceStatus.CONNECTED,\n installedApps: [],\n currentApp: { name: \"Ethereum\", version: \"1.14.0\" },\n deviceModelId: DeviceModelId.NANO_S,\n isSecureConnectionAllowed: false,\n });\n\n // WHEN\n const result = await new BuildBaseContexts(\n apiMock,\n defaultArgs,\n getWeb3ChecksFactoryMock,\n ).run();\n\n // THEN\n expect(result).toEqual({\n clearSignContexts: [clearSignContexts[0]],\n clearSignContextsOptional: [],\n clearSigningType: ClearSigningType.BASIC,\n });\n });\n\n it(\"should exclude generic-parser contexts with an old app version\", async () => {\n // GIVEN\n const clearSignContexts: ClearSignContext[] = [\n {\n type: ClearSignContextType.TOKEN,\n payload: \"payload-1\",\n },\n {\n type: ClearSignContextType.TRANSACTION_INFO,\n payload: \"payload-2\",\n certificate: defaultCertificate,\n },\n {\n type: ClearSignContextType.TRANSACTION_FIELD_DESCRIPTION,\n payload: \"payload-3\",\n },\n {\n type: ClearSignContextType.ENUM,\n payload: \"payload-4\",\n id: 1,\n value: 2,\n certificate: defaultCertificate,\n },\n ];\n contextModuleMock.getContexts.mockResolvedValueOnce(clearSignContexts);\n apiMock.getDeviceSessionState.mockReturnValueOnce({\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\n // WHEN\n const result = await new BuildBaseContexts(\n apiMock,\n defaultArgs,\n getWeb3ChecksFactoryMock,\n ).run();\n\n // THEN\n expect(result).toEqual({\n clearSignContexts: [clearSignContexts[0]],\n clearSignContextsOptional: [],\n clearSigningType: ClearSigningType.BASIC,\n });\n });\n\n it(\"should exclude generic-parser contexts with a non ready device\", async () => {\n // GIVEN\n const clearSignContexts: ClearSignContext[] = [\n {\n type: ClearSignContextType.TOKEN,\n payload: \"payload-1\",\n },\n {\n type: ClearSignContextType.TRANSACTION_INFO,\n payload: \"payload-2\",\n certificate: defaultCertificate,\n },\n {\n type: ClearSignContextType.TRANSACTION_FIELD_DESCRIPTION,\n payload: \"payload-3\",\n },\n {\n type: ClearSignContextType.ENUM,\n payload: \"payload-4\",\n id: 1,\n value: 2,\n certificate: defaultCertificate,\n },\n ];\n contextModuleMock.getContexts.mockResolvedValueOnce(clearSignContexts);\n apiMock.getDeviceSessionState.mockReturnValueOnce({\n sessionStateType: DeviceSessionStateType.Connected,\n deviceStatus: DeviceStatus.NOT_CONNECTED,\n deviceModelId: DeviceModelId.FLEX,\n });\n\n // WHEN\n const result = await new BuildBaseContexts(\n apiMock,\n defaultArgs,\n getWeb3ChecksFactoryMock,\n ).run();\n\n // THEN\n expect(result).toEqual({\n clearSignContexts: [clearSignContexts[0]],\n clearSignContextsOptional: [],\n clearSigningType: ClearSigningType.BASIC,\n });\n });\n\n it(\"should return no clear sign context if the transaction info certificate is missing\", async () => {\n // GIVEN\n const clearSignContexts: ClearSignContext[] = [\n {\n type: ClearSignContextType.TRANSACTION_INFO,\n payload: \"payload-1\",\n },\n {\n type: ClearSignContextType.TRANSACTION_FIELD_DESCRIPTION,\n payload: \"payload-2\",\n },\n {\n type: ClearSignContextType.ENUM,\n payload: \"payload-3\",\n id: 1,\n value: 2,\n },\n ];\n contextModuleMock.getContexts.mockResolvedValueOnce(clearSignContexts);\n apiMock.getDeviceSessionState.mockReturnValueOnce({\n sessionStateType: DeviceSessionStateType.ReadyWithoutSecureChannel,\n deviceStatus: DeviceStatus.CONNECTED,\n installedApps: [],\n currentApp: { name: \"Ethereum\", version: \"1.17.0\" },\n deviceModelId: DeviceModelId.FLEX,\n isSecureConnectionAllowed: false,\n });\n\n // WHEN\n const result = await new BuildBaseContexts(\n apiMock,\n defaultArgs,\n getWeb3ChecksFactoryMock,\n ).run();\n\n // THEN\n expect(result).toEqual({\n clearSignContexts: [],\n clearSignContextsOptional: [],\n clearSigningType: ClearSigningType.BASIC,\n });\n });\n\n it(\"should not return web3check if the transaction is undefined\", async () => {\n // GIVEN\n const clearSignContexts: ClearSignContext[] = [];\n contextModuleMock.getContexts.mockResolvedValueOnce(clearSignContexts);\n apiMock.getDeviceSessionState.mockReturnValueOnce({\n sessionStateType: DeviceSessionStateType.ReadyWithoutSecureChannel,\n deviceStatus: DeviceStatus.CONNECTED,\n installedApps: [],\n currentApp: { name: \"Ethereum\", version: \"1.17.0\" },\n deviceModelId: DeviceModelId.FLEX,\n isSecureConnectionAllowed: false,\n });\n\n // WHEN\n await new BuildBaseContexts(\n apiMock,\n { ...defaultArgs, transaction: undefined },\n getWeb3ChecksFactoryMock,\n ).run();\n\n // THEN\n expect(getWeb3ChecksFactoryMock).not.toHaveBeenCalled();\n });\n});\n"],
5
- "mappings": "aAAA,IAAAA,EAIO,oCACPC,EAOO,2CACPC,EAA4B,kBAG5BC,EAAiC,uCACjCC,EAAgD,6EAEhDC,EAGO,+BACPC,EAAiC,8BAEjC,SAAS,oBAAqB,IAAM,CAClC,MAAMC,EAAoB,CACxB,gBAAiB,GAAG,GAAG,EACvB,YAAa,GAAG,GAAG,EACnB,oBAAqB,GAAG,GAAG,EAC3B,cAAe,GAAG,GAAG,EACrB,iBAAkB,GAAG,GAAG,CAC1B,EACMC,EAAiB,CACrB,OAAQ,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0BAA2B,EAC7B,CAAC,EAGD,MAAMO,EAAS,MAAM,IAAI,oBACvBP,EACAD,EACAE,CACF,EAAE,IAAI,EAGN,OAAOM,CAAM,EAAE,QAAQ,CACrB,kBAAmB,CAAC,EACpB,0BAA2B,CAAC,EAC5B,iBAAkB,mBAAiB,KACrC,CAAC,CACH,CAAC,EAED,GAAG,8DAA+D,SAAY,CAE5E,MAAMF,EAAwC,CAAC,EAC/CV,EAAkB,YAAY,sBAAsBU,CAAiB,EACrEL,EAAQ,sBAAsB,oBAAoB,CAChD,iBAAkB,yBAAuB,0BACzC,aAAc,eAAa,UAC3B,cAAe,CAAC,EAChB,WAAY,CAAE,KAAM,WAAY,QAAS,QAAS,EAClD,cAAe,gBAAc,KAC7B,0BAA2B,EAC7B,CAAC,EAGD,MAAM,IAAI,oBACRA,EACA,CAAE,GAAGD,EAAa,YAAa,MAAU,EACzCE,CACF,EAAE,IAAI,EAGN,OAAOA,CAAwB,EAAE,IAAI,iBAAiB,CACxD,CAAC,CACH,CAAC",
6
- "names": ["import_context_module", "import_device_management_kit", "import_ethers", "import_ClearSigningType", "import_makeInternalApi", "import_BuildBaseContexts", "import_GetWeb3CheckTask", "contextModuleMock", "defaultOptions", "defaultTransaction", "defaultCertificate", "defaultArgs", "apiMock", "getWeb3ChecksFactoryMock", "createAppConfig", "web3ChecksEnabled", "task", "clearSignContexts", "clearSignContextsOptional", "result", "expectedWeb3Check"]
4
+ "sourcesContent": ["import {\n type ClearSignContext,\n ClearSignContextType,\n type PkiCertificate,\n} from \"@ledgerhq/context-module\";\nimport {\n CommandResultFactory,\n DeviceModelId,\n DeviceSessionStateType,\n DeviceStatus,\n hexaStringToBuffer,\n} from \"@ledgerhq/device-management-kit\";\nimport { Transaction } from \"ethers\";\n\nimport type { GetConfigCommandResponse } from \"@api/app-binder/GetConfigCommandTypes\";\nimport { ClearSigningType } from \"@api/model/ClearSigningType\";\nimport { makeDeviceActionInternalApiMock } from \"@internal/app-binder/device-action/__test-utils__/makeInternalApi\";\n\nimport {\n BASE_CONTEXT_TYPES_FILTER,\n BuildBaseContexts,\n type BuildBaseContextsArgs,\n} from \"./BuildBaseContexts\";\n\ndescribe(\"BuildBaseContexts\", () => {\n const contextModuleMock = {\n getFieldContext: vi.fn(),\n getContexts: vi.fn(),\n getTypedDataFilters: vi.fn(),\n getSolanaContext: vi.fn(),\n };\n const defaultOptions = {\n domain: \"domain-name.eth\",\n };\n const defaultTransaction: Uint8Array = hexaStringToBuffer(\n Transaction.from({\n chainId: 1n,\n nonce: 0,\n data: \"0x\",\n }).unsignedSerialized,\n )!;\n const defaultCertificate: PkiCertificate = {\n keyUsageNumber: 1,\n payload: new Uint8Array([0x01, 0x02, 0x03]),\n };\n\n let defaultArgs: BuildBaseContextsArgs;\n const apiMock = makeDeviceActionInternalApiMock();\n\n function createAppConfig(\n web3ChecksEnabled: boolean,\n ): GetConfigCommandResponse {\n return {\n blindSigningEnabled: false,\n web3ChecksEnabled,\n web3ChecksOptIn: false,\n version: \"1.13.0\",\n };\n }\n\n beforeEach(() => {\n vi.resetAllMocks();\n apiMock.sendCommand.mockResolvedValue(\n CommandResultFactory({ data: { challenge: \"challenge\" } }),\n );\n\n defaultArgs = {\n contextModule: contextModuleMock,\n subset: { chainId: 1, to: undefined, data: \"0x\", selector: \"0x\" },\n transaction: defaultTransaction,\n options: defaultOptions,\n appConfig: createAppConfig(false),\n };\n });\n\n it(\"should build the transaction context without clear sign contexts\", async () => {\n // GIVEN\n const clearSignContexts: ClearSignContext[] = [];\n const clearSignContextsOptional: ClearSignContext[] = [];\n contextModuleMock.getContexts.mockResolvedValueOnce(clearSignContexts);\n apiMock.getDeviceSessionState.mockReturnValueOnce({\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\n // WHEN\n const result = await new BuildBaseContexts(apiMock, {\n ...defaultArgs,\n appConfig: createAppConfig(true),\n }).run();\n\n // THEN\n expect(result).toEqual({\n clearSignContexts,\n clearSignContextsOptional,\n clearSigningType: ClearSigningType.BASIC,\n });\n });\n\n it(\"should build the transaction context with transaction check and generic-parser clear sign contexts\", async () => {\n // GIVEN\n const clearSignContexts: ClearSignContext[] = [\n {\n type: ClearSignContextType.TRANSACTION_INFO,\n payload: \"payload-1\",\n certificate: defaultCertificate,\n },\n {\n type: ClearSignContextType.TRANSACTION_FIELD_DESCRIPTION,\n payload: \"payload-2\",\n },\n {\n type: ClearSignContextType.ENUM,\n payload: \"payload-3\",\n id: 1,\n value: 2,\n certificate: defaultCertificate,\n },\n {\n type: ClearSignContextType.TRANSACTION_FIELD_DESCRIPTION,\n payload: \"payload-4\",\n },\n ];\n const expectedTxCheck = {\n type: ClearSignContextType.TRANSACTION_CHECK,\n payload: \"transactionCheck\",\n };\n contextModuleMock.getContexts.mockResolvedValueOnce([\n ...clearSignContexts,\n expectedTxCheck,\n ]);\n apiMock.getDeviceSessionState.mockReturnValueOnce({\n sessionStateType: DeviceSessionStateType.ReadyWithoutSecureChannel,\n deviceStatus: DeviceStatus.CONNECTED,\n installedApps: [],\n currentApp: { name: \"Ethereum\", version: \"1.15.0\" },\n deviceModelId: DeviceModelId.FLEX,\n isSecureConnectionAllowed: false,\n });\n\n // WHEN\n const result = await new BuildBaseContexts(apiMock, {\n ...defaultArgs,\n appConfig: createAppConfig(true),\n }).run();\n\n // THEN\n expect(result).toEqual({\n clearSignContexts: [\n expectedTxCheck,\n clearSignContexts[0],\n clearSignContexts[1],\n clearSignContexts[3],\n ],\n clearSignContextsOptional: [clearSignContexts[2]],\n clearSigningType: ClearSigningType.EIP7730,\n });\n });\n\n it(\"should build the transaction context with transaction check and generic-parser clear sign contexts in the correct order\", async () => {\n // GIVEN\n const clearSignContexts: ClearSignContext[] = [\n {\n type: ClearSignContextType.ENUM,\n payload: \"payload-3\",\n id: 1,\n value: 2,\n certificate: defaultCertificate,\n },\n {\n type: ClearSignContextType.TRANSACTION_FIELD_DESCRIPTION,\n payload: \"payload-4\",\n },\n {\n type: ClearSignContextType.TRANSACTION_FIELD_DESCRIPTION,\n payload: \"payload-2\",\n },\n {\n type: ClearSignContextType.TRANSACTION_INFO,\n payload: \"payload-1\",\n certificate: defaultCertificate,\n },\n ];\n const expectedTxCheck = {\n type: ClearSignContextType.TRANSACTION_CHECK,\n payload: \"transactionCheck\",\n };\n contextModuleMock.getContexts.mockResolvedValueOnce([\n ...clearSignContexts,\n expectedTxCheck,\n ]);\n apiMock.getDeviceSessionState.mockReturnValueOnce({\n sessionStateType: DeviceSessionStateType.ReadyWithoutSecureChannel,\n deviceStatus: DeviceStatus.CONNECTED,\n installedApps: [],\n currentApp: { name: \"Ethereum\", version: \"1.15.0\" },\n deviceModelId: DeviceModelId.FLEX,\n isSecureConnectionAllowed: false,\n });\n\n // WHEN\n const result = await new BuildBaseContexts(apiMock, {\n ...defaultArgs,\n appConfig: createAppConfig(true),\n }).run();\n\n // THEN\n expect(result).toEqual({\n clearSignContexts: [\n expectedTxCheck, // transaction check\n clearSignContexts[3], // transaction info\n clearSignContexts[1], // transaction field description\n clearSignContexts[2], // transaction field description\n ],\n clearSignContextsOptional: [clearSignContexts[0]], // enum\n clearSigningType: ClearSigningType.EIP7730,\n });\n });\n\n it(\"should build the transaction context with clear sign contexts\", async () => {\n // GIVEN\n const clearSignContexts: ClearSignContext[] = [\n {\n type: ClearSignContextType.TRANSACTION_CHECK,\n payload: \"transactionCheck\",\n },\n {\n type: ClearSignContextType.TOKEN,\n payload: \"payload-1\",\n },\n {\n type: ClearSignContextType.NFT,\n payload: \"payload-2\",\n },\n ];\n contextModuleMock.getContexts.mockResolvedValueOnce(clearSignContexts);\n apiMock.getDeviceSessionState.mockReturnValueOnce({\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\n // WHEN\n const result = await new BuildBaseContexts(apiMock, defaultArgs).run();\n\n // THEN\n expect(result).toEqual({\n clearSignContexts,\n clearSignContextsOptional: [],\n clearSigningType: ClearSigningType.BASIC,\n });\n });\n\n it(\"should build the transaction context with generic-parser context\", async () => {\n // GIVEN\n const clearSignContexts: ClearSignContext[] = [\n {\n type: ClearSignContextType.TRANSACTION_INFO,\n payload: \"payload-1\",\n certificate: defaultCertificate,\n },\n {\n type: ClearSignContextType.TRANSACTION_FIELD_DESCRIPTION,\n payload: \"payload-2\",\n },\n {\n type: ClearSignContextType.ENUM,\n payload: \"payload-3\",\n id: 1,\n value: 2,\n certificate: defaultCertificate,\n },\n {\n type: ClearSignContextType.TRANSACTION_FIELD_DESCRIPTION,\n payload: \"payload-4\",\n },\n ];\n contextModuleMock.getContexts.mockResolvedValueOnce(clearSignContexts);\n apiMock.getDeviceSessionState.mockReturnValueOnce({\n sessionStateType: DeviceSessionStateType.ReadyWithoutSecureChannel,\n deviceStatus: DeviceStatus.CONNECTED,\n installedApps: [],\n currentApp: { name: \"Ethereum\", version: \"1.15.0\" },\n deviceModelId: DeviceModelId.FLEX,\n isSecureConnectionAllowed: false,\n });\n\n // WHEN\n const result = await new BuildBaseContexts(apiMock, defaultArgs).run();\n\n // THEN\n expect(result).toEqual({\n clearSignContexts: [\n clearSignContexts[0],\n clearSignContexts[1],\n clearSignContexts[3],\n ],\n clearSignContextsOptional: [clearSignContexts[2]],\n clearSigningType: ClearSigningType.EIP7730,\n });\n });\n\n it(\"should build the transaction context with proxy delegate call context\", async () => {\n // GIVEN\n const clearSignContexts: ClearSignContext[] = [\n {\n type: ClearSignContextType.TRANSACTION_INFO,\n payload: \"payload-1\",\n certificate: defaultCertificate,\n },\n {\n type: ClearSignContextType.PROXY_INFO,\n payload: \"payload-2\",\n },\n ];\n const clearSignContextsOptional: ClearSignContext[] = [];\n contextModuleMock.getContexts.mockResolvedValueOnce(clearSignContexts);\n apiMock.getDeviceSessionState.mockReturnValueOnce({\n sessionStateType: DeviceSessionStateType.ReadyWithoutSecureChannel,\n deviceStatus: DeviceStatus.CONNECTED,\n installedApps: [],\n currentApp: { name: \"Ethereum\", version: \"1.15.0\" },\n deviceModelId: DeviceModelId.FLEX,\n isSecureConnectionAllowed: false,\n });\n\n // WHEN\n const result = await new BuildBaseContexts(apiMock, defaultArgs).run();\n\n // THEN\n expect(result).toEqual({\n clearSignContexts: [clearSignContexts[1], clearSignContexts[0]],\n clearSignContextsOptional,\n clearSigningType: ClearSigningType.EIP7730,\n });\n });\n\n it(\"should call the context module with the correct parameters if transaction check is enabled\", async () => {\n // GIVEN\n const clearSignContexts: ClearSignContext[] = [];\n contextModuleMock.getContexts.mockResolvedValueOnce(clearSignContexts);\n apiMock.getDeviceSessionState.mockReturnValueOnce({\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\n // WHEN\n await new BuildBaseContexts(apiMock, {\n ...defaultArgs,\n appConfig: createAppConfig(true),\n }).run();\n\n // THEN\n expect(contextModuleMock.getContexts).toHaveBeenCalledWith(\n {\n deviceModelId: DeviceModelId.FLEX,\n challenge: \"challenge\",\n domain: \"domain-name.eth\",\n transaction: defaultTransaction,\n ...defaultArgs.subset,\n },\n BASE_CONTEXT_TYPES_FILTER,\n );\n });\n\n it(\"should call the context module with the correct parameters if transaction check is disabled\", async () => {\n // GIVEN\n const clearSignContexts: ClearSignContext[] = [];\n contextModuleMock.getContexts.mockResolvedValueOnce(clearSignContexts);\n apiMock.getDeviceSessionState.mockReturnValueOnce({\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\n // WHEN\n await new BuildBaseContexts(apiMock, {\n ...defaultArgs,\n appConfig: createAppConfig(false),\n }).run();\n\n // THEN\n expect(contextModuleMock.getContexts).toHaveBeenCalledWith(\n {\n deviceModelId: DeviceModelId.FLEX,\n challenge: \"challenge\",\n domain: \"domain-name.eth\",\n ...defaultArgs.subset,\n },\n BASE_CONTEXT_TYPES_FILTER,\n );\n });\n\n it(\"should call the context module without challenge for Nano S\", async () => {\n // GIVEN\n const clearSignContexts: ClearSignContext[] = [];\n contextModuleMock.getContexts.mockResolvedValueOnce(clearSignContexts);\n apiMock.getDeviceSessionState.mockReturnValueOnce({\n sessionStateType: DeviceSessionStateType.ReadyWithoutSecureChannel,\n deviceStatus: DeviceStatus.CONNECTED,\n installedApps: [],\n currentApp: { name: \"Ethereum\", version: \"1.12.0\" },\n deviceModelId: DeviceModelId.NANO_S,\n isSecureConnectionAllowed: false,\n });\n\n // WHEN\n await new BuildBaseContexts(apiMock, defaultArgs).run();\n\n // THEN\n expect(contextModuleMock.getContexts).toHaveBeenCalledWith(\n {\n deviceModelId: DeviceModelId.NANO_S,\n domain: \"domain-name.eth\",\n challenge: undefined,\n ...defaultArgs.subset,\n },\n BASE_CONTEXT_TYPES_FILTER,\n );\n });\n\n it(\"should exclude error contexts from the result\", async () => {\n // GIVEN\n const clearSignContexts: ClearSignContext[] = [\n {\n type: ClearSignContextType.ERROR,\n error: new Error(\"error\"),\n },\n {\n type: ClearSignContextType.TOKEN,\n payload: \"payload-1\",\n },\n {\n type: ClearSignContextType.ERROR,\n error: new Error(\"error\"),\n },\n {\n type: ClearSignContextType.NFT,\n payload: \"payload-2\",\n },\n ];\n contextModuleMock.getContexts.mockResolvedValueOnce(clearSignContexts);\n apiMock.getDeviceSessionState.mockReturnValueOnce({\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\n // WHEN\n const result = await new BuildBaseContexts(apiMock, defaultArgs).run();\n\n // THEN\n expect(result).toEqual({\n clearSignContexts: [clearSignContexts[1], clearSignContexts[3]],\n clearSignContextsOptional: [],\n clearSigningType: ClearSigningType.BASIC,\n });\n });\n\n it(\"should exclude generic-parser contexts from the result on old apps\", async () => {\n // GIVEN\n const clearSignContexts: ClearSignContext[] = [\n {\n type: ClearSignContextType.TRANSACTION_INFO,\n payload: \"transaction_info\",\n certificate: defaultCertificate,\n },\n {\n type: ClearSignContextType.TOKEN,\n payload: \"payload-1\",\n },\n {\n type: ClearSignContextType.TRANSACTION_FIELD_DESCRIPTION,\n payload: \"transaction_field\",\n },\n {\n type: ClearSignContextType.NFT,\n payload: \"payload-2\",\n },\n {\n type: ClearSignContextType.ENUM,\n payload: \"enum\",\n id: 1,\n value: 2,\n certificate: defaultCertificate,\n },\n ];\n contextModuleMock.getContexts.mockResolvedValueOnce(clearSignContexts);\n apiMock.getDeviceSessionState.mockReturnValueOnce({\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\n // WHEN\n const result = await new BuildBaseContexts(apiMock, defaultArgs).run();\n\n // THEN\n expect(result).toEqual({\n clearSignContexts: [clearSignContexts[1], clearSignContexts[3]],\n clearSignContextsOptional: [],\n clearSigningType: ClearSigningType.BASIC,\n });\n });\n\n it(\"should exclude generic-parser contexts from the result if no transaction_info was found\", async () => {\n // GIVEN\n const clearSignContexts: ClearSignContext[] = [\n {\n type: ClearSignContextType.TRANSACTION_FIELD_DESCRIPTION,\n payload: \"transaction_field\",\n },\n {\n type: ClearSignContextType.TOKEN,\n payload: \"payload-1\",\n },\n {\n type: ClearSignContextType.ENUM,\n payload: \"enum\",\n id: 1,\n value: 2,\n },\n {\n type: ClearSignContextType.NFT,\n payload: \"payload-2\",\n },\n ];\n contextModuleMock.getContexts.mockResolvedValueOnce(clearSignContexts);\n apiMock.getDeviceSessionState.mockReturnValueOnce({\n sessionStateType: DeviceSessionStateType.ReadyWithoutSecureChannel,\n deviceStatus: DeviceStatus.CONNECTED,\n installedApps: [],\n currentApp: { name: \"Ethereum\", version: \"1.14.0\" },\n deviceModelId: DeviceModelId.FLEX,\n isSecureConnectionAllowed: false,\n });\n\n // WHEN\n const result = await new BuildBaseContexts(apiMock, defaultArgs).run();\n\n // THEN\n expect(result).toEqual({\n clearSignContexts: [clearSignContexts[1], clearSignContexts[3]],\n clearSignContextsOptional: [],\n clearSigningType: ClearSigningType.BASIC,\n });\n });\n\n it(\"should exclude legacy contexts from the result for generic-parser transactions\", async () => {\n // GIVEN\n const clearSignContexts: ClearSignContext[] = [\n {\n type: ClearSignContextType.TOKEN,\n payload: \"payload-1\",\n },\n {\n type: ClearSignContextType.TRANSACTION_INFO,\n payload: \"payload-2\",\n certificate: defaultCertificate,\n },\n {\n type: ClearSignContextType.EXTERNAL_PLUGIN,\n payload: \"payload-3\",\n },\n {\n type: ClearSignContextType.TRANSACTION_FIELD_DESCRIPTION,\n payload: \"payload-4\",\n },\n {\n type: ClearSignContextType.ENUM,\n payload: \"payload-5\",\n id: 1,\n value: 2,\n certificate: defaultCertificate,\n },\n ];\n contextModuleMock.getContexts.mockResolvedValueOnce(clearSignContexts);\n apiMock.getDeviceSessionState.mockReturnValueOnce({\n sessionStateType: DeviceSessionStateType.ReadyWithoutSecureChannel,\n deviceStatus: DeviceStatus.CONNECTED,\n installedApps: [],\n currentApp: { name: \"Ethereum\", version: \"1.15.0\" },\n deviceModelId: DeviceModelId.FLEX,\n isSecureConnectionAllowed: false,\n });\n\n // WHEN\n const result = await new BuildBaseContexts(apiMock, defaultArgs).run();\n\n // THEN\n expect(result).toEqual({\n clearSignContexts: [clearSignContexts[1], clearSignContexts[3]],\n clearSignContextsOptional: [clearSignContexts[4]],\n clearSigningType: ClearSigningType.EIP7730,\n });\n });\n\n it(\"should exclude generic-parser contexts with a nano s device\", async () => {\n // GIVEN\n const clearSignContexts: ClearSignContext[] = [\n {\n type: ClearSignContextType.TOKEN,\n payload: \"payload-1\",\n },\n {\n type: ClearSignContextType.TRANSACTION_INFO,\n payload: \"payload-2\",\n certificate: defaultCertificate,\n },\n {\n type: ClearSignContextType.TRANSACTION_FIELD_DESCRIPTION,\n payload: \"payload-3\",\n },\n {\n type: ClearSignContextType.ENUM,\n payload: \"payload-4\",\n id: 1,\n value: 2,\n certificate: defaultCertificate,\n },\n ];\n contextModuleMock.getContexts.mockResolvedValueOnce(clearSignContexts);\n apiMock.getDeviceSessionState.mockReturnValueOnce({\n sessionStateType: DeviceSessionStateType.ReadyWithoutSecureChannel,\n deviceStatus: DeviceStatus.CONNECTED,\n installedApps: [],\n currentApp: { name: \"Ethereum\", version: \"1.14.0\" },\n deviceModelId: DeviceModelId.NANO_S,\n isSecureConnectionAllowed: false,\n });\n\n // WHEN\n const result = await new BuildBaseContexts(apiMock, defaultArgs).run();\n\n // THEN\n expect(result).toEqual({\n clearSignContexts: [clearSignContexts[0]],\n clearSignContextsOptional: [],\n clearSigningType: ClearSigningType.BASIC,\n });\n });\n\n it(\"should exclude generic-parser contexts with an old app version\", async () => {\n // GIVEN\n const clearSignContexts: ClearSignContext[] = [\n {\n type: ClearSignContextType.TOKEN,\n payload: \"payload-1\",\n },\n {\n type: ClearSignContextType.TRANSACTION_INFO,\n payload: \"payload-2\",\n certificate: defaultCertificate,\n },\n {\n type: ClearSignContextType.TRANSACTION_FIELD_DESCRIPTION,\n payload: \"payload-3\",\n },\n {\n type: ClearSignContextType.ENUM,\n payload: \"payload-4\",\n id: 1,\n value: 2,\n certificate: defaultCertificate,\n },\n ];\n contextModuleMock.getContexts.mockResolvedValueOnce(clearSignContexts);\n apiMock.getDeviceSessionState.mockReturnValueOnce({\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\n // WHEN\n const result = await new BuildBaseContexts(apiMock, defaultArgs).run();\n\n // THEN\n expect(result).toEqual({\n clearSignContexts: [clearSignContexts[0]],\n clearSignContextsOptional: [],\n clearSigningType: ClearSigningType.BASIC,\n });\n });\n\n it(\"should exclude generic-parser contexts with a non ready device\", async () => {\n // GIVEN\n const clearSignContexts: ClearSignContext[] = [\n {\n type: ClearSignContextType.TOKEN,\n payload: \"payload-1\",\n },\n {\n type: ClearSignContextType.TRANSACTION_INFO,\n payload: \"payload-2\",\n certificate: defaultCertificate,\n },\n {\n type: ClearSignContextType.TRANSACTION_FIELD_DESCRIPTION,\n payload: \"payload-3\",\n },\n {\n type: ClearSignContextType.ENUM,\n payload: \"payload-4\",\n id: 1,\n value: 2,\n certificate: defaultCertificate,\n },\n ];\n contextModuleMock.getContexts.mockResolvedValueOnce(clearSignContexts);\n apiMock.getDeviceSessionState.mockReturnValueOnce({\n sessionStateType: DeviceSessionStateType.Connected,\n deviceStatus: DeviceStatus.NOT_CONNECTED,\n deviceModelId: DeviceModelId.FLEX,\n });\n\n // WHEN\n const result = await new BuildBaseContexts(apiMock, defaultArgs).run();\n\n // THEN\n expect(result).toEqual({\n clearSignContexts: [clearSignContexts[0]],\n clearSignContextsOptional: [],\n clearSigningType: ClearSigningType.BASIC,\n });\n });\n\n it(\"should return no clear sign context if the transaction info certificate is missing\", async () => {\n // GIVEN\n const clearSignContexts: ClearSignContext[] = [\n {\n type: ClearSignContextType.TRANSACTION_INFO,\n payload: \"payload-1\",\n },\n {\n type: ClearSignContextType.TRANSACTION_FIELD_DESCRIPTION,\n payload: \"payload-2\",\n },\n {\n type: ClearSignContextType.ENUM,\n payload: \"payload-3\",\n id: 1,\n value: 2,\n },\n ];\n contextModuleMock.getContexts.mockResolvedValueOnce(clearSignContexts);\n apiMock.getDeviceSessionState.mockReturnValueOnce({\n sessionStateType: DeviceSessionStateType.ReadyWithoutSecureChannel,\n deviceStatus: DeviceStatus.CONNECTED,\n installedApps: [],\n currentApp: { name: \"Ethereum\", version: \"1.17.0\" },\n deviceModelId: DeviceModelId.FLEX,\n isSecureConnectionAllowed: false,\n });\n\n // WHEN\n const result = await new BuildBaseContexts(apiMock, defaultArgs).run();\n\n // THEN\n expect(result).toEqual({\n clearSignContexts: [],\n clearSignContextsOptional: [],\n clearSigningType: ClearSigningType.BASIC,\n });\n });\n});\n"],
5
+ "mappings": "aAAA,IAAAA,EAIO,oCACPC,EAMO,2CACPC,EAA4B,kBAG5BC,EAAiC,uCACjCC,EAAgD,6EAEhDC,EAIO,+BAEP,SAAS,oBAAqB,IAAM,CAClC,MAAMC,EAAoB,CACxB,gBAAiB,GAAG,GAAG,EACvB,YAAa,GAAG,GAAG,EACnB,oBAAqB,GAAG,GAAG,EAC3B,iBAAkB,GAAG,GAAG,CAC1B,EACMC,EAAiB,CACrB,OAAQ,iBACV,EACMC,KAAiC,sBACrC,cAAY,KAAK,CACf,QAAS,GACT,MAAO,EACP,KAAM,IACR,CAAC,EAAE,kBACL,EACMC,EAAqC,CACzC,eAAgB,EAChB,QAAS,IAAI,WAAW,CAAC,EAAM,EAAM,CAAI,CAAC,CAC5C,EAEA,IAAIC,EACJ,MAAMC,KAAU,mCAAgC,EAEhD,SAASC,EACPC,EAC0B,CAC1B,MAAO,CACL,oBAAqB,GACrB,kBAAAA,EACA,gBAAiB,GACjB,QAAS,QACX,CACF,CAEA,WAAW,IAAM,CACf,GAAG,cAAc,EACjBF,EAAQ,YAAY,qBAClB,wBAAqB,CAAE,KAAM,CAAE,UAAW,WAAY,CAAE,CAAC,CAC3D,EAEAD,EAAc,CACZ,cAAeJ,EACf,OAAQ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,aAAc,eAAa,UAC3B,cAAe,CAAC,EAChB,WAAY,CAAE,KAAM,WAAY,QAAS,QAAS,EAClD,cAAe,gBAAc,KAC7B,0BAA2B,EAC7B,CAAC,EAGD,MAAMK,EAAS,MAAM,IAAI,oBAAkBL,EAASD,CAAW,EAAE,IAAI,EAGrE,OAAOM,CAAM,EAAE,QAAQ,CACrB,kBAAmB,CAAC,EACpB,0BAA2B,CAAC,EAC5B,iBAAkB,mBAAiB,KACrC,CAAC,CACH,CAAC,CACH,CAAC",
6
+ "names": ["import_context_module", "import_device_management_kit", "import_ethers", "import_ClearSigningType", "import_makeInternalApi", "import_BuildBaseContexts", "contextModuleMock", "defaultOptions", "defaultTransaction", "defaultCertificate", "defaultArgs", "apiMock", "createAppConfig", "web3ChecksEnabled", "clearSignContexts", "clearSignContextsOptional", "result", "expectedTxCheck"]
7
7
  }
@@ -1,2 +1,2 @@
1
- "use strict";var v=Object.defineProperty;var b=Object.getOwnPropertyDescriptor;var w=Object.getOwnPropertyNames;var A=Object.prototype.hasOwnProperty;var F=(i,e)=>{for(var t in e)v(i,t,{get:e[t],enumerable:!0})},E=(i,e,t,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let a of w(e))!A.call(i,a)&&a!==t&&v(i,a,{get:()=>e[a],enumerable:!(n=b(e,a))||n.enumerable});return i};var W=i=>E(v({},"__esModule",{value:!0}),i);var V={};F(V,{BuildEIP712ContextTask:()=>R,ZERO_ADDRESS:()=>I});module.exports=W(V);var c=require("@ledgerhq/device-management-kit"),r=require("purify-ts"),x=require("../../../api/model/ClearSigningType"),m=require("../../app-binder/command/GetChallengeCommand"),f=require("../../app-binder/task/BuildFullContextsTask"),S=require("../../app-binder/task/GetWeb3CheckTask"),g=require("../../shared/utils/ApplicationChecker"),T=require("../../typed-data/model/Types");const I="0x0000000000000000000000000000000000000000";class R{constructor(e,t,n,a,l,o,C,h,y=(s,d)=>new S.GetWeb3CheckTask(s,d),M=(s,d)=>new f.BuildFullContextsTask(s,d)){this.api=e;this.contextModule=t;this.parser=n;this.transactionParser=a;this.transactionMapper=l;this.data=o;this.derivationPath=C;this.appConfig=h;this.getWeb3ChecksFactory=y;this.buildFullContextFactory=M}async run(){let e=null;this.appConfig.web3ChecksEnabled&&(e=(await this.getWeb3ChecksFactory(this.api,{contextModule:this.contextModule,derivationPath:this.derivationPath,data:this.data}).run()).web3Check);const t=this.parser.parse(this.data);if(t.isLeft())throw t.extract();const{types:n,domain:a,message:l}=t.unsafeCoerce(),o=this.api.getDeviceSessionState();let C=r.Nothing,h={};const y=this.getClearSignVersion(o);if(y.isJust()){let s;const d=await this.api.sendCommand(new m.GetChallengeCommand);(0,c.isSuccessCommandResult)(d)&&(s=d.data.challenge);const k=this.data.domain.verifyingContract?.toLowerCase()||I,P=this.data.domain.chainId||0,D=l.filter(p=>p.value instanceof T.TypedDataValueField).map(p=>({path:p.path,value:p.value.data})),u=await this.contextModule.getTypedDataFilters({verifyingContract:k,chainId:P,version:y.extract(),schema:this.data.types,challenge:s,deviceModelId:o.deviceModelId,fieldsValues:D});u.type==="success"&&(C=(0,r.Just)(u),h=await this.getCalldatasContexts(o,u))}return{derivationPath:this.derivationPath,web3Check:e,types:n,domain:a,message:l,clearSignContext:C,calldatasContexts:h,deviceModelId:o.deviceModelId}}getClearSignVersion(e){return new g.ApplicationChecker(e,this.appConfig).withMinVersionInclusive("1.10.0").excludeDeviceModel(c.DeviceModelId.NANO_S).check()?new g.ApplicationChecker(e,this.appConfig).withMinVersionInclusive("1.12.0").check()?(0,r.Just)("v2"):(0,r.Just)("v1"):r.Nothing}async getCalldatasContexts(e,t){const n={};for(const a in t.calldatas){const{subset:l}=t.calldatas[a],o=await this.buildFullContextFactory(this.api,{contextModule:this.contextModule,mapper:this.transactionMapper,parser:this.transactionParser,options:{},appConfig:this.appConfig,derivationPath:this.derivationPath,subset:l,deviceModelId:e.deviceModelId}).run();o.clearSigningType===x.ClearSigningType.EIP7730&&(n[a]=o.clearSignContexts)}return n}}0&&(module.exports={BuildEIP712ContextTask,ZERO_ADDRESS});
1
+ "use strict";var v=Object.defineProperty;var w=Object.getOwnPropertyDescriptor;var b=Object.getOwnPropertyNames;var F=Object.prototype.hasOwnProperty;var R=(i,e)=>{for(var t in e)v(i,t,{get:e[t],enumerable:!0})},E=(i,e,t,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let a of b(e))!F.call(i,a)&&a!==t&&v(i,a,{get:()=>e[a],enumerable:!(n=w(e,a))||n.enumerable});return i};var V=i=>E(v({},"__esModule",{value:!0}),i);var B={};R(B,{BuildEIP712ContextTask:()=>N,ZERO_ADDRESS:()=>D});module.exports=V(B);var y=require("@ledgerhq/context-module"),l=require("@ledgerhq/device-management-kit"),s=require("purify-ts"),S=require("../../../api/model/ClearSigningType"),T=require("../../app-binder/command/GetChallengeCommand"),I=require("../../app-binder/task/BuildFullContextsTask"),g=require("../../shared/utils/ApplicationChecker"),M=require("../../typed-data/model/Types");const D="0x0000000000000000000000000000000000000000";class N{constructor(e,t,n,a,o,r,m,p,C,u=(x,d)=>new I.BuildFullContextsTask(x,d)){this.api=e;this.contextModule=t;this.parser=n;this.transactionParser=a;this.transactionMapper=o;this.data=r;this.derivationPath=m;this.appConfig=p;this.from=C;this.buildFullContextFactory=u}async run(){const e=this.parser.parse(this.data);if(e.isLeft())throw e.extract();const{types:t,domain:n,message:a}=e.unsafeCoerce(),o=this.api.getDeviceSessionState(),r=o.deviceModelId,m=await this.getTransactionChecks(r);let p=s.Nothing,C={};const u=this.getClearSignVersion(o);if(u.isJust()){let d;const f=await this.api.sendCommand(new T.GetChallengeCommand);(0,l.isSuccessCommandResult)(f)&&(d=f.data.challenge);const P=this.data.domain.verifyingContract?.toLowerCase()||D,A=this.data.domain.chainId||0,k=a.filter(c=>c.value instanceof M.TypedDataValueField).map(c=>({path:c.path,value:c.value.data})),h=await this.contextModule.getTypedDataFilters({verifyingContract:P,chainId:A,version:u.extract(),schema:this.data.types,challenge:d,deviceModelId:o.deviceModelId,fieldsValues:k});h.type==="success"&&(p=(0,s.Just)(h),C=await this.getCalldatasContexts(o,h))}return{derivationPath:this.derivationPath,transactionChecks:m,types:t,domain:n,message:a,clearSignContext:p,calldatasContexts:C,deviceModelId:o.deviceModelId}}async getTransactionChecks(e){if(!this.appConfig.web3ChecksEnabled)return;const t=await this.contextModule.getContexts({deviceModelId:e,data:this.data,from:this.from},[y.ClearSignContextType.TRANSACTION_CHECK]);if(t.length>0&&t[0]?.type===y.ClearSignContextType.TRANSACTION_CHECK)return t[0]}getClearSignVersion(e){return new g.ApplicationChecker(e,this.appConfig).withMinVersionInclusive("1.10.0").excludeDeviceModel(l.DeviceModelId.NANO_S).check()?new g.ApplicationChecker(e,this.appConfig).withMinVersionInclusive("1.12.0").check()?(0,s.Just)("v2"):(0,s.Just)("v1"):s.Nothing}async getCalldatasContexts(e,t){const n={};for(const a in t.calldatas){const{subset:o}=t.calldatas[a],r=await this.buildFullContextFactory(this.api,{contextModule:this.contextModule,mapper:this.transactionMapper,parser:this.transactionParser,options:{},appConfig:this.appConfig,derivationPath:this.derivationPath,subset:o,deviceModelId:e.deviceModelId}).run();r.clearSigningType===S.ClearSigningType.EIP7730&&(n[a]=r.clearSignContexts)}return n}}0&&(module.exports={BuildEIP712ContextTask,ZERO_ADDRESS});
2
2
  //# sourceMappingURL=BuildEIP712ContextTask.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../../src/internal/app-binder/task/BuildEIP712ContextTask.ts"],
4
- "sourcesContent": ["import {\n type ClearSignContextSuccess,\n type ClearSignContextType,\n type ContextModule,\n type TypedDataCalldataIndex,\n type TypedDataClearSignContextSuccess,\n} from \"@ledgerhq/context-module\";\nimport {\n DeviceModelId,\n type DeviceSessionState,\n type InternalApi,\n isSuccessCommandResult,\n} from \"@ledgerhq/device-management-kit\";\nimport { Just, type Maybe, Nothing } from \"purify-ts\";\n\nimport { type GetConfigCommandResponse } from \"@api/app-binder/GetConfigCommandTypes\";\nimport { ClearSigningType } from \"@api/model/ClearSigningType\";\nimport { type TypedData } from \"@api/model/TypedData\";\nimport { GetChallengeCommand } from \"@internal/app-binder/command/GetChallengeCommand\";\nimport {\n BuildFullContextsTask,\n type BuildFullContextsTaskArgs,\n type ContextWithSubContexts,\n} from \"@internal/app-binder/task/BuildFullContextsTask\";\nimport {\n GetWeb3CheckTask,\n type GetWeb3CheckTaskArgs,\n} from \"@internal/app-binder/task/GetWeb3CheckTask\";\nimport { type ProvideEIP712ContextTaskArgs } from \"@internal/app-binder/task/ProvideEIP712ContextTask\";\nimport { ApplicationChecker } from \"@internal/shared/utils/ApplicationChecker\";\nimport { type TransactionMapperService } from \"@internal/transaction/service/mapper/TransactionMapperService\";\nimport { type TransactionParserService } from \"@internal/transaction/service/parser/TransactionParserService\";\nimport { TypedDataValueField } from \"@internal/typed-data/model/Types\";\nimport { type TypedDataParserService } from \"@internal/typed-data/service/TypedDataParserService\";\n\nexport const ZERO_ADDRESS = \"0x0000000000000000000000000000000000000000\";\n\nexport class BuildEIP712ContextTask {\n constructor(\n private readonly api: InternalApi,\n private readonly contextModule: ContextModule,\n private readonly parser: TypedDataParserService,\n private readonly transactionParser: TransactionParserService,\n private readonly transactionMapper: TransactionMapperService,\n private readonly data: TypedData,\n private readonly derivationPath: string,\n private readonly appConfig: GetConfigCommandResponse,\n private readonly getWeb3ChecksFactory = (\n api: InternalApi,\n args: GetWeb3CheckTaskArgs,\n ) => new GetWeb3CheckTask(api, args),\n private readonly buildFullContextFactory = (\n api: InternalApi,\n args: BuildFullContextsTaskArgs,\n ) => new BuildFullContextsTask(api, args),\n ) {}\n\n async run(): Promise<ProvideEIP712ContextTaskArgs> {\n // Run the web3checks if needed\n let web3Check: ClearSignContextSuccess<ClearSignContextType.WEB3_CHECK> | null =\n null;\n if (this.appConfig.web3ChecksEnabled) {\n web3Check = (\n await this.getWeb3ChecksFactory(this.api, {\n contextModule: this.contextModule,\n derivationPath: this.derivationPath,\n data: this.data,\n }).run()\n ).web3Check;\n }\n\n // Clear signing context\n // Parse the message types and values\n const parsed = this.parser.parse(this.data);\n if (parsed.isLeft()) {\n throw parsed.extract();\n }\n const { types, domain, message } = parsed.unsafeCoerce();\n\n // Get clear signing context, if any\n const deviceState = this.api.getDeviceSessionState();\n let clearSignContext: Maybe<TypedDataClearSignContextSuccess> = Nothing;\n let calldatasContexts: Record<\n TypedDataCalldataIndex,\n ContextWithSubContexts[]\n > = {};\n const version = this.getClearSignVersion(deviceState);\n if (version.isJust()) {\n // Get challenge\n let challenge: string | undefined = undefined;\n const challengeRes = await this.api.sendCommand(\n new GetChallengeCommand(),\n );\n if (isSuccessCommandResult(challengeRes)) {\n challenge = challengeRes.data.challenge;\n }\n\n // Get filters\n const verifyingContract =\n this.data.domain.verifyingContract?.toLowerCase() || ZERO_ADDRESS;\n const chainId = this.data.domain.chainId || 0;\n const fieldsValues = message\n .filter((v) => v.value instanceof TypedDataValueField)\n .map((v) => ({\n path: v.path,\n value: (v.value as TypedDataValueField).data,\n }));\n const filters = await this.contextModule.getTypedDataFilters({\n verifyingContract,\n chainId,\n version: version.extract(),\n schema: this.data.types,\n challenge,\n deviceModelId: deviceState.deviceModelId,\n fieldsValues,\n });\n if (filters.type === \"success\") {\n clearSignContext = Just(filters);\n calldatasContexts = await this.getCalldatasContexts(\n deviceState,\n filters,\n );\n }\n }\n\n // Return the args for provide context task\n const provideTaskArgs: ProvideEIP712ContextTaskArgs = {\n derivationPath: this.derivationPath,\n web3Check,\n types,\n domain,\n message,\n clearSignContext,\n calldatasContexts,\n deviceModelId: deviceState.deviceModelId,\n };\n return provideTaskArgs;\n }\n\n private getClearSignVersion(\n deviceState: DeviceSessionState,\n ): Maybe<\"v1\" | \"v2\"> {\n if (\n !new ApplicationChecker(deviceState, this.appConfig)\n .withMinVersionInclusive(\"1.10.0\")\n .excludeDeviceModel(DeviceModelId.NANO_S)\n .check()\n ) {\n return Nothing;\n }\n\n // EIP712 v2 (amount & datetime filters) supported since 1.11.0:\n // https://github.com/LedgerHQ/app-ethereum/blob/develop/doc/ethapp.adoc#1110-1\n // But some issues were still present until 1.12.0 among which:\n // * V2 descriptor with missing token not supported by the app\n // * Empty arrays with filters not correctly handled\n // * Trusted name filters not yet released\n // Therefore it's safer and easier to use V1 filters before 1.12.0:\n // https://github.com/LedgerHQ/app-ethereum/blob/develop/doc/ethapp.adoc#1120\n const shouldUseV2Filters = new ApplicationChecker(\n deviceState,\n this.appConfig,\n )\n .withMinVersionInclusive(\"1.12.0\")\n .check();\n return shouldUseV2Filters ? Just(\"v2\") : Just(\"v1\");\n }\n\n private async getCalldatasContexts(\n deviceState: DeviceSessionState,\n filters: TypedDataClearSignContextSuccess,\n ): Promise<Record<TypedDataCalldataIndex, ContextWithSubContexts[]>> {\n const calldatasContexts: Record<\n TypedDataCalldataIndex,\n ContextWithSubContexts[]\n > = {};\n for (const calldataIndex in filters.calldatas) {\n const { subset } = filters.calldatas[calldataIndex]!;\n const calldataContext = await this.buildFullContextFactory(this.api, {\n contextModule: this.contextModule,\n mapper: this.transactionMapper,\n parser: this.transactionParser,\n options: {},\n appConfig: this.appConfig,\n derivationPath: this.derivationPath,\n subset,\n deviceModelId: deviceState.deviceModelId,\n }).run();\n if (calldataContext.clearSigningType === ClearSigningType.EIP7730) {\n calldatasContexts[calldataIndex] = calldataContext.clearSignContexts;\n }\n }\n return calldatasContexts;\n }\n}\n"],
5
- "mappings": "yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,4BAAAE,EAAA,iBAAAC,IAAA,eAAAC,EAAAJ,GAOA,IAAAK,EAKO,2CACPC,EAA0C,qBAG1CC,EAAiC,uCAEjCC,EAAoC,4DACpCC,EAIO,2DACPC,EAGO,sDAEPC,EAAmC,qDAGnCC,EAAoC,4CAG7B,MAAMT,EAAe,6CAErB,MAAMD,CAAuB,CAClC,YACmBW,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EAAuB,CACtCR,EACAS,IACG,IAAI,mBAAiBT,EAA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Y,cAC3B,aAAAQ,CACF,CAAC,EACGE,EAAQ,OAAS,YACnBT,KAAmB,QAAKS,CAAO,EAC/BR,EAAoB,MAAM,KAAK,qBAC7BF,EACAU,CACF,EAEJ,CAaA,MAVsD,CACpD,eAAgB,KAAK,eACrB,UAAAf,EACA,MAAAE,EACA,OAAAC,EACA,QAAAC,EACA,iBAAAE,EACA,kBAAAC,EACA,cAAeF,EAAY,aAC7B,CAEF,CAEQ,oBACNA,EACoB,CACpB,OACG,IAAI,qBAAmBA,EAAa,KAAK,SAAS,EAChD,wBAAwB,QAAQ,EAChC,mBAAmB,gBAAc,MAAM,EACvC,MAAM,EAagB,IAAI,qBAC7BA,EACA,KAAK,SACP,EACG,wBAAwB,QAAQ,EAChC,MAAM,KACmB,QAAK,IAAI,KAAI,QAAK,IAAI,EAjBzC,SAkBX,CAEA,MAAc,qBACZA,EACAU,EACmE,CACnE,MAAMR,EAGF,CAAC,EACL,UAAWS,KAAiBD,EAAQ,UAAW,CAC7C,KAAM,CAAE,OAAAE,CAAO,EAAIF,EAAQ,UAAUC,CAAa,EAC5CE,EAAkB,MAAM,KAAK,wBAAwB,KAAK,IAAK,CACnE,cAAe,KAAK,cACpB,OAAQ,KAAK,kBACb,OAAQ,KAAK,kBACb,QAAS,CAAC,EACV,UAAW,KAAK,UAChB,eAAgB,KAAK,eACrB,OAAAD,EACA,cAAeZ,EAAY,aAC7B,CAAC,EAAE,IAAI,EACHa,EAAgB,mBAAqB,mBAAiB,UACxDX,EAAkBS,CAAa,EAAIE,EAAgB,kBAEvD,CACA,OAAOX,CACT,CACF",
6
- "names": ["BuildEIP712ContextTask_exports", "__export", "BuildEIP712ContextTask", "ZERO_ADDRESS", "__toCommonJS", "import_device_management_kit", "import_purify_ts", "import_ClearSigningType", "import_GetChallengeCommand", "import_BuildFullContextsTask", "import_GetWeb3CheckTask", "import_ApplicationChecker", "import_Types", "api", "contextModule", "parser", "transactionParser", "transactionMapper", "data", "derivationPath", "appConfig", "getWeb3ChecksFactory", "args", "buildFullContextFactory", "web3Check", "parsed", "types", "domain", "message", "deviceState", "clearSignContext", "calldatasContexts", "version", "challenge", "challengeRes", "verifyingContract", "chainId", "fieldsValues", "v", "filters", "calldataIndex", "subset", "calldataContext"]
4
+ "sourcesContent": ["import {\n type ClearSignContextSuccess,\n ClearSignContextType,\n type ContextModule,\n type TypedDataCalldataIndex,\n type TypedDataClearSignContextSuccess,\n} from \"@ledgerhq/context-module\";\nimport {\n DeviceModelId,\n type DeviceSessionState,\n type InternalApi,\n isSuccessCommandResult,\n} from \"@ledgerhq/device-management-kit\";\nimport { Just, type Maybe, Nothing } from \"purify-ts\";\n\nimport { type GetConfigCommandResponse } from \"@api/app-binder/GetConfigCommandTypes\";\nimport { ClearSigningType } from \"@api/model/ClearSigningType\";\nimport { type TypedData } from \"@api/model/TypedData\";\nimport { GetChallengeCommand } from \"@internal/app-binder/command/GetChallengeCommand\";\nimport {\n BuildFullContextsTask,\n type BuildFullContextsTaskArgs,\n type ContextWithSubContexts,\n} from \"@internal/app-binder/task/BuildFullContextsTask\";\nimport { type ProvideEIP712ContextTaskArgs } from \"@internal/app-binder/task/ProvideEIP712ContextTask\";\nimport { ApplicationChecker } from \"@internal/shared/utils/ApplicationChecker\";\nimport { type TransactionMapperService } from \"@internal/transaction/service/mapper/TransactionMapperService\";\nimport { type TransactionParserService } from \"@internal/transaction/service/parser/TransactionParserService\";\nimport { TypedDataValueField } from \"@internal/typed-data/model/Types\";\nimport { type TypedDataParserService } from \"@internal/typed-data/service/TypedDataParserService\";\n\nexport const ZERO_ADDRESS = \"0x0000000000000000000000000000000000000000\";\n\nexport class BuildEIP712ContextTask {\n constructor(\n private readonly api: InternalApi,\n private readonly contextModule: ContextModule,\n private readonly parser: TypedDataParserService,\n private readonly transactionParser: TransactionParserService,\n private readonly transactionMapper: TransactionMapperService,\n private readonly data: TypedData,\n private readonly derivationPath: string,\n private readonly appConfig: GetConfigCommandResponse,\n private readonly from: string,\n private readonly buildFullContextFactory = (\n api: InternalApi,\n args: BuildFullContextsTaskArgs,\n ) => new BuildFullContextsTask(api, args),\n ) {}\n\n async run(): Promise<ProvideEIP712ContextTaskArgs> {\n // Clear signing context\n // Parse the message types and values\n const parsed = this.parser.parse(this.data);\n if (parsed.isLeft()) {\n throw parsed.extract();\n }\n const { types, domain, message } = parsed.unsafeCoerce();\n\n const deviceState = this.api.getDeviceSessionState();\n const deviceModelId = deviceState.deviceModelId;\n const transactionChecks = await this.getTransactionChecks(deviceModelId);\n\n // Get clear signing context, if any\n let clearSignContext: Maybe<TypedDataClearSignContextSuccess> = Nothing;\n let calldatasContexts: Record<\n TypedDataCalldataIndex,\n ContextWithSubContexts[]\n > = {};\n const version = this.getClearSignVersion(deviceState);\n if (version.isJust()) {\n // Get challenge\n let challenge: string | undefined = undefined;\n const challengeRes = await this.api.sendCommand(\n new GetChallengeCommand(),\n );\n if (isSuccessCommandResult(challengeRes)) {\n challenge = challengeRes.data.challenge;\n }\n\n // Get filters\n const verifyingContract =\n this.data.domain.verifyingContract?.toLowerCase() || ZERO_ADDRESS;\n const chainId = this.data.domain.chainId || 0;\n const fieldsValues = message\n .filter((v) => v.value instanceof TypedDataValueField)\n .map((v) => ({\n path: v.path,\n value: (v.value as TypedDataValueField).data,\n }));\n const filters = await this.contextModule.getTypedDataFilters({\n verifyingContract,\n chainId,\n version: version.extract(),\n schema: this.data.types,\n challenge,\n deviceModelId: deviceState.deviceModelId,\n fieldsValues,\n });\n if (filters.type === \"success\") {\n clearSignContext = Just(filters);\n calldatasContexts = await this.getCalldatasContexts(\n deviceState,\n filters,\n );\n }\n }\n\n // Return the args for provide context task\n const provideTaskArgs: ProvideEIP712ContextTaskArgs = {\n derivationPath: this.derivationPath,\n transactionChecks,\n types,\n domain,\n message,\n clearSignContext,\n calldatasContexts,\n deviceModelId: deviceState.deviceModelId,\n };\n return provideTaskArgs;\n }\n\n private async getTransactionChecks(\n deviceModelId: DeviceModelId,\n ): Promise<ClearSignContextSuccess | undefined> {\n if (!this.appConfig.web3ChecksEnabled) {\n return undefined;\n }\n const contexts = await this.contextModule.getContexts(\n {\n deviceModelId,\n data: this.data,\n from: this.from,\n },\n [ClearSignContextType.TRANSACTION_CHECK],\n );\n if (\n contexts.length > 0 &&\n contexts[0]?.type === ClearSignContextType.TRANSACTION_CHECK\n ) {\n return contexts[0] as ClearSignContextSuccess;\n }\n return undefined;\n }\n\n private getClearSignVersion(\n deviceState: DeviceSessionState,\n ): Maybe<\"v1\" | \"v2\"> {\n if (\n !new ApplicationChecker(deviceState, this.appConfig)\n .withMinVersionInclusive(\"1.10.0\")\n .excludeDeviceModel(DeviceModelId.NANO_S)\n .check()\n ) {\n return Nothing;\n }\n\n // EIP712 v2 (amount & datetime filters) supported since 1.11.0:\n // https://github.com/LedgerHQ/app-ethereum/blob/develop/doc/ethapp.adoc#1110-1\n // But some issues were still present until 1.12.0 among which:\n // * V2 descriptor with missing token not supported by the app\n // * Empty arrays with filters not correctly handled\n // * Trusted name filters not yet released\n // Therefore it's safer and easier to use V1 filters before 1.12.0:\n // https://github.com/LedgerHQ/app-ethereum/blob/develop/doc/ethapp.adoc#1120\n const shouldUseV2Filters = new ApplicationChecker(\n deviceState,\n this.appConfig,\n )\n .withMinVersionInclusive(\"1.12.0\")\n .check();\n return shouldUseV2Filters ? Just(\"v2\") : Just(\"v1\");\n }\n\n private async getCalldatasContexts(\n deviceState: DeviceSessionState,\n filters: TypedDataClearSignContextSuccess,\n ): Promise<Record<TypedDataCalldataIndex, ContextWithSubContexts[]>> {\n const calldatasContexts: Record<\n TypedDataCalldataIndex,\n ContextWithSubContexts[]\n > = {};\n for (const calldataIndex in filters.calldatas) {\n const { subset } = filters.calldatas[calldataIndex]!;\n const calldataContext = await this.buildFullContextFactory(this.api, {\n contextModule: this.contextModule,\n mapper: this.transactionMapper,\n parser: this.transactionParser,\n options: {},\n appConfig: this.appConfig,\n derivationPath: this.derivationPath,\n subset,\n deviceModelId: deviceState.deviceModelId,\n }).run();\n if (calldataContext.clearSigningType === ClearSigningType.EIP7730) {\n calldatasContexts[calldataIndex] = calldataContext.clearSignContexts;\n }\n }\n return calldatasContexts;\n }\n}\n"],
5
+ "mappings": "yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,4BAAAE,EAAA,iBAAAC,IAAA,eAAAC,EAAAJ,GAAA,IAAAK,EAMO,oCACPC,EAKO,2CACPC,EAA0C,qBAG1CC,EAAiC,uCAEjCC,EAAoC,4DACpCC,EAIO,2DAEPC,EAAmC,qDAGnCC,EAAoC,4CAG7B,MAAMT,EAAe,6CAErB,MAAMD,CAAuB,CAClC,YACmBW,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EAA0B,CACzCT,EACAU,IACG,IAAI,wBAAsBV,EAAKU,CAAI,EACxC,CAbiB,SAAAV,EACA,mBAAAC,EACA,YAAAC,EACA,uBAAAC,EACA,uBAAAC,EACA,UAAAC,EACA,oBAAAC,EACA,eAAAC,EACA,UAAAC,EACA,6BAAAC,CAIhB,CAEH,MAAM,KAA6C,CAGjD,MAAME,EAAS,KAAK,OAAO,MAAM,KAAK,IAAI,EAC1C,GAAIA,EAAO,OAAO,EAChB,MAAMA,EAAO,QAAQ,EAEvB,KAAM,CAAE,MAAAC,EAAO,OAAAC,EAAQ,QAAAC,CAAQ,EAAIH,EAAO,aAAa,EAEjDI,EAAc,KAAK,IAAI,sBAAsB,EAC7CC,EAAgBD,EAAY,cAC5BE,EAAoB,MAAM,KAAK,qBAAqBD,CAAa,EAGvE,IAAIE,EAA4D,UAC5DC,EAGA,CAAC,EACL,MAAMC,EAAU,KAAK,oBAAoBL,CAAW,EACpD,GAAIK,EAAQ,OAAO,EAAG,CAEpB,IAAIC,EACJ,MAAMC,EAAe,MAAM,KAAK,IAAI,YAClC,IAAI,qBACN,KACI,0BAAuBA,CAAY,IACrCD,EAAYC,EAAa,KAAK,WAIhC,MAAMC,EACJ,KAAK,KAAK,OAAO,mBAAmB,YAAY,GAAKjC,EACjD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AAE,OAAAG,CAAO,EAAIH,EAAQ,UAAUE,CAAa,EAC5CE,EAAkB,MAAM,KAAK,wBAAwB,KAAK,IAAK,CACnE,cAAe,KAAK,cACpB,OAAQ,KAAK,kBACb,OAAQ,KAAK,kBACb,QAAS,CAAC,EACV,UAAW,KAAK,UAChB,eAAgB,KAAK,eACrB,OAAAD,EACA,cAAef,EAAY,aAC7B,CAAC,EAAE,IAAI,EACHgB,EAAgB,mBAAqB,mBAAiB,UACxDZ,EAAkBU,CAAa,EAAIE,EAAgB,kBAEvD,CACA,OAAOZ,CACT,CACF",
6
+ "names": ["BuildEIP712ContextTask_exports", "__export", "BuildEIP712ContextTask", "ZERO_ADDRESS", "__toCommonJS", "import_context_module", "import_device_management_kit", "import_purify_ts", "import_ClearSigningType", "import_GetChallengeCommand", "import_BuildFullContextsTask", "import_ApplicationChecker", "import_Types", "api", "contextModule", "parser", "transactionParser", "transactionMapper", "data", "derivationPath", "appConfig", "from", "buildFullContextFactory", "args", "parsed", "types", "domain", "message", "deviceState", "deviceModelId", "transactionChecks", "clearSignContext", "calldatasContexts", "version", "challenge", "challengeRes", "verifyingContract", "chainId", "fieldsValues", "v", "filters", "contexts", "calldataIndex", "subset", "calldataContext"]
7
7
  }
@@ -1,2 +1,2 @@
1
- "use strict";var b=require("@ledgerhq/context-module"),e=require("@ledgerhq/device-management-kit"),t=require("purify-ts"),h=require("../../../api/model/ClearSigningType"),k=require("../../app-binder/device-action/__test-utils__/makeInternalApi"),i=require("../../typed-data/model/Types"),f=require("./BuildEIP712ContextTask");describe("BuildEIP712ContextTask",()=>{const a=(0,k.makeDeviceActionInternalApiMock)(),s={getFieldContext:vi.fn(),getContexts:vi.fn(),getTypedDataFilters:vi.fn(),getWeb3Checks:vi.fn(),getSolanaContext:vi.fn()},o={parse:vi.fn()},C={extractValue:vi.fn()},g={mapTransactionToSubset:vi.fn()},r=vi.fn(),m=vi.fn();function y(n){return{blindSigningEnabled:!1,web3ChecksEnabled:n,web3ChecksOptIn:!1,version:"1.13.0"}}const l={domain:{name:"Permit2",chainId:137,verifyingContract:"0x000000000022d473030f116ddee9f6b43ac78ba3"},primaryType:"PermitSingle",message:{details:{token:"0x7ceb23fd6bc0add59e62ac25578270cff1b9f619",amount:"69420000000000000000",expiration:"1718184249",nonce:"0"},spender:"0xec7be89e9d109e7e3fec59c222cf297125fefda2",sigDeadline:"1715594049"},types:{PermitSingle:[{name:"details",type:"PermitDetails"},{name:"spender",type:"address"},{name:"sigDeadline",type:"uint256"}],PermitDetails:[{name:"token",type:"address"},{name:"amount",type:"uint"},{name:"expiration",type:"uint"},{name:"nonce",type:"uint"}]}},d={PermitSingle:{details:new i.StructType("PermitDetails"),spender:new i.PrimitiveType("address","address",t.Nothing),sigDeadline:new i.PrimitiveType("uint256","uint",(0,t.Just)(32))},PermitDetails:{token:new i.PrimitiveType("address","address",t.Nothing),amount:new i.PrimitiveType("uint160","uint",(0,t.Just)(20)),expiration:new i.PrimitiveType("uint48","uint",(0,t.Just)(6)),nonce:new i.PrimitiveType("uint48","uint",(0,t.Just)(6))}},u=[{path:"",type:"",value:new i.TypedDataValueRoot("EIP712Domain")},{path:"chainId",type:"uint256",value:new i.TypedDataValueField(Uint8Array.from([137]))}],p=[{path:"",type:"",value:new i.TypedDataValueRoot("PermitSingle")},{path:"details.amount",type:"uint160",value:new i.TypedDataValueField(Uint8Array.from([18]))},{path:"details.expiration",type:"uint48",value:new i.TypedDataValueField(Uint8Array.from([19]))}],S={type:"success",messageInfo:{displayName:"Permit2",filtersCount:1,signature:"3045022100e3c597d13d28a87a88b0239404c668373cf5063362f2a81d09eed4582941dfe802207669aabb504fd5b95b2734057f6b8bbf51f14a69a5f9bdf658a5952cefbf44d3"},trustedNamesAddresses:{},tokens:{},calldatas:{},proxy:void 0,filters:{"details.amount":{displayName:"Amount allowance",path:"details.amount",signature:"304402201a46e6b4ef89eaf9fcf4945d053bfc5616a826400fd758312fbbe976bafc07ec022025a9b408722baf983ee053f90179c75b0c55bb0668f437d55493e36069bbd5a3",tokenIndex:255,type:"amount"}}},x="0x1234";beforeEach(()=>{vi.resetAllMocks(),r.mockReturnValue({run:async()=>({web3Check:null})}),m.mockReturnValue({run:async()=>({clearSignContexts:[],clearSigningType:h.ClearSigningType.BASIC})}),a.sendCommand.mockResolvedValue((0,e.CommandResultFactory)({data:{challenge:x}}))}),it("Build context with clear signing context not supported by the device",async()=>{const n=new f.BuildEIP712ContextTask(a,s,o,C,g,l,"44'/60'/0'/0/0",y(!1),r,m);o.parse.mockReturnValueOnce((0,t.Right)({types:d,domain:u,message:p})),a.getDeviceSessionState.mockReturnValueOnce({sessionStateType:e.DeviceSessionStateType.ReadyWithoutSecureChannel,deviceStatus:e.DeviceStatus.CONNECTED,installedApps:[],currentApp:{name:"Ethereum",version:"1.11.0"},deviceModelId:e.DeviceModelId.NANO_S,isSecureConnectionAllowed:!1});const c=await n.run();expect(c).toStrictEqual({deviceModelId:e.DeviceModelId.NANO_S,derivationPath:"44'/60'/0'/0/0",web3Check:null,types:d,domain:u,message:p,clearSignContext:t.Nothing,calldatasContexts:{}})}),it("Build context with no clear signing context",async()=>{const n=new f.BuildEIP712ContextTask(a,s,o,C,g,l,"44'/60'/0'/0/0",y(!1),r,m);o.parse.mockReturnValueOnce((0,t.Right)({types:d,domain:u,message:p})),a.getDeviceSessionState.mockReturnValueOnce({sessionStateType:e.DeviceSessionStateType.ReadyWithoutSecureChannel,deviceStatus:e.DeviceStatus.CONNECTED,installedApps:[],currentApp:{name:"Ethereum",version:"1.12.0"},deviceModelId:e.DeviceModelId.FLEX,isSecureConnectionAllowed:!1}),s.getTypedDataFilters.mockResolvedValueOnce({type:"error",error:new Error("no filter")});const c=await n.run();expect(c).toStrictEqual({deviceModelId:e.DeviceModelId.FLEX,derivationPath:"44'/60'/0'/0/0",web3Check:null,types:d,domain:u,message:p,clearSignContext:t.Nothing,calldatasContexts:{}})}),it("Build context with clear signing context",async()=>{const n="web3Check",c=new f.BuildEIP712ContextTask(a,s,o,C,g,l,"44'/60'/0'/0/0",y(!1),r,m);r.mockReturnValueOnce({run:async()=>({web3Check:n})}),o.parse.mockReturnValueOnce((0,t.Right)({types:d,domain:u,message:p})),a.getDeviceSessionState.mockReturnValueOnce({sessionStateType:e.DeviceSessionStateType.ReadyWithoutSecureChannel,deviceStatus:e.DeviceStatus.CONNECTED,installedApps:[],currentApp:{name:"Ethereum",version:"1.12.0"},deviceModelId:e.DeviceModelId.FLEX,isSecureConnectionAllowed:!1}),s.getTypedDataFilters.mockResolvedValueOnce(S);const v=await c.run();expect(v).toStrictEqual({deviceModelId:e.DeviceModelId.FLEX,derivationPath:"44'/60'/0'/0/0",web3Check:null,types:d,domain:u,message:p,clearSignContext:(0,t.Just)(S),calldatasContexts:{}}),expect(o.parse).toHaveBeenCalledWith(l),expect(s.getTypedDataFilters).toHaveBeenCalledWith({verifyingContract:"0x000000000022d473030f116ddee9f6b43ac78ba3",chainId:137,version:"v2",schema:l.types,challenge:x,deviceModelId:e.DeviceModelId.FLEX,fieldsValues:[{path:"details.amount",value:Uint8Array.from([18])},{path:"details.expiration",value:Uint8Array.from([19])}]})}),it("Build context with clear signing context and web3Check",async()=>{const n="web3Check",c=new f.BuildEIP712ContextTask(a,s,o,C,g,l,"44'/60'/0'/0/0",y(!0),r,m);r.mockReturnValueOnce({run:async()=>({web3Check:n})}),o.parse.mockReturnValueOnce((0,t.Right)({types:d,domain:u,message:p})),a.getDeviceSessionState.mockReturnValueOnce({sessionStateType:e.DeviceSessionStateType.ReadyWithoutSecureChannel,deviceStatus:e.DeviceStatus.CONNECTED,installedApps:[],currentApp:{name:"Ethereum",version:"1.12.0"},deviceModelId:e.DeviceModelId.FLEX,isSecureConnectionAllowed:!1}),s.getTypedDataFilters.mockResolvedValueOnce(S);const v=await c.run();expect(v).toStrictEqual({deviceModelId:e.DeviceModelId.FLEX,derivationPath:"44'/60'/0'/0/0",web3Check:n,types:d,domain:u,message:p,clearSignContext:(0,t.Just)(S),calldatasContexts:{}}),expect(r).toHaveBeenCalledWith(a,{contextModule:s,derivationPath:"44'/60'/0'/0/0",data:l})}),it("Build context with clear signing context V1",async()=>{const n=new f.BuildEIP712ContextTask(a,s,o,C,g,l,"44'/60'/0'/0/0",y(!1),r,m);o.parse.mockReturnValueOnce((0,t.Right)({types:d,domain:u,message:p})),a.getDeviceSessionState.mockReturnValueOnce({sessionStateType:e.DeviceSessionStateType.ReadyWithoutSecureChannel,deviceStatus:e.DeviceStatus.CONNECTED,installedApps:[],currentApp:{name:"Ethereum",version:"1.11.0"},deviceModelId:e.DeviceModelId.FLEX,isSecureConnectionAllowed:!1}),s.getTypedDataFilters.mockResolvedValueOnce(S),await n.run(),expect(s.getTypedDataFilters).toHaveBeenCalledWith({verifyingContract:"0x000000000022d473030f116ddee9f6b43ac78ba3",chainId:137,version:"v1",schema:l.types,challenge:x,deviceModelId:e.DeviceModelId.FLEX,fieldsValues:[{path:"details.amount",value:Uint8Array.from([18])},{path:"details.expiration",value:Uint8Array.from([19])}]})}),it("Build context with clear signing context and calldatas",async()=>{const n=new f.BuildEIP712ContextTask(a,s,o,C,g,l,"44'/60'/0'/0/0",y(!1),r,m),c={chainId:4660,data:"0x6a76120200000000000000000000000023f8abfc2824c397ccb3da89ae772984107ddb99",from:"0x8ceb23fd6bc0add59e62ac25578270cff1b9f619",selector:"0x778899aa",to:"0x7ceb23fd6bc0add59e62ac25578270cff1b9f619",value:4200000000000000n},v={...S,calldatas:{0:{filter:{calldataIndex:0,displayName:"Transaction",valueFlag:!0,calleeFlag:b.TypedDataCalldataParamPresence.Present,chainIdFlag:!1,selectorFlag:!1,amountFlag:!0,spenderFlag:b.TypedDataCalldataParamPresence.Present,signature:"3045022100d8496ab69152efeef6a923a3ebd225334ad65dcb985814994243be7bc09bf27e02206314835816908dd6d51d3cbb0f9465d91d7ddc9104b34dd6c4247f65c551836e"},subset:c}}};o.parse.mockReturnValueOnce((0,t.Right)({types:d,domain:u,message:p})),a.getDeviceSessionState.mockReturnValueOnce({sessionStateType:e.DeviceSessionStateType.ReadyWithoutSecureChannel,deviceStatus:e.DeviceStatus.CONNECTED,installedApps:[],currentApp:{name:"Ethereum",version:"1.12.0"},deviceModelId:e.DeviceModelId.FLEX,isSecureConnectionAllowed:!1}),s.getTypedDataFilters.mockResolvedValueOnce(v),m.mockReturnValue({run:async()=>({clearSignContexts:[],clearSigningType:h.ClearSigningType.EIP7730})});const T=await n.run();expect(m).toHaveBeenCalledWith(a,expect.objectContaining({subset:c})),expect(T).toStrictEqual({deviceModelId:e.DeviceModelId.FLEX,derivationPath:"44'/60'/0'/0/0",web3Check:null,types:d,domain:u,message:p,clearSignContext:(0,t.Just)(v),calldatasContexts:{0:[]}})}),it("Should throw an error if parsing fails",async()=>{const n=new f.BuildEIP712ContextTask(a,s,o,C,g,l,"44'/60'/0'/0/0",y(!1),r,m);o.parse.mockReturnValueOnce((0,t.Left)(new Error("Parsing error")));try{await n.run()}catch(c){expect(c).toBeInstanceOf(Error),expect(c.message).toBe("Parsing error")}})});
1
+ "use strict";var v=require("@ledgerhq/context-module"),T=require("@ledgerhq/context-module"),e=require("@ledgerhq/device-management-kit"),t=require("purify-ts"),b=require("../../../api/model/ClearSigningType"),k=require("../../app-binder/device-action/__test-utils__/makeInternalApi"),s=require("../../typed-data/model/Types"),f=require("./BuildEIP712ContextTask");describe("BuildEIP712ContextTask",()=>{const o=(0,k.makeDeviceActionInternalApiMock)(),a={getFieldContext:vi.fn(),getContexts:vi.fn(),getTypedDataFilters:vi.fn()},i={parse:vi.fn()},C={extractValue:vi.fn()},y={mapTransactionToSubset:vi.fn()},p=vi.fn();function g(n){return{blindSigningEnabled:!1,web3ChecksEnabled:n,web3ChecksOptIn:!1,version:"1.13.0"}}const u={domain:{name:"Permit2",chainId:137,verifyingContract:"0x000000000022d473030f116ddee9f6b43ac78ba3"},primaryType:"PermitSingle",message:{details:{token:"0x7ceb23fd6bc0add59e62ac25578270cff1b9f619",amount:"69420000000000000000",expiration:"1718184249",nonce:"0"},spender:"0xec7be89e9d109e7e3fec59c222cf297125fefda2",sigDeadline:"1715594049"},types:{PermitSingle:[{name:"details",type:"PermitDetails"},{name:"spender",type:"address"},{name:"sigDeadline",type:"uint256"}],PermitDetails:[{name:"token",type:"address"},{name:"amount",type:"uint"},{name:"expiration",type:"uint"},{name:"nonce",type:"uint"}]}},r={PermitSingle:{details:new s.StructType("PermitDetails"),spender:new s.PrimitiveType("address","address",t.Nothing),sigDeadline:new s.PrimitiveType("uint256","uint",(0,t.Just)(32))},PermitDetails:{token:new s.PrimitiveType("address","address",t.Nothing),amount:new s.PrimitiveType("uint160","uint",(0,t.Just)(20)),expiration:new s.PrimitiveType("uint48","uint",(0,t.Just)(6)),nonce:new s.PrimitiveType("uint48","uint",(0,t.Just)(6))}},d=[{path:"",type:"",value:new s.TypedDataValueRoot("EIP712Domain")},{path:"chainId",type:"uint256",value:new s.TypedDataValueField(Uint8Array.from([137]))}],l=[{path:"",type:"",value:new s.TypedDataValueRoot("PermitSingle")},{path:"details.amount",type:"uint160",value:new s.TypedDataValueField(Uint8Array.from([18]))},{path:"details.expiration",type:"uint48",value:new s.TypedDataValueField(Uint8Array.from([19]))}],S={type:"success",messageInfo:{displayName:"Permit2",filtersCount:1,signature:"3045022100e3c597d13d28a87a88b0239404c668373cf5063362f2a81d09eed4582941dfe802207669aabb504fd5b95b2734057f6b8bbf51f14a69a5f9bdf658a5952cefbf44d3"},trustedNamesAddresses:{},tokens:{},calldatas:{},proxy:void 0,filters:{"details.amount":{displayName:"Amount allowance",path:"details.amount",signature:"304402201a46e6b4ef89eaf9fcf4945d053bfc5616a826400fd758312fbbe976bafc07ec022025a9b408722baf983ee053f90179c75b0c55bb0668f437d55493e36069bbd5a3",tokenIndex:255,type:"amount"}}},h="0x1234",m="0x8ceb23fd6bc0add59e62ac25578270cff1b9f619";beforeEach(()=>{vi.resetAllMocks(),o.sendCommand.mockResolvedValue((0,e.CommandResultFactory)({data:{challenge:h}})),p.mockReturnValue({run:async()=>({clearSignContexts:[],clearSigningType:b.ClearSigningType.BASIC})})}),it("Build context with clear signing context not supported by the device",async()=>{const n=new f.BuildEIP712ContextTask(o,a,i,C,y,u,"44'/60'/0'/0/0",g(!1),m,p);i.parse.mockReturnValueOnce((0,t.Right)({types:r,domain:d,message:l})),o.getDeviceSessionState.mockReturnValueOnce({sessionStateType:e.DeviceSessionStateType.ReadyWithoutSecureChannel,deviceStatus:e.DeviceStatus.CONNECTED,installedApps:[],currentApp:{name:"Ethereum",version:"1.11.0"},deviceModelId:e.DeviceModelId.NANO_S,isSecureConnectionAllowed:!1});const c=await n.run();expect(c).toStrictEqual({deviceModelId:e.DeviceModelId.NANO_S,derivationPath:"44'/60'/0'/0/0",transactionChecks:void 0,types:r,domain:d,message:l,clearSignContext:t.Nothing,calldatasContexts:{}})}),it("Build context with no clear signing context",async()=>{const n=new f.BuildEIP712ContextTask(o,a,i,C,y,u,"44'/60'/0'/0/0",g(!1),m,p);i.parse.mockReturnValueOnce((0,t.Right)({types:r,domain:d,message:l})),o.getDeviceSessionState.mockReturnValueOnce({sessionStateType:e.DeviceSessionStateType.ReadyWithoutSecureChannel,deviceStatus:e.DeviceStatus.CONNECTED,installedApps:[],currentApp:{name:"Ethereum",version:"1.12.0"},deviceModelId:e.DeviceModelId.FLEX,isSecureConnectionAllowed:!1}),a.getTypedDataFilters.mockResolvedValueOnce({type:v.ClearSignContextType.ERROR,error:new Error("no filter")});const c=await n.run();expect(c).toStrictEqual({deviceModelId:e.DeviceModelId.FLEX,derivationPath:"44'/60'/0'/0/0",transactionChecks:void 0,types:r,domain:d,message:l,clearSignContext:t.Nothing,calldatasContexts:{}})}),it("Build context with clear signing context",async()=>{const n={type:v.ClearSignContextType.TRANSACTION_CHECK,payload:"web3Check"},c=new f.BuildEIP712ContextTask(o,a,i,C,y,u,"44'/60'/0'/0/0",g(!1),m,p);a.getContexts.mockResolvedValueOnce([n]),i.parse.mockReturnValueOnce((0,t.Right)({types:r,domain:d,message:l})),o.getDeviceSessionState.mockReturnValueOnce({sessionStateType:e.DeviceSessionStateType.ReadyWithoutSecureChannel,deviceStatus:e.DeviceStatus.CONNECTED,installedApps:[],currentApp:{name:"Ethereum",version:"1.12.0"},deviceModelId:e.DeviceModelId.FLEX,isSecureConnectionAllowed:!1}),a.getTypedDataFilters.mockResolvedValueOnce(S);const x=await c.run();expect(x).toStrictEqual({deviceModelId:e.DeviceModelId.FLEX,derivationPath:"44'/60'/0'/0/0",transactionChecks:void 0,types:r,domain:d,message:l,clearSignContext:(0,t.Just)(S),calldatasContexts:{}}),expect(i.parse).toHaveBeenCalledWith(u),expect(a.getTypedDataFilters).toHaveBeenCalledWith({verifyingContract:"0x000000000022d473030f116ddee9f6b43ac78ba3",chainId:137,version:"v2",schema:u.types,challenge:h,deviceModelId:e.DeviceModelId.FLEX,fieldsValues:[{path:"details.amount",value:Uint8Array.from([18])},{path:"details.expiration",value:Uint8Array.from([19])}]})}),it("Build context with clear signing context and transaction checks",async()=>{const n={type:v.ClearSignContextType.TRANSACTION_CHECK,payload:"transactionCheck"},c=new f.BuildEIP712ContextTask(o,a,i,C,y,u,"44'/60'/0'/0/0",g(!0),m,p);a.getContexts.mockResolvedValueOnce([n]),i.parse.mockReturnValueOnce((0,t.Right)({types:r,domain:d,message:l})),o.getDeviceSessionState.mockReturnValueOnce({sessionStateType:e.DeviceSessionStateType.ReadyWithoutSecureChannel,deviceStatus:e.DeviceStatus.CONNECTED,installedApps:[],currentApp:{name:"Ethereum",version:"1.12.0"},deviceModelId:e.DeviceModelId.FLEX,isSecureConnectionAllowed:!1}),a.getTypedDataFilters.mockResolvedValueOnce(S);const x=await c.run();expect(x).toStrictEqual({deviceModelId:e.DeviceModelId.FLEX,derivationPath:"44'/60'/0'/0/0",types:r,domain:d,message:l,clearSignContext:(0,t.Just)(S),calldatasContexts:{},transactionChecks:n})}),it("Build context with clear signing context V1",async()=>{const n=new f.BuildEIP712ContextTask(o,a,i,C,y,u,"44'/60'/0'/0/0",g(!1),m,p);i.parse.mockReturnValueOnce((0,t.Right)({types:r,domain:d,message:l})),o.getDeviceSessionState.mockReturnValueOnce({sessionStateType:e.DeviceSessionStateType.ReadyWithoutSecureChannel,deviceStatus:e.DeviceStatus.CONNECTED,installedApps:[],currentApp:{name:"Ethereum",version:"1.11.0"},deviceModelId:e.DeviceModelId.FLEX,isSecureConnectionAllowed:!1}),a.getTypedDataFilters.mockResolvedValueOnce(S),await n.run(),expect(a.getTypedDataFilters).toHaveBeenCalledWith({verifyingContract:"0x000000000022d473030f116ddee9f6b43ac78ba3",chainId:137,version:"v1",schema:u.types,challenge:h,deviceModelId:e.DeviceModelId.FLEX,fieldsValues:[{path:"details.amount",value:Uint8Array.from([18])},{path:"details.expiration",value:Uint8Array.from([19])}]})}),it("Build context with clear signing context and calldatas",async()=>{const n=new f.BuildEIP712ContextTask(o,a,i,C,y,u,"44'/60'/0'/0/0",g(!1),m,p),c={chainId:4660,data:"0x6a76120200000000000000000000000023f8abfc2824c397ccb3da89ae772984107ddb99",from:m,selector:"0x778899aa",to:"0x7ceb23fd6bc0add59e62ac25578270cff1b9f619",value:4200000000000000n},x={...S,calldatas:{0:{filter:{calldataIndex:0,displayName:"Transaction",valueFlag:!0,calleeFlag:T.TypedDataCalldataParamPresence.Present,chainIdFlag:!1,selectorFlag:!1,amountFlag:!0,spenderFlag:T.TypedDataCalldataParamPresence.Present,signature:"3045022100d8496ab69152efeef6a923a3ebd225334ad65dcb985814994243be7bc09bf27e02206314835816908dd6d51d3cbb0f9465d91d7ddc9104b34dd6c4247f65c551836e"},subset:c}}};i.parse.mockReturnValueOnce((0,t.Right)({types:r,domain:d,message:l})),o.getDeviceSessionState.mockReturnValueOnce({sessionStateType:e.DeviceSessionStateType.ReadyWithoutSecureChannel,deviceStatus:e.DeviceStatus.CONNECTED,installedApps:[],currentApp:{name:"Ethereum",version:"1.12.0"},deviceModelId:e.DeviceModelId.FLEX,isSecureConnectionAllowed:!1}),a.getTypedDataFilters.mockResolvedValueOnce(x),p.mockReturnValue({run:async()=>({clearSignContexts:[],clearSigningType:b.ClearSigningType.EIP7730})});const E=await n.run();expect(E).toStrictEqual({deviceModelId:e.DeviceModelId.FLEX,derivationPath:"44'/60'/0'/0/0",transactionChecks:void 0,types:r,domain:d,message:l,clearSignContext:(0,t.Just)(x),calldatasContexts:{0:[]}})}),it("Should throw an error if parsing fails",async()=>{const n=new f.BuildEIP712ContextTask(o,a,i,C,y,u,"44'/60'/0'/0/0",g(!1),m,p);i.parse.mockReturnValueOnce((0,t.Left)(new Error("Parsing error")));try{await n.run()}catch(c){expect(c).toBeInstanceOf(Error),expect(c.message).toBe("Parsing error")}})});
2
2
  //# sourceMappingURL=BuildEIP712ContextTask.test.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../../src/internal/app-binder/task/BuildEIP712ContextTask.test.ts"],
4
- "sourcesContent": ["import type {\n ClearSignContextSuccess,\n ClearSignContextType,\n TypedDataClearSignContextSuccess,\n} from \"@ledgerhq/context-module\";\nimport { TypedDataCalldataParamPresence } from \"@ledgerhq/context-module\";\nimport {\n CommandResultFactory,\n DeviceModelId,\n DeviceSessionStateType,\n DeviceStatus,\n} from \"@ledgerhq/device-management-kit\";\nimport { Just, Left, Nothing, Right } from \"purify-ts\";\n\nimport type { GetConfigCommandResponse } from \"@api/app-binder/GetConfigCommandTypes\";\nimport { ClearSigningType } from \"@api/model/ClearSigningType\";\nimport { makeDeviceActionInternalApiMock } from \"@internal/app-binder/device-action/__test-utils__/makeInternalApi\";\nimport { type TransactionMapperService } from \"@internal/transaction/service/mapper/TransactionMapperService\";\nimport { type TransactionParserService } from \"@internal/transaction/service/parser/TransactionParserService\";\nimport {\n PrimitiveType,\n StructType,\n TypedDataValueField,\n TypedDataValueRoot,\n} from \"@internal/typed-data/model/Types\";\n\nimport { BuildEIP712ContextTask } from \"./BuildEIP712ContextTask\";\n\ndescribe(\"BuildEIP712ContextTask\", () => {\n const apiMock = makeDeviceActionInternalApiMock();\n const contextMouleMock = {\n getFieldContext: vi.fn(),\n getContexts: vi.fn(),\n getTypedDataFilters: vi.fn(),\n getWeb3Checks: vi.fn(),\n getSolanaContext: vi.fn(),\n };\n const parserMock = {\n parse: vi.fn(),\n };\n const mockTransactionParser: TransactionParserService = {\n extractValue: vi.fn(),\n } as unknown as TransactionParserService;\n const mockTransactionMapper: TransactionMapperService = {\n mapTransactionToSubset: vi.fn(),\n };\n const getWeb3ChecksFactoryMock = vi.fn();\n const buildFullContextFactoryMock = vi.fn();\n\n function createAppConfig(\n web3ChecksEnabled: boolean,\n ): GetConfigCommandResponse {\n return {\n blindSigningEnabled: false,\n web3ChecksEnabled,\n web3ChecksOptIn: false,\n version: \"1.13.0\",\n };\n }\n\n const TEST_DATA = {\n domain: {\n name: \"Permit2\",\n chainId: 137,\n verifyingContract: \"0x000000000022d473030f116ddee9f6b43ac78ba3\",\n },\n primaryType: \"PermitSingle\",\n message: {\n details: {\n token: \"0x7ceb23fd6bc0add59e62ac25578270cff1b9f619\",\n amount: \"69420000000000000000\",\n expiration: \"1718184249\",\n nonce: \"0\",\n },\n spender: \"0xec7be89e9d109e7e3fec59c222cf297125fefda2\",\n sigDeadline: \"1715594049\",\n },\n types: {\n PermitSingle: [\n {\n name: \"details\",\n type: \"PermitDetails\",\n },\n {\n name: \"spender\",\n type: \"address\",\n },\n {\n name: \"sigDeadline\",\n type: \"uint256\",\n },\n ],\n PermitDetails: [\n { name: \"token\", type: \"address\" },\n { name: \"amount\", type: \"uint\" },\n { name: \"expiration\", type: \"uint\" },\n { name: \"nonce\", type: \"uint\" },\n ],\n },\n };\n\n const TEST_TYPES = {\n PermitSingle: {\n details: new StructType(\"PermitDetails\"),\n spender: new PrimitiveType(\"address\", \"address\", Nothing),\n sigDeadline: new PrimitiveType(\"uint256\", \"uint\", Just(32)),\n },\n PermitDetails: {\n token: new PrimitiveType(\"address\", \"address\", Nothing),\n amount: new PrimitiveType(\"uint160\", \"uint\", Just(20)),\n expiration: new PrimitiveType(\"uint48\", \"uint\", Just(6)),\n nonce: new PrimitiveType(\"uint48\", \"uint\", Just(6)),\n },\n };\n const TEST_DOMAIN_VALUES = [\n {\n path: \"\",\n type: \"\",\n value: new TypedDataValueRoot(\"EIP712Domain\"),\n },\n {\n path: \"chainId\",\n type: \"uint256\",\n value: new TypedDataValueField(Uint8Array.from([137])),\n },\n ];\n const TEST_MESSAGE_VALUES = [\n {\n path: \"\",\n type: \"\",\n value: new TypedDataValueRoot(\"PermitSingle\"),\n },\n {\n path: \"details.amount\",\n type: \"uint160\",\n value: new TypedDataValueField(Uint8Array.from([0x12])),\n },\n {\n path: \"details.expiration\",\n type: \"uint48\",\n value: new TypedDataValueField(Uint8Array.from([0x13])),\n },\n ];\n const TEST_CLEAR_SIGN_CONTEXT: TypedDataClearSignContextSuccess = {\n type: \"success\",\n messageInfo: {\n displayName: \"Permit2\",\n filtersCount: 1,\n signature:\n \"3045022100e3c597d13d28a87a88b0239404c668373cf5063362f2a81d09eed4582941dfe802207669aabb504fd5b95b2734057f6b8bbf51f14a69a5f9bdf658a5952cefbf44d3\",\n },\n trustedNamesAddresses: {},\n tokens: {},\n calldatas: {},\n proxy: undefined,\n filters: {\n \"details.amount\": {\n displayName: \"Amount allowance\",\n path: \"details.amount\",\n signature:\n \"304402201a46e6b4ef89eaf9fcf4945d053bfc5616a826400fd758312fbbe976bafc07ec022025a9b408722baf983ee053f90179c75b0c55bb0668f437d55493e36069bbd5a3\",\n tokenIndex: 255,\n type: \"amount\",\n },\n },\n };\n\n const TEST_CHALLENGE = \"0x1234\";\n\n beforeEach(() => {\n vi.resetAllMocks();\n getWeb3ChecksFactoryMock.mockReturnValue({\n run: async () => ({ web3Check: null }),\n });\n buildFullContextFactoryMock.mockReturnValue({\n run: async () => ({\n clearSignContexts: [],\n clearSigningType: ClearSigningType.BASIC,\n }),\n });\n apiMock.sendCommand.mockResolvedValue(\n CommandResultFactory({ data: { challenge: TEST_CHALLENGE } }),\n );\n });\n\n it(\"Build context with clear signing context not supported by the device\", async () => {\n // GIVEN\n const task = new BuildEIP712ContextTask(\n apiMock,\n contextMouleMock,\n parserMock,\n mockTransactionParser,\n mockTransactionMapper,\n TEST_DATA,\n \"44'/60'/0'/0/0\",\n createAppConfig(false),\n getWeb3ChecksFactoryMock,\n buildFullContextFactoryMock,\n );\n parserMock.parse.mockReturnValueOnce(\n Right({\n types: TEST_TYPES,\n domain: TEST_DOMAIN_VALUES,\n message: TEST_MESSAGE_VALUES,\n }),\n );\n apiMock.getDeviceSessionState.mockReturnValueOnce({\n sessionStateType: DeviceSessionStateType.ReadyWithoutSecureChannel,\n deviceStatus: DeviceStatus.CONNECTED,\n installedApps: [],\n currentApp: { name: \"Ethereum\", version: \"1.11.0\" },\n deviceModelId: DeviceModelId.NANO_S,\n isSecureConnectionAllowed: false,\n });\n // WHEN\n const builtContext = await task.run();\n // THEN\n expect(builtContext).toStrictEqual({\n deviceModelId: DeviceModelId.NANO_S,\n derivationPath: \"44'/60'/0'/0/0\",\n web3Check: null,\n types: TEST_TYPES,\n domain: TEST_DOMAIN_VALUES,\n message: TEST_MESSAGE_VALUES,\n clearSignContext: Nothing,\n calldatasContexts: {},\n });\n });\n\n it(\"Build context with no clear signing context\", async () => {\n // GIVEN\n const task = new BuildEIP712ContextTask(\n apiMock,\n contextMouleMock,\n parserMock,\n mockTransactionParser,\n mockTransactionMapper,\n TEST_DATA,\n \"44'/60'/0'/0/0\",\n createAppConfig(false),\n getWeb3ChecksFactoryMock,\n buildFullContextFactoryMock,\n );\n parserMock.parse.mockReturnValueOnce(\n Right({\n types: TEST_TYPES,\n domain: TEST_DOMAIN_VALUES,\n message: TEST_MESSAGE_VALUES,\n }),\n );\n apiMock.getDeviceSessionState.mockReturnValueOnce({\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 contextMouleMock.getTypedDataFilters.mockResolvedValueOnce({\n type: \"error\",\n error: new Error(\"no filter\"),\n });\n // WHEN\n const builtContext = await task.run();\n // THEN\n expect(builtContext).toStrictEqual({\n deviceModelId: DeviceModelId.FLEX,\n derivationPath: \"44'/60'/0'/0/0\",\n web3Check: null,\n types: TEST_TYPES,\n domain: TEST_DOMAIN_VALUES,\n message: TEST_MESSAGE_VALUES,\n clearSignContext: Nothing,\n calldatasContexts: {},\n });\n });\n\n it(\"Build context with clear signing context\", async () => {\n // GIVEN\n const expectedWeb3Check =\n \"web3Check\" as unknown as ClearSignContextSuccess<ClearSignContextType.WEB3_CHECK>;\n const task = new BuildEIP712ContextTask(\n apiMock,\n contextMouleMock,\n parserMock,\n mockTransactionParser,\n mockTransactionMapper,\n TEST_DATA,\n \"44'/60'/0'/0/0\",\n createAppConfig(false),\n getWeb3ChecksFactoryMock,\n buildFullContextFactoryMock,\n );\n getWeb3ChecksFactoryMock.mockReturnValueOnce({\n run: async () => ({ web3Check: expectedWeb3Check }),\n });\n parserMock.parse.mockReturnValueOnce(\n Right({\n types: TEST_TYPES,\n domain: TEST_DOMAIN_VALUES,\n message: TEST_MESSAGE_VALUES,\n }),\n );\n apiMock.getDeviceSessionState.mockReturnValueOnce({\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 contextMouleMock.getTypedDataFilters.mockResolvedValueOnce(\n TEST_CLEAR_SIGN_CONTEXT,\n );\n // WHEN\n const builtContext = await task.run();\n // THEN\n expect(builtContext).toStrictEqual({\n deviceModelId: DeviceModelId.FLEX,\n derivationPath: \"44'/60'/0'/0/0\",\n web3Check: null,\n types: TEST_TYPES,\n domain: TEST_DOMAIN_VALUES,\n message: TEST_MESSAGE_VALUES,\n clearSignContext: Just(TEST_CLEAR_SIGN_CONTEXT),\n calldatasContexts: {},\n });\n expect(parserMock.parse).toHaveBeenCalledWith(TEST_DATA);\n expect(contextMouleMock.getTypedDataFilters).toHaveBeenCalledWith({\n verifyingContract: \"0x000000000022d473030f116ddee9f6b43ac78ba3\",\n chainId: 137,\n version: \"v2\",\n schema: TEST_DATA[\"types\"],\n challenge: TEST_CHALLENGE,\n deviceModelId: DeviceModelId.FLEX,\n fieldsValues: [\n {\n path: \"details.amount\",\n value: Uint8Array.from([0x12]),\n },\n {\n path: \"details.expiration\",\n value: Uint8Array.from([0x13]),\n },\n ],\n });\n });\n\n it(\"Build context with clear signing context and web3Check\", async () => {\n // GIVEN\n const expectedWeb3Check =\n \"web3Check\" as unknown as ClearSignContextSuccess<ClearSignContextType.WEB3_CHECK>;\n const task = new BuildEIP712ContextTask(\n apiMock,\n contextMouleMock,\n parserMock,\n mockTransactionParser,\n mockTransactionMapper,\n TEST_DATA,\n \"44'/60'/0'/0/0\",\n createAppConfig(true),\n getWeb3ChecksFactoryMock,\n buildFullContextFactoryMock,\n );\n getWeb3ChecksFactoryMock.mockReturnValueOnce({\n run: async () => ({ web3Check: expectedWeb3Check }),\n });\n parserMock.parse.mockReturnValueOnce(\n Right({\n types: TEST_TYPES,\n domain: TEST_DOMAIN_VALUES,\n message: TEST_MESSAGE_VALUES,\n }),\n );\n apiMock.getDeviceSessionState.mockReturnValueOnce({\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 contextMouleMock.getTypedDataFilters.mockResolvedValueOnce(\n TEST_CLEAR_SIGN_CONTEXT,\n );\n // WHEN\n const builtContext = await task.run();\n // THEN\n expect(builtContext).toStrictEqual({\n deviceModelId: DeviceModelId.FLEX,\n derivationPath: \"44'/60'/0'/0/0\",\n web3Check: expectedWeb3Check,\n types: TEST_TYPES,\n domain: TEST_DOMAIN_VALUES,\n message: TEST_MESSAGE_VALUES,\n clearSignContext: Just(TEST_CLEAR_SIGN_CONTEXT),\n calldatasContexts: {},\n });\n expect(getWeb3ChecksFactoryMock).toHaveBeenCalledWith(apiMock, {\n contextModule: contextMouleMock,\n derivationPath: \"44'/60'/0'/0/0\",\n data: TEST_DATA,\n });\n });\n\n it(\"Build context with clear signing context V1\", async () => {\n // GIVEN\n const task = new BuildEIP712ContextTask(\n apiMock,\n contextMouleMock,\n parserMock,\n mockTransactionParser,\n mockTransactionMapper,\n TEST_DATA,\n \"44'/60'/0'/0/0\",\n createAppConfig(false),\n getWeb3ChecksFactoryMock,\n buildFullContextFactoryMock,\n );\n parserMock.parse.mockReturnValueOnce(\n Right({\n types: TEST_TYPES,\n domain: TEST_DOMAIN_VALUES,\n message: TEST_MESSAGE_VALUES,\n }),\n );\n apiMock.getDeviceSessionState.mockReturnValueOnce({\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 contextMouleMock.getTypedDataFilters.mockResolvedValueOnce(\n TEST_CLEAR_SIGN_CONTEXT,\n );\n // WHEN\n await task.run();\n // THEN\n expect(contextMouleMock.getTypedDataFilters).toHaveBeenCalledWith({\n verifyingContract: \"0x000000000022d473030f116ddee9f6b43ac78ba3\",\n chainId: 137,\n version: \"v1\",\n schema: TEST_DATA[\"types\"],\n challenge: TEST_CHALLENGE,\n deviceModelId: DeviceModelId.FLEX,\n fieldsValues: [\n {\n path: \"details.amount\",\n value: Uint8Array.from([0x12]),\n },\n {\n path: \"details.expiration\",\n value: Uint8Array.from([0x13]),\n },\n ],\n });\n });\n\n it(\"Build context with clear signing context and calldatas\", async () => {\n // GIVEN\n const task = new BuildEIP712ContextTask(\n apiMock,\n contextMouleMock,\n parserMock,\n mockTransactionParser,\n mockTransactionMapper,\n TEST_DATA,\n \"44'/60'/0'/0/0\",\n createAppConfig(false),\n getWeb3ChecksFactoryMock,\n buildFullContextFactoryMock,\n );\n const subset = {\n chainId: 0x1234,\n data: \"0x6a76120200000000000000000000000023f8abfc2824c397ccb3da89ae772984107ddb99\",\n from: \"0x8ceb23fd6bc0add59e62ac25578270cff1b9f619\",\n selector: \"0x778899aa\",\n to: \"0x7ceb23fd6bc0add59e62ac25578270cff1b9f619\",\n value: 4200000000000000n,\n };\n const clearSignContext = {\n ...TEST_CLEAR_SIGN_CONTEXT,\n calldatas: {\n 0: {\n filter: {\n calldataIndex: 0,\n displayName: \"Transaction\",\n valueFlag: true,\n calleeFlag: TypedDataCalldataParamPresence.Present,\n chainIdFlag: false,\n selectorFlag: false,\n amountFlag: true,\n spenderFlag: TypedDataCalldataParamPresence.Present,\n signature:\n \"3045022100d8496ab69152efeef6a923a3ebd225334ad65dcb985814994243be7bc09bf27e02206314835816908dd6d51d3cbb0f9465d91d7ddc9104b34dd6c4247f65c551836e\",\n },\n subset,\n },\n },\n };\n parserMock.parse.mockReturnValueOnce(\n Right({\n types: TEST_TYPES,\n domain: TEST_DOMAIN_VALUES,\n message: TEST_MESSAGE_VALUES,\n }),\n );\n apiMock.getDeviceSessionState.mockReturnValueOnce({\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 contextMouleMock.getTypedDataFilters.mockResolvedValueOnce(\n clearSignContext,\n );\n buildFullContextFactoryMock.mockReturnValue({\n run: async () => ({\n clearSignContexts: [],\n clearSigningType: ClearSigningType.EIP7730,\n }),\n });\n // WHEN\n const builtContext = await task.run();\n // THEN\n expect(buildFullContextFactoryMock).toHaveBeenCalledWith(\n apiMock,\n expect.objectContaining({\n subset,\n }),\n );\n expect(builtContext).toStrictEqual({\n deviceModelId: DeviceModelId.FLEX,\n derivationPath: \"44'/60'/0'/0/0\",\n web3Check: null,\n types: TEST_TYPES,\n domain: TEST_DOMAIN_VALUES,\n message: TEST_MESSAGE_VALUES,\n clearSignContext: Just(clearSignContext),\n calldatasContexts: {\n 0: [],\n },\n });\n });\n\n it(\"Should throw an error if parsing fails\", async () => {\n // GIVEN\n const task = new BuildEIP712ContextTask(\n apiMock,\n contextMouleMock,\n parserMock,\n mockTransactionParser,\n mockTransactionMapper,\n TEST_DATA,\n \"44'/60'/0'/0/0\",\n createAppConfig(false),\n getWeb3ChecksFactoryMock,\n buildFullContextFactoryMock,\n );\n parserMock.parse.mockReturnValueOnce(Left(new Error(\"Parsing error\")));\n // WHEN\n try {\n await task.run();\n } catch (e) {\n // THEN\n expect(e).toBeInstanceOf(Error);\n // @ts-expect-error\n expect(e.message).toBe(\"Parsing error\");\n }\n });\n});\n"],
5
- "mappings": "aAKA,IAAAA,EAA+C,oCAC/CC,EAKO,2CACPC,EAA2C,qBAG3CC,EAAiC,uCACjCC,EAAgD,6EAGhDC,EAKO,4CAEPC,EAAuC,oCAEvC,SAAS,yBAA0B,IAAM,CACvC,MAAMC,KAAU,mCAAgC,EAC1CC,EAAmB,CACvB,gBAAiB,GAAG,GAAG,EACvB,YAAa,GAAG,GAAG,EACnB,oBAAqB,GAAG,GAAG,EAC3B,cAAe,GAAG,GAAG,EACrB,iBAAkB,GAAG,GAAG,CAC1B,EACMC,EAAa,CACjB,MAAO,GAAG,GAAG,CACf,EACMC,EAAkD,CACtD,aAAc,GAAG,GAAG,CACtB,EACMC,EAAkD,CACtD,uBAAwB,GAAG,GAAG,CAChC,EACMC,EAA2B,GAAG,GAAG,EACjCC,EAA8B,GAAG,GAAG,EAE1C,SAASC,EACPC,EAC0B,CAC1B,MAAO,CACL,oBAAqB,GACrB,kBAAAA,EACA,gBAAiB,GACjB,QAAS,QACX,CACF,CAEA,MA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management_kit", "import_purify_ts", "import_ClearSigningType", "import_makeInternalApi", "import_Types", "import_BuildEIP712ContextTask", "apiMock", "contextMouleMock", "parserMock", "mockTransactionParser", "mockTransactionMapper", "getWeb3ChecksFactoryMock", "buildFullContextFactoryMock", "createAppConfig", "web3ChecksEnabled", "TEST_DATA", "TEST_TYPES", "TEST_DOMAIN_VALUES", "TEST_MESSAGE_VALUES", "TEST_CLEAR_SIGN_CONTEXT", "TEST_CHALLENGE", "task", "builtContext", "expectedWeb3Check", "subset", "clearSignContext", "e"]
4
+ "sourcesContent": ["import {\n ClearSignContextType,\n type ContextModule,\n type TypedDataClearSignContextSuccess,\n} from \"@ledgerhq/context-module\";\nimport { TypedDataCalldataParamPresence } from \"@ledgerhq/context-module\";\nimport {\n CommandResultFactory,\n DeviceModelId,\n DeviceSessionStateType,\n DeviceStatus,\n} from \"@ledgerhq/device-management-kit\";\nimport { Just, Left, Nothing, Right } from \"purify-ts\";\n\nimport type { GetConfigCommandResponse } from \"@api/app-binder/GetConfigCommandTypes\";\nimport { ClearSigningType } from \"@api/model/ClearSigningType\";\nimport { makeDeviceActionInternalApiMock } from \"@internal/app-binder/device-action/__test-utils__/makeInternalApi\";\nimport { type TransactionMapperService } from \"@internal/transaction/service/mapper/TransactionMapperService\";\nimport { type TransactionParserService } from \"@internal/transaction/service/parser/TransactionParserService\";\nimport {\n PrimitiveType,\n StructType,\n TypedDataValueField,\n TypedDataValueRoot,\n} from \"@internal/typed-data/model/Types\";\n\nimport { BuildEIP712ContextTask } from \"./BuildEIP712ContextTask\";\n\ndescribe(\"BuildEIP712ContextTask\", () => {\n const apiMock = makeDeviceActionInternalApiMock();\n const contextModuleMock = {\n getFieldContext: vi.fn(),\n getContexts: vi.fn(),\n getTypedDataFilters: vi.fn(),\n };\n const parserMock = {\n parse: vi.fn(),\n };\n const mockTransactionParser: TransactionParserService = {\n extractValue: vi.fn(),\n } as unknown as TransactionParserService;\n const mockTransactionMapper: TransactionMapperService = {\n mapTransactionToSubset: vi.fn(),\n };\n const buildFullContextFactoryMock = vi.fn();\n\n function createAppConfig(\n web3ChecksEnabled: boolean,\n ): GetConfigCommandResponse {\n return {\n blindSigningEnabled: false,\n web3ChecksEnabled,\n web3ChecksOptIn: false,\n version: \"1.13.0\",\n };\n }\n\n const TEST_DATA = {\n domain: {\n name: \"Permit2\",\n chainId: 137,\n verifyingContract: \"0x000000000022d473030f116ddee9f6b43ac78ba3\",\n },\n primaryType: \"PermitSingle\",\n message: {\n details: {\n token: \"0x7ceb23fd6bc0add59e62ac25578270cff1b9f619\",\n amount: \"69420000000000000000\",\n expiration: \"1718184249\",\n nonce: \"0\",\n },\n spender: \"0xec7be89e9d109e7e3fec59c222cf297125fefda2\",\n sigDeadline: \"1715594049\",\n },\n types: {\n PermitSingle: [\n {\n name: \"details\",\n type: \"PermitDetails\",\n },\n {\n name: \"spender\",\n type: \"address\",\n },\n {\n name: \"sigDeadline\",\n type: \"uint256\",\n },\n ],\n PermitDetails: [\n { name: \"token\", type: \"address\" },\n { name: \"amount\", type: \"uint\" },\n { name: \"expiration\", type: \"uint\" },\n { name: \"nonce\", type: \"uint\" },\n ],\n },\n };\n\n const TEST_TYPES = {\n PermitSingle: {\n details: new StructType(\"PermitDetails\"),\n spender: new PrimitiveType(\"address\", \"address\", Nothing),\n sigDeadline: new PrimitiveType(\"uint256\", \"uint\", Just(32)),\n },\n PermitDetails: {\n token: new PrimitiveType(\"address\", \"address\", Nothing),\n amount: new PrimitiveType(\"uint160\", \"uint\", Just(20)),\n expiration: new PrimitiveType(\"uint48\", \"uint\", Just(6)),\n nonce: new PrimitiveType(\"uint48\", \"uint\", Just(6)),\n },\n };\n const TEST_DOMAIN_VALUES = [\n {\n path: \"\",\n type: \"\",\n value: new TypedDataValueRoot(\"EIP712Domain\"),\n },\n {\n path: \"chainId\",\n type: \"uint256\",\n value: new TypedDataValueField(Uint8Array.from([137])),\n },\n ];\n const TEST_MESSAGE_VALUES = [\n {\n path: \"\",\n type: \"\",\n value: new TypedDataValueRoot(\"PermitSingle\"),\n },\n {\n path: \"details.amount\",\n type: \"uint160\",\n value: new TypedDataValueField(Uint8Array.from([0x12])),\n },\n {\n path: \"details.expiration\",\n type: \"uint48\",\n value: new TypedDataValueField(Uint8Array.from([0x13])),\n },\n ];\n const TEST_CLEAR_SIGN_CONTEXT: TypedDataClearSignContextSuccess = {\n type: \"success\",\n messageInfo: {\n displayName: \"Permit2\",\n filtersCount: 1,\n signature:\n \"3045022100e3c597d13d28a87a88b0239404c668373cf5063362f2a81d09eed4582941dfe802207669aabb504fd5b95b2734057f6b8bbf51f14a69a5f9bdf658a5952cefbf44d3\",\n },\n trustedNamesAddresses: {},\n tokens: {},\n calldatas: {},\n proxy: undefined,\n filters: {\n \"details.amount\": {\n displayName: \"Amount allowance\",\n path: \"details.amount\",\n signature:\n \"304402201a46e6b4ef89eaf9fcf4945d053bfc5616a826400fd758312fbbe976bafc07ec022025a9b408722baf983ee053f90179c75b0c55bb0668f437d55493e36069bbd5a3\",\n tokenIndex: 255,\n type: \"amount\",\n },\n },\n };\n\n const TEST_CHALLENGE = \"0x1234\";\n const TEST_FROM = \"0x8ceb23fd6bc0add59e62ac25578270cff1b9f619\";\n\n beforeEach(() => {\n vi.resetAllMocks();\n apiMock.sendCommand.mockResolvedValue(\n CommandResultFactory({ data: { challenge: TEST_CHALLENGE } }),\n );\n buildFullContextFactoryMock.mockReturnValue({\n run: async () => ({\n clearSignContexts: [],\n clearSigningType: ClearSigningType.BASIC,\n }),\n });\n });\n\n it(\"Build context with clear signing context not supported by the device\", async () => {\n // GIVEN\n const task = new BuildEIP712ContextTask(\n apiMock,\n contextModuleMock as unknown as ContextModule,\n parserMock,\n mockTransactionParser,\n mockTransactionMapper,\n TEST_DATA,\n \"44'/60'/0'/0/0\",\n createAppConfig(false),\n TEST_FROM,\n buildFullContextFactoryMock,\n );\n parserMock.parse.mockReturnValueOnce(\n Right({\n types: TEST_TYPES,\n domain: TEST_DOMAIN_VALUES,\n message: TEST_MESSAGE_VALUES,\n }),\n );\n apiMock.getDeviceSessionState.mockReturnValueOnce({\n sessionStateType: DeviceSessionStateType.ReadyWithoutSecureChannel,\n deviceStatus: DeviceStatus.CONNECTED,\n installedApps: [],\n currentApp: { name: \"Ethereum\", version: \"1.11.0\" },\n deviceModelId: DeviceModelId.NANO_S,\n isSecureConnectionAllowed: false,\n });\n // WHEN\n const builtContext = await task.run();\n // THEN\n expect(builtContext).toStrictEqual({\n deviceModelId: DeviceModelId.NANO_S,\n derivationPath: \"44'/60'/0'/0/0\",\n transactionChecks: undefined,\n types: TEST_TYPES,\n domain: TEST_DOMAIN_VALUES,\n message: TEST_MESSAGE_VALUES,\n clearSignContext: Nothing,\n calldatasContexts: {},\n });\n });\n\n it(\"Build context with no clear signing context\", async () => {\n // GIVEN\n const task = new BuildEIP712ContextTask(\n apiMock,\n contextModuleMock as unknown as ContextModule,\n parserMock,\n mockTransactionParser,\n mockTransactionMapper,\n TEST_DATA,\n \"44'/60'/0'/0/0\",\n createAppConfig(false),\n TEST_FROM,\n buildFullContextFactoryMock,\n );\n parserMock.parse.mockReturnValueOnce(\n Right({\n types: TEST_TYPES,\n domain: TEST_DOMAIN_VALUES,\n message: TEST_MESSAGE_VALUES,\n }),\n );\n apiMock.getDeviceSessionState.mockReturnValueOnce({\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 contextModuleMock.getTypedDataFilters.mockResolvedValueOnce({\n type: ClearSignContextType.ERROR,\n error: new Error(\"no filter\"),\n });\n // WHEN\n const builtContext = await task.run();\n // THEN\n expect(builtContext).toStrictEqual({\n deviceModelId: DeviceModelId.FLEX,\n derivationPath: \"44'/60'/0'/0/0\",\n transactionChecks: undefined,\n types: TEST_TYPES,\n domain: TEST_DOMAIN_VALUES,\n message: TEST_MESSAGE_VALUES,\n clearSignContext: Nothing,\n calldatasContexts: {},\n });\n });\n\n it(\"Build context with clear signing context\", async () => {\n // GIVEN\n const txCheckContext = {\n type: ClearSignContextType.TRANSACTION_CHECK,\n payload: \"web3Check\",\n };\n const task = new BuildEIP712ContextTask(\n apiMock,\n contextModuleMock as unknown as ContextModule,\n parserMock,\n mockTransactionParser,\n mockTransactionMapper,\n TEST_DATA,\n \"44'/60'/0'/0/0\",\n createAppConfig(false),\n TEST_FROM,\n buildFullContextFactoryMock,\n );\n contextModuleMock.getContexts.mockResolvedValueOnce([txCheckContext]);\n parserMock.parse.mockReturnValueOnce(\n Right({\n types: TEST_TYPES,\n domain: TEST_DOMAIN_VALUES,\n message: TEST_MESSAGE_VALUES,\n }),\n );\n apiMock.getDeviceSessionState.mockReturnValueOnce({\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 contextModuleMock.getTypedDataFilters.mockResolvedValueOnce(\n TEST_CLEAR_SIGN_CONTEXT,\n );\n // WHEN\n const builtContext = await task.run();\n // THEN\n expect(builtContext).toStrictEqual({\n deviceModelId: DeviceModelId.FLEX,\n derivationPath: \"44'/60'/0'/0/0\",\n transactionChecks: undefined,\n types: TEST_TYPES,\n domain: TEST_DOMAIN_VALUES,\n message: TEST_MESSAGE_VALUES,\n clearSignContext: Just(TEST_CLEAR_SIGN_CONTEXT),\n calldatasContexts: {},\n });\n expect(parserMock.parse).toHaveBeenCalledWith(TEST_DATA);\n expect(contextModuleMock.getTypedDataFilters).toHaveBeenCalledWith({\n verifyingContract: \"0x000000000022d473030f116ddee9f6b43ac78ba3\",\n chainId: 137,\n version: \"v2\",\n schema: TEST_DATA[\"types\"],\n challenge: TEST_CHALLENGE,\n deviceModelId: DeviceModelId.FLEX,\n fieldsValues: [\n {\n path: \"details.amount\",\n value: Uint8Array.from([0x12]),\n },\n {\n path: \"details.expiration\",\n value: Uint8Array.from([0x13]),\n },\n ],\n });\n });\n\n it(\"Build context with clear signing context and transaction checks\", async () => {\n // GIVEN\n const txCheckContext = {\n type: ClearSignContextType.TRANSACTION_CHECK,\n payload: \"transactionCheck\",\n };\n const task = new BuildEIP712ContextTask(\n apiMock,\n contextModuleMock as unknown as ContextModule,\n parserMock,\n mockTransactionParser,\n mockTransactionMapper,\n TEST_DATA,\n \"44'/60'/0'/0/0\",\n createAppConfig(true),\n TEST_FROM,\n buildFullContextFactoryMock,\n );\n contextModuleMock.getContexts.mockResolvedValueOnce([txCheckContext]);\n parserMock.parse.mockReturnValueOnce(\n Right({\n types: TEST_TYPES,\n domain: TEST_DOMAIN_VALUES,\n message: TEST_MESSAGE_VALUES,\n }),\n );\n apiMock.getDeviceSessionState.mockReturnValueOnce({\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 contextModuleMock.getTypedDataFilters.mockResolvedValueOnce(\n TEST_CLEAR_SIGN_CONTEXT,\n );\n // WHEN\n const builtContext = await task.run();\n // THEN\n expect(builtContext).toStrictEqual({\n deviceModelId: DeviceModelId.FLEX,\n derivationPath: \"44'/60'/0'/0/0\",\n types: TEST_TYPES,\n domain: TEST_DOMAIN_VALUES,\n message: TEST_MESSAGE_VALUES,\n clearSignContext: Just(TEST_CLEAR_SIGN_CONTEXT),\n calldatasContexts: {},\n transactionChecks: txCheckContext,\n });\n });\n\n it(\"Build context with clear signing context V1\", async () => {\n // GIVEN\n const task = new BuildEIP712ContextTask(\n apiMock,\n contextModuleMock as unknown as ContextModule,\n parserMock,\n mockTransactionParser,\n mockTransactionMapper,\n TEST_DATA,\n \"44'/60'/0'/0/0\",\n createAppConfig(false),\n TEST_FROM,\n buildFullContextFactoryMock,\n );\n parserMock.parse.mockReturnValueOnce(\n Right({\n types: TEST_TYPES,\n domain: TEST_DOMAIN_VALUES,\n message: TEST_MESSAGE_VALUES,\n }),\n );\n apiMock.getDeviceSessionState.mockReturnValueOnce({\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 contextModuleMock.getTypedDataFilters.mockResolvedValueOnce(\n TEST_CLEAR_SIGN_CONTEXT,\n );\n // WHEN\n await task.run();\n // THEN\n expect(contextModuleMock.getTypedDataFilters).toHaveBeenCalledWith({\n verifyingContract: \"0x000000000022d473030f116ddee9f6b43ac78ba3\",\n chainId: 137,\n version: \"v1\",\n schema: TEST_DATA[\"types\"],\n challenge: TEST_CHALLENGE,\n deviceModelId: DeviceModelId.FLEX,\n fieldsValues: [\n {\n path: \"details.amount\",\n value: Uint8Array.from([0x12]),\n },\n {\n path: \"details.expiration\",\n value: Uint8Array.from([0x13]),\n },\n ],\n });\n });\n\n it(\"Build context with clear signing context and calldatas\", async () => {\n // GIVEN\n const task = new BuildEIP712ContextTask(\n apiMock,\n contextModuleMock as unknown as ContextModule,\n parserMock,\n mockTransactionParser,\n mockTransactionMapper,\n TEST_DATA,\n \"44'/60'/0'/0/0\",\n createAppConfig(false),\n TEST_FROM,\n buildFullContextFactoryMock,\n );\n const subset = {\n chainId: 0x1234,\n data: \"0x6a76120200000000000000000000000023f8abfc2824c397ccb3da89ae772984107ddb99\",\n from: TEST_FROM,\n selector: \"0x778899aa\",\n to: \"0x7ceb23fd6bc0add59e62ac25578270cff1b9f619\",\n value: 4200000000000000n,\n };\n const clearSignContext = {\n ...TEST_CLEAR_SIGN_CONTEXT,\n calldatas: {\n 0: {\n filter: {\n calldataIndex: 0,\n displayName: \"Transaction\",\n valueFlag: true,\n calleeFlag: TypedDataCalldataParamPresence.Present,\n chainIdFlag: false,\n selectorFlag: false,\n amountFlag: true,\n spenderFlag: TypedDataCalldataParamPresence.Present,\n signature:\n \"3045022100d8496ab69152efeef6a923a3ebd225334ad65dcb985814994243be7bc09bf27e02206314835816908dd6d51d3cbb0f9465d91d7ddc9104b34dd6c4247f65c551836e\",\n },\n subset,\n },\n },\n };\n parserMock.parse.mockReturnValueOnce(\n Right({\n types: TEST_TYPES,\n domain: TEST_DOMAIN_VALUES,\n message: TEST_MESSAGE_VALUES,\n }),\n );\n apiMock.getDeviceSessionState.mockReturnValueOnce({\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 contextModuleMock.getTypedDataFilters.mockResolvedValueOnce(\n clearSignContext,\n );\n buildFullContextFactoryMock.mockReturnValue({\n run: async () => ({\n clearSignContexts: [],\n clearSigningType: ClearSigningType.EIP7730,\n }),\n });\n // WHEN\n const builtContext = await task.run();\n // THEN\n expect(builtContext).toStrictEqual({\n deviceModelId: DeviceModelId.FLEX,\n derivationPath: \"44'/60'/0'/0/0\",\n transactionChecks: undefined,\n types: TEST_TYPES,\n domain: TEST_DOMAIN_VALUES,\n message: TEST_MESSAGE_VALUES,\n clearSignContext: Just(clearSignContext),\n calldatasContexts: {\n 0: [],\n },\n });\n });\n\n it(\"Should throw an error if parsing fails\", async () => {\n // GIVEN\n const task = new BuildEIP712ContextTask(\n apiMock,\n contextModuleMock as unknown as ContextModule,\n parserMock,\n mockTransactionParser,\n mockTransactionMapper,\n TEST_DATA,\n \"44'/60'/0'/0/0\",\n createAppConfig(false),\n TEST_FROM,\n buildFullContextFactoryMock,\n );\n parserMock.parse.mockReturnValueOnce(Left(new Error(\"Parsing error\")));\n // WHEN\n try {\n await task.run();\n } catch (e) {\n // THEN\n expect(e).toBeInstanceOf(Error);\n // @ts-expect-error\n expect(e.message).toBe(\"Parsing error\");\n }\n });\n});\n"],
5
+ "mappings": "aAAA,IAAAA,EAIO,oCACPA,EAA+C,oCAC/CC,EAKO,2CACPC,EAA2C,qBAG3CC,EAAiC,uCACjCC,EAAgD,6EAGhDC,EAKO,4CAEPC,EAAuC,oCAEvC,SAAS,yBAA0B,IAAM,CACvC,MAAMC,KAAU,mCAAgC,EAC1CC,EAAoB,CACxB,gBAAiB,GAAG,GAAG,EACvB,YAAa,GAAG,GAAG,EACnB,oBAAqB,GAAG,GAAG,CAC7B,EACMC,EAAa,CACjB,MAAO,GAAG,GAAG,CACf,EACMC,EAAkD,CACtD,aAAc,GAAG,GAAG,CACtB,EACMC,EAAkD,CACtD,uBAAwB,GAAG,GAAG,CAChC,EACMC,EAA8B,GAAG,GAAG,EAE1C,SAASC,EACPC,EAC0B,CAC1B,MAAO,CACL,oBAAqB,GACrB,kBAAAA,EACA,gBAAiB,GACjB,QAAS,QACX,CACF,CAEA,MAAMC,EAAY,CAChB,OAAQ,CACN,KAAM,UACN,QAAS,IACT,kBAAmB,4CACrB,EACA,YAAa,eACb,QAAS,CACP,QAAS,CACP,MAAO,6CACP,OAAQ,uBACR,WAAY,aACZ,MAAO,GACT,EACA,QAAS,6CACT,YAAa,YACf,EACA,MAAO,CACL,aAAc,CACZ,CACE,KAAM,UACN,KAAM,eACR,EACA,CACE,KAAM,UACN,KAAM,SACR,EACA,CACE,KAAM,cACN,KAAM,SACR,CACF,EACA,cAAe,CACb,CAAE,KAAM,QAAS,KAAM,SAAU,EACjC,CAAE,KAAM,SAAU,KAAM,MAAO,EAC/B,CAAE,KAAM,aAAc,KAAM,MAAO,EACnC,CAAE,KAAM,QAAS,KAAM,MAAO,CAChC,CACF,CACF,EAEMC,EAAa,CACjB,aAAc,CACZ,QAAS,IAAI,aAAW,eAAe,EACvC,QAAS,IAAI,gBAAc,UAAW,UAAW,SAAO,EACxD,YAAa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AASC,EACT,oBAAkB,QAAKQ,CAAgB,EACvC,kBAAmB,CACjB,EAAG,CAAC,CACN,CACF,CAAC,CACH,CAAC,EAED,GAAG,yCAA0C,SAAY,CAEvD,MAAMJ,EAAO,IAAI,yBACff,EACAC,EACAC,EACAC,EACAC,EACAI,EACA,iBACAF,EAAgB,EAAK,EACrBQ,EACAT,CACF,EACAH,EAAW,MAAM,uBAAoB,QAAK,IAAI,MAAM,eAAe,CAAC,CAAC,EAErE,GAAI,CACF,MAAMa,EAAK,IAAI,CACjB,OAASK,EAAG,CAEV,OAAOA,CAAC,EAAE,eAAe,KAAK,EAE9B,OAAOA,EAAE,OAAO,EAAE,KAAK,eAAe,CACxC,CACF,CAAC,CACH,CAAC",
6
+ "names": ["import_context_module", "import_device_management_kit", "import_purify_ts", "import_ClearSigningType", "import_makeInternalApi", "import_Types", "import_BuildEIP712ContextTask", "apiMock", "contextModuleMock", "parserMock", "mockTransactionParser", "mockTransactionMapper", "buildFullContextFactoryMock", "createAppConfig", "web3ChecksEnabled", "TEST_DATA", "TEST_TYPES", "TEST_DOMAIN_VALUES", "TEST_MESSAGE_VALUES", "TEST_CLEAR_SIGN_CONTEXT", "TEST_CHALLENGE", "TEST_FROM", "task", "builtContext", "txCheckContext", "subset", "clearSignContext", "e"]
7
7
  }