@better-auth/core 1.3.24 → 1.3.25

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.
@@ -1,5 +1,5 @@
1
1
 
2
- > @better-auth/core@1.3.24 build /home/runner/work/better-auth/better-auth/packages/core
2
+ > @better-auth/core@1.3.25 build /home/runner/work/better-auth/better-auth/packages/core
3
3
  > unbuild --clean
4
4
 
5
5
  [info] Building core
@@ -14,9 +14,13 @@ Generated an empty chunk: "index".
14
14
  [success] Build succeeded for core
15
15
  [log] dist/index.cjs (total size: 15 B, chunk size: 15 B)
16
16
 
17
+ [log] dist/async_hooks/index.cjs (total size: 922 B, chunk size: 922 B, exports: getAsyncLocalStorage)
18
+
17
19
  [log] dist/db/index.cjs (total size: 15 B, chunk size: 15 B)
18
20
  [log] dist/index.mjs (total size: 1 B, chunk size: 1 B)
19
21
 
22
+ [log] dist/async_hooks/index.mjs (total size: 887 B, chunk size: 887 B, exports: getAsyncLocalStorage)
23
+
20
24
  [log] dist/db/index.mjs (total size: 1 B, chunk size: 1 B)
21
- Σ Total dist size (byte size): 11.1 kB
25
+ Σ Total dist size (byte size): 13.8 kB
22
26
  [log]
package/build.config.ts CHANGED
@@ -8,5 +8,9 @@ export default defineBuildConfig({
8
8
  outDir: "dist",
9
9
  clean: true,
10
10
  failOnWarn: false,
11
- entries: ["./src/index.ts", "./src/db/index.ts"],
11
+ entries: [
12
+ "./src/index.ts",
13
+ "./src/db/index.ts",
14
+ "./src/async_hooks/index.ts",
15
+ ],
12
16
  });
@@ -0,0 +1,27 @@
1
+ 'use strict';
2
+
3
+ let moduleName = "node:async_hooks";
4
+ const AsyncLocalStoragePromise = import(
5
+ /* @vite-ignore */
6
+ /* webpackIgnore: true */
7
+ moduleName
8
+ ).then((mod) => mod.AsyncLocalStorage).catch((err) => {
9
+ if ("AsyncLocalStorage" in globalThis) {
10
+ return globalThis.AsyncLocalStorage;
11
+ }
12
+ console.warn(
13
+ "[better-auth] Warning: AsyncLocalStorage is not available in this environment. Some features may not work as expected."
14
+ );
15
+ console.warn(
16
+ "[better-auth] Please read more about this warning at https://better-auth.com/docs/installation#mount-handler"
17
+ );
18
+ console.warn(
19
+ "[better-auth] If you are using Cloudflare Workers, please see: https://developers.cloudflare.com/workers/configuration/compatibility-flags/#nodejs-compatibility-flag"
20
+ );
21
+ throw err;
22
+ });
23
+ async function getAsyncLocalStorage() {
24
+ return AsyncLocalStoragePromise;
25
+ }
26
+
27
+ exports.getAsyncLocalStorage = getAsyncLocalStorage;
@@ -0,0 +1,10 @@
1
+ import { AsyncLocalStorage } from 'node:async_hooks';
2
+ export { AsyncLocalStorage } from 'node:async_hooks';
3
+
4
+ /**
5
+ * AsyncLocalStorage will be import directly in 1.5.x
6
+ */
7
+
8
+ declare function getAsyncLocalStorage(): Promise<typeof AsyncLocalStorage>;
9
+
10
+ export { getAsyncLocalStorage };
@@ -0,0 +1,10 @@
1
+ import { AsyncLocalStorage } from 'node:async_hooks';
2
+ export { AsyncLocalStorage } from 'node:async_hooks';
3
+
4
+ /**
5
+ * AsyncLocalStorage will be import directly in 1.5.x
6
+ */
7
+
8
+ declare function getAsyncLocalStorage(): Promise<typeof AsyncLocalStorage>;
9
+
10
+ export { getAsyncLocalStorage };
@@ -0,0 +1,10 @@
1
+ import { AsyncLocalStorage } from 'node:async_hooks';
2
+ export { AsyncLocalStorage } from 'node:async_hooks';
3
+
4
+ /**
5
+ * AsyncLocalStorage will be import directly in 1.5.x
6
+ */
7
+
8
+ declare function getAsyncLocalStorage(): Promise<typeof AsyncLocalStorage>;
9
+
10
+ export { getAsyncLocalStorage };
@@ -0,0 +1,25 @@
1
+ let moduleName = "node:async_hooks";
2
+ const AsyncLocalStoragePromise = import(
3
+ /* @vite-ignore */
4
+ /* webpackIgnore: true */
5
+ moduleName
6
+ ).then((mod) => mod.AsyncLocalStorage).catch((err) => {
7
+ if ("AsyncLocalStorage" in globalThis) {
8
+ return globalThis.AsyncLocalStorage;
9
+ }
10
+ console.warn(
11
+ "[better-auth] Warning: AsyncLocalStorage is not available in this environment. Some features may not work as expected."
12
+ );
13
+ console.warn(
14
+ "[better-auth] Please read more about this warning at https://better-auth.com/docs/installation#mount-handler"
15
+ );
16
+ console.warn(
17
+ "[better-auth] If you are using Cloudflare Workers, please see: https://developers.cloudflare.com/workers/configuration/compatibility-flags/#nodejs-compatibility-flag"
18
+ );
19
+ throw err;
20
+ });
21
+ async function getAsyncLocalStorage() {
22
+ return AsyncLocalStoragePromise;
23
+ }
24
+
25
+ export { getAsyncLocalStorage };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@better-auth/core",
3
- "version": "1.3.24",
3
+ "version": "1.3.25",
4
4
  "description": "The most comprehensive authentication library for TypeScript.",
5
5
  "type": "module",
6
6
  "main": "./dist/index.cjs",
@@ -16,6 +16,16 @@
16
16
  "default": "./dist/index.cjs"
17
17
  }
18
18
  },
19
+ "./async_hooks": {
20
+ "import": {
21
+ "types": "./dist/async_hooks/index.d.ts",
22
+ "default": "./dist/async_hooks/index.mjs"
23
+ },
24
+ "require": {
25
+ "types": "./dist/async_hooks/index.d.cts",
26
+ "default": "./dist/async_hooks/index.cjs"
27
+ }
28
+ },
19
29
  "./db": {
20
30
  "import": {
21
31
  "types": "./dist/db/index.d.ts",
@@ -32,6 +42,9 @@
32
42
  "index": [
33
43
  "dist/index.d.ts"
34
44
  ],
45
+ "async_hooks": [
46
+ "dist/async_hooks.d.ts"
47
+ ],
35
48
  "db": [
36
49
  "dist/db.d.ts"
37
50
  ]
@@ -0,0 +1,43 @@
1
+ /**
2
+ * AsyncLocalStorage will be import directly in 1.5.x
3
+ */
4
+ import type { AsyncLocalStorage } from "node:async_hooks";
5
+
6
+ // We only export the type here to avoid issues in environments where AsyncLocalStorage is not available.
7
+ export type { AsyncLocalStorage };
8
+
9
+ /**
10
+ * Dynamically import AsyncLocalStorage to avoid issues in environments where it's not available.
11
+ *
12
+ * Right now, this is primarily for Cloudflare Workers.
13
+ *
14
+ */
15
+ let moduleName: string = "node:async_hooks";
16
+
17
+ const AsyncLocalStoragePromise: Promise<typeof AsyncLocalStorage> = import(
18
+ /* @vite-ignore */
19
+ /* webpackIgnore: true */
20
+ moduleName
21
+ )
22
+ .then((mod) => mod.AsyncLocalStorage)
23
+ .catch((err) => {
24
+ if ("AsyncLocalStorage" in globalThis) {
25
+ return (globalThis as any).AsyncLocalStorage;
26
+ }
27
+ console.warn(
28
+ "[better-auth] Warning: AsyncLocalStorage is not available in this environment. Some features may not work as expected.",
29
+ );
30
+ console.warn(
31
+ "[better-auth] Please read more about this warning at https://better-auth.com/docs/installation#mount-handler",
32
+ );
33
+ console.warn(
34
+ "[better-auth] If you are using Cloudflare Workers, please see: https://developers.cloudflare.com/workers/configuration/compatibility-flags/#nodejs-compatibility-flag",
35
+ );
36
+ throw err;
37
+ });
38
+
39
+ export async function getAsyncLocalStorage(): Promise<
40
+ typeof AsyncLocalStorage
41
+ > {
42
+ return AsyncLocalStoragePromise;
43
+ }
package/tsconfig.json CHANGED
@@ -4,7 +4,7 @@
4
4
  "rootDir": "./src",
5
5
  "outDir": "./dist",
6
6
  "lib": ["esnext", "dom", "dom.iterable"],
7
- "types": []
7
+ "types": ["node"]
8
8
  },
9
9
  "include": ["src"]
10
10
  }