@ledgerhq/context-module 0.0.0-20241212001220

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 (420) hide show
  1. package/LICENSE.MD +202 -0
  2. package/README.md +125 -0
  3. package/lib/cjs/index.js +2 -0
  4. package/lib/cjs/index.js.map +7 -0
  5. package/lib/cjs/package.json +57 -0
  6. package/lib/cjs/src/ContextModule.js +2 -0
  7. package/lib/cjs/src/ContextModule.js.map +7 -0
  8. package/lib/cjs/src/ContextModuleBuilder.js +2 -0
  9. package/lib/cjs/src/ContextModuleBuilder.js.map +7 -0
  10. package/lib/cjs/src/ContextModuleBuilder.test.js +2 -0
  11. package/lib/cjs/src/ContextModuleBuilder.test.js.map +7 -0
  12. package/lib/cjs/src/DefaultContextModule.js +2 -0
  13. package/lib/cjs/src/DefaultContextModule.js.map +7 -0
  14. package/lib/cjs/src/DefaultContextModule.test.js +2 -0
  15. package/lib/cjs/src/DefaultContextModule.test.js.map +7 -0
  16. package/lib/cjs/src/config/di/configModuleFactory.js +2 -0
  17. package/lib/cjs/src/config/di/configModuleFactory.js.map +7 -0
  18. package/lib/cjs/src/config/di/configTypes.js +2 -0
  19. package/lib/cjs/src/config/di/configTypes.js.map +7 -0
  20. package/lib/cjs/src/config/model/ContextModuleConfig.js +2 -0
  21. package/lib/cjs/src/config/model/ContextModuleConfig.js.map +7 -0
  22. package/lib/cjs/src/di.js +2 -0
  23. package/lib/cjs/src/di.js.map +7 -0
  24. package/lib/cjs/src/external-plugin/data/DAppDto.js +2 -0
  25. package/lib/cjs/src/external-plugin/data/DAppDto.js.map +7 -0
  26. package/lib/cjs/src/external-plugin/data/ExternalPluginDataSource.js +2 -0
  27. package/lib/cjs/src/external-plugin/data/ExternalPluginDataSource.js.map +7 -0
  28. package/lib/cjs/src/external-plugin/data/HttpExternalPluginDataSource.js +2 -0
  29. package/lib/cjs/src/external-plugin/data/HttpExternalPluginDataSource.js.map +7 -0
  30. package/lib/cjs/src/external-plugin/data/HttpExternalPluginDataSource.test.js +2 -0
  31. package/lib/cjs/src/external-plugin/data/HttpExternalPluginDataSource.test.js.map +7 -0
  32. package/lib/cjs/src/external-plugin/di/externalPluginModuleFactory.js +2 -0
  33. package/lib/cjs/src/external-plugin/di/externalPluginModuleFactory.js.map +7 -0
  34. package/lib/cjs/src/external-plugin/di/externalPluginTypes.js +2 -0
  35. package/lib/cjs/src/external-plugin/di/externalPluginTypes.js.map +7 -0
  36. package/lib/cjs/src/external-plugin/domain/ExternalPluginContextLoader.js +2 -0
  37. package/lib/cjs/src/external-plugin/domain/ExternalPluginContextLoader.js.map +7 -0
  38. package/lib/cjs/src/external-plugin/domain/ExternalPluginContextLoader.test.js +2 -0
  39. package/lib/cjs/src/external-plugin/domain/ExternalPluginContextLoader.test.js.map +7 -0
  40. package/lib/cjs/src/external-plugin/model/DappInfos.js +2 -0
  41. package/lib/cjs/src/external-plugin/model/DappInfos.js.map +7 -0
  42. package/lib/cjs/src/external-plugin/model/SelectorDetails.js +2 -0
  43. package/lib/cjs/src/external-plugin/model/SelectorDetails.js.map +7 -0
  44. package/lib/cjs/src/index.js +2 -0
  45. package/lib/cjs/src/index.js.map +7 -0
  46. package/lib/cjs/src/nft/data/HttpNftDataSource.js +2 -0
  47. package/lib/cjs/src/nft/data/HttpNftDataSource.js.map +7 -0
  48. package/lib/cjs/src/nft/data/HttpNftDataSource.test.js +2 -0
  49. package/lib/cjs/src/nft/data/HttpNftDataSource.test.js.map +7 -0
  50. package/lib/cjs/src/nft/data/NftDataSource.js +2 -0
  51. package/lib/cjs/src/nft/data/NftDataSource.js.map +7 -0
  52. package/lib/cjs/src/nft/di/nftModuleFactory.js +2 -0
  53. package/lib/cjs/src/nft/di/nftModuleFactory.js.map +7 -0
  54. package/lib/cjs/src/nft/di/nftTypes.js +2 -0
  55. package/lib/cjs/src/nft/di/nftTypes.js.map +7 -0
  56. package/lib/cjs/src/nft/domain/NftContextLoader.js +2 -0
  57. package/lib/cjs/src/nft/domain/NftContextLoader.js.map +7 -0
  58. package/lib/cjs/src/nft/domain/NftContextLoader.test.js +2 -0
  59. package/lib/cjs/src/nft/domain/NftContextLoader.test.js.map +7 -0
  60. package/lib/cjs/src/shared/domain/ContextLoader.js +2 -0
  61. package/lib/cjs/src/shared/domain/ContextLoader.js.map +7 -0
  62. package/lib/cjs/src/shared/model/ClearSignContext.js +2 -0
  63. package/lib/cjs/src/shared/model/ClearSignContext.js.map +7 -0
  64. package/lib/cjs/src/shared/model/GenericPath.js +2 -0
  65. package/lib/cjs/src/shared/model/GenericPath.js.map +7 -0
  66. package/lib/cjs/src/shared/model/TransactionContext.js +2 -0
  67. package/lib/cjs/src/shared/model/TransactionContext.js.map +7 -0
  68. package/lib/cjs/src/shared/model/TransactionSubset.js +2 -0
  69. package/lib/cjs/src/shared/model/TransactionSubset.js.map +7 -0
  70. package/lib/cjs/src/shared/model/TypedDataClearSignContext.js +2 -0
  71. package/lib/cjs/src/shared/model/TypedDataClearSignContext.js.map +7 -0
  72. package/lib/cjs/src/shared/model/TypedDataContext.js +2 -0
  73. package/lib/cjs/src/shared/model/TypedDataContext.js.map +7 -0
  74. package/lib/cjs/src/shared/utils/HexStringUtils.js +2 -0
  75. package/lib/cjs/src/shared/utils/HexStringUtils.js.map +7 -0
  76. package/lib/cjs/src/token/data/HttpTokenDataSource.js +2 -0
  77. package/lib/cjs/src/token/data/HttpTokenDataSource.js.map +7 -0
  78. package/lib/cjs/src/token/data/HttpTokenDataSource.test.js +2 -0
  79. package/lib/cjs/src/token/data/HttpTokenDataSource.test.js.map +7 -0
  80. package/lib/cjs/src/token/data/TokenDataSource.js +2 -0
  81. package/lib/cjs/src/token/data/TokenDataSource.js.map +7 -0
  82. package/lib/cjs/src/token/data/TokenDto.js +2 -0
  83. package/lib/cjs/src/token/data/TokenDto.js.map +7 -0
  84. package/lib/cjs/src/token/di/tokenModuleFactory.js +2 -0
  85. package/lib/cjs/src/token/di/tokenModuleFactory.js.map +7 -0
  86. package/lib/cjs/src/token/di/tokenTypes.js +2 -0
  87. package/lib/cjs/src/token/di/tokenTypes.js.map +7 -0
  88. package/lib/cjs/src/token/domain/TokenContextLoader.js +2 -0
  89. package/lib/cjs/src/token/domain/TokenContextLoader.js.map +7 -0
  90. package/lib/cjs/src/token/domain/TokenContextLoader.test.js +2 -0
  91. package/lib/cjs/src/token/domain/TokenContextLoader.test.js.map +7 -0
  92. package/lib/cjs/src/transaction/data/CalldataDto.js +2 -0
  93. package/lib/cjs/src/transaction/data/CalldataDto.js.map +7 -0
  94. package/lib/cjs/src/transaction/data/HttpTransactionDataSource.js +2 -0
  95. package/lib/cjs/src/transaction/data/HttpTransactionDataSource.js.map +7 -0
  96. package/lib/cjs/src/transaction/data/HttpTransactionDataSource.test.js +2 -0
  97. package/lib/cjs/src/transaction/data/HttpTransactionDataSource.test.js.map +7 -0
  98. package/lib/cjs/src/transaction/data/TransactionDataSource.js +2 -0
  99. package/lib/cjs/src/transaction/data/TransactionDataSource.js.map +7 -0
  100. package/lib/cjs/src/transaction/di/transactionModuleFactory.js +2 -0
  101. package/lib/cjs/src/transaction/di/transactionModuleFactory.js.map +7 -0
  102. package/lib/cjs/src/transaction/di/transactionTypes.js +2 -0
  103. package/lib/cjs/src/transaction/di/transactionTypes.js.map +7 -0
  104. package/lib/cjs/src/transaction/domain/TransactionContextLoader.js +2 -0
  105. package/lib/cjs/src/transaction/domain/TransactionContextLoader.js.map +7 -0
  106. package/lib/cjs/src/transaction/domain/TransactionContextLoader.test.js +2 -0
  107. package/lib/cjs/src/transaction/domain/TransactionContextLoader.test.js.map +7 -0
  108. package/lib/cjs/src/trusted-name/data/HttpTrustedNameDataSource.js +2 -0
  109. package/lib/cjs/src/trusted-name/data/HttpTrustedNameDataSource.js.map +7 -0
  110. package/lib/cjs/src/trusted-name/data/HttpTrustedNameDataSource.test.js +2 -0
  111. package/lib/cjs/src/trusted-name/data/HttpTrustedNameDataSource.test.js.map +7 -0
  112. package/lib/cjs/src/trusted-name/data/TrustedNameDataSource.js +2 -0
  113. package/lib/cjs/src/trusted-name/data/TrustedNameDataSource.js.map +7 -0
  114. package/lib/cjs/src/trusted-name/data/TrustedNameDto.js +2 -0
  115. package/lib/cjs/src/trusted-name/data/TrustedNameDto.js.map +7 -0
  116. package/lib/cjs/src/trusted-name/di/trustedNameModuleFactory.js +2 -0
  117. package/lib/cjs/src/trusted-name/di/trustedNameModuleFactory.js.map +7 -0
  118. package/lib/cjs/src/trusted-name/di/trustedNameTypes.js +2 -0
  119. package/lib/cjs/src/trusted-name/di/trustedNameTypes.js.map +7 -0
  120. package/lib/cjs/src/trusted-name/domain/TrustedNameContextLoader.js +2 -0
  121. package/lib/cjs/src/trusted-name/domain/TrustedNameContextLoader.js.map +7 -0
  122. package/lib/cjs/src/trusted-name/domain/TrustedNameContextLoader.test.js +2 -0
  123. package/lib/cjs/src/trusted-name/domain/TrustedNameContextLoader.test.js.map +7 -0
  124. package/lib/cjs/src/typed-data/data/FiltersDto.js +2 -0
  125. package/lib/cjs/src/typed-data/data/FiltersDto.js.map +7 -0
  126. package/lib/cjs/src/typed-data/data/HttpTypedDataDataSource.js +2 -0
  127. package/lib/cjs/src/typed-data/data/HttpTypedDataDataSource.js.map +7 -0
  128. package/lib/cjs/src/typed-data/data/HttpTypedDataDataSource.test.js +2 -0
  129. package/lib/cjs/src/typed-data/data/HttpTypedDataDataSource.test.js.map +7 -0
  130. package/lib/cjs/src/typed-data/data/TypedDataDataSource.js +2 -0
  131. package/lib/cjs/src/typed-data/data/TypedDataDataSource.js.map +7 -0
  132. package/lib/cjs/src/typed-data/di/typedDataModuleFactory.js +2 -0
  133. package/lib/cjs/src/typed-data/di/typedDataModuleFactory.js.map +7 -0
  134. package/lib/cjs/src/typed-data/di/typedDataTypes.js +2 -0
  135. package/lib/cjs/src/typed-data/di/typedDataTypes.js.map +7 -0
  136. package/lib/cjs/src/typed-data/domain/DefaultTypedDataContextLoader.js +2 -0
  137. package/lib/cjs/src/typed-data/domain/DefaultTypedDataContextLoader.js.map +7 -0
  138. package/lib/cjs/src/typed-data/domain/DefaultTypedDataContextLoader.test.js +2 -0
  139. package/lib/cjs/src/typed-data/domain/DefaultTypedDataContextLoader.test.js.map +7 -0
  140. package/lib/cjs/src/typed-data/domain/TypedDataContextLoader.js +2 -0
  141. package/lib/cjs/src/typed-data/domain/TypedDataContextLoader.js.map +7 -0
  142. package/lib/esm/index.js +2 -0
  143. package/lib/esm/index.js.map +7 -0
  144. package/lib/esm/package.json +57 -0
  145. package/lib/esm/src/ContextModule.js +1 -0
  146. package/lib/esm/src/ContextModule.js.map +7 -0
  147. package/lib/esm/src/ContextModuleBuilder.js +2 -0
  148. package/lib/esm/src/ContextModuleBuilder.js.map +7 -0
  149. package/lib/esm/src/ContextModuleBuilder.test.js +2 -0
  150. package/lib/esm/src/ContextModuleBuilder.test.js.map +7 -0
  151. package/lib/esm/src/DefaultContextModule.js +2 -0
  152. package/lib/esm/src/DefaultContextModule.js.map +7 -0
  153. package/lib/esm/src/DefaultContextModule.test.js +2 -0
  154. package/lib/esm/src/DefaultContextModule.test.js.map +7 -0
  155. package/lib/esm/src/config/di/configModuleFactory.js +2 -0
  156. package/lib/esm/src/config/di/configModuleFactory.js.map +7 -0
  157. package/lib/esm/src/config/di/configTypes.js +2 -0
  158. package/lib/esm/src/config/di/configTypes.js.map +7 -0
  159. package/lib/esm/src/config/model/ContextModuleConfig.js +1 -0
  160. package/lib/esm/src/config/model/ContextModuleConfig.js.map +7 -0
  161. package/lib/esm/src/di.js +2 -0
  162. package/lib/esm/src/di.js.map +7 -0
  163. package/lib/esm/src/external-plugin/data/DAppDto.js +1 -0
  164. package/lib/esm/src/external-plugin/data/DAppDto.js.map +7 -0
  165. package/lib/esm/src/external-plugin/data/ExternalPluginDataSource.js +1 -0
  166. package/lib/esm/src/external-plugin/data/ExternalPluginDataSource.js.map +7 -0
  167. package/lib/esm/src/external-plugin/data/HttpExternalPluginDataSource.js +2 -0
  168. package/lib/esm/src/external-plugin/data/HttpExternalPluginDataSource.js.map +7 -0
  169. package/lib/esm/src/external-plugin/data/HttpExternalPluginDataSource.test.js +2 -0
  170. package/lib/esm/src/external-plugin/data/HttpExternalPluginDataSource.test.js.map +7 -0
  171. package/lib/esm/src/external-plugin/di/externalPluginModuleFactory.js +2 -0
  172. package/lib/esm/src/external-plugin/di/externalPluginModuleFactory.js.map +7 -0
  173. package/lib/esm/src/external-plugin/di/externalPluginTypes.js +2 -0
  174. package/lib/esm/src/external-plugin/di/externalPluginTypes.js.map +7 -0
  175. package/lib/esm/src/external-plugin/domain/ExternalPluginContextLoader.js +2 -0
  176. package/lib/esm/src/external-plugin/domain/ExternalPluginContextLoader.js.map +7 -0
  177. package/lib/esm/src/external-plugin/domain/ExternalPluginContextLoader.test.js +2 -0
  178. package/lib/esm/src/external-plugin/domain/ExternalPluginContextLoader.test.js.map +7 -0
  179. package/lib/esm/src/external-plugin/model/DappInfos.js +1 -0
  180. package/lib/esm/src/external-plugin/model/DappInfos.js.map +7 -0
  181. package/lib/esm/src/external-plugin/model/SelectorDetails.js +1 -0
  182. package/lib/esm/src/external-plugin/model/SelectorDetails.js.map +7 -0
  183. package/lib/esm/src/index.js +2 -0
  184. package/lib/esm/src/index.js.map +7 -0
  185. package/lib/esm/src/nft/data/HttpNftDataSource.js +2 -0
  186. package/lib/esm/src/nft/data/HttpNftDataSource.js.map +7 -0
  187. package/lib/esm/src/nft/data/HttpNftDataSource.test.js +2 -0
  188. package/lib/esm/src/nft/data/HttpNftDataSource.test.js.map +7 -0
  189. package/lib/esm/src/nft/data/NftDataSource.js +1 -0
  190. package/lib/esm/src/nft/data/NftDataSource.js.map +7 -0
  191. package/lib/esm/src/nft/di/nftModuleFactory.js +2 -0
  192. package/lib/esm/src/nft/di/nftModuleFactory.js.map +7 -0
  193. package/lib/esm/src/nft/di/nftTypes.js +2 -0
  194. package/lib/esm/src/nft/di/nftTypes.js.map +7 -0
  195. package/lib/esm/src/nft/domain/NftContextLoader.js +2 -0
  196. package/lib/esm/src/nft/domain/NftContextLoader.js.map +7 -0
  197. package/lib/esm/src/nft/domain/NftContextLoader.test.js +2 -0
  198. package/lib/esm/src/nft/domain/NftContextLoader.test.js.map +7 -0
  199. package/lib/esm/src/shared/domain/ContextLoader.js +1 -0
  200. package/lib/esm/src/shared/domain/ContextLoader.js.map +7 -0
  201. package/lib/esm/src/shared/model/ClearSignContext.js +2 -0
  202. package/lib/esm/src/shared/model/ClearSignContext.js.map +7 -0
  203. package/lib/esm/src/shared/model/GenericPath.js +2 -0
  204. package/lib/esm/src/shared/model/GenericPath.js.map +7 -0
  205. package/lib/esm/src/shared/model/TransactionContext.js +1 -0
  206. package/lib/esm/src/shared/model/TransactionContext.js.map +7 -0
  207. package/lib/esm/src/shared/model/TransactionSubset.js +1 -0
  208. package/lib/esm/src/shared/model/TransactionSubset.js.map +7 -0
  209. package/lib/esm/src/shared/model/TypedDataClearSignContext.js +2 -0
  210. package/lib/esm/src/shared/model/TypedDataClearSignContext.js.map +7 -0
  211. package/lib/esm/src/shared/model/TypedDataContext.js +1 -0
  212. package/lib/esm/src/shared/model/TypedDataContext.js.map +7 -0
  213. package/lib/esm/src/shared/utils/HexStringUtils.js +2 -0
  214. package/lib/esm/src/shared/utils/HexStringUtils.js.map +7 -0
  215. package/lib/esm/src/token/data/HttpTokenDataSource.js +2 -0
  216. package/lib/esm/src/token/data/HttpTokenDataSource.js.map +7 -0
  217. package/lib/esm/src/token/data/HttpTokenDataSource.test.js +2 -0
  218. package/lib/esm/src/token/data/HttpTokenDataSource.test.js.map +7 -0
  219. package/lib/esm/src/token/data/TokenDataSource.js +1 -0
  220. package/lib/esm/src/token/data/TokenDataSource.js.map +7 -0
  221. package/lib/esm/src/token/data/TokenDto.js +1 -0
  222. package/lib/esm/src/token/data/TokenDto.js.map +7 -0
  223. package/lib/esm/src/token/di/tokenModuleFactory.js +2 -0
  224. package/lib/esm/src/token/di/tokenModuleFactory.js.map +7 -0
  225. package/lib/esm/src/token/di/tokenTypes.js +2 -0
  226. package/lib/esm/src/token/di/tokenTypes.js.map +7 -0
  227. package/lib/esm/src/token/domain/TokenContextLoader.js +2 -0
  228. package/lib/esm/src/token/domain/TokenContextLoader.js.map +7 -0
  229. package/lib/esm/src/token/domain/TokenContextLoader.test.js +2 -0
  230. package/lib/esm/src/token/domain/TokenContextLoader.test.js.map +7 -0
  231. package/lib/esm/src/transaction/data/CalldataDto.js +1 -0
  232. package/lib/esm/src/transaction/data/CalldataDto.js.map +7 -0
  233. package/lib/esm/src/transaction/data/HttpTransactionDataSource.js +2 -0
  234. package/lib/esm/src/transaction/data/HttpTransactionDataSource.js.map +7 -0
  235. package/lib/esm/src/transaction/data/HttpTransactionDataSource.test.js +2 -0
  236. package/lib/esm/src/transaction/data/HttpTransactionDataSource.test.js.map +7 -0
  237. package/lib/esm/src/transaction/data/TransactionDataSource.js +1 -0
  238. package/lib/esm/src/transaction/data/TransactionDataSource.js.map +7 -0
  239. package/lib/esm/src/transaction/di/transactionModuleFactory.js +2 -0
  240. package/lib/esm/src/transaction/di/transactionModuleFactory.js.map +7 -0
  241. package/lib/esm/src/transaction/di/transactionTypes.js +2 -0
  242. package/lib/esm/src/transaction/di/transactionTypes.js.map +7 -0
  243. package/lib/esm/src/transaction/domain/TransactionContextLoader.js +2 -0
  244. package/lib/esm/src/transaction/domain/TransactionContextLoader.js.map +7 -0
  245. package/lib/esm/src/transaction/domain/TransactionContextLoader.test.js +2 -0
  246. package/lib/esm/src/transaction/domain/TransactionContextLoader.test.js.map +7 -0
  247. package/lib/esm/src/trusted-name/data/HttpTrustedNameDataSource.js +2 -0
  248. package/lib/esm/src/trusted-name/data/HttpTrustedNameDataSource.js.map +7 -0
  249. package/lib/esm/src/trusted-name/data/HttpTrustedNameDataSource.test.js +2 -0
  250. package/lib/esm/src/trusted-name/data/HttpTrustedNameDataSource.test.js.map +7 -0
  251. package/lib/esm/src/trusted-name/data/TrustedNameDataSource.js +1 -0
  252. package/lib/esm/src/trusted-name/data/TrustedNameDataSource.js.map +7 -0
  253. package/lib/esm/src/trusted-name/data/TrustedNameDto.js +1 -0
  254. package/lib/esm/src/trusted-name/data/TrustedNameDto.js.map +7 -0
  255. package/lib/esm/src/trusted-name/di/trustedNameModuleFactory.js +2 -0
  256. package/lib/esm/src/trusted-name/di/trustedNameModuleFactory.js.map +7 -0
  257. package/lib/esm/src/trusted-name/di/trustedNameTypes.js +2 -0
  258. package/lib/esm/src/trusted-name/di/trustedNameTypes.js.map +7 -0
  259. package/lib/esm/src/trusted-name/domain/TrustedNameContextLoader.js +2 -0
  260. package/lib/esm/src/trusted-name/domain/TrustedNameContextLoader.js.map +7 -0
  261. package/lib/esm/src/trusted-name/domain/TrustedNameContextLoader.test.js +2 -0
  262. package/lib/esm/src/trusted-name/domain/TrustedNameContextLoader.test.js.map +7 -0
  263. package/lib/esm/src/typed-data/data/FiltersDto.js +1 -0
  264. package/lib/esm/src/typed-data/data/FiltersDto.js.map +7 -0
  265. package/lib/esm/src/typed-data/data/HttpTypedDataDataSource.js +2 -0
  266. package/lib/esm/src/typed-data/data/HttpTypedDataDataSource.js.map +7 -0
  267. package/lib/esm/src/typed-data/data/HttpTypedDataDataSource.test.js +2 -0
  268. package/lib/esm/src/typed-data/data/HttpTypedDataDataSource.test.js.map +7 -0
  269. package/lib/esm/src/typed-data/data/TypedDataDataSource.js +1 -0
  270. package/lib/esm/src/typed-data/data/TypedDataDataSource.js.map +7 -0
  271. package/lib/esm/src/typed-data/di/typedDataModuleFactory.js +2 -0
  272. package/lib/esm/src/typed-data/di/typedDataModuleFactory.js.map +7 -0
  273. package/lib/esm/src/typed-data/di/typedDataTypes.js +2 -0
  274. package/lib/esm/src/typed-data/di/typedDataTypes.js.map +7 -0
  275. package/lib/esm/src/typed-data/domain/DefaultTypedDataContextLoader.js +2 -0
  276. package/lib/esm/src/typed-data/domain/DefaultTypedDataContextLoader.js.map +7 -0
  277. package/lib/esm/src/typed-data/domain/DefaultTypedDataContextLoader.test.js +2 -0
  278. package/lib/esm/src/typed-data/domain/DefaultTypedDataContextLoader.test.js.map +7 -0
  279. package/lib/esm/src/typed-data/domain/TypedDataContextLoader.js +1 -0
  280. package/lib/esm/src/typed-data/domain/TypedDataContextLoader.js.map +7 -0
  281. package/lib/types/index.d.ts +3 -0
  282. package/lib/types/index.d.ts.map +1 -0
  283. package/lib/types/src/ContextModule.d.ts +10 -0
  284. package/lib/types/src/ContextModule.d.ts.map +1 -0
  285. package/lib/types/src/ContextModuleBuilder.d.ts +43 -0
  286. package/lib/types/src/ContextModuleBuilder.d.ts.map +1 -0
  287. package/lib/types/src/ContextModuleBuilder.test.d.ts +2 -0
  288. package/lib/types/src/ContextModuleBuilder.test.d.ts.map +1 -0
  289. package/lib/types/src/DefaultContextModule.d.ts +18 -0
  290. package/lib/types/src/DefaultContextModule.d.ts.map +1 -0
  291. package/lib/types/src/DefaultContextModule.test.d.ts +2 -0
  292. package/lib/types/src/DefaultContextModule.test.d.ts.map +1 -0
  293. package/lib/types/src/config/di/configModuleFactory.d.ts +4 -0
  294. package/lib/types/src/config/di/configModuleFactory.d.ts.map +1 -0
  295. package/lib/types/src/config/di/configTypes.d.ts +4 -0
  296. package/lib/types/src/config/di/configTypes.d.ts.map +1 -0
  297. package/lib/types/src/config/model/ContextModuleConfig.d.ts +16 -0
  298. package/lib/types/src/config/model/ContextModuleConfig.d.ts.map +1 -0
  299. package/lib/types/src/di.d.ts +8 -0
  300. package/lib/types/src/di.d.ts.map +1 -0
  301. package/lib/types/src/external-plugin/data/DAppDto.d.ts +38 -0
  302. package/lib/types/src/external-plugin/data/DAppDto.d.ts.map +1 -0
  303. package/lib/types/src/external-plugin/data/ExternalPluginDataSource.d.ts +12 -0
  304. package/lib/types/src/external-plugin/data/ExternalPluginDataSource.d.ts.map +1 -0
  305. package/lib/types/src/external-plugin/data/HttpExternalPluginDataSource.d.ts +10 -0
  306. package/lib/types/src/external-plugin/data/HttpExternalPluginDataSource.d.ts.map +1 -0
  307. package/lib/types/src/external-plugin/data/HttpExternalPluginDataSource.test.d.ts +2 -0
  308. package/lib/types/src/external-plugin/data/HttpExternalPluginDataSource.test.d.ts.map +1 -0
  309. package/lib/types/src/external-plugin/di/externalPluginModuleFactory.d.ts +3 -0
  310. package/lib/types/src/external-plugin/di/externalPluginModuleFactory.d.ts.map +1 -0
  311. package/lib/types/src/external-plugin/di/externalPluginTypes.d.ts +5 -0
  312. package/lib/types/src/external-plugin/di/externalPluginTypes.d.ts.map +1 -0
  313. package/lib/types/src/external-plugin/domain/ExternalPluginContextLoader.d.ts +15 -0
  314. package/lib/types/src/external-plugin/domain/ExternalPluginContextLoader.d.ts.map +1 -0
  315. package/lib/types/src/external-plugin/domain/ExternalPluginContextLoader.test.d.ts +2 -0
  316. package/lib/types/src/external-plugin/domain/ExternalPluginContextLoader.test.d.ts.map +1 -0
  317. package/lib/types/src/external-plugin/model/DappInfos.d.ts +6 -0
  318. package/lib/types/src/external-plugin/model/DappInfos.d.ts.map +1 -0
  319. package/lib/types/src/external-plugin/model/SelectorDetails.d.ts +8 -0
  320. package/lib/types/src/external-plugin/model/SelectorDetails.d.ts.map +1 -0
  321. package/lib/types/src/index.d.ts +16 -0
  322. package/lib/types/src/index.d.ts.map +1 -0
  323. package/lib/types/src/nft/data/HttpNftDataSource.d.ts +7 -0
  324. package/lib/types/src/nft/data/HttpNftDataSource.d.ts.map +1 -0
  325. package/lib/types/src/nft/data/HttpNftDataSource.test.d.ts +2 -0
  326. package/lib/types/src/nft/data/HttpNftDataSource.test.d.ts.map +1 -0
  327. package/lib/types/src/nft/data/NftDataSource.d.ts +15 -0
  328. package/lib/types/src/nft/data/NftDataSource.d.ts.map +1 -0
  329. package/lib/types/src/nft/di/nftModuleFactory.d.ts +3 -0
  330. package/lib/types/src/nft/di/nftModuleFactory.d.ts.map +1 -0
  331. package/lib/types/src/nft/di/nftTypes.d.ts +5 -0
  332. package/lib/types/src/nft/di/nftTypes.d.ts.map +1 -0
  333. package/lib/types/src/nft/domain/NftContextLoader.d.ts +12 -0
  334. package/lib/types/src/nft/domain/NftContextLoader.d.ts.map +1 -0
  335. package/lib/types/src/nft/domain/NftContextLoader.test.d.ts +2 -0
  336. package/lib/types/src/nft/domain/NftContextLoader.test.d.ts.map +1 -0
  337. package/lib/types/src/shared/domain/ContextLoader.d.ts +7 -0
  338. package/lib/types/src/shared/domain/ContextLoader.d.ts.map +1 -0
  339. package/lib/types/src/shared/model/ClearSignContext.d.ts +40 -0
  340. package/lib/types/src/shared/model/ClearSignContext.d.ts.map +1 -0
  341. package/lib/types/src/shared/model/GenericPath.d.ts +105 -0
  342. package/lib/types/src/shared/model/GenericPath.d.ts.map +1 -0
  343. package/lib/types/src/shared/model/TransactionContext.d.ts +19 -0
  344. package/lib/types/src/shared/model/TransactionContext.d.ts.map +1 -0
  345. package/lib/types/src/shared/model/TransactionSubset.d.ts +6 -0
  346. package/lib/types/src/shared/model/TransactionSubset.d.ts.map +1 -0
  347. package/lib/types/src/shared/model/TypedDataClearSignContext.d.ts +33 -0
  348. package/lib/types/src/shared/model/TypedDataClearSignContext.d.ts.map +1 -0
  349. package/lib/types/src/shared/model/TypedDataContext.d.ts +16 -0
  350. package/lib/types/src/shared/model/TypedDataContext.d.ts.map +1 -0
  351. package/lib/types/src/shared/utils/HexStringUtils.d.ts +4 -0
  352. package/lib/types/src/shared/utils/HexStringUtils.d.ts.map +1 -0
  353. package/lib/types/src/token/data/HttpTokenDataSource.d.ts +9 -0
  354. package/lib/types/src/token/data/HttpTokenDataSource.d.ts.map +1 -0
  355. package/lib/types/src/token/data/HttpTokenDataSource.test.d.ts +2 -0
  356. package/lib/types/src/token/data/HttpTokenDataSource.test.d.ts.map +1 -0
  357. package/lib/types/src/token/data/TokenDataSource.d.ts +9 -0
  358. package/lib/types/src/token/data/TokenDataSource.d.ts.map +1 -0
  359. package/lib/types/src/token/data/TokenDto.d.ts +16 -0
  360. package/lib/types/src/token/data/TokenDto.d.ts.map +1 -0
  361. package/lib/types/src/token/di/tokenModuleFactory.d.ts +3 -0
  362. package/lib/types/src/token/di/tokenModuleFactory.d.ts.map +1 -0
  363. package/lib/types/src/token/di/tokenTypes.d.ts +5 -0
  364. package/lib/types/src/token/di/tokenTypes.d.ts.map +1 -0
  365. package/lib/types/src/token/domain/TokenContextLoader.d.ts +16 -0
  366. package/lib/types/src/token/domain/TokenContextLoader.d.ts.map +1 -0
  367. package/lib/types/src/token/domain/TokenContextLoader.test.d.ts +2 -0
  368. package/lib/types/src/token/domain/TokenContextLoader.test.d.ts.map +1 -0
  369. package/lib/types/src/transaction/data/CalldataDto.d.ts +117 -0
  370. package/lib/types/src/transaction/data/CalldataDto.d.ts.map +1 -0
  371. package/lib/types/src/transaction/data/HttpTransactionDataSource.d.ts +19 -0
  372. package/lib/types/src/transaction/data/HttpTransactionDataSource.d.ts.map +1 -0
  373. package/lib/types/src/transaction/data/HttpTransactionDataSource.test.d.ts +2 -0
  374. package/lib/types/src/transaction/data/HttpTransactionDataSource.test.d.ts.map +1 -0
  375. package/lib/types/src/transaction/data/TransactionDataSource.d.ts +12 -0
  376. package/lib/types/src/transaction/data/TransactionDataSource.d.ts.map +1 -0
  377. package/lib/types/src/transaction/di/transactionModuleFactory.d.ts +3 -0
  378. package/lib/types/src/transaction/di/transactionModuleFactory.d.ts.map +1 -0
  379. package/lib/types/src/transaction/di/transactionTypes.d.ts +5 -0
  380. package/lib/types/src/transaction/di/transactionTypes.d.ts.map +1 -0
  381. package/lib/types/src/transaction/domain/TransactionContextLoader.d.ts +10 -0
  382. package/lib/types/src/transaction/domain/TransactionContextLoader.d.ts.map +1 -0
  383. package/lib/types/src/transaction/domain/TransactionContextLoader.test.d.ts +2 -0
  384. package/lib/types/src/transaction/domain/TransactionContextLoader.test.d.ts.map +1 -0
  385. package/lib/types/src/trusted-name/data/HttpTrustedNameDataSource.d.ts +11 -0
  386. package/lib/types/src/trusted-name/data/HttpTrustedNameDataSource.d.ts.map +1 -0
  387. package/lib/types/src/trusted-name/data/HttpTrustedNameDataSource.test.d.ts +2 -0
  388. package/lib/types/src/trusted-name/data/HttpTrustedNameDataSource.test.d.ts.map +1 -0
  389. package/lib/types/src/trusted-name/data/TrustedNameDataSource.d.ts +16 -0
  390. package/lib/types/src/trusted-name/data/TrustedNameDataSource.d.ts.map +1 -0
  391. package/lib/types/src/trusted-name/data/TrustedNameDto.d.ts +15 -0
  392. package/lib/types/src/trusted-name/data/TrustedNameDto.d.ts.map +1 -0
  393. package/lib/types/src/trusted-name/di/trustedNameModuleFactory.d.ts +3 -0
  394. package/lib/types/src/trusted-name/di/trustedNameModuleFactory.d.ts.map +1 -0
  395. package/lib/types/src/trusted-name/di/trustedNameTypes.d.ts +5 -0
  396. package/lib/types/src/trusted-name/di/trustedNameTypes.d.ts.map +1 -0
  397. package/lib/types/src/trusted-name/domain/TrustedNameContextLoader.d.ts +12 -0
  398. package/lib/types/src/trusted-name/domain/TrustedNameContextLoader.d.ts.map +1 -0
  399. package/lib/types/src/trusted-name/domain/TrustedNameContextLoader.test.d.ts +2 -0
  400. package/lib/types/src/trusted-name/domain/TrustedNameContextLoader.test.d.ts.map +1 -0
  401. package/lib/types/src/typed-data/data/FiltersDto.d.ts +58 -0
  402. package/lib/types/src/typed-data/data/FiltersDto.d.ts.map +1 -0
  403. package/lib/types/src/typed-data/data/HttpTypedDataDataSource.d.ts +14 -0
  404. package/lib/types/src/typed-data/data/HttpTypedDataDataSource.d.ts.map +1 -0
  405. package/lib/types/src/typed-data/data/HttpTypedDataDataSource.test.d.ts +3 -0
  406. package/lib/types/src/typed-data/data/HttpTypedDataDataSource.test.d.ts.map +1 -0
  407. package/lib/types/src/typed-data/data/TypedDataDataSource.d.ts +17 -0
  408. package/lib/types/src/typed-data/data/TypedDataDataSource.d.ts.map +1 -0
  409. package/lib/types/src/typed-data/di/typedDataModuleFactory.d.ts +3 -0
  410. package/lib/types/src/typed-data/di/typedDataModuleFactory.d.ts.map +1 -0
  411. package/lib/types/src/typed-data/di/typedDataTypes.d.ts +5 -0
  412. package/lib/types/src/typed-data/di/typedDataTypes.d.ts.map +1 -0
  413. package/lib/types/src/typed-data/domain/DefaultTypedDataContextLoader.d.ts +13 -0
  414. package/lib/types/src/typed-data/domain/DefaultTypedDataContextLoader.d.ts.map +1 -0
  415. package/lib/types/src/typed-data/domain/DefaultTypedDataContextLoader.test.d.ts +2 -0
  416. package/lib/types/src/typed-data/domain/DefaultTypedDataContextLoader.test.d.ts.map +1 -0
  417. package/lib/types/src/typed-data/domain/TypedDataContextLoader.d.ts +6 -0
  418. package/lib/types/src/typed-data/domain/TypedDataContextLoader.d.ts.map +1 -0
  419. package/lib/types/tsconfig.prod.tsbuildinfo +1 -0
  420. package/package.json +56 -0
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../../../src/trusted-name/data/HttpTrustedNameDataSource.ts"],
4
+ "sourcesContent": ["import axios from \"axios\";\nimport { inject, injectable } from \"inversify\";\nimport { Either, Left, Right } from \"purify-ts\";\n\nimport { configTypes } from \"@/config/di/configTypes\";\nimport type { ContextModuleConfig } from \"@/config/model/ContextModuleConfig\";\nimport {\n GetDomainNameInfosParams,\n GetTrustedNameInfosParams,\n TrustedNameDataSource,\n} from \"@/trusted-name/data/TrustedNameDataSource\";\nimport PACKAGE from \"@root/package.json\";\n\nimport { TrustedNameDto } from \"./TrustedNameDto\";\n\n@injectable()\nexport class HttpTrustedNameDataSource implements TrustedNameDataSource {\n constructor(\n @inject(configTypes.Config) private readonly config: ContextModuleConfig,\n ) {}\n\n public async getDomainNamePayload({\n domain,\n challenge,\n }: GetDomainNameInfosParams): Promise<Either<Error, string>> {\n try {\n const type = \"eoa\"; // Externally owned account\n const source = \"ens\"; // Ethereum name service\n const response = await axios.request<TrustedNameDto>({\n method: \"GET\",\n url: `https://nft.api.live.ledger.com/v2/names/ethereum/1/forward/${domain}?types=${type}&sources=${source}&challenge=${challenge}`,\n headers: {\n \"X-Ledger-Client-Version\": `context-module/${PACKAGE.version}`,\n },\n });\n\n return response.data.signedDescriptor?.data\n ? Right(response.data.signedDescriptor.data)\n : Left(\n new Error(\n \"[ContextModule] HttpTrustedNameDataSource: error getting domain payload\",\n ),\n );\n } catch (_error) {\n return Left(\n new Error(\n \"[ContextModule] HttpTrustedNameDataSource: Failed to fetch domain name\",\n ),\n );\n }\n }\n\n public async getTrustedNamePayload({\n address,\n challenge,\n sources,\n types,\n }: GetTrustedNameInfosParams): Promise<Either<Error, string>> {\n try {\n // TODO remove that filtering once https://ledgerhq.atlassian.net/browse/BACK-8075 is done\n // For now we have to filter or trusted names won't work with the generic parser, because transaction\n // fields descriptors can contain unsupported sources.\n sources = sources.filter(\n (source) => source === \"ens\" || source === \"crypto_assets_list\",\n );\n const response = await axios.request<TrustedNameDto>({\n method: \"GET\",\n url: `https://nft.api.live.ledger.com/v2/names/ethereum/1/reverse/${address}?types=${types.join(\",\")}&sources=${sources.join(\",\")}&challenge=${challenge}`,\n headers: {\n \"X-Ledger-Client-Version\": `context-module/${PACKAGE.version}`,\n },\n });\n const trustedName = response.data;\n if (!trustedName?.signedDescriptor?.data) {\n return Left(\n new Error(\n `[ContextModule] HttpTrustedNameDataSource: no trusted name metadata for address ${address}`,\n ),\n );\n }\n const payload = trustedName.signedDescriptor.data;\n\n if (\n !trustedName.signedDescriptor.signatures ||\n typeof trustedName.signedDescriptor.signatures[this.config.cal.mode] !==\n \"string\"\n ) {\n // If we have no separated signature but a valid descriptor, it may mean the descriptor was\n // signed on-the-fly for dynamic sources such as ens\n return Right(payload);\n }\n\n const signature =\n trustedName.signedDescriptor.signatures[this.config.cal.mode]!;\n return Right(this.formatTrustedName(payload, signature));\n } catch (_error) {\n return Left(\n new Error(\n \"[ContextModule] HttpTrustedNameDataSource: Failed to fetch trusted name\",\n ),\n );\n }\n }\n\n private formatTrustedName(payload: string, signature: string): string {\n // Ensure correct padding\n if (signature.length % 2 !== 0) {\n signature = \"0\" + signature;\n }\n // TLV encoding as according to trusted name documentation\n const signatureTag = \"15\";\n const signatureLength = (signature.length / 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7C,GACE,CAACA,EAAY,iBAAiB,YAC9B,OAAOA,EAAY,iBAAiB,WAAW,KAAK,OAAO,IAAI,IAAI,GACjE,SAIF,SAAO,SAAMC,CAAO,EAGtB,MAAMC,EACJF,EAAY,iBAAiB,WAAW,KAAK,OAAO,IAAI,IAAI,EAC9D,SAAO,SAAM,KAAK,kBAAkBC,EAASC,CAAS,CAAC,CACzD,MAAiB,CACf,SAAO,QACL,IAAI,MACF,yEACF,CACF,CACF,CACF,CAEQ,kBAAkBD,EAAiBC,EAA2B,CAEhEA,EAAU,OAAS,IAAM,IAC3BA,EAAY,IAAMA,GAGpB,MAAMC,EAAe,KACfC,GAAmBF,EAAU,OAAS,GAAG,SAAS,EAAE,EAC1D,MAAO,GAAGD,CAAO,GAAGE,CAAY,GAAGC,CAAe,GAAGF,CAAS,EAChE,CACF,EAlGab,EAANgB,EAAA,IADN,cAAW,EAGPC,EAAA,eAAO,cAAY,MAAM,IAFjBjB",
6
+ "names": ["HttpTrustedNameDataSource_exports", "__export", "HttpTrustedNameDataSource", "__toCommonJS", "import_axios", "import_inversify", "import_purify_ts", "import_configTypes", "import_package", "HttpTrustedNameDataSource", "config", "domain", "challenge", "response", "axios", "PACKAGE", "address", "sources", "types", "source", "trustedName", "payload", "signature", "signatureTag", "signatureLength", "__decorateClass", "__decorateParam"]
7
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";var u=Object.create;var d=Object.defineProperty;var p=Object.getOwnPropertyDescriptor;var m=Object.getOwnPropertyNames;var h=Object.getPrototypeOf,y=Object.prototype.hasOwnProperty;var g=(t,e,a,l)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of m(e))!y.call(t,r)&&r!==a&&d(t,r,{get:()=>e[r],enumerable:!(l=p(e,r))||l.enumerable});return t};var c=(t,e,a)=>(a=t!=null?u(h(t)):{},g(e||!t||!t.__esModule?d(a,"default",{value:t,enumerable:!0}):a,t));var o=c(require("axios")),s=require("purify-ts"),i=require("../../trusted-name/data/HttpTrustedNameDataSource"),n=c(require("../../../package.json"));jest.mock("axios");describe("HttpTrustedNameDataSource",()=>{let t;beforeAll(()=>{const e={cal:{url:"https://crypto-assets-service.api.ledger.com/v1",mode:"prod",branch:"main"}};t=new i.HttpTrustedNameDataSource(e),jest.clearAllMocks()}),describe("getDomainNamePayload",()=>{it("should call axios with the ledger client version header",async()=>{const e=`context-module/${n.default.version}`,a=jest.fn(()=>Promise.resolve({data:[]}));jest.spyOn(o.default,"request").mockImplementation(a),await t.getDomainNamePayload({challenge:"",domain:"hello.eth"}),expect(a).toHaveBeenCalledWith(expect.objectContaining({headers:{"X-Ledger-Client-Version":e}}))}),it("should throw an error when axios throws an error",async()=>{jest.spyOn(o.default,"request").mockRejectedValue(new Error);const e=await t.getDomainNamePayload({challenge:"",domain:"hello.eth"});expect(e).toEqual((0,s.Left)(new Error("[ContextModule] HttpTrustedNameDataSource: Failed to fetch domain name")))}),it("should return an error when no payload is returned",async()=>{const e={data:{test:""}};jest.spyOn(o.default,"request").mockResolvedValue(e);const a=await t.getDomainNamePayload({challenge:"",domain:"hello.eth"});expect(a).toEqual((0,s.Left)(new Error("[ContextModule] HttpTrustedNameDataSource: error getting domain payload")))}),it("should return a payload",async()=>{const e={data:{signedDescriptor:{data:"payload"}}};jest.spyOn(o.default,"request").mockResolvedValue(e);const a=await t.getDomainNamePayload({challenge:"challenge",domain:"hello.eth"});expect(a).toEqual((0,s.Right)("payload"))})}),describe("getTrustedNamePayload",()=>{it("should call axios with the ledger client version header",async()=>{const e=`context-module/${n.default.version}`,a=jest.fn(()=>Promise.resolve({data:[]}));jest.spyOn(o.default,"request").mockImplementation(a),await t.getTrustedNamePayload({address:"0x1234",challenge:"",sources:["ens"],types:["eoa"]}),expect(a).toHaveBeenCalledWith(expect.objectContaining({headers:{"X-Ledger-Client-Version":e}}))}),it("should throw an error when axios throws an error",async()=>{jest.spyOn(o.default,"request").mockRejectedValue(new Error);const e=await t.getTrustedNamePayload({address:"0x1234",challenge:"",sources:["ens"],types:["eoa"]});expect(e).toEqual((0,s.Left)(new Error("[ContextModule] HttpTrustedNameDataSource: Failed to fetch trusted name")))}),it("should return an error when no payload is returned",async()=>{const e={data:{test:""}};jest.spyOn(o.default,"request").mockResolvedValue(e);const a=await t.getTrustedNamePayload({address:"0x1234",challenge:"",sources:["ens"],types:["eoa"]});expect(a).toEqual((0,s.Left)(new Error("[ContextModule] HttpTrustedNameDataSource: no trusted name metadata for address 0x1234")))}),it("should return a payload",async()=>{const e={data:{signedDescriptor:{data:"payload"}}};jest.spyOn(o.default,"request").mockResolvedValue(e);const a=await t.getTrustedNamePayload({address:"0x1234",challenge:"",sources:["ens"],types:["eoa"]});expect(a).toEqual((0,s.Right)("payload"))}),it("should return a payload with a signature",async()=>{const e={data:{signedDescriptor:{data:"payload",signatures:{prod:"12345"}}}};jest.spyOn(o.default,"request").mockResolvedValue(e);const a=await t.getTrustedNamePayload({address:"0x1234",challenge:"",sources:["ens"],types:["eoa"]});expect(a).toEqual((0,s.Right)("payload153012345"))})})});
2
+ //# sourceMappingURL=HttpTrustedNameDataSource.test.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../../../src/trusted-name/data/HttpTrustedNameDataSource.test.ts"],
4
+ "sourcesContent": ["import axios from \"axios\";\nimport { Left, Right } from \"purify-ts\";\n\nimport { type ContextModuleConfig } from \"@/config/model/ContextModuleConfig\";\nimport { HttpTrustedNameDataSource } from \"@/trusted-name/data/HttpTrustedNameDataSource\";\nimport { type TrustedNameDataSource } from \"@/trusted-name/data/TrustedNameDataSource\";\nimport PACKAGE from \"@root/package.json\";\n\njest.mock(\"axios\");\n\ndescribe(\"HttpTrustedNameDataSource\", () => {\n let datasource: TrustedNameDataSource;\n\n beforeAll(() => {\n const config = {\n cal: {\n url: \"https://crypto-assets-service.api.ledger.com/v1\",\n mode: \"prod\",\n branch: \"main\",\n },\n } as ContextModuleConfig;\n datasource = new HttpTrustedNameDataSource(config);\n jest.clearAllMocks();\n });\n\n describe(\"getDomainNamePayload\", () => {\n it(\"should call axios with the ledger client version header\", async () => {\n // GIVEN\n const version = `context-module/${PACKAGE.version}`;\n const requestSpy = jest.fn(() => Promise.resolve({ data: [] }));\n jest.spyOn(axios, \"request\").mockImplementation(requestSpy);\n\n // WHEN\n await datasource.getDomainNamePayload({\n challenge: \"\",\n domain: \"hello.eth\",\n });\n\n // THEN\n expect(requestSpy).toHaveBeenCalledWith(\n expect.objectContaining({\n headers: { \"X-Ledger-Client-Version\": version },\n }),\n );\n });\n\n it(\"should throw an error when axios throws an error\", async () => {\n // GIVEN\n jest.spyOn(axios, \"request\").mockRejectedValue(new Error());\n\n // WHEN\n const result = await datasource.getDomainNamePayload({\n challenge: \"\",\n domain: \"hello.eth\",\n });\n\n // THEN\n expect(result).toEqual(\n Left(\n new Error(\n \"[ContextModule] HttpTrustedNameDataSource: Failed to fetch domain name\",\n ),\n ),\n );\n });\n\n it(\"should return an error when no payload is returned\", async () => {\n // GIVEN\n const response = { data: { test: \"\" } };\n jest.spyOn(axios, \"request\").mockResolvedValue(response);\n\n // WHEN\n const result = await datasource.getDomainNamePayload({\n challenge: \"\",\n domain: \"hello.eth\",\n });\n\n // THEN\n expect(result).toEqual(\n Left(\n new Error(\n \"[ContextModule] HttpTrustedNameDataSource: error getting domain payload\",\n ),\n ),\n );\n });\n\n it(\"should return a payload\", async () => {\n // GIVEN\n const response = { data: { signedDescriptor: { data: \"payload\" } } };\n jest.spyOn(axios, \"request\").mockResolvedValue(response);\n\n // WHEN\n const result = await datasource.getDomainNamePayload({\n challenge: \"challenge\",\n domain: \"hello.eth\",\n });\n\n // THEN\n expect(result).toEqual(Right(\"payload\"));\n });\n });\n\n describe(\"getTrustedNamePayload\", () => {\n it(\"should call axios with the ledger client version header\", async () => {\n // GIVEN\n const version = `context-module/${PACKAGE.version}`;\n const requestSpy = jest.fn(() => Promise.resolve({ data: [] }));\n jest.spyOn(axios, \"request\").mockImplementation(requestSpy);\n\n // WHEN\n await datasource.getTrustedNamePayload({\n address: \"0x1234\",\n challenge: \"\",\n sources: [\"ens\"],\n types: [\"eoa\"],\n });\n\n // THEN\n expect(requestSpy).toHaveBeenCalledWith(\n expect.objectContaining({\n headers: { \"X-Ledger-Client-Version\": version },\n }),\n );\n });\n\n it(\"should throw an error when axios throws an error\", async () => {\n // GIVEN\n jest.spyOn(axios, \"request\").mockRejectedValue(new Error());\n\n // WHEN\n const result = await datasource.getTrustedNamePayload({\n address: \"0x1234\",\n challenge: \"\",\n sources: [\"ens\"],\n types: [\"eoa\"],\n });\n\n // THEN\n expect(result).toEqual(\n Left(\n new Error(\n \"[ContextModule] HttpTrustedNameDataSource: Failed to fetch trusted name\",\n ),\n ),\n );\n });\n\n it(\"should return an error when no payload is returned\", async () => {\n // GIVEN\n const response = { data: { test: \"\" } };\n jest.spyOn(axios, \"request\").mockResolvedValue(response);\n\n // WHEN\n const result = await datasource.getTrustedNamePayload({\n address: \"0x1234\",\n challenge: \"\",\n sources: [\"ens\"],\n types: [\"eoa\"],\n });\n\n // THEN\n expect(result).toEqual(\n Left(\n new Error(\n \"[ContextModule] HttpTrustedNameDataSource: no trusted name metadata for address 0x1234\",\n ),\n ),\n );\n });\n\n it(\"should return a payload\", async () => {\n // GIVEN\n const response = {\n data: {\n signedDescriptor: { data: \"payload\" },\n },\n };\n jest.spyOn(axios, \"request\").mockResolvedValue(response);\n\n // WHEN\n const result = await datasource.getTrustedNamePayload({\n address: \"0x1234\",\n challenge: \"\",\n sources: [\"ens\"],\n types: [\"eoa\"],\n });\n\n // THEN\n expect(result).toEqual(Right(\"payload\"));\n });\n\n it(\"should return a payload with a signature\", async () => {\n // GIVEN\n const response = {\n data: {\n signedDescriptor: { data: \"payload\", signatures: { prod: \"12345\" } },\n },\n };\n jest.spyOn(axios, \"request\").mockResolvedValue(response);\n\n // WHEN\n const result = await datasource.getTrustedNamePayload({\n address: \"0x1234\",\n challenge: \"\",\n sources: [\"ens\"],\n types: [\"eoa\"],\n });\n\n // THEN\n exp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,QAAO,SAAS,EAAE,kBAAkBE,CAAQ,EAGvD,MAAMD,EAAS,MAAMN,EAAW,sBAAsB,CACpD,QAAS,SACT,UAAW,GACX,QAAS,CAAC,KAAK,EACf,MAAO,CAAC,KAAK,CACf,CAAC,EAGD,OAAOM,CAAM,EAAE,WACb,QACE,IAAI,MACF,wFACF,CACF,CACF,CACF,CAAC,EAED,GAAG,0BAA2B,SAAY,CAExC,MAAMC,EAAW,CACf,KAAM,CACJ,iBAAkB,CAAE,KAAM,SAAU,CACtC,CACF,EACA,KAAK,MAAM,EAAAF,QAAO,SAAS,EAAE,kBAAkBE,CAAQ,EAGvD,MAAMD,EAAS,MAAMN,EAAW,sBAAsB,CACpD,QAAS,SACT,UAAW,GACX,QAAS,CAAC,KAAK,EACf,MAAO,CAAC,KAAK,CACf,CAAC,EAGD,OAAOM,CAAM,EAAE,WAAQ,SAAM,SAAS,CAAC,CACzC,CAAC,EAED,GAAG,2CAA4C,SAAY,CAEzD,MAAMC,EAAW,CACf,KAAM,CACJ,iBAAkB,CAAE,KAAM,UAAW,WAAY,CAAE,KAAM,OAAQ,CAAE,CACrE,CACF,EACA,KAAK,MAAM,EAAAF,QAAO,SAAS,EAAE,kBAAkBE,CAAQ,EAGvD,MAAMD,EAAS,MAAMN,EAAW,sBAAsB,CACpD,QAAS,SACT,UAAW,GACX,QAAS,CAAC,KAAK,EACf,MAAO,CAAC,KAAK,CACf,CAAC,EAGD,OAAOM,CAAM,EAAE,WAAQ,SAAM,kBAAkB,CAAC,CAClD,CAAC,CACH,CAAC,CACH,CAAC",
6
+ "names": ["import_axios", "import_purify_ts", "import_HttpTrustedNameDataSource", "import_package", "datasource", "config", "version", "PACKAGE", "requestSpy", "axios", "result", "response"]
7
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";var s=Object.defineProperty;var o=Object.getOwnPropertyDescriptor;var i=Object.getOwnPropertyNames;var n=Object.prototype.hasOwnProperty;var g=(r,e,m,t)=>{if(e&&typeof e=="object"||typeof e=="function")for(let a of i(e))!n.call(r,a)&&a!==m&&s(r,a,{get:()=>e[a],enumerable:!(t=o(e,a))||t.enumerable});return r};var p=r=>g(s({},"__esModule",{value:!0}),r);var d={};module.exports=p(d);
2
+ //# sourceMappingURL=TrustedNameDataSource.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../../../src/trusted-name/data/TrustedNameDataSource.ts"],
4
+ "sourcesContent": ["import { type Either } from \"purify-ts/Either\";\n\nexport type GetDomainNameInfosParams = {\n domain: string;\n challenge: string;\n};\n\nexport type GetTrustedNameInfosParams = {\n address: string;\n challenge: string;\n types: string[];\n sources: string[];\n};\n\nexport interface TrustedNameDataSource {\n getDomainNamePayload(\n params: GetDomainNameInfosParams,\n ): Promise<Either<Error, string>>;\n\n getTrustedNamePayload(\n params: GetTrustedNameInfosParams,\n ): Promise<Either<Error, string>>;\n}\n"],
5
+ "mappings": "+WAAA,IAAAA,EAAA,kBAAAC,EAAAD",
6
+ "names": ["TrustedNameDataSource_exports", "__toCommonJS"]
7
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";var i=Object.defineProperty;var a=Object.getOwnPropertyDescriptor;var d=Object.getOwnPropertyNames;var g=Object.prototype.hasOwnProperty;var n=(e,t,p,s)=>{if(t&&typeof t=="object"||typeof t=="function")for(let r of d(t))!g.call(e,r)&&r!==p&&i(e,r,{get:()=>t[r],enumerable:!(s=a(t,r))||s.enumerable});return e};var o=e=>n(i({},"__esModule",{value:!0}),e);var u={};module.exports=o(u);
2
+ //# sourceMappingURL=TrustedNameDto.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../../../src/trusted-name/data/TrustedNameDto.ts"],
4
+ "sourcesContent": ["export type TrustedNameSignatures =\n | {\n prod: string;\n test?: string;\n }\n | {\n prod?: string;\n test: string;\n };\n\nexport type TrustedNameDescriptor = {\n data: string;\n signatures?: TrustedNameSignatures;\n};\n\nexport type TrustedNameDto = {\n signedDescriptor: TrustedNameDescriptor;\n};\n"],
5
+ "mappings": "+WAAA,IAAAA,EAAA,kBAAAC,EAAAD",
6
+ "names": ["TrustedNameDto_exports", "__toCommonJS"]
7
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";var m=Object.defineProperty;var i=Object.getOwnPropertyDescriptor;var p=Object.getOwnPropertyNames;var N=Object.prototype.hasOwnProperty;var T=(t,e)=>{for(var o in e)m(t,o,{get:e[o],enumerable:!0})},c=(t,e,o,a)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of p(e))!N.call(t,r)&&r!==o&&m(t,r,{get:()=>e[r],enumerable:!(a=i(e,r))||a.enumerable});return t};var f=t=>c(m({},"__esModule",{value:!0}),t);var C={};T(C,{trustedNameModuleFactory:()=>x});module.exports=f(C);var u=require("inversify"),n=require("../../trusted-name/data/HttpTrustedNameDataSource"),d=require("../../trusted-name/di/trustedNameTypes"),s=require("../../trusted-name/domain/TrustedNameContextLoader");const x=()=>new u.ContainerModule((t,e,o,a)=>{t(d.trustedNameTypes.TrustedNameDataSource).to(n.HttpTrustedNameDataSource),t(d.trustedNameTypes.TrustedNameContextLoader).to(s.TrustedNameContextLoader)});0&&(module.exports={trustedNameModuleFactory});
2
+ //# sourceMappingURL=trustedNameModuleFactory.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../../../src/trusted-name/di/trustedNameModuleFactory.ts"],
4
+ "sourcesContent": ["import { ContainerModule } from \"inversify\";\n\nimport { HttpTrustedNameDataSource } from \"@/trusted-name/data/HttpTrustedNameDataSource\";\nimport { trustedNameTypes } from \"@/trusted-name/di/trustedNameTypes\";\nimport { TrustedNameContextLoader } from \"@/trusted-name/domain/TrustedNameContextLoader\";\n\nexport const trustedNameModuleFactory = () =>\n new ContainerModule((bind, _unbind, _isBound, _rebind) => {\n bind(trustedNameTypes.TrustedNameDataSource).to(HttpTrustedNameDataSource);\n bind(trustedNameTypes.TrustedNameContextLoader).to(\n TrustedNameContextLoader,\n );\n });\n"],
5
+ "mappings": "yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,8BAAAE,IAAA,eAAAC,EAAAH,GAAA,IAAAI,EAAgC,qBAEhCC,EAA0C,yDAC1CC,EAAiC,8CACjCC,EAAyC,0DAElC,MAAML,EAA2B,IACtC,IAAI,kBAAgB,CAACM,EAAMC,EAASC,EAAUC,IAAY,CACxDH,EAAK,mBAAiB,qBAAqB,EAAE,GAAG,2BAAyB,EACzEA,EAAK,mBAAiB,wBAAwB,EAAE,GAC9C,0BACF,CACF,CAAC",
6
+ "names": ["trustedNameModuleFactory_exports", "__export", "trustedNameModuleFactory", "__toCommonJS", "import_inversify", "import_HttpTrustedNameDataSource", "import_trustedNameTypes", "import_TrustedNameContextLoader", "bind", "_unbind", "_isBound", "_rebind"]
7
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";var a=Object.defineProperty;var m=Object.getOwnPropertyDescriptor;var s=Object.getOwnPropertyNames;var u=Object.prototype.hasOwnProperty;var N=(t,e)=>{for(var r in e)a(t,r,{get:e[r],enumerable:!0})},T=(t,e,r,d)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of s(e))!u.call(t,o)&&o!==r&&a(t,o,{get:()=>e[o],enumerable:!(d=m(e,o))||d.enumerable});return t};var S=t=>T(a({},"__esModule",{value:!0}),t);var n={};N(n,{trustedNameTypes:()=>c});module.exports=S(n);const c={TrustedNameDataSource:Symbol.for("TrustedNameDataSource"),TrustedNameContextLoader:Symbol.for("TrustedNameContextLoader")};0&&(module.exports={trustedNameTypes});
2
+ //# sourceMappingURL=trustedNameTypes.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../../../src/trusted-name/di/trustedNameTypes.ts"],
4
+ "sourcesContent": ["export const trustedNameTypes = {\n TrustedNameDataSource: Symbol.for(\"TrustedNameDataSource\"),\n TrustedNameContextLoader: Symbol.for(\"TrustedNameContextLoader\"),\n};\n"],
5
+ "mappings": "yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,sBAAAE,IAAA,eAAAC,EAAAH,GAAO,MAAME,EAAmB,CAC9B,sBAAuB,OAAO,IAAI,uBAAuB,EACzD,yBAA0B,OAAO,IAAI,0BAA0B,CACjE",
6
+ "names": ["trustedNameTypes_exports", "__export", "trustedNameTypes", "__toCommonJS"]
7
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";var l=Object.defineProperty;var m=Object.getOwnPropertyDescriptor;var g=Object.getOwnPropertyNames;var C=Object.prototype.hasOwnProperty;var S=(o,t)=>{for(var e in t)l(o,e,{get:t[e],enumerable:!0})},T=(o,t,e,a)=>{if(t&&typeof t=="object"||typeof t=="function")for(let r of g(t))!C.call(o,r)&&r!==e&&l(o,r,{get:()=>t[r],enumerable:!(a=m(t,r))||a.enumerable});return o};var R=o=>T(l({},"__esModule",{value:!0}),o),p=(o,t,e,a)=>{for(var r=a>1?void 0:a?m(t,e):t,n=o.length-1,d;n>=0;n--)(d=o[n])&&(r=(a?d(t,e,r):d(r))||r);return a&&r&&l(t,e,r),r},u=(o,t)=>(e,a)=>t(e,a,o);var h={};S(h,{TrustedNameContextLoader:()=>s});module.exports=R(h);var c=require("inversify"),i=require("../../shared/model/ClearSignContext"),y=require("../../trusted-name/di/trustedNameTypes");let s=class{_dataSource;constructor(t){this._dataSource=t}async load(t){const{domain:e,challenge:a}=t;return e?this.isDomainValid(e)?[(await this._dataSource.getDomainNamePayload({domain:e,challenge:a})).caseOf({Left:n=>({type:i.ClearSignContextType.ERROR,error:n}),Right:n=>({type:i.ClearSignContextType.TRUSTED_NAME,payload:n})})]:[{type:i.ClearSignContextType.ERROR,error:new Error("[ContextModule] TrustedNameLoader: invalid domain")}]:[]}async loadField(t){return t.type!==i.ClearSignContextType.TRUSTED_NAME?null:(await this._dataSource.getTrustedNamePayload({address:t.address,challenge:t.challenge,types:t.types,sources:t.sources})).caseOf({Left:a=>({type:i.ClearSignContextType.ERROR,error:a}),Right:a=>({type:i.ClearSignContextType.TRUSTED_NAME,payload:a})})}isDomainValid(t){const e=t.length>0&&Number(t.length)<30,a=new RegExp("^[a-zA-Z0-9\\-\\_\\.]+$").test(t);return e&&a}};s=p([(0,c.injectable)(),u(0,(0,c.inject)(y.trustedNameTypes.TrustedNameDataSource))],s);0&&(module.exports={TrustedNameContextLoader});
2
+ //# sourceMappingURL=TrustedNameContextLoader.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../../../src/trusted-name/domain/TrustedNameContextLoader.ts"],
4
+ "sourcesContent": ["import { inject, injectable } from \"inversify\";\n\nimport { ContextLoader } from \"@/shared/domain/ContextLoader\";\nimport {\n ClearSignContext,\n ClearSignContextType,\n} from \"@/shared/model/ClearSignContext\";\nimport {\n TransactionContext,\n TransactionFieldContext,\n} from \"@/shared/model/TransactionContext\";\nimport type { TrustedNameDataSource } from \"@/trusted-name/data/TrustedNameDataSource\";\nimport { trustedNameTypes } from \"@/trusted-name/di/trustedNameTypes\";\n\n@injectable()\nexport class TrustedNameContextLoader implements ContextLoader {\n private _dataSource: TrustedNameDataSource;\n\n constructor(\n @inject(trustedNameTypes.TrustedNameDataSource)\n dataSource: TrustedNameDataSource,\n ) {\n this._dataSource = dataSource;\n }\n\n async load(\n transactionContext: TransactionContext,\n ): Promise<ClearSignContext[]> {\n const { domain, challenge } = transactionContext;\n\n if (!domain) {\n return [];\n }\n\n if (!this.isDomainValid(domain)) {\n return [\n {\n type: ClearSignContextType.ERROR,\n error: new Error(\"[ContextModule] TrustedNameLoader: invalid domain\"),\n },\n ];\n }\n\n const payload = await this._dataSource.getDomainNamePayload({\n domain: domain,\n challenge: challenge,\n });\n\n return [\n payload.caseOf({\n Left: (error): ClearSignContext => ({\n type: ClearSignContextType.ERROR,\n error: error,\n }),\n Right: (value): ClearSignContext => ({\n type: ClearSignContextType.TRUSTED_NAME,\n payload: value,\n }),\n }),\n ];\n }\n\n async loadField(\n field: TransactionFieldContext,\n ): Promise<ClearSignContext | null> {\n if (field.type !== ClearSignContextType.TRUSTED_NAME) {\n return null;\n }\n const payload = await this._dataSource.getTrustedNamePayload({\n address: field.address,\n challenge: field.challenge,\n types: field.types,\n sources: field.sources,\n });\n return payload.caseOf({\n Left: (error): ClearSignContext => ({\n type: ClearSignContextType.ERROR,\n error,\n }),\n Right: (value): ClearSignContext => ({\n type: ClearSignContextType.TRUSTED_NAME,\n payload: value,\n }),\n });\n }\n\n private isDomainValid(domain: string) {\n const lengthIsValid = domain.length > 0 && Number(domain.length) < 30;\n const containsOnlyValidChars = new RegExp(\"^[a-zA-Z0-9\\\\-\\\\_\\\\.]+$\").test(\n domain,\n );\n\n return lengthIsValid && containsOnlyValidChars;\n }\n}\n"],
5
+ "mappings": "okBAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,8BAAAE,IAAA,eAAAC,EAAAH,GAAA,IAAAI,EAAmC,qBAGnCC,EAGO,2CAMPC,EAAiC,8CAG1B,IAAMC,EAAN,KAAwD,CACrD,YAER,YAEEC,EACA,CACA,KAAK,YAAcA,CACrB,CAEA,MAAM,KACJC,EAC6B,CAC7B,KAAM,CAAE,OAAAC,EAAQ,UAAAC,CAAU,EAAIF,EAE9B,OAAKC,EAIA,KAAK,cAAcA,CAAM,EAcvB,EALS,MAAM,KAAK,YAAY,qBAAqB,CAC1D,OAAQA,EACR,UAAWC,CACb,CAAC,GAGS,OAAO,CACb,KAAOC,IAA6B,CAClC,KAAM,uBAAqB,MAC3B,MAAOA,CACT,GACA,MAAQC,IAA6B,CACnC,KAAM,uBAAqB,aAC3B,QAASA,CACX,EACF,CAAC,CACH,EAxBS,CACL,CACE,KAAM,uBAAqB,MAC3B,MAAO,IAAI,MAAM,mDAAmD,CACtE,CACF,EATO,CAAC,CA6BZ,CAEA,MAAM,UACJC,EACkC,CAClC,OAAIA,EAAM,OAAS,uBAAqB,aAC/B,MAEO,MAAM,KAAK,YAAY,sBAAsB,CAC3D,QAASA,EAAM,QACf,UAAWA,EAAM,UACjB,MAAOA,EAAM,MACb,QAASA,EAAM,OACjB,CAAC,GACc,OAAO,CACpB,KAAOF,IAA6B,CAClC,KAAM,uBAAqB,MAC3B,MAAAA,CACF,GACA,MAAQC,IAA6B,CACnC,KAAM,uBAAqB,aAC3B,QAASA,CACX,EACF,CAAC,CACH,CAEQ,cAAcH,EAAgB,CACpC,MAAMK,EAAgBL,EAAO,OAAS,GAAK,OAAOA,EAAO,MAAM,EAAI,GAC7DM,EAAyB,IAAI,OAAO,yBAAyB,EAAE,KACnEN,CACF,EAEA,OAAOK,GAAiBC,CAC1B,CACF,EA/EaT,EAANU,EAAA,IADN,cAAW,EAKPC,EAAA,eAAO,mBAAiB,qBAAqB,IAJrCX",
6
+ "names": ["TrustedNameContextLoader_exports", "__export", "TrustedNameContextLoader", "__toCommonJS", "import_inversify", "import_ClearSignContext", "import_trustedNameTypes", "TrustedNameContextLoader", "dataSource", "transactionContext", "domain", "challenge", "error", "value", "field", "lengthIsValid", "containsOnlyValidChars", "__decorateClass", "__decorateParam"]
7
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";var l=require("purify-ts"),o=require("../../shared/model/ClearSignContext"),n=require("../../trusted-name/domain/TrustedNameContextLoader");describe("TrustedNameContextLoader",()=>{const t={getDomainNamePayload:jest.fn(),getTrustedNamePayload:jest.fn()};beforeEach(()=>{jest.restoreAllMocks(),jest.spyOn(t,"getDomainNamePayload").mockResolvedValue((0,l.Right)("payload"))}),describe("load function",()=>{it("should return an empty array when no domain or registry",()=>{const e={},r=new n.TrustedNameContextLoader(t),a=()=>r.load(e);expect(a()).resolves.toEqual([])}),it("should return an error when domain > max length",async()=>{const e={domain:"maxlength-maxlength-maxlength-maxlength-maxlength-maxlength"},a=await new n.TrustedNameContextLoader(t).load(e);expect(a).toEqual([{type:o.ClearSignContextType.ERROR,error:new Error("[ContextModule] TrustedNameLoader: invalid domain")}])}),it("should return an error when domain is not valid",async()=>{const e={domain:"hello\u{1F44B}"},a=await new n.TrustedNameContextLoader(t).load(e);expect(a).toEqual([{type:o.ClearSignContextType.ERROR,error:new Error("[ContextModule] TrustedNameLoader: invalid domain")}])}),it("should return a payload",async()=>{const e={domain:"hello.eth",challenge:"challenge"},a=await new n.TrustedNameContextLoader(t).load(e);expect(a).toEqual([{type:o.ClearSignContextType.TRUSTED_NAME,payload:"payload"}])}),it("should return an error when unable to fetch the datasource",async()=>{const e={domain:"hello.eth",challenge:"challenge"};jest.spyOn(t,"getDomainNamePayload").mockResolvedValue((0,l.Left)(new Error("error")));const a=await new n.TrustedNameContextLoader(t).load(e);expect(a).toEqual([{type:o.ClearSignContextType.ERROR,error:new Error("error")}])})}),describe("loadField function",()=>{it("should return an error when field type if not supported",async()=>{const e={type:o.ClearSignContextType.TOKEN,chainId:7,address:"0x1234"},a=await new n.TrustedNameContextLoader(t).loadField(e);expect(a).toEqual(null)}),it("should return a payload",async()=>{const e={type:o.ClearSignContextType.TRUSTED_NAME,chainId:7,address:"0x1234",challenge:"17",sources:["ens"],types:["eoa"]};jest.spyOn(t,"getTrustedNamePayload").mockResolvedValue((0,l.Right)("payload"));const a=await new n.TrustedNameContextLoader(t).loadField(e);expect(a).toEqual({type:o.ClearSignContextType.TRUSTED_NAME,payload:"payload"})}),it("should return an error when unable to fetch the datasource",async()=>{const e={type:o.ClearSignContextType.TRUSTED_NAME,chainId:7,address:"0x1234",challenge:"17",sources:["ens"],types:["eoa"]};jest.spyOn(t,"getTrustedNamePayload").mockResolvedValue((0,l.Left)(new Error("error")));const a=await new n.TrustedNameContextLoader(t).loadField(e);expect(a).toEqual({type:o.ClearSignContextType.ERROR,error:new Error("error")})})})});
2
+ //# sourceMappingURL=TrustedNameContextLoader.test.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../../../src/trusted-name/domain/TrustedNameContextLoader.test.ts"],
4
+ "sourcesContent": ["import { Left, Right } from \"purify-ts\";\n\nimport { ClearSignContextType } from \"@/shared/model/ClearSignContext\";\nimport {\n type TransactionContext,\n type TransactionFieldContext,\n} from \"@/shared/model/TransactionContext\";\nimport { type TrustedNameDataSource } from \"@/trusted-name/data/TrustedNameDataSource\";\nimport { TrustedNameContextLoader } from \"@/trusted-name/domain/TrustedNameContextLoader\";\n\ndescribe(\"TrustedNameContextLoader\", () => {\n const mockTrustedNameDataSource: TrustedNameDataSource = {\n getDomainNamePayload: jest.fn(),\n getTrustedNamePayload: jest.fn(),\n };\n\n beforeEach(() => {\n jest.restoreAllMocks();\n jest\n .spyOn(mockTrustedNameDataSource, \"getDomainNamePayload\")\n .mockResolvedValue(Right(\"payload\"));\n });\n\n describe(\"load function\", () => {\n it(\"should return an empty array when no domain or registry\", () => {\n const transaction = {} as TransactionContext;\n const loader = new TrustedNameContextLoader(mockTrustedNameDataSource);\n const promise = () => loader.load(transaction);\n\n expect(promise()).resolves.toEqual([]);\n });\n\n it(\"should return an error when domain > max length\", async () => {\n const transaction = {\n domain: \"maxlength-maxlength-maxlength-maxlength-maxlength-maxlength\",\n } as TransactionContext;\n\n const loader = new TrustedNameContextLoader(mockTrustedNameDataSource);\n const result = await loader.load(transaction);\n\n expect(result).toEqual([\n {\n type: ClearSignContextType.ERROR,\n error: new Error(\"[ContextModule] TrustedNameLoader: invalid domain\"),\n },\n ]);\n });\n\n it(\"should return an error when domain is not valid\", async () => {\n const transaction = {\n domain: \"hello\uD83D\uDC4B\",\n } as TransactionContext;\n\n const loader = new TrustedNameContextLoader(mockTrustedNameDataSource);\n const result = await loader.load(transaction);\n\n expect(result).toEqual([\n {\n type: ClearSignContextType.ERROR,\n error: new Error(\"[ContextModule] TrustedNameLoader: invalid domain\"),\n },\n ]);\n });\n\n it(\"should return a payload\", async () => {\n const transaction = {\n domain: \"hello.eth\",\n challenge: \"challenge\",\n } as TransactionContext;\n\n const loader = new TrustedNameContextLoader(mockTrustedNameDataSource);\n const result = await loader.load(transaction);\n\n expect(result).toEqual([\n {\n type: ClearSignContextType.TRUSTED_NAME,\n payload: \"payload\",\n },\n ]);\n });\n\n it(\"should return an error when unable to fetch the datasource\", async () => {\n // GIVEN\n const transaction = {\n domain: \"hello.eth\",\n challenge: \"challenge\",\n } as TransactionContext;\n\n // WHEN\n jest\n .spyOn(mockTrustedNameDataSource, \"getDomainNamePayload\")\n .mockResolvedValue(Left(new Error(\"error\")));\n const loader = new TrustedNameContextLoader(mockTrustedNameDataSource);\n const result = await loader.load(transaction);\n\n // THEN\n expect(result).toEqual([\n { type: ClearSignContextType.ERROR, error: new Error(\"error\") },\n ]);\n });\n });\n\n describe(\"loadField function\", () => {\n it(\"should return an error when field type if not supported\", async () => {\n const field: TransactionFieldContext = {\n type: ClearSignContextType.TOKEN,\n chainId: 7,\n address: \"0x1234\",\n };\n\n const loader = new TrustedNameContextLoader(mockTrustedNameDataSource);\n const result = await loader.loadField(field);\n\n expect(result).toEqual(null);\n });\n\n it(\"should return a payload\", async () => {\n // GIVEN\n const field: TransactionFieldContext = {\n type: ClearSignContextType.TRUSTED_NAME,\n chainId: 7,\n address: \"0x1234\",\n challenge: \"17\",\n sources: [\"ens\"],\n types: [\"eoa\"],\n };\n\n // WHEN\n jest\n .spyOn(mockTrustedNameDataSource, \"getTrustedNamePayload\")\n .mockResolvedValue(Right(\"payload\"));\n const loader = new TrustedNameContextLoader(mockTrustedNameDataSource);\n const result = await loader.loadField(field);\n\n // THEN\n expect(result).toEqual({\n type: ClearSignContextType.TRUSTED_NAME,\n payload: \"payload\",\n });\n });\n\n it(\"should return an error when unable to fetch the datasource\", async () => {\n // GIVEN\n const field: TransactionFieldContext = {\n type: ClearSignContextType.TRUSTED_NAME,\n chainId: 7,\n address: \"0x1234\",\n challenge: \"17\",\n sources: [\"ens\"],\n types: [\"eoa\"],\n };\n\n // WHEN\n jest\n .spyOn(mockTrustedNameDataSource, \"getTrustedNamePayload\")\n .mockResolvedValue(Left(new Error(\"error\")));\n const loader = new TrustedNameContextLoader(mockTrustedNameDataSource);\n const result = await loader.loadField(field);\n\n // THEN\n expect(result).toEqual({\n type: ClearSignContextType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AAM,OAAO,CAAC,CAAC,EAE7C,MAAMI,EAAS,MADA,IAAI,2BAAyBJ,CAAyB,EACzC,UAAUK,CAAK,EAG3C,OAAOD,CAAM,EAAE,QAAQ,CACrB,KAAM,uBAAqB,MAC3B,MAAO,IAAI,MAAM,OAAO,CAC1B,CAAC,CACH,CAAC,CACH,CAAC,CACH,CAAC",
6
+ "names": ["import_purify_ts", "import_ClearSignContext", "import_TrustedNameContextLoader", "mockTrustedNameDataSource", "transaction", "loader", "promise", "result", "field"]
7
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";var i=Object.defineProperty;var o=Object.getOwnPropertyDescriptor;var p=Object.getOwnPropertyNames;var a=Object.prototype.hasOwnProperty;var c=(e,t,s,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let n of p(t))!a.call(e,n)&&n!==s&&i(e,n,{get:()=>t[n],enumerable:!(r=o(t,n))||r.enumerable});return e};var d=e=>c(i({},"__esModule",{value:!0}),e);var u={};module.exports=d(u);
2
+ //# sourceMappingURL=FiltersDto.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../../../src/typed-data/data/FiltersDto.ts"],
4
+ "sourcesContent": ["export type InstructionSignatures =\n | {\n prod: string;\n test?: string;\n }\n | {\n prod?: string;\n test: string;\n };\n\nexport type InstructionFieldV1 = {\n display_name: string;\n field_mappers_count?: never;\n field_path: string;\n signatures: InstructionSignatures;\n type: \"field\" | \"message\";\n format?: never;\n};\n\nexport type InstructionFieldV2 = {\n display_name: string;\n field_mappers_count?: never;\n field_path: string;\n descriptor: string;\n signatures: InstructionSignatures;\n format: \"raw\" | \"datetime\";\n coin_ref?: never;\n type: \"field\" | \"message\";\n};\n\nexport type InstructionFieldV2WithCoinRef = {\n display_name: string;\n field_mappers_count?: never;\n format: \"token\" | \"amount\";\n field_path: string;\n coin_ref: number;\n descriptor: string;\n signatures: InstructionSignatures;\n type: \"field\";\n};\n\nexport type InstructionContractInfo = {\n display_name: string;\n field_mappers_count: number;\n field_path?: never;\n descriptor: string;\n signatures: InstructionSignatures;\n type: \"message\";\n};\n\nexport type InstructionField =\n | InstructionFieldV1\n | InstructionFieldV2\n | InstructionFieldV2WithCoinRef\n | InstructionContractInfo;\n\nexport type FiltersDto = {\n descriptors_eip712: {\n [contractAddress: string]: {\n [schemaHash: string]: {\n schema: Record<string, { name: string; type: string }[]>;\n instructions: InstructionField[];\n };\n };\n };\n};\n"],
5
+ "mappings": "+WAAA,IAAAA,EAAA,kBAAAC,EAAAD",
6
+ "names": ["FiltersDto_exports", "__toCommonJS"]
7
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";var x=Object.create;var f=Object.defineProperty;var g=Object.getOwnPropertyDescriptor;var T=Object.getOwnPropertyNames;var b=Object.getPrototypeOf,$=Object.prototype.hasOwnProperty;var V=(o,e)=>{for(var t in e)f(o,t,{get:e[t],enumerable:!0})},h=(o,e,t,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of T(e))!$.call(o,i)&&i!==t&&f(o,i,{get:()=>e[i],enumerable:!(r=g(e,i))||r.enumerable});return o};var y=(o,e,t)=>(t=o!=null?x(b(o)):{},h(e||!o||!o.__esModule?f(t,"default",{value:o,enumerable:!0}):t,o)),j=o=>h(f({},"__esModule",{value:!0}),o),C=(o,e,t,r)=>{for(var i=r>1?void 0:r?g(e,t):e,a=o.length-1,p;a>=0;a--)(p=o[a])&&(i=(r?p(e,t,i):p(i))||i);return r&&i&&f(e,t,i),i},_=(o,e)=>(t,r)=>e(t,r,o);var E={};V(E,{HttpTypedDataDataSource:()=>c});module.exports=j(E);var F=y(require("axios")),M=y(require("crypto-js/sha224")),m=require("inversify"),s=require("purify-ts"),D=require("../../config/di/configTypes"),I=y(require("../../../package.json"));let c=class{constructor(e){this.config=e}async getTypedDataFilters({chainId:e,address:t,schema:r,version:i}){let a;try{const p=await F.default.request({method:"GET",url:`${this.config.cal.url}/dapps`,params:{contracts:t,chain_id:e,output:"descriptors_eip712",descriptors_eip712_version:i,descriptors_eip712:"<set>",ref:`branch:${this.config.cal.branch}`},headers:{"X-Ledger-Client-Version":`context-module/${I.default.version}`}}),l=(0,M.default)(JSON.stringify(this.sortTypes(r)).replace(" ","")).toString();t=t.toLowerCase();const d=p.data?.[0]?.descriptors_eip712?.[t]?.[l];if(!d)return(0,s.Left)(new Error(`[ContextModule] HttpTypedDataDataSource: no typed data filters for address ${t} on chain ${e} for schema ${l}`));if(!d.schema||!Array.isArray(d.instructions))return(0,s.Left)(new Error(`[ContextModule] HttpTypedDataDataSource: no message info for address ${t} on chain ${e} for schema ${l}`));const u=[];for(const n of d.instructions)if(this.isInstructionContractInfo(n,this.config.cal.mode))a={displayName:n.display_name,signature:n.signatures[this.config.cal.mode],filtersCount:n.field_mappers_count};else if(i==="v1"&&this.isInstructionFieldV1(n,this.config.cal.mode))u.push({type:"raw",displayName:n.display_name,path:n.field_path,signature:n.signatures[this.config.cal.mode]});else if(this.isInstructionFieldV2(n,this.config.cal.mode))u.push({type:n.format,displayName:n.display_name,path:n.field_path,signature:n.signatures[this.config.cal.mode]});else if(this.isInstructionFieldV2WithCoinRef(n,this.config.cal.mode))u.push({type:n.format,displayName:n.display_name,path:n.field_path,signature:n.signatures[this.config.cal.mode],tokenIndex:n.coin_ref});else return(0,s.Left)(new Error(`[ContextModule] HttpTypedDataDataSource: invalid typed data field for address ${t} on chain ${e} for schema ${l}`));return a?(0,s.Right)({messageInfo:a,filters:u}):(0,s.Left)(new Error(`[ContextModule] HttpTypedDataDataSource: no message info for address ${t} on chain ${e} for schema ${l}`))}catch{return(0,s.Left)(new Error("[ContextModule] HttpTypedDataDataSource: Failed to fetch typed data informations"))}}isInstructionFieldV1(e,t){return typeof e=="object"&&typeof e.display_name=="string"&&typeof e.field_path=="string"&&typeof e.signatures=="object"&&typeof e.signatures[t]=="string"}isInstructionFieldV2(e,t){return typeof e=="object"&&typeof e.display_name=="string"&&typeof e.field_path=="string"&&typeof e.signatures=="object"&&typeof e.signatures[t]=="string"&&typeof e.format=="string"&&["raw","datetime"].includes(e.format)&&e.coin_ref===void 0}isInstructionFieldV2WithCoinRef(e,t){return typeof e=="object"&&typeof e.display_name=="string"&&typeof e.field_path=="string"&&typeof e.signatures=="object"&&typeof e.signatures[t]=="string"&&typeof e.format=="string"&&["token","amount"].includes(e.format)&&typeof e.coin_ref=="number"}isInstructionContractInfo(e,t){return typeof e=="object"&&typeof e.display_name=="string"&&typeof e.field_mappers_count=="number"&&typeof e.signatures=="object"&&typeof e.signatures[t]=="string"&&e.field_path===void 0}sortTypes(e){return Object.fromEntries(Object.entries(e).sort(([t],[r])=>t.localeCompare(r)).map(([t,r])=>[t,r.map(i=>({name:i.name,type:i.type}))]))}};c=C([(0,m.injectable)(),_(0,(0,m.inject)(D.configTypes.Config))],c);0&&(module.exports={HttpTypedDataDataSource});
2
+ //# sourceMappingURL=HttpTypedDataDataSource.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../../../src/typed-data/data/HttpTypedDataDataSource.ts"],
4
+ "sourcesContent": ["import axios from \"axios\";\nimport SHA224 from \"crypto-js/sha224\";\nimport { inject, injectable } from \"inversify\";\nimport { Either, Left, Right } from \"purify-ts\";\n\nimport { configTypes } from \"@/config/di/configTypes\";\nimport type {\n ContextModuleCalMode,\n ContextModuleConfig,\n} from \"@/config/model/ContextModuleConfig\";\nimport type {\n TypedDataFilter,\n TypedDataMessageInfo,\n} from \"@/shared/model/TypedDataClearSignContext\";\nimport type { TypedDataSchema } from \"@/shared/model/TypedDataContext\";\nimport PACKAGE from \"@root/package.json\";\n\nimport type {\n FiltersDto,\n InstructionContractInfo,\n InstructionField,\n InstructionFieldV1,\n InstructionFieldV2,\n InstructionFieldV2WithCoinRef,\n} from \"./FiltersDto\";\nimport {\n GetTypedDataFiltersParams,\n GetTypedDataFiltersResult,\n TypedDataDataSource,\n} from \"./TypedDataDataSource\";\n\n@injectable()\nexport class HttpTypedDataDataSource implements TypedDataDataSource {\n constructor(\n @inject(configTypes.Config) private readonly config: ContextModuleConfig,\n ) {}\n\n public async getTypedDataFilters({\n chainId,\n address,\n schema,\n version,\n }: GetTypedDataFiltersParams): Promise<\n Either<Error, GetTypedDataFiltersResult>\n > {\n let messageInfo: TypedDataMessageInfo | undefined = undefined;\n\n try {\n const response = await axios.request<FiltersDto[]>({\n method: \"GET\",\n url: `${this.config.cal.url}/dapps`,\n params: {\n contracts: address,\n chain_id: chainId,\n output: \"descriptors_eip712\",\n descriptors_eip712_version: version,\n descriptors_eip712: \"<set>\",\n ref: `branch:${this.config.cal.branch}`,\n },\n headers: {\n \"X-Ledger-Client-Version\": `context-module/${PACKAGE.version}`,\n },\n });\n\n // Try to get the filters JSON descriptor, from address and schema hash\n const schemaHash = SHA224(\n JSON.stringify(this.sortTypes(schema)).replace(\" \", \"\"),\n ).toString();\n address = address.toLowerCase();\n const filtersJson =\n response.data?.[0]?.descriptors_eip712?.[address]?.[schemaHash];\n if (!filtersJson) {\n return Left(\n new Error(\n `[ContextModule] HttpTypedDataDataSource: no typed data filters for address ${address} on chain ${chainId} for schema ${schemaHash}`,\n ),\n );\n }\n\n // Parse the message type, if available\n if (!filtersJson.schema || !Array.isArray(filtersJson.instructions)) {\n return Left(\n new Error(\n `[ContextModule] HttpTypedDataDataSource: no message info for address ${address} on chain ${chainId} for schema ${schemaHash}`,\n ),\n );\n }\n\n // Parse all the filters\n const filters: TypedDataFilter[] = [];\n for (const field of filtersJson.instructions) {\n if (this.isInstructionContractInfo(field, this.config.cal.mode)) {\n messageInfo = {\n displayName: field.display_name,\n signature: field.signatures[this.config.cal.mode],\n filtersCount: field.field_mappers_count,\n };\n } else if (\n version === \"v1\" &&\n this.isInstructionFieldV1(field, this.config.cal.mode)\n ) {\n filters.push({\n type: \"raw\",\n displayName: field.display_name,\n path: field.field_path,\n signature: field.signatures[this.config.cal.mode],\n });\n } else if (this.isInstructionFieldV2(field, this.config.cal.mode)) {\n filters.push({\n type: field.format,\n displayName: field.display_name,\n path: field.field_path,\n signature: field.signatures[this.config.cal.mode],\n });\n } else if (\n this.isInstructionFieldV2WithCoinRef(field, this.config.cal.mode)\n ) {\n filters.push({\n type: field.format,\n displayName: field.display_name,\n path: field.field_path,\n signature: field.signatures[this.config.cal.mode],\n tokenIndex: field.coin_ref,\n });\n } else {\n return Left(\n new Error(\n `[ContextModule] HttpTypedDataDataSource: invalid typed data field for address ${address} on chain ${chainId} for schema ${schemaHash}`,\n ),\n );\n }\n }\n\n if (!messageInfo) {\n return Left(\n new Error(\n `[ContextModule] HttpTypedDataDataSource: no message info for address ${address} on chain ${chainId} for schema ${schemaHash}`,\n ),\n );\n }\n\n return Right({ messageInfo, filters });\n } catch (_error) {\n return Left(\n new Error(\n \"[ContextModule] HttpTypedDataDataSource: Failed to fetch typed data informations\",\n ),\n );\n }\n }\n\n private isInstructionFieldV1(\n data: InstructionField,\n mode: ContextModuleCalMode,\n ): data is InstructionFieldV1 & {\n signatures: { [key in ContextModuleCalMode]: string };\n } {\n // NOTE: Currently the backend return the same structure for V1 and V2,\n // so we can't distinguish them here, but we can still check the required fields\n return (\n typeof data === \"object\" &&\n typeof data.display_name === \"string\" &&\n typeof data.field_path === \"string\" &&\n typeof data.signatures === \"object\" &&\n typeof data.signatures[mode] === \"string\"\n );\n }\n\n private isInstructionFieldV2(\n data: InstructionField,\n mode: ContextModuleCalMode,\n ): data is InstructionFieldV2 & {\n signatures: { [key in ContextModuleCalMode]: string };\n } {\n return (\n typeof data === \"object\" &&\n typeof data.display_name === \"string\" &&\n typeof data.field_path === \"string\" &&\n typeof data.signatures === \"object\" &&\n typeof data.signatures[mode] === \"string\" &&\n typeof data.format === \"string\" &&\n [\"raw\", \"datetime\"].includes(data.format) &&\n data.coin_ref === undefined\n );\n }\n\n private isInstructionFieldV2WithCoinRef(\n data: InstructionField,\n mode: ContextModuleCalMode,\n ): data is InstructionFieldV2WithCoinRef & {\n signatures: { [key in ContextModuleCalMode]: string };\n } {\n return (\n typeof data === \"object\" &&\n typeof data.display_name === \"string\" &&\n typeof data.field_path === \"string\" &&\n typeof data.signatures === \"object\" &&\n typeof data.signatures[mode] === \"string\" &&\n typeof data.format === \"string\" &&\n [\"token\", \"amount\"].includes(data.format) &&\n typeof data.coin_ref === \"number\"\n );\n }\n\n private isInstructionContractInfo(\n data: InstructionField,\n mode: ContextModuleCalMode,\n ): data is InstructionContractInfo & {\n signatures: { [key in ContextModuleCalMode]: string };\n } {\n return (\n typeof data === \"object\" &&\n typeof data.display_name === \"string\" &&\n typeof data.field_mappers_count === \"number\" &&\n typeof data.signatures === \"object\" &&\n typeof data.signatures[mode] === \"string\" &&\n data.field_path === undefined\n );\n }\n\n private sortTypes(types: TypedDataSchema): TypedDataSchema {\n return Object.fromEntries(\n Object.entries(types)\n .sort(([aKey], [bKey]) => aKey.localeCompare(bKey))\n .map(([key, value]) => [\n key,\n value.map((v) => ({ name: v.name, type: v.type })),\n ]),\n );\n }\n}\n"],
5
+ "mappings": "qtBAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,6BAAAE,IAAA,eAAAC,EAAAH,GAAA,IAAAI,EAAkB,oBAClBC,EAAmB,+BACnBC,EAAmC,qBACnCC,EAAoC,qBAEpCC,EAA4B,mCAU5BC,EAAoB,iCAiBb,IAAMC,EAAN,KAA6D,CAClE,YAC+CC,EAC7C,CAD6C,YAAAA,CAC5C,CAEH,MAAa,oBAAoB,CAC/B,QAAAC,EACA,QAAAC,EACA,OAAAC,EACA,QAAAC,CACF,EAEE,CACA,IAAIC,EAEJ,GAAI,CACF,MAAMC,EAAW,MAAM,EAAAC,QAAM,QAAsB,CACjD,OAAQ,MACR,IAAK,GAAG,KAAK,OAAO,IAAI,GAAG,SAC3B,OAAQ,CACN,UAAWL,EACX,SAAUD,EACV,OAAQ,qBACR,2BAA4BG,EAC5B,mBAAoB,QACpB,IAAK,UAAU,KAAK,OAAO,IAAI,MAAM,EACvC,EACA,QAAS,CACP,0BAA2B,kBAAkB,EAAAI,QAAQ,OAAO,EAC9D,C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aAAe,MAExB,CAEQ,UAAUE,EAAyC,CACzD,OAAO,OAAO,YACZ,OAAO,QAAQA,CAAK,EACjB,KAAK,CAAC,CAACC,CAAI,EAAG,CAACC,CAAI,IAAMD,EAAK,cAAcC,CAAI,CAAC,EACjD,IAAI,CAAC,CAACC,EAAKC,CAAK,IAAM,CACrBD,EACAC,EAAM,IAAKC,IAAO,CAAE,KAAMA,EAAE,KAAM,KAAMA,EAAE,IAAK,EAAE,CACnD,CAAC,CACL,CACF,CACF,EAtMatB,EAANuB,EAAA,IADN,cAAW,EAGPC,EAAA,eAAO,cAAY,MAAM,IAFjBxB",
6
+ "names": ["HttpTypedDataDataSource_exports", "__export", "HttpTypedDataDataSource", "__toCommonJS", "import_axios", "import_sha224", "import_inversify", "import_purify_ts", "import_configTypes", "import_package", "HttpTypedDataDataSource", "config", "chainId", "address", "schema", "version", "messageInfo", "response", "axios", "PACKAGE", "schemaHash", "SHA224", "filtersJson", "filters", "field", "data", "mode", "types", "aKey", "bKey", "key", "value", "v", "__decorateClass", "__decorateParam"]
7
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";var l=Object.create;var r=Object.defineProperty;var u=Object.getOwnPropertyDescriptor;var m=Object.getOwnPropertyNames;var y=Object.getPrototypeOf,h=Object.prototype.hasOwnProperty;var x=(d,t)=>{for(var e in t)r(d,e,{get:t[e],enumerable:!0})},n=(d,t,e,a)=>{if(t&&typeof t=="object"||typeof t=="function")for(let c of m(t))!h.call(d,c)&&c!==e&&r(d,c,{get:()=>t[c],enumerable:!(a=u(t,c))||a.enumerable});return d};var o=(d,t,e)=>(e=d!=null?l(y(d)):{},n(t||!d||!d.__esModule?r(e,"default",{value:d,enumerable:!0}):e,d)),g=d=>n(r({},"__esModule",{value:!0}),d);var v={};x(v,{buildDescriptor:()=>f});module.exports=g(v);var s=o(require("axios")),b=require("purify-ts"),i=require("../../typed-data/data/HttpTypedDataDataSource"),p=o(require("../../../package.json"));jest.mock("axios");const f=d=>[{descriptors_eip712:{"0x000000000022d473030f116ddee9f6b43ac78ba3":{"4d593149e876e739220f3b5ede1b38a0213d76c4705b1547c4323df3":{schema:{DutchOutput:[{name:"token",type:"address"},{name:"startAmount",type:"uint256"},{name:"endAmount",type:"uint256"},{name:"recipient",type:"address"}],EIP712Domain:[{name:"name",type:"string"},{name:"chainId",type:"uint256"},{name:"verifyingContract",type:"address"}],ExclusiveDutchOrder:[{name:"info",type:"OrderInfo"},{name:"decayStartTime",type:"uint256"},{name:"decayEndTime",type:"uint256"},{name:"exclusiveFiller",type:"address"},{name:"exclusivityOverrideBps",type:"uint256"},{name:"inputToken",type:"address"},{name:"inputStartAmount",type:"uint256"},{name:"inputEndAmount",type:"uint256"},{name:"outputs",type:"DutchOutput[]"}],OrderInfo:[{name:"reactor",type:"address"},{name:"swapper",type:"address"},{name:"nonce",type:"uint256"},{name:"deadline",type:"uint256"},{name:"additionalValidationContract",type:"address"},{name:"additionalValidationData",type:"bytes"}],PermitWitnessTransferFrom:[{name:"permitted",type:"TokenPermissions"},{name:"spender",type:"address"},{name:"nonce",type:"uint256"},{name:"deadline",type:"uint256"},{name:"witness",type:"ExclusiveDutchOrder"}],TokenPermissions:[{name:"token",type:"address"},{name:"amount",type:"uint256"}]},instructions:d}}}}];describe("HttpTypedDataDataSource",()=>{let d;const t={PermitSingle:[{name:"details",type:"PermitDetails"},{name:"spender",type:"address"},{name:"sigDeadline",type:"uint256"}],PermitDetails:[{type:"address",name:"token"},{name:"amount",type:"uint160"},{name:"expiration",type:"uint48"},{name:"nonce",type:"uint48"}],EIP712Domain:[{name:"name",type:"string"},{name:"chainId",type:"uint256"},{name:"verifyingContract",type:"address"}]};beforeAll(()=>{const e={cal:{url:"https://crypto-assets-service.api.ledger.com/v1",mode:"prod"}};d=new i.HttpTypedDataDataSource(e),jest.clearAllMocks()}),it("should call axios with the ledger client version header",async()=>{const e=`context-module/${p.default.version}`,a=jest.fn(()=>Promise.resolve({data:[]}));jest.spyOn(s.default,"request").mockImplementation(a),await d.getTypedDataFilters({chainId:1,address:"0x00",version:"v2",schema:{}}),expect(a).toHaveBeenCalledWith(expect.objectContaining({headers:{"X-Ledger-Client-Version":e}}))}),it("should return V2 filters when axios response is correct",async()=>{const e=f([{display_name:"Permit2",field_mappers_count:4,descriptor:"b7000000000000a4b1000000000022d473030f116ddee9f6b43ac78ba34d593149e876e739220f3b5ede1b38a0213d76c4705b1547c4323df3045065726d697432",signatures:{prod:"304402201675b7d8507b40de5136c386815afdad8012cb8e3f0e0a126c758d6fbb3f6b0f0220595cbfeeab7591d0eebe40f0e4ea8ea53beeaf89ee50b7faf97f97bdf36abbce"},type:"message"},{display_name:"Amount allowance",format:"token",field_path:"details.token",coin_ref:0,descriptor:"48000000000000a4b1000000000022d473030f116ddee9f6b43ac78ba34d593149e876e739220f3b5ede1b38a0213d76c4705b1547c4323df364657461696c732e746f6b656e416d6f756e7420616c6c6f77616e6365",signatures:{prod:"30440220238723d4ddd47baf829d547802a2017476bf68e03d0b920fd46aa543de81d5b902206123218eae82c5f898454c45262e5b0b839dc9d84b2b0926fe14e8218b5b0d53"},type:"field"},{display_name:"Amount allowance",format:"amount",field_path:"details.amount",coin_ref:0,descriptor:"48000000000000a4b1000000000022d473030f116ddee9f6b43ac78ba34d593149e876e739220f3b5ede1b38a0213d76c4705b1547c4323df364657461696c732e616d6f756e74416d6f756e7420616c6c6f77616e6365",signatures:{prod:"30450221008f9e2f33b35872e63b2024a6d4938525c6e72364604da2d5e21b3d7fa44cac8a02207d4fe42c9d3994a322dae99adc2c56157435c177c51831103fdaf3cef12bb19f"},type:"field"},{display_name:"Approve to spender",format:"raw",field_path:"spender",descriptor:"48000000000000a4b1000000000022d473030f116ddee9f6b43ac78ba34d593149e876e739220f3b5ede1b38a0213d76c4705b1547c4323df37370656e646572417070726f766520746f207370656e646572",signatures:{prod:"3045022100dddb92141e3b3f21dafb60c8d5093e28b25a8dc4f926ed501b6d2021203f68bc02201abca405540e72b5b70120a428967b776edb8a88ebd9b1d7aa320c3df602027f"},type:"field"},{display_name:"Approval expire",format:"datetime",field_path:"details.expiration",descriptor:"48000000000000a4b1000000000022d473030f116ddee9f6b43ac78ba34d593149e876e739220f3b5ede1b38a0213d76c4705b1547c4323df364657461696c732e65787069726174696f6e417070726f76616c20657870697265",signatures:{prod:"3044022060a11c1b15d07e7172e2e68a4e4aa5cbd3b5af900907634b1bce58000eab9fb502201e40963d9e2b00948ce16d3817756329e11a81e8b14b762adff68db4b3a4b8ff"},type:"field"}]);jest.spyOn(s.default,"request").mockResolvedValue({data:e});const a=await d.getTypedDataFilters({chainId:1,address:"0x000000000022D473030F116DDEE9F6B43AC78BA3",version:"v2",schema:t});expect(a).toEqual((0,b.Right)({messageInfo:{displayName:"Permit2",filtersCount:4,signature:"304402201675b7d8507b40de5136c386815afdad8012cb8e3f0e0a126c758d6fbb3f6b0f0220595cbfeeab7591d0eebe40f0e4ea8ea53beeaf89ee50b7faf97f97bdf36abbce"},filters:[{type:"token",displayName:"Amount allowance",path:"details.token",tokenIndex:0,signature:"30440220238723d4ddd47baf829d547802a2017476bf68e03d0b920fd46aa543de81d5b902206123218eae82c5f898454c45262e5b0b839dc9d84b2b0926fe14e8218b5b0d53"},{type:"amount",displayName:"Amount allowance",path:"details.amount",tokenIndex:0,signature:"30450221008f9e2f33b35872e63b2024a6d4938525c6e72364604da2d5e21b3d7fa44cac8a02207d4fe42c9d3994a322dae99adc2c56157435c177c51831103fdaf3cef12bb19f"},{type:"raw",displayName:"Approve to spender",path:"spender",signature:"3045022100dddb92141e3b3f21dafb60c8d5093e28b25a8dc4f926ed501b6d2021203f68bc02201abca405540e72b5b70120a428967b776edb8a88ebd9b1d7aa320c3df602027f"},{type:"datetime",displayName:"Approval expire",path:"details.expiration",signature:"3044022060a11c1b15d07e7172e2e68a4e4aa5cbd3b5af900907634b1bce58000eab9fb502201e40963d9e2b00948ce16d3817756329e11a81e8b14b762adff68db4b3a4b8ff"}]}))}),it("should return V1 filters when axios response is correct",async()=>{const e=f([{display_name:"Permit2",field_mappers_count:4,descriptor:"b7000000000000a4b1000000000022d473030f116ddee9f6b43ac78ba34d593149e876e739220f3b5ede1b38a0213d76c4705b1547c4323df3045065726d697432",signatures:{prod:"304402201675b7d8507b40de5136c386815afdad8012cb8e3f0e0a126c758d6fbb3f6b0f0220595cbfeeab7591d0eebe40f0e4ea8ea53beeaf89ee50b7faf97f97bdf36abbce"},type:"message"},{display_name:"Amount allowance",format:"token",field_path:"details.token",coin_ref:0,descriptor:"48000000000000a4b1000000000022d473030f116ddee9f6b43ac78ba34d593149e876e739220f3b5ede1b38a0213d76c4705b1547c4323df364657461696c732e746f6b656e416d6f756e7420616c6c6f77616e6365",signatures:{prod:"30440220238723d4ddd47baf829d547802a2017476bf68e03d0b920fd46aa543de81d5b902206123218eae82c5f898454c45262e5b0b839dc9d84b2b0926fe14e8218b5b0d53"},type:"field"},{display_name:"Amount allowance",format:"amount",field_path:"details.amount",coin_ref:0,descriptor:"48000000000000a4b1000000000022d473030f116ddee9f6b43ac78ba34d593149e876e739220f3b5ede1b38a0213d76c4705b1547c4323df364657461696c732e616d6f756e74416d6f756e7420616c6c6f77616e6365",signatures:{prod:"30450221008f9e2f33b35872e63b2024a6d4938525c6e72364604da2d5e21b3d7fa44cac8a02207d4fe42c9d3994a322dae99adc2c56157435c177c51831103fdaf3cef12bb19f"},type:"field"},{display_name:"Approve to spender",format:"raw",field_path:"spender",descriptor:"48000000000000a4b1000000000022d473030f116ddee9f6b43ac78ba34d593149e876e739220f3b5ede1b38a0213d76c4705b1547c4323df37370656e646572417070726f766520746f207370656e646572",signatures:{prod:"3045022100dddb92141e3b3f21dafb60c8d5093e28b25a8dc4f926ed501b6d2021203f68bc02201abca405540e72b5b70120a428967b776edb8a88ebd9b1d7aa320c3df602027f"},type:"field"},{display_name:"Approval expire",format:"datetime",field_path:"details.expiration",descriptor:"48000000000000a4b1000000000022d473030f116ddee9f6b43ac78ba34d593149e876e739220f3b5ede1b38a0213d76c4705b1547c4323df364657461696c732e65787069726174696f6e417070726f76616c20657870697265",signatures:{prod:"3044022060a11c1b15d07e7172e2e68a4e4aa5cbd3b5af900907634b1bce58000eab9fb502201e40963d9e2b00948ce16d3817756329e11a81e8b14b762adff68db4b3a4b8ff"},type:"field"}]);jest.spyOn(s.default,"request").mockResolvedValue({data:e});const a=await d.getTypedDataFilters({chainId:1,address:"0x000000000022d473030f116ddee9f6b43ac78ba3",version:"v1",schema:t});expect(a).toEqual((0,b.Right)({messageInfo:{displayName:"Permit2",filtersCount:4,signature:"304402201675b7d8507b40de5136c386815afdad8012cb8e3f0e0a126c758d6fbb3f6b0f0220595cbfeeab7591d0eebe40f0e4ea8ea53beeaf89ee50b7faf97f97bdf36abbce"},filters:[{type:"raw",displayName:"Amount allowance",path:"details.token",signature:"30440220238723d4ddd47baf829d547802a2017476bf68e03d0b920fd46aa543de81d5b902206123218eae82c5f898454c45262e5b0b839dc9d84b2b0926fe14e8218b5b0d53"},{type:"raw",displayName:"Amount allowance",path:"details.amount",signature:"30450221008f9e2f33b35872e63b2024a6d4938525c6e72364604da2d5e21b3d7fa44cac8a02207d4fe42c9d3994a322dae99adc2c56157435c177c51831103fdaf3cef12bb19f"},{type:"raw",displayName:"Approve to spender",path:"spender",signature:"3045022100dddb92141e3b3f21dafb60c8d5093e28b25a8dc4f926ed501b6d2021203f68bc02201abca405540e72b5b70120a428967b776edb8a88ebd9b1d7aa320c3df602027f"},{type:"raw",displayName:"Approval expire",path:"details.expiration",signature:"3044022060a11c1b15d07e7172e2e68a4e4aa5cbd3b5af900907634b1bce58000eab9fb502201e40963d9e2b00948ce16d3817756329e11a81e8b14b762adff68db4b3a4b8ff"}]}))}),it("should return an error when data is empty",async()=>{jest.spyOn(s.default,"request").mockResolvedValue({data:void 0});const e=await d.getTypedDataFilters({chainId:1,address:"0x000000000022d473030f116ddee9f6b43ac78ba3",version:"v1",schema:t});expect(e.isLeft()).toEqual(!0),expect(e.extract()).toEqual(new Error("[ContextModule] HttpTypedDataDataSource: no typed data filters for address 0x000000000022d473030f116ddee9f6b43ac78ba3 on chain 1 for schema 4d593149e876e739220f3b5ede1b38a0213d76c4705b1547c4323df3"))}),it("should return an error when schema is not found",async()=>{const e=f([]);jest.spyOn(s.default,"request").mockResolvedValue({data:e});const a=await d.getTypedDataFilters({chainId:1,address:"0x000000000022d473030f116ddee9f6b43ac78ba3",version:"v1",schema:t});expect(a.isLeft()).toEqual(!0),expect(a.extract()).toEqual(new Error("[ContextModule] HttpTypedDataDataSource: no message info for address 0x000000000022d473030f116ddee9f6b43ac78ba3 on chain 1 for schema 4d593149e876e739220f3b5ede1b38a0213d76c4705b1547c4323df3"))}),it("should return an error when schema is undefined",async()=>{const e=f(void 0);jest.spyOn(s.default,"request").mockResolvedValue({data:e});const a=await d.getTypedDataFilters({chainId:1,address:"0x000000000022d473030f116ddee9f6b43ac78ba3",version:"v1",schema:t});expect(a.isLeft()).toEqual(!0),expect(a.extract()).toEqual(new Error("[ContextModule] HttpTypedDataDataSource: no message info for address 0x000000000022d473030f116ddee9f6b43ac78ba3 on chain 1 for schema 4d593149e876e739220f3b5ede1b38a0213d76c4705b1547c4323df3"))}),it("should return an error if no message info is found",async()=>{const e=f([{display_name:"Amount allowance",format:"token",field_path:"details.token",coin_ref:0,descriptor:"48000000000000a4b1000000000022d473030f116ddee9f6b43ac78ba34d593149e876e739220f3b5ede1b38a0213d76c4705b1547c4323df364657461696c732e746f6b656e416d6f756e7420616c6c6f77616e6365",signatures:{prod:"30440220238723d4ddd47baf829d547802a2017476bf68e03d0b920fd46aa543de81d5b902206123218eae82c5f898454c45262e5b0b839dc9d84b2b0926fe14e8218b5b0d53"},type:"field"}]);jest.spyOn(s.default,"request").mockResolvedValue({data:e});const a=await d.getTypedDataFilters({chainId:1,address:"0x000000000022d473030f116ddee9f6b43ac78ba3",version:"v1",schema:t});expect(a.isLeft()).toEqual(!0),expect(a.extract()).toEqual(new Error("[ContextModule] HttpTypedDataDataSource: no message info for address 0x000000000022d473030f116ddee9f6b43ac78ba3 on chain 1 for schema 4d593149e876e739220f3b5ede1b38a0213d76c4705b1547c4323df3"))}),it("should return an error if message info display name is missing",async()=>{const e=f([{field_mappers_count:4,descriptor:"b7000000000000a4b1000000000022d473030f116ddee9f6b43ac78ba34d593149e876e739220f3b5ede1b38a0213d76c4705b1547c4323df3045065726d697432",signatures:{prod:"304402201675b7d8507b40de5136c386815afdad8012cb8e3f0e0a126c758d6fbb3f6b0f0220595cbfeeab7591d0eebe40f0e4ea8ea53beeaf89ee50b7faf97f97bdf36abbce"},type:"message"}]);jest.spyOn(s.default,"request").mockResolvedValue({data:e});const a=await d.getTypedDataFilters({chainId:1,address:"0x000000000022d473030f116ddee9f6b43ac78ba3",version:"v1",schema:t});expect(a.isLeft()).toEqual(!0),expect(a.extract()).toEqual(new Error("[ContextModule] HttpTypedDataDataSource: invalid typed data field for address 0x000000000022d473030f116ddee9f6b43ac78ba3 on chain 1 for schema 4d593149e876e739220f3b5ede1b38a0213d76c4705b1547c4323df3"))}),it("should return an error if field path is invalid",async()=>{const e=f([{display_name:"Amount allowance",format:"token",coin_ref:0,descriptor:"48000000000000a4b1000000000022d473030f116ddee9f6b43ac78ba34d593149e876e739220f3b5ede1b38a0213d76c4705b1547c4323df364657461696c732e746f6b656e416d6f756e7420616c6c6f77616e6365",signatures:{prod:"30440220238723d4ddd47baf829d547802a2017476bf68e03d0b920fd46aa543de81d5b902206123218eae82c5f898454c45262e5b0b839dc9d84b2b0926fe14e8218b5b0d53"},type:"field"}]);jest.spyOn(s.default,"request").mockResolvedValue({data:e});const a=await d.getTypedDataFilters({chainId:1,address:"0x000000000022d473030f116ddee9f6b43ac78ba3",version:"v1",schema:t});expect(a.isLeft()).toEqual(!0),expect(a.extract()).toEqual(new Error("[ContextModule] HttpTypedDataDataSource: invalid typed data field for address 0x000000000022d473030f116ddee9f6b43ac78ba3 on chain 1 for schema 4d593149e876e739220f3b5ede1b38a0213d76c4705b1547c4323df3"))}),it("should return an error if field display_name is invalid",async()=>{const e=f([{format:"token",field_path:"details.token",coin_ref:0,descriptor:"48000000000000a4b1000000000022d473030f116ddee9f6b43ac78ba34d593149e876e739220f3b5ede1b38a0213d76c4705b1547c4323df364657461696c732e746f6b656e416d6f756e7420616c6c6f77616e6365",signatures:{prod:"30440220238723d4ddd47baf829d547802a2017476bf68e03d0b920fd46aa543de81d5b902206123218eae82c5f898454c45262e5b0b839dc9d84b2b0926fe14e8218b5b0d53"},type:"field"}]);jest.spyOn(s.default,"request").mockResolvedValue({data:e});const a=await d.getTypedDataFilters({chainId:1,address:"0x000000000022d473030f116ddee9f6b43ac78ba3",version:"v1",schema:t});expect(a.isLeft()).toEqual(!0),expect(a.extract()).toEqual(new Error("[ContextModule] HttpTypedDataDataSource: invalid typed data field for address 0x000000000022d473030f116ddee9f6b43ac78ba3 on chain 1 for schema 4d593149e876e739220f3b5ede1b38a0213d76c4705b1547c4323df3"))}),it("should return an error if field signatures.prod is missing",async()=>{const e=f([{display_name:"Amount allowance",format:"token",field_path:"details.token",coin_ref:0,descriptor:"48000000000000a4b1000000000022d473030f116ddee9f6b43ac78ba34d593149e876e739220f3b5ede1b38a0213d76c4705b1547c4323df364657461696c732e746f6b656e416d6f756e7420616c6c6f77616e6365",signatures:{test:"30440220238723d4ddd47baf829d547802a2017476bf68e03d0b920fd46aa543de81d5b902206123218eae82c5f898454c45262e5b0b839dc9d84b2b0926fe14e8218b5b0d53"},type:"field"}]);jest.spyOn(s.default,"request").mockResolvedValue({data:e});const a=await d.getTypedDataFilters({chainId:1,address:"0x000000000022d473030f116ddee9f6b43ac78ba3",version:"v1",schema:t});expect(a.isLeft()).toEqual(!0),expect(a.extract()).toEqual(new Error("[ContextModule] HttpTypedDataDataSource: invalid typed data field for address 0x000000000022d473030f116ddee9f6b43ac78ba3 on chain 1 for schema 4d593149e876e739220f3b5ede1b38a0213d76c4705b1547c4323df3"))}),it("should return an error on token fileds with coin ref to null",async()=>{const e=f([{display_name:"Amount allowance",format:"token",field_path:"details.token",coin_ref:null,descriptor:"48000000000000a4b1000000000022d473030f116ddee9f6b43ac78ba34d593149e876e739220f3b5ede1b38a0213d76c4705b1547c4323df364657461696c732e746f6b656e416d6f756e7420616c6c6f77616e6365",signatures:{prod:"30440220238723d4ddd47baf829d547802a2017476bf68e03d0b920fd46aa543de81d5b902206123218eae82c5f898454c45262e5b0b839dc9d84b2b0926fe14e8218b5b0d53"},type:"field"}]);jest.spyOn(s.default,"request").mockResolvedValue({data:e});const a=await d.getTypedDataFilters({chainId:1,address:"0x000000000022d473030f116ddee9f6b43ac78ba3",version:"v2",schema:t});expect(a.isLeft()).toEqual(!0),expect(a.extract()).toEqual(new Error("[ContextModule] HttpTypedDataDataSource: invalid typed data field for address 0x000000000022d473030f116ddee9f6b43ac78ba3 on chain 1 for schema 4d593149e876e739220f3b5ede1b38a0213d76c4705b1547c4323df3"))}),it("should return an error when axios throws an error",async()=>{jest.spyOn(s.default,"request").mockRejectedValue(new Error("error"));const e=await d.getTypedDataFilters({chainId:1,address:"0x000000000022d473030f116ddee9f6b43ac78ba3",version:"v1",schema:t});expect(e.isLeft()).toEqual(!0)})});0&&(module.exports={buildDescriptor});
2
+ //# sourceMappingURL=HttpTypedDataDataSource.test.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../../../src/typed-data/data/HttpTypedDataDataSource.test.ts"],
4
+ "sourcesContent": ["import axios from \"axios\";\nimport { Right } from \"purify-ts\";\n\nimport { type ContextModuleConfig } from \"@/config/model/ContextModuleConfig\";\nimport { HttpTypedDataDataSource } from \"@/typed-data/data/HttpTypedDataDataSource\";\nimport { type TypedDataDataSource } from \"@/typed-data/data/TypedDataDataSource\";\nimport PACKAGE from \"@root/package.json\";\n\nimport { type FiltersDto, type InstructionField } from \"./FiltersDto\";\n\njest.mock(\"axios\");\n\nexport const buildDescriptor = (\n instructions: InstructionField[],\n): FiltersDto[] => [\n {\n descriptors_eip712: {\n \"0x000000000022d473030f116ddee9f6b43ac78ba3\": {\n \"4d593149e876e739220f3b5ede1b38a0213d76c4705b1547c4323df3\": {\n schema: {\n DutchOutput: [\n {\n name: \"token\",\n type: \"address\",\n },\n {\n name: \"startAmount\",\n type: \"uint256\",\n },\n {\n name: \"endAmount\",\n type: \"uint256\",\n },\n {\n name: \"recipient\",\n type: \"address\",\n },\n ],\n EIP712Domain: [\n {\n name: \"name\",\n type: \"string\",\n },\n {\n name: \"chainId\",\n type: \"uint256\",\n },\n {\n name: \"verifyingContract\",\n type: \"address\",\n },\n ],\n ExclusiveDutchOrder: [\n {\n name: \"info\",\n type: \"OrderInfo\",\n },\n {\n name: \"decayStartTime\",\n type: \"uint256\",\n },\n {\n name: \"decayEndTime\",\n type: \"uint256\",\n },\n {\n name: \"exclusiveFiller\",\n type: \"address\",\n },\n {\n name: \"exclusivityOverrideBps\",\n type: \"uint256\",\n },\n {\n name: \"inputToken\",\n type: \"address\",\n },\n {\n name: \"inputStartAmount\",\n type: \"uint256\",\n },\n {\n name: \"inputEndAmount\",\n type: \"uint256\",\n },\n {\n name: \"outputs\",\n type: \"DutchOutput[]\",\n },\n ],\n OrderInfo: [\n {\n name: \"reactor\",\n type: \"address\",\n },\n {\n name: \"swapper\",\n type: \"address\",\n },\n {\n name: \"nonce\",\n type: \"uint256\",\n },\n {\n name: \"deadline\",\n type: \"uint256\",\n },\n {\n name: \"additionalValidationContract\",\n type: \"address\",\n },\n {\n name: \"additionalValidationData\",\n type: \"bytes\",\n },\n ],\n PermitWitnessTransferFrom: [\n {\n name: \"permitted\",\n type: \"TokenPermissions\",\n },\n {\n name: \"spender\",\n type: \"address\",\n },\n {\n name: \"nonce\",\n type: \"uint256\",\n },\n {\n name: \"deadline\",\n type: \"uint256\",\n },\n {\n name: \"witness\",\n type: \"ExclusiveDutchOrder\",\n },\n ],\n TokenPermissions: [\n {\n name: \"token\",\n type: \"address\",\n },\n {\n name: \"amount\",\n type: \"uint256\",\n },\n ],\n },\n instructions,\n },\n },\n },\n },\n];\n\ndescribe(\"HttpTypedDataDataSource\", () => {\n let datasource: TypedDataDataSource;\n\n const TEST_TYPES = {\n PermitSingle: [\n {\n name: \"details\",\n type: \"PermitDetails\",\n },\n {\n name: \"spender\",\n type: \"address\",\n },\n {\n name: \"sigDeadline\",\n type: \"uint256\",\n },\n ],\n PermitDetails: [\n {\n type: \"address\",\n name: \"token\",\n },\n {\n name: \"amount\",\n type: \"uint160\",\n },\n {\n name: \"expiration\",\n type: \"uint48\",\n },\n {\n name: \"nonce\",\n type: \"uint48\",\n },\n ],\n EIP712Domain: [\n {\n name: \"name\",\n type: \"string\",\n },\n {\n name: \"chainId\",\n type: \"uint256\",\n },\n {\n name: \"verifyingContract\",\n type: \"address\",\n },\n ],\n };\n\n beforeAll(() => {\n const config = {\n cal: {\n url: \"https://crypto-assets-service.api.ledger.com/v1\",\n mode: \"prod\",\n },\n } as ContextModuleConfig;\n datasource = new HttpTypedDataDataSource(config);\n jest.clearAllMocks();\n });\n\n it(\"should call axios with the ledger client version header\", async () => {\n // GIVEN\n const version = `context-module/${PACKAGE.version}`;\n const requestSpy = jest.fn(() => Promise.resolve({ data: [] }));\n jest.spyOn(axios, \"request\").mockImplementation(requestSpy);\n\n // WHEN\n await datasource.getTypedDataFilters({\n chainId: 1,\n address: \"0x00\",\n version: \"v2\",\n schema: {},\n });\n\n // THEN\n expect(requestSpy).toHaveBeenCalledWith(\n expect.objectContaining({\n headers: { \"X-Ledger-Client-Version\": version },\n }),\n );\n });\n\n it(\"should return V2 filters when axios response is correct\", async () => {\n // GIVEN\n const filtersDTO = buildDescriptor([\n {\n display_name: \"Permit2\",\n field_mappers_count: 4,\n descriptor:\n \"b7000000000000a4b1000000000022d473030f116ddee9f6b43ac78ba34d593149e876e739220f3b5ede1b38a0213d76c4705b1547c4323df3045065726d697432\",\n signatures: {\n prod: \"304402201675b7d8507b40de5136c386815afdad8012cb8e3f0e0a126c758d6fbb3f6b0f0220595cbfeeab7591d0eebe40f0e4ea8ea53beeaf89ee50b7faf97f97bdf36abbce\",\n },\n type: \"message\",\n },\n {\n display_name: \"Amount allowance\",\n format: \"token\",\n field_path: \"details.token\",\n coin_ref: 0,\n descriptor:\n \"48000000000000a4b1000000000022d473030f116ddee9f6b43ac78ba34d593149e876e739220f3b5ede1b38a0213d76c4705b1547c4323df364657461696c732e746f6b656e416d6f756e7420616c6c6f77616e6365\",\n signatures: {\n prod: \"30440220238723d4ddd47baf829d547802a2017476bf68e03d0b920fd46aa543de81d5b902206123218eae82c5f898454c45262e5b0b839dc9d84b2b0926fe14e8218b5b0d53\",\n },\n type: \"field\",\n },\n {\n display_name: \"Amount allowance\",\n format: \"amount\",\n field_path: \"details.amount\",\n coin_ref: 0,\n descriptor:\n \"48000000000000a4b1000000000022d473030f116ddee9f6b43ac78ba34d593149e876e739220f3b5ede1b38a0213d76c4705b1547c4323df364657461696c732e616d6f756e74416d6f756e7420616c6c6f77616e6365\",\n signatures: {\n prod: \"30450221008f9e2f33b35872e63b2024a6d4938525c6e72364604da2d5e21b3d7fa44cac8a02207d4fe42c9d3994a322dae99adc2c56157435c177c51831103fdaf3cef12bb19f\",\n },\n type: \"field\",\n },\n {\n display_name: \"Approve to spender\",\n format: \"raw\",\n field_path: \"spender\",\n descriptor:\n \"48000000000000a4b1000000000022d473030f116ddee9f6b43ac78ba34d593149e876e739220f3b5ede1b38a0213d76c4705b1547c4323df37370656e646572417070726f766520746f207370656e646572\",\n signatures: {\n prod: \"3045022100dddb92141e3b3f21dafb60c8d5093e28b25a8dc4f926ed501b6d2021203f68bc02201abca405540e72b5b70120a428967b776edb8a88ebd9b1d7aa320c3df602027f\",\n },\n type: \"field\",\n },\n {\n display_name: \"Approval expire\",\n format: \"datetime\",\n field_path: \"details.expiration\",\n descriptor:\n \"48000000000000a4b1000000000022d473030f116ddee9f6b43ac78ba34d593149e876e739220f3b5ede1b38a0213d76c4705b1547c4323df364657461696c732e65787069726174696f6e417070726f76616c20657870697265\",\n signatures: {\n prod: \"3044022060a11c1b15d07e7172e2e68a4e4aa5cbd3b5af900907634b1bce58000eab9fb502201e40963d9e2b00948ce16d3817756329e11a81e8b14b762adff68db4b3a4b8ff\",\n },\n type: \"field\",\n },\n ]);\n jest.spyOn(axios, \"request\").mockResolvedValue({ data: filtersDTO });\n\n // WHEN\n const result = await datasource.getTypedDataFilters({\n chainId: 1,\n address: \"0x000000000022D473030F116DDEE9F6B43AC78BA3\",\n version: \"v2\",\n schema: TEST_TYPES,\n });\n\n // THEN\n expect(result).toEqual(\n Right({\n messageInfo: {\n displayName: \"Permit2\",\n filtersCount: 4,\n signature:\n \"304402201675b7d8507b40de5136c386815afdad8012cb8e3f0e0a126c758d6fbb3f6b0f0220595cbfeeab7591d0eebe40f0e4ea8ea53beeaf89ee50b7faf97f97bdf36abbce\",\n },\n filters: [\n {\n type: \"token\",\n displayName: \"Amount allowance\",\n path: \"details.token\",\n tokenIndex: 0,\n signature:\n \"30440220238723d4ddd47baf829d547802a2017476bf68e03d0b920fd46aa543de81d5b902206123218eae82c5f898454c45262e5b0b839dc9d84b2b0926fe14e8218b5b0d53\",\n },\n {\n type: \"amount\",\n displayName: \"Amount allowance\",\n path: \"details.amount\",\n tokenIndex: 0,\n signature:\n \"30450221008f9e2f33b35872e63b2024a6d4938525c6e72364604da2d5e21b3d7fa44cac8a02207d4fe42c9d3994a322dae99adc2c56157435c177c51831103fdaf3cef12bb19f\",\n },\n {\n type: \"raw\",\n displayName: \"Approve to spender\",\n path: \"spender\",\n signature:\n \"3045022100dddb92141e3b3f21dafb60c8d5093e28b25a8dc4f926ed501b6d2021203f68bc02201abca405540e72b5b70120a428967b776edb8a88ebd9b1d7aa320c3df602027f\",\n },\n {\n type: \"datetime\",\n displayName: \"Approval expire\",\n path: \"details.expiration\",\n signature:\n \"3044022060a11c1b15d07e7172e2e68a4e4aa5cbd3b5af900907634b1bce58000eab9fb502201e40963d9e2b00948ce16d3817756329e11a81e8b14b762adff68db4b3a4b8ff\",\n },\n ],\n }),\n );\n });\n\n it(\"should return V1 filters when axios response is correct\", async () => {\n // GIVEN\n const filtersDTO = buildDescriptor([\n {\n display_name: \"Permit2\",\n field_mappers_count: 4,\n descriptor:\n \"b7000000000000a4b1000000000022d473030f116ddee9f6b43ac78ba34d593149e876e739220f3b5ede1b38a0213d76c4705b1547c4323df3045065726d697432\",\n signatures: {\n prod: \"304402201675b7d8507b40de5136c386815afdad8012cb8e3f0e0a126c758d6fbb3f6b0f0220595cbfeeab7591d0eebe40f0e4ea8ea53beeaf89ee50b7faf97f97bdf36abbce\",\n },\n type: \"message\",\n },\n {\n display_name: \"Amount allowance\",\n format: \"token\",\n field_path: \"details.token\",\n coin_ref: 0,\n descriptor:\n \"48000000000000a4b1000000000022d473030f116ddee9f6b43ac78ba34d593149e876e739220f3b5ede1b38a0213d76c4705b1547c4323df364657461696c732e746f6b656e416d6f756e7420616c6c6f77616e6365\",\n signatures: {\n prod: \"30440220238723d4ddd47baf829d547802a2017476bf68e03d0b920fd46aa543de81d5b902206123218eae82c5f898454c45262e5b0b839dc9d84b2b0926fe14e8218b5b0d53\",\n },\n type: \"field\",\n },\n {\n display_name: \"Amount allowance\",\n format: \"amount\",\n field_path: \"details.amount\",\n coin_ref: 0,\n descriptor:\n \"48000000000000a4b1000000000022d473030f116ddee9f6b43ac78ba34d593149e876e739220f3b5ede1b38a0213d76c4705b1547c4323df364657461696c732e616d6f756e74416d6f756e7420616c6c6f77616e6365\",\n signatures: {\n prod: \"30450221008f9e2f33b35872e63b2024a6d4938525c6e72364604da2d5e21b3d7fa44cac8a02207d4fe42c9d3994a322dae99adc2c56157435c177c51831103fdaf3cef12bb19f\",\n },\n type: \"field\",\n },\n {\n display_name: \"Approve to spender\",\n format: \"raw\",\n field_path: \"spender\",\n descriptor:\n \"48000000000000a4b1000000000022d473030f116ddee9f6b43ac78ba34d593149e876e739220f3b5ede1b38a0213d76c4705b1547c4323df37370656e646572417070726f766520746f207370656e646572\",\n signatures: {\n prod: \"3045022100dddb92141e3b3f21dafb60c8d5093e28b25a8dc4f926ed501b6d2021203f68bc02201abca405540e72b5b70120a428967b776edb8a88ebd9b1d7aa320c3df602027f\",\n },\n type: \"field\",\n },\n {\n display_name: \"Approval expire\",\n format: \"datetime\",\n field_path: \"details.expiration\",\n descriptor:\n \"48000000000000a4b1000000000022d473030f116ddee9f6b43ac78ba34d593149e876e739220f3b5ede1b38a0213d76c4705b1547c4323df364657461696c732e65787069726174696f6e417070726f76616c20657870697265\",\n signatures: {\n prod: \"3044022060a11c1b15d07e7172e2e68a4e4aa5cbd3b5af900907634b1bce58000eab9fb502201e40963d9e2b00948ce16d3817756329e11a81e8b14b762adff68db4b3a4b8ff\",\n },\n type: \"field\",\n },\n ]);\n jest.spyOn(axios, \"request\").mockResolvedValue({ data: filtersDTO });\n\n // WHEN\n const result = await datasource.getTypedDataFilters({\n chainId: 1,\n address: \"0x000000000022d473030f116ddee9f6b43ac78ba3\",\n version: \"v1\",\n schema: TEST_TYPES,\n });\n\n // THEN\n expect(result).toEqual(\n Right({\n messageInfo: {\n displayName: \"Permit2\",\n filtersCount: 4,\n signature:\n \"304402201675b7d8507b40de5136c386815afdad8012cb8e3f0e0a126c758d6fbb3f6b0f0220595cbfeeab7591d0eebe40f0e4ea8ea53beeaf89ee50b7faf97f97bdf36abbce\",\n },\n filters: [\n {\n type: \"raw\",\n displayName: \"Amount allowance\",\n path: \"details.token\",\n signature:\n \"30440220238723d4ddd47baf829d547802a2017476bf68e03d0b920fd46aa543de81d5b902206123218eae82c5f898454c45262e5b0b839dc9d84b2b0926fe14e8218b5b0d53\",\n },\n {\n type: \"raw\",\n displayName: \"Amount allowance\",\n path: \"details.amount\",\n signature:\n \"30450221008f9e2f33b35872e63b2024a6d4938525c6e72364604da2d5e21b3d7fa44cac8a02207d4fe42c9d3994a322dae99adc2c56157435c177c51831103fdaf3cef12bb19f\",\n },\n {\n type: \"raw\",\n displayName: \"Approve to spender\",\n path: \"spender\",\n signature:\n \"3045022100dddb92141e3b3f21dafb60c8d5093e28b25a8dc4f926ed501b6d2021203f68bc02201abca405540e72b5b70120a428967b776edb8a88ebd9b1d7aa320c3df602027f\",\n },\n {\n type: \"raw\",\n displayName: \"Approval expire\",\n path: \"details.expiration\",\n signature:\n \"3044022060a11c1b15d07e7172e2e68a4e4aa5cbd3b5af900907634b1bce58000eab9fb502201e40963d9e2b00948ce16d3817756329e11a81e8b14b762adff68db4b3a4b8ff\",\n },\n ],\n }),\n );\n });\n\n it(\"should return an error when data is empty\", async () => {\n // GIVEN\n jest.spyOn(axios, \"request\").mockResolvedValue({ data: undefined });\n\n // WHEN\n const result = await datasource.getTypedDataFilters({\n chainId: 1,\n address: \"0x000000000022d473030f116ddee9f6b43ac78ba3\",\n version: \"v1\",\n schema: TEST_TYPES,\n });\n\n // THEN\n expect(result.isLeft()).toEqual(true);\n expect(result.extract()).toEqual(\n new Error(\n `[ContextModule] HttpTypedDataDataSource: no typed data filters for address 0x000000000022d473030f116ddee9f6b43ac78ba3 on chain 1 for schema 4d593149e876e739220f3b5ede1b38a0213d76c4705b1547c4323df3`,\n ),\n );\n });\n\n it(\"should return an error when schema is not found\", async () => {\n const filtersDTO = buildDescriptor([]);\n // GIVEN\n jest.spyOn(axios, \"request\").mockResolvedValue({ data: filtersDTO });\n\n // WHEN\n const result = await datasource.getTypedDataFilters({\n chainId: 1,\n address: \"0x000000000022d473030f116ddee9f6b43ac78ba3\",\n version: \"v1\",\n schema: TEST_TYPES,\n });\n\n // THEN\n expect(result.isLeft()).toEqual(true);\n expect(result.extract()).toEqual(\n new Error(\n `[ContextModule] HttpTypedDataDataSource: no message info for address 0x000000000022d473030f116ddee9f6b43ac78ba3 on chain 1 for schema 4d593149e876e739220f3b5ede1b38a0213d76c4705b1547c4323df3`,\n ),\n );\n });\n\n it(\"should return an error when schema is undefined\", async () => {\n const filtersDTO = buildDescriptor(\n undefined as unknown as InstructionField[],\n );\n // GIVEN\n jest.spyOn(axios, \"request\").mockResolvedValue({ data: filtersDTO });\n\n // WHEN\n const result = await datasource.getTypedDataFilters({\n chainId: 1,\n address: \"0x000000000022d473030f116ddee9f6b43ac78ba3\",\n version: \"v1\",\n schema: TEST_TYPES,\n });\n\n // THEN\n expect(result.isLeft()).toEqual(true);\n expect(result.extract()).toEqual(\n new Error(\n `[ContextModule] HttpTypedDataDataSource: no message info for address 0x000000000022d473030f116ddee9f6b43ac78ba3 on chain 1 for schema 4d593149e876e739220f3b5ede1b38a0213d76c4705b1547c4323df3`,\n ),\n );\n });\n\n it(\"should return an error if no message info is found\", async () => {\n const filtersDTO = buildDescriptor([\n {\n display_name: \"Amount allowance\",\n format: \"token\",\n field_path: \"details.token\",\n coin_ref: 0,\n descriptor:\n \"48000000000000a4b1000000000022d473030f116ddee9f6b43ac78ba34d593149e876e739220f3b5ede1b38a0213d76c4705b1547c4323df364657461696c732e746f6b656e416d6f756e7420616c6c6f77616e6365\",\n signatures: {\n prod: \"30440220238723d4ddd47baf829d547802a2017476bf68e03d0b920fd46aa543de81d5b902206123218eae82c5f898454c45262e5b0b839dc9d84b2b0926fe14e8218b5b0d53\",\n },\n type: \"field\",\n },\n ]);\n // GIVEN\n jest.spyOn(axios, \"request\").mockResolvedValue({ data: filtersDTO });\n\n // WHEN\n const result = await datasource.getTypedDataFilters({\n chainId: 1,\n address: \"0x000000000022d473030f116ddee9f6b43ac78ba3\",\n version: \"v1\",\n schema: TEST_TYPES,\n });\n\n // THEN\n expect(result.isLeft()).toEqual(true);\n expect(result.extract()).toEqual(\n new Error(\n `[ContextModule] HttpTypedDataDataSource: no message info for address 0x000000000022d473030f116ddee9f6b43ac78ba3 on chain 1 for schema 4d593149e876e739220f3b5ede1b38a0213d76c4705b1547c4323df3`,\n ),\n );\n });\n\n it(\"should return an error if message info display name is missing\", async () => {\n const filtersDTO = buildDescriptor([\n {\n // display_name: \"Permit2\",\n field_mappers_count: 4,\n descriptor:\n \"b7000000000000a4b1000000000022d473030f116ddee9f6b43ac78ba34d593149e876e739220f3b5ede1b38a0213d76c4705b1547c4323df3045065726d697432\",\n signatures: {\n prod: \"304402201675b7d8507b40de5136c386815afdad8012cb8e3f0e0a126c758d6fbb3f6b0f0220595cbfeeab7591d0eebe40f0e4ea8ea53beeaf89ee50b7faf97f97bdf36abbce\",\n },\n type: \"message\",\n } as InstructionField,\n ]);\n // GIVEN\n jest.spyOn(axios, \"request\").mockResolvedValue({ data: filtersDTO });\n\n // WHEN\n const result = await datasource.getTypedDataFilters({\n chainId: 1,\n address: \"0x000000000022d473030f116ddee9f6b43ac78ba3\",\n version: \"v1\",\n schema: TEST_TYPES,\n });\n\n // THEN\n expect(result.isLeft()).toEqual(true);\n expect(result.extract()).toEqual(\n new Error(\n `[ContextModule] HttpTypedDataDataSource: invalid typed data field for address 0x000000000022d473030f116ddee9f6b43ac78ba3 on chain 1 for schema 4d593149e876e739220f3b5ede1b38a0213d76c4705b1547c4323df3`,\n ),\n );\n });\n\n it(\"should return an error if field path is invalid\", async () => {\n const filtersDTO = buildDescriptor([\n {\n display_name: \"Amount allowance\",\n format: \"token\",\n // field_path: \"details.token\",\n coin_ref: 0,\n descriptor:\n \"48000000000000a4b1000000000022d473030f116ddee9f6b43ac78ba34d593149e876e739220f3b5ede1b38a0213d76c4705b1547c4323df364657461696c732e746f6b656e416d6f756e7420616c6c6f77616e6365\",\n signatures: {\n prod: \"30440220238723d4ddd47baf829d547802a2017476bf68e03d0b920fd46aa543de81d5b902206123218eae82c5f898454c45262e5b0b839dc9d84b2b0926fe14e8218b5b0d53\",\n },\n type: \"field\",\n } as InstructionField,\n ]);\n // GIVEN\n jest.spyOn(axios, \"request\").mockResolvedValue({ data: filtersDTO });\n\n // WHEN\n const result = await datasource.getTypedDataFilters({\n chainId: 1,\n address: \"0x000000000022d473030f116ddee9f6b43ac78ba3\",\n version: \"v1\",\n schema: TEST_TYPES,\n });\n\n // THEN\n expect(result.isLeft()).toEqual(true);\n expect(result.extract()).toEqual(\n new Error(\n `[ContextModule] HttpTypedDataDataSource: invalid typed data field for address 0x000000000022d473030f116ddee9f6b43ac78ba3 on chain 1 for schema 4d593149e876e739220f3b5ede1b38a0213d76c4705b1547c4323df3`,\n ),\n );\n });\n\n it(\"should return an error if field display_name is invalid\", async () => {\n const filtersDTO = buildDescriptor([\n {\n // display_name: \"Amount allowance\",\n format: \"token\",\n field_path: \"details.token\",\n coin_ref: 0,\n descriptor:\n \"48000000000000a4b1000000000022d473030f116ddee9f6b43ac78ba34d593149e876e739220f3b5ede1b38a0213d76c4705b1547c4323df364657461696c732e746f6b656e416d6f756e7420616c6c6f77616e6365\",\n signatures: {\n prod: \"30440220238723d4ddd47baf829d547802a2017476bf68e03d0b920fd46aa543de81d5b902206123218eae82c5f898454c45262e5b0b839dc9d84b2b0926fe14e8218b5b0d53\",\n },\n type: \"field\",\n } as InstructionField,\n ]);\n // GIVEN\n jest.spyOn(axios, \"request\").mockResolvedValue({ data: filtersDTO });\n\n // WHEN\n const result = await datasource.getTypedDataFilters({\n chainId: 1,\n address: \"0x000000000022d473030f116ddee9f6b43ac78ba3\",\n version: \"v1\",\n schema: TEST_TYPES,\n });\n\n // THEN\n expect(result.isLeft()).toEqual(true);\n expect(result.extract()).toEqual(\n new Error(\n `[ContextModule] HttpTypedDataDataSource: invalid typed data field for address 0x000000000022d473030f116ddee9f6b43ac78ba3 on chain 1 for schema 4d593149e876e739220f3b5ede1b38a0213d76c4705b1547c4323df3`,\n ),\n );\n });\n\n it(\"should return an error if field signatures.prod is missing\", async () => {\n const filtersDTO = buildDescriptor([\n {\n display_name: \"Amount allowance\",\n format: \"token\",\n field_path: \"details.token\",\n coin_ref: 0,\n descriptor:\n \"48000000000000a4b1000000000022d473030f116ddee9f6b43ac78ba34d593149e876e739220f3b5ede1b38a0213d76c4705b1547c4323df364657461696c732e746f6b656e416d6f756e7420616c6c6f77616e6365\",\n signatures: {\n test: \"30440220238723d4ddd47baf829d547802a2017476bf68e03d0b920fd46aa543de81d5b902206123218eae82c5f898454c45262e5b0b839dc9d84b2b0926fe14e8218b5b0d53\",\n },\n type: \"field\",\n } as InstructionField,\n ]);\n // GIVEN\n jest.spyOn(axios, \"request\").mockResolvedValue({ data: filtersDTO });\n\n // WHEN\n const result = await datasource.getTypedDataFilters({\n chainId: 1,\n address: \"0x000000000022d473030f116ddee9f6b43ac78ba3\",\n version: \"v1\",\n schema: TEST_TYPES,\n });\n\n // THEN\n expect(result.isLeft()).toEqual(true);\n expect(result.extract()).toEqual(\n new Error(\n `[ContextModule] HttpTypedDataDataSource: invalid typed data field for address 0x000000000022d473030f116ddee9f6b43ac78ba3 on chain 1 for schema 4d593149e876e739220f3b5ede1b38a0213d76c4705b1547c4323df3`,\n ),\n );\n });\n\n it(\"should return an error on token fileds with coin ref to null\", async () => {\n const filtersDTO = buildDescriptor([\n {\n display_name: \"Amount allowance\",\n format: \"token\",\n field_path: \"details.token\",\n coin_ref: null,\n descriptor:\n \"48000000000000a4b1000000000022d473030f116ddee9f6b43ac78ba34d593149e876e739220f3b5ede1b38a0213d76c4705b1547c4323df364657461696c732e746f6b656e416d6f756e7420616c6c6f77616e6365\",\n signatures: {\n prod: \"30440220238723d4ddd47baf829d547802a2017476bf68e03d0b920fd46aa543de81d5b902206123218eae82c5f898454c45262e5b0b839dc9d84b2b0926fe14e8218b5b0d53\",\n },\n type: \"field\",\n } as unknown as InstructionField,\n ]);\n // GIVEN\n jest.spyOn(axios, \"request\").mockResolvedValue({ data: filtersDTO });\n\n // WHEN\n const result = await datasource.getTypedDataFilters({\n chainId: 1,\n address: \"0x000000000022d473030f116ddee9f6b43ac78ba3\",\n version: \"v2\",\n schema: TEST_TYPES,\n });\n\n // THEN\n expect(result.isLeft()).toEqual(true);\n expect(result.extract()).toEqual(\n new Error(\n `[ContextModule] HttpTypedDataDataSource: invalid typed data field for address 0x000000000022d473030f116ddee9f6b43ac78ba3 on chain 1 for schema 4d593149e876e739220f3b5ede1b38a0213d76c4705b1547c4323df3`,\n ),\n );\n });\n\n it(\"should return an error when axios throws an error\", async () => {\n // GIVEN\n jest.spyOn(axios, \"request\").mockRejectedValue(new Error(\"error\"));\n\n // WHEN\n const result = await datasource.getTypedDataFilters({\n chainId: 1,\n address: \"0x000000000022d473030f116ddee9f6b43ac78ba3\",\n version: \"v1\",\n schema: TEST_TYPES,\n });\n\n // THEN\n expect(result.isLeft()).toEqual(true);\n });\n});\n"],
5
+ "mappings": "0jBAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,qBAAAE,IAAA,eAAAC,EAAAH,GAAA,IAAAI,EAAkB,oBAClBC,EAAsB,qBAGtBC,EAAwC,qDAExCC,EAAoB,iCAIpB,KAAK,KAAK,OAAO,EAEV,MAAML,EACXM,GACiB,CACjB,CACE,mBAAoB,CAClB,6CAA8C,CAC5C,2DAA4D,CAC1D,OAAQ,CACN,YAAa,CACX,CACE,KAAM,QACN,KAAM,SACR,EACA,CACE,KAAM,cACN,KAAM,SACR,EACA,CACE,KAAM,YACN,KAAM,SACR,EACA,CACE,KAAM,YACN,KAAM,SACR,CACF,EACA,aAAc,CACZ,CACE,KAAM,OACN,KAAM,QACR,EACA,CACE,KAAM,UACN,KAAM,SACR,EACA,CACE,KAAM,oBACN,KAAM,SACR,CACF,EACA,oBAAqB,CACnB,CACE,KAAM,OACN,KAAM,WACR,EACA,CACE,KAAM,iBACN,KAAM,SACR,EACA,CACE,KAAM,eACN,KAAM,SACR,EACA,CACE,KAAM,kBACN,KAAM,SACR,EACA,CACE,KAAM,yBACN,KAAM,SACR,EACA,CACE,KAAM,aACN,KAAM,SACR,EACA,CACE,KAAM,mBACN,KAAM,SACR,EACA,CACE,KAAM,iBACN,KAAM,SACR,EACA,CACE,KAAM,UACN,KAAM,eACR,CACF,EACA,UAAW,CACT,CACE,KAAM,UACN,KAAM,SACR,EACA,CACE,KAAM,UACN,KAAM,SACR,EACA,CACE,KAAM,QACN,KAAM,SACR,EACA,CACE,KAAM,WACN,KAAM,SACR,EACA,CACE,KAAM,+BACN,KAAM,SACR,EACA,CACE,KAAM,2BACN,KAAM,OACR,CACF,EACA,0BAA2B,CACzB,CACE,KAAM,YACN,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D,CAAC,CACH,CACF,CAAC,EAED,GAAG,0DAA2D,SAAY,CAExE,MAAMI,EAAad,EAAgB,CACjC,CACE,aAAc,UACd,oBAAqB,EACrB,WACE,qIACF,WAAY,CACV,KAAM,8IACR,EACA,KAAM,SACR,EACA,CACE,aAAc,mBACd,OAAQ,QACR,WAAY,gBACZ,SAAU,EACV,WACE,+KACF,WAAY,CACV,KAAM,8IACR,EACA,KAAM,OACR,EACA,CACE,aAAc,mBACd,OAAQ,SACR,WAAY,iBACZ,SAAU,EACV,WACE,iLACF,WAAY,CACV,KAAM,gJACR,EACA,KAAM,OACR,EACA,CACE,aAAc,qBACd,OAAQ,MACR,WAAY,UACZ,WACE,uKACF,WAAY,CACV,KAAM,gJACR,EACA,KAAM,OACR,EACA,CACE,aAAc,kBACd,OAAQ,WACR,WAAY,qBACZ,WACE,uLACF,WAAY,CACV,KAAM,8IACR,EACA,KAAM,OACR,CACF,CAAC,EACD,KAAK,MAAM,EAAAa,QAAO,SAAS,EAAE,kBAAkB,CAAE,KAAMC,CAAW,CAAC,EAGnE,MAAMC,EAAS,MAAMR,EAAW,oBAAoB,CAClD,QAAS,EACT,QAAS,6CACT,QAAS,KACT,OAAQC,CACV,CAAC,EAGD,OAAOO,CAAM,EAAE,WACb,SAAM,CACJ,YAAa,CACX,YAAa,UACb,aAAc,EACd,UACE,8IACJ,EACA,QAAS,CACP,CACE,KAAM,QACN,YAAa,mBACb,KAAM,gBACN,WAAY,EACZ,UACE,8IACJ,EACA,CACE,KAAM,SACN,YAAa,mBACb,KAAM,iBACN,WAAY,EACZ,UACE,gJACJ,EACA,CACE,KAAM,MACN,YAAa,qBACb,KAAM,UACN,UACE,gJACJ,EACA,CACE,KAAM,WACN,YAAa,kBACb,KAAM,qBACN,UACE,8IACJ,CACF,CACF,CAAC,CACH,CACF,CAAC,EAED,GAAG,0DAA2D,SAAY,CAExE,MAAMD,EAAad,EAAgB,CACjC,CACE,aAAc,UACd,oBAAqB,EACrB,WACE,qIACF,WA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C,EAGjE,MAAME,EAAS,MAAMR,EAAW,oBAAoB,CAClD,QAAS,EACT,QAAS,6CACT,QAAS,KACT,OAAQC,CACV,CAAC,EAGD,OAAOO,EAAO,OAAO,CAAC,EAAE,QAAQ,EAAI,CACtC,CAAC,CACH,CAAC",
6
+ "names": ["HttpTypedDataDataSource_test_exports", "__export", "buildDescriptor", "__toCommonJS", "import_axios", "import_purify_ts", "import_HttpTypedDataDataSource", "import_package", "instructions", "datasource", "TEST_TYPES", "config", "version", "PACKAGE", "requestSpy", "axios", "filtersDTO", "result"]
7
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";var p=Object.defineProperty;var i=Object.getOwnPropertyDescriptor;var y=Object.getOwnPropertyNames;var o=Object.prototype.hasOwnProperty;var d=(t,e,s,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let a of y(e))!o.call(t,a)&&a!==s&&p(t,a,{get:()=>e[a],enumerable:!(r=i(e,a))||r.enumerable});return t};var m=t=>d(p({},"__esModule",{value:!0}),t);var D={};module.exports=m(D);
2
+ //# sourceMappingURL=TypedDataDataSource.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../../../src/typed-data/data/TypedDataDataSource.ts"],
4
+ "sourcesContent": ["import { type Either } from \"purify-ts\";\n\nimport {\n type TypedDataFilter,\n type TypedDataMessageInfo,\n} from \"@/shared/model/TypedDataClearSignContext\";\nimport { type TypedDataSchema } from \"@/shared/model/TypedDataContext\";\n\nexport type GetTypedDataFiltersParams = {\n address: string;\n chainId: number;\n version: \"v1\" | \"v2\";\n schema: TypedDataSchema;\n};\n\nexport type GetTypedDataFiltersResult = {\n messageInfo: TypedDataMessageInfo;\n filters: TypedDataFilter[];\n};\n\nexport interface TypedDataDataSource {\n getTypedDataFilters(\n params: GetTypedDataFiltersParams,\n ): Promise<Either<Error, GetTypedDataFiltersResult>>;\n}\n"],
5
+ "mappings": "+WAAA,IAAAA,EAAA,kBAAAC,EAAAD",
6
+ "names": ["TypedDataDataSource_exports", "__toCommonJS"]
7
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";var p=Object.defineProperty;var y=Object.getOwnPropertyDescriptor;var i=Object.getOwnPropertyNames;var u=Object.prototype.hasOwnProperty;var f=(t,o)=>{for(var a in o)p(t,a,{get:o[a],enumerable:!0})},T=(t,o,a,r)=>{if(o&&typeof o=="object"||typeof o=="function")for(let e of i(o))!u.call(t,e)&&e!==a&&p(t,e,{get:()=>o[e],enumerable:!(r=y(o,e))||r.enumerable});return t};var c=t=>T(p({},"__esModule",{value:!0}),t);var s={};f(s,{typedDataModuleFactory:()=>l});module.exports=c(s);var n=require("inversify"),D=require("../../typed-data/data/HttpTypedDataDataSource"),d=require("../../typed-data/di/typedDataTypes"),m=require("../../typed-data/domain/DefaultTypedDataContextLoader");const l=()=>new n.ContainerModule((t,o,a,r)=>{t(d.typedDataTypes.TypedDataDataSource).to(D.HttpTypedDataDataSource),t(d.typedDataTypes.TypedDataContextLoader).to(m.DefaultTypedDataContextLoader)});0&&(module.exports={typedDataModuleFactory});
2
+ //# sourceMappingURL=typedDataModuleFactory.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../../../src/typed-data/di/typedDataModuleFactory.ts"],
4
+ "sourcesContent": ["import { ContainerModule } from \"inversify\";\n\nimport { HttpTypedDataDataSource } from \"@/typed-data/data/HttpTypedDataDataSource\";\nimport { typedDataTypes } from \"@/typed-data/di/typedDataTypes\";\nimport { DefaultTypedDataContextLoader } from \"@/typed-data/domain/DefaultTypedDataContextLoader\";\n\nexport const typedDataModuleFactory = () =>\n new ContainerModule((bind, _unbind, _isBound, _rebind) => {\n bind(typedDataTypes.TypedDataDataSource).to(HttpTypedDataDataSource);\n bind(typedDataTypes.TypedDataContextLoader).to(\n DefaultTypedDataContextLoader,\n );\n });\n"],
5
+ "mappings": "yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,4BAAAE,IAAA,eAAAC,EAAAH,GAAA,IAAAI,EAAgC,qBAEhCC,EAAwC,qDACxCC,EAA+B,0CAC/BC,EAA8C,6DAEvC,MAAML,EAAyB,IACpC,IAAI,kBAAgB,CAACM,EAAMC,EAASC,EAAUC,IAAY,CACxDH,EAAK,iBAAe,mBAAmB,EAAE,GAAG,yBAAuB,EACnEA,EAAK,iBAAe,sBAAsB,EAAE,GAC1C,+BACF,CACF,CAAC",
6
+ "names": ["typedDataModuleFactory_exports", "__export", "typedDataModuleFactory", "__toCommonJS", "import_inversify", "import_HttpTypedDataDataSource", "import_typedDataTypes", "import_DefaultTypedDataContextLoader", "bind", "_unbind", "_isBound", "_rebind"]
7
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";var y=Object.defineProperty;var p=Object.getOwnPropertyDescriptor;var r=Object.getOwnPropertyNames;var D=Object.prototype.hasOwnProperty;var T=(t,a)=>{for(var o in a)y(t,o,{get:a[o],enumerable:!0})},S=(t,a,o,d)=>{if(a&&typeof a=="object"||typeof a=="function")for(let e of r(a))!D.call(t,e)&&e!==o&&y(t,e,{get:()=>a[e],enumerable:!(d=p(a,e))||d.enumerable});return t};var c=t=>S(y({},"__esModule",{value:!0}),t);var x={};T(x,{typedDataTypes:()=>n});module.exports=c(x);const n={TypedDataDataSource:Symbol.for("TypedDataDataSource"),TypedDataContextLoader:Symbol.for("TypedDataContextLoader")};0&&(module.exports={typedDataTypes});
2
+ //# sourceMappingURL=typedDataTypes.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../../../src/typed-data/di/typedDataTypes.ts"],
4
+ "sourcesContent": ["export const typedDataTypes = {\n TypedDataDataSource: Symbol.for(\"TypedDataDataSource\"),\n TypedDataContextLoader: Symbol.for(\"TypedDataContextLoader\"),\n};\n"],
5
+ "mappings": "yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,oBAAAE,IAAA,eAAAC,EAAAH,GAAO,MAAME,EAAiB,CAC5B,oBAAqB,OAAO,IAAI,qBAAqB,EACrD,uBAAwB,OAAO,IAAI,wBAAwB,CAC7D",
6
+ "names": ["typedDataTypes_exports", "__export", "typedDataTypes", "__toCommonJS"]
7
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";var m=Object.defineProperty;var h=Object.getOwnPropertyDescriptor;var v=Object.getOwnPropertyNames;var I=Object.prototype.hasOwnProperty;var C=(o,e)=>{for(var t in e)m(o,t,{get:e[t],enumerable:!0})},F=(o,e,t,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let a of v(e))!I.call(o,a)&&a!==t&&m(o,a,{get:()=>e[a],enumerable:!(r=h(e,a))||r.enumerable});return o};var A=o=>F(m({},"__esModule",{value:!0}),o),S=(o,e,t,r)=>{for(var a=r>1?void 0:r?h(e,t):e,s=o.length-1,n;s>=0;s--)(n=o[s])&&(a=(r?n(e,t,a):n(a))||a);return r&&a&&m(e,t,a),a},u=(o,e)=>(t,r)=>e(t,r,o);var R={};C(R,{DefaultTypedDataContextLoader:()=>c});module.exports=A(R);var y=require("inversify"),k=require("../../shared/model/TypedDataClearSignContext"),D=require("../../token/di/tokenTypes"),g=require("../../typed-data/di/typedDataTypes");let c=class{constructor(e,t){this.dataSource=e;this.tokenDataSource=t}async load(e){const t=await this.dataSource.getTypedDataFilters({address:e.verifyingContract,chainId:e.chainId,version:e.version,schema:e.schema});if(t.isLeft())return{type:"error",error:t.extract()};const{messageInfo:r,filters:a}=t.unsafeCoerce(),s={},n={};for(const i of a){if(s[i.path]=i,i.type!=="token"&&i.type!=="amount")continue;const T=i.tokenIndex;if(n[T]===void 0){if(i.type==="token"){const p=e.fieldsValues.filter(d=>d.path===i.path);if(p.length===0)continue;const f=p[0],l=this.convertAddressToHexaString(f.value);if(p.every(d=>this.convertAddressToHexaString(d.value)===l)){const d=e.chainId;(await this.tokenDataSource.getTokenInfosPayload({address:l,chainId:d})).ifRight(x=>{n[T]=x})}}else if(i.type==="amount"&&T===k.VERIFYING_CONTRACT_TOKEN_INDEX){const p=e.verifyingContract,f=e.chainId;(await this.tokenDataSource.getTokenInfosPayload({address:p,chainId:f})).ifRight(d=>{n[T]=d})}}}return{type:"success",messageInfo:r,filters:s,tokens:n}}convertAddressToHexaString(e){return`0x${Array.from(e,t=>t.toString(16).padStart(2,"0")).join("").padStart(40,"0")}`}};c=S([(0,y.injectable)(),u(0,(0,y.inject)(g.typedDataTypes.TypedDataDataSource)),u(1,(0,y.inject)(D.tokenTypes.TokenDataSource))],c);0&&(module.exports={DefaultTypedDataContextLoader});
2
+ //# sourceMappingURL=DefaultTypedDataContextLoader.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../../../src/typed-data/domain/DefaultTypedDataContextLoader.ts"],
4
+ "sourcesContent": ["import type { HexaString } from \"@ledgerhq/device-management-kit\";\nimport { inject, injectable } from \"inversify\";\n\nimport type {\n TypedDataClearSignContext,\n TypedDataFilter,\n TypedDataFilterPath,\n TypedDataToken,\n TypedDataTokenIndex,\n} from \"@/shared/model/TypedDataClearSignContext\";\nimport { VERIFYING_CONTRACT_TOKEN_INDEX } from \"@/shared/model/TypedDataClearSignContext\";\nimport type { TypedDataContext } from \"@/shared/model/TypedDataContext\";\nimport type { TokenDataSource } from \"@/token/data/TokenDataSource\";\nimport { tokenTypes } from \"@/token/di/tokenTypes\";\nimport type { TypedDataDataSource } from \"@/typed-data/data/TypedDataDataSource\";\nimport { typedDataTypes } from \"@/typed-data/di/typedDataTypes\";\nimport type { TypedDataContextLoader } from \"@/typed-data/domain/TypedDataContextLoader\";\n\n@injectable()\nexport class DefaultTypedDataContextLoader implements TypedDataContextLoader {\n constructor(\n @inject(typedDataTypes.TypedDataDataSource)\n private dataSource: TypedDataDataSource,\n @inject(tokenTypes.TokenDataSource)\n private tokenDataSource: TokenDataSource,\n ) {}\n\n async load(typedData: TypedDataContext): Promise<TypedDataClearSignContext> {\n // Get the typed data filters from the data source\n const data = await this.dataSource.getTypedDataFilters({\n address: typedData.verifyingContract,\n chainId: typedData.chainId,\n version: typedData.version,\n schema: typedData.schema,\n });\n\n // If there was an error getting the typed data filters, return an error immediately\n if (data.isLeft()) {\n return {\n type: \"error\",\n error: data.extract(),\n };\n }\n\n // Else, extract the message info and filters\n const { messageInfo, filters } = data.unsafeCoerce();\n\n // Loop through the typed data filters to extract informations\n const mappedFilters: Record<TypedDataFilterPath, TypedDataFilter> = {};\n const mappedTokens: Record<TypedDataTokenIndex, TypedDataToken> = {};\n for (const filter of filters) {\n // Add the filter to the clear signing context\n mappedFilters[filter.path] = filter;\n if (filter.type !== \"token\" && filter.type !== \"amount\") {\n continue; // no token reference\n }\n\n // If the filter references a token, retrieve its descriptor from the tokens data source\n const tokenIndex = filter.tokenIndex;\n if (mappedTokens[tokenIndex] !== undefined) {\n continue; // Already fetched for a previous filter\n }\n\n // If the filter is a token, get token address from typed message values, and fetch descriptor\n if (filter.type === \"token\") {\n const values = typedData.fieldsValues.filter(\n (entry) => entry.path === filter.path,\n );\n if (values.length === 0) {\n // No value matching the referenced token. It may be located in an empty array.\n continue;\n }\n const value = values[0]!;\n const address = this.convertAddressToHexaString(value.value);\n\n // Arrays with different tokens are not supported since there is only 1 tokenIndex per filter.\n // Only fetch tokens if all values are the same.\n if (\n values.every(\n (entry) => this.convertAddressToHexaString(entry.value) === address,\n )\n ) {\n // Fetch descriptor\n const chainId = typedData.chainId;\n const payload = await this.tokenDataSource.getTokenInfosPayload({\n address,\n chainId,\n });\n payload.ifRight((p) => {\n mappedTokens[tokenIndex] = p;\n });\n }\n }\n\n // If the filter is an amount with a reference to the verifyingContract, fetch verifyingContract descriptor.\n // This is because descriptors data-sources should be compatible with Ledger devices specifications:\n // https://github.com/LedgerHQ/app-ethereum/blob/develop/doc/ethapp.adoc#amount-join-value\n else if (\n filter.type === \"amount\" &&\n tokenIndex === VERIFYING_CONTRACT_TOKEN_INDEX\n ) {\n const address = typedData.verifyingContract;\n const chainId = typedData.chainId;\n const payload = await this.tokenDataSource.getTokenInfosPayload({\n address,\n chainId,\n });\n payload.ifRight((p) => {\n mappedTokens[tokenIndex] = p;\n });\n }\n }\n\n return {\n type: \"success\",\n messageInfo,\n filters: mappedFilters,\n tokens: mappedTokens,\n };\n }\n\n private convertAddressToHexaString(address: Uint8Array): HexaString {\n // Address size is 20 bytes so 40 characters, padded with zeros on the left\n return `0x${Array.from(address, (byte) =>\n byte.toString(16).padStart(2, \"0\"),\n )\n .join(\"\")\n .padStart(40, \"0\")}`;\n }\n}\n"],
5
+ "mappings": "okBAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,mCAAAE,IAAA,eAAAC,EAAAH,GACA,IAAAI,EAAmC,qBASnCC,EAA+C,oDAG/CC,EAA2B,iCAE3BC,EAA+B,0CAIxB,IAAMC,EAAN,KAAsE,CAC3E,YAEUC,EAEAC,EACR,CAHQ,gBAAAD,EAEA,qBAAAC,CACP,CAEH,MAAM,KAAKC,EAAiE,CAE1E,MAAMC,EAAO,MAAM,KAAK,WAAW,oBAAoB,CACrD,QAASD,EAAU,kBACnB,QAASA,EAAU,QACnB,QAASA,EAAU,QACnB,OAAQA,EAAU,MACpB,CAAC,EAGD,GAAIC,EAAK,OAAO,EACd,MAAO,CACL,KAAM,QACN,MAAOA,EAAK,QAAQ,CACtB,EAIF,KAAM,CAAE,YAAAC,EAAa,QAAAC,CAAQ,EAAIF,EAAK,aAAa,EAG7CG,EAA8D,CAAC,EAC/DC,EAA4D,CAAC,EACnE,UAAWC,KAAUH,EAAS,CAG5B,GADAC,EAAcE,EAAO,IAAI,EAAIA,EACzBA,EAAO,OAAS,SAAWA,EAAO,OAAS,SAC7C,SAIF,MAAMC,EAAaD,EAAO,WAC1B,GAAID,EAAaE,CAAU,IAAM,QAKjC,GAAID,EAAO,OAAS,QAAS,CAC3B,MAAME,EAASR,EAAU,aAAa,OACnCS,GAAUA,EAAM,OAASH,EAAO,IACnC,EACA,GAAIE,EAAO,SAAW,EAEpB,SAEF,MAAME,EAAQF,EAAO,CAAC,EAChBG,EAAU,KAAK,2BAA2BD,EAAM,KAAK,EAI3D,GACEF,EAAO,MACJC,GAAU,KAAK,2BAA2BA,EAAM,KAAK,IAAME,CAC9D,EACA,CAEA,MAAMC,EAAUZ,EAAU,SACV,MAAM,KAAK,gBAAgB,qBAAqB,CAC9D,QAAAW,EACA,QAAAC,CACF,CAAC,GACO,QAASC,GAAM,CACrBR,EAAaE,CAAU,EAAIM,CAC7B,CAAC,CACH,CACF,SAMEP,EAAO,OAAS,UAChBC,IAAe,iCACf,CACA,MAAMI,EAAUX,EAAU,kBACpBY,EAAUZ,EAAU,SACV,MAAM,KAAK,gBAAgB,qBAAqB,CAC9D,QAAAW,EACA,QAAAC,CACF,CAAC,GACO,QAASC,GAAM,CACrBR,EAAaE,CAAU,EAAIM,CAC7B,CAAC,CACH,EACF,CAEA,MAAO,CACL,KAAM,UACN,YAAAX,EACA,QAASE,EACT,OAAQC,CACV,CACF,CAEQ,2BAA2BM,EAAiC,CAElE,MAAO,KAAK,MAAM,KAAKA,EAAUG,GAC/BA,EAAK,SAAS,EAAE,EAAE,SAAS,EAAG,GAAG,CACnC,EACG,KAAK,EAAE,EACP,SAAS,GAAI,GAAG,CAAC,EACtB,CACF,EA9GajB,EAANkB,EAAA,IADN,cAAW,EAGPC,EAAA,eAAO,iBAAe,mBAAmB,GAEzCA,EAAA,eAAO,aAAW,eAAe,IAJzBnB",
6
+ "names": ["DefaultTypedDataContextLoader_exports", "__export", "DefaultTypedDataContextLoader", "__toCommonJS", "import_inversify", "import_TypedDataClearSignContext", "import_tokenTypes", "import_typedDataTypes", "DefaultTypedDataContextLoader", "dataSource", "tokenDataSource", "typedData", "data", "messageInfo", "filters", "mappedFilters", "mappedTokens", "filter", "tokenIndex", "values", "entry", "value", "address", "chainId", "p", "byte", "__decorateClass", "__decorateParam"]
7
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";var t=require("purify-ts"),b=require("../../typed-data/domain/DefaultTypedDataContextLoader");describe("TokenContextLoader",()=>{const d={getTokenInfosPayload:jest.fn()},f={getTypedDataFilters:jest.fn()},c=new b.DefaultTypedDataContextLoader(f,d),n={PermitSingle:[{name:"details",type:"PermitDetails"},{name:"spender",type:"address"},{name:"sigDeadline",type:"uint256"}],PermitDetails:[{type:"address[]",name:"token"},{name:"amount",type:"uint160"},{name:"expiration",type:"uint48"},{name:"nonce",type:"uint48"}],EIP712Domain:[{name:"name",type:"string"},{name:"chainId",type:"uint256"},{name:"verifyingContract",type:"address"}]},s=[{path:"details.token.[]",value:Uint8Array.from([124,235,35,253,107,192,173,213,158,98,172,37,87,130,112,207,241,185,246,25])},{path:"details.amount",value:Uint8Array.from([18])},{path:"spender",value:Uint8Array.from([18])},{path:"details.expiration",value:Uint8Array.from([18])}];beforeEach(()=>{jest.clearAllMocks(),jest.spyOn(d,"getTokenInfosPayload").mockImplementation(({address:a})=>Promise.resolve((0,t.Right)(`payload-${a}`)))}),describe("load function",()=>{it("success with referenced token",async()=>{const a={verifyingContract:"0x000000000022d473030f116ddee9f6b43ac78ba3",chainId:1,version:"v2",schema:n,fieldsValues:s};jest.spyOn(f,"getTypedDataFilters").mockImplementation(()=>Promise.resolve((0,t.Right)({messageInfo:{displayName:"Permit2",filtersCount:4,signature:"3045022100e3c597d13d28a87a88b0239404c668373cf5063362f2a81d09eed4582941dfe802207669aabb504fd5b95b2734057f6b8bbf51f14a69a5f9bdf658a5952cefbf44d3"},filters:[{type:"token",displayName:"Amount allowance",path:"details.token.[]",tokenIndex:0,signature:"3044022075103b38995e031d1ebbfe38ac6603bec32854b5146a664e49b4cc4f460c1da6022029f4b0fd1f3b7995ffff1627d4b57f27888a2dcc9b3a4e85c37c67571092c733"},{type:"amount",displayName:"Amount allowance",path:"details.amount",tokenIndex:0,signature:"304402201a46e6b4ef89eaf9fcf4945d053bfc5616a826400fd758312fbbe976bafc07ec022025a9b408722baf983ee053f90179c75b0c55bb0668f437d55493e36069bbd5a3"},{type:"raw",displayName:"Approve to spender",path:"spender",signature:"3044022033e5713d9cb9bc375b56a9fb53b736c81ea3c4ac5cfb2d3ca7f8b8f0558fe2430220543ca4fef6d6f725f29e343f167fe9dd582aa856ecb5797259050eb990a1befb"},{type:"datetime",displayName:"Approval expire",path:"details.expiration",signature:"3044022056b3381e4540629ad73bc434ec49d80523234b82f62340fbb77157fb0eb21a680220459fe9cf6ca309f9c7dfc6d4711fea1848dba661563c57f77b3c2dc480b3a63b"}]})));const e=await c.load(a);expect(e).toEqual({type:"success",messageInfo:{displayName:"Permit2",filtersCount:4,signature:"3045022100e3c597d13d28a87a88b0239404c668373cf5063362f2a81d09eed4582941dfe802207669aabb504fd5b95b2734057f6b8bbf51f14a69a5f9bdf658a5952cefbf44d3"},tokens:{0:"payload-0x7ceb23fd6bc0add59e62ac25578270cff1b9f619"},filters:{"details.amount":{displayName:"Amount allowance",path:"details.amount",signature:"304402201a46e6b4ef89eaf9fcf4945d053bfc5616a826400fd758312fbbe976bafc07ec022025a9b408722baf983ee053f90179c75b0c55bb0668f437d55493e36069bbd5a3",tokenIndex:0,type:"amount"},"details.expiration":{displayName:"Approval expire",path:"details.expiration",signature:"3044022056b3381e4540629ad73bc434ec49d80523234b82f62340fbb77157fb0eb21a680220459fe9cf6ca309f9c7dfc6d4711fea1848dba661563c57f77b3c2dc480b3a63b",type:"datetime"},"details.token.[]":{displayName:"Amount allowance",path:"details.token.[]",signature:"3044022075103b38995e031d1ebbfe38ac6603bec32854b5146a664e49b4cc4f460c1da6022029f4b0fd1f3b7995ffff1627d4b57f27888a2dcc9b3a4e85c37c67571092c733",tokenIndex:0,type:"token"},spender:{displayName:"Approve to spender",path:"spender",signature:"3044022033e5713d9cb9bc375b56a9fb53b736c81ea3c4ac5cfb2d3ca7f8b8f0558fe2430220543ca4fef6d6f725f29e343f167fe9dd582aa856ecb5797259050eb990a1befb",type:"raw"}}})}),it("success with referenced token verifying contract",async()=>{const a={verifyingContract:"0x000000000022d473030f116ddee9f6b43ac78ba3",chainId:1,version:"v2",schema:n,fieldsValues:s};jest.spyOn(f,"getTypedDataFilters").mockImplementation(()=>Promise.resolve((0,t.Right)({messageInfo:{displayName:"Permit2",filtersCount:2,signature:"3045022100e3c597d13d28a87a88b0239404c668373cf5063362f2a81d09eed4582941dfe802207669aabb504fd5b95b2734057f6b8bbf51f14a69a5f9bdf658a5952cefbf44d3"},filters:[{type:"token",displayName:"Amount allowance",path:"details.token.[]",tokenIndex:0,signature:"3044022075103b38995e031d1ebbfe38ac6603bec32854b5146a664e49b4cc4f460c1da6022029f4b0fd1f3b7995ffff1627d4b57f27888a2dcc9b3a4e85c37c67571092c733"},{type:"amount",displayName:"Amount allowance",path:"details.amount",tokenIndex:255,signature:"304402201a46e6b4ef89eaf9fcf4945d053bfc5616a826400fd758312fbbe976bafc07ec022025a9b408722baf983ee053f90179c75b0c55bb0668f437d55493e36069bbd5a3"}]})));const e=await c.load(a);expect(e).toEqual({type:"success",messageInfo:{displayName:"Permit2",filtersCount:2,signature:"3045022100e3c597d13d28a87a88b0239404c668373cf5063362f2a81d09eed4582941dfe802207669aabb504fd5b95b2734057f6b8bbf51f14a69a5f9bdf658a5952cefbf44d3"},tokens:{0:"payload-0x7ceb23fd6bc0add59e62ac25578270cff1b9f619",255:"payload-0x000000000022d473030f116ddee9f6b43ac78ba3"},filters:{"details.amount":{displayName:"Amount allowance",path:"details.amount",signature:"304402201a46e6b4ef89eaf9fcf4945d053bfc5616a826400fd758312fbbe976bafc07ec022025a9b408722baf983ee053f90179c75b0c55bb0668f437d55493e36069bbd5a3",tokenIndex:255,type:"amount"},"details.token.[]":{displayName:"Amount allowance",path:"details.token.[]",signature:"3044022075103b38995e031d1ebbfe38ac6603bec32854b5146a664e49b4cc4f460c1da6022029f4b0fd1f3b7995ffff1627d4b57f27888a2dcc9b3a4e85c37c67571092c733",tokenIndex:0,type:"token"}}})}),it("should return an error if filters are unavailable",async()=>{const a={verifyingContract:"0x000000000022d473030f116ddee9f6b43ac78ba3",chainId:1,version:"v2",schema:n,fieldsValues:s};jest.spyOn(f,"getTypedDataFilters").mockImplementation(()=>Promise.resolve((0,t.Left)(new Error("error"))));const e=await c.load(a);expect(e).toEqual({type:"error",error:new Error("error")})}),it("success with unavailable tokens",async()=>{const a={verifyingContract:"0x000000000022d473030f116ddee9f6b43ac78ba3",chainId:1,version:"v2",schema:n,fieldsValues:s};jest.spyOn(f,"getTypedDataFilters").mockImplementation(()=>Promise.resolve((0,t.Right)({messageInfo:{displayName:"Permit2",filtersCount:2,signature:"3045022100e3c597d13d28a87a88b0239404c668373cf5063362f2a81d09eed4582941dfe802207669aabb504fd5b95b2734057f6b8bbf51f14a69a5f9bdf658a5952cefbf44d3"},filters:[{type:"token",displayName:"Amount allowance",path:"details.token.[]",tokenIndex:0,signature:"3044022075103b38995e031d1ebbfe38ac6603bec32854b5146a664e49b4cc4f460c1da6022029f4b0fd1f3b7995ffff1627d4b57f27888a2dcc9b3a4e85c37c67571092c733"}]}))),jest.spyOn(d,"getTokenInfosPayload").mockImplementation(()=>Promise.resolve((0,t.Left)(new Error("token error"))));const e=await c.load(a);expect(e).toEqual({type:"success",messageInfo:{displayName:"Permit2",filtersCount:2,signature:"3045022100e3c597d13d28a87a88b0239404c668373cf5063362f2a81d09eed4582941dfe802207669aabb504fd5b95b2734057f6b8bbf51f14a69a5f9bdf658a5952cefbf44d3"},tokens:{},filters:{"details.token.[]":{displayName:"Amount allowance",path:"details.token.[]",signature:"3044022075103b38995e031d1ebbfe38ac6603bec32854b5146a664e49b4cc4f460c1da6022029f4b0fd1f3b7995ffff1627d4b57f27888a2dcc9b3a4e85c37c67571092c733",tokenIndex:0,type:"token"}}})}),it("success with several identic tokens",async()=>{const a={verifyingContract:"0x000000000022d473030f116ddee9f6b43ac78ba3",chainId:1,version:"v2",schema:n,fieldsValues:[{path:"details.token.[]",value:Uint8Array.from([124,235,35,253,107,192,173,213,158,98,172,37,87,130,112,207,241,185,246,25])},...s]};jest.spyOn(f,"getTypedDataFilters").mockImplementation(()=>Promise.resolve((0,t.Right)({messageInfo:{displayName:"Permit2",filtersCount:2,signature:"3045022100e3c597d13d28a87a88b0239404c668373cf5063362f2a81d09eed4582941dfe802207669aabb504fd5b95b2734057f6b8bbf51f14a69a5f9bdf658a5952cefbf44d3"},filters:[{type:"token",displayName:"Amount allowance",path:"details.token.[]",tokenIndex:0,signature:"3044022075103b38995e031d1ebbfe38ac6603bec32854b5146a664e49b4cc4f460c1da6022029f4b0fd1f3b7995ffff1627d4b57f27888a2dcc9b3a4e85c37c67571092c733"}]}))),jest.spyOn(d,"getTokenInfosPayload").mockImplementation(()=>Promise.resolve((0,t.Left)(new Error("token error"))));const e=await c.load(a);expect(d.getTokenInfosPayload).toHaveBeenCalledWith({address:"0x7ceb23fd6bc0add59e62ac25578270cff1b9f619",chainId:1}),expect(e.type).toEqual("success")}),it("success with several different tokens",async()=>{const a={verifyingContract:"0x000000000022d473030f116ddee9f6b43ac78ba3",chainId:1,version:"v2",schema:n,fieldsValues:[{path:"details.token.[]",value:Uint8Array.from([124,235,35,253,107,192,173,213,158,98,172,37,87,130,112,207,241,185,246,255])},...s]};jest.spyOn(f,"getTypedDataFilters").mockImplementation(()=>Promise.resolve((0,t.Right)({messageInfo:{displayName:"Permit2",filtersCount:2,signature:"3045022100e3c597d13d28a87a88b0239404c668373cf5063362f2a81d09eed4582941dfe802207669aabb504fd5b95b2734057f6b8bbf51f14a69a5f9bdf658a5952cefbf44d3"},filters:[{type:"token",displayName:"Amount allowance",path:"details.token.[]",tokenIndex:0,signature:"3044022075103b38995e031d1ebbfe38ac6603bec32854b5146a664e49b4cc4f460c1da6022029f4b0fd1f3b7995ffff1627d4b57f27888a2dcc9b3a4e85c37c67571092c733"}]})));const e=await c.load(a);expect(d.getTokenInfosPayload).not.toHaveBeenCalledWith({address:"0x7ceb23fd6bc0add59e62ac25578270cff1b9f6ff",chainId:1}),expect(d.getTokenInfosPayload).not.toHaveBeenCalledWith({address:"0x7ceb23fd6bc0add59e62ac25578270cff1b9f619",chainId:1}),expect(e.type).toEqual("success")}),it("should ignore the token if value is not found",async()=>{const a={verifyingContract:"0x000000000022d473030f116ddee9f6b43ac78ba3",chainId:1,version:"v2",schema:n,fieldsValues:s};jest.spyOn(f,"getTypedDataFilters").mockImplementation(()=>Promise.resolve((0,t.Right)({messageInfo:{displayName:"Permit2",filtersCount:2,signature:"3045022100e3c597d13d28a87a88b0239404c668373cf5063362f2a81d09eed4582941dfe802207669aabb504fd5b95b2734057f6b8bbf51f14a69a5f9bdf658a5952cefbf44d3"},filters:[{type:"token",displayName:"Amount allowance",path:"details.badtoken",tokenIndex:0,signature:"3044022075103b38995e031d1ebbfe38ac6603bec32854b5146a664e49b4cc4f460c1da6022029f4b0fd1f3b7995ffff1627d4b57f27888a2dcc9b3a4e85c37c67571092c733"}]})));const e=await c.load(a);expect(e.type).toEqual("success"),e.type==="success"&&(expect(e.filters["details.badtoken"]?.displayName).toEqual("Amount allowance"),expect(e.tokens).toEqual({}))})})});
2
+ //# sourceMappingURL=DefaultTypedDataContextLoader.test.js.map