@protobase/server 0.0.0-stage → 0.1.1

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