Skip to content

feat: add new token fetching via comlink #475

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

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

ryanbonial
Copy link
Member

@ryanbonial ryanbonial commented Apr 30, 2025

Description

Adds token refresh functionality for SDK instances running within the Sanity dashboard. This implementation enables seamless token renewal without requiring users to re-authenticate when their session expires.

The changes include:

  • New setAuthToken action to update authentication state
  • getIsInDashboardState selector to detect if SDK is running in dashboard context
  • Comlink message types for token refresh communication
  • ComlinkTokenRefreshProvider component for React applications

What to review

  • The new token refresh flow between iframe and parent window
  • Implementation of setAuthToken in authStore.ts
  • The ComlinkTokenRefresh component and its configuration options
  • Updates to client store to properly handle middleware
  • Exported types and functions in the public API

Testing

Tested the token refresh flow in both dashboard and standalone contexts to ensure:

  • Token requests are properly sent from SDK to parent
  • Received tokens are correctly applied to the auth state
  • Client instances are updated with new tokens
  • The feature is only active when explicitly enabled and running in dashboard

Fun gif

Copy link

vercel bot commented Apr 30, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
sdk-docs ❌ Failed (Inspect) May 1, 2025 9:11pm
sdk-kitchensink-react ❌ Failed (Inspect) May 1, 2025 9:11pm

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