@better-auth/core 1.4.12-beta.2 → 1.4.13

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 (185) hide show
  1. package/.turbo/turbo-build.log +172 -35
  2. package/dist/api/index.d.mts +178 -1
  3. package/dist/api/index.mjs +2 -1
  4. package/dist/context/endpoint-context.d.mts +19 -0
  5. package/dist/context/endpoint-context.mjs +31 -0
  6. package/dist/context/global.d.mts +7 -0
  7. package/dist/context/global.mjs +37 -0
  8. package/dist/context/index.d.mts +5 -53
  9. package/dist/context/index.mjs +5 -2
  10. package/dist/context/request-state.d.mts +27 -0
  11. package/dist/context/request-state.mjs +49 -0
  12. package/dist/context/transaction.d.mts +16 -0
  13. package/dist/context/transaction.mjs +52 -0
  14. package/dist/db/adapter/factory.d.mts +27 -0
  15. package/dist/db/adapter/factory.mjs +738 -0
  16. package/dist/db/adapter/get-default-field-name.d.mts +18 -0
  17. package/dist/db/adapter/get-default-field-name.mjs +38 -0
  18. package/dist/db/adapter/get-default-model-name.d.mts +12 -0
  19. package/dist/db/adapter/get-default-model-name.mjs +32 -0
  20. package/dist/db/adapter/get-field-attributes.d.mts +29 -0
  21. package/dist/db/adapter/get-field-attributes.mjs +39 -0
  22. package/dist/db/adapter/get-field-name.d.mts +18 -0
  23. package/dist/db/adapter/get-field-name.mjs +33 -0
  24. package/dist/db/adapter/get-id-field.d.mts +39 -0
  25. package/dist/db/adapter/get-id-field.mjs +68 -0
  26. package/dist/db/adapter/get-model-name.d.mts +12 -0
  27. package/dist/db/adapter/get-model-name.mjs +23 -0
  28. package/dist/db/adapter/index.d.mts +513 -1
  29. package/dist/db/adapter/index.mjs +8 -970
  30. package/dist/db/adapter/types.d.mts +139 -0
  31. package/dist/db/adapter/utils.d.mts +7 -0
  32. package/dist/db/adapter/utils.mjs +38 -0
  33. package/dist/db/get-tables.d.mts +8 -0
  34. package/dist/{get-tables-CMc_Emww.mjs → db/get-tables.mjs} +1 -1
  35. package/dist/db/index.d.mts +10 -2
  36. package/dist/db/index.mjs +7 -60
  37. package/dist/db/plugin.d.mts +12 -0
  38. package/dist/db/schema/account.d.mts +26 -0
  39. package/dist/db/schema/account.mjs +19 -0
  40. package/dist/db/schema/rate-limit.d.mts +14 -0
  41. package/dist/db/schema/rate-limit.mjs +11 -0
  42. package/dist/db/schema/session.d.mts +21 -0
  43. package/dist/db/schema/session.mjs +14 -0
  44. package/dist/db/schema/shared.d.mts +10 -0
  45. package/dist/db/schema/shared.mjs +11 -0
  46. package/dist/db/schema/user.d.mts +20 -0
  47. package/dist/db/schema/user.mjs +13 -0
  48. package/dist/db/schema/verification.d.mts +19 -0
  49. package/dist/db/schema/verification.mjs +12 -0
  50. package/dist/db/type.d.mts +143 -0
  51. package/dist/env/color-depth.d.mts +4 -0
  52. package/dist/env/color-depth.mjs +88 -0
  53. package/dist/env/env-impl.d.mts +32 -0
  54. package/dist/env/env-impl.mjs +82 -0
  55. package/dist/env/index.d.mts +4 -2
  56. package/dist/env/index.mjs +3 -1
  57. package/dist/{index-BRBu0-5h.d.mts → env/logger.d.mts} +1 -35
  58. package/dist/env/logger.mjs +81 -0
  59. package/dist/error/codes.d.mts +48 -0
  60. package/dist/{error-DP1xOn7P.mjs → error/codes.mjs} +3 -14
  61. package/dist/error/index.d.mts +5 -48
  62. package/dist/error/index.mjs +12 -3
  63. package/dist/index.d.mts +8 -2
  64. package/dist/oauth2/client-credentials-token.d.mts +36 -0
  65. package/dist/oauth2/client-credentials-token.mjs +54 -0
  66. package/dist/oauth2/create-authorization-url.d.mts +45 -0
  67. package/dist/oauth2/create-authorization-url.mjs +42 -0
  68. package/dist/oauth2/index.d.mts +8 -2
  69. package/dist/oauth2/index.mjs +6 -2
  70. package/dist/oauth2/oauth-provider.d.mts +194 -0
  71. package/dist/oauth2/refresh-access-token.d.mts +36 -0
  72. package/dist/oauth2/refresh-access-token.mjs +58 -0
  73. package/dist/oauth2/utils.d.mts +7 -0
  74. package/dist/oauth2/utils.mjs +27 -0
  75. package/dist/oauth2/validate-authorization-code.d.mts +55 -0
  76. package/dist/oauth2/validate-authorization-code.mjs +71 -0
  77. package/dist/oauth2/verify.d.mts +49 -0
  78. package/dist/oauth2/verify.mjs +95 -0
  79. package/dist/social-providers/apple.d.mts +119 -0
  80. package/dist/social-providers/apple.mjs +102 -0
  81. package/dist/social-providers/atlassian.d.mts +72 -0
  82. package/dist/social-providers/atlassian.mjs +83 -0
  83. package/dist/social-providers/cognito.d.mts +87 -0
  84. package/dist/social-providers/cognito.mjs +166 -0
  85. package/dist/social-providers/discord.d.mts +126 -0
  86. package/dist/social-providers/discord.mjs +64 -0
  87. package/dist/social-providers/dropbox.d.mts +71 -0
  88. package/dist/social-providers/dropbox.mjs +75 -0
  89. package/dist/social-providers/facebook.d.mts +81 -0
  90. package/dist/social-providers/facebook.mjs +120 -0
  91. package/dist/social-providers/figma.d.mts +63 -0
  92. package/dist/social-providers/figma.mjs +84 -0
  93. package/dist/social-providers/github.d.mts +104 -0
  94. package/dist/social-providers/github.mjs +80 -0
  95. package/dist/social-providers/gitlab.d.mts +125 -0
  96. package/dist/social-providers/gitlab.mjs +82 -0
  97. package/dist/social-providers/google.d.mts +99 -0
  98. package/dist/social-providers/google.mjs +109 -0
  99. package/dist/social-providers/huggingface.d.mts +85 -0
  100. package/dist/social-providers/huggingface.mjs +75 -0
  101. package/dist/social-providers/index.d.mts +1723 -1
  102. package/dist/social-providers/index.mjs +33 -2570
  103. package/dist/social-providers/kakao.d.mts +163 -0
  104. package/dist/social-providers/kakao.mjs +72 -0
  105. package/dist/social-providers/kick.d.mts +75 -0
  106. package/dist/social-providers/kick.mjs +71 -0
  107. package/dist/social-providers/line.d.mts +107 -0
  108. package/dist/social-providers/line.mjs +113 -0
  109. package/dist/social-providers/linear.d.mts +70 -0
  110. package/dist/social-providers/linear.mjs +88 -0
  111. package/dist/social-providers/linkedin.d.mts +69 -0
  112. package/dist/social-providers/linkedin.mjs +76 -0
  113. package/dist/social-providers/microsoft-entra-id.d.mts +174 -0
  114. package/dist/social-providers/microsoft-entra-id.mjs +106 -0
  115. package/dist/social-providers/naver.d.mts +104 -0
  116. package/dist/social-providers/naver.mjs +67 -0
  117. package/dist/social-providers/notion.d.mts +66 -0
  118. package/dist/social-providers/notion.mjs +75 -0
  119. package/dist/social-providers/paybin.d.mts +73 -0
  120. package/dist/social-providers/paybin.mjs +85 -0
  121. package/dist/social-providers/paypal.d.mts +131 -0
  122. package/dist/social-providers/paypal.mjs +144 -0
  123. package/dist/social-providers/polar.d.mts +76 -0
  124. package/dist/social-providers/polar.mjs +73 -0
  125. package/dist/social-providers/reddit.d.mts +64 -0
  126. package/dist/social-providers/reddit.mjs +83 -0
  127. package/dist/social-providers/roblox.d.mts +72 -0
  128. package/dist/social-providers/roblox.mjs +59 -0
  129. package/dist/social-providers/salesforce.d.mts +81 -0
  130. package/dist/social-providers/salesforce.mjs +91 -0
  131. package/dist/social-providers/slack.d.mts +85 -0
  132. package/dist/social-providers/slack.mjs +68 -0
  133. package/dist/social-providers/spotify.d.mts +65 -0
  134. package/dist/social-providers/spotify.mjs +71 -0
  135. package/dist/social-providers/tiktok.d.mts +171 -0
  136. package/dist/social-providers/tiktok.mjs +62 -0
  137. package/dist/social-providers/twitch.d.mts +81 -0
  138. package/dist/social-providers/twitch.mjs +78 -0
  139. package/dist/social-providers/twitter.d.mts +140 -0
  140. package/dist/social-providers/twitter.mjs +87 -0
  141. package/dist/social-providers/vercel.d.mts +64 -0
  142. package/dist/social-providers/vercel.mjs +61 -0
  143. package/dist/social-providers/vk.d.mts +72 -0
  144. package/dist/social-providers/vk.mjs +83 -0
  145. package/dist/social-providers/zoom.d.mts +173 -0
  146. package/dist/social-providers/zoom.mjs +72 -0
  147. package/dist/types/context.d.mts +215 -0
  148. package/dist/types/cookie.d.mts +15 -0
  149. package/dist/types/helper.d.mts +8 -0
  150. package/dist/types/index.d.mts +8 -0
  151. package/dist/types/init-options.d.mts +1266 -0
  152. package/dist/types/plugin-client.d.mts +103 -0
  153. package/dist/types/plugin.d.mts +121 -0
  154. package/dist/utils/deprecate.d.mts +10 -0
  155. package/dist/utils/deprecate.mjs +17 -0
  156. package/dist/utils/error-codes.d.mts +9 -0
  157. package/dist/utils/error-codes.mjs +7 -0
  158. package/dist/utils/id.d.mts +4 -0
  159. package/dist/utils/id.mjs +9 -0
  160. package/dist/utils/index.d.mts +5 -26
  161. package/dist/utils/index.mjs +5 -2
  162. package/dist/utils/json.d.mts +4 -0
  163. package/dist/utils/json.mjs +25 -0
  164. package/dist/utils/string.d.mts +4 -0
  165. package/dist/utils/string.mjs +7 -0
  166. package/package.json +1 -1
  167. package/src/context/endpoint-context.ts +7 -15
  168. package/src/context/global.ts +57 -0
  169. package/src/context/index.ts +1 -0
  170. package/src/context/request-state.ts +7 -12
  171. package/src/context/transaction.ts +7 -16
  172. package/src/db/adapter/factory.ts +13 -13
  173. package/src/db/adapter/get-default-model-name.ts +1 -1
  174. package/src/db/adapter/get-id-field.ts +2 -2
  175. package/src/error/index.ts +2 -3
  176. package/src/social-providers/gitlab.ts +1 -1
  177. package/src/types/context.ts +137 -131
  178. package/src/types/cookie.ts +6 -4
  179. package/src/types/index.ts +2 -1
  180. package/tsdown.config.ts +9 -0
  181. package/dist/context-BGZ8V6DD.mjs +0 -126
  182. package/dist/env-DbssmzoK.mjs +0 -245
  183. package/dist/index-zgYuzZ7O.d.mts +0 -8020
  184. package/dist/oauth2-COJkghlT.mjs +0 -326
  185. package/dist/utils-U2L7n92V.mjs +0 -59
@@ -1,5 +1,5 @@
1
1
 
2
- > @better-auth/core@1.4.12-beta.2 build /home/runner/work/better-auth/better-auth/packages/core
2
+ > @better-auth/core@1.4.13 build /home/runner/work/better-auth/better-auth/packages/core
3
3
  > tsdown
4
4
 
5
5
  ℹ tsdown v0.17.2 powered by rolldown v1.0.0-beta.53
@@ -7,37 +7,174 @@
7
7
  ℹ entry: src/index.ts, src/db/index.ts, src/db/adapter/index.ts, src/async_hooks/index.ts, src/async_hooks/pure.index.ts, src/context/index.ts, src/env/index.ts, src/oauth2/index.ts, src/api/index.ts, src/social-providers/index.ts, src/utils/index.ts, src/error/index.ts
8
8
  ℹ tsconfig: tsconfig.json
9
9
  ℹ Build start
10
- ℹ dist/social-providers/index.mjs  80.96 kB │ gzip: 10.43 kB
11
- ℹ dist/db/adapter/index.mjs  38.55 kB │ gzip: 7.86 kB
12
- ℹ dist/db/index.mjs  1.66 kB │ gzip: 0.54 kB
13
- ℹ dist/api/index.mjs  1.23 kB │ gzip: 0.49 kB
14
- ℹ dist/async_hooks/index.mjs  1.03 kB │ gzip: 0.54 kB
15
- ℹ dist/async_hooks/pure.index.mjs  0.99 kB │ gzip: 0.49 kB
16
- ℹ dist/oauth2/index.mjs  0.75 kB │ gzip: 0.28 kB
17
- ℹ dist/context/index.mjs  0.70 kB │ gzip: 0.24 kB
18
- ℹ dist/env/index.mjs  0.44 kB │ gzip: 0.25 kB
19
- ℹ dist/utils/index.mjs  0.26 kB │ gzip: 0.18 kB
20
- ℹ dist/error/index.mjs  0.19 kB │ gzip: 0.14 kB
21
- ℹ dist/index.mjs  0.01 kB │ gzip: 0.03 kB
22
- ℹ dist/oauth2-COJkghlT.mjs  12.86 kB │ gzip: 3.16 kB
23
- ℹ dist/env-DbssmzoK.mjs  7.67 kB │ gzip: 2.54 kB
24
- ℹ dist/get-tables-CMc_Emww.mjs  6.76 kB │ gzip: 1.30 kB
25
- ℹ dist/context-BGZ8V6DD.mjs  4.46 kB │ gzip: 1.10 kB
26
- ℹ dist/error-DP1xOn7P.mjs  2.76 kB │ gzip: 1.16 kB
27
- ℹ dist/utils-U2L7n92V.mjs  1.46 kB │ gzip: 0.70 kB
28
- ℹ dist/social-providers/index.d.mts  3.89 kB │ gzip: 1.19 kB
29
- ℹ dist/context/index.d.mts  3.02 kB │ gzip: 0.96 kB
30
- ℹ dist/error/index.d.mts  3.02 kB │ gzip: 1.10 kB
31
- ℹ dist/utils/index.d.mts  1.50 kB │ gzip: 0.68 kB
32
- ℹ dist/db/adapter/index.d.mts  1.34 kB │ gzip: 0.43 kB
33
- ℹ dist/index.d.mts  0.95 kB │ gzip: 0.36 kB
34
- ℹ dist/oauth2/index.d.mts  0.88 kB │ gzip: 0.32 kB
35
- ℹ dist/db/index.d.mts  0.81 kB │ gzip: 0.34 kB
36
- ℹ dist/env/index.d.mts  0.59 kB │ gzip: 0.30 kB
37
- ℹ dist/api/index.d.mts  0.26 kB │ gzip: 0.14 kB
38
- ℹ dist/async_hooks/index.d.mts  0.24 kB │ gzip: 0.16 kB
39
- ℹ dist/async_hooks/pure.index.d.mts  0.22 kB │ gzip: 0.16 kB
40
- ℹ dist/index-zgYuzZ7O.d.mts 227.98 kB │ gzip: 36.00 kB
41
- ℹ dist/index-BRBu0-5h.d.mts  3.31 kB │ gzip: 1.11 kB
42
- ℹ 32 files, total: 410.77 kB
43
- ✔ Build complete in 5142ms
10
+ ℹ dist/social-providers/index.mjs  2.32 kB │ gzip: 0.72 kB
11
+ ℹ dist/api/index.mjs  1.27 kB │ gzip: 0.48 kB
12
+ ℹ dist/async_hooks/index.mjs  1.03 kB │ gzip: 0.54 kB
13
+ ℹ dist/async_hooks/pure.index.mjs  0.99 kB │ gzip: 0.49 kB
14
+ ℹ dist/oauth2/index.mjs  0.87 kB │ gzip: 0.27 kB
15
+ ℹ dist/context/index.mjs  0.79 kB │ gzip: 0.23 kB
16
+ ℹ dist/db/adapter/index.mjs  0.71 kB │ gzip: 0.22 kB
17
+ ℹ dist/db/index.mjs  0.50 kB │ gzip: 0.18 kB
18
+ ℹ dist/env/index.mjs  0.43 kB │ gzip: 0.21 kB
19
+ ℹ dist/utils/index.mjs  0.33 kB │ gzip: 0.16 kB
20
+ ℹ dist/error/index.mjs  0.33 kB │ gzip: 0.21 kB
21
+ ℹ dist/index.mjs  0.01 kB │ gzip: 0.03 kB
22
+ ℹ dist/db/adapter/factory.mjs 30.11 kB │ gzip: 5.99 kB
23
+ ℹ dist/db/get-tables.mjs  6.76 kB │ gzip: 1.29 kB
24
+ ℹ dist/social-providers/cognito.mjs  5.93 kB │ gzip: 1.93 kB
25
+ ℹ dist/social-providers/paypal.mjs  5.03 kB │ gzip: 1.48 kB
26
+ ℹ dist/social-providers/google.mjs  3.79 kB │ gzip: 1.39 kB
27
+ ℹ dist/oauth2/verify.mjs  3.74 kB │ gzip: 1.32 kB
28
+ ℹ dist/social-providers/apple.mjs  3.71 kB │ gzip: 1.34 kB
29
+ ℹ dist/social-providers/facebook.mjs  3.57 kB │ gzip: 1.27 kB
30
+ ℹ dist/social-providers/line.mjs  3.57 kB │ gzip: 1.20 kB
31
+ ℹ dist/social-providers/salesforce.mjs  3.50 kB │ gzip: 1.12 kB
32
+ ℹ dist/social-providers/microsoft-entra-id.mjs  3.46 kB │ gzip: 1.22 kB
33
+ ℹ dist/oauth2/validate-authorization-code.mjs  2.76 kB │ gzip: 1.03 kB
34
+ ℹ dist/social-providers/atlassian.mjs  2.75 kB │ gzip: 0.99 kB
35
+ ℹ dist/social-providers/twitter.mjs  2.74 kB │ gzip: 0.92 kB
36
+ ℹ dist/env/color-depth.mjs  2.72 kB │ gzip: 0.99 kB
37
+ ℹ dist/social-providers/figma.mjs  2.71 kB │ gzip: 0.98 kB
38
+ ℹ dist/db/adapter/get-id-field.mjs  2.67 kB │ gzip: 0.98 kB
39
+ ℹ dist/social-providers/paybin.mjs  2.65 kB │ gzip: 0.97 kB
40
+ ℹ dist/social-providers/gitlab.mjs  2.65 kB │ gzip: 0.96 kB
41
+ ℹ dist/social-providers/reddit.mjs  2.63 kB │ gzip: 1.01 kB
42
+ ℹ dist/social-providers/discord.mjs  2.62 kB │ gzip: 1.04 kB
43
+ ℹ dist/social-providers/github.mjs  2.61 kB │ gzip: 0.91 kB
44
+ ℹ dist/social-providers/vk.mjs  2.59 kB │ gzip: 0.94 kB
45
+ ℹ dist/env/env-impl.mjs  2.58 kB │ gzip: 0.90 kB
46
+ ℹ dist/error/codes.mjs  2.52 kB │ gzip: 1.04 kB
47
+ ℹ dist/env/logger.mjs  2.42 kB │ gzip: 0.94 kB
48
+ ℹ dist/social-providers/linear.mjs  2.42 kB │ gzip: 0.90 kB
49
+ ℹ dist/social-providers/dropbox.mjs  2.38 kB │ gzip: 0.87 kB
50
+ ℹ dist/social-providers/kakao.mjs  2.31 kB │ gzip: 0.84 kB
51
+ ℹ dist/social-providers/notion.mjs  2.28 kB │ gzip: 0.86 kB
52
+ ℹ dist/social-providers/zoom.mjs  2.27 kB │ gzip: 0.89 kB
53
+ ℹ dist/social-providers/tiktok.mjs  2.27 kB │ gzip: 0.88 kB
54
+ ℹ dist/social-providers/slack.mjs  2.25 kB │ gzip: 0.84 kB
55
+ ℹ dist/social-providers/huggingface.mjs  2.22 kB │ gzip: 0.79 kB
56
+ ℹ dist/social-providers/twitch.mjs  2.20 kB │ gzip: 0.78 kB
57
+ ℹ dist/social-providers/linkedin.mjs  2.19 kB │ gzip: 0.80 kB
58
+ ℹ dist/social-providers/polar.mjs  2.19 kB │ gzip: 0.79 kB
59
+ ℹ dist/social-providers/roblox.mjs  2.17 kB │ gzip: 0.87 kB
60
+ ℹ dist/oauth2/refresh-access-token.mjs  2.15 kB │ gzip: 0.85 kB
61
+ ℹ dist/social-providers/spotify.mjs  2.13 kB │ gzip: 0.78 kB
62
+ ℹ dist/social-providers/naver.mjs  2.10 kB │ gzip: 0.79 kB
63
+ ℹ dist/social-providers/kick.mjs  2.08 kB │ gzip: 0.77 kB
64
+ ℹ dist/social-providers/vercel.mjs  1.91 kB │ gzip: 0.74 kB
65
+ ℹ dist/oauth2/create-authorization-url.mjs  1.86 kB │ gzip: 0.73 kB
66
+ ℹ dist/oauth2/client-credentials-token.mjs  1.83 kB │ gzip: 0.77 kB
67
+ ℹ dist/context/request-state.mjs  1.63 kB │ gzip: 0.59 kB
68
+ ℹ dist/context/transaction.mjs  1.60 kB │ gzip: 0.55 kB
69
+ ℹ dist/db/adapter/get-default-field-name.mjs  1.41 kB │ gzip: 0.66 kB
70
+ ℹ dist/db/adapter/get-default-model-name.mjs  1.40 kB │ gzip: 0.65 kB
71
+ ℹ dist/context/endpoint-context.mjs  1.31 kB │ gzip: 0.53 kB
72
+ ℹ dist/db/adapter/get-field-attributes.mjs  1.26 kB │ gzip: 0.46 kB
73
+ ℹ dist/db/adapter/utils.mjs  1.15 kB │ gzip: 0.46 kB
74
+ ℹ dist/db/adapter/get-field-name.mjs  1.07 kB │ gzip: 0.47 kB
75
+ ℹ dist/oauth2/utils.mjs  0.98 kB │ gzip: 0.50 kB
76
+ ℹ dist/context/global.mjs  0.96 kB │ gzip: 0.47 kB
77
+ ℹ dist/db/adapter/get-model-name.mjs  0.89 kB │ gzip: 0.42 kB
78
+ ℹ dist/utils/json.mjs  0.59 kB │ gzip: 0.35 kB
79
+ ℹ dist/db/schema/account.mjs  0.52 kB │ gzip: 0.24 kB
80
+ ℹ dist/utils/deprecate.mjs  0.36 kB │ gzip: 0.24 kB
81
+ ℹ dist/db/schema/user.mjs  0.33 kB │ gzip: 0.23 kB
82
+ ℹ dist/db/schema/session.mjs  0.33 kB │ gzip: 0.21 kB
83
+ ℹ dist/db/schema/shared.mjs  0.28 kB │ gzip: 0.19 kB
84
+ ℹ dist/db/schema/verification.mjs  0.27 kB │ gzip: 0.19 kB
85
+ ℹ dist/utils/id.mjs  0.24 kB │ gzip: 0.18 kB
86
+ ℹ dist/db/schema/rate-limit.mjs  0.21 kB │ gzip: 0.17 kB
87
+ ℹ dist/utils/string.mjs  0.17 kB │ gzip: 0.14 kB
88
+ ℹ dist/utils/error-codes.mjs  0.13 kB │ gzip: 0.11 kB
89
+ ℹ dist/social-providers/index.d.mts 45.59 kB │ gzip: 3.09 kB
90
+ ℹ dist/db/adapter/index.d.mts 15.17 kB │ gzip: 3.60 kB
91
+ ℹ dist/api/index.d.mts  7.54 kB │ gzip: 1.45 kB
92
+ ℹ dist/index.d.mts  1.13 kB │ gzip: 0.34 kB
93
+ ℹ dist/oauth2/index.d.mts  1.05 kB │ gzip: 0.32 kB
94
+ ℹ dist/db/index.d.mts  1.04 kB │ gzip: 0.34 kB
95
+ ℹ dist/context/index.d.mts  0.92 kB │ gzip: 0.27 kB
96
+ ℹ dist/env/index.d.mts  0.58 kB │ gzip: 0.27 kB
97
+ ℹ dist/utils/index.d.mts  0.33 kB │ gzip: 0.16 kB
98
+ ℹ dist/error/index.d.mts  0.27 kB │ gzip: 0.21 kB
99
+ ℹ dist/async_hooks/index.d.mts  0.24 kB │ gzip: 0.16 kB
100
+ ℹ dist/async_hooks/pure.index.d.mts  0.22 kB │ gzip: 0.16 kB
101
+ ℹ dist/types/init-options.d.mts 38.19 kB │ gzip: 8.46 kB
102
+ ℹ dist/types/context.d.mts  9.05 kB │ gzip: 2.65 kB
103
+ ℹ dist/social-providers/zoom.d.mts  6.71 kB │ gzip: 2.29 kB
104
+ ℹ dist/oauth2/oauth-provider.d.mts  5.92 kB │ gzip: 1.67 kB
105
+ ℹ dist/social-providers/microsoft-entra-id.d.mts  5.59 kB │ gzip: 1.96 kB
106
+ ℹ dist/db/adapter/types.d.mts  5.42 kB │ gzip: 1.57 kB
107
+ ℹ dist/social-providers/tiktok.d.mts  5.34 kB │ gzip: 1.34 kB
108
+ ℹ dist/social-providers/kakao.d.mts  4.92 kB │ gzip: 1.27 kB
109
+ ℹ dist/social-providers/twitter.d.mts  4.77 kB │ gzip: 1.43 kB
110
+ ℹ dist/db/type.d.mts  3.89 kB │ gzip: 1.28 kB
111
+ ℹ dist/social-providers/apple.d.mts  3.85 kB │ gzip: 1.50 kB
112
+ ℹ dist/social-providers/discord.d.mts  3.72 kB │ gzip: 1.24 kB
113
+ ℹ dist/types/plugin-client.d.mts  3.62 kB │ gzip: 1.39 kB
114
+ ℹ dist/types/plugin.d.mts  3.62 kB │ gzip: 1.32 kB
115
+ ℹ dist/social-providers/paypal.d.mts  3.35 kB │ gzip: 0.99 kB
116
+ ℹ dist/social-providers/gitlab.d.mts  2.95 kB │ gzip: 0.92 kB
117
+ ℹ dist/error/codes.d.mts  2.85 kB │ gzip: 1.02 kB
118
+ ℹ dist/social-providers/line.d.mts  2.61 kB │ gzip: 0.80 kB
119
+ ℹ dist/social-providers/google.d.mts  2.48 kB │ gzip: 0.87 kB
120
+ ℹ dist/social-providers/naver.d.mts  2.42 kB │ gzip: 0.77 kB
121
+ ℹ dist/social-providers/slack.d.mts  2.39 kB │ gzip: 0.72 kB
122
+ ℹ dist/social-providers/github.d.mts  2.38 kB │ gzip: 0.79 kB
123
+ ℹ dist/social-providers/cognito.d.mts  2.33 kB │ gzip: 0.82 kB
124
+ ℹ dist/social-providers/salesforce.d.mts  2.15 kB │ gzip: 0.81 kB
125
+ ℹ dist/social-providers/huggingface.d.mts  2.13 kB │ gzip: 0.72 kB
126
+ ℹ dist/social-providers/polar.d.mts  2.04 kB │ gzip: 0.66 kB
127
+ ℹ dist/social-providers/roblox.d.mts  2.02 kB │ gzip: 0.73 kB
128
+ ℹ dist/social-providers/facebook.d.mts  1.95 kB │ gzip: 0.74 kB
129
+ ℹ dist/env/logger.d.mts  1.86 kB │ gzip: 0.67 kB
130
+ ℹ dist/social-providers/twitch.d.mts  1.84 kB │ gzip: 0.69 kB
131
+ ℹ dist/social-providers/paybin.d.mts  1.80 kB │ gzip: 0.66 kB
132
+ ℹ dist/social-providers/atlassian.d.mts  1.78 kB │ gzip: 0.62 kB
133
+ ℹ dist/oauth2/verify.d.mts  1.77 kB │ gzip: 0.66 kB
134
+ ℹ dist/social-providers/dropbox.d.mts  1.72 kB │ gzip: 0.64 kB
135
+ ℹ dist/social-providers/vk.d.mts  1.67 kB │ gzip: 0.62 kB
136
+ ℹ dist/social-providers/kick.d.mts  1.62 kB │ gzip: 0.59 kB
137
+ ℹ dist/social-providers/linkedin.d.mts  1.61 kB │ gzip: 0.60 kB
138
+ ℹ dist/social-providers/linear.d.mts  1.60 kB │ gzip: 0.59 kB
139
+ ℹ dist/oauth2/validate-authorization-code.d.mts  1.57 kB │ gzip: 0.49 kB
140
+ ℹ dist/social-providers/notion.d.mts  1.56 kB │ gzip: 0.59 kB
141
+ ℹ dist/social-providers/reddit.d.mts  1.54 kB │ gzip: 0.57 kB
142
+ ℹ dist/social-providers/spotify.d.mts  1.51 kB │ gzip: 0.56 kB
143
+ ℹ dist/social-providers/vercel.d.mts  1.47 kB │ gzip: 0.55 kB
144
+ ℹ dist/social-providers/figma.d.mts  1.47 kB │ gzip: 0.55 kB
145
+ ℹ dist/context/request-state.d.mts  1.35 kB │ gzip: 0.59 kB
146
+ ℹ dist/db/adapter/factory.d.mts  1.30 kB │ gzip: 0.45 kB
147
+ ℹ dist/env/env-impl.d.mts  1.26 kB │ gzip: 0.47 kB
148
+ ℹ dist/oauth2/create-authorization-url.d.mts  1.05 kB │ gzip: 0.41 kB
149
+ ℹ dist/db/schema/account.d.mts  1.05 kB │ gzip: 0.43 kB
150
+ ℹ dist/db/adapter/get-id-field.d.mts  1.04 kB │ gzip: 0.47 kB
151
+ ℹ dist/oauth2/refresh-access-token.d.mts  1.01 kB │ gzip: 0.41 kB
152
+ ℹ dist/context/endpoint-context.d.mts  0.99 kB │ gzip: 0.43 kB
153
+ ℹ dist/oauth2/client-credentials-token.d.mts  0.91 kB │ gzip: 0.36 kB
154
+ ℹ dist/context/transaction.d.mts  0.86 kB │ gzip: 0.38 kB
155
+ ℹ dist/utils/error-codes.d.mts  0.84 kB │ gzip: 0.43 kB
156
+ ℹ dist/db/schema/session.d.mts  0.75 kB │ gzip: 0.40 kB
157
+ ℹ dist/types/index.d.mts  0.74 kB │ gzip: 0.32 kB
158
+ ℹ dist/db/adapter/get-field-attributes.d.mts  0.72 kB │ gzip: 0.34 kB
159
+ ℹ dist/db/schema/user.d.mts  0.71 kB │ gzip: 0.40 kB
160
+ ℹ dist/db/schema/verification.d.mts  0.66 kB │ gzip: 0.36 kB
161
+ ℹ dist/types/helper.d.mts  0.45 kB │ gzip: 0.27 kB
162
+ ℹ dist/types/cookie.d.mts  0.38 kB │ gzip: 0.20 kB
163
+ ℹ dist/db/adapter/get-default-field-name.d.mts  0.38 kB │ gzip: 0.24 kB
164
+ ℹ dist/db/schema/rate-limit.d.mts  0.37 kB │ gzip: 0.25 kB
165
+ ℹ dist/db/adapter/get-field-name.d.mts  0.36 kB │ gzip: 0.23 kB
166
+ ℹ dist/db/adapter/utils.d.mts  0.33 kB │ gzip: 0.23 kB
167
+ ℹ dist/db/adapter/get-default-model-name.d.mts  0.32 kB │ gzip: 0.22 kB
168
+ ℹ dist/db/plugin.d.mts  0.32 kB │ gzip: 0.22 kB
169
+ ℹ dist/utils/deprecate.d.mts  0.30 kB │ gzip: 0.22 kB
170
+ ℹ dist/oauth2/utils.d.mts  0.30 kB │ gzip: 0.20 kB
171
+ ℹ dist/db/adapter/get-model-name.d.mts  0.30 kB │ gzip: 0.21 kB
172
+ ℹ dist/db/get-tables.d.mts  0.29 kB │ gzip: 0.18 kB
173
+ ℹ dist/db/schema/shared.d.mts  0.25 kB │ gzip: 0.18 kB
174
+ ℹ dist/context/global.d.mts  0.20 kB │ gzip: 0.16 kB
175
+ ℹ dist/utils/string.d.mts  0.14 kB │ gzip: 0.12 kB
176
+ ℹ dist/utils/json.d.mts  0.13 kB │ gzip: 0.13 kB
177
+ ℹ dist/utils/id.d.mts  0.12 kB │ gzip: 0.12 kB
178
+ ℹ dist/env/color-depth.d.mts  0.12 kB │ gzip: 0.11 kB
179
+ ℹ 169 files, total: 440.17 kB
180
+ ✔ Build complete in 6537ms
@@ -1,2 +1,179 @@
1
- import { a as optionsMiddleware, i as createAuthMiddleware, n as AuthMiddleware, r as createAuthEndpoint, t as AuthEndpoint } from "../index-zgYuzZ7O.mjs";
1
+ import { BetterAuthDBSchema, ModelNames, SecondaryStorage } from "../db/type.mjs";
2
+ import { Session } from "../db/schema/session.mjs";
3
+ import { User } from "../db/schema/user.mjs";
4
+ import "../db/index.mjs";
5
+ import { DBAdapter } from "../db/adapter/index.mjs";
6
+ import { createLogger } from "../env/logger.mjs";
7
+ import { OAuthProvider } from "../oauth2/oauth-provider.mjs";
8
+ import "../oauth2/index.mjs";
9
+ import { BetterAuthCookie, BetterAuthCookies } from "../types/cookie.mjs";
10
+ import { BetterAuthOptions, BetterAuthRateLimitOptions } from "../types/init-options.mjs";
11
+ import { AuthContext, GenericEndpointContext, InfoContext, InternalAdapter, PluginContext } from "../types/context.mjs";
12
+ import "../types/index.mjs";
13
+ import "../index.mjs";
14
+ import * as better_call0 from "better-call";
15
+ import { EndpointContext, EndpointOptions, StrictEndpoint } from "better-call";
16
+
17
+ //#region src/api/index.d.ts
18
+ declare const optionsMiddleware: <InputCtx extends better_call0.MiddlewareInputContext<better_call0.MiddlewareOptions>>(inputContext: InputCtx) => Promise<AuthContext>;
19
+ declare const createAuthMiddleware: {
20
+ <Options extends better_call0.MiddlewareOptions, R>(options: Options, handler: (ctx: better_call0.MiddlewareContext<Options, {
21
+ returned?: unknown | undefined;
22
+ responseHeaders?: Headers | undefined;
23
+ } & PluginContext & InfoContext & {
24
+ options: BetterAuthOptions;
25
+ trustedOrigins: string[];
26
+ isTrustedOrigin: (url: string, settings?: {
27
+ allowRelativePaths: boolean;
28
+ }) => boolean;
29
+ oauthConfig: {
30
+ skipStateCookieCheck?: boolean | undefined;
31
+ storeStateStrategy: "database" | "cookie";
32
+ };
33
+ newSession: {
34
+ session: Session & Record<string, any>;
35
+ user: User & Record<string, any>;
36
+ } | null;
37
+ session: {
38
+ session: Session & Record<string, any>;
39
+ user: User & Record<string, any>;
40
+ } | null;
41
+ setNewSession: (session: {
42
+ session: Session & Record<string, any>;
43
+ user: User & Record<string, any>;
44
+ } | null) => void;
45
+ socialProviders: OAuthProvider[];
46
+ authCookies: BetterAuthCookies;
47
+ logger: ReturnType<typeof createLogger>;
48
+ rateLimit: {
49
+ enabled: boolean;
50
+ window: number;
51
+ max: number;
52
+ storage: "memory" | "database" | "secondary-storage";
53
+ } & Omit<BetterAuthRateLimitOptions, "enabled" | "window" | "max" | "storage">;
54
+ adapter: DBAdapter<BetterAuthOptions>;
55
+ internalAdapter: InternalAdapter<BetterAuthOptions>;
56
+ createAuthCookie: (cookieName: string, overrideAttributes?: Partial<better_call0.CookieOptions> | undefined) => BetterAuthCookie;
57
+ secret: string;
58
+ sessionConfig: {
59
+ updateAge: number;
60
+ expiresIn: number;
61
+ freshAge: number;
62
+ cookieRefreshCache: false | {
63
+ enabled: true;
64
+ updateAge: number;
65
+ };
66
+ };
67
+ generateId: (options: {
68
+ model: ModelNames;
69
+ size?: number | undefined;
70
+ }) => string | false;
71
+ secondaryStorage: SecondaryStorage | undefined;
72
+ password: {
73
+ hash: (password: string) => Promise<string>;
74
+ verify: (data: {
75
+ password: string;
76
+ hash: string;
77
+ }) => Promise<boolean>;
78
+ config: {
79
+ minPasswordLength: number;
80
+ maxPasswordLength: number;
81
+ };
82
+ checkPassword: (userId: string, ctx: GenericEndpointContext<BetterAuthOptions>) => Promise<boolean>;
83
+ };
84
+ tables: BetterAuthDBSchema;
85
+ runMigrations: () => Promise<void>;
86
+ publishTelemetry: (event: {
87
+ type: string;
88
+ anonymousId?: string | undefined;
89
+ payload: Record<string, any>;
90
+ }) => Promise<void>;
91
+ skipOriginCheck: boolean | string[];
92
+ skipCSRFCheck: boolean;
93
+ runInBackground: (promise: Promise<void>) => void;
94
+ runInBackgroundOrAwait: (promise: Promise<unknown> | Promise<void> | void | unknown) => Promise<unknown>;
95
+ }>) => Promise<R>): (inputContext: better_call0.MiddlewareInputContext<Options>) => Promise<R>;
96
+ <Options extends better_call0.MiddlewareOptions, R_1>(handler: (ctx: better_call0.MiddlewareContext<Options, {
97
+ returned?: unknown | undefined;
98
+ responseHeaders?: Headers | undefined;
99
+ } & PluginContext & InfoContext & {
100
+ options: BetterAuthOptions;
101
+ trustedOrigins: string[];
102
+ isTrustedOrigin: (url: string, settings?: {
103
+ allowRelativePaths: boolean;
104
+ }) => boolean;
105
+ oauthConfig: {
106
+ skipStateCookieCheck?: boolean | undefined;
107
+ storeStateStrategy: "database" | "cookie";
108
+ };
109
+ newSession: {
110
+ session: Session & Record<string, any>;
111
+ user: User & Record<string, any>;
112
+ } | null;
113
+ session: {
114
+ session: Session & Record<string, any>;
115
+ user: User & Record<string, any>;
116
+ } | null;
117
+ setNewSession: (session: {
118
+ session: Session & Record<string, any>;
119
+ user: User & Record<string, any>;
120
+ } | null) => void;
121
+ socialProviders: OAuthProvider[];
122
+ authCookies: BetterAuthCookies;
123
+ logger: ReturnType<typeof createLogger>;
124
+ rateLimit: {
125
+ enabled: boolean;
126
+ window: number;
127
+ max: number;
128
+ storage: "memory" | "database" | "secondary-storage";
129
+ } & Omit<BetterAuthRateLimitOptions, "enabled" | "window" | "max" | "storage">;
130
+ adapter: DBAdapter<BetterAuthOptions>;
131
+ internalAdapter: InternalAdapter<BetterAuthOptions>;
132
+ createAuthCookie: (cookieName: string, overrideAttributes?: Partial<better_call0.CookieOptions> | undefined) => BetterAuthCookie;
133
+ secret: string;
134
+ sessionConfig: {
135
+ updateAge: number;
136
+ expiresIn: number;
137
+ freshAge: number;
138
+ cookieRefreshCache: false | {
139
+ enabled: true;
140
+ updateAge: number;
141
+ };
142
+ };
143
+ generateId: (options: {
144
+ model: ModelNames;
145
+ size?: number | undefined;
146
+ }) => string | false;
147
+ secondaryStorage: SecondaryStorage | undefined;
148
+ password: {
149
+ hash: (password: string) => Promise<string>;
150
+ verify: (data: {
151
+ password: string;
152
+ hash: string;
153
+ }) => Promise<boolean>;
154
+ config: {
155
+ minPasswordLength: number;
156
+ maxPasswordLength: number;
157
+ };
158
+ checkPassword: (userId: string, ctx: GenericEndpointContext<BetterAuthOptions>) => Promise<boolean>;
159
+ };
160
+ tables: BetterAuthDBSchema;
161
+ runMigrations: () => Promise<void>;
162
+ publishTelemetry: (event: {
163
+ type: string;
164
+ anonymousId?: string | undefined;
165
+ payload: Record<string, any>;
166
+ }) => Promise<void>;
167
+ skipOriginCheck: boolean | string[];
168
+ skipCSRFCheck: boolean;
169
+ runInBackground: (promise: Promise<void>) => void;
170
+ runInBackgroundOrAwait: (promise: Promise<unknown> | Promise<void> | void | unknown) => Promise<unknown>;
171
+ }>) => Promise<R_1>): (inputContext: better_call0.MiddlewareInputContext<Options>) => Promise<R_1>;
172
+ };
173
+ type EndpointHandler<Path extends string, Options extends EndpointOptions, R> = (context: EndpointContext<Path, Options, AuthContext>) => Promise<R>;
174
+ declare function createAuthEndpoint<Path extends string, Options extends EndpointOptions, R>(path: Path, options: Options, handler: EndpointHandler<Path, Options, R>): StrictEndpoint<Path, Options, R>;
175
+ declare function createAuthEndpoint<Path extends string, Options extends EndpointOptions, R>(options: Options, handler: EndpointHandler<Path, Options, R>): StrictEndpoint<Path, Options, R>;
176
+ type AuthEndpoint<Path extends string, Opts extends EndpointOptions, R> = ReturnType<typeof createAuthEndpoint<Path, Opts, R>>;
177
+ type AuthMiddleware = ReturnType<typeof createAuthMiddleware>;
178
+ //#endregion
2
179
  export { AuthEndpoint, AuthMiddleware, createAuthEndpoint, createAuthMiddleware, optionsMiddleware };
@@ -1,4 +1,5 @@
1
- import { f as runWithEndpointContext } from "../context-BGZ8V6DD.mjs";
1
+ import { runWithEndpointContext } from "../context/endpoint-context.mjs";
2
+ import "../context/index.mjs";
2
3
  import { createEndpoint, createMiddleware } from "better-call";
3
4
 
4
5
  //#region src/api/index.ts
@@ -0,0 +1,19 @@
1
+ import { AuthContext } from "../types/context.mjs";
2
+ import "../types/index.mjs";
3
+ import { AsyncLocalStorage } from "@better-auth/core/async_hooks";
4
+ import { EndpointContext, InputContext } from "better-call";
5
+
6
+ //#region src/context/endpoint-context.d.ts
7
+ type AuthEndpointContext = Partial<InputContext<string, any> & EndpointContext<string, any>> & {
8
+ context: AuthContext;
9
+ };
10
+ /**
11
+ * This is for internal use only. Most users should use `getCurrentAuthContext` instead.
12
+ *
13
+ * It is exposed for advanced use cases where you need direct access to the AsyncLocalStorage instance.
14
+ */
15
+ declare function getCurrentAuthContextAsyncLocalStorage(): Promise<AsyncLocalStorage<AuthEndpointContext>>;
16
+ declare function getCurrentAuthContext(): Promise<AuthEndpointContext>;
17
+ declare function runWithEndpointContext<T>(context: AuthEndpointContext, fn: () => T): Promise<T>;
18
+ //#endregion
19
+ export { AuthEndpointContext, getCurrentAuthContext, getCurrentAuthContextAsyncLocalStorage, runWithEndpointContext };
@@ -0,0 +1,31 @@
1
+ import { __getBetterAuthGlobal } from "./global.mjs";
2
+ import { getAsyncLocalStorage } from "@better-auth/core/async_hooks";
3
+
4
+ //#region src/context/endpoint-context.ts
5
+ const ensureAsyncStorage = async () => {
6
+ const betterAuthGlobal = __getBetterAuthGlobal();
7
+ if (!betterAuthGlobal.context.endpointContextAsyncStorage) {
8
+ const AsyncLocalStorage$1 = await getAsyncLocalStorage();
9
+ betterAuthGlobal.context.endpointContextAsyncStorage = new AsyncLocalStorage$1();
10
+ }
11
+ return betterAuthGlobal.context.endpointContextAsyncStorage;
12
+ };
13
+ /**
14
+ * This is for internal use only. Most users should use `getCurrentAuthContext` instead.
15
+ *
16
+ * It is exposed for advanced use cases where you need direct access to the AsyncLocalStorage instance.
17
+ */
18
+ async function getCurrentAuthContextAsyncLocalStorage() {
19
+ return ensureAsyncStorage();
20
+ }
21
+ async function getCurrentAuthContext() {
22
+ const context = (await ensureAsyncStorage()).getStore();
23
+ if (!context) throw new Error("No auth context found. Please make sure you are calling this function within a `runWithEndpointContext` callback.");
24
+ return context;
25
+ }
26
+ async function runWithEndpointContext(context, fn) {
27
+ return (await ensureAsyncStorage()).run(context, fn);
28
+ }
29
+
30
+ //#endregion
31
+ export { getCurrentAuthContext, getCurrentAuthContextAsyncLocalStorage, runWithEndpointContext };
@@ -0,0 +1,7 @@
1
+ import { AsyncLocalStorage } from "@better-auth/core/async_hooks";
2
+
3
+ //#region src/context/global.d.ts
4
+
5
+ declare function getBetterAuthVersion(): string;
6
+ //#endregion
7
+ export { getBetterAuthVersion };
@@ -0,0 +1,37 @@
1
+ //#region src/context/global.ts
2
+ const symbol = Symbol.for("better-auth:global");
3
+ let bind = null;
4
+ const __context = {};
5
+ const __betterAuthVersion = "1.4.13";
6
+ /**
7
+ * We store context instance in the globalThis.
8
+ *
9
+ * The reason we do this is that some bundlers, web framework, or package managers might
10
+ * create multiple copies of BetterAuth in the same process intentionally or unintentionally.
11
+ *
12
+ * For example, yarn v1, Next.js, SSR, Vite...
13
+ *
14
+ * @internal
15
+ */
16
+ function __getBetterAuthGlobal() {
17
+ if (!globalThis[symbol]) {
18
+ globalThis[symbol] = {
19
+ version: __betterAuthVersion,
20
+ epoch: 1,
21
+ context: __context
22
+ };
23
+ bind = globalThis[symbol];
24
+ }
25
+ bind = globalThis[symbol];
26
+ if (bind.version !== __betterAuthVersion) {
27
+ bind.version = __betterAuthVersion;
28
+ bind.epoch++;
29
+ }
30
+ return globalThis[symbol];
31
+ }
32
+ function getBetterAuthVersion() {
33
+ return __getBetterAuthGlobal().version;
34
+ }
35
+
36
+ //#endregion
37
+ export { __getBetterAuthGlobal, getBetterAuthVersion };
@@ -1,53 +1,5 @@
1
- import { Xn as DBAdapter, f as AuthContext, tr as DBTransactionAdapter } from "../index-zgYuzZ7O.mjs";
2
- import { AsyncLocalStorage } from "@better-auth/core/async_hooks";
3
- import { EndpointContext, InputContext } from "better-call";
4
-
5
- //#region src/context/endpoint-context.d.ts
6
- type AuthEndpointContext = Partial<InputContext<string, any> & EndpointContext<string, any>> & {
7
- context: AuthContext;
8
- };
9
- /**
10
- * This is for internal use only. Most users should use `getCurrentAuthContext` instead.
11
- *
12
- * It is exposed for advanced use cases where you need direct access to the AsyncLocalStorage instance.
13
- */
14
- declare function getCurrentAuthContextAsyncLocalStorage(): Promise<AsyncLocalStorage<AuthEndpointContext>>;
15
- declare function getCurrentAuthContext(): Promise<AuthEndpointContext>;
16
- declare function runWithEndpointContext<T>(context: AuthEndpointContext, fn: () => T): Promise<T>;
17
- //#endregion
18
- //#region src/context/request-state.d.ts
19
- type RequestStateWeakMap = WeakMap<object, any>;
20
- declare function getRequestStateAsyncLocalStorage(): Promise<AsyncLocalStorage<RequestStateWeakMap>>;
21
- declare function hasRequestState(): Promise<boolean>;
22
- declare function getCurrentRequestState(): Promise<RequestStateWeakMap>;
23
- declare function runWithRequestState<T>(store: RequestStateWeakMap, fn: () => T): Promise<T>;
24
- interface RequestState<T> {
25
- get(): Promise<T>;
26
- set(value: T): Promise<void>;
27
- readonly ref: Readonly<object>;
28
- }
29
- /**
30
- * Defines a request-scoped state with lazy initialization.
31
- *
32
- * @param initFn - A function that initializes the state. It is called the first time `get()` is invoked within each request context, and only once per context.
33
- * @returns A RequestState object with `get` and `set` methods, and a unique `ref` for debugging.
34
- *
35
- * @example
36
- * const userState = defineRequestState(() => ({ id: '', name: '' }));
37
- * // Later, within a request context:
38
- * const user = await userState.get();
39
- */
40
- declare function defineRequestState<T>(initFn: () => T | Promise<T>): RequestState<T>;
41
- //#endregion
42
- //#region src/context/transaction.d.ts
43
- /**
44
- * This is for internal use only. Most users should use `getCurrentAdapter` instead.
45
- *
46
- * It is exposed for advanced use cases where you need direct access to the AsyncLocalStorage instance.
47
- */
48
- declare const getCurrentDBAdapterAsyncLocalStorage: () => Promise<AsyncLocalStorage<DBTransactionAdapter>>;
49
- declare const getCurrentAdapter: (fallback: DBTransactionAdapter) => Promise<DBTransactionAdapter>;
50
- declare const runWithAdapter: <R>(adapter: DBAdapter, fn: () => R) => Promise<R>;
51
- declare const runWithTransaction: <R>(adapter: DBAdapter, fn: () => R) => Promise<R>;
52
- //#endregion
53
- export { type AuthEndpointContext, type RequestState, type RequestStateWeakMap, defineRequestState, getCurrentAdapter, getCurrentAuthContext, getCurrentAuthContextAsyncLocalStorage, getCurrentDBAdapterAsyncLocalStorage, getCurrentRequestState, getRequestStateAsyncLocalStorage, hasRequestState, runWithAdapter, runWithEndpointContext, runWithRequestState, runWithTransaction };
1
+ import { AuthEndpointContext, getCurrentAuthContext, getCurrentAuthContextAsyncLocalStorage, runWithEndpointContext } from "./endpoint-context.mjs";
2
+ import { getBetterAuthVersion } from "./global.mjs";
3
+ import { RequestState, RequestStateWeakMap, defineRequestState, getCurrentRequestState, getRequestStateAsyncLocalStorage, hasRequestState, runWithRequestState } from "./request-state.mjs";
4
+ import { getCurrentAdapter, getCurrentDBAdapterAsyncLocalStorage, runWithAdapter, runWithTransaction } from "./transaction.mjs";
5
+ export { type AuthEndpointContext, type RequestState, type RequestStateWeakMap, defineRequestState, getBetterAuthVersion, getCurrentAdapter, getCurrentAuthContext, getCurrentAuthContextAsyncLocalStorage, getCurrentDBAdapterAsyncLocalStorage, getCurrentRequestState, getRequestStateAsyncLocalStorage, hasRequestState, runWithAdapter, runWithEndpointContext, runWithRequestState, runWithTransaction };
@@ -1,3 +1,6 @@
1
- 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-BGZ8V6DD.mjs";
1
+ import { getBetterAuthVersion } from "./global.mjs";
2
+ import { getCurrentAuthContext, getCurrentAuthContextAsyncLocalStorage, runWithEndpointContext } from "./endpoint-context.mjs";
3
+ import { defineRequestState, getCurrentRequestState, getRequestStateAsyncLocalStorage, hasRequestState, runWithRequestState } from "./request-state.mjs";
4
+ import { getCurrentAdapter, getCurrentDBAdapterAsyncLocalStorage, runWithAdapter, runWithTransaction } from "./transaction.mjs";
2
5
 
3
- export { defineRequestState, getCurrentAdapter, getCurrentAuthContext, getCurrentAuthContextAsyncLocalStorage, getCurrentDBAdapterAsyncLocalStorage, getCurrentRequestState, getRequestStateAsyncLocalStorage, hasRequestState, runWithAdapter, runWithEndpointContext, runWithRequestState, runWithTransaction };
6
+ export { defineRequestState, getBetterAuthVersion, getCurrentAdapter, getCurrentAuthContext, getCurrentAuthContextAsyncLocalStorage, getCurrentDBAdapterAsyncLocalStorage, getCurrentRequestState, getRequestStateAsyncLocalStorage, hasRequestState, runWithAdapter, runWithEndpointContext, runWithRequestState, runWithTransaction };
@@ -0,0 +1,27 @@
1
+ import { AsyncLocalStorage } from "@better-auth/core/async_hooks";
2
+
3
+ //#region src/context/request-state.d.ts
4
+ type RequestStateWeakMap = WeakMap<object, any>;
5
+ declare function getRequestStateAsyncLocalStorage(): Promise<AsyncLocalStorage<RequestStateWeakMap>>;
6
+ declare function hasRequestState(): Promise<boolean>;
7
+ declare function getCurrentRequestState(): Promise<RequestStateWeakMap>;
8
+ declare function runWithRequestState<T>(store: RequestStateWeakMap, fn: () => T): Promise<T>;
9
+ interface RequestState<T> {
10
+ get(): Promise<T>;
11
+ set(value: T): Promise<void>;
12
+ readonly ref: Readonly<object>;
13
+ }
14
+ /**
15
+ * Defines a request-scoped state with lazy initialization.
16
+ *
17
+ * @param initFn - A function that initializes the state. It is called the first time `get()` is invoked within each request context, and only once per context.
18
+ * @returns A RequestState object with `get` and `set` methods, and a unique `ref` for debugging.
19
+ *
20
+ * @example
21
+ * const userState = defineRequestState(() => ({ id: '', name: '' }));
22
+ * // Later, within a request context:
23
+ * const user = await userState.get();
24
+ */
25
+ declare function defineRequestState<T>(initFn: () => T | Promise<T>): RequestState<T>;
26
+ //#endregion
27
+ export { RequestState, RequestStateWeakMap, defineRequestState, getCurrentRequestState, getRequestStateAsyncLocalStorage, hasRequestState, runWithRequestState };