@supabase/supabase-js 1.36.0-next.9 → 2.0.0-rc.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/main/SupabaseClient.d.ts +24 -35
- package/dist/main/SupabaseClient.d.ts.map +1 -1
- package/dist/main/SupabaseClient.js +58 -129
- package/dist/main/SupabaseClient.js.map +1 -1
- package/dist/main/index.d.ts +2 -1
- package/dist/main/index.d.ts.map +1 -1
- package/dist/main/index.js +6 -1
- package/dist/main/index.js.map +1 -1
- package/dist/main/lib/constants.d.ts +0 -1
- package/dist/main/lib/constants.d.ts.map +1 -1
- package/dist/main/lib/constants.js +1 -2
- package/dist/main/lib/constants.js.map +1 -1
- package/dist/main/lib/helpers.d.ts +2 -0
- package/dist/main/lib/helpers.d.ts.map +1 -1
- package/dist/main/lib/helpers.js +12 -2
- package/dist/main/lib/helpers.js.map +1 -1
- package/dist/main/lib/types.d.ts +15 -32
- package/dist/main/lib/types.d.ts.map +1 -1
- package/dist/main/lib/version.d.ts +1 -1
- package/dist/main/lib/version.js +1 -1
- package/dist/module/SupabaseClient.d.ts +24 -35
- package/dist/module/SupabaseClient.d.ts.map +1 -1
- package/dist/module/SupabaseClient.js +60 -131
- package/dist/module/SupabaseClient.js.map +1 -1
- package/dist/module/index.d.ts +2 -1
- package/dist/module/index.d.ts.map +1 -1
- package/dist/module/index.js +1 -0
- package/dist/module/index.js.map +1 -1
- package/dist/module/lib/constants.d.ts +0 -1
- package/dist/module/lib/constants.d.ts.map +1 -1
- package/dist/module/lib/constants.js +0 -1
- package/dist/module/lib/constants.js.map +1 -1
- package/dist/module/lib/helpers.d.ts +2 -0
- package/dist/module/lib/helpers.d.ts.map +1 -1
- package/dist/module/lib/helpers.js +10 -1
- package/dist/module/lib/helpers.js.map +1 -1
- package/dist/module/lib/types.d.ts +15 -32
- package/dist/module/lib/types.d.ts.map +1 -1
- package/dist/module/lib/version.d.ts +1 -1
- package/dist/module/lib/version.js +1 -1
- package/dist/umd/supabase.js +1 -1
- package/package.json +7 -7
- package/src/SupabaseClient.ts +73 -136
- package/src/index.ts +7 -1
- package/src/lib/constants.ts +0 -1
- package/src/lib/helpers.ts +43 -0
- package/src/lib/types.ts +15 -33
- package/src/lib/version.ts +1 -1
- package/dist/main/lib/SupabaseRealtimeClient.d.ts +0 -22
- package/dist/main/lib/SupabaseRealtimeClient.d.ts.map +0 -1
- package/dist/main/lib/SupabaseRealtimeClient.js +0 -79
- package/dist/main/lib/SupabaseRealtimeClient.js.map +0 -1
- package/dist/module/lib/SupabaseRealtimeClient.d.ts +0 -22
- package/dist/module/lib/SupabaseRealtimeClient.d.ts.map +0 -1
- package/dist/module/lib/SupabaseRealtimeClient.js +0 -75
- package/dist/module/lib/SupabaseRealtimeClient.js.map +0 -1
- package/src/lib/SupabaseRealtimeClient.ts +0 -91
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
import { FunctionsClient } from '@supabase/functions-js';
|
|
2
2
|
import { PostgrestClient, PostgrestFilterBuilder, PostgrestQueryBuilder } from '@supabase/postgrest-js';
|
|
3
3
|
import { RealtimeChannel, RealtimeClient } from '@supabase/realtime-js';
|
|
4
|
-
import { SupabaseStorageClient } from '@supabase/storage-js';
|
|
4
|
+
import { StorageClient as SupabaseStorageClient } from '@supabase/storage-js';
|
|
5
5
|
import { SupabaseAuthClient } from './lib/SupabaseAuthClient';
|
|
6
|
-
import { SupabaseRealtimeClient } from './lib/SupabaseRealtimeClient';
|
|
7
6
|
import { Fetch, GenericSchema, SupabaseClientOptions } from './lib/types';
|
|
8
7
|
/**
|
|
9
8
|
* Supabase Client.
|
|
@@ -23,10 +22,9 @@ export default class SupabaseClient<Database = any, SchemaName extends string &
|
|
|
23
22
|
protected functionsUrl: string;
|
|
24
23
|
protected realtime: RealtimeClient;
|
|
25
24
|
protected rest: PostgrestClient<Database, SchemaName>;
|
|
26
|
-
protected
|
|
25
|
+
protected storageKey: string;
|
|
27
26
|
protected fetch?: Fetch;
|
|
28
27
|
protected changedAccessToken: string | undefined;
|
|
29
|
-
protected shouldThrowOnError: boolean;
|
|
30
28
|
protected headers: {
|
|
31
29
|
[key: string]: string;
|
|
32
30
|
};
|
|
@@ -34,14 +32,13 @@ export default class SupabaseClient<Database = any, SchemaName extends string &
|
|
|
34
32
|
* Create a new client for use in the browser.
|
|
35
33
|
* @param supabaseUrl The unique Supabase URL which is supplied when you create a new project in your project dashboard.
|
|
36
34
|
* @param supabaseKey The unique Supabase Key which is supplied when you create a new project in your project dashboard.
|
|
37
|
-
* @param options.schema You can switch in between schemas. The schema needs to be on the list of exposed schemas inside Supabase.
|
|
38
|
-
* @param options.autoRefreshToken Set to "true" if you want to automatically refresh the token before expiring.
|
|
39
|
-
* @param options.persistSession Set to "true" if you want to automatically save the user session into local storage.
|
|
40
|
-
* @param options.detectSessionInUrl Set to "true" if you want to automatically detects OAuth grants in the URL and signs in the user.
|
|
41
|
-
* @param options.headers Any additional headers to send with each network request.
|
|
35
|
+
* @param options.db.schema You can switch in between schemas. The schema needs to be on the list of exposed schemas inside Supabase.
|
|
36
|
+
* @param options.auth.autoRefreshToken Set to "true" if you want to automatically refresh the token before expiring.
|
|
37
|
+
* @param options.auth.persistSession Set to "true" if you want to automatically save the user session into local storage.
|
|
38
|
+
* @param options.auth.detectSessionInUrl Set to "true" if you want to automatically detects OAuth grants in the URL and signs in the user.
|
|
42
39
|
* @param options.realtime Options passed along to realtime-js constructor.
|
|
43
|
-
* @param options.
|
|
44
|
-
* @param options.
|
|
40
|
+
* @param options.global.fetch A custom fetch implementation.
|
|
41
|
+
* @param options.global.headers Any additional headers to send with each network request.
|
|
45
42
|
*/
|
|
46
43
|
constructor(supabaseUrl: string, supabaseKey: string, options?: SupabaseClientOptions<SchemaName>);
|
|
47
44
|
/**
|
|
@@ -58,6 +55,7 @@ export default class SupabaseClient<Database = any, SchemaName extends string &
|
|
|
58
55
|
* @param table The table name to operate on.
|
|
59
56
|
*/
|
|
60
57
|
from<TableName extends string & keyof Schema['Tables'], Table extends Schema['Tables'][TableName]>(table: TableName): PostgrestQueryBuilder<Table>;
|
|
58
|
+
from(table: string): PostgrestQueryBuilder<any>;
|
|
61
59
|
/**
|
|
62
60
|
* Perform a function call.
|
|
63
61
|
*
|
|
@@ -72,42 +70,33 @@ export default class SupabaseClient<Database = any, SchemaName extends string &
|
|
|
72
70
|
count?: 'exact' | 'planned' | 'estimated';
|
|
73
71
|
}): PostgrestFilterBuilder<Function_['Returns'] extends any[] ? Function_['Returns'][number] extends Record<string, unknown> ? Function_['Returns'][number] : never : never, Function_['Returns']>;
|
|
74
72
|
/**
|
|
75
|
-
* Creates a channel with Broadcast and
|
|
73
|
+
* Creates a Realtime channel with Broadcast, Presence, and Postgres Changes.
|
|
74
|
+
*
|
|
75
|
+
* @param {string} name - The name of the Realtime channel.
|
|
76
|
+
* @param {Object} opts - The options to pass to the Realtime channel.
|
|
77
|
+
*
|
|
76
78
|
*/
|
|
77
79
|
channel(name: string, opts?: {
|
|
78
80
|
[key: string]: any;
|
|
79
|
-
}):
|
|
81
|
+
}): RealtimeChannel;
|
|
80
82
|
/**
|
|
81
|
-
*
|
|
82
|
-
* channels and their errors.
|
|
83
|
+
* Returns all Realtime channels.
|
|
83
84
|
*/
|
|
84
|
-
|
|
85
|
-
data: {
|
|
86
|
-
channels: RealtimeChannel;
|
|
87
|
-
};
|
|
88
|
-
error: Error | null;
|
|
89
|
-
}[]>;
|
|
85
|
+
getChannels(): RealtimeChannel[];
|
|
90
86
|
/**
|
|
91
|
-
*
|
|
87
|
+
* Unsubscribes and removes Realtime channel from Realtime client.
|
|
88
|
+
*
|
|
89
|
+
* @param {RealtimeChannel} channel - The name of the Realtime channel.
|
|
92
90
|
*
|
|
93
|
-
* @param channel The channel you want to close and remove.
|
|
94
91
|
*/
|
|
95
|
-
removeChannel(channel: RealtimeChannel): Promise<
|
|
96
|
-
data: {
|
|
97
|
-
openChannels: number;
|
|
98
|
-
};
|
|
99
|
-
error: Error | null;
|
|
100
|
-
}>;
|
|
101
|
-
private _getAccessToken;
|
|
102
|
-
private _closeChannel;
|
|
103
|
-
private _unsubscribeChannel;
|
|
92
|
+
removeChannel(channel: RealtimeChannel): Promise<'ok' | 'timed out' | 'error'>;
|
|
104
93
|
/**
|
|
105
|
-
*
|
|
94
|
+
* Unsubscribes and removes all Realtime channels from Realtime client.
|
|
106
95
|
*/
|
|
107
|
-
|
|
96
|
+
removeAllChannels(): Promise<('ok' | 'timed out' | 'error')[]>;
|
|
97
|
+
private _getAccessToken;
|
|
108
98
|
private _initSupabaseAuthClient;
|
|
109
99
|
private _initRealtimeClient;
|
|
110
|
-
private _listenForMultiTabEvents;
|
|
111
100
|
private _listenForAuthEvents;
|
|
112
101
|
private _handleTokenChanged;
|
|
113
102
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SupabaseClient.d.ts","sourceRoot":"","sources":["../../src/SupabaseClient.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAA;AAExD,OAAO,EACL,eAAe,EACf,sBAAsB,EACtB,qBAAqB,EACtB,MAAM,wBAAwB,CAAA;AAC/B,OAAO,EAAE,eAAe,EAAE,cAAc,EAAyB,MAAM,uBAAuB,CAAA;AAC9F,OAAO,EAAE,qBAAqB,EAAE,MAAM,sBAAsB,CAAA;
|
|
1
|
+
{"version":3,"file":"SupabaseClient.d.ts","sourceRoot":"","sources":["../../src/SupabaseClient.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAA;AAExD,OAAO,EACL,eAAe,EACf,sBAAsB,EACtB,qBAAqB,EACtB,MAAM,wBAAwB,CAAA;AAC/B,OAAO,EAAE,eAAe,EAAE,cAAc,EAAyB,MAAM,uBAAuB,CAAA;AAC9F,OAAO,EAAE,aAAa,IAAI,qBAAqB,EAAE,MAAM,sBAAsB,CAAA;AAI7E,OAAO,EAAE,kBAAkB,EAAE,MAAM,0BAA0B,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AAG,WAAW,GAAG,OAAO,CAAC,EAAE,CAAC;YAIhD,eAAe;IAM7B,OAAO,CAAC,uBAAuB;IA2B/B,OAAO,CAAC,mBAAmB;IAO3B,OAAO,CAAC,oBAAoB;IAO5B,OAAO,CAAC,mBAAmB;CAmB5B"}
|
|
@@ -17,15 +17,18 @@ const constants_1 = require("./lib/constants");
|
|
|
17
17
|
const fetch_1 = require("./lib/fetch");
|
|
18
18
|
const helpers_1 = require("./lib/helpers");
|
|
19
19
|
const SupabaseAuthClient_1 = require("./lib/SupabaseAuthClient");
|
|
20
|
-
const
|
|
21
|
-
|
|
20
|
+
const DEFAULT_GLOBAL_OPTIONS = {
|
|
21
|
+
headers: constants_1.DEFAULT_HEADERS,
|
|
22
|
+
};
|
|
23
|
+
const DEFAULT_DB_OPTIONS = {
|
|
22
24
|
schema: 'public',
|
|
25
|
+
};
|
|
26
|
+
const DEFAULT_AUTH_OPTIONS = {
|
|
23
27
|
autoRefreshToken: true,
|
|
24
28
|
persistSession: true,
|
|
25
29
|
detectSessionInUrl: true,
|
|
26
|
-
multiTab: true,
|
|
27
|
-
headers: constants_1.DEFAULT_HEADERS,
|
|
28
30
|
};
|
|
31
|
+
const DEFAULT_REALTIME_OPTIONS = {};
|
|
29
32
|
/**
|
|
30
33
|
* Supabase Client.
|
|
31
34
|
*
|
|
@@ -36,17 +39,16 @@ class SupabaseClient {
|
|
|
36
39
|
* Create a new client for use in the browser.
|
|
37
40
|
* @param supabaseUrl The unique Supabase URL which is supplied when you create a new project in your project dashboard.
|
|
38
41
|
* @param supabaseKey The unique Supabase Key which is supplied when you create a new project in your project dashboard.
|
|
39
|
-
* @param options.schema You can switch in between schemas. The schema needs to be on the list of exposed schemas inside Supabase.
|
|
40
|
-
* @param options.autoRefreshToken Set to "true" if you want to automatically refresh the token before expiring.
|
|
41
|
-
* @param options.persistSession Set to "true" if you want to automatically save the user session into local storage.
|
|
42
|
-
* @param options.detectSessionInUrl Set to "true" if you want to automatically detects OAuth grants in the URL and signs in the user.
|
|
43
|
-
* @param options.headers Any additional headers to send with each network request.
|
|
42
|
+
* @param options.db.schema You can switch in between schemas. The schema needs to be on the list of exposed schemas inside Supabase.
|
|
43
|
+
* @param options.auth.autoRefreshToken Set to "true" if you want to automatically refresh the token before expiring.
|
|
44
|
+
* @param options.auth.persistSession Set to "true" if you want to automatically save the user session into local storage.
|
|
45
|
+
* @param options.auth.detectSessionInUrl Set to "true" if you want to automatically detects OAuth grants in the URL and signs in the user.
|
|
44
46
|
* @param options.realtime Options passed along to realtime-js constructor.
|
|
45
|
-
* @param options.
|
|
46
|
-
* @param options.
|
|
47
|
+
* @param options.global.fetch A custom fetch implementation.
|
|
48
|
+
* @param options.global.headers Any additional headers to send with each network request.
|
|
47
49
|
*/
|
|
48
50
|
constructor(supabaseUrl, supabaseKey, options) {
|
|
49
|
-
var _a, _b, _c;
|
|
51
|
+
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
50
52
|
this.supabaseUrl = supabaseUrl;
|
|
51
53
|
this.supabaseKey = supabaseKey;
|
|
52
54
|
if (!supabaseUrl)
|
|
@@ -54,7 +56,6 @@ class SupabaseClient {
|
|
|
54
56
|
if (!supabaseKey)
|
|
55
57
|
throw new Error('supabaseKey is required.');
|
|
56
58
|
const _supabaseUrl = (0, helpers_1.stripTrailingSlash)(supabaseUrl);
|
|
57
|
-
const settings = Object.assign(Object.assign({}, DEFAULT_OPTIONS), options);
|
|
58
59
|
this.realtimeUrl = `${_supabaseUrl}/realtime/v1`.replace('http', 'ws');
|
|
59
60
|
this.authUrl = `${_supabaseUrl}/auth/v1`;
|
|
60
61
|
this.storageUrl = `${_supabaseUrl}/storage/v1`;
|
|
@@ -66,24 +67,26 @@ class SupabaseClient {
|
|
|
66
67
|
else {
|
|
67
68
|
this.functionsUrl = `${_supabaseUrl}/functions/v1`;
|
|
68
69
|
}
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
70
|
+
// default storage key uses the supabase project ref as a namespace
|
|
71
|
+
const defaultStorageKey = `sb-${new URL(this.authUrl).hostname.split('.')[0]}-auth-token`;
|
|
72
|
+
const DEFAULTS = {
|
|
73
|
+
db: DEFAULT_DB_OPTIONS,
|
|
74
|
+
realtime: DEFAULT_REALTIME_OPTIONS,
|
|
75
|
+
auth: Object.assign(Object.assign({}, DEFAULT_AUTH_OPTIONS), { storageKey: defaultStorageKey }),
|
|
76
|
+
global: DEFAULT_GLOBAL_OPTIONS,
|
|
77
|
+
};
|
|
78
|
+
const settings = (0, helpers_1.applySettingDefaults)(options !== null && options !== void 0 ? options : {}, DEFAULTS);
|
|
79
|
+
this.storageKey = (_b = (_a = settings.auth) === null || _a === void 0 ? void 0 : _a.storageKey) !== null && _b !== void 0 ? _b : '';
|
|
80
|
+
this.headers = (_d = (_c = settings.global) === null || _c === void 0 ? void 0 : _c.headers) !== null && _d !== void 0 ? _d : {};
|
|
81
|
+
this.auth = this._initSupabaseAuthClient((_e = settings.auth) !== null && _e !== void 0 ? _e : {}, this.headers, (_f = settings.global) === null || _f === void 0 ? void 0 : _f.fetch);
|
|
82
|
+
this.fetch = (0, fetch_1.fetchWithAuth)(supabaseKey, this._getAccessToken.bind(this), (_g = settings.global) === null || _g === void 0 ? void 0 : _g.fetch);
|
|
74
83
|
this.realtime = this._initRealtimeClient(Object.assign({ headers: this.headers }, settings.realtime));
|
|
75
84
|
this.rest = new postgrest_js_1.PostgrestClient(`${_supabaseUrl}/rest/v1`, {
|
|
76
85
|
headers: this.headers,
|
|
77
|
-
schema: (
|
|
86
|
+
schema: (_h = settings.db) === null || _h === void 0 ? void 0 : _h.schema,
|
|
78
87
|
fetch: this.fetch,
|
|
79
|
-
throwOnError: this.shouldThrowOnError,
|
|
80
88
|
});
|
|
81
89
|
this._listenForAuthEvents();
|
|
82
|
-
this._listenForMultiTabEvents();
|
|
83
|
-
// In the future we might allow the user to pass in a logger to receive these events.
|
|
84
|
-
// this.realtime.onOpen(() => console.log('OPEN'))
|
|
85
|
-
// this.realtime.onClose(() => console.log('CLOSED'))
|
|
86
|
-
// this.realtime.onError((e: Error) => console.log('Socket error', e))
|
|
87
90
|
}
|
|
88
91
|
/**
|
|
89
92
|
* Supabase Functions allows you to deploy and invoke edge functions.
|
|
@@ -98,13 +101,8 @@ class SupabaseClient {
|
|
|
98
101
|
* Supabase Storage allows you to manage user-generated content, such as photos or videos.
|
|
99
102
|
*/
|
|
100
103
|
get storage() {
|
|
101
|
-
return new storage_js_1.
|
|
104
|
+
return new storage_js_1.StorageClient(this.storageUrl, this.headers, this.fetch);
|
|
102
105
|
}
|
|
103
|
-
/**
|
|
104
|
-
* Perform a table operation.
|
|
105
|
-
*
|
|
106
|
-
* @param table The table name to operate on.
|
|
107
|
-
*/
|
|
108
106
|
from(table) {
|
|
109
107
|
return this.rest.from(table);
|
|
110
108
|
}
|
|
@@ -121,80 +119,44 @@ class SupabaseClient {
|
|
|
121
119
|
return this.rest.rpc(fn, args, options);
|
|
122
120
|
}
|
|
123
121
|
/**
|
|
124
|
-
* Creates a channel with Broadcast and
|
|
122
|
+
* Creates a Realtime channel with Broadcast, Presence, and Postgres Changes.
|
|
123
|
+
*
|
|
124
|
+
* @param {string} name - The name of the Realtime channel.
|
|
125
|
+
* @param {Object} opts - The options to pass to the Realtime channel.
|
|
126
|
+
*
|
|
125
127
|
*/
|
|
126
|
-
channel(name, opts) {
|
|
127
|
-
|
|
128
|
-
this.realtime.connect();
|
|
129
|
-
}
|
|
130
|
-
return new SupabaseRealtimeClient_1.SupabaseRealtimeClient(this.realtime, name, opts);
|
|
128
|
+
channel(name, opts = {}) {
|
|
129
|
+
return this.realtime.channel(name, opts);
|
|
131
130
|
}
|
|
132
131
|
/**
|
|
133
|
-
*
|
|
134
|
-
* channels and their errors.
|
|
132
|
+
* Returns all Realtime channels.
|
|
135
133
|
*/
|
|
136
|
-
|
|
137
|
-
return
|
|
138
|
-
const allChans = this.getChannels().slice();
|
|
139
|
-
const allChanPromises = allChans.map((chan) => this.removeChannel(chan));
|
|
140
|
-
const allRemovedChans = yield Promise.all(allChanPromises);
|
|
141
|
-
return allRemovedChans.map(({ error }, i) => {
|
|
142
|
-
return {
|
|
143
|
-
data: { channels: allChans[i] },
|
|
144
|
-
error,
|
|
145
|
-
};
|
|
146
|
-
});
|
|
147
|
-
});
|
|
134
|
+
getChannels() {
|
|
135
|
+
return this.realtime.getChannels();
|
|
148
136
|
}
|
|
149
137
|
/**
|
|
150
|
-
*
|
|
138
|
+
* Unsubscribes and removes Realtime channel from Realtime client.
|
|
139
|
+
*
|
|
140
|
+
* @param {RealtimeChannel} channel - The name of the Realtime channel.
|
|
151
141
|
*
|
|
152
|
-
* @param channel The channel you want to close and remove.
|
|
153
142
|
*/
|
|
154
143
|
removeChannel(channel) {
|
|
155
|
-
return
|
|
156
|
-
const { error } = yield this._closeChannel(channel);
|
|
157
|
-
const allChans = this.getChannels();
|
|
158
|
-
const openChanCount = allChans.filter((chan) => chan.isJoined()).length;
|
|
159
|
-
if (allChans.length === 0)
|
|
160
|
-
yield this.realtime.disconnect();
|
|
161
|
-
return { data: { openChannels: openChanCount }, error };
|
|
162
|
-
});
|
|
144
|
+
return this.realtime.removeChannel(channel);
|
|
163
145
|
}
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
});
|
|
146
|
+
/**
|
|
147
|
+
* Unsubscribes and removes all Realtime channels from Realtime client.
|
|
148
|
+
*/
|
|
149
|
+
removeAllChannels() {
|
|
150
|
+
return this.realtime.removeAllChannels();
|
|
170
151
|
}
|
|
171
|
-
|
|
152
|
+
_getAccessToken() {
|
|
153
|
+
var _a, _b;
|
|
172
154
|
return __awaiter(this, void 0, void 0, function* () {
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
const { error: unsubError } = yield this._unsubscribeChannel(channel);
|
|
176
|
-
error = unsubError;
|
|
177
|
-
}
|
|
178
|
-
this.realtime.remove(channel);
|
|
179
|
-
return { error };
|
|
180
|
-
});
|
|
181
|
-
}
|
|
182
|
-
_unsubscribeChannel(channel) {
|
|
183
|
-
return new Promise((resolve) => {
|
|
184
|
-
channel
|
|
185
|
-
.unsubscribe()
|
|
186
|
-
.receive('ok', () => resolve({ error: null }))
|
|
187
|
-
.receive('error', (error) => resolve({ error }))
|
|
188
|
-
.receive('timeout', () => resolve({ error: new Error('timed out') }));
|
|
155
|
+
const { data } = yield this.auth.getSession();
|
|
156
|
+
return (_b = (_a = data.session) === null || _a === void 0 ? void 0 : _a.access_token) !== null && _b !== void 0 ? _b : null;
|
|
189
157
|
});
|
|
190
158
|
}
|
|
191
|
-
|
|
192
|
-
* Returns an array of all your channels.
|
|
193
|
-
*/
|
|
194
|
-
getChannels() {
|
|
195
|
-
return this.realtime.channels;
|
|
196
|
-
}
|
|
197
|
-
_initSupabaseAuthClient({ autoRefreshToken, persistSession, detectSessionInUrl, localStorage, cookieOptions, multiTab, }, headers, fetch) {
|
|
159
|
+
_initSupabaseAuthClient({ autoRefreshToken, persistSession, detectSessionInUrl, storage, storageKey, }, headers, fetch) {
|
|
198
160
|
const authHeaders = {
|
|
199
161
|
Authorization: `Bearer ${this.supabaseKey}`,
|
|
200
162
|
apikey: `${this.supabaseKey}`,
|
|
@@ -202,48 +164,19 @@ class SupabaseClient {
|
|
|
202
164
|
return new SupabaseAuthClient_1.SupabaseAuthClient({
|
|
203
165
|
url: this.authUrl,
|
|
204
166
|
headers: Object.assign(Object.assign({}, headers), authHeaders),
|
|
167
|
+
storageKey: storageKey,
|
|
205
168
|
autoRefreshToken,
|
|
206
169
|
persistSession,
|
|
207
170
|
detectSessionInUrl,
|
|
208
|
-
|
|
171
|
+
storage,
|
|
209
172
|
fetch,
|
|
210
|
-
cookieOptions,
|
|
211
|
-
multiTab,
|
|
212
173
|
});
|
|
213
174
|
}
|
|
214
175
|
_initRealtimeClient(options) {
|
|
215
|
-
return new realtime_js_1.RealtimeClient(this.realtimeUrl, Object.assign(Object.assign({}, options), { params: Object.assign({ apikey: this.supabaseKey
|
|
216
|
-
}
|
|
217
|
-
_listenForMultiTabEvents() {
|
|
218
|
-
if (!this.multiTab || !(0, helpers_1.isBrowser)() || !(window === null || window === void 0 ? void 0 : window.addEventListener)) {
|
|
219
|
-
return null;
|
|
220
|
-
}
|
|
221
|
-
try {
|
|
222
|
-
return window === null || window === void 0 ? void 0 : window.addEventListener('storage', (e) => {
|
|
223
|
-
var _a, _b, _c;
|
|
224
|
-
if (e.key === constants_1.STORAGE_KEY) {
|
|
225
|
-
const newSession = JSON.parse(String(e.newValue));
|
|
226
|
-
const accessToken = (_b = (_a = newSession === null || newSession === void 0 ? void 0 : newSession.currentSession) === null || _a === void 0 ? void 0 : _a.access_token) !== null && _b !== void 0 ? _b : undefined;
|
|
227
|
-
const previousAccessToken = (_c = this.auth.session()) === null || _c === void 0 ? void 0 : _c.access_token;
|
|
228
|
-
if (!accessToken) {
|
|
229
|
-
this._handleTokenChanged('SIGNED_OUT', accessToken, 'STORAGE');
|
|
230
|
-
}
|
|
231
|
-
else if (!previousAccessToken && accessToken) {
|
|
232
|
-
this._handleTokenChanged('SIGNED_IN', accessToken, 'STORAGE');
|
|
233
|
-
}
|
|
234
|
-
else if (previousAccessToken !== accessToken) {
|
|
235
|
-
this._handleTokenChanged('TOKEN_REFRESHED', accessToken, 'STORAGE');
|
|
236
|
-
}
|
|
237
|
-
}
|
|
238
|
-
});
|
|
239
|
-
}
|
|
240
|
-
catch (error) {
|
|
241
|
-
console.error('_listenForMultiTabEvents', error);
|
|
242
|
-
return null;
|
|
243
|
-
}
|
|
176
|
+
return new realtime_js_1.RealtimeClient(this.realtimeUrl, Object.assign(Object.assign({}, options), { params: Object.assign({ apikey: this.supabaseKey }, options === null || options === void 0 ? void 0 : options.params) }));
|
|
244
177
|
}
|
|
245
178
|
_listenForAuthEvents() {
|
|
246
|
-
let
|
|
179
|
+
let data = this.auth.onAuthStateChange((event, session) => {
|
|
247
180
|
this._handleTokenChanged(event, session === null || session === void 0 ? void 0 : session.access_token, 'CLIENT');
|
|
248
181
|
});
|
|
249
182
|
return data;
|
|
@@ -252,11 +185,7 @@ class SupabaseClient {
|
|
|
252
185
|
if ((event === 'TOKEN_REFRESHED' || event === 'SIGNED_IN') &&
|
|
253
186
|
this.changedAccessToken !== token) {
|
|
254
187
|
// Token has changed
|
|
255
|
-
this.realtime.setAuth(token);
|
|
256
|
-
// Ideally we should call this.auth.recoverSession() - need to make public
|
|
257
|
-
// to trigger a "SIGNED_IN" event on this client.
|
|
258
|
-
if (source == 'STORAGE')
|
|
259
|
-
this.auth.setAuth(token);
|
|
188
|
+
this.realtime.setAuth(token !== null && token !== void 0 ? token : null);
|
|
260
189
|
this.changedAccessToken = token;
|
|
261
190
|
}
|
|
262
191
|
else if (event === 'SIGNED_OUT' || event === 'USER_DELETED') {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SupabaseClient.js","sourceRoot":"","sources":["../../src/SupabaseClient.ts"],"names":[],"mappings":";;;;;;;;;;;AAAA,yDAAwD;AAExD,yDAI+B;AAC/B,uDAA8F;AAC9F,
|
|
1
|
+
{"version":3,"file":"SupabaseClient.js","sourceRoot":"","sources":["../../src/SupabaseClient.ts"],"names":[],"mappings":";;;;;;;;;;;AAAA,yDAAwD;AAExD,yDAI+B;AAC/B,uDAA8F;AAC9F,qDAA6E;AAC7E,+CAAiD;AACjD,uCAA2C;AAC3C,2CAAwE;AACxE,iEAA6D;AAG7D,MAAM,sBAAsB,GAAG;IAC7B,OAAO,EAAE,2BAAe;CACzB,CAAA;AAED,MAAM,kBAAkB,GAAG;IACzB,MAAM,EAAE,QAAQ;CACjB,CAAA;AAED,MAAM,oBAAoB,GAA8B;IACtD,gBAAgB,EAAE,IAAI;IACtB,cAAc,EAAE,IAAI;IACpB,kBAAkB,EAAE,IAAI;CACzB,CAAA;AAED,MAAM,wBAAwB,GAA0B,EAAE,CAAA;AAE1D;;;;GAIG;AACH,MAAqB,cAAc;IA4BjC;;;;;;;;;;;OAWG;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BAAmB;YACnB,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,IAAI,CAAC,WAAW,CAAC,CAAA;YACvC,IAAI,MAAM,IAAI,SAAS;gBAAE,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE,CAAA;SAC7C;IACH,CAAC;CACF;AA9PD,iCA8PC"}
|
package/dist/main/index.d.ts
CHANGED
|
@@ -3,9 +3,10 @@ import type { GenericSchema, SupabaseClientOptions } from './lib/types';
|
|
|
3
3
|
export * from '@supabase/gotrue-js';
|
|
4
4
|
export type { User as AuthUser, Session as AuthSession } from '@supabase/gotrue-js';
|
|
5
5
|
export type { PostgrestResponse, PostgrestSingleResponse, PostgrestMaybeSingleResponse, PostgrestError, } from '@supabase/postgrest-js';
|
|
6
|
+
export { FunctionsHttpError, FunctionsFetchError, FunctionsRelayError, FunctionsError, } from '@supabase/functions-js';
|
|
6
7
|
export * from '@supabase/realtime-js';
|
|
7
8
|
export { default as SupabaseClient } from './SupabaseClient';
|
|
8
|
-
export type { SupabaseClientOptions
|
|
9
|
+
export type { SupabaseClientOptions } from './lib/types';
|
|
9
10
|
/**
|
|
10
11
|
* Creates a new Supabase Client.
|
|
11
12
|
*/
|
package/dist/main/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,cAAc,MAAM,kBAAkB,CAAA;AAC7C,OAAO,KAAK,EAAE,aAAa,EAAE,qBAAqB,EAAE,MAAM,aAAa,CAAA;AAEvE,cAAc,qBAAqB,CAAA;AACnC,YAAY,EAAE,IAAI,IAAI,QAAQ,EAAE,OAAO,IAAI,WAAW,EAAE,MAAM,qBAAqB,CAAA;AACnF,YAAY,EACV,iBAAiB,EACjB,uBAAuB,EACvB,4BAA4B,EAC5B,cAAc,GACf,MAAM,wBAAwB,CAAA;AAC/B,cAAc,uBAAuB,CAAA;AACrC,OAAO,EAAE,OAAO,IAAI,cAAc,EAAE,MAAM,kBAAkB,CAAA;AAC5D,YAAY,EAAE,qBAAqB,EAAE,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,cAAc,MAAM,kBAAkB,CAAA;AAC7C,OAAO,KAAK,EAAE,aAAa,EAAE,qBAAqB,EAAE,MAAM,aAAa,CAAA;AAEvE,cAAc,qBAAqB,CAAA;AACnC,YAAY,EAAE,IAAI,IAAI,QAAQ,EAAE,OAAO,IAAI,WAAW,EAAE,MAAM,qBAAqB,CAAA;AACnF,YAAY,EACV,iBAAiB,EACjB,uBAAuB,EACvB,4BAA4B,EAC5B,cAAc,GACf,MAAM,wBAAwB,CAAA;AAC/B,OAAO,EACL,kBAAkB,EAClB,mBAAmB,EACnB,mBAAmB,EACnB,cAAc,GACf,MAAM,wBAAwB,CAAA;AAC/B,cAAc,uBAAuB,CAAA;AACrC,OAAO,EAAE,OAAO,IAAI,cAAc,EAAE,MAAM,kBAAkB,CAAA;AAC5D,YAAY,EAAE,qBAAqB,EAAE,MAAM,aAAa,CAAA;AAExD;;GAEG;AACH,eAAO,MAAM,YAAY,2PASV,MAAM,eACN,MAAM,0GAIpB,CAAA"}
|
package/dist/main/index.js
CHANGED
|
@@ -17,9 +17,14 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
17
17
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
18
18
|
};
|
|
19
19
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
20
|
-
exports.createClient = exports.SupabaseClient = void 0;
|
|
20
|
+
exports.createClient = exports.SupabaseClient = exports.FunctionsError = exports.FunctionsRelayError = exports.FunctionsFetchError = exports.FunctionsHttpError = void 0;
|
|
21
21
|
const SupabaseClient_1 = __importDefault(require("./SupabaseClient"));
|
|
22
22
|
__exportStar(require("@supabase/gotrue-js"), exports);
|
|
23
|
+
var functions_js_1 = require("@supabase/functions-js");
|
|
24
|
+
Object.defineProperty(exports, "FunctionsHttpError", { enumerable: true, get: function () { return functions_js_1.FunctionsHttpError; } });
|
|
25
|
+
Object.defineProperty(exports, "FunctionsFetchError", { enumerable: true, get: function () { return functions_js_1.FunctionsFetchError; } });
|
|
26
|
+
Object.defineProperty(exports, "FunctionsRelayError", { enumerable: true, get: function () { return functions_js_1.FunctionsRelayError; } });
|
|
27
|
+
Object.defineProperty(exports, "FunctionsError", { enumerable: true, get: function () { return functions_js_1.FunctionsError; } });
|
|
23
28
|
__exportStar(require("@supabase/realtime-js"), exports);
|
|
24
29
|
var SupabaseClient_2 = require("./SupabaseClient");
|
|
25
30
|
Object.defineProperty(exports, "SupabaseClient", { enumerable: true, get: function () { return __importDefault(SupabaseClient_2).default; } });
|
package/dist/main/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA,sEAA6C;AAG7C,sDAAmC;AAQnC,wDAAqC;AACrC,mDAA4D;AAAnD,iIAAA,OAAO,OAAkB;AAGlC;;GAEG;AACI,MAAM,YAAY,GAAG,CAS1B,WAAmB,EACnB,WAAmB,EACnB,OAA2C,EACG,EAAE;IAChD,OAAO,IAAI,wBAAc,CAAC,WAAW,EAAE,WAAW,EAAE,OAAO,CAAC,CAAA;AAC9D,CAAC,CAAA;AAdY,QAAA,YAAY,gBAcxB"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA,sEAA6C;AAG7C,sDAAmC;AAQnC,uDAK+B;AAJ7B,kHAAA,kBAAkB,OAAA;AAClB,mHAAA,mBAAmB,OAAA;AACnB,mHAAA,mBAAmB,OAAA;AACnB,8GAAA,cAAc,OAAA;AAEhB,wDAAqC;AACrC,mDAA4D;AAAnD,iIAAA,OAAO,OAAkB;AAGlC;;GAEG;AACI,MAAM,YAAY,GAAG,CAS1B,WAAmB,EACnB,WAAmB,EACnB,OAA2C,EACG,EAAE;IAChD,OAAO,IAAI,wBAAc,CAAC,WAAW,EAAE,WAAW,EAAE,OAAO,CAAC,CAAA;AAC9D,CAAC,CAAA;AAdY,QAAA,YAAY,gBAcxB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../../src/lib/constants.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,eAAe;;CAAgD,CAAA
|
|
1
|
+
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../../src/lib/constants.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,eAAe;;CAAgD,CAAA"}
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.DEFAULT_HEADERS = void 0;
|
|
4
4
|
// constants.ts
|
|
5
5
|
const version_1 = require("./version");
|
|
6
6
|
exports.DEFAULT_HEADERS = { 'X-Client-Info': `supabase-js/${version_1.version}` };
|
|
7
|
-
exports.STORAGE_KEY = 'supabase.auth.token';
|
|
8
7
|
//# sourceMappingURL=constants.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../../../src/lib/constants.ts"],"names":[],"mappings":";;;AAAA,eAAe;AACf,uCAAmC;AACtB,QAAA,eAAe,GAAG,EAAE,eAAe,EAAE,eAAe,iBAAO,EAAE,EAAE,CAAA
|
|
1
|
+
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../../../src/lib/constants.ts"],"names":[],"mappings":";;;AAAA,eAAe;AACf,uCAAmC;AACtB,QAAA,eAAe,GAAG,EAAE,eAAe,EAAE,eAAe,iBAAO,EAAE,EAAE,CAAA"}
|
|
@@ -1,4 +1,6 @@
|
|
|
1
|
+
import { SupabaseClientOptions } from './types';
|
|
1
2
|
export declare function uuid(): string;
|
|
2
3
|
export declare function stripTrailingSlash(url: string): string;
|
|
3
4
|
export declare const isBrowser: () => boolean;
|
|
5
|
+
export declare function applySettingDefaults<Database = any, SchemaName extends string & keyof Database = 'public' extends keyof Database ? 'public' : string & keyof Database>(options: SupabaseClientOptions<SchemaName>, defaults: SupabaseClientOptions<any>): SupabaseClientOptions<SchemaName>;
|
|
4
6
|
//# sourceMappingURL=helpers.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"helpers.d.ts","sourceRoot":"","sources":["../../../src/lib/helpers.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"helpers.d.ts","sourceRoot":"","sources":["../../../src/lib/helpers.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,qBAAqB,EAAE,MAAM,SAAS,CAAA;AAE/C,wBAAgB,IAAI,WAMnB;AAED,wBAAgB,kBAAkB,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAEtD;AAED,eAAO,MAAM,SAAS,eAAsC,CAAA;AAE5D,wBAAgB,oBAAoB,CAClC,QAAQ,GAAG,GAAG,EACd,UAAU,SAAS,MAAM,GAAG,MAAM,QAAQ,GAAG,QAAQ,SAAS,MAAM,QAAQ,GACxE,QAAQ,GACR,MAAM,GAAG,MAAM,QAAQ,EAE3B,OAAO,EAAE,qBAAqB,CAAC,UAAU,CAAC,EAC1C,QAAQ,EAAE,qBAAqB,CAAC,GAAG,CAAC,GACnC,qBAAqB,CAAC,UAAU,CAAC,CAgCnC"}
|
package/dist/main/lib/helpers.js
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
// helpers.ts
|
|
3
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
-
exports.isBrowser = exports.stripTrailingSlash = exports.uuid = void 0;
|
|
3
|
+
exports.applySettingDefaults = exports.isBrowser = exports.stripTrailingSlash = exports.uuid = void 0;
|
|
5
4
|
function uuid() {
|
|
6
5
|
return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function (c) {
|
|
7
6
|
var r = (Math.random() * 16) | 0, v = c == 'x' ? r : (r & 0x3) | 0x8;
|
|
@@ -15,4 +14,15 @@ function stripTrailingSlash(url) {
|
|
|
15
14
|
exports.stripTrailingSlash = stripTrailingSlash;
|
|
16
15
|
const isBrowser = () => typeof window !== 'undefined';
|
|
17
16
|
exports.isBrowser = isBrowser;
|
|
17
|
+
function applySettingDefaults(options, defaults) {
|
|
18
|
+
const { db: dbOptions, auth: authOptions, realtime: realtimeOptions, global: globalOptions, } = options;
|
|
19
|
+
const { db: DEFAULT_DB_OPTIONS, auth: DEFAULT_AUTH_OPTIONS, realtime: DEFAULT_REALTIME_OPTIONS, global: DEFAULT_GLOBAL_OPTIONS, } = defaults;
|
|
20
|
+
return {
|
|
21
|
+
db: Object.assign(Object.assign({}, DEFAULT_DB_OPTIONS), dbOptions),
|
|
22
|
+
auth: Object.assign(Object.assign({}, DEFAULT_AUTH_OPTIONS), authOptions),
|
|
23
|
+
realtime: Object.assign(Object.assign({}, DEFAULT_REALTIME_OPTIONS), realtimeOptions),
|
|
24
|
+
global: Object.assign(Object.assign({}, DEFAULT_GLOBAL_OPTIONS), globalOptions),
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
exports.applySettingDefaults = applySettingDefaults;
|
|
18
28
|
//# sourceMappingURL=helpers.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"helpers.js","sourceRoot":"","sources":["../../../src/lib/helpers.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"helpers.js","sourceRoot":"","sources":["../../../src/lib/helpers.ts"],"names":[],"mappings":";;;AAGA,SAAgB,IAAI;IAClB,OAAO,sCAAsC,CAAC,OAAO,CAAC,OAAO,EAAE,UAAU,CAAC;QACxE,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,MAAM,EAAE,GAAG,EAAE,CAAC,GAAG,CAAC,EAC9B,CAAC,GAAG,CAAC,IAAI,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,GAAG,CAAC,GAAG,GAAG,CAAA;QACpC,OAAO,CAAC,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAA;IACvB,CAAC,CAAC,CAAA;AACJ,CAAC;AAND,oBAMC;AAED,SAAgB,kBAAkB,CAAC,GAAW;IAC5C,OAAO,GAAG,CAAC,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC,CAAA;AAC/B,CAAC;AAFD,gDAEC;AAEM,MAAM,SAAS,GAAG,GAAG,EAAE,CAAC,OAAO,MAAM,KAAK,WAAW,CAAA;AAA/C,QAAA,SAAS,aAAsC;AAE5D,SAAgB,oBAAoB,CAMlC,OAA0C,EAC1C,QAAoC;IAEpC,MAAM,EACJ,EAAE,EAAE,SAAS,EACb,IAAI,EAAE,WAAW,EACjB,QAAQ,EAAE,eAAe,EACzB,MAAM,EAAE,aAAa,GACtB,GAAG,OAAO,CAAA;IACX,MAAM,EACJ,EAAE,EAAE,kBAAkB,EACtB,IAAI,EAAE,oBAAoB,EAC1B,QAAQ,EAAE,wBAAwB,EAClC,MAAM,EAAE,sBAAsB,GAC/B,GAAG,QAAQ,CAAA;IAEZ,OAAO;QACL,EAAE,kCACG,kBAAkB,GAClB,SAAS,CACb;QACD,IAAI,kCACC,oBAAoB,GACpB,WAAW,CACf;QACD,QAAQ,kCACH,wBAAwB,GACxB,eAAe,CACnB;QACD,MAAM,kCACD,sBAAsB,GACtB,aAAa,CACjB;KACF,CAAA;AACH,CAAC;AAxCD,oDAwCC"}
|
package/dist/main/lib/types.d.ts
CHANGED
|
@@ -16,6 +16,10 @@ export declare type SupabaseClientOptions<SchemaName> = {
|
|
|
16
16
|
* Automatically refreshes the token for logged in users.
|
|
17
17
|
*/
|
|
18
18
|
autoRefreshToken?: boolean;
|
|
19
|
+
/**
|
|
20
|
+
* Optional key name used for storing tokens in local storage
|
|
21
|
+
*/
|
|
22
|
+
storageKey?: string;
|
|
19
23
|
/**
|
|
20
24
|
* Whether to persist a logged in session to storage.
|
|
21
25
|
*/
|
|
@@ -27,43 +31,22 @@ export declare type SupabaseClientOptions<SchemaName> = {
|
|
|
27
31
|
/**
|
|
28
32
|
* A storage provider. Used to store the logged in session.
|
|
29
33
|
*/
|
|
30
|
-
|
|
31
|
-
/**
|
|
32
|
-
* Options passed to the gotrue-js instance
|
|
33
|
-
*/
|
|
34
|
-
cookieOptions?: SupabaseAuthClientOptions['cookieOptions'];
|
|
35
|
-
/**
|
|
36
|
-
* Allows to enable/disable multi-tab/window events
|
|
37
|
-
*/
|
|
38
|
-
multiTab?: boolean;
|
|
34
|
+
storage?: SupabaseAuthClientOptions['storage'];
|
|
39
35
|
};
|
|
40
36
|
/**
|
|
41
37
|
* Options passed to the realtime-js instance
|
|
42
38
|
*/
|
|
43
39
|
realtime?: RealtimeClientOptions;
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
*/
|
|
55
|
-
shouldThrowOnError?: boolean;
|
|
56
|
-
};
|
|
57
|
-
export declare type SupabaseRealtimePayload<T> = {
|
|
58
|
-
commit_timestamp: string;
|
|
59
|
-
eventType: 'INSERT' | 'UPDATE' | 'DELETE';
|
|
60
|
-
schema: string;
|
|
61
|
-
table: string;
|
|
62
|
-
/** The new record. Present for 'INSERT' and 'UPDATE' events. */
|
|
63
|
-
new: T;
|
|
64
|
-
/** The previous record. Present for 'UPDATE' and 'DELETE' events. */
|
|
65
|
-
old: T;
|
|
66
|
-
errors: string[] | null;
|
|
40
|
+
global?: {
|
|
41
|
+
/**
|
|
42
|
+
* A custom `fetch` implementation.
|
|
43
|
+
*/
|
|
44
|
+
fetch?: Fetch;
|
|
45
|
+
/**
|
|
46
|
+
* Optional headers for initializing the client.
|
|
47
|
+
*/
|
|
48
|
+
headers?: Record<string, string>;
|
|
49
|
+
};
|
|
67
50
|
};
|
|
68
51
|
export declare type GenericTable = {
|
|
69
52
|
Row: Record<string, unknown>;
|