auth-js
auth-js copied to clipboard
Allow to set the Gotrue audience header X-JWT-AUD
Feature request
Is your feature request related to a problem? Please describe.
Gotrue allows to specify the audience of the users during each request, either through the claim "aud" of the JWT token, either from a "X-JWT-AUD" header :
https://github.com/supabase/gotrue/blob/cc9db64d87eaa40cb2986cd3f8e89a17756b6aaa/api/helpers.go#L82
In Gotrue the audience is a credential, it is required to identify a user alongside the email/password or id or tokens of the user. So if a user has a specific audience (different from the default Gotrue audience), this audience must be specified in any request for this user. During signIn, there is no JWT, so no audience specified, so the only way to specify the audience during signin is throught the X-JWT-AUD header.
When using supabase-js it is difficult to use this feature in a clean way: the "headers" field of GotrueApi.ts is private with no setter, it is only possible to set it as a constructor parameter, but when a SupabaseClient instantiates GotrueClient it doesn't forwards the custom headers to it.
Describe the solution you'd like
It would be nice to have a setter on GotrueApi to enable adding a header after its instantiation.
Describe alternatives you've considered
Another solution (or complementary solution) would be to modify SupabaseClient.ts from supabase-js to make it inject additional headers into the constructor of GotrueClient :
https://github.com/supabase/supabase-js/pull/218