Skip to content

Conversation

@zxch3n
Copy link
Member

@zxch3n zxch3n commented Dec 7, 2025

Resolve #32

Resolve auth tokens lazily for joins before registering pending rooms to avoid undefined auth during retries. Use AuthProvider for rejoin paths and await auth value; cleanup now handles failures. Add e2e that verifies a new token is fetched on rejoin when auth provider is used.

@zxch3n zxch3n changed the title Fix auth refresh on reconnect with auth providers feat: join room with auth providers Dec 7, 2025
Copy link

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds support for authentication providers that can return fresh tokens on room rejoins. The key improvement is enabling dynamic token refresh by accepting either static Uint8Array tokens or async functions (AuthProvider) that generate tokens on demand.

  • Introduces AuthProvider type to support both static tokens and dynamic token generation
  • Resolves auth lazily before registering pending rooms to prevent race conditions during retries
  • Updates rejoin logic to await and handle auth provider resolution with proper error handling
  • Adds comprehensive E2E test verifying fresh token fetching on reconnection

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.

File Description
packages/loro-websocket/src/client/index.ts Adds AuthProvider type, implements async auth resolution in resolveAuth(), updates join() to resolve auth before sending request, and modifies sendRejoinRequest() to handle auth providers with error handling
packages/loro-websocket/tests/e2e.test.ts Adds E2E test that verifies a new token is fetched from auth provider when client reconnects after server restart

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copy link
Contributor

Copilot AI commented Dec 7, 2025

@zxch3n I've opened a new pull request, #38, to work on those changes. Once the pull request is ready, I'll request review from you.

zxch3n and others added 3 commits December 8, 2025 02:44
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
…ndler

Co-authored-by: zxch3n <18425020+zxch3n@users.noreply.github.com>
@zxch3n zxch3n merged commit 8a9960a into main Dec 7, 2025
2 checks passed
@zxch3n zxch3n deleted the zxch3n/dynamic-auth-refresh branch December 7, 2025 19:03
@github-actions github-actions bot mentioned this pull request Dec 7, 2025
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.

Feature request: dynamic auth data in loro-websocket client

2 participants