@ledgerhq/context-module 1.1.0 → 1.3.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 (380) hide show
  1. package/lib/cjs/index.js.map +1 -1
  2. package/lib/cjs/package.json +8 -7
  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 +3 -3
  13. package/lib/cjs/src/config/model/ContextModuleConfig.js +1 -1
  14. package/lib/cjs/src/config/model/ContextModuleConfig.js.map +1 -1
  15. package/lib/cjs/src/di.js +1 -1
  16. package/lib/cjs/src/di.js.map +3 -3
  17. package/lib/cjs/src/external-plugin/data/HttpExternalPluginDataSource.test.js +1 -1
  18. package/lib/cjs/src/external-plugin/data/HttpExternalPluginDataSource.test.js.map +2 -2
  19. package/lib/cjs/src/external-plugin/domain/ExternalPluginContextLoader.test.js +1 -1
  20. package/lib/cjs/src/external-plugin/domain/ExternalPluginContextLoader.test.js.map +2 -2
  21. package/lib/cjs/src/index.js +1 -1
  22. package/lib/cjs/src/index.js.map +2 -2
  23. package/lib/cjs/src/nft/data/HttpNftDataSource.test.js +1 -1
  24. package/lib/cjs/src/nft/data/HttpNftDataSource.test.js.map +2 -2
  25. package/lib/cjs/src/nft/domain/NftContextLoader.test.js +1 -1
  26. package/lib/cjs/src/nft/domain/NftContextLoader.test.js.map +2 -2
  27. package/lib/cjs/src/pki/data/HttpPkiCertificateDataSource.js +2 -0
  28. package/lib/cjs/src/pki/data/HttpPkiCertificateDataSource.js.map +7 -0
  29. package/lib/cjs/src/pki/data/HttpPkiCertificateDataSource.test.js +2 -0
  30. package/lib/cjs/src/pki/data/HttpPkiCertificateDataSource.test.js.map +7 -0
  31. package/lib/cjs/src/pki/data/PkiCertificateDataSource.js +2 -0
  32. package/lib/cjs/src/pki/data/PkiCertificateDataSource.js.map +7 -0
  33. package/lib/cjs/src/pki/data/pkiDataSourceTypes.js +2 -0
  34. package/lib/cjs/src/pki/data/pkiDataSourceTypes.js.map +7 -0
  35. package/lib/cjs/src/pki/di/pkiModuleFactory.js +2 -0
  36. package/lib/cjs/src/pki/di/pkiModuleFactory.js.map +7 -0
  37. package/lib/cjs/src/pki/di/pkiTypes.js +2 -0
  38. package/lib/cjs/src/pki/di/pkiTypes.js.map +7 -0
  39. package/lib/cjs/src/pki/domain/DefaultPkiCertificateLoader.js +2 -0
  40. package/lib/cjs/src/pki/domain/DefaultPkiCertificateLoader.js.map +7 -0
  41. package/lib/cjs/src/pki/domain/DefaultPkiCertificateLoader.test.js +2 -0
  42. package/lib/cjs/src/pki/domain/DefaultPkiCertificateLoader.test.js.map +7 -0
  43. package/lib/cjs/src/pki/domain/PkiCertificateLoader.js +2 -0
  44. package/lib/cjs/src/pki/domain/PkiCertificateLoader.js.map +7 -0
  45. package/lib/cjs/src/pki/model/KeyId.js +2 -0
  46. package/lib/cjs/src/pki/model/KeyId.js.map +7 -0
  47. package/lib/cjs/src/pki/model/KeyUsage.js +2 -0
  48. package/lib/cjs/src/pki/model/KeyUsage.js.map +7 -0
  49. package/lib/cjs/src/pki/model/PkiCertificate.js +2 -0
  50. package/lib/cjs/src/pki/model/PkiCertificate.js.map +7 -0
  51. package/lib/cjs/src/pki/model/PkiCertificateInfo.js +2 -0
  52. package/lib/cjs/src/pki/model/PkiCertificateInfo.js.map +7 -0
  53. package/lib/cjs/src/shared/model/ClearSignContext.js +1 -1
  54. package/lib/cjs/src/shared/model/ClearSignContext.js.map +2 -2
  55. package/lib/cjs/src/shared/model/GenericPath.js +1 -1
  56. package/lib/cjs/src/shared/model/GenericPath.js.map +1 -1
  57. package/lib/cjs/src/shared/model/SignatureTags.js +2 -0
  58. package/lib/cjs/src/shared/model/SignatureTags.js.map +7 -0
  59. package/lib/cjs/src/shared/model/TransactionContext.js +1 -1
  60. package/lib/cjs/src/shared/model/TransactionContext.js.map +1 -1
  61. package/lib/cjs/src/shared/model/TransactionSubset.js +1 -1
  62. package/lib/cjs/src/shared/model/TransactionSubset.js.map +1 -1
  63. package/lib/cjs/src/shared/utils/HexStringUtils.js +1 -1
  64. package/lib/cjs/src/shared/utils/HexStringUtils.js.map +3 -3
  65. package/lib/cjs/src/shared/utils/HexStringUtils.test.js +2 -0
  66. package/lib/cjs/src/shared/utils/HexStringUtils.test.js.map +7 -0
  67. package/lib/cjs/src/shared/utils/KeyUsageMapper.js +2 -0
  68. package/lib/cjs/src/shared/utils/KeyUsageMapper.js.map +7 -0
  69. package/lib/cjs/src/shared/utils/KeyUsageMapper.test.js +2 -0
  70. package/lib/cjs/src/shared/utils/KeyUsageMapper.test.js.map +7 -0
  71. package/lib/cjs/src/token/data/HttpTokenDataSource.test.js +1 -1
  72. package/lib/cjs/src/token/data/HttpTokenDataSource.test.js.map +2 -2
  73. package/lib/cjs/src/token/domain/TokenContextLoader.test.js +1 -1
  74. package/lib/cjs/src/token/domain/TokenContextLoader.test.js.map +2 -2
  75. package/lib/cjs/src/transaction/data/CalldataDto.js +1 -1
  76. package/lib/cjs/src/transaction/data/CalldataDto.js.map +1 -1
  77. package/lib/cjs/src/transaction/data/HttpTransactionDataSource.js +1 -1
  78. package/lib/cjs/src/transaction/data/HttpTransactionDataSource.js.map +3 -3
  79. package/lib/cjs/src/transaction/data/HttpTransactionDataSource.test.js +1 -1
  80. package/lib/cjs/src/transaction/data/HttpTransactionDataSource.test.js.map +3 -3
  81. package/lib/cjs/src/transaction/data/TransactionDataSource.js +1 -1
  82. package/lib/cjs/src/transaction/data/TransactionDataSource.js.map +1 -1
  83. package/lib/cjs/src/transaction/domain/TransactionContextLoader.js +1 -1
  84. package/lib/cjs/src/transaction/domain/TransactionContextLoader.js.map +2 -2
  85. package/lib/cjs/src/transaction/domain/TransactionContextLoader.test.js +1 -1
  86. package/lib/cjs/src/transaction/domain/TransactionContextLoader.test.js.map +2 -2
  87. package/lib/cjs/src/trusted-name/data/HttpTrustedNameDataSource.test.js +1 -1
  88. package/lib/cjs/src/trusted-name/data/HttpTrustedNameDataSource.test.js.map +2 -2
  89. package/lib/cjs/src/trusted-name/domain/TrustedNameContextLoader.js +1 -1
  90. package/lib/cjs/src/trusted-name/domain/TrustedNameContextLoader.js.map +2 -2
  91. package/lib/cjs/src/trusted-name/domain/TrustedNameContextLoader.test.js +1 -1
  92. package/lib/cjs/src/trusted-name/domain/TrustedNameContextLoader.test.js.map +2 -2
  93. package/lib/cjs/src/typed-data/data/HttpTypedDataDataSource.test.js +1 -1
  94. package/lib/cjs/src/typed-data/data/HttpTypedDataDataSource.test.js.map +2 -2
  95. package/lib/cjs/src/typed-data/domain/DefaultTypedDataContextLoader.test.js +1 -1
  96. package/lib/cjs/src/typed-data/domain/DefaultTypedDataContextLoader.test.js.map +2 -2
  97. package/lib/cjs/src/uniswap/constants/plugin.js +2 -0
  98. package/lib/cjs/src/uniswap/constants/plugin.js.map +7 -0
  99. package/lib/cjs/src/uniswap/constants/uniswap.js +2 -0
  100. package/lib/cjs/src/uniswap/constants/uniswap.js.map +7 -0
  101. package/lib/cjs/src/uniswap/constants/weth.js +2 -0
  102. package/lib/cjs/src/uniswap/constants/weth.js.map +7 -0
  103. package/lib/cjs/src/uniswap/data/AbiDecoderDataSource.js +2 -0
  104. package/lib/cjs/src/uniswap/data/AbiDecoderDataSource.js.map +7 -0
  105. package/lib/cjs/src/uniswap/data/CommandDecoderDataSource.js +2 -0
  106. package/lib/cjs/src/uniswap/data/CommandDecoderDataSource.js.map +7 -0
  107. package/lib/cjs/src/uniswap/data/DefaultCommandDecoderDataSource.js +2 -0
  108. package/lib/cjs/src/uniswap/data/DefaultCommandDecoderDataSource.js.map +7 -0
  109. package/lib/cjs/src/uniswap/data/DefaultCommandDecoderDataSource.test.js +2 -0
  110. package/lib/cjs/src/uniswap/data/DefaultCommandDecoderDataSource.test.js.map +7 -0
  111. package/lib/cjs/src/uniswap/data/EthersAbiDecoderDataSource.js +2 -0
  112. package/lib/cjs/src/uniswap/data/EthersAbiDecoderDataSource.js.map +7 -0
  113. package/lib/cjs/src/uniswap/data/EthersAbiDecoderDataSource.test.js +2 -0
  114. package/lib/cjs/src/uniswap/data/EthersAbiDecoderDataSource.test.js.map +7 -0
  115. package/lib/cjs/src/uniswap/di/uniswapModuleFactory.js +2 -0
  116. package/lib/cjs/src/uniswap/di/uniswapModuleFactory.js.map +7 -0
  117. package/lib/cjs/src/uniswap/di/uniswapTypes.js +2 -0
  118. package/lib/cjs/src/uniswap/di/uniswapTypes.js.map +7 -0
  119. package/lib/cjs/src/uniswap/domain/UniswapContextLoader.js +2 -0
  120. package/lib/cjs/src/uniswap/domain/UniswapContextLoader.js.map +7 -0
  121. package/lib/cjs/src/uniswap/domain/UniswapContextLoader.test.js +2 -0
  122. package/lib/cjs/src/uniswap/domain/UniswapContextLoader.test.js.map +7 -0
  123. package/lib/cjs/src/web3-check/data/HttpWeb3CheckDataSource.js +2 -0
  124. package/lib/cjs/src/web3-check/data/HttpWeb3CheckDataSource.js.map +7 -0
  125. package/lib/cjs/src/web3-check/data/HttpWeb3CheckDataSource.test.js +2 -0
  126. package/lib/cjs/src/web3-check/data/HttpWeb3CheckDataSource.test.js.map +7 -0
  127. package/lib/cjs/src/web3-check/data/Web3CheckDataSource.js +2 -0
  128. package/lib/cjs/src/web3-check/data/Web3CheckDataSource.js.map +7 -0
  129. package/lib/cjs/src/web3-check/data/Web3CheckDto.js +2 -0
  130. package/lib/cjs/src/web3-check/data/Web3CheckDto.js.map +7 -0
  131. package/lib/cjs/src/web3-check/di/web3CheckModuleFactory.js +2 -0
  132. package/lib/cjs/src/web3-check/di/web3CheckModuleFactory.js.map +7 -0
  133. package/lib/cjs/src/web3-check/di/web3CheckTypes.js +2 -0
  134. package/lib/cjs/src/web3-check/di/web3CheckTypes.js.map +7 -0
  135. package/lib/cjs/src/web3-check/domain/DefaultWeb3CheckLoader.js +2 -0
  136. package/lib/cjs/src/web3-check/domain/DefaultWeb3CheckLoader.js.map +7 -0
  137. package/lib/cjs/src/web3-check/domain/DefaultWeb3CheckLoader.test.js +2 -0
  138. package/lib/cjs/src/web3-check/domain/DefaultWeb3CheckLoader.test.js.map +7 -0
  139. package/lib/cjs/src/web3-check/domain/Web3CheckContextLoader.js +2 -0
  140. package/lib/cjs/src/web3-check/domain/Web3CheckContextLoader.js.map +7 -0
  141. package/lib/cjs/src/web3-check/domain/web3CheckTypes.js +2 -0
  142. package/lib/cjs/src/web3-check/domain/web3CheckTypes.js.map +7 -0
  143. package/lib/esm/package.json +8 -7
  144. package/lib/esm/src/ContextModuleBuilder.js +1 -1
  145. package/lib/esm/src/ContextModuleBuilder.js.map +3 -3
  146. package/lib/esm/src/ContextModuleBuilder.test.js +1 -1
  147. package/lib/esm/src/ContextModuleBuilder.test.js.map +3 -3
  148. package/lib/esm/src/DefaultContextModule.js +1 -1
  149. package/lib/esm/src/DefaultContextModule.js.map +3 -3
  150. package/lib/esm/src/DefaultContextModule.test.js +1 -1
  151. package/lib/esm/src/DefaultContextModule.test.js.map +3 -3
  152. package/lib/esm/src/di.js +1 -1
  153. package/lib/esm/src/di.js.map +3 -3
  154. package/lib/esm/src/external-plugin/data/HttpExternalPluginDataSource.test.js +1 -1
  155. package/lib/esm/src/external-plugin/data/HttpExternalPluginDataSource.test.js.map +2 -2
  156. package/lib/esm/src/external-plugin/domain/ExternalPluginContextLoader.test.js +1 -1
  157. package/lib/esm/src/external-plugin/domain/ExternalPluginContextLoader.test.js.map +2 -2
  158. package/lib/esm/src/index.js +1 -1
  159. package/lib/esm/src/index.js.map +2 -2
  160. package/lib/esm/src/nft/data/HttpNftDataSource.test.js +1 -1
  161. package/lib/esm/src/nft/data/HttpNftDataSource.test.js.map +2 -2
  162. package/lib/esm/src/nft/domain/NftContextLoader.test.js +1 -1
  163. package/lib/esm/src/nft/domain/NftContextLoader.test.js.map +2 -2
  164. package/lib/esm/src/pki/data/HttpPkiCertificateDataSource.js +2 -0
  165. package/lib/esm/src/pki/data/HttpPkiCertificateDataSource.js.map +7 -0
  166. package/lib/esm/src/pki/data/HttpPkiCertificateDataSource.test.js +2 -0
  167. package/lib/esm/src/pki/data/HttpPkiCertificateDataSource.test.js.map +7 -0
  168. package/lib/esm/src/pki/data/PkiCertificateDataSource.js +1 -0
  169. package/lib/esm/src/pki/data/PkiCertificateDataSource.js.map +7 -0
  170. package/lib/esm/src/pki/data/pkiDataSourceTypes.js +1 -0
  171. package/lib/esm/src/pki/data/pkiDataSourceTypes.js.map +7 -0
  172. package/lib/esm/src/pki/di/pkiModuleFactory.js +2 -0
  173. package/lib/esm/src/pki/di/pkiModuleFactory.js.map +7 -0
  174. package/lib/esm/src/pki/di/pkiTypes.js +2 -0
  175. package/lib/esm/src/pki/di/pkiTypes.js.map +7 -0
  176. package/lib/esm/src/pki/domain/DefaultPkiCertificateLoader.js +2 -0
  177. package/lib/esm/src/pki/domain/DefaultPkiCertificateLoader.js.map +7 -0
  178. package/lib/esm/src/pki/domain/DefaultPkiCertificateLoader.test.js +2 -0
  179. package/lib/esm/src/pki/domain/DefaultPkiCertificateLoader.test.js.map +7 -0
  180. package/lib/esm/src/pki/domain/PkiCertificateLoader.js +1 -0
  181. package/lib/esm/src/pki/domain/PkiCertificateLoader.js.map +7 -0
  182. package/lib/esm/src/pki/model/KeyId.js +2 -0
  183. package/lib/esm/src/pki/model/KeyId.js.map +7 -0
  184. package/lib/esm/src/pki/model/KeyUsage.js +2 -0
  185. package/lib/esm/src/pki/model/KeyUsage.js.map +7 -0
  186. package/lib/esm/src/pki/model/PkiCertificate.js +1 -0
  187. package/lib/esm/src/pki/model/PkiCertificate.js.map +7 -0
  188. package/lib/esm/src/pki/model/PkiCertificateInfo.js +1 -0
  189. package/lib/esm/src/pki/model/PkiCertificateInfo.js.map +7 -0
  190. package/lib/esm/src/shared/model/ClearSignContext.js +1 -1
  191. package/lib/esm/src/shared/model/ClearSignContext.js.map +2 -2
  192. package/lib/esm/src/shared/model/GenericPath.js.map +1 -1
  193. package/lib/esm/src/shared/model/SignatureTags.js +2 -0
  194. package/lib/esm/src/shared/model/SignatureTags.js.map +7 -0
  195. package/lib/esm/src/shared/utils/HexStringUtils.js +1 -1
  196. package/lib/esm/src/shared/utils/HexStringUtils.js.map +3 -3
  197. package/lib/esm/src/shared/utils/HexStringUtils.test.js +2 -0
  198. package/lib/esm/src/shared/utils/HexStringUtils.test.js.map +7 -0
  199. package/lib/esm/src/shared/utils/KeyUsageMapper.js +2 -0
  200. package/lib/esm/src/shared/utils/KeyUsageMapper.js.map +7 -0
  201. package/lib/esm/src/shared/utils/KeyUsageMapper.test.js +2 -0
  202. package/lib/esm/src/shared/utils/KeyUsageMapper.test.js.map +7 -0
  203. package/lib/esm/src/token/data/HttpTokenDataSource.test.js +1 -1
  204. package/lib/esm/src/token/data/HttpTokenDataSource.test.js.map +2 -2
  205. package/lib/esm/src/token/domain/TokenContextLoader.test.js +1 -1
  206. package/lib/esm/src/token/domain/TokenContextLoader.test.js.map +2 -2
  207. package/lib/esm/src/transaction/data/HttpTransactionDataSource.js +1 -1
  208. package/lib/esm/src/transaction/data/HttpTransactionDataSource.js.map +3 -3
  209. package/lib/esm/src/transaction/data/HttpTransactionDataSource.test.js +1 -1
  210. package/lib/esm/src/transaction/data/HttpTransactionDataSource.test.js.map +3 -3
  211. package/lib/esm/src/transaction/domain/TransactionContextLoader.js +1 -1
  212. package/lib/esm/src/transaction/domain/TransactionContextLoader.js.map +2 -2
  213. package/lib/esm/src/transaction/domain/TransactionContextLoader.test.js +1 -1
  214. package/lib/esm/src/transaction/domain/TransactionContextLoader.test.js.map +2 -2
  215. package/lib/esm/src/trusted-name/data/HttpTrustedNameDataSource.test.js +1 -1
  216. package/lib/esm/src/trusted-name/data/HttpTrustedNameDataSource.test.js.map +2 -2
  217. package/lib/esm/src/trusted-name/domain/TrustedNameContextLoader.js +1 -1
  218. package/lib/esm/src/trusted-name/domain/TrustedNameContextLoader.js.map +2 -2
  219. package/lib/esm/src/trusted-name/domain/TrustedNameContextLoader.test.js +1 -1
  220. package/lib/esm/src/trusted-name/domain/TrustedNameContextLoader.test.js.map +2 -2
  221. package/lib/esm/src/typed-data/data/HttpTypedDataDataSource.test.js +1 -1
  222. package/lib/esm/src/typed-data/data/HttpTypedDataDataSource.test.js.map +2 -2
  223. package/lib/esm/src/typed-data/domain/DefaultTypedDataContextLoader.test.js +1 -1
  224. package/lib/esm/src/typed-data/domain/DefaultTypedDataContextLoader.test.js.map +2 -2
  225. package/lib/esm/src/uniswap/constants/plugin.js +2 -0
  226. package/lib/esm/src/uniswap/constants/plugin.js.map +7 -0
  227. package/lib/esm/src/uniswap/constants/uniswap.js +2 -0
  228. package/lib/esm/src/uniswap/constants/uniswap.js.map +7 -0
  229. package/lib/esm/src/uniswap/constants/weth.js +2 -0
  230. package/lib/esm/src/uniswap/constants/weth.js.map +7 -0
  231. package/lib/esm/src/uniswap/data/AbiDecoderDataSource.js +1 -0
  232. package/lib/esm/src/uniswap/data/AbiDecoderDataSource.js.map +7 -0
  233. package/lib/esm/src/uniswap/data/CommandDecoderDataSource.js +1 -0
  234. package/lib/esm/src/uniswap/data/CommandDecoderDataSource.js.map +7 -0
  235. package/lib/esm/src/uniswap/data/DefaultCommandDecoderDataSource.js +2 -0
  236. package/lib/esm/src/uniswap/data/DefaultCommandDecoderDataSource.js.map +7 -0
  237. package/lib/esm/src/uniswap/data/DefaultCommandDecoderDataSource.test.js +2 -0
  238. package/lib/esm/src/uniswap/data/DefaultCommandDecoderDataSource.test.js.map +7 -0
  239. package/lib/esm/src/uniswap/data/EthersAbiDecoderDataSource.js +2 -0
  240. package/lib/esm/src/uniswap/data/EthersAbiDecoderDataSource.js.map +7 -0
  241. package/lib/esm/src/uniswap/data/EthersAbiDecoderDataSource.test.js +2 -0
  242. package/lib/esm/src/uniswap/data/EthersAbiDecoderDataSource.test.js.map +7 -0
  243. package/lib/esm/src/uniswap/di/uniswapModuleFactory.js +2 -0
  244. package/lib/esm/src/uniswap/di/uniswapModuleFactory.js.map +7 -0
  245. package/lib/esm/src/uniswap/di/uniswapTypes.js +2 -0
  246. package/lib/esm/src/uniswap/di/uniswapTypes.js.map +7 -0
  247. package/lib/esm/src/uniswap/domain/UniswapContextLoader.js +2 -0
  248. package/lib/esm/src/uniswap/domain/UniswapContextLoader.js.map +7 -0
  249. package/lib/esm/src/uniswap/domain/UniswapContextLoader.test.js +2 -0
  250. package/lib/esm/src/uniswap/domain/UniswapContextLoader.test.js.map +7 -0
  251. package/lib/esm/src/web3-check/data/HttpWeb3CheckDataSource.js +2 -0
  252. package/lib/esm/src/web3-check/data/HttpWeb3CheckDataSource.js.map +7 -0
  253. package/lib/esm/src/web3-check/data/HttpWeb3CheckDataSource.test.js +2 -0
  254. package/lib/esm/src/web3-check/data/HttpWeb3CheckDataSource.test.js.map +7 -0
  255. package/lib/esm/src/web3-check/data/Web3CheckDataSource.js +1 -0
  256. package/lib/esm/src/web3-check/data/Web3CheckDataSource.js.map +7 -0
  257. package/lib/esm/src/web3-check/data/Web3CheckDto.js +1 -0
  258. package/lib/esm/src/web3-check/data/Web3CheckDto.js.map +7 -0
  259. package/lib/esm/src/web3-check/di/web3CheckModuleFactory.js +2 -0
  260. package/lib/esm/src/web3-check/di/web3CheckModuleFactory.js.map +7 -0
  261. package/lib/esm/src/web3-check/di/web3CheckTypes.js +2 -0
  262. package/lib/esm/src/web3-check/di/web3CheckTypes.js.map +7 -0
  263. package/lib/esm/src/web3-check/domain/DefaultWeb3CheckLoader.js +2 -0
  264. package/lib/esm/src/web3-check/domain/DefaultWeb3CheckLoader.js.map +7 -0
  265. package/lib/esm/src/web3-check/domain/DefaultWeb3CheckLoader.test.js +2 -0
  266. package/lib/esm/src/web3-check/domain/DefaultWeb3CheckLoader.test.js.map +7 -0
  267. package/lib/esm/src/web3-check/domain/Web3CheckContextLoader.js +1 -0
  268. package/lib/esm/src/web3-check/domain/Web3CheckContextLoader.js.map +7 -0
  269. package/lib/esm/src/web3-check/domain/web3CheckTypes.js +1 -0
  270. package/lib/esm/src/web3-check/domain/web3CheckTypes.js.map +7 -0
  271. package/lib/types/src/ContextModule.d.ts +2 -0
  272. package/lib/types/src/ContextModule.d.ts.map +1 -1
  273. package/lib/types/src/ContextModuleBuilder.d.ts +16 -1
  274. package/lib/types/src/ContextModuleBuilder.d.ts.map +1 -1
  275. package/lib/types/src/DefaultContextModule.d.ts +5 -1
  276. package/lib/types/src/DefaultContextModule.d.ts.map +1 -1
  277. package/lib/types/src/config/model/ContextModuleConfig.d.ts +6 -0
  278. package/lib/types/src/config/model/ContextModuleConfig.d.ts.map +1 -1
  279. package/lib/types/src/di.d.ts.map +1 -1
  280. package/lib/types/src/index.d.ts +7 -0
  281. package/lib/types/src/index.d.ts.map +1 -1
  282. package/lib/types/src/pki/data/HttpPkiCertificateDataSource.d.ts +12 -0
  283. package/lib/types/src/pki/data/HttpPkiCertificateDataSource.d.ts.map +1 -0
  284. package/lib/types/src/pki/data/HttpPkiCertificateDataSource.test.d.ts +2 -0
  285. package/lib/types/src/pki/data/HttpPkiCertificateDataSource.test.d.ts.map +1 -0
  286. package/lib/types/src/pki/data/PkiCertificateDataSource.d.ts +7 -0
  287. package/lib/types/src/pki/data/PkiCertificateDataSource.d.ts.map +1 -0
  288. package/lib/types/src/pki/data/pkiDataSourceTypes.d.ts +23 -0
  289. package/lib/types/src/pki/data/pkiDataSourceTypes.d.ts.map +1 -0
  290. package/lib/types/src/pki/di/pkiModuleFactory.d.ts +3 -0
  291. package/lib/types/src/pki/di/pkiModuleFactory.d.ts.map +1 -0
  292. package/lib/types/src/pki/di/pkiTypes.d.ts +5 -0
  293. package/lib/types/src/pki/di/pkiTypes.d.ts.map +1 -0
  294. package/lib/types/src/pki/domain/DefaultPkiCertificateLoader.d.ts +10 -0
  295. package/lib/types/src/pki/domain/DefaultPkiCertificateLoader.d.ts.map +1 -0
  296. package/lib/types/src/pki/domain/DefaultPkiCertificateLoader.test.d.ts +2 -0
  297. package/lib/types/src/pki/domain/DefaultPkiCertificateLoader.test.d.ts.map +1 -0
  298. package/lib/types/src/pki/domain/PkiCertificateLoader.d.ts +6 -0
  299. package/lib/types/src/pki/domain/PkiCertificateLoader.d.ts.map +1 -0
  300. package/lib/types/src/pki/model/KeyId.d.ts +14 -0
  301. package/lib/types/src/pki/model/KeyId.d.ts.map +1 -0
  302. package/lib/types/src/pki/model/KeyUsage.d.ts +15 -0
  303. package/lib/types/src/pki/model/KeyUsage.d.ts.map +1 -0
  304. package/lib/types/src/pki/model/PkiCertificate.d.ts +5 -0
  305. package/lib/types/src/pki/model/PkiCertificate.d.ts.map +1 -0
  306. package/lib/types/src/pki/model/PkiCertificateInfo.d.ts +7 -0
  307. package/lib/types/src/pki/model/PkiCertificateInfo.d.ts.map +1 -0
  308. package/lib/types/src/shared/model/ClearSignContext.d.ts +25 -13
  309. package/lib/types/src/shared/model/ClearSignContext.d.ts.map +1 -1
  310. package/lib/types/src/shared/model/GenericPath.d.ts +2 -2
  311. package/lib/types/src/shared/model/GenericPath.d.ts.map +1 -1
  312. package/lib/types/src/shared/model/SignatureTags.d.ts +3 -0
  313. package/lib/types/src/shared/model/SignatureTags.d.ts.map +1 -0
  314. package/lib/types/src/shared/model/TransactionContext.d.ts +3 -1
  315. package/lib/types/src/shared/model/TransactionContext.d.ts.map +1 -1
  316. package/lib/types/src/shared/model/TransactionSubset.d.ts +2 -0
  317. package/lib/types/src/shared/model/TransactionSubset.d.ts.map +1 -1
  318. package/lib/types/src/shared/utils/HexStringUtils.d.ts +1 -0
  319. package/lib/types/src/shared/utils/HexStringUtils.d.ts.map +1 -1
  320. package/lib/types/src/shared/utils/HexStringUtils.test.d.ts +2 -0
  321. package/lib/types/src/shared/utils/HexStringUtils.test.d.ts.map +1 -0
  322. package/lib/types/src/shared/utils/KeyUsageMapper.d.ts +6 -0
  323. package/lib/types/src/shared/utils/KeyUsageMapper.d.ts.map +1 -0
  324. package/lib/types/src/shared/utils/KeyUsageMapper.test.d.ts +2 -0
  325. package/lib/types/src/shared/utils/KeyUsageMapper.test.d.ts.map +1 -0
  326. package/lib/types/src/transaction/data/CalldataDto.d.ts +15 -4
  327. package/lib/types/src/transaction/data/CalldataDto.d.ts.map +1 -1
  328. package/lib/types/src/transaction/data/HttpTransactionDataSource.d.ts +8 -4
  329. package/lib/types/src/transaction/data/HttpTransactionDataSource.d.ts.map +1 -1
  330. package/lib/types/src/transaction/data/TransactionDataSource.d.ts +2 -1
  331. package/lib/types/src/transaction/data/TransactionDataSource.d.ts.map +1 -1
  332. package/lib/types/src/transaction/domain/TransactionContextLoader.d.ts.map +1 -1
  333. package/lib/types/src/uniswap/constants/plugin.d.ts +3 -0
  334. package/lib/types/src/uniswap/constants/plugin.d.ts.map +1 -0
  335. package/lib/types/src/uniswap/constants/uniswap.d.ts +21 -0
  336. package/lib/types/src/uniswap/constants/uniswap.d.ts.map +1 -0
  337. package/lib/types/src/uniswap/constants/weth.d.ts +20 -0
  338. package/lib/types/src/uniswap/constants/weth.d.ts.map +1 -0
  339. package/lib/types/src/uniswap/data/AbiDecoderDataSource.d.ts +5 -0
  340. package/lib/types/src/uniswap/data/AbiDecoderDataSource.d.ts.map +1 -0
  341. package/lib/types/src/uniswap/data/CommandDecoderDataSource.d.ts +6 -0
  342. package/lib/types/src/uniswap/data/CommandDecoderDataSource.d.ts.map +1 -0
  343. package/lib/types/src/uniswap/data/DefaultCommandDecoderDataSource.d.ts +14 -0
  344. package/lib/types/src/uniswap/data/DefaultCommandDecoderDataSource.d.ts.map +1 -0
  345. package/lib/types/src/uniswap/data/DefaultCommandDecoderDataSource.test.d.ts +2 -0
  346. package/lib/types/src/uniswap/data/DefaultCommandDecoderDataSource.test.d.ts.map +1 -0
  347. package/lib/types/src/uniswap/data/EthersAbiDecoderDataSource.d.ts +5 -0
  348. package/lib/types/src/uniswap/data/EthersAbiDecoderDataSource.d.ts.map +1 -0
  349. package/lib/types/src/uniswap/data/EthersAbiDecoderDataSource.test.d.ts +2 -0
  350. package/lib/types/src/uniswap/data/EthersAbiDecoderDataSource.test.d.ts.map +1 -0
  351. package/lib/types/src/uniswap/di/uniswapModuleFactory.d.ts +3 -0
  352. package/lib/types/src/uniswap/di/uniswapModuleFactory.d.ts.map +1 -0
  353. package/lib/types/src/uniswap/di/uniswapTypes.d.ts +6 -0
  354. package/lib/types/src/uniswap/di/uniswapTypes.d.ts.map +1 -0
  355. package/lib/types/src/uniswap/domain/UniswapContextLoader.d.ts +105 -0
  356. package/lib/types/src/uniswap/domain/UniswapContextLoader.d.ts.map +1 -0
  357. package/lib/types/src/uniswap/domain/UniswapContextLoader.test.d.ts +2 -0
  358. package/lib/types/src/uniswap/domain/UniswapContextLoader.test.d.ts.map +1 -0
  359. package/lib/types/src/web3-check/data/HttpWeb3CheckDataSource.d.ts +14 -0
  360. package/lib/types/src/web3-check/data/HttpWeb3CheckDataSource.d.ts.map +1 -0
  361. package/lib/types/src/web3-check/data/HttpWeb3CheckDataSource.test.d.ts +2 -0
  362. package/lib/types/src/web3-check/data/HttpWeb3CheckDataSource.test.d.ts.map +1 -0
  363. package/lib/types/src/web3-check/data/Web3CheckDataSource.d.ts +6 -0
  364. package/lib/types/src/web3-check/data/Web3CheckDataSource.d.ts.map +1 -0
  365. package/lib/types/src/web3-check/data/Web3CheckDto.d.ts +20 -0
  366. package/lib/types/src/web3-check/data/Web3CheckDto.d.ts.map +1 -0
  367. package/lib/types/src/web3-check/di/web3CheckModuleFactory.d.ts +3 -0
  368. package/lib/types/src/web3-check/di/web3CheckModuleFactory.d.ts.map +1 -0
  369. package/lib/types/src/web3-check/di/web3CheckTypes.d.ts +5 -0
  370. package/lib/types/src/web3-check/di/web3CheckTypes.d.ts.map +1 -0
  371. package/lib/types/src/web3-check/domain/DefaultWeb3CheckLoader.d.ts +10 -0
  372. package/lib/types/src/web3-check/domain/DefaultWeb3CheckLoader.d.ts.map +1 -0
  373. package/lib/types/src/web3-check/domain/DefaultWeb3CheckLoader.test.d.ts +2 -0
  374. package/lib/types/src/web3-check/domain/DefaultWeb3CheckLoader.test.d.ts.map +1 -0
  375. package/lib/types/src/web3-check/domain/Web3CheckContextLoader.d.ts +6 -0
  376. package/lib/types/src/web3-check/domain/Web3CheckContextLoader.d.ts.map +1 -0
  377. package/lib/types/src/web3-check/domain/web3CheckTypes.d.ts +35 -0
  378. package/lib/types/src/web3-check/domain/web3CheckTypes.d.ts.map +1 -0
  379. package/lib/types/tsconfig.prod.tsbuildinfo +1 -1
  380. package/package.json +11 -10
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../../src/external-plugin/domain/ExternalPluginContextLoader.test.ts"],
4
- "sourcesContent": ["import { Interface } from \"ethers\";\nimport { Left, Right } from \"purify-ts\";\n\nimport ABI from \"@/external-plugin/__tests__/abi.json\";\nimport { type ExternalPluginDataSource } from \"@/external-plugin/data/ExternalPluginDataSource\";\nimport { ExternalPluginContextLoader } from \"@/external-plugin/domain/ExternalPluginContextLoader\";\nimport { type DappInfos } from \"@/external-plugin/model/DappInfos\";\nimport { type SelectorDetails } from \"@/external-plugin/model/SelectorDetails\";\nimport { ClearSignContextType } from \"@/shared/model/ClearSignContext\";\nimport { type TransactionContext } from \"@/shared/model/TransactionContext\";\nimport { type TokenDataSource } from \"@/token/data/TokenDataSource\";\n\nconst dappInfosBuilder = ({\n abi,\n selectorDetails,\n}: {\n abi?: object[];\n selectorDetails?: Partial<SelectorDetails>;\n}) => {\n return {\n abi: abi,\n selectorDetails: {\n erc20OfInterest: [],\n method: \"\",\n plugin: \"\",\n serializedData: \"123456\",\n signature: \"7890\",\n ...selectorDetails,\n },\n } as DappInfos;\n};\n\nconst transactionBuilder = (\n abi: object,\n functionName: string,\n params: unknown[],\n): TransactionContext => {\n const contract = new Interface(JSON.stringify(abi));\n const data = contract.encodeFunctionData(functionName, params);\n return {\n to: \"0x0\",\n data,\n } as TransactionContext;\n};\n\ndescribe(\"ExternalPluginContextLoader\", () => {\n const mockTokenDataSource: TokenDataSource = {\n getTokenInfosPayload: jest.fn(),\n };\n const mockExternalPluginDataSource: ExternalPluginDataSource = {\n getDappInfos: jest.fn(),\n };\n const loader = new ExternalPluginContextLoader(\n mockExternalPluginDataSource,\n mockTokenDataSource,\n );\n\n beforeEach(() => {\n jest.clearAllMocks();\n jest\n .spyOn(mockTokenDataSource, \"getTokenInfosPayload\")\n .mockImplementation(({ address }) =>\n Promise.resolve(Right(`payload-${address}`)),\n );\n });\n\n describe(\"load function\", () => {\n it(\"should return an empty array if no destination address is provided\", () => {\n // GIVEN\n const transaction = {} as TransactionContext;\n\n // WHEN\n const promise = () => loader.load(transaction);\n\n // THEN\n expect(promise()).resolves.toEqual([]);\n });\n\n it(\"should return an empty array if data is undefined\", async () => {\n // GIVEN\n const transaction = { to: \"0x0\" } as TransactionContext;\n\n // WHEN\n const result = await loader.load(transaction);\n\n // THEN\n expect(result).toEqual([]);\n });\n\n it(\"should return an empty array if no data provided\", async () => {\n // GIVEN\n const transaction = { to: \"0x0\", data: \"0x\" } as TransactionContext;\n\n // WHEN\n const result = await loader.load(transaction);\n\n // THEN\n expect(result).toEqual([]);\n });\n\n it(\"should return an empty array if no dapp info is povided\", async () => {\n // GIVEN\n const transaction = transactionBuilder(ABI, \"singleParam\", [\n \"0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48\",\n ]);\n jest\n .spyOn(mockExternalPluginDataSource, \"getDappInfos\")\n .mockResolvedValue(Right(undefined));\n\n // WHEN\n const result = await loader.load(transaction);\n\n // THEN\n expect(result).toEqual([]);\n });\n\n it(\"should return e plugin if no erc20OfInterest is provided\", async () => {\n // GIVEN\n const dappInfos = dappInfosBuilder({\n abi: ABI,\n selectorDetails: {\n erc20OfInterest: [],\n method: \"singleParam\",\n },\n });\n const transaction = transactionBuilder(ABI, \"singleParam\", [\n \"0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48\",\n ]);\n jest\n .spyOn(mockExternalPluginDataSource, \"getDappInfos\")\n .mockResolvedValue(Right(dappInfos));\n\n // WHEN\n const result = await loader.load(transaction);\n\n // THEN\n expect(result).toEqual([\n {\n type: ClearSignContextType.EXTERNAL_PLUGIN,\n payload: \"1234567890\",\n },\n ]);\n });\n\n it(\"should return a list of context responses when one erc20OfInterest is provided for a single parameter\", async () => {\n // GIVEN\n const dappInfos = dappInfosBuilder({\n abi: ABI,\n selectorDetails: {\n erc20OfInterest: [\"fromToken\"],\n method: \"singleParam\",\n },\n });\n const transaction = transactionBuilder(ABI, \"singleParam\", [\n \"0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48\",\n ]);\n jest\n .spyOn(mockExternalPluginDataSource, \"getDappInfos\")\n .mockResolvedValue(Right(dappInfos));\n\n // WHEN\n const result = await loader.load(transaction);\n\n // THEN\n expect(result).toEqual(\n expect.arrayContaining([\n {\n type: ClearSignContextType.EXTERNAL_PLUGIN,\n payload: \"1234567890\",\n },\n {\n type: ClearSignContextType.TOKEN,\n payload: \"payload-0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48\",\n },\n ]),\n );\n });\n\n it(\"should return a context response with only set external plugin when one erc20OfInterest is provided for a single parameter but no payload is feched\", async () => {\n // GIVEN\n const dappInfos = dappInfosBuilder({\n abi: ABI,\n selectorDetails: {\n erc20OfInterest: [\"fromToken\"],\n method: \"singleParam\",\n },\n });\n const transaction = transactionBuilder(ABI, \"singleParam\", [\n \"0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48\",\n ]);\n jest\n .spyOn(mockExternalPluginDataSource, \"getDappInfos\")\n .mockResolvedValue(Right(dappInfos));\n jest\n .spyOn(mockTokenDataSource, \"getTokenInfosPayload\")\n .mockResolvedValue(Left(Error(\"error\")));\n\n // WHEN\n const result = await loader.load(transaction);\n\n // THEN\n expect(result).toEqual([\n {\n type: ClearSignContextType.ERROR,\n error: new Error(\"error\"),\n },\n {\n type: ClearSignContextType.EXTERNAL_PLUGIN,\n payload: \"1234567890\",\n },\n ]);\n });\n\n it(\"should return a list of context responses when two erc20OfInterest are provided for two parameters\", async () => {\n // GIVEN\n const dappInfos = dappInfosBuilder({\n abi: ABI,\n selectorDetails: {\n erc20OfInterest: [\"fromToken\", \"toToken\"],\n method: \"multipleParams\",\n },\n });\n const transaction = transactionBuilder(ABI, \"multipleParams\", [\n \"0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48\",\n \"0xdAC17F958D2ee523a2206206994597C13D831ec7\",\n ]);\n jest\n .spyOn(mockExternalPluginDataSource, \"getDappInfos\")\n .mockResolvedValue(Right(dappInfos));\n\n // WHEN\n const result = await loader.load(transaction);\n\n // THEN\n expect(result).toEqual(\n expect.arrayContaining([\n {\n type: ClearSignContextType.EXTERNAL_PLUGIN,\n payload: \"1234567890\",\n },\n {\n type: ClearSignContextType.TOKEN,\n payload: \"payload-0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48\",\n },\n {\n type: ClearSignContextType.TOKEN,\n payload: \"payload-0xdAC17F958D2ee523a2206206994597C13D831ec7\",\n },\n ]),\n );\n });\n\n it(\"should return a list of context responses when one erc20OfInterest is an array\", async () => {\n // GIVEN\n const dappInfos = dappInfosBuilder({\n abi: ABI,\n selectorDetails: {\n erc20OfInterest: [\n \"fromToken.0\",\n \"fromToken.1\",\n \"fromToken.2\",\n \"fromToken.-1\",\n ],\n method: \"arrayParam\",\n },\n });\n const transaction = transactionBuilder(ABI, \"arrayParam\", [\n [\n \"0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48\",\n \"0xdAC17F958D2ee523a2206206994597C13D831ec7\",\n \"0xB8c77482e45F1F44dE1745F52C74426C631bDD52\",\n ],\n ]);\n jest\n .spyOn(mockExternalPluginDataSource, \"getDappInfos\")\n .mockResolvedValue(Right(dappInfos));\n\n // WHEN\n const result = await loader.load(transaction);\n\n // THEN\n expect(result).toEqual([\n {\n type: ClearSignContextType.TOKEN,\n payload: \"payload-0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48\",\n },\n {\n type: ClearSignContextType.TOKEN,\n payload: \"payload-0xdAC17F958D2ee523a2206206994597C13D831ec7\",\n },\n // fromToken.2\n {\n type: ClearSignContextType.TOKEN,\n payload: \"payload-0xB8c77482e45F1F44dE1745F52C74426C631bDD52\",\n },\n // fromToken.-1\n {\n type: ClearSignContextType.TOKEN,\n payload: \"payload-0xB8c77482e45F1F44dE1745F52C74426C631bDD52\",\n },\n {\n type: ClearSignContextType.EXTERNAL_PLUGIN,\n payload: \"1234567890\",\n },\n ]);\n });\n\n it(\"should return an error when a token datasource returns an error\", async () => {\n // GIVEN\n const dappInfos = dappInfosBuilder({\n abi: ABI,\n selectorDetails: {\n erc20OfInterest: [\"fromToken\"],\n method: \"singleParam\",\n },\n });\n const transaction = transactionBuilder(ABI, \"singleParam\", [\n \"0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48\",\n ]);\n jest\n .spyOn(mockExternalPluginDataSource, \"getDappInfos\")\n .mockResolvedValue(Right(dappInfos));\n jest\n .spyOn(mockTokenDataSource, \"getTokenInfosPayload\")\n .mockResolvedValue(Left(new Error(\"error\")));\n\n // WHEN\n const result = await loader.load(transaction);\n\n // THEN\n expect(result).toEqual([\n {\n type: ClearSignContextType.ERROR,\n error: new Error(\"error\"),\n },\n {\n type: ClearSignContextType.EXTERNAL_PLUGIN,\n payload: \"1234567890\",\n },\n ]);\n });\n\n it(\"should return an error when the abi is not conform\", async () => {\n // GIVEN\n const dappInfos = dappInfosBuilder({\n abi: [{ fakeabi: \"notworking\" }],\n selectorDetails: {\n erc20OfInterest: [\"fromToken\"],\n method: \"singleParam\",\n },\n });\n const transaction = transactionBuilder(ABI, \"singleParam\", [\n \"0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48\",\n ]);\n jest\n .spyOn(mockExternalPluginDataSource, \"getDappInfos\")\n .mockResolvedValue(Right(dappInfos));\n\n // WHEN\n const result = await loader.load(transaction);\n\n // THEN\n expect(result).toEqual([\n {\n type: ClearSignContextType.ERROR,\n error: new Error(\n \"[ContextModule] ExternalPluginContextLoader: Unable to parse abi\",\n ),\n },\n {\n type: ClearSignContextType.EXTERNAL_PLUGIN,\n payload: \"1234567890\",\n },\n ]);\n });\n\n it(\"should throw an error when the erc20OfInterest doest not exist in the transaction\", async () => {\n // GIVEN\n const dappInfos = dappInfosBuilder({\n abi: ABI,\n selectorDetails: {\n erc20OfInterest: [\"notFound\"],\n method: \"singleParam\",\n },\n });\n const transaction = transactionBuilder(ABI, \"singleParam\", [\n \"0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48\",\n ]);\n jest\n .spyOn(mockExternalPluginDataSource, \"getDappInfos\")\n .mockResolvedValue(Right(dappInfos));\n\n // WHEN\n const result = await loader.load(transaction);\n\n // THEN\n expect(result).toEqual([\n {\n type: ClearSignContextType.ERROR,\n error: new Error(\n \"[ContextModule] ExternalPluginContextLoader: Unable to get address\",\n ),\n },\n ]);\n });\n\n it(\"should throw an error when an out-of-bounds element is present in erc20OfInterest\", async () => {\n // GIVEN\n const dappInfos = dappInfosBuilder({\n abi: ABI,\n selectorDetails: {\n erc20OfInterest: [\"fromToken.3\"],\n method: \"arrayParam\",\n },\n });\n const transaction = transactionBuilder(ABI, \"arrayParam\", [\n [\n \"0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48\",\n \"0xdAC17F958D2ee523a2206206994597C13D831ec7\",\n \"0xB8c77482e45F1F44dE1745F52C74426C631bDD52\",\n ],\n ]);\n jest\n .spyOn(mockExternalPluginDataSource, \"getDappInfos\")\n .mockResolvedValue(Right(dappInfos));\n\n // WHEN\n const result = await loader.load(transaction);\n\n // THEN\n expect(result).toEqual([\n {\n type: ClearSignContextType.ERROR,\n error: new RangeError(\"out of result range\"),\n },\n ]);\n });\n\n it(\"should return a list of context responses when one erc20OfInterest is a complex struct\", async () => {\n // GIVEN\n const dappInfos = dappInfosBuilder({\n abi: ABI,\n selectorDetails: {\n erc20OfInterest: [\n \"complexStruct.address1\",\n \"complexStruct.param1.param2.0.param3.addresses.0\",\n \"complexStruct.param1.param2.0.param3.addresses.1\",\n \"complexStruct.param1.param2.0.param3.addresses.-1\",\n \"complexStruct.param1.param2.1.param3.addresses.0\",\n \"complexStruct.param1.param2.-1.param3.addresses.0\",\n ],\n method: \"complexStructParam\",\n },\n });\n const transaction = transactionBuilder(ABI, \"complexStructParam\", [\n {\n address1: \"0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48\",\n param1: {\n param2: [\n {\n param3: {\n addresses: [\n \"0xdAC17F958D2ee523a2206206994597C13D831ec7\",\n \"0x95aD61b0a150d79219dCF64E1E6Cc01f0B64C4cE\",\n ],\n },\n },\n {\n param3: {\n addresses: [\"0xB8c77482e45F1F44dE1745F52C74426C631bDD52\"],\n },\n },\n ],\n },\n },\n ]);\n jest\n .spyOn(mockExternalPluginDataSource, \"getDappInfos\")\n .mockResolvedValue(Right(dappInfos));\n\n // WHEN\n const result = await loader.load(transaction);\n\n // THEN\n expect(result).toEqual([\n {\n type: ClearSignContextType.TOKEN,\n payload: \"payload-0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48\",\n },\n {\n type: ClearSignContextType.TOKEN,\n payload: \"payload-0xdAC17F958D2ee523a2206206994597C13D831ec7\",\n },\n {\n type: ClearSignContextType.TOKEN,\n payload: \"payload-0x95aD61b0a150d79219dCF64E1E6Cc01f0B64C4cE\",\n },\n {\n type: ClearSignContextType.TOKEN,\n payload: \"payload-0x95aD61b0a150d79219dCF64E1E6Cc01f0B64C4cE\",\n },\n {\n type: ClearSignContextType.TOKEN,\n payload: \"payload-0xB8c77482e45F1F44dE1745F52C74426C631bDD52\",\n },\n {\n type: ClearSignContextType.TOKEN,\n payload: \"payload-0xB8c77482e45F1F44dE1745F52C74426C631bDD52\",\n },\n {\n type: ClearSignContextType.EXTERNAL_PLUGIN,\n payload: \"1234567890\",\n },\n ]);\n });\n\n it(\"should return an error when datasource return a Left\", async () => {\n // GIVEN\n const transaction = transactionBuilder(ABI, \"singleParam\", [\n \"0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48\",\n ]);\n jest\n .spyOn(mockExternalPluginDataSource, \"getDappInfos\")\n .mockResolvedValue(Left(new Error(\"error\")));\n\n // WHEN\n const result = await loader.load(transaction);\n\n // THEN\n expect(result).toEqual([\n {\n type: ClearSignContextType.ERROR,\n error: new Error(\"error\"),\n },\n ]);\n });\n\n it(\"should return an error when transaction data is not a valid hex string\", async () => {\n // GIVEN\n const transaction = {\n to: \"0x0\",\n data: \"notAHexString\",\n } as TransactionContext;\n\n // WHEN\n const result = await loader.load(transaction);\n\n // THEN\n expect(result).toEqual([\n {\n type: ClearSignContextType.ERROR,\n error: new Error(\"Invalid selector\"),\n },\n ]);\n });\n });\n});\n"],
5
- "mappings": "wdAAA,IAAAA,EAA0B,kBAC1BC,EAA4B,qBAE5BC,EAAgB,mDAEhBC,EAA4C,gEAG5CC,EAAqC,2CAIrC,MAAMC,EAAmB,CAAC,CACxB,IAAAC,EACA,gBAAAC,CACF,KAIS,CACL,IAAKD,EACL,gBAAiB,CACf,gBAAiB,CAAC,EAClB,OAAQ,GACR,OAAQ,GACR,eAAgB,SAChB,UAAW,OACX,GAAGC,CACL,CACF,GAGIC,EAAqB,CACzBF,EACAG,EACAC,KAIO,CACL,GAAI,MACJ,KAJe,IAAI,YAAU,KAAK,UAAUJ,CAAG,CAAC,EAC5B,mBAAmBG,EAAcC,CAAM,CAI7D,GAGF,SAAS,8BAA+B,IAAM,CAC5C,MAAMC,EAAuC,CAC3C,qBAAsB,KAAK,GAAG,CAChC,EACMC,EAAyD,CAC7D,aAAc,KAAK,GAAG,CACxB,EACMC,EAAS,IAAI,8BACjBD,EACAD,CACF,EAEA,WAA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AS,oDACX,EACA,CACE,KAAM,uBAAqB,MAC3B,QAAS,oDACX,EACA,CACE,KAAM,uBAAqB,MAC3B,QAAS,oDACX,EACA,CACE,KAAM,uBAAqB,gBAC3B,QAAS,YACX,CACF,CAAC,CACH,CAAC,EAED,GAAG,uDAAwD,SAAY,CAErE,MAAMF,EAAcP,EAAmB,EAAAU,QAAK,cAAe,CACzD,4CACF,CAAC,EACD,KACG,MAAMN,EAA8B,cAAc,EAClD,qBAAkB,QAAK,IAAI,MAAM,OAAO,CAAC,CAAC,EAG7C,MAAMK,EAAS,MAAMJ,EAAO,KAAKE,CAAW,EAG5C,OAAOE,CAAM,EAAE,QAAQ,CACrB,CACE,KAAM,uBAAqB,MAC3B,MAAO,IAAI,MAAM,OAAO,CAC1B,CACF,CAAC,CACH,CAAC,EAED,GAAG,yEAA0E,SAAY,CAEvF,MAAMF,EAAc,CAClB,GAAI,MACJ,KAAM,eACR,EAGME,EAAS,MAAMJ,EAAO,KAAKE,CAAW,EAG5C,OAAOE,CAAM,EAAE,QAAQ,CACrB,CACE,KAAM,uBAAqB,MAC3B,MAAO,IAAI,MAAM,kBAAkB,CACrC,CACF,CAAC,CACH,CAAC,CACH,CAAC,CACH,CAAC",
4
+ "sourcesContent": ["import { Interface } from \"ethers\";\nimport { Left, Right } from \"purify-ts\";\n\nimport ABI from \"@/external-plugin/__tests__/abi.json\";\nimport { type ExternalPluginDataSource } from \"@/external-plugin/data/ExternalPluginDataSource\";\nimport { ExternalPluginContextLoader } from \"@/external-plugin/domain/ExternalPluginContextLoader\";\nimport { type DappInfos } from \"@/external-plugin/model/DappInfos\";\nimport { type SelectorDetails } from \"@/external-plugin/model/SelectorDetails\";\nimport { ClearSignContextType } from \"@/shared/model/ClearSignContext\";\nimport { type TransactionContext } from \"@/shared/model/TransactionContext\";\nimport { type TokenDataSource } from \"@/token/data/TokenDataSource\";\n\nconst dappInfosBuilder = ({\n abi,\n selectorDetails,\n}: {\n abi?: object[];\n selectorDetails?: Partial<SelectorDetails>;\n}) => {\n return {\n abi: abi,\n selectorDetails: {\n erc20OfInterest: [],\n method: \"\",\n plugin: \"\",\n serializedData: \"123456\",\n signature: \"7890\",\n ...selectorDetails,\n },\n } as DappInfos;\n};\n\nconst transactionBuilder = (\n abi: object,\n functionName: string,\n params: unknown[],\n): TransactionContext => {\n const contract = new Interface(JSON.stringify(abi));\n const data = contract.encodeFunctionData(functionName, params);\n return {\n to: \"0x0\",\n data,\n } as TransactionContext;\n};\n\ndescribe(\"ExternalPluginContextLoader\", () => {\n const mockTokenDataSource: TokenDataSource = {\n getTokenInfosPayload: vi.fn(),\n };\n const mockExternalPluginDataSource: ExternalPluginDataSource = {\n getDappInfos: vi.fn(),\n };\n const loader = new ExternalPluginContextLoader(\n mockExternalPluginDataSource,\n mockTokenDataSource,\n );\n\n beforeEach(() => {\n vi.clearAllMocks();\n vi.spyOn(mockTokenDataSource, \"getTokenInfosPayload\").mockImplementation(\n ({ address }) => Promise.resolve(Right(`payload-${address}`)),\n );\n });\n\n describe(\"load function\", async () => {\n it(\"should return an empty array if no destination address is provided\", async () => {\n // GIVEN\n const transaction = {} as TransactionContext;\n\n // WHEN\n const promise = () => loader.load(transaction);\n\n // THEN\n await expect(promise()).resolves.toEqual([]);\n });\n\n it(\"should return an empty array if data is undefined\", async () => {\n // GIVEN\n const transaction = { to: \"0x0\" } as TransactionContext;\n\n // WHEN\n const result = await loader.load(transaction);\n\n // THEN\n expect(result).toEqual([]);\n });\n\n it(\"should return an empty array if no data provided\", async () => {\n // GIVEN\n const transaction = { to: \"0x0\", data: \"0x\" } as TransactionContext;\n\n // WHEN\n const result = await loader.load(transaction);\n\n // THEN\n expect(result).toEqual([]);\n });\n\n it(\"should return an empty array if no dapp info is povided\", async () => {\n // GIVEN\n const transaction = transactionBuilder(ABI, \"singleParam\", [\n \"0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48\",\n ]);\n vi.spyOn(mockExternalPluginDataSource, \"getDappInfos\").mockResolvedValue(\n Right(undefined),\n );\n\n // WHEN\n const result = await loader.load(transaction);\n\n // THEN\n expect(result).toEqual([]);\n });\n\n it(\"should return e plugin if no erc20OfInterest is provided\", async () => {\n // GIVEN\n const dappInfos = dappInfosBuilder({\n abi: ABI,\n selectorDetails: {\n erc20OfInterest: [],\n method: \"singleParam\",\n },\n });\n const transaction = transactionBuilder(ABI, \"singleParam\", [\n \"0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48\",\n ]);\n vi.spyOn(mockExternalPluginDataSource, \"getDappInfos\").mockResolvedValue(\n Right(dappInfos),\n );\n\n // WHEN\n const result = await loader.load(transaction);\n\n // THEN\n expect(result).toEqual([\n {\n type: ClearSignContextType.EXTERNAL_PLUGIN,\n payload: \"1234567890\",\n },\n ]);\n });\n\n it(\"should return a list of context responses when one erc20OfInterest is provided for a single parameter\", async () => {\n // GIVEN\n const dappInfos = dappInfosBuilder({\n abi: ABI,\n selectorDetails: {\n erc20OfInterest: [\"fromToken\"],\n method: \"singleParam\",\n },\n });\n const transaction = transactionBuilder(ABI, \"singleParam\", [\n \"0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48\",\n ]);\n vi.spyOn(mockExternalPluginDataSource, \"getDappInfos\").mockResolvedValue(\n Right(dappInfos),\n );\n\n // WHEN\n const result = await loader.load(transaction);\n\n // THEN\n expect(result).toEqual(\n expect.arrayContaining([\n {\n type: ClearSignContextType.EXTERNAL_PLUGIN,\n payload: \"1234567890\",\n },\n {\n type: ClearSignContextType.TOKEN,\n payload: \"payload-0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48\",\n },\n ]),\n );\n });\n\n it(\"should return a context response with only set external plugin when one erc20OfInterest is provided for a single parameter but no payload is feched\", async () => {\n // GIVEN\n const dappInfos = dappInfosBuilder({\n abi: ABI,\n selectorDetails: {\n erc20OfInterest: [\"fromToken\"],\n method: \"singleParam\",\n },\n });\n const transaction = transactionBuilder(ABI, \"singleParam\", [\n \"0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48\",\n ]);\n vi.spyOn(mockExternalPluginDataSource, \"getDappInfos\").mockResolvedValue(\n Right(dappInfos),\n );\n vi.spyOn(mockTokenDataSource, \"getTokenInfosPayload\").mockResolvedValue(\n Left(Error(\"error\")),\n );\n\n // WHEN\n const result = await loader.load(transaction);\n\n // THEN\n expect(result).toEqual([\n {\n type: ClearSignContextType.ERROR,\n error: new Error(\"error\"),\n },\n {\n type: ClearSignContextType.EXTERNAL_PLUGIN,\n payload: \"1234567890\",\n },\n ]);\n });\n\n it(\"should return a list of context responses when two erc20OfInterest are provided for two parameters\", async () => {\n // GIVEN\n const dappInfos = dappInfosBuilder({\n abi: ABI,\n selectorDetails: {\n erc20OfInterest: [\"fromToken\", \"toToken\"],\n method: \"multipleParams\",\n },\n });\n const transaction = transactionBuilder(ABI, \"multipleParams\", [\n \"0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48\",\n \"0xdAC17F958D2ee523a2206206994597C13D831ec7\",\n ]);\n vi.spyOn(mockExternalPluginDataSource, \"getDappInfos\").mockResolvedValue(\n Right(dappInfos),\n );\n\n // WHEN\n const result = await loader.load(transaction);\n\n // THEN\n expect(result).toEqual(\n expect.arrayContaining([\n {\n type: ClearSignContextType.EXTERNAL_PLUGIN,\n payload: \"1234567890\",\n },\n {\n type: ClearSignContextType.TOKEN,\n payload: \"payload-0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48\",\n },\n {\n type: ClearSignContextType.TOKEN,\n payload: \"payload-0xdAC17F958D2ee523a2206206994597C13D831ec7\",\n },\n ]),\n );\n });\n\n it(\"should return a list of context responses when one erc20OfInterest is an array\", async () => {\n // GIVEN\n const dappInfos = dappInfosBuilder({\n abi: ABI,\n selectorDetails: {\n erc20OfInterest: [\n \"fromToken.0\",\n \"fromToken.1\",\n \"fromToken.2\",\n \"fromToken.-1\",\n ],\n method: \"arrayParam\",\n },\n });\n const transaction = transactionBuilder(ABI, \"arrayParam\", [\n [\n \"0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48\",\n \"0xdAC17F958D2ee523a2206206994597C13D831ec7\",\n \"0xB8c77482e45F1F44dE1745F52C74426C631bDD52\",\n ],\n ]);\n vi.spyOn(mockExternalPluginDataSource, \"getDappInfos\").mockResolvedValue(\n Right(dappInfos),\n );\n\n // WHEN\n const result = await loader.load(transaction);\n\n // THEN\n expect(result).toEqual([\n {\n type: ClearSignContextType.TOKEN,\n payload: \"payload-0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48\",\n },\n {\n type: ClearSignContextType.TOKEN,\n payload: \"payload-0xdAC17F958D2ee523a2206206994597C13D831ec7\",\n },\n // fromToken.2\n {\n type: ClearSignContextType.TOKEN,\n payload: \"payload-0xB8c77482e45F1F44dE1745F52C74426C631bDD52\",\n },\n // fromToken.-1\n {\n type: ClearSignContextType.TOKEN,\n payload: \"payload-0xB8c77482e45F1F44dE1745F52C74426C631bDD52\",\n },\n {\n type: ClearSignContextType.EXTERNAL_PLUGIN,\n payload: \"1234567890\",\n },\n ]);\n });\n\n it(\"should return an error when a token datasource returns an error\", async () => {\n // GIVEN\n const dappInfos = dappInfosBuilder({\n abi: ABI,\n selectorDetails: {\n erc20OfInterest: [\"fromToken\"],\n method: \"singleParam\",\n },\n });\n const transaction = transactionBuilder(ABI, \"singleParam\", [\n \"0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48\",\n ]);\n vi.spyOn(mockExternalPluginDataSource, \"getDappInfos\").mockResolvedValue(\n Right(dappInfos),\n );\n vi.spyOn(mockTokenDataSource, \"getTokenInfosPayload\").mockResolvedValue(\n Left(new Error(\"error\")),\n );\n\n // WHEN\n const result = await loader.load(transaction);\n\n // THEN\n expect(result).toEqual([\n {\n type: ClearSignContextType.ERROR,\n error: new Error(\"error\"),\n },\n {\n type: ClearSignContextType.EXTERNAL_PLUGIN,\n payload: \"1234567890\",\n },\n ]);\n });\n\n it(\"should return an error when the abi is not conform\", async () => {\n // GIVEN\n const dappInfos = dappInfosBuilder({\n abi: [{ fakeabi: \"notworking\" }],\n selectorDetails: {\n erc20OfInterest: [\"fromToken\"],\n method: \"singleParam\",\n },\n });\n const transaction = transactionBuilder(ABI, \"singleParam\", [\n \"0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48\",\n ]);\n vi.spyOn(mockExternalPluginDataSource, \"getDappInfos\").mockResolvedValue(\n Right(dappInfos),\n );\n\n // WHEN\n const result = await loader.load(transaction);\n\n // THEN\n expect(result).toEqual([\n {\n type: ClearSignContextType.ERROR,\n error: new Error(\n \"[ContextModule] ExternalPluginContextLoader: Unable to parse abi\",\n ),\n },\n {\n type: ClearSignContextType.EXTERNAL_PLUGIN,\n payload: \"1234567890\",\n },\n ]);\n });\n\n it(\"should throw an error when the erc20OfInterest doest not exist in the transaction\", async () => {\n // GIVEN\n const dappInfos = dappInfosBuilder({\n abi: ABI,\n selectorDetails: {\n erc20OfInterest: [\"notFound\"],\n method: \"singleParam\",\n },\n });\n const transaction = transactionBuilder(ABI, \"singleParam\", [\n \"0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48\",\n ]);\n vi.spyOn(mockExternalPluginDataSource, \"getDappInfos\").mockResolvedValue(\n Right(dappInfos),\n );\n\n // WHEN\n const result = await loader.load(transaction);\n\n // THEN\n expect(result).toEqual([\n {\n type: ClearSignContextType.ERROR,\n error: new Error(\n \"[ContextModule] ExternalPluginContextLoader: Unable to get address\",\n ),\n },\n ]);\n });\n\n it(\"should throw an error when an out-of-bounds element is present in erc20OfInterest\", async () => {\n // GIVEN\n const dappInfos = dappInfosBuilder({\n abi: ABI,\n selectorDetails: {\n erc20OfInterest: [\"fromToken.3\"],\n method: \"arrayParam\",\n },\n });\n const transaction = transactionBuilder(ABI, \"arrayParam\", [\n [\n \"0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48\",\n \"0xdAC17F958D2ee523a2206206994597C13D831ec7\",\n \"0xB8c77482e45F1F44dE1745F52C74426C631bDD52\",\n ],\n ]);\n vi.spyOn(mockExternalPluginDataSource, \"getDappInfos\").mockResolvedValue(\n Right(dappInfos),\n );\n\n // WHEN\n const result = await loader.load(transaction);\n\n // THEN\n expect(result).toEqual([\n {\n type: ClearSignContextType.ERROR,\n error: new RangeError(\"out of result range\"),\n },\n ]);\n });\n\n it(\"should return a list of context responses when one erc20OfInterest is a complex struct\", async () => {\n // GIVEN\n const dappInfos = dappInfosBuilder({\n abi: ABI,\n selectorDetails: {\n erc20OfInterest: [\n \"complexStruct.address1\",\n \"complexStruct.param1.param2.0.param3.addresses.0\",\n \"complexStruct.param1.param2.0.param3.addresses.1\",\n \"complexStruct.param1.param2.0.param3.addresses.-1\",\n \"complexStruct.param1.param2.1.param3.addresses.0\",\n \"complexStruct.param1.param2.-1.param3.addresses.0\",\n ],\n method: \"complexStructParam\",\n },\n });\n const transaction = transactionBuilder(ABI, \"complexStructParam\", [\n {\n address1: \"0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48\",\n param1: {\n param2: [\n {\n param3: {\n addresses: [\n \"0xdAC17F958D2ee523a2206206994597C13D831ec7\",\n \"0x95aD61b0a150d79219dCF64E1E6Cc01f0B64C4cE\",\n ],\n },\n },\n {\n param3: {\n addresses: [\"0xB8c77482e45F1F44dE1745F52C74426C631bDD52\"],\n },\n },\n ],\n },\n },\n ]);\n vi.spyOn(mockExternalPluginDataSource, \"getDappInfos\").mockResolvedValue(\n Right(dappInfos),\n );\n\n // WHEN\n const result = await loader.load(transaction);\n\n // THEN\n expect(result).toEqual([\n {\n type: ClearSignContextType.TOKEN,\n payload: \"payload-0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48\",\n },\n {\n type: ClearSignContextType.TOKEN,\n payload: \"payload-0xdAC17F958D2ee523a2206206994597C13D831ec7\",\n },\n {\n type: ClearSignContextType.TOKEN,\n payload: \"payload-0x95aD61b0a150d79219dCF64E1E6Cc01f0B64C4cE\",\n },\n {\n type: ClearSignContextType.TOKEN,\n payload: \"payload-0x95aD61b0a150d79219dCF64E1E6Cc01f0B64C4cE\",\n },\n {\n type: ClearSignContextType.TOKEN,\n payload: \"payload-0xB8c77482e45F1F44dE1745F52C74426C631bDD52\",\n },\n {\n type: ClearSignContextType.TOKEN,\n payload: \"payload-0xB8c77482e45F1F44dE1745F52C74426C631bDD52\",\n },\n {\n type: ClearSignContextType.EXTERNAL_PLUGIN,\n payload: \"1234567890\",\n },\n ]);\n });\n\n it(\"should return an error when datasource return a Left\", async () => {\n // GIVEN\n const transaction = transactionBuilder(ABI, \"singleParam\", [\n \"0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48\",\n ]);\n vi.spyOn(mockExternalPluginDataSource, \"getDappInfos\").mockResolvedValue(\n Left(new Error(\"error\")),\n );\n\n // WHEN\n const result = await loader.load(transaction);\n\n // THEN\n expect(result).toEqual([\n {\n type: ClearSignContextType.ERROR,\n error: new Error(\"error\"),\n },\n ]);\n });\n\n it(\"should return an error when transaction data is not a valid hex string\", async () => {\n // GIVEN\n const transaction = {\n to: \"0x0\",\n data: \"notAHexString\",\n } as TransactionContext;\n\n // WHEN\n const result = await loader.load(transaction);\n\n // THEN\n expect(result).toEqual([\n {\n type: ClearSignContextType.ERROR,\n error: new Error(\"Invalid selector\"),\n },\n ]);\n });\n });\n});\n"],
5
+ "mappings": "wdAAA,IAAAA,EAA0B,kBAC1BC,EAA4B,qBAE5BC,EAAgB,mDAEhBC,EAA4C,gEAG5CC,EAAqC,2CAIrC,MAAMC,EAAmB,CAAC,CACxB,IAAAC,EACA,gBAAAC,CACF,KAIS,CACL,IAAKD,EACL,gBAAiB,CACf,gBAAiB,CAAC,EAClB,OAAQ,GACR,OAAQ,GACR,eAAgB,SAChB,UAAW,OACX,GAAGC,CACL,CACF,GAGIC,EAAqB,CACzBF,EACAG,EACAC,KAIO,CACL,GAAI,MACJ,KAJe,IAAI,YAAU,KAAK,UAAUJ,CAAG,CAAC,EAC5B,mBAAmBG,EAAcC,CAAM,CAI7D,GAGF,SAAS,8BAA+B,IAA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AC3B,QAAS,oDACX,EACA,CACE,KAAM,uBAAqB,MAC3B,QAAS,oDACX,EACA,CACE,KAAM,uBAAqB,MAC3B,QAAS,oDACX,EACA,CACE,KAAM,uBAAqB,MAC3B,QAAS,oDACX,EACA,CACE,KAAM,uBAAqB,MAC3B,QAAS,oDACX,EACA,CACE,KAAM,uBAAqB,MAC3B,QAAS,oDACX,EACA,CACE,KAAM,uBAAqB,gBAC3B,QAAS,YACX,CACF,CAAC,CACH,CAAC,EAED,GAAG,uDAAwD,SAAY,CAErE,MAAMF,EAAcP,EAAmB,EAAAU,QAAK,cAAe,CACzD,4CACF,CAAC,EACD,GAAG,MAAMN,EAA8B,cAAc,EAAE,qBACrD,QAAK,IAAI,MAAM,OAAO,CAAC,CACzB,EAGA,MAAMK,EAAS,MAAMJ,EAAO,KAAKE,CAAW,EAG5C,OAAOE,CAAM,EAAE,QAAQ,CACrB,CACE,KAAM,uBAAqB,MAC3B,MAAO,IAAI,MAAM,OAAO,CAC1B,CACF,CAAC,CACH,CAAC,EAED,GAAG,yEAA0E,SAAY,CAEvF,MAAMF,EAAc,CAClB,GAAI,MACJ,KAAM,eACR,EAGME,EAAS,MAAMJ,EAAO,KAAKE,CAAW,EAG5C,OAAOE,CAAM,EAAE,QAAQ,CACrB,CACE,KAAM,uBAAqB,MAC3B,MAAO,IAAI,MAAM,kBAAkB,CACrC,CACF,CAAC,CACH,CAAC,CACH,CAAC,CACH,CAAC",
6
6
  "names": ["import_ethers", "import_purify_ts", "import_abi", "import_ExternalPluginContextLoader", "import_ClearSignContext", "dappInfosBuilder", "abi", "selectorDetails", "transactionBuilder", "functionName", "params", "mockTokenDataSource", "mockExternalPluginDataSource", "loader", "address", "transaction", "promise", "result", "ABI", "dappInfos"]
7
7
  }
@@ -1,2 +1,2 @@
1
- "use strict";var a=Object.defineProperty;var b=Object.getOwnPropertyDescriptor;var c=Object.getOwnPropertyNames;var d=Object.prototype.hasOwnProperty;var t=(f,e,p,x)=>{if(e&&typeof e=="object"||typeof e=="function")for(let m of c(e))!d.call(f,m)&&m!==p&&a(f,m,{get:()=>e[m],enumerable:!(x=b(e,m))||x.enumerable});return f},r=(f,e,p)=>(t(f,e,"default"),p&&t(p,e,"default"));var g=f=>t(a({},"__esModule",{value:!0}),f);var o={};module.exports=g(o);r(o,require("./config/model/ContextModuleConfig"),module.exports);r(o,require("./ContextModule"),module.exports);r(o,require("./ContextModuleBuilder"),module.exports);r(o,require("./DefaultContextModule"),module.exports);r(o,require("./external-plugin/domain/ExternalPluginContextLoader"),module.exports);r(o,require("./nft/domain/NftContextLoader"),module.exports);r(o,require("./shared/domain/ContextLoader"),module.exports);r(o,require("./shared/model/ClearSignContext"),module.exports);r(o,require("./shared/model/GenericPath"),module.exports);r(o,require("./shared/model/TransactionContext"),module.exports);r(o,require("./shared/model/TransactionSubset"),module.exports);r(o,require("./shared/model/TypedDataClearSignContext"),module.exports);r(o,require("./shared/model/TypedDataContext"),module.exports);r(o,require("./token/domain/TokenContextLoader"),module.exports);r(o,require("./trusted-name/domain/TrustedNameContextLoader"),module.exports);0&&(module.exports={...require("./config/model/ContextModuleConfig"),...require("./ContextModule"),...require("./ContextModuleBuilder"),...require("./DefaultContextModule"),...require("./external-plugin/domain/ExternalPluginContextLoader"),...require("./nft/domain/NftContextLoader"),...require("./shared/domain/ContextLoader"),...require("./shared/model/ClearSignContext"),...require("./shared/model/GenericPath"),...require("./shared/model/TransactionContext"),...require("./shared/model/TransactionSubset"),...require("./shared/model/TypedDataClearSignContext"),...require("./shared/model/TypedDataContext"),...require("./token/domain/TokenContextLoader"),...require("./trusted-name/domain/TrustedNameContextLoader")});
1
+ "use strict";var a=Object.defineProperty;var b=Object.getOwnPropertyDescriptor;var c=Object.getOwnPropertyNames;var d=Object.prototype.hasOwnProperty;var t=(f,e,p,x)=>{if(e&&typeof e=="object"||typeof e=="function")for(let m of c(e))!d.call(f,m)&&m!==p&&a(f,m,{get:()=>e[m],enumerable:!(x=b(e,m))||x.enumerable});return f},r=(f,e,p)=>(t(f,e,"default"),p&&t(p,e,"default"));var g=f=>t(a({},"__esModule",{value:!0}),f);var o={};module.exports=g(o);r(o,require("./config/model/ContextModuleConfig"),module.exports);r(o,require("./ContextModule"),module.exports);r(o,require("./ContextModuleBuilder"),module.exports);r(o,require("./DefaultContextModule"),module.exports);r(o,require("./external-plugin/domain/ExternalPluginContextLoader"),module.exports);r(o,require("./nft/domain/NftContextLoader"),module.exports);r(o,require("./pki/domain/PkiCertificateLoader"),module.exports);r(o,require("./pki/model/KeyId"),module.exports);r(o,require("./pki/model/KeyUsage"),module.exports);r(o,require("./pki/model/PkiCertificate"),module.exports);r(o,require("./pki/model/PkiCertificateInfo"),module.exports);r(o,require("./shared/domain/ContextLoader"),module.exports);r(o,require("./shared/model/ClearSignContext"),module.exports);r(o,require("./shared/model/GenericPath"),module.exports);r(o,require("./shared/model/TransactionContext"),module.exports);r(o,require("./shared/model/TransactionSubset"),module.exports);r(o,require("./shared/model/TypedDataClearSignContext"),module.exports);r(o,require("./shared/model/TypedDataContext"),module.exports);r(o,require("./token/domain/TokenContextLoader"),module.exports);r(o,require("./trusted-name/domain/TrustedNameContextLoader"),module.exports);r(o,require("./web3-check/domain/Web3CheckContextLoader"),module.exports);r(o,require("./web3-check/domain/web3CheckTypes"),module.exports);0&&(module.exports={...require("./config/model/ContextModuleConfig"),...require("./ContextModule"),...require("./ContextModuleBuilder"),...require("./DefaultContextModule"),...require("./external-plugin/domain/ExternalPluginContextLoader"),...require("./nft/domain/NftContextLoader"),...require("./pki/domain/PkiCertificateLoader"),...require("./pki/model/KeyId"),...require("./pki/model/KeyUsage"),...require("./pki/model/PkiCertificate"),...require("./pki/model/PkiCertificateInfo"),...require("./shared/domain/ContextLoader"),...require("./shared/model/ClearSignContext"),...require("./shared/model/GenericPath"),...require("./shared/model/TransactionContext"),...require("./shared/model/TransactionSubset"),...require("./shared/model/TypedDataClearSignContext"),...require("./shared/model/TypedDataContext"),...require("./token/domain/TokenContextLoader"),...require("./trusted-name/domain/TrustedNameContextLoader"),...require("./web3-check/domain/Web3CheckContextLoader"),...require("./web3-check/domain/web3CheckTypes")});
2
2
  //# sourceMappingURL=index.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../src/index.ts"],
4
- "sourcesContent": ["export * from \"./config/model/ContextModuleConfig\";\nexport * from \"./ContextModule\";\nexport * from \"./ContextModuleBuilder\";\nexport * from \"./DefaultContextModule\";\nexport * from \"./external-plugin/domain/ExternalPluginContextLoader\";\nexport * from \"./nft/domain/NftContextLoader\";\nexport * from \"./shared/domain/ContextLoader\";\nexport * from \"./shared/model/ClearSignContext\";\nexport * from \"./shared/model/GenericPath\";\nexport * from \"./shared/model/TransactionContext\";\nexport * from \"./shared/model/TransactionSubset\";\nexport * from \"./shared/model/TypedDataClearSignContext\";\nexport * from \"./shared/model/TypedDataContext\";\nexport * from \"./token/domain/TokenContextLoader\";\nexport * from \"./trusted-name/domain/TrustedNameContextLoader\";\n"],
5
- "mappings": "iaAAA,IAAAA,EAAA,kBAAAC,EAAAD,GAAAE,EAAAF,EAAc,8CAAd,gBACAE,EAAAF,EAAc,2BADd,gBAEAE,EAAAF,EAAc,kCAFd,gBAGAE,EAAAF,EAAc,kCAHd,gBAIAE,EAAAF,EAAc,gEAJd,gBAKAE,EAAAF,EAAc,yCALd,gBAMAE,EAAAF,EAAc,yCANd,gBAOAE,EAAAF,EAAc,2CAPd,gBAQAE,EAAAF,EAAc,sCARd,gBASAE,EAAAF,EAAc,6CATd,gBAUAE,EAAAF,EAAc,4CAVd,gBAWAE,EAAAF,EAAc,oDAXd,gBAYAE,EAAAF,EAAc,2CAZd,gBAaAE,EAAAF,EAAc,6CAbd,gBAcAE,EAAAF,EAAc,0DAdd",
4
+ "sourcesContent": ["export * from \"./config/model/ContextModuleConfig\";\nexport * from \"./ContextModule\";\nexport * from \"./ContextModuleBuilder\";\nexport * from \"./DefaultContextModule\";\nexport * from \"./external-plugin/domain/ExternalPluginContextLoader\";\nexport * from \"./nft/domain/NftContextLoader\";\nexport * from \"./pki/domain/PkiCertificateLoader\";\nexport * from \"./pki/model/KeyId\";\nexport * from \"./pki/model/KeyUsage\";\nexport * from \"./pki/model/PkiCertificate\";\nexport * from \"./pki/model/PkiCertificateInfo\";\nexport * from \"./shared/domain/ContextLoader\";\nexport * from \"./shared/model/ClearSignContext\";\nexport * from \"./shared/model/GenericPath\";\nexport * from \"./shared/model/TransactionContext\";\nexport * from \"./shared/model/TransactionSubset\";\nexport * from \"./shared/model/TypedDataClearSignContext\";\nexport * from \"./shared/model/TypedDataContext\";\nexport * from \"./token/domain/TokenContextLoader\";\nexport * from \"./trusted-name/domain/TrustedNameContextLoader\";\nexport * from \"./web3-check/domain/Web3CheckContextLoader\";\nexport * from \"./web3-check/domain/web3CheckTypes\";\n"],
5
+ "mappings": "iaAAA,IAAAA,EAAA,kBAAAC,EAAAD,GAAAE,EAAAF,EAAc,8CAAd,gBACAE,EAAAF,EAAc,2BADd,gBAEAE,EAAAF,EAAc,kCAFd,gBAGAE,EAAAF,EAAc,kCAHd,gBAIAE,EAAAF,EAAc,gEAJd,gBAKAE,EAAAF,EAAc,yCALd,gBAMAE,EAAAF,EAAc,6CANd,gBAOAE,EAAAF,EAAc,6BAPd,gBAQAE,EAAAF,EAAc,gCARd,gBASAE,EAAAF,EAAc,sCATd,gBAUAE,EAAAF,EAAc,0CAVd,gBAWAE,EAAAF,EAAc,yCAXd,gBAYAE,EAAAF,EAAc,2CAZd,gBAaAE,EAAAF,EAAc,sCAbd,gBAcAE,EAAAF,EAAc,6CAdd,gBAeAE,EAAAF,EAAc,4CAfd,gBAgBAE,EAAAF,EAAc,oDAhBd,gBAiBAE,EAAAF,EAAc,2CAjBd,gBAkBAE,EAAAF,EAAc,6CAlBd,gBAmBAE,EAAAF,EAAc,0DAnBd,gBAoBAE,EAAAF,EAAc,sDApBd,gBAqBAE,EAAAF,EAAc,8CArBd",
6
6
  "names": ["src_exports", "__toCommonJS", "__reExport"]
7
7
  }
@@ -1,2 +1,2 @@
1
- "use strict";var i=Object.create;var n=Object.defineProperty;var u=Object.getOwnPropertyDescriptor;var p=Object.getOwnPropertyNames;var x=Object.getPrototypeOf,y=Object.prototype.hasOwnProperty;var h=(t,e,a,s)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of p(e))!y.call(t,r)&&r!==a&&n(t,r,{get:()=>e[r],enumerable:!(s=u(e,r))||s.enumerable});return t};var l=(t,e,a)=>(a=t!=null?i(x(t)):{},h(e||!t||!t.__esModule?n(a,"default",{value:t,enumerable:!0}):a,t));var o=l(require("axios")),d=l(require("../../../package.json")),c=require("./HttpNftDataSource");jest.mock("axios");describe("HttpNftDataSource",()=>{let t;beforeAll(()=>{t=new c.HttpNftDataSource,jest.clearAllMocks()}),it("should call axios with the ledger client version header",async()=>{const e=`context-module/${d.default.version}`,a=jest.fn(()=>Promise.resolve({data:[]}));jest.spyOn(o.default,"request").mockImplementation(a),await t.getNftInfosPayload({address:"0x00",chainId:1}),await t.getSetPluginPayload({address:"0x00",chainId:1,selector:"0x00"}),expect(a).toHaveBeenNthCalledWith(1,expect.objectContaining({headers:{"X-Ledger-Client-Version":e}})),expect(a).toHaveBeenNthCalledWith(2,expect.objectContaining({headers:{"X-Ledger-Client-Version":e}}))}),describe("getNftInfosPayload",()=>{it("should return an error when axios throws an error",async()=>{jest.spyOn(o.default,"request").mockRejectedValue(new Error("error"));const e=await t.getNftInfosPayload({address:"0x00",chainId:1});expect(e.extract()).toEqual(new Error("[ContextModule] HttpNftDataSource: Failed to fetch nft informations"))}),it("should return an error when the response is empty",async()=>{const e={data:{}};jest.spyOn(o.default,"request").mockResolvedValue(e);const a=await t.getNftInfosPayload({address:"0x00",chainId:1});expect(a.extract()).toEqual(new Error("[ContextModule] HttpNftDataSource: no nft metadata"))}),it("should return the payload",async()=>{const e={data:{payload:"payload"}};jest.spyOn(o.default,"request").mockResolvedValue(e);const a=await t.getNftInfosPayload({address:"0x00",chainId:1});expect(a.extract()).toEqual("payload")})}),describe("getSetPluginPayload",()=>{it("should return an error when axios throws an error",async()=>{jest.spyOn(o.default,"request").mockRejectedValue(new Error("error"));const e=await t.getSetPluginPayload({address:"0x00",chainId:1,selector:"0x00"});expect(e.extract()).toEqual(new Error("[ContextModule] HttpNftDataSource: Failed to fetch set plugin payload"))}),it("should return an error when the response is empty",async()=>{const e={data:{}};jest.spyOn(o.default,"request").mockResolvedValue(e);const a=await t.getSetPluginPayload({address:"0x00",chainId:1,selector:"0x00"});expect(a.extract()).toEqual(new Error("[ContextModule] HttpNftDataSource: unexpected empty response"))}),it("should return the payload",async()=>{const e={data:{payload:"payload"}};jest.spyOn(o.default,"request").mockResolvedValue(e);const a=await t.getSetPluginPayload({address:"0x00",chainId:1,selector:"0x00"});expect(a.extract()).toEqual("payload")})})});
1
+ "use strict";var i=Object.create;var n=Object.defineProperty;var u=Object.getOwnPropertyDescriptor;var p=Object.getOwnPropertyNames;var x=Object.getPrototypeOf,y=Object.prototype.hasOwnProperty;var h=(t,e,a,s)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of p(e))!y.call(t,r)&&r!==a&&n(t,r,{get:()=>e[r],enumerable:!(s=u(e,r))||s.enumerable});return t};var l=(t,e,a)=>(a=t!=null?i(x(t)):{},h(e||!t||!t.__esModule?n(a,"default",{value:t,enumerable:!0}):a,t));var o=l(require("axios")),d=l(require("../../../package.json")),c=require("./HttpNftDataSource");vi.mock("axios");describe("HttpNftDataSource",()=>{let t;beforeAll(()=>{t=new c.HttpNftDataSource,vi.clearAllMocks()}),it("should call axios with the ledger client version header",async()=>{const e=`context-module/${d.default.version}`,a=vi.fn(()=>Promise.resolve({data:[]}));vi.spyOn(o.default,"request").mockImplementation(a),await t.getNftInfosPayload({address:"0x00",chainId:1}),await t.getSetPluginPayload({address:"0x00",chainId:1,selector:"0x00"}),expect(a).toHaveBeenNthCalledWith(1,expect.objectContaining({headers:{"X-Ledger-Client-Version":e}})),expect(a).toHaveBeenNthCalledWith(2,expect.objectContaining({headers:{"X-Ledger-Client-Version":e}}))}),describe("getNftInfosPayload",()=>{it("should return an error when axios throws an error",async()=>{vi.spyOn(o.default,"request").mockRejectedValue(new Error("error"));const e=await t.getNftInfosPayload({address:"0x00",chainId:1});expect(e.extract()).toEqual(new Error("[ContextModule] HttpNftDataSource: Failed to fetch nft informations"))}),it("should return an error when the response is empty",async()=>{const e={data:{}};vi.spyOn(o.default,"request").mockResolvedValue(e);const a=await t.getNftInfosPayload({address:"0x00",chainId:1});expect(a.extract()).toEqual(new Error("[ContextModule] HttpNftDataSource: no nft metadata"))}),it("should return the payload",async()=>{const e={data:{payload:"payload"}};vi.spyOn(o.default,"request").mockResolvedValue(e);const a=await t.getNftInfosPayload({address:"0x00",chainId:1});expect(a.extract()).toEqual("payload")})}),describe("getSetPluginPayload",()=>{it("should return an error when axios throws an error",async()=>{vi.spyOn(o.default,"request").mockRejectedValue(new Error("error"));const e=await t.getSetPluginPayload({address:"0x00",chainId:1,selector:"0x00"});expect(e.extract()).toEqual(new Error("[ContextModule] HttpNftDataSource: Failed to fetch set plugin payload"))}),it("should return an error when the response is empty",async()=>{const e={data:{}};vi.spyOn(o.default,"request").mockResolvedValue(e);const a=await t.getSetPluginPayload({address:"0x00",chainId:1,selector:"0x00"});expect(a.extract()).toEqual(new Error("[ContextModule] HttpNftDataSource: unexpected empty response"))}),it("should return the payload",async()=>{const e={data:{payload:"payload"}};vi.spyOn(o.default,"request").mockResolvedValue(e);const a=await t.getSetPluginPayload({address:"0x00",chainId:1,selector:"0x00"});expect(a.extract()).toEqual("payload")})})});
2
2
  //# sourceMappingURL=HttpNftDataSource.test.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../../src/nft/data/HttpNftDataSource.test.ts"],
4
- "sourcesContent": ["import axios from \"axios\";\n\nimport PACKAGE from \"@root/package.json\";\n\nimport { HttpNftDataSource } from \"./HttpNftDataSource\";\nimport { type NftDataSource } from \"./NftDataSource\";\n\njest.mock(\"axios\");\n\ndescribe(\"HttpNftDataSource\", () => {\n let datasource: NftDataSource;\n\n beforeAll(() => {\n datasource = new HttpNftDataSource();\n jest.clearAllMocks();\n });\n\n it(\"should call axios with the ledger client version header\", async () => {\n // GIVEN\n const version = `context-module/${PACKAGE.version}`;\n const requestSpy = jest.fn(() => Promise.resolve({ data: [] }));\n jest.spyOn(axios, \"request\").mockImplementation(requestSpy);\n\n // WHEN\n await datasource.getNftInfosPayload({ address: \"0x00\", chainId: 1 });\n await datasource.getSetPluginPayload({\n address: \"0x00\",\n chainId: 1,\n selector: \"0x00\",\n });\n\n // THEN\n expect(requestSpy).toHaveBeenNthCalledWith(\n 1,\n expect.objectContaining({\n headers: { \"X-Ledger-Client-Version\": version },\n }),\n );\n expect(requestSpy).toHaveBeenNthCalledWith(\n 2,\n expect.objectContaining({\n headers: { \"X-Ledger-Client-Version\": version },\n }),\n );\n });\n\n describe(\"getNftInfosPayload\", () => {\n it(\"should return an error when axios throws an error\", async () => {\n // GIVEN\n jest.spyOn(axios, \"request\").mockRejectedValue(new Error(\"error\"));\n\n // WHEN\n const result = await datasource.getNftInfosPayload({\n address: \"0x00\",\n chainId: 1,\n });\n\n // THEN\n expect(result.extract()).toEqual(\n new Error(\n \"[ContextModule] HttpNftDataSource: Failed to fetch nft informations\",\n ),\n );\n });\n\n it(\"should return an error when the response is empty\", async () => {\n // GIVEN\n const response = { data: {} };\n jest.spyOn(axios, \"request\").mockResolvedValue(response);\n\n // WHEN\n const result = await datasource.getNftInfosPayload({\n address: \"0x00\",\n chainId: 1,\n });\n\n // THEN\n expect(result.extract()).toEqual(\n new Error(\"[ContextModule] HttpNftDataSource: no nft metadata\"),\n );\n });\n\n it(\"should return the payload\", async () => {\n // GIVEN\n const response = { data: { payload: \"payload\" } };\n jest.spyOn(axios, \"request\").mockResolvedValue(response);\n\n // WHEN\n const result = await datasource.getNftInfosPayload({\n address: \"0x00\",\n chainId: 1,\n });\n\n // THEN\n expect(result.extract()).toEqual(\"payload\");\n });\n });\n\n describe(\"getSetPluginPayload\", () => {\n it(\"should return an error when axios throws an error\", async () => {\n // GIVEN\n jest.spyOn(axios, \"request\").mockRejectedValue(new Error(\"error\"));\n\n // WHEN\n const result = await datasource.getSetPluginPayload({\n address: \"0x00\",\n chainId: 1,\n selector: \"0x00\",\n });\n\n // THEN\n expect(result.extract()).toEqual(\n new Error(\n \"[ContextModule] HttpNftDataSource: Failed to fetch set plugin payload\",\n ),\n );\n });\n\n it(\"should return an error when the response is empty\", async () => {\n // GIVEN\n const response = { data: {} };\n jest.spyOn(axios, \"request\").mockResolvedValue(response);\n\n // WHEN\n const result = await datasource.getSetPluginPayload({\n address: \"0x00\",\n chainId: 1,\n selector: \"0x00\",\n });\n\n // THEN\n expect(result.extract()).toEqual(\n new Error(\n \"[ContextModule] HttpNftDataSource: unexpected empty response\",\n ),\n );\n });\n\n it(\"should return the payload\", async () => {\n // GIVEN\n const response = { data: { payload: \"payload\" } };\n jest.spyOn(axios, \"request\").mockResolvedValue(response);\n\n // WHEN\n const result = await datasource.getSetPluginPayload({\n address: \"0x00\",\n chainId: 1,\n selector: \"0x00\",\n });\n\n // THEN\n expect(result.extract()).toEqual(\"payload\");\n });\n });\n});\n"],
5
- "mappings": "wdAAA,IAAAA,EAAkB,oBAElBC,EAAoB,iCAEpBC,EAAkC,+BAGlC,KAAK,KAAK,OAAO,EAEjB,SAAS,oBAAqB,IAAM,CAClC,IAAIC,EAEJ,UAAU,IAAM,CACdA,EAAa,IAAI,oBACjB,KAAK,cAAc,CACrB,CAAC,EAED,GAAG,0DAA2D,SAAY,CAExE,MAAMC,EAAU,kBAAkB,EAAAC,QAAQ,OAAO,GAC3CC,EAAa,KAAK,GAAG,IAAM,QAAQ,QAAQ,CAAE,KAAM,CAAC,CAAE,CAAC,CAAC,EAC9D,KAAK,MAAM,EAAAC,QAAO,SAAS,EAAE,mBAAmBD,CAAU,EAG1D,MAAMH,EAAW,mBAAmB,CAAE,QAAS,O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AK,MAAM,EAAAD,QAAO,SAAS,EAAE,kBAAkB,IAAI,MAAM,OAAO,CAAC,EAGjE,MAAMC,EAAS,MAAML,EAAW,oBAAoB,CAClD,QAAS,OACT,QAAS,EACT,SAAU,MACZ,CAAC,EAGD,OAAOK,EAAO,QAAQ,CAAC,EAAE,QACvB,IAAI,MACF,uEACF,CACF,CACF,CAAC,EAED,GAAG,oDAAqD,SAAY,CAElE,MAAMC,EAAW,CAAE,KAAM,CAAC,CAAE,EAC5B,KAAK,MAAM,EAAAF,QAAO,SAAS,EAAE,kBAAkBE,CAAQ,EAGvD,MAAMD,EAAS,MAAML,EAAW,oBAAoB,CAClD,QAAS,OACT,QAAS,EACT,SAAU,MACZ,CAAC,EAGD,OAAOK,EAAO,QAAQ,CAAC,EAAE,QACvB,IAAI,MACF,8DACF,CACF,CACF,CAAC,EAED,GAAG,4BAA6B,SAAY,CAE1C,MAAMC,EAAW,CAAE,KAAM,CAAE,QAAS,SAAU,CAAE,EAChD,KAAK,MAAM,EAAAF,QAAO,SAAS,EAAE,kBAAkBE,CAAQ,EAGvD,MAAMD,EAAS,MAAML,EAAW,oBAAoB,CAClD,QAAS,OACT,QAAS,EACT,SAAU,MACZ,CAAC,EAGD,OAAOK,EAAO,QAAQ,CAAC,EAAE,QAAQ,SAAS,CAC5C,CAAC,CACH,CAAC,CACH,CAAC",
4
+ "sourcesContent": ["import axios from \"axios\";\n\nimport PACKAGE from \"@root/package.json\";\n\nimport { HttpNftDataSource } from \"./HttpNftDataSource\";\nimport { type NftDataSource } from \"./NftDataSource\";\n\nvi.mock(\"axios\");\n\ndescribe(\"HttpNftDataSource\", () => {\n let datasource: NftDataSource;\n\n beforeAll(() => {\n datasource = new HttpNftDataSource();\n vi.clearAllMocks();\n });\n\n it(\"should call axios with the ledger client version header\", async () => {\n // GIVEN\n const version = `context-module/${PACKAGE.version}`;\n const requestSpy = vi.fn(() => Promise.resolve({ data: [] }));\n vi.spyOn(axios, \"request\").mockImplementation(requestSpy);\n\n // WHEN\n await datasource.getNftInfosPayload({ address: \"0x00\", chainId: 1 });\n await datasource.getSetPluginPayload({\n address: \"0x00\",\n chainId: 1,\n selector: \"0x00\",\n });\n\n // THEN\n expect(requestSpy).toHaveBeenNthCalledWith(\n 1,\n expect.objectContaining({\n headers: { \"X-Ledger-Client-Version\": version },\n }),\n );\n expect(requestSpy).toHaveBeenNthCalledWith(\n 2,\n expect.objectContaining({\n headers: { \"X-Ledger-Client-Version\": version },\n }),\n );\n });\n\n describe(\"getNftInfosPayload\", () => {\n it(\"should return an error when axios throws an error\", async () => {\n // GIVEN\n vi.spyOn(axios, \"request\").mockRejectedValue(new Error(\"error\"));\n\n // WHEN\n const result = await datasource.getNftInfosPayload({\n address: \"0x00\",\n chainId: 1,\n });\n\n // THEN\n expect(result.extract()).toEqual(\n new Error(\n \"[ContextModule] HttpNftDataSource: Failed to fetch nft informations\",\n ),\n );\n });\n\n it(\"should return an error when the response is empty\", async () => {\n // GIVEN\n const response = { data: {} };\n vi.spyOn(axios, \"request\").mockResolvedValue(response);\n\n // WHEN\n const result = await datasource.getNftInfosPayload({\n address: \"0x00\",\n chainId: 1,\n });\n\n // THEN\n expect(result.extract()).toEqual(\n new Error(\"[ContextModule] HttpNftDataSource: no nft metadata\"),\n );\n });\n\n it(\"should return the payload\", async () => {\n // GIVEN\n const response = { data: { payload: \"payload\" } };\n vi.spyOn(axios, \"request\").mockResolvedValue(response);\n\n // WHEN\n const result = await datasource.getNftInfosPayload({\n address: \"0x00\",\n chainId: 1,\n });\n\n // THEN\n expect(result.extract()).toEqual(\"payload\");\n });\n });\n\n describe(\"getSetPluginPayload\", () => {\n it(\"should return an error when axios throws an error\", async () => {\n // GIVEN\n vi.spyOn(axios, \"request\").mockRejectedValue(new Error(\"error\"));\n\n // WHEN\n const result = await datasource.getSetPluginPayload({\n address: \"0x00\",\n chainId: 1,\n selector: \"0x00\",\n });\n\n // THEN\n expect(result.extract()).toEqual(\n new Error(\n \"[ContextModule] HttpNftDataSource: Failed to fetch set plugin payload\",\n ),\n );\n });\n\n it(\"should return an error when the response is empty\", async () => {\n // GIVEN\n const response = { data: {} };\n vi.spyOn(axios, \"request\").mockResolvedValue(response);\n\n // WHEN\n const result = await datasource.getSetPluginPayload({\n address: \"0x00\",\n chainId: 1,\n selector: \"0x00\",\n });\n\n // THEN\n expect(result.extract()).toEqual(\n new Error(\n \"[ContextModule] HttpNftDataSource: unexpected empty response\",\n ),\n );\n });\n\n it(\"should return the payload\", async () => {\n // GIVEN\n const response = { data: { payload: \"payload\" } };\n vi.spyOn(axios, \"request\").mockResolvedValue(response);\n\n // WHEN\n const result = await datasource.getSetPluginPayload({\n address: \"0x00\",\n chainId: 1,\n selector: \"0x00\",\n });\n\n // THEN\n expect(result.extract()).toEqual(\"payload\");\n });\n });\n});\n"],
5
+ "mappings": "wdAAA,IAAAA,EAAkB,oBAElBC,EAAoB,iCAEpBC,EAAkC,+BAGlC,GAAG,KAAK,OAAO,EAEf,SAAS,oBAAqB,IAAM,CAClC,IAAIC,EAEJ,UAAU,IAAM,CACdA,EAAa,IAAI,oBACjB,GAAG,cAAc,CACnB,CAAC,EAED,GAAG,0DAA2D,SAAY,CAExE,MAAMC,EAAU,kBAAkB,EAAAC,QAAQ,OAAO,GAC3CC,EAAa,GAAG,GAAG,IAAM,QAAQ,QAAQ,CAAE,KAAM,CAAC,CAAE,CAAC,CAAC,EAC5D,GAAG,MAAM,EAAAC,QAAO,SAAS,EAAE,mBAAmBD,CAAU,EAGxD,MAAMH,EAAW,mBAAmB,CAAE,QAAS,OAAQ,QAAS,CAAE,CAAC,EACnE,MAAMA,EAAW,oBAAoB,CACnC,QAAS,OACT,QAAS,EACT,SAAU,MACZ,CAAC,EAGD,OAAOG,CAAU,EAAE,wBACjB,EACA,OAAO,iBAAiB,CACtB,QAAS,CAAE,0BAA2BF,CAAQ,CAChD,CAAC,CACH,EACA,OAAOE,CAAU,EAAE,wBACjB,EACA,OAAO,iBAAiB,CACtB,QAAS,CAAE,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EAAW,CAAE,KAAM,CAAC,CAAE,EAC5B,GAAG,MAAM,EAAAF,QAAO,SAAS,EAAE,kBAAkBE,CAAQ,EAGrD,MAAMD,EAAS,MAAML,EAAW,oBAAoB,CAClD,QAAS,OACT,QAAS,EACT,SAAU,MACZ,CAAC,EAGD,OAAOK,EAAO,QAAQ,CAAC,EAAE,QACvB,IAAI,MACF,8DACF,CACF,CACF,CAAC,EAED,GAAG,4BAA6B,SAAY,CAE1C,MAAMC,EAAW,CAAE,KAAM,CAAE,QAAS,SAAU,CAAE,EAChD,GAAG,MAAM,EAAAF,QAAO,SAAS,EAAE,kBAAkBE,CAAQ,EAGrD,MAAMD,EAAS,MAAML,EAAW,oBAAoB,CAClD,QAAS,OACT,QAAS,EACT,SAAU,MACZ,CAAC,EAGD,OAAOK,EAAO,QAAQ,CAAC,EAAE,QAAQ,SAAS,CAC5C,CAAC,CACH,CAAC,CACH,CAAC",
6
6
  "names": ["import_axios", "import_package", "import_HttpNftDataSource", "datasource", "version", "PACKAGE", "requestSpy", "axios", "result", "response"]
7
7
  }
@@ -1,2 +1,2 @@
1
- "use strict";var n=require("purify-ts"),d=require("../../nft/domain/NftContextLoader"),o=require("../../shared/model/ClearSignContext");describe("NftContextLoader",()=>{const r=jest.fn(),s=jest.fn();let c,e;beforeEach(()=>{jest.restoreAllMocks(),c={getNftInfosPayload:r,getSetPluginPayload:s},e=new d.NftContextLoader(c)}),describe("load function",()=>{it("should return an empty array if no dest",async()=>{const t={to:void 0,data:"0x01"},a=await e.load(t);expect(a).toEqual([])}),it("should return an empty array if undefined data",async()=>{const t={to:"0xdAC17F958D2ee523a2206206994597C13D831ec7",data:void 0},a=await e.load(t);expect(a).toEqual([])}),it("should return an empty array if empty data",async()=>{const t={to:"0xdAC17F958D2ee523a2206206994597C13D831ec7",data:"0x"},a=await e.load(t);expect(a).toEqual([])}),it("should return an empty array if selector not supported",async()=>{const t={to:"0xdAC17F958D2ee523a2206206994597C13D831ec7",data:"0x095ea7b20000000000000"},a=await e.load(t);expect(a).toEqual([])}),it("should return an error when transaction data is not a valid hex string",async()=>{const t={to:"0xdAC17F958D2ee523a2206206994597C13D831ec7",data:"notahexstring"},a=await e.load(t);expect(a).toEqual([{type:o.ClearSignContextType.ERROR,error:new Error("Invalid selector")}])}),it("should return an error when datasource get plugin payload return a Left",async()=>{const t={to:"0xdAC17F958D2ee523a2206206994597C13D831ec7",data:"0x095ea7b30000000000000"};s.mockResolvedValueOnce((0,n.Left)(new Error("error")));const a=await e.load(t);expect(a).toEqual([{type:o.ClearSignContextType.ERROR,error:new Error("error")}])}),it("should return an error when datasource get nft infos payload return a Left",async()=>{const t={to:"0xdAC17F958D2ee523a2206206994597C13D831ec7",data:"0x095ea7b30000000000000"};s.mockResolvedValueOnce((0,n.Right)("payload1")),r.mockResolvedValueOnce((0,n.Left)(new Error("error")));const a=await e.load(t);expect(a).toEqual([{type:o.ClearSignContextType.ERROR,error:new Error("error")}])}),it("should return a response",async()=>{const t={to:"0xdAC17F958D2ee523a2206206994597C13D831ec7",data:"0x095ea7b30000000000000"};s.mockResolvedValueOnce((0,n.Right)("payload1")),r.mockResolvedValueOnce((0,n.Right)("payload2"));const a=await e.load(t);expect(a).toEqual([{type:o.ClearSignContextType.PLUGIN,payload:"payload1"},{type:o.ClearSignContextType.NFT,payload:"payload2"}])})}),describe("loadField function",()=>{it("should return an error when field type if not supported",async()=>{const t={type:o.ClearSignContextType.TOKEN,chainId:7,address:"0x1234"},a=await e.loadField(t);expect(a).toEqual(null)}),it("should return a payload",async()=>{const t={type:o.ClearSignContextType.NFT,chainId:7,address:"0x1234"};r.mockResolvedValueOnce((0,n.Right)("payload"));const a=await e.loadField(t);expect(a).toEqual({type:o.ClearSignContextType.NFT,payload:"payload"})}),it("should return an error when unable to fetch the datasource",async()=>{const t={type:o.ClearSignContextType.NFT,chainId:7,address:"0x1234"};r.mockResolvedValueOnce((0,n.Left)(new Error("error")));const a=await e.loadField(t);expect(a).toEqual({type:o.ClearSignContextType.ERROR,error:new Error("error")})})})});
1
+ "use strict";var n=require("purify-ts"),d=require("../../nft/domain/NftContextLoader"),o=require("../../shared/model/ClearSignContext");describe("NftContextLoader",()=>{const r=vi.fn(),s=vi.fn();let c,e;beforeEach(()=>{vi.restoreAllMocks(),c={getNftInfosPayload:r,getSetPluginPayload:s},e=new d.NftContextLoader(c)}),describe("load function",()=>{it("should return an empty array if no dest",async()=>{const t={to:void 0,data:"0x01"},a=await e.load(t);expect(a).toEqual([])}),it("should return an empty array if undefined data",async()=>{const t={to:"0xdAC17F958D2ee523a2206206994597C13D831ec7",data:void 0},a=await e.load(t);expect(a).toEqual([])}),it("should return an empty array if empty data",async()=>{const t={to:"0xdAC17F958D2ee523a2206206994597C13D831ec7",data:"0x"},a=await e.load(t);expect(a).toEqual([])}),it("should return an empty array if selector not supported",async()=>{const t={to:"0xdAC17F958D2ee523a2206206994597C13D831ec7",data:"0x095ea7b20000000000000"},a=await e.load(t);expect(a).toEqual([])}),it("should return an error when transaction data is not a valid hex string",async()=>{const t={to:"0xdAC17F958D2ee523a2206206994597C13D831ec7",data:"notahexstring"},a=await e.load(t);expect(a).toEqual([{type:o.ClearSignContextType.ERROR,error:new Error("Invalid selector")}])}),it("should return an error when datasource get plugin payload return a Left",async()=>{const t={to:"0xdAC17F958D2ee523a2206206994597C13D831ec7",data:"0x095ea7b30000000000000"};s.mockResolvedValueOnce((0,n.Left)(new Error("error")));const a=await e.load(t);expect(a).toEqual([{type:o.ClearSignContextType.ERROR,error:new Error("error")}])}),it("should return an error when datasource get nft infos payload return a Left",async()=>{const t={to:"0xdAC17F958D2ee523a2206206994597C13D831ec7",data:"0x095ea7b30000000000000"};s.mockResolvedValueOnce((0,n.Right)("payload1")),r.mockResolvedValueOnce((0,n.Left)(new Error("error")));const a=await e.load(t);expect(a).toEqual([{type:o.ClearSignContextType.ERROR,error:new Error("error")}])}),it("should return a response",async()=>{const t={to:"0xdAC17F958D2ee523a2206206994597C13D831ec7",data:"0x095ea7b30000000000000"};s.mockResolvedValueOnce((0,n.Right)("payload1")),r.mockResolvedValueOnce((0,n.Right)("payload2"));const a=await e.load(t);expect(a).toEqual([{type:o.ClearSignContextType.PLUGIN,payload:"payload1"},{type:o.ClearSignContextType.NFT,payload:"payload2"}])})}),describe("loadField function",()=>{it("should return an error when field type if not supported",async()=>{const t={type:o.ClearSignContextType.TOKEN,chainId:7,address:"0x1234"},a=await e.loadField(t);expect(a).toEqual(null)}),it("should return a payload",async()=>{const t={type:o.ClearSignContextType.NFT,chainId:7,address:"0x1234"};r.mockResolvedValueOnce((0,n.Right)("payload"));const a=await e.loadField(t);expect(a).toEqual({type:o.ClearSignContextType.NFT,payload:"payload"})}),it("should return an error when unable to fetch the datasource",async()=>{const t={type:o.ClearSignContextType.NFT,chainId:7,address:"0x1234"};r.mockResolvedValueOnce((0,n.Left)(new Error("error")));const a=await e.loadField(t);expect(a).toEqual({type:o.ClearSignContextType.ERROR,error:new Error("error")})})})});
2
2
  //# sourceMappingURL=NftContextLoader.test.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../../src/nft/domain/NftContextLoader.test.ts"],
4
- "sourcesContent": ["import { Left, Right } from \"purify-ts\";\n\nimport { type NftDataSource } from \"@/nft/data/NftDataSource\";\nimport { NftContextLoader } from \"@/nft/domain/NftContextLoader\";\nimport { ClearSignContextType } from \"@/shared/model/ClearSignContext\";\nimport {\n type TransactionContext,\n type TransactionFieldContext,\n} from \"@/shared/model/TransactionContext\";\n\ndescribe(\"NftContextLoader\", () => {\n const spyGetNftInfosPayload = jest.fn();\n const spyGetPluginPayload = jest.fn();\n let mockDataSource: NftDataSource;\n let loader: NftContextLoader;\n\n beforeEach(() => {\n jest.restoreAllMocks();\n mockDataSource = {\n getNftInfosPayload: spyGetNftInfosPayload,\n getSetPluginPayload: spyGetPluginPayload,\n };\n loader = new NftContextLoader(mockDataSource);\n });\n\n describe(\"load function\", () => {\n it(\"should return an empty array if no dest\", async () => {\n const transaction = { to: undefined, data: \"0x01\" } as TransactionContext;\n\n const result = await loader.load(transaction);\n\n expect(result).toEqual([]);\n });\n\n it(\"should return an empty array if undefined data\", async () => {\n const transaction = {\n to: \"0xdAC17F958D2ee523a2206206994597C13D831ec7\",\n data: undefined,\n } as unknown as TransactionContext;\n\n const result = await loader.load(transaction);\n\n expect(result).toEqual([]);\n });\n\n it(\"should return an empty array if empty data\", async () => {\n const transaction = {\n to: \"0xdAC17F958D2ee523a2206206994597C13D831ec7\",\n data: \"0x\",\n } as unknown as TransactionContext;\n\n const result = await loader.load(transaction);\n\n expect(result).toEqual([]);\n });\n\n it(\"should return an empty array if selector not supported\", async () => {\n const transaction = {\n to: \"0xdAC17F958D2ee523a2206206994597C13D831ec7\",\n data: \"0x095ea7b20000000000000\",\n } as unknown as TransactionContext;\n\n const result = await loader.load(transaction);\n\n expect(result).toEqual([]);\n });\n\n it(\"should return an error when transaction data is not a valid hex string\", async () => {\n const transaction = {\n to: \"0xdAC17F958D2ee523a2206206994597C13D831ec7\",\n data: \"notahexstring\",\n } as TransactionContext;\n\n const result = await loader.load(transaction);\n\n expect(result).toEqual([\n {\n type: ClearSignContextType.ERROR,\n error: new Error(\"Invalid selector\"),\n },\n ]);\n });\n\n it(\"should return an error when datasource get plugin payload return a Left\", async () => {\n const transaction = {\n to: \"0xdAC17F958D2ee523a2206206994597C13D831ec7\",\n data: \"0x095ea7b30000000000000\",\n } as TransactionContext;\n spyGetPluginPayload.mockResolvedValueOnce(Left(new Error(\"error\")));\n\n const result = await loader.load(transaction);\n\n expect(result).toEqual([\n {\n type: ClearSignContextType.ERROR,\n error: new Error(\"error\"),\n },\n ]);\n });\n\n it(\"should return an error when datasource get nft infos payload return a Left\", async () => {\n const transaction = {\n to: \"0xdAC17F958D2ee523a2206206994597C13D831ec7\",\n data: \"0x095ea7b30000000000000\",\n } as TransactionContext;\n spyGetPluginPayload.mockResolvedValueOnce(Right(\"payload1\"));\n spyGetNftInfosPayload.mockResolvedValueOnce(Left(new Error(\"error\")));\n\n const result = await loader.load(transaction);\n\n expect(result).toEqual([\n {\n type: ClearSignContextType.ERROR,\n error: new Error(\"error\"),\n },\n ]);\n });\n\n it(\"should return a response\", async () => {\n const transaction = {\n to: \"0xdAC17F958D2ee523a2206206994597C13D831ec7\",\n data: \"0x095ea7b30000000000000\",\n } as TransactionContext;\n spyGetPluginPayload.mockResolvedValueOnce(Right(\"payload1\"));\n spyGetNftInfosPayload.mockResolvedValueOnce(Right(\"payload2\"));\n\n const result = await loader.load(transaction);\n\n expect(result).toEqual([\n {\n type: ClearSignContextType.PLUGIN,\n payload: \"payload1\",\n },\n {\n type: ClearSignContextType.NFT,\n payload: \"payload2\",\n },\n ]);\n });\n });\n\n describe(\"loadField function\", () => {\n it(\"should return an error when field type if not supported\", async () => {\n const field: TransactionFieldContext = {\n type: ClearSignContextType.TOKEN,\n chainId: 7,\n address: \"0x1234\",\n };\n\n const result = await loader.loadField(field);\n\n expect(result).toEqual(null);\n });\n\n it(\"should return a payload\", async () => {\n // GIVEN\n const field: TransactionFieldContext = {\n type: ClearSignContextType.NFT,\n chainId: 7,\n address: \"0x1234\",\n };\n\n // WHEN\n spyGetNftInfosPayload.mockResolvedValueOnce(Right(\"payload\"));\n const result = await loader.loadField(field);\n\n // THEN\n expect(result).toEqual({\n type: ClearSignContextType.NFT,\n payload: \"payload\",\n });\n });\n\n it(\"should return an error when unable to fetch the datasource\", async () => {\n // GIVEN\n const field: TransactionFieldContext = {\n type: ClearSignContextType.NFT,\n chainId: 7,\n address: \"0x1234\",\n };\n\n // WHEN\n spyGetNftInfosPayload.mockResolvedValueOnce(Left(new Error(\"error\")));\n const result = await loader.loadField(field);\n\n // THEN\n expect(result).toEqual({\n type: ClearSignContextType.ERROR,\n error: new Error(\"error\"),\n });\n });\n });\n});\n"],
5
- "mappings": "aAAA,IAAAA,EAA4B,qBAG5BC,EAAiC,yCACjCC,EAAqC,2CAMrC,SAAS,mBAAoB,IAAM,CACjC,MAAMC,EA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EAGAN,EAAsB,yBAAsB,SAAM,SAAS,CAAC,EAC5D,MAAMK,EAAS,MAAMF,EAAO,UAAUG,CAAK,EAG3C,OAAOD,CAAM,EAAE,QAAQ,CACrB,KAAM,uBAAqB,IAC3B,QAAS,SACX,CAAC,CACH,CAAC,EAED,GAAG,6DAA8D,SAAY,CAE3E,MAAMC,EAAiC,CACrC,KAAM,uBAAqB,IAC3B,QAAS,EACT,QAAS,QACX,EAGAN,EAAsB,yBAAsB,QAAK,IAAI,MAAM,OAAO,CAAC,CAAC,EACpE,MAAMK,EAAS,MAAMF,EAAO,UAAUG,CAAK,EAG3C,OAAOD,CAAM,EAAE,QAAQ,CACrB,KAAM,uBAAqB,MAC3B,MAAO,IAAI,MAAM,OAAO,CAC1B,CAAC,CACH,CAAC,CACH,CAAC,CACH,CAAC",
4
+ "sourcesContent": ["import { Left, Right } from \"purify-ts\";\n\nimport { type NftDataSource } from \"@/nft/data/NftDataSource\";\nimport { NftContextLoader } from \"@/nft/domain/NftContextLoader\";\nimport { ClearSignContextType } from \"@/shared/model/ClearSignContext\";\nimport {\n type TransactionContext,\n type TransactionFieldContext,\n} from \"@/shared/model/TransactionContext\";\n\ndescribe(\"NftContextLoader\", () => {\n const spyGetNftInfosPayload = vi.fn();\n const spyGetPluginPayload = vi.fn();\n let mockDataSource: NftDataSource;\n let loader: NftContextLoader;\n\n beforeEach(() => {\n vi.restoreAllMocks();\n mockDataSource = {\n getNftInfosPayload: spyGetNftInfosPayload,\n getSetPluginPayload: spyGetPluginPayload,\n };\n loader = new NftContextLoader(mockDataSource);\n });\n\n describe(\"load function\", () => {\n it(\"should return an empty array if no dest\", async () => {\n const transaction = { to: undefined, data: \"0x01\" } as TransactionContext;\n\n const result = await loader.load(transaction);\n\n expect(result).toEqual([]);\n });\n\n it(\"should return an empty array if undefined data\", async () => {\n const transaction = {\n to: \"0xdAC17F958D2ee523a2206206994597C13D831ec7\",\n data: undefined,\n } as unknown as TransactionContext;\n\n const result = await loader.load(transaction);\n\n expect(result).toEqual([]);\n });\n\n it(\"should return an empty array if empty data\", async () => {\n const transaction = {\n to: \"0xdAC17F958D2ee523a2206206994597C13D831ec7\",\n data: \"0x\",\n } as unknown as TransactionContext;\n\n const result = await loader.load(transaction);\n\n expect(result).toEqual([]);\n });\n\n it(\"should return an empty array if selector not supported\", async () => {\n const transaction = {\n to: \"0xdAC17F958D2ee523a2206206994597C13D831ec7\",\n data: \"0x095ea7b20000000000000\",\n } as unknown as TransactionContext;\n\n const result = await loader.load(transaction);\n\n expect(result).toEqual([]);\n });\n\n it(\"should return an error when transaction data is not a valid hex string\", async () => {\n const transaction = {\n to: \"0xdAC17F958D2ee523a2206206994597C13D831ec7\",\n data: \"notahexstring\",\n } as TransactionContext;\n\n const result = await loader.load(transaction);\n\n expect(result).toEqual([\n {\n type: ClearSignContextType.ERROR,\n error: new Error(\"Invalid selector\"),\n },\n ]);\n });\n\n it(\"should return an error when datasource get plugin payload return a Left\", async () => {\n const transaction = {\n to: \"0xdAC17F958D2ee523a2206206994597C13D831ec7\",\n data: \"0x095ea7b30000000000000\",\n } as TransactionContext;\n spyGetPluginPayload.mockResolvedValueOnce(Left(new Error(\"error\")));\n\n const result = await loader.load(transaction);\n\n expect(result).toEqual([\n {\n type: ClearSignContextType.ERROR,\n error: new Error(\"error\"),\n },\n ]);\n });\n\n it(\"should return an error when datasource get nft infos payload return a Left\", async () => {\n const transaction = {\n to: \"0xdAC17F958D2ee523a2206206994597C13D831ec7\",\n data: \"0x095ea7b30000000000000\",\n } as TransactionContext;\n spyGetPluginPayload.mockResolvedValueOnce(Right(\"payload1\"));\n spyGetNftInfosPayload.mockResolvedValueOnce(Left(new Error(\"error\")));\n\n const result = await loader.load(transaction);\n\n expect(result).toEqual([\n {\n type: ClearSignContextType.ERROR,\n error: new Error(\"error\"),\n },\n ]);\n });\n\n it(\"should return a response\", async () => {\n const transaction = {\n to: \"0xdAC17F958D2ee523a2206206994597C13D831ec7\",\n data: \"0x095ea7b30000000000000\",\n } as TransactionContext;\n spyGetPluginPayload.mockResolvedValueOnce(Right(\"payload1\"));\n spyGetNftInfosPayload.mockResolvedValueOnce(Right(\"payload2\"));\n\n const result = await loader.load(transaction);\n\n expect(result).toEqual([\n {\n type: ClearSignContextType.PLUGIN,\n payload: \"payload1\",\n },\n {\n type: ClearSignContextType.NFT,\n payload: \"payload2\",\n },\n ]);\n });\n });\n\n describe(\"loadField function\", () => {\n it(\"should return an error when field type if not supported\", async () => {\n const field: TransactionFieldContext = {\n type: ClearSignContextType.TOKEN,\n chainId: 7,\n address: \"0x1234\",\n };\n\n const result = await loader.loadField(field);\n\n expect(result).toEqual(null);\n });\n\n it(\"should return a payload\", async () => {\n // GIVEN\n const field: TransactionFieldContext = {\n type: ClearSignContextType.NFT,\n chainId: 7,\n address: \"0x1234\",\n };\n\n // WHEN\n spyGetNftInfosPayload.mockResolvedValueOnce(Right(\"payload\"));\n const result = await loader.loadField(field);\n\n // THEN\n expect(result).toEqual({\n type: ClearSignContextType.NFT,\n payload: \"payload\",\n });\n });\n\n it(\"should return an error when unable to fetch the datasource\", async () => {\n // GIVEN\n const field: TransactionFieldContext = {\n type: ClearSignContextType.NFT,\n chainId: 7,\n address: \"0x1234\",\n };\n\n // WHEN\n spyGetNftInfosPayload.mockResolvedValueOnce(Left(new Error(\"error\")));\n const result = await loader.loadField(field);\n\n // THEN\n expect(result).toEqual({\n type: ClearSignContextType.ERROR,\n error: new Error(\"error\"),\n });\n });\n });\n});\n"],
5
+ "mappings": "aAAA,IAAAA,EAA4B,qBAG5BC,EAAiC,yCACjCC,EAAqC,2CAMrC,SAAS,mBAAoB,IAAM,CACjC,MAAMC,EAAwB,GAAG,GAAG,EAC9BC,EAAsB,GAAG,GAAG,EAClC,IAAIC,EACAC,EAEJ,WAAW,IAAM,CACf,GAAG,gBAAgB,EACnBD,EAAiB,CACf,mBAAoBF,EACpB,oBAAqBC,CACvB,EACAE,EAAS,IAAI,mBAAiBD,CAAc,CAC9C,CAAC,EAED,S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E3E,MAAMC,EAAiC,CACrC,KAAM,uBAAqB,IAC3B,QAAS,EACT,QAAS,QACX,EAGAN,EAAsB,yBAAsB,QAAK,IAAI,MAAM,OAAO,CAAC,CAAC,EACpE,MAAMK,EAAS,MAAMF,EAAO,UAAUG,CAAK,EAG3C,OAAOD,CAAM,EAAE,QAAQ,CACrB,KAAM,uBAAqB,MAC3B,MAAO,IAAI,MAAM,OAAO,CAC1B,CAAC,CACH,CAAC,CACH,CAAC,CACH,CAAC",
6
6
  "names": ["import_purify_ts", "import_NftContextLoader", "import_ClearSignContext", "spyGetNftInfosPayload", "spyGetPluginPayload", "mockDataSource", "loader", "transaction", "result", "field"]
7
7
  }
@@ -0,0 +1,2 @@
1
+ "use strict";var R=Object.create;var n=Object.defineProperty;var d=Object.getOwnPropertyDescriptor;var D=Object.getOwnPropertyNames;var E=Object.getPrototypeOf,b=Object.prototype.hasOwnProperty;var U=(t,e)=>{for(var r in e)n(t,r,{get:e[r],enumerable:!0})},m=(t,e,r,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of D(e))!b.call(t,o)&&o!==r&&n(t,o,{get:()=>e[o],enumerable:!(i=d(e,o))||i.enumerable});return t};var g=(t,e,r)=>(r=t!=null?R(E(t)):{},m(e||!t||!t.__esModule?n(r,"default",{value:t,enumerable:!0}):r,t)),_=t=>m(n({},"__esModule",{value:!0}),t),u=(t,e,r,i)=>{for(var o=i>1?void 0:i?d(e,r):e,a=t.length-1,p;a>=0;a--)(p=t[a])&&(o=(i?p(e,r,o):p(o))||o);return i&&o&&n(e,r,o),o},l=(t,e)=>(r,i)=>e(r,i,t);var K={};U(K,{HttpPkiCertificateDataSource:()=>c});module.exports=_(K);var C=require("@ledgerhq/device-management-kit"),y=g(require("axios")),f=require("inversify"),s=require("purify-ts"),k=require("../../config/di/configTypes"),P=require("../../shared/model/SignatureTags"),h=require("../../shared/utils/HexStringUtils"),x=require("../../shared/utils/KeyUsageMapper"),M=g(require("../../../package.json"));let c=class{constructor(e){this.config=e}async fetchCertificate(e){const r={output:"descriptor",target_device:e.targetDevice,latest:!0,public_key_id:e.keyId,public_key_usage:e.keyUsage};try{const i=await y.default.request({method:"GET",url:`${this.config.cal.url}/certificates`,params:r,headers:{"X-Ledger-Client-Version":`context-module/${M.default.version}`}});if(i.status==200&&i.data!==void 0&&i.data.length>0&&this.isValidPkiCertificateResponse(i.data[0],this.config.cal.mode)){const o=(0,C.hexaStringToBuffer)(h.HexStringUtils.appendSignatureToPayload(i.data[0].descriptor.data,i.data[0].descriptor.signatures[this.config.cal.mode],P.SIGNATURE_TAG));if(!o)return(0,s.Left)(Error("[ContextModule] HttpPkiCertificateDataSource: Cannot generate payload from fetched PKI Certificate"));const a={payload:o,keyUsageNumber:x.KeyUsageMapper.mapKeyUsageForFirmware(e.keyUsage)};return(0,s.Right)(a)}else return(0,s.Left)(Error("[ContextModule] HttpPkiCertificateDataSource: failed to fetch PKI for given descriptor"))}catch{return(0,s.Left)(Error("[ContextModule] HttpPkiCertificateDataSource: failed to fetch PKI for given descriptor"))}}isValidPkiCertificateResponse(e,r){return typeof e=="object"&&e!==null&&"descriptor"in e&&typeof e.descriptor=="object"&&e.descriptor!==null&&"data"in e.descriptor&&typeof e.descriptor.data=="string"&&"signatures"in e.descriptor&&typeof e.descriptor.signatures=="object"&&e.descriptor.signatures!==null&&r in e.descriptor.signatures&&typeof e.descriptor.signatures[r]=="string"}};c=u([(0,f.injectable)(),l(0,(0,f.inject)(k.configTypes.Config))],c);0&&(module.exports={HttpPkiCertificateDataSource});
2
+ //# sourceMappingURL=HttpPkiCertificateDataSource.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../../../src/pki/data/HttpPkiCertificateDataSource.ts"],
4
+ "sourcesContent": ["import { hexaStringToBuffer } from \"@ledgerhq/device-management-kit\";\nimport axios from \"axios\";\nimport { inject, injectable } from \"inversify\";\nimport { Either, Left, Right } from \"purify-ts\";\n\nimport { configTypes } from \"@/config/di/configTypes\";\nimport type {\n ContextModuleCalMode,\n ContextModuleConfig,\n} from \"@/config/model/ContextModuleConfig\";\nimport { PkiCertificate } from \"@/pki/model/PkiCertificate\";\nimport { PkiCertificateInfo } from \"@/pki/model/PkiCertificateInfo\";\nimport { SIGNATURE_TAG } from \"@/shared/model/SignatureTags\";\nimport { HexStringUtils } from \"@/shared/utils/HexStringUtils\";\nimport { KeyUsageMapper } from \"@/shared/utils/KeyUsageMapper\";\nimport PACKAGE from \"@root/package.json\";\n\nimport { type PkiCertificateDataSource } from \"./PkiCertificateDataSource\";\nimport {\n type PkiCertificateRequestDto,\n type PkiCertificateResponseDto,\n} from \"./pkiDataSourceTypes\";\n\n@injectable()\nexport class HttpPkiCertificateDataSource implements PkiCertificateDataSource {\n constructor(\n @inject(configTypes.Config) private readonly config: ContextModuleConfig,\n ) {}\n\n async fetchCertificate(\n pkiCertificateInfo: PkiCertificateInfo,\n ): Promise<Either<Error, PkiCertificate | undefined>> {\n const requestDto: PkiCertificateRequestDto = {\n output: \"descriptor\",\n target_device: pkiCertificateInfo.targetDevice,\n latest: true,\n public_key_id: pkiCertificateInfo.keyId,\n public_key_usage: pkiCertificateInfo.keyUsage,\n };\n\n try {\n const pkiCertificateResponse = await axios.request<\n PkiCertificateResponseDto[]\n >({\n method: \"GET\",\n url: `${this.config.cal.url}/certificates`,\n params: requestDto,\n headers: {\n \"X-Ledger-Client-Version\": `context-module/${PACKAGE.version}`,\n },\n });\n\n if (\n pkiCertificateResponse.status == 200 &&\n pkiCertificateResponse.data !== undefined &&\n pkiCertificateResponse.data.length > 0 &&\n this.isValidPkiCertificateResponse(\n pkiCertificateResponse.data[0],\n this.config.cal.mode,\n )\n ) {\n const payload = hexaStringToBuffer(\n HexStringUtils.appendSignatureToPayload(\n pkiCertificateResponse.data[0].descriptor.data,\n pkiCertificateResponse.data[0].descriptor.signatures[\n this.config.cal.mode\n ],\n SIGNATURE_TAG,\n ),\n );\n if (!payload) {\n return Left(\n Error(\n \"[ContextModule] HttpPkiCertificateDataSource: Cannot generate payload from fetched PKI Certificate\",\n ),\n );\n }\n const pkiCertificate: PkiCertificate = {\n payload: payload,\n keyUsageNumber: KeyUsageMapper.mapKeyUsageForFirmware(\n pkiCertificateInfo.keyUsage,\n ),\n };\n return Right(pkiCertificate);\n } else {\n return Left(\n Error(\n \"[ContextModule] HttpPkiCertificateDataSource: failed to fetch PKI for given descriptor\",\n ),\n );\n }\n } catch (_error) {\n return Left(\n Error(\n \"[ContextModule] HttpPkiCertificateDataSource: failed to fetch PKI for given descriptor\",\n ),\n );\n }\n }\n\n private isValidPkiCertificateResponse(\n value: unknown,\n mode: ContextModuleCalMode,\n ): value is PkiCertificateResponseDto {\n return (\n typeof value === \"object\" &&\n value !== null &&\n \"descriptor\" in value &&\n typeof value.descriptor === \"object\" &&\n value.descriptor !== null &&\n \"data\" in value.descriptor &&\n typeof value.descriptor.data === \"string\" &&\n \"signatures\" in value.descriptor &&\n typeof value.descriptor.signatures === \"object\" &&\n value.descriptor.signatures !== null &&\n mode in value.descriptor.signatures &&\n typeof (value.descriptor.signatures as Record<string, unknown>)[mode] ===\n \"string\"\n );\n }\n}\n"],
5
+ "mappings": "qtBAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,kCAAAE,IAAA,eAAAC,EAAAH,GAAA,IAAAI,EAAmC,2CACnCC,EAAkB,oBAClBC,EAAmC,qBACnCC,EAAoC,qBAEpCC,EAA4B,mCAO5BC,EAA8B,wCAC9BC,EAA+B,yCAC/BC,EAA+B,yCAC/BC,EAAoB,iCASb,IAAMC,EAAN,KAAuE,CAC5E,YAC+CC,EAC7C,CAD6C,YAAAA,CAC5C,CAEH,MAAM,iBACJC,EACoD,CACpD,MAAMC,EAAuC,CAC3C,OAAQ,aACR,cAAeD,EAAmB,aAClC,OAAQ,GACR,cAAeA,EAAmB,MAClC,iBAAkBA,EAAmB,QACvC,EAEA,GAAI,CACF,MAAME,EAAyB,MAAM,EAAAC,QAAM,QAEzC,CACA,OAAQ,MACR,IAAK,GAAG,KAAK,OAAO,IAAI,GAAG,gBAC3B,OAAQF,EACR,QAAS,CACP,0BAA2B,kBAAkB,EAAAG,QAAQ,OAAO,EAC9D,CACF,CAAC,EAED,GACEF,EAAuB,QAAU,KACjCA,EAAuB,OAAS,QAChCA,EAAuB,KAAK,OAAS,GACrC,KAAK,8BACHA,EAAuB,KAAK,CAAC,EAC7B,KAAK,OAAO,IAAI,IAClB,EACA,CACA,MAAMG,KAAU,sBACd,iBAAe,yBACbH,EAAuB,KAAK,CAAC,EAAE,WAAW,KAC1CA,EAAuB,KAAK,CAAC,EAAE,WAAW,WACxC,KAAK,OAAO,IAAI,IAClB,EACA,eACF,CACF,EACA,GAAI,CAACG,EACH,SAAO,QACL,MACE,oGACF,CACF,EAEF,MAAMC,EAAiC,CACrC,QAASD,EACT,eAAgB,iBAAe,uBAC7BL,EAAmB,QACrB,CACF,EACA,SAAO,SAAMM,CAAc,CAC7B,KACE,UAAO,QACL,MACE,wFACF,CACF,CAEJ,MAAiB,CACf,SAAO,QACL,MACE,wFACF,CACF,CACF,CACF,CAEQ,8BACNC,EACAC,EACoC,CACpC,OACE,OAAOD,GAAU,UACjBA,IAAU,MACV,eAAgBA,GAChB,OAAOA,EAAM,YAAe,UAC5BA,EAAM,aAAe,MACrB,SAAUA,EAAM,YAChB,OAAOA,EAAM,WAAW,MAAS,UACjC,eAAgBA,EAAM,YACtB,OAAOA,EAAM,WAAW,YAAe,UACvCA,EAAM,WAAW,aAAe,MAChCC,KAAQD,EAAM,WAAW,YACzB,OAAQA,EAAM,WAAW,WAAuCC,CAAI,GAClE,QAEN,CACF,EAhGaV,EAANW,EAAA,IADN,cAAW,EAGPC,EAAA,eAAO,cAAY,MAAM,IAFjBZ",
6
+ "names": ["HttpPkiCertificateDataSource_exports", "__export", "HttpPkiCertificateDataSource", "__toCommonJS", "import_device_management_kit", "import_axios", "import_inversify", "import_purify_ts", "import_configTypes", "import_SignatureTags", "import_HexStringUtils", "import_KeyUsageMapper", "import_package", "HttpPkiCertificateDataSource", "config", "pkiCertificateInfo", "requestDto", "pkiCertificateResponse", "axios", "PACKAGE", "payload", "pkiCertificate", "value", "mode", "__decorateClass", "__decorateParam"]
7
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";var d=Object.create;var f=Object.defineProperty;var u=Object.getOwnPropertyDescriptor;var l=Object.getOwnPropertyNames;var p=Object.getPrototypeOf,k=Object.prototype.hasOwnProperty;var C=(t,e,a,s)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of l(e))!k.call(t,i)&&i!==a&&f(t,i,{get:()=>e[i],enumerable:!(s=u(e,i))||s.enumerable});return t};var y=(t,e,a)=>(a=t!=null?d(p(t)):{},C(e||!t||!t.__esModule?f(a,"default",{value:t,enumerable:!0}):a,t));var o=y(require("axios")),r=require("purify-ts"),c=require("../../pki/data/HttpPkiCertificateDataSource"),n=require("../../pki/model/KeyUsage");vi.mock("axios");describe("HttpPkiCertificateDataSource",()=>{const t={cal:{url:"https://cal.com",mode:"test",branch:"main"}};describe("fetchCertificate",()=>{it("should return certificate",async()=>{const e={targetDevice:"targetDevice",keyUsage:n.KeyUsage.Calldata,keyId:"keyId"};vi.spyOn(o.default,"request").mockResolvedValue({status:200,data:[{descriptor:{data:"01020304",signatures:{test:"05060708"}}}]});const a=await new c.HttpPkiCertificateDataSource(t).fetchCertificate(e);expect(a).toEqual((0,r.Right)({keyUsageNumber:11,payload:new Uint8Array([1,2,3,4,21,4,5,6,7,8])}))}),it("should return an error when certificate is not found",async()=>{const e={targetDevice:"targetDevice",keyUsage:n.KeyUsage.Calldata,keyId:"keyId"};vi.spyOn(o.default,"request").mockResolvedValue({status:200,data:[]});const a=await new c.HttpPkiCertificateDataSource(t).fetchCertificate(e);expect(a).toEqual((0,r.Left)(Error("[ContextModule] HttpPkiCertificateDataSource: failed to fetch PKI for given descriptor")))}),it("should return an error when axios request fails",async()=>{const e={targetDevice:"targetDevice",keyUsage:n.KeyUsage.Calldata,keyId:"keyId"};vi.spyOn(o.default,"request").mockRejectedValue(new Error("error"));const a=await new c.HttpPkiCertificateDataSource(t).fetchCertificate(e);expect(a).toEqual((0,r.Left)(Error("[ContextModule] HttpPkiCertificateDataSource: failed to fetch PKI for given descriptor")))}),it("should return an error when payload cannot be generated",async()=>{const e={targetDevice:"targetDevice",keyUsage:n.KeyUsage.Calldata,keyId:"keyId"};vi.spyOn(o.default,"request").mockResolvedValue({status:200,data:[{descriptor:{data:"corrupteddata",signatures:{test:"05060708"}}}]});const a=await new c.HttpPkiCertificateDataSource(t).fetchCertificate(e);expect(a).toEqual((0,r.Left)(Error("[ContextModule] HttpPkiCertificateDataSource: Cannot generate payload from fetched PKI Certificate")))})})});
2
+ //# sourceMappingURL=HttpPkiCertificateDataSource.test.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../../../src/pki/data/HttpPkiCertificateDataSource.test.ts"],
4
+ "sourcesContent": ["import axios from \"axios\";\nimport { Left, Right } from \"purify-ts\";\n\nimport { type ContextModuleConfig } from \"@/config/model/ContextModuleConfig\";\nimport { HttpPkiCertificateDataSource } from \"@/pki/data/HttpPkiCertificateDataSource\";\nimport { KeyUsage } from \"@/pki/model/KeyUsage\";\nimport { type PkiCertificateInfo } from \"@/pki/model/PkiCertificateInfo\";\n\nvi.mock(\"axios\");\n\ndescribe(\"HttpPkiCertificateDataSource\", () => {\n const config = {\n cal: {\n url: \"https://cal.com\",\n mode: \"test\",\n branch: \"main\",\n },\n } as ContextModuleConfig;\n\n describe(\"fetchCertificate\", () => {\n it(\"should return certificate\", async () => {\n // GIVEN\n const pkiCertificateInfo: PkiCertificateInfo = {\n targetDevice: \"targetDevice\",\n keyUsage: KeyUsage.Calldata,\n keyId: \"keyId\",\n };\n vi.spyOn(axios, \"request\").mockResolvedValue({\n status: 200,\n data: [\n {\n descriptor: {\n data: \"01020304\",\n signatures: {\n test: \"05060708\",\n },\n },\n },\n ],\n });\n\n // WHEN\n const result = await new HttpPkiCertificateDataSource(\n config,\n ).fetchCertificate(pkiCertificateInfo);\n\n // THEN\n expect(result).toEqual(\n Right({\n keyUsageNumber: 11,\n payload: new Uint8Array([\n 0x01, 0x02, 0x03, 0x04, 0x15, 0x04, 0x05, 0x06, 0x07, 0x08,\n ]),\n }),\n );\n });\n\n it(\"should return an error when certificate is not found\", async () => {\n // GIVEN\n const pkiCertificateInfo: PkiCertificateInfo = {\n targetDevice: \"targetDevice\",\n keyUsage: KeyUsage.Calldata,\n keyId: \"keyId\",\n };\n vi.spyOn(axios, \"request\").mockResolvedValue({\n status: 200,\n data: [],\n });\n\n // WHEN\n const result = await new HttpPkiCertificateDataSource(\n config,\n ).fetchCertificate(pkiCertificateInfo);\n\n // THEN\n expect(result).toEqual(\n Left(\n Error(\n \"[ContextModule] HttpPkiCertificateDataSource: failed to fetch PKI for given descriptor\",\n ),\n ),\n );\n });\n\n it(\"should return an error when axios request fails\", async () => {\n // GIVEN\n const pkiCertificateInfo: PkiCertificateInfo = {\n targetDevice: \"targetDevice\",\n keyUsage: KeyUsage.Calldata,\n keyId: \"keyId\",\n };\n vi.spyOn(axios, \"request\").mockRejectedValue(new Error(\"error\"));\n\n // WHEN\n const result = await new HttpPkiCertificateDataSource(\n config,\n ).fetchCertificate(pkiCertificateInfo);\n\n // THEN\n expect(result).toEqual(\n Left(\n Error(\n \"[ContextModule] HttpPkiCertificateDataSource: failed to fetch PKI for given descriptor\",\n ),\n ),\n );\n });\n\n it(\"should return an error when payload cannot be generated\", async () => {\n // GIVEN\n const pkiCertificateInfo: PkiCertificateInfo = {\n targetDevice: \"targetDevice\",\n keyUsage: KeyUsage.Calldata,\n keyId: \"keyId\",\n };\n vi.spyOn(axios, \"request\").mockResolvedValue({\n status: 200,\n data: [\n {\n descriptor: {\n data: \"corrupteddata\",\n signatures: {\n test: \"05060708\",\n },\n },\n },\n ],\n });\n\n // WHEN\n const result = await new HttpPkiCertificateDataSource(\n config,\n ).fetchCertificate(pkiCertificateInfo);\n\n // THEN\n expect(result).toEqual(\n Left(\n Error(\n \"[ContextModule] HttpPkiCertificateDataSource: Cannot generate payload from fetched PKI Certificate\",\n ),\n ),\n );\n });\n });\n});\n"],
5
+ "mappings": "wdAAA,IAAAA,EAAkB,oBAClBC,EAA4B,qBAG5BC,EAA6C,mDAC7CC,EAAyB,gCAGzB,GAAG,KAAK,OAAO,EAEf,SAAS,+BAAgC,IAAM,CAC7C,MAAMC,EAAS,CACb,IAAK,CACH,IAAK,kBACL,KAAM,OACN,OAAQ,MACV,CACF,EAEA,SAAS,mBAAoB,IAAM,CACjC,GAAG,4BAA6B,SAAY,CAE1C,MAAMC,EAAyC,CAC7C,aAAc,eACd,SAAU,WAAS,SACnB,MAAO,OACT,EACA,GAAG,MAAM,EAAAC,QAAO,SAAS,EAAE,kBAAkB,CAC3C,OAAQ,IACR,KAAM,CACJ,CACE,WAAY,CACV,KAAM,WACN,WAAY,CACV,KAAM,UACR,CACF,CACF,CACF,CACF,CAAC,EAGD,MAAMC,EAAS,MAAM,IAAI,+BACvBH,CACF,EAAE,iBAAiBC,CAAkB,EAGrC,OAAOE,CAAM,EAAE,WACb,SAAM,CACJ,eAAgB,GAChB,QAAS,IAAI,WAAW,CACtB,EAAM,EAAM,EAAM,EAAM,GAAM,EAAM,EAAM,EAAM,EAAM,CACxD,CAAC,CACH,CAAC,CACH,CACF,CAAC,EAED,GAAG,uDAAwD,SAAY,CAErE,MAAMF,EAAyC,CAC7C,aAAc,eACd,SAAU,WAAS,SACnB,MAAO,OACT,EACA,GAAG,MAAM,EAAAC,QAAO,SAAS,EAAE,kBAAkB,CAC3C,OAAQ,IACR,KAAM,CAAC,CACT,CAAC,EAGD,MAAMC,EAAS,MAAM,IAAI,+BACvBH,CACF,EAAE,iBAAiBC,CAAkB,EAGrC,OAAOE,CAAM,EAAE,WACb,QACE,MACE,wFACF,CACF,CACF,CACF,CAAC,EAED,GAAG,kDAAmD,SAAY,CAEhE,MAAMF,EAAyC,CAC7C,aAAc,eACd,SAAU,WAAS,SACnB,MAAO,OACT,EACA,GAAG,MAAM,EAAAC,QAAO,SAAS,EAAE,kBAAkB,IAAI,MAAM,OAAO,CAAC,EAG/D,MAAMC,EAAS,MAAM,IAAI,+BACvBH,CACF,EAAE,iBAAiBC,CAAkB,EAGrC,OAAOE,CAAM,EAAE,WACb,QACE,MACE,wFACF,CACF,CACF,CACF,CAAC,EAED,GAAG,0DAA2D,SAAY,CAExE,MAAMF,EAAyC,CAC7C,aAAc,eACd,SAAU,WAAS,SACnB,MAAO,OACT,EACA,GAAG,MAAM,EAAAC,QAAO,SAAS,EAAE,kBAAkB,CAC3C,OAAQ,IACR,KAAM,CACJ,CACE,WAAY,CACV,KAAM,gBACN,WAAY,CACV,KAAM,UACR,CACF,CACF,CACF,CACF,CAAC,EAGD,MAAMC,EAAS,MAAM,IAAI,+BACvBH,CACF,EAAE,iBAAiBC,CAAkB,EAGrC,OAAOE,CAAM,EAAE,WACb,QACE,MACE,oGACF,CACF,CACF,CACF,CAAC,CACH,CAAC,CACH,CAAC",
6
+ "names": ["import_axios", "import_purify_ts", "import_HttpPkiCertificateDataSource", "import_KeyUsage", "config", "pkiCertificateInfo", "axios", "result"]
7
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";var f=Object.defineProperty;var c=Object.getOwnPropertyDescriptor;var a=Object.getOwnPropertyNames;var m=Object.prototype.hasOwnProperty;var p=(i,e,o,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let t of a(e))!m.call(i,t)&&t!==o&&f(i,t,{get:()=>e[t],enumerable:!(r=c(e,t))||r.enumerable});return i};var n=i=>p(f({},"__esModule",{value:!0}),i);var C={};module.exports=n(C);
2
+ //# sourceMappingURL=PkiCertificateDataSource.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../../../src/pki/data/PkiCertificateDataSource.ts"],
4
+ "sourcesContent": ["import { type Either } from \"purify-ts\";\n\nimport { type PkiCertificate } from \"@/pki/model/PkiCertificate\";\nimport { type PkiCertificateInfo } from \"@/pki/model/PkiCertificateInfo\";\n\nexport interface PkiCertificateDataSource {\n fetchCertificate(\n certificateInfos: PkiCertificateInfo,\n ): Promise<Either<Error, PkiCertificate | undefined>>;\n}\n"],
5
+ "mappings": "+WAAA,IAAAA,EAAA,kBAAAC,EAAAD",
6
+ "names": ["PkiCertificateDataSource_exports", "__toCommonJS"]
7
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";var s=Object.defineProperty;var g=Object.getOwnPropertyDescriptor;var a=Object.getOwnPropertyNames;var o=Object.prototype.hasOwnProperty;var p=(e,t,n,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let i of a(t))!o.call(e,i)&&i!==n&&s(e,i,{get:()=>t[i],enumerable:!(r=g(t,i))||r.enumerable});return e};var c=e=>p(s({},"__esModule",{value:!0}),e);var d={};module.exports=c(d);
2
+ //# sourceMappingURL=pkiDataSourceTypes.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../../../src/pki/data/pkiDataSourceTypes.ts"],
4
+ "sourcesContent": ["export type PkiCertificateRequestDto = {\n public_key_id: string | undefined;\n public_key_usage: string;\n output: string;\n target_device: string;\n latest: boolean;\n};\n\nexport type PkiCertificateResponseDto = {\n id: string;\n target_device: string;\n not_valid_after: string;\n public_key_usage: string;\n certificate_version: string;\n descriptor: {\n data: string;\n descriptorType: string;\n signatures: {\n prod: string;\n test: string;\n };\n };\n};\n"],
5
+ "mappings": "+WAAA,IAAAA,EAAA,kBAAAC,EAAAD",
6
+ "names": ["pkiDataSourceTypes_exports", "__toCommonJS"]
7
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";var a=Object.defineProperty;var p=Object.getOwnPropertyDescriptor;var u=Object.getOwnPropertyNames;var d=Object.prototype.hasOwnProperty;var k=(t,o)=>{for(var i in o)a(t,i,{get:o[i],enumerable:!0})},C=(t,o,i,r)=>{if(o&&typeof o=="object"||typeof o=="function")for(let e of u(o))!d.call(t,e)&&e!==i&&a(t,e,{get:()=>o[e],enumerable:!(r=p(o,e))||r.enumerable});return t};var P=t=>C(a({},"__esModule",{value:!0}),t);var s={};k(s,{nanoPkiModuleFactory:()=>l});module.exports=P(s);var n=require("inversify"),c=require("../../pki/data/HttpPkiCertificateDataSource"),m=require("../../pki/domain/DefaultPkiCertificateLoader"),f=require("./pkiTypes");const l=()=>new n.ContainerModule((t,o,i,r)=>{t(f.pkiTypes.PkiCertificateDataSource).to(c.HttpPkiCertificateDataSource),t(f.pkiTypes.PkiCertificateLoader).to(m.DefaultPkiCertificateLoader)});0&&(module.exports={nanoPkiModuleFactory});
2
+ //# sourceMappingURL=pkiModuleFactory.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../../../src/pki/di/pkiModuleFactory.ts"],
4
+ "sourcesContent": ["import { ContainerModule } from \"inversify\";\n\nimport { HttpPkiCertificateDataSource } from \"@/pki/data/HttpPkiCertificateDataSource\";\nimport { DefaultPkiCertificateLoader } from \"@/pki/domain/DefaultPkiCertificateLoader\";\n\nimport { pkiTypes } from \"./pkiTypes\";\n\nexport const nanoPkiModuleFactory = () =>\n new ContainerModule((bind, _unbind, _isBound, _rebind) => {\n bind(pkiTypes.PkiCertificateDataSource).to(HttpPkiCertificateDataSource);\n bind(pkiTypes.PkiCertificateLoader).to(DefaultPkiCertificateLoader);\n });\n"],
5
+ "mappings": "yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,0BAAAE,IAAA,eAAAC,EAAAH,GAAA,IAAAI,EAAgC,qBAEhCC,EAA6C,mDAC7CC,EAA4C,oDAE5CC,EAAyB,sBAElB,MAAML,EAAuB,IAClC,IAAI,kBAAgB,CAACM,EAAMC,EAASC,EAAUC,IAAY,CACxDH,EAAK,WAAS,wBAAwB,EAAE,GAAG,8BAA4B,EACvEA,EAAK,WAAS,oBAAoB,EAAE,GAAG,6BAA2B,CACpE,CAAC",
6
+ "names": ["pkiModuleFactory_exports", "__export", "nanoPkiModuleFactory", "__toCommonJS", "import_inversify", "import_HttpPkiCertificateDataSource", "import_DefaultPkiCertificateLoader", "import_pkiTypes", "bind", "_unbind", "_isBound", "_rebind"]
7
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";var a=Object.defineProperty;var c=Object.getOwnPropertyDescriptor;var f=Object.getOwnPropertyNames;var k=Object.prototype.hasOwnProperty;var C=(i,e)=>{for(var r in e)a(i,r,{get:e[r],enumerable:!0})},P=(i,e,r,o)=>{if(e&&typeof e=="object"||typeof e=="function")for(let t of f(e))!k.call(i,t)&&t!==r&&a(i,t,{get:()=>e[t],enumerable:!(o=c(e,t))||o.enumerable});return i};var S=i=>P(a({},"__esModule",{value:!0}),i);var y={};C(y,{pkiTypes:()=>p});module.exports=S(y);const p={PkiCertificateDataSource:Symbol.for("PkiCertificateDataSource"),PkiCertificateLoader:Symbol.for("PkiCertificateLoader")};0&&(module.exports={pkiTypes});
2
+ //# sourceMappingURL=pkiTypes.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../../../src/pki/di/pkiTypes.ts"],
4
+ "sourcesContent": ["export const pkiTypes = {\n PkiCertificateDataSource: Symbol.for(\"PkiCertificateDataSource\"),\n PkiCertificateLoader: Symbol.for(\"PkiCertificateLoader\"),\n};\n"],
5
+ "mappings": "yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,cAAAE,IAAA,eAAAC,EAAAH,GAAO,MAAME,EAAW,CACtB,yBAA0B,OAAO,IAAI,0BAA0B,EAC/D,qBAAsB,OAAO,IAAI,sBAAsB,CACzD",
6
+ "names": ["pkiTypes_exports", "__export", "pkiTypes", "__toCommonJS"]
7
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";var o=Object.defineProperty;var n=Object.getOwnPropertyDescriptor;var k=Object.getOwnPropertyNames;var P=Object.prototype.hasOwnProperty;var d=(i,t)=>{for(var r in t)o(i,r,{get:t[r],enumerable:!0})},S=(i,t,r,a)=>{if(t&&typeof t=="object"||typeof t=="function")for(let e of k(t))!P.call(i,e)&&e!==r&&o(i,e,{get:()=>t[e],enumerable:!(a=n(t,e))||a.enumerable});return i};var y=i=>S(o({},"__esModule",{value:!0}),i),s=(i,t,r,a)=>{for(var e=a>1?void 0:a?n(t,r):t,m=i.length-1,p;m>=0;m--)(p=i[m])&&(e=(a?p(t,r,e):p(e))||e);return a&&e&&o(t,r,e),e},u=(i,t)=>(r,a)=>t(r,a,i);var h={};d(h,{DefaultPkiCertificateLoader:()=>c});module.exports=y(h);var f=require("inversify"),C=require("../../pki/di/pkiTypes");let c=class{_dataSource;constructor(t){this._dataSource=t}async loadCertificate(t){return(await this._dataSource.fetchCertificate(t)).orDefault(void 0)}};c=s([(0,f.injectable)(),u(0,(0,f.inject)(C.pkiTypes.PkiCertificateDataSource))],c);0&&(module.exports={DefaultPkiCertificateLoader});
2
+ //# sourceMappingURL=DefaultPkiCertificateLoader.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../../../src/pki/domain/DefaultPkiCertificateLoader.ts"],
4
+ "sourcesContent": ["import { inject, injectable } from \"inversify\";\n\nimport { type PkiCertificateDataSource } from \"@/pki/data/PkiCertificateDataSource\";\nimport { pkiTypes } from \"@/pki/di/pkiTypes\";\nimport { type PkiCertificate } from \"@/pki/model/PkiCertificate\";\nimport { type PkiCertificateInfo } from \"@/pki/model/PkiCertificateInfo\";\n\nimport { PkiCertificateLoader } from \"./PkiCertificateLoader\";\n\n@injectable()\nexport class DefaultPkiCertificateLoader implements PkiCertificateLoader {\n private _dataSource: PkiCertificateDataSource;\n\n constructor(\n @inject(pkiTypes.PkiCertificateDataSource)\n dataSource: PkiCertificateDataSource,\n ) {\n this._dataSource = dataSource;\n }\n\n async loadCertificate(\n certificateInfos: PkiCertificateInfo,\n ): Promise<PkiCertificate | undefined> {\n const certificate =\n await this._dataSource.fetchCertificate(certificateInfos);\n\n return certificate.orDefault(undefined);\n }\n}\n"],
5
+ "mappings": "okBAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,iCAAAE,IAAA,eAAAC,EAAAH,GAAA,IAAAI,EAAmC,qBAGnCC,EAAyB,6BAOlB,IAAMC,EAAN,KAAkE,CAC/D,YAER,YAEEC,EACA,CACA,KAAK,YAAcA,CACrB,CAEA,MAAM,gBACJC,EACqC,CAIrC,OAFE,MAAM,KAAK,YAAY,iBAAiBA,CAAgB,GAEvC,UAAU,MAAS,CACxC,CACF,EAlBaF,EAANG,EAAA,IADN,cAAW,EAKPC,EAAA,eAAO,WAAS,wBAAwB,IAJhCJ",
6
+ "names": ["DefaultPkiCertificateLoader_exports", "__export", "DefaultPkiCertificateLoader", "__toCommonJS", "import_inversify", "import_pkiTypes", "DefaultPkiCertificateLoader", "dataSource", "certificateInfos", "__decorateClass", "__decorateParam"]
7
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";var i=require("purify-ts"),r=require("../../pki/domain/DefaultPkiCertificateLoader"),o=require("../../pki/model/KeyId"),c=require("../../pki/model/KeyUsage");describe("DefaultPkiCertificateLoader",()=>{describe("loadCertificate",()=>{it("should call loadCertificate",async()=>{const e={targetDevice:"targetDevice",keyUsage:c.KeyUsage.Calldata,keyId:o.KeyId.CalNetwork},t={keyUsageNumber:11,payload:new Uint8Array([1,2,3,4,21,4,5,6,7,8])},a={fetchCertificate:vi.fn().mockResolvedValue((0,i.Right)(t))},f=await new r.DefaultPkiCertificateLoader(a).loadCertificate(e);expect(f).toEqual(t),expect(a.fetchCertificate).toHaveBeenCalledWith(e)})})});
2
+ //# sourceMappingURL=DefaultPkiCertificateLoader.test.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../../../src/pki/domain/DefaultPkiCertificateLoader.test.ts"],
4
+ "sourcesContent": ["import { Right } from \"purify-ts\";\n\nimport { DefaultPkiCertificateLoader } from \"@/pki/domain/DefaultPkiCertificateLoader\";\nimport { KeyId } from \"@/pki/model/KeyId\";\nimport { KeyUsage } from \"@/pki/model/KeyUsage\";\nimport { type PkiCertificateInfo } from \"@/pki/model/PkiCertificateInfo\";\n\ndescribe(\"DefaultPkiCertificateLoader\", () => {\n describe(\"loadCertificate\", () => {\n it(\"should call loadCertificate\", async () => {\n // GIVEN\n const certificateInfos: PkiCertificateInfo = {\n targetDevice: \"targetDevice\",\n keyUsage: KeyUsage.Calldata,\n keyId: KeyId.CalNetwork,\n };\n const certificate = {\n keyUsageNumber: 11,\n payload: new Uint8Array([\n 0x01, 0x02, 0x03, 0x04, 0x15, 0x04, 0x05, 0x06, 0x07, 0x08,\n ]),\n };\n const dataSource = {\n fetchCertificate: vi.fn().mockResolvedValue(Right(certificate)),\n };\n\n // WHEN\n const loader = new DefaultPkiCertificateLoader(dataSource);\n const result = await loader.loadCertificate(certificateInfos);\n\n // THEN\n expect(result).toEqual(certificate);\n expect(dataSource.fetchCertificate).toHaveBeenCalledWith(\n certificateInfos,\n );\n });\n });\n});\n"],
5
+ "mappings": "aAAA,IAAAA,EAAsB,qBAEtBC,EAA4C,oDAC5CC,EAAsB,6BACtBC,EAAyB,gCAGzB,SAAS,8BAA+B,IAAM,CAC5C,SAAS,kBAAmB,IAAM,CAChC,GAAG,8BAA+B,SAAY,CAE5C,MAAMC,EAAuC,CAC3C,aAAc,eACd,SAAU,WAAS,SACnB,MAAO,QAAM,UACf,EACMC,EAAc,CAClB,eAAgB,GAChB,QAAS,IAAI,WAAW,CACtB,EAAM,EAAM,EAAM,EAAM,GAAM,EAAM,EAAM,EAAM,EAAM,CACxD,CAAC,CACH,EACMC,EAAa,CACjB,iBAAkB,GAAG,GAAG,EAAE,qBAAkB,SAAMD,CAAW,CAAC,CAChE,EAIME,EAAS,MADA,IAAI,8BAA4BD,CAAU,EAC7B,gBAAgBF,CAAgB,EAG5D,OAAOG,CAAM,EAAE,QAAQF,CAAW,EAClC,OAAOC,EAAW,gBAAgB,EAAE,qBAClCF,CACF,CACF,CAAC,CACH,CAAC,CACH,CAAC",
6
+ "names": ["import_purify_ts", "import_DefaultPkiCertificateLoader", "import_KeyId", "import_KeyUsage", "certificateInfos", "certificate", "dataSource", "result"]
7
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";var f=Object.defineProperty;var a=Object.getOwnPropertyDescriptor;var c=Object.getOwnPropertyNames;var n=Object.prototype.hasOwnProperty;var C=(e,i,o,r)=>{if(i&&typeof i=="object"||typeof i=="function")for(let t of c(i))!n.call(e,t)&&t!==o&&f(e,t,{get:()=>i[t],enumerable:!(r=a(i,t))||r.enumerable});return e};var P=e=>C(f({},"__esModule",{value:!0}),e);var k={};module.exports=P(k);
2
+ //# sourceMappingURL=PkiCertificateLoader.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../../../src/pki/domain/PkiCertificateLoader.ts"],
4
+ "sourcesContent": ["import { type PkiCertificate } from \"@/pki/model/PkiCertificate\";\nimport { type PkiCertificateInfo } from \"@/pki/model/PkiCertificateInfo\";\n\nexport interface PkiCertificateLoader {\n loadCertificate(\n certificateInfos: PkiCertificateInfo,\n ): Promise<PkiCertificate | undefined>;\n}\n"],
5
+ "mappings": "+WAAA,IAAAA,EAAA,kBAAAC,EAAAD",
6
+ "names": ["PkiCertificateLoader_exports", "__toCommonJS"]
7
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";var l=Object.defineProperty;var k=Object.getOwnPropertyDescriptor;var m=Object.getOwnPropertyNames;var c=Object.prototype.hasOwnProperty;var s=(e,t)=>{for(var _ in t)l(e,_,{get:t[_],enumerable:!0})},u=(e,t,_,o)=>{if(t&&typeof t=="object"||typeof t=="function")for(let r of m(t))!c.call(e,r)&&r!==_&&l(e,r,{get:()=>t[r],enumerable:!(o=k(t,r))||o.enumerable});return e};var d=e=>u(l({},"__esModule",{value:!0}),e);var g={};s(g,{KeyId:()=>n});module.exports=d(g);var n=(a=>(a.Test="test",a.PersoV2="persov2",a.LedgerRootV3="ledger_root_v3",a.PluginSelectorKey="plugin_selector_key",a.NftMetadataKey="nft_metadata_key",a.PartnerMetadataKey="partner_metadata_key",a.Erc20MetadataKey="erc20_metadata_key",a.DomainMetadataKey="domain_metadata_key",a.CalCalldataKey="cal_calldata_key",a.CalTrustedNameKey="cal_trusted_name_key",a.CalNetwork="cal_network",a))(n||{});0&&(module.exports={KeyId});
2
+ //# sourceMappingURL=KeyId.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../../../src/pki/model/KeyId.ts"],
4
+ "sourcesContent": ["export enum KeyId {\n Test = \"test\",\n PersoV2 = \"persov2\",\n LedgerRootV3 = \"ledger_root_v3\",\n PluginSelectorKey = \"plugin_selector_key\",\n NftMetadataKey = \"nft_metadata_key\",\n PartnerMetadataKey = \"partner_metadata_key\",\n Erc20MetadataKey = \"erc20_metadata_key\",\n DomainMetadataKey = \"domain_metadata_key\",\n CalCalldataKey = \"cal_calldata_key\",\n CalTrustedNameKey = \"cal_trusted_name_key\",\n CalNetwork = \"cal_network\",\n}\n"],
5
+ "mappings": "yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,WAAAE,IAAA,eAAAC,EAAAH,GAAO,IAAKE,OACVA,EAAA,KAAO,OACPA,EAAA,QAAU,UACVA,EAAA,aAAe,iBACfA,EAAA,kBAAoB,sBACpBA,EAAA,eAAiB,mBACjBA,EAAA,mBAAqB,uBACrBA,EAAA,iBAAmB,qBACnBA,EAAA,kBAAoB,sBACpBA,EAAA,eAAiB,mBACjBA,EAAA,kBAAoB,uBACpBA,EAAA,WAAa,cAXHA,OAAA",
6
+ "names": ["KeyId_exports", "__export", "KeyId", "__toCommonJS"]
7
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";var i=Object.defineProperty;var d=Object.getOwnPropertyDescriptor;var _=Object.getOwnPropertyNames;var e=Object.prototype.hasOwnProperty;var l=(n,r)=>{for(var a in r)i(n,a,{get:r[a],enumerable:!0})},h=(n,r,a,c)=>{if(r&&typeof r=="object"||typeof r=="function")for(let o of _(r))!e.call(n,o)&&o!==a&&i(n,o,{get:()=>r[o],enumerable:!(c=d(r,o))||c.enumerable});return n};var m=n=>h(i({},"__esModule",{value:!0}),n);var p={};l(p,{KeyUsage:()=>u});module.exports=m(p);var u=(t=>(t.GenuineCheck="genuine_check",t.ExchangePayload="exchange_payload",t.NftMeta="nft_meta",t.TrustedName="trusted_name",t.BackupProvider="backup_provider",t.ProtectOrchestrator="protect_orchestrator",t.PluginMeta="plugin_meta",t.CoinMeta="coin_meta",t.SeedIdAuth="seed_id_auth",t.TxSimulationSigner="tx_simu_signer",t.Calldata="calldata",t.Network="network",t))(u||{});0&&(module.exports={KeyUsage});
2
+ //# sourceMappingURL=KeyUsage.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../../../src/pki/model/KeyUsage.ts"],
4
+ "sourcesContent": ["export enum KeyUsage {\n GenuineCheck = \"genuine_check\",\n ExchangePayload = \"exchange_payload\",\n NftMeta = \"nft_meta\",\n TrustedName = \"trusted_name\",\n BackupProvider = \"backup_provider\",\n ProtectOrchestrator = \"protect_orchestrator\",\n PluginMeta = \"plugin_meta\",\n CoinMeta = \"coin_meta\",\n SeedIdAuth = \"seed_id_auth\",\n TxSimulationSigner = \"tx_simu_signer\",\n Calldata = \"calldata\",\n Network = \"network\",\n}\n"],
5
+ "mappings": "yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,cAAAE,IAAA,eAAAC,EAAAH,GAAO,IAAKE,OACVA,EAAA,aAAe,gBACfA,EAAA,gBAAkB,mBAClBA,EAAA,QAAU,WACVA,EAAA,YAAc,eACdA,EAAA,eAAiB,kBACjBA,EAAA,oBAAsB,uBACtBA,EAAA,WAAa,cACbA,EAAA,SAAW,YACXA,EAAA,WAAa,eACbA,EAAA,mBAAqB,iBACrBA,EAAA,SAAW,WACXA,EAAA,QAAU,UAZAA,OAAA",
6
+ "names": ["KeyUsage_exports", "__export", "KeyUsage", "__toCommonJS"]
7
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";var i=Object.defineProperty;var p=Object.getOwnPropertyDescriptor;var b=Object.getOwnPropertyNames;var k=Object.prototype.hasOwnProperty;var m=(r,e,y,t)=>{if(e&&typeof e=="object"||typeof e=="function")for(let a of b(e))!k.call(r,a)&&a!==y&&i(r,a,{get:()=>e[a],enumerable:!(t=p(e,a))||t.enumerable});return r};var n=r=>m(i({},"__esModule",{value:!0}),r);var o={};module.exports=n(o);
2
+ //# sourceMappingURL=PkiCertificate.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../../../src/pki/model/PkiCertificate.ts"],
4
+ "sourcesContent": ["export type PkiCertificate = {\n keyUsageNumber: number;\n payload: Uint8Array;\n};\n"],
5
+ "mappings": "+WAAA,IAAAA,EAAA,kBAAAC,EAAAD",
6
+ "names": ["PkiCertificate_exports", "__toCommonJS"]
7
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";var r=Object.defineProperty;var a=Object.getOwnPropertyDescriptor;var s=Object.getOwnPropertyNames;var o=Object.prototype.hasOwnProperty;var p=(t,e,y,g)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of s(e))!o.call(t,i)&&i!==y&&r(t,i,{get:()=>e[i],enumerable:!(g=a(e,i))||g.enumerable});return t};var k=t=>p(r({},"__esModule",{value:!0}),t);var U={};module.exports=k(U);
2
+ //# sourceMappingURL=PkiCertificateInfo.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../../../src/pki/model/PkiCertificateInfo.ts"],
4
+ "sourcesContent": ["import type { KeyUsage } from \"@/pki/model/KeyUsage\";\n\nexport type PkiCertificateInfo = {\n targetDevice: string;\n keyUsage: KeyUsage;\n keyId: string;\n};\n"],
5
+ "mappings": "+WAAA,IAAAA,EAAA,kBAAAC,EAAAD",
6
+ "names": ["PkiCertificateInfo_exports", "__toCommonJS"]
7
+ }
@@ -1,2 +1,2 @@
1
- "use strict";var a=Object.defineProperty;var N=Object.getOwnPropertyDescriptor;var R=Object.getOwnPropertyNames;var p=Object.prototype.hasOwnProperty;var c=(t,e)=>{for(var o in e)a(t,o,{get:e[o],enumerable:!0})},s=(t,e,o,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of R(e))!p.call(t,n)&&n!==o&&a(t,n,{get:()=>e[n],enumerable:!(i=N(e,n))||i.enumerable});return t};var l=t=>s(a({},"__esModule",{value:!0}),t);var u={};c(u,{ClearSignContextType:()=>E});module.exports=l(u);var E=(r=>(r.TOKEN="token",r.NFT="nft",r.TRUSTED_NAME="trustedName",r.PLUGIN="plugin",r.EXTERNAL_PLUGIN="externalPlugin",r.TRANSACTION_INFO="transactionInfo",r.ENUM="enum",r.TRANSACTION_FIELD_DESCRIPTION="transactionFieldDescription",r.ERROR="error",r))(E||{});0&&(module.exports={ClearSignContextType});
1
+ "use strict";var a=Object.defineProperty;var o=Object.getOwnPropertyDescriptor;var y=Object.getOwnPropertyNames;var T=Object.prototype.hasOwnProperty;var c=(r,t)=>{for(var i in t)a(r,i,{get:t[i],enumerable:!0})},l=(r,t,i,p)=>{if(t&&typeof t=="object"||typeof t=="function")for(let n of y(t))!T.call(r,n)&&n!==i&&a(r,n,{get:()=>t[n],enumerable:!(p=o(t,n))||p.enumerable});return r};var x=r=>l(a({},"__esModule",{value:!0}),r);var E={};c(E,{ClearSignContextType:()=>C});module.exports=x(E);var C=(e=>(e.TOKEN="token",e.NFT="nft",e.TRUSTED_NAME="trustedName",e.PLUGIN="plugin",e.EXTERNAL_PLUGIN="externalPlugin",e.TRANSACTION_INFO="transactionInfo",e.ENUM="enum",e.TRANSACTION_FIELD_DESCRIPTION="transactionFieldDescription",e.WEB3_CHECK="web3Check",e.ERROR="error",e))(C||{});0&&(module.exports={ClearSignContextType});
2
2
  //# sourceMappingURL=ClearSignContext.js.map