Skip to content

Commit

Permalink
Storage adapter (#507)
Browse files Browse the repository at this point in the history
* add storage adapters

* Remove unused filterCookies function

* add pkce support

* update sveltekit example

* Add pre-release changeset

* Bump SvelteKit version

---------

Co-authored-by: David Plugge <git@davidplugge.de>
  • Loading branch information
silentworks and david-plugge committed Apr 12, 2023
1 parent 413476d commit 65bf8d4
Show file tree
Hide file tree
Showing 112 changed files with 1,552 additions and 2,711 deletions.
9 changes: 9 additions & 0 deletions .changeset/cyan-dancers-care.md
@@ -0,0 +1,9 @@
---
'@supabase/auth-helpers-nextjs': minor
'@supabase/auth-helpers-react': minor
'@supabase/auth-helpers-remix': minor
'@supabase/auth-helpers-shared': minor
'@supabase/auth-helpers-sveltekit': minor
---

Add cookie storage adapter per library following a shared storage adapter
17 changes: 17 additions & 0 deletions .changeset/pre.json
@@ -0,0 +1,17 @@
{
"mode": "pre",
"tag": "next",
"initialVersions": {
"@example/nextjs": "0.0.0",
"@example/nextjs-server-components": "0.0.0",
"@example/sveltekit": "0.0.0",
"config": "0.1.0",
"@supabase/auth-helpers-nextjs": "0.6.0",
"@supabase/auth-helpers-react": "0.3.1",
"@supabase/auth-helpers-remix": "0.1.8",
"@supabase/auth-helpers-shared": "0.3.3",
"@supabase/auth-helpers-sveltekit": "0.9.3",
"tsconfig": "0.1.1"
},
"changesets": []
}
9 changes: 9 additions & 0 deletions .changeset/violet-frogs-know.md
@@ -0,0 +1,9 @@
---
'@supabase/auth-helpers-nextjs': minor
'@supabase/auth-helpers-react': minor
'@supabase/auth-helpers-remix': minor
'@supabase/auth-helpers-shared': minor
'@supabase/auth-helpers-sveltekit': minor
---

Add full server side support to auth helpers through PKCE
1 change: 1 addition & 0 deletions examples/nextjs/package.json
Expand Up @@ -13,6 +13,7 @@
"@supabase/auth-helpers-nextjs": "workspace:*",
"@supabase/auth-helpers-react": "workspace:*",
"@supabase/auth-ui-react": "^0.2.6",
"@supabase/supabase-js": "^2.19.0",
"next": "^12.2.5",
"react": "17.0.2",
"react-dom": "17.0.2"
Expand Down
18 changes: 18 additions & 0 deletions examples/nextjs/pages/api/callback.ts
@@ -0,0 +1,18 @@
// pages/api/protected-route.ts
import { NextApiHandler } from 'next';
import { createServerSupabaseClient } from '@supabase/auth-helpers-nextjs';

const callback: NextApiHandler = async (req, res) => {
// Create authenticated Supabase Client
const supabase = createServerSupabaseClient({ req, res });

const code = req.query.code;

if (typeof code === 'string') {
await supabase.auth.exchangeCodeForSession(code);
}

res.redirect('/');
};

export default callback;
5 changes: 4 additions & 1 deletion examples/nextjs/pages/index.tsx
Expand Up @@ -34,7 +34,10 @@ const LoginPage: NextPage = () => {
onClick={() => {
supabaseClient.auth.signInWithOAuth({
provider: 'github',
options: { scopes: 'repo', redirectTo: 'http://localhost:3000' }
options: {
scopes: 'repo',
redirectTo: 'http://localhost:3000/api/callback'
}
});
}}
>
Expand Down
5 changes: 4 additions & 1 deletion examples/remix/app/routes/__supabase.tsx
Expand Up @@ -70,7 +70,10 @@ export default function Supabase() {
const {
data: { subscription }
} = supabase.auth.onAuthStateChange((event, session) => {
if (session?.access_token !== serverAccessToken) {
if (
session?.access_token !== serverAccessToken &&
fetcher.state === 'idle'
) {
// server and client are out of sync.
// Remix recalls active loaders after actions complete
fetcher.submit(null, {
Expand Down
18 changes: 18 additions & 0 deletions examples/remix/app/routes/__supabase/callback.tsx
@@ -0,0 +1,18 @@
import { type LoaderArgs, redirect } from '@remix-run/node';
import { createServerClient } from 'utils/supabase.server';

export async function loader({ request }: LoaderArgs) {
const url = new URL(request.url);
const code = url.searchParams.get('code');

const response = new Response();
if (code) {
const supabase = createServerClient({ request, response });
await supabase.auth.exchangeCodeForSession(code);
}

return redirect('/', {
status: 303,
headers: response.headers
});
}
5 changes: 4 additions & 1 deletion examples/remix/components/login.tsx
Expand Up @@ -20,7 +20,10 @@ export default function Login({

const handleGitHubLogin = async () => {
const { error } = await supabase.auth.signInWithOAuth({
provider: 'github'
provider: 'github',
options: {
redirectTo: `${location.origin}/callback`
}
});

if (error) {
Expand Down
1 change: 1 addition & 0 deletions examples/remix/package.json
Expand Up @@ -12,6 +12,7 @@
"@remix-run/react": "^1.7.6",
"@remix-run/serve": "^1.7.6",
"@supabase/auth-helpers-remix": "workspace:*",
"@supabase/supabase-js": "^2.19.0",
"isbot": "^3.5.4",
"react": "^18.2.0",
"react-dom": "^18.2.0"
Expand Down
3 changes: 0 additions & 3 deletions examples/sveltekit-email-password/.env.example

This file was deleted.

20 changes: 0 additions & 20 deletions examples/sveltekit-email-password/.eslintrc.cjs

This file was deleted.

8 changes: 0 additions & 8 deletions examples/sveltekit-email-password/.gitignore

This file was deleted.

1 change: 0 additions & 1 deletion examples/sveltekit-email-password/.npmrc

This file was deleted.

6 changes: 0 additions & 6 deletions examples/sveltekit-email-password/.prettierrc

This file was deleted.

40 changes: 0 additions & 40 deletions examples/sveltekit-email-password/README.md

This file was deleted.

39 changes: 0 additions & 39 deletions examples/sveltekit-email-password/package.json

This file was deleted.

17 changes: 0 additions & 17 deletions examples/sveltekit-email-password/src/app.d.ts

This file was deleted.

15 changes: 0 additions & 15 deletions examples/sveltekit-email-password/src/app.html

This file was deleted.

24 changes: 0 additions & 24 deletions examples/sveltekit-email-password/src/hooks.server.ts

This file was deleted.

50 changes: 0 additions & 50 deletions examples/sveltekit-email-password/src/routes/(app)/+page.server.ts

This file was deleted.

0 comments on commit 65bf8d4

Please sign in to comment.