Skip to content

Commit

Permalink
Adds integrity shared dependency.
Browse files Browse the repository at this point in the history
  • Loading branch information
carlosmuvi-stripe committed Dec 24, 2024
1 parent 576dbde commit 8b718ff
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 7 deletions.
Original file line number Diff line number Diff line change
@@ -1,9 +1,15 @@
package com.stripe.android.financialconnections.di

import android.app.Application
import com.stripe.android.core.Logger
import com.stripe.attestation.BuildConfig
import com.stripe.attestation.IntegrityRequestManager
import com.stripe.attestation.IntegrityStandardRequestManager
import com.stripe.attestation.RealStandardIntegrityManagerFactory
import dagger.BindsInstance
import dagger.Component
import dagger.Module
import dagger.Provides
import javax.inject.Singleton

/**
Expand Down Expand Up @@ -32,6 +38,8 @@ internal object FinancialConnectionsSingletonSharedComponentHolder {
@Component(modules = [FinancialConnectionsSingletonSharedModule::class])
internal interface FinancialConnectionsSingletonSharedComponent {

fun providesIntegrityRequestManager(): IntegrityRequestManager

@Component.Builder
interface Builder {
@BindsInstance
Expand All @@ -42,4 +50,15 @@ internal interface FinancialConnectionsSingletonSharedComponent {
}

@Module
internal class FinancialConnectionsSingletonSharedModule
internal class FinancialConnectionsSingletonSharedModule {

@Provides
@Singleton
fun providesIntegrityStandardRequestManager(
context: Application
): IntegrityRequestManager = IntegrityStandardRequestManager(
cloudProjectNumber = 527113280969, // stripe-financial-connections
logError = { message, error -> Logger.getInstance(BuildConfig.DEBUG).error(message, error) },
factory = RealStandardIntegrityManagerFactory(context)
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ internal class ConsentViewModel @AssistedInject constructor(
@Assisted initialState: ConsentState,
nativeAuthFlowCoordinator: NativeAuthFlowCoordinator,
private val acceptConsent: AcceptConsent,
private val integrityRequestManager: IntegrityRequestManager,
private val getOrFetchSync: GetOrFetchSync,
private val navigationManager: NavigationManager,
private val eventTracker: FinancialConnectionsAnalyticsTracker,
Expand All @@ -55,11 +54,6 @@ internal class ConsentViewModel @AssistedInject constructor(
) : FinancialConnectionsViewModel<ConsentState>(initialState, nativeAuthFlowCoordinator) {

init {
viewModelScope.launch {
integrityRequestManager.requestToken()
.onSuccess { logger.debug("Integrity token: $it") }
.onFailure { logger.error("Failed to get integrity token", it) }
}
logErrors()
suspend {
val sync = getOrFetchSync()
Expand Down

0 comments on commit 8b718ff

Please sign in to comment.