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
added pyotp dependency and 2fa code generation
Maxim Kopeckic386fc9bcc73
diff --git a/browser_use/controller/registry/service.py b/browser_use/controller/registry/service.pyindex 678ce13da..a20e41d7a 100644--- a/browser_use/controller/registry/service.py+++ b/browser_use/controller/registry/service.py@@ -24,6 +24,8 @@ from browser_use.observability import observe_debugfrom browser_use.telemetry.service import ProductTelemetryfrom browser_use.utils import is_new_tab_page, match_url_with_domain_pattern, time_execution_async+import pyotp+Context = TypeVar('Context')logger = logging.getLogger(__name__)@@ -444,6 +446,12 @@ 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_key" in placeholder:+ totp = pyotp.TOTP(applicable_secrets[placeholder], digits=6)+ applicable_secrets[placeholder] = totp.now()+value = value.replace(f'<secret>{placeholder}</secret>', applicable_secrets[placeholder])replaced_placeholders.add(placeholder)else:diff --git a/pyproject.toml b/pyproject.tomlindex 26d6ac42f..9cbb1a3d5 100644--- a/pyproject.toml+++ b/pyproject.toml@@ -42,6 +42,7 @@ dependencies = ["mcp>=1.10.1","pypdf>=5.7.0","markdown-pdf==1.5",+ "pyotp>=2.9.0",]# google-api-core: only used for Google LLM APIs# pyperclip: only used for examples that use copy/paste