better-auth 1.8.0-beta.7 → 1.8.0-beta.9
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 +70 -4
- package/dist/api/index.mjs +11 -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 +12 -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/id-token-nonce.d.mts +83 -0
- package/dist/api/routes/id-token-nonce.mjs +79 -0
- package/dist/api/routes/index.d.mts +2 -1
- 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 +8 -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 +5 -6
- 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/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 +41 -16
- 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 +44 -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 +11 -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 +5 -3
- package/dist/plugins/one-tap/client.mjs +91 -79
- package/dist/plugins/one-tap/index.d.mts +41 -3
- package/dist/plugins/one-tap/index.mjs +117 -91
- 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 +5 -6
- 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 +8 -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
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import { getAwaitableValue } from "../../context/helpers.mjs";
|
|
2
|
+
import { generateRandomString } from "../../crypto/random.mjs";
|
|
3
|
+
import { APIError, BASE_ERROR_CODES } from "@better-auth/core/error";
|
|
4
|
+
import { SocialProviderListEnum } from "@better-auth/core/social-providers";
|
|
5
|
+
import { createAuthEndpoint } from "@better-auth/core/api";
|
|
6
|
+
import * as z from "zod";
|
|
7
|
+
// src/api/routes/id-token-nonce.ts
|
|
8
|
+
const ISSUED_NONCE_EXPIRES_IN_MS = 3e5;
|
|
9
|
+
const ISSUED_NONCE_LENGTH = 32;
|
|
10
|
+
const ISSUED_NONCE_PATTERN = new RegExp(`^[a-zA-Z0-9]{${ISSUED_NONCE_LENGTH}}$`);
|
|
11
|
+
/**
|
|
12
|
+
* Store a new single-use nonce under `scope` and return it. It expires after
|
|
13
|
+
* five minutes.
|
|
14
|
+
*/
|
|
15
|
+
async function issueNonce(ctx, scope) {
|
|
16
|
+
const nonce = generateRandomString(ISSUED_NONCE_LENGTH, "a-z", "A-Z", "0-9");
|
|
17
|
+
await ctx.context.internalAdapter.createVerificationValue({
|
|
18
|
+
identifier: `${scope}:${nonce}`,
|
|
19
|
+
value: scope,
|
|
20
|
+
expiresAt: new Date(Date.now() + ISSUED_NONCE_EXPIRES_IN_MS)
|
|
21
|
+
});
|
|
22
|
+
return nonce;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Consume a nonce that {@link issueNonce} stored under `scope`. Throws
|
|
26
|
+
* `INVALID_ID_TOKEN_NONCE` when it is missing, malformed, unknown, expired, or
|
|
27
|
+
* already used. Call it before verifying the token, so a failed attempt burns
|
|
28
|
+
* the nonce too.
|
|
29
|
+
*/
|
|
30
|
+
async function consumeNonce(ctx, scope, nonce) {
|
|
31
|
+
if (!(nonce && ISSUED_NONCE_PATTERN.test(nonce) ? await ctx.context.internalAdapter.consumeVerificationValue(`${scope}:${nonce}`) : null)) throw APIError.from("BAD_REQUEST", BASE_ERROR_CODES.INVALID_ID_TOKEN_NONCE);
|
|
32
|
+
}
|
|
33
|
+
/** OpenAPI responses for an endpoint that returns `{ nonce }` from {@link issueNonce}. */
|
|
34
|
+
const issuedNonceResponses = { 200: {
|
|
35
|
+
description: "Success",
|
|
36
|
+
content: { "application/json": { schema: {
|
|
37
|
+
type: "object",
|
|
38
|
+
properties: { nonce: { type: "string" } },
|
|
39
|
+
required: ["nonce"]
|
|
40
|
+
} } }
|
|
41
|
+
} };
|
|
42
|
+
const idTokenNonceScope = (providerId) => `id-token-nonce:${providerId}`;
|
|
43
|
+
const requiresIssuedNonce = (provider) => provider.options?.requireIssuedIdTokenNonce === true;
|
|
44
|
+
/**
|
|
45
|
+
* Consume the issued nonce presented with a client-submitted ID token, from
|
|
46
|
+
* `/sign-in/social` or `/link-social`. A no-op for providers without
|
|
47
|
+
* `requireIssuedIdTokenNonce`.
|
|
48
|
+
*/
|
|
49
|
+
async function consumeIssuedIdTokenNonce(ctx, provider, nonce) {
|
|
50
|
+
if (!requiresIssuedNonce(provider)) return;
|
|
51
|
+
await consumeNonce(ctx, idTokenNonceScope(provider.id), nonce);
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* ### Endpoint
|
|
55
|
+
*
|
|
56
|
+
* POST `/id-token/nonce`
|
|
57
|
+
*
|
|
58
|
+
* Issues a single-use nonce for a client to pass to the provider's SDK before
|
|
59
|
+
* submitting the resulting ID token to `/sign-in/social` or `/link-social`.
|
|
60
|
+
* Only available for providers that set `requireIssuedIdTokenNonce`.
|
|
61
|
+
*/
|
|
62
|
+
const issueIdTokenNonce = createAuthEndpoint("/id-token/nonce", {
|
|
63
|
+
method: "POST",
|
|
64
|
+
body: z.object({ provider: SocialProviderListEnum }),
|
|
65
|
+
metadata: {
|
|
66
|
+
noStore: true,
|
|
67
|
+
openapi: {
|
|
68
|
+
description: "Issue a single-use nonce to bind a provider ID token to one sign-in or account-linking request",
|
|
69
|
+
responses: issuedNonceResponses
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
}, async (ctx) => {
|
|
73
|
+
const provider = await getAwaitableValue(ctx.context.socialProviders, { value: ctx.body.provider });
|
|
74
|
+
if (!provider) throw APIError.from("NOT_FOUND", BASE_ERROR_CODES.PROVIDER_NOT_FOUND);
|
|
75
|
+
if (!requiresIssuedNonce(provider)) throw APIError.from("BAD_REQUEST", BASE_ERROR_CODES.ID_TOKEN_NONCE_NOT_ENABLED);
|
|
76
|
+
const nonce = await issueNonce(ctx, idTokenNonceScope(provider.id));
|
|
77
|
+
return ctx.json({ nonce });
|
|
78
|
+
});
|
|
79
|
+
export { consumeIssuedIdTokenNonce, consumeNonce, issueIdTokenNonce, issueNonce, issuedNonceResponses };
|
|
@@ -2,6 +2,7 @@ import { accountInfo, getAccessToken, linkSocialAccount, listUserAccounts, refre
|
|
|
2
2
|
import { callbackOAuth } from "./callback.mjs";
|
|
3
3
|
import { createEmailVerificationToken, sendVerificationEmail, sendVerificationEmailFn, verifyEmail } from "./email-verification.mjs";
|
|
4
4
|
import { error } from "./error.mjs";
|
|
5
|
+
import { consumeIssuedIdTokenNonce, consumeNonce, issueIdTokenNonce, issueNonce, issuedNonceResponses } from "./id-token-nonce.mjs";
|
|
5
6
|
import { ok } from "./ok.mjs";
|
|
6
7
|
import { requestPasswordReset, requestPasswordResetCallback, resetPassword, verifyPassword } from "./password.mjs";
|
|
7
8
|
import { freshSessionMiddleware, getAuthoritativeSessionFromCtx, getSession, getSessionFromCtx, isStateful, listSessions, requestOnlySessionMiddleware, revokeOtherSessions, revokeSession, revokeSessions, sensitiveSessionMiddleware, sessionMiddleware } from "./session.mjs";
|
|
@@ -10,4 +11,4 @@ import { signOut } from "./sign-out.mjs";
|
|
|
10
11
|
import { signUpEmail } from "./sign-up.mjs";
|
|
11
12
|
import { updateSession } from "./update-session.mjs";
|
|
12
13
|
import { changeEmail, changePassword, deleteUser, deleteUserCallback, setPassword, updateUser } from "./update-user.mjs";
|
|
13
|
-
export { accountInfo, callbackOAuth, changeEmail, changePassword, createEmailVerificationToken, deleteUser, deleteUserCallback, error, freshSessionMiddleware, getAccessToken, getAuthoritativeSessionFromCtx, getSession, getSessionFromCtx, isStateful, linkSocialAccount, listSessions, listUserAccounts, ok, refreshToken, requestOnlySessionMiddleware, requestPasswordReset, requestPasswordResetCallback, resetPassword, revokeOtherSessions, revokeSession, revokeSessions, sendVerificationEmail, sendVerificationEmailFn, sensitiveSessionMiddleware, sessionMiddleware, setPassword, signInEmail, signInSocial, signOut, signUpEmail, unlinkAccount, updateSession, updateUser, verifyEmail, verifyPassword };
|
|
14
|
+
export { accountInfo, callbackOAuth, changeEmail, changePassword, consumeIssuedIdTokenNonce, consumeNonce, createEmailVerificationToken, deleteUser, deleteUserCallback, error, freshSessionMiddleware, getAccessToken, getAuthoritativeSessionFromCtx, getSession, getSessionFromCtx, isStateful, issueIdTokenNonce, issueNonce, issuedNonceResponses, linkSocialAccount, listSessions, listUserAccounts, ok, refreshToken, requestOnlySessionMiddleware, requestPasswordReset, requestPasswordResetCallback, resetPassword, revokeOtherSessions, revokeSession, revokeSessions, sendVerificationEmail, sendVerificationEmailFn, sensitiveSessionMiddleware, sessionMiddleware, setPassword, signInEmail, signInSocial, signOut, signUpEmail, unlinkAccount, updateSession, updateUser, verifyEmail, verifyPassword };
|
package/dist/api/routes/ok.d.mts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
//#region src/api/routes/ok.d.ts
|
|
2
1
|
export declare const ok: import("better-call").StrictEndpoint<"/ok", {
|
|
3
2
|
method: "GET";
|
|
4
3
|
metadata: {
|
|
@@ -28,5 +27,4 @@ export declare const ok: import("better-call").StrictEndpoint<"/ok", {
|
|
|
28
27
|
};
|
|
29
28
|
}, {
|
|
30
29
|
ok: boolean;
|
|
31
|
-
}>;
|
|
32
|
-
//#endregion
|
|
30
|
+
}>;
|
package/dist/api/routes/ok.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { HIDE_METADATA } from "../../utils/hide-metadata.mjs";
|
|
2
2
|
import { createAuthEndpoint } from "@better-auth/core/api";
|
|
3
|
-
|
|
3
|
+
// src/api/routes/ok.ts
|
|
4
4
|
const ok = createAuthEndpoint("/ok", {
|
|
5
5
|
method: "GET",
|
|
6
6
|
metadata: {
|
|
@@ -23,5 +23,4 @@ const ok = createAuthEndpoint("/ok", {
|
|
|
23
23
|
}, async (ctx) => {
|
|
24
24
|
return ctx.json({ ok: true });
|
|
25
25
|
});
|
|
26
|
-
//#endregion
|
|
27
26
|
export { ok };
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import * as z from "zod";
|
|
2
|
-
//#region src/api/routes/password.d.ts
|
|
3
2
|
export declare const requestPasswordReset: import("better-call").StrictEndpoint<"/request-password-reset", {
|
|
4
3
|
method: "POST";
|
|
5
4
|
body: z.ZodObject<{
|
|
@@ -175,5 +174,4 @@ export declare const verifyPassword: import("better-call").StrictEndpoint<"/veri
|
|
|
175
174
|
}>>[];
|
|
176
175
|
}, {
|
|
177
176
|
status: boolean;
|
|
178
|
-
}>;
|
|
179
|
-
//#endregion
|
|
177
|
+
}>;
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import { originCheck } from "../middlewares/origin-check.mjs";
|
|
2
1
|
import { getDate } from "../../utils/date.mjs";
|
|
3
|
-
import { sensitiveSessionMiddleware } from "./session.mjs";
|
|
4
2
|
import { assertPasswordNotTooLong, assertPasswordNotTooShort, resetCredentialPassword, validatePassword } from "../../utils/password.mjs";
|
|
3
|
+
import { originCheck } from "../middlewares/origin-check.mjs";
|
|
4
|
+
import { sensitiveSessionMiddleware } from "./session.mjs";
|
|
5
5
|
import { APIError, BASE_ERROR_CODES } from "@better-auth/core/error";
|
|
6
6
|
import { generateId } from "@better-auth/core/utils/id";
|
|
7
7
|
import { createAuthEndpoint } from "@better-auth/core/api";
|
|
8
8
|
import * as z from "zod";
|
|
9
|
-
|
|
9
|
+
// src/api/routes/password.ts
|
|
10
10
|
function redirectError(ctx, callbackURL, query) {
|
|
11
11
|
const url = callbackURL ? new URL(callbackURL, ctx.baseURL) : new URL(`${ctx.baseURL}/error`);
|
|
12
12
|
if (query) Object.entries(query).forEach(([k, v]) => url.searchParams.set(k, v));
|
|
@@ -195,5 +195,4 @@ password: z.string().meta({ description: "The password to verify" }) }),
|
|
|
195
195
|
})) throw APIError.from("BAD_REQUEST", BASE_ERROR_CODES.INVALID_PASSWORD);
|
|
196
196
|
return ctx.json({ status: true });
|
|
197
197
|
});
|
|
198
|
-
//#endregion
|
|
199
198
|
export { requestPasswordReset, requestPasswordResetCallback, resetPassword, verifyPassword };
|
|
@@ -3,7 +3,6 @@ import { Session, User } from "../../types/models.mjs";
|
|
|
3
3
|
import "../../types/index.mjs";
|
|
4
4
|
import { BetterAuthOptions, GenericEndpointContext } from "@better-auth/core";
|
|
5
5
|
import * as z from "zod";
|
|
6
|
-
//#region src/api/routes/session.d.ts
|
|
7
6
|
export declare const getSession: <Option extends BetterAuthOptions>() => import("better-call").StrictEndpoint<"/get-session", {
|
|
8
7
|
method: ("GET" | "POST")[];
|
|
9
8
|
operationId: string;
|
|
@@ -12,6 +11,7 @@ export declare const getSession: <Option extends BetterAuthOptions>() => import(
|
|
|
12
11
|
disableRefresh: z.ZodOptional<z.ZodCoercedBoolean<unknown>>;
|
|
13
12
|
}, z.core.$strip>>;
|
|
14
13
|
requireHeaders: true;
|
|
14
|
+
disableBody: true;
|
|
15
15
|
metadata: {
|
|
16
16
|
openapi: {
|
|
17
17
|
operationId: string;
|
|
@@ -443,5 +443,4 @@ export declare const revokeOtherSessions: import("better-call").StrictEndpoint<"
|
|
|
443
443
|
};
|
|
444
444
|
}, {
|
|
445
445
|
status: boolean;
|
|
446
|
-
}>;
|
|
447
|
-
//#endregion
|
|
446
|
+
}>;
|
|
@@ -1,19 +1,20 @@
|
|
|
1
|
-
import { isAPIError } from "../../utils/is-api-error.mjs";
|
|
2
1
|
import { hasServerSessionStore } from "../../context/store-capabilities.mjs";
|
|
2
|
+
import { decodeCookieCache, deleteSessionCookie, expireCookie, setCookieCache, setSessionCookie } from "../../cookies/index.mjs";
|
|
3
|
+
import { createSessionStore, getChunkedCookie, getSessionQuerySchema } from "../../cookies/session-store.mjs";
|
|
3
4
|
import { parseSessionOutput, parseUserOutput } from "../../db/schema.mjs";
|
|
4
5
|
import { getDate } from "../../utils/date.mjs";
|
|
5
|
-
import {
|
|
6
|
-
import { decodeCookieCache, deleteSessionCookie, expireCookie, setCookieCache, setSessionCookie } from "../../cookies/index.mjs";
|
|
6
|
+
import { isAPIError } from "../../utils/is-api-error.mjs";
|
|
7
7
|
import { getShouldSkipSessionRefresh } from "../state/should-session-refresh.mjs";
|
|
8
8
|
import { APIError, BASE_ERROR_CODES } from "@better-auth/core/error";
|
|
9
9
|
import { createAuthEndpoint, createAuthMiddleware } from "@better-auth/core/api";
|
|
10
10
|
import * as z from "zod";
|
|
11
|
-
|
|
11
|
+
// src/api/routes/session.ts
|
|
12
12
|
const getSession = () => createAuthEndpoint("/get-session", {
|
|
13
13
|
method: ["GET", "POST"],
|
|
14
14
|
operationId: "getSession",
|
|
15
15
|
query: getSessionQuerySchema,
|
|
16
16
|
requireHeaders: true,
|
|
17
|
+
disableBody: true,
|
|
17
18
|
metadata: { openapi: {
|
|
18
19
|
operationId: "getSession",
|
|
19
20
|
description: "Get the current session",
|
|
@@ -32,6 +33,7 @@ const getSession = () => createAuthEndpoint("/get-session", {
|
|
|
32
33
|
}, async (ctx) => {
|
|
33
34
|
ctx.setHeader("cache-control", "no-store");
|
|
34
35
|
ctx.setHeader("pragma", "no-cache");
|
|
36
|
+
ctx.context.session = null;
|
|
35
37
|
const deferSessionRefresh = ctx.context.options.session?.deferSessionRefresh;
|
|
36
38
|
const isPostRequest = ctx.method === "POST";
|
|
37
39
|
if (isPostRequest && !deferSessionRefresh) throw APIError.from("METHOD_NOT_ALLOWED", BASE_ERROR_CODES.METHOD_NOT_ALLOWED_DEFER_SESSION_REQUIRED);
|
|
@@ -151,7 +153,6 @@ const getSession = () => createAuthEndpoint("/get-session", {
|
|
|
151
153
|
}
|
|
152
154
|
}
|
|
153
155
|
const session = await ctx.context.internalAdapter.findSession(sessionCookieToken);
|
|
154
|
-
ctx.context.session = session;
|
|
155
156
|
if (!session || session.session.expiresAt < /* @__PURE__ */ new Date()) {
|
|
156
157
|
deleteSessionCookie(ctx);
|
|
157
158
|
if (session) {
|
|
@@ -163,6 +164,7 @@ const getSession = () => createAuthEndpoint("/get-session", {
|
|
|
163
164
|
}
|
|
164
165
|
return ctx.json(null);
|
|
165
166
|
}
|
|
167
|
+
ctx.context.session = session;
|
|
166
168
|
/**
|
|
167
169
|
* We don't need to update the session if the user doesn't want to be remembered
|
|
168
170
|
* or if the session refresh is disabled
|
|
@@ -227,6 +229,7 @@ const getSession = () => createAuthEndpoint("/get-session", {
|
|
|
227
229
|
user: parsedUser
|
|
228
230
|
});
|
|
229
231
|
} catch (error) {
|
|
232
|
+
ctx.context.session = null;
|
|
230
233
|
if (isAPIError(error)) throw error;
|
|
231
234
|
ctx.context.logger.error("INTERNAL_SERVER_ERROR", error);
|
|
232
235
|
throw APIError.from("INTERNAL_SERVER_ERROR", BASE_ERROR_CODES.FAILED_TO_GET_SESSION, { cause: error });
|
|
@@ -412,6 +415,7 @@ const revokeSession = createAuthEndpoint("/revoke-session", {
|
|
|
412
415
|
code: "INTERNAL_SERVER_ERROR"
|
|
413
416
|
});
|
|
414
417
|
}
|
|
418
|
+
if (token === ctx.context.session.session.token) deleteSessionCookie(ctx);
|
|
415
419
|
return ctx.json({ status: true });
|
|
416
420
|
});
|
|
417
421
|
/**
|
|
@@ -445,6 +449,7 @@ const revokeSessions = createAuthEndpoint("/revoke-sessions", {
|
|
|
445
449
|
code: "INTERNAL_SERVER_ERROR"
|
|
446
450
|
});
|
|
447
451
|
}
|
|
452
|
+
deleteSessionCookie(ctx);
|
|
448
453
|
return ctx.json({ status: true });
|
|
449
454
|
});
|
|
450
455
|
const revokeOtherSessions = createAuthEndpoint("/revoke-other-sessions", {
|
|
@@ -477,5 +482,4 @@ const revokeOtherSessions = createAuthEndpoint("/revoke-other-sessions", {
|
|
|
477
482
|
await Promise.all(otherSessions.map((session) => ctx.context.internalAdapter.deleteSession(session.token)));
|
|
478
483
|
return ctx.json({ status: true });
|
|
479
484
|
});
|
|
480
|
-
//#endregion
|
|
481
485
|
export { freshSessionMiddleware, getAuthoritativeSessionFromCtx, getSession, getSessionFromCtx, isStateful, listSessions, requestOnlySessionMiddleware, revokeOtherSessions, revokeSession, revokeSessions, sensitiveSessionMiddleware, sessionMiddleware };
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { BetterAuthOptions } from "@better-auth/core";
|
|
2
2
|
import { User } from "@better-auth/core/db";
|
|
3
3
|
import * as z from "zod";
|
|
4
|
-
//#region src/api/routes/sign-in.d.ts
|
|
5
4
|
declare const socialSignInBodySchema: z.ZodObject<{
|
|
6
5
|
callbackURL: z.ZodOptional<z.ZodString>;
|
|
7
6
|
newUserCallbackURL: z.ZodOptional<z.ZodString>;
|
|
@@ -180,5 +179,4 @@ export declare const signInEmail: <O extends BetterAuthOptions>() => import("bet
|
|
|
180
179
|
url?: string | undefined;
|
|
181
180
|
user: User<O["user"], O["plugins"]>;
|
|
182
181
|
}>;
|
|
183
|
-
//#endregion
|
|
184
182
|
export {};
|
|
@@ -1,21 +1,22 @@
|
|
|
1
|
-
import { formCsrfMiddleware } from "../middlewares/origin-check.mjs";
|
|
2
|
-
import { parseUserOutput } from "../../db/schema.mjs";
|
|
3
|
-
import { setSessionCookie } from "../../cookies/index.mjs";
|
|
4
1
|
import { getAwaitableValue } from "../../context/helpers.mjs";
|
|
2
|
+
import { setSessionCookie } from "../../cookies/index.mjs";
|
|
3
|
+
import { parseUserOutput } from "../../db/schema.mjs";
|
|
5
4
|
import { resolveOAuthAccountKeyForAPI, toOAuthProfileRecord } from "../../oauth2/account-key.mjs";
|
|
6
5
|
import { OAUTH_CALLBACK_ERROR_CODES, missingEmailLogMessage } from "../../oauth2/errors.mjs";
|
|
7
|
-
import { getOAuthCallbackPath } from "../../oauth2/utils.mjs";
|
|
8
6
|
import { handleOAuthUserInfo } from "../../oauth2/link-account.mjs";
|
|
7
|
+
import { getOAuthCallbackPath } from "../../oauth2/utils.mjs";
|
|
9
8
|
import { generateIdTokenNonce, generateState } from "../../oauth2/state.mjs";
|
|
9
|
+
import { assertPasswordNotTooLong } from "../../utils/password.mjs";
|
|
10
10
|
import { safeCloneRequest } from "../../utils/request.mjs";
|
|
11
|
+
import { formCsrfMiddleware } from "../middlewares/origin-check.mjs";
|
|
11
12
|
import { createEmailVerificationToken } from "./email-verification.mjs";
|
|
12
|
-
import {
|
|
13
|
+
import { consumeIssuedIdTokenNonce } from "./id-token-nonce.mjs";
|
|
13
14
|
import { APIError, BASE_ERROR_CODES } from "@better-auth/core/error";
|
|
14
15
|
import { additionalAuthorizationParamsSchema, supportsIdTokenSignIn, verifyProviderIdToken } from "@better-auth/core/oauth2";
|
|
15
16
|
import { SocialProviderListEnum } from "@better-auth/core/social-providers";
|
|
16
17
|
import { createAuthEndpoint } from "@better-auth/core/api";
|
|
17
18
|
import * as z from "zod";
|
|
18
|
-
|
|
19
|
+
// src/api/routes/sign-in.ts
|
|
19
20
|
const socialSignInBodySchema = z.object({
|
|
20
21
|
/**
|
|
21
22
|
* Callback URL to redirect to after the user
|
|
@@ -157,6 +158,7 @@ const signInSocial = () => createAuthEndpoint("/sign-in/social", {
|
|
|
157
158
|
throw APIError.from("NOT_FOUND", BASE_ERROR_CODES.ID_TOKEN_NOT_SUPPORTED);
|
|
158
159
|
}
|
|
159
160
|
const { token, nonce } = c.body.idToken;
|
|
161
|
+
await consumeIssuedIdTokenNonce(c, provider, nonce);
|
|
160
162
|
if (!await verifyProviderIdToken(provider, token, nonce, c)) {
|
|
161
163
|
c.context.logger.warn("Invalid id token", { provider: c.body.provider });
|
|
162
164
|
throw APIError.from("UNAUTHORIZED", BASE_ERROR_CODES.INVALID_TOKEN);
|
|
@@ -366,5 +368,4 @@ const signInEmail = () => createAuthEndpoint("/sign-in/email", {
|
|
|
366
368
|
user: parseUserOutput(ctx.context.options, user)
|
|
367
369
|
});
|
|
368
370
|
});
|
|
369
|
-
//#endregion
|
|
370
371
|
export { signInEmail, signInSocial };
|
|
@@ -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 { assertPasswordNotTooLong, assertPasswordNotTooShort } from "../../utils/password.mjs";
|
|
8
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(),
|
|
@@ -276,5 +276,4 @@ const signUpEmail = () => createAuthEndpoint("/sign-up/email", {
|
|
|
276
276
|
});
|
|
277
277
|
});
|
|
278
278
|
});
|
|
279
|
-
//#endregion
|
|
280
279
|
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/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 };
|