feat(llc): implement real guest token flow via createGuest - #113
feat(llc): implement real guest token flow via createGuest#113renefloor wants to merge 6 commits into
Conversation
Guest users (User.guest) now call POST /api/v2/guest to mint a temporary JWT on connect() instead of reusing the anonymous token. This gives guest users a full authenticated WebSocket session. Anonymous users are unchanged: they continue to use the static anonymous token with no WS connection. Closes FLU-373 Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
|
Important Review skippedDraft detected. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 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 |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #113 +/- ##
==========================================
+ Coverage 85.53% 85.59% +0.05%
==========================================
Files 124 124
Lines 4342 4359 +17
==========================================
+ Hits 3714 3731 +17
Misses 628 628 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Inject guestRestApi into StreamFeedsClientImpl to make the guest createGuest() call testable. Add unit test for the guest user token flow via createGuest. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
| return TokenProvider.dynamic((_) async { | ||
| final guestApiClient = guestApi ??= api.DefaultApi( | ||
| StreamCoreHttpClient(options: _restApiOptions(endpointConfig)).apply( | ||
| (client) => client.interceptors.addAll([ | ||
| ApiKeyInterceptor(apiKey), | ||
| HeadersInterceptor(_systemEnvironmentManager), | ||
| const ApiErrorInterceptor(), | ||
| ]), | ||
| ), | ||
| ); | ||
|
|
||
| final result = await guestApiClient.createGuest( | ||
| createGuestRequest: api.CreateGuestRequest( | ||
| user: api.UserRequest( | ||
| id: user.id, | ||
| name: user.originalName, | ||
| image: user.image, | ||
| custom: user.custom.isEmpty ? null : user.custom, | ||
| ), | ||
| ), | ||
| ); | ||
| final response = result.getOrThrow(); |
There was a problem hiding this comment.
Maybe we should put this in the UserRepository from https://github.com/GetStream/stream-feeds-flutter/pull/111/changes#diff-650fcf6bedea499ffcb82f20d5cda7f3a5c6fcb02a19c1bb398a4347c61cc5eb
Summary
User.guest(id)) now use a real guest JWT obtained fromPOST /api/v2/guestrather than an anonymous static token. TheTokenProvider.dynamiccallback creates a minimal API-key-only HTTP client, callsDefaultApi.createGuest, and wraps theaccess_tokenin aUserTokenso the token manager andAuthInterceptortreat it as a JWT.connect()and establish a full WebSocket session with read/write access.User.anonymous()) are unchanged: static anonymous token,stream-auth-type: anonymousheader, and no WebSocket connection.docs/code_snippets/02_02_authentication.dartwith examples for regular JWT, dynamic token provider, guest, and anonymous auth patterns.Closes FLU-373
Test plan
melos run analyze— no issuesmelos run format— no changesflutter testinpackages/stream_feeds— 392 tests passdart analyze docs/code_snippets/02_02_authentication.dart— no issues🤖 Generated with Claude Code