Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@nicknisi
Copy link
Member

@nicknisi nicknisi commented Sep 3, 2025

Summary

  • Adds impersonator field to the useAuth hook
  • Exposes impersonator email and reason when a session is being impersonated
  • Exports Impersonator type for TypeScript users

Fixes #68

Copy link

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

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

Greptile Summary

This PR adds impersonator support to the AuthKit React library, bringing feature parity with other WorkOS client SDKs. The changes introduce a new Impersonator type containing email (string) and reason (string | null) fields that gets exposed through the useAuth hook when a session is being impersonated.

The implementation follows the existing authentication state management patterns in the codebase:

  1. Type Definition: The Impersonator interface is defined in state.ts and exported through index.ts for public consumption
  2. State Integration: The provider extracts impersonator data from the OnRefreshResponse in the handleRefresh callback and includes it in state updates
  3. Session Comparison: Impersonator fields are properly included in the session equality checks to ensure state updates trigger correctly when impersonation status changes
  4. Context Exposure: The impersonator data flows through the authentication context and becomes available via the useAuth hook

The changes maintain backward compatibility by making the impersonator field nullable with a default value of null. The implementation enables React applications to build impersonator components similar to those available in the Next.js SDK, addressing the functionality requested in issue #68.

Confidence score: 5/5

  • This PR is safe to merge with minimal risk as it adds new functionality without breaking existing behavior
  • Score reflects well-structured implementation following established codebase patterns with proper null handling and backward compatibility
  • No files require special attention as the changes are straightforward additions to the existing authentication flow

2 files reviewed, no comments

Edit Code Review Bot Settings | Greptile

@nicknisi nicknisi requested a review from stacurry September 3, 2025 14:15
@nicknisi nicknisi merged commit 89bbad3 into main Sep 3, 2025
2 checks passed
@nicknisi nicknisi deleted the nicknisi/impersonator-support branch September 3, 2025 17:18
@nicknisi nicknisi mentioned this pull request Sep 3, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

Impersonator Support

3 participants