@ledgerhq/context-module 1.16.0 → 1.17.1
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 +2 -3
- package/lib/cjs/src/DefaultContextModule.js +1 -1
- package/lib/cjs/src/DefaultContextModule.js.map +3 -3
- package/lib/cjs/src/account-ownership/data/AccountOwnershipDataSource.js +2 -0
- package/lib/cjs/src/account-ownership/data/AccountOwnershipDataSource.js.map +7 -0
- package/lib/cjs/src/account-ownership/data/AccountOwnershipError.js +2 -0
- package/lib/cjs/src/account-ownership/data/AccountOwnershipError.js.map +7 -0
- package/lib/cjs/src/account-ownership/data/HttpAccountOwnershipDataSource.js +2 -0
- package/lib/cjs/src/account-ownership/data/HttpAccountOwnershipDataSource.js.map +7 -0
- package/lib/cjs/src/account-ownership/data/HttpAccountOwnershipDataSource.test.js +2 -0
- package/lib/cjs/src/account-ownership/data/HttpAccountOwnershipDataSource.test.js.map +7 -0
- package/lib/cjs/src/account-ownership/data/dto/AccountOwnershipDto.js +2 -0
- package/lib/cjs/src/account-ownership/data/dto/AccountOwnershipDto.js.map +7 -0
- package/lib/cjs/src/account-ownership/di/accountOwnershipModuleFactory.js +2 -0
- package/lib/cjs/src/account-ownership/di/accountOwnershipModuleFactory.js.map +7 -0
- package/lib/cjs/src/account-ownership/di/accountOwnershipTypes.js +2 -0
- package/lib/cjs/src/account-ownership/di/accountOwnershipTypes.js.map +7 -0
- package/lib/cjs/src/account-ownership/domain/AccountOwnershipContextLoader.js +2 -0
- package/lib/cjs/src/account-ownership/domain/AccountOwnershipContextLoader.js.map +7 -0
- package/lib/cjs/src/account-ownership/domain/AccountOwnershipContextLoader.test.js +2 -0
- package/lib/cjs/src/account-ownership/domain/AccountOwnershipContextLoader.test.js.map +7 -0
- package/lib/cjs/src/calldata/data/HttpCalldataDescriptorDataSource.js +1 -1
- package/lib/cjs/src/calldata/data/HttpCalldataDescriptorDataSource.js.map +3 -3
- package/lib/cjs/src/calldata/data/HttpCalldataDescriptorDataSource.test.js +1 -1
- package/lib/cjs/src/calldata/data/HttpCalldataDescriptorDataSource.test.js.map +3 -3
- package/lib/cjs/src/calldata/di/calldataModuleFactory.js +1 -1
- package/lib/cjs/src/calldata/di/calldataModuleFactory.js.map +3 -3
- package/lib/cjs/src/di.js +1 -1
- package/lib/cjs/src/di.js.map +3 -3
- package/lib/cjs/src/dynamic-network/data/HttpDynamicNetworkDataSource.js +1 -1
- package/lib/cjs/src/dynamic-network/data/HttpDynamicNetworkDataSource.js.map +3 -3
- package/lib/cjs/src/dynamic-network/data/HttpDynamicNetworkDataSource.test.js +1 -1
- package/lib/cjs/src/dynamic-network/data/HttpDynamicNetworkDataSource.test.js.map +3 -3
- package/lib/cjs/src/external-plugin/data/HttpExternalPluginDataSource.js +1 -1
- package/lib/cjs/src/external-plugin/data/HttpExternalPluginDataSource.js.map +3 -3
- package/lib/cjs/src/external-plugin/data/HttpExternalPluginDataSource.test.js +1 -1
- package/lib/cjs/src/external-plugin/data/HttpExternalPluginDataSource.test.js.map +3 -3
- package/lib/cjs/src/gated-signing/data/HttpGatedDescriptorDataSource.js +1 -1
- package/lib/cjs/src/gated-signing/data/HttpGatedDescriptorDataSource.js.map +3 -3
- package/lib/cjs/src/gated-signing/data/HttpGatedDescriptorDataSource.test.js +1 -1
- package/lib/cjs/src/gated-signing/data/HttpGatedDescriptorDataSource.test.js.map +3 -3
- package/lib/cjs/src/index.js +1 -1
- package/lib/cjs/src/index.js.map +2 -2
- package/lib/cjs/src/network/di/networkModuleFactory.js +2 -0
- package/lib/cjs/src/network/di/networkModuleFactory.js.map +7 -0
- package/lib/cjs/src/network/di/networkTypes.js +2 -0
- package/lib/cjs/src/network/di/networkTypes.js.map +7 -0
- package/lib/cjs/src/network/networkClientFactory.js +2 -0
- package/lib/cjs/src/network/networkClientFactory.js.map +7 -0
- package/lib/cjs/src/network/networkClientFactory.test.js +2 -0
- package/lib/cjs/src/network/networkClientFactory.test.js.map +7 -0
- package/lib/cjs/src/nft/data/HttpNftDataSource.js +1 -1
- package/lib/cjs/src/nft/data/HttpNftDataSource.js.map +3 -3
- package/lib/cjs/src/nft/data/HttpNftDataSource.test.js +1 -1
- package/lib/cjs/src/nft/data/HttpNftDataSource.test.js.map +3 -3
- package/lib/cjs/src/pki/data/HttpPkiCertificateDataSource.js +1 -1
- package/lib/cjs/src/pki/data/HttpPkiCertificateDataSource.js.map +3 -3
- package/lib/cjs/src/pki/data/HttpPkiCertificateDataSource.test.js +1 -1
- package/lib/cjs/src/pki/data/HttpPkiCertificateDataSource.test.js.map +3 -3
- package/lib/cjs/src/proxy/data/HttpProxyDataSource.js +1 -1
- package/lib/cjs/src/proxy/data/HttpProxyDataSource.js.map +3 -3
- package/lib/cjs/src/proxy/data/HttpProxyDataSource.test.js +1 -1
- package/lib/cjs/src/proxy/data/HttpProxyDataSource.test.js.map +3 -3
- package/lib/cjs/src/proxy/data/HttpSafeProxyDataSource.js +1 -1
- package/lib/cjs/src/proxy/data/HttpSafeProxyDataSource.js.map +3 -3
- package/lib/cjs/src/proxy/data/HttpSafeProxyDataSource.test.js +1 -1
- package/lib/cjs/src/proxy/data/HttpSafeProxyDataSource.test.js.map +3 -3
- package/lib/cjs/src/proxy/di/proxyModuleFactory.test.js +1 -1
- package/lib/cjs/src/proxy/di/proxyModuleFactory.test.js.map +3 -3
- package/lib/cjs/src/reporter/data/BlindSigningReporterDatasource.js +1 -1
- package/lib/cjs/src/reporter/data/BlindSigningReporterDatasource.js.map +1 -1
- package/lib/cjs/src/reporter/data/HttpBlindSigningReporterDatasource.js +1 -1
- package/lib/cjs/src/reporter/data/HttpBlindSigningReporterDatasource.js.map +3 -3
- package/lib/cjs/src/reporter/data/HttpBlindSigningReporterDatasource.test.js +1 -1
- package/lib/cjs/src/reporter/data/HttpBlindSigningReporterDatasource.test.js.map +3 -3
- package/lib/cjs/src/safe/data/HttpSafeAccountDataSource.js +1 -1
- package/lib/cjs/src/safe/data/HttpSafeAccountDataSource.js.map +3 -3
- package/lib/cjs/src/safe/data/HttpSafeAccountDataSource.test.js +1 -1
- package/lib/cjs/src/safe/data/HttpSafeAccountDataSource.test.js.map +3 -3
- package/lib/cjs/src/shared/model/ClearSignContext.js +1 -1
- package/lib/cjs/src/shared/model/ClearSignContext.js.map +2 -2
- package/lib/cjs/src/solana/data/HttpSolanaOwnerInfoDataSource.js +1 -1
- package/lib/cjs/src/solana/data/HttpSolanaOwnerInfoDataSource.js.map +3 -3
- package/lib/cjs/src/solana/data/HttpSolanaOwnerInfoDataSource.test.js +1 -1
- package/lib/cjs/src/solana/data/HttpSolanaOwnerInfoDataSource.test.js.map +3 -3
- package/lib/cjs/src/solanaLifi/data/HttpSolanaLifiDataSource.js +1 -1
- package/lib/cjs/src/solanaLifi/data/HttpSolanaLifiDataSource.js.map +3 -3
- package/lib/cjs/src/solanaLifi/data/HttpSolanaLifiDataSource.test.js +1 -1
- package/lib/cjs/src/solanaLifi/data/HttpSolanaLifiDataSource.test.js.map +3 -3
- package/lib/cjs/src/solanaToken/data/HttpSolanaTokenDataSource.js +1 -1
- package/lib/cjs/src/solanaToken/data/HttpSolanaTokenDataSource.js.map +3 -3
- package/lib/cjs/src/solanaToken/data/HttpSolanaTokenDataSource.test.js +6 -6
- package/lib/cjs/src/solanaToken/data/HttpSolanaTokenDataSource.test.js.map +3 -3
- package/lib/cjs/src/token/data/HttpTokenDataSource.js +1 -1
- package/lib/cjs/src/token/data/HttpTokenDataSource.js.map +3 -3
- package/lib/cjs/src/token/data/HttpTokenDataSource.test.js +1 -1
- package/lib/cjs/src/token/data/HttpTokenDataSource.test.js.map +3 -3
- package/lib/cjs/src/transaction-check/data/HttpTransactionCheckDataSource.js +1 -1
- package/lib/cjs/src/transaction-check/data/HttpTransactionCheckDataSource.js.map +3 -3
- package/lib/cjs/src/transaction-check/data/HttpTransactionCheckDataSource.test.js +1 -1
- package/lib/cjs/src/transaction-check/data/HttpTransactionCheckDataSource.test.js.map +3 -3
- package/lib/cjs/src/transaction-check/data/HttpTypedDataCheckDataSource.js +1 -1
- package/lib/cjs/src/transaction-check/data/HttpTypedDataCheckDataSource.js.map +3 -3
- package/lib/cjs/src/transaction-check/data/HttpTypedDataCheckDataSource.test.js +1 -1
- package/lib/cjs/src/transaction-check/data/HttpTypedDataCheckDataSource.test.js.map +3 -3
- package/lib/cjs/src/trusted-name/data/HttpTrustedNameDataSource.js +1 -1
- package/lib/cjs/src/trusted-name/data/HttpTrustedNameDataSource.js.map +3 -3
- package/lib/cjs/src/trusted-name/data/HttpTrustedNameDataSource.test.js +1 -1
- package/lib/cjs/src/trusted-name/data/HttpTrustedNameDataSource.test.js.map +3 -3
- 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/esm/package.json +2 -3
- package/lib/esm/src/DefaultContextModule.js +1 -1
- package/lib/esm/src/DefaultContextModule.js.map +3 -3
- package/lib/esm/src/account-ownership/data/AccountOwnershipDataSource.js +1 -0
- package/lib/esm/src/account-ownership/data/AccountOwnershipDataSource.js.map +7 -0
- package/lib/esm/src/account-ownership/data/AccountOwnershipError.js +2 -0
- package/lib/esm/src/account-ownership/data/AccountOwnershipError.js.map +7 -0
- package/lib/esm/src/account-ownership/data/HttpAccountOwnershipDataSource.js +2 -0
- package/lib/esm/src/account-ownership/data/HttpAccountOwnershipDataSource.js.map +7 -0
- package/lib/esm/src/account-ownership/data/HttpAccountOwnershipDataSource.test.js +2 -0
- package/lib/esm/src/account-ownership/data/HttpAccountOwnershipDataSource.test.js.map +7 -0
- package/lib/esm/src/account-ownership/data/dto/AccountOwnershipDto.js +1 -0
- package/lib/esm/src/account-ownership/data/dto/AccountOwnershipDto.js.map +7 -0
- package/lib/esm/src/account-ownership/di/accountOwnershipModuleFactory.js +2 -0
- package/lib/esm/src/account-ownership/di/accountOwnershipModuleFactory.js.map +7 -0
- package/lib/esm/src/account-ownership/di/accountOwnershipTypes.js +2 -0
- package/lib/esm/src/account-ownership/di/accountOwnershipTypes.js.map +7 -0
- package/lib/esm/src/account-ownership/domain/AccountOwnershipContextLoader.js +2 -0
- package/lib/esm/src/account-ownership/domain/AccountOwnershipContextLoader.js.map +7 -0
- package/lib/esm/src/account-ownership/domain/AccountOwnershipContextLoader.test.js +2 -0
- package/lib/esm/src/account-ownership/domain/AccountOwnershipContextLoader.test.js.map +7 -0
- package/lib/esm/src/calldata/data/HttpCalldataDescriptorDataSource.js +1 -1
- package/lib/esm/src/calldata/data/HttpCalldataDescriptorDataSource.js.map +3 -3
- package/lib/esm/src/calldata/data/HttpCalldataDescriptorDataSource.test.js +1 -1
- package/lib/esm/src/calldata/data/HttpCalldataDescriptorDataSource.test.js.map +3 -3
- package/lib/esm/src/calldata/di/calldataModuleFactory.js +1 -1
- package/lib/esm/src/calldata/di/calldataModuleFactory.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/data/HttpDynamicNetworkDataSource.js +1 -1
- package/lib/esm/src/dynamic-network/data/HttpDynamicNetworkDataSource.js.map +3 -3
- package/lib/esm/src/dynamic-network/data/HttpDynamicNetworkDataSource.test.js +1 -1
- package/lib/esm/src/dynamic-network/data/HttpDynamicNetworkDataSource.test.js.map +3 -3
- package/lib/esm/src/external-plugin/data/HttpExternalPluginDataSource.js +1 -1
- package/lib/esm/src/external-plugin/data/HttpExternalPluginDataSource.js.map +3 -3
- package/lib/esm/src/external-plugin/data/HttpExternalPluginDataSource.test.js +1 -1
- package/lib/esm/src/external-plugin/data/HttpExternalPluginDataSource.test.js.map +3 -3
- package/lib/esm/src/gated-signing/data/HttpGatedDescriptorDataSource.js +1 -1
- package/lib/esm/src/gated-signing/data/HttpGatedDescriptorDataSource.js.map +3 -3
- package/lib/esm/src/gated-signing/data/HttpGatedDescriptorDataSource.test.js +1 -1
- package/lib/esm/src/gated-signing/data/HttpGatedDescriptorDataSource.test.js.map +3 -3
- package/lib/esm/src/index.js +1 -1
- package/lib/esm/src/index.js.map +2 -2
- package/lib/esm/src/network/di/networkModuleFactory.js +2 -0
- package/lib/esm/src/network/di/networkModuleFactory.js.map +7 -0
- package/lib/esm/src/network/di/networkTypes.js +2 -0
- package/lib/esm/src/network/di/networkTypes.js.map +7 -0
- package/lib/esm/src/network/networkClientFactory.js +2 -0
- package/lib/esm/src/network/networkClientFactory.js.map +7 -0
- package/lib/esm/src/network/networkClientFactory.test.js +2 -0
- package/lib/esm/src/network/networkClientFactory.test.js.map +7 -0
- package/lib/esm/src/nft/data/HttpNftDataSource.js +1 -1
- package/lib/esm/src/nft/data/HttpNftDataSource.js.map +3 -3
- package/lib/esm/src/nft/data/HttpNftDataSource.test.js +1 -1
- package/lib/esm/src/nft/data/HttpNftDataSource.test.js.map +3 -3
- package/lib/esm/src/pki/data/HttpPkiCertificateDataSource.js +1 -1
- package/lib/esm/src/pki/data/HttpPkiCertificateDataSource.js.map +3 -3
- package/lib/esm/src/pki/data/HttpPkiCertificateDataSource.test.js +1 -1
- package/lib/esm/src/pki/data/HttpPkiCertificateDataSource.test.js.map +3 -3
- package/lib/esm/src/proxy/data/HttpProxyDataSource.js +1 -1
- package/lib/esm/src/proxy/data/HttpProxyDataSource.js.map +3 -3
- package/lib/esm/src/proxy/data/HttpProxyDataSource.test.js +1 -1
- package/lib/esm/src/proxy/data/HttpProxyDataSource.test.js.map +3 -3
- package/lib/esm/src/proxy/data/HttpSafeProxyDataSource.js +1 -1
- package/lib/esm/src/proxy/data/HttpSafeProxyDataSource.js.map +3 -3
- package/lib/esm/src/proxy/data/HttpSafeProxyDataSource.test.js +1 -1
- package/lib/esm/src/proxy/data/HttpSafeProxyDataSource.test.js.map +3 -3
- package/lib/esm/src/proxy/di/proxyModuleFactory.test.js +1 -1
- package/lib/esm/src/proxy/di/proxyModuleFactory.test.js.map +3 -3
- package/lib/esm/src/reporter/data/HttpBlindSigningReporterDatasource.js +1 -1
- package/lib/esm/src/reporter/data/HttpBlindSigningReporterDatasource.js.map +3 -3
- package/lib/esm/src/reporter/data/HttpBlindSigningReporterDatasource.test.js +1 -1
- package/lib/esm/src/reporter/data/HttpBlindSigningReporterDatasource.test.js.map +3 -3
- package/lib/esm/src/safe/data/HttpSafeAccountDataSource.js +1 -1
- package/lib/esm/src/safe/data/HttpSafeAccountDataSource.js.map +3 -3
- package/lib/esm/src/safe/data/HttpSafeAccountDataSource.test.js +1 -1
- package/lib/esm/src/safe/data/HttpSafeAccountDataSource.test.js.map +3 -3
- package/lib/esm/src/shared/model/ClearSignContext.js +1 -1
- package/lib/esm/src/shared/model/ClearSignContext.js.map +2 -2
- package/lib/esm/src/solana/data/HttpSolanaOwnerInfoDataSource.js +1 -1
- package/lib/esm/src/solana/data/HttpSolanaOwnerInfoDataSource.js.map +3 -3
- package/lib/esm/src/solana/data/HttpSolanaOwnerInfoDataSource.test.js +1 -1
- package/lib/esm/src/solana/data/HttpSolanaOwnerInfoDataSource.test.js.map +3 -3
- package/lib/esm/src/solanaLifi/data/HttpSolanaLifiDataSource.js +1 -1
- package/lib/esm/src/solanaLifi/data/HttpSolanaLifiDataSource.js.map +3 -3
- package/lib/esm/src/solanaLifi/data/HttpSolanaLifiDataSource.test.js +1 -1
- package/lib/esm/src/solanaLifi/data/HttpSolanaLifiDataSource.test.js.map +3 -3
- package/lib/esm/src/solanaToken/data/HttpSolanaTokenDataSource.js +1 -1
- package/lib/esm/src/solanaToken/data/HttpSolanaTokenDataSource.js.map +3 -3
- package/lib/esm/src/solanaToken/data/HttpSolanaTokenDataSource.test.js +6 -6
- package/lib/esm/src/solanaToken/data/HttpSolanaTokenDataSource.test.js.map +3 -3
- package/lib/esm/src/token/data/HttpTokenDataSource.js +1 -1
- package/lib/esm/src/token/data/HttpTokenDataSource.js.map +3 -3
- package/lib/esm/src/token/data/HttpTokenDataSource.test.js +1 -1
- package/lib/esm/src/token/data/HttpTokenDataSource.test.js.map +3 -3
- package/lib/esm/src/transaction-check/data/HttpTransactionCheckDataSource.js +1 -1
- package/lib/esm/src/transaction-check/data/HttpTransactionCheckDataSource.js.map +3 -3
- package/lib/esm/src/transaction-check/data/HttpTransactionCheckDataSource.test.js +1 -1
- package/lib/esm/src/transaction-check/data/HttpTransactionCheckDataSource.test.js.map +3 -3
- package/lib/esm/src/transaction-check/data/HttpTypedDataCheckDataSource.js +1 -1
- package/lib/esm/src/transaction-check/data/HttpTypedDataCheckDataSource.js.map +3 -3
- package/lib/esm/src/transaction-check/data/HttpTypedDataCheckDataSource.test.js +1 -1
- package/lib/esm/src/transaction-check/data/HttpTypedDataCheckDataSource.test.js.map +3 -3
- package/lib/esm/src/trusted-name/data/HttpTrustedNameDataSource.js +1 -1
- package/lib/esm/src/trusted-name/data/HttpTrustedNameDataSource.js.map +3 -3
- package/lib/esm/src/trusted-name/data/HttpTrustedNameDataSource.test.js +1 -1
- package/lib/esm/src/trusted-name/data/HttpTrustedNameDataSource.test.js.map +3 -3
- 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/types/src/DefaultContextModule.d.ts.map +1 -1
- package/lib/types/src/account-ownership/data/AccountOwnershipDataSource.d.ts +17 -0
- package/lib/types/src/account-ownership/data/AccountOwnershipDataSource.d.ts.map +1 -0
- package/lib/types/src/account-ownership/data/AccountOwnershipError.d.ts +17 -0
- package/lib/types/src/account-ownership/data/AccountOwnershipError.d.ts.map +1 -0
- package/lib/types/src/account-ownership/data/HttpAccountOwnershipDataSource.d.ts +30 -0
- package/lib/types/src/account-ownership/data/HttpAccountOwnershipDataSource.d.ts.map +1 -0
- package/lib/types/src/account-ownership/data/HttpAccountOwnershipDataSource.test.d.ts +2 -0
- package/lib/types/src/account-ownership/data/HttpAccountOwnershipDataSource.test.d.ts.map +1 -0
- package/lib/types/src/account-ownership/data/dto/AccountOwnershipDto.d.ts +6 -0
- package/lib/types/src/account-ownership/data/dto/AccountOwnershipDto.d.ts.map +1 -0
- package/lib/types/src/account-ownership/di/accountOwnershipModuleFactory.d.ts +3 -0
- package/lib/types/src/account-ownership/di/accountOwnershipModuleFactory.d.ts.map +1 -0
- package/lib/types/src/account-ownership/di/accountOwnershipTypes.d.ts +5 -0
- package/lib/types/src/account-ownership/di/accountOwnershipTypes.d.ts.map +1 -0
- package/lib/types/src/account-ownership/domain/AccountOwnershipContextLoader.d.ts +20 -0
- package/lib/types/src/account-ownership/domain/AccountOwnershipContextLoader.d.ts.map +1 -0
- package/lib/types/src/account-ownership/domain/AccountOwnershipContextLoader.test.d.ts +2 -0
- package/lib/types/src/account-ownership/domain/AccountOwnershipContextLoader.test.d.ts.map +1 -0
- package/lib/types/src/calldata/data/HttpCalldataDescriptorDataSource.d.ts +3 -1
- package/lib/types/src/calldata/data/HttpCalldataDescriptorDataSource.d.ts.map +1 -1
- package/lib/types/src/calldata/di/calldataModuleFactory.d.ts.map +1 -1
- package/lib/types/src/di.d.ts.map +1 -1
- package/lib/types/src/dynamic-network/data/HttpDynamicNetworkDataSource.d.ts +3 -1
- package/lib/types/src/dynamic-network/data/HttpDynamicNetworkDataSource.d.ts.map +1 -1
- package/lib/types/src/external-plugin/data/HttpExternalPluginDataSource.d.ts +3 -1
- package/lib/types/src/external-plugin/data/HttpExternalPluginDataSource.d.ts.map +1 -1
- package/lib/types/src/gated-signing/data/HttpGatedDescriptorDataSource.d.ts +3 -1
- package/lib/types/src/gated-signing/data/HttpGatedDescriptorDataSource.d.ts.map +1 -1
- package/lib/types/src/index.d.ts +4 -0
- package/lib/types/src/index.d.ts.map +1 -1
- package/lib/types/src/network/di/networkModuleFactory.d.ts +4 -0
- package/lib/types/src/network/di/networkModuleFactory.d.ts.map +1 -0
- package/lib/types/src/network/di/networkTypes.d.ts +4 -0
- package/lib/types/src/network/di/networkTypes.d.ts.map +1 -0
- package/lib/types/src/network/networkClientFactory.d.ts +4 -0
- package/lib/types/src/network/networkClientFactory.d.ts.map +1 -0
- package/lib/types/src/network/networkClientFactory.test.d.ts +2 -0
- package/lib/types/src/network/networkClientFactory.test.d.ts.map +1 -0
- package/lib/types/src/nft/data/HttpNftDataSource.d.ts +3 -1
- package/lib/types/src/nft/data/HttpNftDataSource.d.ts.map +1 -1
- package/lib/types/src/pki/data/HttpPkiCertificateDataSource.d.ts +4 -1
- package/lib/types/src/pki/data/HttpPkiCertificateDataSource.d.ts.map +1 -1
- package/lib/types/src/proxy/data/HttpProxyDataSource.d.ts +3 -1
- package/lib/types/src/proxy/data/HttpProxyDataSource.d.ts.map +1 -1
- package/lib/types/src/proxy/data/HttpSafeProxyDataSource.d.ts +3 -1
- package/lib/types/src/proxy/data/HttpSafeProxyDataSource.d.ts.map +1 -1
- package/lib/types/src/reporter/data/BlindSigningReporterDatasource.d.ts +7 -1
- package/lib/types/src/reporter/data/BlindSigningReporterDatasource.d.ts.map +1 -1
- package/lib/types/src/reporter/data/HttpBlindSigningReporterDatasource.d.ts +3 -1
- package/lib/types/src/reporter/data/HttpBlindSigningReporterDatasource.d.ts.map +1 -1
- package/lib/types/src/safe/data/HttpSafeAccountDataSource.d.ts +3 -1
- package/lib/types/src/safe/data/HttpSafeAccountDataSource.d.ts.map +1 -1
- package/lib/types/src/shared/model/ClearSignContext.d.ts +2 -1
- package/lib/types/src/shared/model/ClearSignContext.d.ts.map +1 -1
- package/lib/types/src/solana/data/HttpSolanaOwnerInfoDataSource.d.ts +3 -1
- package/lib/types/src/solana/data/HttpSolanaOwnerInfoDataSource.d.ts.map +1 -1
- package/lib/types/src/solanaLifi/data/HttpSolanaLifiDataSource.d.ts +3 -2
- package/lib/types/src/solanaLifi/data/HttpSolanaLifiDataSource.d.ts.map +1 -1
- package/lib/types/src/solanaToken/data/HttpSolanaTokenDataSource.d.ts +3 -1
- package/lib/types/src/solanaToken/data/HttpSolanaTokenDataSource.d.ts.map +1 -1
- package/lib/types/src/token/data/HttpTokenDataSource.d.ts +3 -1
- package/lib/types/src/token/data/HttpTokenDataSource.d.ts.map +1 -1
- package/lib/types/src/transaction-check/data/HttpTransactionCheckDataSource.d.ts +3 -1
- package/lib/types/src/transaction-check/data/HttpTransactionCheckDataSource.d.ts.map +1 -1
- package/lib/types/src/transaction-check/data/HttpTypedDataCheckDataSource.d.ts +3 -1
- package/lib/types/src/transaction-check/data/HttpTypedDataCheckDataSource.d.ts.map +1 -1
- package/lib/types/src/trusted-name/data/HttpTrustedNameDataSource.d.ts +3 -1
- package/lib/types/src/trusted-name/data/HttpTrustedNameDataSource.d.ts.map +1 -1
- package/lib/types/src/typed-data/data/HttpTypedDataDataSource.d.ts +3 -1
- package/lib/types/src/typed-data/data/HttpTypedDataDataSource.d.ts.map +1 -1
- package/lib/types/src/typed-data/data/HttpTypedDataDataSource.test.d.ts.map +1 -1
- package/lib/types/tsconfig.prod.tsbuildinfo +1 -1
- package/package.json +5 -6
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
var
|
|
1
|
+
var y=Object.defineProperty;var f=Object.getOwnPropertyDescriptor;var d=(n,e,r,i)=>{for(var o=i>1?void 0:i?f(e,r):e,t=n.length-1,a;t>=0;t--)(a=n[t])&&(o=(i?a(e,r,o):a(o))||o);return i&&o&&y(e,r,o),o},l=(n,e)=>(r,i)=>e(r,i,n);import{inject as p,injectable as c}from"inversify";import{Left as s,Right as g}from"purify-ts";import{configTypes as x}from"../../config/di/configTypes";import{networkTypes as D}from"../../network/di/networkTypes";import{KeyId as u}from"../../pki/model/KeyId";import{KeyUsage as C}from"../../pki/model/KeyUsage";let m=class{constructor(e,r){this.config=e;this.http=r}async getProxyImplementationAddress({proxyAddress:e,chainId:r,challenge:i,calldata:o}){let t;try{t=await this.http.post(`${this.config.metadataServiceDomain.url}/v2/ethereum/${r}/contract/proxy/delegate`,{proxy:e,data:o,challenge:i})}catch{return s(new Error("[ContextModule] HttpProxyDataSource: Failed to fetch delegate proxy"))}return t?this.isProxyDelegateCallDto(t)?t.addresses[0]?g({implementationAddress:t.addresses[0],signedDescriptor:t.signedDescriptor,keyId:u.DomainMetadataKey,keyUsage:C.TrustedName}):s(new Error(`[ContextModule] HttpProxyDataSource: No implementation address found for proxy ${e} on chain ${r}`)):s(new Error(`[ContextModule] HttpProxyDataSource: Invalid proxy delegate call response format for proxy ${e} on chain ${r}`)):s(new Error(`[ContextModule] HttpProxyDataSource: No data received for proxy ${e} on chain ${r}`))}isProxyDelegateCallDto(e){return typeof e=="object"&&e!==null&&"addresses"in e&&"signedDescriptor"in e&&Array.isArray(e.addresses)&&e.addresses.every(r=>typeof r=="string")&&typeof e.signedDescriptor=="string"}};m=d([c(),l(0,p(x.Config)),l(1,p(D.NetworkClient))],m);export{m as HttpProxyDataSource};
|
|
2
2
|
//# sourceMappingURL=HttpProxyDataSource.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../src/proxy/data/HttpProxyDataSource.ts"],
|
|
4
|
-
"sourcesContent": ["import
|
|
5
|
-
"mappings": "
|
|
6
|
-
"names": ["
|
|
4
|
+
"sourcesContent": ["import { DmkNetworkClient } from \"@ledgerhq/device-management-kit\";\nimport { inject, injectable } from \"inversify\";\nimport { Either, Left, Right } from \"purify-ts\";\n\nimport { configTypes } from \"@/config/di/configTypes\";\nimport { type ContextModuleServiceConfig } from \"@/config/model/ContextModuleConfig\";\nimport { networkTypes } from \"@/network/di/networkTypes\";\nimport { KeyId } from \"@/pki/model/KeyId\";\nimport { KeyUsage } from \"@/pki/model/KeyUsage\";\n\nimport { ProxyDelegateCallDto } from \"./dto/ProxyDelegateCallDto\";\nimport {\n GetProxyImplementationAddressParam,\n ProxyDataSource,\n ProxyImplementationAddress,\n} from \"./ProxyDataSource\";\n\n@injectable()\nexport class HttpProxyDataSource implements ProxyDataSource {\n constructor(\n @inject(configTypes.Config)\n private readonly config: ContextModuleServiceConfig,\n @inject(networkTypes.NetworkClient)\n private readonly http: DmkNetworkClient,\n ) {}\n\n async getProxyImplementationAddress({\n proxyAddress,\n chainId,\n challenge,\n calldata,\n }: GetProxyImplementationAddressParam): Promise<\n Either<Error, ProxyImplementationAddress>\n > {\n let dto: ProxyDelegateCallDto | undefined;\n try {\n dto = (await this.http.post(\n `${this.config.metadataServiceDomain.url}/v2/ethereum/${chainId}/contract/proxy/delegate`,\n {\n proxy: proxyAddress,\n data: calldata,\n challenge,\n },\n )) as ProxyDelegateCallDto;\n } catch (_error) {\n return Left(\n new Error(\n `[ContextModule] HttpProxyDataSource: Failed to fetch delegate proxy`,\n ),\n );\n }\n\n if (!dto) {\n return Left(\n new Error(\n `[ContextModule] HttpProxyDataSource: No data received for proxy ${proxyAddress} on chain ${chainId}`,\n ),\n );\n }\n\n if (!this.isProxyDelegateCallDto(dto)) {\n return Left(\n new Error(\n `[ContextModule] HttpProxyDataSource: Invalid proxy delegate call response format for proxy ${proxyAddress} on chain ${chainId}`,\n ),\n );\n }\n\n if (!dto.addresses[0]) {\n return Left(\n new Error(\n `[ContextModule] HttpProxyDataSource: No implementation address found for proxy ${proxyAddress} on chain ${chainId}`,\n ),\n );\n }\n\n return Right({\n implementationAddress: dto.addresses[0],\n signedDescriptor: dto.signedDescriptor,\n keyId: KeyId.DomainMetadataKey,\n keyUsage: KeyUsage.TrustedName,\n });\n }\n\n /**\n * Type guard to validate ProxyDelegateCallDto\n */\n private isProxyDelegateCallDto(\n value: unknown,\n ): value is ProxyDelegateCallDto {\n return (\n typeof value === \"object\" &&\n value !== null &&\n \"addresses\" in value &&\n \"signedDescriptor\" in value &&\n Array.isArray(value.addresses) &&\n value.addresses.every((address) => typeof address === \"string\") &&\n typeof value.signedDescriptor === \"string\"\n );\n }\n}\n"],
|
|
5
|
+
"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A,EAAAC,EAAOC,EAAY,MAAM,GAEzBF,EAAA,EAAAC,EAAOE,EAAa,aAAa,IAJzBnB",
|
|
6
|
+
"names": ["inject", "injectable", "Left", "Right", "configTypes", "networkTypes", "KeyId", "KeyUsage", "HttpProxyDataSource", "config", "http", "proxyAddress", "chainId", "challenge", "calldata", "dto", "Left", "Right", "KeyId", "KeyUsage", "value", "address", "__decorateClass", "injectable", "__decorateParam", "inject", "configTypes", "networkTypes"]
|
|
7
7
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import
|
|
1
|
+
import{KeyId as i}from"../../pki/model/KeyId";import{KeyUsage as c}from"../../pki/model/KeyUsage";import{HttpProxyDataSource as l}from"./HttpProxyDataSource";const d={metadataServiceDomain:{url:"https://metadata.api.live.ledger.com"},originToken:"test-origin-token"};describe("HttpProxyDataSource",()=>{let a,r;beforeEach(()=>{vi.clearAllMocks(),r={post:vi.fn()},a=new l(d,r)});const e={proxyAddress:"0x1234567890123456789012345678901234567890",chainId:1,challenge:"test-challenge",calldata:"0xabcdef"},s={addresses:["0x9876543210987654321098765432109876543210"],signedDescriptor:"signed-descriptor-data"};describe("getProxyImplementationAddress",()=>{it("should call network client post with correct URL and body",async()=>{r.post.mockResolvedValue(s),await a.getProxyImplementationAddress(e),expect(r.post).toHaveBeenCalledWith(`${d.metadataServiceDomain.url}/v2/ethereum/${e.chainId}/contract/proxy/delegate`,{proxy:e.proxyAddress,data:e.calldata,challenge:e.challenge})}),it("should return Right with proxy implementation data when request succeeds with valid DTO",async()=>{r.post.mockResolvedValue(s);const t=await a.getProxyImplementationAddress(e);expect(t.isRight()).toBe(!0),expect(t.extract()).toEqual({implementationAddress:s.addresses[0],signedDescriptor:s.signedDescriptor,keyId:i.DomainMetadataKey,keyUsage:c.TrustedName})}),it("should return Right with first address when multiple addresses are provided",async()=>{const t={addresses:["0x9876543210987654321098765432109876543210","0x1111111111111111111111111111111111111111"],signedDescriptor:"signed-descriptor-data"};r.post.mockResolvedValue(t);const o=await a.getProxyImplementationAddress(e);expect(o.isRight()).toBe(!0),expect(o.extract()).toEqual({implementationAddress:t.addresses[0],signedDescriptor:t.signedDescriptor,keyId:i.DomainMetadataKey,keyUsage:c.TrustedName})}),it("should return Left with error when network client throws",async()=>{r.post.mockRejectedValue(new Error("Network error"));const t=await a.getProxyImplementationAddress(e);expect(t.isLeft()).toBe(!0),expect(t.extract()).toEqual(new Error("[ContextModule] HttpProxyDataSource: Failed to fetch delegate proxy"))}),it("should return Left with error when response data is undefined",async()=>{r.post.mockResolvedValue(void 0);const t=await a.getProxyImplementationAddress(e);expect(t.isLeft()).toBe(!0),expect(t.extract()).toEqual(new Error(`[ContextModule] HttpProxyDataSource: No data received for proxy ${e.proxyAddress} on chain ${e.chainId}`))}),it("should return Left with error when response data is null",async()=>{r.post.mockResolvedValue(null);const t=await a.getProxyImplementationAddress(e);expect(t.isLeft()).toBe(!0),expect(t.extract()).toEqual(new Error(`[ContextModule] HttpProxyDataSource: No data received for proxy ${e.proxyAddress} on chain ${e.chainId}`))}),it("should return Left with error when addresses field is missing",async()=>{const{addresses:t,...o}=s;r.post.mockResolvedValue(o);const n=await a.getProxyImplementationAddress(e);expect(n.isLeft()).toBe(!0),expect(n.extract()).toEqual(new Error(`[ContextModule] HttpProxyDataSource: Invalid proxy delegate call response format for proxy ${e.proxyAddress} on chain ${e.chainId}`))}),it("should return Left with error when signedDescriptor is missing",async()=>{const{signedDescriptor:t,...o}=s;r.post.mockResolvedValue(o);const n=await a.getProxyImplementationAddress(e);expect(n.isLeft()).toBe(!0),expect(n.extract()).toEqual(new Error(`[ContextModule] HttpProxyDataSource: Invalid proxy delegate call response format for proxy ${e.proxyAddress} on chain ${e.chainId}`))}),it("should return Left with error when addresses is not an array",async()=>{const t={...s,addresses:"not-an-array"};r.post.mockResolvedValue(t);const o=await a.getProxyImplementationAddress(e);expect(o.isLeft()).toBe(!0),expect(o.extract()).toEqual(new Error(`[ContextModule] HttpProxyDataSource: Invalid proxy delegate call response format for proxy ${e.proxyAddress} on chain ${e.chainId}`))}),it("should return Left with error when addresses array contains non-string values",async()=>{const t={...s,addresses:[123,"valid-address"]};r.post.mockResolvedValue(t);const o=await a.getProxyImplementationAddress(e);expect(o.isLeft()).toBe(!0),expect(o.extract()).toEqual(new Error(`[ContextModule] HttpProxyDataSource: Invalid proxy delegate call 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={...s,signedDescriptor:123};r.post.mockResolvedValue(t);const o=await a.getProxyImplementationAddress(e);expect(o.isLeft()).toBe(!0),expect(o.extract()).toEqual(new Error(`[ContextModule] HttpProxyDataSource: Invalid proxy delegate call response format for proxy ${e.proxyAddress} on chain ${e.chainId}`))}),it("should return Left with error when addresses array is empty",async()=>{const t={addresses:[],signedDescriptor:"signed-descriptor-data"};r.post.mockResolvedValue(t);const o=await a.getProxyImplementationAddress(e);expect(o.isLeft()).toBe(!0),expect(o.extract()).toEqual(new Error(`[ContextModule] HttpProxyDataSource: No implementation address found for proxy ${e.proxyAddress} on chain ${e.chainId}`))}),it("should return Left with error when response is not an object",async()=>{r.post.mockResolvedValue("not an object");const t=await a.getProxyImplementationAddress(e);expect(t.isLeft()).toBe(!0),expect(t.extract()).toEqual(new Error(`[ContextModule] HttpProxyDataSource: Invalid proxy delegate call response format for proxy ${e.proxyAddress} on chain ${e.chainId}`))}),it("should handle different chainId values correctly",async()=>{const t={...e,chainId:137};r.post.mockResolvedValue(s);const o=await a.getProxyImplementationAddress(t);expect(o.isRight()).toBe(!0),expect(r.post).toHaveBeenCalledWith(`${d.metadataServiceDomain.url}/v2/ethereum/137/contract/proxy/delegate`,expect.anything())}),it("should handle different proxy addresses correctly",async()=>{const t="0xabcdefabcdefabcdefabcdefabcdefabcdefabcd",o={...e,proxyAddress:t};r.post.mockResolvedValue(s);const n=await a.getProxyImplementationAddress(o);expect(n.isRight()).toBe(!0),expect(r.post).toHaveBeenCalledWith(expect.any(String),expect.objectContaining({proxy:t}))}),it("should handle different calldata values correctly",async()=>{const t="0x123456789abcdef",o={...e,calldata:t};r.post.mockResolvedValue(s);const n=await a.getProxyImplementationAddress(o);expect(n.isRight()).toBe(!0),expect(r.post).toHaveBeenCalledWith(expect.any(String),expect.objectContaining({data:t}))}),it("should pass challenge parameter correctly",async()=>{const t="custom-challenge-string",o={...e,challenge:t};r.post.mockResolvedValue(s);const n=await a.getProxyImplementationAddress(o);expect(n.isRight()).toBe(!0),expect(r.post).toHaveBeenCalledWith(expect.any(String),expect.objectContaining({challenge:t}))})})});
|
|
2
2
|
//# sourceMappingURL=HttpProxyDataSource.test.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../src/proxy/data/HttpProxyDataSource.test.ts"],
|
|
4
|
-
"sourcesContent": ["import axios from \"axios\";\n\nimport { type ContextModuleServiceConfig } from \"@/config/model/ContextModuleConfig\";\nimport { KeyId } from \"@/pki/model/KeyId\";\nimport { KeyUsage } from \"@/pki/model/KeyUsage\";\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 ContextModuleServiceConfig;\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 keyId: KeyId.DomainMetadataKey,\n keyUsage: KeyUsage.TrustedName,\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 keyId: KeyId.DomainMetadataKey,\n keyUsage: KeyUsage.TrustedName,\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": "
|
|
6
|
-
"names": ["
|
|
4
|
+
"sourcesContent": ["import { type DmkNetworkClient } from \"@ledgerhq/device-management-kit\";\n\nimport { type ContextModuleServiceConfig } from \"@/config/model/ContextModuleConfig\";\nimport { KeyId } from \"@/pki/model/KeyId\";\nimport { KeyUsage } from \"@/pki/model/KeyUsage\";\n\nimport { type ProxyDelegateCallDto } from \"./dto/ProxyDelegateCallDto\";\nimport { HttpProxyDataSource } from \"./HttpProxyDataSource\";\nimport { type ProxyDataSource } from \"./ProxyDataSource\";\n\nconst config = {\n metadataServiceDomain: {\n url: \"https://metadata.api.live.ledger.com\",\n },\n originToken: \"test-origin-token\",\n} as ContextModuleServiceConfig;\n\ndescribe(\"HttpProxyDataSource\", () => {\n let datasource: ProxyDataSource;\n let httpMock: { post: ReturnType<typeof vi.fn> };\n\n beforeEach(() => {\n vi.clearAllMocks();\n httpMock = { post: vi.fn() };\n datasource = new HttpProxyDataSource(\n config,\n httpMock as unknown as DmkNetworkClient,\n );\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 network client post with correct URL and body\", async () => {\n // GIVEN\n httpMock.post.mockResolvedValue(validDto);\n\n // WHEN\n await datasource.getProxyImplementationAddress(validParams);\n\n // THEN\n expect(httpMock.post).toHaveBeenCalledWith(\n `${config.metadataServiceDomain.url}/v2/ethereum/${validParams.chainId}/contract/proxy/delegate`,\n {\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 httpMock.post.mockResolvedValue(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 keyId: KeyId.DomainMetadataKey,\n keyUsage: KeyUsage.TrustedName,\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 httpMock.post.mockResolvedValue(dtoWithMultipleAddresses);\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 keyId: KeyId.DomainMetadataKey,\n keyUsage: KeyUsage.TrustedName,\n });\n });\n\n it(\"should return Left with error when network client throws\", async () => {\n // GIVEN\n httpMock.post.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 httpMock.post.mockResolvedValue(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 httpMock.post.mockResolvedValue(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 httpMock.post.mockResolvedValue(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 httpMock.post.mockResolvedValue(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 httpMock.post.mockResolvedValue(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 httpMock.post.mockResolvedValue(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 httpMock.post.mockResolvedValue(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 httpMock.post.mockResolvedValue(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 httpMock.post.mockResolvedValue(\"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 httpMock.post.mockResolvedValue(validDto);\n\n // WHEN\n const result = await datasource.getProxyImplementationAddress(\n paramsWithDifferentChainId,\n );\n\n // THEN\n expect(result.isRight()).toBe(true);\n expect(httpMock.post).toHaveBeenCalledWith(\n `${config.metadataServiceDomain.url}/v2/ethereum/137/contract/proxy/delegate`,\n expect.anything(),\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 httpMock.post.mockResolvedValue(validDto);\n\n // WHEN\n const result = await datasource.getProxyImplementationAddress(\n paramsWithDifferentAddress,\n );\n\n // THEN\n expect(result.isRight()).toBe(true);\n expect(httpMock.post).toHaveBeenCalledWith(\n expect.any(String),\n expect.objectContaining({\n proxy: differentProxyAddress,\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 httpMock.post.mockResolvedValue(validDto);\n\n // WHEN\n const result = await datasource.getProxyImplementationAddress(\n paramsWithCustomCalldata,\n );\n\n // THEN\n expect(result.isRight()).toBe(true);\n expect(httpMock.post).toHaveBeenCalledWith(\n expect.any(String),\n expect.objectContaining({\n data: customCalldata,\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 httpMock.post.mockResolvedValue(validDto);\n\n // WHEN\n const result = await datasource.getProxyImplementationAddress(\n paramsWithCustomChallenge,\n );\n\n // THEN\n expect(result.isRight()).toBe(true);\n expect(httpMock.post).toHaveBeenCalledWith(\n expect.any(String),\n expect.objectContaining({\n challenge: customChallenge,\n }),\n );\n });\n });\n});\n"],
|
|
5
|
+
"mappings": "AAGA,OAAS,SAAAA,MAAa,oBACtB,OAAS,YAAAC,MAAgB,uBAGzB,OAAS,uBAAAC,MAA2B,wBAGpC,MAAMC,EAAS,CACb,sBAAuB,CACrB,IAAK,sCACP,EACA,YAAa,mBACf,EAEA,SAAS,sBAAuB,IAAM,CACpC,IAAIC,EACAC,EAEJ,WAAW,IAAM,CACf,GAAG,cAAc,EACjBA,EAAW,CAAE,KAAM,GAAG,GAAG,CAAE,EAC3BD,EAAa,IAAIF,EACfC,EACAE,CACF,CACF,CAAC,EAED,MAAMC,EAAc,CAClB,aAAc,6CACd,QAAS,EACT,UAAW,iBACX,SAAU,UACZ,EAEMC,EAAiC,CACrC,UAAW,CAAC,4CAA4C,EACxD,iBAAkB,wBACpB,EAEA,SAAS,gCAAiC,IAAM,CAC9C,GAAG,4DAA6D,SAAY,CAE1EF,EAAS,KAAK,kBAAkBE,CAAQ,EAGxC,MAAMH,EAAW,8BAA8BE,CAAW,EAG1D,O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AOH,EAAS,IAAI,EAAE,qBACpB,OAAO,IAAI,MAAM,EACjB,OAAO,iBAAiB,CACtB,KAAMU,CACR,CAAC,CACH,CACF,CAAC,EAED,GAAG,4CAA6C,SAAY,CAE1D,MAAME,EAAkB,0BAClBC,EAA4B,CAChC,GAAGZ,EACH,UAAWW,CACb,EACAZ,EAAS,KAAK,kBAAkBE,CAAQ,EAGxC,MAAMC,EAAS,MAAMJ,EAAW,8BAC9Bc,CACF,EAGA,OAAOV,EAAO,QAAQ,CAAC,EAAE,KAAK,EAAI,EAClC,OAAOH,EAAS,IAAI,EAAE,qBACpB,OAAO,IAAI,MAAM,EACjB,OAAO,iBAAiB,CACtB,UAAWY,CACb,CAAC,CACH,CACF,CAAC,CACH,CAAC,CACH,CAAC",
|
|
6
|
+
"names": ["KeyId", "KeyUsage", "HttpProxyDataSource", "config", "datasource", "httpMock", "validParams", "validDto", "result", "dtoWithMultipleAddresses", "_", "invalidDto", "paramsWithDifferentChainId", "differentProxyAddress", "paramsWithDifferentAddress", "customCalldata", "paramsWithCustomCalldata", "customChallenge", "paramsWithCustomChallenge"]
|
|
7
7
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
var
|
|
1
|
+
var f=Object.defineProperty;var c=Object.getOwnPropertyDescriptor;var a=(n,e,r,o)=>{for(var t=o>1?void 0:o?c(e,r):e,i=n.length-1,m;i>=0;i--)(m=n[i])&&(t=(o?m(e,r,t):m(t))||t);return o&&t&&f(e,r,t),t},d=(n,e)=>(r,o)=>e(r,o,n);import{inject as y,injectable as g}from"inversify";import{Left as p,Right as x}from"purify-ts";import{configTypes as l}from"../../config/di/configTypes";import{networkTypes as A}from"../../network/di/networkTypes";let s=class{constructor(e,r){this.config=e;this.http=r}async getProxyImplementationAddress({proxyAddress:e,chainId:r,challenge:o}){let t;try{t=await this.http.get(`${this.config.metadataServiceDomain.url}/v3/ethereum/${r}/contract/proxy/${e}`,{params:{challenge:o,resolver:"SAFE_GATEWAY"}})}catch{return p(new Error("[ContextModule] HttpSafeProxyDataSource: Failed to fetch safe proxy implementation"))}return t?this.isSafeProxyImplementationAddressDto(t)?x({implementationAddress:t.implementationAddress,signedDescriptor:t.signedDescriptor,keyId:t.keyId,keyUsage:t.keyUsage}):p(new Error(`[ContextModule] HttpSafeProxyDataSource: Invalid safe proxy response format for proxy ${e} on chain ${r}`)):p(new Error(`[ContextModule] HttpSafeProxyDataSource: No data received for proxy ${e} on chain ${r}`))}isSafeProxyImplementationAddressDto(e){return typeof e=="object"&&e!==null&&"proxyAddress"in e&&"implementationAddress"in e&&"standard"in e&&"signedDescriptor"in e&&"providedBy"in e&&"keyId"in e&&"keyUsage"in e&&typeof e.proxyAddress=="string"&&typeof e.implementationAddress=="string"&&typeof e.standard=="string"&&typeof e.signedDescriptor=="string"&&typeof e.providedBy=="string"&&typeof e.keyId=="string"&&typeof e.keyUsage=="string"}};s=a([g(),d(0,y(l.Config)),d(1,y(A.NetworkClient))],s);export{s as HttpSafeProxyDataSource};
|
|
2
2
|
//# sourceMappingURL=HttpSafeProxyDataSource.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../src/proxy/data/HttpSafeProxyDataSource.ts"],
|
|
4
|
-
"sourcesContent": ["import
|
|
5
|
-
"mappings": "
|
|
6
|
-
"names": ["
|
|
4
|
+
"sourcesContent": ["import { DmkNetworkClient } from \"@ledgerhq/device-management-kit\";\nimport { inject, injectable } from \"inversify\";\nimport { Either, Left, Right } from \"purify-ts\";\n\nimport { configTypes } from \"@/config/di/configTypes\";\nimport { type ContextModuleServiceConfig } from \"@/config/model/ContextModuleConfig\";\nimport { networkTypes } from \"@/network/di/networkTypes\";\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)\n private readonly config: ContextModuleServiceConfig,\n @inject(networkTypes.NetworkClient)\n private readonly http: DmkNetworkClient,\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 dto = (await this.http.get(\n `${this.config.metadataServiceDomain.url}/v3/ethereum/${chainId}/contract/proxy/${proxyAddress}`,\n {\n params: {\n challenge,\n resolver: \"SAFE_GATEWAY\",\n },\n },\n )) as SafeProxyImplementationAddressDto;\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 keyId: dto.keyId,\n keyUsage: dto.keyUsage,\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 \"keyId\" in value &&\n \"keyUsage\" 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 typeof value.keyId === \"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QAE9B,CACF,EAnFaT,EAANU,EAAA,CADNC,EAAW,EAGPC,EAAA,EAAAC,EAAOC,EAAY,MAAM,GAEzBF,EAAA,EAAAC,EAAOE,EAAa,aAAa,IAJzBf",
|
|
6
|
+
"names": ["inject", "injectable", "Left", "Right", "configTypes", "networkTypes", "HttpSafeProxyDataSource", "config", "http", "proxyAddress", "chainId", "challenge", "dto", "Left", "Right", "value", "__decorateClass", "injectable", "__decorateParam", "inject", "configTypes", "networkTypes"]
|
|
7
7
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import
|
|
1
|
+
import{HttpSafeProxyDataSource as d}from"./HttpSafeProxyDataSource";const i={metadataServiceDomain:{url:"https://metadata.api.live.ledger.com"},originToken:"test-origin-token"};describe("HttpSafeProxyDataSource",()=>{let a,o;beforeEach(()=>{vi.clearAllMocks(),o={get:vi.fn()},a=new d(i,o)});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",keyId:"testKeyId",keyUsage:"testKeyUsage"};describe("getProxyImplementationAddress",()=>{it("should call the network client with correct URL and parameters",async()=>{o.get.mockResolvedValue(n),await a.getProxyImplementationAddress(e),expect(o.get).toHaveBeenCalledWith(`${i.metadataServiceDomain.url}/v3/ethereum/${e.chainId}/contract/proxy/${e.proxyAddress}`,{params:{challenge:e.challenge,resolver:"SAFE_GATEWAY"}})}),it("should return Right with proxy implementation data when request succeeds with valid DTO",async()=>{o.get.mockResolvedValue(n);const t=await a.getProxyImplementationAddress(e);expect(t.isRight()).toBe(!0),expect(t.extract()).toEqual({implementationAddress:n.implementationAddress,signedDescriptor:n.signedDescriptor,keyId:"testKeyId",keyUsage:"testKeyUsage"})}),it("should return Left with error when network client throws",async()=>{o.get.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()=>{o.get.mockResolvedValue(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()=>{o.get.mockResolvedValue(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;o.get.mockResolvedValue(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;o.get.mockResolvedValue(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;o.get.mockResolvedValue(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;o.get.mockResolvedValue(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;o.get.mockResolvedValue(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};o.get.mockResolvedValue(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};o.get.mockResolvedValue(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:[]};o.get.mockResolvedValue(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:{}};o.get.mockResolvedValue(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};o.get.mockResolvedValue(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()=>{o.get.mockResolvedValue("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()=>{o.get.mockResolvedValue(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};o.get.mockResolvedValue(n);const r=await a.getProxyImplementationAddress(t);expect(r.isRight()).toBe(!0),expect(o.get).toHaveBeenCalledWith(`${i.metadataServiceDomain.url}/v3/ethereum/137/contract/proxy/${e.proxyAddress}`,expect.anything())}),it("should handle different proxy addresses correctly",async()=>{const t="0xabcdefabcdefabcdefabcdefabcdefabcdefabcd",r={...e,proxyAddress:t};o.get.mockResolvedValue(n);const s=await a.getProxyImplementationAddress(r);expect(s.isRight()).toBe(!0),expect(o.get).toHaveBeenCalledWith(`${i.metadataServiceDomain.url}/v3/ethereum/${e.chainId}/contract/proxy/${t}`,expect.anything())}),it("should pass challenge parameter correctly",async()=>{const t="custom-challenge-string",r={...e,challenge:t};o.get.mockResolvedValue(n);const s=await a.getProxyImplementationAddress(r);expect(s.isRight()).toBe(!0),expect(o.get).toHaveBeenCalledWith(expect.any(String),{params:{challenge:t,resolver:"SAFE_GATEWAY"}})})})});
|
|
2
2
|
//# sourceMappingURL=HttpSafeProxyDataSource.test.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../src/proxy/data/HttpSafeProxyDataSource.test.ts"],
|
|
4
|
-
"sourcesContent": ["import axios from \"axios\";\n\nimport { type ContextModuleServiceConfig } 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 ContextModuleServiceConfig;\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 keyId: \"testKeyId\",\n keyUsage: \"testKeyUsage\",\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 keyId: \"testKeyId\",\n keyUsage: \"testKeyUsage\",\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": "
|
|
6
|
-
"names": ["
|
|
4
|
+
"sourcesContent": ["import { type DmkNetworkClient } from \"@ledgerhq/device-management-kit\";\n\nimport { type ContextModuleServiceConfig } from \"@/config/model/ContextModuleConfig\";\n\nimport { type SafeProxyImplementationAddressDto } from \"./dto/SafeProxyImplementationAddressDto\";\nimport { HttpSafeProxyDataSource } from \"./HttpSafeProxyDataSource\";\nimport { type ProxyDataSource } from \"./ProxyDataSource\";\n\nconst config = {\n metadataServiceDomain: {\n url: \"https://metadata.api.live.ledger.com\",\n },\n originToken: \"test-origin-token\",\n} as ContextModuleServiceConfig;\n\ndescribe(\"HttpSafeProxyDataSource\", () => {\n let datasource: ProxyDataSource;\n let httpMock: { get: ReturnType<typeof vi.fn> };\n\n beforeEach(() => {\n vi.clearAllMocks();\n httpMock = { get: vi.fn() };\n datasource = new HttpSafeProxyDataSource(\n config,\n httpMock as unknown as DmkNetworkClient,\n );\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 keyId: \"testKeyId\",\n keyUsage: \"testKeyUsage\",\n };\n\n describe(\"getProxyImplementationAddress\", () => {\n it(\"should call the network client with correct URL and parameters\", async () => {\n // GIVEN\n httpMock.get.mockResolvedValue(validDto);\n\n // WHEN\n await datasource.getProxyImplementationAddress(validParams);\n\n // THEN\n expect(httpMock.get).toHaveBeenCalledWith(\n `${config.metadataServiceDomain.url}/v3/ethereum/${validParams.chainId}/contract/proxy/${validParams.proxyAddress}`,\n {\n params: {\n challenge: validParams.challenge,\n resolver: \"SAFE_GATEWAY\",\n },\n },\n );\n });\n\n it(\"should return Right with proxy implementation data when request succeeds with valid DTO\", async () => {\n // GIVEN\n httpMock.get.mockResolvedValue(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 keyId: \"testKeyId\",\n keyUsage: \"testKeyUsage\",\n });\n });\n\n it(\"should return Left with error when network client throws\", async () => {\n // GIVEN\n httpMock.get.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 httpMock.get.mockResolvedValue(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 httpMock.get.mockResolvedValue(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 httpMock.get.mockResolvedValue(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 httpMock.get.mockResolvedValue(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 httpMock.get.mockResolvedValue(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 httpMock.get.mockResolvedValue(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 httpMock.get.mockResolvedValue(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 httpMock.get.mockResolvedValue(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 httpMock.get.mockResolvedValue(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 httpMock.get.mockResolvedValue(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 httpMock.get.mockResolvedValue(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 httpMock.get.mockResolvedValue(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 httpMock.get.mockResolvedValue(\"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 httpMock.get.mockResolvedValue(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 httpMock.get.mockResolvedValue(validDto);\n\n // WHEN\n const result = await datasource.getProxyImplementationAddress(\n paramsWithDifferentChainId,\n );\n\n // THEN\n expect(result.isRight()).toBe(true);\n expect(httpMock.get).toHaveBeenCalledWith(\n `${config.metadataServiceDomain.url}/v3/ethereum/137/contract/proxy/${validParams.proxyAddress}`,\n expect.anything(),\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 httpMock.get.mockResolvedValue(validDto);\n\n // WHEN\n const result = await datasource.getProxyImplementationAddress(\n paramsWithDifferentAddress,\n );\n\n // THEN\n expect(result.isRight()).toBe(true);\n expect(httpMock.get).toHaveBeenCalledWith(\n `${config.metadataServiceDomain.url}/v3/ethereum/${validParams.chainId}/contract/proxy/${differentProxyAddress}`,\n expect.anything(),\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 httpMock.get.mockResolvedValue(validDto);\n\n // WHEN\n const result = await datasource.getProxyImplementationAddress(\n paramsWithCustomChallenge,\n );\n\n // THEN\n expect(result.isRight()).toBe(true);\n expect(httpMock.get).toHaveBeenCalledWith(expect.any(String), {\n params: { challenge: customChallenge, resolver: \"SAFE_GATEWAY\" },\n });\n });\n });\n});\n"],
|
|
5
|
+
"mappings": "AAKA,OAAS,2BAAAA,MAA+B,4BAGxC,MAAMC,EAAS,CACb,sBAAuB,CACrB,IAAK,sCACP,EACA,YAAa,mBACf,EAEA,SAAS,0BAA2B,IAAM,CACxC,IAAIC,EACAC,EAEJ,WAAW,IAAM,CACf,GAAG,cAAc,EACjBA,EAAW,CAAE,IAAK,GAAG,GAAG,CAAE,EAC1BD,EAAa,IAAIF,EACfC,EACAE,CACF,CACF,CAAC,EAED,MAAMC,EAAc,CAClB,aAAc,6CACd,QAAS,EACT,UAAW,iBACX,SAAU,UACZ,EAEMC,EAA8C,CAClD,aAAc,6CACd,sBAAuB,6CACvB,SAAU,WACV,iBAAkB,yBAClB,WAAY,eACZ,MAAO,YACP,SAAU,cACZ,EAEA,SAAS,gCAAiC,IAAM,CAC9C,GAAG,iEAAkE,SAAY,CAE/EF,EAAS,IAAI,kBAAkBE,CAAQ,EAGvC,MAAMH,EAAW,8BAA8BE,CAAW,EAG1D,OAAOD,EAAS,GAAG,EAAE,qBACnB,GAAGF,EAAO,sBAAsB,GAAG,gBAAgBG,EAAY,OAAO,mBAAmBA,EAAY,YAAY,GACjH,CACE,OAAQ,CACN,UAAWA,E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|
6
|
+
"names": ["HttpSafeProxyDataSource", "config", "datasource", "httpMock", "validParams", "validDto", "result", "_", "invalidDto", "paramsWithDifferentChainId", "differentProxyAddress", "paramsWithDifferentAddress", "customChallenge", "paramsWithCustomChallenge"]
|
|
7
7
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{Container as s}from"inversify";import{configTypes as u}from"../../config/di/configTypes";import{
|
|
1
|
+
import{Container as s}from"inversify";import{configTypes as u}from"../../config/di/configTypes";import{networkTypes as x}from"../../network/di/networkTypes";import{pkiTypes as p}from"../../pki/di/pkiTypes";import{HttpProxyDataSource as n}from"../../proxy/data/HttpProxyDataSource";import{HttpSafeProxyDataSource as l}from"../../proxy/data/HttpSafeProxyDataSource";import{ProxyContextFieldLoader as i}from"../../proxy/domain/ProxyContextFieldLoader";import{proxyModuleFactory as r}from"./proxyModuleFactory";import{proxyTypes as a}from"./proxyTypes";describe("proxyModuleFactory",()=>{let o;const c={metadataServiceDomain:{url:"https://metadata.api.live.ledger.com"},originToken:"test-origin-token"},d={loadCertificate:vi.fn()};beforeEach(()=>{o=new s,o.bind(u.Config).toConstantValue(c),o.bind(p.PkiCertificateLoader).toConstantValue(d),o.bind(x.NetworkClient).toConstantValue({get:vi.fn(),post:vi.fn()})}),describe("when datasource config is undefined",()=>{it("should bind HttpProxyDataSource as the default ProxyDataSource",()=>{const e=r();o.load(e);const t=o.get(a.ProxyDataSource);expect(t).toBeInstanceOf(n)}),it("should bind ProxyContextFieldLoader",()=>{const e=r();o.load(e);const t=o.get(a.ProxyContextFieldLoader);expect(t).toBeInstanceOf(i)})}),describe("when datasource.proxy is 'safe'",()=>{it("should bind HttpSafeProxyDataSource as the ProxyDataSource",()=>{const e=r({proxy:"safe"});o.load(e);const t=o.get(a.ProxyDataSource);expect(t).toBeInstanceOf(l)}),it("should bind ProxyContextFieldLoader",()=>{const e=r({proxy:"safe"});o.load(e);const t=o.get(a.ProxyContextFieldLoader);expect(t).toBeInstanceOf(i)})}),describe("when datasource.proxy is 'default'",()=>{it("should bind HttpProxyDataSource as the ProxyDataSource",()=>{const e=r({proxy:"default"});o.load(e);const t=o.get(a.ProxyDataSource);expect(t).toBeInstanceOf(n)})}),describe("when datasource has no proxy set",()=>{it("should bind HttpProxyDataSource as the default ProxyDataSource",()=>{const e=r({});o.load(e);const t=o.get(a.ProxyDataSource);expect(t).toBeInstanceOf(n)})}),describe("when datasource.proxy is an unexpected value",()=>{it("should bind HttpProxyDataSource as the default ProxyDataSource",()=>{const e=r({proxy:"unknown"});o.load(e);const t=o.get(a.ProxyDataSource);expect(t).toBeInstanceOf(n)})})});
|
|
2
2
|
//# sourceMappingURL=proxyModuleFactory.test.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../src/proxy/di/proxyModuleFactory.test.ts"],
|
|
4
|
-
"sourcesContent": ["import { Container } from \"inversify\";\n\nimport { configTypes } from \"@/config/di/configTypes\";\nimport { type ContextModuleServiceConfig } 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: ContextModuleServiceConfig = {\n metadataServiceDomain: {\n url: \"https://metadata.api.live.ledger.com\",\n },\n originToken: \"test-origin-token\",\n } as ContextModuleServiceConfig;\n\n const mockPkiCertificateLoader: PkiCertificateLoader = {\n loadCertificate: vi.fn(),\n };\n\n beforeEach(() => {\n container = new Container();\n container.bind(configTypes.Config).toConstantValue(mockConfig);\n container\n .bind(pkiTypes.PkiCertificateLoader)\n .toConstantValue(mockPkiCertificateLoader);\n });\n\n describe(\"when datasource 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 datasource.proxy is 'safe'\", () => {\n it(\"should bind HttpSafeProxyDataSource as the ProxyDataSource\", () => {\n const module = proxyModuleFactory({ proxy: \"safe\" });\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 module = proxyModuleFactory({ proxy: \"safe\" });\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 datasource.proxy is 'default'\", () => {\n it(\"should bind HttpProxyDataSource as the ProxyDataSource\", () => {\n const module = proxyModuleFactory({ proxy: \"default\" });\n container.load(module);\n\n const proxyDataSource = container.get(proxyTypes.ProxyDataSource);\n expect(proxyDataSource).toBeInstanceOf(HttpProxyDataSource);\n });\n });\n\n describe(\"when datasource has no proxy set\", () => {\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\n describe(\"when datasource.proxy is an unexpected value\", () => {\n it(\"should bind HttpProxyDataSource as the default ProxyDataSource\", () => {\n const module = proxyModuleFactory({\n proxy: \"unknown\" as unknown as \"safe\" | \"default\",\n });\n container.load(module);\n\n const proxyDataSource = container.get(proxyTypes.ProxyDataSource);\n expect(proxyDataSource).toBeInstanceOf(HttpProxyDataSource);\n });\n });\n});\n"],
|
|
5
|
-
"mappings": "
|
|
6
|
-
"names": ["Container", "configTypes", "pkiTypes", "HttpProxyDataSource", "HttpSafeProxyDataSource", "ProxyContextFieldLoader", "proxyModuleFactory", "proxyTypes", "container", "mockConfig", "mockPkiCertificateLoader", "module", "proxyDataSource", "proxyContextFieldLoader"]
|
|
4
|
+
"sourcesContent": ["import { type DmkNetworkClient } from \"@ledgerhq/device-management-kit\";\nimport { Container } from \"inversify\";\n\nimport { configTypes } from \"@/config/di/configTypes\";\nimport { type ContextModuleServiceConfig } from \"@/config/model/ContextModuleConfig\";\nimport { networkTypes } from \"@/network/di/networkTypes\";\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: ContextModuleServiceConfig = {\n metadataServiceDomain: {\n url: \"https://metadata.api.live.ledger.com\",\n },\n originToken: \"test-origin-token\",\n } as ContextModuleServiceConfig;\n\n const mockPkiCertificateLoader: PkiCertificateLoader = {\n loadCertificate: vi.fn(),\n };\n\n beforeEach(() => {\n container = new Container();\n container.bind(configTypes.Config).toConstantValue(mockConfig);\n container\n .bind(pkiTypes.PkiCertificateLoader)\n .toConstantValue(mockPkiCertificateLoader);\n container.bind(networkTypes.NetworkClient).toConstantValue({\n get: vi.fn(),\n post: vi.fn(),\n } as unknown as DmkNetworkClient);\n });\n\n describe(\"when datasource 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 datasource.proxy is 'safe'\", () => {\n it(\"should bind HttpSafeProxyDataSource as the ProxyDataSource\", () => {\n const module = proxyModuleFactory({ proxy: \"safe\" });\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 module = proxyModuleFactory({ proxy: \"safe\" });\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 datasource.proxy is 'default'\", () => {\n it(\"should bind HttpProxyDataSource as the ProxyDataSource\", () => {\n const module = proxyModuleFactory({ proxy: \"default\" });\n container.load(module);\n\n const proxyDataSource = container.get(proxyTypes.ProxyDataSource);\n expect(proxyDataSource).toBeInstanceOf(HttpProxyDataSource);\n });\n });\n\n describe(\"when datasource has no proxy set\", () => {\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\n describe(\"when datasource.proxy is an unexpected value\", () => {\n it(\"should bind HttpProxyDataSource as the default ProxyDataSource\", () => {\n const module = proxyModuleFactory({\n proxy: \"unknown\" as unknown as \"safe\" | \"default\",\n });\n container.load(module);\n\n const proxyDataSource = container.get(proxyTypes.ProxyDataSource);\n expect(proxyDataSource).toBeInstanceOf(HttpProxyDataSource);\n });\n });\n});\n"],
|
|
5
|
+
"mappings": "AACA,OAAS,aAAAA,MAAiB,YAE1B,OAAS,eAAAC,MAAmB,0BAE5B,OAAS,gBAAAC,MAAoB,4BAC7B,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,EAAyC,CAC7C,sBAAuB,CACrB,IAAK,sCACP,EACA,YAAa,mBACf,EAEMC,EAAiD,CACrD,gBAAiB,GAAG,GAAG,CACzB,EAEA,WAAW,IAAM,CACfF,EAAY,IAAIT,EAChBS,EAAU,KAAKR,EAAY,MAAM,EAAE,gBAAgBS,CAAU,EAC7DD,EACG,KAAKN,EAAS,oBAAoB,EAClC,gBAAgBQ,CAAwB,EAC3CF,EAAU,KAAKP,EAAa,aAAa,EAAE,gBAAgB,CACzD,IAAK,GAAG,GAAG,EACX,KAAM,GAAG,GAAG,CACd,CAAgC,CAClC,CAAC,EAED,SAAS,sCAAuC,IAAM,CACpD,GAAG,iEAAkE,IAAM,CACzE,MAAMU,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,EAAU,KAAKG,CAA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,CAC5D,CAAC,CACH,CAAC,CACH,CAAC",
|
|
6
|
+
"names": ["Container", "configTypes", "networkTypes", "pkiTypes", "HttpProxyDataSource", "HttpSafeProxyDataSource", "ProxyContextFieldLoader", "proxyModuleFactory", "proxyTypes", "container", "mockConfig", "mockPkiCertificateLoader", "module", "proxyDataSource", "proxyContextFieldLoader"]
|
|
7
7
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
var c=Object.defineProperty;var f=Object.getOwnPropertyDescriptor;var
|
|
1
|
+
var c=Object.defineProperty;var f=Object.getOwnPropertyDescriptor;var l=(i,r,e,o)=>{for(var t=o>1?void 0:o?f(r,e):r,p=i.length-1,m;p>=0;p--)(m=i[p])&&(t=(o?m(r,e,t):m(t))||t);return o&&t&&c(r,e,t),t},s=(i,r)=>(e,o)=>r(e,o,i);import{inject as a,injectable as g}from"inversify";import{Left as d,Right as y}from"purify-ts";import{configTypes as h}from"../../config/di/configTypes";import{networkTypes as C}from"../../network/di/networkTypes";import{networkClientFactory as u}from"../../network/networkClientFactory";let n=class{constructor(r,e){this.config=r;this.http=e??u(r)}http;async report(r){try{await this.http.post(`${this.config.reporter.url}/blind-signing-events`,{...r,source:this.config.appSource},{responseType:"void"})}catch{return d(new Error("[ContextModule] HttpBlindSigningReporterDatasource: Failed to report blind signing event"))}return y(void 0)}};n=l([g(),s(0,a(h.Config)),s(1,a(C.NetworkClient))],n);export{n as HttpBlindSigningReporterDatasource};
|
|
2
2
|
//# sourceMappingURL=HttpBlindSigningReporterDatasource.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../src/reporter/data/HttpBlindSigningReporterDatasource.ts"],
|
|
4
|
-
"sourcesContent": ["import
|
|
5
|
-
"mappings": "
|
|
6
|
-
"names": ["
|
|
4
|
+
"sourcesContent": ["import { DmkNetworkClient } from \"@ledgerhq/device-management-kit\";\nimport { inject, injectable } from \"inversify\";\nimport { type Either, Left, Right } from \"purify-ts\";\n\nimport { configTypes } from \"@/config/di/configTypes\";\nimport { type ContextModuleServiceConfig } from \"@/config/model/ContextModuleConfig\";\nimport { networkTypes } from \"@/network/di/networkTypes\";\nimport { networkClientFactory } from \"@/network/networkClientFactory\";\n\nimport {\n type BlindSigningReporterDatasource,\n type BlindSigningReportParams,\n} from \"./BlindSigningReporterDatasource\";\n\n@injectable()\nexport class HttpBlindSigningReporterDatasource\n implements BlindSigningReporterDatasource\n{\n private readonly http: DmkNetworkClient;\n\n constructor(\n @inject(configTypes.Config)\n private readonly config: ContextModuleServiceConfig,\n @inject(networkTypes.NetworkClient)\n networkClient?: DmkNetworkClient,\n ) {\n this.http = networkClient ?? networkClientFactory(config);\n }\n\n async report(params: BlindSigningReportParams): Promise<Either<Error, void>> {\n try {\n await this.http.post(\n `${this.config.reporter.url}/blind-signing-events`,\n { ...params, source: this.config.appSource },\n { responseType: \"void\" },\n );\n } catch (_error) {\n return Left(\n new Error(\n \"[ContextModule] HttpBlindSigningReporterDatasource: Failed to report blind signing event\",\n ),\n );\n }\n\n return Right(undefined);\n }\n}\n"],
|
|
5
|
+
"mappings": "iOACA,OAAS,UAAAA,EAAQ,cAAAC,MAAkB,YACnC,OAAsB,QAAAC,EAAM,SAAAC,MAAa,YAEzC,OAAS,eAAAC,MAAmB,0BAE5B,OAAS,gBAAAC,MAAoB,4BAC7B,OAAS,wBAAAC,MAA4B,iCAQ9B,IAAMC,EAAN,KAEP,CAGE,YAEmBC,EAEjBC,EACA,CAHiB,YAAAD,EAIjB,KAAK,KAAOC,GAAiBC,EAAqBF,CAAM,CAC1D,CATiB,KAWjB,MAAM,OAAOG,EAAgE,CAC3E,GAAI,CACF,MAAM,KAAK,KAAK,KACd,GAAG,KAAK,OAAO,SAAS,GAAG,wBAC3B,CAAE,GAAGA,EAAQ,OAAQ,KAAK,OAAO,SAAU,EAC3C,CAAE,aAAc,MAAO,CACzB,CACF,MAAiB,CACf,OAAOC,EACL,IAAI,MACF,0FACF,CACF,CACF,CAEA,OAAOC,EAAM,MAAS,CACxB,CACF,EA/BaN,EAANO,EAAA,CADNC,EAAW,EAOPC,EAAA,EAAAC,EAAOC,EAAY,MAAM,GAEzBF,EAAA,EAAAC,EAAOE,EAAa,aAAa,IARzBZ",
|
|
6
|
+
"names": ["inject", "injectable", "Left", "Right", "configTypes", "networkTypes", "networkClientFactory", "HttpBlindSigningReporterDatasource", "config", "networkClient", "networkClientFactory", "params", "Left", "Right", "__decorateClass", "injectable", "__decorateParam", "inject", "configTypes", "networkTypes"]
|
|
7
7
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import
|
|
1
|
+
import{Left as i,Right as s}from"purify-ts";import{HttpBlindSigningReporterDatasource as p}from"../../reporter/data/HttpBlindSigningReporterDatasource";import{BlindSigningMethod as a,BlindSigningPlatform as d,BlindSignReason as l,ClearSigningType as c}from"../../reporter/model/BlindSigningEvent";import{BlindSigningModelId as g}from"../../reporter/model/BlindSigningModelId";describe("HttpBlindSigningReporterDatasource",()=>{const o={reporter:{url:"https://reporter.test"},originToken:"originToken",appSource:"third-party"},n={signatureId:"a3f8Kb-1738850400000",signingMethod:a.ETH_SIGN_TRANSACTION,isBlindSign:!0,chainId:1,targetAddress:"0xdAC17F958D2ee523a2206206994597C13D831ec7",blindSignReason:l.NO_CLEAR_SIGNING_CONTEXT,modelId:g.NANO_X,signerAppVersion:"1.12.1",deviceVersion:"2.2.3",ethContext:{clearSigningType:c.EIP7730,partialContextErrors:0}};let e,r;beforeEach(()=>{vi.resetAllMocks(),e={post:vi.fn()},r=new p(o,e)}),describe("report",()=>{it("should return Right(undefined) on success",async()=>{e.post.mockResolvedValueOnce(void 0);const t=await r.report(n);expect(t).toEqual(s(void 0))}),it("should return Left(Error) when the request fails",async()=>{e.post.mockRejectedValueOnce(new Error("network error"));const t=await r.report(n);expect(t).toEqual(i(new Error("[ContextModule] HttpBlindSigningReporterDatasource: Failed to report blind signing event")))}),it("should call http.post with the correct URL, body and options",async()=>{e.post.mockResolvedValueOnce(void 0),await r.report(n),expect(e.post).toHaveBeenCalledWith(`${o.reporter.url}/blind-signing-events`,{...n,source:o.appSource},{responseType:"void"})}),it("should forward optional DTO fields when provided",async()=>{e.post.mockResolvedValueOnce(void 0);const t={...n,platform:d.DESKTOP,appVersion:"2.80.0",platformOS:"macOS",platformVersion:"14.5",liveAppContext:"swap",sessionId:"session-123"};await r.report(t),expect(e.post).toHaveBeenCalledWith(`${o.reporter.url}/blind-signing-events`,{...t,source:o.appSource},{responseType:"void"})})})});
|
|
2
2
|
//# sourceMappingURL=HttpBlindSigningReporterDatasource.test.js.map
|