better-auth 0.3.2 → 0.3.3-beta.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.
@@ -1,6 +1,6 @@
1
- import { A as Adapter } from '../index-DHmaFGpa.js';
1
+ import { A as Adapter } from '../index-B8Y4Ky8v.js';
2
2
  import 'kysely';
3
- import '../index-BlnDgm2S.js';
3
+ import '../index-DwNtr-kK.js';
4
4
  import 'arctic';
5
5
  import 'zod';
6
6
  import '../helper-DPDj8Nix.js';
@@ -1,7 +1,7 @@
1
1
  import { Db } from 'mongodb';
2
- import { W as Where } from '../index-DHmaFGpa.js';
2
+ import { W as Where } from '../index-B8Y4Ky8v.js';
3
3
  import 'kysely';
4
- import '../index-BlnDgm2S.js';
4
+ import '../index-DwNtr-kK.js';
5
5
  import 'arctic';
6
6
  import 'zod';
7
7
  import '../helper-DPDj8Nix.js';
@@ -1,6 +1,6 @@
1
- import { A as Adapter } from '../index-DHmaFGpa.js';
1
+ import { A as Adapter } from '../index-B8Y4Ky8v.js';
2
2
  import 'kysely';
3
- import '../index-BlnDgm2S.js';
3
+ import '../index-DwNtr-kK.js';
4
4
  import 'arctic';
5
5
  import 'zod';
6
6
  import '../helper-DPDj8Nix.js';
package/dist/api.d.ts CHANGED
@@ -1,9 +1,9 @@
1
- export { f as AuthEndpoint, g as AuthMiddleware, n as callbackOAuth, L as changePassword, e as createAuthEndpoint, d as createAuthMiddleware, D as createEmailVerificationToken, V as csrfMiddleware, N as deleteUser, Q as error, y as forgetPassword, z as forgetPasswordCallback, O as getCSRFToken, l as getEndpoints, p as getSession, q as getSessionFromCtx, u as listSessions, T as ok, o as optionsMiddleware, C as resetPassword, v as revokeSession, w as revokeSessions, r as router, E as sendVerificationEmail, t as sessionMiddleware, M as setPassword, m as signInEmail, s as signInOAuth, x as signOut, U as signUpEmail, K as updateUser, J as verifyEmail } from './index-DHmaFGpa.js';
1
+ export { f as AuthEndpoint, g as AuthMiddleware, n as callbackOAuth, L as changePassword, e as createAuthEndpoint, d as createAuthMiddleware, D as createEmailVerificationToken, V as csrfMiddleware, N as deleteUser, Q as error, y as forgetPassword, z as forgetPasswordCallback, O as getCSRFToken, l as getEndpoints, p as getSession, q as getSessionFromCtx, u as listSessions, T as ok, o as optionsMiddleware, C as resetPassword, v as revokeSession, w as revokeSessions, r as router, E as sendVerificationEmail, t as sessionMiddleware, M as setPassword, m as signInEmail, s as signInOAuth, x as signOut, U as signUpEmail, K as updateUser, J as verifyEmail } from './index-B8Y4Ky8v.js';
2
2
  import 'zod';
3
3
  import './helper-DPDj8Nix.js';
4
4
  import 'better-call';
5
5
  import 'kysely';
6
- import './index-BlnDgm2S.js';
6
+ import './index-DwNtr-kK.js';
7
7
  import 'arctic';
8
8
  import 'better-sqlite3';
9
9
  import 'mysql2';
package/dist/api.js CHANGED
@@ -362,26 +362,27 @@ var facebook = (options) => {
362
362
  // src/social-providers/github.ts
363
363
  import { betterFetch as betterFetch5 } from "@better-fetch/fetch";
364
364
  import { GitHub } from "arctic";
365
- var github = ({
366
- clientId,
367
- clientSecret,
368
- scope,
369
- redirectURI
370
- }) => {
365
+ var github = (options) => {
371
366
  const githubArctic = new GitHub(
372
- clientId,
373
- clientSecret,
374
- getRedirectURI("github", redirectURI)
367
+ options.clientId,
368
+ options.clientSecret,
369
+ getRedirectURI("github", options.redirectURI)
375
370
  );
371
+ const tokenEndpoint = "https://github.com/login/oauth/access_token";
376
372
  return {
377
373
  id: "github",
378
374
  name: "Github",
379
375
  createAuthorizationURL({ state, scopes }) {
380
- const _scopes = scope || scopes || ["user:email"];
376
+ const _scopes = options.scope || scopes || ["user:email"];
381
377
  return githubArctic.createAuthorizationURL(state, _scopes);
382
378
  },
383
- validateAuthorizationCode: async (state) => {
384
- return await githubArctic.validateAuthorizationCode(state);
379
+ validateAuthorizationCode: async (code, _, redirect) => {
380
+ return validateAuthorizationCode({
381
+ code,
382
+ redirectURI: options.redirectURI || getRedirectURI("google", redirect),
383
+ options,
384
+ tokenEndpoint
385
+ });
385
386
  },
386
387
  async getUserInfo(token) {
387
388
  const { data: profile, error: error2 } = await betterFetch5(
@@ -1388,7 +1389,6 @@ var callbackOAuth = createAuthEndpoint(
1388
1389
  ...user,
1389
1390
  id
1390
1391
  });
1391
- console.log({ user, data });
1392
1392
  const parsedState = parseState(c.query.state);
1393
1393
  if (!parsedState.success) {
1394
1394
  c.context.logger.error("Unable to parse state");
@@ -2,14 +2,14 @@ import * as nanostores from 'nanostores';
2
2
  import { A as AccessControl, S as StatementsPrimitive, R as Role } from '../statement-CfnyN34h.js';
3
3
  import * as _better_fetch_fetch from '@better-fetch/fetch';
4
4
  import { BetterFetchOption } from '@better-fetch/fetch';
5
- import { o as organization, f as Organization, M as Member, I as Invitation, u as username, m as magicLink, d as phoneNumber, e as anonymous } from '../index-8Ml1biZQ.js';
6
- export { g as getPasskeyActions, c as passkeyClient, a as twoFactorClient } from '../index-8Ml1biZQ.js';
5
+ import { o as organization, f as Organization, M as Member, I as Invitation, u as username, m as magicLink, d as phoneNumber, e as anonymous } from '../index-CdP51xBK.js';
6
+ export { g as getPasskeyActions, c as passkeyClient, a as twoFactorClient } from '../index-CdP51xBK.js';
7
7
  import { P as Prettify } from '../helper-DPDj8Nix.js';
8
- import '../index-BlnDgm2S.js';
8
+ import '../index-DwNtr-kK.js';
9
9
  import 'arctic';
10
10
  import 'zod';
11
11
  import 'better-call';
12
- import '../index-DHmaFGpa.js';
12
+ import '../index-B8Y4Ky8v.js';
13
13
  import 'kysely';
14
14
  import 'better-sqlite3';
15
15
  import 'mysql2';
package/dist/client.d.ts CHANGED
@@ -6,9 +6,9 @@ import { BetterFetch, BetterFetchError, BetterFetchOption } from '@better-fetch/
6
6
  import { U as UnionToIntersection, P as Prettify, S as StripEmptyObjects } from './helper-DPDj8Nix.js';
7
7
  import { ClientOptions, InferClientAPI, InferActions, InferAdditionalFromClient, InferSessionFromClient, InferUserFromClient, BetterAuthClientPlugin, IsSignal } from './types.js';
8
8
  export { AtomListener, InferPluginsFromClient } from './types.js';
9
- import './index-DHmaFGpa.js';
9
+ import './index-B8Y4Ky8v.js';
10
10
  import 'kysely';
11
- import './index-BlnDgm2S.js';
11
+ import './index-DwNtr-kK.js';
12
12
  import 'arctic';
13
13
  import 'better-call';
14
14
  import 'better-sqlite3';
@@ -1,5 +1,5 @@
1
1
  import { Kysely, Migration, PostgresPool, Dialect } from 'kysely';
2
- import { S as Session, U as User, A as Account, V as Verification, O as OAuthProvider, a as AppleProfile, D as DiscordProfile, F as FacebookProfile, G as GithubProfile, b as GoogleProfile, M as MicrosoftEntraIDProfile, c as SpotifyProfile, T as TwitchProfile, d as TwitterProfile, e as SocialProviders, f as OAuthProviderList } from './index-BlnDgm2S.js';
2
+ import { S as Session, U as User, A as Account, V as Verification, O as OAuthProvider, a as AppleProfile, D as DiscordProfile, F as FacebookProfile, G as GithubProfile, b as GoogleProfile, M as MicrosoftEntraIDProfile, c as SpotifyProfile, T as TwitchProfile, d as TwitterProfile, e as SocialProviders, f as OAuthProviderList } from './index-DwNtr-kK.js';
3
3
  import * as better_call from 'better-call';
4
4
  import { ContextTools, CookieOptions, Endpoint, EndpointResponse, Context, Prettify as Prettify$1 } from 'better-call';
5
5
  import * as arctic from 'arctic';
@@ -484,7 +484,7 @@ declare const init: (opts: BetterAuthOptions) => Promise<{
484
484
  scopes?: string[];
485
485
  redirectURI?: string;
486
486
  }): URL;
487
- validateAuthorizationCode: (state: string) => Promise<arctic.OAuth2Tokens>;
487
+ validateAuthorizationCode: (code: string, _: string | undefined, redirect: string | undefined) => Promise<arctic.OAuth2Tokens>;
488
488
  getUserInfo(token: arctic.OAuth2Tokens): Promise<{
489
489
  user: {
490
490
  id: string;
@@ -1263,17 +1263,17 @@ declare const signInOAuth: {
1263
1263
  /**
1264
1264
  * OAuth2 provider to use`
1265
1265
  */
1266
- provider: z.ZodEnum<["github", ...("apple" | "discord" | "facebook" | "github" | "google" | "microsoft" | "spotify" | "twitch" | "twitter")[]]>;
1266
+ provider: z.ZodEnum<["github", ...("github" | "apple" | "discord" | "facebook" | "microsoft" | "google" | "spotify" | "twitch" | "twitter")[]]>;
1267
1267
  /**
1268
1268
  * If this is true the session will only be valid for the current browser session
1269
1269
  */
1270
1270
  dontRememberMe: z.ZodOptional<z.ZodDefault<z.ZodBoolean>>;
1271
1271
  }, "strip", z.ZodTypeAny, {
1272
- provider: "apple" | "discord" | "facebook" | "github" | "google" | "microsoft" | "spotify" | "twitch" | "twitter";
1272
+ provider: "github" | "apple" | "discord" | "facebook" | "microsoft" | "google" | "spotify" | "twitch" | "twitter";
1273
1273
  callbackURL?: string | undefined;
1274
1274
  dontRememberMe?: boolean | undefined;
1275
1275
  }, {
1276
- provider: "apple" | "discord" | "facebook" | "github" | "google" | "microsoft" | "spotify" | "twitch" | "twitter";
1276
+ provider: "github" | "apple" | "discord" | "facebook" | "microsoft" | "google" | "spotify" | "twitch" | "twitter";
1277
1277
  callbackURL?: string | undefined;
1278
1278
  dontRememberMe?: boolean | undefined;
1279
1279
  }>;
@@ -1306,17 +1306,17 @@ declare const signInOAuth: {
1306
1306
  /**
1307
1307
  * OAuth2 provider to use`
1308
1308
  */
1309
- provider: z.ZodEnum<["github", ...("apple" | "discord" | "facebook" | "github" | "google" | "microsoft" | "spotify" | "twitch" | "twitter")[]]>;
1309
+ provider: z.ZodEnum<["github", ...("github" | "apple" | "discord" | "facebook" | "microsoft" | "google" | "spotify" | "twitch" | "twitter")[]]>;
1310
1310
  /**
1311
1311
  * If this is true the session will only be valid for the current browser session
1312
1312
  */
1313
1313
  dontRememberMe: z.ZodOptional<z.ZodDefault<z.ZodBoolean>>;
1314
1314
  }, "strip", z.ZodTypeAny, {
1315
- provider: "apple" | "discord" | "facebook" | "github" | "google" | "microsoft" | "spotify" | "twitch" | "twitter";
1315
+ provider: "github" | "apple" | "discord" | "facebook" | "microsoft" | "google" | "spotify" | "twitch" | "twitter";
1316
1316
  callbackURL?: string | undefined;
1317
1317
  dontRememberMe?: boolean | undefined;
1318
1318
  }, {
1319
- provider: "apple" | "discord" | "facebook" | "github" | "google" | "microsoft" | "spotify" | "twitch" | "twitter";
1319
+ provider: "github" | "apple" | "discord" | "facebook" | "microsoft" | "google" | "spotify" | "twitch" | "twitter";
1320
1320
  callbackURL?: string | undefined;
1321
1321
  dontRememberMe?: boolean | undefined;
1322
1322
  }>;
@@ -2465,14 +2465,14 @@ declare function getEndpoints<C extends AuthContext, Option extends BetterAuthOp
2465
2465
  }>>;
2466
2466
  body: zod.ZodObject<{
2467
2467
  callbackURL: zod.ZodOptional<zod.ZodString>;
2468
- provider: zod.ZodEnum<["github", ...("apple" | "discord" | "facebook" | "github" | "google" | "microsoft" | "spotify" | "twitch" | "twitter")[]]>;
2468
+ provider: zod.ZodEnum<["github", ...("github" | "apple" | "discord" | "facebook" | "microsoft" | "google" | "spotify" | "twitch" | "twitter")[]]>;
2469
2469
  dontRememberMe: zod.ZodOptional<zod.ZodDefault<zod.ZodBoolean>>;
2470
2470
  }, "strip", zod.ZodTypeAny, {
2471
- provider: "apple" | "discord" | "facebook" | "github" | "google" | "microsoft" | "spotify" | "twitch" | "twitter";
2471
+ provider: "github" | "apple" | "discord" | "facebook" | "microsoft" | "google" | "spotify" | "twitch" | "twitter";
2472
2472
  callbackURL?: string | undefined;
2473
2473
  dontRememberMe?: boolean | undefined;
2474
2474
  }, {
2475
- provider: "apple" | "discord" | "facebook" | "github" | "google" | "microsoft" | "spotify" | "twitch" | "twitter";
2475
+ provider: "github" | "apple" | "discord" | "facebook" | "microsoft" | "google" | "spotify" | "twitch" | "twitter";
2476
2476
  callbackURL?: string | undefined;
2477
2477
  dontRememberMe?: boolean | undefined;
2478
2478
  }>;
@@ -2495,14 +2495,14 @@ declare function getEndpoints<C extends AuthContext, Option extends BetterAuthOp
2495
2495
  }>>;
2496
2496
  body: zod.ZodObject<{
2497
2497
  callbackURL: zod.ZodOptional<zod.ZodString>;
2498
- provider: zod.ZodEnum<["github", ...("apple" | "discord" | "facebook" | "github" | "google" | "microsoft" | "spotify" | "twitch" | "twitter")[]]>;
2498
+ provider: zod.ZodEnum<["github", ...("github" | "apple" | "discord" | "facebook" | "microsoft" | "google" | "spotify" | "twitch" | "twitter")[]]>;
2499
2499
  dontRememberMe: zod.ZodOptional<zod.ZodDefault<zod.ZodBoolean>>;
2500
2500
  }, "strip", zod.ZodTypeAny, {
2501
- provider: "apple" | "discord" | "facebook" | "github" | "google" | "microsoft" | "spotify" | "twitch" | "twitter";
2501
+ provider: "github" | "apple" | "discord" | "facebook" | "microsoft" | "google" | "spotify" | "twitch" | "twitter";
2502
2502
  callbackURL?: string | undefined;
2503
2503
  dontRememberMe?: boolean | undefined;
2504
2504
  }, {
2505
- provider: "apple" | "discord" | "facebook" | "github" | "google" | "microsoft" | "spotify" | "twitch" | "twitter";
2505
+ provider: "github" | "apple" | "discord" | "facebook" | "microsoft" | "google" | "spotify" | "twitch" | "twitter";
2506
2506
  callbackURL?: string | undefined;
2507
2507
  dontRememberMe?: boolean | undefined;
2508
2508
  }>;
@@ -3527,14 +3527,14 @@ declare const router: <C extends AuthContext, Option extends BetterAuthOptions>(
3527
3527
  }>>;
3528
3528
  body: zod.ZodObject<{
3529
3529
  callbackURL: zod.ZodOptional<zod.ZodString>;
3530
- provider: zod.ZodEnum<["github", ...("apple" | "discord" | "facebook" | "github" | "google" | "microsoft" | "spotify" | "twitch" | "twitter")[]]>;
3530
+ provider: zod.ZodEnum<["github", ...("github" | "apple" | "discord" | "facebook" | "microsoft" | "google" | "spotify" | "twitch" | "twitter")[]]>;
3531
3531
  dontRememberMe: zod.ZodOptional<zod.ZodDefault<zod.ZodBoolean>>;
3532
3532
  }, "strip", zod.ZodTypeAny, {
3533
- provider: "apple" | "discord" | "facebook" | "github" | "google" | "microsoft" | "spotify" | "twitch" | "twitter";
3533
+ provider: "github" | "apple" | "discord" | "facebook" | "microsoft" | "google" | "spotify" | "twitch" | "twitter";
3534
3534
  callbackURL?: string | undefined;
3535
3535
  dontRememberMe?: boolean | undefined;
3536
3536
  }, {
3537
- provider: "apple" | "discord" | "facebook" | "github" | "google" | "microsoft" | "spotify" | "twitch" | "twitter";
3537
+ provider: "github" | "apple" | "discord" | "facebook" | "microsoft" | "google" | "spotify" | "twitch" | "twitter";
3538
3538
  callbackURL?: string | undefined;
3539
3539
  dontRememberMe?: boolean | undefined;
3540
3540
  }>;
@@ -3557,14 +3557,14 @@ declare const router: <C extends AuthContext, Option extends BetterAuthOptions>(
3557
3557
  }>>;
3558
3558
  body: zod.ZodObject<{
3559
3559
  callbackURL: zod.ZodOptional<zod.ZodString>;
3560
- provider: zod.ZodEnum<["github", ...("apple" | "discord" | "facebook" | "github" | "google" | "microsoft" | "spotify" | "twitch" | "twitter")[]]>;
3560
+ provider: zod.ZodEnum<["github", ...("github" | "apple" | "discord" | "facebook" | "microsoft" | "google" | "spotify" | "twitch" | "twitter")[]]>;
3561
3561
  dontRememberMe: zod.ZodOptional<zod.ZodDefault<zod.ZodBoolean>>;
3562
3562
  }, "strip", zod.ZodTypeAny, {
3563
- provider: "apple" | "discord" | "facebook" | "github" | "google" | "microsoft" | "spotify" | "twitch" | "twitter";
3563
+ provider: "github" | "apple" | "discord" | "facebook" | "microsoft" | "google" | "spotify" | "twitch" | "twitter";
3564
3564
  callbackURL?: string | undefined;
3565
3565
  dontRememberMe?: boolean | undefined;
3566
3566
  }, {
3567
- provider: "apple" | "discord" | "facebook" | "github" | "google" | "microsoft" | "spotify" | "twitch" | "twitter";
3567
+ provider: "github" | "apple" | "discord" | "facebook" | "microsoft" | "google" | "spotify" | "twitch" | "twitter";
3568
3568
  callbackURL?: string | undefined;
3569
3569
  dontRememberMe?: boolean | undefined;
3570
3570
  }>;
@@ -4591,14 +4591,14 @@ declare const betterAuth: <O extends BetterAuthOptions>(options: O) => {
4591
4591
  }>>;
4592
4592
  body: zod.ZodObject<{
4593
4593
  callbackURL: zod.ZodOptional<zod.ZodString>;
4594
- provider: zod.ZodEnum<["github", ...("apple" | "discord" | "facebook" | "github" | "google" | "microsoft" | "spotify" | "twitch" | "twitter")[]]>;
4594
+ provider: zod.ZodEnum<["github", ...("github" | "apple" | "discord" | "facebook" | "microsoft" | "google" | "spotify" | "twitch" | "twitter")[]]>;
4595
4595
  dontRememberMe: zod.ZodOptional<zod.ZodDefault<zod.ZodBoolean>>;
4596
4596
  }, "strip", zod.ZodTypeAny, {
4597
- provider: "apple" | "discord" | "facebook" | "github" | "google" | "microsoft" | "spotify" | "twitch" | "twitter";
4597
+ provider: "github" | "apple" | "discord" | "facebook" | "microsoft" | "google" | "spotify" | "twitch" | "twitter";
4598
4598
  callbackURL?: string | undefined;
4599
4599
  dontRememberMe?: boolean | undefined;
4600
4600
  }, {
4601
- provider: "apple" | "discord" | "facebook" | "github" | "google" | "microsoft" | "spotify" | "twitch" | "twitter";
4601
+ provider: "github" | "apple" | "discord" | "facebook" | "microsoft" | "google" | "spotify" | "twitch" | "twitter";
4602
4602
  callbackURL?: string | undefined;
4603
4603
  dontRememberMe?: boolean | undefined;
4604
4604
  }>;
@@ -4621,14 +4621,14 @@ declare const betterAuth: <O extends BetterAuthOptions>(options: O) => {
4621
4621
  }>>;
4622
4622
  body: zod.ZodObject<{
4623
4623
  callbackURL: zod.ZodOptional<zod.ZodString>;
4624
- provider: zod.ZodEnum<["github", ...("apple" | "discord" | "facebook" | "github" | "google" | "microsoft" | "spotify" | "twitch" | "twitter")[]]>;
4624
+ provider: zod.ZodEnum<["github", ...("github" | "apple" | "discord" | "facebook" | "microsoft" | "google" | "spotify" | "twitch" | "twitter")[]]>;
4625
4625
  dontRememberMe: zod.ZodOptional<zod.ZodDefault<zod.ZodBoolean>>;
4626
4626
  }, "strip", zod.ZodTypeAny, {
4627
- provider: "apple" | "discord" | "facebook" | "github" | "google" | "microsoft" | "spotify" | "twitch" | "twitter";
4627
+ provider: "github" | "apple" | "discord" | "facebook" | "microsoft" | "google" | "spotify" | "twitch" | "twitter";
4628
4628
  callbackURL?: string | undefined;
4629
4629
  dontRememberMe?: boolean | undefined;
4630
4630
  }, {
4631
- provider: "apple" | "discord" | "facebook" | "github" | "google" | "microsoft" | "spotify" | "twitch" | "twitter";
4631
+ provider: "github" | "apple" | "discord" | "facebook" | "microsoft" | "google" | "spotify" | "twitch" | "twitter";
4632
4632
  callbackURL?: string | undefined;
4633
4633
  dontRememberMe?: boolean | undefined;
4634
4634
  }>;
@@ -1,11 +1,11 @@
1
- import { U as User, S as Session } from './index-BlnDgm2S.js';
1
+ import { U as User, S as Session } from './index-DwNtr-kK.js';
2
2
  import * as better_call from 'better-call';
3
3
  import { z, ZodObject, ZodOptional, ZodArray, ZodLiteral } from 'zod';
4
4
  import { P as Prettify } from './helper-DPDj8Nix.js';
5
5
  import { A as AccessControl, R as Role, S as StatementsPrimitive, g as defaultRoles } from './statement-CfnyN34h.js';
6
6
  import * as _better_fetch_fetch from '@better-fetch/fetch';
7
7
  import { BetterFetch, BetterFetchOption } from '@better-fetch/fetch';
8
- import { H as HookEndpointContext } from './index-DHmaFGpa.js';
8
+ import { H as HookEndpointContext } from './index-B8Y4Ky8v.js';
9
9
  import * as nanostores from 'nanostores';
10
10
  import { atom } from 'nanostores';
11
11
  import * as _simplewebauthn_types from '@simplewebauthn/types';
@@ -431,7 +431,7 @@ interface GithubProfile {
431
431
  }
432
432
  interface GithubOptions extends ProviderOptions {
433
433
  }
434
- declare const github: ({ clientId, clientSecret, scope, redirectURI, }: GithubOptions) => {
434
+ declare const github: (options: GithubOptions) => {
435
435
  id: "github";
436
436
  name: string;
437
437
  createAuthorizationURL({ state, scopes }: {
@@ -440,7 +440,7 @@ declare const github: ({ clientId, clientSecret, scope, redirectURI, }: GithubOp
440
440
  scopes?: string[];
441
441
  redirectURI?: string;
442
442
  }): URL;
443
- validateAuthorizationCode: (state: string) => Promise<arctic.OAuth2Tokens>;
443
+ validateAuthorizationCode: (code: string, _: string | undefined, redirect: string | undefined) => Promise<arctic.OAuth2Tokens>;
444
444
  getUserInfo(token: arctic.OAuth2Tokens): Promise<{
445
445
  user: {
446
446
  id: string;
@@ -751,7 +751,7 @@ declare const oAuthProviders: {
751
751
  data: FacebookProfile;
752
752
  } | null>;
753
753
  };
754
- github: ({ clientId, clientSecret, scope, redirectURI, }: GithubOptions) => {
754
+ github: (options: GithubOptions) => {
755
755
  id: "github";
756
756
  name: string;
757
757
  createAuthorizationURL({ state, scopes }: {
@@ -760,7 +760,7 @@ declare const oAuthProviders: {
760
760
  scopes?: string[];
761
761
  redirectURI?: string;
762
762
  }): URL;
763
- validateAuthorizationCode: (state: string) => Promise<arctic.OAuth2Tokens>;
763
+ validateAuthorizationCode: (code: string, _: string | undefined, redirect: string | undefined) => Promise<arctic.OAuth2Tokens>;
764
764
  getUserInfo(token: arctic.OAuth2Tokens): Promise<{
765
765
  user: {
766
766
  id: string;
package/dist/index.d.ts CHANGED
@@ -1,6 +1,6 @@
1
- export { a as Auth, X as betterAuth } from './index-DHmaFGpa.js';
1
+ export { a as Auth, X as betterAuth } from './index-B8Y4Ky8v.js';
2
2
  import 'kysely';
3
- import './index-BlnDgm2S.js';
3
+ import './index-DwNtr-kK.js';
4
4
  import 'arctic';
5
5
  import 'zod';
6
6
  import './helper-DPDj8Nix.js';
package/dist/index.js CHANGED
@@ -362,26 +362,27 @@ var facebook = (options) => {
362
362
  // src/social-providers/github.ts
363
363
  import { betterFetch as betterFetch5 } from "@better-fetch/fetch";
364
364
  import { GitHub } from "arctic";
365
- var github = ({
366
- clientId,
367
- clientSecret,
368
- scope,
369
- redirectURI
370
- }) => {
365
+ var github = (options) => {
371
366
  const githubArctic = new GitHub(
372
- clientId,
373
- clientSecret,
374
- getRedirectURI("github", redirectURI)
367
+ options.clientId,
368
+ options.clientSecret,
369
+ getRedirectURI("github", options.redirectURI)
375
370
  );
371
+ const tokenEndpoint = "https://github.com/login/oauth/access_token";
376
372
  return {
377
373
  id: "github",
378
374
  name: "Github",
379
375
  createAuthorizationURL({ state, scopes }) {
380
- const _scopes = scope || scopes || ["user:email"];
376
+ const _scopes = options.scope || scopes || ["user:email"];
381
377
  return githubArctic.createAuthorizationURL(state, _scopes);
382
378
  },
383
- validateAuthorizationCode: async (state) => {
384
- return await githubArctic.validateAuthorizationCode(state);
379
+ validateAuthorizationCode: async (code, _, redirect) => {
380
+ return validateAuthorizationCode({
381
+ code,
382
+ redirectURI: options.redirectURI || getRedirectURI("google", redirect),
383
+ options,
384
+ tokenEndpoint
385
+ });
385
386
  },
386
387
  async getUserInfo(token) {
387
388
  const { data: profile, error: error2 } = await betterFetch5(
@@ -1478,7 +1479,6 @@ var callbackOAuth = createAuthEndpoint(
1478
1479
  ...user,
1479
1480
  id
1480
1481
  });
1481
- console.log({ user, data });
1482
1482
  const parsedState = parseState(c.query.state);
1483
1483
  if (!parsedState.success) {
1484
1484
  c.context.logger.error("Unable to parse state");
package/dist/next-js.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { a as Auth } from './index-DHmaFGpa.js';
2
- import { U as User, S as Session } from './index-BlnDgm2S.js';
1
+ import { a as Auth } from './index-B8Y4Ky8v.js';
2
+ import { U as User, S as Session } from './index-DwNtr-kK.js';
3
3
  import { NextRequest } from 'next/server';
4
4
  import 'kysely';
5
5
  import 'better-call';
package/dist/node.d.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  import * as http from 'http';
2
- import { a as Auth } from './index-DHmaFGpa.js';
2
+ import { a as Auth } from './index-B8Y4Ky8v.js';
3
3
  import 'kysely';
4
- import './index-BlnDgm2S.js';
4
+ import './index-DwNtr-kK.js';
5
5
  import 'arctic';
6
6
  import 'zod';
7
7
  import './helper-DPDj8Nix.js';
package/dist/plugins.d.ts CHANGED
@@ -1,8 +1,8 @@
1
- export { O as OrganizationOptions, b as Passkey, P as PasskeyOptions, e as anonymous, g as getPasskeyActions, m as magicLink, o as organization, p as passkey, c as passkeyClient, d as phoneNumber, t as twoFactor, a as twoFactorClient, u as username } from './index-8Ml1biZQ.js';
1
+ export { O as OrganizationOptions, b as Passkey, P as PasskeyOptions, e as anonymous, g as getPasskeyActions, m as magicLink, o as organization, p as passkey, c as passkeyClient, d as phoneNumber, t as twoFactor, a as twoFactorClient, u as username } from './index-CdP51xBK.js';
2
2
  export { i as ac } from './index-DfAHOgpj.js';
3
- import { b as AuthContext } from './index-DHmaFGpa.js';
4
- export { f as AuthEndpoint, g as AuthMiddleware, c as BetterAuthPlugin, P as PluginSchema, e as createAuthEndpoint, d as createAuthMiddleware, o as optionsMiddleware } from './index-DHmaFGpa.js';
5
- import './index-BlnDgm2S.js';
3
+ import { b as AuthContext } from './index-B8Y4Ky8v.js';
4
+ export { f as AuthEndpoint, g as AuthMiddleware, c as BetterAuthPlugin, P as PluginSchema, e as createAuthEndpoint, d as createAuthMiddleware, o as optionsMiddleware } from './index-B8Y4Ky8v.js';
5
+ import './index-DwNtr-kK.js';
6
6
  import 'arctic';
7
7
  import 'zod';
8
8
  import './helper-DPDj8Nix.js';
package/dist/plugins.js CHANGED
@@ -300,26 +300,27 @@ var facebook = (options) => {
300
300
  // src/social-providers/github.ts
301
301
  import { betterFetch as betterFetch5 } from "@better-fetch/fetch";
302
302
  import { GitHub } from "arctic";
303
- var github = ({
304
- clientId,
305
- clientSecret,
306
- scope,
307
- redirectURI
308
- }) => {
303
+ var github = (options) => {
309
304
  const githubArctic = new GitHub(
310
- clientId,
311
- clientSecret,
312
- getRedirectURI("github", redirectURI)
305
+ options.clientId,
306
+ options.clientSecret,
307
+ getRedirectURI("github", options.redirectURI)
313
308
  );
309
+ const tokenEndpoint = "https://github.com/login/oauth/access_token";
314
310
  return {
315
311
  id: "github",
316
312
  name: "Github",
317
313
  createAuthorizationURL({ state, scopes }) {
318
- const _scopes = scope || scopes || ["user:email"];
314
+ const _scopes = options.scope || scopes || ["user:email"];
319
315
  return githubArctic.createAuthorizationURL(state, _scopes);
320
316
  },
321
- validateAuthorizationCode: async (state) => {
322
- return await githubArctic.validateAuthorizationCode(state);
317
+ validateAuthorizationCode: async (code, _, redirect) => {
318
+ return validateAuthorizationCode({
319
+ code,
320
+ redirectURI: options.redirectURI || getRedirectURI("google", redirect),
321
+ options,
322
+ tokenEndpoint
323
+ });
323
324
  },
324
325
  async getUserInfo(token) {
325
326
  const { data: profile, error: error2 } = await betterFetch5(
@@ -1272,7 +1273,6 @@ var callbackOAuth = createAuthEndpoint(
1272
1273
  ...user,
1273
1274
  id
1274
1275
  });
1275
- console.log({ user, data });
1276
1276
  const parsedState = parseState(c.query.state);
1277
1277
  if (!parsedState.success) {
1278
1278
  c.context.logger.error("Unable to parse state");
package/dist/react.d.ts CHANGED
@@ -3,9 +3,9 @@ import { U as UnionToIntersection, P as Prettify, S as StripEmptyObjects } from
3
3
  import { ClientOptions, InferClientAPI, InferActions, InferAdditionalFromClient, BetterAuthClientPlugin, IsSignal } from './types.js';
4
4
  import { useStore } from '@nanostores/react';
5
5
  import 'zod';
6
- import './index-DHmaFGpa.js';
6
+ import './index-B8Y4Ky8v.js';
7
7
  import 'kysely';
8
- import './index-BlnDgm2S.js';
8
+ import './index-DwNtr-kK.js';
9
9
  import 'arctic';
10
10
  import 'better-call';
11
11
  import 'better-sqlite3';
package/dist/social.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- export { l as AppleOptions, a as AppleProfile, q as DiscordOptions, D as DiscordProfile, w as FacebookOptions, F as FacebookProfile, h as GithubOptions, G as GithubProfile, j as GoogleOptions, b as GoogleProfile, M as MicrosoftEntraIDProfile, n as MicrosoftOptions, O as OAuthProvider, f as OAuthProviderList, P as ProviderOptions, e as SocialProviders, s as SpotifyOptions, c as SpotifyProfile, u as TwitchOptions, T as TwitchProfile, y as TwitterOption, d as TwitterProfile, m as apple, r as discord, x as facebook, i as github, k as google, p as microsoft, g as oAuthProviderList, o as oAuthProviders, t as spotify, v as twitch, z as twitter } from './index-BlnDgm2S.js';
1
+ export { l as AppleOptions, a as AppleProfile, q as DiscordOptions, D as DiscordProfile, w as FacebookOptions, F as FacebookProfile, h as GithubOptions, G as GithubProfile, j as GoogleOptions, b as GoogleProfile, M as MicrosoftEntraIDProfile, n as MicrosoftOptions, O as OAuthProvider, f as OAuthProviderList, P as ProviderOptions, e as SocialProviders, s as SpotifyOptions, c as SpotifyProfile, u as TwitchOptions, T as TwitchProfile, y as TwitterOption, d as TwitterProfile, m as apple, r as discord, x as facebook, i as github, k as google, p as microsoft, g as oAuthProviderList, o as oAuthProviders, t as spotify, v as twitch, z as twitter } from './index-DwNtr-kK.js';
2
2
  import 'arctic';
3
3
  import './helper-DPDj8Nix.js';
4
4
  import 'zod';
package/dist/social.js CHANGED
@@ -259,26 +259,27 @@ var facebook = (options) => {
259
259
  // src/social-providers/github.ts
260
260
  import { betterFetch as betterFetch5 } from "@better-fetch/fetch";
261
261
  import { GitHub } from "arctic";
262
- var github = ({
263
- clientId,
264
- clientSecret,
265
- scope,
266
- redirectURI
267
- }) => {
262
+ var github = (options) => {
268
263
  const githubArctic = new GitHub(
269
- clientId,
270
- clientSecret,
271
- getRedirectURI("github", redirectURI)
264
+ options.clientId,
265
+ options.clientSecret,
266
+ getRedirectURI("github", options.redirectURI)
272
267
  );
268
+ const tokenEndpoint = "https://github.com/login/oauth/access_token";
273
269
  return {
274
270
  id: "github",
275
271
  name: "Github",
276
272
  createAuthorizationURL({ state, scopes }) {
277
- const _scopes = scope || scopes || ["user:email"];
273
+ const _scopes = options.scope || scopes || ["user:email"];
278
274
  return githubArctic.createAuthorizationURL(state, _scopes);
279
275
  },
280
- validateAuthorizationCode: async (state) => {
281
- return await githubArctic.validateAuthorizationCode(state);
276
+ validateAuthorizationCode: async (code, _, redirect) => {
277
+ return validateAuthorizationCode({
278
+ code,
279
+ redirectURI: options.redirectURI || getRedirectURI("google", redirect),
280
+ options,
281
+ tokenEndpoint
282
+ });
282
283
  },
283
284
  async getUserInfo(token) {
284
285
  const { data: profile, error } = await betterFetch5(
@@ -1,6 +1,6 @@
1
- import { a as Auth } from './index-DHmaFGpa.js';
1
+ import { a as Auth } from './index-B8Y4Ky8v.js';
2
2
  import 'kysely';
3
- import './index-BlnDgm2S.js';
3
+ import './index-DwNtr-kK.js';
4
4
  import 'arctic';
5
5
  import 'zod';
6
6
  import './helper-DPDj8Nix.js';
package/dist/solid.d.ts CHANGED
@@ -3,9 +3,9 @@ import { U as UnionToIntersection, P as Prettify, S as StripEmptyObjects } from
3
3
  import { ClientOptions, InferClientAPI, InferActions, InferAdditionalFromClient, BetterAuthClientPlugin, IsSignal } from './types.js';
4
4
  import { Accessor } from 'solid-js';
5
5
  import 'zod';
6
- import './index-DHmaFGpa.js';
6
+ import './index-B8Y4Ky8v.js';
7
7
  import 'kysely';
8
- import './index-BlnDgm2S.js';
8
+ import './index-DwNtr-kK.js';
9
9
  import 'arctic';
10
10
  import 'better-call';
11
11
  import 'better-sqlite3';
@@ -1,6 +1,6 @@
1
- import { a as Auth, B as BetterAuthOptions } from './index-DHmaFGpa.js';
1
+ import { a as Auth, B as BetterAuthOptions } from './index-B8Y4Ky8v.js';
2
2
  import 'kysely';
3
- import './index-BlnDgm2S.js';
3
+ import './index-DwNtr-kK.js';
4
4
  import 'arctic';
5
5
  import 'zod';
6
6
  import './helper-DPDj8Nix.js';
package/dist/svelte.d.ts CHANGED
@@ -3,9 +3,9 @@ import * as _better_fetch_fetch from '@better-fetch/fetch';
3
3
  import { U as UnionToIntersection, P as Prettify, S as StripEmptyObjects } from './helper-DPDj8Nix.js';
4
4
  import { ClientOptions, InferClientAPI, InferActions, InferAdditionalFromClient, BetterAuthClientPlugin, IsSignal } from './types.js';
5
5
  import 'zod';
6
- import './index-DHmaFGpa.js';
6
+ import './index-B8Y4Ky8v.js';
7
7
  import 'kysely';
8
- import './index-BlnDgm2S.js';
8
+ import './index-DwNtr-kK.js';
9
9
  import 'arctic';
10
10
  import 'better-call';
11
11
  import 'better-sqlite3';
package/dist/types.d.ts CHANGED
@@ -1,9 +1,9 @@
1
- import { c as BetterAuthPlugin, a as Auth, F as FieldAttribute, I as InferFieldOutput } from './index-DHmaFGpa.js';
2
- export { A as Adapter, b as AuthContext, B as BetterAuthOptions, G as GenericEndpointContext, H as HookEndpointContext, j as InferPluginTypes, i as InferSession, h as InferUser, P as PluginSchema, R as RateLimit, S as SessionAdapter, W as Where, k as init } from './index-DHmaFGpa.js';
1
+ import { c as BetterAuthPlugin, a as Auth, F as FieldAttribute, I as InferFieldOutput } from './index-B8Y4Ky8v.js';
2
+ export { A as Adapter, b as AuthContext, B as BetterAuthOptions, G as GenericEndpointContext, H as HookEndpointContext, j as InferPluginTypes, i as InferSession, h as InferUser, P as PluginSchema, R as RateLimit, S as SessionAdapter, W as Where, k as init } from './index-B8Y4Ky8v.js';
3
3
  import { U as UnionToIntersection, H as HasRequiredKeys, P as Prettify, S as StripEmptyObjects, L as LiteralString } from './helper-DPDj8Nix.js';
4
4
  export { D as DeepPartial, a as LiteralUnion, R as RequiredKeysOf, W as WithoutEmpty } from './helper-DPDj8Nix.js';
5
- import { S as Session, U as User } from './index-BlnDgm2S.js';
6
- export { O as OAuthProvider, f as OAuthProviderList, P as ProviderOptions } from './index-BlnDgm2S.js';
5
+ import { S as Session, U as User } from './index-DwNtr-kK.js';
6
+ export { O as OAuthProvider, f as OAuthProviderList, P as ProviderOptions } from './index-DwNtr-kK.js';
7
7
  import { BetterFetchOption, BetterFetchResponse, BetterFetch, BetterFetchPlugin } from '@better-fetch/fetch';
8
8
  import { Atom } from 'nanostores';
9
9
  import { Endpoint, Context } from 'better-call';
package/dist/vue.d.ts CHANGED
@@ -3,9 +3,9 @@ import { U as UnionToIntersection, P as Prettify, S as StripEmptyObjects } from
3
3
  import { ClientOptions, InferClientAPI, InferActions, InferAdditionalFromClient, BetterAuthClientPlugin, IsSignal } from './types.js';
4
4
  import { Ref, DeepReadonly } from 'vue';
5
5
  import 'zod';
6
- import './index-DHmaFGpa.js';
6
+ import './index-B8Y4Ky8v.js';
7
7
  import 'kysely';
8
- import './index-BlnDgm2S.js';
8
+ import './index-DwNtr-kK.js';
9
9
  import 'arctic';
10
10
  import 'better-call';
11
11
  import 'better-sqlite3';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "better-auth",
3
- "version": "0.3.2",
3
+ "version": "0.3.3-beta.2",
4
4
  "description": "The most comprehensive authentication library for TypeScript.",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",