feat(eliza-app): implement phone-first auth with auto-provision#271
feat(eliza-app): implement phone-first auth with auto-provision#271
Conversation
Remove OTP flow in favor of simpler authentication: - iMessage: Auto-provision users on first message (phone or Apple ID email) - Telegram: Require OAuth + phone number to prevent bot abuse - Cross-platform: Same phone links accounts across Telegram/iMessage Key changes: - Blooio webhook: Auto-provision by phone OR email (no more rejection) - Telegram webhook: Keep OAuth enforcement, require phone - User service: Add findOrCreateByEmail, findOrCreateByTelegramWithPhone - Remove: OTP service, send-otp/verify-otp endpoints Tests: 37 passing, no LARP assertions Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
Important Review skippedAuto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the You can disable this status message by setting the
Note 🎁 Summarized by CodeRabbit FreeYour organization is on the Free plan. CodeRabbit will generate a high-level summary and a walkthrough for each pull request. For a comprehensive line-by-line review, please upgrade your subscription to CodeRabbit Pro by visiting https://app.coderabbit.ai/login. Comment |
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
Addresses PR review feedback about weak email validation. Creates isValidEmail(), normalizeEmail(), and maskEmailForLogging() with proper handling for edge cases. PR: #271 Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Reject invalid email formats before auto-provisioning. Use proper email masking for consistent logging. Addresses PR review: "Missing email format check before creating user" PR: #271 Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Replace inline regex with maskEmailForLogging() which handles emails with prefixes shorter than 4 characters gracefully. Addresses PR review: "Email masking regex fails on short emails" PR: #271 Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
iMessage delivery doesn't prove the user owns the email address (shared devices, etc.). Set email_verified=false until proper email verification is implemented. Addresses PR review: "email_verified: true for Apple ID emails is questionable" PR: #271 Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Add comprehensive tests for isValidEmail(), normalizeEmail(), and maskEmailForLogging() functions including: - Invalid formats (@, @@, test@, @test, etc.) - Missing TLD - Empty/null inputs - Short/long inputs - Short email prefixes 45 tests passing. Addresses PR review: "Test coverage gaps - missing email validation edge cases" PR: #271 Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Fixes two issues reported by Cursor Bugbot: 1. Missing conflict check in Scenario 1: Before updating phone on existing Telegram user, check if phone is already taken by another user. Returns proper 409 instead of 500 on unique constraint error. 2. Missing race condition handling in Scenario 3: Wrap user creation with try-catch and isUniqueConstraintError recovery, matching the pattern used in findOrCreateByPhone and findOrCreateByEmail. PR: #271 (comment) PR: #271 (comment) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
|
Claude says: Fixed both Cursor Bugbot issues in commit 3c86417: Issue 1 - Missing conflict check (Medium Severity): Issue 2 - Missing race condition handling (Low Severity): ~ Claude Opus 4.5 |
Simplify authentication by removing OTP flow: - get-started: New flow - Telegram OAuth → Phone input → Success - connected: Always show iMessage number, keep upstream dropdown UI - auth-context: Remove OTP methods, update loginWithTelegram signature - Delete unused TelegramLoginButton component Backend PR: elizaOS/cloud#271 Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This comment was marked as outdated.
This comment was marked as outdated.
Addresses two new Bugbot issues: 1. Scenario 2 race: Re-check telegram_id before linking Telegram to phone user. Prevents two Telegram accounts racing to link to same phone user. 2. Scenario 1 phone mismatch: If existing Telegram user already has a different phone linked, return PHONE_MISMATCH error instead of silently returning mismatched data. PR: #271 (comment) PR: #271 (comment) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
|
Claude says: Fixed both new Bugbot issues in commit bf55f98: Issue: Race condition in Scenario 2 (cross-platform linking) Issue: Scenario 1 returns mismatched phone ~ Claude Opus 4.5 |
This comment was marked as outdated.
This comment was marked as outdated.
1. Wrap update calls in Scenarios 1 & 2 with try-catch for unique constraint violations. Converts 500 errors to proper PHONE_ALREADY_LINKED responses, matching Scenario 3's pattern. 2. Remove SPEC-eliza-app-auth-flow.md from PR (internal doc). PR: #271 (comment) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
|
Claude says: Fixed in commit d9fb254. Wrapped Also removed the spec doc from the PR as requested. ~ Claude Opus 4.5 |
This comment was marked as outdated.
This comment was marked as outdated.
|
Thanks for the thorough review! Re: Critical Issues
Re: Medium Priority Issues
Will implement fixes 1, 3, and 5 after the next review iteration. |
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
Bugbot Autofix is OFF. To automatically fix reported issues with Cloud Agents, enable Autofix in the Cursor dashboard.
…dling - Remove redundant pre-flight checks in telegram auth route (service layer handles conflicts) - Add catch-all error handler to prevent uncontrolled 500s - Use isValidEmail() consistently in linkEmailToUser - Fix incomplete race condition recovery in Scenario 3 (check phone constraint too) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Summary
Simplifies eliza-app authentication by removing OTP flow in favor of auto-provision:
Changes
Backend
blooio/route.ts: Auto-provision users by phone OR email (removed rejection of Apple IDs)telegram/route.ts: Keep OAuth enforcement, phone number requireduser-service.ts: AddedfindOrCreateByEmail,findOrCreateByTelegramWithPhone, cross-platform linkingRemoved
send-otp,verify-otproutes)otp-service.test.ts,phone-auth-routes.test.ts)Added
SPEC-eliza-app-auth-flow.md: Comprehensive specification documentcleanup-eliza-app-user.ts: Development script for testingoauth-enforcement.test.ts: New tests for auth logic (37 passing)Test plan
bun test tests/unit/eliza-app/oauth-enforcement.test.ts- 37 tests pass🤖 Generated with Claude Code
Note
Medium Risk
Medium risk because it changes core authentication/user-linking flows and identity mapping (phone/email/Telegram) used to create sessions and route messages; mistakes could cause account conflicts or mis-association across platforms.
Overview
Eliza App auth is reworked to remove phone OTP login and standardize on Telegram OAuth + phone linking. The
/auth/telegramendpoint now requires aphone_number(validated/normalized to E.164) and callsfindOrCreateByTelegramWithPhone, returning conflict errors (409) when the phone is already linked or mismatched.iMessage (Blooio) webhook now auto-provisions by sender identifier (phone or Apple ID email) with new email validation/normalization helpers, and it switches conversation
entityIdtouser.idfor unified cross-platform memory. The Telegram webhook stops auto-provisioning and instead enforces prior OAuth registration, responding with a signup link when the user isn’t registered.OTP API routes/service and their unit tests are deleted, a new unit test suite covers OAuth enforcement/identifier handling, and a
cleanup-eliza-app-user.tsscript is added to remove test users/orgs and clear session keys.Written by Cursor Bugbot for commit efa35f4. This will update automatically on new commits. Configure here.