mirror of
https://github.com/supabase/supabase.git
synced 2026-10-06 01:45:10 +03:00
* Remove the query for temp keys. Remove the query for supabase client. Add a function which creates a supabase client with a temp key. * Add a new query for building the endpoint URL. * Migrate all oAuth queries and mutations to use the new function for creating a Supabase project client. * Use the new queries/mutations in the code. * Use query in refetchInterval for useProjectSettings. * Replace all uses in StorageExplorer with createProjectSupabaseClient.
29 lines
793 B
TypeScript
29 lines
793 B
TypeScript
import { createClient } from '@supabase/supabase-js'
|
|
import { getOrRefreshTemporaryApiKey } from 'data/api-keys/temp-api-keys-utils'
|
|
|
|
/**
|
|
* Creates a Supabase client bound to a specific project. It uses temporary API key.
|
|
*/
|
|
export async function createProjectSupabaseClient(projectRef: string, clientEndpoint: string) {
|
|
try {
|
|
const { apiKey } = await getOrRefreshTemporaryApiKey(projectRef)
|
|
|
|
return createClient(clientEndpoint, apiKey, {
|
|
auth: {
|
|
persistSession: false,
|
|
autoRefreshToken: false,
|
|
detectSessionInUrl: false,
|
|
storage: {
|
|
getItem: (key) => {
|
|
return null
|
|
},
|
|
setItem: (key, value) => {},
|
|
removeItem: (key) => {},
|
|
},
|
|
},
|
|
})
|
|
} catch (error) {
|
|
throw error
|
|
}
|
|
}
|