Conversation
There was a problem hiding this comment.
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:
- Type Definition: The
Impersonatorinterface is defined instate.tsand exported throughindex.tsfor public consumption - State Integration: The provider extracts impersonator data from the
OnRefreshResponsein thehandleRefreshcallback and includes it in state updates - Session Comparison: Impersonator fields are properly included in the session equality checks to ensure state updates trigger correctly when impersonation status changes
- Context Exposure: The impersonator data flows through the authentication context and becomes available via the
useAuthhook
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
Summary
Fixes #68