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
@@ -1,1562 +0,0 @@
1
- import { A as Adapter, c as Session, U as User, d as Account, S as SessionAdapter, F as FieldAttributes, I as InternalFieldAttributes } from './types-DAxaMWCy.js';
2
- import { z, ZodSchema } from 'zod';
3
-
4
- interface CookieSerializeOptions {
5
- /**
6
- * Specifies the value for the {@link https://tools.ietf.org/html/rfc6265#section-5.2.3|Domain Set-Cookie attribute}. By default, no
7
- * domain is set, and most clients will consider the cookie to apply to only
8
- * the current domain.
9
- */
10
- domain?: string | undefined;
11
- /**
12
- * Specifies a function that will be used to encode a cookie's value. Since
13
- * value of a cookie has a limited character set (and must be a simple
14
- * string), this function can be used to encode a value into a string suited
15
- * for a cookie's value.
16
- *
17
- * The default function is the global `encodeURIComponent`, which will
18
- * encode a JavaScript string into UTF-8 byte sequences and then URL-encode
19
- * any that fall outside of the cookie range.
20
- */
21
- encode?(value: string): string;
22
- /**
23
- * Specifies the `Date` object to be the value for the {@link https://tools.ietf.org/html/rfc6265#section-5.2.1|`Expires` `Set-Cookie` attribute}. By default,
24
- * no expiration is set, and most clients will consider this a "non-persistent cookie" and will delete
25
- * it on a condition like exiting a web browser application.
26
- *
27
- * *Note* the {@link https://tools.ietf.org/html/rfc6265#section-5.3|cookie storage model specification}
28
- * states that if both `expires` and `maxAge` are set, then `maxAge` takes precedence, but it is
29
- * possible not all clients by obey this, so if both are set, they should
30
- * point to the same date and time.
31
- */
32
- expires?: Date | undefined;
33
- /**
34
- * Specifies the boolean value for the {@link https://tools.ietf.org/html/rfc6265#section-5.2.6|`HttpOnly` `Set-Cookie` attribute}.
35
- * When truthy, the `HttpOnly` attribute is set, otherwise it is not. By
36
- * default, the `HttpOnly` attribute is not set.
37
- *
38
- * *Note* be careful when setting this to true, as compliant clients will
39
- * not allow client-side JavaScript to see the cookie in `document.cookie`.
40
- */
41
- httpOnly?: boolean | undefined;
42
- /**
43
- * Specifies the number (in seconds) to be the value for the `Max-Age`
44
- * `Set-Cookie` attribute. The given number will be converted to an integer
45
- * by rounding down. By default, no maximum age is set.
46
- *
47
- * *Note* the {@link https://tools.ietf.org/html/rfc6265#section-5.3|cookie storage model specification}
48
- * states that if both `expires` and `maxAge` are set, then `maxAge` takes precedence, but it is
49
- * possible not all clients by obey this, so if both are set, they should
50
- * point to the same date and time.
51
- */
52
- maxAge?: number | undefined;
53
- /**
54
- * Specifies the value for the {@link https://tools.ietf.org/html/rfc6265#section-5.2.4|`Path` `Set-Cookie` attribute}.
55
- * By default, the path is considered the "default path".
56
- */
57
- path?: string | undefined;
58
- /**
59
- * Specifies the `string` to be the value for the [`Priority` `Set-Cookie` attribute][rfc-west-cookie-priority-00-4.1].
60
- *
61
- * - `'low'` will set the `Priority` attribute to `Low`.
62
- * - `'medium'` will set the `Priority` attribute to `Medium`, the default priority when not set.
63
- * - `'high'` will set the `Priority` attribute to `High`.
64
- *
65
- * More information about the different priority levels can be found in
66
- * [the specification][rfc-west-cookie-priority-00-4.1].
67
- *
68
- * **note** This is an attribute that has not yet been fully standardized, and may change in the future.
69
- * This also means many clients may ignore this attribute until they understand it.
70
- */
71
- priority?: "low" | "medium" | "high" | undefined;
72
- /**
73
- * Specifies the boolean or string to be the value for the {@link https://tools.ietf.org/html/draft-ietf-httpbis-rfc6265bis-03#section-4.1.2.7|`SameSite` `Set-Cookie` attribute}.
74
- *
75
- * - `true` will set the `SameSite` attribute to `Strict` for strict same
76
- * site enforcement.
77
- * - `false` will not set the `SameSite` attribute.
78
- * - `'lax'` will set the `SameSite` attribute to Lax for lax same site
79
- * enforcement.
80
- * - `'strict'` will set the `SameSite` attribute to Strict for strict same
81
- * site enforcement.
82
- * - `'none'` will set the SameSite attribute to None for an explicit
83
- * cross-site cookie.
84
- *
85
- * More information about the different enforcement levels can be found in {@link https://tools.ietf.org/html/draft-ietf-httpbis-rfc6265bis-03#section-4.1.2.7|the specification}.
86
- *
87
- * *note* This is an attribute that has not yet been fully standardized, and may change in the future. This also means many clients may ignore this attribute until they understand it.
88
- */
89
- sameSite?: true | false | "lax" | "strict" | "none" | undefined;
90
- /**
91
- * Specifies the boolean value for the {@link https://tools.ietf.org/html/rfc6265#section-5.2.5|`Secure` `Set-Cookie` attribute}. When truthy, the
92
- * `Secure` attribute is set, otherwise it is not. By default, the `Secure` attribute is not set.
93
- *
94
- * *Note* be careful when setting this to `true`, as compliant clients will
95
- * not send the cookie back to the server in the future if the browser does
96
- * not have an HTTPS connection.
97
- */
98
- secure?: boolean | undefined;
99
- /**
100
- * Specifies the `boolean` value for the [`Partitioned` `Set-Cookie`](rfc-cutler-httpbis-partitioned-cookies)
101
- * attribute. When truthy, the `Partitioned` attribute is set, otherwise it is not. By default, the
102
- * `Partitioned` attribute is not set.
103
- *
104
- * **note** This is an attribute that has not yet been fully standardized, and may change in the future.
105
- * This also means many clients may ignore this attribute until they understand it.
106
- *
107
- * More information about can be found in [the proposal](https://github.com/privacycg/CHIPS)
108
- */
109
- partitioned?: boolean;
110
- }
111
-
112
- declare const cookieManager: (header: Headers) => CookieManager;
113
- type CookieManager = {
114
- set: (name: string, value: string, options?: CookieSerializeOptions) => void;
115
- get: (name: string) => string | null | undefined;
116
- };
117
-
118
- interface BetterAuthPlugin {
119
- /**
120
- * The unique identifier of the plugin.
121
- * This will be used to redirect requests that starts with
122
- * the plugin id.
123
- */
124
- id: string;
125
- /**
126
- * The name of the plugin.
127
- */
128
- name: string;
129
- /**
130
- * The version of the plugin.
131
- */
132
- version: string;
133
- /**
134
- * The handler of the plugin. This will be the main
135
- * function that will be called if the request matches the
136
- * plugin id.
137
- */
138
- handler?: GenericHandler;
139
- /**
140
- * Handler hooks
141
- */
142
- hooks?: HandlerHooks;
143
- /**
144
- * If the hook should be executed before or after
145
- * better-auth internal plugins.
146
- */
147
- order?: "pre" | "post" | null;
148
- getActions?: (options: BetterAuthOptions) => {
149
- [key: string]: (request: Request | Headers, input: any) => any;
150
- };
151
- getClient?: () => {
152
- [key: string]: (input: any) => any;
153
- };
154
- options?: any;
155
- }
156
- type BeforeHookHandler<T extends Context = Context> = (ctx: T) => Promise<{
157
- response?: InternalResponse;
158
- context?: Context;
159
- } | undefined | null>;
160
- type AfterHookHandler<T extends Context = Context> = (
161
- /**
162
- * The context of the request.
163
- */
164
- ctx: T,
165
- /**
166
- * The response from the main function.
167
- */
168
- response: InternalResponse) => Promise<{
169
- response?: InternalResponse;
170
- context?: Context;
171
- } | undefined | null>;
172
-
173
- type InternalRequest<T, Q> = {
174
- cookies: ReturnType<typeof cookieManager>;
175
- method: string;
176
- body: T;
177
- query: Q;
178
- headers: Headers;
179
- url: URL;
180
- action: Omit<string, BetterAuthActions> | BetterAuthActions;
181
- };
182
- type Body = Record<string, any> | string | null;
183
- type InternalResponse<T extends Body = any> = {
184
- status: number;
185
- statusText?: string;
186
- body?: T;
187
- headers?: Record<string, any>;
188
- /**
189
- * Metadata for use in plugins.
190
- */
191
- metadata?: {
192
- isError?: boolean;
193
- };
194
- };
195
- type Context<B = any, Q = any> = {
196
- request: InternalRequest<B, Q>;
197
- } & InternalOptions;
198
- type GenericHandler<T = any, R extends Body = any, C extends Context = Context> = (ctx: Context<T> & C) => Promise<InternalResponse<R>>;
199
- type BetterAuthActions = "signin" | "signup" | "signout" | "callback" | "session";
200
- interface HandlerHooks {
201
- /**
202
- * A matcher. A hook will be added to an action if the
203
- * matcher returns true.
204
- */
205
- matcher: (context: Context) => boolean;
206
- /**
207
- * A function that gets executed either before
208
- * the main function. If the function returns a result,
209
- * that result will be the output of the main function.
210
- * If the function returns context, that context will be
211
- * passed to the main function. If the function returns
212
- * null or undefined, the main function will be executed
213
- * with the original context.
214
- */
215
- before?: BeforeHookHandler;
216
- /**
217
- * A function that gets executed after the main function.
218
- * If the function returns a result, that result will be
219
- * the output of the main function.
220
- * If the function returns context, that context will be
221
- * passed to the main function. If the function returns
222
- * null or undefined, the main function will be executed
223
- * with the original context.
224
- */
225
- after?: AfterHookHandler;
226
- }
227
- interface CookieOptions {
228
- expires?: Date;
229
- maxAge?: number;
230
- domain?: string;
231
- path?: string;
232
- secure?: boolean;
233
- httpOnly?: boolean;
234
- sameSite?: string;
235
- }
236
-
237
- declare const createInternalAdapter: (db: Adapter) => {
238
- createSession: (userId: string, context: Context) => Promise<Session>;
239
- updateSession: (session: Session, context: Context) => Promise<Session>;
240
- deleteSession: (id: string, context: Context) => Promise<Session>;
241
- createUser: (data: {
242
- user: Record<string, any>;
243
- account: {
244
- providerId: string;
245
- accountId: string;
246
- [key: string]: any;
247
- };
248
- }, context: Context) => Promise<{
249
- user: User;
250
- account: Account;
251
- }>;
252
- updateUserByEmail: (email: string, data: Record<string, any>, context: Context) => Promise<User>;
253
- findUserByEmail: (email: string, context: Context) => Promise<User | null>;
254
- findSession: (id: string, context: Context) => Promise<Session | null>;
255
- findUserById: (id: string, context: Context) => Promise<User | null>;
256
- findAccount: (input: {
257
- providerId: string;
258
- accountId: string;
259
- }, context: Context) => Promise<Account | null>;
260
- linkAccount: (input: {
261
- userId: string;
262
- providerId: string;
263
- accountId: string;
264
- }, context: Context) => Promise<Account>;
265
- };
266
- type InternalAdapter$1 = ReturnType<typeof createInternalAdapter>;
267
-
268
- declare function getCookies(options: BetterAuthOptions): {
269
- sessionToken: {
270
- name: string;
271
- options: {
272
- domain?: string | undefined;
273
- encode?: ((value: string) => string) | undefined;
274
- expires?: Date | undefined;
275
- httpOnly: boolean;
276
- maxAge: number;
277
- path: string;
278
- priority?: "low" | "medium" | "high" | undefined;
279
- sameSite: boolean | "lax" | "strict" | "none";
280
- secure: boolean;
281
- partitioned?: boolean | undefined;
282
- };
283
- };
284
- csrfToken: {
285
- name: string;
286
- options: {
287
- httpOnly: true;
288
- sameSite: "lax";
289
- path: string;
290
- secure: boolean;
291
- };
292
- };
293
- state: {
294
- name: string;
295
- options: {
296
- httpOnly: true;
297
- sameSite: "lax";
298
- path: string;
299
- secure: boolean;
300
- maxAge: number;
301
- };
302
- };
303
- pkCodeVerifier: {
304
- name: string;
305
- options: CookieSerializeOptions;
306
- };
307
- nonce: {
308
- name: string;
309
- options: CookieSerializeOptions;
310
- };
311
- };
312
-
313
- declare const signUpSchema: z.ZodObject<{
314
- data: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
315
- provider: z.ZodString;
316
- currentURL: z.ZodString;
317
- callbackURL: z.ZodOptional<z.ZodString>;
318
- autoCreateSession: z.ZodOptional<z.ZodBoolean>;
319
- }, "strip", z.ZodTypeAny, {
320
- provider: string;
321
- currentURL: string;
322
- callbackURL?: string | undefined;
323
- data?: Record<string, any> | undefined;
324
- autoCreateSession?: boolean | undefined;
325
- }, {
326
- provider: string;
327
- currentURL: string;
328
- callbackURL?: string | undefined;
329
- data?: Record<string, any> | undefined;
330
- autoCreateSession?: boolean | undefined;
331
- }>;
332
- type SignUpContext = Context<z.infer<typeof signUpSchema>>;
333
-
334
- interface AppleProfile {
335
- /**
336
- * The subject registered claim identifies the principal that’s the subject
337
- * of the identity token. Because this token is for your app, the value is
338
- * the unique identifier for the user.
339
- */
340
- sub: string;
341
- /**
342
- * A String value representing the user's email address.
343
- * The email address is either the user's real email address or the proxy
344
- * address, depending on their status private email relay service.
345
- */
346
- email: string;
347
- /**
348
- * A string or Boolean value that indicates whether the service verifies
349
- * the email. The value can either be a string ("true" or "false") or a
350
- * Boolean (true or false). The system may not verify email addresses for
351
- * Sign in with Apple at Work & School users, and this claim is "false" or
352
- * false for those users.
353
- */
354
- email_verified: true | "true";
355
- /**
356
- * A string or Boolean value that indicates whether the email that the user
357
- * shares is the proxy address. The value can either be a string ("true" or
358
- * "false") or a Boolean (true or false).
359
- */
360
- is_private_email: boolean;
361
- /**
362
- * An Integer value that indicates whether the user appears to be a real
363
- * person. Use the value of this claim to mitigate fraud. The possible
364
- * values are: 0 (or Unsupported), 1 (or Unknown), 2 (or LikelyReal). For
365
- * more information, see ASUserDetectionStatus. This claim is present only
366
- * in iOS 14 and later, macOS 11 and later, watchOS 7 and later, tvOS 14
367
- * and later. The claim isn’t present or supported for web-based apps.
368
- */
369
- real_user_status: number;
370
- /**
371
- * The user’s full name in the format provided during the authorization
372
- * process.
373
- */
374
- name: string;
375
- }
376
- interface AppleOption extends ProviderOptions<AppleProfile> {
377
- }
378
- declare const apple: (options: AppleOption) => {
379
- id: "apple";
380
- name: string;
381
- type: "oidc";
382
- params: {
383
- authorizationEndpoint: string;
384
- tokenEndpoint: string;
385
- linkAccounts: {
386
- field: string;
387
- key: keyof AppleProfile;
388
- enabler?: ((profile: AppleProfile) => boolean | Promise<boolean>) | undefined;
389
- } | undefined;
390
- redirectURL: string | undefined;
391
- clientId: string;
392
- clientSecret: string;
393
- };
394
- issuer: string;
395
- scopes: string[];
396
- getUserInfo(tokens: {
397
- accessToken: string;
398
- id_token: string;
399
- refresh_token?: string | undefined;
400
- expires_in?: number | undefined;
401
- }): Promise<{
402
- id: string;
403
- email: string;
404
- emailVerified: boolean;
405
- /**
406
- * The subject registered claim identifies the principal that’s the subject
407
- * of the identity token. Because this token is for your app, the value is
408
- * the unique identifier for the user.
409
- */
410
- sub: string;
411
- /**
412
- * A string or Boolean value that indicates whether the service verifies
413
- * the email. The value can either be a string ("true" or "false") or a
414
- * Boolean (true or false). The system may not verify email addresses for
415
- * Sign in with Apple at Work & School users, and this claim is "false" or
416
- * false for those users.
417
- */
418
- email_verified: true | "true";
419
- /**
420
- * A string or Boolean value that indicates whether the email that the user
421
- * shares is the proxy address. The value can either be a string ("true" or
422
- * "false") or a Boolean (true or false).
423
- */
424
- is_private_email: boolean;
425
- /**
426
- * An Integer value that indicates whether the user appears to be a real
427
- * person. Use the value of this claim to mitigate fraud. The possible
428
- * values are: 0 (or Unsupported), 1 (or Unknown), 2 (or LikelyReal). For
429
- * more information, see ASUserDetectionStatus. This claim is present only
430
- * in iOS 14 and later, macOS 11 and later, watchOS 7 and later, tvOS 14
431
- * and later. The claim isn’t present or supported for web-based apps.
432
- */
433
- real_user_status: number;
434
- /**
435
- * The user’s full name in the format provided during the authorization
436
- * process.
437
- */
438
- name: string;
439
- }>;
440
- };
441
-
442
- type CredentialOption = {};
443
- /**
444
- * Credential provider for better auth.
445
- * Note: Credential provider only works on node environment.
446
- * It uses argon2 for hashing the password.
447
- */
448
- declare const credential: <O extends CredentialOption>(options?: O) => {
449
- id: "credential";
450
- name: string;
451
- type: "custom";
452
- signIn(context: Context): Promise<{
453
- status: number;
454
- body: {
455
- error: string;
456
- redirect?: undefined;
457
- url?: undefined;
458
- };
459
- } | {
460
- status: number;
461
- body: {
462
- redirect: boolean;
463
- url: string;
464
- error?: undefined;
465
- };
466
- }>;
467
- signUp(context: SignUpContext): Promise<{
468
- status: number;
469
- body: {
470
- error: string;
471
- redirect?: undefined;
472
- url?: undefined;
473
- };
474
- } | {
475
- status: number;
476
- body: {
477
- redirect: boolean;
478
- url: string | undefined;
479
- error?: undefined;
480
- };
481
- }>;
482
- input: z.ZodObject<{
483
- email: z.ZodString;
484
- password: z.ZodString;
485
- }, "strip", z.ZodTypeAny, {
486
- email: string;
487
- password: string;
488
- }, {
489
- email: string;
490
- password: string;
491
- }>;
492
- };
493
-
494
- interface DiscordProfile extends Record<string, any> {
495
- /** the user's id (i.e. the numerical snowflake) */
496
- id: string;
497
- /** the user's username, not unique across the platform */
498
- username: string;
499
- /** the user's Discord-tag */
500
- discriminator: string;
501
- /** the user's display name, if it is set */
502
- global_name: string | null;
503
- /**
504
- * the user's avatar hash:
505
- * https://discord.com/developers/docs/reference#image-formatting
506
- */
507
- avatar: string | null;
508
- /** whether the user belongs to an OAuth2 application */
509
- bot?: boolean;
510
- /**
511
- * whether the user is an Official Discord System user (part of the urgent
512
- * message system)
513
- */
514
- system?: boolean;
515
- /** whether the user has two factor enabled on their account */
516
- mfa_enabled: boolean;
517
- /**
518
- * the user's banner hash:
519
- * https://discord.com/developers/docs/reference#image-formatting
520
- */
521
- banner: string | null;
522
- /** the user's banner color encoded as an integer representation of hexadecimal color code */
523
- accent_color: number | null;
524
- /**
525
- * the user's chosen language option:
526
- * https://discord.com/developers/docs/reference#locales
527
- */
528
- locale: string;
529
- /** whether the email on this account has been verified */
530
- verified: boolean;
531
- /** the user's email */
532
- email: string;
533
- /**
534
- * the flags on a user's account:
535
- * https://discord.com/developers/docs/resources/user#user-object-user-flags
536
- */
537
- flags: number;
538
- /**
539
- * the type of Nitro subscription on a user's account:
540
- * https://discord.com/developers/docs/resources/user#user-object-premium-types
541
- */
542
- premium_type: number;
543
- /**
544
- * the public flags on a user's account:
545
- * https://discord.com/developers/docs/resources/user#user-object-user-flags
546
- */
547
- public_flags: number;
548
- /** undocumented field; corresponds to the user's custom nickname */
549
- display_name: string | null;
550
- /**
551
- * undocumented field; corresponds to the Discord feature where you can e.g.
552
- * put your avatar inside of an ice cube
553
- */
554
- avatar_decoration: string | null;
555
- /**
556
- * undocumented field; corresponds to the premium feature where you can
557
- * select a custom banner color
558
- */
559
- banner_color: string | null;
560
- /** undocumented field; the CDN URL of their profile picture */
561
- image_url: string;
562
- }
563
- interface DiscordOptions extends ProviderOptions<DiscordProfile> {
564
- }
565
- declare const discord: (options: DiscordOptions) => {
566
- id: "discord";
567
- name: string;
568
- type: "oauth";
569
- params: {
570
- clientId: string;
571
- clientSecret: string;
572
- linkAccounts: {
573
- field: string;
574
- key: keyof DiscordProfile;
575
- enabler?: ((profile: DiscordProfile) => boolean | Promise<boolean>) | undefined;
576
- } | undefined;
577
- authorizationEndpoint: string;
578
- tokenEndpoint: string;
579
- redirectURL: string | undefined;
580
- };
581
- scopes: string[];
582
- getUserInfo(tokens: TokenResponse): Promise<{
583
- id: string;
584
- email: string;
585
- name: string;
586
- emailVerified: boolean;
587
- image: string;
588
- /** the user's username, not unique across the platform */
589
- username: string;
590
- /** the user's Discord-tag */
591
- discriminator: string;
592
- /** the user's display name, if it is set */
593
- global_name: string | null;
594
- /**
595
- * the user's avatar hash:
596
- * https://discord.com/developers/docs/reference#image-formatting
597
- */
598
- avatar: string | null;
599
- /** whether the user belongs to an OAuth2 application */
600
- bot?: boolean;
601
- /**
602
- * whether the user is an Official Discord System user (part of the urgent
603
- * message system)
604
- */
605
- system?: boolean;
606
- /** whether the user has two factor enabled on their account */
607
- mfa_enabled: boolean;
608
- /**
609
- * the user's banner hash:
610
- * https://discord.com/developers/docs/reference#image-formatting
611
- */
612
- banner: string | null;
613
- /** the user's banner color encoded as an integer representation of hexadecimal color code */
614
- accent_color: number | null;
615
- /**
616
- * the user's chosen language option:
617
- * https://discord.com/developers/docs/reference#locales
618
- */
619
- locale: string;
620
- /** whether the email on this account has been verified */
621
- verified: boolean;
622
- /**
623
- * the flags on a user's account:
624
- * https://discord.com/developers/docs/resources/user#user-object-user-flags
625
- */
626
- flags: number;
627
- /**
628
- * the type of Nitro subscription on a user's account:
629
- * https://discord.com/developers/docs/resources/user#user-object-premium-types
630
- */
631
- premium_type: number;
632
- /**
633
- * the public flags on a user's account:
634
- * https://discord.com/developers/docs/resources/user#user-object-user-flags
635
- */
636
- public_flags: number;
637
- /** undocumented field; corresponds to the user's custom nickname */
638
- display_name: string | null;
639
- /**
640
- * undocumented field; corresponds to the Discord feature where you can e.g.
641
- * put your avatar inside of an ice cube
642
- */
643
- avatar_decoration: string | null;
644
- /**
645
- * undocumented field; corresponds to the premium feature where you can
646
- * select a custom banner color
647
- */
648
- banner_color: string | null;
649
- /** undocumented field; the CDN URL of their profile picture */
650
- image_url: string;
651
- }>;
652
- };
653
-
654
- interface FacebookProfile {
655
- id: string;
656
- name: string;
657
- email: string;
658
- email_verified: boolean;
659
- picture: {
660
- data: {
661
- height: number;
662
- is_silhouette: boolean;
663
- url: string;
664
- width: number;
665
- };
666
- };
667
- }
668
- interface FacebookOptions extends ProviderOptions<FacebookProfile> {
669
- }
670
- declare const facebook: (options: FacebookOptions) => {
671
- id: "facebook";
672
- name: string;
673
- type: "oauth";
674
- scopes: string[];
675
- params: {
676
- clientId: string;
677
- clientSecret: string;
678
- redirectURL: string | undefined;
679
- authorizationEndpoint: string;
680
- tokenEndpoint: string;
681
- };
682
- getUserInfo(tokens: TokenResponse): Promise<{
683
- id: string;
684
- name: string;
685
- email: string;
686
- emailVerified: boolean;
687
- email_verified: boolean;
688
- picture: {
689
- data: {
690
- height: number;
691
- is_silhouette: boolean;
692
- url: string;
693
- width: number;
694
- };
695
- };
696
- }>;
697
- };
698
-
699
- interface GithubProfile {
700
- login: string;
701
- id: string;
702
- node_id: string;
703
- avatar_url: string;
704
- gravatar_id: string;
705
- url: string;
706
- html_url: string;
707
- followers_url: string;
708
- following_url: string;
709
- gists_url: string;
710
- starred_url: string;
711
- subscriptions_url: string;
712
- organizations_url: string;
713
- repos_url: string;
714
- events_url: string;
715
- received_events_url: string;
716
- type: string;
717
- site_admin: boolean;
718
- name: string;
719
- company: string;
720
- blog: string;
721
- location: string;
722
- email: string;
723
- hireable: boolean;
724
- bio: string;
725
- twitter_username: string;
726
- public_repos: string;
727
- public_gists: string;
728
- followers: string;
729
- following: string;
730
- created_at: string;
731
- updated_at: string;
732
- private_gists: string;
733
- total_private_repos: string;
734
- owned_private_repos: string;
735
- disk_usage: string;
736
- collaborators: string;
737
- two_factor_authentication: boolean;
738
- plan: {
739
- name: string;
740
- space: string;
741
- private_repos: string;
742
- collaborators: string;
743
- };
744
- first_name: string;
745
- last_name: string;
746
- }
747
- interface GitHubOptions extends ProviderOptions<GithubProfile> {
748
- /**
749
- * Whether or not unauthenticated users will be offered
750
- * an option to sign up for GitHub during the OAuth flow
751
- * The default is true. Use false when a policy prohibits
752
- * signup.
753
- */
754
- allowSignup?: boolean;
755
- }
756
- /**
757
- * Github OAuth provider. This provider allows users to sign
758
- * in with their Github account.
759
- */
760
- declare const github: (options: GitHubOptions) => {
761
- id: "github";
762
- name: string;
763
- type: "oauth";
764
- params: {
765
- clientId: string;
766
- clientSecret: string;
767
- redirectURL: string | undefined;
768
- linkAccounts: {
769
- field: string;
770
- key: keyof GithubProfile;
771
- enabler?: ((profile: GithubProfile) => boolean | Promise<boolean>) | undefined;
772
- } | undefined;
773
- tokenEndpoint: string;
774
- authorizationEndpoint: string;
775
- extra: {
776
- allow_signup: string;
777
- };
778
- };
779
- scopes: string[];
780
- getUserInfo(tokens: TokenResponse): Promise<{
781
- id: string;
782
- first_name: string;
783
- last_name: string;
784
- login: string;
785
- node_id: string;
786
- avatar_url: string;
787
- gravatar_id: string;
788
- url: string;
789
- html_url: string;
790
- followers_url: string;
791
- following_url: string;
792
- gists_url: string;
793
- starred_url: string;
794
- subscriptions_url: string;
795
- organizations_url: string;
796
- repos_url: string;
797
- events_url: string;
798
- received_events_url: string;
799
- type: string;
800
- site_admin: boolean;
801
- name: string;
802
- company: string;
803
- blog: string;
804
- location: string;
805
- email: string;
806
- hireable: boolean;
807
- bio: string;
808
- twitter_username: string;
809
- public_repos: string;
810
- public_gists: string;
811
- followers: string;
812
- following: string;
813
- created_at: string;
814
- updated_at: string;
815
- private_gists: string;
816
- total_private_repos: string;
817
- owned_private_repos: string;
818
- disk_usage: string;
819
- collaborators: string;
820
- two_factor_authentication: boolean;
821
- plan: {
822
- name: string;
823
- space: string;
824
- private_repos: string;
825
- collaborators: string;
826
- };
827
- }>;
828
- };
829
-
830
- interface GitLabProfile {
831
- /**
832
- * the user's id (i.e. the numerical snowflake) as a string
833
- */
834
- id: string;
835
- username: string;
836
- email: string;
837
- name: string;
838
- state: string;
839
- avatar_url: string;
840
- web_url: string;
841
- created_at: string;
842
- bio: string;
843
- location?: string;
844
- public_email: string;
845
- skype: string;
846
- linkedin: string;
847
- twitter: string;
848
- website_url: string;
849
- organization: string;
850
- job_title: string;
851
- pronouns: string;
852
- bot: boolean;
853
- work_information?: string;
854
- followers: number;
855
- following: number;
856
- local_time: string;
857
- last_sign_in_at: string;
858
- confirmed_at: string;
859
- theme_id: number;
860
- last_activity_on: string;
861
- color_scheme_id: number;
862
- projects_limit: number;
863
- current_sign_in_at: string;
864
- identities: Array<{
865
- provider: string;
866
- extern_uid: string;
867
- }>;
868
- can_create_group: boolean;
869
- can_create_project: boolean;
870
- two_factor_enabled: boolean;
871
- external: boolean;
872
- private_profile: boolean;
873
- commit_email: string;
874
- shared_runners_minutes_limit: number;
875
- extra_shared_runners_minutes_limit: number;
876
- }
877
- interface GitlabOptions extends ProviderOptions<GitLabProfile> {
878
- domain?: string;
879
- }
880
- declare const gitlab: (options: GitlabOptions) => {
881
- id: "gitlab";
882
- name: string;
883
- type: "oauth";
884
- scopes: string[];
885
- params: {
886
- clientId: string;
887
- clientSecret: string;
888
- redirectURL: string | undefined;
889
- authorizationEndpoint: string;
890
- tokenEndpoint: string;
891
- };
892
- getUserInfo(tokens: TokenResponse): Promise<{
893
- id: string;
894
- email: string;
895
- emailVerified: boolean;
896
- image: string;
897
- username: string;
898
- name: string;
899
- state: string;
900
- avatar_url: string;
901
- web_url: string;
902
- created_at: string;
903
- bio: string;
904
- location?: string;
905
- public_email: string;
906
- skype: string;
907
- linkedin: string;
908
- twitter: string;
909
- website_url: string;
910
- organization: string;
911
- job_title: string;
912
- pronouns: string;
913
- bot: boolean;
914
- work_information?: string;
915
- followers: number;
916
- following: number;
917
- local_time: string;
918
- last_sign_in_at: string;
919
- confirmed_at: string;
920
- theme_id: number;
921
- last_activity_on: string;
922
- color_scheme_id: number;
923
- projects_limit: number;
924
- current_sign_in_at: string;
925
- identities: Array<{
926
- provider: string;
927
- extern_uid: string;
928
- }>;
929
- can_create_group: boolean;
930
- can_create_project: boolean;
931
- two_factor_enabled: boolean;
932
- external: boolean;
933
- private_profile: boolean;
934
- commit_email: string;
935
- shared_runners_minutes_limit: number;
936
- extra_shared_runners_minutes_limit: number;
937
- }>;
938
- };
939
-
940
- interface GoogleProfile {
941
- aud: string;
942
- azp: string;
943
- email: string;
944
- email_verified: boolean;
945
- exp: number;
946
- /**
947
- * The family name of the user, or last name in most
948
- * Western languages.
949
- */
950
- family_name: string;
951
- /**
952
- * The given name of the user, or first name in most
953
- * Western languages.
954
- */
955
- given_name: string;
956
- hd?: string;
957
- iat: number;
958
- iss: string;
959
- jti?: string;
960
- locale?: string;
961
- name: string;
962
- nbf?: number;
963
- picture: string;
964
- sub: string;
965
- }
966
- interface GoogleOptions extends ProviderOptions<GoogleProfile> {
967
- }
968
- declare const google: (options: GoogleOptions) => {
969
- id: "google";
970
- name: string;
971
- type: "oidc";
972
- nonce: true;
973
- params: {
974
- clientId: string;
975
- clientSecret: string;
976
- linkAccounts: {
977
- field: string;
978
- key: keyof GoogleProfile;
979
- enabler?: ((profile: GoogleProfile) => boolean | Promise<boolean>) | undefined;
980
- } | undefined;
981
- redirectURL: string | undefined;
982
- tokenEndpoint: string;
983
- authorizationEndpoint: string;
984
- };
985
- issuer: string;
986
- scopes: string[];
987
- pkCodeVerifier: true;
988
- getUserInfo(tokens: {
989
- accessToken: string;
990
- id_token: string;
991
- refresh_token?: string | undefined;
992
- expires_in?: number | undefined;
993
- }): Promise<{
994
- id: string;
995
- aud: string;
996
- azp: string;
997
- email: string;
998
- email_verified: boolean;
999
- exp: number;
1000
- /**
1001
- * The family name of the user, or last name in most
1002
- * Western languages.
1003
- */
1004
- family_name: string;
1005
- /**
1006
- * The given name of the user, or first name in most
1007
- * Western languages.
1008
- */
1009
- given_name: string;
1010
- hd?: string;
1011
- iat: number;
1012
- iss: string;
1013
- jti?: string;
1014
- locale?: string;
1015
- name: string;
1016
- nbf?: number;
1017
- picture: string;
1018
- sub: string;
1019
- }>;
1020
- };
1021
-
1022
- interface MagicLinkOptions {
1023
- sendEmail: (email: string, url: string) => Promise<void>;
1024
- /**
1025
- * Redirect URL
1026
- * You can pass this when you call on the client.
1027
- */
1028
- redirect?: {
1029
- error: string;
1030
- success: string;
1031
- };
1032
- }
1033
- declare const magicLink: (options?: MagicLinkOptions) => {
1034
- id: "magic-link";
1035
- name: string;
1036
- type: "custom";
1037
- signIn: (context: Context) => Promise<{
1038
- status: number;
1039
- statusText: string;
1040
- Location?: undefined;
1041
- body?: undefined;
1042
- } | {
1043
- status: number;
1044
- Location: string;
1045
- statusText?: undefined;
1046
- body?: undefined;
1047
- } | {
1048
- status: number;
1049
- body: {
1050
- success: boolean;
1051
- };
1052
- statusText?: undefined;
1053
- Location?: undefined;
1054
- }>;
1055
- signUp(context: SignUpContext): Promise<{
1056
- status: number;
1057
- statusText: string;
1058
- Location?: undefined;
1059
- body?: undefined;
1060
- } | {
1061
- status: number;
1062
- body: {
1063
- success: boolean;
1064
- };
1065
- statusText?: undefined;
1066
- Location?: undefined;
1067
- } | {
1068
- status: number;
1069
- Location: string;
1070
- }>;
1071
- handler: {
1072
- matcher: (context: Context) => boolean;
1073
- handler: (context: {
1074
- request: InternalRequest<any, any>;
1075
- } & InternalOptions) => Promise<{
1076
- status: number;
1077
- Location?: undefined;
1078
- } | {
1079
- status: number;
1080
- Location: string;
1081
- }>;
1082
- };
1083
- input: z.ZodObject<{
1084
- email: z.ZodString;
1085
- }, "strip", z.ZodTypeAny, {
1086
- email: string;
1087
- }, {
1088
- email: string;
1089
- }>;
1090
- };
1091
-
1092
- interface SpotifyOptions extends ProviderOptions<SpotifyProfile> {
1093
- }
1094
- interface SpotifyProfile {
1095
- id: string;
1096
- display_name: string;
1097
- email: string;
1098
- images: {
1099
- url: string;
1100
- }[];
1101
- }
1102
- declare const spotify: (options: SpotifyOptions) => {
1103
- id: "spotify";
1104
- name: string;
1105
- type: "oauth";
1106
- scopes: string[];
1107
- params: {
1108
- clientId: string;
1109
- clientSecret: string;
1110
- redirectURL: string | undefined;
1111
- authorizationEndpoint: string;
1112
- tokenEndpoint: string;
1113
- };
1114
- getUserInfo(tokens: TokenResponse): Promise<{
1115
- id: string;
1116
- email: string;
1117
- emailVerified: boolean;
1118
- name: string;
1119
- image: string | undefined;
1120
- display_name: string;
1121
- images: {
1122
- url: string;
1123
- }[];
1124
- }>;
1125
- };
1126
-
1127
- interface TwitchProfile {
1128
- /**
1129
- * The sub of the user
1130
- */
1131
- sub: string;
1132
- /**
1133
- * The preferred username of the user
1134
- */
1135
- preferred_username: string;
1136
- /**
1137
- * The email of the user
1138
- */
1139
- email: string;
1140
- /**
1141
- * The picture of the user
1142
- */
1143
- picture: string;
1144
- }
1145
- interface TwitchOptions extends ProviderOptions<TwitchProfile> {
1146
- }
1147
- declare const Twitch: (options: TwitchOptions) => {
1148
- id: "twitch";
1149
- name: string;
1150
- type: "oauth";
1151
- scopes: string[];
1152
- params: {
1153
- clientId: string;
1154
- linkAccounts: {
1155
- field: string;
1156
- key: keyof TwitchProfile;
1157
- enabler?: ((profile: TwitchProfile) => boolean | Promise<boolean>) | undefined;
1158
- } | undefined;
1159
- clientSecret: string;
1160
- redirectURL: string | undefined;
1161
- authorizationEndpoint: string;
1162
- tokenEndpoint: string;
1163
- };
1164
- getUserInfo(tokens: TokenResponse): Promise<{
1165
- id: string;
1166
- email: string;
1167
- emailVerified: boolean;
1168
- name: string;
1169
- image: string;
1170
- /**
1171
- * The sub of the user
1172
- */
1173
- sub: string;
1174
- /**
1175
- * The preferred username of the user
1176
- */
1177
- preferred_username: string;
1178
- /**
1179
- * The picture of the user
1180
- */
1181
- picture: string;
1182
- }>;
1183
- };
1184
-
1185
- type ProviderType = "oauth" | "oidc" | "custom";
1186
- type Provider<T extends Record<string, any> = any> = OAuthProvider<T> | OIDCProvider<T> | CustomProvider;
1187
- interface BaseProvider {
1188
- /**
1189
- * Make sure this is inferred as a literal type
1190
- *
1191
- * @example
1192
- * ```ts
1193
- * id: "custom" as const;
1194
- * ```
1195
- */
1196
- id: string;
1197
- /**
1198
- * The name of the provider
1199
- */
1200
- name: string;
1201
- }
1202
- interface BaseOAuthProvider<T> extends BaseProvider {
1203
- /**
1204
- * The scopes you want to request from the provider
1205
- */
1206
- scopes: string[];
1207
- /**
1208
- * The issuer of the provider. This will be used to discover the endpoints
1209
- * for the provider, if the endpoints are not provided.
1210
- */
1211
- issuer?: string;
1212
- /**
1213
- * The parameters required for the provider
1214
- */
1215
- params: {
1216
- clientId: string;
1217
- clientSecret: string;
1218
- authorizationEndpoint?: string;
1219
- tokenEndpoint?: string;
1220
- redirectURL?: string;
1221
- /**
1222
- * Extra parameters to be sent to the provider. This will be sent as query parameters.
1223
- */
1224
- extra?: Record<string, string>;
1225
- linkAccounts?: {
1226
- field: string;
1227
- key: keyof T;
1228
- enabler?: (profile: T) => Promise<boolean> | boolean;
1229
- };
1230
- responseMode?: "form_post" | "query";
1231
- };
1232
- /**
1233
- * If PKCE should be used for this provider
1234
- */
1235
- pkCodeVerifier?: boolean;
1236
- /**
1237
- * code_challenge_method for PKCE
1238
- */
1239
- codeChallengeMethod?: "S256" | "plain";
1240
- /**
1241
- * Get the tokens from the provider
1242
- */
1243
- getTokens?: (context: Context) => Promise<TokenResponse>;
1244
- }
1245
- interface OAuthProvider<T extends Record<string, any> = Record<string, any>> extends BaseOAuthProvider<T> {
1246
- /**i
1247
- * The type of the provider
1248
- */
1249
- type: "oauth";
1250
- /**
1251
- * Get the user info from the provider
1252
- */
1253
- getUserInfo: (tokens: TokenResponse) => Promise<T>;
1254
- }
1255
- interface OIDCProvider<T extends Record<string, any> = Record<string, any>> extends BaseOAuthProvider<T> {
1256
- /**
1257
- * The type of the provider
1258
- */
1259
- type: "oidc";
1260
- /**
1261
- * If nonce should be used for this provider
1262
- */
1263
- nonce?: boolean;
1264
- /**
1265
- * Get the user info from the provider
1266
- */
1267
- getUserInfo: (tokens: {
1268
- accessToken: string;
1269
- id_token: string;
1270
- refresh_token?: string;
1271
- expires_in?: number;
1272
- }) => Promise<T>;
1273
- }
1274
- interface CustomProvider<Input extends ZodSchema = ZodSchema> extends BaseProvider {
1275
- /**
1276
- * The type of the provider
1277
- */
1278
- type: "custom";
1279
- /**
1280
- * Sign in the user
1281
- */
1282
- signIn?: (context: Context) => Promise<InternalResponse>;
1283
- /**
1284
- * Sign up the user
1285
- */
1286
- signUp?: (context: SignUpContext) => Promise<InternalResponse>;
1287
- /**
1288
- * The signin Input schema for the provider
1289
- */
1290
- input: Input;
1291
- /**
1292
- * Options Schema
1293
- */
1294
- options?: ZodSchema;
1295
- /**
1296
- * Custom handler for a provider. This can be used to handle custom callbacks.
1297
- */
1298
- handler?: {
1299
- matcher: (context: Context) => boolean;
1300
- handler: GenericHandler;
1301
- };
1302
- }
1303
- interface ProviderOptions<T> {
1304
- /**
1305
- * The client ID of your application
1306
- */
1307
- clientId: string;
1308
- /**
1309
- * The client secret of your application
1310
- */
1311
- clientSecret: string;
1312
- /**
1313
- * The scopes you want to request from the provider
1314
- */
1315
- scopes?: string[];
1316
- /**
1317
- * The redirect URL for your application. This is where the provider will
1318
- * redirect the user after the sign in process. Make sure this URL is
1319
- * whitelisted in the provider's dashboard.
1320
- */
1321
- redirectURL?: string;
1322
- /**
1323
- * ⚠ Advanced Option: link multiple accounts to a single user. This is
1324
- * useful when you want to allow users to sign in
1325
- * with multiple providers.
1326
- *
1327
- * ► NOTE: This option might expose your application to account takeover
1328
- * attacks. Make sure you have proper security measures in place.
1329
- * @default false
1330
- */
1331
- linkAccounts?: {
1332
- /**
1333
- * The filed in the user schema to match the account
1334
- */
1335
- field: string;
1336
- /**
1337
- * The key on the provider profile to match the value
1338
- */
1339
- key: keyof T;
1340
- /**
1341
- * The enabler function to check if the account should be linked
1342
- *
1343
- * @example
1344
- * ```ts
1345
- * enabler: (profile) => profile.email_verified
1346
- * ```
1347
- * strongly recommended to use this option to prevent account takeover attacks
1348
- */
1349
- enabler?: (profile: T) => Promise<boolean> | boolean;
1350
- };
1351
- }
1352
- type Providers = {
1353
- apple: ReturnType<typeof apple>;
1354
- credential: ReturnType<typeof credential>;
1355
- discord: ReturnType<typeof discord>;
1356
- facebook: ReturnType<typeof facebook>;
1357
- github: ReturnType<typeof github>;
1358
- gitlab: ReturnType<typeof gitlab>;
1359
- "magic-link": ReturnType<typeof magicLink>;
1360
- google: ReturnType<typeof google>;
1361
- spotify: ReturnType<typeof spotify>;
1362
- twitch: ReturnType<typeof Twitch>;
1363
- };
1364
-
1365
- interface TokenResponse {
1366
- access_token: string;
1367
- token_type?: string;
1368
- expires_in?: number;
1369
- refresh_token?: string;
1370
- scope?: string;
1371
- error: undefined;
1372
- }
1373
-
1374
- interface BetterAuthOptions {
1375
- /**
1376
- * Base URL for the better auth. This is typically the
1377
- * root URL where your
1378
- * application server is hosted. If not explicitly set,
1379
- * the system will
1380
- * check the following environment variables in order:
1381
- * process.env.BETTER_AUTH_URL, process.env.AUTH_URL,
1382
- * process.env.VERCEL_URL.
1383
- * If none of these environment variables are set it will
1384
- * throw an error.
1385
- */
1386
- baseURL?: string;
1387
- /**
1388
- * Base path for the better auth. This is typically the path where the
1389
- * better auth routes are mounted. If not explicitly set, the system will
1390
- * check if the following environment variables includes a path in order:
1391
- * process.env.BETTER_AUTH_BASE_PATH, process.env.AUTH_BASE_PATH. If none
1392
- * of these environment variables are set, it will default to /api/auth/.
1393
- */
1394
- basePath?: string;
1395
- /**
1396
- * The secret used to sign the session token. This is required for the session to work. If not explicitly set, the system will check the following environment variables in order: process.env.BETTER_AUTH_SECRET, process.env.AUTH_SECRET. If none of these environment variables are set, on development mode, it will default to "better_auth_secret". On production mode, it will throw an error.
1397
- *
1398
- * to generate a good secret you can use the following command:
1399
- *
1400
- * @example openssl rand -base64 32
1401
- */
1402
- secret?: string;
1403
- /**
1404
- * List of providers for better auth
1405
- */
1406
- providers: Provider[];
1407
- /**
1408
- * List of plugins
1409
- */
1410
- plugins?: [BetterAuthPlugin, ...BetterAuthPlugin[]];
1411
- /**
1412
- * Database configuration.
1413
- */
1414
- /**
1415
- * The adapter to use. Make sure to install the appropriate package for
1416
- * your ORM or database.
1417
- */
1418
- adapter: Adapter;
1419
- /**
1420
- * Adapter for session
1421
- */
1422
- sessionAdapter?: SessionAdapter;
1423
- /**
1424
- * Session configuration
1425
- */
1426
- session?: {
1427
- /**
1428
- * The name of the table.
1429
- * @default "session"
1430
- */
1431
- modelName?: string;
1432
- /**
1433
- * Additional fields on session table.
1434
- */
1435
- additionalFields?: {
1436
- [key: string]: FieldAttributes;
1437
- };
1438
- /**
1439
- * Expiration time for the session token. The value
1440
- * should be in seconds.
1441
- * @default 7 days (60 * 60 * 24 * 7)
1442
- */
1443
- expiresIn?: number;
1444
- /**
1445
- * How often the session should be refreshed. The value
1446
- * should be in seconds.
1447
- * If set 0 the session will be refreshed every time it is used.
1448
- * @default 1 day (60 * 60 * 24)
1449
- */
1450
- updateAge?: number;
1451
- };
1452
- /**
1453
- * Schema configuration for the user table.
1454
- */
1455
- user: {
1456
- /**
1457
- * The name of the table.
1458
- * @default "user"
1459
- */
1460
- modelName?: string;
1461
- /**
1462
- * fields on user table other than id.
1463
- *
1464
- * Make sure these fields are added on you actual
1465
- * database table.
1466
- * @example
1467
- * ```ts
1468
- * name: {
1469
- * type: "string",
1470
- * required: false,
1471
- * returned: true
1472
- * }
1473
- * ```
1474
- */
1475
- fields: {
1476
- [key: string]: FieldAttributes;
1477
- };
1478
- };
1479
- /**
1480
- * Schema configuration for the account table.
1481
- */
1482
- account?: {
1483
- /**
1484
- * The name of the table.
1485
- * @default "account"
1486
- */
1487
- modelName?: string;
1488
- /**
1489
- * Additional fields on account table.
1490
- * The key should map to a field on your database
1491
- * table and the value is the value you want to save.
1492
- *
1493
- * @example
1494
- * ```ts
1495
- * {
1496
- * accessToken: "access_token"
1497
- * }
1498
- * ```
1499
- */
1500
- additionalFields?: {
1501
- [key: string]: keyof TokenResponse;
1502
- };
1503
- };
1504
- /**
1505
- * Advanced options. Don't change these unless you know
1506
- * what you are doing.
1507
- */
1508
- advanced?: {
1509
- /**
1510
- * ⚠ Advanced Option: When set to `true` then all
1511
- * cookies set by HTTPS.
1512
- * By default this is set to false for URL begin with
1513
- * http:// and true for URL begin with https://
1514
- */
1515
- useSecureCookies?: boolean;
1516
- /** ⚠ Danger Option:
1517
- * The skipCSRFCheck option is a critical security feature that helps
1518
- * protect against Cross-Site Request Forgery attacks. It should only
1519
- * be modified if you are certain your application has an alternative,
1520
- * robust CSRF protection mechanism in place. Improper use of this
1521
- * option can expose your application to security vulnerabilities.
1522
- */
1523
- skipCSRFCheck?: boolean;
1524
- /**
1525
- * ⚠ Advanced Option: session cookie configuration
1526
- */
1527
- sessionCookie?: CookieSerializeOptions;
1528
- };
1529
- }
1530
- type InternalAdapter = ReturnType<typeof createInternalAdapter>;
1531
- interface InternalOptions {
1532
- _db: Adapter;
1533
- adapter: InternalAdapter;
1534
- cookies: ReturnType<typeof getCookies>;
1535
- disableCSRF?: boolean;
1536
- plugins: BetterAuthPlugin[];
1537
- providers: Provider[];
1538
- secret: string;
1539
- basePath: string;
1540
- session: {
1541
- expiresIn: number;
1542
- updateAge: number;
1543
- modelName: string;
1544
- additionalFields?: Record<string, InternalFieldAttributes>;
1545
- selectFields: string[];
1546
- };
1547
- sessionAdapter?: SessionAdapter;
1548
- user: {
1549
- modelName: string;
1550
- fields: Record<string, InternalFieldAttributes>;
1551
- selectFields: string[];
1552
- };
1553
- account: {
1554
- modelName: string;
1555
- additionalFields?: Record<string, keyof TokenResponse>;
1556
- selectFields: string[];
1557
- };
1558
- baseURL: string;
1559
- }
1560
- type TypeOrTypeReturning<T, P = void, PR = false> = T | ((param: P extends infer R ? R : never) => PR extends true ? Promise<T> : T);
1561
-
1562
- export { type AfterHookHandler as A, type BetterAuthOptions as B, type Context as C, type TwitchProfile as D, type TwitchOptions as E, type FacebookProfile as F, type GenericHandler as G, type HandlerHooks as H, type InternalResponse as I, Twitch as J, type DiscordProfile as K, discord as L, magicLink as M, type OAuthProvider as O, type Providers as P, type TypeOrTypeReturning as T, type BetterAuthPlugin as a, type BeforeHookHandler as b, type Provider as c, type CustomProvider as d, type CookieManager as e, type InternalRequest as f, type BetterAuthActions as g, type CookieOptions as h, type InternalAdapter as i, type InternalOptions as j, createInternalAdapter as k, type InternalAdapter$1 as l, type ProviderType as m, type OIDCProvider as n, type ProviderOptions as o, type GoogleProfile as p, google as q, type GitHubOptions as r, github as s, credential as t, type FacebookOptions as u, facebook as v, apple as w, type GitLabProfile as x, gitlab as y, spotify as z };