Overview
Login two-factor authentication (2FA) asks a user for a second factor after their first sign-in step, such as verifying their email or phone. Turn it on and choose the methods users can enroll in the Developer Portal’s Login Two-Factor Authentication setting: Off (users are never asked), Optional (users who enroll are asked for it), or Required (every user enrolls at their next sign-in). When a sign-in needs a second factor, the user either enrolls one (when your app requires 2FA and they don’t have one yet) or verifies one they already have. Para hosts both steps on its own pages. Your app doesn’t build 2FA screens. If an account keeps its wallet on the user’s device behind a passkey, that passkey is its second factor: the user doesn’t set up an authenticator app and isn’t asked for anything extra at sign-in. Accounts that keep their wallet on the device behind a password or PIN set up an authenticator app like other users.With the authenticate Methods
authenticateWithEmailOrPhone and authenticateWithOAuth need no code changes. On Para’s updated authentication flow, the Para-hosted page runs the second-factor step after the first one, in the same WebAuthenticationSession sheet, and the call returns its AuthenticationResult once the user completes it.
A few sign-ins don’t ask for a second factor:
- Native passkey sign-in. A passkey created on the device that protects the user’s wallet is bound to the device and asks for Face ID, Touch ID, or the device passcode, so signing in with it satisfies 2FA on its own.
- External wallet sign-in with
authenticateWithExternalWalleton Para’s updated authentication flow. The session proves control of the external wallet only and can’t sign with the account’s embedded Para wallets, so it doesn’t owe a second factor. Without the updated flow, the call signs in throughloginExternalWallet, which can owe a second factor (see below).
With the Stage-Based Methods
The stage-based methods (initiateAuthFlow, handleVerificationCode, handleOAuth, and loginExternalWallet) can’t host the second-factor step. When an account must complete it, they cancel the pending sign-in and throw ParaTwoFactorRequiredError. The authenticate methods throw it too when Para’s updated authentication flow isn’t enabled for your app, because they then sign in through these methods.
Para decides which sign-in experience runs for your app, so catch the error and tell the user. Use the authenticate methods, which complete the second factor once Para’s updated authentication flow runs for your app:
AuthenticationView.swift
ParaTwoFactorRequiredError is its own type rather than a ParaError case, so existing switch statements over ParaError keep compiling. Its mode is .verify when the account has a second factor to verify and .enroll when it must set one up first (nil when Para didn’t say), and methods lists the second-factor methods Para offered.