@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.
- package/README.md +25 -1
- package/dist/admin.d.ts +131 -0
- package/dist/admin.d.ts.map +1 -0
- package/dist/admin.js +121 -0
- package/dist/admin.js.map +1 -0
- package/dist/auth.d.ts +463 -0
- package/dist/auth.d.ts.map +1 -0
- package/dist/auth.js +884 -0
- package/dist/auth.js.map +1 -0
- package/dist/channel.d.ts +129 -0
- package/dist/channel.d.ts.map +1 -0
- package/dist/channel.js +215 -0
- package/dist/channel.js.map +1 -0
- package/dist/compat.d.ts +40 -0
- package/dist/compat.d.ts.map +1 -0
- package/dist/compat.js +100 -0
- package/dist/compat.js.map +1 -0
- package/dist/cookie.d.ts +68 -0
- package/dist/cookie.d.ts.map +1 -0
- package/dist/cookie.js +152 -0
- package/dist/cookie.js.map +1 -0
- package/dist/database.d.ts +188 -0
- package/dist/database.d.ts.map +1 -0
- package/dist/database.js +2 -0
- package/dist/database.js.map +1 -0
- package/dist/functions.d.ts +60 -0
- package/dist/functions.d.ts.map +1 -0
- package/dist/functions.js +75 -0
- package/dist/functions.js.map +1 -0
- package/dist/http.d.ts +122 -0
- package/dist/http.d.ts.map +1 -0
- package/dist/http.js +206 -0
- package/dist/http.js.map +1 -0
- package/dist/index.d.ts +215 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +365 -0
- package/dist/index.js.map +1 -0
- package/dist/mfa.d.ts +126 -0
- package/dist/mfa.d.ts.map +1 -0
- package/dist/mfa.js +167 -0
- package/dist/mfa.js.map +1 -0
- package/dist/organization.d.ts +234 -0
- package/dist/organization.d.ts.map +1 -0
- package/dist/organization.js +157 -0
- package/dist/organization.js.map +1 -0
- package/dist/passkey.d.ts +59 -0
- package/dist/passkey.d.ts.map +1 -0
- package/dist/passkey.js +87 -0
- package/dist/passkey.js.map +1 -0
- package/dist/pkce.d.ts +13 -0
- package/dist/pkce.d.ts.map +1 -0
- package/dist/pkce.js +52 -0
- package/dist/pkce.js.map +1 -0
- package/dist/plugin-endpoint.d.ts +20 -0
- package/dist/plugin-endpoint.d.ts.map +1 -0
- package/dist/plugin-endpoint.js +24 -0
- package/dist/plugin-endpoint.js.map +1 -0
- package/dist/postgrest.d.ts +326 -0
- package/dist/postgrest.d.ts.map +1 -0
- package/dist/postgrest.js +625 -0
- package/dist/postgrest.js.map +1 -0
- package/dist/query.d.ts +97 -0
- package/dist/query.d.ts.map +1 -0
- package/dist/query.js +94 -0
- package/dist/query.js.map +1 -0
- package/dist/realtime.d.ts +114 -0
- package/dist/realtime.d.ts.map +1 -0
- package/dist/realtime.js +376 -0
- package/dist/realtime.js.map +1 -0
- package/dist/session.d.ts +47 -0
- package/dist/session.d.ts.map +1 -0
- package/dist/session.js +136 -0
- package/dist/session.js.map +1 -0
- package/dist/sso.d.ts +147 -0
- package/dist/sso.d.ts.map +1 -0
- package/dist/sso.js +35 -0
- package/dist/sso.js.map +1 -0
- package/dist/storage.d.ts +268 -0
- package/dist/storage.d.ts.map +1 -0
- package/dist/storage.js +441 -0
- package/dist/storage.js.map +1 -0
- package/dist/testing.d.ts +38 -0
- package/dist/testing.d.ts.map +1 -0
- package/dist/testing.js +50 -0
- package/dist/testing.js.map +1 -0
- package/dist/types.d.ts +353 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +2 -0
- package/dist/types.js.map +1 -0
- package/dist/warn.d.ts +2 -0
- package/dist/warn.d.ts.map +1 -0
- package/dist/warn.js +23 -0
- package/dist/warn.js.map +1 -0
- package/package.json +4 -2
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,353 @@
|
|
|
1
|
+
/** Shared types for the Motherbase client SDK (Supabase-js compatible surface). */
|
|
2
|
+
import type { StorageRemoveContract, StorageUploadContract } from '@motherbase/contracts';
|
|
3
|
+
/** The envelope non-REST API endpoints (auth, storage, edge) wrap their payload in. */
|
|
4
|
+
export interface ApiEnvelope<T = unknown> {
|
|
5
|
+
status: 0 | 1;
|
|
6
|
+
message: string;
|
|
7
|
+
code?: string;
|
|
8
|
+
requestId?: string;
|
|
9
|
+
data?: T;
|
|
10
|
+
pager?: Record<string, unknown>;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* A timestamp as it can reach the client: ISO string over HTTP, `Date` when a
|
|
14
|
+
* server-side caller passes a Better Auth row straight in.
|
|
15
|
+
*/
|
|
16
|
+
export type Timestamp = string | Date;
|
|
17
|
+
/**
|
|
18
|
+
* The open bag of profile fields.
|
|
19
|
+
*
|
|
20
|
+
* `User` itself is closed: every field the platform sets is declared, and a
|
|
21
|
+
* typo like `user.emailVerifed` is a compile error. Project-specific columns
|
|
22
|
+
* (anything added to `user.additionalFields` on the server) cannot be known
|
|
23
|
+
* here, so they live in this bag, which is the one place with an index
|
|
24
|
+
* signature. `compat.ts` copies every non-platform field into it, so a custom
|
|
25
|
+
* `plan` column is readable as `user.user_metadata.plan`.
|
|
26
|
+
*
|
|
27
|
+
* Declare your own shape for it when you know the columns:
|
|
28
|
+
* `const meta = user.user_metadata as { plan?: string }`.
|
|
29
|
+
*/
|
|
30
|
+
export interface UserMetadata {
|
|
31
|
+
name?: string | null;
|
|
32
|
+
image?: string | null;
|
|
33
|
+
[key: string]: unknown;
|
|
34
|
+
}
|
|
35
|
+
/** Fields Better Auth itself owns on a user row. */
|
|
36
|
+
export interface BetterAuthUserFields {
|
|
37
|
+
/** Display name. Better Auth's own column, mirrored into `user_metadata`. */
|
|
38
|
+
name?: string | null;
|
|
39
|
+
/** Avatar URL. Better Auth's own column, mirrored into `user_metadata`. */
|
|
40
|
+
image?: string | null;
|
|
41
|
+
/** Better Auth stores verification as a boolean, not a timestamp. */
|
|
42
|
+
emailVerified?: boolean;
|
|
43
|
+
createdAt?: Timestamp | null;
|
|
44
|
+
updatedAt?: Timestamp | null;
|
|
45
|
+
/** Set by the `phoneNumber` plugin; aliased to `phone`. */
|
|
46
|
+
phoneNumber?: string | null;
|
|
47
|
+
phoneNumberVerified?: boolean | null;
|
|
48
|
+
/** Set by the `admin` plugin. */
|
|
49
|
+
banned?: boolean | null;
|
|
50
|
+
banReason?: string | null;
|
|
51
|
+
banExpires?: Timestamp | null;
|
|
52
|
+
/** Set by the `twoFactor` plugin. */
|
|
53
|
+
twoFactorEnabled?: boolean | null;
|
|
54
|
+
/** Set by the `anonymous` plugin; aliased to `is_anonymous`. */
|
|
55
|
+
isAnonymous?: boolean | null;
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* The `additionalFields` Motherbase configures on every project's auth
|
|
59
|
+
* instance (see `apps/server/auth/instance.ts`). The first four are
|
|
60
|
+
* client-writable through `updateUser`; the rest are server-set.
|
|
61
|
+
*/
|
|
62
|
+
export interface MotherbaseUserFields {
|
|
63
|
+
username?: string | null;
|
|
64
|
+
firstName?: string | null;
|
|
65
|
+
lastName?: string | null;
|
|
66
|
+
imageUrl?: string | null;
|
|
67
|
+
/** `'USER'` by default on the server, `'authenticated'` after `compat.ts`. */
|
|
68
|
+
role?: string;
|
|
69
|
+
status?: string | null;
|
|
70
|
+
classicEmail?: string | null;
|
|
71
|
+
appleId?: string | null;
|
|
72
|
+
appleEmail?: string | null;
|
|
73
|
+
googleId?: string | null;
|
|
74
|
+
googleEmail?: string | null;
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* The snake_case aliases `compat.ts` adds on the way out, so code ported from
|
|
78
|
+
* supabase-js reads `user.created_at` and `user.user_metadata.full_name` on a
|
|
79
|
+
* user that came out of Better Auth.
|
|
80
|
+
*
|
|
81
|
+
* They are optional because a `User` you construct yourself (a test fixture, a
|
|
82
|
+
* value on its way *in*) has not been through `compat.ts` yet. Everything the
|
|
83
|
+
* SDK hands back has them.
|
|
84
|
+
*/
|
|
85
|
+
export interface SupabaseUserAliases {
|
|
86
|
+
/** Always `'authenticated'`. Present for supabase-js parity. */
|
|
87
|
+
aud?: string;
|
|
88
|
+
created_at?: string | null;
|
|
89
|
+
updated_at?: string | null;
|
|
90
|
+
/** Non-null once the email is verified. Better Auth stores a boolean, so the
|
|
91
|
+
* value is the last-update timestamp rather than the true verification time. */
|
|
92
|
+
email_confirmed_at?: string | null;
|
|
93
|
+
confirmed_at?: string | null;
|
|
94
|
+
/** Alias of `phoneNumber`, `''` when the user has no phone. */
|
|
95
|
+
phone?: string;
|
|
96
|
+
/**
|
|
97
|
+
* Always `{}`: the client is not told which provider issued the session, and
|
|
98
|
+
* a guessed `{ provider: 'email' }` is worse than a missing one.
|
|
99
|
+
*/
|
|
100
|
+
app_metadata?: Record<string, unknown>;
|
|
101
|
+
/** Profile fields (`name`, `image`, any configured additional field). */
|
|
102
|
+
user_metadata?: UserMetadata;
|
|
103
|
+
identities?: UserIdentity[];
|
|
104
|
+
is_anonymous?: boolean;
|
|
105
|
+
}
|
|
106
|
+
/** A linked provider, in the supabase-js `UserIdentity` shape. */
|
|
107
|
+
export interface UserIdentity {
|
|
108
|
+
id: string;
|
|
109
|
+
identity_id: string;
|
|
110
|
+
user_id: string;
|
|
111
|
+
provider: string;
|
|
112
|
+
identity_data: Record<string, unknown>;
|
|
113
|
+
created_at: string | null;
|
|
114
|
+
updated_at: string | null;
|
|
115
|
+
last_sign_in_at: string | null;
|
|
116
|
+
}
|
|
117
|
+
/**
|
|
118
|
+
* Authenticated user as returned by the API.
|
|
119
|
+
*
|
|
120
|
+
* Closed on purpose: every field the platform can set is declared above, so
|
|
121
|
+
* reading one that does not exist is a compile error instead of a silent
|
|
122
|
+
* `undefined` at runtime. Project-specific columns go through
|
|
123
|
+
* [`UserMetadata`](#UserMetadata) (`user.user_metadata.<field>`).
|
|
124
|
+
*/
|
|
125
|
+
export interface User extends BetterAuthUserFields, MotherbaseUserFields, SupabaseUserAliases {
|
|
126
|
+
id: string;
|
|
127
|
+
email: string;
|
|
128
|
+
}
|
|
129
|
+
/**
|
|
130
|
+
* The bearer token issued by sign-up / sign-in. With Better Auth this is the
|
|
131
|
+
* session token; there is no separate refresh token (a session is valid until
|
|
132
|
+
* it expires, after which the user re-authenticates). `refreshToken` is kept
|
|
133
|
+
* optional for backwards source-compat and is unused.
|
|
134
|
+
*/
|
|
135
|
+
export interface Tokens {
|
|
136
|
+
accessToken: string;
|
|
137
|
+
refreshToken?: string;
|
|
138
|
+
}
|
|
139
|
+
/**
|
|
140
|
+
* The locally-held session: the bearer token plus the user it belongs to.
|
|
141
|
+
*
|
|
142
|
+
* The snake_case fields are supabase-js aliases, added by the session store on
|
|
143
|
+
* the way out (see `compat.ts`). `access_token` always mirrors `accessToken`;
|
|
144
|
+
* `expires_at` / `expires_in` are present only when the server dated the
|
|
145
|
+
* session, because supabase-js callers schedule refreshes off them and a
|
|
146
|
+
* fabricated expiry schedules them wrong.
|
|
147
|
+
*/
|
|
148
|
+
export interface Session extends Tokens {
|
|
149
|
+
user: User;
|
|
150
|
+
/** supabase-js alias of `accessToken`. */
|
|
151
|
+
access_token?: string;
|
|
152
|
+
/** supabase-js alias of `refreshToken`. Always null on Better Auth sessions. */
|
|
153
|
+
refresh_token?: string | null;
|
|
154
|
+
token_type?: 'bearer';
|
|
155
|
+
/** Unix seconds. Absent when the backend did not date the session. */
|
|
156
|
+
expires_at?: number;
|
|
157
|
+
/** Seconds until `expires_at`. Absent for the same reason. */
|
|
158
|
+
expires_in?: number;
|
|
159
|
+
}
|
|
160
|
+
/** Session payload returned by Better Auth after sign-in or second-factor verification. */
|
|
161
|
+
export interface AuthPayload {
|
|
162
|
+
token: string;
|
|
163
|
+
user: User;
|
|
164
|
+
}
|
|
165
|
+
export type FileVisibility = 'public' | 'private';
|
|
166
|
+
/** Lifecycle of a stored object: `ready` unless a presigned upload is pending. */
|
|
167
|
+
export type FileStatus = 'pending' | 'ready' | 'expired';
|
|
168
|
+
/**
|
|
169
|
+
* A row of the storage table, as `POST /api/files/` returns it.
|
|
170
|
+
*
|
|
171
|
+
* This is the upload shape, not the `list()` shape: `list()` answers in the
|
|
172
|
+
* supabase-js `FileObject` form, which is a different set of fields under
|
|
173
|
+
* different names. Conflating the two is what the old `[key: string]: unknown`
|
|
174
|
+
* hid, and `file.filename` (a field the server never sent) type-checked.
|
|
175
|
+
*/
|
|
176
|
+
export interface StoredFile {
|
|
177
|
+
id: string;
|
|
178
|
+
/** Bucket slug. */
|
|
179
|
+
bucket: string;
|
|
180
|
+
/** Object key inside the bucket, including any prefix. */
|
|
181
|
+
key: string;
|
|
182
|
+
mime?: string | null;
|
|
183
|
+
size: number;
|
|
184
|
+
visibility: FileVisibility;
|
|
185
|
+
status: FileStatus;
|
|
186
|
+
/** Set for public objects and for drivers that store an absolute URL. */
|
|
187
|
+
url?: string | null;
|
|
188
|
+
ownerId?: string | null;
|
|
189
|
+
bucketId?: string | null;
|
|
190
|
+
/** Deadline of a presigned upload that has not been finalised. */
|
|
191
|
+
uploadExpiresAt?: string | null;
|
|
192
|
+
createdAt: string;
|
|
193
|
+
updatedAt: string;
|
|
194
|
+
}
|
|
195
|
+
/**
|
|
196
|
+
* One object as `list()` returns it: the supabase-js `FileObject` shape, which
|
|
197
|
+
* is what code ported from Supabase reads (`obj.name`, `obj.metadata.size`).
|
|
198
|
+
*/
|
|
199
|
+
export interface FileObject {
|
|
200
|
+
/** Key relative to the bucket. */
|
|
201
|
+
name: string;
|
|
202
|
+
id: string;
|
|
203
|
+
created_at: string | null;
|
|
204
|
+
updated_at: string | null;
|
|
205
|
+
last_accessed_at: string | null;
|
|
206
|
+
metadata: {
|
|
207
|
+
size: number;
|
|
208
|
+
mimetype: string | null;
|
|
209
|
+
cacheControl: string | null;
|
|
210
|
+
};
|
|
211
|
+
}
|
|
212
|
+
/** Exact payload returned by `POST /api/files/`. */
|
|
213
|
+
export type StorageUploadResponse = StorageUploadContract<StoredFile>;
|
|
214
|
+
/** Exact payload returned by `DELETE /api/files/:id`. */
|
|
215
|
+
export type StorageRemoveResponse = StorageRemoveContract;
|
|
216
|
+
/** A file-ish value accepted by multipart uploads (browser File/Blob or RN asset). */
|
|
217
|
+
export type UploadInput = Blob | ArrayBuffer | ArrayBufferView | {
|
|
218
|
+
uri: string;
|
|
219
|
+
name?: string;
|
|
220
|
+
type?: string;
|
|
221
|
+
};
|
|
222
|
+
/**
|
|
223
|
+
* The uniform result envelope every data/auth/storage call resolves to.
|
|
224
|
+
* `error` is `null` on success; `data` is `null` on failure. Never throws for
|
|
225
|
+
* expected API errors: only for programmer misuse.
|
|
226
|
+
*/
|
|
227
|
+
export interface MotherbaseResponse<T> {
|
|
228
|
+
data: T | null;
|
|
229
|
+
error: MotherbaseError | null;
|
|
230
|
+
}
|
|
231
|
+
/** Supabase-shaped error object. */
|
|
232
|
+
export interface MotherbaseError {
|
|
233
|
+
message: string;
|
|
234
|
+
/** HTTP status code, when the failure came from an HTTP response. */
|
|
235
|
+
status?: number;
|
|
236
|
+
/** Backend/app error code, when present. */
|
|
237
|
+
code?: string;
|
|
238
|
+
/**
|
|
239
|
+
* Correlation id of the failed request, from the `x-request-id` response
|
|
240
|
+
* header. The same id is on the server-side log line, so quoting it in a bug
|
|
241
|
+
* report (or logging it beside your own error) is what makes an intermittent
|
|
242
|
+
* 500 findable.
|
|
243
|
+
*/
|
|
244
|
+
requestId?: string;
|
|
245
|
+
}
|
|
246
|
+
/**
|
|
247
|
+
* Persists the session between runs. Implementations must be synchronous-or-async
|
|
248
|
+
* tolerant: every method may return a value or a promise of it.
|
|
249
|
+
*/
|
|
250
|
+
export interface SessionStorageAdapter {
|
|
251
|
+
get(): Session | null | Promise<Session | null>;
|
|
252
|
+
set(session: Session | null): void | Promise<void>;
|
|
253
|
+
}
|
|
254
|
+
/**
|
|
255
|
+
* A key/value store shaped like `window.localStorage` or React Native's
|
|
256
|
+
* `AsyncStorage`. supabase-js takes its session storage in this form, so an app
|
|
257
|
+
* being ported passes one of these; the client wraps it (see
|
|
258
|
+
* `keyValueStorage`) rather than failing at runtime on a missing `.get`.
|
|
259
|
+
*/
|
|
260
|
+
export interface KeyValueStorageAdapter {
|
|
261
|
+
getItem(key: string): string | null | Promise<string | null>;
|
|
262
|
+
setItem(key: string, value: string): void | Promise<void>;
|
|
263
|
+
removeItem(key: string): void | Promise<void>;
|
|
264
|
+
}
|
|
265
|
+
/**
|
|
266
|
+
* The supabase-js-shaped half of the options.
|
|
267
|
+
*
|
|
268
|
+
* supabase-js nests its options under `auth`, `db`, `global` and `realtime`.
|
|
269
|
+
* Ported code passes them that way, and silently dropping them is the worst
|
|
270
|
+
* possible outcome: `{ auth: { persistSession: true } }` looks like it works
|
|
271
|
+
* and the user is signed out on every reload. Both spellings are accepted; the
|
|
272
|
+
* flat (native) one wins where they collide.
|
|
273
|
+
*/
|
|
274
|
+
export interface SupabaseStyleOptions {
|
|
275
|
+
auth?: {
|
|
276
|
+
/** Refresh on 401 and, with `startAutoRefresh()`, on a timer. Default true. */
|
|
277
|
+
autoRefreshToken?: boolean;
|
|
278
|
+
/**
|
|
279
|
+
* `true` (the default in a browser) persists the session to localStorage
|
|
280
|
+
* when no explicit storage is given. `false` keeps it in memory.
|
|
281
|
+
*/
|
|
282
|
+
persistSession?: boolean;
|
|
283
|
+
/** Read the OAuth token out of the URL on construction. Default true in a browser. */
|
|
284
|
+
detectSessionInUrl?: boolean;
|
|
285
|
+
/** Either adapter shape: supabase-js's key/value store or the native one. */
|
|
286
|
+
storage?: KeyValueStorageAdapter | SessionStorageAdapter;
|
|
287
|
+
/** Storage key. Defaults to `motherbase.session`. */
|
|
288
|
+
storageKey?: string;
|
|
289
|
+
/**
|
|
290
|
+
* `implicit` (the default) returns the session in the redirect's URL
|
|
291
|
+
* fragment. `pkce` returns `?code=` instead, exchanged automatically on
|
|
292
|
+
* load (or by `auth.exchangeCodeForSession(code)`) with the verifier this
|
|
293
|
+
* browser kept, so a leaked redirect URL is worth nothing on its own.
|
|
294
|
+
*/
|
|
295
|
+
flowType?: 'implicit' | 'pkce';
|
|
296
|
+
debug?: boolean;
|
|
297
|
+
};
|
|
298
|
+
db?: {
|
|
299
|
+
/** Default schema for `from()` and `rpc()`. Only `public` is exposed today. */
|
|
300
|
+
schema?: string;
|
|
301
|
+
};
|
|
302
|
+
global?: {
|
|
303
|
+
headers?: Record<string, string>;
|
|
304
|
+
fetch?: typeof fetch;
|
|
305
|
+
};
|
|
306
|
+
realtime?: Record<string, unknown>;
|
|
307
|
+
}
|
|
308
|
+
export interface ClientOptions extends SupabaseStyleOptions {
|
|
309
|
+
/** Where to persist the session. Defaults to in-memory (SSR-safe). */
|
|
310
|
+
storage?: SessionStorageAdapter;
|
|
311
|
+
/** Refresh the access token automatically on a 401. Default: true. */
|
|
312
|
+
autoRefresh?: boolean;
|
|
313
|
+
/** Override the fetch implementation (for SSR or tests). */
|
|
314
|
+
fetch?: typeof fetch;
|
|
315
|
+
/** Extra headers merged into every request (e.g. a custom `apikey`). */
|
|
316
|
+
headers?: Record<string, string>;
|
|
317
|
+
/**
|
|
318
|
+
* Align the behaviours that differ from supabase-js but share its spelling.
|
|
319
|
+
*
|
|
320
|
+
* A missing method fails loudly. A method that exists and behaves differently
|
|
321
|
+
* does not, and that is what breaks a ported app in production. Differences
|
|
322
|
+
* are recorded in COMPATIBILITY.md:
|
|
323
|
+
*
|
|
324
|
+
* - `update()` / `delete()` whose filter matches nothing answer 404 here and
|
|
325
|
+
* an empty array in supabase-js.
|
|
326
|
+
*
|
|
327
|
+
* Writes already require `.select()` to return rows in every mode.
|
|
328
|
+
*
|
|
329
|
+
* NOT covered, on purpose: an unfiltered `delete()` stays refused with 400.
|
|
330
|
+
* Parity there means removing a guard against deleting a whole table from a
|
|
331
|
+
* typo, and no migration is worth that. Add `.neq('id', 0)`, or run it from
|
|
332
|
+
* the SQL editor.
|
|
333
|
+
*/
|
|
334
|
+
compat?: 'supabase';
|
|
335
|
+
/**
|
|
336
|
+
* Inject a socket.io factory for realtime (tests / custom transports).
|
|
337
|
+
* When omitted, `socket.io-client` is imported lazily at connect time.
|
|
338
|
+
*/
|
|
339
|
+
realtimeIoFactory?: (url: string, opts: Record<string, unknown>) => import('./realtime.js').SocketLike;
|
|
340
|
+
}
|
|
341
|
+
/**
|
|
342
|
+
* Supabase-compatible auth change events emitted by `onAuthStateChange`.
|
|
343
|
+
*
|
|
344
|
+
* `INITIAL_SESSION` is fired once per subscription, right after subscribing,
|
|
345
|
+
* with whatever session was already stored. supabase-js does the same, and an
|
|
346
|
+
* app that clears its loading flag on it hangs forever without it.
|
|
347
|
+
*/
|
|
348
|
+
export type AuthChangeEvent = 'INITIAL_SESSION' | 'SIGNED_IN' | 'SIGNED_OUT' | 'TOKEN_REFRESHED' | 'USER_UPDATED' | 'PASSWORD_RECOVERY' | 'MFA_CHALLENGE_VERIFIED';
|
|
349
|
+
export type AuthChangeListener = (event: AuthChangeEvent, session: Session | null) => void;
|
|
350
|
+
/** Internal event names used by the session store. */
|
|
351
|
+
export type AuthEvent = 'signIn' | 'signOut' | 'tokenRefreshed' | 'userUpdated' | 'mfaVerified';
|
|
352
|
+
export type AuthListener = (event: AuthEvent, session: Session | null) => void;
|
|
353
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,mFAAmF;AACnF,OAAO,KAAK,EAAE,qBAAqB,EAAE,qBAAqB,EAAE,MAAM,uBAAuB,CAAC;AAE1F,uFAAuF;AACvF,MAAM,WAAW,WAAW,CAAC,CAAC,GAAG,OAAO;IACtC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC;IACd,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,IAAI,CAAC,EAAE,CAAC,CAAC;IACT,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CACjC;AAED;;;GAGG;AACH,MAAM,MAAM,SAAS,GAAG,MAAM,GAAG,IAAI,CAAC;AAEtC;;;;;;;;;;;;GAYG;AACH,MAAM,WAAW,YAAY;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
|
|
|
1
|
+
{"version":3,"file":"warn.d.ts","sourceRoot":"","sources":["../src/warn.ts"],"names":[],"mappings":"AAiBA,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,GAAG,IAAI,CAKzF"}
|
package/dist/warn.js
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { isProduction } from './cookie.js';
|
|
2
|
+
/**
|
|
3
|
+
* One warning per ignored option, in development only.
|
|
4
|
+
*
|
|
5
|
+
* An option this SDK accepts and does not act on is the worst shape of
|
|
6
|
+
* incompatibility: the call compiles, returns a success, and does something
|
|
7
|
+
* other than what the caller asked. supabase-js code passes these because they
|
|
8
|
+
* work there. Saying so once, out loud, is the difference between a five minute
|
|
9
|
+
* fix and a production incident nobody can reproduce.
|
|
10
|
+
*
|
|
11
|
+
* Deduplicated by site and option, because these sit in call paths that run per
|
|
12
|
+
* row, and silent in production, where nobody reads the console and the cost is
|
|
13
|
+
* paid on every call.
|
|
14
|
+
*/
|
|
15
|
+
const warned = new Set();
|
|
16
|
+
export function warnIgnoredOption(site, option, consequence) {
|
|
17
|
+
const key = `${site}.${option}`;
|
|
18
|
+
if (warned.has(key) || isProduction())
|
|
19
|
+
return;
|
|
20
|
+
warned.add(key);
|
|
21
|
+
console.warn(`[motherbase] ${site}: \`${option}\` is accepted and ignored. ${consequence}`);
|
|
22
|
+
}
|
|
23
|
+
//# sourceMappingURL=warn.js.map
|
package/dist/warn.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"warn.js","sourceRoot":"","sources":["../src/warn.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAE3C;;;;;;;;;;;;GAYG;AACH,MAAM,MAAM,GAAG,IAAI,GAAG,EAAU,CAAC;AAEjC,MAAM,UAAU,iBAAiB,CAAC,IAAY,EAAE,MAAc,EAAE,WAAmB;IACjF,MAAM,GAAG,GAAG,GAAG,IAAI,IAAI,MAAM,EAAE,CAAC;IAChC,IAAI,MAAM,CAAC,GAAG,CAAC,GAAG,CAAC,IAAI,YAAY,EAAE;QAAE,OAAO;IAC9C,MAAM,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;IAChB,OAAO,CAAC,IAAI,CAAC,gBAAgB,IAAI,OAAO,MAAM,+BAA+B,WAAW,EAAE,CAAC,CAAC;AAC9F,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@motherbase/client",
|
|
3
|
-
"version": "1.5.
|
|
3
|
+
"version": "1.5.2",
|
|
4
4
|
"description": "Typed client SDK for Motherbase, the open source self-hosted backend platform.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -28,7 +28,9 @@
|
|
|
28
28
|
"README.md"
|
|
29
29
|
],
|
|
30
30
|
"scripts": {
|
|
31
|
+
"prebuild": "npm run build -w @motherbase/contracts",
|
|
31
32
|
"build": "tsc -p tsconfig.json",
|
|
33
|
+
"prepack": "npm run build",
|
|
32
34
|
"clean": "rm -rf dist",
|
|
33
35
|
"test": "vitest run --typecheck",
|
|
34
36
|
"lint": "eslint ."
|
|
@@ -43,7 +45,7 @@
|
|
|
43
45
|
],
|
|
44
46
|
"license": "MIT",
|
|
45
47
|
"dependencies": {
|
|
46
|
-
"@motherbase/contracts": "^1.0.
|
|
48
|
+
"@motherbase/contracts": "^1.0.5"
|
|
47
49
|
},
|
|
48
50
|
"peerDependencies": {
|
|
49
51
|
"socket.io-client": "^4.0.0"
|