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,18 +1,18 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { getSessionFromCtx } from "../../../api/routes/session.mjs";
|
|
2
2
|
import { setSessionCookie } from "../../../cookies/index.mjs";
|
|
3
3
|
import { toZodSchema } from "../../../db/to-zod.mjs";
|
|
4
|
-
import {
|
|
4
|
+
import { getDate } from "../../../utils/date.mjs";
|
|
5
5
|
import { defaultRoles } from "../access/statement.mjs";
|
|
6
|
-
import { ORGANIZATION_ERROR_CODES } from "../error-codes.mjs";
|
|
7
|
-
import { parseRoleList, parseRoles } from "../roles.mjs";
|
|
8
6
|
import { getOrgAdapter } from "../adapter.mjs";
|
|
9
7
|
import { orgMiddleware, orgSessionMiddleware } from "../call.mjs";
|
|
8
|
+
import { ORGANIZATION_ERROR_CODES } from "../error-codes.mjs";
|
|
10
9
|
import { canViewInvitations, hasPermission, withoutCreatorRoleInvitations } from "../has-permission.mjs";
|
|
10
|
+
import { parseRoleList, parseRoles } from "../roles.mjs";
|
|
11
11
|
import { runWithTransaction } from "@better-auth/core/context";
|
|
12
12
|
import { APIError, BASE_ERROR_CODES } from "@better-auth/core/error";
|
|
13
13
|
import { createAuthEndpoint } from "@better-auth/core/api";
|
|
14
14
|
import * as z from "zod";
|
|
15
|
-
|
|
15
|
+
// src/plugins/organization/routes/crud-invites.ts
|
|
16
16
|
const baseInvitationSchema = z.object({
|
|
17
17
|
email: z.string().meta({ description: "The email address of the user to invite" }),
|
|
18
18
|
role: z.union([z.string().meta({ description: "The role to assign to the user" }), z.array(z.string().meta({ description: "The roles to assign to the user" }))]).meta({ description: "The role(s) to assign to the user. It can be `admin`, `member`, owner. Eg: \"member\"" }),
|
|
@@ -612,5 +612,4 @@ const listUserInvitations = (options) => createAuthEndpoint("/organization/list-
|
|
|
612
612
|
const pendingInvitations = (await getOrgAdapter(ctx.context, options).listUserInvitations(userEmail)).filter((inv) => inv.status === "pending");
|
|
613
613
|
return ctx.json(pendingInvitations);
|
|
614
614
|
});
|
|
615
|
-
//#endregion
|
|
616
615
|
export { acceptInvitation, cancelInvitation, createInvitation, getInvitation, listInvitations, listUserInvitations, rejectInvitation };
|
|
@@ -1,13 +1,12 @@
|
|
|
1
1
|
import { FieldAttributeToObject, InferAdditionalFieldsFromPluginOptions, RemoveFieldsWithReturnedFalse } from "../../../db/field.mjs";
|
|
2
2
|
import { Role } from "../../access/types.mjs";
|
|
3
|
-
import "../../../db/index.mjs";
|
|
4
|
-
import { OrganizationOptions } from "../types.mjs";
|
|
5
|
-
import { InferOrganizationRolesFromOption } from "../schema.mjs";
|
|
6
3
|
import "../../index.mjs";
|
|
4
|
+
import "../../../db/index.mjs";
|
|
7
5
|
import { defaultRoles } from "../access/statement.mjs";
|
|
6
|
+
import { InferOrganizationRolesFromOption } from "../schema.mjs";
|
|
7
|
+
import { OrganizationOptions } from "../types.mjs";
|
|
8
8
|
import { LiteralString } from "@better-auth/core";
|
|
9
9
|
import * as z from "zod";
|
|
10
|
-
//#region src/plugins/organization/routes/crud-members.d.ts
|
|
11
10
|
export declare const addMember: <O extends OrganizationOptions>(option: O) => import("better-call").StrictEndpoint<string, {
|
|
12
11
|
method: "POST";
|
|
13
12
|
body: z.ZodObject<{
|
|
@@ -1008,5 +1007,4 @@ export declare const getActiveMemberRole: <O extends OrganizationOptions>(option
|
|
|
1008
1007
|
}>>)[];
|
|
1009
1008
|
}, {
|
|
1010
1009
|
role: InferOrganizationRolesFromOption<O>;
|
|
1011
|
-
}>;
|
|
1012
|
-
//#endregion
|
|
1010
|
+
}>;
|
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
import { toZodSchema } from "../../../db/to-zod.mjs";
|
|
2
1
|
import { getSessionFromCtx, sessionMiddleware } from "../../../api/routes/session.mjs";
|
|
2
|
+
import { toZodSchema } from "../../../db/to-zod.mjs";
|
|
3
3
|
import { defaultRoles } from "../access/statement.mjs";
|
|
4
|
-
import { ORGANIZATION_ERROR_CODES } from "../error-codes.mjs";
|
|
5
|
-
import { parseRoleList, parseRoles } from "../roles.mjs";
|
|
6
4
|
import { getOrgAdapter } from "../adapter.mjs";
|
|
7
5
|
import { orgMiddleware, orgSessionMiddleware } from "../call.mjs";
|
|
6
|
+
import { ORGANIZATION_ERROR_CODES } from "../error-codes.mjs";
|
|
8
7
|
import { hasPermission } from "../has-permission.mjs";
|
|
8
|
+
import { parseRoleList, parseRoles } from "../roles.mjs";
|
|
9
9
|
import { APIError, BASE_ERROR_CODES } from "@better-auth/core/error";
|
|
10
10
|
import { whereOperators } from "@better-auth/core/db/adapter";
|
|
11
11
|
import { createAuthEndpoint } from "@better-auth/core/api";
|
|
12
12
|
import * as z from "zod";
|
|
13
|
-
|
|
13
|
+
// src/plugins/organization/routes/crud-members.ts
|
|
14
14
|
const baseMemberSchema = z.object({
|
|
15
15
|
userId: z.coerce.string().meta({ description: "The ID of the user to add as a member. Eg: \"user-id\"" }),
|
|
16
16
|
role: z.union([z.string(), z.array(z.string())]).meta({ description: "The role(s) to assign to the new member. Eg: [\"admin\", \"sale\"]" }),
|
|
@@ -512,5 +512,4 @@ const getActiveMemberRole = (options) => createAuthEndpoint("/organization/get-a
|
|
|
512
512
|
if (!member) throw APIError.from("FORBIDDEN", ORGANIZATION_ERROR_CODES.YOU_ARE_NOT_A_MEMBER_OF_THIS_ORGANIZATION);
|
|
513
513
|
return ctx.json({ role: member.role });
|
|
514
514
|
});
|
|
515
|
-
//#endregion
|
|
516
515
|
export { addMember, getActiveMember, getActiveMemberRole, leaveOrganization, listMembers, removeMember, updateMemberRole };
|
|
@@ -1,13 +1,12 @@
|
|
|
1
1
|
import { FieldAttributeToObject, InferAdditionalFieldsFromPluginOptions, RemoveFieldsWithReturnedFalse } from "../../../db/field.mjs";
|
|
2
2
|
import { Role } from "../../access/types.mjs";
|
|
3
|
+
import "../access/index.mjs";
|
|
4
|
+
import "../../index.mjs";
|
|
3
5
|
import "../../../db/index.mjs";
|
|
4
|
-
import { OrganizationOptions } from "../types.mjs";
|
|
5
6
|
import { InferInvitation, InferMember, InferTeam } from "../schema.mjs";
|
|
6
|
-
import "../../index.mjs";
|
|
7
7
|
import { defaultRoles } from "../access/statement.mjs";
|
|
8
|
-
import "../
|
|
8
|
+
import { OrganizationOptions } from "../types.mjs";
|
|
9
9
|
import * as z from "zod";
|
|
10
|
-
//#region src/plugins/organization/routes/crud-org.d.ts
|
|
11
10
|
export declare const createOrganization: <O extends OrganizationOptions>(options?: O | undefined) => import("better-call").StrictEndpoint<"/organization/create", {
|
|
12
11
|
method: "POST";
|
|
13
12
|
body: z.ZodObject<{
|
|
@@ -912,5 +911,4 @@ export declare const listOrganizations: <O extends OrganizationOptions>(options:
|
|
|
912
911
|
organization?: {
|
|
913
912
|
additionalFields: infer Field extends Record<string, import("@better-auth/core/db").DBFieldAttribute>;
|
|
914
913
|
} | undefined;
|
|
915
|
-
} ? FieldAttributeToObject<RemoveFieldsWithReturnedFalse<Field>> : {}) extends (infer T) ? { [K in keyof T]: T[K]; } : never)[]>;
|
|
916
|
-
//#endregion
|
|
914
|
+
} ? FieldAttributeToObject<RemoveFieldsWithReturnedFalse<Field>> : {}) extends (infer T) ? { [K in keyof T]: T[K]; } : never)[]>;
|
|
@@ -1,14 +1,14 @@
|
|
|
1
|
+
import { getSessionFromCtx, requestOnlySessionMiddleware } from "../../../api/routes/session.mjs";
|
|
1
2
|
import { setSessionCookie } from "../../../cookies/index.mjs";
|
|
2
3
|
import { toZodSchema } from "../../../db/to-zod.mjs";
|
|
3
|
-
import { getSessionFromCtx, requestOnlySessionMiddleware } from "../../../api/routes/session.mjs";
|
|
4
|
-
import { ORGANIZATION_ERROR_CODES } from "../error-codes.mjs";
|
|
5
4
|
import { getOrgAdapter } from "../adapter.mjs";
|
|
6
5
|
import { orgMiddleware, orgSessionMiddleware } from "../call.mjs";
|
|
6
|
+
import { ORGANIZATION_ERROR_CODES } from "../error-codes.mjs";
|
|
7
7
|
import { canViewInvitations, hasPermission, withoutCreatorRoleInvitations } from "../has-permission.mjs";
|
|
8
8
|
import { APIError } from "@better-auth/core/error";
|
|
9
9
|
import { createAuthEndpoint } from "@better-auth/core/api";
|
|
10
10
|
import * as z from "zod";
|
|
11
|
-
|
|
11
|
+
// src/plugins/organization/routes/crud-org.ts
|
|
12
12
|
const baseOrganizationSchema = z.object({
|
|
13
13
|
name: z.string().min(1).meta({ description: "The name of the organization" }),
|
|
14
14
|
slug: z.string().min(1).meta({ description: "The slug of the organization" }),
|
|
@@ -272,11 +272,6 @@ const deleteOrganization = (options) => {
|
|
|
272
272
|
organizationId,
|
|
273
273
|
options: ctx.context.orgOptions
|
|
274
274
|
}, ctx)) throw APIError.from("FORBIDDEN", ORGANIZATION_ERROR_CODES.YOU_ARE_NOT_ALLOWED_TO_DELETE_THIS_ORGANIZATION);
|
|
275
|
-
if (organizationId === session.session.activeOrganizationId)
|
|
276
|
-
/**
|
|
277
|
-
* If the organization is deleted, we set the active organization to null
|
|
278
|
-
*/
|
|
279
|
-
await adapter.setActiveOrganization(session.session.token, null, ctx);
|
|
280
275
|
const org = await adapter.findOrganizationById(organizationId);
|
|
281
276
|
if (!org) throw APIError.fromStatus("BAD_REQUEST");
|
|
282
277
|
if (options?.organizationHooks?.beforeDeleteOrganization) await options.organizationHooks.beforeDeleteOrganization({
|
|
@@ -284,6 +279,11 @@ const deleteOrganization = (options) => {
|
|
|
284
279
|
user: session.user
|
|
285
280
|
}, ctx);
|
|
286
281
|
await adapter.deleteOrganization(organizationId);
|
|
282
|
+
if (organizationId === session.session.activeOrganizationId)
|
|
283
|
+
/**
|
|
284
|
+
* If the organization is deleted, we set the active organization to null
|
|
285
|
+
*/
|
|
286
|
+
await adapter.setActiveOrganization(session.session.token, null, ctx);
|
|
287
287
|
if (options?.organizationHooks?.afterDeleteOrganization) await options.organizationHooks.afterDeleteOrganization({
|
|
288
288
|
organization: org,
|
|
289
289
|
user: session.user
|
|
@@ -462,5 +462,4 @@ const listOrganizations = (options) => createAuthEndpoint("/organization/list",
|
|
|
462
462
|
const organizations = await getOrgAdapter(ctx.context, options).listOrganizations(ctx.context.session.user.id);
|
|
463
463
|
return ctx.json(organizations);
|
|
464
464
|
});
|
|
465
|
-
//#endregion
|
|
466
465
|
export { checkOrganizationSlug, createOrganization, deleteOrganization, getFullOrganization, getOrganization, listOrganizations, setActiveOrganization, updateOrganization };
|
|
@@ -1,14 +1,13 @@
|
|
|
1
1
|
import { FieldAttributeToObject, InferAdditionalFieldsFromPluginOptions, RemoveFieldsWithReturnedFalse } from "../../../db/field.mjs";
|
|
2
|
-
import
|
|
2
|
+
import "../access/index.mjs";
|
|
3
3
|
import { Role } from "../../access/types.mjs";
|
|
4
|
+
import "../../index.mjs";
|
|
4
5
|
import "../../../db/index.mjs";
|
|
5
|
-
import {
|
|
6
|
+
import { PrettifyDeep } from "../../../types/helper.mjs";
|
|
6
7
|
import { teamSchema } from "../schema.mjs";
|
|
7
|
-
import "../../index.mjs";
|
|
8
8
|
import { defaultRoles } from "../access/statement.mjs";
|
|
9
|
-
import "../
|
|
9
|
+
import { OrganizationOptions } from "../types.mjs";
|
|
10
10
|
import * as z from "zod";
|
|
11
|
-
//#region src/plugins/organization/routes/crud-team.d.ts
|
|
12
11
|
declare const teamBaseSchema: z.ZodObject<{
|
|
13
12
|
name: z.ZodString;
|
|
14
13
|
organizationId: z.ZodOptional<z.ZodString>;
|
|
@@ -1233,5 +1232,4 @@ export declare const removeTeamMember: <O extends OrganizationOptions>(options:
|
|
|
1233
1232
|
}, {
|
|
1234
1233
|
message: string;
|
|
1235
1234
|
}>;
|
|
1236
|
-
//#endregion
|
|
1237
1235
|
export {};
|
|
@@ -1,16 +1,16 @@
|
|
|
1
|
+
import { getSessionFromCtx } from "../../../api/routes/session.mjs";
|
|
1
2
|
import { setSessionCookie } from "../../../cookies/index.mjs";
|
|
2
3
|
import { toZodSchema } from "../../../db/to-zod.mjs";
|
|
3
|
-
import { getSessionFromCtx } from "../../../api/routes/session.mjs";
|
|
4
|
-
import { ORGANIZATION_ERROR_CODES } from "../error-codes.mjs";
|
|
5
4
|
import { getOrgAdapter } from "../adapter.mjs";
|
|
6
5
|
import { orgMiddleware, orgSessionMiddleware } from "../call.mjs";
|
|
6
|
+
import { ORGANIZATION_ERROR_CODES } from "../error-codes.mjs";
|
|
7
7
|
import { hasPermission } from "../has-permission.mjs";
|
|
8
8
|
import { teamSchema } from "../schema.mjs";
|
|
9
9
|
import { getCurrentAdapter, runWithTransaction } from "@better-auth/core/context";
|
|
10
10
|
import { APIError } from "@better-auth/core/error";
|
|
11
11
|
import { createAuthEndpoint } from "@better-auth/core/api";
|
|
12
12
|
import * as z from "zod";
|
|
13
|
-
|
|
13
|
+
// src/plugins/organization/routes/crud-team.ts
|
|
14
14
|
const teamBaseSchema = z.object({
|
|
15
15
|
name: z.string().meta({ description: "The name of the team. Eg: \"my-team\"" }),
|
|
16
16
|
organizationId: z.string().meta({ description: "The organization ID which the team will be created in. Defaults to the active organization. Eg: \"organization-id\"" }).optional()
|
|
@@ -764,5 +764,4 @@ const removeTeamMember = (options) => createAuthEndpoint("/organization/remove-t
|
|
|
764
764
|
});
|
|
765
765
|
return ctx.json({ message: "Team member removed successfully." });
|
|
766
766
|
});
|
|
767
|
-
//#endregion
|
|
768
767
|
export { addTeamMember, createTeam, listOrganizationTeams, listTeamMembers, listUserTeams, removeTeam, removeTeamMember, setActiveTeam, updateTeam };
|
|
@@ -4,7 +4,6 @@ import { OrganizationOptions } from "./types.mjs";
|
|
|
4
4
|
import { BetterAuthPluginDBSchema, DBFieldAttribute } from "@better-auth/core/db";
|
|
5
5
|
import { Prettify } from "better-call";
|
|
6
6
|
import * as z from "zod";
|
|
7
|
-
//#region src/plugins/organization/schema.d.ts
|
|
8
7
|
type InferSchema<Schema extends BetterAuthPluginDBSchema, TableName extends string, DefaultFields> = {
|
|
9
8
|
modelName: Schema[TableName] extends {
|
|
10
9
|
modelName: infer M;
|
|
@@ -386,5 +385,4 @@ export type InferInvitation<O extends OrganizationOptions, isClientSide extends
|
|
|
386
385
|
expiresAt: Date;
|
|
387
386
|
createdAt: Date;
|
|
388
387
|
}) & InferAdditionalFieldsOutput<"invitation", O, isClientSide>>;
|
|
389
|
-
//#endregion
|
|
390
388
|
export {};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { generateId } from "@better-auth/core/utils/id";
|
|
2
2
|
import * as z from "zod";
|
|
3
|
-
|
|
3
|
+
// src/plugins/organization/schema.ts
|
|
4
4
|
const roleSchema = z.string();
|
|
5
5
|
const invitationStatus = z.enum([
|
|
6
6
|
"pending",
|
|
@@ -61,5 +61,4 @@ const defaultRoles = [
|
|
|
61
61
|
"owner"
|
|
62
62
|
];
|
|
63
63
|
z.union([z.enum(defaultRoles), z.array(z.enum(defaultRoles))]);
|
|
64
|
-
//#endregion
|
|
65
64
|
export { invitationStatus, roleSchema, teamSchema };
|
|
@@ -5,7 +5,6 @@ import "../access/index.mjs";
|
|
|
5
5
|
import { Invitation, Member, Organization, OrganizationRole, Team, TeamMember } from "./schema.mjs";
|
|
6
6
|
import { AuthContext, Awaitable, GenericEndpointContext } from "@better-auth/core";
|
|
7
7
|
import { DBFieldAttribute } from "@better-auth/core/db";
|
|
8
|
-
//#region src/plugins/organization/types.d.ts
|
|
9
8
|
export interface OrganizationOptions {
|
|
10
9
|
/**
|
|
11
10
|
* Configure whether new users are able to create new organizations.
|
|
@@ -686,5 +685,4 @@ export interface OrganizationOptions {
|
|
|
686
685
|
organization: Organization & Record<string, any>;
|
|
687
686
|
}) => Promise<void>;
|
|
688
687
|
} | undefined;
|
|
689
|
-
}
|
|
690
|
-
//#endregion
|
|
688
|
+
}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import { PhoneNumberOptions, UserWithPhoneNumber } from "./types.mjs";
|
|
2
1
|
import { phoneNumber } from "./index.mjs";
|
|
2
|
+
import { PhoneNumberOptions, UserWithPhoneNumber } from "./types.mjs";
|
|
3
3
|
import { PHONE_NUMBER_ERROR_CODES } from "./error-codes.mjs";
|
|
4
|
-
//#region src/plugins/phone-number/client.d.ts
|
|
5
4
|
export declare const phoneNumberClient: () => {
|
|
6
5
|
id: "phoneNumber";
|
|
7
6
|
version: string;
|
|
@@ -27,5 +26,4 @@ export declare const phoneNumberClient: () => {
|
|
|
27
26
|
SEND_OTP_NOT_IMPLEMENTED: import("@better-auth/core/utils/error-codes").RawError<"SEND_OTP_NOT_IMPLEMENTED">;
|
|
28
27
|
};
|
|
29
28
|
};
|
|
30
|
-
//#endregion
|
|
31
29
|
export { PHONE_NUMBER_ERROR_CODES, type PhoneNumberOptions, type UserWithPhoneNumber };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { PACKAGE_VERSION } from "../../version.mjs";
|
|
2
2
|
import { PHONE_NUMBER_ERROR_CODES } from "./error-codes.mjs";
|
|
3
|
-
|
|
3
|
+
// src/plugins/phone-number/client.ts
|
|
4
4
|
const phoneNumberClient = () => {
|
|
5
5
|
return {
|
|
6
6
|
id: "phoneNumber",
|
|
@@ -15,5 +15,4 @@ const phoneNumberClient = () => {
|
|
|
15
15
|
$ERROR_CODES: PHONE_NUMBER_ERROR_CODES
|
|
16
16
|
};
|
|
17
17
|
};
|
|
18
|
-
//#endregion
|
|
19
18
|
export { PHONE_NUMBER_ERROR_CODES, phoneNumberClient };
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
//#region src/plugins/phone-number/error-codes.d.ts
|
|
2
1
|
export declare const PHONE_NUMBER_ERROR_CODES: {
|
|
3
2
|
OTP_EXPIRED: import("@better-auth/core/utils/error-codes").RawError<"OTP_EXPIRED">;
|
|
4
3
|
INVALID_OTP: import("@better-auth/core/utils/error-codes").RawError<"INVALID_OTP">;
|
|
@@ -14,5 +13,4 @@ export declare const PHONE_NUMBER_ERROR_CODES: {
|
|
|
14
13
|
PHONE_NUMBER_CANNOT_BE_UPDATED: import("@better-auth/core/utils/error-codes").RawError<"PHONE_NUMBER_CANNOT_BE_UPDATED">;
|
|
15
14
|
PHONE_NUMBER_CANNOT_BE_SET: import("@better-auth/core/utils/error-codes").RawError<"PHONE_NUMBER_CANNOT_BE_SET">;
|
|
16
15
|
SEND_OTP_NOT_IMPLEMENTED: import("@better-auth/core/utils/error-codes").RawError<"SEND_OTP_NOT_IMPLEMENTED">;
|
|
17
|
-
};
|
|
18
|
-
//#endregion
|
|
16
|
+
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { defineErrorCodes } from "@better-auth/core/utils/error-codes";
|
|
2
|
-
|
|
2
|
+
// src/plugins/phone-number/error-codes.ts
|
|
3
3
|
const PHONE_NUMBER_ERROR_CODES = defineErrorCodes({
|
|
4
4
|
INVALID_PHONE_NUMBER: "Invalid phone number",
|
|
5
5
|
PHONE_NUMBER_EXIST: "Phone number already exists",
|
|
@@ -16,5 +16,4 @@ const PHONE_NUMBER_ERROR_CODES = defineErrorCodes({
|
|
|
16
16
|
SEND_OTP_NOT_IMPLEMENTED: "sendOTP not implemented",
|
|
17
17
|
TOO_MANY_ATTEMPTS: "Too many attempts"
|
|
18
18
|
});
|
|
19
|
-
//#endregion
|
|
20
19
|
export { PHONE_NUMBER_ERROR_CODES };
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { PhoneNumberOptions, UserWithPhoneNumber } from "./types.mjs";
|
|
2
|
-
//#region src/plugins/phone-number/index.d.ts
|
|
3
2
|
declare module "@better-auth/core" {
|
|
4
3
|
interface BetterAuthPluginRegistry<AuthOptions, Options> {
|
|
5
4
|
"phone-number": {
|
|
@@ -374,5 +373,4 @@ export declare const phoneNumber: (options?: PhoneNumberOptions | undefined) =>
|
|
|
374
373
|
SEND_OTP_NOT_IMPLEMENTED: import("@better-auth/core/utils/error-codes").RawError<"SEND_OTP_NOT_IMPLEMENTED">;
|
|
375
374
|
};
|
|
376
375
|
};
|
|
377
|
-
//#endregion
|
|
378
376
|
export type { PhoneNumberOptions, UserWithPhoneNumber };
|
|
@@ -5,7 +5,7 @@ import { consumePhoneNumberOTP, requestPasswordResetPhoneNumber, resetPasswordPh
|
|
|
5
5
|
import { schema } from "./schema.mjs";
|
|
6
6
|
import { APIError } from "@better-auth/core/error";
|
|
7
7
|
import { createAuthMiddleware } from "@better-auth/core/api";
|
|
8
|
-
|
|
8
|
+
// src/plugins/phone-number/index.ts
|
|
9
9
|
const phoneNumber = (options) => {
|
|
10
10
|
const opts = {
|
|
11
11
|
expiresIn: options?.expiresIn || 300,
|
|
@@ -69,5 +69,4 @@ const phoneNumber = (options) => {
|
|
|
69
69
|
$ERROR_CODES: PHONE_NUMBER_ERROR_CODES
|
|
70
70
|
};
|
|
71
71
|
};
|
|
72
|
-
//#endregion
|
|
73
72
|
export { phoneNumber };
|
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
import { parseUserInput, parseUserOutput } from "../../db/schema.mjs";
|
|
2
|
-
import { getDate } from "../../utils/date.mjs";
|
|
3
|
-
import { generateRandomString } from "../../crypto/random.mjs";
|
|
4
|
-
import { setSessionCookie } from "../../cookies/index.mjs";
|
|
5
1
|
import { getAuthoritativeSessionFromCtx } from "../../api/routes/session.mjs";
|
|
2
|
+
import { isSessionOutsideStore } from "../../api/state/session-source.mjs";
|
|
3
|
+
import { setSessionCookie } from "../../cookies/index.mjs";
|
|
4
|
+
import { generateRandomString } from "../../crypto/random.mjs";
|
|
5
|
+
import { parseUserInput, parseUserOutput } from "../../db/schema.mjs";
|
|
6
6
|
import { HIDE_METADATA } from "../../utils/hide-metadata.mjs";
|
|
7
|
+
import { getDate } from "../../utils/date.mjs";
|
|
7
8
|
import { assertPasswordNotTooLong, assertPasswordNotTooShort, resetCredentialPassword } from "../../utils/password.mjs";
|
|
8
|
-
import { isSessionOutsideStore } from "../../api/state/session-source.mjs";
|
|
9
9
|
import { PHONE_NUMBER_ERROR_CODES } from "./error-codes.mjs";
|
|
10
10
|
import { APIError, BASE_ERROR_CODES } from "@better-auth/core/error";
|
|
11
11
|
import { createAuthEndpoint } from "@better-auth/core/api";
|
|
12
12
|
import * as z from "zod";
|
|
13
|
-
|
|
13
|
+
// src/plugins/phone-number/routes.ts
|
|
14
14
|
const signInPhoneNumberBodySchema = z.object({
|
|
15
15
|
phoneNumber: z.string().meta({ description: "Phone number to sign in. Eg: \"+1234567890\"" }),
|
|
16
16
|
password: z.string().meta({ description: "Password to use for sign in." }),
|
|
@@ -542,5 +542,4 @@ function phoneNumberResetIdentifier(phoneNumber) {
|
|
|
542
542
|
function generateOTP(size) {
|
|
543
543
|
return generateRandomString(size, "0-9");
|
|
544
544
|
}
|
|
545
|
-
//#endregion
|
|
546
545
|
export { consumePhoneNumberOTP, requestPasswordResetPhoneNumber, resetPasswordPhoneNumber, sendPhoneNumberOTP, signInPhoneNumber, verifyPhoneNumber };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
// src/plugins/phone-number/schema.ts
|
|
2
2
|
const schema = { user: { fields: {
|
|
3
3
|
phoneNumber: {
|
|
4
4
|
type: "string",
|
|
@@ -14,5 +14,4 @@ const schema = { user: { fields: {
|
|
|
14
14
|
input: false
|
|
15
15
|
}
|
|
16
16
|
} } };
|
|
17
|
-
//#endregion
|
|
18
17
|
export { schema };
|
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
import { User } from "../../types/models.mjs";
|
|
2
|
-
import { InferOptionSchema } from "../../types/plugins.mjs";
|
|
3
2
|
import "../../types/index.mjs";
|
|
3
|
+
import { InferOptionSchema } from "../../types/plugins.mjs";
|
|
4
4
|
import { schema } from "./schema.mjs";
|
|
5
5
|
import { Awaitable, GenericEndpointContext } from "@better-auth/core";
|
|
6
|
-
//#region src/plugins/phone-number/types.d.ts
|
|
7
6
|
export interface UserWithPhoneNumber extends User {
|
|
8
7
|
phoneNumber: string;
|
|
9
8
|
phoneNumberVerified: boolean;
|
|
@@ -111,5 +110,4 @@ export interface PhoneNumberOptions {
|
|
|
111
110
|
* @default 3
|
|
112
111
|
*/
|
|
113
112
|
allowedAttempts?: number | undefined;
|
|
114
|
-
}
|
|
115
|
-
//#endregion
|
|
113
|
+
}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { siwe } from "./index.mjs";
|
|
2
|
-
//#region src/plugins/siwe/client.d.ts
|
|
3
2
|
export declare const siweClient: () => {
|
|
4
3
|
id: "siwe";
|
|
5
4
|
version: string;
|
|
@@ -8,5 +7,4 @@ export declare const siweClient: () => {
|
|
|
8
7
|
"/siwe/nonce": "POST";
|
|
9
8
|
"/siwe/get-nonce": "POST";
|
|
10
9
|
};
|
|
11
|
-
};
|
|
12
|
-
//#endregion
|
|
10
|
+
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { PACKAGE_VERSION } from "../../version.mjs";
|
|
2
|
-
|
|
2
|
+
// src/plugins/siwe/client.ts
|
|
3
3
|
const siweClient = () => {
|
|
4
4
|
return {
|
|
5
5
|
id: "siwe",
|
|
@@ -11,5 +11,4 @@ const siweClient = () => {
|
|
|
11
11
|
}
|
|
12
12
|
};
|
|
13
13
|
};
|
|
14
|
-
//#endregion
|
|
15
14
|
export { siweClient };
|
|
@@ -3,7 +3,6 @@ import "../../types/index.mjs";
|
|
|
3
3
|
import { WalletAddressSchema, schema } from "./schema.mjs";
|
|
4
4
|
import { ENSLookupArgs, ENSLookupResult, SIWEVerifyMessageArgs } from "./types.mjs";
|
|
5
5
|
import * as z from "zod";
|
|
6
|
-
//#region src/plugins/siwe/index.d.ts
|
|
7
6
|
declare module "@better-auth/core" {
|
|
8
7
|
interface BetterAuthPluginRegistry<AuthOptions, Options> {
|
|
9
8
|
siwe: {
|
|
@@ -56,5 +55,4 @@ export declare const siwe: (options: SIWEPluginOptions) => {
|
|
|
56
55
|
}>;
|
|
57
56
|
};
|
|
58
57
|
options: SIWEPluginOptions;
|
|
59
|
-
};
|
|
60
|
-
//#endregion
|
|
58
|
+
};
|
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
import { isAPIError } from "../../utils/is-api-error.mjs";
|
|
2
|
-
import { mergeSchema } from "../../db/schema.mjs";
|
|
3
|
-
import { setSessionCookie } from "../../cookies/index.mjs";
|
|
4
1
|
import { APIError } from "../../api/index.mjs";
|
|
5
|
-
import {
|
|
2
|
+
import { setSessionCookie } from "../../cookies/index.mjs";
|
|
3
|
+
import { mergeSchema } from "../../db/schema.mjs";
|
|
6
4
|
import { toChecksumAddress } from "../../utils/hashing.mjs";
|
|
5
|
+
import { isAPIError } from "../../utils/is-api-error.mjs";
|
|
6
|
+
import { PACKAGE_VERSION } from "../../version.mjs";
|
|
7
7
|
import { normalizeSiweDomain, parseSiweMessage } from "./parse-message.mjs";
|
|
8
8
|
import { schema } from "./schema.mjs";
|
|
9
9
|
import { getCurrentAdapter, runWithTransaction } from "@better-auth/core/context";
|
|
10
10
|
import { createAuthEndpoint } from "@better-auth/core/api";
|
|
11
11
|
import * as z from "zod";
|
|
12
12
|
import { createPlaceholderEmail } from "@better-auth/core/utils/email";
|
|
13
|
-
|
|
13
|
+
// src/plugins/siwe/index.ts
|
|
14
14
|
const signedWalletAddressSchema = z.string().regex(/^0x[a-fA-F0-9]{40}$/).length(42);
|
|
15
15
|
const SIWE_VERIFICATION_IDENTIFIER_PREFIX = "siwe:";
|
|
16
16
|
const SIWE_NONCE_MAX_LENGTH = 250;
|
|
@@ -274,9 +274,9 @@ const siwe = (options) => {
|
|
|
274
274
|
});
|
|
275
275
|
} catch (error) {
|
|
276
276
|
if (isAPIError(error)) throw error;
|
|
277
|
+
ctx.context.logger.error("Failed to verify SIWE message", error);
|
|
277
278
|
throw APIError.fromStatus("UNAUTHORIZED", {
|
|
278
279
|
message: "Something went wrong. Please try again later.",
|
|
279
|
-
error: error instanceof Error ? error.message : "Unknown error",
|
|
280
280
|
status: 401
|
|
281
281
|
});
|
|
282
282
|
}
|
|
@@ -285,5 +285,4 @@ const siwe = (options) => {
|
|
|
285
285
|
options
|
|
286
286
|
};
|
|
287
287
|
};
|
|
288
|
-
//#endregion
|
|
289
288
|
export { siwe };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
// src/plugins/siwe/parse-message.ts
|
|
2
2
|
const HEADER_REGEX = /^(?:([a-zA-Z][a-zA-Z0-9+.-]*):\/\/)?(\S+) wants you to sign in with your Ethereum account:$/;
|
|
3
3
|
const ADDRESS_REGEX = /^0x[a-fA-F0-9]{40}$/;
|
|
4
4
|
const FIELD_REGEX = /^([A-Za-z ]+): (.*)$/;
|
|
@@ -54,5 +54,4 @@ function normalizeSiweDomain(domain) {
|
|
|
54
54
|
const pathStart = withoutScheme.indexOf("/");
|
|
55
55
|
return pathStart === -1 ? withoutScheme : withoutScheme.slice(0, pathStart);
|
|
56
56
|
}
|
|
57
|
-
//#endregion
|
|
58
57
|
export { normalizeSiweDomain, parseSiweMessage };
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
//#region src/plugins/siwe/schema.d.ts
|
|
2
1
|
export declare const schema: {
|
|
3
2
|
walletAddress: {
|
|
4
3
|
fields: {
|
|
@@ -30,5 +29,4 @@ export declare const schema: {
|
|
|
30
29
|
};
|
|
31
30
|
};
|
|
32
31
|
};
|
|
33
|
-
export type WalletAddressSchema = typeof schema;
|
|
34
|
-
//#endregion
|
|
32
|
+
export type WalletAddressSchema = typeof schema;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
// src/plugins/siwe/schema.ts
|
|
2
2
|
const schema = { walletAddress: { fields: {
|
|
3
3
|
userId: {
|
|
4
4
|
type: "string",
|
|
@@ -26,5 +26,4 @@ const schema = { walletAddress: { fields: {
|
|
|
26
26
|
required: true
|
|
27
27
|
}
|
|
28
28
|
} } };
|
|
29
|
-
//#endregion
|
|
30
29
|
export { schema };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { createCookieHeaders, createTestCookie } from "./cookie-builder.mjs";
|
|
2
2
|
import { sessionSchema } from "@better-auth/core/db";
|
|
3
|
-
|
|
3
|
+
// src/plugins/test-utils/auth-helpers.ts
|
|
4
4
|
function createSession(ctx, opts) {
|
|
5
5
|
const additionalFields = Object.fromEntries(Object.entries(opts.session ?? {}).filter(([key]) => !Object.hasOwn(sessionSchema.shape, key)));
|
|
6
6
|
return ctx.internalAdapter.createSession(opts.userId, false, additionalFields, true);
|
|
@@ -31,5 +31,4 @@ function createGetCookies(ctx) {
|
|
|
31
31
|
return createTestCookie(ctx, session.token, opts.domain);
|
|
32
32
|
};
|
|
33
33
|
}
|
|
34
|
-
//#endregion
|
|
35
34
|
export { createGetAuthHeaders, createGetCookies, createLogin };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { makeSignature } from "../../crypto/index.mjs";
|
|
2
|
-
|
|
2
|
+
// src/plugins/test-utils/cookie-builder.ts
|
|
3
3
|
/**
|
|
4
4
|
* Signs a cookie value using HMAC-SHA256
|
|
5
5
|
*/
|
|
@@ -51,5 +51,4 @@ function normalizeSameSite(sameSite) {
|
|
|
51
51
|
}
|
|
52
52
|
return "Lax";
|
|
53
53
|
}
|
|
54
|
-
//#endregion
|
|
55
54
|
export { createCookieHeaders, createTestCookie };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { generateRandomString } from "../../crypto/random.mjs";
|
|
2
|
-
|
|
2
|
+
// src/plugins/test-utils/db-helpers.ts
|
|
3
3
|
function createSaveUser(ctx) {
|
|
4
4
|
return async (user) => {
|
|
5
5
|
return ctx.internalAdapter.createUser(user, { method: "test" });
|
|
@@ -61,5 +61,4 @@ function createAddMember(ctx) {
|
|
|
61
61
|
});
|
|
62
62
|
};
|
|
63
63
|
}
|
|
64
|
-
//#endregion
|
|
65
64
|
export { createAddMember, createDeleteOrganization, createDeleteUser, createSaveOrganization, createSaveUser };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { generateRandomString } from "../../crypto/random.mjs";
|
|
2
|
-
|
|
2
|
+
// src/plugins/test-utils/factories.ts
|
|
3
3
|
function createUserFactory(ctx) {
|
|
4
4
|
return (overrides = {}) => {
|
|
5
5
|
const generatedId = ctx.generateId({ model: "user" });
|
|
@@ -34,5 +34,4 @@ function createOrganizationFactory(ctx) {
|
|
|
34
34
|
};
|
|
35
35
|
};
|
|
36
36
|
}
|
|
37
|
-
//#endregion
|
|
38
37
|
export { createOrganizationFactory, createUserFactory };
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { LoginResult, TestAuthOptions, TestCookie, TestHelpers, TestUtilsOptions } from "./types.mjs";
|
|
2
|
-
//#region src/plugins/test-utils/index.d.ts
|
|
3
2
|
declare module "@better-auth/core" {
|
|
4
3
|
interface BetterAuthPluginRegistry<AuthOptions, Options> {
|
|
5
4
|
"test-utils": {
|
|
@@ -67,5 +66,4 @@ export declare const testUtils: (options?: TestUtilsOptions) => {
|
|
|
67
66
|
};
|
|
68
67
|
options: TestUtilsOptions;
|
|
69
68
|
};
|
|
70
|
-
//#endregion
|
|
71
69
|
export type { LoginResult, TestAuthOptions, TestCookie, TestHelpers, TestUtilsOptions };
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { PACKAGE_VERSION } from "../../version.mjs";
|
|
2
1
|
import { createGetAuthHeaders, createGetCookies, createLogin } from "./auth-helpers.mjs";
|
|
3
2
|
import { createAddMember, createDeleteOrganization, createDeleteUser, createSaveOrganization, createSaveUser } from "./db-helpers.mjs";
|
|
4
3
|
import { createOrganizationFactory, createUserFactory } from "./factories.mjs";
|
|
5
4
|
import { createOTPStore } from "./otp-sink.mjs";
|
|
6
|
-
|
|
5
|
+
import { PACKAGE_VERSION } from "../../version.mjs";
|
|
6
|
+
// src/plugins/test-utils/index.ts
|
|
7
7
|
/**
|
|
8
8
|
* Test utilities plugin for Better Auth.
|
|
9
9
|
*
|
|
@@ -93,5 +93,4 @@ const testUtils = (options = {}) => {
|
|
|
93
93
|
options
|
|
94
94
|
};
|
|
95
95
|
};
|
|
96
|
-
//#endregion
|
|
97
96
|
export { testUtils };
|