Open-source Python library for AI browser agents, plus Browser Use Cloud: stealth browsers and a hosted agent API.
Python ai-agentsai-toolsbrowser-agentbrowser-automationbrowser-usecdpcloud-browsercomputer-useheadless-browserllmmcpplaywrightpythonremote-browserstealth-browserweb-automationweb-scraping
Update 2FA implementation to standardize sensitive data references
Magnus Müllerbf385a3f340c
diff --git a/browser_use/tools/registry/service.py b/browser_use/tools/registry/service.pyindex fba456e72..4d1a8ee60 100644--- a/browser_use/tools/registry/service.py+++ b/browser_use/tools/registry/service.py@@ -438,7 +438,7 @@ class Registry(Generic[Context]):for placeholder in matches:if placeholder in applicable_secrets:# generate a totp code if secret is a 2fa secret- if 'otp_secret' in placeholder:+ if '2fa_code' in placeholder:totp = pyotp.TOTP(applicable_secrets[placeholder], digits=6)replacement_value = totp.now()else:diff --git a/examples/custom-functions/2fa.py b/examples/custom-functions/2fa.pyindex 53b0349f6..e90d596bf 100644--- a/examples/custom-functions/2fa.py+++ b/examples/custom-functions/2fa.py@@ -17,12 +17,16 @@ if not secret_key:secret_key = 'JBSWY3DPEHPK3PXP'-sensitive_data = {'otp_secret': secret_key}+sensitive_data = {'2fa_code': secret_key}task = """-1. Go to https://authenticationtest.com/totpChallenge/ and log in.-2. Use the the secret otp_secret to generate the 2FA code."""+1. Go to https://authenticationtest.com/totpChallenge/ and try to log in.+2. If prompted for 2FA code:+Input the the secret 2fa_code.++When you input 2fa_code, the 6 digit code will be generated automatically.+"""Agent(task=task, sensitive_data=sensitive_data).run_sync() # type: ignore