@better-auth/core 1.5.0-beta.9 → 1.5.0
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/README.md +17 -0
- package/dist/api/index.d.mts +144 -41
- package/dist/api/index.mjs +2 -1
- package/dist/api/index.mjs.map +1 -0
- package/dist/async_hooks/index.d.mts +2 -1
- package/dist/async_hooks/index.mjs +2 -1
- package/dist/async_hooks/index.mjs.map +1 -0
- package/dist/async_hooks/pure.index.d.mts +2 -1
- package/dist/async_hooks/pure.index.mjs +2 -1
- package/dist/async_hooks/pure.index.mjs.map +1 -0
- package/dist/context/endpoint-context.d.mts +2 -1
- package/dist/context/endpoint-context.mjs +4 -3
- package/dist/context/endpoint-context.mjs.map +1 -0
- package/dist/context/global.d.mts +2 -2
- package/dist/context/global.mjs +3 -2
- package/dist/context/global.mjs.map +1 -0
- package/dist/context/request-state.d.mts +2 -1
- package/dist/context/request-state.mjs +4 -3
- package/dist/context/request-state.mjs.map +1 -0
- package/dist/context/transaction.d.mts +2 -1
- package/dist/context/transaction.mjs +4 -3
- package/dist/context/transaction.mjs.map +1 -0
- package/dist/db/adapter/factory.d.mts +6 -13
- package/dist/db/adapter/factory.mjs +44 -57
- package/dist/db/adapter/factory.mjs.map +1 -0
- package/dist/db/adapter/get-default-field-name.d.mts +2 -1
- package/dist/db/adapter/get-default-field-name.mjs +3 -2
- package/dist/db/adapter/get-default-field-name.mjs.map +1 -0
- package/dist/db/adapter/get-default-model-name.d.mts +2 -1
- package/dist/db/adapter/get-default-model-name.mjs +5 -4
- package/dist/db/adapter/get-default-model-name.mjs.map +1 -0
- package/dist/db/adapter/get-field-attributes.d.mts +3 -2
- package/dist/db/adapter/get-field-attributes.mjs +2 -1
- package/dist/db/adapter/get-field-attributes.mjs.map +1 -0
- package/dist/db/adapter/get-field-name.d.mts +2 -1
- package/dist/db/adapter/get-field-name.mjs +2 -1
- package/dist/db/adapter/get-field-name.mjs.map +1 -0
- package/dist/db/adapter/get-id-field.d.mts +3 -2
- package/dist/db/adapter/get-id-field.mjs +3 -2
- package/dist/db/adapter/get-id-field.mjs.map +1 -0
- package/dist/db/adapter/get-model-name.d.mts +2 -1
- package/dist/db/adapter/get-model-name.mjs +2 -1
- package/dist/db/adapter/get-model-name.mjs.map +1 -0
- package/dist/db/adapter/index.d.mts +10 -4
- package/dist/db/adapter/index.mjs +19 -2
- package/dist/db/adapter/index.mjs.map +1 -0
- package/dist/db/adapter/types.d.mts +3 -34
- package/dist/db/adapter/utils.d.mts +2 -1
- package/dist/db/adapter/utils.mjs +2 -1
- package/dist/db/adapter/utils.mjs.map +1 -0
- package/dist/db/get-tables.d.mts +2 -1
- package/dist/db/get-tables.mjs +46 -39
- package/dist/db/get-tables.mjs.map +1 -0
- package/dist/db/index.d.mts +7 -7
- package/dist/db/plugin.d.mts +2 -1
- package/dist/db/schema/account.d.mts +8 -4
- package/dist/db/schema/account.mjs +2 -1
- package/dist/db/schema/account.mjs.map +1 -0
- package/dist/db/schema/rate-limit.d.mts +8 -2
- package/dist/db/schema/rate-limit.mjs +2 -1
- package/dist/db/schema/rate-limit.mjs.map +1 -0
- package/dist/db/schema/session.d.mts +8 -4
- package/dist/db/schema/session.mjs +2 -1
- package/dist/db/schema/session.mjs.map +1 -0
- package/dist/db/schema/shared.d.mts +2 -1
- package/dist/db/schema/shared.mjs +2 -1
- package/dist/db/schema/shared.mjs.map +1 -0
- package/dist/db/schema/user.d.mts +8 -4
- package/dist/db/schema/user.mjs +2 -1
- package/dist/db/schema/user.mjs.map +1 -0
- package/dist/db/schema/verification.d.mts +8 -4
- package/dist/db/schema/verification.mjs +2 -1
- package/dist/db/schema/verification.mjs.map +1 -0
- package/dist/db/type.d.mts +28 -2
- package/dist/env/color-depth.d.mts +2 -1
- package/dist/env/color-depth.mjs +2 -1
- package/dist/env/color-depth.mjs.map +1 -0
- package/dist/env/env-impl.d.mts +3 -2
- package/dist/env/env-impl.mjs +9 -8
- package/dist/env/env-impl.mjs.map +1 -0
- package/dist/env/logger.d.mts +2 -1
- package/dist/env/logger.mjs +3 -2
- package/dist/env/logger.mjs.map +1 -0
- package/dist/error/codes.d.mts +64 -181
- package/dist/error/codes.mjs +6 -2
- package/dist/error/codes.mjs.map +1 -0
- package/dist/error/index.d.mts +2 -1
- package/dist/error/index.mjs +2 -1
- package/dist/error/index.mjs.map +1 -0
- package/dist/index.d.mts +5 -4
- package/dist/oauth2/client-credentials-token.d.mts +25 -3
- package/dist/oauth2/client-credentials-token.mjs +15 -2
- package/dist/oauth2/client-credentials-token.mjs.map +1 -0
- package/dist/oauth2/create-authorization-url.d.mts +5 -2
- package/dist/oauth2/create-authorization-url.mjs +3 -1
- package/dist/oauth2/create-authorization-url.mjs.map +1 -0
- package/dist/oauth2/index.d.mts +4 -4
- package/dist/oauth2/index.mjs +4 -4
- package/dist/oauth2/oauth-provider.d.mts +3 -2
- package/dist/oauth2/refresh-access-token.d.mts +24 -4
- package/dist/oauth2/refresh-access-token.mjs +20 -2
- package/dist/oauth2/refresh-access-token.mjs.map +1 -0
- package/dist/oauth2/utils.d.mts +2 -1
- package/dist/oauth2/utils.mjs +2 -1
- package/dist/oauth2/utils.mjs.map +1 -0
- package/dist/oauth2/validate-authorization-code.d.mts +37 -4
- package/dist/oauth2/validate-authorization-code.mjs +25 -13
- package/dist/oauth2/validate-authorization-code.mjs.map +1 -0
- package/dist/oauth2/verify.d.mts +7 -13
- package/dist/oauth2/verify.mjs +2 -1
- package/dist/oauth2/verify.mjs.map +1 -0
- package/dist/social-providers/apple.d.mts +2 -1
- package/dist/social-providers/apple.mjs +22 -21
- package/dist/social-providers/apple.mjs.map +1 -0
- package/dist/social-providers/atlassian.d.mts +2 -1
- package/dist/social-providers/atlassian.mjs +2 -1
- package/dist/social-providers/atlassian.mjs.map +1 -0
- package/dist/social-providers/cognito.d.mts +2 -1
- package/dist/social-providers/cognito.mjs +4 -3
- package/dist/social-providers/cognito.mjs.map +1 -0
- package/dist/social-providers/discord.d.mts +2 -1
- package/dist/social-providers/discord.mjs +2 -1
- package/dist/social-providers/discord.mjs.map +1 -0
- package/dist/social-providers/dropbox.d.mts +2 -1
- package/dist/social-providers/dropbox.mjs +2 -1
- package/dist/social-providers/dropbox.mjs.map +1 -0
- package/dist/social-providers/facebook.d.mts +2 -1
- package/dist/social-providers/facebook.mjs +13 -12
- package/dist/social-providers/facebook.mjs.map +1 -0
- package/dist/social-providers/figma.d.mts +2 -1
- package/dist/social-providers/figma.mjs +2 -1
- package/dist/social-providers/figma.mjs.map +1 -0
- package/dist/social-providers/github.d.mts +3 -2
- package/dist/social-providers/github.mjs +23 -6
- package/dist/social-providers/github.mjs.map +1 -0
- package/dist/social-providers/gitlab.d.mts +2 -1
- package/dist/social-providers/gitlab.mjs +3 -2
- package/dist/social-providers/gitlab.mjs.map +1 -0
- package/dist/social-providers/google.d.mts +2 -1
- package/dist/social-providers/google.mjs +18 -13
- package/dist/social-providers/google.mjs.map +1 -0
- package/dist/social-providers/huggingface.d.mts +2 -1
- package/dist/social-providers/huggingface.mjs +3 -2
- package/dist/social-providers/huggingface.mjs.map +1 -0
- package/dist/social-providers/index.d.mts +61 -8
- package/dist/social-providers/index.mjs +5 -2
- package/dist/social-providers/index.mjs.map +1 -0
- package/dist/social-providers/kakao.d.mts +3 -2
- package/dist/social-providers/kakao.mjs +3 -2
- package/dist/social-providers/kakao.mjs.map +1 -0
- package/dist/social-providers/kick.d.mts +2 -1
- package/dist/social-providers/kick.mjs +2 -1
- package/dist/social-providers/kick.mjs.map +1 -0
- package/dist/social-providers/line.d.mts +2 -1
- package/dist/social-providers/line.mjs +3 -2
- package/dist/social-providers/line.mjs.map +1 -0
- package/dist/social-providers/linear.d.mts +2 -1
- package/dist/social-providers/linear.mjs +2 -1
- package/dist/social-providers/linear.mjs.map +1 -0
- package/dist/social-providers/linkedin.d.mts +2 -1
- package/dist/social-providers/linkedin.mjs +2 -1
- package/dist/social-providers/linkedin.mjs.map +1 -0
- package/dist/social-providers/microsoft-entra-id.d.mts +4 -1
- package/dist/social-providers/microsoft-entra-id.mjs +36 -2
- package/dist/social-providers/microsoft-entra-id.mjs.map +1 -0
- package/dist/social-providers/naver.d.mts +11 -20
- package/dist/social-providers/naver.mjs +3 -2
- package/dist/social-providers/naver.mjs.map +1 -0
- package/dist/social-providers/notion.d.mts +2 -1
- package/dist/social-providers/notion.mjs +3 -2
- package/dist/social-providers/notion.mjs.map +1 -0
- package/dist/social-providers/paybin.d.mts +2 -1
- package/dist/social-providers/paybin.mjs +3 -2
- package/dist/social-providers/paybin.mjs.map +1 -0
- package/dist/social-providers/paypal.d.mts +2 -1
- package/dist/social-providers/paypal.mjs +2 -1
- package/dist/social-providers/paypal.mjs.map +1 -0
- package/dist/social-providers/polar.d.mts +2 -1
- package/dist/social-providers/polar.mjs +3 -2
- package/dist/social-providers/polar.mjs.map +1 -0
- package/dist/social-providers/railway.d.mts +68 -0
- package/dist/social-providers/railway.mjs +78 -0
- package/dist/social-providers/railway.mjs.map +1 -0
- package/dist/social-providers/reddit.d.mts +2 -1
- package/dist/social-providers/reddit.mjs +2 -1
- package/dist/social-providers/reddit.mjs.map +1 -0
- package/dist/social-providers/roblox.d.mts +2 -1
- package/dist/social-providers/roblox.mjs +2 -1
- package/dist/social-providers/roblox.mjs.map +1 -0
- package/dist/social-providers/salesforce.d.mts +2 -1
- package/dist/social-providers/salesforce.mjs +2 -1
- package/dist/social-providers/salesforce.mjs.map +1 -0
- package/dist/social-providers/slack.d.mts +2 -1
- package/dist/social-providers/slack.mjs +2 -1
- package/dist/social-providers/slack.mjs.map +1 -0
- package/dist/social-providers/spotify.d.mts +2 -1
- package/dist/social-providers/spotify.mjs +2 -1
- package/dist/social-providers/spotify.mjs.map +1 -0
- package/dist/social-providers/tiktok.d.mts +3 -3
- package/dist/social-providers/tiktok.mjs +3 -2
- package/dist/social-providers/tiktok.mjs.map +1 -0
- package/dist/social-providers/twitch.d.mts +2 -1
- package/dist/social-providers/twitch.mjs +2 -1
- package/dist/social-providers/twitch.mjs.map +1 -0
- package/dist/social-providers/twitter.d.mts +14 -25
- package/dist/social-providers/twitter.mjs +2 -1
- package/dist/social-providers/twitter.mjs.map +1 -0
- package/dist/social-providers/vercel.d.mts +2 -1
- package/dist/social-providers/vercel.mjs +3 -2
- package/dist/social-providers/vercel.mjs.map +1 -0
- package/dist/social-providers/vk.d.mts +2 -1
- package/dist/social-providers/vk.mjs +2 -1
- package/dist/social-providers/vk.mjs.map +1 -0
- package/dist/social-providers/zoom.d.mts +3 -10
- package/dist/social-providers/zoom.mjs +2 -1
- package/dist/social-providers/zoom.mjs.map +1 -0
- package/dist/types/context.d.mts +53 -21
- package/dist/types/cookie.d.mts +2 -1
- package/dist/types/helper.d.mts +4 -1
- package/dist/types/index.d.mts +4 -3
- package/dist/types/init-options.d.mts +231 -159
- package/dist/types/plugin-client.d.mts +4 -1
- package/dist/types/plugin.d.mts +12 -11
- package/dist/types/secret.d.mts +12 -0
- package/dist/utils/db.d.mts +12 -0
- package/dist/utils/db.mjs +17 -0
- package/dist/utils/db.mjs.map +1 -0
- package/dist/utils/deprecate.d.mts +2 -2
- package/dist/utils/deprecate.mjs +2 -1
- package/dist/utils/deprecate.mjs.map +1 -0
- package/dist/utils/error-codes.d.mts +8 -6
- package/dist/utils/error-codes.mjs +3 -2
- package/dist/utils/error-codes.mjs.map +1 -0
- package/dist/utils/id.d.mts +2 -1
- package/dist/utils/id.mjs +2 -1
- package/dist/utils/id.mjs.map +1 -0
- package/dist/utils/ip.d.mts +2 -1
- package/dist/utils/ip.mjs +2 -1
- package/dist/utils/ip.mjs.map +1 -0
- package/dist/utils/json.d.mts +2 -1
- package/dist/utils/json.mjs +2 -1
- package/dist/utils/json.mjs.map +1 -0
- package/dist/utils/string.d.mts +2 -1
- package/dist/utils/string.mjs +2 -1
- package/dist/utils/string.mjs.map +1 -0
- package/dist/utils/url.d.mts +2 -1
- package/dist/utils/url.mjs +2 -1
- package/dist/utils/url.mjs.map +1 -0
- package/package.json +35 -13
- package/src/db/adapter/factory.ts +41 -73
- package/src/db/adapter/get-id-field.ts +1 -3
- package/src/db/adapter/index.ts +20 -15
- package/src/db/adapter/types.ts +2 -41
- package/src/db/get-tables.ts +48 -37
- package/src/db/index.ts +30 -5
- package/src/db/schema/account.ts +16 -3
- package/src/db/schema/rate-limit.ts +16 -1
- package/src/db/schema/session.ts +15 -3
- package/src/db/schema/user.ts +15 -3
- package/src/db/schema/verification.ts +16 -3
- package/src/db/test/get-tables.test.ts +33 -0
- package/src/db/type.ts +154 -1
- package/src/env/env-impl.ts +2 -2
- package/src/env/logger.ts +1 -1
- package/src/error/codes.ts +17 -0
- package/src/oauth2/client-credentials-token.ts +26 -2
- package/src/oauth2/create-authorization-url.ts +3 -1
- package/src/oauth2/index.ts +3 -0
- package/src/oauth2/oauth-provider.ts +1 -1
- package/src/oauth2/refresh-access-token.test.ts +90 -0
- package/src/oauth2/refresh-access-token.ts +37 -4
- package/src/oauth2/validate-authorization-code.ts +55 -24
- package/src/oauth2/validate-token.test.ts +107 -52
- package/src/social-providers/apple.ts +29 -29
- package/src/social-providers/cognito.ts +6 -5
- package/src/social-providers/facebook.ts +3 -3
- package/src/social-providers/github.ts +26 -4
- package/src/social-providers/gitlab.ts +1 -1
- package/src/social-providers/google.ts +18 -14
- package/src/social-providers/huggingface.ts +1 -1
- package/src/social-providers/index.ts +9 -5
- package/src/social-providers/kakao.ts +1 -1
- package/src/social-providers/line.ts +1 -1
- package/src/social-providers/microsoft-entra-id.ts +84 -1
- package/src/social-providers/naver.ts +1 -1
- package/src/social-providers/notion.ts +1 -1
- package/src/social-providers/paybin.ts +1 -5
- package/src/social-providers/polar.ts +1 -1
- package/src/social-providers/railway.ts +100 -0
- package/src/social-providers/tiktok.ts +2 -1
- package/src/social-providers/vercel.ts +1 -1
- package/src/social-providers/zoom.ts +0 -8
- package/src/types/context.ts +74 -14
- package/src/types/helper.ts +9 -0
- package/src/types/index.ts +14 -2
- package/src/types/init-options.ts +294 -186
- package/src/types/plugin-client.ts +1 -0
- package/src/types/plugin.ts +11 -6
- package/src/types/secret.ts +8 -0
- package/src/utils/db.ts +20 -0
- package/src/utils/deprecate.test.ts +0 -1
- package/src/utils/error-codes.ts +12 -9
- package/.turbo/turbo-build.log +0 -182
- package/tsconfig.json +0 -7
- package/tsdown.config.ts +0 -32
- package/vitest.config.ts +0 -3
package/dist/types/context.d.mts
CHANGED
|
@@ -1,36 +1,55 @@
|
|
|
1
1
|
import { BetterAuthDBSchema, ModelNames, SecondaryStorage } from "../db/type.mjs";
|
|
2
|
-
import {
|
|
2
|
+
import { DBAdapter, Where } from "../db/adapter/index.mjs";
|
|
3
3
|
import { Session } from "../db/schema/session.mjs";
|
|
4
4
|
import { User } from "../db/schema/user.mjs";
|
|
5
5
|
import { Verification } from "../db/schema/verification.mjs";
|
|
6
|
-
import "../db/index.mjs";
|
|
7
|
-
import { LiteralString } from "./helper.mjs";
|
|
8
|
-
import { DBAdapter, Where } from "../db/adapter/index.mjs";
|
|
9
6
|
import { createLogger } from "../env/logger.mjs";
|
|
10
|
-
import {
|
|
11
|
-
import "../oauth2/index.mjs";
|
|
12
|
-
import { BetterAuthCookie, BetterAuthCookies } from "./cookie.mjs";
|
|
7
|
+
import { Awaitable, LiteralString } from "./helper.mjs";
|
|
13
8
|
import { BetterAuthPlugin } from "./plugin.mjs";
|
|
14
9
|
import { BetterAuthOptions, BetterAuthRateLimitOptions } from "./init-options.mjs";
|
|
10
|
+
import { Account } from "../db/schema/account.mjs";
|
|
11
|
+
import "../db/index.mjs";
|
|
12
|
+
import { BetterAuthCookie, BetterAuthCookies } from "./cookie.mjs";
|
|
13
|
+
import { SecretConfig } from "./secret.mjs";
|
|
14
|
+
import { OAuthProvider } from "../oauth2/oauth-provider.mjs";
|
|
15
|
+
import "../oauth2/index.mjs";
|
|
15
16
|
import { CookieOptions, EndpointContext } from "better-call";
|
|
16
17
|
|
|
17
18
|
//#region src/types/context.d.ts
|
|
18
|
-
|
|
19
|
+
/**
|
|
20
|
+
* @internal
|
|
21
|
+
*/
|
|
22
|
+
type InferPluginID<O extends BetterAuthOptions> = O["plugins"] extends Array<infer P> ? P extends BetterAuthPlugin ? P["id"] : never : never;
|
|
23
|
+
/**
|
|
24
|
+
* @internal
|
|
25
|
+
*/
|
|
26
|
+
type InferPluginOptions<O extends BetterAuthOptions, ID extends BetterAuthPluginRegistryIdentifier | LiteralString> = O["plugins"] extends Array<infer P> ? P extends BetterAuthPlugin ? P["id"] extends ID ? P extends {
|
|
27
|
+
options: infer O;
|
|
28
|
+
} ? O : never : never : never : never;
|
|
19
29
|
/**
|
|
20
30
|
* Mutators are defined in each plugin
|
|
21
31
|
*
|
|
22
32
|
* @example
|
|
23
33
|
* ```ts
|
|
34
|
+
* interface MyPluginOptions {
|
|
35
|
+
* useFeature: boolean
|
|
36
|
+
* }
|
|
37
|
+
*
|
|
38
|
+
* const createMyPlugin = <Options extends MyPluginOptions>(options?: Options) => ({
|
|
39
|
+
* id: 'my-plugin',
|
|
40
|
+
* options,
|
|
41
|
+
* } satisfies BetterAuthPlugin);
|
|
42
|
+
*
|
|
24
43
|
* declare module "@better-auth/core" {
|
|
25
|
-
* interface BetterAuthPluginRegistry<
|
|
26
|
-
* '
|
|
27
|
-
* creator: typeof
|
|
44
|
+
* interface BetterAuthPluginRegistry<AuthOptions, Options> {
|
|
45
|
+
* 'my-plugin': {
|
|
46
|
+
* creator: Options extends MyPluginOptions ? typeof createMyPlugin<Options>: typeof createMyPlugin
|
|
28
47
|
* }
|
|
29
48
|
* }
|
|
30
49
|
* }
|
|
31
50
|
* ```
|
|
32
51
|
*/
|
|
33
|
-
interface BetterAuthPluginRegistry<
|
|
52
|
+
interface BetterAuthPluginRegistry<AuthOptions, Options> {}
|
|
34
53
|
type BetterAuthPluginRegistryIdentifier = keyof BetterAuthPluginRegistry<unknown, unknown>;
|
|
35
54
|
type GenericEndpointContext<Options extends BetterAuthOptions = BetterAuthOptions> = EndpointContext<string, any> & {
|
|
36
55
|
context: AuthContext<Options>;
|
|
@@ -42,7 +61,9 @@ interface InternalAdapter<_Options extends BetterAuthOptions = BetterAuthOptions
|
|
|
42
61
|
}>;
|
|
43
62
|
createUser<T extends Record<string, any>>(user: Omit<User, "id" | "createdAt" | "updatedAt" | "emailVerified"> & Partial<User> & Record<string, any>): Promise<T & User>;
|
|
44
63
|
createAccount<T extends Record<string, any>>(account: Omit<Account, "id" | "createdAt" | "updatedAt"> & Partial<Account> & T): Promise<T & Account>;
|
|
45
|
-
listSessions(userId: string
|
|
64
|
+
listSessions(userId: string, options?: {
|
|
65
|
+
onlyActiveSessions?: boolean | undefined;
|
|
66
|
+
} | undefined): Promise<Session[]>;
|
|
46
67
|
listUsers(limit?: number | undefined, offset?: number | undefined, sortBy?: {
|
|
47
68
|
field: string;
|
|
48
69
|
direction: "asc" | "desc";
|
|
@@ -54,7 +75,9 @@ interface InternalAdapter<_Options extends BetterAuthOptions = BetterAuthOptions
|
|
|
54
75
|
session: Session & Record<string, any>;
|
|
55
76
|
user: User & Record<string, any>;
|
|
56
77
|
} | null>;
|
|
57
|
-
findSessions(sessionTokens: string[]
|
|
78
|
+
findSessions(sessionTokens: string[], options?: {
|
|
79
|
+
onlyActiveSessions?: boolean | undefined;
|
|
80
|
+
} | undefined): Promise<{
|
|
58
81
|
session: Session;
|
|
59
82
|
user: User;
|
|
60
83
|
}[]>;
|
|
@@ -92,8 +115,10 @@ interface InternalAdapter<_Options extends BetterAuthOptions = BetterAuthOptions
|
|
|
92
115
|
}
|
|
93
116
|
type CreateCookieGetterFn = (cookieName: string, overrideAttributes?: Partial<CookieOptions> | undefined) => BetterAuthCookie;
|
|
94
117
|
type CheckPasswordFn<Options extends BetterAuthOptions = BetterAuthOptions> = (userId: string, ctx: GenericEndpointContext<Options>) => Promise<boolean>;
|
|
95
|
-
type PluginContext = {
|
|
96
|
-
getPlugin: <ID extends BetterAuthPluginRegistryIdentifier | LiteralString
|
|
118
|
+
type PluginContext<Options extends BetterAuthOptions> = {
|
|
119
|
+
getPlugin: <ID extends BetterAuthPluginRegistryIdentifier | LiteralString, PluginOptions extends InferPluginOptions<Options, ID>>(pluginId: ID) => (ID extends BetterAuthPluginRegistryIdentifier ? BetterAuthPluginRegistry<Options, PluginOptions>[ID] extends {
|
|
120
|
+
creator: infer C;
|
|
121
|
+
} ? C extends ((...args: any[]) => infer R) ? R : never : never : BetterAuthPlugin) | null;
|
|
97
122
|
/**
|
|
98
123
|
* Checks if a plugin is enabled by its ID.
|
|
99
124
|
*
|
|
@@ -107,16 +132,21 @@ type PluginContext = {
|
|
|
107
132
|
* }
|
|
108
133
|
* ```
|
|
109
134
|
*/
|
|
110
|
-
hasPlugin: <ID extends BetterAuthPluginRegistryIdentifier | LiteralString>(pluginId: ID) => boolean;
|
|
135
|
+
hasPlugin: <ID extends BetterAuthPluginRegistryIdentifier | LiteralString>(pluginId: ID) => ID extends InferPluginID<Options> ? true : boolean;
|
|
111
136
|
};
|
|
112
137
|
type InfoContext = {
|
|
113
138
|
appName: string;
|
|
114
139
|
baseURL: string;
|
|
115
140
|
version: string;
|
|
116
141
|
};
|
|
117
|
-
type AuthContext<Options extends BetterAuthOptions = BetterAuthOptions> = PluginContext & InfoContext & {
|
|
142
|
+
type AuthContext<Options extends BetterAuthOptions = BetterAuthOptions> = PluginContext<Options> & InfoContext & {
|
|
118
143
|
options: Options;
|
|
119
144
|
trustedOrigins: string[];
|
|
145
|
+
/**
|
|
146
|
+
* Resolved list of trusted providers for account linking.
|
|
147
|
+
* Populated from "account.accountLinking.trustedProviders" (supports static array or async function).
|
|
148
|
+
*/
|
|
149
|
+
trustedProviders: string[];
|
|
120
150
|
/**
|
|
121
151
|
* Verifies whether url is a trusted origin according to the "trustedOrigins" configuration
|
|
122
152
|
* @param url The url to verify against the "trustedOrigins" configuration
|
|
@@ -172,6 +202,7 @@ type AuthContext<Options extends BetterAuthOptions = BetterAuthOptions> = Plugin
|
|
|
172
202
|
internalAdapter: InternalAdapter<Options>;
|
|
173
203
|
createAuthCookie: CreateCookieGetterFn;
|
|
174
204
|
secret: string;
|
|
205
|
+
secretConfig: string | SecretConfig;
|
|
175
206
|
sessionConfig: {
|
|
176
207
|
updateAge: number;
|
|
177
208
|
expiresIn: number;
|
|
@@ -233,7 +264,7 @@ type AuthContext<Options extends BetterAuthOptions = BetterAuthOptions> = Plugin
|
|
|
233
264
|
* This is inferred from the `options.advanced?.backgroundTasks?.handler` option.
|
|
234
265
|
* Defaults to a no-op that just runs the promise.
|
|
235
266
|
*/
|
|
236
|
-
runInBackground: (promise: Promise<
|
|
267
|
+
runInBackground: (promise: Promise<unknown>) => void;
|
|
237
268
|
/**
|
|
238
269
|
* Runs a task in the background if `runInBackground` is configured,
|
|
239
270
|
* otherwise awaits the task directly.
|
|
@@ -242,7 +273,8 @@ type AuthContext<Options extends BetterAuthOptions = BetterAuthOptions> = Plugin
|
|
|
242
273
|
* to avoid blocking the response when possible (for timing attack
|
|
243
274
|
* mitigation), but still ensure the operation completes.
|
|
244
275
|
*/
|
|
245
|
-
runInBackgroundOrAwait: (promise: Promise<unknown> |
|
|
276
|
+
runInBackgroundOrAwait: (promise: Promise<unknown> | void) => Awaitable<unknown>;
|
|
246
277
|
};
|
|
247
278
|
//#endregion
|
|
248
|
-
export { AuthContext, BetterAuthPluginRegistry, BetterAuthPluginRegistryIdentifier, GenericEndpointContext, InfoContext, InternalAdapter, PluginContext };
|
|
279
|
+
export { AuthContext, BetterAuthPluginRegistry, BetterAuthPluginRegistryIdentifier, GenericEndpointContext, InfoContext, InternalAdapter, PluginContext };
|
|
280
|
+
//# sourceMappingURL=context.d.mts.map
|
package/dist/types/cookie.d.mts
CHANGED
package/dist/types/helper.d.mts
CHANGED
|
@@ -1,8 +1,11 @@
|
|
|
1
1
|
//#region src/types/helper.d.ts
|
|
2
2
|
type Primitive = string | number | symbol | bigint | boolean | null | undefined;
|
|
3
3
|
type Awaitable<T> = T | Promise<T>;
|
|
4
|
+
type AwaitableFunction<T> = T | (() => Awaitable<T>);
|
|
4
5
|
type LiteralString = "" | (string & Record<never, never>);
|
|
5
6
|
type LiteralUnion<LiteralType, BaseType extends Primitive> = LiteralType | (BaseType & Record<never, never>);
|
|
6
7
|
type Prettify<T> = { [K in keyof T]: T[K] } & {};
|
|
8
|
+
type UnionToIntersection<U> = (U extends any ? (k: U) => void : never) extends ((k: infer I) => void) ? I : never;
|
|
7
9
|
//#endregion
|
|
8
|
-
export { Awaitable, LiteralString, LiteralUnion, Prettify, Primitive };
|
|
10
|
+
export { Awaitable, AwaitableFunction, LiteralString, LiteralUnion, Prettify, Primitive, UnionToIntersection };
|
|
11
|
+
//# sourceMappingURL=helper.d.mts.map
|
package/dist/types/index.d.mts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import { Awaitable, LiteralString, LiteralUnion, Prettify, Primitive } from "./helper.mjs";
|
|
1
|
+
import { Awaitable, AwaitableFunction, LiteralString, LiteralUnion, Prettify, Primitive, UnionToIntersection } from "./helper.mjs";
|
|
2
|
+
import { BetterAuthPlugin, BetterAuthPluginErrorCodePart, HookEndpointContext } from "./plugin.mjs";
|
|
3
|
+
import { BaseURLConfig, BetterAuthAdvancedOptions, BetterAuthDBOptions, BetterAuthOptions, BetterAuthRateLimitOptions, BetterAuthRateLimitRule, BetterAuthRateLimitStorage, DynamicBaseURLConfig, GenerateIdFn, StoreIdentifierOption } from "./init-options.mjs";
|
|
2
4
|
import { BetterAuthCookie, BetterAuthCookies } from "./cookie.mjs";
|
|
3
|
-
import {
|
|
4
|
-
import { BetterAuthAdvancedOptions, BetterAuthOptions, BetterAuthRateLimitOptions, BetterAuthRateLimitRule, BetterAuthRateLimitStorage, GenerateIdFn } from "./init-options.mjs";
|
|
5
|
+
import { SecretConfig } from "./secret.mjs";
|
|
5
6
|
import { AuthContext, BetterAuthPluginRegistry, BetterAuthPluginRegistryIdentifier, GenericEndpointContext, InfoContext, InternalAdapter, PluginContext } from "./context.mjs";
|
|
6
7
|
import { BetterAuthClientOptions, BetterAuthClientPlugin, ClientAtomListener, ClientFetchOption, ClientStore } from "./plugin-client.mjs";
|
|
7
8
|
import { StandardSchemaV1 as StandardSchemaV1$1 } from "@standard-schema/spec";
|