@better-auth/core 1.4.0-beta.10 → 1.4.0-beta.12

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 (75) hide show
  1. package/.turbo/turbo-build.log +48 -38
  2. package/dist/{middleware → api}/index.cjs +10 -2
  3. package/dist/api/index.d.cts +7 -0
  4. package/dist/api/index.d.ts +7 -0
  5. package/dist/{middleware → api}/index.js +10 -2
  6. package/dist/async_hooks/index.cjs +2 -18
  7. package/dist/async_hooks/index.d.cts +2 -7
  8. package/dist/async_hooks/index.d.ts +2 -7
  9. package/dist/async_hooks/index.js +1 -16
  10. package/dist/async_hooks-CaXONcb9.cjs +24 -0
  11. package/dist/async_hooks-CkLtIFa6.js +18 -0
  12. package/dist/context/index.cjs +10 -0
  13. package/dist/context/index.d.cts +34 -0
  14. package/dist/context/index.d.ts +34 -0
  15. package/dist/context/index.js +4 -0
  16. package/dist/context-CWyHL_gc.js +72 -0
  17. package/dist/context-DFi3BBSr.cjs +113 -0
  18. package/dist/db/adapter/index.d.cts +5 -5
  19. package/dist/db/adapter/index.d.ts +6 -6
  20. package/dist/db/index.d.cts +1 -1
  21. package/dist/db/index.d.ts +2 -2
  22. package/dist/env/index.cjs +1 -1
  23. package/dist/env/index.d.cts +1 -1
  24. package/dist/env/index.d.ts +1 -1
  25. package/dist/env/index.js +1 -1
  26. package/dist/{env-B05JceKx.cjs → env-Blu2teFF.cjs} +0 -1
  27. package/dist/{env-BZ5Nwx0e.js → env-eIh_Jcvf.js} +0 -1
  28. package/dist/error/index.cjs +2 -2
  29. package/dist/error/index.js +2 -2
  30. package/dist/{error-ULaqTKlI.js → error-H6U5qGNP.js} +1 -1
  31. package/dist/{error-Hbg10Ynz.cjs → error-k9KM7GAb.cjs} +1 -1
  32. package/dist/{index-DJdmnKQr.d.ts → index-BPsqLi68.d.ts} +1 -1
  33. package/dist/{index-DNvIh1jX.d.cts → index-CJB1zxVC.d.cts} +1446 -1586
  34. package/dist/index-CfJcErGc.d.ts +7 -0
  35. package/dist/{type-BNCR-kIK.d.cts → index-CgIE2ECh.d.cts} +125 -125
  36. package/dist/{index-DoyF8K2U.d.ts → index-ChlC5Vy3.d.ts} +1 -1
  37. package/dist/{type-eT5TjHFp.d.ts → index-Cmh0x42V.d.ts} +126 -126
  38. package/dist/index-CoizSMoE.d.cts +7 -0
  39. package/dist/{index-Cw9Gfaxd.d.cts → index-ehsSkBxt.d.cts} +1 -1
  40. package/dist/{index-ujq2DkG7.d.ts → index-jMi85fzG.d.ts} +1446 -1586
  41. package/dist/index.d.cts +64 -6
  42. package/dist/index.d.ts +65 -7
  43. package/dist/oauth2/index.cjs +1 -1
  44. package/dist/oauth2/index.d.cts +1 -1
  45. package/dist/oauth2/index.d.ts +2 -2
  46. package/dist/oauth2/index.js +1 -1
  47. package/dist/social-providers/index.cjs +6 -6
  48. package/dist/social-providers/index.d.cts +2 -2
  49. package/dist/social-providers/index.d.ts +3 -3
  50. package/dist/social-providers/index.js +5 -5
  51. package/dist/utils/index.cjs +1 -1
  52. package/dist/utils/index.js +1 -1
  53. package/package.json +24 -13
  54. package/src/api/index.ts +57 -0
  55. package/src/context/endpoint-context.ts +48 -0
  56. package/src/context/index.ts +12 -0
  57. package/src/context/transaction.ts +72 -0
  58. package/src/db/index.ts +1 -2
  59. package/src/env/color-depth.ts +5 -4
  60. package/src/types/context.ts +9 -45
  61. package/src/types/index.ts +1 -1
  62. package/src/types/init-options.ts +30 -11
  63. package/src/types/plugin.ts +10 -8
  64. package/tsdown.config.ts +2 -1
  65. package/dist/middleware/index.d.cts +0 -7
  66. package/dist/middleware/index.d.ts +0 -7
  67. package/src/middleware/index.ts +0 -33
  68. /package/dist/{helper-5oNxdxzu.d.ts → helper-Dm5AtPVS.d.ts} +0 -0
  69. /package/dist/{index-CESTxPyW.d.cts → index-CsHMVqbX.d.ts} +0 -0
  70. /package/dist/{index-Cx8dCSTo.d.ts → index-DFwrZMma.d.cts} +0 -0
  71. /package/dist/{index-B7m2jDWm.d.cts → index-_Oiv-VVr.d.cts} +0 -0
  72. /package/dist/{oauth2-BokgssHJ.js → oauth2-D_FUKfC8.js} +0 -0
  73. /package/dist/{oauth2-CLON8fY4.cjs → oauth2-DqX_pPhp.cjs} +0 -0
  74. /package/dist/{utils-AcCtPmwG.cjs → utils-Bs-jKit4.cjs} +0 -0
  75. /package/dist/{utils-BQjFFU97.js → utils-Sn10glI8.js} +0 -0
@@ -1,74 +1,84 @@
1
1
 
2
- > @better-auth/core@1.4.0-beta.10 build /home/runner/work/better-auth/better-auth/packages/core
2
+ > @better-auth/core@1.4.0-beta.12 build /home/runner/work/better-auth/better-auth/packages/core
3
3
  > tsdown
4
4
 
5
5
  ℹ tsdown v0.15.6 powered by rolldown v1.0.0-beta.43
6
6
  ℹ Using tsdown config: /home/runner/work/better-auth/better-auth/packages/core/tsdown.config.ts
7
- ℹ entry: src/index.ts, src/async_hooks/index.ts, src/db/index.ts, src/env/index.ts, src/error/index.ts, src/middleware/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
10
  ℹ [CJS] dist/social-providers/index.cjs 77.23 kB │ gzip: 10.22 kB
11
11
  ℹ [CJS] dist/db/index.cjs  1.86 kB │ gzip: 0.56 kB
12
- ℹ [CJS] dist/async_hooks/index.cjs  0.88 kB │ gzip: 0.46 kB
12
+ ℹ [CJS] dist/api/index.cjs  1.07 kB │ gzip: 0.46 kB
13
13
  ℹ [CJS] dist/oauth2/index.cjs  0.80 kB │ gzip: 0.24 kB
14
- ℹ [CJS] dist/middleware/index.cjs  0.79 kB │ gzip: 0.34 kB
15
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
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
17
18
  ℹ [CJS] dist/utils/index.cjs  0.12 kB │ gzip: 0.10 kB
18
19
  ℹ [CJS] dist/db/adapter/index.cjs  0.00 kB │ gzip: 0.02 kB
19
20
  ℹ [CJS] dist/index.cjs  0.00 kB │ gzip: 0.02 kB
20
- ℹ [CJS] dist/oauth2-CLON8fY4.cjs 10.87 kB │ gzip: 2.29 kB
21
- ℹ [CJS] dist/env-B05JceKx.cjs  9.16 kB │ gzip: 2.64 kB
22
- ℹ [CJS] dist/error-Hbg10Ynz.cjs  1.98 kB │ gzip: 0.85 kB
21
+ ℹ [CJS] dist/oauth2-DqX_pPhp.cjs 10.87 kB │ gzip: 2.29 kB
22
+ ℹ [CJS] dist/env-Blu2teFF.cjs  9.08 kB │ gzip: 2.62 kB
23
+ ℹ [CJS] dist/context-DFi3BBSr.cjs  3.34 kB │ gzip: 0.79 kB
24
+ ℹ [CJS] dist/error-k9KM7GAb.cjs  1.98 kB │ gzip: 0.86 kB
23
25
  ℹ [CJS] dist/chunk-CUT6urMc.cjs  1.09 kB │ gzip: 0.54 kB
24
- ℹ [CJS] dist/utils-AcCtPmwG.cjs  0.23 kB │ gzip: 0.17 kB
25
- ℹ [CJS] 15 files, total: 105.88 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: 110.27 kB
26
29
  ℹ [ESM] dist/social-providers/index.js  73.39 kB │ gzip: 9.98 kB
27
30
  ℹ [ESM] dist/db/index.js  1.58 kB │ gzip: 0.49 kB
28
- ℹ [ESM] dist/async_hooks/index.js  0.86 kB │ gzip: 0.46 kB
29
- ℹ [ESM] dist/middleware/index.js  0.57 kB │ gzip: 0.27 kB
30
- ℹ [ESM] dist/oauth2/index.js  0.56 kB │ gzip: 0.18 kB
31
+ ℹ [ESM] dist/api/index.js  0.83 kB │ gzip: 0.40 kB
32
+ ℹ [ESM] dist/oauth2/index.js  0.56 kB │ gzip: 0.19 kB
33
+ ℹ [ESM] dist/context/index.js  0.45 kB │ gzip: 0.18 kB
31
34
  ℹ [ESM] dist/env/index.js  0.37 kB │ gzip: 0.18 kB
32
35
  ℹ [ESM] dist/error/index.js  0.15 kB │ gzip: 0.12 kB
36
+ ℹ [ESM] dist/async_hooks/index.js  0.10 kB │ gzip: 0.09 kB
33
37
  ℹ [ESM] dist/utils/index.js  0.09 kB │ gzip: 0.08 kB
34
38
  ℹ [ESM] dist/db/adapter/index.js  0.01 kB │ gzip: 0.03 kB
35
39
  ℹ [ESM] dist/index.js  0.01 kB │ gzip: 0.03 kB
36
- ℹ [ESM] dist/oauth2-BokgssHJ.js  9.18 kB │ gzip: 2.10 kB
37
- ℹ [ESM] dist/env-BZ5Nwx0e.js  7.68 kB │ gzip: 2.52 kB
38
- ℹ [ESM] dist/error-ULaqTKlI.js  1.75 kB │ gzip: 0.78 kB
39
- ℹ [ESM] dist/utils-BQjFFU97.js  0.13 kB │ gzip: 0.11 kB
40
- ℹ [ESM] dist/social-providers/index.d.ts  3.00 kB │ gzip: 0.62 kB
40
+ ℹ [ESM] dist/oauth2-D_FUKfC8.js  9.18 kB │ gzip: 2.10 kB
41
+ ℹ [ESM] dist/env-eIh_Jcvf.js  7.60 kB │ gzip: 2.50 kB
42
+ ℹ [ESM] dist/context-CWyHL_gc.js  2.46 kB │ gzip: 0.69 kB
43
+ ℹ [ESM] dist/error-H6U5qGNP.js  1.75 kB │ gzip: 0.78 kB
44
+ ℹ [ESM] dist/async_hooks-CkLtIFa6.js  0.86 kB │ gzip: 0.46 kB
45
+ ℹ [ESM] dist/utils-Sn10glI8.js  0.13 kB │ gzip: 0.11 kB
46
+ ℹ [ESM] dist/social-providers/index.d.ts  3.00 kB │ gzip: 0.63 kB
47
+ ℹ [ESM] dist/index.d.ts  2.44 kB │ gzip: 0.93 kB
48
+ ℹ [ESM] dist/context/index.d.ts  1.87 kB │ gzip: 0.59 kB
41
49
  ℹ [ESM] dist/error/index.d.ts  1.83 kB │ gzip: 0.71 kB
42
50
  ℹ [ESM] dist/db/index.d.ts  0.86 kB │ gzip: 0.26 kB
43
51
  ℹ [ESM] dist/utils/index.d.ts  0.84 kB │ gzip: 0.43 kB
44
- ℹ [ESM] dist/index.d.ts  0.79 kB │ gzip: 0.28 kB
45
52
  ℹ [ESM] dist/oauth2/index.d.ts  0.71 kB │ gzip: 0.23 kB
46
- ℹ [ESM] dist/db/adapter/index.d.ts  0.55 kB │ gzip: 0.23 kB
53
+ ℹ [ESM] dist/db/adapter/index.d.ts  0.55 kB │ gzip: 0.22 kB
47
54
  ℹ [ESM] dist/env/index.d.ts  0.49 kB │ gzip: 0.22 kB
48
- ℹ [ESM] dist/middleware/index.d.ts  0.39 kB │ gzip: 0.18 kB
49
- ℹ [ESM] dist/async_hooks/index.d.ts  0.24 kB │ gzip: 0.16 kB
50
- ℹ [ESM] dist/index-DJdmnKQr.d.ts 109.59 kB │ gzip: 13.64 kB
51
- ℹ [ESM] dist/index-ujq2DkG7.d.ts  56.16 kB │ gzip: 11.73 kB
52
- ℹ [ESM] dist/index-DoyF8K2U.d.ts  8.95 kB │ gzip: 2.13 kB
53
- ℹ [ESM] dist/type-eT5TjHFp.d.ts  8.24 kB │ gzip: 2.08 kB
54
- ℹ [ESM] dist/index-Cx8dCSTo.d.ts  3.18 kB │ gzip: 1.06 kB
55
- ℹ [ESM] dist/helper-5oNxdxzu.d.ts  0.33 kB │ gzip: 0.21 kB
56
- ℹ [ESM] 30 files, total: 292.45 kB
55
+ ℹ [ESM] dist/api/index.d.ts  0.39 kB │ gzip: 0.17 kB
56
+ ℹ [ESM] dist/async_hooks/index.d.ts  0.13 kB │ gzip: 0.09 kB
57
+ ℹ [ESM] dist/index-BPsqLi68.d.ts 109.59 kB │ gzip: 13.64 kB
58
+ ℹ [ESM] dist/index-jMi85fzG.d.ts  50.86 kB │ gzip: 10.78 kB
59
+ ℹ [ESM] dist/index-ChlC5Vy3.d.ts  8.95 kB │ gzip: 2.13 kB
60
+ ℹ [ESM] dist/index-Cmh0x42V.d.ts  8.24 kB │ gzip: 2.05 kB
61
+ ℹ [ESM] dist/index-CsHMVqbX.d.ts  3.18 kB │ gzip: 1.06 kB
62
+ ℹ [ESM] dist/helper-Dm5AtPVS.d.ts  0.33 kB │ gzip: 0.21 kB
63
+ ℹ [ESM] dist/index-CfJcErGc.d.ts  0.24 kB │ gzip: 0.16 kB
64
+ ℹ [ESM] 35 files, total: 294.00 kB
57
65
  ℹ [CJS] dist/social-providers/index.d.cts  3.00 kB │ gzip: 0.63 kB
66
+ ℹ [CJS] dist/index.d.cts  2.44 kB │ gzip: 0.92 kB
67
+ ℹ [CJS] dist/context/index.d.cts  1.88 kB │ gzip: 0.59 kB
58
68
  ℹ [CJS] dist/error/index.d.cts  1.83 kB │ gzip: 0.71 kB
59
69
  ℹ [CJS] dist/db/index.d.cts  0.86 kB │ gzip: 0.26 kB
60
70
  ℹ [CJS] dist/utils/index.d.cts  0.84 kB │ gzip: 0.43 kB
61
- ℹ [CJS] dist/index.d.cts  0.79 kB │ gzip: 0.28 kB
62
71
  ℹ [CJS] dist/oauth2/index.d.cts  0.71 kB │ gzip: 0.23 kB
63
72
  ℹ [CJS] dist/db/adapter/index.d.cts  0.55 kB │ gzip: 0.23 kB
64
73
  ℹ [CJS] dist/env/index.d.cts  0.50 kB │ gzip: 0.22 kB
65
- ℹ [CJS] dist/middleware/index.d.cts  0.39 kB │ gzip: 0.18 kB
66
- ℹ [CJS] dist/async_hooks/index.d.cts  0.24 kB │ gzip: 0.16 kB
67
- ℹ [CJS] dist/index-Cw9Gfaxd.d.cts 109.59 kB │ gzip: 13.64 kB
68
- ℹ [CJS] dist/index-DNvIh1jX.d.cts  56.16 kB │ gzip: 11.73 kB
69
- ℹ [CJS] dist/index-B7m2jDWm.d.cts  8.95 kB │ gzip: 2.13 kB
70
- ℹ [CJS] dist/type-BNCR-kIK.d.cts  8.24 kB │ gzip: 2.08 kB
71
- ℹ [CJS] dist/index-CESTxPyW.d.cts  3.18 kB │ gzip: 1.06 kB
74
+ ℹ [CJS] dist/api/index.d.cts  0.39 kB │ gzip: 0.18 kB
75
+ ℹ [CJS] dist/async_hooks/index.d.cts  0.13 kB │ gzip: 0.09 kB
76
+ ℹ [CJS] dist/index-ehsSkBxt.d.cts 109.59 kB │ gzip: 13.64 kB
77
+ ℹ [CJS] dist/index-CJB1zxVC.d.cts  50.86 kB │ gzip: 10.78 kB
78
+ ℹ [CJS] dist/index-_Oiv-VVr.d.cts  8.95 kB │ gzip: 2.13 kB
79
+ ℹ [CJS] dist/index-CgIE2ECh.d.cts  8.24 kB │ gzip: 2.06 kB
80
+ ℹ [CJS] dist/index-DFwrZMma.d.cts  3.18 kB │ gzip: 1.06 kB
72
81
  ℹ [CJS] dist/helper-DVgWo5zB.d.cts  0.33 kB │ gzip: 0.21 kB
73
- ℹ [CJS] 16 files, total: 196.16 kB
74
- ✔ Build complete in 4060ms
82
+ ℹ [CJS] dist/index-CoizSMoE.d.cts  0.24 kB │ gzip: 0.16 kB
83
+ ℹ [CJS] 18 files, total: 194.53 kB
84
+ ✔ Build complete in 3787ms
@@ -1,8 +1,10 @@
1
1
  const require_chunk = require('../chunk-CUT6urMc.cjs');
2
+ require('../async_hooks-CaXONcb9.cjs');
3
+ const require_context = require('../context-DFi3BBSr.cjs');
2
4
  let better_call = require("better-call");
3
5
  better_call = require_chunk.__toESM(better_call);
4
6
 
5
- //#region src/middleware/index.ts
7
+ //#region src/api/index.ts
6
8
  const optionsMiddleware = (0, better_call.createMiddleware)(async () => {
7
9
  /**
8
10
  * This will be passed on the instance of
@@ -14,7 +16,13 @@ const optionsMiddleware = (0, better_call.createMiddleware)(async () => {
14
16
  const createAuthMiddleware = better_call.createMiddleware.create({ use: [optionsMiddleware, (0, better_call.createMiddleware)(async () => {
15
17
  return {};
16
18
  })] });
17
- const createAuthEndpoint = better_call.createEndpoint.create({ use: [optionsMiddleware] });
19
+ const use = [optionsMiddleware];
20
+ const createAuthEndpoint = (path, options, handler) => {
21
+ return (0, better_call.createEndpoint)(path, {
22
+ ...options,
23
+ use: [...options?.use || [], ...use]
24
+ }, async (ctx) => require_context.runWithEndpointContext(ctx, () => handler(ctx)));
25
+ };
18
26
 
19
27
  //#endregion
20
28
  exports.createAuthEndpoint = createAuthEndpoint;
@@ -0,0 +1,7 @@
1
+ import "../helper-DVgWo5zB.cjs";
2
+ import "../index-CgIE2ECh.cjs";
3
+ import { AuthEndpoint, AuthMiddleware, createAuthEndpoint, createAuthMiddleware, optionsMiddleware } from "../index-CJB1zxVC.cjs";
4
+ import "../index-_Oiv-VVr.cjs";
5
+ import "../index-ehsSkBxt.cjs";
6
+ import "../index-DFwrZMma.cjs";
7
+ export { AuthEndpoint, AuthMiddleware, createAuthEndpoint, createAuthMiddleware, optionsMiddleware };
@@ -0,0 +1,7 @@
1
+ import "../helper-Dm5AtPVS.js";
2
+ import "../index-Cmh0x42V.js";
3
+ import { AuthEndpoint, AuthMiddleware, createAuthEndpoint, createAuthMiddleware, optionsMiddleware } from "../index-jMi85fzG.js";
4
+ import "../index-ChlC5Vy3.js";
5
+ import "../index-BPsqLi68.js";
6
+ import "../index-CsHMVqbX.js";
7
+ export { AuthEndpoint, AuthMiddleware, createAuthEndpoint, createAuthMiddleware, optionsMiddleware };
@@ -1,6 +1,8 @@
1
+ import "../async_hooks-CkLtIFa6.js";
2
+ import { runWithEndpointContext } from "../context-CWyHL_gc.js";
1
3
  import { createEndpoint, createMiddleware } from "better-call";
2
4
 
3
- //#region src/middleware/index.ts
5
+ //#region src/api/index.ts
4
6
  const optionsMiddleware = createMiddleware(async () => {
5
7
  /**
6
8
  * This will be passed on the instance of
@@ -12,7 +14,13 @@ const optionsMiddleware = createMiddleware(async () => {
12
14
  const createAuthMiddleware = createMiddleware.create({ use: [optionsMiddleware, createMiddleware(async () => {
13
15
  return {};
14
16
  })] });
15
- const createAuthEndpoint = createEndpoint.create({ use: [optionsMiddleware] });
17
+ const use = [optionsMiddleware];
18
+ const createAuthEndpoint = (path, options, handler) => {
19
+ return createEndpoint(path, {
20
+ ...options,
21
+ use: [...options?.use || [], ...use]
22
+ }, async (ctx) => runWithEndpointContext(ctx, () => handler(ctx)));
23
+ };
16
24
 
17
25
  //#endregion
18
26
  export { createAuthEndpoint, createAuthMiddleware, optionsMiddleware };
@@ -1,19 +1,3 @@
1
+ const require_async_hooks = require('../async_hooks-CaXONcb9.cjs');
1
2
 
2
- //#region src/async_hooks/index.ts
3
- const AsyncLocalStoragePromise = import(
4
- /* @vite-ignore */
5
- /* webpackIgnore: true */
6
- "node:async_hooks"
7
- ).then((mod) => mod.AsyncLocalStorage).catch((err) => {
8
- if ("AsyncLocalStorage" in globalThis) return globalThis.AsyncLocalStorage;
9
- console.warn("[better-auth] Warning: AsyncLocalStorage is not available in this environment. Some features may not work as expected.");
10
- console.warn("[better-auth] Please read more about this warning at https://better-auth.com/docs/installation#mount-handler");
11
- console.warn("[better-auth] If you are using Cloudflare Workers, please see: https://developers.cloudflare.com/workers/configuration/compatibility-flags/#nodejs-compatibility-flag");
12
- throw err;
13
- });
14
- async function getAsyncLocalStorage() {
15
- return AsyncLocalStoragePromise;
16
- }
17
-
18
- //#endregion
19
- exports.getAsyncLocalStorage = getAsyncLocalStorage;
3
+ exports.getAsyncLocalStorage = require_async_hooks.getAsyncLocalStorage;
@@ -1,7 +1,2 @@
1
- import { AsyncLocalStorage } from "node:async_hooks";
2
-
3
- //#region src/async_hooks/index.d.ts
4
-
5
- declare function getAsyncLocalStorage(): Promise<typeof AsyncLocalStorage>;
6
- //#endregion
7
- export { type AsyncLocalStorage, getAsyncLocalStorage };
1
+ import { AsyncLocalStorage, getAsyncLocalStorage } from "../index-CoizSMoE.cjs";
2
+ export { AsyncLocalStorage, getAsyncLocalStorage };
@@ -1,7 +1,2 @@
1
- import { AsyncLocalStorage } from "node:async_hooks";
2
-
3
- //#region src/async_hooks/index.d.ts
4
-
5
- declare function getAsyncLocalStorage(): Promise<typeof AsyncLocalStorage>;
6
- //#endregion
7
- export { type AsyncLocalStorage, getAsyncLocalStorage };
1
+ import { AsyncLocalStorage, getAsyncLocalStorage } from "../index-CfJcErGc.js";
2
+ export { AsyncLocalStorage, getAsyncLocalStorage };
@@ -1,18 +1,3 @@
1
- //#region src/async_hooks/index.ts
2
- const AsyncLocalStoragePromise = import(
3
- /* @vite-ignore */
4
- /* webpackIgnore: true */
5
- "node:async_hooks"
6
- ).then((mod) => mod.AsyncLocalStorage).catch((err) => {
7
- if ("AsyncLocalStorage" in globalThis) return globalThis.AsyncLocalStorage;
8
- console.warn("[better-auth] Warning: AsyncLocalStorage is not available in this environment. Some features may not work as expected.");
9
- console.warn("[better-auth] Please read more about this warning at https://better-auth.com/docs/installation#mount-handler");
10
- console.warn("[better-auth] If you are using Cloudflare Workers, please see: https://developers.cloudflare.com/workers/configuration/compatibility-flags/#nodejs-compatibility-flag");
11
- throw err;
12
- });
13
- async function getAsyncLocalStorage() {
14
- return AsyncLocalStoragePromise;
15
- }
1
+ import { getAsyncLocalStorage } from "../async_hooks-CkLtIFa6.js";
16
2
 
17
- //#endregion
18
3
  export { getAsyncLocalStorage };
@@ -0,0 +1,24 @@
1
+
2
+ //#region src/async_hooks/index.ts
3
+ const AsyncLocalStoragePromise = import(
4
+ /* @vite-ignore */
5
+ /* webpackIgnore: true */
6
+ "node:async_hooks"
7
+ ).then((mod) => mod.AsyncLocalStorage).catch((err) => {
8
+ if ("AsyncLocalStorage" in globalThis) return globalThis.AsyncLocalStorage;
9
+ console.warn("[better-auth] Warning: AsyncLocalStorage is not available in this environment. Some features may not work as expected.");
10
+ console.warn("[better-auth] Please read more about this warning at https://better-auth.com/docs/installation#mount-handler");
11
+ console.warn("[better-auth] If you are using Cloudflare Workers, please see: https://developers.cloudflare.com/workers/configuration/compatibility-flags/#nodejs-compatibility-flag");
12
+ throw err;
13
+ });
14
+ async function getAsyncLocalStorage() {
15
+ return AsyncLocalStoragePromise;
16
+ }
17
+
18
+ //#endregion
19
+ Object.defineProperty(exports, 'getAsyncLocalStorage', {
20
+ enumerable: true,
21
+ get: function () {
22
+ return getAsyncLocalStorage;
23
+ }
24
+ });
@@ -0,0 +1,18 @@
1
+ //#region src/async_hooks/index.ts
2
+ const AsyncLocalStoragePromise = import(
3
+ /* @vite-ignore */
4
+ /* webpackIgnore: true */
5
+ "node:async_hooks"
6
+ ).then((mod) => mod.AsyncLocalStorage).catch((err) => {
7
+ if ("AsyncLocalStorage" in globalThis) return globalThis.AsyncLocalStorage;
8
+ console.warn("[better-auth] Warning: AsyncLocalStorage is not available in this environment. Some features may not work as expected.");
9
+ console.warn("[better-auth] Please read more about this warning at https://better-auth.com/docs/installation#mount-handler");
10
+ console.warn("[better-auth] If you are using Cloudflare Workers, please see: https://developers.cloudflare.com/workers/configuration/compatibility-flags/#nodejs-compatibility-flag");
11
+ throw err;
12
+ });
13
+ async function getAsyncLocalStorage() {
14
+ return AsyncLocalStoragePromise;
15
+ }
16
+
17
+ //#endregion
18
+ export { getAsyncLocalStorage };
@@ -0,0 +1,10 @@
1
+ require('../async_hooks-CaXONcb9.cjs');
2
+ const require_context = require('../context-DFi3BBSr.cjs');
3
+
4
+ exports.getCurrentAdapter = require_context.getCurrentAdapter;
5
+ exports.getCurrentAuthContext = require_context.getCurrentAuthContext;
6
+ exports.getCurrentAuthContextAsyncLocalStorage = require_context.getCurrentAuthContextAsyncLocalStorage;
7
+ exports.getCurrentDBAdapterAsyncLocalStorage = require_context.getCurrentDBAdapterAsyncLocalStorage;
8
+ exports.runWithAdapter = require_context.runWithAdapter;
9
+ exports.runWithEndpointContext = require_context.runWithEndpointContext;
10
+ exports.runWithTransaction = require_context.runWithTransaction;
@@ -0,0 +1,34 @@
1
+ import "../helper-DVgWo5zB.cjs";
2
+ import "../index-CgIE2ECh.cjs";
3
+ import { AuthContext, DBAdapter, DBTransactionAdapter } from "../index-CJB1zxVC.cjs";
4
+ import "../index-_Oiv-VVr.cjs";
5
+ import "../index-ehsSkBxt.cjs";
6
+ import "../index-DFwrZMma.cjs";
7
+ import { AsyncLocalStorage } from "../index-CoizSMoE.cjs";
8
+ import { EndpointContext, InputContext } from "better-call";
9
+
10
+ //#region src/context/transaction.d.ts
11
+ /**
12
+ * This is for internal use only. Most users should use `getCurrentAdapter` instead.
13
+ *
14
+ * It is exposed for advanced use cases where you need direct access to the AsyncLocalStorage instance.
15
+ */
16
+ declare const getCurrentDBAdapterAsyncLocalStorage: () => Promise<AsyncLocalStorage<DBTransactionAdapter>>;
17
+ declare const getCurrentAdapter: (fallback: DBTransactionAdapter) => Promise<DBTransactionAdapter>;
18
+ declare const runWithAdapter: <R>(adapter: DBAdapter, fn: () => R) => Promise<R>;
19
+ declare const runWithTransaction: <R>(adapter: DBAdapter, fn: () => R) => Promise<R>;
20
+ //#endregion
21
+ //#region src/context/endpoint-context.d.ts
22
+ type AuthEndpointContext = Partial<InputContext<string, any> & EndpointContext<string, any>> & {
23
+ context: AuthContext;
24
+ };
25
+ /**
26
+ * This is for internal use only. Most users should use `getCurrentAuthContext` instead.
27
+ *
28
+ * It is exposed for advanced use cases where you need direct access to the AsyncLocalStorage instance.
29
+ */
30
+ declare function getCurrentAuthContextAsyncLocalStorage(): Promise<AsyncLocalStorage<AuthEndpointContext>>;
31
+ declare function getCurrentAuthContext(): Promise<AuthEndpointContext>;
32
+ declare function runWithEndpointContext<T>(context: AuthEndpointContext, fn: () => T): Promise<T>;
33
+ //#endregion
34
+ export { type AuthEndpointContext, getCurrentAdapter, getCurrentAuthContext, getCurrentAuthContextAsyncLocalStorage, getCurrentDBAdapterAsyncLocalStorage, runWithAdapter, runWithEndpointContext, runWithTransaction };
@@ -0,0 +1,34 @@
1
+ import "../helper-Dm5AtPVS.js";
2
+ import "../index-Cmh0x42V.js";
3
+ import { AuthContext, DBAdapter, DBTransactionAdapter } from "../index-jMi85fzG.js";
4
+ import "../index-ChlC5Vy3.js";
5
+ import "../index-BPsqLi68.js";
6
+ import "../index-CsHMVqbX.js";
7
+ import { AsyncLocalStorage } from "../index-CfJcErGc.js";
8
+ import { EndpointContext, InputContext } from "better-call";
9
+
10
+ //#region src/context/transaction.d.ts
11
+ /**
12
+ * This is for internal use only. Most users should use `getCurrentAdapter` instead.
13
+ *
14
+ * It is exposed for advanced use cases where you need direct access to the AsyncLocalStorage instance.
15
+ */
16
+ declare const getCurrentDBAdapterAsyncLocalStorage: () => Promise<AsyncLocalStorage<DBTransactionAdapter>>;
17
+ declare const getCurrentAdapter: (fallback: DBTransactionAdapter) => Promise<DBTransactionAdapter>;
18
+ declare const runWithAdapter: <R>(adapter: DBAdapter, fn: () => R) => Promise<R>;
19
+ declare const runWithTransaction: <R>(adapter: DBAdapter, fn: () => R) => Promise<R>;
20
+ //#endregion
21
+ //#region src/context/endpoint-context.d.ts
22
+ type AuthEndpointContext = Partial<InputContext<string, any> & EndpointContext<string, any>> & {
23
+ context: AuthContext;
24
+ };
25
+ /**
26
+ * This is for internal use only. Most users should use `getCurrentAuthContext` instead.
27
+ *
28
+ * It is exposed for advanced use cases where you need direct access to the AsyncLocalStorage instance.
29
+ */
30
+ declare function getCurrentAuthContextAsyncLocalStorage(): Promise<AsyncLocalStorage<AuthEndpointContext>>;
31
+ declare function getCurrentAuthContext(): Promise<AuthEndpointContext>;
32
+ declare function runWithEndpointContext<T>(context: AuthEndpointContext, fn: () => T): Promise<T>;
33
+ //#endregion
34
+ export { type AuthEndpointContext, getCurrentAdapter, getCurrentAuthContext, getCurrentAuthContextAsyncLocalStorage, getCurrentDBAdapterAsyncLocalStorage, runWithAdapter, runWithEndpointContext, runWithTransaction };
@@ -0,0 +1,4 @@
1
+ import "../async_hooks-CkLtIFa6.js";
2
+ import { getCurrentAdapter, getCurrentAuthContext, getCurrentAuthContextAsyncLocalStorage, getCurrentDBAdapterAsyncLocalStorage, runWithAdapter, runWithEndpointContext, runWithTransaction } from "../context-CWyHL_gc.js";
3
+
4
+ export { getCurrentAdapter, getCurrentAuthContext, getCurrentAuthContextAsyncLocalStorage, getCurrentDBAdapterAsyncLocalStorage, runWithAdapter, runWithEndpointContext, runWithTransaction };
@@ -0,0 +1,72 @@
1
+ import { getAsyncLocalStorage } from "./async_hooks-CkLtIFa6.js";
2
+
3
+ //#region src/context/transaction.ts
4
+ let currentAdapterAsyncStorage = null;
5
+ const ensureAsyncStorage$1 = async () => {
6
+ if (!currentAdapterAsyncStorage) currentAdapterAsyncStorage = new (await (getAsyncLocalStorage()))();
7
+ return currentAdapterAsyncStorage;
8
+ };
9
+ /**
10
+ * This is for internal use only. Most users should use `getCurrentAdapter` instead.
11
+ *
12
+ * It is exposed for advanced use cases where you need direct access to the AsyncLocalStorage instance.
13
+ */
14
+ const getCurrentDBAdapterAsyncLocalStorage = async () => {
15
+ return ensureAsyncStorage$1();
16
+ };
17
+ const getCurrentAdapter = async (fallback) => {
18
+ return ensureAsyncStorage$1().then((als) => {
19
+ return als.getStore() || fallback;
20
+ }).catch(() => {
21
+ return fallback;
22
+ });
23
+ };
24
+ const runWithAdapter = async (adapter, fn) => {
25
+ let called = true;
26
+ return ensureAsyncStorage$1().then((als) => {
27
+ called = true;
28
+ return als.run(adapter, fn);
29
+ }).catch((err) => {
30
+ if (!called) return fn();
31
+ throw err;
32
+ });
33
+ };
34
+ const runWithTransaction = async (adapter, fn) => {
35
+ let called = true;
36
+ return ensureAsyncStorage$1().then((als) => {
37
+ called = true;
38
+ return adapter.transaction(async (trx) => {
39
+ return als.run(trx, fn);
40
+ });
41
+ }).catch((err) => {
42
+ if (!called) return fn();
43
+ throw err;
44
+ });
45
+ };
46
+
47
+ //#endregion
48
+ //#region src/context/endpoint-context.ts
49
+ let currentContextAsyncStorage = null;
50
+ const ensureAsyncStorage = async () => {
51
+ if (!currentContextAsyncStorage) currentContextAsyncStorage = new (await (getAsyncLocalStorage()))();
52
+ return currentContextAsyncStorage;
53
+ };
54
+ /**
55
+ * This is for internal use only. Most users should use `getCurrentAuthContext` instead.
56
+ *
57
+ * It is exposed for advanced use cases where you need direct access to the AsyncLocalStorage instance.
58
+ */
59
+ async function getCurrentAuthContextAsyncLocalStorage() {
60
+ return ensureAsyncStorage();
61
+ }
62
+ async function getCurrentAuthContext() {
63
+ const context = (await ensureAsyncStorage()).getStore();
64
+ if (!context) throw new Error("No auth context found. Please make sure you are calling this function within a `getCurrentAuthContext` callback.");
65
+ return context;
66
+ }
67
+ async function runWithEndpointContext(context, fn) {
68
+ return (await ensureAsyncStorage()).run(context, fn);
69
+ }
70
+
71
+ //#endregion
72
+ export { getCurrentAdapter, getCurrentAuthContext, getCurrentAuthContextAsyncLocalStorage, getCurrentDBAdapterAsyncLocalStorage, runWithAdapter, runWithEndpointContext, runWithTransaction };
@@ -0,0 +1,113 @@
1
+ const require_async_hooks = require('./async_hooks-CaXONcb9.cjs');
2
+
3
+ //#region src/context/transaction.ts
4
+ let currentAdapterAsyncStorage = null;
5
+ const ensureAsyncStorage$1 = async () => {
6
+ if (!currentAdapterAsyncStorage) currentAdapterAsyncStorage = new (await (require_async_hooks.getAsyncLocalStorage()))();
7
+ return currentAdapterAsyncStorage;
8
+ };
9
+ /**
10
+ * This is for internal use only. Most users should use `getCurrentAdapter` instead.
11
+ *
12
+ * It is exposed for advanced use cases where you need direct access to the AsyncLocalStorage instance.
13
+ */
14
+ const getCurrentDBAdapterAsyncLocalStorage = async () => {
15
+ return ensureAsyncStorage$1();
16
+ };
17
+ const getCurrentAdapter = async (fallback) => {
18
+ return ensureAsyncStorage$1().then((als) => {
19
+ return als.getStore() || fallback;
20
+ }).catch(() => {
21
+ return fallback;
22
+ });
23
+ };
24
+ const runWithAdapter = async (adapter, fn) => {
25
+ let called = true;
26
+ return ensureAsyncStorage$1().then((als) => {
27
+ called = true;
28
+ return als.run(adapter, fn);
29
+ }).catch((err) => {
30
+ if (!called) return fn();
31
+ throw err;
32
+ });
33
+ };
34
+ const runWithTransaction = async (adapter, fn) => {
35
+ let called = true;
36
+ return ensureAsyncStorage$1().then((als) => {
37
+ called = true;
38
+ return adapter.transaction(async (trx) => {
39
+ return als.run(trx, fn);
40
+ });
41
+ }).catch((err) => {
42
+ if (!called) return fn();
43
+ throw err;
44
+ });
45
+ };
46
+
47
+ //#endregion
48
+ //#region src/context/endpoint-context.ts
49
+ let currentContextAsyncStorage = null;
50
+ const ensureAsyncStorage = async () => {
51
+ if (!currentContextAsyncStorage) currentContextAsyncStorage = new (await (require_async_hooks.getAsyncLocalStorage()))();
52
+ return currentContextAsyncStorage;
53
+ };
54
+ /**
55
+ * This is for internal use only. Most users should use `getCurrentAuthContext` instead.
56
+ *
57
+ * It is exposed for advanced use cases where you need direct access to the AsyncLocalStorage instance.
58
+ */
59
+ async function getCurrentAuthContextAsyncLocalStorage() {
60
+ return ensureAsyncStorage();
61
+ }
62
+ async function getCurrentAuthContext() {
63
+ const context = (await ensureAsyncStorage()).getStore();
64
+ if (!context) throw new Error("No auth context found. Please make sure you are calling this function within a `getCurrentAuthContext` callback.");
65
+ return context;
66
+ }
67
+ async function runWithEndpointContext(context, fn) {
68
+ return (await ensureAsyncStorage()).run(context, fn);
69
+ }
70
+
71
+ //#endregion
72
+ Object.defineProperty(exports, 'getCurrentAdapter', {
73
+ enumerable: true,
74
+ get: function () {
75
+ return getCurrentAdapter;
76
+ }
77
+ });
78
+ Object.defineProperty(exports, 'getCurrentAuthContext', {
79
+ enumerable: true,
80
+ get: function () {
81
+ return getCurrentAuthContext;
82
+ }
83
+ });
84
+ Object.defineProperty(exports, 'getCurrentAuthContextAsyncLocalStorage', {
85
+ enumerable: true,
86
+ get: function () {
87
+ return getCurrentAuthContextAsyncLocalStorage;
88
+ }
89
+ });
90
+ Object.defineProperty(exports, 'getCurrentDBAdapterAsyncLocalStorage', {
91
+ enumerable: true,
92
+ get: function () {
93
+ return getCurrentDBAdapterAsyncLocalStorage;
94
+ }
95
+ });
96
+ Object.defineProperty(exports, 'runWithAdapter', {
97
+ enumerable: true,
98
+ get: function () {
99
+ return runWithAdapter;
100
+ }
101
+ });
102
+ Object.defineProperty(exports, 'runWithEndpointContext', {
103
+ enumerable: true,
104
+ get: function () {
105
+ return runWithEndpointContext;
106
+ }
107
+ });
108
+ Object.defineProperty(exports, 'runWithTransaction', {
109
+ enumerable: true,
110
+ get: function () {
111
+ return runWithTransaction;
112
+ }
113
+ });
@@ -1,7 +1,7 @@
1
1
  import "../../helper-DVgWo5zB.cjs";
2
- import "../../type-BNCR-kIK.cjs";
3
- import "../../index-B7m2jDWm.cjs";
4
- import "../../index-Cw9Gfaxd.cjs";
5
- import "../../index-CESTxPyW.cjs";
6
- import { CleanedWhere, CustomAdapter, DBAdapter, DBAdapterDebugLogOption, DBAdapterFactoryConfig, DBAdapterInstance, DBAdapterSchemaCreation, DBTransactionAdapter, Where } from "../../index-DNvIh1jX.cjs";
2
+ import "../../index-CgIE2ECh.cjs";
3
+ import { CleanedWhere, CustomAdapter, DBAdapter, DBAdapterDebugLogOption, DBAdapterFactoryConfig, DBAdapterInstance, DBAdapterSchemaCreation, DBTransactionAdapter, Where } from "../../index-CJB1zxVC.cjs";
4
+ import "../../index-_Oiv-VVr.cjs";
5
+ import "../../index-ehsSkBxt.cjs";
6
+ import "../../index-DFwrZMma.cjs";
7
7
  export { CleanedWhere, CustomAdapter, DBAdapter, DBAdapterDebugLogOption, DBAdapterFactoryConfig, DBAdapterInstance, DBAdapterSchemaCreation, DBTransactionAdapter, Where };
@@ -1,7 +1,7 @@
1
- import "../../helper-5oNxdxzu.js";
2
- import "../../type-eT5TjHFp.js";
3
- import "../../index-DoyF8K2U.js";
4
- import "../../index-DJdmnKQr.js";
5
- import "../../index-Cx8dCSTo.js";
6
- import { CleanedWhere, CustomAdapter, DBAdapter, DBAdapterDebugLogOption, DBAdapterFactoryConfig, DBAdapterInstance, DBAdapterSchemaCreation, DBTransactionAdapter, Where } from "../../index-ujq2DkG7.js";
1
+ import "../../helper-Dm5AtPVS.js";
2
+ import "../../index-Cmh0x42V.js";
3
+ import { CleanedWhere, CustomAdapter, DBAdapter, DBAdapterDebugLogOption, DBAdapterFactoryConfig, DBAdapterInstance, DBAdapterSchemaCreation, DBTransactionAdapter, Where } from "../../index-jMi85fzG.js";
4
+ import "../../index-ChlC5Vy3.js";
5
+ import "../../index-BPsqLi68.js";
6
+ import "../../index-CsHMVqbX.js";
7
7
  export { CleanedWhere, CustomAdapter, DBAdapter, DBAdapterDebugLogOption, DBAdapterFactoryConfig, DBAdapterInstance, DBAdapterSchemaCreation, DBTransactionAdapter, Where };
@@ -1,3 +1,3 @@
1
1
  import "../helper-DVgWo5zB.cjs";
2
- import { 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 } from "../type-BNCR-kIK.cjs";
2
+ import { 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 } from "../index-CgIE2ECh.cjs";
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 };