@better-auth/core 1.4.0-beta.15 → 1.4.0-beta.17

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (77) hide show
  1. package/.turbo/turbo-build.log +36 -70
  2. package/dist/api/{index.d.cts → index.d.mts} +2 -2
  3. package/dist/api/{index.js → index.mjs} +2 -2
  4. package/dist/async_hooks/index.d.mts +2 -0
  5. package/dist/async_hooks/index.mjs +3 -0
  6. package/dist/context/{index.d.cts → index.d.mts} +18 -4
  7. package/dist/context/index.mjs +4 -0
  8. package/dist/{context-BAOGRjRS.js → context-PRICt3il.mjs} +38 -6
  9. package/dist/db/adapter/{index.d.cts → index.d.mts} +2 -2
  10. package/dist/db/{index.d.cts → index.d.mts} +2 -2
  11. package/dist/env/{index.d.cts → index.d.mts} +1 -1
  12. package/dist/env/{index.js → index.mjs} +1 -1
  13. package/dist/error/index.mjs +4 -0
  14. package/dist/{error-CxOXAZsS.js → error-D6EqgOXr.mjs} +1 -1
  15. package/dist/{index-Bab6W0hG.d.ts → index-CLtokfjz.d.mts} +64 -1
  16. package/dist/{index.d.cts → index.d.mts} +2 -2
  17. package/dist/oauth2/{index.d.cts → index.d.mts} +2 -2
  18. package/dist/oauth2/{index.js → index.mjs} +1 -1
  19. package/dist/social-providers/{index.d.cts → index.d.mts} +2 -2
  20. package/dist/social-providers/{index.js → index.mjs} +5 -5
  21. package/dist/utils/index.mjs +3 -0
  22. package/package.json +39 -105
  23. package/src/context/index.ts +9 -0
  24. package/src/context/request-state.test.ts +346 -0
  25. package/src/context/request-state.ts +70 -0
  26. package/src/social-providers/vk.ts +3 -3
  27. package/src/types/init-options.ts +59 -0
  28. package/src/types/plugin.ts +8 -0
  29. package/tsdown.config.ts +1 -1
  30. package/dist/api/index.cjs +0 -30
  31. package/dist/api/index.d.ts +0 -3
  32. package/dist/async_hooks/index.cjs +0 -3
  33. package/dist/async_hooks/index.d.cts +0 -2
  34. package/dist/async_hooks/index.d.ts +0 -2
  35. package/dist/async_hooks/index.js +0 -3
  36. package/dist/async_hooks-CaXONcb9.cjs +0 -24
  37. package/dist/chunk-CUT6urMc.cjs +0 -30
  38. package/dist/context/index.cjs +0 -10
  39. package/dist/context/index.d.ts +0 -30
  40. package/dist/context/index.js +0 -4
  41. package/dist/context-BRDf96na.cjs +0 -113
  42. package/dist/db/adapter/index.cjs +0 -0
  43. package/dist/db/adapter/index.d.ts +0 -3
  44. package/dist/db/index.cjs +0 -68
  45. package/dist/db/index.d.ts +0 -3
  46. package/dist/env/index.cjs +0 -16
  47. package/dist/env/index.d.ts +0 -2
  48. package/dist/env-CuEMo0ZI.cjs +0 -329
  49. package/dist/error/index.cjs +0 -5
  50. package/dist/error/index.d.ts +0 -35
  51. package/dist/error/index.js +0 -4
  52. package/dist/error-k9KM7GAb.cjs +0 -56
  53. package/dist/index-CGS5U4X6.d.cts +0 -7155
  54. package/dist/index-CSISZQGm.d.ts +0 -82
  55. package/dist/index-DT7CRnvv.d.ts +0 -7
  56. package/dist/index.cjs +0 -0
  57. package/dist/index.d.ts +0 -3
  58. package/dist/oauth2/index.cjs +0 -12
  59. package/dist/oauth2/index.d.ts +0 -3
  60. package/dist/oauth2-C4Pt8KMZ.cjs +0 -298
  61. package/dist/social-providers/index.cjs +0 -2555
  62. package/dist/social-providers/index.d.ts +0 -3
  63. package/dist/utils/index.cjs +0 -3
  64. package/dist/utils/index.d.ts +0 -9
  65. package/dist/utils/index.js +0 -3
  66. package/dist/utils-Bs-jKit4.cjs +0 -13
  67. /package/dist/{async_hooks-qYTIyHB7.js → async_hooks-BQqSywfV.mjs} +0 -0
  68. /package/dist/db/adapter/{index.js → index.mjs} +0 -0
  69. /package/dist/db/{index.js → index.mjs} +0 -0
  70. /package/dist/{env-DZG_k5Hh.js → env-YhoEXwYv.mjs} +0 -0
  71. /package/dist/error/{index.d.cts → index.d.mts} +0 -0
  72. /package/dist/{index-BzepAavo.d.cts → index-CRg-E-VF.d.mts} +0 -0
  73. /package/dist/{index-B_YiOlcX.d.cts → index-JSfspfWW.d.mts} +0 -0
  74. /package/dist/{index.js → index.mjs} +0 -0
  75. /package/dist/{oauth2-CP3eVHS_.js → oauth2-D4PPavcA.mjs} +0 -0
  76. /package/dist/utils/{index.d.cts → index.d.mts} +0 -0
  77. /package/dist/{utils-CK1IUN9R.js → utils-BFQCAfNW.mjs} +0 -0
@@ -1,76 +1,42 @@
1
1
 
2
- > @better-auth/core@1.4.0-beta.15 build /home/runner/work/better-auth/better-auth/packages/core
2
+ > @better-auth/core@1.4.0-beta.17 build /home/runner/work/better-auth/better-auth/packages/core
3
3
  > tsdown
4
4
 
5
- ℹ tsdown v0.15.11 powered by rolldown v1.0.0-beta.45
5
+ ℹ tsdown v0.16.0 powered by rolldown v1.0.0-beta.46
6
6
  ℹ Using tsdown config: /home/runner/work/better-auth/better-auth/packages/core/tsdown.config.ts
7
- ℹ entry: src/index.ts, src/api/index.ts, src/async_hooks/index.ts, src/context/index.ts, src/db/index.ts, src/env/index.ts, src/error/index.ts, src/oauth2/index.ts, src/social-providers/index.ts, src/utils/index.ts, src/db/adapter/index.ts
7
+ ℹ entry: src/index.ts, src/api/index.ts, src/db/index.ts, src/context/index.ts, src/async_hooks/index.ts, src/env/index.ts, src/error/index.ts, src/oauth2/index.ts, src/social-providers/index.ts, src/utils/index.ts, src/db/adapter/index.ts
8
8
  ℹ tsconfig: tsconfig.json
9
9
  ℹ Build start
10
- ℹ [CJS] dist/social-providers/index.cjs 81.60 kB │ gzip: 10.36 kB
11
- ℹ [CJS] dist/db/index.cjs  1.86 kB │ gzip: 0.56 kB
12
- ℹ [CJS] dist/api/index.cjs  1.07 kB │ gzip: 0.46 kB
13
- ℹ [CJS] dist/oauth2/index.cjs  0.80 kB │ gzip: 0.24 kB
14
- ℹ [CJS] dist/env/index.cjs  0.67 kB │ gzip: 0.24 kB
15
- ℹ [CJS] dist/context/index.cjs  0.64 kB │ gzip: 0.21 kB
16
- ℹ [CJS] dist/error/index.cjs  0.21 kB │ gzip: 0.14 kB
17
- ℹ [CJS] dist/async_hooks/index.cjs  0.14 kB │ gzip: 0.11 kB
18
- ℹ [CJS] dist/utils/index.cjs  0.12 kB │ gzip: 0.10 kB
19
- ℹ [CJS] dist/db/adapter/index.cjs  0.00 kB │ gzip: 0.02 kB
20
- ℹ [CJS] dist/index.cjs  0.00 kB │ gzip: 0.02 kB
21
- ℹ [CJS] dist/oauth2-C4Pt8KMZ.cjs 10.80 kB │ gzip: 2.29 kB
22
- ℹ [CJS] dist/env-CuEMo0ZI.cjs  9.08 kB │ gzip: 2.62 kB
23
- ℹ [CJS] dist/context-BRDf96na.cjs  3.34 kB │ gzip: 0.79 kB
24
- ℹ [CJS] dist/error-k9KM7GAb.cjs  1.98 kB │ gzip: 0.86 kB
25
- ℹ [CJS] dist/chunk-CUT6urMc.cjs  1.09 kB │ gzip: 0.54 kB
26
- ℹ [CJS] dist/async_hooks-CaXONcb9.cjs  0.97 kB │ gzip: 0.51 kB
27
- ℹ [CJS] dist/utils-Bs-jKit4.cjs  0.23 kB │ gzip: 0.17 kB
28
- ℹ [CJS] 18 files, total: 114.57 kB
29
- ℹ [ESM] dist/social-providers/index.js  77.59 kB │ gzip: 10.10 kB
30
- ℹ [ESM] dist/db/index.js  1.58 kB │ gzip: 0.49 kB
31
- ℹ [ESM] dist/api/index.js  0.83 kB │ gzip: 0.40 kB
32
- ℹ [ESM] dist/oauth2/index.js  0.60 kB │ gzip: 0.24 kB
33
- ℹ [ESM] dist/context/index.js  0.48 kB │ gzip: 0.21 kB
34
- ℹ [ESM] dist/env/index.js  0.44 kB │ gzip: 0.25 kB
35
- ℹ [ESM] dist/error/index.js  0.16 kB │ gzip: 0.13 kB
36
- ℹ [ESM] dist/async_hooks/index.js  0.10 kB │ gzip: 0.10 kB
37
- ℹ [ESM] dist/utils/index.js  0.09 kB │ gzip: 0.09 kB
38
- ℹ [ESM] dist/db/adapter/index.js  0.01 kB │ gzip: 0.03 kB
39
- ℹ [ESM] dist/index.js  0.01 kB │ gzip: 0.03 kB
40
- ℹ [ESM] dist/oauth2-CP3eVHS_.js  9.16 kB │ gzip: 2.12 kB
41
- ℹ [ESM] dist/env-DZG_k5Hh.js  7.67 kB │ gzip: 2.54 kB
42
- ℹ [ESM] dist/context-BAOGRjRS.js  2.50 kB │ gzip: 0.72 kB
43
- ℹ [ESM] dist/error-CxOXAZsS.js  1.77 kB │ gzip: 0.79 kB
44
- ℹ [ESM] dist/async_hooks-qYTIyHB7.js  0.87 kB │ gzip: 0.46 kB
45
- ℹ [ESM] dist/utils-CK1IUN9R.js  0.13 kB │ gzip: 0.12 kB
46
- ℹ [ESM] dist/social-providers/index.d.ts  3.77 kB │ gzip: 1.17 kB
47
- ℹ [ESM] dist/error/index.d.ts  1.84 kB │ gzip: 0.72 kB
48
- ℹ [ESM] dist/context/index.d.ts  1.77 kB │ gzip: 0.56 kB
49
- ℹ [ESM] dist/db/index.d.ts  1.01 kB │ gzip: 0.38 kB
50
- ℹ [ESM] dist/utils/index.d.ts  0.84 kB │ gzip: 0.43 kB
51
- ℹ [ESM] dist/index.d.ts  0.82 kB │ gzip: 0.32 kB
52
- ℹ [ESM] dist/oauth2/index.d.ts  0.79 kB │ gzip: 0.30 kB
53
- ℹ [ESM] dist/env/index.d.ts  0.59 kB │ gzip: 0.30 kB
54
- ℹ [ESM] dist/db/adapter/index.d.ts  0.46 kB │ gzip: 0.23 kB
55
- ℹ [ESM] dist/api/index.d.ts  0.29 kB │ gzip: 0.16 kB
56
- ℹ [ESM] dist/async_hooks/index.d.ts  0.14 kB │ gzip: 0.10 kB
57
- ℹ [ESM] dist/index-Bab6W0hG.d.ts 199.65 kB │ gzip: 31.07 kB
58
- ℹ [ESM] dist/index-CSISZQGm.d.ts  3.31 kB │ gzip: 1.11 kB
59
- ℹ [ESM] dist/index-DT7CRnvv.d.ts  0.24 kB │ gzip: 0.16 kB
60
- ℹ [ESM] 31 files, total: 319.55 kB
61
- ℹ [CJS] dist/social-providers/index.d.cts  3.78 kB │ gzip: 1.17 kB
62
- ℹ [CJS] dist/error/index.d.cts  1.84 kB │ gzip: 0.72 kB
63
- ℹ [CJS] dist/context/index.d.cts  1.77 kB │ gzip: 0.56 kB
64
- ℹ [CJS] dist/db/index.d.cts  1.01 kB │ gzip: 0.38 kB
65
- ℹ [CJS] dist/utils/index.d.cts  0.84 kB │ gzip: 0.43 kB
66
- ℹ [CJS] dist/index.d.cts  0.83 kB │ gzip: 0.32 kB
67
- ℹ [CJS] dist/oauth2/index.d.cts  0.79 kB │ gzip: 0.30 kB
68
- ℹ [CJS] dist/env/index.d.cts  0.59 kB │ gzip: 0.30 kB
69
- ℹ [CJS] dist/db/adapter/index.d.cts  0.47 kB │ gzip: 0.23 kB
70
- ℹ [CJS] dist/api/index.d.cts  0.29 kB │ gzip: 0.16 kB
71
- ℹ [CJS] dist/async_hooks/index.d.cts  0.14 kB │ gzip: 0.10 kB
72
- ℹ [CJS] dist/index-CGS5U4X6.d.cts 199.65 kB │ gzip: 31.07 kB
73
- ℹ [CJS] dist/index-B_YiOlcX.d.cts  3.31 kB │ gzip: 1.11 kB
74
- ℹ [CJS] dist/index-BzepAavo.d.cts  0.24 kB │ gzip: 0.16 kB
75
- ℹ [CJS] 14 files, total: 215.56 kB
76
- ✔ Build complete in 5228ms
10
+ ℹ dist/social-providers/index.mjs  77.62 kB │ gzip: 10.12 kB
11
+ ℹ dist/db/index.mjs  1.58 kB │ gzip: 0.49 kB
12
+ ℹ dist/api/index.mjs  0.83 kB │ gzip: 0.40 kB
13
+ ℹ dist/context/index.mjs  0.74 kB │ gzip: 0.27 kB
14
+ ℹ dist/oauth2/index.mjs  0.61 kB │ gzip: 0.24 kB
15
+ ℹ dist/env/index.mjs  0.44 kB │ gzip: 0.25 kB
16
+ ℹ dist/error/index.mjs  0.16 kB │ gzip: 0.13 kB
17
+ ℹ dist/async_hooks/index.mjs  0.11 kB │ gzip: 0.10 kB
18
+ ℹ dist/utils/index.mjs  0.09 kB │ gzip: 0.09 kB
19
+ ℹ dist/db/adapter/index.mjs  0.01 kB │ gzip: 0.03 kB
20
+ ℹ dist/index.mjs  0.01 kB │ gzip: 0.03 kB
21
+ ℹ dist/oauth2-D4PPavcA.mjs  9.16 kB │ gzip: 2.12 kB
22
+ ℹ dist/env-YhoEXwYv.mjs  7.67 kB │ gzip: 2.54 kB
23
+ ℹ dist/context-PRICt3il.mjs  3.68 kB │ gzip: 0.93 kB
24
+ ℹ dist/error-D6EqgOXr.mjs  1.77 kB │ gzip: 0.79 kB
25
+ ℹ dist/async_hooks-BQqSywfV.mjs  0.87 kB │ gzip: 0.46 kB
26
+ ℹ dist/utils-BFQCAfNW.mjs  0.13 kB │ gzip: 0.12 kB
27
+ ℹ dist/social-providers/index.d.mts  3.78 kB │ gzip: 1.16 kB
28
+ ℹ dist/context/index.d.mts  2.77 kB │ gzip: 0.79 kB
29
+ ℹ dist/error/index.d.mts  1.84 kB │ gzip: 0.72 kB
30
+ ℹ dist/db/index.d.mts  1.01 kB │ gzip: 0.38 kB
31
+ ℹ dist/utils/index.d.mts  0.84 kB │ gzip: 0.43 kB
32
+ ℹ dist/index.d.mts  0.83 kB │ gzip: 0.32 kB
33
+ ℹ dist/oauth2/index.d.mts  0.79 kB │ gzip: 0.29 kB
34
+ ℹ dist/env/index.d.mts  0.59 kB │ gzip: 0.30 kB
35
+ ℹ dist/db/adapter/index.d.mts  0.47 kB │ gzip: 0.22 kB
36
+ ℹ dist/api/index.d.mts  0.29 kB │ gzip: 0.16 kB
37
+ ℹ dist/async_hooks/index.d.mts  0.14 kB │ gzip: 0.10 kB
38
+ ℹ dist/index-CLtokfjz.d.mts 201.27 kB │ gzip: 31.50 kB
39
+ ℹ dist/index-JSfspfWW.d.mts  3.31 kB │ gzip: 1.11 kB
40
+ ℹ dist/index-CRg-E-VF.d.mts  0.24 kB │ gzip: 0.16 kB
41
+ ℹ 31 files, total: 323.65 kB
42
+ ✔ Build complete in 4600ms
@@ -1,3 +1,3 @@
1
- import { a as optionsMiddleware, i as createAuthMiddleware, n as AuthMiddleware, r as createAuthEndpoint, t as AuthEndpoint } from "../index-CGS5U4X6.cjs";
2
- import "../index-B_YiOlcX.cjs";
1
+ import { a as optionsMiddleware, i as createAuthMiddleware, n as AuthMiddleware, r as createAuthEndpoint, t as AuthEndpoint } from "../index-CLtokfjz.mjs";
2
+ import "../index-JSfspfWW.mjs";
3
3
  export { AuthEndpoint, AuthMiddleware, createAuthEndpoint, createAuthMiddleware, optionsMiddleware };
@@ -1,5 +1,5 @@
1
- import "../async_hooks-qYTIyHB7.js";
2
- import { s as runWithEndpointContext } from "../context-BAOGRjRS.js";
1
+ import "../async_hooks-BQqSywfV.mjs";
2
+ import { f as runWithEndpointContext } from "../context-PRICt3il.mjs";
3
3
  import { createEndpoint, createMiddleware } from "better-call";
4
4
 
5
5
  //#region src/api/index.ts
@@ -0,0 +1,2 @@
1
+ import { n as getAsyncLocalStorage, t as AsyncLocalStorage } from "../index-CRg-E-VF.mjs";
2
+ export { AsyncLocalStorage, getAsyncLocalStorage };
@@ -0,0 +1,3 @@
1
+ import { t as getAsyncLocalStorage } from "../async_hooks-BQqSywfV.mjs";
2
+
3
+ export { getAsyncLocalStorage };
@@ -1,7 +1,8 @@
1
- import { Jn as DBTransactionAdapter, Un as DBAdapter, d as AuthContext } from "../index-CGS5U4X6.cjs";
2
- import "../index-B_YiOlcX.cjs";
3
- import { t as AsyncLocalStorage } from "../index-BzepAavo.cjs";
1
+ import { Jn as DBTransactionAdapter, Un as DBAdapter, d as AuthContext } from "../index-CLtokfjz.mjs";
2
+ import "../index-JSfspfWW.mjs";
3
+ import { t as AsyncLocalStorage } from "../index-CRg-E-VF.mjs";
4
4
  import { EndpointContext, InputContext } from "better-call";
5
+ import { StandardSchemaV1 } from "@standard-schema/spec";
5
6
 
6
7
  //#region src/context/endpoint-context.d.ts
7
8
  type AuthEndpointContext = Partial<InputContext<string, any> & EndpointContext<string, any>> & {
@@ -16,6 +17,19 @@ declare function getCurrentAuthContextAsyncLocalStorage(): Promise<AsyncLocalSto
16
17
  declare function getCurrentAuthContext(): Promise<AuthEndpointContext>;
17
18
  declare function runWithEndpointContext<T>(context: AuthEndpointContext, fn: () => T): Promise<T>;
18
19
  //#endregion
20
+ //#region src/context/request-state.d.ts
21
+ type RequestStateWeakMap = WeakMap<StandardSchemaV1, any>;
22
+ declare function getRequestStateAsyncLocalStorage(): Promise<AsyncLocalStorage<RequestStateWeakMap>>;
23
+ declare function hasRequestState(): Promise<boolean>;
24
+ declare function getCurrentRequestState(): Promise<RequestStateWeakMap>;
25
+ declare function runWithRequestState<T>(store: RequestStateWeakMap, fn: () => T): Promise<T>;
26
+ interface RequestState<T> {
27
+ get<S>(): Promise<S extends Record<string, any> ? S : T>;
28
+ set(value: T): Promise<void>;
29
+ }
30
+ declare function defineRequestState<T>(schema: StandardSchemaV1<T>): RequestState<T>;
31
+ declare function defineRequestState<Schema extends StandardSchemaV1>(schema: Schema): RequestState<StandardSchemaV1.InferInput<Schema>>;
32
+ //#endregion
19
33
  //#region src/context/transaction.d.ts
20
34
  /**
21
35
  * This is for internal use only. Most users should use `getCurrentAdapter` instead.
@@ -27,4 +41,4 @@ declare const getCurrentAdapter: (fallback: DBTransactionAdapter) => Promise<DBT
27
41
  declare const runWithAdapter: <R>(adapter: DBAdapter, fn: () => R) => Promise<R>;
28
42
  declare const runWithTransaction: <R>(adapter: DBAdapter, fn: () => R) => Promise<R>;
29
43
  //#endregion
30
- export { type AuthEndpointContext, getCurrentAdapter, getCurrentAuthContext, getCurrentAuthContextAsyncLocalStorage, getCurrentDBAdapterAsyncLocalStorage, runWithAdapter, runWithEndpointContext, runWithTransaction };
44
+ export { type AuthEndpointContext, type RequestState, type RequestStateWeakMap, defineRequestState, getCurrentAdapter, getCurrentAuthContext, getCurrentAuthContextAsyncLocalStorage, getCurrentDBAdapterAsyncLocalStorage, getCurrentRequestState, getRequestStateAsyncLocalStorage, hasRequestState, runWithAdapter, runWithEndpointContext, runWithRequestState, runWithTransaction };
@@ -0,0 +1,4 @@
1
+ import "../async_hooks-BQqSywfV.mjs";
2
+ import { a as defineRequestState, c as hasRequestState, d as getCurrentAuthContextAsyncLocalStorage, f as runWithEndpointContext, i as runWithTransaction, l as runWithRequestState, n as getCurrentDBAdapterAsyncLocalStorage, o as getCurrentRequestState, r as runWithAdapter, s as getRequestStateAsyncLocalStorage, t as getCurrentAdapter, u as getCurrentAuthContext } from "../context-PRICt3il.mjs";
3
+
4
+ export { defineRequestState, getCurrentAdapter, getCurrentAuthContext, getCurrentAuthContextAsyncLocalStorage, getCurrentDBAdapterAsyncLocalStorage, getCurrentRequestState, getRequestStateAsyncLocalStorage, hasRequestState, runWithAdapter, runWithEndpointContext, runWithRequestState, runWithTransaction };
@@ -1,8 +1,8 @@
1
- import { t as getAsyncLocalStorage } from "./async_hooks-qYTIyHB7.js";
1
+ import { t as getAsyncLocalStorage } from "./async_hooks-BQqSywfV.mjs";
2
2
 
3
3
  //#region src/context/endpoint-context.ts
4
4
  let currentContextAsyncStorage = null;
5
- const ensureAsyncStorage$1 = async () => {
5
+ const ensureAsyncStorage$2 = async () => {
6
6
  if (!currentContextAsyncStorage) currentContextAsyncStorage = new (await (getAsyncLocalStorage()))();
7
7
  return currentContextAsyncStorage;
8
8
  };
@@ -12,15 +12,47 @@ const ensureAsyncStorage$1 = async () => {
12
12
  * It is exposed for advanced use cases where you need direct access to the AsyncLocalStorage instance.
13
13
  */
14
14
  async function getCurrentAuthContextAsyncLocalStorage() {
15
- return ensureAsyncStorage$1();
15
+ return ensureAsyncStorage$2();
16
16
  }
17
17
  async function getCurrentAuthContext() {
18
- const context = (await ensureAsyncStorage$1()).getStore();
18
+ const context = (await ensureAsyncStorage$2()).getStore();
19
19
  if (!context) throw new Error("No auth context found. Please make sure you are calling this function within a `runWithEndpointContext` callback.");
20
20
  return context;
21
21
  }
22
22
  async function runWithEndpointContext(context, fn) {
23
- return (await ensureAsyncStorage$1()).run(context, fn);
23
+ return (await ensureAsyncStorage$2()).run(context, fn);
24
+ }
25
+
26
+ //#endregion
27
+ //#region src/context/request-state.ts
28
+ let requestStateAsyncStorage = null;
29
+ const ensureAsyncStorage$1 = async () => {
30
+ if (!requestStateAsyncStorage) requestStateAsyncStorage = new (await (getAsyncLocalStorage()))();
31
+ return requestStateAsyncStorage;
32
+ };
33
+ async function getRequestStateAsyncLocalStorage() {
34
+ return ensureAsyncStorage$1();
35
+ }
36
+ async function hasRequestState() {
37
+ return (await ensureAsyncStorage$1()).getStore() !== void 0;
38
+ }
39
+ async function getCurrentRequestState() {
40
+ const store = (await ensureAsyncStorage$1()).getStore();
41
+ if (!store) throw new Error("No request state found. Please make sure you are calling this function within a `runWithRequestState` callback.");
42
+ return store;
43
+ }
44
+ async function runWithRequestState(store, fn) {
45
+ return (await ensureAsyncStorage$1()).run(store, fn);
46
+ }
47
+ function defineRequestState(schema) {
48
+ return {
49
+ async get() {
50
+ return (await getCurrentRequestState()).get(schema);
51
+ },
52
+ async set(value) {
53
+ (await getCurrentRequestState()).set(schema, value);
54
+ }
55
+ };
24
56
  }
25
57
 
26
58
  //#endregion
@@ -69,4 +101,4 @@ const runWithTransaction = async (adapter, fn) => {
69
101
  };
70
102
 
71
103
  //#endregion
72
- export { getCurrentAuthContext as a, runWithTransaction as i, getCurrentDBAdapterAsyncLocalStorage as n, getCurrentAuthContextAsyncLocalStorage as o, runWithAdapter as r, runWithEndpointContext as s, getCurrentAdapter as t };
104
+ export { defineRequestState as a, hasRequestState as c, getCurrentAuthContextAsyncLocalStorage as d, runWithEndpointContext as f, runWithTransaction as i, runWithRequestState as l, getCurrentDBAdapterAsyncLocalStorage as n, getCurrentRequestState as o, runWithAdapter as r, getRequestStateAsyncLocalStorage as s, getCurrentAdapter as t, getCurrentAuthContext as u };
@@ -1,3 +1,3 @@
1
- import { Gn as DBAdapterFactoryConfig, Hn as CustomAdapter, Jn as DBTransactionAdapter, Kn as DBAdapterInstance, Un as DBAdapter, Vn as CleanedWhere, Wn as DBAdapterDebugLogOption, Yn as Where, qn as DBAdapterSchemaCreation } from "../../index-CGS5U4X6.cjs";
2
- import "../../index-B_YiOlcX.cjs";
1
+ import { Gn as DBAdapterFactoryConfig, Hn as CustomAdapter, Jn as DBTransactionAdapter, Kn as DBAdapterInstance, Un as DBAdapter, Vn as CleanedWhere, Wn as DBAdapterDebugLogOption, Yn as Where, qn as DBAdapterSchemaCreation } from "../../index-CLtokfjz.mjs";
2
+ import "../../index-JSfspfWW.mjs";
3
3
  export { CleanedWhere, CustomAdapter, DBAdapter, DBAdapterDebugLogOption, DBAdapterFactoryConfig, DBAdapterInstance, DBAdapterSchemaCreation, DBTransactionAdapter, Where };
@@ -1,3 +1,3 @@
1
- import { $n as FieldAttributeConfig, Qn as FieldAttribute, Xn as AuthPluginSchema, Zn as BetterAuthDbSchema, _r as DBFieldType, ar as userSchema, br as SecondaryStorage, cr as sessionSchema, dr as Account, er as FieldType, fr as accountSchema, gr as DBFieldAttributeConfig, hr as DBFieldAttribute, ir as User, lr as RateLimit, mr as BetterAuthDBSchema, nr as Verification, or as coreSchema, pr as BetterAuthPluginDBSchema, rr as verificationSchema, sr as Session, tr as Primitive, ur as rateLimitSchema, vr as DBPreservedModels, yr as DBPrimitive } from "../index-CGS5U4X6.cjs";
2
- import "../index-B_YiOlcX.cjs";
1
+ import { $n as FieldAttributeConfig, Qn as FieldAttribute, Xn as AuthPluginSchema, Zn as BetterAuthDbSchema, _r as DBFieldType, ar as userSchema, br as SecondaryStorage, cr as sessionSchema, dr as Account, er as FieldType, fr as accountSchema, gr as DBFieldAttributeConfig, hr as DBFieldAttribute, ir as User, lr as RateLimit, mr as BetterAuthDBSchema, nr as Verification, or as coreSchema, pr as BetterAuthPluginDBSchema, rr as verificationSchema, sr as Session, tr as Primitive, ur as rateLimitSchema, vr as DBPreservedModels, yr as DBPrimitive } from "../index-CLtokfjz.mjs";
2
+ import "../index-JSfspfWW.mjs";
3
3
  export { Account, AuthPluginSchema, BetterAuthDBSchema, BetterAuthDbSchema, BetterAuthPluginDBSchema, DBFieldAttribute, DBFieldAttributeConfig, DBFieldType, DBPreservedModels, DBPrimitive, FieldAttribute, FieldAttributeConfig, FieldType, Primitive, RateLimit, SecondaryStorage, Session, User, Verification, accountSchema, coreSchema, rateLimitSchema, sessionSchema, userSchema, verificationSchema };
@@ -1,2 +1,2 @@
1
- import { _ as isTest, a as TTY_COLORS, c as logger, d as EnvObject, f as env, g as isProduction, h as isDevelopment, i as Logger, l as shouldPublishLog, m as getEnvVar, n as LogHandlerParams, o as createLogger, p as getBooleanEnvVar, r as LogLevel, s as levels, t as InternalLogger, u as ENV, v as nodeENV, y as getColorDepth } from "../index-B_YiOlcX.cjs";
1
+ import { _ as isTest, a as TTY_COLORS, c as logger, d as EnvObject, f as env, g as isProduction, h as isDevelopment, i as Logger, l as shouldPublishLog, m as getEnvVar, n as LogHandlerParams, o as createLogger, p as getBooleanEnvVar, r as LogLevel, s as levels, t as InternalLogger, u as ENV, v as nodeENV, y as getColorDepth } from "../index-JSfspfWW.mjs";
2
2
  export { ENV, EnvObject, InternalLogger, LogHandlerParams, LogLevel, Logger, TTY_COLORS, createLogger, env, getBooleanEnvVar, getColorDepth, getEnvVar, isDevelopment, isProduction, isTest, levels, logger, nodeENV, shouldPublishLog };
@@ -1,3 +1,3 @@
1
- import { a as shouldPublishLog, c as env, d as isDevelopment, f as isProduction, i as logger, l as getBooleanEnvVar, m as nodeENV, n as createLogger, o as getColorDepth, p as isTest, r as levels, s as ENV, t as TTY_COLORS, u as getEnvVar } from "../env-DZG_k5Hh.js";
1
+ import { a as shouldPublishLog, c as env, d as isDevelopment, f as isProduction, i as logger, l as getBooleanEnvVar, m as nodeENV, n as createLogger, o as getColorDepth, p as isTest, r as levels, s as ENV, t as TTY_COLORS, u as getEnvVar } from "../env-YhoEXwYv.mjs";
2
2
 
3
3
  export { ENV, TTY_COLORS, createLogger, env, getBooleanEnvVar, getColorDepth, getEnvVar, isDevelopment, isProduction, isTest, levels, logger, nodeENV, shouldPublishLog };
@@ -0,0 +1,4 @@
1
+ import "../utils-BFQCAfNW.mjs";
2
+ import { n as BASE_ERROR_CODES, t as BetterAuthError } from "../error-D6EqgOXr.mjs";
3
+
4
+ export { BASE_ERROR_CODES, BetterAuthError };
@@ -1,4 +1,4 @@
1
- import { t as defineErrorCodes } from "./utils-CK1IUN9R.js";
1
+ import { t as defineErrorCodes } from "./utils-BFQCAfNW.mjs";
2
2
 
3
3
  //#region src/error/codes.ts
4
4
  const BASE_ERROR_CODES = defineErrorCodes({
@@ -1,4 +1,4 @@
1
- import { i as Logger, o as createLogger } from "./index-CSISZQGm.js";
1
+ import { i as Logger, o as createLogger } from "./index-JSfspfWW.mjs";
2
2
  import * as better_call0 from "better-call";
3
3
  import { CookieOptions, Endpoint, EndpointContext, EndpointOptions, InputContext, Middleware } from "better-call";
4
4
  import * as z from "zod";
@@ -5798,6 +5798,14 @@ type BetterAuthPlugin = {
5798
5798
  * The error codes returned by the plugin
5799
5799
  */
5800
5800
  $ERROR_CODES?: Record<string, string> | undefined;
5801
+ /**
5802
+ * All database operations that are performed by the plugin
5803
+ *
5804
+ * This will override the default database operations
5805
+ */
5806
+ adapter?: {
5807
+ [key: string]: (...args: any[]) => Promise<any> | any;
5808
+ };
5801
5809
  };
5802
5810
  //#endregion
5803
5811
  //#region src/types/init-options.d.ts
@@ -6010,6 +6018,25 @@ type BetterAuthAdvancedOptions = {
6010
6018
  * @default "cookie"
6011
6019
  */
6012
6020
  storeStateStrategy?: "database" | "cookie";
6021
+ /**
6022
+ * Additional data to pass through the oauth flow.
6023
+ *
6024
+ * @default undefined
6025
+ */
6026
+ additionalData?: {
6027
+ /**
6028
+ * Whether to enable additional data.
6029
+ *
6030
+ * @default false
6031
+ */
6032
+ enabled?: boolean;
6033
+ /**
6034
+ * Validation schema for the additional data.
6035
+ *
6036
+ * @default undefined
6037
+ */
6038
+ schema?: StandardSchemaV1;
6039
+ } | undefined;
6013
6040
  } | undefined;
6014
6041
  };
6015
6042
  type BetterAuthOptions = {
@@ -6840,6 +6867,42 @@ type BetterAuthOptions = {
6840
6867
  * @default - "/api/auth/error"
6841
6868
  */
6842
6869
  errorURL?: string;
6870
+ /**
6871
+ * Configure the default error page provided by Better-Auth
6872
+ * Start your dev server and go to /api/auth/error to see the error page.
6873
+ */
6874
+ customizeDefaultErrorPage?: {
6875
+ colors?: {
6876
+ background?: string;
6877
+ foreground?: string;
6878
+ primary?: string;
6879
+ primaryForeground?: string;
6880
+ mutedForeground?: string;
6881
+ border?: string;
6882
+ destructive?: string;
6883
+ titleBorder?: string;
6884
+ titleColor?: string;
6885
+ gridColor?: string;
6886
+ cardBackground?: string;
6887
+ cornerBorder?: string;
6888
+ };
6889
+ size?: {
6890
+ radiusSm?: string;
6891
+ radiusMd?: string;
6892
+ radiusLg?: string;
6893
+ textSm?: string;
6894
+ text2xl?: string;
6895
+ text4xl?: string;
6896
+ text6xl?: string;
6897
+ };
6898
+ font?: {
6899
+ defaultFamily?: string;
6900
+ monoFamily?: string;
6901
+ };
6902
+ disableTitleBorder?: boolean;
6903
+ disableCornerDecorations?: boolean;
6904
+ disableBackgroundGrid?: boolean;
6905
+ };
6843
6906
  } | undefined;
6844
6907
  /**
6845
6908
  * Hooks
@@ -1,3 +1,3 @@
1
- import { En as BetterAuthCookies, Tn as LiteralUnion, _ as GenerateIdFn, c as BetterAuthClientPlugin, d as AuthContext, f as GenericEndpointContext, g as BetterAuthRateLimitOptions, h as BetterAuthOptions, l as ClientAtomListener, m as BetterAuthAdvancedOptions, o as StandardSchemaV1, p as InternalAdapter, s as BetterAuthClientOptions, u as ClientStore, v as BetterAuthPlugin, wn as LiteralString, y as HookEndpointContext } from "./index-CGS5U4X6.cjs";
2
- import "./index-B_YiOlcX.cjs";
1
+ import { En as BetterAuthCookies, Tn as LiteralUnion, _ as GenerateIdFn, c as BetterAuthClientPlugin, d as AuthContext, f as GenericEndpointContext, g as BetterAuthRateLimitOptions, h as BetterAuthOptions, l as ClientAtomListener, m as BetterAuthAdvancedOptions, o as StandardSchemaV1, p as InternalAdapter, s as BetterAuthClientOptions, u as ClientStore, v as BetterAuthPlugin, wn as LiteralString, y as HookEndpointContext } from "./index-CLtokfjz.mjs";
2
+ import "./index-JSfspfWW.mjs";
3
3
  export { AuthContext, BetterAuthAdvancedOptions, BetterAuthClientOptions, BetterAuthClientPlugin, BetterAuthCookies, BetterAuthOptions, BetterAuthPlugin, BetterAuthRateLimitOptions, ClientAtomListener, ClientStore, GenerateIdFn, GenericEndpointContext, HookEndpointContext, InternalAdapter, LiteralString, LiteralUnion, StandardSchemaV1 };
@@ -1,3 +1,3 @@
1
- import { An as generateCodeChallenge, Bn as ProviderOptions, Dn as createAuthorizationCodeRequest, Fn as clientCredentialsToken, In as createClientCredentialsTokenRequest, Ln as OAuth2Tokens, Mn as createRefreshAccessTokenRequest, Nn as refreshAccessToken, On as validateAuthorizationCode, Pn as createAuthorizationURL, Rn as OAuth2UserInfo, jn as getOAuth2Tokens, kn as validateToken, zn as OAuthProvider } from "../index-CGS5U4X6.cjs";
2
- import "../index-B_YiOlcX.cjs";
1
+ import { An as generateCodeChallenge, Bn as ProviderOptions, Dn as createAuthorizationCodeRequest, Fn as clientCredentialsToken, In as createClientCredentialsTokenRequest, Ln as OAuth2Tokens, Mn as createRefreshAccessTokenRequest, Nn as refreshAccessToken, On as validateAuthorizationCode, Pn as createAuthorizationURL, Rn as OAuth2UserInfo, jn as getOAuth2Tokens, kn as validateToken, zn as OAuthProvider } from "../index-CLtokfjz.mjs";
2
+ import "../index-JSfspfWW.mjs";
3
3
  export { OAuth2Tokens, OAuth2UserInfo, OAuthProvider, ProviderOptions, clientCredentialsToken, createAuthorizationCodeRequest, createAuthorizationURL, createClientCredentialsTokenRequest, createRefreshAccessTokenRequest, generateCodeChallenge, getOAuth2Tokens, refreshAccessToken, validateAuthorizationCode, validateToken };
@@ -1,3 +1,3 @@
1
- import { a as refreshAccessToken, c as getOAuth2Tokens, i as createRefreshAccessTokenRequest, l as clientCredentialsToken, n as validateAuthorizationCode, o as createAuthorizationURL, r as validateToken, s as generateCodeChallenge, t as createAuthorizationCodeRequest, u as createClientCredentialsTokenRequest } from "../oauth2-CP3eVHS_.js";
1
+ import { a as refreshAccessToken, c as getOAuth2Tokens, i as createRefreshAccessTokenRequest, l as clientCredentialsToken, n as validateAuthorizationCode, o as createAuthorizationURL, r as validateToken, s as generateCodeChallenge, t as createAuthorizationCodeRequest, u as createClientCredentialsTokenRequest } from "../oauth2-D4PPavcA.mjs";
2
2
 
3
3
  export { clientCredentialsToken, createAuthorizationCodeRequest, createAuthorizationURL, createClientCredentialsTokenRequest, createRefreshAccessTokenRequest, generateCodeChallenge, getOAuth2Tokens, refreshAccessToken, validateAuthorizationCode, validateToken };
@@ -1,3 +1,3 @@
1
- import { $ as ZoomOptions, $t as microsoft, A as PayPalProfile, At as DropboxOptions, B as NaverOptions, Bt as SpotifyProfile, C as SocialProviders, Cn as getApplePublicKey, Ct as LinearOptions, D as PolarProfile, Dt as KickOptions, E as PolarOptions, Et as linear, F as paybin, Ft as twitter, G as kakao, Gt as HuggingFaceOptions, H as naver, Ht as SlackOptions, I as LineIdTokenPayload, It as TwitchOptions, J as notion, Jt as GoogleOptions, K as NotionOptions, Kt as HuggingFaceProfile, L as LineOptions, Lt as TwitchProfile, M as paypal, Mt as dropbox, N as PaybinOptions, Nt as TwitterOption, O as polar, Ot as KickProfile, P as PaybinProfile, Pt as TwitterProfile, Q as PronounOption, Qt as MicrosoftOptions, R as LineUserInfo, Rt as twitch, S as SocialProviderListEnum, Sn as apple, St as linkedin, T as socialProviders, Tt as LinearUser, U as KakaoOptions, Ut as SlackProfile, V as NaverProfile, Vt as spotify, W as KakaoProfile, Wt as slack, X as LoginType, Xt as google, Y as AccountStatus, Yt as GoogleProfile, Z as PhoneNumber, Zt as MicrosoftEntraIDProfile, _n as AtlassianProfile, _t as GitlabOptions, an as figma, at as SalesforceOptions, b as SocialProvider, bn as AppleOptions, bt as LinkedInOptions, cn as facebook, ct as RobloxOptions, dn as discord, dt as RedditOptions, en as GithubOptions, et as ZoomProfile, fn as CognitoOptions, ft as RedditProfile, gn as AtlassianOptions, gt as tiktok, hn as getCognitoPublicKey, ht as TiktokProfile, in as FigmaProfile, it as vk, j as PayPalTokenResponse, jt as DropboxProfile, k as PayPalOptions, kt as kick, ln as DiscordOptions, lt as RobloxProfile, mn as cognito, mt as TiktokOptions, nn as github, nt as VkOption, on as FacebookOptions, ot as SalesforceProfile, pn as CognitoProfile, pt as reddit, q as NotionProfile, qt as huggingface, rn as FigmaOptions, rt as VkProfile, sn as FacebookProfile, st as salesforce, tn as GithubProfile, tt as zoom, un as DiscordProfile, ut as roblox, vn as atlassian, vt as GitlabProfile, w as socialProviderList, wt as LinearProfile, x as SocialProviderList, xn as AppleProfile, xt as LinkedInProfile, yn as AppleNonConformUser, yt as gitlab, z as line, zt as SpotifyOptions } from "../index-CGS5U4X6.cjs";
2
- import "../index-B_YiOlcX.cjs";
1
+ import { $ as ZoomOptions, $t as microsoft, A as PayPalProfile, At as DropboxOptions, B as NaverOptions, Bt as SpotifyProfile, C as SocialProviders, Cn as getApplePublicKey, Ct as LinearOptions, D as PolarProfile, Dt as KickOptions, E as PolarOptions, Et as linear, F as paybin, Ft as twitter, G as kakao, Gt as HuggingFaceOptions, H as naver, Ht as SlackOptions, I as LineIdTokenPayload, It as TwitchOptions, J as notion, Jt as GoogleOptions, K as NotionOptions, Kt as HuggingFaceProfile, L as LineOptions, Lt as TwitchProfile, M as paypal, Mt as dropbox, N as PaybinOptions, Nt as TwitterOption, O as polar, Ot as KickProfile, P as PaybinProfile, Pt as TwitterProfile, Q as PronounOption, Qt as MicrosoftOptions, R as LineUserInfo, Rt as twitch, S as SocialProviderListEnum, Sn as apple, St as linkedin, T as socialProviders, Tt as LinearUser, U as KakaoOptions, Ut as SlackProfile, V as NaverProfile, Vt as spotify, W as KakaoProfile, Wt as slack, X as LoginType, Xt as google, Y as AccountStatus, Yt as GoogleProfile, Z as PhoneNumber, Zt as MicrosoftEntraIDProfile, _n as AtlassianProfile, _t as GitlabOptions, an as figma, at as SalesforceOptions, b as SocialProvider, bn as AppleOptions, bt as LinkedInOptions, cn as facebook, ct as RobloxOptions, dn as discord, dt as RedditOptions, en as GithubOptions, et as ZoomProfile, fn as CognitoOptions, ft as RedditProfile, gn as AtlassianOptions, gt as tiktok, hn as getCognitoPublicKey, ht as TiktokProfile, in as FigmaProfile, it as vk, j as PayPalTokenResponse, jt as DropboxProfile, k as PayPalOptions, kt as kick, ln as DiscordOptions, lt as RobloxProfile, mn as cognito, mt as TiktokOptions, nn as github, nt as VkOption, on as FacebookOptions, ot as SalesforceProfile, pn as CognitoProfile, pt as reddit, q as NotionProfile, qt as huggingface, rn as FigmaOptions, rt as VkProfile, sn as FacebookProfile, st as salesforce, tn as GithubProfile, tt as zoom, un as DiscordProfile, ut as roblox, vn as atlassian, vt as GitlabProfile, w as socialProviderList, wt as LinearProfile, x as SocialProviderList, xn as AppleProfile, xt as LinkedInProfile, yn as AppleNonConformUser, yt as gitlab, z as line, zt as SpotifyOptions } from "../index-CLtokfjz.mjs";
2
+ import "../index-JSfspfWW.mjs";
3
3
  export { AccountStatus, AppleNonConformUser, AppleOptions, AppleProfile, AtlassianOptions, AtlassianProfile, CognitoOptions, CognitoProfile, DiscordOptions, DiscordProfile, DropboxOptions, DropboxProfile, FacebookOptions, FacebookProfile, FigmaOptions, FigmaProfile, GithubOptions, GithubProfile, GitlabOptions, GitlabProfile, GoogleOptions, GoogleProfile, HuggingFaceOptions, HuggingFaceProfile, KakaoOptions, KakaoProfile, KickOptions, KickProfile, LineIdTokenPayload, LineOptions, LineUserInfo, LinearOptions, LinearProfile, LinearUser, LinkedInOptions, LinkedInProfile, LoginType, MicrosoftEntraIDProfile, MicrosoftOptions, NaverOptions, NaverProfile, NotionOptions, NotionProfile, PayPalOptions, PayPalProfile, PayPalTokenResponse, PaybinOptions, PaybinProfile, PhoneNumber, PolarOptions, PolarProfile, PronounOption, RedditOptions, RedditProfile, RobloxOptions, RobloxProfile, SalesforceOptions, SalesforceProfile, SlackOptions, SlackProfile, SocialProvider, SocialProviderList, SocialProviderListEnum, SocialProviders, SpotifyOptions, SpotifyProfile, TiktokOptions, TiktokProfile, TwitchOptions, TwitchProfile, TwitterOption, TwitterProfile, VkOption, VkProfile, ZoomOptions, ZoomProfile, apple, atlassian, cognito, discord, dropbox, facebook, figma, getApplePublicKey, getCognitoPublicKey, github, gitlab, google, huggingface, kakao, kick, line, linear, linkedin, microsoft, naver, notion, paybin, paypal, polar, reddit, roblox, salesforce, slack, socialProviderList, socialProviders, spotify, tiktok, twitch, twitter, vk, zoom };
@@ -1,7 +1,7 @@
1
- import { i as logger } from "../env-DZG_k5Hh.js";
2
- import "../utils-CK1IUN9R.js";
3
- import { t as BetterAuthError } from "../error-CxOXAZsS.js";
4
- import { a as refreshAccessToken, c as getOAuth2Tokens, n as validateAuthorizationCode, o as createAuthorizationURL, s as generateCodeChallenge } from "../oauth2-CP3eVHS_.js";
1
+ import { i as logger } from "../env-YhoEXwYv.mjs";
2
+ import "../utils-BFQCAfNW.mjs";
3
+ import { t as BetterAuthError } from "../error-D6EqgOXr.mjs";
4
+ import { a as refreshAccessToken, c as getOAuth2Tokens, n as validateAuthorizationCode, o as createAuthorizationURL, s as generateCodeChallenge } from "../oauth2-D4PPavcA.mjs";
5
5
  import { APIError } from "better-call";
6
6
  import * as z from "zod";
7
7
  import { base64 } from "@better-auth/utils/base64";
@@ -2392,8 +2392,8 @@ const vk = (options) => {
2392
2392
  body: formBody
2393
2393
  });
2394
2394
  if (error) return null;
2395
- if (!profile.user.email) return null;
2396
2395
  const userMap = await options.mapProfileToUser?.(profile);
2396
+ if (!profile.user.email && !userMap?.email) return null;
2397
2397
  return {
2398
2398
  user: {
2399
2399
  id: profile.user.user_id,
@@ -0,0 +1,3 @@
1
+ import { t as defineErrorCodes } from "../utils-BFQCAfNW.mjs";
2
+
3
+ export { defineErrorCodes };