@better-auth/core 1.5.0-beta.5 → 1.5.0-beta.6
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.
- package/.turbo/turbo-build.log +7 -7
- package/dist/context/endpoint-context.mjs +6 -2
- package/dist/context/index.mjs +0 -19
- package/dist/context/request-state.mjs +6 -2
- package/dist/context/transaction.mjs +6 -2
- package/package.json +1 -1
- package/src/context/endpoint-context.ts +11 -2
- package/src/context/index.ts +0 -29
- package/src/context/request-state.ts +8 -2
- package/src/context/transaction.ts +11 -2
package/.turbo/turbo-build.log
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
|
|
2
|
-
> @better-auth/core@1.5.0-beta.
|
|
2
|
+
> @better-auth/core@1.5.0-beta.6 build /home/runner/work/better-auth/better-auth/packages/core
|
|
3
3
|
> tsdown
|
|
4
4
|
|
|
5
5
|
[34mℹ[39m tsdown [2mv0.19.0[22m powered by rolldown [2mv1.0.0-beta.59[22m
|
|
@@ -8,11 +8,11 @@
|
|
|
8
8
|
[34mℹ[39m tsconfig: [34mtsconfig.json[39m
|
|
9
9
|
[34mℹ[39m Build start
|
|
10
10
|
[34mℹ[39m [2mdist/[22m[1msocial-providers/index.mjs[22m [2m 2.32 kB[22m [2m│ gzip: 0.72 kB[22m
|
|
11
|
-
[34mℹ[39m [2mdist/[22m[1mcontext/index.mjs[22m [2m 1.70 kB[22m [2m│ gzip: 0.68 kB[22m
|
|
12
11
|
[34mℹ[39m [2mdist/[22m[1mapi/index.mjs[22m [2m 1.27 kB[22m [2m│ gzip: 0.48 kB[22m
|
|
13
12
|
[34mℹ[39m [2mdist/[22m[1masync_hooks/index.mjs[22m [2m 1.03 kB[22m [2m│ gzip: 0.54 kB[22m
|
|
14
13
|
[34mℹ[39m [2mdist/[22m[1masync_hooks/pure.index.mjs[22m [2m 0.99 kB[22m [2m│ gzip: 0.49 kB[22m
|
|
15
14
|
[34mℹ[39m [2mdist/[22m[1moauth2/index.mjs[22m [2m 0.87 kB[22m [2m│ gzip: 0.27 kB[22m
|
|
15
|
+
[34mℹ[39m [2mdist/[22m[1mcontext/index.mjs[22m [2m 0.72 kB[22m [2m│ gzip: 0.22 kB[22m
|
|
16
16
|
[34mℹ[39m [2mdist/[22m[1mdb/adapter/index.mjs[22m [2m 0.71 kB[22m [2m│ gzip: 0.22 kB[22m
|
|
17
17
|
[34mℹ[39m [2mdist/[22m[1merror/index.mjs[22m [2m 0.70 kB[22m [2m│ gzip: 0.34 kB[22m
|
|
18
18
|
[34mℹ[39m [2mdist/[22m[1mutils/json.mjs[22m [2m 0.59 kB[22m [2m│ gzip: 0.35 kB[22m
|
|
@@ -68,13 +68,13 @@
|
|
|
68
68
|
[34mℹ[39m [2mdist/[22msocial-providers/vercel.mjs [2m 1.91 kB[22m [2m│ gzip: 0.74 kB[22m
|
|
69
69
|
[34mℹ[39m [2mdist/[22moauth2/create-authorization-url.mjs [2m 1.86 kB[22m [2m│ gzip: 0.73 kB[22m
|
|
70
70
|
[34mℹ[39m [2mdist/[22moauth2/client-credentials-token.mjs [2m 1.83 kB[22m [2m│ gzip: 0.77 kB[22m
|
|
71
|
-
[34mℹ[39m [2mdist/[22mcontext/request-state.mjs [2m 1.
|
|
72
|
-
[34mℹ[39m [2mdist/[22mcontext/transaction.mjs [2m 1.
|
|
71
|
+
[34mℹ[39m [2mdist/[22mcontext/request-state.mjs [2m 1.61 kB[22m [2m│ gzip: 0.60 kB[22m
|
|
72
|
+
[34mℹ[39m [2mdist/[22mcontext/transaction.mjs [2m 1.61 kB[22m [2m│ gzip: 0.57 kB[22m
|
|
73
73
|
[34mℹ[39m [2mdist/[22mdb/adapter/get-default-field-name.mjs [2m 1.41 kB[22m [2m│ gzip: 0.66 kB[22m
|
|
74
74
|
[34mℹ[39m [2mdist/[22mdb/adapter/get-default-model-name.mjs [2m 1.39 kB[22m [2m│ gzip: 0.65 kB[22m
|
|
75
|
+
[34mℹ[39m [2mdist/[22mcontext/endpoint-context.mjs [2m 1.30 kB[22m [2m│ gzip: 0.55 kB[22m
|
|
75
76
|
[34mℹ[39m [2mdist/[22mdb/adapter/get-field-attributes.mjs [2m 1.26 kB[22m [2m│ gzip: 0.46 kB[22m
|
|
76
77
|
[34mℹ[39m [2mdist/[22mdb/adapter/utils.mjs [2m 1.15 kB[22m [2m│ gzip: 0.46 kB[22m
|
|
77
|
-
[34mℹ[39m [2mdist/[22mcontext/endpoint-context.mjs [2m 1.11 kB[22m [2m│ gzip: 0.48 kB[22m
|
|
78
78
|
[34mℹ[39m [2mdist/[22mdb/adapter/get-field-name.mjs [2m 1.07 kB[22m [2m│ gzip: 0.47 kB[22m
|
|
79
79
|
[34mℹ[39m [2mdist/[22moauth2/utils.mjs [2m 0.98 kB[22m [2m│ gzip: 0.50 kB[22m
|
|
80
80
|
[34mℹ[39m [2mdist/[22mdb/adapter/get-model-name.mjs [2m 0.89 kB[22m [2m│ gzip: 0.42 kB[22m
|
|
@@ -172,5 +172,5 @@
|
|
|
172
172
|
[34mℹ[39m [2mdist/[22m[32mdb/get-tables.d.mts[39m [2m 0.29 kB[22m [2m│ gzip: 0.18 kB[22m
|
|
173
173
|
[34mℹ[39m [2mdist/[22m[32mdb/schema/shared.d.mts[39m [2m 0.25 kB[22m [2m│ gzip: 0.18 kB[22m
|
|
174
174
|
[34mℹ[39m [2mdist/[22m[32menv/color-depth.d.mts[39m [2m 0.12 kB[22m [2m│ gzip: 0.11 kB[22m
|
|
175
|
-
[34mℹ[39m 165 files, total:
|
|
176
|
-
[32m✔[39m Build complete in [
|
|
175
|
+
[34mℹ[39m 165 files, total: 442.95 kB
|
|
176
|
+
[32m✔[39m Build complete in [32m5309ms[39m
|
|
@@ -1,10 +1,14 @@
|
|
|
1
1
|
import { getAsyncLocalStorage } from "@better-auth/core/async_hooks";
|
|
2
2
|
|
|
3
3
|
//#region src/context/endpoint-context.ts
|
|
4
|
+
const symbol = Symbol.for("better-auth:endpoint-context-async-storage");
|
|
4
5
|
let currentContextAsyncStorage = null;
|
|
5
6
|
const ensureAsyncStorage = async () => {
|
|
6
|
-
if (!currentContextAsyncStorage
|
|
7
|
-
|
|
7
|
+
if (!currentContextAsyncStorage || globalThis[symbol] === void 0) {
|
|
8
|
+
currentContextAsyncStorage = new (await (getAsyncLocalStorage()))();
|
|
9
|
+
globalThis[symbol] = currentContextAsyncStorage;
|
|
10
|
+
}
|
|
11
|
+
return currentContextAsyncStorage || globalThis[symbol];
|
|
8
12
|
};
|
|
9
13
|
/**
|
|
10
14
|
* This is for internal use only. Most users should use `getCurrentAuthContext` instead.
|
package/dist/context/index.mjs
CHANGED
|
@@ -2,23 +2,4 @@ import { getCurrentAuthContext, getCurrentAuthContextAsyncLocalStorage, runWithE
|
|
|
2
2
|
import { defineRequestState, getCurrentRequestState, getRequestStateAsyncLocalStorage, hasRequestState, runWithRequestState } from "./request-state.mjs";
|
|
3
3
|
import { getCurrentAdapter, getCurrentDBAdapterAsyncLocalStorage, runWithAdapter, runWithTransaction } from "./transaction.mjs";
|
|
4
4
|
|
|
5
|
-
//#region src/context/index.ts
|
|
6
|
-
const glo = typeof globalThis !== "undefined" ? globalThis : typeof window !== "undefined" ? window : typeof global !== "undefined" ? global : {};
|
|
7
|
-
const importIdentifier = "__ $BETTER_AUTH$ __";
|
|
8
|
-
if (glo[importIdentifier] === true)
|
|
9
|
-
/**
|
|
10
|
-
* Dear reader of this message. Please take this seriously.
|
|
11
|
-
*
|
|
12
|
-
* If you see this message, make sure that you only import one version of Better Auth. In many cases,
|
|
13
|
-
* your package manager installs two versions of Better Auth that are used by different packages within your project.
|
|
14
|
-
*
|
|
15
|
-
* This often leads to issues that are hard to debug. We often need to ensure async local storage instance,
|
|
16
|
-
* If you imported different versions of Better Auth, it is impossible for us to
|
|
17
|
-
* do status synchronization per request anymore - which might break the states.
|
|
18
|
-
*
|
|
19
|
-
*/
|
|
20
|
-
console.error("Better Auth was already imported. This breaks async local storage instance and will lead to issues!");
|
|
21
|
-
glo[importIdentifier] = true;
|
|
22
|
-
|
|
23
|
-
//#endregion
|
|
24
5
|
export { defineRequestState, getCurrentAdapter, getCurrentAuthContext, getCurrentAuthContextAsyncLocalStorage, getCurrentDBAdapterAsyncLocalStorage, getCurrentRequestState, getRequestStateAsyncLocalStorage, hasRequestState, runWithAdapter, runWithEndpointContext, runWithRequestState, runWithTransaction };
|
|
@@ -1,10 +1,14 @@
|
|
|
1
1
|
import { getAsyncLocalStorage } from "@better-auth/core/async_hooks";
|
|
2
2
|
|
|
3
3
|
//#region src/context/request-state.ts
|
|
4
|
+
const symbol = Symbol.for("better-auth:request-state-async-storage");
|
|
4
5
|
let requestStateAsyncStorage = null;
|
|
5
6
|
const ensureAsyncStorage = async () => {
|
|
6
|
-
if (!requestStateAsyncStorage
|
|
7
|
-
|
|
7
|
+
if (!requestStateAsyncStorage || globalThis[symbol] === void 0) {
|
|
8
|
+
requestStateAsyncStorage = new (await (getAsyncLocalStorage()))();
|
|
9
|
+
globalThis[symbol] = requestStateAsyncStorage;
|
|
10
|
+
}
|
|
11
|
+
return requestStateAsyncStorage || globalThis[symbol];
|
|
8
12
|
};
|
|
9
13
|
async function getRequestStateAsyncLocalStorage() {
|
|
10
14
|
return ensureAsyncStorage();
|
|
@@ -1,10 +1,14 @@
|
|
|
1
1
|
import { getAsyncLocalStorage } from "@better-auth/core/async_hooks";
|
|
2
2
|
|
|
3
3
|
//#region src/context/transaction.ts
|
|
4
|
+
const symbol = Symbol.for("better-auth:transaction-adapter-async-storage");
|
|
4
5
|
let currentAdapterAsyncStorage = null;
|
|
5
6
|
const ensureAsyncStorage = async () => {
|
|
6
|
-
if (!currentAdapterAsyncStorage
|
|
7
|
-
|
|
7
|
+
if (!currentAdapterAsyncStorage || globalThis[symbol] === void 0) {
|
|
8
|
+
currentAdapterAsyncStorage = new (await (getAsyncLocalStorage()))();
|
|
9
|
+
globalThis[symbol] = currentAdapterAsyncStorage;
|
|
10
|
+
}
|
|
11
|
+
return currentAdapterAsyncStorage || globalThis[symbol];
|
|
8
12
|
};
|
|
9
13
|
/**
|
|
10
14
|
* This is for internal use only. Most users should use `getCurrentAdapter` instead.
|
package/package.json
CHANGED
|
@@ -9,15 +9,24 @@ export type AuthEndpointContext = Partial<
|
|
|
9
9
|
context: AuthContext;
|
|
10
10
|
};
|
|
11
11
|
|
|
12
|
+
const symbol = Symbol.for("better-auth:endpoint-context-async-storage");
|
|
13
|
+
|
|
12
14
|
let currentContextAsyncStorage: AsyncLocalStorage<AuthEndpointContext> | null =
|
|
13
15
|
null;
|
|
14
16
|
|
|
15
17
|
const ensureAsyncStorage = async () => {
|
|
16
|
-
if (
|
|
18
|
+
if (
|
|
19
|
+
!currentContextAsyncStorage ||
|
|
20
|
+
(globalThis as any)[symbol] === undefined
|
|
21
|
+
) {
|
|
17
22
|
const AsyncLocalStorage = await getAsyncLocalStorage();
|
|
18
23
|
currentContextAsyncStorage = new AsyncLocalStorage();
|
|
24
|
+
(globalThis as any)[symbol] = currentContextAsyncStorage;
|
|
19
25
|
}
|
|
20
|
-
return
|
|
26
|
+
return (
|
|
27
|
+
currentContextAsyncStorage ||
|
|
28
|
+
((globalThis as any)[symbol] as AsyncLocalStorage<AuthEndpointContext>)
|
|
29
|
+
);
|
|
21
30
|
};
|
|
22
31
|
|
|
23
32
|
/**
|
package/src/context/index.ts
CHANGED
|
@@ -19,32 +19,3 @@ export {
|
|
|
19
19
|
runWithAdapter,
|
|
20
20
|
runWithTransaction,
|
|
21
21
|
} from "./transaction";
|
|
22
|
-
|
|
23
|
-
const glo: any =
|
|
24
|
-
typeof globalThis !== "undefined"
|
|
25
|
-
? globalThis
|
|
26
|
-
: typeof window !== "undefined"
|
|
27
|
-
? window
|
|
28
|
-
: typeof global !== "undefined"
|
|
29
|
-
? global
|
|
30
|
-
: {};
|
|
31
|
-
|
|
32
|
-
const importIdentifier = "__ $BETTER_AUTH$ __";
|
|
33
|
-
|
|
34
|
-
if (glo[importIdentifier] === true) {
|
|
35
|
-
/**
|
|
36
|
-
* Dear reader of this message. Please take this seriously.
|
|
37
|
-
*
|
|
38
|
-
* If you see this message, make sure that you only import one version of Better Auth. In many cases,
|
|
39
|
-
* your package manager installs two versions of Better Auth that are used by different packages within your project.
|
|
40
|
-
*
|
|
41
|
-
* This often leads to issues that are hard to debug. We often need to ensure async local storage instance,
|
|
42
|
-
* If you imported different versions of Better Auth, it is impossible for us to
|
|
43
|
-
* do status synchronization per request anymore - which might break the states.
|
|
44
|
-
*
|
|
45
|
-
*/
|
|
46
|
-
console.error(
|
|
47
|
-
"Better Auth was already imported. This breaks async local storage instance and will lead to issues!",
|
|
48
|
-
);
|
|
49
|
-
}
|
|
50
|
-
glo[importIdentifier] = true;
|
|
@@ -3,15 +3,21 @@ import { getAsyncLocalStorage } from "@better-auth/core/async_hooks";
|
|
|
3
3
|
|
|
4
4
|
export type RequestStateWeakMap = WeakMap<object, any>;
|
|
5
5
|
|
|
6
|
+
const symbol = Symbol.for("better-auth:request-state-async-storage");
|
|
7
|
+
|
|
6
8
|
let requestStateAsyncStorage: AsyncLocalStorage<RequestStateWeakMap> | null =
|
|
7
9
|
null;
|
|
8
10
|
|
|
9
11
|
const ensureAsyncStorage = async () => {
|
|
10
|
-
if (!requestStateAsyncStorage) {
|
|
12
|
+
if (!requestStateAsyncStorage || (globalThis as any)[symbol] === undefined) {
|
|
11
13
|
const AsyncLocalStorage = await getAsyncLocalStorage();
|
|
12
14
|
requestStateAsyncStorage = new AsyncLocalStorage();
|
|
15
|
+
(globalThis as any)[symbol] = requestStateAsyncStorage;
|
|
13
16
|
}
|
|
14
|
-
return
|
|
17
|
+
return (
|
|
18
|
+
requestStateAsyncStorage ||
|
|
19
|
+
((globalThis as any)[symbol] as AsyncLocalStorage<RequestStateWeakMap>)
|
|
20
|
+
);
|
|
15
21
|
};
|
|
16
22
|
|
|
17
23
|
export async function getRequestStateAsyncLocalStorage() {
|
|
@@ -2,15 +2,24 @@ import type { AsyncLocalStorage } from "@better-auth/core/async_hooks";
|
|
|
2
2
|
import { getAsyncLocalStorage } from "@better-auth/core/async_hooks";
|
|
3
3
|
import type { DBAdapter, DBTransactionAdapter } from "../db/adapter";
|
|
4
4
|
|
|
5
|
+
const symbol = Symbol.for("better-auth:transaction-adapter-async-storage");
|
|
6
|
+
|
|
5
7
|
let currentAdapterAsyncStorage: AsyncLocalStorage<DBTransactionAdapter> | null =
|
|
6
8
|
null;
|
|
7
9
|
|
|
8
10
|
const ensureAsyncStorage = async () => {
|
|
9
|
-
if (
|
|
11
|
+
if (
|
|
12
|
+
!currentAdapterAsyncStorage ||
|
|
13
|
+
(globalThis as any)[symbol] === undefined
|
|
14
|
+
) {
|
|
10
15
|
const AsyncLocalStorage = await getAsyncLocalStorage();
|
|
11
16
|
currentAdapterAsyncStorage = new AsyncLocalStorage();
|
|
17
|
+
(globalThis as any)[symbol] = currentAdapterAsyncStorage;
|
|
12
18
|
}
|
|
13
|
-
return
|
|
19
|
+
return (
|
|
20
|
+
currentAdapterAsyncStorage ||
|
|
21
|
+
((globalThis as any)[symbol] as AsyncLocalStorage<DBTransactionAdapter>)
|
|
22
|
+
);
|
|
14
23
|
};
|
|
15
24
|
|
|
16
25
|
/**
|