@ledgerhq/context-module 1.15.0 → 1.17.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 (410) hide show
  1. package/README.md +10 -0
  2. package/lib/cjs/package.json +1 -2
  3. package/lib/cjs/src/ContextModule.js +1 -1
  4. package/lib/cjs/src/ContextModule.js.map +1 -1
  5. package/lib/cjs/src/ContextModuleBuilder.js +1 -1
  6. package/lib/cjs/src/ContextModuleBuilder.js.map +3 -3
  7. package/lib/cjs/src/ContextModuleBuilder.test.js +1 -1
  8. package/lib/cjs/src/ContextModuleBuilder.test.js.map +3 -3
  9. package/lib/cjs/src/DefaultContextModule.js +1 -1
  10. package/lib/cjs/src/DefaultContextModule.js.map +3 -3
  11. package/lib/cjs/src/DefaultContextModule.test.js +1 -1
  12. package/lib/cjs/src/DefaultContextModule.test.js.map +2 -2
  13. package/lib/cjs/src/account-ownership/data/AccountOwnershipDataSource.js +2 -0
  14. package/lib/cjs/src/account-ownership/data/AccountOwnershipDataSource.js.map +7 -0
  15. package/lib/cjs/src/account-ownership/data/AccountOwnershipError.js +2 -0
  16. package/lib/cjs/src/account-ownership/data/AccountOwnershipError.js.map +7 -0
  17. package/lib/cjs/src/account-ownership/data/HttpAccountOwnershipDataSource.js +2 -0
  18. package/lib/cjs/src/account-ownership/data/HttpAccountOwnershipDataSource.js.map +7 -0
  19. package/lib/cjs/src/account-ownership/data/HttpAccountOwnershipDataSource.test.js +2 -0
  20. package/lib/cjs/src/account-ownership/data/HttpAccountOwnershipDataSource.test.js.map +7 -0
  21. package/lib/cjs/src/account-ownership/data/dto/AccountOwnershipDto.js +2 -0
  22. package/lib/cjs/src/account-ownership/data/dto/AccountOwnershipDto.js.map +7 -0
  23. package/lib/cjs/src/account-ownership/di/accountOwnershipModuleFactory.js +2 -0
  24. package/lib/cjs/src/account-ownership/di/accountOwnershipModuleFactory.js.map +7 -0
  25. package/lib/cjs/src/account-ownership/di/accountOwnershipTypes.js +2 -0
  26. package/lib/cjs/src/account-ownership/di/accountOwnershipTypes.js.map +7 -0
  27. package/lib/cjs/src/account-ownership/domain/AccountOwnershipContextLoader.js +2 -0
  28. package/lib/cjs/src/account-ownership/domain/AccountOwnershipContextLoader.js.map +7 -0
  29. package/lib/cjs/src/account-ownership/domain/AccountOwnershipContextLoader.test.js +2 -0
  30. package/lib/cjs/src/account-ownership/domain/AccountOwnershipContextLoader.test.js.map +7 -0
  31. package/lib/cjs/src/calldata/data/HttpCalldataDescriptorDataSource.js +1 -1
  32. package/lib/cjs/src/calldata/data/HttpCalldataDescriptorDataSource.js.map +3 -3
  33. package/lib/cjs/src/calldata/data/HttpCalldataDescriptorDataSource.test.js +1 -1
  34. package/lib/cjs/src/calldata/data/HttpCalldataDescriptorDataSource.test.js.map +3 -3
  35. package/lib/cjs/src/calldata/di/calldataModuleFactory.js +1 -1
  36. package/lib/cjs/src/calldata/di/calldataModuleFactory.js.map +3 -3
  37. package/lib/cjs/src/config/di/configModuleFactory.js +1 -1
  38. package/lib/cjs/src/config/di/configModuleFactory.js.map +2 -2
  39. package/lib/cjs/src/config/model/ContextModuleConfig.js +1 -1
  40. package/lib/cjs/src/config/model/ContextModuleConfig.js.map +1 -1
  41. package/lib/cjs/src/di.js +1 -1
  42. package/lib/cjs/src/di.js.map +3 -3
  43. package/lib/cjs/src/dynamic-network/data/HttpDynamicNetworkDataSource.js +1 -1
  44. package/lib/cjs/src/dynamic-network/data/HttpDynamicNetworkDataSource.js.map +3 -3
  45. package/lib/cjs/src/dynamic-network/data/HttpDynamicNetworkDataSource.test.js +1 -1
  46. package/lib/cjs/src/dynamic-network/data/HttpDynamicNetworkDataSource.test.js.map +3 -3
  47. package/lib/cjs/src/dynamic-network/domain/DynamicNetworkContextLoader.js +1 -1
  48. package/lib/cjs/src/dynamic-network/domain/DynamicNetworkContextLoader.js.map +1 -1
  49. package/lib/cjs/src/dynamic-network/domain/DynamicNetworkContextLoader.test.js.map +1 -1
  50. package/lib/cjs/src/external-plugin/data/HttpExternalPluginDataSource.js +1 -1
  51. package/lib/cjs/src/external-plugin/data/HttpExternalPluginDataSource.js.map +3 -3
  52. package/lib/cjs/src/external-plugin/data/HttpExternalPluginDataSource.test.js +1 -1
  53. package/lib/cjs/src/external-plugin/data/HttpExternalPluginDataSource.test.js.map +3 -3
  54. package/lib/cjs/src/gated-signing/data/HttpGatedDescriptorDataSource.js +1 -1
  55. package/lib/cjs/src/gated-signing/data/HttpGatedDescriptorDataSource.js.map +3 -3
  56. package/lib/cjs/src/gated-signing/data/HttpGatedDescriptorDataSource.test.js +1 -1
  57. package/lib/cjs/src/gated-signing/data/HttpGatedDescriptorDataSource.test.js.map +3 -3
  58. package/lib/cjs/src/index.js +1 -1
  59. package/lib/cjs/src/index.js.map +2 -2
  60. package/lib/cjs/src/network/di/networkModuleFactory.js +2 -0
  61. package/lib/cjs/src/network/di/networkModuleFactory.js.map +7 -0
  62. package/lib/cjs/src/network/di/networkTypes.js +2 -0
  63. package/lib/cjs/src/network/di/networkTypes.js.map +7 -0
  64. package/lib/cjs/src/nft/data/HttpNftDataSource.js +1 -1
  65. package/lib/cjs/src/nft/data/HttpNftDataSource.js.map +3 -3
  66. package/lib/cjs/src/nft/data/HttpNftDataSource.test.js +1 -1
  67. package/lib/cjs/src/nft/data/HttpNftDataSource.test.js.map +3 -3
  68. package/lib/cjs/src/pki/data/HttpPkiCertificateDataSource.js +1 -1
  69. package/lib/cjs/src/pki/data/HttpPkiCertificateDataSource.js.map +3 -3
  70. package/lib/cjs/src/pki/data/HttpPkiCertificateDataSource.test.js +1 -1
  71. package/lib/cjs/src/pki/data/HttpPkiCertificateDataSource.test.js.map +3 -3
  72. package/lib/cjs/src/proxy/data/HttpProxyDataSource.js +1 -1
  73. package/lib/cjs/src/proxy/data/HttpProxyDataSource.js.map +3 -3
  74. package/lib/cjs/src/proxy/data/HttpProxyDataSource.test.js +1 -1
  75. package/lib/cjs/src/proxy/data/HttpProxyDataSource.test.js.map +3 -3
  76. package/lib/cjs/src/proxy/data/HttpSafeProxyDataSource.js +1 -1
  77. package/lib/cjs/src/proxy/data/HttpSafeProxyDataSource.js.map +3 -3
  78. package/lib/cjs/src/proxy/data/HttpSafeProxyDataSource.test.js +1 -1
  79. package/lib/cjs/src/proxy/data/HttpSafeProxyDataSource.test.js.map +3 -3
  80. package/lib/cjs/src/proxy/di/proxyModuleFactory.js +1 -1
  81. package/lib/cjs/src/proxy/di/proxyModuleFactory.js.map +3 -3
  82. package/lib/cjs/src/proxy/di/proxyModuleFactory.test.js +1 -1
  83. package/lib/cjs/src/proxy/di/proxyModuleFactory.test.js.map +3 -3
  84. package/lib/cjs/src/reporter/data/BlindSigningReporterDatasource.js +2 -0
  85. package/lib/cjs/src/reporter/data/BlindSigningReporterDatasource.js.map +7 -0
  86. package/lib/cjs/src/reporter/data/HttpBlindSigningReporterDatasource.js +2 -0
  87. package/lib/cjs/src/reporter/data/HttpBlindSigningReporterDatasource.js.map +7 -0
  88. package/lib/cjs/src/reporter/data/HttpBlindSigningReporterDatasource.test.js +2 -0
  89. package/lib/cjs/src/reporter/data/HttpBlindSigningReporterDatasource.test.js.map +7 -0
  90. package/lib/cjs/src/reporter/data/dto/BlindSigningEventDto.js +2 -0
  91. package/lib/cjs/src/reporter/data/dto/BlindSigningEventDto.js.map +7 -0
  92. package/lib/cjs/src/reporter/di/reporterModuleFactory.js +2 -0
  93. package/lib/cjs/src/reporter/di/reporterModuleFactory.js.map +7 -0
  94. package/lib/cjs/src/reporter/di/reporterTypes.js +2 -0
  95. package/lib/cjs/src/reporter/di/reporterTypes.js.map +7 -0
  96. package/lib/cjs/src/reporter/domain/BlindSigningReporter.js +2 -0
  97. package/lib/cjs/src/reporter/domain/BlindSigningReporter.js.map +7 -0
  98. package/lib/cjs/src/reporter/domain/DefaultBlindSigningReporter.js +2 -0
  99. package/lib/cjs/src/reporter/domain/DefaultBlindSigningReporter.js.map +7 -0
  100. package/lib/cjs/src/reporter/domain/DefaultBlindSigningReporter.test.js +2 -0
  101. package/lib/cjs/src/reporter/domain/DefaultBlindSigningReporter.test.js.map +7 -0
  102. package/lib/cjs/src/reporter/model/BlindSigningEvent.js +2 -0
  103. package/lib/cjs/src/reporter/model/BlindSigningEvent.js.map +7 -0
  104. package/lib/cjs/src/reporter/model/BlindSigningModelId.js +2 -0
  105. package/lib/cjs/src/reporter/model/BlindSigningModelId.js.map +7 -0
  106. package/lib/cjs/src/safe/data/HttpSafeAccountDataSource.js +1 -1
  107. package/lib/cjs/src/safe/data/HttpSafeAccountDataSource.js.map +3 -3
  108. package/lib/cjs/src/safe/data/HttpSafeAccountDataSource.test.js +1 -1
  109. package/lib/cjs/src/safe/data/HttpSafeAccountDataSource.test.js.map +3 -3
  110. package/lib/cjs/src/shared/model/ClearSignContext.js +1 -1
  111. package/lib/cjs/src/shared/model/ClearSignContext.js.map +2 -2
  112. package/lib/cjs/src/solana/data/HttpSolanaOwnerInfoDataSource.js +1 -1
  113. package/lib/cjs/src/solana/data/HttpSolanaOwnerInfoDataSource.js.map +3 -3
  114. package/lib/cjs/src/solana/data/HttpSolanaOwnerInfoDataSource.test.js +1 -1
  115. package/lib/cjs/src/solana/data/HttpSolanaOwnerInfoDataSource.test.js.map +3 -3
  116. package/lib/cjs/src/solana/domain/DefaultSolanaContextLoader.test.js +1 -1
  117. package/lib/cjs/src/solana/domain/DefaultSolanaContextLoader.test.js.map +1 -1
  118. package/lib/cjs/src/solanaLifi/data/HttpSolanaLifiDataSource.js +1 -1
  119. package/lib/cjs/src/solanaLifi/data/HttpSolanaLifiDataSource.js.map +3 -3
  120. package/lib/cjs/src/solanaLifi/data/HttpSolanaLifiDataSource.test.js +1 -1
  121. package/lib/cjs/src/solanaLifi/data/HttpSolanaLifiDataSource.test.js.map +3 -3
  122. package/lib/cjs/src/solanaLifi/domain/SolanaLifiContextLoader.js.map +1 -1
  123. package/lib/cjs/src/solanaLifi/domain/SolanaLifiContextLoader.test.js.map +1 -1
  124. package/lib/cjs/src/solanaToken/data/HttpSolanaTokenDataSource.js +1 -1
  125. package/lib/cjs/src/solanaToken/data/HttpSolanaTokenDataSource.js.map +3 -3
  126. package/lib/cjs/src/solanaToken/data/HttpSolanaTokenDataSource.test.js +6 -6
  127. package/lib/cjs/src/solanaToken/data/HttpSolanaTokenDataSource.test.js.map +3 -3
  128. package/lib/cjs/src/solanaToken/domain/SolanaTokenContextLoader.js +1 -1
  129. package/lib/cjs/src/solanaToken/domain/SolanaTokenContextLoader.js.map +2 -2
  130. package/lib/cjs/src/solanaToken/domain/SolanaTokenContextLoader.test.js +1 -1
  131. package/lib/cjs/src/solanaToken/domain/SolanaTokenContextLoader.test.js.map +1 -1
  132. package/lib/cjs/src/token/data/HttpTokenDataSource.js +1 -1
  133. package/lib/cjs/src/token/data/HttpTokenDataSource.js.map +3 -3
  134. package/lib/cjs/src/token/data/HttpTokenDataSource.test.js +1 -1
  135. package/lib/cjs/src/token/data/HttpTokenDataSource.test.js.map +3 -3
  136. package/lib/cjs/src/transaction-check/data/HttpTransactionCheckDataSource.js +1 -1
  137. package/lib/cjs/src/transaction-check/data/HttpTransactionCheckDataSource.js.map +3 -3
  138. package/lib/cjs/src/transaction-check/data/HttpTransactionCheckDataSource.test.js +1 -1
  139. package/lib/cjs/src/transaction-check/data/HttpTransactionCheckDataSource.test.js.map +3 -3
  140. package/lib/cjs/src/transaction-check/data/HttpTypedDataCheckDataSource.js +1 -1
  141. package/lib/cjs/src/transaction-check/data/HttpTypedDataCheckDataSource.js.map +3 -3
  142. package/lib/cjs/src/transaction-check/data/HttpTypedDataCheckDataSource.test.js +1 -1
  143. package/lib/cjs/src/transaction-check/data/HttpTypedDataCheckDataSource.test.js.map +3 -3
  144. package/lib/cjs/src/trusted-name/data/HttpTrustedNameDataSource.js +1 -1
  145. package/lib/cjs/src/trusted-name/data/HttpTrustedNameDataSource.js.map +3 -3
  146. package/lib/cjs/src/trusted-name/data/HttpTrustedNameDataSource.test.js +1 -1
  147. package/lib/cjs/src/trusted-name/data/HttpTrustedNameDataSource.test.js.map +3 -3
  148. package/lib/cjs/src/trusted-name/di/trustedNameModuleFactory.js +1 -1
  149. package/lib/cjs/src/trusted-name/di/trustedNameModuleFactory.js.map +3 -3
  150. package/lib/cjs/src/typed-data/data/HttpTypedDataDataSource.js +1 -1
  151. package/lib/cjs/src/typed-data/data/HttpTypedDataDataSource.js.map +3 -3
  152. package/lib/cjs/src/typed-data/data/HttpTypedDataDataSource.test.js +1 -1
  153. package/lib/cjs/src/typed-data/data/HttpTypedDataDataSource.test.js.map +3 -3
  154. package/lib/esm/package.json +1 -2
  155. package/lib/esm/src/ContextModuleBuilder.js +1 -1
  156. package/lib/esm/src/ContextModuleBuilder.js.map +3 -3
  157. package/lib/esm/src/ContextModuleBuilder.test.js +1 -1
  158. package/lib/esm/src/ContextModuleBuilder.test.js.map +3 -3
  159. package/lib/esm/src/DefaultContextModule.js +1 -1
  160. package/lib/esm/src/DefaultContextModule.js.map +3 -3
  161. package/lib/esm/src/DefaultContextModule.test.js +1 -1
  162. package/lib/esm/src/DefaultContextModule.test.js.map +2 -2
  163. package/lib/esm/src/account-ownership/data/AccountOwnershipDataSource.js +1 -0
  164. package/lib/esm/src/account-ownership/data/AccountOwnershipDataSource.js.map +7 -0
  165. package/lib/esm/src/account-ownership/data/AccountOwnershipError.js +2 -0
  166. package/lib/esm/src/account-ownership/data/AccountOwnershipError.js.map +7 -0
  167. package/lib/esm/src/account-ownership/data/HttpAccountOwnershipDataSource.js +2 -0
  168. package/lib/esm/src/account-ownership/data/HttpAccountOwnershipDataSource.js.map +7 -0
  169. package/lib/esm/src/account-ownership/data/HttpAccountOwnershipDataSource.test.js +2 -0
  170. package/lib/esm/src/account-ownership/data/HttpAccountOwnershipDataSource.test.js.map +7 -0
  171. package/lib/esm/src/account-ownership/data/dto/AccountOwnershipDto.js +1 -0
  172. package/lib/esm/src/account-ownership/data/dto/AccountOwnershipDto.js.map +7 -0
  173. package/lib/esm/src/account-ownership/di/accountOwnershipModuleFactory.js +2 -0
  174. package/lib/esm/src/account-ownership/di/accountOwnershipModuleFactory.js.map +7 -0
  175. package/lib/esm/src/account-ownership/di/accountOwnershipTypes.js +2 -0
  176. package/lib/esm/src/account-ownership/di/accountOwnershipTypes.js.map +7 -0
  177. package/lib/esm/src/account-ownership/domain/AccountOwnershipContextLoader.js +2 -0
  178. package/lib/esm/src/account-ownership/domain/AccountOwnershipContextLoader.js.map +7 -0
  179. package/lib/esm/src/account-ownership/domain/AccountOwnershipContextLoader.test.js +2 -0
  180. package/lib/esm/src/account-ownership/domain/AccountOwnershipContextLoader.test.js.map +7 -0
  181. package/lib/esm/src/calldata/data/HttpCalldataDescriptorDataSource.js +1 -1
  182. package/lib/esm/src/calldata/data/HttpCalldataDescriptorDataSource.js.map +3 -3
  183. package/lib/esm/src/calldata/data/HttpCalldataDescriptorDataSource.test.js +1 -1
  184. package/lib/esm/src/calldata/data/HttpCalldataDescriptorDataSource.test.js.map +3 -3
  185. package/lib/esm/src/calldata/di/calldataModuleFactory.js +1 -1
  186. package/lib/esm/src/calldata/di/calldataModuleFactory.js.map +3 -3
  187. package/lib/esm/src/config/di/configModuleFactory.js +1 -1
  188. package/lib/esm/src/config/di/configModuleFactory.js.map +2 -2
  189. package/lib/esm/src/di.js +1 -1
  190. package/lib/esm/src/di.js.map +3 -3
  191. package/lib/esm/src/dynamic-network/data/HttpDynamicNetworkDataSource.js +1 -1
  192. package/lib/esm/src/dynamic-network/data/HttpDynamicNetworkDataSource.js.map +3 -3
  193. package/lib/esm/src/dynamic-network/data/HttpDynamicNetworkDataSource.test.js +1 -1
  194. package/lib/esm/src/dynamic-network/data/HttpDynamicNetworkDataSource.test.js.map +3 -3
  195. package/lib/esm/src/dynamic-network/domain/DynamicNetworkContextLoader.js +1 -1
  196. package/lib/esm/src/dynamic-network/domain/DynamicNetworkContextLoader.js.map +1 -1
  197. package/lib/esm/src/dynamic-network/domain/DynamicNetworkContextLoader.test.js.map +1 -1
  198. package/lib/esm/src/external-plugin/data/HttpExternalPluginDataSource.js +1 -1
  199. package/lib/esm/src/external-plugin/data/HttpExternalPluginDataSource.js.map +3 -3
  200. package/lib/esm/src/external-plugin/data/HttpExternalPluginDataSource.test.js +1 -1
  201. package/lib/esm/src/external-plugin/data/HttpExternalPluginDataSource.test.js.map +3 -3
  202. package/lib/esm/src/gated-signing/data/HttpGatedDescriptorDataSource.js +1 -1
  203. package/lib/esm/src/gated-signing/data/HttpGatedDescriptorDataSource.js.map +3 -3
  204. package/lib/esm/src/gated-signing/data/HttpGatedDescriptorDataSource.test.js +1 -1
  205. package/lib/esm/src/gated-signing/data/HttpGatedDescriptorDataSource.test.js.map +3 -3
  206. package/lib/esm/src/index.js +1 -1
  207. package/lib/esm/src/index.js.map +2 -2
  208. package/lib/esm/src/network/di/networkModuleFactory.js +2 -0
  209. package/lib/esm/src/network/di/networkModuleFactory.js.map +7 -0
  210. package/lib/esm/src/network/di/networkTypes.js +2 -0
  211. package/lib/esm/src/network/di/networkTypes.js.map +7 -0
  212. package/lib/esm/src/nft/data/HttpNftDataSource.js +1 -1
  213. package/lib/esm/src/nft/data/HttpNftDataSource.js.map +3 -3
  214. package/lib/esm/src/nft/data/HttpNftDataSource.test.js +1 -1
  215. package/lib/esm/src/nft/data/HttpNftDataSource.test.js.map +3 -3
  216. package/lib/esm/src/pki/data/HttpPkiCertificateDataSource.js +1 -1
  217. package/lib/esm/src/pki/data/HttpPkiCertificateDataSource.js.map +3 -3
  218. package/lib/esm/src/pki/data/HttpPkiCertificateDataSource.test.js +1 -1
  219. package/lib/esm/src/pki/data/HttpPkiCertificateDataSource.test.js.map +3 -3
  220. package/lib/esm/src/proxy/data/HttpProxyDataSource.js +1 -1
  221. package/lib/esm/src/proxy/data/HttpProxyDataSource.js.map +3 -3
  222. package/lib/esm/src/proxy/data/HttpProxyDataSource.test.js +1 -1
  223. package/lib/esm/src/proxy/data/HttpProxyDataSource.test.js.map +3 -3
  224. package/lib/esm/src/proxy/data/HttpSafeProxyDataSource.js +1 -1
  225. package/lib/esm/src/proxy/data/HttpSafeProxyDataSource.js.map +3 -3
  226. package/lib/esm/src/proxy/data/HttpSafeProxyDataSource.test.js +1 -1
  227. package/lib/esm/src/proxy/data/HttpSafeProxyDataSource.test.js.map +3 -3
  228. package/lib/esm/src/proxy/di/proxyModuleFactory.js +1 -1
  229. package/lib/esm/src/proxy/di/proxyModuleFactory.js.map +3 -3
  230. package/lib/esm/src/proxy/di/proxyModuleFactory.test.js +1 -1
  231. package/lib/esm/src/proxy/di/proxyModuleFactory.test.js.map +3 -3
  232. package/lib/esm/src/reporter/data/BlindSigningReporterDatasource.js +1 -0
  233. package/lib/esm/src/reporter/data/BlindSigningReporterDatasource.js.map +7 -0
  234. package/lib/esm/src/reporter/data/HttpBlindSigningReporterDatasource.js +2 -0
  235. package/lib/esm/src/reporter/data/HttpBlindSigningReporterDatasource.js.map +7 -0
  236. package/lib/esm/src/reporter/data/HttpBlindSigningReporterDatasource.test.js +2 -0
  237. package/lib/esm/src/reporter/data/HttpBlindSigningReporterDatasource.test.js.map +7 -0
  238. package/lib/esm/src/reporter/data/dto/BlindSigningEventDto.js +1 -0
  239. package/lib/esm/src/reporter/data/dto/BlindSigningEventDto.js.map +7 -0
  240. package/lib/esm/src/reporter/di/reporterModuleFactory.js +2 -0
  241. package/lib/esm/src/reporter/di/reporterModuleFactory.js.map +7 -0
  242. package/lib/esm/src/reporter/di/reporterTypes.js +2 -0
  243. package/lib/esm/src/reporter/di/reporterTypes.js.map +7 -0
  244. package/lib/esm/src/reporter/domain/BlindSigningReporter.js +1 -0
  245. package/lib/esm/src/reporter/domain/BlindSigningReporter.js.map +7 -0
  246. package/lib/esm/src/reporter/domain/DefaultBlindSigningReporter.js +2 -0
  247. package/lib/esm/src/reporter/domain/DefaultBlindSigningReporter.js.map +7 -0
  248. package/lib/esm/src/reporter/domain/DefaultBlindSigningReporter.test.js +2 -0
  249. package/lib/esm/src/reporter/domain/DefaultBlindSigningReporter.test.js.map +7 -0
  250. package/lib/esm/src/reporter/model/BlindSigningEvent.js +2 -0
  251. package/lib/esm/src/reporter/model/BlindSigningEvent.js.map +7 -0
  252. package/lib/esm/src/reporter/model/BlindSigningModelId.js +2 -0
  253. package/lib/esm/src/reporter/model/BlindSigningModelId.js.map +7 -0
  254. package/lib/esm/src/safe/data/HttpSafeAccountDataSource.js +1 -1
  255. package/lib/esm/src/safe/data/HttpSafeAccountDataSource.js.map +3 -3
  256. package/lib/esm/src/safe/data/HttpSafeAccountDataSource.test.js +1 -1
  257. package/lib/esm/src/safe/data/HttpSafeAccountDataSource.test.js.map +3 -3
  258. package/lib/esm/src/shared/model/ClearSignContext.js +1 -1
  259. package/lib/esm/src/shared/model/ClearSignContext.js.map +2 -2
  260. package/lib/esm/src/solana/data/HttpSolanaOwnerInfoDataSource.js +1 -1
  261. package/lib/esm/src/solana/data/HttpSolanaOwnerInfoDataSource.js.map +3 -3
  262. package/lib/esm/src/solana/data/HttpSolanaOwnerInfoDataSource.test.js +1 -1
  263. package/lib/esm/src/solana/data/HttpSolanaOwnerInfoDataSource.test.js.map +3 -3
  264. package/lib/esm/src/solana/domain/DefaultSolanaContextLoader.test.js +1 -1
  265. package/lib/esm/src/solana/domain/DefaultSolanaContextLoader.test.js.map +1 -1
  266. package/lib/esm/src/solanaLifi/data/HttpSolanaLifiDataSource.js +1 -1
  267. package/lib/esm/src/solanaLifi/data/HttpSolanaLifiDataSource.js.map +3 -3
  268. package/lib/esm/src/solanaLifi/data/HttpSolanaLifiDataSource.test.js +1 -1
  269. package/lib/esm/src/solanaLifi/data/HttpSolanaLifiDataSource.test.js.map +3 -3
  270. package/lib/esm/src/solanaLifi/domain/SolanaLifiContextLoader.js.map +1 -1
  271. package/lib/esm/src/solanaLifi/domain/SolanaLifiContextLoader.test.js +1 -1
  272. package/lib/esm/src/solanaLifi/domain/SolanaLifiContextLoader.test.js.map +1 -1
  273. package/lib/esm/src/solanaToken/data/HttpSolanaTokenDataSource.js +1 -1
  274. package/lib/esm/src/solanaToken/data/HttpSolanaTokenDataSource.js.map +3 -3
  275. package/lib/esm/src/solanaToken/data/HttpSolanaTokenDataSource.test.js +6 -6
  276. package/lib/esm/src/solanaToken/data/HttpSolanaTokenDataSource.test.js.map +3 -3
  277. package/lib/esm/src/solanaToken/domain/SolanaTokenContextLoader.js +1 -1
  278. package/lib/esm/src/solanaToken/domain/SolanaTokenContextLoader.js.map +2 -2
  279. package/lib/esm/src/solanaToken/domain/SolanaTokenContextLoader.test.js +1 -1
  280. package/lib/esm/src/solanaToken/domain/SolanaTokenContextLoader.test.js.map +1 -1
  281. package/lib/esm/src/token/data/HttpTokenDataSource.js +1 -1
  282. package/lib/esm/src/token/data/HttpTokenDataSource.js.map +3 -3
  283. package/lib/esm/src/token/data/HttpTokenDataSource.test.js +1 -1
  284. package/lib/esm/src/token/data/HttpTokenDataSource.test.js.map +3 -3
  285. package/lib/esm/src/transaction-check/data/HttpTransactionCheckDataSource.js +1 -1
  286. package/lib/esm/src/transaction-check/data/HttpTransactionCheckDataSource.js.map +3 -3
  287. package/lib/esm/src/transaction-check/data/HttpTransactionCheckDataSource.test.js +1 -1
  288. package/lib/esm/src/transaction-check/data/HttpTransactionCheckDataSource.test.js.map +3 -3
  289. package/lib/esm/src/transaction-check/data/HttpTypedDataCheckDataSource.js +1 -1
  290. package/lib/esm/src/transaction-check/data/HttpTypedDataCheckDataSource.js.map +3 -3
  291. package/lib/esm/src/transaction-check/data/HttpTypedDataCheckDataSource.test.js +1 -1
  292. package/lib/esm/src/transaction-check/data/HttpTypedDataCheckDataSource.test.js.map +3 -3
  293. package/lib/esm/src/trusted-name/data/HttpTrustedNameDataSource.js +1 -1
  294. package/lib/esm/src/trusted-name/data/HttpTrustedNameDataSource.js.map +3 -3
  295. package/lib/esm/src/trusted-name/data/HttpTrustedNameDataSource.test.js +1 -1
  296. package/lib/esm/src/trusted-name/data/HttpTrustedNameDataSource.test.js.map +3 -3
  297. package/lib/esm/src/trusted-name/di/trustedNameModuleFactory.js +1 -1
  298. package/lib/esm/src/trusted-name/di/trustedNameModuleFactory.js.map +3 -3
  299. package/lib/esm/src/typed-data/data/HttpTypedDataDataSource.js +1 -1
  300. package/lib/esm/src/typed-data/data/HttpTypedDataDataSource.js.map +3 -3
  301. package/lib/esm/src/typed-data/data/HttpTypedDataDataSource.test.js +1 -1
  302. package/lib/esm/src/typed-data/data/HttpTypedDataDataSource.test.js.map +3 -3
  303. package/lib/types/src/ContextModule.d.ts +2 -0
  304. package/lib/types/src/ContextModule.d.ts.map +1 -1
  305. package/lib/types/src/ContextModuleBuilder.d.ts +30 -3
  306. package/lib/types/src/ContextModuleBuilder.d.ts.map +1 -1
  307. package/lib/types/src/DefaultContextModule.d.ts +6 -2
  308. package/lib/types/src/DefaultContextModule.d.ts.map +1 -1
  309. package/lib/types/src/account-ownership/data/AccountOwnershipDataSource.d.ts +17 -0
  310. package/lib/types/src/account-ownership/data/AccountOwnershipDataSource.d.ts.map +1 -0
  311. package/lib/types/src/account-ownership/data/AccountOwnershipError.d.ts +17 -0
  312. package/lib/types/src/account-ownership/data/AccountOwnershipError.d.ts.map +1 -0
  313. package/lib/types/src/account-ownership/data/HttpAccountOwnershipDataSource.d.ts +30 -0
  314. package/lib/types/src/account-ownership/data/HttpAccountOwnershipDataSource.d.ts.map +1 -0
  315. package/lib/types/src/account-ownership/data/HttpAccountOwnershipDataSource.test.d.ts +2 -0
  316. package/lib/types/src/account-ownership/data/HttpAccountOwnershipDataSource.test.d.ts.map +1 -0
  317. package/lib/types/src/account-ownership/data/dto/AccountOwnershipDto.d.ts +6 -0
  318. package/lib/types/src/account-ownership/data/dto/AccountOwnershipDto.d.ts.map +1 -0
  319. package/lib/types/src/account-ownership/di/accountOwnershipModuleFactory.d.ts +3 -0
  320. package/lib/types/src/account-ownership/di/accountOwnershipModuleFactory.d.ts.map +1 -0
  321. package/lib/types/src/account-ownership/di/accountOwnershipTypes.d.ts +5 -0
  322. package/lib/types/src/account-ownership/di/accountOwnershipTypes.d.ts.map +1 -0
  323. package/lib/types/src/account-ownership/domain/AccountOwnershipContextLoader.d.ts +20 -0
  324. package/lib/types/src/account-ownership/domain/AccountOwnershipContextLoader.d.ts.map +1 -0
  325. package/lib/types/src/account-ownership/domain/AccountOwnershipContextLoader.test.d.ts +2 -0
  326. package/lib/types/src/account-ownership/domain/AccountOwnershipContextLoader.test.d.ts.map +1 -0
  327. package/lib/types/src/calldata/data/HttpCalldataDescriptorDataSource.d.ts +4 -2
  328. package/lib/types/src/calldata/data/HttpCalldataDescriptorDataSource.d.ts.map +1 -1
  329. package/lib/types/src/calldata/di/calldataModuleFactory.d.ts.map +1 -1
  330. package/lib/types/src/config/di/configModuleFactory.d.ts +2 -2
  331. package/lib/types/src/config/di/configModuleFactory.d.ts.map +1 -1
  332. package/lib/types/src/config/model/ContextModuleConfig.d.ts +14 -3
  333. package/lib/types/src/config/model/ContextModuleConfig.d.ts.map +1 -1
  334. package/lib/types/src/di.d.ts +2 -2
  335. package/lib/types/src/di.d.ts.map +1 -1
  336. package/lib/types/src/dynamic-network/data/HttpDynamicNetworkDataSource.d.ts +4 -2
  337. package/lib/types/src/dynamic-network/data/HttpDynamicNetworkDataSource.d.ts.map +1 -1
  338. package/lib/types/src/dynamic-network/domain/DynamicNetworkContextLoader.d.ts +2 -2
  339. package/lib/types/src/dynamic-network/domain/DynamicNetworkContextLoader.d.ts.map +1 -1
  340. package/lib/types/src/external-plugin/data/HttpExternalPluginDataSource.d.ts +4 -2
  341. package/lib/types/src/external-plugin/data/HttpExternalPluginDataSource.d.ts.map +1 -1
  342. package/lib/types/src/gated-signing/data/HttpGatedDescriptorDataSource.d.ts +4 -2
  343. package/lib/types/src/gated-signing/data/HttpGatedDescriptorDataSource.d.ts.map +1 -1
  344. package/lib/types/src/index.d.ts +11 -1
  345. package/lib/types/src/index.d.ts.map +1 -1
  346. package/lib/types/src/network/di/networkModuleFactory.d.ts +4 -0
  347. package/lib/types/src/network/di/networkModuleFactory.d.ts.map +1 -0
  348. package/lib/types/src/network/di/networkTypes.d.ts +4 -0
  349. package/lib/types/src/network/di/networkTypes.d.ts.map +1 -0
  350. package/lib/types/src/nft/data/HttpNftDataSource.d.ts +4 -2
  351. package/lib/types/src/nft/data/HttpNftDataSource.d.ts.map +1 -1
  352. package/lib/types/src/pki/data/HttpPkiCertificateDataSource.d.ts +5 -2
  353. package/lib/types/src/pki/data/HttpPkiCertificateDataSource.d.ts.map +1 -1
  354. package/lib/types/src/proxy/data/HttpProxyDataSource.d.ts +4 -2
  355. package/lib/types/src/proxy/data/HttpProxyDataSource.d.ts.map +1 -1
  356. package/lib/types/src/proxy/data/HttpSafeProxyDataSource.d.ts +4 -2
  357. package/lib/types/src/proxy/data/HttpSafeProxyDataSource.d.ts.map +1 -1
  358. package/lib/types/src/proxy/di/proxyModuleFactory.d.ts +2 -2
  359. package/lib/types/src/proxy/di/proxyModuleFactory.d.ts.map +1 -1
  360. package/lib/types/src/reporter/data/BlindSigningReporterDatasource.d.ts +29 -0
  361. package/lib/types/src/reporter/data/BlindSigningReporterDatasource.d.ts.map +1 -0
  362. package/lib/types/src/reporter/data/HttpBlindSigningReporterDatasource.d.ts +11 -0
  363. package/lib/types/src/reporter/data/HttpBlindSigningReporterDatasource.d.ts.map +1 -0
  364. package/lib/types/src/reporter/data/HttpBlindSigningReporterDatasource.test.d.ts +2 -0
  365. package/lib/types/src/reporter/data/HttpBlindSigningReporterDatasource.test.d.ts.map +1 -0
  366. package/lib/types/src/reporter/data/dto/BlindSigningEventDto.d.ts +26 -0
  367. package/lib/types/src/reporter/data/dto/BlindSigningEventDto.d.ts.map +1 -0
  368. package/lib/types/src/reporter/di/reporterModuleFactory.d.ts +3 -0
  369. package/lib/types/src/reporter/di/reporterModuleFactory.d.ts.map +1 -0
  370. package/lib/types/src/reporter/di/reporterTypes.d.ts +5 -0
  371. package/lib/types/src/reporter/di/reporterTypes.d.ts.map +1 -0
  372. package/lib/types/src/reporter/domain/BlindSigningReporter.d.ts +6 -0
  373. package/lib/types/src/reporter/domain/BlindSigningReporter.d.ts.map +1 -0
  374. package/lib/types/src/reporter/domain/DefaultBlindSigningReporter.d.ts +9 -0
  375. package/lib/types/src/reporter/domain/DefaultBlindSigningReporter.d.ts.map +1 -0
  376. package/lib/types/src/reporter/domain/DefaultBlindSigningReporter.test.d.ts +2 -0
  377. package/lib/types/src/reporter/domain/DefaultBlindSigningReporter.test.d.ts.map +1 -0
  378. package/lib/types/src/reporter/model/BlindSigningEvent.d.ts +21 -0
  379. package/lib/types/src/reporter/model/BlindSigningEvent.d.ts.map +1 -0
  380. package/lib/types/src/reporter/model/BlindSigningModelId.d.ts +12 -0
  381. package/lib/types/src/reporter/model/BlindSigningModelId.d.ts.map +1 -0
  382. package/lib/types/src/safe/data/HttpSafeAccountDataSource.d.ts +4 -2
  383. package/lib/types/src/safe/data/HttpSafeAccountDataSource.d.ts.map +1 -1
  384. package/lib/types/src/shared/model/ClearSignContext.d.ts +2 -1
  385. package/lib/types/src/shared/model/ClearSignContext.d.ts.map +1 -1
  386. package/lib/types/src/solana/data/HttpSolanaOwnerInfoDataSource.d.ts +4 -2
  387. package/lib/types/src/solana/data/HttpSolanaOwnerInfoDataSource.d.ts.map +1 -1
  388. package/lib/types/src/solanaLifi/data/HttpSolanaLifiDataSource.d.ts +4 -3
  389. package/lib/types/src/solanaLifi/data/HttpSolanaLifiDataSource.d.ts.map +1 -1
  390. package/lib/types/src/solanaLifi/domain/SolanaLifiContextLoader.d.ts +2 -2
  391. package/lib/types/src/solanaLifi/domain/SolanaLifiContextLoader.d.ts.map +1 -1
  392. package/lib/types/src/solanaToken/data/HttpSolanaTokenDataSource.d.ts +4 -2
  393. package/lib/types/src/solanaToken/data/HttpSolanaTokenDataSource.d.ts.map +1 -1
  394. package/lib/types/src/solanaToken/domain/SolanaTokenContextLoader.d.ts +2 -2
  395. package/lib/types/src/solanaToken/domain/SolanaTokenContextLoader.d.ts.map +1 -1
  396. package/lib/types/src/token/data/HttpTokenDataSource.d.ts +4 -2
  397. package/lib/types/src/token/data/HttpTokenDataSource.d.ts.map +1 -1
  398. package/lib/types/src/transaction-check/data/HttpTransactionCheckDataSource.d.ts +4 -2
  399. package/lib/types/src/transaction-check/data/HttpTransactionCheckDataSource.d.ts.map +1 -1
  400. package/lib/types/src/transaction-check/data/HttpTypedDataCheckDataSource.d.ts +4 -2
  401. package/lib/types/src/transaction-check/data/HttpTypedDataCheckDataSource.d.ts.map +1 -1
  402. package/lib/types/src/trusted-name/data/HttpTrustedNameDataSource.d.ts +4 -2
  403. package/lib/types/src/trusted-name/data/HttpTrustedNameDataSource.d.ts.map +1 -1
  404. package/lib/types/src/trusted-name/di/trustedNameModuleFactory.d.ts +2 -2
  405. package/lib/types/src/trusted-name/di/trustedNameModuleFactory.d.ts.map +1 -1
  406. package/lib/types/src/typed-data/data/HttpTypedDataDataSource.d.ts +4 -2
  407. package/lib/types/src/typed-data/data/HttpTypedDataDataSource.d.ts.map +1 -1
  408. package/lib/types/src/typed-data/data/HttpTypedDataDataSource.test.d.ts.map +1 -1
  409. package/lib/types/tsconfig.prod.tsbuildinfo +1 -1
  410. package/package.json +6 -7
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../src/ContextModuleBuilder.ts"],
4
- "sourcesContent": ["import {\n type LoggerPublisherService,\n noopLoggerFactory,\n} from \"@ledgerhq/device-management-kit\";\n\nimport { type ContextModuleConstructorArgs } from \"./config/model/ContextModuleBuildArgs\";\nimport {\n type ContextModuleCalConfig,\n type ContextModuleConfig,\n type ContextModuleDatasourceConfig,\n type ContextModuleMetadataServiceConfig,\n type ContextModuleWeb3ChecksConfig,\n} from \"./config/model/ContextModuleConfig\";\nimport { type ContextLoader } from \"./shared/domain/ContextLoader\";\nimport { type SolanaContextLoader } from \"./solana/domain/SolanaContextLoader\";\nimport { type TrustedNameDataSource } from \"./trusted-name/data/TrustedNameDataSource\";\nimport { type TypedDataContextLoader } from \"./typed-data/domain/TypedDataContextLoader\";\nimport { type ContextModule } from \"./ContextModule\";\nimport { DefaultContextModule } from \"./DefaultContextModule\";\n\nconst DEFAULT_CAL_URL = \"https://crypto-assets-service.api.ledger.com/v1\";\nconst DEFAULT_WEB3_CHECKS_URL = \"https://web3checks-backend.api.ledger.com/v3\";\nconst DEFAULT_METADATA_SERVICE_DOMAIN = \"https://nft.api.live.ledger.com\";\n\nexport const DEFAULT_CONFIG: ContextModuleConfig = {\n cal: {\n url: DEFAULT_CAL_URL,\n mode: \"prod\",\n branch: \"main\",\n },\n web3checks: {\n url: DEFAULT_WEB3_CHECKS_URL,\n },\n metadataServiceDomain: {\n url: DEFAULT_METADATA_SERVICE_DOMAIN,\n },\n defaultLoaders: true,\n customLoaders: [],\n defaultFieldLoaders: true,\n customFieldLoaders: [],\n customTypedDataLoader: undefined,\n customSolanaLoader: undefined,\n loggerFactory: noopLoggerFactory,\n};\n\nexport class ContextModuleBuilder {\n private config: ContextModuleConfig;\n private originToken?: string;\n\n constructor({ originToken, loggerFactory }: ContextModuleConstructorArgs) {\n this.originToken = originToken;\n\n this.config = {\n ...DEFAULT_CONFIG,\n cal: { ...DEFAULT_CONFIG.cal },\n web3checks: { ...DEFAULT_CONFIG.web3checks },\n metadataServiceDomain: { ...DEFAULT_CONFIG.metadataServiceDomain },\n customLoaders: [...DEFAULT_CONFIG.customLoaders],\n customFieldLoaders: [...DEFAULT_CONFIG.customFieldLoaders],\n };\n if (loggerFactory) {\n this.config.loggerFactory = loggerFactory;\n }\n }\n\n /**\n * Remove default loaders from the list of loaders\n *\n * @returns this\n */\n removeDefaultLoaders() {\n this.config.defaultLoaders = false;\n return this;\n }\n\n /**\n * Add a custom loader to the list of loaders\n *\n * @param loader loader to add to the list of loaders\n * @returns this\n */\n addLoader(loader: ContextLoader) {\n this.config.customLoaders.push(loader);\n return this;\n }\n\n /**\n * Replace the default loader for typed data clear signing contexts\n *\n * @param loader loader to use for typed data clear signing contexts\n * @returns this\n */\n addTypedDataLoader(loader: TypedDataContextLoader) {\n this.config.customTypedDataLoader = loader;\n return this;\n }\n\n /**\n * Replace the default loader for Solana context\n *\n * @param loader loader to use for Solana context\n * @returns this\n */\n addSolanaLoader(loader: SolanaContextLoader) {\n this.config.customSolanaLoader = loader;\n return this;\n }\n\n /**\n * Add a custom CAL configuration\n *\n * @param calConfig\n * @returns this\n */\n setCalConfig(calConfig: ContextModuleCalConfig) {\n this.config.cal = calConfig;\n return this;\n }\n\n /**\n * Add a custom metadata service configuration\n *\n * @param metadataServiceConfig\n * @returns this\n */\n setMetadataServiceConfig(\n metadataServiceConfig: ContextModuleMetadataServiceConfig,\n ) {\n this.config.metadataServiceDomain = metadataServiceConfig;\n return this;\n }\n\n /**\n * Add a custom web3 checks configuration\n *\n * @param web3ChecksConfig\n * @returns this\n */\n setWeb3ChecksConfig(web3ChecksConfig: ContextModuleWeb3ChecksConfig) {\n this.config.web3checks = web3ChecksConfig;\n return this;\n }\n\n /**\n * Add datasource configuration\n *\n * @param datasourceConfig\n * @returns this\n */\n setDatasourceConfig(datasourceConfig: ContextModuleDatasourceConfig) {\n this.config.datasource = datasourceConfig;\n return this;\n }\n\n /**\n * Set a custom trusted name data source\n *\n * @param dataSource data source to use for trusted name resolution\n * @returns this\n */\n setTrustedNameDataSource(dataSource: TrustedNameDataSource) {\n this.config.customTrustedNameDataSource = dataSource;\n return this;\n }\n\n /**\n * Set a custom logger factory\n *\n * @param loggerFactory\n * @returns this\n */\n setLoggerFactory(loggerFactory: (tag: string) => LoggerPublisherService) {\n this.config.loggerFactory = loggerFactory;\n return this;\n }\n\n /**\n * Build the context module\n *\n * @returns the context module\n */\n build(): ContextModule {\n const config = { ...this.config, originToken: this.originToken };\n return new DefaultContextModule(config);\n }\n}\n"],
5
- "mappings": "AAAA,OAEE,qBAAAA,MACK,kCAeP,OAAS,wBAAAC,MAA4B,yBAErC,MAAMC,EAAkB,kDAClBC,EAA0B,+CAC1BC,EAAkC,kCAE3BC,EAAsC,CACjD,IAAK,CACH,IAAKH,EACL,KAAM,OACN,OAAQ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Y,EAC/D,OAAO,IAAId,EAAqBc,CAAM,CACxC,CACF",
6
- "names": ["noopLoggerFactory", "DefaultContextModule", "DEFAULT_CAL_URL", "DEFAULT_WEB3_CHECKS_URL", "DEFAULT_METADATA_SERVICE_DOMAIN", "DEFAULT_CONFIG", "ContextModuleBuilder", "originToken", "loggerFactory", "loader", "calConfig", "metadataServiceConfig", "web3ChecksConfig", "datasourceConfig", "dataSource", "config"]
4
+ "sourcesContent": ["import {\n type LoggerPublisherService,\n noopLoggerFactory,\n} from \"@ledgerhq/device-management-kit\";\n\nimport { type ContextModuleConstructorArgs } from \"./config/model/ContextModuleBuildArgs\";\nimport {\n type ContextModuleCalConfig,\n type ContextModuleConfig,\n type ContextModuleDatasourceConfig,\n type ContextModuleLoaderConfig,\n type ContextModuleMetadataServiceConfig,\n type ContextModuleReporterConfig,\n type ContextModuleServiceConfig,\n type ContextModuleWeb3ChecksConfig,\n} from \"./config/model/ContextModuleConfig\";\nimport { type BlindSigningReporter } from \"./reporter/domain/BlindSigningReporter\";\nimport { type ContextLoader } from \"./shared/domain/ContextLoader\";\nimport { type SolanaContextLoader } from \"./solana/domain/SolanaContextLoader\";\nimport { type TrustedNameDataSource } from \"./trusted-name/data/TrustedNameDataSource\";\nimport { type TypedDataContextLoader } from \"./typed-data/domain/TypedDataContextLoader\";\nimport { type ContextModule } from \"./ContextModule\";\nimport { DefaultContextModule } from \"./DefaultContextModule\";\n\nconst DEFAULT_CAL_URL = \"https://crypto-assets-service.api.ledger.com/v1\";\nconst DEFAULT_WEB3_CHECKS_URL = \"https://web3checks-backend.api.ledger.com/v3\";\nconst DEFAULT_METADATA_SERVICE_DOMAIN = \"https://nft.api.live.ledger.com\";\nconst DEFAULT_REPORTER_URL = \"https://ingest.aws.stg.ldg-tech.com/ingest/v1\";\n\n/**\n * Default configuration for the context module\n *\n * @note This configuration is frozen to prevent modifications after construction\n * and can be used by external packages to get a default configuration.\n */\nexport const DEFAULT_CONFIG: Readonly<ContextModuleConfig> = Object.freeze({\n cal: Object.freeze({\n url: DEFAULT_CAL_URL,\n mode: \"prod\",\n branch: \"main\",\n }),\n web3checks: Object.freeze({\n url: DEFAULT_WEB3_CHECKS_URL,\n }),\n metadataServiceDomain: Object.freeze({\n url: DEFAULT_METADATA_SERVICE_DOMAIN,\n }),\n reporter: Object.freeze({\n url: DEFAULT_REPORTER_URL,\n }),\n datasource: Object.freeze({ proxy: \"default\" }),\n appSource: \"third-party\",\n});\n\n/**\n * Default loader configuration for the context module\n *\n * @note This configuration is internal and will be the default configuration for the context module.\n */\nconst DEFAULT_LOADER_CONFIG: ContextModuleLoaderConfig = {\n defaultLoaders: true,\n defaultFieldLoaders: true,\n customLoaders: [],\n customFieldLoaders: [],\n customTypedDataLoader: undefined,\n customSolanaLoader: undefined,\n customBlindSigningReporter: undefined,\n customTrustedNameDataSource: undefined,\n};\n\nexport class ContextModuleBuilder {\n private config: ContextModuleServiceConfig & ContextModuleLoaderConfig;\n\n constructor({ originToken, loggerFactory }: ContextModuleConstructorArgs) {\n this.config = {\n ...DEFAULT_CONFIG,\n ...DEFAULT_LOADER_CONFIG,\n customLoaders: [],\n customFieldLoaders: [],\n originToken: originToken ?? \"\",\n loggerFactory: loggerFactory ?? noopLoggerFactory,\n } as ContextModuleServiceConfig & ContextModuleLoaderConfig;\n }\n\n /**\n * Remove default loaders from the list of loaders\n *\n * @returns this\n */\n removeDefaultLoaders() {\n this.config.defaultLoaders = false;\n return this;\n }\n\n /**\n * Add a custom loader to the list of loaders\n *\n * @param loader loader to add to the list of loaders\n * @returns this\n */\n addLoader(loader: ContextLoader) {\n this.config.customLoaders.push(loader);\n return this;\n }\n\n /**\n * Replace the default loader for typed data clear signing contexts\n *\n * @param loader loader to use for typed data clear signing contexts\n * @returns this\n */\n addTypedDataLoader(loader: TypedDataContextLoader) {\n this.config.customTypedDataLoader = loader;\n return this;\n }\n\n /**\n * Replace the default loader for Solana context\n *\n * @param loader loader to use for Solana context\n * @returns this\n */\n addSolanaLoader(loader: SolanaContextLoader) {\n this.config.customSolanaLoader = loader;\n return this;\n }\n\n /**\n * Add a custom CAL configuration\n *\n * @param calConfig\n * @returns this\n */\n setCalConfig(calConfig: ContextModuleCalConfig) {\n this.config.cal = calConfig;\n return this;\n }\n\n /**\n * Add a custom metadata service configuration\n *\n * @param metadataServiceConfig\n * @returns this\n */\n setMetadataServiceConfig(\n metadataServiceConfig: ContextModuleMetadataServiceConfig,\n ) {\n this.config.metadataServiceDomain = metadataServiceConfig;\n return this;\n }\n\n /**\n * Add a custom web3 checks configuration\n *\n * @param web3ChecksConfig\n * @returns this\n */\n setWeb3ChecksConfig(web3ChecksConfig: ContextModuleWeb3ChecksConfig) {\n this.config.web3checks = web3ChecksConfig;\n return this;\n }\n\n /**\n * Add datasource configuration\n *\n * @param datasourceConfig\n * @returns this\n */\n setDatasourceConfig(datasourceConfig: ContextModuleDatasourceConfig) {\n this.config.datasource = datasourceConfig;\n return this;\n }\n\n /**\n * Set a custom reporter configuration\n *\n * @param reporterConfig\n * @returns this\n */\n setReporterConfig(reporterConfig: ContextModuleReporterConfig) {\n this.config.reporter = reporterConfig;\n return this;\n }\n\n /**\n * Set the app source identifier included in blind signing reports\n *\n * @param appSource\n * @returns this\n */\n setAppSource(appSource: string) {\n this.config.appSource = appSource;\n return this;\n }\n\n /**\n * Set a custom blind signing reporter\n *\n * @param reporter reporter to use for blind signing events\n * @returns this\n */\n setBlindSigningReporter(reporter: BlindSigningReporter) {\n this.config.customBlindSigningReporter = reporter;\n return this;\n }\n\n /**\n * Set a custom trusted name data source\n *\n * @param dataSource data source to use for trusted name resolution\n * @returns this\n */\n setTrustedNameDataSource(dataSource: TrustedNameDataSource) {\n this.config.customTrustedNameDataSource = dataSource;\n return this;\n }\n\n /**\n * Set a custom logger factory\n *\n * @param loggerFactory\n * @returns this\n */\n setLoggerFactory(loggerFactory: (tag: string) => LoggerPublisherService) {\n this.config.loggerFactory = loggerFactory;\n return this;\n }\n\n /**\n * Build the context module\n *\n * @returns the context module\n */\n build(): ContextModule {\n return new DefaultContextModule(this.config);\n }\n}\n"],
5
+ "mappings": "AAAA,OAEE,qBAAAA,MACK,kCAmBP,OAAS,wBAAAC,MAA4B,yBAErC,MAAMC,EAAkB,kDAClBC,EAA0B,+CAC1BC,EAAkC,kCAClCC,EAAuB,gDAQhBC,EAAgD,OAAO,OAAO,CACzE,IAAK,OAAO,OAAO,CACjB,IAAKJ,EACL,KAAM,OACN,OAAQ,MACV,CAAC,EACD,WAAY,OAAO,OAAO,CACxB,IAAKC,CACP,CAAC,EACD,sBAAuB,OAAO,OAAO,CACnC,IAAKC,CACP,CAAC,EACD,SAAU,OAAO,OAAO,CACtB,IAAKC,CACP,CAAC,EACD,WAAY,OAAO,OAAO,CAAE,MAAO,SAAU,CAAC,EAC9C,UAAW,aACb,CAAC,EAOKE,EAAmD,CACvD,eAAgB,GAChB,oBAAqB,GACrB,cAAe,CAAC,EAChB,mBAAoB,CAAC,EACrB,sBAAuB,OACvB,mBAAoB,OACpB,2BAA4B,OAC5B,4BAA6B,MAC/B,EAEO,MAAMC,CAAqB,CACxB,OAER,YAAY,CAAE,YAAAC,EAAa,cAAAC,CAAc,EAAiC,CACxE,KAAK,OAAS,CACZ,GAAGJ,EACH,GAAGC,EACH,cAAe,CAAC,EAChB,mBAAoB,CAAC,EACrB,YAAaE,GAAe,GAC5B,cAAeC,GAAiBV,CAClC,CACF,CAOA,sBAAuB,CACrB,YAAK,OAAO,eAAiB,GACtB,IACT,CAQA,UAAUW,EAAuB,CAC/B,YAAK,OAAO,cAAc,KAAKA,CAAM,EAC9B,IACT,CAQA,mBAAmBA,EAAgC,CACjD,YAAK,OAAO,sBAAwBA,EAC7B,IACT,CAQA,gBAAgBA,EAA6B,CAC3C,YAAK,OAAO,mBAAqBA,EAC1B,IACT,CAQA,aAAaC,EAAmC,CAC9C,YAAK,OAAO,IAAMA,EACX,IACT,CAQA,yBACEC,EACA,CACA,YAAK,OAAO,sBAAwBA,EAC7B,IACT,CAQA,oBAAoBC,EAAiD,CACnE,YAAK,OAAO,WAAaA,EAClB,IACT,CAQA,oBAAoBC,EAAiD,CACnE,YAAK,OAAO,WAAaA,EAClB,IACT,CAQA,kBAAkBC,EAA6C,CAC7D,YAAK,OAAO,SAAWA,EAChB,IACT,CAQA,aAAaC,EAAmB,CAC9B,YAAK,OAAO,UAAYA,EACjB,IACT,CAQA,wBAAwBC,EAAgC,CACtD,YAAK,OAAO,2BAA6BA,EAClC,IACT,CAQA,yBAAyBC,EAAmC,CAC1D,YAAK,OAAO,4BAA8BA,EACnC,IACT,CAQA,iBAAiBT,EAAwD,CACvE,YAAK,OAAO,cAAgBA,EACrB,IACT,CAOA,OAAuB,CACrB,OAAO,IAAIT,EAAqB,KAAK,MAAM,CAC7C,CACF",
6
+ "names": ["noopLoggerFactory", "DefaultContextModule", "DEFAULT_CAL_URL", "DEFAULT_WEB3_CHECKS_URL", "DEFAULT_METADATA_SERVICE_DOMAIN", "DEFAULT_REPORTER_URL", "DEFAULT_CONFIG", "DEFAULT_LOADER_CONFIG", "ContextModuleBuilder", "originToken", "loggerFactory", "loader", "calConfig", "metadataServiceConfig", "web3ChecksConfig", "datasourceConfig", "reporterConfig", "appSource", "reporter", "dataSource"]
7
7
  }
@@ -1,2 +1,2 @@
1
- import{configTypes as a}from"./config/di/configTypes";import{HttpTrustedNameDataSource as g}from"./trusted-name/data/HttpTrustedNameDataSource";import{trustedNameTypes as l}from"./trusted-name/di/trustedNameTypes";import{ContextModuleBuilder as c}from"./ContextModuleBuilder";import{DefaultContextModule as s}from"./DefaultContextModule";describe("ContextModuleBuilder",()=>{const u={url:"https://cal/v1",mode:"prod",branch:"main"},i={url:"https://web3checks/v1"},r={originToken:"test",loggerFactory:()=>({debug:vi.fn(),info:vi.fn(),warn:vi.fn(),error:vi.fn(),subscribers:[]})};beforeEach(()=>{vi.resetAllMocks()}),it("should return a default context module",()=>{const e=new c(r).build();expect(e).toBeInstanceOf(s)}),it("should return a custom context module",()=>{const n=new c(r),e={load:vi.fn(),canHandle:vi.fn()},o=n.removeDefaultLoaders().addLoader(e).build();expect(o).toBeInstanceOf(s)}),it("should return a custom context module with a custom typed data loader",()=>{const n=new c(r),e={load:vi.fn()},o=n.removeDefaultLoaders().addTypedDataLoader(e).build();expect(o).toBeInstanceOf(s),expect(o._typedDataLoader).toBe(e)}),it("should return a custom context module with a custom config",()=>{const e=new c(r).setCalConfig(u).setWeb3ChecksConfig(i).build(),o=e._container.get(a.Config);expect(e).toBeInstanceOf(s),expect(o.cal).toEqual(u),expect(o.web3checks).toEqual(i)}),it("should not throw an error if origin token is provided",()=>{const n=new c(r);expect(()=>n.build()).not.toThrow()}),describe("setMetadataServiceConfig",()=>{it("should set the metadata service configuration",()=>{const n=new c(r),e={url:"https://custom-metadata-service.com/v3"},o=n.setMetadataServiceConfig(e).build(),t=o._container.get(a.Config);expect(o).toBeInstanceOf(s),expect(t.metadataServiceDomain).toEqual(e)}),it("should override the default metadata service configuration",()=>{const n=new c(r),e={url:"https://override-metadata-service.com/v1"},t=n.setMetadataServiceConfig(e).build()._container.get(a.Config);expect(t.metadataServiceDomain.url).toBe(e.url),expect(t.metadataServiceDomain.url).not.toBe("https://nft.api.live.ledger.com/v2")})}),describe("setCalConfig",()=>{it("should set the CAL configuration",()=>{const n=new c(r),e={url:"https://custom-cal-service.com/v2",mode:"test",branch:"next"},o=n.setCalConfig(e).build(),t=o._container.get(a.Config);expect(o).toBeInstanceOf(s),expect(t.cal).toEqual(e)}),it("should override the default CAL configuration",()=>{const n=new c(r),e={url:"https://override-cal-service.com/v1",mode:"prod",branch:"demo"},t=n.setCalConfig(e).build()._container.get(a.Config);expect(t.cal.url).toBe(e.url),expect(t.cal.mode).toBe(e.mode),expect(t.cal.branch).toBe(e.branch),expect(t.cal.url).not.toBe("https://crypto-assets-service.api.ledger.com/v1")})}),describe("setWeb3ChecksConfig",()=>{it("should set the web3 checks configuration",()=>{const n=new c(r),e={url:"https://custom-web3checks-service.com/v4"},o=n.setWeb3ChecksConfig(e).build(),t=o._container.get(a.Config);expect(o).toBeInstanceOf(s),expect(t.web3checks).toEqual(e)}),it("should override the default web3 checks configuration",()=>{const n=new c(r),e={url:"https://override-web3checks-service.com/v2"},t=n.setWeb3ChecksConfig(e).build()._container.get(a.Config);expect(t.web3checks.url).toBe(e.url),expect(t.web3checks.url).not.toBe("https://web3checks-backend.api.ledger.com/v3")})}),describe("setDatasourceConfig",()=>{it("should set the datasource configuration with safe proxy",()=>{const n=new c(r),e={proxy:"safe"},o=n.setDatasourceConfig(e).build(),t=o._container.get(a.Config);expect(o).toBeInstanceOf(s),expect(t.datasource).toEqual(e),expect(t.datasource?.proxy).toBe("safe")}),it("should set the datasource configuration with default proxy",()=>{const n=new c(r),e={proxy:"default"},o=n.setDatasourceConfig(e).build(),t=o._container.get(a.Config);expect(o).toBeInstanceOf(s),expect(t.datasource).toEqual(e),expect(t.datasource?.proxy).toBe("default")}),it("should override the default datasource configuration",()=>{const n=new c(r),e={proxy:"safe"},t=n.setDatasourceConfig(e).build()._container.get(a.Config);expect(t.datasource?.proxy).toBe("safe"),expect(t.datasource).not.toBeUndefined()}),it("should set an empty datasource configuration",()=>{const n=new c(r),e={},o=n.setDatasourceConfig(e).build(),t=o._container.get(a.Config);expect(o).toBeInstanceOf(s),expect(t.datasource).toEqual(e),expect(t.datasource?.proxy).toBeUndefined()})}),describe("loggerFactory",()=>{it("should use the default empty logger when loggerFactory is not provided",()=>{const e=new c({originToken:"test"}).build(),o=e._container.get(a.Config);expect(e).toBeInstanceOf(s),expect(o.loggerFactory).toBeDefined();const t=o.loggerFactory("test");expect(t.debug).toBeDefined(),expect(t.info).toBeDefined(),expect(t.warn).toBeDefined(),expect(t.error).toBeDefined(),expect(t.subscribers).toEqual([]),expect(()=>t.debug("test")).not.toThrow(),expect(()=>t.info("test")).not.toThrow(),expect(()=>t.warn("test")).not.toThrow(),expect(()=>t.error("test")).not.toThrow()}),it("should set the loggerFactory when provided in the constructor",()=>{const n=vi.fn(),o=new c({...r,loggerFactory:n}).build(),t=o._container.get(a.Config);expect(o).toBeInstanceOf(s),expect(t.loggerFactory).toBe(n)}),it("should set the loggerFactory via setLoggerFactory",()=>{const n=vi.fn(),o=new c(r).setLoggerFactory(n).build(),t=o._container.get(a.Config);expect(o).toBeInstanceOf(s),expect(t.loggerFactory).toBe(n)}),it("should override constructor loggerFactory with setLoggerFactory",()=>{const n=vi.fn(),e=vi.fn(),d=new c({...r,loggerFactory:n}).setLoggerFactory(e).build()._container.get(a.Config);expect(d.loggerFactory).toBe(e),expect(d.loggerFactory).not.toBe(n)})}),describe("setTrustedNameDataSource",()=>{it("should set a custom trusted name data source",()=>{const n=new c(r),e={getDomainNamePayload:vi.fn(),getTrustedNamePayload:vi.fn()},o=n.setTrustedNameDataSource(e).build(),t=o._container.get(a.Config);expect(o).toBeInstanceOf(s),expect(t.customTrustedNameDataSource).toBe(e)}),it("should inject the custom data source into the container",()=>{const n=new c(r),e={getDomainNamePayload:vi.fn(),getTrustedNamePayload:vi.fn()},t=n.setTrustedNameDataSource(e).build()._container.get(l.TrustedNameDataSource);expect(t).toBe(e)}),it("should use HttpTrustedNameDataSource when no custom data source is set",()=>{const e=new c(r).build(),o=e._container.get(l.TrustedNameDataSource);expect(e).toBeInstanceOf(s),expect(o).toBeInstanceOf(g)})})});
1
+ import{configTypes as s}from"./config/di/configTypes";import{HttpProxyDataSource as g}from"./proxy/data/HttpProxyDataSource";import{HttpSafeProxyDataSource as x}from"./proxy/data/HttpSafeProxyDataSource";import{proxyTypes as u}from"./proxy/di/proxyTypes";import{HttpTrustedNameDataSource as C}from"./trusted-name/data/HttpTrustedNameDataSource";import{trustedNameTypes as f}from"./trusted-name/di/trustedNameTypes";import{ContextModuleBuilder as r}from"./ContextModuleBuilder";import{DefaultContextModule as a}from"./DefaultContextModule";describe("ContextModuleBuilder",()=>{const d={url:"https://cal/v1",mode:"prod",branch:"main"},l={url:"https://web3checks/v1"},c={originToken:"test",loggerFactory:()=>({debug:vi.fn(),info:vi.fn(),warn:vi.fn(),error:vi.fn(),subscribers:[]})};beforeEach(()=>{vi.resetAllMocks()}),it("should return a default context module",()=>{const e=new r(c).build();expect(e).toBeInstanceOf(a)}),it("should return a custom context module",()=>{const o=new r(c),e={load:vi.fn(),canHandle:vi.fn()},t=o.removeDefaultLoaders().addLoader(e).build();expect(t).toBeInstanceOf(a)}),it("should return a custom context module with a custom typed data loader",()=>{const o=new r(c),e={load:vi.fn()},t=o.removeDefaultLoaders().addTypedDataLoader(e).build();expect(t).toBeInstanceOf(a),expect(t._typedDataLoader).toBe(e)}),it("should return a custom context module with a custom config",()=>{const e=new r(c).setCalConfig(d).setWeb3ChecksConfig(l).build(),t=e._container.get(s.Config);expect(e).toBeInstanceOf(a),expect(t.cal).toEqual(d),expect(t.web3checks).toEqual(l)}),it("should not throw an error if origin token is provided",()=>{const o=new r(c);expect(()=>o.build()).not.toThrow()}),describe("setMetadataServiceConfig",()=>{it("should set the metadata service configuration",()=>{const o=new r(c),e={url:"https://custom-metadata-service.com/v3"},t=o.setMetadataServiceConfig(e).build(),n=t._container.get(s.Config);expect(t).toBeInstanceOf(a),expect(n.metadataServiceDomain).toEqual(e)}),it("should override the default metadata service configuration",()=>{const o=new r(c),e={url:"https://override-metadata-service.com/v1"},n=o.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 o=new r(c),e={url:"https://custom-cal-service.com/v2",mode:"test",branch:"next"},t=o.setCalConfig(e).build(),n=t._container.get(s.Config);expect(t).toBeInstanceOf(a),expect(n.cal).toEqual(e)}),it("should override the default CAL configuration",()=>{const o=new r(c),e={url:"https://override-cal-service.com/v1",mode:"prod",branch:"demo"},n=o.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 o=new r(c),e={url:"https://custom-web3checks-service.com/v4"},t=o.setWeb3ChecksConfig(e).build(),n=t._container.get(s.Config);expect(t).toBeInstanceOf(a),expect(n.web3checks).toEqual(e)}),it("should override the default web3 checks configuration",()=>{const o=new r(c),e={url:"https://override-web3checks-service.com/v2"},n=o.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")})}),describe("setDatasourceConfig",()=>{it("should bind HttpSafeProxyDataSource when proxy is 'safe'",()=>{const o=new r(c),e={proxy:"safe"},t=o.setDatasourceConfig(e).build(),n=t._container.get(u.ProxyDataSource);expect(t).toBeInstanceOf(a),expect(n).toBeInstanceOf(x)}),it("should bind HttpProxyDataSource when proxy is 'default'",()=>{const o=new r(c),e={proxy:"default"},t=o.setDatasourceConfig(e).build(),n=t._container.get(u.ProxyDataSource);expect(t).toBeInstanceOf(a),expect(n).toBeInstanceOf(g)}),it("should bind HttpProxyDataSource when datasource config is empty",()=>{const o=new r(c),e={},t=o.setDatasourceConfig(e).build(),n=t._container.get(u.ProxyDataSource);expect(t).toBeInstanceOf(a),expect(n).toBeInstanceOf(g)})}),describe("loggerFactory",()=>{it("should use the default empty logger when loggerFactory is not provided",()=>{const e=new r({originToken:"test"}).build(),t=e._container.get(s.ContextModuleLoggerFactory);expect(e).toBeInstanceOf(a),expect(t).toBeDefined();const n=t("test");expect(n.debug).toBeDefined(),expect(n.info).toBeDefined(),expect(n.warn).toBeDefined(),expect(n.error).toBeDefined(),expect(n.subscribers).toEqual([]),expect(()=>n.debug("test")).not.toThrow(),expect(()=>n.info("test")).not.toThrow(),expect(()=>n.warn("test")).not.toThrow(),expect(()=>n.error("test")).not.toThrow()}),it("should set the loggerFactory when provided in the constructor",()=>{const o=vi.fn(),t=new r({...c,loggerFactory:o}).build(),n=t._container.get(s.ContextModuleLoggerFactory);expect(t).toBeInstanceOf(a),expect(n).toBe(o)}),it("should set the loggerFactory via setLoggerFactory",()=>{const o=vi.fn(),t=new r(c).setLoggerFactory(o).build(),n=t._container.get(s.ContextModuleLoggerFactory);expect(t).toBeInstanceOf(a),expect(n).toBe(o)}),it("should override constructor loggerFactory with setLoggerFactory",()=>{const o=vi.fn(),e=vi.fn(),i=new r({...c,loggerFactory:o}).setLoggerFactory(e).build()._container.get(s.ContextModuleLoggerFactory);expect(i).toBe(e),expect(i).not.toBe(o)})}),describe("instance isolation",()=>{it("should not share customLoaders arrays between builder instances",()=>{const o=new r(c),e=new r(c),t={load:vi.fn(),canHandle:vi.fn()};o.addLoader(t);const n=o.removeDefaultLoaders().build(),i=e.removeDefaultLoaders().build();expect(n._loaders).toHaveLength(1),expect(i._loaders).toHaveLength(0)})}),describe("setTrustedNameDataSource",()=>{it("should inject the custom data source into the container",()=>{const o=new r(c),e={getDomainNamePayload:vi.fn(),getTrustedNamePayload:vi.fn()},n=o.setTrustedNameDataSource(e).build()._container.get(f.TrustedNameDataSource);expect(n).toBe(e)}),it("should use HttpTrustedNameDataSource when no custom data source is set",()=>{const e=new r(c).build(),t=e._container.get(f.TrustedNameDataSource);expect(e).toBeInstanceOf(a),expect(t).toBeInstanceOf(C)})})});
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 LoggerPublisherService } from \"@ledgerhq/device-management-kit\";\nimport { 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 ContextModuleDatasourceConfig,\n type ContextModuleMetadataServiceConfig,\n} from \"./config/model/ContextModuleConfig\";\nimport { type ContextLoader } from \"./shared/domain/ContextLoader\";\nimport { HttpTrustedNameDataSource } from \"./trusted-name/data/HttpTrustedNameDataSource\";\nimport { type TrustedNameDataSource } from \"./trusted-name/data/TrustedNameDataSource\";\nimport { trustedNameTypes } from \"./trusted-name/di/trustedNameTypes\";\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 mockLoggerFactory = () => ({\n debug: vi.fn(),\n info: vi.fn(),\n warn: vi.fn(),\n error: vi.fn(),\n subscribers: [],\n });\n\n const defaultBuilderArgs: ContextModuleConstructorArgs = {\n originToken: \"test\",\n loggerFactory: mockLoggerFactory,\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: ContextLoader = {\n load: vi.fn(),\n canHandle: vi.fn() as unknown as ContextLoader[\"canHandle\"],\n };\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 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 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 describe(\"setDatasourceConfig\", () => {\n it(\"should set the datasource configuration with safe proxy\", () => {\n const contextModuleBuilder = new ContextModuleBuilder(defaultBuilderArgs);\n const customDatasourceConfig: ContextModuleDatasourceConfig = {\n proxy: \"safe\",\n };\n\n const res = contextModuleBuilder\n .setDatasourceConfig(customDatasourceConfig)\n .build();\n const config = (res as DefaultContextModule)[\n \"_container\"\n ].get<ContextModuleConfig>(configTypes.Config);\n\n expect(res).toBeInstanceOf(DefaultContextModule);\n expect(config.datasource).toEqual(customDatasourceConfig);\n expect(config.datasource?.proxy).toBe(\"safe\");\n });\n\n it(\"should set the datasource configuration with default proxy\", () => {\n const contextModuleBuilder = new ContextModuleBuilder(defaultBuilderArgs);\n const customDatasourceConfig: ContextModuleDatasourceConfig = {\n proxy: \"default\",\n };\n\n const res = contextModuleBuilder\n .setDatasourceConfig(customDatasourceConfig)\n .build();\n const config = (res as DefaultContextModule)[\n \"_container\"\n ].get<ContextModuleConfig>(configTypes.Config);\n\n expect(res).toBeInstanceOf(DefaultContextModule);\n expect(config.datasource).toEqual(customDatasourceConfig);\n expect(config.datasource?.proxy).toBe(\"default\");\n });\n\n it(\"should override the default datasource configuration\", () => {\n const contextModuleBuilder = new ContextModuleBuilder(defaultBuilderArgs);\n const customDatasourceConfig: ContextModuleDatasourceConfig = {\n proxy: \"safe\",\n };\n\n const res = contextModuleBuilder\n .setDatasourceConfig(customDatasourceConfig)\n .build();\n const config = (res as DefaultContextModule)[\n \"_container\"\n ].get<ContextModuleConfig>(configTypes.Config);\n\n expect(config.datasource?.proxy).toBe(\"safe\");\n expect(config.datasource).not.toBeUndefined();\n });\n\n it(\"should set an empty datasource configuration\", () => {\n const contextModuleBuilder = new ContextModuleBuilder(defaultBuilderArgs);\n const customDatasourceConfig: ContextModuleDatasourceConfig = {};\n\n const res = contextModuleBuilder\n .setDatasourceConfig(customDatasourceConfig)\n .build();\n const config = (res as DefaultContextModule)[\n \"_container\"\n ].get<ContextModuleConfig>(configTypes.Config);\n\n expect(res).toBeInstanceOf(DefaultContextModule);\n expect(config.datasource).toEqual(customDatasourceConfig);\n expect(config.datasource?.proxy).toBeUndefined();\n });\n });\n\n describe(\"loggerFactory\", () => {\n it(\"should use the default empty logger when loggerFactory is not provided\", () => {\n const contextModuleBuilder = new ContextModuleBuilder({\n originToken: \"test\",\n });\n\n const res = contextModuleBuilder.build();\n const config = (res as DefaultContextModule)[\n \"_container\"\n ].get<ContextModuleConfig>(configTypes.Config);\n\n expect(res).toBeInstanceOf(DefaultContextModule);\n expect(config.loggerFactory).toBeDefined();\n\n // Verify the default logger has empty implementations\n const logger = config.loggerFactory(\"test\");\n expect(logger.debug).toBeDefined();\n expect(logger.info).toBeDefined();\n expect(logger.warn).toBeDefined();\n expect(logger.error).toBeDefined();\n expect(logger.subscribers).toEqual([]);\n\n // Verify the empty logger functions don't throw\n expect(() => logger.debug(\"test\")).not.toThrow();\n expect(() => logger.info(\"test\")).not.toThrow();\n expect(() => logger.warn(\"test\")).not.toThrow();\n expect(() => logger.error(\"test\")).not.toThrow();\n });\n\n it(\"should set the loggerFactory when provided in the constructor\", () => {\n const loggerFactory: (tag: string) => LoggerPublisherService = vi.fn();\n\n const contextModuleBuilder = new ContextModuleBuilder({\n ...defaultBuilderArgs,\n loggerFactory,\n });\n\n const res = contextModuleBuilder.build();\n const config = (res as DefaultContextModule)[\n \"_container\"\n ].get<ContextModuleConfig>(configTypes.Config);\n\n expect(res).toBeInstanceOf(DefaultContextModule);\n expect(config.loggerFactory).toBe(loggerFactory);\n });\n\n it(\"should set the loggerFactory via setLoggerFactory\", () => {\n const loggerFactory: (tag: string) => LoggerPublisherService = vi.fn();\n\n const contextModuleBuilder = new ContextModuleBuilder(defaultBuilderArgs);\n\n const res = contextModuleBuilder.setLoggerFactory(loggerFactory).build();\n const config = (res as DefaultContextModule)[\n \"_container\"\n ].get<ContextModuleConfig>(configTypes.Config);\n\n expect(res).toBeInstanceOf(DefaultContextModule);\n expect(config.loggerFactory).toBe(loggerFactory);\n });\n\n it(\"should override constructor loggerFactory with setLoggerFactory\", () => {\n const constructorLoggerFactory: (tag: string) => LoggerPublisherService =\n vi.fn();\n const overrideLoggerFactory: (tag: string) => LoggerPublisherService =\n vi.fn();\n\n const contextModuleBuilder = new ContextModuleBuilder({\n ...defaultBuilderArgs,\n loggerFactory: constructorLoggerFactory,\n });\n\n const res = contextModuleBuilder\n .setLoggerFactory(overrideLoggerFactory)\n .build();\n const config = (res as DefaultContextModule)[\n \"_container\"\n ].get<ContextModuleConfig>(configTypes.Config);\n\n expect(config.loggerFactory).toBe(overrideLoggerFactory);\n expect(config.loggerFactory).not.toBe(constructorLoggerFactory);\n });\n });\n\n describe(\"setTrustedNameDataSource\", () => {\n it(\"should set a custom trusted name data source\", () => {\n const contextModuleBuilder = new ContextModuleBuilder(defaultBuilderArgs);\n const customDataSource: TrustedNameDataSource = {\n getDomainNamePayload: vi.fn(),\n getTrustedNamePayload: vi.fn(),\n };\n\n const res = contextModuleBuilder\n .setTrustedNameDataSource(customDataSource)\n .build();\n const config = (res as DefaultContextModule)[\n \"_container\"\n ].get<ContextModuleConfig>(configTypes.Config);\n\n expect(res).toBeInstanceOf(DefaultContextModule);\n expect(config.customTrustedNameDataSource).toBe(customDataSource);\n });\n\n it(\"should inject the custom data source into the container\", () => {\n const contextModuleBuilder = new ContextModuleBuilder(defaultBuilderArgs);\n const customDataSource: TrustedNameDataSource = {\n getDomainNamePayload: vi.fn(),\n getTrustedNamePayload: vi.fn(),\n };\n\n const res = contextModuleBuilder\n .setTrustedNameDataSource(customDataSource)\n .build();\n const injectedDataSource = (res as DefaultContextModule)[\n \"_container\"\n ].get<TrustedNameDataSource>(trustedNameTypes.TrustedNameDataSource);\n\n expect(injectedDataSource).toBe(customDataSource);\n });\n\n it(\"should use HttpTrustedNameDataSource when no custom data source is set\", () => {\n const contextModuleBuilder = new ContextModuleBuilder(defaultBuilderArgs);\n\n const res = contextModuleBuilder.build();\n const injectedDataSource = (res as DefaultContextModule)[\n \"_container\"\n ].get<TrustedNameDataSource>(trustedNameTypes.TrustedNameDataSource);\n\n expect(res).toBeInstanceOf(DefaultContextModule);\n expect(injectedDataSource).toBeInstanceOf(HttpTrustedNameDataSource);\n });\n });\n});\n"],
5
- "mappings": "AAGA,OAAS,eAAAA,MAAmB,0BAS5B,OAAS,6BAAAC,MAAiC,gDAE1C,OAAS,oBAAAC,MAAwB,qCACjC,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,EASMC,EAAmD,CACvD,YAAa,OACb,cAVwB,KAAO,CAC/B,MAAO,GAAG,GAAG,EACb,KAAM,GAAG,GAAG,EACZ,KAAM,GAAG,GAAG,EACZ,MAAO,GAAG,GAAG,EACb,YAAa,CAAC,CAChB,EAKA,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,EAA8B,CAClC,KAAM,GAAG,GAAG,EACZ,UAAW,GAAG,GAAG,CACnB,EAEMF,EAAMC,EACT,qBAAqB,EACrB,UAAUC,CAAY,EACtB,MAAM,EAET,OAAOF,CAAG,EAAE,eAAeJ,CAAoB,CACjD,CAAC,EAED,GAAG,wEAAyE,IAAM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2BAA2B,EAAE,KAAKS,CAAgB,CAClE,CAAC,EAED,GAAG,0DAA2D,IAAM,CAClE,MAAMX,EAAuB,IAAIN,EAAqBI,CAAkB,EAClEa,EAA0C,CAC9C,qBAAsB,GAAG,GAAG,EAC5B,sBAAuB,GAAG,GAAG,CAC/B,EAKMC,EAHMZ,EACT,yBAAyBW,CAAgB,EACzC,MAAM,EAEP,WACA,IAA2BlB,EAAiB,qBAAqB,EAEnE,OAAOmB,CAAkB,EAAE,KAAKD,CAAgB,CAClD,CAAC,EAED,GAAG,yEAA0E,IAAM,CAGjF,MAAMZ,EAFuB,IAAIL,EAAqBI,CAAkB,EAEvC,MAAM,EACjCc,EAAsBb,EAC1B,WACA,IAA2BN,EAAiB,qBAAqB,EAEnE,OAAOM,CAAG,EAAE,eAAeJ,CAAoB,EAC/C,OAAOiB,CAAkB,EAAE,eAAepB,CAAyB,CACrE,CAAC,CACH,CAAC,CACH,CAAC",
6
- "names": ["configTypes", "HttpTrustedNameDataSource", "trustedNameTypes", "ContextModuleBuilder", "DefaultContextModule", "defaultCalConfig", "defaultWeb3ChecksConfig", "defaultBuilderArgs", "res", "contextModuleBuilder", "customLoader", "config", "customMetadataConfig", "customCalConfig", "customWeb3ChecksConfig", "customDatasourceConfig", "logger", "loggerFactory", "constructorLoggerFactory", "overrideLoggerFactory", "customDataSource", "injectedDataSource"]
4
+ "sourcesContent": ["import { type LoggerPublisherService } from \"@ledgerhq/device-management-kit\";\n\nimport { configTypes } from \"./config/di/configTypes\";\nimport { type ContextModuleConstructorArgs } from \"./config/model/ContextModuleBuildArgs\";\nimport {\n type ContextModuleCalConfig,\n type ContextModuleDatasourceConfig,\n type ContextModuleMetadataServiceConfig,\n type ContextModuleServiceConfig,\n} from \"./config/model/ContextModuleConfig\";\nimport { HttpProxyDataSource } from \"./proxy/data/HttpProxyDataSource\";\nimport { HttpSafeProxyDataSource } from \"./proxy/data/HttpSafeProxyDataSource\";\nimport { proxyTypes } from \"./proxy/di/proxyTypes\";\nimport { type ContextLoader } from \"./shared/domain/ContextLoader\";\nimport { HttpTrustedNameDataSource } from \"./trusted-name/data/HttpTrustedNameDataSource\";\nimport { type TrustedNameDataSource } from \"./trusted-name/data/TrustedNameDataSource\";\nimport { trustedNameTypes } from \"./trusted-name/di/trustedNameTypes\";\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 mockLoggerFactory = () => ({\n debug: vi.fn(),\n info: vi.fn(),\n warn: vi.fn(),\n error: vi.fn(),\n subscribers: [],\n });\n\n const defaultBuilderArgs: ContextModuleConstructorArgs = {\n originToken: \"test\",\n loggerFactory: mockLoggerFactory,\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: ContextLoader = {\n load: vi.fn(),\n canHandle: vi.fn() as unknown as ContextLoader[\"canHandle\"],\n };\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 const config = (res as DefaultContextModule)[\n \"_container\"\n ].get<ContextModuleServiceConfig>(configTypes.Config);\n\n expect(res).toBeInstanceOf(DefaultContextModule);\n expect(config.cal).toEqual(defaultCalConfig);\n expect(config.web3checks).toEqual(defaultWeb3ChecksConfig);\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 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<ContextModuleServiceConfig>(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<ContextModuleServiceConfig>(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<ContextModuleServiceConfig>(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<ContextModuleServiceConfig>(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<ContextModuleServiceConfig>(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<ContextModuleServiceConfig>(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 describe(\"setDatasourceConfig\", () => {\n it(\"should bind HttpSafeProxyDataSource when proxy is 'safe'\", () => {\n const contextModuleBuilder = new ContextModuleBuilder(defaultBuilderArgs);\n const customDatasourceConfig: ContextModuleDatasourceConfig = {\n proxy: \"safe\",\n };\n\n const res = contextModuleBuilder\n .setDatasourceConfig(customDatasourceConfig)\n .build();\n // @ts-expect-error _container is private\n const proxyDataSource = res[\"_container\"].get(proxyTypes.ProxyDataSource);\n\n expect(res).toBeInstanceOf(DefaultContextModule);\n expect(proxyDataSource).toBeInstanceOf(HttpSafeProxyDataSource);\n });\n\n it(\"should bind HttpProxyDataSource when proxy is 'default'\", () => {\n const contextModuleBuilder = new ContextModuleBuilder(defaultBuilderArgs);\n const customDatasourceConfig: ContextModuleDatasourceConfig = {\n proxy: \"default\",\n };\n\n const res = contextModuleBuilder\n .setDatasourceConfig(customDatasourceConfig)\n .build();\n // @ts-expect-error _container is private\n const proxyDataSource = res[\"_container\"].get(proxyTypes.ProxyDataSource);\n\n expect(res).toBeInstanceOf(DefaultContextModule);\n expect(proxyDataSource).toBeInstanceOf(HttpProxyDataSource);\n });\n\n it(\"should bind HttpProxyDataSource when datasource config is empty\", () => {\n const contextModuleBuilder = new ContextModuleBuilder(defaultBuilderArgs);\n const customDatasourceConfig: ContextModuleDatasourceConfig = {};\n\n const res = contextModuleBuilder\n .setDatasourceConfig(customDatasourceConfig)\n .build();\n // @ts-expect-error _container is private\n const proxyDataSource = res[\"_container\"].get(proxyTypes.ProxyDataSource);\n\n expect(res).toBeInstanceOf(DefaultContextModule);\n expect(proxyDataSource).toBeInstanceOf(HttpProxyDataSource);\n });\n });\n\n describe(\"loggerFactory\", () => {\n it(\"should use the default empty logger when loggerFactory is not provided\", () => {\n const contextModuleBuilder = new ContextModuleBuilder({\n originToken: \"test\",\n });\n\n const res = contextModuleBuilder.build();\n const loggerFactory = (res as DefaultContextModule)[\"_container\"].get<\n (tag: string) => LoggerPublisherService\n >(configTypes.ContextModuleLoggerFactory);\n\n expect(res).toBeInstanceOf(DefaultContextModule);\n expect(loggerFactory).toBeDefined();\n\n const logger = loggerFactory(\"test\");\n expect(logger.debug).toBeDefined();\n expect(logger.info).toBeDefined();\n expect(logger.warn).toBeDefined();\n expect(logger.error).toBeDefined();\n expect(logger.subscribers).toEqual([]);\n\n expect(() => logger.debug(\"test\")).not.toThrow();\n expect(() => logger.info(\"test\")).not.toThrow();\n expect(() => logger.warn(\"test\")).not.toThrow();\n expect(() => logger.error(\"test\")).not.toThrow();\n });\n\n it(\"should set the loggerFactory when provided in the constructor\", () => {\n const loggerFactory: (tag: string) => LoggerPublisherService = vi.fn();\n\n const contextModuleBuilder = new ContextModuleBuilder({\n ...defaultBuilderArgs,\n loggerFactory,\n });\n\n const res = contextModuleBuilder.build();\n const boundLoggerFactory = (res as DefaultContextModule)[\n \"_container\"\n ].get<(tag: string) => LoggerPublisherService>(\n configTypes.ContextModuleLoggerFactory,\n );\n\n expect(res).toBeInstanceOf(DefaultContextModule);\n expect(boundLoggerFactory).toBe(loggerFactory);\n });\n\n it(\"should set the loggerFactory via setLoggerFactory\", () => {\n const loggerFactory: (tag: string) => LoggerPublisherService = vi.fn();\n\n const contextModuleBuilder = new ContextModuleBuilder(defaultBuilderArgs);\n\n const res = contextModuleBuilder.setLoggerFactory(loggerFactory).build();\n const boundLoggerFactory = (res as DefaultContextModule)[\n \"_container\"\n ].get<(tag: string) => LoggerPublisherService>(\n configTypes.ContextModuleLoggerFactory,\n );\n\n expect(res).toBeInstanceOf(DefaultContextModule);\n expect(boundLoggerFactory).toBe(loggerFactory);\n });\n\n it(\"should override constructor loggerFactory with setLoggerFactory\", () => {\n const constructorLoggerFactory: (tag: string) => LoggerPublisherService =\n vi.fn();\n const overrideLoggerFactory: (tag: string) => LoggerPublisherService =\n vi.fn();\n\n const contextModuleBuilder = new ContextModuleBuilder({\n ...defaultBuilderArgs,\n loggerFactory: constructorLoggerFactory,\n });\n\n const res = contextModuleBuilder\n .setLoggerFactory(overrideLoggerFactory)\n .build();\n const boundLoggerFactory = (res as DefaultContextModule)[\n \"_container\"\n ].get<(tag: string) => LoggerPublisherService>(\n configTypes.ContextModuleLoggerFactory,\n );\n\n expect(boundLoggerFactory).toBe(overrideLoggerFactory);\n expect(boundLoggerFactory).not.toBe(constructorLoggerFactory);\n });\n });\n\n describe(\"instance isolation\", () => {\n it(\"should not share customLoaders arrays between builder instances\", () => {\n const builder1 = new ContextModuleBuilder(defaultBuilderArgs);\n const builder2 = new ContextModuleBuilder(defaultBuilderArgs);\n const customLoader: ContextLoader = {\n load: vi.fn(),\n canHandle: vi.fn() as unknown as ContextLoader[\"canHandle\"],\n };\n\n builder1.addLoader(customLoader);\n\n const res1 = builder1.removeDefaultLoaders().build();\n const res2 = builder2.removeDefaultLoaders().build();\n\n // @ts-expect-error _loaders is private\n expect(res1[\"_loaders\"]).toHaveLength(1);\n // @ts-expect-error _loaders is private\n expect(res2[\"_loaders\"]).toHaveLength(0);\n });\n });\n\n describe(\"setTrustedNameDataSource\", () => {\n it(\"should inject the custom data source into the container\", () => {\n const contextModuleBuilder = new ContextModuleBuilder(defaultBuilderArgs);\n const customDataSource: TrustedNameDataSource = {\n getDomainNamePayload: vi.fn(),\n getTrustedNamePayload: vi.fn(),\n };\n\n const res = contextModuleBuilder\n .setTrustedNameDataSource(customDataSource)\n .build();\n const injectedDataSource = (res as DefaultContextModule)[\n \"_container\"\n ].get<TrustedNameDataSource>(trustedNameTypes.TrustedNameDataSource);\n\n expect(injectedDataSource).toBe(customDataSource);\n });\n\n it(\"should use HttpTrustedNameDataSource when no custom data source is set\", () => {\n const contextModuleBuilder = new ContextModuleBuilder(defaultBuilderArgs);\n\n const res = contextModuleBuilder.build();\n const injectedDataSource = (res as DefaultContextModule)[\n \"_container\"\n ].get<TrustedNameDataSource>(trustedNameTypes.TrustedNameDataSource);\n\n expect(res).toBeInstanceOf(DefaultContextModule);\n expect(injectedDataSource).toBeInstanceOf(HttpTrustedNameDataSource);\n });\n });\n});\n"],
5
+ "mappings": "AAEA,OAAS,eAAAA,MAAmB,0BAQ5B,OAAS,uBAAAC,MAA2B,mCACpC,OAAS,2BAAAC,MAA+B,uCACxC,OAAS,cAAAC,MAAkB,wBAE3B,OAAS,6BAAAC,MAAiC,gDAE1C,OAAS,oBAAAC,MAAwB,qCACjC,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,EASMC,EAAmD,CACvD,YAAa,OACb,cAVwB,KAAO,CAC/B,MAAO,GAAG,GAAG,EACb,KAAM,GAAG,GAAG,EACZ,KAAM,GAAG,GAAG,EACZ,MAAO,GAAG,GAAG,EACb,YAAa,CAAC,CAChB,EAKA,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,EAA8B,CAClC,KAAM,GAAG,GAAG,EACZ,UAAW,GAAG,GAAG,CACnB,EAEMF,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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A2BN,EAAiB,qBAAqB,EAEnE,OAAOM,CAAG,EAAE,eAAeJ,CAAoB,EAC/C,OAAOuB,CAAkB,EAAE,eAAe1B,CAAyB,CACrE,CAAC,CACH,CAAC,CACH,CAAC",
6
+ "names": ["configTypes", "HttpProxyDataSource", "HttpSafeProxyDataSource", "proxyTypes", "HttpTrustedNameDataSource", "trustedNameTypes", "ContextModuleBuilder", "DefaultContextModule", "defaultCalConfig", "defaultWeb3ChecksConfig", "defaultBuilderArgs", "res", "contextModuleBuilder", "customLoader", "config", "customMetadataConfig", "customCalConfig", "customWeb3ChecksConfig", "customDatasourceConfig", "proxyDataSource", "loggerFactory", "logger", "boundLoggerFactory", "constructorLoggerFactory", "overrideLoggerFactory", "builder1", "builder2", "res1", "res2", "customDataSource", "injectedDataSource"]
7
7
  }
@@ -1,2 +1,2 @@
1
- import{Left as x}from"purify-ts";import{calldataTypes as m}from"./calldata/di/calldataTypes";import{dynamicNetworkTypes as L}from"./dynamic-network/di/dynamicNetworkTypes";import{trustedNameTypes as i}from"./trusted-name/di/trustedNameTypes";import{externalPluginTypes as y}from"./external-plugin/di/externalPluginTypes";import{gatedSigningTypes as s}from"./gated-signing/di/gatedSigningTypes";import{nftTypes as l}from"./nft/di/nftTypes";import{proxyTypes as c}from"./proxy/di/proxyTypes";import{safeTypes as f}from"./safe/di/safeTypes";import{ClearSignContextType as n}from"./shared/model/ClearSignContext";import{solanaContextTypes as u}from"./solana/di/solanaContextTypes";import{tokenTypes as p}from"./token/di/tokenTypes";import{transactionCheckTypes as C}from"./transaction-check/di/transactionCheckTypes";import{typedDataTypes as g}from"./typed-data/di/typedDataTypes";import{makeContainer as T}from"./di";class H{_container;_loaders;_typedDataLoader;_solanaLoader;_fieldLoaders;constructor(t){this._container=T({config:t}),this._loaders=t.defaultLoaders?this._getDefaultLoaders():[],this._loaders.push(...t.customLoaders),this._fieldLoaders=t.defaultFieldLoaders?this._getDefaultFieldLoaders():[],this._fieldLoaders.push(...t.customFieldLoaders),this._typedDataLoader=t.customTypedDataLoader??this._getDefaultTypedDataLoader(),this._solanaLoader=t.customSolanaLoader??this._getSolanaLoader()}_getDefaultFieldLoaders(){return[this._container.get(l.NftContextFieldLoader),this._container.get(p.TokenContextFieldLoader),this._container.get(i.TrustedNameContextFieldLoader),this._container.get(c.ProxyContextFieldLoader)]}_getDefaultLoaders(){return[this._container.get(y.ExternalPluginContextLoader),this._container.get(i.TrustedNameContextLoader),this._container.get(l.NftContextLoader),this._container.get(p.TokenContextLoader),this._container.get(m.CalldataContextLoader),this._container.get(L.DynamicNetworkContextLoader),this._container.get(f.SafeAddressLoader),this._container.get(s.GatedSigningContextLoader),this._container.get(s.GatedSigningTypedDataContextLoader),this._container.get(C.TransactionCheckContextLoader),this._container.get(C.TypedDataCheckContextLoader)]}_getDefaultTypedDataLoader(){return this._container.get(g.TypedDataContextLoader)}_getSolanaLoader(){try{return this._container.get(u.SolanaContextLoader)}catch{return{load:async t=>x(new Error("[ContextModule] - DefaultContextModule: no SolanaContextLoader bound"))}}}async getContexts(t,e){const o=Object.values(n),r=this._loaders.filter(d=>d.canHandle(t,e??o)).map(d=>d.load(t));return(await Promise.all(r)).flat()}async getFieldContext(t,e){const o=this._fieldLoaders.filter(a=>a.canHandle(t,e));if(o.length===0)return Promise.resolve({type:n.ERROR,error:new Error(`Loader not found for field: ${t} and expected type: ${e}`)});for(const a of o){const r=await a.loadField(t);if(r.type!==n.ERROR)return r}return{type:n.ERROR,error:new Error(`Loader not found for field: ${t} and expected type: ${e}`)}}async getTypedDataFilters(t){return this._typedDataLoader.load(t)}async getSolanaContext(t){return await this._solanaLoader.load(t)}}export{H as DefaultContextModule};
1
+ import{Left as m}from"purify-ts";import{accountOwnershipTypes as x}from"./account-ownership/di/accountOwnershipTypes";import{calldataTypes as L}from"./calldata/di/calldataTypes";import{dynamicNetworkTypes as g}from"./dynamic-network/di/dynamicNetworkTypes";import{reporterTypes as c}from"./reporter/di/reporterTypes";import{trustedNameTypes as d}from"./trusted-name/di/trustedNameTypes";import{externalPluginTypes as y}from"./external-plugin/di/externalPluginTypes";import{gatedSigningTypes as p}from"./gated-signing/di/gatedSigningTypes";import{nftTypes as s}from"./nft/di/nftTypes";import{proxyTypes as f}from"./proxy/di/proxyTypes";import{safeTypes as u}from"./safe/di/safeTypes";import{ClearSignContextType as a}from"./shared/model/ClearSignContext";import{solanaContextTypes as _}from"./solana/di/solanaContextTypes";import{tokenTypes as l}from"./token/di/tokenTypes";import{transactionCheckTypes as C}from"./transaction-check/di/transactionCheckTypes";import{typedDataTypes as h}from"./typed-data/di/typedDataTypes";import{makeContainer as T}from"./di";class j{_container;_loaders;_typedDataLoader;_solanaLoader;_fieldLoaders;_blindSigningReporter;constructor(e){this._container=T({config:e}),this._loaders=e.defaultLoaders?this._getDefaultLoaders():[],this._loaders.push(...e.customLoaders),this._fieldLoaders=e.defaultFieldLoaders?this._getDefaultFieldLoaders():[],this._fieldLoaders.push(...e.customFieldLoaders),this._typedDataLoader=e.customTypedDataLoader??this._getDefaultTypedDataLoader(),this._solanaLoader=e.customSolanaLoader??this._getSolanaLoader(),this._blindSigningReporter=e.customBlindSigningReporter??this._getBlindSigningReporter()}_getDefaultFieldLoaders(){return[this._container.get(s.NftContextFieldLoader),this._container.get(l.TokenContextFieldLoader),this._container.get(d.TrustedNameContextFieldLoader),this._container.get(f.ProxyContextFieldLoader)]}_getDefaultLoaders(){return[this._container.get(x.AccountOwnershipContextLoader),this._container.get(y.ExternalPluginContextLoader),this._container.get(d.TrustedNameContextLoader),this._container.get(s.NftContextLoader),this._container.get(l.TokenContextLoader),this._container.get(L.CalldataContextLoader),this._container.get(g.DynamicNetworkContextLoader),this._container.get(u.SafeAddressLoader),this._container.get(p.GatedSigningContextLoader),this._container.get(p.GatedSigningTypedDataContextLoader),this._container.get(C.TransactionCheckContextLoader),this._container.get(C.TypedDataCheckContextLoader)]}_getDefaultTypedDataLoader(){return this._container.get(h.TypedDataContextLoader)}_getBlindSigningReporter(){return this._container.get(c.BlindSigningReporter)}_getSolanaLoader(){try{return this._container.get(_.SolanaContextLoader)}catch{return{load:async e=>m(new Error("[ContextModule] - DefaultContextModule: no SolanaContextLoader bound"))}}}async getContexts(e,t){const o=Object.values(a),n=this._loaders.filter(i=>i.canHandle(e,t??o)).map(i=>i.load(e));return(await Promise.all(n)).flat()}async getFieldContext(e,t){const o=this._fieldLoaders.filter(r=>r.canHandle(e,t));if(o.length===0)return Promise.resolve({type:a.ERROR,error:new Error(`Loader not found for field: ${e} and expected type: ${t}`)});for(const r of o){const n=await r.loadField(e);if(n.type!==a.ERROR)return n}return{type:a.ERROR,error:new Error(`Loader not found for field: ${e} and expected type: ${t}`)}}async getTypedDataFilters(e){return this._typedDataLoader.load(e)}async getSolanaContext(e){return await this._solanaLoader.load(e)}async report(e){await this._blindSigningReporter.report(e)}}export{j 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\";\nimport { Left } from \"purify-ts\";\n\nimport { calldataTypes } from \"@/calldata/di/calldataTypes\";\nimport { dynamicNetworkTypes } from \"@/dynamic-network/di/dynamicNetworkTypes\";\nimport type { TypedDataClearSignContext } from \"@/shared/model/TypedDataClearSignContext\";\nimport type { TypedDataContext } from \"@/shared/model/TypedDataContext\";\nimport { trustedNameTypes } from \"@/trusted-name/di/trustedNameTypes\";\n\nimport { type ContextModuleConfig } from \"./config/model/ContextModuleConfig\";\nimport { externalPluginTypes } from \"./external-plugin/di/externalPluginTypes\";\nimport { gatedSigningTypes } from \"./gated-signing/di/gatedSigningTypes\";\nimport { nftTypes } from \"./nft/di/nftTypes\";\nimport { proxyTypes } from \"./proxy/di/proxyTypes\";\nimport { safeTypes } from \"./safe/di/safeTypes\";\nimport { type ContextFieldLoader } from \"./shared/domain/ContextFieldLoader\";\nimport { type ContextLoader } from \"./shared/domain/ContextLoader\";\nimport {\n type ClearSignContext,\n ClearSignContextType,\n} from \"./shared/model/ClearSignContext\";\nimport { type SolanaTransactionContext } from \"./shared/model/SolanaTransactionContext\";\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 { transactionCheckTypes } from \"./transaction-check/di/transactionCheckTypes\";\nimport { typedDataTypes } from \"./typed-data/di/typedDataTypes\";\nimport type { TypedDataContextLoader } from \"./typed-data/domain/TypedDataContextLoader\";\nimport { type ContextModule } from \"./ContextModule\";\nimport { makeContainer } from \"./di\";\n\nexport class DefaultContextModule implements ContextModule {\n private _container: Container;\n private _loaders: ContextLoader<unknown>[];\n private _typedDataLoader: TypedDataContextLoader;\n private _solanaLoader: SolanaContextLoader;\n private _fieldLoaders: ContextFieldLoader<unknown>[];\n\n constructor(args: ContextModuleConfig) {\n this._container = makeContainer({ config: args });\n\n this._loaders = args.defaultLoaders ? this._getDefaultLoaders() : [];\n this._loaders.push(...args.customLoaders);\n\n this._fieldLoaders = args.defaultFieldLoaders\n ? this._getDefaultFieldLoaders()\n : [];\n this._fieldLoaders.push(...args.customFieldLoaders);\n\n this._typedDataLoader =\n args.customTypedDataLoader ?? this._getDefaultTypedDataLoader();\n this._solanaLoader = args.customSolanaLoader ?? this._getSolanaLoader();\n }\n\n private _getDefaultFieldLoaders(): ContextFieldLoader[] {\n return [\n this._container.get<ContextFieldLoader>(nftTypes.NftContextFieldLoader),\n this._container.get<ContextFieldLoader>(\n tokenTypes.TokenContextFieldLoader,\n ),\n this._container.get<ContextFieldLoader>(\n trustedNameTypes.TrustedNameContextFieldLoader,\n ),\n this._container.get<ContextFieldLoader>(\n proxyTypes.ProxyContextFieldLoader,\n ),\n ];\n }\n\n private _getDefaultLoaders(): ContextLoader<unknown>[] {\n return [\n this._container.get<ContextLoader>(\n externalPluginTypes.ExternalPluginContextLoader,\n ),\n this._container.get<ContextLoader>(\n trustedNameTypes.TrustedNameContextLoader,\n ),\n this._container.get<ContextLoader>(nftTypes.NftContextLoader),\n this._container.get<ContextLoader>(tokenTypes.TokenContextLoader),\n this._container.get<ContextLoader>(calldataTypes.CalldataContextLoader),\n this._container.get<ContextLoader>(\n dynamicNetworkTypes.DynamicNetworkContextLoader,\n ),\n this._container.get<ContextLoader>(safeTypes.SafeAddressLoader),\n this._container.get<ContextLoader>(\n gatedSigningTypes.GatedSigningContextLoader,\n ),\n this._container.get<ContextLoader>(\n gatedSigningTypes.GatedSigningTypedDataContextLoader,\n ),\n this._container.get<ContextLoader>(\n transactionCheckTypes.TransactionCheckContextLoader,\n ),\n this._container.get<ContextLoader>(\n transactionCheckTypes.TypedDataCheckContextLoader,\n ),\n ];\n }\n\n private _getDefaultTypedDataLoader(): TypedDataContextLoader {\n return this._container.get<TypedDataContextLoader>(\n typedDataTypes.TypedDataContextLoader,\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 input: unknown,\n expectedTypes?: ClearSignContextType[],\n ): Promise<ClearSignContext[]> {\n const allContextTypes = Object.values(ClearSignContextType);\n const loaders = this._loaders.filter((l) =>\n l.canHandle(input, expectedTypes ?? allContextTypes),\n );\n const promises = loaders.map((fetcher) => fetcher.load(input));\n const responses = await Promise.all(promises);\n return responses.flat();\n }\n\n public async getFieldContext<TInput>(\n field: TInput,\n expectedType: ClearSignContextType,\n ): Promise<ClearSignContext> {\n const loaders = this._fieldLoaders.filter((l) =>\n l.canHandle(field, expectedType),\n );\n if (loaders.length === 0) {\n return Promise.resolve({\n type: ClearSignContextType.ERROR,\n error: new Error(\n `Loader not found for field: ${field} and expected type: ${expectedType}`,\n ),\n });\n }\n\n for (const loader of loaders) {\n const context = await loader.loadField(field);\n if (context.type !== ClearSignContextType.ERROR) {\n return context;\n }\n }\n\n return {\n type: ClearSignContextType.ERROR,\n error: new Error(\n `Loader not found for field: ${field} and expected type: ${expectedType}`,\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 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,iBAAAC,MAAqB,8BAC9B,OAAS,uBAAAC,MAA2B,2CAGpC,OAAS,oBAAAC,MAAwB,qCAGjC,OAAS,uBAAAC,MAA2B,2CACpC,OAAS,qBAAAC,MAAyB,uCAClC,OAAS,YAAAC,MAAgB,oBACzB,OAAS,cAAAC,MAAkB,wBAC3B,OAAS,aAAAC,MAAiB,sBAG1B,OAEE,wBAAAC,MACK,kCAEP,OAAS,sBAAAC,MAA0B,iCAGnC,OAAS,cAAAC,MAAkB,wBAC3B,OAAS,yBAAAC,MAA6B,+CACtC,OAAS,kBAAAC,MAAsB,iCAG/B,OAAS,iBAAAC,MAAqB,OAEvB,MAAMC,CAA8C,CACjD,WACA,SACA,iBACA,cACA,cAER,YAAYC,EAA2B,CACrC,KAAK,WAAaF,EAAc,CAAE,OAAQE,CAAK,CAAC,EAEhD,KAAK,SAAWA,EAAK,eAAiB,KAAK,mBAAmB,EAAI,CAAC,EACnE,KAAK,SAAS,KAAK,GAAGA,EAAK,aAAa,EAExC,KAAK,cAAgBA,EAAK,oBACtB,KAAK,wBAAwB,EAC7B,CAAC,EACL,KAAK,cAAc,KAAK,GAAGA,EAAK,kBAAkB,EAElD,KAAK,iBACHA,EAAK,uBAAyB,KAAK,2BAA2B,EAChE,KAAK,cAAg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AU,KAAK,cAAc,OAAQJ,GACzCA,EAAE,UAAUE,EAAOC,CAAY,CACjC,EACA,GAAIC,EAAQ,SAAW,EACrB,OAAO,QAAQ,QAAQ,CACrB,KAAMjB,EAAqB,MAC3B,MAAO,IAAI,MACT,+BAA+Be,CAAK,uBAAuBC,CAAY,EACzE,CACF,CAAC,EAGH,UAAWE,KAAUD,EAAS,CAC5B,MAAME,EAAU,MAAMD,EAAO,UAAUH,CAAK,EAC5C,GAAII,EAAQ,OAASnB,EAAqB,MACxC,OAAOmB,CAEX,CAEA,MAAO,CACL,KAAMnB,EAAqB,MAC3B,MAAO,IAAI,MACT,+BAA+Be,CAAK,uBAAuBC,CAAY,EACzE,CACF,CACF,CAEA,MAAa,oBACXI,EACoC,CACpC,OAAO,KAAK,iBAAiB,KAAKA,CAAS,CAC7C,CAEA,MAAa,iBACXC,EACyC,CACzC,OAAO,MAAM,KAAK,cAAc,KAAKA,CAAkB,CACzD,CACF",
6
- "names": ["Left", "calldataTypes", "dynamicNetworkTypes", "trustedNameTypes", "externalPluginTypes", "gatedSigningTypes", "nftTypes", "proxyTypes", "safeTypes", "ClearSignContextType", "solanaContextTypes", "tokenTypes", "transactionCheckTypes", "typedDataTypes", "makeContainer", "DefaultContextModule", "args", "_ctx", "input", "expectedTypes", "allContextTypes", "promises", "l", "fetcher", "field", "expectedType", "loaders", "loader", "context", "typedData", "transactionContext"]
4
+ "sourcesContent": ["import { type Container } from \"inversify\";\nimport { Left } from \"purify-ts\";\n\nimport { accountOwnershipTypes } from \"@/account-ownership/di/accountOwnershipTypes\";\nimport { calldataTypes } from \"@/calldata/di/calldataTypes\";\nimport { dynamicNetworkTypes } from \"@/dynamic-network/di/dynamicNetworkTypes\";\nimport { type BlindSigningReportParams } from \"@/reporter/data/BlindSigningReporterDatasource\";\nimport { reporterTypes } from \"@/reporter/di/reporterTypes\";\nimport { type BlindSigningReporter } from \"@/reporter/domain/BlindSigningReporter\";\nimport type { TypedDataClearSignContext } from \"@/shared/model/TypedDataClearSignContext\";\nimport type { TypedDataContext } from \"@/shared/model/TypedDataContext\";\nimport { trustedNameTypes } from \"@/trusted-name/di/trustedNameTypes\";\n\nimport {\n type ContextModuleLoaderConfig,\n type ContextModuleServiceConfig,\n} from \"./config/model/ContextModuleConfig\";\nimport { externalPluginTypes } from \"./external-plugin/di/externalPluginTypes\";\nimport { gatedSigningTypes } from \"./gated-signing/di/gatedSigningTypes\";\nimport { nftTypes } from \"./nft/di/nftTypes\";\nimport { proxyTypes } from \"./proxy/di/proxyTypes\";\nimport { safeTypes } from \"./safe/di/safeTypes\";\nimport { type ContextFieldLoader } from \"./shared/domain/ContextFieldLoader\";\nimport { type ContextLoader } from \"./shared/domain/ContextLoader\";\nimport {\n type ClearSignContext,\n ClearSignContextType,\n} from \"./shared/model/ClearSignContext\";\nimport { type SolanaTransactionContext } from \"./shared/model/SolanaTransactionContext\";\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 { transactionCheckTypes } from \"./transaction-check/di/transactionCheckTypes\";\nimport { typedDataTypes } from \"./typed-data/di/typedDataTypes\";\nimport type { TypedDataContextLoader } from \"./typed-data/domain/TypedDataContextLoader\";\nimport { type ContextModule } from \"./ContextModule\";\nimport { makeContainer } from \"./di\";\n\nexport class DefaultContextModule implements ContextModule {\n private _container: Container;\n private _loaders: ContextLoader<unknown>[];\n private _typedDataLoader: TypedDataContextLoader;\n private _solanaLoader: SolanaContextLoader;\n private _fieldLoaders: ContextFieldLoader<unknown>[];\n private _blindSigningReporter: BlindSigningReporter;\n\n constructor(args: ContextModuleServiceConfig & ContextModuleLoaderConfig) {\n this._container = makeContainer({ config: args });\n\n this._loaders = args.defaultLoaders ? this._getDefaultLoaders() : [];\n this._loaders.push(...args.customLoaders);\n\n this._fieldLoaders = args.defaultFieldLoaders\n ? this._getDefaultFieldLoaders()\n : [];\n this._fieldLoaders.push(...args.customFieldLoaders);\n\n this._typedDataLoader =\n args.customTypedDataLoader ?? this._getDefaultTypedDataLoader();\n this._solanaLoader = args.customSolanaLoader ?? this._getSolanaLoader();\n this._blindSigningReporter =\n args.customBlindSigningReporter ?? this._getBlindSigningReporter();\n }\n\n private _getDefaultFieldLoaders(): ContextFieldLoader[] {\n return [\n this._container.get<ContextFieldLoader>(nftTypes.NftContextFieldLoader),\n this._container.get<ContextFieldLoader>(\n tokenTypes.TokenContextFieldLoader,\n ),\n this._container.get<ContextFieldLoader>(\n trustedNameTypes.TrustedNameContextFieldLoader,\n ),\n this._container.get<ContextFieldLoader>(\n proxyTypes.ProxyContextFieldLoader,\n ),\n ];\n }\n\n private _getDefaultLoaders(): ContextLoader<unknown>[] {\n return [\n this._container.get<ContextLoader>(\n accountOwnershipTypes.AccountOwnershipContextLoader,\n ),\n this._container.get<ContextLoader>(\n externalPluginTypes.ExternalPluginContextLoader,\n ),\n this._container.get<ContextLoader>(\n trustedNameTypes.TrustedNameContextLoader,\n ),\n this._container.get<ContextLoader>(nftTypes.NftContextLoader),\n this._container.get<ContextLoader>(tokenTypes.TokenContextLoader),\n this._container.get<ContextLoader>(calldataTypes.CalldataContextLoader),\n this._container.get<ContextLoader>(\n dynamicNetworkTypes.DynamicNetworkContextLoader,\n ),\n this._container.get<ContextLoader>(safeTypes.SafeAddressLoader),\n this._container.get<ContextLoader>(\n gatedSigningTypes.GatedSigningContextLoader,\n ),\n this._container.get<ContextLoader>(\n gatedSigningTypes.GatedSigningTypedDataContextLoader,\n ),\n this._container.get<ContextLoader>(\n transactionCheckTypes.TransactionCheckContextLoader,\n ),\n this._container.get<ContextLoader>(\n transactionCheckTypes.TypedDataCheckContextLoader,\n ),\n ];\n }\n\n private _getDefaultTypedDataLoader(): TypedDataContextLoader {\n return this._container.get<TypedDataContextLoader>(\n typedDataTypes.TypedDataContextLoader,\n );\n }\n\n private _getBlindSigningReporter(): BlindSigningReporter {\n return this._container.get<BlindSigningReporter>(\n reporterTypes.BlindSigningReporter,\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 input: unknown,\n expectedTypes?: ClearSignContextType[],\n ): Promise<ClearSignContext[]> {\n const allContextTypes = Object.values(ClearSignContextType);\n const loaders = this._loaders.filter((l) =>\n l.canHandle(input, expectedTypes ?? allContextTypes),\n );\n const promises = loaders.map((fetcher) => fetcher.load(input));\n const responses = await Promise.all(promises);\n return responses.flat();\n }\n\n public async getFieldContext<TInput>(\n field: TInput,\n expectedType: ClearSignContextType,\n ): Promise<ClearSignContext> {\n const loaders = this._fieldLoaders.filter((l) =>\n l.canHandle(field, expectedType),\n );\n if (loaders.length === 0) {\n return Promise.resolve({\n type: ClearSignContextType.ERROR,\n error: new Error(\n `Loader not found for field: ${field} and expected type: ${expectedType}`,\n ),\n });\n }\n\n for (const loader of loaders) {\n const context = await loader.loadField(field);\n if (context.type !== ClearSignContextType.ERROR) {\n return context;\n }\n }\n\n return {\n type: ClearSignContextType.ERROR,\n error: new Error(\n `Loader not found for field: ${field} and expected type: ${expectedType}`,\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 getSolanaContext(\n transactionContext: SolanaTransactionContext,\n ): Promise<SolanaTransactionContextResult> {\n return await this._solanaLoader.load(transactionContext);\n }\n\n public async report(params: BlindSigningReportParams): Promise<void> {\n await this._blindSigningReporter.report(params);\n }\n}\n"],
5
+ "mappings": "AACA,OAAS,QAAAA,MAAY,YAErB,OAAS,yBAAAC,MAA6B,+CACtC,OAAS,iBAAAC,MAA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AUH,CAAK,EAC5C,GAAII,EAAQ,OAASnB,EAAqB,MACxC,OAAOmB,CAEX,CAEA,MAAO,CACL,KAAMnB,EAAqB,MAC3B,MAAO,IAAI,MACT,+BAA+Be,CAAK,uBAAuBC,CAAY,EACzE,CACF,CACF,CAEA,MAAa,oBACXI,EACoC,CACpC,OAAO,KAAK,iBAAiB,KAAKA,CAAS,CAC7C,CAEA,MAAa,iBACXC,EACyC,CACzC,OAAO,MAAM,KAAK,cAAc,KAAKA,CAAkB,CACzD,CAEA,MAAa,OAAOC,EAAiD,CACnE,MAAM,KAAK,sBAAsB,OAAOA,CAAM,CAChD,CACF",
6
+ "names": ["Left", "accountOwnershipTypes", "calldataTypes", "dynamicNetworkTypes", "reporterTypes", "trustedNameTypes", "externalPluginTypes", "gatedSigningTypes", "nftTypes", "proxyTypes", "safeTypes", "ClearSignContextType", "solanaContextTypes", "tokenTypes", "transactionCheckTypes", "typedDataTypes", "makeContainer", "DefaultContextModule", "args", "_ctx", "input", "expectedTypes", "allContextTypes", "promises", "l", "fetcher", "field", "expectedType", "loaders", "loader", "context", "typedData", "transactionContext", "params"]
7
7
  }
@@ -1,2 +1,2 @@
1
- import{ClearSignContextType as o}from"./shared/model/ClearSignContext";import{DefaultContextModule as d}from"./DefaultContextModule";const x=()=>({debug:vi.fn(),info:vi.fn(),warn:vi.fn(),error:vi.fn(),subscribers:[]}),u=i=>({load:vi.fn(),canHandle:vi.fn().mockReturnValue(i)}),r=()=>({canHandle:vi.fn(),loadField:vi.fn()});describe("DefaultContextModule",()=>{const i={load:vi.fn()},l={customLoaders:[],defaultLoaders:!1,defaultFieldLoaders:!1,customFieldLoaders:[],customTypedDataLoader:i,cal:{url:"https://cal/v1",mode:"prod",branch:"main"},web3checks:{url:"https://web3checks/v3"},metadataServiceDomain:{url:"https://metadata.com"},originToken:"originToken",loggerFactory:x};beforeEach(()=>{vi.restoreAllMocks()}),it("should initialize the context module with all the default loaders",async()=>{const t=await new d(l).getContexts({});expect(t).toEqual([])}),it("should return an empty array when no loaders",async()=>{const t=await new d(l).getContexts({});expect(t).toEqual([])}),it("should call all fetch method from metadata fetcher",async()=>{const e=u(!0);await new d({...l,customLoaders:[e,e]}).getContexts({}),expect(e.canHandle).toHaveBeenCalledTimes(2),expect(e.load).toHaveBeenCalledTimes(2)}),it("should return an array of context response",async()=>{const e=u(!0),t=[[{type:"provideERC20Info",payload:"payload1"}],[{type:"provideERC20Info",payload:"payload2"},{type:"plugin",payload:"payload3"}]];vi.spyOn(e,"load").mockResolvedValueOnce(t[0]).mockResolvedValueOnce(t[1]);const a=await new d({...l,customLoaders:[e,e]}).getContexts({});expect(e.canHandle).toHaveBeenCalledTimes(2),expect(e.load).toHaveBeenCalledTimes(2),expect(a).toEqual(t.flat())}),it("should only call loaders that can handle the input",async()=>{const e=u(!0),t=u(!0);vi.spyOn(e,"canHandle").mockReturnValue(!0),vi.spyOn(t,"canHandle").mockReturnValue(!1),vi.spyOn(e,"load").mockResolvedValue([{type:o.TOKEN,payload:"payload1"}]),vi.spyOn(t,"load").mockResolvedValue([{type:o.NFT,payload:"payload2"}]);const n=new d({...l,customLoaders:[e,t]}),a={to:"0x123",selector:"0xabc"},s=await n.getContexts(a);expect(e.canHandle).toHaveBeenCalledWith(a,Object.values(o)),expect(t.canHandle).toHaveBeenCalledWith(a,Object.values(o)),expect(e.load).toHaveBeenCalledWith(a),expect(t.load).not.toHaveBeenCalled(),expect(s).toEqual([{type:"token",payload:"payload1"}])}),it("should use expected types if provided",async()=>{const e=u(!0);vi.spyOn(e,"canHandle").mockReturnValue(!0),vi.spyOn(e,"load").mockResolvedValue([{type:o.TOKEN,payload:"payload1"}]);const t=new d({...l,customLoaders:[e]}),n={to:"0x123",selector:"0xabc"};await t.getContexts(n,[o.TOKEN]),expect(e.canHandle).toHaveBeenCalledWith(n,[o.TOKEN])}),it("should call the typed data loader",async()=>{await new d({...l,customTypedDataLoader:i}).getTypedDataFilters({}),expect(i.load).toHaveBeenCalledTimes(1)}),describe("getFieldContext",()=>{it("should return error when no loader can handle the field",async()=>{const e=r();vi.spyOn(e,"canHandle").mockReturnValue(!1);const t=new d({...l,customFieldLoaders:[e]}),n={type:"unknown"},a=await t.getFieldContext(n,o.TOKEN);expect(e.canHandle).toHaveBeenCalledWith(n,o.TOKEN),expect(e.loadField).not.toHaveBeenCalled(),expect(a).toEqual({type:o.ERROR,error:new Error(`Loader not found for field: ${n} and expected type: ${o.TOKEN}`)})}),it("should return context when a loader can handle the field",async()=>{const e=r(),t={type:o.TOKEN,payload:"test-payload"};vi.spyOn(e,"canHandle").mockReturnValue(!0),vi.spyOn(e,"loadField").mockResolvedValue(t);const n=new d({...l,customFieldLoaders:[e]}),a={type:"token",address:"0x123"},s=await n.getFieldContext(a,o.TOKEN);expect(e.canHandle).toHaveBeenCalledWith(a,o.TOKEN),expect(e.loadField).toHaveBeenCalledWith(a),expect(s).toEqual(t)}),it("should return first context when multiple loaders can handle the field",async()=>{const e=r(),t=r(),n={type:o.TOKEN,payload:"first-payload"},a={type:o.NFT,payload:"second-payload"};vi.spyOn(e,"canHandle").mockReturnValue(!0),vi.spyOn(t,"canHandle").mockReturnValue(!0),vi.spyOn(e,"loadField").mockResolvedValue(n),vi.spyOn(t,"loadField").mockResolvedValue(a);const s=new d({...l,customFieldLoaders:[e,t]}),c={type:"multi",address:"0x123"},p=await s.getFieldContext(c,o.TOKEN);expect(e.canHandle).toHaveBeenCalledWith(c,o.TOKEN),expect(t.canHandle).toHaveBeenCalledWith(c,o.TOKEN),expect(e.loadField).toHaveBeenCalledWith(c),expect(t.loadField).not.toHaveBeenCalled(),expect(p).toEqual(n)}),it("should return second context when first context is an error",async()=>{const e=r(),t=r(),n={type:o.ERROR,error:new Error("first-error")},a={type:o.TOKEN,payload:"second-payload"};vi.spyOn(e,"canHandle").mockReturnValue(!0),vi.spyOn(t,"canHandle").mockReturnValue(!0),vi.spyOn(e,"loadField").mockResolvedValue(n),vi.spyOn(t,"loadField").mockResolvedValue(a);const s=new d({...l,customFieldLoaders:[e,t]}),c={type:"error",address:"0x123"},p=await s.getFieldContext(c,o.TOKEN);expect(e.canHandle).toHaveBeenCalledWith(c,o.TOKEN),expect(t.canHandle).toHaveBeenCalledWith(c,o.TOKEN),expect(e.loadField).toHaveBeenCalledWith(c),expect(t.loadField).toHaveBeenCalledWith(c),expect(p).toEqual(a)}),it("should handle loader rejection gracefully",async()=>{const e=r(),t=new Error("Load field failed");vi.spyOn(e,"canHandle").mockReturnValue(!0),vi.spyOn(e,"loadField").mockRejectedValue(t);const n=new d({...l,customFieldLoaders:[e]}),a={type:"error",address:"0x123"};await expect(n.getFieldContext(a,o.TOKEN)).rejects.toThrow("Load field failed"),expect(e.canHandle).toHaveBeenCalledWith(a,o.TOKEN),expect(e.loadField).toHaveBeenCalledWith(a)})})});
1
+ import{ClearSignContextType as o}from"./shared/model/ClearSignContext";import{DefaultContextModule as d}from"./DefaultContextModule";const x=()=>({debug:vi.fn(),info:vi.fn(),warn:vi.fn(),error:vi.fn(),subscribers:[]}),u=i=>({load:vi.fn(),canHandle:vi.fn().mockReturnValue(i)}),s=()=>({canHandle:vi.fn(),loadField:vi.fn()});describe("DefaultContextModule",()=>{const i={load:vi.fn()},l={customLoaders:[],defaultLoaders:!1,defaultFieldLoaders:!1,customFieldLoaders:[],customTypedDataLoader:i,cal:{url:"https://cal/v1",mode:"prod",branch:"main"},web3checks:{url:"https://web3checks/v3"},metadataServiceDomain:{url:"https://metadata.com"},reporter:{url:"https://reporter.com"},datasource:{proxy:"default"},appSource:"third-party",originToken:"originToken",loggerFactory:x};beforeEach(()=>{vi.restoreAllMocks()}),it("should initialize the context module with all the default loaders",async()=>{const t=await new d(l).getContexts({});expect(t).toEqual([])}),it("should return an empty array when no loaders",async()=>{const t=await new d(l).getContexts({});expect(t).toEqual([])}),it("should call all fetch method from metadata fetcher",async()=>{const e=u(!0);await new d({...l,customLoaders:[e,e]}).getContexts({}),expect(e.canHandle).toHaveBeenCalledTimes(2),expect(e.load).toHaveBeenCalledTimes(2)}),it("should return an array of context response",async()=>{const e=u(!0),t=[[{type:"provideERC20Info",payload:"payload1"}],[{type:"provideERC20Info",payload:"payload2"},{type:"plugin",payload:"payload3"}]];vi.spyOn(e,"load").mockResolvedValueOnce(t[0]).mockResolvedValueOnce(t[1]);const a=await new d({...l,customLoaders:[e,e]}).getContexts({});expect(e.canHandle).toHaveBeenCalledTimes(2),expect(e.load).toHaveBeenCalledTimes(2),expect(a).toEqual(t.flat())}),it("should only call loaders that can handle the input",async()=>{const e=u(!0),t=u(!0);vi.spyOn(e,"canHandle").mockReturnValue(!0),vi.spyOn(t,"canHandle").mockReturnValue(!1),vi.spyOn(e,"load").mockResolvedValue([{type:o.TOKEN,payload:"payload1"}]),vi.spyOn(t,"load").mockResolvedValue([{type:o.NFT,payload:"payload2"}]);const n=new d({...l,customLoaders:[e,t]}),a={to:"0x123",selector:"0xabc"},r=await n.getContexts(a);expect(e.canHandle).toHaveBeenCalledWith(a,Object.values(o)),expect(t.canHandle).toHaveBeenCalledWith(a,Object.values(o)),expect(e.load).toHaveBeenCalledWith(a),expect(t.load).not.toHaveBeenCalled(),expect(r).toEqual([{type:"token",payload:"payload1"}])}),it("should use expected types if provided",async()=>{const e=u(!0);vi.spyOn(e,"canHandle").mockReturnValue(!0),vi.spyOn(e,"load").mockResolvedValue([{type:o.TOKEN,payload:"payload1"}]);const t=new d({...l,customLoaders:[e]}),n={to:"0x123",selector:"0xabc"};await t.getContexts(n,[o.TOKEN]),expect(e.canHandle).toHaveBeenCalledWith(n,[o.TOKEN])}),it("should call the typed data loader",async()=>{await new d({...l,customTypedDataLoader:i}).getTypedDataFilters({}),expect(i.load).toHaveBeenCalledTimes(1)}),describe("getFieldContext",()=>{it("should return error when no loader can handle the field",async()=>{const e=s();vi.spyOn(e,"canHandle").mockReturnValue(!1);const t=new d({...l,customFieldLoaders:[e]}),n={type:"unknown"},a=await t.getFieldContext(n,o.TOKEN);expect(e.canHandle).toHaveBeenCalledWith(n,o.TOKEN),expect(e.loadField).not.toHaveBeenCalled(),expect(a).toEqual({type:o.ERROR,error:new Error(`Loader not found for field: ${n} and expected type: ${o.TOKEN}`)})}),it("should return context when a loader can handle the field",async()=>{const e=s(),t={type:o.TOKEN,payload:"test-payload"};vi.spyOn(e,"canHandle").mockReturnValue(!0),vi.spyOn(e,"loadField").mockResolvedValue(t);const n=new d({...l,customFieldLoaders:[e]}),a={type:"token",address:"0x123"},r=await n.getFieldContext(a,o.TOKEN);expect(e.canHandle).toHaveBeenCalledWith(a,o.TOKEN),expect(e.loadField).toHaveBeenCalledWith(a),expect(r).toEqual(t)}),it("should return first context when multiple loaders can handle the field",async()=>{const e=s(),t=s(),n={type:o.TOKEN,payload:"first-payload"},a={type:o.NFT,payload:"second-payload"};vi.spyOn(e,"canHandle").mockReturnValue(!0),vi.spyOn(t,"canHandle").mockReturnValue(!0),vi.spyOn(e,"loadField").mockResolvedValue(n),vi.spyOn(t,"loadField").mockResolvedValue(a);const r=new d({...l,customFieldLoaders:[e,t]}),c={type:"multi",address:"0x123"},p=await r.getFieldContext(c,o.TOKEN);expect(e.canHandle).toHaveBeenCalledWith(c,o.TOKEN),expect(t.canHandle).toHaveBeenCalledWith(c,o.TOKEN),expect(e.loadField).toHaveBeenCalledWith(c),expect(t.loadField).not.toHaveBeenCalled(),expect(p).toEqual(n)}),it("should return second context when first context is an error",async()=>{const e=s(),t=s(),n={type:o.ERROR,error:new Error("first-error")},a={type:o.TOKEN,payload:"second-payload"};vi.spyOn(e,"canHandle").mockReturnValue(!0),vi.spyOn(t,"canHandle").mockReturnValue(!0),vi.spyOn(e,"loadField").mockResolvedValue(n),vi.spyOn(t,"loadField").mockResolvedValue(a);const r=new d({...l,customFieldLoaders:[e,t]}),c={type:"error",address:"0x123"},p=await r.getFieldContext(c,o.TOKEN);expect(e.canHandle).toHaveBeenCalledWith(c,o.TOKEN),expect(t.canHandle).toHaveBeenCalledWith(c,o.TOKEN),expect(e.loadField).toHaveBeenCalledWith(c),expect(t.loadField).toHaveBeenCalledWith(c),expect(p).toEqual(a)}),it("should handle loader rejection gracefully",async()=>{const e=s(),t=new Error("Load field failed");vi.spyOn(e,"canHandle").mockReturnValue(!0),vi.spyOn(e,"loadField").mockRejectedValue(t);const n=new d({...l,customFieldLoaders:[e]}),a={type:"error",address:"0x123"};await expect(n.getFieldContext(a,o.TOKEN)).rejects.toThrow("Load field failed"),expect(e.canHandle).toHaveBeenCalledWith(a,o.TOKEN),expect(e.loadField).toHaveBeenCalledWith(a)})})});
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 { type ContextModuleConfig } from \"./config/model/ContextModuleConfig\";\nimport { type ContextFieldLoader } from \"./shared/domain/ContextFieldLoader\";\nimport { type ContextLoader } from \"./shared/domain/ContextLoader\";\nimport {\n type ClearSignContext,\n ClearSignContextType,\n} from \"./shared/model/ClearSignContext\";\nimport { type TypedDataContext } from \"./shared/model/TypedDataContext\";\nimport type { TypedDataContextLoader } from \"./typed-data/domain/TypedDataContextLoader\";\nimport { DefaultContextModule } from \"./DefaultContextModule\";\n\nconst mockLoggerFactory = () => ({\n debug: vi.fn(),\n info: vi.fn(),\n warn: vi.fn(),\n error: vi.fn(),\n subscribers: [],\n});\n\nconst contextLoaderStubBuilder = (canHandle: boolean): ContextLoader => {\n return {\n load: vi.fn(),\n canHandle: vi\n .fn()\n .mockReturnValue(canHandle) as unknown as ContextLoader[\"canHandle\"],\n };\n};\n\nconst fieldLoaderStubBuilder = (): ContextFieldLoader => {\n return {\n canHandle: vi.fn() as unknown as ContextFieldLoader[\"canHandle\"],\n loadField: vi.fn(),\n };\n};\n\ndescribe(\"DefaultContextModule\", () => {\n const typedDataLoader: TypedDataContextLoader = { load: vi.fn() };\n const defaultContextModuleConfig: ContextModuleConfig = {\n customLoaders: [],\n defaultLoaders: false,\n defaultFieldLoaders: false,\n customFieldLoaders: [],\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 loggerFactory: mockLoggerFactory,\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({});\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({});\n\n expect(res).toEqual([]);\n });\n\n it(\"should call all fetch method from metadata fetcher\", async () => {\n const loader = contextLoaderStubBuilder(true);\n const contextModule = new DefaultContextModule({\n ...defaultContextModuleConfig,\n customLoaders: [loader, loader],\n });\n\n await contextModule.getContexts({});\n\n expect(loader.canHandle).toHaveBeenCalledTimes(2);\n expect(loader.load).toHaveBeenCalledTimes(2);\n });\n\n it(\"should return an array of context response\", async () => {\n const loader = contextLoaderStubBuilder(true);\n const responses = [\n [{ type: \"provideERC20Info\", payload: \"payload1\" }],\n [\n { type: \"provideERC20Info\", payload: \"payload2\" },\n { type: \"plugin\", payload: \"payload3\" },\n ],\n ] as ClearSignContext[][];\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({});\n\n expect(loader.canHandle).toHaveBeenCalledTimes(2);\n expect(loader.load).toHaveBeenCalledTimes(2);\n expect(res).toEqual(responses.flat());\n });\n\n it(\"should only call loaders that can handle the input\", async () => {\n const loader1 = contextLoaderStubBuilder(true);\n const loader2 = contextLoaderStubBuilder(true);\n\n vi.spyOn(loader1, \"canHandle\").mockReturnValue(true);\n vi.spyOn(loader2, \"canHandle\").mockReturnValue(false);\n vi.spyOn(loader1, \"load\").mockResolvedValue([\n { type: ClearSignContextType.TOKEN, payload: \"payload1\" },\n ]);\n vi.spyOn(loader2, \"load\").mockResolvedValue([\n { type: ClearSignContextType.NFT, payload: \"payload2\" },\n ]);\n\n const contextModule = new DefaultContextModule({\n ...defaultContextModuleConfig,\n customLoaders: [loader1, loader2],\n });\n\n const testInput = { to: \"0x123\", selector: \"0xabc\" };\n const res = await contextModule.getContexts(testInput);\n\n expect(loader1.canHandle).toHaveBeenCalledWith(\n testInput,\n Object.values(ClearSignContextType),\n );\n expect(loader2.canHandle).toHaveBeenCalledWith(\n testInput,\n Object.values(ClearSignContextType),\n );\n expect(loader1.load).toHaveBeenCalledWith(testInput);\n expect(loader2.load).not.toHaveBeenCalled(); // Should not be called since canHandle returned false\n expect(res).toEqual([{ type: \"token\", payload: \"payload1\" }]);\n });\n\n it(\"should use expected types if provided\", async () => {\n const loader = contextLoaderStubBuilder(true);\n\n vi.spyOn(loader, \"canHandle\").mockReturnValue(true);\n\n vi.spyOn(loader, \"load\").mockResolvedValue([\n { type: ClearSignContextType.TOKEN, payload: \"payload1\" },\n ]);\n\n const contextModule = new DefaultContextModule({\n ...defaultContextModuleConfig,\n customLoaders: [loader],\n });\n\n const testInput = { to: \"0x123\", selector: \"0xabc\" };\n await contextModule.getContexts(testInput, [ClearSignContextType.TOKEN]);\n\n expect(loader.canHandle).toHaveBeenCalledWith(testInput, [\n ClearSignContextType.TOKEN,\n ]);\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 describe(\"getFieldContext\", () => {\n it(\"should return error when no loader can handle the field\", async () => {\n // GIVEN\n const fieldLoader = fieldLoaderStubBuilder();\n vi.spyOn(fieldLoader, \"canHandle\").mockReturnValue(false);\n\n const contextModule = new DefaultContextModule({\n ...defaultContextModuleConfig,\n customFieldLoaders: [fieldLoader],\n });\n\n const testField = { type: \"unknown\" };\n\n // WHEN\n const result = await contextModule.getFieldContext(\n testField,\n ClearSignContextType.TOKEN,\n );\n\n // THEN\n expect(fieldLoader.canHandle).toHaveBeenCalledWith(\n testField,\n ClearSignContextType.TOKEN,\n );\n expect(fieldLoader.loadField).not.toHaveBeenCalled();\n expect(result).toEqual({\n type: ClearSignContextType.ERROR,\n error: new Error(\n `Loader not found for field: ${testField} and expected type: ${ClearSignContextType.TOKEN}`,\n ),\n });\n });\n\n it(\"should return context when a loader can handle the field\", async () => {\n // GIVEN\n const fieldLoader = fieldLoaderStubBuilder();\n const mockContext: ClearSignContext = {\n type: ClearSignContextType.TOKEN,\n payload: \"test-payload\",\n };\n\n vi.spyOn(fieldLoader, \"canHandle\").mockReturnValue(true);\n vi.spyOn(fieldLoader, \"loadField\").mockResolvedValue(mockContext);\n\n const contextModule = new DefaultContextModule({\n ...defaultContextModuleConfig,\n customFieldLoaders: [fieldLoader],\n });\n\n const testField = { type: \"token\", address: \"0x123\" };\n\n // WHEN\n const result = await contextModule.getFieldContext(\n testField,\n ClearSignContextType.TOKEN,\n );\n\n // THEN\n expect(fieldLoader.canHandle).toHaveBeenCalledWith(\n testField,\n ClearSignContextType.TOKEN,\n );\n expect(fieldLoader.loadField).toHaveBeenCalledWith(testField);\n expect(result).toEqual(mockContext);\n });\n\n it(\"should return first context when multiple loaders can handle the field\", async () => {\n // GIVEN\n const fieldLoader1 = fieldLoaderStubBuilder();\n const fieldLoader2 = fieldLoaderStubBuilder();\n\n const mockContext1: ClearSignContext = {\n type: ClearSignContextType.TOKEN,\n payload: \"first-payload\",\n };\n const mockContext2: ClearSignContext = {\n type: ClearSignContextType.NFT,\n payload: \"second-payload\",\n };\n\n vi.spyOn(fieldLoader1, \"canHandle\").mockReturnValue(true);\n vi.spyOn(fieldLoader2, \"canHandle\").mockReturnValue(true);\n vi.spyOn(fieldLoader1, \"loadField\").mockResolvedValue(mockContext1);\n vi.spyOn(fieldLoader2, \"loadField\").mockResolvedValue(mockContext2);\n\n const contextModule = new DefaultContextModule({\n ...defaultContextModuleConfig,\n customFieldLoaders: [fieldLoader1, fieldLoader2],\n });\n\n const testField = { type: \"multi\", address: \"0x123\" };\n\n // WHEN\n const result = await contextModule.getFieldContext(\n testField,\n ClearSignContextType.TOKEN,\n );\n\n // THEN\n expect(fieldLoader1.canHandle).toHaveBeenCalledWith(\n testField,\n ClearSignContextType.TOKEN,\n );\n expect(fieldLoader2.canHandle).toHaveBeenCalledWith(\n testField,\n ClearSignContextType.TOKEN,\n );\n expect(fieldLoader1.loadField).toHaveBeenCalledWith(testField);\n expect(fieldLoader2.loadField).not.toHaveBeenCalled();\n expect(result).toEqual(mockContext1); // Should return first context\n });\n\n it(\"should return second context when first context is an error\", async () => {\n // GIVEN\n const fieldLoader1 = fieldLoaderStubBuilder();\n const fieldLoader2 = fieldLoaderStubBuilder();\n const mockContext1: ClearSignContext = {\n type: ClearSignContextType.ERROR,\n error: new Error(\"first-error\"),\n };\n const mockContext2: ClearSignContext = {\n type: ClearSignContextType.TOKEN,\n payload: \"second-payload\",\n };\n vi.spyOn(fieldLoader1, \"canHandle\").mockReturnValue(true);\n vi.spyOn(fieldLoader2, \"canHandle\").mockReturnValue(true);\n vi.spyOn(fieldLoader1, \"loadField\").mockResolvedValue(mockContext1);\n vi.spyOn(fieldLoader2, \"loadField\").mockResolvedValue(mockContext2);\n\n const contextModule = new DefaultContextModule({\n ...defaultContextModuleConfig,\n customFieldLoaders: [fieldLoader1, fieldLoader2],\n });\n\n const testField = { type: \"error\", address: \"0x123\" };\n\n // WHEN\n const result = await contextModule.getFieldContext(\n testField,\n ClearSignContextType.TOKEN,\n );\n\n // THEN\n expect(fieldLoader1.canHandle).toHaveBeenCalledWith(\n testField,\n ClearSignContextType.TOKEN,\n );\n expect(fieldLoader2.canHandle).toHaveBeenCalledWith(\n testField,\n ClearSignContextType.TOKEN,\n );\n expect(fieldLoader1.loadField).toHaveBeenCalledWith(testField);\n expect(fieldLoader2.loadField).toHaveBeenCalledWith(testField);\n expect(result).toEqual(mockContext2);\n });\n\n it(\"should handle loader rejection gracefully\", async () => {\n // GIVEN\n const fieldLoader = fieldLoaderStubBuilder();\n const loadError = new Error(\"Load field failed\");\n\n vi.spyOn(fieldLoader, \"canHandle\").mockReturnValue(true);\n vi.spyOn(fieldLoader, \"loadField\").mockRejectedValue(loadError);\n\n const contextModule = new DefaultContextModule({\n ...defaultContextModuleConfig,\n customFieldLoaders: [fieldLoader],\n });\n\n const testField = { type: \"error\", address: \"0x123\" };\n\n // WHEN & THEN\n await expect(\n contextModule.getFieldContext(testField, ClearSignContextType.TOKEN),\n ).rejects.toThrow(\"Load field failed\");\n\n expect(fieldLoader.canHandle).toHaveBeenCalledWith(\n testField,\n ClearSignContextType.TOKEN,\n );\n expect(fieldLoader.loadField).toHaveBeenCalledWith(testField);\n });\n });\n});\n"],
5
- "mappings": "AAGA,OAEE,wBAAAA,MACK,kCAGP,OAAS,wBAAAC,MAA4B,yBAErC,MAAMC,EAAoB,KAAO,CAC/B,MAAO,GAAG,GAAG,EACb,KAAM,GAAG,GAAG,EACZ,KAAM,GAAG,GAAG,EACZ,MAAO,GAAG,GAAG,EACb,YAAa,CAAC,CAChB,GAEMC,EAA4BC,IACzB,CACL,KAAM,GAAG,GAAG,EACZ,UAAW,GACR,GAAG,EACH,gBAAgBA,CAAS,CAC9B,GAGIC,EAAyB,KACtB,CACL,UAAW,GAAG,GAAG,EACjB,UAAW,GAAG,GAAG,CACnB,GAGF,SAAS,uBAAwB,IAAM,CACrC,MAAMC,EAA0C,CAAE,KAAM,GAAG,GAAG,CAAE,EAC1DC,EAAkD,CACtD,cAAe,CAAC,EAChB,eAAgB,GAChB,oBAAqB,GACrB,mBAAoB,CAAC,EACrB,sBAAuBD,EACvB,IAAK,CACH,IAA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BAAgBG,EAAWhB,EAAqB,KAAK,CACrE,EAAE,QAAQ,QAAQ,mBAAmB,EAErC,OAAOe,EAAY,SAAS,EAAE,qBAC5BC,EACAhB,EAAqB,KACvB,EACA,OAAOe,EAAY,SAAS,EAAE,qBAAqBC,CAAS,CAC9D,CAAC,CACH,CAAC,CACH,CAAC",
4
+ "sourcesContent": ["import {\n type ContextModuleLoaderConfig,\n type ContextModuleServiceConfig,\n} from \"./config/model/ContextModuleConfig\";\nimport { type ContextFieldLoader } from \"./shared/domain/ContextFieldLoader\";\nimport { type ContextLoader } from \"./shared/domain/ContextLoader\";\nimport {\n type ClearSignContext,\n ClearSignContextType,\n} from \"./shared/model/ClearSignContext\";\nimport { type TypedDataContext } from \"./shared/model/TypedDataContext\";\nimport type { TypedDataContextLoader } from \"./typed-data/domain/TypedDataContextLoader\";\nimport { DefaultContextModule } from \"./DefaultContextModule\";\n\nconst mockLoggerFactory = () => ({\n debug: vi.fn(),\n info: vi.fn(),\n warn: vi.fn(),\n error: vi.fn(),\n subscribers: [],\n});\n\nconst contextLoaderStubBuilder = (canHandle: boolean): ContextLoader => {\n return {\n load: vi.fn(),\n canHandle: vi\n .fn()\n .mockReturnValue(canHandle) as unknown as ContextLoader[\"canHandle\"],\n };\n};\n\nconst fieldLoaderStubBuilder = (): ContextFieldLoader => {\n return {\n canHandle: vi.fn() as unknown as ContextFieldLoader[\"canHandle\"],\n loadField: vi.fn(),\n };\n};\n\ndescribe(\"DefaultContextModule\", () => {\n const typedDataLoader: TypedDataContextLoader = { load: vi.fn() };\n const defaultContextModuleConfig: ContextModuleServiceConfig &\n ContextModuleLoaderConfig = {\n customLoaders: [],\n defaultLoaders: false,\n defaultFieldLoaders: false,\n customFieldLoaders: [],\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 reporter: {\n url: \"https://reporter.com\",\n },\n datasource: {\n proxy: \"default\",\n },\n appSource: \"third-party\",\n originToken: \"originToken\",\n loggerFactory: mockLoggerFactory,\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({});\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({});\n\n expect(res).toEqual([]);\n });\n\n it(\"should call all fetch method from metadata fetcher\", async () => {\n const loader = contextLoaderStubBuilder(true);\n const contextModule = new DefaultContextModule({\n ...defaultContextModuleConfig,\n customLoaders: [loader, loader],\n });\n\n await contextModule.getContexts({});\n\n expect(loader.canHandle).toHaveBeenCalledTimes(2);\n expect(loader.load).toHaveBeenCalledTimes(2);\n });\n\n it(\"should return an array of context response\", async () => {\n const loader = contextLoaderStubBuilder(true);\n const responses = [\n [{ type: \"provideERC20Info\", payload: \"payload1\" }],\n [\n { type: \"provideERC20Info\", payload: \"payload2\" },\n { type: \"plugin\", payload: \"payload3\" },\n ],\n ] as ClearSignContext[][];\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({});\n\n expect(loader.canHandle).toHaveBeenCalledTimes(2);\n expect(loader.load).toHaveBeenCalledTimes(2);\n expect(res).toEqual(responses.flat());\n });\n\n it(\"should only call loaders that can handle the input\", async () => {\n const loader1 = contextLoaderStubBuilder(true);\n const loader2 = contextLoaderStubBuilder(true);\n\n vi.spyOn(loader1, \"canHandle\").mockReturnValue(true);\n vi.spyOn(loader2, \"canHandle\").mockReturnValue(false);\n vi.spyOn(loader1, \"load\").mockResolvedValue([\n { type: ClearSignContextType.TOKEN, payload: \"payload1\" },\n ]);\n vi.spyOn(loader2, \"load\").mockResolvedValue([\n { type: ClearSignContextType.NFT, payload: \"payload2\" },\n ]);\n\n const contextModule = new DefaultContextModule({\n ...defaultContextModuleConfig,\n customLoaders: [loader1, loader2],\n });\n\n const testInput = { to: \"0x123\", selector: \"0xabc\" };\n const res = await contextModule.getContexts(testInput);\n\n expect(loader1.canHandle).toHaveBeenCalledWith(\n testInput,\n Object.values(ClearSignContextType),\n );\n expect(loader2.canHandle).toHaveBeenCalledWith(\n testInput,\n Object.values(ClearSignContextType),\n );\n expect(loader1.load).toHaveBeenCalledWith(testInput);\n expect(loader2.load).not.toHaveBeenCalled(); // Should not be called since canHandle returned false\n expect(res).toEqual([{ type: \"token\", payload: \"payload1\" }]);\n });\n\n it(\"should use expected types if provided\", async () => {\n const loader = contextLoaderStubBuilder(true);\n\n vi.spyOn(loader, \"canHandle\").mockReturnValue(true);\n\n vi.spyOn(loader, \"load\").mockResolvedValue([\n { type: ClearSignContextType.TOKEN, payload: \"payload1\" },\n ]);\n\n const contextModule = new DefaultContextModule({\n ...defaultContextModuleConfig,\n customLoaders: [loader],\n });\n\n const testInput = { to: \"0x123\", selector: \"0xabc\" };\n await contextModule.getContexts(testInput, [ClearSignContextType.TOKEN]);\n\n expect(loader.canHandle).toHaveBeenCalledWith(testInput, [\n ClearSignContextType.TOKEN,\n ]);\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 describe(\"getFieldContext\", () => {\n it(\"should return error when no loader can handle the field\", async () => {\n // GIVEN\n const fieldLoader = fieldLoaderStubBuilder();\n vi.spyOn(fieldLoader, \"canHandle\").mockReturnValue(false);\n\n const contextModule = new DefaultContextModule({\n ...defaultContextModuleConfig,\n customFieldLoaders: [fieldLoader],\n });\n\n const testField = { type: \"unknown\" };\n\n // WHEN\n const result = await contextModule.getFieldContext(\n testField,\n ClearSignContextType.TOKEN,\n );\n\n // THEN\n expect(fieldLoader.canHandle).toHaveBeenCalledWith(\n testField,\n ClearSignContextType.TOKEN,\n );\n expect(fieldLoader.loadField).not.toHaveBeenCalled();\n expect(result).toEqual({\n type: ClearSignContextType.ERROR,\n error: new Error(\n `Loader not found for field: ${testField} and expected type: ${ClearSignContextType.TOKEN}`,\n ),\n });\n });\n\n it(\"should return context when a loader can handle the field\", async () => {\n // GIVEN\n const fieldLoader = fieldLoaderStubBuilder();\n const mockContext: ClearSignContext = {\n type: ClearSignContextType.TOKEN,\n payload: \"test-payload\",\n };\n\n vi.spyOn(fieldLoader, \"canHandle\").mockReturnValue(true);\n vi.spyOn(fieldLoader, \"loadField\").mockResolvedValue(mockContext);\n\n const contextModule = new DefaultContextModule({\n ...defaultContextModuleConfig,\n customFieldLoaders: [fieldLoader],\n });\n\n const testField = { type: \"token\", address: \"0x123\" };\n\n // WHEN\n const result = await contextModule.getFieldContext(\n testField,\n ClearSignContextType.TOKEN,\n );\n\n // THEN\n expect(fieldLoader.canHandle).toHaveBeenCalledWith(\n testField,\n ClearSignContextType.TOKEN,\n );\n expect(fieldLoader.loadField).toHaveBeenCalledWith(testField);\n expect(result).toEqual(mockContext);\n });\n\n it(\"should return first context when multiple loaders can handle the field\", async () => {\n // GIVEN\n const fieldLoader1 = fieldLoaderStubBuilder();\n const fieldLoader2 = fieldLoaderStubBuilder();\n\n const mockContext1: ClearSignContext = {\n type: ClearSignContextType.TOKEN,\n payload: \"first-payload\",\n };\n const mockContext2: ClearSignContext = {\n type: ClearSignContextType.NFT,\n payload: \"second-payload\",\n };\n\n vi.spyOn(fieldLoader1, \"canHandle\").mockReturnValue(true);\n vi.spyOn(fieldLoader2, \"canHandle\").mockReturnValue(true);\n vi.spyOn(fieldLoader1, \"loadField\").mockResolvedValue(mockContext1);\n vi.spyOn(fieldLoader2, \"loadField\").mockResolvedValue(mockContext2);\n\n const contextModule = new DefaultContextModule({\n ...defaultContextModuleConfig,\n customFieldLoaders: [fieldLoader1, fieldLoader2],\n });\n\n const testField = { type: \"multi\", address: \"0x123\" };\n\n // WHEN\n const result = await contextModule.getFieldContext(\n testField,\n ClearSignContextType.TOKEN,\n );\n\n // THEN\n expect(fieldLoader1.canHandle).toHaveBeenCalledWith(\n testField,\n ClearSignContextType.TOKEN,\n );\n expect(fieldLoader2.canHandle).toHaveBeenCalledWith(\n testField,\n ClearSignContextType.TOKEN,\n );\n expect(fieldLoader1.loadField).toHaveBeenCalledWith(testField);\n expect(fieldLoader2.loadField).not.toHaveBeenCalled();\n expect(result).toEqual(mockContext1); // Should return first context\n });\n\n it(\"should return second context when first context is an error\", async () => {\n // GIVEN\n const fieldLoader1 = fieldLoaderStubBuilder();\n const fieldLoader2 = fieldLoaderStubBuilder();\n const mockContext1: ClearSignContext = {\n type: ClearSignContextType.ERROR,\n error: new Error(\"first-error\"),\n };\n const mockContext2: ClearSignContext = {\n type: ClearSignContextType.TOKEN,\n payload: \"second-payload\",\n };\n vi.spyOn(fieldLoader1, \"canHandle\").mockReturnValue(true);\n vi.spyOn(fieldLoader2, \"canHandle\").mockReturnValue(true);\n vi.spyOn(fieldLoader1, \"loadField\").mockResolvedValue(mockContext1);\n vi.spyOn(fieldLoader2, \"loadField\").mockResolvedValue(mockContext2);\n\n const contextModule = new DefaultContextModule({\n ...defaultContextModuleConfig,\n customFieldLoaders: [fieldLoader1, fieldLoader2],\n });\n\n const testField = { type: \"error\", address: \"0x123\" };\n\n // WHEN\n const result = await contextModule.getFieldContext(\n testField,\n ClearSignContextType.TOKEN,\n );\n\n // THEN\n expect(fieldLoader1.canHandle).toHaveBeenCalledWith(\n testField,\n ClearSignContextType.TOKEN,\n );\n expect(fieldLoader2.canHandle).toHaveBeenCalledWith(\n testField,\n ClearSignContextType.TOKEN,\n );\n expect(fieldLoader1.loadField).toHaveBeenCalledWith(testField);\n expect(fieldLoader2.loadField).toHaveBeenCalledWith(testField);\n expect(result).toEqual(mockContext2);\n });\n\n it(\"should handle loader rejection gracefully\", async () => {\n // GIVEN\n const fieldLoader = fieldLoaderStubBuilder();\n const loadError = new Error(\"Load field failed\");\n\n vi.spyOn(fieldLoader, \"canHandle\").mockReturnValue(true);\n vi.spyOn(fieldLoader, \"loadField\").mockRejectedValue(loadError);\n\n const contextModule = new DefaultContextModule({\n ...defaultContextModuleConfig,\n customFieldLoaders: [fieldLoader],\n });\n\n const testField = { type: \"error\", address: \"0x123\" };\n\n // WHEN & THEN\n await expect(\n contextModule.getFieldContext(testField, ClearSignContextType.TOKEN),\n ).rejects.toThrow(\"Load field failed\");\n\n expect(fieldLoader.canHandle).toHaveBeenCalledWith(\n testField,\n ClearSignContextType.TOKEN,\n );\n expect(fieldLoader.loadField).toHaveBeenCalledWith(testField);\n });\n });\n});\n"],
5
+ "mappings": "AAMA,OAEE,wBAAAA,MACK,kCAGP,OAAS,wBAAAC,MAA4B,yBAErC,MAAMC,EAAoB,KAAO,CAC/B,MAAO,GAAG,GAAG,EACb,KAAM,GAAG,GAAG,EACZ,KAAM,GAAG,GAAG,EACZ,MAAO,GAAG,GAAG,EACb,YAAa,CAAC,CAChB,GAEMC,EAA4BC,IACzB,CACL,KAAM,GAAG,GAAG,EACZ,UAAW,GACR,GAAG,EACH,gBAAgBA,CAAS,CAC9B,GAGIC,EAAyB,KACtB,CACL,UAAW,GAAG,GAAG,EACjB,UAAW,GAAG,GAAG,CACnB,GAGF,SAAS,uBAAwB,IAAM,CACrC,MAAMC,EAA0C,CAAE,KAAM,GAAG,GAAG,CAAE,EAC1DC,EACwB,CAC5B,cAAe,CAAC,EAChB,eAAgB,GAChB,oBAAqB,GACrB,mBAAoB,CAAC,EACrB,sBAAuBD,EACvB,IAAK,CACH,IAAK,iBACL,KAAM,OACN,OAAQ,MACV,EACA,WAAY,CACV,IAAK,uBACP,EACA,sBAAuB,CACrB,IAAK,sBACP,EACA,SAAU,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EAAE,QAAQ,QAAQ,mBAAmB,EAErC,OAAOe,EAAY,SAAS,EAAE,qBAC5BC,EACAhB,EAAqB,KACvB,EACA,OAAOe,EAAY,SAAS,EAAE,qBAAqBC,CAAS,CAC9D,CAAC,CACH,CAAC,CACH,CAAC",
6
6
  "names": ["ClearSignContextType", "DefaultContextModule", "mockLoggerFactory", "contextLoaderStubBuilder", "canHandle", "fieldLoaderStubBuilder", "typedDataLoader", "defaultContextModuleConfig", "res", "loader", "responses", "loader1", "loader2", "contextModule", "testInput", "fieldLoader", "testField", "result", "mockContext", "fieldLoader1", "fieldLoader2", "mockContext1", "mockContext2", "loadError"]
7
7
  }
@@ -0,0 +1 @@
1
+ //# sourceMappingURL=AccountOwnershipDataSource.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": [],
4
+ "sourcesContent": [],
5
+ "mappings": "",
6
+ "names": []
7
+ }
@@ -0,0 +1,2 @@
1
+ class e extends Error{kind;constructor(r,n){super(n),this.name="AccountOwnershipError",this.kind=r}}export{e as AccountOwnershipError};
2
+ //# sourceMappingURL=AccountOwnershipError.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../../../src/account-ownership/data/AccountOwnershipError.ts"],
4
+ "sourcesContent": ["/**\n * Classification for errors returned by the trusted metadata service when\n * fetching an account-ownership descriptor.\n *\n * - `verification_failed`: the service was reached and actively refused the\n * pubkey \u2192 address mapping (HTTP 4xx). Treat as a terminal, non-retryable\n * verification failure.\n * - `service_unavailable`: the service could not answer (network failure,\n * HTTP 5xx, malformed response). Treat as transient; fallback UI may be\n * appropriate.\n */\nexport type AccountOwnershipErrorKind =\n | \"verification_failed\"\n | \"service_unavailable\";\n\nexport class AccountOwnershipError extends Error {\n readonly kind: AccountOwnershipErrorKind;\n\n constructor(kind: AccountOwnershipErrorKind, message: string) {\n super(message);\n this.name = \"AccountOwnershipError\";\n this.kind = kind;\n }\n}\n"],
5
+ "mappings": "AAeO,MAAMA,UAA8B,KAAM,CACtC,KAET,YAAYC,EAAiCC,EAAiB,CAC5D,MAAMA,CAAO,EACb,KAAK,KAAO,wBACZ,KAAK,KAAOD,CACd,CACF",
6
+ "names": ["AccountOwnershipError", "kind", "message"]
7
+ }
@@ -0,0 +1,2 @@
1
+ var f=Object.defineProperty;var y=Object.getOwnPropertyDescriptor;var g=(o,e,t,r)=>{for(var s=r>1?void 0:r?y(e,t):e,n=o.length-1,a;n>=0;n--)(a=o[n])&&(s=(r?a(e,t,s):a(s))||s);return r&&s&&f(e,t,s),s},p=(o,e)=>(t,r)=>e(t,r,o);import{inject as m,injectable as w}from"inversify";import{Left as u,Right as h}from"purify-ts";import{AccountOwnershipError as i}from"../../account-ownership/data/AccountOwnershipError";import{configTypes as d}from"../../config/di/configTypes";import{networkTypes as l}from"../../network/di/networkTypes";let c=class{constructor(e,t){this.config=e;this.http=t}async getDescriptor({publicKey:e,address:t,challenge:r,network:s}){try{const n=await this.http.get(`${this.config.metadataServiceDomain.url}/v2/concordium/owner/${e}/${t}`,{params:{challenge:r,network:s}});return n?this.isAccountOwnershipDto(n)?h({signedDescriptor:n.signedDescriptor,keyId:n.keyId,keyUsage:n.keyUsage}):u(new i("service_unavailable","[ContextModule] HttpAccountOwnershipDataSource: invalid response format")):u(new i("service_unavailable","[ContextModule] HttpAccountOwnershipDataSource: unexpected empty response"))}catch(n){return u(this.classifyError(n))}}classifyError(e){if(this.hasNumericStatus(e)){const t=e.status,r=this.extractErrorMessage(e);return this.classifyFromStatus(t,r)}return new i("service_unavailable","[ContextModule] HttpAccountOwnershipDataSource: Failed to fetch account ownership descriptor")}classifyFromStatus(e,t){return e>=400&&e<500?new i("verification_failed",t):new i("service_unavailable",`[ContextModule] HttpAccountOwnershipDataSource: backend ${e}: ${t}`)}hasNumericStatus(e){return typeof e=="object"&&e!==null&&"status"in e&&typeof e.status=="number"}extractErrorMessage(e){const t=this.extractResponseBodyMessage(e);return t!==null?t:typeof e=="object"&&e!==null&&"message"in e&&typeof e.message=="string"&&e.message.length>0?e.message:typeof e=="string"?e:"Unknown error"}extractResponseBodyMessage(e){if(typeof e!="object"||e===null||!("responseBody"in e)||typeof e.responseBody!="string")return null;const t=e.responseBody;if(t.length===0)return null;try{const r=JSON.parse(t);if(typeof r=="object"&&r!==null&&"message"in r&&typeof r.message=="string"&&r.message.length>0)return r.message}catch{}return t}isAccountOwnershipDto(e){return typeof e=="object"&&e!==null&&"signedDescriptor"in e&&"keyId"in e&&"keyUsage"in e&&typeof e.signedDescriptor=="string"&&typeof e.keyId=="string"&&typeof e.keyUsage=="string"}};c=g([w(),p(0,m(d.Config)),p(1,m(l.NetworkClient))],c);export{c as HttpAccountOwnershipDataSource};
2
+ //# sourceMappingURL=HttpAccountOwnershipDataSource.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../../../src/account-ownership/data/HttpAccountOwnershipDataSource.ts"],
4
+ "sourcesContent": ["import { DmkNetworkClient } from \"@ledgerhq/device-management-kit\";\nimport { inject, injectable } from \"inversify\";\nimport { type Either, Left, Right } from \"purify-ts\";\n\nimport {\n type AccountOwnershipDataSource,\n type AccountOwnershipDescriptor,\n type GetAccountOwnershipParams,\n} from \"@/account-ownership/data/AccountOwnershipDataSource\";\nimport { AccountOwnershipError } from \"@/account-ownership/data/AccountOwnershipError\";\nimport { type AccountOwnershipDto } from \"@/account-ownership/data/dto/AccountOwnershipDto\";\nimport { configTypes } from \"@/config/di/configTypes\";\nimport { type ContextModuleServiceConfig } from \"@/config/model/ContextModuleConfig\";\nimport { networkTypes } from \"@/network/di/networkTypes\";\n\n@injectable()\nexport class HttpAccountOwnershipDataSource\n implements AccountOwnershipDataSource\n{\n constructor(\n @inject(configTypes.Config)\n private readonly config: ContextModuleServiceConfig,\n @inject(networkTypes.NetworkClient)\n private readonly http: DmkNetworkClient,\n ) {}\n\n async getDescriptor({\n publicKey,\n address,\n challenge,\n network,\n }: GetAccountOwnershipParams): Promise<\n Either<Error, AccountOwnershipDescriptor>\n > {\n try {\n const data = (await this.http.get(\n `${this.config.metadataServiceDomain.url}/v2/concordium/owner/${publicKey}/${address}`,\n {\n params: { challenge, network },\n },\n )) as AccountOwnershipDto | null;\n\n if (!data) {\n return Left(\n new AccountOwnershipError(\n \"service_unavailable\",\n \"[ContextModule] HttpAccountOwnershipDataSource: unexpected empty response\",\n ),\n );\n }\n\n if (!this.isAccountOwnershipDto(data)) {\n return Left(\n new AccountOwnershipError(\n \"service_unavailable\",\n \"[ContextModule] HttpAccountOwnershipDataSource: invalid response format\",\n ),\n );\n }\n\n return Right({\n signedDescriptor: data.signedDescriptor,\n keyId: data.keyId,\n keyUsage: data.keyUsage,\n });\n } catch (error) {\n return Left(this.classifyError(error));\n }\n }\n\n /**\n * Classifies a caught request error into an {@link AccountOwnershipError}:\n * HTTP 4xx responses carry the backend's `message` verbatim and are marked\n * as `verification_failed`; everything else (network failure, 5xx,\n * unrecognized errors) is marked as `service_unavailable`.\n *\n * Errors with a numeric `.status` field are treated as HTTP-shaped\n * failures. `DmkNetworkClientError` exposes `.status` and a raw\n * `.responseBody` string; the backend's human-readable message is\n * extracted from the error's own `.message` first, then from the JSON\n * body on `.responseBody`, and finally from the raw body as a\n * last resort.\n */\n private classifyError(error: unknown): AccountOwnershipError {\n if (this.hasNumericStatus(error)) {\n const status = error.status;\n const message = this.extractErrorMessage(error);\n return this.classifyFromStatus(status, message);\n }\n\n return new AccountOwnershipError(\n \"service_unavailable\",\n \"[ContextModule] HttpAccountOwnershipDataSource: Failed to fetch account ownership descriptor\",\n );\n }\n\n private classifyFromStatus(\n status: number,\n message: string,\n ): AccountOwnershipError {\n if (status >= 400 && status < 500) {\n return new AccountOwnershipError(\"verification_failed\", message);\n }\n return new AccountOwnershipError(\n \"service_unavailable\",\n `[ContextModule] HttpAccountOwnershipDataSource: backend ${status}: ${message}`,\n );\n }\n\n private hasNumericStatus(value: unknown): value is { status: number } {\n return (\n typeof value === \"object\" &&\n value !== null &&\n \"status\" in value &&\n typeof (value as { status: unknown }).status === \"number\"\n );\n }\n\n private extractErrorMessage(value: unknown): string {\n const fromBody = this.extractResponseBodyMessage(value);\n if (fromBody !== null) {\n return fromBody;\n }\n if (\n typeof value === \"object\" &&\n value !== null &&\n \"message\" in value &&\n typeof (value as { message: unknown }).message === \"string\" &&\n (value as { message: string }).message.length > 0\n ) {\n return (value as { message: string }).message;\n }\n if (typeof value === \"string\") {\n return value;\n }\n return \"Unknown error\";\n }\n\n private extractResponseBodyMessage(value: unknown): string | null {\n if (\n typeof value !== \"object\" ||\n value === null ||\n !(\"responseBody\" in value) ||\n typeof (value as { responseBody: unknown }).responseBody !== \"string\"\n ) {\n return null;\n }\n const body = (value as { responseBody: string }).responseBody;\n if (body.length === 0) {\n return null;\n }\n try {\n const parsed = JSON.parse(body) as unknown;\n if (\n typeof parsed === \"object\" &&\n parsed !== null &&\n \"message\" in parsed &&\n typeof (parsed as { message: unknown }).message === \"string\" &&\n (parsed as { message: string }).message.length > 0\n ) {\n return (parsed as { message: string }).message;\n }\n } catch {\n // body is not JSON; fall through to use it as plain text\n }\n return body;\n }\n\n private isAccountOwnershipDto(value: unknown): value is AccountOwnershipDto {\n return (\n typeof value === \"object\" &&\n value !== null &&\n \"signedDescriptor\" in value &&\n \"keyId\" in value &&\n \"keyUsage\" in value &&\n typeof value.signedDescriptor === \"string\" &&\n typeof value.keyId === \"string\" &&\n typeof value.keyUsage === \"string\"\n );\n }\n}\n"],
5
+ "mappings": "iOACA,OAAS,UAAAA,EAAQ,cAAAC,MAAkB,YACnC,OAAsB,QAAAC,EAAM,SAAAC,MAAa,YAOzC,OAAS,yBAAAC,MAA6B,iDAEtC,OAAS,eAAAC,MAAmB,0BAE5B,OAAS,gBAAAC,MAAoB,4BAGtB,IAAMC,EAAN,KAEP,CACE,YAEmBC,EAEAC,EACjB,CAHiB,YAAAD,EAEA,UAAAC,CAChB,CAEH,MAAM,cAAc,CAClB,UAAAC,EACA,QAAAC,EACA,UAAAC,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,GACE,OAAOA,GAAU,UACjBA,IAAU,MACV,EAAE,iBAAkBA,IACpB,OAAQA,EAAoC,cAAiB,SAE7D,OAAO,KAET,MAAME,EAAQF,EAAmC,aACjD,GAAIE,EAAK,SAAW,EAClB,OAAO,KAET,GAAI,CACF,MAAMC,EAAS,KAAK,MAAMD,CAAI,EAC9B,GACE,OAAOC,GAAW,UAClBA,IAAW,MACX,YAAaA,GACb,OAAQA,EAAgC,SAAY,UACnDA,EAA+B,QAAQ,OAAS,EAEjD,OAAQA,EAA+B,OAE3C,MAAQ,CAER,CACA,OAAOD,CACT,CAEQ,sBAAsBF,EAA8C,CAC1E,OACE,OAAOA,GAAU,UACjBA,IAAU,MACV,qBAAsBA,GACtB,UAAWA,GACX,aAAcA,GACd,OAAOA,EAAM,kBAAqB,UAClC,OAAOA,EAAM,OAAU,UACvB,OAAOA,EAAM,UAAa,QAE9B,CACF,EApKad,EAANkB,EAAA,CADNC,EAAW,EAKPC,EAAA,EAAAC,EAAOC,EAAY,MAAM,GAEzBF,EAAA,EAAAC,EAAOE,EAAa,aAAa,IANzBvB",
6
+ "names": ["inject", "injectable", "Left", "Right", "AccountOwnershipError", "configTypes", "networkTypes", "HttpAccountOwnershipDataSource", "config", "http", "publicKey", "address", "challenge", "network", "data", "Right", "Left", "AccountOwnershipError", "error", "status", "message", "value", "fromBody", "body", "parsed", "__decorateClass", "injectable", "__decorateParam", "inject", "configTypes", "networkTypes"]
7
+ }
@@ -0,0 +1,2 @@
1
+ import{Left as d,Right as g}from"purify-ts";import{AccountOwnershipError as u}from"../../account-ownership/data/AccountOwnershipError";import{HttpAccountOwnershipDataSource as p}from"./HttpAccountOwnershipDataSource";function i(n){const c=new Error(n.message??"HTTP error");return n.status!==void 0&&(c.status=n.status),n.responseBody!==void 0&&(c.responseBody=n.responseBody),c}describe("HttpAccountOwnershipDataSource",()=>{const n={metadataServiceDomain:{url:"https://nft.api.live.ledger-test.com"},originToken:"test-origin-token"},c={signedDescriptor:"signed-descriptor-data",keyId:"domain_metadata_key",keyUsage:"trusted_name"},r={publicKey:"abcdef1234567890",address:"3kFkntk2H5FGMzeR3GjQKPhdZK9LShKdPHsj2fiGKCdmDXj2WB",challenge:"0xabcdef",network:"mainnet"};let s,o;beforeEach(()=>{vi.clearAllMocks(),s={get:vi.fn()},o=new p(n,s)}),describe("getDescriptor",()=>{it("should return descriptor on successful request",async()=>{s.get.mockResolvedValue(c);const t=await o.getDescriptor(r);expect(s.get).toHaveBeenCalledWith(`${n.metadataServiceDomain.url}/v2/concordium/owner/${r.publicKey}/${r.address}`,{params:{challenge:r.challenge,network:r.network}}),expect(t).toEqual(g(c))}),it("should pass testnet network parameter",async()=>{s.get.mockResolvedValue(c),await o.getDescriptor({...r,network:"testnet"}),expect(s.get).toHaveBeenCalledWith(expect.any(String),{params:{challenge:r.challenge,network:"testnet"}})}),it("should classify empty response as service_unavailable",async()=>{s.get.mockResolvedValue(null);const t=await o.getDescriptor(r);expect(t.isLeft()).toBe(!0);const e=t.extract();expect(e).toBeInstanceOf(u),expect(e.kind).toBe("service_unavailable"),expect(e.message).toContain("unexpected empty response")}),it.each([["signedDescriptor missing",{keyId:"k",keyUsage:"u"}],["keyId missing",{signedDescriptor:"s",keyUsage:"u"}],["keyUsage missing",{signedDescriptor:"s",keyId:"k"}],["wrong field type",{signedDescriptor:"s",keyId:123,keyUsage:"u"}]])("should classify malformed response (%s) as service_unavailable",async(t,e)=>{s.get.mockResolvedValue(e);const a=await o.getDescriptor(r);expect(a.isLeft()).toBe(!0);const l=a.extract();expect(l).toBeInstanceOf(u),expect(l.kind).toBe("service_unavailable"),expect(l.message).toContain("invalid response format")}),it("should classify 422 with { message } body as verification_failed and forward backend message",async()=>{const t="Address ByteVector(32 bytes, 0xa63c) is not associated with the given public key ByteVector(32 bytes, 0x9dc1) on the network Testnet";s.get.mockRejectedValue(i({status:422,message:"HTTP error 422",responseBody:JSON.stringify({message:t})}));const e=await o.getDescriptor(r);expect(e.isLeft()).toBe(!0);const a=e.extract();expect(a).toBeInstanceOf(u),expect(a.kind).toBe("verification_failed"),expect(a.message).toBe(t)}),it.each([400,401,403,404,429])("should classify HTTP %s as verification_failed with forwarded message",async t=>{s.get.mockRejectedValue(i({status:t,message:`HTTP error ${t}`,responseBody:JSON.stringify({message:"refused"})}));const a=(await o.getDescriptor(r)).extract();expect(a.kind).toBe("verification_failed"),expect(a.message).toBe("refused")}),it("should classify 500 as service_unavailable with status prefix",async()=>{s.get.mockRejectedValue(i({status:500,message:"HTTP error 500",responseBody:JSON.stringify({message:"internal error"})}));const e=(await o.getDescriptor(r)).extract();expect(e.kind).toBe("service_unavailable"),expect(e.message).toContain("backend 500"),expect(e.message).toContain("internal error")}),it.each([502,503,504])("should classify HTTP %s as service_unavailable",async t=>{s.get.mockRejectedValue(i({status:t,message:`HTTP error ${t}`,responseBody:JSON.stringify({message:"down"})}));const a=(await o.getDescriptor(r)).extract();expect(a.kind).toBe("service_unavailable"),expect(a.message).toContain(`backend ${t}`),expect(a.message).toContain("down")}),it("should accept plain-text response body and forward it on 4xx",async()=>{s.get.mockRejectedValue(i({status:422,message:"HTTP error 422",responseBody:"plain text reason"}));const e=(await o.getDescriptor(r)).extract();expect(e.kind).toBe("verification_failed"),expect(e.message).toBe("plain text reason")}),it("should fall back to the client error message when response body is empty",async()=>{s.get.mockRejectedValue(i({status:422,message:"HTTP error 422",responseBody:""}));const e=(await o.getDescriptor(r)).extract();expect(e.kind).toBe("verification_failed"),expect(e.message).toBe("HTTP error 422")}),it("should classify network errors (no status) as service_unavailable",async()=>{s.get.mockRejectedValue(new Error("Network error"));const t=await o.getDescriptor(r);expect(t).toEqual(d(new u("service_unavailable","[ContextModule] HttpAccountOwnershipDataSource: Failed to fetch account ownership descriptor")))}),describe("errors with numeric .status",()=>{it.each([400,401,403,404,422,429])("should classify HTTP %s on .status as verification_failed and forward .message",async t=>{const e="Address ByteVector(...) is not associated with the given public key ByteVector(...)";s.get.mockRejectedValue(i({status:t,message:e}));const l=(await o.getDescriptor(r)).extract();expect(l.kind).toBe("verification_failed"),expect(l.message).toBe(e)}),it.each([500,502,503,504])("should classify HTTP %s on .status as service_unavailable with status prefix",async t=>{s.get.mockRejectedValue(i({status:t,message:"down"}));const a=(await o.getDescriptor(r)).extract();expect(a.kind).toBe("service_unavailable"),expect(a.message).toContain(`backend ${t}`),expect(a.message).toContain("down")}),it("should ignore non-numeric .status and fall through to service_unavailable fallback",async()=>{const t=new Error("bad");t.status="422",s.get.mockRejectedValue(t);const e=await o.getDescriptor(r);expect(e).toEqual(d(new u("service_unavailable","[ContextModule] HttpAccountOwnershipDataSource: Failed to fetch account ownership descriptor")))}),it("should forward .message from plain object errors (not Error instances)",async()=>{s.get.mockRejectedValue({status:422,message:"plain object message"});const e=(await o.getDescriptor(r)).extract();expect(e.kind).toBe("verification_failed"),expect(e.message).toBe("plain object message")}),it("should use an 'Unknown error' fallback when the object has no usable message",async()=>{s.get.mockRejectedValue({status:422});const e=(await o.getDescriptor(r)).extract();expect(e.kind).toBe("verification_failed"),expect(e.message).toBe("Unknown error")})}),it("should use correct metadata service URL from config",async()=>{const t={metadataServiceDomain:{url:"https://custom-metadata.example.com"},originToken:"custom-token"},e=new p(t,s);s.get.mockResolvedValue(c),await e.getDescriptor(r),expect(s.get).toHaveBeenCalledWith("https://custom-metadata.example.com/v2/concordium/owner/abcdef1234567890/3kFkntk2H5FGMzeR3GjQKPhdZK9LShKdPHsj2fiGKCdmDXj2WB",expect.anything())})})});
2
+ //# sourceMappingURL=HttpAccountOwnershipDataSource.test.js.map