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,17 +1,17 @@
|
|
|
1
|
-
import { mergeSchema } from "../../db/schema.mjs";
|
|
2
|
-
import { sessionMiddleware } from "../../api/routes/session.mjs";
|
|
3
1
|
import { APIError as APIError$1 } from "../../api/index.mjs";
|
|
2
|
+
import { sessionMiddleware } from "../../api/routes/session.mjs";
|
|
3
|
+
import { mergeSchema } from "../../db/schema.mjs";
|
|
4
4
|
import { PACKAGE_VERSION } from "../../version.mjs";
|
|
5
5
|
import { getDefaultKeyAlg, getJwksAdapter } from "./adapter.mjs";
|
|
6
|
-
import { createJwk, generateExportedKeyPair, toExpJWT } from "./utils.mjs";
|
|
7
|
-
import { getJwtToken, resolveSigningKey, signJWT } from "./sign.mjs";
|
|
8
6
|
import { createCookieCacheSigner } from "./cookie-cache.mjs";
|
|
9
7
|
import { schema } from "./schema.mjs";
|
|
8
|
+
import { getJwtToken, resolveSigningKey, signJWT } from "./sign.mjs";
|
|
9
|
+
import { createJwk, generateExportedKeyPair, toExpJWT } from "./utils.mjs";
|
|
10
10
|
import { verifyJWT } from "./verify.mjs";
|
|
11
11
|
import { BetterAuthError } from "@better-auth/core/error";
|
|
12
12
|
import { createAuthEndpoint, createAuthMiddleware } from "@better-auth/core/api";
|
|
13
13
|
import * as z from "zod";
|
|
14
|
-
|
|
14
|
+
// src/plugins/jwt/index.ts
|
|
15
15
|
const signJWTBodySchema = z.object({
|
|
16
16
|
payload: z.record(z.string(), z.any()),
|
|
17
17
|
overrideOptions: z.record(z.string(), z.any()).optional()
|
|
@@ -210,5 +210,4 @@ const jwt = (options) => {
|
|
|
210
210
|
schema: mergeSchema(schema, options?.schema)
|
|
211
211
|
};
|
|
212
212
|
};
|
|
213
|
-
//#endregion
|
|
214
213
|
export { createJwk, generateExportedKeyPair, getJwtToken, jwt, resolveSigningKey, signJWT, toExpJWT, verifyJWT };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
// src/plugins/jwt/schema.ts
|
|
2
2
|
const schema = { jwks: { fields: {
|
|
3
3
|
publicKey: {
|
|
4
4
|
type: "string",
|
|
@@ -25,5 +25,4 @@ const schema = { jwks: { fields: {
|
|
|
25
25
|
required: false
|
|
26
26
|
}
|
|
27
27
|
} } };
|
|
28
|
-
//#endregion
|
|
29
28
|
export { schema };
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { JWSAlgorithms, JwtOptions, ResolvedSigningKey } from "./types.mjs";
|
|
2
2
|
import { GenericEndpointContext } from "@better-auth/core";
|
|
3
|
-
//#region src/plugins/jwt/sign.d.ts
|
|
4
3
|
type JWTPayloadWithOptional = {
|
|
5
4
|
/**
|
|
6
5
|
* JWT Issuer
|
|
@@ -125,5 +124,4 @@ export declare function signJWT(ctx: GenericEndpointContext, config: {
|
|
|
125
124
|
signingAlgorithm?: JWSAlgorithms | undefined;
|
|
126
125
|
}): Promise<string>;
|
|
127
126
|
export declare function getJwtToken(ctx: GenericEndpointContext, options?: JwtOptions | undefined): Promise<string>;
|
|
128
|
-
//#endregion
|
|
129
127
|
export {};
|
|
@@ -3,7 +3,7 @@ import { getDefaultKeyAlg, getJwksAdapter } from "./adapter.mjs";
|
|
|
3
3
|
import { createJwk, toExpJWT } from "./utils.mjs";
|
|
4
4
|
import { BetterAuthError } from "@better-auth/core/error";
|
|
5
5
|
import { SignJWT, importJWK } from "jose";
|
|
6
|
-
|
|
6
|
+
// src/plugins/jwt/sign.ts
|
|
7
7
|
/**
|
|
8
8
|
* Resolves the JWKS signing key, decrypts it, and imports it
|
|
9
9
|
* for use with jose's SignJWT. Returns null when signing is
|
|
@@ -127,5 +127,4 @@ async function getJwtToken(ctx, options) {
|
|
|
127
127
|
}
|
|
128
128
|
});
|
|
129
129
|
}
|
|
130
|
-
//#endregion
|
|
131
130
|
export { getJwtToken, resolveSigningKey, signJWT };
|
|
@@ -4,7 +4,6 @@ import "../../types/index.mjs";
|
|
|
4
4
|
import { schema } from "./schema.mjs";
|
|
5
5
|
import { Awaitable, GenericEndpointContext } from "@better-auth/core";
|
|
6
6
|
import { JWTPayload } from "jose";
|
|
7
|
-
//#region src/plugins/jwt/types.d.ts
|
|
8
7
|
export interface JwtOptions {
|
|
9
8
|
/**
|
|
10
9
|
* Use the JWT plugin's locally managed signing keys for JWT session cookie
|
|
@@ -251,5 +250,4 @@ export interface ResolvedSigningKey {
|
|
|
251
250
|
alg: string;
|
|
252
251
|
kid: string;
|
|
253
252
|
privateKey: CryptoKey | Uint8Array;
|
|
254
|
-
}
|
|
255
|
-
//#endregion
|
|
253
|
+
}
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { Jwk, JwtOptions } from "./types.mjs";
|
|
2
2
|
import { GenericEndpointContext } from "@better-auth/core";
|
|
3
|
-
//#region src/plugins/jwt/utils.d.ts
|
|
4
3
|
/**
|
|
5
4
|
* Converts an expirationTime to ISO seconds expiration time (the format of JWT exp)
|
|
6
5
|
*
|
|
@@ -34,5 +33,4 @@ export declare function generateExportedKeyPair(options?: JwtOptions | undefined
|
|
|
34
33
|
* @param options
|
|
35
34
|
* @returns
|
|
36
35
|
*/
|
|
37
|
-
export declare function createJwk(ctx: GenericEndpointContext, options?: JwtOptions | undefined): Promise<Jwk>;
|
|
38
|
-
//#endregion
|
|
36
|
+
export declare function createJwk(ctx: GenericEndpointContext, options?: JwtOptions | undefined): Promise<Jwk>;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { sec } from "../../utils/time.mjs";
|
|
2
1
|
import { symmetricEncrypt } from "../../crypto/index.mjs";
|
|
2
|
+
import { sec } from "../../utils/time.mjs";
|
|
3
3
|
import { getJwksAdapter } from "./adapter.mjs";
|
|
4
4
|
import { exportJWK, generateKeyPair } from "jose";
|
|
5
|
-
|
|
5
|
+
// src/plugins/jwt/utils.ts
|
|
6
6
|
/**
|
|
7
7
|
* Converts an expirationTime to ISO seconds expiration time (the format of JWT exp)
|
|
8
8
|
*
|
|
@@ -60,5 +60,4 @@ async function createJwk(ctx, options) {
|
|
|
60
60
|
};
|
|
61
61
|
return await getJwksAdapter(ctx.context.adapter, options).createJwk(ctx, jwk);
|
|
62
62
|
}
|
|
63
|
-
//#endregion
|
|
64
63
|
export { createJwk, generateExportedKeyPair, toExpJWT };
|
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
import { JwtOptions } from "./types.mjs";
|
|
2
2
|
import { JWTPayload } from "jose";
|
|
3
|
-
//#region src/plugins/jwt/verify.d.ts
|
|
4
3
|
/**
|
|
5
4
|
* Verify a JWT token using the JWKS public keys
|
|
6
5
|
* Returns the payload if valid, null otherwise
|
|
7
6
|
*/
|
|
8
|
-
export declare function verifyJWT<T extends JWTPayload = JWTPayload>(token: string, options?: JwtOptions): Promise<(T & Required<Pick<JWTPayload, "sub" | "aud">>) | null>;
|
|
9
|
-
//#endregion
|
|
7
|
+
export declare function verifyJWT<T extends JWTPayload = JWTPayload>(token: string, options?: JwtOptions): Promise<(T & Required<Pick<JWTPayload, "sub" | "aud">>) | null>;
|
|
@@ -2,7 +2,7 @@ import { getDefaultKeyAlg, getJwksAdapter } from "./adapter.mjs";
|
|
|
2
2
|
import { getCurrentAuthEndpointContext } from "@better-auth/core/context";
|
|
3
3
|
import { base64 } from "@better-auth/utils/base64";
|
|
4
4
|
import { importJWK, jwtVerify } from "jose";
|
|
5
|
-
|
|
5
|
+
// src/plugins/jwt/verify.ts
|
|
6
6
|
/**
|
|
7
7
|
* Verify a JWT token using the JWKS public keys
|
|
8
8
|
* Returns the payload if valid, null otherwise
|
|
@@ -47,5 +47,4 @@ async function verifyJWT(token, options) {
|
|
|
47
47
|
return null;
|
|
48
48
|
}
|
|
49
49
|
}
|
|
50
|
-
//#endregion
|
|
51
50
|
export { verifyJWT };
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
//#region src/plugins/last-login-method/client.d.ts
|
|
2
1
|
/**
|
|
3
2
|
* Configuration for the client-side last login method plugin
|
|
4
3
|
*/
|
|
@@ -43,5 +42,4 @@ export declare const lastLoginMethodClient: (config?: LastLoginMethodClientConfi
|
|
|
43
42
|
*/
|
|
44
43
|
isLastUsedLoginMethod: (method: string) => boolean;
|
|
45
44
|
};
|
|
46
|
-
};
|
|
47
|
-
//#endregion
|
|
45
|
+
};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { parseCookies } from "../../cookies/cookie-utils.mjs";
|
|
2
2
|
import { PACKAGE_VERSION } from "../../version.mjs";
|
|
3
|
-
|
|
3
|
+
// src/plugins/last-login-method/client.ts
|
|
4
4
|
function getCookieValue(name) {
|
|
5
5
|
if (typeof document === "undefined") return null;
|
|
6
6
|
return parseCookies(document.cookie).get(name) ?? null;
|
|
@@ -44,5 +44,4 @@ const lastLoginMethodClient = (config = {}) => {
|
|
|
44
44
|
}
|
|
45
45
|
};
|
|
46
46
|
};
|
|
47
|
-
//#endregion
|
|
48
47
|
export { lastLoginMethodClient };
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { GenericEndpointContext } from "@better-auth/core";
|
|
2
|
-
//#region src/plugins/last-login-method/index.d.ts
|
|
3
2
|
declare module "@better-auth/core" {
|
|
4
3
|
interface BetterAuthPluginRegistry<AuthOptions, Options> {
|
|
5
4
|
"last-login-method": {
|
|
@@ -119,5 +118,4 @@ export declare const lastLoginMethod: <O extends LastLoginMethodOptions>(userCon
|
|
|
119
118
|
};
|
|
120
119
|
} : undefined;
|
|
121
120
|
options: NoInfer<O>;
|
|
122
|
-
};
|
|
123
|
-
//#endregion
|
|
121
|
+
};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { PACKAGE_VERSION } from "../../version.mjs";
|
|
2
2
|
import { createAuthMiddleware } from "@better-auth/core/api";
|
|
3
|
-
|
|
3
|
+
// src/plugins/last-login-method/index.ts
|
|
4
4
|
/**
|
|
5
5
|
* Plugin to track the last used login method
|
|
6
6
|
*/
|
|
@@ -95,5 +95,4 @@ const lastLoginMethod = (userConfig) => {
|
|
|
95
95
|
options: userConfig
|
|
96
96
|
};
|
|
97
97
|
};
|
|
98
|
-
//#endregion
|
|
99
98
|
export { lastLoginMethod };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { PACKAGE_VERSION } from "../../version.mjs";
|
|
2
|
-
|
|
2
|
+
// src/plugins/magic-link/client.ts
|
|
3
3
|
const magicLinkClient = () => {
|
|
4
4
|
return {
|
|
5
5
|
id: "magic-link",
|
|
@@ -7,5 +7,4 @@ const magicLinkClient = () => {
|
|
|
7
7
|
$InferServerPlugin: {}
|
|
8
8
|
};
|
|
9
9
|
};
|
|
10
|
-
//#endregion
|
|
11
10
|
export { magicLinkClient };
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { Awaitable, GenericEndpointContext } from "@better-auth/core";
|
|
2
2
|
import * as z from "zod";
|
|
3
|
-
//#region src/plugins/magic-link/index.d.ts
|
|
4
3
|
declare module "@better-auth/core" {
|
|
5
4
|
interface BetterAuthPluginRegistry<AuthOptions, Options> {
|
|
6
5
|
"magic-link": {
|
|
@@ -206,5 +205,4 @@ export declare const magicLink: (options: MagicLinkOptions) => {
|
|
|
206
205
|
max: number;
|
|
207
206
|
}[];
|
|
208
207
|
options: MagicLinkOptions;
|
|
209
|
-
};
|
|
210
|
-
//#endregion
|
|
208
|
+
};
|
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
import { isAPIError } from "../../utils/is-api-error.mjs";
|
|
2
1
|
import { formCsrfMiddleware, originCheck } from "../../api/middlewares/origin-check.mjs";
|
|
3
|
-
import { parseSessionOutput, parseUserOutput } from "../../db/schema.mjs";
|
|
4
|
-
import { generateRandomString } from "../../crypto/random.mjs";
|
|
5
2
|
import { setSessionCookie } from "../../cookies/index.mjs";
|
|
3
|
+
import { generateRandomString } from "../../crypto/random.mjs";
|
|
4
|
+
import { parseSessionOutput, parseUserOutput } from "../../db/schema.mjs";
|
|
6
5
|
import { revokeUnprovenAccountAccess } from "../../db/revoke-unproven-account-access.mjs";
|
|
6
|
+
import { isAPIError } from "../../utils/is-api-error.mjs";
|
|
7
7
|
import { PACKAGE_VERSION } from "../../version.mjs";
|
|
8
8
|
import { defaultKeyHasher } from "./utils.mjs";
|
|
9
9
|
import { createAuthEndpoint } from "@better-auth/core/api";
|
|
10
10
|
import * as z from "zod";
|
|
11
|
-
|
|
11
|
+
// src/plugins/magic-link/index.ts
|
|
12
12
|
const signInMagicLinkBodySchema = z.object({
|
|
13
13
|
email: z.email().meta({ description: "Email address to send the magic link" }),
|
|
14
14
|
name: z.string().meta({ description: "User display name. Only used if the user is registering for the first time. Eg: \"my-name\"" }).optional(),
|
|
@@ -220,5 +220,4 @@ const magicLink = (options) => {
|
|
|
220
220
|
options
|
|
221
221
|
};
|
|
222
222
|
};
|
|
223
|
-
//#endregion
|
|
224
223
|
export { magicLink };
|
|
@@ -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/magic-link/utils.ts
|
|
4
4
|
const defaultKeyHasher = async (otp) => {
|
|
5
5
|
const hash = await createHash("SHA-256").digest(new TextEncoder().encode(otp));
|
|
6
6
|
return base64Url.encode(new Uint8Array(hash), { padding: false });
|
|
7
7
|
};
|
|
8
|
-
//#endregion
|
|
9
8
|
export { defaultKeyHasher };
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { MULTI_SESSION_ERROR_CODES } from "./error-codes.mjs";
|
|
2
2
|
import { MultiSessionConfig, multiSession } from "./index.mjs";
|
|
3
|
-
//#region src/plugins/multi-session/client.d.ts
|
|
4
3
|
export declare const multiSessionClient: () => {
|
|
5
4
|
id: "multi-session";
|
|
6
5
|
version: string;
|
|
@@ -13,5 +12,4 @@ export declare const multiSessionClient: () => {
|
|
|
13
12
|
INVALID_SESSION_TOKEN: import("@better-auth/core/utils/error-codes").RawError<"INVALID_SESSION_TOKEN">;
|
|
14
13
|
};
|
|
15
14
|
};
|
|
16
|
-
//#endregion
|
|
17
15
|
export { MULTI_SESSION_ERROR_CODES, type MultiSessionConfig };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { PACKAGE_VERSION } from "../../version.mjs";
|
|
2
2
|
import { MULTI_SESSION_ERROR_CODES } from "./error-codes.mjs";
|
|
3
|
-
|
|
3
|
+
// src/plugins/multi-session/client.ts
|
|
4
4
|
const multiSessionClient = () => {
|
|
5
5
|
return {
|
|
6
6
|
id: "multi-session",
|
|
@@ -15,5 +15,4 @@ const multiSessionClient = () => {
|
|
|
15
15
|
$ERROR_CODES: MULTI_SESSION_ERROR_CODES
|
|
16
16
|
};
|
|
17
17
|
};
|
|
18
|
-
//#endregion
|
|
19
18
|
export { MULTI_SESSION_ERROR_CODES, multiSessionClient };
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { defineErrorCodes } from "@better-auth/core/utils/error-codes";
|
|
2
|
-
|
|
2
|
+
// src/plugins/multi-session/error-codes.ts
|
|
3
3
|
const MULTI_SESSION_ERROR_CODES = defineErrorCodes({ INVALID_SESSION_TOKEN: "Invalid session token" });
|
|
4
|
-
//#endregion
|
|
5
4
|
export { MULTI_SESSION_ERROR_CODES };
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { MULTI_SESSION_ERROR_CODES } from "./error-codes.mjs";
|
|
2
2
|
import * as z from "zod";
|
|
3
|
-
//#region src/plugins/multi-session/index.d.ts
|
|
4
3
|
declare module "@better-auth/core" {
|
|
5
4
|
interface BetterAuthPluginRegistry<AuthOptions, Options> {
|
|
6
5
|
"multi-session": {
|
|
@@ -204,5 +203,4 @@ export declare const multiSession: (options?: MultiSessionConfig | undefined) =>
|
|
|
204
203
|
INVALID_SESSION_TOKEN: import("@better-auth/core/utils/error-codes").RawError<"INVALID_SESSION_TOKEN">;
|
|
205
204
|
};
|
|
206
205
|
};
|
|
207
|
-
//#endregion
|
|
208
206
|
export { MULTI_SESSION_ERROR_CODES as ERROR_CODES };
|
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { APIError } from "../../api/index.mjs";
|
|
2
2
|
import { SECURE_COOKIE_PREFIX, parseCookies, parseSetCookieHeader } from "../../cookies/cookie-utils.mjs";
|
|
3
3
|
import { deleteSessionCookie, expireCookie, setSessionCookie } from "../../cookies/index.mjs";
|
|
4
4
|
import { sessionMiddleware } from "../../api/routes/session.mjs";
|
|
5
|
-
import {
|
|
5
|
+
import { parseSessionOutput, parseUserOutput } from "../../db/schema.mjs";
|
|
6
6
|
import { PACKAGE_VERSION } from "../../version.mjs";
|
|
7
7
|
import { MULTI_SESSION_ERROR_CODES } from "./error-codes.mjs";
|
|
8
8
|
import { createAuthEndpoint, createAuthMiddleware } from "@better-auth/core/api";
|
|
9
9
|
import * as z from "zod";
|
|
10
|
-
|
|
10
|
+
// src/plugins/multi-session/index.ts
|
|
11
11
|
const setActiveSessionBodySchema = z.object({ sessionToken: z.string().meta({ description: "The session token to set as active" }) });
|
|
12
12
|
const revokeDeviceSessionBodySchema = z.object({ sessionToken: z.string().meta({ description: "The session token to revoke" }) });
|
|
13
13
|
const multiSession = (options) => {
|
|
@@ -213,5 +213,4 @@ const multiSession = (options) => {
|
|
|
213
213
|
$ERROR_CODES: MULTI_SESSION_ERROR_CODES
|
|
214
214
|
};
|
|
215
215
|
};
|
|
216
|
-
//#endregion
|
|
217
216
|
export { MULTI_SESSION_ERROR_CODES as ERROR_CODES, multiSession };
|
|
@@ -3,7 +3,6 @@ import { OAUTH_POPUP_ERROR_CODES } from "./error-codes.mjs";
|
|
|
3
3
|
import { oauthPopup } from "./index.mjs";
|
|
4
4
|
import { BetterAuthClientOptions, ClientStore } from "@better-auth/core";
|
|
5
5
|
import { BetterFetch, BetterFetchPlugin } from "@better-fetch/fetch";
|
|
6
|
-
//#region src/plugins/oauth-popup/client.d.ts
|
|
7
6
|
/** Inputs for `authClient.signIn.popup`; mirror the redirect sign-in. */
|
|
8
7
|
export interface SignInPopupOptions {
|
|
9
8
|
/** Built-in social provider id (e.g. `"google"`). */
|
|
@@ -72,5 +71,4 @@ export declare const oauthPopupClient: () => {
|
|
|
72
71
|
};
|
|
73
72
|
};
|
|
74
73
|
};
|
|
75
|
-
//#endregion
|
|
76
74
|
export { OAUTH_POPUP_ERROR_CODES, POPUP_TOKEN_STORAGE_KEY };
|
|
@@ -2,7 +2,7 @@ import { getBaseURL } from "../../utils/url.mjs";
|
|
|
2
2
|
import { PACKAGE_VERSION } from "../../version.mjs";
|
|
3
3
|
import { POPUP_TOKEN_STORAGE_KEY } from "./constants.mjs";
|
|
4
4
|
import { OAUTH_POPUP_ERROR_CODES } from "./error-codes.mjs";
|
|
5
|
-
|
|
5
|
+
// src/plugins/oauth-popup/client.ts
|
|
6
6
|
const POPUP_NAME = "better-auth-oauth";
|
|
7
7
|
const POPUP_WIDTH = 500;
|
|
8
8
|
const POPUP_HEIGHT = 600;
|
|
@@ -201,5 +201,4 @@ const oauthPopupClient = () => {
|
|
|
201
201
|
}) } })
|
|
202
202
|
};
|
|
203
203
|
};
|
|
204
|
-
//#endregion
|
|
205
204
|
export { OAUTH_POPUP_ERROR_CODES, POPUP_TOKEN_STORAGE_KEY, createSignInPopup, getStoredPopupToken, oauthPopupClient, popupBearerFetchPlugin };
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
//#region src/plugins/oauth-popup/constants.d.ts
|
|
2
1
|
/** postMessage `type` the completion page posts to its opener. */
|
|
3
2
|
export declare const OAUTH_POPUP_MESSAGE_TYPE = "better-auth:oauth-popup";
|
|
4
3
|
/** DOM id of the inert JSON data block the completion page reads. */
|
|
@@ -6,5 +5,4 @@ export declare const OAUTH_POPUP_DATA_ELEMENT_ID = "better-auth-oauth-popup";
|
|
|
6
5
|
/** Signed cookie carrying the opener origin/nonce from sign-in to callback. */
|
|
7
6
|
export declare const POPUP_MARKER_COOKIE = "oauth_popup";
|
|
8
7
|
/** localStorage key the popup session token is persisted under. */
|
|
9
|
-
export declare const POPUP_TOKEN_STORAGE_KEY = "better-auth.popup_token";
|
|
10
|
-
//#endregion
|
|
8
|
+
export declare const POPUP_TOKEN_STORAGE_KEY = "better-auth.popup_token";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
// src/plugins/oauth-popup/constants.ts
|
|
2
2
|
/** postMessage `type` the completion page posts to its opener. */
|
|
3
3
|
const OAUTH_POPUP_MESSAGE_TYPE = "better-auth:oauth-popup";
|
|
4
4
|
/** DOM id of the inert JSON data block the completion page reads. */
|
|
@@ -7,5 +7,4 @@ const OAUTH_POPUP_DATA_ELEMENT_ID = "better-auth-oauth-popup";
|
|
|
7
7
|
const POPUP_MARKER_COOKIE = "oauth_popup";
|
|
8
8
|
/** localStorage key the popup session token is persisted under. */
|
|
9
9
|
const POPUP_TOKEN_STORAGE_KEY = "better-auth.popup_token";
|
|
10
|
-
//#endregion
|
|
11
10
|
export { OAUTH_POPUP_DATA_ELEMENT_ID, OAUTH_POPUP_MESSAGE_TYPE, POPUP_MARKER_COOKIE, POPUP_TOKEN_STORAGE_KEY };
|
|
@@ -1,8 +1,6 @@
|
|
|
1
|
-
//#region src/plugins/oauth-popup/error-codes.d.ts
|
|
2
1
|
export declare const OAUTH_POPUP_ERROR_CODES: {
|
|
3
2
|
POPUP_SIGN_IN_FAILED: import("@better-auth/core/utils/error-codes").RawError<"POPUP_SIGN_IN_FAILED">;
|
|
4
3
|
POPUP_BLOCKED: import("@better-auth/core/utils/error-codes").RawError<"POPUP_BLOCKED">;
|
|
5
4
|
POPUP_CLOSED: import("@better-auth/core/utils/error-codes").RawError<"POPUP_CLOSED">;
|
|
6
5
|
POPUP_TIMEOUT: import("@better-auth/core/utils/error-codes").RawError<"POPUP_TIMEOUT">;
|
|
7
|
-
};
|
|
8
|
-
//#endregion
|
|
6
|
+
};
|
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
import { defineErrorCodes } from "@better-auth/core/utils/error-codes";
|
|
2
|
-
|
|
2
|
+
// src/plugins/oauth-popup/error-codes.ts
|
|
3
3
|
const OAUTH_POPUP_ERROR_CODES = defineErrorCodes({
|
|
4
4
|
POPUP_SIGN_IN_FAILED: "Popup sign-in failed",
|
|
5
5
|
POPUP_BLOCKED: "Sign-in popup was blocked by the browser",
|
|
6
6
|
POPUP_CLOSED: "Sign-in popup was closed before completing",
|
|
7
7
|
POPUP_TIMEOUT: "Sign-in popup timed out"
|
|
8
8
|
});
|
|
9
|
-
//#endregion
|
|
10
9
|
export { OAUTH_POPUP_ERROR_CODES };
|
|
@@ -2,7 +2,6 @@ import { OAUTH_POPUP_DATA_ELEMENT_ID, OAUTH_POPUP_MESSAGE_TYPE, POPUP_MARKER_COO
|
|
|
2
2
|
import { OAUTH_POPUP_ERROR_CODES } from "./error-codes.mjs";
|
|
3
3
|
import { OAuthPopupData, OAuthPopupMessage } from "./types.mjs";
|
|
4
4
|
import * as z from "zod";
|
|
5
|
-
//#region src/plugins/oauth-popup/index.d.ts
|
|
6
5
|
declare module "@better-auth/core" {
|
|
7
6
|
interface BetterAuthPluginRegistry<AuthOptions, Options> {
|
|
8
7
|
"oauth-popup": {
|
|
@@ -59,5 +58,4 @@ export declare const oauthPopup: () => {
|
|
|
59
58
|
}[];
|
|
60
59
|
};
|
|
61
60
|
};
|
|
62
|
-
//#endregion
|
|
63
61
|
export { OAUTH_POPUP_DATA_ELEMENT_ID, OAUTH_POPUP_ERROR_CODES, OAUTH_POPUP_MESSAGE_TYPE, type OAuthPopupData, type OAuthPopupMessage, POPUP_MARKER_COOKIE };
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { parseSetCookieHeader, splitSetCookieHeader } from "../../cookies/cookie-utils.mjs";
|
|
2
|
-
import { generateRandomString } from "../../crypto/random.mjs";
|
|
3
|
-
import { expireCookie } from "../../cookies/index.mjs";
|
|
4
|
-
import { getAwaitableValue } from "../../context/helpers.mjs";
|
|
5
2
|
import { setOAuthState } from "../../api/state/oauth.mjs";
|
|
6
|
-
import {
|
|
3
|
+
import { getAwaitableValue } from "../../context/helpers.mjs";
|
|
4
|
+
import { expireCookie } from "../../cookies/index.mjs";
|
|
5
|
+
import { generateRandomString } from "../../crypto/random.mjs";
|
|
7
6
|
import { generateIdTokenNonce } from "../../oauth2/state.mjs";
|
|
7
|
+
import { INTERNAL_STATE_KEYS, generateGenericState } from "../../state.mjs";
|
|
8
8
|
import { HIDE_METADATA } from "../../utils/hide-metadata.mjs";
|
|
9
9
|
import { PACKAGE_VERSION } from "../../version.mjs";
|
|
10
10
|
import { OAUTH_POPUP_DATA_ELEMENT_ID, OAUTH_POPUP_MESSAGE_TYPE, POPUP_MARKER_COOKIE } from "./constants.mjs";
|
|
@@ -13,7 +13,7 @@ import { APIError, BASE_ERROR_CODES } from "@better-auth/core/error";
|
|
|
13
13
|
import { safeJSONParse } from "@better-auth/core/utils/json";
|
|
14
14
|
import { createAuthEndpoint, createAuthMiddleware } from "@better-auth/core/api";
|
|
15
15
|
import * as z from "zod";
|
|
16
|
-
|
|
16
|
+
// src/plugins/oauth-popup/index.ts
|
|
17
17
|
let warnedMissingBearer = false;
|
|
18
18
|
/**
|
|
19
19
|
* Escapes `<\/script>` and JS line separators for embedding in a script element.
|
|
@@ -229,5 +229,4 @@ const oauthPopup = () => {
|
|
|
229
229
|
}] }
|
|
230
230
|
};
|
|
231
231
|
};
|
|
232
|
-
//#endregion
|
|
233
232
|
export { OAUTH_POPUP_COMPLETE_SCRIPT, OAUTH_POPUP_DATA_ELEMENT_ID, OAUTH_POPUP_ERROR_CODES, OAUTH_POPUP_MESSAGE_TYPE, OAUTH_POPUP_SCRIPT_CSP_HASH, POPUP_MARKER_COOKIE, oauthPopup };
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { OAUTH_POPUP_MESSAGE_TYPE } from "./constants.mjs";
|
|
2
|
-
//#region src/plugins/oauth-popup/types.d.ts
|
|
3
2
|
/** OAuth error relayed to the opener when the flow fails. */
|
|
4
3
|
export interface OAuthPopupError {
|
|
5
4
|
code: string;
|
|
@@ -24,5 +23,4 @@ export interface OAuthPopupMessage {
|
|
|
24
23
|
export interface OAuthPopupData extends OAuthPopupMessage {
|
|
25
24
|
/** Exact origin the message is posted to (the trusted popup opener). */
|
|
26
25
|
targetOrigin: string;
|
|
27
|
-
}
|
|
28
|
-
//#endregion
|
|
26
|
+
}
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { SecretConfig } from "@better-auth/core";
|
|
2
2
|
import * as z from "zod";
|
|
3
|
-
//#region src/plugins/oauth-proxy/index.d.ts
|
|
4
3
|
declare module "@better-auth/core" {
|
|
5
4
|
interface BetterAuthPluginRegistry<AuthOptions, Options> {
|
|
6
5
|
"oauth-proxy": {
|
|
@@ -121,5 +120,4 @@ export declare const oAuthProxy: <O extends OAuthProxyOptions>(opts?: O) => {
|
|
|
121
120
|
handler: import("better-call").Middleware<import("better-call").MiddlewareOptions, (inputContext: import("better-call").MiddlewareInputContext<import("better-call").MiddlewareOptions>) => Promise<void>>;
|
|
122
121
|
}[];
|
|
123
122
|
};
|
|
124
|
-
};
|
|
125
|
-
//#endregion
|
|
123
|
+
};
|
|
@@ -1,23 +1,23 @@
|
|
|
1
|
-
import { isAPIError } from "../../utils/is-api-error.mjs";
|
|
2
|
-
import { getOrigin } from "../../utils/url.mjs";
|
|
3
1
|
import { originCheck } from "../../api/middlewares/origin-check.mjs";
|
|
2
|
+
import { setOAuthState } from "../../api/state/oauth.mjs";
|
|
3
|
+
import { parseJSON } from "../../client/parser.mjs";
|
|
4
|
+
import { setSessionCookie } from "../../cookies/index.mjs";
|
|
4
5
|
import { parseSetCookieHeader } from "../../cookies/cookie-utils.mjs";
|
|
5
6
|
import { symmetricDecrypt, symmetricEncrypt } from "../../crypto/index.mjs";
|
|
6
|
-
import { setSessionCookie } from "../../cookies/index.mjs";
|
|
7
7
|
import { derivePurposeKey } from "../../crypto/purpose.mjs";
|
|
8
|
+
import { exchangeOAuthCallback } from "../../oauth2/callback.mjs";
|
|
8
9
|
import { redirectOnError } from "../../oauth2/errors.mjs";
|
|
9
10
|
import { handleOAuthUserInfo, linkOAuthAccount } from "../../oauth2/link-account.mjs";
|
|
10
|
-
import { setOAuthState } from "../../api/state/oauth.mjs";
|
|
11
11
|
import { getAuthStateVerificationIdentifier, parseGenericState } from "../../state.mjs";
|
|
12
|
-
import {
|
|
12
|
+
import { isAPIError } from "../../utils/is-api-error.mjs";
|
|
13
|
+
import { getOrigin } from "../../utils/url.mjs";
|
|
13
14
|
import { PACKAGE_VERSION } from "../../version.mjs";
|
|
14
|
-
import { parseJSON } from "../../client/parser.mjs";
|
|
15
15
|
import { checkSkipProxy, resolveCurrentURL, stripTrailingSlash } from "./utils.mjs";
|
|
16
16
|
import { accountSchema, userSchema } from "@better-auth/core/db";
|
|
17
17
|
import { defu as defu$1 } from "defu";
|
|
18
18
|
import { createAuthEndpoint, createAuthMiddleware } from "@better-auth/core/api";
|
|
19
19
|
import * as z from "zod";
|
|
20
|
-
|
|
20
|
+
// src/plugins/oauth-proxy/index.ts
|
|
21
21
|
/**
|
|
22
22
|
* Passthrough payload containing OAuth profile data.
|
|
23
23
|
* Used to transfer OAuth credentials from production to preview
|
|
@@ -394,5 +394,4 @@ const oAuthProxy = (opts) => {
|
|
|
394
394
|
}
|
|
395
395
|
};
|
|
396
396
|
};
|
|
397
|
-
//#endregion
|
|
398
397
|
export { oAuthProxy };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { getOrigin, trimTrailingSlashes } from "../../utils/url.mjs";
|
|
2
2
|
import { env } from "@better-auth/core/env";
|
|
3
|
-
|
|
3
|
+
// src/plugins/oauth-proxy/utils.ts
|
|
4
4
|
/**
|
|
5
5
|
* Strip trailing slashes from URL to prevent double slashes
|
|
6
6
|
*/
|
|
@@ -51,5 +51,4 @@ function checkSkipProxy(ctx, opts) {
|
|
|
51
51
|
if (!currentURL) return false;
|
|
52
52
|
return getOrigin(productionURL) === getOrigin(currentURL);
|
|
53
53
|
}
|
|
54
|
-
//#endregion
|
|
55
54
|
export { checkSkipProxy, resolveCurrentURL, stripTrailingSlash };
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { BetterAuthClientOptions, ClientFetchOption, ClientStore } from "@better-auth/core";
|
|
2
2
|
import { BetterFetch } from "@better-fetch/fetch";
|
|
3
|
-
//#region src/plugins/one-tap/client.d.ts
|
|
4
3
|
declare global {
|
|
5
4
|
interface Window {
|
|
6
5
|
googleScriptInitialized?: boolean | undefined;
|
|
@@ -169,5 +168,4 @@ export declare const oneTapClient: (options: GoogleOneTapOptions) => {
|
|
|
169
168
|
oneTap: (opts?: GoogleOneTapActionOptions | undefined, fetchOptions?: ClientFetchOption | undefined) => Promise<void>;
|
|
170
169
|
};
|
|
171
170
|
getAtoms($fetch: BetterFetch): {};
|
|
172
|
-
};
|
|
173
|
-
//#endregion
|
|
171
|
+
};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { PACKAGE_VERSION } from "../../version.mjs";
|
|
2
2
|
import { isSafeUrlScheme } from "@better-auth/core/utils/url";
|
|
3
|
-
|
|
3
|
+
// src/plugins/one-tap/client.ts
|
|
4
4
|
let isRequestInProgress = false;
|
|
5
5
|
function isFedCMSupported() {
|
|
6
6
|
return typeof window !== "undefined" && "IdentityCredential" in window;
|
|
@@ -188,5 +188,4 @@ const loadGoogleScript = () => {
|
|
|
188
188
|
document.head.appendChild(script);
|
|
189
189
|
});
|
|
190
190
|
};
|
|
191
|
-
//#endregion
|
|
192
191
|
export { oneTapClient };
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import * as z from "zod";
|
|
2
|
-
//#region src/plugins/one-tap/index.d.ts
|
|
3
2
|
declare module "@better-auth/core" {
|
|
4
3
|
interface BetterAuthPluginRegistry<AuthOptions, Options> {
|
|
5
4
|
"one-tap": {
|
|
@@ -75,5 +74,4 @@ export declare const oneTap: (options?: OneTapOptions | undefined) => {
|
|
|
75
74
|
}>;
|
|
76
75
|
};
|
|
77
76
|
options: OneTapOptions | undefined;
|
|
78
|
-
};
|
|
79
|
-
//#endregion
|
|
77
|
+
};
|