@ledgerhq/context-module 1.8.1 → 1.9.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (98) hide show
  1. package/lib/cjs/package.json +2 -2
  2. package/lib/cjs/src/DefaultContextModule.js +1 -1
  3. package/lib/cjs/src/DefaultContextModule.js.map +3 -3
  4. package/lib/cjs/src/di.js +1 -1
  5. package/lib/cjs/src/di.js.map +3 -3
  6. package/lib/cjs/src/pki/model/KeyUsage.js +1 -1
  7. package/lib/cjs/src/pki/model/KeyUsage.js.map +2 -2
  8. package/lib/cjs/src/safe/data/HttpSafeAccountDataSource.js +2 -0
  9. package/lib/cjs/src/safe/data/HttpSafeAccountDataSource.js.map +7 -0
  10. package/lib/cjs/src/safe/data/HttpSafeAccountDataSource.test.js +2 -0
  11. package/lib/cjs/src/safe/data/HttpSafeAccountDataSource.test.js.map +7 -0
  12. package/lib/cjs/src/safe/data/SafeAccountDataSource.js +2 -0
  13. package/lib/cjs/src/safe/data/SafeAccountDataSource.js.map +7 -0
  14. package/lib/cjs/src/safe/data/dto/SafeAccountDto.js +2 -0
  15. package/lib/cjs/src/safe/data/dto/SafeAccountDto.js.map +7 -0
  16. package/lib/cjs/src/safe/di/safeModuleFactory.js +2 -0
  17. package/lib/cjs/src/safe/di/safeModuleFactory.js.map +7 -0
  18. package/lib/cjs/src/safe/di/safeModuleFactory.test.js +2 -0
  19. package/lib/cjs/src/safe/di/safeModuleFactory.test.js.map +7 -0
  20. package/lib/cjs/src/safe/di/safeTypes.js +2 -0
  21. package/lib/cjs/src/safe/di/safeTypes.js.map +7 -0
  22. package/lib/cjs/src/safe/domain/SafeAddressLoader.js +2 -0
  23. package/lib/cjs/src/safe/domain/SafeAddressLoader.js.map +7 -0
  24. package/lib/cjs/src/safe/domain/SafeAddressLoader.test.js +2 -0
  25. package/lib/cjs/src/safe/domain/SafeAddressLoader.test.js.map +7 -0
  26. package/lib/cjs/src/shared/model/ClearSignContext.js +1 -1
  27. package/lib/cjs/src/shared/model/ClearSignContext.js.map +2 -2
  28. package/lib/cjs/src/shared/utils/KeyUsageMapper.js +1 -1
  29. package/lib/cjs/src/shared/utils/KeyUsageMapper.js.map +2 -2
  30. package/lib/cjs/src/shared/utils/KeyUsageMapper.test.js +1 -1
  31. package/lib/cjs/src/shared/utils/KeyUsageMapper.test.js.map +2 -2
  32. package/lib/cjs/src/token/data/HttpTokenDataSource.js +1 -1
  33. package/lib/cjs/src/token/data/HttpTokenDataSource.js.map +2 -2
  34. package/lib/cjs/src/token/data/HttpTokenDataSource.test.js +1 -1
  35. package/lib/cjs/src/token/data/HttpTokenDataSource.test.js.map +2 -2
  36. package/lib/esm/package.json +2 -2
  37. package/lib/esm/src/DefaultContextModule.js +1 -1
  38. package/lib/esm/src/DefaultContextModule.js.map +3 -3
  39. package/lib/esm/src/di.js +1 -1
  40. package/lib/esm/src/di.js.map +3 -3
  41. package/lib/esm/src/pki/model/KeyUsage.js +1 -1
  42. package/lib/esm/src/pki/model/KeyUsage.js.map +2 -2
  43. package/lib/esm/src/safe/data/HttpSafeAccountDataSource.js +2 -0
  44. package/lib/esm/src/safe/data/HttpSafeAccountDataSource.js.map +7 -0
  45. package/lib/esm/src/safe/data/HttpSafeAccountDataSource.test.js +2 -0
  46. package/lib/esm/src/safe/data/HttpSafeAccountDataSource.test.js.map +7 -0
  47. package/lib/esm/src/safe/data/SafeAccountDataSource.js +1 -0
  48. package/lib/esm/src/safe/data/SafeAccountDataSource.js.map +7 -0
  49. package/lib/esm/src/safe/data/dto/SafeAccountDto.js +1 -0
  50. package/lib/esm/src/safe/data/dto/SafeAccountDto.js.map +7 -0
  51. package/lib/esm/src/safe/di/safeModuleFactory.js +2 -0
  52. package/lib/esm/src/safe/di/safeModuleFactory.js.map +7 -0
  53. package/lib/esm/src/safe/di/safeModuleFactory.test.js +2 -0
  54. package/lib/esm/src/safe/di/safeModuleFactory.test.js.map +7 -0
  55. package/lib/esm/src/safe/di/safeTypes.js +2 -0
  56. package/lib/esm/src/safe/di/safeTypes.js.map +7 -0
  57. package/lib/esm/src/safe/domain/SafeAddressLoader.js +2 -0
  58. package/lib/esm/src/safe/domain/SafeAddressLoader.js.map +7 -0
  59. package/lib/esm/src/safe/domain/SafeAddressLoader.test.js +2 -0
  60. package/lib/esm/src/safe/domain/SafeAddressLoader.test.js.map +7 -0
  61. package/lib/esm/src/shared/model/ClearSignContext.js +1 -1
  62. package/lib/esm/src/shared/model/ClearSignContext.js.map +2 -2
  63. package/lib/esm/src/shared/utils/KeyUsageMapper.js +1 -1
  64. package/lib/esm/src/shared/utils/KeyUsageMapper.js.map +2 -2
  65. package/lib/esm/src/shared/utils/KeyUsageMapper.test.js +1 -1
  66. package/lib/esm/src/shared/utils/KeyUsageMapper.test.js.map +2 -2
  67. package/lib/esm/src/token/data/HttpTokenDataSource.js +1 -1
  68. package/lib/esm/src/token/data/HttpTokenDataSource.js.map +2 -2
  69. package/lib/esm/src/token/data/HttpTokenDataSource.test.js +1 -1
  70. package/lib/esm/src/token/data/HttpTokenDataSource.test.js.map +2 -2
  71. package/lib/types/src/DefaultContextModule.d.ts.map +1 -1
  72. package/lib/types/src/di.d.ts.map +1 -1
  73. package/lib/types/src/pki/model/KeyUsage.d.ts +2 -1
  74. package/lib/types/src/pki/model/KeyUsage.d.ts.map +1 -1
  75. package/lib/types/src/safe/data/HttpSafeAccountDataSource.d.ts +11 -0
  76. package/lib/types/src/safe/data/HttpSafeAccountDataSource.d.ts.map +1 -0
  77. package/lib/types/src/safe/data/HttpSafeAccountDataSource.test.d.ts +2 -0
  78. package/lib/types/src/safe/data/HttpSafeAccountDataSource.test.d.ts.map +1 -0
  79. package/lib/types/src/safe/data/SafeAccountDataSource.d.ts +20 -0
  80. package/lib/types/src/safe/data/SafeAccountDataSource.d.ts.map +1 -0
  81. package/lib/types/src/safe/data/dto/SafeAccountDto.d.ts +10 -0
  82. package/lib/types/src/safe/data/dto/SafeAccountDto.d.ts.map +1 -0
  83. package/lib/types/src/safe/di/safeModuleFactory.d.ts +3 -0
  84. package/lib/types/src/safe/di/safeModuleFactory.d.ts.map +1 -0
  85. package/lib/types/src/safe/di/safeModuleFactory.test.d.ts +2 -0
  86. package/lib/types/src/safe/di/safeModuleFactory.test.d.ts.map +1 -0
  87. package/lib/types/src/safe/di/safeTypes.d.ts +5 -0
  88. package/lib/types/src/safe/di/safeTypes.d.ts.map +1 -0
  89. package/lib/types/src/safe/domain/SafeAddressLoader.d.ts +19 -0
  90. package/lib/types/src/safe/domain/SafeAddressLoader.d.ts.map +1 -0
  91. package/lib/types/src/safe/domain/SafeAddressLoader.test.d.ts +2 -0
  92. package/lib/types/src/safe/domain/SafeAddressLoader.test.d.ts.map +1 -0
  93. package/lib/types/src/shared/model/ClearSignContext.d.ts +3 -1
  94. package/lib/types/src/shared/model/ClearSignContext.d.ts.map +1 -1
  95. package/lib/types/src/shared/utils/KeyUsageMapper.d.ts.map +1 -1
  96. package/lib/types/src/token/data/HttpTokenDataSource.d.ts.map +1 -1
  97. package/lib/types/tsconfig.prod.tsbuildinfo +1 -1
  98. package/package.json +5 -5
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ledgerhq/context-module",
3
- "version": "1.8.1",
3
+ "version": "1.9.0",
4
4
  "private": false,
5
5
  "license": "Apache-2.0",
6
6
  "exports": {
@@ -53,6 +53,6 @@
53
53
  "reflect-metadata": "catalog:"
54
54
  },
55
55
  "peerDependencies": {
56
- "@ledgerhq/device-management-kit": "^0.9.1"
56
+ "@ledgerhq/device-management-kit": "workspace:*"
57
57
  }
58
58
  }
@@ -1,2 +1,2 @@
1
- "use strict";var s=Object.defineProperty;var g=Object.getOwnPropertyDescriptor;var T=Object.getOwnPropertyNames;var D=Object.prototype.hasOwnProperty;var k=(r,e)=>{for(var t in e)s(r,t,{get:e[t],enumerable:!0})},S=(r,e,t,o)=>{if(e&&typeof e=="object"||typeof e=="function")for(let a of T(e))!D.call(r,a)&&a!==t&&s(r,a,{get:()=>e[a],enumerable:!(o=g(e,a))||o.enumerable});return r};var b=r=>S(s({},"__esModule",{value:!0}),r);var F={};k(F,{DefaultContextModule:()=>w});module.exports=b(F);var c=require("purify-ts"),x=require("./calldata/di/calldataTypes"),m=require("./dynamic-network/di/dynamicNetworkTypes"),l=require("./trusted-name/di/trustedNameTypes"),L=require("./external-plugin/di/externalPluginTypes"),C=require("./nft/di/nftTypes"),y=require("./proxy/di/proxyTypes"),n=require("./shared/model/ClearSignContext"),u=require("./solana/di/solanaContextTypes"),p=require("./token/di/tokenTypes"),f=require("./typed-data/di/typedDataTypes"),h=require("./web3-check/di/web3CheckTypes"),_=require("./di");class w{_container;_loaders;_typedDataLoader;_web3CheckLoader;_solanaLoader;_fieldLoaders;constructor(e){this._container=(0,_.makeContainer)({config:e}),this._loaders=e.defaultLoaders?this._getDefaultLoaders():[],this._loaders.push(...e.customLoaders),this._fieldLoaders=e.defaultFieldLoaders?this._getDefaultFieldLoaders():[],this._fieldLoaders.push(...e.customFieldLoaders),this._typedDataLoader=e.customTypedDataLoader??this._getDefaultTypedDataLoader(),this._web3CheckLoader=e.customWeb3CheckLoader??this._getWeb3CheckLoader(),this._solanaLoader=e.customSolanaLoader??this._getSolanaLoader()}_getDefaultFieldLoaders(){return[this._container.get(C.nftTypes.NftContextFieldLoader),this._container.get(p.tokenTypes.TokenContextFieldLoader),this._container.get(l.trustedNameTypes.TrustedNameContextFieldLoader),this._container.get(y.proxyTypes.ProxyContextFieldLoader)]}_getDefaultLoaders(){return[this._container.get(L.externalPluginTypes.ExternalPluginContextLoader),this._container.get(l.trustedNameTypes.TrustedNameContextLoader),this._container.get(C.nftTypes.NftContextLoader),this._container.get(p.tokenTypes.TokenContextLoader),this._container.get(x.calldataTypes.CalldataContextLoader),this._container.get(m.dynamicNetworkTypes.DynamicNetworkContextLoader)]}_getDefaultTypedDataLoader(){return this._container.get(f.typedDataTypes.TypedDataContextLoader)}_getWeb3CheckLoader(){return this._container.get(h.web3CheckTypes.Web3CheckContextLoader)}_getSolanaLoader(){try{return this._container.get(u.solanaContextTypes.SolanaContextLoader)}catch{return{load:async e=>(0,c.Left)(new Error("[ContextModule] - DefaultContextModule: no SolanaContextLoader bound"))}}}async getContexts(e,t){const o=Object.values(n.ClearSignContextType),d=this._loaders.filter(i=>i.canHandle(e,t??o)).map(i=>i.load(e));return(await Promise.all(d)).flat()}async getFieldContext(e,t){const o=this._fieldLoaders.filter(a=>a.canHandle(e,t));if(o.length===0)return Promise.resolve({type:n.ClearSignContextType.ERROR,error:new Error(`Loader not found for field: ${e} and expected type: ${t}`)});for(const a of o){const d=await a.loadField(e);if(d.type!==n.ClearSignContextType.ERROR)return d}return{type:n.ClearSignContextType.ERROR,error:new Error(`Loader not found for field: ${e} and expected type: ${t}`)}}async getTypedDataFilters(e){return this._typedDataLoader.load(e)}async getWeb3Checks(e){return(await this._web3CheckLoader.load(e)).caseOf({Right:o=>({type:n.ClearSignContextType.WEB3_CHECK,payload:o.descriptor,certificate:o.certificate}),Left:()=>null})}async getSolanaContext(e){return await this._solanaLoader.load(e)}}0&&(module.exports={DefaultContextModule});
1
+ "use strict";var s=Object.defineProperty;var T=Object.getOwnPropertyDescriptor;var D=Object.getOwnPropertyNames;var S=Object.prototype.hasOwnProperty;var k=(r,e)=>{for(var t in e)s(r,t,{get:e[t],enumerable:!0})},b=(r,e,t,o)=>{if(e&&typeof e=="object"||typeof e=="function")for(let a of D(e))!S.call(r,a)&&a!==t&&s(r,a,{get:()=>e[a],enumerable:!(o=T(e,a))||o.enumerable});return r};var w=r=>b(s({},"__esModule",{value:!0}),r);var W={};k(W,{DefaultContextModule:()=>F});module.exports=w(W);var c=require("purify-ts"),x=require("./calldata/di/calldataTypes"),m=require("./dynamic-network/di/dynamicNetworkTypes"),l=require("./trusted-name/di/trustedNameTypes"),L=require("./external-plugin/di/externalPluginTypes"),C=require("./nft/di/nftTypes"),y=require("./proxy/di/proxyTypes"),f=require("./safe/di/safeTypes"),n=require("./shared/model/ClearSignContext"),u=require("./solana/di/solanaContextTypes"),p=require("./token/di/tokenTypes"),h=require("./typed-data/di/typedDataTypes"),_=require("./web3-check/di/web3CheckTypes"),g=require("./di");class F{_container;_loaders;_typedDataLoader;_web3CheckLoader;_solanaLoader;_fieldLoaders;constructor(e){this._container=(0,g.makeContainer)({config:e}),this._loaders=e.defaultLoaders?this._getDefaultLoaders():[],this._loaders.push(...e.customLoaders),this._fieldLoaders=e.defaultFieldLoaders?this._getDefaultFieldLoaders():[],this._fieldLoaders.push(...e.customFieldLoaders),this._typedDataLoader=e.customTypedDataLoader??this._getDefaultTypedDataLoader(),this._web3CheckLoader=e.customWeb3CheckLoader??this._getWeb3CheckLoader(),this._solanaLoader=e.customSolanaLoader??this._getSolanaLoader()}_getDefaultFieldLoaders(){return[this._container.get(C.nftTypes.NftContextFieldLoader),this._container.get(p.tokenTypes.TokenContextFieldLoader),this._container.get(l.trustedNameTypes.TrustedNameContextFieldLoader),this._container.get(y.proxyTypes.ProxyContextFieldLoader)]}_getDefaultLoaders(){return[this._container.get(L.externalPluginTypes.ExternalPluginContextLoader),this._container.get(l.trustedNameTypes.TrustedNameContextLoader),this._container.get(C.nftTypes.NftContextLoader),this._container.get(p.tokenTypes.TokenContextLoader),this._container.get(x.calldataTypes.CalldataContextLoader),this._container.get(m.dynamicNetworkTypes.DynamicNetworkContextLoader),this._container.get(f.safeTypes.SafeAddressLoader)]}_getDefaultTypedDataLoader(){return this._container.get(h.typedDataTypes.TypedDataContextLoader)}_getWeb3CheckLoader(){return this._container.get(_.web3CheckTypes.Web3CheckContextLoader)}_getSolanaLoader(){try{return this._container.get(u.solanaContextTypes.SolanaContextLoader)}catch{return{load:async e=>(0,c.Left)(new Error("[ContextModule] - DefaultContextModule: no SolanaContextLoader bound"))}}}async getContexts(e,t){const o=Object.values(n.ClearSignContextType),d=this._loaders.filter(i=>i.canHandle(e,t??o)).map(i=>i.load(e));return(await Promise.all(d)).flat()}async getFieldContext(e,t){const o=this._fieldLoaders.filter(a=>a.canHandle(e,t));if(o.length===0)return Promise.resolve({type:n.ClearSignContextType.ERROR,error:new Error(`Loader not found for field: ${e} and expected type: ${t}`)});for(const a of o){const d=await a.loadField(e);if(d.type!==n.ClearSignContextType.ERROR)return d}return{type:n.ClearSignContextType.ERROR,error:new Error(`Loader not found for field: ${e} and expected type: ${t}`)}}async getTypedDataFilters(e){return this._typedDataLoader.load(e)}async getWeb3Checks(e){return(await this._web3CheckLoader.load(e)).caseOf({Right:o=>({type:n.ClearSignContextType.WEB3_CHECK,payload:o.descriptor,certificate:o.certificate}),Left:()=>null})}async getSolanaContext(e){return await this._solanaLoader.load(e)}}0&&(module.exports={DefaultContextModule});
2
2
  //# sourceMappingURL=DefaultContextModule.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../src/DefaultContextModule.ts"],
4
- "sourcesContent": ["import { type Container } from \"inversify\";\nimport { Left } from \"purify-ts\";\n\nimport { calldataTypes } from \"@/calldata/di/calldataTypes\";\nimport { dynamicNetworkTypes } from \"@/dynamic-network/di/dynamicNetworkTypes\";\nimport type { TypedDataClearSignContext } from \"@/shared/model/TypedDataClearSignContext\";\nimport type { TypedDataContext } from \"@/shared/model/TypedDataContext\";\nimport { trustedNameTypes } from \"@/trusted-name/di/trustedNameTypes\";\n\nimport { type ContextModuleConfig } from \"./config/model/ContextModuleConfig\";\nimport { externalPluginTypes } from \"./external-plugin/di/externalPluginTypes\";\nimport { nftTypes } from \"./nft/di/nftTypes\";\nimport { proxyTypes } from \"./proxy/di/proxyTypes\";\nimport { type ContextFieldLoader } from \"./shared/domain/ContextFieldLoader\";\nimport { type ContextLoader } from \"./shared/domain/ContextLoader\";\nimport {\n type ClearSignContext,\n type ClearSignContextSuccess,\n ClearSignContextType,\n} from \"./shared/model/ClearSignContext\";\nimport { type SolanaTransactionContext } from \"./shared/model/SolanaTransactionContext\";\nimport { solanaContextTypes } from \"./solana/di/solanaContextTypes\";\nimport { type SolanaContextLoader } from \"./solana/domain/SolanaContextLoader\";\nimport { type SolanaTransactionContextResult } from \"./solana/domain/solanaContextTypes\";\nimport { tokenTypes } from \"./token/di/tokenTypes\";\nimport { typedDataTypes } from \"./typed-data/di/typedDataTypes\";\nimport type { TypedDataContextLoader } from \"./typed-data/domain/TypedDataContextLoader\";\nimport { web3CheckTypes } from \"./web3-check/di/web3CheckTypes\";\nimport { type Web3CheckContextLoader } from \"./web3-check/domain/Web3CheckContextLoader\";\nimport {\n type Web3CheckContext,\n type Web3Checks,\n} from \"./web3-check/domain/web3CheckTypes\";\nimport { type ContextModule } from \"./ContextModule\";\nimport { makeContainer } from \"./di\";\n\nexport class DefaultContextModule implements ContextModule {\n private _container: Container;\n private _loaders: ContextLoader<unknown>[];\n private _typedDataLoader: TypedDataContextLoader;\n private _web3CheckLoader: Web3CheckContextLoader;\n private _solanaLoader: SolanaContextLoader;\n private _fieldLoaders: ContextFieldLoader<unknown>[];\n\n constructor(args: ContextModuleConfig) {\n this._container = makeContainer({ config: args });\n\n this._loaders = args.defaultLoaders ? this._getDefaultLoaders() : [];\n this._loaders.push(...args.customLoaders);\n\n this._fieldLoaders = args.defaultFieldLoaders\n ? this._getDefaultFieldLoaders()\n : [];\n this._fieldLoaders.push(...args.customFieldLoaders);\n\n this._typedDataLoader =\n args.customTypedDataLoader ?? this._getDefaultTypedDataLoader();\n this._web3CheckLoader =\n args.customWeb3CheckLoader ?? this._getWeb3CheckLoader();\n this._solanaLoader = args.customSolanaLoader ?? this._getSolanaLoader();\n }\n\n private _getDefaultFieldLoaders(): ContextFieldLoader[] {\n return [\n this._container.get<ContextFieldLoader>(nftTypes.NftContextFieldLoader),\n this._container.get<ContextFieldLoader>(\n tokenTypes.TokenContextFieldLoader,\n ),\n this._container.get<ContextFieldLoader>(\n trustedNameTypes.TrustedNameContextFieldLoader,\n ),\n this._container.get<ContextFieldLoader>(\n proxyTypes.ProxyContextFieldLoader,\n ),\n ];\n }\n\n private _getDefaultLoaders(): ContextLoader<unknown>[] {\n return [\n this._container.get<ContextLoader>(\n externalPluginTypes.ExternalPluginContextLoader,\n ),\n this._container.get<ContextLoader>(\n trustedNameTypes.TrustedNameContextLoader,\n ),\n this._container.get<ContextLoader>(nftTypes.NftContextLoader),\n this._container.get<ContextLoader>(tokenTypes.TokenContextLoader),\n this._container.get<ContextLoader>(calldataTypes.CalldataContextLoader),\n this._container.get<ContextLoader>(\n dynamicNetworkTypes.DynamicNetworkContextLoader,\n ),\n ];\n }\n\n private _getDefaultTypedDataLoader(): TypedDataContextLoader {\n return this._container.get<TypedDataContextLoader>(\n typedDataTypes.TypedDataContextLoader,\n );\n }\n\n private _getWeb3CheckLoader(): Web3CheckContextLoader {\n return this._container.get<Web3CheckContextLoader>(\n web3CheckTypes.Web3CheckContextLoader,\n );\n }\n\n private _getSolanaLoader(): SolanaContextLoader {\n try {\n return this._container.get<SolanaContextLoader>(\n solanaContextTypes.SolanaContextLoader,\n );\n } catch {\n return {\n load: async (_ctx) =>\n Left(\n new Error(\n \"[ContextModule] - DefaultContextModule: no SolanaContextLoader bound\",\n ),\n ),\n };\n }\n }\n\n public async getContexts(\n input: unknown,\n expectedTypes?: ClearSignContextType[],\n ): Promise<ClearSignContext[]> {\n const allContextTypes = Object.values(ClearSignContextType);\n const loaders = this._loaders.filter((l) =>\n l.canHandle(input, expectedTypes ?? allContextTypes),\n );\n const promises = loaders.map((fetcher) => fetcher.load(input));\n const responses = await Promise.all(promises);\n return responses.flat();\n }\n\n public async getFieldContext<TInput>(\n field: TInput,\n expectedType: ClearSignContextType,\n ): Promise<ClearSignContext> {\n const loaders = this._fieldLoaders.filter((l) =>\n l.canHandle(field, expectedType),\n );\n if (loaders.length === 0) {\n return Promise.resolve({\n type: ClearSignContextType.ERROR,\n error: new Error(\n `Loader not found for field: ${field} and expected type: ${expectedType}`,\n ),\n });\n }\n\n for (const loader of loaders) {\n const context = await loader.loadField(field);\n if (context.type !== ClearSignContextType.ERROR) {\n return context;\n }\n }\n\n return {\n type: ClearSignContextType.ERROR,\n error: new Error(\n `Loader not found for field: ${field} and expected type: ${expectedType}`,\n ),\n };\n }\n\n public async getTypedDataFilters(\n typedData: TypedDataContext,\n ): Promise<TypedDataClearSignContext> {\n return this._typedDataLoader.load(typedData);\n }\n\n public async getWeb3Checks(\n transactionContext: Web3CheckContext,\n ): Promise<ClearSignContextSuccess<ClearSignContextType.WEB3_CHECK> | null> {\n const web3Checks = await this._web3CheckLoader.load(transactionContext);\n\n return web3Checks.caseOf({\n Right: (checks: Web3Checks) => ({\n type: ClearSignContextType.WEB3_CHECK,\n payload: checks.descriptor,\n certificate: checks.certificate,\n }),\n Left: () => null,\n });\n }\n\n public async getSolanaContext(\n transactionContext: SolanaTransactionContext,\n ): Promise<SolanaTransactionContextResult> {\n return await this._solanaLoader.load(transactionContext);\n }\n}\n"],
5
- "mappings": "yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,0BAAAE,IAAA,eAAAC,EAAAH,GACA,IAAAI,EAAqB,qBAErBC,EAA8B,uCAC9BC,EAAoC,oDAGpCC,EAAiC,8CAGjCC,EAAoC,oDACpCC,EAAyB,6BACzBC,EAA2B,iCAG3BC,EAIO,2CAEPC,EAAmC,0CAGnCC,EAA2B,iCAC3BC,EAA+B,0CAE/BC,EAA+B,0CAO/BC,EAA8B,gBAEvB,MAAMd,CAA8C,CACjD,WACA,SACA,iBACA,iBACA,cACA,cAER,YAAYe,EAA2B,CACrC,KAAK,cAAa,iBAAc,CAAE,OAAQA,CAAK,CAAC,EAEhD,KAAK,SAAWA,EAAK,eAAiB,KAAK,mBAAmB,EAAI,CAAC,EACnE,KAAK,SAAS,KAAK,GAAGA,EAAK,aAAa,EAExC,KAAK,cAAgBA,EAAK,oBACtB,KAAK,wBAAwB,EAC7B,CAAC,EACL,KAAK,cAAc,KAAK,GAAGA,EAAK,kBAAkB,EAElD,KAAK,iBACHA,EAAK,uBAAyB,KAAK,2BAA2B,EAChE,KAAK,iBACHA,EAAK,uBAAyB,KAAK,oBAAoB,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B,KAAM,uBAAqB,MAC3B,MAAO,IAAI,MACT,+BAA+BF,CAAK,uBAAuBC,CAAY,EACzE,CACF,CAAC,EAGH,UAAWE,KAAUD,EAAS,CAC5B,MAAME,EAAU,MAAMD,EAAO,UAAUH,CAAK,EAC5C,GAAII,EAAQ,OAAS,uBAAqB,MACxC,OAAOA,CAEX,CAEA,MAAO,CACL,KAAM,uBAAqB,MAC3B,MAAO,IAAI,MACT,+BAA+BJ,CAAK,uBAAuBC,CAAY,EACzE,CACF,CACF,CAEA,MAAa,oBACXI,EACoC,CACpC,OAAO,KAAK,iBAAiB,KAAKA,CAAS,CAC7C,CAEA,MAAa,cACXC,EAC0E,CAG1E,OAFmB,MAAM,KAAK,iBAAiB,KAAKA,CAAkB,GAEpD,OAAO,CACvB,MAAQC,IAAwB,CAC9B,KAAM,uBAAqB,WAC3B,QAASA,EAAO,WAChB,YAAaA,EAAO,WACtB,GACA,KAAM,IAAM,IACd,CAAC,CACH,CAEA,MAAa,iBACXD,EACyC,CACzC,OAAO,MAAM,KAAK,cAAc,KAAKA,CAAkB,CACzD,CACF",
6
- "names": ["DefaultContextModule_exports", "__export", "DefaultContextModule", "__toCommonJS", "import_purify_ts", "import_calldataTypes", "import_dynamicNetworkTypes", "import_trustedNameTypes", "import_externalPluginTypes", "import_nftTypes", "import_proxyTypes", "import_ClearSignContext", "import_solanaContextTypes", "import_tokenTypes", "import_typedDataTypes", "import_web3CheckTypes", "import_di", "args", "_ctx", "input", "expectedTypes", "allContextTypes", "promises", "l", "fetcher", "field", "expectedType", "loaders", "loader", "context", "typedData", "transactionContext", "checks"]
4
+ "sourcesContent": ["import { type Container } from \"inversify\";\nimport { Left } from \"purify-ts\";\n\nimport { calldataTypes } from \"@/calldata/di/calldataTypes\";\nimport { dynamicNetworkTypes } from \"@/dynamic-network/di/dynamicNetworkTypes\";\nimport type { TypedDataClearSignContext } from \"@/shared/model/TypedDataClearSignContext\";\nimport type { TypedDataContext } from \"@/shared/model/TypedDataContext\";\nimport { trustedNameTypes } from \"@/trusted-name/di/trustedNameTypes\";\n\nimport { type ContextModuleConfig } from \"./config/model/ContextModuleConfig\";\nimport { externalPluginTypes } from \"./external-plugin/di/externalPluginTypes\";\nimport { nftTypes } from \"./nft/di/nftTypes\";\nimport { proxyTypes } from \"./proxy/di/proxyTypes\";\nimport { safeTypes } from \"./safe/di/safeTypes\";\nimport { type ContextFieldLoader } from \"./shared/domain/ContextFieldLoader\";\nimport { type ContextLoader } from \"./shared/domain/ContextLoader\";\nimport {\n type ClearSignContext,\n type ClearSignContextSuccess,\n ClearSignContextType,\n} from \"./shared/model/ClearSignContext\";\nimport { type SolanaTransactionContext } from \"./shared/model/SolanaTransactionContext\";\nimport { solanaContextTypes } from \"./solana/di/solanaContextTypes\";\nimport { type SolanaContextLoader } from \"./solana/domain/SolanaContextLoader\";\nimport { type SolanaTransactionContextResult } from \"./solana/domain/solanaContextTypes\";\nimport { tokenTypes } from \"./token/di/tokenTypes\";\nimport { typedDataTypes } from \"./typed-data/di/typedDataTypes\";\nimport type { TypedDataContextLoader } from \"./typed-data/domain/TypedDataContextLoader\";\nimport { web3CheckTypes } from \"./web3-check/di/web3CheckTypes\";\nimport { type Web3CheckContextLoader } from \"./web3-check/domain/Web3CheckContextLoader\";\nimport {\n type Web3CheckContext,\n type Web3Checks,\n} from \"./web3-check/domain/web3CheckTypes\";\nimport { type ContextModule } from \"./ContextModule\";\nimport { makeContainer } from \"./di\";\n\nexport class DefaultContextModule implements ContextModule {\n private _container: Container;\n private _loaders: ContextLoader<unknown>[];\n private _typedDataLoader: TypedDataContextLoader;\n private _web3CheckLoader: Web3CheckContextLoader;\n private _solanaLoader: SolanaContextLoader;\n private _fieldLoaders: ContextFieldLoader<unknown>[];\n\n constructor(args: ContextModuleConfig) {\n this._container = makeContainer({ config: args });\n\n this._loaders = args.defaultLoaders ? this._getDefaultLoaders() : [];\n this._loaders.push(...args.customLoaders);\n\n this._fieldLoaders = args.defaultFieldLoaders\n ? this._getDefaultFieldLoaders()\n : [];\n this._fieldLoaders.push(...args.customFieldLoaders);\n\n this._typedDataLoader =\n args.customTypedDataLoader ?? this._getDefaultTypedDataLoader();\n this._web3CheckLoader =\n args.customWeb3CheckLoader ?? this._getWeb3CheckLoader();\n this._solanaLoader = args.customSolanaLoader ?? this._getSolanaLoader();\n }\n\n private _getDefaultFieldLoaders(): ContextFieldLoader[] {\n return [\n this._container.get<ContextFieldLoader>(nftTypes.NftContextFieldLoader),\n this._container.get<ContextFieldLoader>(\n tokenTypes.TokenContextFieldLoader,\n ),\n this._container.get<ContextFieldLoader>(\n trustedNameTypes.TrustedNameContextFieldLoader,\n ),\n this._container.get<ContextFieldLoader>(\n proxyTypes.ProxyContextFieldLoader,\n ),\n ];\n }\n\n private _getDefaultLoaders(): ContextLoader<unknown>[] {\n return [\n this._container.get<ContextLoader>(\n externalPluginTypes.ExternalPluginContextLoader,\n ),\n this._container.get<ContextLoader>(\n trustedNameTypes.TrustedNameContextLoader,\n ),\n this._container.get<ContextLoader>(nftTypes.NftContextLoader),\n this._container.get<ContextLoader>(tokenTypes.TokenContextLoader),\n this._container.get<ContextLoader>(calldataTypes.CalldataContextLoader),\n this._container.get<ContextLoader>(\n dynamicNetworkTypes.DynamicNetworkContextLoader,\n ),\n this._container.get<ContextLoader>(safeTypes.SafeAddressLoader),\n ];\n }\n\n private _getDefaultTypedDataLoader(): TypedDataContextLoader {\n return this._container.get<TypedDataContextLoader>(\n typedDataTypes.TypedDataContextLoader,\n );\n }\n\n private _getWeb3CheckLoader(): Web3CheckContextLoader {\n return this._container.get<Web3CheckContextLoader>(\n web3CheckTypes.Web3CheckContextLoader,\n );\n }\n\n private _getSolanaLoader(): SolanaContextLoader {\n try {\n return this._container.get<SolanaContextLoader>(\n solanaContextTypes.SolanaContextLoader,\n );\n } catch {\n return {\n load: async (_ctx) =>\n Left(\n new Error(\n \"[ContextModule] - DefaultContextModule: no SolanaContextLoader bound\",\n ),\n ),\n };\n }\n }\n\n public async getContexts(\n input: unknown,\n expectedTypes?: ClearSignContextType[],\n ): Promise<ClearSignContext[]> {\n const allContextTypes = Object.values(ClearSignContextType);\n const loaders = this._loaders.filter((l) =>\n l.canHandle(input, expectedTypes ?? allContextTypes),\n );\n const promises = loaders.map((fetcher) => fetcher.load(input));\n const responses = await Promise.all(promises);\n return responses.flat();\n }\n\n public async getFieldContext<TInput>(\n field: TInput,\n expectedType: ClearSignContextType,\n ): Promise<ClearSignContext> {\n const loaders = this._fieldLoaders.filter((l) =>\n l.canHandle(field, expectedType),\n );\n if (loaders.length === 0) {\n return Promise.resolve({\n type: ClearSignContextType.ERROR,\n error: new Error(\n `Loader not found for field: ${field} and expected type: ${expectedType}`,\n ),\n });\n }\n\n for (const loader of loaders) {\n const context = await loader.loadField(field);\n if (context.type !== ClearSignContextType.ERROR) {\n return context;\n }\n }\n\n return {\n type: ClearSignContextType.ERROR,\n error: new Error(\n `Loader not found for field: ${field} and expected type: ${expectedType}`,\n ),\n };\n }\n\n public async getTypedDataFilters(\n typedData: TypedDataContext,\n ): Promise<TypedDataClearSignContext> {\n return this._typedDataLoader.load(typedData);\n }\n\n public async getWeb3Checks(\n transactionContext: Web3CheckContext,\n ): Promise<ClearSignContextSuccess<ClearSignContextType.WEB3_CHECK> | null> {\n const web3Checks = await this._web3CheckLoader.load(transactionContext);\n\n return web3Checks.caseOf({\n Right: (checks: Web3Checks) => ({\n type: ClearSignContextType.WEB3_CHECK,\n payload: checks.descriptor,\n certificate: checks.certificate,\n }),\n Left: () => null,\n });\n }\n\n public async getSolanaContext(\n transactionContext: SolanaTransactionContext,\n ): Promise<SolanaTransactionContextResult> {\n return await this._solanaLoader.load(transactionContext);\n }\n}\n"],
5
+ "mappings": "yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,0BAAAE,IAAA,eAAAC,EAAAH,GACA,IAAAI,EAAqB,qBAErBC,EAA8B,uCAC9BC,EAAoC,oDAGpCC,EAAiC,8CAGjCC,EAAoC,oDACpCC,EAAyB,6BAC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O,MAAM,KAAK,cAAc,KAAKA,CAAkB,CACzD,CACF",
6
+ "names": ["DefaultContextModule_exports", "__export", "DefaultContextModule", "__toCommonJS", "import_purify_ts", "import_calldataTypes", "import_dynamicNetworkTypes", "import_trustedNameTypes", "import_externalPluginTypes", "import_nftTypes", "import_proxyTypes", "import_safeTypes", "import_ClearSignContext", "import_solanaContextTypes", "import_tokenTypes", "import_typedDataTypes", "import_web3CheckTypes", "import_di", "args", "_ctx", "input", "expectedTypes", "allContextTypes", "promises", "l", "fetcher", "field", "expectedType", "loaders", "loader", "context", "typedData", "transactionContext", "checks"]
7
7
  }
package/lib/cjs/src/di.js CHANGED
@@ -1,2 +1,2 @@
1
- "use strict";var a=Object.defineProperty;var g=Object.getOwnPropertyDescriptor;var x=Object.getOwnPropertyNames;var w=Object.prototype.hasOwnProperty;var A=(r,o)=>{for(var e in o)a(r,e,{get:o[e],enumerable:!0})},N=(r,o,e,m)=>{if(o&&typeof o=="object"||typeof o=="function")for(let t of x(o))!w.call(r,t)&&t!==e&&a(r,t,{get:()=>o[t],enumerable:!(m=g(o,t))||m.enumerable});return r};var P=r=>N(a({},"__esModule",{value:!0}),r);var h={};A(h,{makeContainer:()=>b});module.exports=P(h);var n=require("inversify"),i=require("./calldata/di/calldataModuleFactory"),c=require("./config/di/configModuleFactory"),l=require("./dynamic-network/di/dynamicNetworkModuleFactory"),p=require("./external-plugin/di/externalPluginModuleFactory"),d=require("./nft/di/nftModuleFactory"),f=require("./pki/di/pkiModuleFactory"),u=require("./proxy/di/proxyModuleFactory"),y=require("./solana/di/SolanaContextModuleFactory"),M=require("./token/di/tokenModuleFactory"),F=require("./trusted-name/di/trustedNameModuleFactory"),C=require("./typed-data/di/typedDataModuleFactory"),k=require("./uniswap/di/uniswapModuleFactory"),s=require("./web3-check/di/web3CheckModuleFactory");const b=({config:r})=>{const o=new n.Container;return o.loadSync((0,c.configModuleFactory)(r),(0,p.externalPluginModuleFactory)(),(0,l.dynamicNetworkModuleFactory)(),(0,d.nftModuleFactory)(),(0,u.proxyModuleFactory)(r),(0,M.tokenModuleFactory)(),(0,i.calldataModuleFactory)(),(0,F.trustedNameModuleFactory)(),(0,C.typedDataModuleFactory)(),(0,f.nanoPkiModuleFactory)(),(0,k.uniswapModuleFactory)(),(0,s.web3CheckModuleFactory)(),(0,y.solanaContextModuleFactory)()),o};0&&(module.exports={makeContainer});
1
+ "use strict";var a=Object.defineProperty;var x=Object.getOwnPropertyDescriptor;var w=Object.getOwnPropertyNames;var A=Object.prototype.hasOwnProperty;var N=(r,o)=>{for(var e in o)a(r,e,{get:o[e],enumerable:!0})},P=(r,o,e,m)=>{if(o&&typeof o=="object"||typeof o=="function")for(let t of w(o))!A.call(r,t)&&t!==e&&a(r,t,{get:()=>o[t],enumerable:!(m=x(o,t))||m.enumerable});return r};var b=r=>P(a({},"__esModule",{value:!0}),r);var D={};N(D,{makeContainer:()=>h});module.exports=b(D);var n=require("inversify"),i=require("./calldata/di/calldataModuleFactory"),c=require("./config/di/configModuleFactory"),l=require("./dynamic-network/di/dynamicNetworkModuleFactory"),p=require("./external-plugin/di/externalPluginModuleFactory"),d=require("./nft/di/nftModuleFactory"),f=require("./pki/di/pkiModuleFactory"),u=require("./proxy/di/proxyModuleFactory"),y=require("./safe/di/safeModuleFactory"),M=require("./solana/di/SolanaContextModuleFactory"),F=require("./token/di/tokenModuleFactory"),C=require("./trusted-name/di/trustedNameModuleFactory"),s=require("./typed-data/di/typedDataModuleFactory"),k=require("./uniswap/di/uniswapModuleFactory"),g=require("./web3-check/di/web3CheckModuleFactory");const h=({config:r})=>{const o=new n.Container;return o.loadSync((0,c.configModuleFactory)(r),(0,p.externalPluginModuleFactory)(),(0,l.dynamicNetworkModuleFactory)(),(0,d.nftModuleFactory)(),(0,u.proxyModuleFactory)(r),(0,y.safeModuleFactory)(),(0,F.tokenModuleFactory)(),(0,i.calldataModuleFactory)(),(0,C.trustedNameModuleFactory)(),(0,s.typedDataModuleFactory)(),(0,f.nanoPkiModuleFactory)(),(0,k.uniswapModuleFactory)(),(0,g.web3CheckModuleFactory)(),(0,M.solanaContextModuleFactory)()),o};0&&(module.exports={makeContainer});
2
2
  //# sourceMappingURL=di.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../src/di.ts"],
4
- "sourcesContent": ["import { Container } from \"inversify\";\n\nimport { calldataModuleFactory } from \"@/calldata/di/calldataModuleFactory\";\nimport { configModuleFactory } from \"@/config/di/configModuleFactory\";\nimport { type ContextModuleConfig } from \"@/config/model/ContextModuleConfig\";\nimport { dynamicNetworkModuleFactory } from \"@/dynamic-network/di/dynamicNetworkModuleFactory\";\nimport { externalPluginModuleFactory } from \"@/external-plugin/di/externalPluginModuleFactory\";\nimport { nftModuleFactory } from \"@/nft/di/nftModuleFactory\";\nimport { nanoPkiModuleFactory } from \"@/pki/di/pkiModuleFactory\";\nimport { proxyModuleFactory } from \"@/proxy/di/proxyModuleFactory\";\nimport { solanaContextModuleFactory } from \"@/solana/di/SolanaContextModuleFactory\";\nimport { tokenModuleFactory } from \"@/token/di/tokenModuleFactory\";\nimport { trustedNameModuleFactory } from \"@/trusted-name/di/trustedNameModuleFactory\";\nimport { typedDataModuleFactory } from \"@/typed-data/di/typedDataModuleFactory\";\nimport { uniswapModuleFactory } from \"@/uniswap/di/uniswapModuleFactory\";\nimport { web3CheckModuleFactory } from \"@/web3-check/di/web3CheckModuleFactory\";\n\ntype MakeContainerArgs = {\n config: ContextModuleConfig;\n};\n\nexport const makeContainer = ({ config }: MakeContainerArgs) => {\n const container = new Container();\n\n container.loadSync(\n configModuleFactory(config),\n externalPluginModuleFactory(),\n dynamicNetworkModuleFactory(),\n nftModuleFactory(),\n proxyModuleFactory(config),\n tokenModuleFactory(),\n calldataModuleFactory(),\n trustedNameModuleFactory(),\n typedDataModuleFactory(),\n nanoPkiModuleFactory(),\n uniswapModuleFactory(),\n web3CheckModuleFactory(),\n solanaContextModuleFactory(),\n );\n\n return container;\n};\n"],
5
- "mappings": "yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,mBAAAE,IAAA,eAAAC,EAAAH,GAAA,IAAAI,EAA0B,qBAE1BC,EAAsC,+CACtCC,EAAoC,2CAEpCC,EAA4C,4DAC5CC,EAA4C,4DAC5CC,EAAiC,qCACjCC,EAAqC,qCACrCC,EAAmC,yCACnCC,EAA2C,kDAC3CC,EAAmC,yCACnCC,EAAyC,sDACzCC,EAAuC,kDACvCC,EAAqC,6CACrCC,EAAuC,kDAMhC,MAAMf,EAAgB,CAAC,CAAE,OAAAgB,CAAO,IAAyB,CAC9D,MAAMC,EAAY,IAAI,YAEtB,OAAAA,EAAU,YACR,uBAAoBD,CAAM,KAC1B,+BAA4B,KAC5B,+BAA4B,KAC5B,oBAAiB,KACjB,sBAAmBA,CAAM,KACzB,sBAAmB,KACnB,yBAAsB,KACtB,4BAAyB,KACzB,0BAAuB,KACvB,wBAAqB,KACrB,wBAAqB,KACrB,0BAAuB,KACvB,8BAA2B,CAC7B,EAEOC,CACT",
6
- "names": ["di_exports", "__export", "makeContainer", "__toCommonJS", "import_inversify", "import_calldataModuleFactory", "import_configModuleFactory", "import_dynamicNetworkModuleFactory", "import_externalPluginModuleFactory", "import_nftModuleFactory", "import_pkiModuleFactory", "import_proxyModuleFactory", "import_SolanaContextModuleFactory", "import_tokenModuleFactory", "import_trustedNameModuleFactory", "import_typedDataModuleFactory", "import_uniswapModuleFactory", "import_web3CheckModuleFactory", "config", "container"]
4
+ "sourcesContent": ["import { Container } from \"inversify\";\n\nimport { calldataModuleFactory } from \"@/calldata/di/calldataModuleFactory\";\nimport { configModuleFactory } from \"@/config/di/configModuleFactory\";\nimport { type ContextModuleConfig } from \"@/config/model/ContextModuleConfig\";\nimport { dynamicNetworkModuleFactory } from \"@/dynamic-network/di/dynamicNetworkModuleFactory\";\nimport { externalPluginModuleFactory } from \"@/external-plugin/di/externalPluginModuleFactory\";\nimport { nftModuleFactory } from \"@/nft/di/nftModuleFactory\";\nimport { nanoPkiModuleFactory } from \"@/pki/di/pkiModuleFactory\";\nimport { proxyModuleFactory } from \"@/proxy/di/proxyModuleFactory\";\nimport { safeModuleFactory } from \"@/safe/di/safeModuleFactory\";\nimport { solanaContextModuleFactory } from \"@/solana/di/SolanaContextModuleFactory\";\nimport { tokenModuleFactory } from \"@/token/di/tokenModuleFactory\";\nimport { trustedNameModuleFactory } from \"@/trusted-name/di/trustedNameModuleFactory\";\nimport { typedDataModuleFactory } from \"@/typed-data/di/typedDataModuleFactory\";\nimport { uniswapModuleFactory } from \"@/uniswap/di/uniswapModuleFactory\";\nimport { web3CheckModuleFactory } from \"@/web3-check/di/web3CheckModuleFactory\";\n\ntype MakeContainerArgs = {\n config: ContextModuleConfig;\n};\n\nexport const makeContainer = ({ config }: MakeContainerArgs) => {\n const container = new Container();\n\n container.loadSync(\n configModuleFactory(config),\n externalPluginModuleFactory(),\n dynamicNetworkModuleFactory(),\n nftModuleFactory(),\n proxyModuleFactory(config),\n safeModuleFactory(),\n tokenModuleFactory(),\n calldataModuleFactory(),\n trustedNameModuleFactory(),\n typedDataModuleFactory(),\n nanoPkiModuleFactory(),\n uniswapModuleFactory(),\n web3CheckModuleFactory(),\n solanaContextModuleFactory(),\n );\n\n return container;\n};\n"],
5
+ "mappings": "yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,mBAAAE,IAAA,eAAAC,EAAAH,GAAA,IAAAI,EAA0B,qBAE1BC,EAAsC,+CACtCC,EAAoC,2CAEpCC,EAA4C,4DAC5CC,EAA4C,4DAC5CC,EAAiC,qCACjCC,EAAqC,qCACrCC,EAAmC,yCACnCC,EAAkC,uCAClCC,EAA2C,kDAC3CC,EAAmC,yCACnCC,EAAyC,sDACzCC,EAAuC,kDACvCC,EAAqC,6CACrCC,EAAuC,kDAMhC,MAAMhB,EAAgB,CAAC,CAAE,OAAAiB,CAAO,IAAyB,CAC9D,MAAMC,EAAY,IAAI,YAEtB,OAAAA,EAAU,YACR,uBAAoBD,CAAM,KAC1B,+BAA4B,KAC5B,+BAA4B,KAC5B,oBAAiB,KACjB,sBAAmBA,CAAM,KACzB,qBAAkB,KAClB,sBAAmB,KACnB,yBAAsB,KACtB,4BAAyB,KACzB,0BAAuB,KACvB,wBAAqB,KACrB,wBAAqB,KACrB,0BAAuB,KACvB,8BAA2B,CAC7B,EAEOC,CACT",
6
+ "names": ["di_exports", "__export", "makeContainer", "__toCommonJS", "import_inversify", "import_calldataModuleFactory", "import_configModuleFactory", "import_dynamicNetworkModuleFactory", "import_externalPluginModuleFactory", "import_nftModuleFactory", "import_pkiModuleFactory", "import_proxyModuleFactory", "import_safeModuleFactory", "import_SolanaContextModuleFactory", "import_tokenModuleFactory", "import_trustedNameModuleFactory", "import_typedDataModuleFactory", "import_uniswapModuleFactory", "import_web3CheckModuleFactory", "config", "container"]
7
7
  }
@@ -1,2 +1,2 @@
1
- "use strict";var i=Object.defineProperty;var d=Object.getOwnPropertyDescriptor;var _=Object.getOwnPropertyNames;var e=Object.prototype.hasOwnProperty;var l=(n,r)=>{for(var a in r)i(n,a,{get:r[a],enumerable:!0})},h=(n,r,a,c)=>{if(r&&typeof r=="object"||typeof r=="function")for(let o of _(r))!e.call(n,o)&&o!==a&&i(n,o,{get:()=>r[o],enumerable:!(c=d(r,o))||c.enumerable});return n};var m=n=>h(i({},"__esModule",{value:!0}),n);var p={};l(p,{KeyUsage:()=>u});module.exports=m(p);var u=(t=>(t.GenuineCheck="genuine_check",t.ExchangePayload="exchange_payload",t.NftMeta="nft_meta",t.TrustedName="trusted_name",t.BackupProvider="backup_provider",t.ProtectOrchestrator="protect_orchestrator",t.PluginMeta="plugin_meta",t.CoinMeta="coin_meta",t.SeedIdAuth="seed_id_auth",t.TxSimulationSigner="tx_simu_signer",t.Calldata="calldata",t.Network="network",t))(u||{});0&&(module.exports={KeyUsage});
1
+ "use strict";var u=Object.defineProperty;var _=Object.getOwnPropertyDescriptor;var d=Object.getOwnPropertyNames;var l=Object.prototype.hasOwnProperty;var e=(i,r)=>{for(var o in r)u(i,o,{get:r[o],enumerable:!0})},m=(i,r,o,a)=>{if(r&&typeof r=="object"||typeof r=="function")for(let n of d(r))!l.call(i,n)&&n!==o&&u(i,n,{get:()=>r[n],enumerable:!(a=_(r,n))||a.enumerable});return i};var h=i=>m(u({},"__esModule",{value:!0}),i);var p={};e(p,{KeyUsage:()=>c});module.exports=h(p);var c=(t=>(t.GenuineCheck="genuine_check",t.ExchangePayload="exchange_payload",t.NftMeta="nft_meta",t.TrustedName="trusted_name",t.BackupProvider="backup_provider",t.ProtectOrchestrator="protect_orchestrator",t.PluginMeta="plugin_meta",t.CoinMeta="coin_meta",t.SeedIdAuth="seed_id_auth",t.TxSimulationSigner="tx_simu_signer",t.Calldata="calldata",t.Network="network",t.LESMultisig="les_multisig",t))(c||{});0&&(module.exports={KeyUsage});
2
2
  //# sourceMappingURL=KeyUsage.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../../src/pki/model/KeyUsage.ts"],
4
- "sourcesContent": ["export enum KeyUsage {\n GenuineCheck = \"genuine_check\",\n ExchangePayload = \"exchange_payload\",\n NftMeta = \"nft_meta\",\n TrustedName = \"trusted_name\",\n BackupProvider = \"backup_provider\",\n ProtectOrchestrator = \"protect_orchestrator\",\n PluginMeta = \"plugin_meta\",\n CoinMeta = \"coin_meta\",\n SeedIdAuth = \"seed_id_auth\",\n TxSimulationSigner = \"tx_simu_signer\",\n Calldata = \"calldata\",\n Network = \"network\",\n}\n"],
5
- "mappings": "yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,cAAAE,IAAA,eAAAC,EAAAH,GAAO,IAAKE,OACVA,EAAA,aAAe,gBACfA,EAAA,gBAAkB,mBAClBA,EAAA,QAAU,WACVA,EAAA,YAAc,eACdA,EAAA,eAAiB,kBACjBA,EAAA,oBAAsB,uBACtBA,EAAA,WAAa,cACbA,EAAA,SAAW,YACXA,EAAA,WAAa,eACbA,EAAA,mBAAqB,iBACrBA,EAAA,SAAW,WACXA,EAAA,QAAU,UAZAA,OAAA",
4
+ "sourcesContent": ["export enum KeyUsage {\n GenuineCheck = \"genuine_check\",\n ExchangePayload = \"exchange_payload\",\n NftMeta = \"nft_meta\",\n TrustedName = \"trusted_name\",\n BackupProvider = \"backup_provider\",\n ProtectOrchestrator = \"protect_orchestrator\",\n PluginMeta = \"plugin_meta\",\n CoinMeta = \"coin_meta\",\n SeedIdAuth = \"seed_id_auth\",\n TxSimulationSigner = \"tx_simu_signer\",\n Calldata = \"calldata\",\n Network = \"network\",\n LESMultisig = \"les_multisig\",\n}\n"],
5
+ "mappings": "yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,cAAAE,IAAA,eAAAC,EAAAH,GAAO,IAAKE,OACVA,EAAA,aAAe,gBACfA,EAAA,gBAAkB,mBAClBA,EAAA,QAAU,WACVA,EAAA,YAAc,eACdA,EAAA,eAAiB,kBACjBA,EAAA,oBAAsB,uBACtBA,EAAA,WAAa,cACbA,EAAA,SAAW,YACXA,EAAA,WAAa,eACbA,EAAA,mBAAqB,iBACrBA,EAAA,SAAW,WACXA,EAAA,QAAU,UACVA,EAAA,YAAc,eAbJA,OAAA",
6
6
  "names": ["KeyUsage_exports", "__export", "KeyUsage", "__toCommonJS"]
7
7
  }
@@ -0,0 +1,2 @@
1
+ "use strict";var A=Object.create;var c=Object.defineProperty;var D=Object.getOwnPropertyDescriptor;var h=Object.getOwnPropertyNames;var C=Object.getPrototypeOf,I=Object.prototype.hasOwnProperty;var x=(r,e)=>{for(var o in e)c(r,o,{get:e[o],enumerable:!0})},d=(r,e,o,s)=>{if(e&&typeof e=="object"||typeof e=="function")for(let t of h(e))!I.call(r,t)&&t!==o&&c(r,t,{get:()=>e[t],enumerable:!(s=D(e,t))||s.enumerable});return r};var u=(r,e,o)=>(o=r!=null?A(C(r)):{},d(e||!r||!r.__esModule?c(o,"default",{value:r,enumerable:!0}):o,r)),G=r=>d(c({},"__esModule",{value:!0}),r),g=(r,e,o,s)=>{for(var t=s>1?void 0:s?D(e,o):e,p=r.length-1,f;p>=0;p--)(f=r[p])&&(t=(s?f(e,o,t):f(t))||t);return s&&t&&c(e,o,t),t},m=(r,e)=>(o,s)=>e(o,s,r);var R={};x(R,{HttpSafeAccountDataSource:()=>n});module.exports=G(R);var y=u(require("axios")),S=require("inversify"),i=require("purify-ts"),E=require("../../config/di/configTypes"),a=require("../../shared/constant/HttpHeaders"),k=u(require("../../../package.json"));let n=class{constructor(e){this.config=e}async getDescriptors({safeContractAddress:e,chainId:o,challenge:s}){try{const t=await y.default.request({method:"GET",url:`${this.config.metadataServiceDomain.url}/v2/ethereum/${o}/safe/account/${e}`,params:{challenge:s},headers:{[a.LEDGER_CLIENT_VERSION_HEADER]:`context-module/${k.default.version}`,[a.LEDGER_ORIGIN_TOKEN_HEADER]:this.config.originToken}});return t.data?this.isSafeAccountDto(t.data)?(0,i.Right)({account:{signedDescriptor:t.data.accountDescriptor.signedDescriptor,keyId:t.data.accountDescriptor.keyId,keyUsage:t.data.accountDescriptor.keyUsage},signers:{signedDescriptor:t.data.signersDescriptor.signedDescriptor,keyId:t.data.signersDescriptor.keyId,keyUsage:t.data.signersDescriptor.keyUsage}}):(0,i.Left)(new Error("[ContextModule] HttpSafeAccountDataSource: invalid safe account response format")):(0,i.Left)(new Error("[ContextModule] HttpSafeAccountDataSource: unexpected empty response"))}catch{return(0,i.Left)(new Error("[ContextModule] HttpSafeAccountDataSource: Failed to fetch safe account descriptors"))}}isSafeAccountDto(e){return typeof e=="object"&&e!==null&&"accountDescriptor"in e&&"signersDescriptor"in e&&typeof e.accountDescriptor=="object"&&typeof e.signersDescriptor=="object"&&this.isSafeDescriptorDto(e.accountDescriptor)&&this.isSafeDescriptorDto(e.signersDescriptor)}isSafeDescriptorDto(e){return typeof e=="object"&&e!==null&&"signedDescriptor"in e&&"keyId"in e&&"keyUsage"in e&&typeof e.signedDescriptor=="string"&&typeof e.keyId=="string"&&typeof e.keyUsage=="string"}};n=g([m(0,(0,S.inject)(E.configTypes.Config))],n);0&&(module.exports={HttpSafeAccountDataSource});
2
+ //# sourceMappingURL=HttpSafeAccountDataSource.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../../../src/safe/data/HttpSafeAccountDataSource.ts"],
4
+ "sourcesContent": ["import axios from \"axios\";\nimport { inject } from \"inversify\";\nimport { type Either, Left, Right } from \"purify-ts\";\n\nimport { configTypes } from \"@/config/di/configTypes\";\nimport { type ContextModuleConfig } from \"@/config/model/ContextModuleConfig\";\nimport {\n LEDGER_CLIENT_VERSION_HEADER,\n LEDGER_ORIGIN_TOKEN_HEADER,\n} from \"@/shared/constant/HttpHeaders\";\nimport PACKAGE from \"@root/package.json\";\n\nimport { SafeAccountDto, SafeDescriptorDto } from \"./dto/SafeAccountDto\";\nimport {\n type GetSafeAccountParams,\n type GetSafeAccountResponse,\n type SafeAccountDataSource,\n} from \"./SafeAccountDataSource\";\n\nexport class HttpSafeAccountDataSource implements SafeAccountDataSource {\n constructor(\n @inject(configTypes.Config) private readonly config: ContextModuleConfig,\n ) {}\n\n async getDescriptors({\n safeContractAddress,\n chainId,\n challenge,\n }: GetSafeAccountParams): Promise<Either<Error, GetSafeAccountResponse>> {\n try {\n const response = await axios.request<SafeAccountDto>({\n method: \"GET\",\n url: `${this.config.metadataServiceDomain.url}/v2/ethereum/${chainId}/safe/account/${safeContractAddress}`,\n params: {\n challenge,\n },\n headers: {\n [LEDGER_CLIENT_VERSION_HEADER]: `context-module/${PACKAGE.version}`,\n [LEDGER_ORIGIN_TOKEN_HEADER]: this.config.originToken,\n },\n });\n\n if (!response.data) {\n return Left(\n new Error(\n \"[ContextModule] HttpSafeAccountDataSource: unexpected empty response\",\n ),\n );\n }\n\n if (!this.isSafeAccountDto(response.data)) {\n return Left(\n new Error(\n \"[ContextModule] HttpSafeAccountDataSource: invalid safe account response format\",\n ),\n );\n }\n\n return Right({\n account: {\n signedDescriptor: response.data.accountDescriptor.signedDescriptor,\n keyId: response.data.accountDescriptor.keyId,\n keyUsage: response.data.accountDescriptor.keyUsage,\n },\n signers: {\n signedDescriptor: response.data.signersDescriptor.signedDescriptor,\n keyId: response.data.signersDescriptor.keyId,\n keyUsage: response.data.signersDescriptor.keyUsage,\n },\n });\n } catch (_error) {\n return Left(\n new Error(\n \"[ContextModule] HttpSafeAccountDataSource: Failed to fetch safe account descriptors\",\n ),\n );\n }\n }\n\n private isSafeAccountDto(value: unknown): value is SafeAccountDto {\n return (\n typeof value === \"object\" &&\n value !== null &&\n \"accountDescriptor\" in value &&\n \"signersDescriptor\" in value &&\n typeof value.accountDescriptor === \"object\" &&\n typeof value.signersDescriptor === \"object\" &&\n this.isSafeDescriptorDto(value.accountDescriptor) &&\n this.isSafeDescriptorDto(value.signersDescriptor)\n );\n }\n\n private isSafeDescriptorDto(value: unknown): value is SafeDescriptorDto {\n return (\n typeof value === \"object\" &&\n value !== null &&\n \"signedDescriptor\" in value &&\n \"keyId\" in value &&\n \"keyUsage\" in value &&\n typeof value.signedDescriptor === \"string\" &&\n typeof value.keyId === \"string\" &&\n typeof value.keyUsage === \"string\"\n );\n }\n}\n"],
5
+ "mappings": "qtBAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,+BAAAE,IAAA,eAAAC,EAAAH,GAAA,IAAAI,EAAkB,oBAClBC,EAAuB,qBACvBC,EAAyC,qBAEzCC,EAA4B,mCAE5BC,EAGO,yCACPC,EAAoB,iCASb,IAAMC,EAAN,KAAiE,CACtE,YAC+CC,EAC7C,CAD6C,YAAAA,CAC5C,CAEH,MAAM,eAAe,CACnB,oBAAAC,EACA,QAAAC,EACA,UAAAC,CACF,EAAyE,CACvE,GAAI,CACF,MAAMC,EAAW,MAAM,EAAAC,QAAM,QAAwB,CACnD,OAAQ,MACR,IAAK,GAAG,KAAK,OAAO,sBAAsB,GAAG,gBAAgBH,CAAO,iBAAiBD,CAAmB,GACxG,OAAQ,CACN,UAAAE,CACF,EACA,QAAS,CACP,CAAC,8BAA4B,EAAG,kBAAkB,EAAAG,QAAQ,OAAO,GACjE,CAAC,4BAA0B,EAAG,KAAK,OAAO,WAC5C,CACF,CAAC,EAED,OAAKF,EAAS,KAQT,KAAK,iBAAiBA,EAAS,IAAI,KAQjC,SAAM,CACX,QAAS,CACP,iBAAkBA,EAAS,KAAK,kBAAkB,iBAClD,MAAOA,EAAS,KAAK,kBAAkB,MACvC,SAAUA,EAAS,KAAK,kBAAkB,QAC5C,EACA,QAAS,CACP,iBAAkBA,EAAS,KAAK,kBAAkB,iBAClD,MAAOA,EAAS,KAAK,kBAAkB,MACvC,SAAUA,EAAS,KAAK,kBAAkB,QAC5C,CACF,CAAC,KAlBQ,QACL,IAAI,MACF,iFACF,CACF,KAZO,QACL,IAAI,MACF,sEACF,CACF,CAuBJ,MAAiB,CACf,SAAO,QACL,IAAI,MACF,qFACF,CACF,CACF,CACF,CAEQ,iBAAiBG,EAAyC,CAChE,OACE,OAAOA,GAAU,UACjBA,IAAU,MACV,sBAAuBA,GACvB,sBAAuBA,GACvB,OAAOA,EAAM,mBAAsB,UACnC,OAAOA,EAAM,mBAAsB,UACnC,KAAK,oBAAoBA,EAAM,iBAAiB,GAChD,KAAK,oBAAoBA,EAAM,iBAAiB,CAEpD,CAEQ,oBAAoBA,EAA4C,CACtE,OACE,OAAOA,GAAU,UACjBA,IAAU,MACV,qBAAsBA,GACtB,UAAWA,GACX,aAAcA,GACd,OAAOA,EAAM,kBAAqB,UAClC,OAAOA,EAAM,OAAU,UACvB,OAAOA,EAAM,UAAa,QAE9B,CACF,EArFaR,EAANS,EAAA,CAEFC,EAAA,eAAO,cAAY,MAAM,IAFjBV",
6
+ "names": ["HttpSafeAccountDataSource_exports", "__export", "HttpSafeAccountDataSource", "__toCommonJS", "import_axios", "import_inversify", "import_purify_ts", "import_configTypes", "import_HttpHeaders", "import_package", "HttpSafeAccountDataSource", "config", "safeContractAddress", "chainId", "challenge", "response", "axios", "PACKAGE", "value", "__decorateClass", "__decorateParam"]
7
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";var g=Object.create;var d=Object.defineProperty;var f=Object.getOwnPropertyDescriptor;var m=Object.getOwnPropertyNames;var h=Object.getPrototypeOf,y=Object.prototype.hasOwnProperty;var D=(s,o,r,e)=>{if(o&&typeof o=="object"||typeof o=="function")for(let t of m(o))!y.call(s,t)&&t!==r&&d(s,t,{get:()=>o[t],enumerable:!(e=f(o,t))||e.enumerable});return s};var u=(s,o,r)=>(r=s!=null?g(h(s)):{},D(o||!s||!s.__esModule?d(r,"default",{value:s,enumerable:!0}):r,s));var a=u(require("axios")),n=require("purify-ts"),c=require("../../safe/data/HttpSafeAccountDataSource"),i=require("../../shared/constant/HttpHeaders"),l=u(require("../../../package.json"));vi.mock("axios");describe("HttpSafeAccountDataSource",()=>{const s={metadataServiceDomain:{url:"https://metadata.ledger.com"},originToken:"test-origin-token"},o={accountDescriptor:{signedDescriptor:"account-signed-descriptor-data",keyId:"account-key-id",keyUsage:"account-key-usage"},signersDescriptor:{signedDescriptor:"signers-signed-descriptor-data",keyId:"signers-key-id",keyUsage:"signers-key-usage"}},r="0x1234567890123456789012345678901234567890";beforeEach(()=>{vi.clearAllMocks()}),describe("getDescriptors",()=>{it("should return safe account descriptors on successful request",async()=>{const e={safeContractAddress:r,chainId:1,challenge:"0xabcdef"};vi.spyOn(a.default,"request").mockResolvedValue({status:200,data:o});const t=await new c.HttpSafeAccountDataSource(s).getDescriptors(e);expect(a.default.request).toHaveBeenCalledWith({method:"GET",url:"https://metadata.ledger.com/v2/ethereum/1/safe/account/0x1234567890123456789012345678901234567890",params:{challenge:"0xabcdef"},headers:{[i.LEDGER_CLIENT_VERSION_HEADER]:`context-module/${l.default.version}`,[i.LEDGER_ORIGIN_TOKEN_HEADER]:"test-origin-token"}}),expect(t).toEqual((0,n.Right)({account:{signedDescriptor:"account-signed-descriptor-data",keyId:"account-key-id",keyUsage:"account-key-usage"},signers:{signedDescriptor:"signers-signed-descriptor-data",keyId:"signers-key-id",keyUsage:"signers-key-usage"}}))}),it("should work with different chain IDs",async()=>{const e={safeContractAddress:r,chainId:137,challenge:"0xabcdef"};vi.spyOn(a.default,"request").mockResolvedValue({status:200,data:o}),await new c.HttpSafeAccountDataSource(s).getDescriptors(e),expect(a.default.request).toHaveBeenCalledWith(expect.objectContaining({url:"https://metadata.ledger.com/v2/ethereum/137/safe/account/0x1234567890123456789012345678901234567890"}))}),it("should work with different safe addresses",async()=>{const e={safeContractAddress:"0xabcdefabcdefabcdefabcdefabcdefabcdefabcd",chainId:1,challenge:"0xabcdef"};vi.spyOn(a.default,"request").mockResolvedValue({status:200,data:o}),await new c.HttpSafeAccountDataSource(s).getDescriptors(e),expect(a.default.request).toHaveBeenCalledWith(expect.objectContaining({url:"https://metadata.ledger.com/v2/ethereum/1/safe/account/0xabcdefabcdefabcdefabcdefabcdefabcdefabcd"}))}),it("should work with different challenges",async()=>{const e={safeContractAddress:r,chainId:1,challenge:"0x123456789"};vi.spyOn(a.default,"request").mockResolvedValue({status:200,data:o}),await new c.HttpSafeAccountDataSource(s).getDescriptors(e),expect(a.default.request).toHaveBeenCalledWith(expect.objectContaining({params:{challenge:"0x123456789"}}))}),it("should return error when response data is empty",async()=>{const e={safeContractAddress:r,chainId:1,challenge:"0xabcdef"};vi.spyOn(a.default,"request").mockResolvedValue({status:200,data:null});const t=await new c.HttpSafeAccountDataSource(s).getDescriptors(e);expect(t).toEqual((0,n.Left)(new Error("[ContextModule] HttpSafeAccountDataSource: unexpected empty response")))}),it("should return error when response data is undefined",async()=>{const e={safeContractAddress:r,chainId:1,challenge:"0xabcdef"};vi.spyOn(a.default,"request").mockResolvedValue({status:200,data:void 0});const t=await new c.HttpSafeAccountDataSource(s).getDescriptors(e);expect(t).toEqual((0,n.Left)(new Error("[ContextModule] HttpSafeAccountDataSource: unexpected empty response")))}),it("should return error when accountDescriptor is missing",async()=>{const e={safeContractAddress:r,chainId:1,challenge:"0xabcdef"};vi.spyOn(a.default,"request").mockResolvedValue({status:200,data:{signersDescriptor:o.signersDescriptor}});const t=await new c.HttpSafeAccountDataSource(s).getDescriptors(e);expect(t).toEqual((0,n.Left)(new Error("[ContextModule] HttpSafeAccountDataSource: invalid safe account response format")))}),it("should return error when signersDescriptor is missing",async()=>{const e={safeContractAddress:r,chainId:1,challenge:"0xabcdef"};vi.spyOn(a.default,"request").mockResolvedValue({status:200,data:{accountDescriptor:o.accountDescriptor}});const t=await new c.HttpSafeAccountDataSource(s).getDescriptors(e);expect(t).toEqual((0,n.Left)(new Error("[ContextModule] HttpSafeAccountDataSource: invalid safe account response format")))}),it("should return error when accountDescriptor.signedDescriptor is missing",async()=>{const e={safeContractAddress:r,chainId:1,challenge:"0xabcdef"};vi.spyOn(a.default,"request").mockResolvedValue({status:200,data:{accountDescriptor:{keyId:"account-key-id",keyUsage:"account-key-usage"},signersDescriptor:o.signersDescriptor}});const t=await new c.HttpSafeAccountDataSource(s).getDescriptors(e);expect(t).toEqual((0,n.Left)(new Error("[ContextModule] HttpSafeAccountDataSource: invalid safe account response format")))}),it("should return error when accountDescriptor.keyId is missing",async()=>{const e={safeContractAddress:r,chainId:1,challenge:"0xabcdef"};vi.spyOn(a.default,"request").mockResolvedValue({status:200,data:{accountDescriptor:{signedDescriptor:"account-signed-descriptor-data",keyUsage:"account-key-usage"},signersDescriptor:o.signersDescriptor}});const t=await new c.HttpSafeAccountDataSource(s).getDescriptors(e);expect(t).toEqual((0,n.Left)(new Error("[ContextModule] HttpSafeAccountDataSource: invalid safe account response format")))}),it("should return error when accountDescriptor.keyUsage is missing",async()=>{const e={safeContractAddress:r,chainId:1,challenge:"0xabcdef"};vi.spyOn(a.default,"request").mockResolvedValue({status:200,data:{accountDescriptor:{signedDescriptor:"account-signed-descriptor-data",keyId:"account-key-id"},signersDescriptor:o.signersDescriptor}});const t=await new c.HttpSafeAccountDataSource(s).getDescriptors(e);expect(t).toEqual((0,n.Left)(new Error("[ContextModule] HttpSafeAccountDataSource: invalid safe account response format")))}),it("should return error when signersDescriptor fields are invalid",async()=>{const e={safeContractAddress:r,chainId:1,challenge:"0xabcdef"};vi.spyOn(a.default,"request").mockResolvedValue({status:200,data:{accountDescriptor:o.accountDescriptor,signersDescriptor:{signedDescriptor:"signers-signed-descriptor-data",keyId:123,keyUsage:"signers-key-usage"}}});const t=await new c.HttpSafeAccountDataSource(s).getDescriptors(e);expect(t).toEqual((0,n.Left)(new Error("[ContextModule] HttpSafeAccountDataSource: invalid safe account response format")))}),it("should return error when accountDescriptor is not an object",async()=>{const e={safeContractAddress:r,chainId:1,challenge:"0xabcdef"};vi.spyOn(a.default,"request").mockResolvedValue({status:200,data:{accountDescriptor:"invalid-string",signersDescriptor:o.signersDescriptor}});const t=await new c.HttpSafeAccountDataSource(s).getDescriptors(e);expect(t).toEqual((0,n.Left)(new Error("[ContextModule] HttpSafeAccountDataSource: invalid safe account response format")))}),it("should return error when signersDescriptor is not an object",async()=>{const e={safeContractAddress:r,chainId:1,challenge:"0xabcdef"};vi.spyOn(a.default,"request").mockResolvedValue({status:200,data:{accountDescriptor:o.accountDescriptor,signersDescriptor:null}});const t=await new c.HttpSafeAccountDataSource(s).getDescriptors(e);expect(t).toEqual((0,n.Left)(new Error("[ContextModule] HttpSafeAccountDataSource: invalid safe account response format")))}),it("should return error when axios request fails",async()=>{const e={safeContractAddress:r,chainId:1,challenge:"0xabcdef"};vi.spyOn(a.default,"request").mockRejectedValue(new Error("Network error"));const t=await new c.HttpSafeAccountDataSource(s).getDescriptors(e);expect(t).toEqual((0,n.Left)(new Error("[ContextModule] HttpSafeAccountDataSource: Failed to fetch safe account descriptors")))}),it("should return error when axios throws an exception",async()=>{const e={safeContractAddress:r,chainId:1,challenge:"0xabcdef"};vi.spyOn(a.default,"request").mockRejectedValue(new Error("timeout"));const t=await new c.HttpSafeAccountDataSource(s).getDescriptors(e);expect(t).toEqual((0,n.Left)(new Error("[ContextModule] HttpSafeAccountDataSource: Failed to fetch safe account descriptors")))}),it("should handle empty string values in descriptors",async()=>{const e={safeContractAddress:r,chainId:1,challenge:"0xabcdef"};vi.spyOn(a.default,"request").mockResolvedValue({status:200,data:{accountDescriptor:{signedDescriptor:"",keyId:"",keyUsage:""},signersDescriptor:{signedDescriptor:"",keyId:"",keyUsage:""}}});const t=await new c.HttpSafeAccountDataSource(s).getDescriptors(e);expect(t).toEqual((0,n.Right)({account:{signedDescriptor:"",keyId:"",keyUsage:""},signers:{signedDescriptor:"",keyId:"",keyUsage:""}}))}),it("should correctly parse response with long descriptor values",async()=>{const e="a".repeat(1e3),t={safeContractAddress:r,chainId:1,challenge:"0xabcdef"};vi.spyOn(a.default,"request").mockResolvedValue({status:200,data:{accountDescriptor:{signedDescriptor:e,keyId:"account-key-id",keyUsage:"account-key-usage"},signersDescriptor:{signedDescriptor:e,keyId:"signers-key-id",keyUsage:"signers-key-usage"}}});const p=await new c.HttpSafeAccountDataSource(s).getDescriptors(t);expect(p).toEqual((0,n.Right)({account:{signedDescriptor:e,keyId:"account-key-id",keyUsage:"account-key-usage"},signers:{signedDescriptor:e,keyId:"signers-key-id",keyUsage:"signers-key-usage"}}))}),it("should use correct origin token from config",async()=>{const e={metadataServiceDomain:{url:"https://metadata.ledger.com"},originToken:"custom-origin-token"},t={safeContractAddress:r,chainId:1,challenge:"0xabcdef"};vi.spyOn(a.default,"request").mockResolvedValue({status:200,data:o}),await new c.HttpSafeAccountDataSource(e).getDescriptors(t),expect(a.default.request).toHaveBeenCalledWith(expect.objectContaining({headers:expect.objectContaining({[i.LEDGER_ORIGIN_TOKEN_HEADER]:"custom-origin-token"})}))}),it("should use correct metadata service URL from config",async()=>{const e={metadataServiceDomain:{url:"https://custom-metadata.example.com"},originToken:"test-token"},t={safeContractAddress:r,chainId:1,challenge:"0xabcdef"};vi.spyOn(a.default,"request").mockResolvedValue({status:200,data:o}),await new c.HttpSafeAccountDataSource(e).getDescriptors(t),expect(a.default.request).toHaveBeenCalledWith(expect.objectContaining({url:"https://custom-metadata.example.com/v2/ethereum/1/safe/account/0x1234567890123456789012345678901234567890"}))})})});
2
+ //# sourceMappingURL=HttpSafeAccountDataSource.test.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../../../src/safe/data/HttpSafeAccountDataSource.test.ts"],
4
+ "sourcesContent": ["import { type HexaString } from \"@ledgerhq/device-management-kit\";\nimport axios from \"axios\";\nimport { Left, Right } from \"purify-ts\";\n\nimport { type ContextModuleConfig } from \"@/config/model/ContextModuleConfig\";\nimport { HttpSafeAccountDataSource } from \"@/safe/data/HttpSafeAccountDataSource\";\nimport {\n LEDGER_CLIENT_VERSION_HEADER,\n LEDGER_ORIGIN_TOKEN_HEADER,\n} from \"@/shared/constant/HttpHeaders\";\nimport PACKAGE from \"@root/package.json\";\n\nvi.mock(\"axios\");\n\ndescribe(\"HttpSafeAccountDataSource\", () => {\n const config: ContextModuleConfig = {\n metadataServiceDomain: {\n url: \"https://metadata.ledger.com\",\n },\n originToken: \"test-origin-token\",\n } as ContextModuleConfig;\n\n const validSafeAccountDto = {\n accountDescriptor: {\n signedDescriptor: \"account-signed-descriptor-data\",\n keyId: \"account-key-id\",\n keyUsage: \"account-key-usage\",\n },\n signersDescriptor: {\n signedDescriptor: \"signers-signed-descriptor-data\",\n keyId: \"signers-key-id\",\n keyUsage: \"signers-key-usage\",\n },\n };\n\n const validsafeContractAddress: HexaString =\n \"0x1234567890123456789012345678901234567890\";\n\n beforeEach(() => {\n vi.clearAllMocks();\n });\n\n describe(\"getDescriptors\", () => {\n it(\"should return safe account descriptors on successful request\", async () => {\n // GIVEN\n const params = {\n safeContractAddress: validsafeContractAddress,\n chainId: 1,\n challenge: \"0xabcdef\",\n };\n vi.spyOn(axios, \"request\").mockResolvedValue({\n status: 200,\n data: validSafeAccountDto,\n });\n\n // WHEN\n const result = await new HttpSafeAccountDataSource(config).getDescriptors(\n params,\n );\n\n // THEN\n expect(axios.request).toHaveBeenCalledWith({\n method: \"GET\",\n url: \"https://metadata.ledger.com/v2/ethereum/1/safe/account/0x1234567890123456789012345678901234567890\",\n params: {\n challenge: \"0xabcdef\",\n },\n headers: {\n [LEDGER_CLIENT_VERSION_HEADER]: `context-module/${PACKAGE.version}`,\n [LEDGER_ORIGIN_TOKEN_HEADER]: \"test-origin-token\",\n },\n });\n expect(result).toEqual(\n Right({\n account: {\n signedDescriptor: \"account-signed-descriptor-data\",\n keyId: \"account-key-id\",\n keyUsage: \"account-key-usage\",\n },\n signers: {\n signedDescriptor: \"signers-signed-descriptor-data\",\n keyId: \"signers-key-id\",\n keyUsage: \"signers-key-usage\",\n },\n }),\n );\n });\n\n it(\"should work with different chain IDs\", async () => {\n // GIVEN\n const params = {\n safeContractAddress: validsafeContractAddress,\n chainId: 137, // Polygon\n challenge: \"0xabcdef\",\n };\n vi.spyOn(axios, \"request\").mockResolvedValue({\n status: 200,\n data: validSafeAccountDto,\n });\n\n // WHEN\n await new HttpSafeAccountDataSource(config).getDescriptors(params);\n\n // THEN\n expect(axios.request).toHaveBeenCalledWith(\n expect.objectContaining({\n url: \"https://metadata.ledger.com/v2/ethereum/137/safe/account/0x1234567890123456789012345678901234567890\",\n }),\n );\n });\n\n it(\"should work with different safe addresses\", async () => {\n // GIVEN\n const params = {\n safeContractAddress:\n \"0xabcdefabcdefabcdefabcdefabcdefabcdefabcd\" as HexaString,\n chainId: 1,\n challenge: \"0xabcdef\",\n };\n vi.spyOn(axios, \"request\").mockResolvedValue({\n status: 200,\n data: validSafeAccountDto,\n });\n\n // WHEN\n await new HttpSafeAccountDataSource(config).getDescriptors(params);\n\n // THEN\n expect(axios.request).toHaveBeenCalledWith(\n expect.objectContaining({\n url: \"https://metadata.ledger.com/v2/ethereum/1/safe/account/0xabcdefabcdefabcdefabcdefabcdefabcdefabcd\",\n }),\n );\n });\n\n it(\"should work with different challenges\", async () => {\n // GIVEN\n const params = {\n safeContractAddress: validsafeContractAddress,\n chainId: 1,\n challenge: \"0x123456789\",\n };\n vi.spyOn(axios, \"request\").mockResolvedValue({\n status: 200,\n data: validSafeAccountDto,\n });\n\n // WHEN\n await new HttpSafeAccountDataSource(config).getDescriptors(params);\n\n // THEN\n expect(axios.request).toHaveBeenCalledWith(\n expect.objectContaining({\n params: {\n challenge: \"0x123456789\",\n },\n }),\n );\n });\n\n it(\"should return error when response data is empty\", async () => {\n // GIVEN\n const params = {\n safeContractAddress: validsafeContractAddress,\n chainId: 1,\n challenge: \"0xabcdef\",\n };\n vi.spyOn(axios, \"request\").mockResolvedValue({\n status: 200,\n data: null,\n });\n\n // WHEN\n const result = await new HttpSafeAccountDataSource(config).getDescriptors(\n params,\n );\n\n // THEN\n expect(result).toEqual(\n Left(\n new Error(\n \"[ContextModule] HttpSafeAccountDataSource: unexpected empty response\",\n ),\n ),\n );\n });\n\n it(\"should return error when response data is undefined\", async () => {\n // GIVEN\n const params = {\n safeContractAddress: validsafeContractAddress,\n chainId: 1,\n challenge: \"0xabcdef\",\n };\n vi.spyOn(axios, \"request\").mockResolvedValue({\n status: 200,\n data: undefined,\n });\n\n // WHEN\n const result = await new HttpSafeAccountDataSource(config).getDescriptors(\n params,\n );\n\n // THEN\n expect(result).toEqual(\n Left(\n new Error(\n \"[ContextModule] HttpSafeAccountDataSource: unexpected empty response\",\n ),\n ),\n );\n });\n\n it(\"should return error when accountDescriptor is missing\", async () => {\n // GIVEN\n const params = {\n safeContractAddress: validsafeContractAddress,\n chainId: 1,\n challenge: \"0xabcdef\",\n };\n vi.spyOn(axios, \"request\").mockResolvedValue({\n status: 200,\n data: {\n signersDescriptor: validSafeAccountDto.signersDescriptor,\n },\n });\n\n // WHEN\n const result = await new HttpSafeAccountDataSource(config).getDescriptors(\n params,\n );\n\n // THEN\n expect(result).toEqual(\n Left(\n new Error(\n \"[ContextModule] HttpSafeAccountDataSource: invalid safe account response format\",\n ),\n ),\n );\n });\n\n it(\"should return error when signersDescriptor is missing\", async () => {\n // GIVEN\n const params = {\n safeContractAddress: validsafeContractAddress,\n chainId: 1,\n challenge: \"0xabcdef\",\n };\n vi.spyOn(axios, \"request\").mockResolvedValue({\n status: 200,\n data: {\n accountDescriptor: validSafeAccountDto.accountDescriptor,\n },\n });\n\n // WHEN\n const result = await new HttpSafeAccountDataSource(config).getDescriptors(\n params,\n );\n\n // THEN\n expect(result).toEqual(\n Left(\n new Error(\n \"[ContextModule] HttpSafeAccountDataSource: invalid safe account response format\",\n ),\n ),\n );\n });\n\n it(\"should return error when accountDescriptor.signedDescriptor is missing\", async () => {\n // GIVEN\n const params = {\n safeContractAddress: validsafeContractAddress,\n chainId: 1,\n challenge: \"0xabcdef\",\n };\n vi.spyOn(axios, \"request\").mockResolvedValue({\n status: 200,\n data: {\n accountDescriptor: {\n keyId: \"account-key-id\",\n keyUsage: \"account-key-usage\",\n },\n signersDescriptor: validSafeAccountDto.signersDescriptor,\n },\n });\n\n // WHEN\n const result = await new HttpSafeAccountDataSource(config).getDescriptors(\n params,\n );\n\n // THEN\n expect(result).toEqual(\n Left(\n new Error(\n \"[ContextModule] HttpSafeAccountDataSource: invalid safe account response format\",\n ),\n ),\n );\n });\n\n it(\"should return error when accountDescriptor.keyId is missing\", async () => {\n // GIVEN\n const params = {\n safeContractAddress: validsafeContractAddress,\n chainId: 1,\n challenge: \"0xabcdef\",\n };\n vi.spyOn(axios, \"request\").mockResolvedValue({\n status: 200,\n data: {\n accountDescriptor: {\n signedDescriptor: \"account-signed-descriptor-data\",\n keyUsage: \"account-key-usage\",\n },\n signersDescriptor: validSafeAccountDto.signersDescriptor,\n },\n });\n\n // WHEN\n const result = await new HttpSafeAccountDataSource(config).getDescriptors(\n params,\n );\n\n // THEN\n expect(result).toEqual(\n Left(\n new Error(\n \"[ContextModule] HttpSafeAccountDataSource: invalid safe account response format\",\n ),\n ),\n );\n });\n\n it(\"should return error when accountDescriptor.keyUsage is missing\", async () => {\n // GIVEN\n const params = {\n safeContractAddress: validsafeContractAddress,\n chainId: 1,\n challenge: \"0xabcdef\",\n };\n vi.spyOn(axios, \"request\").mockResolvedValue({\n status: 200,\n data: {\n accountDescriptor: {\n signedDescriptor: \"account-signed-descriptor-data\",\n keyId: \"account-key-id\",\n },\n signersDescriptor: validSafeAccountDto.signersDescriptor,\n },\n });\n\n // WHEN\n const result = await new HttpSafeAccountDataSource(config).getDescriptors(\n params,\n );\n\n // THEN\n expect(result).toEqual(\n Left(\n new Error(\n \"[ContextModule] HttpSafeAccountDataSource: invalid safe account response format\",\n ),\n ),\n );\n });\n\n it(\"should return error when signersDescriptor fields are invalid\", async () => {\n // GIVEN\n const params = {\n safeContractAddress: validsafeContractAddress,\n chainId: 1,\n challenge: \"0xabcdef\",\n };\n vi.spyOn(axios, \"request\").mockResolvedValue({\n status: 200,\n data: {\n accountDescriptor: validSafeAccountDto.accountDescriptor,\n signersDescriptor: {\n signedDescriptor: \"signers-signed-descriptor-data\",\n keyId: 123, // wrong type\n keyUsage: \"signers-key-usage\",\n },\n },\n });\n\n // WHEN\n const result = await new HttpSafeAccountDataSource(config).getDescriptors(\n params,\n );\n\n // THEN\n expect(result).toEqual(\n Left(\n new Error(\n \"[ContextModule] HttpSafeAccountDataSource: invalid safe account response format\",\n ),\n ),\n );\n });\n\n it(\"should return error when accountDescriptor is not an object\", async () => {\n // GIVEN\n const params = {\n safeContractAddress: validsafeContractAddress,\n chainId: 1,\n challenge: \"0xabcdef\",\n };\n vi.spyOn(axios, \"request\").mockResolvedValue({\n status: 200,\n data: {\n accountDescriptor: \"invalid-string\",\n signersDescriptor: validSafeAccountDto.signersDescriptor,\n },\n });\n\n // WHEN\n const result = await new HttpSafeAccountDataSource(config).getDescriptors(\n params,\n );\n\n // THEN\n expect(result).toEqual(\n Left(\n new Error(\n \"[ContextModule] HttpSafeAccountDataSource: invalid safe account response format\",\n ),\n ),\n );\n });\n\n it(\"should return error when signersDescriptor is not an object\", async () => {\n // GIVEN\n const params = {\n safeContractAddress: validsafeContractAddress,\n chainId: 1,\n challenge: \"0xabcdef\",\n };\n vi.spyOn(axios, \"request\").mockResolvedValue({\n status: 200,\n data: {\n accountDescriptor: validSafeAccountDto.accountDescriptor,\n signersDescriptor: null,\n },\n });\n\n // WHEN\n const result = await new HttpSafeAccountDataSource(config).getDescriptors(\n params,\n );\n\n // THEN\n expect(result).toEqual(\n Left(\n new Error(\n \"[ContextModule] HttpSafeAccountDataSource: invalid safe account response format\",\n ),\n ),\n );\n });\n\n it(\"should return error when axios request fails\", async () => {\n // GIVEN\n const params = {\n safeContractAddress: validsafeContractAddress,\n chainId: 1,\n challenge: \"0xabcdef\",\n };\n vi.spyOn(axios, \"request\").mockRejectedValue(new Error(\"Network error\"));\n\n // WHEN\n const result = await new HttpSafeAccountDataSource(config).getDescriptors(\n params,\n );\n\n // THEN\n expect(result).toEqual(\n Left(\n new Error(\n \"[ContextModule] HttpSafeAccountDataSource: Failed to fetch safe account descriptors\",\n ),\n ),\n );\n });\n\n it(\"should return error when axios throws an exception\", async () => {\n // GIVEN\n const params = {\n safeContractAddress: validsafeContractAddress,\n chainId: 1,\n challenge: \"0xabcdef\",\n };\n vi.spyOn(axios, \"request\").mockRejectedValue(new Error(\"timeout\"));\n\n // WHEN\n const result = await new HttpSafeAccountDataSource(config).getDescriptors(\n params,\n );\n\n // THEN\n expect(result).toEqual(\n Left(\n new Error(\n \"[ContextModule] HttpSafeAccountDataSource: Failed to fetch safe account descriptors\",\n ),\n ),\n );\n });\n\n it(\"should handle empty string values in descriptors\", async () => {\n // GIVEN\n const params = {\n safeContractAddress: validsafeContractAddress,\n chainId: 1,\n challenge: \"0xabcdef\",\n };\n vi.spyOn(axios, \"request\").mockResolvedValue({\n status: 200,\n data: {\n accountDescriptor: {\n signedDescriptor: \"\",\n keyId: \"\",\n keyUsage: \"\",\n },\n signersDescriptor: {\n signedDescriptor: \"\",\n keyId: \"\",\n keyUsage: \"\",\n },\n },\n });\n\n // WHEN\n const result = await new HttpSafeAccountDataSource(config).getDescriptors(\n params,\n );\n\n // THEN\n expect(result).toEqual(\n Right({\n account: {\n signedDescriptor: \"\",\n keyId: \"\",\n keyUsage: \"\",\n },\n signers: {\n signedDescriptor: \"\",\n keyId: \"\",\n keyUsage: \"\",\n },\n }),\n );\n });\n\n it(\"should correctly parse response with long descriptor values\", async () => {\n // GIVEN\n const longValue = \"a\".repeat(1000);\n const params = {\n safeContractAddress: validsafeContractAddress,\n chainId: 1,\n challenge: \"0xabcdef\",\n };\n vi.spyOn(axios, \"request\").mockResolvedValue({\n status: 200,\n data: {\n accountDescriptor: {\n signedDescriptor: longValue,\n keyId: \"account-key-id\",\n keyUsage: \"account-key-usage\",\n },\n signersDescriptor: {\n signedDescriptor: longValue,\n keyId: \"signers-key-id\",\n keyUsage: \"signers-key-usage\",\n },\n },\n });\n\n // WHEN\n const result = await new HttpSafeAccountDataSource(config).getDescriptors(\n params,\n );\n\n // THEN\n expect(result).toEqual(\n Right({\n account: {\n signedDescriptor: longValue,\n keyId: \"account-key-id\",\n keyUsage: \"account-key-usage\",\n },\n signers: {\n signedDescriptor: longValue,\n keyId: \"signers-key-id\",\n keyUsage: \"signers-key-usage\",\n },\n }),\n );\n });\n\n it(\"should use correct origin token from config\", async () => {\n // GIVEN\n const customConfig: ContextModuleConfig = {\n metadataServiceDomain: {\n url: \"https://metadata.ledger.com\",\n },\n originToken: \"custom-origin-token\",\n } as ContextModuleConfig;\n const params = {\n safeContractAddress: validsafeContractAddress,\n chainId: 1,\n challenge: \"0xabcdef\",\n };\n vi.spyOn(axios, \"request\").mockResolvedValue({\n status: 200,\n data: validSafeAccountDto,\n });\n\n // WHEN\n await new HttpSafeAccountDataSource(customConfig).getDescriptors(params);\n\n // THEN\n expect(axios.request).toHaveBeenCalledWith(\n expect.objectContaining({\n headers: expect.objectContaining({\n [LEDGER_ORIGIN_TOKEN_HEADER]: \"custom-origin-token\",\n }),\n }),\n );\n });\n\n it(\"should use correct metadata service URL from config\", async () => {\n // GIVEN\n const customConfig: ContextModuleConfig = {\n metadataServiceDomain: {\n url: \"https://custom-metadata.example.com\",\n },\n originToken: \"test-token\",\n } as ContextModuleConfig;\n const params = {\n safeContractAddress: validsafeContractAddress,\n chainId: 1,\n challenge: \"0xabcdef\",\n };\n vi.spyOn(axios, \"request\").mockResolvedValue({\n status: 200,\n data: validSafeAccountDto,\n });\n\n // WHEN\n await new HttpSafeAccountDataSource(customConfig).getDescriptors(params);\n\n // THEN\n expect(axios.request).toHaveBeenCalledWith(\n expect.objectContaining({\n url: \"https://custom-metadata.example.com/v2/ethereum/1/safe/account/0x1234567890123456789012345678901234567890\",\n }),\n );\n });\n });\n});\n"],
5
+ "mappings": "wdACA,IAAAA,EAAkB,oBAClBC,EAA4B,qBAG5BC,EAA0C,iDAC1CC,EAGO,yCACPC,EAAoB,iCAEpB,GAAG,KAAK,OAAO,EAEf,SAAS,4BAA6B,IAAM,CAC1C,MAAMC,EAA8B,CAClC,sBAAuB,CACrB,IAAK,6BACP,EACA,YAAa,mBACf,EAEMC,EAAsB,CAC1B,kBAAmB,CACjB,iBAAkB,iCAClB,MAAO,iBACP,SAAU,mBACZ,EACA,kBAAmB,CACjB,iBAAkB,iCAClB,MAAO,iBACP,SAAU,mBACZ,CACF,EAEMC,EACJ,6CAEF,WAAW,IAAM,CACf,GAAG,cAAc,CACnB,CAAC,EAED,SAAS,iBAAkB,IAAM,CAC/B,GAAG,+DAAgE,SAAY,CAE7E,MAAMC,EAAS,CACb,oBAAqBD,EACrB,QAAS,EACT,UAAW,UACb,EACA,GAAG,MAAM,EAAAE,QAAO,SAAS,EAAE,kBAAkB,CAC3C,OAAQ,IACR,KAAMH,CACR,CAAC,EAGD,MAAMI,EAAS,MAAM,IAAI,4BAA0BL,CAAM,EAAE,eACzDG,CACF,EAGA,OAAO,EAAAC,QAAM,OAAO,EAAE,qBAAqB,CACzC,OAAQ,MACR,IAAK,oGACL,OAAQ,CACN,UAAW,UACb,EACA,QAAS,CACP,CAAC,8BAA4B,EAAG,kBAAkB,EAAAE,QAAQ,OAAO,GACjE,CAAC,4BAA0B,EAAG,mBAChC,CACF,CAAC,EACD,OAAOD,CAAM,EAAE,WACb,SA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SAAU,mBACZ,CACF,CACF,CAAC,EAGD,MAAMF,EAAS,MAAM,IAAI,4BAA0BL,CAAM,EAAE,eACzDG,CACF,EAGA,OAAOE,CAAM,EAAE,WACb,SAAM,CACJ,QAAS,CACP,iBAAkBE,EAClB,MAAO,iBACP,SAAU,mBACZ,EACA,QAAS,CACP,iBAAkBA,EAClB,MAAO,iBACP,SAAU,mBACZ,CACF,CAAC,CACH,CACF,CAAC,EAED,GAAG,8CAA+C,SAAY,CAE5D,MAAMC,EAAoC,CACxC,sBAAuB,CACrB,IAAK,6BACP,EACA,YAAa,qBACf,EACML,EAAS,CACb,oBAAqBD,EACrB,QAAS,EACT,UAAW,UACb,EACA,GAAG,MAAM,EAAAE,QAAO,SAAS,EAAE,kBAAkB,CAC3C,OAAQ,IACR,KAAMH,CACR,CAAC,EAGD,MAAM,IAAI,4BAA0BO,CAAY,EAAE,eAAeL,CAAM,EAGvE,OAAO,EAAAC,QAAM,OAAO,EAAE,qBACpB,OAAO,iBAAiB,CACtB,QAAS,OAAO,iBAAiB,CAC/B,CAAC,4BAA0B,EAAG,qBAChC,CAAC,CACH,CAAC,CACH,CACF,CAAC,EAED,GAAG,sDAAuD,SAAY,CAEpE,MAAMI,EAAoC,CACxC,sBAAuB,CACrB,IAAK,qCACP,EACA,YAAa,YACf,EACML,EAAS,CACb,oBAAqBD,EACrB,QAAS,EACT,UAAW,UACb,EACA,GAAG,MAAM,EAAAE,QAAO,SAAS,EAAE,kBAAkB,CAC3C,OAAQ,IACR,KAAMH,CACR,CAAC,EAGD,MAAM,IAAI,4BAA0BO,CAAY,EAAE,eAAeL,CAAM,EAGvE,OAAO,EAAAC,QAAM,OAAO,EAAE,qBACpB,OAAO,iBAAiB,CACtB,IAAK,2GACP,CAAC,CACH,CACF,CAAC,CACH,CAAC,CACH,CAAC",
6
+ "names": ["import_axios", "import_purify_ts", "import_HttpSafeAccountDataSource", "import_HttpHeaders", "import_package", "config", "validSafeAccountDto", "validsafeContractAddress", "params", "axios", "result", "PACKAGE", "longValue", "customConfig"]
7
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";var o=Object.defineProperty;var c=Object.getOwnPropertyDescriptor;var n=Object.getOwnPropertyNames;var i=Object.prototype.hasOwnProperty;var p=(r,e,s,a)=>{if(e&&typeof e=="object"||typeof e=="function")for(let t of n(e))!i.call(r,t)&&t!==s&&o(r,t,{get:()=>e[t],enumerable:!(a=c(e,t))||a.enumerable});return r};var f=r=>p(o({},"__esModule",{value:!0}),r);var g={};module.exports=f(g);
2
+ //# sourceMappingURL=SafeAccountDataSource.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../../../src/safe/data/SafeAccountDataSource.ts"],
4
+ "sourcesContent": ["import { type HexaString } from \"@ledgerhq/device-management-kit\";\nimport { type Either } from \"purify-ts\";\n\nexport type GetSafeAccountParams = {\n safeContractAddress: HexaString;\n chainId: number;\n challenge: string;\n};\n\nexport type SafeDescriptor = {\n signedDescriptor: string;\n keyId: string;\n keyUsage: string;\n};\n\nexport type GetSafeAccountResponse = {\n account: SafeDescriptor;\n signers: SafeDescriptor;\n};\n\nexport interface SafeAccountDataSource {\n getDescriptors(\n params: GetSafeAccountParams,\n ): Promise<Either<Error, GetSafeAccountResponse>>;\n}\n"],
5
+ "mappings": "+WAAA,IAAAA,EAAA,kBAAAC,EAAAD",
6
+ "names": ["SafeAccountDataSource_exports", "__toCommonJS"]
7
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";var s=Object.defineProperty;var c=Object.getOwnPropertyDescriptor;var p=Object.getOwnPropertyNames;var D=Object.prototype.hasOwnProperty;var n=(t,e,i,o)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of p(e))!D.call(t,r)&&r!==i&&s(t,r,{get:()=>e[r],enumerable:!(o=c(e,r))||o.enumerable});return t};var a=t=>n(s({},"__esModule",{value:!0}),t);var g={};module.exports=a(g);
2
+ //# sourceMappingURL=SafeAccountDto.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../../../../src/safe/data/dto/SafeAccountDto.ts"],
4
+ "sourcesContent": ["export type SafeAccountDto = {\n accountDescriptor: SafeDescriptorDto;\n signersDescriptor: SafeDescriptorDto;\n};\n\nexport type SafeDescriptorDto = {\n signedDescriptor: string;\n keyId: string;\n keyUsage: string;\n};\n"],
5
+ "mappings": "+WAAA,IAAAA,EAAA,kBAAAC,EAAAD",
6
+ "names": ["SafeAccountDto_exports", "__toCommonJS"]
7
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";var a=Object.defineProperty;var c=Object.getOwnPropertyDescriptor;var S=Object.getOwnPropertyNames;var u=Object.prototype.hasOwnProperty;var i=(o,e)=>{for(var t in e)a(o,t,{get:e[t],enumerable:!0})},n=(o,e,t,s)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of S(e))!u.call(o,r)&&r!==t&&a(o,r,{get:()=>e[r],enumerable:!(s=c(e,r))||s.enumerable});return o};var A=o=>n(a({},"__esModule",{value:!0}),o);var y={};i(y,{safeModuleFactory:()=>l});module.exports=A(y);var d=require("inversify"),m=require("../../safe/data/HttpSafeAccountDataSource"),p=require("../../safe/domain/SafeAddressLoader"),f=require("./safeTypes");const l=()=>new d.ContainerModule(({bind:o})=>{o(f.safeTypes.SafeAddressDataSource).to(m.HttpSafeAccountDataSource),o(f.safeTypes.SafeAddressLoader).to(p.SafeAddressLoader)});0&&(module.exports={safeModuleFactory});
2
+ //# sourceMappingURL=safeModuleFactory.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../../../src/safe/di/safeModuleFactory.ts"],
4
+ "sourcesContent": ["import { ContainerModule } from \"inversify\";\n\nimport { HttpSafeAccountDataSource } from \"@/safe/data/HttpSafeAccountDataSource\";\nimport { SafeAddressLoader } from \"@/safe/domain/SafeAddressLoader\";\n\nimport { safeTypes } from \"./safeTypes\";\n\nexport const safeModuleFactory = () =>\n new ContainerModule(({ bind }) => {\n bind(safeTypes.SafeAddressDataSource).to(HttpSafeAccountDataSource);\n bind(safeTypes.SafeAddressLoader).to(SafeAddressLoader);\n });\n"],
5
+ "mappings": "yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,uBAAAE,IAAA,eAAAC,EAAAH,GAAA,IAAAI,EAAgC,qBAEhCC,EAA0C,iDAC1CC,EAAkC,2CAElCC,EAA0B,uBAEnB,MAAML,EAAoB,IAC/B,IAAI,kBAAgB,CAAC,CAAE,KAAAM,CAAK,IAAM,CAChCA,EAAK,YAAU,qBAAqB,EAAE,GAAG,2BAAyB,EAClEA,EAAK,YAAU,iBAAiB,EAAE,GAAG,mBAAiB,CACxD,CAAC",
6
+ "names": ["safeModuleFactory_exports", "__export", "safeModuleFactory", "__toCommonJS", "import_inversify", "import_HttpSafeAccountDataSource", "import_SafeAddressLoader", "import_safeTypes", "bind"]
7
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";var e=require("vitest"),o=require("./safeModuleFactory");(0,e.describe)("safeModuleFactory",()=>{(0,e.it)("should be defined",()=>{expect(o.safeModuleFactory).toBeDefined()})});
2
+ //# sourceMappingURL=safeModuleFactory.test.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../../../src/safe/di/safeModuleFactory.test.ts"],
4
+ "sourcesContent": ["import { describe, it } from \"vitest\";\n\nimport { safeModuleFactory } from \"./safeModuleFactory\";\n\ndescribe(\"safeModuleFactory\", () => {\n it(\"should be defined\", () => {\n expect(safeModuleFactory).toBeDefined();\n });\n});\n"],
5
+ "mappings": "aAAA,IAAAA,EAA6B,kBAE7BC,EAAkC,kCAElC,YAAS,oBAAqB,IAAM,IAClC,MAAG,oBAAqB,IAAM,CAC5B,OAAO,mBAAiB,EAAE,YAAY,CACxC,CAAC,CACH,CAAC",
6
+ "names": ["import_vitest", "import_safeModuleFactory"]
7
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";var d=Object.defineProperty;var S=Object.getOwnPropertyDescriptor;var f=Object.getOwnPropertyNames;var t=Object.prototype.hasOwnProperty;var A=(a,e)=>{for(var s in e)d(a,s,{get:e[s],enumerable:!0})},c=(a,e,s,o)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of f(e))!t.call(a,r)&&r!==s&&d(a,r,{get:()=>e[r],enumerable:!(o=S(e,r))||o.enumerable});return a};var y=a=>c(d({},"__esModule",{value:!0}),a);var l={};A(l,{safeTypes:()=>b});module.exports=y(l);const b={SafeAddressDataSource:Symbol.for("SafeAddressDataSource"),SafeAddressLoader:Symbol.for("SafeAddressLoader")};0&&(module.exports={safeTypes});
2
+ //# sourceMappingURL=safeTypes.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../../../src/safe/di/safeTypes.ts"],
4
+ "sourcesContent": ["export const safeTypes = {\n SafeAddressDataSource: Symbol.for(\"SafeAddressDataSource\"),\n SafeAddressLoader: Symbol.for(\"SafeAddressLoader\"),\n};\n"],
5
+ "mappings": "yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,eAAAE,IAAA,eAAAC,EAAAH,GAAO,MAAME,EAAY,CACvB,sBAAuB,OAAO,IAAI,uBAAuB,EACzD,kBAAmB,OAAO,IAAI,mBAAmB,CACnD",
6
+ "names": ["safeTypes_exports", "__export", "safeTypes", "__toCommonJS"]
7
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";var f=Object.defineProperty;var y=Object.getOwnPropertyDescriptor;var x=Object.getOwnPropertyNames;var I=Object.prototype.hasOwnProperty;var k=(o,e)=>{for(var t in e)f(o,t,{get:e[t],enumerable:!0})},A=(o,e,t,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let a of x(e))!I.call(o,a)&&a!==t&&f(o,a,{get:()=>e[a],enumerable:!(r=y(e,a))||r.enumerable});return o};var h=o=>A(f({},"__esModule",{value:!0}),o),C=(o,e,t,r)=>{for(var a=r>1?void 0:r?y(e,t):e,d=o.length-1,i;d>=0;d--)(i=o[d])&&(a=(r?i(e,t,a):i(a))||a);return r&&a&&f(e,t,a),a},p=(o,e)=>(t,r)=>e(t,r,o);var D={};k(D,{SafeAddressLoader:()=>c});module.exports=h(D);var S=require("@ledgerhq/device-management-kit"),s=require("inversify"),g=require("../../pki/di/pkiTypes"),m=require("../../safe/di/safeTypes"),n=require("../../shared/model/ClearSignContext");const u=[n.ClearSignContextType.SAFE,n.ClearSignContextType.SIGNER];let c=class{constructor(e,t){this._dataSource=e;this._certificateLoader=t}canHandle(e,t){return t.every(r=>u.includes(r))&&typeof e=="object"&&e!==null&&"safeContractAddress"in e&&(0,S.isHexaString)(e.safeContractAddress)&&e.safeContractAddress!=="0x"&&"chainId"in e&&typeof e.chainId=="number"&&"deviceModelId"in e&&e.deviceModelId!==void 0&&"challenge"in e&&typeof e.challenge=="string"&&e.challenge.length>0}async load({safeContractAddress:e,chainId:t,deviceModelId:r,challenge:a}){return(await this._dataSource.getDescriptors({safeContractAddress:e,chainId:t,challenge:a})).caseOf({Left:i=>Promise.resolve([{type:n.ClearSignContextType.ERROR,error:i}]),Right:async({account:i,signers:l})=>[{type:n.ClearSignContextType.SAFE,payload:i.signedDescriptor,certificate:await this._certificateLoader.loadCertificate({keyId:i.keyId,keyUsage:i.keyUsage,targetDevice:r})},{type:n.ClearSignContextType.SIGNER,payload:l.signedDescriptor,certificate:await this._certificateLoader.loadCertificate({keyId:l.keyId,keyUsage:l.keyUsage,targetDevice:r})}]})}};c=C([(0,s.injectable)(),p(0,(0,s.inject)(m.safeTypes.SafeAddressDataSource)),p(1,(0,s.inject)(g.pkiTypes.PkiCertificateLoader))],c);0&&(module.exports={SafeAddressLoader});
2
+ //# sourceMappingURL=SafeAddressLoader.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../../../src/safe/domain/SafeAddressLoader.ts"],
4
+ "sourcesContent": ["import {\n DeviceModelId,\n HexaString,\n isHexaString,\n} 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 {\n GetSafeAccountResponse,\n SafeAccountDataSource,\n} from \"@/safe/data/SafeAccountDataSource\";\nimport { safeTypes } from \"@/safe/di/safeTypes\";\nimport { ContextLoader } from \"@/shared/domain/ContextLoader\";\nimport {\n ClearSignContext,\n ClearSignContextType,\n} from \"@/shared/model/ClearSignContext\";\n\nexport type SafeAddressContextInput = {\n safeContractAddress: HexaString;\n chainId: number;\n deviceModelId: DeviceModelId;\n challenge: string;\n};\n\nconst SUPPORTED_TYPES: ClearSignContextType[] = [\n ClearSignContextType.SAFE,\n ClearSignContextType.SIGNER,\n];\n\n@injectable()\nexport class SafeAddressLoader\n implements ContextLoader<SafeAddressContextInput>\n{\n constructor(\n @inject(safeTypes.SafeAddressDataSource)\n private readonly _dataSource: SafeAccountDataSource,\n @inject(pkiTypes.PkiCertificateLoader)\n private readonly _certificateLoader: PkiCertificateLoader,\n ) {}\n\n canHandle(\n input: unknown,\n expectedTypes: ClearSignContextType[],\n ): input is SafeAddressContextInput {\n return (\n expectedTypes.every((type) => SUPPORTED_TYPES.includes(type)) &&\n typeof input === \"object\" &&\n input !== null &&\n \"safeContractAddress\" in input &&\n isHexaString(input.safeContractAddress) &&\n input.safeContractAddress !== \"0x\" &&\n \"chainId\" in input &&\n typeof input.chainId === \"number\" &&\n \"deviceModelId\" in input &&\n input.deviceModelId !== undefined &&\n \"challenge\" in input &&\n typeof input.challenge === \"string\" &&\n input.challenge.length > 0\n );\n }\n\n async load({\n safeContractAddress,\n chainId,\n deviceModelId,\n challenge,\n }: SafeAddressContextInput): Promise<ClearSignContext[]> {\n const descriptors = await this._dataSource.getDescriptors({\n safeContractAddress,\n chainId,\n challenge,\n });\n\n return descriptors.caseOf({\n Left: (error): Promise<ClearSignContext[]> =>\n Promise.resolve([\n {\n type: ClearSignContextType.ERROR,\n error,\n },\n ]),\n Right: async ({\n account,\n signers,\n }: GetSafeAccountResponse): Promise<ClearSignContext[]> => [\n {\n type: ClearSignContextType.SAFE,\n payload: account.signedDescriptor,\n certificate: await this._certificateLoader.loadCertificate({\n keyId: account.keyId,\n keyUsage: account.keyUsage,\n targetDevice: deviceModelId,\n }),\n },\n {\n type: ClearSignContextType.SIGNER,\n payload: signers.signedDescriptor,\n certificate: await this._certificateLoader.loadCertificate({\n keyId: signers.keyId,\n keyUsage: signers.keyUsage,\n targetDevice: deviceModelId,\n }),\n },\n ],\n });\n }\n}\n"],
5
+ "mappings": "okBAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,uBAAAE,IAAA,eAAAC,EAAAH,GAAA,IAAAI,EAIO,2CACPC,EAAmC,qBAEnCC,EAAyB,6BAMzBC,EAA0B,+BAE1BC,EAGO,2CASP,MAAMC,EAA0C,CAC9C,uBAAqB,KACrB,uBAAqB,MACvB,EAGO,IAAMC,EAAN,KAEP,CACE,YAEmBC,EAEAC,EACjB,CAHiB,iBAAAD,EAEA,wBAAAC,CAChB,CAEH,UACEC,EACAC,EACkC,CAClC,OACEA,EAAc,MAAOC,GAASN,EAAgB,SAASM,CAAI,CAAC,GAC5D,OAAOF,GAAU,UACjBA,IAAU,MACV,wBAAyBA,MACzB,gBAAaA,EAAM,mBAAmB,GACtCA,EAAM,sBAAwB,MAC9B,YAAaA,GACb,OAAOA,EAAM,SAAY,UACzB,kBAAmBA,GACnBA,EAAM,gBAAkB,QACxB,cAAeA,GACf,OAAOA,EAAM,WAAc,UAC3BA,EAAM,UAAU,OAAS,CAE7B,CAEA,MAAM,KAAK,CACT,oBAAAG,EACA,QAAAC,EACA,cAAAC,EACA,UAAAC,CACF,EAAyD,CAOvD,OANoB,MAAM,KAAK,YAAY,eAAe,CACxD,oBAAAH,EACA,QAAAC,EACA,UAAAE,CACF,CAAC,GAEkB,OAAO,CACxB,KAAOC,GACL,QAAQ,QAAQ,CACd,CACE,KAAM,uBAAqB,MAC3B,MAAAA,CACF,CACF,CAAC,EACH,MAAO,MAAO,CACZ,QAAAC,EACA,QAAAC,CACF,IAA2D,CACzD,CACE,KAAM,uBAAqB,KAC3B,QAASD,EAAQ,iBACjB,YAAa,MAAM,KAAK,mBAAmB,gBAAgB,CACzD,MAAOA,EAAQ,MACf,SAAUA,EAAQ,SAClB,aAAcH,CAChB,CAAC,CACH,EACA,CACE,KAAM,uBAAqB,OAC3B,QAASI,EAAQ,iBACjB,YAAa,MAAM,KAAK,mBAAmB,gBAAgB,CACzD,MAAOA,EAAQ,MACf,SAAUA,EAAQ,SAClB,aAAcJ,CAChB,CAAC,CACH,CACF,CACF,CAAC,CACH,CACF,EA5EaR,EAANa,EAAA,IADN,cAAW,EAKPC,EAAA,eAAO,YAAU,qBAAqB,GAEtCA,EAAA,eAAO,WAAS,oBAAoB,IAN5Bd",
6
+ "names": ["SafeAddressLoader_exports", "__export", "SafeAddressLoader", "__toCommonJS", "import_device_management_kit", "import_inversify", "import_pkiTypes", "import_safeTypes", "import_ClearSignContext", "SUPPORTED_TYPES", "SafeAddressLoader", "_dataSource", "_certificateLoader", "input", "expectedTypes", "type", "safeContractAddress", "chainId", "deviceModelId", "challenge", "error", "account", "signers", "__decorateClass", "__decorateParam"]
7
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";var o=require("@ledgerhq/device-management-kit"),d=require("purify-ts"),u=require("../../safe/domain/SafeAddressLoader"),e=require("../../shared/model/ClearSignContext");describe("SafeAddressLoader",()=>{const n={getDescriptors:vi.fn()},r={loadCertificate:vi.fn()},s=new u.SafeAddressLoader(n,r),l={keyUsageNumber:1,payload:new Uint8Array([1,2,3])},i={account:{signedDescriptor:"safe-descriptor-payload",keyId:"safe-key-id",keyUsage:"safe-key-usage"},signers:{signedDescriptor:"signers-descriptor-payload",keyId:"signers-key-id",keyUsage:"signers-key-usage"}};beforeEach(()=>{vi.clearAllMocks(),vi.spyOn(r,"loadCertificate").mockResolvedValue(l)}),describe("canHandle function",()=>{const t={safeContractAddress:"0x1234567890123456789012345678901234567890",chainId:1,deviceModelId:o.DeviceModelId.FLEX,challenge:"0xabcdef"};it("should return true for valid input with SAFE and SIGNER types",()=>{expect(s.canHandle(t,[e.ClearSignContextType.SAFE,e.ClearSignContextType.SIGNER])).toBe(!0)}),it("should return true when expected types are subset of SAFE and SIGNER",()=>{expect(s.canHandle(t,[e.ClearSignContextType.SAFE])).toBe(!0),expect(s.canHandle(t,[e.ClearSignContextType.SIGNER])).toBe(!0)}),it("should return false when expected types include unsupported types",()=>{expect(s.canHandle(t,[e.ClearSignContextType.TOKEN])).toBe(!1),expect(s.canHandle(t,[e.ClearSignContextType.NFT])).toBe(!1)}),it("should return false when expected types include other types besides SAFE and SIGNER",()=>{expect(s.canHandle(t,[e.ClearSignContextType.SAFE,e.ClearSignContextType.SIGNER,e.ClearSignContextType.TOKEN])).toBe(!1)}),it.each([[null,"null input"],[void 0,"undefined input"],[{},"empty object"],["string","string input"],[123,"number input"],[[],"array input"]])("should return false for %s",(a,c)=>{expect(s.canHandle(a,[e.ClearSignContextType.SAFE,e.ClearSignContextType.SIGNER])).toBe(!1)}),it.each([[{...t,safeContractAddress:void 0},"missing safeContractAddress"],[{...t,chainId:void 0},"missing chainId"],[{...t,deviceModelId:void 0},"missing deviceModelId"],[{...t,challenge:void 0},"missing challenge"]])("should return false for %s",(a,c)=>{expect(s.canHandle(a,[e.ClearSignContextType.SAFE,e.ClearSignContextType.SIGNER])).toBe(!1)}),it.each([[{...t,safeContractAddress:"invalid-hex"},"invalid safeContractAddress hex"],[{...t,safeContractAddress:"0x"},"empty safeContractAddress (0x)"],[{...t,safeContractAddress:"not-hex"},"non-hex safeContractAddress"],[{...t,safeContractAddress:123},"number safeContractAddress"]])("should return false for %s",(a,c)=>{expect(s.canHandle(a,[e.ClearSignContextType.SAFE,e.ClearSignContextType.SIGNER])).toBe(!1)}),it.each([[{...t,chainId:"1"},"string chainId"],[{...t,chainId:null},"null chainId"],[{...t,chainId:void 0},"undefined chainId"]])("should return false for %s",(a,c)=>{expect(s.canHandle(a,[e.ClearSignContextType.SAFE,e.ClearSignContextType.SIGNER])).toBe(!1)}),it.each([[{...t,challenge:""},"empty challenge string"],[{...t,challenge:123},"number challenge"],[{...t,challenge:null},"null challenge"]])("should return false for %s",(a,c)=>{expect(s.canHandle(a,[e.ClearSignContextType.SAFE,e.ClearSignContextType.SIGNER])).toBe(!1)}),it("should return true for different device models",()=>{expect(s.canHandle({...t,deviceModelId:o.DeviceModelId.NANO_S},[e.ClearSignContextType.SAFE,e.ClearSignContextType.SIGNER])).toBe(!0),expect(s.canHandle({...t,deviceModelId:o.DeviceModelId.NANO_SP},[e.ClearSignContextType.SAFE,e.ClearSignContextType.SIGNER])).toBe(!0),expect(s.canHandle({...t,deviceModelId:o.DeviceModelId.NANO_X},[e.ClearSignContextType.SAFE,e.ClearSignContextType.SIGNER])).toBe(!0),expect(s.canHandle({...t,deviceModelId:o.DeviceModelId.STAX},[e.ClearSignContextType.SAFE,e.ClearSignContextType.SIGNER])).toBe(!0),expect(s.canHandle({...t,deviceModelId:o.DeviceModelId.FLEX},[e.ClearSignContextType.SAFE,e.ClearSignContextType.SIGNER])).toBe(!0)}),it("should return true for different chain IDs",()=>{expect(s.canHandle({...t,chainId:1},[e.ClearSignContextType.SAFE,e.ClearSignContextType.SIGNER])).toBe(!0),expect(s.canHandle({...t,chainId:137},[e.ClearSignContextType.SAFE,e.ClearSignContextType.SIGNER])).toBe(!0),expect(s.canHandle({...t,chainId:10},[e.ClearSignContextType.SAFE,e.ClearSignContextType.SIGNER])).toBe(!0)})}),describe("load function",()=>{const t={safeContractAddress:"0x1234567890123456789012345678901234567890",chainId:1,deviceModelId:o.DeviceModelId.FLEX,challenge:"0xabcdef"};it("should return SAFE and SIGNER contexts with certificates",async()=>{vi.spyOn(n,"getDescriptors").mockResolvedValue((0,d.Right)(i));const a=await s.load(t);expect(n.getDescriptors).toHaveBeenCalledWith({safeContractAddress:"0x1234567890123456789012345678901234567890",chainId:1,challenge:"0xabcdef"}),expect(r.loadCertificate).toHaveBeenCalledTimes(2),expect(r.loadCertificate).toHaveBeenNthCalledWith(1,{keyId:"safe-key-id",keyUsage:"safe-key-usage",targetDevice:o.DeviceModelId.FLEX}),expect(r.loadCertificate).toHaveBeenNthCalledWith(2,{keyId:"signers-key-id",keyUsage:"signers-key-usage",targetDevice:o.DeviceModelId.FLEX}),expect(a).toEqual([{type:e.ClearSignContextType.SAFE,payload:"safe-descriptor-payload",certificate:l},{type:e.ClearSignContextType.SIGNER,payload:"signers-descriptor-payload",certificate:l}])}),it("should return SAFE and SIGNER contexts without certificates when loadCertificate returns undefined",async()=>{vi.spyOn(n,"getDescriptors").mockResolvedValue((0,d.Right)(i)),vi.spyOn(r,"loadCertificate").mockResolvedValue(void 0);const a=await s.load(t);expect(a).toEqual([{type:e.ClearSignContextType.SAFE,payload:"safe-descriptor-payload",certificate:void 0},{type:e.ClearSignContextType.SIGNER,payload:"signers-descriptor-payload",certificate:void 0}])}),it("should return ERROR context when data source returns Left",async()=>{const a=new Error("Failed to get safe account descriptors");vi.spyOn(n,"getDescriptors").mockResolvedValue((0,d.Left)(a));const c=await s.load(t);expect(c).toEqual([{type:e.ClearSignContextType.ERROR,error:a}]),expect(r.loadCertificate).not.toHaveBeenCalled()}),it("should work with different device models",async()=>{const a={...t,deviceModelId:o.DeviceModelId.NANO_S};vi.spyOn(n,"getDescriptors").mockResolvedValue((0,d.Right)(i));const c=await s.load(a);expect(r.loadCertificate).toHaveBeenCalledWith(expect.objectContaining({targetDevice:o.DeviceModelId.NANO_S})),expect(c).toHaveLength(2),expect(c[0]?.type).toBe(e.ClearSignContextType.SAFE),expect(c[1]?.type).toBe(e.ClearSignContextType.SIGNER)}),it("should work with different chain IDs",async()=>{const a={...t,chainId:137};vi.spyOn(n,"getDescriptors").mockResolvedValue((0,d.Right)(i)),await s.load(a),expect(n.getDescriptors).toHaveBeenCalledWith(expect.objectContaining({chainId:137}))}),it("should work with different safe addresses",async()=>{const a={...t,safeContractAddress:"0xabcdefabcdefabcdefabcdefabcdefabcdefabcd"};vi.spyOn(n,"getDescriptors").mockResolvedValue((0,d.Right)(i)),await s.load(a),expect(n.getDescriptors).toHaveBeenCalledWith(expect.objectContaining({safeContractAddress:"0xabcdefabcdefabcdefabcdefabcdefabcdefabcd"}))}),it("should handle different certificate data for account and signers",async()=>{const a={keyUsageNumber:1,payload:new Uint8Array([1,2,3])},c={keyUsageNumber:2,payload:new Uint8Array([4,5,6])};vi.spyOn(n,"getDescriptors").mockResolvedValue((0,d.Right)(i)),vi.spyOn(r,"loadCertificate").mockResolvedValueOnce(a).mockResolvedValueOnce(c);const p=await s.load(t);expect(p).toEqual([{type:e.ClearSignContextType.SAFE,payload:"safe-descriptor-payload",certificate:a},{type:e.ClearSignContextType.SIGNER,payload:"signers-descriptor-payload",certificate:c}])}),it("should handle empty descriptor payloads",async()=>{const a={account:{signedDescriptor:"",keyId:"key-id",keyUsage:"key-usage"},signers:{signedDescriptor:"",keyId:"key-id",keyUsage:"key-usage"}};vi.spyOn(n,"getDescriptors").mockResolvedValue((0,d.Right)(a));const c=await s.load(t);expect(c).toEqual([{type:e.ClearSignContextType.SAFE,payload:"",certificate:l},{type:e.ClearSignContextType.SIGNER,payload:"",certificate:l}])}),it("should handle long descriptor payloads",async()=>{const a="a".repeat(1e3),c={account:{signedDescriptor:a,keyId:"key-id",keyUsage:"key-usage"},signers:{signedDescriptor:a,keyId:"key-id",keyUsage:"key-usage"}};vi.spyOn(n,"getDescriptors").mockResolvedValue((0,d.Right)(c));const p=await s.load(t);expect(p[0].payload).toBe(a),expect(p[1].payload).toBe(a)}),it("should handle data source errors gracefully",async()=>{const a=new Error("Network error");vi.spyOn(n,"getDescriptors").mockResolvedValue((0,d.Left)(a));const c=await s.load(t);expect(c).toEqual([{type:e.ClearSignContextType.ERROR,error:new Error("Network error")}])})})});
2
+ //# sourceMappingURL=SafeAddressLoader.test.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../../../src/safe/domain/SafeAddressLoader.test.ts"],
4
+ "sourcesContent": ["import { DeviceModelId } from \"@ledgerhq/device-management-kit\";\nimport { Left, Right } from \"purify-ts\";\n\nimport { type PkiCertificateLoader } from \"@/pki/domain/PkiCertificateLoader\";\nimport { type PkiCertificate } from \"@/pki/model/PkiCertificate\";\nimport {\n type GetSafeAccountResponse,\n type SafeAccountDataSource,\n} from \"@/safe/data/SafeAccountDataSource\";\nimport {\n type SafeAddressContextInput,\n SafeAddressLoader,\n} from \"@/safe/domain/SafeAddressLoader\";\nimport {\n type ClearSignContextSuccess,\n ClearSignContextType,\n} from \"@/shared/model/ClearSignContext\";\n\ndescribe(\"SafeAddressLoader\", () => {\n const mockSafeAccountDataSource: SafeAccountDataSource = {\n getDescriptors: vi.fn(),\n };\n const mockPkiCertificateLoader: PkiCertificateLoader = {\n loadCertificate: vi.fn(),\n };\n const loader = new SafeAddressLoader(\n mockSafeAccountDataSource,\n mockPkiCertificateLoader,\n );\n\n const mockCertificate: PkiCertificate = {\n keyUsageNumber: 1,\n payload: new Uint8Array([1, 2, 3]),\n };\n\n const mockSafeAccountResponse: GetSafeAccountResponse = {\n account: {\n signedDescriptor: \"safe-descriptor-payload\",\n keyId: \"safe-key-id\",\n keyUsage: \"safe-key-usage\",\n },\n signers: {\n signedDescriptor: \"signers-descriptor-payload\",\n keyId: \"signers-key-id\",\n keyUsage: \"signers-key-usage\",\n },\n };\n\n beforeEach(() => {\n vi.clearAllMocks();\n vi.spyOn(mockPkiCertificateLoader, \"loadCertificate\").mockResolvedValue(\n mockCertificate,\n );\n });\n\n describe(\"canHandle function\", () => {\n const validInput: SafeAddressContextInput = {\n safeContractAddress: \"0x1234567890123456789012345678901234567890\",\n chainId: 1,\n deviceModelId: DeviceModelId.FLEX,\n challenge: \"0xabcdef\",\n };\n\n it(\"should return true for valid input with SAFE and SIGNER types\", () => {\n expect(\n loader.canHandle(validInput, [\n ClearSignContextType.SAFE,\n ClearSignContextType.SIGNER,\n ]),\n ).toBe(true);\n });\n\n it(\"should return true when expected types are subset of SAFE and SIGNER\", () => {\n expect(loader.canHandle(validInput, [ClearSignContextType.SAFE])).toBe(\n true,\n );\n expect(loader.canHandle(validInput, [ClearSignContextType.SIGNER])).toBe(\n true,\n );\n });\n\n it(\"should return false when expected types include unsupported types\", () => {\n expect(loader.canHandle(validInput, [ClearSignContextType.TOKEN])).toBe(\n false,\n );\n expect(loader.canHandle(validInput, [ClearSignContextType.NFT])).toBe(\n false,\n );\n });\n\n it(\"should return false when expected types include other types besides SAFE and SIGNER\", () => {\n expect(\n loader.canHandle(validInput, [\n ClearSignContextType.SAFE,\n ClearSignContextType.SIGNER,\n ClearSignContextType.TOKEN,\n ]),\n ).toBe(false);\n });\n\n it.each([\n [null, \"null input\"],\n [undefined, \"undefined input\"],\n [{}, \"empty object\"],\n [\"string\", \"string input\"],\n [123, \"number input\"],\n [[], \"array input\"],\n ])(\"should return false for %s\", (input, _description) => {\n expect(\n loader.canHandle(input, [\n ClearSignContextType.SAFE,\n ClearSignContextType.SIGNER,\n ]),\n ).toBe(false);\n });\n\n it.each([\n [\n { ...validInput, safeContractAddress: undefined },\n \"missing safeContractAddress\",\n ],\n [{ ...validInput, chainId: undefined }, \"missing chainId\"],\n [{ ...validInput, deviceModelId: undefined }, \"missing deviceModelId\"],\n [{ ...validInput, challenge: undefined }, \"missing challenge\"],\n ])(\"should return false for %s\", (input, _description) => {\n expect(\n loader.canHandle(input, [\n ClearSignContextType.SAFE,\n ClearSignContextType.SIGNER,\n ]),\n ).toBe(false);\n });\n\n it.each([\n [\n { ...validInput, safeContractAddress: \"invalid-hex\" },\n \"invalid safeContractAddress hex\",\n ],\n [\n { ...validInput, safeContractAddress: \"0x\" },\n \"empty safeContractAddress (0x)\",\n ],\n [\n { ...validInput, safeContractAddress: \"not-hex\" },\n \"non-hex safeContractAddress\",\n ],\n [\n { ...validInput, safeContractAddress: 123 },\n \"number safeContractAddress\",\n ],\n ])(\"should return false for %s\", (input, _description) => {\n expect(\n loader.canHandle(input, [\n ClearSignContextType.SAFE,\n ClearSignContextType.SIGNER,\n ]),\n ).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(\n loader.canHandle(input, [\n ClearSignContextType.SAFE,\n ClearSignContextType.SIGNER,\n ]),\n ).toBe(false);\n });\n\n it.each([\n [{ ...validInput, challenge: \"\" }, \"empty challenge string\"],\n [{ ...validInput, challenge: 123 }, \"number challenge\"],\n [{ ...validInput, challenge: null }, \"null challenge\"],\n ])(\"should return false for %s\", (input, _description) => {\n expect(\n loader.canHandle(input, [\n ClearSignContextType.SAFE,\n ClearSignContextType.SIGNER,\n ]),\n ).toBe(false);\n });\n\n it(\"should return true for different device models\", () => {\n expect(\n loader.canHandle(\n { ...validInput, deviceModelId: DeviceModelId.NANO_S },\n [ClearSignContextType.SAFE, ClearSignContextType.SIGNER],\n ),\n ).toBe(true);\n expect(\n loader.canHandle(\n { ...validInput, deviceModelId: DeviceModelId.NANO_SP },\n [ClearSignContextType.SAFE, ClearSignContextType.SIGNER],\n ),\n ).toBe(true);\n expect(\n loader.canHandle(\n { ...validInput, deviceModelId: DeviceModelId.NANO_X },\n [ClearSignContextType.SAFE, ClearSignContextType.SIGNER],\n ),\n ).toBe(true);\n expect(\n loader.canHandle({ ...validInput, deviceModelId: DeviceModelId.STAX }, [\n ClearSignContextType.SAFE,\n ClearSignContextType.SIGNER,\n ]),\n ).toBe(true);\n expect(\n loader.canHandle({ ...validInput, deviceModelId: DeviceModelId.FLEX }, [\n ClearSignContextType.SAFE,\n ClearSignContextType.SIGNER,\n ]),\n ).toBe(true);\n });\n\n it(\"should return true for different chain IDs\", () => {\n expect(\n loader.canHandle({ ...validInput, chainId: 1 }, [\n ClearSignContextType.SAFE,\n ClearSignContextType.SIGNER,\n ]),\n ).toBe(true);\n expect(\n loader.canHandle({ ...validInput, chainId: 137 }, [\n ClearSignContextType.SAFE,\n ClearSignContextType.SIGNER,\n ]),\n ).toBe(true);\n expect(\n loader.canHandle({ ...validInput, chainId: 10 }, [\n ClearSignContextType.SAFE,\n ClearSignContextType.SIGNER,\n ]),\n ).toBe(true);\n });\n });\n\n describe(\"load function\", () => {\n const input: SafeAddressContextInput = {\n safeContractAddress: \"0x1234567890123456789012345678901234567890\",\n chainId: 1,\n deviceModelId: DeviceModelId.FLEX,\n challenge: \"0xabcdef\",\n };\n\n it(\"should return SAFE and SIGNER contexts with certificates\", async () => {\n // GIVEN\n vi.spyOn(mockSafeAccountDataSource, \"getDescriptors\").mockResolvedValue(\n Right(mockSafeAccountResponse),\n );\n\n // WHEN\n const result = await loader.load(input);\n\n // THEN\n expect(mockSafeAccountDataSource.getDescriptors).toHaveBeenCalledWith({\n safeContractAddress: \"0x1234567890123456789012345678901234567890\",\n chainId: 1,\n challenge: \"0xabcdef\",\n });\n expect(mockPkiCertificateLoader.loadCertificate).toHaveBeenCalledTimes(2);\n expect(mockPkiCertificateLoader.loadCertificate).toHaveBeenNthCalledWith(\n 1,\n {\n keyId: \"safe-key-id\",\n keyUsage: \"safe-key-usage\",\n targetDevice: DeviceModelId.FLEX,\n },\n );\n expect(mockPkiCertificateLoader.loadCertificate).toHaveBeenNthCalledWith(\n 2,\n {\n keyId: \"signers-key-id\",\n keyUsage: \"signers-key-usage\",\n targetDevice: DeviceModelId.FLEX,\n },\n );\n expect(result).toEqual([\n {\n type: ClearSignContextType.SAFE,\n payload: \"safe-descriptor-payload\",\n certificate: mockCertificate,\n },\n {\n type: ClearSignContextType.SIGNER,\n payload: \"signers-descriptor-payload\",\n certificate: mockCertificate,\n },\n ]);\n });\n\n it(\"should return SAFE and SIGNER contexts without certificates when loadCertificate returns undefined\", async () => {\n // GIVEN\n vi.spyOn(mockSafeAccountDataSource, \"getDescriptors\").mockResolvedValue(\n Right(mockSafeAccountResponse),\n );\n vi.spyOn(mockPkiCertificateLoader, \"loadCertificate\").mockResolvedValue(\n undefined,\n );\n\n // WHEN\n const result = await loader.load(input);\n\n // THEN\n expect(result).toEqual([\n {\n type: ClearSignContextType.SAFE,\n payload: \"safe-descriptor-payload\",\n certificate: undefined,\n },\n {\n type: ClearSignContextType.SIGNER,\n payload: \"signers-descriptor-payload\",\n certificate: undefined,\n },\n ]);\n });\n\n it(\"should return ERROR context when data source returns Left\", async () => {\n // GIVEN\n const error = new Error(\"Failed to get safe account descriptors\");\n vi.spyOn(mockSafeAccountDataSource, \"getDescriptors\").mockResolvedValue(\n Left(error),\n );\n\n // WHEN\n const result = await loader.load(input);\n\n // THEN\n expect(result).toEqual([\n {\n type: ClearSignContextType.ERROR,\n error,\n },\n ]);\n expect(mockPkiCertificateLoader.loadCertificate).not.toHaveBeenCalled();\n });\n\n it(\"should work with different device models\", async () => {\n // GIVEN\n const inputNanoS = { ...input, deviceModelId: DeviceModelId.NANO_S };\n vi.spyOn(mockSafeAccountDataSource, \"getDescriptors\").mockResolvedValue(\n Right(mockSafeAccountResponse),\n );\n\n // WHEN\n const result = await loader.load(inputNanoS);\n\n // THEN\n expect(mockPkiCertificateLoader.loadCertificate).toHaveBeenCalledWith(\n expect.objectContaining({\n targetDevice: DeviceModelId.NANO_S,\n }),\n );\n expect(result).toHaveLength(2);\n expect(result[0]?.type).toBe(ClearSignContextType.SAFE);\n expect(result[1]?.type).toBe(ClearSignContextType.SIGNER);\n });\n\n it(\"should work with different chain IDs\", async () => {\n // GIVEN\n const inputPolygon = { ...input, chainId: 137 };\n vi.spyOn(mockSafeAccountDataSource, \"getDescriptors\").mockResolvedValue(\n Right(mockSafeAccountResponse),\n );\n\n // WHEN\n await loader.load(inputPolygon);\n\n // THEN\n expect(mockSafeAccountDataSource.getDescriptors).toHaveBeenCalledWith(\n expect.objectContaining({\n chainId: 137,\n }),\n );\n });\n\n it(\"should work with different safe addresses\", async () => {\n // GIVEN\n const differentInput = {\n ...input,\n safeContractAddress:\n \"0xabcdefabcdefabcdefabcdefabcdefabcdefabcd\" as const,\n };\n vi.spyOn(mockSafeAccountDataSource, \"getDescriptors\").mockResolvedValue(\n Right(mockSafeAccountResponse),\n );\n\n // WHEN\n await loader.load(differentInput);\n\n // THEN\n expect(mockSafeAccountDataSource.getDescriptors).toHaveBeenCalledWith(\n expect.objectContaining({\n safeContractAddress: \"0xabcdefabcdefabcdefabcdefabcdefabcdefabcd\",\n }),\n );\n });\n\n it(\"should handle different certificate data for account and signers\", async () => {\n // GIVEN\n const accountCertificate: PkiCertificate = {\n keyUsageNumber: 1,\n payload: new Uint8Array([1, 2, 3]),\n };\n const signersCertificate: PkiCertificate = {\n keyUsageNumber: 2,\n payload: new Uint8Array([4, 5, 6]),\n };\n vi.spyOn(mockSafeAccountDataSource, \"getDescriptors\").mockResolvedValue(\n Right(mockSafeAccountResponse),\n );\n vi.spyOn(mockPkiCertificateLoader, \"loadCertificate\")\n .mockResolvedValueOnce(accountCertificate)\n .mockResolvedValueOnce(signersCertificate);\n\n // WHEN\n const result = await loader.load(input);\n\n // THEN\n expect(result).toEqual([\n {\n type: ClearSignContextType.SAFE,\n payload: \"safe-descriptor-payload\",\n certificate: accountCertificate,\n },\n {\n type: ClearSignContextType.SIGNER,\n payload: \"signers-descriptor-payload\",\n certificate: signersCertificate,\n },\n ]);\n });\n\n it(\"should handle empty descriptor payloads\", async () => {\n // GIVEN\n const emptyResponse: GetSafeAccountResponse = {\n account: {\n signedDescriptor: \"\",\n keyId: \"key-id\",\n keyUsage: \"key-usage\",\n },\n signers: {\n signedDescriptor: \"\",\n keyId: \"key-id\",\n keyUsage: \"key-usage\",\n },\n };\n vi.spyOn(mockSafeAccountDataSource, \"getDescriptors\").mockResolvedValue(\n Right(emptyResponse),\n );\n\n // WHEN\n const result = await loader.load(input);\n\n // THEN\n expect(result).toEqual([\n {\n type: ClearSignContextType.SAFE,\n payload: \"\",\n certificate: mockCertificate,\n },\n {\n type: ClearSignContextType.SIGNER,\n payload: \"\",\n certificate: mockCertificate,\n },\n ]);\n });\n\n it(\"should handle long descriptor payloads\", async () => {\n // GIVEN\n const longPayload = \"a\".repeat(1000);\n const longResponse: GetSafeAccountResponse = {\n account: {\n signedDescriptor: longPayload,\n keyId: \"key-id\",\n keyUsage: \"key-usage\",\n },\n signers: {\n signedDescriptor: longPayload,\n keyId: \"key-id\",\n keyUsage: \"key-usage\",\n },\n };\n vi.spyOn(mockSafeAccountDataSource, \"getDescriptors\").mockResolvedValue(\n Right(longResponse),\n );\n\n // WHEN\n const result = await loader.load(input);\n\n // THEN\n expect((result[0] as ClearSignContextSuccess).payload).toBe(longPayload);\n expect((result[1] as ClearSignContextSuccess).payload).toBe(longPayload);\n });\n\n it(\"should handle data source errors gracefully\", async () => {\n // GIVEN\n const error = new Error(\"Network error\");\n vi.spyOn(mockSafeAccountDataSource, \"getDescriptors\").mockResolvedValue(\n Left(error),\n );\n\n // WHEN\n const result = await loader.load(input);\n\n // THEN\n expect(result).toEqual([\n {\n type: ClearSignContextType.ERROR,\n error: new Error(\"Network error\"),\n },\n ]);\n });\n });\n});\n"],
5
+ "mappings": "aAAA,IAAAA,EAA8B,2CAC9BC,EAA4B,qBAQ5BC,EAGO,2CACPC,EAGO,2CAEP,SAAS,oBAAqB,IAAM,CAClC,MAAMC,EAAmD,CACvD,eAAgB,GAAG,GAAG,CACxB,EACMC,EAAiD,CACrD,gBAAiB,GAAG,GAAG,CACzB,EACMC,EAAS,IAAI,oBACjBF,EACAC,CACF,EAEME,EAAkC,CACtC,eAAgB,EAChB,QAAS,IAAI,WAAW,CAAC,EAAG,EAAG,CAAC,CAAC,CACnC,EAEMC,EAAkD,CACtD,QAAS,CACP,iBAAkB,0BAClB,MAAO,cACP,SAAU,gBACZ,EACA,QAAS,CACP,iBAAkB,6BAClB,MAAO,iBACP,SAAU,mBACZ,CACF,EAEA,WAAW,IAAM,CACf,GAAG,cAAc,EACjB,GAAG,MAAMH,EAA0B,iBAAiB,EAAE,kBACpD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EACA,GAAG,MAAMhB,EAA2B,gBAAgB,EAAE,qBACpD,SAAMiB,CAAY,CACpB,EAGA,MAAMT,EAAS,MAAMN,EAAO,KAAKI,CAAK,EAGtC,OAAQE,EAAO,CAAC,EAA8B,OAAO,EAAE,KAAKQ,CAAW,EACvE,OAAQR,EAAO,CAAC,EAA8B,OAAO,EAAE,KAAKQ,CAAW,CACzE,CAAC,EAED,GAAG,8CAA+C,SAAY,CAE5D,MAAMP,EAAQ,IAAI,MAAM,eAAe,EACvC,GAAG,MAAMT,EAA2B,gBAAgB,EAAE,qBACpD,QAAKS,CAAK,CACZ,EAGA,MAAMD,EAAS,MAAMN,EAAO,KAAKI,CAAK,EAGtC,OAAOE,CAAM,EAAE,QAAQ,CACrB,CACE,KAAM,uBAAqB,MAC3B,MAAO,IAAI,MAAM,eAAe,CAClC,CACF,CAAC,CACH,CAAC,CACH,CAAC,CACH,CAAC",
6
+ "names": ["import_device_management_kit", "import_purify_ts", "import_SafeAddressLoader", "import_ClearSignContext", "mockSafeAccountDataSource", "mockPkiCertificateLoader", "loader", "mockCertificate", "mockSafeAccountResponse", "validInput", "input", "_description", "result", "error", "inputNanoS", "inputPolygon", "differentInput", "accountCertificate", "signersCertificate", "emptyResponse", "longPayload", "longResponse"]
7
+ }
@@ -1,2 +1,2 @@
1
- "use strict";var c=Object.defineProperty;var C=Object.getOwnPropertyDescriptor;var N=Object.getOwnPropertyNames;var E=Object.prototype.hasOwnProperty;var l=(r,t)=>{for(var i in t)c(r,i,{get:t[i],enumerable:!0})},y=(r,t,i,T)=>{if(t&&typeof t=="object"||typeof t=="function")for(let n of N(t))!E.call(r,n)&&n!==i&&c(r,n,{get:()=>t[n],enumerable:!(T=C(t,n))||T.enumerable});return r};var R=r=>y(c({},"__esModule",{value:!0}),r);var s={};l(s,{ClearSignContextReferenceType:()=>p,ClearSignContextType:()=>o});module.exports=R(s);var o=(e=>(e.TOKEN="token",e.NFT="nft",e.TRUSTED_NAME="trustedName",e.PLUGIN="plugin",e.EXTERNAL_PLUGIN="externalPlugin",e.TRANSACTION_INFO="transactionInfo",e.PROXY_INFO="proxyInfo",e.ENUM="enum",e.TRANSACTION_FIELD_DESCRIPTION="transactionFieldDescription",e.WEB3_CHECK="web3Check",e.DYNAMIC_NETWORK="dynamicNetwork",e.DYNAMIC_NETWORK_ICON="dynamicNetworkIcon",e.ERROR="error",e))(o||{}),p=(a=>(a.TOKEN="token",a.NFT="nft",a.TRUSTED_NAME="trustedName",a.ENUM="enum",a.CALLDATA="calldata",a))(p||{});0&&(module.exports={ClearSignContextReferenceType,ClearSignContextType});
1
+ "use strict";var c=Object.defineProperty;var o=Object.getOwnPropertyDescriptor;var p=Object.getOwnPropertyNames;var C=Object.prototype.hasOwnProperty;var R=(r,t)=>{for(var i in t)c(r,i,{get:t[i],enumerable:!0})},l=(r,t,i,T)=>{if(t&&typeof t=="object"||typeof t=="function")for(let n of p(t))!C.call(r,n)&&n!==i&&c(r,n,{get:()=>t[n],enumerable:!(T=o(t,n))||T.enumerable});return r};var s=r=>l(c({},"__esModule",{value:!0}),r);var y={};R(y,{ClearSignContextReferenceType:()=>N,ClearSignContextType:()=>E});module.exports=s(y);var E=(e=>(e.TOKEN="token",e.NFT="nft",e.TRUSTED_NAME="trustedName",e.PLUGIN="plugin",e.EXTERNAL_PLUGIN="externalPlugin",e.TRANSACTION_INFO="transactionInfo",e.PROXY_INFO="proxyInfo",e.ENUM="enum",e.TRANSACTION_FIELD_DESCRIPTION="transactionFieldDescription",e.WEB3_CHECK="web3Check",e.DYNAMIC_NETWORK="dynamicNetwork",e.DYNAMIC_NETWORK_ICON="dynamicNetworkIcon",e.ERROR="error",e.SAFE="safe",e.SIGNER="signer",e))(E||{}),N=(a=>(a.TOKEN="token",a.NFT="nft",a.TRUSTED_NAME="trustedName",a.ENUM="enum",a.CALLDATA="calldata",a))(N||{});0&&(module.exports={ClearSignContextReferenceType,ClearSignContextType});
2
2
  //# sourceMappingURL=ClearSignContext.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../../src/shared/model/ClearSignContext.ts"],
4
- "sourcesContent": ["import { type PkiCertificate } from \"@/pki/model/PkiCertificate\";\n\nimport { type GenericPath } from \"./GenericPath\";\n\nexport enum ClearSignContextType {\n TOKEN = \"token\",\n NFT = \"nft\",\n TRUSTED_NAME = \"trustedName\",\n PLUGIN = \"plugin\",\n EXTERNAL_PLUGIN = \"externalPlugin\",\n TRANSACTION_INFO = \"transactionInfo\",\n PROXY_INFO = \"proxyInfo\",\n ENUM = \"enum\",\n TRANSACTION_FIELD_DESCRIPTION = \"transactionFieldDescription\",\n WEB3_CHECK = \"web3Check\",\n DYNAMIC_NETWORK = \"dynamicNetwork\",\n DYNAMIC_NETWORK_ICON = \"dynamicNetworkIcon\",\n ERROR = \"error\",\n}\n\nexport enum ClearSignContextReferenceType {\n TOKEN = ClearSignContextType.TOKEN,\n NFT = ClearSignContextType.NFT,\n TRUSTED_NAME = ClearSignContextType.TRUSTED_NAME,\n ENUM = ClearSignContextType.ENUM,\n CALLDATA = \"calldata\",\n}\n\nexport type ClearSignContextReference<\n Type extends ClearSignContextReferenceType = ClearSignContextReferenceType,\n> = Type extends ClearSignContextReferenceType.ENUM\n ? {\n type: ClearSignContextReferenceType.ENUM;\n valuePath: GenericPath;\n id: number; // enum id to reference\n }\n : Type extends ClearSignContextReferenceType.TRUSTED_NAME\n ? {\n type: ClearSignContextReferenceType.TRUSTED_NAME;\n valuePath: GenericPath;\n types: string[];\n sources: string[];\n }\n : Type extends ClearSignContextReferenceType.CALLDATA\n ? {\n type: ClearSignContextReferenceType.CALLDATA;\n callee: GenericPath;\n valuePath: GenericPath;\n selector?: GenericPath;\n amount?: GenericPath;\n spender?: GenericPath;\n chainId?: GenericPath;\n }\n :\n | {\n type: Type;\n valuePath: GenericPath;\n value?: never;\n }\n | {\n type: Type;\n valuePath?: never;\n value: string;\n };\n\nexport type ClearSignContextSuccessType = Exclude<\n ClearSignContextType,\n ClearSignContextType.ERROR\n>;\n\nexport type ClearSignContextSuccess<\n T extends Exclude<\n ClearSignContextType,\n ClearSignContextType.ERROR\n > = ClearSignContextSuccessType,\n> = T extends ClearSignContextType.ENUM\n ? {\n type: ClearSignContextType.ENUM;\n id: number;\n payload: string;\n value: number;\n certificate?: PkiCertificate;\n }\n : T extends ClearSignContextType.TRANSACTION_FIELD_DESCRIPTION\n ? {\n type: ClearSignContextType.TRANSACTION_FIELD_DESCRIPTION;\n payload: string;\n reference?: ClearSignContextReference;\n certificate?: PkiCertificate;\n }\n : {\n type: T;\n payload: string;\n certificate?: PkiCertificate;\n };\n\nexport type ClearSignContextError = {\n type: ClearSignContextType.ERROR;\n error: Error;\n};\n\nexport type ClearSignContext = ClearSignContextSuccess | ClearSignContextError;\n"],
5
- "mappings": "yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,mCAAAE,EAAA,yBAAAC,IAAA,eAAAC,EAAAJ,GAIO,IAAKG,OACVA,EAAA,MAAQ,QACRA,EAAA,IAAM,MACNA,EAAA,aAAe,cACfA,EAAA,OAAS,SACTA,EAAA,gBAAkB,iBAClBA,EAAA,iBAAmB,kBACnBA,EAAA,WAAa,YACbA,EAAA,KAAO,OACPA,EAAA,8BAAgC,8BAChCA,EAAA,WAAa,YACbA,EAAA,gBAAkB,iBAClBA,EAAA,qBAAuB,qBACvBA,EAAA,MAAQ,QAbEA,OAAA,IAgBAD,OACVA,EAAA,MAAQ,QACRA,EAAA,IAAM,MACNA,EAAA,aAAe,cACfA,EAAA,KAAO,OACPA,EAAA,SAAW,WALDA,OAAA",
4
+ "sourcesContent": ["import { type PkiCertificate } from \"@/pki/model/PkiCertificate\";\n\nimport { type GenericPath } from \"./GenericPath\";\n\nexport enum ClearSignContextType {\n TOKEN = \"token\",\n NFT = \"nft\",\n TRUSTED_NAME = \"trustedName\",\n PLUGIN = \"plugin\",\n EXTERNAL_PLUGIN = \"externalPlugin\",\n TRANSACTION_INFO = \"transactionInfo\",\n PROXY_INFO = \"proxyInfo\",\n ENUM = \"enum\",\n TRANSACTION_FIELD_DESCRIPTION = \"transactionFieldDescription\",\n WEB3_CHECK = \"web3Check\",\n DYNAMIC_NETWORK = \"dynamicNetwork\",\n DYNAMIC_NETWORK_ICON = \"dynamicNetworkIcon\",\n ERROR = \"error\",\n SAFE = \"safe\",\n SIGNER = \"signer\",\n}\n\nexport enum ClearSignContextReferenceType {\n TOKEN = ClearSignContextType.TOKEN,\n NFT = ClearSignContextType.NFT,\n TRUSTED_NAME = ClearSignContextType.TRUSTED_NAME,\n ENUM = ClearSignContextType.ENUM,\n CALLDATA = \"calldata\",\n}\n\nexport type ClearSignContextReference<\n Type extends ClearSignContextReferenceType = ClearSignContextReferenceType,\n> = Type extends ClearSignContextReferenceType.ENUM\n ? {\n type: ClearSignContextReferenceType.ENUM;\n valuePath: GenericPath;\n id: number; // enum id to reference\n }\n : Type extends ClearSignContextReferenceType.TRUSTED_NAME\n ? {\n type: ClearSignContextReferenceType.TRUSTED_NAME;\n valuePath: GenericPath;\n types: string[];\n sources: string[];\n }\n : Type extends ClearSignContextReferenceType.CALLDATA\n ? {\n type: ClearSignContextReferenceType.CALLDATA;\n callee: GenericPath;\n valuePath: GenericPath;\n selector?: GenericPath;\n amount?: GenericPath;\n spender?: GenericPath;\n chainId?: GenericPath;\n }\n :\n | {\n type: Type;\n valuePath: GenericPath;\n value?: never;\n }\n | {\n type: Type;\n valuePath?: never;\n value: string;\n };\n\nexport type ClearSignContextSuccessType = Exclude<\n ClearSignContextType,\n ClearSignContextType.ERROR\n>;\n\nexport type ClearSignContextSuccess<\n T extends Exclude<\n ClearSignContextType,\n ClearSignContextType.ERROR\n > = ClearSignContextSuccessType,\n> = T extends ClearSignContextType.ENUM\n ? {\n type: ClearSignContextType.ENUM;\n id: number;\n payload: string;\n value: number;\n certificate?: PkiCertificate;\n }\n : T extends ClearSignContextType.TRANSACTION_FIELD_DESCRIPTION\n ? {\n type: ClearSignContextType.TRANSACTION_FIELD_DESCRIPTION;\n payload: string;\n reference?: ClearSignContextReference;\n certificate?: PkiCertificate;\n }\n : {\n type: T;\n payload: string;\n certificate?: PkiCertificate;\n };\n\nexport type ClearSignContextError = {\n type: ClearSignContextType.ERROR;\n error: Error;\n};\n\nexport type ClearSignContext = ClearSignContextSuccess | ClearSignContextError;\n"],
5
+ "mappings": "yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,mCAAAE,EAAA,yBAAAC,IAAA,eAAAC,EAAAJ,GAIO,IAAKG,OACVA,EAAA,MAAQ,QACRA,EAAA,IAAM,MACNA,EAAA,aAAe,cACfA,EAAA,OAAS,SACTA,EAAA,gBAAkB,iBAClBA,EAAA,iBAAmB,kBACnBA,EAAA,WAAa,YACbA,EAAA,KAAO,OACPA,EAAA,8BAAgC,8BAChCA,EAAA,WAAa,YACbA,EAAA,gBAAkB,iBAClBA,EAAA,qBAAuB,qBACvBA,EAAA,MAAQ,QACRA,EAAA,KAAO,OACPA,EAAA,OAAS,SAfCA,OAAA,IAkBAD,OACVA,EAAA,MAAQ,QACRA,EAAA,IAAM,MACNA,EAAA,aAAe,cACfA,EAAA,KAAO,OACPA,EAAA,SAAW,WALDA,OAAA",
6
6
  "names": ["ClearSignContext_exports", "__export", "ClearSignContextReferenceType", "ClearSignContextType", "__toCommonJS"]
7
7
  }
@@ -1,2 +1,2 @@
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});
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],[e.KeyUsage.LESMultisig,14]]);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: 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",
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 [KeyUsage.LESMultisig, 14],\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,EACrB,CAAC,WAAS,YAAa,EAAE,CAC3B,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 e=require("../../pki/model/KeyUsage"),r=require("../../shared/utils/KeyUsageMapper");describe("KeyUsageMapper",()=>{describe("mapKeyUsageForFirmware",()=>{it.each([[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]])("should map key usage %s to %i",(a,t)=>{const o=r.KeyUsageMapper.mapKeyUsageForFirmware(a);expect(o).toEqual(t)}),it("should return -1 when key usage is not found",()=>{const a=r.KeyUsageMapper.mapKeyUsageForFirmware("unknown");expect(a).toEqual(-1)})})});
1
+ "use strict";var e=require("../../pki/model/KeyUsage"),r=require("../../shared/utils/KeyUsageMapper");describe("KeyUsageMapper",()=>{describe("mapKeyUsageForFirmware",()=>{it.each([[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],[e.KeyUsage.LESMultisig,14]])("should map key usage %s to %i",(a,t)=>{const o=r.KeyUsageMapper.mapKeyUsageForFirmware(a);expect(o).toEqual(t)}),it("should return -1 when key usage is not found",()=>{const a=r.KeyUsageMapper.mapKeyUsageForFirmware("unknown");expect(a).toEqual(-1)})})});
2
2
  //# sourceMappingURL=KeyUsageMapper.test.js.map