@ledgerhq/context-module 0.0.0-develop-20241017000946 → 0.0.0-signer-eth-20250122093657

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 (366) hide show
  1. package/README.md +4 -6
  2. package/lib/cjs/index.js +1 -1126
  3. package/lib/cjs/index.js.map +4 -4
  4. package/lib/cjs/package.json +58 -0
  5. package/lib/cjs/src/ContextModule.js +2 -0
  6. package/lib/cjs/src/ContextModule.js.map +7 -0
  7. package/lib/cjs/src/ContextModuleBuilder.js +2 -0
  8. package/lib/cjs/src/ContextModuleBuilder.js.map +7 -0
  9. package/lib/cjs/src/ContextModuleBuilder.test.js +2 -0
  10. package/lib/cjs/src/ContextModuleBuilder.test.js.map +7 -0
  11. package/lib/cjs/src/DefaultContextModule.js +2 -0
  12. package/lib/cjs/src/DefaultContextModule.js.map +7 -0
  13. package/lib/cjs/src/DefaultContextModule.test.js +2 -0
  14. package/lib/cjs/src/DefaultContextModule.test.js.map +7 -0
  15. package/lib/cjs/src/config/di/configModuleFactory.js +2 -0
  16. package/lib/cjs/src/config/di/configModuleFactory.js.map +7 -0
  17. package/lib/cjs/src/config/di/configTypes.js +2 -0
  18. package/lib/cjs/src/config/di/configTypes.js.map +7 -0
  19. package/lib/cjs/src/config/model/ContextModuleConfig.js +2 -0
  20. package/lib/cjs/src/config/model/ContextModuleConfig.js.map +7 -0
  21. package/lib/cjs/src/di.js +2 -0
  22. package/lib/cjs/src/di.js.map +7 -0
  23. package/lib/cjs/src/external-plugin/data/DAppDto.js +2 -0
  24. package/lib/cjs/src/external-plugin/data/DAppDto.js.map +7 -0
  25. package/lib/cjs/src/external-plugin/data/ExternalPluginDataSource.js +2 -0
  26. package/lib/cjs/src/external-plugin/data/ExternalPluginDataSource.js.map +7 -0
  27. package/lib/cjs/src/external-plugin/data/HttpExternalPluginDataSource.js +2 -0
  28. package/lib/cjs/src/external-plugin/data/HttpExternalPluginDataSource.js.map +7 -0
  29. package/lib/cjs/src/external-plugin/data/HttpExternalPluginDataSource.test.js +2 -0
  30. package/lib/cjs/src/external-plugin/data/HttpExternalPluginDataSource.test.js.map +7 -0
  31. package/lib/cjs/src/external-plugin/di/externalPluginModuleFactory.js +2 -0
  32. package/lib/cjs/src/external-plugin/di/externalPluginModuleFactory.js.map +7 -0
  33. package/lib/cjs/src/external-plugin/di/externalPluginTypes.js +2 -0
  34. package/lib/cjs/src/external-plugin/di/externalPluginTypes.js.map +7 -0
  35. package/lib/cjs/src/external-plugin/domain/ExternalPluginContextLoader.js +2 -0
  36. package/lib/cjs/src/external-plugin/domain/ExternalPluginContextLoader.js.map +7 -0
  37. package/lib/cjs/src/external-plugin/domain/ExternalPluginContextLoader.test.js +2 -0
  38. package/lib/cjs/src/external-plugin/domain/ExternalPluginContextLoader.test.js.map +7 -0
  39. package/lib/cjs/src/external-plugin/model/DappInfos.js +2 -0
  40. package/lib/cjs/src/external-plugin/model/DappInfos.js.map +7 -0
  41. package/lib/cjs/src/external-plugin/model/SelectorDetails.js +2 -0
  42. package/lib/cjs/src/external-plugin/model/SelectorDetails.js.map +7 -0
  43. package/lib/cjs/src/index.js +2 -0
  44. package/lib/cjs/src/index.js.map +7 -0
  45. package/lib/cjs/src/nft/data/HttpNftDataSource.js +2 -0
  46. package/lib/cjs/src/nft/data/HttpNftDataSource.js.map +7 -0
  47. package/lib/cjs/src/nft/data/HttpNftDataSource.test.js +2 -0
  48. package/lib/cjs/src/nft/data/HttpNftDataSource.test.js.map +7 -0
  49. package/lib/cjs/src/nft/data/NftDataSource.js +2 -0
  50. package/lib/cjs/src/nft/data/NftDataSource.js.map +7 -0
  51. package/lib/cjs/src/nft/di/nftModuleFactory.js +2 -0
  52. package/lib/cjs/src/nft/di/nftModuleFactory.js.map +7 -0
  53. package/lib/cjs/src/nft/di/nftTypes.js +2 -0
  54. package/lib/cjs/src/nft/di/nftTypes.js.map +7 -0
  55. package/lib/cjs/src/nft/domain/NftContextLoader.js +2 -0
  56. package/lib/cjs/src/nft/domain/NftContextLoader.js.map +7 -0
  57. package/lib/cjs/src/nft/domain/NftContextLoader.test.js +2 -0
  58. package/lib/cjs/src/nft/domain/NftContextLoader.test.js.map +7 -0
  59. package/lib/cjs/src/shared/domain/ContextLoader.js +2 -0
  60. package/lib/cjs/src/shared/domain/ContextLoader.js.map +7 -0
  61. package/lib/cjs/src/shared/model/ClearSignContext.js +2 -0
  62. package/lib/cjs/src/shared/model/ClearSignContext.js.map +7 -0
  63. package/lib/cjs/src/shared/model/GenericPath.js +2 -0
  64. package/lib/cjs/src/shared/model/GenericPath.js.map +7 -0
  65. package/lib/cjs/src/shared/model/TransactionContext.js +2 -0
  66. package/lib/cjs/src/shared/model/TransactionContext.js.map +7 -0
  67. package/lib/cjs/src/shared/model/TransactionSubset.js +2 -0
  68. package/lib/cjs/src/shared/model/TransactionSubset.js.map +7 -0
  69. package/lib/cjs/src/shared/model/TypedDataClearSignContext.js +2 -0
  70. package/lib/cjs/src/shared/model/TypedDataClearSignContext.js.map +7 -0
  71. package/lib/cjs/src/shared/model/TypedDataContext.js +2 -0
  72. package/lib/cjs/src/shared/model/TypedDataContext.js.map +7 -0
  73. package/lib/cjs/src/shared/utils/HexStringUtils.js +2 -0
  74. package/lib/cjs/src/shared/utils/HexStringUtils.js.map +7 -0
  75. package/lib/cjs/src/token/data/HttpTokenDataSource.js +2 -0
  76. package/lib/cjs/src/token/data/HttpTokenDataSource.js.map +7 -0
  77. package/lib/cjs/src/token/data/HttpTokenDataSource.test.js +2 -0
  78. package/lib/cjs/src/token/data/HttpTokenDataSource.test.js.map +7 -0
  79. package/lib/cjs/src/token/data/TokenDataSource.js +2 -0
  80. package/lib/cjs/src/token/data/TokenDataSource.js.map +7 -0
  81. package/lib/cjs/src/token/data/TokenDto.js +2 -0
  82. package/lib/cjs/src/token/data/TokenDto.js.map +7 -0
  83. package/lib/cjs/src/token/di/tokenModuleFactory.js +2 -0
  84. package/lib/cjs/src/token/di/tokenModuleFactory.js.map +7 -0
  85. package/lib/cjs/src/token/di/tokenTypes.js +2 -0
  86. package/lib/cjs/src/token/di/tokenTypes.js.map +7 -0
  87. package/lib/cjs/src/token/domain/TokenContextLoader.js +2 -0
  88. package/lib/cjs/src/token/domain/TokenContextLoader.js.map +7 -0
  89. package/lib/cjs/src/token/domain/TokenContextLoader.test.js +2 -0
  90. package/lib/cjs/src/token/domain/TokenContextLoader.test.js.map +7 -0
  91. package/lib/cjs/src/transaction/data/CalldataDto.js +2 -0
  92. package/lib/cjs/src/transaction/data/CalldataDto.js.map +7 -0
  93. package/lib/cjs/src/transaction/data/HttpTransactionDataSource.js +2 -0
  94. package/lib/cjs/src/transaction/data/HttpTransactionDataSource.js.map +7 -0
  95. package/lib/cjs/src/transaction/data/HttpTransactionDataSource.test.js +2 -0
  96. package/lib/cjs/src/transaction/data/HttpTransactionDataSource.test.js.map +7 -0
  97. package/lib/cjs/src/transaction/data/TransactionDataSource.js +2 -0
  98. package/lib/cjs/src/transaction/data/TransactionDataSource.js.map +7 -0
  99. package/lib/cjs/src/transaction/di/transactionModuleFactory.js +2 -0
  100. package/lib/cjs/src/transaction/di/transactionModuleFactory.js.map +7 -0
  101. package/lib/cjs/src/transaction/di/transactionTypes.js +2 -0
  102. package/lib/cjs/src/transaction/di/transactionTypes.js.map +7 -0
  103. package/lib/cjs/src/transaction/domain/TransactionContextLoader.js +2 -0
  104. package/lib/cjs/src/transaction/domain/TransactionContextLoader.js.map +7 -0
  105. package/lib/cjs/src/transaction/domain/TransactionContextLoader.test.js +2 -0
  106. package/lib/cjs/src/transaction/domain/TransactionContextLoader.test.js.map +7 -0
  107. package/lib/cjs/src/trusted-name/data/HttpTrustedNameDataSource.js +2 -0
  108. package/lib/cjs/src/trusted-name/data/HttpTrustedNameDataSource.js.map +7 -0
  109. package/lib/cjs/src/trusted-name/data/HttpTrustedNameDataSource.test.js +2 -0
  110. package/lib/cjs/src/trusted-name/data/HttpTrustedNameDataSource.test.js.map +7 -0
  111. package/lib/cjs/src/trusted-name/data/TrustedNameDataSource.js +2 -0
  112. package/lib/cjs/src/trusted-name/data/TrustedNameDataSource.js.map +7 -0
  113. package/lib/cjs/src/trusted-name/data/TrustedNameDto.js +2 -0
  114. package/lib/cjs/src/trusted-name/data/TrustedNameDto.js.map +7 -0
  115. package/lib/cjs/src/trusted-name/di/trustedNameModuleFactory.js +2 -0
  116. package/lib/cjs/src/trusted-name/di/trustedNameModuleFactory.js.map +7 -0
  117. package/lib/cjs/src/trusted-name/di/trustedNameTypes.js +2 -0
  118. package/lib/cjs/src/trusted-name/di/trustedNameTypes.js.map +7 -0
  119. package/lib/cjs/src/trusted-name/domain/TrustedNameContextLoader.js +2 -0
  120. package/lib/cjs/src/trusted-name/domain/TrustedNameContextLoader.js.map +7 -0
  121. package/lib/cjs/src/trusted-name/domain/TrustedNameContextLoader.test.js +2 -0
  122. package/lib/cjs/src/trusted-name/domain/TrustedNameContextLoader.test.js.map +7 -0
  123. package/lib/cjs/src/typed-data/data/FiltersDto.js +2 -0
  124. package/lib/cjs/src/typed-data/data/FiltersDto.js.map +7 -0
  125. package/lib/cjs/src/typed-data/data/HttpTypedDataDataSource.js +2 -0
  126. package/lib/cjs/src/typed-data/data/HttpTypedDataDataSource.js.map +7 -0
  127. package/lib/cjs/src/typed-data/data/HttpTypedDataDataSource.test.js +2 -0
  128. package/lib/cjs/src/typed-data/data/HttpTypedDataDataSource.test.js.map +7 -0
  129. package/lib/cjs/src/typed-data/data/TypedDataDataSource.js +2 -0
  130. package/lib/cjs/src/typed-data/data/TypedDataDataSource.js.map +7 -0
  131. package/lib/cjs/src/typed-data/di/typedDataModuleFactory.js +2 -0
  132. package/lib/cjs/src/typed-data/di/typedDataModuleFactory.js.map +7 -0
  133. package/lib/cjs/src/typed-data/di/typedDataTypes.js +2 -0
  134. package/lib/cjs/src/typed-data/di/typedDataTypes.js.map +7 -0
  135. package/lib/cjs/src/typed-data/domain/DefaultTypedDataContextLoader.js +2 -0
  136. package/lib/cjs/src/typed-data/domain/DefaultTypedDataContextLoader.js.map +7 -0
  137. package/lib/cjs/src/typed-data/domain/DefaultTypedDataContextLoader.test.js +2 -0
  138. package/lib/cjs/src/typed-data/domain/DefaultTypedDataContextLoader.test.js.map +7 -0
  139. package/lib/cjs/src/typed-data/domain/TypedDataContextLoader.js +2 -0
  140. package/lib/cjs/src/typed-data/domain/TypedDataContextLoader.js.map +7 -0
  141. package/lib/esm/index.js +1 -37617
  142. package/lib/esm/index.js.map +4 -4
  143. package/lib/esm/package.json +58 -0
  144. package/lib/esm/src/ContextModule.js +1 -0
  145. package/lib/esm/src/ContextModule.js.map +7 -0
  146. package/lib/esm/src/ContextModuleBuilder.js +2 -0
  147. package/lib/esm/src/ContextModuleBuilder.js.map +7 -0
  148. package/lib/esm/src/ContextModuleBuilder.test.js +2 -0
  149. package/lib/esm/src/ContextModuleBuilder.test.js.map +7 -0
  150. package/lib/esm/src/DefaultContextModule.js +2 -0
  151. package/lib/esm/src/DefaultContextModule.js.map +7 -0
  152. package/lib/esm/src/DefaultContextModule.test.js +2 -0
  153. package/lib/esm/src/DefaultContextModule.test.js.map +7 -0
  154. package/lib/esm/src/config/di/configModuleFactory.js +2 -0
  155. package/lib/esm/src/config/di/configModuleFactory.js.map +7 -0
  156. package/lib/esm/src/config/di/configTypes.js +2 -0
  157. package/lib/esm/src/config/di/configTypes.js.map +7 -0
  158. package/lib/esm/src/config/model/ContextModuleConfig.js +1 -0
  159. package/lib/esm/src/config/model/ContextModuleConfig.js.map +7 -0
  160. package/lib/esm/src/di.js +2 -0
  161. package/lib/esm/src/di.js.map +7 -0
  162. package/lib/esm/src/external-plugin/data/DAppDto.js +1 -0
  163. package/lib/esm/src/external-plugin/data/DAppDto.js.map +7 -0
  164. package/lib/esm/src/external-plugin/data/ExternalPluginDataSource.js +1 -0
  165. package/lib/esm/src/external-plugin/data/ExternalPluginDataSource.js.map +7 -0
  166. package/lib/esm/src/external-plugin/data/HttpExternalPluginDataSource.js +2 -0
  167. package/lib/esm/src/external-plugin/data/HttpExternalPluginDataSource.js.map +7 -0
  168. package/lib/esm/src/external-plugin/data/HttpExternalPluginDataSource.test.js +2 -0
  169. package/lib/esm/src/external-plugin/data/HttpExternalPluginDataSource.test.js.map +7 -0
  170. package/lib/esm/src/external-plugin/di/externalPluginModuleFactory.js +2 -0
  171. package/lib/esm/src/external-plugin/di/externalPluginModuleFactory.js.map +7 -0
  172. package/lib/esm/src/external-plugin/di/externalPluginTypes.js +2 -0
  173. package/lib/esm/src/external-plugin/di/externalPluginTypes.js.map +7 -0
  174. package/lib/esm/src/external-plugin/domain/ExternalPluginContextLoader.js +2 -0
  175. package/lib/esm/src/external-plugin/domain/ExternalPluginContextLoader.js.map +7 -0
  176. package/lib/esm/src/external-plugin/domain/ExternalPluginContextLoader.test.js +2 -0
  177. package/lib/esm/src/external-plugin/domain/ExternalPluginContextLoader.test.js.map +7 -0
  178. package/lib/esm/src/external-plugin/model/DappInfos.js +1 -0
  179. package/lib/esm/src/external-plugin/model/DappInfos.js.map +7 -0
  180. package/lib/esm/src/external-plugin/model/SelectorDetails.js +1 -0
  181. package/lib/esm/src/external-plugin/model/SelectorDetails.js.map +7 -0
  182. package/lib/esm/src/index.js +2 -0
  183. package/lib/esm/src/index.js.map +7 -0
  184. package/lib/esm/src/nft/data/HttpNftDataSource.js +2 -0
  185. package/lib/esm/src/nft/data/HttpNftDataSource.js.map +7 -0
  186. package/lib/esm/src/nft/data/HttpNftDataSource.test.js +2 -0
  187. package/lib/esm/src/nft/data/HttpNftDataSource.test.js.map +7 -0
  188. package/lib/esm/src/nft/data/NftDataSource.js +1 -0
  189. package/lib/esm/src/nft/data/NftDataSource.js.map +7 -0
  190. package/lib/esm/src/nft/di/nftModuleFactory.js +2 -0
  191. package/lib/esm/src/nft/di/nftModuleFactory.js.map +7 -0
  192. package/lib/esm/src/nft/di/nftTypes.js +2 -0
  193. package/lib/esm/src/nft/di/nftTypes.js.map +7 -0
  194. package/lib/esm/src/nft/domain/NftContextLoader.js +2 -0
  195. package/lib/esm/src/nft/domain/NftContextLoader.js.map +7 -0
  196. package/lib/esm/src/nft/domain/NftContextLoader.test.js +2 -0
  197. package/lib/esm/src/nft/domain/NftContextLoader.test.js.map +7 -0
  198. package/lib/esm/src/shared/domain/ContextLoader.js +1 -0
  199. package/lib/esm/src/shared/domain/ContextLoader.js.map +7 -0
  200. package/lib/esm/src/shared/model/ClearSignContext.js +2 -0
  201. package/lib/esm/src/shared/model/ClearSignContext.js.map +7 -0
  202. package/lib/esm/src/shared/model/GenericPath.js +2 -0
  203. package/lib/esm/src/shared/model/GenericPath.js.map +7 -0
  204. package/lib/esm/src/shared/model/TransactionContext.js +1 -0
  205. package/lib/esm/src/shared/model/TransactionContext.js.map +7 -0
  206. package/lib/esm/src/shared/model/TransactionSubset.js +1 -0
  207. package/lib/esm/src/shared/model/TransactionSubset.js.map +7 -0
  208. package/lib/esm/src/shared/model/TypedDataClearSignContext.js +2 -0
  209. package/lib/esm/src/shared/model/TypedDataClearSignContext.js.map +7 -0
  210. package/lib/esm/src/shared/model/TypedDataContext.js +1 -0
  211. package/lib/esm/src/shared/model/TypedDataContext.js.map +7 -0
  212. package/lib/esm/src/shared/utils/HexStringUtils.js +2 -0
  213. package/lib/esm/src/shared/utils/HexStringUtils.js.map +7 -0
  214. package/lib/esm/src/token/data/HttpTokenDataSource.js +2 -0
  215. package/lib/esm/src/token/data/HttpTokenDataSource.js.map +7 -0
  216. package/lib/esm/src/token/data/HttpTokenDataSource.test.js +2 -0
  217. package/lib/esm/src/token/data/HttpTokenDataSource.test.js.map +7 -0
  218. package/lib/esm/src/token/data/TokenDataSource.js +1 -0
  219. package/lib/esm/src/token/data/TokenDataSource.js.map +7 -0
  220. package/lib/esm/src/token/data/TokenDto.js +1 -0
  221. package/lib/esm/src/token/data/TokenDto.js.map +7 -0
  222. package/lib/esm/src/token/di/tokenModuleFactory.js +2 -0
  223. package/lib/esm/src/token/di/tokenModuleFactory.js.map +7 -0
  224. package/lib/esm/src/token/di/tokenTypes.js +2 -0
  225. package/lib/esm/src/token/di/tokenTypes.js.map +7 -0
  226. package/lib/esm/src/token/domain/TokenContextLoader.js +2 -0
  227. package/lib/esm/src/token/domain/TokenContextLoader.js.map +7 -0
  228. package/lib/esm/src/token/domain/TokenContextLoader.test.js +2 -0
  229. package/lib/esm/src/token/domain/TokenContextLoader.test.js.map +7 -0
  230. package/lib/esm/src/transaction/data/CalldataDto.js +1 -0
  231. package/lib/esm/src/transaction/data/CalldataDto.js.map +7 -0
  232. package/lib/esm/src/transaction/data/HttpTransactionDataSource.js +2 -0
  233. package/lib/esm/src/transaction/data/HttpTransactionDataSource.js.map +7 -0
  234. package/lib/esm/src/transaction/data/HttpTransactionDataSource.test.js +2 -0
  235. package/lib/esm/src/transaction/data/HttpTransactionDataSource.test.js.map +7 -0
  236. package/lib/esm/src/transaction/data/TransactionDataSource.js +1 -0
  237. package/lib/esm/src/transaction/data/TransactionDataSource.js.map +7 -0
  238. package/lib/esm/src/transaction/di/transactionModuleFactory.js +2 -0
  239. package/lib/esm/src/transaction/di/transactionModuleFactory.js.map +7 -0
  240. package/lib/esm/src/transaction/di/transactionTypes.js +2 -0
  241. package/lib/esm/src/transaction/di/transactionTypes.js.map +7 -0
  242. package/lib/esm/src/transaction/domain/TransactionContextLoader.js +2 -0
  243. package/lib/esm/src/transaction/domain/TransactionContextLoader.js.map +7 -0
  244. package/lib/esm/src/transaction/domain/TransactionContextLoader.test.js +2 -0
  245. package/lib/esm/src/transaction/domain/TransactionContextLoader.test.js.map +7 -0
  246. package/lib/esm/src/trusted-name/data/HttpTrustedNameDataSource.js +2 -0
  247. package/lib/esm/src/trusted-name/data/HttpTrustedNameDataSource.js.map +7 -0
  248. package/lib/esm/src/trusted-name/data/HttpTrustedNameDataSource.test.js +2 -0
  249. package/lib/esm/src/trusted-name/data/HttpTrustedNameDataSource.test.js.map +7 -0
  250. package/lib/esm/src/trusted-name/data/TrustedNameDataSource.js +1 -0
  251. package/lib/esm/src/trusted-name/data/TrustedNameDataSource.js.map +7 -0
  252. package/lib/esm/src/trusted-name/data/TrustedNameDto.js +1 -0
  253. package/lib/esm/src/trusted-name/data/TrustedNameDto.js.map +7 -0
  254. package/lib/esm/src/trusted-name/di/trustedNameModuleFactory.js +2 -0
  255. package/lib/esm/src/trusted-name/di/trustedNameModuleFactory.js.map +7 -0
  256. package/lib/esm/src/trusted-name/di/trustedNameTypes.js +2 -0
  257. package/lib/esm/src/trusted-name/di/trustedNameTypes.js.map +7 -0
  258. package/lib/esm/src/trusted-name/domain/TrustedNameContextLoader.js +2 -0
  259. package/lib/esm/src/trusted-name/domain/TrustedNameContextLoader.js.map +7 -0
  260. package/lib/esm/src/trusted-name/domain/TrustedNameContextLoader.test.js +2 -0
  261. package/lib/esm/src/trusted-name/domain/TrustedNameContextLoader.test.js.map +7 -0
  262. package/lib/esm/src/typed-data/data/FiltersDto.js +1 -0
  263. package/lib/esm/src/typed-data/data/FiltersDto.js.map +7 -0
  264. package/lib/esm/src/typed-data/data/HttpTypedDataDataSource.js +2 -0
  265. package/lib/esm/src/typed-data/data/HttpTypedDataDataSource.js.map +7 -0
  266. package/lib/esm/src/typed-data/data/HttpTypedDataDataSource.test.js +2 -0
  267. package/lib/esm/src/typed-data/data/HttpTypedDataDataSource.test.js.map +7 -0
  268. package/lib/esm/src/typed-data/data/TypedDataDataSource.js +1 -0
  269. package/lib/esm/src/typed-data/data/TypedDataDataSource.js.map +7 -0
  270. package/lib/esm/src/typed-data/di/typedDataModuleFactory.js +2 -0
  271. package/lib/esm/src/typed-data/di/typedDataModuleFactory.js.map +7 -0
  272. package/lib/esm/src/typed-data/di/typedDataTypes.js +2 -0
  273. package/lib/esm/src/typed-data/di/typedDataTypes.js.map +7 -0
  274. package/lib/esm/src/typed-data/domain/DefaultTypedDataContextLoader.js +2 -0
  275. package/lib/esm/src/typed-data/domain/DefaultTypedDataContextLoader.js.map +7 -0
  276. package/lib/esm/src/typed-data/domain/DefaultTypedDataContextLoader.test.js +2 -0
  277. package/lib/esm/src/typed-data/domain/DefaultTypedDataContextLoader.test.js.map +7 -0
  278. package/lib/esm/src/typed-data/domain/TypedDataContextLoader.js +1 -0
  279. package/lib/esm/src/typed-data/domain/TypedDataContextLoader.js.map +7 -0
  280. package/lib/types/src/ContextModule.d.ts +3 -2
  281. package/lib/types/src/ContextModule.d.ts.map +1 -1
  282. package/lib/types/src/ContextModuleBuilder.d.ts +9 -11
  283. package/lib/types/src/ContextModuleBuilder.d.ts.map +1 -1
  284. package/lib/types/src/DefaultContextModule.d.ts +9 -11
  285. package/lib/types/src/DefaultContextModule.d.ts.map +1 -1
  286. package/lib/types/src/config/di/configModuleFactory.d.ts +1 -1
  287. package/lib/types/src/config/di/configModuleFactory.d.ts.map +1 -1
  288. package/lib/types/src/config/model/ContextModuleConfig.d.ts +5 -0
  289. package/lib/types/src/config/model/ContextModuleConfig.d.ts.map +1 -1
  290. package/lib/types/src/di.d.ts +1 -1
  291. package/lib/types/src/di.d.ts.map +1 -1
  292. package/lib/types/src/external-plugin/data/ExternalPluginDataSource.d.ts +3 -3
  293. package/lib/types/src/external-plugin/data/ExternalPluginDataSource.d.ts.map +1 -1
  294. package/lib/types/src/external-plugin/model/DappInfos.d.ts +1 -1
  295. package/lib/types/src/external-plugin/model/DappInfos.d.ts.map +1 -1
  296. package/lib/types/src/index.d.ts +2 -1
  297. package/lib/types/src/index.d.ts.map +1 -1
  298. package/lib/types/src/nft/data/NftDataSource.d.ts +1 -1
  299. package/lib/types/src/nft/data/NftDataSource.d.ts.map +1 -1
  300. package/lib/types/src/nft/domain/NftContextLoader.d.ts +2 -1
  301. package/lib/types/src/nft/domain/NftContextLoader.d.ts.map +1 -1
  302. package/lib/types/src/shared/domain/ContextLoader.d.ts +3 -2
  303. package/lib/types/src/shared/domain/ContextLoader.d.ts.map +1 -1
  304. package/lib/types/src/shared/model/ClearSignContext.d.ts +33 -6
  305. package/lib/types/src/shared/model/ClearSignContext.d.ts.map +1 -1
  306. package/lib/types/src/shared/model/GenericPath.d.ts +105 -0
  307. package/lib/types/src/shared/model/GenericPath.d.ts.map +1 -0
  308. package/lib/types/src/shared/model/TransactionContext.d.ts +15 -2
  309. package/lib/types/src/shared/model/TransactionContext.d.ts.map +1 -1
  310. package/lib/types/src/token/data/TokenDataSource.d.ts +1 -1
  311. package/lib/types/src/token/data/TokenDataSource.d.ts.map +1 -1
  312. package/lib/types/src/token/domain/TokenContextLoader.d.ts +2 -1
  313. package/lib/types/src/token/domain/TokenContextLoader.d.ts.map +1 -1
  314. package/lib/types/src/transaction/data/CalldataDto.d.ts +128 -0
  315. package/lib/types/src/transaction/data/CalldataDto.d.ts.map +1 -0
  316. package/lib/types/src/transaction/data/HttpTransactionDataSource.d.ts +22 -0
  317. package/lib/types/src/transaction/data/HttpTransactionDataSource.d.ts.map +1 -0
  318. package/lib/types/src/transaction/data/HttpTransactionDataSource.test.d.ts +2 -0
  319. package/lib/types/src/transaction/data/HttpTransactionDataSource.test.d.ts.map +1 -0
  320. package/lib/types/src/transaction/data/TransactionDataSource.d.ts +12 -0
  321. package/lib/types/src/transaction/data/TransactionDataSource.d.ts.map +1 -0
  322. package/lib/types/src/transaction/di/transactionModuleFactory.d.ts +3 -0
  323. package/lib/types/src/transaction/di/transactionModuleFactory.d.ts.map +1 -0
  324. package/lib/types/src/transaction/di/transactionTypes.d.ts +5 -0
  325. package/lib/types/src/transaction/di/transactionTypes.d.ts.map +1 -0
  326. package/lib/types/src/transaction/domain/TransactionContextLoader.d.ts +10 -0
  327. package/lib/types/src/transaction/domain/TransactionContextLoader.d.ts.map +1 -0
  328. package/lib/types/src/transaction/domain/TransactionContextLoader.test.d.ts +2 -0
  329. package/lib/types/src/transaction/domain/TransactionContextLoader.test.d.ts.map +1 -0
  330. package/lib/types/src/trusted-name/data/HttpTrustedNameDataSource.d.ts +11 -0
  331. package/lib/types/src/trusted-name/data/HttpTrustedNameDataSource.d.ts.map +1 -0
  332. package/lib/types/src/trusted-name/data/HttpTrustedNameDataSource.test.d.ts +2 -0
  333. package/lib/types/src/trusted-name/data/HttpTrustedNameDataSource.test.d.ts.map +1 -0
  334. package/lib/types/src/trusted-name/data/TrustedNameDataSource.d.ts +16 -0
  335. package/lib/types/src/trusted-name/data/TrustedNameDataSource.d.ts.map +1 -0
  336. package/lib/types/src/trusted-name/data/TrustedNameDto.d.ts +15 -0
  337. package/lib/types/src/trusted-name/data/TrustedNameDto.d.ts.map +1 -0
  338. package/lib/types/src/trusted-name/di/trustedNameModuleFactory.d.ts +3 -0
  339. package/lib/types/src/trusted-name/di/trustedNameModuleFactory.d.ts.map +1 -0
  340. package/lib/types/src/trusted-name/di/trustedNameTypes.d.ts +5 -0
  341. package/lib/types/src/trusted-name/di/trustedNameTypes.d.ts.map +1 -0
  342. package/lib/types/src/trusted-name/domain/TrustedNameContextLoader.d.ts +12 -0
  343. package/lib/types/src/trusted-name/domain/TrustedNameContextLoader.d.ts.map +1 -0
  344. package/lib/types/src/trusted-name/domain/TrustedNameContextLoader.test.d.ts +2 -0
  345. package/lib/types/src/trusted-name/domain/TrustedNameContextLoader.test.d.ts.map +1 -0
  346. package/lib/types/src/typed-data/data/HttpTypedDataDataSource.test.d.ts +1 -1
  347. package/lib/types/src/typed-data/data/HttpTypedDataDataSource.test.d.ts.map +1 -1
  348. package/lib/types/src/typed-data/data/TypedDataDataSource.d.ts +3 -3
  349. package/lib/types/src/typed-data/data/TypedDataDataSource.d.ts.map +1 -1
  350. package/lib/types/src/typed-data/domain/DefaultTypedDataContextLoader.d.ts.map +1 -1
  351. package/lib/types/tsconfig.prod.tsbuildinfo +1 -1
  352. package/package.json +18 -15
  353. package/lib/types/src/forward-domain/data/ForwardDomainDataSource.d.ts +0 -9
  354. package/lib/types/src/forward-domain/data/ForwardDomainDataSource.d.ts.map +0 -1
  355. package/lib/types/src/forward-domain/data/HttpForwardDomainDataSource.d.ts +0 -6
  356. package/lib/types/src/forward-domain/data/HttpForwardDomainDataSource.d.ts.map +0 -1
  357. package/lib/types/src/forward-domain/data/HttpForwardDomainDataSource.test.d.ts +0 -2
  358. package/lib/types/src/forward-domain/data/HttpForwardDomainDataSource.test.d.ts.map +0 -1
  359. package/lib/types/src/forward-domain/di/forwardDomainModuleFactory.d.ts +0 -3
  360. package/lib/types/src/forward-domain/di/forwardDomainModuleFactory.d.ts.map +0 -1
  361. package/lib/types/src/forward-domain/di/forwardDomainTypes.d.ts +0 -5
  362. package/lib/types/src/forward-domain/di/forwardDomainTypes.d.ts.map +0 -1
  363. package/lib/types/src/forward-domain/domain/ForwardDomainContextLoader.d.ts +0 -11
  364. package/lib/types/src/forward-domain/domain/ForwardDomainContextLoader.d.ts.map +0 -1
  365. package/lib/types/src/forward-domain/domain/ForwardDomainContextLoader.test.d.ts +0 -2
  366. package/lib/types/src/forward-domain/domain/ForwardDomainContextLoader.test.d.ts.map +0 -1
package/lib/cjs/index.js CHANGED
@@ -1,1127 +1,2 @@
1
- "use strict";
2
- var __create = Object.create;
3
- var __defProp = Object.defineProperty;
4
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
- var __getOwnPropNames = Object.getOwnPropertyNames;
6
- var __getProtoOf = Object.getPrototypeOf;
7
- var __hasOwnProp = Object.prototype.hasOwnProperty;
8
- var __export = (target, all) => {
9
- for (var name in all)
10
- __defProp(target, name, { get: all[name], enumerable: true });
11
- };
12
- var __copyProps = (to, from, except, desc) => {
13
- if (from && typeof from === "object" || typeof from === "function") {
14
- for (let key of __getOwnPropNames(from))
15
- if (!__hasOwnProp.call(to, key) && key !== except)
16
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
- }
18
- return to;
19
- };
20
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
- // If the importer is in node compatibility mode or this is not an ESM
22
- // file that has been converted to a CommonJS file using a Babel-
23
- // compatible transform (i.e. "__esModule" has not been set), then set
24
- // "default" to the CommonJS "module.exports" for node compatibility.
25
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
- mod
27
- ));
28
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
- var __decorateClass = (decorators, target, key, kind) => {
30
- var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc(target, key) : target;
31
- for (var i = decorators.length - 1, decorator; i >= 0; i--)
32
- if (decorator = decorators[i])
33
- result = (kind ? decorator(target, key, result) : decorator(result)) || result;
34
- if (kind && result) __defProp(target, key, result);
35
- return result;
36
- };
37
- var __decorateParam = (index, decorator) => (target, key) => decorator(target, key, index);
38
-
39
- // index.ts
40
- var context_module_exports = {};
41
- __export(context_module_exports, {
42
- ClearSignContextType: () => ClearSignContextType,
43
- ContextModuleBuilder: () => ContextModuleBuilder,
44
- DEFAULT_CONFIG: () => DEFAULT_CONFIG,
45
- DefaultContextModule: () => DefaultContextModule,
46
- ERC20_SUPPORTED_SELECTORS: () => ERC20_SUPPORTED_SELECTORS,
47
- ExternalPluginContextLoader: () => ExternalPluginContextLoader,
48
- ForwardDomainContextLoader: () => ForwardDomainContextLoader,
49
- NftContextLoader: () => NftContextLoader,
50
- TokenContextLoader: () => TokenContextLoader,
51
- VERIFYING_CONTRACT_TOKEN_INDEX: () => VERIFYING_CONTRACT_TOKEN_INDEX
52
- });
53
- module.exports = __toCommonJS(context_module_exports);
54
- var import_reflect_metadata = require("reflect-metadata");
55
-
56
- // src/external-plugin/di/externalPluginTypes.ts
57
- var externalPluginTypes = {
58
- ExternalPluginDataSource: Symbol.for("externalPluginDataSource"),
59
- ExternalPluginContextLoader: Symbol.for("externalPluginContextLoader")
60
- };
61
-
62
- // src/forward-domain/di/forwardDomainTypes.ts
63
- var forwardDomainTypes = {
64
- ForwardDomainDataSource: Symbol.for("forwardDomainDataSource"),
65
- ForwardDomainContextLoader: Symbol.for("forwardDomainContextLoader")
66
- };
67
-
68
- // src/nft/di/nftTypes.ts
69
- var nftTypes = {
70
- NftDataSource: Symbol.for("nftDataSource"),
71
- NftContextLoader: Symbol.for("nftContextLoader")
72
- };
73
-
74
- // src/token/di/tokenTypes.ts
75
- var tokenTypes = {
76
- TokenDataSource: Symbol.for("TokenDataSource"),
77
- TokenContextLoader: Symbol.for("TokenContextLoader")
78
- };
79
-
80
- // src/typed-data/di/typedDataTypes.ts
81
- var typedDataTypes = {
82
- TypedDataDataSource: Symbol.for("TypedDataDataSource"),
83
- TypedDataContextLoader: Symbol.for("TypedDataContextLoader")
84
- };
85
-
86
- // src/DefaultContextModule.ts
87
- var DefaultContextModule = class {
88
- _loaders;
89
- _typedDataLoader;
90
- constructor(args) {
91
- this._loaders = args.loaders;
92
- this._typedDataLoader = args.typedDataLoader;
93
- }
94
- async getContexts(transaction) {
95
- const promises = this._loaders.map((fetcher) => fetcher.load(transaction));
96
- const responses = await Promise.all(promises);
97
- return responses.flat();
98
- }
99
- async getTypedDataFilters(typedData) {
100
- return this._typedDataLoader.load(typedData);
101
- }
102
- };
103
-
104
- // src/di.ts
105
- var import_inversify17 = require("inversify");
106
-
107
- // src/config/di/configModuleFactory.ts
108
- var import_inversify = require("inversify");
109
-
110
- // src/config/di/configTypes.ts
111
- var configTypes = {
112
- Config: Symbol.for("config")
113
- };
114
-
115
- // src/config/di/configModuleFactory.ts
116
- var configModuleFactory = (config) => new import_inversify.ContainerModule((bind, _unbind, _isBound, _rebind) => {
117
- bind(configTypes.Config).toConstantValue(config);
118
- });
119
-
120
- // src/external-plugin/di/externalPluginModuleFactory.ts
121
- var import_inversify4 = require("inversify");
122
-
123
- // src/external-plugin/data/HttpExternalPluginDataSource.ts
124
- var import_axios = __toESM(require("axios"));
125
- var import_inversify2 = require("inversify");
126
- var import_purify_ts = require("purify-ts");
127
-
128
- // package.json
129
- var package_default = {
130
- name: "@ledgerhq/context-module",
131
- version: "1.0.0",
132
- license: "MIT",
133
- exports: {
134
- ".": {
135
- types: "./lib/types/index.d.ts",
136
- import: "./lib/esm/index.js",
137
- require: "./lib/cjs/index.js"
138
- },
139
- "./*": {
140
- types: "./lib/types/*"
141
- }
142
- },
143
- files: [
144
- "./lib"
145
- ],
146
- scripts: {
147
- prebuild: "rimraf lib",
148
- build: "pnpm lmdk-build --entryPoints index.ts --tsconfig tsconfig.prod.json",
149
- dev: 'concurrently "pnpm watch:builds" "pnpm watch:types"',
150
- "watch:builds": "pnpm lmdk-watch --entryPoints index.ts --tsconfig tsconfig.prod.json",
151
- "watch:types": 'concurrently "tsc --watch -p tsconfig.prod.json" "tsc-alias --watch -p tsconfig.prod.json"',
152
- lint: "eslint",
153
- "lint:fix": "pnpm lint --fix",
154
- postpack: "find . -name '*.tgz' -exec cp {} ../../../dist/ \\; ",
155
- prettier: "prettier . --check",
156
- "prettier:fix": "prettier . --write",
157
- test: "jest",
158
- "test:watch": "pnpm test -- --watch",
159
- "test:coverage": "pnpm test -- --coverage",
160
- typecheck: "tsc --noEmit"
161
- },
162
- devDependencies: {
163
- "@ledgerhq/esbuild-tools": "workspace:*",
164
- "@ledgerhq/device-management-kit": "workspace:*",
165
- "@ledgerhq/eslint-config-dsdk": "workspace:*",
166
- "@ledgerhq/jest-config-dsdk": "workspace:*",
167
- "@ledgerhq/prettier-config-dsdk": "workspace:*",
168
- "@ledgerhq/tsconfig-dsdk": "workspace:*",
169
- "@types/crypto-js": "^4.2.2",
170
- "ts-node": "^10.9.2"
171
- },
172
- dependencies: {
173
- axios: "^1.7.7",
174
- "crypto-js": "^4.2.0",
175
- ethers: "^6.13.2",
176
- inversify: "^6.0.2",
177
- "purify-ts": "^2.1.0",
178
- "reflect-metadata": "^0.2.2"
179
- },
180
- peerDependencies: {
181
- "@ledgerhq/device-management-kit": "workspace:*"
182
- }
183
- };
184
-
185
- // src/external-plugin/data/HttpExternalPluginDataSource.ts
186
- var HttpExternalPluginDataSource = class {
187
- constructor(config) {
188
- this.config = config;
189
- }
190
- async getDappInfos({
191
- chainId,
192
- address,
193
- selector
194
- }) {
195
- try {
196
- const dappInfos = await import_axios.default.request({
197
- method: "GET",
198
- url: `${this.config.cal.url}/dapps`,
199
- params: {
200
- output: "b2c,b2c_signatures,abis",
201
- chain_id: chainId,
202
- contracts: address
203
- },
204
- headers: {
205
- "X-Ledger-Client-Version": `context-module/${package_default.version}`
206
- }
207
- });
208
- if (!dappInfos.data[0]) {
209
- return (0, import_purify_ts.Right)(void 0);
210
- }
211
- address = address.toLowerCase();
212
- selector = `0x${selector.slice(2).toLowerCase()}`;
213
- const { erc20OfInterest, method, plugin } = dappInfos.data[0].b2c?.contracts?.find((c) => c.address === address)?.selectors?.[selector] || {};
214
- const { signature, serialized_data: serializedData } = dappInfos.data[0].b2c_signatures?.[address]?.[selector] || {};
215
- if (!erc20OfInterest || !method || !plugin || !signature || !serializedData) {
216
- return (0, import_purify_ts.Right)(void 0);
217
- }
218
- const abi = dappInfos.data[0].abis?.[address];
219
- if (!abi) {
220
- return (0, import_purify_ts.Right)(void 0);
221
- }
222
- const selectorDetails = {
223
- method,
224
- plugin,
225
- erc20OfInterest,
226
- signature,
227
- serializedData
228
- };
229
- return (0, import_purify_ts.Right)({ selectorDetails, abi });
230
- } catch (_error) {
231
- return (0, import_purify_ts.Left)(
232
- new Error(
233
- "[ContextModule] HttpExternalPluginDataSource: Error fetching dapp infos"
234
- )
235
- );
236
- }
237
- }
238
- };
239
- HttpExternalPluginDataSource = __decorateClass([
240
- (0, import_inversify2.injectable)(),
241
- __decorateParam(0, (0, import_inversify2.inject)(configTypes.Config))
242
- ], HttpExternalPluginDataSource);
243
-
244
- // src/external-plugin/domain/ExternalPluginContextLoader.ts
245
- var import_device_management_kit = require("@ledgerhq/device-management-kit");
246
- var import_ethers = require("ethers");
247
- var import_inversify3 = require("inversify");
248
- var import_purify_ts2 = require("purify-ts");
249
-
250
- // src/shared/model/ClearSignContext.ts
251
- var ClearSignContextType = /* @__PURE__ */ ((ClearSignContextType2) => {
252
- ClearSignContextType2["TOKEN"] = "token";
253
- ClearSignContextType2["NFT"] = "nft";
254
- ClearSignContextType2["DOMAIN_NAME"] = "domainName";
255
- ClearSignContextType2["PLUGIN"] = "plugin";
256
- ClearSignContextType2["EXTERNAL_PLUGIN"] = "externalPlugin";
257
- ClearSignContextType2["ERROR"] = "error";
258
- return ClearSignContextType2;
259
- })(ClearSignContextType || {});
260
-
261
- // src/external-plugin/domain/ExternalPluginContextLoader.ts
262
- var ExternalPluginContextLoader = class {
263
- _externalPluginDataSource;
264
- _tokenDataSource;
265
- constructor(externalPluginDataSource, tokenDataSource) {
266
- this._externalPluginDataSource = externalPluginDataSource;
267
- this._tokenDataSource = tokenDataSource;
268
- }
269
- async load(transaction) {
270
- if (!transaction.to || !transaction.data || transaction.data === "0x") {
271
- return [];
272
- }
273
- const selector = transaction.data.slice(0, 10);
274
- if (!(0, import_device_management_kit.isHexaString)(selector)) {
275
- return [
276
- {
277
- type: "error" /* ERROR */,
278
- error: new Error("Invalid selector")
279
- }
280
- ];
281
- }
282
- const eitherDappInfos = await this._externalPluginDataSource.getDappInfos({
283
- address: transaction.to,
284
- chainId: transaction.chainId,
285
- selector
286
- });
287
- return (0, import_purify_ts2.EitherAsync)(async ({ liftEither }) => {
288
- const dappInfos = await liftEither(eitherDappInfos);
289
- if (!dappInfos) {
290
- return [];
291
- }
292
- const externalPluginContext = {
293
- type: "externalPlugin" /* EXTERNAL_PLUGIN */,
294
- payload: dappInfos.selectorDetails.serializedData.concat(
295
- dappInfos.selectorDetails.signature
296
- )
297
- };
298
- const decodedCallData = this.getDecodedCallData(
299
- dappInfos.abi,
300
- dappInfos.selectorDetails.method,
301
- transaction.data
302
- // trasaction.data is not null and not infered correctly
303
- );
304
- if (decodedCallData.isLeft()) {
305
- return [
306
- {
307
- type: "error" /* ERROR */,
308
- error: decodedCallData.extract()
309
- },
310
- externalPluginContext
311
- ];
312
- }
313
- const extractedDecodedCallData = decodedCallData.extract();
314
- const promises = dappInfos.selectorDetails.erc20OfInterest.map(
315
- async (erc20Path) => this.getTokenPayload(
316
- transaction,
317
- erc20Path,
318
- extractedDecodedCallData
319
- )
320
- );
321
- const tokensPayload = await Promise.all(promises);
322
- const contexts = tokensPayload.map(
323
- (eitherToken) => eitherToken.caseOf({
324
- Left: (error) => ({ type: "error" /* ERROR */, error }),
325
- Right: (payload) => ({ type: "token" /* TOKEN */, payload })
326
- })
327
- );
328
- return [...contexts, externalPluginContext];
329
- }).caseOf({
330
- // parse all errors into ClearSignContext
331
- Left: (error) => [{ type: "error" /* ERROR */, error }],
332
- Right: (contexts) => contexts
333
- });
334
- }
335
- getTokenPayload(transaction, erc20Path, decodedCallData) {
336
- const address = this.getAddressFromPath(erc20Path, decodedCallData);
337
- return (0, import_purify_ts2.EitherAsync)(
338
- ({ fromPromise }) => fromPromise(
339
- this._tokenDataSource.getTokenInfosPayload({
340
- address,
341
- chainId: transaction.chainId
342
- })
343
- )
344
- );
345
- }
346
- getDecodedCallData(abi, method, data) {
347
- try {
348
- const contractInterface = new import_ethers.Interface(abi);
349
- return (0, import_purify_ts2.Right)(contractInterface.decodeFunctionData(method, data));
350
- } catch (_error) {
351
- return (0, import_purify_ts2.Left)(
352
- new Error(
353
- "[ContextModule] ExternalPluginContextLoader: Unable to parse abi"
354
- )
355
- );
356
- }
357
- }
358
- getAddressFromPath(path, decodedCallData) {
359
- let value = decodedCallData;
360
- for (const key of path.split(".")) {
361
- if (key === "-1") {
362
- value = value[value.length - 1];
363
- } else {
364
- value = value[key];
365
- }
366
- }
367
- if (!(0, import_device_management_kit.isHexaString)(value)) {
368
- throw new Error(
369
- "[ContextModule] ExternalPluginContextLoader: Unable to get address"
370
- );
371
- }
372
- return value;
373
- }
374
- };
375
- ExternalPluginContextLoader = __decorateClass([
376
- (0, import_inversify3.injectable)(),
377
- __decorateParam(0, (0, import_inversify3.inject)(externalPluginTypes.ExternalPluginDataSource)),
378
- __decorateParam(1, (0, import_inversify3.inject)(tokenTypes.TokenDataSource))
379
- ], ExternalPluginContextLoader);
380
-
381
- // src/external-plugin/di/externalPluginModuleFactory.ts
382
- var externalPluginModuleFactory = () => new import_inversify4.ContainerModule((bind, _unbind, _isBound, _rebind) => {
383
- bind(externalPluginTypes.ExternalPluginDataSource).to(
384
- HttpExternalPluginDataSource
385
- );
386
- bind(externalPluginTypes.ExternalPluginContextLoader).to(
387
- ExternalPluginContextLoader
388
- );
389
- });
390
-
391
- // src/forward-domain/di/forwardDomainModuleFactory.ts
392
- var import_inversify7 = require("inversify");
393
-
394
- // src/forward-domain/data/HttpForwardDomainDataSource.ts
395
- var import_axios2 = __toESM(require("axios"));
396
- var import_inversify5 = require("inversify");
397
- var import_purify_ts3 = require("purify-ts");
398
- var HttpForwardDomainDataSource = class {
399
- async getDomainNamePayload({
400
- domain,
401
- challenge
402
- }) {
403
- try {
404
- const response = await import_axios2.default.request({
405
- method: "GET",
406
- url: `https://nft.api.live.ledger.com/v1/names/ens/forward/${domain}?challenge=${challenge}`,
407
- headers: {
408
- "X-Ledger-Client-Version": `context-module/${package_default.version}`
409
- }
410
- });
411
- return response.data.payload ? (0, import_purify_ts3.Right)(response.data.payload) : (0, import_purify_ts3.Left)(
412
- new Error(
413
- "[ContextModule] HttpForwardDomainDataSource: error getting domain payload"
414
- )
415
- );
416
- } catch (_error) {
417
- return (0, import_purify_ts3.Left)(
418
- new Error(
419
- "[ContextModule] HttpForwardDomainDataSource: Failed to fetch domain name"
420
- )
421
- );
422
- }
423
- }
424
- };
425
- HttpForwardDomainDataSource = __decorateClass([
426
- (0, import_inversify5.injectable)()
427
- ], HttpForwardDomainDataSource);
428
-
429
- // src/forward-domain/domain/ForwardDomainContextLoader.ts
430
- var import_inversify6 = require("inversify");
431
- var ForwardDomainContextLoader = class {
432
- _dataSource;
433
- constructor(dataSource) {
434
- this._dataSource = dataSource;
435
- }
436
- async load(transactionContext) {
437
- const { domain, challenge } = transactionContext;
438
- if (!domain) {
439
- return [];
440
- }
441
- if (!this.isDomainValid(domain)) {
442
- return [
443
- {
444
- type: "error" /* ERROR */,
445
- error: new Error(
446
- "[ContextModule] ForwardDomainLoader: invalid domain"
447
- )
448
- }
449
- ];
450
- }
451
- const payload = await this._dataSource.getDomainNamePayload({
452
- domain,
453
- challenge
454
- });
455
- return [
456
- payload.caseOf({
457
- Left: (error) => ({
458
- type: "error" /* ERROR */,
459
- error
460
- }),
461
- Right: (value) => ({
462
- type: "domainName" /* DOMAIN_NAME */,
463
- payload: value
464
- })
465
- })
466
- ];
467
- }
468
- isDomainValid(domain) {
469
- const lengthIsValid = domain.length > 0 && Number(domain.length) < 30;
470
- const containsOnlyValidChars = new RegExp("^[a-zA-Z0-9\\-\\_\\.]+$").test(
471
- domain
472
- );
473
- return lengthIsValid && containsOnlyValidChars;
474
- }
475
- };
476
- ForwardDomainContextLoader = __decorateClass([
477
- (0, import_inversify6.injectable)(),
478
- __decorateParam(0, (0, import_inversify6.inject)(forwardDomainTypes.ForwardDomainDataSource))
479
- ], ForwardDomainContextLoader);
480
-
481
- // src/forward-domain/di/forwardDomainModuleFactory.ts
482
- var forwardDomainModuleFactory = () => new import_inversify7.ContainerModule((bind, _unbind, _isBound, _rebind) => {
483
- bind(forwardDomainTypes.ForwardDomainDataSource).to(
484
- HttpForwardDomainDataSource
485
- );
486
- bind(forwardDomainTypes.ForwardDomainContextLoader).to(
487
- ForwardDomainContextLoader
488
- );
489
- });
490
-
491
- // src/nft/di/nftModuleFactory.ts
492
- var import_inversify10 = require("inversify");
493
-
494
- // src/nft/data/HttpNftDataSource.ts
495
- var import_axios3 = __toESM(require("axios"));
496
- var import_inversify8 = require("inversify");
497
- var import_purify_ts4 = require("purify-ts");
498
- var HttpNftDataSource = class {
499
- async getSetPluginPayload({
500
- chainId,
501
- address,
502
- selector
503
- }) {
504
- try {
505
- const response = await import_axios3.default.request({
506
- method: "GET",
507
- url: `https://nft.api.live.ledger.com/v1/ethereum/${chainId}/contracts/${address}/plugin-selector/${selector}`,
508
- headers: {
509
- "X-Ledger-Client-Version": `context-module/${package_default.version}`
510
- }
511
- });
512
- return response.data.payload ? (0, import_purify_ts4.Right)(response.data.payload) : (0, import_purify_ts4.Left)(
513
- new Error(
514
- "[ContextModule] HttpNftDataSource: unexpected empty response"
515
- )
516
- );
517
- } catch (_error) {
518
- return (0, import_purify_ts4.Left)(
519
- new Error(
520
- "[ContextModule] HttpNftDataSource: Failed to fetch set plugin payload"
521
- )
522
- );
523
- }
524
- }
525
- async getNftInfosPayload({
526
- chainId,
527
- address
528
- }) {
529
- try {
530
- const response = await import_axios3.default.request({
531
- method: "GET",
532
- url: `https://nft.api.live.ledger.com/v1/ethereum/${chainId}/contracts/${address}`,
533
- headers: {
534
- "X-Ledger-Client-Version": `context-module/${package_default.version}`
535
- }
536
- });
537
- return response.data.payload ? (0, import_purify_ts4.Right)(response.data.payload) : (0, import_purify_ts4.Left)(new Error("[ContextModule] HttpNftDataSource: no nft metadata"));
538
- } catch (_error) {
539
- return (0, import_purify_ts4.Left)(
540
- new Error(
541
- "[ContextModule] HttpNftDataSource: Failed to fetch nft informations"
542
- )
543
- );
544
- }
545
- }
546
- };
547
- HttpNftDataSource = __decorateClass([
548
- (0, import_inversify8.injectable)()
549
- ], HttpNftDataSource);
550
-
551
- // src/nft/domain/NftContextLoader.ts
552
- var import_device_management_kit2 = require("@ledgerhq/device-management-kit");
553
- var import_inversify9 = require("inversify");
554
- var ERC721_SUPPORTED_SELECTOR = /* @__PURE__ */ ((ERC721_SUPPORTED_SELECTOR2) => {
555
- ERC721_SUPPORTED_SELECTOR2["Approve"] = "0x095ea7b3";
556
- ERC721_SUPPORTED_SELECTOR2["SetApprovalForAll"] = "0xa22cb465";
557
- ERC721_SUPPORTED_SELECTOR2["TransferFrom"] = "0x23b872dd";
558
- ERC721_SUPPORTED_SELECTOR2["SafeTransferFrom"] = "0x42842e0e";
559
- ERC721_SUPPORTED_SELECTOR2["SafeTransferFromWithData"] = "0xb88d4fde";
560
- return ERC721_SUPPORTED_SELECTOR2;
561
- })(ERC721_SUPPORTED_SELECTOR || {});
562
- var ERC1155_SUPPORTED_SELECTOR = /* @__PURE__ */ ((ERC1155_SUPPORTED_SELECTOR2) => {
563
- ERC1155_SUPPORTED_SELECTOR2["SetApprovalForAll"] = "0xa22cb465";
564
- ERC1155_SUPPORTED_SELECTOR2["SafeTransferFrom"] = "0xf242432a";
565
- ERC1155_SUPPORTED_SELECTOR2["SafeBatchTransferFrom"] = "0x2eb2c2d6";
566
- return ERC1155_SUPPORTED_SELECTOR2;
567
- })(ERC1155_SUPPORTED_SELECTOR || {});
568
- var SUPPORTED_SELECTORS = [
569
- ...Object.values(ERC721_SUPPORTED_SELECTOR),
570
- ...Object.values(ERC1155_SUPPORTED_SELECTOR)
571
- ];
572
- var NftContextLoader = class {
573
- _dataSource;
574
- constructor(dataSource) {
575
- this._dataSource = dataSource;
576
- }
577
- async load(transaction) {
578
- const responses = [];
579
- if (!transaction.to || !transaction.data || transaction.data === "0x") {
580
- return [];
581
- }
582
- const selector = transaction.data.slice(0, 10);
583
- if (!(0, import_device_management_kit2.isHexaString)(selector)) {
584
- return [
585
- {
586
- type: "error" /* ERROR */,
587
- error: new Error("Invalid selector")
588
- }
589
- ];
590
- }
591
- if (!this.isSelectorSupported(selector)) {
592
- return [];
593
- }
594
- const getPluginPayloadResponse = await this._dataSource.getSetPluginPayload(
595
- {
596
- chainId: transaction.chainId,
597
- address: transaction.to,
598
- selector
599
- }
600
- );
601
- const pluginPayload = getPluginPayloadResponse.caseOf({
602
- Left: (error) => ({
603
- type: "error" /* ERROR */,
604
- error
605
- }),
606
- Right: (value) => ({
607
- type: "plugin" /* PLUGIN */,
608
- payload: value
609
- })
610
- });
611
- if (pluginPayload.type === "error" /* ERROR */) {
612
- return [pluginPayload];
613
- }
614
- responses.push(pluginPayload);
615
- const getNftInfosPayloadResponse = await this._dataSource.getNftInfosPayload({
616
- chainId: transaction.chainId,
617
- address: transaction.to
618
- });
619
- const nftInfosPayload = getNftInfosPayloadResponse.caseOf({
620
- Left: (error) => ({
621
- type: "error" /* ERROR */,
622
- error
623
- }),
624
- Right: (value) => ({
625
- type: "nft" /* NFT */,
626
- payload: value
627
- })
628
- });
629
- if (nftInfosPayload.type === "error" /* ERROR */) {
630
- return [nftInfosPayload];
631
- }
632
- responses.push(nftInfosPayload);
633
- return responses;
634
- }
635
- isSelectorSupported(selector) {
636
- return Object.values(SUPPORTED_SELECTORS).includes(selector);
637
- }
638
- };
639
- NftContextLoader = __decorateClass([
640
- (0, import_inversify9.injectable)(),
641
- __decorateParam(0, (0, import_inversify9.inject)(nftTypes.NftDataSource))
642
- ], NftContextLoader);
643
-
644
- // src/nft/di/nftModuleFactory.ts
645
- var nftModuleFactory = () => new import_inversify10.ContainerModule((bind, _unbind, _isBound, _rebind) => {
646
- bind(nftTypes.NftDataSource).to(HttpNftDataSource);
647
- bind(nftTypes.NftContextLoader).to(NftContextLoader);
648
- });
649
-
650
- // src/token/di/tokenModuleFactory.ts
651
- var import_inversify13 = require("inversify");
652
-
653
- // src/token/data/HttpTokenDataSource.ts
654
- var import_axios4 = __toESM(require("axios"));
655
- var import_inversify11 = require("inversify");
656
- var import_purify_ts5 = require("purify-ts");
657
- var HttpTokenDataSource = class {
658
- constructor(config) {
659
- this.config = config;
660
- }
661
- async getTokenInfosPayload({
662
- chainId,
663
- address
664
- }) {
665
- try {
666
- const response = await import_axios4.default.request({
667
- method: "GET",
668
- url: `${this.config.cal.url}/tokens`,
669
- params: {
670
- contract_address: address,
671
- chain_id: chainId,
672
- output: "descriptor,ticker",
673
- ref: `branch:${this.config.cal.branch}`
674
- },
675
- headers: {
676
- "X-Ledger-Client-Version": `context-module/${package_default.version}`
677
- }
678
- });
679
- const tokenInfos = response.data?.[0];
680
- if (!tokenInfos || !tokenInfos.ticker || !tokenInfos.descriptor || !tokenInfos.descriptor.data || !tokenInfos.descriptor.signatures || typeof tokenInfos.descriptor.signatures[this.config.cal.mode] !== "string") {
681
- return (0, import_purify_ts5.Left)(
682
- new Error(
683
- `[ContextModule] HttpTokenDataSource: no token metadata for address ${address} on chain ${chainId}`
684
- )
685
- );
686
- }
687
- const tickerLengthBuff = tokenInfos.ticker.length.toString(16).padStart(2, "0");
688
- return (0, import_purify_ts5.Right)(
689
- [
690
- tickerLengthBuff,
691
- tokenInfos.descriptor.data,
692
- tokenInfos.descriptor.signatures[this.config.cal.mode]
693
- ].join("")
694
- );
695
- } catch (_error) {
696
- return (0, import_purify_ts5.Left)(
697
- new Error(
698
- "[ContextModule] HttpTokenDataSource: Failed to fetch token informations"
699
- )
700
- );
701
- }
702
- }
703
- };
704
- HttpTokenDataSource = __decorateClass([
705
- (0, import_inversify11.injectable)(),
706
- __decorateParam(0, (0, import_inversify11.inject)(configTypes.Config))
707
- ], HttpTokenDataSource);
708
-
709
- // src/token/domain/TokenContextLoader.ts
710
- var import_device_management_kit3 = require("@ledgerhq/device-management-kit");
711
- var import_inversify12 = require("inversify");
712
- var ERC20_SUPPORTED_SELECTORS = /* @__PURE__ */ ((ERC20_SUPPORTED_SELECTORS2) => {
713
- ERC20_SUPPORTED_SELECTORS2["Approve"] = "0x095ea7b3";
714
- ERC20_SUPPORTED_SELECTORS2["Transfer"] = "0xa9059cbb";
715
- return ERC20_SUPPORTED_SELECTORS2;
716
- })(ERC20_SUPPORTED_SELECTORS || {});
717
- var SUPPORTED_SELECTORS2 = Object.values(
718
- ERC20_SUPPORTED_SELECTORS
719
- );
720
- var TokenContextLoader = class {
721
- _dataSource;
722
- constructor(dataSource) {
723
- this._dataSource = dataSource;
724
- }
725
- async load(transaction) {
726
- if (!transaction.to || !transaction.data || transaction.data === "0x") {
727
- return [];
728
- }
729
- const selector = transaction.data.slice(0, 10);
730
- if (!(0, import_device_management_kit3.isHexaString)(selector)) {
731
- return [
732
- {
733
- type: "error" /* ERROR */,
734
- error: new Error("Invalid selector")
735
- }
736
- ];
737
- }
738
- if (!this.isSelectorSupported(selector)) {
739
- return [];
740
- }
741
- const payload = await this._dataSource.getTokenInfosPayload({
742
- address: transaction.to,
743
- chainId: transaction.chainId
744
- });
745
- return [
746
- payload.caseOf({
747
- Left: (error) => ({
748
- type: "error" /* ERROR */,
749
- error
750
- }),
751
- Right: (value) => ({
752
- type: "token" /* TOKEN */,
753
- payload: value
754
- })
755
- })
756
- ];
757
- }
758
- isSelectorSupported(selector) {
759
- return Object.values(SUPPORTED_SELECTORS2).includes(selector);
760
- }
761
- };
762
- TokenContextLoader = __decorateClass([
763
- (0, import_inversify12.injectable)(),
764
- __decorateParam(0, (0, import_inversify12.inject)(tokenTypes.TokenDataSource))
765
- ], TokenContextLoader);
766
-
767
- // src/token/di/tokenModuleFactory.ts
768
- var tokenModuleFactory = () => new import_inversify13.ContainerModule((bind, _unbind, _isBound, _rebind) => {
769
- bind(tokenTypes.TokenDataSource).to(HttpTokenDataSource);
770
- bind(tokenTypes.TokenContextLoader).to(TokenContextLoader);
771
- });
772
-
773
- // src/typed-data/di/typedDataModuleFactory.ts
774
- var import_inversify16 = require("inversify");
775
-
776
- // src/typed-data/data/HttpTypedDataDataSource.ts
777
- var import_axios5 = __toESM(require("axios"));
778
- var import_sha224 = __toESM(require("crypto-js/sha224"));
779
- var import_inversify14 = require("inversify");
780
- var import_purify_ts6 = require("purify-ts");
781
- var HttpTypedDataDataSource = class {
782
- constructor(config) {
783
- this.config = config;
784
- }
785
- async getTypedDataFilters({
786
- chainId,
787
- address,
788
- schema,
789
- version
790
- }) {
791
- let messageInfo = void 0;
792
- try {
793
- const response = await import_axios5.default.request({
794
- method: "GET",
795
- url: `${this.config.cal.url}/dapps`,
796
- params: {
797
- contracts: address,
798
- chain_id: chainId,
799
- output: "descriptors_eip712",
800
- descriptors_eip712_version: version,
801
- descriptors_eip712: "<set>",
802
- ref: `branch:${this.config.cal.branch}`
803
- },
804
- headers: {
805
- "X-Ledger-Client-Version": `context-module/${package_default.version}`
806
- }
807
- });
808
- const schemaHash = (0, import_sha224.default)(
809
- JSON.stringify(this.sortTypes(schema)).replace(" ", "")
810
- ).toString();
811
- address = address.toLowerCase();
812
- const filtersJson = response.data?.[0]?.descriptors_eip712?.[address]?.[schemaHash];
813
- if (!filtersJson) {
814
- return (0, import_purify_ts6.Left)(
815
- new Error(
816
- `[ContextModule] HttpTypedDataDataSource: no typed data filters for address ${address} on chain ${chainId} for schema ${schemaHash}`
817
- )
818
- );
819
- }
820
- if (!filtersJson.schema || !Array.isArray(filtersJson.instructions)) {
821
- return (0, import_purify_ts6.Left)(
822
- new Error(
823
- `[ContextModule] HttpTypedDataDataSource: no message info for address ${address} on chain ${chainId} for schema ${schemaHash}`
824
- )
825
- );
826
- }
827
- const filters = [];
828
- for (const field of filtersJson.instructions) {
829
- if (this.isInstructionContractInfo(field, this.config.cal.mode)) {
830
- messageInfo = {
831
- displayName: field.display_name,
832
- signature: field.signatures[this.config.cal.mode],
833
- filtersCount: field.field_mappers_count
834
- };
835
- } else if (version === "v1" && this.isInstructionFieldV1(field, this.config.cal.mode)) {
836
- filters.push({
837
- type: "raw",
838
- displayName: field.display_name,
839
- path: field.field_path,
840
- signature: field.signatures[this.config.cal.mode]
841
- });
842
- } else if (this.isInstructionFieldV2(field, this.config.cal.mode)) {
843
- filters.push({
844
- type: field.format,
845
- displayName: field.display_name,
846
- path: field.field_path,
847
- signature: field.signatures[this.config.cal.mode]
848
- });
849
- } else if (this.isInstructionFieldV2WithCoinRef(field, this.config.cal.mode)) {
850
- filters.push({
851
- type: field.format,
852
- displayName: field.display_name,
853
- path: field.field_path,
854
- signature: field.signatures[this.config.cal.mode],
855
- tokenIndex: field.coin_ref
856
- });
857
- } else {
858
- return (0, import_purify_ts6.Left)(
859
- new Error(
860
- `[ContextModule] HttpTypedDataDataSource: invalid typed data field for address ${address} on chain ${chainId} for schema ${schemaHash}`
861
- )
862
- );
863
- }
864
- }
865
- if (!messageInfo) {
866
- return (0, import_purify_ts6.Left)(
867
- new Error(
868
- `[ContextModule] HttpTypedDataDataSource: no message info for address ${address} on chain ${chainId} for schema ${schemaHash}`
869
- )
870
- );
871
- }
872
- return (0, import_purify_ts6.Right)({ messageInfo, filters });
873
- } catch (_error) {
874
- return (0, import_purify_ts6.Left)(
875
- new Error(
876
- "[ContextModule] HttpTypedDataDataSource: Failed to fetch typed data informations"
877
- )
878
- );
879
- }
880
- }
881
- isInstructionFieldV1(data, mode) {
882
- return typeof data === "object" && typeof data.display_name === "string" && typeof data.field_path === "string" && typeof data.signatures === "object" && typeof data.signatures[mode] === "string";
883
- }
884
- isInstructionFieldV2(data, mode) {
885
- return typeof data === "object" && typeof data.display_name === "string" && typeof data.field_path === "string" && typeof data.signatures === "object" && typeof data.signatures[mode] === "string" && typeof data.format === "string" && ["raw", "datetime"].includes(data.format) && data.coin_ref === void 0;
886
- }
887
- isInstructionFieldV2WithCoinRef(data, mode) {
888
- return typeof data === "object" && typeof data.display_name === "string" && typeof data.field_path === "string" && typeof data.signatures === "object" && typeof data.signatures[mode] === "string" && typeof data.format === "string" && ["token", "amount"].includes(data.format) && typeof data.coin_ref === "number";
889
- }
890
- isInstructionContractInfo(data, mode) {
891
- return typeof data === "object" && typeof data.display_name === "string" && typeof data.field_mappers_count === "number" && typeof data.signatures === "object" && typeof data.signatures[mode] === "string" && data.field_path === void 0;
892
- }
893
- sortTypes(types) {
894
- return Object.fromEntries(
895
- Object.entries(types).sort(([aKey], [bKey]) => aKey.localeCompare(bKey)).map(([key, value]) => [
896
- key,
897
- value.map((v) => ({ name: v.name, type: v.type }))
898
- ])
899
- );
900
- }
901
- };
902
- HttpTypedDataDataSource = __decorateClass([
903
- (0, import_inversify14.injectable)(),
904
- __decorateParam(0, (0, import_inversify14.inject)(configTypes.Config))
905
- ], HttpTypedDataDataSource);
906
-
907
- // src/typed-data/domain/DefaultTypedDataContextLoader.ts
908
- var import_inversify15 = require("inversify");
909
-
910
- // src/shared/model/TypedDataClearSignContext.ts
911
- var VERIFYING_CONTRACT_TOKEN_INDEX = 255;
912
-
913
- // src/typed-data/domain/DefaultTypedDataContextLoader.ts
914
- var DefaultTypedDataContextLoader = class {
915
- constructor(dataSource, tokenDataSource) {
916
- this.dataSource = dataSource;
917
- this.tokenDataSource = tokenDataSource;
918
- }
919
- async load(typedData) {
920
- const data = await this.dataSource.getTypedDataFilters({
921
- address: typedData.verifyingContract,
922
- chainId: typedData.chainId,
923
- version: typedData.version,
924
- schema: typedData.schema
925
- });
926
- if (data.isLeft()) {
927
- return {
928
- type: "error",
929
- error: data.extract()
930
- };
931
- }
932
- const { messageInfo, filters } = data.unsafeCoerce();
933
- const mappedFilters = {};
934
- const mappedTokens = {};
935
- for (const filter of filters) {
936
- mappedFilters[filter.path] = filter;
937
- if (filter.type !== "token" && filter.type !== "amount") {
938
- continue;
939
- }
940
- const tokenIndex = filter.tokenIndex;
941
- if (mappedTokens[tokenIndex] !== void 0) {
942
- continue;
943
- }
944
- if (filter.type === "token") {
945
- const value = typedData.fieldsValues.find(
946
- (entry) => entry.path === filter.path
947
- );
948
- if (value === void 0) {
949
- return {
950
- type: "error",
951
- error: new Error(
952
- `The token filter references the value ${filter.path} which is absent from the message`
953
- )
954
- };
955
- }
956
- const address = this.convertAddressToHexaString(value.value);
957
- const chainId = typedData.chainId;
958
- const payload = await this.tokenDataSource.getTokenInfosPayload({
959
- address,
960
- chainId
961
- });
962
- if (payload.isLeft()) {
963
- return {
964
- type: "error",
965
- error: payload.extract()
966
- };
967
- }
968
- payload.ifRight((payload2) => {
969
- mappedTokens[tokenIndex] = payload2;
970
- });
971
- } else if (filter.type === "amount" && tokenIndex === VERIFYING_CONTRACT_TOKEN_INDEX) {
972
- const address = typedData.verifyingContract;
973
- const chainId = typedData.chainId;
974
- const payload = await this.tokenDataSource.getTokenInfosPayload({
975
- address,
976
- chainId
977
- });
978
- if (payload.isLeft()) {
979
- return {
980
- type: "error",
981
- error: payload.extract()
982
- };
983
- }
984
- payload.ifRight((payload2) => {
985
- mappedTokens[tokenIndex] = payload2;
986
- });
987
- }
988
- }
989
- return {
990
- type: "success",
991
- messageInfo,
992
- filters: mappedFilters,
993
- tokens: mappedTokens
994
- };
995
- }
996
- convertAddressToHexaString(address) {
997
- return `0x${Array.from(
998
- address,
999
- (byte) => byte.toString(16).padStart(2, "0")
1000
- ).join("").padStart(40, "0")}`;
1001
- }
1002
- };
1003
- DefaultTypedDataContextLoader = __decorateClass([
1004
- (0, import_inversify15.injectable)(),
1005
- __decorateParam(0, (0, import_inversify15.inject)(typedDataTypes.TypedDataDataSource)),
1006
- __decorateParam(1, (0, import_inversify15.inject)(tokenTypes.TokenDataSource))
1007
- ], DefaultTypedDataContextLoader);
1008
-
1009
- // src/typed-data/di/typedDataModuleFactory.ts
1010
- var typedDataModuleFactory = () => new import_inversify16.ContainerModule((bind, _unbind, _isBound, _rebind) => {
1011
- bind(typedDataTypes.TypedDataDataSource).to(HttpTypedDataDataSource);
1012
- bind(typedDataTypes.TypedDataContextLoader).to(
1013
- DefaultTypedDataContextLoader
1014
- );
1015
- });
1016
-
1017
- // src/di.ts
1018
- var makeContainer = ({ config }) => {
1019
- const container = new import_inversify17.Container();
1020
- container.load(
1021
- configModuleFactory(config),
1022
- externalPluginModuleFactory(),
1023
- forwardDomainModuleFactory(),
1024
- nftModuleFactory(),
1025
- tokenModuleFactory(),
1026
- typedDataModuleFactory()
1027
- );
1028
- return container;
1029
- };
1030
-
1031
- // src/ContextModuleBuilder.ts
1032
- var DEFAULT_CAL_URL = "https://crypto-assets-service.api.ledger.com/v1";
1033
- var DEFAULT_CONFIG = {
1034
- cal: {
1035
- url: DEFAULT_CAL_URL,
1036
- mode: "prod",
1037
- branch: "main"
1038
- }
1039
- };
1040
- var ContextModuleBuilder = class {
1041
- config = {};
1042
- customLoaders = [];
1043
- defaultLoaders = [];
1044
- customTypedDataLoader;
1045
- constructor() {
1046
- }
1047
- /**
1048
- * Remove default loaders from the list of loaders
1049
- *
1050
- * @returns this
1051
- */
1052
- withoutDefaultLoaders() {
1053
- this.defaultLoaders = [];
1054
- return this;
1055
- }
1056
- /**
1057
- * Add a custom loader to the list of loaders
1058
- *
1059
- * @param loader loader to add to the list of loaders
1060
- * @returns this
1061
- */
1062
- addLoader(loader) {
1063
- this.customLoaders.push(loader);
1064
- return this;
1065
- }
1066
- /**
1067
- * Replace the default loader for typed data clear signing contexts
1068
- *
1069
- * @returns this
1070
- */
1071
- withTypedDataLoader(loader) {
1072
- this.customTypedDataLoader = loader;
1073
- return this;
1074
- }
1075
- /**
1076
- * Set the configuration for the context module
1077
- *
1078
- * @param config configuration for the context module
1079
- * @returns this
1080
- */
1081
- withConfig(config) {
1082
- this.config = config;
1083
- return this;
1084
- }
1085
- /**
1086
- * Build the context module
1087
- *
1088
- * @returns the context module
1089
- */
1090
- build() {
1091
- const container = makeContainer({
1092
- config: { ...DEFAULT_CONFIG, ...this.config }
1093
- });
1094
- this.defaultLoaders = [
1095
- container.get(
1096
- externalPluginTypes.ExternalPluginContextLoader
1097
- ),
1098
- container.get(
1099
- forwardDomainTypes.ForwardDomainContextLoader
1100
- ),
1101
- container.get(nftTypes.NftContextLoader),
1102
- container.get(tokenTypes.TokenContextLoader)
1103
- ];
1104
- const defaultTypedDataLoader = container.get(
1105
- typedDataTypes.TypedDataContextLoader
1106
- );
1107
- const loaders = [...this.defaultLoaders, ...this.customLoaders];
1108
- return new DefaultContextModule({
1109
- loaders,
1110
- typedDataLoader: this.customTypedDataLoader ?? defaultTypedDataLoader
1111
- });
1112
- }
1113
- };
1114
- // Annotate the CommonJS export names for ESM import in node:
1115
- 0 && (module.exports = {
1116
- ClearSignContextType,
1117
- ContextModuleBuilder,
1118
- DEFAULT_CONFIG,
1119
- DefaultContextModule,
1120
- ERC20_SUPPORTED_SELECTORS,
1121
- ExternalPluginContextLoader,
1122
- ForwardDomainContextLoader,
1123
- NftContextLoader,
1124
- TokenContextLoader,
1125
- VERIFYING_CONTRACT_TOKEN_INDEX
1126
- });
1
+ "use strict";var x=Object.defineProperty;var a=Object.getOwnPropertyDescriptor;var b=Object.getOwnPropertyNames;var c=Object.prototype.hasOwnProperty;var f=(r,o,t,i)=>{if(o&&typeof o=="object"||typeof o=="function")for(let m of b(o))!c.call(r,m)&&m!==t&&x(r,m,{get:()=>o[m],enumerable:!(i=a(o,m))||i.enumerable});return r},e=(r,o,t)=>(f(r,o,"default"),t&&f(t,o,"default"));var d=r=>f(x({},"__esModule",{value:!0}),r);var p={};module.exports=d(p);var h=require("reflect-metadata");e(p,require("./src/index"),module.exports);0&&(module.exports={...require("./src/index")});
1127
2
  //# sourceMappingURL=index.js.map