Skip to content

feat(socket-auth): add socket.token() to mint realtime socket tokens - #45

Merged
roncodes merged 2 commits into
release/v2.1.0from
feature/socket-auth
Oct 8, 2026
Merged

roncodes merged 2 commits into
release/v2.1.0from
feature/socket-auth

Conversation

@roncodes

@roncodes roncodes commented Oct 6, 2026 •

Copy link
Copy Markdown
Member

What

  • New Socket helper exposed as fleetbase.socket; fleetbase.socket.token(options?) calls POST socket/token and resolves to { token, expires_in, expires_at } (exported type SocketTokenResponse).
  • setAdapter() also moves the socket helper to the new adapter.
  • README: new Realtime socket tokens section showing the server-side mint with a secret key, then the browser connecting with socketcluster-client using an in-memory authEngine / socket.authenticate(token) and refreshing ~60 s before expiry.
  • Changeset (minor). No version bump.

Why

Fleetbase realtime channels are moving to authenticated subscriptions. API customers need a supported way to exchange their secret key for a short-lived socket token on their own server, so the browser only ever sees the token.

Test plan

  • Unit tests in tests/core.test.ts cover the request path/body/options, adapter replacement and error propagation (100% coverage gate).
  • Verified by CI (not run locally).

Related PRs

Part of the authenticated realtime channels rollout (socket auth), one PR per repo:

Adds a Socket helper on the client (fleetbase.socket.token()) that calls
POST socket/token and resolves to { token, expires_in, expires_at }.
Documents the server-side mint / browser authenticate flow.
@codecov

codecov Bot commented Oct 6, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 100.00%. Comparing base (a502a95) to head (aaa39eb).

Additional details and impacted files
@@               Coverage Diff                @@
##           release/v2.1.0       #45   +/-   ##
================================================
  Coverage          100.00%   100.00%           
================================================
  Files                  17        18    +1     
  Lines                 855       860    +5     
  Branches              143       143           
================================================
+ Hits                  855       860    +5     

☔ 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.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@roncodes
roncodes merged commit 444df50 into release/v2.1.0 Oct 8, 2026
41 checks passed
@roncodes
roncodes deleted the feature/socket-auth branch October 8, 2026 10:06
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