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,3 @@
|
|
|
1
|
-
import { toBoolean } from "../../utils/boolean.mjs";
|
|
2
1
|
import { PACKAGE_VERSION } from "../../version.mjs";
|
|
3
2
|
import { GENERIC_OAUTH_ERROR_CODES } from "./error-codes.mjs";
|
|
4
3
|
import { auth0 } from "./providers/auth0.mjs";
|
|
@@ -12,11 +11,11 @@ import { patreon } from "./providers/patreon.mjs";
|
|
|
12
11
|
import { slack } from "./providers/slack.mjs";
|
|
13
12
|
import { yandex } from "./providers/yandex.mjs";
|
|
14
13
|
import { APIError } from "@better-auth/core/error";
|
|
15
|
-
import { applyDefaultAccessTokenExpiry, createAuthorizationURL, refreshAccessToken, validateAuthorizationCode, verifyProviderIdToken } from "@better-auth/core/oauth2";
|
|
14
|
+
import { applyDefaultAccessTokenExpiry, createAuthorizationURL, parseStringBoolean, refreshAccessToken, validateAuthorizationCode, verifyProviderIdToken } from "@better-auth/core/oauth2";
|
|
16
15
|
import { createAuthMiddleware } from "@better-auth/core/api";
|
|
17
16
|
import { createRemoteJWKSet, decodeJwt } from "jose";
|
|
18
17
|
import { betterFetch } from "@better-fetch/fetch";
|
|
19
|
-
|
|
18
|
+
// src/plugins/generic-oauth/index.ts
|
|
20
19
|
function isSecretlessTokenEndpointAuth(tokenEndpointAuth) {
|
|
21
20
|
return tokenEndpointAuth?.method === "private_key_jwt" || tokenEndpointAuth?.method === "none";
|
|
22
21
|
}
|
|
@@ -25,6 +24,7 @@ function isClientSecretTokenEndpointAuth(tokenEndpointAuth) {
|
|
|
25
24
|
}
|
|
26
25
|
/** A request waits on a discovery retry, so bound it (the SSO plugin uses 10s too). */
|
|
27
26
|
const DISCOVERY_RETRY_TIMEOUT_MS = 1e4;
|
|
27
|
+
const MAX_DISCOVERY_REDIRECTS = 5;
|
|
28
28
|
/**
|
|
29
29
|
* Providers skipped because startup discovery failed. Init stores them on each auth
|
|
30
30
|
* instance's context, so one plugin object can serve several instances. It is a context
|
|
@@ -44,25 +44,42 @@ const readIdTokenClaims = (idToken) => {
|
|
|
44
44
|
}
|
|
45
45
|
};
|
|
46
46
|
async function fetchDiscovery(url, headers, timeout) {
|
|
47
|
-
const
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
47
|
+
const signal = timeout ? AbortSignal.timeout(timeout) : void 0;
|
|
48
|
+
let target = url;
|
|
49
|
+
for (let hop = 0;; hop++) {
|
|
50
|
+
const redirect = {};
|
|
51
|
+
const result = await betterFetch(target, {
|
|
52
|
+
method: "GET",
|
|
53
|
+
headers,
|
|
54
|
+
redirect: headers ? "manual" : void 0,
|
|
55
|
+
signal,
|
|
56
|
+
onError: ({ response }) => {
|
|
57
|
+
if (response.status >= 300 && response.status < 400) redirect.location = response.headers.get("location");
|
|
58
|
+
}
|
|
59
|
+
});
|
|
60
|
+
if (headers && redirect.location) {
|
|
61
|
+
const next = new URL(redirect.location, target);
|
|
62
|
+
if (next.origin !== new URL(url).origin) throw new Error(`discovery redirected to ${next.origin}; with discoveryHeaders set, only same-origin redirects are followed. Set discoveryUrl to the final URL.`);
|
|
63
|
+
if (hop >= MAX_DISCOVERY_REDIRECTS) throw new Error(`discovery redirected more than ${MAX_DISCOVERY_REDIRECTS} times. Set discoveryUrl to the final URL.`);
|
|
64
|
+
target = next.href;
|
|
65
|
+
continue;
|
|
66
|
+
}
|
|
67
|
+
if (headers && result.error?.status === 0) throw new Error("discovery redirected; with discoveryHeaders set, set discoveryUrl to the final URL.");
|
|
68
|
+
if (result.error || !result.data) return null;
|
|
69
|
+
if (result.data.issuer) try {
|
|
70
|
+
new URL(result.data.issuer);
|
|
71
|
+
} catch {
|
|
72
|
+
return null;
|
|
73
|
+
}
|
|
74
|
+
return result.data;
|
|
57
75
|
}
|
|
58
|
-
return result.data;
|
|
59
76
|
}
|
|
60
77
|
async function fetchUserInfo(tokens, userInfoUrl, idTokenClaims) {
|
|
61
78
|
if (tokens.idToken) {
|
|
62
79
|
const decoded = idTokenClaims ?? readIdTokenClaims(tokens.idToken);
|
|
63
80
|
if (decoded?.sub && decoded?.email) return {
|
|
64
81
|
id: decoded.sub,
|
|
65
|
-
emailVerified:
|
|
82
|
+
emailVerified: parseStringBoolean(decoded.email_verified) ?? false,
|
|
66
83
|
image: decoded.picture,
|
|
67
84
|
...decoded
|
|
68
85
|
};
|
|
@@ -76,7 +93,7 @@ async function fetchUserInfo(tokens, userInfoUrl, idTokenClaims) {
|
|
|
76
93
|
return {
|
|
77
94
|
...userInfo.data,
|
|
78
95
|
email: userInfo.data.email,
|
|
79
|
-
emailVerified:
|
|
96
|
+
emailVerified: parseStringBoolean(userInfo.data.email_verified) ?? false,
|
|
80
97
|
image: userInfo.data.picture,
|
|
81
98
|
name: userInfo.data.name
|
|
82
99
|
};
|
|
@@ -128,8 +145,9 @@ const genericOAuth = (options) => {
|
|
|
128
145
|
ctx.logger.error(`Provider "${c.providerId}": invalid jwks_uri "${discovered.jwks_uri}" in discovery document. Provider skipped.`);
|
|
129
146
|
continue;
|
|
130
147
|
}
|
|
148
|
+
const jwksHeaders = jwksUrl.origin === new URL(c.discoveryUrl).origin ? c.discoveryHeaders : void 0;
|
|
131
149
|
idTokenConfig = {
|
|
132
|
-
jwks: createRemoteJWKSet(jwksUrl),
|
|
150
|
+
jwks: createRemoteJWKSet(jwksUrl, jwksHeaders && { headers: jwksHeaders }),
|
|
133
151
|
issuer: discovered.issuer,
|
|
134
152
|
audience: c.clientId,
|
|
135
153
|
algorithms: isOidc ? signingAlgs : void 0
|
|
@@ -160,7 +178,7 @@ const genericOAuth = (options) => {
|
|
|
160
178
|
const mapped = c.mapProfileToUser ? await c.mapProfileToUser(raw) : {};
|
|
161
179
|
const user = {
|
|
162
180
|
email: raw.email,
|
|
163
|
-
emailVerified:
|
|
181
|
+
emailVerified: parseStringBoolean(raw.emailVerified) ?? false,
|
|
164
182
|
image: raw.image,
|
|
165
183
|
name: raw.name,
|
|
166
184
|
...mapped
|
|
@@ -287,7 +305,8 @@ const genericOAuth = (options) => {
|
|
|
287
305
|
authentication: c.authentication,
|
|
288
306
|
tokenEndpointAuth,
|
|
289
307
|
tokenEndpoint: tokenUrl,
|
|
290
|
-
extraParams: resolvedRefreshParams
|
|
308
|
+
extraParams: resolvedRefreshParams,
|
|
309
|
+
headers: c.authorizationHeaders
|
|
291
310
|
});
|
|
292
311
|
return applyDefaultAccessTokenExpiry(tokens, c.accessTokenExpiresIn);
|
|
293
312
|
},
|
|
@@ -303,18 +322,13 @@ const genericOAuth = (options) => {
|
|
|
303
322
|
}
|
|
304
323
|
return genericProviders;
|
|
305
324
|
};
|
|
306
|
-
const retryDiscovery = (ctx, providerId) => {
|
|
325
|
+
const retryDiscovery = async (ctx, providerId) => {
|
|
307
326
|
const pendingDiscovery = getPendingDiscovery(ctx);
|
|
308
327
|
const pending = pendingDiscovery?.get(providerId);
|
|
309
328
|
if (!pending) return;
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
ctx.socialProviders.unshift(provider);
|
|
314
|
-
}).finally(() => {
|
|
315
|
-
pending.attempt = void 0;
|
|
316
|
-
});
|
|
317
|
-
return pending.attempt;
|
|
329
|
+
const [provider] = await buildProviders([pending], ctx, DISCOVERY_RETRY_TIMEOUT_MS);
|
|
330
|
+
if (!provider || !pendingDiscovery?.delete(providerId)) return;
|
|
331
|
+
ctx.socialProviders.unshift(provider);
|
|
318
332
|
};
|
|
319
333
|
const requestedProviderId = (context) => {
|
|
320
334
|
const id = context.body?.provider ?? context.body?.providerId ?? context.query?.provider ?? context.params?.id;
|
|
@@ -326,7 +340,7 @@ const genericOAuth = (options) => {
|
|
|
326
340
|
init: async (ctx) => {
|
|
327
341
|
const genericProviders = await buildProviders(options.config, ctx);
|
|
328
342
|
const built = new Set(genericProviders.map((p) => p.id));
|
|
329
|
-
const genericOAuthPendingDiscovery = new Map(options.config.filter((c) => !built.has(c.providerId)).map((c) => [c.providerId,
|
|
343
|
+
const genericOAuthPendingDiscovery = new Map(options.config.filter((c) => !built.has(c.providerId)).map((c) => [c.providerId, c]));
|
|
330
344
|
const existingIds = new Set(ctx.socialProviders.map((p) => p.id));
|
|
331
345
|
for (const gp of genericProviders) if (existingIds.has(gp.id)) ctx.logger.warn(`Generic OAuth provider "${gp.id}" shadows a built-in social provider with the same ID`);
|
|
332
346
|
return { context: {
|
|
@@ -344,5 +358,4 @@ const genericOAuth = (options) => {
|
|
|
344
358
|
$ERROR_CODES: GENERIC_OAUTH_ERROR_CODES
|
|
345
359
|
};
|
|
346
360
|
};
|
|
347
|
-
//#endregion
|
|
348
361
|
export { auth0, genericOAuth, gumroad, hubspot, keycloak, line, microsoftEntraId, okta, patreon, slack, yandex };
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { GenericOAuthConfig } from "../types.mjs";
|
|
2
2
|
import { BaseOAuthProviderOptions } from "../index.mjs";
|
|
3
|
-
//#region src/plugins/generic-oauth/providers/auth0.d.ts
|
|
4
3
|
export interface Auth0Options extends BaseOAuthProviderOptions {
|
|
5
4
|
/**
|
|
6
5
|
* Auth0 domain (e.g., dev-xxx.eu.auth0.com)
|
|
@@ -30,5 +29,4 @@ export interface Auth0Options extends BaseOAuthProviderOptions {
|
|
|
30
29
|
* });
|
|
31
30
|
* ```
|
|
32
31
|
*/
|
|
33
|
-
export declare function auth0(options: Auth0Options): GenericOAuthConfig<"auth0">;
|
|
34
|
-
//#endregion
|
|
32
|
+
export declare function auth0(options: Auth0Options): GenericOAuthConfig<"auth0">;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
// src/plugins/generic-oauth/providers/auth0.ts
|
|
2
2
|
/**
|
|
3
3
|
* Auth0 OAuth provider helper
|
|
4
4
|
*
|
|
@@ -45,5 +45,4 @@ function auth0(options) {
|
|
|
45
45
|
overrideUserInfo: options.overrideUserInfo
|
|
46
46
|
};
|
|
47
47
|
}
|
|
48
|
-
//#endregion
|
|
49
48
|
export { auth0 };
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { GenericOAuthConfig } from "../types.mjs";
|
|
2
2
|
import { BaseOAuthProviderOptions } from "../index.mjs";
|
|
3
|
-
//#region src/plugins/generic-oauth/providers/gumroad.d.ts
|
|
4
3
|
export interface GumroadOptions extends BaseOAuthProviderOptions {}
|
|
5
4
|
/**
|
|
6
5
|
* Gumroad OAuth provider helper
|
|
@@ -25,5 +24,4 @@ export interface GumroadOptions extends BaseOAuthProviderOptions {}
|
|
|
25
24
|
*
|
|
26
25
|
* @see https://app.gumroad.com/oauth
|
|
27
26
|
*/
|
|
28
|
-
export declare function gumroad(options: GumroadOptions): GenericOAuthConfig<"gumroad">;
|
|
29
|
-
//#endregion
|
|
27
|
+
export declare function gumroad(options: GumroadOptions): GenericOAuthConfig<"gumroad">;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { betterFetch } from "@better-fetch/fetch";
|
|
2
|
-
|
|
2
|
+
// src/plugins/generic-oauth/providers/gumroad.ts
|
|
3
3
|
/**
|
|
4
4
|
* Gumroad OAuth provider helper
|
|
5
5
|
*
|
|
@@ -58,5 +58,4 @@ function gumroad(options) {
|
|
|
58
58
|
getUserInfo
|
|
59
59
|
};
|
|
60
60
|
}
|
|
61
|
-
//#endregion
|
|
62
61
|
export { gumroad };
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { GenericOAuthConfig } from "../types.mjs";
|
|
2
2
|
import { BaseOAuthProviderOptions } from "../index.mjs";
|
|
3
|
-
//#region src/plugins/generic-oauth/providers/hubspot.d.ts
|
|
4
3
|
export interface HubSpotOptions extends BaseOAuthProviderOptions {
|
|
5
4
|
/**
|
|
6
5
|
* OAuth scopes to request.
|
|
@@ -30,5 +29,4 @@ export interface HubSpotOptions extends BaseOAuthProviderOptions {
|
|
|
30
29
|
* });
|
|
31
30
|
* ```
|
|
32
31
|
*/
|
|
33
|
-
export declare function hubspot(options: HubSpotOptions): GenericOAuthConfig<"hubspot">;
|
|
34
|
-
//#endregion
|
|
32
|
+
export declare function hubspot(options: HubSpotOptions): GenericOAuthConfig<"hubspot">;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { betterFetch } from "@better-fetch/fetch";
|
|
2
|
-
|
|
2
|
+
// src/plugins/generic-oauth/providers/hubspot.ts
|
|
3
3
|
/**
|
|
4
4
|
* HubSpot OAuth provider helper
|
|
5
5
|
*
|
|
@@ -62,5 +62,4 @@ function hubspot(options) {
|
|
|
62
62
|
getUserInfo
|
|
63
63
|
};
|
|
64
64
|
}
|
|
65
|
-
//#endregion
|
|
66
65
|
export { hubspot };
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { GenericOAuthConfig } from "../types.mjs";
|
|
2
2
|
import { BaseOAuthProviderOptions } from "../index.mjs";
|
|
3
|
-
//#region src/plugins/generic-oauth/providers/keycloak.d.ts
|
|
4
3
|
export interface KeycloakOptions extends BaseOAuthProviderOptions {
|
|
5
4
|
/**
|
|
6
5
|
* Keycloak issuer URL (includes realm, e.g., https://my-domain/realms/MyRealm)
|
|
@@ -30,5 +29,4 @@ export interface KeycloakOptions extends BaseOAuthProviderOptions {
|
|
|
30
29
|
* });
|
|
31
30
|
* ```
|
|
32
31
|
*/
|
|
33
|
-
export declare function keycloak(options: KeycloakOptions): GenericOAuthConfig<"keycloak">;
|
|
34
|
-
//#endregion
|
|
32
|
+
export declare function keycloak(options: KeycloakOptions): GenericOAuthConfig<"keycloak">;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
// src/plugins/generic-oauth/providers/keycloak.ts
|
|
2
2
|
/**
|
|
3
3
|
* Keycloak OAuth provider helper
|
|
4
4
|
*
|
|
@@ -43,5 +43,4 @@ function keycloak(options) {
|
|
|
43
43
|
overrideUserInfo: options.overrideUserInfo
|
|
44
44
|
};
|
|
45
45
|
}
|
|
46
|
-
//#endregion
|
|
47
46
|
export { keycloak };
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { GenericOAuthConfig } from "../types.mjs";
|
|
2
2
|
import { BaseOAuthProviderOptions } from "../index.mjs";
|
|
3
|
-
//#region src/plugins/generic-oauth/providers/line.d.ts
|
|
4
3
|
export interface LineOptions extends BaseOAuthProviderOptions {
|
|
5
4
|
/**
|
|
6
5
|
* Unique provider identifier for this LINE channel.
|
|
@@ -48,5 +47,4 @@ export interface LineOptions extends BaseOAuthProviderOptions {
|
|
|
48
47
|
* });
|
|
49
48
|
* ```
|
|
50
49
|
*/
|
|
51
|
-
export declare function line(options: LineOptions): GenericOAuthConfig;
|
|
52
|
-
//#endregion
|
|
50
|
+
export declare function line(options: LineOptions): GenericOAuthConfig;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { decodeJwt } from "jose";
|
|
2
2
|
import { betterFetch } from "@better-fetch/fetch";
|
|
3
|
-
|
|
3
|
+
// src/plugins/generic-oauth/providers/line.ts
|
|
4
4
|
/**
|
|
5
5
|
* LINE OAuth provider helper
|
|
6
6
|
*
|
|
@@ -89,5 +89,4 @@ function line(options) {
|
|
|
89
89
|
getUserInfo
|
|
90
90
|
};
|
|
91
91
|
}
|
|
92
|
-
//#endregion
|
|
93
92
|
export { line };
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { GenericOAuthConfig } from "../types.mjs";
|
|
2
2
|
import { BaseOAuthProviderOptions } from "../index.mjs";
|
|
3
|
-
//#region src/plugins/generic-oauth/providers/microsoft-entra-id.d.ts
|
|
4
3
|
export interface MicrosoftEntraIdOptions extends BaseOAuthProviderOptions {
|
|
5
4
|
/**
|
|
6
5
|
* Concrete Microsoft Entra ID tenant GUID.
|
|
@@ -33,5 +32,4 @@ export interface MicrosoftEntraIdOptions extends BaseOAuthProviderOptions {
|
|
|
33
32
|
* });
|
|
34
33
|
* ```
|
|
35
34
|
*/
|
|
36
|
-
export declare function microsoftEntraId(options: MicrosoftEntraIdOptions): GenericOAuthConfig<"microsoft-entra-id">;
|
|
37
|
-
//#endregion
|
|
35
|
+
export declare function microsoftEntraId(options: MicrosoftEntraIdOptions): GenericOAuthConfig<"microsoft-entra-id">;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { decodeJwt } from "jose";
|
|
2
2
|
import { betterFetch } from "@better-fetch/fetch";
|
|
3
3
|
import { createPlaceholderEmail } from "@better-auth/core/utils/email";
|
|
4
|
-
|
|
4
|
+
// src/plugins/generic-oauth/providers/microsoft-entra-id.ts
|
|
5
5
|
function getMicrosoftProfileName(profile) {
|
|
6
6
|
return profile.name ?? (`${profile.given_name ?? profile.givenname ?? ""} ${profile.family_name ?? profile.familyname ?? ""}`.trim() || void 0);
|
|
7
7
|
}
|
|
@@ -100,5 +100,4 @@ function microsoftEntraId(options) {
|
|
|
100
100
|
getUserInfo
|
|
101
101
|
};
|
|
102
102
|
}
|
|
103
|
-
//#endregion
|
|
104
103
|
export { microsoftEntraId };
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { GenericOAuthConfig } from "../types.mjs";
|
|
2
2
|
import { BaseOAuthProviderOptions } from "../index.mjs";
|
|
3
|
-
//#region src/plugins/generic-oauth/providers/okta.d.ts
|
|
4
3
|
export interface OktaOptions extends BaseOAuthProviderOptions {
|
|
5
4
|
/**
|
|
6
5
|
* Okta issuer URL (e.g., https://dev-xxxxx.okta.com/oauth2/default)
|
|
@@ -30,5 +29,4 @@ export interface OktaOptions extends BaseOAuthProviderOptions {
|
|
|
30
29
|
* });
|
|
31
30
|
* ```
|
|
32
31
|
*/
|
|
33
|
-
export declare function okta(options: OktaOptions): GenericOAuthConfig<"okta">;
|
|
34
|
-
//#endregion
|
|
32
|
+
export declare function okta(options: OktaOptions): GenericOAuthConfig<"okta">;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
// src/plugins/generic-oauth/providers/okta.ts
|
|
2
2
|
/**
|
|
3
3
|
* Okta OAuth provider helper
|
|
4
4
|
*
|
|
@@ -43,5 +43,4 @@ function okta(options) {
|
|
|
43
43
|
overrideUserInfo: options.overrideUserInfo
|
|
44
44
|
};
|
|
45
45
|
}
|
|
46
|
-
//#endregion
|
|
47
46
|
export { okta };
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { GenericOAuthConfig } from "../types.mjs";
|
|
2
2
|
import { BaseOAuthProviderOptions } from "../index.mjs";
|
|
3
|
-
//#region src/plugins/generic-oauth/providers/patreon.d.ts
|
|
4
3
|
export interface PatreonOptions extends BaseOAuthProviderOptions {}
|
|
5
4
|
/**
|
|
6
5
|
* Patreon OAuth provider helper
|
|
@@ -23,5 +22,4 @@ export interface PatreonOptions extends BaseOAuthProviderOptions {}
|
|
|
23
22
|
* });
|
|
24
23
|
* ```
|
|
25
24
|
*/
|
|
26
|
-
export declare function patreon(options: PatreonOptions): GenericOAuthConfig<"patreon">;
|
|
27
|
-
//#endregion
|
|
25
|
+
export declare function patreon(options: PatreonOptions): GenericOAuthConfig<"patreon">;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { betterFetch } from "@better-fetch/fetch";
|
|
2
|
-
|
|
2
|
+
// src/plugins/generic-oauth/providers/patreon.ts
|
|
3
3
|
/**
|
|
4
4
|
* Patreon OAuth provider helper
|
|
5
5
|
*
|
|
@@ -57,5 +57,4 @@ function patreon(options) {
|
|
|
57
57
|
getUserInfo
|
|
58
58
|
};
|
|
59
59
|
}
|
|
60
|
-
//#endregion
|
|
61
60
|
export { patreon };
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { GenericOAuthConfig } from "../types.mjs";
|
|
2
2
|
import { BaseOAuthProviderOptions } from "../index.mjs";
|
|
3
|
-
//#region src/plugins/generic-oauth/providers/slack.d.ts
|
|
4
3
|
export interface SlackOptions extends BaseOAuthProviderOptions {}
|
|
5
4
|
/**
|
|
6
5
|
* Slack OAuth provider helper
|
|
@@ -23,5 +22,4 @@ export interface SlackOptions extends BaseOAuthProviderOptions {}
|
|
|
23
22
|
* });
|
|
24
23
|
* ```
|
|
25
24
|
*/
|
|
26
|
-
export declare function slack(options: SlackOptions): GenericOAuthConfig<"slack">;
|
|
27
|
-
//#endregion
|
|
25
|
+
export declare function slack(options: SlackOptions): GenericOAuthConfig<"slack">;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { betterFetch } from "@better-fetch/fetch";
|
|
2
|
-
|
|
2
|
+
// src/plugins/generic-oauth/providers/slack.ts
|
|
3
3
|
/**
|
|
4
4
|
* Slack OAuth provider helper
|
|
5
5
|
*
|
|
@@ -59,5 +59,4 @@ function slack(options) {
|
|
|
59
59
|
getUserInfo
|
|
60
60
|
};
|
|
61
61
|
}
|
|
62
|
-
//#endregion
|
|
63
62
|
export { slack };
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { GenericOAuthConfig } from "../types.mjs";
|
|
2
2
|
import { BaseOAuthProviderOptions } from "../index.mjs";
|
|
3
|
-
//#region src/plugins/generic-oauth/providers/yandex.d.ts
|
|
4
3
|
export interface YandexOptions extends BaseOAuthProviderOptions {}
|
|
5
4
|
/**
|
|
6
5
|
* Yandex OAuth provider helper
|
|
@@ -23,5 +22,4 @@ export interface YandexOptions extends BaseOAuthProviderOptions {}
|
|
|
23
22
|
* });
|
|
24
23
|
* ```
|
|
25
24
|
*/
|
|
26
|
-
export declare function yandex(options: YandexOptions): GenericOAuthConfig;
|
|
27
|
-
//#endregion
|
|
25
|
+
export declare function yandex(options: YandexOptions): GenericOAuthConfig;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { betterFetch } from "@better-fetch/fetch";
|
|
2
|
-
|
|
2
|
+
// src/plugins/generic-oauth/providers/yandex.ts
|
|
3
3
|
/**
|
|
4
4
|
* Yandex OAuth provider helper
|
|
5
5
|
*
|
|
@@ -63,5 +63,4 @@ function yandex(options) {
|
|
|
63
63
|
getUserInfo
|
|
64
64
|
};
|
|
65
65
|
}
|
|
66
|
-
//#endregion
|
|
67
66
|
export { yandex };
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { Awaitable } from "@better-auth/core";
|
|
2
2
|
import { OAuth2Tokens, OAuth2UserInfo, OAuthAccountKeyContext, OAuthMappedUser, OAuthRefreshContext, TokenEndpointAuth } from "@better-auth/core/oauth2";
|
|
3
|
-
//#region src/plugins/generic-oauth/types.d.ts
|
|
4
3
|
/** Raw profile returned by a Generic OAuth provider. */
|
|
5
4
|
export type GenericOAuthUserInfo = Omit<OAuth2UserInfo, "id"> & {
|
|
6
5
|
id?: string | number | null | undefined;
|
|
@@ -211,12 +210,15 @@ export interface GenericOAuthConfig<ID extends string = string> {
|
|
|
211
210
|
*/
|
|
212
211
|
authentication?: ("basic" | "post") | undefined;
|
|
213
212
|
/**
|
|
214
|
-
* Custom headers to include in the discovery request
|
|
213
|
+
* Custom headers to include in the discovery request, and in the JWKS request when
|
|
214
|
+
* `jwks_uri` has the same origin as `discoveryUrl`. When set, discovery follows
|
|
215
|
+
* redirects only within that origin and fails on a redirect to another origin.
|
|
215
216
|
* Useful for providers like Epic that require specific headers (e.g., Epic-Client-ID).
|
|
216
217
|
*/
|
|
217
218
|
discoveryHeaders?: Record<string, string> | undefined;
|
|
218
219
|
/**
|
|
219
|
-
* Custom headers to include in the authorization
|
|
220
|
+
* Custom headers to include in token endpoint requests: the authorization
|
|
221
|
+
* code exchange and token refresh.
|
|
220
222
|
* Useful for providers like Qonto that require specific headers (e.g., X-Qonto-Staging-Token for local development).
|
|
221
223
|
*/
|
|
222
224
|
authorizationHeaders?: Record<string, string> | undefined;
|
|
@@ -263,5 +265,4 @@ export interface GenericOAuthConfig<ID extends string = string> {
|
|
|
263
265
|
* @default false
|
|
264
266
|
*/
|
|
265
267
|
disableIdTokenNonceBinding?: boolean | undefined;
|
|
266
|
-
}
|
|
267
|
-
//#endregion
|
|
268
|
+
}
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
//#region src/plugins/haveibeenpwned/index.d.ts
|
|
2
1
|
declare module "@better-auth/core" {
|
|
3
2
|
interface BetterAuthPluginRegistry<AuthOptions, Options> {
|
|
4
3
|
"have-i-been-pwned": {
|
|
@@ -55,5 +54,4 @@ export declare const haveIBeenPwned: (options?: HaveIBeenPwnedOptions | undefine
|
|
|
55
54
|
$ERROR_CODES: {
|
|
56
55
|
PASSWORD_COMPROMISED: import("@better-auth/core/utils/error-codes").RawError<"PASSWORD_COMPROMISED">;
|
|
57
56
|
};
|
|
58
|
-
};
|
|
59
|
-
//#endregion
|
|
57
|
+
};
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { isAPIError } from "../../utils/is-api-error.mjs";
|
|
2
1
|
import { APIError } from "../../api/index.mjs";
|
|
2
|
+
import { isAPIError } from "../../utils/is-api-error.mjs";
|
|
3
3
|
import { PACKAGE_VERSION } from "../../version.mjs";
|
|
4
4
|
import { getCurrentAuthEndpointContext } from "@better-auth/core/context";
|
|
5
5
|
import { defineErrorCodes } from "@better-auth/core/utils/error-codes";
|
|
6
6
|
import { createHash } from "@better-auth/utils/hash";
|
|
7
7
|
import { betterFetch } from "@better-fetch/fetch";
|
|
8
|
-
|
|
8
|
+
// src/plugins/haveibeenpwned/index.ts
|
|
9
9
|
const ERROR_CODES = defineErrorCodes({ PASSWORD_COMPROMISED: "The password you entered has been compromised. Please choose a different password." });
|
|
10
10
|
function getPasswordCompromiseCount(response, hashSuffix) {
|
|
11
11
|
const matchingEntryPrefix = `${hashSuffix.toUpperCase()}:`;
|
|
@@ -77,5 +77,4 @@ const haveIBeenPwned = (options) => {
|
|
|
77
77
|
$ERROR_CODES: ERROR_CODES
|
|
78
78
|
};
|
|
79
79
|
};
|
|
80
|
-
//#endregion
|
|
81
80
|
export { haveIBeenPwned, isPasswordCompromised };
|
package/dist/plugins/index.d.mts
CHANGED
|
@@ -53,21 +53,21 @@ import { OneTimeTokenOptions, oneTimeToken } from "./one-time-token/index.mjs";
|
|
|
53
53
|
import { FieldSchema, OpenAPIModelSchema, OpenAPIParameter, OpenAPISchema, Path, generator } from "./open-api/generator.mjs";
|
|
54
54
|
import { OpenAPIOptions, openAPI } from "./open-api/index.mjs";
|
|
55
55
|
import { PhoneNumberOptions, UserWithPhoneNumber } from "./phone-number/types.mjs";
|
|
56
|
+
import "./organization/index.mjs";
|
|
56
57
|
import { phoneNumber } from "./phone-number/index.mjs";
|
|
57
|
-
import { SIWEPluginOptions, siwe } from "./siwe/index.mjs";
|
|
58
58
|
import { LoginResult, TestAuthOptions, TestCookie, TestHelpers, TestUtilsOptions } from "./test-utils/types.mjs";
|
|
59
|
-
import {
|
|
59
|
+
import { SIWEPluginOptions, siwe } from "./siwe/index.mjs";
|
|
60
60
|
import { BackupCodeOptions, backupCode2fa, encodeBackupCodes, generateBackupCodes, getBackupCodes, verifyBackupCode } from "./two-factor/backup-codes/index.mjs";
|
|
61
61
|
import { OTPOptions, otp2fa } from "./two-factor/otp/index.mjs";
|
|
62
62
|
import { TOTPOptions, totp2fa } from "./two-factor/totp/index.mjs";
|
|
63
63
|
import { TwoFactorOptions, TwoFactorProvider, TwoFactorTable, UserWithTwoFactor } from "./two-factor/types.mjs";
|
|
64
64
|
import { TWO_FACTOR_ERROR_CODES } from "./two-factor/error-code.mjs";
|
|
65
65
|
import { twoFactorClient } from "./two-factor/client.mjs";
|
|
66
|
-
import {
|
|
66
|
+
import { testUtils } from "./test-utils/index.mjs";
|
|
67
67
|
import { USERNAME_ERROR_CODES } from "./username/error-codes.mjs";
|
|
68
|
-
import {
|
|
68
|
+
import { twoFactor } from "./two-factor/index.mjs";
|
|
69
69
|
import { hasPermission } from "./organization/has-permission.mjs";
|
|
70
70
|
import { parseRoles } from "./organization/roles.mjs";
|
|
71
71
|
import { DefaultOrganizationPlugin, DynamicAccessControlEndpoints, OrganizationCreator, OrganizationEndpoints, OrganizationPlugin, TeamEndpoints, organization } from "./organization/organization.mjs";
|
|
72
|
-
import "./
|
|
72
|
+
import { UsernameOptions, UsernamePlugin, UsernamePluginWithoutDisplayUsername, username } from "./username/index.mjs";
|
|
73
73
|
export { AccessControl, type AdminOptions, type AnonymousOptions, type AnonymousSession, ArrayElement, type Auth0Options, AuthorizeResponse, type BackupCodeOptions, type BaseCaptchaOptions, BaseOAuthProviderOptions, BearerOptions, type BotIdVerification, type CaptchaFoxOptions, type CaptchaOptions, type CloudflareTurnstileOptions, CustomSessionPluginOptions, DefaultOrganizationPlugin, DeviceAuthorizationGrant, DeviceAuthorizationGrantAuthorization, DeviceAuthorizationOptions, DeviceAuthorizationPluginOptions, DeviceAuthorizationRequest, type DeviceCode, type DeviceCodeRedemptionAuthorization, type DeviceCodeRedemptionResult, DynamicAccessControlEndpoints, MULTI_SESSION_ERROR_CODES as ERROR_CODES, type EmailOTPOptions, ExactRoleStatements, type FieldSchema, type GenericOAuthConfig, type GenericOAuthOptions, type GenericOAuthUserInfo, type GoogleRecaptchaOptions, type GumroadOptions, type HCaptchaOptions, HIDE_METADATA, HaveIBeenPwnedOptions, type HubSpotOptions, type InferAdminRolesFromOption, type InferInvitation, type InferMember, InferOptionSchema, type InferOrganization, type InferOrganizationRolesFromOption, type InferOrganizationZodRolesFromOption, InferPluginContext, InferPluginErrorCodes, InferPluginIDs, type InferTeam, type Invitation, type InvitationInput, type InvitationStatus, type JWKOptions, type JWSAlgorithms, type Jwk, type JwtOptions, type KeycloakOptions, LastLoginMethodOptions, type LineOptions, type LoginResult, MagicLinkOptions, type Member, type MemberInput, type MicrosoftEntraIdOptions, MultiSessionConfig, OAUTH_POPUP_COMPLETE_SCRIPT, OAUTH_POPUP_DATA_ELEMENT_ID, OAUTH_POPUP_ERROR_CODES, OAUTH_POPUP_MESSAGE_TYPE, OAUTH_POPUP_SCRIPT_CSP_HASH, type OAuthPopupData, type OAuthPopupMessage, OAuthProxyOptions, type OTPOptions, type OktaOptions, OneTapOptions, OneTimeTokenOptions, type OpenAPIModelSchema, OpenAPIOptions, type OpenAPIParameter, type OpenAPISchema, type Organization, OrganizationCreator, OrganizationEndpoints, type OrganizationInput, type OrganizationOptions, OrganizationPlugin, type OrganizationRole, type OrganizationSchema, POPUP_MARKER_COOKIE, type Path, type PatreonOptions, type PhoneNumberOptions, type Provider, type ResolvedSigningKey, Role, RoleAuthorizeRequest, RoleInput, RoleStatements, SIWEPluginOptions, type SessionWithImpersonatedBy, type SlackOptions, Statements, SubArray, Subset, type TOTPOptions, TWO_FACTOR_ERROR_CODES, type Team, TeamEndpoints, type TeamInput, type TeamMember, type TeamMemberInput, type TestAuthOptions, type TestCookie, type TestHelpers, type TestUtilsOptions, type TimeString, TwoFactorOptions, TwoFactorProvider, TwoFactorTable, USERNAME_ERROR_CODES, type UserWithAnonymous, type UserWithPhoneNumber, type UserWithRole, UserWithTwoFactor, UsernameOptions, UsernamePlugin, UsernamePluginWithoutDisplayUsername, type ValidateRequestContext, type VercelBotIdOptions, type YandexOptions, admin, anonymous, auth0, type backupCode2fa, bearer, captcha, createAccessControl, createJwk, customSession, type defaultRolesSchema, deviceAuthorization, deviceAuthorizationOptionsSchema, emailOTP, type encodeBackupCodes, type generateBackupCodes, generateExportedKeyPair, type generator, genericOAuth, type getBackupCodes, getJwtToken, getOrgAdapter, gumroad, hasPermission, haveIBeenPwned, hubspot, type invitationSchema, type invitationStatus, isPasswordCompromised, jwt, keycloak, lastLoginMethod, line, magicLink, type memberSchema, microsoftEntraId, type ms, multiSession, oAuthProxy, oauthPopup, okta, oneTap, oneTimeToken, openAPI, organization, type organizationRoleSchema, type organizationSchema, type otp2fa, parseRoles, patreon, phoneNumber, redeemDeviceCode, resolveSigningKey, role, type roleSchema, type sec, signJWT, siwe, slack, type teamMemberSchema, type teamSchema, testUtils, toExpJWT, type totp2fa, twoFactor, twoFactorClient, username, type verifyBackupCode, verifyJWT, yandex };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { getCurrentAdapter } from "@better-auth/core/context";
|
|
2
|
-
|
|
2
|
+
// src/plugins/jwt/adapter.ts
|
|
3
3
|
/**
|
|
4
4
|
* Algorithm of the key the plugin generates when `jwks.keyPairConfig` is unset.
|
|
5
5
|
*/
|
|
@@ -75,5 +75,4 @@ const getJwksAdapter = (baseAdapter, options) => {
|
|
|
75
75
|
}
|
|
76
76
|
};
|
|
77
77
|
};
|
|
78
|
-
//#endregion
|
|
79
78
|
export { DEFAULT_JWK_ALG, getDefaultKeyAlg, getJwksAdapter };
|
|
@@ -1,9 +1,8 @@
|
|
|
1
|
-
import { JWKOptions, JWSAlgorithms, Jwk, JwtOptions, ResolvedSigningKey } from "./types.mjs";
|
|
2
1
|
import { jwt } from "./index.mjs";
|
|
2
|
+
import { JWKOptions, JWSAlgorithms, Jwk, JwtOptions, ResolvedSigningKey } from "./types.mjs";
|
|
3
3
|
import { BetterAuthClientOptions, ClientFetchOption, ClientStore } from "@better-auth/core";
|
|
4
4
|
import { JSONWebKeySet } from "jose";
|
|
5
5
|
import { BetterFetch } from "@better-fetch/fetch";
|
|
6
|
-
//#region src/plugins/jwt/client.d.ts
|
|
7
6
|
interface JwtClientOptions {
|
|
8
7
|
jwks?: {
|
|
9
8
|
/**
|
|
@@ -36,5 +35,4 @@ export declare const jwtClient: (options?: JwtClientOptions) => {
|
|
|
36
35
|
}>;
|
|
37
36
|
};
|
|
38
37
|
};
|
|
39
|
-
//#endregion
|
|
40
38
|
export type { JWKOptions, JWSAlgorithms, Jwk, JwtOptions, ResolvedSigningKey };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { PACKAGE_VERSION } from "../../version.mjs";
|
|
2
|
-
|
|
2
|
+
// src/plugins/jwt/client.ts
|
|
3
3
|
const jwtClient = (options) => {
|
|
4
4
|
const jwksPath = options?.jwks?.jwksPath ?? "/jwks";
|
|
5
5
|
return {
|
|
@@ -15,5 +15,4 @@ const jwtClient = (options) => {
|
|
|
15
15
|
} })
|
|
16
16
|
};
|
|
17
17
|
};
|
|
18
|
-
//#endregion
|
|
19
18
|
export { jwtClient };
|
|
@@ -3,7 +3,7 @@ import { getDefaultKeyAlg, getJwksAdapter } from "./adapter.mjs";
|
|
|
3
3
|
import { resolveSigningKey } from "./sign.mjs";
|
|
4
4
|
import { BetterAuthError } from "@better-auth/core/error";
|
|
5
5
|
import { SignJWT, decodeProtectedHeader, importJWK, jwtVerify } from "jose";
|
|
6
|
-
|
|
6
|
+
// src/plugins/jwt/cookie-cache.ts
|
|
7
7
|
function getCookieCacheJwtIssuer(ctx) {
|
|
8
8
|
const baseURL = ctx.context.options.baseURL;
|
|
9
9
|
return typeof baseURL === "string" ? baseURL || "better-auth:session-cache" : ctx.context.baseURL || "better-auth:session-cache";
|
|
@@ -68,5 +68,4 @@ function createCookieCacheSigner(options) {
|
|
|
68
68
|
verify: (ctx, token) => verifyCookieCacheJWT(ctx, token, options)
|
|
69
69
|
};
|
|
70
70
|
}
|
|
71
|
-
//#endregion
|
|
72
71
|
export { createCookieCacheSigner };
|
|
@@ -1,10 +1,9 @@
|
|
|
1
|
-
import { JWKOptions, JWSAlgorithms, Jwk, JwtOptions, ResolvedSigningKey } from "./types.mjs";
|
|
2
1
|
import { getJwtToken, resolveSigningKey, signJWT } from "./sign.mjs";
|
|
2
|
+
import { JWKOptions, JWSAlgorithms, Jwk, JwtOptions, ResolvedSigningKey } from "./types.mjs";
|
|
3
3
|
import { createJwk, generateExportedKeyPair, toExpJWT } from "./utils.mjs";
|
|
4
4
|
import { verifyJWT } from "./verify.mjs";
|
|
5
5
|
import * as z from "zod";
|
|
6
6
|
import { JSONWebKeySet, JWTPayload } from "jose";
|
|
7
|
-
//#region src/plugins/jwt/index.d.ts
|
|
8
7
|
declare module "@better-auth/core" {
|
|
9
8
|
interface BetterAuthPluginRegistry<AuthOptions, Options> {
|
|
10
9
|
jwt: {
|
|
@@ -239,5 +238,4 @@ export declare const jwt: <O extends JwtOptions>(options?: O) => {
|
|
|
239
238
|
};
|
|
240
239
|
};
|
|
241
240
|
};
|
|
242
|
-
//#endregion
|
|
243
241
|
export { type JWKOptions, type JWSAlgorithms, type Jwk, type JwtOptions, type ResolvedSigningKey, createJwk, generateExportedKeyPair, getJwtToken, resolveSigningKey, signJWT, toExpJWT, verifyJWT };
|