-
Notifications
You must be signed in to change notification settings - Fork 662
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[FC] Updates lookup call to use mobile endpoint on verified flows (#9820
) # Summary - Uses new `mobile/lookup` on verified flows. - Pass verification token and app_id, required for this endpoint - Also `session_id` and `email_source`, optional before, are now required. - Non verified flows continue to use `POST consumer_sessions` (does some method renaming to match this) - Modifies `ErrorHandler` to, on attestation failures, close the native AuthFlow and continue on web. # Motivation https://docs.google.com/document/d/1joKz5UZHLVazmecfMHbq6gB6n4wj5u8To6AtqYgq_tc/edit?tab=t.0#heading=h.cz1xkpga7giy # Testing - [x] Added tests - [x] Modified tests - [x] Manually verified
- Loading branch information
1 parent
eb9f87e
commit 96e9ba3
Showing
23 changed files
with
335 additions
and
56 deletions.
There are no files selected for viewing
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 | ||
} | ||
} |
36 changes: 29 additions & 7 deletions
36
...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,43 @@ | ||
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, | ||
sessionId: String | ||
): ConsumerSessionLookup { | ||
return if (verifiedFlow) { | ||
requireNotNull( | ||
consumerSessionRepository.mobileLookupConsumerSession( | ||
email = email.lowercase().trim(), | ||
emailSource = emailSource, | ||
verificationToken = integrityRequestManager.requestToken().getOrThrow(), | ||
appId = application.packageName, | ||
sessionId = sessionId | ||
) | ||
) | ||
} else { | ||
requireNotNull( | ||
consumerSessionRepository.postConsumerSession( | ||
email = email.lowercase().trim(), | ||
clientSecret = configuration.financialConnectionsSessionClientSecret | ||
) | ||
) | ||
} | ||
} | ||
} |
13 changes: 13 additions & 0 deletions
13
...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,13 @@ | ||
package com.stripe.android.financialconnections.features.error | ||
|
||
import com.stripe.android.core.exception.APIException | ||
import com.stripe.attestation.AttestationError | ||
|
||
internal val Throwable.isAttestationError: Boolean | ||
get() = 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
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.