@@ -15,11 +15,14 @@ import { SupabaseRealtimeChannel } from './lib/SupabaseRealtimeChannel'
15
15
import { Fetch , GenericSchema , SupabaseClientOptions , SupabaseAuthClientOptions } from './lib/types'
16
16
17
17
const DEFAULT_OPTIONS = {
18
- schema : 'public' ,
19
- autoRefreshToken : true ,
20
- persistSession : true ,
21
- detectSessionInUrl : true ,
22
- headers : DEFAULT_HEADERS ,
18
+ auth : {
19
+ autoRefreshToken : true ,
20
+ persistSession : true ,
21
+ detectSessionInUrl : true ,
22
+ } ,
23
+ general : {
24
+ schema : 'public' ,
25
+ } ,
23
26
}
24
27
25
28
/**
@@ -50,7 +53,6 @@ export default class SupabaseClient<
50
53
protected storageKey : string
51
54
protected fetch ?: Fetch
52
55
protected changedAccessToken : string | undefined
53
- protected shouldThrowOnError : boolean
54
56
55
57
protected headers : {
56
58
[ key : string ] : string
@@ -93,20 +95,23 @@ export default class SupabaseClient<
93
95
const defaultStorageKey = `sb-${ new URL ( this . authUrl ) . hostname . split ( '.' ) [ 0 ] } -auth-token`
94
96
this . storageKey = options ?. auth ?. storageKey ?? defaultStorageKey
95
97
96
- const settings = { ...DEFAULT_OPTIONS , ...options , storageKey : this . storageKey }
98
+ const settings = { ...DEFAULT_OPTIONS ?. general , ...options }
97
99
98
100
this . headers = { ...DEFAULT_HEADERS , ...options ?. headers }
99
- this . shouldThrowOnError = settings . shouldThrowOnError || false
100
101
101
- this . auth = this . _initSupabaseAuthClient ( settings . auth || { } , this . headers , settings . fetch )
102
+ this . auth = this . _initSupabaseAuthClient (
103
+ settings . auth || DEFAULT_OPTIONS . auth ,
104
+ this . headers ,
105
+ settings . fetch
106
+ )
102
107
this . fetch = fetchWithAuth ( supabaseKey , this . _getAccessToken . bind ( this ) , settings . fetch )
103
108
104
109
this . realtime = this . _initRealtimeClient ( { headers : this . headers , ...settings . realtime } )
105
110
this . rest = new PostgrestClient ( `${ _supabaseUrl } /rest/v1` , {
106
111
headers : this . headers ,
107
112
schema : options ?. db ?. schema ,
108
113
fetch : this . fetch ,
109
- throwOnError : this . shouldThrowOnError ,
114
+ throwOnError : options ?. db ?. shouldThrowOnError || false ,
110
115
} )
111
116
112
117
this . _listenForAuthEvents ( )
0 commit comments