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
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
// src/plugins/phone-number/schema.ts
|
|
2
2
|
const schema = { user: { fields: {
|
|
3
3
|
phoneNumber: {
|
|
4
4
|
type: "string",
|
|
@@ -14,5 +14,4 @@ const schema = { user: { fields: {
|
|
|
14
14
|
input: false
|
|
15
15
|
}
|
|
16
16
|
} } };
|
|
17
|
-
//#endregion
|
|
18
17
|
export { schema };
|
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
import { User } from "../../types/models.mjs";
|
|
2
|
-
import { InferOptionSchema } from "../../types/plugins.mjs";
|
|
3
2
|
import "../../types/index.mjs";
|
|
3
|
+
import { InferOptionSchema } from "../../types/plugins.mjs";
|
|
4
4
|
import { schema } from "./schema.mjs";
|
|
5
5
|
import { Awaitable, GenericEndpointContext } from "@better-auth/core";
|
|
6
|
-
//#region src/plugins/phone-number/types.d.ts
|
|
7
6
|
export interface UserWithPhoneNumber extends User {
|
|
8
7
|
phoneNumber: string;
|
|
9
8
|
phoneNumberVerified: boolean;
|
|
@@ -111,5 +110,4 @@ export interface PhoneNumberOptions {
|
|
|
111
110
|
* @default 3
|
|
112
111
|
*/
|
|
113
112
|
allowedAttempts?: number | undefined;
|
|
114
|
-
}
|
|
115
|
-
//#endregion
|
|
113
|
+
}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { siwe } from "./index.mjs";
|
|
2
|
-
//#region src/plugins/siwe/client.d.ts
|
|
3
2
|
export declare const siweClient: () => {
|
|
4
3
|
id: "siwe";
|
|
5
4
|
version: string;
|
|
@@ -8,5 +7,4 @@ export declare const siweClient: () => {
|
|
|
8
7
|
"/siwe/nonce": "POST";
|
|
9
8
|
"/siwe/get-nonce": "POST";
|
|
10
9
|
};
|
|
11
|
-
};
|
|
12
|
-
//#endregion
|
|
10
|
+
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { PACKAGE_VERSION } from "../../version.mjs";
|
|
2
|
-
|
|
2
|
+
// src/plugins/siwe/client.ts
|
|
3
3
|
const siweClient = () => {
|
|
4
4
|
return {
|
|
5
5
|
id: "siwe",
|
|
@@ -11,5 +11,4 @@ const siweClient = () => {
|
|
|
11
11
|
}
|
|
12
12
|
};
|
|
13
13
|
};
|
|
14
|
-
//#endregion
|
|
15
14
|
export { siweClient };
|
|
@@ -3,7 +3,6 @@ import "../../types/index.mjs";
|
|
|
3
3
|
import { WalletAddressSchema, schema } from "./schema.mjs";
|
|
4
4
|
import { ENSLookupArgs, ENSLookupResult, SIWEVerifyMessageArgs } from "./types.mjs";
|
|
5
5
|
import * as z from "zod";
|
|
6
|
-
//#region src/plugins/siwe/index.d.ts
|
|
7
6
|
declare module "@better-auth/core" {
|
|
8
7
|
interface BetterAuthPluginRegistry<AuthOptions, Options> {
|
|
9
8
|
siwe: {
|
|
@@ -56,5 +55,4 @@ export declare const siwe: (options: SIWEPluginOptions) => {
|
|
|
56
55
|
}>;
|
|
57
56
|
};
|
|
58
57
|
options: SIWEPluginOptions;
|
|
59
|
-
};
|
|
60
|
-
//#endregion
|
|
58
|
+
};
|
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
import { isAPIError } from "../../utils/is-api-error.mjs";
|
|
2
|
-
import { mergeSchema } from "../../db/schema.mjs";
|
|
3
|
-
import { setSessionCookie } from "../../cookies/index.mjs";
|
|
4
1
|
import { APIError } from "../../api/index.mjs";
|
|
5
|
-
import {
|
|
2
|
+
import { setSessionCookie } from "../../cookies/index.mjs";
|
|
3
|
+
import { mergeSchema } from "../../db/schema.mjs";
|
|
6
4
|
import { toChecksumAddress } from "../../utils/hashing.mjs";
|
|
5
|
+
import { isAPIError } from "../../utils/is-api-error.mjs";
|
|
6
|
+
import { PACKAGE_VERSION } from "../../version.mjs";
|
|
7
7
|
import { normalizeSiweDomain, parseSiweMessage } from "./parse-message.mjs";
|
|
8
8
|
import { schema } from "./schema.mjs";
|
|
9
9
|
import { getCurrentAdapter, runWithTransaction } from "@better-auth/core/context";
|
|
10
10
|
import { createAuthEndpoint } from "@better-auth/core/api";
|
|
11
11
|
import * as z from "zod";
|
|
12
12
|
import { createPlaceholderEmail } from "@better-auth/core/utils/email";
|
|
13
|
-
|
|
13
|
+
// src/plugins/siwe/index.ts
|
|
14
14
|
const signedWalletAddressSchema = z.string().regex(/^0x[a-fA-F0-9]{40}$/).length(42);
|
|
15
15
|
const SIWE_VERIFICATION_IDENTIFIER_PREFIX = "siwe:";
|
|
16
16
|
const SIWE_NONCE_MAX_LENGTH = 250;
|
|
@@ -285,5 +285,4 @@ const siwe = (options) => {
|
|
|
285
285
|
options
|
|
286
286
|
};
|
|
287
287
|
};
|
|
288
|
-
//#endregion
|
|
289
288
|
export { siwe };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
// src/plugins/siwe/parse-message.ts
|
|
2
2
|
const HEADER_REGEX = /^(?:([a-zA-Z][a-zA-Z0-9+.-]*):\/\/)?(\S+) wants you to sign in with your Ethereum account:$/;
|
|
3
3
|
const ADDRESS_REGEX = /^0x[a-fA-F0-9]{40}$/;
|
|
4
4
|
const FIELD_REGEX = /^([A-Za-z ]+): (.*)$/;
|
|
@@ -54,5 +54,4 @@ function normalizeSiweDomain(domain) {
|
|
|
54
54
|
const pathStart = withoutScheme.indexOf("/");
|
|
55
55
|
return pathStart === -1 ? withoutScheme : withoutScheme.slice(0, pathStart);
|
|
56
56
|
}
|
|
57
|
-
//#endregion
|
|
58
57
|
export { normalizeSiweDomain, parseSiweMessage };
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
//#region src/plugins/siwe/schema.d.ts
|
|
2
1
|
export declare const schema: {
|
|
3
2
|
walletAddress: {
|
|
4
3
|
fields: {
|
|
@@ -30,5 +29,4 @@ export declare const schema: {
|
|
|
30
29
|
};
|
|
31
30
|
};
|
|
32
31
|
};
|
|
33
|
-
export type WalletAddressSchema = typeof schema;
|
|
34
|
-
//#endregion
|
|
32
|
+
export type WalletAddressSchema = typeof schema;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
// src/plugins/siwe/schema.ts
|
|
2
2
|
const schema = { walletAddress: { fields: {
|
|
3
3
|
userId: {
|
|
4
4
|
type: "string",
|
|
@@ -26,5 +26,4 @@ const schema = { walletAddress: { fields: {
|
|
|
26
26
|
required: true
|
|
27
27
|
}
|
|
28
28
|
} } };
|
|
29
|
-
//#endregion
|
|
30
29
|
export { schema };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { createCookieHeaders, createTestCookie } from "./cookie-builder.mjs";
|
|
2
2
|
import { sessionSchema } from "@better-auth/core/db";
|
|
3
|
-
|
|
3
|
+
// src/plugins/test-utils/auth-helpers.ts
|
|
4
4
|
function createSession(ctx, opts) {
|
|
5
5
|
const additionalFields = Object.fromEntries(Object.entries(opts.session ?? {}).filter(([key]) => !Object.hasOwn(sessionSchema.shape, key)));
|
|
6
6
|
return ctx.internalAdapter.createSession(opts.userId, false, additionalFields, true);
|
|
@@ -31,5 +31,4 @@ function createGetCookies(ctx) {
|
|
|
31
31
|
return createTestCookie(ctx, session.token, opts.domain);
|
|
32
32
|
};
|
|
33
33
|
}
|
|
34
|
-
//#endregion
|
|
35
34
|
export { createGetAuthHeaders, createGetCookies, createLogin };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { makeSignature } from "../../crypto/index.mjs";
|
|
2
|
-
|
|
2
|
+
// src/plugins/test-utils/cookie-builder.ts
|
|
3
3
|
/**
|
|
4
4
|
* Signs a cookie value using HMAC-SHA256
|
|
5
5
|
*/
|
|
@@ -51,5 +51,4 @@ function normalizeSameSite(sameSite) {
|
|
|
51
51
|
}
|
|
52
52
|
return "Lax";
|
|
53
53
|
}
|
|
54
|
-
//#endregion
|
|
55
54
|
export { createCookieHeaders, createTestCookie };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { generateRandomString } from "../../crypto/random.mjs";
|
|
2
|
-
|
|
2
|
+
// src/plugins/test-utils/db-helpers.ts
|
|
3
3
|
function createSaveUser(ctx) {
|
|
4
4
|
return async (user) => {
|
|
5
5
|
return ctx.internalAdapter.createUser(user, { method: "test" });
|
|
@@ -61,5 +61,4 @@ function createAddMember(ctx) {
|
|
|
61
61
|
});
|
|
62
62
|
};
|
|
63
63
|
}
|
|
64
|
-
//#endregion
|
|
65
64
|
export { createAddMember, createDeleteOrganization, createDeleteUser, createSaveOrganization, createSaveUser };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { generateRandomString } from "../../crypto/random.mjs";
|
|
2
|
-
|
|
2
|
+
// src/plugins/test-utils/factories.ts
|
|
3
3
|
function createUserFactory(ctx) {
|
|
4
4
|
return (overrides = {}) => {
|
|
5
5
|
const generatedId = ctx.generateId({ model: "user" });
|
|
@@ -34,5 +34,4 @@ function createOrganizationFactory(ctx) {
|
|
|
34
34
|
};
|
|
35
35
|
};
|
|
36
36
|
}
|
|
37
|
-
//#endregion
|
|
38
37
|
export { createOrganizationFactory, createUserFactory };
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { LoginResult, TestAuthOptions, TestCookie, TestHelpers, TestUtilsOptions } from "./types.mjs";
|
|
2
|
-
//#region src/plugins/test-utils/index.d.ts
|
|
3
2
|
declare module "@better-auth/core" {
|
|
4
3
|
interface BetterAuthPluginRegistry<AuthOptions, Options> {
|
|
5
4
|
"test-utils": {
|
|
@@ -67,5 +66,4 @@ export declare const testUtils: (options?: TestUtilsOptions) => {
|
|
|
67
66
|
};
|
|
68
67
|
options: TestUtilsOptions;
|
|
69
68
|
};
|
|
70
|
-
//#endregion
|
|
71
69
|
export type { LoginResult, TestAuthOptions, TestCookie, TestHelpers, TestUtilsOptions };
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { PACKAGE_VERSION } from "../../version.mjs";
|
|
2
1
|
import { createGetAuthHeaders, createGetCookies, createLogin } from "./auth-helpers.mjs";
|
|
3
2
|
import { createAddMember, createDeleteOrganization, createDeleteUser, createSaveOrganization, createSaveUser } from "./db-helpers.mjs";
|
|
4
3
|
import { createOrganizationFactory, createUserFactory } from "./factories.mjs";
|
|
5
4
|
import { createOTPStore } from "./otp-sink.mjs";
|
|
6
|
-
|
|
5
|
+
import { PACKAGE_VERSION } from "../../version.mjs";
|
|
6
|
+
// src/plugins/test-utils/index.ts
|
|
7
7
|
/**
|
|
8
8
|
* Test utilities plugin for Better Auth.
|
|
9
9
|
*
|
|
@@ -93,5 +93,4 @@ const testUtils = (options = {}) => {
|
|
|
93
93
|
options
|
|
94
94
|
};
|
|
95
95
|
};
|
|
96
|
-
//#endregion
|
|
97
96
|
export { testUtils };
|
|
@@ -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 };
|