@protobase/server 0.0.0-stage → 0.1.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.
Files changed (76) hide show
  1. package/LICENSE +202 -0
  2. package/dist/aggregate-service.js +135 -0
  3. package/dist/audit/console-queue.d.ts +5 -0
  4. package/dist/audit/console-queue.js +5 -0
  5. package/dist/auth/jwt.d.ts +21 -0
  6. package/dist/auth/jwt.js +49 -0
  7. package/dist/batch/refs.js +31 -0
  8. package/dist/batch/reorder.js +79 -0
  9. package/dist/batch/run-batch.js +105 -0
  10. package/dist/batch/schema.js +51 -0
  11. package/dist/better-auth/authenticator.d.ts +22 -0
  12. package/dist/better-auth/authenticator.js +21 -0
  13. package/dist/better-auth/create-auth.d.ts +1244 -0
  14. package/dist/better-auth/create-auth.js +93 -0
  15. package/dist/better-auth/jwks-cache.d.ts +9 -0
  16. package/dist/better-auth/jwks-cache.js +31 -0
  17. package/dist/better-auth/password-reset.js +32 -0
  18. package/dist/better-auth/status-route.js +17 -0
  19. package/dist/better-auth/tokens.d.ts +18 -0
  20. package/dist/better-auth/tokens.js +37 -0
  21. package/dist/better-auth/users.d.ts +50 -0
  22. package/dist/better-auth/users.js +111 -0
  23. package/dist/check-shell.js +17 -0
  24. package/dist/check-views.js +45 -0
  25. package/dist/create-admin.d.ts +23 -0
  26. package/dist/create-admin.js +85 -0
  27. package/dist/error-handler.js +44 -0
  28. package/dist/etag.js +22 -0
  29. package/dist/filter-input.js +28 -0
  30. package/dist/filter-shape.js +25 -0
  31. package/dist/hash.js +10 -0
  32. package/dist/index.d.ts +11 -0
  33. package/dist/index.js +10 -0
  34. package/dist/key.js +22 -0
  35. package/dist/list-service.js +96 -0
  36. package/dist/mail/mail-settings.js +26 -0
  37. package/dist/mail/smtp-mailer.d.ts +11 -0
  38. package/dist/mail/smtp-mailer.js +17 -0
  39. package/dist/meta.js +63 -0
  40. package/dist/openapi/components.js +331 -0
  41. package/dist/openapi/document.js +74 -0
  42. package/dist/openapi/naming.js +4 -0
  43. package/dist/openapi/resource-paths.js +417 -0
  44. package/dist/openapi/schemas.js +93 -0
  45. package/dist/params.js +48 -0
  46. package/dist/problem.d.ts +17 -0
  47. package/dist/problem.js +43 -0
  48. package/dist/read-service.js +65 -0
  49. package/dist/records.js +66 -0
  50. package/dist/registry.js +44 -0
  51. package/dist/request-access.js +97 -0
  52. package/dist/resource-source.d.ts +35 -0
  53. package/dist/resource-source.js +22 -0
  54. package/dist/reveal-service.js +43 -0
  55. package/dist/routes/batch.js +21 -0
  56. package/dist/routes/collection.js +63 -0
  57. package/dist/routes/docs.js +20 -0
  58. package/dist/routes/meta.js +22 -0
  59. package/dist/routes/preferences.js +12 -0
  60. package/dist/routes/record.js +97 -0
  61. package/dist/routes/target.js +18 -0
  62. package/dist/row-permissions.js +69 -0
  63. package/dist/rows.js +12 -0
  64. package/dist/scan-guard.js +72 -0
  65. package/dist/sql-parts.js +32 -0
  66. package/dist/tenant.js +10 -0
  67. package/dist/transactions.js +14 -0
  68. package/dist/types.d.ts +97 -0
  69. package/dist/validate-body.js +73 -0
  70. package/dist/view-access.js +54 -0
  71. package/dist/view-related.js +59 -0
  72. package/dist/write-pipeline.js +94 -0
  73. package/dist/write-shared.js +52 -0
  74. package/dist/write-update.js +45 -0
  75. package/package.json +39 -3
  76. package/README.md +0 -3
@@ -0,0 +1,1244 @@
1
+ import { Mailer } from "../mail/smtp-mailer.js";
2
+ import { BetterAuthOptions } from "better-auth";
3
+ //#region src/better-auth/create-auth.d.ts
4
+ export type CreateAuthOptions = {
5
+ /** A `pg` Pool, or `{ dialect, type: 'postgres', schemaName? }` for a Kysely dialect: the admin store, apart from the application's tables (its own schema or database). */
6
+ database: BetterAuthOptions['database'];
7
+ /** Public origin of the API, for example `https://admin.example.com`. Issuer and audience of the tokens. */
8
+ baseURL: string;
9
+ /** Signs cookies and encrypts the JWT private keys. Generate with `openssl rand -base64 32`. */
10
+ secret: string;
11
+ /** Extra origins that may call the auth endpoints. `baseURL` and `https://*.trycloudflare.com` are always trusted. */
12
+ trustedOrigins?: string[];
13
+ /** The roles users can have, for example `['admin', 'accountant', 'warehouse']`. `admin` is always included; default `['admin', 'user']`. */
14
+ roles?: string[];
15
+ /**
16
+ * The role of a user created without one. Optional: when unset, and more than one role besides `admin` exists,
17
+ * creating a user without a role is an error that asks for one. With exactly one other role, that role is the default.
18
+ */
19
+ defaultRole?: string;
20
+ /** Sign-in attempts allowed per minute and client, default 5. */
21
+ signInPerMinute?: number;
22
+ /**
23
+ * Sends the password-reset email; without a mailer there is no password reset. Defaults to SMTP with the settings
24
+ * the platform passes in `PROTOBASE_SMTP_URL` and `PROTOBASE_MAIL_FROM` (see `readMailSettings`), when set; `false`
25
+ * turns reset off whatever the environment says.
26
+ */
27
+ mailer?: Mailer | false;
28
+ };
29
+ /** The configured roles with `admin` first; `admin` is added when missing. */
30
+ export declare const normalizeRoles: (roles?: string[]) => string[];
31
+ export declare const createAuth: (options: CreateAuthOptions) => import("better-auth").Auth<{
32
+ database: any;
33
+ baseURL: string;
34
+ basePath: string;
35
+ secret: string;
36
+ trustedOrigins: string[];
37
+ emailAndPassword: {
38
+ resetPasswordTokenExpiresIn?: number | undefined;
39
+ revokeSessionsOnPasswordReset?: true | undefined;
40
+ sendResetPassword?: (({ user, url }: {
41
+ user: import("better-auth").User;
42
+ url: string;
43
+ token: string;
44
+ }) => Promise<void>) | undefined;
45
+ enabled: true;
46
+ disableSignUp: true;
47
+ minPasswordLength: number;
48
+ };
49
+ plugins: [{
50
+ id: "admin";
51
+ version: string;
52
+ init(): {
53
+ options: {
54
+ databaseHooks: {
55
+ user: {
56
+ create: {
57
+ before(user: {
58
+ id: string;
59
+ createdAt: Date;
60
+ updatedAt: Date;
61
+ email: string;
62
+ emailVerified: boolean;
63
+ name: string;
64
+ image?: string | null | undefined;
65
+ } & Record<string, unknown>): Promise<{
66
+ data: {
67
+ id: string;
68
+ createdAt: Date;
69
+ updatedAt: Date;
70
+ email: string;
71
+ emailVerified: boolean;
72
+ name: string;
73
+ image?: string | null | undefined;
74
+ role: string;
75
+ };
76
+ }>;
77
+ };
78
+ };
79
+ session: {
80
+ create: {
81
+ before(session: {
82
+ id: string;
83
+ createdAt: Date;
84
+ updatedAt: Date;
85
+ userId: string;
86
+ expiresAt: Date;
87
+ token: string;
88
+ ipAddress?: string | null | undefined;
89
+ userAgent?: string | null | undefined;
90
+ } & Record<string, unknown>, ctx: import("better-auth").GenericEndpointContext | null): Promise<void>;
91
+ };
92
+ };
93
+ };
94
+ };
95
+ };
96
+ hooks: {
97
+ after: {
98
+ matcher(context: import("better-auth").HookEndpointContext): boolean;
99
+ handler: import("better-auth").Middleware<import("better-auth").MiddlewareOptions, (inputContext: import("better-auth").MiddlewareInputContext<import("better-auth").MiddlewareOptions>) => Promise<import("better-auth/plugins").SessionWithImpersonatedBy[] | undefined>>;
100
+ }[];
101
+ };
102
+ endpoints: {
103
+ setRole: import("better-auth").StrictEndpoint<"/admin/set-role", {
104
+ method: "POST";
105
+ body: import("zod").ZodObject<{
106
+ userId: import("zod").ZodCoercedString<unknown>;
107
+ role: import("zod").ZodUnion<readonly [import("zod").ZodString, import("zod").ZodArray<import("zod").ZodString>]>;
108
+ }, import("zod/v4/core").$strip>;
109
+ requireHeaders: true;
110
+ use: import("better-auth").Middleware<import("better-auth").MiddlewareOptions, (inputContext: import("better-auth").MiddlewareInputContext<import("better-auth").MiddlewareOptions>) => Promise<{
111
+ session: {
112
+ user: import("better-auth/plugins").UserWithRole;
113
+ session: {
114
+ id: string;
115
+ createdAt: Date;
116
+ updatedAt: Date;
117
+ userId: string;
118
+ expiresAt: Date;
119
+ token: string;
120
+ ipAddress?: string | null | undefined;
121
+ userAgent?: string | null | undefined;
122
+ };
123
+ };
124
+ }>>[];
125
+ metadata: {
126
+ openapi: {
127
+ operationId: string;
128
+ summary: string;
129
+ description: string;
130
+ responses: {
131
+ 200: {
132
+ description: string;
133
+ content: {
134
+ "application/json": {
135
+ schema: {
136
+ type: "object";
137
+ properties: {
138
+ user: {
139
+ $ref: string;
140
+ };
141
+ };
142
+ };
143
+ };
144
+ };
145
+ };
146
+ };
147
+ };
148
+ $Infer: {
149
+ body: {
150
+ userId: string;
151
+ role: string | number | (string | number)[];
152
+ };
153
+ };
154
+ };
155
+ }, {
156
+ user: import("better-auth/plugins").UserWithRole;
157
+ }>;
158
+ getUser: import("better-auth").StrictEndpoint<"/admin/get-user", {
159
+ method: "GET";
160
+ query: import("zod").ZodObject<{
161
+ id: import("zod").ZodString;
162
+ }, import("zod/v4/core").$strip>;
163
+ use: import("better-auth").Middleware<import("better-auth").MiddlewareOptions, (inputContext: import("better-auth").MiddlewareInputContext<import("better-auth").MiddlewareOptions>) => Promise<{
164
+ session: {
165
+ user: import("better-auth/plugins").UserWithRole;
166
+ session: {
167
+ id: string;
168
+ createdAt: Date;
169
+ updatedAt: Date;
170
+ userId: string;
171
+ expiresAt: Date;
172
+ token: string;
173
+ ipAddress?: string | null | undefined;
174
+ userAgent?: string | null | undefined;
175
+ };
176
+ };
177
+ }>>[];
178
+ metadata: {
179
+ openapi: {
180
+ operationId: string;
181
+ summary: string;
182
+ description: string;
183
+ responses: {
184
+ 200: {
185
+ description: string;
186
+ content: {
187
+ "application/json": {
188
+ schema: {
189
+ type: "object";
190
+ properties: {
191
+ user: {
192
+ $ref: string;
193
+ };
194
+ };
195
+ };
196
+ };
197
+ };
198
+ };
199
+ };
200
+ };
201
+ };
202
+ }, import("better-auth/plugins").UserWithRole>;
203
+ createUser: import("better-auth").StrictEndpoint<"/admin/create-user", {
204
+ method: "POST";
205
+ body: import("zod").ZodObject<{
206
+ email: import("zod").ZodString;
207
+ password: import("zod").ZodOptional<import("zod").ZodString>;
208
+ name: import("zod").ZodString;
209
+ role: import("zod").ZodOptional<import("zod").ZodUnion<readonly [import("zod").ZodString, import("zod").ZodArray<import("zod").ZodString>]>>;
210
+ data: import("zod").ZodOptional<import("zod").ZodRecord<import("zod").ZodString, import("zod").ZodAny>>;
211
+ }, import("zod/v4/core").$strip>;
212
+ metadata: {
213
+ openapi: {
214
+ operationId: string;
215
+ summary: string;
216
+ description: string;
217
+ responses: {
218
+ 200: {
219
+ description: string;
220
+ content: {
221
+ "application/json": {
222
+ schema: {
223
+ type: "object";
224
+ properties: {
225
+ user: {
226
+ $ref: string;
227
+ };
228
+ };
229
+ };
230
+ };
231
+ };
232
+ };
233
+ };
234
+ };
235
+ $Infer: {
236
+ body: {
237
+ email: string;
238
+ password?: string | undefined;
239
+ name: string;
240
+ role?: string | number | (string | number)[] | undefined;
241
+ data?: Record<string, any> | undefined;
242
+ };
243
+ };
244
+ };
245
+ }, {
246
+ user: import("better-auth/plugins").UserWithRole;
247
+ }>;
248
+ adminUpdateUser: import("better-auth").StrictEndpoint<"/admin/update-user", {
249
+ method: "POST";
250
+ body: import("zod").ZodObject<{
251
+ userId: import("zod").ZodCoercedString<unknown>;
252
+ data: import("zod").ZodRecord<import("zod").ZodAny, import("zod").ZodAny>;
253
+ }, import("zod/v4/core").$strip>;
254
+ use: import("better-auth").Middleware<import("better-auth").MiddlewareOptions, (inputContext: import("better-auth").MiddlewareInputContext<import("better-auth").MiddlewareOptions>) => Promise<{
255
+ session: {
256
+ user: import("better-auth/plugins").UserWithRole;
257
+ session: {
258
+ id: string;
259
+ createdAt: Date;
260
+ updatedAt: Date;
261
+ userId: string;
262
+ expiresAt: Date;
263
+ token: string;
264
+ ipAddress?: string | null | undefined;
265
+ userAgent?: string | null | undefined;
266
+ };
267
+ };
268
+ }>>[];
269
+ metadata: {
270
+ openapi: {
271
+ operationId: string;
272
+ summary: string;
273
+ description: string;
274
+ responses: {
275
+ 200: {
276
+ description: string;
277
+ content: {
278
+ "application/json": {
279
+ schema: {
280
+ type: "object";
281
+ properties: {
282
+ user: {
283
+ $ref: string;
284
+ };
285
+ };
286
+ };
287
+ };
288
+ };
289
+ };
290
+ };
291
+ };
292
+ };
293
+ }, import("better-auth/plugins").UserWithRole>;
294
+ listUsers: import("better-auth").StrictEndpoint<"/admin/list-users", {
295
+ method: "GET";
296
+ use: import("better-auth").Middleware<import("better-auth").MiddlewareOptions, (inputContext: import("better-auth").MiddlewareInputContext<import("better-auth").MiddlewareOptions>) => Promise<{
297
+ session: {
298
+ user: import("better-auth/plugins").UserWithRole;
299
+ session: {
300
+ id: string;
301
+ createdAt: Date;
302
+ updatedAt: Date;
303
+ userId: string;
304
+ expiresAt: Date;
305
+ token: string;
306
+ ipAddress?: string | null | undefined;
307
+ userAgent?: string | null | undefined;
308
+ };
309
+ };
310
+ }>>[];
311
+ query: import("zod").ZodObject<{
312
+ searchValue: import("zod").ZodOptional<import("zod").ZodString>;
313
+ searchField: import("zod").ZodOptional<import("zod").ZodEnum<{
314
+ email: "email";
315
+ name: "name";
316
+ }>>;
317
+ searchOperator: import("zod").ZodOptional<import("zod").ZodEnum<{
318
+ contains: "contains";
319
+ starts_with: "starts_with";
320
+ ends_with: "ends_with";
321
+ }>>;
322
+ limit: import("zod").ZodOptional<import("zod").ZodUnion<[import("zod").ZodString, import("zod").ZodNumber]>>;
323
+ offset: import("zod").ZodOptional<import("zod").ZodUnion<[import("zod").ZodString, import("zod").ZodNumber]>>;
324
+ sortBy: import("zod").ZodOptional<import("zod").ZodString>;
325
+ sortDirection: import("zod").ZodOptional<import("zod").ZodEnum<{
326
+ asc: "asc";
327
+ desc: "desc";
328
+ }>>;
329
+ filterField: import("zod").ZodOptional<import("zod").ZodString>;
330
+ filterValue: import("zod").ZodOptional<import("zod").ZodUnion<[import("zod").ZodUnion<[import("zod").ZodUnion<[import("zod").ZodUnion<[import("zod").ZodString, import("zod").ZodNumber]>, import("zod").ZodBoolean]>, import("zod").ZodArray<import("zod").ZodString>]>, import("zod").ZodArray<import("zod").ZodNumber>]>>;
331
+ filterOperator: import("zod").ZodOptional<import("zod").ZodEnum<{
332
+ in: "in";
333
+ lte: "lte";
334
+ eq: "eq";
335
+ ne: "ne";
336
+ lt: "lt";
337
+ gt: "gt";
338
+ gte: "gte";
339
+ not_in: "not_in";
340
+ contains: "contains";
341
+ starts_with: "starts_with";
342
+ ends_with: "ends_with";
343
+ }>>;
344
+ }, import("zod/v4/core").$strip>;
345
+ metadata: {
346
+ openapi: {
347
+ operationId: string;
348
+ summary: string;
349
+ description: string;
350
+ responses: {
351
+ 200: {
352
+ description: string;
353
+ content: {
354
+ "application/json": {
355
+ schema: {
356
+ type: "object";
357
+ properties: {
358
+ users: {
359
+ type: string;
360
+ items: {
361
+ $ref: string;
362
+ };
363
+ };
364
+ total: {
365
+ type: string;
366
+ };
367
+ limit: {
368
+ type: string;
369
+ };
370
+ offset: {
371
+ type: string;
372
+ };
373
+ };
374
+ required: string[];
375
+ };
376
+ };
377
+ };
378
+ };
379
+ };
380
+ };
381
+ };
382
+ }, {
383
+ users: import("better-auth/plugins").UserWithRole[];
384
+ total: number;
385
+ }>;
386
+ listUserSessions: import("better-auth").StrictEndpoint<"/admin/list-user-sessions", {
387
+ method: "POST";
388
+ use: import("better-auth").Middleware<import("better-auth").MiddlewareOptions, (inputContext: import("better-auth").MiddlewareInputContext<import("better-auth").MiddlewareOptions>) => Promise<{
389
+ session: {
390
+ user: import("better-auth/plugins").UserWithRole;
391
+ session: {
392
+ id: string;
393
+ createdAt: Date;
394
+ updatedAt: Date;
395
+ userId: string;
396
+ expiresAt: Date;
397
+ token: string;
398
+ ipAddress?: string | null | undefined;
399
+ userAgent?: string | null | undefined;
400
+ };
401
+ };
402
+ }>>[];
403
+ body: import("zod").ZodObject<{
404
+ userId: import("zod").ZodCoercedString<unknown>;
405
+ }, import("zod/v4/core").$strip>;
406
+ metadata: {
407
+ openapi: {
408
+ operationId: string;
409
+ summary: string;
410
+ description: string;
411
+ responses: {
412
+ 200: {
413
+ description: string;
414
+ content: {
415
+ "application/json": {
416
+ schema: {
417
+ type: "object";
418
+ properties: {
419
+ sessions: {
420
+ type: string;
421
+ items: {
422
+ $ref: string;
423
+ };
424
+ };
425
+ };
426
+ };
427
+ };
428
+ };
429
+ };
430
+ };
431
+ };
432
+ };
433
+ }, {
434
+ sessions: import("better-auth/plugins").SessionWithImpersonatedBy[];
435
+ }>;
436
+ unbanUser: import("better-auth").StrictEndpoint<"/admin/unban-user", {
437
+ method: "POST";
438
+ body: import("zod").ZodObject<{
439
+ userId: import("zod").ZodCoercedString<unknown>;
440
+ }, import("zod/v4/core").$strip>;
441
+ use: import("better-auth").Middleware<import("better-auth").MiddlewareOptions, (inputContext: import("better-auth").MiddlewareInputContext<import("better-auth").MiddlewareOptions>) => Promise<{
442
+ session: {
443
+ user: import("better-auth/plugins").UserWithRole;
444
+ session: {
445
+ id: string;
446
+ createdAt: Date;
447
+ updatedAt: Date;
448
+ userId: string;
449
+ expiresAt: Date;
450
+ token: string;
451
+ ipAddress?: string | null | undefined;
452
+ userAgent?: string | null | undefined;
453
+ };
454
+ };
455
+ }>>[];
456
+ metadata: {
457
+ openapi: {
458
+ operationId: string;
459
+ summary: string;
460
+ description: string;
461
+ responses: {
462
+ 200: {
463
+ description: string;
464
+ content: {
465
+ "application/json": {
466
+ schema: {
467
+ type: "object";
468
+ properties: {
469
+ user: {
470
+ $ref: string;
471
+ };
472
+ };
473
+ };
474
+ };
475
+ };
476
+ };
477
+ };
478
+ };
479
+ };
480
+ }, {
481
+ user: import("better-auth/plugins").UserWithRole;
482
+ }>;
483
+ banUser: import("better-auth").StrictEndpoint<"/admin/ban-user", {
484
+ method: "POST";
485
+ body: import("zod").ZodObject<{
486
+ userId: import("zod").ZodCoercedString<unknown>;
487
+ banReason: import("zod").ZodOptional<import("zod").ZodString>;
488
+ banExpiresIn: import("zod").ZodOptional<import("zod").ZodNumber>;
489
+ }, import("zod/v4/core").$strip>;
490
+ use: import("better-auth").Middleware<import("better-auth").MiddlewareOptions, (inputContext: import("better-auth").MiddlewareInputContext<import("better-auth").MiddlewareOptions>) => Promise<{
491
+ session: {
492
+ user: import("better-auth/plugins").UserWithRole;
493
+ session: {
494
+ id: string;
495
+ createdAt: Date;
496
+ updatedAt: Date;
497
+ userId: string;
498
+ expiresAt: Date;
499
+ token: string;
500
+ ipAddress?: string | null | undefined;
501
+ userAgent?: string | null | undefined;
502
+ };
503
+ };
504
+ }>>[];
505
+ metadata: {
506
+ openapi: {
507
+ operationId: string;
508
+ summary: string;
509
+ description: string;
510
+ responses: {
511
+ 200: {
512
+ description: string;
513
+ content: {
514
+ "application/json": {
515
+ schema: {
516
+ type: "object";
517
+ properties: {
518
+ user: {
519
+ $ref: string;
520
+ };
521
+ };
522
+ };
523
+ };
524
+ };
525
+ };
526
+ };
527
+ };
528
+ };
529
+ }, {
530
+ user: import("better-auth/plugins").UserWithRole;
531
+ }>;
532
+ impersonateUser: import("better-auth").StrictEndpoint<"/admin/impersonate-user", {
533
+ method: "POST";
534
+ body: import("zod").ZodObject<{
535
+ userId: import("zod").ZodCoercedString<unknown>;
536
+ }, import("zod/v4/core").$strip>;
537
+ use: import("better-auth").Middleware<import("better-auth").MiddlewareOptions, (inputContext: import("better-auth").MiddlewareInputContext<import("better-auth").MiddlewareOptions>) => Promise<{
538
+ session: {
539
+ user: import("better-auth/plugins").UserWithRole;
540
+ session: {
541
+ id: string;
542
+ createdAt: Date;
543
+ updatedAt: Date;
544
+ userId: string;
545
+ expiresAt: Date;
546
+ token: string;
547
+ ipAddress?: string | null | undefined;
548
+ userAgent?: string | null | undefined;
549
+ };
550
+ };
551
+ }>>[];
552
+ metadata: {
553
+ openapi: {
554
+ operationId: string;
555
+ summary: string;
556
+ description: string;
557
+ responses: {
558
+ 200: {
559
+ description: string;
560
+ content: {
561
+ "application/json": {
562
+ schema: {
563
+ type: "object";
564
+ properties: {
565
+ session: {
566
+ $ref: string;
567
+ };
568
+ user: {
569
+ $ref: string;
570
+ };
571
+ };
572
+ };
573
+ };
574
+ };
575
+ };
576
+ };
577
+ };
578
+ };
579
+ }, {
580
+ session: {
581
+ id: string;
582
+ createdAt: Date;
583
+ updatedAt: Date;
584
+ userId: string;
585
+ expiresAt: Date;
586
+ token: string;
587
+ ipAddress?: string | null | undefined;
588
+ userAgent?: string | null | undefined;
589
+ };
590
+ user: import("better-auth/plugins").UserWithRole;
591
+ }>;
592
+ stopImpersonating: import("better-auth").StrictEndpoint<"/admin/stop-impersonating", {
593
+ method: "POST";
594
+ requireHeaders: true;
595
+ }, {
596
+ session: {
597
+ id: string;
598
+ createdAt: Date;
599
+ updatedAt: Date;
600
+ userId: string;
601
+ expiresAt: Date;
602
+ token: string;
603
+ ipAddress?: string | null | undefined;
604
+ userAgent?: string | null | undefined;
605
+ } & Record<string, any>;
606
+ user: {
607
+ id: string;
608
+ createdAt: Date;
609
+ updatedAt: Date;
610
+ email: string;
611
+ emailVerified: boolean;
612
+ name: string;
613
+ image?: string | null | undefined;
614
+ } & Record<string, any>;
615
+ }>;
616
+ revokeUserSession: import("better-auth").StrictEndpoint<"/admin/revoke-user-session", {
617
+ method: "POST";
618
+ body: import("zod").ZodObject<{
619
+ sessionToken: import("zod").ZodString;
620
+ }, import("zod/v4/core").$strip>;
621
+ use: import("better-auth").Middleware<import("better-auth").MiddlewareOptions, (inputContext: import("better-auth").MiddlewareInputContext<import("better-auth").MiddlewareOptions>) => Promise<{
622
+ session: {
623
+ user: import("better-auth/plugins").UserWithRole;
624
+ session: {
625
+ id: string;
626
+ createdAt: Date;
627
+ updatedAt: Date;
628
+ userId: string;
629
+ expiresAt: Date;
630
+ token: string;
631
+ ipAddress?: string | null | undefined;
632
+ userAgent?: string | null | undefined;
633
+ };
634
+ };
635
+ }>>[];
636
+ metadata: {
637
+ openapi: {
638
+ operationId: string;
639
+ summary: string;
640
+ description: string;
641
+ responses: {
642
+ 200: {
643
+ description: string;
644
+ content: {
645
+ "application/json": {
646
+ schema: {
647
+ type: "object";
648
+ properties: {
649
+ success: {
650
+ type: string;
651
+ };
652
+ };
653
+ };
654
+ };
655
+ };
656
+ };
657
+ };
658
+ };
659
+ };
660
+ }, {
661
+ success: boolean;
662
+ }>;
663
+ revokeUserSessions: import("better-auth").StrictEndpoint<"/admin/revoke-user-sessions", {
664
+ method: "POST";
665
+ body: import("zod").ZodObject<{
666
+ userId: import("zod").ZodCoercedString<unknown>;
667
+ }, import("zod/v4/core").$strip>;
668
+ use: import("better-auth").Middleware<import("better-auth").MiddlewareOptions, (inputContext: import("better-auth").MiddlewareInputContext<import("better-auth").MiddlewareOptions>) => Promise<{
669
+ session: {
670
+ user: import("better-auth/plugins").UserWithRole;
671
+ session: {
672
+ id: string;
673
+ createdAt: Date;
674
+ updatedAt: Date;
675
+ userId: string;
676
+ expiresAt: Date;
677
+ token: string;
678
+ ipAddress?: string | null | undefined;
679
+ userAgent?: string | null | undefined;
680
+ };
681
+ };
682
+ }>>[];
683
+ metadata: {
684
+ openapi: {
685
+ operationId: string;
686
+ summary: string;
687
+ description: string;
688
+ responses: {
689
+ 200: {
690
+ description: string;
691
+ content: {
692
+ "application/json": {
693
+ schema: {
694
+ type: "object";
695
+ properties: {
696
+ success: {
697
+ type: string;
698
+ };
699
+ };
700
+ };
701
+ };
702
+ };
703
+ };
704
+ };
705
+ };
706
+ };
707
+ }, {
708
+ success: boolean;
709
+ }>;
710
+ removeUser: import("better-auth").StrictEndpoint<"/admin/remove-user", {
711
+ method: "POST";
712
+ body: import("zod").ZodObject<{
713
+ userId: import("zod").ZodCoercedString<unknown>;
714
+ }, import("zod/v4/core").$strip>;
715
+ use: import("better-auth").Middleware<import("better-auth").MiddlewareOptions, (inputContext: import("better-auth").MiddlewareInputContext<import("better-auth").MiddlewareOptions>) => Promise<{
716
+ session: {
717
+ user: import("better-auth/plugins").UserWithRole;
718
+ session: {
719
+ id: string;
720
+ createdAt: Date;
721
+ updatedAt: Date;
722
+ userId: string;
723
+ expiresAt: Date;
724
+ token: string;
725
+ ipAddress?: string | null | undefined;
726
+ userAgent?: string | null | undefined;
727
+ };
728
+ };
729
+ }>>[];
730
+ metadata: {
731
+ openapi: {
732
+ operationId: string;
733
+ summary: string;
734
+ description: string;
735
+ responses: {
736
+ 200: {
737
+ description: string;
738
+ content: {
739
+ "application/json": {
740
+ schema: {
741
+ type: "object";
742
+ properties: {
743
+ success: {
744
+ type: string;
745
+ };
746
+ };
747
+ };
748
+ };
749
+ };
750
+ };
751
+ };
752
+ };
753
+ };
754
+ }, {
755
+ success: boolean;
756
+ }>;
757
+ setUserPassword: import("better-auth").StrictEndpoint<"/admin/set-user-password", {
758
+ method: "POST";
759
+ body: import("zod").ZodObject<{
760
+ newPassword: import("zod").ZodString;
761
+ userId: import("zod").ZodCoercedString<unknown>;
762
+ }, import("zod/v4/core").$strip>;
763
+ use: import("better-auth").Middleware<import("better-auth").MiddlewareOptions, (inputContext: import("better-auth").MiddlewareInputContext<import("better-auth").MiddlewareOptions>) => Promise<{
764
+ session: {
765
+ user: import("better-auth/plugins").UserWithRole;
766
+ session: {
767
+ id: string;
768
+ createdAt: Date;
769
+ updatedAt: Date;
770
+ userId: string;
771
+ expiresAt: Date;
772
+ token: string;
773
+ ipAddress?: string | null | undefined;
774
+ userAgent?: string | null | undefined;
775
+ };
776
+ };
777
+ }>>[];
778
+ metadata: {
779
+ openapi: {
780
+ operationId: string;
781
+ summary: string;
782
+ description: string;
783
+ responses: {
784
+ 200: {
785
+ description: string;
786
+ content: {
787
+ "application/json": {
788
+ schema: {
789
+ type: "object";
790
+ properties: {
791
+ status: {
792
+ type: string;
793
+ };
794
+ };
795
+ };
796
+ };
797
+ };
798
+ };
799
+ };
800
+ };
801
+ };
802
+ }, {
803
+ status: boolean;
804
+ }>;
805
+ userHasPermission: import("better-auth").StrictEndpoint<"/admin/has-permission", {
806
+ method: "POST";
807
+ body: import("zod").ZodIntersection<import("zod").ZodObject<{
808
+ userId: import("zod").ZodOptional<import("zod").ZodCoercedString<unknown>>;
809
+ role: import("zod").ZodOptional<import("zod").ZodString>;
810
+ }, import("zod/v4/core").$strip>, import("zod").ZodXor<readonly [import("zod").ZodObject<{
811
+ permission: import("zod").ZodRecord<import("zod").ZodString, import("zod").ZodArray<import("zod").ZodString>>;
812
+ }, import("zod/v4/core").$strip>, import("zod").ZodObject<{
813
+ permissions: import("zod").ZodRecord<import("zod").ZodString, import("zod").ZodArray<import("zod").ZodString>>;
814
+ }, import("zod/v4/core").$strip>]>>;
815
+ metadata: {
816
+ openapi: {
817
+ description: string;
818
+ requestBody: {
819
+ content: {
820
+ "application/json": {
821
+ schema: {
822
+ type: "object";
823
+ properties: {
824
+ permissions: {
825
+ type: string;
826
+ description: string;
827
+ };
828
+ };
829
+ required: string[];
830
+ };
831
+ };
832
+ };
833
+ };
834
+ responses: {
835
+ "200": {
836
+ description: string;
837
+ content: {
838
+ "application/json": {
839
+ schema: {
840
+ type: "object";
841
+ properties: {
842
+ error: {
843
+ type: string;
844
+ };
845
+ success: {
846
+ type: string;
847
+ };
848
+ };
849
+ required: string[];
850
+ };
851
+ };
852
+ };
853
+ };
854
+ };
855
+ };
856
+ $Infer: {
857
+ body: {
858
+ permissions: {
859
+ readonly user?: ("create" | "list" | "set-role" | "ban" | "impersonate" | "delete" | "set-password" | "set-email" | "get" | "update" | "impersonate-admins")[] | undefined;
860
+ readonly session?: ("list" | "delete" | "revoke")[] | undefined;
861
+ };
862
+ } & {
863
+ userId?: string | undefined;
864
+ role?: string | number | undefined;
865
+ };
866
+ };
867
+ };
868
+ }, {
869
+ error: null;
870
+ success: boolean;
871
+ }>;
872
+ };
873
+ $ERROR_CODES: {
874
+ USER_ALREADY_EXISTS_USE_ANOTHER_EMAIL: import("better-auth").RawError<"USER_ALREADY_EXISTS_USE_ANOTHER_EMAIL">;
875
+ FAILED_TO_CREATE_USER: import("better-auth").RawError<"FAILED_TO_CREATE_USER">;
876
+ USER_ALREADY_EXISTS: import("better-auth").RawError<"USER_ALREADY_EXISTS">;
877
+ YOU_CANNOT_BAN_YOURSELF: import("better-auth").RawError<"YOU_CANNOT_BAN_YOURSELF">;
878
+ YOU_ARE_NOT_ALLOWED_TO_CHANGE_USERS_ROLE: import("better-auth").RawError<"YOU_ARE_NOT_ALLOWED_TO_CHANGE_USERS_ROLE">;
879
+ YOU_ARE_NOT_ALLOWED_TO_CREATE_USERS: import("better-auth").RawError<"YOU_ARE_NOT_ALLOWED_TO_CREATE_USERS">;
880
+ YOU_ARE_NOT_ALLOWED_TO_LIST_USERS: import("better-auth").RawError<"YOU_ARE_NOT_ALLOWED_TO_LIST_USERS">;
881
+ YOU_ARE_NOT_ALLOWED_TO_LIST_USERS_SESSIONS: import("better-auth").RawError<"YOU_ARE_NOT_ALLOWED_TO_LIST_USERS_SESSIONS">;
882
+ YOU_ARE_NOT_ALLOWED_TO_BAN_USERS: import("better-auth").RawError<"YOU_ARE_NOT_ALLOWED_TO_BAN_USERS">;
883
+ YOU_ARE_NOT_ALLOWED_TO_IMPERSONATE_USERS: import("better-auth").RawError<"YOU_ARE_NOT_ALLOWED_TO_IMPERSONATE_USERS">;
884
+ YOU_ARE_NOT_ALLOWED_TO_REVOKE_USERS_SESSIONS: import("better-auth").RawError<"YOU_ARE_NOT_ALLOWED_TO_REVOKE_USERS_SESSIONS">;
885
+ YOU_ARE_NOT_ALLOWED_TO_DELETE_USERS: import("better-auth").RawError<"YOU_ARE_NOT_ALLOWED_TO_DELETE_USERS">;
886
+ YOU_ARE_NOT_ALLOWED_TO_SET_USERS_PASSWORD: import("better-auth").RawError<"YOU_ARE_NOT_ALLOWED_TO_SET_USERS_PASSWORD">;
887
+ BANNED_USER: import("better-auth").RawError<"BANNED_USER">;
888
+ YOU_ARE_NOT_ALLOWED_TO_GET_USER: import("better-auth").RawError<"YOU_ARE_NOT_ALLOWED_TO_GET_USER">;
889
+ NO_DATA_TO_UPDATE: import("better-auth").RawError<"NO_DATA_TO_UPDATE">;
890
+ YOU_ARE_NOT_ALLOWED_TO_UPDATE_USERS: import("better-auth").RawError<"YOU_ARE_NOT_ALLOWED_TO_UPDATE_USERS">;
891
+ YOU_CANNOT_REMOVE_YOURSELF: import("better-auth").RawError<"YOU_CANNOT_REMOVE_YOURSELF">;
892
+ YOU_ARE_NOT_ALLOWED_TO_SET_NON_EXISTENT_VALUE: import("better-auth").RawError<"YOU_ARE_NOT_ALLOWED_TO_SET_NON_EXISTENT_VALUE">;
893
+ YOU_CANNOT_IMPERSONATE_ADMINS: import("better-auth").RawError<"YOU_CANNOT_IMPERSONATE_ADMINS">;
894
+ INVALID_ROLE_TYPE: import("better-auth").RawError<"INVALID_ROLE_TYPE">;
895
+ YOU_ARE_NOT_ALLOWED_TO_SET_USERS_EMAIL: import("better-auth").RawError<"YOU_ARE_NOT_ALLOWED_TO_SET_USERS_EMAIL">;
896
+ PASSWORD_CANNOT_BE_UPDATED_VIA_UPDATE_USER: import("better-auth").RawError<"PASSWORD_CANNOT_BE_UPDATED_VIA_UPDATE_USER">;
897
+ };
898
+ schema: {
899
+ user: {
900
+ fields: {
901
+ role: {
902
+ type: "string";
903
+ required: false;
904
+ input: false;
905
+ };
906
+ banned: {
907
+ type: "boolean";
908
+ defaultValue: false;
909
+ required: false;
910
+ input: false;
911
+ };
912
+ banReason: {
913
+ type: "string";
914
+ required: false;
915
+ input: false;
916
+ };
917
+ banExpires: {
918
+ type: "date";
919
+ required: false;
920
+ input: false;
921
+ };
922
+ };
923
+ };
924
+ session: {
925
+ fields: {
926
+ impersonatedBy: {
927
+ type: "string";
928
+ required: false;
929
+ input: false;
930
+ };
931
+ };
932
+ };
933
+ };
934
+ options: NoInfer<{
935
+ defaultRole: string;
936
+ roles: {
937
+ [k: string]: import("better-auth/plugins").Role<import("better-auth/plugins").ExactRoleStatements<{
938
+ readonly user: ["create", "list", "set-role", "ban", "impersonate", "delete", "set-password", "set-email", "get", "update"];
939
+ readonly session: ["list", "revoke", "delete"];
940
+ }>, {
941
+ readonly user: readonly ["create", "list", "set-role", "ban", "impersonate", "impersonate-admins", "delete", "set-password", "set-email", "get", "update"];
942
+ readonly session: readonly ["list", "revoke", "delete"];
943
+ }> | import("better-auth/plugins").Role<import("better-auth/plugins").ExactRoleStatements<{
944
+ readonly user: [];
945
+ readonly session: [];
946
+ }>, {
947
+ readonly user: readonly ["create", "list", "set-role", "ban", "impersonate", "impersonate-admins", "delete", "set-password", "set-email", "get", "update"];
948
+ readonly session: readonly ["list", "revoke", "delete"];
949
+ }>;
950
+ };
951
+ }>;
952
+ }, {
953
+ id: "jwt";
954
+ version: string;
955
+ options: NoInfer<{
956
+ jwt: {
957
+ expirationTime: string;
958
+ issuer: string;
959
+ audience: string;
960
+ definePayload: ({ user }: {
961
+ user: import("better-auth").User & Record<string, any>;
962
+ session: import("better-auth").Session & Record<string, any>;
963
+ }) => {
964
+ email: string;
965
+ role: any;
966
+ };
967
+ };
968
+ }>;
969
+ init(ctx: import("better-auth").AuthContext): {
970
+ context: {
971
+ sessionConfig: {
972
+ cookieCacheSigner: import("better-auth").CookieCacheSigner;
973
+ updateAge: number;
974
+ expiresIn: number;
975
+ freshAge: number;
976
+ cookieRefreshCache: false | {
977
+ enabled: true;
978
+ updateAge: number;
979
+ };
980
+ };
981
+ };
982
+ } | undefined;
983
+ endpoints: {
984
+ getJwks: import("better-auth").StrictEndpoint<string, {
985
+ method: "GET";
986
+ metadata: {
987
+ openapi: {
988
+ operationId: string;
989
+ description: string;
990
+ responses: {
991
+ "200": {
992
+ description: string;
993
+ content: {
994
+ "application/json": {
995
+ schema: {
996
+ type: "object";
997
+ properties: {
998
+ keys: {
999
+ type: string;
1000
+ description: string;
1001
+ items: {
1002
+ type: string;
1003
+ properties: {
1004
+ kid: {
1005
+ type: string;
1006
+ description: string;
1007
+ };
1008
+ kty: {
1009
+ type: string;
1010
+ description: string;
1011
+ };
1012
+ alg: {
1013
+ type: string;
1014
+ description: string;
1015
+ };
1016
+ use: {
1017
+ type: string;
1018
+ description: string;
1019
+ enum: string[];
1020
+ nullable: boolean;
1021
+ };
1022
+ n: {
1023
+ type: string;
1024
+ description: string;
1025
+ nullable: boolean;
1026
+ };
1027
+ e: {
1028
+ type: string;
1029
+ description: string;
1030
+ nullable: boolean;
1031
+ };
1032
+ crv: {
1033
+ type: string;
1034
+ description: string;
1035
+ nullable: boolean;
1036
+ };
1037
+ x: {
1038
+ type: string;
1039
+ description: string;
1040
+ nullable: boolean;
1041
+ };
1042
+ y: {
1043
+ type: string;
1044
+ description: string;
1045
+ nullable: boolean;
1046
+ };
1047
+ };
1048
+ required: string[];
1049
+ };
1050
+ };
1051
+ };
1052
+ required: string[];
1053
+ };
1054
+ };
1055
+ };
1056
+ };
1057
+ };
1058
+ };
1059
+ };
1060
+ }, import("jose").JSONWebKeySet>;
1061
+ getToken: import("better-auth").StrictEndpoint<"/token", {
1062
+ method: "GET";
1063
+ requireHeaders: true;
1064
+ use: import("better-auth").Middleware<import("better-auth").MiddlewareOptions, (inputContext: import("better-auth").MiddlewareInputContext<import("better-auth").MiddlewareOptions>) => Promise<{
1065
+ session: {
1066
+ session: Record<string, any> & {
1067
+ id: string;
1068
+ createdAt: Date;
1069
+ updatedAt: Date;
1070
+ userId: string;
1071
+ expiresAt: Date;
1072
+ token: string;
1073
+ ipAddress?: string | null | undefined;
1074
+ userAgent?: string | null | undefined;
1075
+ };
1076
+ user: Record<string, any> & {
1077
+ id: string;
1078
+ createdAt: Date;
1079
+ updatedAt: Date;
1080
+ email: string;
1081
+ emailVerified: boolean;
1082
+ name: string;
1083
+ image?: string | null | undefined;
1084
+ };
1085
+ };
1086
+ }>>[];
1087
+ metadata: {
1088
+ openapi: {
1089
+ operationId: string;
1090
+ description: string;
1091
+ responses: {
1092
+ 200: {
1093
+ description: string;
1094
+ content: {
1095
+ "application/json": {
1096
+ schema: {
1097
+ type: "object";
1098
+ properties: {
1099
+ token: {
1100
+ type: string;
1101
+ };
1102
+ };
1103
+ };
1104
+ };
1105
+ };
1106
+ };
1107
+ };
1108
+ };
1109
+ };
1110
+ }, {
1111
+ token: string;
1112
+ }>;
1113
+ signJWT: import("better-auth").StrictEndpoint<string, {
1114
+ method: "POST";
1115
+ metadata: {
1116
+ $Infer: {
1117
+ body: {
1118
+ payload: import("jose").JWTPayload;
1119
+ overrideOptions?: import("better-auth/plugins").JwtOptions | undefined;
1120
+ };
1121
+ };
1122
+ };
1123
+ body: import("zod").ZodObject<{
1124
+ payload: import("zod").ZodRecord<import("zod").ZodString, import("zod").ZodAny>;
1125
+ overrideOptions: import("zod").ZodOptional<import("zod").ZodRecord<import("zod").ZodString, import("zod").ZodAny>>;
1126
+ }, import("zod/v4/core").$strip>;
1127
+ }, {
1128
+ token: string;
1129
+ }>;
1130
+ verifyJWT: import("better-auth").StrictEndpoint<string, {
1131
+ method: "POST";
1132
+ metadata: {
1133
+ $Infer: {
1134
+ body: {
1135
+ token: string;
1136
+ issuer?: string;
1137
+ };
1138
+ response: {
1139
+ payload: {
1140
+ sub: string;
1141
+ aud: string;
1142
+ [key: string]: any;
1143
+ } | null;
1144
+ };
1145
+ };
1146
+ };
1147
+ body: import("zod").ZodObject<{
1148
+ token: import("zod").ZodString;
1149
+ issuer: import("zod").ZodOptional<import("zod").ZodString>;
1150
+ }, import("zod/v4/core").$strip>;
1151
+ }, {
1152
+ payload: (import("jose").JWTPayload & Required<Pick<import("jose").JWTPayload, "sub" | "aud">>) | null;
1153
+ }>;
1154
+ };
1155
+ hooks: {
1156
+ after: {
1157
+ matcher(context: import("better-auth").HookEndpointContext): boolean;
1158
+ handler: import("better-auth").Middleware<import("better-auth").MiddlewareOptions, (inputContext: import("better-auth").MiddlewareInputContext<import("better-auth").MiddlewareOptions>) => Promise<void>>;
1159
+ }[];
1160
+ };
1161
+ schema: {
1162
+ jwks: {
1163
+ fields: {
1164
+ publicKey: {
1165
+ type: "string";
1166
+ required: true;
1167
+ };
1168
+ privateKey: {
1169
+ type: "string";
1170
+ required: true;
1171
+ };
1172
+ createdAt: {
1173
+ type: "date";
1174
+ required: true;
1175
+ };
1176
+ expiresAt: {
1177
+ type: "date";
1178
+ required: false;
1179
+ };
1180
+ alg: {
1181
+ type: "string";
1182
+ required: false;
1183
+ };
1184
+ crv: {
1185
+ type: "string";
1186
+ required: false;
1187
+ };
1188
+ };
1189
+ };
1190
+ };
1191
+ }];
1192
+ databaseHooks: {
1193
+ user: {
1194
+ create: {
1195
+ before: (user: {
1196
+ id: string;
1197
+ createdAt: Date;
1198
+ updatedAt: Date;
1199
+ email: string;
1200
+ emailVerified: boolean;
1201
+ name: string;
1202
+ image?: string | null | undefined;
1203
+ } & Record<string, unknown>) => Promise<{
1204
+ data: {
1205
+ id: string;
1206
+ createdAt: Date;
1207
+ updatedAt: Date;
1208
+ email: string;
1209
+ emailVerified: boolean;
1210
+ name: string;
1211
+ image?: string | null | undefined;
1212
+ } & Record<string, unknown>;
1213
+ }>;
1214
+ };
1215
+ };
1216
+ };
1217
+ rateLimit: {
1218
+ enabled: true;
1219
+ window: number;
1220
+ max: number;
1221
+ customRules: {
1222
+ '/sign-in/email': {
1223
+ window: number;
1224
+ max: number;
1225
+ };
1226
+ };
1227
+ };
1228
+ advanced: {
1229
+ useSecureCookies: boolean;
1230
+ defaultCookieAttributes: {
1231
+ sameSite: "lax";
1232
+ secure: boolean;
1233
+ };
1234
+ backgroundTasks: {
1235
+ handler: () => void;
1236
+ };
1237
+ };
1238
+ }> & {
1239
+ roles: string[];
1240
+ defaultRole: string | undefined;
1241
+ passwordReset: boolean;
1242
+ };
1243
+ export type AdminAuth = ReturnType<typeof createAuth>;
1244
+ //#endregion