better-auth 1.7.20 → 1.7.22
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/_virtual/_rolldown/runtime.mjs +1 -2
- package/dist/adapters/index.d.mts +0 -2
- package/dist/adapters/index.mjs +1 -2
- package/dist/api/dispatch.d.mts +1 -3
- package/dist/api/dispatch.mjs +1 -2
- package/dist/api/index.d.mts +5 -4
- package/dist/api/index.mjs +9 -9
- package/dist/api/middlewares/authorization.d.mts +1 -3
- package/dist/api/middlewares/authorization.mjs +1 -2
- package/dist/api/middlewares/origin-check.d.mts +1 -3
- package/dist/api/middlewares/origin-check.mjs +2 -3
- package/dist/api/rate-limiter/index.mjs +1 -2
- package/dist/api/routes/account.d.mts +1 -3
- package/dist/api/routes/account.mjs +10 -10
- package/dist/api/routes/callback.d.mts +1 -3
- package/dist/api/routes/callback.mjs +5 -6
- package/dist/api/routes/email-verification.d.mts +1 -3
- package/dist/api/routes/email-verification.mjs +4 -5
- package/dist/api/routes/error.d.mts +1 -3
- package/dist/api/routes/error.mjs +1 -2
- package/dist/api/routes/ok.d.mts +1 -3
- package/dist/api/routes/ok.mjs +1 -2
- package/dist/api/routes/password.d.mts +1 -3
- package/dist/api/routes/password.mjs +3 -4
- package/dist/api/routes/session.d.mts +2 -3
- package/dist/api/routes/session.mjs +10 -6
- package/dist/api/routes/sign-in.d.mts +0 -2
- package/dist/api/routes/sign-in.mjs +6 -7
- package/dist/api/routes/sign-out.d.mts +1 -3
- package/dist/api/routes/sign-out.mjs +1 -2
- package/dist/api/routes/sign-up.d.mts +1 -3
- package/dist/api/routes/sign-up.mjs +26 -16
- package/dist/api/routes/update-session.d.mts +1 -3
- package/dist/api/routes/update-session.mjs +2 -3
- package/dist/api/routes/update-user.d.mts +1 -3
- package/dist/api/routes/update-user.mjs +31 -28
- package/dist/api/state/oauth.d.mts +0 -2
- package/dist/api/state/oauth.mjs +1 -2
- package/dist/api/state/session-source.d.mts +1 -3
- package/dist/api/state/session-source.mjs +1 -2
- package/dist/api/state/should-session-refresh.d.mts +0 -2
- package/dist/api/state/should-session-refresh.mjs +1 -2
- package/dist/api/to-auth-endpoints.mjs +2 -3
- package/dist/auth/base.mjs +3 -9
- package/dist/auth/full.d.mts +1 -3
- package/dist/auth/full.mjs +1 -2
- package/dist/auth/minimal.d.mts +0 -2
- package/dist/auth/minimal.mjs +2 -3
- package/dist/auth/trusted-origins.mjs +2 -3
- package/dist/client/broadcast-channel.d.mts +1 -3
- package/dist/client/broadcast-channel.mjs +4 -4
- package/dist/client/config.d.mts +1 -3
- package/dist/client/config.mjs +2 -3
- package/dist/client/equality.d.mts +1 -3
- package/dist/client/equality.mjs +1 -2
- package/dist/client/fetch-plugins.mjs +1 -2
- package/dist/client/focus-manager.d.mts +1 -3
- package/dist/client/focus-manager.mjs +4 -4
- package/dist/client/index.d.mts +5 -7
- package/dist/client/index.mjs +1 -2
- package/dist/client/lynx/index.d.mts +1 -3
- package/dist/client/lynx/index.mjs +1 -2
- package/dist/client/lynx/lynx-store.d.mts +0 -2
- package/dist/client/lynx/lynx-store.mjs +1 -2
- package/dist/client/online-manager.d.mts +1 -3
- package/dist/client/online-manager.mjs +7 -7
- package/dist/client/parser.d.mts +0 -2
- package/dist/client/parser.mjs +1 -2
- package/dist/client/path-to-object.d.mts +0 -2
- package/dist/client/plugins/index.d.mts +6 -6
- package/dist/client/plugins/infer-plugin.d.mts +1 -3
- package/dist/client/plugins/infer-plugin.mjs +1 -2
- package/dist/client/proxy.mjs +1 -2
- package/dist/client/query-atom.mjs +1 -2
- package/dist/client/query.d.mts +1 -3
- package/dist/client/query.mjs +1 -2
- package/dist/client/react/index.d.mts +1 -3
- package/dist/client/react/index.mjs +1 -2
- package/dist/client/react/react-store.d.mts +0 -2
- package/dist/client/react/react-store.mjs +1 -2
- package/dist/client/session-atom.d.mts +1 -3
- package/dist/client/session-atom.mjs +2 -2
- package/dist/client/session-refresh.d.mts +1 -3
- package/dist/client/session-refresh.mjs +3 -3
- package/dist/client/solid/index.d.mts +1 -3
- package/dist/client/solid/index.mjs +1 -2
- package/dist/client/solid/solid-store.mjs +1 -2
- package/dist/client/svelte/index.d.mts +1 -3
- package/dist/client/svelte/index.mjs +1 -2
- package/dist/client/types.d.mts +2 -4
- package/dist/client/vanilla.d.mts +1 -3
- package/dist/client/vanilla.mjs +1 -2
- package/dist/client/vue/index.d.mts +1 -3
- package/dist/client/vue/index.mjs +1 -2
- package/dist/client/vue/vue-store.mjs +1 -2
- package/dist/context/create-context.mjs +8 -9
- package/dist/context/helpers.mjs +3 -4
- package/dist/context/init-minimal.mjs +1 -2
- package/dist/context/init.mjs +1 -2
- package/dist/context/secret-utils.mjs +1 -2
- package/dist/context/store-capabilities.mjs +1 -2
- package/dist/cookies/cache.mjs +1 -2
- package/dist/cookies/cookie-utils.d.mts +0 -2
- package/dist/cookies/cookie-utils.mjs +1 -2
- package/dist/cookies/index.d.mts +0 -2
- package/dist/cookies/index.mjs +2 -3
- package/dist/cookies/jwt.mjs +1 -2
- package/dist/cookies/session-store.d.mts +0 -2
- package/dist/cookies/session-store.mjs +1 -2
- package/dist/crypto/buffer.d.mts +1 -3
- package/dist/crypto/buffer.mjs +1 -2
- package/dist/crypto/index.d.mts +0 -2
- package/dist/crypto/index.mjs +2 -3
- package/dist/crypto/jwt.d.mts +1 -3
- package/dist/crypto/jwt.mjs +1 -2
- package/dist/crypto/password.d.mts +0 -2
- package/dist/crypto/password.mjs +1 -2
- package/dist/crypto/purpose.mjs +1 -2
- package/dist/crypto/random.d.mts +1 -3
- package/dist/crypto/random.mjs +1 -2
- package/dist/db/adapter-base.d.mts +1 -3
- package/dist/db/adapter-base.mjs +1 -2
- package/dist/db/adapter-kysely.d.mts +1 -3
- package/dist/db/adapter-kysely.mjs +1 -2
- package/dist/db/field-converter.d.mts +1 -3
- package/dist/db/field-converter.mjs +1 -2
- package/dist/db/field.d.mts +0 -2
- package/dist/db/get-migration.d.mts +1 -3
- package/dist/db/get-migration.mjs +10 -13
- package/dist/db/get-schema.d.mts +1 -3
- package/dist/db/get-schema.mjs +1 -2
- package/dist/db/index.d.mts +1 -1
- package/dist/db/index.mjs +4 -5
- package/dist/db/internal-adapter.d.mts +1 -3
- package/dist/db/internal-adapter.mjs +25 -11
- package/dist/db/revoke-unproven-account-access.d.mts +1 -3
- package/dist/db/revoke-unproven-account-access.mjs +1 -2
- package/dist/db/schema.d.mts +1 -3
- package/dist/db/schema.mjs +1 -2
- package/dist/db/to-zod.d.mts +0 -2
- package/dist/db/to-zod.mjs +1 -2
- package/dist/db/verification-token-storage.mjs +1 -2
- package/dist/db/with-hooks.d.mts +1 -3
- package/dist/db/with-hooks.mjs +1 -2
- package/dist/index.d.mts +1 -1
- package/dist/index.mjs +1 -1
- package/dist/integrations/cookie-plugin-guard.mjs +1 -2
- package/dist/integrations/next-js.d.mts +1 -3
- package/dist/integrations/next-js.mjs +2 -3
- package/dist/integrations/node.d.mts +1 -3
- package/dist/integrations/node.mjs +1 -2
- package/dist/integrations/solid-start.d.mts +1 -3
- package/dist/integrations/solid-start.mjs +1 -2
- package/dist/integrations/svelte-kit.d.mts +1 -3
- package/dist/integrations/svelte-kit.mjs +1 -2
- package/dist/integrations/tanstack-start-solid.d.mts +1 -3
- package/dist/integrations/tanstack-start-solid.mjs +1 -2
- package/dist/integrations/tanstack-start.d.mts +1 -3
- package/dist/integrations/tanstack-start.mjs +1 -2
- package/dist/oauth2/account-key.mjs +1 -2
- package/dist/oauth2/callback.mjs +1 -2
- package/dist/oauth2/errors.mjs +1 -2
- package/dist/oauth2/index.d.mts +1 -1
- package/dist/oauth2/index.mjs +1 -1
- package/dist/oauth2/link-account.d.mts +1 -3
- package/dist/oauth2/link-account.mjs +18 -13
- package/dist/oauth2/state.d.mts +1 -3
- package/dist/oauth2/state.mjs +3 -4
- package/dist/oauth2/utils.d.mts +1 -3
- package/dist/oauth2/utils.mjs +1 -2
- package/dist/package.mjs +2 -3
- package/dist/plugins/access/access.d.mts +1 -3
- package/dist/plugins/access/access.mjs +1 -2
- package/dist/plugins/access/index.d.mts +1 -1
- package/dist/plugins/access/types.d.mts +1 -3
- package/dist/plugins/additional-fields/client.d.mts +1 -3
- package/dist/plugins/additional-fields/client.mjs +1 -2
- package/dist/plugins/admin/access/statement.d.mts +1 -3
- package/dist/plugins/admin/access/statement.mjs +1 -2
- package/dist/plugins/admin/admin.d.mts +1 -3
- package/dist/plugins/admin/admin.mjs +2 -3
- package/dist/plugins/admin/client.d.mts +2 -4
- package/dist/plugins/admin/client.mjs +1 -2
- package/dist/plugins/admin/error-codes.d.mts +1 -3
- package/dist/plugins/admin/error-codes.mjs +1 -2
- package/dist/plugins/admin/has-permission.mjs +1 -2
- package/dist/plugins/admin/index.d.mts +1 -1
- package/dist/plugins/admin/routes.mjs +3 -4
- package/dist/plugins/admin/schema.d.mts +1 -3
- package/dist/plugins/admin/schema.mjs +1 -2
- package/dist/plugins/admin/types.d.mts +1 -3
- package/dist/plugins/anonymous/client.d.mts +1 -3
- package/dist/plugins/anonymous/client.mjs +1 -2
- package/dist/plugins/anonymous/error-codes.d.mts +1 -3
- package/dist/plugins/anonymous/error-codes.mjs +1 -2
- package/dist/plugins/anonymous/index.d.mts +0 -2
- package/dist/plugins/anonymous/index.mjs +3 -4
- package/dist/plugins/anonymous/schema.d.mts +1 -3
- package/dist/plugins/anonymous/schema.mjs +1 -2
- package/dist/plugins/anonymous/types.d.mts +1 -3
- package/dist/plugins/bearer/index.d.mts +1 -3
- package/dist/plugins/bearer/index.mjs +1 -2
- package/dist/plugins/captcha/constants.d.mts +1 -3
- package/dist/plugins/captcha/constants.mjs +1 -2
- package/dist/plugins/captcha/error-codes.mjs +1 -2
- package/dist/plugins/captcha/index.d.mts +0 -2
- package/dist/plugins/captcha/index.mjs +2 -3
- package/dist/plugins/captcha/types.d.mts +1 -3
- package/dist/plugins/captcha/utils.mjs +1 -2
- package/dist/plugins/captcha/verify-handlers/captchafox.mjs +1 -2
- package/dist/plugins/captcha/verify-handlers/cloudflare-turnstile.mjs +1 -2
- package/dist/plugins/captcha/verify-handlers/google-recaptcha.mjs +1 -2
- package/dist/plugins/captcha/verify-handlers/h-captcha.mjs +1 -2
- package/dist/plugins/captcha/verify-handlers/vercel-botid.mjs +1 -2
- package/dist/plugins/custom-session/client.d.mts +1 -3
- package/dist/plugins/custom-session/client.mjs +1 -2
- package/dist/plugins/custom-session/index.d.mts +1 -3
- package/dist/plugins/custom-session/index.mjs +3 -4
- package/dist/plugins/device-authorization/client.d.mts +1 -3
- package/dist/plugins/device-authorization/client.mjs +1 -2
- package/dist/plugins/device-authorization/error-codes.mjs +1 -2
- package/dist/plugins/device-authorization/index.d.mts +1 -3
- package/dist/plugins/device-authorization/index.mjs +2 -3
- package/dist/plugins/device-authorization/routes.d.mts +4 -6
- package/dist/plugins/device-authorization/routes.mjs +18 -4
- package/dist/plugins/device-authorization/schema.d.mts +0 -2
- package/dist/plugins/device-authorization/schema.mjs +1 -2
- package/dist/plugins/email-otp/client.d.mts +0 -2
- package/dist/plugins/email-otp/client.mjs +1 -2
- package/dist/plugins/email-otp/error-codes.d.mts +1 -3
- package/dist/plugins/email-otp/error-codes.mjs +1 -2
- package/dist/plugins/email-otp/index.d.mts +0 -2
- package/dist/plugins/email-otp/index.mjs +4 -5
- package/dist/plugins/email-otp/otp-token.mjs +3 -4
- package/dist/plugins/email-otp/routes.mjs +6 -7
- package/dist/plugins/email-otp/types.d.mts +1 -3
- package/dist/plugins/email-otp/utils.mjs +1 -2
- package/dist/plugins/generic-oauth/error-codes.mjs +1 -2
- package/dist/plugins/generic-oauth/index.d.mts +1 -6
- package/dist/plugins/generic-oauth/index.mjs +43 -30
- package/dist/plugins/generic-oauth/providers/auth0.d.mts +1 -3
- package/dist/plugins/generic-oauth/providers/auth0.mjs +1 -2
- package/dist/plugins/generic-oauth/providers/gumroad.d.mts +1 -3
- package/dist/plugins/generic-oauth/providers/gumroad.mjs +1 -2
- package/dist/plugins/generic-oauth/providers/hubspot.d.mts +1 -3
- package/dist/plugins/generic-oauth/providers/hubspot.mjs +1 -2
- package/dist/plugins/generic-oauth/providers/keycloak.d.mts +1 -3
- package/dist/plugins/generic-oauth/providers/keycloak.mjs +1 -2
- package/dist/plugins/generic-oauth/providers/line.d.mts +1 -3
- package/dist/plugins/generic-oauth/providers/line.mjs +1 -2
- package/dist/plugins/generic-oauth/providers/microsoft-entra-id.d.mts +1 -3
- package/dist/plugins/generic-oauth/providers/microsoft-entra-id.mjs +1 -2
- package/dist/plugins/generic-oauth/providers/okta.d.mts +1 -3
- package/dist/plugins/generic-oauth/providers/okta.mjs +1 -2
- package/dist/plugins/generic-oauth/providers/patreon.d.mts +1 -3
- package/dist/plugins/generic-oauth/providers/patreon.mjs +1 -2
- package/dist/plugins/generic-oauth/providers/slack.d.mts +1 -3
- package/dist/plugins/generic-oauth/providers/slack.mjs +1 -2
- package/dist/plugins/generic-oauth/providers/yandex.d.mts +1 -3
- package/dist/plugins/generic-oauth/providers/yandex.mjs +1 -2
- package/dist/plugins/generic-oauth/types.d.mts +6 -5
- package/dist/plugins/haveibeenpwned/index.d.mts +1 -3
- package/dist/plugins/haveibeenpwned/index.mjs +2 -3
- package/dist/plugins/index.d.mts +5 -5
- package/dist/plugins/jwt/adapter.mjs +1 -2
- package/dist/plugins/jwt/client.d.mts +1 -3
- package/dist/plugins/jwt/client.mjs +1 -2
- package/dist/plugins/jwt/cookie-cache.mjs +1 -2
- package/dist/plugins/jwt/index.d.mts +1 -3
- package/dist/plugins/jwt/index.mjs +5 -6
- package/dist/plugins/jwt/schema.d.mts +1 -3
- package/dist/plugins/jwt/schema.mjs +1 -2
- package/dist/plugins/jwt/sign.d.mts +0 -2
- package/dist/plugins/jwt/sign.mjs +1 -2
- package/dist/plugins/jwt/types.d.mts +1 -3
- package/dist/plugins/jwt/utils.d.mts +1 -3
- package/dist/plugins/jwt/utils.mjs +2 -3
- package/dist/plugins/jwt/verify.d.mts +1 -3
- package/dist/plugins/jwt/verify.mjs +1 -2
- package/dist/plugins/last-login-method/client.d.mts +1 -3
- package/dist/plugins/last-login-method/client.mjs +1 -2
- package/dist/plugins/last-login-method/index.d.mts +1 -3
- package/dist/plugins/last-login-method/index.mjs +1 -2
- package/dist/plugins/magic-link/client.d.mts +1 -3
- package/dist/plugins/magic-link/client.mjs +1 -2
- package/dist/plugins/magic-link/index.d.mts +1 -3
- package/dist/plugins/magic-link/index.mjs +4 -5
- package/dist/plugins/magic-link/utils.mjs +1 -2
- package/dist/plugins/multi-session/client.d.mts +0 -2
- package/dist/plugins/multi-session/client.mjs +1 -2
- package/dist/plugins/multi-session/error-codes.d.mts +1 -3
- package/dist/plugins/multi-session/error-codes.mjs +1 -2
- package/dist/plugins/multi-session/index.d.mts +0 -2
- package/dist/plugins/multi-session/index.mjs +3 -4
- package/dist/plugins/oauth-popup/client.d.mts +0 -2
- package/dist/plugins/oauth-popup/client.mjs +1 -2
- package/dist/plugins/oauth-popup/constants.d.mts +1 -3
- package/dist/plugins/oauth-popup/constants.mjs +1 -2
- package/dist/plugins/oauth-popup/error-codes.d.mts +1 -3
- package/dist/plugins/oauth-popup/error-codes.mjs +1 -2
- package/dist/plugins/oauth-popup/index.d.mts +0 -2
- package/dist/plugins/oauth-popup/index.mjs +5 -6
- package/dist/plugins/oauth-popup/types.d.mts +1 -3
- package/dist/plugins/oauth-proxy/index.d.mts +1 -3
- package/dist/plugins/oauth-proxy/index.mjs +7 -8
- package/dist/plugins/oauth-proxy/utils.mjs +1 -2
- package/dist/plugins/one-tap/client.d.mts +1 -3
- package/dist/plugins/one-tap/client.mjs +1 -2
- package/dist/plugins/one-tap/index.d.mts +1 -3
- package/dist/plugins/one-tap/index.mjs +7 -8
- package/dist/plugins/one-time-token/client.d.mts +0 -2
- package/dist/plugins/one-time-token/client.mjs +1 -2
- package/dist/plugins/one-time-token/index.d.mts +1 -3
- package/dist/plugins/one-time-token/index.mjs +3 -4
- package/dist/plugins/one-time-token/utils.mjs +1 -2
- package/dist/plugins/open-api/generator.d.mts +0 -2
- package/dist/plugins/open-api/generator.mjs +2 -3
- package/dist/plugins/open-api/index.d.mts +0 -2
- package/dist/plugins/open-api/index.mjs +2 -3
- package/dist/plugins/open-api/logo.mjs +1 -2
- package/dist/plugins/organization/access/statement.d.mts +1 -3
- package/dist/plugins/organization/access/statement.mjs +1 -2
- package/dist/plugins/organization/adapter.d.mts +3 -5
- package/dist/plugins/organization/adapter.mjs +2 -3
- package/dist/plugins/organization/call.mjs +1 -2
- package/dist/plugins/organization/client.d.mts +9 -11
- package/dist/plugins/organization/client.mjs +2 -3
- package/dist/plugins/organization/error-codes.d.mts +1 -3
- package/dist/plugins/organization/error-codes.mjs +1 -2
- package/dist/plugins/organization/has-permission.d.mts +1 -3
- package/dist/plugins/organization/has-permission.mjs +2 -3
- package/dist/plugins/organization/index.d.mts +3 -3
- package/dist/plugins/organization/organization.d.mts +3 -5
- package/dist/plugins/organization/organization.mjs +3 -4
- package/dist/plugins/organization/permission.d.mts +1 -3
- package/dist/plugins/organization/permission.mjs +1 -2
- package/dist/plugins/organization/roles.d.mts +1 -3
- package/dist/plugins/organization/roles.mjs +1 -2
- package/dist/plugins/organization/routes/crud-access-control.d.mts +2 -4
- package/dist/plugins/organization/routes/crud-access-control.mjs +3 -4
- package/dist/plugins/organization/routes/crud-invites.d.mts +4 -6
- package/dist/plugins/organization/routes/crud-invites.mjs +5 -6
- package/dist/plugins/organization/routes/crud-members.d.mts +4 -6
- package/dist/plugins/organization/routes/crud-members.mjs +4 -5
- package/dist/plugins/organization/routes/crud-org.d.mts +4 -6
- package/dist/plugins/organization/routes/crud-org.mjs +8 -9
- package/dist/plugins/organization/routes/crud-team.d.mts +4 -6
- package/dist/plugins/organization/routes/crud-team.mjs +3 -4
- package/dist/plugins/organization/schema.d.mts +0 -2
- package/dist/plugins/organization/schema.mjs +1 -2
- package/dist/plugins/organization/types.d.mts +1 -3
- package/dist/plugins/phone-number/client.d.mts +1 -3
- package/dist/plugins/phone-number/client.mjs +1 -2
- package/dist/plugins/phone-number/error-codes.d.mts +1 -3
- package/dist/plugins/phone-number/error-codes.mjs +1 -2
- package/dist/plugins/phone-number/index.d.mts +0 -2
- package/dist/plugins/phone-number/index.mjs +1 -2
- package/dist/plugins/phone-number/routes.mjs +6 -7
- package/dist/plugins/phone-number/schema.d.mts +1 -3
- package/dist/plugins/phone-number/schema.mjs +1 -2
- package/dist/plugins/phone-number/types.d.mts +2 -4
- package/dist/plugins/siwe/client.d.mts +1 -3
- package/dist/plugins/siwe/client.mjs +1 -2
- package/dist/plugins/siwe/index.d.mts +1 -3
- package/dist/plugins/siwe/index.mjs +6 -7
- package/dist/plugins/siwe/parse-message.mjs +1 -2
- package/dist/plugins/siwe/schema.d.mts +1 -3
- package/dist/plugins/siwe/schema.mjs +1 -2
- package/dist/plugins/siwe/types.d.mts +0 -2
- package/dist/plugins/test-utils/auth-helpers.mjs +1 -2
- package/dist/plugins/test-utils/cookie-builder.mjs +1 -2
- package/dist/plugins/test-utils/db-helpers.mjs +1 -2
- package/dist/plugins/test-utils/factories.mjs +1 -2
- package/dist/plugins/test-utils/index.d.mts +0 -2
- package/dist/plugins/test-utils/index.mjs +2 -3
- package/dist/plugins/test-utils/otp-sink.mjs +1 -2
- package/dist/plugins/test-utils/types.d.mts +1 -3
- package/dist/plugins/two-factor/backup-codes/index.d.mts +1 -3
- package/dist/plugins/two-factor/backup-codes/index.mjs +4 -5
- package/dist/plugins/two-factor/client.d.mts +2 -4
- package/dist/plugins/two-factor/client.mjs +1 -2
- package/dist/plugins/two-factor/constant.mjs +1 -2
- package/dist/plugins/two-factor/error-code.d.mts +1 -3
- package/dist/plugins/two-factor/error-code.mjs +1 -2
- package/dist/plugins/two-factor/index.d.mts +0 -2
- package/dist/plugins/two-factor/index.mjs +9 -10
- package/dist/plugins/two-factor/otp/index.d.mts +1 -3
- package/dist/plugins/two-factor/otp/index.mjs +4 -5
- package/dist/plugins/two-factor/schema.d.mts +1 -3
- package/dist/plugins/two-factor/schema.mjs +1 -2
- package/dist/plugins/two-factor/totp/index.d.mts +1 -3
- package/dist/plugins/two-factor/totp/index.mjs +3 -4
- package/dist/plugins/two-factor/types.d.mts +1 -3
- package/dist/plugins/two-factor/utils.mjs +1 -2
- package/dist/plugins/two-factor/verify-two-factor.mjs +5 -6
- package/dist/plugins/username/client.d.mts +0 -2
- package/dist/plugins/username/client.mjs +1 -2
- package/dist/plugins/username/error-codes.d.mts +1 -3
- package/dist/plugins/username/error-codes.mjs +1 -2
- package/dist/plugins/username/index.d.mts +0 -2
- package/dist/plugins/username/index.mjs +4 -5
- package/dist/plugins/username/schema.d.mts +1 -3
- package/dist/plugins/username/schema.mjs +1 -2
- package/dist/state.d.mts +2 -7
- package/dist/state.mjs +3 -7
- package/dist/test-utils/headers.d.mts +1 -3
- package/dist/test-utils/headers.mjs +1 -2
- package/dist/test-utils/http-test-instance.d.mts +0 -2
- package/dist/test-utils/http-test-instance.mjs +1 -2
- package/dist/test-utils/index.d.mts +1 -1
- package/dist/test-utils/index.mjs +1 -1
- package/dist/test-utils/test-instance.d.mts +4 -6
- package/dist/test-utils/test-instance.mjs +5 -6
- package/dist/types/api.d.mts +1 -3
- package/dist/types/auth.d.mts +2 -4
- package/dist/types/helper.d.mts +1 -3
- package/dist/types/index.d.mts +2 -2
- package/dist/types/models.d.mts +0 -2
- package/dist/types/plugins.d.mts +0 -2
- package/dist/utils/constants.mjs +1 -2
- package/dist/utils/date.mjs +1 -2
- package/dist/utils/hashing.mjs +1 -2
- package/dist/utils/hide-metadata.d.mts +2 -5
- package/dist/utils/hide-metadata.mjs +1 -4
- package/dist/utils/index.d.mts +1 -1
- package/dist/utils/is-atom.mjs +1 -2
- package/dist/utils/is-promise.mjs +1 -2
- package/dist/utils/middleware-response.mjs +1 -2
- package/dist/utils/password.mjs +1 -2
- package/dist/utils/plugin-helper.mjs +1 -2
- package/dist/utils/request.mjs +1 -2
- package/dist/utils/shim.mjs +1 -2
- package/dist/utils/time.d.mts +0 -2
- package/dist/utils/time.mjs +1 -2
- package/dist/utils/url.d.mts +1 -3
- package/dist/utils/url.mjs +1 -2
- package/dist/utils/validate-user-info.mjs +1 -2
- package/dist/utils/wildcard.mjs +1 -2
- package/dist/version.mjs +1 -2
- package/package.json +10 -10
- package/dist/utils/boolean.mjs +0 -6
|
@@ -1,19 +1,18 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import { symmetricDecrypt } from "../crypto/index.mjs";
|
|
1
|
+
import { createEmailVerificationToken } from "../api/routes/email-verification.mjs";
|
|
2
|
+
import { isStateful } from "../api/routes/session.mjs";
|
|
4
3
|
import { setAccountCookie } from "../cookies/session-store.mjs";
|
|
5
|
-
import {
|
|
4
|
+
import { symmetricDecrypt } from "../crypto/index.mjs";
|
|
6
5
|
import { derivePurposeKey } from "../crypto/purpose.mjs";
|
|
6
|
+
import { parseAdditionalUserInputFromProviderProfile } from "../db/schema.mjs";
|
|
7
|
+
import { isAPIError } from "../utils/is-api-error.mjs";
|
|
8
|
+
import { assertValidUserInfo } from "../utils/validate-user-info.mjs";
|
|
7
9
|
import { OAUTH_CALLBACK_ERROR_CODES, redirectOnError } from "./errors.mjs";
|
|
8
|
-
import { isStateful } from "../api/routes/session.mjs";
|
|
9
|
-
import { toBoolean } from "../utils/boolean.mjs";
|
|
10
10
|
import { setTokenUtil } from "./utils.mjs";
|
|
11
|
-
import { createEmailVerificationToken } from "../api/routes/email-verification.mjs";
|
|
12
11
|
import { queueAfterTransactionHook, runWithTransaction } from "@better-auth/core/context";
|
|
13
12
|
import { isDevelopment } from "@better-auth/core/env";
|
|
14
13
|
import { APIError } from "@better-auth/core/error";
|
|
15
|
-
import { mergeScopes } from "@better-auth/core/oauth2";
|
|
16
|
-
|
|
14
|
+
import { mergeScopes, parseStringBoolean } from "@better-auth/core/oauth2";
|
|
15
|
+
// src/oauth2/link-account.ts
|
|
17
16
|
function linkOAuthAccountFailure(code, message) {
|
|
18
17
|
return {
|
|
19
18
|
linked: false,
|
|
@@ -43,7 +42,7 @@ async function linkOAuthAccount(c, opts) {
|
|
|
43
42
|
const { link, account, profile, scopes } = opts;
|
|
44
43
|
const userInfo = {
|
|
45
44
|
...opts.userInfo,
|
|
46
|
-
emailVerified:
|
|
45
|
+
emailVerified: parseStringBoolean(opts.userInfo.emailVerified) ?? false
|
|
47
46
|
};
|
|
48
47
|
if (!await isLinkSessionLive(c, link)) return linkOAuthAccountFailure(OAUTH_CALLBACK_ERROR_CODES.UNABLE_TO_LINK_ACCOUNT);
|
|
49
48
|
try {
|
|
@@ -99,7 +98,7 @@ async function handleOAuthUserInfo(c, opts) {
|
|
|
99
98
|
const { account, callbackURL, disableSignUp, overrideUserInfo } = opts;
|
|
100
99
|
const userInfo = {
|
|
101
100
|
...opts.userInfo,
|
|
102
|
-
emailVerified:
|
|
101
|
+
emailVerified: parseStringBoolean(opts.userInfo.emailVerified) ?? false
|
|
103
102
|
};
|
|
104
103
|
const source = opts.source ?? {
|
|
105
104
|
method: "oauth",
|
|
@@ -305,7 +304,7 @@ async function handleOAuthUserInfo(c, opts) {
|
|
|
305
304
|
providerId: account.providerId,
|
|
306
305
|
accountId: account.accountId
|
|
307
306
|
};
|
|
308
|
-
const
|
|
307
|
+
const created = await runWithTransaction(c.context.adapter, async () => {
|
|
309
308
|
const createdUser = await c.context.internalAdapter.createUser({
|
|
310
309
|
name,
|
|
311
310
|
image,
|
|
@@ -313,6 +312,7 @@ async function handleOAuthUserInfo(c, opts) {
|
|
|
313
312
|
email: userInfo.email.toLowerCase(),
|
|
314
313
|
emailVerified: userInfo.emailVerified
|
|
315
314
|
}, source);
|
|
315
|
+
if (!createdUser) return null;
|
|
316
316
|
return {
|
|
317
317
|
createdUser,
|
|
318
318
|
createdAccount: await c.context.internalAdapter.createAccount({
|
|
@@ -321,6 +321,12 @@ async function handleOAuthUserInfo(c, opts) {
|
|
|
321
321
|
})
|
|
322
322
|
};
|
|
323
323
|
});
|
|
324
|
+
if (!created) return {
|
|
325
|
+
error: "unable to create user",
|
|
326
|
+
data: null,
|
|
327
|
+
isRegister: false
|
|
328
|
+
};
|
|
329
|
+
const { createdUser, createdAccount } = created;
|
|
324
330
|
if (requireExactAccountBinding && (createdAccount.accountId !== account.accountId || createdAccount.providerId !== account.providerId || createdAccount.userId !== createdUser.id)) throw new APIError("CONFLICT", {
|
|
325
331
|
code: "account_hook_binding_conflict",
|
|
326
332
|
message: "Account hook changed the selected authentication binding"
|
|
@@ -421,5 +427,4 @@ async function applyUpdateUserInfoOnLink(c, userId, userInfo) {
|
|
|
421
427
|
return;
|
|
422
428
|
}
|
|
423
429
|
}
|
|
424
|
-
//#endregion
|
|
425
430
|
export { applyUpdateUserInfoOnLink, handleOAuthUserInfo, linkOAuthAccount };
|
package/dist/oauth2/state.d.mts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { StateData } from "../state.mjs";
|
|
2
2
|
import { GenericEndpointContext } from "@better-auth/core";
|
|
3
|
-
//#region src/oauth2/state.d.ts
|
|
4
3
|
/**
|
|
5
4
|
* Mint the OIDC `nonce` for the redirect flow, or `undefined` when the provider
|
|
6
5
|
* does not require ID-token nonce binding. Every redirect entrypoint (social
|
|
@@ -49,5 +48,4 @@ export declare function parseState(c: GenericEndpointContext): Promise<{
|
|
|
49
48
|
requestSignUp?: boolean | undefined;
|
|
50
49
|
idTokenNonce?: string | undefined;
|
|
51
50
|
serverContext?: Record<string, unknown> | undefined;
|
|
52
|
-
}>;
|
|
53
|
-
//#endregion
|
|
51
|
+
}>;
|
package/dist/oauth2/state.mjs
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { generateRandomString } from "../crypto/random.mjs";
|
|
2
|
-
import { redirectOnError } from "./errors.mjs";
|
|
3
1
|
import { getOAuthServerContext, setOAuthState } from "../api/state/oauth.mjs";
|
|
2
|
+
import { generateRandomString } from "../crypto/random.mjs";
|
|
4
3
|
import { StateError, generateGenericState, parseGenericState } from "../state.mjs";
|
|
4
|
+
import { redirectOnError } from "./errors.mjs";
|
|
5
5
|
import { APIError, BASE_ERROR_CODES } from "@better-auth/core/error";
|
|
6
|
-
|
|
6
|
+
// src/oauth2/state.ts
|
|
7
7
|
/**
|
|
8
8
|
* Mint the OIDC `nonce` for the redirect flow, or `undefined` when the provider
|
|
9
9
|
* does not require ID-token nonce binding. Every redirect entrypoint (social
|
|
@@ -63,5 +63,4 @@ async function parseState(c) {
|
|
|
63
63
|
if (parsedData) await setOAuthState(parsedData);
|
|
64
64
|
return parsedData;
|
|
65
65
|
}
|
|
66
|
-
//#endregion
|
|
67
66
|
export { generateIdTokenNonce, generateState, parseState };
|
package/dist/oauth2/utils.d.mts
CHANGED
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
import { AuthContext, LiteralString } from "@better-auth/core";
|
|
2
|
-
//#region src/oauth2/utils.d.ts
|
|
3
2
|
export declare function decryptOAuthToken(token: string, ctx: AuthContext): string | Promise<string>;
|
|
4
3
|
export declare function setTokenUtil(token: string | null | undefined, ctx: AuthContext): string | Promise<string> | null | undefined;
|
|
5
4
|
export declare function getOAuthCallbackPath(provider: {
|
|
6
5
|
id: LiteralString;
|
|
7
6
|
callbackPath?: string | undefined;
|
|
8
|
-
}): string;
|
|
9
|
-
//#endregion
|
|
7
|
+
}): string;
|
package/dist/oauth2/utils.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { symmetricDecrypt, symmetricEncrypt } from "../crypto/index.mjs";
|
|
2
|
-
|
|
2
|
+
// src/oauth2/utils.ts
|
|
3
3
|
/**
|
|
4
4
|
* Check if a string looks like encrypted data
|
|
5
5
|
*/
|
|
@@ -29,5 +29,4 @@ function getOAuthCallbackPath(provider) {
|
|
|
29
29
|
if (!provider.callbackPath) return `/callback/${provider.id}`;
|
|
30
30
|
return provider.callbackPath.startsWith("/") ? provider.callbackPath : `/${provider.callbackPath}`;
|
|
31
31
|
}
|
|
32
|
-
//#endregion
|
|
33
32
|
export { decryptOAuthToken, getOAuthCallbackPath, setTokenUtil };
|
package/dist/package.mjs
CHANGED
|
@@ -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 };
|