@headless-lms/adapter-auth 0.3.0 → 0.4.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/access-grant.d.ts +2 -4
- package/dist/access-grant.js +11 -20
- package/dist/access-grant.js.map +1 -1
- package/dist/access.d.ts +17 -78
- package/dist/access.js +7 -45
- package/dist/access.js.map +1 -1
- package/dist/better-auth.d.ts +598 -461
- package/dist/better-auth.js +221 -156
- package/dist/better-auth.js.map +1 -1
- package/dist/index.d.ts +3 -3
- package/dist/index.js +3 -3
- package/package.json +3 -3
package/dist/better-auth.d.ts
CHANGED
|
@@ -1,15 +1,19 @@
|
|
|
1
1
|
import { CreateAuthOptions, Hooks } from "./types.js";
|
|
2
2
|
import { SessionAdmin } from "@headless-lms/core/identity";
|
|
3
|
-
import { AuthHeaders, AuthOrganization,
|
|
3
|
+
import { Accounts, ApiKeys, AuthHeaders, AuthOrganization, NewApiKey, OrgAdmin, PlatformAccount, StoredApiKey, UpdateOrganizationInput } from "@headless-lms/core/organizations";
|
|
4
4
|
import { AccessTokenAuthorization } from "better-auth/oauth2";
|
|
5
5
|
import { BetterAuthOptions, BetterAuthPlugin } from "better-auth";
|
|
6
|
-
import { AccessGrant, AccessRequest, AccessTokenVerifier, ActiveSession,
|
|
6
|
+
import { AccessGrant, AccessRequest, AccessTokenVerifier, ActiveSession, ConnectedApp, HeaderBag, Logger, NewOrganizationInput, SessionVerifier } from "@headless-lms/core/types";
|
|
7
7
|
import { IncomingHttpHeaders } from "node:http";
|
|
8
8
|
//#region src/better-auth.d.ts
|
|
9
|
+
declare const API_KEY_PREFIX = "hlms_";
|
|
9
10
|
declare function buildAuthOptions(opts: CreateAuthOptions): {
|
|
10
11
|
baseURL: string;
|
|
11
12
|
secret: string;
|
|
12
13
|
trustedOrigins: string[];
|
|
14
|
+
logger: {
|
|
15
|
+
log: (level: "debug" | "info" | "warn" | "error", message: string, ...args: any[]) => void;
|
|
16
|
+
};
|
|
13
17
|
session: {
|
|
14
18
|
cookieCache: {
|
|
15
19
|
enabled: true;
|
|
@@ -169,18 +173,12 @@ declare function buildAuthOptions(opts: CreateAuthOptions): {
|
|
|
169
173
|
}, import("better-auth/plugins").DefaultOrganizationPlugin<{
|
|
170
174
|
ac: {
|
|
171
175
|
newRole<const TRoleStatements extends import("better-auth/plugins").Statements>(statements: import("better-auth/plugins").RoleInput<{
|
|
172
|
-
readonly course: readonly ["create", "read", "update", "delete"];
|
|
173
|
-
readonly progress: readonly ["view"];
|
|
174
|
-
readonly community: readonly ["moderate"];
|
|
175
176
|
readonly organization: readonly ["update", "delete"];
|
|
176
177
|
readonly member: readonly ["create", "update", "delete"];
|
|
177
178
|
readonly invitation: readonly ["create", "cancel"];
|
|
178
179
|
readonly team: readonly ["create", "update", "delete"];
|
|
179
180
|
readonly ac: readonly ["create", "read", "update", "delete"];
|
|
180
181
|
}, TRoleStatements>): import("better-auth/plugins").Role<import("better-auth/plugins").ExactRoleStatements<TRoleStatements>, {
|
|
181
|
-
readonly course: readonly ["create", "read", "update", "delete"];
|
|
182
|
-
readonly progress: readonly ["view"];
|
|
183
|
-
readonly community: readonly ["moderate"];
|
|
184
182
|
readonly organization: readonly ["update", "delete"];
|
|
185
183
|
readonly member: readonly ["create", "update", "delete"];
|
|
186
184
|
readonly invitation: readonly ["create", "cancel"];
|
|
@@ -188,9 +186,6 @@ declare function buildAuthOptions(opts: CreateAuthOptions): {
|
|
|
188
186
|
readonly ac: readonly ["create", "read", "update", "delete"];
|
|
189
187
|
}>;
|
|
190
188
|
statements: {
|
|
191
|
-
readonly course: readonly ["create", "read", "update", "delete"];
|
|
192
|
-
readonly progress: readonly ["view"];
|
|
193
|
-
readonly community: readonly ["moderate"];
|
|
194
189
|
readonly organization: readonly ["update", "delete"];
|
|
195
190
|
readonly member: readonly ["create", "update", "delete"];
|
|
196
191
|
readonly invitation: readonly ["create", "cancel"];
|
|
@@ -199,77 +194,26 @@ declare function buildAuthOptions(opts: CreateAuthOptions): {
|
|
|
199
194
|
};
|
|
200
195
|
};
|
|
201
196
|
roles: {
|
|
202
|
-
owner: import("better-auth/plugins").Role<import("better-auth/plugins").ExactRoleStatements<{
|
|
203
|
-
readonly
|
|
204
|
-
readonly
|
|
205
|
-
readonly
|
|
206
|
-
readonly
|
|
207
|
-
readonly
|
|
208
|
-
|
|
209
|
-
readonly team: readonly ["create", "update", "delete"];
|
|
210
|
-
readonly ac: readonly ["create", "read", "update", "delete"];
|
|
211
|
-
}>, {
|
|
212
|
-
readonly course: readonly ["create", "read", "update", "delete"];
|
|
213
|
-
readonly progress: readonly ["view"];
|
|
214
|
-
readonly community: readonly ["moderate"];
|
|
215
|
-
readonly organization: readonly ["update", "delete"];
|
|
216
|
-
readonly member: readonly ["create", "update", "delete"];
|
|
217
|
-
readonly invitation: readonly ["create", "cancel"];
|
|
218
|
-
readonly team: readonly ["create", "update", "delete"];
|
|
219
|
-
readonly ac: readonly ["create", "read", "update", "delete"];
|
|
220
|
-
}>;
|
|
221
|
-
admin: import("better-auth/plugins").Role<import("better-auth/plugins").ExactRoleStatements<{
|
|
222
|
-
readonly course: ["create", "read", "update", "delete"];
|
|
223
|
-
readonly progress: ["view"];
|
|
224
|
-
readonly community: ["moderate"];
|
|
225
|
-
readonly organization: readonly ["update"];
|
|
226
|
-
readonly invitation: readonly ["create", "cancel"];
|
|
227
|
-
readonly member: readonly ["create", "update", "delete"];
|
|
228
|
-
readonly team: readonly ["create", "update", "delete"];
|
|
229
|
-
readonly ac: readonly ["create", "read", "update", "delete"];
|
|
230
|
-
}>, {
|
|
231
|
-
readonly course: readonly ["create", "read", "update", "delete"];
|
|
232
|
-
readonly progress: readonly ["view"];
|
|
233
|
-
readonly community: readonly ["moderate"];
|
|
234
|
-
readonly organization: readonly ["update", "delete"];
|
|
235
|
-
readonly member: readonly ["create", "update", "delete"];
|
|
236
|
-
readonly invitation: readonly ["create", "cancel"];
|
|
237
|
-
readonly team: readonly ["create", "update", "delete"];
|
|
238
|
-
readonly ac: readonly ["create", "read", "update", "delete"];
|
|
239
|
-
}>;
|
|
240
|
-
instructor: import("better-auth/plugins").Role<import("better-auth/plugins").ExactRoleStatements<{
|
|
241
|
-
readonly course: ["read", "update"];
|
|
242
|
-
readonly progress: ["view"];
|
|
243
|
-
readonly community: ["moderate"];
|
|
244
|
-
}>, {
|
|
245
|
-
readonly course: readonly ["create", "read", "update", "delete"];
|
|
246
|
-
readonly progress: readonly ["view"];
|
|
247
|
-
readonly community: readonly ["moderate"];
|
|
197
|
+
owner: import("better-auth/plugins").Role<import("better-auth/plugins").ExactRoleStatements<import("better-auth/plugins").ExactRoleStatements<{
|
|
198
|
+
readonly organization: ["update", "delete"];
|
|
199
|
+
readonly member: ["create", "update", "delete"];
|
|
200
|
+
readonly invitation: ["create", "cancel"];
|
|
201
|
+
readonly team: ["create", "update", "delete"];
|
|
202
|
+
readonly ac: ["create", "read", "update", "delete"];
|
|
203
|
+
}>>, {
|
|
248
204
|
readonly organization: readonly ["update", "delete"];
|
|
249
205
|
readonly member: readonly ["create", "update", "delete"];
|
|
250
206
|
readonly invitation: readonly ["create", "cancel"];
|
|
251
207
|
readonly team: readonly ["create", "update", "delete"];
|
|
252
208
|
readonly ac: readonly ["create", "read", "update", "delete"];
|
|
253
209
|
}>;
|
|
254
|
-
|
|
255
|
-
readonly
|
|
256
|
-
readonly
|
|
257
|
-
|
|
258
|
-
readonly
|
|
259
|
-
readonly
|
|
260
|
-
|
|
261
|
-
readonly organization: readonly ["update", "delete"];
|
|
262
|
-
readonly member: readonly ["create", "update", "delete"];
|
|
263
|
-
readonly invitation: readonly ["create", "cancel"];
|
|
264
|
-
readonly team: readonly ["create", "update", "delete"];
|
|
265
|
-
readonly ac: readonly ["create", "read", "update", "delete"];
|
|
266
|
-
}>;
|
|
267
|
-
student: import("better-auth/plugins").Role<import("better-auth/plugins").ExactRoleStatements<{
|
|
268
|
-
readonly course: ["read"];
|
|
269
|
-
}>, {
|
|
270
|
-
readonly course: readonly ["create", "read", "update", "delete"];
|
|
271
|
-
readonly progress: readonly ["view"];
|
|
272
|
-
readonly community: readonly ["moderate"];
|
|
210
|
+
participant: import("better-auth/plugins").Role<import("better-auth/plugins").ExactRoleStatements<import("better-auth/plugins").ExactRoleStatements<{
|
|
211
|
+
readonly organization: [];
|
|
212
|
+
readonly member: [];
|
|
213
|
+
readonly invitation: [];
|
|
214
|
+
readonly team: [];
|
|
215
|
+
readonly ac: ["read"];
|
|
216
|
+
}>>, {
|
|
273
217
|
readonly organization: readonly ["update", "delete"];
|
|
274
218
|
readonly member: readonly ["create", "update", "delete"];
|
|
275
219
|
readonly invitation: readonly ["create", "cancel"];
|
|
@@ -278,146 +222,9 @@ declare function buildAuthOptions(opts: CreateAuthOptions): {
|
|
|
278
222
|
}>;
|
|
279
223
|
};
|
|
280
224
|
creatorRole: string;
|
|
225
|
+
membershipLimit: number;
|
|
281
226
|
organizationHooks: Hooks;
|
|
282
|
-
}>, BetterAuthPlugin, ...BetterAuthPlugin[], BetterAuthPlugin
|
|
283
|
-
id: "custom-session";
|
|
284
|
-
version: string;
|
|
285
|
-
hooks: {
|
|
286
|
-
after: {
|
|
287
|
-
matcher: (ctx: import("better-auth").HookEndpointContext) => boolean;
|
|
288
|
-
handler: import("better-auth").Middleware<import("better-auth").MiddlewareOptions, (inputContext: import("better-auth").MiddlewareInputContext<import("better-auth").MiddlewareOptions>) => Promise<{
|
|
289
|
-
user: {
|
|
290
|
-
id: string;
|
|
291
|
-
createdAt: Date;
|
|
292
|
-
updatedAt: Date;
|
|
293
|
-
email: string;
|
|
294
|
-
emailVerified: boolean;
|
|
295
|
-
name: string;
|
|
296
|
-
image?: string | null | undefined;
|
|
297
|
-
};
|
|
298
|
-
session: {
|
|
299
|
-
id: string;
|
|
300
|
-
createdAt: Date;
|
|
301
|
-
updatedAt: Date;
|
|
302
|
-
userId: string;
|
|
303
|
-
expiresAt: Date;
|
|
304
|
-
token: string;
|
|
305
|
-
ipAddress?: string | null | undefined;
|
|
306
|
-
userAgent?: string | null | undefined;
|
|
307
|
-
};
|
|
308
|
-
activeMemberRole: string | null;
|
|
309
|
-
activeOrganization: {
|
|
310
|
-
id: string;
|
|
311
|
-
name: string;
|
|
312
|
-
slug: string;
|
|
313
|
-
} | null;
|
|
314
|
-
organizations: {
|
|
315
|
-
id: string;
|
|
316
|
-
name: string;
|
|
317
|
-
slug: string;
|
|
318
|
-
}[];
|
|
319
|
-
}[] | undefined>>;
|
|
320
|
-
}[];
|
|
321
|
-
};
|
|
322
|
-
endpoints: {
|
|
323
|
-
getSession: import("better-auth").StrictEndpoint<"/get-session", {
|
|
324
|
-
method: "GET";
|
|
325
|
-
query: import("better-auth").ZodOptional<import("better-auth").ZodObject<{
|
|
326
|
-
disableCookieCache: import("better-auth").ZodOptional<import("better-auth").ZodCoercedBoolean<unknown>>;
|
|
327
|
-
disableRefresh: import("better-auth").ZodOptional<import("better-auth").ZodCoercedBoolean<unknown>>;
|
|
328
|
-
}, import("zod/v4/core").$strip>>;
|
|
329
|
-
metadata: {
|
|
330
|
-
CUSTOM_SESSION: boolean;
|
|
331
|
-
openapi: {
|
|
332
|
-
description: string;
|
|
333
|
-
responses: {
|
|
334
|
-
"200": {
|
|
335
|
-
description: string;
|
|
336
|
-
content: {
|
|
337
|
-
"application/json": {
|
|
338
|
-
schema: {
|
|
339
|
-
type: "array";
|
|
340
|
-
nullable: boolean;
|
|
341
|
-
items: {
|
|
342
|
-
$ref: string;
|
|
343
|
-
};
|
|
344
|
-
};
|
|
345
|
-
};
|
|
346
|
-
};
|
|
347
|
-
};
|
|
348
|
-
};
|
|
349
|
-
};
|
|
350
|
-
};
|
|
351
|
-
requireHeaders: true;
|
|
352
|
-
}, {
|
|
353
|
-
user: {
|
|
354
|
-
id: string;
|
|
355
|
-
createdAt: Date;
|
|
356
|
-
updatedAt: Date;
|
|
357
|
-
email: string;
|
|
358
|
-
emailVerified: boolean;
|
|
359
|
-
name: string;
|
|
360
|
-
image?: string | null | undefined;
|
|
361
|
-
};
|
|
362
|
-
session: {
|
|
363
|
-
id: string;
|
|
364
|
-
createdAt: Date;
|
|
365
|
-
updatedAt: Date;
|
|
366
|
-
userId: string;
|
|
367
|
-
expiresAt: Date;
|
|
368
|
-
token: string;
|
|
369
|
-
ipAddress?: string | null | undefined;
|
|
370
|
-
userAgent?: string | null | undefined;
|
|
371
|
-
};
|
|
372
|
-
activeMemberRole: string | null;
|
|
373
|
-
activeOrganization: {
|
|
374
|
-
id: string;
|
|
375
|
-
name: string;
|
|
376
|
-
slug: string;
|
|
377
|
-
} | null;
|
|
378
|
-
organizations: {
|
|
379
|
-
id: string;
|
|
380
|
-
name: string;
|
|
381
|
-
slug: string;
|
|
382
|
-
}[];
|
|
383
|
-
} | null>;
|
|
384
|
-
};
|
|
385
|
-
$Infer: {
|
|
386
|
-
Session: {
|
|
387
|
-
user: {
|
|
388
|
-
id: string;
|
|
389
|
-
createdAt: Date;
|
|
390
|
-
updatedAt: Date;
|
|
391
|
-
email: string;
|
|
392
|
-
emailVerified: boolean;
|
|
393
|
-
name: string;
|
|
394
|
-
image?: string | null | undefined;
|
|
395
|
-
};
|
|
396
|
-
session: {
|
|
397
|
-
id: string;
|
|
398
|
-
createdAt: Date;
|
|
399
|
-
updatedAt: Date;
|
|
400
|
-
userId: string;
|
|
401
|
-
expiresAt: Date;
|
|
402
|
-
token: string;
|
|
403
|
-
ipAddress?: string | null | undefined;
|
|
404
|
-
userAgent?: string | null | undefined;
|
|
405
|
-
};
|
|
406
|
-
activeMemberRole: string | null;
|
|
407
|
-
activeOrganization: {
|
|
408
|
-
id: string;
|
|
409
|
-
name: string;
|
|
410
|
-
slug: string;
|
|
411
|
-
} | null;
|
|
412
|
-
organizations: {
|
|
413
|
-
id: string;
|
|
414
|
-
name: string;
|
|
415
|
-
slug: string;
|
|
416
|
-
}[];
|
|
417
|
-
};
|
|
418
|
-
};
|
|
419
|
-
options: import("better-auth/plugins").CustomSessionPluginOptions | undefined;
|
|
420
|
-
}];
|
|
227
|
+
}>, BetterAuthPlugin, ...BetterAuthPlugin[], BetterAuthPlugin];
|
|
421
228
|
hooks: {
|
|
422
229
|
before: import("better-auth").Middleware<import("better-auth").MiddlewareOptions, (inputContext: import("better-auth").MiddlewareInputContext<import("better-auth").MiddlewareOptions>) => Promise<{
|
|
423
230
|
context: {
|
|
@@ -446,6 +253,9 @@ declare function createAuth(opts: CreateAuthOptions): import("better-auth").Auth
|
|
|
446
253
|
baseURL: string;
|
|
447
254
|
secret: string;
|
|
448
255
|
trustedOrigins: string[];
|
|
256
|
+
logger: {
|
|
257
|
+
log: (level: "debug" | "info" | "warn" | "error", message: string, ...args: any[]) => void;
|
|
258
|
+
};
|
|
449
259
|
session: {
|
|
450
260
|
cookieCache: {
|
|
451
261
|
enabled: true;
|
|
@@ -605,18 +415,12 @@ declare function createAuth(opts: CreateAuthOptions): import("better-auth").Auth
|
|
|
605
415
|
}, import("better-auth/plugins").DefaultOrganizationPlugin<{
|
|
606
416
|
ac: {
|
|
607
417
|
newRole<const TRoleStatements extends import("better-auth/plugins").Statements>(statements: import("better-auth/plugins").RoleInput<{
|
|
608
|
-
readonly course: readonly ["create", "read", "update", "delete"];
|
|
609
|
-
readonly progress: readonly ["view"];
|
|
610
|
-
readonly community: readonly ["moderate"];
|
|
611
418
|
readonly organization: readonly ["update", "delete"];
|
|
612
419
|
readonly member: readonly ["create", "update", "delete"];
|
|
613
420
|
readonly invitation: readonly ["create", "cancel"];
|
|
614
421
|
readonly team: readonly ["create", "update", "delete"];
|
|
615
422
|
readonly ac: readonly ["create", "read", "update", "delete"];
|
|
616
423
|
}, TRoleStatements>): import("better-auth/plugins").Role<import("better-auth/plugins").ExactRoleStatements<TRoleStatements>, {
|
|
617
|
-
readonly course: readonly ["create", "read", "update", "delete"];
|
|
618
|
-
readonly progress: readonly ["view"];
|
|
619
|
-
readonly community: readonly ["moderate"];
|
|
620
424
|
readonly organization: readonly ["update", "delete"];
|
|
621
425
|
readonly member: readonly ["create", "update", "delete"];
|
|
622
426
|
readonly invitation: readonly ["create", "cancel"];
|
|
@@ -624,9 +428,6 @@ declare function createAuth(opts: CreateAuthOptions): import("better-auth").Auth
|
|
|
624
428
|
readonly ac: readonly ["create", "read", "update", "delete"];
|
|
625
429
|
}>;
|
|
626
430
|
statements: {
|
|
627
|
-
readonly course: readonly ["create", "read", "update", "delete"];
|
|
628
|
-
readonly progress: readonly ["view"];
|
|
629
|
-
readonly community: readonly ["moderate"];
|
|
630
431
|
readonly organization: readonly ["update", "delete"];
|
|
631
432
|
readonly member: readonly ["create", "update", "delete"];
|
|
632
433
|
readonly invitation: readonly ["create", "cancel"];
|
|
@@ -635,77 +436,26 @@ declare function createAuth(opts: CreateAuthOptions): import("better-auth").Auth
|
|
|
635
436
|
};
|
|
636
437
|
};
|
|
637
438
|
roles: {
|
|
638
|
-
owner: import("better-auth/plugins").Role<import("better-auth/plugins").ExactRoleStatements<{
|
|
639
|
-
readonly
|
|
640
|
-
readonly
|
|
641
|
-
readonly
|
|
642
|
-
readonly
|
|
643
|
-
readonly
|
|
644
|
-
|
|
645
|
-
readonly team: readonly ["create", "update", "delete"];
|
|
646
|
-
readonly ac: readonly ["create", "read", "update", "delete"];
|
|
647
|
-
}>, {
|
|
648
|
-
readonly course: readonly ["create", "read", "update", "delete"];
|
|
649
|
-
readonly progress: readonly ["view"];
|
|
650
|
-
readonly community: readonly ["moderate"];
|
|
651
|
-
readonly organization: readonly ["update", "delete"];
|
|
652
|
-
readonly member: readonly ["create", "update", "delete"];
|
|
653
|
-
readonly invitation: readonly ["create", "cancel"];
|
|
654
|
-
readonly team: readonly ["create", "update", "delete"];
|
|
655
|
-
readonly ac: readonly ["create", "read", "update", "delete"];
|
|
656
|
-
}>;
|
|
657
|
-
admin: import("better-auth/plugins").Role<import("better-auth/plugins").ExactRoleStatements<{
|
|
658
|
-
readonly course: ["create", "read", "update", "delete"];
|
|
659
|
-
readonly progress: ["view"];
|
|
660
|
-
readonly community: ["moderate"];
|
|
661
|
-
readonly organization: readonly ["update"];
|
|
662
|
-
readonly invitation: readonly ["create", "cancel"];
|
|
663
|
-
readonly member: readonly ["create", "update", "delete"];
|
|
664
|
-
readonly team: readonly ["create", "update", "delete"];
|
|
665
|
-
readonly ac: readonly ["create", "read", "update", "delete"];
|
|
666
|
-
}>, {
|
|
667
|
-
readonly course: readonly ["create", "read", "update", "delete"];
|
|
668
|
-
readonly progress: readonly ["view"];
|
|
669
|
-
readonly community: readonly ["moderate"];
|
|
670
|
-
readonly organization: readonly ["update", "delete"];
|
|
671
|
-
readonly member: readonly ["create", "update", "delete"];
|
|
672
|
-
readonly invitation: readonly ["create", "cancel"];
|
|
673
|
-
readonly team: readonly ["create", "update", "delete"];
|
|
674
|
-
readonly ac: readonly ["create", "read", "update", "delete"];
|
|
675
|
-
}>;
|
|
676
|
-
instructor: import("better-auth/plugins").Role<import("better-auth/plugins").ExactRoleStatements<{
|
|
677
|
-
readonly course: ["read", "update"];
|
|
678
|
-
readonly progress: ["view"];
|
|
679
|
-
readonly community: ["moderate"];
|
|
680
|
-
}>, {
|
|
681
|
-
readonly course: readonly ["create", "read", "update", "delete"];
|
|
682
|
-
readonly progress: readonly ["view"];
|
|
683
|
-
readonly community: readonly ["moderate"];
|
|
439
|
+
owner: import("better-auth/plugins").Role<import("better-auth/plugins").ExactRoleStatements<import("better-auth/plugins").ExactRoleStatements<{
|
|
440
|
+
readonly organization: ["update", "delete"];
|
|
441
|
+
readonly member: ["create", "update", "delete"];
|
|
442
|
+
readonly invitation: ["create", "cancel"];
|
|
443
|
+
readonly team: ["create", "update", "delete"];
|
|
444
|
+
readonly ac: ["create", "read", "update", "delete"];
|
|
445
|
+
}>>, {
|
|
684
446
|
readonly organization: readonly ["update", "delete"];
|
|
685
447
|
readonly member: readonly ["create", "update", "delete"];
|
|
686
448
|
readonly invitation: readonly ["create", "cancel"];
|
|
687
449
|
readonly team: readonly ["create", "update", "delete"];
|
|
688
450
|
readonly ac: readonly ["create", "read", "update", "delete"];
|
|
689
451
|
}>;
|
|
690
|
-
|
|
691
|
-
readonly
|
|
692
|
-
readonly
|
|
693
|
-
|
|
694
|
-
readonly
|
|
695
|
-
readonly
|
|
696
|
-
|
|
697
|
-
readonly organization: readonly ["update", "delete"];
|
|
698
|
-
readonly member: readonly ["create", "update", "delete"];
|
|
699
|
-
readonly invitation: readonly ["create", "cancel"];
|
|
700
|
-
readonly team: readonly ["create", "update", "delete"];
|
|
701
|
-
readonly ac: readonly ["create", "read", "update", "delete"];
|
|
702
|
-
}>;
|
|
703
|
-
student: import("better-auth/plugins").Role<import("better-auth/plugins").ExactRoleStatements<{
|
|
704
|
-
readonly course: ["read"];
|
|
705
|
-
}>, {
|
|
706
|
-
readonly course: readonly ["create", "read", "update", "delete"];
|
|
707
|
-
readonly progress: readonly ["view"];
|
|
708
|
-
readonly community: readonly ["moderate"];
|
|
452
|
+
participant: import("better-auth/plugins").Role<import("better-auth/plugins").ExactRoleStatements<import("better-auth/plugins").ExactRoleStatements<{
|
|
453
|
+
readonly organization: [];
|
|
454
|
+
readonly member: [];
|
|
455
|
+
readonly invitation: [];
|
|
456
|
+
readonly team: [];
|
|
457
|
+
readonly ac: ["read"];
|
|
458
|
+
}>>, {
|
|
709
459
|
readonly organization: readonly ["update", "delete"];
|
|
710
460
|
readonly member: readonly ["create", "update", "delete"];
|
|
711
461
|
readonly invitation: readonly ["create", "cancel"];
|
|
@@ -714,146 +464,9 @@ declare function createAuth(opts: CreateAuthOptions): import("better-auth").Auth
|
|
|
714
464
|
}>;
|
|
715
465
|
};
|
|
716
466
|
creatorRole: string;
|
|
467
|
+
membershipLimit: number;
|
|
717
468
|
organizationHooks: Hooks;
|
|
718
|
-
}>, BetterAuthPlugin, ...BetterAuthPlugin[], BetterAuthPlugin
|
|
719
|
-
id: "custom-session";
|
|
720
|
-
version: string;
|
|
721
|
-
hooks: {
|
|
722
|
-
after: {
|
|
723
|
-
matcher: (ctx: import("better-auth").HookEndpointContext) => boolean;
|
|
724
|
-
handler: import("better-auth").Middleware<import("better-auth").MiddlewareOptions, (inputContext: import("better-auth").MiddlewareInputContext<import("better-auth").MiddlewareOptions>) => Promise<{
|
|
725
|
-
user: {
|
|
726
|
-
id: string;
|
|
727
|
-
createdAt: Date;
|
|
728
|
-
updatedAt: Date;
|
|
729
|
-
email: string;
|
|
730
|
-
emailVerified: boolean;
|
|
731
|
-
name: string;
|
|
732
|
-
image?: string | null | undefined;
|
|
733
|
-
};
|
|
734
|
-
session: {
|
|
735
|
-
id: string;
|
|
736
|
-
createdAt: Date;
|
|
737
|
-
updatedAt: Date;
|
|
738
|
-
userId: string;
|
|
739
|
-
expiresAt: Date;
|
|
740
|
-
token: string;
|
|
741
|
-
ipAddress?: string | null | undefined;
|
|
742
|
-
userAgent?: string | null | undefined;
|
|
743
|
-
};
|
|
744
|
-
activeMemberRole: string | null;
|
|
745
|
-
activeOrganization: {
|
|
746
|
-
id: string;
|
|
747
|
-
name: string;
|
|
748
|
-
slug: string;
|
|
749
|
-
} | null;
|
|
750
|
-
organizations: {
|
|
751
|
-
id: string;
|
|
752
|
-
name: string;
|
|
753
|
-
slug: string;
|
|
754
|
-
}[];
|
|
755
|
-
}[] | undefined>>;
|
|
756
|
-
}[];
|
|
757
|
-
};
|
|
758
|
-
endpoints: {
|
|
759
|
-
getSession: import("better-auth").StrictEndpoint<"/get-session", {
|
|
760
|
-
method: "GET";
|
|
761
|
-
query: import("better-auth").ZodOptional<import("better-auth").ZodObject<{
|
|
762
|
-
disableCookieCache: import("better-auth").ZodOptional<import("better-auth").ZodCoercedBoolean<unknown>>;
|
|
763
|
-
disableRefresh: import("better-auth").ZodOptional<import("better-auth").ZodCoercedBoolean<unknown>>;
|
|
764
|
-
}, import("zod/v4/core").$strip>>;
|
|
765
|
-
metadata: {
|
|
766
|
-
CUSTOM_SESSION: boolean;
|
|
767
|
-
openapi: {
|
|
768
|
-
description: string;
|
|
769
|
-
responses: {
|
|
770
|
-
"200": {
|
|
771
|
-
description: string;
|
|
772
|
-
content: {
|
|
773
|
-
"application/json": {
|
|
774
|
-
schema: {
|
|
775
|
-
type: "array";
|
|
776
|
-
nullable: boolean;
|
|
777
|
-
items: {
|
|
778
|
-
$ref: string;
|
|
779
|
-
};
|
|
780
|
-
};
|
|
781
|
-
};
|
|
782
|
-
};
|
|
783
|
-
};
|
|
784
|
-
};
|
|
785
|
-
};
|
|
786
|
-
};
|
|
787
|
-
requireHeaders: true;
|
|
788
|
-
}, {
|
|
789
|
-
user: {
|
|
790
|
-
id: string;
|
|
791
|
-
createdAt: Date;
|
|
792
|
-
updatedAt: Date;
|
|
793
|
-
email: string;
|
|
794
|
-
emailVerified: boolean;
|
|
795
|
-
name: string;
|
|
796
|
-
image?: string | null | undefined;
|
|
797
|
-
};
|
|
798
|
-
session: {
|
|
799
|
-
id: string;
|
|
800
|
-
createdAt: Date;
|
|
801
|
-
updatedAt: Date;
|
|
802
|
-
userId: string;
|
|
803
|
-
expiresAt: Date;
|
|
804
|
-
token: string;
|
|
805
|
-
ipAddress?: string | null | undefined;
|
|
806
|
-
userAgent?: string | null | undefined;
|
|
807
|
-
};
|
|
808
|
-
activeMemberRole: string | null;
|
|
809
|
-
activeOrganization: {
|
|
810
|
-
id: string;
|
|
811
|
-
name: string;
|
|
812
|
-
slug: string;
|
|
813
|
-
} | null;
|
|
814
|
-
organizations: {
|
|
815
|
-
id: string;
|
|
816
|
-
name: string;
|
|
817
|
-
slug: string;
|
|
818
|
-
}[];
|
|
819
|
-
} | null>;
|
|
820
|
-
};
|
|
821
|
-
$Infer: {
|
|
822
|
-
Session: {
|
|
823
|
-
user: {
|
|
824
|
-
id: string;
|
|
825
|
-
createdAt: Date;
|
|
826
|
-
updatedAt: Date;
|
|
827
|
-
email: string;
|
|
828
|
-
emailVerified: boolean;
|
|
829
|
-
name: string;
|
|
830
|
-
image?: string | null | undefined;
|
|
831
|
-
};
|
|
832
|
-
session: {
|
|
833
|
-
id: string;
|
|
834
|
-
createdAt: Date;
|
|
835
|
-
updatedAt: Date;
|
|
836
|
-
userId: string;
|
|
837
|
-
expiresAt: Date;
|
|
838
|
-
token: string;
|
|
839
|
-
ipAddress?: string | null | undefined;
|
|
840
|
-
userAgent?: string | null | undefined;
|
|
841
|
-
};
|
|
842
|
-
activeMemberRole: string | null;
|
|
843
|
-
activeOrganization: {
|
|
844
|
-
id: string;
|
|
845
|
-
name: string;
|
|
846
|
-
slug: string;
|
|
847
|
-
} | null;
|
|
848
|
-
organizations: {
|
|
849
|
-
id: string;
|
|
850
|
-
name: string;
|
|
851
|
-
slug: string;
|
|
852
|
-
}[];
|
|
853
|
-
};
|
|
854
|
-
};
|
|
855
|
-
options: import("better-auth/plugins").CustomSessionPluginOptions | undefined;
|
|
856
|
-
}];
|
|
469
|
+
}>, BetterAuthPlugin, ...BetterAuthPlugin[], BetterAuthPlugin];
|
|
857
470
|
hooks: {
|
|
858
471
|
before: import("better-auth").Middleware<import("better-auth").MiddlewareOptions, (inputContext: import("better-auth").MiddlewareInputContext<import("better-auth").MiddlewareOptions>) => Promise<{
|
|
859
472
|
context: {
|
|
@@ -882,15 +495,15 @@ type Auth = ReturnType<typeof createAuth>;
|
|
|
882
495
|
type JSONWebKeySet = {
|
|
883
496
|
keys: Array<Record<string, unknown>>;
|
|
884
497
|
};
|
|
885
|
-
type
|
|
498
|
+
type ApiKeyRow = {
|
|
886
499
|
id: string;
|
|
887
500
|
name: string | null;
|
|
888
501
|
start: string | null;
|
|
889
502
|
referenceId: string;
|
|
890
503
|
metadata: unknown;
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
|
|
504
|
+
createdAt: Date | string;
|
|
505
|
+
lastRequest: Date | string | null;
|
|
506
|
+
expiresAt: Date | string | null;
|
|
894
507
|
};
|
|
895
508
|
type PluginApi = {
|
|
896
509
|
getJwks(): Promise<JSONWebKeySet>;
|
|
@@ -900,32 +513,22 @@ type PluginApi = {
|
|
|
900
513
|
};
|
|
901
514
|
}): Promise<{
|
|
902
515
|
valid: boolean;
|
|
903
|
-
key:
|
|
516
|
+
key: ApiKeyRow | null;
|
|
904
517
|
}>;
|
|
905
518
|
createApiKey(input: {
|
|
906
519
|
body: {
|
|
907
520
|
name: string;
|
|
908
521
|
userId: string;
|
|
909
522
|
metadata: Record<string, unknown>;
|
|
910
|
-
|
|
523
|
+
expiresIn?: number;
|
|
911
524
|
};
|
|
912
|
-
}): Promise<
|
|
525
|
+
}): Promise<ApiKeyRow & {
|
|
913
526
|
key: string;
|
|
914
527
|
}>;
|
|
915
|
-
listApiKeys(input: {
|
|
916
|
-
headers: Headers;
|
|
917
|
-
}): Promise<{
|
|
918
|
-
apiKeys: PluginApiKey[];
|
|
919
|
-
}>;
|
|
920
|
-
deleteApiKey(input: {
|
|
921
|
-
body: {
|
|
922
|
-
keyId: string;
|
|
923
|
-
};
|
|
924
|
-
headers: Headers;
|
|
925
|
-
}): Promise<unknown>;
|
|
926
528
|
};
|
|
927
|
-
declare class BetterAuth implements SessionVerifier, OrgAdmin, SessionAdmin, AccessTokenVerifier,
|
|
529
|
+
declare class BetterAuth implements SessionVerifier, OrgAdmin, SessionAdmin, AccessTokenVerifier, ApiKeys, Accounts {
|
|
928
530
|
protected auth: Auth;
|
|
531
|
+
protected db: CreateAuthOptions["db"];
|
|
929
532
|
protected logger: Logger;
|
|
930
533
|
protected mcp: CreateAuthOptions["mcp"];
|
|
931
534
|
protected issuer: string;
|
|
@@ -935,29 +538,563 @@ declare class BetterAuth implements SessionVerifier, OrgAdmin, SessionAdmin, Acc
|
|
|
935
538
|
handler(request: Request): Promise<Response>;
|
|
936
539
|
authorizationServerMetadata(request: Request): Promise<Response>;
|
|
937
540
|
verifyAccess(request: AccessRequest): Promise<AccessGrant | null>;
|
|
541
|
+
verifyApiKey(headers: HeaderBag): Promise<AccessGrant | null>;
|
|
938
542
|
protected verifyAccessToken(authorization: AccessTokenAuthorization, request: AccessRequest): Promise<AccessGrant | null>;
|
|
939
|
-
protected
|
|
940
|
-
protected
|
|
941
|
-
|
|
942
|
-
|
|
943
|
-
|
|
944
|
-
|
|
945
|
-
|
|
543
|
+
protected grantForKey(key: string): Promise<AccessGrant | null>;
|
|
544
|
+
protected ownKeys(orgId: string, userExternalId: string): Promise<ApiKeyRow[]>;
|
|
545
|
+
list(orgId: string, userExternalId: string): Promise<StoredApiKey[]>;
|
|
546
|
+
create(orgId: string, userExternalId: string, input: NewApiKey): Promise<StoredApiKey & {
|
|
547
|
+
key: string;
|
|
548
|
+
}>;
|
|
549
|
+
countWithRole(orgId: string, roleKey: string): Promise<number>;
|
|
550
|
+
createAccount(input: PlatformAccount): Promise<{
|
|
551
|
+
externalId: string;
|
|
552
|
+
}>;
|
|
553
|
+
revoke(orgId: string, userExternalId: string, keyId: string): Promise<void>;
|
|
554
|
+
listApps(orgId: string, userExternalId: string): Promise<ConnectedApp[]>;
|
|
555
|
+
revokeApp(orgId: string, userExternalId: string, clientId: string): Promise<void>;
|
|
556
|
+
revokeAllFor(orgId: string, userExternalId: string): Promise<void>;
|
|
946
557
|
verify(headers: IncomingHttpHeaders): Promise<ActiveSession | null>;
|
|
947
558
|
/** Stamps the org onto the caller's session row. The 5-minute cookie cache
|
|
948
559
|
* still holds the pre-stamp session, so callers refresh it client-side with
|
|
949
560
|
* `getSession({ disableCookieCache: true })`. */
|
|
950
561
|
stampActiveOrganization(headers: AuthHeaders, orgId: string): Promise<boolean>;
|
|
951
562
|
createOrganization(headers: AuthHeaders, input: NewOrganizationInput): Promise<AuthOrganization>;
|
|
563
|
+
createOrganizationFor(ownerExternalId: string, input: NewOrganizationInput): Promise<AuthOrganization>;
|
|
952
564
|
setActiveOrganization(headers: AuthHeaders, externalId: string): Promise<void>;
|
|
953
|
-
|
|
565
|
+
protected orgAdapter(): Promise<{
|
|
566
|
+
findOrganizationBySlug: (slug: string) => Promise<{
|
|
567
|
+
id: string;
|
|
568
|
+
name: string;
|
|
569
|
+
slug: string;
|
|
570
|
+
createdAt: Date;
|
|
571
|
+
logo?: string | null | undefined;
|
|
572
|
+
metadata?: any;
|
|
573
|
+
} | null>;
|
|
574
|
+
createOrganization: (data: {
|
|
575
|
+
organization: import("better-auth/plugins").OrganizationInput & Record<string, any>;
|
|
576
|
+
}) => Promise<{
|
|
577
|
+
id: string;
|
|
578
|
+
name: string;
|
|
579
|
+
slug: string;
|
|
580
|
+
createdAt: Date;
|
|
581
|
+
logo?: string | null | undefined;
|
|
582
|
+
metadata?: any;
|
|
583
|
+
}>;
|
|
584
|
+
findMemberByEmail: (data: {
|
|
585
|
+
email: string;
|
|
586
|
+
organizationId: string;
|
|
587
|
+
}) => Promise<({
|
|
588
|
+
id: string;
|
|
589
|
+
organizationId: string;
|
|
590
|
+
role: "member" | "owner" | "admin";
|
|
591
|
+
createdAt: Date;
|
|
592
|
+
userId: string;
|
|
593
|
+
user: {
|
|
594
|
+
id: string;
|
|
595
|
+
email: string;
|
|
596
|
+
name: string;
|
|
597
|
+
image?: string | undefined;
|
|
598
|
+
};
|
|
599
|
+
} & {
|
|
600
|
+
user: {
|
|
601
|
+
id: string;
|
|
602
|
+
name: string;
|
|
603
|
+
email: string;
|
|
604
|
+
image: string | null | undefined;
|
|
605
|
+
};
|
|
606
|
+
}) | null>;
|
|
607
|
+
listMembers: (data: {
|
|
608
|
+
organizationId?: string | undefined;
|
|
609
|
+
limit?: number | undefined;
|
|
610
|
+
offset?: number | undefined;
|
|
611
|
+
sortBy?: string | undefined;
|
|
612
|
+
sortOrder?: ("asc" | "desc") | undefined;
|
|
613
|
+
filter?: {
|
|
614
|
+
field: string;
|
|
615
|
+
operator?: "in" | "lte" | "eq" | "ne" | "lt" | "gt" | "gte" | "not_in" | "contains" | "starts_with" | "ends_with";
|
|
616
|
+
value: any;
|
|
617
|
+
} | undefined;
|
|
618
|
+
}) => Promise<{
|
|
619
|
+
members: ({
|
|
620
|
+
id: string;
|
|
621
|
+
organizationId: string;
|
|
622
|
+
role: "member" | "owner" | "admin";
|
|
623
|
+
createdAt: Date;
|
|
624
|
+
userId: string;
|
|
625
|
+
user: {
|
|
626
|
+
id: string;
|
|
627
|
+
email: string;
|
|
628
|
+
name: string;
|
|
629
|
+
image?: string | undefined;
|
|
630
|
+
};
|
|
631
|
+
} & {
|
|
632
|
+
user: {
|
|
633
|
+
id: string;
|
|
634
|
+
name: string;
|
|
635
|
+
email: string;
|
|
636
|
+
image: string | null | undefined;
|
|
637
|
+
};
|
|
638
|
+
})[];
|
|
639
|
+
total: number;
|
|
640
|
+
}>;
|
|
641
|
+
findMemberByOrgId: (data: {
|
|
642
|
+
userId: string;
|
|
643
|
+
organizationId: string;
|
|
644
|
+
}) => Promise<(Omit<{
|
|
645
|
+
id: string;
|
|
646
|
+
organizationId: string;
|
|
647
|
+
role: "member" | "owner" | "admin";
|
|
648
|
+
createdAt: Date;
|
|
649
|
+
userId: string;
|
|
650
|
+
user: {
|
|
651
|
+
id: string;
|
|
652
|
+
email: string;
|
|
653
|
+
name: string;
|
|
654
|
+
image?: string | undefined;
|
|
655
|
+
};
|
|
656
|
+
} & {
|
|
657
|
+
user: {
|
|
658
|
+
id: string;
|
|
659
|
+
createdAt: Date;
|
|
660
|
+
updatedAt: Date;
|
|
661
|
+
email: string;
|
|
662
|
+
emailVerified: boolean;
|
|
663
|
+
name: string;
|
|
664
|
+
image?: string | null | undefined;
|
|
665
|
+
};
|
|
666
|
+
}, "user"> & {
|
|
667
|
+
user: {
|
|
668
|
+
id: string;
|
|
669
|
+
name: string;
|
|
670
|
+
email: string;
|
|
671
|
+
image: string | undefined;
|
|
672
|
+
};
|
|
673
|
+
}) | null>;
|
|
674
|
+
findMemberById: (memberId: string) => Promise<({
|
|
675
|
+
id: string;
|
|
676
|
+
organizationId: string;
|
|
677
|
+
role: "member" | "owner" | "admin";
|
|
678
|
+
createdAt: Date;
|
|
679
|
+
userId: string;
|
|
680
|
+
user: {
|
|
681
|
+
id: string;
|
|
682
|
+
email: string;
|
|
683
|
+
name: string;
|
|
684
|
+
image?: string | undefined;
|
|
685
|
+
};
|
|
686
|
+
} & {
|
|
687
|
+
user: {
|
|
688
|
+
id: string;
|
|
689
|
+
name: string;
|
|
690
|
+
email: string;
|
|
691
|
+
image: string | undefined;
|
|
692
|
+
};
|
|
693
|
+
}) | null>;
|
|
694
|
+
createMember: (data: Omit<import("better-auth/plugins").MemberInput, "id"> & Record<string, any>) => Promise<{
|
|
695
|
+
id: string;
|
|
696
|
+
organizationId: string;
|
|
697
|
+
userId: string;
|
|
698
|
+
role: string;
|
|
699
|
+
createdAt: Date;
|
|
700
|
+
}>;
|
|
701
|
+
updateMember: (memberId: string, role: string) => Promise<{
|
|
702
|
+
id: string;
|
|
703
|
+
organizationId: string;
|
|
704
|
+
role: "member" | "owner" | "admin";
|
|
705
|
+
createdAt: Date;
|
|
706
|
+
userId: string;
|
|
707
|
+
user: {
|
|
708
|
+
id: string;
|
|
709
|
+
email: string;
|
|
710
|
+
name: string;
|
|
711
|
+
image?: string | undefined;
|
|
712
|
+
};
|
|
713
|
+
} | null>;
|
|
714
|
+
deleteMember: ({ memberId, organizationId, userId: _userId }: {
|
|
715
|
+
memberId: string;
|
|
716
|
+
organizationId: string;
|
|
717
|
+
userId?: string;
|
|
718
|
+
}) => Promise<void>;
|
|
719
|
+
updateOrganization: (organizationId: string, data: Partial<import("better-auth/plugins").OrganizationInput>) => Promise<{
|
|
720
|
+
id: string;
|
|
721
|
+
name: string;
|
|
722
|
+
slug: string;
|
|
723
|
+
createdAt: Date;
|
|
724
|
+
logo?: string | null | undefined;
|
|
725
|
+
metadata?: any;
|
|
726
|
+
} | null>;
|
|
727
|
+
deleteOrganization: (organizationId: string) => Promise<string>;
|
|
728
|
+
setActiveOrganization: (sessionToken: string, organizationId: string | null, ctx: import("better-auth").GenericEndpointContext) => Promise<{
|
|
729
|
+
id: string;
|
|
730
|
+
createdAt: Date;
|
|
731
|
+
updatedAt: Date;
|
|
732
|
+
userId: string;
|
|
733
|
+
expiresAt: Date;
|
|
734
|
+
token: string;
|
|
735
|
+
ipAddress?: string | null | undefined;
|
|
736
|
+
userAgent?: string | null | undefined;
|
|
737
|
+
}>;
|
|
738
|
+
findOrganizationById: (organizationId: string) => Promise<{
|
|
739
|
+
id: string;
|
|
740
|
+
name: string;
|
|
741
|
+
slug: string;
|
|
742
|
+
createdAt: Date;
|
|
743
|
+
logo?: string | null | undefined;
|
|
744
|
+
metadata?: any;
|
|
745
|
+
} | null>;
|
|
746
|
+
checkMembership: ({ userId, organizationId }: {
|
|
747
|
+
userId: string;
|
|
748
|
+
organizationId: string;
|
|
749
|
+
}) => Promise<{
|
|
750
|
+
id: string;
|
|
751
|
+
organizationId: string;
|
|
752
|
+
role: "member" | "owner" | "admin";
|
|
753
|
+
createdAt: Date;
|
|
754
|
+
userId: string;
|
|
755
|
+
user: {
|
|
756
|
+
id: string;
|
|
757
|
+
email: string;
|
|
758
|
+
name: string;
|
|
759
|
+
image?: string | undefined;
|
|
760
|
+
};
|
|
761
|
+
} | null>;
|
|
762
|
+
findFullOrganization: ({ organizationId, isSlug, includeTeams, membersLimit }: {
|
|
763
|
+
organizationId: string;
|
|
764
|
+
isSlug?: boolean | undefined;
|
|
765
|
+
includeTeams?: boolean | undefined;
|
|
766
|
+
membersLimit?: number | undefined;
|
|
767
|
+
}) => Promise<(Omit<{
|
|
768
|
+
id: string;
|
|
769
|
+
name: string;
|
|
770
|
+
slug: string;
|
|
771
|
+
createdAt: Date;
|
|
772
|
+
logo?: string | null | undefined | undefined;
|
|
773
|
+
metadata?: any;
|
|
774
|
+
} & {
|
|
775
|
+
invitation: {
|
|
776
|
+
id: string;
|
|
777
|
+
organizationId: string;
|
|
778
|
+
email: string;
|
|
779
|
+
role: "member" | "owner" | "admin";
|
|
780
|
+
status: import("better-auth/plugins").InvitationStatus;
|
|
781
|
+
inviterId: string;
|
|
782
|
+
expiresAt: Date;
|
|
783
|
+
createdAt: Date;
|
|
784
|
+
}[];
|
|
785
|
+
member: {
|
|
786
|
+
id: string;
|
|
787
|
+
organizationId: string;
|
|
788
|
+
role: "member" | "owner" | "admin";
|
|
789
|
+
createdAt: Date;
|
|
790
|
+
userId: string;
|
|
791
|
+
user: {
|
|
792
|
+
id: string;
|
|
793
|
+
email: string;
|
|
794
|
+
name: string;
|
|
795
|
+
image?: string | undefined;
|
|
796
|
+
};
|
|
797
|
+
}[];
|
|
798
|
+
team: {
|
|
799
|
+
id: string;
|
|
800
|
+
name: string;
|
|
801
|
+
organizationId: string;
|
|
802
|
+
createdAt: Date;
|
|
803
|
+
updatedAt?: Date | undefined;
|
|
804
|
+
}[] | undefined;
|
|
805
|
+
}, "member" | "invitation" | "team"> & {
|
|
806
|
+
invitations: {
|
|
807
|
+
id: string;
|
|
808
|
+
organizationId: string;
|
|
809
|
+
email: string;
|
|
810
|
+
role: "member" | "owner" | "admin";
|
|
811
|
+
status: import("better-auth/plugins").InvitationStatus;
|
|
812
|
+
inviterId: string;
|
|
813
|
+
expiresAt: Date;
|
|
814
|
+
createdAt: Date;
|
|
815
|
+
}[];
|
|
816
|
+
members: ({
|
|
817
|
+
id: string;
|
|
818
|
+
organizationId: string;
|
|
819
|
+
role: "member" | "owner" | "admin";
|
|
820
|
+
createdAt: Date;
|
|
821
|
+
userId: string;
|
|
822
|
+
user: {
|
|
823
|
+
id: string;
|
|
824
|
+
email: string;
|
|
825
|
+
name: string;
|
|
826
|
+
image?: string | undefined;
|
|
827
|
+
};
|
|
828
|
+
} & {
|
|
829
|
+
user: {
|
|
830
|
+
id: string;
|
|
831
|
+
name: string;
|
|
832
|
+
email: string;
|
|
833
|
+
image: string | null | undefined;
|
|
834
|
+
};
|
|
835
|
+
})[];
|
|
836
|
+
teams: {
|
|
837
|
+
id: string;
|
|
838
|
+
name: string;
|
|
839
|
+
organizationId: string;
|
|
840
|
+
createdAt: Date;
|
|
841
|
+
updatedAt?: Date | undefined;
|
|
842
|
+
}[] | undefined;
|
|
843
|
+
}) | null>;
|
|
844
|
+
listOrganizations: (userId: string) => Promise<{
|
|
845
|
+
id: string;
|
|
846
|
+
name: string;
|
|
847
|
+
slug: string;
|
|
848
|
+
createdAt: Date;
|
|
849
|
+
logo?: string | null | undefined;
|
|
850
|
+
metadata?: any;
|
|
851
|
+
}[]>;
|
|
852
|
+
createTeam: (data: import("better-auth/plugins").TeamInput) => Promise<{
|
|
853
|
+
id: string;
|
|
854
|
+
name: string;
|
|
855
|
+
organizationId: string;
|
|
856
|
+
createdAt: Date;
|
|
857
|
+
updatedAt?: Date | undefined;
|
|
858
|
+
}>;
|
|
859
|
+
findTeamById: <IncludeMembers extends boolean>({ teamId, organizationId, includeTeamMembers }: {
|
|
860
|
+
teamId: string;
|
|
861
|
+
organizationId?: string | undefined;
|
|
862
|
+
includeTeamMembers?: IncludeMembers | undefined;
|
|
863
|
+
}) => Promise<({
|
|
864
|
+
id: string;
|
|
865
|
+
name: string;
|
|
866
|
+
organizationId: string;
|
|
867
|
+
createdAt: Date;
|
|
868
|
+
updatedAt?: Date | undefined;
|
|
869
|
+
} & (IncludeMembers extends true ? {
|
|
870
|
+
members: import("better-auth/plugins").TeamMember[];
|
|
871
|
+
} : {})) | null>;
|
|
872
|
+
updateTeam: (teamId: string, data: {
|
|
873
|
+
name?: string | undefined;
|
|
874
|
+
description?: string | undefined;
|
|
875
|
+
status?: string | undefined;
|
|
876
|
+
}) => Promise<{
|
|
877
|
+
id: string;
|
|
878
|
+
name: string;
|
|
879
|
+
organizationId: string;
|
|
880
|
+
createdAt: Date;
|
|
881
|
+
updatedAt?: Date | undefined;
|
|
882
|
+
} | null>;
|
|
883
|
+
deleteTeam: (teamId: string) => Promise<void>;
|
|
884
|
+
listTeams: (organizationId: string) => Promise<{
|
|
885
|
+
id: string;
|
|
886
|
+
name: string;
|
|
887
|
+
organizationId: string;
|
|
888
|
+
createdAt: Date;
|
|
889
|
+
updatedAt?: Date | undefined;
|
|
890
|
+
}[]>;
|
|
891
|
+
createTeamInvitation: ({ email, role, teamId, organizationId, inviterId, expiresIn }: {
|
|
892
|
+
email: string;
|
|
893
|
+
role: string;
|
|
894
|
+
teamId: string;
|
|
895
|
+
organizationId: string;
|
|
896
|
+
inviterId: string;
|
|
897
|
+
expiresIn?: number | undefined;
|
|
898
|
+
}) => Promise<{
|
|
899
|
+
id: string;
|
|
900
|
+
organizationId: string;
|
|
901
|
+
email: string;
|
|
902
|
+
role: "member" | "owner" | "admin";
|
|
903
|
+
status: import("better-auth/plugins").InvitationStatus;
|
|
904
|
+
inviterId: string;
|
|
905
|
+
expiresAt: Date;
|
|
906
|
+
createdAt: Date;
|
|
907
|
+
}>;
|
|
908
|
+
setActiveTeam: (sessionToken: string, teamId: string | null, ctx: import("better-auth").GenericEndpointContext) => Promise<{
|
|
909
|
+
id: string;
|
|
910
|
+
createdAt: Date;
|
|
911
|
+
updatedAt: Date;
|
|
912
|
+
userId: string;
|
|
913
|
+
expiresAt: Date;
|
|
914
|
+
token: string;
|
|
915
|
+
ipAddress?: string | null | undefined;
|
|
916
|
+
userAgent?: string | null | undefined;
|
|
917
|
+
}>;
|
|
918
|
+
listTeamMembers: (data: {
|
|
919
|
+
teamId: string;
|
|
920
|
+
}) => Promise<{
|
|
921
|
+
id: string;
|
|
922
|
+
teamId: string;
|
|
923
|
+
userId: string;
|
|
924
|
+
createdAt: Date;
|
|
925
|
+
}[]>;
|
|
926
|
+
countTeamMembers: (data: {
|
|
927
|
+
teamId: string;
|
|
928
|
+
}) => Promise<number>;
|
|
929
|
+
countMembers: (data: {
|
|
930
|
+
organizationId: string;
|
|
931
|
+
}) => Promise<number>;
|
|
932
|
+
listTeamsByUser: (data: {
|
|
933
|
+
userId: string;
|
|
934
|
+
}) => Promise<{
|
|
935
|
+
id: string;
|
|
936
|
+
name: string;
|
|
937
|
+
organizationId: string;
|
|
938
|
+
createdAt: Date;
|
|
939
|
+
updatedAt?: Date | undefined;
|
|
940
|
+
}[]>;
|
|
941
|
+
findTeamMember: (data: {
|
|
942
|
+
teamId: string;
|
|
943
|
+
userId: string;
|
|
944
|
+
}) => Promise<{
|
|
945
|
+
id: string;
|
|
946
|
+
teamId: string;
|
|
947
|
+
userId: string;
|
|
948
|
+
createdAt: Date;
|
|
949
|
+
} | null>;
|
|
950
|
+
findOrCreateTeamMember: (data: {
|
|
951
|
+
teamId: string;
|
|
952
|
+
userId: string;
|
|
953
|
+
}) => Promise<{
|
|
954
|
+
id: string;
|
|
955
|
+
teamId: string;
|
|
956
|
+
userId: string;
|
|
957
|
+
createdAt: Date;
|
|
958
|
+
}>;
|
|
959
|
+
addTeamMemberWithLimit: (data: {
|
|
960
|
+
teamId: string;
|
|
961
|
+
userId: string;
|
|
962
|
+
maximumMembersPerTeam: number;
|
|
963
|
+
}) => Promise<{
|
|
964
|
+
status: "added";
|
|
965
|
+
member: import("better-auth/plugins").TeamMember;
|
|
966
|
+
} | {
|
|
967
|
+
status: "limitReached";
|
|
968
|
+
}>;
|
|
969
|
+
removeTeamMember: (data: {
|
|
970
|
+
teamId: string;
|
|
971
|
+
userId: string;
|
|
972
|
+
}) => Promise<void>;
|
|
973
|
+
findInvitationsByTeamId: (teamId: string) => Promise<{
|
|
974
|
+
id: string;
|
|
975
|
+
organizationId: string;
|
|
976
|
+
email: string;
|
|
977
|
+
role: "member" | "owner" | "admin";
|
|
978
|
+
status: import("better-auth/plugins").InvitationStatus;
|
|
979
|
+
inviterId: string;
|
|
980
|
+
expiresAt: Date;
|
|
981
|
+
createdAt: Date;
|
|
982
|
+
}[]>;
|
|
983
|
+
listUserInvitations: (email: string) => Promise<(Omit<{
|
|
984
|
+
id: string;
|
|
985
|
+
organizationId: string;
|
|
986
|
+
email: string;
|
|
987
|
+
role: "member" | "owner" | "admin";
|
|
988
|
+
status: import("better-auth/plugins").InvitationStatus;
|
|
989
|
+
inviterId: string;
|
|
990
|
+
expiresAt: Date;
|
|
991
|
+
createdAt: Date;
|
|
992
|
+
} & {
|
|
993
|
+
organization: {
|
|
994
|
+
id: string;
|
|
995
|
+
name: string;
|
|
996
|
+
slug: string;
|
|
997
|
+
createdAt: Date;
|
|
998
|
+
logo?: string | null | undefined;
|
|
999
|
+
metadata?: any;
|
|
1000
|
+
};
|
|
1001
|
+
}, "organization"> & {
|
|
1002
|
+
organizationName: string;
|
|
1003
|
+
})[]>;
|
|
1004
|
+
createInvitation: ({ invitation, user }: {
|
|
1005
|
+
invitation: {
|
|
1006
|
+
email: string;
|
|
1007
|
+
role: string;
|
|
1008
|
+
organizationId: string;
|
|
1009
|
+
teamIds: string[];
|
|
1010
|
+
} & Record<string, any>;
|
|
1011
|
+
user: {
|
|
1012
|
+
id: string;
|
|
1013
|
+
createdAt: Date;
|
|
1014
|
+
updatedAt: Date;
|
|
1015
|
+
email: string;
|
|
1016
|
+
emailVerified: boolean;
|
|
1017
|
+
name: string;
|
|
1018
|
+
image?: string | null | undefined;
|
|
1019
|
+
};
|
|
1020
|
+
}) => Promise<{
|
|
1021
|
+
id: string;
|
|
1022
|
+
organizationId: string;
|
|
1023
|
+
email: string;
|
|
1024
|
+
role: "member" | "owner" | "admin";
|
|
1025
|
+
status: import("better-auth/plugins").InvitationStatus;
|
|
1026
|
+
inviterId: string;
|
|
1027
|
+
expiresAt: Date;
|
|
1028
|
+
createdAt: Date;
|
|
1029
|
+
}>;
|
|
1030
|
+
findInvitationById: (id: string) => Promise<{
|
|
1031
|
+
id: string;
|
|
1032
|
+
organizationId: string;
|
|
1033
|
+
email: string;
|
|
1034
|
+
role: "member" | "owner" | "admin";
|
|
1035
|
+
status: import("better-auth/plugins").InvitationStatus;
|
|
1036
|
+
inviterId: string;
|
|
1037
|
+
expiresAt: Date;
|
|
1038
|
+
createdAt: Date;
|
|
1039
|
+
} | null>;
|
|
1040
|
+
findPendingInvitation: (data: {
|
|
1041
|
+
email: string;
|
|
1042
|
+
organizationId: string;
|
|
1043
|
+
}) => Promise<{
|
|
1044
|
+
id: string;
|
|
1045
|
+
organizationId: string;
|
|
1046
|
+
email: string;
|
|
1047
|
+
role: "member" | "owner" | "admin";
|
|
1048
|
+
status: import("better-auth/plugins").InvitationStatus;
|
|
1049
|
+
inviterId: string;
|
|
1050
|
+
expiresAt: Date;
|
|
1051
|
+
createdAt: Date;
|
|
1052
|
+
}[]>;
|
|
1053
|
+
findPendingInvitations: (data: {
|
|
1054
|
+
organizationId: string;
|
|
1055
|
+
}) => Promise<{
|
|
1056
|
+
id: string;
|
|
1057
|
+
organizationId: string;
|
|
1058
|
+
email: string;
|
|
1059
|
+
role: "member" | "owner" | "admin";
|
|
1060
|
+
status: import("better-auth/plugins").InvitationStatus;
|
|
1061
|
+
inviterId: string;
|
|
1062
|
+
expiresAt: Date;
|
|
1063
|
+
createdAt: Date;
|
|
1064
|
+
}[]>;
|
|
1065
|
+
listInvitations: (data: {
|
|
1066
|
+
organizationId: string;
|
|
1067
|
+
}) => Promise<{
|
|
1068
|
+
id: string;
|
|
1069
|
+
organizationId: string;
|
|
1070
|
+
email: string;
|
|
1071
|
+
role: "member" | "owner" | "admin";
|
|
1072
|
+
status: import("better-auth/plugins").InvitationStatus;
|
|
1073
|
+
inviterId: string;
|
|
1074
|
+
expiresAt: Date;
|
|
1075
|
+
createdAt: Date;
|
|
1076
|
+
}[]>;
|
|
1077
|
+
updateInvitation: (data: {
|
|
1078
|
+
invitationId: string;
|
|
1079
|
+
status: "pending" | "accepted" | "canceled" | "rejected";
|
|
1080
|
+
fromStatus?: "pending" | "accepted" | "canceled" | "rejected";
|
|
1081
|
+
}) => Promise<{
|
|
1082
|
+
id: string;
|
|
1083
|
+
organizationId: string;
|
|
1084
|
+
email: string;
|
|
1085
|
+
role: "member" | "owner" | "admin";
|
|
1086
|
+
status: import("better-auth/plugins").InvitationStatus;
|
|
1087
|
+
inviterId: string;
|
|
1088
|
+
expiresAt: Date;
|
|
1089
|
+
createdAt: Date;
|
|
1090
|
+
} | null>;
|
|
1091
|
+
}>;
|
|
1092
|
+
updateOrganization(externalId: string, input: UpdateOrganizationInput): Promise<void>;
|
|
954
1093
|
deleteOrganization(headers: AuthHeaders, externalId: string): Promise<void>;
|
|
955
|
-
grantMembership(orgExternalId: string, userExternalId: string
|
|
956
|
-
|
|
957
|
-
|
|
958
|
-
protected headersOf(ctx: MemberWriteContext): Headers;
|
|
959
|
-
protected resolveMemberId(ctx: MemberWriteContext, userExternalId: string): Promise<string>;
|
|
1094
|
+
grantMembership(orgExternalId: string, userExternalId: string): Promise<void>;
|
|
1095
|
+
setMembershipOwner(orgExternalId: string, userExternalId: string, owner: boolean): Promise<void>;
|
|
1096
|
+
removeMembership(orgExternalId: string, userExternalId: string): Promise<void>;
|
|
960
1097
|
}
|
|
961
1098
|
//#endregion
|
|
962
|
-
export { Auth, BetterAuth, buildAuthOptions, createAuth };
|
|
1099
|
+
export { API_KEY_PREFIX, Auth, BetterAuth, buildAuthOptions, createAuth };
|
|
963
1100
|
//# sourceMappingURL=better-auth.d.ts.map
|