better-auth 1.7.20 → 1.7.22
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/_virtual/_rolldown/runtime.mjs +1 -2
- package/dist/adapters/index.d.mts +0 -2
- package/dist/adapters/index.mjs +1 -2
- package/dist/api/dispatch.d.mts +1 -3
- package/dist/api/dispatch.mjs +1 -2
- package/dist/api/index.d.mts +5 -4
- package/dist/api/index.mjs +9 -9
- package/dist/api/middlewares/authorization.d.mts +1 -3
- package/dist/api/middlewares/authorization.mjs +1 -2
- package/dist/api/middlewares/origin-check.d.mts +1 -3
- package/dist/api/middlewares/origin-check.mjs +2 -3
- package/dist/api/rate-limiter/index.mjs +1 -2
- package/dist/api/routes/account.d.mts +1 -3
- package/dist/api/routes/account.mjs +10 -10
- package/dist/api/routes/callback.d.mts +1 -3
- package/dist/api/routes/callback.mjs +5 -6
- package/dist/api/routes/email-verification.d.mts +1 -3
- package/dist/api/routes/email-verification.mjs +4 -5
- package/dist/api/routes/error.d.mts +1 -3
- package/dist/api/routes/error.mjs +1 -2
- package/dist/api/routes/ok.d.mts +1 -3
- package/dist/api/routes/ok.mjs +1 -2
- package/dist/api/routes/password.d.mts +1 -3
- package/dist/api/routes/password.mjs +3 -4
- package/dist/api/routes/session.d.mts +2 -3
- package/dist/api/routes/session.mjs +10 -6
- package/dist/api/routes/sign-in.d.mts +0 -2
- package/dist/api/routes/sign-in.mjs +6 -7
- package/dist/api/routes/sign-out.d.mts +1 -3
- package/dist/api/routes/sign-out.mjs +1 -2
- package/dist/api/routes/sign-up.d.mts +1 -3
- package/dist/api/routes/sign-up.mjs +26 -16
- package/dist/api/routes/update-session.d.mts +1 -3
- package/dist/api/routes/update-session.mjs +2 -3
- package/dist/api/routes/update-user.d.mts +1 -3
- package/dist/api/routes/update-user.mjs +31 -28
- package/dist/api/state/oauth.d.mts +0 -2
- package/dist/api/state/oauth.mjs +1 -2
- package/dist/api/state/session-source.d.mts +1 -3
- package/dist/api/state/session-source.mjs +1 -2
- package/dist/api/state/should-session-refresh.d.mts +0 -2
- package/dist/api/state/should-session-refresh.mjs +1 -2
- package/dist/api/to-auth-endpoints.mjs +2 -3
- package/dist/auth/base.mjs +3 -9
- package/dist/auth/full.d.mts +1 -3
- package/dist/auth/full.mjs +1 -2
- package/dist/auth/minimal.d.mts +0 -2
- package/dist/auth/minimal.mjs +2 -3
- package/dist/auth/trusted-origins.mjs +2 -3
- package/dist/client/broadcast-channel.d.mts +1 -3
- package/dist/client/broadcast-channel.mjs +4 -4
- package/dist/client/config.d.mts +1 -3
- package/dist/client/config.mjs +2 -3
- package/dist/client/equality.d.mts +1 -3
- package/dist/client/equality.mjs +1 -2
- package/dist/client/fetch-plugins.mjs +1 -2
- package/dist/client/focus-manager.d.mts +1 -3
- package/dist/client/focus-manager.mjs +4 -4
- package/dist/client/index.d.mts +5 -7
- package/dist/client/index.mjs +1 -2
- package/dist/client/lynx/index.d.mts +1 -3
- package/dist/client/lynx/index.mjs +1 -2
- package/dist/client/lynx/lynx-store.d.mts +0 -2
- package/dist/client/lynx/lynx-store.mjs +1 -2
- package/dist/client/online-manager.d.mts +1 -3
- package/dist/client/online-manager.mjs +7 -7
- package/dist/client/parser.d.mts +0 -2
- package/dist/client/parser.mjs +1 -2
- package/dist/client/path-to-object.d.mts +0 -2
- package/dist/client/plugins/index.d.mts +6 -6
- package/dist/client/plugins/infer-plugin.d.mts +1 -3
- package/dist/client/plugins/infer-plugin.mjs +1 -2
- package/dist/client/proxy.mjs +1 -2
- package/dist/client/query-atom.mjs +1 -2
- package/dist/client/query.d.mts +1 -3
- package/dist/client/query.mjs +1 -2
- package/dist/client/react/index.d.mts +1 -3
- package/dist/client/react/index.mjs +1 -2
- package/dist/client/react/react-store.d.mts +0 -2
- package/dist/client/react/react-store.mjs +1 -2
- package/dist/client/session-atom.d.mts +1 -3
- package/dist/client/session-atom.mjs +2 -2
- package/dist/client/session-refresh.d.mts +1 -3
- package/dist/client/session-refresh.mjs +3 -3
- package/dist/client/solid/index.d.mts +1 -3
- package/dist/client/solid/index.mjs +1 -2
- package/dist/client/solid/solid-store.mjs +1 -2
- package/dist/client/svelte/index.d.mts +1 -3
- package/dist/client/svelte/index.mjs +1 -2
- package/dist/client/types.d.mts +2 -4
- package/dist/client/vanilla.d.mts +1 -3
- package/dist/client/vanilla.mjs +1 -2
- package/dist/client/vue/index.d.mts +1 -3
- package/dist/client/vue/index.mjs +1 -2
- package/dist/client/vue/vue-store.mjs +1 -2
- package/dist/context/create-context.mjs +8 -9
- package/dist/context/helpers.mjs +3 -4
- package/dist/context/init-minimal.mjs +1 -2
- package/dist/context/init.mjs +1 -2
- package/dist/context/secret-utils.mjs +1 -2
- package/dist/context/store-capabilities.mjs +1 -2
- package/dist/cookies/cache.mjs +1 -2
- package/dist/cookies/cookie-utils.d.mts +0 -2
- package/dist/cookies/cookie-utils.mjs +1 -2
- package/dist/cookies/index.d.mts +0 -2
- package/dist/cookies/index.mjs +2 -3
- package/dist/cookies/jwt.mjs +1 -2
- package/dist/cookies/session-store.d.mts +0 -2
- package/dist/cookies/session-store.mjs +1 -2
- package/dist/crypto/buffer.d.mts +1 -3
- package/dist/crypto/buffer.mjs +1 -2
- package/dist/crypto/index.d.mts +0 -2
- package/dist/crypto/index.mjs +2 -3
- package/dist/crypto/jwt.d.mts +1 -3
- package/dist/crypto/jwt.mjs +1 -2
- package/dist/crypto/password.d.mts +0 -2
- package/dist/crypto/password.mjs +1 -2
- package/dist/crypto/purpose.mjs +1 -2
- package/dist/crypto/random.d.mts +1 -3
- package/dist/crypto/random.mjs +1 -2
- package/dist/db/adapter-base.d.mts +1 -3
- package/dist/db/adapter-base.mjs +1 -2
- package/dist/db/adapter-kysely.d.mts +1 -3
- package/dist/db/adapter-kysely.mjs +1 -2
- package/dist/db/field-converter.d.mts +1 -3
- package/dist/db/field-converter.mjs +1 -2
- package/dist/db/field.d.mts +0 -2
- package/dist/db/get-migration.d.mts +1 -3
- package/dist/db/get-migration.mjs +10 -13
- package/dist/db/get-schema.d.mts +1 -3
- package/dist/db/get-schema.mjs +1 -2
- package/dist/db/index.d.mts +1 -1
- package/dist/db/index.mjs +4 -5
- package/dist/db/internal-adapter.d.mts +1 -3
- package/dist/db/internal-adapter.mjs +25 -11
- package/dist/db/revoke-unproven-account-access.d.mts +1 -3
- package/dist/db/revoke-unproven-account-access.mjs +1 -2
- package/dist/db/schema.d.mts +1 -3
- package/dist/db/schema.mjs +1 -2
- package/dist/db/to-zod.d.mts +0 -2
- package/dist/db/to-zod.mjs +1 -2
- package/dist/db/verification-token-storage.mjs +1 -2
- package/dist/db/with-hooks.d.mts +1 -3
- package/dist/db/with-hooks.mjs +1 -2
- package/dist/index.d.mts +1 -1
- package/dist/index.mjs +1 -1
- package/dist/integrations/cookie-plugin-guard.mjs +1 -2
- package/dist/integrations/next-js.d.mts +1 -3
- package/dist/integrations/next-js.mjs +2 -3
- package/dist/integrations/node.d.mts +1 -3
- package/dist/integrations/node.mjs +1 -2
- package/dist/integrations/solid-start.d.mts +1 -3
- package/dist/integrations/solid-start.mjs +1 -2
- package/dist/integrations/svelte-kit.d.mts +1 -3
- package/dist/integrations/svelte-kit.mjs +1 -2
- package/dist/integrations/tanstack-start-solid.d.mts +1 -3
- package/dist/integrations/tanstack-start-solid.mjs +1 -2
- package/dist/integrations/tanstack-start.d.mts +1 -3
- package/dist/integrations/tanstack-start.mjs +1 -2
- package/dist/oauth2/account-key.mjs +1 -2
- package/dist/oauth2/callback.mjs +1 -2
- package/dist/oauth2/errors.mjs +1 -2
- package/dist/oauth2/index.d.mts +1 -1
- package/dist/oauth2/index.mjs +1 -1
- package/dist/oauth2/link-account.d.mts +1 -3
- package/dist/oauth2/link-account.mjs +18 -13
- package/dist/oauth2/state.d.mts +1 -3
- package/dist/oauth2/state.mjs +3 -4
- package/dist/oauth2/utils.d.mts +1 -3
- package/dist/oauth2/utils.mjs +1 -2
- package/dist/package.mjs +2 -3
- package/dist/plugins/access/access.d.mts +1 -3
- package/dist/plugins/access/access.mjs +1 -2
- package/dist/plugins/access/index.d.mts +1 -1
- package/dist/plugins/access/types.d.mts +1 -3
- package/dist/plugins/additional-fields/client.d.mts +1 -3
- package/dist/plugins/additional-fields/client.mjs +1 -2
- package/dist/plugins/admin/access/statement.d.mts +1 -3
- package/dist/plugins/admin/access/statement.mjs +1 -2
- package/dist/plugins/admin/admin.d.mts +1 -3
- package/dist/plugins/admin/admin.mjs +2 -3
- package/dist/plugins/admin/client.d.mts +2 -4
- package/dist/plugins/admin/client.mjs +1 -2
- package/dist/plugins/admin/error-codes.d.mts +1 -3
- package/dist/plugins/admin/error-codes.mjs +1 -2
- package/dist/plugins/admin/has-permission.mjs +1 -2
- package/dist/plugins/admin/index.d.mts +1 -1
- package/dist/plugins/admin/routes.mjs +3 -4
- package/dist/plugins/admin/schema.d.mts +1 -3
- package/dist/plugins/admin/schema.mjs +1 -2
- package/dist/plugins/admin/types.d.mts +1 -3
- package/dist/plugins/anonymous/client.d.mts +1 -3
- package/dist/plugins/anonymous/client.mjs +1 -2
- package/dist/plugins/anonymous/error-codes.d.mts +1 -3
- package/dist/plugins/anonymous/error-codes.mjs +1 -2
- package/dist/plugins/anonymous/index.d.mts +0 -2
- package/dist/plugins/anonymous/index.mjs +3 -4
- package/dist/plugins/anonymous/schema.d.mts +1 -3
- package/dist/plugins/anonymous/schema.mjs +1 -2
- package/dist/plugins/anonymous/types.d.mts +1 -3
- package/dist/plugins/bearer/index.d.mts +1 -3
- package/dist/plugins/bearer/index.mjs +1 -2
- package/dist/plugins/captcha/constants.d.mts +1 -3
- package/dist/plugins/captcha/constants.mjs +1 -2
- package/dist/plugins/captcha/error-codes.mjs +1 -2
- package/dist/plugins/captcha/index.d.mts +0 -2
- package/dist/plugins/captcha/index.mjs +2 -3
- package/dist/plugins/captcha/types.d.mts +1 -3
- package/dist/plugins/captcha/utils.mjs +1 -2
- package/dist/plugins/captcha/verify-handlers/captchafox.mjs +1 -2
- package/dist/plugins/captcha/verify-handlers/cloudflare-turnstile.mjs +1 -2
- package/dist/plugins/captcha/verify-handlers/google-recaptcha.mjs +1 -2
- package/dist/plugins/captcha/verify-handlers/h-captcha.mjs +1 -2
- package/dist/plugins/captcha/verify-handlers/vercel-botid.mjs +1 -2
- package/dist/plugins/custom-session/client.d.mts +1 -3
- package/dist/plugins/custom-session/client.mjs +1 -2
- package/dist/plugins/custom-session/index.d.mts +1 -3
- package/dist/plugins/custom-session/index.mjs +3 -4
- package/dist/plugins/device-authorization/client.d.mts +1 -3
- package/dist/plugins/device-authorization/client.mjs +1 -2
- package/dist/plugins/device-authorization/error-codes.mjs +1 -2
- package/dist/plugins/device-authorization/index.d.mts +1 -3
- package/dist/plugins/device-authorization/index.mjs +2 -3
- package/dist/plugins/device-authorization/routes.d.mts +4 -6
- package/dist/plugins/device-authorization/routes.mjs +18 -4
- package/dist/plugins/device-authorization/schema.d.mts +0 -2
- package/dist/plugins/device-authorization/schema.mjs +1 -2
- package/dist/plugins/email-otp/client.d.mts +0 -2
- package/dist/plugins/email-otp/client.mjs +1 -2
- package/dist/plugins/email-otp/error-codes.d.mts +1 -3
- package/dist/plugins/email-otp/error-codes.mjs +1 -2
- package/dist/plugins/email-otp/index.d.mts +0 -2
- package/dist/plugins/email-otp/index.mjs +4 -5
- package/dist/plugins/email-otp/otp-token.mjs +3 -4
- package/dist/plugins/email-otp/routes.mjs +6 -7
- package/dist/plugins/email-otp/types.d.mts +1 -3
- package/dist/plugins/email-otp/utils.mjs +1 -2
- package/dist/plugins/generic-oauth/error-codes.mjs +1 -2
- package/dist/plugins/generic-oauth/index.d.mts +1 -6
- package/dist/plugins/generic-oauth/index.mjs +43 -30
- package/dist/plugins/generic-oauth/providers/auth0.d.mts +1 -3
- package/dist/plugins/generic-oauth/providers/auth0.mjs +1 -2
- package/dist/plugins/generic-oauth/providers/gumroad.d.mts +1 -3
- package/dist/plugins/generic-oauth/providers/gumroad.mjs +1 -2
- package/dist/plugins/generic-oauth/providers/hubspot.d.mts +1 -3
- package/dist/plugins/generic-oauth/providers/hubspot.mjs +1 -2
- package/dist/plugins/generic-oauth/providers/keycloak.d.mts +1 -3
- package/dist/plugins/generic-oauth/providers/keycloak.mjs +1 -2
- package/dist/plugins/generic-oauth/providers/line.d.mts +1 -3
- package/dist/plugins/generic-oauth/providers/line.mjs +1 -2
- package/dist/plugins/generic-oauth/providers/microsoft-entra-id.d.mts +1 -3
- package/dist/plugins/generic-oauth/providers/microsoft-entra-id.mjs +1 -2
- package/dist/plugins/generic-oauth/providers/okta.d.mts +1 -3
- package/dist/plugins/generic-oauth/providers/okta.mjs +1 -2
- package/dist/plugins/generic-oauth/providers/patreon.d.mts +1 -3
- package/dist/plugins/generic-oauth/providers/patreon.mjs +1 -2
- package/dist/plugins/generic-oauth/providers/slack.d.mts +1 -3
- package/dist/plugins/generic-oauth/providers/slack.mjs +1 -2
- package/dist/plugins/generic-oauth/providers/yandex.d.mts +1 -3
- package/dist/plugins/generic-oauth/providers/yandex.mjs +1 -2
- package/dist/plugins/generic-oauth/types.d.mts +6 -5
- package/dist/plugins/haveibeenpwned/index.d.mts +1 -3
- package/dist/plugins/haveibeenpwned/index.mjs +2 -3
- package/dist/plugins/index.d.mts +5 -5
- package/dist/plugins/jwt/adapter.mjs +1 -2
- package/dist/plugins/jwt/client.d.mts +1 -3
- package/dist/plugins/jwt/client.mjs +1 -2
- package/dist/plugins/jwt/cookie-cache.mjs +1 -2
- package/dist/plugins/jwt/index.d.mts +1 -3
- package/dist/plugins/jwt/index.mjs +5 -6
- package/dist/plugins/jwt/schema.d.mts +1 -3
- package/dist/plugins/jwt/schema.mjs +1 -2
- package/dist/plugins/jwt/sign.d.mts +0 -2
- package/dist/plugins/jwt/sign.mjs +1 -2
- package/dist/plugins/jwt/types.d.mts +1 -3
- package/dist/plugins/jwt/utils.d.mts +1 -3
- package/dist/plugins/jwt/utils.mjs +2 -3
- package/dist/plugins/jwt/verify.d.mts +1 -3
- package/dist/plugins/jwt/verify.mjs +1 -2
- package/dist/plugins/last-login-method/client.d.mts +1 -3
- package/dist/plugins/last-login-method/client.mjs +1 -2
- package/dist/plugins/last-login-method/index.d.mts +1 -3
- package/dist/plugins/last-login-method/index.mjs +1 -2
- package/dist/plugins/magic-link/client.d.mts +1 -3
- package/dist/plugins/magic-link/client.mjs +1 -2
- package/dist/plugins/magic-link/index.d.mts +1 -3
- package/dist/plugins/magic-link/index.mjs +4 -5
- package/dist/plugins/magic-link/utils.mjs +1 -2
- package/dist/plugins/multi-session/client.d.mts +0 -2
- package/dist/plugins/multi-session/client.mjs +1 -2
- package/dist/plugins/multi-session/error-codes.d.mts +1 -3
- package/dist/plugins/multi-session/error-codes.mjs +1 -2
- package/dist/plugins/multi-session/index.d.mts +0 -2
- package/dist/plugins/multi-session/index.mjs +3 -4
- package/dist/plugins/oauth-popup/client.d.mts +0 -2
- package/dist/plugins/oauth-popup/client.mjs +1 -2
- package/dist/plugins/oauth-popup/constants.d.mts +1 -3
- package/dist/plugins/oauth-popup/constants.mjs +1 -2
- package/dist/plugins/oauth-popup/error-codes.d.mts +1 -3
- package/dist/plugins/oauth-popup/error-codes.mjs +1 -2
- package/dist/plugins/oauth-popup/index.d.mts +0 -2
- package/dist/plugins/oauth-popup/index.mjs +5 -6
- package/dist/plugins/oauth-popup/types.d.mts +1 -3
- package/dist/plugins/oauth-proxy/index.d.mts +1 -3
- package/dist/plugins/oauth-proxy/index.mjs +7 -8
- package/dist/plugins/oauth-proxy/utils.mjs +1 -2
- package/dist/plugins/one-tap/client.d.mts +1 -3
- package/dist/plugins/one-tap/client.mjs +1 -2
- package/dist/plugins/one-tap/index.d.mts +1 -3
- package/dist/plugins/one-tap/index.mjs +7 -8
- package/dist/plugins/one-time-token/client.d.mts +0 -2
- package/dist/plugins/one-time-token/client.mjs +1 -2
- package/dist/plugins/one-time-token/index.d.mts +1 -3
- package/dist/plugins/one-time-token/index.mjs +3 -4
- package/dist/plugins/one-time-token/utils.mjs +1 -2
- package/dist/plugins/open-api/generator.d.mts +0 -2
- package/dist/plugins/open-api/generator.mjs +2 -3
- package/dist/plugins/open-api/index.d.mts +0 -2
- package/dist/plugins/open-api/index.mjs +2 -3
- package/dist/plugins/open-api/logo.mjs +1 -2
- package/dist/plugins/organization/access/statement.d.mts +1 -3
- package/dist/plugins/organization/access/statement.mjs +1 -2
- package/dist/plugins/organization/adapter.d.mts +3 -5
- package/dist/plugins/organization/adapter.mjs +2 -3
- package/dist/plugins/organization/call.mjs +1 -2
- package/dist/plugins/organization/client.d.mts +9 -11
- package/dist/plugins/organization/client.mjs +2 -3
- package/dist/plugins/organization/error-codes.d.mts +1 -3
- package/dist/plugins/organization/error-codes.mjs +1 -2
- package/dist/plugins/organization/has-permission.d.mts +1 -3
- package/dist/plugins/organization/has-permission.mjs +2 -3
- package/dist/plugins/organization/index.d.mts +3 -3
- package/dist/plugins/organization/organization.d.mts +3 -5
- package/dist/plugins/organization/organization.mjs +3 -4
- package/dist/plugins/organization/permission.d.mts +1 -3
- package/dist/plugins/organization/permission.mjs +1 -2
- package/dist/plugins/organization/roles.d.mts +1 -3
- package/dist/plugins/organization/roles.mjs +1 -2
- package/dist/plugins/organization/routes/crud-access-control.d.mts +2 -4
- package/dist/plugins/organization/routes/crud-access-control.mjs +3 -4
- package/dist/plugins/organization/routes/crud-invites.d.mts +4 -6
- package/dist/plugins/organization/routes/crud-invites.mjs +5 -6
- package/dist/plugins/organization/routes/crud-members.d.mts +4 -6
- package/dist/plugins/organization/routes/crud-members.mjs +4 -5
- package/dist/plugins/organization/routes/crud-org.d.mts +4 -6
- package/dist/plugins/organization/routes/crud-org.mjs +8 -9
- package/dist/plugins/organization/routes/crud-team.d.mts +4 -6
- package/dist/plugins/organization/routes/crud-team.mjs +3 -4
- package/dist/plugins/organization/schema.d.mts +0 -2
- package/dist/plugins/organization/schema.mjs +1 -2
- package/dist/plugins/organization/types.d.mts +1 -3
- package/dist/plugins/phone-number/client.d.mts +1 -3
- package/dist/plugins/phone-number/client.mjs +1 -2
- package/dist/plugins/phone-number/error-codes.d.mts +1 -3
- package/dist/plugins/phone-number/error-codes.mjs +1 -2
- package/dist/plugins/phone-number/index.d.mts +0 -2
- package/dist/plugins/phone-number/index.mjs +1 -2
- package/dist/plugins/phone-number/routes.mjs +6 -7
- package/dist/plugins/phone-number/schema.d.mts +1 -3
- package/dist/plugins/phone-number/schema.mjs +1 -2
- package/dist/plugins/phone-number/types.d.mts +2 -4
- package/dist/plugins/siwe/client.d.mts +1 -3
- package/dist/plugins/siwe/client.mjs +1 -2
- package/dist/plugins/siwe/index.d.mts +1 -3
- package/dist/plugins/siwe/index.mjs +6 -7
- package/dist/plugins/siwe/parse-message.mjs +1 -2
- package/dist/plugins/siwe/schema.d.mts +1 -3
- package/dist/plugins/siwe/schema.mjs +1 -2
- package/dist/plugins/siwe/types.d.mts +0 -2
- package/dist/plugins/test-utils/auth-helpers.mjs +1 -2
- package/dist/plugins/test-utils/cookie-builder.mjs +1 -2
- package/dist/plugins/test-utils/db-helpers.mjs +1 -2
- package/dist/plugins/test-utils/factories.mjs +1 -2
- package/dist/plugins/test-utils/index.d.mts +0 -2
- package/dist/plugins/test-utils/index.mjs +2 -3
- package/dist/plugins/test-utils/otp-sink.mjs +1 -2
- package/dist/plugins/test-utils/types.d.mts +1 -3
- package/dist/plugins/two-factor/backup-codes/index.d.mts +1 -3
- package/dist/plugins/two-factor/backup-codes/index.mjs +4 -5
- package/dist/plugins/two-factor/client.d.mts +2 -4
- package/dist/plugins/two-factor/client.mjs +1 -2
- package/dist/plugins/two-factor/constant.mjs +1 -2
- package/dist/plugins/two-factor/error-code.d.mts +1 -3
- package/dist/plugins/two-factor/error-code.mjs +1 -2
- package/dist/plugins/two-factor/index.d.mts +0 -2
- package/dist/plugins/two-factor/index.mjs +9 -10
- package/dist/plugins/two-factor/otp/index.d.mts +1 -3
- package/dist/plugins/two-factor/otp/index.mjs +4 -5
- package/dist/plugins/two-factor/schema.d.mts +1 -3
- package/dist/plugins/two-factor/schema.mjs +1 -2
- package/dist/plugins/two-factor/totp/index.d.mts +1 -3
- package/dist/plugins/two-factor/totp/index.mjs +3 -4
- package/dist/plugins/two-factor/types.d.mts +1 -3
- package/dist/plugins/two-factor/utils.mjs +1 -2
- package/dist/plugins/two-factor/verify-two-factor.mjs +5 -6
- package/dist/plugins/username/client.d.mts +0 -2
- package/dist/plugins/username/client.mjs +1 -2
- package/dist/plugins/username/error-codes.d.mts +1 -3
- package/dist/plugins/username/error-codes.mjs +1 -2
- package/dist/plugins/username/index.d.mts +0 -2
- package/dist/plugins/username/index.mjs +4 -5
- package/dist/plugins/username/schema.d.mts +1 -3
- package/dist/plugins/username/schema.mjs +1 -2
- package/dist/state.d.mts +2 -7
- package/dist/state.mjs +3 -7
- package/dist/test-utils/headers.d.mts +1 -3
- package/dist/test-utils/headers.mjs +1 -2
- package/dist/test-utils/http-test-instance.d.mts +0 -2
- package/dist/test-utils/http-test-instance.mjs +1 -2
- package/dist/test-utils/index.d.mts +1 -1
- package/dist/test-utils/index.mjs +1 -1
- package/dist/test-utils/test-instance.d.mts +4 -6
- package/dist/test-utils/test-instance.mjs +5 -6
- package/dist/types/api.d.mts +1 -3
- package/dist/types/auth.d.mts +2 -4
- package/dist/types/helper.d.mts +1 -3
- package/dist/types/index.d.mts +2 -2
- package/dist/types/models.d.mts +0 -2
- package/dist/types/plugins.d.mts +0 -2
- package/dist/utils/constants.mjs +1 -2
- package/dist/utils/date.mjs +1 -2
- package/dist/utils/hashing.mjs +1 -2
- package/dist/utils/hide-metadata.d.mts +2 -5
- package/dist/utils/hide-metadata.mjs +1 -4
- package/dist/utils/index.d.mts +1 -1
- package/dist/utils/is-atom.mjs +1 -2
- package/dist/utils/is-promise.mjs +1 -2
- package/dist/utils/middleware-response.mjs +1 -2
- package/dist/utils/password.mjs +1 -2
- package/dist/utils/plugin-helper.mjs +1 -2
- package/dist/utils/request.mjs +1 -2
- package/dist/utils/shim.mjs +1 -2
- package/dist/utils/time.d.mts +0 -2
- package/dist/utils/time.mjs +1 -2
- package/dist/utils/url.d.mts +1 -3
- package/dist/utils/url.mjs +1 -2
- package/dist/utils/validate-user-info.mjs +1 -2
- package/dist/utils/wildcard.mjs +1 -2
- package/dist/version.mjs +1 -2
- package/package.json +10 -10
- package/dist/utils/boolean.mjs +0 -6
|
@@ -1,5 +1,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 };
|
|
@@ -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 { withTimeout } from "../utils.mjs";
|
|
5
|
-
|
|
5
|
+
// src/plugins/captcha/verify-handlers/vercel-botid.ts
|
|
6
6
|
const vercelBotId = async ({ request, checkBotId, validateRequest }) => {
|
|
7
7
|
let isValid;
|
|
8
8
|
try {
|
|
@@ -23,5 +23,4 @@ const vercelBotId = async ({ request, checkBotId, validateRequest }) => {
|
|
|
23
23
|
status: 403
|
|
24
24
|
});
|
|
25
25
|
};
|
|
26
|
-
//#endregion
|
|
27
26
|
export { vercelBotId };
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { BetterAuthOptions } from "../../types/index.mjs";
|
|
2
2
|
import { Auth } from "better-auth";
|
|
3
|
-
//#region src/plugins/custom-session/client.d.ts
|
|
4
3
|
export declare const customSessionClient: <A extends Auth | {
|
|
5
4
|
options: BetterAuthOptions;
|
|
6
5
|
}>() => {
|
|
@@ -11,5 +10,4 @@ export declare const customSessionClient: <A extends Auth | {
|
|
|
11
10
|
} ? O : A)["plugins"] extends (infer P)[] ? P extends {
|
|
12
11
|
id: "custom-session";
|
|
13
12
|
} ? P : never : never;
|
|
14
|
-
};
|
|
15
|
-
//#endregion
|
|
13
|
+
};
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { InferServerPlugin } from "../../client/plugins/infer-plugin.mjs";
|
|
2
|
-
|
|
2
|
+
// src/plugins/custom-session/client.ts
|
|
3
3
|
const customSessionClient = () => {
|
|
4
4
|
return InferServerPlugin();
|
|
5
5
|
};
|
|
6
|
-
//#endregion
|
|
7
6
|
export { customSessionClient };
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { BetterAuthOptions, GenericEndpointContext } from "@better-auth/core";
|
|
2
2
|
import { Session, User } from "@better-auth/core/db";
|
|
3
|
-
//#region src/plugins/custom-session/index.d.ts
|
|
4
3
|
declare module "@better-auth/core" {
|
|
5
4
|
interface BetterAuthPluginRegistry<AuthOptions, Options> {
|
|
6
5
|
"custom-session": {
|
|
@@ -63,5 +62,4 @@ export declare const customSession: <Returns extends Record<string, any>, O exte
|
|
|
63
62
|
Session: Awaited<ReturnType<typeof fn>>;
|
|
64
63
|
};
|
|
65
64
|
options: CustomSessionPluginOptions | undefined;
|
|
66
|
-
};
|
|
67
|
-
//#endregion
|
|
65
|
+
};
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
+
import { getSession } from "../../api/routes/session.mjs";
|
|
1
2
|
import { parseSetCookieHeader, toCookieOptions } from "../../cookies/cookie-utils.mjs";
|
|
2
3
|
import { getSessionQuerySchema } from "../../cookies/session-store.mjs";
|
|
3
|
-
import { getSession } from "../../api/routes/session.mjs";
|
|
4
|
-
import { PACKAGE_VERSION } from "../../version.mjs";
|
|
5
4
|
import { getEndpointResponse } from "../../utils/plugin-helper.mjs";
|
|
5
|
+
import { PACKAGE_VERSION } from "../../version.mjs";
|
|
6
6
|
import { createAuthEndpoint, createAuthMiddleware } from "@better-auth/core/api";
|
|
7
|
-
|
|
7
|
+
// src/plugins/custom-session/index.ts
|
|
8
8
|
const customSession = (fn, options, pluginOptions) => {
|
|
9
9
|
return {
|
|
10
10
|
id: "custom-session",
|
|
@@ -54,5 +54,4 @@ const customSession = (fn, options, pluginOptions) => {
|
|
|
54
54
|
options: pluginOptions
|
|
55
55
|
};
|
|
56
56
|
};
|
|
57
|
-
//#endregion
|
|
58
57
|
export { customSession };
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { DeviceAuthorizationGrant, deviceAuthorization } from "./index.mjs";
|
|
2
|
-
//#region src/plugins/device-authorization/client.d.ts
|
|
3
2
|
export declare const deviceAuthorizationClient: <Grant extends DeviceAuthorizationGrant | undefined = undefined>() => {
|
|
4
3
|
id: "device-authorization";
|
|
5
4
|
version: string;
|
|
@@ -11,5 +10,4 @@ export declare const deviceAuthorizationClient: <Grant extends DeviceAuthorizati
|
|
|
11
10
|
"/device/approve": "POST";
|
|
12
11
|
"/device/deny": "POST";
|
|
13
12
|
};
|
|
14
|
-
};
|
|
15
|
-
//#endregion
|
|
13
|
+
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { PACKAGE_VERSION } from "../../version.mjs";
|
|
2
|
-
|
|
2
|
+
// src/plugins/device-authorization/client.ts
|
|
3
3
|
const deviceAuthorizationClient = () => {
|
|
4
4
|
return {
|
|
5
5
|
id: "device-authorization",
|
|
@@ -14,5 +14,4 @@ const deviceAuthorizationClient = () => {
|
|
|
14
14
|
}
|
|
15
15
|
};
|
|
16
16
|
};
|
|
17
|
-
//#endregion
|
|
18
17
|
export { deviceAuthorizationClient };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { defineErrorCodes } from "@better-auth/core/utils/error-codes";
|
|
2
|
-
|
|
2
|
+
// src/plugins/device-authorization/error-codes.ts
|
|
3
3
|
const DEVICE_AUTHORIZATION_ERROR_CODES = defineErrorCodes({
|
|
4
4
|
INVALID_DEVICE_CODE: "Invalid device code",
|
|
5
5
|
EXPIRED_DEVICE_CODE: "Device code has expired",
|
|
@@ -15,5 +15,4 @@ const DEVICE_AUTHORIZATION_ERROR_CODES = defineErrorCodes({
|
|
|
15
15
|
INVALID_DEVICE_CODE_STATUS: "Invalid device code status",
|
|
16
16
|
AUTHENTICATION_REQUIRED: "Authentication required"
|
|
17
17
|
});
|
|
18
|
-
//#endregion
|
|
19
18
|
export { DEVICE_AUTHORIZATION_ERROR_CODES };
|
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
import { TimeString, ms, sec } from "../../utils/time.mjs";
|
|
2
|
-
import { DeviceCode } from "./schema.mjs";
|
|
3
2
|
import { DeviceCodeRedemptionAuthorization, DeviceCodeRedemptionResult, redeemDeviceCode } from "./routes.mjs";
|
|
3
|
+
import { DeviceCode } from "./schema.mjs";
|
|
4
4
|
import { GenericEndpointContext, StandardSchemaV1 } from "@better-auth/core";
|
|
5
5
|
import { DBFieldAttribute } from "@better-auth/core/db";
|
|
6
6
|
import * as z from "zod";
|
|
7
|
-
//#region src/plugins/device-authorization/index.d.ts
|
|
8
7
|
declare module "@better-auth/core" {
|
|
9
8
|
interface BetterAuthPluginRegistry<AuthOptions, Options> {
|
|
10
9
|
"device-authorization": {
|
|
@@ -550,5 +549,4 @@ export declare const deviceAuthorization: <Grant extends DeviceAuthorizationGran
|
|
|
550
549
|
} | undefined;
|
|
551
550
|
};
|
|
552
551
|
};
|
|
553
|
-
//#endregion
|
|
554
552
|
export { type DeviceCode, type DeviceCodeRedemptionAuthorization, type DeviceCodeRedemptionResult, type TimeString, type ms, redeemDeviceCode, type sec };
|
|
@@ -2,11 +2,11 @@ import { mergeSchema } from "../../db/schema.mjs";
|
|
|
2
2
|
import { ms } from "../../utils/time.mjs";
|
|
3
3
|
import { PACKAGE_VERSION } from "../../version.mjs";
|
|
4
4
|
import { DEVICE_AUTHORIZATION_ERROR_CODES } from "./error-codes.mjs";
|
|
5
|
-
import { schema } from "./schema.mjs";
|
|
6
5
|
import { deviceApprove, deviceCode, deviceDeny, deviceToken, deviceVerify, redeemDeviceCode } from "./routes.mjs";
|
|
6
|
+
import { schema } from "./schema.mjs";
|
|
7
7
|
import { BetterAuthError } from "@better-auth/core/error";
|
|
8
8
|
import * as z from "zod";
|
|
9
|
-
|
|
9
|
+
// src/plugins/device-authorization/index.ts
|
|
10
10
|
const timeStringSchema = z.custom((val) => {
|
|
11
11
|
if (typeof val !== "string") return false;
|
|
12
12
|
try {
|
|
@@ -84,5 +84,4 @@ const deviceAuthorization = (options = {}) => {
|
|
|
84
84
|
}
|
|
85
85
|
};
|
|
86
86
|
};
|
|
87
|
-
//#endregion
|
|
88
87
|
export { deviceAuthorization, deviceAuthorizationOptionsSchema, redeemDeviceCode };
|
|
@@ -1,11 +1,10 @@
|
|
|
1
|
-
import { Where } from "../../types/adapter.mjs";
|
|
2
|
-
import { User } from "../../types/models.mjs";
|
|
3
1
|
import "../../types/index.mjs";
|
|
4
|
-
import {
|
|
2
|
+
import { User } from "../../types/models.mjs";
|
|
3
|
+
import { Where } from "../../types/adapter.mjs";
|
|
5
4
|
import "./index.mjs";
|
|
5
|
+
import { DeviceCode } from "./schema.mjs";
|
|
6
6
|
import { GenericEndpointContext } from "@better-auth/core";
|
|
7
7
|
import "zod";
|
|
8
|
-
//#region src/plugins/device-authorization/routes.d.ts
|
|
9
8
|
export interface DeviceCodeRedemptionAuthorization<AuthorizationContext> {
|
|
10
9
|
/** Additional ownership predicate used by the atomic claim. */
|
|
11
10
|
ownershipWhere: Where;
|
|
@@ -30,5 +29,4 @@ export declare function redeemDeviceCode<DeviceCodeFields extends Record<string,
|
|
|
30
29
|
deviceCode: string;
|
|
31
30
|
authorizeRedemption: (deviceCode: DeviceCode & DeviceCodeFields) => DeviceCodeRedemptionAuthorization<AuthorizationContext> | Promise<DeviceCodeRedemptionAuthorization<AuthorizationContext>>;
|
|
32
31
|
prepareRedemption: (deviceCode: DeviceCode & DeviceCodeFields, authorizationContext: AuthorizationContext) => RedemptionContext | Promise<RedemptionContext>;
|
|
33
|
-
}): Promise<DeviceCodeRedemptionResult<DeviceCodeFields, AuthorizationContext, RedemptionContext>>;
|
|
34
|
-
//#endregion
|
|
32
|
+
}): Promise<DeviceCodeRedemptionResult<DeviceCodeFields, AuthorizationContext, RedemptionContext>>;
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { ms } from "../../utils/time.mjs";
|
|
2
|
-
import { generateRandomString } from "../../crypto/random.mjs";
|
|
3
1
|
import { getAuthoritativeSessionFromCtx } from "../../api/routes/session.mjs";
|
|
2
|
+
import { generateRandomString } from "../../crypto/random.mjs";
|
|
3
|
+
import { ms } from "../../utils/time.mjs";
|
|
4
4
|
import { DEVICE_AUTHORIZATION_ERROR_CODES } from "./error-codes.mjs";
|
|
5
5
|
import { APIError } from "@better-auth/core/error";
|
|
6
6
|
import { createAuthEndpoint } from "@better-auth/core/api";
|
|
7
7
|
import * as z from "zod";
|
|
8
|
-
|
|
8
|
+
// src/plugins/device-authorization/routes.ts
|
|
9
9
|
const defaultCharset = "ABCDEFGHJKLMNPQRSTUVWXYZ23456789";
|
|
10
10
|
const MAX_DEVICE_CODE_GENERATION_ATTEMPTS = 3;
|
|
11
11
|
const UNIQUE_CONSTRAINT_ERROR_IDENTIFIERS = /* @__PURE__ */ new Set([
|
|
@@ -550,6 +550,21 @@ const deviceVerify = (grant) => createAuthEndpoint("/device", {
|
|
|
550
550
|
increment: {},
|
|
551
551
|
set: { userId: session.user.id }
|
|
552
552
|
})) deviceCodeRecord.userId = session.user.id;
|
|
553
|
+
else {
|
|
554
|
+
const current = await ctx.context.adapter.findOne({
|
|
555
|
+
model: "deviceCode",
|
|
556
|
+
where: [{
|
|
557
|
+
field: "id",
|
|
558
|
+
value: deviceCodeRecord.id
|
|
559
|
+
}]
|
|
560
|
+
});
|
|
561
|
+
if (!current) throw new APIError("BAD_REQUEST", {
|
|
562
|
+
error: "invalid_request",
|
|
563
|
+
error_description: DEVICE_AUTHORIZATION_ERROR_CODES.INVALID_USER_CODE.message
|
|
564
|
+
});
|
|
565
|
+
deviceCodeRecord.userId = current.userId;
|
|
566
|
+
deviceCodeRecord.status = current.status;
|
|
567
|
+
}
|
|
553
568
|
}
|
|
554
569
|
const canReviewRequest = session?.user.id !== void 0 && deviceCodeRecord.userId === session.user.id;
|
|
555
570
|
const grantContext = canReviewRequest ? grant?.getVerificationContext(deviceCodeRecord) : void 0;
|
|
@@ -724,5 +739,4 @@ const defaultGenerateUserCode = (length) => {
|
|
|
724
739
|
const chars = new Uint8Array(length);
|
|
725
740
|
return Array.from(crypto.getRandomValues(chars)).map((byte) => defaultCharset[byte % 32]).join("");
|
|
726
741
|
};
|
|
727
|
-
//#endregion
|
|
728
742
|
export { deviceApprove, deviceCode, deviceDeny, deviceToken, deviceVerify, redeemDeviceCode };
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import * as z from "zod";
|
|
2
|
-
//#region src/plugins/device-authorization/schema.d.ts
|
|
3
2
|
declare const deviceCode: z.ZodObject<{
|
|
4
3
|
id: z.ZodString;
|
|
5
4
|
deviceCode: z.ZodString;
|
|
@@ -13,5 +12,4 @@ declare const deviceCode: z.ZodObject<{
|
|
|
13
12
|
scope: z.ZodOptional<z.ZodString>;
|
|
14
13
|
}, z.core.$strip>;
|
|
15
14
|
export type DeviceCode = z.infer<typeof deviceCode>;
|
|
16
|
-
//#endregion
|
|
17
15
|
export {};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as z from "zod";
|
|
2
|
-
|
|
2
|
+
// src/plugins/device-authorization/schema.ts
|
|
3
3
|
const schema = { deviceCode: {
|
|
4
4
|
fields: {
|
|
5
5
|
deviceCode: {
|
|
@@ -59,5 +59,4 @@ z.object({
|
|
|
59
59
|
clientId: z.string().optional(),
|
|
60
60
|
scope: z.string().optional()
|
|
61
61
|
});
|
|
62
|
-
//#endregion
|
|
63
62
|
export { schema };
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { emailOTP } from "./index.mjs";
|
|
2
2
|
import { EMAIL_OTP_ERROR_CODES } from "./error-codes.mjs";
|
|
3
|
-
//#region src/plugins/email-otp/client.d.ts
|
|
4
3
|
export declare const emailOTPClient: () => {
|
|
5
4
|
id: "email-otp";
|
|
6
5
|
version: string;
|
|
@@ -15,5 +14,4 @@ export declare const emailOTPClient: () => {
|
|
|
15
14
|
TOO_MANY_ATTEMPTS: import("@better-auth/core/utils/error-codes").RawError<"TOO_MANY_ATTEMPTS">;
|
|
16
15
|
};
|
|
17
16
|
};
|
|
18
|
-
//#endregion
|
|
19
17
|
export { EMAIL_OTP_ERROR_CODES };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { PACKAGE_VERSION } from "../../version.mjs";
|
|
2
2
|
import { EMAIL_OTP_ERROR_CODES } from "./error-codes.mjs";
|
|
3
|
-
|
|
3
|
+
// src/plugins/email-otp/client.ts
|
|
4
4
|
const emailOTPClient = () => {
|
|
5
5
|
return {
|
|
6
6
|
id: "email-otp",
|
|
@@ -13,5 +13,4 @@ const emailOTPClient = () => {
|
|
|
13
13
|
$ERROR_CODES: EMAIL_OTP_ERROR_CODES
|
|
14
14
|
};
|
|
15
15
|
};
|
|
16
|
-
//#endregion
|
|
17
16
|
export { EMAIL_OTP_ERROR_CODES, emailOTPClient };
|
|
@@ -1,7 +1,5 @@
|
|
|
1
|
-
//#region src/plugins/email-otp/error-codes.d.ts
|
|
2
1
|
export declare const EMAIL_OTP_ERROR_CODES: {
|
|
3
2
|
OTP_EXPIRED: import("@better-auth/core/utils/error-codes").RawError<"OTP_EXPIRED">;
|
|
4
3
|
INVALID_OTP: import("@better-auth/core/utils/error-codes").RawError<"INVALID_OTP">;
|
|
5
4
|
TOO_MANY_ATTEMPTS: import("@better-auth/core/utils/error-codes").RawError<"TOO_MANY_ATTEMPTS">;
|
|
6
|
-
};
|
|
7
|
-
//#endregion
|
|
5
|
+
};
|
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
import { defineErrorCodes } from "@better-auth/core/utils/error-codes";
|
|
2
|
-
|
|
2
|
+
// src/plugins/email-otp/error-codes.ts
|
|
3
3
|
const EMAIL_OTP_ERROR_CODES = defineErrorCodes({
|
|
4
4
|
OTP_EXPIRED: "OTP expired",
|
|
5
5
|
INVALID_OTP: "Invalid OTP",
|
|
6
6
|
TOO_MANY_ATTEMPTS: "Too many attempts"
|
|
7
7
|
});
|
|
8
|
-
//#endregion
|
|
9
8
|
export { EMAIL_OTP_ERROR_CODES };
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { EmailOTPOptions } from "./types.mjs";
|
|
2
|
-
//#region src/plugins/email-otp/index.d.ts
|
|
3
2
|
declare module "@better-auth/core" {
|
|
4
3
|
interface BetterAuthPluginRegistry<AuthOptions, Options> {
|
|
5
4
|
"email-otp": {
|
|
@@ -540,5 +539,4 @@ export declare const emailOTP: (options: EmailOTPOptions) => {
|
|
|
540
539
|
TOO_MANY_ATTEMPTS: import("@better-auth/core/utils/error-codes").RawError<"TOO_MANY_ATTEMPTS">;
|
|
541
540
|
};
|
|
542
541
|
};
|
|
543
|
-
//#endregion
|
|
544
542
|
export type { EmailOTPOptions };
|
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import { getDate } from "../../utils/date.mjs";
|
|
2
1
|
import { generateRandomString } from "../../crypto/random.mjs";
|
|
2
|
+
import { getDate } from "../../utils/date.mjs";
|
|
3
|
+
import { getEndpointResponse } from "../../utils/plugin-helper.mjs";
|
|
3
4
|
import { PACKAGE_VERSION } from "../../version.mjs";
|
|
4
5
|
import { EMAIL_OTP_ERROR_CODES } from "./error-codes.mjs";
|
|
5
|
-
import { getEndpointResponse } from "../../utils/plugin-helper.mjs";
|
|
6
|
-
import { toOTPIdentifier } from "./utils.mjs";
|
|
7
6
|
import { storeOTP } from "./otp-token.mjs";
|
|
8
7
|
import { changeEmailEmailOTP, checkVerificationOTP, createVerificationOTP, forgetPasswordEmailOTP, getVerificationOTP, requestEmailChangeEmailOTP, requestPasswordResetEmailOTP, resetPasswordEmailOTP, sendVerificationOTP, signInEmailOTP, verifyEmailOTP } from "./routes.mjs";
|
|
8
|
+
import { toOTPIdentifier } from "./utils.mjs";
|
|
9
9
|
import { createAuthMiddleware } from "@better-auth/core/api";
|
|
10
|
-
|
|
10
|
+
// src/plugins/email-otp/index.ts
|
|
11
11
|
const defaultOTPGenerator = (options) => generateRandomString(options.otpLength ?? 6, "0-9");
|
|
12
12
|
const emailOTP = (options) => {
|
|
13
13
|
const opts = {
|
|
@@ -141,5 +141,4 @@ const emailOTP = (options) => {
|
|
|
141
141
|
$ERROR_CODES: EMAIL_OTP_ERROR_CODES
|
|
142
142
|
};
|
|
143
143
|
};
|
|
144
|
-
//#endregion
|
|
145
144
|
export { emailOTP };
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { getDate } from "../../utils/date.mjs";
|
|
2
|
-
import { constantTimeEqual } from "../../crypto/buffer.mjs";
|
|
3
1
|
import { symmetricDecrypt, symmetricEncrypt } from "../../crypto/index.mjs";
|
|
2
|
+
import { constantTimeEqual } from "../../crypto/buffer.mjs";
|
|
3
|
+
import { getDate } from "../../utils/date.mjs";
|
|
4
4
|
import { defaultKeyHasher, splitAtLastColon } from "./utils.mjs";
|
|
5
|
-
|
|
5
|
+
// src/plugins/email-otp/otp-token.ts
|
|
6
6
|
async function storeOTP(ctx, opts, otp) {
|
|
7
7
|
if (opts.storeOTP === "encrypted") return await symmetricEncrypt({
|
|
8
8
|
key: ctx.context.secretConfig,
|
|
@@ -63,5 +63,4 @@ async function tryReuseOTP(ctx, opts, identifier) {
|
|
|
63
63
|
await ctx.context.internalAdapter.updateVerificationByIdentifier(identifier, { expiresAt: getDate(opts.expiresIn, "sec") });
|
|
64
64
|
return plainOtp;
|
|
65
65
|
}
|
|
66
|
-
//#endregion
|
|
67
66
|
export { storeOTP, tryReuseOTP, verifyStoredOTP };
|
|
@@ -1,21 +1,21 @@
|
|
|
1
1
|
import { formCsrfMiddleware } from "../../api/middlewares/origin-check.mjs";
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
2
|
+
import { APIError as APIError$1 } from "../../api/index.mjs";
|
|
3
|
+
import { setCookieCache, setSessionCookie } from "../../cookies/index.mjs";
|
|
4
4
|
import { generateRandomString } from "../../crypto/random.mjs";
|
|
5
5
|
import { symmetricDecrypt } from "../../crypto/index.mjs";
|
|
6
|
-
import { setCookieCache, setSessionCookie } from "../../cookies/index.mjs";
|
|
7
6
|
import { revokeUnprovenAccountAccess } from "../../db/revoke-unproven-account-access.mjs";
|
|
7
|
+
import { parseUserInput, parseUserOutput } from "../../db/schema.mjs";
|
|
8
8
|
import { getSessionFromCtx, sensitiveSessionMiddleware } from "../../api/routes/session.mjs";
|
|
9
|
+
import { getDate } from "../../utils/date.mjs";
|
|
9
10
|
import { assertPasswordNotTooLong, assertPasswordNotTooShort, resetCredentialPassword } from "../../utils/password.mjs";
|
|
10
|
-
import { APIError as APIError$1 } from "../../api/index.mjs";
|
|
11
11
|
import { EMAIL_OTP_ERROR_CODES } from "./error-codes.mjs";
|
|
12
|
-
import { splitAtLastColon, toOTPIdentifier } from "./utils.mjs";
|
|
13
12
|
import { storeOTP, tryReuseOTP, verifyStoredOTP } from "./otp-token.mjs";
|
|
13
|
+
import { splitAtLastColon, toOTPIdentifier } from "./utils.mjs";
|
|
14
14
|
import { BASE_ERROR_CODES } from "@better-auth/core/error";
|
|
15
15
|
import { createAuthEndpoint } from "@better-auth/core/api";
|
|
16
16
|
import { deprecate } from "@better-auth/core/utils/deprecate";
|
|
17
17
|
import * as z from "zod";
|
|
18
|
-
|
|
18
|
+
// src/plugins/email-otp/routes.ts
|
|
19
19
|
const types = [
|
|
20
20
|
"email-verification",
|
|
21
21
|
"sign-in",
|
|
@@ -771,5 +771,4 @@ async function atomicVerifyOTP(ctx, opts, identifier, providedOTP, successDispos
|
|
|
771
771
|
expiresAt: consumed.expiresAt
|
|
772
772
|
})) throw APIError$1.fromStatus("INTERNAL_SERVER_ERROR", { message: "Unable to complete OTP verification" });
|
|
773
773
|
}
|
|
774
|
-
//#endregion
|
|
775
774
|
export { changeEmailEmailOTP, checkVerificationOTP, createVerificationOTP, forgetPasswordEmailOTP, getVerificationOTP, requestEmailChangeEmailOTP, requestPasswordResetEmailOTP, resetPasswordEmailOTP, sendVerificationOTP, signInEmailOTP, verifyEmailOTP };
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { GenericEndpointContext } from "@better-auth/core";
|
|
2
|
-
//#region src/plugins/email-otp/types.d.ts
|
|
3
2
|
export interface EmailOTPOptions {
|
|
4
3
|
/**
|
|
5
4
|
* Function to send email verification.
|
|
@@ -103,5 +102,4 @@ export interface EmailOTPOptions {
|
|
|
103
102
|
window: number;
|
|
104
103
|
max: number;
|
|
105
104
|
};
|
|
106
|
-
}
|
|
107
|
-
//#endregion
|
|
105
|
+
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { base64Url } from "@better-auth/utils/base64";
|
|
2
2
|
import { createHash } from "@better-auth/utils/hash";
|
|
3
|
-
|
|
3
|
+
// src/plugins/email-otp/utils.ts
|
|
4
4
|
function toOTPIdentifier(type, email) {
|
|
5
5
|
return `${type}-otp-${email}`;
|
|
6
6
|
}
|
|
@@ -13,5 +13,4 @@ function splitAtLastColon(input) {
|
|
|
13
13
|
if (idx === -1) return [input, ""];
|
|
14
14
|
return [input.slice(0, idx), input.slice(idx + 1)];
|
|
15
15
|
}
|
|
16
|
-
//#endregion
|
|
17
16
|
export { defaultKeyHasher, splitAtLastColon, toOTPIdentifier };
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import { defineErrorCodes } from "@better-auth/core/utils/error-codes";
|
|
2
|
-
|
|
2
|
+
// src/plugins/generic-oauth/error-codes.ts
|
|
3
3
|
const GENERIC_OAUTH_ERROR_CODES = defineErrorCodes({
|
|
4
4
|
INVALID_OAUTH_CONFIGURATION: "Invalid OAuth configuration",
|
|
5
5
|
TOKEN_URL_NOT_FOUND: "Invalid OAuth configuration. Token URL not found."
|
|
6
6
|
});
|
|
7
|
-
//#endregion
|
|
8
7
|
export { GENERIC_OAUTH_ERROR_CODES };
|
|
@@ -12,7 +12,6 @@ import { YandexOptions, yandex } from "./providers/yandex.mjs";
|
|
|
12
12
|
import "./providers/index.mjs";
|
|
13
13
|
import { AuthContext } from "@better-auth/core";
|
|
14
14
|
import { OAuthProvider } from "@better-auth/core/oauth2";
|
|
15
|
-
//#region src/plugins/generic-oauth/index.d.ts
|
|
16
15
|
declare module "@better-auth/core" {
|
|
17
16
|
interface BetterAuthPluginRegistry<AuthOptions, Options> {
|
|
18
17
|
"generic-oauth": {
|
|
@@ -25,10 +24,7 @@ declare module "@better-auth/core" {
|
|
|
25
24
|
* Extracts common fields from GenericOAuthConfig for provider helpers.
|
|
26
25
|
*/
|
|
27
26
|
export type BaseOAuthProviderOptions = Pick<GenericOAuthConfig, "clientId" | "clientSecret" | "tokenEndpointAuth" | "scopes" | "redirectURI" | "endSessionEndpoint" | "postLogoutRedirectURI" | "disableProviderLogout" | "pkce" | "disableImplicitSignUp" | "disableSignUp" | "overrideUserInfo">;
|
|
28
|
-
type PendingDiscovery = Map<string,
|
|
29
|
-
config: GenericOAuthConfig;
|
|
30
|
-
attempt?: Promise<void> | undefined;
|
|
31
|
-
}>;
|
|
27
|
+
type PendingDiscovery = Map<string, GenericOAuthConfig>;
|
|
32
28
|
/**
|
|
33
29
|
* A generic OAuth plugin that registers any OAuth/OIDC provider
|
|
34
30
|
* as a first-class social provider.
|
|
@@ -57,5 +53,4 @@ export declare const genericOAuth: <const ID extends string>(options: GenericOAu
|
|
|
57
53
|
TOKEN_URL_NOT_FOUND: import("@better-auth/core/utils/error-codes").RawError<"TOKEN_URL_NOT_FOUND">;
|
|
58
54
|
};
|
|
59
55
|
};
|
|
60
|
-
//#endregion
|
|
61
56
|
export { type Auth0Options, type GenericOAuthConfig, type GenericOAuthOptions, type GenericOAuthUserInfo, type GumroadOptions, type HubSpotOptions, type KeycloakOptions, type LineOptions, type MicrosoftEntraIdOptions, type OktaOptions, type PatreonOptions, type SlackOptions, type YandexOptions, auth0, gumroad, hubspot, keycloak, line, microsoftEntraId, okta, patreon, slack, yandex };
|