@better-auth/core 1.4.0-beta.14 → 1.4.0-beta.16

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 (101) hide show
  1. package/.turbo/turbo-build.log +36 -86
  2. package/dist/api/index.d.ts +2 -2
  3. package/dist/api/index.js +1 -1
  4. package/dist/context/index.d.ts +17 -3
  5. package/dist/context/index.js +2 -2
  6. package/dist/{context-BAOGRjRS.js → context-C8waWcB6.js} +37 -5
  7. package/dist/db/adapter/index.d.ts +2 -2
  8. package/dist/db/index.d.ts +2 -2
  9. package/dist/env/index.d.ts +1 -1
  10. package/dist/error/index.d.ts +1 -1
  11. package/dist/{index-DAzyP5GG.d.cts → index-CSISZQGm.d.ts} +5 -5
  12. package/dist/{index-DTT2geV_.d.ts → index-oZnxDn99.d.ts} +1057 -829
  13. package/dist/index.d.ts +2 -2
  14. package/dist/oauth2/index.d.ts +2 -2
  15. package/dist/social-providers/index.d.ts +3 -3
  16. package/dist/social-providers/index.js +218 -143
  17. package/package.json +24 -90
  18. package/src/api/index.ts +2 -2
  19. package/src/context/index.ts +9 -0
  20. package/src/context/request-state.test.ts +346 -0
  21. package/src/context/request-state.ts +70 -0
  22. package/src/db/adapter/index.ts +145 -127
  23. package/src/db/plugin.ts +2 -2
  24. package/src/db/type.ts +46 -40
  25. package/src/env/logger.ts +11 -9
  26. package/src/error/index.ts +1 -1
  27. package/src/oauth2/client-credentials-token.ts +8 -8
  28. package/src/oauth2/create-authorization-url.ts +12 -12
  29. package/src/oauth2/oauth-provider.ts +91 -74
  30. package/src/oauth2/refresh-access-token.ts +11 -11
  31. package/src/oauth2/validate-authorization-code.ts +12 -12
  32. package/src/social-providers/apple.ts +5 -5
  33. package/src/social-providers/atlassian.ts +17 -15
  34. package/src/social-providers/cognito.ts +10 -10
  35. package/src/social-providers/discord.ts +6 -6
  36. package/src/social-providers/dropbox.ts +3 -3
  37. package/src/social-providers/facebook.ts +4 -4
  38. package/src/social-providers/figma.ts +2 -2
  39. package/src/social-providers/github.ts +2 -2
  40. package/src/social-providers/gitlab.ts +6 -6
  41. package/src/social-providers/google.ts +9 -9
  42. package/src/social-providers/huggingface.ts +24 -22
  43. package/src/social-providers/index.ts +4 -1
  44. package/src/social-providers/kakao.ts +38 -38
  45. package/src/social-providers/kick.ts +2 -2
  46. package/src/social-providers/line.ts +10 -10
  47. package/src/social-providers/linear.ts +4 -4
  48. package/src/social-providers/linkedin.ts +2 -2
  49. package/src/social-providers/microsoft-entra-id.ts +9 -7
  50. package/src/social-providers/naver.ts +2 -2
  51. package/src/social-providers/notion.ts +9 -7
  52. package/src/social-providers/paybin.ts +122 -0
  53. package/src/social-providers/paypal.ts +26 -24
  54. package/src/social-providers/polar.ts +21 -19
  55. package/src/social-providers/reddit.ts +3 -3
  56. package/src/social-providers/roblox.ts +10 -7
  57. package/src/social-providers/salesforce.ts +16 -14
  58. package/src/social-providers/slack.ts +2 -2
  59. package/src/social-providers/spotify.ts +2 -2
  60. package/src/social-providers/tiktok.ts +30 -28
  61. package/src/social-providers/twitch.ts +3 -3
  62. package/src/social-providers/twitter.ts +47 -43
  63. package/src/social-providers/vk.ts +11 -11
  64. package/src/social-providers/zoom.ts +14 -12
  65. package/src/types/context.ts +19 -14
  66. package/src/types/init-options.ts +1085 -947
  67. package/src/types/plugin-client.ts +42 -11
  68. package/src/types/plugin.ts +63 -49
  69. package/tsdown.config.ts +1 -1
  70. package/dist/api/index.cjs +0 -30
  71. package/dist/api/index.d.cts +0 -3
  72. package/dist/async_hooks/index.cjs +0 -3
  73. package/dist/async_hooks/index.d.cts +0 -2
  74. package/dist/async_hooks-CaXONcb9.cjs +0 -24
  75. package/dist/chunk-CUT6urMc.cjs +0 -30
  76. package/dist/context/index.cjs +0 -10
  77. package/dist/context/index.d.cts +0 -30
  78. package/dist/context-BRDf96na.cjs +0 -113
  79. package/dist/db/adapter/index.cjs +0 -0
  80. package/dist/db/adapter/index.d.cts +0 -3
  81. package/dist/db/index.cjs +0 -68
  82. package/dist/db/index.d.cts +0 -3
  83. package/dist/env/index.cjs +0 -16
  84. package/dist/env/index.d.cts +0 -2
  85. package/dist/env-CuEMo0ZI.cjs +0 -329
  86. package/dist/error/index.cjs +0 -5
  87. package/dist/error/index.d.cts +0 -35
  88. package/dist/error-k9KM7GAb.cjs +0 -56
  89. package/dist/index-6-zeCbRA.d.cts +0 -7097
  90. package/dist/index-BzepAavo.d.cts +0 -7
  91. package/dist/index-C8vNYjIq.d.ts +0 -82
  92. package/dist/index.cjs +0 -0
  93. package/dist/index.d.cts +0 -3
  94. package/dist/oauth2/index.cjs +0 -12
  95. package/dist/oauth2/index.d.cts +0 -3
  96. package/dist/oauth2-C4Pt8KMZ.cjs +0 -298
  97. package/dist/social-providers/index.cjs +0 -2480
  98. package/dist/social-providers/index.d.cts +0 -3
  99. package/dist/utils/index.cjs +0 -3
  100. package/dist/utils/index.d.cts +0 -9
  101. package/dist/utils-Bs-jKit4.cjs +0 -13
@@ -1,92 +1,42 @@
1
1
 
2
- > @better-auth/core@1.4.0-beta.14 build /home/runner/work/better-auth/better-auth/packages/core
2
+ > @better-auth/core@1.4.0-beta.16 build /home/runner/work/better-auth/better-auth/packages/core
3
3
  > tsdown
4
4
 
5
- ℹ tsdown v0.15.10 powered by rolldown v1.0.0-beta.44
5
+ ℹ tsdown v0.15.11 powered by rolldown v1.0.0-beta.45
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/db/index.ts, src/context/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/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
8
8
  ℹ tsconfig: tsconfig.json
9
9
  ℹ Build start
10
- ℹ [CJS] dist/social-providers/index.cjs 79.35 kB │ gzip: 10.25 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: 112.32 kB
29
- [UNRESOLVED_IMPORT] Warning: Could not resolve '@better-auth/core/oauth2' in src/social-providers/polar.ts
30
- ╭─[ src/social-providers/polar.ts:6:8 ]
31
- │
32
- 6 │ } from "@better-auth/core/oauth2";
33
-  │ ─────────────┬────────────
34
-  │ ╰────────────── Module not found, treating it as an external dependency
35
- ───╯
36
-
37
- ℹ [ESM] dist/social-providers/index.js  75.54 kB │ gzip: 9.98 kB
38
- ℹ [ESM] dist/db/index.js  1.58 kB │ gzip: 0.49 kB
39
- ℹ [ESM] dist/api/index.js  0.83 kB │ gzip: 0.40 kB
40
- ℹ [ESM] dist/oauth2/index.js  0.60 kB │ gzip: 0.24 kB
41
- ℹ [ESM] dist/context/index.js  0.48 kB │ gzip: 0.21 kB
42
- ℹ [ESM] dist/env/index.js  0.44 kB │ gzip: 0.25 kB
43
- ℹ [ESM] dist/error/index.js  0.16 kB │ gzip: 0.13 kB
44
- ℹ [ESM] dist/async_hooks/index.js  0.10 kB │ gzip: 0.10 kB
45
- ℹ [ESM] dist/utils/index.js  0.09 kB │ gzip: 0.09 kB
46
- ℹ [ESM] dist/db/adapter/index.js  0.01 kB │ gzip: 0.03 kB
47
- ℹ [ESM] dist/index.js  0.01 kB │ gzip: 0.03 kB
48
- ℹ [ESM] dist/oauth2-CP3eVHS_.js  9.16 kB │ gzip: 2.12 kB
49
- ℹ [ESM] dist/env-DZG_k5Hh.js  7.67 kB │ gzip: 2.54 kB
50
- ℹ [ESM] dist/context-BAOGRjRS.js  2.50 kB │ gzip: 0.72 kB
51
- ℹ [ESM] dist/error-CxOXAZsS.js  1.77 kB │ gzip: 0.79 kB
52
- ℹ [ESM] dist/async_hooks-qYTIyHB7.js  0.87 kB │ gzip: 0.46 kB
53
- ℹ [ESM] dist/utils-CK1IUN9R.js  0.13 kB │ gzip: 0.12 kB
54
- ℹ [ESM] dist/social-providers/index.d.ts  3.65 kB │ gzip: 1.14 kB
55
- ℹ [ESM] dist/error/index.d.ts  1.83 kB │ gzip: 0.71 kB
56
- ℹ [ESM] dist/context/index.d.ts  1.77 kB │ gzip: 0.56 kB
57
- ℹ [ESM] dist/db/index.d.ts  1.01 kB │ gzip: 0.38 kB
58
- ℹ [ESM] dist/utils/index.d.ts  0.84 kB │ gzip: 0.43 kB
59
- ℹ [ESM] dist/index.d.ts  0.82 kB │ gzip: 0.32 kB
60
- ℹ [ESM] dist/oauth2/index.d.ts  0.79 kB │ gzip: 0.30 kB
61
- ℹ [ESM] dist/env/index.d.ts  0.59 kB │ gzip: 0.30 kB
62
- ℹ [ESM] dist/db/adapter/index.d.ts  0.46 kB │ gzip: 0.23 kB
63
- ℹ [ESM] dist/api/index.d.ts  0.29 kB │ gzip: 0.16 kB
64
- ℹ [ESM] dist/async_hooks/index.d.ts  0.14 kB │ gzip: 0.10 kB
65
- ℹ [ESM] dist/index-DTT2geV_.d.ts 185.45 kB │ gzip: 29.86 kB
66
- ℹ [ESM] dist/index-C8vNYjIq.d.ts  3.25 kB │ gzip: 1.10 kB
67
- ℹ [ESM] dist/index-DT7CRnvv.d.ts  0.24 kB │ gzip: 0.16 kB
68
- ℹ [ESM] 31 files, total: 303.10 kB
69
- [UNRESOLVED_IMPORT] Warning: Could not resolve '@better-auth/core/oauth2' in src/social-providers/polar.ts
70
- ╭─[ src/social-providers/polar.ts:6:8 ]
71
- │
72
- 6 │ } from "@better-auth/core/oauth2";
73
-  │ ─────────────┬────────────
74
-  │ ╰────────────── Module not found, treating it as an external dependency
75
- ───╯
76
-
77
- ℹ [CJS] dist/social-providers/index.d.cts  3.65 kB │ gzip: 1.14 kB
78
- ℹ [CJS] dist/error/index.d.cts  1.83 kB │ gzip: 0.71 kB
79
- ℹ [CJS] dist/context/index.d.cts  1.77 kB │ gzip: 0.56 kB
80
- ℹ [CJS] dist/db/index.d.cts  1.01 kB │ gzip: 0.38 kB
81
- ℹ [CJS] dist/utils/index.d.cts  0.84 kB │ gzip: 0.43 kB
82
- ℹ [CJS] dist/index.d.cts  0.83 kB │ gzip: 0.32 kB
83
- ℹ [CJS] dist/oauth2/index.d.cts  0.79 kB │ gzip: 0.30 kB
84
- ℹ [CJS] dist/env/index.d.cts  0.59 kB │ gzip: 0.30 kB
85
- ℹ [CJS] dist/db/adapter/index.d.cts  0.47 kB │ gzip: 0.22 kB
86
- ℹ [CJS] dist/api/index.d.cts  0.29 kB │ gzip: 0.16 kB
87
- ℹ [CJS] dist/async_hooks/index.d.cts  0.14 kB │ gzip: 0.10 kB
88
- ℹ [CJS] dist/index-6-zeCbRA.d.cts 188.69 kB │ gzip: 30.59 kB
89
- ℹ [CJS] dist/index-DAzyP5GG.d.cts  3.25 kB │ gzip: 1.10 kB
90
- ℹ [CJS] dist/index-BzepAavo.d.cts  0.24 kB │ gzip: 0.16 kB
91
- ℹ [CJS] 14 files, total: 204.40 kB
92
- ✔ Build complete in 4733ms
10
+ ℹ dist/social-providers/index.js  77.61 kB │ gzip: 10.11 kB
11
+ ℹ dist/db/index.js  1.58 kB │ gzip: 0.49 kB
12
+ ℹ dist/api/index.js  0.83 kB │ gzip: 0.40 kB
13
+ ℹ dist/context/index.js  0.74 kB │ gzip: 0.27 kB
14
+ ℹ dist/oauth2/index.js  0.60 kB │ gzip: 0.24 kB
15
+ ℹ dist/env/index.js  0.44 kB │ gzip: 0.25 kB
16
+ ℹ dist/error/index.js  0.16 kB │ gzip: 0.13 kB
17
+ ℹ dist/async_hooks/index.js  0.10 kB │ gzip: 0.10 kB
18
+ ℹ dist/utils/index.js  0.09 kB │ gzip: 0.09 kB
19
+ ℹ dist/db/adapter/index.js  0.01 kB │ gzip: 0.03 kB
20
+ ℹ dist/index.js  0.01 kB │ gzip: 0.03 kB
21
+ ℹ dist/oauth2-CP3eVHS_.js  9.16 kB │ gzip: 2.12 kB
22
+ ℹ dist/env-DZG_k5Hh.js  7.67 kB │ gzip: 2.54 kB
23
+ ℹ dist/context-C8waWcB6.js  3.67 kB │ gzip: 0.93 kB
24
+ ℹ dist/error-CxOXAZsS.js  1.77 kB │ gzip: 0.79 kB
25
+ ℹ dist/async_hooks-qYTIyHB7.js  0.87 kB │ gzip: 0.46 kB
26
+ ℹ dist/utils-CK1IUN9R.js  0.13 kB │ gzip: 0.12 kB
27
+ ℹ dist/social-providers/index.d.ts  3.77 kB │ gzip: 1.17 kB
28
+ ℹ dist/context/index.d.ts  2.74 kB │ gzip: 0.79 kB
29
+ ℹ dist/error/index.d.ts  1.84 kB │ gzip: 0.72 kB
30
+ ℹ dist/db/index.d.ts  1.01 kB │ gzip: 0.38 kB
31
+ ℹ dist/utils/index.d.ts  0.84 kB │ gzip: 0.43 kB
32
+ ℹ dist/index.d.ts  0.82 kB │ gzip: 0.32 kB
33
+ ℹ dist/oauth2/index.d.ts  0.79 kB │ gzip: 0.29 kB
34
+ ℹ dist/env/index.d.ts  0.59 kB │ gzip: 0.30 kB
35
+ ℹ dist/db/adapter/index.d.ts  0.46 kB │ gzip: 0.23 kB
36
+ ℹ dist/api/index.d.ts  0.29 kB │ gzip: 0.16 kB
37
+ ℹ dist/async_hooks/index.d.ts  0.14 kB │ gzip: 0.10 kB
38
+ ℹ dist/index-oZnxDn99.d.ts 201.06 kB │ gzip: 31.45 kB
39
+ ℹ dist/index-CSISZQGm.d.ts  3.31 kB │ gzip: 1.11 kB
40
+ ℹ dist/index-DT7CRnvv.d.ts  0.24 kB │ gzip: 0.16 kB
41
+ ℹ 31 files, total: 323.38 kB
42
+ ✔ Build complete in 4529ms
@@ -1,3 +1,3 @@
1
- import { a as optionsMiddleware, i as createAuthMiddleware, n as AuthMiddleware, r as createAuthEndpoint, t as AuthEndpoint } from "../index-DTT2geV_.js";
2
- import "../index-C8vNYjIq.js";
1
+ import { a as optionsMiddleware, i as createAuthMiddleware, n as AuthMiddleware, r as createAuthEndpoint, t as AuthEndpoint } from "../index-oZnxDn99.js";
2
+ import "../index-CSISZQGm.js";
3
3
  export { AuthEndpoint, AuthMiddleware, createAuthEndpoint, createAuthMiddleware, optionsMiddleware };
package/dist/api/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import "../async_hooks-qYTIyHB7.js";
2
- import { s as runWithEndpointContext } from "../context-BAOGRjRS.js";
2
+ import { f as runWithEndpointContext } from "../context-C8waWcB6.js";
3
3
  import { createEndpoint, createMiddleware } from "better-call";
4
4
 
5
5
  //#region src/api/index.ts
@@ -1,7 +1,8 @@
1
- import { Wn as DBTransactionAdapter, d as AuthContext, zn as DBAdapter } from "../index-DTT2geV_.js";
2
- import "../index-C8vNYjIq.js";
1
+ import { Jn as DBTransactionAdapter, Un as DBAdapter, d as AuthContext } from "../index-oZnxDn99.js";
2
+ import "../index-CSISZQGm.js";
3
3
  import { t as AsyncLocalStorage } from "../index-DT7CRnvv.js";
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(): Promise<T | undefined>;
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 };
@@ -1,4 +1,4 @@
1
1
  import "../async_hooks-qYTIyHB7.js";
2
- import { a as getCurrentAuthContext, i as runWithTransaction, n as getCurrentDBAdapterAsyncLocalStorage, o as getCurrentAuthContextAsyncLocalStorage, r as runWithAdapter, s as runWithEndpointContext, t as getCurrentAdapter } from "../context-BAOGRjRS.js";
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-C8waWcB6.js";
3
3
 
4
- export { getCurrentAdapter, getCurrentAuthContext, getCurrentAuthContextAsyncLocalStorage, getCurrentDBAdapterAsyncLocalStorage, runWithAdapter, runWithEndpointContext, runWithTransaction };
4
+ export { defineRequestState, getCurrentAdapter, getCurrentAuthContext, getCurrentAuthContextAsyncLocalStorage, getCurrentDBAdapterAsyncLocalStorage, getCurrentRequestState, getRequestStateAsyncLocalStorage, hasRequestState, runWithAdapter, runWithEndpointContext, runWithRequestState, runWithTransaction };
@@ -2,7 +2,7 @@ import { t as getAsyncLocalStorage } from "./async_hooks-qYTIyHB7.js";
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 { Bn as DBAdapterDebugLogOption, Gn as Where, Hn as DBAdapterInstance, Ln as CleanedWhere, Rn as CustomAdapter, Un as DBAdapterSchemaCreation, Vn as DBAdapterFactoryConfig, Wn as DBTransactionAdapter, zn as DBAdapter } from "../../index-DTT2geV_.js";
2
- import "../../index-C8vNYjIq.js";
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-oZnxDn99.js";
2
+ import "../../index-CSISZQGm.js";
3
3
  export { CleanedWhere, CustomAdapter, DBAdapter, DBAdapterDebugLogOption, DBAdapterFactoryConfig, DBAdapterInstance, DBAdapterSchemaCreation, DBTransactionAdapter, Where };
@@ -1,3 +1,3 @@
1
- import { $n as verificationSchema, Jn as FieldAttribute, Kn as AuthPluginSchema, Qn as Verification, Xn as FieldType, Yn as FieldAttributeConfig, Zn as Primitive, ar as RateLimit, cr as accountSchema, dr as DBFieldAttribute, er as User, fr as DBFieldAttributeConfig, gr as SecondaryStorage, hr as DBPrimitive, ir as sessionSchema, lr as BetterAuthPluginDBSchema, mr as DBPreservedModels, nr as coreSchema, or as rateLimitSchema, pr as DBFieldType, qn as BetterAuthDbSchema, rr as Session, sr as Account, tr as userSchema, ur as BetterAuthDBSchema } from "../index-DTT2geV_.js";
2
- import "../index-C8vNYjIq.js";
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-oZnxDn99.js";
2
+ import "../index-CSISZQGm.js";
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-C8vNYjIq.js";
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-CSISZQGm.js";
2
2
  export { ENV, EnvObject, InternalLogger, LogHandlerParams, LogLevel, Logger, TTY_COLORS, createLogger, env, getBooleanEnvVar, getColorDepth, getEnvVar, isDevelopment, isProduction, isTest, levels, logger, nodeENV, shouldPublishLog };
@@ -29,7 +29,7 @@ declare const BASE_ERROR_CODES: {
29
29
  //#endregion
30
30
  //#region src/error/index.d.ts
31
31
  declare class BetterAuthError extends Error {
32
- constructor(message: string, cause?: string);
32
+ constructor(message: string, cause?: string | undefined);
33
33
  }
34
34
  //#endregion
35
35
  export { BASE_ERROR_CODES, BetterAuthError };
@@ -67,16 +67,16 @@ type LogLevel = "info" | "success" | "warn" | "error" | "debug";
67
67
  declare const levels: readonly ["info", "success", "warn", "error", "debug"];
68
68
  declare function shouldPublishLog(currentLogLevel: LogLevel, logLevel: LogLevel): boolean;
69
69
  interface Logger {
70
- disabled?: boolean;
71
- disableColors?: boolean;
72
- level?: Exclude<LogLevel, "success">;
73
- log?: (level: Exclude<LogLevel, "success">, message: string, ...args: any[]) => void;
70
+ disabled?: boolean | undefined;
71
+ disableColors?: boolean | undefined;
72
+ level?: Exclude<LogLevel, "success"> | undefined;
73
+ log?: ((level: Exclude<LogLevel, "success">, message: string, ...args: any[]) => void) | undefined;
74
74
  }
75
75
  type LogHandlerParams = Parameters<NonNullable<Logger["log"]>> extends [LogLevel, ...infer Rest] ? Rest : never;
76
76
  type InternalLogger = { [K in LogLevel]: (...params: LogHandlerParams) => void } & {
77
77
  get level(): LogLevel;
78
78
  };
79
- declare const createLogger: (options?: Logger) => InternalLogger;
79
+ declare const createLogger: (options?: Logger | undefined) => InternalLogger;
80
80
  declare const logger: InternalLogger;
81
81
  //#endregion
82
82
  export { isTest as _, TTY_COLORS as a, logger as c, EnvObject as d, env as f, isProduction as g, isDevelopment as h, Logger as i, shouldPublishLog as l, getEnvVar as m, LogHandlerParams as n, createLogger as o, getBooleanEnvVar as p, LogLevel as r, levels as s, InternalLogger as t, ENV as u, nodeENV as v, getColorDepth as y };