@motherbase/client 1.3.1 → 1.5.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/README.md +127 -13
- package/package.json +10 -2
- package/dist/admin.d.ts +0 -81
- package/dist/admin.d.ts.map +0 -1
- package/dist/admin.js +0 -85
- package/dist/admin.js.map +0 -1
- package/dist/auth.d.ts +0 -233
- package/dist/auth.d.ts.map +0 -1
- package/dist/auth.js +0 -418
- package/dist/auth.js.map +0 -1
- package/dist/channel.d.ts +0 -119
- package/dist/channel.d.ts.map +0 -1
- package/dist/channel.js +0 -213
- package/dist/channel.js.map +0 -1
- package/dist/cookie.d.ts +0 -60
- package/dist/cookie.d.ts.map +0 -1
- package/dist/cookie.js +0 -144
- package/dist/cookie.js.map +0 -1
- package/dist/database.d.ts +0 -169
- package/dist/database.d.ts.map +0 -1
- package/dist/database.js +0 -2
- package/dist/database.js.map +0 -1
- package/dist/devices.d.ts +0 -13
- package/dist/devices.d.ts.map +0 -1
- package/dist/devices.js +0 -13
- package/dist/devices.js.map +0 -1
- package/dist/edge.d.ts +0 -7
- package/dist/edge.d.ts.map +0 -1
- package/dist/edge.js +0 -13
- package/dist/edge.js.map +0 -1
- package/dist/functions.d.ts +0 -24
- package/dist/functions.d.ts.map +0 -1
- package/dist/functions.js +0 -24
- package/dist/functions.js.map +0 -1
- package/dist/http.d.ts +0 -96
- package/dist/http.d.ts.map +0 -1
- package/dist/http.js +0 -157
- package/dist/http.js.map +0 -1
- package/dist/index.d.ts +0 -118
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js +0 -180
- package/dist/index.js.map +0 -1
- package/dist/mfa.d.ts +0 -109
- package/dist/mfa.d.ts.map +0 -1
- package/dist/mfa.js +0 -134
- package/dist/mfa.js.map +0 -1
- package/dist/postgrest.d.ts +0 -239
- package/dist/postgrest.d.ts.map +0 -1
- package/dist/postgrest.js +0 -467
- package/dist/postgrest.js.map +0 -1
- package/dist/profile.d.ts +0 -16
- package/dist/profile.d.ts.map +0 -1
- package/dist/profile.js +0 -26
- package/dist/profile.js.map +0 -1
- package/dist/realtime.d.ts +0 -114
- package/dist/realtime.d.ts.map +0 -1
- package/dist/realtime.js +0 -372
- package/dist/realtime.js.map +0 -1
- package/dist/rest.d.ts +0 -50
- package/dist/rest.d.ts.map +0 -1
- package/dist/rest.js +0 -75
- package/dist/rest.js.map +0 -1
- package/dist/session.d.ts +0 -36
- package/dist/session.d.ts.map +0 -1
- package/dist/session.js +0 -90
- package/dist/session.js.map +0 -1
- package/dist/storage.d.ts +0 -72
- package/dist/storage.d.ts.map +0 -1
- package/dist/storage.js +0 -148
- package/dist/storage.js.map +0 -1
- package/dist/types.d.ts +0 -106
- package/dist/types.d.ts.map +0 -1
- package/dist/types.js +0 -2
- package/dist/types.js.map +0 -1
package/README.md
CHANGED
|
@@ -10,20 +10,69 @@ import and the client factory, keep your queries. Every `supabase-js` data call
|
|
|
10
10
|
in the contract suite is either supported or supported with a stated difference,
|
|
11
11
|
including relational embedding (`select('*, author(*)')`), `.rpc()`, native
|
|
12
12
|
`upsert`, `count`, `csv()`, the full filter set and PostgREST error codes.
|
|
13
|
-
Auth and realtime are close, with named gaps (no
|
|
14
|
-
|
|
13
|
+
Auth and realtime are close, with named gaps (no private channels). Two-factor
|
|
14
|
+
(`client.auth.mfa.*`), SSO, anonymous sign-ins, CAPTCHA tokens, the PKCE flow
|
|
15
|
+
(`flowType: 'pkce'` + `exchangeCodeForSession`), linked identities and
|
|
16
|
+
secret-key user administration (`client.auth.admin.*`, including `generateLink`
|
|
17
|
+
and `admin.mfa`) are all here, and so are what supabase-js lacks: organizations
|
|
18
|
+
and teams (`client.auth.organization.*`), passkeys and runtime SSO providers. You
|
|
19
|
+
never import Better Auth on the client.
|
|
15
20
|
|
|
16
21
|
**Storage is path-addressed too**: `upload('avatars/123/pic.png')` then
|
|
17
22
|
`download('avatars/123/pic.png')` round trips, `list(prefix)` works, and keys are
|
|
18
|
-
traversal-checked.
|
|
19
|
-
|
|
20
|
-
|
|
23
|
+
traversal-checked. `copy`, `move`, `info`, `exists`, batch signed URLs and
|
|
24
|
+
direct-to-storage signed uploads are supported; image transforms are not.
|
|
25
|
+
Authorization is ownership plus bucket tokens by default, and real RLS policies on
|
|
26
|
+
`storage.files` when the `storage.policies` setting is on. See
|
|
21
27
|
[`docs/migrating-from-supabase.md`](../../docs/migrating-from-supabase.md).
|
|
22
28
|
|
|
29
|
+
On the server, `createClient(url, secretKey)` also authorizes storage objects as
|
|
30
|
+
`service_role`, including objects uploaded by another user. Secret-key
|
|
31
|
+
impersonation keeps the permissions of the impersonated caller. Anonymous uploads
|
|
32
|
+
require storage policies granting INSERT; they do not require SELECT. An upload
|
|
33
|
+
response's `url` can be `null` when the caller cannot read the object.
|
|
34
|
+
|
|
35
|
+
Uploads accept `Blob`, `ArrayBuffer`, and typed arrays, including Node `Buffer`.
|
|
36
|
+
Signed uploads carry a scoped finalization token; keep the entire returned token
|
|
37
|
+
when calling `uploadToSignedUrl`. This capability grants finalization, not private
|
|
38
|
+
read access. Public URLs use the shared contracts route.
|
|
39
|
+
|
|
40
|
+
For auth mutations in Node, the SDK supplies the API URL's origin when no
|
|
41
|
+
`Origin` header was provided. An explicit `headers: { Origin: 'https://app.example' }`
|
|
42
|
+
is preserved and must be trusted by the server. Browser requests retain the
|
|
43
|
+
browser's Origin and the server's CSRF checks remain enabled.
|
|
44
|
+
|
|
23
45
|
Do not plan a migration from the paragraph above. Plan it from
|
|
24
46
|
[`COMPATIBILITY.md`](./COMPATIBILITY.md), which is generated from contract tests
|
|
25
47
|
and is exhaustive, per method, with the exact difference for every partial row.
|
|
26
48
|
|
|
49
|
+
**Write responses (Supabase semantics).** Native and compatibility clients,
|
|
50
|
+
including SSR clients, return `data: null` after a successful write unless you
|
|
51
|
+
chain `.select()`. For a public contact form, grant INSERT and create an INSERT
|
|
52
|
+
policy; no SELECT policy is needed. Requesting rows also requires SELECT access.
|
|
53
|
+
|
|
54
|
+
```ts
|
|
55
|
+
// Write only: no SELECT access required.
|
|
56
|
+
const { error } = await client.from('contacts').insert({ email, message });
|
|
57
|
+
|
|
58
|
+
// Read back the stored row, including generated defaults, if RLS permits it.
|
|
59
|
+
const { data } = await client.from('contacts').insert({ email, message }).select().single();
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
Existing Motherbase code that consumed implicit write responses must add
|
|
63
|
+
`.select()` to those calls. Raw REST writes default to `Prefer: return=minimal`;
|
|
64
|
+
use `Prefer: return=representation` to receive rows. Apply the
|
|
65
|
+
`20260924120000_rest_write_capture` server migration before starting the updated
|
|
66
|
+
server: internal trigger capture keeps realtime/webhooks transactional without
|
|
67
|
+
requiring client read access. It does not enable event delivery for arbitrary
|
|
68
|
+
SQL-editor or RPC writes. Motherbase's `transaction()` extension retains its
|
|
69
|
+
existing batch response contract.
|
|
70
|
+
|
|
71
|
+
**Invalid keys are refused.** A project key that is unknown or revoked now
|
|
72
|
+
answers `401 UNAUTHORIZED` even when the project does not require an API key.
|
|
73
|
+
Before, it was ignored and the request ran as anonymous. Remove stale keys from
|
|
74
|
+
client configuration rather than relying on that fallback.
|
|
75
|
+
|
|
27
76
|
Typed, isomorphic (browser, Next.js server & client, Expo / React Native), built
|
|
28
77
|
on global `fetch` with zero runtime dependencies (`socket.io-client` is an
|
|
29
78
|
optional peer dependency, used only for realtime).
|
|
@@ -107,7 +156,8 @@ client.from(table).select(cols).limit(n, { referencedTable }).range(from, to).ab
|
|
|
107
156
|
client.from(table).select(cols).or('a.eq.1,and(b.gt.2,c.is.null)') // nests, as PostgREST does
|
|
108
157
|
client.from(table).select(cols).not(col, 'eq', v).filter(col, 'isdistinct', v)
|
|
109
158
|
client.from(table).select(cols).textSearch(col, q, { type: 'websearch', config: 'english' })
|
|
110
|
-
client.from(table).select(cols).single() | .maybeSingle() | .returns<T>() | .csv() | .explain()
|
|
159
|
+
client.from(table).select(cols).single() | .maybeSingle() | .returns<T>() | .csv() | .geojson() | .explain()
|
|
160
|
+
client.from(table).update(v).eq(..).throwOnError() | .maxAffected(1) | .rollback()
|
|
111
161
|
client.from(table).insert(row) | .insert([rowA, rowB], { defaultToNull: false })
|
|
112
162
|
client.from(table).upsert(rows, { onConflict, ignoreDuplicates })
|
|
113
163
|
client.from(table).update(values).eq(..) // a filter is required
|
|
@@ -115,8 +165,10 @@ client.from(table).delete().eq(..) // a filter is required
|
|
|
115
165
|
// Every call resolves { data, error, count }. `count` is null unless you ask:
|
|
116
166
|
// .select('*', { count: 'exact', head: true }).
|
|
117
167
|
// Values are quoted for you: .in('name', ['a,b']) is one value, not two.
|
|
118
|
-
// Writes
|
|
119
|
-
//
|
|
168
|
+
// Writes return { data: null, error: null } by default, like supabase-js.
|
|
169
|
+
// Add .select() to insert/upsert/update/delete to request the written rows.
|
|
170
|
+
// Returning rows requires a SELECT policy as well as the write policy.
|
|
171
|
+
// An unbounded select is capped by api.rest.maxRows (1000 by default): paginate with .range().
|
|
120
172
|
// explain() needs an admin caller; a normal caller gets 403.
|
|
121
173
|
|
|
122
174
|
// Relational embedding. Compiles to a correlated LATERAL subquery inside the
|
|
@@ -147,15 +199,44 @@ client.auth.getSession() // { data: { session } }, local only
|
|
|
147
199
|
client.auth.refreshSession()
|
|
148
200
|
client.auth.onAuthStateChange((event, session) => {}) // SIGNED_IN | SIGNED_OUT | TOKEN_REFRESHED
|
|
149
201
|
client.auth.deleteUser({ password }) // self-service, needs the backend flow enabled
|
|
202
|
+
client.auth.signInWithSSO({ domain | providerId | email })
|
|
203
|
+
client.auth.signInWithIdToken({ provider, token, nonce }) // Apple / Google One Tap
|
|
204
|
+
client.auth.getUserIdentities() | .linkIdentity({ provider }) | .unlinkIdentity({ provider, id })
|
|
205
|
+
client.auth.getClaims() // { claims, token }, decoded from a minted JWT
|
|
206
|
+
client.auth.startAutoRefresh(ms) | .stopAutoRefresh()
|
|
207
|
+
client.auth.mfa.enroll({ password }) | .challenge({ channel }) | .verify({ code, type? })
|
|
208
|
+
client.auth.mfa.listFactors() | .regenerateBackupCodes({ password }) | .unenroll({ password })
|
|
209
|
+
client.auth.admin.* // secret key only: list/get/create/update/delete/signOut/invite
|
|
210
|
+
|
|
211
|
+
// Beyond supabase-js. Method names and parameters are Better Auth's own, so its
|
|
212
|
+
// plugin docs apply; each needs its plugin on in the project's Auth settings.
|
|
213
|
+
client.auth.signInWithPasskey() // browser passkey prompt, then a session like any sign-in
|
|
214
|
+
client.auth.passkey.register({ name }) | .list() | .update({ id, name }) | .delete({ id })
|
|
215
|
+
client.auth.organization.create({ name, slug }) | .list() | .setActive({ organizationId })
|
|
216
|
+
client.auth.organization.getFullOrganization() | .update({ data }) | .delete({ organizationId }) | .leave(...)
|
|
217
|
+
client.auth.organization.inviteMember({ email, role }) | .acceptInvitation({ invitationId }) | .listUserInvitations()
|
|
218
|
+
client.auth.organization.listMembers() | .updateMemberRole({ memberId, role }) | .removeMember({ memberIdOrEmail })
|
|
219
|
+
client.auth.organization.hasPermission({ permissions: { member: ['create'] } })
|
|
220
|
+
client.auth.organization.createTeam({ name }) | .listTeams() | .addTeamMember({ teamId, userId }) // teams on
|
|
221
|
+
client.auth.sso.register({ providerId, issuer, domain, organizationId, oidcConfig | samlConfig })
|
|
222
|
+
client.auth.sso.listProviders() | .getProvider({ providerId }) | .updateProvider(...) | .deleteProvider(...)
|
|
150
223
|
|
|
151
224
|
// Storage → { data, error }. `path` is the object key inside the bucket, and it
|
|
152
225
|
// round trips. The file id returned by upload still works anywhere a path does.
|
|
153
226
|
client.storage.from(bucket).upload(path, file, { visibility, upsert })
|
|
154
|
-
client.storage.from(bucket).download(path)
|
|
227
|
+
client.storage.from(bucket).download(path, { transform }) // transform: see below
|
|
155
228
|
client.storage.from(bucket).remove([path])
|
|
156
229
|
client.storage.from(bucket).list(prefix, { limit, offset, search, sortBy })
|
|
157
|
-
client.storage.from(bucket).createSignedUrl(path, expiresIn)
|
|
158
|
-
client.storage.from(bucket).
|
|
230
|
+
client.storage.from(bucket).createSignedUrl(path, expiresIn, { transform }) // seconds, 1..604800
|
|
231
|
+
client.storage.from(bucket).createSignedUrls([path], expiresIn) // per-entry results
|
|
232
|
+
client.storage.from(bucket).getPublicUrl(path, { transform }) // sync
|
|
233
|
+
client.storage.from(bucket).update(path, file) // upload with upsert on
|
|
234
|
+
client.storage.from(bucket).copy(from, to, { upsert }) | .move(from, to, { upsert })
|
|
235
|
+
client.storage.from(bucket).info(path) | .exists(path) // 404 reads as false
|
|
236
|
+
client.storage.from(bucket).createSignedUploadUrl(path, { size, contentType }) // S3 driver
|
|
237
|
+
client.storage.from(bucket).uploadToSignedUrl(path, token, file)
|
|
238
|
+
client.storage.createBucket(id, { public, fileSizeLimit, allowedMimeTypes }) // secret key
|
|
239
|
+
// transform: { width, height, resize: 'cover'|'contain'|'fill', quality, format: 'origin'|'webp'|'avif' }
|
|
159
240
|
|
|
160
241
|
// Realtime
|
|
161
242
|
client.channel(name, { config: { broadcast: { self, ack }, presence: { key } } })
|
|
@@ -167,8 +248,41 @@ channel.send({ type: 'broadcast', event, payload })
|
|
|
167
248
|
channel.track(state); channel.untrack(); channel.presenceState()
|
|
168
249
|
client.removeChannel(channel)
|
|
169
250
|
|
|
170
|
-
// Edge functions → { data, error }
|
|
171
|
-
|
|
251
|
+
// Edge functions → { data, error }. `error` is a FunctionsHttpError /
|
|
252
|
+
// FunctionsFetchError instance, but invoke still resolves rather than throws.
|
|
253
|
+
client.functions.invoke(name, { body, method, headers, auth })
|
|
254
|
+
```
|
|
255
|
+
|
|
256
|
+
## Resumable uploads
|
|
257
|
+
|
|
258
|
+
Large files go over TUS, exactly as on Supabase: the SDK does not bundle a TUS
|
|
259
|
+
client (supabase-js does not either), so use
|
|
260
|
+
[`tus-js-client`](https://github.com/tus/tus-js-client) against
|
|
261
|
+
`/storage/v1/upload/resumable`. Chunks must be 6 MB. Bucket limits, the key
|
|
262
|
+
collision check and storage policies are enforced when the upload is created,
|
|
263
|
+
and an unfinished upload can be resumed for 24 hours.
|
|
264
|
+
|
|
265
|
+
```ts
|
|
266
|
+
import { Upload } from 'tus-js-client';
|
|
267
|
+
|
|
268
|
+
const { data: { session } } = await client.auth.getSession();
|
|
269
|
+
const upload = new Upload(file, {
|
|
270
|
+
endpoint: `${MOTHERBASE_URL}/storage/v1/upload/resumable`,
|
|
271
|
+
chunkSize: 6 * 1024 * 1024,
|
|
272
|
+
retryDelays: [0, 3000, 5000, 10000, 20000],
|
|
273
|
+
headers: {
|
|
274
|
+
authorization: `Bearer ${session?.access_token}`,
|
|
275
|
+
apikey: MOTHERBASE_PUBLISHABLE_KEY,
|
|
276
|
+
'x-upsert': 'true', // optional: replace an existing object
|
|
277
|
+
},
|
|
278
|
+
metadata: { bucketName: 'videos', objectName: 'u1/clip.mp4', contentType: 'video/mp4' },
|
|
279
|
+
onProgress: (sent, total) => console.log(Math.round((sent / total) * 100), '%'),
|
|
280
|
+
onSuccess: () => console.log('uploaded'),
|
|
281
|
+
});
|
|
282
|
+
upload.findPreviousUploads().then(previous => {
|
|
283
|
+
if (previous[0]) upload.resumeFromPreviousUpload(previous[0]);
|
|
284
|
+
upload.start();
|
|
285
|
+
});
|
|
172
286
|
```
|
|
173
287
|
|
|
174
288
|
## Social sign-in (OAuth)
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@motherbase/client",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.5.0",
|
|
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",
|
|
@@ -13,6 +13,14 @@
|
|
|
13
13
|
".": {
|
|
14
14
|
"types": "./dist/index.d.ts",
|
|
15
15
|
"import": "./dist/index.js"
|
|
16
|
+
},
|
|
17
|
+
"./query": {
|
|
18
|
+
"types": "./dist/query.d.ts",
|
|
19
|
+
"import": "./dist/query.js"
|
|
20
|
+
},
|
|
21
|
+
"./testing": {
|
|
22
|
+
"types": "./dist/testing.d.ts",
|
|
23
|
+
"import": "./dist/testing.js"
|
|
16
24
|
}
|
|
17
25
|
},
|
|
18
26
|
"files": [
|
|
@@ -47,6 +55,6 @@
|
|
|
47
55
|
},
|
|
48
56
|
"devDependencies": {
|
|
49
57
|
"typescript": "^5.4.2",
|
|
50
|
-
"vitest": "^
|
|
58
|
+
"vitest": "^5.0.0"
|
|
51
59
|
}
|
|
52
60
|
}
|
package/dist/admin.d.ts
DELETED
|
@@ -1,81 +0,0 @@
|
|
|
1
|
-
import type { HttpClient } from './http.js';
|
|
2
|
-
import type { MotherbaseResponse, User } from './types.js';
|
|
3
|
-
/**
|
|
4
|
-
* `client.auth.admin`, shaped like `supabase.auth.admin`.
|
|
5
|
-
*
|
|
6
|
-
* Every method here needs a **secret** project API key, so the client it hangs
|
|
7
|
-
* off must have been built with one. A publishable key gets a 401 from the
|
|
8
|
-
* server, which is the correct outcome: these calls create and delete users
|
|
9
|
-
* without being any user.
|
|
10
|
-
*
|
|
11
|
-
* Two differences from supabase-js worth knowing before you port code:
|
|
12
|
-
*
|
|
13
|
-
* * Scope. This is user administration only. Supabase's service key also opens
|
|
14
|
-
* SQL and DDL; here those stay behind operator authentication, so a leaked
|
|
15
|
-
* application key cannot drop a table.
|
|
16
|
-
* * `generateLink` has no equivalent. Better Auth issues one-time codes rather
|
|
17
|
-
* than pre-signed links, so use `auth.signInWithOtp` / `auth.verifyOtp`, or
|
|
18
|
-
* `invite()` below, which mails the credential itself.
|
|
19
|
-
*/
|
|
20
|
-
export interface AdminListUsersParams {
|
|
21
|
-
page?: number;
|
|
22
|
-
perPage?: number;
|
|
23
|
-
}
|
|
24
|
-
export interface AdminUserList {
|
|
25
|
-
users: User[];
|
|
26
|
-
page: number;
|
|
27
|
-
perPage: number;
|
|
28
|
-
total: number;
|
|
29
|
-
}
|
|
30
|
-
export interface AdminCreateUserParams {
|
|
31
|
-
email: string;
|
|
32
|
-
password?: string;
|
|
33
|
-
username?: string;
|
|
34
|
-
role?: 'ADMIN' | 'USER';
|
|
35
|
-
/** Mark the address verified without sending a confirmation. */
|
|
36
|
-
email_confirm?: boolean;
|
|
37
|
-
/** Also email the temporary password. `invite()` is the same thing, named. */
|
|
38
|
-
sendInvite?: boolean;
|
|
39
|
-
}
|
|
40
|
-
export interface AdminCreatedUser {
|
|
41
|
-
user: User;
|
|
42
|
-
/** Generated when no password was supplied. Never logged by the SDK. */
|
|
43
|
-
temporaryPassword: string;
|
|
44
|
-
invited: boolean;
|
|
45
|
-
}
|
|
46
|
-
export interface AdminUpdateUserParams {
|
|
47
|
-
password?: string;
|
|
48
|
-
role?: 'ADMIN' | 'USER';
|
|
49
|
-
username?: string;
|
|
50
|
-
firstName?: string;
|
|
51
|
-
lastName?: string;
|
|
52
|
-
status?: string;
|
|
53
|
-
}
|
|
54
|
-
export declare class AuthAdminClient {
|
|
55
|
-
private readonly http;
|
|
56
|
-
constructor(http: HttpClient);
|
|
57
|
-
listUsers(params?: AdminListUsersParams): Promise<MotherbaseResponse<AdminUserList>>;
|
|
58
|
-
getUserById(id: string): Promise<MotherbaseResponse<{
|
|
59
|
-
user: User | null;
|
|
60
|
-
}>>;
|
|
61
|
-
createUser(params: AdminCreateUserParams): Promise<MotherbaseResponse<AdminCreatedUser>>;
|
|
62
|
-
updateUserById(id: string, params: AdminUpdateUserParams): Promise<MotherbaseResponse<{
|
|
63
|
-
user: User | null;
|
|
64
|
-
}>>;
|
|
65
|
-
deleteUser(id: string): Promise<MotherbaseResponse<{
|
|
66
|
-
id: string;
|
|
67
|
-
}>>;
|
|
68
|
-
/** End every session this user holds, everywhere. */
|
|
69
|
-
signOut(userId: string): Promise<MotherbaseResponse<{
|
|
70
|
-
id: string;
|
|
71
|
-
}>>;
|
|
72
|
-
/** Create the account and email the temporary password to it. */
|
|
73
|
-
inviteUserByEmail(email: string, options?: {
|
|
74
|
-
username?: string;
|
|
75
|
-
role?: 'ADMIN' | 'USER';
|
|
76
|
-
}): Promise<MotherbaseResponse<{
|
|
77
|
-
user: User;
|
|
78
|
-
invited: boolean;
|
|
79
|
-
}>>;
|
|
80
|
-
}
|
|
81
|
-
//# sourceMappingURL=admin.d.ts.map
|
package/dist/admin.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"admin.d.ts","sourceRoot":"","sources":["../src/admin.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AAC5C,OAAO,KAAK,EAAE,kBAAkB,EAAE,IAAI,EAAE,MAAM,YAAY,CAAC;AAE3D;;;;;;;;;;;;;;;;GAgBG;AAEH,MAAM,WAAW,oBAAoB;IACnC,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAED,MAAM,WAAW,aAAa;IAC5B,KAAK,EAAE,IAAI,EAAE,CAAC;IACd,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,EAAE,MAAM,CAAC;CACf;AAED,MAAM,WAAW,qBAAqB;IACpC,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,IAAI,CAAC,EAAE,OAAO,GAAG,MAAM,CAAC;IACxB,gEAAgE;IAChE,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,8EAA8E;IAC9E,UAAU,CAAC,EAAE,OAAO,CAAC;CACtB;AAED,MAAM,WAAW,gBAAgB;IAC/B,IAAI,EAAE,IAAI,CAAC;IACX,wEAAwE;IACxE,iBAAiB,EAAE,MAAM,CAAC;IAC1B,OAAO,EAAE,OAAO,CAAC;CAClB;AAED,MAAM,WAAW,qBAAqB;IACpC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,IAAI,CAAC,EAAE,OAAO,GAAG,MAAM,CAAC;IACxB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,SAAS,CAAC,EAAE,MAAM,CAAC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js';
|
|
2
|
-
const BASE = '/api/auth/admin';
|
|
3
|
-
export class AuthAdminClient {
|
|
4
|
-
constructor(http) {
|
|
5
|
-
this.http = http;
|
|
6
|
-
}
|
|
7
|
-
async listUsers(params = {}) {
|
|
8
|
-
const query = new URLSearchParams();
|
|
9
|
-
if (params.page !== undefined)
|
|
10
|
-
query.set('page', String(params.page));
|
|
11
|
-
if (params.perPage !== undefined)
|
|
12
|
-
query.set('per_page', String(params.perPage));
|
|
13
|
-
const suffix = query.toString();
|
|
14
|
-
try {
|
|
15
|
-
const data = await this.http.request(`${BASE}/users${suffix ? `?${suffix}` : ''}`);
|
|
16
|
-
return { data, error: null };
|
|
17
|
-
}
|
|
18
|
-
catch (err) {
|
|
19
|
-
return { data: null, error: toError(err) };
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
async getUserById(id) {
|
|
23
|
-
try {
|
|
24
|
-
const data = await this.http.request(`${BASE}/users/${encodeURIComponent(id)}`);
|
|
25
|
-
return { data, error: null };
|
|
26
|
-
}
|
|
27
|
-
catch (err) {
|
|
28
|
-
return { data: { user: null }, error: toError(err) };
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
async createUser(params) {
|
|
32
|
-
try {
|
|
33
|
-
const data = await this.http.request(`${BASE}/users`, { method: 'POST', body: params });
|
|
34
|
-
return { data, error: null };
|
|
35
|
-
}
|
|
36
|
-
catch (err) {
|
|
37
|
-
return { data: null, error: toError(err) };
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
async updateUserById(id, params) {
|
|
41
|
-
try {
|
|
42
|
-
const data = await this.http.request(`${BASE}/users/${encodeURIComponent(id)}`, {
|
|
43
|
-
method: 'PATCH',
|
|
44
|
-
body: params,
|
|
45
|
-
});
|
|
46
|
-
return { data, error: null };
|
|
47
|
-
}
|
|
48
|
-
catch (err) {
|
|
49
|
-
return { data: { user: null }, error: toError(err) };
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
async deleteUser(id) {
|
|
53
|
-
try {
|
|
54
|
-
await this.http.request(`${BASE}/users/${encodeURIComponent(id)}`, { method: 'DELETE' });
|
|
55
|
-
return { data: { id }, error: null };
|
|
56
|
-
}
|
|
57
|
-
catch (err) {
|
|
58
|
-
return { data: null, error: toError(err) };
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
/** End every session this user holds, everywhere. */
|
|
62
|
-
async signOut(userId) {
|
|
63
|
-
try {
|
|
64
|
-
await this.http.request(`${BASE}/users/${encodeURIComponent(userId)}/sign-out`, { method: 'POST' });
|
|
65
|
-
return { data: { id: userId }, error: null };
|
|
66
|
-
}
|
|
67
|
-
catch (err) {
|
|
68
|
-
return { data: null, error: toError(err) };
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
/** Create the account and email the temporary password to it. */
|
|
72
|
-
async inviteUserByEmail(email, options = {}) {
|
|
73
|
-
try {
|
|
74
|
-
const data = await this.http.request(`${BASE}/invite`, {
|
|
75
|
-
method: 'POST',
|
|
76
|
-
body: { email, ...options },
|
|
77
|
-
});
|
|
78
|
-
return { data, error: null };
|
|
79
|
-
}
|
|
80
|
-
catch (err) {
|
|
81
|
-
return { data: null, error: toError(err) };
|
|
82
|
-
}
|
|
83
|
-
}
|
|
84
|
-
}
|
|
85
|
-
//# sourceMappingURL=admin.js.map
|
package/dist/admin.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"admin.js","sourceRoot":"","sources":["../src/admin.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AA6DpC,MAAM,IAAI,GAAG,iBAAiB,CAAC;AAE/B,MAAM,OAAO,eAAe;IAC1B,YAA6B,IAAgB;QAAhB,SAAI,GAAJ,IAAI,CAAY;IAAG,CAAC;IAEjD,KAAK,CAAC,SAAS,CAAC,SAA+B,EAAE;QAC/C,MAAM,KAAK,GAAG,IAAI,eAAe,EAAE,CAAC;QACpC,IAAI,MAAM,CAAC,IAA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AC;IACH,CAAC;IAED,qDAAqD;IACrD,KAAK,CAAC,OAAO,CAAC,MAAc;QAC1B,IAAI,CAAC;YACH,MAAM,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,GAAG,IAAI,UAAU,kBAAkB,CAAC,MAAM,CAAC,WAAW,EAAE,EAAE,MAAM,EAAE,MAAM,EAAE,CAAC,CAAC;YACpG,OAAO,EAAE,IAAI,EAAE,EAAE,EAAE,EAAE,MAAM,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC;QAC/C,CAAC;QAAC,OAAO,GAAG,EAAE,CAAC;YACb,OAAO,EAAE,IAAI,EAAE,IAAa,EAAE,KAAK,EAAE,OAAO,CAAC,GAAG,CAAC,EAAE,CAAC;QACtD,CAAC;IACH,CAAC;IAED,iEAAiE;IACjE,KAAK,CAAC,iBAAiB,CACrB,KAAa,EACb,UAA0D,EAAE;QAE5D,IAAI,CAAC;YACH,MAAM,IAAI,GAAG,MAAM,IAAI,CAAC,IAAI,CAAC,OAAO,CAAmC,GAAG,IAAI,SAAS,EAAE;gBACvF,MAAM,EAAE,MAAM;gBACd,IAAI,EAAE,EAAE,KAAK,EAAE,GAAG,OAAO,EAAE;aAC5B,CAAC,CAAC;YACH,OAAO,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC;QAC/B,CAAC;QAAC,OAAO,GAAG,EAAE,CAAC;YACb,OAAO,EAAE,IAAI,EAAE,IAAa,EAAE,KAAK,EAAE,OAAO,CAAC,GAAG,CAAC,EAAE,CAAC;QACtD,CAAC;IACH,CAAC;CACF"}
|
package/dist/auth.d.ts
DELETED
|
@@ -1,233 +0,0 @@
|
|
|
1
|
-
import { MfaClient } from './mfa.js';
|
|
2
|
-
import { AuthAdminClient } from './admin.js';
|
|
3
|
-
import type { HttpClient } from './http.js';
|
|
4
|
-
import type { SessionStore } from './session.js';
|
|
5
|
-
import type { AuthChangeListener, MotherbaseResponse, Session, User } from './types.js';
|
|
6
|
-
export interface SignUpCredentials {
|
|
7
|
-
email: string;
|
|
8
|
-
password: string;
|
|
9
|
-
/** Optional extra profile field supported by the backend. */
|
|
10
|
-
username?: string;
|
|
11
|
-
}
|
|
12
|
-
export interface SignInWithPasswordCredentials {
|
|
13
|
-
email: string;
|
|
14
|
-
password: string;
|
|
15
|
-
}
|
|
16
|
-
export interface SignInWithOtpCredentials {
|
|
17
|
-
email: string;
|
|
18
|
-
}
|
|
19
|
-
export interface VerifyOtpParams {
|
|
20
|
-
email: string;
|
|
21
|
-
/** The OTP code sent to the email. Named `token` for supabase-js parity. */
|
|
22
|
-
token: string;
|
|
23
|
-
/** Accepted for supabase-js signature parity; only the email sign-in OTP flow is supported. */
|
|
24
|
-
type?: 'email';
|
|
25
|
-
}
|
|
26
|
-
export interface SignInWithOAuthCredentials {
|
|
27
|
-
/** Social provider id, e.g. 'google' or 'apple'. Must be enabled on the backend. */
|
|
28
|
-
provider: string;
|
|
29
|
-
options?: {
|
|
30
|
-
/** Where the provider should send the user back to after auth. */
|
|
31
|
-
redirectTo?: string;
|
|
32
|
-
/** Space-separated OAuth scopes. */
|
|
33
|
-
scopes?: string;
|
|
34
|
-
/** Skip the automatic `window.location` redirect and just return the URL. */
|
|
35
|
-
skipBrowserRedirect?: boolean;
|
|
36
|
-
};
|
|
37
|
-
}
|
|
38
|
-
export interface DeleteUserAttributes {
|
|
39
|
-
/** Required unless the session is already "fresh" (i.e. just re-authenticated). */
|
|
40
|
-
password?: string;
|
|
41
|
-
/** Deletion-confirmation token, when the backend's delete flow requires an email confirmation step. */
|
|
42
|
-
token?: string;
|
|
43
|
-
callbackURL?: string;
|
|
44
|
-
}
|
|
45
|
-
export interface UpdateUserAttributes {
|
|
46
|
-
/** New password. Requires `currentPassword` — the backend does not allow a
|
|
47
|
-
* blind password change from an authenticated session. */
|
|
48
|
-
password?: string;
|
|
49
|
-
currentPassword?: string;
|
|
50
|
-
/** Arbitrary profile fields (name, image, or any custom additional field). */
|
|
51
|
-
data?: Record<string, unknown>;
|
|
52
|
-
}
|
|
53
|
-
/**
|
|
54
|
-
* Read the token an OAuth callback left in the URL fragment and return the URL
|
|
55
|
-
* with it removed, so a reload or a shared link cannot replay it.
|
|
56
|
-
*
|
|
57
|
-
* The provider callback cannot answer the SDK with a JSON body: it is a browser
|
|
58
|
-
* redirect. The backend therefore appends `#access_token=…` to the redirect it
|
|
59
|
-
* issues, the same implicit flow supabase-js reads. Exported for testing.
|
|
60
|
-
*/
|
|
61
|
-
export declare function readAccessTokenFromUrl(href: string): {
|
|
62
|
-
accessToken: string;
|
|
63
|
-
cleanedHref: string;
|
|
64
|
-
} | null;
|
|
65
|
-
export interface Subscription {
|
|
66
|
-
unsubscribe(): void;
|
|
67
|
-
}
|
|
68
|
-
/**
|
|
69
|
-
* Supabase-compatible auth client. Maps supabase-js method names onto the
|
|
70
|
-
* Motherbase auth endpoints and reuses the existing token/refresh/session-store
|
|
71
|
-
* machinery. Returns `{ data, error }` and never throws for expected failures.
|
|
72
|
-
*/
|
|
73
|
-
export declare class AuthClient {
|
|
74
|
-
private readonly http;
|
|
75
|
-
private readonly store;
|
|
76
|
-
/**
|
|
77
|
-
* Two-factor, shaped like `supabase.auth.mfa`. The server has shipped TOTP
|
|
78
|
-
* from the start; this is the namespace that makes it reachable.
|
|
79
|
-
*/
|
|
80
|
-
readonly mfa: MfaClient;
|
|
81
|
-
/**
|
|
82
|
-
* User administration for server code holding a secret key. Present on every
|
|
83
|
-
* client, because whether the key is secret is a server-side fact: calling
|
|
84
|
-
* these with a publishable key is a 401, not a missing method.
|
|
85
|
-
*/
|
|
86
|
-
readonly admin: AuthAdminClient;
|
|
87
|
-
constructor(http: HttpClient, store: SessionStore);
|
|
88
|
-
signUp(credentials: SignUpCredentials): Promise<MotherbaseResponse<{
|
|
89
|
-
user: User | null;
|
|
90
|
-
session: Session | null;
|
|
91
|
-
}>>;
|
|
92
|
-
signInWithPassword(credentials: SignInWithPasswordCredentials): Promise<MotherbaseResponse<{
|
|
93
|
-
user: User | null;
|
|
94
|
-
session: Session | null;
|
|
95
|
-
}>>;
|
|
96
|
-
/**
|
|
97
|
-
* Request a password-reset OTP by email. Always resolves successfully
|
|
98
|
-
* (whether or not the email is registered) to avoid leaking account
|
|
99
|
-
* existence; check `error` only for transport/server failures.
|
|
100
|
-
*/
|
|
101
|
-
resetPasswordForEmail(email: string): Promise<{
|
|
102
|
-
error: MotherbaseResponse<null>['error'];
|
|
103
|
-
}>;
|
|
104
|
-
/** Complete a password reset using the OTP sent to the user's email. */
|
|
105
|
-
resetPassword(args: {
|
|
106
|
-
email: string;
|
|
107
|
-
otp: string;
|
|
108
|
-
password: string;
|
|
109
|
-
}): Promise<{
|
|
110
|
-
error: MotherbaseResponse<null>['error'];
|
|
111
|
-
}>;
|
|
112
|
-
/** Send a one-time sign-in code by email. Pair with `verifyOtp` to complete sign-in. */
|
|
113
|
-
signInWithOtp(credentials: SignInWithOtpCredentials): Promise<{
|
|
114
|
-
data: Record<string, never>;
|
|
115
|
-
error: MotherbaseResponse<null>['error'];
|
|
116
|
-
}>;
|
|
117
|
-
/** Complete a `signInWithOtp` sign-in using the code sent to the user's email. */
|
|
118
|
-
verifyOtp(params: VerifyOtpParams): Promise<MotherbaseResponse<{
|
|
119
|
-
user: User | null;
|
|
120
|
-
session: Session | null;
|
|
121
|
-
}>>;
|
|
122
|
-
/**
|
|
123
|
-
* Start an OAuth sign-in with a configured social provider. Resolves with the
|
|
124
|
-
* provider's authorize URL and, in a browser, redirects to it immediately
|
|
125
|
-
* unless `options.skipBrowserRedirect` is set.
|
|
126
|
-
*/
|
|
127
|
-
signInWithOAuth(credentials: SignInWithOAuthCredentials): Promise<MotherbaseResponse<{
|
|
128
|
-
provider: string;
|
|
129
|
-
url: string | null;
|
|
130
|
-
}>>;
|
|
131
|
-
/**
|
|
132
|
-
* Start an enterprise SSO sign-in. Identify the provider by the user's email
|
|
133
|
-
* domain, by an explicit `domain`, or by `providerId` when you already know
|
|
134
|
-
* which one to use.
|
|
135
|
-
*
|
|
136
|
-
* Resolves with the identity provider's URL and, in a browser, redirects to it
|
|
137
|
-
* unless `options.skipBrowserRedirect` is set. The project must have the SSO
|
|
138
|
-
* plugin enabled and at least one provider registered (Studio →
|
|
139
|
-
* Authentication → Organizations & SSO).
|
|
140
|
-
*/
|
|
141
|
-
signInWithSSO(params: {
|
|
142
|
-
domain?: string;
|
|
143
|
-
email?: string;
|
|
144
|
-
providerId?: string;
|
|
145
|
-
organizationSlug?: string;
|
|
146
|
-
options?: {
|
|
147
|
-
redirectTo?: string;
|
|
148
|
-
skipBrowserRedirect?: boolean;
|
|
149
|
-
};
|
|
150
|
-
}): Promise<MotherbaseResponse<{
|
|
151
|
-
url: string | null;
|
|
152
|
-
}>>;
|
|
153
|
-
/**
|
|
154
|
-
* Update the signed-in user's profile fields and/or password. Password
|
|
155
|
-
* changes require `currentPassword` (a Better Auth requirement — there is no
|
|
156
|
-
* blind password overwrite from an authenticated session).
|
|
157
|
-
*/
|
|
158
|
-
updateUser(attributes: UpdateUserAttributes): Promise<MotherbaseResponse<{
|
|
159
|
-
user: User | null;
|
|
160
|
-
}>>;
|
|
161
|
-
/**
|
|
162
|
-
* Permanently delete the signed-in user's account. Not part of the
|
|
163
|
-
* supabase-js client surface (there it's admin-only) — kept here because
|
|
164
|
-
* self-service account deletion is a real product need. Requires the
|
|
165
|
-
* backend's `delete-user` flow to be enabled; clears the local session on
|
|
166
|
-
* success.
|
|
167
|
-
*/
|
|
168
|
-
deleteUser(attributes?: DeleteUserAttributes): Promise<{
|
|
169
|
-
error: MotherbaseResponse<null>['error'];
|
|
170
|
-
}>;
|
|
171
|
-
/**
|
|
172
|
-
* Adopt an externally-obtained access token as the current session (e.g. one
|
|
173
|
-
* captured from an OAuth redirect). Validates it against the server before
|
|
174
|
-
* persisting. `refresh_token` is accepted for supabase-js signature parity
|
|
175
|
-
* and unused — Better Auth bearer sessions have none.
|
|
176
|
-
*/
|
|
177
|
-
setSession(currentSession: {
|
|
178
|
-
access_token: string;
|
|
179
|
-
refresh_token?: string;
|
|
180
|
-
}): Promise<MotherbaseResponse<{
|
|
181
|
-
user: User | null;
|
|
182
|
-
session: Session | null;
|
|
183
|
-
}>>;
|
|
184
|
-
signOut(): Promise<{
|
|
185
|
-
error: MotherbaseResponse<null>['error'];
|
|
186
|
-
}>;
|
|
187
|
-
/**
|
|
188
|
-
* Finish an OAuth / SSO sign-in after the provider redirected back.
|
|
189
|
-
*
|
|
190
|
-
* `signInWithOAuth` only starts the flow; the session is created during the
|
|
191
|
-
* redirect the browser makes to the backend callback, so the SDK has to pick
|
|
192
|
-
* it up from the URL the browser landed on. Call this once on the page you
|
|
193
|
-
* pointed `redirectTo` at (or on app start, which is where supabase-js does
|
|
194
|
-
* the equivalent). Without it the user is signed in on the backend and signed
|
|
195
|
-
* out in your app.
|
|
196
|
-
*
|
|
197
|
-
* Resolves with a null session and no error when there is nothing to read, so
|
|
198
|
-
* it is safe to call on every page load.
|
|
199
|
-
*/
|
|
200
|
-
getSessionFromUrl(href?: string): Promise<MotherbaseResponse<{
|
|
201
|
-
user: User | null;
|
|
202
|
-
session: Session | null;
|
|
203
|
-
}>>;
|
|
204
|
-
/** Fetch the current user from Better Auth (requires a valid session). */
|
|
205
|
-
getUser(): Promise<MotherbaseResponse<{
|
|
206
|
-
user: User | null;
|
|
207
|
-
}>>;
|
|
208
|
-
/** The locally-held session, if any (no network call). */
|
|
209
|
-
getSession(): Promise<MotherbaseResponse<{
|
|
210
|
-
session: Session | null;
|
|
211
|
-
}>>;
|
|
212
|
-
/**
|
|
213
|
-
* Revalidate the current session against the server. Better Auth bearer
|
|
214
|
-
* sessions have no refresh token — if the session is still valid the user is
|
|
215
|
-
* refreshed; otherwise the local session is cleared.
|
|
216
|
-
*/
|
|
217
|
-
refreshSession(): Promise<MotherbaseResponse<{
|
|
218
|
-
user: User | null;
|
|
219
|
-
session: Session | null;
|
|
220
|
-
}>>;
|
|
221
|
-
onAuthStateChange(callback: AuthChangeListener): {
|
|
222
|
-
data: {
|
|
223
|
-
subscription: Subscription;
|
|
224
|
-
};
|
|
225
|
-
};
|
|
226
|
-
/**
|
|
227
|
-
* Internal: refresh used by the HttpClient's 401 path. Returns true on success.
|
|
228
|
-
* Not part of the public Supabase surface.
|
|
229
|
-
*/
|
|
230
|
-
_refresh(): Promise<boolean>;
|
|
231
|
-
private persist;
|
|
232
|
-
}
|
|
233
|
-
//# sourceMappingURL=auth.d.ts.map
|
package/dist/auth.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"auth.d.ts","sourceRoot":"","sources":["../src/auth.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AACrC,OAAO,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAE7C,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AAC5C,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AACjD,OAAO,KAAK,EAEV,kBAAkB,EAElB,kBAAkB,EAClB,OAAO,EACP,IAAI,EACL,MAAM,YAAY,CAAC;AAEpB,MAAM,WAAW,iBAAiB;IAChC,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,MAAM,CAAC;IACjB,6DAA6D;IAC7D,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAED,MAAM,WAAW,6BAA6B;IAC5C,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,MAAM,CAAC;CAClB;AAED,MAAM,WAAW,wBAAwB;IACvC,KAAK,EAAE,MAAM,CAAC;CACf;AAED,MAAM,WAAW,eAAe;IAC9B,KAAK,EAAE,MAAM,CAAC;IACd,4EAA4E;IAC5E,KAAK,EAAE,MAAM,CAAC;IACd,+FAA+F;IAC/F,IAAI,CAAC,EAAE,OAAO,CAAC;CAChB;AAED,MAAM,WAAW,0BAA0B;IACzC,oFAAoF;IACpF,QAAQ,EAAE,MAAM,CAAC;IACjB,OAAO,CAAC,E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