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