MFA Handling - TOTP Automation

Automate MFA completion using TOTP code generation with RFC 6238 compliant algorithm

Demo preview
TypeScript
Source code
npx create-browser-app --template mfa-handling
uvx create-browser-app --template mfa-handling

Get started automating TOTP-based MFA authentication

This template automates Multi-Factor Authentication (MFA) completion using Time-based One-Time Password (TOTP) code generation. It implements the RFC 6238 compliant algorithm to generate 6-digit codes programmatically, extracts TOTP secrets from pages, and automatically fills MFA forms without user interaction. The template includes retry logic to handle time window edge cases and automatically regenerates codes when authentication fails. Perfect for automated authentication workflows and `zero-touch` MFA completion.

Steps

  1. Navigate to the authentication page with TOTP challenge
  2. Extract test credentials (email, password) and TOTP secret from the page
  3. Generate TOTP code using RFC 6238 algorithm (HMAC-SHA1, 30-second windows)
  4. Fill in email and password fields using Stagehand act
  5. Fill in TOTP code field with the generated code
  6. Submit the authentication form