@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,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../../../src/internal/app-binder/device-action/SignTypedData/SignTypedDataDeviceAction.test.ts"],
4
- "sourcesContent": ["/* eslint @typescript-eslint/consistent-type-imports: 0 */\nimport { type ContextModule } from \"@ledgerhq/context-module\";\nimport {\n CommandResultFactory,\n DeviceActionStatus,\n DeviceModelId,\n DeviceSessionStateType,\n DeviceStatus,\n InvalidStatusWordError,\n UnknownDAError,\n UnknownDeviceExchangeError,\n UserInteractionRequired,\n} from \"@ledgerhq/device-management-kit\";\nimport { Just, Nothing } from \"purify-ts\";\n\nimport { type SignTypedDataDAState } from \"@api/app-binder/SignTypedDataDeviceActionTypes\";\nimport { SignTypedDataDAStateStep } from \"@api/app-binder/SignTypedDataDeviceActionTypes\";\nimport { EthAppCommandErrorFactory } from \"@internal/app-binder/command/utils/ethAppErrors\";\nimport { makeDeviceActionInternalApiMock } from \"@internal/app-binder/device-action/__test-utils__/makeInternalApi\";\nimport { setupOpenAppDAMock } from \"@internal/app-binder/device-action/__test-utils__/setupOpenAppDAMock\";\nimport { testDeviceActionStates } from \"@internal/app-binder/device-action/__test-utils__/testDeviceActionStates\";\nimport { type ProvideEIP712ContextTaskArgs } from \"@internal/app-binder/task/ProvideEIP712ContextTask\";\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} from \"@internal/typed-data/model/Types\";\nimport { type TypedDataParserService } from \"@internal/typed-data/service/TypedDataParserService\";\n\nimport { SignTypedDataDeviceAction } from \"./SignTypedDataDeviceAction\";\n\nvi.mock(\"@ledgerhq/device-management-kit\", async (importOriginal) => {\n const original =\n await importOriginal<typeof import(\"@ledgerhq/device-management-kit\")>();\n return {\n ...original,\n OpenAppDeviceAction: vi.fn(() => ({\n makeStateMachine: vi.fn(),\n })),\n };\n});\n\ndescribe(\"SignTypedDataDeviceAction\", () => {\n const TEST_MESSAGE = {\n domain: {},\n message: {},\n primaryType: \"TestMessage\",\n types: {},\n };\n const TEST_BUILT_CONTEXT: ProvideEIP712ContextTaskArgs = {\n deviceModelId: DeviceModelId.STAX,\n derivationPath: \"44'/60'/0'/0/0\",\n web3Check: null,\n 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 },\n domain: [\n {\n path: \"chainId\",\n type: \"uint256\",\n value: new TypedDataValueField(Uint8Array.from([137])),\n },\n ],\n message: [\n {\n path: \"details.expiration\",\n type: \"uint48\",\n value: new TypedDataValueField(Uint8Array.from([0x13])),\n },\n ],\n clearSignContext: Just({\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 calldatasContexts: {},\n };\n\n const mockParser: TypedDataParserService = {\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 mockContextModule: ContextModule = {\n getFieldContext: vi.fn(),\n getContexts: vi.fn(),\n getTypedDataFilters: vi.fn(),\n getWeb3Checks: vi.fn(),\n getSolanaContext: vi.fn(),\n };\n const apiMock = makeDeviceActionInternalApiMock();\n const getAppConfigMock = vi.fn();\n const web3CheckOptInMock = vi.fn();\n const buildContextMock = vi.fn();\n const provideContextMock = vi.fn();\n const signTypedDataMock = vi.fn();\n const signTypedDataLegacyMock = vi.fn();\n function extractDependenciesMock() {\n return {\n getAppConfig: getAppConfigMock,\n web3CheckOptIn: web3CheckOptInMock,\n buildContext: buildContextMock,\n provideContext: provideContextMock,\n signTypedData: signTypedDataMock,\n signTypedDataLegacy: signTypedDataLegacyMock,\n };\n }\n\n function createAppConfig(\n version: string,\n web3ChecksEnabled: boolean,\n web3ChecksOptIn: boolean,\n ) {\n return {\n blindSigningEnabled: false,\n web3ChecksEnabled,\n web3ChecksOptIn,\n version,\n };\n }\n\n function setupAppConfig(\n version: string,\n web3ChecksEnabled: boolean,\n web3ChecksOptIn: boolean,\n ) {\n apiMock.getDeviceSessionState.mockReturnValueOnce({\n sessionStateType: DeviceSessionStateType.ReadyWithoutSecureChannel,\n deviceStatus: DeviceStatus.CONNECTED,\n installedApps: [],\n currentApp: { name: \"Ethereum\", version },\n deviceModelId: DeviceModelId.FLEX,\n isSecureConnectionAllowed: false,\n });\n getAppConfigMock.mockResolvedValue(\n CommandResultFactory({\n data: createAppConfig(version, web3ChecksEnabled, web3ChecksOptIn),\n }),\n );\n }\n\n beforeEach(() => {\n vi.resetAllMocks();\n });\n\n describe(\"Success case\", () => {\n it(\"should call external dependencies with the correct parameters\", () =>\n new Promise<void>((resolve, reject) => {\n setupOpenAppDAMock();\n setupAppConfig(\"1.15.0\", false, false);\n\n const deviceAction = new SignTypedDataDeviceAction({\n input: {\n derivationPath: \"44'/60'/0'/0/0\",\n data: TEST_MESSAGE,\n contextModule: mockContextModule,\n parser: mockParser,\n transactionParser: mockTransactionParser,\n transactionMapper: mockTransactionMapper,\n skipOpenApp: false,\n },\n });\n\n // Mock the dependencies to return some sample data\n vi.spyOn(deviceAction, \"extractDependencies\").mockReturnValue(\n extractDependenciesMock(),\n );\n buildContextMock.mockResolvedValueOnce(TEST_BUILT_CONTEXT);\n provideContextMock.mockResolvedValueOnce(\n CommandResultFactory({ data: undefined }),\n );\n signTypedDataMock.mockResolvedValueOnce(\n CommandResultFactory({\n data: {\n v: 0x1c,\n r: \"0x8a540510e13b0f2b11a451275716d29e08caad07e89a1c84964782fb5e1ad788\",\n s: \"0x64a0de235b270fbe81e8e40688f4a9f9ad9d283d690552c9331d7773ceafa513\",\n },\n }),\n );\n\n // Expected intermediate values for the following state sequence:\n // Initial -> OpenApp -> BuildContext -> ProvideContext -> SignTypedData\n const expectedStates: Array<SignTypedDataDAState> = [\n {\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.None,\n step: SignTypedDataDAStateStep.OPEN_APP,\n },\n status: DeviceActionStatus.Pending,\n },\n {\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.ConfirmOpenApp,\n step: SignTypedDataDAStateStep.OPEN_APP,\n },\n status: DeviceActionStatus.Pending,\n },\n {\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.None,\n step: SignTypedDataDAStateStep.GET_APP_CONFIG,\n },\n status: DeviceActionStatus.Pending,\n },\n {\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.None,\n step: SignTypedDataDAStateStep.BUILD_CONTEXT,\n },\n status: DeviceActionStatus.Pending,\n },\n {\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.SignTypedData,\n step: SignTypedDataDAStateStep.PROVIDE_CONTEXT,\n },\n status: DeviceActionStatus.Pending,\n },\n {\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.SignTypedData,\n step: SignTypedDataDAStateStep.SIGN_TYPED_DATA,\n },\n status: DeviceActionStatus.Pending,\n },\n {\n output: {\n v: 0x1c,\n r: \"0x8a540510e13b0f2b11a451275716d29e08caad07e89a1c84964782fb5e1ad788\",\n s: \"0x64a0de235b270fbe81e8e40688f4a9f9ad9d283d690552c9331d7773ceafa513\",\n },\n status: DeviceActionStatus.Completed,\n },\n ];\n\n testDeviceActionStates(deviceAction, expectedStates, apiMock, {\n onError: reject,\n onDone: () => {\n // Verify mocks calls parameters\n expect(buildContextMock).toHaveBeenCalledWith(\n expect.objectContaining({\n input: {\n contextModule: mockContextModule,\n parser: mockParser,\n transactionParser: mockTransactionParser,\n transactionMapper: mockTransactionMapper,\n data: TEST_MESSAGE,\n appConfig: createAppConfig(\"1.15.0\", false, false),\n derivationPath: \"44'/60'/0'/0/0\",\n },\n }),\n );\n\n expect(provideContextMock).toHaveBeenCalledWith(\n expect.objectContaining({\n input: {\n contextModule: mockContextModule,\n taskArgs: TEST_BUILT_CONTEXT,\n },\n }),\n );\n\n expect(signTypedDataMock).toHaveBeenCalledWith(\n expect.objectContaining({\n input: {\n derivationPath: \"44'/60'/0'/0/0\",\n },\n }),\n );\n\n resolve();\n },\n });\n }));\n\n it(\"should be successful whlie skipping OpenApp\", () =>\n new Promise<void>((resolve, reject) => {\n setupOpenAppDAMock();\n setupAppConfig(\"1.15.0\", false, false);\n\n const deviceAction = new SignTypedDataDeviceAction({\n input: {\n derivationPath: \"44'/60'/0'/0/0\",\n data: TEST_MESSAGE,\n contextModule: mockContextModule,\n parser: mockParser,\n transactionParser: mockTransactionParser,\n transactionMapper: mockTransactionMapper,\n skipOpenApp: true,\n },\n });\n\n // Mock the dependencies to return some sample data\n vi.spyOn(deviceAction, \"extractDependencies\").mockReturnValue(\n extractDependenciesMock(),\n );\n buildContextMock.mockResolvedValueOnce(TEST_BUILT_CONTEXT);\n provideContextMock.mockResolvedValueOnce(\n CommandResultFactory({ data: undefined }),\n );\n signTypedDataMock.mockResolvedValueOnce(\n CommandResultFactory({\n data: {\n v: 0x1c,\n r: \"0x8a540510e13b0f2b11a451275716d29e08caad07e89a1c84964782fb5e1ad788\",\n s: \"0x64a0de235b270fbe81e8e40688f4a9f9ad9d283d690552c9331d7773ceafa513\",\n },\n }),\n );\n\n // Expected intermediate values for the following state sequence:\n // Initial -> BuildContext -> ProvideContext -> SignTypedData\n const expectedStates: Array<SignTypedDataDAState> = [\n {\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.None,\n step: SignTypedDataDAStateStep.GET_APP_CONFIG,\n },\n status: DeviceActionStatus.Pending,\n },\n {\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.None,\n step: SignTypedDataDAStateStep.BUILD_CONTEXT,\n },\n status: DeviceActionStatus.Pending,\n },\n {\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.SignTypedData,\n step: SignTypedDataDAStateStep.PROVIDE_CONTEXT,\n },\n status: DeviceActionStatus.Pending,\n },\n {\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.SignTypedData,\n step: SignTypedDataDAStateStep.SIGN_TYPED_DATA,\n },\n status: DeviceActionStatus.Pending,\n },\n {\n output: {\n v: 0x1c,\n r: \"0x8a540510e13b0f2b11a451275716d29e08caad07e89a1c84964782fb5e1ad788\",\n s: \"0x64a0de235b270fbe81e8e40688f4a9f9ad9d283d690552c9331d7773ceafa513\",\n },\n status: DeviceActionStatus.Completed,\n },\n ];\n\n testDeviceActionStates(deviceAction, expectedStates, apiMock, {\n onError: reject,\n onDone: resolve,\n });\n }));\n\n it(\"should fallback to legacy signing if the new one fails\", () =>\n new Promise<void>((resolve, reject) => {\n setupOpenAppDAMock();\n setupAppConfig(\"1.15.0\", false, false);\n\n const deviceAction = new SignTypedDataDeviceAction({\n input: {\n derivationPath: \"44'/60'/0'/0/0\",\n data: TEST_MESSAGE,\n contextModule: mockContextModule,\n parser: mockParser,\n transactionParser: mockTransactionParser,\n transactionMapper: mockTransactionMapper,\n skipOpenApp: false,\n },\n });\n\n // Mock the providing error\n vi.spyOn(deviceAction, \"extractDependencies\").mockReturnValue(\n extractDependenciesMock(),\n );\n buildContextMock.mockResolvedValueOnce(TEST_BUILT_CONTEXT);\n provideContextMock.mockResolvedValueOnce(\n CommandResultFactory({\n error: EthAppCommandErrorFactory({\n errorCode: \"6a80\",\n message: \"\",\n }),\n }),\n );\n signTypedDataLegacyMock.mockResolvedValueOnce(\n CommandResultFactory({\n data: {\n v: 0x1c,\n r: \"0x8a540510e13b0f2b11a451275716d29e08caad07e89a1c84964782fb5e1ad788\",\n s: \"0x64a0de235b270fbe81e8e40688f4a9f9ad9d283d690552c9331d7773ceafa513\",\n },\n }),\n );\n\n const expectedStates: Array<SignTypedDataDAState> = [\n {\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.None,\n step: SignTypedDataDAStateStep.OPEN_APP,\n },\n status: DeviceActionStatus.Pending,\n },\n {\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.ConfirmOpenApp,\n step: SignTypedDataDAStateStep.OPEN_APP,\n },\n status: DeviceActionStatus.Pending,\n },\n {\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.None,\n step: SignTypedDataDAStateStep.GET_APP_CONFIG,\n },\n status: DeviceActionStatus.Pending,\n },\n {\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.None,\n step: SignTypedDataDAStateStep.BUILD_CONTEXT,\n },\n status: DeviceActionStatus.Pending,\n },\n {\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.SignTypedData,\n step: SignTypedDataDAStateStep.PROVIDE_CONTEXT,\n },\n status: DeviceActionStatus.Pending,\n },\n {\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.SignTypedData,\n step: SignTypedDataDAStateStep.SIGN_TYPED_DATA_LEGACY,\n },\n status: DeviceActionStatus.Pending,\n },\n {\n output: {\n v: 0x1c,\n r: \"0x8a540510e13b0f2b11a451275716d29e08caad07e89a1c84964782fb5e1ad788\",\n s: \"0x64a0de235b270fbe81e8e40688f4a9f9ad9d283d690552c9331d7773ceafa513\",\n },\n status: DeviceActionStatus.Completed,\n },\n ];\n\n testDeviceActionStates(deviceAction, expectedStates, apiMock, {\n onError: reject,\n onDone: resolve,\n });\n }));\n\n it(\"should fallback to legacy signing BuildContext fails\", () =>\n new Promise<void>((resolve, reject) => {\n setupOpenAppDAMock();\n setupAppConfig(\"1.15.0\", false, false);\n\n const deviceAction = new SignTypedDataDeviceAction({\n input: {\n derivationPath: \"44'/60'/0'/0/0\",\n data: TEST_MESSAGE,\n contextModule: mockContextModule,\n parser: mockParser,\n transactionParser: mockTransactionParser,\n transactionMapper: mockTransactionMapper,\n skipOpenApp: false,\n },\n });\n\n // Mock the providing error\n vi.spyOn(deviceAction, \"extractDependencies\").mockReturnValue(\n extractDependenciesMock(),\n );\n buildContextMock.mockRejectedValueOnce(new UnknownDAError(\"Error\"));\n signTypedDataLegacyMock.mockResolvedValueOnce(\n CommandResultFactory({\n data: {\n v: 0x1c,\n r: \"0x8a540510e13b0f2b11a451275716d29e08caad07e89a1c84964782fb5e1ad788\",\n s: \"0x64a0de235b270fbe81e8e40688f4a9f9ad9d283d690552c9331d7773ceafa513\",\n },\n }),\n );\n\n const expectedStates: Array<SignTypedDataDAState> = [\n {\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.None,\n step: SignTypedDataDAStateStep.OPEN_APP,\n },\n status: DeviceActionStatus.Pending,\n },\n {\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.ConfirmOpenApp,\n step: SignTypedDataDAStateStep.OPEN_APP,\n },\n status: DeviceActionStatus.Pending,\n },\n {\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.None,\n step: SignTypedDataDAStateStep.GET_APP_CONFIG,\n },\n status: DeviceActionStatus.Pending,\n },\n {\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.None,\n step: SignTypedDataDAStateStep.BUILD_CONTEXT,\n },\n status: DeviceActionStatus.Pending,\n },\n {\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.SignTypedData,\n step: SignTypedDataDAStateStep.SIGN_TYPED_DATA_LEGACY,\n },\n status: DeviceActionStatus.Pending,\n },\n {\n output: {\n v: 0x1c,\n r: \"0x8a540510e13b0f2b11a451275716d29e08caad07e89a1c84964782fb5e1ad788\",\n s: \"0x64a0de235b270fbe81e8e40688f4a9f9ad9d283d690552c9331d7773ceafa513\",\n },\n status: DeviceActionStatus.Completed,\n },\n ];\n\n testDeviceActionStates(deviceAction, expectedStates, apiMock, {\n onError: reject,\n onDone: resolve,\n });\n }));\n\n it(\"should not fallback to legacy signing if rejected by the user during streaming\", () =>\n new Promise<void>((resolve, reject) => {\n setupOpenAppDAMock();\n setupAppConfig(\"1.15.0\", false, false);\n\n const deviceAction = new SignTypedDataDeviceAction({\n input: {\n derivationPath: \"44'/60'/0'/0/0\",\n data: TEST_MESSAGE,\n contextModule: mockContextModule,\n parser: mockParser,\n transactionParser: mockTransactionParser,\n transactionMapper: mockTransactionMapper,\n skipOpenApp: false,\n },\n });\n\n // Mock the providing error\n vi.spyOn(deviceAction, \"extractDependencies\").mockReturnValue(\n extractDependenciesMock(),\n );\n buildContextMock.mockResolvedValueOnce(TEST_BUILT_CONTEXT);\n provideContextMock.mockResolvedValueOnce(\n CommandResultFactory({\n error: EthAppCommandErrorFactory({\n errorCode: \"6985\",\n message: \"\",\n }),\n }),\n );\n signTypedDataLegacyMock.mockResolvedValueOnce(\n CommandResultFactory({\n data: {\n v: 0x1c,\n r: \"0x8a540510e13b0f2b11a451275716d29e08caad07e89a1c84964782fb5e1ad788\",\n s: \"0x64a0de235b270fbe81e8e40688f4a9f9ad9d283d690552c9331d7773ceafa513\",\n },\n }),\n );\n\n const expectedStates: Array<SignTypedDataDAState> = [\n {\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.None,\n step: SignTypedDataDAStateStep.OPEN_APP,\n },\n status: DeviceActionStatus.Pending,\n },\n {\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.ConfirmOpenApp,\n step: SignTypedDataDAStateStep.OPEN_APP,\n },\n status: DeviceActionStatus.Pending,\n },\n {\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.None,\n step: SignTypedDataDAStateStep.GET_APP_CONFIG,\n },\n status: DeviceActionStatus.Pending,\n },\n {\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.None,\n step: SignTypedDataDAStateStep.BUILD_CONTEXT,\n },\n status: DeviceActionStatus.Pending,\n },\n {\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.SignTypedData,\n step: SignTypedDataDAStateStep.PROVIDE_CONTEXT,\n },\n status: DeviceActionStatus.Pending,\n },\n {\n error: EthAppCommandErrorFactory({\n errorCode: \"6985\",\n message: \"\",\n }),\n status: DeviceActionStatus.Error,\n },\n ];\n\n testDeviceActionStates(deviceAction, expectedStates, apiMock, {\n onError: reject,\n onDone: resolve,\n });\n }));\n });\n\n describe(\"Web3Checks\", () => {\n it(\"should call external dependencies with web3Checks enabled and supported\", () =>\n new Promise<void>((resolve, reject) => {\n setupOpenAppDAMock();\n setupAppConfig(\"1.16.0\", true, true);\n\n const deviceAction = new SignTypedDataDeviceAction({\n input: {\n derivationPath: \"44'/60'/0'/0/0\",\n data: TEST_MESSAGE,\n contextModule: mockContextModule,\n parser: mockParser,\n transactionParser: mockTransactionParser,\n transactionMapper: mockTransactionMapper,\n skipOpenApp: false,\n },\n });\n\n // Mock the dependencies to return some sample data\n vi.spyOn(deviceAction, \"extractDependencies\").mockReturnValue(\n extractDependenciesMock(),\n );\n buildContextMock.mockRejectedValueOnce(\n new InvalidStatusWordError(\"buildContext error\"),\n );\n signTypedDataLegacyMock.mockRejectedValueOnce(\n new InvalidStatusWordError(\"signTypedDataLegacy error\"),\n );\n\n // Expected intermediate values for the following state sequence:\n // Initial -> OpenApp -> GetAppConfiguration -> BuildContext\n const expectedStates: Array<SignTypedDataDAState> = [\n {\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.None,\n step: SignTypedDataDAStateStep.OPEN_APP,\n },\n status: DeviceActionStatus.Pending,\n },\n {\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.ConfirmOpenApp,\n step: SignTypedDataDAStateStep.OPEN_APP,\n },\n status: DeviceActionStatus.Pending,\n },\n {\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.None,\n step: SignTypedDataDAStateStep.GET_APP_CONFIG,\n },\n status: DeviceActionStatus.Pending,\n },\n {\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.None,\n step: SignTypedDataDAStateStep.BUILD_CONTEXT,\n },\n status: DeviceActionStatus.Pending,\n },\n {\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.SignTypedData,\n step: SignTypedDataDAStateStep.SIGN_TYPED_DATA_LEGACY,\n },\n status: DeviceActionStatus.Pending,\n },\n {\n error: new InvalidStatusWordError(\"signTypedDataLegacy error\"),\n status: DeviceActionStatus.Error,\n },\n ];\n\n testDeviceActionStates(deviceAction, expectedStates, apiMock, {\n onError: reject,\n onDone: () => {\n // Verify mocks calls parameters\n expect(getAppConfigMock).toHaveBeenCalled();\n expect(buildContextMock).toHaveBeenCalledWith(\n expect.objectContaining({\n input: {\n contextModule: mockContextModule,\n parser: mockParser,\n transactionParser: mockTransactionParser,\n transactionMapper: mockTransactionMapper,\n data: TEST_MESSAGE,\n appConfig: createAppConfig(\"1.16.0\", true, true),\n derivationPath: \"44'/60'/0'/0/0\",\n },\n }),\n );\n resolve();\n },\n });\n }));\n\n it(\"should call external dependencies with web3Checks supported but disabled\", () =>\n new Promise<void>((resolve, reject) => {\n setupOpenAppDAMock();\n setupAppConfig(\"1.16.0\", false, true);\n\n const deviceAction = new SignTypedDataDeviceAction({\n input: {\n derivationPath: \"44'/60'/0'/0/0\",\n data: TEST_MESSAGE,\n contextModule: mockContextModule,\n parser: mockParser,\n transactionParser: mockTransactionParser,\n transactionMapper: mockTransactionMapper,\n skipOpenApp: false,\n },\n });\n\n // Mock the dependencies to return some sample data\n vi.spyOn(deviceAction, \"extractDependencies\").mockReturnValue(\n extractDependenciesMock(),\n );\n buildContextMock.mockRejectedValueOnce(\n new InvalidStatusWordError(\"buildContext error\"),\n );\n signTypedDataLegacyMock.mockRejectedValueOnce(\n new InvalidStatusWordError(\"signTypedDataLegacy error\"),\n );\n\n // Expected intermediate values for the following state sequence:\n // Initial -> OpenApp -> GetAppConfiguration -> BuildContext\n const expectedStates: Array<SignTypedDataDAState> = [\n {\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.None,\n step: SignTypedDataDAStateStep.OPEN_APP,\n },\n status: DeviceActionStatus.Pending,\n },\n {\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.ConfirmOpenApp,\n step: SignTypedDataDAStateStep.OPEN_APP,\n },\n status: DeviceActionStatus.Pending,\n },\n {\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.None,\n step: SignTypedDataDAStateStep.GET_APP_CONFIG,\n },\n status: DeviceActionStatus.Pending,\n },\n {\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.None,\n step: SignTypedDataDAStateStep.BUILD_CONTEXT,\n },\n status: DeviceActionStatus.Pending,\n },\n {\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.SignTypedData,\n step: SignTypedDataDAStateStep.SIGN_TYPED_DATA_LEGACY,\n },\n status: DeviceActionStatus.Pending,\n },\n {\n error: new InvalidStatusWordError(\"signTypedDataLegacy error\"),\n status: DeviceActionStatus.Error,\n },\n ];\n\n testDeviceActionStates(deviceAction, expectedStates, apiMock, {\n onError: reject,\n onDone: () => {\n // Verify mocks calls parameters\n expect(getAppConfigMock).toHaveBeenCalled();\n expect(buildContextMock).toHaveBeenCalledWith(\n expect.objectContaining({\n input: {\n contextModule: mockContextModule,\n parser: mockParser,\n transactionParser: mockTransactionParser,\n transactionMapper: mockTransactionMapper,\n data: TEST_MESSAGE,\n appConfig: createAppConfig(\"1.16.0\", false, true),\n derivationPath: \"44'/60'/0'/0/0\",\n },\n }),\n );\n resolve();\n },\n });\n }));\n\n it(\"should call external dependencies with web3Checks opt-in, then enabled\", () =>\n new Promise<void>((resolve, reject) => {\n setupOpenAppDAMock();\n setupAppConfig(\"1.16.0\", false, false);\n\n const deviceAction = new SignTypedDataDeviceAction({\n input: {\n derivationPath: \"44'/60'/0'/0/0\",\n data: TEST_MESSAGE,\n contextModule: mockContextModule,\n parser: mockParser,\n transactionParser: mockTransactionParser,\n transactionMapper: mockTransactionMapper,\n skipOpenApp: false,\n },\n });\n\n // Mock the dependencies to return some sample data\n vi.spyOn(deviceAction, \"extractDependencies\").mockReturnValue(\n extractDependenciesMock(),\n );\n web3CheckOptInMock.mockResolvedValueOnce(\n CommandResultFactory({ data: { enabled: true } }),\n );\n buildContextMock.mockRejectedValueOnce(\n new InvalidStatusWordError(\"buildContext error\"),\n );\n signTypedDataLegacyMock.mockRejectedValueOnce(\n new InvalidStatusWordError(\"signTypedDataLegacy error\"),\n );\n\n // Expected intermediate values for the following state sequence:\n // Initial -> OpenApp -> GetAppConfiguration -> Web3ChecksOptIn -> BuildContext\n const expectedStates: Array<SignTypedDataDAState> = [\n {\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.None,\n step: SignTypedDataDAStateStep.OPEN_APP,\n },\n status: DeviceActionStatus.Pending,\n },\n {\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.ConfirmOpenApp,\n step: SignTypedDataDAStateStep.OPEN_APP,\n },\n status: DeviceActionStatus.Pending,\n },\n {\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.None,\n step: SignTypedDataDAStateStep.GET_APP_CONFIG,\n },\n status: DeviceActionStatus.Pending,\n },\n {\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.Web3ChecksOptIn,\n step: SignTypedDataDAStateStep.WEB3_CHECKS_OPT_IN,\n },\n status: DeviceActionStatus.Pending,\n },\n {\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.None,\n step: SignTypedDataDAStateStep.WEB3_CHECKS_OPT_IN_RESULT,\n result: true,\n },\n status: DeviceActionStatus.Pending,\n },\n {\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.None,\n step: SignTypedDataDAStateStep.BUILD_CONTEXT,\n },\n status: DeviceActionStatus.Pending,\n },\n {\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.SignTypedData,\n step: SignTypedDataDAStateStep.SIGN_TYPED_DATA_LEGACY,\n },\n status: DeviceActionStatus.Pending,\n },\n {\n error: new InvalidStatusWordError(\"signTypedDataLegacy error\"),\n status: DeviceActionStatus.Error,\n },\n ];\n\n testDeviceActionStates(deviceAction, expectedStates, apiMock, {\n onError: reject,\n onDone: () => {\n // Verify mocks calls parameters\n expect(getAppConfigMock).toHaveBeenCalled();\n expect(web3CheckOptInMock).toHaveBeenCalled();\n expect(buildContextMock).toHaveBeenCalledWith(\n expect.objectContaining({\n input: {\n contextModule: mockContextModule,\n parser: mockParser,\n transactionParser: mockTransactionParser,\n transactionMapper: mockTransactionMapper,\n data: TEST_MESSAGE,\n appConfig: createAppConfig(\"1.16.0\", true, false),\n derivationPath: \"44'/60'/0'/0/0\",\n },\n }),\n );\n resolve();\n },\n });\n }));\n\n it(\"should call external dependencies with web3Checks opt-in, then disabled\", () =>\n new Promise<void>((resolve, reject) => {\n setupOpenAppDAMock();\n setupAppConfig(\"1.16.0\", false, false);\n\n const deviceAction = new SignTypedDataDeviceAction({\n input: {\n derivationPath: \"44'/60'/0'/0/0\",\n data: TEST_MESSAGE,\n contextModule: mockContextModule,\n parser: mockParser,\n transactionParser: mockTransactionParser,\n transactionMapper: mockTransactionMapper,\n skipOpenApp: false,\n },\n });\n\n // Mock the dependencies to return some sample data\n vi.spyOn(deviceAction, \"extractDependencies\").mockReturnValue(\n extractDependenciesMock(),\n );\n web3CheckOptInMock.mockResolvedValueOnce(\n CommandResultFactory({ data: { enabled: false } }),\n );\n buildContextMock.mockRejectedValueOnce(\n new InvalidStatusWordError(\"buildContext error\"),\n );\n signTypedDataLegacyMock.mockRejectedValueOnce(\n new InvalidStatusWordError(\"signTypedDataLegacy error\"),\n );\n\n // Expected intermediate values for the following state sequence:\n // Initial -> OpenApp -> GetAppConfiguration -> Web3ChecksOptIn -> BuildContext\n const expectedStates: Array<SignTypedDataDAState> = [\n {\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.None,\n step: SignTypedDataDAStateStep.OPEN_APP,\n },\n status: DeviceActionStatus.Pending,\n },\n {\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.ConfirmOpenApp,\n step: SignTypedDataDAStateStep.OPEN_APP,\n },\n status: DeviceActionStatus.Pending,\n },\n {\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.None,\n step: SignTypedDataDAStateStep.GET_APP_CONFIG,\n },\n status: DeviceActionStatus.Pending,\n },\n {\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.Web3ChecksOptIn,\n step: SignTypedDataDAStateStep.WEB3_CHECKS_OPT_IN,\n },\n status: DeviceActionStatus.Pending,\n },\n {\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.None,\n step: SignTypedDataDAStateStep.WEB3_CHECKS_OPT_IN_RESULT,\n result: false,\n },\n status: DeviceActionStatus.Pending,\n },\n {\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.None,\n step: SignTypedDataDAStateStep.BUILD_CONTEXT,\n },\n status: DeviceActionStatus.Pending,\n },\n {\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.SignTypedData,\n step: SignTypedDataDAStateStep.SIGN_TYPED_DATA_LEGACY,\n },\n status: DeviceActionStatus.Pending,\n },\n {\n error: new InvalidStatusWordError(\"signTypedDataLegacy error\"),\n status: DeviceActionStatus.Error,\n },\n ];\n\n testDeviceActionStates(deviceAction, expectedStates, apiMock, {\n onError: reject,\n onDone: () => {\n // Verify mocks calls parameters\n expect(getAppConfigMock).toHaveBeenCalled();\n expect(web3CheckOptInMock).toHaveBeenCalled();\n expect(buildContextMock).toHaveBeenCalledWith(\n expect.objectContaining({\n input: {\n contextModule: mockContextModule,\n parser: mockParser,\n transactionParser: mockTransactionParser,\n transactionMapper: mockTransactionMapper,\n data: TEST_MESSAGE,\n appConfig: createAppConfig(\"1.16.0\", false, false),\n derivationPath: \"44'/60'/0'/0/0\",\n },\n }),\n );\n resolve();\n },\n });\n }));\n });\n\n describe(\"error cases\", () => {\n it(\"Error if the open app fails\", () =>\n new Promise<void>((resolve, reject) => {\n setupOpenAppDAMock(new UnknownDAError(\"Mocked error\"));\n\n const expectedStates: Array<SignTypedDataDAState> = [\n {\n status: DeviceActionStatus.Pending,\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.None,\n step: SignTypedDataDAStateStep.OPEN_APP,\n },\n },\n {\n status: DeviceActionStatus.Pending,\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.ConfirmOpenApp,\n step: SignTypedDataDAStateStep.OPEN_APP,\n },\n },\n {\n status: DeviceActionStatus.Error,\n error: new UnknownDAError(\"Mocked error\"),\n },\n ];\n\n const deviceAction = new SignTypedDataDeviceAction({\n input: {\n derivationPath: \"44'/60'/0'/0/0\",\n data: TEST_MESSAGE,\n contextModule: mockContextModule,\n parser: mockParser,\n transactionParser: mockTransactionParser,\n transactionMapper: mockTransactionMapper,\n skipOpenApp: false,\n },\n });\n\n testDeviceActionStates(deviceAction, expectedStates, apiMock, {\n onError: reject,\n onDone: resolve,\n });\n }));\n\n it(\"Error thrown while providing context\", () =>\n new Promise<void>((resolve, reject) => {\n setupOpenAppDAMock();\n setupAppConfig(\"1.15.0\", false, false);\n\n const deviceAction = new SignTypedDataDeviceAction({\n input: {\n derivationPath: \"44'/60'/0'/0/0\",\n data: TEST_MESSAGE,\n contextModule: mockContextModule,\n parser: mockParser,\n transactionParser: mockTransactionParser,\n transactionMapper: mockTransactionMapper,\n skipOpenApp: false,\n },\n });\n\n // Mock the providing error\n vi.spyOn(deviceAction, \"extractDependencies\").mockReturnValue(\n extractDependenciesMock(),\n );\n buildContextMock.mockResolvedValueOnce(TEST_BUILT_CONTEXT);\n provideContextMock.mockRejectedValueOnce(new UnknownDAError(\"Error\"));\n\n const expectedStates: Array<SignTypedDataDAState> = [\n {\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.None,\n step: SignTypedDataDAStateStep.OPEN_APP,\n },\n status: DeviceActionStatus.Pending,\n },\n {\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.ConfirmOpenApp,\n step: SignTypedDataDAStateStep.OPEN_APP,\n },\n status: DeviceActionStatus.Pending,\n },\n {\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.None,\n step: SignTypedDataDAStateStep.GET_APP_CONFIG,\n },\n status: DeviceActionStatus.Pending,\n },\n {\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.None,\n step: SignTypedDataDAStateStep.BUILD_CONTEXT,\n },\n status: DeviceActionStatus.Pending,\n },\n {\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.SignTypedData,\n step: SignTypedDataDAStateStep.PROVIDE_CONTEXT,\n },\n status: DeviceActionStatus.Pending,\n },\n {\n error: new UnknownDAError(\"Error\"),\n status: DeviceActionStatus.Error,\n },\n ];\n\n testDeviceActionStates(deviceAction, expectedStates, apiMock, {\n onError: reject,\n onDone: resolve,\n });\n }));\n\n it(\"Error while signing\", () =>\n new Promise<void>((resolve, reject) => {\n setupOpenAppDAMock();\n setupAppConfig(\"1.15.0\", false, false);\n\n const deviceAction = new SignTypedDataDeviceAction({\n input: {\n derivationPath: \"44'/60'/0'/0/0\",\n data: TEST_MESSAGE,\n contextModule: mockContextModule,\n parser: mockParser,\n transactionParser: mockTransactionParser,\n transactionMapper: mockTransactionMapper,\n skipOpenApp: false,\n },\n });\n\n // Mock signing error\n vi.spyOn(deviceAction, \"extractDependencies\").mockReturnValue(\n extractDependenciesMock(),\n );\n buildContextMock.mockResolvedValueOnce(TEST_BUILT_CONTEXT);\n provideContextMock.mockResolvedValueOnce(\n CommandResultFactory({ data: undefined }),\n );\n signTypedDataMock.mockResolvedValueOnce(\n CommandResultFactory({\n error: new UnknownDeviceExchangeError(\n \"Error while signing the typed data\",\n ),\n }),\n );\n\n const expectedStates: Array<SignTypedDataDAState> = [\n {\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.None,\n step: SignTypedDataDAStateStep.OPEN_APP,\n },\n status: DeviceActionStatus.Pending,\n },\n {\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.ConfirmOpenApp,\n step: SignTypedDataDAStateStep.OPEN_APP,\n },\n status: DeviceActionStatus.Pending,\n },\n {\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.None,\n step: SignTypedDataDAStateStep.GET_APP_CONFIG,\n },\n status: DeviceActionStatus.Pending,\n },\n {\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.None,\n step: SignTypedDataDAStateStep.BUILD_CONTEXT,\n },\n status: DeviceActionStatus.Pending,\n },\n {\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.SignTypedData,\n step: SignTypedDataDAStateStep.PROVIDE_CONTEXT,\n },\n status: DeviceActionStatus.Pending,\n },\n {\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.SignTypedData,\n step: SignTypedDataDAStateStep.SIGN_TYPED_DATA,\n },\n status: DeviceActionStatus.Pending,\n },\n {\n error: new UnknownDeviceExchangeError(\n \"Error while signing the typed data\",\n ),\n status: DeviceActionStatus.Error,\n },\n ];\n\n testDeviceActionStates(deviceAction, expectedStates, apiMock, {\n onError: reject,\n onDone: resolve,\n });\n }));\n });\n});\n"],
5
- "mappings": "aAEA,IAAAA,EAUO,2CACPC,EAA8B,qBAG9BC,EAAyC,0DACzCC,EAA0C,2DAC1CC,EAAgD,6EAChDC,EAAmC,gFACnCC,EAAuC,oFAIvCC,EAIO,4CAGPC,EAA0C,uCAE1C,GAAG,KAAK,kCAAmC,MAAOC,IAGzC,CACL,GAFA,MAAMA,EAAiE,EAGvE,oBAAqB,GAAG,GAAG,KAAO,CAChC,iBAAkB,GAAG,GAAG,CAC1B,EAAE,CACJ,EACD,EAED,SAAS,4BAA6B,IAAM,CAC1C,MAAMC,EAAe,CACnB,OAAQ,CAAC,EACT,QAAS,CAAC,EACV,YAAa,cACb,MAAO,CAAC,CACV,EACMC,EAAmD,CACvD,cAAe,gBAAc,KAC7B,eAAgB,iBAChB,UAAW,KACX,MAAO,CACL,aAAc,CACZ,QAAS,IAAI,aAAW,eAAe,EACvC,QAAS,IAAI,gBAAc,UAAW,UAAW,SAAO,EACxD,YAAa,IAAI,gBAAc,UAAW,UAAQ,QAAK,EAAE,CAAC,CAC5D,CACF,EACA,OAAQ,CACN,CACE,KAAM,UACN,KAAM,UACN,MAAO,IAAI,sBAAoB,WAAW,KAAK,CAAC,GAAG,CAAC,CAAC,CACvD,CACF,EACA,QAAS,CACP,CACE,KAAM,qBACN,KAAM,SACN,MAAO,IAAI,sBAAoB,WAAW,KAAK,CAAC,EAAI,CAAC,CAAC,CACxD,CACF,EACA,oBAAkB,QAAK,CACrB,KAAM,UACN,YAAa,CACX,YAAa,UACb,aAAc,EACd,UACE,gJACJ,EACA,sBAAuB,CAAC,EACxB,OAAQ,CAAC,EACT,UAAW,CAAC,EACZ,MAAO,OACP,QAAS,CACP,iBAAkB,CAChB,YAAa,mBACb,K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B,wBAAyB,0BAAwB,KACjD,KAAM,2BAAyB,QACjC,EACA,OAAQ,qBAAmB,OAC7B,EACA,CACE,kBAAmB,CACjB,wBAAyB,0BAAwB,eACjD,KAAM,2BAAyB,QACjC,EACA,OAAQ,qBAAmB,OAC7B,EACA,CACE,kBAAmB,CACjB,wBAAyB,0BAAwB,KACjD,KAAM,2BAAyB,cACjC,EACA,OAAQ,qBAAmB,OAC7B,EACA,CACE,kBAAmB,CACjB,wBAAyB,0BAAwB,KACjD,KAAM,2BAAyB,aACjC,EACA,OAAQ,qBAAmB,OAC7B,EACA,CACE,kBAAmB,CACjB,wBAAyB,0BAAwB,cACjD,KAAM,2BAAyB,eACjC,EACA,OAAQ,qBAAmB,OAC7B,EACA,CACE,kBAAmB,CACjB,wBAAyB,0BAAwB,cACjD,KAAM,2BAAyB,eACjC,EACA,OAAQ,qBAAmB,OAC7B,EACA,CACE,MAAO,IAAI,6BACT,oCACF,EACA,OAAQ,qBAAmB,KAC7B,CACF,KAEA,0BAAuBD,EAAcC,EAAgBhB,EAAS,CAC5D,QAASc,EACT,OAAQD,CACV,CAAC,CACH,CAAC,CAAC,CACN,CAAC,CACH,CAAC",
6
- "names": ["import_device_management_kit", "import_purify_ts", "import_SignTypedDataDeviceActionTypes", "import_ethAppErrors", "import_makeInternalApi", "import_setupOpenAppDAMock", "import_testDeviceActionStates", "import_Types", "import_SignTypedDataDeviceAction", "importOriginal", "TEST_MESSAGE", "TEST_BUILT_CONTEXT", "mockParser", "mockTransactionParser", "mockTransactionMapper", "mockContextModule", "apiMock", "getAppConfigMock", "web3CheckOptInMock", "buildContextMock", "provideContextMock", "signTypedDataMock", "signTypedDataLegacyMock", "extractDependenciesMock", "createAppConfig", "version", "web3ChecksEnabled", "web3ChecksOptIn", "setupAppConfig", "resolve", "reject", "deviceAction", "expectedStates"]
4
+ "sourcesContent": ["/* eslint @typescript-eslint/consistent-type-imports: 0 */\nimport { type ContextModule } from \"@ledgerhq/context-module\";\nimport {\n CommandResultFactory,\n DeviceActionStatus,\n DeviceModelId,\n DeviceSessionStateType,\n DeviceStatus,\n UnknownDAError,\n UnknownDeviceExchangeError,\n UserInteractionRequired,\n} from \"@ledgerhq/device-management-kit\";\nimport { Just, Nothing } from \"purify-ts\";\n\nimport { type SignTypedDataDAState } from \"@api/app-binder/SignTypedDataDeviceActionTypes\";\nimport { SignTypedDataDAStateStep } from \"@api/app-binder/SignTypedDataDeviceActionTypes\";\nimport { EthAppCommandErrorFactory } from \"@internal/app-binder/command/utils/ethAppErrors\";\nimport { makeDeviceActionInternalApiMock } from \"@internal/app-binder/device-action/__test-utils__/makeInternalApi\";\nimport { setupOpenAppDAMock } from \"@internal/app-binder/device-action/__test-utils__/setupOpenAppDAMock\";\nimport { testDeviceActionStates } from \"@internal/app-binder/device-action/__test-utils__/testDeviceActionStates\";\nimport { type ProvideEIP712ContextTaskArgs } from \"@internal/app-binder/task/ProvideEIP712ContextTask\";\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} from \"@internal/typed-data/model/Types\";\nimport { type TypedDataParserService } from \"@internal/typed-data/service/TypedDataParserService\";\n\nimport { SignTypedDataDeviceAction } from \"./SignTypedDataDeviceAction\";\n\nvi.mock(\"@ledgerhq/device-management-kit\", async (importOriginal) => {\n const original =\n await importOriginal<typeof import(\"@ledgerhq/device-management-kit\")>();\n return {\n ...original,\n OpenAppDeviceAction: vi.fn(() => ({\n makeStateMachine: vi.fn(),\n })),\n };\n});\n\ndescribe(\"SignTypedDataDeviceAction\", () => {\n const TEST_MESSAGE = {\n domain: {},\n message: {},\n primaryType: \"TestMessage\",\n types: {},\n };\n const TEST_BUILT_CONTEXT: ProvideEIP712ContextTaskArgs = {\n deviceModelId: DeviceModelId.STAX,\n derivationPath: \"44'/60'/0'/0/0\",\n 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 },\n domain: [\n {\n path: \"chainId\",\n type: \"uint256\",\n value: new TypedDataValueField(Uint8Array.from([137])),\n },\n ],\n message: [\n {\n path: \"details.expiration\",\n type: \"uint48\",\n value: new TypedDataValueField(Uint8Array.from([0x13])),\n },\n ],\n clearSignContext: Just({\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 calldatasContexts: {},\n };\n const FROM = \"0x8ceb23fd6bc0add59e62ac25578270cff1b9f619\";\n\n const mockParser: TypedDataParserService = {\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 mockContextModule = {\n getFieldContext: vi.fn(),\n getContexts: vi.fn(),\n getTypedDataFilters: vi.fn(),\n };\n const apiMock = makeDeviceActionInternalApiMock();\n const getAppConfigMock = vi.fn();\n const web3CheckOptInMock = vi.fn();\n const buildContextMock = vi.fn();\n const provideContextMock = vi.fn();\n const signTypedDataMock = vi.fn();\n const signTypedDataLegacyMock = vi.fn();\n const getAddressMock = vi.fn();\n function extractDependenciesMock() {\n return {\n getAddress: getAddressMock,\n getAppConfig: getAppConfigMock,\n web3CheckOptIn: web3CheckOptInMock,\n buildContext: buildContextMock,\n provideContext: provideContextMock,\n signTypedData: signTypedDataMock,\n signTypedDataLegacy: signTypedDataLegacyMock,\n };\n }\n\n function createAppConfig(\n version: string,\n web3ChecksEnabled: boolean,\n web3ChecksOptIn: boolean,\n ) {\n return {\n blindSigningEnabled: false,\n web3ChecksEnabled,\n web3ChecksOptIn,\n version,\n };\n }\n\n function setupAppConfig(\n version: string,\n web3ChecksEnabled: boolean,\n web3ChecksOptIn: boolean,\n ) {\n apiMock.getDeviceSessionState.mockReturnValueOnce({\n sessionStateType: DeviceSessionStateType.ReadyWithoutSecureChannel,\n deviceStatus: DeviceStatus.CONNECTED,\n installedApps: [],\n currentApp: { name: \"Ethereum\", version },\n deviceModelId: DeviceModelId.FLEX,\n isSecureConnectionAllowed: false,\n });\n getAppConfigMock.mockResolvedValue(\n CommandResultFactory({\n data: createAppConfig(version, web3ChecksEnabled, web3ChecksOptIn),\n }),\n );\n }\n\n beforeEach(() => {\n vi.resetAllMocks();\n });\n\n describe(\"Success case\", () => {\n it(\"should call external dependencies with the correct parameters\", () =>\n new Promise<void>((resolve, reject) => {\n setupOpenAppDAMock();\n setupAppConfig(\"1.15.0\", false, false);\n getAddressMock.mockResolvedValueOnce(\n CommandResultFactory({\n data: { address: FROM },\n }),\n );\n\n const deviceAction = new SignTypedDataDeviceAction({\n input: {\n derivationPath: \"44'/60'/0'/0/0\",\n data: TEST_MESSAGE,\n contextModule: mockContextModule as unknown as ContextModule,\n parser: mockParser,\n transactionParser: mockTransactionParser,\n transactionMapper: mockTransactionMapper,\n skipOpenApp: false,\n },\n });\n\n // Mock the dependencies to return some sample data\n vi.spyOn(deviceAction, \"extractDependencies\").mockReturnValue(\n extractDependenciesMock(),\n );\n buildContextMock.mockResolvedValueOnce(TEST_BUILT_CONTEXT);\n provideContextMock.mockResolvedValueOnce(\n CommandResultFactory({ data: undefined }),\n );\n signTypedDataMock.mockResolvedValueOnce(\n CommandResultFactory({\n data: {\n v: 0x1c,\n r: \"0x8a540510e13b0f2b11a451275716d29e08caad07e89a1c84964782fb5e1ad788\",\n s: \"0x64a0de235b270fbe81e8e40688f4a9f9ad9d283d690552c9331d7773ceafa513\",\n },\n }),\n );\n\n // Expected intermediate values for the following state sequence:\n // Initial -> OpenApp -> BuildContext -> ProvideContext -> SignTypedData\n const expectedStates: Array<SignTypedDataDAState> = [\n {\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.None,\n step: SignTypedDataDAStateStep.OPEN_APP,\n },\n status: DeviceActionStatus.Pending,\n },\n {\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.ConfirmOpenApp,\n step: SignTypedDataDAStateStep.OPEN_APP,\n },\n status: DeviceActionStatus.Pending,\n },\n {\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.None,\n step: SignTypedDataDAStateStep.GET_APP_CONFIG,\n },\n status: DeviceActionStatus.Pending,\n },\n {\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.None,\n step: SignTypedDataDAStateStep.GET_ADDRESS,\n },\n status: DeviceActionStatus.Pending,\n },\n {\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.None,\n step: SignTypedDataDAStateStep.BUILD_CONTEXT,\n },\n status: DeviceActionStatus.Pending,\n },\n {\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.SignTypedData,\n step: SignTypedDataDAStateStep.PROVIDE_CONTEXT,\n },\n status: DeviceActionStatus.Pending,\n },\n {\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.SignTypedData,\n step: SignTypedDataDAStateStep.SIGN_TYPED_DATA,\n },\n status: DeviceActionStatus.Pending,\n },\n {\n output: {\n v: 0x1c,\n r: \"0x8a540510e13b0f2b11a451275716d29e08caad07e89a1c84964782fb5e1ad788\",\n s: \"0x64a0de235b270fbe81e8e40688f4a9f9ad9d283d690552c9331d7773ceafa513\",\n },\n status: DeviceActionStatus.Completed,\n },\n ];\n\n testDeviceActionStates(deviceAction, expectedStates, apiMock, {\n onError: reject,\n onDone: () => {\n // Verify mocks calls parameters\n expect(buildContextMock).toHaveBeenCalledWith(\n expect.objectContaining({\n input: {\n contextModule: mockContextModule,\n parser: mockParser,\n transactionParser: mockTransactionParser,\n transactionMapper: mockTransactionMapper,\n data: TEST_MESSAGE,\n appConfig: createAppConfig(\"1.15.0\", false, false),\n derivationPath: \"44'/60'/0'/0/0\",\n from: FROM,\n },\n }),\n );\n\n expect(provideContextMock).toHaveBeenCalledWith(\n expect.objectContaining({\n input: {\n contextModule: mockContextModule,\n taskArgs: TEST_BUILT_CONTEXT,\n },\n }),\n );\n\n expect(signTypedDataMock).toHaveBeenCalledWith(\n expect.objectContaining({\n input: {\n derivationPath: \"44'/60'/0'/0/0\",\n },\n }),\n );\n\n resolve();\n },\n });\n }));\n\n it(\"should be successful whlie skipping OpenApp\", () =>\n new Promise<void>((resolve, reject) => {\n setupOpenAppDAMock();\n setupAppConfig(\"1.15.0\", false, false);\n getAddressMock.mockResolvedValueOnce(\n CommandResultFactory({\n data: { address: FROM },\n }),\n );\n\n const deviceAction = new SignTypedDataDeviceAction({\n input: {\n derivationPath: \"44'/60'/0'/0/0\",\n data: TEST_MESSAGE,\n contextModule: mockContextModule as unknown as ContextModule,\n parser: mockParser,\n transactionParser: mockTransactionParser,\n transactionMapper: mockTransactionMapper,\n skipOpenApp: true,\n },\n });\n\n // Mock the dependencies to return some sample data\n vi.spyOn(deviceAction, \"extractDependencies\").mockReturnValue(\n extractDependenciesMock(),\n );\n buildContextMock.mockResolvedValueOnce(TEST_BUILT_CONTEXT);\n provideContextMock.mockResolvedValueOnce(\n CommandResultFactory({ data: undefined }),\n );\n signTypedDataMock.mockResolvedValueOnce(\n CommandResultFactory({\n data: {\n v: 0x1c,\n r: \"0x8a540510e13b0f2b11a451275716d29e08caad07e89a1c84964782fb5e1ad788\",\n s: \"0x64a0de235b270fbe81e8e40688f4a9f9ad9d283d690552c9331d7773ceafa513\",\n },\n }),\n );\n\n // Expected intermediate values for the following state sequence:\n // Initial -> BuildContext -> ProvideContext -> SignTypedData\n const expectedStates: Array<SignTypedDataDAState> = [\n {\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.None,\n step: SignTypedDataDAStateStep.GET_APP_CONFIG,\n },\n status: DeviceActionStatus.Pending,\n },\n {\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.None,\n step: SignTypedDataDAStateStep.GET_ADDRESS,\n },\n status: DeviceActionStatus.Pending,\n },\n {\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.None,\n step: SignTypedDataDAStateStep.BUILD_CONTEXT,\n },\n status: DeviceActionStatus.Pending,\n },\n {\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.SignTypedData,\n step: SignTypedDataDAStateStep.PROVIDE_CONTEXT,\n },\n status: DeviceActionStatus.Pending,\n },\n {\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.SignTypedData,\n step: SignTypedDataDAStateStep.SIGN_TYPED_DATA,\n },\n status: DeviceActionStatus.Pending,\n },\n {\n output: {\n v: 0x1c,\n r: \"0x8a540510e13b0f2b11a451275716d29e08caad07e89a1c84964782fb5e1ad788\",\n s: \"0x64a0de235b270fbe81e8e40688f4a9f9ad9d283d690552c9331d7773ceafa513\",\n },\n status: DeviceActionStatus.Completed,\n },\n ];\n\n testDeviceActionStates(deviceAction, expectedStates, apiMock, {\n onError: reject,\n onDone: resolve,\n });\n }));\n\n it(\"should fallback to legacy signing if the new one fails\", () =>\n new Promise<void>((resolve, reject) => {\n setupOpenAppDAMock();\n setupAppConfig(\"1.15.0\", false, false);\n getAddressMock.mockResolvedValueOnce(\n CommandResultFactory({\n data: { address: FROM },\n }),\n );\n\n const deviceAction = new SignTypedDataDeviceAction({\n input: {\n derivationPath: \"44'/60'/0'/0/0\",\n data: TEST_MESSAGE,\n contextModule: mockContextModule as unknown as ContextModule,\n parser: mockParser,\n transactionParser: mockTransactionParser,\n transactionMapper: mockTransactionMapper,\n skipOpenApp: false,\n },\n });\n\n // Mock the providing error\n vi.spyOn(deviceAction, \"extractDependencies\").mockReturnValue(\n extractDependenciesMock(),\n );\n buildContextMock.mockResolvedValueOnce(TEST_BUILT_CONTEXT);\n provideContextMock.mockResolvedValueOnce(\n CommandResultFactory({\n error: EthAppCommandErrorFactory({\n errorCode: \"6a80\",\n message: \"\",\n }),\n }),\n );\n signTypedDataLegacyMock.mockResolvedValueOnce(\n CommandResultFactory({\n data: {\n v: 0x1c,\n r: \"0x8a540510e13b0f2b11a451275716d29e08caad07e89a1c84964782fb5e1ad788\",\n s: \"0x64a0de235b270fbe81e8e40688f4a9f9ad9d283d690552c9331d7773ceafa513\",\n },\n }),\n );\n\n const expectedStates: Array<SignTypedDataDAState> = [\n {\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.None,\n step: SignTypedDataDAStateStep.OPEN_APP,\n },\n status: DeviceActionStatus.Pending,\n },\n {\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.ConfirmOpenApp,\n step: SignTypedDataDAStateStep.OPEN_APP,\n },\n status: DeviceActionStatus.Pending,\n },\n {\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.None,\n step: SignTypedDataDAStateStep.GET_APP_CONFIG,\n },\n status: DeviceActionStatus.Pending,\n },\n {\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.None,\n step: SignTypedDataDAStateStep.GET_ADDRESS,\n },\n status: DeviceActionStatus.Pending,\n },\n {\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.None,\n step: SignTypedDataDAStateStep.BUILD_CONTEXT,\n },\n status: DeviceActionStatus.Pending,\n },\n {\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.SignTypedData,\n step: SignTypedDataDAStateStep.PROVIDE_CONTEXT,\n },\n status: DeviceActionStatus.Pending,\n },\n {\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.SignTypedData,\n step: SignTypedDataDAStateStep.SIGN_TYPED_DATA_LEGACY,\n },\n status: DeviceActionStatus.Pending,\n },\n {\n output: {\n v: 0x1c,\n r: \"0x8a540510e13b0f2b11a451275716d29e08caad07e89a1c84964782fb5e1ad788\",\n s: \"0x64a0de235b270fbe81e8e40688f4a9f9ad9d283d690552c9331d7773ceafa513\",\n },\n status: DeviceActionStatus.Completed,\n },\n ];\n\n testDeviceActionStates(deviceAction, expectedStates, apiMock, {\n onError: reject,\n onDone: resolve,\n });\n }));\n\n it(\"should fallback to legacy signing BuildContext fails\", () =>\n new Promise<void>((resolve, reject) => {\n setupOpenAppDAMock();\n setupAppConfig(\"1.15.0\", false, false);\n getAddressMock.mockResolvedValueOnce(\n CommandResultFactory({\n data: { address: FROM },\n }),\n );\n\n const deviceAction = new SignTypedDataDeviceAction({\n input: {\n derivationPath: \"44'/60'/0'/0/0\",\n data: TEST_MESSAGE,\n contextModule: mockContextModule as unknown as ContextModule,\n parser: mockParser,\n transactionParser: mockTransactionParser,\n transactionMapper: mockTransactionMapper,\n skipOpenApp: false,\n },\n });\n\n // Mock the providing error\n vi.spyOn(deviceAction, \"extractDependencies\").mockReturnValue(\n extractDependenciesMock(),\n );\n buildContextMock.mockRejectedValueOnce(new UnknownDAError(\"Error\"));\n signTypedDataLegacyMock.mockResolvedValueOnce(\n CommandResultFactory({\n data: {\n v: 0x1c,\n r: \"0x8a540510e13b0f2b11a451275716d29e08caad07e89a1c84964782fb5e1ad788\",\n s: \"0x64a0de235b270fbe81e8e40688f4a9f9ad9d283d690552c9331d7773ceafa513\",\n },\n }),\n );\n\n const expectedStates: Array<SignTypedDataDAState> = [\n {\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.None,\n step: SignTypedDataDAStateStep.OPEN_APP,\n },\n status: DeviceActionStatus.Pending,\n },\n {\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.ConfirmOpenApp,\n step: SignTypedDataDAStateStep.OPEN_APP,\n },\n status: DeviceActionStatus.Pending,\n },\n {\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.None,\n step: SignTypedDataDAStateStep.GET_APP_CONFIG,\n },\n status: DeviceActionStatus.Pending,\n },\n {\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.None,\n step: SignTypedDataDAStateStep.GET_ADDRESS,\n },\n status: DeviceActionStatus.Pending,\n },\n {\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.None,\n step: SignTypedDataDAStateStep.BUILD_CONTEXT,\n },\n status: DeviceActionStatus.Pending,\n },\n {\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.SignTypedData,\n step: SignTypedDataDAStateStep.SIGN_TYPED_DATA_LEGACY,\n },\n status: DeviceActionStatus.Pending,\n },\n {\n output: {\n v: 0x1c,\n r: \"0x8a540510e13b0f2b11a451275716d29e08caad07e89a1c84964782fb5e1ad788\",\n s: \"0x64a0de235b270fbe81e8e40688f4a9f9ad9d283d690552c9331d7773ceafa513\",\n },\n status: DeviceActionStatus.Completed,\n },\n ];\n\n testDeviceActionStates(deviceAction, expectedStates, apiMock, {\n onError: reject,\n onDone: resolve,\n });\n }));\n\n it(\"should not fallback to legacy signing if rejected by the user during streaming\", () =>\n new Promise<void>((resolve, reject) => {\n setupOpenAppDAMock();\n setupAppConfig(\"1.15.0\", false, false);\n getAddressMock.mockResolvedValueOnce(\n CommandResultFactory({\n data: { address: FROM },\n }),\n );\n\n const deviceAction = new SignTypedDataDeviceAction({\n input: {\n derivationPath: \"44'/60'/0'/0/0\",\n data: TEST_MESSAGE,\n contextModule: mockContextModule as unknown as ContextModule,\n parser: mockParser,\n transactionParser: mockTransactionParser,\n transactionMapper: mockTransactionMapper,\n skipOpenApp: false,\n },\n });\n\n // Mock the providing error\n vi.spyOn(deviceAction, \"extractDependencies\").mockReturnValue(\n extractDependenciesMock(),\n );\n buildContextMock.mockResolvedValueOnce(TEST_BUILT_CONTEXT);\n provideContextMock.mockResolvedValueOnce(\n CommandResultFactory({\n error: EthAppCommandErrorFactory({\n errorCode: \"6985\",\n message: \"\",\n }),\n }),\n );\n signTypedDataLegacyMock.mockResolvedValueOnce(\n CommandResultFactory({\n data: {\n v: 0x1c,\n r: \"0x8a540510e13b0f2b11a451275716d29e08caad07e89a1c84964782fb5e1ad788\",\n s: \"0x64a0de235b270fbe81e8e40688f4a9f9ad9d283d690552c9331d7773ceafa513\",\n },\n }),\n );\n\n const expectedStates: Array<SignTypedDataDAState> = [\n {\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.None,\n step: SignTypedDataDAStateStep.OPEN_APP,\n },\n status: DeviceActionStatus.Pending,\n },\n {\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.ConfirmOpenApp,\n step: SignTypedDataDAStateStep.OPEN_APP,\n },\n status: DeviceActionStatus.Pending,\n },\n {\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.None,\n step: SignTypedDataDAStateStep.GET_APP_CONFIG,\n },\n status: DeviceActionStatus.Pending,\n },\n {\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.None,\n step: SignTypedDataDAStateStep.GET_ADDRESS,\n },\n status: DeviceActionStatus.Pending,\n },\n {\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.None,\n step: SignTypedDataDAStateStep.BUILD_CONTEXT,\n },\n status: DeviceActionStatus.Pending,\n },\n {\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.SignTypedData,\n step: SignTypedDataDAStateStep.PROVIDE_CONTEXT,\n },\n status: DeviceActionStatus.Pending,\n },\n {\n error: EthAppCommandErrorFactory({\n errorCode: \"6985\",\n message: \"\",\n }),\n status: DeviceActionStatus.Error,\n },\n ];\n\n testDeviceActionStates(deviceAction, expectedStates, apiMock, {\n onError: reject,\n onDone: resolve,\n });\n }));\n });\n\n describe(\"error cases\", () => {\n it(\"Error if the open app fails\", () =>\n new Promise<void>((resolve, reject) => {\n setupOpenAppDAMock(new UnknownDAError(\"Mocked error\"));\n\n const expectedStates: Array<SignTypedDataDAState> = [\n {\n status: DeviceActionStatus.Pending,\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.None,\n step: SignTypedDataDAStateStep.OPEN_APP,\n },\n },\n {\n status: DeviceActionStatus.Pending,\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.ConfirmOpenApp,\n step: SignTypedDataDAStateStep.OPEN_APP,\n },\n },\n {\n status: DeviceActionStatus.Error,\n error: new UnknownDAError(\"Mocked error\"),\n },\n ];\n\n const deviceAction = new SignTypedDataDeviceAction({\n input: {\n derivationPath: \"44'/60'/0'/0/0\",\n data: TEST_MESSAGE,\n contextModule: mockContextModule as unknown as ContextModule,\n parser: mockParser,\n transactionParser: mockTransactionParser,\n transactionMapper: mockTransactionMapper,\n skipOpenApp: false,\n },\n });\n\n testDeviceActionStates(deviceAction, expectedStates, apiMock, {\n onError: reject,\n onDone: resolve,\n });\n }));\n\n it(\"Error thrown while providing context\", () =>\n new Promise<void>((resolve, reject) => {\n setupOpenAppDAMock();\n setupAppConfig(\"1.15.0\", false, false);\n getAddressMock.mockResolvedValueOnce(\n CommandResultFactory({\n data: { address: FROM },\n }),\n );\n\n const deviceAction = new SignTypedDataDeviceAction({\n input: {\n derivationPath: \"44'/60'/0'/0/0\",\n data: TEST_MESSAGE,\n contextModule: mockContextModule as unknown as ContextModule,\n parser: mockParser,\n transactionParser: mockTransactionParser,\n transactionMapper: mockTransactionMapper,\n skipOpenApp: false,\n },\n });\n\n // Mock the providing error\n vi.spyOn(deviceAction, \"extractDependencies\").mockReturnValue(\n extractDependenciesMock(),\n );\n buildContextMock.mockResolvedValueOnce(TEST_BUILT_CONTEXT);\n provideContextMock.mockRejectedValueOnce(new UnknownDAError(\"Error\"));\n\n const expectedStates: Array<SignTypedDataDAState> = [\n {\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.None,\n step: SignTypedDataDAStateStep.OPEN_APP,\n },\n status: DeviceActionStatus.Pending,\n },\n {\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.ConfirmOpenApp,\n step: SignTypedDataDAStateStep.OPEN_APP,\n },\n status: DeviceActionStatus.Pending,\n },\n {\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.None,\n step: SignTypedDataDAStateStep.GET_APP_CONFIG,\n },\n status: DeviceActionStatus.Pending,\n },\n {\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.None,\n step: SignTypedDataDAStateStep.GET_ADDRESS,\n },\n status: DeviceActionStatus.Pending,\n },\n {\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.None,\n step: SignTypedDataDAStateStep.BUILD_CONTEXT,\n },\n status: DeviceActionStatus.Pending,\n },\n {\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.SignTypedData,\n step: SignTypedDataDAStateStep.PROVIDE_CONTEXT,\n },\n status: DeviceActionStatus.Pending,\n },\n {\n error: new UnknownDAError(\"Error\"),\n status: DeviceActionStatus.Error,\n },\n ];\n\n testDeviceActionStates(deviceAction, expectedStates, apiMock, {\n onError: reject,\n onDone: resolve,\n });\n }));\n\n it(\"Error while signing\", () =>\n new Promise<void>((resolve, reject) => {\n setupOpenAppDAMock();\n setupAppConfig(\"1.15.0\", false, false);\n getAddressMock.mockResolvedValueOnce(\n CommandResultFactory({\n data: { address: FROM },\n }),\n );\n\n const deviceAction = new SignTypedDataDeviceAction({\n input: {\n derivationPath: \"44'/60'/0'/0/0\",\n data: TEST_MESSAGE,\n contextModule: mockContextModule as unknown as ContextModule,\n parser: mockParser,\n transactionParser: mockTransactionParser,\n transactionMapper: mockTransactionMapper,\n skipOpenApp: false,\n },\n });\n\n // Mock signing error\n vi.spyOn(deviceAction, \"extractDependencies\").mockReturnValue(\n extractDependenciesMock(),\n );\n buildContextMock.mockResolvedValueOnce(TEST_BUILT_CONTEXT);\n provideContextMock.mockResolvedValueOnce(\n CommandResultFactory({ data: undefined }),\n );\n signTypedDataMock.mockResolvedValueOnce(\n CommandResultFactory({\n error: new UnknownDeviceExchangeError(\n \"Error while signing the typed data\",\n ),\n }),\n );\n\n const expectedStates: Array<SignTypedDataDAState> = [\n {\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.None,\n step: SignTypedDataDAStateStep.OPEN_APP,\n },\n status: DeviceActionStatus.Pending,\n },\n {\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.ConfirmOpenApp,\n step: SignTypedDataDAStateStep.OPEN_APP,\n },\n status: DeviceActionStatus.Pending,\n },\n {\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.None,\n step: SignTypedDataDAStateStep.GET_APP_CONFIG,\n },\n status: DeviceActionStatus.Pending,\n },\n {\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.None,\n step: SignTypedDataDAStateStep.GET_ADDRESS,\n },\n status: DeviceActionStatus.Pending,\n },\n {\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.None,\n step: SignTypedDataDAStateStep.BUILD_CONTEXT,\n },\n status: DeviceActionStatus.Pending,\n },\n {\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.SignTypedData,\n step: SignTypedDataDAStateStep.PROVIDE_CONTEXT,\n },\n status: DeviceActionStatus.Pending,\n },\n {\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.SignTypedData,\n step: SignTypedDataDAStateStep.SIGN_TYPED_DATA,\n },\n status: DeviceActionStatus.Pending,\n },\n {\n error: new UnknownDeviceExchangeError(\n \"Error while signing the typed data\",\n ),\n status: DeviceActionStatus.Error,\n },\n ];\n\n testDeviceActionStates(deviceAction, expectedStates, apiMock, {\n onError: reject,\n onDone: resolve,\n });\n }));\n });\n});\n"],
5
+ "mappings": "aAEA,IAAAA,EASO,2CACPC,EAA8B,qBAG9BC,EAAyC,0DACzCC,EAA0C,2DAC1CC,EAAgD,6EAChDC,EAAmC,gFACnCC,EAAuC,oFAIvCC,EAIO,4CAGPC,EAA0C,uCAE1C,GAAG,KAAK,kCAAmC,MAAOC,IAGzC,CACL,GAFA,MAAMA,EAAiE,EAGvE,oBAAqB,GAAG,GAAG,KAAO,CAChC,iBAAkB,GAAG,GAAG,CAC1B,EAAE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jC,EACA,OAAQ,qBAAmB,OAC7B,EACA,CACE,kBAAmB,CACjB,wBAAyB,0BAAwB,cACjD,KAAM,2BAAyB,eACjC,EACA,OAAQ,qBAAmB,OAC7B,EACA,CACE,MAAO,IAAI,6BACT,oCACF,EACA,OAAQ,qBAAmB,KAC7B,CACF,KAEA,0BAAuBD,EAAcC,EAAgBjB,EAAS,CAC5D,QAASe,EACT,OAAQD,CACV,CAAC,CACH,CAAC,CAAC,CACN,CAAC,CACH,CAAC",
6
+ "names": ["import_device_management_kit", "import_purify_ts", "import_SignTypedDataDeviceActionTypes", "import_ethAppErrors", "import_makeInternalApi", "import_setupOpenAppDAMock", "import_testDeviceActionStates", "import_Types", "import_SignTypedDataDeviceAction", "importOriginal", "TEST_MESSAGE", "TEST_BUILT_CONTEXT", "FROM", "mockParser", "mockTransactionParser", "mockTransactionMapper", "mockContextModule", "apiMock", "getAppConfigMock", "web3CheckOptInMock", "buildContextMock", "provideContextMock", "signTypedDataMock", "signTypedDataLegacyMock", "getAddressMock", "extractDependenciesMock", "createAppConfig", "version", "web3ChecksEnabled", "web3ChecksOptIn", "setupAppConfig", "resolve", "reject", "deviceAction", "expectedStates"]
7
7
  }
@@ -0,0 +1,2 @@
1
+ "use strict";var u=Object.defineProperty;var f=Object.getOwnPropertyDescriptor;var l=Object.getOwnPropertyNames;var y=Object.prototype.hasOwnProperty;var x=(s,t)=>{for(var i in t)u(s,i,{get:t[i],enumerable:!0})},C=(s,t,i,d)=>{if(t&&typeof t=="object"||typeof t=="function")for(let e of l(t))!y.call(s,e)&&e!==i&&u(s,e,{get:()=>t[e],enumerable:!(d=f(t,e))||d.enumerable});return s};var D=s=>C(u({},"__esModule",{value:!0}),s);var v={};x(v,{VerifySafeAddressDeviceAction:()=>m});module.exports=D(v);var n=require("@ledgerhq/device-management-kit"),o=require("purify-ts"),r=require("xstate"),p=require("../../../../api/app-binder/VerifySafeAddressDeviceActionTypes"),A=require("../../../app-binder/task/BuildSafeAddressContextTask"),S=require("../../../app-binder/task/ProvideContextTask");class m extends n.XStateDeviceAction{makeStateMachine(t){const{buildSafeAddressContexts:i,provideContexts:d}=this.extractDependencies(t);return(0,r.setup)({types:{input:{},context:{},output:{}},actors:{openAppStateMachine:new n.OpenAppDeviceAction({input:{appName:"Ethereum"}}).makeStateMachine(t),buildSafeAddressContexts:(0,r.fromPromise)(i),provideContexts:(0,r.fromPromise)(d)},guards:{noInternalError:({context:e})=>e._internalState.error===null,skipOpenApp:({context:e})=>!!e.input.options.skipOpenApp},actions:{assignErrorFromEvent:(0,r.assign)({_internalState:e=>({...e.context._internalState,error:e.event.error})})}}).createMachine({id:"VerifySafeAddressDeviceAction",initial:"InitialState",context:({input:e})=>({input:e,intermediateValue:{requiredUserInteraction:n.UserInteractionRequired.None,step:p.VerifySafeAddressDAStep.OPEN_APP},_internalState:{error:null,contexts:[]}}),states:{InitialState:{always:[{target:"BuildSafeAddressContexts",guard:"skipOpenApp"},"OpenAppDeviceAction"]},OpenAppDeviceAction:{invoke:{id:"openAppStateMachine",input:{appName:"Ethereum"},src:"openAppStateMachine",onSnapshot:{actions:(0,r.assign)({intermediateValue:e=>({...e.event.snapshot.context.intermediateValue,step:p.VerifySafeAddressDAStep.OPEN_APP})})},onDone:{actions:(0,r.assign)({_internalState:e=>e.event.output.caseOf({Right:()=>e.context._internalState,Left:a=>({...e.context._internalState,error:a})})}),target:"CheckOpenAppDeviceActionResult"}}},CheckOpenAppDeviceActionResult:{always:[{target:"BuildSafeAddressContexts",guard:"noInternalError"},"Error"]},BuildSafeAddressContexts:{entry:(0,r.assign)({intermediateValue:{requiredUserInteraction:n.UserInteractionRequired.None,step:p.VerifySafeAddressDAStep.BUILD_CONTEXTS}}),invoke:{id:"buildSafeAddressContexts",src:"buildSafeAddressContexts",input:({context:e})=>({contextModule:e.input.contextModule,safeContractAddress:e.input.safeContractAddress,options:e.input.options,deviceModelId:t.getDeviceModel().id}),onDone:{target:"ProvideContexts",actions:[(0,r.assign)({_internalState:({event:e,context:a})=>({...a._internalState,contexts:e.output.clearSignContexts})})]},onError:{target:"Error",actions:"assignErrorFromEvent"}}},ProvideContexts:{entry:(0,r.assign)({intermediateValue:{requiredUserInteraction:n.UserInteractionRequired.None,step:p.VerifySafeAddressDAStep.VERIFY_SAFE_ADDRESS}}),invoke:{id:"provideContexts",src:"provideContexts",input:({context:e})=>({contexts:e._internalState.contexts}),onDone:{target:"ProvideContextsResultCheck",actions:[(0,r.assign)({_internalState:({event:e,context:a})=>e.output.isLeft()?{...a._internalState,error:e.output.extract()}:{...a._internalState,error:null}})]},onError:{target:"Error",actions:"assignErrorFromEvent"}}},ProvideContextsResultCheck:{always:[{guard:"noInternalError",target:"Success"},{target:"Error"}]},Success:{type:"final"},Error:{type:"final"}},output:({context:e})=>e._internalState.error?(0,o.Left)(e._internalState.error):(0,o.Right)(void 0)})}extractDependencies(t){return{provideContexts:async e=>{for(const a of e.input.contexts){const c=await new S.ProvideContextTask(t,{context:a}).run();if(!(0,n.isSuccessCommandResult)(c))return(0,o.Left)(c.error)}return(0,o.Right)(void 0)},buildSafeAddressContexts:async e=>new A.BuildSafeAddressContextTask(t,e.input).run()}}}0&&(module.exports={VerifySafeAddressDeviceAction});
2
+ //# sourceMappingURL=VerifySafeAddress.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../../../../src/internal/app-binder/device-action/VerifySafeAddress/VerifySafeAddress.ts"],
4
+ "sourcesContent": ["import { type ClearSignContextSuccess } from \"@ledgerhq/context-module\";\nimport {\n type DeviceActionStateMachine,\n type InternalApi,\n isSuccessCommandResult,\n OpenAppDeviceAction,\n type StateMachineTypes,\n UserInteractionRequired,\n XStateDeviceAction,\n} from \"@ledgerhq/device-management-kit\";\nimport { type Either, Left, Right } from \"purify-ts\";\nimport { assign, fromPromise, setup } from \"xstate\";\n\nimport {\n type VerifySafeAddressDAError,\n type VerifySafeAddressDAInput,\n type VerifySafeAddressDAIntermediateValue,\n type VerifySafeAddressDAInternalState,\n type VerifySafeAddressDAOutput,\n VerifySafeAddressDAStep,\n} from \"@api/app-binder/VerifySafeAddressDeviceActionTypes\";\nimport {\n BuildSafeAddressContextTask,\n type BuildSafeAddressContextTaskArgs,\n type BuildSafeAddressContextTaskResult,\n} from \"@internal/app-binder/task/BuildSafeAddressContextTask\";\nimport { ProvideContextTask } from \"@internal/app-binder/task/ProvideContextTask\";\n\nexport type MachineDependencies = {\n readonly buildSafeAddressContexts: (arg0: {\n input: BuildSafeAddressContextTaskArgs;\n }) => Promise<BuildSafeAddressContextTaskResult>;\n readonly provideContexts: (arg0: {\n input: {\n contexts: ClearSignContextSuccess[];\n };\n }) => Promise<Either<VerifySafeAddressDAError, void>>;\n};\n\nexport class VerifySafeAddressDeviceAction extends XStateDeviceAction<\n VerifySafeAddressDAOutput,\n VerifySafeAddressDAInput,\n VerifySafeAddressDAError,\n VerifySafeAddressDAIntermediateValue,\n VerifySafeAddressDAInternalState\n> {\n makeStateMachine(\n internalApi: InternalApi,\n ): DeviceActionStateMachine<\n VerifySafeAddressDAOutput,\n VerifySafeAddressDAInput,\n VerifySafeAddressDAError,\n VerifySafeAddressDAIntermediateValue,\n VerifySafeAddressDAInternalState\n > {\n type types = StateMachineTypes<\n VerifySafeAddressDAOutput,\n VerifySafeAddressDAInput,\n VerifySafeAddressDAError,\n VerifySafeAddressDAIntermediateValue,\n VerifySafeAddressDAInternalState\n >;\n\n const { buildSafeAddressContexts, provideContexts } =\n this.extractDependencies(internalApi);\n\n return setup({\n types: {\n input: {} as types[\"input\"],\n context: {} as types[\"context\"],\n output: {} as types[\"output\"],\n },\n actors: {\n openAppStateMachine: new OpenAppDeviceAction({\n input: { appName: \"Ethereum\" },\n }).makeStateMachine(internalApi),\n buildSafeAddressContexts: fromPromise(buildSafeAddressContexts),\n provideContexts: fromPromise(provideContexts),\n },\n guards: {\n noInternalError: ({ context }) => context._internalState.error === null,\n skipOpenApp: ({ context }) => !!context.input.options.skipOpenApp,\n },\n actions: {\n assignErrorFromEvent: assign({\n _internalState: (_) => ({\n ..._.context._internalState,\n error: _.event[\"error\"], // NOTE: it should never happen, the error is not typed anymore here\n }),\n }),\n },\n }).createMachine({\n /** @xstate-layout N4IgpgJg5mDOIC5QGUCWUB2AVATgQw1jwGMAXVAewwBEwA3VYsAQTMowDoBJDVcvADbJSeUmADEAbQAMAXUSgADhVh92CkAA9EARgDsAZg4AOACzGAnAFYDNgGxXpF6ToA0IAJ67TOgEwcDHTsLCz9pQN9bAF8o9zRMXAIiNipaBiZWcipuXn4hETEpHXkkEGVVLIwNbQR9IzNLG3tHZzdPXV87aQ5I5ztfSON+zpi49Gx8QhJKtMYWFM4AeUUwDGZFRVmMhfEIKjAOVAw6CgBrA4oVtY3hUTAAWRIACyOwGRKlFTUqasQ9RxMVjMdgcdj0xnBvncXlqkTsHAsQxcnVMvmM4TsoxA8QmSWm7C280qHAAwk8wMRTstVutNvQ5pl2AAlOAAVwEpCkcg05W+VVKNR0gW6IOsoWMfgMdmhHRBHActisFnMMqCmNi2PGiSmC0JjOyZIpVKutINCxZsHZnMkxR5X0qv1qwsVwRVOglcJlcoQEo4ns9pmkQL00mCFgMWJxuuSM3p22JAHEwKRaSSqAAzdC7faHY5nA4wNMbDMYbNQd4OirqAW6CVWDhWPR2fR2Yy+Fu+UwGX1C4zGHoGcPSDuGCx6HTRnWTOMEhNE9gcFMlxRliviMA4HAUHAcRQCUSZ3cAWw4xfTWfQVdKvKdddqDabLbbY/6Pb7IQ4I+sPdR1n+KMtRjWd8VSBdDU4FdL3LdArRtY1KS5D4ykdWtQBqAYO2-MFwyBHRTEjNoYT8Lpv3CKwrG7Zt0VMPRpwSUD9QghZl1TGCK3gjlENOIoULvdCtEQLD-HDMMHAlQjAj7VEdADENg1MYNhQMUwGNxPV43SRdsmg0srygLjSB4qRfH4tCfgfEScPE-CpOIxBVO6HQiLbVUQR8dTYzAmgWOJAB1MAACMDB42BllIHhcwwA4jhOc4OAAd2C0LyUpCKeBvT4a0sjDhKGfx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HkXPYK8-pGSTTIWyaYxGk5IjPmsHXfQeEoT-1UqLfowpKIdlWUBDWRjGEpOaQiiZLyelvNOKipCdp+E5JqNiowzY8U+FskSkiw5TAmGlCEQioR_j6BiFqDAFBT7wFKIixpkEMUBMQAAWnIdqxsIQQiE3BGClx0QjmGzVaxHgahBC3DEBq-ZiBUQyXCE2YWSjJxgOFtC81NsNHZGpNcOkcKEbw0-Y5OuJg1ZDCUSqQFuNgHfmDN2AOYCnBTl9aw_1nAeKBvNH5ZkbIOQOvDQgA1AQxy2BbKdWwuNmwmDqo4cwjRykwuzWxVc650AludDXMBPRmoGAlP8cwTg5aRs6GGGu-g0RgJUTS45lrkzsX0rBQyRbjLTR7VZex-g0QuU6HXIdE5Sm1GDKLHQSsgkShDMLNtBbsiQ2mo9Wa27lrANdWYP2_QPKdikf_ORAQpZKLBUKds96Q2cCfQ9PqRk31Cxlvjaw7YKIQk9iRYB_hKUFJogU4BEGmGcD1jzC1gsw2Ox7EYYWql5aqS6MUuWdgjAhjrpQ7GSiCP0s7tnbByd4M1GDK6hwlEpRbyBcS_0_LURlTqiEMwnGmlHwwXfLBGBe7KufpigTVFGzlKVJ6cMX65YQnkljaVUo_DdgUzdVVZGHaCNHP4Fy2KP32OCDJBx1gzCIkIuiexzdM3qIfak55loN08X44gX-nYAzlOA_oKio4ZKExMFLFUQJ4mnWs6xM5YzbPIspJFhAXR0QBkOkKLGdUOybIA4YAIwDDCehVCCfDgWoHBYZecplXSWUovC1u-2AjlpgiYyIicl6St4SXvI7oX7RzWCDFhbLxJkCsmIEwWAGm8Fab-EdiqtFfT_HxgOd0TsQMdjlVEIAA */\n id: \"VerifySafeAddressDeviceAction\",\n initial: \"InitialState\",\n context: ({ input }) => {\n return {\n input,\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.None,\n step: VerifySafeAddressDAStep.OPEN_APP,\n },\n _internalState: {\n error: null,\n contexts: [],\n },\n };\n },\n states: {\n InitialState: {\n always: [\n {\n target: \"BuildSafeAddressContexts\",\n guard: \"skipOpenApp\",\n },\n \"OpenAppDeviceAction\",\n ],\n },\n OpenAppDeviceAction: {\n invoke: {\n id: \"openAppStateMachine\",\n input: {\n appName: \"Ethereum\",\n },\n src: \"openAppStateMachine\",\n onSnapshot: {\n actions: assign({\n intermediateValue: (_) => ({\n ..._.event.snapshot.context.intermediateValue,\n step: VerifySafeAddressDAStep.OPEN_APP,\n }),\n }),\n },\n onDone: {\n actions: assign({\n _internalState: (_) => {\n return _.event.output.caseOf<VerifySafeAddressDAInternalState>(\n {\n Right: () => _.context._internalState,\n Left: (error) => ({\n ..._.context._internalState,\n error,\n }),\n },\n );\n },\n }),\n target: \"CheckOpenAppDeviceActionResult\",\n },\n },\n },\n CheckOpenAppDeviceActionResult: {\n always: [\n {\n target: \"BuildSafeAddressContexts\",\n guard: \"noInternalError\",\n },\n \"Error\",\n ],\n },\n BuildSafeAddressContexts: {\n entry: assign({\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.None,\n step: VerifySafeAddressDAStep.BUILD_CONTEXTS,\n },\n }),\n invoke: {\n id: \"buildSafeAddressContexts\",\n src: \"buildSafeAddressContexts\",\n input: ({ context }) => ({\n contextModule: context.input.contextModule,\n safeContractAddress: context.input.safeContractAddress,\n options: context.input.options,\n deviceModelId: internalApi.getDeviceModel().id,\n }),\n onDone: {\n target: \"ProvideContexts\",\n actions: [\n assign({\n _internalState: ({ event, context }) => ({\n ...context._internalState,\n contexts: event.output.clearSignContexts,\n }),\n }),\n ],\n },\n onError: {\n target: \"Error\",\n actions: \"assignErrorFromEvent\",\n },\n },\n },\n ProvideContexts: {\n entry: assign({\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.None,\n step: VerifySafeAddressDAStep.VERIFY_SAFE_ADDRESS,\n },\n }),\n invoke: {\n id: \"provideContexts\",\n src: \"provideContexts\",\n input: ({ context }) => ({\n contexts: context._internalState\n .contexts as ClearSignContextSuccess[],\n }),\n onDone: {\n target: \"ProvideContextsResultCheck\",\n actions: [\n assign({\n _internalState: ({ event, context }) => {\n if (event.output.isLeft()) {\n return {\n ...context._internalState,\n error: event.output.extract(),\n };\n }\n\n return {\n ...context._internalState,\n error: null,\n };\n },\n }),\n ],\n },\n onError: {\n target: \"Error\",\n actions: \"assignErrorFromEvent\",\n },\n },\n },\n ProvideContextsResultCheck: {\n always: [\n { guard: \"noInternalError\", target: \"Success\" },\n { target: \"Error\" },\n ],\n },\n Success: {\n type: \"final\",\n },\n Error: {\n type: \"final\",\n },\n },\n output: ({ context }) =>\n context._internalState.error\n ? Left(context._internalState.error)\n : Right(void 0),\n });\n }\n\n extractDependencies(internalApi: InternalApi): MachineDependencies {\n const buildSafeAddressContexts = async (arg0: {\n input: BuildSafeAddressContextTaskArgs;\n }) => new BuildSafeAddressContextTask(internalApi, arg0.input).run();\n\n const provideContexts = async (arg0: {\n input: {\n contexts: ClearSignContextSuccess[];\n };\n }) => {\n for (const context of arg0.input.contexts) {\n const res = await new ProvideContextTask(internalApi, {\n context,\n }).run();\n\n if (!isSuccessCommandResult(res)) {\n return Left(res.error);\n }\n }\n return Right(void 0);\n };\n\n return {\n provideContexts,\n buildSafeAddressContexts,\n };\n }\n}\n"],
5
+ "mappings": "yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,mCAAAE,IAAA,eAAAC,EAAAH,GACA,IAAAI,EAQO,2CACPC,EAAyC,qBACzCC,EAA2C,kBAE3CC,EAOO,8DACPC,EAIO,iEACPC,EAAmC,wDAa5B,MAAMP,UAAsC,oBAMjD,CACA,iBACEQ,EAOA,CASA,KAAM,CAAE,yBAAAC,EAA0B,gBAAAC,CAAgB,EAChD,KAAK,oBAAoBF,CAAW,EAEtC,SAAO,SAAM,CACX,MAAO,CACL,MAAO,CAAC,EACR,QAAS,CAAC,EACV,OAAQ,CAAC,CACX,EACA,OAAQ,CACN,oBAAqB,IAAI,sBAAoB,CAC3C,MAAO,CAAE,QAAS,UAAW,CAC/B,CAAC,EAAE,iBAAiBA,CAAW,E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KACjC,SAAM,MAAM,CACpB,CAAC,CACH,CAEA,oBAAoBH,EAA+C,CAsBjE,MAAO,CACL,gBAlBsB,MAAOQ,GAIzB,CACJ,UAAWL,KAAWK,EAAK,MAAM,SAAU,CACzC,MAAMC,EAAM,MAAM,IAAI,qBAAmBT,EAAa,CACpD,QAAAG,CACF,CAAC,EAAE,IAAI,EAEP,GAAI,IAAC,0BAAuBM,CAAG,EAC7B,SAAO,QAAKA,EAAI,KAAK,CAEzB,CACA,SAAO,SAAM,MAAM,CACrB,EAIE,yBAvB+B,MAAOD,GAElC,IAAI,8BAA4BR,EAAaQ,EAAK,KAAK,EAAE,IAAI,CAsBnE,CACF,CACF",
6
+ "names": ["VerifySafeAddress_exports", "__export", "VerifySafeAddressDeviceAction", "__toCommonJS", "import_device_management_kit", "import_purify_ts", "import_xstate", "import_VerifySafeAddressDeviceActionTypes", "import_BuildSafeAddressContextTask", "import_ProvideContextTask", "internalApi", "buildSafeAddressContexts", "provideContexts", "context", "_", "input", "error", "event", "arg0", "res"]
7
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";var S=require("@ledgerhq/context-module"),t=require("@ledgerhq/device-management-kit"),A=require("purify-ts"),v=require("rxjs"),E=require("../../../../api/app-binder/VerifySafeAddressDeviceActionTypes"),w=require("../../../app-binder/device-action/__test-utils__/makeInternalApi"),d=require("../../../app-binder/device-action/__test-utils__/setupOpenAppDAMock"),C=require("../../../app-binder/device-action/__test-utils__/testDeviceActionUntilStep"),l=require("./VerifySafeAddress");vi.mock("@ledgerhq/device-management-kit",async o=>({...await o(),OpenAppDeviceAction:vi.fn(()=>({makeStateMachine:vi.fn()}))}));describe("VerifySafeAddressDeviceAction",()=>{let o;const s={getContexts:vi.fn()},r=vi.fn(),x=vi.fn();function u(){return{buildSafeAddressContexts:r,provideContexts:x}}const a=(0,w.makeDeviceActionInternalApiMock)(),c="0x1234567890123456789012345678901234567890",i=1,m={type:S.ClearSignContextType.SAFE,payload:"safe_payload"},y={type:S.ClearSignContextType.SIGNER,payload:"signer_payload"};function p(e){a.getDeviceModel.mockReturnValue({id:e}),a.getDeviceSessionState.mockReturnValue({sessionStateType:t.DeviceSessionStateType.ReadyWithoutSecureChannel,deviceStatus:t.DeviceStatus.CONNECTED,installedApps:[],currentApp:{name:"Ethereum",version:"1.15.0"},deviceModelId:e,isSecureConnectionAllowed:!1})}const k=(e,n)=>{if(e[n]?.status!==t.DeviceActionStatus.Pending)throw new Error(`Step ${n} is not pending: ${JSON.stringify(e[n])}`);return e[n]};describe("Happy path",()=>{describe("should verify safe address",()=>{beforeEach(()=>{vi.resetAllMocks(),(0,d.setupOpenAppDAMock)(),p(t.DeviceModelId.FLEX),r.mockResolvedValueOnce({clearSignContexts:[m,y]}),x.mockResolvedValueOnce((0,A.Right)(void 0));const e=new l.VerifySafeAddressDeviceAction({input:{safeContractAddress:c,options:{chainId:i},contextModule:s}});vi.spyOn(e,"extractDependencies").mockReturnValue(u()),o=e._execute(a).observable}),it("should open the app",async()=>{const{steps:e}=await(0,C.executeUntilStep)(0,o);expect(k(e,0).intermediateValue.step).toBe(E.VerifySafeAddressDAStep.OPEN_APP)}),it("should confirm open app",async()=>{const{steps:e}=await(0,C.executeUntilStep)(1,o);expect(k(e,1).intermediateValue.requiredUserInteraction).toBe(t.UserInteractionRequired.ConfirmOpenApp)}),it("should build safe address contexts",async()=>{const{steps:e}=await(0,C.executeUntilStep)(2,o);expect(k(e,2).intermediateValue.step).toBe(E.VerifySafeAddressDAStep.BUILD_CONTEXTS),expect(r).toHaveBeenCalledWith(expect.objectContaining({input:{contextModule:s,safeContractAddress:c,options:{chainId:i},deviceModelId:t.DeviceModelId.FLEX}}))}),it("should provide contexts (verify safe address)",async()=>{const{steps:e}=await(0,C.executeUntilStep)(3,o);expect(k(e,3).intermediateValue.step).toBe(E.VerifySafeAddressDAStep.VERIFY_SAFE_ADDRESS),expect(x).toHaveBeenCalledWith(expect.objectContaining({input:{contexts:[m,y]}}))}),it("should complete successfully",async()=>{const e=await(0,v.lastValueFrom)(o);expect(e).toEqual({status:t.DeviceActionStatus.Completed,output:void 0})})}),describe("should skip open app",()=>{beforeEach(()=>{vi.resetAllMocks(),(0,d.setupOpenAppDAMock)(),p(t.DeviceModelId.FLEX);const e=new l.VerifySafeAddressDeviceAction({input:{safeContractAddress:c,options:{chainId:i,skipOpenApp:!0},contextModule:s}});r.mockResolvedValueOnce({clearSignContexts:[m,y]}),x.mockResolvedValueOnce((0,A.Right)(void 0)),vi.spyOn(e,"extractDependencies").mockReturnValue(u()),o=e._execute(a).observable}),it("should skip open app and build contexts directly",async()=>{const{steps:e}=await(0,C.executeUntilStep)(0,o);expect(k(e,0).intermediateValue.step).toBe(E.VerifySafeAddressDAStep.BUILD_CONTEXTS)})}),describe("should work with different device models",()=>{it.each([[t.DeviceModelId.NANO_S,"Nano S"],[t.DeviceModelId.NANO_SP,"Nano S Plus"],[t.DeviceModelId.NANO_X,"Nano X"],[t.DeviceModelId.FLEX,"Flex"],[t.DeviceModelId.STAX,"Stax"]])("should verify safe address on %s device",async(e,n)=>{vi.resetAllMocks(),(0,d.setupOpenAppDAMock)(),p(e),r.mockResolvedValueOnce({clearSignContexts:[m,y]}),x.mockResolvedValueOnce((0,A.Right)(void 0));const f=new l.VerifySafeAddressDeviceAction({input:{safeContractAddress:c,options:{chainId:i,skipOpenApp:!0},contextModule:s}});vi.spyOn(f,"extractDependencies").mockReturnValue(u()),o=f._execute(a).observable;const h=await(0,v.lastValueFrom)(o);expect(h).toEqual({status:t.DeviceActionStatus.Completed,output:void 0}),expect(r).toHaveBeenCalledWith(expect.objectContaining({input:expect.objectContaining({deviceModelId:e})}))})}),describe("should work with contexts with certificates",()=>{beforeEach(()=>{vi.resetAllMocks(),(0,d.setupOpenAppDAMock)(),p(t.DeviceModelId.FLEX);const e={type:S.ClearSignContextType.SAFE,payload:"safe_payload",certificate:{keyUsageNumber:1,payload:new Uint8Array([1,2,3])}},n={type:S.ClearSignContextType.SIGNER,payload:"signer_payload",certificate:{keyUsageNumber:2,payload:new Uint8Array([4,5,6])}};r.mockResolvedValueOnce({clearSignContexts:[e,n]}),x.mockResolvedValueOnce((0,A.Right)(void 0));const f=new l.VerifySafeAddressDeviceAction({input:{safeContractAddress:c,options:{chainId:i,skipOpenApp:!0},contextModule:s}});vi.spyOn(f,"extractDependencies").mockReturnValue(u()),o=f._execute(a).observable}),it("should handle contexts with certificates",async()=>{const e=await(0,v.lastValueFrom)(o);expect(e).toEqual({status:t.DeviceActionStatus.Completed,output:void 0})})})}),describe("Error cases",()=>{beforeEach(()=>{vi.resetAllMocks()}),it("should return an error if the open app throws an error",async()=>{(0,d.setupOpenAppDAMock)(new Error("Open app failed")),p(t.DeviceModelId.FLEX);const e=new l.VerifySafeAddressDeviceAction({input:{safeContractAddress:c,options:{chainId:i},contextModule:s}});vi.spyOn(e,"extractDependencies").mockReturnValue(u()),o=e._execute(a).observable;const n=await(0,v.lastValueFrom)(o);expect(n).toEqual({status:t.DeviceActionStatus.Error,error:new Error("Open app failed")})}),it("should return an error if buildSafeAddressContexts throws an error",async()=>{(0,d.setupOpenAppDAMock)(),p(t.DeviceModelId.FLEX),r.mockRejectedValueOnce(new Error("Failed to build contexts"));const e=new l.VerifySafeAddressDeviceAction({input:{safeContractAddress:c,options:{chainId:i},contextModule:s}});vi.spyOn(e,"extractDependencies").mockReturnValue(u()),o=e._execute(a).observable;const n=await(0,v.lastValueFrom)(o);expect(n).toEqual({status:t.DeviceActionStatus.Error,error:new Error("Failed to build contexts")})}),it("should return an error if provideContexts returns Left (error)",async()=>{(0,d.setupOpenAppDAMock)(),p(t.DeviceModelId.FLEX),r.mockResolvedValueOnce({clearSignContexts:[m,y]});const e=new t.InvalidStatusWordError("Failed to provide context");x.mockResolvedValueOnce((0,A.Left)(e));const n=new l.VerifySafeAddressDeviceAction({input:{safeContractAddress:c,options:{chainId:i},contextModule:s}});vi.spyOn(n,"extractDependencies").mockReturnValue(u()),o=n._execute(a).observable;const f=await(0,v.lastValueFrom)(o);expect(f).toEqual({status:t.DeviceActionStatus.Error,error:e})}),it("should return an error if provideContexts throws an error",async()=>{(0,d.setupOpenAppDAMock)(),p(t.DeviceModelId.FLEX),r.mockResolvedValueOnce({clearSignContexts:[m,y]}),x.mockRejectedValueOnce(new Error("Provide contexts failed"));const e=new l.VerifySafeAddressDeviceAction({input:{safeContractAddress:c,options:{chainId:i},contextModule:s}});vi.spyOn(e,"extractDependencies").mockReturnValue(u()),o=e._execute(a).observable;const n=await(0,v.lastValueFrom)(o);expect(n).toEqual({status:t.DeviceActionStatus.Error,error:new Error("Provide contexts failed")})}),it("should return an error when buildSafeAddressContexts returns invalid data",async()=>{(0,d.setupOpenAppDAMock)(),p(t.DeviceModelId.FLEX),r.mockRejectedValueOnce(new Error("Invalid safe address contexts"));const e=new l.VerifySafeAddressDeviceAction({input:{safeContractAddress:c,options:{chainId:i},contextModule:s}});vi.spyOn(e,"extractDependencies").mockReturnValue(u()),o=e._execute(a).observable;const n=await(0,v.lastValueFrom)(o);expect(n).toEqual({status:t.DeviceActionStatus.Error,error:new Error("Invalid safe address contexts")})}),it("should handle user rejection during provide contexts",async()=>{(0,d.setupOpenAppDAMock)(),p(t.DeviceModelId.FLEX),r.mockResolvedValueOnce({clearSignContexts:[m,y]});const e=new t.InvalidStatusWordError("User rejected");e.errorCode="6985",x.mockResolvedValueOnce((0,A.Left)(e));const n=new l.VerifySafeAddressDeviceAction({input:{safeContractAddress:c,options:{chainId:i},contextModule:s}});vi.spyOn(n,"extractDependencies").mockReturnValue(u()),o=n._execute(a).observable;const f=await(0,v.lastValueFrom)(o);expect(f).toEqual({status:t.DeviceActionStatus.Error,error:e})})})});
2
+ //# sourceMappingURL=VerifySafeAddress.test.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../../../../src/internal/app-binder/device-action/VerifySafeAddress/VerifySafeAddress.test.ts"],
4
+ "sourcesContent": ["/* eslint @typescript-eslint/consistent-type-imports: 0 */\nimport {\n ClearSignContextType,\n type ContextModule,\n} from \"@ledgerhq/context-module\";\nimport {\n DeviceActionState,\n DeviceActionStatus,\n DeviceModelId,\n DeviceSessionStateType,\n DeviceStatus,\n InvalidStatusWordError,\n TransportDeviceModel,\n UserInteractionRequired,\n} from \"@ledgerhq/device-management-kit\";\nimport { Left, Right } from \"purify-ts\";\nimport { lastValueFrom, Observable } from \"rxjs\";\n\nimport {\n VerifySafeAddressDAError,\n VerifySafeAddressDAIntermediateValue,\n type VerifySafeAddressDAState,\n VerifySafeAddressDAStep,\n} from \"@api/app-binder/VerifySafeAddressDeviceActionTypes\";\nimport { makeDeviceActionInternalApiMock } from \"@internal/app-binder/device-action/__test-utils__/makeInternalApi\";\nimport { setupOpenAppDAMock } from \"@internal/app-binder/device-action/__test-utils__/setupOpenAppDAMock\";\nimport { executeUntilStep } from \"@internal/app-binder/device-action/__test-utils__/testDeviceActionUntilStep\";\n\nimport { VerifySafeAddressDeviceAction } from \"./VerifySafeAddress\";\n\nvi.mock(\"@ledgerhq/device-management-kit\", async (importOriginal) => {\n const original =\n await importOriginal<typeof import(\"@ledgerhq/device-management-kit\")>();\n return {\n ...original,\n OpenAppDeviceAction: vi.fn(() => ({\n makeStateMachine: vi.fn(),\n })),\n };\n});\n\ndescribe(\"VerifySafeAddressDeviceAction\", () => {\n let observable: Observable<\n DeviceActionState<\n void,\n VerifySafeAddressDAError,\n VerifySafeAddressDAIntermediateValue\n >\n >;\n const contextModuleMock = {\n getContexts: vi.fn(),\n };\n const buildSafeAddressContextsMock = vi.fn();\n const provideContextsMock = vi.fn();\n\n function extractDependenciesMock() {\n return {\n buildSafeAddressContexts: buildSafeAddressContextsMock,\n provideContexts: provideContextsMock,\n };\n }\n\n const apiMock = makeDeviceActionInternalApiMock();\n const TEST_SAFE_ADDRESS = \"0x1234567890123456789012345678901234567890\";\n const TEST_CHAIN_ID = 1;\n\n const validSafeContext = {\n type: ClearSignContextType.SAFE,\n payload: \"safe_payload\",\n };\n\n const validSignerContext = {\n type: ClearSignContextType.SIGNER,\n payload: \"signer_payload\",\n };\n\n function setupDeviceModel(deviceModelId: DeviceModelId) {\n apiMock.getDeviceModel.mockReturnValue({\n id: deviceModelId,\n } as unknown as TransportDeviceModel);\n apiMock.getDeviceSessionState.mockReturnValue({\n sessionStateType: DeviceSessionStateType.ReadyWithoutSecureChannel,\n deviceStatus: DeviceStatus.CONNECTED,\n installedApps: [],\n currentApp: { name: \"Ethereum\", version: \"1.15.0\" },\n deviceModelId,\n isSecureConnectionAllowed: false,\n });\n }\n\n const getStep = (s: Array<VerifySafeAddressDAState>, index: number) => {\n if (s[index]?.status !== DeviceActionStatus.Pending) {\n throw new Error(\n `Step ${index} is not pending: ${JSON.stringify(s[index])}`,\n );\n }\n return s[index];\n };\n\n describe(\"Happy path\", () => {\n describe(\"should verify safe address\", () => {\n beforeEach(() => {\n vi.resetAllMocks();\n setupOpenAppDAMock();\n setupDeviceModel(DeviceModelId.FLEX);\n\n // Mock the dependencies to return some sample data\n buildSafeAddressContextsMock.mockResolvedValueOnce({\n clearSignContexts: [validSafeContext, validSignerContext],\n });\n provideContextsMock.mockResolvedValueOnce(Right(void 0));\n\n const deviceAction = new VerifySafeAddressDeviceAction({\n input: {\n safeContractAddress: TEST_SAFE_ADDRESS,\n options: { chainId: TEST_CHAIN_ID },\n contextModule: contextModuleMock as unknown as ContextModule,\n },\n });\n vi.spyOn(deviceAction, \"extractDependencies\").mockReturnValue(\n extractDependenciesMock(),\n );\n\n observable = deviceAction._execute(apiMock).observable;\n });\n\n it(\"should open the app\", async () => {\n const { steps } = await executeUntilStep(0, observable);\n expect(getStep(steps, 0).intermediateValue.step).toBe(\n VerifySafeAddressDAStep.OPEN_APP,\n );\n });\n\n it(\"should confirm open app\", async () => {\n const { steps } = await executeUntilStep(1, observable);\n expect(\n getStep(steps, 1).intermediateValue.requiredUserInteraction,\n ).toBe(UserInteractionRequired.ConfirmOpenApp);\n });\n\n it(\"should build safe address contexts\", async () => {\n const { steps } = await executeUntilStep(2, observable);\n expect(getStep(steps, 2).intermediateValue.step).toBe(\n VerifySafeAddressDAStep.BUILD_CONTEXTS,\n );\n expect(buildSafeAddressContextsMock).toHaveBeenCalledWith(\n expect.objectContaining({\n input: {\n contextModule: contextModuleMock as unknown as ContextModule,\n safeContractAddress: TEST_SAFE_ADDRESS,\n options: { chainId: TEST_CHAIN_ID },\n deviceModelId: DeviceModelId.FLEX,\n },\n }),\n );\n });\n\n it(\"should provide contexts (verify safe address)\", async () => {\n const { steps } = await executeUntilStep(3, observable);\n expect(getStep(steps, 3).intermediateValue.step).toBe(\n VerifySafeAddressDAStep.VERIFY_SAFE_ADDRESS,\n );\n expect(provideContextsMock).toHaveBeenCalledWith(\n expect.objectContaining({\n input: {\n contexts: [validSafeContext, validSignerContext],\n },\n }),\n );\n });\n\n it(\"should complete successfully\", async () => {\n const result = await lastValueFrom(observable);\n expect(result).toEqual({\n status: DeviceActionStatus.Completed,\n output: void 0,\n });\n });\n });\n\n describe(\"should skip open app\", () => {\n beforeEach(() => {\n vi.resetAllMocks();\n setupOpenAppDAMock();\n setupDeviceModel(DeviceModelId.FLEX);\n\n const deviceAction = new VerifySafeAddressDeviceAction({\n input: {\n safeContractAddress: TEST_SAFE_ADDRESS,\n options: { chainId: TEST_CHAIN_ID, skipOpenApp: true },\n contextModule: contextModuleMock as unknown as ContextModule,\n },\n });\n buildSafeAddressContextsMock.mockResolvedValueOnce({\n clearSignContexts: [validSafeContext, validSignerContext],\n });\n provideContextsMock.mockResolvedValueOnce(Right(void 0));\n\n vi.spyOn(deviceAction, \"extractDependencies\").mockReturnValue(\n extractDependenciesMock(),\n );\n\n observable = deviceAction._execute(apiMock).observable;\n });\n\n it(\"should skip open app and build contexts directly\", async () => {\n const { steps } = await executeUntilStep(0, observable);\n\n expect(getStep(steps, 0).intermediateValue.step).toBe(\n VerifySafeAddressDAStep.BUILD_CONTEXTS,\n );\n });\n });\n\n describe(\"should work with different device models\", () => {\n it.each([\n [DeviceModelId.NANO_S, \"Nano S\"],\n [DeviceModelId.NANO_SP, \"Nano S Plus\"],\n [DeviceModelId.NANO_X, \"Nano X\"],\n [DeviceModelId.FLEX, \"Flex\"],\n [DeviceModelId.STAX, \"Stax\"],\n ])(\n \"should verify safe address on %s device\",\n async (deviceModelId, _deviceName) => {\n // GIVEN\n vi.resetAllMocks();\n setupOpenAppDAMock();\n setupDeviceModel(deviceModelId);\n\n buildSafeAddressContextsMock.mockResolvedValueOnce({\n clearSignContexts: [validSafeContext, validSignerContext],\n });\n provideContextsMock.mockResolvedValueOnce(Right(void 0));\n\n const deviceAction = new VerifySafeAddressDeviceAction({\n input: {\n safeContractAddress: TEST_SAFE_ADDRESS,\n options: { chainId: TEST_CHAIN_ID, skipOpenApp: true },\n contextModule: contextModuleMock as unknown as ContextModule,\n },\n });\n vi.spyOn(deviceAction, \"extractDependencies\").mockReturnValue(\n extractDependenciesMock(),\n );\n\n observable = deviceAction._execute(apiMock).observable;\n\n // WHEN\n const result = await lastValueFrom(observable);\n\n // THEN\n expect(result).toEqual({\n status: DeviceActionStatus.Completed,\n output: void 0,\n });\n expect(buildSafeAddressContextsMock).toHaveBeenCalledWith(\n expect.objectContaining({\n input: expect.objectContaining({\n deviceModelId,\n }),\n }),\n );\n },\n );\n });\n\n describe(\"should work with contexts with certificates\", () => {\n beforeEach(() => {\n vi.resetAllMocks();\n setupOpenAppDAMock();\n setupDeviceModel(DeviceModelId.FLEX);\n\n const safeContextWithCert = {\n type: ClearSignContextType.SAFE,\n payload: \"safe_payload\",\n certificate: {\n keyUsageNumber: 1,\n payload: new Uint8Array([1, 2, 3]),\n },\n };\n\n const signerContextWithCert = {\n type: ClearSignContextType.SIGNER,\n payload: \"signer_payload\",\n certificate: {\n keyUsageNumber: 2,\n payload: new Uint8Array([4, 5, 6]),\n },\n };\n\n buildSafeAddressContextsMock.mockResolvedValueOnce({\n clearSignContexts: [safeContextWithCert, signerContextWithCert],\n });\n provideContextsMock.mockResolvedValueOnce(Right(void 0));\n\n const deviceAction = new VerifySafeAddressDeviceAction({\n input: {\n safeContractAddress: TEST_SAFE_ADDRESS,\n options: { chainId: TEST_CHAIN_ID, skipOpenApp: true },\n contextModule: contextModuleMock as unknown as ContextModule,\n },\n });\n vi.spyOn(deviceAction, \"extractDependencies\").mockReturnValue(\n extractDependenciesMock(),\n );\n\n observable = deviceAction._execute(apiMock).observable;\n });\n\n it(\"should handle contexts with certificates\", async () => {\n const result = await lastValueFrom(observable);\n expect(result).toEqual({\n status: DeviceActionStatus.Completed,\n output: void 0,\n });\n });\n });\n });\n\n describe(\"Error cases\", () => {\n beforeEach(() => {\n vi.resetAllMocks();\n });\n\n it(\"should return an error if the open app throws an error\", async () => {\n // GIVEN\n setupOpenAppDAMock(new Error(\"Open app failed\"));\n setupDeviceModel(DeviceModelId.FLEX);\n const deviceAction = new VerifySafeAddressDeviceAction({\n input: {\n safeContractAddress: TEST_SAFE_ADDRESS,\n options: { chainId: TEST_CHAIN_ID },\n contextModule: contextModuleMock as unknown as ContextModule,\n },\n });\n vi.spyOn(deviceAction, \"extractDependencies\").mockReturnValue(\n extractDependenciesMock(),\n );\n observable = deviceAction._execute(apiMock).observable;\n\n // WHEN\n const result = await lastValueFrom(observable);\n\n // THEN\n expect(result).toEqual({\n status: DeviceActionStatus.Error,\n error: new Error(\"Open app failed\"),\n });\n });\n\n it(\"should return an error if buildSafeAddressContexts throws an error\", async () => {\n // GIVEN\n setupOpenAppDAMock();\n setupDeviceModel(DeviceModelId.FLEX);\n buildSafeAddressContextsMock.mockRejectedValueOnce(\n new Error(\"Failed to build contexts\"),\n );\n const deviceAction = new VerifySafeAddressDeviceAction({\n input: {\n safeContractAddress: TEST_SAFE_ADDRESS,\n options: { chainId: TEST_CHAIN_ID },\n contextModule: contextModuleMock as unknown as ContextModule,\n },\n });\n vi.spyOn(deviceAction, \"extractDependencies\").mockReturnValue(\n extractDependenciesMock(),\n );\n observable = deviceAction._execute(apiMock).observable;\n\n // WHEN\n const result = await lastValueFrom(observable);\n\n // THEN\n expect(result).toEqual({\n status: DeviceActionStatus.Error,\n error: new Error(\"Failed to build contexts\"),\n });\n });\n\n it(\"should return an error if provideContexts returns Left (error)\", async () => {\n // GIVEN\n setupOpenAppDAMock();\n setupDeviceModel(DeviceModelId.FLEX);\n buildSafeAddressContextsMock.mockResolvedValueOnce({\n clearSignContexts: [validSafeContext, validSignerContext],\n });\n const provideError = new InvalidStatusWordError(\n \"Failed to provide context\",\n );\n provideContextsMock.mockResolvedValueOnce(Left(provideError));\n const deviceAction = new VerifySafeAddressDeviceAction({\n input: {\n safeContractAddress: TEST_SAFE_ADDRESS,\n options: { chainId: TEST_CHAIN_ID },\n contextModule: contextModuleMock as unknown as ContextModule,\n },\n });\n vi.spyOn(deviceAction, \"extractDependencies\").mockReturnValue(\n extractDependenciesMock(),\n );\n observable = deviceAction._execute(apiMock).observable;\n\n // WHEN\n const result = await lastValueFrom(observable);\n\n // THEN\n expect(result).toEqual({\n status: DeviceActionStatus.Error,\n error: provideError,\n });\n });\n\n it(\"should return an error if provideContexts throws an error\", async () => {\n // GIVEN\n setupOpenAppDAMock();\n setupDeviceModel(DeviceModelId.FLEX);\n buildSafeAddressContextsMock.mockResolvedValueOnce({\n clearSignContexts: [validSafeContext, validSignerContext],\n });\n provideContextsMock.mockRejectedValueOnce(\n new Error(\"Provide contexts failed\"),\n );\n const deviceAction = new VerifySafeAddressDeviceAction({\n input: {\n safeContractAddress: TEST_SAFE_ADDRESS,\n options: { chainId: TEST_CHAIN_ID },\n contextModule: contextModuleMock as unknown as ContextModule,\n },\n });\n vi.spyOn(deviceAction, \"extractDependencies\").mockReturnValue(\n extractDependenciesMock(),\n );\n observable = deviceAction._execute(apiMock).observable;\n\n // WHEN\n const result = await lastValueFrom(observable);\n\n // THEN\n expect(result).toEqual({\n status: DeviceActionStatus.Error,\n error: new Error(\"Provide contexts failed\"),\n });\n });\n\n it(\"should return an error when buildSafeAddressContexts returns invalid data\", async () => {\n // GIVEN\n setupOpenAppDAMock();\n setupDeviceModel(DeviceModelId.FLEX);\n buildSafeAddressContextsMock.mockRejectedValueOnce(\n new Error(\"Invalid safe address contexts\"),\n );\n const deviceAction = new VerifySafeAddressDeviceAction({\n input: {\n safeContractAddress: TEST_SAFE_ADDRESS,\n options: { chainId: TEST_CHAIN_ID },\n contextModule: contextModuleMock as unknown as ContextModule,\n },\n });\n vi.spyOn(deviceAction, \"extractDependencies\").mockReturnValue(\n extractDependenciesMock(),\n );\n observable = deviceAction._execute(apiMock).observable;\n\n // WHEN\n const result = await lastValueFrom(observable);\n\n // THEN\n expect(result).toEqual({\n status: DeviceActionStatus.Error,\n error: new Error(\"Invalid safe address contexts\"),\n });\n });\n\n it(\"should handle user rejection during provide contexts\", async () => {\n // GIVEN\n setupOpenAppDAMock();\n setupDeviceModel(DeviceModelId.FLEX);\n buildSafeAddressContextsMock.mockResolvedValueOnce({\n clearSignContexts: [validSafeContext, validSignerContext],\n });\n const userRejectionError = new InvalidStatusWordError(\"User rejected\");\n (\n userRejectionError as InvalidStatusWordError & { errorCode: string }\n ).errorCode = \"6985\";\n provideContextsMock.mockResolvedValueOnce(Left(userRejectionError));\n const deviceAction = new VerifySafeAddressDeviceAction({\n input: {\n safeContractAddress: TEST_SAFE_ADDRESS,\n options: { chainId: TEST_CHAIN_ID },\n contextModule: contextModuleMock as unknown as ContextModule,\n },\n });\n vi.spyOn(deviceAction, \"extractDependencies\").mockReturnValue(\n extractDependenciesMock(),\n );\n observable = deviceAction._execute(apiMock).observable;\n\n // WHEN\n const result = await lastValueFrom(observable);\n\n // THEN\n expect(result).toEqual({\n status: DeviceActionStatus.Error,\n error: userRejectionError,\n });\n });\n });\n});\n"],
5
+ "mappings": "aACA,IAAAA,EAGO,oCACPC,EASO,2CACPC,EAA4B,qBAC5BC,EAA0C,gBAE1CC,EAKO,8DACPC,EAAgD,6EAChDC,EAAmC,gFACnCC,EAAiC,uFAEjCC,EAA8C,+BAE9C,GAAG,KAAK,kCAAmC,MAAOC,IAGzC,CACL,GAF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AI,MAAM,+BAA+B,CAC3C,EACA,MAAMa,EAAe,IAAI,gCAA8B,CACrD,MAAO,CACL,oBAAqBT,EACrB,QAAS,CAAE,QAASC,CAAc,EAClC,cAAeN,CACjB,CACF,CAAC,EACD,GAAG,MAAMc,EAAc,qBAAqB,EAAE,gBAC5CX,EAAwB,CAC1B,EACAJ,EAAae,EAAa,SAASV,CAAO,EAAE,WAG5C,MAAMY,EAAS,QAAM,iBAAcjB,CAAU,EAG7C,OAAOiB,CAAM,EAAE,QAAQ,CACrB,OAAQ,qBAAmB,MAC3B,MAAO,IAAI,MAAM,+BAA+B,CAClD,CAAC,CACH,CAAC,EAED,GAAG,uDAAwD,SAAY,IAErE,sBAAmB,EACnBP,EAAiB,gBAAc,IAAI,EACnCR,EAA6B,sBAAsB,CACjD,kBAAmB,CAACM,EAAkBC,CAAkB,CAC1D,CAAC,EACD,MAAMa,EAAqB,IAAI,yBAAuB,eAAe,EAEnEA,EACA,UAAY,OACdnB,EAAoB,yBAAsB,QAAKmB,CAAkB,CAAC,EAClE,MAAMP,EAAe,IAAI,gCAA8B,CACrD,MAAO,CACL,oBAAqBT,EACrB,QAAS,CAAE,QAASC,CAAc,EAClC,cAAeN,CACjB,CACF,CAAC,EACD,GAAG,MAAMc,EAAc,qBAAqB,EAAE,gBAC5CX,EAAwB,CAC1B,EACAJ,EAAae,EAAa,SAASV,CAAO,EAAE,WAG5C,MAAMY,EAAS,QAAM,iBAAcjB,CAAU,EAG7C,OAAOiB,CAAM,EAAE,QAAQ,CACrB,OAAQ,qBAAmB,MAC3B,MAAOK,CACT,CAAC,CACH,CAAC,CACH,CAAC,CACH,CAAC",
6
+ "names": ["import_context_module", "import_device_management_kit", "import_purify_ts", "import_rxjs", "import_VerifySafeAddressDeviceActionTypes", "import_makeInternalApi", "import_setupOpenAppDAMock", "import_testDeviceActionUntilStep", "import_VerifySafeAddress", "importOriginal", "observable", "contextModuleMock", "buildSafeAddressContextsMock", "provideContextsMock", "extractDependenciesMock", "apiMock", "TEST_SAFE_ADDRESS", "TEST_CHAIN_ID", "validSafeContext", "validSignerContext", "setupDeviceModel", "deviceModelId", "getStep", "s", "index", "deviceAction", "steps", "result", "_deviceName", "safeContextWithCert", "signerContextWithCert", "provideError", "userRejectionError"]
7
+ }
@@ -1,2 +1,2 @@
1
- "use strict";var d=Object.defineProperty;var I=Object.getOwnPropertyDescriptor;var E=Object.getOwnPropertyNames;var O=Object.prototype.hasOwnProperty;var y=(i,t)=>{for(var n in t)d(i,n,{get:t[n],enumerable:!0})},R=(i,t,n,a)=>{if(t&&typeof t=="object"||typeof t=="function")for(let s of E(t))!O.call(i,s)&&s!==n&&d(i,s,{get:()=>t[s],enumerable:!(a=I(t,s))||a.enumerable});return i};var h=i=>R(d({},"__esModule",{value:!0}),i);var m={};y(m,{BuildBaseContexts:()=>f});module.exports=h(m);var e=require("@ledgerhq/context-module"),c=require("@ledgerhq/device-management-kit"),S=require("../../../api/model/ClearSigningType"),u=require("../../app-binder/command/GetChallengeCommand"),T=require("../../app-binder/task/GetWeb3CheckTask"),_=require("../../shared/utils/ApplicationChecker");const A=[e.ClearSignContextType.TRANSACTION_INFO,e.ClearSignContextType.TRANSACTION_FIELD_DESCRIPTION,e.ClearSignContextType.ENUM,e.ClearSignContextType.PROXY_INFO];class f{constructor(t,n,a=(s,r)=>new T.GetWeb3CheckTask(s,r)){this._api=t;this._args=n;this.getWeb3ChecksFactory=a}async run(){const{contextModule:t,options:n,appConfig:a,derivationPath:s,transaction:r,subset:N}=this._args,x=r===void 0,C=this._api.getDeviceSessionState();let g;if(C.deviceModelId!==c.DeviceModelId.NANO_S){const o=await this._api.sendCommand(new u.GetChallengeCommand);(0,c.isSuccessCommandResult)(o)&&(g=o.data.challenge)}const p=await t.getContexts({challenge:g,domain:n.domain,deviceModelId:C.deviceModelId,...N},x?A:void 0);if(r&&a.web3ChecksEnabled){const o=(await this.getWeb3ChecksFactory(this._api,{contextModule:t,derivationPath:s,subset:N,transaction:r}).run()).web3Check;o&&p.unshift(o)}const l=p.filter(o=>o.type!==e.ClearSignContextType.ERROR);return this._supportsGenericParser(C,a)&&this._hasValidTransactionInfo(l)?this._getERC7730Contexts(l):this._getBasicContexts(l)}_getERC7730Contexts(t){const n=t.filter(s=>this._isContextNeededForERC7730ClearSigning(s)).sort((s,r)=>this._getContextPriority(s)-this._getContextPriority(r)),a=t.filter(s=>s.type===e.ClearSignContextType.ENUM);return{clearSignContexts:n,clearSignContextsOptional:a,clearSigningType:S.ClearSigningType.EIP7730}}_getBasicContexts(t){return{clearSignContexts:t.filter(a=>this._isContextNeededForBasicClearSigning(a)).sort((a,s)=>this._getContextPriority(a)-this._getContextPriority(s)),clearSignContextsOptional:[],clearSigningType:S.ClearSigningType.BASIC}}_isContextNeededForBasicClearSigning({type:t}){switch(t){case e.ClearSignContextType.WEB3_CHECK:case e.ClearSignContextType.PLUGIN:case e.ClearSignContextType.EXTERNAL_PLUGIN:case e.ClearSignContextType.DYNAMIC_NETWORK:case e.ClearSignContextType.DYNAMIC_NETWORK_ICON:case e.ClearSignContextType.TRUSTED_NAME:case e.ClearSignContextType.TOKEN:case e.ClearSignContextType.NFT:return!0;case e.ClearSignContextType.TRANSACTION_INFO:case e.ClearSignContextType.TRANSACTION_FIELD_DESCRIPTION:case e.ClearSignContextType.ENUM:case e.ClearSignContextType.PROXY_INFO:return!1;default:{const n=t;throw new Error(`Unhandled context type ${String(n)}`)}}}_isContextNeededForERC7730ClearSigning({type:t}){switch(t){case e.ClearSignContextType.TRANSACTION_INFO:case e.ClearSignContextType.TRANSACTION_FIELD_DESCRIPTION:case e.ClearSignContextType.PROXY_INFO:case e.ClearSignContextType.WEB3_CHECK:case e.ClearSignContextType.DYNAMIC_NETWORK:case e.ClearSignContextType.DYNAMIC_NETWORK_ICON:return!0;case e.ClearSignContextType.ENUM:case e.ClearSignContextType.TRUSTED_NAME:case e.ClearSignContextType.TOKEN:case e.ClearSignContextType.NFT:case e.ClearSignContextType.PLUGIN:case e.ClearSignContextType.EXTERNAL_PLUGIN:return!1;default:{const n=t;throw new Error(`Unhandled context type ${String(n)}`)}}}_hasValidTransactionInfo(t){return t.find(n=>n.type===e.ClearSignContextType.TRANSACTION_INFO)?.certificate!==void 0}_supportsGenericParser(t,n){return new _.ApplicationChecker(t,n).withMinVersionExclusive("1.14.0").excludeDeviceModel(c.DeviceModelId.NANO_S).check()}_getContextPriority({type:t}){switch(t){case e.ClearSignContextType.WEB3_CHECK:return 10;case e.ClearSignContextType.DYNAMIC_NETWORK:case e.ClearSignContextType.DYNAMIC_NETWORK_ICON:case e.ClearSignContextType.PROXY_INFO:return 30;case e.ClearSignContextType.TRANSACTION_INFO:return 50;case e.ClearSignContextType.PLUGIN:case e.ClearSignContextType.EXTERNAL_PLUGIN:case e.ClearSignContextType.TOKEN:case e.ClearSignContextType.NFT:case e.ClearSignContextType.TRUSTED_NAME:case e.ClearSignContextType.TRANSACTION_FIELD_DESCRIPTION:case e.ClearSignContextType.ENUM:return 70;default:{const n=t;throw new Error(`Unhandled context type for priority: ${String(n)}`)}}}}0&&(module.exports={BuildBaseContexts});
1
+ "use strict";var l=Object.defineProperty;var u=Object.getOwnPropertyDescriptor;var x=Object.getOwnPropertyNames;var A=Object.prototype.hasOwnProperty;var O=(o,t)=>{for(var n in t)l(o,n,{get:t[n],enumerable:!0})},R=(o,t,n,a)=>{if(t&&typeof t=="object"||typeof t=="function")for(let s of x(t))!A.call(o,s)&&s!==n&&l(o,s,{get:()=>t[s],enumerable:!(a=u(t,s))||a.enumerable});return o};var y=o=>R(l({},"__esModule",{value:!0}),o);var h={};O(h,{BASE_CONTEXT_TYPES_FILTER:()=>E,BuildBaseContexts:()=>f,NESTED_CALLDATA_CONTEXT_TYPES_FILTER:()=>g});module.exports=y(h);var e=require("@ledgerhq/context-module"),r=require("@ledgerhq/device-management-kit"),S=require("../../../api/model/ClearSigningType"),I=require("../../app-binder/command/GetChallengeCommand"),_=require("../../shared/utils/ApplicationChecker");const g=[e.ClearSignContextType.TRANSACTION_INFO,e.ClearSignContextType.TRANSACTION_FIELD_DESCRIPTION,e.ClearSignContextType.ENUM,e.ClearSignContextType.PROXY_INFO],E=[e.ClearSignContextType.TRANSACTION_INFO,e.ClearSignContextType.TRANSACTION_FIELD_DESCRIPTION,e.ClearSignContextType.PROXY_INFO,e.ClearSignContextType.TRANSACTION_CHECK,e.ClearSignContextType.DYNAMIC_NETWORK,e.ClearSignContextType.DYNAMIC_NETWORK_ICON,e.ClearSignContextType.ENUM,e.ClearSignContextType.TRUSTED_NAME,e.ClearSignContextType.TOKEN,e.ClearSignContextType.NFT,e.ClearSignContextType.PLUGIN,e.ClearSignContextType.EXTERNAL_PLUGIN];class f{constructor(t,n){this._api=t;this._args=n}async run(){const{contextModule:t,options:n,appConfig:a,transaction:s,subset:c}=this._args,T=s===void 0,p=!T&&a.web3ChecksEnabled,C=this._api.getDeviceSessionState();let d;if(C.deviceModelId!==r.DeviceModelId.NANO_S){const i=await this._api.sendCommand(new I.GetChallengeCommand);(0,r.isSuccessCommandResult)(i)&&(d=i.data.challenge)}const N=(await t.getContexts({challenge:d,domain:n.domain,deviceModelId:C.deviceModelId,transaction:p?s:void 0,...c},T?g:E)).filter(i=>i.type!==e.ClearSignContextType.ERROR);return this._supportsGenericParser(C,a)&&this._hasValidTransactionInfo(N)?this._getERC7730Contexts(N):this._getBasicContexts(N)}_getERC7730Contexts(t){const n=t.filter(s=>this._isContextNeededForERC7730ClearSigning(s)).sort((s,c)=>this._getContextPriority(s)-this._getContextPriority(c)),a=t.filter(s=>s.type===e.ClearSignContextType.ENUM);return{clearSignContexts:n,clearSignContextsOptional:a,clearSigningType:S.ClearSigningType.EIP7730}}_getBasicContexts(t){return{clearSignContexts:t.filter(a=>this._isContextNeededForBasicClearSigning(a)).sort((a,s)=>this._getContextPriority(a)-this._getContextPriority(s)),clearSignContextsOptional:[],clearSigningType:S.ClearSigningType.BASIC}}_isContextNeededForBasicClearSigning({type:t}){switch(t){case e.ClearSignContextType.TRANSACTION_CHECK:case e.ClearSignContextType.PLUGIN:case e.ClearSignContextType.EXTERNAL_PLUGIN:case e.ClearSignContextType.DYNAMIC_NETWORK:case e.ClearSignContextType.DYNAMIC_NETWORK_ICON:case e.ClearSignContextType.TRUSTED_NAME:case e.ClearSignContextType.TOKEN:case e.ClearSignContextType.NFT:return!0;case e.ClearSignContextType.TRANSACTION_INFO:case e.ClearSignContextType.TRANSACTION_FIELD_DESCRIPTION:case e.ClearSignContextType.ENUM:case e.ClearSignContextType.PROXY_INFO:case e.ClearSignContextType.SAFE:case e.ClearSignContextType.SIGNER:return!1;default:{const n=t;throw new Error(`Unhandled context type ${String(n)}`)}}}_isContextNeededForERC7730ClearSigning({type:t}){switch(t){case e.ClearSignContextType.TRANSACTION_INFO:case e.ClearSignContextType.TRANSACTION_FIELD_DESCRIPTION:case e.ClearSignContextType.PROXY_INFO:case e.ClearSignContextType.DYNAMIC_NETWORK:case e.ClearSignContextType.DYNAMIC_NETWORK_ICON:case e.ClearSignContextType.TRANSACTION_CHECK:return!0;case e.ClearSignContextType.ENUM:case e.ClearSignContextType.TRUSTED_NAME:case e.ClearSignContextType.TOKEN:case e.ClearSignContextType.NFT:case e.ClearSignContextType.PLUGIN:case e.ClearSignContextType.EXTERNAL_PLUGIN:case e.ClearSignContextType.SAFE:case e.ClearSignContextType.SIGNER:return!1;default:{const n=t;throw new Error(`Unhandled context type ${String(n)}`)}}}_hasValidTransactionInfo(t){return t.find(n=>n.type===e.ClearSignContextType.TRANSACTION_INFO)?.certificate!==void 0}_supportsGenericParser(t,n){return new _.ApplicationChecker(t,n).withMinVersionExclusive("1.14.0").excludeDeviceModel(r.DeviceModelId.NANO_S).check()}_getContextPriority({type:t}){switch(t){case e.ClearSignContextType.TRANSACTION_CHECK:return 10;case e.ClearSignContextType.DYNAMIC_NETWORK:case e.ClearSignContextType.DYNAMIC_NETWORK_ICON:case e.ClearSignContextType.PROXY_INFO:return 30;case e.ClearSignContextType.TRANSACTION_INFO:return 50;case e.ClearSignContextType.PLUGIN:case e.ClearSignContextType.EXTERNAL_PLUGIN:case e.ClearSignContextType.TOKEN:case e.ClearSignContextType.NFT:case e.ClearSignContextType.TRUSTED_NAME:case e.ClearSignContextType.TRANSACTION_FIELD_DESCRIPTION:case e.ClearSignContextType.ENUM:return 70;case e.ClearSignContextType.SAFE:case e.ClearSignContextType.SIGNER:return 90;default:{const n=t;throw new Error(`Unhandled context type for priority: ${String(n)}`)}}}}0&&(module.exports={BASE_CONTEXT_TYPES_FILTER,BuildBaseContexts,NESTED_CALLDATA_CONTEXT_TYPES_FILTER});
2
2
  //# sourceMappingURL=BuildBaseContexts.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../../src/internal/app-binder/task/BuildBaseContexts.ts"],
4
- "sourcesContent": ["import {\n type ClearSignContext,\n type ClearSignContextSuccess,\n ClearSignContextType,\n type ContextModule,\n type TransactionSubset,\n} from \"@ledgerhq/context-module\";\nimport {\n DeviceModelId,\n type DeviceSessionState,\n type InternalApi,\n isSuccessCommandResult,\n} from \"@ledgerhq/device-management-kit\";\n\nimport { type GetConfigCommandResponse } from \"@api/app-binder/GetConfigCommandTypes\";\nimport { ClearSigningType } from \"@api/model/ClearSigningType\";\nimport { type TransactionOptions } from \"@api/model/TransactionOptions\";\nimport { GetChallengeCommand } from \"@internal/app-binder/command/GetChallengeCommand\";\nimport {\n GetWeb3CheckTask,\n type GetWeb3CheckTaskArgs,\n} from \"@internal/app-binder/task/GetWeb3CheckTask\";\nimport { ApplicationChecker } from \"@internal/shared/utils/ApplicationChecker\";\n\nconst NESTED_CALLDATA_CONTEXT_TYPES_FILTER: ClearSignContextType[] = [\n ClearSignContextType.TRANSACTION_INFO,\n ClearSignContextType.TRANSACTION_FIELD_DESCRIPTION,\n ClearSignContextType.ENUM,\n ClearSignContextType.PROXY_INFO,\n];\n\nexport type BuildBaseContextsResult = {\n readonly clearSignContexts: ClearSignContextSuccess[];\n readonly clearSignContextsOptional: ClearSignContextSuccess[];\n readonly clearSigningType: ClearSigningType;\n};\n\nexport type BuildBaseContextsArgs = {\n readonly contextModule: ContextModule;\n readonly options: TransactionOptions;\n readonly appConfig: GetConfigCommandResponse;\n readonly derivationPath: string;\n readonly subset: TransactionSubset;\n readonly transaction?: Uint8Array;\n};\n\n/**\n * Builds the base contexts for a transaction\n * @param api - The internal API\n * @param args - The arguments for the build\n * @param getWeb3ChecksFactory - The factory for the web3 checks\n *\n * returns the base contexts for a transaction, without subcontexts or nested call data contexts\n */\nexport class BuildBaseContexts {\n constructor(\n private readonly _api: InternalApi,\n private readonly _args: BuildBaseContextsArgs,\n private readonly getWeb3ChecksFactory = (\n api: InternalApi,\n args: GetWeb3CheckTaskArgs,\n ) => new GetWeb3CheckTask(api, args),\n ) {}\n\n async run(): Promise<BuildBaseContextsResult> {\n const {\n contextModule,\n options,\n appConfig,\n derivationPath,\n transaction,\n subset,\n } = this._args;\n const isNestedCallData = transaction === undefined;\n const deviceState = this._api.getDeviceSessionState();\n\n // Get challenge (not supported on Nano S)\n let challenge: string | undefined = undefined;\n if (deviceState.deviceModelId !== DeviceModelId.NANO_S) {\n const challengeRes = await this._api.sendCommand(\n new GetChallengeCommand(),\n );\n if (isSuccessCommandResult(challengeRes)) {\n challenge = challengeRes.data.challenge;\n }\n }\n\n // Get the clear sign contexts\n const clearSignContexts: ClearSignContext[] =\n await contextModule.getContexts(\n {\n challenge: challenge,\n domain: options.domain,\n deviceModelId: deviceState.deviceModelId,\n ...subset,\n },\n isNestedCallData ? NESTED_CALLDATA_CONTEXT_TYPES_FILTER : undefined,\n );\n\n // Run the web3checks if needed\n if (transaction && appConfig.web3ChecksEnabled) {\n const web3CheckContext = (\n await this.getWeb3ChecksFactory(this._api, {\n contextModule,\n derivationPath,\n subset,\n transaction,\n }).run()\n ).web3Check;\n if (web3CheckContext) {\n clearSignContexts.unshift(web3CheckContext);\n }\n }\n\n // filter out the error contexts\n const contextsSuccess: ClearSignContextSuccess[] = clearSignContexts.filter(\n (context) => context.type !== ClearSignContextType.ERROR,\n );\n\n if (\n this._supportsGenericParser(deviceState, appConfig) &&\n this._hasValidTransactionInfo(contextsSuccess)\n ) {\n return this._getERC7730Contexts(contextsSuccess);\n } else {\n return this._getBasicContexts(contextsSuccess);\n }\n }\n\n private _getERC7730Contexts(\n contexts: ClearSignContextSuccess[],\n ): BuildBaseContextsResult {\n const clearSignContexts: ClearSignContextSuccess[] = contexts\n .filter((context) => this._isContextNeededForERC7730ClearSigning(context))\n .sort(\n (a, b) => this._getContextPriority(a) - this._getContextPriority(b),\n );\n\n const clearSignContextsOptional: ClearSignContextSuccess[] =\n contexts.filter((context) => context.type === ClearSignContextType.ENUM);\n\n return {\n clearSignContexts,\n clearSignContextsOptional,\n clearSigningType: ClearSigningType.EIP7730,\n };\n }\n\n private _getBasicContexts(\n contexts: ClearSignContextSuccess[],\n ): BuildBaseContextsResult {\n const clearSignContexts: ClearSignContextSuccess[] = contexts\n .filter((context) => this._isContextNeededForBasicClearSigning(context))\n .sort(\n (a, b) => this._getContextPriority(a) - this._getContextPriority(b),\n );\n\n return {\n clearSignContexts,\n clearSignContextsOptional: [],\n clearSigningType: ClearSigningType.BASIC,\n };\n }\n\n private _isContextNeededForBasicClearSigning({\n type,\n }: ClearSignContextSuccess): boolean {\n switch (type) {\n case ClearSignContextType.WEB3_CHECK:\n case ClearSignContextType.PLUGIN:\n case ClearSignContextType.EXTERNAL_PLUGIN:\n case ClearSignContextType.DYNAMIC_NETWORK:\n case ClearSignContextType.DYNAMIC_NETWORK_ICON:\n case ClearSignContextType.TRUSTED_NAME:\n case ClearSignContextType.TOKEN:\n case ClearSignContextType.NFT:\n return true;\n case ClearSignContextType.TRANSACTION_INFO:\n case ClearSignContextType.TRANSACTION_FIELD_DESCRIPTION:\n case ClearSignContextType.ENUM:\n case ClearSignContextType.PROXY_INFO:\n return false;\n default: {\n const uncoveredType: never = type;\n throw new Error(`Unhandled context type ${String(uncoveredType)}`);\n }\n }\n }\n\n private _isContextNeededForERC7730ClearSigning({\n type,\n }: ClearSignContextSuccess): boolean {\n switch (type) {\n case ClearSignContextType.TRANSACTION_INFO:\n case ClearSignContextType.TRANSACTION_FIELD_DESCRIPTION:\n case ClearSignContextType.PROXY_INFO:\n case ClearSignContextType.WEB3_CHECK:\n case ClearSignContextType.DYNAMIC_NETWORK:\n case ClearSignContextType.DYNAMIC_NETWORK_ICON:\n return true;\n case ClearSignContextType.ENUM: // enum is needed but as optional\n case ClearSignContextType.TRUSTED_NAME:\n case ClearSignContextType.TOKEN:\n case ClearSignContextType.NFT:\n case ClearSignContextType.PLUGIN:\n case ClearSignContextType.EXTERNAL_PLUGIN:\n return false;\n default: {\n const uncoveredType: never = type;\n throw new Error(`Unhandled context type ${String(uncoveredType)}`);\n }\n }\n }\n\n private _hasValidTransactionInfo(\n contexts: ClearSignContextSuccess[],\n ): boolean {\n return (\n contexts.find(\n (context) => context.type === ClearSignContextType.TRANSACTION_INFO,\n )?.certificate !== undefined\n );\n }\n\n private _supportsGenericParser(\n deviceState: DeviceSessionState,\n appConfig: GetConfigCommandResponse,\n ): boolean {\n return new ApplicationChecker(deviceState, appConfig)\n .withMinVersionExclusive(\"1.14.0\")\n .excludeDeviceModel(DeviceModelId.NANO_S)\n .check();\n }\n\n /**\n * Determines the processing priority of a clear sign context.\n * Lower numbers indicate higher priority (processed first).\n *\n * @param context The clear sign context to get priority for\n * @returns Priority number (lower = higher priority)\n */\n private _getContextPriority({ type }: ClearSignContextSuccess): number {\n switch (type) {\n case ClearSignContextType.WEB3_CHECK:\n return 10;\n case ClearSignContextType.DYNAMIC_NETWORK:\n case ClearSignContextType.DYNAMIC_NETWORK_ICON:\n case ClearSignContextType.PROXY_INFO:\n return 30;\n case ClearSignContextType.TRANSACTION_INFO:\n return 50;\n case ClearSignContextType.PLUGIN:\n case ClearSignContextType.EXTERNAL_PLUGIN:\n case ClearSignContextType.TOKEN:\n case ClearSignContextType.NFT:\n case ClearSignContextType.TRUSTED_NAME:\n case ClearSignContextType.TRANSACTION_FIELD_DESCRIPTION:\n case ClearSignContextType.ENUM:\n return 70;\n\n default: {\n const uncoveredType: never = type;\n throw new Error(\n `Unhandled context type for priority: ${String(uncoveredType)}`,\n );\n }\n }\n }\n}\n"],
5
- "mappings": "yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,uBAAAE,IAAA,eAAAC,EAAAH,GAAA,IAAAI,EAMO,oCACPC,EAKO,2CAGPC,EAAiC,uCAEjCC,EAAoC,4DACpCC,EAGO,sDACPC,EAAmC,qDAEnC,MAAMC,EAA+D,CACnE,uBAAqB,iBACrB,uBAAqB,8BACrB,uBAAqB,KACrB,uBAAqB,UACvB,EAyBO,MAAMR,CAAkB,CAC7B,YACmBS,EACAC,EACAC,EAAuB,CACtCC,EACAC,IACG,IAAI,mBAAiBD,EAAKC,CAAI,EACnC,CANiB,UAAAJ,EACA,WAAAC,EACA,0BAAAC,CAIhB,CAEH,MAAM,KAAwC,CAC5C,KAAM,CACJ,cAAAG,EACA,QAAAC,EACA,UAAAC,EACA,eAAAC,EACA,YAAAC,EACA,OAAAC,CACF,EAAI,KAAK,MACHC,EAAmBF,IAAgB,OACnCG,EAAc,KAAK,KAAK,sBAAsB,EAGpD,IAAIC,EACJ,GAAID,EAAY,gBAAkB,gBAAc,OAAQ,CACtD,MAAME,EAAe,MAAM,KAAK,KAAK,YACnC,IAAI,qBACN,KACI,0BAAuBA,CAAY,IACrCD,EAAYC,EAAa,KAAK,UAElC,CAGA,MAAMC,EACJ,MAAMV,EAAc,YAClB,CACE,UAAWQ,EACX,OAAQP,EAAQ,OAChB,cAAeM,EAAY,cAC3B,GAAGF,CACL,EACAC,EAAmBZ,EAAuC,MAC5D,EAGF,GAAIU,GAAeF,EAAU,kBAAmB,CAC9C,MAAMS,GACJ,MAAM,KAAK,qBAAqB,KAAK,KAAM,CACzC,cAAAX,EACA,eAAAG,EACA,OAAAE,EACA,YAAAD,CACF,CAAC,EAAE,IAAI,GACP,UACEO,GACFD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EQ,uCAAuC,CAC7C,KAAAD,CACF,EAAqC,CACnC,OAAQA,EAAM,CACZ,KAAK,uBAAqB,iBAC1B,KAAK,uBAAqB,8BAC1B,KAAK,uBAAqB,WAC1B,KAAK,uBAAqB,WAC1B,KAAK,uBAAqB,gBAC1B,KAAK,uBAAqB,qBACxB,MAAO,GACT,KAAK,uBAAqB,KAC1B,KAAK,uBAAqB,aAC1B,KAAK,uBAAqB,MAC1B,KAAK,uBAAqB,IAC1B,KAAK,uBAAqB,OAC1B,KAAK,uBAAqB,gBACxB,MAAO,GACT,QAAS,CACP,MAAMC,EAAuBD,EAC7B,MAAM,IAAI,MAAM,0BAA0B,OAAOC,CAAa,CAAC,EAAE,CACnE,CACF,CACF,CAEQ,yBACNL,EACS,CACT,OACEA,EAAS,KACND,GAAYA,EAAQ,OAAS,uBAAqB,gBACrD,GAAG,cAAgB,MAEvB,CAEQ,uBACNN,EACAL,EACS,CACT,OAAO,IAAI,qBAAmBK,EAAaL,CAAS,EACjD,wBAAwB,QAAQ,EAChC,mBAAmB,gBAAc,MAAM,EACvC,MAAM,CACX,CASQ,oBAAoB,CAAE,KAAAgB,CAAK,EAAoC,CACrE,OAAQA,EAAM,CACZ,KAAK,uBAAqB,WACxB,MAAO,IACT,KAAK,uBAAqB,gBAC1B,KAAK,uBAAqB,qBAC1B,KAAK,uBAAqB,WACxB,MAAO,IACT,KAAK,uBAAqB,iBACxB,MAAO,IACT,KAAK,uBAAqB,OAC1B,KAAK,uBAAqB,gBAC1B,KAAK,uBAAqB,MAC1B,KAAK,uBAAqB,IAC1B,KAAK,uBAAqB,aAC1B,KAAK,uBAAqB,8BAC1B,KAAK,uBAAqB,KACxB,MAAO,IAET,QAAS,CACP,MAAMC,EAAuBD,EAC7B,MAAM,IAAI,MACR,wCAAwC,OAAOC,CAAa,CAAC,EAC/D,CACF,CACF,CACF,CACF",
6
- "names": ["BuildBaseContexts_exports", "__export", "BuildBaseContexts", "__toCommonJS", "import_context_module", "import_device_management_kit", "import_ClearSigningType", "import_GetChallengeCommand", "import_GetWeb3CheckTask", "import_ApplicationChecker", "NESTED_CALLDATA_CONTEXT_TYPES_FILTER", "_api", "_args", "getWeb3ChecksFactory", "api", "args", "contextModule", "options", "appConfig", "derivationPath", "transaction", "subset", "isNestedCallData", "deviceState", "challenge", "challengeRes", "clearSignContexts", "web3CheckContext", "contextsSuccess", "context", "contexts", "a", "b", "clearSignContextsOptional", "type", "uncoveredType"]
4
+ "sourcesContent": ["import {\n type ClearSignContext,\n type ClearSignContextSuccess,\n ClearSignContextType,\n type ContextModule,\n type TransactionSubset,\n} from \"@ledgerhq/context-module\";\nimport {\n DeviceModelId,\n type DeviceSessionState,\n type InternalApi,\n isSuccessCommandResult,\n} from \"@ledgerhq/device-management-kit\";\n\nimport { type GetConfigCommandResponse } from \"@api/app-binder/GetConfigCommandTypes\";\nimport { ClearSigningType } from \"@api/model/ClearSigningType\";\nimport { type TransactionOptions } from \"@api/model/TransactionOptions\";\nimport { GetChallengeCommand } from \"@internal/app-binder/command/GetChallengeCommand\";\nimport { ApplicationChecker } from \"@internal/shared/utils/ApplicationChecker\";\n\nexport const NESTED_CALLDATA_CONTEXT_TYPES_FILTER: ClearSignContextType[] = [\n ClearSignContextType.TRANSACTION_INFO,\n ClearSignContextType.TRANSACTION_FIELD_DESCRIPTION,\n ClearSignContextType.ENUM,\n ClearSignContextType.PROXY_INFO,\n];\n\nexport const BASE_CONTEXT_TYPES_FILTER: ClearSignContextType[] = [\n ClearSignContextType.TRANSACTION_INFO,\n ClearSignContextType.TRANSACTION_FIELD_DESCRIPTION,\n ClearSignContextType.PROXY_INFO,\n ClearSignContextType.TRANSACTION_CHECK,\n ClearSignContextType.DYNAMIC_NETWORK,\n ClearSignContextType.DYNAMIC_NETWORK_ICON,\n ClearSignContextType.ENUM,\n ClearSignContextType.TRUSTED_NAME,\n ClearSignContextType.TOKEN,\n ClearSignContextType.NFT,\n ClearSignContextType.PLUGIN,\n ClearSignContextType.EXTERNAL_PLUGIN,\n];\n\nexport type BuildBaseContextsResult = {\n readonly clearSignContexts: ClearSignContextSuccess[];\n readonly clearSignContextsOptional: ClearSignContextSuccess[];\n readonly clearSigningType: ClearSigningType;\n};\n\nexport type BuildBaseContextsArgs = {\n readonly contextModule: ContextModule;\n readonly options: TransactionOptions;\n readonly appConfig: GetConfigCommandResponse;\n readonly subset: TransactionSubset;\n readonly transaction?: Uint8Array;\n};\n\n/**\n * Builds the base contexts for a transaction\n * @param api - The internal API\n * @param args - The arguments for the build\n *\n * returns the base contexts for a transaction, without subcontexts or nested call data contexts\n */\nexport class BuildBaseContexts {\n constructor(\n private readonly _api: InternalApi,\n private readonly _args: BuildBaseContextsArgs,\n ) {}\n\n async run(): Promise<BuildBaseContextsResult> {\n const { contextModule, options, appConfig, transaction, subset } =\n this._args;\n const isNestedCallData = transaction === undefined;\n // As only transaction checks needs the transaction, we don't need to send it if it's not needed\n const needTransaction = !isNestedCallData && appConfig.web3ChecksEnabled;\n\n const deviceState = this._api.getDeviceSessionState();\n\n // Get challenge (not supported on Nano S)\n let challenge: string | undefined = undefined;\n if (deviceState.deviceModelId !== DeviceModelId.NANO_S) {\n const challengeRes = await this._api.sendCommand(\n new GetChallengeCommand(),\n );\n if (isSuccessCommandResult(challengeRes)) {\n challenge = challengeRes.data.challenge;\n }\n }\n\n // Get the clear sign contexts\n const clearSignContexts: ClearSignContext[] =\n await contextModule.getContexts(\n {\n challenge: challenge,\n domain: options.domain,\n deviceModelId: deviceState.deviceModelId,\n transaction: needTransaction ? transaction : undefined,\n ...subset,\n },\n isNestedCallData\n ? NESTED_CALLDATA_CONTEXT_TYPES_FILTER\n : BASE_CONTEXT_TYPES_FILTER,\n );\n\n // filter out the error contexts\n const contextsSuccess: ClearSignContextSuccess[] = clearSignContexts.filter(\n (context) => context.type !== ClearSignContextType.ERROR,\n );\n\n if (\n this._supportsGenericParser(deviceState, appConfig) &&\n this._hasValidTransactionInfo(contextsSuccess)\n ) {\n return this._getERC7730Contexts(contextsSuccess);\n } else {\n return this._getBasicContexts(contextsSuccess);\n }\n }\n\n private _getERC7730Contexts(\n contexts: ClearSignContextSuccess[],\n ): BuildBaseContextsResult {\n const clearSignContexts: ClearSignContextSuccess[] = contexts\n .filter((context) => this._isContextNeededForERC7730ClearSigning(context))\n .sort(\n (a, b) => this._getContextPriority(a) - this._getContextPriority(b),\n );\n\n const clearSignContextsOptional: ClearSignContextSuccess[] =\n contexts.filter((context) => context.type === ClearSignContextType.ENUM);\n\n return {\n clearSignContexts,\n clearSignContextsOptional,\n clearSigningType: ClearSigningType.EIP7730,\n };\n }\n\n private _getBasicContexts(\n contexts: ClearSignContextSuccess[],\n ): BuildBaseContextsResult {\n const clearSignContexts: ClearSignContextSuccess[] = contexts\n .filter((context) => this._isContextNeededForBasicClearSigning(context))\n .sort(\n (a, b) => this._getContextPriority(a) - this._getContextPriority(b),\n );\n\n return {\n clearSignContexts,\n clearSignContextsOptional: [],\n clearSigningType: ClearSigningType.BASIC,\n };\n }\n\n private _isContextNeededForBasicClearSigning({\n type,\n }: ClearSignContextSuccess): boolean {\n switch (type) {\n case ClearSignContextType.TRANSACTION_CHECK:\n case ClearSignContextType.PLUGIN:\n case ClearSignContextType.EXTERNAL_PLUGIN:\n case ClearSignContextType.DYNAMIC_NETWORK:\n case ClearSignContextType.DYNAMIC_NETWORK_ICON:\n case ClearSignContextType.TRUSTED_NAME:\n case ClearSignContextType.TOKEN:\n case ClearSignContextType.NFT:\n return true;\n case ClearSignContextType.TRANSACTION_INFO:\n case ClearSignContextType.TRANSACTION_FIELD_DESCRIPTION:\n case ClearSignContextType.ENUM:\n case ClearSignContextType.PROXY_INFO:\n case ClearSignContextType.SAFE:\n case ClearSignContextType.SIGNER:\n return false;\n default: {\n const uncoveredType: never = type;\n throw new Error(`Unhandled context type ${String(uncoveredType)}`);\n }\n }\n }\n\n private _isContextNeededForERC7730ClearSigning({\n type,\n }: ClearSignContextSuccess): boolean {\n switch (type) {\n case ClearSignContextType.TRANSACTION_INFO:\n case ClearSignContextType.TRANSACTION_FIELD_DESCRIPTION:\n case ClearSignContextType.PROXY_INFO:\n case ClearSignContextType.DYNAMIC_NETWORK:\n case ClearSignContextType.DYNAMIC_NETWORK_ICON:\n case ClearSignContextType.TRANSACTION_CHECK:\n return true;\n case ClearSignContextType.ENUM: // enum is needed but as optional\n case ClearSignContextType.TRUSTED_NAME:\n case ClearSignContextType.TOKEN:\n case ClearSignContextType.NFT:\n case ClearSignContextType.PLUGIN:\n case ClearSignContextType.EXTERNAL_PLUGIN:\n case ClearSignContextType.SAFE:\n case ClearSignContextType.SIGNER:\n return false;\n default: {\n const uncoveredType: never = type;\n throw new Error(`Unhandled context type ${String(uncoveredType)}`);\n }\n }\n }\n\n private _hasValidTransactionInfo(\n contexts: ClearSignContextSuccess[],\n ): boolean {\n return (\n contexts.find(\n (context) => context.type === ClearSignContextType.TRANSACTION_INFO,\n )?.certificate !== undefined\n );\n }\n\n private _supportsGenericParser(\n deviceState: DeviceSessionState,\n appConfig: GetConfigCommandResponse,\n ): boolean {\n return new ApplicationChecker(deviceState, appConfig)\n .withMinVersionExclusive(\"1.14.0\")\n .excludeDeviceModel(DeviceModelId.NANO_S)\n .check();\n }\n\n /**\n * Determines the processing priority of a clear sign context.\n * Lower numbers indicate higher priority (processed first).\n *\n * @param context The clear sign context to get priority for\n * @returns Priority number (lower = higher priority)\n */\n private _getContextPriority({ type }: ClearSignContextSuccess): number {\n switch (type) {\n case ClearSignContextType.TRANSACTION_CHECK:\n return 10;\n case ClearSignContextType.DYNAMIC_NETWORK:\n case ClearSignContextType.DYNAMIC_NETWORK_ICON:\n case ClearSignContextType.PROXY_INFO:\n return 30;\n case ClearSignContextType.TRANSACTION_INFO:\n return 50;\n case ClearSignContextType.PLUGIN:\n case ClearSignContextType.EXTERNAL_PLUGIN:\n case ClearSignContextType.TOKEN:\n case ClearSignContextType.NFT:\n case ClearSignContextType.TRUSTED_NAME:\n case ClearSignContextType.TRANSACTION_FIELD_DESCRIPTION:\n case ClearSignContextType.ENUM:\n return 70;\n\n /* not used here */\n case ClearSignContextType.SAFE:\n case ClearSignContextType.SIGNER:\n return 90;\n\n default: {\n const uncoveredType: never = type;\n throw new Error(\n `Unhandled context type for priority: ${String(uncoveredType)}`,\n );\n }\n }\n }\n}\n"],
5
+ "mappings": "yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,+BAAAE,EAAA,sBAAAC,EAAA,yCAAAC,IAAA,eAAAC,EAAAL,GAAA,IAAAM,EAMO,oCACPC,EAKO,2CAGPC,EAAiC,uCAEjCC,EAAoC,4DACpCC,EAAmC,qDAE5B,MAAMN,EAA+D,CAC1E,uBAAqB,iBACrB,uBAAqB,8BACrB,uBAAqB,KACrB,uBAAqB,UACvB,EAEaF,EAAoD,CAC/D,uBAAqB,iBACrB,uBAAqB,8BACrB,uBAAqB,WACrB,uBAAqB,kBACrB,uBAAqB,gBACrB,uBAAqB,qBACrB,uBAAqB,KACrB,uBAAqB,aACrB,uBAAqB,MACrB,uBAAqB,IACrB,uBAAqB,OACrB,uBAAqB,eACvB,EAuBO,MAAMC,CAAkB,CAC7B,YACmBQ,EACAC,EACjB,CAFiB,UAAAD,EACA,WAAAC,CAChB,CAEH,MAAM,KAAwC,CAC5C,KAAM,CAAE,cAAAC,EAAe,QAAAC,EAAS,UAAAC,EAAW,YAAAC,EAAa,OAAAC,CAAO,EAC7D,KAAK,MACDC,EAAmBF,IAAgB,OAEnCG,EAAkB,CAACD,GAAoBH,EAAU,kBAEjDK,EAAc,KAAK,KAAK,sBAAsB,EAGpD,IAAIC,EACJ,GAAID,EAAY,gBAAkB,gBAAc,OAAQ,CACtD,MAAME,EAAe,MAAM,KAAK,KAAK,YACnC,IAAI,qBACN,KACI,0BAAuBA,CAAY,IACrCD,EAAYC,EAAa,KAAK,UAElC,CAkBA,MAAMC,GAdJ,MAAMV,EAAc,YAClB,CACE,UAAWQ,EACX,OAAQP,EAAQ,OAChB,cAAeM,EAAY,cAC3B,YAAaD,EAA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B,MAAM,IAAI,MACR,wCAAwC,OAAOC,CAAa,CAAC,EAC/D,CACF,CACF,CACF,CACF",
6
+ "names": ["BuildBaseContexts_exports", "__export", "BASE_CONTEXT_TYPES_FILTER", "BuildBaseContexts", "NESTED_CALLDATA_CONTEXT_TYPES_FILTER", "__toCommonJS", "import_context_module", "import_device_management_kit", "import_ClearSigningType", "import_GetChallengeCommand", "import_ApplicationChecker", "_api", "_args", "contextModule", "options", "appConfig", "transaction", "subset", "isNestedCallData", "needTransaction", "deviceState", "challenge", "challengeRes", "contextsSuccess", "context", "contexts", "clearSignContexts", "a", "b", "clearSignContextsOptional", "type", "uncoveredType"]
7
7
  }