better-auth 1.6.27 → 1.6.28

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 (209) hide show
  1. package/dist/adapters/index.d.mts +6 -1
  2. package/dist/api/dispatch.d.mts +1 -0
  3. package/dist/api/index.d.mts +474 -472
  4. package/dist/api/middlewares/authorization.d.mts +8 -12
  5. package/dist/api/middlewares/authorization.mjs +1 -2
  6. package/dist/api/middlewares/index.d.mts +1 -2
  7. package/dist/api/middlewares/origin-check.d.mts +5 -3
  8. package/dist/api/routes/account.d.mts +13 -10
  9. package/dist/api/routes/callback.d.mts +3 -1
  10. package/dist/api/routes/email-verification.d.mts +8 -4
  11. package/dist/api/routes/error.d.mts +3 -1
  12. package/dist/api/routes/index.d.mts +1 -2
  13. package/dist/api/routes/ok.d.mts +3 -1
  14. package/dist/api/routes/password.d.mts +9 -7
  15. package/dist/api/routes/session.d.mts +24 -22
  16. package/dist/api/routes/sign-in.d.mts +5 -3
  17. package/dist/api/routes/sign-out.d.mts +3 -1
  18. package/dist/api/routes/sign-up.d.mts +4 -3
  19. package/dist/api/routes/update-session.d.mts +4 -3
  20. package/dist/api/routes/update-user.d.mts +14 -13
  21. package/dist/auth/full.d.mts +1 -1
  22. package/dist/auth/minimal.d.mts +1 -1
  23. package/dist/client/config.d.mts +14 -12
  24. package/dist/client/config.mjs +2 -2
  25. package/dist/client/equality.d.mts +1 -0
  26. package/dist/client/index.d.mts +5 -6
  27. package/dist/client/lynx/index.d.mts +5 -4
  28. package/dist/client/lynx/lynx-store.d.mts +2 -1
  29. package/dist/client/parser.d.mts +3 -7
  30. package/dist/client/path-to-object.d.mts +4 -3
  31. package/dist/client/plugins/index.d.mts +1 -1
  32. package/dist/client/plugins/infer-plugin.d.mts +1 -0
  33. package/dist/client/query.d.mts +1 -0
  34. package/dist/client/react/index.d.mts +5 -4
  35. package/dist/client/react/react-store.d.mts +2 -1
  36. package/dist/client/session-atom.mjs +41 -17
  37. package/dist/client/session-refresh.d.mts +1 -0
  38. package/dist/client/solid/index.d.mts +5 -4
  39. package/dist/client/svelte/index.d.mts +5 -4
  40. package/dist/client/types.d.mts +2 -2
  41. package/dist/client/vanilla.d.mts +2 -1
  42. package/dist/client/vue/index.d.mts +5 -4
  43. package/dist/context/create-context.mjs +3 -3
  44. package/dist/context/helpers.mjs +2 -2
  45. package/dist/cookies/index.d.mts +7 -6
  46. package/dist/cookies/session-store.d.mts +0 -1
  47. package/dist/cookies/session-store.mjs +1 -2
  48. package/dist/crypto/index.d.mts +9 -2
  49. package/dist/crypto/jwt.d.mts +1 -0
  50. package/dist/crypto/password.d.mts +5 -1
  51. package/dist/db/adapter-base.d.mts +1 -0
  52. package/dist/db/adapter-kysely.d.mts +1 -0
  53. package/dist/db/field-converter.d.mts +1 -0
  54. package/dist/db/field.d.mts +10 -9
  55. package/dist/db/get-migration.d.mts +1 -0
  56. package/dist/db/get-schema.d.mts +1 -0
  57. package/dist/db/internal-adapter.d.mts +1 -0
  58. package/dist/db/internal-adapter.mjs +1 -2
  59. package/dist/db/revoke-unproven-account-access.d.mts +1 -0
  60. package/dist/db/schema.d.mts +2 -2
  61. package/dist/db/to-zod.d.mts +7 -3
  62. package/dist/db/with-hooks.d.mts +1 -0
  63. package/dist/index.d.mts +3 -4
  64. package/dist/integrations/next-js.d.mts +7 -4
  65. package/dist/integrations/node.d.mts +3 -2
  66. package/dist/integrations/svelte-kit.d.mts +9 -2
  67. package/dist/integrations/tanstack-start-solid.d.mts +5 -2
  68. package/dist/integrations/tanstack-start.d.mts +5 -2
  69. package/dist/oauth2/link-account.d.mts +1 -1
  70. package/dist/oauth2/state.d.mts +1 -0
  71. package/dist/oauth2/utils.d.mts +1 -0
  72. package/dist/package.mjs +1 -1
  73. package/dist/plugins/access/access.d.mts +1 -0
  74. package/dist/plugins/access/types.d.mts +5 -4
  75. package/dist/plugins/additional-fields/client.d.mts +1 -0
  76. package/dist/plugins/admin/access/statement.d.mts +0 -1
  77. package/dist/plugins/admin/admin.d.mts +125 -120
  78. package/dist/plugins/admin/client.d.mts +30 -30
  79. package/dist/plugins/admin/client.mjs +1 -1
  80. package/dist/plugins/admin/error-codes.d.mts +25 -23
  81. package/dist/plugins/admin/index.d.mts +1 -1
  82. package/dist/plugins/admin/schema.d.mts +1 -1
  83. package/dist/plugins/admin/types.d.mts +2 -3
  84. package/dist/plugins/anonymous/client.d.mts +11 -9
  85. package/dist/plugins/anonymous/client.mjs +1 -1
  86. package/dist/plugins/anonymous/error-codes.d.mts +10 -8
  87. package/dist/plugins/anonymous/index.d.mts +18 -14
  88. package/dist/plugins/anonymous/types.d.mts +1 -1
  89. package/dist/plugins/bearer/index.d.mts +7 -4
  90. package/dist/plugins/captcha/index.d.mts +8 -5
  91. package/dist/plugins/captcha/types.d.mts +1 -0
  92. package/dist/plugins/custom-session/client.d.mts +1 -0
  93. package/dist/plugins/custom-session/index.d.mts +12 -7
  94. package/dist/plugins/device-authorization/client.d.mts +1 -0
  95. package/dist/plugins/device-authorization/index.d.mts +22 -19
  96. package/dist/plugins/email-otp/client.d.mts +6 -4
  97. package/dist/plugins/email-otp/client.mjs +1 -1
  98. package/dist/plugins/email-otp/error-codes.d.mts +5 -3
  99. package/dist/plugins/email-otp/index.d.mts +74 -67
  100. package/dist/plugins/email-otp/types.d.mts +1 -0
  101. package/dist/plugins/generic-oauth/client.d.mts +11 -10
  102. package/dist/plugins/generic-oauth/client.mjs +1 -1
  103. package/dist/plugins/generic-oauth/error-codes.d.mts +10 -8
  104. package/dist/plugins/generic-oauth/index.d.mts +44 -40
  105. package/dist/plugins/generic-oauth/providers/auth0.d.mts +1 -0
  106. package/dist/plugins/generic-oauth/providers/gumroad.d.mts +1 -0
  107. package/dist/plugins/generic-oauth/providers/hubspot.d.mts +1 -0
  108. package/dist/plugins/generic-oauth/providers/index.d.mts +1 -2
  109. package/dist/plugins/generic-oauth/providers/keycloak.d.mts +1 -0
  110. package/dist/plugins/generic-oauth/providers/line.d.mts +1 -0
  111. package/dist/plugins/generic-oauth/providers/microsoft-entra-id.d.mts +1 -0
  112. package/dist/plugins/generic-oauth/providers/okta.d.mts +1 -0
  113. package/dist/plugins/generic-oauth/providers/patreon.d.mts +1 -0
  114. package/dist/plugins/generic-oauth/providers/slack.d.mts +1 -0
  115. package/dist/plugins/generic-oauth/providers/yandex.d.mts +1 -0
  116. package/dist/plugins/generic-oauth/types.d.mts +2 -1
  117. package/dist/plugins/haveibeenpwned/index.d.mts +6 -3
  118. package/dist/plugins/index.d.mts +1 -4
  119. package/dist/plugins/jwt/client.d.mts +2 -1
  120. package/dist/plugins/jwt/index.d.mts +11 -8
  121. package/dist/plugins/jwt/sign.d.mts +2 -2
  122. package/dist/plugins/jwt/types.d.mts +1 -1
  123. package/dist/plugins/jwt/utils.d.mts +4 -2
  124. package/dist/plugins/jwt/verify.d.mts +1 -0
  125. package/dist/plugins/last-login-method/index.d.mts +5 -2
  126. package/dist/plugins/magic-link/client.d.mts +1 -0
  127. package/dist/plugins/magic-link/index.d.mts +6 -4
  128. package/dist/plugins/mcp/client/adapters.d.mts +1 -0
  129. package/dist/plugins/mcp/client/index.mjs +2 -4
  130. package/dist/plugins/mcp/index.d.mts +11 -10
  131. package/dist/plugins/multi-session/client.d.mts +4 -2
  132. package/dist/plugins/multi-session/client.mjs +1 -1
  133. package/dist/plugins/multi-session/error-codes.d.mts +3 -1
  134. package/dist/plugins/multi-session/index.d.mts +11 -7
  135. package/dist/plugins/oauth-popup/client.d.mts +12 -6
  136. package/dist/plugins/oauth-popup/client.mjs +3 -5
  137. package/dist/plugins/oauth-popup/error-codes.d.mts +6 -4
  138. package/dist/plugins/oauth-popup/index.d.mts +12 -8
  139. package/dist/plugins/oauth-popup/index.mjs +1 -1
  140. package/dist/plugins/oauth-popup/types.d.mts +2 -1
  141. package/dist/plugins/oauth-proxy/index.d.mts +9 -6
  142. package/dist/plugins/oauth-proxy/index.mjs +2 -2
  143. package/dist/plugins/oidc-provider/client.d.mts +2 -1
  144. package/dist/plugins/oidc-provider/index.d.mts +17 -15
  145. package/dist/plugins/oidc-provider/schema.d.mts +1 -0
  146. package/dist/plugins/oidc-provider/types.d.mts +1 -1
  147. package/dist/plugins/one-tap/client.d.mts +3 -1
  148. package/dist/plugins/one-tap/index.d.mts +3 -1
  149. package/dist/plugins/one-time-token/client.d.mts +2 -1
  150. package/dist/plugins/one-time-token/index.d.mts +6 -5
  151. package/dist/plugins/open-api/generator.d.mts +1 -0
  152. package/dist/plugins/open-api/generator.mjs +5 -5
  153. package/dist/plugins/open-api/index.d.mts +5 -3
  154. package/dist/plugins/organization/access/statement.d.mts +0 -1
  155. package/dist/plugins/organization/adapter.d.mts +82 -56
  156. package/dist/plugins/organization/client.d.mts +103 -104
  157. package/dist/plugins/organization/client.mjs +4 -7
  158. package/dist/plugins/organization/error-codes.d.mts +61 -59
  159. package/dist/plugins/organization/has-permission.d.mts +1 -0
  160. package/dist/plugins/organization/has-permission.mjs +1 -1
  161. package/dist/plugins/organization/index.d.mts +1 -1
  162. package/dist/plugins/organization/organization.d.mts +9 -9
  163. package/dist/plugins/organization/organization.mjs +1 -1
  164. package/dist/plugins/organization/permission.d.mts +2 -2
  165. package/dist/plugins/organization/routes/crud-access-control.d.mts +27 -27
  166. package/dist/plugins/organization/routes/crud-invites.d.mts +64 -63
  167. package/dist/plugins/organization/routes/crud-invites.mjs +1 -1
  168. package/dist/plugins/organization/routes/crud-members.d.mts +56 -54
  169. package/dist/plugins/organization/routes/crud-members.mjs +1 -1
  170. package/dist/plugins/organization/routes/crud-org.d.mts +54 -53
  171. package/dist/plugins/organization/routes/crud-team.d.mts +65 -64
  172. package/dist/plugins/organization/schema.d.mts +4 -4
  173. package/dist/plugins/organization/schema.mjs +1 -1
  174. package/dist/plugins/organization/types.d.mts +14 -14
  175. package/dist/plugins/phone-number/client.d.mts +15 -13
  176. package/dist/plugins/phone-number/client.mjs +1 -1
  177. package/dist/plugins/phone-number/error-codes.d.mts +14 -12
  178. package/dist/plugins/phone-number/index.d.mts +47 -41
  179. package/dist/plugins/phone-number/types.d.mts +1 -1
  180. package/dist/plugins/siwe/client.d.mts +1 -0
  181. package/dist/plugins/siwe/index.d.mts +5 -4
  182. package/dist/plugins/test-utils/index.d.mts +4 -2
  183. package/dist/plugins/test-utils/types.d.mts +0 -1
  184. package/dist/plugins/two-factor/backup-codes/index.d.mts +6 -4
  185. package/dist/plugins/two-factor/backup-codes/index.mjs +1 -1
  186. package/dist/plugins/two-factor/client.d.mts +15 -12
  187. package/dist/plugins/two-factor/client.mjs +1 -1
  188. package/dist/plugins/two-factor/error-code.d.mts +12 -10
  189. package/dist/plugins/two-factor/index.d.mts +31 -27
  190. package/dist/plugins/two-factor/otp/index.d.mts +4 -2
  191. package/dist/plugins/two-factor/totp/index.d.mts +6 -4
  192. package/dist/plugins/two-factor/types.d.mts +1 -1
  193. package/dist/plugins/username/client.d.mts +11 -9
  194. package/dist/plugins/username/client.mjs +1 -1
  195. package/dist/plugins/username/error-codes.d.mts +10 -8
  196. package/dist/plugins/username/index.d.mts +22 -17
  197. package/dist/plugins/username/schema.d.mts +5 -3
  198. package/dist/state.d.mts +1 -0
  199. package/dist/test-utils/test-instance.d.mts +3 -5
  200. package/dist/types/adapter.d.mts +1 -1
  201. package/dist/types/api.d.mts +2 -1
  202. package/dist/types/auth.d.mts +1 -0
  203. package/dist/types/helper.d.mts +5 -5
  204. package/dist/types/index.d.mts +2 -2
  205. package/dist/types/models.d.mts +1 -0
  206. package/dist/types/plugins.d.mts +3 -2
  207. package/dist/utils/index.d.mts +1 -2
  208. package/dist/utils/url.d.mts +1 -0
  209. package/package.json +10 -10
@@ -1,13 +1,14 @@
1
1
  import { AdditionalUserFieldsInput } from "../../types/models.mjs";
2
- import "../../types/index.mjs";
3
2
  import { BetterAuthOptions } from "@better-auth/core";
3
+ import * as _$better_call0 from "better-call";
4
4
  import * as z from "zod";
5
+
5
6
  //#region src/api/routes/update-user.d.ts
6
- declare const updateUser: <O extends BetterAuthOptions>() => import("better-call").StrictEndpoint<"/update-user", {
7
+ declare const updateUser: <O extends BetterAuthOptions>() => _$better_call0.StrictEndpoint<"/update-user", {
7
8
  method: "POST";
8
9
  operationId: string;
9
10
  body: z.ZodRecord<z.ZodString, z.ZodAny>;
10
- use: import("better-call").Middleware<import("better-call").MiddlewareOptions, (inputContext: import("better-call").MiddlewareInputContext<import("better-call").MiddlewareOptions>) => Promise<{
11
+ use: _$better_call0.Middleware<_$better_call0.MiddlewareOptions, (inputContext: _$better_call0.MiddlewareInputContext<_$better_call0.MiddlewareOptions>) => Promise<{
11
12
  session: {
12
13
  session: Record<string, any> & {
13
14
  id: string;
@@ -83,7 +84,7 @@ declare const updateUser: <O extends BetterAuthOptions>() => import("better-call
83
84
  }, {
84
85
  status: boolean;
85
86
  }>;
86
- declare const changePassword: import("better-call").StrictEndpoint<"/change-password", {
87
+ declare const changePassword: _$better_call0.StrictEndpoint<"/change-password", {
87
88
  method: "POST";
88
89
  operationId: string;
89
90
  body: z.ZodObject<{
@@ -91,7 +92,7 @@ declare const changePassword: import("better-call").StrictEndpoint<"/change-pass
91
92
  currentPassword: z.ZodString;
92
93
  revokeOtherSessions: z.ZodOptional<z.ZodBoolean>;
93
94
  }, z.core.$strip>;
94
- use: import("better-call").Middleware<import("better-call").MiddlewareOptions, (inputContext: import("better-call").MiddlewareInputContext<import("better-call").MiddlewareOptions>) => Promise<{
95
+ use: _$better_call0.Middleware<_$better_call0.MiddlewareOptions, (inputContext: _$better_call0.MiddlewareInputContext<_$better_call0.MiddlewareOptions>) => Promise<{
95
96
  session: {
96
97
  session: Record<string, any> & {
97
98
  id: string;
@@ -199,12 +200,12 @@ declare const changePassword: import("better-call").StrictEndpoint<"/change-pass
199
200
  image?: string | null | undefined;
200
201
  };
201
202
  }>;
202
- declare const setPassword: import("better-call").StrictEndpoint<string, {
203
+ declare const setPassword: _$better_call0.StrictEndpoint<string, {
203
204
  method: "POST";
204
205
  body: z.ZodObject<{
205
206
  newPassword: z.ZodString;
206
207
  }, z.core.$strip>;
207
- use: import("better-call").Middleware<import("better-call").MiddlewareOptions, (inputContext: import("better-call").MiddlewareInputContext<import("better-call").MiddlewareOptions>) => Promise<{
208
+ use: _$better_call0.Middleware<_$better_call0.MiddlewareOptions, (inputContext: _$better_call0.MiddlewareInputContext<_$better_call0.MiddlewareOptions>) => Promise<{
208
209
  session: {
209
210
  session: Record<string, any> & {
210
211
  id: string;
@@ -230,9 +231,9 @@ declare const setPassword: import("better-call").StrictEndpoint<string, {
230
231
  }, {
231
232
  status: boolean;
232
233
  }>;
233
- declare const deleteUser: import("better-call").StrictEndpoint<"/delete-user", {
234
+ declare const deleteUser: _$better_call0.StrictEndpoint<"/delete-user", {
234
235
  method: "POST";
235
- use: import("better-call").Middleware<import("better-call").MiddlewareOptions, (inputContext: import("better-call").MiddlewareInputContext<import("better-call").MiddlewareOptions>) => Promise<{
236
+ use: _$better_call0.Middleware<_$better_call0.MiddlewareOptions, (inputContext: _$better_call0.MiddlewareInputContext<_$better_call0.MiddlewareOptions>) => Promise<{
236
237
  session: {
237
238
  session: Record<string, any> & {
238
239
  id: string;
@@ -317,13 +318,13 @@ declare const deleteUser: import("better-call").StrictEndpoint<"/delete-user", {
317
318
  success: boolean;
318
319
  message: string;
319
320
  }>;
320
- declare const deleteUserCallback: import("better-call").StrictEndpoint<"/delete-user/callback", {
321
+ declare const deleteUserCallback: _$better_call0.StrictEndpoint<"/delete-user/callback", {
321
322
  method: "GET";
322
323
  query: z.ZodObject<{
323
324
  token: z.ZodString;
324
325
  callbackURL: z.ZodOptional<z.ZodString>;
325
326
  }, z.core.$strip>;
326
- use: import("better-call").Middleware<import("better-call").MiddlewareOptions, (inputContext: import("better-call").MiddlewareInputContext<import("better-call").MiddlewareOptions>) => Promise<void>>[];
327
+ use: _$better_call0.Middleware<_$better_call0.MiddlewareOptions, (inputContext: _$better_call0.MiddlewareInputContext<_$better_call0.MiddlewareOptions>) => Promise<void>>[];
327
328
  metadata: {
328
329
  openapi: {
329
330
  description: string;
@@ -357,13 +358,13 @@ declare const deleteUserCallback: import("better-call").StrictEndpoint<"/delete-
357
358
  success: boolean;
358
359
  message: string;
359
360
  }>;
360
- declare const changeEmail: import("better-call").StrictEndpoint<"/change-email", {
361
+ declare const changeEmail: _$better_call0.StrictEndpoint<"/change-email", {
361
362
  method: "POST";
362
363
  body: z.ZodObject<{
363
364
  newEmail: z.ZodEmail;
364
365
  callbackURL: z.ZodOptional<z.ZodString>;
365
366
  }, z.core.$strip>;
366
- use: import("better-call").Middleware<import("better-call").MiddlewareOptions, (inputContext: import("better-call").MiddlewareInputContext<import("better-call").MiddlewareOptions>) => Promise<{
367
+ use: _$better_call0.Middleware<_$better_call0.MiddlewareOptions, (inputContext: _$better_call0.MiddlewareInputContext<_$better_call0.MiddlewareOptions>) => Promise<{
367
368
  session: {
368
369
  session: Record<string, any> & {
369
370
  id: string;
@@ -1,6 +1,6 @@
1
1
  import { Auth } from "../types/auth.mjs";
2
- import "../types/index.mjs";
3
2
  import { BetterAuthOptions } from "@better-auth/core";
3
+
4
4
  //#region src/auth/full.d.ts
5
5
  /**
6
6
  * Better Auth initializer for full mode (with Kysely)
@@ -1,6 +1,6 @@
1
1
  import { Auth } from "../types/auth.mjs";
2
- import "../types/index.mjs";
3
2
  import { BetterAuthOptions } from "@better-auth/core";
3
+
4
4
  //#region src/auth/minimal.d.ts
5
5
  /**
6
6
  * Better Auth initializer for minimal mode (without Kysely)
@@ -1,5 +1,7 @@
1
1
  import { BetterAuthClientOptions, ClientAtomListener } from "@better-auth/core";
2
2
  import { WritableAtom } from "nanostores";
3
+ import * as _$_better_fetch_fetch0 from "@better-fetch/fetch";
4
+
3
5
  //#region src/client/config.d.ts
4
6
  declare const getClientConfig: (options?: BetterAuthClientOptions | undefined, loadEnv?: boolean | undefined) => {
5
7
  readonly baseURL: string;
@@ -7,21 +9,21 @@ declare const getClientConfig: (options?: BetterAuthClientOptions | undefined, l
7
9
  pluginsAtoms: Record<string, WritableAtom<any>>;
8
10
  pluginPathMethods: Record<string, "GET" | "POST">;
9
11
  atomListeners: ClientAtomListener[];
10
- $fetch: import("@better-fetch/fetch").BetterFetch<{
11
- plugins: (import("@better-fetch/fetch").BetterFetchPlugin<Record<string, any>> | {
12
+ $fetch: _$_better_fetch_fetch0.BetterFetch<{
13
+ plugins: (_$_better_fetch_fetch0.BetterFetchPlugin<Record<string, any>> | {
12
14
  id: string;
13
15
  name: string;
14
16
  hooks: {
15
- onSuccess(context: import("@better-fetch/fetch").SuccessContext<any>): void;
17
+ onSuccess(context: _$_better_fetch_fetch0.SuccessContext<any>): void;
16
18
  };
17
19
  } | {
18
20
  id: string;
19
21
  name: string;
20
22
  hooks: {
21
- onSuccess: ((context: import("@better-fetch/fetch").SuccessContext<any>) => Promise<void> | void) | undefined;
22
- onError: ((context: import("@better-fetch/fetch").ErrorContext) => Promise<void> | void) | undefined;
23
- onRequest: (<T extends Record<string, any>>(context: import("@better-fetch/fetch").RequestContext<T>) => Promise<import("@better-fetch/fetch").RequestContext | void> | import("@better-fetch/fetch").RequestContext | void) | undefined;
24
- onResponse: ((context: import("@better-fetch/fetch").ResponseContext) => Promise<Response | void | import("@better-fetch/fetch").ResponseContext> | Response | import("@better-fetch/fetch").ResponseContext | void) | undefined;
23
+ onSuccess: ((context: _$_better_fetch_fetch0.SuccessContext<any>) => Promise<void> | void) | undefined;
24
+ onError: ((context: _$_better_fetch_fetch0.ErrorContext) => Promise<void> | void) | undefined;
25
+ onRequest: (<T extends Record<string, any>>(context: _$_better_fetch_fetch0.RequestContext<T>) => Promise<_$_better_fetch_fetch0.RequestContext | void> | _$_better_fetch_fetch0.RequestContext | void) | undefined;
26
+ onResponse: ((context: _$_better_fetch_fetch0.ResponseContext) => Promise<Response | void | _$_better_fetch_fetch0.ResponseContext> | Response | _$_better_fetch_fetch0.ResponseContext | void) | undefined;
25
27
  };
26
28
  })[];
27
29
  priority?: RequestPriority | undefined;
@@ -36,12 +38,12 @@ declare const getClientConfig: (options?: BetterAuthClientOptions | undefined, l
36
38
  referrerPolicy?: ReferrerPolicy | undefined;
37
39
  signal?: (AbortSignal | null) | undefined;
38
40
  window?: null | undefined;
39
- onRetry?: ((response: import("@better-fetch/fetch").ResponseContext) => Promise<void> | void) | undefined;
41
+ onRetry?: ((response: _$_better_fetch_fetch0.ResponseContext) => Promise<void> | void) | undefined;
40
42
  hookOptions?: {
41
43
  cloneResponse?: boolean;
42
44
  } | undefined;
43
45
  timeout?: number | undefined;
44
- customFetchImpl: import("@better-fetch/fetch").FetchEsque;
46
+ customFetchImpl: _$_better_fetch_fetch0.FetchEsque;
45
47
  baseURL: string;
46
48
  throw?: boolean | undefined;
47
49
  auth?: ({
@@ -67,10 +69,10 @@ declare const getClientConfig: (options?: BetterAuthClientOptions | undefined, l
67
69
  params?: any;
68
70
  duplex?: "full" | "half" | undefined;
69
71
  jsonParser: (text: string) => Promise<any> | any;
70
- retry?: import("@better-fetch/fetch").RetryOptions | undefined;
72
+ retry?: _$_better_fetch_fetch0.RetryOptions | undefined;
71
73
  retryAttempt?: number | undefined;
72
- output?: (import("@better-fetch/fetch").StandardSchemaV1 | typeof Blob | typeof File) | undefined;
73
- errorSchema?: import("@better-fetch/fetch").StandardSchemaV1 | undefined;
74
+ output?: (_$_better_fetch_fetch0.StandardSchemaV1 | typeof Blob | typeof File) | undefined;
75
+ errorSchema?: _$_better_fetch_fetch0.StandardSchemaV1 | undefined;
74
76
  disableValidation?: boolean | undefined;
75
77
  disableSignal?: boolean | undefined;
76
78
  }, unknown, unknown, {}>;
@@ -2,7 +2,7 @@ import { getBaseURL } from "../utils/url.mjs";
2
2
  import { parseJSON } from "./parser.mjs";
3
3
  import { redirectPlugin } from "./fetch-plugins.mjs";
4
4
  import { getSessionAtom } from "./session-atom.mjs";
5
- import { defu as defu$1 } from "defu";
5
+ import { defu } from "defu";
6
6
  import { createFetch } from "@better-fetch/fetch";
7
7
  //#region src/client/config.ts
8
8
  const resolvePublicAuthUrl = (basePath) => {
@@ -88,7 +88,7 @@ const getClientConfig = (options, loadEnv) => {
88
88
  },
89
89
  atoms: pluginsAtoms
90
90
  };
91
- for (const plugin of plugins) if (plugin.getActions) pluginsActions = defu$1(plugin.getActions?.($fetch, $store, options) ?? {}, pluginsActions);
91
+ for (const plugin of plugins) if (plugin.getActions) pluginsActions = defu(plugin.getActions?.($fetch, $store, options) ?? {}, pluginsActions);
92
92
  return {
93
93
  get baseURL() {
94
94
  return baseURL;
@@ -1,4 +1,5 @@
1
1
  import { Store, StoreValue } from "nanostores";
2
+
2
3
  //#region src/client/equality.d.ts
3
4
  /**
4
5
  * Deep structural equality for JSON-serializable values.
@@ -11,18 +11,17 @@ import { SessionRefreshOptions, createSessionRefreshManager } from "./session-re
11
11
  import { AuthClient, createAuthClient } from "./vanilla.mjs";
12
12
  import { AccessControl, ArrayElement, ExactRoleStatements, Role, RoleAuthorizeRequest, RoleInput, RoleStatements, Statements, SubArray, Subset } from "../plugins/access/types.mjs";
13
13
  import { AuthorizeResponse, createAccessControl, role } from "../plugins/access/access.mjs";
14
- import "../plugins/access/index.mjs";
15
14
  import { OrganizationOptions } from "../plugins/organization/types.mjs";
16
15
  import { InferInvitation, InferMember, InferOrganization, InferOrganizationRolesFromOption, InferOrganizationZodRolesFromOption, InferTeam, Invitation, InvitationInput, InvitationStatus, Member, MemberInput, Organization, OrganizationInput, OrganizationRole, OrganizationSchema, Team, TeamInput, TeamMember, TeamMemberInput, defaultRolesSchema, invitationSchema, invitationStatus, memberSchema, organizationRoleSchema, organizationSchema, roleSchema, teamMemberSchema, teamSchema } from "../plugins/organization/schema.mjs";
17
16
  import { getOrgAdapter } from "../plugins/organization/adapter.mjs";
18
17
  import { hasPermission } from "../plugins/organization/has-permission.mjs";
19
18
  import { DefaultOrganizationPlugin, DynamicAccessControlEndpoints, OrganizationCreator, OrganizationEndpoints, OrganizationPlugin, TeamEndpoints, organization, parseRoles } from "../plugins/organization/organization.mjs";
20
- import "../plugins/organization/index.mjs";
21
19
  import { BetterAuthOptions, BetterAuthPlugin } from "@better-auth/core";
22
20
  import { DBPrimitive } from "@better-auth/core/db";
23
- export type * from "@better-auth/core/db";
24
- export type * from "nanostores";
25
- export type * from "@better-fetch/fetch";
21
+ export * from "@better-auth/core/db";
22
+ export * from "nanostores";
23
+ export * from "@better-fetch/fetch";
24
+
26
25
  //#region src/client/index.d.ts
27
26
  declare const InferPlugin: <T extends BetterAuthPlugin>() => {
28
27
  id: "infer-server-plugin";
@@ -33,4 +32,4 @@ declare function InferAuth<O extends {
33
32
  options: BetterAuthOptions;
34
33
  }>(): O["options"];
35
34
  //#endregion
36
- export { type AccessControl, type ArrayElement, AuthClient, AuthQueryAtom, AuthQueryState, type AuthorizeResponse, type BetterAuthClientOptions, type BetterAuthClientPlugin, BroadcastChannel, BroadcastListener, BroadcastMessage, type CamelCase, type ClientAtomListener, type ClientStore, type DBPrimitive, type DefaultOrganizationPlugin, type DynamicAccessControlEndpoints, type ExactRoleStatements, type ExtractPluginField, type FocusListener, type FocusManager, type HasRequiredKeys, InferActions, InferAdditionalFromClient, InferAuth, InferClientAPI, type InferCtx, InferErrorCodes, type InferInvitation, type InferMember, type InferOrganization, type InferOrganizationRolesFromOption, type InferOrganizationZodRolesFromOption, InferPlugin, type InferPluginFieldFromTuple, type InferRoute, type InferRoutes, InferSessionFromClient, type InferSessionUpdateCtx, type InferSignUpEmailCtx, type InferTeam, InferUserFromClient, type InferUserUpdateCtx, type Invitation, type InvitationInput, type InvitationStatus, type IsAny, IsSignal, type Member, type MemberInput, type MergeRoutes, type OnlineListener, type OnlineManager, type Organization, type OrganizationCreator, type OrganizationEndpoints, type OrganizationInput, type OrganizationOptions, type OrganizationPlugin, type OrganizationRole, type OrganizationSchema, type OverrideMerge, type PathToObject, type Prettify, type PrettifyDeep, type ProxyRequest, type RequiredKeysOf, type Role, type RoleAuthorizeRequest, type RoleInput, type RoleStatements, SessionQueryParams, SessionRefreshOptions, type Statements, type StripEmptyObjects, type SubArray, type Subset, type Team, type TeamEndpoints, type TeamInput, type TeamMember, type TeamMemberInput, type UnionToIntersection, type createAccessControl, createAuthClient, createSessionRefreshManager, type defaultRolesSchema, getGlobalBroadcastChannel, type getOrgAdapter, type hasPermission, type invitationSchema, type invitationStatus, isJsonEqual, kBroadcastChannel, kFocusManager, kOnlineManager, type memberSchema, type organization, type organizationRoleSchema, type organizationSchema, parseJSON, type parseRoles, type role, type roleSchema, type teamMemberSchema, type teamSchema, useAuthQuery, withEquality };
35
+ export { AccessControl, ArrayElement, AuthClient, AuthQueryAtom, AuthQueryState, AuthorizeResponse, BetterAuthClientOptions, BetterAuthClientPlugin, BroadcastChannel, BroadcastListener, BroadcastMessage, CamelCase, ClientAtomListener, ClientStore, type DBPrimitive, DefaultOrganizationPlugin, DynamicAccessControlEndpoints, ExactRoleStatements, ExtractPluginField, type FocusListener, type FocusManager, HasRequiredKeys, InferActions, InferAdditionalFromClient, InferAuth, InferClientAPI, InferCtx, InferErrorCodes, InferInvitation, InferMember, InferOrganization, InferOrganizationRolesFromOption, InferOrganizationZodRolesFromOption, InferPlugin, InferPluginFieldFromTuple, InferRoute, InferRoutes, InferSessionFromClient, InferSessionUpdateCtx, InferSignUpEmailCtx, InferTeam, InferUserFromClient, InferUserUpdateCtx, Invitation, InvitationInput, InvitationStatus, IsAny, IsSignal, Member, MemberInput, MergeRoutes, type OnlineListener, type OnlineManager, Organization, OrganizationCreator, OrganizationEndpoints, OrganizationInput, OrganizationOptions, OrganizationPlugin, OrganizationRole, OrganizationSchema, OverrideMerge, PathToObject, Prettify, PrettifyDeep, ProxyRequest, RequiredKeysOf, Role, RoleAuthorizeRequest, RoleInput, RoleStatements, SessionQueryParams, SessionRefreshOptions, Statements, StripEmptyObjects, SubArray, Subset, Team, TeamEndpoints, TeamInput, TeamMember, TeamMemberInput, type UnionToIntersection, createAccessControl, createAuthClient, createSessionRefreshManager, defaultRolesSchema, getGlobalBroadcastChannel, getOrgAdapter, hasPermission, invitationSchema, invitationStatus, isJsonEqual, kBroadcastChannel, kFocusManager, kOnlineManager, memberSchema, organization, organizationRoleSchema, organizationSchema, parseJSON, parseRoles, role, roleSchema, teamMemberSchema, teamSchema, useAuthQuery, withEquality };
@@ -5,14 +5,15 @@ import { useStore } from "./lynx-store.mjs";
5
5
  import { BetterAuthClientOptions } from "@better-auth/core";
6
6
  import { BASE_ERROR_CODES } from "@better-auth/core/error";
7
7
  import { BetterFetchError, BetterFetchResponse } from "@better-fetch/fetch";
8
- export type * from "nanostores";
9
- export type * from "@better-fetch/fetch";
8
+ export * from "nanostores";
9
+ export * from "@better-fetch/fetch";
10
+
10
11
  //#region src/client/lynx/index.d.ts
11
12
  type InferResolvedHooks<O extends BetterAuthClientOptions> = O extends {
12
13
  plugins: Array<infer Plugin>;
13
14
  } ? UnionToIntersection<Plugin extends {
14
15
  getAtoms?: infer GetAtoms;
15
- } ? GetAtoms extends ((fetch: any) => infer Atoms) ? Atoms extends Record<string, any> ? { [key in keyof Atoms as IsSignal<key> extends true ? never : key extends string ? `use${Capitalize<key>}` : never]: () => ReturnType<Atoms[key]["get"]>; } : {} : {} : {}> : {};
16
+ } ? GetAtoms extends ((fetch: any) => infer Atoms) ? Atoms extends Record<string, any> ? { [key in keyof Atoms as IsSignal<key> extends true ? never : key extends string ? `use${Capitalize<key>}` : never]: () => ReturnType<Atoms[key]["get"]> } : {} : {} : {}> : {};
16
17
  type ClientConfig = ReturnType<typeof getClientConfig>;
17
18
  type ClientSession<Option extends BetterAuthClientOptions> = InferClientAPI<Option> extends {
18
19
  getSession: () => Promise<infer Res>;
@@ -38,4 +39,4 @@ type LynxAuthClient<Option extends BetterAuthClientOptions> = UnionToIntersectio
38
39
  };
39
40
  declare function createAuthClient<Option extends BetterAuthClientOptions>(options?: Option | undefined): LynxAuthClient<Option>;
40
41
  //#endregion
41
- export { type ExtractPluginField, type HasRequiredKeys, type InferPluginFieldFromTuple, type IsAny, LynxAuthClient, type OverrideMerge, type Prettify, type PrettifyDeep, type RequiredKeysOf, type StripEmptyObjects, type UnionToIntersection, createAuthClient, useStore };
42
+ export { ExtractPluginField, HasRequiredKeys, InferPluginFieldFromTuple, IsAny, LynxAuthClient, OverrideMerge, Prettify, PrettifyDeep, RequiredKeysOf, StripEmptyObjects, type UnionToIntersection, createAuthClient, useStore };
@@ -1,5 +1,6 @@
1
1
  import { Store, StoreValue } from "nanostores";
2
2
  import { DependencyList } from "@lynx-js/react";
3
+
3
4
  //#region src/client/lynx/lynx-store.d.ts
4
5
  type StoreKeys<T> = T extends {
5
6
  setKey: (k: infer K, v: any) => unknown;
@@ -42,4 +43,4 @@ interface UseStoreOptions<SomeStore> {
42
43
  */
43
44
  declare function useStore<SomeStore extends Store>(store: SomeStore, options?: UseStoreOptions<SomeStore>): StoreValue<SomeStore>;
44
45
  //#endregion
45
- export { UseStoreOptions, useStore };
46
+ export { useStore };
@@ -1,12 +1,8 @@
1
1
  //#region src/client/parser.d.ts
2
2
  type ParseOptions = {
3
- /** Throw errors instead of returning the original value */
4
- strict?: boolean | undefined;
5
- /** Log warnings when suspicious patterns are detected */
6
- warnings?: boolean | undefined;
7
- /** Custom reviver function */
8
- reviver?: ((key: string, value: any) => any) | undefined;
9
- /** Automatically convert ISO date strings to Date objects */
3
+ /** Throw errors instead of returning the original value */strict?: boolean | undefined; /** Log warnings when suspicious patterns are detected */
4
+ warnings?: boolean | undefined; /** Custom reviver function */
5
+ reviver?: ((key: string, value: any) => any) | undefined; /** Automatically convert ISO date strings to Date objects */
10
6
  parseDates?: boolean | undefined;
11
7
  };
12
8
  declare function parseJSON<T = unknown>(value: unknown, options?: ParseOptions): T;
@@ -3,11 +3,12 @@ import { InferAdditionalFromClient, InferSessionFromClient, InferUserFromClient
3
3
  import { BetterAuthClientOptions, ClientFetchOption } from "@better-auth/core";
4
4
  import { Endpoint, InputContext, StandardSchemaV1 } from "better-call";
5
5
  import { BetterFetchResponse } from "@better-fetch/fetch";
6
+
6
7
  //#region src/client/path-to-object.d.ts
7
8
  type KeepNullishFromOriginal<Original, Replaced> = Replaced | (undefined extends Original ? undefined : never) | (null extends Original ? null : never);
8
- type ReplaceTopLevelField<Data, Field extends "user" | "session", Replaced> = Data extends object ? Field extends keyof Data ? Omit<Data, Field> & { [K in Field]: KeepNullishFromOriginal<Data[K], Replaced>; } : Data : Data;
9
+ type ReplaceTopLevelField<Data, Field extends "user" | "session", Replaced> = Data extends object ? Field extends keyof Data ? Omit<Data, Field> & { [K in Field]: KeepNullishFromOriginal<Data[K], Replaced> } : Data : Data;
9
10
  type ReplaceAuthUserAndSession<Data, ClientOpts extends BetterAuthClientOptions> = ReplaceTopLevelField<ReplaceTopLevelField<Data, "user", InferUserFromClient<ClientOpts>>, "session", InferSessionFromClient<ClientOpts>>;
10
- type MergeCustomSessionField<R extends object, Field extends "user" | "session", InferType> = Field extends keyof R ? { [K in Field]: KeepNullishFromOriginal<R[K], NonNullable<R[K]> & InferType>; } : {};
11
+ type MergeCustomSessionField<R extends object, Field extends "user" | "session", InferType> = Field extends keyof R ? { [K in Field]: KeepNullishFromOriginal<R[K], NonNullable<R[K]> & InferType> } : {};
11
12
  type MergeCustomSessionWithInferred<R, ClientOpts extends BetterAuthClientOptions> = R extends object ? Omit<R, "user" | "session"> & MergeCustomSessionField<R, "user", InferUserFromClient<ClientOpts>> & MergeCustomSessionField<R, "session", InferSessionFromClient<ClientOpts>> : never;
12
13
  type RefineAuthResponse<Data, ClientOpts extends BetterAuthClientOptions> = Data extends {
13
14
  token: unknown;
@@ -15,7 +16,7 @@ type RefineAuthResponse<Data, ClientOpts extends BetterAuthClientOptions> = Data
15
16
  redirect: unknown;
16
17
  } ? ReplaceAuthUserAndSession<Data, ClientOpts> : Data;
17
18
  type CamelCase<S extends string> = S extends `${infer P1}-${infer P2}${infer P3}` ? `${Lowercase<P1>}${Uppercase<P2>}${CamelCase<P3>}` : Lowercase<S>;
18
- type PathToObject<T extends string, Fn extends (...args: any[]) => any> = T extends `/${infer Segment}/${infer Rest}` ? { [K in CamelCase<Segment>]: PathToObject<`/${Rest}`, Fn>; } : T extends `/${infer Segment}` ? { [K in CamelCase<Segment>]: Fn; } : never;
19
+ type PathToObject<T extends string, Fn extends (...args: any[]) => any> = T extends `/${infer Segment}/${infer Rest}` ? { [K in CamelCase<Segment>]: PathToObject<`/${Rest}`, Fn> } : T extends `/${infer Segment}` ? { [K in CamelCase<Segment>]: Fn } : never;
19
20
  type InferSignUpEmailCtx<ClientOpts extends BetterAuthClientOptions, FetchOptions extends ClientFetchOption> = {
20
21
  email: string;
21
22
  name: string;
@@ -57,4 +57,4 @@ import { phoneNumberClient } from "../../plugins/phone-number/client.mjs";
57
57
  import { siweClient } from "../../plugins/siwe/client.mjs";
58
58
  import { usernameClient } from "../../plugins/username/client.mjs";
59
59
  import { InferServerPlugin } from "./infer-plugin.mjs";
60
- export { ADMIN_ERROR_CODES, ANONYMOUS_ERROR_CODES, AdminClientOptions, type AdminOptions, type AnonymousOptions, type AnonymousSession, type Auth0Options, type AuthorizationQuery, type BackupCodeOptions, type BaseOAuthProviderOptions, type Client, type CodeVerificationValue, EMAIL_OTP_ERROR_CODES, type ExtractPluginField, type FieldAttributeToObject, GENERIC_OAUTH_ERROR_CODES, type GenericOAuthConfig, type GenericOAuthOptions, GoogleOneTapActionOptions, GoogleOneTapOptions, GsiButtonConfiguration, type GumroadOptions, type HasRequiredKeys, type HubSpotOptions, type InferAdminRolesFromOption, type InferInvitation, type InferMember, type InferOrganization, type InferOrganizationRolesFromOption, type InferOrganizationZodRolesFromOption, type InferPluginFieldFromTuple, InferServerPlugin, type InferTeam, type Invitation, type InvitationInput, type InvitationStatus, type IsAny, type JWKOptions, type JWSAlgorithms, type Jwk, type JwtOptions, type KeycloakOptions, LastLoginMethodClientConfig, type LineOptions, MULTI_SESSION_ERROR_CODES, type Member, type MemberInput, type MicrosoftEntraIdOptions, type MultiSessionConfig, OAUTH_POPUP_ERROR_CODES, type OAuthAccessToken, type OIDCMetadata, type OIDCOptions, ORGANIZATION_ERROR_CODES, type OTPOptions, OidcClientPlugin, type OktaOptions, type OneTimeTokenOptions, type Organization, OrganizationClientOptions, type OrganizationInput, type OrganizationRole, type OrganizationSchema, type OverrideMerge, PHONE_NUMBER_ERROR_CODES, POPUP_TOKEN_STORAGE_KEY, type PatreonOptions, type PhoneNumberOptions, type Prettify, type PrettifyDeep, type RemoveFieldsWithReturnedFalse, type RequiredKeysOf, type SessionWithImpersonatedBy, SignInPopupOptions, SignInPopupResult, type SlackOptions, type StripEmptyObjects, type TOTPOptions, TWO_FACTOR_ERROR_CODES, type Team, type TeamInput, type TeamMember, type TeamMemberInput, type TokenBody, type TwoFactorOptions, type TwoFactorProvider, type TwoFactorTable, USERNAME_ERROR_CODES, type UnionToIntersection, type UserWithAnonymous, type UserWithPhoneNumber, type UserWithRole, type UserWithTwoFactor, type YandexOptions, adminClient, anonymousClient, type auth0, type backupCode2fa, clientSideHasPermission, createSignInPopup, customSessionClient, type defaultRolesSchema, deviceAuthorizationClient, emailOTPClient, type encodeBackupCodes, type generateBackupCodes, genericOAuthClient, type getBackupCodes, getStoredPopupToken, type gumroad, type hubspot, inferAdditionalFields, inferOrgAdditionalFields, type invitationSchema, type invitationStatus, jwtClient, type keycloak, lastLoginMethodClient, type line, magicLinkClient, type memberSchema, type microsoftEntraId, multiSessionClient, oauthPopupClient, oidcClient, type okta, oneTapClient, oneTimeTokenClient, organizationClient, type organizationRoleSchema, type organizationSchema, type otp2fa, type patreon, phoneNumberClient, popupBearerFetchPlugin, type roleSchema, type schema, siweClient, type slack, type teamMemberSchema, type teamSchema, type totp2fa, twoFactorClient, usernameClient, type verifyBackupCode, type yandex };
60
+ export { ADMIN_ERROR_CODES, ANONYMOUS_ERROR_CODES, AdminClientOptions, AdminOptions, AnonymousOptions, AnonymousSession, Auth0Options, AuthorizationQuery, BackupCodeOptions, BaseOAuthProviderOptions, Client, CodeVerificationValue, EMAIL_OTP_ERROR_CODES, ExtractPluginField, type FieldAttributeToObject, GENERIC_OAUTH_ERROR_CODES, GenericOAuthConfig, GenericOAuthOptions, GoogleOneTapActionOptions, GoogleOneTapOptions, GsiButtonConfiguration, GumroadOptions, HasRequiredKeys, HubSpotOptions, InferAdminRolesFromOption, InferInvitation, InferMember, InferOrganization, InferOrganizationRolesFromOption, InferOrganizationZodRolesFromOption, InferPluginFieldFromTuple, InferServerPlugin, InferTeam, Invitation, InvitationInput, InvitationStatus, IsAny, JWKOptions, JWSAlgorithms, Jwk, JwtOptions, KeycloakOptions, LastLoginMethodClientConfig, LineOptions, MULTI_SESSION_ERROR_CODES, Member, MemberInput, MicrosoftEntraIdOptions, MultiSessionConfig, OAUTH_POPUP_ERROR_CODES, OAuthAccessToken, OIDCMetadata, OIDCOptions, ORGANIZATION_ERROR_CODES, OTPOptions, OidcClientPlugin, OktaOptions, OneTimeTokenOptions, Organization, OrganizationClientOptions, OrganizationInput, OrganizationRole, OrganizationSchema, OverrideMerge, PHONE_NUMBER_ERROR_CODES, POPUP_TOKEN_STORAGE_KEY, PatreonOptions, PhoneNumberOptions, Prettify, PrettifyDeep, type RemoveFieldsWithReturnedFalse, RequiredKeysOf, SessionWithImpersonatedBy, SignInPopupOptions, SignInPopupResult, SlackOptions, StripEmptyObjects, TOTPOptions, TWO_FACTOR_ERROR_CODES, Team, TeamInput, TeamMember, TeamMemberInput, TokenBody, TwoFactorOptions, TwoFactorProvider, TwoFactorTable, USERNAME_ERROR_CODES, UnionToIntersection, UserWithAnonymous, UserWithPhoneNumber, UserWithRole, UserWithTwoFactor, YandexOptions, adminClient, anonymousClient, auth0, backupCode2fa, clientSideHasPermission, createSignInPopup, customSessionClient, defaultRolesSchema, deviceAuthorizationClient, emailOTPClient, encodeBackupCodes, generateBackupCodes, genericOAuthClient, getBackupCodes, getStoredPopupToken, gumroad, hubspot, inferAdditionalFields, inferOrgAdditionalFields, invitationSchema, invitationStatus, jwtClient, keycloak, lastLoginMethodClient, line, magicLinkClient, memberSchema, microsoftEntraId, multiSessionClient, oauthPopupClient, oidcClient, okta, oneTapClient, oneTimeTokenClient, organizationClient, organizationRoleSchema, organizationSchema, otp2fa, patreon, phoneNumberClient, popupBearerFetchPlugin, roleSchema, schema, siweClient, slack, teamMemberSchema, teamSchema, totp2fa, twoFactorClient, usernameClient, verifyBackupCode, yandex };
@@ -1,4 +1,5 @@
1
1
  import { BetterAuthOptions } from "@better-auth/core";
2
+
2
3
  //#region src/client/plugins/infer-plugin.d.ts
3
4
  declare const InferServerPlugin: <AuthOrOption extends BetterAuthOptions | {
4
5
  options: BetterAuthOptions;
@@ -2,6 +2,7 @@ import { SessionQueryParams } from "./types.mjs";
2
2
  import { ClientFetchOption } from "@better-auth/core";
3
3
  import { PreinitializedWritableAtom } from "nanostores";
4
4
  import { BetterFetch, BetterFetchError } from "@better-fetch/fetch";
5
+
5
6
  //#region src/client/query.d.ts
6
7
  type AuthQueryState<T> = {
7
8
  data: null | T;
@@ -5,14 +5,15 @@ import { useStore } from "./react-store.mjs";
5
5
  import { BetterAuthClientOptions } from "@better-auth/core";
6
6
  import { BASE_ERROR_CODES } from "@better-auth/core/error";
7
7
  import { BetterFetchError, BetterFetchResponse } from "@better-fetch/fetch";
8
- export type * from "nanostores";
9
- export type * from "@better-fetch/fetch";
8
+ export * from "nanostores";
9
+ export * from "@better-fetch/fetch";
10
+
10
11
  //#region src/client/react/index.d.ts
11
12
  type InferResolvedHooks<O extends BetterAuthClientOptions> = O extends {
12
13
  plugins: Array<infer Plugin>;
13
14
  } ? UnionToIntersection<Plugin extends {
14
15
  getAtoms?: infer GetAtoms;
15
- } ? GetAtoms extends ((fetch: any) => infer Atoms) ? Atoms extends Record<string, any> ? { [key in keyof Atoms as IsSignal<key> extends true ? never : key extends string ? `use${Capitalize<key>}` : never]: () => ReturnType<Atoms[key]["get"]>; } : {} : {} : {}> : {};
16
+ } ? GetAtoms extends ((fetch: any) => infer Atoms) ? Atoms extends Record<string, any> ? { [key in keyof Atoms as IsSignal<key> extends true ? never : key extends string ? `use${Capitalize<key>}` : never]: () => ReturnType<Atoms[key]["get"]> } : {} : {} : {}> : {};
16
17
  type ClientConfig = ReturnType<typeof getClientConfig>;
17
18
  type ClientSession<Option extends BetterAuthClientOptions> = InferClientAPI<Option> extends {
18
19
  getSession: () => Promise<infer Res>;
@@ -39,4 +40,4 @@ type ReactAuthClient<Option extends BetterAuthClientOptions> = UnionToIntersecti
39
40
  };
40
41
  declare function createAuthClient<Option extends BetterAuthClientOptions>(options?: Option | undefined): ReactAuthClient<Option>;
41
42
  //#endregion
42
- export { type ExtractPluginField, type HasRequiredKeys, type InferPluginFieldFromTuple, type IsAny, type OverrideMerge, type Prettify, type PrettifyDeep, ReactAuthClient, type RequiredKeysOf, type StripEmptyObjects, type UnionToIntersection, createAuthClient, useStore };
43
+ export { ExtractPluginField, HasRequiredKeys, InferPluginFieldFromTuple, IsAny, OverrideMerge, Prettify, PrettifyDeep, ReactAuthClient, RequiredKeysOf, StripEmptyObjects, type UnionToIntersection, createAuthClient, useStore };
@@ -1,5 +1,6 @@
1
1
  import { Store, StoreValue } from "nanostores";
2
2
  import { DependencyList } from "react";
3
+
3
4
  //#region src/client/react/react-store.d.ts
4
5
  type StoreKeys<T> = T extends {
5
6
  setKey: (k: infer K, v: any) => unknown;
@@ -42,4 +43,4 @@ interface UseStoreOptions<SomeStore> {
42
43
  */
43
44
  declare function useStore<SomeStore extends Store>(store: SomeStore, options?: UseStoreOptions<SomeStore>): StoreValue<SomeStore>;
44
45
  //#endregion
45
- export { UseStoreOptions, useStore };
46
+ export { useStore };
@@ -1,8 +1,9 @@
1
1
  import { isJsonEqual, withEquality } from "./equality.mjs";
2
2
  import { createSessionRefreshManager } from "./session-refresh.mjs";
3
- import { atom, onMount } from "nanostores";
3
+ import { STORE_UNMOUNT_DELAY, atom, onMount } from "nanostores";
4
4
  //#region src/client/session-atom.ts
5
5
  const isServer = () => typeof window === "undefined";
6
+ const SESSION_MOUNT_DEDUPE_INTERVAL = STORE_UNMOUNT_DELAY;
6
7
  /**
7
8
  * Normalize $fetch response: `throw: true` returns data directly,
8
9
  * otherwise `{ data, error }`.
@@ -24,7 +25,13 @@ function isSessionAtomEqual(a, b) {
24
25
  }
25
26
  function getSessionAtom($fetch, options) {
26
27
  const $signal = atom(false);
27
- let activeRequest;
28
+ let flight;
29
+ let freshUntil = 0;
30
+ let sessionRevision = 0;
31
+ $signal.listen(() => {
32
+ sessionRevision++;
33
+ freshUntil = 0;
34
+ });
28
35
  const refetch = (queryParams) => fetchSession(queryParams);
29
36
  const session = atom({
30
37
  data: null,
@@ -43,24 +50,26 @@ function getSessionAtom($fetch, options) {
43
50
  error: null,
44
51
  refetch
45
52
  });
46
- if (signal.aborted) return;
53
+ if (signal.aborted) return "aborted";
47
54
  try {
48
55
  const res = await $fetch("/get-session", {
49
56
  method: "GET",
50
57
  query: queryParams?.query,
51
58
  signal
52
59
  });
53
- if (signal.aborted) return;
60
+ if (signal.aborted) return "aborted";
54
61
  let { data, error } = normalizeSessionResponse(res);
62
+ let outcome = "fresh";
55
63
  if (data?.needsRefresh) try {
56
64
  const refreshRes = await $fetch("/get-session", {
57
65
  method: "POST",
58
66
  signal
59
67
  });
60
- if (signal.aborted) return;
68
+ if (signal.aborted) return "aborted";
61
69
  ({data, error} = normalizeSessionResponse(refreshRes));
62
70
  } catch {
63
- if (signal.aborted) return;
71
+ if (signal.aborted) return "aborted";
72
+ outcome = "stale";
64
73
  }
65
74
  if (error) {
66
75
  const latest = session.value;
@@ -72,7 +81,7 @@ function getSessionAtom($fetch, options) {
72
81
  isRefetching: false,
73
82
  refetch
74
83
  });
75
- return;
84
+ return "failed";
76
85
  }
77
86
  const sessionData = normalizeSessionData(data);
78
87
  const current = session.value;
@@ -84,8 +93,9 @@ function getSessionAtom($fetch, options) {
84
93
  isRefetching: false,
85
94
  refetch
86
95
  });
96
+ return outcome;
87
97
  } catch (fetchError) {
88
- if (signal.aborted) return;
98
+ if (signal.aborted) return "aborted";
89
99
  const latest = session.value;
90
100
  session.set({
91
101
  data: latest.data,
@@ -94,26 +104,40 @@ function getSessionAtom($fetch, options) {
94
104
  isRefetching: false,
95
105
  refetch
96
106
  });
107
+ return "failed";
97
108
  }
98
109
  };
110
+ const getFreshUntil = () => {
111
+ const expiresAt = session.value.data?.session?.expiresAt;
112
+ const sessionExpiresAt = expiresAt instanceof Date ? expiresAt.getTime() : Number.POSITIVE_INFINITY;
113
+ return Math.min(Date.now() + SESSION_MOUNT_DEDUPE_INTERVAL, sessionExpiresAt);
114
+ };
99
115
  const fetchSession = (queryParams) => {
100
- activeRequest?.cancel();
116
+ freshUntil = 0;
117
+ flight?.cancel();
101
118
  const controller = new AbortController();
102
119
  const request = {
103
120
  cancel: () => controller.abort(),
104
121
  promise: Promise.resolve().then(() => {
105
- if (controller.signal.aborted) return;
122
+ if (controller.signal.aborted) return "aborted";
106
123
  return executeSessionFetch(controller.signal, queryParams);
107
- })
124
+ }),
125
+ revision: sessionRevision
108
126
  };
109
- activeRequest = request;
110
- const clearActiveRequest = () => {
111
- if (activeRequest === request) activeRequest = void 0;
127
+ flight = request;
128
+ const settleFlight = (outcome) => {
129
+ if (flight !== request) return;
130
+ flight = void 0;
131
+ if (outcome === "fresh" && request.revision === sessionRevision) freshUntil = getFreshUntil();
112
132
  };
113
- request.promise.then(clearActiveRequest, clearActiveRequest);
114
- return request.promise;
133
+ request.promise.then(settleFlight, () => settleFlight("failed"));
134
+ return request.promise.then(() => void 0);
135
+ };
136
+ const fetchSessionOnMount = () => {
137
+ if (flight?.revision === sessionRevision) return flight.promise.then(() => void 0);
138
+ if (Date.now() < freshUntil) return Promise.resolve();
139
+ return fetchSession();
115
140
  };
116
- const fetchSessionOnMount = () => activeRequest?.promise ?? fetchSession();
117
141
  let broadcastSessionUpdate = () => {};
118
142
  onMount(session, () => {
119
143
  let timeoutId;
@@ -1,5 +1,6 @@
1
1
  import { BetterAuthClientOptions } from "@better-auth/core";
2
2
  import { WritableAtom } from "nanostores";
3
+
3
4
  //#region src/client/session-refresh.d.ts
4
5
  interface SessionRefreshOptions {
5
6
  fetchSession: () => Promise<void>;
@@ -5,14 +5,15 @@ 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
7
  import { Accessor } from "solid-js";
8
- export type * from "nanostores";
9
- export type * from "@better-fetch/fetch";
8
+ export * from "nanostores";
9
+ export * from "@better-fetch/fetch";
10
+
10
11
  //#region src/client/solid/index.d.ts
11
12
  type InferResolvedHooks<O extends BetterAuthClientOptions> = O extends {
12
13
  plugins: Array<infer Plugin>;
13
14
  } ? UnionToIntersection<Plugin extends {
14
15
  getAtoms?: infer GetAtoms;
15
- } ? GetAtoms extends ((fetch: any) => infer Atoms) ? Atoms extends Record<string, any> ? { [key in keyof Atoms as IsSignal<key> extends true ? never : key extends string ? `use${Capitalize<key>}` : never]: () => Accessor<ReturnType<Atoms[key]["get"]>>; } : {} : {} : {}> : {};
16
+ } ? GetAtoms extends ((fetch: any) => infer Atoms) ? Atoms extends Record<string, any> ? { [key in keyof Atoms as IsSignal<key> extends true ? never : key extends string ? `use${Capitalize<key>}` : never]: () => Accessor<ReturnType<Atoms[key]["get"]>> } : {} : {} : {}> : {};
16
17
  type ClientConfig = ReturnType<typeof getClientConfig>;
17
18
  type ClientSession<Option extends BetterAuthClientOptions> = InferClientAPI<Option> extends {
18
19
  getSession: () => Promise<infer Res>;
@@ -39,4 +40,4 @@ type SolidAuthClient<Option extends BetterAuthClientOptions> = UnionToIntersecti
39
40
  };
40
41
  declare function createAuthClient<Option extends BetterAuthClientOptions>(options?: Option | undefined): SolidAuthClient<Option>;
41
42
  //#endregion
42
- export { type ExtractPluginField, type HasRequiredKeys, type InferPluginFieldFromTuple, type IsAny, type OverrideMerge, type Prettify, type PrettifyDeep, type RequiredKeysOf, SolidAuthClient, type StripEmptyObjects, type UnionToIntersection, createAuthClient };
43
+ export { ExtractPluginField, HasRequiredKeys, InferPluginFieldFromTuple, IsAny, OverrideMerge, Prettify, PrettifyDeep, RequiredKeysOf, SolidAuthClient, StripEmptyObjects, type UnionToIntersection, createAuthClient };
@@ -5,14 +5,15 @@ import { BetterAuthClientOptions } from "@better-auth/core";
5
5
  import { BASE_ERROR_CODES } from "@better-auth/core/error";
6
6
  import { Atom } from "nanostores";
7
7
  import { BetterFetchError, BetterFetchResponse } from "@better-fetch/fetch";
8
- export type * from "nanostores";
9
- export type * from "@better-fetch/fetch";
8
+ export * from "nanostores";
9
+ export * from "@better-fetch/fetch";
10
+
10
11
  //#region src/client/svelte/index.d.ts
11
12
  type InferResolvedHooks<O extends BetterAuthClientOptions> = O extends {
12
13
  plugins: Array<infer Plugin>;
13
14
  } ? UnionToIntersection<Plugin extends {
14
15
  getAtoms?: infer GetAtoms;
15
- } ? GetAtoms extends ((fetch: any) => infer Atoms) ? Atoms extends Record<string, any> ? { [key in keyof Atoms as IsSignal<key> extends true ? never : key extends string ? `use${Capitalize<key>}` : never]: () => Atoms[key]; } : {} : {} : {}> : {};
16
+ } ? GetAtoms extends ((fetch: any) => infer Atoms) ? Atoms extends Record<string, any> ? { [key in keyof Atoms as IsSignal<key> extends true ? never : key extends string ? `use${Capitalize<key>}` : never]: () => Atoms[key] } : {} : {} : {}> : {};
16
17
  type ClientConfig = ReturnType<typeof getClientConfig>;
17
18
  type ClientSession<Option extends BetterAuthClientOptions> = InferClientAPI<Option> extends {
18
19
  getSession: () => Promise<infer Res>;
@@ -39,4 +40,4 @@ type SvelteAuthClient<Option extends BetterAuthClientOptions> = UnionToIntersect
39
40
  };
40
41
  declare function createAuthClient<Option extends BetterAuthClientOptions>(options?: Option | undefined): SvelteAuthClient<Option>;
41
42
  //#endregion
42
- export { type ExtractPluginField, type HasRequiredKeys, type InferPluginFieldFromTuple, type IsAny, type OverrideMerge, type Prettify, type PrettifyDeep, type RequiredKeysOf, type StripEmptyObjects, SvelteAuthClient, type UnionToIntersection, createAuthClient };
43
+ export { ExtractPluginField, HasRequiredKeys, InferPluginFieldFromTuple, IsAny, OverrideMerge, Prettify, PrettifyDeep, RequiredKeysOf, StripEmptyObjects, SvelteAuthClient, type UnionToIntersection, createAuthClient };
@@ -3,9 +3,9 @@ import { StripEmptyObjects, UnionToIntersection } from "../types/helper.mjs";
3
3
  import { InferRoutes } from "./path-to-object.mjs";
4
4
  import { Session as Session$1, User as User$1 } from "../types/models.mjs";
5
5
  import { Auth } from "../types/auth.mjs";
6
- import "../types/index.mjs";
7
6
  import { BetterAuthClientOptions as BetterAuthClientOptions$1, BetterAuthClientPlugin, ClientAtomListener as ClientAtomListener$1, ClientStore as ClientStore$1 } from "@better-auth/core";
8
7
  import { DBFieldAttribute, InferDBFieldsOutput } from "@better-auth/core/db";
8
+
9
9
  //#region src/client/types.d.ts
10
10
  type ClientPluginError<K extends string = string> = {
11
11
  readonly code: K;
@@ -28,7 +28,7 @@ type InferErrorCodes<O extends BetterAuthClientOptions$1> = O["plugins"] extends
28
28
  $InferServerPlugin?: infer ServerPlugin;
29
29
  } ? ServerPlugin extends {
30
30
  $ERROR_CODES?: infer E;
31
- } ? { [K in keyof E & string]: E[K] extends ClientPluginError ? ClientPluginError<K> : never; } : {} : {}> : {};
31
+ } ? { [K in keyof E & string]: E[K] extends ClientPluginError ? ClientPluginError<K> : never } : {} : {}> : {};
32
32
  /**
33
33
  * signals are just used to recall a computed value.
34
34
  * as a convention they start with "$"