better-auth 1.7.1 → 1.7.3

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 (77) hide show
  1. package/dist/api/index.d.mts +6 -22
  2. package/dist/api/index.mjs +2 -0
  3. package/dist/api/middlewares/origin-check.mjs +9 -5
  4. package/dist/api/routes/account.d.mts +1 -9
  5. package/dist/api/routes/account.mjs +0 -6
  6. package/dist/api/routes/callback.mjs +7 -7
  7. package/dist/api/routes/email-verification.mjs +4 -2
  8. package/dist/api/routes/error.mjs +12 -8
  9. package/dist/api/routes/password.mjs +0 -2
  10. package/dist/api/routes/session.mjs +12 -5
  11. package/dist/api/routes/sign-in.d.mts +2 -2
  12. package/dist/api/routes/sign-in.mjs +1 -4
  13. package/dist/api/routes/sign-up.mjs +0 -2
  14. package/dist/api/routes/update-user.mjs +0 -2
  15. package/dist/api/to-auth-endpoints.mjs +2 -0
  16. package/dist/auth/base.mjs +13 -1
  17. package/dist/auth/trusted-origins.mjs +24 -5
  18. package/dist/client/config.d.mts +2 -0
  19. package/dist/client/config.mjs +1 -0
  20. package/dist/client/lynx/index.d.mts +1 -1
  21. package/dist/client/react/index.d.mts +1 -1
  22. package/dist/client/solid/index.d.mts +1 -1
  23. package/dist/client/svelte/index.d.mts +1 -1
  24. package/dist/client/vanilla.d.mts +1 -1
  25. package/dist/client/vue/index.d.mts +32 -21
  26. package/dist/client/vue/index.mjs +23 -5
  27. package/dist/context/create-context.mjs +2 -0
  28. package/dist/cookies/cache.mjs +10 -2
  29. package/dist/cookies/session-store.d.mts +0 -1
  30. package/dist/cookies/session-store.mjs +16 -5
  31. package/dist/db/adapter-kysely.mjs +1 -2
  32. package/dist/db/get-migration.d.mts +1 -0
  33. package/dist/db/get-migration.mjs +49 -56
  34. package/dist/db/internal-adapter.mjs +17 -20
  35. package/dist/db/schema.d.mts +0 -1
  36. package/dist/db/with-hooks.mjs +7 -7
  37. package/dist/oauth2/account-key.mjs +1 -5
  38. package/dist/oauth2/errors.mjs +4 -3
  39. package/dist/oauth2/link-account.d.mts +0 -1
  40. package/dist/oauth2/link-account.mjs +5 -11
  41. package/dist/oauth2/state.mjs +1 -1
  42. package/dist/package.mjs +1 -1
  43. package/dist/plugins/admin/routes.mjs +1 -4
  44. package/dist/plugins/anonymous/index.mjs +5 -1
  45. package/dist/plugins/anonymous/types.d.mts +2 -3
  46. package/dist/plugins/device-authorization/index.d.mts +11 -11
  47. package/dist/plugins/email-otp/routes.mjs +0 -2
  48. package/dist/plugins/generic-oauth/index.mjs +14 -10
  49. package/dist/plugins/generic-oauth/providers/auth0.mjs +2 -4
  50. package/dist/plugins/generic-oauth/providers/keycloak.mjs +6 -9
  51. package/dist/plugins/generic-oauth/providers/line.mjs +0 -1
  52. package/dist/plugins/generic-oauth/providers/microsoft-entra-id.mjs +15 -5
  53. package/dist/plugins/generic-oauth/providers/okta.mjs +6 -9
  54. package/dist/plugins/generic-oauth/providers/slack.mjs +0 -1
  55. package/dist/plugins/generic-oauth/types.d.mts +0 -9
  56. package/dist/plugins/haveibeenpwned/index.d.mts +9 -1
  57. package/dist/plugins/haveibeenpwned/index.mjs +33 -13
  58. package/dist/plugins/index.d.mts +2 -2
  59. package/dist/plugins/index.mjs +2 -2
  60. package/dist/plugins/jwt/verify.mjs +2 -2
  61. package/dist/plugins/last-login-method/index.mjs +1 -0
  62. package/dist/plugins/oauth-proxy/index.d.mts +17 -0
  63. package/dist/plugins/oauth-proxy/index.mjs +145 -99
  64. package/dist/plugins/one-tap/index.mjs +0 -1
  65. package/dist/plugins/open-api/generator.mjs +15 -1
  66. package/dist/plugins/organization/has-permission.mjs +4 -2
  67. package/dist/plugins/phone-number/routes.mjs +0 -2
  68. package/dist/plugins/siwe/index.mjs +5 -6
  69. package/dist/plugins/two-factor/client.d.mts +1 -0
  70. package/dist/plugins/two-factor/error-code.d.mts +1 -0
  71. package/dist/plugins/two-factor/error-code.mjs +1 -0
  72. package/dist/plugins/two-factor/index.d.mts +1 -0
  73. package/dist/plugins/two-factor/index.mjs +3 -2
  74. package/dist/state.d.mts +0 -13
  75. package/dist/test-utils/http-test-instance.d.mts +1 -1
  76. package/dist/test-utils/test-instance.mjs +27 -10
  77. package/package.json +10 -10
@@ -93,7 +93,7 @@ declare function getEndpoints<Option extends BetterAuthOptions>(ctx: Awaitable<A
93
93
  callbackURL: _$zod.ZodOptional<_$zod.ZodString>;
94
94
  newUserCallbackURL: _$zod.ZodOptional<_$zod.ZodString>;
95
95
  errorCallbackURL: _$zod.ZodOptional<_$zod.ZodString>;
96
- provider: _$zod.ZodType<(string & {}) | "linear" | "huggingface" | "github" | "apple" | "atlassian" | "cognito" | "discord" | "facebook" | "figma" | "microsoft" | "google" | "slack" | "spotify" | "twitch" | "twitter" | "dropbox" | "kick" | "linkedin" | "gitlab" | "tiktok" | "reddit" | "roblox" | "salesforce" | "vk" | "zoom" | "notion" | "kakao" | "naver" | "line" | "paybin" | "paypal" | "polar" | "railway" | "vercel" | "wechat", unknown, _$zod_v4_core0.$ZodTypeInternals<(string & {}) | "linear" | "huggingface" | "github" | "apple" | "atlassian" | "cognito" | "discord" | "facebook" | "figma" | "microsoft" | "google" | "slack" | "spotify" | "twitch" | "twitter" | "dropbox" | "kick" | "linkedin" | "gitlab" | "tiktok" | "reddit" | "roblox" | "salesforce" | "vk" | "zoom" | "notion" | "kakao" | "naver" | "line" | "paybin" | "paypal" | "polar" | "railway" | "vercel" | "wechat", unknown>>;
96
+ provider: _$zod.ZodType<(string & {}) | "linear" | "huggingface" | "github" | "apple" | "atlassian" | "cloudflare" | "cognito" | "discord" | "facebook" | "figma" | "microsoft" | "google" | "slack" | "spotify" | "twitch" | "twitter" | "dropbox" | "kick" | "linkedin" | "gitlab" | "tiktok" | "reddit" | "roblox" | "salesforce" | "vk" | "zoom" | "notion" | "kakao" | "naver" | "line" | "paybin" | "paypal" | "polar" | "railway" | "vercel" | "wechat", unknown, _$zod_v4_core0.$ZodTypeInternals<(string & {}) | "linear" | "huggingface" | "github" | "apple" | "atlassian" | "cloudflare" | "cognito" | "discord" | "facebook" | "figma" | "microsoft" | "google" | "slack" | "spotify" | "twitch" | "twitter" | "dropbox" | "kick" | "linkedin" | "gitlab" | "tiktok" | "reddit" | "roblox" | "salesforce" | "vk" | "zoom" | "notion" | "kakao" | "naver" | "line" | "paybin" | "paypal" | "polar" | "railway" | "vercel" | "wechat", unknown>>;
97
97
  disableRedirect: _$zod.ZodOptional<_$zod.ZodBoolean>;
98
98
  idToken: _$zod.ZodOptional<_$zod.ZodObject<{
99
99
  token: _$zod.ZodString;
@@ -121,7 +121,7 @@ declare function getEndpoints<Option extends BetterAuthOptions>(ctx: Awaitable<A
121
121
  callbackURL: _$zod.ZodOptional<_$zod.ZodString>;
122
122
  newUserCallbackURL: _$zod.ZodOptional<_$zod.ZodString>;
123
123
  errorCallbackURL: _$zod.ZodOptional<_$zod.ZodString>;
124
- provider: _$zod.ZodType<(string & {}) | "linear" | "huggingface" | "github" | "apple" | "atlassian" | "cognito" | "discord" | "facebook" | "figma" | "microsoft" | "google" | "slack" | "spotify" | "twitch" | "twitter" | "dropbox" | "kick" | "linkedin" | "gitlab" | "tiktok" | "reddit" | "roblox" | "salesforce" | "vk" | "zoom" | "notion" | "kakao" | "naver" | "line" | "paybin" | "paypal" | "polar" | "railway" | "vercel" | "wechat", unknown, _$zod_v4_core0.$ZodTypeInternals<(string & {}) | "linear" | "huggingface" | "github" | "apple" | "atlassian" | "cognito" | "discord" | "facebook" | "figma" | "microsoft" | "google" | "slack" | "spotify" | "twitch" | "twitter" | "dropbox" | "kick" | "linkedin" | "gitlab" | "tiktok" | "reddit" | "roblox" | "salesforce" | "vk" | "zoom" | "notion" | "kakao" | "naver" | "line" | "paybin" | "paypal" | "polar" | "railway" | "vercel" | "wechat", unknown>>;
124
+ provider: _$zod.ZodType<(string & {}) | "linear" | "huggingface" | "github" | "apple" | "atlassian" | "cloudflare" | "cognito" | "discord" | "facebook" | "figma" | "microsoft" | "google" | "slack" | "spotify" | "twitch" | "twitter" | "dropbox" | "kick" | "linkedin" | "gitlab" | "tiktok" | "reddit" | "roblox" | "salesforce" | "vk" | "zoom" | "notion" | "kakao" | "naver" | "line" | "paybin" | "paypal" | "polar" | "railway" | "vercel" | "wechat", unknown, _$zod_v4_core0.$ZodTypeInternals<(string & {}) | "linear" | "huggingface" | "github" | "apple" | "atlassian" | "cloudflare" | "cognito" | "discord" | "facebook" | "figma" | "microsoft" | "google" | "slack" | "spotify" | "twitch" | "twitter" | "dropbox" | "kick" | "linkedin" | "gitlab" | "tiktok" | "reddit" | "roblox" | "salesforce" | "vk" | "zoom" | "notion" | "kakao" | "naver" | "line" | "paybin" | "paypal" | "polar" | "railway" | "vercel" | "wechat", unknown>>;
125
125
  disableRedirect: _$zod.ZodOptional<_$zod.ZodBoolean>;
126
126
  idToken: _$zod.ZodOptional<_$zod.ZodObject<{
127
127
  token: _$zod.ZodString;
@@ -1592,7 +1592,7 @@ declare function getEndpoints<Option extends BetterAuthOptions>(ctx: Awaitable<A
1592
1592
  requireHeaders: true;
1593
1593
  body: _$zod.ZodObject<{
1594
1594
  callbackURL: _$zod.ZodOptional<_$zod.ZodString>;
1595
- provider: _$zod.ZodType<(string & {}) | "linear" | "huggingface" | "github" | "apple" | "atlassian" | "cognito" | "discord" | "facebook" | "figma" | "microsoft" | "google" | "slack" | "spotify" | "twitch" | "twitter" | "dropbox" | "kick" | "linkedin" | "gitlab" | "tiktok" | "reddit" | "roblox" | "salesforce" | "vk" | "zoom" | "notion" | "kakao" | "naver" | "line" | "paybin" | "paypal" | "polar" | "railway" | "vercel" | "wechat", unknown, _$zod_v4_core0.$ZodTypeInternals<(string & {}) | "linear" | "huggingface" | "github" | "apple" | "atlassian" | "cognito" | "discord" | "facebook" | "figma" | "microsoft" | "google" | "slack" | "spotify" | "twitch" | "twitter" | "dropbox" | "kick" | "linkedin" | "gitlab" | "tiktok" | "reddit" | "roblox" | "salesforce" | "vk" | "zoom" | "notion" | "kakao" | "naver" | "line" | "paybin" | "paypal" | "polar" | "railway" | "vercel" | "wechat", unknown>>;
1595
+ provider: _$zod.ZodType<(string & {}) | "linear" | "huggingface" | "github" | "apple" | "atlassian" | "cloudflare" | "cognito" | "discord" | "facebook" | "figma" | "microsoft" | "google" | "slack" | "spotify" | "twitch" | "twitter" | "dropbox" | "kick" | "linkedin" | "gitlab" | "tiktok" | "reddit" | "roblox" | "salesforce" | "vk" | "zoom" | "notion" | "kakao" | "naver" | "line" | "paybin" | "paypal" | "polar" | "railway" | "vercel" | "wechat", unknown, _$zod_v4_core0.$ZodTypeInternals<(string & {}) | "linear" | "huggingface" | "github" | "apple" | "atlassian" | "cloudflare" | "cognito" | "discord" | "facebook" | "figma" | "microsoft" | "google" | "slack" | "spotify" | "twitch" | "twitter" | "dropbox" | "kick" | "linkedin" | "gitlab" | "tiktok" | "reddit" | "roblox" | "salesforce" | "vk" | "zoom" | "notion" | "kakao" | "naver" | "line" | "paybin" | "paypal" | "polar" | "railway" | "vercel" | "wechat", unknown>>;
1596
1596
  idToken: _$zod.ZodOptional<_$zod.ZodObject<{
1597
1597
  token: _$zod.ZodString;
1598
1598
  nonce: _$zod.ZodOptional<_$zod.ZodString>;
@@ -1719,9 +1719,6 @@ declare function getEndpoints<Option extends BetterAuthOptions>(ctx: Awaitable<A
1719
1719
  type: string;
1720
1720
  format: string;
1721
1721
  };
1722
- issuer: {
1723
- type: string;
1724
- };
1725
1722
  accountId: {
1726
1723
  type: string;
1727
1724
  };
@@ -1751,7 +1748,6 @@ declare function getEndpoints<Option extends BetterAuthOptions>(ctx: Awaitable<A
1751
1748
  updatedAt: Date;
1752
1749
  userId: string;
1753
1750
  providerId: string;
1754
- issuer: string;
1755
1751
  accountId: string;
1756
1752
  }[]>;
1757
1753
  readonly deleteUserCallback: _$better_call0.StrictEndpoint<"/delete-user/callback", {
@@ -1999,9 +1995,6 @@ declare function getEndpoints<Option extends BetterAuthOptions>(ctx: Awaitable<A
1999
1995
  providerId: {
2000
1996
  type: string;
2001
1997
  };
2002
- issuer: {
2003
- type: string;
2004
- };
2005
1998
  accountId: {
2006
1999
  type: string;
2007
2000
  };
@@ -2035,7 +2028,6 @@ declare function getEndpoints<Option extends BetterAuthOptions>(ctx: Awaitable<A
2035
2028
  account: {
2036
2029
  id: string;
2037
2030
  providerId: string;
2038
- issuer: string;
2039
2031
  accountId: string;
2040
2032
  };
2041
2033
  user: _$_better_auth_core_oauth20.OAuth2UserInfo;
@@ -2115,7 +2107,7 @@ declare const router: <Option extends BetterAuthOptions>(ctx: AuthContext, optio
2115
2107
  callbackURL: _$zod.ZodOptional<_$zod.ZodString>;
2116
2108
  newUserCallbackURL: _$zod.ZodOptional<_$zod.ZodString>;
2117
2109
  errorCallbackURL: _$zod.ZodOptional<_$zod.ZodString>;
2118
- provider: _$zod.ZodType<(string & {}) | "linear" | "huggingface" | "github" | "apple" | "atlassian" | "cognito" | "discord" | "facebook" | "figma" | "microsoft" | "google" | "slack" | "spotify" | "twitch" | "twitter" | "dropbox" | "kick" | "linkedin" | "gitlab" | "tiktok" | "reddit" | "roblox" | "salesforce" | "vk" | "zoom" | "notion" | "kakao" | "naver" | "line" | "paybin" | "paypal" | "polar" | "railway" | "vercel" | "wechat", unknown, _$zod_v4_core0.$ZodTypeInternals<(string & {}) | "linear" | "huggingface" | "github" | "apple" | "atlassian" | "cognito" | "discord" | "facebook" | "figma" | "microsoft" | "google" | "slack" | "spotify" | "twitch" | "twitter" | "dropbox" | "kick" | "linkedin" | "gitlab" | "tiktok" | "reddit" | "roblox" | "salesforce" | "vk" | "zoom" | "notion" | "kakao" | "naver" | "line" | "paybin" | "paypal" | "polar" | "railway" | "vercel" | "wechat", unknown>>;
2110
+ provider: _$zod.ZodType<(string & {}) | "linear" | "huggingface" | "github" | "apple" | "atlassian" | "cloudflare" | "cognito" | "discord" | "facebook" | "figma" | "microsoft" | "google" | "slack" | "spotify" | "twitch" | "twitter" | "dropbox" | "kick" | "linkedin" | "gitlab" | "tiktok" | "reddit" | "roblox" | "salesforce" | "vk" | "zoom" | "notion" | "kakao" | "naver" | "line" | "paybin" | "paypal" | "polar" | "railway" | "vercel" | "wechat", unknown, _$zod_v4_core0.$ZodTypeInternals<(string & {}) | "linear" | "huggingface" | "github" | "apple" | "atlassian" | "cloudflare" | "cognito" | "discord" | "facebook" | "figma" | "microsoft" | "google" | "slack" | "spotify" | "twitch" | "twitter" | "dropbox" | "kick" | "linkedin" | "gitlab" | "tiktok" | "reddit" | "roblox" | "salesforce" | "vk" | "zoom" | "notion" | "kakao" | "naver" | "line" | "paybin" | "paypal" | "polar" | "railway" | "vercel" | "wechat", unknown>>;
2119
2111
  disableRedirect: _$zod.ZodOptional<_$zod.ZodBoolean>;
2120
2112
  idToken: _$zod.ZodOptional<_$zod.ZodObject<{
2121
2113
  token: _$zod.ZodString;
@@ -2143,7 +2135,7 @@ declare const router: <Option extends BetterAuthOptions>(ctx: AuthContext, optio
2143
2135
  callbackURL: _$zod.ZodOptional<_$zod.ZodString>;
2144
2136
  newUserCallbackURL: _$zod.ZodOptional<_$zod.ZodString>;
2145
2137
  errorCallbackURL: _$zod.ZodOptional<_$zod.ZodString>;
2146
- provider: _$zod.ZodType<(string & {}) | "linear" | "huggingface" | "github" | "apple" | "atlassian" | "cognito" | "discord" | "facebook" | "figma" | "microsoft" | "google" | "slack" | "spotify" | "twitch" | "twitter" | "dropbox" | "kick" | "linkedin" | "gitlab" | "tiktok" | "reddit" | "roblox" | "salesforce" | "vk" | "zoom" | "notion" | "kakao" | "naver" | "line" | "paybin" | "paypal" | "polar" | "railway" | "vercel" | "wechat", unknown, _$zod_v4_core0.$ZodTypeInternals<(string & {}) | "linear" | "huggingface" | "github" | "apple" | "atlassian" | "cognito" | "discord" | "facebook" | "figma" | "microsoft" | "google" | "slack" | "spotify" | "twitch" | "twitter" | "dropbox" | "kick" | "linkedin" | "gitlab" | "tiktok" | "reddit" | "roblox" | "salesforce" | "vk" | "zoom" | "notion" | "kakao" | "naver" | "line" | "paybin" | "paypal" | "polar" | "railway" | "vercel" | "wechat", unknown>>;
2138
+ provider: _$zod.ZodType<(string & {}) | "linear" | "huggingface" | "github" | "apple" | "atlassian" | "cloudflare" | "cognito" | "discord" | "facebook" | "figma" | "microsoft" | "google" | "slack" | "spotify" | "twitch" | "twitter" | "dropbox" | "kick" | "linkedin" | "gitlab" | "tiktok" | "reddit" | "roblox" | "salesforce" | "vk" | "zoom" | "notion" | "kakao" | "naver" | "line" | "paybin" | "paypal" | "polar" | "railway" | "vercel" | "wechat", unknown, _$zod_v4_core0.$ZodTypeInternals<(string & {}) | "linear" | "huggingface" | "github" | "apple" | "atlassian" | "cloudflare" | "cognito" | "discord" | "facebook" | "figma" | "microsoft" | "google" | "slack" | "spotify" | "twitch" | "twitter" | "dropbox" | "kick" | "linkedin" | "gitlab" | "tiktok" | "reddit" | "roblox" | "salesforce" | "vk" | "zoom" | "notion" | "kakao" | "naver" | "line" | "paybin" | "paypal" | "polar" | "railway" | "vercel" | "wechat", unknown>>;
2147
2139
  disableRedirect: _$zod.ZodOptional<_$zod.ZodBoolean>;
2148
2140
  idToken: _$zod.ZodOptional<_$zod.ZodObject<{
2149
2141
  token: _$zod.ZodString;
@@ -3614,7 +3606,7 @@ declare const router: <Option extends BetterAuthOptions>(ctx: AuthContext, optio
3614
3606
  requireHeaders: true;
3615
3607
  body: _$zod.ZodObject<{
3616
3608
  callbackURL: _$zod.ZodOptional<_$zod.ZodString>;
3617
- provider: _$zod.ZodType<(string & {}) | "linear" | "huggingface" | "github" | "apple" | "atlassian" | "cognito" | "discord" | "facebook" | "figma" | "microsoft" | "google" | "slack" | "spotify" | "twitch" | "twitter" | "dropbox" | "kick" | "linkedin" | "gitlab" | "tiktok" | "reddit" | "roblox" | "salesforce" | "vk" | "zoom" | "notion" | "kakao" | "naver" | "line" | "paybin" | "paypal" | "polar" | "railway" | "vercel" | "wechat", unknown, _$zod_v4_core0.$ZodTypeInternals<(string & {}) | "linear" | "huggingface" | "github" | "apple" | "atlassian" | "cognito" | "discord" | "facebook" | "figma" | "microsoft" | "google" | "slack" | "spotify" | "twitch" | "twitter" | "dropbox" | "kick" | "linkedin" | "gitlab" | "tiktok" | "reddit" | "roblox" | "salesforce" | "vk" | "zoom" | "notion" | "kakao" | "naver" | "line" | "paybin" | "paypal" | "polar" | "railway" | "vercel" | "wechat", unknown>>;
3609
+ provider: _$zod.ZodType<(string & {}) | "linear" | "huggingface" | "github" | "apple" | "atlassian" | "cloudflare" | "cognito" | "discord" | "facebook" | "figma" | "microsoft" | "google" | "slack" | "spotify" | "twitch" | "twitter" | "dropbox" | "kick" | "linkedin" | "gitlab" | "tiktok" | "reddit" | "roblox" | "salesforce" | "vk" | "zoom" | "notion" | "kakao" | "naver" | "line" | "paybin" | "paypal" | "polar" | "railway" | "vercel" | "wechat", unknown, _$zod_v4_core0.$ZodTypeInternals<(string & {}) | "linear" | "huggingface" | "github" | "apple" | "atlassian" | "cloudflare" | "cognito" | "discord" | "facebook" | "figma" | "microsoft" | "google" | "slack" | "spotify" | "twitch" | "twitter" | "dropbox" | "kick" | "linkedin" | "gitlab" | "tiktok" | "reddit" | "roblox" | "salesforce" | "vk" | "zoom" | "notion" | "kakao" | "naver" | "line" | "paybin" | "paypal" | "polar" | "railway" | "vercel" | "wechat", unknown>>;
3618
3610
  idToken: _$zod.ZodOptional<_$zod.ZodObject<{
3619
3611
  token: _$zod.ZodString;
3620
3612
  nonce: _$zod.ZodOptional<_$zod.ZodString>;
@@ -3741,9 +3733,6 @@ declare const router: <Option extends BetterAuthOptions>(ctx: AuthContext, optio
3741
3733
  type: string;
3742
3734
  format: string;
3743
3735
  };
3744
- issuer: {
3745
- type: string;
3746
- };
3747
3736
  accountId: {
3748
3737
  type: string;
3749
3738
  };
@@ -3773,7 +3762,6 @@ declare const router: <Option extends BetterAuthOptions>(ctx: AuthContext, optio
3773
3762
  updatedAt: Date;
3774
3763
  userId: string;
3775
3764
  providerId: string;
3776
- issuer: string;
3777
3765
  accountId: string;
3778
3766
  }[]>;
3779
3767
  readonly deleteUserCallback: _$better_call0.StrictEndpoint<"/delete-user/callback", {
@@ -4021,9 +4009,6 @@ declare const router: <Option extends BetterAuthOptions>(ctx: AuthContext, optio
4021
4009
  providerId: {
4022
4010
  type: string;
4023
4011
  };
4024
- issuer: {
4025
- type: string;
4026
- };
4027
4012
  accountId: {
4028
4013
  type: string;
4029
4014
  };
@@ -4057,7 +4042,6 @@ declare const router: <Option extends BetterAuthOptions>(ctx: AuthContext, optio
4057
4042
  account: {
4058
4043
  id: string;
4059
4044
  providerId: string;
4060
- issuer: string;
4061
4045
  accountId: string;
4062
4046
  };
4063
4047
  user: _$_better_auth_core_oauth20.OAuth2UserInfo;
@@ -164,6 +164,8 @@ const router = (ctx, options) => {
164
164
  const disabledPaths = ctx.options.disabledPaths || [];
165
165
  const normalizedPath = normalizePathname(req.url, basePath);
166
166
  if (disabledPaths.includes(normalizedPath)) return new Response("Not Found", { status: 404 });
167
+ const pendingSchemaCheck = ctx.checkSchema?.();
168
+ if (pendingSchemaCheck) await pendingSchemaCheck;
167
169
  let currentRequest = req;
168
170
  const rateLimitResponse = await onRequestRateLimit(currentRequest, ctx);
169
171
  if (rateLimitResponse) return rateLimitResponse;
@@ -1,3 +1,4 @@
1
+ import { getBaseURL, getOrigin } from "../../utils/url.mjs";
1
2
  import { matchesOriginPattern } from "../../auth/trusted-origins.mjs";
2
3
  import { APIError, BASE_ERROR_CODES } from "@better-auth/core/error";
3
4
  import { normalizePathname } from "@better-auth/core/utils/url";
@@ -95,7 +96,8 @@ const originCheck = (getValue) => createAuthMiddleware(async (ctx) => {
95
96
  async function validateOrigin(ctx, forceValidate = false) {
96
97
  const headers = ctx.request?.headers;
97
98
  if (!headers || !ctx.request) return;
98
- const originHeader = headers.get("origin") || headers.get("referer") || "";
99
+ const origin = headers.get("origin");
100
+ const originHeader = origin || headers.get("referer") || "";
99
101
  const useCookies = headers.has("cookie");
100
102
  if (ctx.context.skipCSRFCheck) return;
101
103
  if (shouldSkipCSRFForBackwardCompat(ctx)) {
@@ -104,11 +106,13 @@ async function validateOrigin(ctx, forceValidate = false) {
104
106
  }
105
107
  if (shouldSkipOriginCheck(ctx)) return;
106
108
  if (!(forceValidate || useCookies)) return;
107
- if (!originHeader || originHeader === "null") throw APIError.from("FORBIDDEN", BASE_ERROR_CODES.MISSING_OR_NULL_ORIGIN);
109
+ const inferredBaseURL = origin === "null" && headers.get("sec-fetch-site") === "same-origin" ? getBaseURL(void 0, ctx.context.options.basePath, ctx.request, false, ctx.context.options.advanced?.trustedProxyHeaders) : void 0;
110
+ const originToValidate = (inferredBaseURL ? getOrigin(inferredBaseURL) : void 0) ?? originHeader;
111
+ if (!originToValidate || originToValidate === "null") throw APIError.from("FORBIDDEN", BASE_ERROR_CODES.MISSING_OR_NULL_ORIGIN);
108
112
  const trustedOrigins = Array.isArray(ctx.context.options.trustedOrigins) ? ctx.context.trustedOrigins : [...ctx.context.trustedOrigins, ...(await ctx.context.options.trustedOrigins?.(ctx.request))?.filter((v) => Boolean(v)) || []];
109
- if (!trustedOrigins.some((origin) => matchesOriginPattern(originHeader, origin))) {
110
- ctx.context.logger.error(`Invalid origin: ${originHeader}`);
111
- ctx.context.logger.info(`If it's a valid URL, please add ${originHeader} to trustedOrigins in your auth config\n`, `Current list of trustedOrigins: ${trustedOrigins}`);
113
+ if (!trustedOrigins.some((origin) => matchesOriginPattern(originToValidate, origin))) {
114
+ ctx.context.logger.error(`Invalid origin: ${originToValidate}`);
115
+ ctx.context.logger.info(`If it's a valid URL, please add ${originToValidate} to trustedOrigins in your auth config\n`, `Current list of trustedOrigins: ${trustedOrigins}`);
112
116
  throw APIError.from("FORBIDDEN", BASE_ERROR_CODES.INVALID_ORIGIN);
113
117
  }
114
118
  }
@@ -56,9 +56,6 @@ declare const listUserAccounts: _$better_call0.StrictEndpoint<"/list-accounts",
56
56
  type: string;
57
57
  format: string;
58
58
  };
59
- issuer: {
60
- type: string;
61
- };
62
59
  accountId: {
63
60
  type: string;
64
61
  };
@@ -88,7 +85,6 @@ declare const listUserAccounts: _$better_call0.StrictEndpoint<"/list-accounts",
88
85
  updatedAt: Date;
89
86
  userId: string;
90
87
  providerId: string;
91
- issuer: string;
92
88
  accountId: string;
93
89
  }[]>;
94
90
  declare const linkSocialAccount: _$better_call0.StrictEndpoint<"/link-social", {
@@ -96,7 +92,7 @@ declare const linkSocialAccount: _$better_call0.StrictEndpoint<"/link-social", {
96
92
  requireHeaders: true;
97
93
  body: z.ZodObject<{
98
94
  callbackURL: z.ZodOptional<z.ZodString>;
99
- provider: z.ZodType<(string & {}) | "linear" | "huggingface" | "github" | "apple" | "atlassian" | "cognito" | "discord" | "facebook" | "figma" | "microsoft" | "google" | "slack" | "spotify" | "twitch" | "twitter" | "dropbox" | "kick" | "linkedin" | "gitlab" | "tiktok" | "reddit" | "roblox" | "salesforce" | "vk" | "zoom" | "notion" | "kakao" | "naver" | "line" | "paybin" | "paypal" | "polar" | "railway" | "vercel" | "wechat", unknown, z.core.$ZodTypeInternals<(string & {}) | "linear" | "huggingface" | "github" | "apple" | "atlassian" | "cognito" | "discord" | "facebook" | "figma" | "microsoft" | "google" | "slack" | "spotify" | "twitch" | "twitter" | "dropbox" | "kick" | "linkedin" | "gitlab" | "tiktok" | "reddit" | "roblox" | "salesforce" | "vk" | "zoom" | "notion" | "kakao" | "naver" | "line" | "paybin" | "paypal" | "polar" | "railway" | "vercel" | "wechat", unknown>>;
95
+ provider: z.ZodType<(string & {}) | "linear" | "huggingface" | "github" | "apple" | "atlassian" | "cloudflare" | "cognito" | "discord" | "facebook" | "figma" | "microsoft" | "google" | "slack" | "spotify" | "twitch" | "twitter" | "dropbox" | "kick" | "linkedin" | "gitlab" | "tiktok" | "reddit" | "roblox" | "salesforce" | "vk" | "zoom" | "notion" | "kakao" | "naver" | "line" | "paybin" | "paypal" | "polar" | "railway" | "vercel" | "wechat", unknown, z.core.$ZodTypeInternals<(string & {}) | "linear" | "huggingface" | "github" | "apple" | "atlassian" | "cloudflare" | "cognito" | "discord" | "facebook" | "figma" | "microsoft" | "google" | "slack" | "spotify" | "twitch" | "twitter" | "dropbox" | "kick" | "linkedin" | "gitlab" | "tiktok" | "reddit" | "roblox" | "salesforce" | "vk" | "zoom" | "notion" | "kakao" | "naver" | "line" | "paybin" | "paypal" | "polar" | "railway" | "vercel" | "wechat", unknown>>;
100
96
  idToken: z.ZodOptional<z.ZodObject<{
101
97
  token: z.ZodString;
102
98
  nonce: z.ZodOptional<z.ZodString>;
@@ -375,9 +371,6 @@ declare const accountInfo: _$better_call0.StrictEndpoint<"/account-info", {
375
371
  providerId: {
376
372
  type: string;
377
373
  };
378
- issuer: {
379
- type: string;
380
- };
381
374
  accountId: {
382
375
  type: string;
383
376
  };
@@ -411,7 +404,6 @@ declare const accountInfo: _$better_call0.StrictEndpoint<"/account-info", {
411
404
  account: {
412
405
  id: string;
413
406
  providerId: string;
414
- issuer: string;
415
407
  accountId: string;
416
408
  };
417
409
  user: _$_better_auth_core_oauth20.OAuth2UserInfo;
@@ -41,7 +41,6 @@ const listUserAccounts = createAuthEndpoint("/list-accounts", {
41
41
  type: "string",
42
42
  format: "date-time"
43
43
  },
44
- issuer: { type: "string" },
45
44
  accountId: { type: "string" },
46
45
  userId: { type: "string" },
47
46
  scopes: {
@@ -54,7 +53,6 @@ const listUserAccounts = createAuthEndpoint("/list-accounts", {
54
53
  "providerId",
55
54
  "createdAt",
56
55
  "updatedAt",
57
- "issuer",
58
56
  "accountId",
59
57
  "userId",
60
58
  "scopes"
@@ -217,7 +215,6 @@ const linkSocialAccount = createAuthEndpoint("/link-social", {
217
215
  try {
218
216
  await c.context.internalAdapter.createAccount({
219
217
  userId: session.user.id,
220
- providerId: provider.id,
221
218
  ...accountKey,
222
219
  accessToken: await setTokenUtil(c.body.idToken.accessToken, c.context),
223
220
  idToken: token,
@@ -558,13 +555,11 @@ const accountInfo = createAuthEndpoint("/account-info", {
558
555
  properties: {
559
556
  id: { type: "string" },
560
557
  providerId: { type: "string" },
561
- issuer: { type: "string" },
562
558
  accountId: { type: "string" }
563
559
  },
564
560
  required: [
565
561
  "id",
566
562
  "providerId",
567
- "issuer",
568
563
  "accountId"
569
564
  ],
570
565
  additionalProperties: false
@@ -616,7 +611,6 @@ const accountInfo = createAuthEndpoint("/account-info", {
616
611
  account: {
617
612
  id: account.id,
618
613
  providerId: account.providerId,
619
- issuer: account.issuer,
620
614
  accountId: account.accountId
621
615
  }
622
616
  });
@@ -10,6 +10,7 @@ import { generateIdTokenNonce, generateState, parseState } from "../../oauth2/st
10
10
  import { HIDE_METADATA } from "../../utils/hide-metadata.mjs";
11
11
  import { mergeScopes } from "@better-auth/core/oauth2";
12
12
  import { safeJSONParse } from "@better-auth/core/utils/json";
13
+ import { appendQueryParams } from "@better-auth/core/utils/url";
13
14
  import { createAuthEndpoint } from "@better-auth/core/api";
14
15
  import * as z from "zod";
15
16
  //#region src/api/routes/callback.ts
@@ -52,7 +53,8 @@ const callbackOAuth = createAuthEndpoint("/callback/:id", {
52
53
  else throw new Error("Unsupported method");
53
54
  } catch (e) {
54
55
  c.context.logger.error("INVALID_CALLBACK_REQUEST", e);
55
- throw c.redirect(`${defaultErrorURL}?error=invalid_callback_request`);
56
+ const redirectURL = appendQueryParams(defaultErrorURL, new URLSearchParams({ error: "invalid_callback_request" }));
57
+ throw c.redirect(redirectURL);
56
58
  }
57
59
  const { code, error, state, error_description, device_id, user: userData, iss } = queryOrBody;
58
60
  if (state === void 0 && code) {
@@ -71,16 +73,16 @@ const callbackOAuth = createAuthEndpoint("/callback/:id", {
71
73
  }
72
74
  if (!state) {
73
75
  c.context.logger.error("State not found", error);
74
- const url = `${defaultErrorURL}${defaultErrorURL.includes("?") ? "&" : "?"}error=state_not_found`;
75
- throw c.redirect(url);
76
+ const redirectURL = appendQueryParams(defaultErrorURL, new URLSearchParams({ error: "state_not_found" }));
77
+ throw c.redirect(redirectURL);
76
78
  }
77
79
  const { codeVerifier, callbackURL, link, errorURL, newUserURL, requestSignUp, idTokenNonce } = await parseState(c);
78
80
  function redirectOnError(error, description) {
79
81
  const baseURL = errorURL ?? defaultErrorURL;
80
82
  const params = new URLSearchParams({ error });
81
83
  if (description) params.set("error_description", description);
82
- const url = `${baseURL}${baseURL.includes("?") ? "&" : "?"}${params.toString()}`;
83
- throw c.redirect(url);
84
+ const redirectURL = appendQueryParams(baseURL, params);
85
+ throw c.redirect(redirectURL);
84
86
  }
85
87
  if (error) redirectOnError(error, error_description);
86
88
  if (!code) {
@@ -189,7 +191,6 @@ const callbackOAuth = createAuthEndpoint("/callback/:id", {
189
191
  await c.context.internalAdapter.updateAccount(existingAccount.id, updateData);
190
192
  } else if (!await c.context.internalAdapter.createAccount({
191
193
  userId: link.userId,
192
- providerId: provider.id,
193
194
  ...accountKey,
194
195
  ...tokens,
195
196
  accessToken: await setTokenUtil(tokens.accessToken, c.context),
@@ -210,7 +211,6 @@ const callbackOAuth = createAuthEndpoint("/callback/:id", {
210
211
  return redirectOnError(OAUTH_CALLBACK_ERROR_CODES.EMAIL_NOT_FOUND);
211
212
  }
212
213
  const accountData = {
213
- providerId: provider.id,
214
214
  ...accountKey,
215
215
  ...tokens,
216
216
  scope: tokens.scopes?.join(",")
@@ -5,6 +5,7 @@ import { setSessionCookie } from "../../cookies/index.mjs";
5
5
  import { getSessionFromCtx } from "./session.mjs";
6
6
  import { safeCloneRequest } from "../../utils/request.mjs";
7
7
  import { APIError, BASE_ERROR_CODES } from "@better-auth/core/error";
8
+ import { appendQueryParams } from "@better-auth/core/utils/url";
8
9
  import { createAuthEndpoint } from "@better-auth/core/api";
9
10
  import * as z from "zod";
10
11
  import { jwtVerify } from "jose";
@@ -165,8 +166,9 @@ const verifyEmail = createAuthEndpoint("/verify-email", {
165
166
  }, async (ctx) => {
166
167
  function redirectOnError(error) {
167
168
  if (ctx.query.callbackURL) {
168
- if (ctx.query.callbackURL.includes("?")) throw ctx.redirect(`${ctx.query.callbackURL}&error=${error.code}`);
169
- throw ctx.redirect(`${ctx.query.callbackURL}?error=${error.code}`);
169
+ const params = new URLSearchParams({ error: error.code });
170
+ const redirectURL = appendQueryParams(ctx.query.callbackURL, params);
171
+ throw ctx.redirect(redirectURL);
170
172
  }
171
173
  throw APIError.from("UNAUTHORIZED", error);
172
174
  }
@@ -1,5 +1,6 @@
1
1
  import { HIDE_METADATA } from "../../utils/hide-metadata.mjs";
2
2
  import { isProduction } from "@better-auth/core/env";
3
+ import { appendQueryParams } from "@better-auth/core/utils/url";
3
4
  import { createAuthEndpoint } from "@better-auth/core/api";
4
5
  //#region src/api/routes/error.ts
5
6
  function sanitize(input) {
@@ -364,18 +365,21 @@ const error = createAuthEndpoint("/error", {
364
365
  const unsanitizedDescription = url.searchParams.get("error_description") || null;
365
366
  const safeCode = /^[\'A-Za-z0-9_-]+$/.test(unsanitizedCode || "") ? unsanitizedCode : "UNKNOWN";
366
367
  const safeDescription = unsanitizedDescription ? sanitize(unsanitizedDescription) : null;
367
- const queryParams = new URLSearchParams();
368
- queryParams.set("error", safeCode);
369
- if (unsanitizedDescription) queryParams.set("error_description", unsanitizedDescription);
368
+ const params = new URLSearchParams();
369
+ params.set("error", safeCode);
370
+ if (unsanitizedDescription) params.set("error_description", unsanitizedDescription);
370
371
  const options = c.context.options;
371
372
  const errorURL = options.onAPIError?.errorURL;
372
- if (errorURL) return new Response(null, {
373
- status: 302,
374
- headers: { Location: `${errorURL}${errorURL.includes("?") ? "&" : "?"}${queryParams.toString()}` }
375
- });
373
+ if (errorURL) {
374
+ const redirectURL = appendQueryParams(errorURL, params);
375
+ return new Response(null, {
376
+ status: 302,
377
+ headers: { Location: redirectURL }
378
+ });
379
+ }
376
380
  if (isProduction && !options.onAPIError?.customizeDefaultErrorPage) return new Response(null, {
377
381
  status: 302,
378
- headers: { Location: `/?${queryParams.toString()}` }
382
+ headers: { Location: `/?${params.toString()}` }
379
383
  });
380
384
  return new Response(html(c.context.options, safeCode, safeDescription), { headers: { "Content-Type": "text/html" } });
381
385
  });
@@ -2,7 +2,6 @@ import { originCheck } from "../middlewares/origin-check.mjs";
2
2
  import { getDate } from "../../utils/date.mjs";
3
3
  import { sensitiveSessionMiddleware } from "./session.mjs";
4
4
  import { validatePassword } from "../../utils/password.mjs";
5
- import { createLocalAccountIssuer } from "@better-auth/core/db";
6
5
  import { APIError, BASE_ERROR_CODES } from "@better-auth/core/error";
7
6
  import { generateId } from "@better-auth/core/utils/id";
8
7
  import { createAuthEndpoint } from "@better-auth/core/api";
@@ -164,7 +163,6 @@ const resetPassword = createAuthEndpoint("/reset-password", {
164
163
  if (!await ctx.context.internalAdapter.findCredentialAccount(userId)) await ctx.context.internalAdapter.createAccount({
165
164
  userId,
166
165
  providerId: "credential",
167
- issuer: createLocalAccountIssuer("credential"),
168
166
  accountId: user.id,
169
167
  password: hashedPassword
170
168
  });
@@ -2,7 +2,7 @@ import { isAPIError } from "../../utils/is-api-error.mjs";
2
2
  import { hasServerSessionStore } from "../../context/store-capabilities.mjs";
3
3
  import { parseSessionOutput, parseUserOutput } from "../../db/schema.mjs";
4
4
  import { getDate } from "../../utils/date.mjs";
5
- import { getChunkedCookie, getSessionQuerySchema } from "../../cookies/session-store.mjs";
5
+ import { createSessionStore, getChunkedCookie, getSessionQuerySchema } from "../../cookies/session-store.mjs";
6
6
  import { decodeCookieCache, deleteSessionCookie, expireCookie, setCookieCache, setSessionCookie } from "../../cookies/index.mjs";
7
7
  import { getShouldSkipSessionRefresh } from "../state/should-session-refresh.mjs";
8
8
  import { APIError, BASE_ERROR_CODES } from "@better-auth/core/error";
@@ -36,16 +36,23 @@ const getSession = () => createAuthEndpoint("/get-session", {
36
36
  const isPostRequest = ctx.method === "POST";
37
37
  if (isPostRequest && !deferSessionRefresh) throw APIError.from("METHOD_NOT_ALLOWED", BASE_ERROR_CODES.METHOD_NOT_ALLOWED_DEFER_SESSION_REQUIRED);
38
38
  try {
39
+ const cookieCacheEnabled = ctx.context.options.session?.cookieCache?.enabled === true;
39
40
  const sessionCookieToken = await ctx.getSignedCookie(ctx.context.authCookies.sessionToken.name, ctx.context.secret);
40
- if (!sessionCookieToken) return null;
41
+ if (!sessionCookieToken && cookieCacheEnabled) return null;
41
42
  const sessionDataCookie = getChunkedCookie(ctx, ctx.context.authCookies.sessionData.name);
42
- const sessionDataPayload = sessionDataCookie ? await decodeCookieCache(ctx, sessionDataCookie) : null;
43
- if (sessionDataCookie && !sessionDataPayload) expireCookie(ctx, ctx.context.authCookies.sessionData);
43
+ if (sessionDataCookie && !cookieCacheEnabled) {
44
+ const sessionStore = createSessionStore(ctx.context.authCookies.sessionData.name, ctx.context.authCookies.sessionData.attributes, ctx);
45
+ sessionStore.setCookies(sessionStore.clean());
46
+ }
47
+ if (!sessionCookieToken) return null;
48
+ const shouldUseCookieCache = cookieCacheEnabled && !ctx.query?.disableCookieCache;
49
+ const sessionDataPayload = shouldUseCookieCache && sessionDataCookie ? await decodeCookieCache(ctx, sessionDataCookie) : null;
50
+ if (shouldUseCookieCache && sessionDataCookie && !sessionDataPayload) expireCookie(ctx, ctx.context.authCookies.sessionData);
44
51
  const dontRememberMe = await ctx.getSignedCookie(ctx.context.authCookies.dontRememberToken.name, ctx.context.secret);
45
52
  /**
46
53
  * If session data is present in the cookie, check if it should be used or refreshed
47
54
  */
48
- if (sessionDataPayload?.session && ctx.context.options.session?.cookieCache?.enabled && !ctx.query?.disableCookieCache) {
55
+ if (sessionDataPayload?.session) {
49
56
  const session = sessionDataPayload.session;
50
57
  let shouldExpireCookieCache = session.session.token !== sessionCookieToken;
51
58
  if (!shouldExpireCookieCache) {
@@ -8,7 +8,7 @@ declare const socialSignInBodySchema: z.ZodObject<{
8
8
  callbackURL: z.ZodOptional<z.ZodString>;
9
9
  newUserCallbackURL: z.ZodOptional<z.ZodString>;
10
10
  errorCallbackURL: z.ZodOptional<z.ZodString>;
11
- provider: z.ZodType<(string & {}) | "linear" | "huggingface" | "github" | "apple" | "atlassian" | "cognito" | "discord" | "facebook" | "figma" | "microsoft" | "google" | "slack" | "spotify" | "twitch" | "twitter" | "dropbox" | "kick" | "linkedin" | "gitlab" | "tiktok" | "reddit" | "roblox" | "salesforce" | "vk" | "zoom" | "notion" | "kakao" | "naver" | "line" | "paybin" | "paypal" | "polar" | "railway" | "vercel" | "wechat", unknown, z.core.$ZodTypeInternals<(string & {}) | "linear" | "huggingface" | "github" | "apple" | "atlassian" | "cognito" | "discord" | "facebook" | "figma" | "microsoft" | "google" | "slack" | "spotify" | "twitch" | "twitter" | "dropbox" | "kick" | "linkedin" | "gitlab" | "tiktok" | "reddit" | "roblox" | "salesforce" | "vk" | "zoom" | "notion" | "kakao" | "naver" | "line" | "paybin" | "paypal" | "polar" | "railway" | "vercel" | "wechat", unknown>>;
11
+ provider: z.ZodType<(string & {}) | "linear" | "huggingface" | "github" | "apple" | "atlassian" | "cloudflare" | "cognito" | "discord" | "facebook" | "figma" | "microsoft" | "google" | "slack" | "spotify" | "twitch" | "twitter" | "dropbox" | "kick" | "linkedin" | "gitlab" | "tiktok" | "reddit" | "roblox" | "salesforce" | "vk" | "zoom" | "notion" | "kakao" | "naver" | "line" | "paybin" | "paypal" | "polar" | "railway" | "vercel" | "wechat", unknown, z.core.$ZodTypeInternals<(string & {}) | "linear" | "huggingface" | "github" | "apple" | "atlassian" | "cloudflare" | "cognito" | "discord" | "facebook" | "figma" | "microsoft" | "google" | "slack" | "spotify" | "twitch" | "twitter" | "dropbox" | "kick" | "linkedin" | "gitlab" | "tiktok" | "reddit" | "roblox" | "salesforce" | "vk" | "zoom" | "notion" | "kakao" | "naver" | "line" | "paybin" | "paypal" | "polar" | "railway" | "vercel" | "wechat", unknown>>;
12
12
  disableRedirect: z.ZodOptional<z.ZodBoolean>;
13
13
  idToken: z.ZodOptional<z.ZodObject<{
14
14
  token: z.ZodString;
@@ -37,7 +37,7 @@ declare const signInSocial: <O extends BetterAuthOptions>() => _$better_call0.St
37
37
  callbackURL: z.ZodOptional<z.ZodString>;
38
38
  newUserCallbackURL: z.ZodOptional<z.ZodString>;
39
39
  errorCallbackURL: z.ZodOptional<z.ZodString>;
40
- provider: z.ZodType<(string & {}) | "linear" | "huggingface" | "github" | "apple" | "atlassian" | "cognito" | "discord" | "facebook" | "figma" | "microsoft" | "google" | "slack" | "spotify" | "twitch" | "twitter" | "dropbox" | "kick" | "linkedin" | "gitlab" | "tiktok" | "reddit" | "roblox" | "salesforce" | "vk" | "zoom" | "notion" | "kakao" | "naver" | "line" | "paybin" | "paypal" | "polar" | "railway" | "vercel" | "wechat", unknown, z.core.$ZodTypeInternals<(string & {}) | "linear" | "huggingface" | "github" | "apple" | "atlassian" | "cognito" | "discord" | "facebook" | "figma" | "microsoft" | "google" | "slack" | "spotify" | "twitch" | "twitter" | "dropbox" | "kick" | "linkedin" | "gitlab" | "tiktok" | "reddit" | "roblox" | "salesforce" | "vk" | "zoom" | "notion" | "kakao" | "naver" | "line" | "paybin" | "paypal" | "polar" | "railway" | "vercel" | "wechat", unknown>>;
40
+ provider: z.ZodType<(string & {}) | "linear" | "huggingface" | "github" | "apple" | "atlassian" | "cloudflare" | "cognito" | "discord" | "facebook" | "figma" | "microsoft" | "google" | "slack" | "spotify" | "twitch" | "twitter" | "dropbox" | "kick" | "linkedin" | "gitlab" | "tiktok" | "reddit" | "roblox" | "salesforce" | "vk" | "zoom" | "notion" | "kakao" | "naver" | "line" | "paybin" | "paypal" | "polar" | "railway" | "vercel" | "wechat", unknown, z.core.$ZodTypeInternals<(string & {}) | "linear" | "huggingface" | "github" | "apple" | "atlassian" | "cloudflare" | "cognito" | "discord" | "facebook" | "figma" | "microsoft" | "google" | "slack" | "spotify" | "twitch" | "twitter" | "dropbox" | "kick" | "linkedin" | "gitlab" | "tiktok" | "reddit" | "roblox" | "salesforce" | "vk" | "zoom" | "notion" | "kakao" | "naver" | "line" | "paybin" | "paypal" | "polar" | "railway" | "vercel" | "wechat", unknown>>;
41
41
  disableRedirect: z.ZodOptional<z.ZodBoolean>;
42
42
  idToken: z.ZodOptional<z.ZodObject<{
43
43
  token: z.ZodString;
@@ -9,7 +9,6 @@ import { handleOAuthUserInfo } from "../../oauth2/link-account.mjs";
9
9
  import { generateIdTokenNonce, generateState } from "../../oauth2/state.mjs";
10
10
  import { safeCloneRequest } from "../../utils/request.mjs";
11
11
  import { createEmailVerificationToken } from "./email-verification.mjs";
12
- import { createLocalAccountIssuer } from "@better-auth/core/db";
13
12
  import { APIError, BASE_ERROR_CODES } from "@better-auth/core/error";
14
13
  import { additionalAuthorizationParamsSchema, supportsIdTokenSignIn, verifyProviderIdToken } from "@better-auth/core/oauth2";
15
14
  import { SocialProviderListEnum } from "@better-auth/core/social-providers";
@@ -188,7 +187,6 @@ const signInSocial = () => createAuthEndpoint("/sign-in/social", {
188
187
  emailVerified: userInfo.user.emailVerified || false
189
188
  },
190
189
  account: {
191
- providerId: provider.id,
192
190
  ...accountKey,
193
191
  accessToken: c.body.idToken.accessToken,
194
192
  idToken: token
@@ -315,8 +313,7 @@ const signInEmail = () => createAuthEndpoint("/sign-in/email", {
315
313
  const { email, password } = ctx.body;
316
314
  if (!z.email().safeParse(email).success) throw APIError.from("BAD_REQUEST", BASE_ERROR_CODES.INVALID_EMAIL);
317
315
  const userRecord = await ctx.context.internalAdapter.findUserByEmail(email.toLowerCase(), { includeAccounts: true });
318
- const credentialIssuer = createLocalAccountIssuer("credential");
319
- const credentialAccount = userRecord?.accounts.find((account) => account.providerId === "credential" && account.issuer === credentialIssuer && account.accountId === userRecord.user.id);
316
+ const credentialAccount = userRecord?.accounts.find((account) => account.providerId === "credential" && account.accountId === userRecord.user.id);
320
317
  if (!userRecord || !credentialAccount) {
321
318
  await ctx.context.password.hash(password);
322
319
  ctx.context.logger.warn("User not found");
@@ -5,7 +5,6 @@ import { setSessionCookie } from "../../cookies/index.mjs";
5
5
  import { safeCloneRequest } from "../../utils/request.mjs";
6
6
  import { createEmailVerificationToken } from "./email-verification.mjs";
7
7
  import { runWithTransaction } from "@better-auth/core/context";
8
- import { createLocalAccountIssuer } from "@better-auth/core/db";
9
8
  import { isDevelopment } from "@better-auth/core/env";
10
9
  import { APIError, BASE_ERROR_CODES } from "@better-auth/core/error";
11
10
  import { generateId } from "@better-auth/core/utils/id";
@@ -243,7 +242,6 @@ const signUpEmail = () => createAuthEndpoint("/sign-up/email", {
243
242
  await ctx.context.internalAdapter.linkAccount({
244
243
  userId: createdUser.id,
245
244
  providerId: "credential",
246
- issuer: createLocalAccountIssuer("credential"),
247
245
  accountId: createdUser.id,
248
246
  password: hash
249
247
  });
@@ -4,7 +4,6 @@ import { generateRandomString } from "../../crypto/random.mjs";
4
4
  import { deleteSessionCookie, setSessionCookie } from "../../cookies/index.mjs";
5
5
  import { getSessionFromCtx, isStateful, sensitiveSessionMiddleware, sessionMiddleware } from "./session.mjs";
6
6
  import { createEmailVerificationToken } from "./email-verification.mjs";
7
- import { createLocalAccountIssuer } from "@better-auth/core/db";
8
7
  import { APIError, BASE_ERROR_CODES } from "@better-auth/core/error";
9
8
  import { createAuthEndpoint } from "@better-auth/core/api";
10
9
  import * as z from "zod";
@@ -220,7 +219,6 @@ newPassword: z.string().meta({ description: "The new password to set is required
220
219
  await ctx.context.internalAdapter.linkAccount({
221
220
  userId: session.user.id,
222
221
  providerId: "credential",
223
- issuer: createLocalAccountIssuer("credential"),
224
222
  accountId: session.user.id,
225
223
  password: passwordHash
226
224
  });
@@ -38,6 +38,8 @@ function toAuthEndpoints(endpoints, ctx) {
38
38
  const operationId = getOperationId(endpoint, key);
39
39
  const run = async () => {
40
40
  const rawContext = await ctx;
41
+ const pendingSchemaCheck = rawContext.checkSchema?.();
42
+ if (pendingSchemaCheck) await pendingSchemaCheck;
41
43
  const authContext = isDynamicBaseURLConfig(rawContext.options.baseURL) ? await resolveDynamicContext(rawContext, context) : rawContext;
42
44
  return dispatchAuthEndpoint(endpoint, {
43
45
  ...context,
@@ -3,9 +3,21 @@ import { getTrustedOrigins, getTrustedProviders, resolveDynamicTrustedProxyHeade
3
3
  import { getEndpoints, router } from "../api/index.mjs";
4
4
  import { runWithAdapter } from "@better-auth/core/context";
5
5
  import { BASE_ERROR_CODES, BetterAuthError } from "@better-auth/core/error";
6
+ import { SchemaMismatchError } from "@better-auth/core/db/internal";
6
7
  //#region src/auth/base.ts
7
8
  const createBetterAuth = (options, initFn) => {
8
- const authContext = initFn(options);
9
+ const authContext = initFn(options).then((ctx) => {
10
+ const validateSchema = ctx.options.advanced?.database?.validateSchema;
11
+ if (!ctx.checkSchema && validateSchema !== false) {
12
+ const level = validateSchema === true ? "warn" : "debug";
13
+ ctx.logger[level](`Schema validation is not available for adapter "${ctx.adapter.id}". Skipping schema validation. Database operations will proceed normally.`);
14
+ }
15
+ const pendingSchemaCheck = ctx.checkSchema?.();
16
+ if (pendingSchemaCheck) pendingSchemaCheck.catch((error) => {
17
+ ctx.logger.error(error instanceof SchemaMismatchError ? error.message : "Could not validate the database schema. Check your database connection.");
18
+ });
19
+ return ctx;
20
+ });
9
21
  const { api } = getEndpoints(authContext, options);
10
22
  const errorCodes = options.plugins?.reduce((acc, plugin) => {
11
23
  if (plugin.$ERROR_CODES) return {