project-briven-client.ts 796 B

1234567891011121314151617181920212223242526272829
  1. import { createClient } from '@supabase/supabase-js'
  2. import { getOrRefreshTemporaryApiKey } from '@/data/api-keys/temp-api-keys-utils'
  3. /**
  4. * Creates a Briven client bound to a specific project. It uses temporary API key.
  5. */
  6. export async function createProjectBrivenClient(projectRef: string, clientEndpoint: string) {
  7. try {
  8. const { apiKey } = await getOrRefreshTemporaryApiKey(projectRef)
  9. return createClient(clientEndpoint, apiKey, {
  10. auth: {
  11. persistSession: false,
  12. autoRefreshToken: false,
  13. detectSessionInUrl: false,
  14. storage: {
  15. getItem: (_key) => {
  16. return null
  17. },
  18. setItem: (_key, _value) => {},
  19. removeItem: (_key) => {},
  20. },
  21. },
  22. })
  23. } catch (error) {
  24. throw error
  25. }
  26. }