better-auth 1.7.21 → 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 +3 -3
- package/dist/api/index.mjs +8 -9
- package/dist/api/middlewares/authorization.d.mts +1 -3
- package/dist/api/middlewares/authorization.mjs +1 -2
- package/dist/api/middlewares/origin-check.d.mts +1 -3
- package/dist/api/middlewares/origin-check.mjs +2 -3
- package/dist/api/rate-limiter/index.mjs +1 -2
- package/dist/api/routes/account.d.mts +1 -3
- package/dist/api/routes/account.mjs +10 -10
- package/dist/api/routes/callback.d.mts +1 -3
- package/dist/api/routes/callback.mjs +5 -6
- package/dist/api/routes/email-verification.d.mts +1 -3
- package/dist/api/routes/email-verification.mjs +4 -5
- package/dist/api/routes/error.d.mts +1 -3
- package/dist/api/routes/error.mjs +1 -2
- package/dist/api/routes/ok.d.mts +1 -3
- package/dist/api/routes/ok.mjs +1 -2
- package/dist/api/routes/password.d.mts +1 -3
- package/dist/api/routes/password.mjs +3 -4
- package/dist/api/routes/session.d.mts +2 -3
- package/dist/api/routes/session.mjs +10 -6
- package/dist/api/routes/sign-in.d.mts +0 -2
- package/dist/api/routes/sign-in.mjs +6 -7
- package/dist/api/routes/sign-out.d.mts +1 -3
- package/dist/api/routes/sign-out.mjs +1 -2
- package/dist/api/routes/sign-up.d.mts +1 -3
- package/dist/api/routes/sign-up.mjs +5 -6
- package/dist/api/routes/update-session.d.mts +1 -3
- package/dist/api/routes/update-session.mjs +2 -3
- package/dist/api/routes/update-user.d.mts +1 -3
- package/dist/api/routes/update-user.mjs +31 -28
- package/dist/api/state/oauth.d.mts +0 -2
- package/dist/api/state/oauth.mjs +1 -2
- package/dist/api/state/session-source.d.mts +1 -3
- package/dist/api/state/session-source.mjs +1 -2
- package/dist/api/state/should-session-refresh.d.mts +0 -2
- package/dist/api/state/should-session-refresh.mjs +1 -2
- package/dist/api/to-auth-endpoints.mjs +2 -3
- package/dist/auth/base.mjs +3 -9
- package/dist/auth/full.d.mts +1 -3
- package/dist/auth/full.mjs +1 -2
- package/dist/auth/minimal.d.mts +0 -2
- package/dist/auth/minimal.mjs +2 -3
- package/dist/auth/trusted-origins.mjs +2 -3
- package/dist/client/broadcast-channel.d.mts +1 -3
- package/dist/client/broadcast-channel.mjs +4 -4
- package/dist/client/config.d.mts +1 -3
- package/dist/client/config.mjs +2 -3
- package/dist/client/equality.d.mts +1 -3
- package/dist/client/equality.mjs +1 -2
- package/dist/client/fetch-plugins.mjs +1 -2
- package/dist/client/focus-manager.d.mts +1 -3
- package/dist/client/focus-manager.mjs +4 -4
- package/dist/client/index.d.mts +5 -7
- package/dist/client/index.mjs +1 -2
- package/dist/client/lynx/index.d.mts +1 -3
- package/dist/client/lynx/index.mjs +1 -2
- package/dist/client/lynx/lynx-store.d.mts +0 -2
- package/dist/client/lynx/lynx-store.mjs +1 -2
- package/dist/client/online-manager.d.mts +1 -3
- package/dist/client/online-manager.mjs +7 -7
- package/dist/client/parser.d.mts +0 -2
- package/dist/client/parser.mjs +1 -2
- package/dist/client/path-to-object.d.mts +0 -2
- package/dist/client/plugins/index.d.mts +6 -6
- package/dist/client/plugins/infer-plugin.d.mts +1 -3
- package/dist/client/plugins/infer-plugin.mjs +1 -2
- package/dist/client/proxy.mjs +1 -2
- package/dist/client/query-atom.mjs +1 -2
- package/dist/client/query.d.mts +1 -3
- package/dist/client/query.mjs +1 -2
- package/dist/client/react/index.d.mts +1 -3
- package/dist/client/react/index.mjs +1 -2
- package/dist/client/react/react-store.d.mts +0 -2
- package/dist/client/react/react-store.mjs +1 -2
- package/dist/client/session-atom.d.mts +1 -3
- package/dist/client/session-atom.mjs +2 -2
- package/dist/client/session-refresh.d.mts +1 -3
- package/dist/client/session-refresh.mjs +3 -3
- package/dist/client/solid/index.d.mts +1 -3
- package/dist/client/solid/index.mjs +1 -2
- package/dist/client/solid/solid-store.mjs +1 -2
- package/dist/client/svelte/index.d.mts +1 -3
- package/dist/client/svelte/index.mjs +1 -2
- package/dist/client/types.d.mts +2 -4
- package/dist/client/vanilla.d.mts +1 -3
- package/dist/client/vanilla.mjs +1 -2
- package/dist/client/vue/index.d.mts +1 -3
- package/dist/client/vue/index.mjs +1 -2
- package/dist/client/vue/vue-store.mjs +1 -2
- package/dist/context/create-context.mjs +8 -9
- package/dist/context/helpers.mjs +3 -4
- package/dist/context/init-minimal.mjs +1 -2
- package/dist/context/init.mjs +1 -2
- package/dist/context/secret-utils.mjs +1 -2
- package/dist/context/store-capabilities.mjs +1 -2
- package/dist/cookies/cache.mjs +1 -2
- package/dist/cookies/cookie-utils.d.mts +0 -2
- package/dist/cookies/cookie-utils.mjs +1 -2
- package/dist/cookies/index.d.mts +0 -2
- package/dist/cookies/index.mjs +2 -3
- package/dist/cookies/jwt.mjs +1 -2
- package/dist/cookies/session-store.d.mts +0 -2
- package/dist/cookies/session-store.mjs +1 -2
- package/dist/crypto/buffer.d.mts +1 -3
- package/dist/crypto/buffer.mjs +1 -2
- package/dist/crypto/index.d.mts +0 -2
- package/dist/crypto/index.mjs +2 -3
- package/dist/crypto/jwt.d.mts +1 -3
- package/dist/crypto/jwt.mjs +1 -2
- package/dist/crypto/password.d.mts +0 -2
- package/dist/crypto/password.mjs +1 -2
- package/dist/crypto/purpose.mjs +1 -2
- package/dist/crypto/random.d.mts +1 -3
- package/dist/crypto/random.mjs +1 -2
- package/dist/db/adapter-base.d.mts +1 -3
- package/dist/db/adapter-base.mjs +1 -2
- package/dist/db/adapter-kysely.d.mts +1 -3
- package/dist/db/adapter-kysely.mjs +1 -2
- package/dist/db/field-converter.d.mts +1 -3
- package/dist/db/field-converter.mjs +1 -2
- package/dist/db/field.d.mts +0 -2
- package/dist/db/get-migration.d.mts +1 -3
- package/dist/db/get-migration.mjs +1 -2
- package/dist/db/get-schema.d.mts +1 -3
- package/dist/db/get-schema.mjs +1 -2
- package/dist/db/index.d.mts +1 -1
- package/dist/db/index.mjs +4 -5
- package/dist/db/internal-adapter.d.mts +1 -3
- package/dist/db/internal-adapter.mjs +21 -10
- package/dist/db/revoke-unproven-account-access.d.mts +1 -3
- package/dist/db/revoke-unproven-account-access.mjs +1 -2
- package/dist/db/schema.d.mts +1 -3
- package/dist/db/schema.mjs +1 -2
- package/dist/db/to-zod.d.mts +0 -2
- package/dist/db/to-zod.mjs +1 -2
- package/dist/db/verification-token-storage.mjs +1 -2
- package/dist/db/with-hooks.d.mts +1 -3
- package/dist/db/with-hooks.mjs +1 -2
- package/dist/index.d.mts +1 -1
- package/dist/index.mjs +1 -1
- package/dist/integrations/cookie-plugin-guard.mjs +1 -2
- package/dist/integrations/next-js.d.mts +1 -3
- package/dist/integrations/next-js.mjs +2 -3
- package/dist/integrations/node.d.mts +1 -3
- package/dist/integrations/node.mjs +1 -2
- package/dist/integrations/solid-start.d.mts +1 -3
- package/dist/integrations/solid-start.mjs +1 -2
- package/dist/integrations/svelte-kit.d.mts +1 -3
- package/dist/integrations/svelte-kit.mjs +1 -2
- package/dist/integrations/tanstack-start-solid.d.mts +1 -3
- package/dist/integrations/tanstack-start-solid.mjs +1 -2
- package/dist/integrations/tanstack-start.d.mts +1 -3
- package/dist/integrations/tanstack-start.mjs +1 -2
- package/dist/oauth2/account-key.mjs +1 -2
- package/dist/oauth2/callback.mjs +1 -2
- package/dist/oauth2/errors.mjs +1 -2
- package/dist/oauth2/index.d.mts +1 -1
- package/dist/oauth2/index.mjs +1 -1
- package/dist/oauth2/link-account.d.mts +1 -3
- package/dist/oauth2/link-account.mjs +18 -13
- package/dist/oauth2/state.d.mts +1 -3
- package/dist/oauth2/state.mjs +3 -4
- package/dist/oauth2/utils.d.mts +1 -3
- package/dist/oauth2/utils.mjs +1 -2
- package/dist/package.mjs +2 -3
- package/dist/plugins/access/access.d.mts +1 -3
- package/dist/plugins/access/access.mjs +1 -2
- package/dist/plugins/access/index.d.mts +1 -1
- package/dist/plugins/access/types.d.mts +1 -3
- package/dist/plugins/additional-fields/client.d.mts +1 -3
- package/dist/plugins/additional-fields/client.mjs +1 -2
- package/dist/plugins/admin/access/statement.d.mts +1 -3
- package/dist/plugins/admin/access/statement.mjs +1 -2
- package/dist/plugins/admin/admin.d.mts +1 -3
- package/dist/plugins/admin/admin.mjs +2 -3
- package/dist/plugins/admin/client.d.mts +2 -4
- package/dist/plugins/admin/client.mjs +1 -2
- package/dist/plugins/admin/error-codes.d.mts +1 -3
- package/dist/plugins/admin/error-codes.mjs +1 -2
- package/dist/plugins/admin/has-permission.mjs +1 -2
- package/dist/plugins/admin/index.d.mts +1 -1
- package/dist/plugins/admin/routes.mjs +3 -4
- package/dist/plugins/admin/schema.d.mts +1 -3
- package/dist/plugins/admin/schema.mjs +1 -2
- package/dist/plugins/admin/types.d.mts +1 -3
- package/dist/plugins/anonymous/client.d.mts +1 -3
- package/dist/plugins/anonymous/client.mjs +1 -2
- package/dist/plugins/anonymous/error-codes.d.mts +1 -3
- package/dist/plugins/anonymous/error-codes.mjs +1 -2
- package/dist/plugins/anonymous/index.d.mts +0 -2
- package/dist/plugins/anonymous/index.mjs +3 -4
- package/dist/plugins/anonymous/schema.d.mts +1 -3
- package/dist/plugins/anonymous/schema.mjs +1 -2
- package/dist/plugins/anonymous/types.d.mts +1 -3
- package/dist/plugins/bearer/index.d.mts +1 -3
- package/dist/plugins/bearer/index.mjs +1 -2
- package/dist/plugins/captcha/constants.d.mts +1 -3
- package/dist/plugins/captcha/constants.mjs +1 -2
- package/dist/plugins/captcha/error-codes.mjs +1 -2
- package/dist/plugins/captcha/index.d.mts +0 -2
- package/dist/plugins/captcha/index.mjs +2 -3
- package/dist/plugins/captcha/types.d.mts +1 -3
- package/dist/plugins/captcha/utils.mjs +1 -2
- package/dist/plugins/captcha/verify-handlers/captchafox.mjs +1 -2
- package/dist/plugins/captcha/verify-handlers/cloudflare-turnstile.mjs +1 -2
- package/dist/plugins/captcha/verify-handlers/google-recaptcha.mjs +1 -2
- package/dist/plugins/captcha/verify-handlers/h-captcha.mjs +1 -2
- package/dist/plugins/captcha/verify-handlers/vercel-botid.mjs +1 -2
- package/dist/plugins/custom-session/client.d.mts +1 -3
- package/dist/plugins/custom-session/client.mjs +1 -2
- package/dist/plugins/custom-session/index.d.mts +1 -3
- package/dist/plugins/custom-session/index.mjs +3 -4
- package/dist/plugins/device-authorization/client.d.mts +1 -3
- package/dist/plugins/device-authorization/client.mjs +1 -2
- package/dist/plugins/device-authorization/error-codes.mjs +1 -2
- package/dist/plugins/device-authorization/index.d.mts +1 -3
- package/dist/plugins/device-authorization/index.mjs +2 -3
- package/dist/plugins/device-authorization/routes.d.mts +4 -6
- package/dist/plugins/device-authorization/routes.mjs +3 -4
- package/dist/plugins/device-authorization/schema.d.mts +0 -2
- package/dist/plugins/device-authorization/schema.mjs +1 -2
- package/dist/plugins/email-otp/client.d.mts +0 -2
- package/dist/plugins/email-otp/client.mjs +1 -2
- package/dist/plugins/email-otp/error-codes.d.mts +1 -3
- package/dist/plugins/email-otp/error-codes.mjs +1 -2
- package/dist/plugins/email-otp/index.d.mts +0 -2
- package/dist/plugins/email-otp/index.mjs +4 -5
- package/dist/plugins/email-otp/otp-token.mjs +3 -4
- package/dist/plugins/email-otp/routes.mjs +6 -7
- package/dist/plugins/email-otp/types.d.mts +1 -3
- package/dist/plugins/email-otp/utils.mjs +1 -2
- package/dist/plugins/generic-oauth/error-codes.mjs +1 -2
- package/dist/plugins/generic-oauth/index.d.mts +0 -2
- package/dist/plugins/generic-oauth/index.mjs +5 -7
- package/dist/plugins/generic-oauth/providers/auth0.d.mts +1 -3
- package/dist/plugins/generic-oauth/providers/auth0.mjs +1 -2
- package/dist/plugins/generic-oauth/providers/gumroad.d.mts +1 -3
- package/dist/plugins/generic-oauth/providers/gumroad.mjs +1 -2
- package/dist/plugins/generic-oauth/providers/hubspot.d.mts +1 -3
- package/dist/plugins/generic-oauth/providers/hubspot.mjs +1 -2
- package/dist/plugins/generic-oauth/providers/keycloak.d.mts +1 -3
- package/dist/plugins/generic-oauth/providers/keycloak.mjs +1 -2
- package/dist/plugins/generic-oauth/providers/line.d.mts +1 -3
- package/dist/plugins/generic-oauth/providers/line.mjs +1 -2
- package/dist/plugins/generic-oauth/providers/microsoft-entra-id.d.mts +1 -3
- package/dist/plugins/generic-oauth/providers/microsoft-entra-id.mjs +1 -2
- package/dist/plugins/generic-oauth/providers/okta.d.mts +1 -3
- package/dist/plugins/generic-oauth/providers/okta.mjs +1 -2
- package/dist/plugins/generic-oauth/providers/patreon.d.mts +1 -3
- package/dist/plugins/generic-oauth/providers/patreon.mjs +1 -2
- package/dist/plugins/generic-oauth/providers/slack.d.mts +1 -3
- package/dist/plugins/generic-oauth/providers/slack.mjs +1 -2
- package/dist/plugins/generic-oauth/providers/yandex.d.mts +1 -3
- package/dist/plugins/generic-oauth/providers/yandex.mjs +1 -2
- package/dist/plugins/generic-oauth/types.d.mts +1 -3
- package/dist/plugins/haveibeenpwned/index.d.mts +1 -3
- package/dist/plugins/haveibeenpwned/index.mjs +2 -3
- package/dist/plugins/index.d.mts +5 -5
- package/dist/plugins/jwt/adapter.mjs +1 -2
- package/dist/plugins/jwt/client.d.mts +1 -3
- package/dist/plugins/jwt/client.mjs +1 -2
- package/dist/plugins/jwt/cookie-cache.mjs +1 -2
- package/dist/plugins/jwt/index.d.mts +1 -3
- package/dist/plugins/jwt/index.mjs +5 -6
- package/dist/plugins/jwt/schema.d.mts +1 -3
- package/dist/plugins/jwt/schema.mjs +1 -2
- package/dist/plugins/jwt/sign.d.mts +0 -2
- package/dist/plugins/jwt/sign.mjs +1 -2
- package/dist/plugins/jwt/types.d.mts +1 -3
- package/dist/plugins/jwt/utils.d.mts +1 -3
- package/dist/plugins/jwt/utils.mjs +2 -3
- package/dist/plugins/jwt/verify.d.mts +1 -3
- package/dist/plugins/jwt/verify.mjs +1 -2
- package/dist/plugins/last-login-method/client.d.mts +1 -3
- package/dist/plugins/last-login-method/client.mjs +1 -2
- package/dist/plugins/last-login-method/index.d.mts +1 -3
- package/dist/plugins/last-login-method/index.mjs +1 -2
- package/dist/plugins/magic-link/client.d.mts +1 -3
- package/dist/plugins/magic-link/client.mjs +1 -2
- package/dist/plugins/magic-link/index.d.mts +1 -3
- package/dist/plugins/magic-link/index.mjs +4 -5
- package/dist/plugins/magic-link/utils.mjs +1 -2
- package/dist/plugins/multi-session/client.d.mts +0 -2
- package/dist/plugins/multi-session/client.mjs +1 -2
- package/dist/plugins/multi-session/error-codes.d.mts +1 -3
- package/dist/plugins/multi-session/error-codes.mjs +1 -2
- package/dist/plugins/multi-session/index.d.mts +0 -2
- package/dist/plugins/multi-session/index.mjs +3 -4
- package/dist/plugins/oauth-popup/client.d.mts +0 -2
- package/dist/plugins/oauth-popup/client.mjs +1 -2
- package/dist/plugins/oauth-popup/constants.d.mts +1 -3
- package/dist/plugins/oauth-popup/constants.mjs +1 -2
- package/dist/plugins/oauth-popup/error-codes.d.mts +1 -3
- package/dist/plugins/oauth-popup/error-codes.mjs +1 -2
- package/dist/plugins/oauth-popup/index.d.mts +0 -2
- package/dist/plugins/oauth-popup/index.mjs +5 -6
- package/dist/plugins/oauth-popup/types.d.mts +1 -3
- package/dist/plugins/oauth-proxy/index.d.mts +1 -3
- package/dist/plugins/oauth-proxy/index.mjs +7 -8
- package/dist/plugins/oauth-proxy/utils.mjs +1 -2
- package/dist/plugins/one-tap/client.d.mts +1 -3
- package/dist/plugins/one-tap/client.mjs +1 -2
- package/dist/plugins/one-tap/index.d.mts +1 -3
- package/dist/plugins/one-tap/index.mjs +7 -8
- package/dist/plugins/one-time-token/client.d.mts +0 -2
- package/dist/plugins/one-time-token/client.mjs +1 -2
- package/dist/plugins/one-time-token/index.d.mts +1 -3
- package/dist/plugins/one-time-token/index.mjs +3 -4
- package/dist/plugins/one-time-token/utils.mjs +1 -2
- package/dist/plugins/open-api/generator.d.mts +0 -2
- package/dist/plugins/open-api/generator.mjs +2 -3
- package/dist/plugins/open-api/index.d.mts +0 -2
- package/dist/plugins/open-api/index.mjs +2 -3
- package/dist/plugins/open-api/logo.mjs +1 -2
- package/dist/plugins/organization/access/statement.d.mts +1 -3
- package/dist/plugins/organization/access/statement.mjs +1 -2
- package/dist/plugins/organization/adapter.d.mts +3 -5
- package/dist/plugins/organization/adapter.mjs +2 -3
- package/dist/plugins/organization/call.mjs +1 -2
- package/dist/plugins/organization/client.d.mts +9 -11
- package/dist/plugins/organization/client.mjs +2 -3
- package/dist/plugins/organization/error-codes.d.mts +1 -3
- package/dist/plugins/organization/error-codes.mjs +1 -2
- package/dist/plugins/organization/has-permission.d.mts +1 -3
- package/dist/plugins/organization/has-permission.mjs +2 -3
- package/dist/plugins/organization/index.d.mts +3 -3
- package/dist/plugins/organization/organization.d.mts +3 -5
- package/dist/plugins/organization/organization.mjs +3 -4
- package/dist/plugins/organization/permission.d.mts +1 -3
- package/dist/plugins/organization/permission.mjs +1 -2
- package/dist/plugins/organization/roles.d.mts +1 -3
- package/dist/plugins/organization/roles.mjs +1 -2
- package/dist/plugins/organization/routes/crud-access-control.d.mts +2 -4
- package/dist/plugins/organization/routes/crud-access-control.mjs +3 -4
- package/dist/plugins/organization/routes/crud-invites.d.mts +4 -6
- package/dist/plugins/organization/routes/crud-invites.mjs +5 -6
- package/dist/plugins/organization/routes/crud-members.d.mts +4 -6
- package/dist/plugins/organization/routes/crud-members.mjs +4 -5
- package/dist/plugins/organization/routes/crud-org.d.mts +4 -6
- package/dist/plugins/organization/routes/crud-org.mjs +8 -9
- package/dist/plugins/organization/routes/crud-team.d.mts +4 -6
- package/dist/plugins/organization/routes/crud-team.mjs +3 -4
- package/dist/plugins/organization/schema.d.mts +0 -2
- package/dist/plugins/organization/schema.mjs +1 -2
- package/dist/plugins/organization/types.d.mts +1 -3
- package/dist/plugins/phone-number/client.d.mts +1 -3
- package/dist/plugins/phone-number/client.mjs +1 -2
- package/dist/plugins/phone-number/error-codes.d.mts +1 -3
- package/dist/plugins/phone-number/error-codes.mjs +1 -2
- package/dist/plugins/phone-number/index.d.mts +0 -2
- package/dist/plugins/phone-number/index.mjs +1 -2
- package/dist/plugins/phone-number/routes.mjs +6 -7
- package/dist/plugins/phone-number/schema.d.mts +1 -3
- package/dist/plugins/phone-number/schema.mjs +1 -2
- package/dist/plugins/phone-number/types.d.mts +2 -4
- package/dist/plugins/siwe/client.d.mts +1 -3
- package/dist/plugins/siwe/client.mjs +1 -2
- package/dist/plugins/siwe/index.d.mts +1 -3
- package/dist/plugins/siwe/index.mjs +5 -6
- package/dist/plugins/siwe/parse-message.mjs +1 -2
- package/dist/plugins/siwe/schema.d.mts +1 -3
- package/dist/plugins/siwe/schema.mjs +1 -2
- package/dist/plugins/siwe/types.d.mts +0 -2
- package/dist/plugins/test-utils/auth-helpers.mjs +1 -2
- package/dist/plugins/test-utils/cookie-builder.mjs +1 -2
- package/dist/plugins/test-utils/db-helpers.mjs +1 -2
- package/dist/plugins/test-utils/factories.mjs +1 -2
- package/dist/plugins/test-utils/index.d.mts +0 -2
- package/dist/plugins/test-utils/index.mjs +2 -3
- package/dist/plugins/test-utils/otp-sink.mjs +1 -2
- package/dist/plugins/test-utils/types.d.mts +1 -3
- package/dist/plugins/two-factor/backup-codes/index.d.mts +1 -3
- package/dist/plugins/two-factor/backup-codes/index.mjs +4 -5
- package/dist/plugins/two-factor/client.d.mts +2 -4
- package/dist/plugins/two-factor/client.mjs +1 -2
- package/dist/plugins/two-factor/constant.mjs +1 -2
- package/dist/plugins/two-factor/error-code.d.mts +1 -3
- package/dist/plugins/two-factor/error-code.mjs +1 -2
- package/dist/plugins/two-factor/index.d.mts +0 -2
- package/dist/plugins/two-factor/index.mjs +9 -10
- package/dist/plugins/two-factor/otp/index.d.mts +1 -3
- package/dist/plugins/two-factor/otp/index.mjs +4 -5
- package/dist/plugins/two-factor/schema.d.mts +1 -3
- package/dist/plugins/two-factor/schema.mjs +1 -2
- package/dist/plugins/two-factor/totp/index.d.mts +1 -3
- package/dist/plugins/two-factor/totp/index.mjs +3 -4
- package/dist/plugins/two-factor/types.d.mts +1 -3
- package/dist/plugins/two-factor/utils.mjs +1 -2
- package/dist/plugins/two-factor/verify-two-factor.mjs +5 -6
- package/dist/plugins/username/client.d.mts +0 -2
- package/dist/plugins/username/client.mjs +1 -2
- package/dist/plugins/username/error-codes.d.mts +1 -3
- package/dist/plugins/username/error-codes.mjs +1 -2
- package/dist/plugins/username/index.d.mts +0 -2
- package/dist/plugins/username/index.mjs +4 -5
- package/dist/plugins/username/schema.d.mts +1 -3
- package/dist/plugins/username/schema.mjs +1 -2
- package/dist/state.d.mts +0 -2
- package/dist/state.mjs +2 -3
- package/dist/test-utils/headers.d.mts +1 -3
- package/dist/test-utils/headers.mjs +1 -2
- package/dist/test-utils/http-test-instance.d.mts +0 -2
- package/dist/test-utils/http-test-instance.mjs +1 -2
- package/dist/test-utils/index.d.mts +1 -1
- package/dist/test-utils/index.mjs +1 -1
- package/dist/test-utils/test-instance.d.mts +4 -6
- package/dist/test-utils/test-instance.mjs +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/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
|
@@ -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([
|
|
@@ -739,5 +739,4 @@ const defaultGenerateUserCode = (length) => {
|
|
|
739
739
|
const chars = new Uint8Array(length);
|
|
740
740
|
return Array.from(crypto.getRandomValues(chars)).map((byte) => defaultCharset[byte % 32]).join("");
|
|
741
741
|
};
|
|
742
|
-
//#endregion
|
|
743
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": {
|
|
@@ -54,5 +53,4 @@ export declare const genericOAuth: <const ID extends string>(options: GenericOAu
|
|
|
54
53
|
TOKEN_URL_NOT_FOUND: import("@better-auth/core/utils/error-codes").RawError<"TOKEN_URL_NOT_FOUND">;
|
|
55
54
|
};
|
|
56
55
|
};
|
|
57
|
-
//#endregion
|
|
58
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 };
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { toBoolean } from "../../utils/boolean.mjs";
|
|
2
1
|
import { PACKAGE_VERSION } from "../../version.mjs";
|
|
3
2
|
import { GENERIC_OAUTH_ERROR_CODES } from "./error-codes.mjs";
|
|
4
3
|
import { auth0 } from "./providers/auth0.mjs";
|
|
@@ -12,11 +11,11 @@ import { patreon } from "./providers/patreon.mjs";
|
|
|
12
11
|
import { slack } from "./providers/slack.mjs";
|
|
13
12
|
import { yandex } from "./providers/yandex.mjs";
|
|
14
13
|
import { APIError } from "@better-auth/core/error";
|
|
15
|
-
import { applyDefaultAccessTokenExpiry, createAuthorizationURL, refreshAccessToken, validateAuthorizationCode, verifyProviderIdToken } from "@better-auth/core/oauth2";
|
|
14
|
+
import { applyDefaultAccessTokenExpiry, createAuthorizationURL, parseStringBoolean, refreshAccessToken, validateAuthorizationCode, verifyProviderIdToken } from "@better-auth/core/oauth2";
|
|
16
15
|
import { createAuthMiddleware } from "@better-auth/core/api";
|
|
17
16
|
import { createRemoteJWKSet, decodeJwt } from "jose";
|
|
18
17
|
import { betterFetch } from "@better-fetch/fetch";
|
|
19
|
-
|
|
18
|
+
// src/plugins/generic-oauth/index.ts
|
|
20
19
|
function isSecretlessTokenEndpointAuth(tokenEndpointAuth) {
|
|
21
20
|
return tokenEndpointAuth?.method === "private_key_jwt" || tokenEndpointAuth?.method === "none";
|
|
22
21
|
}
|
|
@@ -80,7 +79,7 @@ async function fetchUserInfo(tokens, userInfoUrl, idTokenClaims) {
|
|
|
80
79
|
const decoded = idTokenClaims ?? readIdTokenClaims(tokens.idToken);
|
|
81
80
|
if (decoded?.sub && decoded?.email) return {
|
|
82
81
|
id: decoded.sub,
|
|
83
|
-
emailVerified:
|
|
82
|
+
emailVerified: parseStringBoolean(decoded.email_verified) ?? false,
|
|
84
83
|
image: decoded.picture,
|
|
85
84
|
...decoded
|
|
86
85
|
};
|
|
@@ -94,7 +93,7 @@ async function fetchUserInfo(tokens, userInfoUrl, idTokenClaims) {
|
|
|
94
93
|
return {
|
|
95
94
|
...userInfo.data,
|
|
96
95
|
email: userInfo.data.email,
|
|
97
|
-
emailVerified:
|
|
96
|
+
emailVerified: parseStringBoolean(userInfo.data.email_verified) ?? false,
|
|
98
97
|
image: userInfo.data.picture,
|
|
99
98
|
name: userInfo.data.name
|
|
100
99
|
};
|
|
@@ -179,7 +178,7 @@ const genericOAuth = (options) => {
|
|
|
179
178
|
const mapped = c.mapProfileToUser ? await c.mapProfileToUser(raw) : {};
|
|
180
179
|
const user = {
|
|
181
180
|
email: raw.email,
|
|
182
|
-
emailVerified:
|
|
181
|
+
emailVerified: parseStringBoolean(raw.emailVerified) ?? false,
|
|
183
182
|
image: raw.image,
|
|
184
183
|
name: raw.name,
|
|
185
184
|
...mapped
|
|
@@ -359,5 +358,4 @@ const genericOAuth = (options) => {
|
|
|
359
358
|
$ERROR_CODES: GENERIC_OAUTH_ERROR_CODES
|
|
360
359
|
};
|
|
361
360
|
};
|
|
362
|
-
//#endregion
|
|
363
361
|
export { auth0, genericOAuth, gumroad, hubspot, keycloak, line, microsoftEntraId, okta, patreon, slack, yandex };
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { GenericOAuthConfig } from "../types.mjs";
|
|
2
2
|
import { BaseOAuthProviderOptions } from "../index.mjs";
|
|
3
|
-
//#region src/plugins/generic-oauth/providers/auth0.d.ts
|
|
4
3
|
export interface Auth0Options extends BaseOAuthProviderOptions {
|
|
5
4
|
/**
|
|
6
5
|
* Auth0 domain (e.g., dev-xxx.eu.auth0.com)
|
|
@@ -30,5 +29,4 @@ export interface Auth0Options extends BaseOAuthProviderOptions {
|
|
|
30
29
|
* });
|
|
31
30
|
* ```
|
|
32
31
|
*/
|
|
33
|
-
export declare function auth0(options: Auth0Options): GenericOAuthConfig<"auth0">;
|
|
34
|
-
//#endregion
|
|
32
|
+
export declare function auth0(options: Auth0Options): GenericOAuthConfig<"auth0">;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
// src/plugins/generic-oauth/providers/auth0.ts
|
|
2
2
|
/**
|
|
3
3
|
* Auth0 OAuth provider helper
|
|
4
4
|
*
|
|
@@ -45,5 +45,4 @@ function auth0(options) {
|
|
|
45
45
|
overrideUserInfo: options.overrideUserInfo
|
|
46
46
|
};
|
|
47
47
|
}
|
|
48
|
-
//#endregion
|
|
49
48
|
export { auth0 };
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { GenericOAuthConfig } from "../types.mjs";
|
|
2
2
|
import { BaseOAuthProviderOptions } from "../index.mjs";
|
|
3
|
-
//#region src/plugins/generic-oauth/providers/gumroad.d.ts
|
|
4
3
|
export interface GumroadOptions extends BaseOAuthProviderOptions {}
|
|
5
4
|
/**
|
|
6
5
|
* Gumroad OAuth provider helper
|
|
@@ -25,5 +24,4 @@ export interface GumroadOptions extends BaseOAuthProviderOptions {}
|
|
|
25
24
|
*
|
|
26
25
|
* @see https://app.gumroad.com/oauth
|
|
27
26
|
*/
|
|
28
|
-
export declare function gumroad(options: GumroadOptions): GenericOAuthConfig<"gumroad">;
|
|
29
|
-
//#endregion
|
|
27
|
+
export declare function gumroad(options: GumroadOptions): GenericOAuthConfig<"gumroad">;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { betterFetch } from "@better-fetch/fetch";
|
|
2
|
-
|
|
2
|
+
// src/plugins/generic-oauth/providers/gumroad.ts
|
|
3
3
|
/**
|
|
4
4
|
* Gumroad OAuth provider helper
|
|
5
5
|
*
|
|
@@ -58,5 +58,4 @@ function gumroad(options) {
|
|
|
58
58
|
getUserInfo
|
|
59
59
|
};
|
|
60
60
|
}
|
|
61
|
-
//#endregion
|
|
62
61
|
export { gumroad };
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { GenericOAuthConfig } from "../types.mjs";
|
|
2
2
|
import { BaseOAuthProviderOptions } from "../index.mjs";
|
|
3
|
-
//#region src/plugins/generic-oauth/providers/hubspot.d.ts
|
|
4
3
|
export interface HubSpotOptions extends BaseOAuthProviderOptions {
|
|
5
4
|
/**
|
|
6
5
|
* OAuth scopes to request.
|
|
@@ -30,5 +29,4 @@ export interface HubSpotOptions extends BaseOAuthProviderOptions {
|
|
|
30
29
|
* });
|
|
31
30
|
* ```
|
|
32
31
|
*/
|
|
33
|
-
export declare function hubspot(options: HubSpotOptions): GenericOAuthConfig<"hubspot">;
|
|
34
|
-
//#endregion
|
|
32
|
+
export declare function hubspot(options: HubSpotOptions): GenericOAuthConfig<"hubspot">;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { betterFetch } from "@better-fetch/fetch";
|
|
2
|
-
|
|
2
|
+
// src/plugins/generic-oauth/providers/hubspot.ts
|
|
3
3
|
/**
|
|
4
4
|
* HubSpot OAuth provider helper
|
|
5
5
|
*
|
|
@@ -62,5 +62,4 @@ function hubspot(options) {
|
|
|
62
62
|
getUserInfo
|
|
63
63
|
};
|
|
64
64
|
}
|
|
65
|
-
//#endregion
|
|
66
65
|
export { hubspot };
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { GenericOAuthConfig } from "../types.mjs";
|
|
2
2
|
import { BaseOAuthProviderOptions } from "../index.mjs";
|
|
3
|
-
//#region src/plugins/generic-oauth/providers/keycloak.d.ts
|
|
4
3
|
export interface KeycloakOptions extends BaseOAuthProviderOptions {
|
|
5
4
|
/**
|
|
6
5
|
* Keycloak issuer URL (includes realm, e.g., https://my-domain/realms/MyRealm)
|
|
@@ -30,5 +29,4 @@ export interface KeycloakOptions extends BaseOAuthProviderOptions {
|
|
|
30
29
|
* });
|
|
31
30
|
* ```
|
|
32
31
|
*/
|
|
33
|
-
export declare function keycloak(options: KeycloakOptions): GenericOAuthConfig<"keycloak">;
|
|
34
|
-
//#endregion
|
|
32
|
+
export declare function keycloak(options: KeycloakOptions): GenericOAuthConfig<"keycloak">;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
// src/plugins/generic-oauth/providers/keycloak.ts
|
|
2
2
|
/**
|
|
3
3
|
* Keycloak OAuth provider helper
|
|
4
4
|
*
|
|
@@ -43,5 +43,4 @@ function keycloak(options) {
|
|
|
43
43
|
overrideUserInfo: options.overrideUserInfo
|
|
44
44
|
};
|
|
45
45
|
}
|
|
46
|
-
//#endregion
|
|
47
46
|
export { keycloak };
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { GenericOAuthConfig } from "../types.mjs";
|
|
2
2
|
import { BaseOAuthProviderOptions } from "../index.mjs";
|
|
3
|
-
//#region src/plugins/generic-oauth/providers/line.d.ts
|
|
4
3
|
export interface LineOptions extends BaseOAuthProviderOptions {
|
|
5
4
|
/**
|
|
6
5
|
* Unique provider identifier for this LINE channel.
|
|
@@ -48,5 +47,4 @@ export interface LineOptions extends BaseOAuthProviderOptions {
|
|
|
48
47
|
* });
|
|
49
48
|
* ```
|
|
50
49
|
*/
|
|
51
|
-
export declare function line(options: LineOptions): GenericOAuthConfig;
|
|
52
|
-
//#endregion
|
|
50
|
+
export declare function line(options: LineOptions): GenericOAuthConfig;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { decodeJwt } from "jose";
|
|
2
2
|
import { betterFetch } from "@better-fetch/fetch";
|
|
3
|
-
|
|
3
|
+
// src/plugins/generic-oauth/providers/line.ts
|
|
4
4
|
/**
|
|
5
5
|
* LINE OAuth provider helper
|
|
6
6
|
*
|
|
@@ -89,5 +89,4 @@ function line(options) {
|
|
|
89
89
|
getUserInfo
|
|
90
90
|
};
|
|
91
91
|
}
|
|
92
|
-
//#endregion
|
|
93
92
|
export { line };
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { GenericOAuthConfig } from "../types.mjs";
|
|
2
2
|
import { BaseOAuthProviderOptions } from "../index.mjs";
|
|
3
|
-
//#region src/plugins/generic-oauth/providers/microsoft-entra-id.d.ts
|
|
4
3
|
export interface MicrosoftEntraIdOptions extends BaseOAuthProviderOptions {
|
|
5
4
|
/**
|
|
6
5
|
* Concrete Microsoft Entra ID tenant GUID.
|
|
@@ -33,5 +32,4 @@ export interface MicrosoftEntraIdOptions extends BaseOAuthProviderOptions {
|
|
|
33
32
|
* });
|
|
34
33
|
* ```
|
|
35
34
|
*/
|
|
36
|
-
export declare function microsoftEntraId(options: MicrosoftEntraIdOptions): GenericOAuthConfig<"microsoft-entra-id">;
|
|
37
|
-
//#endregion
|
|
35
|
+
export declare function microsoftEntraId(options: MicrosoftEntraIdOptions): GenericOAuthConfig<"microsoft-entra-id">;
|