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
@@ -0,0 +1,4 @@
1
+ export { h as AppleOptions, f as AppleProfile, j as DiscordOptions, D as DiscordProfile, p as FacebookOptions, F as FacebookProfile, b as GithubOptions, G as GithubProfile, d as GoogleOptions, c as GoogleProfile, O as OAuthProvider, w as OAuthProviderList, m as SpotifyOptions, l as SpotifyProfile, n as TwitchOptions, T as TwitchProfile, u as TwitterOption, r as TwitterProfile, i as apple, k as discord, q as facebook, g as github, e as google, a as oAuthProviderList, o as oAuthProviders, s as spotify, t as twitch, v as twitter } from './schema-BOszzrbQ.js';
2
+ import 'arctic';
3
+ import 'zod';
4
+ import './helper-B5_2Vzba.js';
package/dist/social.js ADDED
@@ -0,0 +1,509 @@
1
+ // src/social-providers/apple.ts
2
+ import "arctic";
3
+ import { parseJWT } from "oslo/jwt";
4
+ import { betterFetch } from "@better-fetch/fetch";
5
+
6
+ // src/error/better-auth-error.ts
7
+ var BetterAuthError = class extends Error {
8
+ constructor(message) {
9
+ super(message);
10
+ }
11
+ };
12
+
13
+ // src/utils/base-url.ts
14
+ function checkHasPath(url) {
15
+ try {
16
+ const parsedUrl = new URL(url);
17
+ return parsedUrl.pathname !== "/";
18
+ } catch (error) {
19
+ console.error("Invalid URL:", error);
20
+ return false;
21
+ }
22
+ }
23
+ function withPath(url, path = "/api/auth") {
24
+ const hasPath = checkHasPath(url);
25
+ if (hasPath) {
26
+ return {
27
+ baseURL: new URL(url).origin,
28
+ withPath: url
29
+ };
30
+ }
31
+ path = path.startsWith("/") ? path : `/${path}`;
32
+ return {
33
+ baseURL: url,
34
+ withPath: `${url}${path}`
35
+ };
36
+ }
37
+ function getBaseURL(url, path) {
38
+ if (url) {
39
+ return withPath(url, path);
40
+ }
41
+ const env = typeof process !== "undefined" ? process.env : typeof import.meta !== "undefined" ? (
42
+ //@ts-ignore
43
+ import.meta.env
44
+ ) : {};
45
+ const fromEnv = env.BETTER_AUTH_URL || env.AUTH_URL || env.NEXT_PUBLIC_AUTH_URL || env.NEXT_PUBLIC_BETTER_AUTH_URL || env.PUBLIC_AUTH_URL || env.PUBLIC_BETTER_AUTH_URL || env.NUXT_PUBLIC_BETTER_AUTH_URL || env.NUXT_PUBLIC_AUTH_URL;
46
+ if (fromEnv) {
47
+ return withPath(fromEnv, path);
48
+ }
49
+ const isDev = !fromEnv && (env.NODE_ENV === "development" || env.NODE_ENV === "test");
50
+ if (isDev) {
51
+ return {
52
+ baseURL: "http://localhost:3000",
53
+ withPath: "http://localhost:3000/api/auth"
54
+ };
55
+ }
56
+ throw new BetterAuthError(
57
+ "Could not infer baseURL from environment variables"
58
+ );
59
+ }
60
+
61
+ // src/social-providers/utils.ts
62
+ function getRedirectURI(providerId, redirectURI) {
63
+ return redirectURI || `${getBaseURL()}/api/auth/callback/${providerId}`;
64
+ }
65
+
66
+ // src/social-providers/apple.ts
67
+ var apple = ({
68
+ clientId,
69
+ clientSecret,
70
+ redirectURI
71
+ }) => {
72
+ const tokenEndpoint = "https://appleid.apple.com/auth/token";
73
+ redirectURI = getRedirectURI("apple", redirectURI);
74
+ return {
75
+ id: "apple",
76
+ name: "Apple",
77
+ createAuthorizationURL({ state, scopes }) {
78
+ const _scope = scopes || ["email", "name", "openid"];
79
+ return new URL(
80
+ `https://appleid.apple.com/auth/authorize?client_id=${clientId}&response_type=code&redirect_uri=${redirectURI}&scope=${_scope.join(
81
+ " "
82
+ )}&state=${state}`
83
+ );
84
+ },
85
+ validateAuthorizationCode: async (code) => {
86
+ const data = await betterFetch(tokenEndpoint, {
87
+ method: "POST",
88
+ body: new URLSearchParams({
89
+ client_id: clientId,
90
+ client_secret: clientSecret,
91
+ grant_type: "authorization_code",
92
+ code
93
+ }),
94
+ headers: {
95
+ "Content-Type": "application/x-www-form-urlencoded"
96
+ }
97
+ });
98
+ if (data.error) {
99
+ throw new BetterAuthError(data.error?.message || "");
100
+ }
101
+ return data.data;
102
+ },
103
+ async getUserInfo(token) {
104
+ const data = parseJWT(token.idToken())?.payload;
105
+ if (!data) {
106
+ return null;
107
+ }
108
+ return {
109
+ user: {
110
+ id: data.sub,
111
+ name: data.name,
112
+ email: data.email,
113
+ emailVerified: data.email_verified === "true"
114
+ },
115
+ data
116
+ };
117
+ }
118
+ };
119
+ };
120
+
121
+ // src/social-providers/discord.ts
122
+ import { betterFetch as betterFetch2 } from "@better-fetch/fetch";
123
+ import { Discord } from "arctic";
124
+ var discord = ({
125
+ clientId,
126
+ clientSecret,
127
+ redirectURI
128
+ }) => {
129
+ const discordArctic = new Discord(
130
+ clientId,
131
+ clientSecret,
132
+ getRedirectURI("discord", redirectURI)
133
+ );
134
+ return {
135
+ id: "discord",
136
+ name: "Discord",
137
+ createAuthorizationURL({ state, scopes }) {
138
+ const _scope = scopes || ["email"];
139
+ return discordArctic.createAuthorizationURL(state, _scope);
140
+ },
141
+ validateAuthorizationCode: discordArctic.validateAuthorizationCode,
142
+ async getUserInfo(token) {
143
+ const { data: profile, error } = await betterFetch2(
144
+ "https://discord.com/api/users/@me",
145
+ {
146
+ auth: {
147
+ type: "Bearer",
148
+ token: token.accessToken
149
+ }
150
+ }
151
+ );
152
+ if (error) {
153
+ return null;
154
+ }
155
+ return {
156
+ user: {
157
+ id: profile.id,
158
+ name: profile.display_name || profile.username || "",
159
+ email: profile.email,
160
+ emailVerified: profile.verified
161
+ },
162
+ data: profile
163
+ };
164
+ }
165
+ };
166
+ };
167
+
168
+ // src/social-providers/facebook.ts
169
+ import { betterFetch as betterFetch3 } from "@better-fetch/fetch";
170
+ import { Facebook } from "arctic";
171
+ var facebook = ({
172
+ clientId,
173
+ clientSecret,
174
+ redirectURI
175
+ }) => {
176
+ const facebookArctic = new Facebook(
177
+ clientId,
178
+ clientSecret,
179
+ getRedirectURI("facebook", redirectURI)
180
+ );
181
+ return {
182
+ id: "facebook",
183
+ name: "Facebook",
184
+ createAuthorizationURL({ state, scopes }) {
185
+ const _scopes = scopes || ["email", "public_profile"];
186
+ return facebookArctic.createAuthorizationURL(state, _scopes);
187
+ },
188
+ validateAuthorizationCode: facebookArctic.validateAuthorizationCode,
189
+ async getUserInfo(token) {
190
+ const { data: profile, error } = await betterFetch3(
191
+ "https://graph.facebook.com/me",
192
+ {
193
+ auth: {
194
+ type: "Bearer",
195
+ token: token.accessToken
196
+ }
197
+ }
198
+ );
199
+ if (error) {
200
+ return null;
201
+ }
202
+ return {
203
+ user: {
204
+ id: profile.id,
205
+ name: profile.name,
206
+ email: profile.email,
207
+ emailVerified: profile.email_verified
208
+ },
209
+ data: profile
210
+ };
211
+ }
212
+ };
213
+ };
214
+
215
+ // src/social-providers/github.ts
216
+ import { betterFetch as betterFetch4 } from "@better-fetch/fetch";
217
+ import { GitHub } from "arctic";
218
+ var github = ({
219
+ clientId,
220
+ clientSecret,
221
+ redirectURI
222
+ }) => {
223
+ const githubArctic = new GitHub(
224
+ clientId,
225
+ clientSecret,
226
+ getRedirectURI("github", redirectURI)
227
+ );
228
+ return {
229
+ id: "github",
230
+ name: "Github",
231
+ createAuthorizationURL({ state, scopes }) {
232
+ const _scopes = scopes || ["user:email"];
233
+ return githubArctic.createAuthorizationURL(state, _scopes);
234
+ },
235
+ validateAuthorizationCode: githubArctic.validateAuthorizationCode,
236
+ async getUserInfo(token) {
237
+ const { data: profile, error } = await betterFetch4(
238
+ "https://api.github.com/user",
239
+ {
240
+ method: "GET",
241
+ headers: {
242
+ Authorization: `Bearer ${token.accessToken}`
243
+ }
244
+ }
245
+ );
246
+ if (error) {
247
+ return null;
248
+ }
249
+ let emailVerified = false;
250
+ if (!profile.email) {
251
+ const { data, error: error2 } = await betterFetch4("https://api.github.com/user/emails", {
252
+ headers: {
253
+ Authorization: `Bearer ${token.accessToken}`,
254
+ "User-Agent": "better-auth"
255
+ }
256
+ });
257
+ if (!error2) {
258
+ profile.email = (data.find((e) => e.primary) ?? data[0])?.email;
259
+ emailVerified = data.find((e) => e.email === profile.email)?.verified ?? false;
260
+ }
261
+ }
262
+ return {
263
+ user: {
264
+ id: profile.id,
265
+ name: profile.name,
266
+ email: profile.email,
267
+ image: profile.avatar_url,
268
+ emailVerified,
269
+ createdAt: /* @__PURE__ */ new Date(),
270
+ updatedAt: /* @__PURE__ */ new Date()
271
+ },
272
+ data: profile
273
+ };
274
+ }
275
+ };
276
+ };
277
+
278
+ // src/social-providers/google.ts
279
+ import { Google } from "arctic";
280
+ import { parseJWT as parseJWT2 } from "oslo/jwt";
281
+ var google = ({
282
+ clientId,
283
+ clientSecret,
284
+ redirectURI
285
+ }) => {
286
+ const googleArctic = new Google(
287
+ clientId,
288
+ clientSecret,
289
+ getRedirectURI("google", redirectURI)
290
+ );
291
+ return {
292
+ id: "google",
293
+ name: "Google",
294
+ createAuthorizationURL({ state, scopes, codeVerifier }) {
295
+ if (!codeVerifier) {
296
+ throw new BetterAuthError("codeVerifier is required for Google");
297
+ }
298
+ const _scopes = scopes || ["email", "profile"];
299
+ return googleArctic.createAuthorizationURL(state, codeVerifier, _scopes);
300
+ },
301
+ validateAuthorizationCode: async (code, codeVerifier) => {
302
+ if (!codeVerifier) {
303
+ throw new BetterAuthError("codeVerifier is required for Google");
304
+ }
305
+ return googleArctic.validateAuthorizationCode(code, codeVerifier);
306
+ },
307
+ async getUserInfo(token) {
308
+ if (!token.idToken) {
309
+ return null;
310
+ }
311
+ const user = parseJWT2(token.idToken())?.payload;
312
+ return {
313
+ user: {
314
+ id: user.sub,
315
+ name: user.name,
316
+ email: user.email,
317
+ image: user.picture,
318
+ emailVerified: user.email_verified
319
+ },
320
+ data: user
321
+ };
322
+ }
323
+ };
324
+ };
325
+
326
+ // src/social-providers/spotify.ts
327
+ import { betterFetch as betterFetch5 } from "@better-fetch/fetch";
328
+ import { Spotify } from "arctic";
329
+ var spotify = ({
330
+ clientId,
331
+ clientSecret,
332
+ redirectURI
333
+ }) => {
334
+ const spotifyArctic = new Spotify(
335
+ clientId,
336
+ clientSecret,
337
+ getRedirectURI("spotify", redirectURI)
338
+ );
339
+ return {
340
+ id: "spotify",
341
+ name: "Spotify",
342
+ createAuthorizationURL({ state, scopes }) {
343
+ const _scopes = scopes || ["user-read-email"];
344
+ return spotifyArctic.createAuthorizationURL(state, _scopes);
345
+ },
346
+ validateAuthorizationCode: spotifyArctic.validateAuthorizationCode,
347
+ async getUserInfo(token) {
348
+ const { data: profile, error } = await betterFetch5(
349
+ "https://api.spotify.com/v1/me",
350
+ {
351
+ method: "GET",
352
+ headers: {
353
+ Authorization: `Bearer ${token.accessToken}`
354
+ }
355
+ }
356
+ );
357
+ if (error) {
358
+ return null;
359
+ }
360
+ return {
361
+ user: {
362
+ id: profile.id,
363
+ name: profile.display_name,
364
+ email: profile.email,
365
+ image: profile.images[0]?.url,
366
+ emailVerified: false
367
+ },
368
+ data: profile
369
+ };
370
+ }
371
+ };
372
+ };
373
+
374
+ // src/social-providers/twitch.ts
375
+ import { betterFetch as betterFetch6 } from "@better-fetch/fetch";
376
+ import { Twitch } from "arctic";
377
+ var twitch = ({
378
+ clientId,
379
+ clientSecret,
380
+ redirectURI
381
+ }) => {
382
+ const twitchArctic = new Twitch(
383
+ clientId,
384
+ clientSecret,
385
+ getRedirectURI("twitch", redirectURI)
386
+ );
387
+ return {
388
+ id: "twitch",
389
+ name: "Twitch",
390
+ createAuthorizationURL({ state, scopes }) {
391
+ const _scopes = scopes || ["activity:write", "read"];
392
+ return twitchArctic.createAuthorizationURL(state, _scopes);
393
+ },
394
+ validateAuthorizationCode: twitchArctic.validateAuthorizationCode,
395
+ async getUserInfo(token) {
396
+ const { data: profile, error } = await betterFetch6(
397
+ "https://api.twitch.tv/helix/users",
398
+ {
399
+ method: "GET",
400
+ headers: {
401
+ Authorization: `Bearer ${token.accessToken}`
402
+ }
403
+ }
404
+ );
405
+ if (error) {
406
+ return null;
407
+ }
408
+ return {
409
+ user: {
410
+ id: profile.sub,
411
+ name: profile.preferred_username,
412
+ email: profile.email,
413
+ image: profile.picture,
414
+ emailVerified: false
415
+ },
416
+ data: profile
417
+ };
418
+ }
419
+ };
420
+ };
421
+
422
+ // src/social-providers/twitter.ts
423
+ import { betterFetch as betterFetch7 } from "@better-fetch/fetch";
424
+ import { Twitter } from "arctic";
425
+ var twitter = ({
426
+ clientId,
427
+ clientSecret,
428
+ redirectURI
429
+ }) => {
430
+ const twitterArctic = new Twitter(
431
+ clientId,
432
+ clientSecret,
433
+ getRedirectURI("twitter", redirectURI)
434
+ );
435
+ return {
436
+ id: "twitter",
437
+ name: "Twitter",
438
+ createAuthorizationURL(data) {
439
+ const _scopes = data.scopes || ["account_info.read"];
440
+ return twitterArctic.createAuthorizationURL(
441
+ data.state,
442
+ data.codeVerifier,
443
+ _scopes
444
+ );
445
+ },
446
+ validateAuthorizationCode: async (code, codeVerifier) => {
447
+ if (!codeVerifier) {
448
+ throw new BetterAuthError("codeVerifier is required for Twitter");
449
+ }
450
+ return twitterArctic.validateAuthorizationCode(code, codeVerifier);
451
+ },
452
+ async getUserInfo(token) {
453
+ const { data: profile, error } = await betterFetch7(
454
+ "https://api.x.com/2/users/me?user.fields=profile_image_url",
455
+ {
456
+ method: "GET",
457
+ headers: {
458
+ Authorization: `Bearer ${token.accessToken}`
459
+ }
460
+ }
461
+ );
462
+ if (error) {
463
+ return null;
464
+ }
465
+ if (!profile.data.email) {
466
+ return null;
467
+ }
468
+ return {
469
+ user: {
470
+ id: profile.data.id,
471
+ name: profile.data.name,
472
+ email: profile.data.email,
473
+ image: profile.data.profile_image_url,
474
+ emailVerified: profile.data.verified || false
475
+ },
476
+ data: profile
477
+ };
478
+ }
479
+ };
480
+ };
481
+
482
+ // src/types/provider.ts
483
+ import "arctic";
484
+
485
+ // src/social-providers/index.ts
486
+ var oAuthProviders = {
487
+ apple,
488
+ discord,
489
+ facebook,
490
+ github,
491
+ google,
492
+ spotify,
493
+ twitch,
494
+ twitter
495
+ };
496
+ var oAuthProviderList = Object.keys(oAuthProviders);
497
+ export {
498
+ apple,
499
+ discord,
500
+ facebook,
501
+ github,
502
+ google,
503
+ oAuthProviderList,
504
+ oAuthProviders,
505
+ spotify,
506
+ twitch,
507
+ twitter
508
+ };
509
+ //# sourceMappingURL=social.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/social-providers/apple.ts","../src/error/better-auth-error.ts","../src/utils/base-url.ts","../src/social-providers/utils.ts","../src/social-providers/discord.ts","../src/social-providers/facebook.ts","../src/social-providers/github.ts","../src/social-providers/google.ts","../src/social-providers/spotify.ts","../src/social-providers/twitch.ts","../src/social-providers/twitter.ts","../src/types/provider.ts","../src/social-providers/index.ts"],"sourcesContent":["import { OAuth2Tokens } from \"arctic\";\nimport type { OAuthProvider } from \".\";\nimport { parseJWT } from \"oslo/jwt\";\nimport { betterFetch } from \"@better-fetch/fetch\";\nimport { BetterAuthError } from \"../error/better-auth-error\";\nimport { getRedirectURI } from \"./utils\";\nexport interface AppleProfile {\n\t/**\n\t * The subject registered claim identifies the principal that’s the subject\n\t * of the identity token. Because this token is for your app, the value is\n\t * the unique identifier for the user.\n\t */\n\tsub: string;\n\t/**\n\t * A String value representing the user's email address.\n\t * The email address is either the user's real email address or the proxy\n\t * address, depending on their status private email relay service.\n\t */\n\temail: string;\n\t/**\n\t * A string or Boolean value that indicates whether the service verifies\n\t * the email. The value can either be a string (\"true\" or \"false\") or a\n\t * Boolean (true or false). The system may not verify email addresses for\n\t * Sign in with Apple at Work & School users, and this claim is \"false\" or\n\t * false for those users.\n\t */\n\temail_verified: true | \"true\";\n\t/**\n\t * A string or Boolean value that indicates whether the email that the user\n\t * shares is the proxy address. The value can either be a string (\"true\" or\n\t * \"false\") or a Boolean (true or false).\n\t */\n\tis_private_email: boolean;\n\t/**\n\t * An Integer value that indicates whether the user appears to be a real\n\t * person. Use the value of this claim to mitigate fraud. The possible\n\t * values are: 0 (or Unsupported), 1 (or Unknown), 2 (or LikelyReal). For\n\t * more information, see ASUserDetectionStatus. This claim is present only\n\t * in iOS 14 and later, macOS 11 and later, watchOS 7 and later, tvOS 14\n\t * and later. The claim isn’t present or supported for web-based apps.\n\t */\n\treal_user_status: number;\n\t/**\n\t * The user’s full name in the format provided during the authorization\n\t * process.\n\t */\n\tname: string;\n}\n\nexport interface AppleOptions {\n\tclientId: string;\n\tclientSecret: string;\n\tredirectURI?: string;\n}\n\nexport const apple = ({\n\tclientId,\n\tclientSecret,\n\tredirectURI,\n}: AppleOptions) => {\n\tconst tokenEndpoint = \"https://appleid.apple.com/auth/token\";\n\tredirectURI = getRedirectURI(\"apple\", redirectURI);\n\treturn {\n\t\tid: \"apple\",\n\t\tname: \"Apple\",\n\t\tcreateAuthorizationURL({ state, scopes }) {\n\t\t\tconst _scope = scopes || [\"email\", \"name\", \"openid\"];\n\t\t\treturn new URL(\n\t\t\t\t`https://appleid.apple.com/auth/authorize?client_id=${clientId}&response_type=code&redirect_uri=${redirectURI}&scope=${_scope.join(\n\t\t\t\t\t\" \",\n\t\t\t\t)}&state=${state}`,\n\t\t\t);\n\t\t},\n\t\tvalidateAuthorizationCode: async (code) => {\n\t\t\tconst data = await betterFetch<OAuth2Tokens>(tokenEndpoint, {\n\t\t\t\tmethod: \"POST\",\n\t\t\t\tbody: new URLSearchParams({\n\t\t\t\t\tclient_id: clientId,\n\t\t\t\t\tclient_secret: clientSecret,\n\t\t\t\t\tgrant_type: \"authorization_code\",\n\t\t\t\t\tcode,\n\t\t\t\t}),\n\t\t\t\theaders: {\n\t\t\t\t\t\"Content-Type\": \"application/x-www-form-urlencoded\",\n\t\t\t\t},\n\t\t\t});\n\t\t\tif (data.error) {\n\t\t\t\tthrow new BetterAuthError(data.error?.message || \"\");\n\t\t\t}\n\t\t\treturn data.data;\n\t\t},\n\t\tasync getUserInfo(token) {\n\t\t\tconst data = parseJWT(token.idToken())?.payload as AppleProfile | null;\n\t\t\tif (!data) {\n\t\t\t\treturn null;\n\t\t\t}\n\t\t\treturn {\n\t\t\t\tuser: {\n\t\t\t\t\tid: data.sub,\n\t\t\t\t\tname: data.name,\n\t\t\t\t\temail: data.email,\n\t\t\t\t\temailVerified: data.email_verified === \"true\",\n\t\t\t\t},\n\t\t\t\tdata,\n\t\t\t};\n\t\t},\n\t} satisfies OAuthProvider<AppleProfile>;\n};\n","export class BetterAuthError extends Error {\n\tconstructor(message: string) {\n\t\tsuper(message);\n\t}\n}\n","import { BetterAuthError } from \"../error/better-auth-error\";\n\nfunction checkHasPath(url: string): boolean {\n\ttry {\n\t\tconst parsedUrl = new URL(url);\n\t\treturn parsedUrl.pathname !== \"/\";\n\t} catch (error) {\n\t\tconsole.error(\"Invalid URL:\", error);\n\t\treturn false;\n\t}\n}\n\nfunction withPath(url: string, path = \"/api/auth\") {\n\tconst hasPath = checkHasPath(url);\n\tif (hasPath) {\n\t\treturn {\n\t\t\tbaseURL: new URL(url).origin,\n\t\t\twithPath: url,\n\t\t};\n\t}\n\tpath = path.startsWith(\"/\") ? path : `/${path}`;\n\treturn {\n\t\tbaseURL: url,\n\t\twithPath: `${url}${path}`,\n\t};\n}\n\nexport function getBaseURL(url?: string, path?: string) {\n\tif (url) {\n\t\treturn withPath(url, path);\n\t}\n\t//@ts-ignore\n\tconst env: any =\n\t\ttypeof process !== \"undefined\"\n\t\t\t? process.env\n\t\t\t: typeof import.meta !== \"undefined\"\n\t\t\t\t? //@ts-ignore\n\t\t\t\t\timport.meta.env\n\t\t\t\t: {};\n\tconst fromEnv =\n\t\tenv.BETTER_AUTH_URL ||\n\t\tenv.AUTH_URL ||\n\t\tenv.NEXT_PUBLIC_AUTH_URL ||\n\t\tenv.NEXT_PUBLIC_BETTER_AUTH_URL ||\n\t\tenv.PUBLIC_AUTH_URL ||\n\t\tenv.PUBLIC_BETTER_AUTH_URL ||\n\t\tenv.NUXT_PUBLIC_BETTER_AUTH_URL ||\n\t\tenv.NUXT_PUBLIC_AUTH_URL;\n\tif (fromEnv) {\n\t\treturn withPath(fromEnv, path);\n\t}\n\n\tconst isDev =\n\t\t!fromEnv && (env.NODE_ENV === \"development\" || env.NODE_ENV === \"test\");\n\tif (isDev) {\n\t\treturn {\n\t\t\tbaseURL: \"http://localhost:3000\",\n\t\t\twithPath: \"http://localhost:3000/api/auth\",\n\t\t};\n\t}\n\tthrow new BetterAuthError(\n\t\t\"Could not infer baseURL from environment variables\",\n\t);\n}\n","import { getBaseURL } from \"../utils/base-url\";\n\nexport function getRedirectURI(providerId: string, redirectURI?: string) {\n\treturn redirectURI || `${getBaseURL()}/api/auth/callback/${providerId}`;\n}\n","import { betterFetch } from \"@better-fetch/fetch\";\nimport { Discord } from \"arctic\";\nimport type { OAuthProvider } from \".\";\nimport { getRedirectURI } from \"./utils\";\n\nexport interface DiscordProfile extends Record<string, any> {\n\t/** the user's id (i.e. the numerical snowflake) */\n\tid: string;\n\t/** the user's username, not unique across the platform */\n\tusername: string;\n\t/** the user's Discord-tag */\n\tdiscriminator: string;\n\t/** the user's display name, if it is set */\n\tglobal_name: string | null;\n\t/**\n\t * the user's avatar hash:\n\t * https://discord.com/developers/docs/reference#image-formatting\n\t */\n\tavatar: string | null;\n\t/** whether the user belongs to an OAuth2 application */\n\tbot?: boolean;\n\t/**\n\t * whether the user is an Official Discord System user (part of the urgent\n\t * message system)\n\t */\n\tsystem?: boolean;\n\t/** whether the user has two factor enabled on their account */\n\tmfa_enabled: boolean;\n\t/**\n\t * the user's banner hash:\n\t * https://discord.com/developers/docs/reference#image-formatting\n\t */\n\tbanner: string | null;\n\n\t/** the user's banner color encoded as an integer representation of hexadecimal color code */\n\taccent_color: number | null;\n\n\t/**\n\t * the user's chosen language option:\n\t * https://discord.com/developers/docs/reference#locales\n\t */\n\tlocale: string;\n\t/** whether the email on this account has been verified */\n\tverified: boolean;\n\t/** the user's email */\n\temail: string;\n\t/**\n\t * the flags on a user's account:\n\t * https://discord.com/developers/docs/resources/user#user-object-user-flags\n\t */\n\tflags: number;\n\t/**\n\t * the type of Nitro subscription on a user's account:\n\t * https://discord.com/developers/docs/resources/user#user-object-premium-types\n\t */\n\tpremium_type: number;\n\t/**\n\t * the public flags on a user's account:\n\t * https://discord.com/developers/docs/resources/user#user-object-user-flags\n\t */\n\tpublic_flags: number;\n\t/** undocumented field; corresponds to the user's custom nickname */\n\tdisplay_name: string | null;\n\t/**\n\t * undocumented field; corresponds to the Discord feature where you can e.g.\n\t * put your avatar inside of an ice cube\n\t */\n\tavatar_decoration: string | null;\n\t/**\n\t * undocumented field; corresponds to the premium feature where you can\n\t * select a custom banner color\n\t */\n\tbanner_color: string | null;\n\t/** undocumented field; the CDN URL of their profile picture */\n\timage_url: string;\n}\n\nexport interface DiscordOptions {\n\tclientId: string;\n\tclientSecret: string;\n\tredirectURI?: string;\n}\n\nexport const discord = ({\n\tclientId,\n\tclientSecret,\n\tredirectURI,\n}: DiscordOptions) => {\n\tconst discordArctic = new Discord(\n\t\tclientId,\n\t\tclientSecret,\n\t\tgetRedirectURI(\"discord\", redirectURI),\n\t);\n\treturn {\n\t\tid: \"discord\",\n\t\tname: \"Discord\",\n\t\tcreateAuthorizationURL({ state, scopes }) {\n\t\t\tconst _scope = scopes || [\"email\"];\n\t\t\treturn discordArctic.createAuthorizationURL(state, _scope);\n\t\t},\n\t\tvalidateAuthorizationCode: discordArctic.validateAuthorizationCode,\n\t\tasync getUserInfo(token) {\n\t\t\tconst { data: profile, error } = await betterFetch<DiscordProfile>(\n\t\t\t\t\"https://discord.com/api/users/@me\",\n\t\t\t\t{\n\t\t\t\t\tauth: {\n\t\t\t\t\t\ttype: \"Bearer\",\n\t\t\t\t\t\ttoken: token.accessToken,\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t);\n\t\t\tif (error) {\n\t\t\t\treturn null;\n\t\t\t}\n\t\t\treturn {\n\t\t\t\tuser: {\n\t\t\t\t\tid: profile.id,\n\t\t\t\t\tname: profile.display_name || profile.username || \"\",\n\t\t\t\t\temail: profile.email,\n\t\t\t\t\temailVerified: profile.verified,\n\t\t\t\t},\n\t\t\t\tdata: profile,\n\t\t\t};\n\t\t},\n\t} satisfies OAuthProvider<DiscordProfile>;\n};\n","import { betterFetch } from \"@better-fetch/fetch\";\nimport { Facebook } from \"arctic\";\nimport type { OAuthProvider } from \".\";\nimport { getRedirectURI } from \"./utils\";\n\nexport interface FacebookProfile {\n\tid: string;\n\tname: string;\n\temail: string;\n\temail_verified: boolean;\n\tpicture: {\n\t\tdata: {\n\t\t\theight: number;\n\t\t\tis_silhouette: boolean;\n\t\t\turl: string;\n\t\t\twidth: number;\n\t\t};\n\t};\n}\nexport interface FacebookOptions {\n\tclientId: string;\n\tclientSecret: string;\n\tredirectURI?: string;\n}\nexport const facebook = ({\n\tclientId,\n\tclientSecret,\n\tredirectURI,\n}: FacebookOptions) => {\n\tconst facebookArctic = new Facebook(\n\t\tclientId,\n\t\tclientSecret,\n\t\tgetRedirectURI(\"facebook\", redirectURI),\n\t);\n\treturn {\n\t\tid: \"facebook\",\n\t\tname: \"Facebook\",\n\t\tcreateAuthorizationURL({ state, scopes }) {\n\t\t\tconst _scopes = scopes || [\"email\", \"public_profile\"];\n\t\t\treturn facebookArctic.createAuthorizationURL(state, _scopes);\n\t\t},\n\t\tvalidateAuthorizationCode: facebookArctic.validateAuthorizationCode,\n\t\tasync getUserInfo(token) {\n\t\t\tconst { data: profile, error } = await betterFetch<FacebookProfile>(\n\t\t\t\t\"https://graph.facebook.com/me\",\n\t\t\t\t{\n\t\t\t\t\tauth: {\n\t\t\t\t\t\ttype: \"Bearer\",\n\t\t\t\t\t\ttoken: token.accessToken,\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t);\n\t\t\tif (error) {\n\t\t\t\treturn null;\n\t\t\t}\n\t\t\treturn {\n\t\t\t\tuser: {\n\t\t\t\t\tid: profile.id,\n\t\t\t\t\tname: profile.name,\n\t\t\t\t\temail: profile.email,\n\t\t\t\t\temailVerified: profile.email_verified,\n\t\t\t\t},\n\t\t\t\tdata: profile,\n\t\t\t};\n\t\t},\n\t} satisfies OAuthProvider<FacebookProfile>;\n};\n","import { betterFetch } from \"@better-fetch/fetch\";\nimport { GitHub } from \"arctic\";\nimport type { OAuthProvider } from \".\";\nimport { getRedirectURI } from \"./utils\";\n\nexport interface GithubProfile {\n\tlogin: string;\n\tid: string;\n\tnode_id: string;\n\tavatar_url: string;\n\tgravatar_id: string;\n\turl: string;\n\thtml_url: string;\n\tfollowers_url: string;\n\tfollowing_url: string;\n\tgists_url: string;\n\tstarred_url: string;\n\tsubscriptions_url: string;\n\torganizations_url: string;\n\trepos_url: string;\n\tevents_url: string;\n\treceived_events_url: string;\n\ttype: string;\n\tsite_admin: boolean;\n\tname: string;\n\tcompany: string;\n\tblog: string;\n\tlocation: string;\n\temail: string;\n\thireable: boolean;\n\tbio: string;\n\ttwitter_username: string;\n\tpublic_repos: string;\n\tpublic_gists: string;\n\tfollowers: string;\n\tfollowing: string;\n\tcreated_at: string;\n\tupdated_at: string;\n\tprivate_gists: string;\n\ttotal_private_repos: string;\n\towned_private_repos: string;\n\tdisk_usage: string;\n\tcollaborators: string;\n\ttwo_factor_authentication: boolean;\n\tplan: {\n\t\tname: string;\n\t\tspace: string;\n\t\tprivate_repos: string;\n\t\tcollaborators: string;\n\t};\n\tfirst_name: string;\n\tlast_name: string;\n}\n\nexport interface GithubOptions {\n\tclientId: string;\n\tclientSecret: string;\n\tredirectURI?: string;\n}\nexport const github = ({\n\tclientId,\n\tclientSecret,\n\tredirectURI,\n}: GithubOptions) => {\n\tconst githubArctic = new GitHub(\n\t\tclientId,\n\t\tclientSecret,\n\t\tgetRedirectURI(\"github\", redirectURI),\n\t);\n\treturn {\n\t\tid: \"github\",\n\t\tname: \"Github\",\n\t\tcreateAuthorizationURL({ state, scopes }) {\n\t\t\tconst _scopes = scopes || [\"user:email\"];\n\t\t\treturn githubArctic.createAuthorizationURL(state, _scopes);\n\t\t},\n\t\tvalidateAuthorizationCode: githubArctic.validateAuthorizationCode,\n\t\tasync getUserInfo(token) {\n\t\t\tconst { data: profile, error } = await betterFetch<GithubProfile>(\n\t\t\t\t\"https://api.github.com/user\",\n\t\t\t\t{\n\t\t\t\t\tmethod: \"GET\",\n\t\t\t\t\theaders: {\n\t\t\t\t\t\tAuthorization: `Bearer ${token.accessToken}`,\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t);\n\t\t\tif (error) {\n\t\t\t\treturn null;\n\t\t\t}\n\t\t\tlet emailVerified = false;\n\t\t\tif (!profile.email) {\n\t\t\t\tconst { data, error } = await betterFetch<\n\t\t\t\t\t{\n\t\t\t\t\t\temail: string;\n\t\t\t\t\t\tprimary: boolean;\n\t\t\t\t\t\tverified: boolean;\n\t\t\t\t\t\tvisibility: \"public\" | \"private\";\n\t\t\t\t\t}[]\n\t\t\t\t>(\"https://api.github.com/user/emails\", {\n\t\t\t\t\theaders: {\n\t\t\t\t\t\tAuthorization: `Bearer ${token.accessToken}`,\n\t\t\t\t\t\t\"User-Agent\": \"better-auth\",\n\t\t\t\t\t},\n\t\t\t\t});\n\t\t\t\tif (!error) {\n\t\t\t\t\tprofile.email = (data.find((e) => e.primary) ?? data[0])\n\t\t\t\t\t\t?.email as string;\n\t\t\t\t\temailVerified =\n\t\t\t\t\t\tdata.find((e) => e.email === profile.email)?.verified ?? false;\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn {\n\t\t\t\tuser: {\n\t\t\t\t\tid: profile.id,\n\t\t\t\t\tname: profile.name,\n\t\t\t\t\temail: profile.email,\n\t\t\t\t\timage: profile.avatar_url,\n\t\t\t\t\temailVerified,\n\t\t\t\t\tcreatedAt: new Date(),\n\t\t\t\t\tupdatedAt: new Date(),\n\t\t\t\t},\n\t\t\t\tdata: profile,\n\t\t\t};\n\t\t},\n\t} satisfies OAuthProvider<GithubProfile>;\n};\n","import { Google } from \"arctic\";\nimport { parseJWT } from \"oslo/jwt\";\nimport type { OAuthProvider } from \".\";\nimport { getRedirectURI } from \"./utils\";\nimport { BetterAuthError } from \"../error/better-auth-error\";\n\nexport interface GoogleProfile {\n\taud: string;\n\tazp: string;\n\temail: string;\n\temail_verified: boolean;\n\texp: number;\n\t/**\n\t * The family name of the user, or last name in most\n\t * Western languages.\n\t */\n\tfamily_name: string;\n\t/**\n\t * The given name of the user, or first name in most\n\t * Western languages.\n\t */\n\tgiven_name: string;\n\thd?: string;\n\tiat: number;\n\tiss: string;\n\tjti?: string;\n\tlocale?: string;\n\tname: string;\n\tnbf?: number;\n\tpicture: string;\n\tsub: string;\n}\n\nexport interface GoogleOptions {\n\tclientId: string;\n\tclientSecret: string;\n\tredirectURI?: string;\n}\n\nexport const google = ({\n\tclientId,\n\tclientSecret,\n\tredirectURI,\n}: GoogleOptions) => {\n\tconst googleArctic = new Google(\n\t\tclientId,\n\t\tclientSecret,\n\t\tgetRedirectURI(\"google\", redirectURI),\n\t);\n\treturn {\n\t\tid: \"google\",\n\t\tname: \"Google\",\n\t\tcreateAuthorizationURL({ state, scopes, codeVerifier }) {\n\t\t\tif (!codeVerifier) {\n\t\t\t\tthrow new BetterAuthError(\"codeVerifier is required for Google\");\n\t\t\t}\n\t\t\tconst _scopes = scopes || [\"email\", \"profile\"];\n\t\t\treturn googleArctic.createAuthorizationURL(state, codeVerifier, _scopes);\n\t\t},\n\t\tvalidateAuthorizationCode: async (code, codeVerifier) => {\n\t\t\tif (!codeVerifier) {\n\t\t\t\tthrow new BetterAuthError(\"codeVerifier is required for Google\");\n\t\t\t}\n\t\t\treturn googleArctic.validateAuthorizationCode(code, codeVerifier);\n\t\t},\n\t\tasync getUserInfo(token) {\n\t\t\tif (!token.idToken) {\n\t\t\t\treturn null;\n\t\t\t}\n\t\t\tconst user = parseJWT(token.idToken())?.payload as GoogleProfile;\n\t\t\treturn {\n\t\t\t\tuser: {\n\t\t\t\t\tid: user.sub,\n\t\t\t\t\tname: user.name,\n\t\t\t\t\temail: user.email,\n\t\t\t\t\timage: user.picture,\n\t\t\t\t\temailVerified: user.email_verified,\n\t\t\t\t},\n\t\t\t\tdata: user,\n\t\t\t};\n\t\t},\n\t} satisfies OAuthProvider<GoogleProfile>;\n};\n","import { betterFetch } from \"@better-fetch/fetch\";\nimport { Spotify } from \"arctic\";\nimport type { OAuthProvider } from \".\";\nimport { getRedirectURI } from \"./utils\";\n\nexport interface SpotifyProfile {\n\tid: string;\n\tdisplay_name: string;\n\temail: string;\n\timages: {\n\t\turl: string;\n\t}[];\n}\n\nexport interface SpotifyOptions {\n\tclientId: string;\n\tclientSecret: string;\n\tredirectURI?: string;\n}\n\nexport const spotify = ({\n\tclientId,\n\tclientSecret,\n\tredirectURI,\n}: SpotifyOptions) => {\n\tconst spotifyArctic = new Spotify(\n\t\tclientId,\n\t\tclientSecret,\n\t\tgetRedirectURI(\"spotify\", redirectURI),\n\t);\n\treturn {\n\t\tid: \"spotify\",\n\t\tname: \"Spotify\",\n\t\tcreateAuthorizationURL({ state, scopes }) {\n\t\t\tconst _scopes = scopes || [\"user-read-email\"];\n\t\t\treturn spotifyArctic.createAuthorizationURL(state, _scopes);\n\t\t},\n\t\tvalidateAuthorizationCode: spotifyArctic.validateAuthorizationCode,\n\t\tasync getUserInfo(token) {\n\t\t\tconst { data: profile, error } = await betterFetch<SpotifyProfile>(\n\t\t\t\t\"https://api.spotify.com/v1/me\",\n\t\t\t\t{\n\t\t\t\t\tmethod: \"GET\",\n\t\t\t\t\theaders: {\n\t\t\t\t\t\tAuthorization: `Bearer ${token.accessToken}`,\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t);\n\t\t\tif (error) {\n\t\t\t\treturn null;\n\t\t\t}\n\t\t\treturn {\n\t\t\t\tuser: {\n\t\t\t\t\tid: profile.id,\n\t\t\t\t\tname: profile.display_name,\n\t\t\t\t\temail: profile.email,\n\t\t\t\t\timage: profile.images[0]?.url,\n\t\t\t\t\temailVerified: false,\n\t\t\t\t},\n\t\t\t\tdata: profile,\n\t\t\t};\n\t\t},\n\t} satisfies OAuthProvider<SpotifyProfile>;\n};\n","import { betterFetch } from \"@better-fetch/fetch\";\nimport { Twitch } from \"arctic\";\nimport type { OAuthProvider } from \".\";\nimport { getRedirectURI } from \"./utils\";\n\nexport interface TwitchProfile {\n\t/**\n\t * The sub of the user\n\t */\n\tsub: string;\n\t/**\n\t * The preferred username of the user\n\t */\n\tpreferred_username: string;\n\t/**\n\t * The email of the user\n\t */\n\temail: string;\n\t/**\n\t * The picture of the user\n\t */\n\tpicture: string;\n}\n\nexport interface TwitchOptions {\n\tclientId: string;\n\tclientSecret: string;\n\tredirectURI?: string;\n}\n\nexport const twitch = ({\n\tclientId,\n\tclientSecret,\n\tredirectURI,\n}: TwitchOptions) => {\n\tconst twitchArctic = new Twitch(\n\t\tclientId,\n\t\tclientSecret,\n\t\tgetRedirectURI(\"twitch\", redirectURI),\n\t);\n\treturn {\n\t\tid: \"twitch\",\n\t\tname: \"Twitch\",\n\t\tcreateAuthorizationURL({ state, scopes }) {\n\t\t\tconst _scopes = scopes || [\"activity:write\", \"read\"];\n\t\t\treturn twitchArctic.createAuthorizationURL(state, _scopes);\n\t\t},\n\t\tvalidateAuthorizationCode: twitchArctic.validateAuthorizationCode,\n\t\tasync getUserInfo(token) {\n\t\t\tconst { data: profile, error } = await betterFetch<TwitchProfile>(\n\t\t\t\t\"https://api.twitch.tv/helix/users\",\n\t\t\t\t{\n\t\t\t\t\tmethod: \"GET\",\n\t\t\t\t\theaders: {\n\t\t\t\t\t\tAuthorization: `Bearer ${token.accessToken}`,\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t);\n\t\t\tif (error) {\n\t\t\t\treturn null;\n\t\t\t}\n\t\t\treturn {\n\t\t\t\tuser: {\n\t\t\t\t\tid: profile.sub,\n\t\t\t\t\tname: profile.preferred_username,\n\t\t\t\t\temail: profile.email,\n\t\t\t\t\timage: profile.picture,\n\t\t\t\t\temailVerified: false,\n\t\t\t\t},\n\t\t\t\tdata: profile,\n\t\t\t};\n\t\t},\n\t} satisfies OAuthProvider<TwitchProfile>;\n};\n","import { betterFetch } from \"@better-fetch/fetch\";\nimport { Twitter } from \"arctic\";\nimport type { OAuthProvider } from \".\";\nimport { getRedirectURI } from \"./utils\";\nimport { BetterAuthError } from \"../error/better-auth-error\";\n\nexport interface TwitterProfile {\n\tdata: {\n\t\t/**\n\t\t * Unique identifier of this user. This is returned as a string in order to avoid complications with languages and tools\n\t\t * that cannot handle large integers.\n\t\t */\n\t\tid: string;\n\t\t/** The friendly name of this user, as shown on their profile. */\n\t\tname: string;\n\t\t/** @note Email is currently unsupported by Twitter. */\n\t\temail?: string;\n\t\t/** The Twitter handle (screen name) of this user. */\n\t\tusername: string;\n\t\t/**\n\t\t * The location specified in the user's profile, if the user provided one.\n\t\t * As this is a freeform value, it may not indicate a valid location, but it may be fuzzily evaluated when performing searches with location queries.\n\t\t *\n\t\t * To return this field, add `user.fields=location` in the authorization request's query parameter.\n\t\t */\n\t\tlocation?: string;\n\t\t/**\n\t\t * This object and its children fields contain details about text that has a special meaning in the user's description.\n\t\t *\n\t\t *To return this field, add `user.fields=entities` in the authorization request's query parameter.\n\t\t */\n\t\tentities?: {\n\t\t\t/** Contains details about the user's profile website. */\n\t\t\turl: {\n\t\t\t\t/** Contains details about the user's profile website. */\n\t\t\t\turls: Array<{\n\t\t\t\t\t/** The start position (zero-based) of the recognized user's profile website. All start indices are inclusive. */\n\t\t\t\t\tstart: number;\n\t\t\t\t\t/** The end position (zero-based) of the recognized user's profile website. This end index is exclusive. */\n\t\t\t\t\tend: number;\n\t\t\t\t\t/** The URL in the format entered by the user. */\n\t\t\t\t\turl: string;\n\t\t\t\t\t/** The fully resolved URL. */\n\t\t\t\t\texpanded_url: string;\n\t\t\t\t\t/** The URL as displayed in the user's profile. */\n\t\t\t\t\tdisplay_url: string;\n\t\t\t\t}>;\n\t\t\t};\n\t\t\t/** Contains details about URLs, Hashtags, Cashtags, or mentions located within a user's description. */\n\t\t\tdescription: {\n\t\t\t\thashtags: Array<{\n\t\t\t\t\tstart: number;\n\t\t\t\t\tend: number;\n\t\t\t\t\ttag: string;\n\t\t\t\t}>;\n\t\t\t};\n\t\t};\n\t\t/**\n\t\t * Indicate if this user is a verified Twitter user.\n\t\t *\n\t\t * To return this field, add `user.fields=verified` in the authorization request's query parameter.\n\t\t */\n\t\tverified?: boolean;\n\t\t/**\n\t\t * The text of this user's profile description (also known as bio), if the user provided one.\n\t\t *\n\t\t * To return this field, add `user.fields=description` in the authorization request's query parameter.\n\t\t */\n\t\tdescription?: string;\n\t\t/**\n\t\t * The URL specified in the user's profile, if present.\n\t\t *\n\t\t * To return this field, add `user.fields=url` in the authorization request's query parameter.\n\t\t */\n\t\turl?: string;\n\t\t/** The URL to the profile image for this user, as shown on the user's profile. */\n\t\tprofile_image_url?: string;\n\t\tprotected?: boolean;\n\t\t/**\n\t\t * Unique identifier of this user's pinned Tweet.\n\t\t *\n\t\t * You can obtain the expanded object in `includes.tweets` by adding `expansions=pinned_tweet_id` in the authorization request's query parameter.\n\t\t */\n\t\tpinned_tweet_id?: string;\n\t\tcreated_at?: string;\n\t};\n\tincludes?: {\n\t\ttweets?: Array<{\n\t\t\tid: string;\n\t\t\ttext: string;\n\t\t}>;\n\t};\n\t[claims: string]: unknown;\n}\n\nexport interface TwitterOption {\n\tclientId: string;\n\tclientSecret: string;\n\tredirectURI?: string;\n}\n\nexport const twitter = ({\n\tclientId,\n\tclientSecret,\n\tredirectURI,\n}: TwitterOption) => {\n\tconst twitterArctic = new Twitter(\n\t\tclientId,\n\t\tclientSecret,\n\t\tgetRedirectURI(\"twitter\", redirectURI),\n\t);\n\treturn {\n\t\tid: \"twitter\",\n\t\tname: \"Twitter\",\n\t\tcreateAuthorizationURL(data) {\n\t\t\tconst _scopes = data.scopes || [\"account_info.read\"];\n\t\t\treturn twitterArctic.createAuthorizationURL(\n\t\t\t\tdata.state,\n\t\t\t\tdata.codeVerifier,\n\t\t\t\t_scopes,\n\t\t\t);\n\t\t},\n\t\tvalidateAuthorizationCode: async (code, codeVerifier) => {\n\t\t\tif (!codeVerifier) {\n\t\t\t\tthrow new BetterAuthError(\"codeVerifier is required for Twitter\");\n\t\t\t}\n\t\t\treturn twitterArctic.validateAuthorizationCode(code, codeVerifier);\n\t\t},\n\t\tasync getUserInfo(token) {\n\t\t\tconst { data: profile, error } = await betterFetch<TwitterProfile>(\n\t\t\t\t\"https://api.x.com/2/users/me?user.fields=profile_image_url\",\n\t\t\t\t{\n\t\t\t\t\tmethod: \"GET\",\n\t\t\t\t\theaders: {\n\t\t\t\t\t\tAuthorization: `Bearer ${token.accessToken}`,\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t);\n\t\t\tif (error) {\n\t\t\t\treturn null;\n\t\t\t}\n\t\t\tif (!profile.data.email) {\n\t\t\t\treturn null;\n\t\t\t}\n\t\t\treturn {\n\t\t\t\tuser: {\n\t\t\t\t\tid: profile.data.id,\n\t\t\t\t\tname: profile.data.name,\n\t\t\t\t\temail: profile.data.email,\n\t\t\t\t\timage: profile.data.profile_image_url,\n\t\t\t\t\temailVerified: profile.data.verified || false,\n\t\t\t\t},\n\t\t\t\tdata: profile,\n\t\t\t};\n\t\t},\n\t} satisfies OAuthProvider<TwitterProfile>;\n};\n","import type { User } from \"../adapters/schema\";\nimport type { oAuthProviderList } from \"../social-providers\";\nimport type { LiteralString } from \"./helper\";\nimport { OAuth2Tokens } from \"arctic\";\n\nexport interface OAuthProvider<\n\tT extends Record<string, any> = Record<string, any>,\n> {\n\tid: LiteralString;\n\tcreateAuthorizationURL: (data: {\n\t\tstate: string;\n\t\tcodeVerifier: string;\n\t\tscopes?: string[];\n\t}) => URL;\n\tname: string;\n\tvalidateAuthorizationCode: (\n\t\tcode: string,\n\t\tcodeVerifier?: string,\n\t) => Promise<OAuth2Tokens>;\n\tgetUserInfo: (token: OAuth2Tokens) => Promise<{\n\t\tuser: Omit<User, \"createdAt\" | \"updatedAt\">;\n\t\tdata: T;\n\t} | null>;\n\trefreshAccessToken?: (refreshToken: string) => Promise<OAuth2Tokens>;\n\trevokeToken?: (token: string) => Promise<void>;\n}\n\nexport type OAuthProviderList = typeof oAuthProviderList;\n","import { apple } from \"./apple\";\nimport { discord } from \"./discord\";\nimport { facebook } from \"./facebook\";\nimport { github } from \"./github\";\nimport { google } from \"./google\";\nimport { spotify } from \"./spotify\";\nimport { twitch } from \"./twitch\";\nimport { twitter } from \"./twitter\";\n\nexport const oAuthProviders = {\n\tapple,\n\tdiscord,\n\tfacebook,\n\tgithub,\n\tgoogle,\n\tspotify,\n\ttwitch,\n\ttwitter,\n};\n\nexport const oAuthProviderList = Object.keys(oAuthProviders) as [\n\t\"github\",\n\t...(keyof typeof oAuthProviders)[],\n];\n\nexport * from \"./github\";\nexport * from \"./google\";\nexport * from \"./apple\";\nexport * from \"./discord\";\nexport * from \"./spotify\";\nexport * from \"./twitch\";\nexport * from \"./facebook\";\nexport * from \"./twitter\";\nexport * from \"../types/provider\";\n"],"mappings":";AAAA,OAA6B;AAE7B,SAAS,gBAAgB;AACzB,SAAS,mBAAmB;;;ACHrB,IAAM,kBAAN,cAA8B,MAAM;AAAA,EAC1C,YAAY,SAAiB;AAC5B,UAAM,OAAO;AAAA,EACd;AACD;;;ACFA,SAAS,aAAa,KAAsB;AAC3C,MAAI;AACH,UAAM,YAAY,IAAI,IAAI,GAAG;AAC7B,WAAO,UAAU,aAAa;AAAA,EAC/B,SAAS,OAAO;AACf,YAAQ,MAAM,gBAAgB,KAAK;AACnC,WAAO;AAAA,EACR;AACD;AAEA,SAAS,SAAS,KAAa,OAAO,aAAa;AAClD,QAAM,UAAU,aAAa,GAAG;AAChC,MAAI,SAAS;AACZ,WAAO;AAAA,MACN,SAAS,IAAI,IAAI,GAAG,EAAE;AAAA,MACtB,UAAU;AAAA,IACX;AAAA,EACD;AACA,SAAO,KAAK,WAAW,GAAG,IAAI,OAAO,IAAI,IAAI;AAC7C,SAAO;AAAA,IACN,SAAS;AAAA,IACT,UAAU,GAAG,GAAG,GAAG,IAAI;AAAA,EACxB;AACD;AAEO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AA,MACP;AAAA,IACD;AAAA,EACD;AACD;;;ACzJA,OAA6B;;;ACMtB,IAAM,iBAAiB;AAAA,EAC7B;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACD;AAEO,IAAM,oBAAoB,OAAO,KAAK,cAAc;","names":["betterFetch","betterFetch","betterFetch","betterFetch","betterFetch","betterFetch","error","parseJWT","parseJWT","betterFetch","betterFetch","betterFetch","betterFetch","betterFetch","betterFetch"]}
@@ -0,0 +1,18 @@
1
+ import { A as Auth } from './index-W5nXvJ-p.js';
2
+ import 'better-call';
3
+ import 'zod';
4
+ import './helper-B5_2Vzba.js';
5
+ import './schema-BOszzrbQ.js';
6
+ import 'arctic';
7
+ import 'kysely';
8
+
9
+ declare function toSolidStartHandler(auth: Auth | Auth["handler"]): {
10
+ GET: (event: {
11
+ request: Request;
12
+ }) => Promise<Response>;
13
+ POST: (event: {
14
+ request: Request;
15
+ }) => Promise<Response>;
16
+ };
17
+
18
+ export { toSolidStartHandler };
@@ -0,0 +1,14 @@
1
+ // src/integrations/solid-start.ts
2
+ function toSolidStartHandler(auth) {
3
+ const handler = async (event) => {
4
+ return "handler" in auth ? auth.handler(event.request) : auth(event.request);
5
+ };
6
+ return {
7
+ GET: handler,
8
+ POST: handler
9
+ };
10
+ }
11
+ export {
12
+ toSolidStartHandler
13
+ };
14
+ //# sourceMappingURL=solid-start.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/integrations/solid-start.ts"],"sourcesContent":["import type { Auth } from \"../auth\";\n\nexport function toSolidStartHandler(auth: Auth | Auth[\"handler\"]) {\n\tconst handler = async (event: {\n\t\trequest: Request;\n\t}) => {\n\t\treturn \"handler\" in auth\n\t\t\t? auth.handler(event.request)\n\t\t\t: auth(event.request);\n\t};\n\treturn {\n\t\tGET: handler,\n\t\tPOST: handler,\n\t};\n}\n"],"mappings":";AAEO,SAAS,oBAAoB,MAA8B;AACjE,QAAM,UAAU,OAAO,UAEjB;AACL,WAAO,aAAa,OACjB,KAAK,QAAQ,MAAM,OAAO,IAC1B,KAAK,MAAM,OAAO;AAAA,EACtB;AACA,SAAO;AAAA,IACN,KAAK;AAAA,IACL,MAAM;AAAA,EACP;AACD;","names":[]}