Para supports Two-Factor Authentication (2FA) to enhance wallet recovery security by requiring users to provide two different authentication factors when verifying their identity.

Implementation Options

There are two ways to implement 2FA with Para:

  1. Using ParaModal (Recommended): The simplest approach with 2FA built-in and a complete user interface.
  2. Custom Implementation: For applications with custom UIs, manually implement 2FA using Para’s methods as described below.

The ParaModal enables 2FA by default. See the Customizing Para Guide if you need to disable this feature.

Custom Implementation Process

Follow these steps to implement 2FA in your custom UI:

1. Check 2FA Status

Begin by checking if 2FA is already enabled for the user:

const checkTwoFactorStatus = async () => {
  const { isSetup } = await para.check2FAStatus();
  
  if (isSetup) {
    // 2FA is already set up - proceed to verification if needed
  } else {
    // 2FA needs to be set up - proceed to setup flow
  }
};

2. Set Up 2FA

If 2FA isn’t configured, initiate the setup process:

const setupTwoFactor = async () => {
  const { uri } = await para.setup2FA();
  
  if (uri) {
    // Display the QR code to the user or provide the secret for manual entry
  } else {
    // Handle case where no URI is returned
  }
};

The returned uri can be used to generate a QR code or extracted to provide the secret key. Most authenticator apps (like Google Authenticator, Authy, or Microsoft Authenticator) can scan this QR code directly.

3. Enable 2FA

After the user has added the 2FA secret to their authenticator app, verify and enable 2FA:

const enableTwoFactor = async (verificationCode: string) => {
  await para.enable2FA({ verificationCode });
  // Notify the user of successful 2FA setup
};

4. Verify 2FA

When the user authenticates, verify their 2FA code:

const verifyTwoFactor = async (email: string, verificationCode: string) => {
  await para.verify2FA({ email, verificationCode });
  // Proceed with the authentication process
};

Next Steps

After integrating Para, you can explore other features and integrations to enhance your Para experience.