Skip to content

Commit 4c0ba32

Browse files
feat(mfa): enhance factor type mapping for MFA authenticators
1 parent 11d2dad commit 4c0ba32

1 file changed

Lines changed: 16 additions & 1 deletion

File tree

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

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,13 +55,28 @@ class MfaClient(
5555
}
5656
}
5757

58+
private fun mapFactorType(factor: String): String? {
59+
return when (factor.lowercase()) {
60+
"otp", "totp" -> "otp"
61+
"sms", "phone" -> "sms"
62+
"email" -> "email"
63+
"push", "push-notification" -> "push-notification"
64+
"oob" -> "oob"
65+
"recovery-code" -> "recovery-code"
66+
"voice" -> "sms"
67+
else -> null
68+
}
69+
}
70+
5871
fun getAuthenticators(mfaToken: String, factorsAllowed: ReadableArray?, promise: Promise) {
5972
val mfaClient = client.mfaClient(mfaToken)
6073

6174
val factors = mutableListOf<String>()
6275
factorsAllowed?.let {
6376
for (i in 0 until it.size()) {
64-
it.getString(i)?.let { factor -> factors.add(factor) }
77+
it.getString(i)?.let { factor ->
78+
mapFactorType(factor)?.let { mapped -> factors.add(mapped) }
79+
}
6580
}
6681
}
6782

0 commit comments

Comments
 (0)