better-auth 0.0.2-beta.7 → 0.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (96) hide show
  1. package/dist/access.d.ts +4 -0
  2. package/dist/access.js +126 -0
  3. package/dist/access.js.map +1 -0
  4. package/dist/cli.d.ts +2 -0
  5. package/dist/cli.js +553 -0
  6. package/dist/cli.js.map +1 -0
  7. package/dist/client/plugins.d.ts +2436 -0
  8. package/dist/client/plugins.js +411 -0
  9. package/dist/client/plugins.js.map +1 -0
  10. package/dist/client-A2Mt04KQ.d.ts +3503 -0
  11. package/dist/client.d.ts +1433 -0
  12. package/dist/client.js +693 -0
  13. package/dist/client.js.map +1 -0
  14. package/dist/helper-B5_2Vzba.d.ts +14 -0
  15. package/dist/index-Dg4eEXZW.d.ts +24 -0
  16. package/dist/index-W5nXvJ-p.d.ts +1498 -0
  17. package/dist/index.d.ts +6 -4
  18. package/dist/index.js +2195 -1191
  19. package/dist/index.js.map +1 -1
  20. package/dist/next-js.d.ts +14 -0
  21. package/dist/next-js.js +14 -0
  22. package/dist/next-js.js.map +1 -0
  23. package/dist/plugins.d.ts +892 -49
  24. package/dist/plugins.js +3951 -253
  25. package/dist/plugins.js.map +1 -1
  26. package/dist/preact.d.ts +8 -0
  27. package/dist/preact.js +294 -0
  28. package/dist/preact.js.map +1 -0
  29. package/dist/react.d.ts +14 -0
  30. package/dist/react.js +314 -0
  31. package/dist/react.js.map +1 -0
  32. package/dist/schema-BOszzrbQ.d.ts +792 -0
  33. package/dist/social.d.ts +4 -0
  34. package/dist/social.js +509 -0
  35. package/dist/social.js.map +1 -0
  36. package/dist/solid-start.d.ts +18 -0
  37. package/dist/solid-start.js +14 -0
  38. package/dist/solid-start.js.map +1 -0
  39. package/dist/solid.d.ts +2790 -0
  40. package/dist/solid.js +306 -0
  41. package/dist/solid.js.map +1 -0
  42. package/dist/statement-COylZd3J.d.ts +81 -0
  43. package/dist/svelte-kit.d.ts +10 -7
  44. package/dist/svelte-kit.js +12 -17
  45. package/dist/svelte-kit.js.map +1 -1
  46. package/dist/svelte.d.ts +2791 -0
  47. package/dist/svelte.js +304 -0
  48. package/dist/svelte.js.map +1 -0
  49. package/dist/type-DbMyI3b5.d.ts +5724 -0
  50. package/dist/types.d.ts +7 -0
  51. package/dist/types.js +1 -0
  52. package/dist/types.js.map +1 -0
  53. package/dist/vue.d.ts +14 -0
  54. package/dist/vue.js +311 -0
  55. package/dist/vue.js.map +1 -0
  56. package/package.json +80 -54
  57. package/LICENSE +0 -21
  58. package/dist/actions.d.ts +0 -33
  59. package/dist/actions.js +0 -1373
  60. package/dist/actions.js.map +0 -1
  61. package/dist/adapters/drizzle-adapter.d.ts +0 -10
  62. package/dist/adapters/drizzle-adapter.js +0 -1095
  63. package/dist/adapters/drizzle-adapter.js.map +0 -1
  64. package/dist/adapters/memory.d.ts +0 -8
  65. package/dist/adapters/memory.js +0 -136
  66. package/dist/adapters/memory.js.map +0 -1
  67. package/dist/adapters/mongodb-adapter.d.ts +0 -9
  68. package/dist/adapters/mongodb-adapter.js +0 -97
  69. package/dist/adapters/mongodb-adapter.js.map +0 -1
  70. package/dist/adapters/prisma-adapter.d.ts +0 -7
  71. package/dist/adapters/prisma-adapter.js +0 -144
  72. package/dist/adapters/prisma-adapter.js.map +0 -1
  73. package/dist/adapters/redis-adapter.d.ts +0 -7
  74. package/dist/adapters/redis-adapter.js +0 -65
  75. package/dist/adapters/redis-adapter.js.map +0 -1
  76. package/dist/adapters.d.ts +0 -3
  77. package/dist/adapters.js +0 -206
  78. package/dist/adapters.js.map +0 -1
  79. package/dist/h3.d.ts +0 -10
  80. package/dist/h3.js +0 -326
  81. package/dist/h3.js.map +0 -1
  82. package/dist/hono.d.ts +0 -10
  83. package/dist/hono.js +0 -25
  84. package/dist/hono.js.map +0 -1
  85. package/dist/index-UcTu1vUg.d.ts +0 -107
  86. package/dist/next.d.ts +0 -17
  87. package/dist/next.js +0 -26
  88. package/dist/next.js.map +0 -1
  89. package/dist/options-CH15FEBw.d.ts +0 -1562
  90. package/dist/providers.d.ts +0 -3
  91. package/dist/providers.js +0 -653
  92. package/dist/providers.js.map +0 -1
  93. package/dist/routes/session.d.ts +0 -39
  94. package/dist/routes/session.js +0 -128
  95. package/dist/routes/session.js.map +0 -1
  96. package/dist/types-DAxaMWCy.d.ts +0 -136
package/dist/plugins.d.ts CHANGED
@@ -1,55 +1,898 @@
1
- import { a as BetterAuthPlugin, P as Providers, B as BetterAuthOptions, C as Context, I as InternalResponse, G as GenericHandler } from './options-CH15FEBw.js';
2
- export { A as AfterHookHandler, b as BeforeHookHandler } from './options-CH15FEBw.js';
3
- import './types-DAxaMWCy.js';
4
- import 'zod';
1
+ import { T as TwoFactorOptions, U as UserWithTwoFactor } from './client-A2Mt04KQ.js';
2
+ export { O as OrganizationOptions, a as Passkey, P as PasskeyOptions, W as WebAuthnCookieType, g as getPasskeyActions, o as organization, b as passkey, p as passkeyClient, t as twoFactorClient } from './client-A2Mt04KQ.js';
3
+ export { i as ac } from './index-Dg4eEXZW.js';
4
+ import { G as GenericEndpointContext } from './index-W5nXvJ-p.js';
5
+ import * as better_call from 'better-call';
6
+ import { z } from 'zod';
7
+ import 'nanostores';
8
+ import './type-DbMyI3b5.js';
9
+ import '@better-fetch/fetch';
10
+ import './helper-B5_2Vzba.js';
11
+ import '@nanostores/react';
12
+ import '@vue/reactivity';
13
+ import '@nanostores/vue';
14
+ import '@nanostores/solid';
15
+ import './schema-BOszzrbQ.js';
16
+ import 'arctic';
17
+ import './preact.js';
18
+ import './statement-COylZd3J.js';
19
+ import '@simplewebauthn/types';
20
+ import 'kysely';
5
21
 
6
- interface EmailVerificationOptions {
7
- /**
8
- * Send email to the user with the verification url.
9
- */
10
- sendEmail: (email: string, url: string) => Promise<void>;
11
- /**
12
- * Expiry time for the token.
13
- * @default 60 * 60 * 24 (1 day)
14
- */
15
- expiresIn?: number;
16
- /**
17
- * On which providers to enable email verification.
18
- * @default ["credential"]
19
- */
20
- providers?: (keyof Providers)[];
21
- /**
22
- * Redirect URL after email verification.
23
- */
24
- redirectURL: {
25
- /**
26
- * URL to redirect to on success.
27
- */
28
- success: string;
29
- /**
30
- * URL to redirect to on error. The error will be =
31
- * appended as a query param.
32
- */
33
- error: string;
22
+ declare const twoFactor: <O extends TwoFactorOptions>(options: O) => {
23
+ id: "two-factor";
24
+ endpoints: {
25
+ enableTwoFactor: {
26
+ (ctx_0?: better_call.Context<"/two-factor/enable", {
27
+ method: "POST";
28
+ use: better_call.Endpoint<better_call.Handler<string, better_call.EndpointOptions, {
29
+ session: {
30
+ session: {
31
+ id: string;
32
+ userId: string;
33
+ expiresAt: Date;
34
+ ipAddress?: string | undefined;
35
+ userAgent?: string | undefined;
36
+ };
37
+ user: {
38
+ id: string;
39
+ name: string;
40
+ email: string;
41
+ emailVerified: boolean;
42
+ createdAt: Date;
43
+ updatedAt: Date;
44
+ image?: string | undefined;
45
+ };
46
+ };
47
+ }>, better_call.EndpointOptions>[];
48
+ }> | undefined): Promise<{
49
+ status: boolean;
50
+ }>;
51
+ path: "/two-factor/enable";
52
+ options: {
53
+ method: "POST";
54
+ use: better_call.Endpoint<better_call.Handler<string, better_call.EndpointOptions, {
55
+ session: {
56
+ session: {
57
+ id: string;
58
+ userId: string;
59
+ expiresAt: Date;
60
+ ipAddress?: string | undefined;
61
+ userAgent?: string | undefined;
62
+ };
63
+ user: {
64
+ id: string;
65
+ name: string;
66
+ email: string;
67
+ emailVerified: boolean;
68
+ createdAt: Date;
69
+ updatedAt: Date;
70
+ image?: string | undefined;
71
+ };
72
+ };
73
+ }>, better_call.EndpointOptions>[];
74
+ };
75
+ method: better_call.Method | better_call.Method[];
76
+ headers: Headers;
77
+ };
78
+ disableTwoFactor: {
79
+ (ctx_0?: better_call.Context<"/two-factor/disable", {
80
+ method: "POST";
81
+ use: better_call.Endpoint<better_call.Handler<string, better_call.EndpointOptions, {
82
+ session: {
83
+ session: {
84
+ id: string;
85
+ userId: string;
86
+ expiresAt: Date;
87
+ ipAddress?: string | undefined;
88
+ userAgent?: string | undefined;
89
+ };
90
+ user: {
91
+ id: string;
92
+ name: string;
93
+ email: string;
94
+ emailVerified: boolean;
95
+ createdAt: Date;
96
+ updatedAt: Date;
97
+ image?: string | undefined;
98
+ };
99
+ };
100
+ }>, better_call.EndpointOptions>[];
101
+ }> | undefined): Promise<{
102
+ status: boolean;
103
+ }>;
104
+ path: "/two-factor/disable";
105
+ options: {
106
+ method: "POST";
107
+ use: better_call.Endpoint<better_call.Handler<string, better_call.EndpointOptions, {
108
+ session: {
109
+ session: {
110
+ id: string;
111
+ userId: string;
112
+ expiresAt: Date;
113
+ ipAddress?: string | undefined;
114
+ userAgent?: string | undefined;
115
+ };
116
+ user: {
117
+ id: string;
118
+ name: string;
119
+ email: string;
120
+ emailVerified: boolean;
121
+ createdAt: Date;
122
+ updatedAt: Date;
123
+ image?: string | undefined;
124
+ };
125
+ };
126
+ }>, better_call.EndpointOptions>[];
127
+ };
128
+ method: better_call.Method | better_call.Method[];
129
+ headers: Headers;
130
+ };
131
+ verifyBackupCode: {
132
+ (ctx_0: better_call.Context<"/two-factor/verify-backup-code", {
133
+ method: "POST";
134
+ body: z.ZodObject<{
135
+ code: z.ZodString;
136
+ }, "strip", z.ZodTypeAny, {
137
+ code: string;
138
+ }, {
139
+ code: string;
140
+ }>;
141
+ use: better_call.Endpoint<better_call.Handler<string, better_call.EndpointOptions, {
142
+ valid: () => Promise<{
143
+ response: {
144
+ body: any;
145
+ status: number;
146
+ statusText: string;
147
+ headers: Record<string, string> | undefined;
148
+ };
149
+ body: {
150
+ status: boolean;
151
+ };
152
+ _flag: "json";
153
+ }>;
154
+ invalid: () => Promise<{
155
+ response: {
156
+ body: any;
157
+ status: number;
158
+ statusText: string;
159
+ headers: Record<string, string> | undefined;
160
+ };
161
+ body: {
162
+ status: boolean;
163
+ };
164
+ _flag: "json";
165
+ }>;
166
+ session: {
167
+ id: string;
168
+ userId: string;
169
+ expiresAt: Date;
170
+ user: UserWithTwoFactor;
171
+ };
172
+ }>, better_call.EndpointOptions>[];
173
+ }>): Promise<{
174
+ status: boolean;
175
+ }>;
176
+ path: "/two-factor/verify-backup-code";
177
+ options: {
178
+ method: "POST";
179
+ body: z.ZodObject<{
180
+ code: z.ZodString;
181
+ }, "strip", z.ZodTypeAny, {
182
+ code: string;
183
+ }, {
184
+ code: string;
185
+ }>;
186
+ use: better_call.Endpoint<better_call.Handler<string, better_call.EndpointOptions, {
187
+ valid: () => Promise<{
188
+ response: {
189
+ body: any;
190
+ status: number;
191
+ statusText: string;
192
+ headers: Record<string, string> | undefined;
193
+ };
194
+ body: {
195
+ status: boolean;
196
+ };
197
+ _flag: "json";
198
+ }>;
199
+ invalid: () => Promise<{
200
+ response: {
201
+ body: any;
202
+ status: number;
203
+ statusText: string;
204
+ headers: Record<string, string> | undefined;
205
+ };
206
+ body: {
207
+ status: boolean;
208
+ };
209
+ _flag: "json";
210
+ }>;
211
+ session: {
212
+ id: string;
213
+ userId: string;
214
+ expiresAt: Date;
215
+ user: UserWithTwoFactor;
216
+ };
217
+ }>, better_call.EndpointOptions>[];
218
+ };
219
+ method: better_call.Method | better_call.Method[];
220
+ headers: Headers;
221
+ };
222
+ generateBackupCodes: {
223
+ (ctx_0?: better_call.Context<"/two-factor/generate-backup-codes", {
224
+ method: "POST";
225
+ use: better_call.Endpoint<better_call.Handler<string, better_call.EndpointOptions, {
226
+ session: {
227
+ session: {
228
+ id: string;
229
+ userId: string;
230
+ expiresAt: Date;
231
+ ipAddress?: string | undefined;
232
+ userAgent?: string | undefined;
233
+ };
234
+ user: {
235
+ id: string;
236
+ name: string;
237
+ email: string;
238
+ emailVerified: boolean;
239
+ createdAt: Date;
240
+ updatedAt: Date;
241
+ image?: string | undefined;
242
+ };
243
+ };
244
+ }>, better_call.EndpointOptions>[];
245
+ }> | undefined): Promise<{
246
+ status: boolean;
247
+ backupCodes: string[];
248
+ }>;
249
+ path: "/two-factor/generate-backup-codes";
250
+ options: {
251
+ method: "POST";
252
+ use: better_call.Endpoint<better_call.Handler<string, better_call.EndpointOptions, {
253
+ session: {
254
+ session: {
255
+ id: string;
256
+ userId: string;
257
+ expiresAt: Date;
258
+ ipAddress?: string | undefined;
259
+ userAgent?: string | undefined;
260
+ };
261
+ user: {
262
+ id: string;
263
+ name: string;
264
+ email: string;
265
+ emailVerified: boolean;
266
+ createdAt: Date;
267
+ updatedAt: Date;
268
+ image?: string | undefined;
269
+ };
270
+ };
271
+ }>, better_call.EndpointOptions>[];
272
+ };
273
+ method: better_call.Method | better_call.Method[];
274
+ headers: Headers;
275
+ };
276
+ viewBackupCodes: {
277
+ (ctx_0?: better_call.Context<"/view/backup-codes", {
278
+ method: "GET";
279
+ use: better_call.Endpoint<better_call.Handler<string, better_call.EndpointOptions, {
280
+ session: {
281
+ session: {
282
+ id: string;
283
+ userId: string;
284
+ expiresAt: Date;
285
+ ipAddress?: string | undefined;
286
+ userAgent?: string | undefined;
287
+ };
288
+ user: {
289
+ id: string;
290
+ name: string;
291
+ email: string;
292
+ emailVerified: boolean;
293
+ createdAt: Date;
294
+ updatedAt: Date;
295
+ image?: string | undefined;
296
+ };
297
+ };
298
+ }>, better_call.EndpointOptions>[];
299
+ }> | undefined): Promise<{
300
+ status: boolean;
301
+ backupCodes: Promise<string[] | null>;
302
+ }>;
303
+ path: "/view/backup-codes";
304
+ options: {
305
+ method: "GET";
306
+ use: better_call.Endpoint<better_call.Handler<string, better_call.EndpointOptions, {
307
+ session: {
308
+ session: {
309
+ id: string;
310
+ userId: string;
311
+ expiresAt: Date;
312
+ ipAddress?: string | undefined;
313
+ userAgent?: string | undefined;
314
+ };
315
+ user: {
316
+ id: string;
317
+ name: string;
318
+ email: string;
319
+ emailVerified: boolean;
320
+ createdAt: Date;
321
+ updatedAt: Date;
322
+ image?: string | undefined;
323
+ };
324
+ };
325
+ }>, better_call.EndpointOptions>[];
326
+ };
327
+ method: better_call.Method | better_call.Method[];
328
+ headers: Headers;
329
+ };
330
+ send2FaOTP: {
331
+ (ctx_0?: better_call.Context<"/two-factor/send-otp", {
332
+ method: "POST";
333
+ use: better_call.Endpoint<better_call.Handler<string, better_call.EndpointOptions, {
334
+ valid: () => Promise<{
335
+ response: {
336
+ body: any;
337
+ status: number;
338
+ statusText: string;
339
+ headers: Record<string, string> | undefined;
340
+ };
341
+ body: {
342
+ status: boolean;
343
+ };
344
+ _flag: "json";
345
+ }>;
346
+ invalid: () => Promise<{
347
+ response: {
348
+ body: any;
349
+ status: number;
350
+ statusText: string;
351
+ headers: Record<string, string> | undefined;
352
+ };
353
+ body: {
354
+ status: boolean;
355
+ };
356
+ _flag: "json";
357
+ }>;
358
+ session: {
359
+ id: string;
360
+ userId: string;
361
+ expiresAt: Date;
362
+ user: UserWithTwoFactor;
363
+ };
364
+ }>, better_call.EndpointOptions>[];
365
+ }> | undefined): Promise<{
366
+ status: boolean;
367
+ }>;
368
+ path: "/two-factor/send-otp";
369
+ options: {
370
+ method: "POST";
371
+ use: better_call.Endpoint<better_call.Handler<string, better_call.EndpointOptions, {
372
+ valid: () => Promise<{
373
+ response: {
374
+ body: any;
375
+ status: number;
376
+ statusText: string;
377
+ headers: Record<string, string> | undefined;
378
+ };
379
+ body: {
380
+ status: boolean;
381
+ };
382
+ _flag: "json";
383
+ }>;
384
+ invalid: () => Promise<{
385
+ response: {
386
+ body: any;
387
+ status: number;
388
+ statusText: string;
389
+ headers: Record<string, string> | undefined;
390
+ };
391
+ body: {
392
+ status: boolean;
393
+ };
394
+ _flag: "json";
395
+ }>;
396
+ session: {
397
+ id: string;
398
+ userId: string;
399
+ expiresAt: Date;
400
+ user: UserWithTwoFactor;
401
+ };
402
+ }>, better_call.EndpointOptions>[];
403
+ };
404
+ method: better_call.Method | better_call.Method[];
405
+ headers: Headers;
406
+ };
407
+ verifyOTP: {
408
+ (ctx_0: better_call.Context<"/two-factor/verify-otp", {
409
+ method: "POST";
410
+ body: z.ZodObject<{
411
+ code: z.ZodString;
412
+ }, "strip", z.ZodTypeAny, {
413
+ code: string;
414
+ }, {
415
+ code: string;
416
+ }>;
417
+ use: better_call.Endpoint<better_call.Handler<string, better_call.EndpointOptions, {
418
+ valid: () => Promise<{
419
+ response: {
420
+ body: any;
421
+ status: number;
422
+ statusText: string;
423
+ headers: Record<string, string> | undefined;
424
+ };
425
+ body: {
426
+ status: boolean;
427
+ };
428
+ _flag: "json";
429
+ }>;
430
+ invalid: () => Promise<{
431
+ response: {
432
+ body: any;
433
+ status: number;
434
+ statusText: string;
435
+ headers: Record<string, string> | undefined;
436
+ };
437
+ body: {
438
+ status: boolean;
439
+ };
440
+ _flag: "json";
441
+ }>;
442
+ session: {
443
+ id: string;
444
+ userId: string;
445
+ expiresAt: Date;
446
+ user: UserWithTwoFactor;
447
+ };
448
+ }>, better_call.EndpointOptions>[];
449
+ }>): Promise<{
450
+ status: boolean;
451
+ }>;
452
+ path: "/two-factor/verify-otp";
453
+ options: {
454
+ method: "POST";
455
+ body: z.ZodObject<{
456
+ code: z.ZodString;
457
+ }, "strip", z.ZodTypeAny, {
458
+ code: string;
459
+ }, {
460
+ code: string;
461
+ }>;
462
+ use: better_call.Endpoint<better_call.Handler<string, better_call.EndpointOptions, {
463
+ valid: () => Promise<{
464
+ response: {
465
+ body: any;
466
+ status: number;
467
+ statusText: string;
468
+ headers: Record<string, string> | undefined;
469
+ };
470
+ body: {
471
+ status: boolean;
472
+ };
473
+ _flag: "json";
474
+ }>;
475
+ invalid: () => Promise<{
476
+ response: {
477
+ body: any;
478
+ status: number;
479
+ statusText: string;
480
+ headers: Record<string, string> | undefined;
481
+ };
482
+ body: {
483
+ status: boolean;
484
+ };
485
+ _flag: "json";
486
+ }>;
487
+ session: {
488
+ id: string;
489
+ userId: string;
490
+ expiresAt: Date;
491
+ user: UserWithTwoFactor;
492
+ };
493
+ }>, better_call.EndpointOptions>[];
494
+ };
495
+ method: better_call.Method | better_call.Method[];
496
+ headers: Headers;
497
+ };
498
+ generateTOTP: {
499
+ (ctx_0?: better_call.Context<"/totp/generate", {
500
+ method: "POST";
501
+ use: better_call.Endpoint<better_call.Handler<string, better_call.EndpointOptions, {
502
+ session: {
503
+ session: {
504
+ id: string;
505
+ userId: string;
506
+ expiresAt: Date;
507
+ ipAddress?: string | undefined;
508
+ userAgent?: string | undefined;
509
+ };
510
+ user: {
511
+ id: string;
512
+ name: string;
513
+ email: string;
514
+ emailVerified: boolean;
515
+ createdAt: Date;
516
+ updatedAt: Date;
517
+ image?: string | undefined;
518
+ };
519
+ };
520
+ }>, better_call.EndpointOptions>[];
521
+ }> | undefined): Promise<{
522
+ code: string;
523
+ }>;
524
+ path: "/totp/generate";
525
+ options: {
526
+ method: "POST";
527
+ use: better_call.Endpoint<better_call.Handler<string, better_call.EndpointOptions, {
528
+ session: {
529
+ session: {
530
+ id: string;
531
+ userId: string;
532
+ expiresAt: Date;
533
+ ipAddress?: string | undefined;
534
+ userAgent?: string | undefined;
535
+ };
536
+ user: {
537
+ id: string;
538
+ name: string;
539
+ email: string;
540
+ emailVerified: boolean;
541
+ createdAt: Date;
542
+ updatedAt: Date;
543
+ image?: string | undefined;
544
+ };
545
+ };
546
+ }>, better_call.EndpointOptions>[];
547
+ };
548
+ method: better_call.Method | better_call.Method[];
549
+ headers: Headers;
550
+ };
551
+ viewTOTPURI: {
552
+ (ctx_0?: better_call.Context<"/two-factor/get-totp-uri", {
553
+ method: "GET";
554
+ use: better_call.Endpoint<better_call.Handler<string, better_call.EndpointOptions, {
555
+ session: {
556
+ session: {
557
+ id: string;
558
+ userId: string;
559
+ expiresAt: Date;
560
+ ipAddress?: string | undefined;
561
+ userAgent?: string | undefined;
562
+ };
563
+ user: {
564
+ id: string;
565
+ name: string;
566
+ email: string;
567
+ emailVerified: boolean;
568
+ createdAt: Date;
569
+ updatedAt: Date;
570
+ image?: string | undefined;
571
+ };
572
+ };
573
+ }>, better_call.EndpointOptions>[];
574
+ }> | undefined): Promise<{
575
+ totpURI: string;
576
+ }>;
577
+ path: "/two-factor/get-totp-uri";
578
+ options: {
579
+ method: "GET";
580
+ use: better_call.Endpoint<better_call.Handler<string, better_call.EndpointOptions, {
581
+ session: {
582
+ session: {
583
+ id: string;
584
+ userId: string;
585
+ expiresAt: Date;
586
+ ipAddress?: string | undefined;
587
+ userAgent?: string | undefined;
588
+ };
589
+ user: {
590
+ id: string;
591
+ name: string;
592
+ email: string;
593
+ emailVerified: boolean;
594
+ createdAt: Date;
595
+ updatedAt: Date;
596
+ image?: string | undefined;
597
+ };
598
+ };
599
+ }>, better_call.EndpointOptions>[];
600
+ };
601
+ method: better_call.Method | better_call.Method[];
602
+ headers: Headers;
603
+ };
604
+ verifyTOTP: {
605
+ (ctx_0: better_call.Context<"/two-factor/verify-totp", {
606
+ method: "POST";
607
+ body: z.ZodObject<{
608
+ code: z.ZodString;
609
+ callbackURL: z.ZodOptional<z.ZodString>;
610
+ }, "strip", z.ZodTypeAny, {
611
+ code: string;
612
+ callbackURL?: string | undefined;
613
+ }, {
614
+ code: string;
615
+ callbackURL?: string | undefined;
616
+ }>;
617
+ use: better_call.Endpoint<better_call.Handler<string, better_call.EndpointOptions, {
618
+ valid: () => Promise<{
619
+ response: {
620
+ body: any;
621
+ status: number;
622
+ statusText: string;
623
+ headers: Record<string, string> | undefined;
624
+ };
625
+ body: {
626
+ status: boolean;
627
+ };
628
+ _flag: "json";
629
+ }>;
630
+ invalid: () => Promise<{
631
+ response: {
632
+ body: any;
633
+ status: number;
634
+ statusText: string;
635
+ headers: Record<string, string> | undefined;
636
+ };
637
+ body: {
638
+ status: boolean;
639
+ };
640
+ _flag: "json";
641
+ }>;
642
+ session: {
643
+ id: string;
644
+ userId: string;
645
+ expiresAt: Date;
646
+ user: UserWithTwoFactor;
647
+ };
648
+ }>, better_call.EndpointOptions>[];
649
+ }>): Promise<{
650
+ status: boolean;
651
+ }>;
652
+ path: "/two-factor/verify-totp";
653
+ options: {
654
+ method: "POST";
655
+ body: z.ZodObject<{
656
+ code: z.ZodString;
657
+ callbackURL: z.ZodOptional<z.ZodString>;
658
+ }, "strip", z.ZodTypeAny, {
659
+ code: string;
660
+ callbackURL?: string | undefined;
661
+ }, {
662
+ code: string;
663
+ callbackURL?: string | undefined;
664
+ }>;
665
+ use: better_call.Endpoint<better_call.Handler<string, better_call.EndpointOptions, {
666
+ valid: () => Promise<{
667
+ response: {
668
+ body: any;
669
+ status: number;
670
+ statusText: string;
671
+ headers: Record<string, string> | undefined;
672
+ };
673
+ body: {
674
+ status: boolean;
675
+ };
676
+ _flag: "json";
677
+ }>;
678
+ invalid: () => Promise<{
679
+ response: {
680
+ body: any;
681
+ status: number;
682
+ statusText: string;
683
+ headers: Record<string, string> | undefined;
684
+ };
685
+ body: {
686
+ status: boolean;
687
+ };
688
+ _flag: "json";
689
+ }>;
690
+ session: {
691
+ id: string;
692
+ userId: string;
693
+ expiresAt: Date;
694
+ user: UserWithTwoFactor;
695
+ };
696
+ }>, better_call.EndpointOptions>[];
697
+ };
698
+ method: better_call.Method | better_call.Method[];
699
+ headers: Headers;
700
+ };
34
701
  };
35
- }
702
+ options: O;
703
+ hooks: {
704
+ after: {
705
+ matcher(context: GenericEndpointContext): boolean;
706
+ handler: better_call.Endpoint<better_call.Handler<string, better_call.EndpointOptions, {
707
+ response: Response;
708
+ } | undefined>, better_call.EndpointOptions>;
709
+ }[];
710
+ };
711
+ schema: {
712
+ user: {
713
+ fields: {
714
+ twoFactorEnabled: {
715
+ type: "boolean";
716
+ required: false;
717
+ defaultValue: false;
718
+ };
719
+ twoFactorSecret: {
720
+ type: "string";
721
+ required: false;
722
+ };
723
+ twoFactorBackupCodes: {
724
+ type: "string";
725
+ required: false;
726
+ returned: false;
727
+ };
728
+ };
729
+ };
730
+ };
731
+ };
732
+
733
+ declare const username: () => {
734
+ id: "username";
735
+ endpoints: {
736
+ signInUsername: {
737
+ (ctx_0: better_call.Context<"/sign-in/username", {
738
+ method: "POST";
739
+ body: z.ZodObject<{
740
+ username: z.ZodString;
741
+ password: z.ZodString;
742
+ dontRememberMe: z.ZodOptional<z.ZodBoolean>;
743
+ callbackURL: z.ZodOptional<z.ZodString>;
744
+ }, "strip", z.ZodTypeAny, {
745
+ password: string;
746
+ username: string;
747
+ callbackURL?: string | undefined;
748
+ dontRememberMe?: boolean | undefined;
749
+ }, {
750
+ password: string;
751
+ username: string;
752
+ callbackURL?: string | undefined;
753
+ dontRememberMe?: boolean | undefined;
754
+ }>;
755
+ }>): Promise<{
756
+ user: {
757
+ id: string;
758
+ name: string;
759
+ email: string;
760
+ emailVerified: boolean;
761
+ createdAt: Date;
762
+ updatedAt: Date;
763
+ image?: string | undefined;
764
+ };
765
+ session: {
766
+ id: string;
767
+ userId: string;
768
+ expiresAt: Date;
769
+ ipAddress?: string | undefined;
770
+ userAgent?: string | undefined;
771
+ };
772
+ redirect: boolean;
773
+ url: string | undefined;
774
+ }>;
775
+ path: "/sign-in/username";
776
+ options: {
777
+ method: "POST";
778
+ body: z.ZodObject<{
779
+ username: z.ZodString;
780
+ password: z.ZodString;
781
+ dontRememberMe: z.ZodOptional<z.ZodBoolean>;
782
+ callbackURL: z.ZodOptional<z.ZodString>;
783
+ }, "strip", z.ZodTypeAny, {
784
+ password: string;
785
+ username: string;
786
+ callbackURL?: string | undefined;
787
+ dontRememberMe?: boolean | undefined;
788
+ }, {
789
+ password: string;
790
+ username: string;
791
+ callbackURL?: string | undefined;
792
+ dontRememberMe?: boolean | undefined;
793
+ }>;
794
+ };
795
+ method: better_call.Method | better_call.Method[];
796
+ headers: Headers;
797
+ };
798
+ signUpUsername: {
799
+ (ctx_0: better_call.Context<"/sign-up/username", {
800
+ method: "POST";
801
+ body: z.ZodObject<{
802
+ username: z.ZodString;
803
+ name: z.ZodString;
804
+ email: z.ZodString;
805
+ password: z.ZodString;
806
+ image: z.ZodOptional<z.ZodString>;
807
+ callbackURL: z.ZodOptional<z.ZodString>;
808
+ }, "strip", z.ZodTypeAny, {
809
+ password: string;
810
+ name: string;
811
+ email: string;
812
+ username: string;
813
+ image?: string | undefined;
814
+ callbackURL?: string | undefined;
815
+ }, {
816
+ password: string;
817
+ name: string;
818
+ email: string;
819
+ username: string;
820
+ image?: string | undefined;
821
+ callbackURL?: string | undefined;
822
+ }>;
823
+ }>): Promise<{
824
+ user: {
825
+ id: string;
826
+ name: string;
827
+ email: string;
828
+ emailVerified: boolean;
829
+ createdAt: Date;
830
+ updatedAt: Date;
831
+ image?: string | undefined;
832
+ };
833
+ session: {
834
+ id: string;
835
+ userId: string;
836
+ expiresAt: Date;
837
+ ipAddress?: string | undefined;
838
+ userAgent?: string | undefined;
839
+ };
840
+ } | null>;
841
+ path: "/sign-up/username";
842
+ options: {
843
+ method: "POST";
844
+ body: z.ZodObject<{
845
+ username: z.ZodString;
846
+ name: z.ZodString;
847
+ email: z.ZodString;
848
+ password: z.ZodString;
849
+ image: z.ZodOptional<z.ZodString>;
850
+ callbackURL: z.ZodOptional<z.ZodString>;
851
+ }, "strip", z.ZodTypeAny, {
852
+ password: string;
853
+ name: string;
854
+ email: string;
855
+ username: string;
856
+ image?: string | undefined;
857
+ callbackURL?: string | undefined;
858
+ }, {
859
+ password: string;
860
+ name: string;
861
+ email: string;
862
+ username: string;
863
+ image?: string | undefined;
864
+ callbackURL?: string | undefined;
865
+ }>;
866
+ };
867
+ method: better_call.Method | better_call.Method[];
868
+ headers: Headers;
869
+ };
870
+ };
871
+ schema: {
872
+ user: {
873
+ fields: {
874
+ username: {
875
+ type: "string";
876
+ required: false;
877
+ unique: true;
878
+ returned: true;
879
+ };
880
+ };
881
+ };
882
+ };
883
+ };
884
+
36
885
  /**
37
- * Email verification plugin. This plugin will send an email
38
- * to the user with a token to verify the email on sign up.
886
+ * Converts bearer token to session cookie
39
887
  */
40
- declare const emailVerification: (opts: EmailVerificationOptions) => BetterAuthPlugin;
41
-
42
- declare const getPlugins: (options: BetterAuthOptions) => BetterAuthPlugin[];
43
- declare const usePlugins: (context: Context, ignorePlugins?: string[]) => {
44
- before: (context: Context) => Promise<{
45
- context: Context;
46
- response: InternalResponse | undefined;
47
- }>;
48
- after: (context: Context, fnResponse: InternalResponse) => Promise<{
49
- context: Context;
50
- response: InternalResponse | undefined;
51
- }>;
888
+ declare const bearer: () => {
889
+ id: "bearer";
890
+ hooks: {
891
+ before: {
892
+ matcher(context: GenericEndpointContext): boolean;
893
+ handler: (ctx: GenericEndpointContext) => Promise<void>;
894
+ }[];
895
+ };
52
896
  };
53
- declare const withPlugins: <T extends GenericHandler<any, any, any>>(fn: T, ignorePlugins?: string[]) => (ctx: Parameters<T>["0"]) => Promise<InternalResponse | ReturnType<T>>;
54
897
 
55
- export { BetterAuthPlugin, emailVerification, getPlugins, usePlugins, withPlugins };
898
+ export { bearer, twoFactor, username };