# MFA Enrollment Form
# Interactive Multi-Factor Authentication enrollment
# Location: .typedialog/provisioning/mfa-enroll.toml

description = "Interactive Multi-Factor Authentication enrollment"
display_mode = "complete"
locales_path = "../../../../../locales"
name = "MFA Enrollment"

# ============================================================================
# MFA CONFIGURATION
# ============================================================================

[[elements]]
border_bottom = true
border_top = true
name = "mfa_header"
title = "🔐 Multi-Factor Authentication Setup"
type = "section_header"

[[elements]]
default = "totp"
help = "Choose the MFA method"
name = "mfa_type"
nickel_path = ["mfa", "type"]
options = ["totp", "webauthn", "sms"]
prompt = "MFA Type"
required = true
type = "select"

# ============================================================================
# TOTP CONFIGURATION (Time-based One-Time Password)
# ============================================================================

[[elements]]
border_bottom = true
border_top = true
name = "totp_header"
title = "📱 TOTP Configuration"
type = "section_header"
when = "mfa_type == 'totp'"

[[elements]]
default = "Authenticator App"
help = "Name for this MFA device (e.g., 'iPhone', 'Authenticator App')"
name = "totp_device_name"
nickel_path = ["mfa", "totp", "device_name"]
placeholder = "My Phone"
prompt = "Device name"
required = false
type = "text"
when = "mfa_type == 'totp'"

[[elements]]
help = "Verify your setup by entering the code from your authenticator app"
name = "totp_verification_code"
nickel_path = ["mfa", "totp", "verification_code"]
placeholder = "123456"
prompt = "Verification code (6 digits)"
required = false
type = "text"
validation_pattern = "^[0-9]{6}$"
when = "mfa_type == 'totp'"

# ============================================================================
# WEBAUTHN CONFIGURATION (Hardware Keys / Biometrics)
# ============================================================================

[[elements]]
border_bottom = true
border_top = true
name = "webauthn_header"
title = "🔑 WebAuthn Configuration"
type = "section_header"
when = "mfa_type == 'webauthn'"

[[elements]]
default = "Security Key"
help = "Name for this security key (e.g., 'YubiKey', 'Fingerprint')"
name = "webauthn_device_name"
nickel_path = ["mfa", "webauthn", "device_name"]
placeholder = "Security Key"
prompt = "Device name"
required = false
type = "text"
when = "mfa_type == 'webauthn'"

# ============================================================================
# SMS CONFIGURATION
# ============================================================================

[[elements]]
border_bottom = true
border_top = true
name = "sms_header"
title = "📲 SMS Configuration"
type = "section_header"
when = "mfa_type == 'sms'"

[[elements]]
help = "Phone number for SMS verification (international format: +1234567890)"
name = "sms_phone_number"
nickel_path = ["mfa", "sms", "phone_number"]
placeholder = "+1234567890"
prompt = "Phone number"
required = false
type = "text"
validation_pattern = "^\\+[0-9]{10,15}$"
when = "mfa_type == 'sms'"

[[elements]]
help = "Verify your phone number by entering the SMS code"
name = "sms_verification_code"
nickel_path = ["mfa", "sms", "verification_code"]
placeholder = "123456"
prompt = "SMS verification code (6 digits)"
required = false
type = "text"
validation_pattern = "^[0-9]{6}$"
when = "mfa_type == 'sms'"

# ============================================================================
# BACKUP CODES
# ============================================================================

[[elements]]
border_bottom = true
border_top = true
name = "backup_header"
title = "💾 Backup Codes"
type = "section_header"

[[elements]]
default = true
help = "Generate backup codes for account recovery"
name = "generate_backup_codes"
nickel_path = ["mfa", "generate_backup_codes"]
prompt = "Generate backup codes?"
required = false
type = "confirm"

[[elements]]
default = 10
help = "Number of backup codes to generate"
max = 20
min = 5
name = "backup_codes_count"
nickel_path = ["mfa", "backup_codes_count"]
prompt = "Number of backup codes"
required = false
type = "number"
when = "generate_backup_codes == true"

# ============================================================================
# CONFIRMATION
# ============================================================================

[[elements]]
border_bottom = true
border_top = true
name = "confirm_header"
title = "✅ Confirmation"
type = "section_header"

[[elements]]
default = true
help = "Confirm MFA enrollment with the provided configuration"
name = "confirm_enroll"
nickel_path = ["mfa", "confirm_enroll"]
prompt = "Complete MFA enrollment?"
required = false
type = "confirm"
