@ledgerhq/context-module 1.4.0 → 1.7.0

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 (387) hide show
  1. package/lib/cjs/package.json +2 -2
  2. package/lib/cjs/src/ContextModule.js +1 -1
  3. package/lib/cjs/src/ContextModule.js.map +1 -1
  4. package/lib/cjs/src/ContextModuleBuilder.js +1 -1
  5. package/lib/cjs/src/ContextModuleBuilder.js.map +3 -3
  6. package/lib/cjs/src/ContextModuleBuilder.test.js +1 -1
  7. package/lib/cjs/src/ContextModuleBuilder.test.js.map +3 -3
  8. package/lib/cjs/src/DefaultContextModule.js +1 -1
  9. package/lib/cjs/src/DefaultContextModule.js.map +3 -3
  10. package/lib/cjs/src/DefaultContextModule.test.js +1 -1
  11. package/lib/cjs/src/DefaultContextModule.test.js.map +2 -2
  12. package/lib/cjs/src/config/di/configModuleFactory.js +1 -1
  13. package/lib/cjs/src/config/di/configModuleFactory.js.map +3 -3
  14. package/lib/cjs/src/config/model/ContextModuleConfig.js +1 -1
  15. package/lib/cjs/src/config/model/ContextModuleConfig.js.map +1 -1
  16. package/lib/cjs/src/di.js +1 -1
  17. package/lib/cjs/src/di.js.map +3 -3
  18. package/lib/cjs/src/dynamic-network/data/DynamicNetworkDataSource.js +2 -0
  19. package/lib/cjs/src/dynamic-network/data/DynamicNetworkDataSource.js.map +7 -0
  20. package/lib/cjs/src/dynamic-network/data/HttpDynamicNetworkDataSource.js +2 -0
  21. package/lib/cjs/src/dynamic-network/data/HttpDynamicNetworkDataSource.js.map +7 -0
  22. package/lib/cjs/src/dynamic-network/data/HttpDynamicNetworkDataSource.test.js +2 -0
  23. package/lib/cjs/src/dynamic-network/data/HttpDynamicNetworkDataSource.test.js.map +7 -0
  24. package/lib/cjs/src/dynamic-network/data/dto/DynamicNetworkApiResponseDto.js +2 -0
  25. package/lib/cjs/src/dynamic-network/data/dto/DynamicNetworkApiResponseDto.js.map +7 -0
  26. package/lib/cjs/src/dynamic-network/di/dynamicNetworkModuleFactory.js +2 -0
  27. package/lib/cjs/src/dynamic-network/di/dynamicNetworkModuleFactory.js.map +7 -0
  28. package/lib/cjs/src/dynamic-network/di/dynamicNetworkTypes.js +2 -0
  29. package/lib/cjs/src/dynamic-network/di/dynamicNetworkTypes.js.map +7 -0
  30. package/lib/cjs/src/dynamic-network/domain/DynamicNetworkContextLoader.js +2 -0
  31. package/lib/cjs/src/dynamic-network/domain/DynamicNetworkContextLoader.js.map +7 -0
  32. package/lib/cjs/src/dynamic-network/domain/DynamicNetworkContextLoader.test.js +2 -0
  33. package/lib/cjs/src/dynamic-network/domain/DynamicNetworkContextLoader.test.js.map +7 -0
  34. package/lib/cjs/src/dynamic-network/model/DynamicNetworkConfiguration.js +2 -0
  35. package/lib/cjs/src/dynamic-network/model/DynamicNetworkConfiguration.js.map +7 -0
  36. package/lib/cjs/src/external-plugin/data/HttpExternalPluginDataSource.js +1 -1
  37. package/lib/cjs/src/external-plugin/data/HttpExternalPluginDataSource.js.map +2 -2
  38. package/lib/cjs/src/external-plugin/data/HttpExternalPluginDataSource.test.js +1 -1
  39. package/lib/cjs/src/external-plugin/data/HttpExternalPluginDataSource.test.js.map +3 -3
  40. package/lib/cjs/src/external-plugin/di/externalPluginModuleFactory.js +1 -1
  41. package/lib/cjs/src/external-plugin/di/externalPluginModuleFactory.js.map +3 -3
  42. package/lib/cjs/src/external-plugin/domain/ExternalPluginContextLoader.js +1 -1
  43. package/lib/cjs/src/external-plugin/domain/ExternalPluginContextLoader.js.map +3 -3
  44. package/lib/cjs/src/external-plugin/domain/ExternalPluginContextLoader.test.js +1 -1
  45. package/lib/cjs/src/external-plugin/domain/ExternalPluginContextLoader.test.js.map +3 -3
  46. package/lib/cjs/src/index.js +1 -1
  47. package/lib/cjs/src/index.js.map +2 -2
  48. package/lib/cjs/src/nft/data/HttpNftDataSource.js +1 -1
  49. package/lib/cjs/src/nft/data/HttpNftDataSource.js.map +3 -3
  50. package/lib/cjs/src/nft/data/HttpNftDataSource.test.js +1 -1
  51. package/lib/cjs/src/nft/data/HttpNftDataSource.test.js.map +3 -3
  52. package/lib/cjs/src/nft/di/nftModuleFactory.js +1 -1
  53. package/lib/cjs/src/nft/di/nftModuleFactory.js.map +3 -3
  54. package/lib/cjs/src/nft/domain/NftContextLoader.js +1 -1
  55. package/lib/cjs/src/nft/domain/NftContextLoader.js.map +3 -3
  56. package/lib/cjs/src/nft/domain/NftContextLoader.test.js +1 -1
  57. package/lib/cjs/src/nft/domain/NftContextLoader.test.js.map +2 -2
  58. package/lib/cjs/src/pki/di/pkiModuleFactory.js +1 -1
  59. package/lib/cjs/src/pki/di/pkiModuleFactory.js.map +3 -3
  60. package/lib/cjs/src/pki/domain/DefaultPkiCertificateLoader.js.map +2 -2
  61. package/lib/cjs/src/pki/domain/DefaultPkiCertificateLoader.test.js +1 -1
  62. package/lib/cjs/src/pki/domain/DefaultPkiCertificateLoader.test.js.map +3 -3
  63. package/lib/cjs/src/shared/constant/HttpHeaders.js +1 -1
  64. package/lib/cjs/src/shared/constant/HttpHeaders.js.map +1 -1
  65. package/lib/cjs/src/shared/model/ClearSignContext.js +1 -1
  66. package/lib/cjs/src/shared/model/ClearSignContext.js.map +2 -2
  67. package/lib/cjs/src/shared/model/SolanaTransactionContext.js +2 -0
  68. package/lib/cjs/src/shared/model/SolanaTransactionContext.js.map +7 -0
  69. package/lib/cjs/src/shared/model/TransactionSubset.js +1 -1
  70. package/lib/cjs/src/shared/model/TransactionSubset.js.map +1 -1
  71. package/lib/cjs/src/solana/data/HttpSolanaOwnerInfoDataSource.js +2 -0
  72. package/lib/cjs/src/solana/data/HttpSolanaOwnerInfoDataSource.js.map +7 -0
  73. package/lib/cjs/src/solana/data/HttpSolanaOwnerInfoDataSource.test.js +2 -0
  74. package/lib/cjs/src/solana/data/HttpSolanaOwnerInfoDataSource.test.js.map +7 -0
  75. package/lib/cjs/src/solana/data/SolanaDataSource.js +2 -0
  76. package/lib/cjs/src/solana/data/SolanaDataSource.js.map +7 -0
  77. package/lib/cjs/src/solana/di/SolanaContextModuleFactory.js +2 -0
  78. package/lib/cjs/src/solana/di/SolanaContextModuleFactory.js.map +7 -0
  79. package/lib/cjs/src/solana/di/solanaContextTypes.js +2 -0
  80. package/lib/cjs/src/solana/di/solanaContextTypes.js.map +7 -0
  81. package/lib/cjs/src/solana/domain/DefaultSolanaContextLoader.js +2 -0
  82. package/lib/cjs/src/solana/domain/DefaultSolanaContextLoader.js.map +7 -0
  83. package/lib/cjs/src/solana/domain/DefaultSolanaContextLoader.test.js +2 -0
  84. package/lib/cjs/src/solana/domain/DefaultSolanaContextLoader.test.js.map +7 -0
  85. package/lib/cjs/src/solana/domain/SolanaContextLoader.js +2 -0
  86. package/lib/cjs/src/solana/domain/SolanaContextLoader.js.map +7 -0
  87. package/lib/cjs/src/solana/domain/solanaContextTypes.js +2 -0
  88. package/lib/cjs/src/solana/domain/solanaContextTypes.js.map +7 -0
  89. package/lib/cjs/src/token/di/tokenModuleFactory.js +1 -1
  90. package/lib/cjs/src/token/di/tokenModuleFactory.js.map +3 -3
  91. package/lib/cjs/src/token/domain/TokenContextLoader.js +1 -1
  92. package/lib/cjs/src/token/domain/TokenContextLoader.js.map +3 -3
  93. package/lib/cjs/src/token/domain/TokenContextLoader.test.js +1 -1
  94. package/lib/cjs/src/token/domain/TokenContextLoader.test.js.map +2 -2
  95. package/lib/cjs/src/transaction/data/HttpProxyDataSource.js +2 -0
  96. package/lib/cjs/src/transaction/data/HttpProxyDataSource.js.map +7 -0
  97. package/lib/cjs/src/transaction/data/HttpProxyDataSource.test.js +2 -0
  98. package/lib/cjs/src/transaction/data/HttpProxyDataSource.test.js.map +7 -0
  99. package/lib/cjs/src/transaction/data/HttpTransactionDataSource.js +1 -1
  100. package/lib/cjs/src/transaction/data/HttpTransactionDataSource.js.map +2 -2
  101. package/lib/cjs/src/transaction/data/HttpTransactionDataSource.test.js +1 -1
  102. package/lib/cjs/src/transaction/data/HttpTransactionDataSource.test.js.map +3 -3
  103. package/lib/cjs/src/transaction/data/{CalldataDto.js.map → dto/CalldataDto.js.map} +1 -1
  104. package/lib/cjs/src/transaction/data/dto/ProxyDelegateCallDto.js +2 -0
  105. package/lib/cjs/src/transaction/data/dto/ProxyDelegateCallDto.js.map +7 -0
  106. package/lib/cjs/src/transaction/data/dto/ProxyImplementationAddressDto.js +2 -0
  107. package/lib/cjs/src/transaction/data/dto/ProxyImplementationAddressDto.js.map +7 -0
  108. package/lib/cjs/src/transaction/di/transactionModuleFactory.js +1 -1
  109. package/lib/cjs/src/transaction/di/transactionModuleFactory.js.map +3 -3
  110. package/lib/cjs/src/transaction/di/transactionTypes.js +1 -1
  111. package/lib/cjs/src/transaction/di/transactionTypes.js.map +2 -2
  112. package/lib/cjs/src/transaction/domain/TransactionContextLoader.js +1 -1
  113. package/lib/cjs/src/transaction/domain/TransactionContextLoader.js.map +3 -3
  114. package/lib/cjs/src/transaction/domain/TransactionContextLoader.test.js +1 -1
  115. package/lib/cjs/src/transaction/domain/TransactionContextLoader.test.js.map +3 -3
  116. package/lib/cjs/src/transaction/model/ProxyDelegateCall.js +2 -0
  117. package/lib/cjs/src/transaction/model/ProxyDelegateCall.js.map +7 -0
  118. package/lib/cjs/src/transaction/model/ProxyImplementationAddress.js +2 -0
  119. package/lib/cjs/src/transaction/model/ProxyImplementationAddress.js.map +7 -0
  120. package/lib/cjs/src/trusted-name/data/HttpTrustedNameDataSource.js +1 -1
  121. package/lib/cjs/src/trusted-name/data/HttpTrustedNameDataSource.js.map +2 -2
  122. package/lib/cjs/src/trusted-name/data/HttpTrustedNameDataSource.test.js +1 -1
  123. package/lib/cjs/src/trusted-name/data/HttpTrustedNameDataSource.test.js.map +3 -3
  124. package/lib/cjs/src/trusted-name/di/trustedNameModuleFactory.js +1 -1
  125. package/lib/cjs/src/trusted-name/di/trustedNameModuleFactory.js.map +3 -3
  126. package/lib/cjs/src/trusted-name/domain/TrustedNameContextLoader.js +1 -1
  127. package/lib/cjs/src/trusted-name/domain/TrustedNameContextLoader.js.map +3 -3
  128. package/lib/cjs/src/trusted-name/domain/TrustedNameContextLoader.test.js +1 -1
  129. package/lib/cjs/src/trusted-name/domain/TrustedNameContextLoader.test.js.map +2 -2
  130. package/lib/cjs/src/typed-data/data/HttpTypedDataDataSource.js +1 -1
  131. package/lib/cjs/src/typed-data/data/HttpTypedDataDataSource.js.map +2 -2
  132. package/lib/cjs/src/typed-data/data/HttpTypedDataDataSource.test.js +1 -1
  133. package/lib/cjs/src/typed-data/data/HttpTypedDataDataSource.test.js.map +3 -3
  134. package/lib/cjs/src/typed-data/di/typedDataModuleFactory.js +1 -1
  135. package/lib/cjs/src/typed-data/di/typedDataModuleFactory.js.map +3 -3
  136. package/lib/cjs/src/uniswap/di/uniswapModuleFactory.js +1 -1
  137. package/lib/cjs/src/uniswap/di/uniswapModuleFactory.js.map +3 -3
  138. package/lib/cjs/src/uniswap/domain/UniswapContextLoader.js +1 -1
  139. package/lib/cjs/src/uniswap/domain/UniswapContextLoader.js.map +3 -3
  140. package/lib/cjs/src/uniswap/domain/UniswapContextLoader.test.js +1 -1
  141. package/lib/cjs/src/uniswap/domain/UniswapContextLoader.test.js.map +2 -2
  142. package/lib/cjs/src/web3-check/data/HttpWeb3CheckDataSource.js +1 -1
  143. package/lib/cjs/src/web3-check/data/HttpWeb3CheckDataSource.js.map +2 -2
  144. package/lib/cjs/src/web3-check/data/HttpWeb3CheckDataSource.test.js +1 -1
  145. package/lib/cjs/src/web3-check/data/HttpWeb3CheckDataSource.test.js.map +2 -2
  146. package/lib/cjs/src/web3-check/di/web3CheckModuleFactory.js +1 -1
  147. package/lib/cjs/src/web3-check/di/web3CheckModuleFactory.js.map +3 -3
  148. package/lib/esm/package.json +2 -2
  149. package/lib/esm/src/ContextModuleBuilder.js +1 -1
  150. package/lib/esm/src/ContextModuleBuilder.js.map +3 -3
  151. package/lib/esm/src/ContextModuleBuilder.test.js +1 -1
  152. package/lib/esm/src/ContextModuleBuilder.test.js.map +3 -3
  153. package/lib/esm/src/DefaultContextModule.js +1 -1
  154. package/lib/esm/src/DefaultContextModule.js.map +3 -3
  155. package/lib/esm/src/DefaultContextModule.test.js +1 -1
  156. package/lib/esm/src/DefaultContextModule.test.js.map +2 -2
  157. package/lib/esm/src/config/di/configModuleFactory.js +1 -1
  158. package/lib/esm/src/config/di/configModuleFactory.js.map +3 -3
  159. package/lib/esm/src/di.js +1 -1
  160. package/lib/esm/src/di.js.map +3 -3
  161. package/lib/esm/src/dynamic-network/data/DynamicNetworkDataSource.js +1 -0
  162. package/lib/esm/src/dynamic-network/data/HttpDynamicNetworkDataSource.js +2 -0
  163. package/lib/esm/src/dynamic-network/data/HttpDynamicNetworkDataSource.js.map +7 -0
  164. package/lib/esm/src/dynamic-network/data/HttpDynamicNetworkDataSource.test.js +2 -0
  165. package/lib/esm/src/dynamic-network/data/HttpDynamicNetworkDataSource.test.js.map +7 -0
  166. package/lib/esm/src/dynamic-network/data/dto/DynamicNetworkApiResponseDto.js +1 -0
  167. package/lib/esm/src/dynamic-network/data/dto/DynamicNetworkApiResponseDto.js.map +7 -0
  168. package/lib/esm/src/dynamic-network/di/dynamicNetworkModuleFactory.js +2 -0
  169. package/lib/esm/src/dynamic-network/di/dynamicNetworkModuleFactory.js.map +7 -0
  170. package/lib/esm/src/dynamic-network/di/dynamicNetworkTypes.js +2 -0
  171. package/lib/esm/src/dynamic-network/di/dynamicNetworkTypes.js.map +7 -0
  172. package/lib/esm/src/dynamic-network/domain/DynamicNetworkContextLoader.js +2 -0
  173. package/lib/esm/src/dynamic-network/domain/DynamicNetworkContextLoader.js.map +7 -0
  174. package/lib/esm/src/dynamic-network/domain/DynamicNetworkContextLoader.test.js +2 -0
  175. package/lib/esm/src/dynamic-network/domain/DynamicNetworkContextLoader.test.js.map +7 -0
  176. package/lib/esm/src/dynamic-network/model/DynamicNetworkConfiguration.js +1 -0
  177. package/lib/esm/src/dynamic-network/model/DynamicNetworkConfiguration.js.map +7 -0
  178. package/lib/esm/src/external-plugin/data/HttpExternalPluginDataSource.js +1 -1
  179. package/lib/esm/src/external-plugin/data/HttpExternalPluginDataSource.js.map +3 -3
  180. package/lib/esm/src/external-plugin/data/HttpExternalPluginDataSource.test.js +1 -1
  181. package/lib/esm/src/external-plugin/data/HttpExternalPluginDataSource.test.js.map +3 -3
  182. package/lib/esm/src/external-plugin/di/externalPluginModuleFactory.js +1 -1
  183. package/lib/esm/src/external-plugin/di/externalPluginModuleFactory.js.map +3 -3
  184. package/lib/esm/src/external-plugin/domain/ExternalPluginContextLoader.js +1 -1
  185. package/lib/esm/src/external-plugin/domain/ExternalPluginContextLoader.js.map +3 -3
  186. package/lib/esm/src/external-plugin/domain/ExternalPluginContextLoader.test.js +1 -1
  187. package/lib/esm/src/external-plugin/domain/ExternalPluginContextLoader.test.js.map +3 -3
  188. package/lib/esm/src/index.js +1 -1
  189. package/lib/esm/src/index.js.map +2 -2
  190. package/lib/esm/src/nft/data/HttpNftDataSource.js +1 -1
  191. package/lib/esm/src/nft/data/HttpNftDataSource.js.map +3 -3
  192. package/lib/esm/src/nft/data/HttpNftDataSource.test.js +1 -1
  193. package/lib/esm/src/nft/data/HttpNftDataSource.test.js.map +3 -3
  194. package/lib/esm/src/nft/di/nftModuleFactory.js +1 -1
  195. package/lib/esm/src/nft/di/nftModuleFactory.js.map +3 -3
  196. package/lib/esm/src/nft/domain/NftContextLoader.js +1 -1
  197. package/lib/esm/src/nft/domain/NftContextLoader.js.map +3 -3
  198. package/lib/esm/src/nft/domain/NftContextLoader.test.js +1 -1
  199. package/lib/esm/src/nft/domain/NftContextLoader.test.js.map +2 -2
  200. package/lib/esm/src/pki/di/pkiModuleFactory.js +1 -1
  201. package/lib/esm/src/pki/di/pkiModuleFactory.js.map +3 -3
  202. package/lib/esm/src/pki/domain/DefaultPkiCertificateLoader.js.map +2 -2
  203. package/lib/esm/src/pki/domain/DefaultPkiCertificateLoader.test.js +1 -1
  204. package/lib/esm/src/pki/domain/DefaultPkiCertificateLoader.test.js.map +3 -3
  205. package/lib/esm/src/shared/constant/HttpHeaders.js +1 -1
  206. package/lib/esm/src/shared/constant/HttpHeaders.js.map +1 -1
  207. package/lib/esm/src/shared/model/ClearSignContext.js +1 -1
  208. package/lib/esm/src/shared/model/ClearSignContext.js.map +2 -2
  209. package/lib/esm/src/shared/model/SolanaTransactionContext.js +1 -0
  210. package/lib/esm/src/shared/model/SolanaTransactionContext.js.map +7 -0
  211. package/lib/esm/src/solana/data/HttpSolanaOwnerInfoDataSource.js +2 -0
  212. package/lib/esm/src/solana/data/HttpSolanaOwnerInfoDataSource.js.map +7 -0
  213. package/lib/esm/src/solana/data/HttpSolanaOwnerInfoDataSource.test.js +2 -0
  214. package/lib/esm/src/solana/data/HttpSolanaOwnerInfoDataSource.test.js.map +7 -0
  215. package/lib/esm/src/solana/data/SolanaDataSource.js +1 -0
  216. package/lib/esm/src/solana/data/SolanaDataSource.js.map +7 -0
  217. package/lib/esm/src/solana/di/SolanaContextModuleFactory.js +2 -0
  218. package/lib/esm/src/solana/di/SolanaContextModuleFactory.js.map +7 -0
  219. package/lib/esm/src/solana/di/solanaContextTypes.js +2 -0
  220. package/lib/esm/src/solana/di/solanaContextTypes.js.map +7 -0
  221. package/lib/esm/src/solana/domain/DefaultSolanaContextLoader.js +2 -0
  222. package/lib/esm/src/solana/domain/DefaultSolanaContextLoader.js.map +7 -0
  223. package/lib/esm/src/solana/domain/DefaultSolanaContextLoader.test.js +2 -0
  224. package/lib/esm/src/solana/domain/DefaultSolanaContextLoader.test.js.map +7 -0
  225. package/lib/esm/src/solana/domain/SolanaContextLoader.js +1 -0
  226. package/lib/esm/src/solana/domain/SolanaContextLoader.js.map +7 -0
  227. package/lib/esm/src/solana/domain/solanaContextTypes.js +1 -0
  228. package/lib/esm/src/solana/domain/solanaContextTypes.js.map +7 -0
  229. package/lib/esm/src/token/di/tokenModuleFactory.js +1 -1
  230. package/lib/esm/src/token/di/tokenModuleFactory.js.map +3 -3
  231. package/lib/esm/src/token/domain/TokenContextLoader.js +1 -1
  232. package/lib/esm/src/token/domain/TokenContextLoader.js.map +3 -3
  233. package/lib/esm/src/token/domain/TokenContextLoader.test.js +1 -1
  234. package/lib/esm/src/token/domain/TokenContextLoader.test.js.map +2 -2
  235. package/lib/esm/src/transaction/data/HttpProxyDataSource.js +2 -0
  236. package/lib/esm/src/transaction/data/HttpProxyDataSource.js.map +7 -0
  237. package/lib/esm/src/transaction/data/HttpProxyDataSource.test.js +2 -0
  238. package/lib/esm/src/transaction/data/HttpProxyDataSource.test.js.map +7 -0
  239. package/lib/esm/src/transaction/data/HttpTransactionDataSource.js +1 -1
  240. package/lib/esm/src/transaction/data/HttpTransactionDataSource.js.map +3 -3
  241. package/lib/esm/src/transaction/data/HttpTransactionDataSource.test.js +1 -1
  242. package/lib/esm/src/transaction/data/HttpTransactionDataSource.test.js.map +3 -3
  243. package/lib/esm/src/transaction/data/dto/CalldataDto.js.map +7 -0
  244. package/lib/esm/src/transaction/data/dto/ProxyDelegateCallDto.js +1 -0
  245. package/lib/esm/src/transaction/data/dto/ProxyDelegateCallDto.js.map +7 -0
  246. package/lib/esm/src/transaction/data/dto/ProxyImplementationAddressDto.js +1 -0
  247. package/lib/esm/src/transaction/data/dto/ProxyImplementationAddressDto.js.map +7 -0
  248. package/lib/esm/src/transaction/di/transactionModuleFactory.js +1 -1
  249. package/lib/esm/src/transaction/di/transactionModuleFactory.js.map +3 -3
  250. package/lib/esm/src/transaction/di/transactionTypes.js +1 -1
  251. package/lib/esm/src/transaction/di/transactionTypes.js.map +2 -2
  252. package/lib/esm/src/transaction/domain/TransactionContextLoader.js +1 -1
  253. package/lib/esm/src/transaction/domain/TransactionContextLoader.js.map +3 -3
  254. package/lib/esm/src/transaction/domain/TransactionContextLoader.test.js +1 -1
  255. package/lib/esm/src/transaction/domain/TransactionContextLoader.test.js.map +3 -3
  256. package/lib/esm/src/transaction/model/ProxyDelegateCall.js +1 -0
  257. package/lib/esm/src/transaction/model/ProxyDelegateCall.js.map +7 -0
  258. package/lib/esm/src/transaction/model/ProxyImplementationAddress.js +1 -0
  259. package/lib/esm/src/transaction/model/ProxyImplementationAddress.js.map +7 -0
  260. package/lib/esm/src/trusted-name/data/HttpTrustedNameDataSource.js +1 -1
  261. package/lib/esm/src/trusted-name/data/HttpTrustedNameDataSource.js.map +3 -3
  262. package/lib/esm/src/trusted-name/data/HttpTrustedNameDataSource.test.js +1 -1
  263. package/lib/esm/src/trusted-name/data/HttpTrustedNameDataSource.test.js.map +3 -3
  264. package/lib/esm/src/trusted-name/di/trustedNameModuleFactory.js +1 -1
  265. package/lib/esm/src/trusted-name/di/trustedNameModuleFactory.js.map +3 -3
  266. package/lib/esm/src/trusted-name/domain/TrustedNameContextLoader.js +1 -1
  267. package/lib/esm/src/trusted-name/domain/TrustedNameContextLoader.js.map +3 -3
  268. package/lib/esm/src/trusted-name/domain/TrustedNameContextLoader.test.js +1 -1
  269. package/lib/esm/src/trusted-name/domain/TrustedNameContextLoader.test.js.map +2 -2
  270. package/lib/esm/src/typed-data/data/HttpTypedDataDataSource.js +1 -1
  271. package/lib/esm/src/typed-data/data/HttpTypedDataDataSource.js.map +3 -3
  272. package/lib/esm/src/typed-data/data/HttpTypedDataDataSource.test.js +1 -1
  273. package/lib/esm/src/typed-data/data/HttpTypedDataDataSource.test.js.map +3 -3
  274. package/lib/esm/src/typed-data/di/typedDataModuleFactory.js +1 -1
  275. package/lib/esm/src/typed-data/di/typedDataModuleFactory.js.map +3 -3
  276. package/lib/esm/src/uniswap/di/uniswapModuleFactory.js +1 -1
  277. package/lib/esm/src/uniswap/di/uniswapModuleFactory.js.map +3 -3
  278. package/lib/esm/src/uniswap/domain/UniswapContextLoader.js +1 -1
  279. package/lib/esm/src/uniswap/domain/UniswapContextLoader.js.map +3 -3
  280. package/lib/esm/src/uniswap/domain/UniswapContextLoader.test.js +1 -1
  281. package/lib/esm/src/uniswap/domain/UniswapContextLoader.test.js.map +2 -2
  282. package/lib/esm/src/web3-check/data/HttpWeb3CheckDataSource.js +1 -1
  283. package/lib/esm/src/web3-check/data/HttpWeb3CheckDataSource.js.map +3 -3
  284. package/lib/esm/src/web3-check/data/HttpWeb3CheckDataSource.test.js +1 -1
  285. package/lib/esm/src/web3-check/data/HttpWeb3CheckDataSource.test.js.map +3 -3
  286. package/lib/esm/src/web3-check/di/web3CheckModuleFactory.js +1 -1
  287. package/lib/esm/src/web3-check/di/web3CheckModuleFactory.js.map +3 -3
  288. package/lib/types/src/ContextModule.d.ts +3 -0
  289. package/lib/types/src/ContextModule.d.ts.map +1 -1
  290. package/lib/types/src/ContextModuleBuilder.d.ts +18 -3
  291. package/lib/types/src/ContextModuleBuilder.d.ts.map +1 -1
  292. package/lib/types/src/DefaultContextModule.d.ts +5 -0
  293. package/lib/types/src/DefaultContextModule.d.ts.map +1 -1
  294. package/lib/types/src/config/di/configModuleFactory.d.ts.map +1 -1
  295. package/lib/types/src/config/model/ContextModuleConfig.d.ts +6 -0
  296. package/lib/types/src/config/model/ContextModuleConfig.d.ts.map +1 -1
  297. package/lib/types/src/di.d.ts.map +1 -1
  298. package/lib/types/src/dynamic-network/data/DynamicNetworkDataSource.d.ts +6 -0
  299. package/lib/types/src/dynamic-network/data/DynamicNetworkDataSource.d.ts.map +1 -0
  300. package/lib/types/src/dynamic-network/data/HttpDynamicNetworkDataSource.d.ts +13 -0
  301. package/lib/types/src/dynamic-network/data/HttpDynamicNetworkDataSource.d.ts.map +1 -0
  302. package/lib/types/src/dynamic-network/data/HttpDynamicNetworkDataSource.test.d.ts +2 -0
  303. package/lib/types/src/dynamic-network/data/HttpDynamicNetworkDataSource.test.d.ts.map +1 -0
  304. package/lib/types/src/dynamic-network/data/dto/DynamicNetworkApiResponseDto.d.ts +14 -0
  305. package/lib/types/src/dynamic-network/data/dto/DynamicNetworkApiResponseDto.d.ts.map +1 -0
  306. package/lib/types/src/dynamic-network/di/dynamicNetworkModuleFactory.d.ts +3 -0
  307. package/lib/types/src/dynamic-network/di/dynamicNetworkModuleFactory.d.ts.map +1 -0
  308. package/lib/types/src/dynamic-network/di/dynamicNetworkTypes.d.ts +5 -0
  309. package/lib/types/src/dynamic-network/di/dynamicNetworkTypes.d.ts.map +1 -0
  310. package/lib/types/src/dynamic-network/domain/DynamicNetworkContextLoader.d.ts +15 -0
  311. package/lib/types/src/dynamic-network/domain/DynamicNetworkContextLoader.d.ts.map +1 -0
  312. package/lib/types/src/dynamic-network/domain/DynamicNetworkContextLoader.test.d.ts +2 -0
  313. package/lib/types/src/dynamic-network/domain/DynamicNetworkContextLoader.test.d.ts.map +1 -0
  314. package/lib/types/src/dynamic-network/model/DynamicNetworkConfiguration.d.ts +16 -0
  315. package/lib/types/src/dynamic-network/model/DynamicNetworkConfiguration.d.ts.map +1 -0
  316. package/lib/types/src/external-plugin/data/HttpExternalPluginDataSource.d.ts.map +1 -1
  317. package/lib/types/src/external-plugin/domain/ExternalPluginContextLoader.d.ts +1 -1
  318. package/lib/types/src/external-plugin/domain/ExternalPluginContextLoader.d.ts.map +1 -1
  319. package/lib/types/src/index.d.ts +2 -0
  320. package/lib/types/src/index.d.ts.map +1 -1
  321. package/lib/types/src/nft/data/HttpNftDataSource.d.ts +3 -0
  322. package/lib/types/src/nft/data/HttpNftDataSource.d.ts.map +1 -1
  323. package/lib/types/src/nft/domain/NftContextLoader.d.ts +1 -1
  324. package/lib/types/src/nft/domain/NftContextLoader.d.ts.map +1 -1
  325. package/lib/types/src/pki/domain/DefaultPkiCertificateLoader.d.ts.map +1 -1
  326. package/lib/types/src/shared/constant/HttpHeaders.d.ts +1 -1
  327. package/lib/types/src/shared/constant/HttpHeaders.d.ts.map +1 -1
  328. package/lib/types/src/shared/model/ClearSignContext.d.ts +3 -0
  329. package/lib/types/src/shared/model/ClearSignContext.d.ts.map +1 -1
  330. package/lib/types/src/shared/model/SolanaTransactionContext.d.ts +11 -0
  331. package/lib/types/src/shared/model/SolanaTransactionContext.d.ts.map +1 -0
  332. package/lib/types/src/shared/model/TransactionSubset.d.ts +3 -3
  333. package/lib/types/src/shared/model/TransactionSubset.d.ts.map +1 -1
  334. package/lib/types/src/solana/data/HttpSolanaOwnerInfoDataSource.d.ts +13 -0
  335. package/lib/types/src/solana/data/HttpSolanaOwnerInfoDataSource.d.ts.map +1 -0
  336. package/lib/types/src/solana/data/HttpSolanaOwnerInfoDataSource.test.d.ts +2 -0
  337. package/lib/types/src/solana/data/HttpSolanaOwnerInfoDataSource.test.d.ts.map +1 -0
  338. package/lib/types/src/solana/data/SolanaDataSource.d.ts +12 -0
  339. package/lib/types/src/solana/data/SolanaDataSource.d.ts.map +1 -0
  340. package/lib/types/src/solana/di/SolanaContextModuleFactory.d.ts +3 -0
  341. package/lib/types/src/solana/di/SolanaContextModuleFactory.d.ts.map +1 -0
  342. package/lib/types/src/solana/di/solanaContextTypes.d.ts +5 -0
  343. package/lib/types/src/solana/di/solanaContextTypes.d.ts.map +1 -0
  344. package/lib/types/src/solana/domain/DefaultSolanaContextLoader.d.ts +11 -0
  345. package/lib/types/src/solana/domain/DefaultSolanaContextLoader.d.ts.map +1 -0
  346. package/lib/types/src/solana/domain/DefaultSolanaContextLoader.test.d.ts +2 -0
  347. package/lib/types/src/solana/domain/DefaultSolanaContextLoader.test.d.ts.map +1 -0
  348. package/lib/types/src/solana/domain/SolanaContextLoader.d.ts +5 -0
  349. package/lib/types/src/solana/domain/SolanaContextLoader.d.ts.map +1 -0
  350. package/lib/types/src/solana/domain/solanaContextTypes.d.ts +27 -0
  351. package/lib/types/src/solana/domain/solanaContextTypes.d.ts.map +1 -0
  352. package/lib/types/src/token/domain/TokenContextLoader.d.ts +1 -1
  353. package/lib/types/src/token/domain/TokenContextLoader.d.ts.map +1 -1
  354. package/lib/types/src/transaction/data/HttpProxyDataSource.d.ts +33 -0
  355. package/lib/types/src/transaction/data/HttpProxyDataSource.d.ts.map +1 -0
  356. package/lib/types/src/transaction/data/HttpProxyDataSource.test.d.ts +2 -0
  357. package/lib/types/src/transaction/data/HttpProxyDataSource.test.d.ts.map +1 -0
  358. package/lib/types/src/transaction/data/HttpTransactionDataSource.d.ts.map +1 -1
  359. package/lib/types/src/transaction/data/dto/CalldataDto.d.ts.map +1 -0
  360. package/lib/types/src/transaction/data/dto/ProxyDelegateCallDto.d.ts +5 -0
  361. package/lib/types/src/transaction/data/dto/ProxyDelegateCallDto.d.ts.map +1 -0
  362. package/lib/types/src/transaction/data/dto/ProxyImplementationAddressDto.d.ts +6 -0
  363. package/lib/types/src/transaction/data/dto/ProxyImplementationAddressDto.d.ts.map +1 -0
  364. package/lib/types/src/transaction/di/transactionModuleFactory.d.ts.map +1 -1
  365. package/lib/types/src/transaction/di/transactionTypes.d.ts +1 -0
  366. package/lib/types/src/transaction/di/transactionTypes.d.ts.map +1 -1
  367. package/lib/types/src/transaction/domain/TransactionContextLoader.d.ts +4 -2
  368. package/lib/types/src/transaction/domain/TransactionContextLoader.d.ts.map +1 -1
  369. package/lib/types/src/transaction/model/ProxyDelegateCall.d.ts +5 -0
  370. package/lib/types/src/transaction/model/ProxyDelegateCall.d.ts.map +1 -0
  371. package/lib/types/src/transaction/model/ProxyImplementationAddress.d.ts +4 -0
  372. package/lib/types/src/transaction/model/ProxyImplementationAddress.d.ts.map +1 -0
  373. package/lib/types/src/trusted-name/data/HttpTrustedNameDataSource.d.ts.map +1 -1
  374. package/lib/types/src/trusted-name/domain/TrustedNameContextLoader.d.ts +1 -1
  375. package/lib/types/src/trusted-name/domain/TrustedNameContextLoader.d.ts.map +1 -1
  376. package/lib/types/src/typed-data/data/HttpTypedDataDataSource.d.ts.map +1 -1
  377. package/lib/types/src/typed-data/data/HttpTypedDataDataSource.test.d.ts.map +1 -1
  378. package/lib/types/src/uniswap/domain/UniswapContextLoader.d.ts +1 -1
  379. package/lib/types/src/uniswap/domain/UniswapContextLoader.d.ts.map +1 -1
  380. package/lib/types/src/web3-check/data/HttpWeb3CheckDataSource.d.ts.map +1 -1
  381. package/lib/types/tsconfig.prod.tsbuildinfo +1 -1
  382. package/package.json +6 -6
  383. package/lib/types/src/transaction/data/CalldataDto.d.ts.map +0 -1
  384. /package/lib/cjs/src/transaction/data/{CalldataDto.js → dto/CalldataDto.js} +0 -0
  385. /package/lib/esm/src/{transaction/data/CalldataDto.js.map → dynamic-network/data/DynamicNetworkDataSource.js.map} +0 -0
  386. /package/lib/esm/src/transaction/data/{CalldataDto.js → dto/CalldataDto.js} +0 -0
  387. /package/lib/types/src/transaction/data/{CalldataDto.d.ts → dto/CalldataDto.d.ts} +0 -0
@@ -1,2 +1,2 @@
1
- import{configTypes as i}from"./config/di/configTypes";import{ContextModuleBuilder as n}from"./ContextModuleBuilder";import{DefaultContextModule as r}from"./DefaultContextModule";describe("ContextModuleBuilder",()=>{const c={url:"https://cal/v1",mode:"prod",branch:"main"},u={url:"https://web3checks/v1"},d={originToken:"test"};it("should return a default context module",()=>{const o=new n(d).build();expect(o).toBeInstanceOf(r)}),it("should return a custom context module",()=>{const e=new n(d),o={load:vi.fn()},t=e.removeDefaultLoaders().addLoader(o).build();expect(t).toBeInstanceOf(r)}),it("should return a custom context module with a custom typed data loader",()=>{const e=new n(d),o={load:vi.fn()},t=e.removeDefaultLoaders().addTypedDataLoader(o).build();expect(t).toBeInstanceOf(r),expect(t._typedDataLoader).toBe(o)}),it("should return a custom context module with a custom config",()=>{const o=new n(d).addCalConfig(c).addWeb3ChecksConfig(u).build(),t=o._container.get(i.Config);expect(o).toBeInstanceOf(r),expect(t.cal).toEqual(c),expect(t.web3checks).toEqual(u)}),it("should return a custom context module with a custom custom web3checks loader",()=>{const e=new n,o={load:vi.fn()},t=e.removeDefaultLoaders().addWeb3CheckLoader(o).build();expect(t).toBeInstanceOf(r),expect(t._web3CheckLoader).toBe(o)}),it("should throw an error if origin token is not provided",()=>{const e=new n;expect(()=>e.build()).toThrow("Origin token is required")}),it("should not throw an error if origin token is provided",()=>{const e=new n(d);expect(()=>e.build()).not.toThrow()}),it("should not throw an error if origin token is not provided and addWeb3CheckLoader is called",()=>{const e=new n;expect(()=>e.addWeb3CheckLoader({load:vi.fn()}).build()).not.toThrow()})});
1
+ import{configTypes as s}from"./config/di/configTypes";import{ContextModuleBuilder as c}from"./ContextModuleBuilder";import{DefaultContextModule as r}from"./DefaultContextModule";describe("ContextModuleBuilder",()=>{const d={url:"https://cal/v1",mode:"prod",branch:"main"},a={url:"https://web3checks/v1"},i={originToken:"test"};beforeEach(()=>{vi.resetAllMocks()}),it("should return a default context module",()=>{const e=new c(i).build();expect(e).toBeInstanceOf(r)}),it("should return a custom context module",()=>{const t=new c(i),e={load:vi.fn()},o=t.removeDefaultLoaders().addLoader(e).build();expect(o).toBeInstanceOf(r)}),it("should return a custom context module with a custom typed data loader",()=>{const t=new c(i),e={load:vi.fn()},o=t.removeDefaultLoaders().addTypedDataLoader(e).build();expect(o).toBeInstanceOf(r),expect(o._typedDataLoader).toBe(e)}),it("should return a custom context module with a custom config",()=>{const e=new c(i).setCalConfig(d).setWeb3ChecksConfig(a).build(),o=e._container.get(s.Config);expect(e).toBeInstanceOf(r),expect(o.cal).toEqual(d),expect(o.web3checks).toEqual(a)}),it("should return a custom context module with a custom custom web3checks loader",()=>{const t=new c,e={load:vi.fn()},o=t.removeDefaultLoaders().addWeb3CheckLoader(e).build();expect(o).toBeInstanceOf(r),expect(o._web3CheckLoader).toBe(e)}),it("should throw an error if origin token is not provided",()=>{const t=new c;expect(()=>t.build()).toThrow("Origin token is required")}),it("should not throw an error if origin token is provided",()=>{const t=new c(i);expect(()=>t.build()).not.toThrow()}),it("should not throw an error if origin token is not provided and addWeb3CheckLoader is called",()=>{const t=new c;expect(()=>t.addWeb3CheckLoader({load:vi.fn()}).build()).not.toThrow()}),describe("setMetadataServiceConfig",()=>{it("should set the metadata service configuration",()=>{const t=new c(i),e={url:"https://custom-metadata-service.com/v3"},o=t.setMetadataServiceConfig(e).build(),n=o._container.get(s.Config);expect(o).toBeInstanceOf(r),expect(n.metadataServiceDomain).toEqual(e)}),it("should override the default metadata service configuration",()=>{const t=new c(i),e={url:"https://override-metadata-service.com/v1"},n=t.setMetadataServiceConfig(e).build()._container.get(s.Config);expect(n.metadataServiceDomain.url).toBe(e.url),expect(n.metadataServiceDomain.url).not.toBe("https://nft.api.live.ledger.com/v2")})}),describe("setCalConfig",()=>{it("should set the CAL configuration",()=>{const t=new c(i),e={url:"https://custom-cal-service.com/v2",mode:"test",branch:"next"},o=t.setCalConfig(e).build(),n=o._container.get(s.Config);expect(o).toBeInstanceOf(r),expect(n.cal).toEqual(e)}),it("should override the default CAL configuration",()=>{const t=new c(i),e={url:"https://override-cal-service.com/v1",mode:"prod",branch:"demo"},n=t.setCalConfig(e).build()._container.get(s.Config);expect(n.cal.url).toBe(e.url),expect(n.cal.mode).toBe(e.mode),expect(n.cal.branch).toBe(e.branch),expect(n.cal.url).not.toBe("https://crypto-assets-service.api.ledger.com/v1")})}),describe("setWeb3ChecksConfig",()=>{it("should set the web3 checks configuration",()=>{const t=new c(i),e={url:"https://custom-web3checks-service.com/v4"},o=t.setWeb3ChecksConfig(e).build(),n=o._container.get(s.Config);expect(o).toBeInstanceOf(r),expect(n.web3checks).toEqual(e)}),it("should override the default web3 checks configuration",()=>{const t=new c(i),e={url:"https://override-web3checks-service.com/v2"},n=t.setWeb3ChecksConfig(e).build()._container.get(s.Config);expect(n.web3checks.url).toBe(e.url),expect(n.web3checks.url).not.toBe("https://web3checks-backend.api.ledger.com/v3")})})});
2
2
  //# sourceMappingURL=ContextModuleBuilder.test.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../src/ContextModuleBuilder.test.ts"],
4
- "sourcesContent": ["import { type Container } from \"inversify\";\n\nimport { configTypes } from \"./config/di/configTypes\";\nimport { type ContextModuleConstructorArgs } from \"./config/model/ContextModuleBuildArgs\";\nimport {\n type ContextModuleCalConfig,\n type ContextModuleConfig,\n} from \"./config/model/ContextModuleConfig\";\nimport { ContextModuleBuilder } from \"./ContextModuleBuilder\";\nimport { DefaultContextModule } from \"./DefaultContextModule\";\n\ndescribe(\"ContextModuleBuilder\", () => {\n const defaultCalConfig: ContextModuleCalConfig = {\n url: \"https://cal/v1\",\n mode: \"prod\",\n branch: \"main\",\n };\n const defaultWeb3ChecksConfig = {\n url: \"https://web3checks/v1\",\n };\n const defaultBuilderArgs: ContextModuleConstructorArgs = {\n originToken: \"test\",\n };\n it(\"should return a default context module\", () => {\n const contextModuleBuilder = new ContextModuleBuilder(defaultBuilderArgs);\n\n const res = contextModuleBuilder.build();\n\n expect(res).toBeInstanceOf(DefaultContextModule);\n });\n\n it(\"should return a custom context module\", () => {\n const contextModuleBuilder = new ContextModuleBuilder(defaultBuilderArgs);\n const customLoader = { load: vi.fn() };\n\n const res = contextModuleBuilder\n .removeDefaultLoaders()\n .addLoader(customLoader)\n .build();\n\n expect(res).toBeInstanceOf(DefaultContextModule);\n });\n\n it(\"should return a custom context module with a custom typed data loader\", () => {\n const contextModuleBuilder = new ContextModuleBuilder(defaultBuilderArgs);\n const customLoader = { load: vi.fn() };\n\n const res = contextModuleBuilder\n .removeDefaultLoaders()\n .addTypedDataLoader(customLoader)\n .build();\n\n expect(res).toBeInstanceOf(DefaultContextModule);\n // @ts-expect-error _typedDataLoader is private\n expect(res[\"_typedDataLoader\"]).toBe(customLoader);\n });\n\n it(\"should return a custom context module with a custom config\", () => {\n const contextModuleBuilder = new ContextModuleBuilder(defaultBuilderArgs);\n\n const res = contextModuleBuilder\n .addCalConfig(defaultCalConfig)\n .addWeb3ChecksConfig(defaultWeb3ChecksConfig)\n .build();\n // @ts-expect-error _container is private\n const config = (res[\"_container\"] as Container).get<ContextModuleConfig>(\n configTypes.Config,\n );\n\n expect(res).toBeInstanceOf(DefaultContextModule);\n expect(config.cal).toEqual(defaultCalConfig);\n expect(config.web3checks).toEqual(defaultWeb3ChecksConfig);\n });\n\n it(\"should return a custom context module with a custom custom web3checks loader\", () => {\n const contextModuleBuilder = new ContextModuleBuilder();\n const customLoader = { load: vi.fn() };\n\n const res = contextModuleBuilder\n .removeDefaultLoaders()\n .addWeb3CheckLoader(customLoader)\n .build();\n\n expect(res).toBeInstanceOf(DefaultContextModule);\n // @ts-expect-error _web3CheckLoader is private\n expect(res[\"_web3CheckLoader\"]).toBe(customLoader);\n });\n\n it(\"should throw an error if origin token is not provided\", () => {\n const contextModuleBuilder = new ContextModuleBuilder();\n\n expect(() => contextModuleBuilder.build()).toThrow(\n \"Origin token is required\",\n );\n });\n\n it(\"should not throw an error if origin token is provided\", () => {\n const contextModuleBuilder = new ContextModuleBuilder(defaultBuilderArgs);\n\n expect(() => contextModuleBuilder.build()).not.toThrow();\n });\n\n it(\"should not throw an error if origin token is not provided and addWeb3CheckLoader is called\", () => {\n const contextModuleBuilder = new ContextModuleBuilder();\n\n expect(() =>\n contextModuleBuilder.addWeb3CheckLoader({ load: vi.fn() }).build(),\n ).not.toThrow();\n });\n});\n"],
5
- "mappings": "AAEA,OAAS,eAAAA,MAAmB,0BAM5B,OAAS,wBAAAC,MAA4B,yBACrC,OAAS,wBAAAC,MAA4B,yBAErC,SAAS,uBAAwB,IAAM,CACrC,MAAMC,EAA2C,CAC/C,IAAK,iBACL,KAAM,OACN,OAAQ,MACV,EACMC,EAA0B,CAC9B,IAAK,uBACP,EACMC,EAAmD,CACvD,YAAa,MACf,EACA,GAAG,yCAA0C,IAAM,CAGjD,MAAMC,EAFuB,IAAIL,EAAqBI,CAAkB,EAEvC,MAAM,EAEvC,OAAOC,CAAG,EAAE,eAAeJ,CAAoB,CACjD,CAAC,EAED,GAAG,wCAAyC,IAAM,CAChD,MAAMK,EAAuB,IAAIN,EAAqBI,CAAkB,EAClEG,EAAe,CAAE,KAAM,GAAG,GAAG,CAAE,EAE/BF,EAAMC,EACT,qBAAqB,EACrB,UAAUC,CAAY,EACtB,MAAM,EAET,OAAOF,CAAG,EAAE,eAAeJ,CAAoB,CACjD,CAAC,EAED,GAAG,wEAAyE,IAAM,CAChF,MAAMK,EAAuB,IAAIN,EAAqBI,CAAkB,EAClEG,EAAe,CAAE,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"ContextModuleBuilder", "DefaultContextModule", "defaultCalConfig", "defaultWeb3ChecksConfig", "defaultBuilderArgs", "res", "contextModuleBuilder", "customLoader", "config"]
4
+ "sourcesContent": ["import { type Container } from \"inversify\";\n\nimport { configTypes } from \"./config/di/configTypes\";\nimport { type ContextModuleConstructorArgs } from \"./config/model/ContextModuleBuildArgs\";\nimport {\n type ContextModuleCalConfig,\n type ContextModuleConfig,\n type ContextModuleMetadataServiceConfig,\n} from \"./config/model/ContextModuleConfig\";\nimport { ContextModuleBuilder } from \"./ContextModuleBuilder\";\nimport { DefaultContextModule } from \"./DefaultContextModule\";\n\ndescribe(\"ContextModuleBuilder\", () => {\n const defaultCalConfig: ContextModuleCalConfig = {\n url: \"https://cal/v1\",\n mode: \"prod\",\n branch: \"main\",\n };\n const defaultWeb3ChecksConfig = {\n url: \"https://web3checks/v1\",\n };\n const defaultBuilderArgs: ContextModuleConstructorArgs = {\n originToken: \"test\",\n };\n\n beforeEach(() => {\n vi.resetAllMocks();\n });\n\n it(\"should return a default context module\", () => {\n const contextModuleBuilder = new ContextModuleBuilder(defaultBuilderArgs);\n\n const res = contextModuleBuilder.build();\n\n expect(res).toBeInstanceOf(DefaultContextModule);\n });\n\n it(\"should return a custom context module\", () => {\n const contextModuleBuilder = new ContextModuleBuilder(defaultBuilderArgs);\n const customLoader = { load: vi.fn() };\n\n const res = contextModuleBuilder\n .removeDefaultLoaders()\n .addLoader(customLoader)\n .build();\n\n expect(res).toBeInstanceOf(DefaultContextModule);\n });\n\n it(\"should return a custom context module with a custom typed data loader\", () => {\n const contextModuleBuilder = new ContextModuleBuilder(defaultBuilderArgs);\n const customLoader = { load: vi.fn() };\n\n const res = contextModuleBuilder\n .removeDefaultLoaders()\n .addTypedDataLoader(customLoader)\n .build();\n\n expect(res).toBeInstanceOf(DefaultContextModule);\n // @ts-expect-error _typedDataLoader is private\n expect(res[\"_typedDataLoader\"]).toBe(customLoader);\n });\n\n it(\"should return a custom context module with a custom config\", () => {\n const contextModuleBuilder = new ContextModuleBuilder(defaultBuilderArgs);\n\n const res = contextModuleBuilder\n .setCalConfig(defaultCalConfig)\n .setWeb3ChecksConfig(defaultWeb3ChecksConfig)\n .build();\n // @ts-expect-error _container is private\n const config = (res[\"_container\"] as Container).get<ContextModuleConfig>(\n configTypes.Config,\n );\n\n expect(res).toBeInstanceOf(DefaultContextModule);\n expect(config.cal).toEqual(defaultCalConfig);\n expect(config.web3checks).toEqual(defaultWeb3ChecksConfig);\n });\n\n it(\"should return a custom context module with a custom custom web3checks loader\", () => {\n const contextModuleBuilder = new ContextModuleBuilder();\n const customLoader = { load: vi.fn() };\n\n const res = contextModuleBuilder\n .removeDefaultLoaders()\n .addWeb3CheckLoader(customLoader)\n .build();\n\n expect(res).toBeInstanceOf(DefaultContextModule);\n // @ts-expect-error _web3CheckLoader is private\n expect(res[\"_web3CheckLoader\"]).toBe(customLoader);\n });\n\n it(\"should throw an error if origin token is not provided\", () => {\n const contextModuleBuilder = new ContextModuleBuilder();\n\n expect(() => contextModuleBuilder.build()).toThrow(\n \"Origin token is required\",\n );\n });\n\n it(\"should not throw an error if origin token is provided\", () => {\n const contextModuleBuilder = new ContextModuleBuilder(defaultBuilderArgs);\n\n expect(() => contextModuleBuilder.build()).not.toThrow();\n });\n\n it(\"should not throw an error if origin token is not provided and addWeb3CheckLoader is called\", () => {\n const contextModuleBuilder = new ContextModuleBuilder();\n\n expect(() =>\n contextModuleBuilder.addWeb3CheckLoader({ load: vi.fn() }).build(),\n ).not.toThrow();\n });\n\n describe(\"setMetadataServiceConfig\", () => {\n it(\"should set the metadata service configuration\", () => {\n const contextModuleBuilder = new ContextModuleBuilder(defaultBuilderArgs);\n const customMetadataConfig: ContextModuleMetadataServiceConfig = {\n url: \"https://custom-metadata-service.com/v3\",\n };\n\n const res = contextModuleBuilder\n .setMetadataServiceConfig(customMetadataConfig)\n .build();\n const config = (res as DefaultContextModule)[\n \"_container\"\n ].get<ContextModuleConfig>(configTypes.Config);\n\n expect(res).toBeInstanceOf(DefaultContextModule);\n expect(config.metadataServiceDomain).toEqual(customMetadataConfig);\n });\n\n it(\"should override the default metadata service configuration\", () => {\n const contextModuleBuilder = new ContextModuleBuilder(defaultBuilderArgs);\n const customMetadataConfig: ContextModuleMetadataServiceConfig = {\n url: \"https://override-metadata-service.com/v1\",\n };\n\n const res = contextModuleBuilder\n .setMetadataServiceConfig(customMetadataConfig)\n .build();\n const config = (res as DefaultContextModule)[\n \"_container\"\n ].get<ContextModuleConfig>(configTypes.Config);\n\n expect(config.metadataServiceDomain.url).toBe(customMetadataConfig.url);\n expect(config.metadataServiceDomain.url).not.toBe(\n \"https://nft.api.live.ledger.com/v2\",\n );\n });\n });\n\n describe(\"setCalConfig\", () => {\n it(\"should set the CAL configuration\", () => {\n const contextModuleBuilder = new ContextModuleBuilder(defaultBuilderArgs);\n const customCalConfig: ContextModuleCalConfig = {\n url: \"https://custom-cal-service.com/v2\",\n mode: \"test\",\n branch: \"next\",\n };\n\n const res = contextModuleBuilder.setCalConfig(customCalConfig).build();\n const config = (res as DefaultContextModule)[\n \"_container\"\n ].get<ContextModuleConfig>(configTypes.Config);\n\n expect(res).toBeInstanceOf(DefaultContextModule);\n expect(config.cal).toEqual(customCalConfig);\n });\n\n it(\"should override the default CAL configuration\", () => {\n const contextModuleBuilder = new ContextModuleBuilder(defaultBuilderArgs);\n const customCalConfig: ContextModuleCalConfig = {\n url: \"https://override-cal-service.com/v1\",\n mode: \"prod\",\n branch: \"demo\",\n };\n\n const res = contextModuleBuilder.setCalConfig(customCalConfig).build();\n const config = (res as DefaultContextModule)[\n \"_container\"\n ].get<ContextModuleConfig>(configTypes.Config);\n\n expect(config.cal.url).toBe(customCalConfig.url);\n expect(config.cal.mode).toBe(customCalConfig.mode);\n expect(config.cal.branch).toBe(customCalConfig.branch);\n expect(config.cal.url).not.toBe(\n \"https://crypto-assets-service.api.ledger.com/v1\",\n );\n });\n });\n\n describe(\"setWeb3ChecksConfig\", () => {\n it(\"should set the web3 checks configuration\", () => {\n const contextModuleBuilder = new ContextModuleBuilder(defaultBuilderArgs);\n const customWeb3ChecksConfig = {\n url: \"https://custom-web3checks-service.com/v4\",\n };\n\n const res = contextModuleBuilder\n .setWeb3ChecksConfig(customWeb3ChecksConfig)\n .build();\n const config = (res as DefaultContextModule)[\n \"_container\"\n ].get<ContextModuleConfig>(configTypes.Config);\n\n expect(res).toBeInstanceOf(DefaultContextModule);\n expect(config.web3checks).toEqual(customWeb3ChecksConfig);\n });\n\n it(\"should override the default web3 checks configuration\", () => {\n const contextModuleBuilder = new ContextModuleBuilder(defaultBuilderArgs);\n const customWeb3ChecksConfig = {\n url: \"https://override-web3checks-service.com/v2\",\n };\n\n const res = contextModuleBuilder\n .setWeb3ChecksConfig(customWeb3ChecksConfig)\n .build();\n const config = (res as DefaultContextModule)[\n \"_container\"\n ].get<ContextModuleConfig>(configTypes.Config);\n\n expect(config.web3checks.url).toBe(customWeb3ChecksConfig.url);\n expect(config.web3checks.url).not.toBe(\n \"https://web3checks-backend.api.ledger.com/v3\",\n );\n });\n });\n});\n"],
5
+ "mappings": "AAEA,OAAS,eAAAA,MAAmB,0BAO5B,OAAS,wBAAAC,MAA4B,yBACrC,OAAS,wBAAAC,MAA4B,yBAErC,SAAS,uBAAwB,IAAM,CACrC,MAAMC,EAA2C,CAC/C,IAAK,iBACL,KAAM,OACN,OAAQ,MACV,EACMC,EAA0B,CAC9B,IAAK,uBACP,EACMC,EAAmD,CACvD,YAAa,MACf,EAEA,WAAW,IAAM,CACf,GAAG,cAAc,CACnB,CAAC,EAED,GAAG,yCAA0C,IAAM,CAGjD,MAAMC,EAFuB,IAAIL,EAAqBI,CAAkB,EAEvC,MAAM,EAEvC,OAAOC,CAAG,EAAE,eAAeJ,CAAoB,CACjD,CAAC,EAED,GAAG,wCAAyC,IAAM,CAChD,MAAMK,EAAuB,IAAIN,EAAqBI,CAAkB,EAClEG,EAAe,CAAE,KAAM,GAAG,GAAG,CAAE,EAE/BF,EAAMC,EACT,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CAC9C,IAAK,sCACL,KAAM,OACN,OAAQ,MACV,EAGMF,EADMF,EAAqB,aAAaI,CAAe,EAAE,MAAM,EAEnE,WACA,IAAyBX,EAAY,MAAM,EAE7C,OAAOS,EAAO,IAAI,GAAG,EAAE,KAAKE,EAAgB,GAAG,EAC/C,OAAOF,EAAO,IAAI,IAAI,EAAE,KAAKE,EAAgB,IAAI,EACjD,OAAOF,EAAO,IAAI,MAAM,EAAE,KAAKE,EAAgB,MAAM,EACrD,OAAOF,EAAO,IAAI,GAAG,EAAE,IAAI,KACzB,iDACF,CACF,CAAC,CACH,CAAC,EAED,SAAS,sBAAuB,IAAM,CACpC,GAAG,2CAA4C,IAAM,CACnD,MAAMF,EAAuB,IAAIN,EAAqBI,CAAkB,EAClEO,EAAyB,CAC7B,IAAK,0CACP,EAEMN,EAAMC,EACT,oBAAoBK,CAAsB,EAC1C,MAAM,EACHH,EAAUH,EACd,WACA,IAAyBN,EAAY,MAAM,EAE7C,OAAOM,CAAG,EAAE,eAAeJ,CAAoB,EAC/C,OAAOO,EAAO,UAAU,EAAE,QAAQG,CAAsB,CAC1D,CAAC,EAED,GAAG,wDAAyD,IAAM,CAChE,MAAML,EAAuB,IAAIN,EAAqBI,CAAkB,EAClEO,EAAyB,CAC7B,IAAK,4CACP,EAKMH,EAHMF,EACT,oBAAoBK,CAAsB,EAC1C,MAAM,EAEP,WACA,IAAyBZ,EAAY,MAAM,EAE7C,OAAOS,EAAO,WAAW,GAAG,EAAE,KAAKG,EAAuB,GAAG,EAC7D,OAAOH,EAAO,WAAW,GAAG,EAAE,IAAI,KAChC,8CACF,CACF,CAAC,CACH,CAAC,CACH,CAAC",
6
+ "names": ["configTypes", "ContextModuleBuilder", "DefaultContextModule", "defaultCalConfig", "defaultWeb3ChecksConfig", "defaultBuilderArgs", "res", "contextModuleBuilder", "customLoader", "config", "customMetadataConfig", "customCalConfig", "customWeb3ChecksConfig"]
7
7
  }
@@ -1,2 +1,2 @@
1
- import{transactionTypes as n}from"./transaction/di/transactionTypes";import{trustedNameTypes as i}from"./trusted-name/di/trustedNameTypes";import{externalPluginTypes as p}from"./external-plugin/di/externalPluginTypes";import{nftTypes as d}from"./nft/di/nftTypes";import{ClearSignContextType as a}from"./shared/model/ClearSignContext";import{tokenTypes as s}from"./token/di/tokenTypes";import{typedDataTypes as C}from"./typed-data/di/typedDataTypes";import{uniswapTypes as m}from"./uniswap/di/uniswapTypes";import{web3CheckTypes as c}from"./web3-check/di/web3CheckTypes";import{makeContainer as l}from"./di";class k{_container;_loaders;_typedDataLoader;_web3CheckLoader;constructor(e){this._container=l({config:e}),this._loaders=e.defaultLoaders?this._getDefaultLoaders():[],this._loaders.push(...e.customLoaders),this._typedDataLoader=e.customTypedDataLoader??this._getDefaultTypedDataLoader(),this._web3CheckLoader=e.customWeb3CheckLoader??this._getWeb3CheckLoader()}_getDefaultLoaders(){return[this._container.get(p.ExternalPluginContextLoader),this._container.get(i.TrustedNameContextLoader),this._container.get(d.NftContextLoader),this._container.get(s.TokenContextLoader),this._container.get(n.TransactionContextLoader),this._container.get(m.UniswapContextLoader)]}_getDefaultTypedDataLoader(){return this._container.get(C.TypedDataContextLoader)}_getWeb3CheckLoader(){return this._container.get(c.Web3CheckContextLoader)}async getContexts(e){const o=this._loaders.map(t=>t.load(e));return(await Promise.all(o)).flat()}async getContext(e){const o=this._loaders.filter(t=>t.loadField).map(t=>t.loadField(e));return(await Promise.all(o)).find(t=>t!==null)||{type:a.ERROR,error:new Error(`Field type not supported: ${e.type}`)}}async getTypedDataFilters(e){return this._typedDataLoader.load(e)}async getWeb3Checks(e){return(await this._web3CheckLoader.load(e)).caseOf({Right:r=>({type:a.WEB3_CHECK,payload:r.descriptor,certificate:r.certificate}),Left:()=>null})}}export{k as DefaultContextModule};
1
+ import{Left as n}from"purify-ts";import{dynamicNetworkTypes as i}from"./dynamic-network/di/dynamicNetworkTypes";import{transactionTypes as p}from"./transaction/di/transactionTypes";import{trustedNameTypes as d}from"./trusted-name/di/trustedNameTypes";import{externalPluginTypes as s}from"./external-plugin/di/externalPluginTypes";import{nftTypes as C}from"./nft/di/nftTypes";import{ClearSignContextType as r}from"./shared/model/ClearSignContext";import{solanaContextTypes as m}from"./solana/di/solanaContextTypes";import{tokenTypes as l}from"./token/di/tokenTypes";import{typedDataTypes as c}from"./typed-data/di/typedDataTypes";import{uniswapTypes as x}from"./uniswap/di/uniswapTypes";import{web3CheckTypes as y}from"./web3-check/di/web3CheckTypes";import{makeContainer as L}from"./di";class E{_container;_loaders;_typedDataLoader;_web3CheckLoader;_solanaLoader;constructor(t){this._container=L({config:t}),this._loaders=t.defaultLoaders?this._getDefaultLoaders():[],this._loaders.push(...t.customLoaders),this._typedDataLoader=t.customTypedDataLoader??this._getDefaultTypedDataLoader(),this._web3CheckLoader=t.customWeb3CheckLoader??this._getWeb3CheckLoader(),this._solanaLoader=t.customSolanaLoader??this._getSolanaLoader()}_getDefaultLoaders(){return[this._container.get(s.ExternalPluginContextLoader),this._container.get(d.TrustedNameContextLoader),this._container.get(C.NftContextLoader),this._container.get(l.TokenContextLoader),this._container.get(p.TransactionContextLoader),this._container.get(x.UniswapContextLoader),this._container.get(i.DynamicNetworkContextLoader)]}_getDefaultTypedDataLoader(){return this._container.get(c.TypedDataContextLoader)}_getWeb3CheckLoader(){return this._container.get(y.Web3CheckContextLoader)}_getSolanaLoader(){try{return this._container.get(m.SolanaContextLoader)}catch{return{load:async t=>n(new Error("[ContextModule] - DefaultContextModule: no SolanaContextLoader bound"))}}}async getContexts(t){const o=this._loaders.map(e=>e.load(t));return(await Promise.all(o)).flat()}async getContext(t){const o=this._loaders.filter(e=>e.loadField).map(e=>e.loadField(t));return(await Promise.all(o)).find(e=>e!==null)||{type:r.ERROR,error:new Error(`Field type not supported: ${t.type}`)}}async getTypedDataFilters(t){return this._typedDataLoader.load(t)}async getWeb3Checks(t){return(await this._web3CheckLoader.load(t)).caseOf({Right:a=>({type:r.WEB3_CHECK,payload:a.descriptor,certificate:a.certificate}),Left:()=>null})}async getSolanaContext(t){return await this._solanaLoader.load(t)}}export{E as DefaultContextModule};
2
2
  //# sourceMappingURL=DefaultContextModule.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../src/DefaultContextModule.ts"],
4
- "sourcesContent": ["import { type Container } from \"inversify\";\n\nimport type { TypedDataClearSignContext } from \"@/shared/model/TypedDataClearSignContext\";\nimport type { TypedDataContext } from \"@/shared/model/TypedDataContext\";\nimport { transactionTypes } from \"@/transaction/di/transactionTypes\";\nimport { trustedNameTypes } from \"@/trusted-name/di/trustedNameTypes\";\n\nimport { type ContextModuleConfig } from \"./config/model/ContextModuleConfig\";\nimport { externalPluginTypes } from \"./external-plugin/di/externalPluginTypes\";\nimport { type ExternalPluginContextLoader } from \"./external-plugin/domain/ExternalPluginContextLoader\";\nimport { nftTypes } from \"./nft/di/nftTypes\";\nimport { type NftContextLoader } from \"./nft/domain/NftContextLoader\";\nimport { type ContextLoader } from \"./shared/domain/ContextLoader\";\nimport {\n type ClearSignContext,\n type ClearSignContextSuccess,\n ClearSignContextType,\n} from \"./shared/model/ClearSignContext\";\nimport {\n type TransactionContext,\n type TransactionFieldContext,\n} from \"./shared/model/TransactionContext\";\nimport { tokenTypes } from \"./token/di/tokenTypes\";\nimport { type TokenContextLoader } from \"./token/domain/TokenContextLoader\";\nimport { type TransactionContextLoader } from \"./transaction/domain/TransactionContextLoader\";\nimport { type TrustedNameContextLoader } from \"./trusted-name/domain/TrustedNameContextLoader\";\nimport { typedDataTypes } from \"./typed-data/di/typedDataTypes\";\nimport type { TypedDataContextLoader } from \"./typed-data/domain/TypedDataContextLoader\";\nimport { uniswapTypes } from \"./uniswap/di/uniswapTypes\";\nimport { type UniswapContextLoader } from \"./uniswap/domain/UniswapContextLoader\";\nimport { web3CheckTypes } from \"./web3-check/di/web3CheckTypes\";\nimport { type Web3CheckContextLoader } from \"./web3-check/domain/Web3CheckContextLoader\";\nimport {\n type Web3CheckContext,\n type Web3Checks,\n} from \"./web3-check/domain/web3CheckTypes\";\nimport { type ContextModule } from \"./ContextModule\";\nimport { makeContainer } from \"./di\";\n\nexport class DefaultContextModule implements ContextModule {\n private _container: Container;\n private _loaders: ContextLoader[];\n private _typedDataLoader: TypedDataContextLoader;\n private _web3CheckLoader: Web3CheckContextLoader;\n\n constructor(args: ContextModuleConfig) {\n this._container = makeContainer({ config: args });\n this._loaders = args.defaultLoaders ? this._getDefaultLoaders() : [];\n this._loaders.push(...args.customLoaders);\n this._typedDataLoader =\n args.customTypedDataLoader ?? this._getDefaultTypedDataLoader();\n this._web3CheckLoader =\n args.customWeb3CheckLoader ?? this._getWeb3CheckLoader();\n }\n\n private _getDefaultLoaders(): ContextLoader[] {\n return [\n this._container.get<ExternalPluginContextLoader>(\n externalPluginTypes.ExternalPluginContextLoader,\n ),\n this._container.get<TrustedNameContextLoader>(\n trustedNameTypes.TrustedNameContextLoader,\n ),\n this._container.get<NftContextLoader>(nftTypes.NftContextLoader),\n this._container.get<TokenContextLoader>(tokenTypes.TokenContextLoader),\n this._container.get<TransactionContextLoader>(\n transactionTypes.TransactionContextLoader,\n ),\n this._container.get<UniswapContextLoader>(\n uniswapTypes.UniswapContextLoader,\n ),\n ];\n }\n\n private _getDefaultTypedDataLoader(): TypedDataContextLoader {\n return this._container.get<TypedDataContextLoader>(\n typedDataTypes.TypedDataContextLoader,\n );\n }\n\n private _getWeb3CheckLoader(): Web3CheckContextLoader {\n return this._container.get<Web3CheckContextLoader>(\n web3CheckTypes.Web3CheckContextLoader,\n );\n }\n\n public async getContexts(\n transaction: TransactionContext,\n ): Promise<ClearSignContext[]> {\n const promises = this._loaders.map((fetcher) => fetcher.load(transaction));\n const responses = await Promise.all(promises);\n return responses.flat();\n }\n\n public async getContext(\n field: TransactionFieldContext,\n ): Promise<ClearSignContext> {\n const promises = this._loaders\n .filter((fetcher) => fetcher.loadField)\n .map((fetcher) => fetcher.loadField!(field));\n const responses = await Promise.all(promises);\n return (\n responses.find((resp) => resp !== null) || {\n type: ClearSignContextType.ERROR,\n error: new Error(`Field type not supported: ${field.type}`),\n }\n );\n }\n\n public async getTypedDataFilters(\n typedData: TypedDataContext,\n ): Promise<TypedDataClearSignContext> {\n return this._typedDataLoader.load(typedData);\n }\n\n public async getWeb3Checks(\n transactionContext: Web3CheckContext,\n ): Promise<ClearSignContextSuccess<ClearSignContextType.WEB3_CHECK> | null> {\n const web3Checks = await this._web3CheckLoader.load(transactionContext);\n\n return web3Checks.caseOf({\n Right: (checks: Web3Checks) => ({\n type: ClearSignContextType.WEB3_CHECK,\n payload: checks.descriptor,\n certificate: checks.certificate,\n }),\n Left: () => null,\n });\n }\n}\n"],
5
- "mappings": "AAIA,OAAS,oBAAAA,MAAwB,oCACjC,OAAS,oBAAAC,MAAwB,qCAGjC,OAAS,uBAAAC,MAA2B,2CAEpC,OAAS,YAAAC,MAAgB,oBAGzB,OAGE,wBAAAC,MACK,kCAKP,OAAS,cAAAC,MAAkB,wBAI3B,OAAS,kBAAAC,MAAsB,iCAE/B,OAAS,gBAAAC,MAAoB,4BAE7B,OAAS,kBAAAC,MAAsB,iCAO/B,OAAS,iBAAAC,MAAqB,OAEvB,MAAMC,CAA8C,CACjD,WACA,SACA,iBACA,iBAER,YAAYC,EAA2B,CACrC,KAAK,WAAaF,EAAc,CAAE,OAAQE,CAAK,CAAC,EAChD,KAAK,SAAWA,EAAK,eAAiB,KAAK,mBAAmB,EAAI,CAAC,EACnE,KAAK,SAAS,KAAK,GAAGA,EAAK,aAAa,EACxC,KAAK,iBACHA,EAAK,uBAAyB,KAAK,2BAA2B,EAChE,KAAK,iBACHA,EAAK,uBAAyB,KAAK,oBAAoB,CAC3D,CAEQ,oBAAsC,CAC5C,MAAO,CACL,KAAK,WAAW,IACdT,EAAoB,2BACtB,EACA,KAAK,WAAW,IACdD,EAAiB,wBACnB,EACA,KAAK,WAAW,IAAsBE,EAAS,gBAAgB,EAC/D,KAAK,WAAW,IAAwBE,EAAW,kBAAkB,EACrE,KAAK,WAAW,IACdL,EAAiB,wBACnB,EACA,KAAK,WAAW,IACdO,EAAa,oBACf,CACF,CACF,CAEQ,4BAAqD,CAC3D,OAAO,KAAK,WAAW,IACrBD,EAAe,sBACjB,CACF,CAEQ,qBAA8C,CACpD,OAAO,KAAK,WAAW,IACrBE,EAAe,sBACjB,CACF,CAEA,MAAa,YACXI,EAC6B,CAC7B,MAAMC,EAAW,KAAK,SAAS,IAAKC,GAAYA,EAAQ,KAAKF,CAAW,CAAC,EAEzE,OADkB,MAAM,QAAQ,IAAIC,CAAQ,GAC3B,KAAK,CACxB,CAEA,MAAa,WACXE,EAC2B,CAC3B,MAAMF,EAAW,KAAK,SACnB,OAAQC,GAAYA,EAAQ,SAAS,EACrC,IAAKA,GAAYA,EAAQ,UAAWC,CAAK,CAAC,EAE7C,OADkB,MAAM,QAAQ,IAAIF,CAAQ,GAEhC,KAAMG,GAASA,IAAS,IAAI,GAAK,CACzC,KAAMZ,EAAqB,MAC3B,MAAO,IAAI,MAAM,6BAA6BW,EAAM,IAAI,EAAE,CAC5D,CAEJ,CAEA,MAAa,oBACXE,EACoC,CACpC,OAAO,KAAK,iBAAiB,KAAKA,CAAS,CAC7C,CAEA,MAAa,cACXC,EAC0E,CAG1E,OAFmB,MAAM,KAAK,iBAAiB,KAAKA,CAAkB,GAEpD,OAAO,CACvB,MAAQC,IAAwB,CAC9B,KAAMf,EAAqB,WAC3B,QAASe,EAAO,WAChB,YAAaA,EAAO,WACtB,GACA,KAAM,IAAM,IACd,CAAC,CACH,CACF",
6
- "names": ["transactionTypes", "trustedNameTypes", "externalPluginTypes", "nftTypes", "ClearSignContextType", "tokenTypes", "typedDataTypes", "uniswapTypes", "web3CheckTypes", "makeContainer", "DefaultContextModule", "args", "transaction", "promises", "fetcher", "field", "resp", "typedData", "transactionContext", "checks"]
4
+ "sourcesContent": ["import { type Container } from \"inversify\";\nimport { Left } from \"purify-ts\";\n\nimport { dynamicNetworkTypes } from \"@/dynamic-network/di/dynamicNetworkTypes\";\nimport { type DynamicNetworkContextLoader } from \"@/dynamic-network/domain/DynamicNetworkContextLoader\";\nimport type { TypedDataClearSignContext } from \"@/shared/model/TypedDataClearSignContext\";\nimport type { TypedDataContext } from \"@/shared/model/TypedDataContext\";\nimport { transactionTypes } from \"@/transaction/di/transactionTypes\";\nimport { trustedNameTypes } from \"@/trusted-name/di/trustedNameTypes\";\n\nimport { type ContextModuleConfig } from \"./config/model/ContextModuleConfig\";\nimport { externalPluginTypes } from \"./external-plugin/di/externalPluginTypes\";\nimport { type ExternalPluginContextLoader } from \"./external-plugin/domain/ExternalPluginContextLoader\";\nimport { nftTypes } from \"./nft/di/nftTypes\";\nimport { type NftContextLoader } from \"./nft/domain/NftContextLoader\";\nimport { type ContextLoader } from \"./shared/domain/ContextLoader\";\nimport {\n type ClearSignContext,\n type ClearSignContextSuccess,\n ClearSignContextType,\n} from \"./shared/model/ClearSignContext\";\nimport { type SolanaTransactionContext } from \"./shared/model/SolanaTransactionContext\";\nimport {\n type TransactionContext,\n type TransactionFieldContext,\n} from \"./shared/model/TransactionContext\";\nimport { solanaContextTypes } from \"./solana/di/solanaContextTypes\";\nimport { type SolanaContextLoader } from \"./solana/domain/SolanaContextLoader\";\nimport { type SolanaTransactionContextResult } from \"./solana/domain/solanaContextTypes\";\nimport { tokenTypes } from \"./token/di/tokenTypes\";\nimport { type TokenContextLoader } from \"./token/domain/TokenContextLoader\";\nimport { type TransactionContextLoader } from \"./transaction/domain/TransactionContextLoader\";\nimport { type TrustedNameContextLoader } from \"./trusted-name/domain/TrustedNameContextLoader\";\nimport { typedDataTypes } from \"./typed-data/di/typedDataTypes\";\nimport type { TypedDataContextLoader } from \"./typed-data/domain/TypedDataContextLoader\";\nimport { uniswapTypes } from \"./uniswap/di/uniswapTypes\";\nimport { type UniswapContextLoader } from \"./uniswap/domain/UniswapContextLoader\";\nimport { web3CheckTypes } from \"./web3-check/di/web3CheckTypes\";\nimport { type Web3CheckContextLoader } from \"./web3-check/domain/Web3CheckContextLoader\";\nimport {\n type Web3CheckContext,\n type Web3Checks,\n} from \"./web3-check/domain/web3CheckTypes\";\nimport { type ContextModule } from \"./ContextModule\";\nimport { makeContainer } from \"./di\";\n\nexport class DefaultContextModule implements ContextModule {\n private _container: Container;\n private _loaders: ContextLoader[];\n private _typedDataLoader: TypedDataContextLoader;\n private _web3CheckLoader: Web3CheckContextLoader;\n private _solanaLoader: SolanaContextLoader;\n\n constructor(args: ContextModuleConfig) {\n this._container = makeContainer({ config: args });\n this._loaders = args.defaultLoaders ? this._getDefaultLoaders() : [];\n this._loaders.push(...args.customLoaders);\n this._typedDataLoader =\n args.customTypedDataLoader ?? this._getDefaultTypedDataLoader();\n this._web3CheckLoader =\n args.customWeb3CheckLoader ?? this._getWeb3CheckLoader();\n this._solanaLoader = args.customSolanaLoader ?? this._getSolanaLoader();\n }\n\n private _getDefaultLoaders(): ContextLoader[] {\n return [\n this._container.get<ExternalPluginContextLoader>(\n externalPluginTypes.ExternalPluginContextLoader,\n ),\n this._container.get<TrustedNameContextLoader>(\n trustedNameTypes.TrustedNameContextLoader,\n ),\n this._container.get<NftContextLoader>(nftTypes.NftContextLoader),\n this._container.get<TokenContextLoader>(tokenTypes.TokenContextLoader),\n this._container.get<TransactionContextLoader>(\n transactionTypes.TransactionContextLoader,\n ),\n this._container.get<UniswapContextLoader>(\n uniswapTypes.UniswapContextLoader,\n ),\n this._container.get<DynamicNetworkContextLoader>(\n dynamicNetworkTypes.DynamicNetworkContextLoader,\n ),\n ];\n }\n\n private _getDefaultTypedDataLoader(): TypedDataContextLoader {\n return this._container.get<TypedDataContextLoader>(\n typedDataTypes.TypedDataContextLoader,\n );\n }\n\n private _getWeb3CheckLoader(): Web3CheckContextLoader {\n return this._container.get<Web3CheckContextLoader>(\n web3CheckTypes.Web3CheckContextLoader,\n );\n }\n\n private _getSolanaLoader(): SolanaContextLoader {\n try {\n return this._container.get<SolanaContextLoader>(\n solanaContextTypes.SolanaContextLoader,\n );\n } catch {\n return {\n load: async (_ctx) =>\n Left(\n new Error(\n \"[ContextModule] - DefaultContextModule: no SolanaContextLoader bound\",\n ),\n ),\n };\n }\n }\n\n public async getContexts(\n transaction: TransactionContext,\n ): Promise<ClearSignContext[]> {\n const promises = this._loaders.map((fetcher) => fetcher.load(transaction));\n const responses = await Promise.all(promises);\n return responses.flat();\n }\n\n public async getContext(\n field: TransactionFieldContext,\n ): Promise<ClearSignContext> {\n const promises = this._loaders\n .filter((fetcher) => fetcher.loadField)\n .map((fetcher) => fetcher.loadField!(field));\n const responses = await Promise.all(promises);\n return (\n responses.find((resp) => resp !== null) || {\n type: ClearSignContextType.ERROR,\n error: new Error(`Field type not supported: ${field.type}`),\n }\n );\n }\n\n public async getTypedDataFilters(\n typedData: TypedDataContext,\n ): Promise<TypedDataClearSignContext> {\n return this._typedDataLoader.load(typedData);\n }\n\n public async getWeb3Checks(\n transactionContext: Web3CheckContext,\n ): Promise<ClearSignContextSuccess<ClearSignContextType.WEB3_CHECK> | null> {\n const web3Checks = await this._web3CheckLoader.load(transactionContext);\n\n return web3Checks.caseOf({\n Right: (checks: Web3Checks) => ({\n type: ClearSignContextType.WEB3_CHECK,\n payload: checks.descriptor,\n certificate: checks.certificate,\n }),\n Left: () => null,\n });\n }\n\n public async getSolanaContext(\n transactionContext: SolanaTransactionContext,\n ): Promise<SolanaTransactionContextResult> {\n return await this._solanaLoader.load(transactionContext);\n }\n}\n"],
5
+ "mappings": "AACA,OAAS,QAAAA,MAAY,YAErB,OAAS,uBAAAC,MAA2B,2CAIpC,OAAS,oBAAAC,MAAwB,oCACjC,OAAS,oBAAAC,MAAwB,qCAGjC,OAAS,uBAAAC,MAA2B,2CAEpC,OAAS,YAAAC,MAAgB,oBAGzB,OAGE,wBAAAC,MACK,kCAMP,OAAS,sBAAAC,MAA0B,iCAGnC,OAAS,cAAAC,MAAkB,wBAI3B,OAAS,kBAAAC,MAAsB,iCAE/B,OAAS,gBAAAC,MAAoB,4BAE7B,OAAS,kBAAAC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,OAAQC,GAAYA,EAAQ,SAAS,EACrC,IAAKA,GAAYA,EAAQ,UAAWC,CAAK,CAAC,EAE7C,OADkB,MAAM,QAAQ,IAAIF,CAAQ,GAEhC,KAAMG,GAASA,IAAS,IAAI,GAAK,CACzC,KAAMd,EAAqB,MAC3B,MAAO,IAAI,MAAM,6BAA6Ba,EAAM,IAAI,EAAE,CAC5D,CAEJ,CAEA,MAAa,oBACXE,EACoC,CACpC,OAAO,KAAK,iBAAiB,KAAKA,CAAS,CAC7C,CAEA,MAAa,cACXC,EAC0E,CAG1E,OAFmB,MAAM,KAAK,iBAAiB,KAAKA,CAAkB,GAEpD,OAAO,CACvB,MAAQC,IAAwB,CAC9B,KAAMjB,EAAqB,WAC3B,QAASiB,EAAO,WAChB,YAAaA,EAAO,WACtB,GACA,KAAM,IAAM,IACd,CAAC,CACH,CAEA,MAAa,iBACXD,EACyC,CACzC,OAAO,MAAM,KAAK,cAAc,KAAKA,CAAkB,CACzD,CACF",
6
+ "names": ["Left", "dynamicNetworkTypes", "transactionTypes", "trustedNameTypes", "externalPluginTypes", "nftTypes", "ClearSignContextType", "solanaContextTypes", "tokenTypes", "typedDataTypes", "uniswapTypes", "web3CheckTypes", "makeContainer", "DefaultContextModule", "args", "_ctx", "transaction", "promises", "fetcher", "field", "resp", "typedData", "transactionContext", "checks"]
7
7
  }
@@ -1,2 +1,2 @@
1
- import{DeviceModelId as c}from"@ledgerhq/device-management-kit";import{Left as r,Right as i}from"purify-ts";import{DefaultContextModule as a}from"./DefaultContextModule";const d=()=>({load:vi.fn(),loadField:vi.fn()});describe("DefaultContextModule",()=>{const s={load:vi.fn()},o={customLoaders:[],defaultLoaders:!1,customTypedDataLoader:s,cal:{url:"https://cal/v1",mode:"prod",branch:"main"},web3checks:{url:"https://web3checks/v3"},originToken:"originToken"};beforeEach(()=>{vi.restoreAllMocks()}),it("should initialize the context module with all the default loaders",async()=>{const t=await new a(o).getContexts({});expect(t).toEqual([])}),it("should return an empty array when no loaders",async()=>{const t=await new a(o).getContexts({});expect(t).toEqual([])}),it("should call all fetch method from metadata fetcher",async()=>{const e=d();await new a({...o,customLoaders:[e,e]}).getContexts({}),expect(e.load).toHaveBeenCalledTimes(2)}),it("should return an array of context response",async()=>{const e=d(),t=[[{type:"provideERC20Info",payload:"payload1"}],[{type:"provideERC20Info",payload:"payload2"},{type:"plugin",payload:"payload3"}]];vi.spyOn(e,"load").mockResolvedValueOnce(t[0]).mockResolvedValueOnce(t[1]);const l=await new a({...o,customLoaders:[e,e]}).getContexts({});expect(e.load).toHaveBeenCalledTimes(2),expect(l).toEqual(t.flat())}),it("should call the typed data loader",async()=>{await new a({...o,customTypedDataLoader:s}).getTypedDataFilters({}),expect(s.load).toHaveBeenCalledTimes(1)}),it("should return a single context",async()=>{const e=d(),t=[null,{type:"token",payload:"payload"}];vi.spyOn(e,"loadField").mockResolvedValueOnce(t[0]).mockResolvedValueOnce(t[1]);const l=await new a({...o,customLoaders:[e,{load:vi.fn()},e]}).getContext({type:"token"});expect(e.loadField).toHaveBeenCalledTimes(2),expect(l).toEqual({type:"token",payload:"payload"})}),it("should return a web3 check context",async()=>{const e=d();vi.spyOn(e,"load").mockResolvedValueOnce(i({descriptor:"payload"}));const n=await new a({...o,customLoaders:[],customWeb3CheckLoader:e}).getWeb3Checks({deviceModelId:c.FLEX,from:"from",rawTx:"rawTx",chainId:1});expect(e.load).toHaveBeenCalledTimes(1),expect(n).toEqual({type:"web3Check",payload:"payload"})}),it("should return null if no web3 check context",async()=>{const e=d();vi.spyOn(e,"load").mockResolvedValue(r(new Error("error")));const n=await new a({...o,customLoaders:[],customWeb3CheckLoader:e}).getWeb3Checks({deviceModelId:c.FLEX,from:"from",rawTx:"rawTx",chainId:1});expect(e.load).toHaveBeenCalledTimes(1),expect(n).toBeNull()}),it("context field not supported",async()=>{const e=d(),t=[null,null];vi.spyOn(e,"loadField").mockResolvedValueOnce(t[0]).mockResolvedValueOnce(t[1]);const l=await new a({...o,customLoaders:[e,{load:vi.fn()},e]}).getContext({type:"token"});expect(e.loadField).toHaveBeenCalledTimes(2),expect(l).toEqual({type:"error",error:new Error("Field type not supported: token")})}),it("getField not implemented",async()=>{const t=await new a({...o,customLoaders:[{load:vi.fn()}]}).getContext({type:"token"});expect(t).toEqual({type:"error",error:new Error("Field type not supported: token")})}),it("should throw an error if origin token is not provided",()=>{expect(()=>new a({...o,originToken:void 0})).toThrow("Origin token is required")})});
1
+ import{DeviceModelId as c}from"@ledgerhq/device-management-kit";import{Left as r,Right as i}from"purify-ts";import{DefaultContextModule as a}from"./DefaultContextModule";const d=()=>({load:vi.fn(),loadField:vi.fn()});describe("DefaultContextModule",()=>{const s={load:vi.fn()},o={customLoaders:[],defaultLoaders:!1,customTypedDataLoader:s,cal:{url:"https://cal/v1",mode:"prod",branch:"main"},web3checks:{url:"https://web3checks/v3"},metadataServiceDomain:{url:"https://metadata.com"},originToken:"originToken"};beforeEach(()=>{vi.restoreAllMocks()}),it("should initialize the context module with all the default loaders",async()=>{const t=await new a(o).getContexts({});expect(t).toEqual([])}),it("should return an empty array when no loaders",async()=>{const t=await new a(o).getContexts({});expect(t).toEqual([])}),it("should call all fetch method from metadata fetcher",async()=>{const e=d();await new a({...o,customLoaders:[e,e]}).getContexts({}),expect(e.load).toHaveBeenCalledTimes(2)}),it("should return an array of context response",async()=>{const e=d(),t=[[{type:"provideERC20Info",payload:"payload1"}],[{type:"provideERC20Info",payload:"payload2"},{type:"plugin",payload:"payload3"}]];vi.spyOn(e,"load").mockResolvedValueOnce(t[0]).mockResolvedValueOnce(t[1]);const l=await new a({...o,customLoaders:[e,e]}).getContexts({});expect(e.load).toHaveBeenCalledTimes(2),expect(l).toEqual(t.flat())}),it("should call the typed data loader",async()=>{await new a({...o,customTypedDataLoader:s}).getTypedDataFilters({}),expect(s.load).toHaveBeenCalledTimes(1)}),it("should return a single context",async()=>{const e=d(),t=[null,{type:"token",payload:"payload"}];vi.spyOn(e,"loadField").mockResolvedValueOnce(t[0]).mockResolvedValueOnce(t[1]);const l=await new a({...o,customLoaders:[e,{load:vi.fn()},e]}).getContext({type:"token"});expect(e.loadField).toHaveBeenCalledTimes(2),expect(l).toEqual({type:"token",payload:"payload"})}),it("should return a web3 check context",async()=>{const e=d();vi.spyOn(e,"load").mockResolvedValueOnce(i({descriptor:"payload"}));const n=await new a({...o,customLoaders:[],customWeb3CheckLoader:e}).getWeb3Checks({deviceModelId:c.FLEX,from:"from",rawTx:"rawTx",chainId:1});expect(e.load).toHaveBeenCalledTimes(1),expect(n).toEqual({type:"web3Check",payload:"payload"})}),it("should return null if no web3 check context",async()=>{const e=d();vi.spyOn(e,"load").mockResolvedValue(r(new Error("error")));const n=await new a({...o,customLoaders:[],customWeb3CheckLoader:e}).getWeb3Checks({deviceModelId:c.FLEX,from:"from",rawTx:"rawTx",chainId:1});expect(e.load).toHaveBeenCalledTimes(1),expect(n).toBeNull()}),it("context field not supported",async()=>{const e=d(),t=[null,null];vi.spyOn(e,"loadField").mockResolvedValueOnce(t[0]).mockResolvedValueOnce(t[1]);const l=await new a({...o,customLoaders:[e,{load:vi.fn()},e]}).getContext({type:"token"});expect(e.loadField).toHaveBeenCalledTimes(2),expect(l).toEqual({type:"error",error:new Error("Field type not supported: token")})}),it("getField not implemented",async()=>{const t=await new a({...o,customLoaders:[{load:vi.fn()}]}).getContext({type:"token"});expect(t).toEqual({type:"error",error:new Error("Field type not supported: token")})}),it("should throw an error if origin token is not provided",()=>{expect(()=>new a({...o,originToken:void 0})).toThrow("Origin token is required")})});
2
2
  //# sourceMappingURL=DefaultContextModule.test.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../src/DefaultContextModule.test.ts"],
4
- "sourcesContent": ["import { DeviceModelId } from \"@ledgerhq/device-management-kit\";\nimport { Left, Right } from \"purify-ts\";\n\nimport { type ContextModuleConfig } from \"./config/model/ContextModuleConfig\";\nimport {\n type TransactionContext,\n type TransactionFieldContext,\n} from \"./shared/model/TransactionContext\";\nimport { type TypedDataContext } from \"./shared/model/TypedDataContext\";\nimport type { TypedDataContextLoader } from \"./typed-data/domain/TypedDataContextLoader\";\nimport { DefaultContextModule } from \"./DefaultContextModule\";\n\nconst contextLoaderStubBuilder = () => {\n return { load: vi.fn(), loadField: vi.fn() };\n};\n\ndescribe(\"DefaultContextModule\", () => {\n const typedDataLoader: TypedDataContextLoader = { load: vi.fn() };\n const defaultContextModuleConfig: ContextModuleConfig = {\n customLoaders: [],\n defaultLoaders: false,\n customTypedDataLoader: typedDataLoader,\n cal: {\n url: \"https://cal/v1\",\n mode: \"prod\",\n branch: \"main\",\n },\n web3checks: {\n url: \"https://web3checks/v3\",\n },\n originToken: \"originToken\",\n };\n\n beforeEach(() => {\n vi.restoreAllMocks();\n });\n\n it(\"should initialize the context module with all the default loaders\", async () => {\n const contextModule = new DefaultContextModule(defaultContextModuleConfig);\n\n const res = await contextModule.getContexts({} as TransactionContext);\n\n expect(res).toEqual([]);\n });\n\n it(\"should return an empty array when no loaders\", async () => {\n const contextModule = new DefaultContextModule(defaultContextModuleConfig);\n\n const res = await contextModule.getContexts({} as TransactionContext);\n\n expect(res).toEqual([]);\n });\n\n it(\"should call all fetch method from metadata fetcher\", async () => {\n const loader = contextLoaderStubBuilder();\n const contextModule = new DefaultContextModule({\n ...defaultContextModuleConfig,\n customLoaders: [loader, loader],\n });\n\n await contextModule.getContexts({} as TransactionContext);\n\n expect(loader.load).toHaveBeenCalledTimes(2);\n });\n\n it(\"should return an array of context response\", async () => {\n const loader = contextLoaderStubBuilder();\n const responses = [\n [{ type: \"provideERC20Info\", payload: \"payload1\" }],\n [\n { type: \"provideERC20Info\", payload: \"payload2\" },\n { type: \"plugin\", payload: \"payload3\" },\n ],\n ];\n vi.spyOn(loader, \"load\")\n .mockResolvedValueOnce(responses[0])\n .mockResolvedValueOnce(responses[1]);\n const contextModule = new DefaultContextModule({\n ...defaultContextModuleConfig,\n customLoaders: [loader, loader],\n });\n\n const res = await contextModule.getContexts({} as TransactionContext);\n\n expect(loader.load).toHaveBeenCalledTimes(2);\n expect(res).toEqual(responses.flat());\n });\n\n it(\"should call the typed data loader\", async () => {\n const contextModule = new DefaultContextModule({\n ...defaultContextModuleConfig,\n customTypedDataLoader: typedDataLoader,\n });\n\n await contextModule.getTypedDataFilters({} as TypedDataContext);\n\n expect(typedDataLoader.load).toHaveBeenCalledTimes(1);\n });\n\n it(\"should return a single context\", async () => {\n const loader = contextLoaderStubBuilder();\n const responses = [null, { type: \"token\", payload: \"payload\" }];\n vi.spyOn(loader, \"loadField\")\n .mockResolvedValueOnce(responses[0])\n .mockResolvedValueOnce(responses[1]);\n const contextModule = new DefaultContextModule({\n ...defaultContextModuleConfig,\n customLoaders: [loader, { load: vi.fn() }, loader],\n });\n\n const res = await contextModule.getContext({\n type: \"token\",\n } as TransactionFieldContext);\n\n expect(loader.loadField).toHaveBeenCalledTimes(2);\n expect(res).toEqual({ type: \"token\", payload: \"payload\" });\n });\n\n it(\"should return a web3 check context\", async () => {\n const loader = contextLoaderStubBuilder();\n vi.spyOn(loader, \"load\").mockResolvedValueOnce(\n Right({ descriptor: \"payload\" }),\n );\n const contextModule = new DefaultContextModule({\n ...defaultContextModuleConfig,\n customLoaders: [],\n customWeb3CheckLoader: loader,\n });\n\n const res = await contextModule.getWeb3Checks({\n deviceModelId: DeviceModelId.FLEX,\n from: \"from\",\n rawTx: \"rawTx\",\n chainId: 1,\n });\n\n expect(loader.load).toHaveBeenCalledTimes(1);\n expect(res).toEqual({ type: \"web3Check\", payload: \"payload\" });\n });\n\n it(\"should return null if no web3 check context\", async () => {\n const loader = contextLoaderStubBuilder();\n vi.spyOn(loader, \"load\").mockResolvedValue(Left(new Error(\"error\")));\n const contextModule = new DefaultContextModule({\n ...defaultContextModuleConfig,\n customLoaders: [],\n customWeb3CheckLoader: loader,\n });\n\n const res = await contextModule.getWeb3Checks({\n deviceModelId: DeviceModelId.FLEX,\n from: \"from\",\n rawTx: \"rawTx\",\n chainId: 1,\n });\n\n expect(loader.load).toHaveBeenCalledTimes(1);\n expect(res).toBeNull();\n });\n\n it(\"context field not supported\", async () => {\n const loader = contextLoaderStubBuilder();\n const responses = [null, null];\n vi.spyOn(loader, \"loadField\")\n .mockResolvedValueOnce(responses[0])\n .mockResolvedValueOnce(responses[1]);\n const contextModule = new DefaultContextModule({\n ...defaultContextModuleConfig,\n customLoaders: [loader, { load: vi.fn() }, loader],\n });\n\n const res = await contextModule.getContext({\n type: \"token\",\n } as TransactionFieldContext);\n\n expect(loader.loadField).toHaveBeenCalledTimes(2);\n expect(res).toEqual({\n type: \"error\",\n error: new Error(\"Field type not supported: token\"),\n });\n });\n\n it(\"getField not implemented\", async () => {\n const contextModule = new DefaultContextModule({\n ...defaultContextModuleConfig,\n customLoaders: [{ load: vi.fn() }],\n });\n\n const res = await contextModule.getContext({\n type: \"token\",\n } as TransactionFieldContext);\n\n expect(res).toEqual({\n type: \"error\",\n error: new Error(\"Field type not supported: token\"),\n });\n });\n\n it(\"should throw an error if origin token is not provided\", () => {\n expect(\n () =>\n new DefaultContextModule({\n ...defaultContextModuleConfig,\n originToken: undefined,\n }),\n ).toThrow(\"Origin token is required\");\n });\n});\n"],
5
- "mappings": "AAAA,OAAS,iBAAAA,MAAqB,kCAC9B,OAAS,QAAAC,EAAM,SAAAC,MAAa,YAS5B,OAAS,wBAAAC,MAA4B,yBAErC,MAAMC,EAA2B,KACxB,CAAE,KAAM,GAAG,GAAG,EAAG,UAAW,GAAG,GAAG,CAAE,GAG7C,SAAS,uBAAwB,IAAM,CACrC,MAAMC,EAA0C,CAAE,KAAM,GAAG,GAAG,CAAE,EAC1DC,EAAkD,CACtD,cAAe,CAAC,EAChB,eAAgB,GAChB,sBAAuBD,EACvB,IAAK,CACH,IAAK,iBACL,KAAM,OACN,OAAQ,MACV,EACA,WAAY,CACV,IAAK,uBACP,EACA,YAAa,aACf,EAEA,WAAW,IAAM,CACf,GAAG,gBAAgB,CACrB,CAAC,EAED,GAAG,oEAAqE,SAAY,C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EAAc,KAC7B,KAAM,OACN,MAAO,QACP,QAAS,CACX,CAAC,EAED,OAAOQ,EAAO,IAAI,EAAE,sBAAsB,CAAC,EAC3C,OAAOD,CAAG,EAAE,SAAS,CACvB,CAAC,EAED,GAAG,8BAA+B,SAAY,CAC5C,MAAMC,EAASJ,EAAyB,EAClCK,EAAY,CAAC,KAAM,IAAI,EAC7B,GAAG,MAAMD,EAAQ,WAAW,EACzB,sBAAsBC,EAAU,CAAC,CAAC,EAClC,sBAAsBA,EAAU,CAAC,CAAC,EAMrC,MAAMF,EAAM,MALU,IAAIJ,EAAqB,CAC7C,GAAGG,EACH,cAAe,CAACE,EAAQ,CAAE,KAAM,GAAG,GAAG,CAAE,EAAGA,CAAM,CACnD,CAAC,EAE+B,WAAW,CACzC,KAAM,OACR,CAA4B,EAE5B,OAAOA,EAAO,SAAS,EAAE,sBAAsB,CAAC,EAChD,OAAOD,CAAG,EAAE,QAAQ,CAClB,KAAM,QACN,MAAO,IAAI,MAAM,iCAAiC,CACpD,CAAC,CACH,CAAC,EAED,GAAG,2BAA4B,SAAY,CAMzC,MAAMA,EAAM,MALU,IAAIJ,EAAqB,CAC7C,GAAGG,EACH,cAAe,CAAC,CAAE,KAAM,GAAG,GAAG,CAAE,CAAC,CACnC,CAAC,EAE+B,WAAW,CACzC,KAAM,OACR,CAA4B,EAE5B,OAAOC,CAAG,EAAE,QAAQ,CAClB,KAAM,QACN,MAAO,IAAI,MAAM,iCAAiC,CACpD,CAAC,CACH,CAAC,EAED,GAAG,wDAAyD,IAAM,CAChE,OACE,IACE,IAAIJ,EAAqB,CACvB,GAAGG,EACH,YAAa,MACf,CAAC,CACL,EAAE,QAAQ,0BAA0B,CACtC,CAAC,CACH,CAAC",
4
+ "sourcesContent": ["import { DeviceModelId } from \"@ledgerhq/device-management-kit\";\nimport { Left, Right } from \"purify-ts\";\n\nimport { type ContextModuleConfig } from \"./config/model/ContextModuleConfig\";\nimport {\n type TransactionContext,\n type TransactionFieldContext,\n} from \"./shared/model/TransactionContext\";\nimport { type TypedDataContext } from \"./shared/model/TypedDataContext\";\nimport type { TypedDataContextLoader } from \"./typed-data/domain/TypedDataContextLoader\";\nimport { DefaultContextModule } from \"./DefaultContextModule\";\n\nconst contextLoaderStubBuilder = () => {\n return { load: vi.fn(), loadField: vi.fn() };\n};\n\ndescribe(\"DefaultContextModule\", () => {\n const typedDataLoader: TypedDataContextLoader = { load: vi.fn() };\n const defaultContextModuleConfig: ContextModuleConfig = {\n customLoaders: [],\n defaultLoaders: false,\n customTypedDataLoader: typedDataLoader,\n cal: {\n url: \"https://cal/v1\",\n mode: \"prod\",\n branch: \"main\",\n },\n web3checks: {\n url: \"https://web3checks/v3\",\n },\n metadataServiceDomain: {\n url: \"https://metadata.com\",\n },\n originToken: \"originToken\",\n };\n\n beforeEach(() => {\n vi.restoreAllMocks();\n });\n\n it(\"should initialize the context module with all the default loaders\", async () => {\n const contextModule = new DefaultContextModule(defaultContextModuleConfig);\n\n const res = await contextModule.getContexts({} as TransactionContext);\n\n expect(res).toEqual([]);\n });\n\n it(\"should return an empty array when no loaders\", async () => {\n const contextModule = new DefaultContextModule(defaultContextModuleConfig);\n\n const res = await contextModule.getContexts({} as TransactionContext);\n\n expect(res).toEqual([]);\n });\n\n it(\"should call all fetch method from metadata fetcher\", async () => {\n const loader = contextLoaderStubBuilder();\n const contextModule = new DefaultContextModule({\n ...defaultContextModuleConfig,\n customLoaders: [loader, loader],\n });\n\n await contextModule.getContexts({} as TransactionContext);\n\n expect(loader.load).toHaveBeenCalledTimes(2);\n });\n\n it(\"should return an array of context response\", async () => {\n const loader = contextLoaderStubBuilder();\n const responses = [\n [{ type: \"provideERC20Info\", payload: \"payload1\" }],\n [\n { type: \"provideERC20Info\", payload: \"payload2\" },\n { type: \"plugin\", payload: \"payload3\" },\n ],\n ];\n vi.spyOn(loader, \"load\")\n .mockResolvedValueOnce(responses[0])\n .mockResolvedValueOnce(responses[1]);\n const contextModule = new DefaultContextModule({\n ...defaultContextModuleConfig,\n customLoaders: [loader, loader],\n });\n\n const res = await contextModule.getContexts({} as TransactionContext);\n\n expect(loader.load).toHaveBeenCalledTimes(2);\n expect(res).toEqual(responses.flat());\n });\n\n it(\"should call the typed data loader\", async () => {\n const contextModule = new DefaultContextModule({\n ...defaultContextModuleConfig,\n customTypedDataLoader: typedDataLoader,\n });\n\n await contextModule.getTypedDataFilters({} as TypedDataContext);\n\n expect(typedDataLoader.load).toHaveBeenCalledTimes(1);\n });\n\n it(\"should return a single context\", async () => {\n const loader = contextLoaderStubBuilder();\n const responses = [null, { type: \"token\", payload: \"payload\" }];\n vi.spyOn(loader, \"loadField\")\n .mockResolvedValueOnce(responses[0])\n .mockResolvedValueOnce(responses[1]);\n const contextModule = new DefaultContextModule({\n ...defaultContextModuleConfig,\n customLoaders: [loader, { load: vi.fn() }, loader],\n });\n\n const res = await contextModule.getContext({\n type: \"token\",\n } as TransactionFieldContext);\n\n expect(loader.loadField).toHaveBeenCalledTimes(2);\n expect(res).toEqual({ type: \"token\", payload: \"payload\" });\n });\n\n it(\"should return a web3 check context\", async () => {\n const loader = contextLoaderStubBuilder();\n vi.spyOn(loader, \"load\").mockResolvedValueOnce(\n Right({ descriptor: \"payload\" }),\n );\n const contextModule = new DefaultContextModule({\n ...defaultContextModuleConfig,\n customLoaders: [],\n customWeb3CheckLoader: loader,\n });\n\n const res = await contextModule.getWeb3Checks({\n deviceModelId: DeviceModelId.FLEX,\n from: \"from\",\n rawTx: \"rawTx\",\n chainId: 1,\n });\n\n expect(loader.load).toHaveBeenCalledTimes(1);\n expect(res).toEqual({ type: \"web3Check\", payload: \"payload\" });\n });\n\n it(\"should return null if no web3 check context\", async () => {\n const loader = contextLoaderStubBuilder();\n vi.spyOn(loader, \"load\").mockResolvedValue(Left(new Error(\"error\")));\n const contextModule = new DefaultContextModule({\n ...defaultContextModuleConfig,\n customLoaders: [],\n customWeb3CheckLoader: loader,\n });\n\n const res = await contextModule.getWeb3Checks({\n deviceModelId: DeviceModelId.FLEX,\n from: \"from\",\n rawTx: \"rawTx\",\n chainId: 1,\n });\n\n expect(loader.load).toHaveBeenCalledTimes(1);\n expect(res).toBeNull();\n });\n\n it(\"context field not supported\", async () => {\n const loader = contextLoaderStubBuilder();\n const responses = [null, null];\n vi.spyOn(loader, \"loadField\")\n .mockResolvedValueOnce(responses[0])\n .mockResolvedValueOnce(responses[1]);\n const contextModule = new DefaultContextModule({\n ...defaultContextModuleConfig,\n customLoaders: [loader, { load: vi.fn() }, loader],\n });\n\n const res = await contextModule.getContext({\n type: \"token\",\n } as TransactionFieldContext);\n\n expect(loader.loadField).toHaveBeenCalledTimes(2);\n expect(res).toEqual({\n type: \"error\",\n error: new Error(\"Field type not supported: token\"),\n });\n });\n\n it(\"getField not implemented\", async () => {\n const contextModule = new DefaultContextModule({\n ...defaultContextModuleConfig,\n customLoaders: [{ load: vi.fn() }],\n });\n\n const res = await contextModule.getContext({\n type: \"token\",\n } as TransactionFieldContext);\n\n expect(res).toEqual({\n type: \"error\",\n error: new Error(\"Field type not supported: token\"),\n });\n });\n\n it(\"should throw an error if origin token is not provided\", () => {\n expect(\n () =>\n new DefaultContextModule({\n ...defaultContextModuleConfig,\n originToken: undefined,\n }),\n ).toThrow(\"Origin token is required\");\n });\n});\n"],
5
+ "mappings": "AAAA,OAAS,iBAAAA,MAAqB,kCAC9B,OAAS,QAAAC,EAAM,SAAAC,MAAa,YAS5B,OAAS,wBAAAC,MAA4B,yBAErC,MAAMC,EAA2B,KACxB,CAAE,KAAM,GAAG,GAAG,EAAG,UAAW,GAAG,GAAG,CAAE,GAG7C,SAAS,uBAAwB,IAAM,CACrC,MAAMC,EAA0C,CAAE,KAAM,GAAG,GAAG,CAAE,EAC1DC,EAAkD,CACtD,cAAe,CAAC,EAChB,eAAgB,GAChB,sBAAuBD,EACvB,IAAK,CACH,IAAK,iBACL,KAAM,OACN,OAAQ,MACV,EACA,WAAY,CACV,IAAK,uBACP,EACA,sBAAuB,CACrB,IAAK,sBACP,EACA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aultContextModuleConfig", "res", "loader", "responses"]
7
7
  }
@@ -1,2 +1,2 @@
1
- import{ContainerModule as t}from"inversify";import{configTypes as e}from"./configTypes";const u=o=>new t((n,i,r,f)=>{n(e.Config).toConstantValue(o)});export{u as configModuleFactory};
1
+ import{ContainerModule as n}from"inversify";import{configTypes as e}from"./configTypes";const r=o=>new n(({bind:t})=>{t(e.Config).toConstantValue(o)});export{r as configModuleFactory};
2
2
  //# sourceMappingURL=configModuleFactory.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../../src/config/di/configModuleFactory.ts"],
4
- "sourcesContent": ["import { ContainerModule } from \"inversify\";\n\nimport { type ContextModuleConfig } from \"@/config/model/ContextModuleConfig\";\n\nimport { configTypes } from \"./configTypes\";\n\nexport const configModuleFactory = (config: ContextModuleConfig) =>\n new ContainerModule((bind, _unbind, _isBound, _rebind) => {\n bind<ContextModuleConfig>(configTypes.Config).toConstantValue(config);\n });\n"],
5
- "mappings": "AAAA,OAAS,mBAAAA,MAAuB,YAIhC,OAAS,eAAAC,MAAmB,gBAErB,MAAMC,EAAuBC,GAClC,IAAIH,EAAgB,CAACI,EAAMC,EAASC,EAAUC,IAAY,CACxDH,EAA0BH,EAAY,MAAM,EAAE,gBAAgBE,CAAM,CACtE,CAAC",
6
- "names": ["ContainerModule", "configTypes", "configModuleFactory", "config", "bind", "_unbind", "_isBound", "_rebind"]
4
+ "sourcesContent": ["import { ContainerModule } from \"inversify\";\n\nimport { type ContextModuleConfig } from \"@/config/model/ContextModuleConfig\";\n\nimport { configTypes } from \"./configTypes\";\n\nexport const configModuleFactory = (config: ContextModuleConfig) =>\n new ContainerModule(({ bind }) => {\n bind<ContextModuleConfig>(configTypes.Config).toConstantValue(config);\n });\n"],
5
+ "mappings": "AAAA,OAAS,mBAAAA,MAAuB,YAIhC,OAAS,eAAAC,MAAmB,gBAErB,MAAMC,EAAuBC,GAClC,IAAIH,EAAgB,CAAC,CAAE,KAAAI,CAAK,IAAM,CAChCA,EAA0BH,EAAY,MAAM,EAAE,gBAAgBE,CAAM,CACtE,CAAC",
6
+ "names": ["ContainerModule", "configTypes", "configModuleFactory", "config", "bind"]
7
7
  }
package/lib/esm/src/di.js CHANGED
@@ -1,2 +1,2 @@
1
- import{Container as t}from"inversify";import{configModuleFactory as e}from"./config/di/configModuleFactory";import{externalPluginModuleFactory as n}from"./external-plugin/di/externalPluginModuleFactory";import{nftModuleFactory as a}from"./nft/di/nftModuleFactory";import{nanoPkiModuleFactory as m}from"./pki/di/pkiModuleFactory";import{tokenModuleFactory as i}from"./token/di/tokenModuleFactory";import{transactionModuleFactory as c}from"./transaction/di/transactionModuleFactory";import{trustedNameModuleFactory as f}from"./trusted-name/di/trustedNameModuleFactory";import{typedDataModuleFactory as p}from"./typed-data/di/typedDataModuleFactory";import{uniswapModuleFactory as u}from"./uniswap/di/uniswapModuleFactory";import{web3CheckModuleFactory as d}from"./web3-check/di/web3CheckModuleFactory";const P=({config:r})=>{const o=new t;return o.load(e(r),n(),a(),i(),c(),f(),p(),m(),u(),d()),o};export{P as makeContainer};
1
+ import{Container as t}from"inversify";import{configModuleFactory as e}from"./config/di/configModuleFactory";import{dynamicNetworkModuleFactory as n}from"./dynamic-network/di/dynamicNetworkModuleFactory";import{externalPluginModuleFactory as a}from"./external-plugin/di/externalPluginModuleFactory";import{nftModuleFactory as m}from"./nft/di/nftModuleFactory";import{nanoPkiModuleFactory as i}from"./pki/di/pkiModuleFactory";import{solanaContextModuleFactory as c}from"./solana/di/SolanaContextModuleFactory";import{tokenModuleFactory as f}from"./token/di/tokenModuleFactory";import{transactionModuleFactory as p}from"./transaction/di/transactionModuleFactory";import{trustedNameModuleFactory as d}from"./trusted-name/di/trustedNameModuleFactory";import{typedDataModuleFactory as l}from"./typed-data/di/typedDataModuleFactory";import{uniswapModuleFactory as u}from"./uniswap/di/uniswapModuleFactory";import{web3CheckModuleFactory as y}from"./web3-check/di/web3CheckModuleFactory";const D=({config:r})=>{const o=new t;return o.loadSync(e(r),a(),n(),m(),f(),p(),d(),l(),i(),u(),y(),c()),o};export{D as makeContainer};
2
2
  //# sourceMappingURL=di.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../src/di.ts"],
4
- "sourcesContent": ["import { Container } from \"inversify\";\n\nimport { configModuleFactory } from \"@/config/di/configModuleFactory\";\nimport { type ContextModuleConfig } from \"@/config/model/ContextModuleConfig\";\nimport { externalPluginModuleFactory } from \"@/external-plugin/di/externalPluginModuleFactory\";\nimport { nftModuleFactory } from \"@/nft/di/nftModuleFactory\";\nimport { nanoPkiModuleFactory } from \"@/pki/di/pkiModuleFactory\";\nimport { tokenModuleFactory } from \"@/token/di/tokenModuleFactory\";\nimport { transactionModuleFactory } from \"@/transaction/di/transactionModuleFactory\";\nimport { trustedNameModuleFactory } from \"@/trusted-name/di/trustedNameModuleFactory\";\nimport { typedDataModuleFactory } from \"@/typed-data/di/typedDataModuleFactory\";\nimport { uniswapModuleFactory } from \"@/uniswap/di/uniswapModuleFactory\";\nimport { web3CheckModuleFactory } from \"@/web3-check/di/web3CheckModuleFactory\";\n\ntype MakeContainerArgs = {\n config: ContextModuleConfig;\n};\n\nexport const makeContainer = ({ config }: MakeContainerArgs) => {\n const container = new Container();\n\n container.load(\n configModuleFactory(config),\n externalPluginModuleFactory(),\n nftModuleFactory(),\n tokenModuleFactory(),\n transactionModuleFactory(),\n trustedNameModuleFactory(),\n typedDataModuleFactory(),\n nanoPkiModuleFactory(),\n uniswapModuleFactory(),\n web3CheckModuleFactory(),\n );\n\n return container;\n};\n"],
5
- "mappings": "AAAA,OAAS,aAAAA,MAAiB,YAE1B,OAAS,uBAAAC,MAA2B,kCAEpC,OAAS,+BAAAC,MAAmC,mDAC5C,OAAS,oBAAAC,MAAwB,4BACjC,OAAS,wBAAAC,MAA4B,4BACrC,OAAS,sBAAAC,MAA0B,gCACnC,OAAS,4BAAAC,MAAgC,4CACzC,OAAS,4BAAAC,MAAgC,6CACzC,OAAS,0BAAAC,MAA8B,yCACvC,OAAS,wBAAAC,MAA4B,oCACrC,OAAS,0BAAAC,MAA8B,yCAMhC,MAAMC,EAAgB,CAAC,CAAE,OAAAC,CAAO,IAAyB,CAC9D,MAAMC,EAAY,IAAIb,EAEtB,OAAAa,EAAU,KACRZ,EAAoBW,CAAM,EAC1BV,EAA4B,EAC5BC,EAAiB,EACjBE,EAAmB,EACnBC,EAAyB,EACzBC,EAAyB,EACzBC,EAAuB,EACvBJ,EAAqB,EACrBK,EAAqB,EACrBC,EAAuB,CACzB,EAEOG,CACT",
6
- "names": ["Container", "configModuleFactory", "externalPluginModuleFactory", "nftModuleFactory", "nanoPkiModuleFactory", "tokenModuleFactory", "transactionModuleFactory", "trustedNameModuleFactory", "typedDataModuleFactory", "uniswapModuleFactory", "web3CheckModuleFactory", "makeContainer", "config", "container"]
4
+ "sourcesContent": ["import { Container } from \"inversify\";\n\nimport { configModuleFactory } from \"@/config/di/configModuleFactory\";\nimport { type ContextModuleConfig } from \"@/config/model/ContextModuleConfig\";\nimport { dynamicNetworkModuleFactory } from \"@/dynamic-network/di/dynamicNetworkModuleFactory\";\nimport { externalPluginModuleFactory } from \"@/external-plugin/di/externalPluginModuleFactory\";\nimport { nftModuleFactory } from \"@/nft/di/nftModuleFactory\";\nimport { nanoPkiModuleFactory } from \"@/pki/di/pkiModuleFactory\";\nimport { solanaContextModuleFactory } from \"@/solana/di/SolanaContextModuleFactory\";\nimport { tokenModuleFactory } from \"@/token/di/tokenModuleFactory\";\nimport { transactionModuleFactory } from \"@/transaction/di/transactionModuleFactory\";\nimport { trustedNameModuleFactory } from \"@/trusted-name/di/trustedNameModuleFactory\";\nimport { typedDataModuleFactory } from \"@/typed-data/di/typedDataModuleFactory\";\nimport { uniswapModuleFactory } from \"@/uniswap/di/uniswapModuleFactory\";\nimport { web3CheckModuleFactory } from \"@/web3-check/di/web3CheckModuleFactory\";\n\ntype MakeContainerArgs = {\n config: ContextModuleConfig;\n};\n\nexport const makeContainer = ({ config }: MakeContainerArgs) => {\n const container = new Container();\n\n container.loadSync(\n configModuleFactory(config),\n externalPluginModuleFactory(),\n dynamicNetworkModuleFactory(),\n nftModuleFactory(),\n tokenModuleFactory(),\n transactionModuleFactory(),\n trustedNameModuleFactory(),\n typedDataModuleFactory(),\n nanoPkiModuleFactory(),\n uniswapModuleFactory(),\n web3CheckModuleFactory(),\n solanaContextModuleFactory(),\n );\n\n return container;\n};\n"],
5
+ "mappings": "AAAA,OAAS,aAAAA,MAAiB,YAE1B,OAAS,uBAAAC,MAA2B,kCAEpC,OAAS,+BAAAC,MAAmC,mDAC5C,OAAS,+BAAAC,MAAmC,mDAC5C,OAAS,oBAAAC,MAAwB,4BACjC,OAAS,wBAAAC,MAA4B,4BACrC,OAAS,8BAAAC,MAAkC,yCAC3C,OAAS,sBAAAC,MAA0B,gCACnC,OAAS,4BAAAC,MAAgC,4CACzC,OAAS,4BAAAC,MAAgC,6CACzC,OAAS,0BAAAC,MAA8B,yCACvC,OAAS,wBAAAC,MAA4B,oCACrC,OAAS,0BAAAC,MAA8B,yCAMhC,MAAMC,EAAgB,CAAC,CAAE,OAAAC,CAAO,IAAyB,CAC9D,MAAMC,EAAY,IAAIf,EAEtB,OAAAe,EAAU,SACRd,EAAoBa,CAAM,EAC1BX,EAA4B,EAC5BD,EAA4B,EAC5BE,EAAiB,EACjBG,EAAmB,EACnBC,EAAyB,EACzBC,EAAyB,EACzBC,EAAuB,EACvBL,EAAqB,EACrBM,EAAqB,EACrBC,EAAuB,EACvBN,EAA2B,CAC7B,EAEOS,CACT",
6
+ "names": ["Container", "configModuleFactory", "dynamicNetworkModuleFactory", "externalPluginModuleFactory", "nftModuleFactory", "nanoPkiModuleFactory", "solanaContextModuleFactory", "tokenModuleFactory", "transactionModuleFactory", "trustedNameModuleFactory", "typedDataModuleFactory", "uniswapModuleFactory", "web3CheckModuleFactory", "makeContainer", "config", "container"]
7
7
  }
@@ -0,0 +1 @@
1
+ //# sourceMappingURL=DynamicNetworkDataSource.js.map
@@ -0,0 +1,2 @@
1
+ var u=Object.defineProperty;var m=Object.getOwnPropertyDescriptor;var f=(n,o,r,e)=>{for(var t=e>1?void 0:e?m(o,r):o,i=n.length-1,a;i>=0;i--)(a=n[i])&&(t=(e?a(o,r,t):a(t))||t);return e&&t&&u(o,r,t),t},p=(n,o)=>(r,e)=>o(r,e,n);import d from"axios";import{inject as g,injectable as y}from"inversify";import{Left as c,Right as l}from"purify-ts";import{configTypes as D}from"../../config/di/configTypes";import{LEDGER_CLIENT_VERSION_HEADER as w}from"../../shared/constant/HttpHeaders";import k from"../../../package.json";let s=class{constructor(o){this.config=o}async getDynamicNetworkConfiguration(o){let r;try{r=(await d.get(`${this.config.cal.url}/networks?output=id,descriptors,icons&chain_id=${o}`,{headers:{[w]:`context-module/${k.version}`}})).data}catch(i){return c(i instanceof Error?i:new Error("Failed to fetch network configuration"))}const e=r?.[0];if(!e)return c(new Error(`Network configuration not found for chain ID: ${o}`));if(!this.isValidNetworkData(e))return c(new Error(`Invalid network configuration response for chain ID: ${o}`));const t=this.transformToNetworkConfiguration(e);return l(t)}isValidNetworkData(o){if(!o||typeof o!="object")return!1;const r=o;if(typeof r.id!="string"||!r.descriptors||typeof r.descriptors!="object")return!1;for(const e of Object.values(r.descriptors))if(!this.isValidDescriptor(e))return!1;return!(r.icons&&typeof r.icons!="object")}isValidDescriptor(o){if(!o||typeof o!="object")return!1;const r=o;if(typeof r.data!="string"||typeof r.descriptorType!="string"||typeof r.descriptorVersion!="string"||!r.signatures||typeof r.signatures!="object")return!1;const e=r.signatures;return!(typeof e.prod!="string"||typeof e.test!="string")}transformToNetworkConfiguration(o){const r=Object.entries(o.descriptors).reduce((e,[t,i])=>(e[t]={descriptorType:i.descriptorType,descriptorVersion:i.descriptorVersion,data:i.data,signatures:i.signatures,icon:o.icons?.[t]},e),{});return{id:o.id,descriptors:r}}};s=f([y(),p(0,g(D.Config))],s);export{s as HttpDynamicNetworkDataSource};
2
+ //# sourceMappingURL=HttpDynamicNetworkDataSource.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../../../src/dynamic-network/data/HttpDynamicNetworkDataSource.ts"],
4
+ "sourcesContent": ["import { type DeviceModelId } from \"@ledgerhq/device-management-kit\";\nimport 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 type DynamicNetworkConfiguration,\n type DynamicNetworkDescriptor,\n} from \"@/dynamic-network/model/DynamicNetworkConfiguration\";\nimport { LEDGER_CLIENT_VERSION_HEADER } from \"@/shared/constant/HttpHeaders\";\nimport PACKAGE from \"@root/package.json\";\n\nimport { type DynamicNetworkApiResponseDto } from \"./dto/DynamicNetworkApiResponseDto\";\nimport { type DynamicNetworkDataSource } from \"./DynamicNetworkDataSource\";\n\n@injectable()\nexport class HttpDynamicNetworkDataSource implements DynamicNetworkDataSource {\n constructor(\n @inject(configTypes.Config) private readonly config: ContextModuleConfig,\n ) {}\n\n async getDynamicNetworkConfiguration(\n chainId: number,\n ): Promise<Either<Error, DynamicNetworkConfiguration>> {\n let response: DynamicNetworkApiResponseDto;\n\n try {\n const axiosResponse = await axios.get<DynamicNetworkApiResponseDto>(\n `${this.config.cal.url}/networks?output=id,descriptors,icons&chain_id=${chainId}`,\n {\n headers: {\n [LEDGER_CLIENT_VERSION_HEADER]: `context-module/${PACKAGE.version}`,\n },\n },\n );\n response = axiosResponse.data;\n } catch (error) {\n return Left(\n error instanceof Error\n ? error\n : new Error(\"Failed to fetch network configuration\"),\n );\n }\n\n const networkData = response?.[0];\n if (!networkData) {\n return Left(\n new Error(`Network configuration not found for chain ID: ${chainId}`),\n );\n }\n\n // Validate response structure\n if (!this.isValidNetworkData(networkData)) {\n return Left(\n new Error(\n `Invalid network configuration response for chain ID: ${chainId}`,\n ),\n );\n }\n\n const configuration = this.transformToNetworkConfiguration(networkData);\n return Right(configuration);\n }\n\n private isValidNetworkData(\n data: unknown,\n ): data is DynamicNetworkApiResponseDto[0] {\n if (!data || typeof data !== \"object\") {\n return false;\n }\n\n const obj = data as Record<string, unknown>;\n\n // Check required fields\n if (typeof obj[\"id\"] !== \"string\") {\n return false;\n }\n\n // Check descriptors structure\n if (!obj[\"descriptors\"] || typeof obj[\"descriptors\"] !== \"object\") {\n return false;\n }\n\n // Validate each descriptor\n for (const descriptor of Object.values(obj[\"descriptors\"])) {\n if (!this.isValidDescriptor(descriptor)) {\n return false;\n }\n }\n\n // Icons are optional but if present, should be an object\n if (obj[\"icons\"] && typeof obj[\"icons\"] !== \"object\") {\n return false;\n }\n\n return true;\n }\n\n private isValidDescriptor(\n descriptor: unknown,\n ): descriptor is DynamicNetworkApiResponseDto[0][\"descriptors\"][string] {\n if (!descriptor || typeof descriptor !== \"object\") {\n return false;\n }\n\n const desc = descriptor as Record<string, unknown>;\n\n // Check required descriptor fields\n if (\n typeof desc[\"data\"] !== \"string\" ||\n typeof desc[\"descriptorType\"] !== \"string\" ||\n typeof desc[\"descriptorVersion\"] !== \"string\"\n ) {\n return false;\n }\n\n // Check signatures structure\n if (!desc[\"signatures\"] || typeof desc[\"signatures\"] !== \"object\") {\n return false;\n }\n\n const signatures = desc[\"signatures\"] as Record<string, unknown>;\n if (\n typeof signatures[\"prod\"] !== \"string\" ||\n typeof signatures[\"test\"] !== \"string\"\n ) {\n return false;\n }\n\n return true;\n }\n\n private transformToNetworkConfiguration(\n networkData: DynamicNetworkApiResponseDto[0],\n ): DynamicNetworkConfiguration {\n const descriptors = Object.entries(networkData.descriptors).reduce(\n (acc, [deviceModel, descriptor]) => {\n acc[deviceModel as DeviceModelId] = {\n descriptorType: descriptor.descriptorType,\n descriptorVersion: descriptor.descriptorVersion,\n data: descriptor.data,\n signatures: descriptor.signatures,\n icon: networkData.icons?.[deviceModel],\n };\n return acc;\n },\n {} as Record<D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OA,EAAI,OAAa,SAK9C,CAEQ,kBACNC,EACsE,CACtE,GAAI,CAACA,GAAc,OAAOA,GAAe,SACvC,MAAO,GAGT,MAAMC,EAAOD,EAYb,GARE,OAAOC,EAAK,MAAY,UACxB,OAAOA,EAAK,gBAAsB,UAClC,OAAOA,EAAK,mBAAyB,UAMnC,CAACA,EAAK,YAAiB,OAAOA,EAAK,YAAkB,SACvD,MAAO,GAGT,MAAMC,EAAaD,EAAK,WACxB,MACE,SAAOC,EAAW,MAAY,UAC9B,OAAOA,EAAW,MAAY,SAMlC,CAEQ,gCACNP,EAC6B,CAC7B,MAAMQ,EAAc,OAAO,QAAQR,EAAY,WAAW,EAAE,OAC1D,CAACS,EAAK,CAACC,EAAaL,CAAU,KAC5BI,EAAIC,CAA4B,EAAI,CAClC,eAAgBL,EAAW,eAC3B,kBAAmBA,EAAW,kBAC9B,KAAMA,EAAW,KACjB,WAAYA,EAAW,WACvB,KAAML,EAAY,QAAQU,CAAW,CACvC,EACOD,GAET,CAAC,CACH,EAEA,MAAO,CACL,GAAIT,EAAY,GAChB,YAAAQ,CACF,CACF,CACF,EA1IajB,EAANoB,EAAA,CADNC,EAAW,EAGPC,EAAA,EAAAC,EAAOC,EAAY,MAAM,IAFjBxB",
6
+ "names": ["axios", "inject", "injectable", "Left", "Right", "configTypes", "LEDGER_CLIENT_VERSION_HEADER", "PACKAGE", "HttpDynamicNetworkDataSource", "config", "chainId", "response", "axios", "LEDGER_CLIENT_VERSION_HEADER", "PACKAGE", "error", "Left", "networkData", "configuration", "Right", "data", "obj", "descriptor", "desc", "signatures", "descriptors", "acc", "deviceModel", "__decorateClass", "injectable", "__decorateParam", "inject", "configTypes"]
7
+ }
@@ -0,0 +1,2 @@
1
+ import a from"axios";import{Left as c,Right as u}from"purify-ts";import{beforeAll as g,beforeEach as p,describe as l,expect as o,it as i,vi as r}from"vitest";import{HttpDynamicNetworkDataSource as w}from"./HttpDynamicNetworkDataSource";r.mock("axios");l("HttpNetworkDataSource",()=>{let n;const f={cal:{url:"https://crypto-assets-service.api.ledger.com",mode:"prod",branch:"main"}},s={data:[{id:"ethereum",descriptors:{flex:{data:"0x010108020101510101230800000000000000895207506f6c79676f6e2403504f4c",descriptorType:"network",descriptorVersion:"v1",signatures:{prod:"3045022100c116b5470c266c2947b92aa9eadbe3da03305efc6b8fee041e04e8484a9834af022041d5b82b359614ea8dd94a542dfd87b0ae6f3b4a075aad9a53a030064ab42cd0",test:"3045022100f78bac5c9c3f2ceeea26680aaea17be61fce84ae7ec983a8194e68275f4fe5900220231afbe39fcec63edfea2b4e787a72d79ce53d6a4c408f24b5a116905a9082d3"}},stax:{data:"0x010108020101510101230800000000000000895207506f6c79676f6e2403504f4c53204aa5034d2fd4c46647d382aa64d0a03d06b185512bb7942390318bda18d0423a",descriptorType:"network",descriptorVersion:"v1",signatures:{prod:"3045022100cf42c039c16fc95dc97c09f15cdd93bed0e63ee45cf5c38c2b30bb8a3bc17f8d022053a96c9e51695c3c1c1a31f5cbf84bd6febadc97f4bb02bdc67cf3e24ad0c32d",test:"304402207e1e1b8f99b45c95b0cf1e90f46cf07e6a90f82c49ccdb6e2e95ab0c1e2f5a370220784e1fac16bb01c5d096733e1cbf067d616e4de659fda2c388f8c3502e7f7f80"}}}}]};g(()=>{n=new w(f)}),p(()=>{r.clearAllMocks()}),l("getNetworkConfiguration",()=>{i("should return network configuration successfully",async()=>{r.mocked(a.get).mockResolvedValue(s);const e=await n.getDynamicNetworkConfiguration(1);o(a.get).toHaveBeenCalledWith("https://crypto-assets-service.api.ledger.com/networks?output=id,descriptors,icons&chain_id=1",o.objectContaining({headers:o.any(Object)})),o(e).toEqual(u({id:"ethereum",descriptors:{flex:{data:"0x010108020101510101230800000000000000895207506f6c79676f6e2403504f4c",descriptorType:"network",descriptorVersion:"v1",signatures:{prod:"3045022100c116b5470c266c2947b92aa9eadbe3da03305efc6b8fee041e04e8484a9834af022041d5b82b359614ea8dd94a542dfd87b0ae6f3b4a075aad9a53a030064ab42cd0",test:"3045022100f78bac5c9c3f2ceeea26680aaea17be61fce84ae7ec983a8194e68275f4fe5900220231afbe39fcec63edfea2b4e787a72d79ce53d6a4c408f24b5a116905a9082d3"},icon:void 0},stax:{data:"0x010108020101510101230800000000000000895207506f6c79676f6e2403504f4c53204aa5034d2fd4c46647d382aa64d0a03d06b185512bb7942390318bda18d0423a",descriptorType:"network",descriptorVersion:"v1",signatures:{prod:"3045022100cf42c039c16fc95dc97c09f15cdd93bed0e63ee45cf5c38c2b30bb8a3bc17f8d022053a96c9e51695c3c1c1a31f5cbf84bd6febadc97f4bb02bdc67cf3e24ad0c32d",test:"304402207e1e1b8f99b45c95b0cf1e90f46cf07e6a90f82c49ccdb6e2e95ab0c1e2f5a370220784e1fac16bb01c5d096733e1cbf067d616e4de659fda2c388f8c3502e7f7f80"},icon:void 0}}}))}),i("should return error when network data is not found",async()=>{r.mocked(a.get).mockResolvedValue({data:[]});const e=await n.getDynamicNetworkConfiguration(1);o(e).toEqual(c(new Error("Network configuration not found for chain ID: 1")))}),i("should return error when network data is undefined",async()=>{r.mocked(a.get).mockResolvedValue({data:void 0});const e=await n.getDynamicNetworkConfiguration(1);o(e).toEqual(c(new Error("Network configuration not found for chain ID: 1")))}),i("should return error when axios throws an error",async()=>{r.mocked(a.get).mockRejectedValue(new Error("Network error"));const e=await n.getDynamicNetworkConfiguration(1);o(e).toEqual(c(new Error("Network error")))}),i("should return generic error when axios throws non-Error",async()=>{r.mocked(a.get).mockRejectedValue("String error");const e=await n.getDynamicNetworkConfiguration(1);o(e).toEqual(c(new Error("Failed to fetch network configuration")))}),i("should handle invalid data - missing id",async()=>{const e={data:[{descriptors:{}}]};r.mocked(a.get).mockResolvedValue(e);const t=await n.getDynamicNetworkConfiguration(1);o(t).toEqual(c(new Error("Invalid network configuration response for chain ID: 1")))}),i("should handle invalid data - missing descriptors",async()=>{const e={data:[{id:"ethereum"}]};r.mocked(a.get).mockResolvedValue(e);const t=await n.getDynamicNetworkConfiguration(1);o(t).toEqual(c(new Error("Invalid network configuration response for chain ID: 1")))}),i("should handle invalid descriptor - missing data field",async()=>{const e={data:[{id:"ethereum",descriptors:{flex:{descriptorType:"network",descriptorVersion:"v1",signatures:{prod:"sig1",test:"sig2"}}}}]};r.mocked(a.get).mockResolvedValue(e);const t=await n.getDynamicNetworkConfiguration(1);o(t).toEqual(c(new Error("Invalid network configuration response for chain ID: 1")))}),i("should handle invalid descriptor - missing signatures",async()=>{const e={data:[{id:"ethereum",descriptors:{flex:{data:"0x0101",descriptorType:"network",descriptorVersion:"v1"}}}]};r.mocked(a.get).mockResolvedValue(e);const t=await n.getDynamicNetworkConfiguration(1);o(t).toEqual(c(new Error("Invalid network configuration response for chain ID: 1")))}),i("should handle invalid signatures - missing prod",async()=>{const e={data:[{id:"ethereum",descriptors:{flex:{data:"0x0101",descriptorType:"network",descriptorVersion:"v1",signatures:{test:"sig2"}}}}]};r.mocked(a.get).mockResolvedValue(e);const t=await n.getDynamicNetworkConfiguration(1);o(t).toEqual(c(new Error("Invalid network configuration response for chain ID: 1")))}),i("should include icons when available",async()=>{const e={data:[{id:"ethereum",descriptors:{flex:{data:"0x0101",descriptorType:"network",descriptorVersion:"v1",signatures:{prod:"sig1",test:"sig2"}},stax:{data:"0x0102",descriptorType:"network",descriptorVersion:"v1",signatures:{prod:"sig3",test:"sig4"}}},icons:{flex:"icon1",stax:"icon2"}}]};r.mocked(a.get).mockResolvedValue(e);const t=await n.getDynamicNetworkConfiguration(1);o(t.isRight()).toBe(!0);const d=t.unsafeCoerce();o(d.descriptors.flex.icon).toBe("icon1"),o(d.descriptors.stax.icon).toBe("icon2")}),i("should transform data correctly for Polygon chain ID",async()=>{r.mocked(a.get).mockResolvedValue(s);const e=await n.getDynamicNetworkConfiguration(137);o(a.get).toHaveBeenCalledWith("https://crypto-assets-service.api.ledger.com/networks?output=id,descriptors,icons&chain_id=137",o.objectContaining({headers:o.any(Object)})),o(e.isRight()).toBe(!0);const t=e.unsafeCoerce();o(Object.keys(t.descriptors)).toEqual(["flex","stax"])}),i("should handle invalid data - null data",async()=>{const e={data:[null]};r.mocked(a.get).mockResolvedValue(e);const t=await n.getDynamicNetworkConfiguration(1);o(t).toEqual(c(new Error("Network configuration not found for chain ID: 1")))}),i("should handle invalid data - non-object data",async()=>{const e={data:["string_instead_of_object"]};r.mocked(a.get).mockResolvedValue(e);const t=await n.getDynamicNetworkConfiguration(1);o(t).toEqual(c(new Error("Invalid network configuration response for chain ID: 1")))}),i("should handle invalid data - icons as string instead of object",async()=>{const e={data:[{id:"ethereum",descriptors:{flex:{data:"0x0101",descriptorType:"network",descriptorVersion:"v1",signatures:{prod:"sig1",test:"sig2"}}},icons:"should_be_object_not_string"}]};r.mocked(a.get).mockResolvedValue(e);const t=await n.getDynamicNetworkConfiguration(1);o(t).toEqual(c(new Error("Invalid network configuration response for chain ID: 1")))}),i("should handle invalid data - icons as number instead of object (line 93)",async()=>{const e={data:[{id:"ethereum",descriptors:{flex:{data:"0x0101",descriptorType:"network",descriptorVersion:"v1",signatures:{prod:"sig1",test:"sig2"}}},icons:123}]};r.mocked(a.get).mockResolvedValue(e);const t=await n.getDynamicNetworkConfiguration(1);o(t).toEqual(c(new Error("Invalid network configuration response for chain ID: 1")))}),i("should handle invalid descriptor - null descriptor (line 103)",async()=>{const e={data:[{id:"ethereum",descriptors:{flex:null}}]};r.mocked(a.get).mockResolvedValue(e);const t=await n.getDynamicNetworkConfiguration(1);o(t).toEqual(c(new Error("Invalid network configuration response for chain ID: 1")))}),i("should handle invalid descriptor - non-object descriptor (line 103)",async()=>{const e={data:[{id:"ethereum",descriptors:{flex:"should_be_object_not_string"}}]};r.mocked(a.get).mockResolvedValue(e);const t=await n.getDynamicNetworkConfiguration(1);o(t).toEqual(c(new Error("Invalid network configuration response for chain ID: 1")))})})});
2
+ //# sourceMappingURL=HttpDynamicNetworkDataSource.test.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../../../src/dynamic-network/data/HttpDynamicNetworkDataSource.test.ts"],
4
+ "sourcesContent": ["import axios from \"axios\";\nimport { Left, Right } from \"purify-ts\";\nimport { beforeAll, beforeEach, describe, expect, it, vi } from \"vitest\";\n\nimport { type ContextModuleConfig } from \"@/config/model/ContextModuleConfig\";\n\nimport { HttpDynamicNetworkDataSource } from \"./HttpDynamicNetworkDataSource\";\n\nvi.mock(\"axios\");\n\ndescribe(\"HttpNetworkDataSource\", () => {\n let datasource: HttpDynamicNetworkDataSource;\n const mockConfig: ContextModuleConfig = {\n cal: {\n url: \"https://crypto-assets-service.api.ledger.com\",\n mode: \"prod\",\n branch: \"main\",\n },\n } as ContextModuleConfig;\n\n const mockNetworkResponse = {\n data: [\n {\n id: \"ethereum\",\n descriptors: {\n flex: {\n data: \"0x010108020101510101230800000000000000895207506f6c79676f6e2403504f4c\",\n descriptorType: \"network\",\n descriptorVersion: \"v1\",\n signatures: {\n prod: \"3045022100c116b5470c266c2947b92aa9eadbe3da03305efc6b8fee041e04e8484a9834af022041d5b82b359614ea8dd94a542dfd87b0ae6f3b4a075aad9a53a030064ab42cd0\",\n test: \"3045022100f78bac5c9c3f2ceeea26680aaea17be61fce84ae7ec983a8194e68275f4fe5900220231afbe39fcec63edfea2b4e787a72d79ce53d6a4c408f24b5a116905a9082d3\",\n },\n },\n stax: {\n data: \"0x010108020101510101230800000000000000895207506f6c79676f6e2403504f4c53204aa5034d2fd4c46647d382aa64d0a03d06b185512bb7942390318bda18d0423a\",\n descriptorType: \"network\",\n descriptorVersion: \"v1\",\n signatures: {\n prod: \"3045022100cf42c039c16fc95dc97c09f15cdd93bed0e63ee45cf5c38c2b30bb8a3bc17f8d022053a96c9e51695c3c1c1a31f5cbf84bd6febadc97f4bb02bdc67cf3e24ad0c32d\",\n test: \"304402207e1e1b8f99b45c95b0cf1e90f46cf07e6a90f82c49ccdb6e2e95ab0c1e2f5a370220784e1fac16bb01c5d096733e1cbf067d616e4de659fda2c388f8c3502e7f7f80\",\n },\n },\n },\n },\n ],\n };\n\n beforeAll(() => {\n datasource = new HttpDynamicNetworkDataSource(mockConfig);\n });\n\n beforeEach(() => {\n vi.clearAllMocks();\n });\n\n describe(\"getNetworkConfiguration\", () => {\n it(\"should return network configuration successfully\", async () => {\n vi.mocked(axios.get).mockResolvedValue(mockNetworkResponse);\n\n const result = await datasource.getDynamicNetworkConfiguration(1);\n\n expect(axios.get).toHaveBeenCalledWith(\n \"https://crypto-assets-service.api.ledger.com/networks?output=id,descriptors,icons&chain_id=1\",\n expect.objectContaining({\n headers: expect.any(Object) as Record<string, string>,\n }),\n );\n\n expect(result).toEqual(\n Right({\n id: \"ethereum\",\n descriptors: {\n flex: {\n data: \"0x010108020101510101230800000000000000895207506f6c79676f6e2403504f4c\",\n descriptorType: \"network\",\n descriptorVersion: \"v1\",\n signatures: {\n prod: \"3045022100c116b5470c266c2947b92aa9eadbe3da03305efc6b8fee041e04e8484a9834af022041d5b82b359614ea8dd94a542dfd87b0ae6f3b4a075aad9a53a030064ab42cd0\",\n test: \"3045022100f78bac5c9c3f2ceeea26680aaea17be61fce84ae7ec983a8194e68275f4fe5900220231afbe39fcec63edfea2b4e787a72d79ce53d6a4c408f24b5a116905a9082d3\",\n },\n icon: undefined,\n },\n stax: {\n data: \"0x010108020101510101230800000000000000895207506f6c79676f6e2403504f4c53204aa5034d2fd4c46647d382aa64d0a03d06b185512bb7942390318bda18d0423a\",\n descriptorType: \"network\",\n descriptorVersion: \"v1\",\n signatures: {\n prod: \"3045022100cf42c039c16fc95dc97c09f15cdd93bed0e63ee45cf5c38c2b30bb8a3bc17f8d022053a96c9e51695c3c1c1a31f5cbf84bd6febadc97f4bb02bdc67cf3e24ad0c32d\",\n test: \"304402207e1e1b8f99b45c95b0cf1e90f46cf07e6a90f82c49ccdb6e2e95ab0c1e2f5a370220784e1fac16bb01c5d096733e1cbf067d616e4de659fda2c388f8c3502e7f7f80\",\n },\n icon: undefined,\n },\n },\n }),\n );\n });\n\n it(\"should return error when network data is not found\", async () => {\n vi.mocked(axios.get).mockResolvedValue({ data: [] });\n\n const result = await datasource.getDynamicNetworkConfiguration(1);\n\n expect(result).toEqual(\n Left(new Error(\"Network configuration not found for chain ID: 1\")),\n );\n });\n\n it(\"should return error when network data is undefined\", async () => {\n vi.mocked(axios.get).mockResolvedValue({ data: undefined });\n\n const result = await datasource.getDynamicNetworkConfiguration(1);\n\n expect(result).toEqual(\n Left(new Error(\"Network configuration not found for chain ID: 1\")),\n );\n });\n\n it(\"should return error when axios throws an error\", async () => {\n vi.mocked(axios.get).mockRejectedValue(new Error(\"Network error\"));\n\n const result = await datasource.getDynamicNetworkConfiguration(1);\n\n expect(result).toEqual(Left(new Error(\"Network error\")));\n });\n\n it(\"should return generic error when axios throws non-Error\", async () => {\n vi.mocked(axios.get).mockRejectedValue(\"String error\");\n\n const result = await datasource.getDynamicNetworkConfiguration(1);\n\n expect(result).toEqual(\n Left(new Error(\"Failed to fetch network configuration\")),\n );\n });\n\n it(\"should handle invalid data - missing id\", async () => {\n const invalidResponse = {\n data: [\n {\n // Missing id\n descriptors: {},\n },\n ],\n };\n vi.mocked(axios.get).mockResolvedValue(invalidResponse);\n\n const result = await datasource.getDynamicNetworkConfiguration(1);\n\n expect(result).toEqual(\n Left(\n new Error(\"Invalid network configuration response for chain ID: 1\"),\n ),\n );\n });\n\n it(\"should handle invalid data - missing descriptors\", async () => {\n const invalidResponse = {\n data: [\n {\n id: \"ethereum\",\n // Missing descriptors\n },\n ],\n };\n vi.mocked(axios.get).mockResolvedValue(invalidResponse);\n\n const result = await datasource.getDynamicNetworkConfiguration(1);\n\n expect(result).toEqual(\n Left(\n new Error(\"Invalid network configuration response for chain ID: 1\"),\n ),\n );\n });\n\n it(\"should handle invalid descriptor - missing data field\", async () => {\n const invalidResponse = {\n data: [\n {\n id: \"ethereum\",\n descriptors: {\n flex: {\n // Missing data\n descriptorType: \"network\",\n descriptorVersion: \"v1\",\n signatures: { prod: \"sig1\", test: \"sig2\" },\n },\n },\n },\n ],\n };\n vi.mocked(axios.get).mockResolvedValue(invalidResponse);\n\n const result = await datasource.getDynamicNetworkConfiguration(1);\n\n expect(result).toEqual(\n Left(\n new Error(\"Invalid network configuration response for chain ID: 1\"),\n ),\n );\n });\n\n it(\"should handle invalid descriptor - missing signatures\", async () => {\n const invalidResponse = {\n data: [\n {\n id: \"ethereum\",\n descriptors: {\n flex: {\n data: \"0x0101\",\n descriptorType: \"network\",\n descriptorVersion: \"v1\",\n // Missing signatures\n },\n },\n },\n ],\n };\n vi.mocked(axios.get).mockResolvedValue(invalidResponse);\n\n const result = await datasource.getDynamicNetworkConfiguration(1);\n\n expect(result).toEqual(\n Left(\n new Error(\"Invalid network configuration response for chain ID: 1\"),\n ),\n );\n });\n\n it(\"should handle invalid signatures - missing prod\", async () => {\n const invalidResponse = {\n data: [\n {\n id: \"ethereum\",\n descriptors: {\n flex: {\n data: \"0x0101\",\n descriptorType: \"network\",\n descriptorVersion: \"v1\",\n signatures: {\n // Missing prod\n test: \"sig2\",\n },\n },\n },\n },\n ],\n };\n vi.mocked(axios.get).mockResolvedValue(invalidResponse);\n\n const result = await datasource.getDynamicNetworkConfiguration(1);\n\n expect(result).toEqual(\n Left(\n new Error(\"Invalid network configuration response for chain ID: 1\"),\n ),\n );\n });\n\n it(\"should include icons when available\", async () => {\n const responseWithIcons = {\n data: [\n {\n id: \"ethereum\",\n descriptors: {\n flex: {\n data: \"0x0101\",\n descriptorType: \"network\",\n descriptorVersion: \"v1\",\n signatures: {\n prod: \"sig1\",\n test: \"sig2\",\n },\n },\n stax: {\n data: \"0x0102\",\n descriptorType: \"network\",\n descriptorVersion: \"v1\",\n signatures: {\n prod: \"sig3\",\n test: \"sig4\",\n },\n },\n },\n icons: {\n flex: \"icon1\",\n stax: \"icon2\",\n },\n },\n ],\n };\n vi.mocked(axios.get).mockResolvedValue(responseWithIcons);\n\n const result = await datasource.getDynamicNetworkConfiguration(1);\n\n expect(result.isRight()).toBe(true);\n const configuration = result.unsafeCoerce();\n expect(configuration.descriptors.flex.icon).toBe(\"icon1\");\n expect(configuration.descriptors.stax.icon).toBe(\"icon2\");\n });\n\n it(\"should transform data correctly for Polygon chain ID\", async () => {\n vi.mocked(axios.get).mockResolvedValue(mockNetworkResponse);\n\n const result = await datasource.getDynamicNetworkConfiguration(137);\n\n expect(axios.get).toHaveBeenCalledWith(\n \"https://crypto-assets-service.api.ledger.com/networks?output=id,descriptors,icons&chain_id=137\",\n expect.objectContaining({\n headers: expect.any(Object) as Record<string, string>,\n }),\n );\n\n expect(result.isRight()).toBe(true);\n const configuration = result.unsafeCoerce();\n expect(Object.keys(configuration.descriptors)).toEqual([\"flex\", \"stax\"]);\n });\n\n it(\"should handle invalid data - null data\", async () => {\n const invalidResponse = {\n data: [null],\n };\n vi.mocked(axios.get).mockResolvedValue(invalidResponse);\n\n const result = await datasource.getDynamicNetworkConfiguration(1);\n\n expect(result).toEqual(\n Left(new Error(\"Network configuration not found for chain ID: 1\")),\n );\n });\n\n it(\"should handle invalid data - non-object data\", async () => {\n const invalidResponse = {\n data: [\"string_instead_of_object\"],\n };\n vi.mocked(axios.get).mockResolvedValue(invalidResponse);\n\n const result = await datasource.getDynamicNetworkConfiguration(1);\n\n expect(result).toEqual(\n Left(\n new Error(\"Invalid network configuration response for chain ID: 1\"),\n ),\n );\n });\n\n it(\"should handle invalid data - icons as string instead of object\", async () => {\n const invalidResponse = {\n data: [\n {\n id: \"ethereum\",\n descriptors: {\n flex: {\n data: \"0x0101\",\n descriptorType: \"network\",\n descriptorVersion: \"v1\",\n signatures: {\n prod: \"sig1\",\n test: \"sig2\",\n },\n },\n },\n icons: \"should_be_object_not_string\",\n },\n ],\n };\n vi.mocked(axios.get).mockResolvedValue(invalidResponse);\n\n const result = await datasource.getDynamicNetworkConfiguration(1);\n\n expect(result).toEqual(\n Left(\n new Error(\"Invalid network configuration response for chain ID: 1\"),\n ),\n );\n });\n\n it(\"should handle invalid data - icons as number instead of object (line 93)\", async () => {\n const invalidResponse = {\n data: [\n {\n id: \"ethereum\",\n descriptors: {\n flex: {\n data: \"0x0101\",\n descriptorType: \"network\",\n descriptorVersion: \"v1\",\n signatures: {\n prod: \"sig1\",\n test: \"sig2\",\n },\n },\n },\n icons: 123,\n },\n ],\n };\n vi.mocked(axios.get).mockResolvedValue(invalidResponse);\n\n const result = await datasource.getDynamicNetworkConfiguration(1);\n\n expect(result).toEqual(\n Left(\n new Error(\"Invalid network configuration response for chain ID: 1\"),\n ),\n );\n });\n\n it(\"should handle invalid descriptor - null descriptor (line 103)\", async () => {\n const invalidResponse = {\n data: [\n {\n id: \"ethereum\",\n descriptors: {\n flex: null,\n },\n },\n ],\n };\n vi.mocked(axios.get).mockResolvedValue(invalidResponse);\n\n const result = await datasource.getDynamicNetworkConfiguration(1);\n\n expect(result).toEqual(\n Left(\n new Error(\"Invalid network configuration response for chain ID: 1\"),\n ),\n );\n });\n\n it(\"should handle invalid descriptor - non-object descriptor (line 103)\", async () => {\n const invalidResponse = {\n data: [\n {\n id: \"ethereum\",\n descriptors: {\n flex: \"should_be_object_not_string\",\n },\n },\n ],\n };\n vi.mocked(axios.get).mockResolvedValue(invalidResponse);\n\n const result = await datasource.getDynamicNetworkConfiguration(1);\n\n expect(result).toEqual(\n Left(\n new Error(\"Invalid network configuration response for chain ID: 1\"),\n ),\n );\n });\n });\n});\n"],
5
+ "mappings": "AAAA,OAAOA,MAAW,QAClB,OAAS,QAAAC,EAAM,SAAAC,MAAa,YAC5B,OAAS,aAAAC,EAAW,cAAAC,EAAY,YAAAC,EAAU,UAAAC,EAAQ,MAAAC,EAAI,MAAAC,MAAU,SAIhE,OAAS,gCAAAC,MAAoC,iCAE7CD,EAAG,KAAK,OAAO,EAEfH,EAAS,wBAAyB,IAAM,CACtC,IAAIK,EACJ,MAAMC,EAAkC,CACtC,IAAK,CACH,IAAK,+CACL,KAAM,OACN,OAAQ,MACV,CACF,EAEMC,EAAsB,CAC1B,KAAM,CACJ,CACE,GAAI,WACJ,YAAa,CACX,KAAM,CACJ,KAAM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AC,EAEDM,EAAG,sEAAuE,SAAY,CACpF,MAAMO,EAAkB,CACtB,KAAM,CACJ,CACE,GAAI,WACJ,YAAa,CACX,KAAM,6BACR,CACF,CACF,CACF,EACAN,EAAG,OAAOR,EAAM,GAAG,EAAE,kBAAkBc,CAAe,EAEtD,MAAMD,EAAS,MAAMH,EAAW,+BAA+B,CAAC,EAEhEJ,EAAOO,CAAM,EAAE,QACbZ,EACE,IAAI,MAAM,wDAAwD,CACpE,CACF,CACF,CAAC,CACH,CAAC,CACH,CAAC",
6
+ "names": ["axios", "Left", "Right", "beforeAll", "beforeEach", "describe", "expect", "it", "vi", "HttpDynamicNetworkDataSource", "datasource", "mockConfig", "mockNetworkResponse", "result", "invalidResponse", "responseWithIcons", "configuration"]
7
+ }
@@ -0,0 +1 @@
1
+ //# sourceMappingURL=DynamicNetworkApiResponseDto.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": [],
4
+ "sourcesContent": [],
5
+ "mappings": "",
6
+ "names": []
7
+ }
@@ -0,0 +1,2 @@
1
+ import{ContainerModule as r}from"inversify";import{HttpDynamicNetworkDataSource as e}from"../../dynamic-network/data/HttpDynamicNetworkDataSource";import{DynamicNetworkContextLoader as a}from"../../dynamic-network/domain/DynamicNetworkContextLoader";import{dynamicNetworkTypes as t}from"./dynamicNetworkTypes";const y=()=>new r(({bind:o})=>{o(t.DynamicNetworkDataSource).to(e),o(t.DynamicNetworkContextLoader).to(a)});export{y as dynamicNetworkModuleFactory};
2
+ //# sourceMappingURL=dynamicNetworkModuleFactory.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../../../src/dynamic-network/di/dynamicNetworkModuleFactory.ts"],
4
+ "sourcesContent": ["import { ContainerModule } from \"inversify\";\n\nimport { HttpDynamicNetworkDataSource } from \"@/dynamic-network/data/HttpDynamicNetworkDataSource\";\nimport { DynamicNetworkContextLoader } from \"@/dynamic-network/domain/DynamicNetworkContextLoader\";\n\nimport { dynamicNetworkTypes } from \"./dynamicNetworkTypes\";\n\nexport const dynamicNetworkModuleFactory = () =>\n new ContainerModule(({ bind }) => {\n bind(dynamicNetworkTypes.DynamicNetworkDataSource).to(\n HttpDynamicNetworkDataSource,\n );\n bind(dynamicNetworkTypes.DynamicNetworkContextLoader).to(\n DynamicNetworkContextLoader,\n );\n });\n"],
5
+ "mappings": "AAAA,OAAS,mBAAAA,MAAuB,YAEhC,OAAS,gCAAAC,MAAoC,sDAC7C,OAAS,+BAAAC,MAAmC,uDAE5C,OAAS,uBAAAC,MAA2B,wBAE7B,MAAMC,EAA8B,IACzC,IAAIJ,EAAgB,CAAC,CAAE,KAAAK,CAAK,IAAM,CAChCA,EAAKF,EAAoB,wBAAwB,EAAE,GACjDF,CACF,EACAI,EAAKF,EAAoB,2BAA2B,EAAE,GACpDD,CACF,CACF,CAAC",
6
+ "names": ["ContainerModule", "HttpDynamicNetworkDataSource", "DynamicNetworkContextLoader", "dynamicNetworkTypes", "dynamicNetworkModuleFactory", "bind"]
7
+ }
@@ -0,0 +1,2 @@
1
+ const o={DynamicNetworkDataSource:Symbol("DynamicNetworkDataSource"),DynamicNetworkContextLoader:Symbol("DynamicNetworkContextLoader")};export{o as dynamicNetworkTypes};
2
+ //# sourceMappingURL=dynamicNetworkTypes.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../../../src/dynamic-network/di/dynamicNetworkTypes.ts"],
4
+ "sourcesContent": ["export const dynamicNetworkTypes = {\n DynamicNetworkDataSource: Symbol(\"DynamicNetworkDataSource\"),\n DynamicNetworkContextLoader: Symbol(\"DynamicNetworkContextLoader\"),\n};\n"],
5
+ "mappings": "AAAO,MAAMA,EAAsB,CACjC,yBAA0B,OAAO,0BAA0B,EAC3D,4BAA6B,OAAO,6BAA6B,CACnE",
6
+ "names": ["dynamicNetworkTypes"]
7
+ }
@@ -0,0 +1,2 @@
1
+ var C=Object.defineProperty;var u=Object.getOwnPropertyDescriptor;var l=(n,e,o,t)=>{for(var r=t>1?void 0:t?u(e,o):e,a=n.length-1,i;a>=0;a--)(i=n[a])&&(r=(t?i(e,o,r):i(r))||r);return t&&r&&C(e,o,r),r},c=(n,e)=>(o,t)=>e(o,t,n);import{DeviceModelId as g}from"@ledgerhq/device-management-kit";import{inject as s,injectable as y}from"inversify";import{configTypes as S}from"../../config/di/configTypes";import{dynamicNetworkTypes as _}from"../../dynamic-network/di/dynamicNetworkTypes";import{pkiTypes as k}from"../../pki/di/pkiTypes";import{KeyId as N}from"../../pki/model/KeyId";import{KeyUsage as T}from"../../pki/model/KeyUsage";import{ClearSignContextType as m}from"../../shared/model/ClearSignContext";import{HexStringUtils as D}from"../../shared/utils/HexStringUtils";const x="15";let d=class{_networkDataSource;_config;_certificateLoader;constructor(e,o,t){this._networkDataSource=e,this._config=o,this._certificateLoader=t}async load(e){if(e.deviceModelId===g.NANO_S)return[];const o=await this._networkDataSource.getDynamicNetworkConfiguration(e.chainId),t=await this._certificateLoader.loadCertificate({keyId:N.CalNetwork,keyUsage:T.Network,targetDevice:e.deviceModelId});return o.caseOf({Left:()=>[],Right:r=>{const a=[],i=r.descriptors[e.deviceModelId];if(!i)return[];const f=i.signatures[this._config.cal.mode];if(!f)return[];const p=D.appendSignatureToPayload(i.data,f,x);return a.push({type:m.DYNAMIC_NETWORK,payload:p,certificate:t}),i.icon&&a.push({type:m.DYNAMIC_NETWORK_ICON,payload:i.icon}),a}})}loadField(e){return Promise.resolve(null)}};d=l([y(),c(0,s(_.DynamicNetworkDataSource)),c(1,s(S.Config)),c(2,s(k.PkiCertificateLoader))],d);export{d as DynamicNetworkContextLoader};
2
+ //# sourceMappingURL=DynamicNetworkContextLoader.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../../../src/dynamic-network/domain/DynamicNetworkContextLoader.ts"],
4
+ "sourcesContent": ["import { DeviceModelId } from \"@ledgerhq/device-management-kit\";\nimport { inject, injectable } from \"inversify\";\n\nimport { configTypes } from \"@/config/di/configTypes\";\nimport { type ContextModuleConfig } from \"@/config/model/ContextModuleConfig\";\nimport { type DynamicNetworkDataSource } from \"@/dynamic-network/data/DynamicNetworkDataSource\";\nimport { dynamicNetworkTypes } from \"@/dynamic-network/di/dynamicNetworkTypes\";\nimport { pkiTypes } from \"@/pki/di/pkiTypes\";\nimport { type PkiCertificateLoader } from \"@/pki/domain/PkiCertificateLoader\";\nimport { KeyId } from \"@/pki/model/KeyId\";\nimport { KeyUsage } from \"@/pki/model/KeyUsage\";\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 { HexStringUtils } from \"@/shared/utils/HexStringUtils\";\n\nconst NETWORK_SIGNATURE_TAG = \"15\";\n\n@injectable()\nexport class DynamicNetworkContextLoader implements ContextLoader {\n private readonly _networkDataSource: DynamicNetworkDataSource;\n private readonly _config: ContextModuleConfig;\n private readonly _certificateLoader: PkiCertificateLoader;\n\n constructor(\n @inject(dynamicNetworkTypes.DynamicNetworkDataSource)\n networkDataSource: DynamicNetworkDataSource,\n @inject(configTypes.Config)\n config: ContextModuleConfig,\n @inject(pkiTypes.PkiCertificateLoader)\n certificateLoader: PkiCertificateLoader,\n ) {\n this._networkDataSource = networkDataSource;\n this._config = config;\n this._certificateLoader = certificateLoader;\n }\n\n async load(ctx: TransactionContext): Promise<ClearSignContext[]> {\n if (ctx.deviceModelId === DeviceModelId.NANO_S) return [];\n\n const result = await this._networkDataSource.getDynamicNetworkConfiguration(\n ctx.chainId,\n );\n\n // Fetch certificate for the network configuration upfront\n const certificate = await this._certificateLoader.loadCertificate({\n keyId: KeyId.CalNetwork,\n keyUsage: KeyUsage.Network,\n targetDevice: ctx.deviceModelId,\n });\n\n return result.caseOf({\n Left: () => [],\n Right: (configuration) => {\n const contexts: ClearSignContext[] = [];\n const descriptor = configuration.descriptors[ctx.deviceModelId];\n\n if (!descriptor) {\n return [];\n }\n\n const signature = descriptor.signatures[this._config.cal.mode];\n\n if (!signature) {\n return [];\n }\n\n const configPayload = HexStringUtils.appendSignatureToPayload(\n descriptor.data,\n signature,\n NETWORK_SIGNATURE_TAG,\n );\n\n contexts.push({\n type: ClearSignContextType.DYNAMIC_NETWORK,\n payload: configPayload,\n certificate,\n });\n\n // Add icon if available in the descriptor\n if (descriptor.icon) {\n // Icons don't need signatures appended\n contexts.push({\n type: ClearSignContextType.DYNAMIC_NETWORK_ICON,\n payload: descriptor.icon,\n });\n }\n\n return contexts;\n },\n });\n }\n\n // Dynamic network context doesn't support field-level loading\n loadField(_field: TransactionFieldContext): Promise<ClearSignContext | null> {\n return Promise.resolve(null);\n }\n}\n"],
5
+ "mappings": "iOAAA,OAAS,iBAAAA,MAAqB,kCAC9B,OAAS,UAAAC,EAAQ,cAAAC,MAAkB,YAEnC,OAAS,eAAAC,MAAmB,0BAG5B,OAAS,uBAAAC,MAA2B,2CACpC,OAAS,YAAAC,MAAgB,oBAEzB,OAAS,SAAAC,MAAa,oBACtB,OAAS,YAAAC,MAAgB,uBAEzB,OAEE,wBAAAC,MACK,kCAKP,OAAS,kBAAAC,MAAsB,gCAE/B,MAAMC,EAAwB,KAGvB,IAAMC,EAAN,KAA2D,CAC/C,mBACA,QACA,mBAEjB,YAEEC,EAEAC,EAEAC,EACA,CACA,KAAK,mBAAqBF,EAC1B,KAAK,QAAUC,EACf,KAAK,mBAAqBC,CAC5B,CAEA,MAAM,KAAKC,EAAsD,CAC/D,GAAIA,EAAI,gBAAkBC,EAAc,OAAQ,MAAO,CAAC,EAExD,MAAMC,EAAS,MAAM,KAAK,mBAAmB,+BAC3CF,EAAI,OACN,EAGMG,EAAc,MAAM,KAAK,mBAAmB,gBAAgB,CAChE,MAAOC,EAAM,WACb,SAAUC,EAAS,QACnB,aAAcL,EAAI,aACpB,CAAC,EAED,OAAOE,EAAO,OAAO,CACnB,KAAM,IAAM,CAAC,EACb,MAAQI,GAAkB,CACxB,MAAMC,EAA+B,CAAC,EAChCC,EAAaF,EAAc,YAAYN,EAAI,aAAa,EAE9D,GAAI,CAACQ,EACH,MAAO,CAAC,EAGV,MAAMC,EAAYD,EAAW,WAAW,KAAK,QAAQ,IAAI,IAAI,EAE7D,GAAI,CAACC,EACH,MAAO,CAAC,EAGV,MAAMC,EAAgBC,EAAe,yBACnCH,EAAW,KACXC,EACAd,CACF,EAEA,OAAAY,EAAS,KAAK,CACZ,KAAMK,EAAqB,gBAC3B,QAASF,EACT,YAAAP,CACF,CAAC,EAGGK,EAAW,MAEbD,EAAS,KAAK,CACZ,KAAMK,EAAqB,qBAC3B,QAASJ,EAAW,IACtB,CAAC,EAGID,CACT,CACF,CAAC,CACH,CAGA,UAAUM,EAAmE,CAC3E,OAAO,QAAQ,QAAQ,IAAI,CAC7B,CACF,EA9EajB,EAANkB,EAAA,CADNC,EAAW,EAOPC,EAAA,EAAAC,EAAOC,EAAoB,wBAAwB,GAEnDF,EAAA,EAAAC,EAAOE,EAAY,MAAM,GAEzBH,EAAA,EAAAC,EAAOG,EAAS,oBAAoB,IAV5BxB",
6
+ "names": ["DeviceModelId", "inject", "injectable", "configTypes", "dynamicNetworkTypes", "pkiTypes", "KeyId", "KeyUsage", "ClearSignContextType", "HexStringUtils", "NETWORK_SIGNATURE_TAG", "DynamicNetworkContextLoader", "networkDataSource", "config", "certificateLoader", "ctx", "DeviceModelId", "result", "certificate", "KeyId", "KeyUsage", "configuration", "contexts", "descriptor", "signature", "configPayload", "HexStringUtils", "ClearSignContextType", "_field", "__decorateClass", "injectable", "__decorateParam", "inject", "dynamicNetworkTypes", "configTypes", "pkiTypes"]
7
+ }
@@ -0,0 +1,2 @@
1
+ import{DeviceModelId as e}from"@ledgerhq/device-management-kit";import{Left as m,Right as s}from"purify-ts";import{DynamicNetworkContextLoader as f}from"../../dynamic-network/domain/DynamicNetworkContextLoader";import{KeyId as g}from"../../pki/model/KeyId";import{KeyUsage as x}from"../../pki/model/KeyUsage";import{ClearSignContextType as p}from"../../shared/model/ClearSignContext";describe("DynamicNetworkContextLoader",()=>{const a={getDynamicNetworkConfiguration:vi.fn()},l={cal:{url:"https://crypto-assets-service.api.ledger.com",mode:"prod",branch:"main"},web3checks:{url:"https://web3checks.api.ledger.com"},metadataServiceDomain:{url:"https://metadata.api.ledger.com"},defaultLoaders:!0,customLoaders:[]},d={loadCertificate:vi.fn()},u={keyUsageNumber:1,payload:new Uint8Array([1,2,3])},n=new f(a,l,d),t=o=>({data:"",descriptorType:"",descriptorVersion:"",signatures:{prod:"",test:""},icon:void 0,...o});beforeEach(()=>{vi.restoreAllMocks(),vi.spyOn(d,"loadCertificate").mockResolvedValue(u)}),describe("load function",()=>{it("should return empty array when network data source returns error",async()=>{const o={chainId:1,deviceModelId:e.STAX,to:"0x123",data:"0x456",selector:"0x789"};vi.spyOn(a,"getDynamicNetworkConfiguration").mockResolvedValue(m(new Error("Network error")));const i=await n.load(o);expect(i).toEqual([]),expect(a.getDynamicNetworkConfiguration).toHaveBeenCalledWith(1)}),it("should return empty array when descriptor for device model is not found",async()=>{const o={chainId:1,deviceModelId:e.STAX,to:"0x123",data:"0x456",selector:"0x789"},i={id:"ethereum",descriptors:{[e.NANO_S]:t(),[e.NANO_SP]:t(),[e.NANO_X]:t(),[e.FLEX]:t({data:"0x0101",descriptorType:"network",descriptorVersion:"v1",signatures:{prod:"prod-sig",test:"test-sig"},icon:void 0})}};vi.spyOn(a,"getDynamicNetworkConfiguration").mockResolvedValue(s(i));const r=await n.load(o);expect(r).toEqual([])}),it("should return empty array when signature for mode is not found",async()=>{const o={chainId:1,deviceModelId:e.STAX,to:"0x123",data:"0x456",selector:"0x789"},i={id:"ethereum",descriptors:{[e.APEX]:t(),[e.NANO_S]:t(),[e.NANO_SP]:t(),[e.NANO_X]:t(),[e.FLEX]:t(),[e.STAX]:t({data:"0x0101",descriptorType:"network",descriptorVersion:"v1",signatures:{test:"test-sig"},icon:void 0})}};vi.spyOn(a,"getDynamicNetworkConfiguration").mockResolvedValue(s(i));const r=await n.load(o);expect(r).toEqual([])}),it("should return context with network configuration when all data is available",async()=>{const o={chainId:137,deviceModelId:e.STAX,to:"0x123",data:"0x456",selector:"0x789"},i={id:"polygon",descriptors:{[e.APEX]:t(),[e.NANO_S]:t(),[e.NANO_SP]:t(),[e.NANO_X]:t(),[e.FLEX]:t(),[e.STAX]:{data:"0x0101080201015101012308000000000000008952",descriptorType:"network",descriptorVersion:"v1",signatures:{prod:"3045022100cf42c039c16fc95dc97c09f15cdd93bed0e63ee45cf5c38c2b30bb8a3bc17f8d022053a96c9e51695c3c1c1a31f5cbf84bd6febadc97f4bb02bdc67cf3e24ad0c32d",test:"test-sig"},icon:void 0}}};vi.spyOn(a,"getDynamicNetworkConfiguration").mockResolvedValue(s(i));const r=await n.load(o);expect(r).toHaveLength(1),expect(r[0]).toMatchObject({type:p.DYNAMIC_NETWORK,payload:expect.stringContaining("0x0101080201015101012308000000000000008952"),certificate:u}),expect(d.loadCertificate).toHaveBeenCalledWith({keyId:g.CalNetwork,keyUsage:x.Network,targetDevice:e.STAX})}),it("should include icon context when icon is available",async()=>{const o={chainId:1,deviceModelId:e.STAX,to:"0x123",data:"0x456",selector:"0x789"},i={id:"ethereum",descriptors:{[e.APEX]:t(),[e.NANO_S]:t(),[e.NANO_SP]:t(),[e.NANO_X]:t(),[e.FLEX]:t(),[e.STAX]:{data:"0x0101",descriptorType:"network",descriptorVersion:"v1",signatures:{prod:"prod-sig",test:"test-sig"},icon:"icon-hex-data"}}};vi.spyOn(a,"getDynamicNetworkConfiguration").mockResolvedValue(s(i));const r=await n.load(o);expect(r).toHaveLength(2),expect(r[0]).toMatchObject({type:p.DYNAMIC_NETWORK,payload:expect.any(String),certificate:u}),expect(r[1]).toMatchObject({type:p.DYNAMIC_NETWORK_ICON,payload:"icon-hex-data"})}),it("should handle multiple device models correctly",async()=>{const o={chainId:1,deviceModelId:e.FLEX,to:"0x123",data:"0x456",selector:"0x789"},i={id:"ethereum",descriptors:{[e.APEX]:t(),[e.NANO_S]:t(),[e.NANO_SP]:t(),[e.NANO_X]:t(),[e.FLEX]:{data:"0xFLEX",descriptorType:"network",descriptorVersion:"v1",signatures:{prod:"flex-prod-sig",test:"flex-test-sig"},icon:void 0},[e.STAX]:{data:"0xSTAX",descriptorType:"network",descriptorVersion:"v1",signatures:{prod:"stax-prod-sig",test:"stax-test-sig"},icon:void 0}}};vi.spyOn(a,"getDynamicNetworkConfiguration").mockResolvedValue(s(i));const r=await n.load(o);expect(r).toHaveLength(1);const c=r[0];c&&"payload"in c&&(expect(c.payload).toContain("0xFLEX"),expect(c.payload).toContain("flex-prod-sig"))}),it("should use test mode signature when configured",async()=>{const o=new f(a,{...l,cal:{...l.cal,mode:"test"}},d),i={chainId:1,deviceModelId:e.STAX,to:"0x123",data:"0x456",selector:"0x789"},r={id:"ethereum",descriptors:{[e.APEX]:t(),[e.NANO_S]:t(),[e.NANO_SP]:t(),[e.NANO_X]:t(),[e.FLEX]:t(),[e.STAX]:{data:"0x0101",descriptorType:"network",descriptorVersion:"v1",signatures:{prod:"prod-sig",test:"test-sig"},icon:void 0}}};vi.spyOn(a,"getDynamicNetworkConfiguration").mockResolvedValue(s(r));const c=await o.load(i);expect(c).toHaveLength(1);const y=c[0];y&&"payload"in y&&expect(y.payload).toContain("test-sig")})}),describe("loadField function",()=>{it("should always return null",async()=>{const o={type:p.TOKEN,chainId:1,address:"0x123"},i=await n.loadField(o);expect(i).toBeNull()})})});
2
+ //# sourceMappingURL=DynamicNetworkContextLoader.test.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../../../src/dynamic-network/domain/DynamicNetworkContextLoader.test.ts"],
4
+ "sourcesContent": ["import { DeviceModelId } from \"@ledgerhq/device-management-kit\";\nimport { Left, Right } from \"purify-ts\";\n\nimport { type ContextModuleConfig } from \"@/config/model/ContextModuleConfig\";\nimport { type DynamicNetworkDataSource } from \"@/dynamic-network/data/DynamicNetworkDataSource\";\nimport { DynamicNetworkContextLoader } from \"@/dynamic-network/domain/DynamicNetworkContextLoader\";\nimport {\n type DynamicNetworkConfiguration,\n type DynamicNetworkDescriptor,\n} from \"@/dynamic-network/model/DynamicNetworkConfiguration\";\nimport { type PkiCertificateLoader } from \"@/pki/domain/PkiCertificateLoader\";\nimport { KeyId } from \"@/pki/model/KeyId\";\nimport { KeyUsage } from \"@/pki/model/KeyUsage\";\nimport { type PkiCertificate } from \"@/pki/model/PkiCertificate\";\nimport { ClearSignContextType } from \"@/shared/model/ClearSignContext\";\nimport {\n type TransactionContext,\n type TransactionFieldContext,\n} from \"@/shared/model/TransactionContext\";\n\ndescribe(\"DynamicNetworkContextLoader\", () => {\n const mockNetworkDataSource: DynamicNetworkDataSource = {\n getDynamicNetworkConfiguration: vi.fn(),\n };\n\n const mockConfig: ContextModuleConfig = {\n cal: {\n url: \"https://crypto-assets-service.api.ledger.com\",\n mode: \"prod\",\n branch: \"main\",\n },\n web3checks: {\n url: \"https://web3checks.api.ledger.com\",\n },\n metadataServiceDomain: {\n url: \"https://metadata.api.ledger.com\",\n },\n defaultLoaders: true,\n customLoaders: [],\n };\n\n const mockCertificateLoader: PkiCertificateLoader = {\n loadCertificate: vi.fn(),\n };\n\n const mockCertificate: PkiCertificate = {\n keyUsageNumber: 1,\n payload: new Uint8Array([0x01, 0x02, 0x03]),\n };\n\n const loader = new DynamicNetworkContextLoader(\n mockNetworkDataSource,\n mockConfig,\n mockCertificateLoader,\n );\n\n // Helper function to create a mock NetworkDescriptor\n const createMockDescriptor = (\n partial?: Partial<DynamicNetworkDescriptor>,\n ): DynamicNetworkDescriptor => ({\n data: \"\",\n descriptorType: \"\",\n descriptorVersion: \"\",\n signatures: {\n prod: \"\",\n test: \"\",\n },\n icon: undefined,\n ...partial,\n });\n\n beforeEach(() => {\n vi.restoreAllMocks();\n vi.spyOn(mockCertificateLoader, \"loadCertificate\").mockResolvedValue(\n mockCertificate,\n );\n });\n\n describe(\"load function\", () => {\n it(\"should return empty array when network data source returns error\", async () => {\n // GIVEN\n const transaction: TransactionContext = {\n chainId: 1,\n deviceModelId: DeviceModelId.STAX,\n to: \"0x123\",\n data: \"0x456\",\n selector: \"0x789\",\n };\n vi.spyOn(\n mockNetworkDataSource,\n \"getDynamicNetworkConfiguration\",\n ).mockResolvedValue(Left(new Error(\"Network error\")));\n\n // WHEN\n const result = await loader.load(transaction);\n\n // THEN\n expect(result).toEqual([]);\n expect(\n mockNetworkDataSource.getDynamicNetworkConfiguration,\n ).toHaveBeenCalledWith(1);\n });\n\n it(\"should return empty array when descriptor for device model is not found\", async () => {\n // GIVEN\n const transaction: TransactionContext = {\n chainId: 1,\n deviceModelId: DeviceModelId.STAX,\n to: \"0x123\",\n data: \"0x456\",\n selector: \"0x789\",\n };\n const networkConfig: DynamicNetworkConfiguration = {\n id: \"ethereum\",\n descriptors: {\n [DeviceModelId.NANO_S]: createMockDescriptor(),\n [DeviceModelId.NANO_SP]: createMockDescriptor(),\n [DeviceModelId.NANO_X]: createMockDescriptor(),\n // STAX descriptor is intentionally missing\n [DeviceModelId.FLEX]: createMockDescriptor({\n data: \"0x0101\",\n descriptorType: \"network\",\n descriptorVersion: \"v1\",\n signatures: {\n prod: \"prod-sig\",\n test: \"test-sig\",\n },\n icon: undefined,\n }),\n } as Record<DeviceModelId, DynamicNetworkDescriptor>,\n };\n vi.spyOn(\n mockNetworkDataSource,\n \"getDynamicNetworkConfiguration\",\n ).mockResolvedValue(Right(networkConfig));\n\n // WHEN\n const result = await loader.load(transaction);\n\n // THEN\n expect(result).toEqual([]);\n });\n\n it(\"should return empty array when signature for mode is not found\", async () => {\n // GIVEN\n const transaction: TransactionContext = {\n chainId: 1,\n deviceModelId: DeviceModelId.STAX,\n to: \"0x123\",\n data: \"0x456\",\n selector: \"0x789\",\n };\n const networkConfig: DynamicNetworkConfiguration = {\n id: \"ethereum\",\n descriptors: {\n [DeviceModelId.APEX]: createMockDescriptor(),\n [DeviceModelId.NANO_S]: createMockDescriptor(),\n [DeviceModelId.NANO_SP]: createMockDescriptor(),\n [DeviceModelId.NANO_X]: createMockDescriptor(),\n [DeviceModelId.FLEX]: createMockDescriptor(),\n [DeviceModelId.STAX]: createMockDescriptor({\n data: \"0x0101\",\n descriptorType: \"network\",\n descriptorVersion: \"v1\",\n signatures: {\n test: \"test-sig\",\n // Missing prod signature - intentionally partial\n } as { prod: string; test: string },\n icon: undefined,\n }),\n },\n };\n vi.spyOn(\n mockNetworkDataSource,\n \"getDynamicNetworkConfiguration\",\n ).mockResolvedValue(Right(networkConfig));\n\n // WHEN\n const result = await loader.load(transaction);\n\n // THEN\n expect(result).toEqual([]);\n });\n\n it(\"should return context with network configuration when all data is available\", async () => {\n // GIVEN\n const transaction: TransactionContext = {\n chainId: 137,\n deviceModelId: DeviceModelId.STAX,\n to: \"0x123\",\n data: \"0x456\",\n selector: \"0x789\",\n };\n const networkConfig: DynamicNetworkConfiguration = {\n id: \"polygon\",\n descriptors: {\n [DeviceModelId.APEX]: createMockDescriptor(),\n [DeviceModelId.NANO_S]: createMockDescriptor(),\n [DeviceModelId.NANO_SP]: createMockDescriptor(),\n [DeviceModelId.NANO_X]: createMockDescriptor(),\n [DeviceModelId.FLEX]: createMockDescriptor(),\n [DeviceModelId.STAX]: {\n data: \"0x0101080201015101012308000000000000008952\",\n descriptorType: \"network\",\n descriptorVersion: \"v1\",\n signatures: {\n prod: \"3045022100cf42c039c16fc95dc97c09f15cdd93bed0e63ee45cf5c38c2b30bb8a3bc17f8d022053a96c9e51695c3c1c1a31f5cbf84bd6febadc97f4bb02bdc67cf3e24ad0c32d\",\n test: \"test-sig\",\n },\n icon: undefined,\n },\n },\n };\n vi.spyOn(\n mockNetworkDataSource,\n \"getDynamicNetworkConfiguration\",\n ).mockResolvedValue(Right(networkConfig));\n\n // WHEN\n const result = await loader.load(transaction);\n\n // THEN\n expect(result).toHaveLength(1);\n expect(result[0]).toMatchObject({\n type: ClearSignContextType.DYNAMIC_NETWORK,\n payload: expect.stringContaining(\n \"0x0101080201015101012308000000000000008952\",\n ),\n certificate: mockCertificate,\n });\n expect(mockCertificateLoader.loadCertificate).toHaveBeenCalledWith({\n keyId: KeyId.CalNetwork,\n keyUsage: KeyUsage.Network,\n targetDevice: DeviceModelId.STAX,\n });\n });\n\n it(\"should include icon context when icon is available\", async () => {\n // GIVEN\n const transaction: TransactionContext = {\n chainId: 1,\n deviceModelId: DeviceModelId.STAX,\n to: \"0x123\",\n data: \"0x456\",\n selector: \"0x789\",\n };\n const networkConfig: DynamicNetworkConfiguration = {\n id: \"ethereum\",\n descriptors: {\n [DeviceModelId.APEX]: createMockDescriptor(),\n [DeviceModelId.NANO_S]: createMockDescriptor(),\n [DeviceModelId.NANO_SP]: createMockDescriptor(),\n [DeviceModelId.NANO_X]: createMockDescriptor(),\n [DeviceModelId.FLEX]: createMockDescriptor(),\n [DeviceModelId.STAX]: {\n data: \"0x0101\",\n descriptorType: \"network\",\n descriptorVersion: \"v1\",\n signatures: {\n prod: \"prod-sig\",\n test: \"test-sig\",\n },\n icon: \"icon-hex-data\",\n },\n },\n };\n vi.spyOn(\n mockNetworkDataSource,\n \"getDynamicNetworkConfiguration\",\n ).mockResolvedValue(Right(networkConfig));\n\n // WHEN\n const result = await loader.load(transaction);\n\n // THEN\n expect(result).toHaveLength(2);\n expect(result[0]).toMatchObject({\n type: ClearSignContextType.DYNAMIC_NETWORK,\n payload: expect.any(String),\n certificate: mockCertificate,\n });\n expect(result[1]).toMatchObject({\n type: ClearSignContextType.DYNAMIC_NETWORK_ICON,\n payload: \"icon-hex-data\",\n });\n });\n\n it(\"should handle multiple device models correctly\", async () => {\n // GIVEN\n const transaction: TransactionContext = {\n chainId: 1,\n deviceModelId: DeviceModelId.FLEX,\n to: \"0x123\",\n data: \"0x456\",\n selector: \"0x789\",\n };\n const networkConfig: DynamicNetworkConfiguration = {\n id: \"ethereum\",\n descriptors: {\n [DeviceModelId.APEX]: createMockDescriptor(),\n [DeviceModelId.NANO_S]: createMockDescriptor(),\n [DeviceModelId.NANO_SP]: createMockDescriptor(),\n [DeviceModelId.NANO_X]: createMockDescriptor(),\n [DeviceModelId.FLEX]: {\n data: \"0xFLEX\",\n descriptorType: \"network\",\n descriptorVersion: \"v1\",\n signatures: {\n prod: \"flex-prod-sig\",\n test: \"flex-test-sig\",\n },\n icon: undefined,\n },\n [DeviceModelId.STAX]: {\n data: \"0xSTAX\",\n descriptorType: \"network\",\n descriptorVersion: \"v1\",\n signatures: {\n prod: \"stax-prod-sig\",\n test: \"stax-test-sig\",\n },\n icon: undefined,\n },\n },\n };\n vi.spyOn(\n mockNetworkDataSource,\n \"getDynamicNetworkConfiguration\",\n ).mockResolvedValue(Right(networkConfig));\n\n // WHEN\n const result = await loader.load(transaction);\n\n // THEN\n expect(result).toHaveLength(1);\n const context = result[0];\n if (context && \"payload\" in context) {\n expect(context.payload).toContain(\"0xFLEX\");\n expect(context.payload).toContain(\"flex-prod-sig\");\n }\n });\n\n it(\"should use test mode signature when configured\", async () => {\n // GIVEN\n const testModeLoader = new DynamicNetworkContextLoader(\n mockNetworkDataSource,\n { ...mockConfig, cal: { ...mockConfig.cal, mode: \"test\" } },\n mockCertificateLoader,\n );\n const transaction: TransactionContext = {\n chainId: 1,\n deviceModelId: DeviceModelId.STAX,\n to: \"0x123\",\n data: \"0x456\",\n selector: \"0x789\",\n };\n const networkConfig: DynamicNetworkConfiguration = {\n id: \"ethereum\",\n descriptors: {\n [DeviceModelId.APEX]: createMockDescriptor(),\n [DeviceModelId.NANO_S]: createMockDescriptor(),\n [DeviceModelId.NANO_SP]: createMockDescriptor(),\n [DeviceModelId.NANO_X]: createMockDescriptor(),\n [DeviceModelId.FLEX]: createMockDescriptor(),\n [DeviceModelId.STAX]: {\n data: \"0x0101\",\n descriptorType: \"network\",\n descriptorVersion: \"v1\",\n signatures: {\n prod: \"prod-sig\",\n test: \"test-sig\",\n },\n icon: undefined,\n },\n },\n };\n vi.spyOn(\n mockNetworkDataSource,\n \"getDynamicNetworkConfiguration\",\n ).mockResolvedValue(Right(networkConfig));\n\n // WHEN\n const result = await testModeLoader.load(transaction);\n\n // THEN\n expect(result).toHaveLength(1);\n const context = result[0];\n if (context && \"payload\" in context) {\n expect(context.payload).toContain(\"test-sig\");\n }\n });\n });\n\n describe(\"loadField function\", () => {\n it(\"should always return null\", async () => {\n // GIVEN\n const field: TransactionFieldContext = {\n type: ClearSignContextType.TOKEN,\n chainId: 1,\n address: \"0x123\",\n };\n\n // WHEN\n const result = await loader.loadField(field);\n\n // THEN\n expect(result).toBeNull();\n });\n });\n});\n"],
5
+ "mappings": "AAAA,OAAS,iBAAAA,MAAqB,kCAC9B,OAAS,QAAAC,EAAM,SAAAC,MAAa,YAI5B,OAAS,+BAAAC,MAAmC,uDAM5C,OAAS,SAAAC,MAAa,oBACtB,OAAS,YAAAC,MAAgB,uBAEzB,OAAS,wBAAAC,MAA4B,kCAMrC,SAAS,8BAA+B,IAAM,CAC5C,MAAMC,EAAkD,CACtD,+BAAgC,GAAG,GAAG,CACxC,EAEMC,EAAkC,CACtC,IAAK,CACH,IAAK,+CACL,KAAM,OACN,OAAQ,MACV,EACA,WAAY,CACV,IAAK,mCACP,EACA,sBAAuB,CACrB,IAAK,iCACP,EACA,eAAgB,GAChB,cAAe,CAAC,CAClB,EAEMC,EAA8C,CAClD,gBAAiB,GAAG,GAAG,CACzB,EAEMC,EAAkC,CACtC,eAAgB,EAChB,QAAS,IAAI,WAAW,CAAC,EAAM,EAAM,CAAI,CAAC,CAC5C,EAEMC,EAAS,IAAIR,EACjBI,EACAC,EACAC,CACF,EAGMG,EACJC,IAC8B,CAC9B,KAAM,GACN,eAAgB,GAChB,kBAAmB,GACnB,WAAY,CACV,KAAM,GACN,KAAM,EACR,EACA,KAAM,OACN,GAAGA,CACL,GAEA,WAAW,IAAM,CACf,GAAG,gBAAgB,EACnB,GAAG,MAAMJ,EAAuB,iBAAiB,EAAE,kBACjDC,C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AE,kBAAkBL,EAAMc,CAAa,CAAC,EAGxC,MAAMD,EAAS,MAAMG,EAAe,KAAKJ,CAAW,EAGpD,OAAOC,CAAM,EAAE,aAAa,CAAC,EAC7B,MAAME,EAAUF,EAAO,CAAC,EACpBE,GAAW,YAAaA,GAC1B,OAAOA,EAAQ,OAAO,EAAE,UAAU,UAAU,CAEhD,CAAC,CACH,CAAC,EAED,SAAS,qBAAsB,IAAM,CACnC,GAAG,4BAA6B,SAAY,CAE1C,MAAME,EAAiC,CACrC,KAAMb,EAAqB,MAC3B,QAAS,EACT,QAAS,OACX,EAGMS,EAAS,MAAMJ,EAAO,UAAUQ,CAAK,EAG3C,OAAOJ,CAAM,EAAE,SAAS,CAC1B,CAAC,CACH,CAAC,CACH,CAAC",
6
+ "names": ["DeviceModelId", "Left", "Right", "DynamicNetworkContextLoader", "KeyId", "KeyUsage", "ClearSignContextType", "mockNetworkDataSource", "mockConfig", "mockCertificateLoader", "mockCertificate", "loader", "createMockDescriptor", "partial", "transaction", "result", "networkConfig", "context", "testModeLoader", "field"]
7
+ }
@@ -0,0 +1 @@
1
+ //# sourceMappingURL=DynamicNetworkConfiguration.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": [],
4
+ "sourcesContent": [],
5
+ "mappings": "",
6
+ "names": []
7
+ }