better-auth 1.7.20 → 1.7.22
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/_virtual/_rolldown/runtime.mjs +1 -2
- package/dist/adapters/index.d.mts +0 -2
- package/dist/adapters/index.mjs +1 -2
- package/dist/api/dispatch.d.mts +1 -3
- package/dist/api/dispatch.mjs +1 -2
- package/dist/api/index.d.mts +5 -4
- package/dist/api/index.mjs +9 -9
- package/dist/api/middlewares/authorization.d.mts +1 -3
- package/dist/api/middlewares/authorization.mjs +1 -2
- package/dist/api/middlewares/origin-check.d.mts +1 -3
- package/dist/api/middlewares/origin-check.mjs +2 -3
- package/dist/api/rate-limiter/index.mjs +1 -2
- package/dist/api/routes/account.d.mts +1 -3
- package/dist/api/routes/account.mjs +10 -10
- package/dist/api/routes/callback.d.mts +1 -3
- package/dist/api/routes/callback.mjs +5 -6
- package/dist/api/routes/email-verification.d.mts +1 -3
- package/dist/api/routes/email-verification.mjs +4 -5
- package/dist/api/routes/error.d.mts +1 -3
- package/dist/api/routes/error.mjs +1 -2
- package/dist/api/routes/ok.d.mts +1 -3
- package/dist/api/routes/ok.mjs +1 -2
- package/dist/api/routes/password.d.mts +1 -3
- package/dist/api/routes/password.mjs +3 -4
- package/dist/api/routes/session.d.mts +2 -3
- package/dist/api/routes/session.mjs +10 -6
- package/dist/api/routes/sign-in.d.mts +0 -2
- package/dist/api/routes/sign-in.mjs +6 -7
- package/dist/api/routes/sign-out.d.mts +1 -3
- package/dist/api/routes/sign-out.mjs +1 -2
- package/dist/api/routes/sign-up.d.mts +1 -3
- package/dist/api/routes/sign-up.mjs +26 -16
- package/dist/api/routes/update-session.d.mts +1 -3
- package/dist/api/routes/update-session.mjs +2 -3
- package/dist/api/routes/update-user.d.mts +1 -3
- package/dist/api/routes/update-user.mjs +31 -28
- package/dist/api/state/oauth.d.mts +0 -2
- package/dist/api/state/oauth.mjs +1 -2
- package/dist/api/state/session-source.d.mts +1 -3
- package/dist/api/state/session-source.mjs +1 -2
- package/dist/api/state/should-session-refresh.d.mts +0 -2
- package/dist/api/state/should-session-refresh.mjs +1 -2
- package/dist/api/to-auth-endpoints.mjs +2 -3
- package/dist/auth/base.mjs +3 -9
- package/dist/auth/full.d.mts +1 -3
- package/dist/auth/full.mjs +1 -2
- package/dist/auth/minimal.d.mts +0 -2
- package/dist/auth/minimal.mjs +2 -3
- package/dist/auth/trusted-origins.mjs +2 -3
- package/dist/client/broadcast-channel.d.mts +1 -3
- package/dist/client/broadcast-channel.mjs +4 -4
- package/dist/client/config.d.mts +1 -3
- package/dist/client/config.mjs +2 -3
- package/dist/client/equality.d.mts +1 -3
- package/dist/client/equality.mjs +1 -2
- package/dist/client/fetch-plugins.mjs +1 -2
- package/dist/client/focus-manager.d.mts +1 -3
- package/dist/client/focus-manager.mjs +4 -4
- package/dist/client/index.d.mts +5 -7
- package/dist/client/index.mjs +1 -2
- package/dist/client/lynx/index.d.mts +1 -3
- package/dist/client/lynx/index.mjs +1 -2
- package/dist/client/lynx/lynx-store.d.mts +0 -2
- package/dist/client/lynx/lynx-store.mjs +1 -2
- package/dist/client/online-manager.d.mts +1 -3
- package/dist/client/online-manager.mjs +7 -7
- package/dist/client/parser.d.mts +0 -2
- package/dist/client/parser.mjs +1 -2
- package/dist/client/path-to-object.d.mts +0 -2
- package/dist/client/plugins/index.d.mts +6 -6
- package/dist/client/plugins/infer-plugin.d.mts +1 -3
- package/dist/client/plugins/infer-plugin.mjs +1 -2
- package/dist/client/proxy.mjs +1 -2
- package/dist/client/query-atom.mjs +1 -2
- package/dist/client/query.d.mts +1 -3
- package/dist/client/query.mjs +1 -2
- package/dist/client/react/index.d.mts +1 -3
- package/dist/client/react/index.mjs +1 -2
- package/dist/client/react/react-store.d.mts +0 -2
- package/dist/client/react/react-store.mjs +1 -2
- package/dist/client/session-atom.d.mts +1 -3
- package/dist/client/session-atom.mjs +2 -2
- package/dist/client/session-refresh.d.mts +1 -3
- package/dist/client/session-refresh.mjs +3 -3
- package/dist/client/solid/index.d.mts +1 -3
- package/dist/client/solid/index.mjs +1 -2
- package/dist/client/solid/solid-store.mjs +1 -2
- package/dist/client/svelte/index.d.mts +1 -3
- package/dist/client/svelte/index.mjs +1 -2
- package/dist/client/types.d.mts +2 -4
- package/dist/client/vanilla.d.mts +1 -3
- package/dist/client/vanilla.mjs +1 -2
- package/dist/client/vue/index.d.mts +1 -3
- package/dist/client/vue/index.mjs +1 -2
- package/dist/client/vue/vue-store.mjs +1 -2
- package/dist/context/create-context.mjs +8 -9
- package/dist/context/helpers.mjs +3 -4
- package/dist/context/init-minimal.mjs +1 -2
- package/dist/context/init.mjs +1 -2
- package/dist/context/secret-utils.mjs +1 -2
- package/dist/context/store-capabilities.mjs +1 -2
- package/dist/cookies/cache.mjs +1 -2
- package/dist/cookies/cookie-utils.d.mts +0 -2
- package/dist/cookies/cookie-utils.mjs +1 -2
- package/dist/cookies/index.d.mts +0 -2
- package/dist/cookies/index.mjs +2 -3
- package/dist/cookies/jwt.mjs +1 -2
- package/dist/cookies/session-store.d.mts +0 -2
- package/dist/cookies/session-store.mjs +1 -2
- package/dist/crypto/buffer.d.mts +1 -3
- package/dist/crypto/buffer.mjs +1 -2
- package/dist/crypto/index.d.mts +0 -2
- package/dist/crypto/index.mjs +2 -3
- package/dist/crypto/jwt.d.mts +1 -3
- package/dist/crypto/jwt.mjs +1 -2
- package/dist/crypto/password.d.mts +0 -2
- package/dist/crypto/password.mjs +1 -2
- package/dist/crypto/purpose.mjs +1 -2
- package/dist/crypto/random.d.mts +1 -3
- package/dist/crypto/random.mjs +1 -2
- package/dist/db/adapter-base.d.mts +1 -3
- package/dist/db/adapter-base.mjs +1 -2
- package/dist/db/adapter-kysely.d.mts +1 -3
- package/dist/db/adapter-kysely.mjs +1 -2
- package/dist/db/field-converter.d.mts +1 -3
- package/dist/db/field-converter.mjs +1 -2
- package/dist/db/field.d.mts +0 -2
- package/dist/db/get-migration.d.mts +1 -3
- package/dist/db/get-migration.mjs +10 -13
- package/dist/db/get-schema.d.mts +1 -3
- package/dist/db/get-schema.mjs +1 -2
- package/dist/db/index.d.mts +1 -1
- package/dist/db/index.mjs +4 -5
- package/dist/db/internal-adapter.d.mts +1 -3
- package/dist/db/internal-adapter.mjs +25 -11
- package/dist/db/revoke-unproven-account-access.d.mts +1 -3
- package/dist/db/revoke-unproven-account-access.mjs +1 -2
- package/dist/db/schema.d.mts +1 -3
- package/dist/db/schema.mjs +1 -2
- package/dist/db/to-zod.d.mts +0 -2
- package/dist/db/to-zod.mjs +1 -2
- package/dist/db/verification-token-storage.mjs +1 -2
- package/dist/db/with-hooks.d.mts +1 -3
- package/dist/db/with-hooks.mjs +1 -2
- package/dist/index.d.mts +1 -1
- package/dist/index.mjs +1 -1
- package/dist/integrations/cookie-plugin-guard.mjs +1 -2
- package/dist/integrations/next-js.d.mts +1 -3
- package/dist/integrations/next-js.mjs +2 -3
- package/dist/integrations/node.d.mts +1 -3
- package/dist/integrations/node.mjs +1 -2
- package/dist/integrations/solid-start.d.mts +1 -3
- package/dist/integrations/solid-start.mjs +1 -2
- package/dist/integrations/svelte-kit.d.mts +1 -3
- package/dist/integrations/svelte-kit.mjs +1 -2
- package/dist/integrations/tanstack-start-solid.d.mts +1 -3
- package/dist/integrations/tanstack-start-solid.mjs +1 -2
- package/dist/integrations/tanstack-start.d.mts +1 -3
- package/dist/integrations/tanstack-start.mjs +1 -2
- package/dist/oauth2/account-key.mjs +1 -2
- package/dist/oauth2/callback.mjs +1 -2
- package/dist/oauth2/errors.mjs +1 -2
- package/dist/oauth2/index.d.mts +1 -1
- package/dist/oauth2/index.mjs +1 -1
- package/dist/oauth2/link-account.d.mts +1 -3
- package/dist/oauth2/link-account.mjs +18 -13
- package/dist/oauth2/state.d.mts +1 -3
- package/dist/oauth2/state.mjs +3 -4
- package/dist/oauth2/utils.d.mts +1 -3
- package/dist/oauth2/utils.mjs +1 -2
- package/dist/package.mjs +2 -3
- package/dist/plugins/access/access.d.mts +1 -3
- package/dist/plugins/access/access.mjs +1 -2
- package/dist/plugins/access/index.d.mts +1 -1
- package/dist/plugins/access/types.d.mts +1 -3
- package/dist/plugins/additional-fields/client.d.mts +1 -3
- package/dist/plugins/additional-fields/client.mjs +1 -2
- package/dist/plugins/admin/access/statement.d.mts +1 -3
- package/dist/plugins/admin/access/statement.mjs +1 -2
- package/dist/plugins/admin/admin.d.mts +1 -3
- package/dist/plugins/admin/admin.mjs +2 -3
- package/dist/plugins/admin/client.d.mts +2 -4
- package/dist/plugins/admin/client.mjs +1 -2
- package/dist/plugins/admin/error-codes.d.mts +1 -3
- package/dist/plugins/admin/error-codes.mjs +1 -2
- package/dist/plugins/admin/has-permission.mjs +1 -2
- package/dist/plugins/admin/index.d.mts +1 -1
- package/dist/plugins/admin/routes.mjs +3 -4
- package/dist/plugins/admin/schema.d.mts +1 -3
- package/dist/plugins/admin/schema.mjs +1 -2
- package/dist/plugins/admin/types.d.mts +1 -3
- package/dist/plugins/anonymous/client.d.mts +1 -3
- package/dist/plugins/anonymous/client.mjs +1 -2
- package/dist/plugins/anonymous/error-codes.d.mts +1 -3
- package/dist/plugins/anonymous/error-codes.mjs +1 -2
- package/dist/plugins/anonymous/index.d.mts +0 -2
- package/dist/plugins/anonymous/index.mjs +3 -4
- package/dist/plugins/anonymous/schema.d.mts +1 -3
- package/dist/plugins/anonymous/schema.mjs +1 -2
- package/dist/plugins/anonymous/types.d.mts +1 -3
- package/dist/plugins/bearer/index.d.mts +1 -3
- package/dist/plugins/bearer/index.mjs +1 -2
- package/dist/plugins/captcha/constants.d.mts +1 -3
- package/dist/plugins/captcha/constants.mjs +1 -2
- package/dist/plugins/captcha/error-codes.mjs +1 -2
- package/dist/plugins/captcha/index.d.mts +0 -2
- package/dist/plugins/captcha/index.mjs +2 -3
- package/dist/plugins/captcha/types.d.mts +1 -3
- package/dist/plugins/captcha/utils.mjs +1 -2
- package/dist/plugins/captcha/verify-handlers/captchafox.mjs +1 -2
- package/dist/plugins/captcha/verify-handlers/cloudflare-turnstile.mjs +1 -2
- package/dist/plugins/captcha/verify-handlers/google-recaptcha.mjs +1 -2
- package/dist/plugins/captcha/verify-handlers/h-captcha.mjs +1 -2
- package/dist/plugins/captcha/verify-handlers/vercel-botid.mjs +1 -2
- package/dist/plugins/custom-session/client.d.mts +1 -3
- package/dist/plugins/custom-session/client.mjs +1 -2
- package/dist/plugins/custom-session/index.d.mts +1 -3
- package/dist/plugins/custom-session/index.mjs +3 -4
- package/dist/plugins/device-authorization/client.d.mts +1 -3
- package/dist/plugins/device-authorization/client.mjs +1 -2
- package/dist/plugins/device-authorization/error-codes.mjs +1 -2
- package/dist/plugins/device-authorization/index.d.mts +1 -3
- package/dist/plugins/device-authorization/index.mjs +2 -3
- package/dist/plugins/device-authorization/routes.d.mts +4 -6
- package/dist/plugins/device-authorization/routes.mjs +18 -4
- package/dist/plugins/device-authorization/schema.d.mts +0 -2
- package/dist/plugins/device-authorization/schema.mjs +1 -2
- package/dist/plugins/email-otp/client.d.mts +0 -2
- package/dist/plugins/email-otp/client.mjs +1 -2
- package/dist/plugins/email-otp/error-codes.d.mts +1 -3
- package/dist/plugins/email-otp/error-codes.mjs +1 -2
- package/dist/plugins/email-otp/index.d.mts +0 -2
- package/dist/plugins/email-otp/index.mjs +4 -5
- package/dist/plugins/email-otp/otp-token.mjs +3 -4
- package/dist/plugins/email-otp/routes.mjs +6 -7
- package/dist/plugins/email-otp/types.d.mts +1 -3
- package/dist/plugins/email-otp/utils.mjs +1 -2
- package/dist/plugins/generic-oauth/error-codes.mjs +1 -2
- package/dist/plugins/generic-oauth/index.d.mts +1 -6
- package/dist/plugins/generic-oauth/index.mjs +43 -30
- package/dist/plugins/generic-oauth/providers/auth0.d.mts +1 -3
- package/dist/plugins/generic-oauth/providers/auth0.mjs +1 -2
- package/dist/plugins/generic-oauth/providers/gumroad.d.mts +1 -3
- package/dist/plugins/generic-oauth/providers/gumroad.mjs +1 -2
- package/dist/plugins/generic-oauth/providers/hubspot.d.mts +1 -3
- package/dist/plugins/generic-oauth/providers/hubspot.mjs +1 -2
- package/dist/plugins/generic-oauth/providers/keycloak.d.mts +1 -3
- package/dist/plugins/generic-oauth/providers/keycloak.mjs +1 -2
- package/dist/plugins/generic-oauth/providers/line.d.mts +1 -3
- package/dist/plugins/generic-oauth/providers/line.mjs +1 -2
- package/dist/plugins/generic-oauth/providers/microsoft-entra-id.d.mts +1 -3
- package/dist/plugins/generic-oauth/providers/microsoft-entra-id.mjs +1 -2
- package/dist/plugins/generic-oauth/providers/okta.d.mts +1 -3
- package/dist/plugins/generic-oauth/providers/okta.mjs +1 -2
- package/dist/plugins/generic-oauth/providers/patreon.d.mts +1 -3
- package/dist/plugins/generic-oauth/providers/patreon.mjs +1 -2
- package/dist/plugins/generic-oauth/providers/slack.d.mts +1 -3
- package/dist/plugins/generic-oauth/providers/slack.mjs +1 -2
- package/dist/plugins/generic-oauth/providers/yandex.d.mts +1 -3
- package/dist/plugins/generic-oauth/providers/yandex.mjs +1 -2
- package/dist/plugins/generic-oauth/types.d.mts +6 -5
- package/dist/plugins/haveibeenpwned/index.d.mts +1 -3
- package/dist/plugins/haveibeenpwned/index.mjs +2 -3
- package/dist/plugins/index.d.mts +5 -5
- package/dist/plugins/jwt/adapter.mjs +1 -2
- package/dist/plugins/jwt/client.d.mts +1 -3
- package/dist/plugins/jwt/client.mjs +1 -2
- package/dist/plugins/jwt/cookie-cache.mjs +1 -2
- package/dist/plugins/jwt/index.d.mts +1 -3
- package/dist/plugins/jwt/index.mjs +5 -6
- package/dist/plugins/jwt/schema.d.mts +1 -3
- package/dist/plugins/jwt/schema.mjs +1 -2
- package/dist/plugins/jwt/sign.d.mts +0 -2
- package/dist/plugins/jwt/sign.mjs +1 -2
- package/dist/plugins/jwt/types.d.mts +1 -3
- package/dist/plugins/jwt/utils.d.mts +1 -3
- package/dist/plugins/jwt/utils.mjs +2 -3
- package/dist/plugins/jwt/verify.d.mts +1 -3
- package/dist/plugins/jwt/verify.mjs +1 -2
- package/dist/plugins/last-login-method/client.d.mts +1 -3
- package/dist/plugins/last-login-method/client.mjs +1 -2
- package/dist/plugins/last-login-method/index.d.mts +1 -3
- package/dist/plugins/last-login-method/index.mjs +1 -2
- package/dist/plugins/magic-link/client.d.mts +1 -3
- package/dist/plugins/magic-link/client.mjs +1 -2
- package/dist/plugins/magic-link/index.d.mts +1 -3
- package/dist/plugins/magic-link/index.mjs +4 -5
- package/dist/plugins/magic-link/utils.mjs +1 -2
- package/dist/plugins/multi-session/client.d.mts +0 -2
- package/dist/plugins/multi-session/client.mjs +1 -2
- package/dist/plugins/multi-session/error-codes.d.mts +1 -3
- package/dist/plugins/multi-session/error-codes.mjs +1 -2
- package/dist/plugins/multi-session/index.d.mts +0 -2
- package/dist/plugins/multi-session/index.mjs +3 -4
- package/dist/plugins/oauth-popup/client.d.mts +0 -2
- package/dist/plugins/oauth-popup/client.mjs +1 -2
- package/dist/plugins/oauth-popup/constants.d.mts +1 -3
- package/dist/plugins/oauth-popup/constants.mjs +1 -2
- package/dist/plugins/oauth-popup/error-codes.d.mts +1 -3
- package/dist/plugins/oauth-popup/error-codes.mjs +1 -2
- package/dist/plugins/oauth-popup/index.d.mts +0 -2
- package/dist/plugins/oauth-popup/index.mjs +5 -6
- package/dist/plugins/oauth-popup/types.d.mts +1 -3
- package/dist/plugins/oauth-proxy/index.d.mts +1 -3
- package/dist/plugins/oauth-proxy/index.mjs +7 -8
- package/dist/plugins/oauth-proxy/utils.mjs +1 -2
- package/dist/plugins/one-tap/client.d.mts +1 -3
- package/dist/plugins/one-tap/client.mjs +1 -2
- package/dist/plugins/one-tap/index.d.mts +1 -3
- package/dist/plugins/one-tap/index.mjs +7 -8
- package/dist/plugins/one-time-token/client.d.mts +0 -2
- package/dist/plugins/one-time-token/client.mjs +1 -2
- package/dist/plugins/one-time-token/index.d.mts +1 -3
- package/dist/plugins/one-time-token/index.mjs +3 -4
- package/dist/plugins/one-time-token/utils.mjs +1 -2
- package/dist/plugins/open-api/generator.d.mts +0 -2
- package/dist/plugins/open-api/generator.mjs +2 -3
- package/dist/plugins/open-api/index.d.mts +0 -2
- package/dist/plugins/open-api/index.mjs +2 -3
- package/dist/plugins/open-api/logo.mjs +1 -2
- package/dist/plugins/organization/access/statement.d.mts +1 -3
- package/dist/plugins/organization/access/statement.mjs +1 -2
- package/dist/plugins/organization/adapter.d.mts +3 -5
- package/dist/plugins/organization/adapter.mjs +2 -3
- package/dist/plugins/organization/call.mjs +1 -2
- package/dist/plugins/organization/client.d.mts +9 -11
- package/dist/plugins/organization/client.mjs +2 -3
- package/dist/plugins/organization/error-codes.d.mts +1 -3
- package/dist/plugins/organization/error-codes.mjs +1 -2
- package/dist/plugins/organization/has-permission.d.mts +1 -3
- package/dist/plugins/organization/has-permission.mjs +2 -3
- package/dist/plugins/organization/index.d.mts +3 -3
- package/dist/plugins/organization/organization.d.mts +3 -5
- package/dist/plugins/organization/organization.mjs +3 -4
- package/dist/plugins/organization/permission.d.mts +1 -3
- package/dist/plugins/organization/permission.mjs +1 -2
- package/dist/plugins/organization/roles.d.mts +1 -3
- package/dist/plugins/organization/roles.mjs +1 -2
- package/dist/plugins/organization/routes/crud-access-control.d.mts +2 -4
- package/dist/plugins/organization/routes/crud-access-control.mjs +3 -4
- package/dist/plugins/organization/routes/crud-invites.d.mts +4 -6
- package/dist/plugins/organization/routes/crud-invites.mjs +5 -6
- package/dist/plugins/organization/routes/crud-members.d.mts +4 -6
- package/dist/plugins/organization/routes/crud-members.mjs +4 -5
- package/dist/plugins/organization/routes/crud-org.d.mts +4 -6
- package/dist/plugins/organization/routes/crud-org.mjs +8 -9
- package/dist/plugins/organization/routes/crud-team.d.mts +4 -6
- package/dist/plugins/organization/routes/crud-team.mjs +3 -4
- package/dist/plugins/organization/schema.d.mts +0 -2
- package/dist/plugins/organization/schema.mjs +1 -2
- package/dist/plugins/organization/types.d.mts +1 -3
- package/dist/plugins/phone-number/client.d.mts +1 -3
- package/dist/plugins/phone-number/client.mjs +1 -2
- package/dist/plugins/phone-number/error-codes.d.mts +1 -3
- package/dist/plugins/phone-number/error-codes.mjs +1 -2
- package/dist/plugins/phone-number/index.d.mts +0 -2
- package/dist/plugins/phone-number/index.mjs +1 -2
- package/dist/plugins/phone-number/routes.mjs +6 -7
- package/dist/plugins/phone-number/schema.d.mts +1 -3
- package/dist/plugins/phone-number/schema.mjs +1 -2
- package/dist/plugins/phone-number/types.d.mts +2 -4
- package/dist/plugins/siwe/client.d.mts +1 -3
- package/dist/plugins/siwe/client.mjs +1 -2
- package/dist/plugins/siwe/index.d.mts +1 -3
- package/dist/plugins/siwe/index.mjs +6 -7
- package/dist/plugins/siwe/parse-message.mjs +1 -2
- package/dist/plugins/siwe/schema.d.mts +1 -3
- package/dist/plugins/siwe/schema.mjs +1 -2
- package/dist/plugins/siwe/types.d.mts +0 -2
- package/dist/plugins/test-utils/auth-helpers.mjs +1 -2
- package/dist/plugins/test-utils/cookie-builder.mjs +1 -2
- package/dist/plugins/test-utils/db-helpers.mjs +1 -2
- package/dist/plugins/test-utils/factories.mjs +1 -2
- package/dist/plugins/test-utils/index.d.mts +0 -2
- package/dist/plugins/test-utils/index.mjs +2 -3
- package/dist/plugins/test-utils/otp-sink.mjs +1 -2
- package/dist/plugins/test-utils/types.d.mts +1 -3
- package/dist/plugins/two-factor/backup-codes/index.d.mts +1 -3
- package/dist/plugins/two-factor/backup-codes/index.mjs +4 -5
- package/dist/plugins/two-factor/client.d.mts +2 -4
- package/dist/plugins/two-factor/client.mjs +1 -2
- package/dist/plugins/two-factor/constant.mjs +1 -2
- package/dist/plugins/two-factor/error-code.d.mts +1 -3
- package/dist/plugins/two-factor/error-code.mjs +1 -2
- package/dist/plugins/two-factor/index.d.mts +0 -2
- package/dist/plugins/two-factor/index.mjs +9 -10
- package/dist/plugins/two-factor/otp/index.d.mts +1 -3
- package/dist/plugins/two-factor/otp/index.mjs +4 -5
- package/dist/plugins/two-factor/schema.d.mts +1 -3
- package/dist/plugins/two-factor/schema.mjs +1 -2
- package/dist/plugins/two-factor/totp/index.d.mts +1 -3
- package/dist/plugins/two-factor/totp/index.mjs +3 -4
- package/dist/plugins/two-factor/types.d.mts +1 -3
- package/dist/plugins/two-factor/utils.mjs +1 -2
- package/dist/plugins/two-factor/verify-two-factor.mjs +5 -6
- package/dist/plugins/username/client.d.mts +0 -2
- package/dist/plugins/username/client.mjs +1 -2
- package/dist/plugins/username/error-codes.d.mts +1 -3
- package/dist/plugins/username/error-codes.mjs +1 -2
- package/dist/plugins/username/index.d.mts +0 -2
- package/dist/plugins/username/index.mjs +4 -5
- package/dist/plugins/username/schema.d.mts +1 -3
- package/dist/plugins/username/schema.mjs +1 -2
- package/dist/state.d.mts +2 -7
- package/dist/state.mjs +3 -7
- package/dist/test-utils/headers.d.mts +1 -3
- package/dist/test-utils/headers.mjs +1 -2
- package/dist/test-utils/http-test-instance.d.mts +0 -2
- package/dist/test-utils/http-test-instance.mjs +1 -2
- package/dist/test-utils/index.d.mts +1 -1
- package/dist/test-utils/index.mjs +1 -1
- package/dist/test-utils/test-instance.d.mts +4 -6
- package/dist/test-utils/test-instance.mjs +5 -6
- package/dist/types/api.d.mts +1 -3
- package/dist/types/auth.d.mts +2 -4
- package/dist/types/helper.d.mts +1 -3
- package/dist/types/index.d.mts +2 -2
- package/dist/types/models.d.mts +0 -2
- package/dist/types/plugins.d.mts +0 -2
- package/dist/utils/constants.mjs +1 -2
- package/dist/utils/date.mjs +1 -2
- package/dist/utils/hashing.mjs +1 -2
- package/dist/utils/hide-metadata.d.mts +2 -5
- package/dist/utils/hide-metadata.mjs +1 -4
- package/dist/utils/index.d.mts +1 -1
- package/dist/utils/is-atom.mjs +1 -2
- package/dist/utils/is-promise.mjs +1 -2
- package/dist/utils/middleware-response.mjs +1 -2
- package/dist/utils/password.mjs +1 -2
- package/dist/utils/plugin-helper.mjs +1 -2
- package/dist/utils/request.mjs +1 -2
- package/dist/utils/shim.mjs +1 -2
- package/dist/utils/time.d.mts +0 -2
- package/dist/utils/time.mjs +1 -2
- package/dist/utils/url.d.mts +1 -3
- package/dist/utils/url.mjs +1 -2
- package/dist/utils/validate-user-info.mjs +1 -2
- package/dist/utils/wildcard.mjs +1 -2
- package/dist/version.mjs +1 -2
- package/package.json +10 -10
- package/dist/utils/boolean.mjs +0 -6
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import * as z from "zod";
|
|
2
|
-
//#region src/api/routes/sign-out.d.ts
|
|
3
2
|
export declare const signOut: import("better-call").StrictEndpoint<"/sign-out", {
|
|
4
3
|
method: "POST";
|
|
5
4
|
body: z.ZodOptional<z.ZodObject<{
|
|
@@ -44,5 +43,4 @@ export declare const signOut: import("better-call").StrictEndpoint<"/sign-out",
|
|
|
44
43
|
success: boolean;
|
|
45
44
|
url: string | undefined;
|
|
46
45
|
redirect: boolean | undefined;
|
|
47
|
-
}>;
|
|
48
|
-
//#endregion
|
|
46
|
+
}>;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { deleteSessionCookie } from "../../cookies/index.mjs";
|
|
2
2
|
import { createAuthEndpoint } from "@better-auth/core/api";
|
|
3
3
|
import * as z from "zod";
|
|
4
|
-
|
|
4
|
+
// src/api/routes/sign-out.ts
|
|
5
5
|
const signOutBodySchema = z.object({
|
|
6
6
|
callbackURL: z.string().meta({ description: "The URL to redirect to after provider logout" }).optional(),
|
|
7
7
|
disableRedirect: z.boolean().meta({ description: "Return the provider logout URL without redirecting" }).optional(),
|
|
@@ -92,5 +92,4 @@ const signOut = createAuthEndpoint("/sign-out", {
|
|
|
92
92
|
}
|
|
93
93
|
return ctx.json(signOutResponse());
|
|
94
94
|
});
|
|
95
|
-
//#endregion
|
|
96
95
|
export { signOut };
|
|
@@ -2,7 +2,6 @@ import { AdditionalUserFieldsInput, User } from "../../types/models.mjs";
|
|
|
2
2
|
import "../../types/index.mjs";
|
|
3
3
|
import { BetterAuthOptions } from "@better-auth/core";
|
|
4
4
|
import * as z from "zod";
|
|
5
|
-
//#region src/api/routes/sign-up.d.ts
|
|
6
5
|
export declare const signUpEmail: <O extends BetterAuthOptions>() => import("better-call").StrictEndpoint<"/sign-up/email", {
|
|
7
6
|
method: "POST";
|
|
8
7
|
operationId: string;
|
|
@@ -153,5 +152,4 @@ export declare const signUpEmail: <O extends BetterAuthOptions>() => import("bet
|
|
|
153
152
|
} | {
|
|
154
153
|
token: string;
|
|
155
154
|
user: User<O["user"], O["plugins"]>;
|
|
156
|
-
}>;
|
|
157
|
-
//#endregion
|
|
155
|
+
}>;
|
|
@@ -1,17 +1,17 @@
|
|
|
1
|
-
import { isAPIError } from "../../utils/is-api-error.mjs";
|
|
2
|
-
import { formCsrfMiddleware } from "../middlewares/origin-check.mjs";
|
|
3
|
-
import { buildSyntheticUserOutput, parseUserInput, parseUserOutput } from "../../db/schema.mjs";
|
|
4
1
|
import { setSessionCookie } from "../../cookies/index.mjs";
|
|
2
|
+
import { buildSyntheticUserOutput, parseUserInput, parseUserOutput } from "../../db/schema.mjs";
|
|
3
|
+
import { isAPIError } from "../../utils/is-api-error.mjs";
|
|
4
|
+
import { assertPasswordNotTooLong, assertPasswordNotTooShort } from "../../utils/password.mjs";
|
|
5
5
|
import { safeCloneRequest } from "../../utils/request.mjs";
|
|
6
|
+
import { formCsrfMiddleware } from "../middlewares/origin-check.mjs";
|
|
6
7
|
import { createEmailVerificationToken } from "./email-verification.mjs";
|
|
7
|
-
import {
|
|
8
|
-
import { runWithTransaction } from "@better-auth/core/context";
|
|
8
|
+
import { queueAfterTransactionHook, runWithTransaction } from "@better-auth/core/context";
|
|
9
9
|
import { isDevelopment } from "@better-auth/core/env";
|
|
10
10
|
import { APIError, BASE_ERROR_CODES } from "@better-auth/core/error";
|
|
11
11
|
import { generateId } from "@better-auth/core/utils/id";
|
|
12
12
|
import { createAuthEndpoint } from "@better-auth/core/api";
|
|
13
13
|
import * as z from "zod";
|
|
14
|
-
|
|
14
|
+
// src/api/routes/sign-up.ts
|
|
15
15
|
const signUpEmailBodySchema = z.object({
|
|
16
16
|
name: z.string(),
|
|
17
17
|
email: z.email(),
|
|
@@ -198,7 +198,13 @@ const signUpEmail = () => createAuthEndpoint("/sign-up/email", {
|
|
|
198
198
|
* between existing and non-existing emails.
|
|
199
199
|
*/
|
|
200
200
|
await ctx.context.password.hash(password);
|
|
201
|
-
|
|
201
|
+
const onExistingUserSignUp = ctx.context.options.emailAndPassword?.onExistingUserSignUp;
|
|
202
|
+
if (onExistingUserSignUp) {
|
|
203
|
+
const request = safeCloneRequest(ctx.request);
|
|
204
|
+
await queueAfterTransactionHook(async () => {
|
|
205
|
+
await ctx.context.runInBackgroundOrAwait(onExistingUserSignUp({ user: dbUser.user }, request));
|
|
206
|
+
}, { onError: (error) => ctx.context.logger.error("Failed to run onExistingUserSignUp after sign-up", error) });
|
|
207
|
+
}
|
|
202
208
|
return buildGenericDuplicateResponse();
|
|
203
209
|
}
|
|
204
210
|
throw APIError.from("UNPROCESSABLE_ENTITY", BASE_ERROR_CODES.USER_ALREADY_EXISTS_USE_ANOTHER_EMAIL);
|
|
@@ -238,15 +244,20 @@ const signUpEmail = () => createAuthEndpoint("/sign-up/email", {
|
|
|
238
244
|
accountId: createdUser.id,
|
|
239
245
|
password: hash
|
|
240
246
|
});
|
|
241
|
-
|
|
242
|
-
|
|
247
|
+
const shouldSendVerificationEmail = ctx.context.options.emailVerification?.sendOnSignUp ?? ctx.context.options.emailAndPassword.requireEmailVerification;
|
|
248
|
+
const sendVerificationEmail = ctx.context.options.emailVerification?.sendVerificationEmail;
|
|
249
|
+
if (shouldSendVerificationEmail && sendVerificationEmail) {
|
|
243
250
|
const callbackURL = body.callbackURL ? encodeURIComponent(body.callbackURL) : encodeURIComponent("/");
|
|
244
|
-
const
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
url
|
|
248
|
-
|
|
249
|
-
|
|
251
|
+
const request = safeCloneRequest(ctx.request);
|
|
252
|
+
await queueAfterTransactionHook(async () => {
|
|
253
|
+
const token = await createEmailVerificationToken(ctx.context.secret, createdUser.email, void 0, ctx.context.options.emailVerification?.expiresIn, { userId: createdUser.id });
|
|
254
|
+
const url = `${ctx.context.baseURL}/verify-email?token=${token}&callbackURL=${callbackURL}`;
|
|
255
|
+
await ctx.context.runInBackgroundOrAwait(sendVerificationEmail({
|
|
256
|
+
user: createdUser,
|
|
257
|
+
url,
|
|
258
|
+
token
|
|
259
|
+
}, request));
|
|
260
|
+
}, { onError: (error) => ctx.context.logger.error("Failed to send the sign-up verification email", error) });
|
|
250
261
|
}
|
|
251
262
|
if (shouldSkipAutoSignIn) return ctx.json({
|
|
252
263
|
token: null,
|
|
@@ -264,5 +275,4 @@ const signUpEmail = () => createAuthEndpoint("/sign-up/email", {
|
|
|
264
275
|
});
|
|
265
276
|
});
|
|
266
277
|
});
|
|
267
|
-
//#endregion
|
|
268
278
|
export { signUpEmail };
|
|
@@ -2,7 +2,6 @@ import { AdditionalSessionFieldsInput } from "../../types/models.mjs";
|
|
|
2
2
|
import "../../types/index.mjs";
|
|
3
3
|
import { BetterAuthOptions } from "@better-auth/core";
|
|
4
4
|
import * as z from "zod";
|
|
5
|
-
//#region src/api/routes/update-session.d.ts
|
|
6
5
|
export declare const updateSession: <O extends BetterAuthOptions>() => import("better-call").StrictEndpoint<"/update-session", {
|
|
7
6
|
method: "POST";
|
|
8
7
|
operationId: string;
|
|
@@ -68,5 +67,4 @@ export declare const updateSession: <O extends BetterAuthOptions>() => import("b
|
|
|
68
67
|
ipAddress?: string | null | undefined;
|
|
69
68
|
userAgent?: string | null | undefined;
|
|
70
69
|
};
|
|
71
|
-
}>;
|
|
72
|
-
//#endregion
|
|
70
|
+
}>;
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { parseSessionInput, parseSessionOutput } from "../../db/schema.mjs";
|
|
2
1
|
import { deleteSessionCookie, setSessionCookie } from "../../cookies/index.mjs";
|
|
2
|
+
import { parseSessionInput, parseSessionOutput } from "../../db/schema.mjs";
|
|
3
3
|
import { isStateful, sessionMiddleware } from "./session.mjs";
|
|
4
4
|
import { APIError, BASE_ERROR_CODES } from "@better-auth/core/error";
|
|
5
5
|
import { createAuthEndpoint } from "@better-auth/core/api";
|
|
6
6
|
import * as z from "zod";
|
|
7
|
-
|
|
7
|
+
// src/api/routes/update-session.ts
|
|
8
8
|
const updateSessionBodySchema = z.record(z.string().meta({ description: "Field name must be a string" }), z.any());
|
|
9
9
|
const updateSession = () => createAuthEndpoint("/update-session", {
|
|
10
10
|
method: "POST",
|
|
@@ -53,5 +53,4 @@ const updateSession = () => createAuthEndpoint("/update-session", {
|
|
|
53
53
|
});
|
|
54
54
|
return ctx.json({ session: parseSessionOutput(ctx.context.options, newSession) });
|
|
55
55
|
});
|
|
56
|
-
//#endregion
|
|
57
56
|
export { updateSession };
|
|
@@ -2,7 +2,6 @@ import { AdditionalUserFieldsInput } from "../../types/models.mjs";
|
|
|
2
2
|
import "../../types/index.mjs";
|
|
3
3
|
import { BetterAuthOptions } from "@better-auth/core";
|
|
4
4
|
import * as z from "zod";
|
|
5
|
-
//#region src/api/routes/update-user.d.ts
|
|
6
5
|
export declare const updateUser: <O extends BetterAuthOptions>() => import("better-call").StrictEndpoint<"/update-user", {
|
|
7
6
|
method: "POST";
|
|
8
7
|
operationId: string;
|
|
@@ -422,5 +421,4 @@ export declare const changeEmail: import("better-call").StrictEndpoint<"/change-
|
|
|
422
421
|
};
|
|
423
422
|
}, {
|
|
424
423
|
status: boolean;
|
|
425
|
-
}>;
|
|
426
|
-
//#endregion
|
|
424
|
+
}>;
|
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
import { originCheck } from "../middlewares/origin-check.mjs";
|
|
2
|
-
import { parseUserInput, parseUserOutput } from "../../db/schema.mjs";
|
|
3
|
-
import { generateRandomString } from "../../crypto/random.mjs";
|
|
4
1
|
import { deleteSessionCookie, setSessionCookie } from "../../cookies/index.mjs";
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
2
|
+
import { generateRandomString } from "../../crypto/random.mjs";
|
|
3
|
+
import { parseUserInput, parseUserOutput } from "../../db/schema.mjs";
|
|
7
4
|
import { assertPasswordNotTooLong, assertPasswordNotTooShort } from "../../utils/password.mjs";
|
|
5
|
+
import { originCheck } from "../middlewares/origin-check.mjs";
|
|
6
|
+
import { createEmailVerificationToken } from "./email-verification.mjs";
|
|
7
|
+
import { getSessionFromCtx, isStateful, sensitiveSessionMiddleware, sessionMiddleware } from "./session.mjs";
|
|
8
8
|
import { runWithTransaction } from "@better-auth/core/context";
|
|
9
9
|
import { APIError, BASE_ERROR_CODES } from "@better-auth/core/error";
|
|
10
10
|
import { createAuthEndpoint } from "@better-auth/core/api";
|
|
11
11
|
import * as z from "zod";
|
|
12
|
-
|
|
12
|
+
// src/api/routes/update-user.ts
|
|
13
13
|
const updateUserBodySchema = z.record(z.string().meta({ description: "Field name must be a string" }), z.any());
|
|
14
14
|
const updateUser = () => createAuthEndpoint("/update-user", {
|
|
15
15
|
method: "POST",
|
|
@@ -221,6 +221,28 @@ newPassword: z.string().meta({ description: "The new password to set is required
|
|
|
221
221
|
}
|
|
222
222
|
throw APIError.from("BAD_REQUEST", BASE_ERROR_CODES.PASSWORD_ALREADY_SET);
|
|
223
223
|
});
|
|
224
|
+
/**
|
|
225
|
+
* Deletes the signed-in user and expires the session cookies on the
|
|
226
|
+
* caller's response.
|
|
227
|
+
*/
|
|
228
|
+
async function deleteCurrentUser(ctx, user) {
|
|
229
|
+
const beforeDelete = ctx.context.options.user?.deleteUser?.beforeDelete;
|
|
230
|
+
if (beforeDelete) await beforeDelete(user, ctx.request);
|
|
231
|
+
await ctx.context.internalAdapter.deleteUser(user.id);
|
|
232
|
+
await ctx.context.internalAdapter.deleteUserSessions(user.id);
|
|
233
|
+
deleteSessionCookie(ctx);
|
|
234
|
+
const afterDelete = ctx.context.options.user?.deleteUser?.afterDelete;
|
|
235
|
+
if (afterDelete) await afterDelete(user, ctx.request);
|
|
236
|
+
}
|
|
237
|
+
/**
|
|
238
|
+
* Consumes a delete-account token issued to `user` and deletes the user.
|
|
239
|
+
* Runs on the caller's context so the expired cookies reach its response.
|
|
240
|
+
*/
|
|
241
|
+
async function deleteUserWithToken(ctx, user, token) {
|
|
242
|
+
const verification = await ctx.context.internalAdapter.consumeVerificationValue(`delete-account-${token}`);
|
|
243
|
+
if (!verification || verification.value !== user.id) throw APIError.from("NOT_FOUND", BASE_ERROR_CODES.INVALID_TOKEN);
|
|
244
|
+
await deleteCurrentUser(ctx, user);
|
|
245
|
+
}
|
|
224
246
|
const deleteUser = createAuthEndpoint("/delete-user", {
|
|
225
247
|
method: "POST",
|
|
226
248
|
use: [sensitiveSessionMiddleware],
|
|
@@ -295,10 +317,7 @@ const deleteUser = createAuthEndpoint("/delete-user", {
|
|
|
295
317
|
})) throw APIError.from("BAD_REQUEST", BASE_ERROR_CODES.INVALID_PASSWORD);
|
|
296
318
|
}
|
|
297
319
|
if (ctx.body.token) {
|
|
298
|
-
await
|
|
299
|
-
...ctx,
|
|
300
|
-
query: { token: ctx.body.token }
|
|
301
|
-
});
|
|
320
|
+
await deleteUserWithToken(ctx, session.user, ctx.body.token);
|
|
302
321
|
return ctx.json({
|
|
303
322
|
success: true,
|
|
304
323
|
message: "User deleted"
|
|
@@ -327,13 +346,7 @@ const deleteUser = createAuthEndpoint("/delete-user", {
|
|
|
327
346
|
const freshAge = ctx.context.sessionConfig.freshAge * 1e3;
|
|
328
347
|
if (Date.now() - createdAt >= freshAge) throw APIError.from("BAD_REQUEST", BASE_ERROR_CODES.SESSION_EXPIRED);
|
|
329
348
|
}
|
|
330
|
-
|
|
331
|
-
if (beforeDelete) await beforeDelete(session.user, ctx.request);
|
|
332
|
-
await ctx.context.internalAdapter.deleteUser(session.user.id);
|
|
333
|
-
await ctx.context.internalAdapter.deleteUserSessions(session.user.id);
|
|
334
|
-
deleteSessionCookie(ctx);
|
|
335
|
-
const afterDelete = ctx.context.options.user.deleteUser?.afterDelete;
|
|
336
|
-
if (afterDelete) await afterDelete(session.user, ctx.request);
|
|
349
|
+
await deleteCurrentUser(ctx, session.user);
|
|
337
350
|
return ctx.json({
|
|
338
351
|
success: true,
|
|
339
352
|
message: "User deleted"
|
|
@@ -377,16 +390,7 @@ const deleteUserCallback = createAuthEndpoint("/delete-user/callback", {
|
|
|
377
390
|
}
|
|
378
391
|
const session = await getSessionFromCtx(ctx, { disableCookieCache: isStateful(ctx) });
|
|
379
392
|
if (!session) throw APIError.from("NOT_FOUND", BASE_ERROR_CODES.FAILED_TO_GET_USER_INFO);
|
|
380
|
-
|
|
381
|
-
if (!token || token.value !== session.user.id) throw APIError.from("NOT_FOUND", BASE_ERROR_CODES.INVALID_TOKEN);
|
|
382
|
-
const beforeDelete = ctx.context.options.user.deleteUser?.beforeDelete;
|
|
383
|
-
if (beforeDelete) await beforeDelete(session.user, ctx.request);
|
|
384
|
-
await ctx.context.internalAdapter.deleteUser(session.user.id);
|
|
385
|
-
await ctx.context.internalAdapter.deleteUserSessions(session.user.id);
|
|
386
|
-
await ctx.context.internalAdapter.deleteAccounts(session.user.id);
|
|
387
|
-
deleteSessionCookie(ctx);
|
|
388
|
-
const afterDelete = ctx.context.options.user.deleteUser?.afterDelete;
|
|
389
|
-
if (afterDelete) await afterDelete(session.user, ctx.request);
|
|
393
|
+
await deleteUserWithToken(ctx, session.user, ctx.query.token);
|
|
390
394
|
if (ctx.query.callbackURL) throw ctx.redirect(ctx.query.callbackURL || "/");
|
|
391
395
|
return ctx.json({
|
|
392
396
|
success: true,
|
|
@@ -516,5 +520,4 @@ const changeEmail = createAuthEndpoint("/change-email", {
|
|
|
516
520
|
}, ctx.request));
|
|
517
521
|
return ctx.json({ status: true });
|
|
518
522
|
});
|
|
519
|
-
//#endregion
|
|
520
523
|
export { changeEmail, changePassword, deleteUser, deleteUserCallback, setPassword, updateUser };
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
//#region src/api/state/oauth.d.ts
|
|
2
1
|
type OAuthState = {
|
|
3
2
|
callbackURL: string;
|
|
4
3
|
codeVerifier: string;
|
|
@@ -46,5 +45,4 @@ declare const getOAuthState: <T extends Record<string, unknown> = Record<string,
|
|
|
46
45
|
* stored as `unknown`, so narrow their shape when reading them back.
|
|
47
46
|
*/
|
|
48
47
|
declare const addOAuthServerContext: (values: Record<string, unknown>) => Promise<void>;
|
|
49
|
-
//#endregion
|
|
50
48
|
export { addOAuthServerContext, getOAuthState };
|
package/dist/api/state/oauth.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { defineRequestState } from "@better-auth/core/context";
|
|
2
|
-
|
|
2
|
+
// src/api/state/oauth.ts
|
|
3
3
|
const { get: getRawOAuthState, set: setOAuthState } = defineRequestState(() => null);
|
|
4
4
|
/**
|
|
5
5
|
* Reads the OAuth state for the current request. During a callback it holds the
|
|
@@ -35,5 +35,4 @@ const addOAuthServerContext = async (values) => {
|
|
|
35
35
|
...values
|
|
36
36
|
});
|
|
37
37
|
};
|
|
38
|
-
//#endregion
|
|
39
38
|
export { addOAuthServerContext, getOAuthServerContext, getOAuthState, setOAuthState };
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
//#region src/api/state/session-source.d.ts
|
|
2
1
|
/**
|
|
3
2
|
* Marks the request session with `token` as built without a session-store
|
|
4
3
|
* row. Checks that re-read the store to catch a concurrent revocation skip
|
|
@@ -6,5 +5,4 @@
|
|
|
6
5
|
*
|
|
7
6
|
* @internal Shared by Better Auth packages; not a supported public API.
|
|
8
7
|
*/
|
|
9
|
-
export declare function markSessionOutsideStore(token: string): Promise<void>;
|
|
10
|
-
//#endregion
|
|
8
|
+
export declare function markSessionOutsideStore(token: string): Promise<void>;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { defineRequestState } from "@better-auth/core/context";
|
|
2
|
-
|
|
2
|
+
// src/api/state/session-source.ts
|
|
3
3
|
/**
|
|
4
4
|
* Tokens of request sessions that a plugin built without a session-store
|
|
5
5
|
* row, such as one authenticated by an API key on every request.
|
|
@@ -24,5 +24,4 @@ async function markSessionOutsideStore(token) {
|
|
|
24
24
|
async function isSessionOutsideStore(token) {
|
|
25
25
|
return (await getTokensOutsideStore().catch(() => null))?.has(token) ?? false;
|
|
26
26
|
}
|
|
27
|
-
//#endregion
|
|
28
27
|
export { isSessionOutsideStore, markSessionOutsideStore };
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
//#region src/api/state/should-session-refresh.d.ts
|
|
2
1
|
/**
|
|
3
2
|
* State for skipping session refresh
|
|
4
3
|
*
|
|
@@ -8,5 +7,4 @@
|
|
|
8
7
|
* data stored in cookies.
|
|
9
8
|
*/
|
|
10
9
|
declare const getShouldSkipSessionRefresh: () => Promise<boolean | null>, setShouldSkipSessionRefresh: (value: boolean | null) => Promise<void>;
|
|
11
|
-
//#endregion
|
|
12
10
|
export { getShouldSkipSessionRefresh, setShouldSkipSessionRefresh };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { defineRequestState } from "@better-auth/core/context";
|
|
2
|
-
|
|
2
|
+
// src/api/state/should-session-refresh.ts
|
|
3
3
|
/**
|
|
4
4
|
* State for skipping session refresh
|
|
5
5
|
*
|
|
@@ -9,5 +9,4 @@ import { defineRequestState } from "@better-auth/core/context";
|
|
|
9
9
|
* data stored in cookies.
|
|
10
10
|
*/
|
|
11
11
|
const { get: getShouldSkipSessionRefresh, set: setShouldSkipSessionRefresh } = defineRequestState(() => false);
|
|
12
|
-
//#endregion
|
|
13
12
|
export { getShouldSkipSessionRefresh, setShouldSkipSessionRefresh };
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { isDynamicBaseURLConfig, isRequestLike } from "../utils/url.mjs";
|
|
2
1
|
import { pickSource, resolveDynamicTrustedProxyHeaders, resolveRequestContext } from "../context/helpers.mjs";
|
|
2
|
+
import { isDynamicBaseURLConfig, isRequestLike } from "../utils/url.mjs";
|
|
3
3
|
import { dispatchAuthEndpoint, getOperationId } from "./dispatch.mjs";
|
|
4
4
|
import { hasRequestState, runWithRequestState } from "@better-auth/core/context";
|
|
5
5
|
import { APIError, BetterAuthError } from "@better-auth/core/error";
|
|
6
|
-
|
|
6
|
+
// src/api/to-auth-endpoints.ts
|
|
7
7
|
/**
|
|
8
8
|
* Resolves the per-call `AuthContext` for endpoints with a dynamic `baseURL`.
|
|
9
9
|
*
|
|
@@ -56,5 +56,4 @@ function toAuthEndpoints(endpoints, ctx) {
|
|
|
56
56
|
}
|
|
57
57
|
return api;
|
|
58
58
|
}
|
|
59
|
-
//#endregion
|
|
60
59
|
export { toAuthEndpoints };
|
package/dist/auth/base.mjs
CHANGED
|
@@ -1,10 +1,9 @@
|
|
|
1
|
-
import { getBaseURL, getOrigin, isDynamicBaseURLConfig } from "../utils/url.mjs";
|
|
2
|
-
import { getTrustedOrigins, getTrustedProviders, resolveDynamicTrustedProxyHeaders, resolveRequestContext } from "../context/helpers.mjs";
|
|
3
1
|
import { getEndpoints, router } from "../api/index.mjs";
|
|
2
|
+
import { getTrustedOrigins, getTrustedProviders, resolveDynamicTrustedProxyHeaders, resolveRequestContext } from "../context/helpers.mjs";
|
|
3
|
+
import { getBaseURL, getOrigin, isDynamicBaseURLConfig } from "../utils/url.mjs";
|
|
4
4
|
import { runWithAdapter } from "@better-auth/core/context";
|
|
5
5
|
import { BASE_ERROR_CODES, BetterAuthError } from "@better-auth/core/error";
|
|
6
|
-
|
|
7
|
-
//#region src/auth/base.ts
|
|
6
|
+
// src/auth/base.ts
|
|
8
7
|
const createBetterAuth = (options, initFn) => {
|
|
9
8
|
const authContext = initFn(options).then((ctx) => {
|
|
10
9
|
const validateSchema = ctx.options.advanced?.database?.validateSchema;
|
|
@@ -12,10 +11,6 @@ const createBetterAuth = (options, initFn) => {
|
|
|
12
11
|
const level = validateSchema === true ? "warn" : "debug";
|
|
13
12
|
ctx.logger[level](`Schema validation is not available for adapter "${ctx.adapter.id}". Skipping schema validation. Database operations will proceed normally.`);
|
|
14
13
|
}
|
|
15
|
-
const pendingSchemaCheck = ctx.checkSchema?.();
|
|
16
|
-
if (pendingSchemaCheck) pendingSchemaCheck.catch((error) => {
|
|
17
|
-
ctx.logger.error(error instanceof SchemaMismatchError ? error.message : "Could not validate the database schema. Check your database connection.");
|
|
18
|
-
});
|
|
19
14
|
return ctx;
|
|
20
15
|
});
|
|
21
16
|
const { api } = getEndpoints(authContext, options);
|
|
@@ -62,5 +57,4 @@ const createBetterAuth = (options, initFn) => {
|
|
|
62
57
|
}
|
|
63
58
|
};
|
|
64
59
|
};
|
|
65
|
-
//#endregion
|
|
66
60
|
export { createBetterAuth };
|
package/dist/auth/full.d.mts
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { Auth } from "../types/auth.mjs";
|
|
2
2
|
import "../types/index.mjs";
|
|
3
3
|
import { BetterAuthOptions } from "@better-auth/core";
|
|
4
|
-
//#region src/auth/full.d.ts
|
|
5
4
|
/**
|
|
6
5
|
* Better Auth initializer for full mode (with Kysely)
|
|
7
6
|
*
|
|
@@ -23,5 +22,4 @@ import { BetterAuthOptions } from "@better-auth/core";
|
|
|
23
22
|
* database: drizzleAdapter(db, { provider: "pg" }),
|
|
24
23
|
* });
|
|
25
24
|
*/
|
|
26
|
-
export declare const betterAuth: <Options extends BetterAuthOptions>(options: Options & {}) => Auth<Options>;
|
|
27
|
-
//#endregion
|
|
25
|
+
export declare const betterAuth: <Options extends BetterAuthOptions>(options: Options & {}) => Auth<Options>;
|
package/dist/auth/full.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { init } from "../context/init.mjs";
|
|
2
2
|
import { createBetterAuth } from "./base.mjs";
|
|
3
|
-
|
|
3
|
+
// src/auth/full.ts
|
|
4
4
|
/**
|
|
5
5
|
* Better Auth initializer for full mode (with Kysely)
|
|
6
6
|
*
|
|
@@ -25,5 +25,4 @@ import { createBetterAuth } from "./base.mjs";
|
|
|
25
25
|
const betterAuth = (options) => {
|
|
26
26
|
return createBetterAuth(options, init);
|
|
27
27
|
};
|
|
28
|
-
//#endregion
|
|
29
28
|
export { betterAuth };
|
package/dist/auth/minimal.d.mts
CHANGED
|
@@ -1,10 +1,8 @@
|
|
|
1
1
|
import { Auth } from "../types/auth.mjs";
|
|
2
2
|
import "../types/index.mjs";
|
|
3
3
|
import { BetterAuthOptions } from "@better-auth/core";
|
|
4
|
-
//#region src/auth/minimal.d.ts
|
|
5
4
|
/**
|
|
6
5
|
* Better Auth initializer for minimal mode (without Kysely)
|
|
7
6
|
*/
|
|
8
7
|
export declare const betterAuth: <Options extends BetterAuthOptions>(options: Options & {}) => Auth<Options>;
|
|
9
|
-
//#endregion
|
|
10
8
|
export type { BetterAuthOptions };
|
package/dist/auth/minimal.mjs
CHANGED
|
@@ -1,11 +1,10 @@
|
|
|
1
|
-
import { createBetterAuth } from "./base.mjs";
|
|
2
1
|
import { initMinimal } from "../context/init-minimal.mjs";
|
|
3
|
-
|
|
2
|
+
import { createBetterAuth } from "./base.mjs";
|
|
3
|
+
// src/auth/minimal.ts
|
|
4
4
|
/**
|
|
5
5
|
* Better Auth initializer for minimal mode (without Kysely)
|
|
6
6
|
*/
|
|
7
7
|
const betterAuth = (options) => {
|
|
8
8
|
return createBetterAuth(options, initMinimal);
|
|
9
9
|
};
|
|
10
|
-
//#endregion
|
|
11
10
|
export { betterAuth };
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { wildcardMatch } from "../utils/wildcard.mjs";
|
|
2
1
|
import { getHost, getOrigin, getProtocol } from "../utils/url.mjs";
|
|
2
|
+
import { wildcardMatch } from "../utils/wildcard.mjs";
|
|
3
3
|
import * as z from "zod";
|
|
4
|
-
|
|
4
|
+
// src/auth/trusted-origins.ts
|
|
5
5
|
const CONTROL_CHARACTER_PATTERN = /[\u0000-\u001f\u007f-\u009f]/;
|
|
6
6
|
const RELATIVE_URL_PARSER_ORIGIN = "https://better-auth.invalid";
|
|
7
7
|
const ENCODED_PATH_SEPARATOR_PATTERN = /%2[fF]|%5[cC]/;
|
|
@@ -127,5 +127,4 @@ const matchesOriginPattern = (url, pattern, settings) => {
|
|
|
127
127
|
if (!parsedPattern.path) return true;
|
|
128
128
|
return parsed.path === parsedPattern.path || parsed.path.startsWith(`${parsedPattern.path}/`);
|
|
129
129
|
};
|
|
130
|
-
//#endregion
|
|
131
130
|
export { matchesOriginPattern };
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
//#region src/client/broadcast-channel.d.ts
|
|
2
1
|
export interface BroadcastMessage {
|
|
3
2
|
event?: "session" | undefined;
|
|
4
3
|
data?: {
|
|
@@ -14,5 +13,4 @@ export interface BroadcastChannel {
|
|
|
14
13
|
subscribe(listener: BroadcastListener): () => void;
|
|
15
14
|
setup(): () => void;
|
|
16
15
|
}
|
|
17
|
-
export declare function getGlobalBroadcastChannel(name?: string): BroadcastChannel;
|
|
18
|
-
//#endregion
|
|
16
|
+
export declare function getGlobalBroadcastChannel(name?: string): BroadcastChannel;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
// src/client/broadcast-channel.ts
|
|
2
2
|
const kBroadcastChannel = Symbol.for("better-auth:broadcast-channel");
|
|
3
3
|
const now = () => Math.floor(Date.now() / 1e3);
|
|
4
4
|
var WindowBroadcastChannel = class {
|
|
@@ -24,15 +24,16 @@ var WindowBroadcastChannel = class {
|
|
|
24
24
|
}
|
|
25
25
|
setup() {
|
|
26
26
|
if (typeof window === "undefined" || typeof window.addEventListener === "undefined") return () => {};
|
|
27
|
+
const target = window;
|
|
27
28
|
const handler = (event) => {
|
|
28
29
|
if (event.key !== this.name) return;
|
|
29
30
|
const message = JSON.parse(event.newValue ?? "{}");
|
|
30
31
|
if (message?.event !== "session" || !message?.data) return;
|
|
31
32
|
this.listeners.forEach((listener) => listener(message));
|
|
32
33
|
};
|
|
33
|
-
|
|
34
|
+
target.addEventListener("storage", handler);
|
|
34
35
|
return () => {
|
|
35
|
-
|
|
36
|
+
target.removeEventListener("storage", handler);
|
|
36
37
|
};
|
|
37
38
|
}
|
|
38
39
|
};
|
|
@@ -40,5 +41,4 @@ function getGlobalBroadcastChannel(name = "better-auth.message") {
|
|
|
40
41
|
if (!globalThis[kBroadcastChannel]) globalThis[kBroadcastChannel] = new WindowBroadcastChannel(name);
|
|
41
42
|
return globalThis[kBroadcastChannel];
|
|
42
43
|
}
|
|
43
|
-
//#endregion
|
|
44
44
|
export { getGlobalBroadcastChannel, kBroadcastChannel };
|
package/dist/client/config.d.mts
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { SessionData } from "./session-atom.mjs";
|
|
2
2
|
import { BetterAuthClientOptions, ClientAtomListener } from "@better-auth/core";
|
|
3
3
|
import { WritableAtom } from "nanostores";
|
|
4
|
-
//#region src/client/config.d.ts
|
|
5
4
|
export declare const getClientConfig: (options?: BetterAuthClientOptions | undefined, loadEnv?: boolean | undefined) => {
|
|
6
5
|
readonly baseURL: string;
|
|
7
6
|
pluginsActions: Record<string, any>;
|
|
@@ -82,5 +81,4 @@ export declare const getClientConfig: (options?: BetterAuthClientOptions | undef
|
|
|
82
81
|
listen: (signal: Omit<string, "$sessionSignal"> | "$sessionSignal", listener: (value: boolean, oldValue?: boolean | undefined) => void) => void;
|
|
83
82
|
atoms: Record<string, WritableAtom<any>>;
|
|
84
83
|
};
|
|
85
|
-
};
|
|
86
|
-
//#endregion
|
|
84
|
+
};
|
package/dist/client/config.mjs
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { getBaseURL } from "../utils/url.mjs";
|
|
2
|
-
import { parseJSON } from "./parser.mjs";
|
|
3
2
|
import { redirectPlugin } from "./fetch-plugins.mjs";
|
|
3
|
+
import { parseJSON } from "./parser.mjs";
|
|
4
4
|
import { getSessionAtom, hydrateSessionAtom } from "./session-atom.mjs";
|
|
5
5
|
import { defu as defu$1 } from "defu";
|
|
6
6
|
import { createFetch } from "@better-fetch/fetch";
|
|
7
|
-
|
|
7
|
+
// src/client/config.ts
|
|
8
8
|
const resolvePublicAuthUrl = (basePath) => {
|
|
9
9
|
if (typeof process === "undefined") return void 0;
|
|
10
10
|
const path = basePath ?? "/api/auth";
|
|
@@ -108,5 +108,4 @@ const getClientConfig = (options, loadEnv) => {
|
|
|
108
108
|
$store
|
|
109
109
|
};
|
|
110
110
|
};
|
|
111
|
-
//#endregion
|
|
112
111
|
export { getClientConfig, matchesSessionSignal };
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { Store, StoreValue } from "nanostores";
|
|
2
|
-
//#region src/client/equality.d.ts
|
|
3
2
|
/**
|
|
4
3
|
* Deep structural equality for JSON-serializable values.
|
|
5
4
|
* Handles: primitives, null, arrays, and plain objects.
|
|
@@ -13,5 +12,4 @@ export declare function isJsonEqual(a: unknown, b: unknown): boolean;
|
|
|
13
12
|
*
|
|
14
13
|
* Returns the unsubscribe function from `onSet`.
|
|
15
14
|
*/
|
|
16
|
-
export declare function withEquality<S extends Store>(store: S, isEqual: (a: StoreValue<S>, b: StoreValue<S>) => boolean): () => void;
|
|
17
|
-
//#endregion
|
|
15
|
+
export declare function withEquality<S extends Store>(store: S, isEqual: (a: StoreValue<S>, b: StoreValue<S>) => boolean): () => void;
|
package/dist/client/equality.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { onSet } from "nanostores";
|
|
2
|
-
|
|
2
|
+
// src/client/equality.ts
|
|
3
3
|
function isPlainObject(value) {
|
|
4
4
|
if (typeof value !== "object" || value === null) return false;
|
|
5
5
|
const prototype = Object.getPrototypeOf(value);
|
|
@@ -38,5 +38,4 @@ function withEquality(store, isEqual) {
|
|
|
38
38
|
if (isEqual(store.value, newValue)) abort();
|
|
39
39
|
});
|
|
40
40
|
}
|
|
41
|
-
//#endregion
|
|
42
41
|
export { isJsonEqual, withEquality };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { isSafeUrlScheme } from "@better-auth/core/utils/url";
|
|
2
|
-
|
|
2
|
+
// src/client/fetch-plugins.ts
|
|
3
3
|
const redirectPlugin = {
|
|
4
4
|
id: "redirect",
|
|
5
5
|
name: "Redirect",
|
|
@@ -13,5 +13,4 @@ const redirectPlugin = {
|
|
|
13
13
|
}
|
|
14
14
|
} }
|
|
15
15
|
};
|
|
16
|
-
//#endregion
|
|
17
16
|
export { redirectPlugin };
|
|
@@ -1,9 +1,7 @@
|
|
|
1
|
-
//#region src/client/focus-manager.d.ts
|
|
2
1
|
export type FocusListener = (focused: boolean) => void;
|
|
3
2
|
export declare const kFocusManager: unique symbol;
|
|
4
3
|
export interface FocusManager {
|
|
5
4
|
setFocused(focused: boolean): void;
|
|
6
5
|
subscribe(listener: FocusListener): () => void;
|
|
7
6
|
setup(): () => void;
|
|
8
|
-
}
|
|
9
|
-
//#endregion
|
|
7
|
+
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
// src/client/focus-manager.ts
|
|
2
2
|
const kFocusManager = Symbol.for("better-auth:focus-manager");
|
|
3
3
|
var WindowFocusManager = class {
|
|
4
4
|
listeners = /* @__PURE__ */ new Set();
|
|
@@ -13,12 +13,13 @@ var WindowFocusManager = class {
|
|
|
13
13
|
}
|
|
14
14
|
setup() {
|
|
15
15
|
if (typeof window === "undefined" || typeof document === "undefined" || typeof window.addEventListener === "undefined") return () => {};
|
|
16
|
+
const target = document;
|
|
16
17
|
const visibilityHandler = () => {
|
|
17
18
|
if (document.visibilityState === "visible") this.setFocused(true);
|
|
18
19
|
};
|
|
19
|
-
|
|
20
|
+
target.addEventListener("visibilitychange", visibilityHandler, false);
|
|
20
21
|
return () => {
|
|
21
|
-
|
|
22
|
+
target.removeEventListener("visibilitychange", visibilityHandler, false);
|
|
22
23
|
};
|
|
23
24
|
}
|
|
24
25
|
};
|
|
@@ -26,5 +27,4 @@ function getGlobalFocusManager() {
|
|
|
26
27
|
if (!globalThis[kFocusManager]) globalThis[kFocusManager] = new WindowFocusManager();
|
|
27
28
|
return globalThis[kFocusManager];
|
|
28
29
|
}
|
|
29
|
-
//#endregion
|
|
30
30
|
export { getGlobalFocusManager, kFocusManager };
|