@motherbase/client 1.5.0 → 1.5.2

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.
Files changed (94) hide show
  1. package/README.md +25 -1
  2. package/dist/admin.d.ts +131 -0
  3. package/dist/admin.d.ts.map +1 -0
  4. package/dist/admin.js +121 -0
  5. package/dist/admin.js.map +1 -0
  6. package/dist/auth.d.ts +463 -0
  7. package/dist/auth.d.ts.map +1 -0
  8. package/dist/auth.js +884 -0
  9. package/dist/auth.js.map +1 -0
  10. package/dist/channel.d.ts +129 -0
  11. package/dist/channel.d.ts.map +1 -0
  12. package/dist/channel.js +215 -0
  13. package/dist/channel.js.map +1 -0
  14. package/dist/compat.d.ts +40 -0
  15. package/dist/compat.d.ts.map +1 -0
  16. package/dist/compat.js +100 -0
  17. package/dist/compat.js.map +1 -0
  18. package/dist/cookie.d.ts +68 -0
  19. package/dist/cookie.d.ts.map +1 -0
  20. package/dist/cookie.js +152 -0
  21. package/dist/cookie.js.map +1 -0
  22. package/dist/database.d.ts +188 -0
  23. package/dist/database.d.ts.map +1 -0
  24. package/dist/database.js +2 -0
  25. package/dist/database.js.map +1 -0
  26. package/dist/functions.d.ts +60 -0
  27. package/dist/functions.d.ts.map +1 -0
  28. package/dist/functions.js +75 -0
  29. package/dist/functions.js.map +1 -0
  30. package/dist/http.d.ts +122 -0
  31. package/dist/http.d.ts.map +1 -0
  32. package/dist/http.js +206 -0
  33. package/dist/http.js.map +1 -0
  34. package/dist/index.d.ts +215 -0
  35. package/dist/index.d.ts.map +1 -0
  36. package/dist/index.js +365 -0
  37. package/dist/index.js.map +1 -0
  38. package/dist/mfa.d.ts +126 -0
  39. package/dist/mfa.d.ts.map +1 -0
  40. package/dist/mfa.js +167 -0
  41. package/dist/mfa.js.map +1 -0
  42. package/dist/organization.d.ts +234 -0
  43. package/dist/organization.d.ts.map +1 -0
  44. package/dist/organization.js +157 -0
  45. package/dist/organization.js.map +1 -0
  46. package/dist/passkey.d.ts +59 -0
  47. package/dist/passkey.d.ts.map +1 -0
  48. package/dist/passkey.js +87 -0
  49. package/dist/passkey.js.map +1 -0
  50. package/dist/pkce.d.ts +13 -0
  51. package/dist/pkce.d.ts.map +1 -0
  52. package/dist/pkce.js +52 -0
  53. package/dist/pkce.js.map +1 -0
  54. package/dist/plugin-endpoint.d.ts +20 -0
  55. package/dist/plugin-endpoint.d.ts.map +1 -0
  56. package/dist/plugin-endpoint.js +24 -0
  57. package/dist/plugin-endpoint.js.map +1 -0
  58. package/dist/postgrest.d.ts +326 -0
  59. package/dist/postgrest.d.ts.map +1 -0
  60. package/dist/postgrest.js +625 -0
  61. package/dist/postgrest.js.map +1 -0
  62. package/dist/query.d.ts +97 -0
  63. package/dist/query.d.ts.map +1 -0
  64. package/dist/query.js +94 -0
  65. package/dist/query.js.map +1 -0
  66. package/dist/realtime.d.ts +114 -0
  67. package/dist/realtime.d.ts.map +1 -0
  68. package/dist/realtime.js +376 -0
  69. package/dist/realtime.js.map +1 -0
  70. package/dist/session.d.ts +47 -0
  71. package/dist/session.d.ts.map +1 -0
  72. package/dist/session.js +136 -0
  73. package/dist/session.js.map +1 -0
  74. package/dist/sso.d.ts +147 -0
  75. package/dist/sso.d.ts.map +1 -0
  76. package/dist/sso.js +35 -0
  77. package/dist/sso.js.map +1 -0
  78. package/dist/storage.d.ts +268 -0
  79. package/dist/storage.d.ts.map +1 -0
  80. package/dist/storage.js +441 -0
  81. package/dist/storage.js.map +1 -0
  82. package/dist/testing.d.ts +38 -0
  83. package/dist/testing.d.ts.map +1 -0
  84. package/dist/testing.js +50 -0
  85. package/dist/testing.js.map +1 -0
  86. package/dist/types.d.ts +353 -0
  87. package/dist/types.d.ts.map +1 -0
  88. package/dist/types.js +2 -0
  89. package/dist/types.js.map +1 -0
  90. package/dist/warn.d.ts +2 -0
  91. package/dist/warn.d.ts.map +1 -0
  92. package/dist/warn.js +23 -0
  93. package/dist/warn.js.map +1 -0
  94. package/package.json +4 -2
package/dist/auth.d.ts ADDED
@@ -0,0 +1,463 @@
1
+ import { MfaClient } from './mfa.js';
2
+ import { AuthAdminClient } from './admin.js';
3
+ import { type VerifierStore } from './pkce.js';
4
+ import { OrganizationClient } from './organization.js';
5
+ import { PasskeyClient } from './passkey.js';
6
+ import { SsoClient } from './sso.js';
7
+ import type { HttpClient } from './http.js';
8
+ import type { SessionStore } from './session.js';
9
+ import type { AuthChangeListener, MotherbaseResponse, Session, User, UserIdentity } from './types.js';
10
+ /**
11
+ * The CAPTCHA response token from the hCaptcha or Turnstile widget. Required
12
+ * by every guarded endpoint once the project turns CAPTCHA protection on
13
+ * (Studio → Authentication → Attack Protection), exactly as in supabase-js.
14
+ */
15
+ export interface CaptchaOptions {
16
+ captchaToken?: string;
17
+ }
18
+ export interface SignUpCredentials {
19
+ email: string;
20
+ password: string;
21
+ /** Optional extra profile field supported by the backend. */
22
+ username?: string;
23
+ options?: CaptchaOptions & {
24
+ /** Where the email-verification link sends the user. Must be an allowed redirect URL. */
25
+ emailRedirectTo?: string;
26
+ };
27
+ }
28
+ export interface SignInWithPasswordCredentials {
29
+ email: string;
30
+ password: string;
31
+ options?: CaptchaOptions;
32
+ }
33
+ export interface SignInWithOtpCredentials {
34
+ email?: string;
35
+ /** E.164 phone number. Routes to the SMS one-time code flow instead. */
36
+ phone?: string;
37
+ options?: CaptchaOptions;
38
+ }
39
+ export interface SignInAnonymouslyCredentials {
40
+ options?: CaptchaOptions & {
41
+ /** Profile fields for the guest, stored like `updateUser({ data })`. */
42
+ data?: Record<string, unknown>;
43
+ };
44
+ }
45
+ export interface VerifyOtpParams {
46
+ email?: string;
47
+ /** E.164 phone number, when the code was sent by SMS. */
48
+ phone?: string;
49
+ /** The code that was sent. Named `token` for supabase-js parity. */
50
+ token: string;
51
+ /**
52
+ * supabase-js verification type. The channel actually follows the identifier
53
+ * you pass; this only disambiguates if both are present. `recovery` and
54
+ * `email_change` are not routed: use `resetPassword` for the first, and
55
+ * email changes are not supported.
56
+ */
57
+ type?: 'email' | 'sms' | 'phone_change' | 'recovery' | 'email_change' | 'signup';
58
+ }
59
+ export interface SignInWithOAuthCredentials {
60
+ /** Social provider id, e.g. 'google' or 'apple'. Must be enabled on the backend. */
61
+ provider: string;
62
+ options?: {
63
+ /** Where the provider should send the user back to after auth. */
64
+ redirectTo?: string;
65
+ /** Space-separated OAuth scopes. */
66
+ scopes?: string;
67
+ /** Skip the automatic `window.location` redirect and just return the URL. */
68
+ skipBrowserRedirect?: boolean;
69
+ };
70
+ }
71
+ export interface DeleteUserAttributes {
72
+ /** Required unless the session is already "fresh" (i.e. just re-authenticated). */
73
+ password?: string;
74
+ /** Deletion-confirmation token, when the backend's delete flow requires an email confirmation step. */
75
+ token?: string;
76
+ callbackURL?: string;
77
+ }
78
+ export interface UpdateUserAttributes {
79
+ /**
80
+ * Give an anonymous user an email address, which makes it permanent. The id
81
+ * does not change, so everything the guest owned stays owned. A permanent
82
+ * user cannot change its address through this call.
83
+ */
84
+ email?: string;
85
+ /**
86
+ * New password. Replacing an existing one takes either `currentPassword` or
87
+ * the `nonce` that `reauthenticate()` emailed. A user with no password yet
88
+ * (a converted guest, a social sign-in) needs neither.
89
+ */
90
+ password?: string;
91
+ currentPassword?: string;
92
+ /** The code from `reauthenticate()`. */
93
+ nonce?: string;
94
+ /** Arbitrary profile fields (name, image, or any custom additional field). */
95
+ data?: Record<string, unknown>;
96
+ }
97
+ export interface PasswordSignInData {
98
+ user: User | null;
99
+ session: Session | null;
100
+ /** The password was accepted, but no authenticated session exists yet. */
101
+ twoFactorRequired?: boolean;
102
+ twoFactorMethods?: string[];
103
+ }
104
+ /**
105
+ * Read the token an OAuth callback left in the URL fragment and return the URL
106
+ * with it removed, so a reload or a shared link cannot replay it.
107
+ *
108
+ * The provider callback cannot answer the SDK with a JSON body: it is a browser
109
+ * redirect. The backend therefore appends `#access_token=…` to the redirect it
110
+ * issues, the same implicit flow supabase-js reads. Exported for testing.
111
+ */
112
+ export declare function readAccessTokenFromUrl(href: string): {
113
+ accessToken: string;
114
+ cleanedHref: string;
115
+ } | null;
116
+ export interface Subscription {
117
+ unsubscribe(): void;
118
+ }
119
+ export interface AuthClientOptions {
120
+ /** `pkce` makes OAuth and SSO redirects come back with `?code=` for `exchangeCodeForSession`. */
121
+ flowType?: 'implicit' | 'pkce';
122
+ /** Where the PKCE verifier waits out the redirect. Defaults to localStorage, else memory. */
123
+ verifiers?: VerifierStore;
124
+ }
125
+ /**
126
+ * Supabase-compatible auth client. Maps supabase-js method names onto the
127
+ * Motherbase auth endpoints and reuses the existing token/refresh/session-store
128
+ * machinery. Returns `{ data, error }` and never throws for expected failures.
129
+ */
130
+ export declare class AuthClient {
131
+ private readonly http;
132
+ private readonly store;
133
+ /**
134
+ * Two-factor, shaped like `supabase.auth.mfa`. The server has shipped TOTP
135
+ * from the start; this is the namespace that makes it reachable.
136
+ */
137
+ readonly mfa: MfaClient;
138
+ /**
139
+ * User administration for server code holding a secret key. Present on every
140
+ * client, because whether the key is secret is a server-side fact: calling
141
+ * these with a publishable key is a 401, not a missing method.
142
+ */
143
+ readonly admin: AuthAdminClient;
144
+ /**
145
+ * End-user organizations, members, invitations and teams. Not part of
146
+ * supabase-js; method names follow Better Auth's organization client.
147
+ */
148
+ readonly organization: OrganizationClient;
149
+ /** The signed-in user's passkeys. Signing in with one is `signInWithPasskey`. */
150
+ readonly passkey: PasskeyClient;
151
+ /** Identity providers registered at runtime. Signing in through one is `signInWithSSO`. */
152
+ readonly sso: SsoClient;
153
+ private autoRefreshTimer;
154
+ private readonly flowType;
155
+ private readonly verifiers;
156
+ constructor(http: HttpClient, store: SessionStore, options?: AuthClientOptions);
157
+ signUp(credentials: SignUpCredentials): Promise<MotherbaseResponse<{
158
+ user: User | null;
159
+ session: Session | null;
160
+ }>>;
161
+ signInWithPassword(credentials: SignInWithPasswordCredentials): Promise<MotherbaseResponse<PasswordSignInData>>;
162
+ /**
163
+ * Sign in as a new guest, supabase-js style. The project must allow
164
+ * anonymous sign-ins (Studio → Authentication → Sign In / Providers).
165
+ *
166
+ * The guest is a real user whose `is_anonymous` is true, and RLS sees the
167
+ * same flag as the `is_anonymous` claim. Make it permanent without changing
168
+ * its id with `updateUser({ email })` or `linkIdentity()`.
169
+ */
170
+ signInAnonymously(credentials?: SignInAnonymouslyCredentials): Promise<MotherbaseResponse<{
171
+ user: User | null;
172
+ session: Session | null;
173
+ }>>;
174
+ /**
175
+ * Email the signed-in user a one-time nonce, then pass it to
176
+ * `updateUser({ password, nonce })`. GoTrue's "secure password change".
177
+ */
178
+ reauthenticate(): Promise<MotherbaseResponse<{
179
+ user: null;
180
+ session: null;
181
+ }>>;
182
+ /**
183
+ * Request a password-reset OTP by email. Always resolves successfully
184
+ * (whether or not the email is registered) to avoid leaking account
185
+ * existence; check `error` only for transport/server failures.
186
+ */
187
+ resetPasswordForEmail(email: string, options?: CaptchaOptions): Promise<{
188
+ error: MotherbaseResponse<null>['error'];
189
+ }>;
190
+ /** Complete a password reset using the OTP sent to the user's email. */
191
+ resetPassword(args: {
192
+ email: string;
193
+ otp: string;
194
+ password: string;
195
+ }): Promise<{
196
+ error: MotherbaseResponse<null>['error'];
197
+ }>;
198
+ /**
199
+ * Send a one-time sign-in code, by email or by SMS. Pair with `verifyOtp` to
200
+ * complete the sign-in.
201
+ *
202
+ * `{ phone }` routes to the phone-number plugin, which the project has to
203
+ * have enabled with an SMS sender configured; without one the call resolves
204
+ * with the backend's error rather than pretending a code was sent.
205
+ */
206
+ signInWithOtp(credentials: SignInWithOtpCredentials): Promise<{
207
+ data: Record<string, never>;
208
+ error: MotherbaseResponse<null>['error'];
209
+ }>;
210
+ /**
211
+ * Send the one-time code again, supabase-js style.
212
+ *
213
+ * supabase-js names the flows `signup` (confirm a new address), `email_change`
214
+ * and `recovery`; Better Auth names them `email-verification` and
215
+ * `forget-password`. The mapping lives here so ported code keeps working.
216
+ * `sms` and `phone_change` re-send an SMS code through the phone-number flow.
217
+ */
218
+ resend(params: {
219
+ type: 'signup' | 'email_change' | 'recovery' | 'sms' | 'phone_change';
220
+ email?: string;
221
+ phone?: string;
222
+ }): Promise<{
223
+ data: Record<string, never>;
224
+ error: MotherbaseResponse<null>['error'];
225
+ }>;
226
+ /**
227
+ * Complete a `signInWithOtp` sign-in with the code that was sent.
228
+ *
229
+ * The channel follows the identifier, as in supabase-js: `{ phone }` verifies
230
+ * an SMS code, `{ email }` an email one. `type` is accepted for signature
231
+ * parity and only disambiguates when both are somehow present.
232
+ */
233
+ verifyOtp(params: VerifyOtpParams): Promise<MotherbaseResponse<{
234
+ user: User | null;
235
+ session: Session | null;
236
+ }>>;
237
+ /**
238
+ * Start an OAuth sign-in with a configured social provider. Resolves with the
239
+ * provider's authorize URL and, in a browser, redirects to it immediately
240
+ * unless `options.skipBrowserRedirect` is set.
241
+ */
242
+ signInWithOAuth(credentials: SignInWithOAuthCredentials): Promise<MotherbaseResponse<{
243
+ provider: string;
244
+ url: string | null;
245
+ }>>;
246
+ /**
247
+ * Sign in with a passkey saved on this device or a synced one. Opens the
248
+ * browser's passkey prompt; dismissing it resolves with an error, not a throw.
249
+ * Needs Auth · Passkey on and a browser (see `auth.passkey`).
250
+ */
251
+ signInWithPasskey(): Promise<MotherbaseResponse<{
252
+ user: User | null;
253
+ session: Session | null;
254
+ }>>;
255
+ /**
256
+ * Start an enterprise SSO sign-in. Identify the provider by the user's email
257
+ * domain, by an explicit `domain`, or by `providerId` when you already know
258
+ * which one to use.
259
+ *
260
+ * Resolves with the identity provider's URL and, in a browser, redirects to it
261
+ * unless `options.skipBrowserRedirect` is set. The project must have the SSO
262
+ * plugin enabled and at least one provider registered (Studio →
263
+ * Authentication → Organizations & SSO).
264
+ */
265
+ signInWithSSO(params: {
266
+ domain?: string;
267
+ email?: string;
268
+ providerId?: string;
269
+ organizationSlug?: string;
270
+ options?: {
271
+ redirectTo?: string;
272
+ skipBrowserRedirect?: boolean;
273
+ };
274
+ }): Promise<MotherbaseResponse<{
275
+ url: string | null;
276
+ }>>;
277
+ /**
278
+ * Update the signed-in user's profile fields and/or password. Password
279
+ * changes require `currentPassword` (a Better Auth requirement. There is no
280
+ * blind password overwrite from an authenticated session).
281
+ */
282
+ updateUser(attributes: UpdateUserAttributes): Promise<MotherbaseResponse<{
283
+ user: User | null;
284
+ }>>;
285
+ /**
286
+ * Permanently delete the signed-in user's account. Not part of the
287
+ * supabase-js client surface (there it's admin-only). Kept here because
288
+ * self-service account deletion is a real product need. Requires the
289
+ * backend's `delete-user` flow to be enabled; clears the local session on
290
+ * success.
291
+ */
292
+ deleteUser(attributes?: DeleteUserAttributes): Promise<{
293
+ error: MotherbaseResponse<null>['error'];
294
+ }>;
295
+ /**
296
+ * Adopt an externally-obtained access token as the current session (e.g. one
297
+ * captured from an OAuth redirect). Validates it against the server before
298
+ * persisting. `refresh_token` is accepted for supabase-js signature parity
299
+ * and unused: Better Auth bearer sessions have none.
300
+ */
301
+ setSession(currentSession: {
302
+ access_token: string;
303
+ refresh_token?: string;
304
+ }): Promise<MotherbaseResponse<{
305
+ user: User | null;
306
+ session: Session | null;
307
+ }>>;
308
+ signOut(): Promise<{
309
+ error: MotherbaseResponse<null>['error'];
310
+ }>;
311
+ /**
312
+ * Finish an OAuth / SSO sign-in after the provider redirected back.
313
+ *
314
+ * `signInWithOAuth` only starts the flow; the session is created during the
315
+ * redirect the browser makes to the backend callback, so the SDK has to pick
316
+ * it up from the URL the browser landed on. Call this once on the page you
317
+ * pointed `redirectTo` at (or on app start, which is where supabase-js does
318
+ * the equivalent). Without it the user is signed in on the backend and signed
319
+ * out in your app.
320
+ *
321
+ * Resolves with a null session and no error when there is nothing to read, so
322
+ * it is safe to call on every page load.
323
+ */
324
+ getSessionFromUrl(href?: string): Promise<MotherbaseResponse<{
325
+ user: User | null;
326
+ session: Session | null;
327
+ }>>;
328
+ /**
329
+ * Finish a PKCE sign-in: trade the `?code=` the provider redirect came back
330
+ * with for the session. Needs the verifier `signInWithOAuth` stored, so it
331
+ * works once, in the browser that started the flow.
332
+ */
333
+ exchangeCodeForSession(authCode: string): Promise<MotherbaseResponse<{
334
+ user: User | null;
335
+ session: Session | null;
336
+ }>>;
337
+ /**
338
+ * The redirect a flow should use. Implicit: as given. PKCE: with a fresh
339
+ * challenge on it, the verifier stored for `exchangeCodeForSession`; the
340
+ * challenge rides on the redirect URL, so PKCE needs one, and in a browser
341
+ * the current page stands in when none is given.
342
+ */
343
+ private redirectForFlow;
344
+ /** Fetch the current user from Better Auth (requires a valid session). */
345
+ getUser(): Promise<MotherbaseResponse<{
346
+ user: User | null;
347
+ }>>;
348
+ /**
349
+ * NEVER USE FOR AN AUTHORIZATION DECISION. Use {@link getUser} instead.
350
+ *
351
+ * The locally-held session, if any (no network call). It is whatever the
352
+ * caller's cookie or storage said, parsed: unsigned JSON the browser sent,
353
+ * which anyone can set by hand. `session.user.id`, `.email` and `.role` are
354
+ * therefore attacker-controlled, and an admin allowlist checked against
355
+ * them is checked against nothing.
356
+ *
357
+ * Reads and writes through `from()` are unaffected: they carry the access
358
+ * token to the backend, which verifies it under RLS. It is the decisions
359
+ * your own app takes from `session.user` that are forgeable.
360
+ *
361
+ * `getUser()` costs one round trip and returns the user the backend
362
+ * confirms, in the same `{ data, error }` shape. Prefer it everywhere but a
363
+ * cosmetic "am I probably signed in" check.
364
+ */
365
+ getSession(): Promise<MotherbaseResponse<{
366
+ session: Session | null;
367
+ }>>;
368
+ /**
369
+ * Revalidate the current session against the server. Better Auth bearer
370
+ * sessions have no refresh token: if the session is still valid the user is
371
+ * refreshed; otherwise the local session is cleared.
372
+ */
373
+ refreshSession(): Promise<MotherbaseResponse<{
374
+ user: User | null;
375
+ session: Session | null;
376
+ }>>;
377
+ /**
378
+ * Subscribe to auth changes, supabase-js style.
379
+ *
380
+ * The callback fires once with `INITIAL_SESSION` as soon as the stored
381
+ * session has been read, before any later event. That first call is not a
382
+ * nicety: the standard Supabase bootstrap is
383
+ * `if (event === 'INITIAL_SESSION') setLoading(false)`, and without it the
384
+ * app renders its loading state forever for a signed-out visitor, who never
385
+ * produces any other event.
386
+ *
387
+ * It is delivered asynchronously (after hydration), so unsubscribing
388
+ * synchronously suppresses it, exactly as in supabase-js.
389
+ */
390
+ /**
391
+ * The providers linked to the signed-in user, in the supabase-js identity
392
+ * shape. Backed by Better Auth's `list-accounts`, which is why `email` shows
393
+ * up as an identity for a password account: it is a real linked credential,
394
+ * exactly as in Supabase.
395
+ */
396
+ getUserIdentities(): Promise<MotherbaseResponse<{
397
+ identities: UserIdentity[];
398
+ }>>;
399
+ /**
400
+ * Link another provider to the signed-in user. Like `signInWithOAuth`, this
401
+ * only starts the flow: the browser is sent to the provider and comes back
402
+ * through the callback.
403
+ */
404
+ linkIdentity(credentials: SignInWithOAuthCredentials): Promise<MotherbaseResponse<{
405
+ provider: string;
406
+ url: string | null;
407
+ }>>;
408
+ /** Unlink a provider from the signed-in user. */
409
+ unlinkIdentity(identity: {
410
+ provider: string;
411
+ id?: string;
412
+ identity_id?: string;
413
+ }): Promise<MotherbaseResponse<Record<string, never>>>;
414
+ /**
415
+ * Native mobile sign-in with a provider id token (Sign in with Apple, Google
416
+ * One Tap), routed to Better Auth's social sign-in with an `idToken`.
417
+ * The provider must be configured on the backend.
418
+ */
419
+ signInWithIdToken(params: {
420
+ provider: string;
421
+ token: string;
422
+ access_token?: string;
423
+ nonce?: string;
424
+ }): Promise<MotherbaseResponse<{
425
+ user: User | null;
426
+ session: Session | null;
427
+ }>>;
428
+ /**
429
+ * Claims for the current session, as a JWT payload.
430
+ *
431
+ * supabase-js reads them out of the access token, which is itself a JWT.
432
+ * A Better Auth session token is an opaque bearer, so this asks the server's
433
+ * jwt plugin to mint one and decodes it. The decode is NOT a verification:
434
+ * the token came from the authenticated endpoint over TLS, and a client
435
+ * verifying a token it just asked for proves nothing. Verify server side,
436
+ * against `/api/auth/jwks`.
437
+ */
438
+ getClaims(): Promise<MotherbaseResponse<{
439
+ claims: Record<string, unknown>;
440
+ token: string;
441
+ }>>;
442
+ /**
443
+ * Revalidate the session on a timer, the way supabase-js does while the tab
444
+ * is focused. Motherbase refreshes on a 401 already, so this is opt-in: it
445
+ * exists so a ported app that calls it keeps working, and so a long-lived
446
+ * screen notices a revoked session without waiting for its next request.
447
+ */
448
+ startAutoRefresh(intervalMs?: number): void;
449
+ /** Stop the timer started by `startAutoRefresh`. Safe to call when none runs. */
450
+ stopAutoRefresh(): void;
451
+ onAuthStateChange(callback: AuthChangeListener): {
452
+ data: {
453
+ subscription: Subscription;
454
+ };
455
+ };
456
+ /**
457
+ * Internal: refresh used by the HttpClient's 401 path. Returns true on success.
458
+ * Not part of the public Supabase surface.
459
+ */
460
+ _refresh(): Promise<boolean>;
461
+ private persist;
462
+ }
463
+ //# sourceMappingURL=auth.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"auth.d.ts","sourceRoot":"","sources":["../src/auth.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AACrC,OAAO,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAC7C,OAAO,EAA4E,KAAK,aAAa,EAAE,MAAM,WAAW,CAAC;AACzH,OAAO,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAC;AACvD,OAAO,EAAE,aAAa,EAA2B,MAAM,cAAc,CAAC;AACtE,OAAO,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AAErC,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AAC5C,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AACjD,OAAO,KAAK,EAEV,kBAAkB,EAGlB,kBAAkB,EAClB,OAAO,EACP,IAAI,EACJ,YAAY,EACb,MAAM,YAAY,CAAC;AAEpB;;;;GAIG;AACH,MAAM,WAAW,cAAc;IAC7B,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB;AAED,MAAM,WAAW,iBAAiB;IAChC,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,MAAM,CAAC;IACjB,6DAA6D;I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