-
Notifications
You must be signed in to change notification settings - Fork 663
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Updates lookup call to use mobile endpoint on verified flows
- Loading branch information
1 parent
0112b88
commit f5ed9fe
Showing
26 changed files
with
338 additions
and
65 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
20 changes: 20 additions & 0 deletions
20
...s/src/main/java/com/stripe/android/financialconnections/domain/IntegrityVerdictManager.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
package com.stripe.android.financialconnections.domain | ||
|
||
/** | ||
* Manages the verdict of the integrity check. If the verdict is failed, the user will be switched to web flow. | ||
* | ||
* The scope of this is the application session. Subsequent launches of the AuthFlow within the hosting app after | ||
* a verdict failure will directly launch the web flow. | ||
*/ | ||
internal class IntegrityVerdictManager { | ||
|
||
private var verdictFailed: Boolean = false | ||
|
||
fun setVerdictFailed() { | ||
verdictFailed = true | ||
} | ||
|
||
fun verdictFailed(): Boolean { | ||
return verdictFailed | ||
} | ||
} |
34 changes: 27 additions & 7 deletions
34
...connections/src/main/java/com/stripe/android/financialconnections/domain/LookupAccount.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,41 @@ | ||
package com.stripe.android.financialconnections.domain | ||
|
||
import android.app.Application | ||
import com.stripe.android.financialconnections.FinancialConnectionsSheet | ||
import com.stripe.android.financialconnections.repository.FinancialConnectionsConsumerSessionRepository | ||
import com.stripe.android.model.ConsumerSessionLookup | ||
import com.stripe.android.model.EmailSource | ||
import com.stripe.attestation.IntegrityRequestManager | ||
import javax.inject.Inject | ||
|
||
internal class LookupAccount @Inject constructor( | ||
private val application: Application, | ||
private val integrityRequestManager: IntegrityRequestManager, | ||
private val consumerSessionRepository: FinancialConnectionsConsumerSessionRepository, | ||
val configuration: FinancialConnectionsSheet.Configuration, | ||
) { | ||
|
||
suspend operator fun invoke( | ||
email: String | ||
): ConsumerSessionLookup = requireNotNull( | ||
consumerSessionRepository.lookupConsumerSession( | ||
email = email.lowercase().trim(), | ||
clientSecret = configuration.financialConnectionsSessionClientSecret | ||
) | ||
) | ||
email: String, | ||
emailSource: EmailSource, | ||
verifiedFlow: Boolean | ||
): ConsumerSessionLookup { | ||
return if (verifiedFlow) { | ||
requireNotNull( | ||
consumerSessionRepository.mobileLookupConsumerSession( | ||
email = email.lowercase().trim(), | ||
emailSource = emailSource, | ||
verificationToken = integrityRequestManager.requestToken().getOrThrow(), | ||
appId = application.packageName | ||
) | ||
) | ||
} else { | ||
requireNotNull( | ||
consumerSessionRepository.postConsumerSession( | ||
email = email.lowercase().trim(), | ||
clientSecret = configuration.financialConnectionsSessionClientSecret | ||
) | ||
) | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
12 changes: 12 additions & 0 deletions
12
...nections/src/main/java/com/stripe/android/financialconnections/features/error/ErrorExt.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
package com.stripe.android.financialconnections.features.error | ||
|
||
import com.stripe.android.core.exception.APIException | ||
import com.stripe.attestation.AttestationError | ||
|
||
internal fun Throwable.isAttestationError(): Boolean = when (this) { | ||
// Stripe backend could not verify the intregrity of the request | ||
is APIException -> stripeError?.code == "link_failed_to_attest_request" | ||
// Interaction with Integrity API to generate tokens resulted in a failure | ||
is AttestationError -> true | ||
else -> false | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.