@ledgerhq/context-module 0.0.0-multisig-2-20250922095845 → 0.0.0-multisig-20250925175241

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 (174) hide show
  1. package/lib/cjs/src/ContextModule.js +1 -1
  2. package/lib/cjs/src/ContextModule.js.map +1 -1
  3. package/lib/cjs/src/ContextModuleBuilder.test.js +1 -1
  4. package/lib/cjs/src/ContextModuleBuilder.test.js.map +2 -2
  5. package/lib/cjs/src/DefaultContextModule.js +1 -1
  6. package/lib/cjs/src/DefaultContextModule.js.map +3 -3
  7. package/lib/cjs/src/DefaultContextModule.test.js +1 -1
  8. package/lib/cjs/src/DefaultContextModule.test.js.map +3 -3
  9. package/lib/cjs/src/calldata/data/HttpCalldataDescriptorDataSource.js +1 -1
  10. package/lib/cjs/src/calldata/data/HttpCalldataDescriptorDataSource.js.map +3 -3
  11. package/lib/cjs/src/calldata/domain/CalldataContextLoader.js +1 -1
  12. package/lib/cjs/src/calldata/domain/CalldataContextLoader.js.map +3 -3
  13. package/lib/cjs/src/calldata/domain/CalldataContextLoader.test.js +1 -1
  14. package/lib/cjs/src/calldata/domain/CalldataContextLoader.test.js.map +3 -3
  15. package/lib/cjs/src/dynamic-network/domain/DynamicNetworkContextLoader.js +1 -1
  16. package/lib/cjs/src/dynamic-network/domain/DynamicNetworkContextLoader.js.map +3 -3
  17. package/lib/cjs/src/dynamic-network/domain/DynamicNetworkContextLoader.test.js +1 -1
  18. package/lib/cjs/src/dynamic-network/domain/DynamicNetworkContextLoader.test.js.map +3 -3
  19. package/lib/cjs/src/external-plugin/domain/ExternalPluginContextLoader.js +1 -1
  20. package/lib/cjs/src/external-plugin/domain/ExternalPluginContextLoader.js.map +3 -3
  21. package/lib/cjs/src/external-plugin/domain/ExternalPluginContextLoader.test.js +1 -1
  22. package/lib/cjs/src/external-plugin/domain/ExternalPluginContextLoader.test.js.map +3 -3
  23. package/lib/cjs/src/index.js +1 -1
  24. package/lib/cjs/src/index.js.map +2 -2
  25. package/lib/cjs/src/nft/domain/NftContextLoader.js +1 -1
  26. package/lib/cjs/src/nft/domain/NftContextLoader.js.map +3 -3
  27. package/lib/cjs/src/nft/domain/NftContextLoader.test.js +1 -1
  28. package/lib/cjs/src/nft/domain/NftContextLoader.test.js.map +3 -3
  29. package/lib/cjs/src/pki/model/PkiCertificateInfo.js +1 -1
  30. package/lib/cjs/src/pki/model/PkiCertificateInfo.js.map +1 -1
  31. package/lib/cjs/src/proxy/data/HttpProxyDataSource.js +1 -1
  32. package/lib/cjs/src/proxy/data/HttpProxyDataSource.js.map +3 -3
  33. package/lib/cjs/src/proxy/data/HttpProxyDataSource.test.js +1 -1
  34. package/lib/cjs/src/proxy/data/HttpProxyDataSource.test.js.map +3 -3
  35. package/lib/cjs/src/proxy/data/HttpSafeProxyDataSource.js +1 -1
  36. package/lib/cjs/src/proxy/data/HttpSafeProxyDataSource.js.map +2 -2
  37. package/lib/cjs/src/proxy/data/HttpSafeProxyDataSource.test.js +1 -1
  38. package/lib/cjs/src/proxy/data/HttpSafeProxyDataSource.test.js.map +2 -2
  39. package/lib/cjs/src/proxy/data/ProxyDataSource.js +1 -1
  40. package/lib/cjs/src/proxy/data/ProxyDataSource.js.map +1 -1
  41. package/lib/cjs/src/proxy/data/dto/SafeProxyImplementationAddressDto.js +1 -1
  42. package/lib/cjs/src/proxy/data/dto/SafeProxyImplementationAddressDto.js.map +1 -1
  43. package/lib/cjs/src/proxy/domain/ProxyContextFieldLoader.js +1 -1
  44. package/lib/cjs/src/proxy/domain/ProxyContextFieldLoader.js.map +3 -3
  45. package/lib/cjs/src/proxy/domain/ProxyContextFieldLoader.test.js +1 -1
  46. package/lib/cjs/src/proxy/domain/ProxyContextFieldLoader.test.js.map +2 -2
  47. package/lib/cjs/src/proxy/model/ProxyDelegateCall.js +1 -1
  48. package/lib/cjs/src/proxy/model/ProxyDelegateCall.js.map +1 -1
  49. package/lib/cjs/src/shared/domain/ContextLoader.js +1 -1
  50. package/lib/cjs/src/shared/domain/ContextLoader.js.map +1 -1
  51. package/lib/cjs/src/shared/utils/KeyUsageMapper.js +1 -1
  52. package/lib/cjs/src/shared/utils/KeyUsageMapper.js.map +2 -2
  53. package/lib/cjs/src/token/domain/TokenContextLoader.js +1 -1
  54. package/lib/cjs/src/token/domain/TokenContextLoader.js.map +3 -3
  55. package/lib/cjs/src/token/domain/TokenContextLoader.test.js +1 -1
  56. package/lib/cjs/src/token/domain/TokenContextLoader.test.js.map +3 -3
  57. package/lib/cjs/src/trusted-name/domain/TrustedNameContextLoader.js +1 -1
  58. package/lib/cjs/src/trusted-name/domain/TrustedNameContextLoader.js.map +3 -3
  59. package/lib/cjs/src/trusted-name/domain/TrustedNameContextLoader.test.js +1 -1
  60. package/lib/cjs/src/trusted-name/domain/TrustedNameContextLoader.test.js.map +3 -3
  61. package/lib/cjs/src/typed-data/data/HttpTypedDataDataSource.js +1 -1
  62. package/lib/cjs/src/typed-data/data/HttpTypedDataDataSource.js.map +2 -2
  63. package/lib/cjs/src/typed-data/domain/DefaultTypedDataContextLoader.js +1 -1
  64. package/lib/cjs/src/typed-data/domain/DefaultTypedDataContextLoader.js.map +3 -3
  65. package/lib/cjs/src/typed-data/domain/DefaultTypedDataContextLoader.test.js +1 -1
  66. package/lib/cjs/src/typed-data/domain/DefaultTypedDataContextLoader.test.js.map +2 -2
  67. package/lib/cjs/src/uniswap/domain/UniswapContextLoader.js +1 -1
  68. package/lib/cjs/src/uniswap/domain/UniswapContextLoader.js.map +3 -3
  69. package/lib/cjs/src/uniswap/domain/UniswapContextLoader.test.js +1 -1
  70. package/lib/cjs/src/uniswap/domain/UniswapContextLoader.test.js.map +3 -3
  71. package/lib/esm/src/ContextModuleBuilder.test.js +1 -1
  72. package/lib/esm/src/ContextModuleBuilder.test.js.map +2 -2
  73. package/lib/esm/src/DefaultContextModule.js +1 -1
  74. package/lib/esm/src/DefaultContextModule.js.map +3 -3
  75. package/lib/esm/src/DefaultContextModule.test.js +1 -1
  76. package/lib/esm/src/DefaultContextModule.test.js.map +3 -3
  77. package/lib/esm/src/calldata/data/HttpCalldataDescriptorDataSource.js +1 -1
  78. package/lib/esm/src/calldata/data/HttpCalldataDescriptorDataSource.js.map +3 -3
  79. package/lib/esm/src/calldata/domain/CalldataContextLoader.js +1 -1
  80. package/lib/esm/src/calldata/domain/CalldataContextLoader.js.map +3 -3
  81. package/lib/esm/src/calldata/domain/CalldataContextLoader.test.js +1 -1
  82. package/lib/esm/src/calldata/domain/CalldataContextLoader.test.js.map +3 -3
  83. package/lib/esm/src/dynamic-network/domain/DynamicNetworkContextLoader.js +1 -1
  84. package/lib/esm/src/dynamic-network/domain/DynamicNetworkContextLoader.js.map +3 -3
  85. package/lib/esm/src/dynamic-network/domain/DynamicNetworkContextLoader.test.js +1 -1
  86. package/lib/esm/src/dynamic-network/domain/DynamicNetworkContextLoader.test.js.map +3 -3
  87. package/lib/esm/src/external-plugin/domain/ExternalPluginContextLoader.js +1 -1
  88. package/lib/esm/src/external-plugin/domain/ExternalPluginContextLoader.js.map +3 -3
  89. package/lib/esm/src/external-plugin/domain/ExternalPluginContextLoader.test.js +1 -1
  90. package/lib/esm/src/external-plugin/domain/ExternalPluginContextLoader.test.js.map +3 -3
  91. package/lib/esm/src/index.js +1 -1
  92. package/lib/esm/src/index.js.map +2 -2
  93. package/lib/esm/src/nft/domain/NftContextLoader.js +1 -1
  94. package/lib/esm/src/nft/domain/NftContextLoader.js.map +3 -3
  95. package/lib/esm/src/nft/domain/NftContextLoader.test.js +1 -1
  96. package/lib/esm/src/nft/domain/NftContextLoader.test.js.map +3 -3
  97. package/lib/esm/src/proxy/data/HttpProxyDataSource.js +1 -1
  98. package/lib/esm/src/proxy/data/HttpProxyDataSource.js.map +3 -3
  99. package/lib/esm/src/proxy/data/HttpProxyDataSource.test.js +1 -1
  100. package/lib/esm/src/proxy/data/HttpProxyDataSource.test.js.map +3 -3
  101. package/lib/esm/src/proxy/data/HttpSafeProxyDataSource.js +1 -1
  102. package/lib/esm/src/proxy/data/HttpSafeProxyDataSource.js.map +2 -2
  103. package/lib/esm/src/proxy/data/HttpSafeProxyDataSource.test.js +1 -1
  104. package/lib/esm/src/proxy/data/HttpSafeProxyDataSource.test.js.map +2 -2
  105. package/lib/esm/src/proxy/domain/ProxyContextFieldLoader.js +1 -1
  106. package/lib/esm/src/proxy/domain/ProxyContextFieldLoader.js.map +3 -3
  107. package/lib/esm/src/proxy/domain/ProxyContextFieldLoader.test.js +1 -1
  108. package/lib/esm/src/proxy/domain/ProxyContextFieldLoader.test.js.map +2 -2
  109. package/lib/esm/src/shared/utils/KeyUsageMapper.js +1 -1
  110. package/lib/esm/src/shared/utils/KeyUsageMapper.js.map +2 -2
  111. package/lib/esm/src/token/domain/TokenContextLoader.js +1 -1
  112. package/lib/esm/src/token/domain/TokenContextLoader.js.map +3 -3
  113. package/lib/esm/src/token/domain/TokenContextLoader.test.js +1 -1
  114. package/lib/esm/src/token/domain/TokenContextLoader.test.js.map +3 -3
  115. package/lib/esm/src/trusted-name/domain/TrustedNameContextLoader.js +1 -1
  116. package/lib/esm/src/trusted-name/domain/TrustedNameContextLoader.js.map +3 -3
  117. package/lib/esm/src/trusted-name/domain/TrustedNameContextLoader.test.js +1 -1
  118. package/lib/esm/src/trusted-name/domain/TrustedNameContextLoader.test.js.map +3 -3
  119. package/lib/esm/src/typed-data/data/HttpTypedDataDataSource.js +1 -1
  120. package/lib/esm/src/typed-data/data/HttpTypedDataDataSource.js.map +2 -2
  121. package/lib/esm/src/typed-data/domain/DefaultTypedDataContextLoader.js +1 -1
  122. package/lib/esm/src/typed-data/domain/DefaultTypedDataContextLoader.js.map +3 -3
  123. package/lib/esm/src/typed-data/domain/DefaultTypedDataContextLoader.test.js +1 -1
  124. package/lib/esm/src/typed-data/domain/DefaultTypedDataContextLoader.test.js.map +2 -2
  125. package/lib/esm/src/uniswap/domain/UniswapContextLoader.js +1 -1
  126. package/lib/esm/src/uniswap/domain/UniswapContextLoader.js.map +3 -3
  127. package/lib/esm/src/uniswap/domain/UniswapContextLoader.test.js +1 -1
  128. package/lib/esm/src/uniswap/domain/UniswapContextLoader.test.js.map +3 -3
  129. package/lib/types/src/ContextModule.d.ts +1 -2
  130. package/lib/types/src/ContextModule.d.ts.map +1 -1
  131. package/lib/types/src/DefaultContextModule.d.ts +1 -2
  132. package/lib/types/src/DefaultContextModule.d.ts.map +1 -1
  133. package/lib/types/src/calldata/data/HttpCalldataDescriptorDataSource.d.ts.map +1 -1
  134. package/lib/types/src/calldata/domain/CalldataContextLoader.d.ts +12 -4
  135. package/lib/types/src/calldata/domain/CalldataContextLoader.d.ts.map +1 -1
  136. package/lib/types/src/dynamic-network/domain/DynamicNetworkContextLoader.d.ts +9 -4
  137. package/lib/types/src/dynamic-network/domain/DynamicNetworkContextLoader.d.ts.map +1 -1
  138. package/lib/types/src/external-plugin/domain/ExternalPluginContextLoader.d.ts +11 -4
  139. package/lib/types/src/external-plugin/domain/ExternalPluginContextLoader.d.ts.map +1 -1
  140. package/lib/types/src/index.d.ts +0 -1
  141. package/lib/types/src/index.d.ts.map +1 -1
  142. package/lib/types/src/nft/domain/NftContextLoader.d.ts +10 -4
  143. package/lib/types/src/nft/domain/NftContextLoader.d.ts.map +1 -1
  144. package/lib/types/src/pki/model/PkiCertificateInfo.d.ts +1 -2
  145. package/lib/types/src/pki/model/PkiCertificateInfo.d.ts.map +1 -1
  146. package/lib/types/src/proxy/data/HttpProxyDataSource.d.ts.map +1 -1
  147. package/lib/types/src/proxy/data/HttpSafeProxyDataSource.d.ts.map +1 -1
  148. package/lib/types/src/proxy/data/ProxyDataSource.d.ts +2 -0
  149. package/lib/types/src/proxy/data/ProxyDataSource.d.ts.map +1 -1
  150. package/lib/types/src/proxy/data/dto/SafeProxyImplementationAddressDto.d.ts +2 -0
  151. package/lib/types/src/proxy/data/dto/SafeProxyImplementationAddressDto.d.ts.map +1 -1
  152. package/lib/types/src/proxy/domain/ProxyContextFieldLoader.d.ts.map +1 -1
  153. package/lib/types/src/proxy/model/ProxyDelegateCall.d.ts +2 -0
  154. package/lib/types/src/proxy/model/ProxyDelegateCall.d.ts.map +1 -1
  155. package/lib/types/src/shared/domain/ContextLoader.d.ts +13 -4
  156. package/lib/types/src/shared/domain/ContextLoader.d.ts.map +1 -1
  157. package/lib/types/src/shared/utils/KeyUsageMapper.d.ts +1 -2
  158. package/lib/types/src/shared/utils/KeyUsageMapper.d.ts.map +1 -1
  159. package/lib/types/src/token/domain/TokenContextLoader.d.ts +10 -4
  160. package/lib/types/src/token/domain/TokenContextLoader.d.ts.map +1 -1
  161. package/lib/types/src/trusted-name/domain/TrustedNameContextLoader.d.ts +9 -4
  162. package/lib/types/src/trusted-name/domain/TrustedNameContextLoader.d.ts.map +1 -1
  163. package/lib/types/src/typed-data/data/HttpTypedDataDataSource.d.ts.map +1 -1
  164. package/lib/types/src/typed-data/domain/DefaultTypedDataContextLoader.d.ts.map +1 -1
  165. package/lib/types/src/uniswap/domain/UniswapContextLoader.d.ts +11 -4
  166. package/lib/types/src/uniswap/domain/UniswapContextLoader.d.ts.map +1 -1
  167. package/lib/types/tsconfig.prod.tsbuildinfo +1 -1
  168. package/package.json +6 -6
  169. package/lib/cjs/src/shared/model/TransactionContext.js +0 -2
  170. package/lib/cjs/src/shared/model/TransactionContext.js.map +0 -7
  171. package/lib/esm/src/shared/model/TransactionContext.js +0 -1
  172. package/lib/esm/src/shared/model/TransactionContext.js.map +0 -7
  173. package/lib/types/src/shared/model/TransactionContext.d.ts +0 -8
  174. package/lib/types/src/shared/model/TransactionContext.d.ts.map +0 -1
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../../src/shared/domain/ContextLoader.ts"],
4
- "sourcesContent": ["import { type ClearSignContext } from \"@/shared/model/ClearSignContext\";\nimport { type TransactionContext } from \"@/shared/model/TransactionContext\";\n\nexport type ContextLoader = {\n load: (transaction: TransactionContext) => Promise<ClearSignContext[]>;\n};\n"],
4
+ "sourcesContent": ["import {\n type ClearSignContext,\n type ClearSignContextType,\n} from \"@/shared/model/ClearSignContext\";\n\nexport type ContextLoader<TInput = unknown> = {\n /**\n * @param input - The input to load context for\n * @returns The loaded contexts\n */\n load: (input: TInput) => Promise<ClearSignContext[]>;\n\n /**\n * @param input - The input to check\n * @param expectedTypes - The expected types of the context to load\n * @returns True if the loader can handle the input, false otherwise\n */\n canHandle: (\n input: unknown,\n expectedTypes: ClearSignContextType[],\n ) => input is TInput;\n};\n"],
5
5
  "mappings": "+WAAA,IAAAA,EAAA,kBAAAC,EAAAD",
6
6
  "names": ["ContextLoader_exports", "__toCommonJS"]
7
7
  }
@@ -1,2 +1,2 @@
1
- "use strict";var i=Object.defineProperty;var n=Object.getOwnPropertyDescriptor;var o=Object.getOwnPropertyNames;var p=Object.prototype.hasOwnProperty;var u=(t,a)=>{for(var s in a)i(t,s,{get:a[s],enumerable:!0})},y=(t,a,s,g)=>{if(a&&typeof a=="object"||typeof a=="function")for(let r of o(a))!p.call(t,r)&&r!==s&&i(t,r,{get:()=>a[r],enumerable:!(g=n(a,r))||g.enumerable});return t};var c=t=>y(i({},"__esModule",{value:!0}),t);var U={};u(U,{KeyUsageMapper:()=>m});module.exports=c(U);var e=require("../../pki/model/KeyUsage");class m{static keyUsageMap=new Map([[e.KeyUsage.GenuineCheck,1],[e.KeyUsage.ExchangePayload,2],[e.KeyUsage.NftMeta,3],[e.KeyUsage.TrustedName,4],[e.KeyUsage.BackupProvider,5],[e.KeyUsage.ProtectOrchestrator,6],[e.KeyUsage.PluginMeta,7],[e.KeyUsage.CoinMeta,8],[e.KeyUsage.SeedIdAuth,9],[e.KeyUsage.TxSimulationSigner,10],[e.KeyUsage.Calldata,11],[e.KeyUsage.Network,12]]);static mapKeyUsageForFirmware(a){return this.keyUsageMap.get(a)??-1}}0&&(module.exports={KeyUsageMapper});
1
+ "use strict";var i=Object.defineProperty;var g=Object.getOwnPropertyDescriptor;var u=Object.getOwnPropertyNames;var o=Object.prototype.hasOwnProperty;var c=(t,a)=>{for(var s in a)i(t,s,{get:a[s],enumerable:!0})},p=(t,a,s,n)=>{if(a&&typeof a=="object"||typeof a=="function")for(let r of u(a))!o.call(t,r)&&r!==s&&i(t,r,{get:()=>a[r],enumerable:!(n=g(a,r))||n.enumerable});return t};var l=t=>p(i({},"__esModule",{value:!0}),t);var y={};c(y,{KeyUsageMapper:()=>m});module.exports=l(y);var e=require("../../pki/model/KeyUsage");class m{static keyUsageMap=new Map([[e.KeyUsage.GenuineCheck,1],[e.KeyUsage.ExchangePayload,2],[e.KeyUsage.NftMeta,3],[e.KeyUsage.TrustedName,4],[e.KeyUsage.BackupProvider,5],[e.KeyUsage.ProtectOrchestrator,6],[e.KeyUsage.PluginMeta,7],[e.KeyUsage.CoinMeta,8],[e.KeyUsage.SeedIdAuth,9],[e.KeyUsage.TxSimulationSigner,10],[e.KeyUsage.Calldata,11],[e.KeyUsage.Network,12]]);static mapKeyUsageForFirmware(a){return Object.values(e.KeyUsage).includes(a)?this.keyUsageMap.get(a)??-1:-1}}0&&(module.exports={KeyUsageMapper});
2
2
  //# sourceMappingURL=KeyUsageMapper.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../../src/shared/utils/KeyUsageMapper.ts"],
4
- "sourcesContent": ["import { KeyUsage } from \"@/pki/model/KeyUsage\";\n\nexport class KeyUsageMapper {\n private static keyUsageMap = new Map<KeyUsage, number>([\n [KeyUsage.GenuineCheck, 1],\n [KeyUsage.ExchangePayload, 2],\n [KeyUsage.NftMeta, 3],\n [KeyUsage.TrustedName, 4],\n [KeyUsage.BackupProvider, 5],\n [KeyUsage.ProtectOrchestrator, 6],\n [KeyUsage.PluginMeta, 7],\n [KeyUsage.CoinMeta, 8],\n [KeyUsage.SeedIdAuth, 9],\n [KeyUsage.TxSimulationSigner, 10],\n [KeyUsage.Calldata, 11],\n [KeyUsage.Network, 12],\n ]);\n\n static mapKeyUsageForFirmware(keyUsage: KeyUsage): number {\n return this.keyUsageMap.get(keyUsage as KeyUsage) ?? -1;\n }\n}\n"],
5
- "mappings": "yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,oBAAAE,IAAA,eAAAC,EAAAH,GAAA,IAAAI,EAAyB,gCAElB,MAAMF,CAAe,CAC1B,OAAe,YAAc,IAAI,IAAsB,CACrD,CAAC,WAAS,aAAc,CAAC,EACzB,CAAC,WAAS,gBAAiB,CAAC,EAC5B,CAAC,WAAS,QAAS,CAAC,EACpB,CAAC,WAAS,YAAa,CAAC,EACxB,CAAC,WAAS,eAAgB,CAAC,EAC3B,CAAC,WAAS,oBAAqB,CAAC,EAChC,CAAC,WAAS,WAAY,CAAC,EACvB,CAAC,WAAS,SAAU,CAAC,EACrB,CAAC,WAAS,WAAY,CAAC,EACvB,CAAC,WAAS,mBAAoB,EAAE,EAChC,CAAC,WAAS,SAAU,EAAE,EACtB,CAAC,WAAS,QAAS,EAAE,CACvB,CAAC,EAED,OAAO,uBAAuBG,EAA4B,CACxD,OAAO,KAAK,YAAY,IAAIA,CAAoB,GAAK,EACvD,CACF",
4
+ "sourcesContent": ["import { KeyUsage } from \"@/pki/model/KeyUsage\";\n\nexport class KeyUsageMapper {\n private static keyUsageMap = new Map<KeyUsage, number>([\n [KeyUsage.GenuineCheck, 1],\n [KeyUsage.ExchangePayload, 2],\n [KeyUsage.NftMeta, 3],\n [KeyUsage.TrustedName, 4],\n [KeyUsage.BackupProvider, 5],\n [KeyUsage.ProtectOrchestrator, 6],\n [KeyUsage.PluginMeta, 7],\n [KeyUsage.CoinMeta, 8],\n [KeyUsage.SeedIdAuth, 9],\n [KeyUsage.TxSimulationSigner, 10],\n [KeyUsage.Calldata, 11],\n [KeyUsage.Network, 12],\n ]);\n\n static mapKeyUsageForFirmware(keyUsage: string): number {\n if (Object.values(KeyUsage).includes(keyUsage as KeyUsage)) {\n return this.keyUsageMap.get(keyUsage as KeyUsage) ?? -1;\n }\n return -1;\n }\n}\n"],
5
+ "mappings": "yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,oBAAAE,IAAA,eAAAC,EAAAH,GAAA,IAAAI,EAAyB,gCAElB,MAAMF,CAAe,CAC1B,OAAe,YAAc,IAAI,IAAsB,CACrD,CAAC,WAAS,aAAc,CAAC,EACzB,CAAC,WAAS,gBAAiB,CAAC,EAC5B,CAAC,WAAS,QAAS,CAAC,EACpB,CAAC,WAAS,YAAa,CAAC,EACxB,CAAC,WAAS,eAAgB,CAAC,EAC3B,CAAC,WAAS,oBAAqB,CAAC,EAChC,CAAC,WAAS,WAAY,CAAC,EACvB,CAAC,WAAS,SAAU,CAAC,EACrB,CAAC,WAAS,WAAY,CAAC,EACvB,CAAC,WAAS,mBAAoB,EAAE,EAChC,CAAC,WAAS,SAAU,EAAE,EACtB,CAAC,WAAS,QAAS,EAAE,CACvB,CAAC,EAED,OAAO,uBAAuBG,EAA0B,CACtD,OAAI,OAAO,OAAO,UAAQ,EAAE,SAASA,CAAoB,EAChD,KAAK,YAAY,IAAIA,CAAoB,GAAK,GAEhD,EACT,CACF",
6
6
  "names": ["KeyUsageMapper_exports", "__export", "KeyUsageMapper", "__toCommonJS", "import_KeyUsage", "keyUsage"]
7
7
  }
@@ -1,2 +1,2 @@
1
- "use strict";var s=Object.defineProperty;var m=Object.getOwnPropertyDescriptor;var g=Object.getOwnPropertyNames;var y=Object.prototype.hasOwnProperty;var C=(o,e)=>{for(var t in e)s(o,t,{get:e[t],enumerable:!0})},T=(o,e,t,a)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of g(e))!y.call(o,r)&&r!==t&&s(o,r,{get:()=>e[r],enumerable:!(a=m(e,r))||a.enumerable});return o};var b=o=>T(s({},"__esModule",{value:!0}),o),S=(o,e,t,a)=>{for(var r=a>1?void 0:a?m(e,t):e,c=o.length-1,n;c>=0;c--)(n=o[c])&&(r=(a?n(e,t,r):n(r))||r);return a&&r&&s(e,t,r),r},d=(o,e)=>(t,a)=>e(t,a,o);var h={};C(h,{ERC20_SUPPORTED_SELECTORS:()=>u,TokenContextLoader:()=>i});module.exports=b(h);var f=require("@ledgerhq/device-management-kit"),l=require("inversify"),p=require("../../shared/model/ClearSignContext"),x=require("../../token/di/tokenTypes");var u=(t=>(t.Approve="0x095ea7b3",t.Transfer="0xa9059cbb",t))(u||{});const v=Object.values(u);let i=class{_dataSource;constructor(e){this._dataSource=e}async load(e){const{to:t,selector:a,chainId:r}=e;return t?(0,f.isHexaString)(a)?this.isSelectorSupported(a)?[(await this._dataSource.getTokenInfosPayload({address:t,chainId:r})).caseOf({Left:n=>({type:p.ClearSignContextType.ERROR,error:n}),Right:n=>({type:p.ClearSignContextType.TOKEN,payload:n})})]:[]:[{type:p.ClearSignContextType.ERROR,error:new Error("Invalid selector")}]:[]}isSelectorSupported(e){return Object.values(v).includes(e)}};i=S([(0,l.injectable)(),d(0,(0,l.inject)(x.tokenTypes.TokenDataSource))],i);0&&(module.exports={ERC20_SUPPORTED_SELECTORS,TokenContextLoader});
1
+ "use strict";var i=Object.defineProperty;var d=Object.getOwnPropertyDescriptor;var g=Object.getOwnPropertyNames;var C=Object.prototype.hasOwnProperty;var T=(r,e)=>{for(var t in e)i(r,t,{get:e[t],enumerable:!0})},f=(r,e,t,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of g(e))!C.call(r,o)&&o!==t&&i(r,o,{get:()=>e[o],enumerable:!(n=d(e,o))||n.enumerable});return r};var k=r=>f(i({},"__esModule",{value:!0}),r),u=(r,e,t,n)=>{for(var o=n>1?void 0:n?d(e,t):e,a=r.length-1,p;a>=0;a--)(p=r[a])&&(o=(n?p(e,t,o):p(o))||o);return n&&o&&i(e,t,o),o},m=(r,e)=>(t,n)=>e(t,n,r);var h={};T(h,{ERC20_SUPPORTED_SELECTORS:()=>x,TokenContextLoader:()=>c});module.exports=k(h);var S=require("@ledgerhq/device-management-kit"),l=require("inversify"),s=require("../../shared/model/ClearSignContext"),y=require("../../token/di/tokenTypes");var x=(t=>(t.Approve="0x095ea7b3",t.Transfer="0xa9059cbb",t))(x||{});const b=Object.values(x),I=[s.ClearSignContextType.TOKEN];let c=class{_dataSource;constructor(e){this._dataSource=e}canHandle(e,t){return typeof e=="object"&&e!==null&&"to"in e&&"selector"in e&&"chainId"in e&&typeof e.chainId=="number"&&(0,S.isHexaString)(e.to)&&e.to!=="0x"&&(0,S.isHexaString)(e.selector)&&this.isSelectorSupported(e.selector)&&I.every(n=>t.includes(n))}async load(e){const{to:t,chainId:n}=e;return[(await this._dataSource.getTokenInfosPayload({address:t,chainId:n})).caseOf({Left:a=>({type:s.ClearSignContextType.ERROR,error:a}),Right:a=>({type:s.ClearSignContextType.TOKEN,payload:a})})]}isSelectorSupported(e){return Object.values(b).includes(e)}};c=u([(0,l.injectable)(),m(0,(0,l.inject)(y.tokenTypes.TokenDataSource))],c);0&&(module.exports={ERC20_SUPPORTED_SELECTORS,TokenContextLoader});
2
2
  //# sourceMappingURL=TokenContextLoader.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../../src/token/domain/TokenContextLoader.ts"],
4
- "sourcesContent": ["import { HexaString, isHexaString } from \"@ledgerhq/device-management-kit\";\nimport { inject, injectable } from \"inversify\";\n\nimport { ContextLoader } from \"@/shared/domain/ContextLoader\";\nimport {\n ClearSignContext,\n ClearSignContextType,\n} from \"@/shared/model/ClearSignContext\";\nimport { TransactionContext } from \"@/shared/model/TransactionContext\";\nimport type { TokenDataSource } from \"@/token/data/TokenDataSource\";\nimport { tokenTypes } from \"@/token/di/tokenTypes\";\n\nexport enum ERC20_SUPPORTED_SELECTORS {\n Approve = \"0x095ea7b3\",\n Transfer = \"0xa9059cbb\",\n}\n\nconst SUPPORTED_SELECTORS: HexaString[] = Object.values(\n ERC20_SUPPORTED_SELECTORS,\n);\n\n@injectable()\nexport class TokenContextLoader implements ContextLoader {\n private _dataSource: TokenDataSource;\n\n constructor(@inject(tokenTypes.TokenDataSource) dataSource: TokenDataSource) {\n this._dataSource = dataSource;\n }\n\n async load(ctx: TransactionContext): Promise<ClearSignContext[]> {\n const { to, selector, chainId } = ctx;\n if (!to) {\n return [];\n }\n\n if (!isHexaString(selector)) {\n return [\n {\n type: ClearSignContextType.ERROR,\n error: new Error(\"Invalid selector\"),\n },\n ];\n }\n\n if (!this.isSelectorSupported(selector)) {\n return [];\n }\n\n const payload = await this._dataSource.getTokenInfosPayload({\n address: to,\n chainId,\n });\n\n return [\n payload.caseOf({\n Left: (error): ClearSignContext => ({\n type: ClearSignContextType.ERROR,\n error,\n }),\n Right: (value): ClearSignContext => ({\n type: ClearSignContextType.TOKEN,\n payload: value,\n }),\n }),\n ];\n }\n\n private isSelectorSupported(selector: HexaString) {\n return Object.values(SUPPORTED_SELECTORS).includes(selector);\n }\n}\n"],
5
- "mappings": "okBAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,+BAAAE,EAAA,uBAAAC,IAAA,eAAAC,EAAAJ,GAAA,IAAAK,EAAyC,2CACzCC,EAAmC,qBAGnCC,EAGO,2CAGPC,EAA2B,iCAEpB,IAAKC,OACVA,EAAA,QAAU,aACVA,EAAA,SAAW,aAFDA,OAAA,IAKZ,MAAMC,EAAoC,OAAO,OAC/CD,CACF,EAGO,IAAME,EAAN,KAAkD,CAC/C,YAER,YAAgDC,EAA6B,CAC3E,KAAK,YAAcA,CACrB,CAEA,MAAM,KAAKC,EAAsD,CAC/D,KAAM,CAAE,GAAAC,EAAI,SAAAC,EAAU,QAAAC,CAAQ,EAAIH,EAClC,OAAKC,KAIA,gBAAaC,CAAQ,EASrB,KAAK,oBAAoBA,CAAQ,EAS/B,EALS,MAAM,KAAK,YAAY,qBAAqB,CAC1D,QAASD,EACT,QAAAE,CACF,CAAC,GAGS,OAAO,CACb,KAAOC,IAA6B,CAClC,KAAM,uBAAqB,MAC3B,MAAAA,CACF,GACA,MAAQC,IAA6B,CACnC,KAAM,uBAAqB,MAC3B,QAASA,CACX,EACF,CAAC,CACH,EAnBS,CAAC,EATD,CACL,CACE,KAAM,uBAAqB,MAC3B,MAAO,IAAI,MAAM,kBAAkB,CACrC,CACF,EATO,CAAC,CAiCZ,CAEQ,oBAAoBH,EAAsB,CAChD,OAAO,OAAO,OAAOL,CAAmB,EAAE,SAASK,CAAQ,CAC7D,CACF,EAhDaJ,EAANQ,EAAA,IADN,cAAW,EAIGC,EAAA,eAAO,aAAW,eAAe,IAHnCT",
6
- "names": ["TokenContextLoader_exports", "__export", "ERC20_SUPPORTED_SELECTORS", "TokenContextLoader", "__toCommonJS", "import_device_management_kit", "import_inversify", "import_ClearSignContext", "import_tokenTypes", "ERC20_SUPPORTED_SELECTORS", "SUPPORTED_SELECTORS", "TokenContextLoader", "dataSource", "ctx", "to", "selector", "chainId", "error", "value", "__decorateClass", "__decorateParam"]
4
+ "sourcesContent": ["import { HexaString, isHexaString } from \"@ledgerhq/device-management-kit\";\nimport { inject, injectable } from \"inversify\";\n\nimport { ContextLoader } from \"@/shared/domain/ContextLoader\";\nimport {\n ClearSignContext,\n ClearSignContextType,\n} from \"@/shared/model/ClearSignContext\";\nimport type { TokenDataSource } from \"@/token/data/TokenDataSource\";\nimport { tokenTypes } from \"@/token/di/tokenTypes\";\n\nexport enum ERC20_SUPPORTED_SELECTORS {\n Approve = \"0x095ea7b3\",\n Transfer = \"0xa9059cbb\",\n}\n\nconst SUPPORTED_SELECTORS: HexaString[] = Object.values(\n ERC20_SUPPORTED_SELECTORS,\n);\n\nconst SUPPORTED_TYPES: ClearSignContextType[] = [ClearSignContextType.TOKEN];\n\nexport type TokenContextInput = {\n to: HexaString;\n selector: HexaString;\n chainId: number;\n};\n\n@injectable()\nexport class TokenContextLoader implements ContextLoader<TokenContextInput> {\n private _dataSource: TokenDataSource;\n\n constructor(@inject(tokenTypes.TokenDataSource) dataSource: TokenDataSource) {\n this._dataSource = dataSource;\n }\n\n canHandle(\n input: unknown,\n expectedTypes: ClearSignContextType[],\n ): input is TokenContextInput {\n return (\n typeof input === \"object\" &&\n input !== null &&\n \"to\" in input &&\n \"selector\" in input &&\n \"chainId\" in input &&\n typeof input.chainId === \"number\" &&\n isHexaString(input.to) &&\n input.to !== \"0x\" &&\n isHexaString(input.selector) &&\n this.isSelectorSupported(input.selector) &&\n SUPPORTED_TYPES.every((type) => expectedTypes.includes(type))\n );\n }\n\n async load(input: TokenContextInput): Promise<ClearSignContext[]> {\n const { to, chainId } = input;\n\n const payload = await this._dataSource.getTokenInfosPayload({\n address: to,\n chainId,\n });\n\n return [\n payload.caseOf({\n Left: (error): ClearSignContext => ({\n type: ClearSignContextType.ERROR,\n error,\n }),\n Right: (value): ClearSignContext => ({\n type: ClearSignContextType.TOKEN,\n payload: value,\n }),\n }),\n ];\n }\n\n private isSelectorSupported(selector: HexaString) {\n return Object.values(SUPPORTED_SELECTORS).includes(selector);\n }\n}\n"],
5
+ "mappings": "okBAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,+BAAAE,EAAA,uBAAAC,IAAA,eAAAC,EAAAJ,GAAA,IAAAK,EAAyC,2CACzCC,EAAmC,qBAGnCC,EAGO,2CAEPC,EAA2B,iCAEpB,IAAKC,OACVA,EAAA,QAAU,aACVA,EAAA,SAAW,aAFDA,OAAA,IAKZ,MAAMC,EAAoC,OAAO,OAC/CD,CACF,EAEME,EAA0C,CAAC,uBAAqB,KAAK,EASpE,IAAMC,EAAN,KAAqE,CAClE,YAER,YAAgDC,EAA6B,CAC3E,KAAK,YAAcA,CACrB,CAEA,UACEC,EACAC,EAC4B,CAC5B,OACE,OAAOD,GAAU,UACjBA,IAAU,MACV,OAAQA,GACR,aAAcA,GACd,YAAaA,GACb,OAAOA,EAAM,SAAY,aACzB,gBAAaA,EAAM,EAAE,GACrBA,EAAM,KAAO,SACb,gBAAaA,EAAM,QAAQ,GAC3B,KAAK,oBAAoBA,EAAM,QAAQ,GACvCH,EAAgB,MAAOK,GAASD,EAAc,SAASC,CAAI,CAAC,CAEhE,CAEA,MAAM,KAAKF,EAAuD,CAChE,KAAM,CAAE,GAAAG,EAAI,QAAAC,CAAQ,EAAIJ,EAOxB,MAAO,EALS,MAAM,KAAK,YAAY,qBAAqB,CAC1D,QAASG,EACT,QAAAC,CACF,CAAC,GAGS,OAAO,CACb,KAAOC,IAA6B,CAClC,KAAM,uBAAqB,MAC3B,MAAAA,CACF,GACA,MAAQC,IAA6B,CACnC,KAAM,uBAAqB,MAC3B,QAASA,CACX,EACF,CAAC,CACH,CACF,CAEQ,oBAAoBC,EAAsB,CAChD,OAAO,OAAO,OAAOX,CAAmB,EAAE,SAASW,CAAQ,CAC7D,CACF,EAnDaT,EAANU,EAAA,IADN,cAAW,EAIGC,EAAA,eAAO,aAAW,eAAe,IAHnCX",
6
+ "names": ["TokenContextLoader_exports", "__export", "ERC20_SUPPORTED_SELECTORS", "TokenContextLoader", "__toCommonJS", "import_device_management_kit", "import_inversify", "import_ClearSignContext", "import_tokenTypes", "ERC20_SUPPORTED_SELECTORS", "SUPPORTED_SELECTORS", "SUPPORTED_TYPES", "TokenContextLoader", "dataSource", "input", "expectedTypes", "type", "to", "chainId", "error", "value", "selector", "__decorateClass", "__decorateParam"]
7
7
  }
@@ -1,2 +1,2 @@
1
- "use strict";var t=require("purify-ts"),n=require("../../shared/model/ClearSignContext"),s=require("../../token/domain/TokenContextLoader");describe("TokenContextLoader",()=>{const a={getTokenInfosPayload:vi.fn()},r=new s.TokenContextLoader(a);beforeEach(()=>{vi.restoreAllMocks(),vi.spyOn(a,"getTokenInfosPayload").mockImplementation(({address:e})=>Promise.resolve((0,t.Right)(`payload-${e}`)))}),describe("load function",()=>{it("should return an empty array if transaction dest is undefined",async()=>{const e={to:void 0},o=await r.load(e);expect(o).toEqual([])}),it("should return an error when datasource returns an error",async()=>{const e={to:"0xdAC17F958D2ee523a2206206994597C13D831ec7",chainId:1,selector:"0x095ea7b3"};vi.spyOn(a,"getTokenInfosPayload").mockResolvedValue((0,t.Left)(new Error("error")));const o=await r.load(e);expect(o).toEqual([{type:n.ClearSignContextType.ERROR,error:new Error("error")}])}),it("should return a correct response",async()=>{const e={to:"0xdAC17F958D2ee523a2206206994597C13D831ec7",chainId:1,selector:"0x095ea7b3"},o=await r.load(e);expect(o).toEqual([{type:n.ClearSignContextType.TOKEN,payload:"payload-0xdAC17F958D2ee523a2206206994597C13D831ec7"}])})})});
1
+ "use strict";var a=require("purify-ts"),t=require("../../shared/model/ClearSignContext"),c=require("../../token/domain/TokenContextLoader");describe("TokenContextLoader",()=>{const r={getTokenInfosPayload:vi.fn()},o=new c.TokenContextLoader(r);beforeEach(()=>{vi.restoreAllMocks(),vi.spyOn(r,"getTokenInfosPayload").mockImplementation(({address:e})=>Promise.resolve((0,a.Right)(`payload-${e}`)))}),describe("canHandle function",()=>{const e={to:"0xdAC17F958D2ee523a2206206994597C13D831ec7",selector:"0x095ea7b3",chainId:1};it("should return true for valid input",()=>{expect(o.canHandle(e,[t.ClearSignContextType.TOKEN])).toBe(!0)}),it("should return false for invalid expected type",()=>{expect(o.canHandle(e,[t.ClearSignContextType.NFT])).toBe(!1)}),it.each([[null,"null input"],[void 0,"undefined input"],[{},"empty object"],["string","string input"],[123,"number input"]])("should return false for %s",(n,i)=>{expect(o.canHandle(n,[t.ClearSignContextType.TOKEN])).toBe(!1)}),it.each([[{...e,to:void 0},"missing to"],[{...e,selector:void 0},"missing selector"],[{...e,chainId:void 0},"missing chainId"]])("should return false for %s",(n,i)=>{expect(o.canHandle(n,[t.ClearSignContextType.TOKEN])).toBe(!1)}),it.each([[{...e,to:"invalid-hex"},"invalid to hex"],[{...e,to:"0x"},"empty to hex"],[{...e,to:"not-hex-at-all"},"non-hex to"],[{...e,selector:"invalid-hex"},"invalid selector hex"],[{...e,selector:"0x"},"empty selector hex"],[{...e,selector:"not-hex-at-all"},"non-hex selector"]])("should return false for %s",(n,i)=>{expect(o.canHandle(n,[t.ClearSignContextType.TOKEN])).toBe(!1)}),it.each([[{...e,chainId:"1"},"string chainId"],[{...e,chainId:null},"null chainId"],[{...e,chainId:void 0},"undefined chainId"]])("should return false for %s",(n,i)=>{expect(o.canHandle(n,[t.ClearSignContextType.TOKEN])).toBe(!1)})}),describe("load function",()=>{it("should return an error when datasource returns an error",async()=>{const e={to:"0xdAC17F958D2ee523a2206206994597C13D831ec7",chainId:1,selector:"0x095ea7b3"};vi.spyOn(r,"getTokenInfosPayload").mockResolvedValue((0,a.Left)(new Error("error")));const n=await o.load(e);expect(n).toEqual([{type:t.ClearSignContextType.ERROR,error:new Error("error")}])}),it("should return a correct response",async()=>{const e={to:"0xdAC17F958D2ee523a2206206994597C13D831ec7",chainId:1,selector:"0x095ea7b3"},n=await o.load(e);expect(n).toEqual([{type:t.ClearSignContextType.TOKEN,payload:"payload-0xdAC17F958D2ee523a2206206994597C13D831ec7"}])})})});
2
2
  //# sourceMappingURL=TokenContextLoader.test.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../../src/token/domain/TokenContextLoader.test.ts"],
4
- "sourcesContent": ["import { Left, Right } from \"purify-ts\";\n\nimport { ClearSignContextType } from \"@/shared/model/ClearSignContext\";\nimport { type TransactionContext } from \"@/shared/model/TransactionContext\";\nimport { type TokenDataSource } from \"@/token/data/TokenDataSource\";\nimport { TokenContextLoader } from \"@/token/domain/TokenContextLoader\";\n\ndescribe(\"TokenContextLoader\", () => {\n const mockTokenDataSource: TokenDataSource = {\n getTokenInfosPayload: vi.fn(),\n };\n const loader = new TokenContextLoader(mockTokenDataSource);\n\n beforeEach(() => {\n vi.restoreAllMocks();\n vi.spyOn(mockTokenDataSource, \"getTokenInfosPayload\").mockImplementation(\n ({ address }) => Promise.resolve(Right(`payload-${address}`)),\n );\n });\n\n describe(\"load function\", () => {\n it(\"should return an empty array if transaction dest is undefined\", async () => {\n // GIVEN\n const transaction = { to: undefined } as TransactionContext;\n\n // WHEN\n const result = await loader.load(transaction);\n\n // THEN\n expect(result).toEqual([]);\n });\n\n it(\"should return an error when datasource returns an error\", async () => {\n // GIVEN\n const transaction = {\n to: \"0xdAC17F958D2ee523a2206206994597C13D831ec7\",\n chainId: 1,\n selector: \"0x095ea7b3\",\n } as TransactionContext;\n vi.spyOn(mockTokenDataSource, \"getTokenInfosPayload\").mockResolvedValue(\n Left(new Error(\"error\")),\n );\n\n // WHEN\n const result = await loader.load(transaction);\n\n // THEN\n expect(result).toEqual([\n { type: ClearSignContextType.ERROR, error: new Error(\"error\") },\n ]);\n });\n\n it(\"should return a correct response\", async () => {\n // GIVEN\n const transaction = {\n to: \"0xdAC17F958D2ee523a2206206994597C13D831ec7\",\n chainId: 1,\n selector: \"0x095ea7b3\",\n } as TransactionContext;\n\n // WHEN\n const result = await loader.load(transaction);\n\n // THEN\n expect(result).toEqual([\n {\n type: ClearSignContextType.TOKEN,\n payload: \"payload-0xdAC17F958D2ee523a2206206994597C13D831ec7\",\n },\n ]);\n });\n });\n});\n"],
5
- "mappings": "aAAA,IAAAA,EAA4B,qBAE5BC,EAAqC,2CAGrCC,EAAmC,6CAEnC,SAAS,qBAAsB,IAAM,CACnC,MAAMC,EAAuC,CAC3C,qBAAsB,GAAG,GAAG,CAC9B,EACMC,EAAS,IAAI,qBAAmBD,CAAmB,EAEzD,WAAW,IAAM,CACf,GAAG,gBAAgB,EACnB,GAAG,MAAMA,EAAqB,sBAAsB,EAAE,mBACpD,CAAC,CAAE,QAAAE,CAAQ,IAAM,QAAQ,WAAQ,SAAM,WAAWA,CAAO,EAAE,CAAC,CAC9D,CACF,CAAC,EAED,SAAS,gBAAiB,IAAM,CAC9B,GAAG,gEAAiE,SAAY,CAE9E,MAAMC,EAAc,CAAE,GAAI,MAAU,EAG9BC,EAAS,MAAMH,EAAO,KAAKE,CAAW,EAG5C,OAAOC,CAAM,EAAE,QAAQ,CAAC,CAAC,CAC3B,CAAC,EAED,GAAG,0DAA2D,SAAY,CAExE,MAAMD,EAAc,CAClB,GAAI,6CACJ,QAAS,EACT,SAAU,YACZ,EACA,GAAG,MAAMH,EAAqB,sBAAsB,EAAE,qBACpD,QAAK,IAAI,MAAM,OAAO,CAAC,CACzB,EAGA,MAAMI,EAAS,MAAMH,EAAO,KAAKE,CAAW,EAG5C,OAAOC,CAAM,EAAE,QAAQ,CACrB,CAAE,KAAM,uBAAqB,MAAO,MAAO,IAAI,MAAM,OAAO,CAAE,CAChE,CAAC,CACH,CAAC,EAED,GAAG,mCAAoC,SAAY,CAEjD,MAAMD,EAAc,CAClB,GAAI,6CACJ,QAAS,EACT,SAAU,YACZ,EAGMC,EAAS,MAAMH,EAAO,KAAKE,CAAW,EAG5C,OAAOC,CAAM,EAAE,QAAQ,CACrB,CACE,KAAM,uBAAqB,MAC3B,QAAS,oDACX,CACF,CAAC,CACH,CAAC,CACH,CAAC,CACH,CAAC",
6
- "names": ["import_purify_ts", "import_ClearSignContext", "import_TokenContextLoader", "mockTokenDataSource", "loader", "address", "transaction", "result"]
4
+ "sourcesContent": ["import { Left, Right } from \"purify-ts\";\n\nimport { ClearSignContextType } from \"@/shared/model/ClearSignContext\";\nimport { type TokenDataSource } from \"@/token/data/TokenDataSource\";\nimport {\n type TokenContextInput,\n TokenContextLoader,\n} from \"@/token/domain/TokenContextLoader\";\n\ndescribe(\"TokenContextLoader\", () => {\n const mockTokenDataSource: TokenDataSource = {\n getTokenInfosPayload: vi.fn(),\n };\n const loader = new TokenContextLoader(mockTokenDataSource);\n\n beforeEach(() => {\n vi.restoreAllMocks();\n vi.spyOn(mockTokenDataSource, \"getTokenInfosPayload\").mockImplementation(\n ({ address }) => Promise.resolve(Right(`payload-${address}`)),\n );\n });\n\n describe(\"canHandle function\", () => {\n const validInput: TokenContextInput = {\n to: \"0xdAC17F958D2ee523a2206206994597C13D831ec7\",\n selector: \"0x095ea7b3\",\n chainId: 1,\n };\n\n it(\"should return true for valid input\", () => {\n expect(loader.canHandle(validInput, [ClearSignContextType.TOKEN])).toBe(\n true,\n );\n });\n\n it(\"should return false for invalid expected type\", () => {\n expect(loader.canHandle(validInput, [ClearSignContextType.NFT])).toBe(\n false,\n );\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, [ClearSignContextType.TOKEN])).toBe(false);\n });\n\n it.each([\n [{ ...validInput, to: undefined }, \"missing to\"],\n [{ ...validInput, selector: undefined }, \"missing selector\"],\n [{ ...validInput, chainId: undefined }, \"missing chainId\"],\n ])(\"should return false for %s\", (input, _description) => {\n expect(loader.canHandle(input, [ClearSignContextType.TOKEN])).toBe(false);\n });\n\n it.each([\n [{ ...validInput, to: \"invalid-hex\" }, \"invalid to hex\"],\n [{ ...validInput, to: \"0x\" }, \"empty to hex\"],\n [{ ...validInput, to: \"not-hex-at-all\" }, \"non-hex to\"],\n [{ ...validInput, selector: \"invalid-hex\" }, \"invalid selector hex\"],\n [{ ...validInput, selector: \"0x\" }, \"empty selector hex\"],\n [{ ...validInput, selector: \"not-hex-at-all\" }, \"non-hex selector\"],\n ])(\"should return false for %s\", (input, _description) => {\n expect(loader.canHandle(input, [ClearSignContextType.TOKEN])).toBe(false);\n });\n\n it.each([\n [{ ...validInput, chainId: \"1\" }, \"string chainId\"],\n [{ ...validInput, chainId: null }, \"null chainId\"],\n [{ ...validInput, chainId: undefined }, \"undefined chainId\"],\n ])(\"should return false for %s\", (input, _description) => {\n expect(loader.canHandle(input, [ClearSignContextType.TOKEN])).toBe(false);\n });\n });\n\n describe(\"load function\", () => {\n it(\"should return an error when datasource returns an error\", async () => {\n // GIVEN\n const input: TokenContextInput = {\n to: \"0xdAC17F958D2ee523a2206206994597C13D831ec7\",\n chainId: 1,\n selector: \"0x095ea7b3\",\n };\n vi.spyOn(mockTokenDataSource, \"getTokenInfosPayload\").mockResolvedValue(\n Left(new Error(\"error\")),\n );\n\n // WHEN\n const result = await loader.load(input);\n\n // THEN\n expect(result).toEqual([\n { type: ClearSignContextType.ERROR, error: new Error(\"error\") },\n ]);\n });\n\n it(\"should return a correct response\", async () => {\n // GIVEN\n const input: TokenContextInput = {\n to: \"0xdAC17F958D2ee523a2206206994597C13D831ec7\",\n chainId: 1,\n selector: \"0x095ea7b3\",\n };\n\n // WHEN\n const result = await loader.load(input);\n\n // THEN\n expect(result).toEqual([\n {\n type: ClearSignContextType.TOKEN,\n payload: \"payload-0xdAC17F958D2ee523a2206206994597C13D831ec7\",\n },\n ]);\n });\n });\n});\n"],
5
+ "mappings": "aAAA,IAAAA,EAA4B,qBAE5BC,EAAqC,2CAErCC,EAGO,6CAEP,SAAS,qBAAsB,IAAM,CACnC,MAAMC,EAAuC,CAC3C,qBAAsB,GAAG,GAAG,CAC9B,EACMC,EAAS,IAAI,qBAAmBD,CAAmB,EAEzD,WAAW,IAAM,CACf,GAAG,gBAAgB,EACnB,GAAG,MAAMA,EAAqB,sBAAsB,EAAE,mBACpD,CAAC,CAAE,QAAAE,CAAQ,IAAM,QAAQ,WAAQ,SAAM,WAAWA,CAAO,EAAE,CAAC,CAC9D,CACF,CAAC,EAED,SAAS,qBAAsB,IAAM,CACnC,MAAMC,EAAgC,CACpC,GAAI,6CACJ,SAAU,aACV,QAAS,CACX,EAEA,GAAG,qCAAsC,IAAM,CAC7C,OAAOF,EAAO,UAAUE,EAAY,CAAC,uBAAqB,KAAK,CAAC,CAAC,EAAE,KACjE,EACF,CACF,CAAC,EAED,GAAG,gDAAiD,IAAM,CACxD,OAAOF,EAAO,UAAUE,EAAY,CAAC,uBAAqB,GAAG,CAAC,CAAC,EAAE,KAC/D,EACF,CACF,CAAC,EAED,GAAG,KAAK,CACN,CAAC,KAAM,YAAY,EACnB,CAAC,OAAW,iBAAiB,EAC7B,CAAC,CAAC,EAAG,cAAc,EACnB,CAAC,SAAU,cAAc,EACzB,CAAC,IAAK,cAAc,CACtB,CAAC,EAAE,6BAA8B,CAACC,EAAOC,IAAiB,CACxD,OAAOJ,EAAO,UAAUG,EAAO,CAAC,uBAAqB,KAAK,CAAC,CAAC,EAAE,KAAK,EAAK,CAC1E,CAAC,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SAAY,CAExE,MAAMA,EAA2B,CAC/B,GAAI,6CACJ,QAAS,EACT,SAAU,YACZ,EACA,GAAG,MAAMJ,EAAqB,sBAAsB,EAAE,qBACpD,QAAK,IAAI,MAAM,OAAO,CAAC,CACzB,EAGA,MAAMM,EAAS,MAAML,EAAO,KAAKG,CAAK,EAGtC,OAAOE,CAAM,EAAE,QAAQ,CACrB,CAAE,KAAM,uBAAqB,MAAO,MAAO,IAAI,MAAM,OAAO,CAAE,CAChE,CAAC,CACH,CAAC,EAED,GAAG,mCAAoC,SAAY,CAEjD,MAAMF,EAA2B,CAC/B,GAAI,6CACJ,QAAS,EACT,SAAU,YACZ,EAGME,EAAS,MAAML,EAAO,KAAKG,CAAK,EAGtC,OAAOE,CAAM,EAAE,QAAQ,CACrB,CACE,KAAM,uBAAqB,MAC3B,QAAS,oDACX,CACF,CAAC,CACH,CAAC,CACH,CAAC,CACH,CAAC",
6
+ "names": ["import_purify_ts", "import_ClearSignContext", "import_TokenContextLoader", "mockTokenDataSource", "loader", "address", "validInput", "input", "_description", "result"]
7
7
  }
@@ -1,2 +1,2 @@
1
- "use strict";var l=Object.defineProperty;var d=Object.getOwnPropertyDescriptor;var g=Object.getOwnPropertyNames;var C=Object.prototype.hasOwnProperty;var y=(o,t)=>{for(var r in t)l(o,r,{get:t[r],enumerable:!0})},f=(o,t,r,a)=>{if(t&&typeof t=="object"||typeof t=="function")for(let e of g(t))!C.call(o,e)&&e!==r&&l(o,e,{get:()=>t[e],enumerable:!(a=d(t,e))||a.enumerable});return o};var h=o=>f(l({},"__esModule",{value:!0}),o),p=(o,t,r,a)=>{for(var e=a>1?void 0:a?d(t,r):t,s=o.length-1,n;s>=0;s--)(n=o[s])&&(e=(a?n(t,r,e):n(e))||e);return a&&e&&l(t,r,e),e},u=(o,t)=>(r,a)=>t(r,a,o);var x={};y(x,{TrustedNameContextLoader:()=>i});module.exports=h(x);var c=require("inversify"),m=require("../../shared/model/ClearSignContext"),S=require("../../trusted-name/di/trustedNameTypes");let i=class{_dataSource;constructor(t){this._dataSource=t}async load(t){const{chainId:r,domain:a,challenge:e}=t;return!a||!e?[]:this.isDomainValid(a)?[(await this._dataSource.getDomainNamePayload({chainId:r,domain:a,challenge:e})).caseOf({Left:n=>({type:m.ClearSignContextType.ERROR,error:n}),Right:n=>({type:m.ClearSignContextType.TRUSTED_NAME,payload:n})})]:[{type:m.ClearSignContextType.ERROR,error:new Error("[ContextModule] TrustedNameLoader: invalid domain")}]}isDomainValid(t){const r=t.length>0&&Number(t.length)<30,a=new RegExp("^[a-zA-Z0-9\\-\\_\\.]+$").test(t);return r&&a}};i=p([(0,c.injectable)(),u(0,(0,c.inject)(S.trustedNameTypes.TrustedNameDataSource))],i);0&&(module.exports={TrustedNameContextLoader});
1
+ "use strict";var d=Object.defineProperty;var m=Object.getOwnPropertyDescriptor;var y=Object.getOwnPropertyNames;var h=Object.prototype.hasOwnProperty;var C=(r,e)=>{for(var t in e)d(r,t,{get:e[t],enumerable:!0})},S=(r,e,t,a)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of y(e))!h.call(r,n)&&n!==t&&d(r,n,{get:()=>e[n],enumerable:!(a=m(e,n))||a.enumerable});return r};var T=r=>S(d({},"__esModule",{value:!0}),r),g=(r,e,t,a)=>{for(var n=a>1?void 0:a?m(e,t):e,s=r.length-1,o;s>=0;s--)(o=r[s])&&(n=(a?o(e,t,n):o(n))||n);return a&&n&&d(e,t,n),n},u=(r,e)=>(t,a)=>e(t,a,r);var f={};C(f,{TrustedNameContextLoader:()=>i});module.exports=T(f);var c=require("inversify"),l=require("../../shared/model/ClearSignContext"),p=require("../../trusted-name/di/trustedNameTypes");const x=[l.ClearSignContextType.TRUSTED_NAME];let i=class{_dataSource;constructor(e){this._dataSource=e}canHandle(e,t){return typeof e=="object"&&e!==null&&"chainId"in e&&"domain"in e&&"challenge"in e&&typeof e.chainId=="number"&&typeof e.domain=="string"&&e.domain.length>0&&typeof e.challenge=="string"&&e.challenge.length>0&&x.every(a=>t.includes(a))}async load(e){const{chainId:t,domain:a,challenge:n}=e;return this.isDomainValid(a)?[(await this._dataSource.getDomainNamePayload({chainId:t,domain:a,challenge:n})).caseOf({Left:o=>({type:l.ClearSignContextType.ERROR,error:o}),Right:o=>({type:l.ClearSignContextType.TRUSTED_NAME,payload:o})})]:[{type:l.ClearSignContextType.ERROR,error:new Error("[ContextModule] TrustedNameLoader: invalid domain")}]}isDomainValid(e){const t=e.length>0&&Number(e.length)<30,a=new RegExp("^[a-zA-Z0-9\\-\\_\\.]+$").test(e);return t&&a}};i=g([(0,c.injectable)(),u(0,(0,c.inject)(p.trustedNameTypes.TrustedNameDataSource))],i);0&&(module.exports={TrustedNameContextLoader});
2
2
  //# sourceMappingURL=TrustedNameContextLoader.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../../src/trusted-name/domain/TrustedNameContextLoader.ts"],
4
- "sourcesContent": ["import { inject, injectable } from \"inversify\";\n\nimport { ContextLoader } from \"@/shared/domain/ContextLoader\";\nimport {\n ClearSignContext,\n ClearSignContextType,\n} from \"@/shared/model/ClearSignContext\";\nimport { TransactionContext } from \"@/shared/model/TransactionContext\";\nimport type { TrustedNameDataSource } from \"@/trusted-name/data/TrustedNameDataSource\";\nimport { trustedNameTypes } from \"@/trusted-name/di/trustedNameTypes\";\n\n@injectable()\nexport class TrustedNameContextLoader implements ContextLoader {\n private _dataSource: TrustedNameDataSource;\n\n constructor(\n @inject(trustedNameTypes.TrustedNameDataSource)\n dataSource: TrustedNameDataSource,\n ) {\n this._dataSource = dataSource;\n }\n\n async load(ctx: TransactionContext): Promise<ClearSignContext[]> {\n const { chainId, domain, challenge } = ctx;\n\n if (!domain || !challenge) {\n return [];\n }\n\n if (!this.isDomainValid(domain)) {\n return [\n {\n type: ClearSignContextType.ERROR,\n error: new Error(\"[ContextModule] TrustedNameLoader: invalid domain\"),\n },\n ];\n }\n\n const payload = await this._dataSource.getDomainNamePayload({\n chainId,\n domain,\n challenge,\n });\n\n return [\n payload.caseOf({\n Left: (error): ClearSignContext => ({\n type: ClearSignContextType.ERROR,\n error: error,\n }),\n Right: (value): ClearSignContext => ({\n type: ClearSignContextType.TRUSTED_NAME,\n payload: value,\n }),\n }),\n ];\n }\n\n private isDomainValid(domain: string) {\n const lengthIsValid = domain.length > 0 && Number(domain.length) < 30;\n const containsOnlyValidChars = new RegExp(\"^[a-zA-Z0-9\\\\-\\\\_\\\\.]+$\").test(\n domain,\n );\n\n return lengthIsValid && containsOnlyValidChars;\n }\n}\n"],
5
- "mappings": "okBAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,8BAAAE,IAAA,eAAAC,EAAAH,GAAA,IAAAI,EAAmC,qBAGnCC,EAGO,2CAGPC,EAAiC,8CAG1B,IAAMC,EAAN,KAAwD,CACrD,YAER,YAEEC,EACA,CACA,KAAK,YAAcA,CACrB,CAEA,MAAM,KAAKC,EAAsD,CAC/D,KAAM,CAAE,QAAAC,EAAS,OAAAC,EAAQ,UAAAC,CAAU,EAAIH,EAEvC,MAAI,CAACE,GAAU,CAACC,EACP,CAAC,EAGL,KAAK,cAAcD,CAAM,EAevB,EANS,MAAM,KAAK,YAAY,qBAAqB,CAC1D,QAAAD,EACA,OAAAC,EACA,UAAAC,CACF,CAAC,GAGS,OAAO,CACb,KAAOC,IAA6B,CAClC,KAAM,uBAAqB,MAC3B,MAAOA,CACT,GACA,MAAQC,IAA6B,CACnC,KAAM,uBAAqB,aAC3B,QAASA,CACX,EACF,CAAC,CACH,EAzBS,CACL,CACE,KAAM,uBAAqB,MAC3B,MAAO,IAAI,MAAM,mDAAmD,CACtE,CACF,CAqBJ,CAEQ,cAAcH,EAAgB,CACpC,MAAMI,EAAgBJ,EAAO,OAAS,GAAK,OAAOA,EAAO,MAAM,EAAI,GAC7DK,EAAyB,IAAI,OAAO,yBAAyB,EAAE,KACnEL,CACF,EAEA,OAAOI,GAAiBC,CAC1B,CACF,EAtDaT,EAANU,EAAA,IADN,cAAW,EAKPC,EAAA,eAAO,mBAAiB,qBAAqB,IAJrCX",
6
- "names": ["TrustedNameContextLoader_exports", "__export", "TrustedNameContextLoader", "__toCommonJS", "import_inversify", "import_ClearSignContext", "import_trustedNameTypes", "TrustedNameContextLoader", "dataSource", "ctx", "chainId", "domain", "challenge", "error", "value", "lengthIsValid", "containsOnlyValidChars", "__decorateClass", "__decorateParam"]
4
+ "sourcesContent": ["import { inject, injectable } from \"inversify\";\n\nimport { ContextLoader } from \"@/shared/domain/ContextLoader\";\nimport {\n ClearSignContext,\n ClearSignContextType,\n} from \"@/shared/model/ClearSignContext\";\nimport type { TrustedNameDataSource } from \"@/trusted-name/data/TrustedNameDataSource\";\nimport { trustedNameTypes } from \"@/trusted-name/di/trustedNameTypes\";\n\nexport type TrustedNameContextInput = {\n chainId: number;\n domain: string;\n challenge: string;\n};\n\nconst SUPPORTED_TYPES: ClearSignContextType[] = [\n ClearSignContextType.TRUSTED_NAME,\n];\n\n@injectable()\nexport class TrustedNameContextLoader\n implements ContextLoader<TrustedNameContextInput>\n{\n private _dataSource: TrustedNameDataSource;\n\n constructor(\n @inject(trustedNameTypes.TrustedNameDataSource)\n dataSource: TrustedNameDataSource,\n ) {\n this._dataSource = dataSource;\n }\n\n canHandle(\n input: unknown,\n expectedTypes: ClearSignContextType[],\n ): input is TrustedNameContextInput {\n return (\n typeof input === \"object\" &&\n input !== null &&\n \"chainId\" in input &&\n \"domain\" in input &&\n \"challenge\" in input &&\n typeof input.chainId === \"number\" &&\n typeof input.domain === \"string\" &&\n input.domain.length > 0 &&\n typeof input.challenge === \"string\" &&\n input.challenge.length > 0 &&\n SUPPORTED_TYPES.every((type) => expectedTypes.includes(type))\n );\n }\n\n async load(input: TrustedNameContextInput): Promise<ClearSignContext[]> {\n const { chainId, domain, challenge } = input;\n\n if (!this.isDomainValid(domain)) {\n return [\n {\n type: ClearSignContextType.ERROR,\n error: new Error(\"[ContextModule] TrustedNameLoader: invalid domain\"),\n },\n ];\n }\n\n const payload = await this._dataSource.getDomainNamePayload({\n chainId,\n domain,\n challenge,\n });\n\n return [\n payload.caseOf({\n Left: (error): ClearSignContext => ({\n type: ClearSignContextType.ERROR,\n error: error,\n }),\n Right: (value): ClearSignContext => ({\n type: ClearSignContextType.TRUSTED_NAME,\n payload: value,\n }),\n }),\n ];\n }\n\n private isDomainValid(domain: string) {\n const lengthIsValid = domain.length > 0 && Number(domain.length) < 30;\n const containsOnlyValidChars = new RegExp(\"^[a-zA-Z0-9\\\\-\\\\_\\\\.]+$\").test(\n domain,\n );\n\n return lengthIsValid && containsOnlyValidChars;\n }\n}\n"],
5
+ "mappings": "okBAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,8BAAAE,IAAA,eAAAC,EAAAH,GAAA,IAAAI,EAAmC,qBAGnCC,EAGO,2CAEPC,EAAiC,8CAQjC,MAAMC,EAA0C,CAC9C,uBAAqB,YACvB,EAGO,IAAMC,EAAN,KAEP,CACU,YAER,YAEEC,EACA,CACA,KAAK,YAAcA,CACrB,CAEA,UACEC,EACAC,EACkC,CAClC,OACE,OAAOD,GAAU,UACjBA,IAAU,MACV,YAAaA,GACb,WAAYA,GACZ,cAAeA,GACf,OAAOA,EAAM,SAAY,UACzB,OAAOA,EAAM,QAAW,UACxBA,EAAM,OAAO,OAAS,GACtB,OAAOA,EAAM,WAAc,UAC3BA,EAAM,UAAU,OAAS,GACzBH,EAAgB,MAAOK,GAASD,EAAc,SAASC,CAAI,CAAC,CAEhE,CAEA,MAAM,KAAKF,EAA6D,CACtE,KAAM,CAAE,QAAAG,EAAS,OAAAC,EAAQ,UAAAC,CAAU,EAAIL,EAEvC,OAAK,KAAK,cAAcI,CAAM,EAevB,EANS,MAAM,KAAK,YAAY,qBAAqB,CAC1D,QAAAD,EACA,OAAAC,EACA,UAAAC,CACF,CAAC,GAGS,OAAO,CACb,KAAOC,IAA6B,CAClC,KAAM,uBAAqB,MAC3B,MAAOA,CACT,GACA,MAAQC,IAA6B,CACnC,KAAM,uBAAqB,aAC3B,QAASA,CACX,EACF,CAAC,CACH,EAzBS,CACL,CACE,KAAM,uBAAqB,MAC3B,MAAO,IAAI,MAAM,mDAAmD,CACtE,CACF,CAqBJ,CAEQ,cAAcH,EAAgB,CACpC,MAAMI,EAAgBJ,EAAO,OAAS,GAAK,OAAOA,EAAO,MAAM,EAAI,GAC7DK,EAAyB,IAAI,OAAO,yBAAyB,EAAE,KACnEL,CACF,EAEA,OAAOI,GAAiBC,CAC1B,CACF,EAvEaX,EAANY,EAAA,IADN,cAAW,EAOPC,EAAA,eAAO,mBAAiB,qBAAqB,IANrCb",
6
+ "names": ["TrustedNameContextLoader_exports", "__export", "TrustedNameContextLoader", "__toCommonJS", "import_inversify", "import_ClearSignContext", "import_trustedNameTypes", "SUPPORTED_TYPES", "TrustedNameContextLoader", "dataSource", "input", "expectedTypes", "type", "chainId", "domain", "challenge", "error", "value", "lengthIsValid", "containsOnlyValidChars", "__decorateClass", "__decorateParam"]
7
7
  }
@@ -1,2 +1,2 @@
1
- "use strict";var l=require("purify-ts"),r=require("../../shared/model/ClearSignContext"),t=require("../../trusted-name/domain/TrustedNameContextLoader");describe("TrustedNameContextLoader",()=>{const o={getDomainNamePayload:vi.fn(),getTrustedNamePayload:vi.fn()};beforeEach(()=>{vi.restoreAllMocks(),vi.spyOn(o,"getDomainNamePayload").mockResolvedValue((0,l.Right)("payload"))}),describe("load function",()=>{it("should return an empty array when no domain or registry",async()=>{const e={},n=new t.TrustedNameContextLoader(o),a=()=>n.load(e);await expect(a()).resolves.toEqual([])}),it("should return an error when domain > max length",async()=>{const e={domain:"maxlength-maxlength-maxlength-maxlength-maxlength-maxlength",challenge:"challenge"},a=await new t.TrustedNameContextLoader(o).load(e);expect(a).toEqual([{type:r.ClearSignContextType.ERROR,error:new Error("[ContextModule] TrustedNameLoader: invalid domain")}])}),it("should return an error when domain is not valid",async()=>{const e={domain:"hello\u{1F44B}",challenge:"challenge"},a=await new t.TrustedNameContextLoader(o).load(e);expect(a).toEqual([{type:r.ClearSignContextType.ERROR,error:new Error("[ContextModule] TrustedNameLoader: invalid domain")}])}),it("should return a payload",async()=>{const e={domain:"hello.eth",challenge:"challenge"},a=await new t.TrustedNameContextLoader(o).load(e);expect(a).toEqual([{type:r.ClearSignContextType.TRUSTED_NAME,payload:"payload"}])}),it("should return an error when unable to fetch the datasource",async()=>{const e={domain:"hello.eth",challenge:"challenge"};vi.spyOn(o,"getDomainNamePayload").mockResolvedValue((0,l.Left)(new Error("error")));const a=await new t.TrustedNameContextLoader(o).load(e);expect(a).toEqual([{type:r.ClearSignContextType.ERROR,error:new Error("error")}])}),it("should return an empty array when no challenge",async()=>{const e={domain:"hello.eth",challenge:void 0},a=await new t.TrustedNameContextLoader(o).load(e);expect(a).toEqual([])})})});
1
+ "use strict";var o=require("purify-ts"),t=require("../../shared/model/ClearSignContext"),d=require("../../trusted-name/domain/TrustedNameContextLoader");describe("TrustedNameContextLoader",()=>{const l={getDomainNamePayload:vi.fn(),getTrustedNamePayload:vi.fn()},a=new d.TrustedNameContextLoader(l);beforeEach(()=>{vi.restoreAllMocks(),vi.spyOn(l,"getDomainNamePayload").mockResolvedValue((0,o.Right)("payload"))}),describe("canHandle function",()=>{const e={chainId:1,domain:"hello.eth",challenge:"challenge"};it("should return true for valid input",()=>{expect(a.canHandle(e,[t.ClearSignContextType.TRUSTED_NAME])).toBe(!0)}),it("should return false for invalid expected type",()=>{expect(a.canHandle(e,[t.ClearSignContextType.TOKEN])).toBe(!1)}),it.each([[null,"null input"],[void 0,"undefined input"],[{},"empty object"],["string","string input"],[123,"number input"]])("should return false for %s",(n,r)=>{expect(a.canHandle(n,[t.ClearSignContextType.TRUSTED_NAME])).toBe(!1)}),it.each([[{...e,chainId:void 0},"missing chainId"],[{...e,domain:void 0},"missing domain"],[{...e,challenge:void 0},"missing challenge"]])("should return false for %s",(n,r)=>{expect(a.canHandle(n,[t.ClearSignContextType.TRUSTED_NAME])).toBe(!1)}),it.each([[{...e,domain:""},"empty domain"],[{...e,challenge:""},"empty challenge"],[{...e,chainId:"1"},"string chainId"],[{...e,chainId:null},"null chainId"],[{...e,domain:123},"numeric domain"],[{...e,challenge:123},"numeric challenge"]])("should return false for %s",(n,r)=>{expect(a.canHandle(n,[t.ClearSignContextType.TRUSTED_NAME])).toBe(!1)})}),describe("load function",()=>{it("should return an error when domain > max length",async()=>{const e={chainId:1,domain:"maxlength-maxlength-maxlength-maxlength-maxlength-maxlength",challenge:"challenge"},n=await a.load(e);expect(n).toEqual([{type:t.ClearSignContextType.ERROR,error:new Error("[ContextModule] TrustedNameLoader: invalid domain")}])}),it("should return an error when domain is not valid",async()=>{const e={chainId:1,domain:"hello\u{1F44B}",challenge:"challenge"},n=await a.load(e);expect(n).toEqual([{type:t.ClearSignContextType.ERROR,error:new Error("[ContextModule] TrustedNameLoader: invalid domain")}])}),it("should return a payload",async()=>{const e={chainId:1,domain:"hello.eth",challenge:"challenge"},n=await a.load(e);expect(n).toEqual([{type:t.ClearSignContextType.TRUSTED_NAME,payload:"payload"}])}),it("should return an error when unable to fetch the datasource",async()=>{const e={chainId:1,domain:"hello.eth",challenge:"challenge"};vi.spyOn(l,"getDomainNamePayload").mockResolvedValue((0,o.Left)(new Error("error")));const n=await a.load(e);expect(n).toEqual([{type:t.ClearSignContextType.ERROR,error:new Error("error")}])})})});
2
2
  //# sourceMappingURL=TrustedNameContextLoader.test.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../../src/trusted-name/domain/TrustedNameContextLoader.test.ts"],
4
- "sourcesContent": ["import { Left, Right } from \"purify-ts\";\n\nimport { ClearSignContextType } from \"@/shared/model/ClearSignContext\";\nimport { type TransactionContext } from \"@/shared/model/TransactionContext\";\nimport { type TrustedNameDataSource } from \"@/trusted-name/data/TrustedNameDataSource\";\nimport { TrustedNameContextLoader } from \"@/trusted-name/domain/TrustedNameContextLoader\";\n\ndescribe(\"TrustedNameContextLoader\", () => {\n const mockTrustedNameDataSource: TrustedNameDataSource = {\n getDomainNamePayload: vi.fn(),\n getTrustedNamePayload: vi.fn(),\n };\n\n beforeEach(() => {\n vi.restoreAllMocks();\n vi.spyOn(\n mockTrustedNameDataSource,\n \"getDomainNamePayload\",\n ).mockResolvedValue(Right(\"payload\"));\n });\n\n describe(\"load function\", () => {\n it(\"should return an empty array when no domain or registry\", async () => {\n const transaction = {} as TransactionContext;\n const loader = new TrustedNameContextLoader(mockTrustedNameDataSource);\n const promise = () => loader.load(transaction);\n\n await expect(promise()).resolves.toEqual([]);\n });\n\n it(\"should return an error when domain > max length\", async () => {\n const transaction = {\n domain: \"maxlength-maxlength-maxlength-maxlength-maxlength-maxlength\",\n challenge: \"challenge\",\n } as TransactionContext;\n\n const loader = new TrustedNameContextLoader(mockTrustedNameDataSource);\n const result = await loader.load(transaction);\n\n expect(result).toEqual([\n {\n type: ClearSignContextType.ERROR,\n error: new Error(\"[ContextModule] TrustedNameLoader: invalid domain\"),\n },\n ]);\n });\n\n it(\"should return an error when domain is not valid\", async () => {\n const transaction = {\n domain: \"hello\uD83D\uDC4B\",\n challenge: \"challenge\",\n } as TransactionContext;\n\n const loader = new TrustedNameContextLoader(mockTrustedNameDataSource);\n const result = await loader.load(transaction);\n\n expect(result).toEqual([\n {\n type: ClearSignContextType.ERROR,\n error: new Error(\"[ContextModule] TrustedNameLoader: invalid domain\"),\n },\n ]);\n });\n\n it(\"should return a payload\", async () => {\n const transaction = {\n domain: \"hello.eth\",\n challenge: \"challenge\",\n } as TransactionContext;\n\n const loader = new TrustedNameContextLoader(mockTrustedNameDataSource);\n const result = await loader.load(transaction);\n\n expect(result).toEqual([\n {\n type: ClearSignContextType.TRUSTED_NAME,\n payload: \"payload\",\n },\n ]);\n });\n\n it(\"should return an error when unable to fetch the datasource\", async () => {\n // GIVEN\n const transaction = {\n domain: \"hello.eth\",\n challenge: \"challenge\",\n } as TransactionContext;\n\n // WHEN\n vi.spyOn(\n mockTrustedNameDataSource,\n \"getDomainNamePayload\",\n ).mockResolvedValue(Left(new Error(\"error\")));\n const loader = new TrustedNameContextLoader(mockTrustedNameDataSource);\n const result = await loader.load(transaction);\n\n // THEN\n expect(result).toEqual([\n { type: ClearSignContextType.ERROR, error: new Error(\"error\") },\n ]);\n });\n\n it(\"should return an empty array when no challenge\", async () => {\n // GIVEN\n const transaction = {\n domain: \"hello.eth\",\n challenge: undefined,\n } as TransactionContext;\n\n // WHEN\n const loader = new TrustedNameContextLoader(mockTrustedNameDataSource);\n const result = await loader.load(transaction);\n\n // THEN\n expect(result).toEqual([]);\n });\n });\n});\n"],
5
- "mappings": "aAAA,IAAAA,EAA4B,qBAE5BC,EAAqC,2CAGrCC,EAAyC,0DAEzC,SAAS,2BAA4B,IAAM,CACzC,MAAMC,EAAmD,CACvD,qBAAsB,GAAG,GAAG,EAC5B,sBAAuB,GAAG,GAAG,CAC/B,EAEA,WAAW,IAAM,CACf,GAAG,gBAAgB,EACnB,GAAG,MACDA,EACA,sBACF,EAAE,qBAAkB,SAAM,SAAS,CAAC,CACtC,CAAC,EAED,SAAS,gBAAiB,IAAM,CAC9B,GAAG,0DAA2D,SAAY,CACxE,MAAMC,EAAc,CAAC,EACfC,EAAS,IAAI,2BAAyBF,CAAyB,EAC/DG,EAAU,IAAMD,EAAO,KAAKD,CAAW,EAE7C,MAAM,OAAOE,EAAQ,CAAC,EAAE,SAAS,QAAQ,CAAC,CAAC,CAC7C,CAAC,EAED,GAAG,kDAAmD,SAAY,CAChE,MAAMF,EAAc,CAClB,OAAQ,8DACR,UAAW,WACb,EAGMG,EAAS,MADA,IAAI,2BAAyBJ,CAAyB,EACzC,KAAKC,CAAW,EAE5C,OAAOG,CAAM,EAAE,QAAQ,CACrB,CACE,KAAM,uBAAqB,MAC3B,MAAO,IAAI,MAAM,mDAAmD,CACtE,CACF,CAAC,CACH,CAAC,EAED,GAAG,kDAAmD,SAAY,CAChE,MAAMH,EAAc,CAClB,OAAQ,iBACR,UAAW,WACb,EAGMG,EAAS,MADA,IAAI,2BAAyBJ,CAAyB,EACzC,KAAKC,CAAW,EAE5C,OAAOG,CAAM,EAAE,QAAQ,CACrB,CACE,KAAM,uBAAqB,MAC3B,MAAO,IAAI,MAAM,mDAAmD,CACtE,CACF,CAAC,CACH,CAAC,EAED,GAAG,0BAA2B,SAAY,CACxC,MAAMH,EAAc,CAClB,OAAQ,YACR,UAAW,WACb,EAGMG,EAAS,MADA,IAAI,2BAAyBJ,CAAyB,EACzC,KAAKC,CAAW,EAE5C,OAAOG,CAAM,EAAE,QAAQ,CACrB,CACE,KAAM,uBAAqB,aAC3B,QAAS,SACX,CACF,CAAC,CACH,CAAC,EAED,GAAG,6DAA8D,SAAY,CAE3E,MAAMH,EAAc,CAClB,OAAQ,YACR,UAAW,WACb,EAGA,GAAG,MACDD,EACA,sBACF,EAAE,qBAAkB,QAAK,IAAI,MAAM,OAAO,CAAC,CAAC,EAE5C,MAAMI,EAAS,MADA,IAAI,2BAAyBJ,CAAyB,EACzC,KAAKC,CAAW,EAG5C,OAAOG,CAAM,EAAE,QAAQ,CACrB,CAAE,KAAM,uBAAqB,MAAO,MAAO,IAAI,MAAM,OAAO,CAAE,CAChE,CAAC,CACH,CAAC,EAED,GAAG,iDAAkD,SAAY,CAE/D,MAAMH,EAAc,CAClB,OAAQ,YACR,UAAW,MACb,EAIMG,EAAS,MADA,IAAI,2BAAyBJ,CAAyB,EACzC,KAAKC,CAAW,EAG5C,OAAOG,CAAM,EAAE,QAAQ,CAAC,CAAC,CAC3B,CAAC,CACH,CAAC,CACH,CAAC",
6
- "names": ["import_purify_ts", "import_ClearSignContext", "import_TrustedNameContextLoader", "mockTrustedNameDataSource", "transaction", "loader", "promise", "result"]
4
+ "sourcesContent": ["import { Left, Right } from \"purify-ts\";\n\nimport { ClearSignContextType } from \"@/shared/model/ClearSignContext\";\nimport { type TrustedNameDataSource } from \"@/trusted-name/data/TrustedNameDataSource\";\nimport {\n type TrustedNameContextInput,\n TrustedNameContextLoader,\n} from \"@/trusted-name/domain/TrustedNameContextLoader\";\n\ndescribe(\"TrustedNameContextLoader\", () => {\n const mockTrustedNameDataSource: TrustedNameDataSource = {\n getDomainNamePayload: vi.fn(),\n getTrustedNamePayload: vi.fn(),\n };\n const loader = new TrustedNameContextLoader(mockTrustedNameDataSource);\n\n beforeEach(() => {\n vi.restoreAllMocks();\n vi.spyOn(\n mockTrustedNameDataSource,\n \"getDomainNamePayload\",\n ).mockResolvedValue(Right(\"payload\"));\n });\n\n describe(\"canHandle function\", () => {\n const validInput: TrustedNameContextInput = {\n chainId: 1,\n domain: \"hello.eth\",\n challenge: \"challenge\",\n };\n\n it(\"should return true for valid input\", () => {\n expect(\n loader.canHandle(validInput, [ClearSignContextType.TRUSTED_NAME]),\n ).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 });\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, [ClearSignContextType.TRUSTED_NAME])).toBe(\n false,\n );\n });\n\n it.each([\n [{ ...validInput, chainId: undefined }, \"missing chainId\"],\n [{ ...validInput, domain: undefined }, \"missing domain\"],\n [{ ...validInput, challenge: undefined }, \"missing challenge\"],\n ])(\"should return false for %s\", (input, _description) => {\n expect(loader.canHandle(input, [ClearSignContextType.TRUSTED_NAME])).toBe(\n false,\n );\n });\n\n it.each([\n [{ ...validInput, domain: \"\" }, \"empty domain\"],\n [{ ...validInput, challenge: \"\" }, \"empty challenge\"],\n [{ ...validInput, chainId: \"1\" }, \"string chainId\"],\n [{ ...validInput, chainId: null }, \"null chainId\"],\n [{ ...validInput, domain: 123 }, \"numeric domain\"],\n [{ ...validInput, challenge: 123 }, \"numeric challenge\"],\n ])(\"should return false for %s\", (input, _description) => {\n expect(loader.canHandle(input, [ClearSignContextType.TRUSTED_NAME])).toBe(\n false,\n );\n });\n });\n\n describe(\"load function\", () => {\n it(\"should return an error when domain > max length\", async () => {\n const input: TrustedNameContextInput = {\n chainId: 1,\n domain: \"maxlength-maxlength-maxlength-maxlength-maxlength-maxlength\",\n challenge: \"challenge\",\n };\n\n const result = await loader.load(input);\n\n expect(result).toEqual([\n {\n type: ClearSignContextType.ERROR,\n error: new Error(\"[ContextModule] TrustedNameLoader: invalid domain\"),\n },\n ]);\n });\n\n it(\"should return an error when domain is not valid\", async () => {\n const input: TrustedNameContextInput = {\n chainId: 1,\n domain: \"hello\uD83D\uDC4B\",\n challenge: \"challenge\",\n };\n\n const result = await loader.load(input);\n\n expect(result).toEqual([\n {\n type: ClearSignContextType.ERROR,\n error: new Error(\"[ContextModule] TrustedNameLoader: invalid domain\"),\n },\n ]);\n });\n\n it(\"should return a payload\", async () => {\n const input: TrustedNameContextInput = {\n chainId: 1,\n domain: \"hello.eth\",\n challenge: \"challenge\",\n };\n\n const result = await loader.load(input);\n\n expect(result).toEqual([\n {\n type: ClearSignContextType.TRUSTED_NAME,\n payload: \"payload\",\n },\n ]);\n });\n\n it(\"should return an error when unable to fetch the datasource\", async () => {\n // GIVEN\n const input: TrustedNameContextInput = {\n chainId: 1,\n domain: \"hello.eth\",\n challenge: \"challenge\",\n };\n\n // WHEN\n vi.spyOn(\n mockTrustedNameDataSource,\n \"getDomainNamePayload\",\n ).mockResolvedValue(Left(new Error(\"error\")));\n const result = await loader.load(input);\n\n // THEN\n expect(result).toEqual([\n { type: ClearSignContextType.ERROR, error: new Error(\"error\") },\n ]);\n });\n });\n});\n"],
5
+ "mappings": "aAAA,IAAAA,EAA4B,qBAE5BC,EAAqC,2CAErCC,EAGO,0DAEP,SAAS,2BAA4B,IAAM,CACzC,MAAMC,EAAmD,CACvD,qBAAsB,GAAG,GAAG,EAC5B,sBAAuB,GAAG,GAAG,CAC/B,EACMC,EAAS,IAAI,2BAAyBD,CAAyB,EAErE,WAAW,IAAM,CACf,GAAG,gBAAgB,EAC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O,KAAKE,CAAK,EAGtC,OAAOE,CAAM,EAAE,QAAQ,CACrB,CAAE,KAAM,uBAAqB,MAAO,MAAO,IAAI,MAAM,OAAO,CAAE,CAChE,CAAC,CACH,CAAC,CACH,CAAC,CACH,CAAC",
6
+ "names": ["import_purify_ts", "import_ClearSignContext", "import_TrustedNameContextLoader", "mockTrustedNameDataSource", "loader", "validInput", "input", "_description", "result"]
7
7
  }
@@ -1,2 +1,2 @@
1
- "use strict";var v=Object.create;var f=Object.defineProperty;var C=Object.getOwnPropertyDescriptor;var E=Object.getOwnPropertyNames;var V=Object.getPrototypeOf,N=Object.prototype.hasOwnProperty;var S=(r,e)=>{for(var t in e)f(r,t,{get:e[t],enumerable:!0})},I=(r,e,t,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of E(e))!N.call(r,o)&&o!==t&&f(r,o,{get:()=>e[o],enumerable:!(i=C(e,o))||i.enumerable});return r};var _=(r,e,t)=>(t=r!=null?v(V(r)):{},I(e||!r||!r.__esModule?f(t,"default",{value:r,enumerable:!0}):t,r)),j=r=>I(f({},"__esModule",{value:!0}),r),F=(r,e,t,i)=>{for(var o=i>1?void 0:i?C(e,t):e,s=r.length-1,a;s>=0;s--)(a=r[s])&&(o=(i?a(e,t,o):a(o))||o);return i&&o&&f(e,t,o),o},x=(r,e)=>(t,i)=>e(t,i,r);var P={};S(P,{HttpTypedDataDataSource:()=>d});module.exports=j(P);var M=_(require("axios")),D=_(require("crypto-js/sha224")),m=require("inversify"),l=require("purify-ts"),T=require("../../config/di/configTypes"),g=require("../../shared/constant/HttpHeaders"),y=require("../../shared/model/TypedDataClearSignContext"),b=_(require("../../../package.json"));let d=class{constructor(e){this.config=e}async getTypedDataFilters({chainId:e,address:t,schema:i,version:o}){let s;try{const a=await M.default.request({method:"GET",url:`${this.config.cal.url}/dapps`,params:{contracts:t,chain_id:e,output:"descriptors_eip712",descriptors_eip712_version:o,descriptors_eip712:"<set>",ref:"commit:c9227c39e225932796e87ef4c9eb84f647e16150"},headers:{[g.LEDGER_CLIENT_VERSION_HEADER]:`context-module/${b.default.version}`,[g.LEDGER_ORIGIN_TOKEN_HEADER]:this.config.originToken}}),c=(0,D.default)(JSON.stringify(this.sortTypes(i)).replace(" ","")).toString();t=t.toLowerCase();const u=a.data?.[0]?.descriptors_eip712?.[t]?.[c];if(!u)return(0,l.Left)(new Error(`[ContextModule] HttpTypedDataDataSource: no typed data filters for address ${t} on chain ${e} for schema ${c}`));if(!u.schema||!Array.isArray(u.instructions))return(0,l.Left)(new Error(`[ContextModule] HttpTypedDataDataSource: no message info for address ${t} on chain ${e} for schema ${c}`));const p=[],h={};for(const n of u.instructions)if(this.isInstructionContractInfo(n,this.config.cal.mode))s={displayName:n.display_name,signature:n.signatures[this.config.cal.mode],filtersCount:n.field_mappers_count};else if(o==="v1"&&this.isInstructionFieldV1(n,this.config.cal.mode))p.push({type:"raw",displayName:n.display_name,path:n.field_path,signature:n.signatures[this.config.cal.mode]});else if(this.isInstructionFieldV2(n,this.config.cal.mode))p.push({type:n.format,displayName:n.display_name,path:n.field_path,signature:n.signatures[this.config.cal.mode]});else if(this.isInstructionFieldV2WithCoinRef(n,this.config.cal.mode))p.push({type:n.format,displayName:n.display_name,path:n.field_path,signature:n.signatures[this.config.cal.mode],tokenIndex:n.coin_ref});else if(this.isInstructionFieldV2WithName(n,this.config.cal.mode))p.push({type:n.format,displayName:n.display_name,path:n.field_path,signature:n.signatures[this.config.cal.mode],types:n.name_types,sources:n.name_sources,typesAndSourcesPayload:this.formatTrustedNameTypesAndSources(n)});else if(this.isInstructionCalldataInfo(n,this.config.cal.mode))h[n.calldata_index]={displayName:n.display_name,calldataIndex:n.calldata_index,valueFlag:n.value_filter_flag,calleeFlag:this.convertCalldataPresenceFlag(n.callee_filter_flag),amountFlag:n.amount_filter_flag,spenderFlag:this.convertCalldataPresenceFlag(n.spender_filter_flag),chainIdFlag:n.chain_id_filter_flag,selectorFlag:n.selector_filter_flag,signature:n.signatures[this.config.cal.mode]};else if(this.isInstructionFieldV2Calldata(n,this.config.cal.mode))p.push({type:n.format,displayName:n.display_name,path:n.field_path,signature:n.signatures[this.config.cal.mode],calldataIndex:n.calldata_index});else return(0,l.Left)(new Error(`[ContextModule] HttpTypedDataDataSource: invalid typed data field for address ${t} on chain ${e} for schema ${c}`));return s?(0,l.Right)({messageInfo:s,filters:p,calldatasInfos:h}):(0,l.Left)(new Error(`[ContextModule] HttpTypedDataDataSource: no message info for address ${t} on chain ${e} for schema ${c}`))}catch{return(0,l.Left)(new Error("[ContextModule] HttpTypedDataDataSource: Failed to fetch typed data informations"))}}convertCalldataPresenceFlag(e){switch(e){case"none":return y.TypedDataCalldataParamPresence.None;case"present":return y.TypedDataCalldataParamPresence.Present;case"verifying_contract":return y.TypedDataCalldataParamPresence.VerifyingContract;default:{const t=e;throw new Error(`Unhandled flag: ${t}`)}}}formatTrustedNameTypesAndSources(e){const t=e.name_types.length,i=e.name_sources.length,o=e.descriptor.slice((t+i)*2*-1,i*2*-1),s=e.descriptor.slice(i*2*-1),a=t.toString(16).padStart(2,"0"),c=i.toString(16).padStart(2,"0");return a+o+c+s}isInstructionFieldV1(e,t){return typeof e=="object"&&typeof e.display_name=="string"&&typeof e.field_path=="string"&&typeof e.signatures=="object"&&typeof e.signatures[t]=="string"}isInstructionFieldV2(e,t){return typeof e=="object"&&typeof e.display_name=="string"&&typeof e.field_path=="string"&&typeof e.signatures=="object"&&typeof e.signatures[t]=="string"&&typeof e.format=="string"&&["raw","datetime"].includes(e.format)&&e.coin_ref===void 0}isInstructionFieldV2WithCoinRef(e,t){return typeof e=="object"&&typeof e.display_name=="string"&&typeof e.field_path=="string"&&typeof e.signatures=="object"&&typeof e.signatures[t]=="string"&&typeof e.format=="string"&&["token","amount"].includes(e.format)&&typeof e.coin_ref=="number"}isInstructionFieldV2WithName(e,t){return typeof e=="object"&&typeof e.display_name=="string"&&typeof e.field_path=="string"&&typeof e.signatures=="object"&&typeof e.signatures[t]=="string"&&typeof e.format=="string"&&e.format==="trusted-name"&&e.coin_ref===void 0&&Array.isArray(e.name_types)&&Array.isArray(e.name_sources)&&e.name_types.every(i=>typeof i=="string")&&e.name_sources.every(i=>typeof i=="string")}isInstructionContractInfo(e,t){return typeof e=="object"&&typeof e.display_name=="string"&&typeof e.field_mappers_count=="number"&&typeof e.signatures=="object"&&typeof e.signatures[t]=="string"&&e.field_path===void 0}isInstructionCalldataInfo(e,t){return typeof e=="object"&&typeof e.type=="string"&&e.type==="calldata"&&typeof e.display_name=="string"&&typeof e.calldata_index=="number"&&typeof e.value_filter_flag=="boolean"&&typeof e.chain_id_filter_flag=="boolean"&&typeof e.selector_filter_flag=="boolean"&&typeof e.amount_filter_flag=="boolean"&&["none","present","verifying_contract"].includes(e.callee_filter_flag)&&["none","present","verifying_contract"].includes(e.spender_filter_flag)&&typeof e.signatures=="object"&&typeof e.signatures[t]=="string"}isInstructionFieldV2Calldata(e,t){return typeof e=="object"&&typeof e.display_name=="string"&&typeof e.field_path=="string"&&typeof e.signatures=="object"&&typeof e.signatures[t]=="string"&&typeof e.format=="string"&&["calldata-value","calldata-callee","calldata-chain-id","calldata-selector","calldata-amount","calldata-spender"].includes(e.format)&&typeof e.calldata_index=="number"}sortTypes(e){return Object.fromEntries(Object.entries(e).sort(([t],[i])=>t.localeCompare(i)).map(([t,i])=>[t,i.map(o=>({name:o.name,type:o.type}))]))}};d=F([(0,m.injectable)(),x(0,(0,m.inject)(T.configTypes.Config))],d);0&&(module.exports={HttpTypedDataDataSource});
1
+ "use strict";var v=Object.create;var f=Object.defineProperty;var C=Object.getOwnPropertyDescriptor;var E=Object.getOwnPropertyNames;var V=Object.getPrototypeOf,N=Object.prototype.hasOwnProperty;var S=(r,e)=>{for(var t in e)f(r,t,{get:e[t],enumerable:!0})},I=(r,e,t,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of E(e))!N.call(r,o)&&o!==t&&f(r,o,{get:()=>e[o],enumerable:!(i=C(e,o))||i.enumerable});return r};var _=(r,e,t)=>(t=r!=null?v(V(r)):{},I(e||!r||!r.__esModule?f(t,"default",{value:r,enumerable:!0}):t,r)),j=r=>I(f({},"__esModule",{value:!0}),r),F=(r,e,t,i)=>{for(var o=i>1?void 0:i?C(e,t):e,s=r.length-1,a;s>=0;s--)(a=r[s])&&(o=(i?a(e,t,o):a(o))||o);return i&&o&&f(e,t,o),o},x=(r,e)=>(t,i)=>e(t,i,r);var P={};S(P,{HttpTypedDataDataSource:()=>d});module.exports=j(P);var M=_(require("axios")),D=_(require("crypto-js/sha224")),m=require("inversify"),l=require("purify-ts"),T=require("../../config/di/configTypes"),g=require("../../shared/constant/HttpHeaders"),y=require("../../shared/model/TypedDataClearSignContext"),b=_(require("../../../package.json"));let d=class{constructor(e){this.config=e}async getTypedDataFilters({chainId:e,address:t,schema:i,version:o}){let s;try{const a=await M.default.request({method:"GET",url:`${this.config.cal.url}/dapps`,params:{contracts:t,chain_id:e,output:"descriptors_eip712",descriptors_eip712_version:o,descriptors_eip712:"<set>",ref:`branch:${this.config.cal.branch}`},headers:{[g.LEDGER_CLIENT_VERSION_HEADER]:`context-module/${b.default.version}`,[g.LEDGER_ORIGIN_TOKEN_HEADER]:this.config.originToken}}),c=(0,D.default)(JSON.stringify(this.sortTypes(i)).replace(" ","")).toString();t=t.toLowerCase();const u=a.data?.[0]?.descriptors_eip712?.[t]?.[c];if(!u)return(0,l.Left)(new Error(`[ContextModule] HttpTypedDataDataSource: no typed data filters for address ${t} on chain ${e} for schema ${c}`));if(!u.schema||!Array.isArray(u.instructions))return(0,l.Left)(new Error(`[ContextModule] HttpTypedDataDataSource: no message info for address ${t} on chain ${e} for schema ${c}`));const p=[],h={};for(const n of u.instructions)if(this.isInstructionContractInfo(n,this.config.cal.mode))s={displayName:n.display_name,signature:n.signatures[this.config.cal.mode],filtersCount:n.field_mappers_count};else if(o==="v1"&&this.isInstructionFieldV1(n,this.config.cal.mode))p.push({type:"raw",displayName:n.display_name,path:n.field_path,signature:n.signatures[this.config.cal.mode]});else if(this.isInstructionFieldV2(n,this.config.cal.mode))p.push({type:n.format,displayName:n.display_name,path:n.field_path,signature:n.signatures[this.config.cal.mode]});else if(this.isInstructionFieldV2WithCoinRef(n,this.config.cal.mode))p.push({type:n.format,displayName:n.display_name,path:n.field_path,signature:n.signatures[this.config.cal.mode],tokenIndex:n.coin_ref});else if(this.isInstructionFieldV2WithName(n,this.config.cal.mode))p.push({type:n.format,displayName:n.display_name,path:n.field_path,signature:n.signatures[this.config.cal.mode],types:n.name_types,sources:n.name_sources,typesAndSourcesPayload:this.formatTrustedNameTypesAndSources(n)});else if(this.isInstructionCalldataInfo(n,this.config.cal.mode))h[n.calldata_index]={displayName:n.display_name,calldataIndex:n.calldata_index,valueFlag:n.value_filter_flag,calleeFlag:this.convertCalldataPresenceFlag(n.callee_filter_flag),amountFlag:n.amount_filter_flag,spenderFlag:this.convertCalldataPresenceFlag(n.spender_filter_flag),chainIdFlag:n.chain_id_filter_flag,selectorFlag:n.selector_filter_flag,signature:n.signatures[this.config.cal.mode]};else if(this.isInstructionFieldV2Calldata(n,this.config.cal.mode))p.push({type:n.format,displayName:n.display_name,path:n.field_path,signature:n.signatures[this.config.cal.mode],calldataIndex:n.calldata_index});else return(0,l.Left)(new Error(`[ContextModule] HttpTypedDataDataSource: invalid typed data field for address ${t} on chain ${e} for schema ${c}`));return s?(0,l.Right)({messageInfo:s,filters:p,calldatasInfos:h}):(0,l.Left)(new Error(`[ContextModule] HttpTypedDataDataSource: no message info for address ${t} on chain ${e} for schema ${c}`))}catch{return(0,l.Left)(new Error("[ContextModule] HttpTypedDataDataSource: Failed to fetch typed data informations"))}}convertCalldataPresenceFlag(e){switch(e){case"none":return y.TypedDataCalldataParamPresence.None;case"present":return y.TypedDataCalldataParamPresence.Present;case"verifying_contract":return y.TypedDataCalldataParamPresence.VerifyingContract;default:{const t=e;throw new Error(`Unhandled flag: ${t}`)}}}formatTrustedNameTypesAndSources(e){const t=e.name_types.length,i=e.name_sources.length,o=e.descriptor.slice((t+i)*2*-1,i*2*-1),s=e.descriptor.slice(i*2*-1),a=t.toString(16).padStart(2,"0"),c=i.toString(16).padStart(2,"0");return a+o+c+s}isInstructionFieldV1(e,t){return typeof e=="object"&&typeof e.display_name=="string"&&typeof e.field_path=="string"&&typeof e.signatures=="object"&&typeof e.signatures[t]=="string"}isInstructionFieldV2(e,t){return typeof e=="object"&&typeof e.display_name=="string"&&typeof e.field_path=="string"&&typeof e.signatures=="object"&&typeof e.signatures[t]=="string"&&typeof e.format=="string"&&["raw","datetime"].includes(e.format)&&e.coin_ref===void 0}isInstructionFieldV2WithCoinRef(e,t){return typeof e=="object"&&typeof e.display_name=="string"&&typeof e.field_path=="string"&&typeof e.signatures=="object"&&typeof e.signatures[t]=="string"&&typeof e.format=="string"&&["token","amount"].includes(e.format)&&typeof e.coin_ref=="number"}isInstructionFieldV2WithName(e,t){return typeof e=="object"&&typeof e.display_name=="string"&&typeof e.field_path=="string"&&typeof e.signatures=="object"&&typeof e.signatures[t]=="string"&&typeof e.format=="string"&&e.format==="trusted-name"&&e.coin_ref===void 0&&Array.isArray(e.name_types)&&Array.isArray(e.name_sources)&&e.name_types.every(i=>typeof i=="string")&&e.name_sources.every(i=>typeof i=="string")}isInstructionContractInfo(e,t){return typeof e=="object"&&typeof e.display_name=="string"&&typeof e.field_mappers_count=="number"&&typeof e.signatures=="object"&&typeof e.signatures[t]=="string"&&e.field_path===void 0}isInstructionCalldataInfo(e,t){return typeof e=="object"&&typeof e.type=="string"&&e.type==="calldata"&&typeof e.display_name=="string"&&typeof e.calldata_index=="number"&&typeof e.value_filter_flag=="boolean"&&typeof e.chain_id_filter_flag=="boolean"&&typeof e.selector_filter_flag=="boolean"&&typeof e.amount_filter_flag=="boolean"&&["none","present","verifying_contract"].includes(e.callee_filter_flag)&&["none","present","verifying_contract"].includes(e.spender_filter_flag)&&typeof e.signatures=="object"&&typeof e.signatures[t]=="string"}isInstructionFieldV2Calldata(e,t){return typeof e=="object"&&typeof e.display_name=="string"&&typeof e.field_path=="string"&&typeof e.signatures=="object"&&typeof e.signatures[t]=="string"&&typeof e.format=="string"&&["calldata-value","calldata-callee","calldata-chain-id","calldata-selector","calldata-amount","calldata-spender"].includes(e.format)&&typeof e.calldata_index=="number"}sortTypes(e){return Object.fromEntries(Object.entries(e).sort(([t],[i])=>t.localeCompare(i)).map(([t,i])=>[t,i.map(o=>({name:o.name,type:o.type}))]))}};d=F([(0,m.injectable)(),x(0,(0,m.inject)(T.configTypes.Config))],d);0&&(module.exports={HttpTypedDataDataSource});
2
2
  //# sourceMappingURL=HttpTypedDataDataSource.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../../src/typed-data/data/HttpTypedDataDataSource.ts"],
4
- "sourcesContent": ["import axios from \"axios\";\nimport SHA224 from \"crypto-js/sha224\";\nimport { inject, injectable } from \"inversify\";\nimport { Either, Left, Right } from \"purify-ts\";\n\nimport { configTypes } from \"@/config/di/configTypes\";\nimport type {\n ContextModuleCalMode,\n ContextModuleConfig,\n} from \"@/config/model/ContextModuleConfig\";\nimport {\n LEDGER_CLIENT_VERSION_HEADER,\n LEDGER_ORIGIN_TOKEN_HEADER,\n} from \"@/shared/constant/HttpHeaders\";\nimport type {\n TypedDataCalldataIndex,\n TypedDataFilter,\n TypedDataFilterCalldataInfo,\n TypedDataMessageInfo,\n} from \"@/shared/model/TypedDataClearSignContext\";\nimport { TypedDataCalldataParamPresence } from \"@/shared/model/TypedDataClearSignContext\";\nimport type { TypedDataSchema } from \"@/shared/model/TypedDataContext\";\nimport PACKAGE from \"@root/package.json\";\n\nimport type {\n FiltersDto,\n InstructionCalldataInfo,\n InstructionCalldataParamPresence,\n InstructionContractInfo,\n InstructionField,\n InstructionFieldV1,\n InstructionFieldV2,\n InstructionFieldV2Calldata,\n InstructionFieldV2WithCoinRef,\n InstructionFieldV2WithName,\n} from \"./FiltersDto\";\nimport {\n GetTypedDataFiltersParams,\n GetTypedDataFiltersResult,\n TypedDataDataSource,\n} from \"./TypedDataDataSource\";\n\n@injectable()\nexport class HttpTypedDataDataSource implements TypedDataDataSource {\n constructor(\n @inject(configTypes.Config) private readonly config: ContextModuleConfig,\n ) {}\n\n public async getTypedDataFilters({\n chainId,\n address,\n schema,\n version,\n }: GetTypedDataFiltersParams): Promise<\n Either<Error, GetTypedDataFiltersResult>\n > {\n let messageInfo: TypedDataMessageInfo | undefined = undefined;\n\n try {\n const response = await axios.request<FiltersDto[]>({\n method: \"GET\",\n url: `${this.config.cal.url}/dapps`,\n params: {\n contracts: address,\n chain_id: chainId,\n output: \"descriptors_eip712\",\n descriptors_eip712_version: version,\n descriptors_eip712: \"<set>\",\n // TODO revert to branch\n ref: `commit:c9227c39e225932796e87ef4c9eb84f647e16150`,\n },\n headers: {\n [LEDGER_CLIENT_VERSION_HEADER]: `context-module/${PACKAGE.version}`,\n [LEDGER_ORIGIN_TOKEN_HEADER]: this.config.originToken,\n },\n });\n\n // Try to get the filters JSON descriptor, from address and schema hash\n const schemaHash = SHA224(\n JSON.stringify(this.sortTypes(schema)).replace(\" \", \"\"),\n ).toString();\n address = address.toLowerCase();\n const filtersJson =\n response.data?.[0]?.descriptors_eip712?.[address]?.[schemaHash];\n if (!filtersJson) {\n return Left(\n new Error(\n `[ContextModule] HttpTypedDataDataSource: no typed data filters for address ${address} on chain ${chainId} for schema ${schemaHash}`,\n ),\n );\n }\n\n // Parse the message type, if available\n if (!filtersJson.schema || !Array.isArray(filtersJson.instructions)) {\n return Left(\n new Error(\n `[ContextModule] HttpTypedDataDataSource: no message info for address ${address} on chain ${chainId} for schema ${schemaHash}`,\n ),\n );\n }\n\n // Parse all the filters\n const filters: TypedDataFilter[] = [];\n const calldatasInfos: Record<\n TypedDataCalldataIndex,\n TypedDataFilterCalldataInfo\n > = {};\n for (const field of filtersJson.instructions) {\n if (this.isInstructionContractInfo(field, this.config.cal.mode)) {\n messageInfo = {\n displayName: field.display_name,\n signature: field.signatures[this.config.cal.mode],\n filtersCount: field.field_mappers_count,\n };\n } else if (\n version === \"v1\" &&\n this.isInstructionFieldV1(field, this.config.cal.mode)\n ) {\n filters.push({\n type: \"raw\",\n displayName: field.display_name,\n path: field.field_path,\n signature: field.signatures[this.config.cal.mode],\n });\n } else if (this.isInstructionFieldV2(field, this.config.cal.mode)) {\n filters.push({\n type: field.format,\n displayName: field.display_name,\n path: field.field_path,\n signature: field.signatures[this.config.cal.mode],\n });\n } else if (\n this.isInstructionFieldV2WithCoinRef(field, this.config.cal.mode)\n ) {\n filters.push({\n type: field.format,\n displayName: field.display_name,\n path: field.field_path,\n signature: field.signatures[this.config.cal.mode],\n tokenIndex: field.coin_ref,\n });\n } else if (\n this.isInstructionFieldV2WithName(field, this.config.cal.mode)\n ) {\n filters.push({\n type: field.format,\n displayName: field.display_name,\n path: field.field_path,\n signature: field.signatures[this.config.cal.mode],\n types: field.name_types,\n sources: field.name_sources,\n typesAndSourcesPayload:\n this.formatTrustedNameTypesAndSources(field),\n });\n } else if (\n this.isInstructionCalldataInfo(field, this.config.cal.mode)\n ) {\n calldatasInfos[field.calldata_index] = {\n displayName: field.display_name,\n calldataIndex: field.calldata_index,\n valueFlag: field.value_filter_flag,\n calleeFlag: this.convertCalldataPresenceFlag(\n field.callee_filter_flag,\n ),\n amountFlag: field.amount_filter_flag,\n spenderFlag: this.convertCalldataPresenceFlag(\n field.spender_filter_flag,\n ),\n chainIdFlag: field.chain_id_filter_flag,\n selectorFlag: field.selector_filter_flag,\n signature: field.signatures[this.config.cal.mode],\n };\n } else if (\n this.isInstructionFieldV2Calldata(field, this.config.cal.mode)\n ) {\n filters.push({\n type: field.format,\n displayName: field.display_name,\n path: field.field_path,\n signature: field.signatures[this.config.cal.mode],\n calldataIndex: field.calldata_index,\n });\n } else {\n return Left(\n new Error(\n `[ContextModule] HttpTypedDataDataSource: invalid typed data field for address ${address} on chain ${chainId} for schema ${schemaHash}`,\n ),\n );\n }\n }\n\n if (!messageInfo) {\n return Left(\n new Error(\n `[ContextModule] HttpTypedDataDataSource: no message info for address ${address} on chain ${chainId} for schema ${schemaHash}`,\n ),\n );\n }\n\n return Right({ messageInfo, filters, calldatasInfos });\n } catch (_error) {\n return Left(\n new Error(\n \"[ContextModule] HttpTypedDataDataSource: Failed to fetch typed data informations\",\n ),\n );\n }\n }\n\n private convertCalldataPresenceFlag(\n flag: InstructionCalldataParamPresence,\n ): TypedDataCalldataParamPresence {\n switch (flag) {\n case \"none\":\n return TypedDataCalldataParamPresence.None;\n case \"present\":\n return TypedDataCalldataParamPresence.Present;\n case \"verifying_contract\":\n return TypedDataCalldataParamPresence.VerifyingContract;\n default: {\n const uncoveredFlag: never = flag;\n throw new Error(`Unhandled flag: ${uncoveredFlag}`);\n }\n }\n }\n\n private formatTrustedNameTypesAndSources(\n field: InstructionFieldV2WithName,\n ): string {\n // Get number of types and sources\n const typesCount = field.name_types.length;\n const sourcesCount = field.name_sources.length;\n\n // Extract types and sources from the descriptor\n const types = field.descriptor.slice(\n (typesCount + sourcesCount) * 2 * -1,\n sourcesCount * 2 * -1,\n );\n const sources = field.descriptor.slice(sourcesCount * 2 * -1);\n\n // Convert counts into hex strings\n const typesCountHex = typesCount.toString(16).padStart(2, \"0\");\n const sourcesCountHex = sourcesCount.toString(16).padStart(2, \"0\");\n\n // Return the payload\n return typesCountHex + types + sourcesCountHex + sources;\n }\n\n private isInstructionFieldV1(\n data: InstructionField,\n mode: ContextModuleCalMode,\n ): data is InstructionFieldV1 & {\n signatures: { [_key in ContextModuleCalMode]: string };\n } {\n // NOTE: Currently the backend return the same structure for V1 and V2,\n // so we can't distinguish them here, but we can still check the required fields\n return (\n typeof data === \"object\" &&\n typeof data.display_name === \"string\" &&\n typeof data.field_path === \"string\" &&\n typeof data.signatures === \"object\" &&\n typeof data.signatures[mode] === \"string\"\n );\n }\n\n private isInstructionFieldV2(\n data: InstructionField,\n mode: ContextModuleCalMode,\n ): data is InstructionFieldV2 & {\n signatures: { [_key in ContextModuleCalMode]: string };\n } {\n return (\n typeof data === \"object\" &&\n typeof data.display_name === \"string\" &&\n typeof data.field_path === \"string\" &&\n typeof data.signatures === \"object\" &&\n typeof data.signatures[mode] === \"string\" &&\n typeof data.format === \"string\" &&\n [\"raw\", \"datetime\"].includes(data.format) &&\n data.coin_ref === undefined\n );\n }\n\n private isInstructionFieldV2WithCoinRef(\n data: InstructionField,\n mode: ContextModuleCalMode,\n ): data is InstructionFieldV2WithCoinRef & {\n signatures: { [_key in ContextModuleCalMode]: string };\n } {\n return (\n typeof data === \"object\" &&\n typeof data.display_name === \"string\" &&\n typeof data.field_path === \"string\" &&\n typeof data.signatures === \"object\" &&\n typeof data.signatures[mode] === \"string\" &&\n typeof data.format === \"string\" &&\n [\"token\", \"amount\"].includes(data.format) &&\n typeof data.coin_ref === \"number\"\n );\n }\n\n private isInstructionFieldV2WithName(\n data: InstructionField,\n mode: ContextModuleCalMode,\n ): data is InstructionFieldV2WithName & {\n signatures: { [_key in ContextModuleCalMode]: string };\n } {\n return (\n typeof data === \"object\" &&\n typeof data.display_name === \"string\" &&\n typeof data.field_path === \"string\" &&\n typeof data.signatures === \"object\" &&\n typeof data.signatures[mode] === \"string\" &&\n typeof data.format === \"string\" &&\n data.format === \"trusted-name\" &&\n data.coin_ref === undefined &&\n Array.isArray(data.name_types) &&\n Array.isArray(data.name_sources) &&\n data.name_types.every((t) => typeof t === \"string\") &&\n data.name_sources.every((s) => typeof s === \"string\")\n );\n }\n\n private isInstructionContractInfo(\n data: InstructionField,\n mode: ContextModuleCalMode,\n ): data is InstructionContractInfo & {\n signatures: { [_key in ContextModuleCalMode]: string };\n } {\n return (\n typeof data === \"object\" &&\n typeof data.display_name === \"string\" &&\n typeof data.field_mappers_count === \"number\" &&\n typeof data.signatures === \"object\" &&\n typeof data.signatures[mode] === \"string\" &&\n data.field_path === undefined\n );\n }\n\n private isInstructionCalldataInfo(\n data: InstructionField,\n mode: ContextModuleCalMode,\n ): data is InstructionCalldataInfo & {\n signatures: { [_key in ContextModuleCalMode]: string };\n } {\n return (\n typeof data === \"object\" &&\n typeof data.type === \"string\" &&\n data.type === \"calldata\" &&\n typeof data.display_name === \"string\" &&\n typeof data.calldata_index === \"number\" &&\n typeof data.value_filter_flag === \"boolean\" &&\n typeof data.chain_id_filter_flag === \"boolean\" &&\n typeof data.selector_filter_flag === \"boolean\" &&\n typeof data.amount_filter_flag === \"boolean\" &&\n [\"none\", \"present\", \"verifying_contract\"].includes(\n data.callee_filter_flag,\n ) &&\n [\"none\", \"present\", \"verifying_contract\"].includes(\n data.spender_filter_flag,\n ) &&\n typeof data.signatures === \"object\" &&\n typeof data.signatures[mode] === \"string\"\n );\n }\n\n private isInstructionFieldV2Calldata(\n data: InstructionField,\n mode: ContextModuleCalMode,\n ): data is InstructionFieldV2Calldata & {\n signatures: { [_key in ContextModuleCalMode]: string };\n } {\n return (\n typeof data === \"object\" &&\n typeof data.display_name === \"string\" &&\n typeof data.field_path === \"string\" &&\n typeof data.signatures === \"object\" &&\n typeof data.signatures[mode] === \"string\" &&\n typeof data.format === \"string\" &&\n [\n \"calldata-value\",\n \"calldata-callee\",\n \"calldata-chain-id\",\n \"calldata-selector\",\n \"calldata-amount\",\n \"calldata-spender\",\n ].includes(data.format) &&\n typeof data.calldata_index === \"number\"\n );\n }\n\n private sortTypes(types: TypedDataSchema): TypedDataSchema {\n return Object.fromEntries(\n Object.entries(types)\n .sort(([aKey], [bKey]) => aKey.localeCompare(bKey))\n .map(([key, value]) => [\n key,\n value.map((v) => ({ name: v.name, type: v.type })),\n ]),\n );\n }\n}\n"],
5
- "mappings": "qtBAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,6BAAAE,IAAA,eAAAC,EAAAH,GAAA,IAAAI,EAAkB,oBAClBC,EAAmB,+BACnBC,EAAmC,qBACnCC,EAAoC,qBAEpCC,EAA4B,mCAK5BC,EAGO,yCAOPC,EAA+C,oDAE/CC,EAAoB,iCAqBb,IAAMC,EAAN,KAA6D,CAClE,YAC+CC,EAC7C,CAD6C,YAAAA,C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ClC,OAAOA,EAAK,sBAAyB,WACrC,OAAOA,EAAK,sBAAyB,WACrC,OAAOA,EAAK,oBAAuB,WACnC,CAAC,OAAQ,UAAW,oBAAoB,EAAE,SACxCA,EAAK,kBACP,GACA,CAAC,OAAQ,UAAW,oBAAoB,EAAE,SACxCA,EAAK,mBACP,GACA,OAAOA,EAAK,YAAe,UAC3B,OAAOA,EAAK,WAAWC,CAAI,GAAM,QAErC,CAEQ,6BACND,EACAC,EAGA,CACA,OACE,OAAOD,GAAS,UAChB,OAAOA,EAAK,cAAiB,UAC7B,OAAOA,EAAK,YAAe,UAC3B,OAAOA,EAAK,YAAe,UAC3B,OAAOA,EAAK,WAAWC,CAAI,GAAM,UACjC,OAAOD,EAAK,QAAW,UACvB,CACE,iBACA,kBACA,oBACA,oBACA,kBACA,kBACF,EAAE,SAASA,EAAK,MAAM,GACtB,OAAOA,EAAK,gBAAmB,QAEnC,CAEQ,UAAUJ,EAAyC,CACzD,OAAO,OAAO,YACZ,OAAO,QAAQA,CAAK,EACjB,KAAK,CAAC,CAACQ,CAAI,EAAG,CAACC,CAAI,IAAMD,EAAK,cAAcC,CAAI,CAAC,EACjD,IAAI,CAAC,CAACC,EAAKC,CAAK,IAAM,CACrBD,EACAC,EAAM,IAAKC,IAAO,CAAE,KAAMA,EAAE,KAAM,KAAMA,EAAE,IAAK,EAAE,CACnD,CAAC,CACL,CACF,CACF,EAtWahC,EAANiC,EAAA,IADN,cAAW,EAGPC,EAAA,eAAO,cAAY,MAAM,IAFjBlC",
4
+ "sourcesContent": ["import axios from \"axios\";\nimport SHA224 from \"crypto-js/sha224\";\nimport { inject, injectable } from \"inversify\";\nimport { Either, Left, Right } from \"purify-ts\";\n\nimport { configTypes } from \"@/config/di/configTypes\";\nimport type {\n ContextModuleCalMode,\n ContextModuleConfig,\n} from \"@/config/model/ContextModuleConfig\";\nimport {\n LEDGER_CLIENT_VERSION_HEADER,\n LEDGER_ORIGIN_TOKEN_HEADER,\n} from \"@/shared/constant/HttpHeaders\";\nimport type {\n TypedDataCalldataIndex,\n TypedDataFilter,\n TypedDataFilterCalldataInfo,\n TypedDataMessageInfo,\n} from \"@/shared/model/TypedDataClearSignContext\";\nimport { TypedDataCalldataParamPresence } from \"@/shared/model/TypedDataClearSignContext\";\nimport type { TypedDataSchema } from \"@/shared/model/TypedDataContext\";\nimport PACKAGE from \"@root/package.json\";\n\nimport type {\n FiltersDto,\n InstructionCalldataInfo,\n InstructionCalldataParamPresence,\n InstructionContractInfo,\n InstructionField,\n InstructionFieldV1,\n InstructionFieldV2,\n InstructionFieldV2Calldata,\n InstructionFieldV2WithCoinRef,\n InstructionFieldV2WithName,\n} from \"./FiltersDto\";\nimport {\n GetTypedDataFiltersParams,\n GetTypedDataFiltersResult,\n TypedDataDataSource,\n} from \"./TypedDataDataSource\";\n\n@injectable()\nexport class HttpTypedDataDataSource implements TypedDataDataSource {\n constructor(\n @inject(configTypes.Config) private readonly config: ContextModuleConfig,\n ) {}\n\n public async getTypedDataFilters({\n chainId,\n address,\n schema,\n version,\n }: GetTypedDataFiltersParams): Promise<\n Either<Error, GetTypedDataFiltersResult>\n > {\n let messageInfo: TypedDataMessageInfo | undefined = undefined;\n\n try {\n const response = await axios.request<FiltersDto[]>({\n method: \"GET\",\n url: `${this.config.cal.url}/dapps`,\n params: {\n contracts: address,\n chain_id: chainId,\n output: \"descriptors_eip712\",\n descriptors_eip712_version: version,\n descriptors_eip712: \"<set>\",\n ref: `branch:${this.config.cal.branch}`,\n },\n headers: {\n [LEDGER_CLIENT_VERSION_HEADER]: `context-module/${PACKAGE.version}`,\n [LEDGER_ORIGIN_TOKEN_HEADER]: this.config.originToken,\n },\n });\n\n // Try to get the filters JSON descriptor, from address and schema hash\n const schemaHash = SHA224(\n JSON.stringify(this.sortTypes(schema)).replace(\" \", \"\"),\n ).toString();\n address = address.toLowerCase();\n const filtersJson =\n response.data?.[0]?.descriptors_eip712?.[address]?.[schemaHash];\n if (!filtersJson) {\n return Left(\n new Error(\n `[ContextModule] HttpTypedDataDataSource: no typed data filters for address ${address} on chain ${chainId} for schema ${schemaHash}`,\n ),\n );\n }\n\n // Parse the message type, if available\n if (!filtersJson.schema || !Array.isArray(filtersJson.instructions)) {\n return Left(\n new Error(\n `[ContextModule] HttpTypedDataDataSource: no message info for address ${address} on chain ${chainId} for schema ${schemaHash}`,\n ),\n );\n }\n\n // Parse all the filters\n const filters: TypedDataFilter[] = [];\n const calldatasInfos: Record<\n TypedDataCalldataIndex,\n TypedDataFilterCalldataInfo\n > = {};\n for (const field of filtersJson.instructions) {\n if (this.isInstructionContractInfo(field, this.config.cal.mode)) {\n messageInfo = {\n displayName: field.display_name,\n signature: field.signatures[this.config.cal.mode],\n filtersCount: field.field_mappers_count,\n };\n } else if (\n version === \"v1\" &&\n this.isInstructionFieldV1(field, this.config.cal.mode)\n ) {\n filters.push({\n type: \"raw\",\n displayName: field.display_name,\n path: field.field_path,\n signature: field.signatures[this.config.cal.mode],\n });\n } else if (this.isInstructionFieldV2(field, this.config.cal.mode)) {\n filters.push({\n type: field.format,\n displayName: field.display_name,\n path: field.field_path,\n signature: field.signatures[this.config.cal.mode],\n });\n } else if (\n this.isInstructionFieldV2WithCoinRef(field, this.config.cal.mode)\n ) {\n filters.push({\n type: field.format,\n displayName: field.display_name,\n path: field.field_path,\n signature: field.signatures[this.config.cal.mode],\n tokenIndex: field.coin_ref,\n });\n } else if (\n this.isInstructionFieldV2WithName(field, this.config.cal.mode)\n ) {\n filters.push({\n type: field.format,\n displayName: field.display_name,\n path: field.field_path,\n signature: field.signatures[this.config.cal.mode],\n types: field.name_types,\n sources: field.name_sources,\n typesAndSourcesPayload:\n this.formatTrustedNameTypesAndSources(field),\n });\n } else if (\n this.isInstructionCalldataInfo(field, this.config.cal.mode)\n ) {\n calldatasInfos[field.calldata_index] = {\n displayName: field.display_name,\n calldataIndex: field.calldata_index,\n valueFlag: field.value_filter_flag,\n calleeFlag: this.convertCalldataPresenceFlag(\n field.callee_filter_flag,\n ),\n amountFlag: field.amount_filter_flag,\n spenderFlag: this.convertCalldataPresenceFlag(\n field.spender_filter_flag,\n ),\n chainIdFlag: field.chain_id_filter_flag,\n selectorFlag: field.selector_filter_flag,\n signature: field.signatures[this.config.cal.mode],\n };\n } else if (\n this.isInstructionFieldV2Calldata(field, this.config.cal.mode)\n ) {\n filters.push({\n type: field.format,\n displayName: field.display_name,\n path: field.field_path,\n signature: field.signatures[this.config.cal.mode],\n calldataIndex: field.calldata_index,\n });\n } else {\n return Left(\n new Error(\n `[ContextModule] HttpTypedDataDataSource: invalid typed data field for address ${address} on chain ${chainId} for schema ${schemaHash}`,\n ),\n );\n }\n }\n\n if (!messageInfo) {\n return Left(\n new Error(\n `[ContextModule] HttpTypedDataDataSource: no message info for address ${address} on chain ${chainId} for schema ${schemaHash}`,\n ),\n );\n }\n\n return Right({ messageInfo, filters, calldatasInfos });\n } catch (_error) {\n return Left(\n new Error(\n \"[ContextModule] HttpTypedDataDataSource: Failed to fetch typed data informations\",\n ),\n );\n }\n }\n\n private convertCalldataPresenceFlag(\n flag: InstructionCalldataParamPresence,\n ): TypedDataCalldataParamPresence {\n switch (flag) {\n case \"none\":\n return TypedDataCalldataParamPresence.None;\n case \"present\":\n return TypedDataCalldataParamPresence.Present;\n case \"verifying_contract\":\n return TypedDataCalldataParamPresence.VerifyingContract;\n default: {\n const uncoveredFlag: never = flag;\n throw new Error(`Unhandled flag: ${uncoveredFlag}`);\n }\n }\n }\n\n private formatTrustedNameTypesAndSources(\n field: InstructionFieldV2WithName,\n ): string {\n // Get number of types and sources\n const typesCount = field.name_types.length;\n const sourcesCount = field.name_sources.length;\n\n // Extract types and sources from the descriptor\n const types = field.descriptor.slice(\n (typesCount + sourcesCount) * 2 * -1,\n sourcesCount * 2 * -1,\n );\n const sources = field.descriptor.slice(sourcesCount * 2 * -1);\n\n // Convert counts into hex strings\n const typesCountHex = typesCount.toString(16).padStart(2, \"0\");\n const sourcesCountHex = sourcesCount.toString(16).padStart(2, \"0\");\n\n // Return the payload\n return typesCountHex + types + sourcesCountHex + sources;\n }\n\n private isInstructionFieldV1(\n data: InstructionField,\n mode: ContextModuleCalMode,\n ): data is InstructionFieldV1 & {\n signatures: { [_key in ContextModuleCalMode]: string };\n } {\n // NOTE: Currently the backend return the same structure for V1 and V2,\n // so we can't distinguish them here, but we can still check the required fields\n return (\n typeof data === \"object\" &&\n typeof data.display_name === \"string\" &&\n typeof data.field_path === \"string\" &&\n typeof data.signatures === \"object\" &&\n typeof data.signatures[mode] === \"string\"\n );\n }\n\n private isInstructionFieldV2(\n data: InstructionField,\n mode: ContextModuleCalMode,\n ): data is InstructionFieldV2 & {\n signatures: { [_key in ContextModuleCalMode]: string };\n } {\n return (\n typeof data === \"object\" &&\n typeof data.display_name === \"string\" &&\n typeof data.field_path === \"string\" &&\n typeof data.signatures === \"object\" &&\n typeof data.signatures[mode] === \"string\" &&\n typeof data.format === \"string\" &&\n [\"raw\", \"datetime\"].includes(data.format) &&\n data.coin_ref === undefined\n );\n }\n\n private isInstructionFieldV2WithCoinRef(\n data: InstructionField,\n mode: ContextModuleCalMode,\n ): data is InstructionFieldV2WithCoinRef & {\n signatures: { [_key in ContextModuleCalMode]: string };\n } {\n return (\n typeof data === \"object\" &&\n typeof data.display_name === \"string\" &&\n typeof data.field_path === \"string\" &&\n typeof data.signatures === \"object\" &&\n typeof data.signatures[mode] === \"string\" &&\n typeof data.format === \"string\" &&\n [\"token\", \"amount\"].includes(data.format) &&\n typeof data.coin_ref === \"number\"\n );\n }\n\n private isInstructionFieldV2WithName(\n data: InstructionField,\n mode: ContextModuleCalMode,\n ): data is InstructionFieldV2WithName & {\n signatures: { [_key in ContextModuleCalMode]: string };\n } {\n return (\n typeof data === \"object\" &&\n typeof data.display_name === \"string\" &&\n typeof data.field_path === \"string\" &&\n typeof data.signatures === \"object\" &&\n typeof data.signatures[mode] === \"string\" &&\n typeof data.format === \"string\" &&\n data.format === \"trusted-name\" &&\n data.coin_ref === undefined &&\n Array.isArray(data.name_types) &&\n Array.isArray(data.name_sources) &&\n data.name_types.every((t) => typeof t === \"string\") &&\n data.name_sources.every((s) => typeof s === \"string\")\n );\n }\n\n private isInstructionContractInfo(\n data: InstructionField,\n mode: ContextModuleCalMode,\n ): data is InstructionContractInfo & {\n signatures: { [_key in ContextModuleCalMode]: string };\n } {\n return (\n typeof data === \"object\" &&\n typeof data.display_name === \"string\" &&\n typeof data.field_mappers_count === \"number\" &&\n typeof data.signatures === \"object\" &&\n typeof data.signatures[mode] === \"string\" &&\n data.field_path === undefined\n );\n }\n\n private isInstructionCalldataInfo(\n data: InstructionField,\n mode: ContextModuleCalMode,\n ): data is InstructionCalldataInfo & {\n signatures: { [_key in ContextModuleCalMode]: string };\n } {\n return (\n typeof data === \"object\" &&\n typeof data.type === \"string\" &&\n data.type === \"calldata\" &&\n typeof data.display_name === \"string\" &&\n typeof data.calldata_index === \"number\" &&\n typeof data.value_filter_flag === \"boolean\" &&\n typeof data.chain_id_filter_flag === \"boolean\" &&\n typeof data.selector_filter_flag === \"boolean\" &&\n typeof data.amount_filter_flag === \"boolean\" &&\n [\"none\", \"present\", \"verifying_contract\"].includes(\n data.callee_filter_flag,\n ) &&\n [\"none\", \"present\", \"verifying_contract\"].includes(\n data.spender_filter_flag,\n ) &&\n typeof data.signatures === \"object\" &&\n typeof data.signatures[mode] === \"string\"\n );\n }\n\n private isInstructionFieldV2Calldata(\n data: InstructionField,\n mode: ContextModuleCalMode,\n ): data is InstructionFieldV2Calldata & {\n signatures: { [_key in ContextModuleCalMode]: string };\n } {\n return (\n typeof data === \"object\" &&\n typeof data.display_name === \"string\" &&\n typeof data.field_path === \"string\" &&\n typeof data.signatures === \"object\" &&\n typeof data.signatures[mode] === \"string\" &&\n typeof data.format === \"string\" &&\n [\n \"calldata-value\",\n \"calldata-callee\",\n \"calldata-chain-id\",\n \"calldata-selector\",\n \"calldata-amount\",\n \"calldata-spender\",\n ].includes(data.format) &&\n typeof data.calldata_index === \"number\"\n );\n }\n\n private sortTypes(types: TypedDataSchema): TypedDataSchema {\n return Object.fromEntries(\n Object.entries(types)\n .sort(([aKey], [bKey]) => aKey.localeCompare(bKey))\n .map(([key, value]) => [\n key,\n value.map((v) => ({ name: v.name, type: v.type })),\n ]),\n );\n }\n}\n"],
5
+ "mappings": "qtBAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,6BAAAE,IAAA,eAAAC,EAAAH,GAAA,IAAAI,EAAkB,oBAClBC,EAAmB,+BACnBC,EAAmC,qBACnCC,EAAoC,qBAEpCC,EAA4B,mCAK5BC,EAGO,yCAOPC,EAA+C,oDAE/CC,EAAoB,iCAqBb,IAAMC,EAAN,KAA6D,CAClE,YAC+CC,EAC7C,CAD6C,YAAAA,CAC5C,CAEH,MAAa,oBAAoB,CAC/B,QAAAC,EACA,QAAAC,EACA,OAAAC,EACA,QAAAC,CACF,EAEE,CACA,IAAIC,EAEJ,GAAI,CACF,MAAMC,EAAW,MAAM,EAAAC,QAAM,QAAsB,CACjD,OAAQ,MACR,IAAK,GAAG,KAAK,OAAO,IAAI,GAAG,SAC3B,OAAQ,CACN,UAAWL,EACX,SAAUD,EACV,OAAQ,qBACR,2BAA4BG,EAC5B,mBAAoB,QACpB,IAAK,UAAU,KAAK,OAAO,IAAI,MAAM,EACvC,EACA,QAAS,CACP,CAAC,8BAA4B,EAAG,kBAAkB,EAAAI,QAAQ,OAAO,GACjE,CAAC,4BAA0B,EAAG,KAAK,OAAO,WAC5C,CACF,CAAC,EAGKC,KAAa,EAAAC,SACjB,KAAK,UAAU,KAAK,UAAUP,CAAM,CAAC,EAAE,QAAQ,IAAK,EAAE,CACxD,EAAE,SAAS,EACXD,EAAUA,EAAQ,YAAY,EAC9B,MAAMS,EACJL,EAAS,OAAO,CAAC,GAAG,qBAAqBJ,CAAO,IAAIO,CAAU,EAChE,GAAI,CAACE,EACH,SAAO,QACL,IAAI,MACF,8EAA8ET,CAAO,aAAaD,CAAO,eAAeQ,CAAU,EACpI,CACF,EAIF,GAAI,CAAC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CACrBD,EACAC,EAAM,IAAKC,IAAO,CAAE,KAAMA,EAAE,KAAM,KAAMA,EAAE,IAAK,EAAE,CACnD,CAAC,CACL,CACF,CACF,EArWahC,EAANiC,EAAA,IADN,cAAW,EAGPC,EAAA,eAAO,cAAY,MAAM,IAFjBlC",
6
6
  "names": ["HttpTypedDataDataSource_exports", "__export", "HttpTypedDataDataSource", "__toCommonJS", "import_axios", "import_sha224", "import_inversify", "import_purify_ts", "import_configTypes", "import_HttpHeaders", "import_TypedDataClearSignContext", "import_package", "HttpTypedDataDataSource", "config", "chainId", "address", "schema", "version", "messageInfo", "response", "axios", "PACKAGE", "schemaHash", "SHA224", "filtersJson", "filters", "calldatasInfos", "field", "flag", "uncoveredFlag", "typesCount", "sourcesCount", "types", "sources", "typesCountHex", "sourcesCountHex", "data", "mode", "t", "s", "aKey", "bKey", "key", "value", "v", "__decorateClass", "__decorateParam"]
7
7
  }
@@ -1,2 +1,2 @@
1
- "use strict";var f=Object.defineProperty;var C=Object.getOwnPropertyDescriptor;var _=Object.getOwnPropertyNames;var w=Object.prototype.hasOwnProperty;var L=(l,e)=>{for(var r in e)f(l,r,{get:e[r],enumerable:!0})},O=(l,e,r,t)=>{if(e&&typeof e=="object"||typeof e=="function")for(let a of _(e))!w.call(l,a)&&a!==r&&f(l,a,{get:()=>e[a],enumerable:!(t=C(e,a))||t.enumerable});return l};var b=l=>O(f({},"__esModule",{value:!0}),l),v=(l,e,r,t)=>{for(var a=t>1?void 0:t?C(e,r):e,n=l.length-1,o;n>=0;n--)(o=l[n])&&(a=(t?o(e,r,a):o(a))||a);return t&&a&&f(e,r,a),a},y=(l,e)=>(r,t)=>e(r,t,l);var V={};L(V,{DefaultTypedDataContextLoader:()=>u});module.exports=b(V);var h=require("@ledgerhq/device-management-kit"),p=require("inversify"),S=require("../../pki/di/pkiTypes"),D=require("../../pki/model/KeyId"),I=require("../../pki/model/KeyUsage"),k=require("../../proxy/di/proxyTypes"),P=require("../../shared/model/ClearSignContext"),x=require("../../shared/model/TypedDataClearSignContext"),F=require("../../token/di/tokenTypes"),A=require("../../typed-data/di/typedDataTypes");let u=class{constructor(e,r,t,a){this.dataSource=e;this.tokenDataSource=r;this.proxyDataSource=t;this._certificateLoader=a}async load(e){let r,t=await this.dataSource.getTypedDataFilters({address:e.verifyingContract,chainId:e.chainId,version:e.version,schema:e.schema});if(t.isLeft()){const{resolvedAddress:i,context:s}=await this.resolveProxy(e);if(s!==void 0&&(r=s,t=await this.dataSource.getTypedDataFilters({address:i,chainId:e.chainId,version:e.version,schema:e.schema})),t.isLeft())return{type:"error",error:t.extract()}}const{messageInfo:a,filters:n,calldatasInfos:o}=t.unsafeCoerce(),d=n.reduce((i,s)=>(i[s.path]=s,i),{});return{type:"success",messageInfo:a,filters:d,trustedNamesAddresses:this.extractTrustedNames(n,e),tokens:await this.extractTokens(n,e),calldatas:this.extractCalldatas(n,o,e),proxy:r}}async resolveProxy(e){const r=await this.proxyDataSource.getProxyImplementationAddress({calldata:"0x",proxyAddress:e.verifyingContract,chainId:e.chainId,challenge:e.challenge??""});if(r.isLeft())return{resolvedAddress:e.verifyingContract,context:void 0};const t=await this._certificateLoader.loadCertificate({keyId:D.KeyId.CalCalldataKey,keyUsage:I.KeyUsage.Calldata,targetDevice:e.deviceModelId}),a=r.unsafeCoerce();return{resolvedAddress:a.implementationAddress,context:{type:P.ClearSignContextType.PROXY_INFO,payload:a.signedDescriptor,certificate:t}}}extractTrustedNames(e,r){return e.filter(t=>t.type==="trusted-name").reduce((t,a)=>{const n=r.fieldsValues.filter(o=>o.path===a.path);if(n.length!==0){const o=n[0],d=this.convertAddressToHexaString(o.value);t[a.path]=d}return t},{})}async extractTokens(e,r){const t={};for(const a of e){if(a.type!=="token"&&a.type!=="amount")continue;const n=a.tokenIndex;if(t[n]===void 0){if(a.type==="token"){const o=r.fieldsValues.filter(s=>s.path===a.path);if(o.length===0)continue;const d=o[0],i=this.convertAddressToHexaString(d.value);if(o.every(s=>this.convertAddressToHexaString(s.value)===i)){const s=r.chainId;(await this.tokenDataSource.getTokenInfosPayload({address:i,chainId:s})).ifRight(T=>{t[n]=T})}}else if(a.type==="amount"&&n===x.VERIFYING_CONTRACT_TOKEN_INDEX){const o=r.verifyingContract,d=r.chainId;(await this.tokenDataSource.getTokenInfosPayload({address:o,chainId:d})).ifRight(s=>{t[n]=s})}}}return t}extractCalldatas(e,r,t){const a=e.reduce((o,d)=>{if(d.type==="calldata-value"||d.type==="calldata-callee"||d.type==="calldata-chain-id"||d.type==="calldata-selector"||d.type==="calldata-amount"||d.type==="calldata-spender"){const i=o[d.calldataIndex];i===void 0?o[d.calldataIndex]=[d]:i.push(d)}return o},{}),n={};for(const o in r){const d=r[o],i=a[o];if(!i)continue;const s=this.extractHexaString(i.find(c=>c.type==="calldata-value"),t,"0x"),g=this.extractHexaString(i.find(c=>c.type==="calldata-selector"),t,s.slice(0,10)),T=this.extractAddress(i.find(c=>c.type==="calldata-callee"),t,d.calleeFlag),R=this.extractAddress(i.find(c=>c.type==="calldata-spender"),t,d.spenderFlag),H=this.extractBigint(i.find(c=>c.type==="calldata-amount"),t,void 0),m=this.extractBigint(i.find(c=>c.type==="calldata-chain-id"),t,void 0),N=m!==void 0&&m<Number.MAX_SAFE_INTEGER?Number(m):t.chainId;n[o]={filter:d,subset:{chainId:N,data:s,selector:g,to:T,value:H,from:R}}}return n}extractHexaString(e,r,t){if(e!==void 0){const a=r.fieldsValues.filter(n=>n.path===e.path);if(a.length!==0)return(0,h.bufferToHexaString)(a[0].value)}return t}extractAddress(e,r,t,a){if(t===x.TypedDataCalldataParamPresence.VerifyingContract)return r.verifyingContract;if(e!==void 0){const n=r.fieldsValues.filter(o=>o.path===e.path);if(n.length!==0)return this.convertAddressToHexaString(n[0].value)}return a}extractBigint(e,r,t){if(e!==void 0){const a=r.fieldsValues.filter(n=>n.path===e.path);if(a.length!==0)return BigInt((0,h.bufferToHexaString)(a[0].value))}return t}convertAddressToHexaString(e){return`0x${Array.from(e,r=>r.toString(16).padStart(2,"0")).join("").padStart(40,"0")}`}};u=v([(0,p.injectable)(),y(0,(0,p.inject)(A.typedDataTypes.TypedDataDataSource)),y(1,(0,p.inject)(F.tokenTypes.TokenDataSource)),y(2,(0,p.inject)(k.proxyTypes.ProxyDataSource)),y(3,(0,p.inject)(S.pkiTypes.PkiCertificateLoader))],u);0&&(module.exports={DefaultTypedDataContextLoader});
1
+ "use strict";var f=Object.defineProperty;var C=Object.getOwnPropertyDescriptor;var H=Object.getOwnPropertyNames;var N=Object.prototype.hasOwnProperty;var _=(c,e)=>{for(var r in e)f(c,r,{get:e[r],enumerable:!0})},w=(c,e,r,t)=>{if(e&&typeof e=="object"||typeof e=="function")for(let a of H(e))!N.call(c,a)&&a!==r&&f(c,a,{get:()=>e[a],enumerable:!(t=C(e,a))||t.enumerable});return c};var L=c=>w(f({},"__esModule",{value:!0}),c),v=(c,e,r,t)=>{for(var a=t>1?void 0:t?C(e,r):e,n=c.length-1,o;n>=0;n--)(o=c[n])&&(a=(t?o(e,r,a):o(a))||a);return t&&a&&f(e,r,a),a},y=(c,e)=>(r,t)=>e(r,t,c);var O={};_(O,{DefaultTypedDataContextLoader:()=>u});module.exports=L(O);var m=require("@ledgerhq/device-management-kit"),p=require("inversify"),S=require("../../pki/di/pkiTypes"),D=require("../../proxy/di/proxyTypes"),I=require("../../shared/model/ClearSignContext"),x=require("../../shared/model/TypedDataClearSignContext"),k=require("../../token/di/tokenTypes"),P=require("../../typed-data/di/typedDataTypes");let u=class{constructor(e,r,t,a){this.dataSource=e;this.tokenDataSource=r;this.proxyDataSource=t;this._certificateLoader=a}async load(e){let r,t=await this.dataSource.getTypedDataFilters({address:e.verifyingContract,chainId:e.chainId,version:e.version,schema:e.schema});if(t.isLeft()){const{resolvedAddress:i,context:s}=await this.resolveProxy(e);if(s!==void 0&&(r=s,t=await this.dataSource.getTypedDataFilters({address:i,chainId:e.chainId,version:e.version,schema:e.schema})),t.isLeft())return{type:"error",error:t.extract()}}const{messageInfo:a,filters:n,calldatasInfos:o}=t.unsafeCoerce(),d=n.reduce((i,s)=>(i[s.path]=s,i),{});return{type:"success",messageInfo:a,filters:d,trustedNamesAddresses:this.extractTrustedNames(n,e),tokens:await this.extractTokens(n,e),calldatas:this.extractCalldatas(n,o,e),proxy:r}}async resolveProxy(e){const r=await this.proxyDataSource.getProxyImplementationAddress({calldata:"0x",proxyAddress:e.verifyingContract,chainId:e.chainId,challenge:e.challenge??""});if(r.isLeft())return{resolvedAddress:e.verifyingContract,context:void 0};const t=r.unsafeCoerce(),a=await this._certificateLoader.loadCertificate({keyId:t.keyId,keyUsage:t.keyUsage,targetDevice:e.deviceModelId});return{resolvedAddress:t.implementationAddress,context:{type:I.ClearSignContextType.PROXY_INFO,payload:t.signedDescriptor,certificate:a}}}extractTrustedNames(e,r){return e.filter(t=>t.type==="trusted-name").reduce((t,a)=>{const n=r.fieldsValues.filter(o=>o.path===a.path);if(n.length!==0){const o=n[0],d=this.convertAddressToHexaString(o.value);t[a.path]=d}return t},{})}async extractTokens(e,r){const t={};for(const a of e){if(a.type!=="token"&&a.type!=="amount")continue;const n=a.tokenIndex;if(t[n]===void 0){if(a.type==="token"){const o=r.fieldsValues.filter(s=>s.path===a.path);if(o.length===0)continue;const d=o[0],i=this.convertAddressToHexaString(d.value);if(o.every(s=>this.convertAddressToHexaString(s.value)===i)){const s=r.chainId;(await this.tokenDataSource.getTokenInfosPayload({address:i,chainId:s})).ifRight(T=>{t[n]=T})}}else if(a.type==="amount"&&n===x.VERIFYING_CONTRACT_TOKEN_INDEX){const o=r.verifyingContract,d=r.chainId;(await this.tokenDataSource.getTokenInfosPayload({address:o,chainId:d})).ifRight(s=>{t[n]=s})}}}return t}extractCalldatas(e,r,t){const a=e.reduce((o,d)=>{if(d.type==="calldata-value"||d.type==="calldata-callee"||d.type==="calldata-chain-id"||d.type==="calldata-selector"||d.type==="calldata-amount"||d.type==="calldata-spender"){const i=o[d.calldataIndex];i===void 0?o[d.calldataIndex]=[d]:i.push(d)}return o},{}),n={};for(const o in r){const d=r[o],i=a[o];if(!i)continue;const s=this.extractHexaString(i.find(l=>l.type==="calldata-value"),t,"0x"),g=this.extractHexaString(i.find(l=>l.type==="calldata-selector"),t,s.slice(0,10)),T=this.extractAddress(i.find(l=>l.type==="calldata-callee"),t,d.calleeFlag),F=this.extractAddress(i.find(l=>l.type==="calldata-spender"),t,d.spenderFlag),A=this.extractBigint(i.find(l=>l.type==="calldata-amount"),t,void 0),h=this.extractBigint(i.find(l=>l.type==="calldata-chain-id"),t,void 0),R=h!==void 0&&h<Number.MAX_SAFE_INTEGER?Number(h):t.chainId;n[o]={filter:d,subset:{chainId:R,data:s,selector:g,to:T,value:A,from:F}}}return n}extractHexaString(e,r,t){if(e!==void 0){const a=r.fieldsValues.filter(n=>n.path===e.path);if(a.length!==0)return(0,m.bufferToHexaString)(a[0].value)}return t}extractAddress(e,r,t,a){if(t===x.TypedDataCalldataParamPresence.VerifyingContract)return r.verifyingContract;if(e!==void 0){const n=r.fieldsValues.filter(o=>o.path===e.path);if(n.length!==0)return this.convertAddressToHexaString(n[0].value)}return a}extractBigint(e,r,t){if(e!==void 0){const a=r.fieldsValues.filter(n=>n.path===e.path);if(a.length!==0)return BigInt((0,m.bufferToHexaString)(a[0].value))}return t}convertAddressToHexaString(e){return`0x${Array.from(e,r=>r.toString(16).padStart(2,"0")).join("").padStart(40,"0")}`}};u=v([(0,p.injectable)(),y(0,(0,p.inject)(P.typedDataTypes.TypedDataDataSource)),y(1,(0,p.inject)(k.tokenTypes.TokenDataSource)),y(2,(0,p.inject)(D.proxyTypes.ProxyDataSource)),y(3,(0,p.inject)(S.pkiTypes.PkiCertificateLoader))],u);0&&(module.exports={DefaultTypedDataContextLoader});
2
2
  //# sourceMappingURL=DefaultTypedDataContextLoader.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../../src/typed-data/domain/DefaultTypedDataContextLoader.ts"],
4
- "sourcesContent": ["import type { HexaString } from \"@ledgerhq/device-management-kit\";\nimport { bufferToHexaString } from \"@ledgerhq/device-management-kit\";\nimport { inject, injectable } from \"inversify\";\n\nimport { pkiTypes } from \"@/pki/di/pkiTypes\";\nimport { type PkiCertificateLoader } from \"@/pki/domain/PkiCertificateLoader\";\nimport { KeyId } from \"@/pki/model/KeyId\";\nimport { KeyUsage } from \"@/pki/model/KeyUsage\";\nimport type { ProxyDataSource } from \"@/proxy/data/ProxyDataSource\";\nimport { proxyTypes } from \"@/proxy/di/proxyTypes\";\nimport {\n type ClearSignContextSuccess,\n ClearSignContextType,\n} from \"@/shared/model/ClearSignContext\";\nimport type {\n TypedDataCalldataIndex,\n TypedDataCalldataInfo,\n TypedDataClearSignContext,\n TypedDataFilter,\n TypedDataFilterCalldata,\n TypedDataFilterCalldataInfo,\n TypedDataFilterPath,\n TypedDataToken,\n TypedDataTokenIndex,\n} from \"@/shared/model/TypedDataClearSignContext\";\nimport {\n TypedDataCalldataParamPresence,\n VERIFYING_CONTRACT_TOKEN_INDEX,\n} from \"@/shared/model/TypedDataClearSignContext\";\nimport type { TypedDataContext } from \"@/shared/model/TypedDataContext\";\nimport type { TokenDataSource } from \"@/token/data/TokenDataSource\";\nimport { tokenTypes } from \"@/token/di/tokenTypes\";\nimport type { TypedDataDataSource } from \"@/typed-data/data/TypedDataDataSource\";\nimport { typedDataTypes } from \"@/typed-data/di/typedDataTypes\";\nimport type { TypedDataContextLoader } from \"@/typed-data/domain/TypedDataContextLoader\";\n\ntype ResolvedProxy = {\n resolvedAddress: string;\n context?: ClearSignContextSuccess<ClearSignContextType.PROXY_INFO>;\n};\n\n@injectable()\nexport class DefaultTypedDataContextLoader implements TypedDataContextLoader {\n constructor(\n @inject(typedDataTypes.TypedDataDataSource)\n private dataSource: TypedDataDataSource,\n @inject(tokenTypes.TokenDataSource)\n private tokenDataSource: TokenDataSource,\n @inject(proxyTypes.ProxyDataSource)\n private proxyDataSource: ProxyDataSource,\n @inject(pkiTypes.PkiCertificateLoader)\n private _certificateLoader: PkiCertificateLoader,\n ) {}\n\n async load(typedData: TypedDataContext): Promise<TypedDataClearSignContext> {\n // Get the typed data filters from the data source\n let proxy:\n | ClearSignContextSuccess<ClearSignContextType.PROXY_INFO>\n | undefined = undefined;\n let data = await this.dataSource.getTypedDataFilters({\n address: typedData.verifyingContract,\n chainId: typedData.chainId,\n version: typedData.version,\n schema: typedData.schema,\n });\n\n // If there was an error getting the typed data filters, try to resolve a proxy at that address\n if (data.isLeft()) {\n const { resolvedAddress, context } = await this.resolveProxy(typedData);\n if (context !== undefined) {\n proxy = context;\n data = await this.dataSource.getTypedDataFilters({\n address: resolvedAddress,\n chainId: typedData.chainId,\n version: typedData.version,\n schema: typedData.schema,\n });\n }\n // If there was stil an error, return immediately\n if (data.isLeft()) {\n return {\n type: \"error\",\n error: data.extract(),\n };\n }\n }\n\n // Else, extract the message info and filters\n const { messageInfo, filters, calldatasInfos } = data.unsafeCoerce();\n const mappedFilters = filters.reduce(\n (acc, filter) => {\n acc[filter.path] = filter;\n return acc;\n },\n {} as Record<TypedDataFilterPath, TypedDataFilter>,\n );\n\n return {\n type: \"success\",\n messageInfo,\n filters: mappedFilters,\n trustedNamesAddresses: this.extractTrustedNames(filters, typedData),\n tokens: await this.extractTokens(filters, typedData),\n calldatas: this.extractCalldatas(filters, calldatasInfos, typedData),\n proxy,\n };\n }\n\n private async resolveProxy(\n typedData: TypedDataContext,\n ): Promise<ResolvedProxy> {\n // Try to resolve the proxy\n const proxyDelegateCall =\n await this.proxyDataSource.getProxyImplementationAddress({\n calldata: \"0x\",\n proxyAddress: typedData.verifyingContract,\n chainId: typedData.chainId,\n challenge: typedData.challenge ?? \"\",\n });\n\n // Early return on failure\n if (proxyDelegateCall.isLeft()) {\n return {\n resolvedAddress: typedData.verifyingContract,\n context: undefined,\n };\n }\n\n // Fetch descriptor on success\n const certificate = await this._certificateLoader.loadCertificate({\n keyId: KeyId.CalCalldataKey,\n keyUsage: KeyUsage.Calldata,\n targetDevice: typedData.deviceModelId,\n });\n const proxyData = proxyDelegateCall.unsafeCoerce();\n return {\n resolvedAddress: proxyData.implementationAddress,\n context: {\n type: ClearSignContextType.PROXY_INFO,\n payload: proxyData.signedDescriptor,\n certificate,\n },\n };\n }\n\n private extractTrustedNames(\n filters: TypedDataFilter[],\n typedData: TypedDataContext,\n ): Record<TypedDataFilterPath, HexaString> {\n return filters\n .filter((filter) => filter.type === \"trusted-name\")\n .reduce(\n (acc, filter) => {\n const values = typedData.fieldsValues.filter(\n (entry) => entry.path === filter.path,\n );\n if (values.length !== 0) {\n const value = values[0]!;\n const address = this.convertAddressToHexaString(value.value);\n acc[filter.path] = address;\n }\n return acc;\n },\n {} as Record<TypedDataFilterPath, HexaString>,\n );\n }\n\n private async extractTokens(\n filters: TypedDataFilter[],\n typedData: TypedDataContext,\n ): Promise<Record<TypedDataTokenIndex, TypedDataToken>> {\n const mappedTokens: Record<TypedDataTokenIndex, TypedDataToken> = {};\n for (const filter of filters) {\n if (filter.type !== \"token\" && filter.type !== \"amount\") {\n continue; // no token reference\n }\n const tokenIndex = filter.tokenIndex;\n if (mappedTokens[tokenIndex] !== undefined) {\n continue; // Already fetched for a previous filter\n }\n\n // If the filter is a token, get token address from typed message values, and fetch descriptor\n if (filter.type === \"token\") {\n const values = typedData.fieldsValues.filter(\n (entry) => entry.path === filter.path,\n );\n if (values.length === 0) {\n // No value matching the referenced token. It may be located in an empty array.\n continue;\n }\n const value = values[0]!;\n const address = this.convertAddressToHexaString(value.value);\n\n // Arrays with different tokens are not supported since there is only 1 tokenIndex per filter.\n // Only fetch tokens if all values are the same.\n if (\n values.every(\n (entry) => this.convertAddressToHexaString(entry.value) === address,\n )\n ) {\n // Fetch descriptor\n const chainId = typedData.chainId;\n const payload = await this.tokenDataSource.getTokenInfosPayload({\n address,\n chainId,\n });\n payload.ifRight((p) => {\n mappedTokens[tokenIndex] = p;\n });\n }\n }\n\n // If the filter is an amount with a reference to the verifyingContract, fetch verifyingContract descriptor.\n // This is because descriptors data-sources should be compatible with Ledger devices specifications:\n // https://github.com/LedgerHQ/app-ethereum/blob/develop/doc/ethapp.adoc#amount-join-value\n else if (\n filter.type === \"amount\" &&\n tokenIndex === VERIFYING_CONTRACT_TOKEN_INDEX\n ) {\n const address = typedData.verifyingContract;\n const chainId = typedData.chainId;\n const payload = await this.tokenDataSource.getTokenInfosPayload({\n address,\n chainId,\n });\n payload.ifRight((p) => {\n mappedTokens[tokenIndex] = p;\n });\n }\n }\n return mappedTokens;\n }\n\n private extractCalldatas(\n filters: TypedDataFilter[],\n calldatasInfos: Record<TypedDataCalldataIndex, TypedDataFilterCalldataInfo>,\n typedData: TypedDataContext,\n ): Record<TypedDataCalldataIndex, TypedDataCalldataInfo> {\n // Map filters per calldataIndex\n const calldataFilters = filters.reduce(\n (acc, filter) => {\n if (\n filter.type === \"calldata-value\" ||\n filter.type === \"calldata-callee\" ||\n filter.type === \"calldata-chain-id\" ||\n filter.type === \"calldata-selector\" ||\n filter.type === \"calldata-amount\" ||\n filter.type === \"calldata-spender\"\n ) {\n const array = acc[filter.calldataIndex];\n if (array === undefined) {\n acc[filter.calldataIndex] = [filter];\n } else {\n array.push(filter);\n }\n }\n return acc;\n },\n {} as Record<TypedDataCalldataIndex, TypedDataFilterCalldata[]>,\n );\n\n // Iterate over calldatas\n const mappedCalldatas: Record<\n TypedDataCalldataIndex,\n TypedDataCalldataInfo\n > = {};\n for (const calldataIndex in calldatasInfos) {\n const infos = calldatasInfos[calldataIndex]!;\n const filters = calldataFilters[calldataIndex];\n if (!filters) {\n continue;\n }\n\n // Get data\n const data = this.extractHexaString(\n filters.find((filter) => filter.type === \"calldata-value\"),\n typedData,\n \"0x\",\n );\n\n // Get selector\n const selector = this.extractHexaString(\n filters.find((filter) => filter.type === \"calldata-selector\"),\n typedData,\n data.slice(0, 10),\n );\n\n // Get to\n const to = this.extractAddress(\n filters.find((filter) => filter.type === \"calldata-callee\"),\n typedData,\n infos.calleeFlag,\n );\n\n // Get from\n const from = this.extractAddress(\n filters.find((filter) => filter.type === \"calldata-spender\"),\n typedData,\n infos.spenderFlag,\n );\n\n // Get amount\n const value = this.extractBigint(\n filters.find((filter) => filter.type === \"calldata-amount\"),\n typedData,\n undefined,\n );\n\n // Get chainId\n const chainIdBigint = this.extractBigint(\n filters.find((filter) => filter.type === \"calldata-chain-id\"),\n typedData,\n undefined,\n );\n const chainId =\n chainIdBigint !== undefined && chainIdBigint < Number.MAX_SAFE_INTEGER\n ? Number(chainIdBigint)\n : typedData.chainId;\n\n mappedCalldatas[calldataIndex] = {\n filter: infos,\n subset: {\n chainId,\n data,\n selector,\n to,\n value,\n from,\n },\n };\n }\n return mappedCalldatas;\n }\n\n private extractHexaString(\n filter: TypedDataFilter | undefined,\n typedData: TypedDataContext,\n defaultValue: string,\n ): string {\n if (filter !== undefined) {\n const values = typedData.fieldsValues.filter(\n (entry) => entry.path === filter.path,\n );\n if (values.length !== 0) {\n return bufferToHexaString(values[0]!.value);\n }\n }\n return defaultValue;\n }\n\n private extractAddress(\n filter: TypedDataFilter | undefined,\n typedData: TypedDataContext,\n presenceFlag: TypedDataCalldataParamPresence,\n defaultValue?: string,\n ): string | undefined {\n if (presenceFlag === TypedDataCalldataParamPresence.VerifyingContract) {\n return typedData.verifyingContract;\n } else if (filter !== undefined) {\n const values = typedData.fieldsValues.filter(\n (entry) => entry.path === filter.path,\n );\n if (values.length !== 0) {\n return this.convertAddressToHexaString(values[0]!.value);\n }\n }\n return defaultValue;\n }\n\n private extractBigint(\n filter: TypedDataFilter | undefined,\n typedData: TypedDataContext,\n defaultValue: bigint | undefined,\n ): bigint | undefined {\n if (filter !== undefined) {\n const values = typedData.fieldsValues.filter(\n (entry) => entry.path === filter.path,\n );\n if (values.length !== 0) {\n return BigInt(bufferToHexaString(values[0]!.value));\n }\n }\n return defaultValue;\n }\n\n private convertAddressToHexaString(address: Uint8Array): HexaString {\n // Address size is 20 bytes so 40 characters, padded with zeros on the left\n return `0x${Array.from(address, (byte) =>\n byte.to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OiB,CACT,CAEQ,cACNrB,EACAV,EACA+B,EACoB,CACpB,GAAIrB,IAAW,OAAW,CACxB,MAAMI,EAASd,EAAU,aAAa,OACnCe,GAAUA,EAAM,OAASL,EAAO,IACnC,EACA,GAAII,EAAO,SAAW,EACpB,OAAO,UAAO,sBAAmBA,EAAO,CAAC,EAAG,KAAK,CAAC,CAEtD,CACA,OAAOiB,CACT,CAEQ,2BAA2Bd,EAAiC,CAElE,MAAO,KAAK,MAAM,KAAKA,EAAUgB,GAC/BA,EAAK,SAAS,EAAE,EAAE,SAAS,EAAG,GAAG,CACnC,EACG,KAAK,EAAE,EACP,SAAS,GAAI,GAAG,CAAC,EACtB,CACF,EA/VatC,EAANuC,EAAA,IADN,cAAW,EAGPC,EAAA,eAAO,iBAAe,mBAAmB,GAEzCA,EAAA,eAAO,aAAW,eAAe,GAEjCA,EAAA,eAAO,aAAW,eAAe,GAEjCA,EAAA,eAAO,WAAS,oBAAoB,IAR5BxC",
6
- "names": ["DefaultTypedDataContextLoader_exports", "__export", "DefaultTypedDataContextLoader", "__toCommonJS", "import_device_management_kit", "import_inversify", "import_pkiTypes", "import_KeyId", "import_KeyUsage", "import_proxyTypes", "import_ClearSignContext", "import_TypedDataClearSignContext", "import_tokenTypes", "import_typedDataTypes", "DefaultTypedDataContextLoader", "dataSource", "tokenDataSource", "proxyDataSource", "_certificateLoader", "typedData", "proxy", "data", "resolvedAddress", "context", "messageInfo", "filters", "calldatasInfos", "mappedFilters", "acc", "filter", "proxyDelegateCall", "certificate", "proxyData", "values", "entry", "value", "address", "mappedTokens", "tokenIndex", "chainId", "p", "calldataFilters", "array", "mappedCalldatas", "calldataIndex", "infos", "selector", "to", "from", "chainIdBigint", "defaultValue", "presenceFlag", "byte", "__decorateClass", "__decorateParam"]
4
+ "sourcesContent": ["import type { HexaString } from \"@ledgerhq/device-management-kit\";\nimport { bufferToHexaString } from \"@ledgerhq/device-management-kit\";\nimport { inject, injectable } from \"inversify\";\n\nimport { pkiTypes } from \"@/pki/di/pkiTypes\";\nimport { type PkiCertificateLoader } from \"@/pki/domain/PkiCertificateLoader\";\nimport type { ProxyDataSource } from \"@/proxy/data/ProxyDataSource\";\nimport { proxyTypes } from \"@/proxy/di/proxyTypes\";\nimport {\n type ClearSignContextSuccess,\n ClearSignContextType,\n} from \"@/shared/model/ClearSignContext\";\nimport type {\n TypedDataCalldataIndex,\n TypedDataCalldataInfo,\n TypedDataClearSignContext,\n TypedDataFilter,\n TypedDataFilterCalldata,\n TypedDataFilterCalldataInfo,\n TypedDataFilterPath,\n TypedDataToken,\n TypedDataTokenIndex,\n} from \"@/shared/model/TypedDataClearSignContext\";\nimport {\n TypedDataCalldataParamPresence,\n VERIFYING_CONTRACT_TOKEN_INDEX,\n} from \"@/shared/model/TypedDataClearSignContext\";\nimport type { TypedDataContext } from \"@/shared/model/TypedDataContext\";\nimport type { TokenDataSource } from \"@/token/data/TokenDataSource\";\nimport { tokenTypes } from \"@/token/di/tokenTypes\";\nimport type { TypedDataDataSource } from \"@/typed-data/data/TypedDataDataSource\";\nimport { typedDataTypes } from \"@/typed-data/di/typedDataTypes\";\nimport type { TypedDataContextLoader } from \"@/typed-data/domain/TypedDataContextLoader\";\n\ntype ResolvedProxy = {\n resolvedAddress: string;\n context?: ClearSignContextSuccess<ClearSignContextType.PROXY_INFO>;\n};\n\n@injectable()\nexport class DefaultTypedDataContextLoader implements TypedDataContextLoader {\n constructor(\n @inject(typedDataTypes.TypedDataDataSource)\n private dataSource: TypedDataDataSource,\n @inject(tokenTypes.TokenDataSource)\n private tokenDataSource: TokenDataSource,\n @inject(proxyTypes.ProxyDataSource)\n private proxyDataSource: ProxyDataSource,\n @inject(pkiTypes.PkiCertificateLoader)\n private _certificateLoader: PkiCertificateLoader,\n ) {}\n\n async load(typedData: TypedDataContext): Promise<TypedDataClearSignContext> {\n // Get the typed data filters from the data source\n let proxy:\n | ClearSignContextSuccess<ClearSignContextType.PROXY_INFO>\n | undefined = undefined;\n let data = await this.dataSource.getTypedDataFilters({\n address: typedData.verifyingContract,\n chainId: typedData.chainId,\n version: typedData.version,\n schema: typedData.schema,\n });\n\n // If there was an error getting the typed data filters, try to resolve a proxy at that address\n if (data.isLeft()) {\n const { resolvedAddress, context } = await this.resolveProxy(typedData);\n if (context !== undefined) {\n proxy = context;\n data = await this.dataSource.getTypedDataFilters({\n address: resolvedAddress,\n chainId: typedData.chainId,\n version: typedData.version,\n schema: typedData.schema,\n });\n }\n // If there was stil an error, return immediately\n if (data.isLeft()) {\n return {\n type: \"error\",\n error: data.extract(),\n };\n }\n }\n\n // Else, extract the message info and filters\n const { messageInfo, filters, calldatasInfos } = data.unsafeCoerce();\n const mappedFilters = filters.reduce(\n (acc, filter) => {\n acc[filter.path] = filter;\n return acc;\n },\n {} as Record<TypedDataFilterPath, TypedDataFilter>,\n );\n\n return {\n type: \"success\",\n messageInfo,\n filters: mappedFilters,\n trustedNamesAddresses: this.extractTrustedNames(filters, typedData),\n tokens: await this.extractTokens(filters, typedData),\n calldatas: this.extractCalldatas(filters, calldatasInfos, typedData),\n proxy,\n };\n }\n\n private async resolveProxy(\n typedData: TypedDataContext,\n ): Promise<ResolvedProxy> {\n // Try to resolve the proxy\n const proxyDelegateCall =\n await this.proxyDataSource.getProxyImplementationAddress({\n calldata: \"0x\",\n proxyAddress: typedData.verifyingContract,\n chainId: typedData.chainId,\n challenge: typedData.challenge ?? \"\",\n });\n\n // Early return on failure\n if (proxyDelegateCall.isLeft()) {\n return {\n resolvedAddress: typedData.verifyingContract,\n context: undefined,\n };\n }\n\n // Fetch descriptor on success\n const proxyData = proxyDelegateCall.unsafeCoerce();\n const certificate = await this._certificateLoader.loadCertificate({\n keyId: proxyData.keyId,\n keyUsage: proxyData.keyUsage,\n targetDevice: typedData.deviceModelId,\n });\n return {\n resolvedAddress: proxyData.implementationAddress,\n context: {\n type: ClearSignContextType.PROXY_INFO,\n payload: proxyData.signedDescriptor,\n certificate,\n },\n };\n }\n\n private extractTrustedNames(\n filters: TypedDataFilter[],\n typedData: TypedDataContext,\n ): Record<TypedDataFilterPath, HexaString> {\n return filters\n .filter((filter) => filter.type === \"trusted-name\")\n .reduce(\n (acc, filter) => {\n const values = typedData.fieldsValues.filter(\n (entry) => entry.path === filter.path,\n );\n if (values.length !== 0) {\n const value = values[0]!;\n const address = this.convertAddressToHexaString(value.value);\n acc[filter.path] = address;\n }\n return acc;\n },\n {} as Record<TypedDataFilterPath, HexaString>,\n );\n }\n\n private async extractTokens(\n filters: TypedDataFilter[],\n typedData: TypedDataContext,\n ): Promise<Record<TypedDataTokenIndex, TypedDataToken>> {\n const mappedTokens: Record<TypedDataTokenIndex, TypedDataToken> = {};\n for (const filter of filters) {\n if (filter.type !== \"token\" && filter.type !== \"amount\") {\n continue; // no token reference\n }\n const tokenIndex = filter.tokenIndex;\n if (mappedTokens[tokenIndex] !== undefined) {\n continue; // Already fetched for a previous filter\n }\n\n // If the filter is a token, get token address from typed message values, and fetch descriptor\n if (filter.type === \"token\") {\n const values = typedData.fieldsValues.filter(\n (entry) => entry.path === filter.path,\n );\n if (values.length === 0) {\n // No value matching the referenced token. It may be located in an empty array.\n continue;\n }\n const value = values[0]!;\n const address = this.convertAddressToHexaString(value.value);\n\n // Arrays with different tokens are not supported since there is only 1 tokenIndex per filter.\n // Only fetch tokens if all values are the same.\n if (\n values.every(\n (entry) => this.convertAddressToHexaString(entry.value) === address,\n )\n ) {\n // Fetch descriptor\n const chainId = typedData.chainId;\n const payload = await this.tokenDataSource.getTokenInfosPayload({\n address,\n chainId,\n });\n payload.ifRight((p) => {\n mappedTokens[tokenIndex] = p;\n });\n }\n }\n\n // If the filter is an amount with a reference to the verifyingContract, fetch verifyingContract descriptor.\n // This is because descriptors data-sources should be compatible with Ledger devices specifications:\n // https://github.com/LedgerHQ/app-ethereum/blob/develop/doc/ethapp.adoc#amount-join-value\n else if (\n filter.type === \"amount\" &&\n tokenIndex === VERIFYING_CONTRACT_TOKEN_INDEX\n ) {\n const address = typedData.verifyingContract;\n const chainId = typedData.chainId;\n const payload = await this.tokenDataSource.getTokenInfosPayload({\n address,\n chainId,\n });\n payload.ifRight((p) => {\n mappedTokens[tokenIndex] = p;\n });\n }\n }\n return mappedTokens;\n }\n\n private extractCalldatas(\n filters: TypedDataFilter[],\n calldatasInfos: Record<TypedDataCalldataIndex, TypedDataFilterCalldataInfo>,\n typedData: TypedDataContext,\n ): Record<TypedDataCalldataIndex, TypedDataCalldataInfo> {\n // Map filters per calldataIndex\n const calldataFilters = filters.reduce(\n (acc, filter) => {\n if (\n filter.type === \"calldata-value\" ||\n filter.type === \"calldata-callee\" ||\n filter.type === \"calldata-chain-id\" ||\n filter.type === \"calldata-selector\" ||\n filter.type === \"calldata-amount\" ||\n filter.type === \"calldata-spender\"\n ) {\n const array = acc[filter.calldataIndex];\n if (array === undefined) {\n acc[filter.calldataIndex] = [filter];\n } else {\n array.push(filter);\n }\n }\n return acc;\n },\n {} as Record<TypedDataCalldataIndex, TypedDataFilterCalldata[]>,\n );\n\n // Iterate over calldatas\n const mappedCalldatas: Record<\n TypedDataCalldataIndex,\n TypedDataCalldataInfo\n > = {};\n for (const calldataIndex in calldatasInfos) {\n const infos = calldatasInfos[calldataIndex]!;\n const filters = calldataFilters[calldataIndex];\n if (!filters) {\n continue;\n }\n\n // Get data\n const data = this.extractHexaString(\n filters.find((filter) => filter.type === \"calldata-value\"),\n typedData,\n \"0x\",\n );\n\n // Get selector\n const selector = this.extractHexaString(\n filters.find((filter) => filter.type === \"calldata-selector\"),\n typedData,\n data.slice(0, 10),\n );\n\n // Get to\n const to = this.extractAddress(\n filters.find((filter) => filter.type === \"calldata-callee\"),\n typedData,\n infos.calleeFlag,\n );\n\n // Get from\n const from = this.extractAddress(\n filters.find((filter) => filter.type === \"calldata-spender\"),\n typedData,\n infos.spenderFlag,\n );\n\n // Get amount\n const value = this.extractBigint(\n filters.find((filter) => filter.type === \"calldata-amount\"),\n typedData,\n undefined,\n );\n\n // Get chainId\n const chainIdBigint = this.extractBigint(\n filters.find((filter) => filter.type === \"calldata-chain-id\"),\n typedData,\n undefined,\n );\n const chainId =\n chainIdBigint !== undefined && chainIdBigint < Number.MAX_SAFE_INTEGER\n ? Number(chainIdBigint)\n : typedData.chainId;\n\n mappedCalldatas[calldataIndex] = {\n filter: infos,\n subset: {\n chainId,\n data,\n selector,\n to,\n value,\n from,\n },\n };\n }\n return mappedCalldatas;\n }\n\n private extractHexaString(\n filter: TypedDataFilter | undefined,\n typedData: TypedDataContext,\n defaultValue: string,\n ): string {\n if (filter !== undefined) {\n const values = typedData.fieldsValues.filter(\n (entry) => entry.path === filter.path,\n );\n if (values.length !== 0) {\n return bufferToHexaString(values[0]!.value);\n }\n }\n return defaultValue;\n }\n\n private extractAddress(\n filter: TypedDataFilter | undefined,\n typedData: TypedDataContext,\n presenceFlag: TypedDataCalldataParamPresence,\n defaultValue?: string,\n ): string | undefined {\n if (presenceFlag === TypedDataCalldataParamPresence.VerifyingContract) {\n return typedData.verifyingContract;\n } else if (filter !== undefined) {\n const values = typedData.fieldsValues.filter(\n (entry) => entry.path === filter.path,\n );\n if (values.length !== 0) {\n return this.convertAddressToHexaString(values[0]!.value);\n }\n }\n return defaultValue;\n }\n\n private extractBigint(\n filter: TypedDataFilter | undefined,\n typedData: TypedDataContext,\n defaultValue: bigint | undefined,\n ): bigint | undefined {\n if (filter !== undefined) {\n const values = typedData.fieldsValues.filter(\n (entry) => entry.path === filter.path,\n );\n if (values.length !== 0) {\n return BigInt(bufferToHexaString(values[0]!.value));\n }\n }\n return defaultValue;\n }\n\n private convertAddressToHexaString(address: Uint8Array): HexaString {\n // Address size is 20 bytes so 40 characters, padded with zeros on the left\n return `0x${Array.from(address, (byte) =>\n byte.toString(16).padStart(2, \"0\"),\n )\n .join(\"\")\n .padStart(40, \"0\")}`;\n }\n}\n"],
5
+ "mappings": "okBAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,mCAAAE,IAAA,eAAAC,EAAAH,GACA,IAAAI,EAAmC,2CACnCC,EAA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,KAAK,CAAC,CAEtD,CACA,OAAOiB,CACT,CAEQ,2BAA2Bd,EAAiC,CAElE,MAAO,KAAK,MAAM,KAAKA,EAAUgB,GAC/BA,EAAK,SAAS,EAAE,EAAE,SAAS,EAAG,GAAG,CACnC,EACG,KAAK,EAAE,EACP,SAAS,GAAI,GAAG,CAAC,EACtB,CACF,EA/VatC,EAANuC,EAAA,IADN,cAAW,EAGPC,EAAA,eAAO,iBAAe,mBAAmB,GAEzCA,EAAA,eAAO,aAAW,eAAe,GAEjCA,EAAA,eAAO,aAAW,eAAe,GAEjCA,EAAA,eAAO,WAAS,oBAAoB,IAR5BxC",
6
+ "names": ["DefaultTypedDataContextLoader_exports", "__export", "DefaultTypedDataContextLoader", "__toCommonJS", "import_device_management_kit", "import_inversify", "import_pkiTypes", "import_proxyTypes", "import_ClearSignContext", "import_TypedDataClearSignContext", "import_tokenTypes", "import_typedDataTypes", "DefaultTypedDataContextLoader", "dataSource", "tokenDataSource", "proxyDataSource", "_certificateLoader", "typedData", "proxy", "data", "resolvedAddress", "context", "messageInfo", "filters", "calldatasInfos", "mappedFilters", "acc", "filter", "proxyDelegateCall", "proxyData", "certificate", "values", "entry", "value", "address", "mappedTokens", "tokenIndex", "chainId", "p", "calldataFilters", "array", "mappedCalldatas", "calldataIndex", "infos", "selector", "to", "from", "chainIdBigint", "defaultValue", "presenceFlag", "byte", "__decorateClass", "__decorateParam"]
7
7
  }