@ledgerhq/context-module 1.11.1 → 1.13.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 (200) hide show
  1. package/lib/cjs/package.json +1 -1
  2. package/lib/cjs/src/ContextModuleBuilder.js +1 -1
  3. package/lib/cjs/src/ContextModuleBuilder.js.map +3 -3
  4. package/lib/cjs/src/ContextModuleBuilder.test.js +1 -1
  5. package/lib/cjs/src/ContextModuleBuilder.test.js.map +3 -3
  6. package/lib/cjs/src/DefaultContextModule.test.js +1 -1
  7. package/lib/cjs/src/DefaultContextModule.test.js.map +3 -3
  8. package/lib/cjs/src/calldata/domain/CalldataContextLoader.js +1 -1
  9. package/lib/cjs/src/calldata/domain/CalldataContextLoader.js.map +3 -3
  10. package/lib/cjs/src/calldata/domain/CalldataContextLoader.test.js +1 -1
  11. package/lib/cjs/src/calldata/domain/CalldataContextLoader.test.js.map +3 -3
  12. package/lib/cjs/src/config/di/configTypes.js +1 -1
  13. package/lib/cjs/src/config/di/configTypes.js.map +2 -2
  14. package/lib/cjs/src/config/model/ContextModuleBuildArgs.js +1 -1
  15. package/lib/cjs/src/config/model/ContextModuleBuildArgs.js.map +1 -1
  16. package/lib/cjs/src/config/model/ContextModuleConfig.js +1 -1
  17. package/lib/cjs/src/config/model/ContextModuleConfig.js.map +1 -1
  18. package/lib/cjs/src/di.js +1 -1
  19. package/lib/cjs/src/di.js.map +3 -3
  20. package/lib/cjs/src/dynamic-network/domain/DynamicNetworkContextLoader.js +1 -1
  21. package/lib/cjs/src/dynamic-network/domain/DynamicNetworkContextLoader.js.map +3 -3
  22. package/lib/cjs/src/dynamic-network/domain/DynamicNetworkContextLoader.test.js +1 -1
  23. package/lib/cjs/src/dynamic-network/domain/DynamicNetworkContextLoader.test.js.map +3 -3
  24. package/lib/cjs/src/external-plugin/domain/ExternalPluginContextLoader.js +1 -1
  25. package/lib/cjs/src/external-plugin/domain/ExternalPluginContextLoader.js.map +3 -3
  26. package/lib/cjs/src/external-plugin/domain/ExternalPluginContextLoader.test.js +1 -1
  27. package/lib/cjs/src/external-plugin/domain/ExternalPluginContextLoader.test.js.map +3 -3
  28. package/lib/cjs/src/nft/domain/NftContextLoader.js +1 -1
  29. package/lib/cjs/src/nft/domain/NftContextLoader.js.map +3 -3
  30. package/lib/cjs/src/nft/domain/NftContextLoader.test.js +1 -1
  31. package/lib/cjs/src/nft/domain/NftContextLoader.test.js.map +3 -3
  32. package/lib/cjs/src/shared/model/TypedDataClearSignContext.js +1 -1
  33. package/lib/cjs/src/shared/model/TypedDataClearSignContext.js.map +2 -2
  34. package/lib/cjs/src/solana/domain/DefaultSolanaContextLoader.js +1 -1
  35. package/lib/cjs/src/solana/domain/DefaultSolanaContextLoader.js.map +3 -3
  36. package/lib/cjs/src/solana/domain/DefaultSolanaContextLoader.test.js +1 -1
  37. package/lib/cjs/src/solana/domain/DefaultSolanaContextLoader.test.js.map +3 -3
  38. package/lib/cjs/src/solanaLifi/domain/SolanaLifiContextLoader.js +1 -1
  39. package/lib/cjs/src/solanaLifi/domain/SolanaLifiContextLoader.js.map +3 -3
  40. package/lib/cjs/src/solanaLifi/domain/SolanaLifiContextLoader.test.js +1 -1
  41. package/lib/cjs/src/solanaLifi/domain/SolanaLifiContextLoader.test.js.map +3 -3
  42. package/lib/cjs/src/solanaToken/domain/SolanaTokenContextLoader.js +1 -1
  43. package/lib/cjs/src/solanaToken/domain/SolanaTokenContextLoader.js.map +3 -3
  44. package/lib/cjs/src/solanaToken/domain/SolanaTokenContextLoader.test.js +1 -1
  45. package/lib/cjs/src/solanaToken/domain/SolanaTokenContextLoader.test.js.map +3 -3
  46. package/lib/cjs/src/token/domain/TokenContextFieldLoader.js +1 -1
  47. package/lib/cjs/src/token/domain/TokenContextFieldLoader.js.map +3 -3
  48. package/lib/cjs/src/token/domain/TokenContextFieldLoader.test.js +1 -1
  49. package/lib/cjs/src/token/domain/TokenContextFieldLoader.test.js.map +3 -3
  50. package/lib/cjs/src/token/domain/TokenContextLoader.js +1 -1
  51. package/lib/cjs/src/token/domain/TokenContextLoader.js.map +3 -3
  52. package/lib/cjs/src/token/domain/TokenContextLoader.test.js +1 -1
  53. package/lib/cjs/src/token/domain/TokenContextLoader.test.js.map +3 -3
  54. package/lib/cjs/src/transaction-check/domain/TransactionCheckContextLoader.js +1 -1
  55. package/lib/cjs/src/transaction-check/domain/TransactionCheckContextLoader.js.map +3 -3
  56. package/lib/cjs/src/transaction-check/domain/TransactionCheckContextLoader.test.js +1 -1
  57. package/lib/cjs/src/transaction-check/domain/TransactionCheckContextLoader.test.js.map +3 -3
  58. package/lib/cjs/src/transaction-check/domain/TypedDataCheckContextLoader.js +1 -1
  59. package/lib/cjs/src/transaction-check/domain/TypedDataCheckContextLoader.js.map +3 -3
  60. package/lib/cjs/src/transaction-check/domain/TypedDataCheckContextLoader.test.js +1 -1
  61. package/lib/cjs/src/transaction-check/domain/TypedDataCheckContextLoader.test.js.map +3 -3
  62. package/lib/cjs/src/trusted-name/di/trustedNameModuleFactory.js +1 -1
  63. package/lib/cjs/src/trusted-name/di/trustedNameModuleFactory.js.map +3 -3
  64. package/lib/cjs/src/trusted-name/domain/TrustedNameContextLoader.js +1 -1
  65. package/lib/cjs/src/trusted-name/domain/TrustedNameContextLoader.js.map +3 -3
  66. package/lib/cjs/src/trusted-name/domain/TrustedNameContextLoader.test.js +1 -1
  67. package/lib/cjs/src/trusted-name/domain/TrustedNameContextLoader.test.js.map +3 -3
  68. package/lib/cjs/src/typed-data/data/FiltersDto.js.map +1 -1
  69. package/lib/cjs/src/typed-data/data/HttpTypedDataDataSource.js +1 -1
  70. package/lib/cjs/src/typed-data/data/HttpTypedDataDataSource.js.map +2 -2
  71. package/lib/cjs/src/typed-data/data/HttpTypedDataDataSource.test.js +1 -1
  72. package/lib/cjs/src/typed-data/data/HttpTypedDataDataSource.test.js.map +2 -2
  73. package/lib/cjs/src/typed-data/domain/DefaultTypedDataContextLoader.js +1 -1
  74. package/lib/cjs/src/typed-data/domain/DefaultTypedDataContextLoader.js.map +3 -3
  75. package/lib/cjs/src/typed-data/domain/DefaultTypedDataContextLoader.test.js +1 -1
  76. package/lib/cjs/src/typed-data/domain/DefaultTypedDataContextLoader.test.js.map +3 -3
  77. package/lib/cjs/src/uniswap/domain/UniswapContextLoader.js +1 -1
  78. package/lib/cjs/src/uniswap/domain/UniswapContextLoader.js.map +3 -3
  79. package/lib/cjs/src/uniswap/domain/UniswapContextLoader.test.js +1 -1
  80. package/lib/cjs/src/uniswap/domain/UniswapContextLoader.test.js.map +3 -3
  81. package/lib/esm/package.json +1 -1
  82. package/lib/esm/src/ContextModuleBuilder.js +1 -1
  83. package/lib/esm/src/ContextModuleBuilder.js.map +3 -3
  84. package/lib/esm/src/ContextModuleBuilder.test.js +1 -1
  85. package/lib/esm/src/ContextModuleBuilder.test.js.map +3 -3
  86. package/lib/esm/src/DefaultContextModule.test.js +1 -1
  87. package/lib/esm/src/DefaultContextModule.test.js.map +3 -3
  88. package/lib/esm/src/calldata/domain/CalldataContextLoader.js +1 -1
  89. package/lib/esm/src/calldata/domain/CalldataContextLoader.js.map +3 -3
  90. package/lib/esm/src/calldata/domain/CalldataContextLoader.test.js +1 -1
  91. package/lib/esm/src/calldata/domain/CalldataContextLoader.test.js.map +3 -3
  92. package/lib/esm/src/config/di/configTypes.js +1 -1
  93. package/lib/esm/src/config/di/configTypes.js.map +2 -2
  94. package/lib/esm/src/di.js +1 -1
  95. package/lib/esm/src/di.js.map +3 -3
  96. package/lib/esm/src/dynamic-network/domain/DynamicNetworkContextLoader.js +1 -1
  97. package/lib/esm/src/dynamic-network/domain/DynamicNetworkContextLoader.js.map +3 -3
  98. package/lib/esm/src/dynamic-network/domain/DynamicNetworkContextLoader.test.js +1 -1
  99. package/lib/esm/src/dynamic-network/domain/DynamicNetworkContextLoader.test.js.map +3 -3
  100. package/lib/esm/src/external-plugin/domain/ExternalPluginContextLoader.js +1 -1
  101. package/lib/esm/src/external-plugin/domain/ExternalPluginContextLoader.js.map +3 -3
  102. package/lib/esm/src/external-plugin/domain/ExternalPluginContextLoader.test.js +1 -1
  103. package/lib/esm/src/external-plugin/domain/ExternalPluginContextLoader.test.js.map +3 -3
  104. package/lib/esm/src/nft/domain/NftContextLoader.js +1 -1
  105. package/lib/esm/src/nft/domain/NftContextLoader.js.map +3 -3
  106. package/lib/esm/src/nft/domain/NftContextLoader.test.js +1 -1
  107. package/lib/esm/src/nft/domain/NftContextLoader.test.js.map +3 -3
  108. package/lib/esm/src/shared/model/TypedDataClearSignContext.js.map +2 -2
  109. package/lib/esm/src/solana/domain/DefaultSolanaContextLoader.js +1 -1
  110. package/lib/esm/src/solana/domain/DefaultSolanaContextLoader.js.map +3 -3
  111. package/lib/esm/src/solana/domain/DefaultSolanaContextLoader.test.js +1 -1
  112. package/lib/esm/src/solana/domain/DefaultSolanaContextLoader.test.js.map +3 -3
  113. package/lib/esm/src/solanaLifi/domain/SolanaLifiContextLoader.js +1 -1
  114. package/lib/esm/src/solanaLifi/domain/SolanaLifiContextLoader.js.map +3 -3
  115. package/lib/esm/src/solanaLifi/domain/SolanaLifiContextLoader.test.js +1 -1
  116. package/lib/esm/src/solanaLifi/domain/SolanaLifiContextLoader.test.js.map +3 -3
  117. package/lib/esm/src/solanaToken/domain/SolanaTokenContextLoader.js +1 -1
  118. package/lib/esm/src/solanaToken/domain/SolanaTokenContextLoader.js.map +3 -3
  119. package/lib/esm/src/solanaToken/domain/SolanaTokenContextLoader.test.js +1 -1
  120. package/lib/esm/src/solanaToken/domain/SolanaTokenContextLoader.test.js.map +3 -3
  121. package/lib/esm/src/token/domain/TokenContextFieldLoader.js +1 -1
  122. package/lib/esm/src/token/domain/TokenContextFieldLoader.js.map +3 -3
  123. package/lib/esm/src/token/domain/TokenContextFieldLoader.test.js +1 -1
  124. package/lib/esm/src/token/domain/TokenContextFieldLoader.test.js.map +3 -3
  125. package/lib/esm/src/token/domain/TokenContextLoader.js +1 -1
  126. package/lib/esm/src/token/domain/TokenContextLoader.js.map +3 -3
  127. package/lib/esm/src/token/domain/TokenContextLoader.test.js +1 -1
  128. package/lib/esm/src/token/domain/TokenContextLoader.test.js.map +3 -3
  129. package/lib/esm/src/transaction-check/domain/TransactionCheckContextLoader.js +1 -1
  130. package/lib/esm/src/transaction-check/domain/TransactionCheckContextLoader.js.map +3 -3
  131. package/lib/esm/src/transaction-check/domain/TransactionCheckContextLoader.test.js +1 -1
  132. package/lib/esm/src/transaction-check/domain/TransactionCheckContextLoader.test.js.map +3 -3
  133. package/lib/esm/src/transaction-check/domain/TypedDataCheckContextLoader.js +1 -1
  134. package/lib/esm/src/transaction-check/domain/TypedDataCheckContextLoader.js.map +3 -3
  135. package/lib/esm/src/transaction-check/domain/TypedDataCheckContextLoader.test.js +1 -1
  136. package/lib/esm/src/transaction-check/domain/TypedDataCheckContextLoader.test.js.map +3 -3
  137. package/lib/esm/src/trusted-name/di/trustedNameModuleFactory.js +1 -1
  138. package/lib/esm/src/trusted-name/di/trustedNameModuleFactory.js.map +3 -3
  139. package/lib/esm/src/trusted-name/domain/TrustedNameContextLoader.js +1 -1
  140. package/lib/esm/src/trusted-name/domain/TrustedNameContextLoader.js.map +3 -3
  141. package/lib/esm/src/trusted-name/domain/TrustedNameContextLoader.test.js +1 -1
  142. package/lib/esm/src/trusted-name/domain/TrustedNameContextLoader.test.js.map +3 -3
  143. package/lib/esm/src/typed-data/data/HttpTypedDataDataSource.js +1 -1
  144. package/lib/esm/src/typed-data/data/HttpTypedDataDataSource.js.map +2 -2
  145. package/lib/esm/src/typed-data/data/HttpTypedDataDataSource.test.js +1 -1
  146. package/lib/esm/src/typed-data/data/HttpTypedDataDataSource.test.js.map +2 -2
  147. package/lib/esm/src/typed-data/domain/DefaultTypedDataContextLoader.js +1 -1
  148. package/lib/esm/src/typed-data/domain/DefaultTypedDataContextLoader.js.map +3 -3
  149. package/lib/esm/src/typed-data/domain/DefaultTypedDataContextLoader.test.js +1 -1
  150. package/lib/esm/src/typed-data/domain/DefaultTypedDataContextLoader.test.js.map +3 -3
  151. package/lib/esm/src/uniswap/domain/UniswapContextLoader.js +1 -1
  152. package/lib/esm/src/uniswap/domain/UniswapContextLoader.js.map +3 -3
  153. package/lib/esm/src/uniswap/domain/UniswapContextLoader.test.js +1 -1
  154. package/lib/esm/src/uniswap/domain/UniswapContextLoader.test.js.map +3 -3
  155. package/lib/types/src/ContextModuleBuilder.d.ts +18 -3
  156. package/lib/types/src/ContextModuleBuilder.d.ts.map +1 -1
  157. package/lib/types/src/calldata/domain/CalldataContextLoader.d.ts +3 -2
  158. package/lib/types/src/calldata/domain/CalldataContextLoader.d.ts.map +1 -1
  159. package/lib/types/src/config/di/configTypes.d.ts +1 -0
  160. package/lib/types/src/config/di/configTypes.d.ts.map +1 -1
  161. package/lib/types/src/config/model/ContextModuleBuildArgs.d.ts +2 -0
  162. package/lib/types/src/config/model/ContextModuleBuildArgs.d.ts.map +1 -1
  163. package/lib/types/src/config/model/ContextModuleConfig.d.ts +4 -0
  164. package/lib/types/src/config/model/ContextModuleConfig.d.ts.map +1 -1
  165. package/lib/types/src/di.d.ts.map +1 -1
  166. package/lib/types/src/dynamic-network/domain/DynamicNetworkContextLoader.d.ts +3 -2
  167. package/lib/types/src/dynamic-network/domain/DynamicNetworkContextLoader.d.ts.map +1 -1
  168. package/lib/types/src/external-plugin/domain/ExternalPluginContextLoader.d.ts +3 -2
  169. package/lib/types/src/external-plugin/domain/ExternalPluginContextLoader.d.ts.map +1 -1
  170. package/lib/types/src/nft/domain/NftContextLoader.d.ts +3 -2
  171. package/lib/types/src/nft/domain/NftContextLoader.d.ts.map +1 -1
  172. package/lib/types/src/shared/model/TypedDataClearSignContext.d.ts +2 -0
  173. package/lib/types/src/shared/model/TypedDataClearSignContext.d.ts.map +1 -1
  174. package/lib/types/src/solana/domain/DefaultSolanaContextLoader.d.ts +3 -1
  175. package/lib/types/src/solana/domain/DefaultSolanaContextLoader.d.ts.map +1 -1
  176. package/lib/types/src/solanaLifi/domain/SolanaLifiContextLoader.d.ts +3 -1
  177. package/lib/types/src/solanaLifi/domain/SolanaLifiContextLoader.d.ts.map +1 -1
  178. package/lib/types/src/solanaToken/domain/SolanaTokenContextLoader.d.ts +3 -2
  179. package/lib/types/src/solanaToken/domain/SolanaTokenContextLoader.d.ts.map +1 -1
  180. package/lib/types/src/token/domain/TokenContextFieldLoader.d.ts +5 -1
  181. package/lib/types/src/token/domain/TokenContextFieldLoader.d.ts.map +1 -1
  182. package/lib/types/src/token/domain/TokenContextLoader.d.ts +3 -2
  183. package/lib/types/src/token/domain/TokenContextLoader.d.ts.map +1 -1
  184. package/lib/types/src/transaction-check/domain/TransactionCheckContextLoader.d.ts +3 -2
  185. package/lib/types/src/transaction-check/domain/TransactionCheckContextLoader.d.ts.map +1 -1
  186. package/lib/types/src/transaction-check/domain/TypedDataCheckContextLoader.d.ts +3 -2
  187. package/lib/types/src/transaction-check/domain/TypedDataCheckContextLoader.d.ts.map +1 -1
  188. package/lib/types/src/trusted-name/di/trustedNameModuleFactory.d.ts +2 -1
  189. package/lib/types/src/trusted-name/di/trustedNameModuleFactory.d.ts.map +1 -1
  190. package/lib/types/src/trusted-name/domain/TrustedNameContextLoader.d.ts +3 -2
  191. package/lib/types/src/trusted-name/domain/TrustedNameContextLoader.d.ts.map +1 -1
  192. package/lib/types/src/typed-data/data/FiltersDto.d.ts +0 -4
  193. package/lib/types/src/typed-data/data/FiltersDto.d.ts.map +1 -1
  194. package/lib/types/src/typed-data/data/HttpTypedDataDataSource.test.d.ts.map +1 -1
  195. package/lib/types/src/typed-data/domain/DefaultTypedDataContextLoader.d.ts +3 -1
  196. package/lib/types/src/typed-data/domain/DefaultTypedDataContextLoader.d.ts.map +1 -1
  197. package/lib/types/src/uniswap/domain/UniswapContextLoader.d.ts +3 -2
  198. package/lib/types/src/uniswap/domain/UniswapContextLoader.d.ts.map +1 -1
  199. package/lib/types/tsconfig.prod.tsbuildinfo +1 -1
  200. package/package.json +3 -3
@@ -58,5 +58,5 @@
58
58
  "watch:builds": "pnpm ldmk-tool watch --entryPoints index.ts,src/**/*.ts --tsconfig tsconfig.prod.json",
59
59
  "watch:types": "concurrently \"tsc --watch -p tsconfig.prod.json\" \"tsc-alias --watch -p tsconfig.prod.json\""
60
60
  },
61
- "version": "1.11.1"
61
+ "version": "1.13.0"
62
62
  }
@@ -1,2 +1,2 @@
1
- "use strict";var n=Object.defineProperty;var s=Object.getOwnPropertyDescriptor;var c=Object.getOwnPropertyNames;var u=Object.prototype.hasOwnProperty;var C=(t,e)=>{for(var r in e)n(t,r,{get:e[r],enumerable:!0})},l=(t,e,r,a)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of c(e))!u.call(t,o)&&o!==r&&n(t,o,{get:()=>e[o],enumerable:!(a=s(e,o))||a.enumerable});return t};var f=t=>l(n({},"__esModule",{value:!0}),t);var L={};C(L,{ContextModuleBuilder:()=>h,DEFAULT_CONFIG:()=>d});module.exports=f(L);var i=require("./DefaultContextModule");const g="https://crypto-assets-service.api.ledger.com/v1",p="https://web3checks-backend.api.ledger.com/v3",m="https://nft.api.live.ledger.com",d={cal:{url:g,mode:"prod",branch:"main"},web3checks:{url:p},metadataServiceDomain:{url:m},defaultLoaders:!0,customLoaders:[],defaultFieldLoaders:!0,customFieldLoaders:[],customTypedDataLoader:void 0,customSolanaLoader:void 0};class h{config=d;originToken;constructor({originToken:e}={}){this.originToken=e}removeDefaultLoaders(){return this.config.defaultLoaders=!1,this}addLoader(e){return this.config.customLoaders.push(e),this}addTypedDataLoader(e){return this.config.customTypedDataLoader=e,this}addSolanaLoader(e){return this.config.customSolanaLoader=e,this}setCalConfig(e){return this.config.cal=e,this}setMetadataServiceConfig(e){return this.config.metadataServiceDomain=e,this}setWeb3ChecksConfig(e){return this.config.web3checks=e,this}setDatasourceConfig(e){return this.config.datasource=e,this}build(){const e={...this.config,originToken:this.originToken};return new i.DefaultContextModule(e)}}0&&(module.exports={ContextModuleBuilder,DEFAULT_CONFIG});
1
+ "use strict";var a=Object.defineProperty;var s=Object.getOwnPropertyDescriptor;var d=Object.getOwnPropertyNames;var u=Object.prototype.hasOwnProperty;var c=(t,e)=>{for(var o in e)a(t,o,{get:e[o],enumerable:!0})},g=(t,e,o,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of d(e))!u.call(t,r)&&r!==o&&a(t,r,{get:()=>e[r],enumerable:!(i=s(e,r))||i.enumerable});return t};var C=t=>g(a({},"__esModule",{value:!0}),t);var h={};c(h,{ContextModuleBuilder:()=>p});module.exports=C(h);var n=require("./DefaultContextModule");const l="https://crypto-assets-service.api.ledger.com/v1",f="https://web3checks-backend.api.ledger.com/v3",m="https://nft.api.live.ledger.com";class p{config;originToken;constructor({originToken:e,loggerFactory:o}){this.originToken=e,this.config={cal:{url:l,mode:"prod",branch:"main"},web3checks:{url:f},metadataServiceDomain:{url:m},defaultLoaders:!0,customLoaders:[],defaultFieldLoaders:!0,customFieldLoaders:[],customTypedDataLoader:void 0,customSolanaLoader:void 0,loggerFactory:o}}removeDefaultLoaders(){return this.config.defaultLoaders=!1,this}addLoader(e){return this.config.customLoaders.push(e),this}addTypedDataLoader(e){return this.config.customTypedDataLoader=e,this}addSolanaLoader(e){return this.config.customSolanaLoader=e,this}setCalConfig(e){return this.config.cal=e,this}setMetadataServiceConfig(e){return this.config.metadataServiceDomain=e,this}setWeb3ChecksConfig(e){return this.config.web3checks=e,this}setDatasourceConfig(e){return this.config.datasource=e,this}setTrustedNameDataSource(e){return this.config.customTrustedNameDataSource=e,this}setLoggerFactory(e){return this.config.loggerFactory=e,this}build(){const e={...this.config,originToken:this.originToken};return new n.DefaultContextModule(e)}}0&&(module.exports={ContextModuleBuilder});
2
2
  //# sourceMappingURL=ContextModuleBuilder.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../src/ContextModuleBuilder.ts"],
4
- "sourcesContent": ["import { type ContextModuleConstructorArgs } from \"./config/model/ContextModuleBuildArgs\";\nimport {\n type ContextModuleCalConfig,\n type ContextModuleConfig,\n type ContextModuleDatasourceConfig,\n type ContextModuleMetadataServiceConfig,\n type ContextModuleWeb3ChecksConfig,\n} from \"./config/model/ContextModuleConfig\";\nimport { type ContextLoader } from \"./shared/domain/ContextLoader\";\nimport { type SolanaContextLoader } from \"./solana/domain/SolanaContextLoader\";\nimport { type TypedDataContextLoader } from \"./typed-data/domain/TypedDataContextLoader\";\nimport { type ContextModule } from \"./ContextModule\";\nimport { DefaultContextModule } from \"./DefaultContextModule\";\n\nconst DEFAULT_CAL_URL = \"https://crypto-assets-service.api.ledger.com/v1\";\nconst DEFAULT_WEB3_CHECKS_URL = \"https://web3checks-backend.api.ledger.com/v3\";\nconst DEFAULT_METADATA_SERVICE_DOMAIN = \"https://nft.api.live.ledger.com\";\n\nexport const DEFAULT_CONFIG: ContextModuleConfig = {\n cal: {\n url: DEFAULT_CAL_URL,\n mode: \"prod\",\n branch: \"main\",\n },\n web3checks: {\n url: DEFAULT_WEB3_CHECKS_URL,\n },\n metadataServiceDomain: {\n url: DEFAULT_METADATA_SERVICE_DOMAIN,\n },\n defaultLoaders: true,\n customLoaders: [],\n defaultFieldLoaders: true,\n customFieldLoaders: [],\n customTypedDataLoader: undefined,\n customSolanaLoader: undefined,\n};\n\nexport class ContextModuleBuilder {\n private config: ContextModuleConfig = DEFAULT_CONFIG;\n private originToken?: string;\n\n constructor({ originToken }: ContextModuleConstructorArgs = {}) {\n this.originToken = originToken;\n }\n\n /**\n * Remove default loaders from the list of loaders\n *\n * @returns this\n */\n removeDefaultLoaders() {\n this.config.defaultLoaders = false;\n return this;\n }\n\n /**\n * Add a custom loader to the list of loaders\n *\n * @param loader loader to add to the list of loaders\n * @returns this\n */\n addLoader(loader: ContextLoader) {\n this.config.customLoaders.push(loader);\n return this;\n }\n\n /**\n * Replace the default loader for typed data clear signing contexts\n *\n * @param loader loader to use for typed data clear signing contexts\n * @returns this\n */\n addTypedDataLoader(loader: TypedDataContextLoader) {\n this.config.customTypedDataLoader = loader;\n return this;\n }\n\n /**\n * Replace the default loader for Solana context\n *\n * @param loader loader to use for Solana context\n * @returns this\n */\n addSolanaLoader(loader: SolanaContextLoader) {\n this.config.customSolanaLoader = loader;\n return this;\n }\n\n /**\n * Add a custom CAL configuration\n *\n * @param calConfig\n * @returns this\n */\n setCalConfig(calConfig: ContextModuleCalConfig) {\n this.config.cal = calConfig;\n return this;\n }\n\n /**\n * Add a custom metadata service configuration\n *\n * @param metadataServiceConfig\n * @returns this\n */\n setMetadataServiceConfig(\n metadataServiceConfig: ContextModuleMetadataServiceConfig,\n ) {\n this.config.metadataServiceDomain = metadataServiceConfig;\n return this;\n }\n\n /**\n * Add a custom web3 checks configuration\n *\n * @param web3ChecksConfig\n * @returns this\n */\n setWeb3ChecksConfig(web3ChecksConfig: ContextModuleWeb3ChecksConfig) {\n this.config.web3checks = web3ChecksConfig;\n return this;\n }\n\n /**\n * Add datasource configuration\n *\n * @param datasourceConfig\n * @returns this\n */\n setDatasourceConfig(datasourceConfig: ContextModuleDatasourceConfig) {\n this.config.datasource = datasourceConfig;\n return this;\n }\n\n /**\n * Build the context module\n *\n * @returns the context module\n */\n build(): ContextModule {\n const config = { ...this.config, originToken: this.originToken };\n return new DefaultContextModule(config);\n }\n}\n"],
5
- "mappings": "yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,0BAAAE,EAAA,mBAAAC,IAAA,eAAAC,EAAAJ,GAYA,IAAAK,EAAqC,kCAErC,MAAMC,EAAkB,kDAClBC,EAA0B,+CAC1BC,EAAkC,kCAE3BL,EAAsC,CACjD,IAAK,CACH,IAAKG,EACL,KAAM,OACN,OAAQ,MACV,EACA,WAAY,CACV,IAAKC,CACP,EACA,sBAAuB,CACrB,IAAKC,CACP,EACA,eAAgB,GAChB,cAAe,CAAC,EAChB,oBAAqB,GACrB,mBAAoB,CAAC,EACrB,sBAAuB,OACvB,mBAAoB,MACtB,EAEO,MAAMN,CAAqB,CACxB,OAA8BC,EAC9B,YAER,YAAY,CAAE,YAAAM,CAAY,EAAkC,CAAC,EAAG,CAC9D,KAAK,YAAcA,CACrB,CAOA,sBAAuB,CACrB,YAAK,OAAO,eAAiB,GACtB,IACT,CAQA,UAAUC,EAAuB,CAC/B,YAAK,OAAO,cAAc,KAAKA,CAAM,EAC9B,IACT,CAQA,mBAAmBA,EAAgC,CACjD,YAAK,OAAO,sBAAwBA,EAC7B,IACT,CAQA,gBAAgBA,EAA6B,CAC3C,YAAK,OAAO,mBAAqBA,EAC1B,IACT,CAQA,aAAaC,EAAmC,CAC9C,YAAK,OAAO,IAAMA,EACX,IACT,CAQA,yBACEC,EACA,CACA,YAAK,OAAO,sBAAwBA,EAC7B,IACT,CAQA,oBAAoBC,EAAiD,CACnE,YAAK,OAAO,WAAaA,EAClB,IACT,CAQA,oBAAoBC,EAAiD,CACnE,YAAK,OAAO,WAAaA,EAClB,IACT,CAOA,OAAuB,CACrB,MAAMC,EAAS,CAAE,GAAG,KAAK,OAAQ,YAAa,KAAK,WAAY,EAC/D,OAAO,IAAI,uBAAqBA,CAAM,CACxC,CACF",
6
- "names": ["ContextModuleBuilder_exports", "__export", "ContextModuleBuilder", "DEFAULT_CONFIG", "__toCommonJS", "import_DefaultContextModule", "DEFAULT_CAL_URL", "DEFAULT_WEB3_CHECKS_URL", "DEFAULT_METADATA_SERVICE_DOMAIN", "originToken", "loader", "calConfig", "metadataServiceConfig", "web3ChecksConfig", "datasourceConfig", "config"]
4
+ "sourcesContent": ["import { type LoggerPublisherService } from \"@ledgerhq/device-management-kit\";\n\nimport { type ContextModuleConstructorArgs } from \"./config/model/ContextModuleBuildArgs\";\nimport {\n type ContextModuleCalConfig,\n type ContextModuleConfig,\n type ContextModuleDatasourceConfig,\n type ContextModuleMetadataServiceConfig,\n type ContextModuleWeb3ChecksConfig,\n} from \"./config/model/ContextModuleConfig\";\nimport { type ContextLoader } from \"./shared/domain/ContextLoader\";\nimport { type SolanaContextLoader } from \"./solana/domain/SolanaContextLoader\";\nimport { type TrustedNameDataSource } from \"./trusted-name/data/TrustedNameDataSource\";\nimport { type TypedDataContextLoader } from \"./typed-data/domain/TypedDataContextLoader\";\nimport { type ContextModule } from \"./ContextModule\";\nimport { DefaultContextModule } from \"./DefaultContextModule\";\n\nconst DEFAULT_CAL_URL = \"https://crypto-assets-service.api.ledger.com/v1\";\nconst DEFAULT_WEB3_CHECKS_URL = \"https://web3checks-backend.api.ledger.com/v3\";\nconst DEFAULT_METADATA_SERVICE_DOMAIN = \"https://nft.api.live.ledger.com\";\n\nexport class ContextModuleBuilder {\n private config: ContextModuleConfig;\n private originToken?: string;\n\n constructor({ originToken, loggerFactory }: ContextModuleConstructorArgs) {\n this.originToken = originToken;\n\n this.config = {\n cal: {\n url: DEFAULT_CAL_URL,\n mode: \"prod\",\n branch: \"main\",\n },\n web3checks: {\n url: DEFAULT_WEB3_CHECKS_URL,\n },\n metadataServiceDomain: {\n url: DEFAULT_METADATA_SERVICE_DOMAIN,\n },\n defaultLoaders: true,\n customLoaders: [],\n defaultFieldLoaders: true,\n customFieldLoaders: [],\n customTypedDataLoader: undefined,\n customSolanaLoader: undefined,\n loggerFactory,\n };\n }\n\n /**\n * Remove default loaders from the list of loaders\n *\n * @returns this\n */\n removeDefaultLoaders() {\n this.config.defaultLoaders = false;\n return this;\n }\n\n /**\n * Add a custom loader to the list of loaders\n *\n * @param loader loader to add to the list of loaders\n * @returns this\n */\n addLoader(loader: ContextLoader) {\n this.config.customLoaders.push(loader);\n return this;\n }\n\n /**\n * Replace the default loader for typed data clear signing contexts\n *\n * @param loader loader to use for typed data clear signing contexts\n * @returns this\n */\n addTypedDataLoader(loader: TypedDataContextLoader) {\n this.config.customTypedDataLoader = loader;\n return this;\n }\n\n /**\n * Replace the default loader for Solana context\n *\n * @param loader loader to use for Solana context\n * @returns this\n */\n addSolanaLoader(loader: SolanaContextLoader) {\n this.config.customSolanaLoader = loader;\n return this;\n }\n\n /**\n * Add a custom CAL configuration\n *\n * @param calConfig\n * @returns this\n */\n setCalConfig(calConfig: ContextModuleCalConfig) {\n this.config.cal = calConfig;\n return this;\n }\n\n /**\n * Add a custom metadata service configuration\n *\n * @param metadataServiceConfig\n * @returns this\n */\n setMetadataServiceConfig(\n metadataServiceConfig: ContextModuleMetadataServiceConfig,\n ) {\n this.config.metadataServiceDomain = metadataServiceConfig;\n return this;\n }\n\n /**\n * Add a custom web3 checks configuration\n *\n * @param web3ChecksConfig\n * @returns this\n */\n setWeb3ChecksConfig(web3ChecksConfig: ContextModuleWeb3ChecksConfig) {\n this.config.web3checks = web3ChecksConfig;\n return this;\n }\n\n /**\n * Add datasource configuration\n *\n * @param datasourceConfig\n * @returns this\n */\n setDatasourceConfig(datasourceConfig: ContextModuleDatasourceConfig) {\n this.config.datasource = datasourceConfig;\n return this;\n }\n\n /**\n * Set a custom trusted name data source\n *\n * @param dataSource data source to use for trusted name resolution\n * @returns this\n */\n setTrustedNameDataSource(dataSource: TrustedNameDataSource) {\n this.config.customTrustedNameDataSource = dataSource;\n return this;\n }\n\n /**\n * Set a custom logger factory\n *\n * @param loggerFactory\n * @returns this\n */\n setLoggerFactory(loggerFactory: (tag: string) => LoggerPublisherService) {\n this.config.loggerFactory = loggerFactory;\n return this;\n }\n\n /**\n * Build the context module\n *\n * @returns the context module\n */\n build(): ContextModule {\n const config = { ...this.config, originToken: this.originToken };\n return new DefaultContextModule(config);\n }\n}\n"],
5
+ "mappings": "yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,0BAAAE,IAAA,eAAAC,EAAAH,GAeA,IAAAI,EAAqC,kCAErC,MAAMC,EAAkB,kDAClBC,EAA0B,+CAC1BC,EAAkC,kCAEjC,MAAML,CAAqB,CACxB,OACA,YAER,YAAY,CAAE,YAAAM,EAAa,cAAAC,CAAc,EAAiC,CACxE,KAAK,YAAcD,EAEnB,KAAK,OAAS,CACZ,IAAK,CACH,IAAKH,EACL,KAAM,OACN,OAAQ,MACV,EACA,WAAY,CACV,IAAKC,CACP,EACA,sBAAuB,CACrB,IAAKC,CACP,EACA,eAAgB,GAChB,cAAe,CAAC,EAChB,oBAAqB,GACrB,mBAAoB,CAAC,EACrB,sBAAuB,OACvB,mBAAoB,OACpB,cAAAE,CACF,CACF,CAOA,sBAAuB,CACrB,YAAK,OAAO,eAAiB,GACtB,IACT,CAQA,UAAUC,EAAuB,CAC/B,YAAK,OAAO,cAAc,KAAKA,CAAM,EAC9B,IACT,CAQA,mBAAmBA,EAAgC,CACjD,YAAK,OAAO,sBAAwBA,EAC7B,IACT,CAQA,gBAAgBA,EAA6B,CAC3C,YAAK,OAAO,mBAAqBA,EAC1B,IACT,CAQA,aAAaC,EAAmC,CAC9C,YAAK,OAAO,IAAMA,EACX,IACT,CAQA,yBACEC,EACA,CACA,YAAK,OAAO,sBAAwBA,EAC7B,IACT,CAQA,oBAAoBC,EAAiD,CACnE,YAAK,OAAO,WAAaA,EAClB,IACT,CAQA,oBAAoBC,EAAiD,CACnE,YAAK,OAAO,WAAaA,EAClB,IACT,CAQA,yBAAyBC,EAAmC,CAC1D,YAAK,OAAO,4BAA8BA,EACnC,IACT,CAQA,iBAAiBN,EAAwD,CACvE,YAAK,OAAO,cAAgBA,EACrB,IACT,CAOA,OAAuB,CACrB,MAAMO,EAAS,CAAE,GAAG,KAAK,OAAQ,YAAa,KAAK,WAAY,EAC/D,OAAO,IAAI,uBAAqBA,CAAM,CACxC,CACF",
6
+ "names": ["ContextModuleBuilder_exports", "__export", "ContextModuleBuilder", "__toCommonJS", "import_DefaultContextModule", "DEFAULT_CAL_URL", "DEFAULT_WEB3_CHECKS_URL", "DEFAULT_METADATA_SERVICE_DOMAIN", "originToken", "loggerFactory", "loader", "calConfig", "metadataServiceConfig", "web3ChecksConfig", "datasourceConfig", "dataSource", "config"]
7
7
  }
@@ -1,2 +1,2 @@
1
- "use strict";var s=require("./config/di/configTypes"),c=require("./ContextModuleBuilder"),u=require("./DefaultContextModule");describe("ContextModuleBuilder",()=>{const i={url:"https://cal/v1",mode:"prod",branch:"main"},r={url:"https://web3checks/v1"},a={originToken:"test"};beforeEach(()=>{vi.resetAllMocks()}),it("should return a default context module",()=>{const e=new c.ContextModuleBuilder(a).build();expect(e).toBeInstanceOf(u.DefaultContextModule)}),it("should return a custom context module",()=>{const n=new c.ContextModuleBuilder(a),e={load:vi.fn(),canHandle:vi.fn()},t=n.removeDefaultLoaders().addLoader(e).build();expect(t).toBeInstanceOf(u.DefaultContextModule)}),it("should return a custom context module with a custom typed data loader",()=>{const n=new c.ContextModuleBuilder(a),e={load:vi.fn()},t=n.removeDefaultLoaders().addTypedDataLoader(e).build();expect(t).toBeInstanceOf(u.DefaultContextModule),expect(t._typedDataLoader).toBe(e)}),it("should return a custom context module with a custom config",()=>{const e=new c.ContextModuleBuilder(a).setCalConfig(i).setWeb3ChecksConfig(r).build(),t=e._container.get(s.configTypes.Config);expect(e).toBeInstanceOf(u.DefaultContextModule),expect(t.cal).toEqual(i),expect(t.web3checks).toEqual(r)}),it("should not throw an error if origin token is provided",()=>{const n=new c.ContextModuleBuilder(a);expect(()=>n.build()).not.toThrow()}),describe("setMetadataServiceConfig",()=>{it("should set the metadata service configuration",()=>{const n=new c.ContextModuleBuilder(a),e={url:"https://custom-metadata-service.com/v3"},t=n.setMetadataServiceConfig(e).build(),o=t._container.get(s.configTypes.Config);expect(t).toBeInstanceOf(u.DefaultContextModule),expect(o.metadataServiceDomain).toEqual(e)}),it("should override the default metadata service configuration",()=>{const n=new c.ContextModuleBuilder(a),e={url:"https://override-metadata-service.com/v1"},o=n.setMetadataServiceConfig(e).build()._container.get(s.configTypes.Config);expect(o.metadataServiceDomain.url).toBe(e.url),expect(o.metadataServiceDomain.url).not.toBe("https://nft.api.live.ledger.com/v2")})}),describe("setCalConfig",()=>{it("should set the CAL configuration",()=>{const n=new c.ContextModuleBuilder(a),e={url:"https://custom-cal-service.com/v2",mode:"test",branch:"next"},t=n.setCalConfig(e).build(),o=t._container.get(s.configTypes.Config);expect(t).toBeInstanceOf(u.DefaultContextModule),expect(o.cal).toEqual(e)}),it("should override the default CAL configuration",()=>{const n=new c.ContextModuleBuilder(a),e={url:"https://override-cal-service.com/v1",mode:"prod",branch:"demo"},o=n.setCalConfig(e).build()._container.get(s.configTypes.Config);expect(o.cal.url).toBe(e.url),expect(o.cal.mode).toBe(e.mode),expect(o.cal.branch).toBe(e.branch),expect(o.cal.url).not.toBe("https://crypto-assets-service.api.ledger.com/v1")})}),describe("setWeb3ChecksConfig",()=>{it("should set the web3 checks configuration",()=>{const n=new c.ContextModuleBuilder(a),e={url:"https://custom-web3checks-service.com/v4"},t=n.setWeb3ChecksConfig(e).build(),o=t._container.get(s.configTypes.Config);expect(t).toBeInstanceOf(u.DefaultContextModule),expect(o.web3checks).toEqual(e)}),it("should override the default web3 checks configuration",()=>{const n=new c.ContextModuleBuilder(a),e={url:"https://override-web3checks-service.com/v2"},o=n.setWeb3ChecksConfig(e).build()._container.get(s.configTypes.Config);expect(o.web3checks.url).toBe(e.url),expect(o.web3checks.url).not.toBe("https://web3checks-backend.api.ledger.com/v3")})}),describe("setDatasourceConfig",()=>{it("should set the datasource configuration with safe proxy",()=>{const n=new c.ContextModuleBuilder(a),e={proxy:"safe"},t=n.setDatasourceConfig(e).build(),o=t._container.get(s.configTypes.Config);expect(t).toBeInstanceOf(u.DefaultContextModule),expect(o.datasource).toEqual(e),expect(o.datasource?.proxy).toBe("safe")}),it("should set the datasource configuration with default proxy",()=>{const n=new c.ContextModuleBuilder(a),e={proxy:"default"},t=n.setDatasourceConfig(e).build(),o=t._container.get(s.configTypes.Config);expect(t).toBeInstanceOf(u.DefaultContextModule),expect(o.datasource).toEqual(e),expect(o.datasource?.proxy).toBe("default")}),it("should override the default datasource configuration",()=>{const n=new c.ContextModuleBuilder(a),e={proxy:"safe"},o=n.setDatasourceConfig(e).build()._container.get(s.configTypes.Config);expect(o.datasource?.proxy).toBe("safe"),expect(o.datasource).not.toBeUndefined()}),it("should set an empty datasource configuration",()=>{const n=new c.ContextModuleBuilder(a),e={},t=n.setDatasourceConfig(e).build(),o=t._container.get(s.configTypes.Config);expect(t).toBeInstanceOf(u.DefaultContextModule),expect(o.datasource).toEqual(e),expect(o.datasource?.proxy).toBeUndefined()})})});
1
+ "use strict";var r=require("./config/di/configTypes"),g=require("./trusted-name/data/HttpTrustedNameDataSource"),u=require("./trusted-name/di/trustedNameTypes"),c=require("./ContextModuleBuilder"),s=require("./DefaultContextModule");describe("ContextModuleBuilder",()=>{const i={url:"https://cal/v1",mode:"prod",branch:"main"},d={url:"https://web3checks/v1"},a={originToken:"test",loggerFactory:()=>({debug:vi.fn(),info:vi.fn(),warn:vi.fn(),error:vi.fn(),subscribers:[]})};beforeEach(()=>{vi.resetAllMocks()}),it("should return a default context module",()=>{const e=new c.ContextModuleBuilder(a).build();expect(e).toBeInstanceOf(s.DefaultContextModule)}),it("should return a custom context module",()=>{const o=new c.ContextModuleBuilder(a),e={load:vi.fn(),canHandle:vi.fn()},t=o.removeDefaultLoaders().addLoader(e).build();expect(t).toBeInstanceOf(s.DefaultContextModule)}),it("should return a custom context module with a custom typed data loader",()=>{const o=new c.ContextModuleBuilder(a),e={load:vi.fn()},t=o.removeDefaultLoaders().addTypedDataLoader(e).build();expect(t).toBeInstanceOf(s.DefaultContextModule),expect(t._typedDataLoader).toBe(e)}),it("should return a custom context module with a custom config",()=>{const e=new c.ContextModuleBuilder(a).setCalConfig(i).setWeb3ChecksConfig(d).build(),t=e._container.get(r.configTypes.Config);expect(e).toBeInstanceOf(s.DefaultContextModule),expect(t.cal).toEqual(i),expect(t.web3checks).toEqual(d)}),it("should not throw an error if origin token is provided",()=>{const o=new c.ContextModuleBuilder(a);expect(()=>o.build()).not.toThrow()}),describe("setMetadataServiceConfig",()=>{it("should set the metadata service configuration",()=>{const o=new c.ContextModuleBuilder(a),e={url:"https://custom-metadata-service.com/v3"},t=o.setMetadataServiceConfig(e).build(),n=t._container.get(r.configTypes.Config);expect(t).toBeInstanceOf(s.DefaultContextModule),expect(n.metadataServiceDomain).toEqual(e)}),it("should override the default metadata service configuration",()=>{const o=new c.ContextModuleBuilder(a),e={url:"https://override-metadata-service.com/v1"},n=o.setMetadataServiceConfig(e).build()._container.get(r.configTypes.Config);expect(n.metadataServiceDomain.url).toBe(e.url),expect(n.metadataServiceDomain.url).not.toBe("https://nft.api.live.ledger.com/v2")})}),describe("setCalConfig",()=>{it("should set the CAL configuration",()=>{const o=new c.ContextModuleBuilder(a),e={url:"https://custom-cal-service.com/v2",mode:"test",branch:"next"},t=o.setCalConfig(e).build(),n=t._container.get(r.configTypes.Config);expect(t).toBeInstanceOf(s.DefaultContextModule),expect(n.cal).toEqual(e)}),it("should override the default CAL configuration",()=>{const o=new c.ContextModuleBuilder(a),e={url:"https://override-cal-service.com/v1",mode:"prod",branch:"demo"},n=o.setCalConfig(e).build()._container.get(r.configTypes.Config);expect(n.cal.url).toBe(e.url),expect(n.cal.mode).toBe(e.mode),expect(n.cal.branch).toBe(e.branch),expect(n.cal.url).not.toBe("https://crypto-assets-service.api.ledger.com/v1")})}),describe("setWeb3ChecksConfig",()=>{it("should set the web3 checks configuration",()=>{const o=new c.ContextModuleBuilder(a),e={url:"https://custom-web3checks-service.com/v4"},t=o.setWeb3ChecksConfig(e).build(),n=t._container.get(r.configTypes.Config);expect(t).toBeInstanceOf(s.DefaultContextModule),expect(n.web3checks).toEqual(e)}),it("should override the default web3 checks configuration",()=>{const o=new c.ContextModuleBuilder(a),e={url:"https://override-web3checks-service.com/v2"},n=o.setWeb3ChecksConfig(e).build()._container.get(r.configTypes.Config);expect(n.web3checks.url).toBe(e.url),expect(n.web3checks.url).not.toBe("https://web3checks-backend.api.ledger.com/v3")})}),describe("setDatasourceConfig",()=>{it("should set the datasource configuration with safe proxy",()=>{const o=new c.ContextModuleBuilder(a),e={proxy:"safe"},t=o.setDatasourceConfig(e).build(),n=t._container.get(r.configTypes.Config);expect(t).toBeInstanceOf(s.DefaultContextModule),expect(n.datasource).toEqual(e),expect(n.datasource?.proxy).toBe("safe")}),it("should set the datasource configuration with default proxy",()=>{const o=new c.ContextModuleBuilder(a),e={proxy:"default"},t=o.setDatasourceConfig(e).build(),n=t._container.get(r.configTypes.Config);expect(t).toBeInstanceOf(s.DefaultContextModule),expect(n.datasource).toEqual(e),expect(n.datasource?.proxy).toBe("default")}),it("should override the default datasource configuration",()=>{const o=new c.ContextModuleBuilder(a),e={proxy:"safe"},n=o.setDatasourceConfig(e).build()._container.get(r.configTypes.Config);expect(n.datasource?.proxy).toBe("safe"),expect(n.datasource).not.toBeUndefined()}),it("should set an empty datasource configuration",()=>{const o=new c.ContextModuleBuilder(a),e={},t=o.setDatasourceConfig(e).build(),n=t._container.get(r.configTypes.Config);expect(t).toBeInstanceOf(s.DefaultContextModule),expect(n.datasource).toEqual(e),expect(n.datasource?.proxy).toBeUndefined()})}),describe("loggerFactory",()=>{it("should set the loggerFactory when provided in the constructor",()=>{const o=vi.fn(),t=new c.ContextModuleBuilder({...a,loggerFactory:o}).build(),n=t._container.get(r.configTypes.Config);expect(t).toBeInstanceOf(s.DefaultContextModule),expect(n.loggerFactory).toBe(o)}),it("should set the loggerFactory via setLoggerFactory",()=>{const o=vi.fn(),t=new c.ContextModuleBuilder(a).setLoggerFactory(o).build(),n=t._container.get(r.configTypes.Config);expect(t).toBeInstanceOf(s.DefaultContextModule),expect(n.loggerFactory).toBe(o)}),it("should override constructor loggerFactory with setLoggerFactory",()=>{const o=vi.fn(),e=vi.fn(),l=new c.ContextModuleBuilder({...a,loggerFactory:o}).setLoggerFactory(e).build()._container.get(r.configTypes.Config);expect(l.loggerFactory).toBe(e),expect(l.loggerFactory).not.toBe(o)})}),describe("setTrustedNameDataSource",()=>{it("should set a custom trusted name data source",()=>{const o=new c.ContextModuleBuilder(a),e={getDomainNamePayload:vi.fn(),getTrustedNamePayload:vi.fn()},t=o.setTrustedNameDataSource(e).build(),n=t._container.get(r.configTypes.Config);expect(t).toBeInstanceOf(s.DefaultContextModule),expect(n.customTrustedNameDataSource).toBe(e)}),it("should inject the custom data source into the container",()=>{const o=new c.ContextModuleBuilder(a),e={getDomainNamePayload:vi.fn(),getTrustedNamePayload:vi.fn()},n=o.setTrustedNameDataSource(e).build()._container.get(u.trustedNameTypes.TrustedNameDataSource);expect(n).toBe(e)}),it("should use HttpTrustedNameDataSource when no custom data source is set",()=>{const e=new c.ContextModuleBuilder(a).build(),t=e._container.get(u.trustedNameTypes.TrustedNameDataSource);expect(e).toBeInstanceOf(s.DefaultContextModule),expect(t).toBeInstanceOf(g.HttpTrustedNameDataSource)})})});
2
2
  //# sourceMappingURL=ContextModuleBuilder.test.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../src/ContextModuleBuilder.test.ts"],
4
- "sourcesContent": ["import { type Container } from \"inversify\";\n\nimport { configTypes } from \"./config/di/configTypes\";\nimport { type ContextModuleConstructorArgs } from \"./config/model/ContextModuleBuildArgs\";\nimport {\n type ContextModuleCalConfig,\n type ContextModuleConfig,\n type ContextModuleDatasourceConfig,\n type ContextModuleMetadataServiceConfig,\n} from \"./config/model/ContextModuleConfig\";\nimport { type ContextLoader } from \"./shared/domain/ContextLoader\";\nimport { ContextModuleBuilder } from \"./ContextModuleBuilder\";\nimport { DefaultContextModule } from \"./DefaultContextModule\";\n\ndescribe(\"ContextModuleBuilder\", () => {\n const defaultCalConfig: ContextModuleCalConfig = {\n url: \"https://cal/v1\",\n mode: \"prod\",\n branch: \"main\",\n };\n const defaultWeb3ChecksConfig = {\n url: \"https://web3checks/v1\",\n };\n const defaultBuilderArgs: ContextModuleConstructorArgs = {\n originToken: \"test\",\n };\n\n beforeEach(() => {\n vi.resetAllMocks();\n });\n\n it(\"should return a default context module\", () => {\n const contextModuleBuilder = new ContextModuleBuilder(defaultBuilderArgs);\n\n const res = contextModuleBuilder.build();\n\n expect(res).toBeInstanceOf(DefaultContextModule);\n });\n\n it(\"should return a custom context module\", () => {\n const contextModuleBuilder = new ContextModuleBuilder(defaultBuilderArgs);\n const customLoader: ContextLoader = {\n load: vi.fn(),\n canHandle: vi.fn() as unknown as ContextLoader[\"canHandle\"],\n };\n\n const res = contextModuleBuilder\n .removeDefaultLoaders()\n .addLoader(customLoader)\n .build();\n\n expect(res).toBeInstanceOf(DefaultContextModule);\n });\n\n it(\"should return a custom context module with a custom typed data loader\", () => {\n const contextModuleBuilder = new ContextModuleBuilder(defaultBuilderArgs);\n const customLoader = { load: vi.fn() };\n\n const res = contextModuleBuilder\n .removeDefaultLoaders()\n .addTypedDataLoader(customLoader)\n .build();\n\n expect(res).toBeInstanceOf(DefaultContextModule);\n // @ts-expect-error _typedDataLoader is private\n expect(res[\"_typedDataLoader\"]).toBe(customLoader);\n });\n\n it(\"should return a custom context module with a custom config\", () => {\n const contextModuleBuilder = new ContextModuleBuilder(defaultBuilderArgs);\n\n const res = contextModuleBuilder\n .setCalConfig(defaultCalConfig)\n .setWeb3ChecksConfig(defaultWeb3ChecksConfig)\n .build();\n // @ts-expect-error _container is private\n const config = (res[\"_container\"] as Container).get<ContextModuleConfig>(\n configTypes.Config,\n );\n\n expect(res).toBeInstanceOf(DefaultContextModule);\n expect(config.cal).toEqual(defaultCalConfig);\n expect(config.web3checks).toEqual(defaultWeb3ChecksConfig);\n });\n\n it(\"should not throw an error if origin token is provided\", () => {\n const contextModuleBuilder = new ContextModuleBuilder(defaultBuilderArgs);\n\n expect(() => contextModuleBuilder.build()).not.toThrow();\n });\n\n describe(\"setMetadataServiceConfig\", () => {\n it(\"should set the metadata service configuration\", () => {\n const contextModuleBuilder = new ContextModuleBuilder(defaultBuilderArgs);\n const customMetadataConfig: ContextModuleMetadataServiceConfig = {\n url: \"https://custom-metadata-service.com/v3\",\n };\n\n const res = contextModuleBuilder\n .setMetadataServiceConfig(customMetadataConfig)\n .build();\n const config = (res as DefaultContextModule)[\n \"_container\"\n ].get<ContextModuleConfig>(configTypes.Config);\n\n expect(res).toBeInstanceOf(DefaultContextModule);\n expect(config.metadataServiceDomain).toEqual(customMetadataConfig);\n });\n\n it(\"should override the default metadata service configuration\", () => {\n const contextModuleBuilder = new ContextModuleBuilder(defaultBuilderArgs);\n const customMetadataConfig: ContextModuleMetadataServiceConfig = {\n url: \"https://override-metadata-service.com/v1\",\n };\n\n const res = contextModuleBuilder\n .setMetadataServiceConfig(customMetadataConfig)\n .build();\n const config = (res as DefaultContextModule)[\n \"_container\"\n ].get<ContextModuleConfig>(configTypes.Config);\n\n expect(config.metadataServiceDomain.url).toBe(customMetadataConfig.url);\n expect(config.metadataServiceDomain.url).not.toBe(\n \"https://nft.api.live.ledger.com/v2\",\n );\n });\n });\n\n describe(\"setCalConfig\", () => {\n it(\"should set the CAL configuration\", () => {\n const contextModuleBuilder = new ContextModuleBuilder(defaultBuilderArgs);\n const customCalConfig: ContextModuleCalConfig = {\n url: \"https://custom-cal-service.com/v2\",\n mode: \"test\",\n branch: \"next\",\n };\n\n const res = contextModuleBuilder.setCalConfig(customCalConfig).build();\n const config = (res as DefaultContextModule)[\n \"_container\"\n ].get<ContextModuleConfig>(configTypes.Config);\n\n expect(res).toBeInstanceOf(DefaultContextModule);\n expect(config.cal).toEqual(customCalConfig);\n });\n\n it(\"should override the default CAL configuration\", () => {\n const contextModuleBuilder = new ContextModuleBuilder(defaultBuilderArgs);\n const customCalConfig: ContextModuleCalConfig = {\n url: \"https://override-cal-service.com/v1\",\n mode: \"prod\",\n branch: \"demo\",\n };\n\n const res = contextModuleBuilder.setCalConfig(customCalConfig).build();\n const config = (res as DefaultContextModule)[\n \"_container\"\n ].get<ContextModuleConfig>(configTypes.Config);\n\n expect(config.cal.url).toBe(customCalConfig.url);\n expect(config.cal.mode).toBe(customCalConfig.mode);\n expect(config.cal.branch).toBe(customCalConfig.branch);\n expect(config.cal.url).not.toBe(\n \"https://crypto-assets-service.api.ledger.com/v1\",\n );\n });\n });\n\n describe(\"setWeb3ChecksConfig\", () => {\n it(\"should set the web3 checks configuration\", () => {\n const contextModuleBuilder = new ContextModuleBuilder(defaultBuilderArgs);\n const customWeb3ChecksConfig = {\n url: \"https://custom-web3checks-service.com/v4\",\n };\n\n const res = contextModuleBuilder\n .setWeb3ChecksConfig(customWeb3ChecksConfig)\n .build();\n const config = (res as DefaultContextModule)[\n \"_container\"\n ].get<ContextModuleConfig>(configTypes.Config);\n\n expect(res).toBeInstanceOf(DefaultContextModule);\n expect(config.web3checks).toEqual(customWeb3ChecksConfig);\n });\n\n it(\"should override the default web3 checks configuration\", () => {\n const contextModuleBuilder = new ContextModuleBuilder(defaultBuilderArgs);\n const customWeb3ChecksConfig = {\n url: \"https://override-web3checks-service.com/v2\",\n };\n\n const res = contextModuleBuilder\n .setWeb3ChecksConfig(customWeb3ChecksConfig)\n .build();\n const config = (res as DefaultContextModule)[\n \"_container\"\n ].get<ContextModuleConfig>(configTypes.Config);\n\n expect(config.web3checks.url).toBe(customWeb3ChecksConfig.url);\n expect(config.web3checks.url).not.toBe(\n \"https://web3checks-backend.api.ledger.com/v3\",\n );\n });\n });\n\n describe(\"setDatasourceConfig\", () => {\n it(\"should set the datasource configuration with safe proxy\", () => {\n const contextModuleBuilder = new ContextModuleBuilder(defaultBuilderArgs);\n const customDatasourceConfig: ContextModuleDatasourceConfig = {\n proxy: \"safe\",\n };\n\n const res = contextModuleBuilder\n .setDatasourceConfig(customDatasourceConfig)\n .build();\n const config = (res as DefaultContextModule)[\n \"_container\"\n ].get<ContextModuleConfig>(configTypes.Config);\n\n expect(res).toBeInstanceOf(DefaultContextModule);\n expect(config.datasource).toEqual(customDatasourceConfig);\n expect(config.datasource?.proxy).toBe(\"safe\");\n });\n\n it(\"should set the datasource configuration with default proxy\", () => {\n const contextModuleBuilder = new ContextModuleBuilder(defaultBuilderArgs);\n const customDatasourceConfig: ContextModuleDatasourceConfig = {\n proxy: \"default\",\n };\n\n const res = contextModuleBuilder\n .setDatasourceConfig(customDatasourceConfig)\n .build();\n const config = (res as DefaultContextModule)[\n \"_container\"\n ].get<ContextModuleConfig>(configTypes.Config);\n\n expect(res).toBeInstanceOf(DefaultContextModule);\n expect(config.datasource).toEqual(customDatasourceConfig);\n expect(config.datasource?.proxy).toBe(\"default\");\n });\n\n it(\"should override the default datasource configuration\", () => {\n const contextModuleBuilder = new ContextModuleBuilder(defaultBuilderArgs);\n const customDatasourceConfig: ContextModuleDatasourceConfig = {\n proxy: \"safe\",\n };\n\n const res = contextModuleBuilder\n .setDatasourceConfig(customDatasourceConfig)\n .build();\n const config = (res as DefaultContextModule)[\n \"_container\"\n ].get<ContextModuleConfig>(configTypes.Config);\n\n expect(config.datasource?.proxy).toBe(\"safe\");\n expect(config.datasource).not.toBeUndefined();\n });\n\n it(\"should set an empty datasource configuration\", () => {\n const contextModuleBuilder = new ContextModuleBuilder(defaultBuilderArgs);\n const customDatasourceConfig: ContextModuleDatasourceConfig = {};\n\n const res = contextModuleBuilder\n .setDatasourceConfig(customDatasourceConfig)\n .build();\n const config = (res as DefaultContextModule)[\n \"_container\"\n ].get<ContextModuleConfig>(configTypes.Config);\n\n expect(res).toBeInstanceOf(DefaultContextModule);\n expect(config.datasource).toEqual(customDatasourceConfig);\n expect(config.datasource?.proxy).toBeUndefined();\n });\n });\n});\n"],
5
- "mappings": "aAEA,IAAAA,EAA4B,mCAS5BC,EAAqC,kCACrCC,EAAqC,kCAErC,SAAS,uBAAwB,IAAM,CACrC,MAAMC,EAA2C,CAC/C,IAAK,iBACL,KAAM,OACN,OAAQ,MACV,EACMC,EAA0B,CAC9B,IAAK,uBACP,EACMC,EAAmD,CACvD,YAAa,MACf,EAEA,WAAW,IAAM,CACf,GAAG,cAAc,CACnB,CAAC,EAED,GAAG,yCAA0C,IAAM,CAGjD,MAAMC,EAFuB,IAAI,uBAAqBD,CAAkB,EAEvC,MAAM,EAEvC,OAAOC,CAAG,EAAE,eAAe,sBAAoB,CACjD,CAAC,EAED,GAAG,wCAAyC,IAAM,CAChD,MAAMC,EAAuB,IAAI,uBAAqBF,CAAkB,EAClEG,EAA8B,CAClC,KAAM,GAAG,GAAG,EACZ,UAAW,GAAG,GAAG,CACnB,EAEMF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AqBF,CAAkB,EAClEQ,EAAwD,CAC5D,MAAO,MACT,EAKMJ,EAHMF,EACT,oBAAoBM,CAAsB,EAC1C,MAAM,EAEP,WACA,IAAyB,cAAY,MAAM,EAE7C,OAAOJ,EAAO,YAAY,KAAK,EAAE,KAAK,MAAM,EAC5C,OAAOA,EAAO,UAAU,EAAE,IAAI,cAAc,CAC9C,CAAC,EAED,GAAG,+CAAgD,IAAM,CACvD,MAAMF,EAAuB,IAAI,uBAAqBF,CAAkB,EAClEQ,EAAwD,CAAC,EAEzDP,EAAMC,EACT,oBAAoBM,CAAsB,EAC1C,MAAM,EACHJ,EAAUH,EACd,WACA,IAAyB,cAAY,MAAM,EAE7C,OAAOA,CAAG,EAAE,eAAe,sBAAoB,EAC/C,OAAOG,EAAO,UAAU,EAAE,QAAQI,CAAsB,EACxD,OAAOJ,EAAO,YAAY,KAAK,EAAE,cAAc,CACjD,CAAC,CACH,CAAC,CACH,CAAC",
6
- "names": ["import_configTypes", "import_ContextModuleBuilder", "import_DefaultContextModule", "defaultCalConfig", "defaultWeb3ChecksConfig", "defaultBuilderArgs", "res", "contextModuleBuilder", "customLoader", "config", "customMetadataConfig", "customCalConfig", "customWeb3ChecksConfig", "customDatasourceConfig"]
4
+ "sourcesContent": ["import { type LoggerPublisherService } from \"@ledgerhq/device-management-kit\";\nimport { type Container } from \"inversify\";\n\nimport { configTypes } from \"./config/di/configTypes\";\nimport { type ContextModuleConstructorArgs } from \"./config/model/ContextModuleBuildArgs\";\nimport {\n type ContextModuleCalConfig,\n type ContextModuleConfig,\n type ContextModuleDatasourceConfig,\n type ContextModuleMetadataServiceConfig,\n} from \"./config/model/ContextModuleConfig\";\nimport { type ContextLoader } from \"./shared/domain/ContextLoader\";\nimport { HttpTrustedNameDataSource } from \"./trusted-name/data/HttpTrustedNameDataSource\";\nimport { type TrustedNameDataSource } from \"./trusted-name/data/TrustedNameDataSource\";\nimport { trustedNameTypes } from \"./trusted-name/di/trustedNameTypes\";\nimport { ContextModuleBuilder } from \"./ContextModuleBuilder\";\nimport { DefaultContextModule } from \"./DefaultContextModule\";\n\ndescribe(\"ContextModuleBuilder\", () => {\n const defaultCalConfig: ContextModuleCalConfig = {\n url: \"https://cal/v1\",\n mode: \"prod\",\n branch: \"main\",\n };\n const defaultWeb3ChecksConfig = {\n url: \"https://web3checks/v1\",\n };\n const mockLoggerFactory = () => ({\n debug: vi.fn(),\n info: vi.fn(),\n warn: vi.fn(),\n error: vi.fn(),\n subscribers: [],\n });\n\n const defaultBuilderArgs: ContextModuleConstructorArgs = {\n originToken: \"test\",\n loggerFactory: mockLoggerFactory,\n };\n\n beforeEach(() => {\n vi.resetAllMocks();\n });\n\n it(\"should return a default context module\", () => {\n const contextModuleBuilder = new ContextModuleBuilder(defaultBuilderArgs);\n\n const res = contextModuleBuilder.build();\n\n expect(res).toBeInstanceOf(DefaultContextModule);\n });\n\n it(\"should return a custom context module\", () => {\n const contextModuleBuilder = new ContextModuleBuilder(defaultBuilderArgs);\n const customLoader: ContextLoader = {\n load: vi.fn(),\n canHandle: vi.fn() as unknown as ContextLoader[\"canHandle\"],\n };\n\n const res = contextModuleBuilder\n .removeDefaultLoaders()\n .addLoader(customLoader)\n .build();\n\n expect(res).toBeInstanceOf(DefaultContextModule);\n });\n\n it(\"should return a custom context module with a custom typed data loader\", () => {\n const contextModuleBuilder = new ContextModuleBuilder(defaultBuilderArgs);\n const customLoader = { load: vi.fn() };\n\n const res = contextModuleBuilder\n .removeDefaultLoaders()\n .addTypedDataLoader(customLoader)\n .build();\n\n expect(res).toBeInstanceOf(DefaultContextModule);\n // @ts-expect-error _typedDataLoader is private\n expect(res[\"_typedDataLoader\"]).toBe(customLoader);\n });\n\n it(\"should return a custom context module with a custom config\", () => {\n const contextModuleBuilder = new ContextModuleBuilder(defaultBuilderArgs);\n\n const res = contextModuleBuilder\n .setCalConfig(defaultCalConfig)\n .setWeb3ChecksConfig(defaultWeb3ChecksConfig)\n .build();\n // @ts-expect-error _container is private\n const config = (res[\"_container\"] as Container).get<ContextModuleConfig>(\n configTypes.Config,\n );\n\n expect(res).toBeInstanceOf(DefaultContextModule);\n expect(config.cal).toEqual(defaultCalConfig);\n expect(config.web3checks).toEqual(defaultWeb3ChecksConfig);\n });\n\n it(\"should not throw an error if origin token is provided\", () => {\n const contextModuleBuilder = new ContextModuleBuilder(defaultBuilderArgs);\n\n expect(() => contextModuleBuilder.build()).not.toThrow();\n });\n\n describe(\"setMetadataServiceConfig\", () => {\n it(\"should set the metadata service configuration\", () => {\n const contextModuleBuilder = new ContextModuleBuilder(defaultBuilderArgs);\n const customMetadataConfig: ContextModuleMetadataServiceConfig = {\n url: \"https://custom-metadata-service.com/v3\",\n };\n\n const res = contextModuleBuilder\n .setMetadataServiceConfig(customMetadataConfig)\n .build();\n const config = (res as DefaultContextModule)[\n \"_container\"\n ].get<ContextModuleConfig>(configTypes.Config);\n\n expect(res).toBeInstanceOf(DefaultContextModule);\n expect(config.metadataServiceDomain).toEqual(customMetadataConfig);\n });\n\n it(\"should override the default metadata service configuration\", () => {\n const contextModuleBuilder = new ContextModuleBuilder(defaultBuilderArgs);\n const customMetadataConfig: ContextModuleMetadataServiceConfig = {\n url: \"https://override-metadata-service.com/v1\",\n };\n\n const res = contextModuleBuilder\n .setMetadataServiceConfig(customMetadataConfig)\n .build();\n const config = (res as DefaultContextModule)[\n \"_container\"\n ].get<ContextModuleConfig>(configTypes.Config);\n\n expect(config.metadataServiceDomain.url).toBe(customMetadataConfig.url);\n expect(config.metadataServiceDomain.url).not.toBe(\n \"https://nft.api.live.ledger.com/v2\",\n );\n });\n });\n\n describe(\"setCalConfig\", () => {\n it(\"should set the CAL configuration\", () => {\n const contextModuleBuilder = new ContextModuleBuilder(defaultBuilderArgs);\n const customCalConfig: ContextModuleCalConfig = {\n url: \"https://custom-cal-service.com/v2\",\n mode: \"test\",\n branch: \"next\",\n };\n\n const res = contextModuleBuilder.setCalConfig(customCalConfig).build();\n const config = (res as DefaultContextModule)[\n \"_container\"\n ].get<ContextModuleConfig>(configTypes.Config);\n\n expect(res).toBeInstanceOf(DefaultContextModule);\n expect(config.cal).toEqual(customCalConfig);\n });\n\n it(\"should override the default CAL configuration\", () => {\n const contextModuleBuilder = new ContextModuleBuilder(defaultBuilderArgs);\n const customCalConfig: ContextModuleCalConfig = {\n url: \"https://override-cal-service.com/v1\",\n mode: \"prod\",\n branch: \"demo\",\n };\n\n const res = contextModuleBuilder.setCalConfig(customCalConfig).build();\n const config = (res as DefaultContextModule)[\n \"_container\"\n ].get<ContextModuleConfig>(configTypes.Config);\n\n expect(config.cal.url).toBe(customCalConfig.url);\n expect(config.cal.mode).toBe(customCalConfig.mode);\n expect(config.cal.branch).toBe(customCalConfig.branch);\n expect(config.cal.url).not.toBe(\n \"https://crypto-assets-service.api.ledger.com/v1\",\n );\n });\n });\n\n describe(\"setWeb3ChecksConfig\", () => {\n it(\"should set the web3 checks configuration\", () => {\n const contextModuleBuilder = new ContextModuleBuilder(defaultBuilderArgs);\n const customWeb3ChecksConfig = {\n url: \"https://custom-web3checks-service.com/v4\",\n };\n\n const res = contextModuleBuilder\n .setWeb3ChecksConfig(customWeb3ChecksConfig)\n .build();\n const config = (res as DefaultContextModule)[\n \"_container\"\n ].get<ContextModuleConfig>(configTypes.Config);\n\n expect(res).toBeInstanceOf(DefaultContextModule);\n expect(config.web3checks).toEqual(customWeb3ChecksConfig);\n });\n\n it(\"should override the default web3 checks configuration\", () => {\n const contextModuleBuilder = new ContextModuleBuilder(defaultBuilderArgs);\n const customWeb3ChecksConfig = {\n url: \"https://override-web3checks-service.com/v2\",\n };\n\n const res = contextModuleBuilder\n .setWeb3ChecksConfig(customWeb3ChecksConfig)\n .build();\n const config = (res as DefaultContextModule)[\n \"_container\"\n ].get<ContextModuleConfig>(configTypes.Config);\n\n expect(config.web3checks.url).toBe(customWeb3ChecksConfig.url);\n expect(config.web3checks.url).not.toBe(\n \"https://web3checks-backend.api.ledger.com/v3\",\n );\n });\n });\n\n describe(\"setDatasourceConfig\", () => {\n it(\"should set the datasource configuration with safe proxy\", () => {\n const contextModuleBuilder = new ContextModuleBuilder(defaultBuilderArgs);\n const customDatasourceConfig: ContextModuleDatasourceConfig = {\n proxy: \"safe\",\n };\n\n const res = contextModuleBuilder\n .setDatasourceConfig(customDatasourceConfig)\n .build();\n const config = (res as DefaultContextModule)[\n \"_container\"\n ].get<ContextModuleConfig>(configTypes.Config);\n\n expect(res).toBeInstanceOf(DefaultContextModule);\n expect(config.datasource).toEqual(customDatasourceConfig);\n expect(config.datasource?.proxy).toBe(\"safe\");\n });\n\n it(\"should set the datasource configuration with default proxy\", () => {\n const contextModuleBuilder = new ContextModuleBuilder(defaultBuilderArgs);\n const customDatasourceConfig: ContextModuleDatasourceConfig = {\n proxy: \"default\",\n };\n\n const res = contextModuleBuilder\n .setDatasourceConfig(customDatasourceConfig)\n .build();\n const config = (res as DefaultContextModule)[\n \"_container\"\n ].get<ContextModuleConfig>(configTypes.Config);\n\n expect(res).toBeInstanceOf(DefaultContextModule);\n expect(config.datasource).toEqual(customDatasourceConfig);\n expect(config.datasource?.proxy).toBe(\"default\");\n });\n\n it(\"should override the default datasource configuration\", () => {\n const contextModuleBuilder = new ContextModuleBuilder(defaultBuilderArgs);\n const customDatasourceConfig: ContextModuleDatasourceConfig = {\n proxy: \"safe\",\n };\n\n const res = contextModuleBuilder\n .setDatasourceConfig(customDatasourceConfig)\n .build();\n const config = (res as DefaultContextModule)[\n \"_container\"\n ].get<ContextModuleConfig>(configTypes.Config);\n\n expect(config.datasource?.proxy).toBe(\"safe\");\n expect(config.datasource).not.toBeUndefined();\n });\n\n it(\"should set an empty datasource configuration\", () => {\n const contextModuleBuilder = new ContextModuleBuilder(defaultBuilderArgs);\n const customDatasourceConfig: ContextModuleDatasourceConfig = {};\n\n const res = contextModuleBuilder\n .setDatasourceConfig(customDatasourceConfig)\n .build();\n const config = (res as DefaultContextModule)[\n \"_container\"\n ].get<ContextModuleConfig>(configTypes.Config);\n\n expect(res).toBeInstanceOf(DefaultContextModule);\n expect(config.datasource).toEqual(customDatasourceConfig);\n expect(config.datasource?.proxy).toBeUndefined();\n });\n });\n\n describe(\"loggerFactory\", () => {\n it(\"should set the loggerFactory when provided in the constructor\", () => {\n const loggerFactory: (tag: string) => LoggerPublisherService = vi.fn();\n\n const contextModuleBuilder = new ContextModuleBuilder({\n ...defaultBuilderArgs,\n loggerFactory,\n });\n\n const res = contextModuleBuilder.build();\n const config = (res as DefaultContextModule)[\n \"_container\"\n ].get<ContextModuleConfig>(configTypes.Config);\n\n expect(res).toBeInstanceOf(DefaultContextModule);\n expect(config.loggerFactory).toBe(loggerFactory);\n });\n\n it(\"should set the loggerFactory via setLoggerFactory\", () => {\n const loggerFactory: (tag: string) => LoggerPublisherService = vi.fn();\n\n const contextModuleBuilder = new ContextModuleBuilder(defaultBuilderArgs);\n\n const res = contextModuleBuilder.setLoggerFactory(loggerFactory).build();\n const config = (res as DefaultContextModule)[\n \"_container\"\n ].get<ContextModuleConfig>(configTypes.Config);\n\n expect(res).toBeInstanceOf(DefaultContextModule);\n expect(config.loggerFactory).toBe(loggerFactory);\n });\n\n it(\"should override constructor loggerFactory with setLoggerFactory\", () => {\n const constructorLoggerFactory: (tag: string) => LoggerPublisherService =\n vi.fn();\n const overrideLoggerFactory: (tag: string) => LoggerPublisherService =\n vi.fn();\n\n const contextModuleBuilder = new ContextModuleBuilder({\n ...defaultBuilderArgs,\n loggerFactory: constructorLoggerFactory,\n });\n\n const res = contextModuleBuilder\n .setLoggerFactory(overrideLoggerFactory)\n .build();\n const config = (res as DefaultContextModule)[\n \"_container\"\n ].get<ContextModuleConfig>(configTypes.Config);\n\n expect(config.loggerFactory).toBe(overrideLoggerFactory);\n expect(config.loggerFactory).not.toBe(constructorLoggerFactory);\n });\n });\n\n describe(\"setTrustedNameDataSource\", () => {\n it(\"should set a custom trusted name data source\", () => {\n const contextModuleBuilder = new ContextModuleBuilder(defaultBuilderArgs);\n const customDataSource: TrustedNameDataSource = {\n getDomainNamePayload: vi.fn(),\n getTrustedNamePayload: vi.fn(),\n };\n\n const res = contextModuleBuilder\n .setTrustedNameDataSource(customDataSource)\n .build();\n const config = (res as DefaultContextModule)[\n \"_container\"\n ].get<ContextModuleConfig>(configTypes.Config);\n\n expect(res).toBeInstanceOf(DefaultContextModule);\n expect(config.customTrustedNameDataSource).toBe(customDataSource);\n });\n\n it(\"should inject the custom data source into the container\", () => {\n const contextModuleBuilder = new ContextModuleBuilder(defaultBuilderArgs);\n const customDataSource: TrustedNameDataSource = {\n getDomainNamePayload: vi.fn(),\n getTrustedNamePayload: vi.fn(),\n };\n\n const res = contextModuleBuilder\n .setTrustedNameDataSource(customDataSource)\n .build();\n const injectedDataSource = (res as DefaultContextModule)[\n \"_container\"\n ].get<TrustedNameDataSource>(trustedNameTypes.TrustedNameDataSource);\n\n expect(injectedDataSource).toBe(customDataSource);\n });\n\n it(\"should use HttpTrustedNameDataSource when no custom data source is set\", () => {\n const contextModuleBuilder = new ContextModuleBuilder(defaultBuilderArgs);\n\n const res = contextModuleBuilder.build();\n const injectedDataSource = (res as DefaultContextModule)[\n \"_container\"\n ].get<TrustedNameDataSource>(trustedNameTypes.TrustedNameDataSource);\n\n expect(res).toBeInstanceOf(DefaultContextModule);\n expect(injectedDataSource).toBeInstanceOf(HttpTrustedNameDataSource);\n });\n });\n});\n"],
5
+ "mappings": "aAGA,IAAAA,EAA4B,mCAS5BC,EAA0C,yDAE1CC,EAAiC,8CACjCC,EAAqC,kCACrCC,EAAqC,kCAErC,SAAS,uBAAwB,IAAM,CACrC,MAAMC,EAA2C,CAC/C,IAAK,iBACL,KAAM,OACN,OAAQ,MACV,EACMC,EAA0B,CAC9B,IAAK,uBACP,EASMC,EAAmD,CACvD,YAAa,OACb,cAVwB,KAAO,CAC/B,MAAO,GAAG,GAAG,EACb,KAAM,GAAG,GAAG,EACZ,KAAM,GAAG,GAAG,EACZ,MAAO,GAAG,GAAG,EACb,YAAa,CAAC,CAChB,EAKA,EAEA,WAAW,I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EAA0E,IAAM,CAGjF,MAAMX,EAFuB,IAAI,uBAAqBD,CAAkB,EAEvC,MAAM,EACjCa,EAAsBZ,EAC1B,WACA,IAA2B,mBAAiB,qBAAqB,EAEnE,OAAOA,CAAG,EAAE,eAAe,sBAAoB,EAC/C,OAAOY,CAAkB,EAAE,eAAe,2BAAyB,CACrE,CAAC,CACH,CAAC,CACH,CAAC",
6
+ "names": ["import_configTypes", "import_HttpTrustedNameDataSource", "import_trustedNameTypes", "import_ContextModuleBuilder", "import_DefaultContextModule", "defaultCalConfig", "defaultWeb3ChecksConfig", "defaultBuilderArgs", "res", "contextModuleBuilder", "customLoader", "config", "customMetadataConfig", "customCalConfig", "customWeb3ChecksConfig", "customDatasourceConfig", "loggerFactory", "constructorLoggerFactory", "overrideLoggerFactory", "customDataSource", "injectedDataSource"]
7
7
  }
@@ -1,2 +1,2 @@
1
- "use strict";var o=require("./shared/model/ClearSignContext"),l=require("./DefaultContextModule");const u=i=>({load:vi.fn(),canHandle:vi.fn().mockReturnValue(i)}),r=()=>({canHandle:vi.fn(),loadField:vi.fn()});describe("DefaultContextModule",()=>{const i={load:vi.fn()},d={customLoaders:[],defaultLoaders:!1,defaultFieldLoaders:!1,customFieldLoaders:[],customTypedDataLoader:i,cal:{url:"https://cal/v1",mode:"prod",branch:"main"},web3checks:{url:"https://web3checks/v3"},metadataServiceDomain:{url:"https://metadata.com"},originToken:"originToken"};beforeEach(()=>{vi.restoreAllMocks()}),it("should initialize the context module with all the default loaders",async()=>{const t=await new l.DefaultContextModule(d).getContexts({});expect(t).toEqual([])}),it("should return an empty array when no loaders",async()=>{const t=await new l.DefaultContextModule(d).getContexts({});expect(t).toEqual([])}),it("should call all fetch method from metadata fetcher",async()=>{const e=u(!0);await new l.DefaultContextModule({...d,customLoaders:[e,e]}).getContexts({}),expect(e.canHandle).toHaveBeenCalledTimes(2),expect(e.load).toHaveBeenCalledTimes(2)}),it("should return an array of context response",async()=>{const e=u(!0),t=[[{type:"provideERC20Info",payload:"payload1"}],[{type:"provideERC20Info",payload:"payload2"},{type:"plugin",payload:"payload3"}]];vi.spyOn(e,"load").mockResolvedValueOnce(t[0]).mockResolvedValueOnce(t[1]);const a=await new l.DefaultContextModule({...d,customLoaders:[e,e]}).getContexts({});expect(e.canHandle).toHaveBeenCalledTimes(2),expect(e.load).toHaveBeenCalledTimes(2),expect(a).toEqual(t.flat())}),it("should only call loaders that can handle the input",async()=>{const e=u(!0),t=u(!0);vi.spyOn(e,"canHandle").mockReturnValue(!0),vi.spyOn(t,"canHandle").mockReturnValue(!1),vi.spyOn(e,"load").mockResolvedValue([{type:o.ClearSignContextType.TOKEN,payload:"payload1"}]),vi.spyOn(t,"load").mockResolvedValue([{type:o.ClearSignContextType.NFT,payload:"payload2"}]);const n=new l.DefaultContextModule({...d,customLoaders:[e,t]}),a={to:"0x123",selector:"0xabc"},s=await n.getContexts(a);expect(e.canHandle).toHaveBeenCalledWith(a,Object.values(o.ClearSignContextType)),expect(t.canHandle).toHaveBeenCalledWith(a,Object.values(o.ClearSignContextType)),expect(e.load).toHaveBeenCalledWith(a),expect(t.load).not.toHaveBeenCalled(),expect(s).toEqual([{type:"token",payload:"payload1"}])}),it("should use expected types if provided",async()=>{const e=u(!0);vi.spyOn(e,"canHandle").mockReturnValue(!0),vi.spyOn(e,"load").mockResolvedValue([{type:o.ClearSignContextType.TOKEN,payload:"payload1"}]);const t=new l.DefaultContextModule({...d,customLoaders:[e]}),n={to:"0x123",selector:"0xabc"};await t.getContexts(n,[o.ClearSignContextType.TOKEN]),expect(e.canHandle).toHaveBeenCalledWith(n,[o.ClearSignContextType.TOKEN])}),it("should call the typed data loader",async()=>{await new l.DefaultContextModule({...d,customTypedDataLoader:i}).getTypedDataFilters({}),expect(i.load).toHaveBeenCalledTimes(1)}),describe("getFieldContext",()=>{it("should return error when no loader can handle the field",async()=>{const e=r();vi.spyOn(e,"canHandle").mockReturnValue(!1);const t=new l.DefaultContextModule({...d,customFieldLoaders:[e]}),n={type:"unknown"},a=await t.getFieldContext(n,o.ClearSignContextType.TOKEN);expect(e.canHandle).toHaveBeenCalledWith(n,o.ClearSignContextType.TOKEN),expect(e.loadField).not.toHaveBeenCalled(),expect(a).toEqual({type:o.ClearSignContextType.ERROR,error:new Error(`Loader not found for field: ${n} and expected type: ${o.ClearSignContextType.TOKEN}`)})}),it("should return context when a loader can handle the field",async()=>{const e=r(),t={type:o.ClearSignContextType.TOKEN,payload:"test-payload"};vi.spyOn(e,"canHandle").mockReturnValue(!0),vi.spyOn(e,"loadField").mockResolvedValue(t);const n=new l.DefaultContextModule({...d,customFieldLoaders:[e]}),a={type:"token",address:"0x123"},s=await n.getFieldContext(a,o.ClearSignContextType.TOKEN);expect(e.canHandle).toHaveBeenCalledWith(a,o.ClearSignContextType.TOKEN),expect(e.loadField).toHaveBeenCalledWith(a),expect(s).toEqual(t)}),it("should return first context when multiple loaders can handle the field",async()=>{const e=r(),t=r(),n={type:o.ClearSignContextType.TOKEN,payload:"first-payload"},a={type:o.ClearSignContextType.NFT,payload:"second-payload"};vi.spyOn(e,"canHandle").mockReturnValue(!0),vi.spyOn(t,"canHandle").mockReturnValue(!0),vi.spyOn(e,"loadField").mockResolvedValue(n),vi.spyOn(t,"loadField").mockResolvedValue(a);const s=new l.DefaultContextModule({...d,customFieldLoaders:[e,t]}),c={type:"multi",address:"0x123"},p=await s.getFieldContext(c,o.ClearSignContextType.TOKEN);expect(e.canHandle).toHaveBeenCalledWith(c,o.ClearSignContextType.TOKEN),expect(t.canHandle).toHaveBeenCalledWith(c,o.ClearSignContextType.TOKEN),expect(e.loadField).toHaveBeenCalledWith(c),expect(t.loadField).not.toHaveBeenCalled(),expect(p).toEqual(n)}),it("should return second context when first context is an error",async()=>{const e=r(),t=r(),n={type:o.ClearSignContextType.ERROR,error:new Error("first-error")},a={type:o.ClearSignContextType.TOKEN,payload:"second-payload"};vi.spyOn(e,"canHandle").mockReturnValue(!0),vi.spyOn(t,"canHandle").mockReturnValue(!0),vi.spyOn(e,"loadField").mockResolvedValue(n),vi.spyOn(t,"loadField").mockResolvedValue(a);const s=new l.DefaultContextModule({...d,customFieldLoaders:[e,t]}),c={type:"error",address:"0x123"},p=await s.getFieldContext(c,o.ClearSignContextType.TOKEN);expect(e.canHandle).toHaveBeenCalledWith(c,o.ClearSignContextType.TOKEN),expect(t.canHandle).toHaveBeenCalledWith(c,o.ClearSignContextType.TOKEN),expect(e.loadField).toHaveBeenCalledWith(c),expect(t.loadField).toHaveBeenCalledWith(c),expect(p).toEqual(a)}),it("should handle loader rejection gracefully",async()=>{const e=r(),t=new Error("Load field failed");vi.spyOn(e,"canHandle").mockReturnValue(!0),vi.spyOn(e,"loadField").mockRejectedValue(t);const n=new l.DefaultContextModule({...d,customFieldLoaders:[e]}),a={type:"error",address:"0x123"};await expect(n.getFieldContext(a,o.ClearSignContextType.TOKEN)).rejects.toThrow("Load field failed"),expect(e.canHandle).toHaveBeenCalledWith(a,o.ClearSignContextType.TOKEN),expect(e.loadField).toHaveBeenCalledWith(a)})})});
1
+ "use strict";var o=require("./shared/model/ClearSignContext"),l=require("./DefaultContextModule");const x=()=>({debug:vi.fn(),info:vi.fn(),warn:vi.fn(),error:vi.fn(),subscribers:[]}),u=i=>({load:vi.fn(),canHandle:vi.fn().mockReturnValue(i)}),r=()=>({canHandle:vi.fn(),loadField:vi.fn()});describe("DefaultContextModule",()=>{const i={load:vi.fn()},d={customLoaders:[],defaultLoaders:!1,defaultFieldLoaders:!1,customFieldLoaders:[],customTypedDataLoader:i,cal:{url:"https://cal/v1",mode:"prod",branch:"main"},web3checks:{url:"https://web3checks/v3"},metadataServiceDomain:{url:"https://metadata.com"},originToken:"originToken",loggerFactory:x};beforeEach(()=>{vi.restoreAllMocks()}),it("should initialize the context module with all the default loaders",async()=>{const t=await new l.DefaultContextModule(d).getContexts({});expect(t).toEqual([])}),it("should return an empty array when no loaders",async()=>{const t=await new l.DefaultContextModule(d).getContexts({});expect(t).toEqual([])}),it("should call all fetch method from metadata fetcher",async()=>{const e=u(!0);await new l.DefaultContextModule({...d,customLoaders:[e,e]}).getContexts({}),expect(e.canHandle).toHaveBeenCalledTimes(2),expect(e.load).toHaveBeenCalledTimes(2)}),it("should return an array of context response",async()=>{const e=u(!0),t=[[{type:"provideERC20Info",payload:"payload1"}],[{type:"provideERC20Info",payload:"payload2"},{type:"plugin",payload:"payload3"}]];vi.spyOn(e,"load").mockResolvedValueOnce(t[0]).mockResolvedValueOnce(t[1]);const a=await new l.DefaultContextModule({...d,customLoaders:[e,e]}).getContexts({});expect(e.canHandle).toHaveBeenCalledTimes(2),expect(e.load).toHaveBeenCalledTimes(2),expect(a).toEqual(t.flat())}),it("should only call loaders that can handle the input",async()=>{const e=u(!0),t=u(!0);vi.spyOn(e,"canHandle").mockReturnValue(!0),vi.spyOn(t,"canHandle").mockReturnValue(!1),vi.spyOn(e,"load").mockResolvedValue([{type:o.ClearSignContextType.TOKEN,payload:"payload1"}]),vi.spyOn(t,"load").mockResolvedValue([{type:o.ClearSignContextType.NFT,payload:"payload2"}]);const n=new l.DefaultContextModule({...d,customLoaders:[e,t]}),a={to:"0x123",selector:"0xabc"},s=await n.getContexts(a);expect(e.canHandle).toHaveBeenCalledWith(a,Object.values(o.ClearSignContextType)),expect(t.canHandle).toHaveBeenCalledWith(a,Object.values(o.ClearSignContextType)),expect(e.load).toHaveBeenCalledWith(a),expect(t.load).not.toHaveBeenCalled(),expect(s).toEqual([{type:"token",payload:"payload1"}])}),it("should use expected types if provided",async()=>{const e=u(!0);vi.spyOn(e,"canHandle").mockReturnValue(!0),vi.spyOn(e,"load").mockResolvedValue([{type:o.ClearSignContextType.TOKEN,payload:"payload1"}]);const t=new l.DefaultContextModule({...d,customLoaders:[e]}),n={to:"0x123",selector:"0xabc"};await t.getContexts(n,[o.ClearSignContextType.TOKEN]),expect(e.canHandle).toHaveBeenCalledWith(n,[o.ClearSignContextType.TOKEN])}),it("should call the typed data loader",async()=>{await new l.DefaultContextModule({...d,customTypedDataLoader:i}).getTypedDataFilters({}),expect(i.load).toHaveBeenCalledTimes(1)}),describe("getFieldContext",()=>{it("should return error when no loader can handle the field",async()=>{const e=r();vi.spyOn(e,"canHandle").mockReturnValue(!1);const t=new l.DefaultContextModule({...d,customFieldLoaders:[e]}),n={type:"unknown"},a=await t.getFieldContext(n,o.ClearSignContextType.TOKEN);expect(e.canHandle).toHaveBeenCalledWith(n,o.ClearSignContextType.TOKEN),expect(e.loadField).not.toHaveBeenCalled(),expect(a).toEqual({type:o.ClearSignContextType.ERROR,error:new Error(`Loader not found for field: ${n} and expected type: ${o.ClearSignContextType.TOKEN}`)})}),it("should return context when a loader can handle the field",async()=>{const e=r(),t={type:o.ClearSignContextType.TOKEN,payload:"test-payload"};vi.spyOn(e,"canHandle").mockReturnValue(!0),vi.spyOn(e,"loadField").mockResolvedValue(t);const n=new l.DefaultContextModule({...d,customFieldLoaders:[e]}),a={type:"token",address:"0x123"},s=await n.getFieldContext(a,o.ClearSignContextType.TOKEN);expect(e.canHandle).toHaveBeenCalledWith(a,o.ClearSignContextType.TOKEN),expect(e.loadField).toHaveBeenCalledWith(a),expect(s).toEqual(t)}),it("should return first context when multiple loaders can handle the field",async()=>{const e=r(),t=r(),n={type:o.ClearSignContextType.TOKEN,payload:"first-payload"},a={type:o.ClearSignContextType.NFT,payload:"second-payload"};vi.spyOn(e,"canHandle").mockReturnValue(!0),vi.spyOn(t,"canHandle").mockReturnValue(!0),vi.spyOn(e,"loadField").mockResolvedValue(n),vi.spyOn(t,"loadField").mockResolvedValue(a);const s=new l.DefaultContextModule({...d,customFieldLoaders:[e,t]}),c={type:"multi",address:"0x123"},p=await s.getFieldContext(c,o.ClearSignContextType.TOKEN);expect(e.canHandle).toHaveBeenCalledWith(c,o.ClearSignContextType.TOKEN),expect(t.canHandle).toHaveBeenCalledWith(c,o.ClearSignContextType.TOKEN),expect(e.loadField).toHaveBeenCalledWith(c),expect(t.loadField).not.toHaveBeenCalled(),expect(p).toEqual(n)}),it("should return second context when first context is an error",async()=>{const e=r(),t=r(),n={type:o.ClearSignContextType.ERROR,error:new Error("first-error")},a={type:o.ClearSignContextType.TOKEN,payload:"second-payload"};vi.spyOn(e,"canHandle").mockReturnValue(!0),vi.spyOn(t,"canHandle").mockReturnValue(!0),vi.spyOn(e,"loadField").mockResolvedValue(n),vi.spyOn(t,"loadField").mockResolvedValue(a);const s=new l.DefaultContextModule({...d,customFieldLoaders:[e,t]}),c={type:"error",address:"0x123"},p=await s.getFieldContext(c,o.ClearSignContextType.TOKEN);expect(e.canHandle).toHaveBeenCalledWith(c,o.ClearSignContextType.TOKEN),expect(t.canHandle).toHaveBeenCalledWith(c,o.ClearSignContextType.TOKEN),expect(e.loadField).toHaveBeenCalledWith(c),expect(t.loadField).toHaveBeenCalledWith(c),expect(p).toEqual(a)}),it("should handle loader rejection gracefully",async()=>{const e=r(),t=new Error("Load field failed");vi.spyOn(e,"canHandle").mockReturnValue(!0),vi.spyOn(e,"loadField").mockRejectedValue(t);const n=new l.DefaultContextModule({...d,customFieldLoaders:[e]}),a={type:"error",address:"0x123"};await expect(n.getFieldContext(a,o.ClearSignContextType.TOKEN)).rejects.toThrow("Load field failed"),expect(e.canHandle).toHaveBeenCalledWith(a,o.ClearSignContextType.TOKEN),expect(e.loadField).toHaveBeenCalledWith(a)})})});
2
2
  //# sourceMappingURL=DefaultContextModule.test.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../src/DefaultContextModule.test.ts"],
4
- "sourcesContent": ["import { type ContextModuleConfig } from \"./config/model/ContextModuleConfig\";\nimport { type ContextFieldLoader } from \"./shared/domain/ContextFieldLoader\";\nimport { type ContextLoader } from \"./shared/domain/ContextLoader\";\nimport {\n type ClearSignContext,\n ClearSignContextType,\n} from \"./shared/model/ClearSignContext\";\nimport { type TypedDataContext } from \"./shared/model/TypedDataContext\";\nimport type { TypedDataContextLoader } from \"./typed-data/domain/TypedDataContextLoader\";\nimport { DefaultContextModule } from \"./DefaultContextModule\";\n\nconst contextLoaderStubBuilder = (canHandle: boolean): ContextLoader => {\n return {\n load: vi.fn(),\n canHandle: vi\n .fn()\n .mockReturnValue(canHandle) as unknown as ContextLoader[\"canHandle\"],\n };\n};\n\nconst fieldLoaderStubBuilder = (): ContextFieldLoader => {\n return {\n canHandle: vi.fn() as unknown as ContextFieldLoader[\"canHandle\"],\n loadField: vi.fn(),\n };\n};\n\ndescribe(\"DefaultContextModule\", () => {\n const typedDataLoader: TypedDataContextLoader = { load: vi.fn() };\n const defaultContextModuleConfig: ContextModuleConfig = {\n customLoaders: [],\n defaultLoaders: false,\n defaultFieldLoaders: false,\n customFieldLoaders: [],\n customTypedDataLoader: typedDataLoader,\n cal: {\n url: \"https://cal/v1\",\n mode: \"prod\",\n branch: \"main\",\n },\n web3checks: {\n url: \"https://web3checks/v3\",\n },\n metadataServiceDomain: {\n url: \"https://metadata.com\",\n },\n originToken: \"originToken\",\n };\n\n beforeEach(() => {\n vi.restoreAllMocks();\n });\n\n it(\"should initialize the context module with all the default loaders\", async () => {\n const contextModule = new DefaultContextModule(defaultContextModuleConfig);\n\n const res = await contextModule.getContexts({});\n\n expect(res).toEqual([]);\n });\n\n it(\"should return an empty array when no loaders\", async () => {\n const contextModule = new DefaultContextModule(defaultContextModuleConfig);\n\n const res = await contextModule.getContexts({});\n\n expect(res).toEqual([]);\n });\n\n it(\"should call all fetch method from metadata fetcher\", async () => {\n const loader = contextLoaderStubBuilder(true);\n const contextModule = new DefaultContextModule({\n ...defaultContextModuleConfig,\n customLoaders: [loader, loader],\n });\n\n await contextModule.getContexts({});\n\n expect(loader.canHandle).toHaveBeenCalledTimes(2);\n expect(loader.load).toHaveBeenCalledTimes(2);\n });\n\n it(\"should return an array of context response\", async () => {\n const loader = contextLoaderStubBuilder(true);\n const responses = [\n [{ type: \"provideERC20Info\", payload: \"payload1\" }],\n [\n { type: \"provideERC20Info\", payload: \"payload2\" },\n { type: \"plugin\", payload: \"payload3\" },\n ],\n ] as ClearSignContext[][];\n vi.spyOn(loader, \"load\")\n .mockResolvedValueOnce(responses[0]!)\n .mockResolvedValueOnce(responses[1]!);\n const contextModule = new DefaultContextModule({\n ...defaultContextModuleConfig,\n customLoaders: [loader, loader],\n });\n\n const res = await contextModule.getContexts({});\n\n expect(loader.canHandle).toHaveBeenCalledTimes(2);\n expect(loader.load).toHaveBeenCalledTimes(2);\n expect(res).toEqual(responses.flat());\n });\n\n it(\"should only call loaders that can handle the input\", async () => {\n const loader1 = contextLoaderStubBuilder(true);\n const loader2 = contextLoaderStubBuilder(true);\n\n vi.spyOn(loader1, \"canHandle\").mockReturnValue(true);\n vi.spyOn(loader2, \"canHandle\").mockReturnValue(false);\n vi.spyOn(loader1, \"load\").mockResolvedValue([\n { type: ClearSignContextType.TOKEN, payload: \"payload1\" },\n ]);\n vi.spyOn(loader2, \"load\").mockResolvedValue([\n { type: ClearSignContextType.NFT, payload: \"payload2\" },\n ]);\n\n const contextModule = new DefaultContextModule({\n ...defaultContextModuleConfig,\n customLoaders: [loader1, loader2],\n });\n\n const testInput = { to: \"0x123\", selector: \"0xabc\" };\n const res = await contextModule.getContexts(testInput);\n\n expect(loader1.canHandle).toHaveBeenCalledWith(\n testInput,\n Object.values(ClearSignContextType),\n );\n expect(loader2.canHandle).toHaveBeenCalledWith(\n testInput,\n Object.values(ClearSignContextType),\n );\n expect(loader1.load).toHaveBeenCalledWith(testInput);\n expect(loader2.load).not.toHaveBeenCalled(); // Should not be called since canHandle returned false\n expect(res).toEqual([{ type: \"token\", payload: \"payload1\" }]);\n });\n\n it(\"should use expected types if provided\", async () => {\n const loader = contextLoaderStubBuilder(true);\n\n vi.spyOn(loader, \"canHandle\").mockReturnValue(true);\n\n vi.spyOn(loader, \"load\").mockResolvedValue([\n { type: ClearSignContextType.TOKEN, payload: \"payload1\" },\n ]);\n\n const contextModule = new DefaultContextModule({\n ...defaultContextModuleConfig,\n customLoaders: [loader],\n });\n\n const testInput = { to: \"0x123\", selector: \"0xabc\" };\n await contextModule.getContexts(testInput, [ClearSignContextType.TOKEN]);\n\n expect(loader.canHandle).toHaveBeenCalledWith(testInput, [\n ClearSignContextType.TOKEN,\n ]);\n });\n\n it(\"should call the typed data loader\", async () => {\n const contextModule = new DefaultContextModule({\n ...defaultContextModuleConfig,\n customTypedDataLoader: typedDataLoader,\n });\n\n await contextModule.getTypedDataFilters({} as TypedDataContext);\n\n expect(typedDataLoader.load).toHaveBeenCalledTimes(1);\n });\n\n describe(\"getFieldContext\", () => {\n it(\"should return error when no loader can handle the field\", async () => {\n // GIVEN\n const fieldLoader = fieldLoaderStubBuilder();\n vi.spyOn(fieldLoader, \"canHandle\").mockReturnValue(false);\n\n const contextModule = new DefaultContextModule({\n ...defaultContextModuleConfig,\n customFieldLoaders: [fieldLoader],\n });\n\n const testField = { type: \"unknown\" };\n\n // WHEN\n const result = await contextModule.getFieldContext(\n testField,\n ClearSignContextType.TOKEN,\n );\n\n // THEN\n expect(fieldLoader.canHandle).toHaveBeenCalledWith(\n testField,\n ClearSignContextType.TOKEN,\n );\n expect(fieldLoader.loadField).not.toHaveBeenCalled();\n expect(result).toEqual({\n type: ClearSignContextType.ERROR,\n error: new Error(\n `Loader not found for field: ${testField} and expected type: ${ClearSignContextType.TOKEN}`,\n ),\n });\n });\n\n it(\"should return context when a loader can handle the field\", async () => {\n // GIVEN\n const fieldLoader = fieldLoaderStubBuilder();\n const mockContext: ClearSignContext = {\n type: ClearSignContextType.TOKEN,\n payload: \"test-payload\",\n };\n\n vi.spyOn(fieldLoader, \"canHandle\").mockReturnValue(true);\n vi.spyOn(fieldLoader, \"loadField\").mockResolvedValue(mockContext);\n\n const contextModule = new DefaultContextModule({\n ...defaultContextModuleConfig,\n customFieldLoaders: [fieldLoader],\n });\n\n const testField = { type: \"token\", address: \"0x123\" };\n\n // WHEN\n const result = await contextModule.getFieldContext(\n testField,\n ClearSignContextType.TOKEN,\n );\n\n // THEN\n expect(fieldLoader.canHandle).toHaveBeenCalledWith(\n testField,\n ClearSignContextType.TOKEN,\n );\n expect(fieldLoader.loadField).toHaveBeenCalledWith(testField);\n expect(result).toEqual(mockContext);\n });\n\n it(\"should return first context when multiple loaders can handle the field\", async () => {\n // GIVEN\n const fieldLoader1 = fieldLoaderStubBuilder();\n const fieldLoader2 = fieldLoaderStubBuilder();\n\n const mockContext1: ClearSignContext = {\n type: ClearSignContextType.TOKEN,\n payload: \"first-payload\",\n };\n const mockContext2: ClearSignContext = {\n type: ClearSignContextType.NFT,\n payload: \"second-payload\",\n };\n\n vi.spyOn(fieldLoader1, \"canHandle\").mockReturnValue(true);\n vi.spyOn(fieldLoader2, \"canHandle\").mockReturnValue(true);\n vi.spyOn(fieldLoader1, \"loadField\").mockResolvedValue(mockContext1);\n vi.spyOn(fieldLoader2, \"loadField\").mockResolvedValue(mockContext2);\n\n const contextModule = new DefaultContextModule({\n ...defaultContextModuleConfig,\n customFieldLoaders: [fieldLoader1, fieldLoader2],\n });\n\n const testField = { type: \"multi\", address: \"0x123\" };\n\n // WHEN\n const result = await contextModule.getFieldContext(\n testField,\n ClearSignContextType.TOKEN,\n );\n\n // THEN\n expect(fieldLoader1.canHandle).toHaveBeenCalledWith(\n testField,\n ClearSignContextType.TOKEN,\n );\n expect(fieldLoader2.canHandle).toHaveBeenCalledWith(\n testField,\n ClearSignContextType.TOKEN,\n );\n expect(fieldLoader1.loadField).toHaveBeenCalledWith(testField);\n expect(fieldLoader2.loadField).not.toHaveBeenCalled();\n expect(result).toEqual(mockContext1); // Should return first context\n });\n\n it(\"should return second context when first context is an error\", async () => {\n // GIVEN\n const fieldLoader1 = fieldLoaderStubBuilder();\n const fieldLoader2 = fieldLoaderStubBuilder();\n const mockContext1: ClearSignContext = {\n type: ClearSignContextType.ERROR,\n error: new Error(\"first-error\"),\n };\n const mockContext2: ClearSignContext = {\n type: ClearSignContextType.TOKEN,\n payload: \"second-payload\",\n };\n vi.spyOn(fieldLoader1, \"canHandle\").mockReturnValue(true);\n vi.spyOn(fieldLoader2, \"canHandle\").mockReturnValue(true);\n vi.spyOn(fieldLoader1, \"loadField\").mockResolvedValue(mockContext1);\n vi.spyOn(fieldLoader2, \"loadField\").mockResolvedValue(mockContext2);\n\n const contextModule = new DefaultContextModule({\n ...defaultContextModuleConfig,\n customFieldLoaders: [fieldLoader1, fieldLoader2],\n });\n\n const testField = { type: \"error\", address: \"0x123\" };\n\n // WHEN\n const result = await contextModule.getFieldContext(\n testField,\n ClearSignContextType.TOKEN,\n );\n\n // THEN\n expect(fieldLoader1.canHandle).toHaveBeenCalledWith(\n testField,\n ClearSignContextType.TOKEN,\n );\n expect(fieldLoader2.canHandle).toHaveBeenCalledWith(\n testField,\n ClearSignContextType.TOKEN,\n );\n expect(fieldLoader1.loadField).toHaveBeenCalledWith(testField);\n expect(fieldLoader2.loadField).toHaveBeenCalledWith(testField);\n expect(result).toEqual(mockContext2);\n });\n\n it(\"should handle loader rejection gracefully\", async () => {\n // GIVEN\n const fieldLoader = fieldLoaderStubBuilder();\n const loadError = new Error(\"Load field failed\");\n\n vi.spyOn(fieldLoader, \"canHandle\").mockReturnValue(true);\n vi.spyOn(fieldLoader, \"loadField\").mockRejectedValue(loadError);\n\n const contextModule = new DefaultContextModule({\n ...defaultContextModuleConfig,\n customFieldLoaders: [fieldLoader],\n });\n\n const testField = { type: \"error\", address: \"0x123\" };\n\n // WHEN & THEN\n await expect(\n contextModule.getFieldContext(testField, ClearSignContextType.TOKEN),\n ).rejects.toThrow(\"Load field failed\");\n\n expect(fieldLoader.canHandle).toHaveBeenCalledWith(\n testField,\n ClearSignContextType.TOKEN,\n );\n expect(fieldLoader.loadField).toHaveBeenCalledWith(testField);\n });\n });\n});\n"],
5
- "mappings": "aAGA,IAAAA,EAGO,2CAGPC,EAAqC,kCAErC,MAAMC,EAA4BC,IACzB,CACL,KAAM,GAAG,GAAG,EACZ,UAAW,GACR,GAAG,EACH,gBAAgBA,CAAS,CAC9B,GAGIC,EAAyB,KACtB,CACL,UAAW,GAAG,GAAG,EACjB,UAAW,GAAG,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MV,EAAgB,IAAI,uBAAqB,CAC7C,GAAGN,EACH,mBAAoB,CAACQ,CAAW,CAClC,CAAC,EAEKC,EAAY,CAAE,KAAM,QAAS,QAAS,OAAQ,EAGpD,MAAM,OACJH,EAAc,gBAAgBG,EAAW,uBAAqB,KAAK,CACrE,EAAE,QAAQ,QAAQ,mBAAmB,EAErC,OAAOD,EAAY,SAAS,EAAE,qBAC5BC,EACA,uBAAqB,KACvB,EACA,OAAOD,EAAY,SAAS,EAAE,qBAAqBC,CAAS,CAC9D,CAAC,CACH,CAAC,CACH,CAAC",
6
- "names": ["import_ClearSignContext", "import_DefaultContextModule", "contextLoaderStubBuilder", "canHandle", "fieldLoaderStubBuilder", "typedDataLoader", "defaultContextModuleConfig", "res", "loader", "responses", "loader1", "loader2", "contextModule", "testInput", "fieldLoader", "testField", "result", "mockContext", "fieldLoader1", "fieldLoader2", "mockContext1", "mockContext2", "loadError"]
4
+ "sourcesContent": ["import { type ContextModuleConfig } from \"./config/model/ContextModuleConfig\";\nimport { type ContextFieldLoader } from \"./shared/domain/ContextFieldLoader\";\nimport { type ContextLoader } from \"./shared/domain/ContextLoader\";\nimport {\n type ClearSignContext,\n ClearSignContextType,\n} from \"./shared/model/ClearSignContext\";\nimport { type TypedDataContext } from \"./shared/model/TypedDataContext\";\nimport type { TypedDataContextLoader } from \"./typed-data/domain/TypedDataContextLoader\";\nimport { DefaultContextModule } from \"./DefaultContextModule\";\n\nconst mockLoggerFactory = () => ({\n debug: vi.fn(),\n info: vi.fn(),\n warn: vi.fn(),\n error: vi.fn(),\n subscribers: [],\n});\n\nconst contextLoaderStubBuilder = (canHandle: boolean): ContextLoader => {\n return {\n load: vi.fn(),\n canHandle: vi\n .fn()\n .mockReturnValue(canHandle) as unknown as ContextLoader[\"canHandle\"],\n };\n};\n\nconst fieldLoaderStubBuilder = (): ContextFieldLoader => {\n return {\n canHandle: vi.fn() as unknown as ContextFieldLoader[\"canHandle\"],\n loadField: vi.fn(),\n };\n};\n\ndescribe(\"DefaultContextModule\", () => {\n const typedDataLoader: TypedDataContextLoader = { load: vi.fn() };\n const defaultContextModuleConfig: ContextModuleConfig = {\n customLoaders: [],\n defaultLoaders: false,\n defaultFieldLoaders: false,\n customFieldLoaders: [],\n customTypedDataLoader: typedDataLoader,\n cal: {\n url: \"https://cal/v1\",\n mode: \"prod\",\n branch: \"main\",\n },\n web3checks: {\n url: \"https://web3checks/v3\",\n },\n metadataServiceDomain: {\n url: \"https://metadata.com\",\n },\n originToken: \"originToken\",\n loggerFactory: mockLoggerFactory,\n };\n\n beforeEach(() => {\n vi.restoreAllMocks();\n });\n\n it(\"should initialize the context module with all the default loaders\", async () => {\n const contextModule = new DefaultContextModule(defaultContextModuleConfig);\n\n const res = await contextModule.getContexts({});\n\n expect(res).toEqual([]);\n });\n\n it(\"should return an empty array when no loaders\", async () => {\n const contextModule = new DefaultContextModule(defaultContextModuleConfig);\n\n const res = await contextModule.getContexts({});\n\n expect(res).toEqual([]);\n });\n\n it(\"should call all fetch method from metadata fetcher\", async () => {\n const loader = contextLoaderStubBuilder(true);\n const contextModule = new DefaultContextModule({\n ...defaultContextModuleConfig,\n customLoaders: [loader, loader],\n });\n\n await contextModule.getContexts({});\n\n expect(loader.canHandle).toHaveBeenCalledTimes(2);\n expect(loader.load).toHaveBeenCalledTimes(2);\n });\n\n it(\"should return an array of context response\", async () => {\n const loader = contextLoaderStubBuilder(true);\n const responses = [\n [{ type: \"provideERC20Info\", payload: \"payload1\" }],\n [\n { type: \"provideERC20Info\", payload: \"payload2\" },\n { type: \"plugin\", payload: \"payload3\" },\n ],\n ] as ClearSignContext[][];\n vi.spyOn(loader, \"load\")\n .mockResolvedValueOnce(responses[0]!)\n .mockResolvedValueOnce(responses[1]!);\n const contextModule = new DefaultContextModule({\n ...defaultContextModuleConfig,\n customLoaders: [loader, loader],\n });\n\n const res = await contextModule.getContexts({});\n\n expect(loader.canHandle).toHaveBeenCalledTimes(2);\n expect(loader.load).toHaveBeenCalledTimes(2);\n expect(res).toEqual(responses.flat());\n });\n\n it(\"should only call loaders that can handle the input\", async () => {\n const loader1 = contextLoaderStubBuilder(true);\n const loader2 = contextLoaderStubBuilder(true);\n\n vi.spyOn(loader1, \"canHandle\").mockReturnValue(true);\n vi.spyOn(loader2, \"canHandle\").mockReturnValue(false);\n vi.spyOn(loader1, \"load\").mockResolvedValue([\n { type: ClearSignContextType.TOKEN, payload: \"payload1\" },\n ]);\n vi.spyOn(loader2, \"load\").mockResolvedValue([\n { type: ClearSignContextType.NFT, payload: \"payload2\" },\n ]);\n\n const contextModule = new DefaultContextModule({\n ...defaultContextModuleConfig,\n customLoaders: [loader1, loader2],\n });\n\n const testInput = { to: \"0x123\", selector: \"0xabc\" };\n const res = await contextModule.getContexts(testInput);\n\n expect(loader1.canHandle).toHaveBeenCalledWith(\n testInput,\n Object.values(ClearSignContextType),\n );\n expect(loader2.canHandle).toHaveBeenCalledWith(\n testInput,\n Object.values(ClearSignContextType),\n );\n expect(loader1.load).toHaveBeenCalledWith(testInput);\n expect(loader2.load).not.toHaveBeenCalled(); // Should not be called since canHandle returned false\n expect(res).toEqual([{ type: \"token\", payload: \"payload1\" }]);\n });\n\n it(\"should use expected types if provided\", async () => {\n const loader = contextLoaderStubBuilder(true);\n\n vi.spyOn(loader, \"canHandle\").mockReturnValue(true);\n\n vi.spyOn(loader, \"load\").mockResolvedValue([\n { type: ClearSignContextType.TOKEN, payload: \"payload1\" },\n ]);\n\n const contextModule = new DefaultContextModule({\n ...defaultContextModuleConfig,\n customLoaders: [loader],\n });\n\n const testInput = { to: \"0x123\", selector: \"0xabc\" };\n await contextModule.getContexts(testInput, [ClearSignContextType.TOKEN]);\n\n expect(loader.canHandle).toHaveBeenCalledWith(testInput, [\n ClearSignContextType.TOKEN,\n ]);\n });\n\n it(\"should call the typed data loader\", async () => {\n const contextModule = new DefaultContextModule({\n ...defaultContextModuleConfig,\n customTypedDataLoader: typedDataLoader,\n });\n\n await contextModule.getTypedDataFilters({} as TypedDataContext);\n\n expect(typedDataLoader.load).toHaveBeenCalledTimes(1);\n });\n\n describe(\"getFieldContext\", () => {\n it(\"should return error when no loader can handle the field\", async () => {\n // GIVEN\n const fieldLoader = fieldLoaderStubBuilder();\n vi.spyOn(fieldLoader, \"canHandle\").mockReturnValue(false);\n\n const contextModule = new DefaultContextModule({\n ...defaultContextModuleConfig,\n customFieldLoaders: [fieldLoader],\n });\n\n const testField = { type: \"unknown\" };\n\n // WHEN\n const result = await contextModule.getFieldContext(\n testField,\n ClearSignContextType.TOKEN,\n );\n\n // THEN\n expect(fieldLoader.canHandle).toHaveBeenCalledWith(\n testField,\n ClearSignContextType.TOKEN,\n );\n expect(fieldLoader.loadField).not.toHaveBeenCalled();\n expect(result).toEqual({\n type: ClearSignContextType.ERROR,\n error: new Error(\n `Loader not found for field: ${testField} and expected type: ${ClearSignContextType.TOKEN}`,\n ),\n });\n });\n\n it(\"should return context when a loader can handle the field\", async () => {\n // GIVEN\n const fieldLoader = fieldLoaderStubBuilder();\n const mockContext: ClearSignContext = {\n type: ClearSignContextType.TOKEN,\n payload: \"test-payload\",\n };\n\n vi.spyOn(fieldLoader, \"canHandle\").mockReturnValue(true);\n vi.spyOn(fieldLoader, \"loadField\").mockResolvedValue(mockContext);\n\n const contextModule = new DefaultContextModule({\n ...defaultContextModuleConfig,\n customFieldLoaders: [fieldLoader],\n });\n\n const testField = { type: \"token\", address: \"0x123\" };\n\n // WHEN\n const result = await contextModule.getFieldContext(\n testField,\n ClearSignContextType.TOKEN,\n );\n\n // THEN\n expect(fieldLoader.canHandle).toHaveBeenCalledWith(\n testField,\n ClearSignContextType.TOKEN,\n );\n expect(fieldLoader.loadField).toHaveBeenCalledWith(testField);\n expect(result).toEqual(mockContext);\n });\n\n it(\"should return first context when multiple loaders can handle the field\", async () => {\n // GIVEN\n const fieldLoader1 = fieldLoaderStubBuilder();\n const fieldLoader2 = fieldLoaderStubBuilder();\n\n const mockContext1: ClearSignContext = {\n type: ClearSignContextType.TOKEN,\n payload: \"first-payload\",\n };\n const mockContext2: ClearSignContext = {\n type: ClearSignContextType.NFT,\n payload: \"second-payload\",\n };\n\n vi.spyOn(fieldLoader1, \"canHandle\").mockReturnValue(true);\n vi.spyOn(fieldLoader2, \"canHandle\").mockReturnValue(true);\n vi.spyOn(fieldLoader1, \"loadField\").mockResolvedValue(mockContext1);\n vi.spyOn(fieldLoader2, \"loadField\").mockResolvedValue(mockContext2);\n\n const contextModule = new DefaultContextModule({\n ...defaultContextModuleConfig,\n customFieldLoaders: [fieldLoader1, fieldLoader2],\n });\n\n const testField = { type: \"multi\", address: \"0x123\" };\n\n // WHEN\n const result = await contextModule.getFieldContext(\n testField,\n ClearSignContextType.TOKEN,\n );\n\n // THEN\n expect(fieldLoader1.canHandle).toHaveBeenCalledWith(\n testField,\n ClearSignContextType.TOKEN,\n );\n expect(fieldLoader2.canHandle).toHaveBeenCalledWith(\n testField,\n ClearSignContextType.TOKEN,\n );\n expect(fieldLoader1.loadField).toHaveBeenCalledWith(testField);\n expect(fieldLoader2.loadField).not.toHaveBeenCalled();\n expect(result).toEqual(mockContext1); // Should return first context\n });\n\n it(\"should return second context when first context is an error\", async () => {\n // GIVEN\n const fieldLoader1 = fieldLoaderStubBuilder();\n const fieldLoader2 = fieldLoaderStubBuilder();\n const mockContext1: ClearSignContext = {\n type: ClearSignContextType.ERROR,\n error: new Error(\"first-error\"),\n };\n const mockContext2: ClearSignContext = {\n type: ClearSignContextType.TOKEN,\n payload: \"second-payload\",\n };\n vi.spyOn(fieldLoader1, \"canHandle\").mockReturnValue(true);\n vi.spyOn(fieldLoader2, \"canHandle\").mockReturnValue(true);\n vi.spyOn(fieldLoader1, \"loadField\").mockResolvedValue(mockContext1);\n vi.spyOn(fieldLoader2, \"loadField\").mockResolvedValue(mockContext2);\n\n const contextModule = new DefaultContextModule({\n ...defaultContextModuleConfig,\n customFieldLoaders: [fieldLoader1, fieldLoader2],\n });\n\n const testField = { type: \"error\", address: \"0x123\" };\n\n // WHEN\n const result = await contextModule.getFieldContext(\n testField,\n ClearSignContextType.TOKEN,\n );\n\n // THEN\n expect(fieldLoader1.canHandle).toHaveBeenCalledWith(\n testField,\n ClearSignContextType.TOKEN,\n );\n expect(fieldLoader2.canHandle).toHaveBeenCalledWith(\n testField,\n ClearSignContextType.TOKEN,\n );\n expect(fieldLoader1.loadField).toHaveBeenCalledWith(testField);\n expect(fieldLoader2.loadField).toHaveBeenCalledWith(testField);\n expect(result).toEqual(mockContext2);\n });\n\n it(\"should handle loader rejection gracefully\", async () => {\n // GIVEN\n const fieldLoader = fieldLoaderStubBuilder();\n const loadError = new Error(\"Load field failed\");\n\n vi.spyOn(fieldLoader, \"canHandle\").mockReturnValue(true);\n vi.spyOn(fieldLoader, \"loadField\").mockRejectedValue(loadError);\n\n const contextModule = new DefaultContextModule({\n ...defaultContextModuleConfig,\n customFieldLoaders: [fieldLoader],\n });\n\n const testField = { type: \"error\", address: \"0x123\" };\n\n // WHEN & THEN\n await expect(\n contextModule.getFieldContext(testField, ClearSignContextType.TOKEN),\n ).rejects.toThrow(\"Load field failed\");\n\n expect(fieldLoader.canHandle).toHaveBeenCalledWith(\n testField,\n ClearSignContextType.TOKEN,\n );\n expect(fieldLoader.loadField).toHaveBeenCalledWith(testField);\n });\n });\n});\n"],
5
+ "mappings": "aAGA,IAAAA,EAGO,2CAGPC,EAAqC,kCAErC,MAAMC,EAAoB,KAAO,CAC/B,MAAO,GAAG,GAAG,EACb,KAAM,GAAG,GAAG,EACZ,KAAM,GAAG,GAAG,EACZ,MAAO,GAAG,GAAG,EACb,YAAa,CAAC,CAChB,GAEMC,EAA4BC,IACzB,CACL,KAAM,GAAG,GAAG,EACZ,UAAW,GACR,GAAG,EACH,gBAAgBA,CAAS,CAC9B,GAGIC,EAAyB,KACtB,CACL,UAAW,GAAG,GAAG,EACjB,UAAW,GAAG,GAAG,CACnB,GAGF,SAAS,uBAAwB,IAAM,CACrC,MAAMC,EAA0C,CAAE,KAAM,GAAG,GAAG,CAAE,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AAC,EAEKC,EAAY,CAAE,KAAM,QAAS,QAAS,OAAQ,EAGpD,MAAM,OACJH,EAAc,gBAAgBG,EAAW,uBAAqB,KAAK,CACrE,EAAE,QAAQ,QAAQ,mBAAmB,EAErC,OAAOD,EAAY,SAAS,EAAE,qBAC5BC,EACA,uBAAqB,KACvB,EACA,OAAOD,EAAY,SAAS,EAAE,qBAAqBC,CAAS,CAC9D,CAAC,CACH,CAAC,CACH,CAAC",
6
+ "names": ["import_ClearSignContext", "import_DefaultContextModule", "mockLoggerFactory", "contextLoaderStubBuilder", "canHandle", "fieldLoaderStubBuilder", "typedDataLoader", "defaultContextModuleConfig", "res", "loader", "responses", "loader1", "loader2", "contextModule", "testInput", "fieldLoader", "testField", "result", "mockContext", "fieldLoader1", "fieldLoader2", "mockContext1", "mockContext2", "loadError"]
7
7
  }
@@ -1,2 +1,2 @@
1
- "use strict";var C=Object.defineProperty;var u=Object.getOwnPropertyDescriptor;var M=Object.getOwnPropertyNames;var h=Object.prototype.hasOwnProperty;var f=(o,e)=>{for(var t in e)C(o,t,{get:e[t],enumerable:!0})},v=(o,e,t,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let a of M(e))!h.call(o,a)&&a!==t&&C(o,a,{get:()=>e[a],enumerable:!(r=u(e,a))||r.enumerable});return o};var A=o=>v(C({},"__esModule",{value:!0}),o),g=(o,e,t,r)=>{for(var a=r>1?void 0:r?u(e,t):e,n=o.length-1,s;n>=0;n--)(s=o[n])&&(a=(r?s(e,t,a):s(a))||a);return r&&a&&C(e,t,a),a},y=(o,e)=>(t,r)=>e(t,r,o);var _={};f(_,{CalldataContextLoader:()=>x});module.exports=A(_);var l=require("@ledgerhq/device-management-kit"),i=require("inversify"),D=require("purify-ts"),m=require("../../calldata/di/calldataTypes"),I=require("../../proxy/di/proxyTypes"),c=require("../../shared/model/ClearSignContext");const T=[c.ClearSignContextType.TRANSACTION_INFO,c.ClearSignContextType.TRANSACTION_FIELD_DESCRIPTION,c.ClearSignContextType.PROXY_INFO,c.ClearSignContextType.ENUM];let x=class{constructor(e,t,r){this.dappDataSource=e;this.tokenDataSource=t;this.proxyDataSource=r}canHandle(e,t){return typeof e=="object"&&e!==null&&"to"in e&&"data"in e&&"selector"in e&&"chainId"in e&&"deviceModelId"in e&&e.deviceModelId!==void 0&&e.deviceModelId!==l.DeviceModelId.NANO_S&&typeof e.chainId=="number"&&(0,l.isHexaString)(e.to)&&e.to!=="0x"&&(0,l.isHexaString)(e.data)&&(0,l.isHexaString)(e.selector)&&e.selector!=="0x"&&T.every(r=>t.includes(r))}async load(e){const{to:t,data:r,selector:a,chainId:n,deviceModelId:s}=e,d={address:t,chainId:n,selector:a,deviceModelId:s,data:r};return this._getContexts(d,this.dappDataSource).alt(this._getContexts(d,this.tokenDataSource)).alt(this._getContextsWithProxy(d,this.dappDataSource)).orDefault([{type:c.ClearSignContextType.ERROR,error:new Error("[ContextModule] CalldataContextLoader: No calldata contexts found")}])}_getContexts({address:e,chainId:t,selector:r,deviceModelId:a},n){return(0,D.MaybeAsync)(async({liftMaybe:s})=>{const d=await n.getCalldataDescriptors({deviceModelId:a,address:e,chainId:t,selector:r});return s(d.toMaybe().filter(p=>p.length>0))})}_getContextsWithProxy({address:e,chainId:t,selector:r,deviceModelId:a,data:n},s){return(0,D.MaybeAsync)(async({liftMaybe:p})=>{const S=await this.proxyDataSource.getProxyImplementationAddress({calldata:n,proxyAddress:e,chainId:t,challenge:""});return p(S.toMaybe())}).map(({implementationAddress:p})=>{const S={address:p,chainId:t,selector:r,deviceModelId:a,data:n};return this._getContexts(S,s).map(P=>[{type:c.ClearSignContextType.PROXY_INFO,payload:"0x"},...P])}).join()}};x=g([(0,i.injectable)(),y(0,(0,i.inject)(m.calldataTypes.DappCalldataDescriptorDataSource)),y(1,(0,i.inject)(m.calldataTypes.TokenCalldataDescriptorDataSource)),y(2,(0,i.inject)(I.proxyTypes.ProxyDataSource))],x);0&&(module.exports={CalldataContextLoader});
1
+ "use strict";var g=Object.defineProperty;var D=Object.getOwnPropertyDescriptor;var v=Object.getOwnPropertyNames;var M=Object.prototype.hasOwnProperty;var b=(o,e)=>{for(var a in e)g(o,a,{get:e[a],enumerable:!0})},f=(o,e,a,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let t of v(e))!M.call(o,t)&&t!==a&&g(o,t,{get:()=>e[t],enumerable:!(r=D(e,t))||r.enumerable});return o};var T=o=>f(g({},"__esModule",{value:!0}),o),I=(o,e,a,r)=>{for(var t=r>1?void 0:r?D(e,a):e,s=o.length-1,n;s>=0;s--)(n=o[s])&&(t=(r?n(e,a,t):n(t))||t);return r&&t&&g(e,a,t),t},C=(o,e)=>(a,r)=>e(a,r,o);var N={};b(N,{CalldataContextLoader:()=>y});module.exports=T(N);var x=require("@ledgerhq/device-management-kit"),l=require("inversify"),u=require("purify-ts"),m=require("../../calldata/di/calldataTypes"),h=require("../../config/di/configTypes"),P=require("../../proxy/di/proxyTypes"),c=require("../../shared/model/ClearSignContext");const A=[c.ClearSignContextType.TRANSACTION_INFO,c.ClearSignContextType.TRANSACTION_FIELD_DESCRIPTION,c.ClearSignContextType.PROXY_INFO,c.ClearSignContextType.ENUM];let y=class{constructor(e,a,r,t){this.dappDataSource=e;this.tokenDataSource=a;this.proxyDataSource=r;this.logger=t("CalldataContextLoader")}logger;canHandle(e,a){return typeof e=="object"&&e!==null&&"to"in e&&"data"in e&&"selector"in e&&"chainId"in e&&"deviceModelId"in e&&e.deviceModelId!==void 0&&e.deviceModelId!==x.DeviceModelId.NANO_S&&typeof e.chainId=="number"&&(0,x.isHexaString)(e.to)&&e.to!=="0x"&&(0,x.isHexaString)(e.data)&&(0,x.isHexaString)(e.selector)&&e.selector!=="0x"&&A.every(r=>a.includes(r))}async load(e){const{to:a,data:r,selector:t,chainId:s,deviceModelId:n}=e,i={address:a,chainId:s,selector:t,deviceModelId:n,data:r},p=(await this._getContexts(i,this.dappDataSource).alt(this._getContexts(i,this.tokenDataSource)).alt(this._getContextsWithProxy(i,this.dappDataSource)).run()).caseOf({Just:S=>S,Nothing:()=>[{type:c.ClearSignContextType.ERROR,error:new Error("[ContextModule] CalldataContextLoader: No calldata contexts found")}]});return this.logger.debug("load result",{data:{result:p}}),p}_getContexts({address:e,chainId:a,selector:r,deviceModelId:t},s){return(0,u.MaybeAsync)(async({liftMaybe:n})=>{const i=await s.getCalldataDescriptors({deviceModelId:t,address:e,chainId:a,selector:r});return n(i.toMaybe().filter(d=>d.length>0))})}_getContextsWithProxy({address:e,chainId:a,selector:r,deviceModelId:t,data:s},n){return(0,u.MaybeAsync)(async({liftMaybe:d})=>{const p=await this.proxyDataSource.getProxyImplementationAddress({calldata:s,proxyAddress:e,chainId:a,challenge:""});return d(p.toMaybe())}).map(({implementationAddress:d})=>{const p={address:d,chainId:a,selector:r,deviceModelId:t,data:s};return this._getContexts(p,n).map(S=>[{type:c.ClearSignContextType.PROXY_INFO,payload:"0x"},...S])}).join()}};y=I([(0,l.injectable)(),C(0,(0,l.inject)(m.calldataTypes.DappCalldataDescriptorDataSource)),C(1,(0,l.inject)(m.calldataTypes.TokenCalldataDescriptorDataSource)),C(2,(0,l.inject)(P.proxyTypes.ProxyDataSource)),C(3,(0,l.inject)(h.configTypes.ContextModuleLoggerFactory))],y);0&&(module.exports={CalldataContextLoader});
2
2
  //# sourceMappingURL=CalldataContextLoader.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../../src/calldata/domain/CalldataContextLoader.ts"],
4
- "sourcesContent": ["import {\n DeviceModelId,\n HexaString,\n isHexaString,\n} from \"@ledgerhq/device-management-kit\";\nimport { inject, injectable } from \"inversify\";\nimport { MaybeAsync } from \"purify-ts\";\n\nimport type { CalldataDescriptorDataSource } from \"@/calldata/data/CalldataDescriptorDataSource\";\nimport { calldataTypes } from \"@/calldata/di/calldataTypes\";\nimport type { ProxyDataSource } from \"@/proxy/data/ProxyDataSource\";\nimport { proxyTypes } from \"@/proxy/di/proxyTypes\";\nimport { ContextLoader } from \"@/shared/domain/ContextLoader\";\nimport {\n ClearSignContext,\n ClearSignContextType,\n} from \"@/shared/model/ClearSignContext\";\n\nexport type CalldataContextInput = {\n to: HexaString;\n data: HexaString;\n selector: HexaString;\n chainId: number;\n deviceModelId: DeviceModelId;\n};\n\ntype GetContextsParams = {\n address: string;\n chainId: number;\n data: string;\n selector: HexaString;\n deviceModelId: DeviceModelId;\n};\n\nconst SUPPORTED_TYPES: ClearSignContextType[] = [\n ClearSignContextType.TRANSACTION_INFO,\n ClearSignContextType.TRANSACTION_FIELD_DESCRIPTION,\n ClearSignContextType.PROXY_INFO,\n ClearSignContextType.ENUM,\n];\n\n@injectable()\nexport class CalldataContextLoader\n implements ContextLoader<CalldataContextInput>\n{\n constructor(\n @inject(calldataTypes.DappCalldataDescriptorDataSource)\n private dappDataSource: CalldataDescriptorDataSource,\n @inject(calldataTypes.TokenCalldataDescriptorDataSource)\n private tokenDataSource: CalldataDescriptorDataSource,\n @inject(proxyTypes.ProxyDataSource)\n private proxyDataSource: ProxyDataSource,\n ) {}\n\n canHandle(\n input: unknown,\n expectedTypes: ClearSignContextType[],\n ): input is CalldataContextInput {\n return (\n typeof input === \"object\" &&\n input !== null &&\n \"to\" in input &&\n \"data\" in input &&\n \"selector\" in input &&\n \"chainId\" in input &&\n \"deviceModelId\" in input &&\n input.deviceModelId !== undefined &&\n input.deviceModelId !== DeviceModelId.NANO_S &&\n typeof input.chainId === \"number\" &&\n isHexaString(input.to) &&\n input.to !== \"0x\" &&\n isHexaString(input.data) &&\n isHexaString(input.selector) &&\n input.selector !== \"0x\" &&\n SUPPORTED_TYPES.every((type) => expectedTypes.includes(type))\n );\n }\n\n async load(input: CalldataContextInput): Promise<ClearSignContext[]> {\n const { to, data, selector, chainId, deviceModelId } = input;\n\n const param: GetContextsParams = {\n address: to,\n chainId,\n selector,\n deviceModelId,\n data,\n };\n\n return this._getContexts(param, this.dappDataSource)\n .alt(this._getContexts(param, this.tokenDataSource))\n .alt(this._getContextsWithProxy(param, this.dappDataSource))\n .orDefault([\n {\n type: ClearSignContextType.ERROR,\n error: new Error(\n \"[ContextModule] CalldataContextLoader: No calldata contexts found\",\n ),\n },\n ]);\n }\n\n private _getContexts(\n { address, chainId, selector, deviceModelId }: GetContextsParams,\n datasource: CalldataDescriptorDataSource,\n ): MaybeAsync<ClearSignContext[]> {\n return MaybeAsync(async ({ liftMaybe }) => {\n const result = await datasource.getCalldataDescriptors({\n deviceModelId,\n address,\n chainId,\n selector,\n });\n\n return liftMaybe(result.toMaybe().filter((ctxs) => ctxs.length > 0));\n });\n }\n\n private _getContextsWithProxy(\n { address, chainId, selector, deviceModelId, data }: GetContextsParams,\n datasource: CalldataDescriptorDataSource,\n ): MaybeAsync<ClearSignContext[]> {\n const proxyAddress = MaybeAsync(async ({ liftMaybe }) => {\n const result = await this.proxyDataSource.getProxyImplementationAddress({\n calldata: data,\n proxyAddress: address,\n chainId,\n challenge: \"\",\n });\n return liftMaybe(result.toMaybe());\n });\n\n return proxyAddress\n .map<MaybeAsync<ClearSignContext[]>>(({ implementationAddress }) => {\n const params = {\n address: implementationAddress,\n chainId,\n selector,\n deviceModelId,\n data,\n };\n return this._getContexts(params, datasource).map((contexts) => [\n // Add a proxy info context to the list of contexts\n // to specify that the proxy info should be refetched during the provide step\n {\n type: ClearSignContextType.PROXY_INFO,\n payload: \"0x\",\n },\n ...contexts,\n ]);\n })\n .join(); // join the two MaybeAsyncs\n }\n}\n"],
5
- "mappings": "okBAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,2BAAAE,IAAA,eAAAC,EAAAH,GAAA,IAAAI,EAIO,2CACPC,EAAmC,qBACnCC,EAA2B,qBAG3BC,EAA8B,uCAE9BC,EAA2B,iCAE3BC,EAGO,2CAkBP,MAAMC,EAA0C,CAC9C,uBAAqB,iBACrB,uBAAqB,8BACrB,uBAAqB,WACrB,uBAAqB,IACvB,EAGO,IAAMC,EAAN,KAEP,CACE,YAEUC,EAEAC,EAEAC,EACR,CALQ,o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AAD,EAAU,cAAAE,EAAe,KAAAH,CAAK,EAClDM,EACgC,CAWhC,SAVqB,cAAW,MAAO,CAAE,UAAAC,CAAU,IAAM,CACvD,MAAMC,EAAS,MAAM,KAAK,gBAAgB,8BAA8B,CACtE,SAAUR,EACV,aAAcK,EACd,QAAAH,EACA,UAAW,EACb,CAAC,EACD,OAAOK,EAAUC,EAAO,QAAQ,CAAC,CACnC,CAAC,EAGE,IAAoC,CAAC,CAAE,sBAAAE,CAAsB,IAAM,CAClE,MAAMC,EAAS,CACb,QAASD,EACT,QAAAR,EACA,SAAAD,EACA,cAAAE,EACA,KAAAH,CACF,EACA,OAAO,KAAK,aAAaW,EAAQL,CAAU,EAAE,IAAKM,GAAa,CAG7D,CACE,KAAM,uBAAqB,WAC3B,QAAS,IACX,EACA,GAAGA,CACL,CAAC,CACH,CAAC,EACA,KAAK,CACV,CACF,EA/GapB,EAANqB,EAAA,IADN,cAAW,EAKPC,EAAA,eAAO,gBAAc,gCAAgC,GAErDA,EAAA,eAAO,gBAAc,iCAAiC,GAEtDA,EAAA,eAAO,aAAW,eAAe,IARzBtB",
6
- "names": ["CalldataContextLoader_exports", "__export", "CalldataContextLoader", "__toCommonJS", "import_device_management_kit", "import_inversify", "import_purify_ts", "import_calldataTypes", "import_proxyTypes", "import_ClearSignContext", "SUPPORTED_TYPES", "CalldataContextLoader", "dappDataSource", "tokenDataSource", "proxyDataSource", "input", "expectedTypes", "type", "to", "data", "selector", "chainId", "deviceModelId", "param", "address", "datasource", "liftMaybe", "result", "ctxs", "implementationAddress", "params", "contexts", "__decorateClass", "__decorateParam"]
4
+ "sourcesContent": ["import {\n DeviceModelId,\n HexaString,\n isHexaString,\n LoggerPublisherService,\n} from \"@ledgerhq/device-management-kit\";\nimport { inject, injectable } from \"inversify\";\nimport { MaybeAsync } from \"purify-ts\";\n\nimport type { CalldataDescriptorDataSource } from \"@/calldata/data/CalldataDescriptorDataSource\";\nimport { calldataTypes } from \"@/calldata/di/calldataTypes\";\nimport { configTypes } from \"@/config/di/configTypes\";\nimport type { ProxyDataSource } from \"@/proxy/data/ProxyDataSource\";\nimport { proxyTypes } from \"@/proxy/di/proxyTypes\";\nimport { ContextLoader } from \"@/shared/domain/ContextLoader\";\nimport {\n ClearSignContext,\n ClearSignContextType,\n} from \"@/shared/model/ClearSignContext\";\n\nexport type CalldataContextInput = {\n to: HexaString;\n data: HexaString;\n selector: HexaString;\n chainId: number;\n deviceModelId: DeviceModelId;\n};\n\ntype GetContextsParams = {\n address: string;\n chainId: number;\n data: string;\n selector: HexaString;\n deviceModelId: DeviceModelId;\n};\n\nconst SUPPORTED_TYPES: ClearSignContextType[] = [\n ClearSignContextType.TRANSACTION_INFO,\n ClearSignContextType.TRANSACTION_FIELD_DESCRIPTION,\n ClearSignContextType.PROXY_INFO,\n ClearSignContextType.ENUM,\n];\n\n@injectable()\nexport class CalldataContextLoader\n implements ContextLoader<CalldataContextInput>\n{\n private logger: LoggerPublisherService;\n\n constructor(\n @inject(calldataTypes.DappCalldataDescriptorDataSource)\n private dappDataSource: CalldataDescriptorDataSource,\n @inject(calldataTypes.TokenCalldataDescriptorDataSource)\n private tokenDataSource: CalldataDescriptorDataSource,\n @inject(proxyTypes.ProxyDataSource)\n private proxyDataSource: ProxyDataSource,\n @inject(configTypes.ContextModuleLoggerFactory)\n loggerFactory: (tag: string) => LoggerPublisherService,\n ) {\n this.logger = loggerFactory(\"CalldataContextLoader\");\n }\n\n canHandle(\n input: unknown,\n expectedTypes: ClearSignContextType[],\n ): input is CalldataContextInput {\n return (\n typeof input === \"object\" &&\n input !== null &&\n \"to\" in input &&\n \"data\" in input &&\n \"selector\" in input &&\n \"chainId\" in input &&\n \"deviceModelId\" in input &&\n input.deviceModelId !== undefined &&\n input.deviceModelId !== DeviceModelId.NANO_S &&\n typeof input.chainId === \"number\" &&\n isHexaString(input.to) &&\n input.to !== \"0x\" &&\n isHexaString(input.data) &&\n isHexaString(input.selector) &&\n input.selector !== \"0x\" &&\n SUPPORTED_TYPES.every((type) => expectedTypes.includes(type))\n );\n }\n\n async load(input: CalldataContextInput): Promise<ClearSignContext[]> {\n const { to, data, selector, chainId, deviceModelId } = input;\n\n const param: GetContextsParams = {\n address: to,\n chainId,\n selector,\n deviceModelId,\n data,\n };\n\n const maybeResult = await this._getContexts(param, this.dappDataSource)\n .alt(this._getContexts(param, this.tokenDataSource))\n .alt(this._getContextsWithProxy(param, this.dappDataSource))\n .run();\n\n const result = maybeResult.caseOf({\n Just: (contexts) => contexts,\n Nothing: () => [\n {\n type: ClearSignContextType.ERROR as const,\n error: new Error(\n \"[ContextModule] CalldataContextLoader: No calldata contexts found\",\n ),\n },\n ],\n });\n\n this.logger.debug(\"load result\", { data: { result } });\n return result;\n }\n\n private _getContexts(\n { address, chainId, selector, deviceModelId }: GetContextsParams,\n datasource: CalldataDescriptorDataSource,\n ): MaybeAsync<ClearSignContext[]> {\n return MaybeAsync(async ({ liftMaybe }) => {\n const result = await datasource.getCalldataDescriptors({\n deviceModelId,\n address,\n chainId,\n selector,\n });\n\n return liftMaybe(result.toMaybe().filter((ctxs) => ctxs.length > 0));\n });\n }\n\n private _getContextsWithProxy(\n { address, chainId, selector, deviceModelId, data }: GetContextsParams,\n datasource: CalldataDescriptorDataSource,\n ): MaybeAsync<ClearSignContext[]> {\n const proxyAddress = MaybeAsync(async ({ liftMaybe }) => {\n const result = await this.proxyDataSource.getProxyImplementationAddress({\n calldata: data,\n proxyAddress: address,\n chainId,\n challenge: \"\",\n });\n return liftMaybe(result.toMaybe());\n });\n\n return proxyAddress\n .map<MaybeAsync<ClearSignContext[]>>(({ implementationAddress }) => {\n const params = {\n address: implementationAddress,\n chainId,\n selector,\n deviceModelId,\n data,\n };\n return this._getContexts(params, datasource).map((contexts) => [\n // Add a proxy info context to the list of contexts\n // to specify that the proxy info should be refetched during the provide step\n {\n type: ClearSignContextType.PROXY_INFO,\n payload: \"0x\",\n },\n ...contexts,\n ]);\n })\n .join(); // join the two MaybeAsyncs\n }\n}\n"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e,GAEjCA,EAAA,eAAO,cAAY,0BAA0B,IAZrCvB",
6
+ "names": ["CalldataContextLoader_exports", "__export", "CalldataContextLoader", "__toCommonJS", "import_device_management_kit", "import_inversify", "import_purify_ts", "import_calldataTypes", "import_configTypes", "import_proxyTypes", "import_ClearSignContext", "SUPPORTED_TYPES", "CalldataContextLoader", "dappDataSource", "tokenDataSource", "proxyDataSource", "loggerFactory", "input", "expectedTypes", "type", "to", "data", "selector", "chainId", "deviceModelId", "param", "result", "contexts", "address", "datasource", "liftMaybe", "ctxs", "implementationAddress", "params", "__decorateClass", "__decorateParam"]
7
7
  }
@@ -1,2 +1,2 @@
1
- "use strict";var n=require("@ledgerhq/device-management-kit"),d=require("purify-ts"),i=require("../../calldata/domain/CalldataContextLoader"),a=require("../../shared/model/ClearSignContext");describe("CalldataContextLoader",()=>{const r=vi.fn(),l=vi.fn(),p=vi.fn(),u={getCalldataDescriptors:l},x={getCalldataDescriptors:p},I={getProxyImplementationAddress:r},o=new i.CalldataContextLoader(u,x,I),c=[a.ClearSignContextType.TRANSACTION_INFO,a.ClearSignContextType.TRANSACTION_FIELD_DESCRIPTION,a.ClearSignContextType.PROXY_INFO,a.ClearSignContextType.ENUM];beforeEach(()=>{vi.resetAllMocks()}),describe("canHandle function",()=>{const e={to:"0x1234567890123456789012345678901234567890",data:"0xaf68b302000000000000000000000000000000000000000000000000000000000002",selector:"0xaf68b302",chainId:1,deviceModelId:n.DeviceModelId.NANO_X};it("should return true for valid input",()=>{expect(o.canHandle(e,c)).toBe(!0)}),it("should return false for invalid expected type",()=>{expect(o.canHandle(e,[a.ClearSignContextType.TOKEN])).toBe(!1),expect(o.canHandle(e,[a.ClearSignContextType.NFT])).toBe(!1),expect(o.canHandle(e,[a.ClearSignContextType.PROXY_INFO])).toBe(!1),expect(o.canHandle(e,[a.ClearSignContextType.ENUM])).toBe(!1),expect(o.canHandle(e,[a.ClearSignContextType.TRANSACTION_INFO])).toBe(!1)}),it.each([[null,"null input"],[void 0,"undefined input"],[{},"empty object"],["string","string input"],[123,"number input"]])("should return false for %s",(t,s)=>{expect(o.canHandle(t,c)).toBe(!1)}),it.each([[{...e,to:void 0},"missing to"],[{...e,data:void 0},"missing data"],[{...e,selector:void 0},"missing selector"],[{...e,chainId:void 0},"missing chainId"],[{...e,deviceModelId:void 0},"missing deviceModelId"]])("should return false for %s",(t,s)=>{expect(o.canHandle(t,c)).toBe(!1)}),it.each([[{...e,to:"invalid-hex"},"invalid to hex"],[{...e,to:"0x"},"empty to hex"],[{...e,data:"invalid-hex"},"invalid data hex"],[{...e,selector:"invalid-hex"},"invalid selector hex"],[{...e,selector:"0x"},"empty selector hex"]])("should return false for %s",(t,s)=>{expect(o.canHandle(t,c)).toBe(!1)}),it.each([[{...e,chainId:"1"},"string chainId"],[{...e,chainId:null},"null chainId"],[{...e,deviceModelId:n.DeviceModelId.NANO_S},"deviceModelId is NANO_S"]])("should return false for %s",(t,s)=>{expect(o.canHandle(t,c)).toBe(!1)})}),it("should return an error if data source fails",async()=>{r.mockResolvedValue((0,d.Left)(new Error("data source error"))),l.mockResolvedValue((0,d.Left)(new Error("data source error")));const e={to:"0x1234567890123456789012345678901234567890",chainId:3,data:"0xaf68b302000000000000000000000000000000000000000000000000000000000002",selector:"0xaf68b302",deviceModelId:n.DeviceModelId.NANO_X},t=await o.load(e);expect(l).toHaveBeenCalledWith({address:"0x1234567890123456789012345678901234567890",chainId:3,selector:"0xaf68b302",deviceModelId:n.DeviceModelId.NANO_X}),expect(t).toEqual([{type:a.ClearSignContextType.ERROR,error:new Error("[ContextModule] CalldataContextLoader: No calldata contexts found")}])}),it("should return the contexts on success",async()=>{l.mockResolvedValue((0,d.Right)([{type:a.ClearSignContextType.TRANSACTION_INFO,payload:"1234567890"},{type:a.ClearSignContextType.TRANSACTION_FIELD_DESCRIPTION,payload:"deadbeef"}])),r.mockResolvedValue((0,d.Left)(new Error("data source error")));const e={to:"0x1234567890123456789012345678901234567890",chainId:3,data:"0xaf68b302000000000000000000000000000000000000000000000000000000000002",selector:"0xaf68b302",deviceModelId:n.DeviceModelId.NANO_X},t=await o.load(e);expect(t).toEqual([{type:a.ClearSignContextType.TRANSACTION_INFO,payload:"1234567890"},{type:a.ClearSignContextType.TRANSACTION_FIELD_DESCRIPTION,payload:"deadbeef"}])}),it("should return the proxy delegate call context on success",async()=>{l.mockResolvedValueOnce((0,d.Right)([])),l.mockResolvedValue((0,d.Right)([{type:a.ClearSignContextType.TRANSACTION_INFO,payload:"1234567890"},{type:a.ClearSignContextType.TRANSACTION_FIELD_DESCRIPTION,payload:"deadbeef"}])),r.mockResolvedValue((0,d.Right)({implementationAddress:"0x1234567890abcdef",signedDescriptor:"0x1234567890abcdef"}));const e={to:"0x1234567890123456789012345678901234567890",chainId:3,data:"0xaf68b302000000000000000000000000000000000000000000000000000000000002",selector:"0xaf68b302",deviceModelId:n.DeviceModelId.NANO_X},t=await o.load(e);expect(t).toEqual([{type:a.ClearSignContextType.PROXY_INFO,payload:"0x"},{type:a.ClearSignContextType.TRANSACTION_INFO,payload:"1234567890"},{type:a.ClearSignContextType.TRANSACTION_FIELD_DESCRIPTION,payload:"deadbeef"}])}),it("should return an error when proxy delegate call succeeds but transaction descriptors for resolved address fail",async()=>{l.mockResolvedValueOnce((0,d.Right)([])),l.mockResolvedValueOnce((0,d.Left)(new Error("data source error"))),r.mockResolvedValue((0,d.Right)({implementationAddress:"0xResolvedAddress",signedDescriptor:"0x1234567890abcdef"}));const e={to:"0x1234567890123456789012345678901234567890",chainId:3,data:"0xaf68b302000000000000000000000000000000000000000000000000000000000002",selector:"0xaf68b302",deviceModelId:n.DeviceModelId.NANO_X},t=await o.load(e);expect(l).toHaveBeenCalledTimes(2),expect(l).toHaveBeenNthCalledWith(2,{address:"0xResolvedAddress",chainId:3,selector:"0xaf68b302",deviceModelId:n.DeviceModelId.NANO_X}),expect(t).toEqual([{type:a.ClearSignContextType.ERROR,error:new Error("[ContextModule] CalldataContextLoader: No calldata contexts found")}])})});
1
+ "use strict";var l=require("@ledgerhq/device-management-kit"),d=require("purify-ts"),i=require("../../calldata/domain/CalldataContextLoader"),a=require("../../shared/model/ClearSignContext");const I=()=>({debug:vi.fn(),info:vi.fn(),warn:vi.fn(),error:vi.fn(),subscribers:[]});describe("CalldataContextLoader",()=>{const r=vi.fn(),n=vi.fn(),p=vi.fn(),u={getCalldataDescriptors:n},x={getCalldataDescriptors:p},f={getProxyImplementationAddress:r},o=new i.CalldataContextLoader(u,x,f,I),c=[a.ClearSignContextType.TRANSACTION_INFO,a.ClearSignContextType.TRANSACTION_FIELD_DESCRIPTION,a.ClearSignContextType.PROXY_INFO,a.ClearSignContextType.ENUM];beforeEach(()=>{vi.resetAllMocks()}),describe("canHandle function",()=>{const e={to:"0x1234567890123456789012345678901234567890",data:"0xaf68b302000000000000000000000000000000000000000000000000000000000002",selector:"0xaf68b302",chainId:1,deviceModelId:l.DeviceModelId.NANO_X};it("should return true for valid input",()=>{expect(o.canHandle(e,c)).toBe(!0)}),it("should return false for invalid expected type",()=>{expect(o.canHandle(e,[a.ClearSignContextType.TOKEN])).toBe(!1),expect(o.canHandle(e,[a.ClearSignContextType.NFT])).toBe(!1),expect(o.canHandle(e,[a.ClearSignContextType.PROXY_INFO])).toBe(!1),expect(o.canHandle(e,[a.ClearSignContextType.ENUM])).toBe(!1),expect(o.canHandle(e,[a.ClearSignContextType.TRANSACTION_INFO])).toBe(!1)}),it.each([[null,"null input"],[void 0,"undefined input"],[{},"empty object"],["string","string input"],[123,"number input"]])("should return false for %s",(t,s)=>{expect(o.canHandle(t,c)).toBe(!1)}),it.each([[{...e,to:void 0},"missing to"],[{...e,data:void 0},"missing data"],[{...e,selector:void 0},"missing selector"],[{...e,chainId:void 0},"missing chainId"],[{...e,deviceModelId:void 0},"missing deviceModelId"]])("should return false for %s",(t,s)=>{expect(o.canHandle(t,c)).toBe(!1)}),it.each([[{...e,to:"invalid-hex"},"invalid to hex"],[{...e,to:"0x"},"empty to hex"],[{...e,data:"invalid-hex"},"invalid data hex"],[{...e,selector:"invalid-hex"},"invalid selector hex"],[{...e,selector:"0x"},"empty selector hex"]])("should return false for %s",(t,s)=>{expect(o.canHandle(t,c)).toBe(!1)}),it.each([[{...e,chainId:"1"},"string chainId"],[{...e,chainId:null},"null chainId"],[{...e,deviceModelId:l.DeviceModelId.NANO_S},"deviceModelId is NANO_S"]])("should return false for %s",(t,s)=>{expect(o.canHandle(t,c)).toBe(!1)})}),it("should return an error if data source fails",async()=>{r.mockResolvedValue((0,d.Left)(new Error("data source error"))),n.mockResolvedValue((0,d.Left)(new Error("data source error")));const e={to:"0x1234567890123456789012345678901234567890",chainId:3,data:"0xaf68b302000000000000000000000000000000000000000000000000000000000002",selector:"0xaf68b302",deviceModelId:l.DeviceModelId.NANO_X},t=await o.load(e);expect(n).toHaveBeenCalledWith({address:"0x1234567890123456789012345678901234567890",chainId:3,selector:"0xaf68b302",deviceModelId:l.DeviceModelId.NANO_X}),expect(t).toEqual([{type:a.ClearSignContextType.ERROR,error:new Error("[ContextModule] CalldataContextLoader: No calldata contexts found")}])}),it("should return the contexts on success",async()=>{n.mockResolvedValue((0,d.Right)([{type:a.ClearSignContextType.TRANSACTION_INFO,payload:"1234567890"},{type:a.ClearSignContextType.TRANSACTION_FIELD_DESCRIPTION,payload:"deadbeef"}])),r.mockResolvedValue((0,d.Left)(new Error("data source error")));const e={to:"0x1234567890123456789012345678901234567890",chainId:3,data:"0xaf68b302000000000000000000000000000000000000000000000000000000000002",selector:"0xaf68b302",deviceModelId:l.DeviceModelId.NANO_X},t=await o.load(e);expect(t).toEqual([{type:a.ClearSignContextType.TRANSACTION_INFO,payload:"1234567890"},{type:a.ClearSignContextType.TRANSACTION_FIELD_DESCRIPTION,payload:"deadbeef"}])}),it("should return the proxy delegate call context on success",async()=>{n.mockResolvedValueOnce((0,d.Right)([])),n.mockResolvedValue((0,d.Right)([{type:a.ClearSignContextType.TRANSACTION_INFO,payload:"1234567890"},{type:a.ClearSignContextType.TRANSACTION_FIELD_DESCRIPTION,payload:"deadbeef"}])),r.mockResolvedValue((0,d.Right)({implementationAddress:"0x1234567890abcdef",signedDescriptor:"0x1234567890abcdef"}));const e={to:"0x1234567890123456789012345678901234567890",chainId:3,data:"0xaf68b302000000000000000000000000000000000000000000000000000000000002",selector:"0xaf68b302",deviceModelId:l.DeviceModelId.NANO_X},t=await o.load(e);expect(t).toEqual([{type:a.ClearSignContextType.PROXY_INFO,payload:"0x"},{type:a.ClearSignContextType.TRANSACTION_INFO,payload:"1234567890"},{type:a.ClearSignContextType.TRANSACTION_FIELD_DESCRIPTION,payload:"deadbeef"}])}),it("should return an error when proxy delegate call succeeds but transaction descriptors for resolved address fail",async()=>{n.mockResolvedValueOnce((0,d.Right)([])),n.mockResolvedValueOnce((0,d.Left)(new Error("data source error"))),r.mockResolvedValue((0,d.Right)({implementationAddress:"0xResolvedAddress",signedDescriptor:"0x1234567890abcdef"}));const e={to:"0x1234567890123456789012345678901234567890",chainId:3,data:"0xaf68b302000000000000000000000000000000000000000000000000000000000002",selector:"0xaf68b302",deviceModelId:l.DeviceModelId.NANO_X},t=await o.load(e);expect(n).toHaveBeenCalledTimes(2),expect(n).toHaveBeenNthCalledWith(2,{address:"0xResolvedAddress",chainId:3,selector:"0xaf68b302",deviceModelId:l.DeviceModelId.NANO_X}),expect(t).toEqual([{type:a.ClearSignContextType.ERROR,error:new Error("[ContextModule] CalldataContextLoader: No calldata contexts found")}])})});
2
2
  //# sourceMappingURL=CalldataContextLoader.test.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../../src/calldata/domain/CalldataContextLoader.test.ts"],
4
- "sourcesContent": ["import { DeviceModelId } from \"@ledgerhq/device-management-kit\";\nimport { Left, Right } from \"purify-ts\";\n\nimport type { CalldataDescriptorDataSource } from \"@/calldata/data/CalldataDescriptorDataSource\";\nimport {\n type CalldataContextInput,\n CalldataContextLoader,\n} from \"@/calldata/domain/CalldataContextLoader\";\nimport type { ProxyDataSource } from \"@/proxy/data/ProxyDataSource\";\nimport { ClearSignContextType } from \"@/shared/model/ClearSignContext\";\n\ndescribe(\"CalldataContextLoader\", () => {\n const getProxyImplementationAddress = vi.fn();\n const getDappDescriptorsMock = vi.fn();\n const getTokenDescriptorsMock = vi.fn();\n const mockDappDataSource: CalldataDescriptorDataSource = {\n getCalldataDescriptors: getDappDescriptorsMock,\n };\n const mockTokenDataSource: CalldataDescriptorDataSource = {\n getCalldataDescriptors: getTokenDescriptorsMock,\n };\n const mockProxyDatasource: ProxyDataSource = {\n getProxyImplementationAddress: getProxyImplementationAddress,\n };\n const loader = new CalldataContextLoader(\n mockDappDataSource,\n mockTokenDataSource,\n mockProxyDatasource,\n );\n const SUPPORTED_TYPES: ClearSignContextType[] = [\n ClearSignContextType.TRANSACTION_INFO,\n ClearSignContextType.TRANSACTION_FIELD_DESCRIPTION,\n ClearSignContextType.PROXY_INFO,\n ClearSignContextType.ENUM,\n ];\n\n beforeEach(() => {\n vi.resetAllMocks();\n });\n\n describe(\"canHandle function\", () => {\n const validInput: CalldataContextInput = {\n to: \"0x1234567890123456789012345678901234567890\",\n data: \"0xaf68b302000000000000000000000000000000000000000000000000000000000002\",\n selector: \"0xaf68b302\",\n chainId: 1,\n deviceModelId: DeviceModelId.NANO_X,\n };\n\n it(\"should return true for valid input\", () => {\n expect(loader.canHandle(validInput, SUPPORTED_TYPES)).toBe(true);\n });\n\n it(\"should return false for invalid expected type\", () => {\n expect(loader.canHandle(validInput, [ClearSignContextType.TOKEN])).toBe(\n false,\n );\n expect(loader.canHandle(validInput, [ClearSignContextType.NFT])).toBe(\n false,\n );\n expect(\n loader.canHandle(validInput, [ClearSignContextType.PROXY_INFO]),\n ).toBe(false);\n expect(loader.canHandle(validInput, [ClearSignContextType.ENUM])).toBe(\n false,\n );\n expect(\n loader.canHandle(validInput, [ClearSignContextType.TRANSACTION_INFO]),\n ).toBe(false);\n });\n\n it.each([\n [null, \"null input\"],\n [undefined, \"undefined input\"],\n [{}, \"empty object\"],\n [\"string\", \"string input\"],\n [123, \"number input\"],\n ])(\"should return false for %s\", (input, _description) => {\n expect(loader.canHandle(input, SUPPORTED_TYPES)).toBe(false);\n });\n\n it.each([\n [{ ...validInput, to: undefined }, \"missing to\"],\n [{ ...validInput, data: undefined }, \"missing data\"],\n [{ ...validInput, selector: undefined }, \"missing selector\"],\n [{ ...validInput, chainId: undefined }, \"missing chainId\"],\n [{ ...validInput, deviceModelId: undefined }, \"missing deviceModelId\"],\n ])(\"should return false for %s\", (input, _description) => {\n expect(loader.canHandle(input, SUPPORTED_TYPES)).toBe(false);\n });\n\n it.each([\n [{ ...validInput, to: \"invalid-hex\" }, \"invalid to hex\"],\n [{ ...validInput, to: \"0x\" }, \"empty to hex\"],\n [{ ...validInput, data: \"invalid-hex\" }, \"invalid data hex\"],\n [{ ...validInput, selector: \"invalid-hex\" }, \"invalid selector hex\"],\n [{ ...validInput, selector: \"0x\" }, \"empty selector hex\"],\n ])(\"should return false for %s\", (input, _description) => {\n expect(loader.canHandle(input, SUPPORTED_TYPES)).toBe(false);\n });\n\n it.each([\n [{ ...validInput, chainId: \"1\" }, \"string chainId\"],\n [{ ...validInput, chainId: null }, \"null chainId\"],\n [\n { ...validInput, deviceModelId: DeviceModelId.NANO_S },\n \"deviceModelId is NANO_S\",\n ],\n ])(\"should return false for %s\", (input, _description) => {\n expect(loader.canHandle(input, SUPPORTED_TYPES)).toBe(false);\n });\n });\n\n it(\"should return an error if data source fails\", async () => {\n // GIVEN\n getProxyImplementationAddress.mockResolvedValue(\n Left(new Error(\"data source error\")),\n );\n getDappDescriptorsMock.mockResolvedValue(\n Left(new Error(\"data source error\")),\n );\n const input = {\n to: \"0x1234567890123456789012345678901234567890\",\n chainId: 3,\n data: \"0xaf68b302000000000000000000000000000000000000000000000000000000000002\",\n selector: \"0xaf68b302\",\n deviceModelId: DeviceModelId.NANO_X,\n } as CalldataContextInput;\n\n // WHEN\n const result = await loader.load(input);\n\n // THEN\n expect(getDappDescriptorsMock).toHaveBeenCalledWith({\n address: \"0x1234567890123456789012345678901234567890\",\n chainId: 3,\n selector: \"0xaf68b302\",\n deviceModelId: DeviceModelId.NANO_X,\n });\n expect(result).toEqual([\n {\n type: ClearSignContextType.ERROR,\n error: new Error(\n \"[ContextModule] CalldataContextLoader: No calldata contexts found\",\n ),\n },\n ]);\n });\n\n it(\"should return the contexts on success\", async () => {\n // GIVEN\n getDappDescriptorsMock.mockResolvedValue(\n Right([\n {\n type: ClearSignContextType.TRANSACTION_INFO,\n payload: \"1234567890\",\n },\n {\n type: ClearSignContextType.TRANSACTION_FIELD_DESCRIPTION,\n payload: \"deadbeef\",\n },\n ]),\n );\n getProxyImplementationAddress.mockResolvedValue(\n Left(new Error(\"data source error\")),\n );\n const input = {\n to: \"0x1234567890123456789012345678901234567890\",\n chainId: 3,\n data: \"0xaf68b302000000000000000000000000000000000000000000000000000000000002\",\n selector: \"0xaf68b302\",\n deviceModelId: DeviceModelId.NANO_X,\n } as CalldataContextInput;\n\n // WHEN\n const result = await loader.load(input);\n\n // THEN\n expect(result).toEqual([\n {\n type: ClearSignContextType.TRANSACTION_INFO,\n payload: \"1234567890\",\n },\n {\n type: ClearSignContextType.TRANSACTION_FIELD_DESCRIPTION,\n payload: \"deadbeef\",\n },\n ]);\n });\n\n it(\"should return the proxy delegate call context on success\", async () => {\n // GIVEN\n getDappDescriptorsMock.mockResolvedValueOnce(Right([])); // No transaction descriptors found for the first call\n getDappDescriptorsMock.mockResolvedValue(\n Right([\n {\n type: ClearSignContextType.TRANSACTION_INFO,\n payload: \"1234567890\",\n },\n {\n type: ClearSignContextType.TRANSACTION_FIELD_DESCRIPTION,\n payload: \"deadbeef\",\n },\n ]),\n );\n getProxyImplementationAddress.mockResolvedValue(\n Right({\n implementationAddress: \"0x1234567890abcdef\",\n signedDescriptor: \"0x1234567890abcdef\",\n }),\n );\n const input = {\n to: \"0x1234567890123456789012345678901234567890\",\n chainId: 3,\n data: \"0xaf68b302000000000000000000000000000000000000000000000000000000000002\",\n selector: \"0xaf68b302\",\n deviceModelId: DeviceModelId.NANO_X,\n } as CalldataContextInput;\n\n // WHEN\n const result = await loader.load(input);\n\n // THEN\n expect(result).toEqual([\n {\n type: ClearSignContextType.PROXY_INFO,\n payload: \"0x\",\n },\n {\n type: ClearSignContextType.TRANSACTION_INFO,\n payload: \"1234567890\",\n },\n {\n type: ClearSignContextType.TRANSACTION_FIELD_DESCRIPTION,\n payload: \"deadbeef\",\n },\n ]);\n });\n\n it(\"should return an error when proxy delegate call succeeds but transaction descriptors for resolved address fail\", async () => {\n // GIVEN\n getDappDescriptorsMock.mockResolvedValueOnce(Right([])); // No transaction descriptors found for the first call\n getDappDescriptorsMock.mockResolvedValueOnce(\n Left(new Error(\"data source error\")),\n ); // Second call fails\n getProxyImplementationAddress.mockResolvedValue(\n Right({\n implementationAddress: \"0xResolvedAddress\",\n signedDescriptor: \"0x1234567890abcdef\",\n }),\n );\n const input = {\n to: \"0x1234567890123456789012345678901234567890\",\n chainId: 3,\n data: \"0xaf68b302000000000000000000000000000000000000000000000000000000000002\",\n selector: \"0xaf68b302\",\n deviceModelId: DeviceModelId.NANO_X,\n } as CalldataContextInput;\n\n // WHEN\n const result = await loader.load(input);\n\n // THEN\n expect(getDappDescriptorsMock).toHaveBeenCalledTimes(2);\n expect(getDappDescriptorsMock).toHaveBeenNthCalledWith(2, {\n address: \"0xResolvedAddress\",\n chainId: 3,\n selector: \"0xaf68b302\",\n deviceModelId: DeviceModelId.NANO_X,\n });\n expect(result).toEqual([\n {\n type: ClearSignContextType.ERROR,\n error: new Error(\n \"[ContextModule] CalldataContextLoader: No calldata contexts found\",\n ),\n },\n ]);\n });\n});\n"],
5
- "mappings": "aAAA,IAAAA,EAA8B,2CAC9BC,EAA4B,qBAG5BC,EAGO,mDAEPC,EAAqC,2CAErC,SAAS,wBAAyB,IAAM,CACtC,MAAMC,EAAgC,GAAG,GAAG,EACtCC,EAAyB,GAAG,GAAG,EAC/BC,EAA0B,GAAG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,GAAI,6CACJ,QAAS,EACT,KAAM,yEACN,SAAU,aACV,cAAe,gBAAc,MAC/B,EAGME,EAAS,MAAML,EAAO,KAAKG,CAAK,EAGtC,OAAOE,CAAM,EAAE,QAAQ,CACrB,CACE,KAAM,uBAAqB,WAC3B,QAAS,IACX,EACA,CACE,KAAM,uBAAqB,iBAC3B,QAAS,YACX,EACA,CACE,KAAM,uBAAqB,8BAC3B,QAAS,UACX,CACF,CAAC,CACH,CAAC,EAED,GAAG,iHAAkH,SAAY,CAE/HV,EAAuB,yBAAsB,SAAM,CAAC,CAAC,CAAC,EACtDA,EAAuB,yBACrB,QAAK,IAAI,MAAM,mBAAmB,CAAC,CACrC,EACAD,EAA8B,qBAC5B,SAAM,CACJ,sBAAuB,oBACvB,iBAAkB,oBACpB,CAAC,CACH,EACA,MAAMS,EAAQ,CACZ,GAAI,6CACJ,QAAS,EACT,KAAM,yEACN,SAAU,aACV,cAAe,gBAAc,MAC/B,EAGME,EAAS,MAAML,EAAO,KAAKG,CAAK,EAGtC,OAAOR,CAAsB,EAAE,sBAAsB,CAAC,EACtD,OAAOA,CAAsB,EAAE,wBAAwB,EAAG,CACxD,QAAS,oBACT,QAAS,EACT,SAAU,aACV,cAAe,gBAAc,MAC/B,CAAC,EACD,OAAOU,CAAM,EAAE,QAAQ,CACrB,CACE,KAAM,uBAAqB,MAC3B,MAAO,IAAI,MACT,mEACF,CACF,CACF,CAAC,CACH,CAAC,CACH,CAAC",
6
- "names": ["import_device_management_kit", "import_purify_ts", "import_CalldataContextLoader", "import_ClearSignContext", "getProxyImplementationAddress", "getDappDescriptorsMock", "getTokenDescriptorsMock", "mockDappDataSource", "mockTokenDataSource", "mockProxyDatasource", "loader", "SUPPORTED_TYPES", "validInput", "input", "_description", "result"]
4
+ "sourcesContent": ["import { DeviceModelId } from \"@ledgerhq/device-management-kit\";\nimport { Left, Right } from \"purify-ts\";\n\nimport type { CalldataDescriptorDataSource } from \"@/calldata/data/CalldataDescriptorDataSource\";\nimport {\n type CalldataContextInput,\n CalldataContextLoader,\n} from \"@/calldata/domain/CalldataContextLoader\";\nimport type { ProxyDataSource } from \"@/proxy/data/ProxyDataSource\";\nimport { ClearSignContextType } from \"@/shared/model/ClearSignContext\";\n\nconst mockLoggerFactory = () => ({\n debug: vi.fn(),\n info: vi.fn(),\n warn: vi.fn(),\n error: vi.fn(),\n subscribers: [],\n});\n\ndescribe(\"CalldataContextLoader\", () => {\n const getProxyImplementationAddress = vi.fn();\n const getDappDescriptorsMock = vi.fn();\n const getTokenDescriptorsMock = vi.fn();\n const mockDappDataSource: CalldataDescriptorDataSource = {\n getCalldataDescriptors: getDappDescriptorsMock,\n };\n const mockTokenDataSource: CalldataDescriptorDataSource = {\n getCalldataDescriptors: getTokenDescriptorsMock,\n };\n const mockProxyDatasource: ProxyDataSource = {\n getProxyImplementationAddress: getProxyImplementationAddress,\n };\n const loader = new CalldataContextLoader(\n mockDappDataSource,\n mockTokenDataSource,\n mockProxyDatasource,\n mockLoggerFactory,\n );\n const SUPPORTED_TYPES: ClearSignContextType[] = [\n ClearSignContextType.TRANSACTION_INFO,\n ClearSignContextType.TRANSACTION_FIELD_DESCRIPTION,\n ClearSignContextType.PROXY_INFO,\n ClearSignContextType.ENUM,\n ];\n\n beforeEach(() => {\n vi.resetAllMocks();\n });\n\n describe(\"canHandle function\", () => {\n const validInput: CalldataContextInput = {\n to: \"0x1234567890123456789012345678901234567890\",\n data: \"0xaf68b302000000000000000000000000000000000000000000000000000000000002\",\n selector: \"0xaf68b302\",\n chainId: 1,\n deviceModelId: DeviceModelId.NANO_X,\n };\n\n it(\"should return true for valid input\", () => {\n expect(loader.canHandle(validInput, SUPPORTED_TYPES)).toBe(true);\n });\n\n it(\"should return false for invalid expected type\", () => {\n expect(loader.canHandle(validInput, [ClearSignContextType.TOKEN])).toBe(\n false,\n );\n expect(loader.canHandle(validInput, [ClearSignContextType.NFT])).toBe(\n false,\n );\n expect(\n loader.canHandle(validInput, [ClearSignContextType.PROXY_INFO]),\n ).toBe(false);\n expect(loader.canHandle(validInput, [ClearSignContextType.ENUM])).toBe(\n false,\n );\n expect(\n loader.canHandle(validInput, [ClearSignContextType.TRANSACTION_INFO]),\n ).toBe(false);\n });\n\n it.each([\n [null, \"null input\"],\n [undefined, \"undefined input\"],\n [{}, \"empty object\"],\n [\"string\", \"string input\"],\n [123, \"number input\"],\n ])(\"should return false for %s\", (input, _description) => {\n expect(loader.canHandle(input, SUPPORTED_TYPES)).toBe(false);\n });\n\n it.each([\n [{ ...validInput, to: undefined }, \"missing to\"],\n [{ ...validInput, data: undefined }, \"missing data\"],\n [{ ...validInput, selector: undefined }, \"missing selector\"],\n [{ ...validInput, chainId: undefined }, \"missing chainId\"],\n [{ ...validInput, deviceModelId: undefined }, \"missing deviceModelId\"],\n ])(\"should return false for %s\", (input, _description) => {\n expect(loader.canHandle(input, SUPPORTED_TYPES)).toBe(false);\n });\n\n it.each([\n [{ ...validInput, to: \"invalid-hex\" }, \"invalid to hex\"],\n [{ ...validInput, to: \"0x\" }, \"empty to hex\"],\n [{ ...validInput, data: \"invalid-hex\" }, \"invalid data hex\"],\n [{ ...validInput, selector: \"invalid-hex\" }, \"invalid selector hex\"],\n [{ ...validInput, selector: \"0x\" }, \"empty selector hex\"],\n ])(\"should return false for %s\", (input, _description) => {\n expect(loader.canHandle(input, SUPPORTED_TYPES)).toBe(false);\n });\n\n it.each([\n [{ ...validInput, chainId: \"1\" }, \"string chainId\"],\n [{ ...validInput, chainId: null }, \"null chainId\"],\n [\n { ...validInput, deviceModelId: DeviceModelId.NANO_S },\n \"deviceModelId is NANO_S\",\n ],\n ])(\"should return false for %s\", (input, _description) => {\n expect(loader.canHandle(input, SUPPORTED_TYPES)).toBe(false);\n });\n });\n\n it(\"should return an error if data source fails\", async () => {\n // GIVEN\n getProxyImplementationAddress.mockResolvedValue(\n Left(new Error(\"data source error\")),\n );\n getDappDescriptorsMock.mockResolvedValue(\n Left(new Error(\"data source error\")),\n );\n const input = {\n to: \"0x1234567890123456789012345678901234567890\",\n chainId: 3,\n data: \"0xaf68b302000000000000000000000000000000000000000000000000000000000002\",\n selector: \"0xaf68b302\",\n deviceModelId: DeviceModelId.NANO_X,\n } as CalldataContextInput;\n\n // WHEN\n const result = await loader.load(input);\n\n // THEN\n expect(getDappDescriptorsMock).toHaveBeenCalledWith({\n address: \"0x1234567890123456789012345678901234567890\",\n chainId: 3,\n selector: \"0xaf68b302\",\n deviceModelId: DeviceModelId.NANO_X,\n });\n expect(result).toEqual([\n {\n type: ClearSignContextType.ERROR,\n error: new Error(\n \"[ContextModule] CalldataContextLoader: No calldata contexts found\",\n ),\n },\n ]);\n });\n\n it(\"should return the contexts on success\", async () => {\n // GIVEN\n getDappDescriptorsMock.mockResolvedValue(\n Right([\n {\n type: ClearSignContextType.TRANSACTION_INFO,\n payload: \"1234567890\",\n },\n {\n type: ClearSignContextType.TRANSACTION_FIELD_DESCRIPTION,\n payload: \"deadbeef\",\n },\n ]),\n );\n getProxyImplementationAddress.mockResolvedValue(\n Left(new Error(\"data source error\")),\n );\n const input = {\n to: \"0x1234567890123456789012345678901234567890\",\n chainId: 3,\n data: \"0xaf68b302000000000000000000000000000000000000000000000000000000000002\",\n selector: \"0xaf68b302\",\n deviceModelId: DeviceModelId.NANO_X,\n } as CalldataContextInput;\n\n // WHEN\n const result = await loader.load(input);\n\n // THEN\n expect(result).toEqual([\n {\n type: ClearSignContextType.TRANSACTION_INFO,\n payload: \"1234567890\",\n },\n {\n type: ClearSignContextType.TRANSACTION_FIELD_DESCRIPTION,\n payload: \"deadbeef\",\n },\n ]);\n });\n\n it(\"should return the proxy delegate call context on success\", async () => {\n // GIVEN\n getDappDescriptorsMock.mockResolvedValueOnce(Right([])); // No transaction descriptors found for the first call\n getDappDescriptorsMock.mockResolvedValue(\n Right([\n {\n type: ClearSignContextType.TRANSACTION_INFO,\n payload: \"1234567890\",\n },\n {\n type: ClearSignContextType.TRANSACTION_FIELD_DESCRIPTION,\n payload: \"deadbeef\",\n },\n ]),\n );\n getProxyImplementationAddress.mockResolvedValue(\n Right({\n implementationAddress: \"0x1234567890abcdef\",\n signedDescriptor: \"0x1234567890abcdef\",\n }),\n );\n const input = {\n to: \"0x1234567890123456789012345678901234567890\",\n chainId: 3,\n data: \"0xaf68b302000000000000000000000000000000000000000000000000000000000002\",\n selector: \"0xaf68b302\",\n deviceModelId: DeviceModelId.NANO_X,\n } as CalldataContextInput;\n\n // WHEN\n const result = await loader.load(input);\n\n // THEN\n expect(result).toEqual([\n {\n type: ClearSignContextType.PROXY_INFO,\n payload: \"0x\",\n },\n {\n type: ClearSignContextType.TRANSACTION_INFO,\n payload: \"1234567890\",\n },\n {\n type: ClearSignContextType.TRANSACTION_FIELD_DESCRIPTION,\n payload: \"deadbeef\",\n },\n ]);\n });\n\n it(\"should return an error when proxy delegate call succeeds but transaction descriptors for resolved address fail\", async () => {\n // GIVEN\n getDappDescriptorsMock.mockResolvedValueOnce(Right([])); // No transaction descriptors found for the first call\n getDappDescriptorsMock.mockResolvedValueOnce(\n Left(new Error(\"data source error\")),\n ); // Second call fails\n getProxyImplementationAddress.mockResolvedValue(\n Right({\n implementationAddress: \"0xResolvedAddress\",\n signedDescriptor: \"0x1234567890abcdef\",\n }),\n );\n const input = {\n to: \"0x1234567890123456789012345678901234567890\",\n chainId: 3,\n data: \"0xaf68b302000000000000000000000000000000000000000000000000000000000002\",\n selector: \"0xaf68b302\",\n deviceModelId: DeviceModelId.NANO_X,\n } as CalldataContextInput;\n\n // WHEN\n const result = await loader.load(input);\n\n // THEN\n expect(getDappDescriptorsMock).toHaveBeenCalledTimes(2);\n expect(getDappDescriptorsMock).toHaveBeenNthCalledWith(2, {\n address: \"0xResolvedAddress\",\n chainId: 3,\n selector: \"0xaf68b302\",\n deviceModelId: DeviceModelId.NANO_X,\n });\n expect(result).toEqual([\n {\n type: ClearSignContextType.ERROR,\n error: new Error(\n \"[ContextModule] CalldataContextLoader: No calldata contexts found\",\n ),\n },\n ]);\n });\n});\n"],
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C,CACH,CAAC",
6
+ "names": ["import_device_management_kit", "import_purify_ts", "import_CalldataContextLoader", "import_ClearSignContext", "mockLoggerFactory", "getProxyImplementationAddress", "getDappDescriptorsMock", "getTokenDescriptorsMock", "mockDappDataSource", "mockTokenDataSource", "mockProxyDatasource", "loader", "SUPPORTED_TYPES", "validInput", "input", "_description", "result"]
7
7
  }
@@ -1,2 +1,2 @@
1
- "use strict";var g=Object.defineProperty;var e=Object.getOwnPropertyDescriptor;var c=Object.getOwnPropertyNames;var y=Object.prototype.hasOwnProperty;var T=(n,o)=>{for(var f in o)g(n,f,{get:o[f],enumerable:!0})},b=(n,o,f,r)=>{if(o&&typeof o=="object"||typeof o=="function")for(let i of c(o))!y.call(n,i)&&i!==f&&g(n,i,{get:()=>o[i],enumerable:!(r=e(o,i))||r.enumerable});return n};var k=n=>b(g({},"__esModule",{value:!0}),n);var m={};T(m,{configTypes:()=>l});module.exports=k(m);const l={Config:Symbol.for("config"),OriginToken:Symbol.for("originToken")};0&&(module.exports={configTypes});
1
+ "use strict";var g=Object.defineProperty;var i=Object.getOwnPropertyDescriptor;var c=Object.getOwnPropertyNames;var f=Object.prototype.hasOwnProperty;var y=(e,o)=>{for(var r in o)g(e,r,{get:o[r],enumerable:!0})},l=(e,o,r,t)=>{if(o&&typeof o=="object"||typeof o=="function")for(let n of c(o))!f.call(e,n)&&n!==r&&g(e,n,{get:()=>o[n],enumerable:!(t=i(o,n))||t.enumerable});return e};var b=e=>l(g({},"__esModule",{value:!0}),e);var x={};y(x,{configTypes:()=>m});module.exports=b(x);const m={Config:Symbol.for("config"),OriginToken:Symbol.for("originToken"),ContextModuleLoggerFactory:Symbol.for("contextModuleLoggerFactory")};0&&(module.exports={configTypes});
2
2
  //# sourceMappingURL=configTypes.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../../src/config/di/configTypes.ts"],
4
- "sourcesContent": ["export const configTypes = {\n Config: Symbol.for(\"config\"),\n OriginToken: Symbol.for(\"originToken\"),\n};\n"],
5
- "mappings": "yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,iBAAAE,IAAA,eAAAC,EAAAH,GAAO,MAAME,EAAc,CACzB,OAAQ,OAAO,IAAI,QAAQ,EAC3B,YAAa,OAAO,IAAI,aAAa,CACvC",
4
+ "sourcesContent": ["export const configTypes = {\n Config: Symbol.for(\"config\"),\n OriginToken: Symbol.for(\"originToken\"),\n ContextModuleLoggerFactory: Symbol.for(\"contextModuleLoggerFactory\"),\n};\n"],
5
+ "mappings": "yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,iBAAAE,IAAA,eAAAC,EAAAH,GAAO,MAAME,EAAc,CACzB,OAAQ,OAAO,IAAI,QAAQ,EAC3B,YAAa,OAAO,IAAI,aAAa,EACrC,2BAA4B,OAAO,IAAI,4BAA4B,CACrE",
6
6
  "names": ["configTypes_exports", "__export", "configTypes", "__toCommonJS"]
7
7
  }
@@ -1,2 +1,2 @@
1
- "use strict";var n=Object.defineProperty;var i=Object.getOwnPropertyDescriptor;var s=Object.getOwnPropertyNames;var p=Object.prototype.hasOwnProperty;var u=(t,o,g,e)=>{if(o&&typeof o=="object"||typeof o=="function")for(let r of s(o))!p.call(t,r)&&r!==g&&n(t,r,{get:()=>o[r],enumerable:!(e=i(o,r))||e.enumerable});return t};var x=t=>u(n({},"__esModule",{value:!0}),t);var C={};module.exports=x(C);
1
+ "use strict";var g=Object.defineProperty;var n=Object.getOwnPropertyDescriptor;var s=Object.getOwnPropertyNames;var c=Object.prototype.hasOwnProperty;var l=(e,r,i,t)=>{if(r&&typeof r=="object"||typeof r=="function")for(let o of s(r))!c.call(e,o)&&o!==i&&g(e,o,{get:()=>r[o],enumerable:!(t=n(r,o))||t.enumerable});return e};var p=e=>l(g({},"__esModule",{value:!0}),e);var u={};module.exports=p(u);
2
2
  //# sourceMappingURL=ContextModuleBuildArgs.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../../src/config/model/ContextModuleBuildArgs.ts"],
4
- "sourcesContent": ["export type ContextModuleConstructorArgs = {\n originToken?: string;\n};\n"],
4
+ "sourcesContent": ["import { type LoggerPublisherService } from \"@ledgerhq/device-management-kit\";\n\nexport type ContextModuleConstructorArgs = {\n originToken?: string;\n loggerFactory: (tag: string) => LoggerPublisherService;\n};\n"],
5
5
  "mappings": "+WAAA,IAAAA,EAAA,kBAAAC,EAAAD",
6
6
  "names": ["ContextModuleBuildArgs_exports", "__toCommonJS"]
7
7
  }
@@ -1,2 +1,2 @@
1
- "use strict";var r=Object.defineProperty;var d=Object.getOwnPropertyDescriptor;var C=Object.getOwnPropertyNames;var l=Object.prototype.hasOwnProperty;var x=(o,e,n,a)=>{if(e&&typeof e=="object"||typeof e=="function")for(let t of C(e))!l.call(o,t)&&t!==n&&r(o,t,{get:()=>e[t],enumerable:!(a=d(e,t))||a.enumerable});return o};var i=o=>x(r({},"__esModule",{value:!0}),o);var p={};module.exports=i(p);
1
+ "use strict";var r=Object.defineProperty;var n=Object.getOwnPropertyDescriptor;var l=Object.getOwnPropertyNames;var C=Object.prototype.hasOwnProperty;var i=(o,e,d,a)=>{if(e&&typeof e=="object"||typeof e=="function")for(let t of l(e))!C.call(o,t)&&t!==d&&r(o,t,{get:()=>e[t],enumerable:!(a=n(e,t))||a.enumerable});return o};var u=o=>i(r({},"__esModule",{value:!0}),o);var p={};module.exports=u(p);
2
2
  //# sourceMappingURL=ContextModuleConfig.js.map