@better-auth/core 1.5.0-beta.4 → 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 +170 -37
- package/dist/api/index.d.mts +188 -1
- package/dist/api/index.mjs +2 -1
- package/dist/context/endpoint-context.d.mts +19 -0
- package/dist/context/endpoint-context.mjs +31 -0
- package/dist/context/index.d.mts +3 -52
- package/dist/context/index.mjs +3 -1
- package/dist/context/request-state.d.mts +27 -0
- package/dist/context/request-state.mjs +49 -0
- package/dist/context/transaction.d.mts +16 -0
- package/dist/context/transaction.mjs +52 -0
- package/dist/db/adapter/factory.d.mts +27 -0
- package/dist/db/adapter/factory.mjs +738 -0
- package/dist/db/adapter/get-default-field-name.d.mts +18 -0
- package/dist/db/adapter/get-default-field-name.mjs +38 -0
- package/dist/db/adapter/get-default-model-name.d.mts +12 -0
- package/dist/db/adapter/get-default-model-name.mjs +32 -0
- package/dist/db/adapter/get-field-attributes.d.mts +29 -0
- package/dist/db/adapter/get-field-attributes.mjs +39 -0
- package/dist/db/adapter/get-field-name.d.mts +18 -0
- package/dist/db/adapter/get-field-name.mjs +33 -0
- package/dist/db/adapter/get-id-field.d.mts +39 -0
- package/dist/db/adapter/get-id-field.mjs +67 -0
- package/dist/db/adapter/get-model-name.d.mts +12 -0
- package/dist/db/adapter/get-model-name.mjs +23 -0
- package/dist/db/adapter/index.d.mts +513 -1
- package/dist/db/adapter/index.mjs +8 -970
- package/dist/db/adapter/types.d.mts +139 -0
- package/dist/db/adapter/utils.d.mts +7 -0
- package/dist/db/adapter/utils.mjs +38 -0
- package/dist/db/get-tables.d.mts +8 -0
- package/dist/{get-tables-CMc_Emww.mjs → db/get-tables.mjs} +1 -1
- package/dist/db/index.d.mts +10 -2
- package/dist/db/index.mjs +7 -60
- package/dist/db/plugin.d.mts +12 -0
- package/dist/db/schema/account.d.mts +26 -0
- package/dist/db/schema/account.mjs +19 -0
- package/dist/db/schema/rate-limit.d.mts +14 -0
- package/dist/db/schema/rate-limit.mjs +11 -0
- package/dist/db/schema/session.d.mts +21 -0
- package/dist/db/schema/session.mjs +14 -0
- package/dist/db/schema/shared.d.mts +10 -0
- package/dist/db/schema/shared.mjs +11 -0
- package/dist/db/schema/user.d.mts +20 -0
- package/dist/db/schema/user.mjs +13 -0
- package/dist/db/schema/verification.d.mts +19 -0
- package/dist/db/schema/verification.mjs +12 -0
- package/dist/db/type.d.mts +143 -0
- package/dist/env/color-depth.d.mts +4 -0
- package/dist/env/color-depth.mjs +88 -0
- package/dist/env/env-impl.d.mts +32 -0
- package/dist/env/env-impl.mjs +82 -0
- package/dist/env/index.d.mts +4 -2
- package/dist/env/index.mjs +3 -1
- package/dist/{index-BRBu0-5h.d.mts → env/logger.d.mts} +1 -35
- package/dist/env/logger.mjs +81 -0
- package/dist/error/codes.d.mts +186 -0
- package/dist/{error-GNtLPYaS.mjs → error/codes.mjs} +2 -29
- package/dist/error/index.d.mts +1 -185
- package/dist/error/index.mjs +28 -3
- package/dist/index.d.mts +7 -1
- package/dist/oauth2/client-credentials-token.d.mts +36 -0
- package/dist/oauth2/client-credentials-token.mjs +54 -0
- package/dist/oauth2/create-authorization-url.d.mts +45 -0
- package/dist/oauth2/create-authorization-url.mjs +42 -0
- package/dist/oauth2/index.d.mts +8 -2
- package/dist/oauth2/index.mjs +6 -2
- package/dist/oauth2/oauth-provider.d.mts +194 -0
- package/dist/oauth2/refresh-access-token.d.mts +36 -0
- package/dist/oauth2/refresh-access-token.mjs +58 -0
- package/dist/oauth2/utils.d.mts +7 -0
- package/dist/oauth2/utils.mjs +27 -0
- package/dist/oauth2/validate-authorization-code.d.mts +55 -0
- package/dist/oauth2/validate-authorization-code.mjs +71 -0
- package/dist/oauth2/verify.d.mts +49 -0
- package/dist/oauth2/verify.mjs +95 -0
- package/dist/social-providers/apple.d.mts +119 -0
- package/dist/social-providers/apple.mjs +102 -0
- package/dist/social-providers/atlassian.d.mts +72 -0
- package/dist/social-providers/atlassian.mjs +83 -0
- package/dist/social-providers/cognito.d.mts +87 -0
- package/dist/social-providers/cognito.mjs +165 -0
- package/dist/social-providers/discord.d.mts +126 -0
- package/dist/social-providers/discord.mjs +64 -0
- package/dist/social-providers/dropbox.d.mts +71 -0
- package/dist/social-providers/dropbox.mjs +75 -0
- package/dist/social-providers/facebook.d.mts +81 -0
- package/dist/social-providers/facebook.mjs +120 -0
- package/dist/social-providers/figma.d.mts +63 -0
- package/dist/social-providers/figma.mjs +84 -0
- package/dist/social-providers/github.d.mts +104 -0
- package/dist/social-providers/github.mjs +80 -0
- package/dist/social-providers/gitlab.d.mts +125 -0
- package/dist/social-providers/gitlab.mjs +82 -0
- package/dist/social-providers/google.d.mts +99 -0
- package/dist/social-providers/google.mjs +108 -0
- package/dist/social-providers/huggingface.d.mts +85 -0
- package/dist/social-providers/huggingface.mjs +75 -0
- package/dist/social-providers/index.d.mts +1723 -1
- package/dist/social-providers/index.mjs +33 -2569
- package/dist/social-providers/kakao.d.mts +163 -0
- package/dist/social-providers/kakao.mjs +72 -0
- package/dist/social-providers/kick.d.mts +75 -0
- package/dist/social-providers/kick.mjs +71 -0
- package/dist/social-providers/line.d.mts +107 -0
- package/dist/social-providers/line.mjs +113 -0
- package/dist/social-providers/linear.d.mts +70 -0
- package/dist/social-providers/linear.mjs +88 -0
- package/dist/social-providers/linkedin.d.mts +69 -0
- package/dist/social-providers/linkedin.mjs +76 -0
- package/dist/social-providers/microsoft-entra-id.d.mts +174 -0
- package/dist/social-providers/microsoft-entra-id.mjs +106 -0
- package/dist/social-providers/naver.d.mts +104 -0
- package/dist/social-providers/naver.mjs +67 -0
- package/dist/social-providers/notion.d.mts +66 -0
- package/dist/social-providers/notion.mjs +75 -0
- package/dist/social-providers/paybin.d.mts +73 -0
- package/dist/social-providers/paybin.mjs +85 -0
- package/dist/social-providers/paypal.d.mts +131 -0
- package/dist/social-providers/paypal.mjs +144 -0
- package/dist/social-providers/polar.d.mts +76 -0
- package/dist/social-providers/polar.mjs +73 -0
- package/dist/social-providers/reddit.d.mts +64 -0
- package/dist/social-providers/reddit.mjs +83 -0
- package/dist/social-providers/roblox.d.mts +72 -0
- package/dist/social-providers/roblox.mjs +59 -0
- package/dist/social-providers/salesforce.d.mts +81 -0
- package/dist/social-providers/salesforce.mjs +91 -0
- package/dist/social-providers/slack.d.mts +85 -0
- package/dist/social-providers/slack.mjs +68 -0
- package/dist/social-providers/spotify.d.mts +65 -0
- package/dist/social-providers/spotify.mjs +71 -0
- package/dist/social-providers/tiktok.d.mts +171 -0
- package/dist/social-providers/tiktok.mjs +62 -0
- package/dist/social-providers/twitch.d.mts +81 -0
- package/dist/social-providers/twitch.mjs +78 -0
- package/dist/social-providers/twitter.d.mts +140 -0
- package/dist/social-providers/twitter.mjs +87 -0
- package/dist/social-providers/vercel.d.mts +64 -0
- package/dist/social-providers/vercel.mjs +61 -0
- package/dist/social-providers/vk.d.mts +72 -0
- package/dist/social-providers/vk.mjs +83 -0
- package/dist/social-providers/zoom.d.mts +173 -0
- package/dist/social-providers/zoom.mjs +72 -0
- package/dist/types/context.d.mts +246 -0
- package/dist/types/cookie.d.mts +23 -0
- package/dist/types/helper.d.mts +8 -0
- package/dist/types/index.d.mts +8 -0
- package/dist/types/init-options.d.mts +1266 -0
- package/dist/types/plugin-client.d.mts +110 -0
- package/dist/types/plugin.d.mts +124 -0
- package/dist/utils/deprecate.d.mts +10 -0
- package/dist/utils/deprecate.mjs +17 -0
- package/dist/utils/{index.d.mts → error-codes.d.mts} +1 -19
- package/dist/utils/error-codes.mjs +11 -0
- package/dist/utils/id.d.mts +4 -0
- package/dist/utils/id.mjs +9 -0
- package/dist/utils/json.d.mts +4 -0
- package/dist/utils/json.mjs +25 -0
- package/dist/utils/string.d.mts +4 -0
- package/dist/utils/string.mjs +7 -0
- package/package.json +9 -6
- 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/db/adapter/get-id-field.ts +1 -1
- package/src/error/codes.ts +1 -1
- package/src/oauth2/create-authorization-url.ts +1 -1
- package/src/oauth2/oauth-provider.ts +6 -0
- package/tsdown.config.ts +3 -1
- package/dist/context-BBNwughv.mjs +0 -133
- package/dist/env-DbssmzoK.mjs +0 -245
- package/dist/index-B5x_W0dM.d.mts +0 -8054
- package/dist/oauth2-BjWM15hm.mjs +0 -326
- package/dist/utils/index.mjs +0 -4
- package/dist/utils-puAL36Bz.mjs +0 -63
- package/src/utils/index.ts +0 -5
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { DBAdapter, DBTransactionAdapter } from "../db/adapter/index.mjs";
|
|
2
|
+
import { AsyncLocalStorage } from "@better-auth/core/async_hooks";
|
|
3
|
+
|
|
4
|
+
//#region src/context/transaction.d.ts
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* This is for internal use only. Most users should use `getCurrentAdapter` instead.
|
|
8
|
+
*
|
|
9
|
+
* It is exposed for advanced use cases where you need direct access to the AsyncLocalStorage instance.
|
|
10
|
+
*/
|
|
11
|
+
declare const getCurrentDBAdapterAsyncLocalStorage: () => Promise<AsyncLocalStorage<DBTransactionAdapter>>;
|
|
12
|
+
declare const getCurrentAdapter: (fallback: DBTransactionAdapter) => Promise<DBTransactionAdapter>;
|
|
13
|
+
declare const runWithAdapter: <R>(adapter: DBAdapter, fn: () => R) => Promise<R>;
|
|
14
|
+
declare const runWithTransaction: <R>(adapter: DBAdapter, fn: () => R) => Promise<R>;
|
|
15
|
+
//#endregion
|
|
16
|
+
export { getCurrentAdapter, getCurrentDBAdapterAsyncLocalStorage, runWithAdapter, runWithTransaction };
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { getAsyncLocalStorage } from "@better-auth/core/async_hooks";
|
|
2
|
+
|
|
3
|
+
//#region src/context/transaction.ts
|
|
4
|
+
const symbol = Symbol.for("better-auth:transaction-adapter-async-storage");
|
|
5
|
+
let currentAdapterAsyncStorage = null;
|
|
6
|
+
const ensureAsyncStorage = async () => {
|
|
7
|
+
if (!currentAdapterAsyncStorage || globalThis[symbol] === void 0) {
|
|
8
|
+
currentAdapterAsyncStorage = new (await (getAsyncLocalStorage()))();
|
|
9
|
+
globalThis[symbol] = currentAdapterAsyncStorage;
|
|
10
|
+
}
|
|
11
|
+
return currentAdapterAsyncStorage || globalThis[symbol];
|
|
12
|
+
};
|
|
13
|
+
/**
|
|
14
|
+
* This is for internal use only. Most users should use `getCurrentAdapter` instead.
|
|
15
|
+
*
|
|
16
|
+
* It is exposed for advanced use cases where you need direct access to the AsyncLocalStorage instance.
|
|
17
|
+
*/
|
|
18
|
+
const getCurrentDBAdapterAsyncLocalStorage = async () => {
|
|
19
|
+
return ensureAsyncStorage();
|
|
20
|
+
};
|
|
21
|
+
const getCurrentAdapter = async (fallback) => {
|
|
22
|
+
return ensureAsyncStorage().then((als) => {
|
|
23
|
+
return als.getStore() || fallback;
|
|
24
|
+
}).catch(() => {
|
|
25
|
+
return fallback;
|
|
26
|
+
});
|
|
27
|
+
};
|
|
28
|
+
const runWithAdapter = async (adapter, fn) => {
|
|
29
|
+
let called = true;
|
|
30
|
+
return ensureAsyncStorage().then((als) => {
|
|
31
|
+
called = true;
|
|
32
|
+
return als.run(adapter, fn);
|
|
33
|
+
}).catch((err) => {
|
|
34
|
+
if (!called) return fn();
|
|
35
|
+
throw err;
|
|
36
|
+
});
|
|
37
|
+
};
|
|
38
|
+
const runWithTransaction = async (adapter, fn) => {
|
|
39
|
+
let called = true;
|
|
40
|
+
return ensureAsyncStorage().then((als) => {
|
|
41
|
+
called = true;
|
|
42
|
+
return adapter.transaction(async (trx) => {
|
|
43
|
+
return als.run(trx, fn);
|
|
44
|
+
});
|
|
45
|
+
}).catch((err) => {
|
|
46
|
+
if (!called) return fn();
|
|
47
|
+
throw err;
|
|
48
|
+
});
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
//#endregion
|
|
52
|
+
export { getCurrentAdapter, getCurrentDBAdapterAsyncLocalStorage, runWithAdapter, runWithTransaction };
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { initGetDefaultFieldName } from "./get-default-field-name.mjs";
|
|
2
|
+
import { initGetDefaultModelName } from "./get-default-model-name.mjs";
|
|
3
|
+
import { initGetFieldAttributes } from "./get-field-attributes.mjs";
|
|
4
|
+
import { initGetFieldName } from "./get-field-name.mjs";
|
|
5
|
+
import { initGetIdField } from "./get-id-field.mjs";
|
|
6
|
+
import { initGetModelName } from "./get-model-name.mjs";
|
|
7
|
+
import { AdapterConfig, AdapterFactoryConfig, AdapterFactoryCustomizeAdapterCreator, AdapterFactoryOptions, AdapterTestDebugLogs, CleanedWhere, CreateAdapterOptions, CreateCustomAdapter, CustomAdapter } from "./types.mjs";
|
|
8
|
+
import { DBAdapter } from "./index.mjs";
|
|
9
|
+
import { BetterAuthOptions } from "../../types/init-options.mjs";
|
|
10
|
+
import "../../types/index.mjs";
|
|
11
|
+
|
|
12
|
+
//#region src/db/adapter/factory.d.ts
|
|
13
|
+
type AdapterFactory = (options: BetterAuthOptions) => DBAdapter<BetterAuthOptions>;
|
|
14
|
+
declare const createAdapterFactory: ({
|
|
15
|
+
adapter: customAdapter,
|
|
16
|
+
config: cfg
|
|
17
|
+
}: AdapterFactoryOptions) => AdapterFactory;
|
|
18
|
+
/**
|
|
19
|
+
* @deprecated Use `createAdapterFactory` instead. This export will be removed in a future version.
|
|
20
|
+
* @alias
|
|
21
|
+
*/
|
|
22
|
+
declare const createAdapter: ({
|
|
23
|
+
adapter: customAdapter,
|
|
24
|
+
config: cfg
|
|
25
|
+
}: AdapterFactoryOptions) => AdapterFactory;
|
|
26
|
+
//#endregion
|
|
27
|
+
export { AdapterFactory, createAdapter, createAdapterFactory };
|