-
Notifications
You must be signed in to change notification settings - Fork 224
chore: upgrade to supabase-js v2 #239
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Looks promising but we really need a better way to manage auth state. OAuth is one weak point of Supabase auth, especially when it comes to redirecting to index page and you immediately need the session state. |
Will this fix the "getting logged out with a stale token" issue I have ? |
export interface CookieOptions { | ||
// (Optional) The Cookie name prefix. Defaults to `sb` meaning the cookies will be `sb-access-token` and `sb-refresh-token`. | ||
name?: string; | ||
// (Optional) The cookie lifetime (expiration) in seconds. Set to 8 hours by default. | ||
lifetime?: number; | ||
// (Optional) The cookie domain this should run on. Leave it blank to restrict it to your domain. | ||
domain?: string; | ||
path?: string; | ||
// (Optional) SameSite configuration for the session cookie. Defaults to 'lax', but can be changed to 'strict' or 'none'. Set it to false if you want to disable the SameSite setting. | ||
sameSite?: string; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I just tried this version, and this change broke builds or me, because the sveltekit helpers seemed to import it.
Edit: It was actually COOKIE_OPTIONS
(constant), not the type.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
SvelteKit helpers haven't been upgraded to work with v2 as yet.
import { CookieOptions } from './types'; | ||
import { isBrowser } from './utils/helpers'; | ||
|
||
export function createBrowserSupabaseClient({ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
With the new v2 createClient API shouldn't we be expecting a users to provide a Database type?
* Update to add release from the next branch * Setup for pre-releases of libraries * chore: upgrade to supabase-js v2 (#239) * chore: upgrade to gotrue js rc * pass initial session in ssr * adds onAuthStateChange to SessionContextProvider * chore: update to auth-ui-react. * chore: some nits Co-authored-by: thorwebdev <[email protected]> * Update to work with supabase-js v2 RC (#242) * chore: update versions (next) (#243) Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com> * chore: update middleware (#247) * chore: update middleware and README. * chore: changeset * chore: update versions (next) (#248) Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com> * chore: improve types. (#255) * chore: improve types. * chore: types and changeset. * chore: update versions (next) (#257) Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com> * chore: types n middleware (#259) * chore: fix types and middleware. * chore: changeset * chore: update versions (next) (#260) Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com> * chore: README and migration guide. * fix: type useSupabaseClient (#291) * fix: type useSupabaseClient * chore: run changeset * chore: update versions (next) (#292) Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com> * chore: fix versioning * sveltekit supabase v2 (#296) * sveltekit supabase v2 * update lockfile * add missing exports & error * httpOnly false * add sveltekit supabase v2 support * chore: update versions (next) (#297) * chore: update versions (next) * chore: revert fix versions Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com> Co-authored-by: thorwebdev <[email protected]> * chore: update v 2.0.0 * chore: changeset exit * chore: fix version typo. * chore: update versions (#298) Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com> * Rollback to last change being 0.7.1 Co-authored-by: Andrew Smith <[email protected]> Co-authored-by: Alaister Young <[email protected]> Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com> Co-authored-by: David Plugge <[email protected]>
What kind of change does this PR introduce?
Upgrades to the
rc
release ofgotrue-js
Additional context
At this stage, this can be treated as a proof-of-concept of a technically different approach to the
auth-helpers
.Refreshing behaviour is now handled by
gotrue-js
, and the session is synced by using shared cookies.The
nextjs
example has been updated to work with this new approach. If we decide this is the direction we want to take, we can look at upgrading the other libraries/examples too.