Updated on 2026-08-14
This commit is contained in:
parent
244f9bc61d
commit
62d0a771d9
9 changed files with 34 additions and 38 deletions
|
|
@ -1,23 +1,16 @@
|
|||
package com.tangem.tap.network.auth
|
||||
|
||||
import com.tangem.datasource.config.ConfigManager
|
||||
import com.tangem.datasource.local.userwallet.UserWalletsStore
|
||||
import com.tangem.lib.auth.ExpressAuthProvider
|
||||
import com.tangem.lib.auth.sessionId.ExpressSessionIdGenerator
|
||||
import java.util.UUID
|
||||
import java.util.concurrent.atomic.AtomicReference
|
||||
|
||||
internal class DefaultExpressAuthProvider(
|
||||
private val userWalletsStore: UserWalletsStore,
|
||||
private val configManager: ConfigManager,
|
||||
) : ExpressAuthProvider, ExpressSessionIdGenerator {
|
||||
) : ExpressAuthProvider {
|
||||
|
||||
private var uuid = AtomicReference(UUID.randomUUID())
|
||||
|
||||
override fun getApiKey(): String {
|
||||
return configManager.config.express?.apiKey ?: error("No express api key provided")
|
||||
}
|
||||
|
||||
override fun getUserId(): String {
|
||||
return userWalletsStore.selectedUserWalletOrNull?.walletId?.stringValue ?: error("No user id provided")
|
||||
}
|
||||
|
|
@ -25,8 +18,4 @@ internal class DefaultExpressAuthProvider(
|
|||
override fun getSessionId(): String {
|
||||
return uuid.get().toString()
|
||||
}
|
||||
|
||||
override fun generateNewSessionId() {
|
||||
uuid = AtomicReference(UUID.randomUUID())
|
||||
}
|
||||
}
|
||||
|
|
@ -29,14 +29,8 @@ class AuthModule {
|
|||
|
||||
@Provides
|
||||
@Singleton
|
||||
fun provideExpressAuthProvider(
|
||||
userWalletsStore: UserWalletsStore,
|
||||
configManager: ConfigManager,
|
||||
): ExpressAuthProvider {
|
||||
return DefaultExpressAuthProvider(
|
||||
userWalletsStore = userWalletsStore,
|
||||
configManager = configManager,
|
||||
)
|
||||
fun provideExpressAuthProvider(userWalletsStore: UserWalletsStore): ExpressAuthProvider {
|
||||
return DefaultExpressAuthProvider(userWalletsStore = userWalletsStore)
|
||||
}
|
||||
|
||||
@Provides
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue