Skip to content

feat(llc): implement real guest token flow via createGuest - #113

Draft
renefloor wants to merge 6 commits into
mainfrom
renefloor/flu-373-guest-and-anonymous-login
Draft

feat(llc): implement real guest token flow via createGuest#113
renefloor wants to merge 6 commits into
mainfrom
renefloor/flu-373-guest-and-anonymous-login

Conversation

@renefloor

Copy link
Copy Markdown
Collaborator

Summary

  • Guest users (User.guest(id)) now use a real guest JWT obtained from POST /api/v2/guest rather than an anonymous static token. The TokenProvider.dynamic callback creates a minimal API-key-only HTTP client, calls DefaultApi.createGuest, and wraps the access_token in a UserToken so the token manager and AuthInterceptor treat it as a JWT.
  • Guest users can now call connect() and establish a full WebSocket session with read/write access.
  • Anonymous users (User.anonymous()) are unchanged: static anonymous token, stream-auth-type: anonymous header, and no WebSocket connection.
  • Added docs/code_snippets/02_02_authentication.dart with examples for regular JWT, dynamic token provider, guest, and anonymous auth patterns.

Closes FLU-373

Test plan

  • melos run analyze — no issues
  • melos run format — no changes
  • flutter test in packages/stream_feeds — 392 tests pass
  • dart analyze docs/code_snippets/02_02_authentication.dart — no issues

🤖 Generated with Claude Code

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>
@renefloor
renefloor requested a review from a team as a code owner June 17, 2026 13:04
@coderabbitai

coderabbitai Bot commented Jun 17, 2026

Copy link
Copy Markdown

Important

Review skipped

Draft detected.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: d2e5d805-a476-4872-bfc8-ee9d4567b34f

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch renefloor/flu-373-guest-and-anonymous-login

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@codecov

codecov Bot commented Jun 17, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 94.44444% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 85.59%. Comparing base (a1590dd) to head (477415c).

Files with missing lines Patch % Lines
...stream_feeds/lib/src/client/feeds_client_impl.dart 94.44% 1 Missing ⚠️
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.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

renefloor and others added 3 commits June 18, 2026 10:06
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>
Comment on lines +266 to +287
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();

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

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