better-auth 1.7.21 → 1.7.23
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 +3 -3
- package/dist/api/index.mjs +8 -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 +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/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 +1 -2
- 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 +21 -10
- 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 +3 -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 +0 -2
- package/dist/plugins/generic-oauth/index.mjs +5 -7
- 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 +1 -3
- 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 +5 -6
- 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 +0 -2
- package/dist/state.mjs +2 -3
- 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 +35 -22
- 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/index.d.mts +1 -1
- package/dist/utils/is-atom.mjs +1 -2
- package/dist/utils/is-promise.mjs +1 -2
- package/dist/utils/middleware-response.mjs +1 -2
- package/dist/utils/password.mjs +1 -2
- package/dist/utils/plugin-helper.mjs +1 -2
- package/dist/utils/request.mjs +1 -2
- package/dist/utils/shim.mjs +1 -2
- package/dist/utils/time.d.mts +0 -2
- package/dist/utils/time.mjs +1 -2
- package/dist/utils/url.d.mts +1 -3
- package/dist/utils/url.mjs +1 -2
- package/dist/utils/validate-user-info.mjs +1 -2
- package/dist/utils/wildcard.mjs +1 -2
- package/dist/version.mjs +1 -2
- package/package.json +10 -10
- package/dist/utils/boolean.mjs +0 -6
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { ExactRoleStatements, Role, RoleInput, Statements } from "./types.mjs";
|
|
2
|
-
//#region src/plugins/access/access.d.ts
|
|
3
2
|
export type AuthorizeResponse = {
|
|
4
3
|
success: false;
|
|
5
4
|
error: string;
|
|
@@ -11,5 +10,4 @@ export declare function role<const TRoleStatements extends Statements, TAuthoriz
|
|
|
11
10
|
export declare function createAccessControl<const TStatements extends Statements>(s: TStatements): {
|
|
12
11
|
newRole<const TRoleStatements extends Statements>(statements: RoleInput<TStatements, TRoleStatements>): Role<ExactRoleStatements<TRoleStatements>, TStatements>;
|
|
13
12
|
statements: TStatements;
|
|
14
|
-
};
|
|
15
|
-
//#endregion
|
|
13
|
+
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { BetterAuthError } from "@better-auth/core/error";
|
|
2
|
-
|
|
2
|
+
// src/plugins/access/access.ts
|
|
3
3
|
function unknownResourceResponse(requestedResource) {
|
|
4
4
|
return {
|
|
5
5
|
success: false,
|
|
@@ -74,5 +74,4 @@ function createAccessControl(s) {
|
|
|
74
74
|
statements: s
|
|
75
75
|
};
|
|
76
76
|
}
|
|
77
|
-
//#endregion
|
|
78
77
|
export { createAccessControl, role };
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { AccessControl, ArrayElement, ExactRoleStatements, Role, RoleAuthorizeRequest, RoleInput, RoleStatements, Statements, SubArray, Subset } from "./types.mjs";
|
|
2
1
|
import { AuthorizeResponse, createAccessControl, role } from "./access.mjs";
|
|
2
|
+
import { AccessControl, ArrayElement, ExactRoleStatements, Role, RoleAuthorizeRequest, RoleInput, RoleStatements, Statements, SubArray, Subset } from "./types.mjs";
|
|
3
3
|
export { AccessControl, ArrayElement, AuthorizeResponse, ExactRoleStatements, Role, RoleAuthorizeRequest, RoleInput, RoleStatements, Statements, SubArray, Subset, createAccessControl, role };
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { AuthorizeResponse, createAccessControl } from "./access.mjs";
|
|
2
2
|
import { LiteralString } from "@better-auth/core";
|
|
3
|
-
//#region src/plugins/access/types.d.ts
|
|
4
3
|
export type ArrayElement<T> = T extends readonly (infer E)[] ? E : never;
|
|
5
4
|
export type SubArray<T extends unknown[] | readonly unknown[] | any[]> = T[number][] | ReadonlyArray<T[number]>;
|
|
6
5
|
export type Subset<K extends keyof R, R extends Record<string | LiteralString, readonly string[] | readonly LiteralString[]>> = { [P in K]: SubArray<R[P]>; };
|
|
@@ -18,5 +17,4 @@ export type RoleAuthorizeRequest<TStatements extends Statements> = { [P in keyof
|
|
|
18
17
|
export type Role<TRoleStatements extends Statements = Record<string, any>, TAuthorizeStatements extends Statements = TRoleStatements> = {
|
|
19
18
|
authorize: (request: RoleAuthorizeRequest<TAuthorizeStatements>, connector?: ("OR" | "AND") | undefined) => AuthorizeResponse;
|
|
20
19
|
statements: TRoleStatements;
|
|
21
|
-
};
|
|
22
|
-
//#endregion
|
|
20
|
+
};
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { BetterAuthOptions, BetterAuthPlugin } from "@better-auth/core";
|
|
2
2
|
import { DBFieldAttribute } from "@better-auth/core/db";
|
|
3
|
-
//#region src/plugins/additional-fields/client.d.ts
|
|
4
3
|
export declare const inferAdditionalFields: <T, S extends {
|
|
5
4
|
user?: {
|
|
6
5
|
[key: string]: DBFieldAttribute;
|
|
@@ -94,5 +93,4 @@ export declare const inferAdditionalFields: <T, S extends {
|
|
|
94
93
|
};
|
|
95
94
|
};
|
|
96
95
|
} : never : undefined;
|
|
97
|
-
};
|
|
98
|
-
//#endregion
|
|
96
|
+
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { PACKAGE_VERSION } from "../../version.mjs";
|
|
2
|
-
|
|
2
|
+
// src/plugins/additional-fields/client.ts
|
|
3
3
|
const inferAdditionalFields = (schema) => {
|
|
4
4
|
return {
|
|
5
5
|
id: "additional-fields-client",
|
|
@@ -7,5 +7,4 @@ const inferAdditionalFields = (schema) => {
|
|
|
7
7
|
$InferServerPlugin: {}
|
|
8
8
|
};
|
|
9
9
|
};
|
|
10
|
-
//#endregion
|
|
11
10
|
export { inferAdditionalFields };
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { ExactRoleStatements, Role, RoleInput, Statements } from "../../access/types.mjs";
|
|
2
2
|
import "../../index.mjs";
|
|
3
|
-
//#region src/plugins/admin/access/statement.d.ts
|
|
4
3
|
export declare const defaultStatements: {
|
|
5
4
|
readonly user: readonly ["create", "list", "set-role", "ban", "impersonate", "impersonate-admins", "delete", "set-password", "set-email", "set-phone", "get", "update"];
|
|
6
5
|
readonly session: readonly ["list", "revoke", "delete"];
|
|
@@ -47,5 +46,4 @@ export declare const defaultRoles: {
|
|
|
47
46
|
readonly user: readonly ["create", "list", "set-role", "ban", "impersonate", "impersonate-admins", "delete", "set-password", "set-email", "set-phone", "get", "update"];
|
|
48
47
|
readonly session: readonly ["list", "revoke", "delete"];
|
|
49
48
|
}>;
|
|
50
|
-
};
|
|
51
|
-
//#endregion
|
|
49
|
+
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { createAccessControl } from "../../access/access.mjs";
|
|
2
|
-
|
|
2
|
+
// src/plugins/admin/access/statement.ts
|
|
3
3
|
const defaultStatements = {
|
|
4
4
|
user: [
|
|
5
5
|
"create",
|
|
@@ -50,5 +50,4 @@ const defaultRoles = {
|
|
|
50
50
|
admin: adminAc,
|
|
51
51
|
user: userAc
|
|
52
52
|
};
|
|
53
|
-
//#endregion
|
|
54
53
|
export { adminAc, defaultAc, defaultRoles, defaultStatements, userAc };
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { AccessControl, ArrayElement, Statements } from "../access/types.mjs";
|
|
2
2
|
import { AdminOptions, InferAdminRolesFromOption, SessionWithImpersonatedBy, UserWithRole } from "./types.mjs";
|
|
3
3
|
import "../index.mjs";
|
|
4
|
-
//#region src/plugins/admin/admin.d.ts
|
|
5
4
|
declare module "@better-auth/core" {
|
|
6
5
|
interface BetterAuthPluginRegistry<AuthOptions, Options> {
|
|
7
6
|
admin: {
|
|
@@ -903,5 +902,4 @@ export declare const admin: <O extends AdminOptions>(options?: O | undefined) =>
|
|
|
903
902
|
};
|
|
904
903
|
};
|
|
905
904
|
options: NoInfer<O>;
|
|
906
|
-
};
|
|
907
|
-
//#endregion
|
|
905
|
+
};
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { mergeSchema } from "../../db/schema.mjs";
|
|
2
|
+
import { getEndpointResponse } from "../../utils/plugin-helper.mjs";
|
|
2
3
|
import { PACKAGE_VERSION } from "../../version.mjs";
|
|
3
4
|
import { defaultRoles } from "./access/statement.mjs";
|
|
4
5
|
import { ADMIN_ERROR_CODES } from "./error-codes.mjs";
|
|
5
|
-
import { getEndpointResponse } from "../../utils/plugin-helper.mjs";
|
|
6
6
|
import { adminUpdateUser, banUser, createUser, getUser, impersonateUser, listUserSessions, listUsers, removeUser, revokeUserSession, revokeUserSessions, setRole, setUserPassword, stopImpersonating, unbanUser, userHasPermission } from "./routes.mjs";
|
|
7
7
|
import { schema } from "./schema.mjs";
|
|
8
8
|
import { APIError, BetterAuthError } from "@better-auth/core/error";
|
|
9
9
|
import { createAuthMiddleware } from "@better-auth/core/api";
|
|
10
|
-
|
|
10
|
+
// src/plugins/admin/admin.ts
|
|
11
11
|
const admin = (options) => {
|
|
12
12
|
const opts = {
|
|
13
13
|
...options || {},
|
|
@@ -87,5 +87,4 @@ const admin = (options) => {
|
|
|
87
87
|
options
|
|
88
88
|
};
|
|
89
89
|
};
|
|
90
|
-
//#endregion
|
|
91
90
|
export { admin };
|
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
import { AccessControl, ArrayElement, Role, Statements } from "../access/types.mjs";
|
|
2
|
+
import "../index.mjs";
|
|
2
3
|
import "../access/index.mjs";
|
|
3
|
-
import { AdminOptions, InferAdminRolesFromOption, SessionWithImpersonatedBy, UserWithRole } from "./types.mjs";
|
|
4
4
|
import { admin } from "./admin.mjs";
|
|
5
|
-
import "
|
|
5
|
+
import { AdminOptions, InferAdminRolesFromOption, SessionWithImpersonatedBy, UserWithRole } from "./types.mjs";
|
|
6
6
|
import { ADMIN_ERROR_CODES } from "./error-codes.mjs";
|
|
7
|
-
//#region src/plugins/admin/client.d.ts
|
|
8
7
|
export interface AdminClientOptions {
|
|
9
8
|
ac?: AccessControl | undefined;
|
|
10
9
|
roles?: { [key in string]: Role; } | undefined;
|
|
@@ -79,5 +78,4 @@ export declare const adminClient: <O extends AdminClientOptions>(options?: O | u
|
|
|
79
78
|
USER_ID_CANNOT_BE_UPDATED: import("@better-auth/core/utils/error-codes").RawError<"USER_ID_CANNOT_BE_UPDATED">;
|
|
80
79
|
};
|
|
81
80
|
};
|
|
82
|
-
//#endregion
|
|
83
81
|
export { ADMIN_ERROR_CODES, type AdminOptions, type InferAdminRolesFromOption, type SessionWithImpersonatedBy, type UserWithRole };
|
|
@@ -2,7 +2,7 @@ import { PACKAGE_VERSION } from "../../version.mjs";
|
|
|
2
2
|
import { adminAc, userAc } from "./access/statement.mjs";
|
|
3
3
|
import { ADMIN_ERROR_CODES } from "./error-codes.mjs";
|
|
4
4
|
import { hasPermission } from "./has-permission.mjs";
|
|
5
|
-
|
|
5
|
+
// src/plugins/admin/client.ts
|
|
6
6
|
const adminClient = (options) => {
|
|
7
7
|
const roles = {
|
|
8
8
|
admin: adminAc,
|
|
@@ -35,5 +35,4 @@ const adminClient = (options) => {
|
|
|
35
35
|
$ERROR_CODES: ADMIN_ERROR_CODES
|
|
36
36
|
};
|
|
37
37
|
};
|
|
38
|
-
//#endregion
|
|
39
38
|
export { ADMIN_ERROR_CODES, adminClient };
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
//#region src/plugins/admin/error-codes.d.ts
|
|
2
1
|
export declare const ADMIN_ERROR_CODES: {
|
|
3
2
|
USER_ALREADY_EXISTS_USE_ANOTHER_EMAIL: import("@better-auth/core/utils/error-codes").RawError<"USER_ALREADY_EXISTS_USE_ANOTHER_EMAIL">;
|
|
4
3
|
FAILED_TO_CREATE_USER: import("@better-auth/core/utils/error-codes").RawError<"FAILED_TO_CREATE_USER">;
|
|
@@ -25,5 +24,4 @@ export declare const ADMIN_ERROR_CODES: {
|
|
|
25
24
|
YOU_ARE_NOT_ALLOWED_TO_SET_USERS_PHONE_NUMBER: import("@better-auth/core/utils/error-codes").RawError<"YOU_ARE_NOT_ALLOWED_TO_SET_USERS_PHONE_NUMBER">;
|
|
26
25
|
PASSWORD_CANNOT_BE_UPDATED_VIA_UPDATE_USER: import("@better-auth/core/utils/error-codes").RawError<"PASSWORD_CANNOT_BE_UPDATED_VIA_UPDATE_USER">;
|
|
27
26
|
USER_ID_CANNOT_BE_UPDATED: import("@better-auth/core/utils/error-codes").RawError<"USER_ID_CANNOT_BE_UPDATED">;
|
|
28
|
-
};
|
|
29
|
-
//#endregion
|
|
27
|
+
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { defineErrorCodes } from "@better-auth/core/utils/error-codes";
|
|
2
|
-
|
|
2
|
+
// src/plugins/admin/error-codes.ts
|
|
3
3
|
const ADMIN_ERROR_CODES = defineErrorCodes({
|
|
4
4
|
FAILED_TO_CREATE_USER: "Failed to create user",
|
|
5
5
|
USER_ALREADY_EXISTS: "User already exists.",
|
|
@@ -27,5 +27,4 @@ const ADMIN_ERROR_CODES = defineErrorCodes({
|
|
|
27
27
|
PASSWORD_CANNOT_BE_UPDATED_VIA_UPDATE_USER: "Password cannot be updated through update-user. Use the set-user-password endpoint instead",
|
|
28
28
|
USER_ID_CANNOT_BE_UPDATED: "User id cannot be updated"
|
|
29
29
|
});
|
|
30
|
-
//#endregion
|
|
31
30
|
export { ADMIN_ERROR_CODES };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { defaultRoles } from "./access/statement.mjs";
|
|
2
|
-
|
|
2
|
+
// src/plugins/admin/has-permission.ts
|
|
3
3
|
const hasPermission = (input) => {
|
|
4
4
|
if (input.userId && input.options?.adminUserIds?.includes(input.userId)) return true;
|
|
5
5
|
if (!input.permissions) return false;
|
|
@@ -8,5 +8,4 @@ const hasPermission = (input) => {
|
|
|
8
8
|
for (const role of roles) if ((acRoles[role]?.authorize(input.permissions))?.success) return true;
|
|
9
9
|
return false;
|
|
10
10
|
};
|
|
11
|
-
//#endregion
|
|
12
11
|
export { hasPermission };
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { AdminOptions, InferAdminRolesFromOption, SessionWithImpersonatedBy, UserWithRole } from "./types.mjs";
|
|
2
1
|
import { admin } from "./admin.mjs";
|
|
2
|
+
import { AdminOptions, InferAdminRolesFromOption, SessionWithImpersonatedBy, UserWithRole } from "./types.mjs";
|
|
3
3
|
export { type AdminOptions, type InferAdminRolesFromOption, type SessionWithImpersonatedBy, type UserWithRole, admin };
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
+
import { getAuthoritativeSessionFromCtx, getSessionFromCtx } from "../../api/routes/session.mjs";
|
|
2
|
+
import { deleteSessionCookie, expireCookie, setSessionCookie } from "../../cookies/index.mjs";
|
|
1
3
|
import { parseSessionOutput, parseUserOutput } from "../../db/schema.mjs";
|
|
2
4
|
import { getDate } from "../../utils/date.mjs";
|
|
3
|
-
import { deleteSessionCookie, expireCookie, setSessionCookie } from "../../cookies/index.mjs";
|
|
4
|
-
import { getAuthoritativeSessionFromCtx, getSessionFromCtx } from "../../api/routes/session.mjs";
|
|
5
5
|
import { assertPasswordNotTooLong, assertPasswordNotTooShort } from "../../utils/password.mjs";
|
|
6
6
|
import { ADMIN_ERROR_CODES } from "./error-codes.mjs";
|
|
7
7
|
import { hasPermission } from "./has-permission.mjs";
|
|
@@ -10,7 +10,7 @@ import { APIError, BASE_ERROR_CODES } from "@better-auth/core/error";
|
|
|
10
10
|
import { whereOperators } from "@better-auth/core/db/adapter";
|
|
11
11
|
import { createAuthEndpoint, createAuthMiddleware } from "@better-auth/core/api";
|
|
12
12
|
import * as z from "zod";
|
|
13
|
-
|
|
13
|
+
// src/plugins/admin/routes.ts
|
|
14
14
|
/**
|
|
15
15
|
* Ensures a valid session, if not will throw.
|
|
16
16
|
* Will also provide additional types on the user to include role types.
|
|
@@ -920,5 +920,4 @@ const userHasPermission = (opts) => {
|
|
|
920
920
|
});
|
|
921
921
|
});
|
|
922
922
|
};
|
|
923
|
-
//#endregion
|
|
924
923
|
export { adminUpdateUser, banUser, createUser, getUser, impersonateUser, listUserSessions, listUsers, removeUser, revokeUserSession, revokeUserSessions, setRole, setUserPassword, stopImpersonating, unbanUser, userHasPermission };
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
//#region src/plugins/admin/schema.d.ts
|
|
2
1
|
export declare const schema: {
|
|
3
2
|
user: {
|
|
4
3
|
fields: {
|
|
@@ -35,5 +34,4 @@ export declare const schema: {
|
|
|
35
34
|
};
|
|
36
35
|
};
|
|
37
36
|
};
|
|
38
|
-
export type AdminSchema = typeof schema;
|
|
39
|
-
//#endregion
|
|
37
|
+
export type AdminSchema = typeof schema;
|
|
@@ -5,7 +5,6 @@ import { AccessControl, Role } from "../access/types.mjs";
|
|
|
5
5
|
import "../access/index.mjs";
|
|
6
6
|
import { AdminSchema } from "./schema.mjs";
|
|
7
7
|
import { Awaitable } from "@better-auth/core";
|
|
8
|
-
//#region src/plugins/admin/types.d.ts
|
|
9
8
|
export interface UserWithRole extends User {
|
|
10
9
|
role?: string | undefined;
|
|
11
10
|
banned: boolean | null;
|
|
@@ -87,5 +86,4 @@ export interface AdminOptions {
|
|
|
87
86
|
}
|
|
88
87
|
export type InferAdminRolesFromOption<O extends AdminOptions | undefined> = O extends {
|
|
89
88
|
roles: Record<string, unknown>;
|
|
90
|
-
} ? keyof O["roles"] : "user" | "admin";
|
|
91
|
-
//#endregion
|
|
89
|
+
} ? keyof O["roles"] : "user" | "admin";
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import { schema } from "./schema.mjs";
|
|
2
|
-
import { AnonymousOptions, AnonymousSession, UserWithAnonymous } from "./types.mjs";
|
|
3
2
|
import { anonymous } from "./index.mjs";
|
|
3
|
+
import { AnonymousOptions, AnonymousSession, UserWithAnonymous } from "./types.mjs";
|
|
4
4
|
import { ANONYMOUS_ERROR_CODES } from "./error-codes.mjs";
|
|
5
|
-
//#region src/plugins/anonymous/client.d.ts
|
|
6
5
|
export declare const anonymousClient: () => {
|
|
7
6
|
id: "anonymous";
|
|
8
7
|
version: string;
|
|
@@ -26,5 +25,4 @@ export declare const anonymousClient: () => {
|
|
|
26
25
|
DELETE_ANONYMOUS_USER_DISABLED: import("@better-auth/core/utils/error-codes").RawError<"DELETE_ANONYMOUS_USER_DISABLED">;
|
|
27
26
|
};
|
|
28
27
|
};
|
|
29
|
-
//#endregion
|
|
30
28
|
export { ANONYMOUS_ERROR_CODES, type AnonymousOptions, type AnonymousSession, type UserWithAnonymous, type schema };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { PACKAGE_VERSION } from "../../version.mjs";
|
|
2
2
|
import { ANONYMOUS_ERROR_CODES } from "./error-codes.mjs";
|
|
3
|
-
|
|
3
|
+
// src/plugins/anonymous/client.ts
|
|
4
4
|
const anonymousClient = () => {
|
|
5
5
|
return {
|
|
6
6
|
id: "anonymous",
|
|
@@ -17,5 +17,4 @@ const anonymousClient = () => {
|
|
|
17
17
|
$ERROR_CODES: ANONYMOUS_ERROR_CODES
|
|
18
18
|
};
|
|
19
19
|
};
|
|
20
|
-
//#endregion
|
|
21
20
|
export { ANONYMOUS_ERROR_CODES, anonymousClient };
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
//#region src/plugins/anonymous/error-codes.d.ts
|
|
2
1
|
export declare const ANONYMOUS_ERROR_CODES: {
|
|
3
2
|
FAILED_TO_CREATE_USER: import("@better-auth/core/utils/error-codes").RawError<"FAILED_TO_CREATE_USER">;
|
|
4
3
|
INVALID_EMAIL_FORMAT: import("@better-auth/core/utils/error-codes").RawError<"INVALID_EMAIL_FORMAT">;
|
|
@@ -8,5 +7,4 @@ export declare const ANONYMOUS_ERROR_CODES: {
|
|
|
8
7
|
FAILED_TO_DELETE_ANONYMOUS_USER_SESSIONS: import("@better-auth/core/utils/error-codes").RawError<"FAILED_TO_DELETE_ANONYMOUS_USER_SESSIONS">;
|
|
9
8
|
USER_IS_NOT_ANONYMOUS: import("@better-auth/core/utils/error-codes").RawError<"USER_IS_NOT_ANONYMOUS">;
|
|
10
9
|
DELETE_ANONYMOUS_USER_DISABLED: import("@better-auth/core/utils/error-codes").RawError<"DELETE_ANONYMOUS_USER_DISABLED">;
|
|
11
|
-
};
|
|
12
|
-
//#endregion
|
|
10
|
+
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { defineErrorCodes } from "@better-auth/core/utils/error-codes";
|
|
2
|
-
|
|
2
|
+
// src/plugins/anonymous/error-codes.ts
|
|
3
3
|
const ANONYMOUS_ERROR_CODES = defineErrorCodes({
|
|
4
4
|
INVALID_EMAIL_FORMAT: "Email was not generated in a valid format",
|
|
5
5
|
FAILED_TO_CREATE_USER: "Failed to create user",
|
|
@@ -10,5 +10,4 @@ const ANONYMOUS_ERROR_CODES = defineErrorCodes({
|
|
|
10
10
|
USER_IS_NOT_ANONYMOUS: "User is not anonymous",
|
|
11
11
|
DELETE_ANONYMOUS_USER_DISABLED: "Deleting anonymous users is disabled"
|
|
12
12
|
});
|
|
13
|
-
//#endregion
|
|
14
13
|
export { ANONYMOUS_ERROR_CODES };
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { AnonymousOptions, AnonymousSession, UserWithAnonymous } from "./types.mjs";
|
|
2
|
-
//#region src/plugins/anonymous/index.d.ts
|
|
3
2
|
declare module "@better-auth/core" {
|
|
4
3
|
interface BetterAuthPluginRegistry<AuthOptions, Options> {
|
|
5
4
|
anonymous: {
|
|
@@ -167,5 +166,4 @@ export declare const anonymous: (options?: AnonymousOptions | undefined) => {
|
|
|
167
166
|
DELETE_ANONYMOUS_USER_DISABLED: import("@better-auth/core/utils/error-codes").RawError<"DELETE_ANONYMOUS_USER_DISABLED">;
|
|
168
167
|
};
|
|
169
168
|
};
|
|
170
|
-
//#endregion
|
|
171
169
|
export type { AnonymousOptions, AnonymousSession, UserWithAnonymous };
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { APIError } from "../../api/index.mjs";
|
|
2
2
|
import { parseSetCookieHeader } from "../../cookies/cookie-utils.mjs";
|
|
3
3
|
import { deleteSessionCookie, setSessionCookie } from "../../cookies/index.mjs";
|
|
4
4
|
import { getSessionFromCtx, sensitiveSessionMiddleware } from "../../api/routes/session.mjs";
|
|
5
5
|
import { addOAuthServerContext, getOAuthState } from "../../api/state/oauth.mjs";
|
|
6
|
-
import {
|
|
6
|
+
import { mergeSchema, parseUserOutput } from "../../db/schema.mjs";
|
|
7
7
|
import { PACKAGE_VERSION } from "../../version.mjs";
|
|
8
8
|
import { ANONYMOUS_ERROR_CODES } from "./error-codes.mjs";
|
|
9
9
|
import { schema } from "./schema.mjs";
|
|
@@ -11,7 +11,7 @@ import { generateId } from "@better-auth/core/utils/id";
|
|
|
11
11
|
import { createAuthEndpoint, createAuthMiddleware } from "@better-auth/core/api";
|
|
12
12
|
import * as z from "zod";
|
|
13
13
|
import { createPlaceholderEmail } from "@better-auth/core/utils/email";
|
|
14
|
-
|
|
14
|
+
// src/plugins/anonymous/index.ts
|
|
15
15
|
/**
|
|
16
16
|
* Resolves the anonymous session being upgraded during an account-link callback.
|
|
17
17
|
*
|
|
@@ -216,5 +216,4 @@ const anonymous = (options) => {
|
|
|
216
216
|
$ERROR_CODES: ANONYMOUS_ERROR_CODES
|
|
217
217
|
};
|
|
218
218
|
};
|
|
219
|
-
//#endregion
|
|
220
219
|
export { anonymous };
|
|
@@ -4,7 +4,6 @@ import "../../types/index.mjs";
|
|
|
4
4
|
import { schema } from "./schema.mjs";
|
|
5
5
|
import { AuthContext, Awaitable, GenericEndpointContext } from "@better-auth/core";
|
|
6
6
|
import { EndpointContext } from "better-call";
|
|
7
|
-
//#region src/plugins/anonymous/types.d.ts
|
|
8
7
|
export type AnonymousSession = {
|
|
9
8
|
session: Session;
|
|
10
9
|
user: User;
|
|
@@ -60,5 +59,4 @@ export interface AnonymousOptions {
|
|
|
60
59
|
* Custom schema for the anonymous plugin
|
|
61
60
|
*/
|
|
62
61
|
schema?: InferOptionSchema<typeof schema> | undefined;
|
|
63
|
-
}
|
|
64
|
-
//#endregion
|
|
62
|
+
}
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
//#region src/plugins/bearer/index.d.ts
|
|
2
1
|
declare module "@better-auth/core" {
|
|
3
2
|
interface BetterAuthPluginRegistry<AuthOptions, Options> {
|
|
4
3
|
bearer: {
|
|
@@ -37,5 +36,4 @@ export declare const bearer: (options?: BearerOptions | undefined) => {
|
|
|
37
36
|
}[];
|
|
38
37
|
};
|
|
39
38
|
options: BearerOptions | undefined;
|
|
40
|
-
};
|
|
41
|
-
//#endregion
|
|
39
|
+
};
|
|
@@ -3,7 +3,7 @@ import { PACKAGE_VERSION } from "../../version.mjs";
|
|
|
3
3
|
import { serializeSignedCookie } from "better-call";
|
|
4
4
|
import { createAuthMiddleware } from "@better-auth/core/api";
|
|
5
5
|
import { createHMAC } from "@better-auth/utils/hmac";
|
|
6
|
-
|
|
6
|
+
// src/plugins/bearer/index.ts
|
|
7
7
|
const BEARER_SCHEME = "bearer ";
|
|
8
8
|
function tryDecode(str) {
|
|
9
9
|
try {
|
|
@@ -70,5 +70,4 @@ const bearer = (options) => {
|
|
|
70
70
|
options
|
|
71
71
|
};
|
|
72
72
|
};
|
|
73
|
-
//#endregion
|
|
74
73
|
export { bearer };
|
|
@@ -1,9 +1,7 @@
|
|
|
1
|
-
//#region src/plugins/captcha/constants.d.ts
|
|
2
1
|
export declare const Providers: {
|
|
3
2
|
readonly CLOUDFLARE_TURNSTILE: "cloudflare-turnstile";
|
|
4
3
|
readonly GOOGLE_RECAPTCHA: "google-recaptcha";
|
|
5
4
|
readonly HCAPTCHA: "hcaptcha";
|
|
6
5
|
readonly CAPTCHAFOX: "captchafox";
|
|
7
6
|
readonly VERCEL_BOTID: "vercel-botid";
|
|
8
|
-
};
|
|
9
|
-
//#endregion
|
|
7
|
+
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
// src/plugins/captcha/constants.ts
|
|
2
2
|
/**
|
|
3
3
|
* Upper bound (in milliseconds) for a single provider verification request.
|
|
4
4
|
* Without it, a hanging provider would tie up the request indefinitely before
|
|
@@ -24,5 +24,4 @@ const siteVerifyMap = {
|
|
|
24
24
|
[Providers.HCAPTCHA]: "https://api.hcaptcha.com/siteverify",
|
|
25
25
|
[Providers.CAPTCHAFOX]: "https://api.captchafox.com/siteverify"
|
|
26
26
|
};
|
|
27
|
-
//#endregion
|
|
28
27
|
export { CAPTCHA_VERIFY_TIMEOUT_MS, Providers, defaultEndpoints, siteVerifyMap };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { defineErrorCodes } from "@better-auth/core/utils/error-codes";
|
|
2
|
-
|
|
2
|
+
// src/plugins/captcha/error-codes.ts
|
|
3
3
|
const EXTERNAL_ERROR_CODES = defineErrorCodes({
|
|
4
4
|
VERIFICATION_FAILED: "Captcha verification failed",
|
|
5
5
|
MISSING_RESPONSE: "Missing CAPTCHA response",
|
|
@@ -9,5 +9,4 @@ const INTERNAL_ERROR_CODES = defineErrorCodes({
|
|
|
9
9
|
MISSING_SECRET_KEY: "Missing secret key",
|
|
10
10
|
SERVICE_UNAVAILABLE: "CAPTCHA service unavailable"
|
|
11
11
|
});
|
|
12
|
-
//#endregion
|
|
13
12
|
export { EXTERNAL_ERROR_CODES, INTERNAL_ERROR_CODES };
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { BaseCaptchaOptions, BotIdVerification, CaptchaFoxOptions, CaptchaOptions, CloudflareTurnstileOptions, GoogleRecaptchaOptions, HCaptchaOptions, Provider, ValidateRequestContext, VercelBotIdOptions } from "./types.mjs";
|
|
2
|
-
//#region src/plugins/captcha/index.d.ts
|
|
3
2
|
declare module "@better-auth/core" {
|
|
4
3
|
interface BetterAuthPluginRegistry<AuthOptions, Options> {
|
|
5
4
|
captcha: {
|
|
@@ -20,5 +19,4 @@ export declare const captcha: (options: CaptchaOptions) => {
|
|
|
20
19
|
} | undefined>;
|
|
21
20
|
options: CaptchaOptions;
|
|
22
21
|
};
|
|
23
|
-
//#endregion
|
|
24
22
|
export type { BaseCaptchaOptions, BotIdVerification, CaptchaFoxOptions, CaptchaOptions, CloudflareTurnstileOptions, GoogleRecaptchaOptions, HCaptchaOptions, Provider, ValidateRequestContext, VercelBotIdOptions };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
+
import { middlewareResponse } from "../../utils/middleware-response.mjs";
|
|
1
2
|
import { wildcardMatch } from "../../utils/wildcard.mjs";
|
|
2
3
|
import { PACKAGE_VERSION } from "../../version.mjs";
|
|
3
|
-
import { middlewareResponse } from "../../utils/middleware-response.mjs";
|
|
4
4
|
import { Providers, defaultEndpoints, siteVerifyMap } from "./constants.mjs";
|
|
5
5
|
import { EXTERNAL_ERROR_CODES, INTERNAL_ERROR_CODES } from "./error-codes.mjs";
|
|
6
6
|
import { captchaFox } from "./verify-handlers/captchafox.mjs";
|
|
@@ -9,7 +9,7 @@ import { googleRecaptcha } from "./verify-handlers/google-recaptcha.mjs";
|
|
|
9
9
|
import { hCaptcha } from "./verify-handlers/h-captcha.mjs";
|
|
10
10
|
import { vercelBotId } from "./verify-handlers/vercel-botid.mjs";
|
|
11
11
|
import { getIP } from "@better-auth/core/utils/ip";
|
|
12
|
-
|
|
12
|
+
// src/plugins/captcha/index.ts
|
|
13
13
|
const normalizeEndpointPath = (pathname, basePath) => {
|
|
14
14
|
let normalizedPathname = (pathname.startsWith(basePath) ? pathname.slice(basePath.length) : pathname).replace(/\/{2,}/g, "/");
|
|
15
15
|
if (!normalizedPathname.startsWith("/")) normalizedPathname = `/${normalizedPathname}`;
|
|
@@ -81,5 +81,4 @@ const captcha = (options) => ({
|
|
|
81
81
|
},
|
|
82
82
|
options
|
|
83
83
|
});
|
|
84
|
-
//#endregion
|
|
85
84
|
export { captcha };
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { Providers } from "./constants.mjs";
|
|
2
|
-
//#region src/plugins/captcha/types.d.ts
|
|
3
2
|
export type Provider = (typeof Providers)[keyof typeof Providers];
|
|
4
3
|
export interface BaseCaptchaOptions {
|
|
5
4
|
secretKey: string;
|
|
@@ -88,5 +87,4 @@ export interface VercelBotIdOptions {
|
|
|
88
87
|
*/
|
|
89
88
|
validateRequest?: (ctx: ValidateRequestContext) => boolean | Promise<boolean>;
|
|
90
89
|
}
|
|
91
|
-
export type CaptchaOptions = GoogleRecaptchaOptions | CloudflareTurnstileOptions | HCaptchaOptions | CaptchaFoxOptions | VercelBotIdOptions;
|
|
92
|
-
//#endregion
|
|
90
|
+
export type CaptchaOptions = GoogleRecaptchaOptions | CloudflareTurnstileOptions | HCaptchaOptions | CaptchaFoxOptions | VercelBotIdOptions;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
// src/plugins/captcha/utils.ts
|
|
2
2
|
const encodeToURLParams = (obj) => {
|
|
3
3
|
if (typeof obj !== "object" || obj === null || Array.isArray(obj)) throw new Error("Input must be a non-null object.");
|
|
4
4
|
const params = new URLSearchParams();
|
|
@@ -15,5 +15,4 @@ const withTimeout = (promise, timeoutMs) => {
|
|
|
15
15
|
});
|
|
16
16
|
return Promise.race([promise, timeout]).finally(() => clearTimeout(timer));
|
|
17
17
|
};
|
|
18
|
-
//#endregion
|
|
19
18
|
export { encodeToURLParams, withTimeout };
|
|
@@ -3,7 +3,7 @@ import { CAPTCHA_VERIFY_TIMEOUT_MS } from "../constants.mjs";
|
|
|
3
3
|
import { EXTERNAL_ERROR_CODES, INTERNAL_ERROR_CODES } from "../error-codes.mjs";
|
|
4
4
|
import { encodeToURLParams } from "../utils.mjs";
|
|
5
5
|
import { betterFetch } from "@better-fetch/fetch";
|
|
6
|
-
|
|
6
|
+
// src/plugins/captcha/verify-handlers/captchafox.ts
|
|
7
7
|
const captchaFox = async ({ siteVerifyURL, captchaResponse, secretKey, siteKey, remoteIP }) => {
|
|
8
8
|
const response = await betterFetch(siteVerifyURL, {
|
|
9
9
|
method: "POST",
|
|
@@ -23,5 +23,4 @@ const captchaFox = async ({ siteVerifyURL, captchaResponse, secretKey, siteKey,
|
|
|
23
23
|
status: 403
|
|
24
24
|
});
|
|
25
25
|
};
|
|
26
|
-
//#endregion
|
|
27
26
|
export { captchaFox };
|
|
@@ -2,7 +2,7 @@ import { middlewareResponse } from "../../../utils/middleware-response.mjs";
|
|
|
2
2
|
import { CAPTCHA_VERIFY_TIMEOUT_MS } from "../constants.mjs";
|
|
3
3
|
import { EXTERNAL_ERROR_CODES, INTERNAL_ERROR_CODES } from "../error-codes.mjs";
|
|
4
4
|
import { betterFetch } from "@better-fetch/fetch";
|
|
5
|
-
|
|
5
|
+
// src/plugins/captcha/verify-handlers/cloudflare-turnstile.ts
|
|
6
6
|
const cloudflareTurnstile = async ({ siteVerifyURL, captchaResponse, secretKey, logger, remoteIP, expectedAction, allowedHostnames }) => {
|
|
7
7
|
const response = await betterFetch(siteVerifyURL, {
|
|
8
8
|
method: "POST",
|
|
@@ -43,5 +43,4 @@ const cloudflareTurnstile = async ({ siteVerifyURL, captchaResponse, secretKey,
|
|
|
43
43
|
actualHostname: response.data.hostname
|
|
44
44
|
});
|
|
45
45
|
};
|
|
46
|
-
//#endregion
|
|
47
46
|
export { cloudflareTurnstile };
|
|
@@ -3,7 +3,7 @@ import { CAPTCHA_VERIFY_TIMEOUT_MS } from "../constants.mjs";
|
|
|
3
3
|
import { EXTERNAL_ERROR_CODES, INTERNAL_ERROR_CODES } from "../error-codes.mjs";
|
|
4
4
|
import { encodeToURLParams } from "../utils.mjs";
|
|
5
5
|
import { betterFetch } from "@better-fetch/fetch";
|
|
6
|
-
|
|
6
|
+
// src/plugins/captcha/verify-handlers/google-recaptcha.ts
|
|
7
7
|
const isV3 = (response) => {
|
|
8
8
|
return "score" in response && typeof response.score === "number";
|
|
9
9
|
};
|
|
@@ -28,5 +28,4 @@ const googleRecaptcha = async ({ siteVerifyURL, captchaResponse, secretKey, minS
|
|
|
28
28
|
if (expectedAction && response.data.action !== expectedAction) return verificationFailed();
|
|
29
29
|
if (allowedHostnames && allowedHostnames.length > 0 && !allowedHostnames.includes(response.data.hostname)) return verificationFailed();
|
|
30
30
|
};
|
|
31
|
-
//#endregion
|
|
32
31
|
export { googleRecaptcha };
|
|
@@ -3,7 +3,7 @@ import { CAPTCHA_VERIFY_TIMEOUT_MS } from "../constants.mjs";
|
|
|
3
3
|
import { EXTERNAL_ERROR_CODES, INTERNAL_ERROR_CODES } from "../error-codes.mjs";
|
|
4
4
|
import { encodeToURLParams } from "../utils.mjs";
|
|
5
5
|
import { betterFetch } from "@better-fetch/fetch";
|
|
6
|
-
|
|
6
|
+
// src/plugins/captcha/verify-handlers/h-captcha.ts
|
|
7
7
|
const hCaptcha = async ({ siteVerifyURL, captchaResponse, secretKey, siteKey, remoteIP }) => {
|
|
8
8
|
const response = await betterFetch(siteVerifyURL, {
|
|
9
9
|
method: "POST",
|
|
@@ -23,5 +23,4 @@ const hCaptcha = async ({ siteVerifyURL, captchaResponse, secretKey, siteKey, re
|
|
|
23
23
|
status: 403
|
|
24
24
|
});
|
|
25
25
|
};
|
|
26
|
-
//#endregion
|
|
27
26
|
export { hCaptcha };
|