@depup/supabase__supabase-js 2.99.2-depup.0

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/index.mjs ADDED
@@ -0,0 +1,575 @@
1
+ import { FunctionRegion, FunctionsClient, FunctionsError, FunctionsFetchError, FunctionsHttpError, FunctionsRelayError } from "@supabase/functions-js";
2
+ import { PostgrestClient, PostgrestError } from "@supabase/postgrest-js";
3
+ import { RealtimeClient } from "@supabase/realtime-js";
4
+ import { StorageClient } from "@supabase/storage-js";
5
+ import { AuthClient } from "@supabase/auth-js";
6
+
7
+ export * from "@supabase/realtime-js"
8
+
9
+ export * from "@supabase/auth-js"
10
+
11
+ //#region src/lib/version.ts
12
+ const version = "2.99.2";
13
+
14
+ //#endregion
15
+ //#region src/lib/constants.ts
16
+ let JS_ENV = "";
17
+ if (typeof Deno !== "undefined") JS_ENV = "deno";
18
+ else if (typeof document !== "undefined") JS_ENV = "web";
19
+ else if (typeof navigator !== "undefined" && navigator.product === "ReactNative") JS_ENV = "react-native";
20
+ else JS_ENV = "node";
21
+ const DEFAULT_HEADERS = { "X-Client-Info": `supabase-js-${JS_ENV}/${version}` };
22
+ const DEFAULT_GLOBAL_OPTIONS = { headers: DEFAULT_HEADERS };
23
+ const DEFAULT_DB_OPTIONS = { schema: "public" };
24
+ const DEFAULT_AUTH_OPTIONS = {
25
+ autoRefreshToken: true,
26
+ persistSession: true,
27
+ detectSessionInUrl: true,
28
+ flowType: "implicit"
29
+ };
30
+ const DEFAULT_REALTIME_OPTIONS = {};
31
+
32
+ //#endregion
33
+ //#region \0@oxc-project+runtime@0.101.0/helpers/typeof.js
34
+ function _typeof(o) {
35
+ "@babel/helpers - typeof";
36
+ return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(o$1) {
37
+ return typeof o$1;
38
+ } : function(o$1) {
39
+ return o$1 && "function" == typeof Symbol && o$1.constructor === Symbol && o$1 !== Symbol.prototype ? "symbol" : typeof o$1;
40
+ }, _typeof(o);
41
+ }
42
+
43
+ //#endregion
44
+ //#region \0@oxc-project+runtime@0.101.0/helpers/toPrimitive.js
45
+ function toPrimitive(t, r) {
46
+ if ("object" != _typeof(t) || !t) return t;
47
+ var e = t[Symbol.toPrimitive];
48
+ if (void 0 !== e) {
49
+ var i = e.call(t, r || "default");
50
+ if ("object" != _typeof(i)) return i;
51
+ throw new TypeError("@@toPrimitive must return a primitive value.");
52
+ }
53
+ return ("string" === r ? String : Number)(t);
54
+ }
55
+
56
+ //#endregion
57
+ //#region \0@oxc-project+runtime@0.101.0/helpers/toPropertyKey.js
58
+ function toPropertyKey(t) {
59
+ var i = toPrimitive(t, "string");
60
+ return "symbol" == _typeof(i) ? i : i + "";
61
+ }
62
+
63
+ //#endregion
64
+ //#region \0@oxc-project+runtime@0.101.0/helpers/defineProperty.js
65
+ function _defineProperty(e, r, t) {
66
+ return (r = toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
67
+ value: t,
68
+ enumerable: !0,
69
+ configurable: !0,
70
+ writable: !0
71
+ }) : e[r] = t, e;
72
+ }
73
+
74
+ //#endregion
75
+ //#region \0@oxc-project+runtime@0.101.0/helpers/objectSpread2.js
76
+ function ownKeys(e, r) {
77
+ var t = Object.keys(e);
78
+ if (Object.getOwnPropertySymbols) {
79
+ var o = Object.getOwnPropertySymbols(e);
80
+ r && (o = o.filter(function(r$1) {
81
+ return Object.getOwnPropertyDescriptor(e, r$1).enumerable;
82
+ })), t.push.apply(t, o);
83
+ }
84
+ return t;
85
+ }
86
+ function _objectSpread2(e) {
87
+ for (var r = 1; r < arguments.length; r++) {
88
+ var t = null != arguments[r] ? arguments[r] : {};
89
+ r % 2 ? ownKeys(Object(t), !0).forEach(function(r$1) {
90
+ _defineProperty(e, r$1, t[r$1]);
91
+ }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function(r$1) {
92
+ Object.defineProperty(e, r$1, Object.getOwnPropertyDescriptor(t, r$1));
93
+ });
94
+ }
95
+ return e;
96
+ }
97
+
98
+ //#endregion
99
+ //#region src/lib/fetch.ts
100
+ const resolveFetch = (customFetch) => {
101
+ if (customFetch) return (...args) => customFetch(...args);
102
+ return (...args) => fetch(...args);
103
+ };
104
+ const resolveHeadersConstructor = () => {
105
+ return Headers;
106
+ };
107
+ const fetchWithAuth = (supabaseKey, getAccessToken, customFetch) => {
108
+ const fetch$1 = resolveFetch(customFetch);
109
+ const HeadersConstructor = resolveHeadersConstructor();
110
+ return async (input, init) => {
111
+ var _await$getAccessToken;
112
+ const accessToken = (_await$getAccessToken = await getAccessToken()) !== null && _await$getAccessToken !== void 0 ? _await$getAccessToken : supabaseKey;
113
+ let headers = new HeadersConstructor(init === null || init === void 0 ? void 0 : init.headers);
114
+ if (!headers.has("apikey")) headers.set("apikey", supabaseKey);
115
+ if (!headers.has("Authorization")) headers.set("Authorization", `Bearer ${accessToken}`);
116
+ return fetch$1(input, _objectSpread2(_objectSpread2({}, init), {}, { headers }));
117
+ };
118
+ };
119
+
120
+ //#endregion
121
+ //#region src/lib/helpers.ts
122
+ function ensureTrailingSlash(url) {
123
+ return url.endsWith("/") ? url : url + "/";
124
+ }
125
+ function applySettingDefaults(options, defaults) {
126
+ var _DEFAULT_GLOBAL_OPTIO, _globalOptions$header;
127
+ const { db: dbOptions, auth: authOptions, realtime: realtimeOptions, global: globalOptions } = options;
128
+ const { db: DEFAULT_DB_OPTIONS$1, auth: DEFAULT_AUTH_OPTIONS$1, realtime: DEFAULT_REALTIME_OPTIONS$1, global: DEFAULT_GLOBAL_OPTIONS$1 } = defaults;
129
+ const result = {
130
+ db: _objectSpread2(_objectSpread2({}, DEFAULT_DB_OPTIONS$1), dbOptions),
131
+ auth: _objectSpread2(_objectSpread2({}, DEFAULT_AUTH_OPTIONS$1), authOptions),
132
+ realtime: _objectSpread2(_objectSpread2({}, DEFAULT_REALTIME_OPTIONS$1), realtimeOptions),
133
+ storage: {},
134
+ global: _objectSpread2(_objectSpread2(_objectSpread2({}, DEFAULT_GLOBAL_OPTIONS$1), globalOptions), {}, { headers: _objectSpread2(_objectSpread2({}, (_DEFAULT_GLOBAL_OPTIO = DEFAULT_GLOBAL_OPTIONS$1 === null || DEFAULT_GLOBAL_OPTIONS$1 === void 0 ? void 0 : DEFAULT_GLOBAL_OPTIONS$1.headers) !== null && _DEFAULT_GLOBAL_OPTIO !== void 0 ? _DEFAULT_GLOBAL_OPTIO : {}), (_globalOptions$header = globalOptions === null || globalOptions === void 0 ? void 0 : globalOptions.headers) !== null && _globalOptions$header !== void 0 ? _globalOptions$header : {}) }),
135
+ accessToken: async () => ""
136
+ };
137
+ if (options.accessToken) result.accessToken = options.accessToken;
138
+ else delete result.accessToken;
139
+ return result;
140
+ }
141
+ /**
142
+ * Validates a Supabase client URL
143
+ *
144
+ * @param {string} supabaseUrl - The Supabase client URL string.
145
+ * @returns {URL} - The validated base URL.
146
+ * @throws {Error}
147
+ */
148
+ function validateSupabaseUrl(supabaseUrl) {
149
+ const trimmedUrl = supabaseUrl === null || supabaseUrl === void 0 ? void 0 : supabaseUrl.trim();
150
+ if (!trimmedUrl) throw new Error("supabaseUrl is required.");
151
+ if (!trimmedUrl.match(/^https?:\/\//i)) throw new Error("Invalid supabaseUrl: Must be a valid HTTP or HTTPS URL.");
152
+ try {
153
+ return new URL(ensureTrailingSlash(trimmedUrl));
154
+ } catch (_unused) {
155
+ throw Error("Invalid supabaseUrl: Provided URL is malformed.");
156
+ }
157
+ }
158
+
159
+ //#endregion
160
+ //#region src/lib/SupabaseAuthClient.ts
161
+ var SupabaseAuthClient = class extends AuthClient {
162
+ constructor(options) {
163
+ super(options);
164
+ }
165
+ };
166
+
167
+ //#endregion
168
+ //#region src/SupabaseClient.ts
169
+ /**
170
+ * Supabase Client.
171
+ *
172
+ * An isomorphic Javascript client for interacting with Postgres.
173
+ */
174
+ var SupabaseClient = class {
175
+ /**
176
+ * Create a new client for use in the browser.
177
+ *
178
+ * @category Initializing
179
+ *
180
+ * @param supabaseUrl The unique Supabase URL which is supplied when you create a new project in your project dashboard.
181
+ * @param supabaseKey The unique Supabase Key which is supplied when you create a new project in your project dashboard.
182
+ * @param options.db.schema You can switch in between schemas. The schema needs to be on the list of exposed schemas inside Supabase.
183
+ * @param options.auth.autoRefreshToken Set to "true" if you want to automatically refresh the token before expiring.
184
+ * @param options.auth.persistSession Set to "true" if you want to automatically save the user session into local storage.
185
+ * @param options.auth.detectSessionInUrl Set to "true" if you want to automatically detects OAuth grants in the URL and signs in the user.
186
+ * @param options.realtime Options passed along to realtime-js constructor.
187
+ * @param options.storage Options passed along to the storage-js constructor.
188
+ * @param options.global.fetch A custom fetch implementation.
189
+ * @param options.global.headers Any additional headers to send with each network request.
190
+ *
191
+ * @example Creating a client
192
+ * ```js
193
+ * import { createClient } from '@supabase/supabase-js'
194
+ *
195
+ * // Create a single supabase client for interacting with your database
196
+ * const supabase = createClient('https://xyzcompany.supabase.co', 'publishable-or-anon-key')
197
+ * ```
198
+ *
199
+ * @example With a custom domain
200
+ * ```js
201
+ * import { createClient } from '@supabase/supabase-js'
202
+ *
203
+ * // Use a custom domain as the supabase URL
204
+ * const supabase = createClient('https://my-custom-domain.com', 'publishable-or-anon-key')
205
+ * ```
206
+ *
207
+ * @example With additional parameters
208
+ * ```js
209
+ * import { createClient } from '@supabase/supabase-js'
210
+ *
211
+ * const options = {
212
+ * db: {
213
+ * schema: 'public',
214
+ * },
215
+ * auth: {
216
+ * autoRefreshToken: true,
217
+ * persistSession: true,
218
+ * detectSessionInUrl: true
219
+ * },
220
+ * global: {
221
+ * headers: { 'x-my-custom-header': 'my-app-name' },
222
+ * },
223
+ * }
224
+ * const supabase = createClient("https://xyzcompany.supabase.co", "publishable-or-anon-key", options)
225
+ * ```
226
+ *
227
+ * @exampleDescription With custom schemas
228
+ * By default the API server points to the `public` schema. You can enable other database schemas within the Dashboard.
229
+ * Go to [Settings > API > Exposed schemas](/dashboard/project/_/settings/api) and add the schema which you want to expose to the API.
230
+ *
231
+ * Note: each client connection can only access a single schema, so the code above can access the `other_schema` schema but cannot access the `public` schema.
232
+ *
233
+ * @example With custom schemas
234
+ * ```js
235
+ * import { createClient } from '@supabase/supabase-js'
236
+ *
237
+ * const supabase = createClient('https://xyzcompany.supabase.co', 'publishable-or-anon-key', {
238
+ * // Provide a custom schema. Defaults to "public".
239
+ * db: { schema: 'other_schema' }
240
+ * })
241
+ * ```
242
+ *
243
+ * @exampleDescription Custom fetch implementation
244
+ * `supabase-js` uses the [`cross-fetch`](https://www.npmjs.com/package/cross-fetch) library to make HTTP requests,
245
+ * but an alternative `fetch` implementation can be provided as an option.
246
+ * This is most useful in environments where `cross-fetch` is not compatible (for instance Cloudflare Workers).
247
+ *
248
+ * @example Custom fetch implementation
249
+ * ```js
250
+ * import { createClient } from '@supabase/supabase-js'
251
+ *
252
+ * const supabase = createClient('https://xyzcompany.supabase.co', 'publishable-or-anon-key', {
253
+ * global: { fetch: fetch.bind(globalThis) }
254
+ * })
255
+ * ```
256
+ *
257
+ * @exampleDescription React Native options with AsyncStorage
258
+ * For React Native we recommend using `AsyncStorage` as the storage implementation for Supabase Auth.
259
+ *
260
+ * @example React Native options with AsyncStorage
261
+ * ```js
262
+ * import 'react-native-url-polyfill/auto'
263
+ * import { createClient } from '@supabase/supabase-js'
264
+ * import AsyncStorage from "@react-native-async-storage/async-storage";
265
+ *
266
+ * const supabase = createClient("https://xyzcompany.supabase.co", "publishable-or-anon-key", {
267
+ * auth: {
268
+ * storage: AsyncStorage,
269
+ * autoRefreshToken: true,
270
+ * persistSession: true,
271
+ * detectSessionInUrl: false,
272
+ * },
273
+ * });
274
+ * ```
275
+ *
276
+ * @exampleDescription React Native options with Expo SecureStore
277
+ * If you wish to encrypt the user's session information, you can use `aes-js` and store the encryption key in Expo SecureStore.
278
+ * The `aes-js` library, a reputable JavaScript-only implementation of the AES encryption algorithm in CTR mode.
279
+ * A new 256-bit encryption key is generated using the `react-native-get-random-values` library.
280
+ * This key is stored inside Expo's SecureStore, while the value is encrypted and placed inside AsyncStorage.
281
+ *
282
+ * Please make sure that:
283
+ * - You keep the `expo-secure-store`, `aes-js` and `react-native-get-random-values` libraries up-to-date.
284
+ * - Choose the correct [`SecureStoreOptions`](https://docs.expo.dev/versions/latest/sdk/securestore/#securestoreoptions) for your app's needs.
285
+ * E.g. [`SecureStore.WHEN_UNLOCKED`](https://docs.expo.dev/versions/latest/sdk/securestore/#securestorewhen_unlocked) regulates when the data can be accessed.
286
+ * - Carefully consider optimizations or other modifications to the above example, as those can lead to introducing subtle security vulnerabilities.
287
+ *
288
+ * @example React Native options with Expo SecureStore
289
+ * ```ts
290
+ * import 'react-native-url-polyfill/auto'
291
+ * import { createClient } from '@supabase/supabase-js'
292
+ * import AsyncStorage from '@react-native-async-storage/async-storage';
293
+ * import * as SecureStore from 'expo-secure-store';
294
+ * import * as aesjs from 'aes-js';
295
+ * import 'react-native-get-random-values';
296
+ *
297
+ * // As Expo's SecureStore does not support values larger than 2048
298
+ * // bytes, an AES-256 key is generated and stored in SecureStore, while
299
+ * // it is used to encrypt/decrypt values stored in AsyncStorage.
300
+ * class LargeSecureStore {
301
+ * private async _encrypt(key: string, value: string) {
302
+ * const encryptionKey = crypto.getRandomValues(new Uint8Array(256 / 8));
303
+ *
304
+ * const cipher = new aesjs.ModeOfOperation.ctr(encryptionKey, new aesjs.Counter(1));
305
+ * const encryptedBytes = cipher.encrypt(aesjs.utils.utf8.toBytes(value));
306
+ *
307
+ * await SecureStore.setItemAsync(key, aesjs.utils.hex.fromBytes(encryptionKey));
308
+ *
309
+ * return aesjs.utils.hex.fromBytes(encryptedBytes);
310
+ * }
311
+ *
312
+ * private async _decrypt(key: string, value: string) {
313
+ * const encryptionKeyHex = await SecureStore.getItemAsync(key);
314
+ * if (!encryptionKeyHex) {
315
+ * return encryptionKeyHex;
316
+ * }
317
+ *
318
+ * const cipher = new aesjs.ModeOfOperation.ctr(aesjs.utils.hex.toBytes(encryptionKeyHex), new aesjs.Counter(1));
319
+ * const decryptedBytes = cipher.decrypt(aesjs.utils.hex.toBytes(value));
320
+ *
321
+ * return aesjs.utils.utf8.fromBytes(decryptedBytes);
322
+ * }
323
+ *
324
+ * async getItem(key: string) {
325
+ * const encrypted = await AsyncStorage.getItem(key);
326
+ * if (!encrypted) { return encrypted; }
327
+ *
328
+ * return await this._decrypt(key, encrypted);
329
+ * }
330
+ *
331
+ * async removeItem(key: string) {
332
+ * await AsyncStorage.removeItem(key);
333
+ * await SecureStore.deleteItemAsync(key);
334
+ * }
335
+ *
336
+ * async setItem(key: string, value: string) {
337
+ * const encrypted = await this._encrypt(key, value);
338
+ *
339
+ * await AsyncStorage.setItem(key, encrypted);
340
+ * }
341
+ * }
342
+ *
343
+ * const supabase = createClient("https://xyzcompany.supabase.co", "publishable-or-anon-key", {
344
+ * auth: {
345
+ * storage: new LargeSecureStore(),
346
+ * autoRefreshToken: true,
347
+ * persistSession: true,
348
+ * detectSessionInUrl: false,
349
+ * },
350
+ * });
351
+ * ```
352
+ *
353
+ * @example With a database query
354
+ * ```ts
355
+ * import { createClient } from '@supabase/supabase-js'
356
+ *
357
+ * const supabase = createClient('https://xyzcompany.supabase.co', 'public-anon-key')
358
+ *
359
+ * const { data } = await supabase.from('profiles').select('*')
360
+ * ```
361
+ */
362
+ constructor(supabaseUrl, supabaseKey, options) {
363
+ var _settings$auth$storag, _settings$global$head;
364
+ this.supabaseUrl = supabaseUrl;
365
+ this.supabaseKey = supabaseKey;
366
+ const baseUrl = validateSupabaseUrl(supabaseUrl);
367
+ if (!supabaseKey) throw new Error("supabaseKey is required.");
368
+ this.realtimeUrl = new URL("realtime/v1", baseUrl);
369
+ this.realtimeUrl.protocol = this.realtimeUrl.protocol.replace("http", "ws");
370
+ this.authUrl = new URL("auth/v1", baseUrl);
371
+ this.storageUrl = new URL("storage/v1", baseUrl);
372
+ this.functionsUrl = new URL("functions/v1", baseUrl);
373
+ const defaultStorageKey = `sb-${baseUrl.hostname.split(".")[0]}-auth-token`;
374
+ const DEFAULTS = {
375
+ db: DEFAULT_DB_OPTIONS,
376
+ realtime: DEFAULT_REALTIME_OPTIONS,
377
+ auth: _objectSpread2(_objectSpread2({}, DEFAULT_AUTH_OPTIONS), {}, { storageKey: defaultStorageKey }),
378
+ global: DEFAULT_GLOBAL_OPTIONS
379
+ };
380
+ const settings = applySettingDefaults(options !== null && options !== void 0 ? options : {}, DEFAULTS);
381
+ this.storageKey = (_settings$auth$storag = settings.auth.storageKey) !== null && _settings$auth$storag !== void 0 ? _settings$auth$storag : "";
382
+ this.headers = (_settings$global$head = settings.global.headers) !== null && _settings$global$head !== void 0 ? _settings$global$head : {};
383
+ if (!settings.accessToken) {
384
+ var _settings$auth;
385
+ this.auth = this._initSupabaseAuthClient((_settings$auth = settings.auth) !== null && _settings$auth !== void 0 ? _settings$auth : {}, this.headers, settings.global.fetch);
386
+ } else {
387
+ this.accessToken = settings.accessToken;
388
+ this.auth = new Proxy({}, { get: (_, prop) => {
389
+ throw new Error(`@supabase/supabase-js: Supabase Client is configured with the accessToken option, accessing supabase.auth.${String(prop)} is not possible`);
390
+ } });
391
+ }
392
+ this.fetch = fetchWithAuth(supabaseKey, this._getAccessToken.bind(this), settings.global.fetch);
393
+ this.realtime = this._initRealtimeClient(_objectSpread2({
394
+ headers: this.headers,
395
+ accessToken: this._getAccessToken.bind(this)
396
+ }, settings.realtime));
397
+ if (this.accessToken) Promise.resolve(this.accessToken()).then((token) => this.realtime.setAuth(token)).catch((e) => console.warn("Failed to set initial Realtime auth token:", e));
398
+ this.rest = new PostgrestClient(new URL("rest/v1", baseUrl).href, {
399
+ headers: this.headers,
400
+ schema: settings.db.schema,
401
+ fetch: this.fetch,
402
+ timeout: settings.db.timeout,
403
+ urlLengthLimit: settings.db.urlLengthLimit
404
+ });
405
+ this.storage = new StorageClient(this.storageUrl.href, this.headers, this.fetch, options === null || options === void 0 ? void 0 : options.storage);
406
+ if (!settings.accessToken) this._listenForAuthEvents();
407
+ }
408
+ /**
409
+ * Supabase Functions allows you to deploy and invoke edge functions.
410
+ */
411
+ get functions() {
412
+ return new FunctionsClient(this.functionsUrl.href, {
413
+ headers: this.headers,
414
+ customFetch: this.fetch
415
+ });
416
+ }
417
+ /**
418
+ * Perform a query on a table or a view.
419
+ *
420
+ * @param relation - The table or view name to query
421
+ */
422
+ from(relation) {
423
+ return this.rest.from(relation);
424
+ }
425
+ /**
426
+ * Select a schema to query or perform an function (rpc) call.
427
+ *
428
+ * The schema needs to be on the list of exposed schemas inside Supabase.
429
+ *
430
+ * @param schema - The schema to query
431
+ */
432
+ schema(schema) {
433
+ return this.rest.schema(schema);
434
+ }
435
+ /**
436
+ * Perform a function call.
437
+ *
438
+ * @param fn - The function name to call
439
+ * @param args - The arguments to pass to the function call
440
+ * @param options - Named parameters
441
+ * @param options.head - When set to `true`, `data` will not be returned.
442
+ * Useful if you only need the count.
443
+ * @param options.get - When set to `true`, the function will be called with
444
+ * read-only access mode.
445
+ * @param options.count - Count algorithm to use to count rows returned by the
446
+ * function. Only applicable for [set-returning
447
+ * functions](https://www.postgresql.org/docs/current/functions-srf.html).
448
+ *
449
+ * `"exact"`: Exact but slow count algorithm. Performs a `COUNT(*)` under the
450
+ * hood.
451
+ *
452
+ * `"planned"`: Approximated but fast count algorithm. Uses the Postgres
453
+ * statistics under the hood.
454
+ *
455
+ * `"estimated"`: Uses exact count for low numbers and planned count for high
456
+ * numbers.
457
+ */
458
+ rpc(fn, args = {}, options = {
459
+ head: false,
460
+ get: false,
461
+ count: void 0
462
+ }) {
463
+ return this.rest.rpc(fn, args, options);
464
+ }
465
+ /**
466
+ * Creates a Realtime channel with Broadcast, Presence, and Postgres Changes.
467
+ *
468
+ * @param {string} name - The name of the Realtime channel.
469
+ * @param {Object} opts - The options to pass to the Realtime channel.
470
+ *
471
+ */
472
+ channel(name, opts = { config: {} }) {
473
+ return this.realtime.channel(name, opts);
474
+ }
475
+ /**
476
+ * Returns all Realtime channels.
477
+ */
478
+ getChannels() {
479
+ return this.realtime.getChannels();
480
+ }
481
+ /**
482
+ * Unsubscribes and removes Realtime channel from Realtime client.
483
+ *
484
+ * @param {RealtimeChannel} channel - The name of the Realtime channel.
485
+ *
486
+ */
487
+ removeChannel(channel) {
488
+ return this.realtime.removeChannel(channel);
489
+ }
490
+ /**
491
+ * Unsubscribes and removes all Realtime channels from Realtime client.
492
+ */
493
+ removeAllChannels() {
494
+ return this.realtime.removeAllChannels();
495
+ }
496
+ async _getAccessToken() {
497
+ var _this = this;
498
+ var _data$session$access_, _data$session;
499
+ if (_this.accessToken) return await _this.accessToken();
500
+ const { data } = await _this.auth.getSession();
501
+ return (_data$session$access_ = (_data$session = data.session) === null || _data$session === void 0 ? void 0 : _data$session.access_token) !== null && _data$session$access_ !== void 0 ? _data$session$access_ : _this.supabaseKey;
502
+ }
503
+ _initSupabaseAuthClient({ autoRefreshToken, persistSession, detectSessionInUrl, storage, userStorage, storageKey, flowType, lock, debug, throwOnError }, headers, fetch$1) {
504
+ const authHeaders = {
505
+ Authorization: `Bearer ${this.supabaseKey}`,
506
+ apikey: `${this.supabaseKey}`
507
+ };
508
+ return new SupabaseAuthClient({
509
+ url: this.authUrl.href,
510
+ headers: _objectSpread2(_objectSpread2({}, authHeaders), headers),
511
+ storageKey,
512
+ autoRefreshToken,
513
+ persistSession,
514
+ detectSessionInUrl,
515
+ storage,
516
+ userStorage,
517
+ flowType,
518
+ lock,
519
+ debug,
520
+ throwOnError,
521
+ fetch: fetch$1,
522
+ hasCustomAuthorizationHeader: Object.keys(this.headers).some((key) => key.toLowerCase() === "authorization")
523
+ });
524
+ }
525
+ _initRealtimeClient(options) {
526
+ return new RealtimeClient(this.realtimeUrl.href, _objectSpread2(_objectSpread2({}, options), {}, { params: _objectSpread2(_objectSpread2({}, { apikey: this.supabaseKey }), options === null || options === void 0 ? void 0 : options.params) }));
527
+ }
528
+ _listenForAuthEvents() {
529
+ return this.auth.onAuthStateChange((event, session) => {
530
+ this._handleTokenChanged(event, "CLIENT", session === null || session === void 0 ? void 0 : session.access_token);
531
+ });
532
+ }
533
+ _handleTokenChanged(event, source, token) {
534
+ if ((event === "TOKEN_REFRESHED" || event === "SIGNED_IN") && this.changedAccessToken !== token) {
535
+ this.changedAccessToken = token;
536
+ this.realtime.setAuth(token);
537
+ } else if (event === "SIGNED_OUT") {
538
+ this.realtime.setAuth();
539
+ if (source == "STORAGE") this.auth.signOut();
540
+ this.changedAccessToken = void 0;
541
+ }
542
+ }
543
+ };
544
+
545
+ //#endregion
546
+ //#region src/index.ts
547
+ /**
548
+ * Creates a new Supabase Client.
549
+ *
550
+ * @example
551
+ * ```ts
552
+ * import { createClient } from '@supabase/supabase-js'
553
+ *
554
+ * const supabase = createClient('https://xyzcompany.supabase.co', 'public-anon-key')
555
+ * const { data, error } = await supabase.from('profiles').select('*')
556
+ * ```
557
+ */
558
+ const createClient = (supabaseUrl, supabaseKey, options) => {
559
+ return new SupabaseClient(supabaseUrl, supabaseKey, options);
560
+ };
561
+ function shouldShowDeprecationWarning() {
562
+ if (typeof window !== "undefined") return false;
563
+ const _process = globalThis["process"];
564
+ if (!_process) return false;
565
+ const processVersion = _process["version"];
566
+ if (processVersion === void 0 || processVersion === null) return false;
567
+ const versionMatch = processVersion.match(/^v(\d+)\./);
568
+ if (!versionMatch) return false;
569
+ return parseInt(versionMatch[1], 10) <= 18;
570
+ }
571
+ if (shouldShowDeprecationWarning()) console.warn("⚠️ Node.js 18 and below are deprecated and will no longer be supported in future versions of @supabase/supabase-js. Please upgrade to Node.js 20 or later. For more information, visit: https://github.com/orgs/supabase/discussions/37217");
572
+
573
+ //#endregion
574
+ export { FunctionRegion, FunctionsError, FunctionsFetchError, FunctionsHttpError, FunctionsRelayError, PostgrestError, SupabaseClient, createClient };
575
+ //# sourceMappingURL=index.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.mjs","names":["DEFAULT_AUTH_OPTIONS: SupabaseAuthClientOptions","DEFAULT_REALTIME_OPTIONS: RealtimeClientOptions","fetch","DEFAULT_DB_OPTIONS","DEFAULT_AUTH_OPTIONS","DEFAULT_REALTIME_OPTIONS","DEFAULT_GLOBAL_OPTIONS","result: Required<SupabaseClientOptions<SchemaName>>","supabaseUrl: string","supabaseKey: string","SupabaseStorageClient","this"],"sources":["../src/lib/version.ts","../src/lib/constants.ts","../src/lib/fetch.ts","../src/lib/helpers.ts","../src/lib/SupabaseAuthClient.ts","../src/SupabaseClient.ts","../src/index.ts"],"sourcesContent":["// Generated automatically during releases by scripts/update-version-files.ts\n// This file provides runtime access to the package version for:\n// - HTTP request headers (e.g., X-Client-Info header for API requests)\n// - Debugging and support (identifying which version is running)\n// - Telemetry and logging (version reporting in errors/analytics)\n// - Ensuring build artifacts match the published package version\nexport const version = '2.99.2'\n","// constants.ts\nimport { RealtimeClientOptions } from '@supabase/realtime-js'\nimport { SupabaseAuthClientOptions } from './types'\nimport { version } from './version'\n\nlet JS_ENV = ''\n// @ts-ignore\nif (typeof Deno !== 'undefined') {\n JS_ENV = 'deno'\n} else if (typeof document !== 'undefined') {\n JS_ENV = 'web'\n} else if (typeof navigator !== 'undefined' && navigator.product === 'ReactNative') {\n JS_ENV = 'react-native'\n} else {\n JS_ENV = 'node'\n}\n\nexport const DEFAULT_HEADERS = { 'X-Client-Info': `supabase-js-${JS_ENV}/${version}` }\n\nexport const DEFAULT_GLOBAL_OPTIONS = {\n headers: DEFAULT_HEADERS,\n}\n\nexport const DEFAULT_DB_OPTIONS = {\n schema: 'public',\n}\n\nexport const DEFAULT_AUTH_OPTIONS: SupabaseAuthClientOptions = {\n autoRefreshToken: true,\n persistSession: true,\n detectSessionInUrl: true,\n flowType: 'implicit',\n}\n\nexport const DEFAULT_REALTIME_OPTIONS: RealtimeClientOptions = {}\n","type Fetch = typeof fetch\n\nexport const resolveFetch = (customFetch?: Fetch): Fetch => {\n if (customFetch) {\n return (...args: Parameters<Fetch>) => customFetch(...args)\n }\n return (...args: Parameters<Fetch>) => fetch(...args)\n}\n\nexport const resolveHeadersConstructor = () => {\n return Headers\n}\n\nexport const fetchWithAuth = (\n supabaseKey: string,\n getAccessToken: () => Promise<string | null>,\n customFetch?: Fetch\n): Fetch => {\n const fetch = resolveFetch(customFetch)\n const HeadersConstructor = resolveHeadersConstructor()\n\n return async (input, init) => {\n const accessToken = (await getAccessToken()) ?? supabaseKey\n let headers = new HeadersConstructor(init?.headers)\n\n if (!headers.has('apikey')) {\n headers.set('apikey', supabaseKey)\n }\n\n if (!headers.has('Authorization')) {\n headers.set('Authorization', `Bearer ${accessToken}`)\n }\n\n return fetch(input, { ...init, headers })\n }\n}\n","// helpers.ts\nimport { SupabaseClientOptions } from './types'\n\nexport function uuid() {\n return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function (c) {\n var r = (Math.random() * 16) | 0,\n v = c == 'x' ? r : (r & 0x3) | 0x8\n return v.toString(16)\n })\n}\n\nexport function ensureTrailingSlash(url: string): string {\n return url.endsWith('/') ? url : url + '/'\n}\n\nexport const isBrowser = () => typeof window !== 'undefined'\n\nexport function applySettingDefaults<\n Database = any,\n SchemaName extends string & keyof Database = 'public' extends keyof Database\n ? 'public'\n : string & keyof Database,\n>(\n options: SupabaseClientOptions<SchemaName>,\n defaults: SupabaseClientOptions<any>\n): Required<SupabaseClientOptions<SchemaName>> {\n const {\n db: dbOptions,\n auth: authOptions,\n realtime: realtimeOptions,\n global: globalOptions,\n } = options\n const {\n db: DEFAULT_DB_OPTIONS,\n auth: DEFAULT_AUTH_OPTIONS,\n realtime: DEFAULT_REALTIME_OPTIONS,\n global: DEFAULT_GLOBAL_OPTIONS,\n } = defaults\n\n const result: Required<SupabaseClientOptions<SchemaName>> = {\n db: {\n ...DEFAULT_DB_OPTIONS,\n ...dbOptions,\n },\n auth: {\n ...DEFAULT_AUTH_OPTIONS,\n ...authOptions,\n },\n realtime: {\n ...DEFAULT_REALTIME_OPTIONS,\n ...realtimeOptions,\n },\n storage: {},\n global: {\n ...DEFAULT_GLOBAL_OPTIONS,\n ...globalOptions,\n headers: {\n ...(DEFAULT_GLOBAL_OPTIONS?.headers ?? {}),\n ...(globalOptions?.headers ?? {}),\n },\n },\n accessToken: async () => '',\n }\n\n if (options.accessToken) {\n result.accessToken = options.accessToken\n } else {\n // hack around Required<>\n delete (result as any).accessToken\n }\n\n return result\n}\n\n/**\n * Validates a Supabase client URL\n *\n * @param {string} supabaseUrl - The Supabase client URL string.\n * @returns {URL} - The validated base URL.\n * @throws {Error}\n */\nexport function validateSupabaseUrl(supabaseUrl: string): URL {\n const trimmedUrl = supabaseUrl?.trim()\n\n if (!trimmedUrl) {\n throw new Error('supabaseUrl is required.')\n }\n\n if (!trimmedUrl.match(/^https?:\\/\\//i)) {\n throw new Error('Invalid supabaseUrl: Must be a valid HTTP or HTTPS URL.')\n }\n\n try {\n return new URL(ensureTrailingSlash(trimmedUrl))\n } catch {\n throw Error('Invalid supabaseUrl: Provided URL is malformed.')\n }\n}\n","import { AuthClient } from '@supabase/auth-js'\nimport { SupabaseAuthClientOptions } from './types'\n\nexport class SupabaseAuthClient extends AuthClient {\n constructor(options: SupabaseAuthClientOptions) {\n super(options)\n }\n}\n","import type { AuthChangeEvent } from '@supabase/auth-js'\nimport { FunctionsClient } from '@supabase/functions-js'\nimport {\n PostgrestClient,\n type PostgrestFilterBuilder,\n type PostgrestQueryBuilder,\n} from '@supabase/postgrest-js'\nimport {\n type RealtimeChannel,\n type RealtimeChannelOptions,\n RealtimeClient,\n type RealtimeClientOptions,\n} from '@supabase/realtime-js'\nimport { StorageClient as SupabaseStorageClient } from '@supabase/storage-js'\nimport {\n DEFAULT_AUTH_OPTIONS,\n DEFAULT_DB_OPTIONS,\n DEFAULT_GLOBAL_OPTIONS,\n DEFAULT_REALTIME_OPTIONS,\n} from './lib/constants'\nimport { fetchWithAuth } from './lib/fetch'\nimport { applySettingDefaults, validateSupabaseUrl } from './lib/helpers'\nimport { SupabaseAuthClient } from './lib/SupabaseAuthClient'\nimport type {\n Fetch,\n GenericSchema,\n SupabaseAuthClientOptions,\n SupabaseClientOptions,\n} from './lib/types'\nimport { GetRpcFunctionFilterBuilderByArgs } from './lib/rest/types/common/rpc'\n\n/**\n * Supabase Client.\n *\n * An isomorphic Javascript client for interacting with Postgres.\n */\nexport default class SupabaseClient<\n Database = any,\n // The second type parameter is also used for specifying db_schema, so we\n // support both cases.\n // TODO: Allow setting db_schema from ClientOptions.\n SchemaNameOrClientOptions extends\n | (string & keyof Omit<Database, '__InternalSupabase'>)\n | { PostgrestVersion: string } = 'public' extends keyof Omit<Database, '__InternalSupabase'>\n ? 'public'\n : string & keyof Omit<Database, '__InternalSupabase'>,\n SchemaName extends string &\n keyof Omit<Database, '__InternalSupabase'> = SchemaNameOrClientOptions extends string &\n keyof Omit<Database, '__InternalSupabase'>\n ? SchemaNameOrClientOptions\n : 'public' extends keyof Omit<Database, '__InternalSupabase'>\n ? 'public'\n : string & keyof Omit<Omit<Database, '__InternalSupabase'>, '__InternalSupabase'>,\n Schema extends Omit<Database, '__InternalSupabase'>[SchemaName] extends GenericSchema\n ? Omit<Database, '__InternalSupabase'>[SchemaName]\n : never = Omit<Database, '__InternalSupabase'>[SchemaName] extends GenericSchema\n ? Omit<Database, '__InternalSupabase'>[SchemaName]\n : never,\n ClientOptions extends { PostgrestVersion: string } = SchemaNameOrClientOptions extends string &\n keyof Omit<Database, '__InternalSupabase'>\n ? // If the version isn't explicitly set, look for it in the __InternalSupabase object to infer the right version\n Database extends { __InternalSupabase: { PostgrestVersion: string } }\n ? Database['__InternalSupabase']\n : // otherwise default to 12\n { PostgrestVersion: '12' }\n : SchemaNameOrClientOptions extends { PostgrestVersion: string }\n ? SchemaNameOrClientOptions\n : never,\n> {\n /**\n * Supabase Auth allows you to create and manage user sessions for access to data that is secured by access policies.\n */\n auth: SupabaseAuthClient\n realtime: RealtimeClient\n /**\n * Supabase Storage allows you to manage user-generated content, such as photos or videos.\n */\n storage: SupabaseStorageClient\n\n protected realtimeUrl: URL\n protected authUrl: URL\n protected storageUrl: URL\n protected functionsUrl: URL\n protected rest: PostgrestClient<Database, ClientOptions, SchemaName>\n protected storageKey: string\n protected fetch?: Fetch\n protected changedAccessToken?: string\n protected accessToken?: () => Promise<string | null>\n\n protected headers: Record<string, string>\n\n /**\n * Create a new client for use in the browser.\n *\n * @category Initializing\n *\n * @param supabaseUrl The unique Supabase URL which is supplied when you create a new project in your project dashboard.\n * @param supabaseKey The unique Supabase Key which is supplied when you create a new project in your project dashboard.\n * @param options.db.schema You can switch in between schemas. The schema needs to be on the list of exposed schemas inside Supabase.\n * @param options.auth.autoRefreshToken Set to \"true\" if you want to automatically refresh the token before expiring.\n * @param options.auth.persistSession Set to \"true\" if you want to automatically save the user session into local storage.\n * @param options.auth.detectSessionInUrl Set to \"true\" if you want to automatically detects OAuth grants in the URL and signs in the user.\n * @param options.realtime Options passed along to realtime-js constructor.\n * @param options.storage Options passed along to the storage-js constructor.\n * @param options.global.fetch A custom fetch implementation.\n * @param options.global.headers Any additional headers to send with each network request.\n *\n * @example Creating a client\n * ```js\n * import { createClient } from '@supabase/supabase-js'\n *\n * // Create a single supabase client for interacting with your database\n * const supabase = createClient('https://xyzcompany.supabase.co', 'publishable-or-anon-key')\n * ```\n *\n * @example With a custom domain\n * ```js\n * import { createClient } from '@supabase/supabase-js'\n *\n * // Use a custom domain as the supabase URL\n * const supabase = createClient('https://my-custom-domain.com', 'publishable-or-anon-key')\n * ```\n *\n * @example With additional parameters\n * ```js\n * import { createClient } from '@supabase/supabase-js'\n *\n * const options = {\n * db: {\n * schema: 'public',\n * },\n * auth: {\n * autoRefreshToken: true,\n * persistSession: true,\n * detectSessionInUrl: true\n * },\n * global: {\n * headers: { 'x-my-custom-header': 'my-app-name' },\n * },\n * }\n * const supabase = createClient(\"https://xyzcompany.supabase.co\", \"publishable-or-anon-key\", options)\n * ```\n *\n * @exampleDescription With custom schemas\n * By default the API server points to the `public` schema. You can enable other database schemas within the Dashboard.\n * Go to [Settings > API > Exposed schemas](/dashboard/project/_/settings/api) and add the schema which you want to expose to the API.\n *\n * Note: each client connection can only access a single schema, so the code above can access the `other_schema` schema but cannot access the `public` schema.\n *\n * @example With custom schemas\n * ```js\n * import { createClient } from '@supabase/supabase-js'\n *\n * const supabase = createClient('https://xyzcompany.supabase.co', 'publishable-or-anon-key', {\n * // Provide a custom schema. Defaults to \"public\".\n * db: { schema: 'other_schema' }\n * })\n * ```\n *\n * @exampleDescription Custom fetch implementation\n * `supabase-js` uses the [`cross-fetch`](https://www.npmjs.com/package/cross-fetch) library to make HTTP requests,\n * but an alternative `fetch` implementation can be provided as an option.\n * This is most useful in environments where `cross-fetch` is not compatible (for instance Cloudflare Workers).\n *\n * @example Custom fetch implementation\n * ```js\n * import { createClient } from '@supabase/supabase-js'\n *\n * const supabase = createClient('https://xyzcompany.supabase.co', 'publishable-or-anon-key', {\n * global: { fetch: fetch.bind(globalThis) }\n * })\n * ```\n *\n * @exampleDescription React Native options with AsyncStorage\n * For React Native we recommend using `AsyncStorage` as the storage implementation for Supabase Auth.\n *\n * @example React Native options with AsyncStorage\n * ```js\n * import 'react-native-url-polyfill/auto'\n * import { createClient } from '@supabase/supabase-js'\n * import AsyncStorage from \"@react-native-async-storage/async-storage\";\n *\n * const supabase = createClient(\"https://xyzcompany.supabase.co\", \"publishable-or-anon-key\", {\n * auth: {\n * storage: AsyncStorage,\n * autoRefreshToken: true,\n * persistSession: true,\n * detectSessionInUrl: false,\n * },\n * });\n * ```\n *\n * @exampleDescription React Native options with Expo SecureStore\n * If you wish to encrypt the user's session information, you can use `aes-js` and store the encryption key in Expo SecureStore.\n * The `aes-js` library, a reputable JavaScript-only implementation of the AES encryption algorithm in CTR mode.\n * A new 256-bit encryption key is generated using the `react-native-get-random-values` library.\n * This key is stored inside Expo's SecureStore, while the value is encrypted and placed inside AsyncStorage.\n *\n * Please make sure that:\n * - You keep the `expo-secure-store`, `aes-js` and `react-native-get-random-values` libraries up-to-date.\n * - Choose the correct [`SecureStoreOptions`](https://docs.expo.dev/versions/latest/sdk/securestore/#securestoreoptions) for your app's needs.\n * E.g. [`SecureStore.WHEN_UNLOCKED`](https://docs.expo.dev/versions/latest/sdk/securestore/#securestorewhen_unlocked) regulates when the data can be accessed.\n * - Carefully consider optimizations or other modifications to the above example, as those can lead to introducing subtle security vulnerabilities.\n *\n * @example React Native options with Expo SecureStore\n * ```ts\n * import 'react-native-url-polyfill/auto'\n * import { createClient } from '@supabase/supabase-js'\n * import AsyncStorage from '@react-native-async-storage/async-storage';\n * import * as SecureStore from 'expo-secure-store';\n * import * as aesjs from 'aes-js';\n * import 'react-native-get-random-values';\n *\n * // As Expo's SecureStore does not support values larger than 2048\n * // bytes, an AES-256 key is generated and stored in SecureStore, while\n * // it is used to encrypt/decrypt values stored in AsyncStorage.\n * class LargeSecureStore {\n * private async _encrypt(key: string, value: string) {\n * const encryptionKey = crypto.getRandomValues(new Uint8Array(256 / 8));\n *\n * const cipher = new aesjs.ModeOfOperation.ctr(encryptionKey, new aesjs.Counter(1));\n * const encryptedBytes = cipher.encrypt(aesjs.utils.utf8.toBytes(value));\n *\n * await SecureStore.setItemAsync(key, aesjs.utils.hex.fromBytes(encryptionKey));\n *\n * return aesjs.utils.hex.fromBytes(encryptedBytes);\n * }\n *\n * private async _decrypt(key: string, value: string) {\n * const encryptionKeyHex = await SecureStore.getItemAsync(key);\n * if (!encryptionKeyHex) {\n * return encryptionKeyHex;\n * }\n *\n * const cipher = new aesjs.ModeOfOperation.ctr(aesjs.utils.hex.toBytes(encryptionKeyHex), new aesjs.Counter(1));\n * const decryptedBytes = cipher.decrypt(aesjs.utils.hex.toBytes(value));\n *\n * return aesjs.utils.utf8.fromBytes(decryptedBytes);\n * }\n *\n * async getItem(key: string) {\n * const encrypted = await AsyncStorage.getItem(key);\n * if (!encrypted) { return encrypted; }\n *\n * return await this._decrypt(key, encrypted);\n * }\n *\n * async removeItem(key: string) {\n * await AsyncStorage.removeItem(key);\n * await SecureStore.deleteItemAsync(key);\n * }\n *\n * async setItem(key: string, value: string) {\n * const encrypted = await this._encrypt(key, value);\n *\n * await AsyncStorage.setItem(key, encrypted);\n * }\n * }\n *\n * const supabase = createClient(\"https://xyzcompany.supabase.co\", \"publishable-or-anon-key\", {\n * auth: {\n * storage: new LargeSecureStore(),\n * autoRefreshToken: true,\n * persistSession: true,\n * detectSessionInUrl: false,\n * },\n * });\n * ```\n *\n * @example With a database query\n * ```ts\n * import { createClient } from '@supabase/supabase-js'\n *\n * const supabase = createClient('https://xyzcompany.supabase.co', 'public-anon-key')\n *\n * const { data } = await supabase.from('profiles').select('*')\n * ```\n */\n constructor(\n protected supabaseUrl: string,\n protected supabaseKey: string,\n options?: SupabaseClientOptions<SchemaName>\n ) {\n const baseUrl = validateSupabaseUrl(supabaseUrl)\n if (!supabaseKey) throw new Error('supabaseKey is required.')\n\n this.realtimeUrl = new URL('realtime/v1', baseUrl)\n this.realtimeUrl.protocol = this.realtimeUrl.protocol.replace('http', 'ws')\n this.authUrl = new URL('auth/v1', baseUrl)\n this.storageUrl = new URL('storage/v1', baseUrl)\n this.functionsUrl = new URL('functions/v1', baseUrl)\n\n // default storage key uses the supabase project ref as a namespace\n const defaultStorageKey = `sb-${baseUrl.hostname.split('.')[0]}-auth-token`\n const DEFAULTS = {\n db: DEFAULT_DB_OPTIONS,\n realtime: DEFAULT_REALTIME_OPTIONS,\n auth: { ...DEFAULT_AUTH_OPTIONS, storageKey: defaultStorageKey },\n global: DEFAULT_GLOBAL_OPTIONS,\n }\n\n const settings = applySettingDefaults(options ?? {}, DEFAULTS)\n\n this.storageKey = settings.auth.storageKey ?? ''\n this.headers = settings.global.headers ?? {}\n\n if (!settings.accessToken) {\n this.auth = this._initSupabaseAuthClient(\n settings.auth ?? {},\n this.headers,\n settings.global.fetch\n )\n } else {\n this.accessToken = settings.accessToken\n\n this.auth = new Proxy<SupabaseAuthClient>({} as any, {\n get: (_, prop) => {\n throw new Error(\n `@supabase/supabase-js: Supabase Client is configured with the accessToken option, accessing supabase.auth.${String(\n prop\n )} is not possible`\n )\n },\n })\n }\n\n this.fetch = fetchWithAuth(supabaseKey, this._getAccessToken.bind(this), settings.global.fetch)\n this.realtime = this._initRealtimeClient({\n headers: this.headers,\n accessToken: this._getAccessToken.bind(this),\n ...settings.realtime,\n })\n if (this.accessToken) {\n // Start auth immediately to avoid race condition with channel subscriptions\n // Wrap Promise to avoid Firefox extension cross-context Promise access errors\n Promise.resolve(this.accessToken())\n .then((token) => this.realtime.setAuth(token))\n .catch((e) => console.warn('Failed to set initial Realtime auth token:', e))\n }\n\n this.rest = new PostgrestClient(new URL('rest/v1', baseUrl).href, {\n headers: this.headers,\n schema: settings.db.schema,\n fetch: this.fetch,\n timeout: settings.db.timeout,\n urlLengthLimit: settings.db.urlLengthLimit,\n })\n\n this.storage = new SupabaseStorageClient(\n this.storageUrl.href,\n this.headers,\n this.fetch,\n options?.storage\n )\n\n if (!settings.accessToken) {\n this._listenForAuthEvents()\n }\n }\n\n /**\n * Supabase Functions allows you to deploy and invoke edge functions.\n */\n get functions(): FunctionsClient {\n return new FunctionsClient(this.functionsUrl.href, {\n headers: this.headers,\n customFetch: this.fetch,\n })\n }\n\n // NOTE: signatures must be kept in sync with PostgrestClient.from\n from<\n TableName extends string & keyof Schema['Tables'],\n Table extends Schema['Tables'][TableName],\n >(relation: TableName): PostgrestQueryBuilder<ClientOptions, Schema, Table, TableName>\n from<ViewName extends string & keyof Schema['Views'], View extends Schema['Views'][ViewName]>(\n relation: ViewName\n ): PostgrestQueryBuilder<ClientOptions, Schema, View, ViewName>\n /**\n * Perform a query on a table or a view.\n *\n * @param relation - The table or view name to query\n */\n from(relation: string): PostgrestQueryBuilder<ClientOptions, Schema, any> {\n return this.rest.from(relation)\n }\n\n // NOTE: signatures must be kept in sync with PostgrestClient.schema\n /**\n * Select a schema to query or perform an function (rpc) call.\n *\n * The schema needs to be on the list of exposed schemas inside Supabase.\n *\n * @param schema - The schema to query\n */\n schema<DynamicSchema extends string & keyof Omit<Database, '__InternalSupabase'>>(\n schema: DynamicSchema\n ): PostgrestClient<\n Database,\n ClientOptions,\n DynamicSchema,\n Database[DynamicSchema] extends GenericSchema ? Database[DynamicSchema] : any\n > {\n return this.rest.schema<DynamicSchema>(schema)\n }\n\n // NOTE: signatures must be kept in sync with PostgrestClient.rpc\n /**\n * Perform a function call.\n *\n * @param fn - The function name to call\n * @param args - The arguments to pass to the function call\n * @param options - Named parameters\n * @param options.head - When set to `true`, `data` will not be returned.\n * Useful if you only need the count.\n * @param options.get - When set to `true`, the function will be called with\n * read-only access mode.\n * @param options.count - Count algorithm to use to count rows returned by the\n * function. Only applicable for [set-returning\n * functions](https://www.postgresql.org/docs/current/functions-srf.html).\n *\n * `\"exact\"`: Exact but slow count algorithm. Performs a `COUNT(*)` under the\n * hood.\n *\n * `\"planned\"`: Approximated but fast count algorithm. Uses the Postgres\n * statistics under the hood.\n *\n * `\"estimated\"`: Uses exact count for low numbers and planned count for high\n * numbers.\n */\n rpc<\n FnName extends string & keyof Schema['Functions'],\n Args extends Schema['Functions'][FnName]['Args'] = never,\n FilterBuilder extends GetRpcFunctionFilterBuilderByArgs<\n Schema,\n FnName,\n Args\n > = GetRpcFunctionFilterBuilderByArgs<Schema, FnName, Args>,\n >(\n fn: FnName,\n args: Args = {} as Args,\n options: {\n head?: boolean\n get?: boolean\n count?: 'exact' | 'planned' | 'estimated'\n } = {\n head: false,\n get: false,\n count: undefined,\n }\n ): PostgrestFilterBuilder<\n ClientOptions,\n Schema,\n FilterBuilder['Row'],\n FilterBuilder['Result'],\n FilterBuilder['RelationName'],\n FilterBuilder['Relationships'],\n 'RPC'\n > {\n return this.rest.rpc(fn, args, options) as unknown as PostgrestFilterBuilder<\n ClientOptions,\n Schema,\n FilterBuilder['Row'],\n FilterBuilder['Result'],\n FilterBuilder['RelationName'],\n FilterBuilder['Relationships'],\n 'RPC'\n >\n }\n\n /**\n * Creates a Realtime channel with Broadcast, Presence, and Postgres Changes.\n *\n * @param {string} name - The name of the Realtime channel.\n * @param {Object} opts - The options to pass to the Realtime channel.\n *\n */\n channel(name: string, opts: RealtimeChannelOptions = { config: {} }): RealtimeChannel {\n return this.realtime.channel(name, opts)\n }\n\n /**\n * Returns all Realtime channels.\n */\n getChannels(): RealtimeChannel[] {\n return this.realtime.getChannels()\n }\n\n /**\n * Unsubscribes and removes Realtime channel from Realtime client.\n *\n * @param {RealtimeChannel} channel - The name of the Realtime channel.\n *\n */\n removeChannel(channel: RealtimeChannel): Promise<'ok' | 'timed out' | 'error'> {\n return this.realtime.removeChannel(channel)\n }\n\n /**\n * Unsubscribes and removes all Realtime channels from Realtime client.\n */\n removeAllChannels(): Promise<('ok' | 'timed out' | 'error')[]> {\n return this.realtime.removeAllChannels()\n }\n\n private async _getAccessToken() {\n if (this.accessToken) {\n return await this.accessToken()\n }\n\n const { data } = await this.auth.getSession()\n\n return data.session?.access_token ?? this.supabaseKey\n }\n\n private _initSupabaseAuthClient(\n {\n autoRefreshToken,\n persistSession,\n detectSessionInUrl,\n storage,\n userStorage,\n storageKey,\n flowType,\n lock,\n debug,\n throwOnError,\n }: SupabaseAuthClientOptions,\n headers?: Record<string, string>,\n fetch?: Fetch\n ) {\n const authHeaders = {\n Authorization: `Bearer ${this.supabaseKey}`,\n apikey: `${this.supabaseKey}`,\n }\n return new SupabaseAuthClient({\n url: this.authUrl.href,\n headers: { ...authHeaders, ...headers },\n storageKey: storageKey,\n autoRefreshToken,\n persistSession,\n detectSessionInUrl,\n storage,\n userStorage,\n flowType,\n lock,\n debug,\n throwOnError,\n fetch,\n // auth checks if there is a custom authorizaiton header using this flag\n // so it knows whether to return an error when getUser is called with no session\n hasCustomAuthorizationHeader: Object.keys(this.headers).some(\n (key) => key.toLowerCase() === 'authorization'\n ),\n })\n }\n\n private _initRealtimeClient(options: RealtimeClientOptions) {\n return new RealtimeClient(this.realtimeUrl.href, {\n ...options,\n params: { ...{ apikey: this.supabaseKey }, ...options?.params },\n })\n }\n\n private _listenForAuthEvents() {\n const data = this.auth.onAuthStateChange((event, session) => {\n this._handleTokenChanged(event, 'CLIENT', session?.access_token)\n })\n return data\n }\n\n private _handleTokenChanged(\n event: AuthChangeEvent,\n source: 'CLIENT' | 'STORAGE',\n token?: string\n ) {\n if (\n (event === 'TOKEN_REFRESHED' || event === 'SIGNED_IN') &&\n this.changedAccessToken !== token\n ) {\n this.changedAccessToken = token\n this.realtime.setAuth(token)\n } else if (event === 'SIGNED_OUT') {\n this.realtime.setAuth()\n if (source == 'STORAGE') this.auth.signOut()\n this.changedAccessToken = undefined\n }\n }\n}\n","import SupabaseClient from './SupabaseClient'\nimport type { SupabaseClientOptions } from './lib/types'\n\nexport * from '@supabase/auth-js'\nexport type { User as AuthUser, Session as AuthSession } from '@supabase/auth-js'\nexport type {\n PostgrestResponse,\n PostgrestSingleResponse,\n PostgrestMaybeSingleResponse,\n} from '@supabase/postgrest-js'\nexport { PostgrestError } from '@supabase/postgrest-js'\nexport type { FunctionInvokeOptions } from '@supabase/functions-js'\nexport {\n FunctionsHttpError,\n FunctionsFetchError,\n FunctionsRelayError,\n FunctionsError,\n FunctionRegion,\n} from '@supabase/functions-js'\nexport * from '@supabase/realtime-js'\nexport { default as SupabaseClient } from './SupabaseClient'\nexport type {\n SupabaseClientOptions,\n QueryResult,\n QueryData,\n QueryError,\n DatabaseWithoutInternals,\n} from './lib/types'\n\n/**\n * Creates a new Supabase Client.\n *\n * @example\n * ```ts\n * import { createClient } from '@supabase/supabase-js'\n *\n * const supabase = createClient('https://xyzcompany.supabase.co', 'public-anon-key')\n * const { data, error } = await supabase.from('profiles').select('*')\n * ```\n */\nexport const createClient = <\n Database = any,\n SchemaNameOrClientOptions extends\n | (string & keyof Omit<Database, '__InternalSupabase'>)\n | { PostgrestVersion: string } = 'public' extends keyof Omit<Database, '__InternalSupabase'>\n ? 'public'\n : string & keyof Omit<Database, '__InternalSupabase'>,\n SchemaName extends string &\n keyof Omit<Database, '__InternalSupabase'> = SchemaNameOrClientOptions extends string &\n keyof Omit<Database, '__InternalSupabase'>\n ? SchemaNameOrClientOptions\n : 'public' extends keyof Omit<Database, '__InternalSupabase'>\n ? 'public'\n : string & keyof Omit<Omit<Database, '__InternalSupabase'>, '__InternalSupabase'>,\n>(\n supabaseUrl: string,\n supabaseKey: string,\n options?: SupabaseClientOptions<SchemaName>\n): SupabaseClient<Database, SchemaNameOrClientOptions, SchemaName> => {\n return new SupabaseClient<Database, SchemaNameOrClientOptions, SchemaName>(\n supabaseUrl,\n supabaseKey,\n options\n )\n}\n\n// Check for Node.js <= 18 deprecation\nfunction shouldShowDeprecationWarning(): boolean {\n // Skip in browser environments\n if (typeof window !== 'undefined') {\n return false\n }\n\n // Skip if process is not available (e.g., Edge Runtime)\n // Use dynamic property access to avoid Next.js Edge Runtime static analysis warnings\n const _process = (globalThis as any)['process']\n if (!_process) {\n return false\n }\n\n const processVersion = _process['version']\n if (processVersion === undefined || processVersion === null) {\n return false\n }\n\n const versionMatch = processVersion.match(/^v(\\d+)\\./)\n if (!versionMatch) {\n return false\n }\n\n const majorVersion = parseInt(versionMatch[1], 10)\n return majorVersion <= 18\n}\n\nif (shouldShowDeprecationWarning()) {\n console.warn(\n `⚠️ Node.js 18 and below are deprecated and will no longer be supported in future versions of @supabase/supabase-js. ` +\n `Please upgrade to Node.js 20 or later. ` +\n `For more information, visit: https://github.com/orgs/supabase/discussions/37217`\n )\n}\n"],"mappings":";;;;;;;;;;;AAMA,MAAa,UAAU;;;;ACDvB,IAAI,SAAS;AAEb,IAAI,OAAO,SAAS,YAClB,UAAS;SACA,OAAO,aAAa,YAC7B,UAAS;SACA,OAAO,cAAc,eAAe,UAAU,YAAY,cACnE,UAAS;IAET,UAAS;AAGX,MAAa,kBAAkB,EAAE,iBAAiB,eAAe,OAAO,GAAG,WAAW;AAEtF,MAAa,yBAAyB,EACpC,SAAS,iBACV;AAED,MAAa,qBAAqB,EAChC,QAAQ,UACT;AAED,MAAaA,uBAAkD;CAC7D,kBAAkB;CAClB,gBAAgB;CAChB,oBAAo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