@ledgerhq/context-module 0.0.0-multisig-20250905101831 → 0.0.0-multisig-20250918154034
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.
- package/lib/cjs/package.json +1 -1
- package/lib/cjs/src/ContextModule.js +1 -1
- package/lib/cjs/src/ContextModule.js.map +1 -1
- package/lib/cjs/src/ContextModuleBuilder.js +1 -1
- package/lib/cjs/src/ContextModuleBuilder.js.map +3 -3
- package/lib/cjs/src/ContextModuleBuilder.test.js +1 -1
- package/lib/cjs/src/ContextModuleBuilder.test.js.map +3 -3
- package/lib/cjs/src/DefaultContextModule.js +1 -1
- package/lib/cjs/src/DefaultContextModule.js.map +3 -3
- package/lib/cjs/src/DefaultContextModule.test.js +1 -1
- package/lib/cjs/src/DefaultContextModule.test.js.map +3 -3
- package/lib/cjs/src/config/model/ContextModuleConfig.js +1 -1
- package/lib/cjs/src/config/model/ContextModuleConfig.js.map +1 -1
- package/lib/cjs/src/di.js +1 -1
- package/lib/cjs/src/di.js.map +3 -3
- package/lib/cjs/src/dynamic-network/domain/DynamicNetworkContextLoader.js +1 -1
- package/lib/cjs/src/dynamic-network/domain/DynamicNetworkContextLoader.js.map +3 -3
- package/lib/cjs/src/dynamic-network/domain/DynamicNetworkContextLoader.test.js +1 -1
- package/lib/cjs/src/dynamic-network/domain/DynamicNetworkContextLoader.test.js.map +2 -2
- package/lib/cjs/src/index.js +1 -1
- package/lib/cjs/src/index.js.map +2 -2
- package/lib/cjs/src/nft/domain/NftContextFieldLoader.js +1 -1
- package/lib/cjs/src/nft/domain/NftContextFieldLoader.js.map +2 -2
- package/lib/cjs/src/nft/domain/NftContextFieldLoader.test.js +2 -0
- package/lib/cjs/src/nft/domain/NftContextFieldLoader.test.js.map +7 -0
- package/lib/cjs/src/proxy/data/HttpProxyDataSource.js +2 -0
- package/lib/cjs/src/proxy/data/HttpProxyDataSource.js.map +7 -0
- package/lib/cjs/src/proxy/data/HttpProxyDataSource.test.js +2 -0
- package/lib/cjs/src/proxy/data/HttpProxyDataSource.test.js.map +7 -0
- package/lib/cjs/src/proxy/data/HttpSafeProxyDataSource.js +2 -0
- package/lib/cjs/src/proxy/data/HttpSafeProxyDataSource.js.map +7 -0
- package/lib/cjs/src/proxy/data/HttpSafeProxyDataSource.test.js +2 -0
- package/lib/cjs/src/proxy/data/HttpSafeProxyDataSource.test.js.map +7 -0
- package/lib/cjs/src/proxy/data/ProxyDataSource.js +2 -0
- package/lib/cjs/src/proxy/data/ProxyDataSource.js.map +7 -0
- package/lib/cjs/src/{transaction → proxy}/data/dto/ProxyDelegateCallDto.js.map +1 -1
- package/lib/cjs/src/{transaction → proxy}/data/dto/ProxyImplementationAddressDto.js.map +1 -1
- package/lib/cjs/src/proxy/data/dto/SafeProxyImplementationAddressDto.js +2 -0
- package/lib/cjs/src/proxy/data/dto/SafeProxyImplementationAddressDto.js.map +7 -0
- package/lib/cjs/src/proxy/di/proxyModuleFactory.js +2 -0
- package/lib/cjs/src/proxy/di/proxyModuleFactory.js.map +7 -0
- package/lib/cjs/src/proxy/di/proxyModuleFactory.test.js +2 -0
- package/lib/cjs/src/proxy/di/proxyModuleFactory.test.js.map +7 -0
- package/lib/cjs/src/proxy/di/proxyTypes.js +2 -0
- package/lib/cjs/src/proxy/di/proxyTypes.js.map +7 -0
- package/lib/cjs/src/proxy/domain/ProxyContextFieldLoader.js +2 -0
- package/lib/cjs/src/proxy/domain/ProxyContextFieldLoader.js.map +7 -0
- package/lib/cjs/src/proxy/domain/ProxyContextFieldLoader.test.js +2 -0
- package/lib/cjs/src/proxy/domain/ProxyContextFieldLoader.test.js.map +7 -0
- package/lib/cjs/src/proxy/model/ProxyDelegateCall.js +2 -0
- package/lib/cjs/src/proxy/model/ProxyDelegateCall.js.map +7 -0
- package/lib/cjs/src/shared/domain/ContextFieldLoader.js +1 -1
- package/lib/cjs/src/shared/domain/ContextFieldLoader.js.map +2 -2
- package/lib/cjs/src/shared/domain/ContextLoader.js +1 -1
- package/lib/cjs/src/shared/domain/ContextLoader.js.map +1 -1
- package/lib/cjs/src/shared/model/TransactionContext.js +1 -1
- package/lib/cjs/src/shared/model/TransactionContext.js.map +1 -1
- package/lib/cjs/src/shared/model/TransactionFieldContext.js +2 -0
- package/lib/cjs/src/shared/model/TransactionFieldContext.js.map +7 -0
- package/lib/cjs/src/shared/model/TransactionSubset.js.map +1 -1
- package/lib/cjs/src/shared/model/TypedDataClearSignContext.js +1 -1
- package/lib/cjs/src/shared/model/TypedDataClearSignContext.js.map +3 -3
- package/lib/cjs/src/shared/model/TypedDataContext.js +1 -1
- package/lib/cjs/src/shared/model/TypedDataContext.js.map +1 -1
- package/lib/cjs/src/token/domain/TokenContextFieldLoader.js +1 -1
- package/lib/cjs/src/token/domain/TokenContextFieldLoader.js.map +3 -3
- package/lib/cjs/src/token/domain/TokenContextFieldLoader.test.js +2 -0
- package/lib/cjs/src/token/domain/TokenContextFieldLoader.test.js.map +7 -0
- package/lib/cjs/src/transaction/data/HttpTransactionDataSource.js +1 -1
- package/lib/cjs/src/transaction/data/HttpTransactionDataSource.js.map +2 -2
- package/lib/cjs/src/transaction/di/transactionModuleFactory.js +1 -1
- package/lib/cjs/src/transaction/di/transactionModuleFactory.js.map +3 -3
- package/lib/cjs/src/transaction/di/transactionTypes.js +1 -1
- package/lib/cjs/src/transaction/di/transactionTypes.js.map +2 -2
- package/lib/cjs/src/transaction/domain/TransactionContextLoader.js +1 -1
- package/lib/cjs/src/transaction/domain/TransactionContextLoader.js.map +3 -3
- package/lib/cjs/src/transaction/domain/TransactionContextLoader.test.js +1 -1
- package/lib/cjs/src/transaction/domain/TransactionContextLoader.test.js.map +3 -3
- package/lib/cjs/src/trusted-name/domain/TrustedNameContextFieldLoader.js +1 -1
- package/lib/cjs/src/trusted-name/domain/TrustedNameContextFieldLoader.js.map +2 -2
- package/lib/cjs/src/trusted-name/domain/TrustedNameContextFieldLoader.test.js +2 -0
- package/lib/cjs/src/trusted-name/domain/TrustedNameContextFieldLoader.test.js.map +7 -0
- package/lib/cjs/src/typed-data/data/FiltersDto.js +1 -1
- package/lib/cjs/src/typed-data/data/FiltersDto.js.map +1 -1
- package/lib/cjs/src/typed-data/data/HttpTypedDataDataSource.js +1 -1
- package/lib/cjs/src/typed-data/data/HttpTypedDataDataSource.js.map +3 -3
- package/lib/cjs/src/typed-data/data/HttpTypedDataDataSource.test.js +1 -1
- package/lib/cjs/src/typed-data/data/HttpTypedDataDataSource.test.js.map +3 -3
- package/lib/cjs/src/typed-data/data/TypedDataDataSource.js +1 -1
- package/lib/cjs/src/typed-data/data/TypedDataDataSource.js.map +1 -1
- package/lib/cjs/src/typed-data/domain/DefaultTypedDataContextLoader.js +1 -1
- package/lib/cjs/src/typed-data/domain/DefaultTypedDataContextLoader.js.map +3 -3
- package/lib/cjs/src/typed-data/domain/DefaultTypedDataContextLoader.test.js +1 -1
- package/lib/cjs/src/typed-data/domain/DefaultTypedDataContextLoader.test.js.map +3 -3
- package/lib/esm/package.json +1 -1
- package/lib/esm/src/ContextModuleBuilder.js +1 -1
- package/lib/esm/src/ContextModuleBuilder.js.map +3 -3
- package/lib/esm/src/ContextModuleBuilder.test.js +1 -1
- package/lib/esm/src/ContextModuleBuilder.test.js.map +3 -3
- package/lib/esm/src/DefaultContextModule.js +1 -1
- package/lib/esm/src/DefaultContextModule.js.map +3 -3
- package/lib/esm/src/DefaultContextModule.test.js +1 -1
- package/lib/esm/src/DefaultContextModule.test.js.map +3 -3
- package/lib/esm/src/di.js +1 -1
- package/lib/esm/src/di.js.map +3 -3
- package/lib/esm/src/dynamic-network/domain/DynamicNetworkContextLoader.js +1 -1
- package/lib/esm/src/dynamic-network/domain/DynamicNetworkContextLoader.js.map +3 -3
- package/lib/esm/src/dynamic-network/domain/DynamicNetworkContextLoader.test.js +1 -1
- package/lib/esm/src/dynamic-network/domain/DynamicNetworkContextLoader.test.js.map +2 -2
- package/lib/esm/src/index.js +1 -1
- package/lib/esm/src/index.js.map +2 -2
- package/lib/esm/src/nft/domain/NftContextFieldLoader.js +1 -1
- package/lib/esm/src/nft/domain/NftContextFieldLoader.js.map +3 -3
- package/lib/esm/src/nft/domain/NftContextFieldLoader.test.js +2 -0
- package/lib/esm/src/nft/domain/NftContextFieldLoader.test.js.map +7 -0
- package/lib/esm/src/proxy/data/HttpProxyDataSource.js +2 -0
- package/lib/esm/src/proxy/data/HttpProxyDataSource.js.map +7 -0
- package/lib/esm/src/proxy/data/HttpProxyDataSource.test.js +2 -0
- package/lib/esm/src/proxy/data/HttpProxyDataSource.test.js.map +7 -0
- package/lib/esm/src/proxy/data/HttpSafeProxyDataSource.js +2 -0
- package/lib/esm/src/proxy/data/HttpSafeProxyDataSource.js.map +7 -0
- package/lib/esm/src/proxy/data/HttpSafeProxyDataSource.test.js +2 -0
- package/lib/esm/src/proxy/data/HttpSafeProxyDataSource.test.js.map +7 -0
- package/lib/esm/src/proxy/data/ProxyDataSource.js +1 -0
- package/lib/esm/src/proxy/data/dto/SafeProxyImplementationAddressDto.js +1 -0
- package/lib/esm/src/proxy/di/proxyModuleFactory.js +2 -0
- package/lib/esm/src/proxy/di/proxyModuleFactory.js.map +7 -0
- package/lib/esm/src/proxy/di/proxyModuleFactory.test.js +2 -0
- package/lib/esm/src/proxy/di/proxyModuleFactory.test.js.map +7 -0
- package/lib/esm/src/proxy/di/proxyTypes.js +2 -0
- package/lib/esm/src/proxy/di/proxyTypes.js.map +7 -0
- package/lib/esm/src/proxy/domain/ProxyContextFieldLoader.js +2 -0
- package/lib/esm/src/proxy/domain/ProxyContextFieldLoader.js.map +7 -0
- package/lib/esm/src/proxy/domain/ProxyContextFieldLoader.test.js +2 -0
- package/lib/esm/src/proxy/domain/ProxyContextFieldLoader.test.js.map +7 -0
- package/lib/esm/src/proxy/model/ProxyDelegateCall.js.map +7 -0
- package/lib/esm/src/shared/domain/ContextFieldLoader.js +1 -1
- package/lib/esm/src/shared/domain/ContextFieldLoader.js.map +2 -2
- package/lib/esm/src/shared/model/TransactionFieldContext.js +1 -0
- package/lib/esm/src/shared/model/TransactionFieldContext.js.map +7 -0
- package/lib/esm/src/shared/model/TypedDataClearSignContext.js +1 -1
- package/lib/esm/src/shared/model/TypedDataClearSignContext.js.map +3 -3
- package/lib/esm/src/token/domain/TokenContextFieldLoader.js +1 -1
- package/lib/esm/src/token/domain/TokenContextFieldLoader.js.map +3 -3
- package/lib/esm/src/token/domain/TokenContextFieldLoader.test.js +2 -0
- package/lib/esm/src/token/domain/TokenContextFieldLoader.test.js.map +7 -0
- package/lib/esm/src/transaction/data/HttpTransactionDataSource.js +1 -1
- package/lib/esm/src/transaction/data/HttpTransactionDataSource.js.map +2 -2
- package/lib/esm/src/transaction/di/transactionModuleFactory.js +1 -1
- package/lib/esm/src/transaction/di/transactionModuleFactory.js.map +3 -3
- package/lib/esm/src/transaction/di/transactionTypes.js +1 -1
- package/lib/esm/src/transaction/di/transactionTypes.js.map +2 -2
- package/lib/esm/src/transaction/domain/TransactionContextLoader.js +1 -1
- package/lib/esm/src/transaction/domain/TransactionContextLoader.js.map +3 -3
- package/lib/esm/src/transaction/domain/TransactionContextLoader.test.js +1 -1
- package/lib/esm/src/transaction/domain/TransactionContextLoader.test.js.map +3 -3
- package/lib/esm/src/trusted-name/domain/TrustedNameContextFieldLoader.js +1 -1
- package/lib/esm/src/trusted-name/domain/TrustedNameContextFieldLoader.js.map +3 -3
- package/lib/esm/src/trusted-name/domain/TrustedNameContextFieldLoader.test.js +2 -0
- package/lib/esm/src/trusted-name/domain/TrustedNameContextFieldLoader.test.js.map +7 -0
- package/lib/esm/src/typed-data/data/HttpTypedDataDataSource.js +1 -1
- package/lib/esm/src/typed-data/data/HttpTypedDataDataSource.js.map +3 -3
- package/lib/esm/src/typed-data/data/HttpTypedDataDataSource.test.js +1 -1
- package/lib/esm/src/typed-data/data/HttpTypedDataDataSource.test.js.map +3 -3
- package/lib/esm/src/typed-data/domain/DefaultTypedDataContextLoader.js +1 -1
- package/lib/esm/src/typed-data/domain/DefaultTypedDataContextLoader.js.map +3 -3
- package/lib/esm/src/typed-data/domain/DefaultTypedDataContextLoader.test.js +1 -1
- package/lib/esm/src/typed-data/domain/DefaultTypedDataContextLoader.test.js.map +3 -3
- package/lib/types/src/ContextModule.d.ts +2 -4
- package/lib/types/src/ContextModule.d.ts.map +1 -1
- package/lib/types/src/ContextModuleBuilder.d.ts +8 -1
- package/lib/types/src/ContextModuleBuilder.d.ts.map +1 -1
- package/lib/types/src/DefaultContextModule.d.ts +3 -6
- package/lib/types/src/DefaultContextModule.d.ts.map +1 -1
- package/lib/types/src/config/model/ContextModuleConfig.d.ts +7 -0
- package/lib/types/src/config/model/ContextModuleConfig.d.ts.map +1 -1
- package/lib/types/src/di.d.ts.map +1 -1
- package/lib/types/src/dynamic-network/domain/DynamicNetworkContextLoader.d.ts +1 -2
- package/lib/types/src/dynamic-network/domain/DynamicNetworkContextLoader.d.ts.map +1 -1
- package/lib/types/src/index.d.ts +39 -0
- package/lib/types/src/index.d.ts.map +1 -1
- package/lib/types/src/nft/domain/NftContextFieldLoader.d.ts +9 -4
- package/lib/types/src/nft/domain/NftContextFieldLoader.d.ts.map +1 -1
- package/lib/types/src/nft/domain/NftContextFieldLoader.test.d.ts +2 -0
- package/lib/types/src/nft/domain/NftContextFieldLoader.test.d.ts.map +1 -0
- package/lib/types/src/proxy/data/HttpProxyDataSource.d.ts +13 -0
- package/lib/types/src/proxy/data/HttpProxyDataSource.d.ts.map +1 -0
- package/lib/types/src/proxy/data/HttpProxyDataSource.test.d.ts.map +1 -0
- package/lib/types/src/proxy/data/HttpSafeProxyDataSource.d.ts +13 -0
- package/lib/types/src/proxy/data/HttpSafeProxyDataSource.d.ts.map +1 -0
- package/lib/types/src/proxy/data/HttpSafeProxyDataSource.test.d.ts +2 -0
- package/lib/types/src/proxy/data/HttpSafeProxyDataSource.test.d.ts.map +1 -0
- package/lib/types/src/proxy/data/ProxyDataSource.d.ts +15 -0
- package/lib/types/src/proxy/data/ProxyDataSource.d.ts.map +1 -0
- package/lib/types/src/proxy/data/dto/ProxyDelegateCallDto.d.ts.map +1 -0
- package/lib/types/src/proxy/data/dto/ProxyImplementationAddressDto.d.ts.map +1 -0
- package/lib/types/src/proxy/data/dto/SafeProxyImplementationAddressDto.d.ts +8 -0
- package/lib/types/src/proxy/data/dto/SafeProxyImplementationAddressDto.d.ts.map +1 -0
- package/lib/types/src/proxy/di/proxyModuleFactory.d.ts +4 -0
- package/lib/types/src/proxy/di/proxyModuleFactory.d.ts.map +1 -0
- package/lib/types/src/proxy/di/proxyModuleFactory.test.d.ts +2 -0
- package/lib/types/src/proxy/di/proxyModuleFactory.test.d.ts.map +1 -0
- package/lib/types/src/proxy/di/proxyTypes.d.ts +5 -0
- package/lib/types/src/proxy/di/proxyTypes.d.ts.map +1 -0
- package/lib/types/src/proxy/domain/ProxyContextFieldLoader.d.ts +22 -0
- package/lib/types/src/proxy/domain/ProxyContextFieldLoader.d.ts.map +1 -0
- package/lib/types/src/proxy/domain/ProxyContextFieldLoader.test.d.ts +2 -0
- package/lib/types/src/proxy/domain/ProxyContextFieldLoader.test.d.ts.map +1 -0
- package/lib/types/src/proxy/model/ProxyDelegateCall.d.ts +5 -0
- package/lib/types/src/proxy/model/ProxyDelegateCall.d.ts.map +1 -0
- package/lib/types/src/shared/domain/ContextFieldLoader.d.ts +3 -4
- package/lib/types/src/shared/domain/ContextFieldLoader.d.ts.map +1 -1
- package/lib/types/src/shared/domain/ContextLoader.d.ts +1 -2
- package/lib/types/src/shared/domain/ContextLoader.d.ts.map +1 -1
- package/lib/types/src/shared/model/TransactionContext.d.ts +0 -17
- package/lib/types/src/shared/model/TransactionContext.d.ts.map +1 -1
- package/lib/types/src/shared/model/TransactionFieldContext.d.ts +26 -0
- package/lib/types/src/shared/model/TransactionFieldContext.d.ts.map +1 -0
- package/lib/types/src/shared/model/TypedDataClearSignContext.d.ts +33 -1
- package/lib/types/src/shared/model/TypedDataClearSignContext.d.ts.map +1 -1
- package/lib/types/src/shared/model/TypedDataContext.d.ts +3 -0
- package/lib/types/src/shared/model/TypedDataContext.d.ts.map +1 -1
- package/lib/types/src/token/domain/TokenContextFieldLoader.d.ts +8 -4
- package/lib/types/src/token/domain/TokenContextFieldLoader.d.ts.map +1 -1
- package/lib/types/src/token/domain/TokenContextFieldLoader.test.d.ts +2 -0
- package/lib/types/src/token/domain/TokenContextFieldLoader.test.d.ts.map +1 -0
- package/lib/types/src/transaction/data/HttpTransactionDataSource.d.ts.map +1 -1
- package/lib/types/src/transaction/di/transactionModuleFactory.d.ts.map +1 -1
- package/lib/types/src/transaction/di/transactionTypes.d.ts +0 -1
- package/lib/types/src/transaction/di/transactionTypes.d.ts.map +1 -1
- package/lib/types/src/transaction/domain/TransactionContextLoader.d.ts +2 -4
- package/lib/types/src/transaction/domain/TransactionContextLoader.d.ts.map +1 -1
- package/lib/types/src/trusted-name/domain/TrustedNameContextFieldLoader.d.ts +12 -4
- package/lib/types/src/trusted-name/domain/TrustedNameContextFieldLoader.d.ts.map +1 -1
- package/lib/types/src/trusted-name/domain/TrustedNameContextFieldLoader.test.d.ts +2 -0
- package/lib/types/src/trusted-name/domain/TrustedNameContextFieldLoader.test.d.ts.map +1 -0
- package/lib/types/src/typed-data/data/FiltersDto.d.ts +32 -2
- package/lib/types/src/typed-data/data/FiltersDto.d.ts.map +1 -1
- package/lib/types/src/typed-data/data/HttpTypedDataDataSource.d.ts +3 -0
- package/lib/types/src/typed-data/data/HttpTypedDataDataSource.d.ts.map +1 -1
- package/lib/types/src/typed-data/data/HttpTypedDataDataSource.test.d.ts +1 -0
- package/lib/types/src/typed-data/data/HttpTypedDataDataSource.test.d.ts.map +1 -1
- package/lib/types/src/typed-data/data/TypedDataDataSource.d.ts +2 -1
- package/lib/types/src/typed-data/data/TypedDataDataSource.d.ts.map +1 -1
- package/lib/types/src/typed-data/domain/DefaultTypedDataContextLoader.d.ts +12 -1
- package/lib/types/src/typed-data/domain/DefaultTypedDataContextLoader.d.ts.map +1 -1
- package/lib/types/tsconfig.prod.tsbuildinfo +1 -1
- package/package.json +5 -5
- package/lib/cjs/src/transaction/data/HttpProxyDataSource.js +0 -2
- package/lib/cjs/src/transaction/data/HttpProxyDataSource.js.map +0 -7
- package/lib/cjs/src/transaction/data/HttpProxyDataSource.test.js +0 -2
- package/lib/cjs/src/transaction/data/HttpProxyDataSource.test.js.map +0 -7
- package/lib/cjs/src/transaction/model/ProxyDelegateCall.js +0 -2
- package/lib/cjs/src/transaction/model/ProxyDelegateCall.js.map +0 -7
- package/lib/cjs/src/transaction/model/ProxyImplementationAddress.js +0 -2
- package/lib/cjs/src/transaction/model/ProxyImplementationAddress.js.map +0 -7
- package/lib/esm/src/transaction/data/HttpProxyDataSource.js +0 -2
- package/lib/esm/src/transaction/data/HttpProxyDataSource.js.map +0 -7
- package/lib/esm/src/transaction/data/HttpProxyDataSource.test.js +0 -2
- package/lib/esm/src/transaction/data/HttpProxyDataSource.test.js.map +0 -7
- package/lib/esm/src/transaction/model/ProxyImplementationAddress.js +0 -1
- package/lib/types/src/transaction/data/HttpProxyDataSource.d.ts +0 -33
- package/lib/types/src/transaction/data/HttpProxyDataSource.d.ts.map +0 -1
- package/lib/types/src/transaction/data/HttpProxyDataSource.test.d.ts.map +0 -1
- package/lib/types/src/transaction/data/dto/ProxyDelegateCallDto.d.ts.map +0 -1
- package/lib/types/src/transaction/data/dto/ProxyImplementationAddressDto.d.ts.map +0 -1
- package/lib/types/src/transaction/model/ProxyDelegateCall.d.ts +0 -5
- package/lib/types/src/transaction/model/ProxyDelegateCall.d.ts.map +0 -1
- package/lib/types/src/transaction/model/ProxyImplementationAddress.d.ts +0 -4
- package/lib/types/src/transaction/model/ProxyImplementationAddress.d.ts.map +0 -1
- /package/lib/cjs/src/{transaction → proxy}/data/dto/ProxyDelegateCallDto.js +0 -0
- /package/lib/cjs/src/{transaction → proxy}/data/dto/ProxyImplementationAddressDto.js +0 -0
- /package/lib/esm/src/{transaction/data/dto/ProxyDelegateCallDto.js.map → proxy/data/ProxyDataSource.js.map} +0 -0
- /package/lib/esm/src/{transaction → proxy}/data/dto/ProxyDelegateCallDto.js +0 -0
- /package/lib/esm/src/{transaction/data/dto/ProxyImplementationAddressDto.js.map → proxy/data/dto/ProxyDelegateCallDto.js.map} +0 -0
- /package/lib/esm/src/{transaction → proxy}/data/dto/ProxyImplementationAddressDto.js +0 -0
- /package/lib/esm/src/{transaction/model/ProxyDelegateCall.js.map → proxy/data/dto/ProxyImplementationAddressDto.js.map} +0 -0
- /package/lib/esm/src/{transaction/model/ProxyImplementationAddress.js.map → proxy/data/dto/SafeProxyImplementationAddressDto.js.map} +0 -0
- /package/lib/esm/src/{transaction → proxy}/model/ProxyDelegateCall.js +0 -0
- /package/lib/types/src/{transaction → proxy}/data/HttpProxyDataSource.test.d.ts +0 -0
- /package/lib/types/src/{transaction → proxy}/data/dto/ProxyDelegateCallDto.d.ts +0 -0
- /package/lib/types/src/{transaction → proxy}/data/dto/ProxyImplementationAddressDto.d.ts +0 -0
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../../src/proxy/data/HttpProxyDataSource.test.ts"],
|
|
4
|
+
"sourcesContent": ["import axios from \"axios\";\n\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 { type ProxyDelegateCallDto } from \"./dto/ProxyDelegateCallDto\";\nimport { HttpProxyDataSource } from \"./HttpProxyDataSource\";\nimport { type ProxyDataSource } from \"./ProxyDataSource\";\n\nvi.mock(\"axios\");\n\nconst config = {\n metadataServiceDomain: {\n url: \"https://metadata.api.live.ledger.com\",\n },\n originToken: \"test-origin-token\",\n} as ContextModuleConfig;\n\ndescribe(\"HttpProxyDataSource\", () => {\n let datasource: ProxyDataSource;\n\n beforeAll(() => {\n datasource = new HttpProxyDataSource(config);\n vi.clearAllMocks();\n });\n\n beforeEach(() => {\n vi.clearAllMocks();\n });\n\n const validParams = {\n proxyAddress: \"0x1234567890123456789012345678901234567890\",\n chainId: 1,\n challenge: \"test-challenge\",\n calldata: \"0xabcdef\",\n };\n\n const validDto: ProxyDelegateCallDto = {\n addresses: [\"0x9876543210987654321098765432109876543210\"],\n signedDescriptor: \"signed-descriptor-data\",\n };\n\n describe(\"getProxyImplementationAddress\", () => {\n it(\"should call axios with correct URL, headers, and data\", async () => {\n // GIVEN\n const version = `context-module/${PACKAGE.version}`;\n const requestSpy = vi.fn(() => Promise.resolve({ data: validDto }));\n vi.spyOn(axios, \"request\").mockImplementation(requestSpy);\n\n // WHEN\n await datasource.getProxyImplementationAddress(validParams);\n\n // THEN\n expect(requestSpy).toHaveBeenCalledWith({\n method: \"POST\",\n url: `${config.metadataServiceDomain.url}/v2/ethereum/${validParams.chainId}/contract/proxy/delegate`,\n headers: {\n [LEDGER_CLIENT_VERSION_HEADER]: version,\n [LEDGER_ORIGIN_TOKEN_HEADER]: config.originToken,\n },\n data: {\n proxy: validParams.proxyAddress,\n data: validParams.calldata,\n challenge: validParams.challenge,\n },\n });\n });\n\n it(\"should return Right with proxy implementation data when request succeeds with valid DTO\", async () => {\n // GIVEN\n vi.spyOn(axios, \"request\").mockResolvedValue({ data: validDto });\n\n // WHEN\n const result =\n await datasource.getProxyImplementationAddress(validParams);\n\n // THEN\n expect(result.isRight()).toBe(true);\n expect(result.extract()).toEqual({\n implementationAddress: validDto.addresses[0],\n signedDescriptor: validDto.signedDescriptor,\n });\n });\n\n it(\"should return Right with first address when multiple addresses are provided\", async () => {\n // GIVEN\n const dtoWithMultipleAddresses: ProxyDelegateCallDto = {\n addresses: [\n \"0x9876543210987654321098765432109876543210\",\n \"0x1111111111111111111111111111111111111111\",\n ],\n signedDescriptor: \"signed-descriptor-data\",\n };\n vi.spyOn(axios, \"request\").mockResolvedValue({\n data: dtoWithMultipleAddresses,\n });\n\n // WHEN\n const result =\n await datasource.getProxyImplementationAddress(validParams);\n\n // THEN\n expect(result.isRight()).toBe(true);\n expect(result.extract()).toEqual({\n implementationAddress: dtoWithMultipleAddresses.addresses[0],\n signedDescriptor: dtoWithMultipleAddresses.signedDescriptor,\n });\n });\n\n it(\"should return Left with error when axios throws an error\", async () => {\n // GIVEN\n vi.spyOn(axios, \"request\").mockRejectedValue(new Error(\"Network error\"));\n\n // WHEN\n const result =\n await datasource.getProxyImplementationAddress(validParams);\n\n // THEN\n expect(result.isLeft()).toBe(true);\n expect(result.extract()).toEqual(\n new Error(\n \"[ContextModule] HttpProxyDataSource: Failed to fetch delegate proxy\",\n ),\n );\n });\n\n it(\"should return Left with error when response data is undefined\", async () => {\n // GIVEN\n vi.spyOn(axios, \"request\").mockResolvedValue({ data: undefined });\n\n // WHEN\n const result =\n await datasource.getProxyImplementationAddress(validParams);\n\n // THEN\n expect(result.isLeft()).toBe(true);\n expect(result.extract()).toEqual(\n new Error(\n `[ContextModule] HttpProxyDataSource: No data received for proxy ${validParams.proxyAddress} on chain ${validParams.chainId}`,\n ),\n );\n });\n\n it(\"should return Left with error when response data is null\", async () => {\n // GIVEN\n vi.spyOn(axios, \"request\").mockResolvedValue({ data: null });\n\n // WHEN\n const result =\n await datasource.getProxyImplementationAddress(validParams);\n\n // THEN\n expect(result.isLeft()).toBe(true);\n expect(result.extract()).toEqual(\n new Error(\n `[ContextModule] HttpProxyDataSource: No data received for proxy ${validParams.proxyAddress} on chain ${validParams.chainId}`,\n ),\n );\n });\n\n it(\"should return Left with error when addresses field is missing\", async () => {\n // GIVEN\n const { addresses: _, ...invalidDto } = validDto;\n vi.spyOn(axios, \"request\").mockResolvedValue({ data: invalidDto });\n\n // WHEN\n const result =\n await datasource.getProxyImplementationAddress(validParams);\n\n // THEN\n expect(result.isLeft()).toBe(true);\n expect(result.extract()).toEqual(\n new Error(\n `[ContextModule] HttpProxyDataSource: Invalid proxy delegate call response format for proxy ${validParams.proxyAddress} on chain ${validParams.chainId}`,\n ),\n );\n });\n\n it(\"should return Left with error when signedDescriptor is missing\", async () => {\n // GIVEN\n const { signedDescriptor: _, ...invalidDto } = validDto;\n vi.spyOn(axios, \"request\").mockResolvedValue({ data: invalidDto });\n\n // WHEN\n const result =\n await datasource.getProxyImplementationAddress(validParams);\n\n // THEN\n expect(result.isLeft()).toBe(true);\n expect(result.extract()).toEqual(\n new Error(\n `[ContextModule] HttpProxyDataSource: Invalid proxy delegate call response format for proxy ${validParams.proxyAddress} on chain ${validParams.chainId}`,\n ),\n );\n });\n\n it(\"should return Left with error when addresses is not an array\", async () => {\n // GIVEN\n const invalidDto = { ...validDto, addresses: \"not-an-array\" };\n vi.spyOn(axios, \"request\").mockResolvedValue({ data: invalidDto });\n\n // WHEN\n const result =\n await datasource.getProxyImplementationAddress(validParams);\n\n // THEN\n expect(result.isLeft()).toBe(true);\n expect(result.extract()).toEqual(\n new Error(\n `[ContextModule] HttpProxyDataSource: Invalid proxy delegate call response format for proxy ${validParams.proxyAddress} on chain ${validParams.chainId}`,\n ),\n );\n });\n\n it(\"should return Left with error when addresses array contains non-string values\", async () => {\n // GIVEN\n const invalidDto = { ...validDto, addresses: [123, \"valid-address\"] };\n vi.spyOn(axios, \"request\").mockResolvedValue({ data: invalidDto });\n\n // WHEN\n const result =\n await datasource.getProxyImplementationAddress(validParams);\n\n // THEN\n expect(result.isLeft()).toBe(true);\n expect(result.extract()).toEqual(\n new Error(\n `[ContextModule] HttpProxyDataSource: Invalid proxy delegate call response format for proxy ${validParams.proxyAddress} on chain ${validParams.chainId}`,\n ),\n );\n });\n\n it(\"should return Left with error when signedDescriptor is not a string\", async () => {\n // GIVEN\n const invalidDto = { ...validDto, signedDescriptor: 123 };\n vi.spyOn(axios, \"request\").mockResolvedValue({ data: invalidDto });\n\n // WHEN\n const result =\n await datasource.getProxyImplementationAddress(validParams);\n\n // THEN\n expect(result.isLeft()).toBe(true);\n expect(result.extract()).toEqual(\n new Error(\n `[ContextModule] HttpProxyDataSource: Invalid proxy delegate call response format for proxy ${validParams.proxyAddress} on chain ${validParams.chainId}`,\n ),\n );\n });\n\n it(\"should return Left with error when addresses array is empty\", async () => {\n // GIVEN\n const invalidDto: ProxyDelegateCallDto = {\n addresses: [],\n signedDescriptor: \"signed-descriptor-data\",\n };\n vi.spyOn(axios, \"request\").mockResolvedValue({ data: invalidDto });\n\n // WHEN\n const result =\n await datasource.getProxyImplementationAddress(validParams);\n\n // THEN\n expect(result.isLeft()).toBe(true);\n expect(result.extract()).toEqual(\n new Error(\n `[ContextModule] HttpProxyDataSource: No implementation address found for proxy ${validParams.proxyAddress} on chain ${validParams.chainId}`,\n ),\n );\n });\n\n it(\"should return Left with error when response is not an object\", async () => {\n // GIVEN\n vi.spyOn(axios, \"request\").mockResolvedValue({ data: \"not an object\" });\n\n // WHEN\n const result =\n await datasource.getProxyImplementationAddress(validParams);\n\n // THEN\n expect(result.isLeft()).toBe(true);\n expect(result.extract()).toEqual(\n new Error(\n `[ContextModule] HttpProxyDataSource: Invalid proxy delegate call response format for proxy ${validParams.proxyAddress} on chain ${validParams.chainId}`,\n ),\n );\n });\n\n it(\"should handle different chainId values correctly\", async () => {\n // GIVEN\n const paramsWithDifferentChainId = { ...validParams, chainId: 137 };\n vi.spyOn(axios, \"request\").mockResolvedValue({ data: validDto });\n\n // WHEN\n const result = await datasource.getProxyImplementationAddress(\n paramsWithDifferentChainId,\n );\n\n // THEN\n expect(result.isRight()).toBe(true);\n expect(axios.request).toHaveBeenCalledWith(\n expect.objectContaining({\n url: `${config.metadataServiceDomain.url}/v2/ethereum/137/contract/proxy/delegate`,\n }),\n );\n });\n\n it(\"should handle different proxy addresses correctly\", async () => {\n // GIVEN\n const differentProxyAddress =\n \"0xabcdefabcdefabcdefabcdefabcdefabcdefabcd\";\n const paramsWithDifferentAddress = {\n ...validParams,\n proxyAddress: differentProxyAddress,\n };\n vi.spyOn(axios, \"request\").mockResolvedValue({ data: validDto });\n\n // WHEN\n const result = await datasource.getProxyImplementationAddress(\n paramsWithDifferentAddress,\n );\n\n // THEN\n expect(result.isRight()).toBe(true);\n expect(axios.request).toHaveBeenCalledWith(\n expect.objectContaining({\n data: expect.objectContaining({\n proxy: differentProxyAddress,\n }),\n }),\n );\n });\n\n it(\"should handle different calldata values correctly\", async () => {\n // GIVEN\n const customCalldata = \"0x123456789abcdef\";\n const paramsWithCustomCalldata = {\n ...validParams,\n calldata: customCalldata,\n };\n vi.spyOn(axios, \"request\").mockResolvedValue({ data: validDto });\n\n // WHEN\n const result = await datasource.getProxyImplementationAddress(\n paramsWithCustomCalldata,\n );\n\n // THEN\n expect(result.isRight()).toBe(true);\n expect(axios.request).toHaveBeenCalledWith(\n expect.objectContaining({\n data: expect.objectContaining({\n data: customCalldata,\n }),\n }),\n );\n });\n\n it(\"should pass challenge parameter correctly\", async () => {\n // GIVEN\n const customChallenge = \"custom-challenge-string\";\n const paramsWithCustomChallenge = {\n ...validParams,\n challenge: customChallenge,\n };\n vi.spyOn(axios, \"request\").mockResolvedValue({ data: validDto });\n\n // WHEN\n const result = await datasource.getProxyImplementationAddress(\n paramsWithCustomChallenge,\n );\n\n // THEN\n expect(result.isRight()).toBe(true);\n expect(axios.request).toHaveBeenCalledWith(\n expect.objectContaining({\n data: expect.objectContaining({\n challenge: customChallenge,\n }),\n }),\n );\n });\n });\n});\n"],
|
|
5
|
+
"mappings": "AAAA,OAAOA,MAAW,QAGlB,OACE,gCAAAC,EACA,8BAAAC,MACK,gCACP,OAAOC,MAAa,qBAGpB,OAAS,uBAAAC,MAA2B,wBAGpC,GAAG,KAAK,OAAO,EAEf,MAAMC,EAAS,CACb,sBAAuB,CACrB,IAAK,sCACP,EACA,YAAa,mBACf,EAEA,SAAS,sBAAuB,IAAM,CACpC,IAAIC,EAEJ,UAAU,IAAM,CACdA,EAAa,IAAIF,EAAoBC,CAAM,EAC3C,GAAG,cAAc,CACnB,CAAC,EAED,WAAW,IAAM,CACf,GAAG,cAAc,CACnB,CAAC,EAED,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E,KAAMQ,CAAS,CAAC,EAG/D,MAAMG,EAAS,MAAML,EAAW,8BAC9Be,CACF,EAGA,OAAOV,EAAO,QAAQ,CAAC,EAAE,KAAK,EAAI,EAClC,OAAOX,EAAM,OAAO,EAAE,qBACpB,OAAO,iBAAiB,CACtB,KAAM,OAAO,iBAAiB,CAC5B,UAAWoB,CACb,CAAC,CACH,CAAC,CACH,CACF,CAAC,CACH,CAAC,CACH,CAAC",
|
|
6
|
+
"names": ["axios", "LEDGER_CLIENT_VERSION_HEADER", "LEDGER_ORIGIN_TOKEN_HEADER", "PACKAGE", "HttpProxyDataSource", "config", "datasource", "validParams", "validDto", "version", "requestSpy", "result", "dtoWithMultipleAddresses", "_", "invalidDto", "paramsWithDifferentChainId", "differentProxyAddress", "paramsWithDifferentAddress", "customCalldata", "paramsWithCustomCalldata", "customChallenge", "paramsWithCustomChallenge"]
|
|
7
|
+
}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
var f=Object.defineProperty;var y=Object.getOwnPropertyDescriptor;var p=(n,e,t,o)=>{for(var r=o>1?void 0:o?y(e,t):e,i=n.length-1,m;i>=0;i--)(m=n[i])&&(r=(o?m(e,t,r):m(r))||r);return o&&r&&f(e,t,r),r},a=(n,e)=>(t,o)=>e(t,o,n);import c from"axios";import{inject as x,injectable as l}from"inversify";import{Left as d,Right as A}from"purify-ts";import{configTypes as E}from"../../config/di/configTypes";import{LEDGER_CLIENT_VERSION_HEADER as g,LEDGER_ORIGIN_TOKEN_HEADER as P}from"../../shared/constant/HttpHeaders";import D from"../../../package.json";let s=class{constructor(e){this.config=e}async getProxyImplementationAddress({proxyAddress:e,chainId:t,challenge:o}){let r;try{r=(await c.request({method:"GET",url:` https://nft.aws.stg.ldg-tech.com/v3/ethereum/${t}/contract/proxy/${e}`,headers:{[g]:`context-module/${D.version}`,[P]:this.config.originToken},params:{challenge:o,resolver:"SAFE_GATEWAY"}})).data}catch{return d(new Error("[ContextModule] HttpSafeProxyDataSource: Failed to fetch safe proxy implementation"))}return r?this.isSafeProxyImplementationAddressDto(r)?A({implementationAddress:r.implementationAddress,signedDescriptor:r.signedDescriptor}):d(new Error(`[ContextModule] HttpSafeProxyDataSource: Invalid safe proxy response format for proxy ${e} on chain ${t}`)):d(new Error(`[ContextModule] HttpSafeProxyDataSource: No data received for proxy ${e} on chain ${t}`))}isSafeProxyImplementationAddressDto(e){return typeof e=="object"&&e!==null&&"proxyAddress"in e&&"implementationAddress"in e&&"standard"in e&&"signedDescriptor"in e&&"providedBy"in e&&typeof e.proxyAddress=="string"&&typeof e.implementationAddress=="string"&&typeof e.standard=="string"&&typeof e.signedDescriptor=="string"&&typeof e.providedBy=="string"}};s=p([l(),a(0,x(E.Config))],s);export{s as HttpSafeProxyDataSource};
|
|
2
|
+
//# sourceMappingURL=HttpSafeProxyDataSource.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../../src/proxy/data/HttpSafeProxyDataSource.ts"],
|
|
4
|
+
"sourcesContent": ["import axios from \"axios\";\nimport { inject, injectable } from \"inversify\";\nimport { 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 { SafeProxyImplementationAddressDto } from \"./dto/SafeProxyImplementationAddressDto\";\nimport {\n GetProxyImplementationAddressParam,\n type ProxyDataSource,\n ProxyImplementationAddress,\n} from \"./ProxyDataSource\";\n\n@injectable()\nexport class HttpSafeProxyDataSource implements ProxyDataSource {\n constructor(\n @inject(configTypes.Config) private readonly config: ContextModuleConfig,\n ) {}\n\n async getProxyImplementationAddress({\n proxyAddress,\n chainId,\n challenge,\n }: GetProxyImplementationAddressParam): Promise<\n Either<Error, ProxyImplementationAddress>\n > {\n let dto: SafeProxyImplementationAddressDto | undefined;\n try {\n const response = await axios.request<SafeProxyImplementationAddressDto>({\n method: \"GET\",\n // url: `${this.config.metadataServiceDomain.url}/v3/ethereum/${chainId}/contract/proxy/${proxyAddress}`,\n // TODO: replace with the correct url\n url: ` https://nft.aws.stg.ldg-tech.com/v3/ethereum/${chainId}/contract/proxy/${proxyAddress}`,\n headers: {\n [LEDGER_CLIENT_VERSION_HEADER]: `context-module/${PACKAGE.version}`,\n [LEDGER_ORIGIN_TOKEN_HEADER]: this.config.originToken,\n },\n params: {\n challenge,\n resolver: \"SAFE_GATEWAY\",\n },\n });\n dto = response.data;\n } catch (_error) {\n return Left(\n new Error(\n `[ContextModule] HttpSafeProxyDataSource: Failed to fetch safe proxy implementation`,\n ),\n );\n }\n\n if (!dto) {\n return Left(\n new Error(\n `[ContextModule] HttpSafeProxyDataSource: No data received for proxy ${proxyAddress} on chain ${chainId}`,\n ),\n );\n }\n\n if (!this.isSafeProxyImplementationAddressDto(dto)) {\n return Left(\n new Error(\n `[ContextModule] HttpSafeProxyDataSource: Invalid safe proxy response format for proxy ${proxyAddress} on chain ${chainId}`,\n ),\n );\n }\n\n return Right({\n implementationAddress: dto.implementationAddress,\n signedDescriptor: dto.signedDescriptor,\n });\n }\n\n /**\n * Type guard to validate SafeProxyImplementationAddressDto\n */\n private isSafeProxyImplementationAddressDto(\n value: unknown,\n ): value is SafeProxyImplementationAddressDto {\n return (\n typeof value === \"object\" &&\n value !== null &&\n \"proxyAddress\" in value &&\n \"implementationAddress\" in value &&\n \"standard\" in value &&\n \"signedDescriptor\" in value &&\n \"providedBy\" in value &&\n typeof value.proxyAddress === \"string\" &&\n typeof value.implementationAddress === \"string\" &&\n typeof value.standard === \"string\" &&\n typeof value.signedDescriptor === \"string\" &&\n typeof value.providedBy === \"string\"\n );\n }\n}\n"],
|
|
5
|
+
"mappings": "iOAAA,OAAOA,MAAW,QAClB,OAAS,UAAAC,EAAQ,cAA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+
"names": ["axios", "inject", "injectable", "Left", "Right", "configTypes", "LEDGER_CLIENT_VERSION_HEADER", "LEDGER_ORIGIN_TOKEN_HEADER", "PACKAGE", "HttpSafeProxyDataSource", "config", "proxyAddress", "chainId", "challenge", "dto", "axios", "LEDGER_CLIENT_VERSION_HEADER", "PACKAGE", "LEDGER_ORIGIN_TOKEN_HEADER", "Left", "Right", "value", "__decorateClass", "injectable", "__decorateParam", "inject", "configTypes"]
|
|
7
|
+
}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import o from"axios";import{LEDGER_CLIENT_VERSION_HEADER as d,LEDGER_ORIGIN_TOKEN_HEADER as c}from"../../shared/constant/HttpHeaders";import l from"../../../package.json";import{HttpSafeProxyDataSource as p}from"./HttpSafeProxyDataSource";vi.mock("axios");const i={metadataServiceDomain:{url:"https://metadata.api.live.ledger.com"},originToken:"test-origin-token"};describe("HttpSafeProxyDataSource",()=>{let a;beforeAll(()=>{a=new p(i),vi.clearAllMocks()}),beforeEach(()=>{vi.clearAllMocks()});const e={proxyAddress:"0x1234567890123456789012345678901234567890",chainId:1,challenge:"test-challenge",calldata:"0xabcdef"},n={proxyAddress:"0x1234567890123456789012345678901234567890",implementationAddress:"0x9876543210987654321098765432109876543210",standard:"EIP-1967",signedDescriptor:"signed-descriptor-data",providedBy:"SAFE_GATEWAY"};describe("getProxyImplementationAddress",()=>{it("should call axios with correct URL, headers, and parameters",async()=>{const t=`context-module/${l.version}`,r=vi.fn(()=>Promise.resolve({data:n}));vi.spyOn(o,"request").mockImplementation(r),await a.getProxyImplementationAddress(e),expect(r).toHaveBeenCalledWith({method:"GET",url:`${i.metadataServiceDomain.url}/v3/ethereum/${e.chainId}/contract/proxy/${e.proxyAddress}`,headers:{[d]:t,[c]:i.originToken},params:{challenge:e.challenge,resolver:"SAFE_GATEWAY"}})}),it("should return Right with proxy implementation data when request succeeds with valid DTO",async()=>{vi.spyOn(o,"request").mockResolvedValue({data:n});const t=await a.getProxyImplementationAddress(e);expect(t.isRight()).toBe(!0),expect(t.extract()).toEqual({implementationAddress:n.implementationAddress,signedDescriptor:n.signedDescriptor})}),it("should return Left with error when axios throws an error",async()=>{vi.spyOn(o,"request").mockRejectedValue(new Error("Network error"));const t=await a.getProxyImplementationAddress(e);expect(t.isLeft()).toBe(!0),expect(t.extract()).toEqual(new Error("[ContextModule] HttpSafeProxyDataSource: Failed to fetch safe proxy implementation"))}),it("should return Left with error when response data is undefined",async()=>{vi.spyOn(o,"request").mockResolvedValue({data:void 0});const t=await a.getProxyImplementationAddress(e);expect(t.isLeft()).toBe(!0),expect(t.extract()).toEqual(new Error(`[ContextModule] HttpSafeProxyDataSource: No data received for proxy ${e.proxyAddress} on chain ${e.chainId}`))}),it("should return Left with error when response data is null",async()=>{vi.spyOn(o,"request").mockResolvedValue({data:null});const t=await a.getProxyImplementationAddress(e);expect(t.isLeft()).toBe(!0),expect(t.extract()).toEqual(new Error(`[ContextModule] HttpSafeProxyDataSource: No data received for proxy ${e.proxyAddress} on chain ${e.chainId}`))}),it("should return Left with error when proxyAddress is missing",async()=>{const{proxyAddress:t,...r}=n;vi.spyOn(o,"request").mockResolvedValue({data:r});const s=await a.getProxyImplementationAddress(e);expect(s.isLeft()).toBe(!0),expect(s.extract()).toEqual(new Error(`[ContextModule] HttpSafeProxyDataSource: Invalid safe proxy response format for proxy ${e.proxyAddress} on chain ${e.chainId}`))}),it("should return Left with error when implementationAddress is missing",async()=>{const{implementationAddress:t,...r}=n;vi.spyOn(o,"request").mockResolvedValue({data:r});const s=await a.getProxyImplementationAddress(e);expect(s.isLeft()).toBe(!0),expect(s.extract()).toEqual(new Error(`[ContextModule] HttpSafeProxyDataSource: Invalid safe proxy response format for proxy ${e.proxyAddress} on chain ${e.chainId}`))}),it("should return Left with error when standard is missing",async()=>{const{standard:t,...r}=n;vi.spyOn(o,"request").mockResolvedValue({data:r});const s=await a.getProxyImplementationAddress(e);expect(s.isLeft()).toBe(!0),expect(s.extract()).toEqual(new Error(`[ContextModule] HttpSafeProxyDataSource: Invalid safe proxy response format for proxy ${e.proxyAddress} on chain ${e.chainId}`))}),it("should return Left with error when signedDescriptor is missing",async()=>{const{signedDescriptor:t,...r}=n;vi.spyOn(o,"request").mockResolvedValue({data:r});const s=await a.getProxyImplementationAddress(e);expect(s.isLeft()).toBe(!0),expect(s.extract()).toEqual(new Error(`[ContextModule] HttpSafeProxyDataSource: Invalid safe proxy response format for proxy ${e.proxyAddress} on chain ${e.chainId}`))}),it("should return Left with error when providedBy is missing",async()=>{const{providedBy:t,...r}=n;vi.spyOn(o,"request").mockResolvedValue({data:r});const s=await a.getProxyImplementationAddress(e);expect(s.isLeft()).toBe(!0),expect(s.extract()).toEqual(new Error(`[ContextModule] HttpSafeProxyDataSource: Invalid safe proxy response format for proxy ${e.proxyAddress} on chain ${e.chainId}`))}),it("should return Left with error when proxyAddress is not a string",async()=>{const t={...n,proxyAddress:123};vi.spyOn(o,"request").mockResolvedValue({data:t});const r=await a.getProxyImplementationAddress(e);expect(r.isLeft()).toBe(!0),expect(r.extract()).toEqual(new Error(`[ContextModule] HttpSafeProxyDataSource: Invalid safe proxy response format for proxy ${e.proxyAddress} on chain ${e.chainId}`))}),it("should return Left with error when implementationAddress is not a string",async()=>{const t={...n,implementationAddress:null};vi.spyOn(o,"request").mockResolvedValue({data:t});const r=await a.getProxyImplementationAddress(e);expect(r.isLeft()).toBe(!0),expect(r.extract()).toEqual(new Error(`[ContextModule] HttpSafeProxyDataSource: Invalid safe proxy response format for proxy ${e.proxyAddress} on chain ${e.chainId}`))}),it("should return Left with error when standard is not a string",async()=>{const t={...n,standard:[]};vi.spyOn(o,"request").mockResolvedValue({data:t});const r=await a.getProxyImplementationAddress(e);expect(r.isLeft()).toBe(!0),expect(r.extract()).toEqual(new Error(`[ContextModule] HttpSafeProxyDataSource: Invalid safe proxy response format for proxy ${e.proxyAddress} on chain ${e.chainId}`))}),it("should return Left with error when signedDescriptor is not a string",async()=>{const t={...n,signedDescriptor:{}};vi.spyOn(o,"request").mockResolvedValue({data:t});const r=await a.getProxyImplementationAddress(e);expect(r.isLeft()).toBe(!0),expect(r.extract()).toEqual(new Error(`[ContextModule] HttpSafeProxyDataSource: Invalid safe proxy response format for proxy ${e.proxyAddress} on chain ${e.chainId}`))}),it("should return Left with error when providedBy is not a string",async()=>{const t={...n,providedBy:!0};vi.spyOn(o,"request").mockResolvedValue({data:t});const r=await a.getProxyImplementationAddress(e);expect(r.isLeft()).toBe(!0),expect(r.extract()).toEqual(new Error(`[ContextModule] HttpSafeProxyDataSource: Invalid safe proxy response format for proxy ${e.proxyAddress} on chain ${e.chainId}`))}),it("should return Left with error when response is not an object",async()=>{vi.spyOn(o,"request").mockResolvedValue({data:"not an object"});const t=await a.getProxyImplementationAddress(e);expect(t.isLeft()).toBe(!0),expect(t.extract()).toEqual(new Error(`[ContextModule] HttpSafeProxyDataSource: Invalid safe proxy response format for proxy ${e.proxyAddress} on chain ${e.chainId}`))}),it("should return Left with error when response is null",async()=>{vi.spyOn(o,"request").mockResolvedValue({data:null});const t=await a.getProxyImplementationAddress(e);expect(t.isLeft()).toBe(!0),expect(t.extract()).toEqual(new Error(`[ContextModule] HttpSafeProxyDataSource: No data received for proxy ${e.proxyAddress} on chain ${e.chainId}`))}),it("should handle different chainId values correctly",async()=>{const t={...e,chainId:137};vi.spyOn(o,"request").mockResolvedValue({data:n});const r=await a.getProxyImplementationAddress(t);expect(r.isRight()).toBe(!0),expect(o.request).toHaveBeenCalledWith(expect.objectContaining({url:`${i.metadataServiceDomain.url}/v3/ethereum/137/contract/proxy/${e.proxyAddress}`}))}),it("should handle different proxy addresses correctly",async()=>{const t="0xabcdefabcdefabcdefabcdefabcdefabcdefabcd",r={...e,proxyAddress:t};vi.spyOn(o,"request").mockResolvedValue({data:n});const s=await a.getProxyImplementationAddress(r);expect(s.isRight()).toBe(!0),expect(o.request).toHaveBeenCalledWith(expect.objectContaining({url:`${i.metadataServiceDomain.url}/v3/ethereum/${e.chainId}/contract/proxy/${t}`}))}),it("should pass challenge parameter correctly",async()=>{const t="custom-challenge-string",r={...e,challenge:t};vi.spyOn(o,"request").mockResolvedValue({data:n});const s=await a.getProxyImplementationAddress(r);expect(s.isRight()).toBe(!0),expect(o.request).toHaveBeenCalledWith(expect.objectContaining({params:{challenge:t,resolver:"SAFE_GATEWAY"}}))})})});
|
|
2
|
+
//# sourceMappingURL=HttpSafeProxyDataSource.test.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../../src/proxy/data/HttpSafeProxyDataSource.test.ts"],
|
|
4
|
+
"sourcesContent": ["import axios from \"axios\";\n\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 { type SafeProxyImplementationAddressDto } from \"./dto/SafeProxyImplementationAddressDto\";\nimport { HttpSafeProxyDataSource } from \"./HttpSafeProxyDataSource\";\nimport { type ProxyDataSource } from \"./ProxyDataSource\";\n\nvi.mock(\"axios\");\n\nconst config = {\n metadataServiceDomain: {\n url: \"https://metadata.api.live.ledger.com\",\n },\n originToken: \"test-origin-token\",\n} as ContextModuleConfig;\n\ndescribe(\"HttpSafeProxyDataSource\", () => {\n let datasource: ProxyDataSource;\n\n beforeAll(() => {\n datasource = new HttpSafeProxyDataSource(config);\n vi.clearAllMocks();\n });\n\n beforeEach(() => {\n vi.clearAllMocks();\n });\n\n const validParams = {\n proxyAddress: \"0x1234567890123456789012345678901234567890\",\n chainId: 1,\n challenge: \"test-challenge\",\n calldata: \"0xabcdef\",\n };\n\n const validDto: SafeProxyImplementationAddressDto = {\n proxyAddress: \"0x1234567890123456789012345678901234567890\",\n implementationAddress: \"0x9876543210987654321098765432109876543210\",\n standard: \"EIP-1967\",\n signedDescriptor: \"signed-descriptor-data\",\n providedBy: \"SAFE_GATEWAY\",\n };\n\n describe(\"getProxyImplementationAddress\", () => {\n it(\"should call axios with correct URL, headers, and parameters\", async () => {\n // GIVEN\n const version = `context-module/${PACKAGE.version}`;\n const requestSpy = vi.fn(() => Promise.resolve({ data: validDto }));\n vi.spyOn(axios, \"request\").mockImplementation(requestSpy);\n\n // WHEN\n await datasource.getProxyImplementationAddress(validParams);\n\n // THEN\n expect(requestSpy).toHaveBeenCalledWith({\n method: \"GET\",\n url: `${config.metadataServiceDomain.url}/v3/ethereum/${validParams.chainId}/contract/proxy/${validParams.proxyAddress}`,\n headers: {\n [LEDGER_CLIENT_VERSION_HEADER]: version,\n [LEDGER_ORIGIN_TOKEN_HEADER]: config.originToken,\n },\n params: {\n challenge: validParams.challenge,\n resolver: \"SAFE_GATEWAY\",\n },\n });\n });\n\n it(\"should return Right with proxy implementation data when request succeeds with valid DTO\", async () => {\n // GIVEN\n vi.spyOn(axios, \"request\").mockResolvedValue({ data: validDto });\n\n // WHEN\n const result =\n await datasource.getProxyImplementationAddress(validParams);\n\n // THEN\n expect(result.isRight()).toBe(true);\n expect(result.extract()).toEqual({\n implementationAddress: validDto.implementationAddress,\n signedDescriptor: validDto.signedDescriptor,\n });\n });\n\n it(\"should return Left with error when axios throws an error\", async () => {\n // GIVEN\n vi.spyOn(axios, \"request\").mockRejectedValue(new Error(\"Network error\"));\n\n // WHEN\n const result =\n await datasource.getProxyImplementationAddress(validParams);\n\n // THEN\n expect(result.isLeft()).toBe(true);\n expect(result.extract()).toEqual(\n new Error(\n \"[ContextModule] HttpSafeProxyDataSource: Failed to fetch safe proxy implementation\",\n ),\n );\n });\n\n it(\"should return Left with error when response data is undefined\", async () => {\n // GIVEN\n vi.spyOn(axios, \"request\").mockResolvedValue({ data: undefined });\n\n // WHEN\n const result =\n await datasource.getProxyImplementationAddress(validParams);\n\n // THEN\n expect(result.isLeft()).toBe(true);\n expect(result.extract()).toEqual(\n new Error(\n `[ContextModule] HttpSafeProxyDataSource: No data received for proxy ${validParams.proxyAddress} on chain ${validParams.chainId}`,\n ),\n );\n });\n\n it(\"should return Left with error when response data is null\", async () => {\n // GIVEN\n vi.spyOn(axios, \"request\").mockResolvedValue({ data: null });\n\n // WHEN\n const result =\n await datasource.getProxyImplementationAddress(validParams);\n\n // THEN\n expect(result.isLeft()).toBe(true);\n expect(result.extract()).toEqual(\n new Error(\n `[ContextModule] HttpSafeProxyDataSource: No data received for proxy ${validParams.proxyAddress} on chain ${validParams.chainId}`,\n ),\n );\n });\n\n it(\"should return Left with error when proxyAddress is missing\", async () => {\n // GIVEN\n const { proxyAddress: _, ...invalidDto } = validDto;\n vi.spyOn(axios, \"request\").mockResolvedValue({ data: invalidDto });\n\n // WHEN\n const result =\n await datasource.getProxyImplementationAddress(validParams);\n\n // THEN\n expect(result.isLeft()).toBe(true);\n expect(result.extract()).toEqual(\n new Error(\n `[ContextModule] HttpSafeProxyDataSource: Invalid safe proxy response format for proxy ${validParams.proxyAddress} on chain ${validParams.chainId}`,\n ),\n );\n });\n\n it(\"should return Left with error when implementationAddress is missing\", async () => {\n // GIVEN\n const { implementationAddress: _, ...invalidDto } = validDto;\n vi.spyOn(axios, \"request\").mockResolvedValue({ data: invalidDto });\n\n // WHEN\n const result =\n await datasource.getProxyImplementationAddress(validParams);\n\n // THEN\n expect(result.isLeft()).toBe(true);\n expect(result.extract()).toEqual(\n new Error(\n `[ContextModule] HttpSafeProxyDataSource: Invalid safe proxy response format for proxy ${validParams.proxyAddress} on chain ${validParams.chainId}`,\n ),\n );\n });\n\n it(\"should return Left with error when standard is missing\", async () => {\n // GIVEN\n const { standard: _, ...invalidDto } = validDto;\n vi.spyOn(axios, \"request\").mockResolvedValue({ data: invalidDto });\n\n // WHEN\n const result =\n await datasource.getProxyImplementationAddress(validParams);\n\n // THEN\n expect(result.isLeft()).toBe(true);\n expect(result.extract()).toEqual(\n new Error(\n `[ContextModule] HttpSafeProxyDataSource: Invalid safe proxy response format for proxy ${validParams.proxyAddress} on chain ${validParams.chainId}`,\n ),\n );\n });\n\n it(\"should return Left with error when signedDescriptor is missing\", async () => {\n // GIVEN\n const { signedDescriptor: _, ...invalidDto } = validDto;\n vi.spyOn(axios, \"request\").mockResolvedValue({ data: invalidDto });\n\n // WHEN\n const result =\n await datasource.getProxyImplementationAddress(validParams);\n\n // THEN\n expect(result.isLeft()).toBe(true);\n expect(result.extract()).toEqual(\n new Error(\n `[ContextModule] HttpSafeProxyDataSource: Invalid safe proxy response format for proxy ${validParams.proxyAddress} on chain ${validParams.chainId}`,\n ),\n );\n });\n\n it(\"should return Left with error when providedBy is missing\", async () => {\n // GIVEN\n const { providedBy: _, ...invalidDto } = validDto;\n vi.spyOn(axios, \"request\").mockResolvedValue({ data: invalidDto });\n\n // WHEN\n const result =\n await datasource.getProxyImplementationAddress(validParams);\n\n // THEN\n expect(result.isLeft()).toBe(true);\n expect(result.extract()).toEqual(\n new Error(\n `[ContextModule] HttpSafeProxyDataSource: Invalid safe proxy response format for proxy ${validParams.proxyAddress} on chain ${validParams.chainId}`,\n ),\n );\n });\n\n it(\"should return Left with error when proxyAddress is not a string\", async () => {\n // GIVEN\n const invalidDto = { ...validDto, proxyAddress: 123 };\n vi.spyOn(axios, \"request\").mockResolvedValue({ data: invalidDto });\n\n // WHEN\n const result =\n await datasource.getProxyImplementationAddress(validParams);\n\n // THEN\n expect(result.isLeft()).toBe(true);\n expect(result.extract()).toEqual(\n new Error(\n `[ContextModule] HttpSafeProxyDataSource: Invalid safe proxy response format for proxy ${validParams.proxyAddress} on chain ${validParams.chainId}`,\n ),\n );\n });\n\n it(\"should return Left with error when implementationAddress is not a string\", async () => {\n // GIVEN\n const invalidDto = { ...validDto, implementationAddress: null };\n vi.spyOn(axios, \"request\").mockResolvedValue({ data: invalidDto });\n\n // WHEN\n const result =\n await datasource.getProxyImplementationAddress(validParams);\n\n // THEN\n expect(result.isLeft()).toBe(true);\n expect(result.extract()).toEqual(\n new Error(\n `[ContextModule] HttpSafeProxyDataSource: Invalid safe proxy response format for proxy ${validParams.proxyAddress} on chain ${validParams.chainId}`,\n ),\n );\n });\n\n it(\"should return Left with error when standard is not a string\", async () => {\n // GIVEN\n const invalidDto = { ...validDto, standard: [] };\n vi.spyOn(axios, \"request\").mockResolvedValue({ data: invalidDto });\n\n // WHEN\n const result =\n await datasource.getProxyImplementationAddress(validParams);\n\n // THEN\n expect(result.isLeft()).toBe(true);\n expect(result.extract()).toEqual(\n new Error(\n `[ContextModule] HttpSafeProxyDataSource: Invalid safe proxy response format for proxy ${validParams.proxyAddress} on chain ${validParams.chainId}`,\n ),\n );\n });\n\n it(\"should return Left with error when signedDescriptor is not a string\", async () => {\n // GIVEN\n const invalidDto = { ...validDto, signedDescriptor: {} };\n vi.spyOn(axios, \"request\").mockResolvedValue({ data: invalidDto });\n\n // WHEN\n const result =\n await datasource.getProxyImplementationAddress(validParams);\n\n // THEN\n expect(result.isLeft()).toBe(true);\n expect(result.extract()).toEqual(\n new Error(\n `[ContextModule] HttpSafeProxyDataSource: Invalid safe proxy response format for proxy ${validParams.proxyAddress} on chain ${validParams.chainId}`,\n ),\n );\n });\n\n it(\"should return Left with error when providedBy is not a string\", async () => {\n // GIVEN\n const invalidDto = { ...validDto, providedBy: true };\n vi.spyOn(axios, \"request\").mockResolvedValue({ data: invalidDto });\n\n // WHEN\n const result =\n await datasource.getProxyImplementationAddress(validParams);\n\n // THEN\n expect(result.isLeft()).toBe(true);\n expect(result.extract()).toEqual(\n new Error(\n `[ContextModule] HttpSafeProxyDataSource: Invalid safe proxy response format for proxy ${validParams.proxyAddress} on chain ${validParams.chainId}`,\n ),\n );\n });\n\n it(\"should return Left with error when response is not an object\", async () => {\n // GIVEN\n vi.spyOn(axios, \"request\").mockResolvedValue({ data: \"not an object\" });\n\n // WHEN\n const result =\n await datasource.getProxyImplementationAddress(validParams);\n\n // THEN\n expect(result.isLeft()).toBe(true);\n expect(result.extract()).toEqual(\n new Error(\n `[ContextModule] HttpSafeProxyDataSource: Invalid safe proxy response format for proxy ${validParams.proxyAddress} on chain ${validParams.chainId}`,\n ),\n );\n });\n\n it(\"should return Left with error when response is null\", async () => {\n // GIVEN\n vi.spyOn(axios, \"request\").mockResolvedValue({ data: null });\n\n // WHEN\n const result =\n await datasource.getProxyImplementationAddress(validParams);\n\n // THEN\n expect(result.isLeft()).toBe(true);\n expect(result.extract()).toEqual(\n new Error(\n `[ContextModule] HttpSafeProxyDataSource: No data received for proxy ${validParams.proxyAddress} on chain ${validParams.chainId}`,\n ),\n );\n });\n\n it(\"should handle different chainId values correctly\", async () => {\n // GIVEN\n const paramsWithDifferentChainId = { ...validParams, chainId: 137 };\n vi.spyOn(axios, \"request\").mockResolvedValue({ data: validDto });\n\n // WHEN\n const result = await datasource.getProxyImplementationAddress(\n paramsWithDifferentChainId,\n );\n\n // THEN\n expect(result.isRight()).toBe(true);\n expect(axios.request).toHaveBeenCalledWith(\n expect.objectContaining({\n url: `${config.metadataServiceDomain.url}/v3/ethereum/137/contract/proxy/${validParams.proxyAddress}`,\n }),\n );\n });\n\n it(\"should handle different proxy addresses correctly\", async () => {\n // GIVEN\n const differentProxyAddress =\n \"0xabcdefabcdefabcdefabcdefabcdefabcdefabcd\";\n const paramsWithDifferentAddress = {\n ...validParams,\n proxyAddress: differentProxyAddress,\n };\n vi.spyOn(axios, \"request\").mockResolvedValue({ data: validDto });\n\n // WHEN\n const result = await datasource.getProxyImplementationAddress(\n paramsWithDifferentAddress,\n );\n\n // THEN\n expect(result.isRight()).toBe(true);\n expect(axios.request).toHaveBeenCalledWith(\n expect.objectContaining({\n url: `${config.metadataServiceDomain.url}/v3/ethereum/${validParams.chainId}/contract/proxy/${differentProxyAddress}`,\n }),\n );\n });\n\n it(\"should pass challenge parameter correctly\", async () => {\n // GIVEN\n const customChallenge = \"custom-challenge-string\";\n const paramsWithCustomChallenge = {\n ...validParams,\n challenge: customChallenge,\n };\n vi.spyOn(axios, \"request\").mockResolvedValue({ data: validDto });\n\n // WHEN\n const result = await datasource.getProxyImplementationAddress(\n paramsWithCustomChallenge,\n );\n\n // THEN\n expect(result.isRight()).toBe(true);\n expect(axios.request).toHaveBeenCalledWith(\n expect.objectContaining({\n params: {\n challenge: customChallenge,\n resolver: \"SAFE_GATEWAY\",\n },\n }),\n );\n });\n });\n});\n"],
|
|
5
|
+
"mappings": "AAAA,OAAOA,MAAW,QAGlB,OACE,gCAAAC,EACA,8BAAAC,MACK,gCACP,OAAOC,MAAa,qBAGpB,OAAS,2BAAAC,MAA+B,4BAGxC,GAAG,KAAK,OAAO,EAEf,MAAMC,EAAS,CACb,sBAAuB,CACrB,IAAK,sCACP,EACA,YAAa,mBACf,EAEA,SAAS,0BAA2B,IAAM,CACxC,IAAIC,EAEJ,UAAU,IAAM,CACdA,EAAa,IAAIF,EAAwBC,CAAM,EAC/C,GAAG,cAAc,CACnB,CAAC,EAED,WAAW,IAAM,CACf,GAAG,cAAc,CACnB,CAAC,EAED,MAAME,EAAc,CAClB,aAAc,6CACd,QAAS,EACT,UAAW,iBACX,SAAU,UACZ,EAEMC,EAA8C,CAClD,aAAc,6CACd,sBAAuB,6CACvB,SAAU,WACV,iBAAkB,yBAClB,WAAY,cACd,EAEA,SAAS,gCAAiC,IAAM,CAC9C,GAAG,8DAA+D,SAAY,CAE5E,MAAMC,EAAU,kBAAkBN,EAAQ,OAAO,GAC3CO,EAAa,GAAG,GAAG,IAAM,QAAQ,QAAQ,CAAE,KAAMF,CAAS,CAAC,CAAC,EAClE,GAAG,MAAMR,EAAO,SAAS,EAAE,mBAAmBU,CAAU,EAGxD,MAAMJ,EAAW,8BAA8BC,CAAW,EAG1D,OAAOG,CAAU,EAAE,qBAAqB,CACtC,OAAQ,MACR,IAAK,GAAGL,EAAO,sBAAsB,GAAG,gBAAgBE,EAAY,OAAO,mBAAmBA,EAAY,YAAY,GACtH,QAAS,CACP,CAACN,CAA4B,EAAGQ,EAChC,CAACP,CAA0B,EAAGG,EAAO,WACvC,EACA,OAAQ,CACN,UAAWE,EAAY,UACvB,SAAU,c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8BAC9BU,CACF,EAGA,OAAOL,EAAO,QAAQ,CAAC,EAAE,KAAK,EAAI,EAClC,OAAOX,EAAM,OAAO,EAAE,qBACpB,OAAO,iBAAiB,CACtB,IAAK,GAAGK,EAAO,sBAAsB,GAAG,gBAAgBE,EAAY,OAAO,mBAAmBQ,CAAqB,EACrH,CAAC,CACH,CACF,CAAC,EAED,GAAG,4CAA6C,SAAY,CAE1D,MAAME,EAAkB,0BAClBC,EAA4B,CAChC,GAAGX,EACH,UAAWU,CACb,EACA,GAAG,MAAMjB,EAAO,SAAS,EAAE,kBAAkB,CAAE,KAAMQ,CAAS,CAAC,EAG/D,MAAMG,EAAS,MAAML,EAAW,8BAC9BY,CACF,EAGA,OAAOP,EAAO,QAAQ,CAAC,EAAE,KAAK,EAAI,EAClC,OAAOX,EAAM,OAAO,EAAE,qBACpB,OAAO,iBAAiB,CACtB,OAAQ,CACN,UAAWiB,EACX,SAAU,cACZ,CACF,CAAC,CACH,CACF,CAAC,CACH,CAAC,CACH,CAAC",
|
|
6
|
+
"names": ["axios", "LEDGER_CLIENT_VERSION_HEADER", "LEDGER_ORIGIN_TOKEN_HEADER", "PACKAGE", "HttpSafeProxyDataSource", "config", "datasource", "validParams", "validDto", "version", "requestSpy", "result", "_", "invalidDto", "paramsWithDifferentChainId", "differentProxyAddress", "paramsWithDifferentAddress", "customChallenge", "paramsWithCustomChallenge"]
|
|
7
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
//# sourceMappingURL=ProxyDataSource.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
//# sourceMappingURL=SafeProxyImplementationAddressDto.js.map
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{ContainerModule as e}from"inversify";import{HttpProxyDataSource as a}from"../../proxy/data/HttpProxyDataSource";import{HttpSafeProxyDataSource as p}from"../../proxy/data/HttpSafeProxyDataSource";import{proxyTypes as r}from"../../proxy/di/proxyTypes";import{ProxyContextFieldLoader as x}from"../../proxy/domain/ProxyContextFieldLoader";const n=t=>new e(({bind:o})=>{t?.datasource?.proxy==="safe"?o(r.ProxyDataSource).to(p):o(r.ProxyDataSource).to(a),o(r.ProxyContextFieldLoader).to(x)});export{n as proxyModuleFactory};
|
|
2
|
+
//# sourceMappingURL=proxyModuleFactory.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../../src/proxy/di/proxyModuleFactory.ts"],
|
|
4
|
+
"sourcesContent": ["import { ContainerModule } from \"inversify\";\n\nimport { type ContextModuleConfig } from \"@/config/model/ContextModuleConfig\";\nimport { HttpProxyDataSource } from \"@/proxy/data/HttpProxyDataSource\";\nimport { HttpSafeProxyDataSource } from \"@/proxy/data/HttpSafeProxyDataSource\";\nimport { proxyTypes } from \"@/proxy/di/proxyTypes\";\nimport { ProxyContextFieldLoader } from \"@/proxy/domain/ProxyContextFieldLoader\";\n\nexport const proxyModuleFactory = (config?: ContextModuleConfig) =>\n new ContainerModule(({ bind }) => {\n if (config?.datasource?.proxy === \"safe\") {\n bind(proxyTypes.ProxyDataSource).to(HttpSafeProxyDataSource);\n } else {\n bind(proxyTypes.ProxyDataSource).to(HttpProxyDataSource);\n }\n bind(proxyTypes.ProxyContextFieldLoader).to(ProxyContextFieldLoader);\n });\n"],
|
|
5
|
+
"mappings": "AAAA,OAAS,mBAAAA,MAAuB,YAGhC,OAAS,uBAAAC,MAA2B,mCACpC,OAAS,2BAAAC,MAA+B,uCACxC,OAAS,cAAAC,MAAkB,wBAC3B,OAAS,2BAAAC,MAA+B,yCAEjC,MAAMC,EAAsBC,GACjC,IAAIN,EAAgB,CAAC,CAAE,KAAAO,CAAK,IAAM,CAC5BD,GAAQ,YAAY,QAAU,OAChCC,EAAKJ,EAAW,eAAe,EAAE,GAAGD,CAAuB,EAE3DK,EAAKJ,EAAW,eAAe,EAAE,GAAGF,CAAmB,EAEzDM,EAAKJ,EAAW,uBAAuB,EAAE,GAAGC,CAAuB,CACrE,CAAC",
|
|
6
|
+
"names": ["ContainerModule", "HttpProxyDataSource", "HttpSafeProxyDataSource", "proxyTypes", "ProxyContextFieldLoader", "proxyModuleFactory", "config", "bind"]
|
|
7
|
+
}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{Container as u}from"inversify";import{configTypes as f}from"../../config/di/configTypes";import{pkiTypes as x}from"../../pki/di/pkiTypes";import{HttpProxyDataSource as i}from"../../proxy/data/HttpProxyDataSource";import{HttpSafeProxyDataSource as l}from"../../proxy/data/HttpSafeProxyDataSource";import{ProxyContextFieldLoader as c}from"../../proxy/domain/ProxyContextFieldLoader";import{proxyModuleFactory as n}from"./proxyModuleFactory";import{proxyTypes as r}from"./proxyTypes";describe("proxyModuleFactory",()=>{let o;const d={metadataServiceDomain:{url:"https://metadata.api.live.ledger.com"},originToken:"test-origin-token"},s={loadCertificate:vi.fn()};beforeEach(()=>{o=new u,o.bind(f.Config).toConstantValue(d),o.bind(x.PkiCertificateLoader).toConstantValue(s)}),describe("when config is undefined",()=>{it("should bind HttpProxyDataSource as the default ProxyDataSource",()=>{const a=n();o.load(a);const e=o.get(r.ProxyDataSource);expect(e).toBeInstanceOf(i)}),it("should bind ProxyContextFieldLoader",()=>{const a=n();o.load(a);const e=o.get(r.ProxyContextFieldLoader);expect(e).toBeInstanceOf(c)})}),describe("when config.datasource.proxy is 'safe'",()=>{it("should bind HttpSafeProxyDataSource as the ProxyDataSource",()=>{const e=n({datasource:{proxy:"safe"}});o.load(e);const t=o.get(r.ProxyDataSource);expect(t).toBeInstanceOf(l)}),it("should bind ProxyContextFieldLoader",()=>{const e=n({datasource:{proxy:"safe"}});o.load(e);const t=o.get(r.ProxyContextFieldLoader);expect(t).toBeInstanceOf(c)})}),describe("when config.datasource.proxy is 'default'",()=>{it("should bind HttpProxyDataSource as the ProxyDataSource",()=>{const e=n({datasource:{proxy:"default"}});o.load(e);const t=o.get(r.ProxyDataSource);expect(t).toBeInstanceOf(i)})}),describe("when config.datasource is undefined",()=>{it("should bind HttpProxyDataSource as the default ProxyDataSource",()=>{const e=n({});o.load(e);const t=o.get(r.ProxyDataSource);expect(t).toBeInstanceOf(i)})}),describe("when config.datasource.proxy is an unexpected value",()=>{it("should bind HttpProxyDataSource as the default ProxyDataSource",()=>{const e=n({datasource:{proxy:"unknown"}});o.load(e);const t=o.get(r.ProxyDataSource);expect(t).toBeInstanceOf(i)})})});
|
|
2
|
+
//# sourceMappingURL=proxyModuleFactory.test.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../../src/proxy/di/proxyModuleFactory.test.ts"],
|
|
4
|
+
"sourcesContent": ["import { Container } from \"inversify\";\n\nimport { configTypes } from \"@/config/di/configTypes\";\nimport { type ContextModuleConfig } from \"@/config/model/ContextModuleConfig\";\nimport { pkiTypes } from \"@/pki/di/pkiTypes\";\nimport { type PkiCertificateLoader } from \"@/pki/domain/PkiCertificateLoader\";\nimport { HttpProxyDataSource } from \"@/proxy/data/HttpProxyDataSource\";\nimport { HttpSafeProxyDataSource } from \"@/proxy/data/HttpSafeProxyDataSource\";\nimport { ProxyContextFieldLoader } from \"@/proxy/domain/ProxyContextFieldLoader\";\n\nimport { proxyModuleFactory } from \"./proxyModuleFactory\";\nimport { proxyTypes } from \"./proxyTypes\";\n\ndescribe(\"proxyModuleFactory\", () => {\n let container: Container;\n const mockConfig: ContextModuleConfig = {\n metadataServiceDomain: {\n url: \"https://metadata.api.live.ledger.com\",\n },\n originToken: \"test-origin-token\",\n } as ContextModuleConfig;\n\n const mockPkiCertificateLoader: PkiCertificateLoader = {\n loadCertificate: vi.fn(),\n };\n\n beforeEach(() => {\n container = new Container();\n // Bind the config that the datasources depend on\n container.bind(configTypes.Config).toConstantValue(mockConfig);\n // Bind the PKI certificate loader that ProxyContextFieldLoader depends on\n container\n .bind(pkiTypes.PkiCertificateLoader)\n .toConstantValue(mockPkiCertificateLoader);\n });\n\n describe(\"when config is undefined\", () => {\n it(\"should bind HttpProxyDataSource as the default ProxyDataSource\", () => {\n const module = proxyModuleFactory();\n container.load(module);\n\n const proxyDataSource = container.get(proxyTypes.ProxyDataSource);\n expect(proxyDataSource).toBeInstanceOf(HttpProxyDataSource);\n });\n\n it(\"should bind ProxyContextFieldLoader\", () => {\n const module = proxyModuleFactory();\n container.load(module);\n\n const proxyContextFieldLoader = container.get(\n proxyTypes.ProxyContextFieldLoader,\n );\n expect(proxyContextFieldLoader).toBeInstanceOf(ProxyContextFieldLoader);\n });\n });\n\n describe(\"when config.datasource.proxy is 'safe'\", () => {\n it(\"should bind HttpSafeProxyDataSource as the ProxyDataSource\", () => {\n const config: ContextModuleConfig = {\n datasource: {\n proxy: \"safe\",\n },\n } as ContextModuleConfig;\n\n const module = proxyModuleFactory(config);\n container.load(module);\n\n const proxyDataSource = container.get(proxyTypes.ProxyDataSource);\n expect(proxyDataSource).toBeInstanceOf(HttpSafeProxyDataSource);\n });\n\n it(\"should bind ProxyContextFieldLoader\", () => {\n const config: ContextModuleConfig = {\n datasource: {\n proxy: \"safe\",\n },\n } as ContextModuleConfig;\n\n const module = proxyModuleFactory(config);\n container.load(module);\n\n const proxyContextFieldLoader = container.get(\n proxyTypes.ProxyContextFieldLoader,\n );\n expect(proxyContextFieldLoader).toBeInstanceOf(ProxyContextFieldLoader);\n });\n });\n\n describe(\"when config.datasource.proxy is 'default'\", () => {\n it(\"should bind HttpProxyDataSource as the ProxyDataSource\", () => {\n const config: ContextModuleConfig = {\n datasource: {\n proxy: \"default\",\n },\n } as ContextModuleConfig;\n\n const module = proxyModuleFactory(config);\n container.load(module);\n\n const proxyDataSource = container.get(proxyTypes.ProxyDataSource);\n expect(proxyDataSource).toBeInstanceOf(HttpProxyDataSource);\n });\n });\n\n describe(\"when config.datasource is undefined\", () => {\n it(\"should bind HttpProxyDataSource as the default ProxyDataSource\", () => {\n const config: ContextModuleConfig = {} as ContextModuleConfig;\n\n const module = proxyModuleFactory(config);\n container.load(module);\n\n const proxyDataSource = container.get(proxyTypes.ProxyDataSource);\n expect(proxyDataSource).toBeInstanceOf(HttpProxyDataSource);\n });\n });\n\n describe(\"when config.datasource.proxy is an unexpected value\", () => {\n it(\"should bind HttpProxyDataSource as the default ProxyDataSource\", () => {\n const config: ContextModuleConfig = {\n datasource: {\n proxy: \"unknown\" as unknown as \"safe\" | \"default\",\n },\n } as ContextModuleConfig;\n\n const module = proxyModuleFactory(config);\n container.load(module);\n\n const proxyDataSource = container.get(proxyTypes.ProxyDataSource);\n expect(proxyDataSource).toBeInstanceOf(HttpProxyDataSource);\n });\n });\n});\n"],
|
|
5
|
+
"mappings": "AAAA,OAAS,aAAAA,MAAiB,YAE1B,OAAS,eAAAC,MAAmB,0BAE5B,OAAS,YAAAC,MAAgB,oBAEzB,OAAS,uBAAAC,MAA2B,mCACpC,OAAS,2BAAAC,MAA+B,uCACxC,OAAS,2BAAAC,MAA+B,yCAExC,OAAS,sBAAAC,MAA0B,uBACnC,OAAS,cAAAC,MAAkB,eAE3B,SAAS,qBAAsB,IAAM,CACnC,IAAIC,EACJ,MAAMC,EAAkC,CACtC,sBAAuB,CACrB,IAAK,sCACP,EACA,YAAa,mBACf,EAEMC,EAAiD,CACrD,gBAAiB,GAAG,GAAG,CACzB,EAEA,WAAW,IAAM,CACfF,EAAY,IAAIR,EAEhBQ,EAAU,KAAKP,EAAY,MAAM,EAAE,gBAAgBQ,CAAU,EAE7DD,EACG,KAAKN,EAAS,oBAAoB,EAClC,gBAAgBQ,CAAwB,CAC7C,CAAC,EAED,SAAS,2BAA4B,IAAM,CACzC,GAAG,iEAAkE,IAAM,CACzE,MAAMC,EAASL,EAAmB,EAClCE,EAAU,KAAKG,CAAM,EAErB,MAAMC,EAAkBJ,EAAU,IAAID,EAAW,eAAe,EAChE,OAAOK,CAAe,EAAE,eAAeT,CAAmB,CAC5D,CAAC,EAED,GAAG,sCAAuC,IAAM,CAC9C,MAAMQ,EAASL,EAAmB,EAClCE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ErB,MAAMC,EAAkBJ,EAAU,IAAID,EAAW,eAAe,EAChE,OAAOK,CAAe,EAAE,eAAeT,CAAmB,CAC5D,CAAC,CACH,CAAC,CACH,CAAC",
|
|
6
|
+
"names": ["Container", "configTypes", "pkiTypes", "HttpProxyDataSource", "HttpSafeProxyDataSource", "ProxyContextFieldLoader", "proxyModuleFactory", "proxyTypes", "container", "mockConfig", "mockPkiCertificateLoader", "module", "proxyDataSource", "proxyContextFieldLoader"]
|
|
7
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../../src/proxy/di/proxyTypes.ts"],
|
|
4
|
+
"sourcesContent": ["export const proxyTypes = {\n ProxyDataSource: Symbol.for(\"ProxyDataSource\"),\n ProxyContextFieldLoader: Symbol.for(\"ProxyContextFieldLoader\"),\n};\n"],
|
|
5
|
+
"mappings": "AAAO,MAAMA,EAAa,CACxB,gBAAiB,OAAO,IAAI,iBAAiB,EAC7C,wBAAyB,OAAO,IAAI,yBAAyB,CAC/D",
|
|
6
|
+
"names": ["proxyTypes"]
|
|
7
|
+
}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
var s=Object.defineProperty;var m=Object.getOwnPropertyDescriptor;var d=(o,e,a,t)=>{for(var r=t>1?void 0:t?m(e,a):e,n=o.length-1,l;n>=0;n--)(l=o[n])&&(r=(t?l(e,a,r):l(r))||r);return t&&r&&s(e,a,r),r},c=(o,e)=>(a,t)=>e(a,t,o);import{inject as p,injectable as C}from"inversify";import{pkiTypes as x}from"../../pki/di/pkiTypes";import{KeyId as g}from"../../pki/model/KeyId";import{KeyUsage as u}from"../../pki/model/KeyUsage";import{proxyTypes as I}from"../../proxy/di/proxyTypes";import{ContextFieldLoaderKind as L}from"../../shared/domain/ContextFieldLoader";import{ClearSignContextType as y}from"../../shared/model/ClearSignContext";let i=class{constructor(e,a){this._proxyDataSource=e;this._certificateLoader=a}canHandle(e){return typeof e=="object"&&e!==null&&"kind"in e&&e.kind===L.PROXY_DELEGATE_CALL&&"chainId"in e&&"proxyAddress"in e&&"calldata"in e&&"challenge"in e&&"deviceModelId"in e}async loadField(e){return(await this._proxyDataSource.getProxyImplementationAddress({calldata:e.calldata,proxyAddress:e.proxyAddress,chainId:e.chainId,challenge:e.challenge})).caseOf({Left:t=>Promise.resolve({type:y.ERROR,error:t}),Right:async({signedDescriptor:t})=>{const r=await this._certificateLoader.loadCertificate({keyId:g.CalCalldataKey,keyUsage:u.Calldata,targetDevice:e.deviceModelId});return{type:y.PROXY_DELEGATE_CALL,payload:t,certificate:r}}})}};i=d([C(),c(0,p(I.ProxyDataSource)),c(1,p(x.PkiCertificateLoader))],i);export{i as ProxyContextFieldLoader};
|
|
2
|
+
//# sourceMappingURL=ProxyContextFieldLoader.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../../src/proxy/domain/ProxyContextFieldLoader.ts"],
|
|
4
|
+
"sourcesContent": ["import { DeviceModelId } from \"@ledgerhq/device-management-kit\";\nimport { inject, injectable } from \"inversify\";\n\nimport { pkiTypes } from \"@/pki/di/pkiTypes\";\nimport { type PkiCertificateLoader } from \"@/pki/domain/PkiCertificateLoader\";\nimport { KeyId } from \"@/pki/model/KeyId\";\nimport { KeyUsage } from \"@/pki/model/KeyUsage\";\nimport { type ProxyDataSource } from \"@/proxy/data/ProxyDataSource\";\nimport { proxyTypes } from \"@/proxy/di/proxyTypes\";\nimport { type ProxyDelegateCall } from \"@/proxy/model/ProxyDelegateCall\";\nimport {\n type ContextFieldLoader,\n ContextFieldLoaderKind,\n} from \"@/shared/domain/ContextFieldLoader\";\nimport {\n type ClearSignContext,\n ClearSignContextType,\n} from \"@/shared/model/ClearSignContext\";\n\ntype ProxyFieldInput = {\n kind: ContextFieldLoaderKind.PROXY_DELEGATE_CALL;\n chainId: number;\n proxyAddress: string;\n calldata: string;\n challenge: string;\n deviceModelId: DeviceModelId;\n};\n\n@injectable()\nexport class ProxyContextFieldLoader\n implements ContextFieldLoader<ProxyFieldInput>\n{\n constructor(\n @inject(proxyTypes.ProxyDataSource)\n private _proxyDataSource: ProxyDataSource,\n @inject(pkiTypes.PkiCertificateLoader)\n private _certificateLoader: PkiCertificateLoader,\n ) {}\n\n canHandle(field: unknown): field is ProxyFieldInput {\n return (\n typeof field === \"object\" &&\n field !== null &&\n \"kind\" in field &&\n field.kind === ContextFieldLoaderKind.PROXY_DELEGATE_CALL &&\n \"chainId\" in field &&\n \"proxyAddress\" in field &&\n \"calldata\" in field &&\n \"challenge\" in field &&\n \"deviceModelId\" in field\n );\n }\n\n async loadField(field: ProxyFieldInput): Promise<ClearSignContext> {\n const proxyDelegateCall =\n await this._proxyDataSource.getProxyImplementationAddress({\n calldata: field.calldata,\n proxyAddress: field.proxyAddress,\n chainId: field.chainId,\n challenge: field.challenge,\n });\n\n return proxyDelegateCall.caseOf<Promise<ClearSignContext>>({\n Left: (error) =>\n Promise.resolve({\n type: ClearSignContextType.ERROR,\n error: error,\n }),\n Right: async ({ signedDescriptor }: ProxyDelegateCall) => {\n const certificate = await this._certificateLoader.loadCertificate({\n keyId: KeyId.CalCalldataKey,\n keyUsage: KeyUsage.Calldata,\n targetDevice: field.deviceModelId,\n });\n\n return {\n type: ClearSignContextType.PROXY_DELEGATE_CALL,\n payload: signedDescriptor,\n certificate,\n };\n },\n });\n }\n}\n"],
|
|
5
|
+
"mappings": "iOACA,OAAS,UAAAA,EAAQ,cAAAC,MAAkB,YAEnC,OAAS,YAAAC,MAAgB,oBAEzB,OAAS,SAAAC,MAAa,oBACtB,OAAS,YAAAC,MAAgB,uBAEzB,OAAS,cAAAC,MAAkB,wBAE3B,OAEE,0BAAAC,MACK,qCACP,OAEE,wBAAAC,MACK,kCAYA,IAAMC,EAAN,KAEP,CACE,YAEUC,EAEAC,EACR,CAHQ,sBAAAD,EAEA,wBAAAC,CACP,CAEH,UAAUC,EAA0C,CAClD,OACE,OAAOA,GAAU,UACjBA,IAAU,MACV,SAAUA,GACVA,EAAM,OAASC,EAAuB,qBACtC,YAAaD,GACb,iBAAkBA,GAClB,aAAcA,GACd,cAAeA,GACf,kBAAmBA,CAEvB,CAEA,MAAM,UAAUA,EAAmD,CASjE,OAPE,MAAM,KAAK,iBAAiB,8BAA8B,CACxD,SAAUA,EAAM,SAChB,aAAcA,EAAM,aACpB,QAASA,EAAM,QACf,UAAWA,EAAM,SACnB,CAAC,GAEsB,OAAkC,CACzD,KAAOE,GACL,QAAQ,QAAQ,CACd,KAAMC,EAAqB,MAC3B,MAAOD,CACT,CAAC,EACH,MAAO,MAAO,CAAE,iBAAAE,CAAiB,IAAyB,CACxD,MAAMC,EAAc,MAAM,KAAK,mBAAmB,gBAAgB,CAChE,MAAOC,EAAM,eACb,SAAUC,EAAS,SACnB,aAAcP,EAAM,aACtB,CAAC,EAED,MAAO,CACL,KAAMG,EAAqB,oBAC3B,QAASC,EACT,YAAAC,CACF,CACF,CACF,CAAC,CACH,CACF,EAtDaR,EAANW,EAAA,CADNC,EAAW,EAKPC,EAAA,EAAAC,EAAOC,EAAW,eAAe,GAEjCF,EAAA,EAAAC,EAAOE,EAAS,oBAAoB,IAN5BhB",
|
|
6
|
+
"names": ["inject", "injectable", "pkiTypes", "KeyId", "KeyUsage", "proxyTypes", "ContextFieldLoaderKind", "ClearSignContextType", "ProxyContextFieldLoader", "_proxyDataSource", "_certificateLoader", "field", "ContextFieldLoaderKind", "error", "ClearSignContextType", "signedDescriptor", "certificate", "KeyId", "KeyUsage", "__decorateClass", "injectable", "__decorateParam", "inject", "proxyTypes", "pkiTypes"]
|
|
7
|
+
}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{DeviceModelId as r}from"@ledgerhq/device-management-kit";import{Left as x,Right as p}from"purify-ts";import{KeyId as y}from"../../pki/model/KeyId";import{KeyUsage as m}from"../../pki/model/KeyUsage";import{ProxyContextFieldLoader as u}from"../../proxy/domain/ProxyContextFieldLoader";import{ContextFieldLoaderKind as n}from"../../shared/domain/ContextFieldLoader";import{ClearSignContextType as s}from"../../shared/model/ClearSignContext";describe("ProxyContextFieldLoader",()=>{const t={getProxyImplementationAddress:vi.fn()},d={loadCertificate:vi.fn()},o=new u(t,d),e={kind:n.PROXY_DELEGATE_CALL,chainId:1,proxyAddress:"0x1234567890abcdef",calldata:"0xabcdef1234567890",challenge:"test-challenge",deviceModelId:r.STAX},i={implementationAddress:"0x987654321fedcba0",signedDescriptor:"0x123456789abcdef0"},c={keyUsageNumber:1,payload:new Uint8Array([1,2,3,4])};beforeEach(()=>{vi.resetAllMocks()}),describe("canHandle",()=>{it("should return true for valid proxy field",()=>{const a={kind:n.PROXY_DELEGATE_CALL,chainId:1,proxyAddress:"0x1234567890abcdef",calldata:"0xabcdef1234567890",challenge:"test-challenge",deviceModelId:r.STAX};expect(o.canHandle(a)).toBe(!0)}),describe("should return false for invalid fields",()=>{const a=[{name:"null",value:null},{name:"undefined",value:void 0},{name:"string",value:"invalid"},{name:"number",value:123},{name:"boolean",value:!0},{name:"array",value:[]},{name:"empty object",value:{}},{name:"object missing kind",value:{chainId:1,proxyAddress:"0x123",calldata:"0xabc",challenge:"test",deviceModelId:r.STAX}},{name:"object missing chainId",value:{kind:n.PROXY_DELEGATE_CALL,proxyAddress:"0x123",calldata:"0xabc",challenge:"test",deviceModelId:r.STAX}},{name:"object missing proxyAddress",value:{kind:n.PROXY_DELEGATE_CALL,chainId:1,calldata:"0xabc",challenge:"test",deviceModelId:r.STAX}},{name:"object missing calldata",value:{kind:n.PROXY_DELEGATE_CALL,chainId:1,proxyAddress:"0x123",challenge:"test",deviceModelId:r.STAX}},{name:"object missing challenge",value:{kind:n.PROXY_DELEGATE_CALL,chainId:1,proxyAddress:"0x123",calldata:"0xabc",deviceModelId:r.STAX}},{name:"object missing deviceModelId",value:{kind:n.PROXY_DELEGATE_CALL,chainId:1,proxyAddress:"0x123",calldata:"0xabc",challenge:"test"}},{name:"object with wrong kind",value:{kind:n.TOKEN,chainId:1,proxyAddress:"0x123",calldata:"0xabc",challenge:"test",deviceModelId:r.STAX}}];test.each(a)("$name",({value:l})=>{expect(o.canHandle(l)).toBe(!1)})})}),describe("loadField",()=>{it("should return error context when proxy data source fails",async()=>{const a=new Error("Proxy data source error");vi.spyOn(t,"getProxyImplementationAddress").mockResolvedValue(x(a));const l=await o.loadField(e);expect(t.getProxyImplementationAddress).toHaveBeenCalledWith({calldata:e.calldata,proxyAddress:e.proxyAddress,chainId:e.chainId,challenge:e.challenge}),expect(l).toEqual({type:s.ERROR,error:a}),expect(d.loadCertificate).not.toHaveBeenCalled()}),it("should return proxy delegate call context when successful",async()=>{vi.spyOn(t,"getProxyImplementationAddress").mockResolvedValue(p(i)),vi.spyOn(d,"loadCertificate").mockResolvedValue(c);const a=await o.loadField(e);expect(t.getProxyImplementationAddress).toHaveBeenCalledWith({calldata:e.calldata,proxyAddress:e.proxyAddress,chainId:e.chainId,challenge:e.challenge}),expect(d.loadCertificate).toHaveBeenCalledWith({keyId:y.CalCalldataKey,keyUsage:m.Calldata,targetDevice:e.deviceModelId}),expect(a).toEqual({type:s.PROXY_DELEGATE_CALL,payload:i.signedDescriptor,certificate:c})}),it("should return proxy delegate call context with undefined certificate when certificate loading returns undefined",async()=>{vi.spyOn(t,"getProxyImplementationAddress").mockResolvedValue(p(i)),vi.spyOn(d,"loadCertificate").mockResolvedValue(void 0);const a=await o.loadField(e);expect(t.getProxyImplementationAddress).toHaveBeenCalledWith({calldata:e.calldata,proxyAddress:e.proxyAddress,chainId:e.chainId,challenge:e.challenge}),expect(d.loadCertificate).toHaveBeenCalledWith({keyId:y.CalCalldataKey,keyUsage:m.Calldata,targetDevice:e.deviceModelId}),expect(a).toEqual({type:s.PROXY_DELEGATE_CALL,payload:i.signedDescriptor,certificate:void 0})}),it("should handle different device model IDs correctly",async()=>{const a={...e,deviceModelId:r.NANO_X};vi.spyOn(t,"getProxyImplementationAddress").mockResolvedValue(p(i)),vi.spyOn(d,"loadCertificate").mockResolvedValue(c);const l=await o.loadField(a);expect(d.loadCertificate).toHaveBeenCalledWith({keyId:y.CalCalldataKey,keyUsage:m.Calldata,targetDevice:r.NANO_X}),expect(l).toEqual({type:s.PROXY_DELEGATE_CALL,payload:i.signedDescriptor,certificate:c})}),it("should handle different chain IDs and addresses correctly",async()=>{const a={...e,chainId:137,proxyAddress:"0xdeadbeef",calldata:"0xcafebabe",challenge:"custom-challenge"};vi.spyOn(t,"getProxyImplementationAddress").mockResolvedValue(p(i)),vi.spyOn(d,"loadCertificate").mockResolvedValue(c);const l=await o.loadField(a);expect(t.getProxyImplementationAddress).toHaveBeenCalledWith({calldata:"0xcafebabe",proxyAddress:"0xdeadbeef",chainId:137,challenge:"custom-challenge"}),expect(l).toEqual({type:s.PROXY_DELEGATE_CALL,payload:i.signedDescriptor,certificate:c})}),it("should handle certificate loading failure gracefully",async()=>{vi.spyOn(t,"getProxyImplementationAddress").mockResolvedValue(p(i)),vi.spyOn(d,"loadCertificate").mockRejectedValue(new Error("Certificate loading failed")),await expect(o.loadField(e)).rejects.toThrow("Certificate loading failed"),expect(t.getProxyImplementationAddress).toHaveBeenCalled(),expect(d.loadCertificate).toHaveBeenCalled()}),it("should preserve error message from proxy data source",async()=>{const a=new Error("Network timeout error");vi.spyOn(t,"getProxyImplementationAddress").mockResolvedValue(x(a));const l=await o.loadField(e);expect(l).toEqual({type:s.ERROR,error:a})}),it("should handle empty signed descriptor",async()=>{const a={...i,signedDescriptor:""};vi.spyOn(t,"getProxyImplementationAddress").mockResolvedValue(p(a)),vi.spyOn(d,"loadCertificate").mockResolvedValue(c);const l=await o.loadField(e);expect(l).toEqual({type:s.PROXY_DELEGATE_CALL,payload:"",certificate:c})})})});
|
|
2
|
+
//# sourceMappingURL=ProxyContextFieldLoader.test.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../../src/proxy/domain/ProxyContextFieldLoader.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 { KeyId } from \"@/pki/model/KeyId\";\nimport { KeyUsage } from \"@/pki/model/KeyUsage\";\nimport { type PkiCertificate } from \"@/pki/model/PkiCertificate\";\nimport { type ProxyDataSource } from \"@/proxy/data/ProxyDataSource\";\nimport { ProxyContextFieldLoader } from \"@/proxy/domain/ProxyContextFieldLoader\";\nimport { type ProxyDelegateCall } from \"@/proxy/model/ProxyDelegateCall\";\nimport { ContextFieldLoaderKind } from \"@/shared/domain/ContextFieldLoader\";\nimport { ClearSignContextType } from \"@/shared/model/ClearSignContext\";\nimport { type TransactionFieldContext } from \"@/shared/model/TransactionFieldContext\";\n\ndescribe(\"ProxyContextFieldLoader\", () => {\n const mockProxyDataSource: ProxyDataSource = {\n getProxyImplementationAddress: vi.fn(),\n };\n const mockCertificateLoader: PkiCertificateLoader = {\n loadCertificate: vi.fn(),\n };\n const proxyContextFieldLoader = new ProxyContextFieldLoader(\n mockProxyDataSource,\n mockCertificateLoader,\n );\n\n const mockTransactionField: TransactionFieldContext<ContextFieldLoaderKind.PROXY_DELEGATE_CALL> =\n {\n kind: ContextFieldLoaderKind.PROXY_DELEGATE_CALL,\n chainId: 1,\n proxyAddress: \"0x1234567890abcdef\",\n calldata: \"0xabcdef1234567890\",\n challenge: \"test-challenge\",\n deviceModelId: DeviceModelId.STAX,\n };\n\n const mockProxyDelegateCall: ProxyDelegateCall = {\n implementationAddress: \"0x987654321fedcba0\",\n signedDescriptor: \"0x123456789abcdef0\",\n };\n\n const mockCertificate: PkiCertificate = {\n keyUsageNumber: 1,\n payload: new Uint8Array([1, 2, 3, 4]),\n };\n\n beforeEach(() => {\n vi.resetAllMocks();\n });\n\n describe(\"canHandle\", () => {\n it(\"should return true for valid proxy field\", () => {\n // GIVEN\n const validField = {\n kind: ContextFieldLoaderKind.PROXY_DELEGATE_CALL,\n chainId: 1,\n proxyAddress: \"0x1234567890abcdef\",\n calldata: \"0xabcdef1234567890\",\n challenge: \"test-challenge\",\n deviceModelId: DeviceModelId.STAX,\n };\n\n // THEN\n expect(proxyContextFieldLoader.canHandle(validField)).toBe(true);\n });\n\n describe(\"should return false for invalid fields\", () => {\n const invalidFields = [\n { name: \"null\", value: null },\n { name: \"undefined\", value: undefined },\n { name: \"string\", value: \"invalid\" },\n { name: \"number\", value: 123 },\n { name: \"boolean\", value: true },\n { name: \"array\", value: [] },\n { name: \"empty object\", value: {} },\n {\n name: \"object missing kind\",\n value: {\n chainId: 1,\n proxyAddress: \"0x123\",\n calldata: \"0xabc\",\n challenge: \"test\",\n deviceModelId: DeviceModelId.STAX,\n },\n },\n {\n name: \"object missing chainId\",\n value: {\n kind: ContextFieldLoaderKind.PROXY_DELEGATE_CALL,\n proxyAddress: \"0x123\",\n calldata: \"0xabc\",\n challenge: \"test\",\n deviceModelId: DeviceModelId.STAX,\n },\n },\n {\n name: \"object missing proxyAddress\",\n value: {\n kind: ContextFieldLoaderKind.PROXY_DELEGATE_CALL,\n chainId: 1,\n calldata: \"0xabc\",\n challenge: \"test\",\n deviceModelId: DeviceModelId.STAX,\n },\n },\n {\n name: \"object missing calldata\",\n value: {\n kind: ContextFieldLoaderKind.PROXY_DELEGATE_CALL,\n chainId: 1,\n proxyAddress: \"0x123\",\n challenge: \"test\",\n deviceModelId: DeviceModelId.STAX,\n },\n },\n {\n name: \"object missing challenge\",\n value: {\n kind: ContextFieldLoaderKind.PROXY_DELEGATE_CALL,\n chainId: 1,\n proxyAddress: \"0x123\",\n calldata: \"0xabc\",\n deviceModelId: DeviceModelId.STAX,\n },\n },\n {\n name: \"object missing deviceModelId\",\n value: {\n kind: ContextFieldLoaderKind.PROXY_DELEGATE_CALL,\n chainId: 1,\n proxyAddress: \"0x123\",\n calldata: \"0xabc\",\n challenge: \"test\",\n },\n },\n {\n name: \"object with wrong kind\",\n value: {\n kind: ContextFieldLoaderKind.TOKEN,\n chainId: 1,\n proxyAddress: \"0x123\",\n calldata: \"0xabc\",\n challenge: \"test\",\n deviceModelId: DeviceModelId.STAX,\n },\n },\n ];\n\n test.each(invalidFields)(\"$name\", ({ value }) => {\n expect(proxyContextFieldLoader.canHandle(value)).toBe(false);\n });\n });\n });\n\n describe(\"loadField\", () => {\n it(\"should return error context when proxy data source fails\", async () => {\n // GIVEN\n const error = new Error(\"Proxy data source error\");\n vi.spyOn(\n mockProxyDataSource,\n \"getProxyImplementationAddress\",\n ).mockResolvedValue(Left(error));\n\n // WHEN\n const result =\n await proxyContextFieldLoader.loadField(mockTransactionField);\n\n // THEN\n expect(\n mockProxyDataSource.getProxyImplementationAddress,\n ).toHaveBeenCalledWith({\n calldata: mockTransactionField.calldata,\n proxyAddress: mockTransactionField.proxyAddress,\n chainId: mockTransactionField.chainId,\n challenge: mockTransactionField.challenge,\n });\n expect(result).toEqual({\n type: ClearSignContextType.ERROR,\n error: error,\n });\n expect(mockCertificateLoader.loadCertificate).not.toHaveBeenCalled();\n });\n\n it(\"should return proxy delegate call context when successful\", async () => {\n // GIVEN\n vi.spyOn(\n mockProxyDataSource,\n \"getProxyImplementationAddress\",\n ).mockResolvedValue(Right(mockProxyDelegateCall));\n vi.spyOn(mockCertificateLoader, \"loadCertificate\").mockResolvedValue(\n mockCertificate,\n );\n\n // WHEN\n const result =\n await proxyContextFieldLoader.loadField(mockTransactionField);\n\n // THEN\n expect(\n mockProxyDataSource.getProxyImplementationAddress,\n ).toHaveBeenCalledWith({\n calldata: mockTransactionField.calldata,\n proxyAddress: mockTransactionField.proxyAddress,\n chainId: mockTransactionField.chainId,\n challenge: mockTransactionField.challenge,\n });\n expect(mockCertificateLoader.loadCertificate).toHaveBeenCalledWith({\n keyId: KeyId.CalCalldataKey,\n keyUsage: KeyUsage.Calldata,\n targetDevice: mockTransactionField.deviceModelId,\n });\n expect(result).toEqual({\n type: ClearSignContextType.PROXY_DELEGATE_CALL,\n payload: mockProxyDelegateCall.signedDescriptor,\n certificate: mockCertificate,\n });\n });\n\n it(\"should return proxy delegate call context with undefined certificate when certificate loading returns undefined\", async () => {\n // GIVEN\n vi.spyOn(\n mockProxyDataSource,\n \"getProxyImplementationAddress\",\n ).mockResolvedValue(Right(mockProxyDelegateCall));\n vi.spyOn(mockCertificateLoader, \"loadCertificate\").mockResolvedValue(\n undefined,\n );\n\n // WHEN\n const result =\n await proxyContextFieldLoader.loadField(mockTransactionField);\n\n // THEN\n expect(\n mockProxyDataSource.getProxyImplementationAddress,\n ).toHaveBeenCalledWith({\n calldata: mockTransactionField.calldata,\n proxyAddress: mockTransactionField.proxyAddress,\n chainId: mockTransactionField.chainId,\n challenge: mockTransactionField.challenge,\n });\n expect(mockCertificateLoader.loadCertificate).toHaveBeenCalledWith({\n keyId: KeyId.CalCalldataKey,\n keyUsage: KeyUsage.Calldata,\n targetDevice: mockTransactionField.deviceModelId,\n });\n expect(result).toEqual({\n type: ClearSignContextType.PROXY_DELEGATE_CALL,\n payload: mockProxyDelegateCall.signedDescriptor,\n certificate: undefined,\n });\n });\n\n it(\"should handle different device model IDs correctly\", async () => {\n // GIVEN\n const nanoXField = {\n ...mockTransactionField,\n deviceModelId: DeviceModelId.NANO_X,\n };\n vi.spyOn(\n mockProxyDataSource,\n \"getProxyImplementationAddress\",\n ).mockResolvedValue(Right(mockProxyDelegateCall));\n vi.spyOn(mockCertificateLoader, \"loadCertificate\").mockResolvedValue(\n mockCertificate,\n );\n\n // WHEN\n const result = await proxyContextFieldLoader.loadField(nanoXField);\n\n // THEN\n expect(mockCertificateLoader.loadCertificate).toHaveBeenCalledWith({\n keyId: KeyId.CalCalldataKey,\n keyUsage: KeyUsage.Calldata,\n targetDevice: DeviceModelId.NANO_X,\n });\n expect(result).toEqual({\n type: ClearSignContextType.PROXY_DELEGATE_CALL,\n payload: mockProxyDelegateCall.signedDescriptor,\n certificate: mockCertificate,\n });\n });\n\n it(\"should handle different chain IDs and addresses correctly\", async () => {\n // GIVEN\n const customField = {\n ...mockTransactionField,\n chainId: 137,\n proxyAddress: \"0xdeadbeef\",\n calldata: \"0xcafebabe\",\n challenge: \"custom-challenge\",\n };\n vi.spyOn(\n mockProxyDataSource,\n \"getProxyImplementationAddress\",\n ).mockResolvedValue(Right(mockProxyDelegateCall));\n vi.spyOn(mockCertificateLoader, \"loadCertificate\").mockResolvedValue(\n mockCertificate,\n );\n\n // WHEN\n const result = await proxyContextFieldLoader.loadField(customField);\n\n // THEN\n expect(\n mockProxyDataSource.getProxyImplementationAddress,\n ).toHaveBeenCalledWith({\n calldata: \"0xcafebabe\",\n proxyAddress: \"0xdeadbeef\",\n chainId: 137,\n challenge: \"custom-challenge\",\n });\n expect(result).toEqual({\n type: ClearSignContextType.PROXY_DELEGATE_CALL,\n payload: mockProxyDelegateCall.signedDescriptor,\n certificate: mockCertificate,\n });\n });\n\n it(\"should handle certificate loading failure gracefully\", async () => {\n // GIVEN\n vi.spyOn(\n mockProxyDataSource,\n \"getProxyImplementationAddress\",\n ).mockResolvedValue(Right(mockProxyDelegateCall));\n vi.spyOn(mockCertificateLoader, \"loadCertificate\").mockRejectedValue(\n new Error(\"Certificate loading failed\"),\n );\n\n // WHEN & THEN\n await expect(\n proxyContextFieldLoader.loadField(mockTransactionField),\n ).rejects.toThrow(\"Certificate loading failed\");\n\n expect(\n mockProxyDataSource.getProxyImplementationAddress,\n ).toHaveBeenCalled();\n expect(mockCertificateLoader.loadCertificate).toHaveBeenCalled();\n });\n\n it(\"should preserve error message from proxy data source\", async () => {\n // GIVEN\n const specificError = new Error(\"Network timeout error\");\n vi.spyOn(\n mockProxyDataSource,\n \"getProxyImplementationAddress\",\n ).mockResolvedValue(Left(specificError));\n\n // WHEN\n const result =\n await proxyContextFieldLoader.loadField(mockTransactionField);\n\n // THEN\n expect(result).toEqual({\n type: ClearSignContextType.ERROR,\n error: specificError,\n });\n });\n\n it(\"should handle empty signed descriptor\", async () => {\n // GIVEN\n const proxyCallWithEmptyDescriptor = {\n ...mockProxyDelegateCall,\n signedDescriptor: \"\",\n };\n vi.spyOn(\n mockProxyDataSource,\n \"getProxyImplementationAddress\",\n ).mockResolvedValue(Right(proxyCallWithEmptyDescriptor));\n vi.spyOn(mockCertificateLoader, \"loadCertificate\").mockResolvedValue(\n mockCertificate,\n );\n\n // WHEN\n const result =\n await proxyContextFieldLoader.loadField(mockTransactionField);\n\n // THEN\n expect(result).toEqual({\n type: ClearSignContextType.PROXY_DELEGATE_CALL,\n payload: \"\",\n certificate: mockCertificate,\n });\n });\n });\n});\n"],
|
|
5
|
+
"mappings": "AAAA,OAAS,iBAAAA,MAAqB,kCAC9B,OAAS,QAAAC,EAAM,SAAAC,MAAa,YAG5B,OAAS,SAAAC,MAAa,oBACtB,OAAS,YAAAC,MAAgB,uBAGzB,OAAS,2BAAAC,MAA+B,yCAExC,OAAS,0BAAAC,MAA8B,qCACvC,OAAS,wBAAAC,MAA4B,kCAGrC,SAAS,0BAA2B,IAAM,CACxC,MAAMC,EAAuC,CAC3C,8BAA+B,GAAG,GAAG,CACvC,EACMC,EAA8C,CAClD,gBAAiB,GAAG,GAAG,CACzB,EACMC,EAA0B,IAAIL,EAClCG,EACAC,CACF,EAEME,EACJ,CACE,KAAML,EAAuB,oBAC7B,QAAS,EACT,aAAc,qBACd,SAAU,qBACV,UAAW,iBACX,cAAeN,EAAc,IAC/B,EAEIY,EAA2C,CAC/C,sBAAuB,qBACvB,iBAAkB,oBACpB,EAEMC,EAAkC,CACtC,eAAgB,EAChB,QAAS,IAAI,WAAW,CAAC,EAAG,EAAG,EAAG,CAAC,CAAC,CACtC,EAEA,WAAW,IAAM,CACf,GAAG,cAAc,CACnB,CAAC,EAED,SAAS,YAAa,IAAM,CAC1B,GAAG,2CAA4C,IAAM,CAEnD,MAAMC,EAAa,CACjB,KAAMR,EAAuB,oBAC7B,QAAS,EACT,aAAc,qBACd,SAAU,qBACV,UAAW,iBACX,cAAeN,EAAc,IAC/B,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derKind", "ClearSignContextType", "mockProxyDataSource", "mockCertificateLoader", "proxyContextFieldLoader", "mockTransactionField", "mockProxyDelegateCall", "mockCertificate", "validField", "invalidFields", "value", "error", "result", "nanoXField", "customField", "specificError", "proxyCallWithEmptyDescriptor"]
|
|
7
|
+
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
var
|
|
1
|
+
var n=(e=>(e.PROXY_DELEGATE_CALL="proxy_delegate_call",e.TOKEN="token",e.NFT="nft",e.TRUSTED_NAME="trusted_name",e))(n||{});export{n as ContextFieldLoaderKind};
|
|
2
2
|
//# sourceMappingURL=ContextFieldLoader.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../src/shared/domain/ContextFieldLoader.ts"],
|
|
4
|
-
"sourcesContent": ["import { type ClearSignContext } from \"@/shared/model/ClearSignContext\";\
|
|
5
|
-
"mappings": "
|
|
4
|
+
"sourcesContent": ["import { type ClearSignContext } from \"@/shared/model/ClearSignContext\";\n\nexport enum ContextFieldLoaderKind {\n PROXY_DELEGATE_CALL = \"proxy_delegate_call\",\n TOKEN = \"token\",\n NFT = \"nft\",\n TRUSTED_NAME = \"trusted_name\",\n}\n\nexport interface ContextFieldLoader<TInput = unknown> {\n loadField: (field: TInput) => Promise<ClearSignContext>;\n canHandle: (field: unknown) => boolean;\n}\n"],
|
|
5
|
+
"mappings": "AAEO,IAAKA,OACVA,EAAA,oBAAsB,sBACtBA,EAAA,MAAQ,QACRA,EAAA,IAAM,MACNA,EAAA,aAAe,eAJLA,OAAA",
|
|
6
6
|
"names": ["ContextFieldLoaderKind"]
|
|
7
7
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
//# sourceMappingURL=TransactionFieldContext.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
const
|
|
1
|
+
const a=255;var t=(e=>(e.None="none",e.Present="present",e.VerifyingContract="verifying_contract",e))(t||{});export{t as TypedDataCalldataParamPresence,a as VERIFYING_CONTRACT_TOKEN_INDEX};
|
|
2
2
|
//# sourceMappingURL=TypedDataClearSignContext.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../src/shared/model/TypedDataClearSignContext.ts"],
|
|
4
|
-
"sourcesContent": ["import type { HexaString } from \"@ledgerhq/device-management-kit\";\n\n// The general informations for a typed message\nexport type TypedDataMessageInfo = {\n displayName: string;\n filtersCount: number;\n signature: string;\n};\n\n// Token index and descriptor. Needed for tokens that are referenced by a typed message\nexport type TypedDataTokenIndex = number;\nexport type TypedDataToken = string;\n// Special token index value when the referenced token is the verifying contract\nexport const VERIFYING_CONTRACT_TOKEN_INDEX = 255;\n\n// Typed message filters, to select fields to display, and provide formatting informations\nexport type TypedDataFilterPath = string;\nexport type TypedDataFilterWithToken = {\n type: \"amount\" | \"token\";\n displayName: string;\n tokenIndex: TypedDataTokenIndex;\n path: TypedDataFilterPath;\n signature: string;\n};\nexport type TypedDataFilterWithTrustedName = {\n type: \"trusted-name\";\n displayName: string;\n types: string[];\n sources: string[];\n typesAndSourcesPayload: string;\n path: TypedDataFilterPath;\n signature: string;\n};\nexport type TypedDataFilter =\n | {\n type: \"datetime\" | \"raw\";\n displayName: string;\n path: TypedDataFilterPath;\n signature: string;\n }\n | TypedDataFilterWithToken\n | TypedDataFilterWithTrustedName;\n\n// Clear signing context for a typed message\nexport type TypedDataClearSignContextSuccess = {\n type: \"success\";\n messageInfo: TypedDataMessageInfo;\n filters: Record<TypedDataFilterPath, TypedDataFilter>;\n trustedNamesAddresses: Record<TypedDataFilterPath, HexaString>;\n tokens: Record<TypedDataTokenIndex, TypedDataToken>;\n};\nexport type TypedDataClearSignContextError = {\n type: \"error\";\n error: Error;\n};\nexport type TypedDataClearSignContext =\n | TypedDataClearSignContextSuccess\n | TypedDataClearSignContextError;\n"],
|
|
5
|
-
"mappings": "
|
|
6
|
-
"names": ["VERIFYING_CONTRACT_TOKEN_INDEX"]
|
|
4
|
+
"sourcesContent": ["import type { HexaString } from \"@ledgerhq/device-management-kit\";\n\nimport {\n type ClearSignContextSuccess,\n type ClearSignContextType,\n} from \"@/shared/model/ClearSignContext\";\nimport { type TransactionSubset } from \"@/shared/model/TransactionSubset\";\n\n// The general informations for a typed message\nexport type TypedDataMessageInfo = {\n displayName: string;\n filtersCount: number;\n signature: string;\n};\n\n// Token index and descriptor. Needed for tokens that are referenced by a typed message\nexport type TypedDataTokenIndex = number;\nexport type TypedDataToken = string;\n// Calldata index. Needed for calldatas that are referenced by a typed message\nexport type TypedDataCalldataIndex = number;\n// Special token index value when the referenced token is the verifying contract\nexport const VERIFYING_CONTRACT_TOKEN_INDEX = 255;\n\n// Typed message filters, to select fields to display, and provide formatting informations\nexport type TypedDataFilterPath = string;\nexport type TypedDataFilterWithToken = {\n type: \"amount\" | \"token\";\n displayName: string;\n tokenIndex: TypedDataTokenIndex;\n path: TypedDataFilterPath;\n signature: string;\n};\nexport type TypedDataFilterWithTrustedName = {\n type: \"trusted-name\";\n displayName: string;\n types: string[];\n sources: string[];\n typesAndSourcesPayload: string;\n path: TypedDataFilterPath;\n signature: string;\n};\nexport type TypedDataFilterCalldata = {\n type:\n | \"calldata-value\"\n | \"calldata-callee\"\n | \"calldata-chain-id\"\n | \"calldata-selector\"\n | \"calldata-amount\"\n | \"calldata-spender\";\n displayName: string;\n calldataIndex: TypedDataCalldataIndex;\n path: TypedDataFilterPath;\n signature: string;\n};\nexport type TypedDataFilter =\n | {\n type: \"datetime\" | \"raw\";\n displayName: string;\n path: TypedDataFilterPath;\n signature: string;\n }\n | TypedDataFilterWithToken\n | TypedDataFilterWithTrustedName\n | TypedDataFilterCalldata;\n\n// Calldata info when referenced by a typed message\nexport enum TypedDataCalldataParamPresence {\n None = \"none\",\n Present = \"present\",\n VerifyingContract = \"verifying_contract\",\n}\nexport type TypedDataFilterCalldataInfo = {\n displayName: string;\n calldataIndex: TypedDataCalldataIndex;\n valueFlag: boolean;\n calleeFlag: TypedDataCalldataParamPresence;\n chainIdFlag: boolean;\n selectorFlag: boolean;\n amountFlag: boolean;\n spenderFlag: TypedDataCalldataParamPresence;\n signature: string;\n};\nexport type TypedDataCalldataInfo = {\n filter: TypedDataFilterCalldataInfo;\n subset: TransactionSubset;\n};\n\n// Clear signing context for a typed message\nexport type TypedDataClearSignContextSuccess = {\n type: \"success\";\n messageInfo: TypedDataMessageInfo;\n filters: Record<TypedDataFilterPath, TypedDataFilter>;\n trustedNamesAddresses: Record<TypedDataFilterPath, HexaString>;\n tokens: Record<TypedDataTokenIndex, TypedDataToken>;\n calldatas: Record<TypedDataCalldataIndex, TypedDataCalldataInfo>;\n proxy?: ClearSignContextSuccess<ClearSignContextType.PROXY_DELEGATE_CALL>;\n};\nexport type TypedDataClearSignContextError = {\n type: \"error\";\n error: Error;\n};\nexport type TypedDataClearSignContext =\n | TypedDataClearSignContextSuccess\n | TypedDataClearSignContextError;\n"],
|
|
5
|
+
"mappings": "AAqBO,MAAMA,EAAiC,IA6CvC,IAAKC,OACVA,EAAA,KAAO,OACPA,EAAA,QAAU,UACVA,EAAA,kBAAoB,qBAHVA,OAAA",
|
|
6
|
+
"names": ["VERIFYING_CONTRACT_TOKEN_INDEX", "TypedDataCalldataParamPresence"]
|
|
7
7
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
var
|
|
1
|
+
var c=Object.defineProperty;var m=Object.getOwnPropertyDescriptor;var l=(a,e,o,t)=>{for(var n=t>1?void 0:t?m(e,o):e,i=a.length-1,d;i>=0;i--)(d=a[i])&&(n=(t?d(e,o,n):d(n))||n);return t&&n&&c(e,o,n),n},p=(a,e)=>(o,t)=>e(o,t,a);import{inject as y,injectable as u}from"inversify";import{ContextFieldLoaderKind as C}from"../../shared/domain/ContextFieldLoader";import{ClearSignContextType as s}from"../../shared/model/ClearSignContext";import{tokenTypes as k}from"../../token/di/tokenTypes";let r=class{constructor(e){this._dataSource=e}canHandle(e){return typeof e=="object"&&e!==null&&"kind"in e&&e.kind===C.TOKEN&&"chainId"in e&&"address"in e}async loadField(e){return(await this._dataSource.getTokenInfosPayload({address:e.address,chainId:e.chainId})).caseOf({Left:t=>({type:s.ERROR,error:t}),Right:t=>({type:s.TOKEN,payload:t})})}};r=l([u(),p(0,y(k.TokenDataSource))],r);export{r as TokenContextFieldLoader};
|
|
2
2
|
//# sourceMappingURL=TokenContextFieldLoader.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../src/token/domain/TokenContextFieldLoader.ts"],
|
|
4
|
-
"sourcesContent": ["import { inject, injectable } from \"inversify\";\n\nimport {\n type ContextFieldLoader,\n ContextFieldLoaderKind,\n} from \"@/shared/domain/ContextFieldLoader\";\nimport {\n type ClearSignContext,\n ClearSignContextType,\n} from \"@/shared/model/ClearSignContext\";\nimport { type
|
|
5
|
-
"mappings": "iOAAA,OAAS,UAAAA,EAAQ,cAAAC,MAAkB,YAEnC,OAEE,0BAAAC,MACK,qCACP,OAEE,wBAAAC,MACK,
|
|
6
|
-
"names": ["inject", "injectable", "ContextFieldLoaderKind", "ClearSignContextType", "tokenTypes", "TokenContextFieldLoader", "_dataSource", "ContextFieldLoaderKind", "field", "error", "ClearSignContextType", "value", "__decorateClass", "injectable", "__decorateParam", "inject", "tokenTypes"]
|
|
4
|
+
"sourcesContent": ["import { inject, injectable } from \"inversify\";\n\nimport {\n type ContextFieldLoader,\n ContextFieldLoaderKind,\n} from \"@/shared/domain/ContextFieldLoader\";\nimport {\n type ClearSignContext,\n ClearSignContextType,\n} from \"@/shared/model/ClearSignContext\";\nimport { type TokenDataSource } from \"@/token/data/TokenDataSource\";\nimport { tokenTypes } from \"@/token/di/tokenTypes\";\n\nexport type TokenFieldInput = {\n kind: ContextFieldLoaderKind.TOKEN;\n chainId: number;\n address: string;\n};\n\n@injectable()\nexport class TokenContextFieldLoader\n implements ContextFieldLoader<TokenFieldInput>\n{\n constructor(\n @inject(tokenTypes.TokenDataSource) private _dataSource: TokenDataSource,\n ) {}\n\n canHandle(input: unknown): input is TokenFieldInput {\n return (\n typeof input === \"object\" &&\n input !== null &&\n \"kind\" in input &&\n input.kind === ContextFieldLoaderKind.TOKEN &&\n \"chainId\" in input &&\n \"address\" in input\n );\n }\n\n async loadField(field: TokenFieldInput): Promise<ClearSignContext> {\n const payload = await this._dataSource.getTokenInfosPayload({\n address: field.address,\n chainId: field.chainId,\n });\n return payload.caseOf({\n Left: (error): ClearSignContext => ({\n type: ClearSignContextType.ERROR,\n error,\n }),\n Right: (value): ClearSignContext => ({\n type: ClearSignContextType.TOKEN,\n payload: value,\n }),\n });\n }\n}\n"],
|
|
5
|
+
"mappings": "iOAAA,OAAS,UAAAA,EAAQ,cAAAC,MAAkB,YAEnC,OAEE,0BAAAC,MACK,qCACP,OAEE,wBAAAC,MACK,kCAEP,OAAS,cAAAC,MAAkB,wBASpB,IAAMC,EAAN,KAEP,CACE,YAC8CC,EAC5C,CAD4C,iBAAAA,CAC3C,CAEH,UAAUC,EAA0C,CAClD,OACE,OAAOA,GAAU,UACjBA,IAAU,MACV,SAAUA,GACVA,EAAM,OAASC,EAAuB,OACtC,YAAaD,GACb,YAAaA,CAEjB,CAEA,MAAM,UAAUE,EAAmD,CAKjE,OAJgB,MAAM,KAAK,YAAY,qBAAqB,CAC1D,QAASA,EAAM,QACf,QAASA,EAAM,OACjB,CAAC,GACc,OAAO,CACpB,KAAOC,IAA6B,CAClC,KAAMC,EAAqB,MAC3B,MAAAD,CACF,GACA,MAAQE,IAA6B,CACnC,KAAMD,EAAqB,MAC3B,QAASC,CACX,EACF,CAAC,CACH,CACF,EAlCaP,EAANQ,EAAA,CADNC,EAAW,EAKPC,EAAA,EAAAC,EAAOC,EAAW,eAAe,IAJzBZ",
|
|
6
|
+
"names": ["inject", "injectable", "ContextFieldLoaderKind", "ClearSignContextType", "tokenTypes", "TokenContextFieldLoader", "_dataSource", "input", "ContextFieldLoaderKind", "field", "error", "ClearSignContextType", "value", "__decorateClass", "injectable", "__decorateParam", "inject", "tokenTypes"]
|
|
7
7
|
}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{Left as i,Right as r}from"purify-ts";import{ContextFieldLoaderKind as d}from"../../shared/domain/ContextFieldLoader";import{ClearSignContextType as s}from"../../shared/model/ClearSignContext";import{TokenContextFieldLoader as c}from"../../token/domain/TokenContextFieldLoader";describe("TokenContextFieldLoader",()=>{const a={getTokenInfosPayload:vi.fn()},t=new c(a),o={kind:d.TOKEN,chainId:1,address:"0x1234567890abcdef"},l="0x123456789abcdef0";beforeEach(()=>{vi.resetAllMocks()}),describe("canHandle",()=>{it("should return true for valid token field",()=>{const e={kind:d.TOKEN,chainId:1,address:"0x1234567890abcdef"};expect(t.canHandle(e)).toBe(!0)}),describe("should return false for invalid fields",()=>{const e=[{name:"null",value:null},{name:"undefined",value:void 0},{name:"string",value:"invalid"},{name:"number",value:123},{name:"boolean",value:!0},{name:"array",value:[]},{name:"empty object",value:{}},{name:"object missing kind",value:{chainId:1,address:"0x123"}},{name:"object missing chainId",value:{kind:d.TOKEN,address:"0x123"}},{name:"object missing address",value:{kind:d.TOKEN,chainId:1}},{name:"object with wrong kind",value:{kind:d.NFT,chainId:1,address:"0x123"}}];test.each(e)("$name",({value:n})=>{expect(t.canHandle(n)).toBe(!1)})})}),describe("loadField",()=>{it("should return error context when token data source fails",async()=>{const e=new Error("Token data source error");vi.spyOn(a,"getTokenInfosPayload").mockResolvedValue(i(e));const n=await t.loadField(o);expect(a.getTokenInfosPayload).toHaveBeenCalledWith({address:o.address,chainId:o.chainId}),expect(n).toEqual({type:s.ERROR,error:e})}),it("should return token context when successful",async()=>{vi.spyOn(a,"getTokenInfosPayload").mockResolvedValue(r(l));const e=await t.loadField(o);expect(a.getTokenInfosPayload).toHaveBeenCalledWith({address:o.address,chainId:o.chainId}),expect(e).toEqual({type:s.TOKEN,payload:l})}),it("should handle different chain IDs and addresses correctly",async()=>{const e={...o,chainId:137,address:"0xdeadbeef"};vi.spyOn(a,"getTokenInfosPayload").mockResolvedValue(r(l));const n=await t.loadField(e);expect(a.getTokenInfosPayload).toHaveBeenCalledWith({address:"0xdeadbeef",chainId:137}),expect(n).toEqual({type:s.TOKEN,payload:l})}),it("should preserve error message from token data source",async()=>{const e=new Error("Network timeout error");vi.spyOn(a,"getTokenInfosPayload").mockResolvedValue(i(e));const n=await t.loadField(o);expect(n).toEqual({type:s.ERROR,error:e})}),it("should handle empty token payload",async()=>{const e="";vi.spyOn(a,"getTokenInfosPayload").mockResolvedValue(r(e));const n=await t.loadField(o);expect(n).toEqual({type:s.TOKEN,payload:e})})})});
|
|
2
|
+
//# sourceMappingURL=TokenContextFieldLoader.test.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../../src/token/domain/TokenContextFieldLoader.test.ts"],
|
|
4
|
+
"sourcesContent": ["import { Left, Right } from \"purify-ts\";\n\nimport { ContextFieldLoaderKind } from \"@/shared/domain/ContextFieldLoader\";\nimport { ClearSignContextType } from \"@/shared/model/ClearSignContext\";\nimport { type TransactionFieldContext } from \"@/shared/model/TransactionFieldContext\";\nimport { type TokenDataSource } from \"@/token/data/TokenDataSource\";\nimport { TokenContextFieldLoader } from \"@/token/domain/TokenContextFieldLoader\";\n\ndescribe(\"TokenContextFieldLoader\", () => {\n const mockTokenDataSource: TokenDataSource = {\n getTokenInfosPayload: vi.fn(),\n };\n const tokenContextFieldLoader = new TokenContextFieldLoader(\n mockTokenDataSource,\n );\n\n const mockTransactionField: TransactionFieldContext<ContextFieldLoaderKind.TOKEN> =\n {\n kind: ContextFieldLoaderKind.TOKEN,\n chainId: 1,\n address: \"0x1234567890abcdef\",\n };\n\n const mockTokenPayload = \"0x123456789abcdef0\";\n\n beforeEach(() => {\n vi.resetAllMocks();\n });\n\n describe(\"canHandle\", () => {\n it(\"should return true for valid token field\", () => {\n // GIVEN\n const validField = {\n kind: ContextFieldLoaderKind.TOKEN,\n chainId: 1,\n address: \"0x1234567890abcdef\",\n };\n\n // THEN\n expect(tokenContextFieldLoader.canHandle(validField)).toBe(true);\n });\n\n describe(\"should return false for invalid fields\", () => {\n const invalidFields = [\n { name: \"null\", value: null },\n { name: \"undefined\", value: undefined },\n { name: \"string\", value: \"invalid\" },\n { name: \"number\", value: 123 },\n { name: \"boolean\", value: true },\n { name: \"array\", value: [] },\n { name: \"empty object\", value: {} },\n {\n name: \"object missing kind\",\n value: { chainId: 1, address: \"0x123\" },\n },\n {\n name: \"object missing chainId\",\n value: { kind: ContextFieldLoaderKind.TOKEN, address: \"0x123\" },\n },\n {\n name: \"object missing address\",\n value: { kind: ContextFieldLoaderKind.TOKEN, chainId: 1 },\n },\n {\n name: \"object with wrong kind\",\n value: {\n kind: ContextFieldLoaderKind.NFT,\n chainId: 1,\n address: \"0x123\",\n },\n },\n ];\n\n test.each(invalidFields)(\"$name\", ({ value }) => {\n expect(tokenContextFieldLoader.canHandle(value)).toBe(false);\n });\n });\n });\n\n describe(\"loadField\", () => {\n it(\"should return error context when token data source fails\", async () => {\n // GIVEN\n const error = new Error(\"Token data source error\");\n vi.spyOn(mockTokenDataSource, \"getTokenInfosPayload\").mockResolvedValue(\n Left(error),\n );\n\n // WHEN\n const result =\n await tokenContextFieldLoader.loadField(mockTransactionField);\n\n // THEN\n expect(mockTokenDataSource.getTokenInfosPayload).toHaveBeenCalledWith({\n address: mockTransactionField.address,\n chainId: mockTransactionField.chainId,\n });\n expect(result).toEqual({\n type: ClearSignContextType.ERROR,\n error: error,\n });\n });\n\n it(\"should return token context when successful\", async () => {\n // GIVEN\n vi.spyOn(mockTokenDataSource, \"getTokenInfosPayload\").mockResolvedValue(\n Right(mockTokenPayload),\n );\n\n // WHEN\n const result =\n await tokenContextFieldLoader.loadField(mockTransactionField);\n\n // THEN\n expect(mockTokenDataSource.getTokenInfosPayload).toHaveBeenCalledWith({\n address: mockTransactionField.address,\n chainId: mockTransactionField.chainId,\n });\n expect(result).toEqual({\n type: ClearSignContextType.TOKEN,\n payload: mockTokenPayload,\n });\n });\n\n it(\"should handle different chain IDs and addresses correctly\", async () => {\n // GIVEN\n const customField = {\n ...mockTransactionField,\n chainId: 137,\n address: \"0xdeadbeef\",\n };\n vi.spyOn(mockTokenDataSource, \"getTokenInfosPayload\").mockResolvedValue(\n Right(mockTokenPayload),\n );\n\n // WHEN\n const result = await tokenContextFieldLoader.loadField(customField);\n\n // THEN\n expect(mockTokenDataSource.getTokenInfosPayload).toHaveBeenCalledWith({\n address: \"0xdeadbeef\",\n chainId: 137,\n });\n expect(result).toEqual({\n type: ClearSignContextType.TOKEN,\n payload: mockTokenPayload,\n });\n });\n\n it(\"should preserve error message from token data source\", async () => {\n // GIVEN\n const specificError = new Error(\"Network timeout error\");\n vi.spyOn(mockTokenDataSource, \"getTokenInfosPayload\").mockResolvedValue(\n Left(specificError),\n );\n\n // WHEN\n const result =\n await tokenContextFieldLoader.loadField(mockTransactionField);\n\n // THEN\n expect(result).toEqual({\n type: ClearSignContextType.ERROR,\n error: specificError,\n });\n });\n\n it(\"should handle empty token payload\", async () => {\n // GIVEN\n const emptyPayload = \"\";\n vi.spyOn(mockTokenDataSource, \"getTokenInfosPayload\").mockResolvedValue(\n Right(emptyPayload),\n );\n\n // WHEN\n const result =\n await tokenContextFieldLoader.loadField(mockTransactionField);\n\n // THEN\n expect(result).toEqual({\n type: ClearSignContextType.TOKEN,\n payload: emptyPayload,\n });\n });\n });\n});\n"],
|
|
5
|
+
"mappings": "AAAA,OAAS,QAAAA,EAAM,SAAAC,MAAa,YAE5B,OAAS,0BAAAC,MAA8B,qCACvC,OAAS,wBAAAC,MAA4B,kCAGrC,OAAS,2BAAAC,MAA+B,yCAExC,SAAS,0BAA2B,IAAM,CACxC,MAAMC,EAAuC,CAC3C,qBAAsB,GAAG,GAAG,CAC9B,EACMC,EAA0B,IAAIF,EAClCC,CACF,EAEME,E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CAAqC,SAAY,CAElD,MAAMC,EAAe,GACrB,GAAG,MAAMX,EAAqB,sBAAsB,EAAE,kBACpDJ,EAAMe,CAAY,CACpB,EAGA,MAAMH,EACJ,MAAMP,EAAwB,UAAUC,CAAoB,EAG9D,OAAOM,CAAM,EAAE,QAAQ,CACrB,KAAMV,EAAqB,MAC3B,QAASa,CACX,CAAC,CACH,CAAC,CACH,CAAC,CACH,CAAC",
|
|
6
|
+
"names": ["Left", "Right", "ContextFieldLoaderKind", "ClearSignContextType", "TokenContextFieldLoader", "mockTokenDataSource", "tokenContextFieldLoader", "mockTransactionField", "mockTokenPayload", "validField", "invalidFields", "value", "error", "result", "customField", "specificError", "emptyPayload"]
|
|
7
|
+
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
var
|
|
1
|
+
var I=Object.defineProperty;var S=Object.getOwnPropertyDescriptor;var h=(l,e,t,r)=>{for(var i=r>1?void 0:r?S(e,t):e,n=l.length-1,o;n>=0;n--)(o=l[n])&&(i=(r?o(e,t,i):o(i))||i);return r&&i&&I(e,t,i),i},y=(l,e)=>(t,r)=>e(t,r,l);import M from"axios";import{inject as m,injectable as R}from"inversify";import{Left as c,Right as L}from"purify-ts";import{configTypes as x}from"../../config/di/configTypes";import{pkiTypes as O}from"../../pki/di/pkiTypes";import{KeyId as F}from"../../pki/model/KeyId";import{KeyUsage as G}from"../../pki/model/KeyUsage";import{LEDGER_CLIENT_VERSION_HEADER as k,LEDGER_ORIGIN_TOKEN_HEADER as U}from"../../shared/constant/HttpHeaders";import{ClearSignContextReferenceType as a,ClearSignContextType as f}from"../../shared/model/ClearSignContext";import{INFO_SIGNATURE_TAG as T}from"../../shared/model/SignatureTags";import{HexStringUtils as D}from"../../shared/utils/HexStringUtils";import j from"../../../package.json";let u=class{constructor(e,t){this.config=e;this._certificateLoader=t}async getTransactionDescriptors({chainId:e,address:t,selector:r,deviceModelId:i}){let n;try{n=(await M.request({method:"GET",url:`${this.config.cal.url}/dapps`,params:{output:"descriptors_calldata",chain_id:e,contracts:t,ref:"commit:cdd7d0f9cec33eb969a12641810cc7b06efeec1c"},headers:{[k]:`context-module/${j.version}`,[U]:this.config.originToken}})).data}catch(o){return c(new Error(`[ContextModule] HttpTransactionDataSource: Failed to fetch transaction informations: ${o}`))}if(!Array.isArray(n))return c(new Error("[ContextModule] HttpTransactionDataSource: Response is not an array"));if(n.length===0)return c(new Error(`[ContextModule] HttpTransactionDataSource: No data for contract ${t} and selector ${r}`));for(const o of n){t=t.toLowerCase(),r=`0x${r.slice(2).toLowerCase()}`;const s=o.descriptors_calldata?.[t]?.[r];if(!s||!this.isCalldataDescriptorV1(s,this.config.cal.mode))continue;const E=s.transaction_info.descriptor.data,V=s.transaction_info.descriptor.signatures[this.config.cal.mode],g={targetDevice:i,keyUsage:G.Calldata,keyId:F.CalCalldataKey},C=await this._certificateLoader.loadCertificate(g),A={type:f.TRANSACTION_INFO,payload:D.appendSignatureToPayload(E,V,T),certificate:C},d=[];for(const[p,b]of Object.entries(s.enums))for(const[P,{data:v,signatures:N}]of Object.entries(b))d.push({type:f.ENUM,id:Number(p),value:Number(P),payload:D.appendSignatureToPayload(v,N[this.config.cal.mode],T),certificate:C});const _=s.fields.map(p=>({type:f.TRANSACTION_FIELD_DESCRIPTION,payload:p.descriptor,reference:this.getReference(p.param)}));return L([A,...d,..._])}return c(new Error(`[ContextModule] HttpTransactionDataSource: Invalid response for contract ${t} and selector ${r}`))}getReference(e){if(e.type==="TOKEN_AMOUNT"&&e.token!==void 0&&e.token.type==="path")return{type:a.TOKEN,valuePath:this.toGenericPath(e.token.binary_path)};if(e.type==="TOKEN_AMOUNT"&&e.token!==void 0&&e.token.type==="constant")return{type:a.TOKEN,value:e.token.value};if(e.type==="NFT"&&e.collection.type==="path")return{type:a.NFT,valuePath:this.toGenericPath(e.collection.binary_path)};if(e.type==="NFT"&&e.collection.type==="constant")return{type:a.NFT,value:e.collection.value};if(e.type==="TRUSTED_NAME"&&e.value.type==="path")return{type:a.TRUSTED_NAME,valuePath:this.toGenericPath(e.value.binary_path),types:e.types,sources:e.sources};if(e.type==="ENUM"&&e.value.type==="path")return{type:a.ENUM,valuePath:this.toGenericPath(e.value.binary_path),id:e.id};if(e.type==="CALLDATA"&&e.value.type==="path"&&e.callee.type==="path")return{type:a.CALLDATA,valuePath:this.toGenericPath(e.value.binary_path),callee:this.toGenericPath(e.callee.binary_path),selector:e.selector?.type==="path"?this.toGenericPath(e.selector.binary_path):void 0,amount:e.amount?.type==="path"?this.toGenericPath(e.amount.binary_path):void 0,spender:e.spender?.type==="path"?this.toGenericPath(e.spender.binary_path):void 0,chainId:e.chainId?.type==="path"?this.toGenericPath(e.chainId.binary_path):void 0}}toGenericPath(e){return e.type==="CONTAINER"?e.value:e.elements.map(t=>{if(t.type==="ARRAY"){const{weight:r,...i}=t;return{itemSize:r,...i}}else if(t.type==="LEAF"){const{leaf_type:r,...i}=t;return{leafType:r,...i}}return t})}isCalldataDescriptorV1(e,t){return typeof e=="object"&&e.type==="calldata"&&e.version==="v1"&&this.isTransactionInfoV1(e.transaction_info,t)&&this.isEnumV1(e.enums,t)&&Array.isArray(e.fields)&&e.fields.every(r=>this.isFieldV1(r))}isTransactionInfoV1(e,t){return typeof e=="object"&&typeof e.descriptor=="object"&&typeof e.descriptor.data=="string"&&typeof e.descriptor.signatures=="object"&&typeof e.descriptor.signatures[t]=="string"}isEnumV1(e,t){return typeof e=="object"&&Object.entries(e).every(([r,i])=>typeof r=="string"&&typeof i=="object"&&Object.entries(i).every(([n,o])=>typeof n=="string"&&typeof o=="object"&&typeof o.data=="string"&&o.signatures!==void 0&&this.isCalldataSignatures(o.signatures,t)))}isCalldataSignatures(e,t){return typeof e=="object"&&typeof e[t]=="string"}isFieldV1(e){return typeof e=="object"&&typeof e.descriptor=="string"&&typeof e.param=="object"&&typeof e.param.value=="object"&&this.isDescriptorValueV1(e.param.value)&&(e.param.type==="RAW"||e.param.type==="AMOUNT"||e.param.type==="DATETIME"||e.param.type==="DURATION"||e.param.type==="UNIT"||e.param.type==="ENUM"||e.param.type==="NFT"&&this.isDescriptorValueV1(e.param.collection)||e.param.type==="TOKEN_AMOUNT"&&(e.param.token===void 0||this.isDescriptorValueV1(e.param.token))||e.param.type==="TRUSTED_NAME"&&Array.isArray(e.param.types)&&Array.isArray(e.param.sources)&&e.param.types.every(t=>typeof t=="string")&&e.param.sources.every(t=>typeof t=="string")||e.param.type==="CALLDATA"&&this.isDescriptorValueV1(e.param.value)&&this.isDescriptorValueV1(e.param.callee)&&(e.param.selector===void 0||this.isDescriptorValueV1(e.param.selector))&&(e.param.amount===void 0||this.isDescriptorValueV1(e.param.amount))&&(e.param.spender===void 0||this.isDescriptorValueV1(e.param.spender))&&(e.param.chainId===void 0||this.isDescriptorValueV1(e.param.chainId)))}isDescriptorValueV1(e){return typeof e=="object"&&typeof e.type_family=="string"&&["UINT","INT","UFIXED","FIXED","ADDRESS","BOOL","BYTES","STRING"].includes(e.type_family)&&(typeof e.type_size>"u"||typeof e.type_size=="number")&&(e.type==="path"&&this.isCalldataDescriptorValueBinaryPathV1(e)||e.type==="constant"&&this.isCalldataDescriptorValueConstantV1(e))}isCalldataDescriptorValueConstantV1(e){return typeof e=="object"&&e.type==="constant"&&typeof e.value=="string"}isCalldataDescriptorValueBinaryPathV1(e){return typeof e=="object"&&(e.type==="path"&&e.binary_path.type==="CONTAINER"&&["FROM","TO","VALUE"].includes(e.binary_path.value)||e.binary_path.type==="DATA"&&Array.isArray(e.binary_path.elements)&&e.binary_path.elements.every(t=>this.isPathElementV1(t)))}isPathElementV1(e){return typeof e=="object"&&(e.type==="REF"||e.type==="TUPLE"&&typeof e.offset=="number"||e.type==="ARRAY"&&typeof e.weight=="number"&&(typeof e.start>"u"||typeof e.start=="number")&&(typeof e.end>"u"||typeof e.end=="number")||e.type==="LEAF"&&typeof e.leaf_type=="string"&&["ARRAY_LEAF","TUPLE_LEAF","STATIC_LEAF","DYNAMIC_LEAF"].includes(e.leaf_type)||e.type==="SLICE"&&(typeof e.start>"u"||typeof e.start=="number")&&(typeof e.end>"u"||typeof e.end=="number"))}};u=h([R(),y(0,m(x.Config)),y(1,m(O.PkiCertificateLoader))],u);export{u as HttpTransactionDataSource};
|
|
2
2
|
//# sourceMappingURL=HttpTransactionDataSource.js.map
|