Skip to content

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

Merged
merged 5 commits into from
Sep 2, 2022
Merged

Conversation

alaister
Copy link
Member

What kind of change does this PR introduce?

Upgrades to the rc release of gotrue-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.

@kangmingtay kangmingtay self-requested a review August 29, 2022 11:14
@thorwebdev thorwebdev linked an issue Aug 31, 2022 that may be closed by this pull request
@thorwebdev thorwebdev requested a review from silentworks August 31, 2022 05:23
@thorwebdev thorwebdev marked this pull request as ready for review August 31, 2022 05:23
@dukesx
Copy link

dukesx commented Sep 1, 2022

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.

@grantvine-fg
Copy link

Will this fix the "getting logged out with a stale token" issue I have ?

@silentworks silentworks changed the base branch from main to next September 2, 2022 22:50
@silentworks silentworks merged commit f179523 into next Sep 2, 2022
@silentworks silentworks deleted the chore/upgrade-to-gotrue-js-rc branch September 2, 2022 23:00
Comment on lines -18 to -28
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;
}
Copy link

@AaronDewes AaronDewes Sep 4, 2022

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.

Copy link
Contributor

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({
Copy link
Contributor

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?

silentworks added a commit that referenced this pull request Oct 12, 2022
* 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]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

withMiddlewareAuth to work with nextjs 12.2 new middleware
6 participants