MfaApi

sealed interface MfaApi(source)

An interface for interacting with Multi-Factor Authentication Api in GoTrue.

Properties

Link copied to clipboard
abstract val status: MfaStatus

The current MFA status of the user

Link copied to clipboard
abstract val statusFlow: Flow<MfaStatus>

The current MFA status of the user as a flow. This flow will emit a new status any time Auth.sessionStatus changes.

Link copied to clipboard

Returns all verified factors from the current user session. If the user has no verified factors or there is no session, an empty list is returned. To fetch up-to-date factors, use retrieveFactorsForCurrentUser.

Functions

Link copied to clipboard
abstract suspend fun createChallenge(factorId: String, channel: Phone.Channel? = null): MfaChallenge

Creates a new MFA challenge, which can be used to verify the user's code using verifyChallenge

Link copied to clipboard
open suspend fun createChallengeAndVerify(factorId: String, code: String, channel: Phone.Channel = Phone.Channel.SMS, saveSession: Boolean = true): UserSession

Creates a new MFA challenge and immediately verifies it

Link copied to clipboard
abstract suspend fun <Config, Response> enroll(factorType: FactorType<Config, Response>, friendlyName: String? = null, config: Config.() -> Unit = {}): MfaFactor<Response>
Link copied to clipboard

Parses the current JWT and returns the AuthenticatorAssuranceLevel for the current session and the next session

Link copied to clipboard

Retrieves all factors for the current user. This will make a network request to fetch the factors. Use verifiedFactors to get the factors from the current session.

Link copied to clipboard
abstract suspend fun unenroll(factorId: String)

Unenrolls an MFA factor

Link copied to clipboard
abstract suspend fun verifyChallenge(factorId: String, challengeId: String, code: String, saveSession: Boolean = true): UserSession

Verifies a MFA challenge