✳ Lambatoken / Mobile DocsAUTH 0.7.0 · WALLET 0.2.0
Authentication / 08

MFA recovery and account recovery

Two different recovery mechanisms; neither is a wallet seed recovery flow.

Generate recovery codes

An authenticated enrolled user supplies their primary credential and current TOTP. Show codes once and advise offline storage. Never send codes to analytics.

typescript
const codes = await auth.mfa.recoveryGenerate(currentPassword, code);
// Secure display: codes.codes
const status = await auth.mfa.recoveryStatus();
// Regenerate explicitly with auth.mfa.recoveryRegenerate(password, code).

Replace lost authenticator

During MFA login use a recovery code. The SDK holds a restricted recovery credential. Start replacement, display new QR, confirm and return to login.

typescript
await auth.recoverMfa(challengeId, recoveryCode);
const replacement = await auth.mfa.replacementStart();
// Display replacement.otpauthUri securely.
await auth.mfa.replacementConfirm(replacement.replacementId, newTotp);

Generate account recovery credential

This is separate from TOTP recovery codes. Store the returned secret offline; do not persist it in the app.

typescript
const receipt = await auth.account.generateRecoveryCredential(currentPassword);
// Secure display: receipt.secret
await auth.account.recoveryCredentialStatus();
// Explicit revoke: auth.account.revokeRecoveryCredential(currentPassword)

Recover account

Start with email and recovery secret; complete email proof and TOTP when required. The final operation resets the password and explicitly disconnects providers. Obtain user consent and then require login.

typescript
const start = await auth.account.startRecovery(email, recoverySecret);
const grant = await auth.account.verifyRecovery({
  challengeId: start.challengeId, recoverySecret, emailCode, totpCode,
});
await auth.account.completeRecovery({
  authorizationId: grant.authorizationId,
  recoveryAuthorization: grant.secret, newPassword, disconnectProviders: true,
});