Adopt createGuest's server-issued identity for guest users#1704
Conversation
PR checklist ✅All required conditions are satisfied:
🎉 Great job! This PR is ready for review. |
ba62c23 to
f13c6a4
Compare
…y in sync The createGuest endpoint returns the server-resolved user (which may differ from what was passed in — e.g. normalized id). The SDK previously kept only the access token and left its in-memory user as the builder's input, so the WS auth payload and the JWT user_id claim could disagree. setupGuestUser now also updates client.user from response.user (matching the JS SDK's connectUser(response.user, response.access_token) semantics). userId becomes a computed property so every existing reader of client.userId picks up the new identity automatically. CoordinatorSocketConnection.user turns into a var so its onCreated() auth payload reads the latest user. Adds three regression tests: userId reactivity, the var update inside the socket connection's connect path, and a full setupGuestUser flow with the api mocked to return a different user id than the input. AND-1202
SDK Size Comparison 📏
|
2638910 to
63ccca2
Compare
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (3)
WalkthroughThe PR updates ChangesGuest user identity adoption with mutable user properties
🎯 3 (Moderate) | ⏱️ ~20 minutes
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|



Stacked on #1703. Merge after parent.
Goal
Refs AND-1202 — keep the SDK's in-memory guest user in sync with the server-issued identity returned by
createGuest, matching the JS SDK'sconnectUser(response.user, response.access_token)semantics.The SDK previously discarded
response.userand only keptresponse.accessToken. If the server resolves a guest id to a different value than what the integrator passed in, the WS auth payload (built fromclient.user.id) and the JWTuser_idclaim drift apart.Implementation
setupGuestUsernow mapsresponse.userviaUserResponse.toUser(), re-appliesUserType.Guest, and writes the result back toStreamVideoClient.user.StreamVideoClient.userbecomesvar;userIdbecomesget() = user.idso every reader (CallState,ParticipantState, ringing-state checks) picks up the new identity.CoordinatorSocketConnection.userbecomesvar, set from theconnectData/dataargument insideconnect()/reconnect()soonCreated()'s WS auth payload reflects the latest user.Testing
StreamVideoClientTest:userId tracks the current user reference— the computed property.setupGuestUser adopts the server-issued user identity on success— drivessetupGuestUserwith a mockedapi.createGuestreturning a different id; assertsclient.user.id,client.userId, and preservedUserType.Guest.Summary by CodeRabbit