Skip to content

fix: implement Clerk v7 custom auth flow and correct SSE parsing - #85

Merged
ferosai[bot] merged 1 commit into
mainfrom
sync/main
May 13, 2026
Merged

fix: implement Clerk v7 custom auth flow and correct SSE parsing#85
ferosai[bot] merged 1 commit into
mainfrom
sync/main

Conversation

@ferosai

@ferosai ferosai Bot commented May 13, 2026

Copy link
Copy Markdown

fix: implement Clerk v7 custom auth flow and correct SSE parsing

This commit addresses two critical issues in the frontend functionality:

  1. Authentication Flow (Clerk v7 Migration):

    • Migrated the custom sign-in form to utilize the correct Clerk Next.js v7 SDK API surface (signIn.password(), signIn.mfa.sendEmailCode(), signIn.mfa.verifyEmailCode()).
    • Replaced deprecated v4/v5 methods (signIn.create, attemptFirstFactor, setActive) which were causing TypeScript build failures.
    • Implemented a complete state machine to handle Multi-Factor Authentication (MFA) and Client Trust requirements, automatically toggling the UI to prompt for an email verification code when necessary.
    • Hardened error handling by properly casting and parsing native ClerkError objects without relying on deprecated array structures.
  2. API Event Stream Parser:

    • Fixed off-by-one substring index errors in the Server-Sent Events (SSE) parser (event: and data: prefixes).
    • Added multiline data concatenation logic to ensure complete payload capture when streaming chunks are split across multiple lines.
    • Added the explicit Accept: text/event-stream header for better proxy/CDN compatibility.

This commit addresses two critical issues in the frontend functionality:

1. Authentication Flow (Clerk v7 Migration):
   - Migrated the custom sign-in form to utilize the correct Clerk Next.js v7 SDK API surface (`signIn.password()`, `signIn.mfa.sendEmailCode()`, `signIn.mfa.verifyEmailCode()`).
   - Replaced deprecated v4/v5 methods (`signIn.create`, `attemptFirstFactor`, `setActive`) which were causing TypeScript build failures.
   - Implemented a complete state machine to handle Multi-Factor Authentication (MFA) and Client Trust requirements, automatically toggling the UI to prompt for an email verification code when necessary.
   - Hardened error handling by properly casting and parsing native `ClerkError` objects without relying on deprecated array structures.

2. API Event Stream Parser:
   - Fixed off-by-one substring index errors in the Server-Sent Events (SSE) parser (`event:` and `data:` prefixes).
   - Added multiline data concatenation logic to ensure complete payload capture when streaming chunks are split across multiple lines.
   - Added the explicit `Accept: text/event-stream` header for better proxy/CDN compatibility.

GitOrigin-RevId: 637463bdf54360d554260868c06bd0d832dc4b42
@ferosai
ferosai Bot merged commit 657d931 into main May 13, 2026
@ferosai
ferosai Bot deleted the sync/main branch May 13, 2026 07:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant