Skip to content

Conversation

@ohjonah
Copy link
Contributor

@ohjonah ohjonah commented Dec 23, 2025

This PR exposes the authenticationMethod field from the AuthKit JS SDK, allowing consumers to know how a user authenticated.

Changes

  • Added authenticationMethod to the State interface and initialState
  • Updated handleRefresh in the provider to extract and store authenticationMethod from the refresh response
  • Added authenticationMethod to the session equality check to prevent unnecessary re-renders
  • Re-exported AuthenticationMethod type for consumer use (authkit-js)

@greptile-apps
Copy link

greptile-apps bot commented Dec 23, 2025

Greptile Summary

This PR exposes the authenticationMethod field from the AuthKit JS SDK through the React wrapper, enabling consumers to determine how a user authenticated.

  • Added authenticationMethod to the State interface and initialState in src/state.ts:17,29
  • Updated handleRefresh in src/provider.tsx:43,61 to extract and store authenticationMethod from the refresh response
  • Added authenticationMethod to the session equality check in src/provider.tsx:133 to prevent unnecessary re-renders when the authentication method changes
  • Re-exported AuthenticationMethod type in src/index.ts:10 for consumer use

The implementation is clean, consistent, and follows the existing patterns for other session fields like impersonator. All changes are properly threaded through the state management system.

Confidence Score: 5/5

  • This PR is safe to merge with no identified risks
  • The changes are straightforward and follow existing patterns consistently. The new field is properly threaded through all necessary components: type definitions, state initialization, refresh handler, and equality checks. No security concerns identified - the field is simply passed through from the underlying SDK without transformation.
  • No files require special attention

Important Files Changed

Filename Overview
src/state.ts Added authenticationMethod field to State interface and initialState
src/provider.tsx Extracts and stores authenticationMethod from refresh response, includes it in session equality check
src/index.ts Re-exports AuthenticationMethod type from authkit-js for consumer use

Sequence Diagram

sequenceDiagram
    participant App
    participant Hook
    participant Provider
    participant JS

    App->>Provider: Init
    Provider->>JS: createClient
    JS-->>Provider: client
    
    JS->>Provider: onRefresh
    Provider->>JS: getClaims
    JS-->>Provider: claims
    Provider->>Provider: update state
    
    App->>Hook: useAuth
    Hook-->>App: authenticationMethod
Loading

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.

3 files reviewed, no comments

Edit Code Review Agent Settings | Greptile

} from "@workos-inc/authkit-js";
export type {
User,
AuthenticationMethod,
Copy link
Member

Choose a reason for hiding this comment

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

@ohjonah I just released authkit-js v0.17.0, which included your change to introduce AuthenticationMethod. We'll need to upgrade authkit-js in authkit-react in this PR to get it working.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sweet! Doing that now - thanks for the review!!

@ohjonah ohjonah requested a review from nholden December 23, 2025 23:43
Copy link
Member

@nholden nholden left a comment

Choose a reason for hiding this comment

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

🙌

@nholden nholden merged commit 416f4ae into main Dec 24, 2025
4 checks passed
@nholden nholden deleted the support-auth-method-in-state branch December 24, 2025 00:05
@nholden nholden mentioned this pull request Dec 24, 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.

3 participants