Supported factor types: totp (stable) and webauthn (experimental — opt in with @_spi(Experimental) import Supabase). The returned id should be used to create a challenge.
For a one-call WebAuthn enrollment on iOS 16+/macOS 13+, use mfa.enrollWebAuthnFactor(friendlyName:presentationAnchor:) instead.
Examples
Enroll a time-based, one-time password (TOTP) factor
let response = try await supabase.auth.mfa.enroll(
params: MFAEnrollParams(
issuer: "optional issuer",
friendlyName: "optional friendly name"
)
)
// Use the id to create a challenge.
// The challenge can be verified by entering the code generated from the authenticator app.
// The code will be generated upon scanning the qrCode or entering the secret into the authenticator app.
let id = response.id
let type = response.type
let qrCode = response.totp?.qrCode
let secret = response.totp?.secret
let uri = response.totp?.uri
Enroll a WebAuthn (passkey) factor (iOS 16+/macOS 13+, experimental)
// @_spi(Experimental) import Supabase
// enrollWebAuthnFactor drives the full ceremony: enroll → challenge → present native UI → verify.
let verifyResponse = try await supabase.auth.mfa.enrollWebAuthnFactor(
friendlyName: "My passkey",
presentationAnchor: view.window!
)