better-auth 1.6.22 → 1.6.24
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/dist/adapters/index.d.mts +1 -6
- package/dist/api/dispatch.d.mts +0 -1
- package/dist/api/index.d.mts +476 -478
- package/dist/api/middlewares/authorization.d.mts +12 -8
- package/dist/api/middlewares/authorization.mjs +2 -1
- package/dist/api/middlewares/index.d.mts +2 -1
- package/dist/api/middlewares/origin-check.d.mts +3 -5
- package/dist/api/routes/account.d.mts +10 -13
- package/dist/api/routes/account.mjs +35 -7
- package/dist/api/routes/callback.d.mts +1 -3
- package/dist/api/routes/callback.mjs +4 -0
- package/dist/api/routes/email-verification.d.mts +4 -8
- package/dist/api/routes/email-verification.mjs +15 -2
- package/dist/api/routes/error.d.mts +1 -3
- package/dist/api/routes/index.d.mts +2 -1
- package/dist/api/routes/ok.d.mts +1 -3
- package/dist/api/routes/password.d.mts +7 -9
- package/dist/api/routes/password.mjs +14 -1
- package/dist/api/routes/session.d.mts +22 -24
- package/dist/api/routes/session.mjs +5 -1
- package/dist/api/routes/sign-in.d.mts +3 -5
- package/dist/api/routes/sign-in.mjs +84 -2
- package/dist/api/routes/sign-out.d.mts +1 -3
- package/dist/api/routes/sign-up.d.mts +3 -4
- package/dist/api/routes/sign-up.mjs +3 -2
- package/dist/api/routes/update-session.d.mts +3 -4
- package/dist/api/routes/update-user.d.mts +13 -14
- package/dist/api/routes/update-user.mjs +26 -1
- package/dist/auth/full.d.mts +1 -1
- package/dist/auth/minimal.d.mts +1 -1
- package/dist/client/config.d.mts +12 -14
- package/dist/client/config.mjs +2 -2
- package/dist/client/equality.d.mts +0 -1
- package/dist/client/index.d.mts +6 -5
- package/dist/client/lynx/index.d.mts +4 -5
- package/dist/client/lynx/lynx-store.d.mts +1 -2
- package/dist/client/parser.d.mts +7 -3
- package/dist/client/path-to-object.d.mts +3 -4
- package/dist/client/plugins/index.d.mts +2 -1
- package/dist/client/plugins/infer-plugin.d.mts +0 -1
- package/dist/client/query.d.mts +0 -1
- package/dist/client/query.mjs +38 -20
- package/dist/client/react/index.d.mts +4 -5
- package/dist/client/react/react-store.d.mts +1 -2
- package/dist/client/session-refresh.d.mts +0 -1
- package/dist/client/solid/index.d.mts +5 -6
- package/dist/client/svelte/index.d.mts +5 -6
- package/dist/client/types.d.mts +2 -2
- package/dist/client/vanilla.d.mts +2 -3
- package/dist/client/vue/index.d.mts +5 -6
- package/dist/context/create-context.mjs +3 -3
- package/dist/context/helpers.mjs +2 -2
- package/dist/cookies/cookie-utils.d.mts +1 -1
- package/dist/cookies/index.d.mts +6 -7
- package/dist/cookies/index.mjs +4 -0
- package/dist/cookies/session-store.d.mts +1 -0
- package/dist/cookies/session-store.mjs +6 -1
- package/dist/crypto/index.d.mts +2 -9
- package/dist/crypto/jwt.d.mts +0 -1
- package/dist/crypto/password.d.mts +1 -5
- package/dist/db/adapter-base.d.mts +0 -1
- package/dist/db/adapter-kysely.d.mts +0 -1
- package/dist/db/field-converter.d.mts +0 -1
- package/dist/db/field.d.mts +9 -10
- package/dist/db/get-migration.d.mts +0 -1
- package/dist/db/get-migration.mjs +8 -4
- package/dist/db/get-schema.d.mts +0 -1
- package/dist/db/internal-adapter.d.mts +0 -1
- package/dist/db/internal-adapter.mjs +61 -1
- package/dist/db/revoke-unproven-account-access.d.mts +0 -1
- package/dist/db/schema.d.mts +2 -2
- package/dist/db/to-zod.d.mts +3 -7
- package/dist/db/with-hooks.d.mts +0 -1
- package/dist/index.d.mts +4 -3
- package/dist/integrations/next-js.d.mts +4 -7
- package/dist/integrations/node.d.mts +2 -3
- package/dist/integrations/svelte-kit.d.mts +2 -9
- package/dist/integrations/tanstack-start-solid.d.mts +2 -5
- package/dist/integrations/tanstack-start.d.mts +2 -5
- package/dist/oauth2/link-account.d.mts +1 -1
- package/dist/oauth2/state.d.mts +0 -1
- package/dist/oauth2/utils.d.mts +0 -1
- package/dist/package.mjs +1 -1
- package/dist/plugins/access/access.d.mts +0 -1
- package/dist/plugins/access/types.d.mts +4 -5
- package/dist/plugins/additional-fields/client.d.mts +0 -1
- package/dist/plugins/admin/access/statement.d.mts +1 -0
- package/dist/plugins/admin/admin.d.mts +120 -125
- package/dist/plugins/admin/client.d.mts +30 -30
- package/dist/plugins/admin/client.mjs +1 -1
- package/dist/plugins/admin/error-codes.d.mts +23 -25
- package/dist/plugins/admin/index.d.mts +1 -1
- package/dist/plugins/admin/routes.mjs +9 -0
- package/dist/plugins/admin/schema.d.mts +1 -1
- package/dist/plugins/admin/types.d.mts +3 -2
- package/dist/plugins/anonymous/client.d.mts +9 -11
- package/dist/plugins/anonymous/client.mjs +1 -1
- package/dist/plugins/anonymous/error-codes.d.mts +8 -10
- package/dist/plugins/anonymous/index.d.mts +14 -18
- package/dist/plugins/anonymous/types.d.mts +1 -1
- package/dist/plugins/bearer/index.d.mts +4 -7
- package/dist/plugins/captcha/index.d.mts +5 -8
- package/dist/plugins/captcha/types.d.mts +0 -1
- package/dist/plugins/custom-session/client.d.mts +0 -1
- package/dist/plugins/custom-session/index.d.mts +7 -12
- package/dist/plugins/device-authorization/client.d.mts +0 -1
- package/dist/plugins/device-authorization/index.d.mts +19 -22
- package/dist/plugins/email-otp/client.d.mts +4 -6
- package/dist/plugins/email-otp/client.mjs +1 -1
- package/dist/plugins/email-otp/error-codes.d.mts +3 -5
- package/dist/plugins/email-otp/index.d.mts +67 -73
- package/dist/plugins/email-otp/routes.mjs +2 -0
- package/dist/plugins/email-otp/types.d.mts +0 -1
- package/dist/plugins/generic-oauth/client.d.mts +11 -11
- package/dist/plugins/generic-oauth/client.mjs +1 -1
- package/dist/plugins/generic-oauth/error-codes.d.mts +8 -10
- package/dist/plugins/generic-oauth/index.d.mts +41 -44
- package/dist/plugins/generic-oauth/index.mjs +2 -1
- package/dist/plugins/generic-oauth/providers/auth0.d.mts +0 -1
- package/dist/plugins/generic-oauth/providers/gumroad.d.mts +0 -1
- package/dist/plugins/generic-oauth/providers/hubspot.d.mts +0 -1
- package/dist/plugins/generic-oauth/providers/index.d.mts +3 -1
- package/dist/plugins/generic-oauth/providers/keycloak.d.mts +0 -1
- package/dist/plugins/generic-oauth/providers/line.d.mts +0 -1
- package/dist/plugins/generic-oauth/providers/microsoft-entra-id.d.mts +0 -1
- package/dist/plugins/generic-oauth/providers/okta.d.mts +0 -1
- package/dist/plugins/generic-oauth/providers/patreon.d.mts +0 -1
- package/dist/plugins/generic-oauth/providers/slack.d.mts +0 -1
- package/dist/plugins/generic-oauth/providers/yandex.d.mts +28 -0
- package/dist/plugins/generic-oauth/providers/yandex.mjs +60 -0
- package/dist/plugins/generic-oauth/routes.mjs +14 -0
- package/dist/plugins/generic-oauth/types.d.mts +1 -2
- package/dist/plugins/haveibeenpwned/index.d.mts +3 -6
- package/dist/plugins/index.d.mts +5 -1
- package/dist/plugins/index.mjs +2 -1
- package/dist/plugins/jwt/client.d.mts +2 -4
- package/dist/plugins/jwt/index.d.mts +8 -11
- package/dist/plugins/jwt/sign.d.mts +2 -2
- package/dist/plugins/jwt/types.d.mts +1 -1
- package/dist/plugins/jwt/utils.d.mts +2 -4
- package/dist/plugins/jwt/verify.d.mts +0 -1
- package/dist/plugins/last-login-method/client.mjs +13 -0
- package/dist/plugins/last-login-method/index.d.mts +11 -5
- package/dist/plugins/last-login-method/index.mjs +8 -0
- package/dist/plugins/magic-link/client.d.mts +0 -1
- package/dist/plugins/magic-link/index.d.mts +4 -5
- package/dist/plugins/magic-link/index.mjs +32 -1
- package/dist/plugins/mcp/authorize.mjs +12 -0
- package/dist/plugins/mcp/client/adapters.d.mts +0 -1
- package/dist/plugins/mcp/client/index.d.mts +2 -0
- package/dist/plugins/mcp/client/index.mjs +36 -11
- package/dist/plugins/mcp/index.d.mts +10 -11
- package/dist/plugins/multi-session/client.d.mts +2 -4
- package/dist/plugins/multi-session/client.mjs +1 -1
- package/dist/plugins/multi-session/error-codes.d.mts +1 -3
- package/dist/plugins/multi-session/index.d.mts +7 -11
- package/dist/plugins/multi-session/index.mjs +45 -0
- package/dist/plugins/oauth-popup/client.d.mts +6 -12
- package/dist/plugins/oauth-popup/client.mjs +5 -3
- package/dist/plugins/oauth-popup/error-codes.d.mts +4 -6
- package/dist/plugins/oauth-popup/index.d.mts +8 -12
- package/dist/plugins/oauth-popup/index.mjs +1 -1
- package/dist/plugins/oauth-popup/types.d.mts +1 -2
- package/dist/plugins/oauth-proxy/index.d.mts +6 -9
- package/dist/plugins/oauth-proxy/index.mjs +2 -2
- package/dist/plugins/oidc-provider/authorize.mjs +9 -0
- package/dist/plugins/oidc-provider/client.d.mts +1 -2
- package/dist/plugins/oidc-provider/index.d.mts +15 -17
- package/dist/plugins/oidc-provider/index.mjs +26 -2
- package/dist/plugins/oidc-provider/schema.d.mts +0 -1
- package/dist/plugins/oidc-provider/schema.mjs +37 -0
- package/dist/plugins/oidc-provider/types.d.mts +1 -1
- package/dist/plugins/one-tap/client.d.mts +3 -6
- package/dist/plugins/one-tap/client.mjs +3 -0
- package/dist/plugins/one-tap/index.d.mts +1 -3
- package/dist/plugins/one-tap/index.mjs +5 -0
- package/dist/plugins/one-time-token/client.d.mts +1 -2
- package/dist/plugins/one-time-token/index.d.mts +5 -6
- package/dist/plugins/one-time-token/index.mjs +30 -0
- package/dist/plugins/open-api/generator.d.mts +0 -1
- package/dist/plugins/open-api/generator.mjs +81 -5
- package/dist/plugins/open-api/index.d.mts +3 -5
- package/dist/plugins/organization/access/statement.d.mts +1 -0
- package/dist/plugins/organization/adapter.d.mts +56 -82
- package/dist/plugins/organization/adapter.mjs +17 -3
- package/dist/plugins/organization/client.d.mts +106 -105
- package/dist/plugins/organization/client.mjs +7 -4
- package/dist/plugins/organization/error-codes.d.mts +59 -61
- package/dist/plugins/organization/has-permission.d.mts +0 -1
- package/dist/plugins/organization/has-permission.mjs +1 -1
- package/dist/plugins/organization/index.d.mts +1 -1
- package/dist/plugins/organization/organization.d.mts +7 -7
- package/dist/plugins/organization/organization.mjs +434 -1
- package/dist/plugins/organization/permission.d.mts +2 -2
- package/dist/plugins/organization/routes/crud-access-control.d.mts +17 -17
- package/dist/plugins/organization/routes/crud-invites.d.mts +53 -54
- package/dist/plugins/organization/routes/crud-invites.mjs +1 -1
- package/dist/plugins/organization/routes/crud-members.d.mts +44 -46
- package/dist/plugins/organization/routes/crud-members.mjs +4 -1
- package/dist/plugins/organization/routes/crud-org.d.mts +47 -48
- package/dist/plugins/organization/routes/crud-org.mjs +2 -2
- package/dist/plugins/organization/routes/crud-team.d.mts +50 -51
- package/dist/plugins/organization/schema.d.mts +4 -4
- package/dist/plugins/organization/schema.mjs +1 -1
- package/dist/plugins/organization/types.d.mts +16 -16
- package/dist/plugins/phone-number/client.d.mts +13 -15
- package/dist/plugins/phone-number/client.mjs +1 -1
- package/dist/plugins/phone-number/error-codes.d.mts +12 -14
- package/dist/plugins/phone-number/index.d.mts +41 -47
- package/dist/plugins/phone-number/routes.mjs +15 -0
- package/dist/plugins/phone-number/types.d.mts +1 -1
- package/dist/plugins/siwe/client.d.mts +0 -1
- package/dist/plugins/siwe/index.d.mts +4 -5
- package/dist/plugins/test-utils/index.d.mts +2 -4
- package/dist/plugins/test-utils/types.d.mts +1 -0
- package/dist/plugins/two-factor/backup-codes/index.d.mts +4 -6
- package/dist/plugins/two-factor/backup-codes/index.mjs +52 -1
- package/dist/plugins/two-factor/client.d.mts +12 -15
- package/dist/plugins/two-factor/client.mjs +1 -1
- package/dist/plugins/two-factor/error-code.d.mts +10 -12
- package/dist/plugins/two-factor/index.d.mts +27 -31
- package/dist/plugins/two-factor/index.mjs +30 -0
- package/dist/plugins/two-factor/otp/index.d.mts +2 -4
- package/dist/plugins/two-factor/otp/index.mjs +42 -1
- package/dist/plugins/two-factor/totp/index.d.mts +4 -6
- package/dist/plugins/two-factor/totp/index.mjs +47 -0
- package/dist/plugins/two-factor/types.d.mts +1 -1
- package/dist/plugins/username/client.d.mts +9 -11
- package/dist/plugins/username/client.mjs +1 -1
- package/dist/plugins/username/error-codes.d.mts +8 -10
- package/dist/plugins/username/index.d.mts +17 -22
- package/dist/plugins/username/schema.d.mts +3 -5
- package/dist/state.d.mts +0 -1
- package/dist/state.mjs +4 -0
- package/dist/test-utils/test-instance.d.mts +5 -3
- package/dist/test-utils/test-instance.mjs +4 -1
- package/dist/types/adapter.d.mts +1 -1
- package/dist/types/api.d.mts +1 -2
- package/dist/types/auth.d.mts +0 -1
- package/dist/types/helper.d.mts +5 -5
- package/dist/types/index.d.mts +2 -2
- package/dist/types/models.d.mts +0 -1
- package/dist/types/plugins.d.mts +2 -3
- package/dist/utils/index.d.mts +2 -1
- package/dist/utils/request.mjs +23 -0
- package/dist/utils/url.d.mts +0 -1
- package/package.json +10 -10
|
@@ -3,12 +3,11 @@ import { InferAdditionalFromClient, InferSessionFromClient, InferUserFromClient
|
|
|
3
3
|
import { BetterAuthClientOptions, ClientFetchOption } from "@better-auth/core";
|
|
4
4
|
import { Endpoint, InputContext, StandardSchemaV1 } from "better-call";
|
|
5
5
|
import { BetterFetchResponse } from "@better-fetch/fetch";
|
|
6
|
-
|
|
7
6
|
//#region src/client/path-to-object.d.ts
|
|
8
7
|
type KeepNullishFromOriginal<Original, Replaced> = Replaced | (undefined extends Original ? undefined : never) | (null extends Original ? null : never);
|
|
9
|
-
type ReplaceTopLevelField<Data, Field extends "user" | "session", Replaced> = Data extends object ? Field extends keyof Data ? Omit<Data, Field> & { [K in Field]: KeepNullishFromOriginal<Data[K], Replaced
|
|
8
|
+
type ReplaceTopLevelField<Data, Field extends "user" | "session", Replaced> = Data extends object ? Field extends keyof Data ? Omit<Data, Field> & { [K in Field]: KeepNullishFromOriginal<Data[K], Replaced>; } : Data : Data;
|
|
10
9
|
type ReplaceAuthUserAndSession<Data, ClientOpts extends BetterAuthClientOptions> = ReplaceTopLevelField<ReplaceTopLevelField<Data, "user", InferUserFromClient<ClientOpts>>, "session", InferSessionFromClient<ClientOpts>>;
|
|
11
|
-
type MergeCustomSessionField<R extends object, Field extends "user" | "session", InferType> = Field extends keyof R ? { [K in Field]: KeepNullishFromOriginal<R[K], NonNullable<R[K]> & InferType
|
|
10
|
+
type MergeCustomSessionField<R extends object, Field extends "user" | "session", InferType> = Field extends keyof R ? { [K in Field]: KeepNullishFromOriginal<R[K], NonNullable<R[K]> & InferType>; } : {};
|
|
12
11
|
type MergeCustomSessionWithInferred<R, ClientOpts extends BetterAuthClientOptions> = R extends object ? Omit<R, "user" | "session"> & MergeCustomSessionField<R, "user", InferUserFromClient<ClientOpts>> & MergeCustomSessionField<R, "session", InferSessionFromClient<ClientOpts>> : never;
|
|
13
12
|
type RefineAuthResponse<Data, ClientOpts extends BetterAuthClientOptions> = Data extends {
|
|
14
13
|
token: unknown;
|
|
@@ -16,7 +15,7 @@ type RefineAuthResponse<Data, ClientOpts extends BetterAuthClientOptions> = Data
|
|
|
16
15
|
redirect: unknown;
|
|
17
16
|
} ? ReplaceAuthUserAndSession<Data, ClientOpts> : Data;
|
|
18
17
|
type CamelCase<S extends string> = S extends `${infer P1}-${infer P2}${infer P3}` ? `${Lowercase<P1>}${Uppercase<P2>}${CamelCase<P3>}` : Lowercase<S>;
|
|
19
|
-
type PathToObject<T extends string, Fn extends (...args: any[]) => any> = T extends `/${infer Segment}/${infer Rest}` ? { [K in CamelCase<Segment>]: PathToObject<`/${Rest}`, Fn
|
|
18
|
+
type PathToObject<T extends string, Fn extends (...args: any[]) => any> = T extends `/${infer Segment}/${infer Rest}` ? { [K in CamelCase<Segment>]: PathToObject<`/${Rest}`, Fn>; } : T extends `/${infer Segment}` ? { [K in CamelCase<Segment>]: Fn; } : never;
|
|
20
19
|
type InferSignUpEmailCtx<ClientOpts extends BetterAuthClientOptions, FetchOptions extends ClientFetchOption> = {
|
|
21
20
|
email: string;
|
|
22
21
|
name: string;
|
|
@@ -14,6 +14,7 @@ import { MicrosoftEntraIdOptions, microsoftEntraId } from "../../plugins/generic
|
|
|
14
14
|
import { OktaOptions, okta } from "../../plugins/generic-oauth/providers/okta.mjs";
|
|
15
15
|
import { PatreonOptions, patreon } from "../../plugins/generic-oauth/providers/patreon.mjs";
|
|
16
16
|
import { SlackOptions, slack } from "../../plugins/generic-oauth/providers/slack.mjs";
|
|
17
|
+
import { YandexOptions, yandex } from "../../plugins/generic-oauth/providers/yandex.mjs";
|
|
17
18
|
import { BaseOAuthProviderOptions } from "../../plugins/generic-oauth/index.mjs";
|
|
18
19
|
import { JWKOptions, JWSAlgorithms, Jwk, JwtOptions } from "../../plugins/jwt/types.mjs";
|
|
19
20
|
import { AuthorizationQuery, Client, CodeVerificationValue, OAuthAccessToken, OIDCMetadata, OIDCOptions, TokenBody } from "../../plugins/oidc-provider/types.mjs";
|
|
@@ -56,4 +57,4 @@ import { phoneNumberClient } from "../../plugins/phone-number/client.mjs";
|
|
|
56
57
|
import { siweClient } from "../../plugins/siwe/client.mjs";
|
|
57
58
|
import { usernameClient } from "../../plugins/username/client.mjs";
|
|
58
59
|
import { InferServerPlugin } from "./infer-plugin.mjs";
|
|
59
|
-
export { ADMIN_ERROR_CODES, ANONYMOUS_ERROR_CODES, AdminClientOptions, AdminOptions, AnonymousOptions, AnonymousSession, Auth0Options, AuthorizationQuery, BackupCodeOptions, BaseOAuthProviderOptions, Client, CodeVerificationValue, EMAIL_OTP_ERROR_CODES, ExtractPluginField, type FieldAttributeToObject, GENERIC_OAUTH_ERROR_CODES, GenericOAuthConfig, GenericOAuthOptions, GoogleOneTapActionOptions, GoogleOneTapOptions, GsiButtonConfiguration, GumroadOptions, HasRequiredKeys, HubSpotOptions, InferAdminRolesFromOption, InferInvitation, InferMember, InferOrganization, InferOrganizationRolesFromOption, InferOrganizationZodRolesFromOption, InferPluginFieldFromTuple, InferServerPlugin, InferTeam, Invitation, InvitationInput, InvitationStatus, IsAny, JWKOptions, JWSAlgorithms, Jwk, JwtOptions, KeycloakOptions, LastLoginMethodClientConfig, LineOptions, MULTI_SESSION_ERROR_CODES, Member, MemberInput, MicrosoftEntraIdOptions, MultiSessionConfig, OAUTH_POPUP_ERROR_CODES, OAuthAccessToken, OIDCMetadata, OIDCOptions, ORGANIZATION_ERROR_CODES, OTPOptions, OidcClientPlugin, OktaOptions, OneTimeTokenOptions, Organization, OrganizationClientOptions, OrganizationInput, OrganizationRole, OrganizationSchema, OverrideMerge, PHONE_NUMBER_ERROR_CODES, POPUP_TOKEN_STORAGE_KEY, PatreonOptions, PhoneNumberOptions, Prettify, PrettifyDeep, type RemoveFieldsWithReturnedFalse, RequiredKeysOf, SessionWithImpersonatedBy, SignInPopupOptions, SignInPopupResult, SlackOptions, StripEmptyObjects, TOTPOptions, TWO_FACTOR_ERROR_CODES, Team, TeamInput, TeamMember, TeamMemberInput, TokenBody, TwoFactorOptions, TwoFactorProvider, TwoFactorTable, USERNAME_ERROR_CODES, UnionToIntersection, UserWithAnonymous, UserWithPhoneNumber, UserWithRole, UserWithTwoFactor, adminClient, anonymousClient, auth0, backupCode2fa, clientSideHasPermission, createSignInPopup, customSessionClient, defaultRolesSchema, deviceAuthorizationClient, emailOTPClient, encodeBackupCodes, generateBackupCodes, genericOAuthClient, getBackupCodes, getStoredPopupToken, gumroad, hubspot, inferAdditionalFields, inferOrgAdditionalFields, invitationSchema, invitationStatus, jwtClient, keycloak, lastLoginMethodClient, line, magicLinkClient, memberSchema, microsoftEntraId, multiSessionClient, oauthPopupClient, oidcClient, okta, oneTapClient, oneTimeTokenClient, organizationClient, organizationRoleSchema, organizationSchema, otp2fa, patreon, phoneNumberClient, popupBearerFetchPlugin, roleSchema, schema, siweClient, slack, teamMemberSchema, teamSchema, totp2fa, twoFactorClient, usernameClient, verifyBackupCode };
|
|
60
|
+
export { ADMIN_ERROR_CODES, ANONYMOUS_ERROR_CODES, AdminClientOptions, type AdminOptions, type AnonymousOptions, type AnonymousSession, type Auth0Options, type AuthorizationQuery, type BackupCodeOptions, type BaseOAuthProviderOptions, type Client, type CodeVerificationValue, EMAIL_OTP_ERROR_CODES, type ExtractPluginField, type FieldAttributeToObject, GENERIC_OAUTH_ERROR_CODES, type GenericOAuthConfig, type GenericOAuthOptions, GoogleOneTapActionOptions, GoogleOneTapOptions, GsiButtonConfiguration, type GumroadOptions, type HasRequiredKeys, type HubSpotOptions, type InferAdminRolesFromOption, type InferInvitation, type InferMember, type InferOrganization, type InferOrganizationRolesFromOption, type InferOrganizationZodRolesFromOption, type InferPluginFieldFromTuple, InferServerPlugin, type InferTeam, type Invitation, type InvitationInput, type InvitationStatus, type IsAny, type JWKOptions, type JWSAlgorithms, type Jwk, type JwtOptions, type KeycloakOptions, LastLoginMethodClientConfig, type LineOptions, MULTI_SESSION_ERROR_CODES, type Member, type MemberInput, type MicrosoftEntraIdOptions, type MultiSessionConfig, OAUTH_POPUP_ERROR_CODES, type OAuthAccessToken, type OIDCMetadata, type OIDCOptions, ORGANIZATION_ERROR_CODES, type OTPOptions, OidcClientPlugin, type OktaOptions, type OneTimeTokenOptions, type Organization, OrganizationClientOptions, type OrganizationInput, type OrganizationRole, type OrganizationSchema, type OverrideMerge, PHONE_NUMBER_ERROR_CODES, POPUP_TOKEN_STORAGE_KEY, type PatreonOptions, type PhoneNumberOptions, type Prettify, type PrettifyDeep, type RemoveFieldsWithReturnedFalse, type RequiredKeysOf, type SessionWithImpersonatedBy, SignInPopupOptions, SignInPopupResult, type SlackOptions, type StripEmptyObjects, type TOTPOptions, TWO_FACTOR_ERROR_CODES, type Team, type TeamInput, type TeamMember, type TeamMemberInput, type TokenBody, type TwoFactorOptions, type TwoFactorProvider, type TwoFactorTable, USERNAME_ERROR_CODES, type UnionToIntersection, type UserWithAnonymous, type UserWithPhoneNumber, type UserWithRole, type UserWithTwoFactor, type YandexOptions, adminClient, anonymousClient, type auth0, type backupCode2fa, clientSideHasPermission, createSignInPopup, customSessionClient, type defaultRolesSchema, deviceAuthorizationClient, emailOTPClient, type encodeBackupCodes, type generateBackupCodes, genericOAuthClient, type getBackupCodes, getStoredPopupToken, type gumroad, type hubspot, inferAdditionalFields, inferOrgAdditionalFields, type invitationSchema, type invitationStatus, jwtClient, type keycloak, lastLoginMethodClient, type line, magicLinkClient, type memberSchema, type microsoftEntraId, multiSessionClient, oauthPopupClient, oidcClient, type okta, oneTapClient, oneTimeTokenClient, organizationClient, type organizationRoleSchema, type organizationSchema, type otp2fa, type patreon, phoneNumberClient, popupBearerFetchPlugin, type roleSchema, type schema, siweClient, type slack, type teamMemberSchema, type teamSchema, type totp2fa, twoFactorClient, usernameClient, type verifyBackupCode, type yandex };
|
package/dist/client/query.d.mts
CHANGED
|
@@ -2,7 +2,6 @@ import { SessionQueryParams } from "./types.mjs";
|
|
|
2
2
|
import { ClientFetchOption } from "@better-auth/core";
|
|
3
3
|
import { PreinitializedWritableAtom } from "nanostores";
|
|
4
4
|
import { BetterFetch, BetterFetchError } from "@better-fetch/fetch";
|
|
5
|
-
|
|
6
5
|
//#region src/client/query.d.ts
|
|
7
6
|
type AuthQueryState<T> = {
|
|
8
7
|
data: null | T;
|
package/dist/client/query.mjs
CHANGED
|
@@ -79,27 +79,45 @@ const useAuthQuery = (initializedAtom, path, $fetch, options) => {
|
|
|
79
79
|
});
|
|
80
80
|
};
|
|
81
81
|
initializedAtom = Array.isArray(initializedAtom) ? initializedAtom : [initializedAtom];
|
|
82
|
-
let
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
for (const u of cleanups) u();
|
|
97
|
-
clearTimeout(timeoutId);
|
|
98
|
-
};
|
|
99
|
-
});
|
|
82
|
+
let isMountFetchPending = false;
|
|
83
|
+
let isMounted = false;
|
|
84
|
+
let shouldRefetchAfterPending = false;
|
|
85
|
+
const fetchOnMount = () => {
|
|
86
|
+
if (isMountFetchPending) {
|
|
87
|
+
shouldRefetchAfterPending = true;
|
|
88
|
+
return;
|
|
89
|
+
}
|
|
90
|
+
isMountFetchPending = true;
|
|
91
|
+
fn().finally(() => {
|
|
92
|
+
isMountFetchPending = false;
|
|
93
|
+
const shouldRefetch = shouldRefetchAfterPending && isMounted;
|
|
94
|
+
shouldRefetchAfterPending = false;
|
|
95
|
+
if (shouldRefetch) fetchOnMount();
|
|
100
96
|
});
|
|
101
|
-
|
|
102
|
-
|
|
97
|
+
};
|
|
98
|
+
onMount(value, () => {
|
|
99
|
+
if (isServer()) return;
|
|
100
|
+
isMounted = true;
|
|
101
|
+
let isInitialized = false;
|
|
102
|
+
let timeoutId;
|
|
103
|
+
const cleanups = initializedAtom.map((initAtom) => initAtom.listen(() => {
|
|
104
|
+
if (isInitialized) fn();
|
|
105
|
+
else {
|
|
106
|
+
isInitialized = true;
|
|
107
|
+
clearTimeout(timeoutId);
|
|
108
|
+
fetchOnMount();
|
|
109
|
+
}
|
|
110
|
+
}));
|
|
111
|
+
timeoutId = setTimeout(() => {
|
|
112
|
+
isInitialized = true;
|
|
113
|
+
fetchOnMount();
|
|
114
|
+
}, 0);
|
|
115
|
+
return () => {
|
|
116
|
+
isMounted = false;
|
|
117
|
+
for (const cleanup of cleanups) cleanup();
|
|
118
|
+
clearTimeout(timeoutId);
|
|
119
|
+
};
|
|
120
|
+
});
|
|
103
121
|
return value;
|
|
104
122
|
};
|
|
105
123
|
//#endregion
|
|
@@ -5,15 +5,14 @@ import { useStore } from "./react-store.mjs";
|
|
|
5
5
|
import { BetterAuthClientOptions } from "@better-auth/core";
|
|
6
6
|
import { BASE_ERROR_CODES } from "@better-auth/core/error";
|
|
7
7
|
import { BetterFetchError, BetterFetchResponse } from "@better-fetch/fetch";
|
|
8
|
-
export * from "nanostores";
|
|
9
|
-
export * from "@better-fetch/fetch";
|
|
10
|
-
|
|
8
|
+
export type * from "nanostores";
|
|
9
|
+
export type * from "@better-fetch/fetch";
|
|
11
10
|
//#region src/client/react/index.d.ts
|
|
12
11
|
type InferResolvedHooks<O extends BetterAuthClientOptions> = O extends {
|
|
13
12
|
plugins: Array<infer Plugin>;
|
|
14
13
|
} ? UnionToIntersection<Plugin extends {
|
|
15
14
|
getAtoms?: infer GetAtoms;
|
|
16
|
-
} ? GetAtoms extends ((fetch: any) => infer Atoms) ? Atoms extends Record<string, any> ? { [key in keyof Atoms as IsSignal<key> extends true ? never : key extends string ? `use${Capitalize<key>}` : never]: () => ReturnType<Atoms[key]["get"]
|
|
15
|
+
} ? GetAtoms extends ((fetch: any) => infer Atoms) ? Atoms extends Record<string, any> ? { [key in keyof Atoms as IsSignal<key> extends true ? never : key extends string ? `use${Capitalize<key>}` : never]: () => ReturnType<Atoms[key]["get"]>; } : {} : {} : {}> : {};
|
|
17
16
|
type ClientConfig = ReturnType<typeof getClientConfig>;
|
|
18
17
|
type ClientSession<Option extends BetterAuthClientOptions> = InferClientAPI<Option> extends {
|
|
19
18
|
getSession: () => Promise<infer Res>;
|
|
@@ -40,4 +39,4 @@ type ReactAuthClient<Option extends BetterAuthClientOptions> = UnionToIntersecti
|
|
|
40
39
|
};
|
|
41
40
|
declare function createAuthClient<Option extends BetterAuthClientOptions>(options?: Option | undefined): ReactAuthClient<Option>;
|
|
42
41
|
//#endregion
|
|
43
|
-
export { ExtractPluginField, HasRequiredKeys, InferPluginFieldFromTuple, IsAny, OverrideMerge, Prettify, PrettifyDeep, ReactAuthClient, RequiredKeysOf, StripEmptyObjects, type UnionToIntersection, createAuthClient, useStore };
|
|
42
|
+
export { type ExtractPluginField, type HasRequiredKeys, type InferPluginFieldFromTuple, type IsAny, type OverrideMerge, type Prettify, type PrettifyDeep, ReactAuthClient, type RequiredKeysOf, type StripEmptyObjects, type UnionToIntersection, createAuthClient, useStore };
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { Store, StoreValue } from "nanostores";
|
|
2
2
|
import { DependencyList } from "react";
|
|
3
|
-
|
|
4
3
|
//#region src/client/react/react-store.d.ts
|
|
5
4
|
type StoreKeys<T> = T extends {
|
|
6
5
|
setKey: (k: infer K, v: any) => unknown;
|
|
@@ -43,4 +42,4 @@ interface UseStoreOptions<SomeStore> {
|
|
|
43
42
|
*/
|
|
44
43
|
declare function useStore<SomeStore extends Store>(store: SomeStore, options?: UseStoreOptions<SomeStore>): StoreValue<SomeStore>;
|
|
45
44
|
//#endregion
|
|
46
|
-
export { useStore };
|
|
45
|
+
export { UseStoreOptions, useStore };
|
|
@@ -5,19 +5,18 @@ import { BetterAuthClientOptions } from "@better-auth/core";
|
|
|
5
5
|
import { BASE_ERROR_CODES } from "@better-auth/core/error";
|
|
6
6
|
import { BetterFetchError, BetterFetchResponse } from "@better-fetch/fetch";
|
|
7
7
|
import { Accessor } from "solid-js";
|
|
8
|
-
export * from "nanostores";
|
|
9
|
-
export * from "@better-fetch/fetch";
|
|
10
|
-
|
|
8
|
+
export type * from "nanostores";
|
|
9
|
+
export type * from "@better-fetch/fetch";
|
|
11
10
|
//#region src/client/solid/index.d.ts
|
|
12
11
|
type InferResolvedHooks<O extends BetterAuthClientOptions> = O extends {
|
|
13
12
|
plugins: Array<infer Plugin>;
|
|
14
13
|
} ? UnionToIntersection<Plugin extends {
|
|
15
14
|
getAtoms?: infer GetAtoms;
|
|
16
|
-
} ? GetAtoms extends ((fetch: any) => infer Atoms) ? Atoms extends Record<string, any> ? { [key in keyof Atoms as IsSignal<key> extends true ? never : key extends string ? `use${Capitalize<key>}` : never]: () => Accessor<ReturnType<Atoms[key]["get"]
|
|
15
|
+
} ? GetAtoms extends ((fetch: any) => infer Atoms) ? Atoms extends Record<string, any> ? { [key in keyof Atoms as IsSignal<key> extends true ? never : key extends string ? `use${Capitalize<key>}` : never]: () => Accessor<ReturnType<Atoms[key]["get"]>>; } : {} : {} : {}> : {};
|
|
17
16
|
type ClientConfig = ReturnType<typeof getClientConfig>;
|
|
18
17
|
type ClientSession<Option extends BetterAuthClientOptions> = InferClientAPI<Option> extends {
|
|
19
18
|
getSession: () => Promise<infer Res>;
|
|
20
|
-
} ? Res extends BetterFetchResponse<infer S> ? S : Res
|
|
19
|
+
} ? Res extends BetterFetchResponse<infer S> ? S : Res : never;
|
|
21
20
|
/**
|
|
22
21
|
* Solid client returned by `createAuthClient`.
|
|
23
22
|
*/
|
|
@@ -39,4 +38,4 @@ type SolidAuthClient<Option extends BetterAuthClientOptions> = UnionToIntersecti
|
|
|
39
38
|
};
|
|
40
39
|
declare function createAuthClient<Option extends BetterAuthClientOptions>(options?: Option | undefined): SolidAuthClient<Option>;
|
|
41
40
|
//#endregion
|
|
42
|
-
export { ExtractPluginField, HasRequiredKeys, InferPluginFieldFromTuple, IsAny, OverrideMerge, Prettify, PrettifyDeep, RequiredKeysOf, SolidAuthClient, StripEmptyObjects, type UnionToIntersection, createAuthClient };
|
|
41
|
+
export { type ExtractPluginField, type HasRequiredKeys, type InferPluginFieldFromTuple, type IsAny, type OverrideMerge, type Prettify, type PrettifyDeep, type RequiredKeysOf, SolidAuthClient, type StripEmptyObjects, type UnionToIntersection, createAuthClient };
|
|
@@ -5,19 +5,18 @@ import { BetterAuthClientOptions } from "@better-auth/core";
|
|
|
5
5
|
import { BASE_ERROR_CODES } from "@better-auth/core/error";
|
|
6
6
|
import { Atom } from "nanostores";
|
|
7
7
|
import { BetterFetchError, BetterFetchResponse } from "@better-fetch/fetch";
|
|
8
|
-
export * from "nanostores";
|
|
9
|
-
export * from "@better-fetch/fetch";
|
|
10
|
-
|
|
8
|
+
export type * from "nanostores";
|
|
9
|
+
export type * from "@better-fetch/fetch";
|
|
11
10
|
//#region src/client/svelte/index.d.ts
|
|
12
11
|
type InferResolvedHooks<O extends BetterAuthClientOptions> = O extends {
|
|
13
12
|
plugins: Array<infer Plugin>;
|
|
14
13
|
} ? UnionToIntersection<Plugin extends {
|
|
15
14
|
getAtoms?: infer GetAtoms;
|
|
16
|
-
} ? GetAtoms extends ((fetch: any) => infer Atoms) ? Atoms extends Record<string, any> ? { [key in keyof Atoms as IsSignal<key> extends true ? never : key extends string ? `use${Capitalize<key>}` : never]: () => Atoms[key] } : {} : {} : {}> : {};
|
|
15
|
+
} ? GetAtoms extends ((fetch: any) => infer Atoms) ? Atoms extends Record<string, any> ? { [key in keyof Atoms as IsSignal<key> extends true ? never : key extends string ? `use${Capitalize<key>}` : never]: () => Atoms[key]; } : {} : {} : {}> : {};
|
|
17
16
|
type ClientConfig = ReturnType<typeof getClientConfig>;
|
|
18
17
|
type ClientSession<Option extends BetterAuthClientOptions> = InferClientAPI<Option> extends {
|
|
19
18
|
getSession: () => Promise<infer Res>;
|
|
20
|
-
} ? Res extends BetterFetchResponse<infer S> ? S : Res
|
|
19
|
+
} ? Res extends BetterFetchResponse<infer S> ? S : Res : never;
|
|
21
20
|
/**
|
|
22
21
|
* Svelte client returned by `createAuthClient`.
|
|
23
22
|
*/
|
|
@@ -40,4 +39,4 @@ type SvelteAuthClient<Option extends BetterAuthClientOptions> = UnionToIntersect
|
|
|
40
39
|
};
|
|
41
40
|
declare function createAuthClient<Option extends BetterAuthClientOptions>(options?: Option | undefined): SvelteAuthClient<Option>;
|
|
42
41
|
//#endregion
|
|
43
|
-
export { ExtractPluginField, HasRequiredKeys, InferPluginFieldFromTuple, IsAny, OverrideMerge, Prettify, PrettifyDeep, RequiredKeysOf, StripEmptyObjects, SvelteAuthClient, type UnionToIntersection, createAuthClient };
|
|
42
|
+
export { type ExtractPluginField, type HasRequiredKeys, type InferPluginFieldFromTuple, type IsAny, type OverrideMerge, type Prettify, type PrettifyDeep, type RequiredKeysOf, type StripEmptyObjects, SvelteAuthClient, type UnionToIntersection, createAuthClient };
|
package/dist/client/types.d.mts
CHANGED
|
@@ -3,9 +3,9 @@ import { StripEmptyObjects, UnionToIntersection } from "../types/helper.mjs";
|
|
|
3
3
|
import { InferRoutes } from "./path-to-object.mjs";
|
|
4
4
|
import { Session as Session$1, User as User$1 } from "../types/models.mjs";
|
|
5
5
|
import { Auth } from "../types/auth.mjs";
|
|
6
|
+
import "../types/index.mjs";
|
|
6
7
|
import { BetterAuthClientOptions as BetterAuthClientOptions$1, BetterAuthClientPlugin, ClientAtomListener as ClientAtomListener$1, ClientStore as ClientStore$1 } from "@better-auth/core";
|
|
7
8
|
import { DBFieldAttribute, InferDBFieldsOutput } from "@better-auth/core/db";
|
|
8
|
-
|
|
9
9
|
//#region src/client/types.d.ts
|
|
10
10
|
type ClientPluginError<K extends string = string> = {
|
|
11
11
|
readonly code: K;
|
|
@@ -28,7 +28,7 @@ type InferErrorCodes<O extends BetterAuthClientOptions$1> = O["plugins"] extends
|
|
|
28
28
|
$InferServerPlugin?: infer ServerPlugin;
|
|
29
29
|
} ? ServerPlugin extends {
|
|
30
30
|
$ERROR_CODES?: infer E;
|
|
31
|
-
} ? { [K in keyof E & string]: E[K] extends ClientPluginError ? ClientPluginError<K> : never } : {} : {}> : {};
|
|
31
|
+
} ? { [K in keyof E & string]: E[K] extends ClientPluginError ? ClientPluginError<K> : never; } : {} : {}> : {};
|
|
32
32
|
/**
|
|
33
33
|
* signals are just used to recall a computed value.
|
|
34
34
|
* as a convention they start with "$"
|
|
@@ -5,17 +5,16 @@ import { BetterAuthClientOptions } from "@better-auth/core";
|
|
|
5
5
|
import { BASE_ERROR_CODES } from "@better-auth/core/error";
|
|
6
6
|
import { Atom } from "nanostores";
|
|
7
7
|
import { BetterFetchError, BetterFetchResponse } from "@better-fetch/fetch";
|
|
8
|
-
|
|
9
8
|
//#region src/client/vanilla.d.ts
|
|
10
9
|
type InferResolvedHooks<O extends BetterAuthClientOptions> = O extends {
|
|
11
10
|
plugins: Array<infer Plugin>;
|
|
12
11
|
} ? UnionToIntersection<Plugin extends {
|
|
13
12
|
getAtoms?: infer GetAtoms;
|
|
14
|
-
} ? GetAtoms extends ((fetch: any) => infer Atoms) ? Atoms extends Record<string, any> ? { [key in keyof Atoms as IsSignal<key> extends true ? never : key extends string ? `use${Capitalize<key>}` : never]: Atoms[key] } : {} : {} : {}> : {};
|
|
13
|
+
} ? GetAtoms extends ((fetch: any) => infer Atoms) ? Atoms extends Record<string, any> ? { [key in keyof Atoms as IsSignal<key> extends true ? never : key extends string ? `use${Capitalize<key>}` : never]: Atoms[key]; } : {} : {} : {}> : {};
|
|
15
14
|
type ClientConfig = ReturnType<typeof getClientConfig>;
|
|
16
15
|
type ClientSession<Option extends BetterAuthClientOptions> = InferClientAPI<Option> extends {
|
|
17
16
|
getSession: () => Promise<infer Res>;
|
|
18
|
-
} ? Res extends BetterFetchResponse<infer S> ? S : Res
|
|
17
|
+
} ? Res extends BetterFetchResponse<infer S> ? S : Res : never;
|
|
19
18
|
/**
|
|
20
19
|
* Client returned by `createAuthClient`.
|
|
21
20
|
*/
|
|
@@ -5,19 +5,18 @@ import { BetterAuthClientOptions } from "@better-auth/core";
|
|
|
5
5
|
import { BASE_ERROR_CODES } from "@better-auth/core/error";
|
|
6
6
|
import { BetterFetchError, BetterFetchResponse } from "@better-fetch/fetch";
|
|
7
7
|
import { DeepReadonly, Ref } from "vue";
|
|
8
|
-
export * from "nanostores";
|
|
9
|
-
export * from "@better-fetch/fetch";
|
|
10
|
-
|
|
8
|
+
export type * from "nanostores";
|
|
9
|
+
export type * from "@better-fetch/fetch";
|
|
11
10
|
//#region src/client/vue/index.d.ts
|
|
12
11
|
type InferResolvedHooks<O extends BetterAuthClientOptions> = O extends {
|
|
13
12
|
plugins: Array<infer Plugin>;
|
|
14
13
|
} ? UnionToIntersection<Plugin extends {
|
|
15
14
|
getAtoms?: infer GetAtoms;
|
|
16
|
-
} ? GetAtoms extends ((fetch: any) => infer Atoms) ? Atoms extends Record<string, any> ? { [key in keyof Atoms as IsSignal<key> extends true ? never : key extends string ? `use${Capitalize<key>}` : never]: () => DeepReadonly<Ref<ReturnType<Atoms[key]["get"]
|
|
15
|
+
} ? GetAtoms extends ((fetch: any) => infer Atoms) ? Atoms extends Record<string, any> ? { [key in keyof Atoms as IsSignal<key> extends true ? never : key extends string ? `use${Capitalize<key>}` : never]: () => DeepReadonly<Ref<ReturnType<Atoms[key]["get"]>>>; } : {} : {} : {}> : {};
|
|
17
16
|
type ClientConfig = ReturnType<typeof getClientConfig>;
|
|
18
17
|
type ClientSession<Option extends BetterAuthClientOptions> = InferClientAPI<Option> extends {
|
|
19
18
|
getSession: () => Promise<infer Res>;
|
|
20
|
-
} ? Res extends BetterFetchResponse<infer S> ? S : Res
|
|
19
|
+
} ? Res extends BetterFetchResponse<infer S> ? S : Res : never;
|
|
21
20
|
type VueUseSession<Option extends BetterAuthClientOptions> = {
|
|
22
21
|
(): DeepReadonly<Ref<{
|
|
23
22
|
data: ClientSession<Option>;
|
|
@@ -52,4 +51,4 @@ type VueAuthClient<Option extends BetterAuthClientOptions> = UnionToIntersection
|
|
|
52
51
|
};
|
|
53
52
|
declare function createAuthClient<Option extends BetterAuthClientOptions>(options?: Option | undefined): VueAuthClient<Option>;
|
|
54
53
|
//#endregion
|
|
55
|
-
export { ExtractPluginField, HasRequiredKeys, InferPluginFieldFromTuple, IsAny, OverrideMerge, Prettify, PrettifyDeep, RequiredKeysOf, StripEmptyObjects, type UnionToIntersection, VueAuthClient, createAuthClient };
|
|
54
|
+
export { type ExtractPluginField, type HasRequiredKeys, type InferPluginFieldFromTuple, type IsAny, type OverrideMerge, type Prettify, type PrettifyDeep, type RequiredKeysOf, type StripEmptyObjects, type UnionToIntersection, VueAuthClient, createAuthClient };
|
|
@@ -18,7 +18,7 @@ import { generateId } from "@better-auth/core/utils/id";
|
|
|
18
18
|
import { socialProviders } from "@better-auth/core/social-providers";
|
|
19
19
|
import { findInvalidTrustedProxies } from "@better-auth/core/utils/ip";
|
|
20
20
|
import { createTelemetry } from "@better-auth/telemetry";
|
|
21
|
-
import defu
|
|
21
|
+
import defu from "defu";
|
|
22
22
|
//#region src/context/create-context.ts
|
|
23
23
|
/**
|
|
24
24
|
* Estimates the entropy of a string in bits.
|
|
@@ -45,13 +45,13 @@ function validateSecret(secret, logger) {
|
|
|
45
45
|
}
|
|
46
46
|
async function createAuthContext(adapter, options, getDatabaseType) {
|
|
47
47
|
const isStateful = hasServerSessionStore(options);
|
|
48
|
-
if (!isStateful) options = defu
|
|
48
|
+
if (!isStateful) options = defu(options, { session: { cookieCache: {
|
|
49
49
|
enabled: true,
|
|
50
50
|
strategy: "jwe",
|
|
51
51
|
refreshCache: true,
|
|
52
52
|
maxAge: options.session?.expiresIn || 3600 * 24 * 7
|
|
53
53
|
} } });
|
|
54
|
-
if (!options.database) options = defu
|
|
54
|
+
if (!options.database) options = defu(options, { account: { storeAccountCookie: true } });
|
|
55
55
|
const plugins = options.plugins || [];
|
|
56
56
|
const internalPlugins = getInternalPlugins(options);
|
|
57
57
|
const logger = createLogger(options.logger);
|
package/dist/context/helpers.mjs
CHANGED
|
@@ -4,7 +4,7 @@ import { createCookieGetter, getCookies } from "../cookies/index.mjs";
|
|
|
4
4
|
import { createInternalAdapter } from "../db/internal-adapter.mjs";
|
|
5
5
|
import { env } from "@better-auth/core/env";
|
|
6
6
|
import { BetterAuthError } from "@better-auth/core/error";
|
|
7
|
-
import { defu } from "defu";
|
|
7
|
+
import { defu as defu$1 } from "defu";
|
|
8
8
|
import { isLoopbackHost } from "@better-auth/core/utils/host";
|
|
9
9
|
//#region src/context/helpers.ts
|
|
10
10
|
async function runPluginInit(context) {
|
|
@@ -25,7 +25,7 @@ async function runPluginInit(context) {
|
|
|
25
25
|
hooks: databaseHooks
|
|
26
26
|
});
|
|
27
27
|
if (trustedOrigins) pluginTrustedOrigins.push(trustedOrigins);
|
|
28
|
-
options = defu(options, restOpts);
|
|
28
|
+
options = defu$1(options, restOpts);
|
|
29
29
|
}
|
|
30
30
|
if (result.context) Object.assign(context, result.context);
|
|
31
31
|
}
|
|
@@ -9,7 +9,7 @@ interface CookieAttributes {
|
|
|
9
9
|
httponly?: boolean | undefined;
|
|
10
10
|
partitioned?: boolean | undefined;
|
|
11
11
|
samesite?: ("strict" | "lax" | "none") | undefined;
|
|
12
|
-
[key: string]:
|
|
12
|
+
[key: string]: string | number | boolean | Date | undefined;
|
|
13
13
|
}
|
|
14
14
|
interface ParsedCookieOptions {
|
|
15
15
|
maxAge?: number | undefined;
|
package/dist/cookies/index.d.mts
CHANGED
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
import { Session, User } from "../types/models.mjs";
|
|
2
|
+
import "../types/index.mjs";
|
|
2
3
|
import { CookieAttributes, HOST_COOKIE_PREFIX, SECURE_COOKIE_PREFIX, applySetCookies, cookieNameRegex, parseCookies, parseSetCookieHeader, setCookieToHeader, setRequestCookie, splitSetCookieHeader, stripSecureCookiePrefix, toCookieOptions } from "./cookie-utils.mjs";
|
|
3
4
|
import { createSessionStore, getAccountCookie, getChunkedCookie } from "./session-store.mjs";
|
|
4
5
|
import { BetterAuthCookie, BetterAuthCookies, BetterAuthOptions, GenericEndpointContext } from "@better-auth/core";
|
|
5
|
-
import * as better_call0 from "better-call";
|
|
6
6
|
import { CookieOptions } from "better-call";
|
|
7
|
-
|
|
8
7
|
//#region src/cookies/index.d.ts
|
|
9
8
|
declare function createCookieGetter(options: BetterAuthOptions): (cookieName: string, overrideAttributes?: Partial<CookieOptions>) => {
|
|
10
9
|
name: string;
|
|
@@ -17,7 +16,7 @@ declare function createCookieGetter(options: BetterAuthOptions): (cookieName: st
|
|
|
17
16
|
secure: boolean;
|
|
18
17
|
sameSite: "Strict" | "Lax" | "None" | "strict" | "lax" | "none";
|
|
19
18
|
partitioned?: boolean;
|
|
20
|
-
prefix?:
|
|
19
|
+
prefix?: import("better-call").CookiePrefixOptions;
|
|
21
20
|
};
|
|
22
21
|
};
|
|
23
22
|
declare function getCookies(options: BetterAuthOptions): {
|
|
@@ -32,7 +31,7 @@ declare function getCookies(options: BetterAuthOptions): {
|
|
|
32
31
|
secure: boolean;
|
|
33
32
|
sameSite: "Strict" | "Lax" | "None" | "strict" | "lax" | "none";
|
|
34
33
|
partitioned?: boolean;
|
|
35
|
-
prefix?:
|
|
34
|
+
prefix?: import("better-call").CookiePrefixOptions;
|
|
36
35
|
};
|
|
37
36
|
};
|
|
38
37
|
/**
|
|
@@ -50,7 +49,7 @@ declare function getCookies(options: BetterAuthOptions): {
|
|
|
50
49
|
secure: boolean;
|
|
51
50
|
sameSite: "Strict" | "Lax" | "None" | "strict" | "lax" | "none";
|
|
52
51
|
partitioned?: boolean;
|
|
53
|
-
prefix?:
|
|
52
|
+
prefix?: import("better-call").CookiePrefixOptions;
|
|
54
53
|
};
|
|
55
54
|
};
|
|
56
55
|
dontRememberToken: {
|
|
@@ -64,7 +63,7 @@ declare function getCookies(options: BetterAuthOptions): {
|
|
|
64
63
|
secure: boolean;
|
|
65
64
|
sameSite: "Strict" | "Lax" | "None" | "strict" | "lax" | "none";
|
|
66
65
|
partitioned?: boolean;
|
|
67
|
-
prefix?:
|
|
66
|
+
prefix?: import("better-call").CookiePrefixOptions;
|
|
68
67
|
};
|
|
69
68
|
};
|
|
70
69
|
accountData: {
|
|
@@ -78,7 +77,7 @@ declare function getCookies(options: BetterAuthOptions): {
|
|
|
78
77
|
secure: boolean;
|
|
79
78
|
sameSite: "Strict" | "Lax" | "None" | "strict" | "lax" | "none";
|
|
80
79
|
partitioned?: boolean;
|
|
81
|
-
prefix?:
|
|
80
|
+
prefix?: import("better-call").CookiePrefixOptions;
|
|
82
81
|
};
|
|
83
82
|
};
|
|
84
83
|
};
|
package/dist/cookies/index.mjs
CHANGED
|
@@ -53,6 +53,10 @@ function getCookies(options) {
|
|
|
53
53
|
name: sessionToken.name,
|
|
54
54
|
attributes: sessionToken.attributes
|
|
55
55
|
},
|
|
56
|
+
/**
|
|
57
|
+
* This cookie is used to store the session data in the cookie
|
|
58
|
+
* This is useful for when you want to cache the session in the cookie
|
|
59
|
+
*/
|
|
56
60
|
sessionData: {
|
|
57
61
|
name: sessionData.name,
|
|
58
62
|
attributes: sessionData.attributes
|
|
@@ -24,7 +24,8 @@ const MAX_COOKIE_CHUNKS = 100;
|
|
|
24
24
|
* wire. Non-positive when the name and attributes alone overflow.
|
|
25
25
|
*/
|
|
26
26
|
function getMaxCookieValueSize(name, options) {
|
|
27
|
-
|
|
27
|
+
const overhead = serializeCookie(name, "", { ...options }).length;
|
|
28
|
+
return MAX_COOKIE_SIZE - overhead;
|
|
28
29
|
}
|
|
29
30
|
/**
|
|
30
31
|
* Read all existing chunks from cookies
|
|
@@ -161,6 +162,10 @@ async function getAccountCookie(c) {
|
|
|
161
162
|
return null;
|
|
162
163
|
}
|
|
163
164
|
const getSessionQuerySchema = z.optional(z.object({
|
|
165
|
+
/**
|
|
166
|
+
* If cookie cache is enabled, it will disable the cache
|
|
167
|
+
* and fetch the session from the database
|
|
168
|
+
*/
|
|
164
169
|
disableCookieCache: z.coerce.boolean().meta({ description: "Disable cookie cache and fetch session from database" }).optional(),
|
|
165
170
|
disableRefresh: z.coerce.boolean().meta({ description: "Disable session refresh. Useful for checking session status, without updating the session" }).optional()
|
|
166
171
|
}));
|
package/dist/crypto/index.d.mts
CHANGED
|
@@ -3,7 +3,6 @@ import { signJWT, symmetricDecodeJWT, symmetricEncodeJWT, verifyJWT } from "./jw
|
|
|
3
3
|
import { hashPassword, verifyPassword } from "./password.mjs";
|
|
4
4
|
import { generateRandomString } from "./random.mjs";
|
|
5
5
|
import { SecretConfig } from "@better-auth/core";
|
|
6
|
-
|
|
7
6
|
//#region src/crypto/index.d.ts
|
|
8
7
|
declare function parseEnvelope(data: string): {
|
|
9
8
|
version: number;
|
|
@@ -14,18 +13,12 @@ type SymmetricEncryptOptions = {
|
|
|
14
13
|
key: string | SecretConfig;
|
|
15
14
|
data: string;
|
|
16
15
|
};
|
|
17
|
-
declare const symmetricEncrypt: ({
|
|
18
|
-
key,
|
|
19
|
-
data
|
|
20
|
-
}: SymmetricEncryptOptions) => Promise<string>;
|
|
16
|
+
declare const symmetricEncrypt: ({ key, data }: SymmetricEncryptOptions) => Promise<string>;
|
|
21
17
|
type SymmetricDecryptOptions = {
|
|
22
18
|
key: string | SecretConfig;
|
|
23
19
|
data: string;
|
|
24
20
|
};
|
|
25
|
-
declare const symmetricDecrypt: ({
|
|
26
|
-
key,
|
|
27
|
-
data
|
|
28
|
-
}: SymmetricDecryptOptions) => Promise<string>;
|
|
21
|
+
declare const symmetricDecrypt: ({ key, data }: SymmetricDecryptOptions) => Promise<string>;
|
|
29
22
|
declare const getCryptoKey: (secret: string | BufferSource) => Promise<CryptoKey>;
|
|
30
23
|
declare const makeSignature: (value: string, secret: string | BufferSource) => Promise<string>;
|
|
31
24
|
//#endregion
|
package/dist/crypto/jwt.d.mts
CHANGED
|
@@ -1,11 +1,7 @@
|
|
|
1
1
|
import { hashPassword } from "@better-auth/utils/password";
|
|
2
|
-
|
|
3
2
|
//#region src/crypto/password.d.ts
|
|
4
3
|
declare const hashPassword$1: typeof hashPassword;
|
|
5
|
-
declare const verifyPassword$1: ({
|
|
6
|
-
hash,
|
|
7
|
-
password
|
|
8
|
-
}: {
|
|
4
|
+
declare const verifyPassword$1: ({ hash, password }: {
|
|
9
5
|
hash: string;
|
|
10
6
|
password: string;
|
|
11
7
|
}) => Promise<boolean>;
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { BetterAuthOptions } from "@better-auth/core";
|
|
2
2
|
import { DBAdapter } from "@better-auth/core/db/adapter";
|
|
3
|
-
|
|
4
3
|
//#region src/db/adapter-base.d.ts
|
|
5
4
|
declare function getBaseAdapter(options: BetterAuthOptions, handleDirectDatabase: (options: BetterAuthOptions) => Promise<DBAdapter<BetterAuthOptions>>): Promise<DBAdapter<BetterAuthOptions>>;
|
|
6
5
|
//#endregion
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { DBFieldAttribute } from "@better-auth/core/db";
|
|
2
|
-
|
|
3
2
|
//#region src/db/field-converter.d.ts
|
|
4
3
|
declare function convertToDB<T extends Record<string, any>>(fields: Record<string, DBFieldAttribute>, values: T): T;
|
|
5
4
|
declare function convertFromDB<T extends Record<string, any>>(fields: Record<string, DBFieldAttribute>, values: T | null): T | null;
|
package/dist/db/field.d.mts
CHANGED
|
@@ -1,22 +1,21 @@
|
|
|
1
1
|
import { DBFieldAttribute, InferDBValueType } from "@better-auth/core/db";
|
|
2
|
-
|
|
3
2
|
//#region src/db/field.d.ts
|
|
4
|
-
type InferFieldsOutput<Fields extends Record<string, DBFieldAttribute>> = Fields extends Record<infer Key, DBFieldAttribute> ? { [key in Key as Fields[key]["returned"] extends false ? never : Fields[key]["required"] extends false ? Fields[key]["defaultValue"] extends boolean | string | number | Date ? key : never : key]: InferFieldOutput<Fields[key]
|
|
3
|
+
type InferFieldsOutput<Fields extends Record<string, DBFieldAttribute>> = Fields extends Record<infer Key, DBFieldAttribute> ? { [key in Key as Fields[key]["returned"] extends false ? never : Fields[key]["required"] extends false ? Fields[key]["defaultValue"] extends boolean | string | number | Date ? key : never : key]: InferFieldOutput<Fields[key]>; } & { [key in Key as Fields[key]["returned"] extends false ? never : Fields[key]["required"] extends false ? Fields[key]["defaultValue"] extends boolean | string | number | Date ? never : key : never]?: InferFieldOutput<Fields[key]> | null; } : never;
|
|
5
4
|
/**
|
|
6
5
|
* For client will add "?" on optional fields
|
|
7
6
|
*/
|
|
8
|
-
type InferFieldsInputClient<Fields extends Record<string, DBFieldAttribute>> = Fields extends Record<infer Key, DBFieldAttribute> ? { [key in Key as Fields[key]["required"] extends false ? never : Fields[key]["defaultValue"] extends string | number | boolean | Date ? never : Fields[key]["input"] extends false ? never : key]: InferFieldInput<Fields[key]
|
|
7
|
+
type InferFieldsInputClient<Fields extends Record<string, DBFieldAttribute>> = Fields extends Record<infer Key, DBFieldAttribute> ? { [key in Key as Fields[key]["required"] extends false ? never : Fields[key]["defaultValue"] extends string | number | boolean | Date ? never : Fields[key]["input"] extends false ? never : key]: InferFieldInput<Fields[key]>; } & { [key in Key as Fields[key]["input"] extends false ? never : Fields[key]["required"] extends false ? key : Fields[key]["defaultValue"] extends string | number | boolean | Date ? key : never]?: InferFieldInput<Fields[key]> | undefined | null; } : never;
|
|
9
8
|
type InferFieldOutput<T extends DBFieldAttribute> = T["returned"] extends false ? never : T["required"] extends false ? InferDBValueType<T["type"]> | undefined | null : InferDBValueType<T["type"]>;
|
|
10
9
|
/**
|
|
11
10
|
* Converts a Record<string, DBFieldAttribute> to an object type
|
|
12
11
|
* with keys and value types inferred from DBFieldAttribute["type"].
|
|
13
12
|
*/
|
|
14
|
-
type FieldAttributeToObject<Fields extends Record<string, DBFieldAttribute>> = AddOptionalFields<{ [K in keyof Fields]: InferDBValueType<Fields[K]["type"]
|
|
13
|
+
type FieldAttributeToObject<Fields extends Record<string, DBFieldAttribute>> = AddOptionalFields<{ [K in keyof Fields]: InferDBValueType<Fields[K]["type"]>; }, Fields>;
|
|
15
14
|
type AddOptionalFields<T extends Record<string, any>, Fields extends Record<keyof T, DBFieldAttribute>> = { [K in keyof T as Fields[K] extends {
|
|
16
15
|
required: false;
|
|
17
|
-
} ? never : K]: T[K] } & { [K in keyof T as Fields[K] extends {
|
|
16
|
+
} ? never : K]: T[K]; } & { [K in keyof T as Fields[K] extends {
|
|
18
17
|
required: false;
|
|
19
|
-
} ? K : never]?: T[K] };
|
|
18
|
+
} ? K : never]?: T[K]; };
|
|
20
19
|
/**
|
|
21
20
|
* Infer the additional fields from the plugin options.
|
|
22
21
|
* For example, you can infer the additional fields of the org plugin's organization schema like this:
|
|
@@ -30,12 +29,12 @@ type AddOptionalFields<T extends Record<string, any>, Fields extends Record<keyo
|
|
|
30
29
|
type InferAdditionalFieldsFromPluginOptions<SchemaName extends string, Options extends {
|
|
31
30
|
schema?: { [key in SchemaName]?: {
|
|
32
31
|
additionalFields?: Record<string, DBFieldAttribute>;
|
|
33
|
-
} } | undefined;
|
|
32
|
+
}; } | undefined;
|
|
34
33
|
}, isClientSide extends boolean = true> = Options["schema"] extends { [key in SchemaName]?: {
|
|
35
34
|
additionalFields: infer Field extends Record<string, DBFieldAttribute>;
|
|
36
|
-
} } ? isClientSide extends true ? FieldAttributeToObject<RemoveFieldsWithInputFalse<Field>> : FieldAttributeToObject<Field> : {};
|
|
37
|
-
type RemoveFieldsWithInputFalse<T extends Record<string, DBFieldAttribute>> = { [K in keyof T as T[K]["input"] extends false ? never : K]: T[K] };
|
|
38
|
-
type RemoveFieldsWithReturnedFalse<T extends Record<string, DBFieldAttribute>> = { [K in keyof T as T[K]["returned"] extends false ? never : K]: T[K] };
|
|
35
|
+
}; } ? isClientSide extends true ? FieldAttributeToObject<RemoveFieldsWithInputFalse<Field>> : FieldAttributeToObject<Field> : {};
|
|
36
|
+
type RemoveFieldsWithInputFalse<T extends Record<string, DBFieldAttribute>> = { [K in keyof T as T[K]["input"] extends false ? never : K]: T[K]; };
|
|
37
|
+
type RemoveFieldsWithReturnedFalse<T extends Record<string, DBFieldAttribute>> = { [K in keyof T as T[K]["returned"] extends false ? never : K]: T[K]; };
|
|
39
38
|
type InferFieldInput<T extends DBFieldAttribute> = InferDBValueType<T["type"]>;
|
|
40
39
|
//#endregion
|
|
41
40
|
export { FieldAttributeToObject, InferAdditionalFieldsFromPluginOptions, InferFieldsInputClient, InferFieldsOutput, RemoveFieldsWithReturnedFalse };
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { BetterAuthOptions } from "@better-auth/core";
|
|
2
2
|
import { DBFieldAttribute, DBFieldType } from "@better-auth/core/db";
|
|
3
3
|
import { KyselyDatabaseType } from "@better-auth/kysely-adapter";
|
|
4
|
-
|
|
5
4
|
//#region src/db/get-migration.d.ts
|
|
6
5
|
declare function matchType(columnDataType: string, fieldType: DBFieldType, dbType: KyselyDatabaseType): boolean;
|
|
7
6
|
declare function getMigrations(config: BetterAuthOptions): Promise<{
|