@better-auth/core 1.4.11 → 1.4.12-beta.2
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/api/index.d.mts +1 -1
- package/dist/api/index.mjs +1 -1
- package/dist/context/index.d.mts +1 -1
- package/dist/context/index.mjs +1 -1
- package/dist/{context-BBNwughv.mjs → context-BGZ8V6DD.mjs} +18 -25
- package/dist/db/adapter/index.d.mts +1 -1
- package/dist/db/index.d.mts +1 -1
- package/dist/{index-BHaoMSKV.d.mts → index-zgYuzZ7O.d.mts} +6 -0
- package/dist/index.d.mts +1 -1
- package/dist/oauth2/index.d.mts +1 -1
- package/dist/oauth2/index.mjs +1 -1
- package/dist/{oauth2-BjWM15hm.mjs → oauth2-COJkghlT.mjs} +1 -1
- package/dist/social-providers/index.d.mts +1 -1
- package/dist/social-providers/index.mjs +1 -1
- 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/src/oauth2/create-authorization-url.ts +1 -1
- package/src/oauth2/oauth-provider.ts +6 -0
package/.turbo/turbo-build.log
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
|
|
2
|
-
> @better-auth/core@1.4.
|
|
2
|
+
> @better-auth/core@1.4.12-beta.2 build /home/runner/work/better-auth/better-auth/packages/core
|
|
3
3
|
> tsdown
|
|
4
4
|
|
|
5
5
|
[34mℹ[39m tsdown [2mv0.17.2[22m powered by rolldown [2mv1.0.0-beta.53[22m
|
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
[34mℹ[39m [2mdist/[22m[1msocial-providers/index.mjs[22m [2m 80.96 kB[22m [2m│ gzip: 10.43 kB[22m
|
|
11
11
|
[34mℹ[39m [2mdist/[22m[1mdb/adapter/index.mjs[22m [2m 38.55 kB[22m [2m│ gzip: 7.86 kB[22m
|
|
12
12
|
[34mℹ[39m [2mdist/[22m[1mdb/index.mjs[22m [2m 1.66 kB[22m [2m│ gzip: 0.54 kB[22m
|
|
13
|
-
[34mℹ[39m [2mdist/[22m[1mapi/index.mjs[22m [2m 1.23 kB[22m [2m│ gzip: 0.
|
|
13
|
+
[34mℹ[39m [2mdist/[22m[1mapi/index.mjs[22m [2m 1.23 kB[22m [2m│ gzip: 0.49 kB[22m
|
|
14
14
|
[34mℹ[39m [2mdist/[22m[1masync_hooks/index.mjs[22m [2m 1.03 kB[22m [2m│ gzip: 0.54 kB[22m
|
|
15
15
|
[34mℹ[39m [2mdist/[22m[1masync_hooks/pure.index.mjs[22m [2m 0.99 kB[22m [2m│ gzip: 0.49 kB[22m
|
|
16
16
|
[34mℹ[39m [2mdist/[22m[1moauth2/index.mjs[22m [2m 0.75 kB[22m [2m│ gzip: 0.28 kB[22m
|
|
@@ -19,10 +19,10 @@
|
|
|
19
19
|
[34mℹ[39m [2mdist/[22m[1mutils/index.mjs[22m [2m 0.26 kB[22m [2m│ gzip: 0.18 kB[22m
|
|
20
20
|
[34mℹ[39m [2mdist/[22m[1merror/index.mjs[22m [2m 0.19 kB[22m [2m│ gzip: 0.14 kB[22m
|
|
21
21
|
[34mℹ[39m [2mdist/[22m[1mindex.mjs[22m [2m 0.01 kB[22m [2m│ gzip: 0.03 kB[22m
|
|
22
|
-
[34mℹ[39m [2mdist/[22moauth2-
|
|
22
|
+
[34mℹ[39m [2mdist/[22moauth2-COJkghlT.mjs [2m 12.86 kB[22m [2m│ gzip: 3.16 kB[22m
|
|
23
23
|
[34mℹ[39m [2mdist/[22menv-DbssmzoK.mjs [2m 7.67 kB[22m [2m│ gzip: 2.54 kB[22m
|
|
24
24
|
[34mℹ[39m [2mdist/[22mget-tables-CMc_Emww.mjs [2m 6.76 kB[22m [2m│ gzip: 1.30 kB[22m
|
|
25
|
-
[34mℹ[39m [2mdist/[22mcontext-
|
|
25
|
+
[34mℹ[39m [2mdist/[22mcontext-BGZ8V6DD.mjs [2m 4.46 kB[22m [2m│ gzip: 1.10 kB[22m
|
|
26
26
|
[34mℹ[39m [2mdist/[22merror-DP1xOn7P.mjs [2m 2.76 kB[22m [2m│ gzip: 1.16 kB[22m
|
|
27
27
|
[34mℹ[39m [2mdist/[22mutils-U2L7n92V.mjs [2m 1.46 kB[22m [2m│ gzip: 0.70 kB[22m
|
|
28
28
|
[34mℹ[39m [2mdist/[22m[32m[1msocial-providers/index.d.mts[22m[39m [2m 3.89 kB[22m [2m│ gzip: 1.19 kB[22m
|
|
@@ -37,7 +37,7 @@
|
|
|
37
37
|
[34mℹ[39m [2mdist/[22m[32m[1mapi/index.d.mts[22m[39m [2m 0.26 kB[22m [2m│ gzip: 0.14 kB[22m
|
|
38
38
|
[34mℹ[39m [2mdist/[22m[32m[1masync_hooks/index.d.mts[22m[39m [2m 0.24 kB[22m [2m│ gzip: 0.16 kB[22m
|
|
39
39
|
[34mℹ[39m [2mdist/[22m[32m[1masync_hooks/pure.index.d.mts[22m[39m [2m 0.22 kB[22m [2m│ gzip: 0.16 kB[22m
|
|
40
|
-
[34mℹ[39m [2mdist/[22m[32mindex-
|
|
40
|
+
[34mℹ[39m [2mdist/[22m[32mindex-zgYuzZ7O.d.mts[39m [2m227.98 kB[22m [2m│ gzip: 36.00 kB[22m
|
|
41
41
|
[34mℹ[39m [2mdist/[22m[32mindex-BRBu0-5h.d.mts[39m [2m 3.31 kB[22m [2m│ gzip: 1.11 kB[22m
|
|
42
|
-
[34mℹ[39m 32 files, total: 410.
|
|
43
|
-
[32m✔[39m Build complete in [
|
|
42
|
+
[34mℹ[39m 32 files, total: 410.77 kB
|
|
43
|
+
[32m✔[39m Build complete in [32m5142ms[39m
|
package/dist/api/index.d.mts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { a as optionsMiddleware, i as createAuthMiddleware, n as AuthMiddleware, r as createAuthEndpoint, t as AuthEndpoint } from "../index-
|
|
1
|
+
import { a as optionsMiddleware, i as createAuthMiddleware, n as AuthMiddleware, r as createAuthEndpoint, t as AuthEndpoint } from "../index-zgYuzZ7O.mjs";
|
|
2
2
|
export { AuthEndpoint, AuthMiddleware, createAuthEndpoint, createAuthMiddleware, optionsMiddleware };
|
package/dist/api/index.mjs
CHANGED
package/dist/context/index.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Xn as DBAdapter, f as AuthContext, tr as DBTransactionAdapter } from "../index-
|
|
1
|
+
import { Xn as DBAdapter, f as AuthContext, tr as DBTransactionAdapter } from "../index-zgYuzZ7O.mjs";
|
|
2
2
|
import { AsyncLocalStorage } from "@better-auth/core/async_hooks";
|
|
3
3
|
import { EndpointContext, InputContext } from "better-call";
|
|
4
4
|
|
package/dist/context/index.mjs
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
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-
|
|
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";
|
|
2
2
|
|
|
3
3
|
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/endpoint-context.ts
|
|
4
|
+
const symbol$2 = Symbol.for("better-auth:endpoint-context-async-storage");
|
|
4
5
|
let currentContextAsyncStorage = null;
|
|
5
6
|
const ensureAsyncStorage$2 = async () => {
|
|
6
|
-
if (!currentContextAsyncStorage
|
|
7
|
-
|
|
7
|
+
if (!currentContextAsyncStorage || globalThis[symbol$2] === void 0) {
|
|
8
|
+
currentContextAsyncStorage = new (await (getAsyncLocalStorage()))();
|
|
9
|
+
globalThis[symbol$2] = currentContextAsyncStorage;
|
|
10
|
+
}
|
|
11
|
+
return currentContextAsyncStorage || globalThis[symbol$2];
|
|
8
12
|
};
|
|
9
13
|
/**
|
|
10
14
|
* This is for internal use only. Most users should use `getCurrentAuthContext` instead.
|
|
@@ -25,10 +29,14 @@ async function runWithEndpointContext(context, fn) {
|
|
|
25
29
|
|
|
26
30
|
//#endregion
|
|
27
31
|
//#region src/context/request-state.ts
|
|
32
|
+
const symbol$1 = Symbol.for("better-auth:request-state-async-storage");
|
|
28
33
|
let requestStateAsyncStorage = null;
|
|
29
34
|
const ensureAsyncStorage$1 = async () => {
|
|
30
|
-
if (!requestStateAsyncStorage
|
|
31
|
-
|
|
35
|
+
if (!requestStateAsyncStorage || globalThis[symbol$1] === void 0) {
|
|
36
|
+
requestStateAsyncStorage = new (await (getAsyncLocalStorage()))();
|
|
37
|
+
globalThis[symbol$1] = requestStateAsyncStorage;
|
|
38
|
+
}
|
|
39
|
+
return requestStateAsyncStorage || globalThis[symbol$1];
|
|
32
40
|
};
|
|
33
41
|
async function getRequestStateAsyncLocalStorage() {
|
|
34
42
|
return ensureAsyncStorage$1();
|
|
@@ -67,10 +75,14 @@ function defineRequestState(initFn) {
|
|
|
67
75
|
|
|
68
76
|
//#endregion
|
|
69
77
|
//#region src/context/transaction.ts
|
|
78
|
+
const symbol = Symbol.for("better-auth:transaction-adapter-async-storage");
|
|
70
79
|
let currentAdapterAsyncStorage = null;
|
|
71
80
|
const ensureAsyncStorage = async () => {
|
|
72
|
-
if (!currentAdapterAsyncStorage
|
|
73
|
-
|
|
81
|
+
if (!currentAdapterAsyncStorage || globalThis[symbol] === void 0) {
|
|
82
|
+
currentAdapterAsyncStorage = new (await (getAsyncLocalStorage()))();
|
|
83
|
+
globalThis[symbol] = currentAdapterAsyncStorage;
|
|
84
|
+
}
|
|
85
|
+
return currentAdapterAsyncStorage || globalThis[symbol];
|
|
74
86
|
};
|
|
75
87
|
/**
|
|
76
88
|
* This is for internal use only. Most users should use `getCurrentAdapter` instead.
|
|
@@ -110,24 +122,5 @@ const runWithTransaction = async (adapter, fn) => {
|
|
|
110
122
|
});
|
|
111
123
|
};
|
|
112
124
|
|
|
113
|
-
//#endregion
|
|
114
|
-
//#region src/context/index.ts
|
|
115
|
-
const glo = typeof globalThis !== "undefined" ? globalThis : typeof window !== "undefined" ? window : typeof global !== "undefined" ? global : {};
|
|
116
|
-
const importIdentifier = "__ $BETTER_AUTH$ __";
|
|
117
|
-
if (glo[importIdentifier] === true)
|
|
118
|
-
/**
|
|
119
|
-
* Dear reader of this message. Please take this seriously.
|
|
120
|
-
*
|
|
121
|
-
* If you see this message, make sure that you only import one version of Better Auth. In many cases,
|
|
122
|
-
* your package manager installs two versions of Better Auth that are used by different packages within your project.
|
|
123
|
-
*
|
|
124
|
-
* This often leads to issues that are hard to debug. We often need to ensure async local storage instance,
|
|
125
|
-
* If you imported different versions of Better Auth, it is impossible for us to
|
|
126
|
-
* do status synchronization per request anymore - which might break the states.
|
|
127
|
-
*
|
|
128
|
-
*/
|
|
129
|
-
console.error("Better Auth was already imported. This breaks async local storage instance and will lead to issues!");
|
|
130
|
-
glo[importIdentifier] = true;
|
|
131
|
-
|
|
132
125
|
//#endregion
|
|
133
126
|
export { defineRequestState as a, hasRequestState as c, getCurrentAuthContextAsyncLocalStorage as d, runWithEndpointContext as f, runWithTransaction as i, runWithRequestState as l, getCurrentDBAdapterAsyncLocalStorage as n, getCurrentRequestState as o, runWithAdapter as r, getRequestStateAsyncLocalStorage as s, getCurrentAdapter as t, getCurrentAuthContext as u };
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { $n as DBAdapterInstance, Cr as initGetIdField, Dr as initGetDefaultFieldName, Er as initGetDefaultModelName, Jn as CleanedWhere, Qn as DBAdapterFactoryConfig, Sr as initGetModelName, Tr as initGetFieldAttributes, Xn as DBAdapter, Yn as CustomAdapter, Zn as DBAdapterDebugLogOption, ar as deepmerge, cr as createAdapter, dr as AdapterFactoryConfig, er as DBAdapterSchemaCreation, fr as AdapterFactoryCustomizeAdapterCreator, gr as CreateCustomAdapter, hr as CreateAdapterOptions, ir as Where, lr as createAdapterFactory, mr as AdapterTestDebugLogs, nr as JoinConfig, or as withApplyDefault, pr as AdapterFactoryOptions, rr as JoinOption, sr as AdapterFactory, tr as DBTransactionAdapter, ur as AdapterConfig, wr as initGetFieldName } from "../../index-
|
|
1
|
+
import { $n as DBAdapterInstance, Cr as initGetIdField, Dr as initGetDefaultFieldName, Er as initGetDefaultModelName, Jn as CleanedWhere, Qn as DBAdapterFactoryConfig, Sr as initGetModelName, Tr as initGetFieldAttributes, Xn as DBAdapter, Yn as CustomAdapter, Zn as DBAdapterDebugLogOption, ar as deepmerge, cr as createAdapter, dr as AdapterFactoryConfig, er as DBAdapterSchemaCreation, fr as AdapterFactoryCustomizeAdapterCreator, gr as CreateCustomAdapter, hr as CreateAdapterOptions, ir as Where, lr as createAdapterFactory, mr as AdapterTestDebugLogs, nr as JoinConfig, or as withApplyDefault, pr as AdapterFactoryOptions, rr as JoinOption, sr as AdapterFactory, tr as DBTransactionAdapter, ur as AdapterConfig, wr as initGetFieldName } from "../../index-zgYuzZ7O.mjs";
|
|
2
2
|
export { AdapterConfig, AdapterFactory, AdapterFactoryConfig, AdapterFactoryCustomizeAdapterCreator, AdapterFactoryOptions, AdapterTestDebugLogs, CleanedWhere, CreateAdapterOptions, CreateCustomAdapter, CustomAdapter, DBAdapter, DBAdapterDebugLogOption, DBAdapterFactoryConfig, DBAdapterInstance, DBAdapterSchemaCreation, DBTransactionAdapter, JoinConfig, JoinOption, Where, createAdapter, createAdapterFactory, deepmerge, initGetDefaultFieldName, initGetDefaultModelName, initGetFieldAttributes, initGetFieldName, initGetIdField, initGetModelName, withApplyDefault };
|
package/dist/db/index.d.mts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { Ar as User, Br as getAuthTables, Fr as RateLimit, Gr as DBFieldType, Hr as BetterAuthDBSchema, Ir as rateLimitSchema, Jr as SecondaryStorage, Kr as DBPrimitive, Lr as Account, Mr as coreSchema, Nr as Session, Or as Verification, Pr as sessionSchema, Rr as accountSchema, Ur as DBFieldAttribute, Vr as BaseModelNames, Wr as DBFieldAttributeConfig, jr as userSchema, kr as verificationSchema, qr as ModelNames, zr as BetterAuthPluginDBSchema } from "../index-
|
|
1
|
+
import { Ar as User, Br as getAuthTables, Fr as RateLimit, Gr as DBFieldType, Hr as BetterAuthDBSchema, Ir as rateLimitSchema, Jr as SecondaryStorage, Kr as DBPrimitive, Lr as Account, Mr as coreSchema, Nr as Session, Or as Verification, Pr as sessionSchema, Rr as accountSchema, Ur as DBFieldAttribute, Vr as BaseModelNames, Wr as DBFieldAttributeConfig, jr as userSchema, kr as verificationSchema, qr as ModelNames, zr as BetterAuthPluginDBSchema } from "../index-zgYuzZ7O.mjs";
|
|
2
2
|
export { Account, BaseModelNames, BetterAuthDBSchema, BetterAuthPluginDBSchema, DBFieldAttribute, DBFieldAttributeConfig, DBFieldType, DBPrimitive, ModelNames, RateLimit, SecondaryStorage, Session, User, Verification, accountSchema, coreSchema, getAuthTables, rateLimitSchema, sessionSchema, userSchema, verificationSchema };
|
|
@@ -1121,6 +1121,12 @@ type ProviderOptions<Profile$1 extends Record<string, any> = any> = {
|
|
|
1121
1121
|
* whitelisted in the provider's dashboard.
|
|
1122
1122
|
*/
|
|
1123
1123
|
redirectURI?: string | undefined;
|
|
1124
|
+
/**
|
|
1125
|
+
* Custom authorization endpoint URL.
|
|
1126
|
+
* Use this to override the default authorization endpoint of the provider.
|
|
1127
|
+
* Useful for testing with local OAuth servers or using sandbox environments.
|
|
1128
|
+
*/
|
|
1129
|
+
authorizationEndpoint?: string | undefined;
|
|
1124
1130
|
/**
|
|
1125
1131
|
* The client key of your application
|
|
1126
1132
|
* Tiktok Social Provider uses this field instead of clientId
|
package/dist/index.d.mts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { An as BetterAuthCookies, _ as BetterAuthOptions, _r as Awaitable, b as BetterAuthPlugin, br as Prettify, c as BetterAuthClientPlugin, d as ClientStore, f as AuthContext, g as BetterAuthAdvancedOptions, h as PluginContext, l as ClientAtomListener, m as InternalAdapter, o as StandardSchemaV1, p as GenericEndpointContext, s as BetterAuthClientOptions, u as ClientFetchOption, v as BetterAuthRateLimitOptions, vr as LiteralString, x as HookEndpointContext, xr as Primitive, y as GenerateIdFn, yr as LiteralUnion } from "./index-
|
|
1
|
+
import { An as BetterAuthCookies, _ as BetterAuthOptions, _r as Awaitable, b as BetterAuthPlugin, br as Prettify, c as BetterAuthClientPlugin, d as ClientStore, f as AuthContext, g as BetterAuthAdvancedOptions, h as PluginContext, l as ClientAtomListener, m as InternalAdapter, o as StandardSchemaV1, p as GenericEndpointContext, s as BetterAuthClientOptions, u as ClientFetchOption, v as BetterAuthRateLimitOptions, vr as LiteralString, x as HookEndpointContext, xr as Primitive, y as GenerateIdFn, yr as LiteralUnion } from "./index-zgYuzZ7O.mjs";
|
|
2
2
|
export { AuthContext, Awaitable, BetterAuthAdvancedOptions, BetterAuthClientOptions, BetterAuthClientPlugin, BetterAuthCookies, BetterAuthOptions, BetterAuthPlugin, BetterAuthRateLimitOptions, ClientAtomListener, ClientFetchOption, ClientStore, GenerateIdFn, GenericEndpointContext, HookEndpointContext, InternalAdapter, LiteralString, LiteralUnion, PluginContext, Prettify, Primitive, StandardSchemaV1 };
|
package/dist/oauth2/index.d.mts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { Bn as refreshAccessToken, Fn as validateAuthorizationCode, Gn as OAuth2UserInfo, Hn as clientCredentialsToken, In as validateToken, Kn as OAuthProvider, Ln as generateCodeChallenge, Mn as verifyAccessToken, Nn as verifyJwsAccessToken, Pn as createAuthorizationCodeRequest, Rn as getOAuth2Tokens, Un as createClientCredentialsTokenRequest, Vn as createAuthorizationURL, Wn as OAuth2Tokens, jn as getJwks, qn as ProviderOptions, zn as createRefreshAccessTokenRequest } from "../index-
|
|
1
|
+
import { Bn as refreshAccessToken, Fn as validateAuthorizationCode, Gn as OAuth2UserInfo, Hn as clientCredentialsToken, In as validateToken, Kn as OAuthProvider, Ln as generateCodeChallenge, Mn as verifyAccessToken, Nn as verifyJwsAccessToken, Pn as createAuthorizationCodeRequest, Rn as getOAuth2Tokens, Un as createClientCredentialsTokenRequest, Vn as createAuthorizationURL, Wn as OAuth2Tokens, jn as getJwks, qn as ProviderOptions, zn as createRefreshAccessTokenRequest } from "../index-zgYuzZ7O.mjs";
|
|
2
2
|
export { OAuth2Tokens, OAuth2UserInfo, OAuthProvider, ProviderOptions, clientCredentialsToken, createAuthorizationCodeRequest, createAuthorizationURL, createClientCredentialsTokenRequest, createRefreshAccessTokenRequest, generateCodeChallenge, getJwks, getOAuth2Tokens, refreshAccessToken, validateAuthorizationCode, validateToken, verifyAccessToken, verifyJwsAccessToken };
|
package/dist/oauth2/index.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import "../env-DbssmzoK.mjs";
|
|
2
|
-
import { a as validateAuthorizationCode, c as refreshAccessToken, d as getOAuth2Tokens, f as clientCredentialsToken, i as createAuthorizationCodeRequest, l as createAuthorizationURL, n as verifyAccessToken, o as validateToken, p as createClientCredentialsTokenRequest, r as verifyJwsAccessToken, s as createRefreshAccessTokenRequest, t as getJwks, u as generateCodeChallenge } from "../oauth2-
|
|
2
|
+
import { a as validateAuthorizationCode, c as refreshAccessToken, d as getOAuth2Tokens, f as clientCredentialsToken, i as createAuthorizationCodeRequest, l as createAuthorizationURL, n as verifyAccessToken, o as validateToken, p as createClientCredentialsTokenRequest, r as verifyJwsAccessToken, s as createRefreshAccessTokenRequest, t as getJwks, u as generateCodeChallenge } from "../oauth2-COJkghlT.mjs";
|
|
3
3
|
|
|
4
4
|
export { clientCredentialsToken, createAuthorizationCodeRequest, createAuthorizationURL, createClientCredentialsTokenRequest, createRefreshAccessTokenRequest, generateCodeChallenge, getJwks, getOAuth2Tokens, refreshAccessToken, validateAuthorizationCode, validateToken, verifyAccessToken, verifyJwsAccessToken };
|
|
@@ -80,7 +80,7 @@ async function generateCodeChallenge(codeVerifier) {
|
|
|
80
80
|
//#endregion
|
|
81
81
|
//#region src/oauth2/create-authorization-url.ts
|
|
82
82
|
async function createAuthorizationURL({ id, options, authorizationEndpoint, state, codeVerifier, scopes, claims, redirectURI, duration, prompt, accessType, responseType, display, loginHint, hd, responseMode, additionalParams, scopeJoiner }) {
|
|
83
|
-
const url = new URL(authorizationEndpoint);
|
|
83
|
+
const url = new URL(options.authorizationEndpoint || authorizationEndpoint);
|
|
84
84
|
url.searchParams.set("response_type", responseType || "code");
|
|
85
85
|
const primaryClientId = Array.isArray(options.clientId) ? options.clientId[0] : options.clientId;
|
|
86
86
|
url.searchParams.set("client_id", primaryClientId);
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { $ as notion, $t as GoogleOptions, A as vercel, At as LinearUser, B as paybin, Bt as twitter, C as SocialProviderList, Cn as AtlassianProfile, Ct as GitlabProfile, D as socialProviders, Dn as AppleProfile, Dt as linkedin, E as socialProviderList, En as AppleOptions, Et as LinkedInProfile, F as PayPalProfile, Ft as DropboxOptions, G as NaverOptions, Gt as SpotifyProfile, H as LineOptions, Ht as TwitchProfile, I as PayPalTokenResponse, It as DropboxProfile, J as KakaoOptions, Jt as SlackProfile, K as NaverProfile, Kt as spotify, L as paypal, Lt as dropbox, M as PolarProfile, Mt as KickOptions, N as polar, Nt as KickProfile, O as VercelOptions, On as apple, Ot as LinearOptions, P as PayPalOptions, Pt as kick, Q as NotionProfile, Qt as huggingface, R as PaybinOptions, Rt as TwitterOption, S as SocialProvider, Sn as AtlassianOptions, St as GitlabOptions, T as SocialProviders, Tn as AppleNonConformUser, Tt as LinkedInOptions, U as LineUserInfo, Ut as twitch, V as LineIdTokenPayload, Vt as TwitchOptions, W as line, Wt as SpotifyOptions, X as kakao, Xt as HuggingFaceOptions, Y as KakaoProfile, Yt as slack, Z as NotionOptions, Zt as HuggingFaceProfile, _n as discord, _t as RedditProfile, an as microsoft, at as ZoomProfile, bn as cognito, bt as TiktokProfile, cn as github, ct as VkProfile, dn as figma, dt as SalesforceProfile, en as GoogleProfile, et as AccountStatus, fn as FacebookOptions, ft as salesforce, gn as DiscordProfile, gt as RedditOptions, hn as DiscordOptions, ht as roblox, in as MicrosoftOptions, it as ZoomOptions, j as PolarOptions, jt as linear, k as VercelProfile, kn as getApplePublicKey, kt as LinearProfile, ln as FigmaOptions, lt as vk, mn as facebook, mt as RobloxProfile, nn as google, nt as PhoneNumber, on as GithubOptions, ot as zoom, pn as FacebookProfile, pt as RobloxOptions, q as naver, qt as SlackOptions, rn as MicrosoftEntraIDProfile, rt as PronounOption, sn as GithubProfile, st as VkOption, tn as getGooglePublicKey, tt as LoginType, un as FigmaProfile, ut as SalesforceOptions, vn as CognitoOptions, vt as reddit, w as SocialProviderListEnum, wn as atlassian, wt as gitlab, xn as getCognitoPublicKey, xt as tiktok, yn as CognitoProfile, yt as TiktokOptions, z as PaybinProfile, zt as TwitterProfile } from "../index-
|
|
1
|
+
import { $ as notion, $t as GoogleOptions, A as vercel, At as LinearUser, B as paybin, Bt as twitter, C as SocialProviderList, Cn as AtlassianProfile, Ct as GitlabProfile, D as socialProviders, Dn as AppleProfile, Dt as linkedin, E as socialProviderList, En as AppleOptions, Et as LinkedInProfile, F as PayPalProfile, Ft as DropboxOptions, G as NaverOptions, Gt as SpotifyProfile, H as LineOptions, Ht as TwitchProfile, I as PayPalTokenResponse, It as DropboxProfile, J as KakaoOptions, Jt as SlackProfile, K as NaverProfile, Kt as spotify, L as paypal, Lt as dropbox, M as PolarProfile, Mt as KickOptions, N as polar, Nt as KickProfile, O as VercelOptions, On as apple, Ot as LinearOptions, P as PayPalOptions, Pt as kick, Q as NotionProfile, Qt as huggingface, R as PaybinOptions, Rt as TwitterOption, S as SocialProvider, Sn as AtlassianOptions, St as GitlabOptions, T as SocialProviders, Tn as AppleNonConformUser, Tt as LinkedInOptions, U as LineUserInfo, Ut as twitch, V as LineIdTokenPayload, Vt as TwitchOptions, W as line, Wt as SpotifyOptions, X as kakao, Xt as HuggingFaceOptions, Y as KakaoProfile, Yt as slack, Z as NotionOptions, Zt as HuggingFaceProfile, _n as discord, _t as RedditProfile, an as microsoft, at as ZoomProfile, bn as cognito, bt as TiktokProfile, cn as github, ct as VkProfile, dn as figma, dt as SalesforceProfile, en as GoogleProfile, et as AccountStatus, fn as FacebookOptions, ft as salesforce, gn as DiscordProfile, gt as RedditOptions, hn as DiscordOptions, ht as roblox, in as MicrosoftOptions, it as ZoomOptions, j as PolarOptions, jt as linear, k as VercelProfile, kn as getApplePublicKey, kt as LinearProfile, ln as FigmaOptions, lt as vk, mn as facebook, mt as RobloxProfile, nn as google, nt as PhoneNumber, on as GithubOptions, ot as zoom, pn as FacebookProfile, pt as RobloxOptions, q as naver, qt as SlackOptions, rn as MicrosoftEntraIDProfile, rt as PronounOption, sn as GithubProfile, st as VkOption, tn as getGooglePublicKey, tt as LoginType, un as FigmaProfile, ut as SalesforceOptions, vn as CognitoOptions, vt as reddit, w as SocialProviderListEnum, wn as atlassian, wt as gitlab, xn as getCognitoPublicKey, xt as tiktok, yn as CognitoProfile, yt as TiktokOptions, z as PaybinProfile, zt as TwitterProfile } from "../index-zgYuzZ7O.mjs";
|
|
2
2
|
export { AccountStatus, AppleNonConformUser, AppleOptions, AppleProfile, AtlassianOptions, AtlassianProfile, CognitoOptions, CognitoProfile, DiscordOptions, DiscordProfile, DropboxOptions, DropboxProfile, FacebookOptions, FacebookProfile, FigmaOptions, FigmaProfile, GithubOptions, GithubProfile, GitlabOptions, GitlabProfile, GoogleOptions, GoogleProfile, HuggingFaceOptions, HuggingFaceProfile, KakaoOptions, KakaoProfile, KickOptions, KickProfile, LineIdTokenPayload, LineOptions, LineUserInfo, LinearOptions, LinearProfile, LinearUser, LinkedInOptions, LinkedInProfile, LoginType, MicrosoftEntraIDProfile, MicrosoftOptions, NaverOptions, NaverProfile, NotionOptions, NotionProfile, PayPalOptions, PayPalProfile, PayPalTokenResponse, PaybinOptions, PaybinProfile, PhoneNumber, PolarOptions, PolarProfile, PronounOption, RedditOptions, RedditProfile, RobloxOptions, RobloxProfile, SalesforceOptions, SalesforceProfile, SlackOptions, SlackProfile, SocialProvider, SocialProviderList, SocialProviderListEnum, SocialProviders, SpotifyOptions, SpotifyProfile, TiktokOptions, TiktokProfile, TwitchOptions, TwitchProfile, TwitterOption, TwitterProfile, VercelOptions, VercelProfile, VkOption, VkProfile, ZoomOptions, ZoomProfile, apple, atlassian, cognito, discord, dropbox, facebook, figma, getApplePublicKey, getCognitoPublicKey, getGooglePublicKey, github, gitlab, google, huggingface, kakao, kick, line, linear, linkedin, microsoft, naver, notion, paybin, paypal, polar, reddit, roblox, salesforce, slack, socialProviderList, socialProviders, spotify, tiktok, twitch, twitter, vercel, vk, zoom };
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { i as logger } from "../env-DbssmzoK.mjs";
|
|
2
2
|
import "../utils-U2L7n92V.mjs";
|
|
3
3
|
import { t as BetterAuthError } from "../error-DP1xOn7P.mjs";
|
|
4
|
-
import { a as validateAuthorizationCode, c as refreshAccessToken, d as getOAuth2Tokens, l as createAuthorizationURL, u as generateCodeChallenge } from "../oauth2-
|
|
4
|
+
import { a as validateAuthorizationCode, c as refreshAccessToken, d as getOAuth2Tokens, l as createAuthorizationURL, u as generateCodeChallenge } from "../oauth2-COJkghlT.mjs";
|
|
5
5
|
import * as z from "zod";
|
|
6
6
|
import { base64 } from "@better-auth/utils/base64";
|
|
7
7
|
import { betterFetch } from "@better-fetch/fetch";
|
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
|
/**
|
|
@@ -40,7 +40,7 @@ export async function createAuthorizationURL({
|
|
|
40
40
|
additionalParams?: Record<string, string> | undefined;
|
|
41
41
|
scopeJoiner?: string | undefined;
|
|
42
42
|
}) {
|
|
43
|
-
const url = new URL(authorizationEndpoint);
|
|
43
|
+
const url = new URL(options.authorizationEndpoint || authorizationEndpoint);
|
|
44
44
|
url.searchParams.set("response_type", responseType || "code");
|
|
45
45
|
const primaryClientId = Array.isArray(options.clientId)
|
|
46
46
|
? options.clientId[0]
|
|
@@ -119,6 +119,12 @@ export type ProviderOptions<Profile extends Record<string, any> = any> = {
|
|
|
119
119
|
* whitelisted in the provider's dashboard.
|
|
120
120
|
*/
|
|
121
121
|
redirectURI?: string | undefined;
|
|
122
|
+
/**
|
|
123
|
+
* Custom authorization endpoint URL.
|
|
124
|
+
* Use this to override the default authorization endpoint of the provider.
|
|
125
|
+
* Useful for testing with local OAuth servers or using sandbox environments.
|
|
126
|
+
*/
|
|
127
|
+
authorizationEndpoint?: string | undefined;
|
|
122
128
|
/**
|
|
123
129
|
* The client key of your application
|
|
124
130
|
* Tiktok Social Provider uses this field instead of clientId
|