-
Notifications
You must be signed in to change notification settings - Fork 486
Description
Refactor Request
Describe the refactor
The getClaims()
method returns JwtPayload
with type RequiredClaims & { [key: string]: any }
, which doesn't provide TypeScript types for common Supabase JWT fields that are documented in
the JWT Claims Reference.
const { data } = await supabase.auth.getClaims()
data.claims.email // No TypeScript support
data.claims.user_metadata // No TypeScript support
The documented fields like email, phone, user_metadata, app_metadata, and is_anonymous exist at
runtime but aren't typed, making developers lose autocomplete and type safety. I understand why you did it, but it doesn't make it smooth to work with.
getUser()
returns a properly typed User object with these fields, but getClaims()
loses this type
information despite returning the same data from the JWT.
Additional context
Would you consider providing TypeScript types for these documented JWT fields, or what's the
recommended approach for type-safe access to these claims when using getClaims()?