better-auth 1.7.2 → 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 (63) hide show
  1. package/dist/api/index.d.mts +6 -22
  2. package/dist/api/index.mjs +2 -0
  3. package/dist/api/routes/account.d.mts +1 -9
  4. package/dist/api/routes/account.mjs +0 -6
  5. package/dist/api/routes/callback.mjs +0 -2
  6. package/dist/api/routes/password.mjs +0 -2
  7. package/dist/api/routes/session.mjs +12 -5
  8. package/dist/api/routes/sign-in.d.mts +2 -2
  9. package/dist/api/routes/sign-in.mjs +1 -5
  10. package/dist/api/routes/sign-up.mjs +0 -2
  11. package/dist/api/routes/update-user.mjs +0 -2
  12. package/dist/api/to-auth-endpoints.mjs +2 -0
  13. package/dist/auth/base.mjs +13 -1
  14. package/dist/auth/trusted-origins.mjs +6 -4
  15. package/dist/client/config.d.mts +2 -0
  16. package/dist/client/config.mjs +1 -0
  17. package/dist/client/vue/index.d.mts +31 -20
  18. package/dist/client/vue/index.mjs +23 -5
  19. package/dist/context/create-context.mjs +2 -0
  20. package/dist/cookies/session-store.d.mts +0 -1
  21. package/dist/cookies/session-store.mjs +16 -5
  22. package/dist/db/adapter-kysely.mjs +1 -2
  23. package/dist/db/get-migration.d.mts +1 -0
  24. package/dist/db/get-migration.mjs +10 -32
  25. package/dist/db/internal-adapter.mjs +14 -17
  26. package/dist/db/schema.d.mts +0 -1
  27. package/dist/index.mjs +0 -1
  28. package/dist/oauth2/account-key.mjs +1 -5
  29. package/dist/oauth2/link-account.d.mts +0 -1
  30. package/dist/oauth2/link-account.mjs +5 -11
  31. package/dist/package.mjs +1 -1
  32. package/dist/plugins/admin/routes.mjs +0 -3
  33. package/dist/plugins/device-authorization/index.d.mts +11 -11
  34. package/dist/plugins/email-otp/routes.mjs +0 -2
  35. package/dist/plugins/generic-oauth/index.mjs +14 -10
  36. package/dist/plugins/generic-oauth/providers/auth0.mjs +2 -4
  37. package/dist/plugins/generic-oauth/providers/keycloak.mjs +6 -9
  38. package/dist/plugins/generic-oauth/providers/line.mjs +0 -1
  39. package/dist/plugins/generic-oauth/providers/okta.mjs +6 -9
  40. package/dist/plugins/generic-oauth/providers/slack.mjs +0 -1
  41. package/dist/plugins/generic-oauth/types.d.mts +0 -9
  42. package/dist/plugins/haveibeenpwned/index.d.mts +9 -1
  43. package/dist/plugins/haveibeenpwned/index.mjs +31 -11
  44. package/dist/plugins/index.d.mts +2 -2
  45. package/dist/plugins/index.mjs +2 -2
  46. package/dist/plugins/last-login-method/index.mjs +1 -0
  47. package/dist/plugins/oauth-proxy/index.d.mts +17 -0
  48. package/dist/plugins/oauth-proxy/index.mjs +145 -99
  49. package/dist/plugins/one-tap/index.mjs +0 -1
  50. package/dist/plugins/open-api/generator.mjs +15 -1
  51. package/dist/plugins/open-api/index.mjs +0 -1
  52. package/dist/plugins/organization/has-permission.mjs +4 -2
  53. package/dist/plugins/phone-number/routes.mjs +0 -3
  54. package/dist/plugins/siwe/index.mjs +0 -3
  55. package/dist/plugins/two-factor/client.d.mts +1 -0
  56. package/dist/plugins/two-factor/error-code.d.mts +1 -0
  57. package/dist/plugins/two-factor/error-code.mjs +1 -0
  58. package/dist/plugins/two-factor/index.d.mts +1 -0
  59. package/dist/plugins/two-factor/index.mjs +3 -2
  60. package/dist/state.d.mts +0 -13
  61. package/dist/test-utils/test-instance.mjs +10 -9
  62. package/package.json +9 -9
  63. package/dist/utils/index.mjs +0 -5
@@ -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;
@@ -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
  });
@@ -191,7 +191,6 @@ const callbackOAuth = createAuthEndpoint("/callback/:id", {
191
191
  await c.context.internalAdapter.updateAccount(existingAccount.id, updateData);
192
192
  } else if (!await c.context.internalAdapter.createAccount({
193
193
  userId: link.userId,
194
- providerId: provider.id,
195
194
  ...accountKey,
196
195
  ...tokens,
197
196
  accessToken: await setTokenUtil(tokens.accessToken, c.context),
@@ -212,7 +211,6 @@ const callbackOAuth = createAuthEndpoint("/callback/:id", {
212
211
  return redirectOnError(OAUTH_CALLBACK_ERROR_CODES.EMAIL_NOT_FOUND);
213
212
  }
214
213
  const accountData = {
215
- providerId: provider.id,
216
214
  ...accountKey,
217
215
  ...tokens,
218
216
  scope: tokens.scopes?.join(",")
@@ -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,8 +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 "../../utils/index.mjs";
13
- import { createLocalAccountIssuer } from "@better-auth/core/db";
14
12
  import { APIError, BASE_ERROR_CODES } from "@better-auth/core/error";
15
13
  import { additionalAuthorizationParamsSchema, supportsIdTokenSignIn, verifyProviderIdToken } from "@better-auth/core/oauth2";
16
14
  import { SocialProviderListEnum } from "@better-auth/core/social-providers";
@@ -189,7 +187,6 @@ const signInSocial = () => createAuthEndpoint("/sign-in/social", {
189
187
  emailVerified: userInfo.user.emailVerified || false
190
188
  },
191
189
  account: {
192
- providerId: provider.id,
193
190
  ...accountKey,
194
191
  accessToken: c.body.idToken.accessToken,
195
192
  idToken: token
@@ -316,8 +313,7 @@ const signInEmail = () => createAuthEndpoint("/sign-in/email", {
316
313
  const { email, password } = ctx.body;
317
314
  if (!z.email().safeParse(email).success) throw APIError.from("BAD_REQUEST", BASE_ERROR_CODES.INVALID_EMAIL);
318
315
  const userRecord = await ctx.context.internalAdapter.findUserByEmail(email.toLowerCase(), { includeAccounts: true });
319
- const credentialIssuer = createLocalAccountIssuer("credential");
320
- 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);
321
317
  if (!userRecord || !credentialAccount) {
322
318
  await ctx.context.password.hash(password);
323
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 {
@@ -1,6 +1,9 @@
1
1
  import { wildcardMatch } from "../utils/wildcard.mjs";
2
2
  import { getHost, getOrigin, getProtocol } from "../utils/url.mjs";
3
3
  //#region src/auth/trusted-origins.ts
4
+ const CONTROL_CHARACTER_PATTERN = /[\u0000-\u001f\u007f-\u009f]/;
5
+ const RELATIVE_URL_PARSER_ORIGIN = "https://better-auth.invalid";
6
+ const ENCODED_PATH_SEPARATOR_PATTERN = /%2[fF]|%5[cC]/;
4
7
  /**
5
8
  * Resolves `.` and `..` segments in a path after percent-decoding so a
6
9
  * path-pinned pattern cannot be bypassed with traversal: e.g.
@@ -31,6 +34,7 @@ const normalizePath = (path) => {
31
34
  * a path-pinned pattern.
32
35
  */
33
36
  const parseCustomSchemeOrigin = (value) => {
37
+ if (CONTROL_CHARACTER_PATTERN.test(value)) return null;
34
38
  const schemeEnd = value.indexOf(":");
35
39
  if (schemeEnd <= 0) return null;
36
40
  const scheme = value.slice(0, schemeEnd).toLowerCase();
@@ -47,16 +51,14 @@ const parseCustomSchemeOrigin = (value) => {
47
51
  rest = rest.slice(authorityEnd);
48
52
  }
49
53
  }
50
- const path = normalizePath(rest.replace(/[?#].*$/, ""));
54
+ const pathEnd = rest.search(/[?#]/);
55
+ const path = normalizePath(pathEnd === -1 ? rest : rest.slice(0, pathEnd));
51
56
  return {
52
57
  scheme,
53
58
  authority: authority.toLowerCase(),
54
59
  path
55
60
  };
56
61
  };
57
- const RELATIVE_URL_PARSER_ORIGIN = "https://better-auth.invalid";
58
- const CONTROL_CHARACTER_PATTERN = /[\u0000-\u001f\u007f-\u009f]/;
59
- const ENCODED_PATH_SEPARATOR_PATTERN = /%2[fF]|%5[cC]/;
60
62
  /**
61
63
  * Validates root-relative redirects against ambiguous browser and router parsing.
62
64
  *
@@ -1,5 +1,6 @@
1
1
  import { SessionData } from "./session-atom.mjs";
2
2
  import { BetterAuthClientOptions, ClientAtomListener } from "@better-auth/core";
3
+ import * as _$nanostores from "nanostores";
3
4
  import { WritableAtom } from "nanostores";
4
5
  import * as _$_better_fetch_fetch0 from "@better-fetch/fetch";
5
6
 
@@ -11,6 +12,7 @@ declare const getClientConfig: (options?: BetterAuthClientOptions | undefined, l
11
12
  pluginPathMethods: Record<string, "GET" | "POST">;
12
13
  atomListeners: ClientAtomListener[];
13
14
  hydrateSession: (sessionData: SessionData | null) => void;
15
+ $sessionSignal: _$nanostores.PreinitializedWritableAtom<boolean> & object;
14
16
  $fetch: _$_better_fetch_fetch0.BetterFetch<{
15
17
  plugins: (_$_better_fetch_fetch0.BetterFetchPlugin<Record<string, any>> | {
16
18
  id: string;
@@ -104,6 +104,7 @@ const getClientConfig = (options, loadEnv) => {
104
104
  pluginPathMethods,
105
105
  atomListeners,
106
106
  hydrateSession,
107
+ $sessionSignal,
107
108
  $fetch,
108
109
  $store
109
110
  };
@@ -4,7 +4,7 @@ import { getClientConfig } from "../config.mjs";
4
4
  import { BetterAuthClientOptions } from "@better-auth/core";
5
5
  import { BASE_ERROR_CODES } from "@better-auth/core/error";
6
6
  import { BetterFetchError, BetterFetchResponse } from "@better-fetch/fetch";
7
- import { DeepReadonly, Ref } from "vue";
7
+ import { DeepReadonly, Ref, WatchSource } from "vue";
8
8
  export * from "nanostores";
9
9
  export * from "@better-fetch/fetch";
10
10
 
@@ -18,24 +18,34 @@ type ClientConfig = ReturnType<typeof getClientConfig>;
18
18
  type ClientSession<Option extends BetterAuthClientOptions> = InferClientAPI<Option> extends {
19
19
  getSession: () => Promise<infer Res>;
20
20
  } ? Res extends BetterFetchResponse<infer S> ? S : Res : never;
21
- type VueUseSession<Option extends BetterAuthClientOptions> = {
22
- (): DeepReadonly<Ref<{
23
- data: ClientSession<Option>;
24
- isPending: boolean;
25
- isRefetching: boolean;
26
- error: BetterFetchError | null;
27
- refetch: (queryParams?: {
28
- query?: SessionQueryParams;
29
- } | undefined) => Promise<void>;
30
- }>>;
31
- <F extends (...args: any) => any>(useFetch: F): Promise<{
32
- data: Ref<ClientSession<Option>>;
33
- isPending: false;
34
- error: Ref<{
35
- message?: string | undefined;
36
- status: number;
37
- statusText: string;
38
- }>;
21
+ /**
22
+ * Minimal Nuxt-compatible fetch contract for `useSession(useFetch)`.
23
+ * Compatibility with Nuxt's `useFetch` and `UseFetchOptions` is checked by the Nuxt fixture type test.
24
+ */
25
+ type SessionFetch = (url: string, options: {
26
+ headers?: HeadersInit;
27
+ key: string;
28
+ watch: WatchSource<unknown>[];
29
+ }) => Promise<{
30
+ data: Ref<unknown>;
31
+ error: Ref<unknown>;
32
+ }>;
33
+ type VueSessionState<Option extends BetterAuthClientOptions> = DeepReadonly<Ref<{
34
+ data: ClientSession<Option>;
35
+ isPending: boolean;
36
+ isRefetching: boolean;
37
+ error: BetterFetchError | null;
38
+ refetch: (queryParams?: {
39
+ query?: SessionQueryParams;
40
+ } | undefined) => Promise<void>;
41
+ }>>;
42
+ type SessionFetchResult<Option extends BetterAuthClientOptions> = {
43
+ data: Ref<ClientSession<Option>>;
44
+ isPending: false;
45
+ error: Ref<{
46
+ message?: string | undefined;
47
+ status: number;
48
+ statusText: string;
39
49
  }>;
40
50
  };
41
51
  /**
@@ -43,7 +53,8 @@ type VueUseSession<Option extends BetterAuthClientOptions> = {
43
53
  */
44
54
  type VueAuthClient<Option extends BetterAuthClientOptions> = UnionToIntersection<InferResolvedHooks<Option>> & InferClientAPI<Option> & InferActions<Option> & {
45
55
  hydrateSession(session: NonNullable<ClientSession<Option>> | null): void;
46
- useSession: VueUseSession<Option>;
56
+ useSession(): VueSessionState<Option>;
57
+ useSession(useFetch: SessionFetch): Promise<SessionFetchResult<Option>>;
47
58
  $Infer: {
48
59
  Session: NonNullable<ClientSession<Option>>;
49
60
  };