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,3 +0,0 @@
1
- export { d as CustomProvider, K as DiscordProfile, u as FacebookOptions, F as FacebookProfile, r as GitHubOptions, x as GitLabProfile, p as GoogleProfile, O as OAuthProvider, n as OIDCProvider, c as Provider, o as ProviderOptions, m as ProviderType, P as Providers, J as Twitch, E as TwitchOptions, D as TwitchProfile, w as apple, t as credential, L as discord, v as facebook, s as github, y as gitlab, q as google, M as magicLink, z as spotify } from './options-CH15FEBw.js';
2
- import './types-DAxaMWCy.js';
3
- import 'zod';
package/dist/providers.js DELETED
@@ -1,653 +0,0 @@
1
- // src/jwt/index.ts
2
- import { SignJWT, decodeJwt, jwtVerify } from "jose";
3
- function parseJWT(jwt) {
4
- const decoded = decodeJwt(jwt);
5
- return decoded;
6
- }
7
- function validateJWT(jwt, secret) {
8
- return jwtVerify(jwt, new TextEncoder().encode(secret));
9
- }
10
- function createJWT({
11
- payload,
12
- secret,
13
- expiresIn,
14
- algorithm
15
- }) {
16
- return new SignJWT(payload).setProtectedHeader({
17
- alg: algorithm || "HS256"
18
- }).setExpirationTime(Math.floor(Date.now() / 1e3) + expiresIn).sign(new TextEncoder().encode(secret));
19
- }
20
-
21
- // src/providers/google.ts
22
- var google = (options) => {
23
- return {
24
- id: "google",
25
- name: "Google",
26
- type: "oidc",
27
- nonce: true,
28
- params: {
29
- clientId: options.clientId,
30
- clientSecret: options.clientSecret,
31
- linkAccounts: options.linkAccounts,
32
- redirectURL: options.redirectURL,
33
- tokenEndpoint: "https://oauth2.googleapis.com/token",
34
- authorizationEndpoint: "https://accounts.google.com/o/oauth2/v2/auth"
35
- },
36
- issuer: "https://accounts.google.com",
37
- scopes: options.scopes || ["openid", "email", "profile"],
38
- pkCodeVerifier: true,
39
- async getUserInfo(tokens) {
40
- const idToken = tokens?.id_token;
41
- const user = parseJWT(idToken);
42
- const profile = {
43
- ...user,
44
- id: user.sub
45
- };
46
- return profile;
47
- }
48
- };
49
- };
50
-
51
- // src/providers/github.ts
52
- var github = (options) => {
53
- return {
54
- id: "github",
55
- name: "Github",
56
- type: "oauth",
57
- params: {
58
- clientId: options.clientId,
59
- clientSecret: options.clientSecret,
60
- redirectURL: options.redirectURL,
61
- linkAccounts: options.linkAccounts,
62
- tokenEndpoint: "https://github.com/login/oauth/access_token",
63
- authorizationEndpoint: "https://github.com/login/oauth/authorize",
64
- extra: {
65
- allow_signup: options.allowSignup === void 0 ? "true" : options.allowSignup ? "true" : "false"
66
- }
67
- },
68
- scopes: options.scopes || ["read:user user:email"],
69
- async getUserInfo(tokens) {
70
- const response = await fetch("https://api.github.com/user", {
71
- headers: {
72
- Authorization: `Bearer ${tokens.access_token}`
73
- }
74
- });
75
- const profile = await response.json();
76
- if (!profile.email) {
77
- const res = await fetch("https://api.github.com/user/emails", {
78
- headers: {
79
- Authorization: `Bearer ${tokens.access_token}`,
80
- "User-Agent": "better-auth"
81
- }
82
- });
83
- if (res.ok) {
84
- const emails = await res.json();
85
- profile.email = (emails.find((e) => e.primary) ?? emails[0])?.email;
86
- }
87
- }
88
- return {
89
- ...profile,
90
- id: profile.id,
91
- first_name: profile.name.split(" ")[0] || "",
92
- last_name: profile.name.split(" ")[1] || ""
93
- };
94
- }
95
- };
96
- };
97
-
98
- // ../shared/src/error.ts
99
- var BetterAuthError = class extends Error {
100
- constructor(message) {
101
- super(`${message}`);
102
- this.name = this.constructor.name;
103
- Object.setPrototypeOf(this, new.target.prototype);
104
- Error.captureStackTrace(this, this.constructor);
105
- }
106
- };
107
-
108
- // src/providers/credential.ts
109
- import { z } from "zod";
110
-
111
- // src/crypto/password.ts
112
- import * as argon2 from "argon2";
113
-
114
- // src/crypto/random.ts
115
- function generateRandomString(size) {
116
- const i2hex = (i) => `0${i.toString(16)}`.slice(-2);
117
- const r = (a, i) => a + i2hex(i);
118
- const bytes = crypto.getRandomValues(new Uint8Array(size));
119
- return Array.from(bytes).reduce(r, "");
120
- }
121
-
122
- // src/crypto/password.ts
123
- var hashPassword = async (password, secret) => {
124
- const salt = generateRandomString(12);
125
- const hash2 = await argon2.hash(password, {
126
- type: argon2.argon2id,
127
- salt: Buffer.from(salt),
128
- secret: Buffer.from(secret)
129
- });
130
- return hash2;
131
- };
132
- var validatePassword = async (password, hash2, secret) => {
133
- const res = await argon2.verify(hash2, password, {
134
- secret: Buffer.from(secret)
135
- });
136
- return res;
137
- };
138
-
139
- // src/cookies/index.ts
140
- function setSessionCookie(context, sessionId) {
141
- context.request.cookies.set(
142
- context.cookies.sessionToken.name,
143
- sessionId,
144
- context.cookies.sessionToken.options
145
- );
146
- }
147
-
148
- // src/utils/session.ts
149
- var createSession = async (userId, context) => {
150
- const session = await context.adapter.createSession(userId, context);
151
- setSessionCookie(context, session.id);
152
- return session;
153
- };
154
-
155
- // src/providers/credential.ts
156
- var credential = (options) => {
157
- const input = z.object({
158
- email: z.string(),
159
- password: z.string()
160
- });
161
- return {
162
- id: "credential",
163
- name: "Credential",
164
- type: "custom",
165
- async signIn(context) {
166
- const {
167
- data: { email, password },
168
- currentURL,
169
- callbackURL
170
- } = z.object({
171
- data: z.object({
172
- email: z.string(),
173
- password: z.string()
174
- }),
175
- currentURL: z.string(),
176
- callbackURL: z.string()
177
- }).parse(context.request.body);
178
- const user = await context._db.findOne({
179
- model: context.user.modelName || "user",
180
- where: [
181
- {
182
- field: "email",
183
- value: email
184
- }
185
- ]
186
- });
187
- if (!user) {
188
- return {
189
- status: 401,
190
- body: {
191
- error: "user_not_found"
192
- }
193
- };
194
- }
195
- const passwordHash = user["password"];
196
- if (!passwordHash) {
197
- throw new BetterAuthError(
198
- "Password field is missing in the user table."
199
- );
200
- }
201
- try {
202
- const isValid = await validatePassword(
203
- password,
204
- passwordHash,
205
- context.secret
206
- );
207
- if (!isValid) {
208
- return {
209
- status: 401,
210
- body: {
211
- error: "invalid_password"
212
- }
213
- };
214
- }
215
- } catch (e) {
216
- return {
217
- status: 401,
218
- body: {
219
- error: "invalid_password"
220
- }
221
- };
222
- }
223
- await createSession(user.id, context);
224
- return {
225
- status: 200,
226
- body: {
227
- redirect: true,
228
- url: callbackURL
229
- }
230
- };
231
- },
232
- async signUp(context) {
233
- const { data, autoCreateSession, currentURL, callbackURL } = context.request.body;
234
- if (!data) {
235
- throw new BetterAuthError("Data is required for sign up.");
236
- }
237
- const userExist = await context.adapter.findUserByEmail(
238
- data["email"],
239
- context
240
- );
241
- if (userExist) {
242
- return {
243
- status: 400,
244
- body: {
245
- error: "user_already_exist"
246
- }
247
- };
248
- }
249
- const user = await context.adapter.createUser(
250
- {
251
- user: {
252
- ...data,
253
- ["password"]: await hashPassword(data["password"], context.secret),
254
- emailVerified: false
255
- },
256
- account: {
257
- providerId: "credential",
258
- accountId: data["email"]
259
- }
260
- },
261
- context
262
- );
263
- if (autoCreateSession) {
264
- await createSession(user.user.id, context);
265
- }
266
- return {
267
- status: 200,
268
- body: {
269
- redirect: true,
270
- url: callbackURL
271
- }
272
- };
273
- },
274
- input
275
- };
276
- };
277
-
278
- // src/providers/facebook.ts
279
- var facebook = (options) => {
280
- return {
281
- id: "facebook",
282
- name: "Facebook",
283
- type: "oauth",
284
- scopes: ["email", "public_profile"],
285
- params: {
286
- clientId: options.clientId,
287
- clientSecret: options.clientSecret,
288
- redirectURL: options.redirectURL,
289
- authorizationEndpoint: "https://www.facebook.com/v16.0/dialog/oauth",
290
- tokenEndpoint: "https://graph.facebook.com/v16.0/oauth/access_token"
291
- },
292
- async getUserInfo(tokens) {
293
- const result = await fetch(
294
- "https://graph.facebook.com/v16.0/me?fields=id,name,email,picture",
295
- {
296
- headers: {
297
- Authorization: `Bearer ${tokens.access_token}`
298
- }
299
- }
300
- ).then((res) => res.json()).then((res) => res);
301
- return {
302
- ...result,
303
- id: result.id,
304
- name: result.name,
305
- email: result.email,
306
- emailVerified: true
307
- };
308
- }
309
- };
310
- };
311
-
312
- // src/providers/apple.ts
313
- var apple = (options) => {
314
- const authorizationEndpoint = "https://appleid.apple.com/auth/authorize";
315
- const tokenEndpoint = "https://appleid.apple.com/auth/token";
316
- return {
317
- id: "apple",
318
- name: "Apple",
319
- type: "oidc",
320
- params: {
321
- authorizationEndpoint,
322
- tokenEndpoint,
323
- linkAccounts: options.linkAccounts,
324
- redirectURL: options.redirectURL,
325
- clientId: options.clientId,
326
- clientSecret: options.clientSecret
327
- },
328
- issuer: "https://appleid.apple.com",
329
- scopes: options.scopes || ["email", "name"],
330
- async getUserInfo(tokens) {
331
- const idToken = tokens?.id_token;
332
- const user = parseJWT(idToken)?.payload;
333
- const profile = {
334
- ...user,
335
- id: user.sub,
336
- email: user.email,
337
- emailVerified: true
338
- };
339
- return profile;
340
- }
341
- };
342
- };
343
-
344
- // src/providers/gitlab.ts
345
- var gitlab = (options) => {
346
- const domain = options?.domain ?? "https://gitlab.com";
347
- const authorizationEndpoint = `${domain}/oauth/authorize`;
348
- const tokenEndpoint = `${domain}/oauth/token`;
349
- return {
350
- id: "gitlab",
351
- name: "Gitlab",
352
- type: "oauth",
353
- scopes: ["read_user"],
354
- params: {
355
- clientId: options.clientId,
356
- clientSecret: options.clientSecret,
357
- redirectURL: options.redirectURL,
358
- authorizationEndpoint,
359
- tokenEndpoint
360
- },
361
- async getUserInfo(tokens) {
362
- const headers = {
363
- Authorization: `Bearer ${tokens.access_token}`
364
- };
365
- const result = await fetch("https://gitlab.com/api/v4/user", {
366
- headers
367
- }).then((res) => res.json()).then((res) => res);
368
- return {
369
- ...result,
370
- id: result.id.toString(),
371
- email: result.public_email,
372
- emailVerified: true,
373
- image: result.avatar_url
374
- };
375
- }
376
- };
377
- };
378
-
379
- // src/providers/spotify.ts
380
- var spotify = (options) => {
381
- return {
382
- id: "spotify",
383
- name: "Spotify",
384
- type: "oauth",
385
- scopes: ["user-read-email"],
386
- params: {
387
- clientId: options.clientId,
388
- clientSecret: options.clientSecret,
389
- redirectURL: options.redirectURL,
390
- authorizationEndpoint: "https://accounts.spotify.com/authorize",
391
- tokenEndpoint: "https://accounts.spotify.com/api/token"
392
- },
393
- async getUserInfo(tokens) {
394
- const profile = await fetch("https://api.spotify.com/v1/me", {
395
- headers: {
396
- Authorization: `Bearer ${tokens.access_token}`
397
- }
398
- }).then((res) => res.json()).then((res) => res);
399
- return {
400
- ...profile,
401
- id: profile.id,
402
- email: profile.email,
403
- emailVerified: true,
404
- name: profile.display_name,
405
- image: profile.images[0]?.url
406
- };
407
- }
408
- };
409
- };
410
-
411
- // src/providers/twitch.ts
412
- var Twitch = (options) => {
413
- const authorizeEndpoint = "https://id.twitch.tv/oauth2/authorize";
414
- const tokenEndpoint = "https://id.twitch.tv/oauth2/token";
415
- return {
416
- id: "twitch",
417
- name: "Twitch",
418
- type: "oauth",
419
- scopes: options.scopes ?? ["openid user:read:email"],
420
- params: {
421
- clientId: options.clientId,
422
- linkAccounts: options.linkAccounts,
423
- clientSecret: options.clientSecret,
424
- redirectURL: options.redirectURL,
425
- authorizationEndpoint: authorizeEndpoint,
426
- tokenEndpoint
427
- },
428
- async getUserInfo(tokens) {
429
- const headers = {
430
- Authorization: `Bearer ${tokens.access_token}`
431
- };
432
- const result = await fetch("https://api.twitch.tv/helix/users", {
433
- headers
434
- }).then((res) => res.json()).then((res) => res.data[0]);
435
- return {
436
- ...result,
437
- id: result.sub,
438
- email: result.email,
439
- emailVerified: true,
440
- name: result.preferred_username,
441
- image: result.picture
442
- };
443
- }
444
- };
445
- };
446
-
447
- // src/providers/discord.ts
448
- var discord = (options) => {
449
- const authorizeEndpoint = "https://discord.com/oauth2/authorize";
450
- const tokenEndpoint = "https://discord.com/api/oauth2/token";
451
- return {
452
- id: "discord",
453
- name: "Discord",
454
- type: "oauth",
455
- params: {
456
- clientId: options.clientId,
457
- clientSecret: options.clientSecret,
458
- linkAccounts: options.linkAccounts,
459
- authorizationEndpoint: authorizeEndpoint,
460
- tokenEndpoint,
461
- redirectURL: options.redirectURL
462
- },
463
- scopes: options.scopes || ["identify", "email"],
464
- async getUserInfo(tokens) {
465
- const profile = await fetch("https://discord.com/api/users/@me", {
466
- headers: {
467
- Authorization: `Bearer ${tokens.access_token}`
468
- }
469
- }).then((res) => res.json()).then((res) => res);
470
- if (profile.avatar === null) {
471
- const defaultAvatarNumber = profile.discriminator === "0" ? Number(BigInt(profile.id) >> BigInt(22)) % 6 : Number.parseInt(profile.discriminator) % 5;
472
- profile.image_url = `https://cdn.discordapp.com/embed/avatars/${defaultAvatarNumber}.png`;
473
- } else {
474
- const format = profile.avatar.startsWith("a_") ? "gif" : "png";
475
- profile.image_url = `https://cdn.discordapp.com/avatars/${profile.id}/${profile.avatar}.${format}`;
476
- }
477
- return {
478
- ...profile,
479
- id: profile.id,
480
- email: profile.email,
481
- name: profile.global_name || profile.username,
482
- emailVerified: profile.verified || false,
483
- image: profile.image_url
484
- };
485
- }
486
- };
487
- };
488
-
489
- // src/providers/magic-link.ts
490
- import { base64url } from "jose";
491
- import { z as z2 } from "zod";
492
- var magicLink = (options) => {
493
- const schema = z2.object({
494
- callbackURL: z2.string(),
495
- currentURL: z2.string(),
496
- allowSignUp: z2.boolean().default(false),
497
- data: z2.object({
498
- email: z2.string()
499
- }).and(z2.record(z2.string(), z2.any()))
500
- });
501
- async function signIn(context) {
502
- const data = schema.safeParse(context.request.body);
503
- if (data.error) {
504
- return {
505
- status: 400,
506
- statusText: "Invalid Data"
507
- };
508
- }
509
- const {
510
- data: { email },
511
- currentURL,
512
- callbackURL
513
- } = data.data;
514
- let user = await context.adapter.findUserByEmail(email, context);
515
- const redirect = callbackURL ? {
516
- error: options?.redirect?.error || currentURL,
517
- success: formatURL(callbackURL, currentURL)
518
- } : {
519
- error: options?.redirect?.error || currentURL,
520
- success: options?.redirect?.success || new URL(currentURL).origin
521
- };
522
- if (!user) {
523
- if (data.data.allowSignUp) {
524
- if (!data.data.data) {
525
- return {
526
- status: 400,
527
- statusText: "Invalid User Registration Data"
528
- };
529
- }
530
- const response = await context.adapter.createUser(
531
- {
532
- user: data.data.data,
533
- account: {
534
- providerId: "magic_link",
535
- accountId: email
536
- }
537
- },
538
- context
539
- );
540
- user = response.user;
541
- } else {
542
- return {
543
- status: 302,
544
- Location: `${redirect.error}?error=user_doesn't_exist`
545
- };
546
- }
547
- }
548
- const token = await createJWT({
549
- payload: {
550
- email,
551
- redirect: {
552
- error: formatURL(redirect.error, currentURL),
553
- redirect: formatURL(redirect.error, currentURL)
554
- }
555
- },
556
- secret: context.secret,
557
- expiresIn: 60 * 60 * 2
558
- });
559
- const encoded = base64url.encode(token);
560
- const url = `${context.request.url.toString()}/magic-link/verify?token=${encoded}`;
561
- await options?.sendEmail(email, url);
562
- return {
563
- status: 200,
564
- body: {
565
- success: true
566
- }
567
- };
568
- }
569
- return {
570
- id: "magic-link",
571
- name: "magic-link",
572
- type: "custom",
573
- signIn,
574
- async signUp(context) {
575
- const data = schema.parse(context.request.body);
576
- const user = await context.adapter.findUserByEmail(
577
- data.data.email,
578
- context
579
- );
580
- if (user) {
581
- return {
582
- status: 302,
583
- Location: `${data.currentURL}?error=user_already_exists`
584
- };
585
- }
586
- return await signIn({
587
- ...context,
588
- request: {
589
- ...context.request,
590
- body: data
591
- }
592
- });
593
- },
594
- handler: {
595
- matcher: (context) => context.request.action.startsWith("magic-link"),
596
- handler: async (context) => {
597
- const token = context.request.url.searchParams.get("token");
598
- if (!token) {
599
- return {
600
- status: 403
601
- };
602
- }
603
- const decoded = new TextDecoder().decode(base64url.decode(token));
604
- const isValid = await validateJWT(decoded, context.secret);
605
- if (!isValid) {
606
- return {
607
- status: 403
608
- };
609
- }
610
- const payload = parseJWT(decoded);
611
- const user = await context.adapter.findUserByEmail(
612
- payload.email,
613
- context
614
- );
615
- if (!user) {
616
- return {
617
- status: 302,
618
- Location: `${payload.redirect.error}?error=user_not_found`
619
- };
620
- }
621
- await createSession(user.id, context);
622
- return {
623
- status: 200
624
- };
625
- }
626
- },
627
- input: z2.object({
628
- email: z2.string()
629
- })
630
- };
631
- };
632
- function formatURL(pathOrURL, currentURL) {
633
- if (pathOrURL.startsWith("/")) {
634
- return `${new URL(currentURL).origin}/${pathOrURL}`;
635
- }
636
- if (pathOrURL.startsWith("http")) {
637
- return pathOrURL;
638
- }
639
- throw new BetterAuthError("Redirect url passed in magic links are invalid.");
640
- }
641
- export {
642
- Twitch,
643
- apple,
644
- credential,
645
- discord,
646
- facebook,
647
- github,
648
- gitlab,
649
- google,
650
- magicLink,
651
- spotify
652
- };
653
- //# sourceMappingURL=providers.js.map