-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Supabase ssr #7544
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
Open
sreeisalso
wants to merge
6
commits into
QwikDev:main
Choose a base branch
from
sreeisalso:supabase-ssr
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Supabase ssr #7544
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
4257092
draft
sreeisalso 9935453
Merge remote-tracking branch 'upstream/main' into supabase-ssr
sreeisalso ad786be
working
sreeisalso ce80ac6
Merge remote-tracking branch 'upstream/main' into supabase-ssr
sreeisalso 2964741
removed comment
sreeisalso b8aa6f5
Merge remote-tracking branch 'upstream/main' into supabase-ssr
sreeisalso File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
// Methods | ||
export { createBrowserClient, createServerClient } from './utils/createSupabaseClient'; | ||
export { createBrowserClient } from './utils/createBrowserClient'; | ||
export { createServerClient } from './utils/createServerClient'; | ||
|
||
// Types | ||
export type { Session, User, SupabaseClient } from '@supabase/supabase-js'; |
49 changes: 49 additions & 0 deletions
49
packages/supabase-auth-helpers-qwik/src/utils/createBrowserClient.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
import type { SupabaseClient } from '@supabase/supabase-js'; | ||
import { | ||
createBrowserClient as browserClient, | ||
type CookieMethodsBrowser, | ||
type CookieOptionsWithName, | ||
} from '@supabase/ssr'; | ||
import type { | ||
GenericSchema, | ||
SupabaseClientOptions, | ||
} from '@supabase/supabase-js/dist/module/lib/types'; | ||
|
||
export function createBrowserClient< | ||
Database = any, | ||
SchemaName extends string & keyof Database = 'public' extends keyof Database | ||
? 'public' | ||
: string & keyof Database, | ||
Schema extends GenericSchema = Database[SchemaName] extends GenericSchema | ||
? Database[SchemaName] | ||
: any, | ||
>( | ||
supabaseUrl: string, | ||
supabaseKey: string, | ||
options?: SupabaseClientOptions<SchemaName> & { | ||
cookies?: CookieMethodsBrowser; | ||
cookieOptions?: CookieOptionsWithName; | ||
cookieEncoding?: 'raw' | 'base64url'; | ||
isSingleton?: boolean; | ||
} | ||
): SupabaseClient<Database, SchemaName, Schema> { | ||
if (!supabaseUrl || !supabaseKey) { | ||
throw new Error( | ||
'supabaseUrl and supabaseKey are required to create a Supabase client! Find these under `Settings` > `API` in your Supabase dashboard.' | ||
); | ||
} | ||
|
||
return browserClient<Database, SchemaName, Schema>(supabaseUrl, supabaseKey, { | ||
...options, | ||
global: { | ||
...options?.global, | ||
headers: { | ||
...options?.global?.headers, | ||
'X-Client-Info': '[email protected]', | ||
}, | ||
}, | ||
auth: { | ||
storageKey: options?.cookieOptions?.name, | ||
}, | ||
}); | ||
} |
61 changes: 61 additions & 0 deletions
61
packages/supabase-auth-helpers-qwik/src/utils/createServerClient.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
import type { SupabaseClient } from '@supabase/supabase-js'; | ||
import { createServerClient as serverClint } from '@supabase/ssr'; | ||
import type { CookieMethodsBrowser, CookieOptionsWithName } from '@supabase/ssr'; | ||
import type { | ||
GenericSchema, | ||
SupabaseClientOptions, | ||
} from '@supabase/supabase-js/dist/module/lib/types'; | ||
import type { RequestEventBase } from 'packages/qwik-city/lib'; | ||
|
||
export function createServerClient< | ||
Database = any, | ||
SchemaName extends string & keyof Database = 'public' extends keyof Database | ||
? 'public' | ||
: string & keyof Database, | ||
Schema extends GenericSchema = Database[SchemaName] extends GenericSchema | ||
? Database[SchemaName] | ||
: any, | ||
>( | ||
supabaseUrl: string, | ||
supabaseKey: string, | ||
requestEv: RequestEventBase, | ||
options?: SupabaseClientOptions<SchemaName> & { | ||
cookies?: CookieMethodsBrowser; | ||
cookieOptions?: CookieOptionsWithName; | ||
cookieEncoding?: 'raw' | 'base64url'; | ||
isSingleton?: boolean; | ||
} | ||
): SupabaseClient<Database, SchemaName, Schema> { | ||
if (!supabaseUrl || !supabaseKey) { | ||
throw new Error( | ||
'supabaseUrl and supabaseKey are required to create a Supabase client! Find these under `Settings` > `API` in your Supabase dashboard.' | ||
); | ||
} | ||
|
||
return serverClint<Database, SchemaName, Schema>(supabaseUrl, supabaseKey, { | ||
...options, | ||
global: { | ||
...options?.global, | ||
headers: { | ||
...options?.global?.headers, | ||
'X-Client-Info': '[email protected]', | ||
}, | ||
}, | ||
auth: { | ||
storageKey: options?.cookieOptions?.name, | ||
}, | ||
cookies: { | ||
getAll: () => { | ||
const cookies = requestEv.cookie.getAll(); | ||
return Object.keys(cookies).map((name) => { | ||
return { name, value: cookies[name].value }; | ||
}); | ||
}, | ||
setAll: (cookies) => { | ||
cookies.map((cookie) => { | ||
requestEv.cookie.set(cookie.name, cookie.value, cookie.options); | ||
}); | ||
}, | ||
}, | ||
}); | ||
} |
157 changes: 0 additions & 157 deletions
157
packages/supabase-auth-helpers-qwik/src/utils/createSupabaseClient.ts
This file was deleted.
Oops, something went wrong.
37 changes: 0 additions & 37 deletions
37
packages/supabase-auth-helpers-qwik/src/utils/storageAdapter.ts
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
why the rename and isn't that a typo?
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.
We are also exporting the same helper function