Skip to content

Commit 073115e

Browse files
feat(mfa): enhance MFA functionality with scope and audience support
1 parent 6d7f4f1 commit 073115e

20 files changed

Lines changed: 740 additions & 92 deletions

File tree

android/src/main/java/com/auth0/react/A0Auth0Module.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -662,8 +662,8 @@ class A0Auth0Module(private val reactContext: ReactApplicationContext) : A0Auth0
662662
}
663663

664664
@ReactMethod
665-
override fun mfaVerify(mfaToken: String, type: String, code: String, bindingCode: String?, promise: Promise) {
666-
mfaClient?.verify(mfaToken, type, code, bindingCode, promise)
665+
override fun mfaVerify(mfaToken: String, type: String, code: String, bindingCode: String?, scope: String?, audience: String?, promise: Promise) {
666+
mfaClient?.verify(mfaToken, type, code, bindingCode, scope, audience, promise)
667667
?: promise.reject("NOT_INITIALIZED", "Auth0 not initialized")
668668
}
669669

android/src/main/java/com/auth0/react/MfaClient.kt

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,7 @@ class MfaClient(
106106
for (authenticator in result) {
107107
val map = WritableNativeMap().apply {
108108
putString("id", authenticator.id)
109+
putString("type", authenticator.type)
109110
putString("authenticatorType", authenticator.authenticatorType)
110111
putBoolean("active", authenticator.active)
111112
authenticator.name?.let { putString("name", it) }
@@ -221,7 +222,7 @@ class MfaClient(
221222
)
222223
}
223224

224-
fun verify(mfaToken: String, type: String, code: String, bindingCode: String?, promise: Promise) {
225+
fun verify(mfaToken: String, type: String, code: String, bindingCode: String?, scope: String?, audience: String?, promise: Promise) {
225226
val verifyType = MfaVerifyType.fromString(type)
226227
if (verifyType == null) {
227228
promise.reject("MFA_VERIFY_ERROR", "Unsupported verification type: $type")
@@ -236,7 +237,11 @@ class MfaClient(
236237
MfaVerifyType.RECOVERY_CODE -> MfaVerificationType.RecoveryCode(code)
237238
}
238239

239-
mfaClient.verify(verificationType).start(
240+
val verifyRequest = mfaClient.verify(verificationType)
241+
scope?.let { verifyRequest.addParameter("scope", it) }
242+
audience?.let { verifyRequest.addParameter("audience", it) }
243+
244+
verifyRequest.start(
240245
object : com.auth0.android.callback.Callback<Credentials, MfaException.MfaVerifyException> {
241246
override fun onSuccess(result: Credentials) {
242247
val map = CredentialsParser.toMap(result)

android/src/main/oldarch/com/auth0/react/A0Auth0Spec.kt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,8 @@ abstract class A0Auth0Spec(context: ReactApplicationContext) : ReactContextBaseJ
161161
type: String,
162162
code: String,
163163
bindingCode: String?,
164+
scope: String?,
165+
audience: String?,
164166
promise: Promise
165167
)
166168

0 commit comments

Comments
 (0)