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
package/dist/db/get-schema.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { getAuthTablesWithResolvedIndexes } from "@better-auth/core/db/internal";
|
|
2
|
-
|
|
2
|
+
// src/db/get-schema.ts
|
|
3
3
|
function getSchema(config) {
|
|
4
4
|
return buildSchema(config).schema;
|
|
5
5
|
}
|
|
@@ -51,5 +51,4 @@ function buildSchema(config) {
|
|
|
51
51
|
referenceKeys
|
|
52
52
|
};
|
|
53
53
|
}
|
|
54
|
-
//#endregion
|
|
55
54
|
export { buildSchema, getSchema };
|
package/dist/db/index.d.mts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { FieldAttributeToObject, InferAdditionalFieldsFromPluginOptions, InferFieldsInputClient, InferFieldsOutput, RemoveFieldsWithReturnedFalse } from "./field.mjs";
|
|
2
2
|
import { convertFromDB, convertToDB } from "./field-converter.mjs";
|
|
3
3
|
import { getSchema } from "./get-schema.mjs";
|
|
4
|
-
import { DatabaseHooksEntry, getWithHooks } from "./with-hooks.mjs";
|
|
5
4
|
import { createInternalAdapter } from "./internal-adapter.mjs";
|
|
6
5
|
import { revokeUnprovenAccountAccess } from "./revoke-unproven-account-access.mjs";
|
|
7
6
|
import { buildSyntheticUserOutput, getSessionDefaultFields, mergeSchema, parseAccountInput, parseAccountOutput, parseAdditionalUserInput, parseAdditionalUserInputFromProviderProfile, parseInputData, parseSessionInput, parseSessionOutput, parseUserInput, parseUserOutput } from "./schema.mjs";
|
|
8
7
|
import { FieldAttributeToSchema, toZodSchema } from "./to-zod.mjs";
|
|
8
|
+
import { DatabaseHooksEntry, getWithHooks } from "./with-hooks.mjs";
|
|
9
9
|
export * from "@better-auth/core/db";
|
|
10
10
|
export { DatabaseHooksEntry, FieldAttributeToObject, FieldAttributeToSchema, InferAdditionalFieldsFromPluginOptions, InferFieldsInputClient, InferFieldsOutput, RemoveFieldsWithReturnedFalse, buildSyntheticUserOutput, convertFromDB, convertToDB, createInternalAdapter, getSchema, getSessionDefaultFields, getWithHooks, mergeSchema, parseAccountInput, parseAccountOutput, parseAdditionalUserInput, parseAdditionalUserInputFromProviderProfile, parseInputData, parseSessionInput, parseSessionOutput, parseUserInput, parseUserOutput, revokeUnprovenAccountAccess, toZodSchema };
|
package/dist/db/index.mjs
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { __exportAll, __reExport } from "../_virtual/_rolldown/runtime.mjs";
|
|
2
|
-
import { getSchema } from "./get-schema.mjs";
|
|
3
|
-
import { buildSyntheticUserOutput, getSessionDefaultFields, mergeSchema, parseAccountInput, parseAccountOutput, parseAdditionalUserInput, parseAdditionalUserInputFromProviderProfile, parseInputData, parseSessionInput, parseSessionOutput, parseUserInput, parseUserOutput } from "./schema.mjs";
|
|
4
2
|
import { convertFromDB, convertToDB } from "./field-converter.mjs";
|
|
5
|
-
import {
|
|
3
|
+
import { getSchema } from "./get-schema.mjs";
|
|
6
4
|
import { createInternalAdapter } from "./internal-adapter.mjs";
|
|
7
5
|
import { revokeUnprovenAccountAccess } from "./revoke-unproven-account-access.mjs";
|
|
6
|
+
import { buildSyntheticUserOutput, getSessionDefaultFields, mergeSchema, parseAccountInput, parseAccountOutput, parseAdditionalUserInput, parseAdditionalUserInputFromProviderProfile, parseInputData, parseSessionInput, parseSessionOutput, parseUserInput, parseUserOutput } from "./schema.mjs";
|
|
8
7
|
import { toZodSchema } from "./to-zod.mjs";
|
|
8
|
+
import { getWithHooks } from "./with-hooks.mjs";
|
|
9
9
|
export * from "@better-auth/core/db";
|
|
10
|
-
|
|
10
|
+
// src/db/index.ts
|
|
11
11
|
var db_exports = /* @__PURE__ */ __exportAll({
|
|
12
12
|
buildSyntheticUserOutput: () => buildSyntheticUserOutput,
|
|
13
13
|
convertFromDB: () => convertFromDB,
|
|
@@ -31,5 +31,4 @@ var db_exports = /* @__PURE__ */ __exportAll({
|
|
|
31
31
|
});
|
|
32
32
|
import * as import__better_auth_core_db from "@better-auth/core/db";
|
|
33
33
|
__reExport(db_exports, import__better_auth_core_db);
|
|
34
|
-
//#endregion
|
|
35
34
|
export { buildSyntheticUserOutput, convertFromDB, convertToDB, createInternalAdapter, db_exports, getSchema, getSessionDefaultFields, getWithHooks, mergeSchema, parseAccountInput, parseAccountOutput, parseAdditionalUserInput, parseAdditionalUserInputFromProviderProfile, parseInputData, parseSessionInput, parseSessionOutput, parseUserInput, parseUserOutput, revokeUnprovenAccountAccess, toZodSchema };
|
|
@@ -2,11 +2,9 @@ import { DatabaseHooksEntry } from "./with-hooks.mjs";
|
|
|
2
2
|
import { AuthContext, BetterAuthOptions, InternalAdapter } from "@better-auth/core";
|
|
3
3
|
import { InternalLogger } from "@better-auth/core/env";
|
|
4
4
|
import { DBAdapter } from "@better-auth/core/db/adapter";
|
|
5
|
-
//#region src/db/internal-adapter.d.ts
|
|
6
5
|
export declare const createInternalAdapter: (adapter: DBAdapter<BetterAuthOptions>, ctx: {
|
|
7
6
|
options: Omit<BetterAuthOptions, "logger">;
|
|
8
7
|
logger: InternalLogger;
|
|
9
8
|
hooks: DatabaseHooksEntry[];
|
|
10
9
|
generateId: AuthContext["generateId"];
|
|
11
|
-
}) => InternalAdapter;
|
|
12
|
-
//#endregion
|
|
10
|
+
}) => InternalAdapter;
|
|
@@ -1,16 +1,17 @@
|
|
|
1
|
-
import { getSessionDefaultFields, parseSessionOutput, parseUserOutput } from "./schema.mjs";
|
|
2
1
|
import { getDate } from "../utils/date.mjs";
|
|
3
2
|
import { assertValidUserInfo, assertValidUserInfoSource } from "../utils/validate-user-info.mjs";
|
|
3
|
+
import { getSessionDefaultFields, parseSessionOutput, parseUserOutput } from "./schema.mjs";
|
|
4
4
|
import { getStorageOption, processIdentifier } from "./verification-token-storage.mjs";
|
|
5
5
|
import { getWithHooks } from "./with-hooks.mjs";
|
|
6
6
|
import { getCurrentAdapter, getCurrentAuthEndpointContext, queueAfterTransactionHook, runWithTransaction, tryGetCurrentAuthEndpointContext } from "@better-auth/core/context";
|
|
7
|
+
import { isWorkerd } from "@better-auth/core/env";
|
|
7
8
|
import { APIError, BetterAuthError } from "@better-auth/core/error";
|
|
8
9
|
import { generateId } from "@better-auth/core/utils/id";
|
|
9
10
|
import { safeJSONParse } from "@better-auth/core/utils/json";
|
|
10
11
|
import { encodeDeterministicId } from "@better-auth/core/db/internal";
|
|
11
12
|
import { getIP } from "@better-auth/core/utils/ip";
|
|
12
13
|
import { createHash } from "@better-auth/utils/hash";
|
|
13
|
-
|
|
14
|
+
// src/db/internal-adapter.ts
|
|
14
15
|
function getTTLSeconds(expiresAt, now = Date.now()) {
|
|
15
16
|
const expiresMs = typeof expiresAt === "number" ? expiresAt : expiresAt.getTime();
|
|
16
17
|
return Math.max(Math.floor((expiresMs - now) / 1e3), 0);
|
|
@@ -116,6 +117,7 @@ const createInternalAdapter = (adapter, ctx) => {
|
|
|
116
117
|
} });
|
|
117
118
|
}
|
|
118
119
|
async function withVerificationConsumeLock(key, fn) {
|
|
120
|
+
if (isWorkerd()) return fn();
|
|
119
121
|
const previous = verificationConsumeLocks.get(key) ?? Promise.resolve();
|
|
120
122
|
let release;
|
|
121
123
|
const current = new Promise((resolve) => {
|
|
@@ -878,19 +880,29 @@ const createInternalAdapter = (adapter, ctx) => {
|
|
|
878
880
|
field: "id",
|
|
879
881
|
value: latest.id
|
|
880
882
|
}], async () => {
|
|
881
|
-
|
|
883
|
+
await txAdapter.deleteMany({
|
|
884
|
+
model: "verification",
|
|
885
|
+
where: [
|
|
886
|
+
...where,
|
|
887
|
+
{
|
|
888
|
+
field: "id",
|
|
889
|
+
operator: "ne",
|
|
890
|
+
value: latest.id
|
|
891
|
+
},
|
|
892
|
+
{
|
|
893
|
+
field: "createdAt",
|
|
894
|
+
operator: "lte",
|
|
895
|
+
value: latest.createdAt
|
|
896
|
+
}
|
|
897
|
+
]
|
|
898
|
+
});
|
|
899
|
+
return txAdapter.consumeOne({
|
|
882
900
|
model: "verification",
|
|
883
901
|
where: [{
|
|
884
902
|
field: "id",
|
|
885
903
|
value: latest.id
|
|
886
904
|
}]
|
|
887
905
|
});
|
|
888
|
-
if (!row) return null;
|
|
889
|
-
await txAdapter.deleteMany({
|
|
890
|
-
model: "verification",
|
|
891
|
-
where
|
|
892
|
-
});
|
|
893
|
-
return row;
|
|
894
906
|
}, latest);
|
|
895
907
|
}));
|
|
896
908
|
for (const stored of identifiersToTry) {
|
|
@@ -930,7 +942,10 @@ const createInternalAdapter = (adapter, ctx) => {
|
|
|
930
942
|
* is best-effort there (it is intended for development and tests).
|
|
931
943
|
*/
|
|
932
944
|
reserveVerificationValue: async (data) => {
|
|
933
|
-
const reservationId = encodeDeterministicId(new Uint8Array(await createHash("SHA-256").digest(new TextEncoder().encode("reserve:" + data.identifier))), options
|
|
945
|
+
const reservationId = encodeDeterministicId(new Uint8Array(await createHash("SHA-256").digest(new TextEncoder().encode("reserve:" + data.identifier))), options, {
|
|
946
|
+
adapter,
|
|
947
|
+
model: "verification"
|
|
948
|
+
});
|
|
934
949
|
const storageOption = getStorageOption(data.identifier, options.verification?.storeIdentifier);
|
|
935
950
|
const storedIdentifier = await processIdentifier(data.identifier, storageOption);
|
|
936
951
|
if (secondaryStorage && !options.verification?.storeInDatabase) throw new BetterAuthError("reserveVerificationValue requires database-backed verification storage. Set verification.storeInDatabase to true for flows that reserve verification values.");
|
|
@@ -996,5 +1011,4 @@ const createInternalAdapter = (adapter, ctx) => {
|
|
|
996
1011
|
refreshUserSessions
|
|
997
1012
|
};
|
|
998
1013
|
};
|
|
999
|
-
//#endregion
|
|
1000
1014
|
export { createInternalAdapter };
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { User } from "../types/models.mjs";
|
|
2
2
|
import "../types/index.mjs";
|
|
3
3
|
import { GenericEndpointContext } from "@better-auth/core";
|
|
4
|
-
//#region src/db/revoke-unproven-account-access.d.ts
|
|
5
4
|
/**
|
|
6
5
|
* Strip every account link and session a pre-existing account accrued before
|
|
7
6
|
* control of its email was proven.
|
|
@@ -16,5 +15,4 @@ import { GenericEndpointContext } from "@better-auth/core";
|
|
|
16
15
|
*
|
|
17
16
|
* @param userId - The pre-existing, not-yet-verified user being promoted.
|
|
18
17
|
*/
|
|
19
|
-
export declare function revokeUnprovenAccountAccess(ctx: GenericEndpointContext, userId: string): Promise<User | null>;
|
|
20
|
-
//#endregion
|
|
18
|
+
export declare function revokeUnprovenAccountAccess(ctx: GenericEndpointContext, userId: string): Promise<User | null>;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { BetterAuthError } from "@better-auth/core/error";
|
|
2
|
-
|
|
2
|
+
// src/db/revoke-unproven-account-access.ts
|
|
3
3
|
const cleanupLockExpiresInMs = 5e3;
|
|
4
4
|
const cleanupLockWaitMs = 2e3;
|
|
5
5
|
const cleanupLockPollMs = 250;
|
|
@@ -54,5 +54,4 @@ async function revokeUnprovenAccountAccess(ctx, userId) {
|
|
|
54
54
|
await ctx.context.internalAdapter.deleteVerificationByIdentifier(lockIdentifier).catch(() => {});
|
|
55
55
|
}
|
|
56
56
|
}
|
|
57
|
-
//#endregion
|
|
58
57
|
export { revokeUnprovenAccountAccess };
|
package/dist/db/schema.d.mts
CHANGED
|
@@ -2,7 +2,6 @@ import { Account, Session as Session$1, User as User$1 } from "../types/models.m
|
|
|
2
2
|
import "../types/index.mjs";
|
|
3
3
|
import { BetterAuthOptions } from "@better-auth/core";
|
|
4
4
|
import { BetterAuthPluginDBSchema, DBFieldAttribute } from "@better-auth/core/db";
|
|
5
|
-
//#region src/db/schema.d.ts
|
|
6
5
|
export declare function parseUserOutput<T extends User$1>(options: BetterAuthOptions, user: T): T;
|
|
7
6
|
/**
|
|
8
7
|
* Builds a synthetic user object that matches the shape of a real user
|
|
@@ -57,5 +56,4 @@ export declare function mergeSchema<S extends BetterAuthPluginDBSchema>(schema:
|
|
|
57
56
|
fields?: {
|
|
58
57
|
[P: string]: string;
|
|
59
58
|
} | undefined;
|
|
60
|
-
} | undefined; } | undefined): S;
|
|
61
|
-
//#endregion
|
|
59
|
+
} | undefined; } | undefined): S;
|
package/dist/db/schema.mjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { getAuthTables } from "@better-auth/core/db";
|
|
2
2
|
import { APIError, BASE_ERROR_CODES } from "@better-auth/core/error";
|
|
3
3
|
import { filterOutputFields } from "@better-auth/core/utils/db";
|
|
4
|
-
|
|
4
|
+
// src/db/schema.ts
|
|
5
5
|
const cache = /* @__PURE__ */ new WeakMap();
|
|
6
6
|
function getFields(options, modelName, mode) {
|
|
7
7
|
const cacheKey = `${modelName}:${mode}`;
|
|
@@ -169,5 +169,4 @@ function mergeSchema(schema, newSchema) {
|
|
|
169
169
|
}
|
|
170
170
|
return merged;
|
|
171
171
|
}
|
|
172
|
-
//#endregion
|
|
173
172
|
export { buildSyntheticUserOutput, getSessionDefaultFields, mergeSchema, parseAccountInput, parseAccountOutput, parseAdditionalUserInput, parseAdditionalUserInputFromProviderProfile, parseInputData, parseSessionInput, parseSessionOutput, parseUserInput, parseUserOutput };
|
package/dist/db/to-zod.d.mts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { DBFieldAttribute } from "@better-auth/core/db";
|
|
2
2
|
import * as z from "zod";
|
|
3
|
-
//#region src/db/to-zod.d.ts
|
|
4
3
|
export declare function toZodSchema<Fields extends Record<string, DBFieldAttribute | never>, IsClientSide extends boolean>({ fields, isClientSide }: {
|
|
5
4
|
fields: Fields;
|
|
6
5
|
/**
|
|
@@ -29,5 +28,4 @@ type GetSchemaForSide<isClientSide extends boolean, Field extends DBFieldAttribu
|
|
|
29
28
|
returned: false;
|
|
30
29
|
} ? never : Schema;
|
|
31
30
|
type RemoveNeverProps<T> = { [K in keyof T as [T[K]] extends [never] ? never : K]: T[K]; };
|
|
32
|
-
//#endregion
|
|
33
31
|
export {};
|
package/dist/db/to-zod.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as z from "zod";
|
|
2
|
-
|
|
2
|
+
// src/db/to-zod.ts
|
|
3
3
|
/**
|
|
4
4
|
* Static lookup keeps `zod` tree-shakeable. `z[field.type]()` forces bundlers
|
|
5
5
|
* to retain every `zod` export, including all locales.
|
|
@@ -29,5 +29,4 @@ function toZodSchema({ fields, isClientSide }) {
|
|
|
29
29
|
}, {});
|
|
30
30
|
return z.object(zodFields);
|
|
31
31
|
}
|
|
32
|
-
//#endregion
|
|
33
32
|
export { toZodSchema };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { base64Url } from "@better-auth/utils/base64";
|
|
2
2
|
import { createHash } from "@better-auth/utils/hash";
|
|
3
|
-
|
|
3
|
+
// src/db/verification-token-storage.ts
|
|
4
4
|
const defaultKeyHasher = async (identifier) => {
|
|
5
5
|
const hash = await createHash("SHA-256").digest(new TextEncoder().encode(identifier));
|
|
6
6
|
return base64Url.encode(new Uint8Array(hash), { padding: false });
|
|
@@ -21,5 +21,4 @@ function getStorageOption(identifier, config) {
|
|
|
21
21
|
}
|
|
22
22
|
return config;
|
|
23
23
|
}
|
|
24
|
-
//#endregion
|
|
25
24
|
export { getStorageOption, processIdentifier };
|
package/dist/db/with-hooks.d.mts
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { BetterAuthOptions } from "@better-auth/core";
|
|
2
2
|
import { BaseModelNames } from "@better-auth/core/db";
|
|
3
3
|
import { DBAdapter, Where } from "@better-auth/core/db/adapter";
|
|
4
|
-
//#region src/db/with-hooks.d.ts
|
|
5
4
|
export type DatabaseHooksEntry = {
|
|
6
5
|
source: string;
|
|
7
6
|
hooks: Exclude<BetterAuthOptions["databaseHooks"], undefined>;
|
|
@@ -31,5 +30,4 @@ export declare function getWithHooks(adapter: DBAdapter<BetterAuthOptions>, ctx:
|
|
|
31
30
|
executeMainFn?: boolean;
|
|
32
31
|
} | undefined) => Promise<any>;
|
|
33
32
|
consumeOneWithHooks: <T extends Record<string, any>>(model: BaseModelNames, hookWhere: Where[], consumeFn: () => Promise<T | null>, preSnapshot?: T | null) => Promise<T | null>;
|
|
34
|
-
};
|
|
35
|
-
//#endregion
|
|
33
|
+
};
|
package/dist/db/with-hooks.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { getCurrentAdapter, queueAfterTransactionHook, tryGetCurrentAuthEndpointContext } from "@better-auth/core/context";
|
|
2
2
|
import { ATTR_CONTEXT, ATTR_DB_COLLECTION_NAME, ATTR_HOOK_TYPE, createWithSpan } from "@better-auth/core/instrumentation";
|
|
3
|
-
|
|
3
|
+
// src/db/with-hooks.ts
|
|
4
4
|
function getWithHooks(adapter, ctx) {
|
|
5
5
|
const withSpan = createWithSpan(ctx.options);
|
|
6
6
|
const hooksEntries = ctx.hooks;
|
|
@@ -251,5 +251,4 @@ function getWithHooks(adapter, ctx) {
|
|
|
251
251
|
consumeOneWithHooks
|
|
252
252
|
};
|
|
253
253
|
}
|
|
254
|
-
//#endregion
|
|
255
254
|
export { getWithHooks };
|
package/dist/index.d.mts
CHANGED
|
@@ -5,8 +5,8 @@ import { FilteredAPI, InferAPI, InferSessionAPI } from "./types/api.mjs";
|
|
|
5
5
|
import { Account, AdditionalSessionFieldsInput, AdditionalUserFieldsInput, InferPluginTypes, RateLimit, Session, User, Verification } from "./types/models.mjs";
|
|
6
6
|
import { InferOptionSchema, InferPluginContext, InferPluginErrorCodes, InferPluginIDs } from "./types/plugins.mjs";
|
|
7
7
|
import { Auth } from "./types/auth.mjs";
|
|
8
|
-
import { BetterAuthAdvancedOptions, BetterAuthCookies, BetterAuthOptions, BetterAuthPlugin, BetterAuthRateLimitOptions, StoreIdentifierOption, UserProvisioningSource, ValidateUserInfoAction, ValidateUserInfoMethod, ValidateUserInfoOAuthInfo, ValidateUserInfoResult, ValidateUserInfoSSOInfo, ValidateUserInfoSource } from "./types/index.mjs";
|
|
9
8
|
import { betterAuth } from "./auth/full.mjs";
|
|
9
|
+
import { BetterAuthAdvancedOptions, BetterAuthCookies, BetterAuthOptions, BetterAuthPlugin, BetterAuthRateLimitOptions, StoreIdentifierOption, UserProvisioningSource, ValidateUserInfoAction, ValidateUserInfoMethod, ValidateUserInfoOAuthInfo, ValidateUserInfoResult, ValidateUserInfoSSOInfo, ValidateUserInfoSource } from "./types/index.mjs";
|
|
10
10
|
import { StateData, generateGenericState, getAuthStateVerificationIdentifier, parseGenericState } from "./state.mjs";
|
|
11
11
|
import { GenerateStateOptions, generateIdTokenNonce, generateState, parseState } from "./oauth2/state.mjs";
|
|
12
12
|
import { HIDE_METADATA } from "./utils/hide-metadata.mjs";
|
package/dist/index.mjs
CHANGED
|
@@ -2,8 +2,8 @@ import { getBaseURL, getHost, getHostFromSource, getOrigin, getProtocol, getProt
|
|
|
2
2
|
import { generateGenericState, getAuthStateVerificationIdentifier, parseGenericState } from "./state.mjs";
|
|
3
3
|
import { generateIdTokenNonce, generateState, parseState } from "./oauth2/state.mjs";
|
|
4
4
|
import { HIDE_METADATA } from "./utils/hide-metadata.mjs";
|
|
5
|
-
import { APIError } from "./api/index.mjs";
|
|
6
5
|
import { betterAuth } from "./auth/full.mjs";
|
|
6
|
+
import { APIError } from "./api/index.mjs";
|
|
7
7
|
import { getCurrentAdapter } from "@better-auth/core/context";
|
|
8
8
|
import { createTelemetry, getTelemetryAuthConfig } from "@better-auth/telemetry";
|
|
9
9
|
export * from "@better-auth/core";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
// src/integrations/cookie-plugin-guard.ts
|
|
2
2
|
/**
|
|
3
3
|
* Warns when a cookie integration plugin is not effectively last.
|
|
4
4
|
*
|
|
@@ -14,5 +14,4 @@ function warnIfCookiePluginNotLast(ctx, pluginId) {
|
|
|
14
14
|
if (!plugins.slice(index + 1).some((p) => p.hooks && Array.isArray(p.hooks.after) && p.hooks.after.length > 0)) return;
|
|
15
15
|
ctx.logger.warn(`[better-auth] Cookie integration plugin "${pluginId}" should be placed last in the plugins array. Plugins with \`hooks.after\` running after it may set cookies that are not forwarded to the framework cookie store. Move your cookie integration plugin to the end of the \`plugins\` array to avoid missing \`Set-Cookie\` headers.`);
|
|
16
16
|
}
|
|
17
|
-
//#endregion
|
|
18
17
|
export { warnIfCookiePluginNotLast };
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
//#region src/integrations/next-js.d.ts
|
|
2
1
|
export declare function toNextJsHandler(auth: {
|
|
3
2
|
handler: (request: Request) => Promise<Response>;
|
|
4
3
|
} | ((request: Request) => Promise<Response>)): {
|
|
@@ -21,5 +20,4 @@ export declare const nextCookies: () => {
|
|
|
21
20
|
handler: import("better-call").Middleware<import("better-call").MiddlewareOptions, (inputContext: import("better-call").MiddlewareInputContext<import("better-call").MiddlewareOptions>) => Promise<void>>;
|
|
22
21
|
}[];
|
|
23
22
|
};
|
|
24
|
-
};
|
|
25
|
-
//#endregion
|
|
23
|
+
};
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { parseSetCookieHeader, toCookieOptions } from "../cookies/cookie-utils.mjs";
|
|
2
1
|
import { setShouldSkipSessionRefresh } from "../api/state/should-session-refresh.mjs";
|
|
2
|
+
import { parseSetCookieHeader, toCookieOptions } from "../cookies/cookie-utils.mjs";
|
|
3
3
|
import { PACKAGE_VERSION } from "../version.mjs";
|
|
4
4
|
import { warnIfCookiePluginNotLast } from "./cookie-plugin-guard.mjs";
|
|
5
5
|
import { createAuthMiddleware } from "@better-auth/core/api";
|
|
6
|
-
|
|
6
|
+
// src/integrations/next-js.ts
|
|
7
7
|
function toNextJsHandler(auth) {
|
|
8
8
|
const handler = async (request) => {
|
|
9
9
|
return "handler" in auth ? auth.handler(request) : auth(request);
|
|
@@ -101,5 +101,4 @@ const nextCookies = () => {
|
|
|
101
101
|
}
|
|
102
102
|
};
|
|
103
103
|
};
|
|
104
|
-
//#endregion
|
|
105
104
|
export { nextCookies, toNextJsHandler };
|
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
import { Auth } from "../types/auth.mjs";
|
|
2
2
|
import "../types/index.mjs";
|
|
3
3
|
import { IncomingHttpHeaders } from "node:http";
|
|
4
|
-
//#region src/integrations/node.d.ts
|
|
5
4
|
export declare const toNodeHandler: (auth: {
|
|
6
5
|
handler: Auth["handler"];
|
|
7
6
|
} | Auth["handler"]) => (req: import("node:http").IncomingMessage, res: import("node:http").ServerResponse) => Promise<void>;
|
|
8
|
-
export declare function fromNodeHeaders(nodeHeaders: IncomingHttpHeaders): Headers;
|
|
9
|
-
//#endregion
|
|
7
|
+
export declare function fromNodeHeaders(nodeHeaders: IncomingHttpHeaders): Headers;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { toNodeHandler as toNodeHandler$1 } from "better-call/node";
|
|
2
|
-
|
|
2
|
+
// src/integrations/node.ts
|
|
3
3
|
const toNodeHandler = (auth) => {
|
|
4
4
|
return "handler" in auth ? toNodeHandler$1(auth.handler) : toNodeHandler$1(auth);
|
|
5
5
|
};
|
|
@@ -11,5 +11,4 @@ function fromNodeHeaders(nodeHeaders) {
|
|
|
11
11
|
}
|
|
12
12
|
return webHeaders;
|
|
13
13
|
}
|
|
14
|
-
//#endregion
|
|
15
14
|
export { fromNodeHeaders, toNodeHandler };
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
//#region src/integrations/solid-start.d.ts
|
|
2
1
|
export declare function toSolidStartHandler(auth: {
|
|
3
2
|
handler: (request: Request) => Promise<Response>;
|
|
4
3
|
} | ((request: Request) => Promise<Response>)): {
|
|
@@ -17,5 +16,4 @@ export declare function toSolidStartHandler(auth: {
|
|
|
17
16
|
DELETE: (event: {
|
|
18
17
|
request: Request;
|
|
19
18
|
}) => Promise<Response>;
|
|
20
|
-
};
|
|
21
|
-
//#endregion
|
|
19
|
+
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
// src/integrations/solid-start.ts
|
|
2
2
|
function toSolidStartHandler(auth) {
|
|
3
3
|
const handler = async (event) => {
|
|
4
4
|
return "handler" in auth ? auth.handler(event.request) : auth(event.request);
|
|
@@ -11,5 +11,4 @@ function toSolidStartHandler(auth) {
|
|
|
11
11
|
DELETE: handler
|
|
12
12
|
};
|
|
13
13
|
}
|
|
14
|
-
//#endregion
|
|
15
14
|
export { toSolidStartHandler };
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { BetterAuthOptions } from "../types/index.mjs";
|
|
2
2
|
import { RequestEvent } from "@sveltejs/kit";
|
|
3
|
-
//#region src/integrations/svelte-kit.d.ts
|
|
4
3
|
export declare const toSvelteKitHandler: (auth: {
|
|
5
4
|
handler: (request: Request) => Response | Promise<Response>;
|
|
6
5
|
options: BetterAuthOptions;
|
|
@@ -26,5 +25,4 @@ export declare const sveltekitCookies: (getRequestEvent: () => RequestEvent<any,
|
|
|
26
25
|
handler: import("better-call").Middleware<import("better-call").MiddlewareOptions, (inputContext: import("better-call").MiddlewareInputContext<import("better-call").MiddlewareOptions>) => Promise<void>>;
|
|
27
26
|
}[];
|
|
28
27
|
};
|
|
29
|
-
};
|
|
30
|
-
//#endregion
|
|
28
|
+
};
|
|
@@ -2,7 +2,7 @@ import { parseSetCookieHeader, toCookieOptions } from "../cookies/cookie-utils.m
|
|
|
2
2
|
import { PACKAGE_VERSION } from "../version.mjs";
|
|
3
3
|
import { warnIfCookiePluginNotLast } from "./cookie-plugin-guard.mjs";
|
|
4
4
|
import { createAuthMiddleware } from "@better-auth/core/api";
|
|
5
|
-
|
|
5
|
+
// src/integrations/svelte-kit.ts
|
|
6
6
|
const toSvelteKitHandler = (auth) => {
|
|
7
7
|
return (event) => auth.handler(event.request);
|
|
8
8
|
};
|
|
@@ -53,5 +53,4 @@ const sveltekitCookies = (getRequestEvent) => {
|
|
|
53
53
|
}] }
|
|
54
54
|
};
|
|
55
55
|
};
|
|
56
|
-
//#endregion
|
|
57
56
|
export { isAuthPath, svelteKitHandler, sveltekitCookies, toSvelteKitHandler };
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
//#region src/integrations/tanstack-start-solid.d.ts
|
|
2
1
|
/**
|
|
3
2
|
* TanStack Start cookie plugin for Solid.js.
|
|
4
3
|
*
|
|
@@ -25,5 +24,4 @@ export declare const tanstackStartCookies: () => {
|
|
|
25
24
|
handler: import("better-call").Middleware<import("better-call").MiddlewareOptions, (inputContext: import("better-call").MiddlewareInputContext<import("better-call").MiddlewareOptions>) => Promise<void>>;
|
|
26
25
|
}[];
|
|
27
26
|
};
|
|
28
|
-
};
|
|
29
|
-
//#endregion
|
|
27
|
+
};
|
|
@@ -2,7 +2,7 @@ import { parseSetCookieHeader, toCookieOptions } from "../cookies/cookie-utils.m
|
|
|
2
2
|
import { PACKAGE_VERSION } from "../version.mjs";
|
|
3
3
|
import { warnIfCookiePluginNotLast } from "./cookie-plugin-guard.mjs";
|
|
4
4
|
import { createAuthMiddleware } from "@better-auth/core/api";
|
|
5
|
-
|
|
5
|
+
// src/integrations/tanstack-start-solid.ts
|
|
6
6
|
/**
|
|
7
7
|
* TanStack Start cookie plugin for Solid.js.
|
|
8
8
|
*
|
|
@@ -53,5 +53,4 @@ const tanstackStartCookies = () => {
|
|
|
53
53
|
}] }
|
|
54
54
|
};
|
|
55
55
|
};
|
|
56
|
-
//#endregion
|
|
57
56
|
export { tanstackStartCookies };
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
//#region src/integrations/tanstack-start.d.ts
|
|
2
1
|
/**
|
|
3
2
|
* TanStack Start cookie plugin for React.
|
|
4
3
|
*
|
|
@@ -25,5 +24,4 @@ export declare const tanstackStartCookies: () => {
|
|
|
25
24
|
handler: import("better-call").Middleware<import("better-call").MiddlewareOptions, (inputContext: import("better-call").MiddlewareInputContext<import("better-call").MiddlewareOptions>) => Promise<void>>;
|
|
26
25
|
}[];
|
|
27
26
|
};
|
|
28
|
-
};
|
|
29
|
-
//#endregion
|
|
27
|
+
};
|
|
@@ -2,7 +2,7 @@ import { parseSetCookieHeader, toCookieOptions } from "../cookies/cookie-utils.m
|
|
|
2
2
|
import { PACKAGE_VERSION } from "../version.mjs";
|
|
3
3
|
import { warnIfCookiePluginNotLast } from "./cookie-plugin-guard.mjs";
|
|
4
4
|
import { createAuthMiddleware } from "@better-auth/core/api";
|
|
5
|
-
|
|
5
|
+
// src/integrations/tanstack-start.ts
|
|
6
6
|
/**
|
|
7
7
|
* TanStack Start cookie plugin for React.
|
|
8
8
|
*
|
|
@@ -53,5 +53,4 @@ const tanstackStartCookies = () => {
|
|
|
53
53
|
}] }
|
|
54
54
|
};
|
|
55
55
|
};
|
|
56
|
-
//#endregion
|
|
57
56
|
export { tanstackStartCookies };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { APIError, BASE_ERROR_CODES, BetterAuthError } from "@better-auth/core/error";
|
|
2
|
-
|
|
2
|
+
// src/oauth2/account-key.ts
|
|
3
3
|
/**
|
|
4
4
|
* Exposes a provider-declared profile as the raw claim record used by
|
|
5
5
|
* provisioning hooks. Provider profile interfaces are object-shaped but do
|
|
@@ -39,5 +39,4 @@ async function resolveOAuthAccountKeyForAPI(provider, tokens, profile) {
|
|
|
39
39
|
throw APIError.from("UNAUTHORIZED", BASE_ERROR_CODES.FAILED_TO_GET_USER_INFO);
|
|
40
40
|
}
|
|
41
41
|
}
|
|
42
|
-
//#endregion
|
|
43
42
|
export { resolveOAuthAccountKey, resolveOAuthAccountKeyForAPI, toOAuthProfileRecord };
|
package/dist/oauth2/callback.mjs
CHANGED
|
@@ -2,7 +2,7 @@ import { resolveOAuthAccountKey, toOAuthProfileRecord } from "./account-key.mjs"
|
|
|
2
2
|
import { OAUTH_CALLBACK_ERROR_CODES } from "./errors.mjs";
|
|
3
3
|
import { getOAuthCallbackPath } from "./utils.mjs";
|
|
4
4
|
import { safeJSONParse } from "@better-auth/core/utils/json";
|
|
5
|
-
|
|
5
|
+
// src/oauth2/callback.ts
|
|
6
6
|
/**
|
|
7
7
|
* Turns a provider callback into a verified identity. It checks that the
|
|
8
8
|
* callback answers this authorization request, exchanges the code, and
|
|
@@ -64,5 +64,4 @@ async function exchangeOAuthCallback(ctx, provider, callback) {
|
|
|
64
64
|
accountKey
|
|
65
65
|
};
|
|
66
66
|
}
|
|
67
|
-
//#endregion
|
|
68
67
|
export { exchangeOAuthCallback };
|
package/dist/oauth2/errors.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { appendQueryParams } from "@better-auth/core/utils/url";
|
|
2
|
-
|
|
2
|
+
// src/oauth2/errors.ts
|
|
3
3
|
/**
|
|
4
4
|
* Error codes used in OAuth callback redirects (`?error=<code>`). These are
|
|
5
5
|
* URL-safe strings, not API error objects. Some also serve as the OAuth seam's
|
|
@@ -45,5 +45,4 @@ function redirectOnError(ctx, errorURL, error, description) {
|
|
|
45
45
|
function missingEmailLogMessage(providerId, options) {
|
|
46
46
|
return `${options?.source === "generic" ? `Generic OAuth provider "${providerId}"` : `Provider "${providerId}"`} did not return an email${options?.source === "id_token" ? " in the id token" : ""}. Either request the provider's email scope, or create a placeholder via \`mapProfileToUser\`. See ${HANDLING_DOCS_URL}`;
|
|
47
47
|
}
|
|
48
|
-
//#endregion
|
|
49
48
|
export { OAUTH_CALLBACK_ERROR_CODES, missingEmailLogMessage, redirectOnError };
|
package/dist/oauth2/index.d.mts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { GenerateStateOptions, generateIdTokenNonce, generateState, parseState } from "./state.mjs";
|
|
2
1
|
import { applyUpdateUserInfoOnLink, handleOAuthUserInfo, linkOAuthAccount } from "./link-account.mjs";
|
|
2
|
+
import { GenerateStateOptions, generateIdTokenNonce, generateState, parseState } from "./state.mjs";
|
|
3
3
|
import { decryptOAuthToken, getOAuthCallbackPath, setTokenUtil } from "./utils.mjs";
|
|
4
4
|
export * from "@better-auth/core/oauth2";
|
|
5
5
|
export { GenerateStateOptions, applyUpdateUserInfoOnLink, decryptOAuthToken, generateIdTokenNonce, generateState, getOAuthCallbackPath, handleOAuthUserInfo, linkOAuthAccount, parseState, setTokenUtil };
|
package/dist/oauth2/index.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { decryptOAuthToken, getOAuthCallbackPath, setTokenUtil } from "./utils.mjs";
|
|
2
1
|
import { applyUpdateUserInfoOnLink, handleOAuthUserInfo, linkOAuthAccount } from "./link-account.mjs";
|
|
3
2
|
import { generateIdTokenNonce, generateState, parseState } from "./state.mjs";
|
|
3
|
+
import { decryptOAuthToken, getOAuthCallbackPath, setTokenUtil } from "./utils.mjs";
|
|
4
4
|
export * from "@better-auth/core/oauth2";
|
|
5
5
|
export { applyUpdateUserInfoOnLink, decryptOAuthToken, generateIdTokenNonce, generateState, getOAuthCallbackPath, handleOAuthUserInfo, linkOAuthAccount, parseState, setTokenUtil };
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import { Account, User } from "../types/models.mjs";
|
|
2
|
-
import "../types/index.mjs";
|
|
3
2
|
import { StateData } from "../state.mjs";
|
|
3
|
+
import "../types/index.mjs";
|
|
4
4
|
import { GenericEndpointContext, UserProvisioningSource } from "@better-auth/core";
|
|
5
|
-
//#region src/oauth2/link-account.d.ts
|
|
6
5
|
type OAuthAccountData = Omit<Account, "id" | "userId" | "createdAt" | "updatedAt">;
|
|
7
6
|
/**
|
|
8
7
|
* Provider profile a freshly linked account may copy onto the local user.
|
|
@@ -112,5 +111,4 @@ export declare function handleOAuthUserInfo(c: GenericEndpointContext, opts: {
|
|
|
112
111
|
* disabled or the update fails: a failed profile sync must not abort the link.
|
|
113
112
|
*/
|
|
114
113
|
export declare function applyUpdateUserInfoOnLink(c: GenericEndpointContext, userId: string, userInfo: LinkedProviderProfile): Promise<User | undefined>;
|
|
115
|
-
//#endregion
|
|
116
114
|
export {};
|