-
Notifications
You must be signed in to change notification settings - Fork 4
feat: join room with auth providers #37
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this 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".
There was a problem hiding this 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
AuthProvidertype 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.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
…ndler Co-authored-by: zxch3n <18425020+zxch3n@users.noreply.github.com>
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.