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,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
// src/plugins/test-utils/otp-sink.ts
|
|
2
2
|
/**
|
|
3
3
|
* Creates an instance-scoped OTP store for capturing OTPs during testing.
|
|
4
4
|
* Each auth instance gets its own store to avoid cross-contamination.
|
|
@@ -17,5 +17,4 @@ function createOTPStore() {
|
|
|
17
17
|
}
|
|
18
18
|
};
|
|
19
19
|
}
|
|
20
|
-
//#endregion
|
|
21
20
|
export { createOTPStore };
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { Session, User } from "../../types/models.mjs";
|
|
2
2
|
import "../../types/index.mjs";
|
|
3
|
-
//#region src/plugins/test-utils/types.d.ts
|
|
4
3
|
export interface TestUtilsOptions {
|
|
5
4
|
/** Capture OTPs in memory when created (doesn't prevent sending) */
|
|
6
5
|
captureOTP?: boolean;
|
|
@@ -47,5 +46,4 @@ export interface TestHelpers {
|
|
|
47
46
|
}): Promise<TestCookie[]>;
|
|
48
47
|
getOTP?(identifier: string): string | undefined;
|
|
49
48
|
clearOTPs?(): void;
|
|
50
|
-
}
|
|
51
|
-
//#endregion
|
|
49
|
+
}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { SecretConfig } from "../../../crypto/index.mjs";
|
|
2
2
|
import { UserWithTwoFactor } from "../types.mjs";
|
|
3
3
|
import * as z from "zod";
|
|
4
|
-
//#region src/plugins/two-factor/backup-codes/index.d.ts
|
|
5
4
|
export interface BackupCodeOptions {
|
|
6
5
|
/**
|
|
7
6
|
* The amount of backup codes to generate
|
|
@@ -284,5 +283,4 @@ export declare const backupCode2fa: (opts: BackupCodeOptions) => {
|
|
|
284
283
|
backupCodes: string[];
|
|
285
284
|
}>;
|
|
286
285
|
};
|
|
287
|
-
};
|
|
288
|
-
//#endregion
|
|
286
|
+
};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { parseUserOutput } from "../../../db/schema.mjs";
|
|
2
|
-
import { generateRandomString } from "../../../crypto/random.mjs";
|
|
3
|
-
import { symmetricDecrypt, symmetricEncrypt } from "../../../crypto/index.mjs";
|
|
4
1
|
import { sessionMiddleware } from "../../../api/routes/session.mjs";
|
|
2
|
+
import { symmetricDecrypt, symmetricEncrypt } from "../../../crypto/index.mjs";
|
|
3
|
+
import { generateRandomString } from "../../../crypto/random.mjs";
|
|
4
|
+
import { parseUserOutput } from "../../../db/schema.mjs";
|
|
5
5
|
import { shouldRequirePassword } from "../../../utils/password.mjs";
|
|
6
6
|
import { PACKAGE_VERSION } from "../../../version.mjs";
|
|
7
7
|
import { TWO_FACTOR_ERROR_CODES } from "../error-code.mjs";
|
|
@@ -10,7 +10,7 @@ import { APIError, BASE_ERROR_CODES } from "@better-auth/core/error";
|
|
|
10
10
|
import { safeJSONParse } from "@better-auth/core/utils/json";
|
|
11
11
|
import { createAuthEndpoint } from "@better-auth/core/api";
|
|
12
12
|
import * as z from "zod";
|
|
13
|
-
|
|
13
|
+
// src/plugins/two-factor/backup-codes/index.ts
|
|
14
14
|
function generateBackupCodesFn(options) {
|
|
15
15
|
return Array.from({ length: options?.amount ?? 10 }).fill(null).map(() => generateRandomString(options?.length ?? 10, "a-z", "0-9", "A-Z")).map((code) => `${code.slice(0, 5)}-${code.slice(5)}`);
|
|
16
16
|
}
|
|
@@ -343,5 +343,4 @@ const backupCode2fa = (opts) => {
|
|
|
343
343
|
}
|
|
344
344
|
};
|
|
345
345
|
};
|
|
346
|
-
//#endregion
|
|
347
346
|
export { backupCode2fa, encodeBackupCodes, generateBackupCodes, getBackupCodes, verifyBackupCode };
|
|
@@ -1,10 +1,9 @@
|
|
|
1
|
+
import { twoFactor } from "./index.mjs";
|
|
1
2
|
import { BackupCodeOptions, backupCode2fa, encodeBackupCodes, generateBackupCodes, getBackupCodes, verifyBackupCode } from "./backup-codes/index.mjs";
|
|
2
3
|
import { OTPOptions, otp2fa } from "./otp/index.mjs";
|
|
3
4
|
import { TOTPOptions, totp2fa } from "./totp/index.mjs";
|
|
4
|
-
import { TwoFactorOptions, TwoFactorProvider, TwoFactorTable, UserWithTwoFactor } from "./types.mjs";
|
|
5
5
|
import { TWO_FACTOR_ERROR_CODES } from "./error-code.mjs";
|
|
6
|
-
import {
|
|
7
|
-
//#region src/plugins/two-factor/client.d.ts
|
|
6
|
+
import { TwoFactorOptions, TwoFactorProvider, TwoFactorTable, UserWithTwoFactor } from "./types.mjs";
|
|
8
7
|
export declare const twoFactorClient: (options?: {
|
|
9
8
|
/**
|
|
10
9
|
* the page to redirect if a user needs to verify
|
|
@@ -69,5 +68,4 @@ export declare const twoFactorClient: (options?: {
|
|
|
69
68
|
INVALID_TWO_FACTOR_COOKIE: import("@better-auth/core/utils/error-codes").RawError<"INVALID_TWO_FACTOR_COOKIE">;
|
|
70
69
|
};
|
|
71
70
|
};
|
|
72
|
-
//#endregion
|
|
73
71
|
export { type BackupCodeOptions, type OTPOptions, type TOTPOptions, TWO_FACTOR_ERROR_CODES, type TwoFactorOptions, type TwoFactorProvider, type TwoFactorTable, type UserWithTwoFactor, type backupCode2fa, type encodeBackupCodes, type generateBackupCodes, type getBackupCodes, type otp2fa, type totp2fa, type verifyBackupCode };
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { PACKAGE_VERSION } from "../../version.mjs";
|
|
2
2
|
import { TWO_FACTOR_ERROR_CODES } from "./error-code.mjs";
|
|
3
3
|
import { isSafeUrlScheme } from "@better-auth/core/utils/url";
|
|
4
|
-
|
|
4
|
+
// src/plugins/two-factor/client.ts
|
|
5
5
|
const twoFactorClient = (options) => {
|
|
6
6
|
return {
|
|
7
7
|
id: "two-factor",
|
|
@@ -37,5 +37,4 @@ const twoFactorClient = (options) => {
|
|
|
37
37
|
$ERROR_CODES: TWO_FACTOR_ERROR_CODES
|
|
38
38
|
};
|
|
39
39
|
};
|
|
40
|
-
//#endregion
|
|
41
40
|
export { TWO_FACTOR_ERROR_CODES, twoFactorClient };
|
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
|
|
1
|
+
// src/plugins/two-factor/constant.ts
|
|
2
2
|
const TWO_FACTOR_COOKIE_NAME = "two_factor";
|
|
3
3
|
const TRUST_DEVICE_COOKIE_NAME = "trust_device";
|
|
4
4
|
const TRUST_DEVICE_COOKIE_MAX_AGE = 2592e3;
|
|
5
|
-
//#endregion
|
|
6
5
|
export { TRUST_DEVICE_COOKIE_MAX_AGE, TRUST_DEVICE_COOKIE_NAME, TWO_FACTOR_COOKIE_NAME };
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
//#region src/plugins/two-factor/error-code.d.ts
|
|
2
1
|
export declare const TWO_FACTOR_ERROR_CODES: {
|
|
3
2
|
OTP_NOT_ENABLED: import("@better-auth/core/utils/error-codes").RawError<"OTP_NOT_ENABLED">;
|
|
4
3
|
OTP_NOT_CONFIGURED: import("@better-auth/core/utils/error-codes").RawError<"OTP_NOT_CONFIGURED">;
|
|
@@ -13,5 +12,4 @@ export declare const TWO_FACTOR_ERROR_CODES: {
|
|
|
13
12
|
TOO_MANY_ATTEMPTS_REQUEST_NEW_CODE: import("@better-auth/core/utils/error-codes").RawError<"TOO_MANY_ATTEMPTS_REQUEST_NEW_CODE">;
|
|
14
13
|
ACCOUNT_TEMPORARILY_LOCKED: import("@better-auth/core/utils/error-codes").RawError<"ACCOUNT_TEMPORARILY_LOCKED">;
|
|
15
14
|
INVALID_TWO_FACTOR_COOKIE: import("@better-auth/core/utils/error-codes").RawError<"INVALID_TWO_FACTOR_COOKIE">;
|
|
16
|
-
};
|
|
17
|
-
//#endregion
|
|
15
|
+
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { defineErrorCodes } from "@better-auth/core/utils/error-codes";
|
|
2
|
-
|
|
2
|
+
// src/plugins/two-factor/error-code.ts
|
|
3
3
|
const TWO_FACTOR_ERROR_CODES = defineErrorCodes({
|
|
4
4
|
OTP_NOT_ENABLED: "OTP not enabled",
|
|
5
5
|
OTP_NOT_CONFIGURED: "OTP is not available",
|
|
@@ -15,5 +15,4 @@ const TWO_FACTOR_ERROR_CODES = defineErrorCodes({
|
|
|
15
15
|
ACCOUNT_TEMPORARILY_LOCKED: "Too many failed verification attempts. Your account is temporarily locked. Please try again later.",
|
|
16
16
|
INVALID_TWO_FACTOR_COOKIE: "Invalid two factor cookie"
|
|
17
17
|
});
|
|
18
|
-
//#endregion
|
|
19
18
|
export { TWO_FACTOR_ERROR_CODES };
|
|
@@ -6,7 +6,6 @@ import { TWO_FACTOR_ERROR_CODES } from "./error-code.mjs";
|
|
|
6
6
|
import { twoFactorClient } from "./client.mjs";
|
|
7
7
|
import { GenericEndpointContext } from "@better-auth/core";
|
|
8
8
|
import * as z from "zod";
|
|
9
|
-
//#region src/plugins/two-factor/index.d.ts
|
|
10
9
|
declare module "@better-auth/core" {
|
|
11
10
|
interface BetterAuthPluginRegistry<AuthOptions, Options> {
|
|
12
11
|
"two-factor": {
|
|
@@ -719,5 +718,4 @@ export declare const twoFactor: <O extends TwoFactorOptions>(options?: O) => {
|
|
|
719
718
|
INVALID_TWO_FACTOR_COOKIE: import("@better-auth/core/utils/error-codes").RawError<"INVALID_TWO_FACTOR_COOKIE">;
|
|
720
719
|
};
|
|
721
720
|
};
|
|
722
|
-
//#endregion
|
|
723
721
|
export { type BackupCodeOptions, type OTPOptions, type TOTPOptions, TWO_FACTOR_ERROR_CODES, TwoFactorOptions, TwoFactorProvider, TwoFactorTable, UserWithTwoFactor, type backupCode2fa, type encodeBackupCodes, type generateBackupCodes, type getBackupCodes, type otp2fa, type totp2fa, twoFactorClient, type verifyBackupCode };
|
|
@@ -1,24 +1,24 @@
|
|
|
1
|
-
import { mergeSchema } from "../../db/schema.mjs";
|
|
2
|
-
import { generateRandomString } from "../../crypto/random.mjs";
|
|
3
|
-
import { symmetricEncrypt } from "../../crypto/index.mjs";
|
|
4
|
-
import { deleteSessionCookie, expireCookie, setSessionCookie } from "../../cookies/index.mjs";
|
|
5
1
|
import { getAuthoritativeSessionFromCtx, sensitiveSessionMiddleware, sessionMiddleware } from "../../api/routes/session.mjs";
|
|
6
|
-
import { shouldRequirePassword, validatePassword } from "../../utils/password.mjs";
|
|
7
2
|
import { isSessionOutsideStore } from "../../api/state/session-source.mjs";
|
|
3
|
+
import { deleteSessionCookie, expireCookie, setSessionCookie } from "../../cookies/index.mjs";
|
|
4
|
+
import { symmetricEncrypt } from "../../crypto/index.mjs";
|
|
5
|
+
import { generateRandomString } from "../../crypto/random.mjs";
|
|
6
|
+
import { mergeSchema } from "../../db/schema.mjs";
|
|
7
|
+
import { shouldRequirePassword, validatePassword } from "../../utils/password.mjs";
|
|
8
8
|
import { PACKAGE_VERSION } from "../../version.mjs";
|
|
9
|
-
import { TWO_FACTOR_ERROR_CODES } from "./error-code.mjs";
|
|
10
|
-
import { twoFactorClient } from "./client.mjs";
|
|
11
|
-
import { TRUST_DEVICE_COOKIE_NAME, TWO_FACTOR_COOKIE_NAME } from "./constant.mjs";
|
|
12
9
|
import { backupCode2fa, generateBackupCodes } from "./backup-codes/index.mjs";
|
|
10
|
+
import { TRUST_DEVICE_COOKIE_NAME, TWO_FACTOR_COOKIE_NAME } from "./constant.mjs";
|
|
11
|
+
import { TWO_FACTOR_ERROR_CODES } from "./error-code.mjs";
|
|
13
12
|
import { otp2fa } from "./otp/index.mjs";
|
|
14
13
|
import { schema } from "./schema.mjs";
|
|
15
14
|
import { totp2fa } from "./totp/index.mjs";
|
|
15
|
+
import { twoFactorClient } from "./client.mjs";
|
|
16
16
|
import { APIError, BASE_ERROR_CODES } from "@better-auth/core/error";
|
|
17
17
|
import { createAuthEndpoint, createAuthMiddleware } from "@better-auth/core/api";
|
|
18
18
|
import * as z from "zod";
|
|
19
19
|
import { createHMAC } from "@better-auth/utils/hmac";
|
|
20
20
|
import { createOTP } from "@better-auth/utils/otp";
|
|
21
|
-
|
|
21
|
+
// src/plugins/two-factor/index.ts
|
|
22
22
|
const signInPaths = /* @__PURE__ */ new Set([
|
|
23
23
|
"/sign-in/email",
|
|
24
24
|
"/sign-in/username",
|
|
@@ -396,5 +396,4 @@ const twoFactor = (options) => {
|
|
|
396
396
|
$ERROR_CODES: TWO_FACTOR_ERROR_CODES
|
|
397
397
|
};
|
|
398
398
|
};
|
|
399
|
-
//#endregion
|
|
400
399
|
export { TWO_FACTOR_ERROR_CODES, twoFactor, twoFactorClient };
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { UserWithTwoFactor } from "../types.mjs";
|
|
2
2
|
import { Awaitable, GenericEndpointContext } from "@better-auth/core";
|
|
3
3
|
import * as z from "zod";
|
|
4
|
-
//#region src/plugins/two-factor/otp/index.d.ts
|
|
5
4
|
export interface OTPOptions {
|
|
6
5
|
/**
|
|
7
6
|
* How long the opt will be valid for in
|
|
@@ -209,5 +208,4 @@ export declare const otp2fa: (options?: OTPOptions | undefined) => {
|
|
|
209
208
|
} & Record<string, any>;
|
|
210
209
|
}>;
|
|
211
210
|
};
|
|
212
|
-
};
|
|
213
|
-
//#endregion
|
|
211
|
+
};
|
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { setSessionCookie } from "../../../cookies/index.mjs";
|
|
2
2
|
import { constantTimeEqual } from "../../../crypto/buffer.mjs";
|
|
3
3
|
import { generateRandomString } from "../../../crypto/random.mjs";
|
|
4
4
|
import { symmetricDecrypt, symmetricEncrypt } from "../../../crypto/index.mjs";
|
|
5
|
-
import {
|
|
5
|
+
import { parseUserOutput } from "../../../db/schema.mjs";
|
|
6
6
|
import { PACKAGE_VERSION } from "../../../version.mjs";
|
|
7
7
|
import { TWO_FACTOR_ERROR_CODES } from "../error-code.mjs";
|
|
8
|
-
import { assertTwoFactorNotLocked, recordTwoFactorFailure, resetTwoFactorFailures, verifyTwoFactor } from "../verify-two-factor.mjs";
|
|
9
8
|
import { defaultKeyHasher } from "../utils.mjs";
|
|
9
|
+
import { assertTwoFactorNotLocked, recordTwoFactorFailure, resetTwoFactorFailures, verifyTwoFactor } from "../verify-two-factor.mjs";
|
|
10
10
|
import { APIError, BASE_ERROR_CODES } from "@better-auth/core/error";
|
|
11
11
|
import { createAuthEndpoint } from "@better-auth/core/api";
|
|
12
12
|
import * as z from "zod";
|
|
13
|
-
|
|
13
|
+
// src/plugins/two-factor/otp/index.ts
|
|
14
14
|
const verifyOTPBodySchema = z.object({
|
|
15
15
|
code: z.string().meta({ description: "The otp code to verify. Eg: \"012345\"" }),
|
|
16
16
|
/**
|
|
@@ -253,5 +253,4 @@ const otp2fa = (options) => {
|
|
|
253
253
|
}
|
|
254
254
|
};
|
|
255
255
|
};
|
|
256
|
-
//#endregion
|
|
257
256
|
export { otp2fa };
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { BackupCodeOptions } from "../backup-codes/index.mjs";
|
|
2
2
|
import { UserWithTwoFactor } from "../types.mjs";
|
|
3
3
|
import * as z from "zod";
|
|
4
|
-
//#region src/plugins/two-factor/totp/index.d.ts
|
|
5
4
|
export type TOTPOptions = {
|
|
6
5
|
/**
|
|
7
6
|
* Issuer
|
|
@@ -212,5 +211,4 @@ export declare const totp2fa: (options?: TOTPOptions | undefined) => {
|
|
|
212
211
|
} & Record<string, any>;
|
|
213
212
|
}>;
|
|
214
213
|
};
|
|
215
|
-
};
|
|
216
|
-
//#endregion
|
|
214
|
+
};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { symmetricDecrypt } from "../../../crypto/index.mjs";
|
|
2
|
-
import { setSessionCookie } from "../../../cookies/index.mjs";
|
|
3
1
|
import { sessionMiddleware } from "../../../api/routes/session.mjs";
|
|
2
|
+
import { setSessionCookie } from "../../../cookies/index.mjs";
|
|
3
|
+
import { symmetricDecrypt } from "../../../crypto/index.mjs";
|
|
4
4
|
import { shouldRequirePassword } from "../../../utils/password.mjs";
|
|
5
5
|
import { PACKAGE_VERSION } from "../../../version.mjs";
|
|
6
6
|
import { TWO_FACTOR_ERROR_CODES } from "../error-code.mjs";
|
|
@@ -10,7 +10,7 @@ import { createAuthEndpoint } from "@better-auth/core/api";
|
|
|
10
10
|
import * as z from "zod";
|
|
11
11
|
import { createOTP } from "@better-auth/utils/otp";
|
|
12
12
|
import { base32 } from "@better-auth/utils/base32";
|
|
13
|
-
|
|
13
|
+
// src/plugins/two-factor/totp/index.ts
|
|
14
14
|
const BASE32_PREFIX = "base32:";
|
|
15
15
|
/**
|
|
16
16
|
* Secrets imported from other providers are stored as `base32:<secret>`.
|
|
@@ -242,5 +242,4 @@ const totp2fa = (options) => {
|
|
|
242
242
|
}
|
|
243
243
|
};
|
|
244
244
|
};
|
|
245
|
-
//#endregion
|
|
246
245
|
export { totp2fa };
|
|
@@ -6,7 +6,6 @@ import { OTPOptions } from "./otp/index.mjs";
|
|
|
6
6
|
import { schema } from "./schema.mjs";
|
|
7
7
|
import { TOTPOptions } from "./totp/index.mjs";
|
|
8
8
|
import { BetterAuthPlugin, LiteralString } from "@better-auth/core";
|
|
9
|
-
//#region src/plugins/two-factor/types.d.ts
|
|
10
9
|
export interface TwoFactorOptions {
|
|
11
10
|
/**
|
|
12
11
|
* Application Name
|
|
@@ -106,5 +105,4 @@ export interface TwoFactorTable {
|
|
|
106
105
|
verified: boolean;
|
|
107
106
|
failedVerificationCount?: number;
|
|
108
107
|
lockedUntil?: Date | null;
|
|
109
|
-
}
|
|
110
|
-
//#endregion
|
|
108
|
+
}
|
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
import { base64Url } from "@better-auth/utils/base64";
|
|
2
2
|
import { createHash } from "@better-auth/utils/hash";
|
|
3
|
-
|
|
3
|
+
// src/plugins/two-factor/utils.ts
|
|
4
4
|
const defaultKeyHasher = async (token) => {
|
|
5
5
|
const hash = await createHash("SHA-256").digest(new TextEncoder().encode(token));
|
|
6
6
|
return base64Url.encode(new Uint8Array(hash), { padding: false });
|
|
7
7
|
};
|
|
8
|
-
//#endregion
|
|
9
8
|
export { defaultKeyHasher };
|
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import { parseUserOutput } from "../../db/schema.mjs";
|
|
2
|
-
import { generateRandomString } from "../../crypto/random.mjs";
|
|
3
|
-
import { expireCookie, setSessionCookie } from "../../cookies/index.mjs";
|
|
4
1
|
import { getAuthoritativeSessionFromCtx } from "../../api/routes/session.mjs";
|
|
5
2
|
import { isSessionOutsideStore } from "../../api/state/session-source.mjs";
|
|
6
|
-
import {
|
|
3
|
+
import { expireCookie, setSessionCookie } from "../../cookies/index.mjs";
|
|
4
|
+
import { generateRandomString } from "../../crypto/random.mjs";
|
|
5
|
+
import { parseUserOutput } from "../../db/schema.mjs";
|
|
7
6
|
import { TRUST_DEVICE_COOKIE_NAME, TWO_FACTOR_COOKIE_NAME } from "./constant.mjs";
|
|
7
|
+
import { TWO_FACTOR_ERROR_CODES } from "./error-code.mjs";
|
|
8
8
|
import { APIError } from "@better-auth/core/error";
|
|
9
9
|
import { createHMAC } from "@better-auth/utils/hmac";
|
|
10
|
-
|
|
10
|
+
// src/plugins/two-factor/verify-two-factor.ts
|
|
11
11
|
async function verifyTwoFactor(ctx) {
|
|
12
12
|
const invalid = (errorKey) => {
|
|
13
13
|
throw APIError.from("UNAUTHORIZED", TWO_FACTOR_ERROR_CODES[errorKey]);
|
|
@@ -203,5 +203,4 @@ async function resetTwoFactorFailures(ctx, twoFactorTable, twoFactor) {
|
|
|
203
203
|
}
|
|
204
204
|
});
|
|
205
205
|
}
|
|
206
|
-
//#endregion
|
|
207
206
|
export { assertTwoFactorNotLocked, recordTwoFactorFailure, resetTwoFactorFailures, verifyTwoFactor };
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { USERNAME_ERROR_CODES } from "./error-codes.mjs";
|
|
2
2
|
import { UsernamePlugin, UsernamePluginWithoutDisplayUsername } from "./index.mjs";
|
|
3
|
-
//#region src/plugins/username/client.d.ts
|
|
4
3
|
export type UsernameClientOptions = {
|
|
5
4
|
/**
|
|
6
5
|
* Whether the server has the `displayUsername` field enabled.
|
|
@@ -32,5 +31,4 @@ export declare const usernameClient: <O extends UsernameClientOptions = Username
|
|
|
32
31
|
USERNAME_IS_IMMUTABLE: import("@better-auth/core/utils/error-codes").RawError<"USERNAME_IS_IMMUTABLE">;
|
|
33
32
|
};
|
|
34
33
|
};
|
|
35
|
-
//#endregion
|
|
36
34
|
export { USERNAME_ERROR_CODES };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { PACKAGE_VERSION } from "../../version.mjs";
|
|
2
2
|
import { USERNAME_ERROR_CODES } from "./error-codes.mjs";
|
|
3
|
-
|
|
3
|
+
// src/plugins/username/client.ts
|
|
4
4
|
const usernameClient = (options) => {
|
|
5
5
|
return {
|
|
6
6
|
id: "username",
|
|
@@ -13,5 +13,4 @@ const usernameClient = (options) => {
|
|
|
13
13
|
$ERROR_CODES: USERNAME_ERROR_CODES
|
|
14
14
|
};
|
|
15
15
|
};
|
|
16
|
-
//#endregion
|
|
17
16
|
export { USERNAME_ERROR_CODES, usernameClient };
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
//#region src/plugins/username/error-codes.d.ts
|
|
2
1
|
export declare const USERNAME_ERROR_CODES: {
|
|
3
2
|
EMAIL_NOT_VERIFIED: import("@better-auth/core/utils/error-codes").RawError<"EMAIL_NOT_VERIFIED">;
|
|
4
3
|
UNEXPECTED_ERROR: import("@better-auth/core/utils/error-codes").RawError<"UNEXPECTED_ERROR">;
|
|
@@ -9,5 +8,4 @@ export declare const USERNAME_ERROR_CODES: {
|
|
|
9
8
|
INVALID_USERNAME: import("@better-auth/core/utils/error-codes").RawError<"INVALID_USERNAME">;
|
|
10
9
|
INVALID_DISPLAY_USERNAME: import("@better-auth/core/utils/error-codes").RawError<"INVALID_DISPLAY_USERNAME">;
|
|
11
10
|
USERNAME_IS_IMMUTABLE: import("@better-auth/core/utils/error-codes").RawError<"USERNAME_IS_IMMUTABLE">;
|
|
12
|
-
};
|
|
13
|
-
//#endregion
|
|
11
|
+
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { defineErrorCodes } from "@better-auth/core/utils/error-codes";
|
|
2
|
-
|
|
2
|
+
// src/plugins/username/error-codes.ts
|
|
3
3
|
const USERNAME_ERROR_CODES = defineErrorCodes({
|
|
4
4
|
INVALID_USERNAME_OR_PASSWORD: "Invalid username or password",
|
|
5
5
|
EMAIL_NOT_VERIFIED: "Email not verified",
|
|
@@ -11,5 +11,4 @@ const USERNAME_ERROR_CODES = defineErrorCodes({
|
|
|
11
11
|
INVALID_DISPLAY_USERNAME: "Display username is invalid",
|
|
12
12
|
USERNAME_IS_IMMUTABLE: "Username cannot be updated"
|
|
13
13
|
});
|
|
14
|
-
//#endregion
|
|
15
14
|
export { USERNAME_ERROR_CODES };
|
|
@@ -2,7 +2,6 @@ import { InferOptionSchema } from "../../types/plugins.mjs";
|
|
|
2
2
|
import { UsernameSchema } from "./schema.mjs";
|
|
3
3
|
import { USERNAME_ERROR_CODES } from "./error-codes.mjs";
|
|
4
4
|
import * as z from "zod";
|
|
5
|
-
//#region src/plugins/username/index.d.ts
|
|
6
5
|
declare module "@better-auth/core" {
|
|
7
6
|
interface BetterAuthPluginRegistry<AuthOptions, Options> {
|
|
8
7
|
username: {
|
|
@@ -317,5 +316,4 @@ export declare function username(options: UsernameOptions & {
|
|
|
317
316
|
displayUsername: false;
|
|
318
317
|
}): UsernamePluginWithoutDisplayUsername;
|
|
319
318
|
export declare function username(options?: UsernameOptions): UsernamePlugin;
|
|
320
|
-
//#endregion
|
|
321
319
|
export { USERNAME_ERROR_CODES };
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { mergeSchema, parseUserOutput } from "../../db/schema.mjs";
|
|
2
|
-
import { setSessionCookie } from "../../cookies/index.mjs";
|
|
3
|
-
import { getSessionFromCtx } from "../../api/routes/session.mjs";
|
|
4
1
|
import { createEmailVerificationToken } from "../../api/routes/email-verification.mjs";
|
|
2
|
+
import { getSessionFromCtx } from "../../api/routes/session.mjs";
|
|
3
|
+
import { setSessionCookie } from "../../cookies/index.mjs";
|
|
4
|
+
import { mergeSchema, parseUserOutput } from "../../db/schema.mjs";
|
|
5
5
|
import { assertPasswordNotTooLong } from "../../utils/password.mjs";
|
|
6
6
|
import { PACKAGE_VERSION } from "../../version.mjs";
|
|
7
7
|
import { USERNAME_ERROR_CODES } from "./error-codes.mjs";
|
|
@@ -10,7 +10,7 @@ import { getCurrentAdapter } from "@better-auth/core/context";
|
|
|
10
10
|
import { APIError, BASE_ERROR_CODES } from "@better-auth/core/error";
|
|
11
11
|
import { createAuthEndpoint, createAuthMiddleware } from "@better-auth/core/api";
|
|
12
12
|
import * as z from "zod";
|
|
13
|
-
|
|
13
|
+
// src/plugins/username/index.ts
|
|
14
14
|
function defaultUsernameValidator(username) {
|
|
15
15
|
return /^[a-zA-Z0-9_.]+$/.test(username);
|
|
16
16
|
}
|
|
@@ -298,5 +298,4 @@ const usernameImpl = (options, includeDisplayUsername) => {
|
|
|
298
298
|
function username(options) {
|
|
299
299
|
return usernameImpl(options, options?.displayUsername !== false);
|
|
300
300
|
}
|
|
301
|
-
//#endregion
|
|
302
301
|
export { USERNAME_ERROR_CODES, username };
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
//#region src/plugins/username/schema.d.ts
|
|
2
1
|
export declare const getSchema: <IncludeDisplayUsername extends boolean = true>(normalizer: {
|
|
3
2
|
username: (username: string) => string;
|
|
4
3
|
displayUsername: (displayUsername: string) => string;
|
|
@@ -43,5 +42,4 @@ export declare const getSchema: <IncludeDisplayUsername extends boolean = true>(
|
|
|
43
42
|
};
|
|
44
43
|
};
|
|
45
44
|
};
|
|
46
|
-
export type UsernameSchema = ReturnType<typeof getSchema<true>>;
|
|
47
|
-
//#endregion
|
|
45
|
+
export type UsernameSchema = ReturnType<typeof getSchema<true>>;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
// src/plugins/username/schema.ts
|
|
2
2
|
const getSchema = (normalizer, includeDisplayUsername = true) => {
|
|
3
3
|
const fields = {
|
|
4
4
|
username: {
|
|
@@ -21,5 +21,4 @@ const getSchema = (normalizer, includeDisplayUsername = true) => {
|
|
|
21
21
|
};
|
|
22
22
|
return { user: { fields: includeDisplayUsername ? fields : { username: fields.username } } };
|
|
23
23
|
};
|
|
24
|
-
//#endregion
|
|
25
24
|
export { getSchema };
|
package/dist/state.d.mts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { GenericEndpointContext } from "@better-auth/core";
|
|
2
2
|
import { BetterAuthError } from "@better-auth/core/error";
|
|
3
3
|
import * as z from "zod";
|
|
4
|
-
|
|
4
|
+
import { getAuthStateVerificationIdentifier } from "@better-auth/core/utils/state";
|
|
5
5
|
declare const stateDataSchema: z.ZodObject<{
|
|
6
6
|
callbackURL: z.ZodString;
|
|
7
7
|
codeVerifier: z.ZodString;
|
|
@@ -19,10 +19,6 @@ declare const stateDataSchema: z.ZodObject<{
|
|
|
19
19
|
serverContext: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
20
20
|
}, z.core.$loose>;
|
|
21
21
|
export type StateData = z.infer<typeof stateDataSchema>;
|
|
22
|
-
/**
|
|
23
|
-
* Verification key for database-backed OAuth and SAML relay state.
|
|
24
|
-
*/
|
|
25
|
-
export declare const getAuthStateVerificationIdentifier: (state: string) => string;
|
|
26
22
|
export declare function generateGenericState(c: GenericEndpointContext, stateData: StateData, settings?: {
|
|
27
23
|
cookieName: string;
|
|
28
24
|
}): Promise<{
|
|
@@ -49,5 +45,4 @@ export declare function parseGenericState(c: GenericEndpointContext, state: stri
|
|
|
49
45
|
idTokenNonce?: string | undefined;
|
|
50
46
|
serverContext?: Record<string, unknown> | undefined;
|
|
51
47
|
}>;
|
|
52
|
-
|
|
53
|
-
export {};
|
|
48
|
+
export { getAuthStateVerificationIdentifier };
|
package/dist/state.mjs
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import { generateRandomString } from "./crypto/random.mjs";
|
|
2
|
-
import { symmetricDecrypt, symmetricEncrypt } from "./crypto/index.mjs";
|
|
3
2
|
import { expireCookie } from "./cookies/index.mjs";
|
|
3
|
+
import { symmetricDecrypt, symmetricEncrypt } from "./crypto/index.mjs";
|
|
4
4
|
import { derivePurposeKey } from "./crypto/purpose.mjs";
|
|
5
5
|
import { BetterAuthError } from "@better-auth/core/error";
|
|
6
6
|
import * as z from "zod";
|
|
7
|
-
|
|
7
|
+
import { getAuthStateVerificationIdentifier } from "@better-auth/core/utils/state";
|
|
8
|
+
// src/state.ts
|
|
8
9
|
const stateDataSchema = z.looseObject({
|
|
9
10
|
callbackURL: z.string(),
|
|
10
11
|
codeVerifier: z.string(),
|
|
@@ -34,10 +35,6 @@ const stateDataSchema = z.looseObject({
|
|
|
34
35
|
*/
|
|
35
36
|
serverContext: z.record(z.string(), z.unknown()).optional()
|
|
36
37
|
});
|
|
37
|
-
/**
|
|
38
|
-
* Verification key for database-backed OAuth and SAML relay state.
|
|
39
|
-
*/
|
|
40
|
-
const getAuthStateVerificationIdentifier = (state) => `auth-state:${state}`;
|
|
41
38
|
const INTERNAL_STATE_KEYS = new Set(Object.keys(stateDataSchema.shape));
|
|
42
39
|
var StateError = class extends BetterAuthError {
|
|
43
40
|
code;
|
|
@@ -150,5 +147,4 @@ async function parseGenericState(c, state, settings) {
|
|
|
150
147
|
});
|
|
151
148
|
return parsedData;
|
|
152
149
|
}
|
|
153
|
-
//#endregion
|
|
154
150
|
export { INTERNAL_STATE_KEYS, StateError, generateGenericState, getAuthStateVerificationIdentifier, parseGenericState };
|
|
@@ -1,7 +1,5 @@
|
|
|
1
|
-
//#region src/test-utils/headers.d.ts
|
|
2
1
|
/**
|
|
3
2
|
* converts set cookie containing headers to
|
|
4
3
|
* cookie containing headers
|
|
5
4
|
*/
|
|
6
|
-
export declare function convertSetCookieToCookie(headers: Headers): Headers;
|
|
7
|
-
//#endregion
|
|
5
|
+
export declare function convertSetCookieToCookie(headers: Headers): Headers;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { applySetCookies } from "../cookies/cookie-utils.mjs";
|
|
2
|
-
|
|
2
|
+
// src/test-utils/headers.ts
|
|
3
3
|
/**
|
|
4
4
|
* converts set cookie containing headers to
|
|
5
5
|
* cookie containing headers
|
|
@@ -13,5 +13,4 @@ function convertSetCookieToCookie(headers) {
|
|
|
13
13
|
applySetCookies(headers, setCookieHeaders);
|
|
14
14
|
return headers;
|
|
15
15
|
}
|
|
16
|
-
//#endregion
|
|
17
16
|
export { convertSetCookieToCookie };
|
|
@@ -7,7 +7,6 @@ import { getTestInstance } from "./test-instance.mjs";
|
|
|
7
7
|
import { BetterAuthClientOptions, BetterAuthOptions } from "@better-auth/core";
|
|
8
8
|
import { IncomingMessage, ServerResponse, createServer } from "node:http";
|
|
9
9
|
import { AddressInfo } from "node:net";
|
|
10
|
-
//#region src/test-utils/http-test-instance.d.ts
|
|
11
10
|
/** A Node request handler that can be installed on an HTTP test listener. */
|
|
12
11
|
export type HttpTestRequestHandler = (req: IncomingMessage, res: ServerResponse) => unknown | Promise<unknown>;
|
|
13
12
|
/** A bound HTTP test listener whose request handler can be installed later. */
|
|
@@ -406,5 +405,4 @@ export declare function getHttpTestInstance<O extends Partial<BetterAuthOptions>
|
|
|
406
405
|
db: import("@better-auth/core/db/adapter").DBAdapter<BetterAuthOptions>;
|
|
407
406
|
runWithUser: (email: string, password: string, fn: (headers: Headers) => import("@better-auth/core").Awaitable<void>) => Promise<void>;
|
|
408
407
|
}>;
|
|
409
|
-
//#endregion
|
|
410
408
|
export {};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { toNodeHandler } from "../integrations/node.mjs";
|
|
2
2
|
import { getTestInstance } from "./test-instance.mjs";
|
|
3
3
|
import { createServer } from "node:http";
|
|
4
|
-
|
|
4
|
+
// src/test-utils/http-test-instance.ts
|
|
5
5
|
const closeHttpServer = (server) => new Promise((resolve, reject) => {
|
|
6
6
|
server.close((error) => {
|
|
7
7
|
if (error) {
|
|
@@ -103,5 +103,4 @@ async function getHttpTestInstance(options, config) {
|
|
|
103
103
|
throw error;
|
|
104
104
|
}
|
|
105
105
|
}
|
|
106
|
-
//#endregion
|
|
107
106
|
export { createHttpTestServer, getHttpTestInstance };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { convertSetCookieToCookie } from "./headers.mjs";
|
|
2
|
-
import { getTestInstance } from "./test-instance.mjs";
|
|
3
2
|
import { HttpTestInstanceConfig, HttpTestRequestHandler, HttpTestServer, createHttpTestServer, getHttpTestInstance } from "./http-test-instance.mjs";
|
|
3
|
+
import { getTestInstance } from "./test-instance.mjs";
|
|
4
4
|
export { type HttpTestInstanceConfig, type HttpTestRequestHandler, type HttpTestServer, convertSetCookieToCookie, createHttpTestServer, getHttpTestInstance, getTestInstance };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { convertSetCookieToCookie } from "./headers.mjs";
|
|
2
|
-
import { getTestInstance } from "./test-instance.mjs";
|
|
3
2
|
import { createHttpTestServer, getHttpTestInstance } from "./http-test-instance.mjs";
|
|
3
|
+
import { getTestInstance } from "./test-instance.mjs";
|
|
4
4
|
export { convertSetCookieToCookie, createHttpTestServer, getHttpTestInstance, getTestInstance };
|
|
@@ -1,14 +1,13 @@
|
|
|
1
1
|
import { Session, User } from "../types/models.mjs";
|
|
2
2
|
import { Auth } from "../types/auth.mjs";
|
|
3
|
-
import "../types/index.mjs";
|
|
4
3
|
import "../index.mjs";
|
|
5
|
-
import { AuthClient } from "../client/vanilla.mjs";
|
|
6
4
|
import "../client/index.mjs";
|
|
7
|
-
import {
|
|
5
|
+
import { AuthClient } from "../client/vanilla.mjs";
|
|
8
6
|
import "../cookies/index.mjs";
|
|
7
|
+
import { setCookieToHeader } from "../cookies/cookie-utils.mjs";
|
|
8
|
+
import "../types/index.mjs";
|
|
9
9
|
import { Awaitable, BetterAuthClientOptions, BetterAuthOptions } from "@better-auth/core";
|
|
10
10
|
import { SuccessContext } from "@better-fetch/fetch";
|
|
11
|
-
//#region src/test-utils/test-instance.d.ts
|
|
12
11
|
export declare function getTestInstance<O extends Partial<BetterAuthOptions>, C extends BetterAuthClientOptions>(options?: O | undefined, config?: {
|
|
13
12
|
clientOptions?: C;
|
|
14
13
|
port?: number;
|
|
@@ -53,5 +52,4 @@ export declare function getTestInstance<O extends Partial<BetterAuthOptions>, C
|
|
|
53
52
|
sessionSetter: (headers: Headers) => (context: SuccessContext) => void;
|
|
54
53
|
db: import("@better-auth/core/db/adapter").DBAdapter<BetterAuthOptions>;
|
|
55
54
|
runWithUser: (email: string, password: string, fn: (headers: Headers) => Awaitable<void>) => Promise<void>;
|
|
56
|
-
}>;
|
|
57
|
-
//#endregion
|
|
55
|
+
}>;
|