Updated on 2026-08-14
This commit is contained in:
parent
982bd4130e
commit
122d654f29
5 changed files with 5 additions and 44 deletions
|
|
@ -1,16 +0,0 @@
|
|||
package com.tangem.tap.network.auth
|
||||
|
||||
import com.tangem.common.extensions.toHexString
|
||||
import com.tangem.lib.auth.LazyAuthProvider
|
||||
import com.tangem.tap.proxy.AppStateHolder
|
||||
|
||||
class LazyAuthProviderImpl(private val appStateHolder: AppStateHolder) : LazyAuthProvider {
|
||||
|
||||
override fun getCardPublicKeyProvider(): () -> String {
|
||||
return { appStateHolder.getActualCard()?.cardPublicKey?.toHexString() ?: "" }
|
||||
}
|
||||
|
||||
override fun getCardIdProvider(): () -> String {
|
||||
return { appStateHolder.getActualCard()?.cardId ?: "" }
|
||||
}
|
||||
}
|
||||
|
|
@ -1,9 +1,7 @@
|
|||
package com.tangem.tap.network.auth.di
|
||||
|
||||
import com.tangem.lib.auth.AuthProvider
|
||||
import com.tangem.lib.auth.LazyAuthProvider
|
||||
import com.tangem.tap.network.auth.AuthProviderImpl
|
||||
import com.tangem.tap.network.auth.LazyAuthProviderImpl
|
||||
import com.tangem.tap.proxy.AppStateHolder
|
||||
import dagger.Module
|
||||
import dagger.Provides
|
||||
|
|
@ -20,10 +18,4 @@ class AuthModule {
|
|||
fun provideAuthProvider(appStateHolder: AppStateHolder): AuthProvider {
|
||||
return AuthProviderImpl(appStateHolder)
|
||||
}
|
||||
|
||||
@Provides
|
||||
@Singleton
|
||||
fun provideLazyAuthProvider(appStateHolder: AppStateHolder): LazyAuthProvider {
|
||||
return LazyAuthProviderImpl(appStateHolder)
|
||||
}
|
||||
}
|
||||
|
|
@ -9,8 +9,8 @@ import com.tangem.datasource.utils.RequestHeader.*
|
|||
import com.tangem.datasource.utils.addHeaders
|
||||
import com.tangem.datasource.utils.addLazyHeaders
|
||||
import com.tangem.datasource.utils.allowLogging
|
||||
import com.tangem.lib.auth.AuthProvider
|
||||
import com.tangem.lib.auth.BuildConfig
|
||||
import com.tangem.lib.auth.LazyAuthProvider
|
||||
import dagger.Module
|
||||
import dagger.Provides
|
||||
import dagger.hilt.InstallIn
|
||||
|
|
@ -63,7 +63,7 @@ class NetworkModule {
|
|||
@Provides
|
||||
@Singleton
|
||||
@PromotionOneInch
|
||||
fun providePromotionOneInchApi(authProvider: LazyAuthProvider, @NetworkMoshi moshi: Moshi): PromotionApi {
|
||||
fun providePromotionOneInchApi(authProvider: AuthProvider, @NetworkMoshi moshi: Moshi): PromotionApi {
|
||||
val okClient = OkHttpClient.Builder()
|
||||
.addLazyHeaders(
|
||||
LazyRequestHeader.LazyAuthenticationHeader(authProvider),
|
||||
|
|
|
|||
|
|
@ -1,7 +1,6 @@
|
|||
package com.tangem.datasource.utils
|
||||
|
||||
import com.tangem.lib.auth.AuthProvider
|
||||
import com.tangem.lib.auth.LazyAuthProvider
|
||||
|
||||
/**
|
||||
* Presentation of request header
|
||||
|
|
@ -25,8 +24,8 @@ sealed class LazyRequestHeader(vararg pairs: Pair<String, () -> String>) {
|
|||
|
||||
val values: List<Pair<String, () -> String>> = pairs.toList()
|
||||
|
||||
class LazyAuthenticationHeader(authProvider: LazyAuthProvider) : LazyRequestHeader(
|
||||
"card_id" to authProvider.getCardIdProvider(),
|
||||
"card_public_key" to authProvider.getCardPublicKeyProvider(),
|
||||
class LazyAuthenticationHeader(authProvider: AuthProvider) : LazyRequestHeader(
|
||||
"card_id" to { authProvider.getCardId() },
|
||||
"card_public_key" to { authProvider.getCardPublicKey() },
|
||||
)
|
||||
}
|
||||
|
|
@ -1,14 +0,0 @@
|
|||
package com.tangem.lib.auth
|
||||
|
||||
/**
|
||||
* Provides auth for tangemTech API
|
||||
*/
|
||||
interface LazyAuthProvider {
|
||||
|
||||
/**
|
||||
* Returns authToken for tangem tech api
|
||||
*/
|
||||
fun getCardPublicKeyProvider(): () -> String
|
||||
|
||||
fun getCardIdProvider(): () -> String
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue