@hammadj/better-auth 1.5.0-beta.9
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/LICENSE.md +20 -0
- package/README.md +33 -0
- package/dist/_virtual/rolldown_runtime.mjs +36 -0
- package/dist/adapters/drizzle-adapter/index.d.mts +1 -0
- package/dist/adapters/drizzle-adapter/index.mjs +3 -0
- package/dist/adapters/index.d.mts +23 -0
- package/dist/adapters/index.mjs +13 -0
- package/dist/adapters/index.mjs.map +1 -0
- package/dist/adapters/kysely-adapter/index.d.mts +1 -0
- package/dist/adapters/kysely-adapter/index.mjs +3 -0
- package/dist/adapters/memory-adapter/index.d.mts +1 -0
- package/dist/adapters/memory-adapter/index.mjs +3 -0
- package/dist/adapters/mongodb-adapter/index.d.mts +1 -0
- package/dist/adapters/mongodb-adapter/index.mjs +3 -0
- package/dist/adapters/prisma-adapter/index.d.mts +1 -0
- package/dist/adapters/prisma-adapter/index.mjs +3 -0
- package/dist/api/index.d.mts +40 -0
- package/dist/api/index.mjs +205 -0
- package/dist/api/index.mjs.map +1 -0
- package/dist/api/middlewares/index.d.mts +1 -0
- package/dist/api/middlewares/index.mjs +3 -0
- package/dist/api/middlewares/origin-check.d.mts +17 -0
- package/dist/api/middlewares/origin-check.mjs +140 -0
- package/dist/api/middlewares/origin-check.mjs.map +1 -0
- package/dist/api/rate-limiter/index.mjs +177 -0
- package/dist/api/rate-limiter/index.mjs.map +1 -0
- package/dist/api/routes/account.d.mts +10 -0
- package/dist/api/routes/account.mjs +493 -0
- package/dist/api/routes/account.mjs.map +1 -0
- package/dist/api/routes/callback.d.mts +5 -0
- package/dist/api/routes/callback.mjs +178 -0
- package/dist/api/routes/callback.mjs.map +1 -0
- package/dist/api/routes/email-verification.d.mts +29 -0
- package/dist/api/routes/email-verification.mjs +301 -0
- package/dist/api/routes/email-verification.mjs.map +1 -0
- package/dist/api/routes/error.d.mts +5 -0
- package/dist/api/routes/error.mjs +386 -0
- package/dist/api/routes/error.mjs.map +1 -0
- package/dist/api/routes/index.d.mts +11 -0
- package/dist/api/routes/index.mjs +13 -0
- package/dist/api/routes/ok.d.mts +5 -0
- package/dist/api/routes/ok.mjs +30 -0
- package/dist/api/routes/ok.mjs.map +1 -0
- package/dist/api/routes/password.d.mts +8 -0
- package/dist/api/routes/password.mjs +198 -0
- package/dist/api/routes/password.mjs.map +1 -0
- package/dist/api/routes/session.d.mts +52 -0
- package/dist/api/routes/session.mjs +478 -0
- package/dist/api/routes/session.mjs.map +1 -0
- package/dist/api/routes/sign-in.d.mts +8 -0
- package/dist/api/routes/sign-in.mjs +262 -0
- package/dist/api/routes/sign-in.mjs.map +1 -0
- package/dist/api/routes/sign-out.d.mts +5 -0
- package/dist/api/routes/sign-out.mjs +33 -0
- package/dist/api/routes/sign-out.mjs.map +1 -0
- package/dist/api/routes/sign-up.d.mts +7 -0
- package/dist/api/routes/sign-up.mjs +227 -0
- package/dist/api/routes/sign-up.mjs.map +1 -0
- package/dist/api/routes/update-user.d.mts +12 -0
- package/dist/api/routes/update-user.mjs +493 -0
- package/dist/api/routes/update-user.mjs.map +1 -0
- package/dist/api/state/oauth.d.mts +5 -0
- package/dist/api/state/oauth.mjs +8 -0
- package/dist/api/state/oauth.mjs.map +1 -0
- package/dist/api/state/should-session-refresh.d.mts +13 -0
- package/dist/api/state/should-session-refresh.mjs +16 -0
- package/dist/api/state/should-session-refresh.mjs.map +1 -0
- package/dist/api/to-auth-endpoints.mjs +197 -0
- package/dist/api/to-auth-endpoints.mjs.map +1 -0
- package/dist/auth/base.mjs +44 -0
- package/dist/auth/base.mjs.map +1 -0
- package/dist/auth/full.d.mts +30 -0
- package/dist/auth/full.mjs +32 -0
- package/dist/auth/full.mjs.map +1 -0
- package/dist/auth/minimal.d.mts +12 -0
- package/dist/auth/minimal.mjs +14 -0
- package/dist/auth/minimal.mjs.map +1 -0
- package/dist/auth/trusted-origins.mjs +31 -0
- package/dist/auth/trusted-origins.mjs.map +1 -0
- package/dist/client/broadcast-channel.d.mts +20 -0
- package/dist/client/broadcast-channel.mjs +46 -0
- package/dist/client/broadcast-channel.mjs.map +1 -0
- package/dist/client/config.mjs +90 -0
- package/dist/client/config.mjs.map +1 -0
- package/dist/client/fetch-plugins.mjs +18 -0
- package/dist/client/fetch-plugins.mjs.map +1 -0
- package/dist/client/focus-manager.d.mts +11 -0
- package/dist/client/focus-manager.mjs +32 -0
- package/dist/client/focus-manager.mjs.map +1 -0
- package/dist/client/index.d.mts +30 -0
- package/dist/client/index.mjs +21 -0
- package/dist/client/index.mjs.map +1 -0
- package/dist/client/lynx/index.d.mts +62 -0
- package/dist/client/lynx/index.mjs +24 -0
- package/dist/client/lynx/index.mjs.map +1 -0
- package/dist/client/lynx/lynx-store.d.mts +47 -0
- package/dist/client/lynx/lynx-store.mjs +47 -0
- package/dist/client/lynx/lynx-store.mjs.map +1 -0
- package/dist/client/online-manager.d.mts +12 -0
- package/dist/client/online-manager.mjs +35 -0
- package/dist/client/online-manager.mjs.map +1 -0
- package/dist/client/parser.mjs +73 -0
- package/dist/client/parser.mjs.map +1 -0
- package/dist/client/path-to-object.d.mts +57 -0
- package/dist/client/plugins/index.d.mts +58 -0
- package/dist/client/plugins/index.mjs +33 -0
- package/dist/client/plugins/infer-plugin.d.mts +9 -0
- package/dist/client/plugins/infer-plugin.mjs +11 -0
- package/dist/client/plugins/infer-plugin.mjs.map +1 -0
- package/dist/client/proxy.mjs +79 -0
- package/dist/client/proxy.mjs.map +1 -0
- package/dist/client/query.d.mts +23 -0
- package/dist/client/query.mjs +98 -0
- package/dist/client/query.mjs.map +1 -0
- package/dist/client/react/index.d.mts +63 -0
- package/dist/client/react/index.mjs +24 -0
- package/dist/client/react/index.mjs.map +1 -0
- package/dist/client/react/react-store.d.mts +47 -0
- package/dist/client/react/react-store.mjs +47 -0
- package/dist/client/react/react-store.mjs.map +1 -0
- package/dist/client/session-atom.mjs +29 -0
- package/dist/client/session-atom.mjs.map +1 -0
- package/dist/client/session-refresh.d.mts +28 -0
- package/dist/client/session-refresh.mjs +140 -0
- package/dist/client/session-refresh.mjs.map +1 -0
- package/dist/client/solid/index.d.mts +57 -0
- package/dist/client/solid/index.mjs +22 -0
- package/dist/client/solid/index.mjs.map +1 -0
- package/dist/client/solid/solid-store.mjs +24 -0
- package/dist/client/solid/solid-store.mjs.map +1 -0
- package/dist/client/svelte/index.d.mts +63 -0
- package/dist/client/svelte/index.mjs +20 -0
- package/dist/client/svelte/index.mjs.map +1 -0
- package/dist/client/types.d.mts +58 -0
- package/dist/client/vanilla.d.mts +62 -0
- package/dist/client/vanilla.mjs +20 -0
- package/dist/client/vanilla.mjs.map +1 -0
- package/dist/client/vue/index.d.mts +86 -0
- package/dist/client/vue/index.mjs +38 -0
- package/dist/client/vue/index.mjs.map +1 -0
- package/dist/client/vue/vue-store.mjs +26 -0
- package/dist/client/vue/vue-store.mjs.map +1 -0
- package/dist/context/create-context.mjs +211 -0
- package/dist/context/create-context.mjs.map +1 -0
- package/dist/context/helpers.mjs +62 -0
- package/dist/context/helpers.mjs.map +1 -0
- package/dist/context/init-minimal.mjs +20 -0
- package/dist/context/init-minimal.mjs.map +1 -0
- package/dist/context/init.mjs +22 -0
- package/dist/context/init.mjs.map +1 -0
- package/dist/cookies/cookie-utils.d.mts +29 -0
- package/dist/cookies/cookie-utils.mjs +105 -0
- package/dist/cookies/cookie-utils.mjs.map +1 -0
- package/dist/cookies/index.d.mts +67 -0
- package/dist/cookies/index.mjs +264 -0
- package/dist/cookies/index.mjs.map +1 -0
- package/dist/cookies/session-store.d.mts +36 -0
- package/dist/cookies/session-store.mjs +200 -0
- package/dist/cookies/session-store.mjs.map +1 -0
- package/dist/crypto/buffer.d.mts +8 -0
- package/dist/crypto/buffer.mjs +18 -0
- package/dist/crypto/buffer.mjs.map +1 -0
- package/dist/crypto/index.d.mts +27 -0
- package/dist/crypto/index.mjs +38 -0
- package/dist/crypto/index.mjs.map +1 -0
- package/dist/crypto/jwt.d.mts +8 -0
- package/dist/crypto/jwt.mjs +95 -0
- package/dist/crypto/jwt.mjs.map +1 -0
- package/dist/crypto/password.d.mts +12 -0
- package/dist/crypto/password.mjs +36 -0
- package/dist/crypto/password.mjs.map +1 -0
- package/dist/crypto/random.d.mts +5 -0
- package/dist/crypto/random.mjs +8 -0
- package/dist/crypto/random.mjs.map +1 -0
- package/dist/db/adapter-base.d.mts +8 -0
- package/dist/db/adapter-base.mjs +28 -0
- package/dist/db/adapter-base.mjs.map +1 -0
- package/dist/db/adapter-kysely.d.mts +8 -0
- package/dist/db/adapter-kysely.mjs +21 -0
- package/dist/db/adapter-kysely.mjs.map +1 -0
- package/dist/db/field-converter.d.mts +8 -0
- package/dist/db/field-converter.mjs +21 -0
- package/dist/db/field-converter.mjs.map +1 -0
- package/dist/db/field.d.mts +55 -0
- package/dist/db/field.mjs +11 -0
- package/dist/db/field.mjs.map +1 -0
- package/dist/db/get-migration.d.mts +23 -0
- package/dist/db/get-migration.mjs +339 -0
- package/dist/db/get-migration.mjs.map +1 -0
- package/dist/db/get-schema.d.mts +11 -0
- package/dist/db/get-schema.mjs +39 -0
- package/dist/db/get-schema.mjs.map +1 -0
- package/dist/db/index.d.mts +9 -0
- package/dist/db/index.mjs +36 -0
- package/dist/db/index.mjs.map +1 -0
- package/dist/db/internal-adapter.d.mts +14 -0
- package/dist/db/internal-adapter.mjs +616 -0
- package/dist/db/internal-adapter.mjs.map +1 -0
- package/dist/db/schema.d.mts +26 -0
- package/dist/db/schema.mjs +118 -0
- package/dist/db/schema.mjs.map +1 -0
- package/dist/db/to-zod.d.mts +36 -0
- package/dist/db/to-zod.mjs +26 -0
- package/dist/db/to-zod.mjs.map +1 -0
- package/dist/db/verification-token-storage.mjs +28 -0
- package/dist/db/verification-token-storage.mjs.map +1 -0
- package/dist/db/with-hooks.d.mts +33 -0
- package/dist/db/with-hooks.mjs +159 -0
- package/dist/db/with-hooks.mjs.map +1 -0
- package/dist/index.d.mts +52 -0
- package/dist/index.mjs +26 -0
- package/dist/integrations/next-js.d.mts +14 -0
- package/dist/integrations/next-js.mjs +78 -0
- package/dist/integrations/next-js.mjs.map +1 -0
- package/dist/integrations/node.d.mts +13 -0
- package/dist/integrations/node.mjs +16 -0
- package/dist/integrations/node.mjs.map +1 -0
- package/dist/integrations/solid-start.d.mts +23 -0
- package/dist/integrations/solid-start.mjs +17 -0
- package/dist/integrations/solid-start.mjs.map +1 -0
- package/dist/integrations/svelte-kit.d.mts +29 -0
- package/dist/integrations/svelte-kit.mjs +57 -0
- package/dist/integrations/svelte-kit.mjs.map +1 -0
- package/dist/integrations/tanstack-start-solid.d.mts +22 -0
- package/dist/integrations/tanstack-start-solid.mjs +61 -0
- package/dist/integrations/tanstack-start-solid.mjs.map +1 -0
- package/dist/integrations/tanstack-start.d.mts +22 -0
- package/dist/integrations/tanstack-start.mjs +61 -0
- package/dist/integrations/tanstack-start.mjs.map +1 -0
- package/dist/oauth2/index.d.mts +5 -0
- package/dist/oauth2/index.mjs +7 -0
- package/dist/oauth2/link-account.d.mts +31 -0
- package/dist/oauth2/link-account.mjs +144 -0
- package/dist/oauth2/link-account.mjs.map +1 -0
- package/dist/oauth2/state.d.mts +26 -0
- package/dist/oauth2/state.mjs +51 -0
- package/dist/oauth2/state.mjs.map +1 -0
- package/dist/oauth2/utils.d.mts +8 -0
- package/dist/oauth2/utils.mjs +31 -0
- package/dist/oauth2/utils.mjs.map +1 -0
- package/dist/plugins/access/access.d.mts +30 -0
- package/dist/plugins/access/access.mjs +46 -0
- package/dist/plugins/access/access.mjs.map +1 -0
- package/dist/plugins/access/index.d.mts +3 -0
- package/dist/plugins/access/index.mjs +3 -0
- package/dist/plugins/access/types.d.mts +17 -0
- package/dist/plugins/additional-fields/client.d.mts +14 -0
- package/dist/plugins/additional-fields/client.mjs +11 -0
- package/dist/plugins/additional-fields/client.mjs.map +1 -0
- package/dist/plugins/admin/access/index.d.mts +2 -0
- package/dist/plugins/admin/access/index.mjs +3 -0
- package/dist/plugins/admin/access/statement.d.mts +118 -0
- package/dist/plugins/admin/access/statement.mjs +53 -0
- package/dist/plugins/admin/access/statement.mjs.map +1 -0
- package/dist/plugins/admin/admin.d.mts +14 -0
- package/dist/plugins/admin/admin.mjs +95 -0
- package/dist/plugins/admin/admin.mjs.map +1 -0
- package/dist/plugins/admin/client.d.mts +14 -0
- package/dist/plugins/admin/client.mjs +36 -0
- package/dist/plugins/admin/client.mjs.map +1 -0
- package/dist/plugins/admin/error-codes.d.mts +5 -0
- package/dist/plugins/admin/error-codes.mjs +30 -0
- package/dist/plugins/admin/error-codes.mjs.map +1 -0
- package/dist/plugins/admin/has-permission.mjs +16 -0
- package/dist/plugins/admin/has-permission.mjs.map +1 -0
- package/dist/plugins/admin/index.d.mts +3 -0
- package/dist/plugins/admin/index.mjs +3 -0
- package/dist/plugins/admin/routes.mjs +855 -0
- package/dist/plugins/admin/routes.mjs.map +1 -0
- package/dist/plugins/admin/schema.d.mts +6 -0
- package/dist/plugins/admin/schema.mjs +34 -0
- package/dist/plugins/admin/schema.mjs.map +1 -0
- package/dist/plugins/admin/types.d.mts +89 -0
- package/dist/plugins/anonymous/client.d.mts +9 -0
- package/dist/plugins/anonymous/client.mjs +22 -0
- package/dist/plugins/anonymous/client.mjs.map +1 -0
- package/dist/plugins/anonymous/error-codes.d.mts +5 -0
- package/dist/plugins/anonymous/error-codes.mjs +16 -0
- package/dist/plugins/anonymous/error-codes.mjs.map +1 -0
- package/dist/plugins/anonymous/index.d.mts +14 -0
- package/dist/plugins/anonymous/index.mjs +163 -0
- package/dist/plugins/anonymous/index.mjs.map +1 -0
- package/dist/plugins/anonymous/schema.d.mts +5 -0
- package/dist/plugins/anonymous/schema.mjs +11 -0
- package/dist/plugins/anonymous/schema.mjs.map +1 -0
- package/dist/plugins/anonymous/types.d.mts +68 -0
- package/dist/plugins/api-key/adapter.mjs +468 -0
- package/dist/plugins/api-key/adapter.mjs.map +1 -0
- package/dist/plugins/api-key/client.d.mts +9 -0
- package/dist/plugins/api-key/client.mjs +19 -0
- package/dist/plugins/api-key/client.mjs.map +1 -0
- package/dist/plugins/api-key/error-codes.d.mts +5 -0
- package/dist/plugins/api-key/error-codes.mjs +34 -0
- package/dist/plugins/api-key/error-codes.mjs.map +1 -0
- package/dist/plugins/api-key/index.d.mts +17 -0
- package/dist/plugins/api-key/index.mjs +134 -0
- package/dist/plugins/api-key/index.mjs.map +1 -0
- package/dist/plugins/api-key/rate-limit.mjs +74 -0
- package/dist/plugins/api-key/rate-limit.mjs.map +1 -0
- package/dist/plugins/api-key/routes/create-api-key.mjs +252 -0
- package/dist/plugins/api-key/routes/create-api-key.mjs.map +1 -0
- package/dist/plugins/api-key/routes/delete-all-expired-api-keys.mjs +24 -0
- package/dist/plugins/api-key/routes/delete-all-expired-api-keys.mjs.map +1 -0
- package/dist/plugins/api-key/routes/delete-api-key.mjs +74 -0
- package/dist/plugins/api-key/routes/delete-api-key.mjs.map +1 -0
- package/dist/plugins/api-key/routes/get-api-key.mjs +158 -0
- package/dist/plugins/api-key/routes/get-api-key.mjs.map +1 -0
- package/dist/plugins/api-key/routes/index.mjs +71 -0
- package/dist/plugins/api-key/routes/index.mjs.map +1 -0
- package/dist/plugins/api-key/routes/list-api-keys.mjs +194 -0
- package/dist/plugins/api-key/routes/list-api-keys.mjs.map +1 -0
- package/dist/plugins/api-key/routes/update-api-key.mjs +248 -0
- package/dist/plugins/api-key/routes/update-api-key.mjs.map +1 -0
- package/dist/plugins/api-key/routes/verify-api-key.mjs +223 -0
- package/dist/plugins/api-key/routes/verify-api-key.mjs.map +1 -0
- package/dist/plugins/api-key/schema.d.mts +11 -0
- package/dist/plugins/api-key/schema.mjs +130 -0
- package/dist/plugins/api-key/schema.mjs.map +1 -0
- package/dist/plugins/api-key/types.d.mts +346 -0
- package/dist/plugins/bearer/index.d.mts +25 -0
- package/dist/plugins/bearer/index.mjs +66 -0
- package/dist/plugins/bearer/index.mjs.map +1 -0
- package/dist/plugins/captcha/constants.d.mts +10 -0
- package/dist/plugins/captcha/constants.mjs +22 -0
- package/dist/plugins/captcha/constants.mjs.map +1 -0
- package/dist/plugins/captcha/error-codes.mjs +16 -0
- package/dist/plugins/captcha/error-codes.mjs.map +1 -0
- package/dist/plugins/captcha/index.d.mts +14 -0
- package/dist/plugins/captcha/index.mjs +60 -0
- package/dist/plugins/captcha/index.mjs.map +1 -0
- package/dist/plugins/captcha/types.d.mts +28 -0
- package/dist/plugins/captcha/utils.mjs +11 -0
- package/dist/plugins/captcha/utils.mjs.map +1 -0
- package/dist/plugins/captcha/verify-handlers/captchafox.mjs +27 -0
- package/dist/plugins/captcha/verify-handlers/captchafox.mjs.map +1 -0
- package/dist/plugins/captcha/verify-handlers/cloudflare-turnstile.mjs +25 -0
- package/dist/plugins/captcha/verify-handlers/cloudflare-turnstile.mjs.map +1 -0
- package/dist/plugins/captcha/verify-handlers/google-recaptcha.mjs +29 -0
- package/dist/plugins/captcha/verify-handlers/google-recaptcha.mjs.map +1 -0
- package/dist/plugins/captcha/verify-handlers/h-captcha.mjs +27 -0
- package/dist/plugins/captcha/verify-handlers/h-captcha.mjs.map +1 -0
- package/dist/plugins/captcha/verify-handlers/index.mjs +6 -0
- package/dist/plugins/custom-session/client.d.mts +10 -0
- package/dist/plugins/custom-session/client.mjs +11 -0
- package/dist/plugins/custom-session/client.mjs.map +1 -0
- package/dist/plugins/custom-session/index.d.mts +26 -0
- package/dist/plugins/custom-session/index.mjs +70 -0
- package/dist/plugins/custom-session/index.mjs.map +1 -0
- package/dist/plugins/device-authorization/client.d.mts +5 -0
- package/dist/plugins/device-authorization/client.mjs +18 -0
- package/dist/plugins/device-authorization/client.mjs.map +1 -0
- package/dist/plugins/device-authorization/error-codes.mjs +21 -0
- package/dist/plugins/device-authorization/error-codes.mjs.map +1 -0
- package/dist/plugins/device-authorization/index.d.mts +28 -0
- package/dist/plugins/device-authorization/index.mjs +50 -0
- package/dist/plugins/device-authorization/index.mjs.map +1 -0
- package/dist/plugins/device-authorization/routes.mjs +510 -0
- package/dist/plugins/device-authorization/routes.mjs.map +1 -0
- package/dist/plugins/device-authorization/schema.mjs +57 -0
- package/dist/plugins/device-authorization/schema.mjs.map +1 -0
- package/dist/plugins/email-otp/client.d.mts +7 -0
- package/dist/plugins/email-otp/client.mjs +18 -0
- package/dist/plugins/email-otp/client.mjs.map +1 -0
- package/dist/plugins/email-otp/error-codes.d.mts +5 -0
- package/dist/plugins/email-otp/error-codes.mjs +12 -0
- package/dist/plugins/email-otp/error-codes.mjs.map +1 -0
- package/dist/plugins/email-otp/index.d.mts +14 -0
- package/dist/plugins/email-otp/index.mjs +108 -0
- package/dist/plugins/email-otp/index.mjs.map +1 -0
- package/dist/plugins/email-otp/otp-token.mjs +29 -0
- package/dist/plugins/email-otp/otp-token.mjs.map +1 -0
- package/dist/plugins/email-otp/routes.mjs +564 -0
- package/dist/plugins/email-otp/routes.mjs.map +1 -0
- package/dist/plugins/email-otp/types.d.mts +74 -0
- package/dist/plugins/email-otp/utils.mjs +17 -0
- package/dist/plugins/email-otp/utils.mjs.map +1 -0
- package/dist/plugins/generic-oauth/client.d.mts +19 -0
- package/dist/plugins/generic-oauth/client.mjs +14 -0
- package/dist/plugins/generic-oauth/client.mjs.map +1 -0
- package/dist/plugins/generic-oauth/error-codes.d.mts +5 -0
- package/dist/plugins/generic-oauth/error-codes.mjs +15 -0
- package/dist/plugins/generic-oauth/error-codes.mjs.map +1 -0
- package/dist/plugins/generic-oauth/index.d.mts +34 -0
- package/dist/plugins/generic-oauth/index.mjs +137 -0
- package/dist/plugins/generic-oauth/index.mjs.map +1 -0
- package/dist/plugins/generic-oauth/providers/auth0.d.mts +37 -0
- package/dist/plugins/generic-oauth/providers/auth0.mjs +62 -0
- package/dist/plugins/generic-oauth/providers/auth0.mjs.map +1 -0
- package/dist/plugins/generic-oauth/providers/gumroad.d.mts +32 -0
- package/dist/plugins/generic-oauth/providers/gumroad.mjs +60 -0
- package/dist/plugins/generic-oauth/providers/gumroad.mjs.map +1 -0
- package/dist/plugins/generic-oauth/providers/hubspot.d.mts +37 -0
- package/dist/plugins/generic-oauth/providers/hubspot.mjs +60 -0
- package/dist/plugins/generic-oauth/providers/hubspot.mjs.map +1 -0
- package/dist/plugins/generic-oauth/providers/index.d.mts +9 -0
- package/dist/plugins/generic-oauth/providers/index.mjs +11 -0
- package/dist/plugins/generic-oauth/providers/keycloak.d.mts +37 -0
- package/dist/plugins/generic-oauth/providers/keycloak.mjs +62 -0
- package/dist/plugins/generic-oauth/providers/keycloak.mjs.map +1 -0
- package/dist/plugins/generic-oauth/providers/line.d.mts +55 -0
- package/dist/plugins/generic-oauth/providers/line.mjs +91 -0
- package/dist/plugins/generic-oauth/providers/line.mjs.map +1 -0
- package/dist/plugins/generic-oauth/providers/microsoft-entra-id.d.mts +37 -0
- package/dist/plugins/generic-oauth/providers/microsoft-entra-id.mjs +66 -0
- package/dist/plugins/generic-oauth/providers/microsoft-entra-id.mjs.map +1 -0
- package/dist/plugins/generic-oauth/providers/okta.d.mts +37 -0
- package/dist/plugins/generic-oauth/providers/okta.mjs +62 -0
- package/dist/plugins/generic-oauth/providers/okta.mjs.map +1 -0
- package/dist/plugins/generic-oauth/providers/patreon.d.mts +30 -0
- package/dist/plugins/generic-oauth/providers/patreon.mjs +59 -0
- package/dist/plugins/generic-oauth/providers/patreon.mjs.map +1 -0
- package/dist/plugins/generic-oauth/providers/slack.d.mts +30 -0
- package/dist/plugins/generic-oauth/providers/slack.mjs +61 -0
- package/dist/plugins/generic-oauth/providers/slack.mjs.map +1 -0
- package/dist/plugins/generic-oauth/routes.mjs +394 -0
- package/dist/plugins/generic-oauth/routes.mjs.map +1 -0
- package/dist/plugins/generic-oauth/types.d.mts +145 -0
- package/dist/plugins/haveibeenpwned/index.d.mts +21 -0
- package/dist/plugins/haveibeenpwned/index.mjs +56 -0
- package/dist/plugins/haveibeenpwned/index.mjs.map +1 -0
- package/dist/plugins/index.d.mts +68 -0
- package/dist/plugins/index.mjs +51 -0
- package/dist/plugins/jwt/adapter.mjs +27 -0
- package/dist/plugins/jwt/adapter.mjs.map +1 -0
- package/dist/plugins/jwt/client.d.mts +18 -0
- package/dist/plugins/jwt/client.mjs +19 -0
- package/dist/plugins/jwt/client.mjs.map +1 -0
- package/dist/plugins/jwt/index.d.mts +17 -0
- package/dist/plugins/jwt/index.mjs +202 -0
- package/dist/plugins/jwt/index.mjs.map +1 -0
- package/dist/plugins/jwt/schema.d.mts +5 -0
- package/dist/plugins/jwt/schema.mjs +23 -0
- package/dist/plugins/jwt/schema.mjs.map +1 -0
- package/dist/plugins/jwt/sign.d.mts +57 -0
- package/dist/plugins/jwt/sign.mjs +66 -0
- package/dist/plugins/jwt/sign.mjs.map +1 -0
- package/dist/plugins/jwt/types.d.mts +194 -0
- package/dist/plugins/jwt/utils.d.mts +42 -0
- package/dist/plugins/jwt/utils.mjs +64 -0
- package/dist/plugins/jwt/utils.mjs.map +1 -0
- package/dist/plugins/jwt/verify.d.mts +12 -0
- package/dist/plugins/jwt/verify.mjs +46 -0
- package/dist/plugins/jwt/verify.mjs.map +1 -0
- package/dist/plugins/last-login-method/client.d.mts +18 -0
- package/dist/plugins/last-login-method/client.mjs +32 -0
- package/dist/plugins/last-login-method/client.mjs.map +1 -0
- package/dist/plugins/last-login-method/index.d.mts +52 -0
- package/dist/plugins/last-login-method/index.mjs +77 -0
- package/dist/plugins/last-login-method/index.mjs.map +1 -0
- package/dist/plugins/magic-link/client.d.mts +5 -0
- package/dist/plugins/magic-link/client.mjs +11 -0
- package/dist/plugins/magic-link/client.mjs.map +1 -0
- package/dist/plugins/magic-link/index.d.mts +61 -0
- package/dist/plugins/magic-link/index.mjs +167 -0
- package/dist/plugins/magic-link/index.mjs.map +1 -0
- package/dist/plugins/magic-link/utils.mjs +12 -0
- package/dist/plugins/magic-link/utils.mjs.map +1 -0
- package/dist/plugins/mcp/authorize.mjs +133 -0
- package/dist/plugins/mcp/authorize.mjs.map +1 -0
- package/dist/plugins/mcp/index.d.mts +46 -0
- package/dist/plugins/mcp/index.mjs +717 -0
- package/dist/plugins/mcp/index.mjs.map +1 -0
- package/dist/plugins/multi-session/client.d.mts +8 -0
- package/dist/plugins/multi-session/client.mjs +20 -0
- package/dist/plugins/multi-session/client.mjs.map +1 -0
- package/dist/plugins/multi-session/error-codes.d.mts +5 -0
- package/dist/plugins/multi-session/error-codes.mjs +8 -0
- package/dist/plugins/multi-session/error-codes.mjs.map +1 -0
- package/dist/plugins/multi-session/index.d.mts +22 -0
- package/dist/plugins/multi-session/index.mjs +172 -0
- package/dist/plugins/multi-session/index.mjs.map +1 -0
- package/dist/plugins/oauth-proxy/index.d.mts +39 -0
- package/dist/plugins/oauth-proxy/index.mjs +305 -0
- package/dist/plugins/oauth-proxy/index.mjs.map +1 -0
- package/dist/plugins/oauth-proxy/utils.mjs +44 -0
- package/dist/plugins/oauth-proxy/utils.mjs.map +1 -0
- package/dist/plugins/oidc-provider/authorize.mjs +194 -0
- package/dist/plugins/oidc-provider/authorize.mjs.map +1 -0
- package/dist/plugins/oidc-provider/client.d.mts +8 -0
- package/dist/plugins/oidc-provider/client.mjs +11 -0
- package/dist/plugins/oidc-provider/client.mjs.map +1 -0
- package/dist/plugins/oidc-provider/error.mjs +17 -0
- package/dist/plugins/oidc-provider/error.mjs.map +1 -0
- package/dist/plugins/oidc-provider/index.d.mts +32 -0
- package/dist/plugins/oidc-provider/index.mjs +1093 -0
- package/dist/plugins/oidc-provider/index.mjs.map +1 -0
- package/dist/plugins/oidc-provider/schema.d.mts +26 -0
- package/dist/plugins/oidc-provider/schema.mjs +132 -0
- package/dist/plugins/oidc-provider/schema.mjs.map +1 -0
- package/dist/plugins/oidc-provider/types.d.mts +517 -0
- package/dist/plugins/oidc-provider/utils/prompt.mjs +19 -0
- package/dist/plugins/oidc-provider/utils/prompt.mjs.map +1 -0
- package/dist/plugins/oidc-provider/utils.mjs +15 -0
- package/dist/plugins/oidc-provider/utils.mjs.map +1 -0
- package/dist/plugins/one-tap/client.d.mts +159 -0
- package/dist/plugins/one-tap/client.mjs +214 -0
- package/dist/plugins/one-tap/client.mjs.map +1 -0
- package/dist/plugins/one-tap/index.d.mts +27 -0
- package/dist/plugins/one-tap/index.mjs +96 -0
- package/dist/plugins/one-tap/index.mjs.map +1 -0
- package/dist/plugins/one-time-token/client.d.mts +7 -0
- package/dist/plugins/one-time-token/client.mjs +11 -0
- package/dist/plugins/one-time-token/client.mjs.map +1 -0
- package/dist/plugins/one-time-token/index.d.mts +53 -0
- package/dist/plugins/one-time-token/index.mjs +82 -0
- package/dist/plugins/one-time-token/index.mjs.map +1 -0
- package/dist/plugins/one-time-token/utils.mjs +12 -0
- package/dist/plugins/one-time-token/utils.mjs.map +1 -0
- package/dist/plugins/open-api/generator.d.mts +115 -0
- package/dist/plugins/open-api/generator.mjs +315 -0
- package/dist/plugins/open-api/generator.mjs.map +1 -0
- package/dist/plugins/open-api/index.d.mts +45 -0
- package/dist/plugins/open-api/index.mjs +67 -0
- package/dist/plugins/open-api/index.mjs.map +1 -0
- package/dist/plugins/open-api/logo.mjs +15 -0
- package/dist/plugins/open-api/logo.mjs.map +1 -0
- package/dist/plugins/organization/access/index.d.mts +2 -0
- package/dist/plugins/organization/access/index.mjs +3 -0
- package/dist/plugins/organization/access/statement.d.mts +249 -0
- package/dist/plugins/organization/access/statement.mjs +81 -0
- package/dist/plugins/organization/access/statement.mjs.map +1 -0
- package/dist/plugins/organization/adapter.d.mts +205 -0
- package/dist/plugins/organization/adapter.mjs +624 -0
- package/dist/plugins/organization/adapter.mjs.map +1 -0
- package/dist/plugins/organization/call.mjs +19 -0
- package/dist/plugins/organization/call.mjs.map +1 -0
- package/dist/plugins/organization/client.d.mts +151 -0
- package/dist/plugins/organization/client.mjs +107 -0
- package/dist/plugins/organization/client.mjs.map +1 -0
- package/dist/plugins/organization/error-codes.d.mts +5 -0
- package/dist/plugins/organization/error-codes.mjs +65 -0
- package/dist/plugins/organization/error-codes.mjs.map +1 -0
- package/dist/plugins/organization/has-permission.mjs +35 -0
- package/dist/plugins/organization/has-permission.mjs.map +1 -0
- package/dist/plugins/organization/index.d.mts +5 -0
- package/dist/plugins/organization/index.mjs +4 -0
- package/dist/plugins/organization/organization.d.mts +252 -0
- package/dist/plugins/organization/organization.mjs +428 -0
- package/dist/plugins/organization/organization.mjs.map +1 -0
- package/dist/plugins/organization/permission.d.mts +26 -0
- package/dist/plugins/organization/permission.mjs +16 -0
- package/dist/plugins/organization/permission.mjs.map +1 -0
- package/dist/plugins/organization/routes/crud-access-control.d.mts +11 -0
- package/dist/plugins/organization/routes/crud-access-control.mjs +656 -0
- package/dist/plugins/organization/routes/crud-access-control.mjs.map +1 -0
- package/dist/plugins/organization/routes/crud-invites.d.mts +16 -0
- package/dist/plugins/organization/routes/crud-invites.mjs +555 -0
- package/dist/plugins/organization/routes/crud-invites.mjs.map +1 -0
- package/dist/plugins/organization/routes/crud-members.d.mts +13 -0
- package/dist/plugins/organization/routes/crud-members.mjs +473 -0
- package/dist/plugins/organization/routes/crud-members.mjs.map +1 -0
- package/dist/plugins/organization/routes/crud-org.d.mts +13 -0
- package/dist/plugins/organization/routes/crud-org.mjs +447 -0
- package/dist/plugins/organization/routes/crud-org.mjs.map +1 -0
- package/dist/plugins/organization/routes/crud-team.d.mts +15 -0
- package/dist/plugins/organization/routes/crud-team.mjs +676 -0
- package/dist/plugins/organization/routes/crud-team.mjs.map +1 -0
- package/dist/plugins/organization/schema.d.mts +376 -0
- package/dist/plugins/organization/schema.mjs +68 -0
- package/dist/plugins/organization/schema.mjs.map +1 -0
- package/dist/plugins/organization/types.d.mts +733 -0
- package/dist/plugins/phone-number/client.d.mts +8 -0
- package/dist/plugins/phone-number/client.mjs +20 -0
- package/dist/plugins/phone-number/client.mjs.map +1 -0
- package/dist/plugins/phone-number/error-codes.d.mts +5 -0
- package/dist/plugins/phone-number/error-codes.mjs +21 -0
- package/dist/plugins/phone-number/error-codes.mjs.map +1 -0
- package/dist/plugins/phone-number/index.d.mts +14 -0
- package/dist/plugins/phone-number/index.mjs +49 -0
- package/dist/plugins/phone-number/index.mjs.map +1 -0
- package/dist/plugins/phone-number/routes.mjs +459 -0
- package/dist/plugins/phone-number/routes.mjs.map +1 -0
- package/dist/plugins/phone-number/schema.d.mts +5 -0
- package/dist/plugins/phone-number/schema.mjs +20 -0
- package/dist/plugins/phone-number/schema.mjs.map +1 -0
- package/dist/plugins/phone-number/types.d.mts +118 -0
- package/dist/plugins/siwe/client.d.mts +5 -0
- package/dist/plugins/siwe/client.mjs +11 -0
- package/dist/plugins/siwe/client.mjs.map +1 -0
- package/dist/plugins/siwe/error-codes.mjs +13 -0
- package/dist/plugins/siwe/error-codes.mjs.map +1 -0
- package/dist/plugins/siwe/index.d.mts +26 -0
- package/dist/plugins/siwe/index.mjs +261 -0
- package/dist/plugins/siwe/index.mjs.map +1 -0
- package/dist/plugins/siwe/schema.d.mts +5 -0
- package/dist/plugins/siwe/schema.mjs +32 -0
- package/dist/plugins/siwe/schema.mjs.map +1 -0
- package/dist/plugins/siwe/types.d.mts +44 -0
- package/dist/plugins/two-factor/backup-codes/index.d.mts +91 -0
- package/dist/plugins/two-factor/backup-codes/index.mjs +277 -0
- package/dist/plugins/two-factor/backup-codes/index.mjs.map +1 -0
- package/dist/plugins/two-factor/client.d.mts +17 -0
- package/dist/plugins/two-factor/client.mjs +37 -0
- package/dist/plugins/two-factor/client.mjs.map +1 -0
- package/dist/plugins/two-factor/constant.mjs +8 -0
- package/dist/plugins/two-factor/constant.mjs.map +1 -0
- package/dist/plugins/two-factor/error-code.d.mts +5 -0
- package/dist/plugins/two-factor/error-code.mjs +18 -0
- package/dist/plugins/two-factor/error-code.mjs.map +1 -0
- package/dist/plugins/two-factor/index.d.mts +19 -0
- package/dist/plugins/two-factor/index.mjs +207 -0
- package/dist/plugins/two-factor/index.mjs.map +1 -0
- package/dist/plugins/two-factor/otp/index.d.mts +96 -0
- package/dist/plugins/two-factor/otp/index.mjs +199 -0
- package/dist/plugins/two-factor/otp/index.mjs.map +1 -0
- package/dist/plugins/two-factor/schema.d.mts +5 -0
- package/dist/plugins/two-factor/schema.mjs +36 -0
- package/dist/plugins/two-factor/schema.mjs.map +1 -0
- package/dist/plugins/two-factor/totp/index.d.mts +81 -0
- package/dist/plugins/two-factor/totp/index.mjs +157 -0
- package/dist/plugins/two-factor/totp/index.mjs.map +1 -0
- package/dist/plugins/two-factor/types.d.mts +65 -0
- package/dist/plugins/two-factor/utils.mjs +12 -0
- package/dist/plugins/two-factor/utils.mjs.map +1 -0
- package/dist/plugins/two-factor/verify-two-factor.mjs +76 -0
- package/dist/plugins/two-factor/verify-two-factor.mjs.map +1 -0
- package/dist/plugins/username/client.d.mts +7 -0
- package/dist/plugins/username/client.mjs +18 -0
- package/dist/plugins/username/client.mjs.map +1 -0
- package/dist/plugins/username/error-codes.d.mts +5 -0
- package/dist/plugins/username/error-codes.mjs +17 -0
- package/dist/plugins/username/error-codes.mjs.map +1 -0
- package/dist/plugins/username/index.d.mts +74 -0
- package/dist/plugins/username/index.mjs +237 -0
- package/dist/plugins/username/index.mjs.map +1 -0
- package/dist/plugins/username/schema.d.mts +9 -0
- package/dist/plugins/username/schema.mjs +26 -0
- package/dist/plugins/username/schema.mjs.map +1 -0
- package/dist/social-providers/index.d.mts +1 -0
- package/dist/social-providers/index.mjs +3 -0
- package/dist/state.d.mts +42 -0
- package/dist/state.mjs +107 -0
- package/dist/state.mjs.map +1 -0
- package/dist/test-utils/headers.d.mts +9 -0
- package/dist/test-utils/headers.mjs +24 -0
- package/dist/test-utils/headers.mjs.map +1 -0
- package/dist/test-utils/index.d.mts +3 -0
- package/dist/test-utils/index.mjs +4 -0
- package/dist/test-utils/test-instance.d.mts +181 -0
- package/dist/test-utils/test-instance.mjs +210 -0
- package/dist/test-utils/test-instance.mjs.map +1 -0
- package/dist/types/adapter.d.mts +24 -0
- package/dist/types/api.d.mts +29 -0
- package/dist/types/auth.d.mts +30 -0
- package/dist/types/helper.d.mts +21 -0
- package/dist/types/index.d.mts +11 -0
- package/dist/types/index.mjs +1 -0
- package/dist/types/models.d.mts +17 -0
- package/dist/types/plugins.d.mts +16 -0
- package/dist/utils/boolean.mjs +8 -0
- package/dist/utils/boolean.mjs.map +1 -0
- package/dist/utils/constants.mjs +6 -0
- package/dist/utils/constants.mjs.map +1 -0
- package/dist/utils/date.mjs +8 -0
- package/dist/utils/date.mjs.map +1 -0
- package/dist/utils/get-request-ip.d.mts +7 -0
- package/dist/utils/get-request-ip.mjs +23 -0
- package/dist/utils/get-request-ip.mjs.map +1 -0
- package/dist/utils/hashing.mjs +21 -0
- package/dist/utils/hashing.mjs.map +1 -0
- package/dist/utils/hide-metadata.d.mts +7 -0
- package/dist/utils/hide-metadata.mjs +6 -0
- package/dist/utils/hide-metadata.mjs.map +1 -0
- package/dist/utils/index.d.mts +3 -0
- package/dist/utils/index.mjs +5 -0
- package/dist/utils/is-api-error.d.mts +7 -0
- package/dist/utils/is-api-error.mjs +11 -0
- package/dist/utils/is-api-error.mjs.map +1 -0
- package/dist/utils/is-atom.mjs +8 -0
- package/dist/utils/is-atom.mjs.map +1 -0
- package/dist/utils/is-promise.mjs +8 -0
- package/dist/utils/is-promise.mjs.map +1 -0
- package/dist/utils/middleware-response.mjs +6 -0
- package/dist/utils/middleware-response.mjs.map +1 -0
- package/dist/utils/password.mjs +26 -0
- package/dist/utils/password.mjs.map +1 -0
- package/dist/utils/plugin-helper.mjs +17 -0
- package/dist/utils/plugin-helper.mjs.map +1 -0
- package/dist/utils/shim.mjs +24 -0
- package/dist/utils/shim.mjs.map +1 -0
- package/dist/utils/time.d.mts +49 -0
- package/dist/utils/time.mjs +100 -0
- package/dist/utils/time.mjs.map +1 -0
- package/dist/utils/url.mjs +92 -0
- package/dist/utils/url.mjs.map +1 -0
- package/dist/utils/wildcard.mjs +108 -0
- package/dist/utils/wildcard.mjs.map +1 -0
- package/package.json +601 -0
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
import { GenericEndpointContext } from "@better-auth/core";
|
|
2
|
+
import { User } from "@better-auth/core/db";
|
|
3
|
+
import { OAuth2Tokens, OAuth2UserInfo } from "@better-auth/core/oauth2";
|
|
4
|
+
|
|
5
|
+
//#region src/plugins/generic-oauth/types.d.ts
|
|
6
|
+
interface GenericOAuthOptions {
|
|
7
|
+
/**
|
|
8
|
+
* Array of OAuth provider configurations.
|
|
9
|
+
*/
|
|
10
|
+
config: GenericOAuthConfig[];
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Configuration interface for generic OAuth providers.
|
|
14
|
+
*/
|
|
15
|
+
interface GenericOAuthConfig {
|
|
16
|
+
/** Unique identifier for the OAuth provider */
|
|
17
|
+
providerId: string;
|
|
18
|
+
/**
|
|
19
|
+
* URL to fetch OAuth 2.0 configuration.
|
|
20
|
+
* If provided, the authorization and token endpoints will be fetched from this URL.
|
|
21
|
+
*/
|
|
22
|
+
discoveryUrl?: string | undefined;
|
|
23
|
+
/**
|
|
24
|
+
* URL for the authorization endpoint.
|
|
25
|
+
* Optional if using discoveryUrl.
|
|
26
|
+
*/
|
|
27
|
+
authorizationUrl?: string | undefined;
|
|
28
|
+
/**
|
|
29
|
+
* URL for the token endpoint.
|
|
30
|
+
* Optional if using discoveryUrl.
|
|
31
|
+
*/
|
|
32
|
+
tokenUrl?: string | undefined;
|
|
33
|
+
/**
|
|
34
|
+
* URL for the user info endpoint.
|
|
35
|
+
* Optional if using discoveryUrl.
|
|
36
|
+
*/
|
|
37
|
+
userInfoUrl?: string | undefined;
|
|
38
|
+
/** OAuth client ID */
|
|
39
|
+
clientId: string;
|
|
40
|
+
/** OAuth client secret */
|
|
41
|
+
clientSecret?: string | undefined;
|
|
42
|
+
/**
|
|
43
|
+
* Array of OAuth scopes to request.
|
|
44
|
+
* @default []
|
|
45
|
+
*/
|
|
46
|
+
scopes?: string[] | undefined;
|
|
47
|
+
/**
|
|
48
|
+
* Custom redirect URI.
|
|
49
|
+
* If not provided, a default URI will be constructed.
|
|
50
|
+
*/
|
|
51
|
+
redirectURI?: string | undefined;
|
|
52
|
+
/**
|
|
53
|
+
* OAuth response type.
|
|
54
|
+
* @default "code"
|
|
55
|
+
*/
|
|
56
|
+
responseType?: string | undefined;
|
|
57
|
+
/**
|
|
58
|
+
* The response mode to use for the authorization code request.
|
|
59
|
+
*/
|
|
60
|
+
responseMode?: ("query" | "form_post") | undefined;
|
|
61
|
+
/**
|
|
62
|
+
* Prompt parameter for the authorization request.
|
|
63
|
+
* Controls the authentication experience for the user.
|
|
64
|
+
*/
|
|
65
|
+
prompt?: ("none" | "login" | "create" | "consent" | "select_account" | "select_account consent" | "login consent") | undefined;
|
|
66
|
+
/**
|
|
67
|
+
* Whether to use PKCE (Proof Key for Code Exchange)
|
|
68
|
+
* @default false
|
|
69
|
+
*/
|
|
70
|
+
pkce?: boolean | undefined;
|
|
71
|
+
/**
|
|
72
|
+
* Access type for the authorization request.
|
|
73
|
+
* Use "offline" to request a refresh token.
|
|
74
|
+
*/
|
|
75
|
+
accessType?: string | undefined;
|
|
76
|
+
/**
|
|
77
|
+
* Custom function to exchange authorization code for tokens.
|
|
78
|
+
* If provided, this function will be used instead of the default token exchange logic.
|
|
79
|
+
* This is useful for providers with non-standard token endpoints.
|
|
80
|
+
* @param data - Authorization code exchange parameters
|
|
81
|
+
* @returns A promise that resolves to OAuth2Tokens
|
|
82
|
+
*/
|
|
83
|
+
getToken?: ((data: {
|
|
84
|
+
code: string;
|
|
85
|
+
redirectURI: string;
|
|
86
|
+
codeVerifier?: string | undefined;
|
|
87
|
+
deviceId?: string | undefined;
|
|
88
|
+
}) => Promise<OAuth2Tokens>) | undefined;
|
|
89
|
+
/**
|
|
90
|
+
* Custom function to fetch user info.
|
|
91
|
+
* If provided, this function will be used instead of the default user info fetching logic.
|
|
92
|
+
* @param tokens - The OAuth tokens received after successful authentication
|
|
93
|
+
* @returns A promise that resolves to a User object or null
|
|
94
|
+
*/
|
|
95
|
+
getUserInfo?: ((tokens: OAuth2Tokens) => Promise<OAuth2UserInfo | null>) | undefined;
|
|
96
|
+
/**
|
|
97
|
+
* Custom function to map the user profile to a User object.
|
|
98
|
+
*/
|
|
99
|
+
mapProfileToUser?: ((profile: Record<string, any>) => Partial<Partial<User>> | Promise<Partial<User>>) | undefined;
|
|
100
|
+
/**
|
|
101
|
+
* Additional search-params to add to the authorizationUrl.
|
|
102
|
+
* Warning: Search-params added here overwrite any default params.
|
|
103
|
+
*/
|
|
104
|
+
authorizationUrlParams?: (Record<string, string> | ((ctx: GenericEndpointContext) => Record<string, string>)) | undefined;
|
|
105
|
+
/**
|
|
106
|
+
* Additional search-params to add to the tokenUrl.
|
|
107
|
+
* Warning: Search-params added here overwrite any default params.
|
|
108
|
+
*/
|
|
109
|
+
tokenUrlParams?: (Record<string, string> | ((ctx: GenericEndpointContext) => Record<string, string>)) | undefined;
|
|
110
|
+
/**
|
|
111
|
+
* Disable implicit sign up for new users. When set to true for the provider,
|
|
112
|
+
* sign-in need to be called with with requestSignUp as true to create new users.
|
|
113
|
+
*/
|
|
114
|
+
disableImplicitSignUp?: boolean | undefined;
|
|
115
|
+
/**
|
|
116
|
+
* Disable sign up for new users.
|
|
117
|
+
*/
|
|
118
|
+
disableSignUp?: boolean | undefined;
|
|
119
|
+
/**
|
|
120
|
+
* Authentication method for token requests.
|
|
121
|
+
* @default "post"
|
|
122
|
+
*/
|
|
123
|
+
authentication?: ("basic" | "post") | undefined;
|
|
124
|
+
/**
|
|
125
|
+
* Custom headers to include in the discovery request.
|
|
126
|
+
* Useful for providers like Epic that require specific headers (e.g., Epic-Client-ID).
|
|
127
|
+
*/
|
|
128
|
+
discoveryHeaders?: Record<string, string> | undefined;
|
|
129
|
+
/**
|
|
130
|
+
* Custom headers to include in the authorization request.
|
|
131
|
+
* Useful for providers like Qonto that require specific headers (e.g., X-Qonto-Staging-Token for local development).
|
|
132
|
+
*/
|
|
133
|
+
authorizationHeaders?: Record<string, string> | undefined;
|
|
134
|
+
/**
|
|
135
|
+
* Override user info with the provider info.
|
|
136
|
+
*
|
|
137
|
+
* This will update the user info with the provider info,
|
|
138
|
+
* when the user signs in with the provider.
|
|
139
|
+
* @default false
|
|
140
|
+
*/
|
|
141
|
+
overrideUserInfo?: boolean | undefined;
|
|
142
|
+
}
|
|
143
|
+
//#endregion
|
|
144
|
+
export { GenericOAuthConfig, GenericOAuthOptions };
|
|
145
|
+
//# sourceMappingURL=types.d.mts.map
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
//#region src/plugins/haveibeenpwned/index.d.ts
|
|
2
|
+
declare module "@better-auth/core" {
|
|
3
|
+
interface BetterAuthPluginRegistry<AuthOptions, Options> {
|
|
4
|
+
"have-i-been-pwned": {
|
|
5
|
+
creator: typeof haveIBeenPwned;
|
|
6
|
+
};
|
|
7
|
+
}
|
|
8
|
+
}
|
|
9
|
+
interface HaveIBeenPwnedOptions {
|
|
10
|
+
customPasswordCompromisedMessage?: string | undefined;
|
|
11
|
+
/**
|
|
12
|
+
* Paths to check for password
|
|
13
|
+
*
|
|
14
|
+
* @default ["/sign-up/email", "/change-password", "/reset-password"]
|
|
15
|
+
*/
|
|
16
|
+
paths?: string[];
|
|
17
|
+
}
|
|
18
|
+
declare const haveIBeenPwned: (options?: HaveIBeenPwnedOptions | undefined) => BetterAuthPlugin;
|
|
19
|
+
//#endregion
|
|
20
|
+
export { HaveIBeenPwnedOptions, haveIBeenPwned };
|
|
21
|
+
//# sourceMappingURL=index.d.mts.map
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { isAPIError } from "../../utils/is-api-error.mjs";
|
|
2
|
+
import { APIError } from "../../api/index.mjs";
|
|
3
|
+
import { getCurrentAuthContext } from "@better-auth/core/context";
|
|
4
|
+
import { defineErrorCodes } from "@better-auth/core/utils/error-codes";
|
|
5
|
+
import { createHash } from "@better-auth/utils/hash";
|
|
6
|
+
import { betterFetch } from "@better-fetch/fetch";
|
|
7
|
+
|
|
8
|
+
//#region src/plugins/haveibeenpwned/index.ts
|
|
9
|
+
const ERROR_CODES = defineErrorCodes({ PASSWORD_COMPROMISED: "The password you entered has been compromised. Please choose a different password." });
|
|
10
|
+
async function checkPasswordCompromise(password, customMessage) {
|
|
11
|
+
if (!password) return;
|
|
12
|
+
const sha1Hash = (await createHash("SHA-1", "hex").digest(password)).toUpperCase();
|
|
13
|
+
const prefix = sha1Hash.substring(0, 5);
|
|
14
|
+
const suffix = sha1Hash.substring(5);
|
|
15
|
+
try {
|
|
16
|
+
const { data, error } = await betterFetch(`https://api.pwnedpasswords.com/range/${prefix}`, { headers: {
|
|
17
|
+
"Add-Padding": "true",
|
|
18
|
+
"User-Agent": "BetterAuth Password Checker"
|
|
19
|
+
} });
|
|
20
|
+
if (error) throw new APIError("INTERNAL_SERVER_ERROR", { message: `Failed to check password. Status: ${error.status}` });
|
|
21
|
+
if (data.split("\n").some((line) => line.split(":")[0].toUpperCase() === suffix.toUpperCase())) throw APIError.from("BAD_REQUEST", {
|
|
22
|
+
message: customMessage || ERROR_CODES.PASSWORD_COMPROMISED.message,
|
|
23
|
+
code: ERROR_CODES.PASSWORD_COMPROMISED.code
|
|
24
|
+
});
|
|
25
|
+
} catch (error) {
|
|
26
|
+
if (isAPIError(error)) throw error;
|
|
27
|
+
throw new APIError("INTERNAL_SERVER_ERROR", { message: "Failed to check password. Please try again later." });
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
const haveIBeenPwned = (options) => {
|
|
31
|
+
const paths = options?.paths || [
|
|
32
|
+
"/sign-up/email",
|
|
33
|
+
"/change-password",
|
|
34
|
+
"/reset-password"
|
|
35
|
+
];
|
|
36
|
+
return {
|
|
37
|
+
id: "have-i-been-pwned",
|
|
38
|
+
init(ctx) {
|
|
39
|
+
return { context: { password: {
|
|
40
|
+
...ctx.password,
|
|
41
|
+
async hash(password) {
|
|
42
|
+
const c = await getCurrentAuthContext();
|
|
43
|
+
if (!c.path || !paths.includes(c.path)) return ctx.password.hash(password);
|
|
44
|
+
await checkPasswordCompromise(password, options?.customPasswordCompromisedMessage);
|
|
45
|
+
return ctx.password.hash(password);
|
|
46
|
+
}
|
|
47
|
+
} } };
|
|
48
|
+
},
|
|
49
|
+
options,
|
|
50
|
+
$ERROR_CODES: ERROR_CODES
|
|
51
|
+
};
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
//#endregion
|
|
55
|
+
export { haveIBeenPwned };
|
|
56
|
+
//# sourceMappingURL=index.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.mjs","names":[],"sources":["../../../src/plugins/haveibeenpwned/index.ts"],"sourcesContent":["import type { BetterAuthPlugin } from \"@better-auth/core\";\nimport { getCurrentAuthContext } from \"@better-auth/core/context\";\nimport { defineErrorCodes } from \"@better-auth/core/utils/error-codes\";\nimport { createHash } from \"@better-auth/utils/hash\";\nimport { betterFetch } from \"@better-fetch/fetch\";\nimport { APIError } from \"../../api\";\nimport { isAPIError } from \"../../utils/is-api-error\";\n\ndeclare module \"@better-auth/core\" {\n\tinterface BetterAuthPluginRegistry<AuthOptions, Options> {\n\t\t\"have-i-been-pwned\": {\n\t\t\tcreator: typeof haveIBeenPwned;\n\t\t};\n\t}\n}\n\nconst ERROR_CODES = defineErrorCodes({\n\tPASSWORD_COMPROMISED:\n\t\t\"The password you entered has been compromised. Please choose a different password.\",\n});\n\nasync function checkPasswordCompromise(\n\tpassword: string,\n\tcustomMessage?: string | undefined,\n) {\n\tif (!password) return;\n\n\tconst sha1Hash = (\n\t\tawait createHash(\"SHA-1\", \"hex\").digest(password)\n\t).toUpperCase();\n\tconst prefix = sha1Hash.substring(0, 5);\n\tconst suffix = sha1Hash.substring(5);\n\ttry {\n\t\tconst { data, error } = await betterFetch<string>(\n\t\t\t`https://api.pwnedpasswords.com/range/${prefix}`,\n\t\t\t{\n\t\t\t\theaders: {\n\t\t\t\t\t\"Add-Padding\": \"true\",\n\t\t\t\t\t\"User-Agent\": \"BetterAuth Password Checker\",\n\t\t\t\t},\n\t\t\t},\n\t\t);\n\n\t\tif (error) {\n\t\t\tthrow new APIError(\"INTERNAL_SERVER_ERROR\", {\n\t\t\t\tmessage: `Failed to check password. Status: ${error.status}`,\n\t\t\t});\n\t\t}\n\t\tconst lines = data.split(\"\\n\");\n\t\tconst found = lines.some(\n\t\t\t(line) => line.split(\":\")[0]!.toUpperCase() === suffix.toUpperCase(),\n\t\t);\n\n\t\tif (found) {\n\t\t\tthrow APIError.from(\"BAD_REQUEST\", {\n\t\t\t\tmessage: customMessage || ERROR_CODES.PASSWORD_COMPROMISED.message,\n\t\t\t\tcode: ERROR_CODES.PASSWORD_COMPROMISED.code,\n\t\t\t});\n\t\t}\n\t} catch (error) {\n\t\tif (isAPIError(error)) throw error;\n\t\tthrow new APIError(\"INTERNAL_SERVER_ERROR\", {\n\t\t\tmessage: \"Failed to check password. Please try again later.\",\n\t\t});\n\t}\n}\n\nexport interface HaveIBeenPwnedOptions {\n\tcustomPasswordCompromisedMessage?: string | undefined;\n\t/**\n\t * Paths to check for password\n\t *\n\t * @default [\"/sign-up/email\", \"/change-password\", \"/reset-password\"]\n\t */\n\tpaths?: string[];\n}\n\nexport const haveIBeenPwned = (options?: HaveIBeenPwnedOptions | undefined) => {\n\tconst paths = options?.paths || [\n\t\t\"/sign-up/email\",\n\t\t\"/change-password\",\n\t\t\"/reset-password\",\n\t];\n\n\treturn {\n\t\tid: \"have-i-been-pwned\",\n\t\tinit(ctx) {\n\t\t\treturn {\n\t\t\t\tcontext: {\n\t\t\t\t\tpassword: {\n\t\t\t\t\t\t...ctx.password,\n\t\t\t\t\t\tasync hash(password) {\n\t\t\t\t\t\t\tconst c = await getCurrentAuthContext();\n\t\t\t\t\t\t\tif (!c.path || !paths.includes(c.path)) {\n\t\t\t\t\t\t\t\treturn ctx.password.hash(password);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tawait checkPasswordCompromise(\n\t\t\t\t\t\t\t\tpassword,\n\t\t\t\t\t\t\t\toptions?.customPasswordCompromisedMessage,\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\treturn ctx.password.hash(password);\n\t\t\t\t\t\t},\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t};\n\t\t},\n\t\toptions,\n\t\t$ERROR_CODES: ERROR_CODES,\n\t} satisfies BetterAuthPlugin;\n};\n"],"mappings":";;;;;;;;AAgBA,MAAM,cAAc,iBAAiB,EACpC,sBACC,sFACD,CAAC;AAEF,eAAe,wBACd,UACA,eACC;AACD,KAAI,CAAC,SAAU;CAEf,MAAM,YACL,MAAM,WAAW,SAAS,MAAM,CAAC,OAAO,SAAS,EAChD,aAAa;CACf,MAAM,SAAS,SAAS,UAAU,GAAG,EAAE;CACvC,MAAM,SAAS,SAAS,UAAU,EAAE;AACpC,KAAI;EACH,MAAM,EAAE,MAAM,UAAU,MAAM,YAC7B,wCAAwC,UACxC,EACC,SAAS;GACR,eAAe;GACf,cAAc;GACd,EACD,CACD;AAED,MAAI,MACH,OAAM,IAAI,SAAS,yBAAyB,EAC3C,SAAS,qCAAqC,MAAM,UACpD,CAAC;AAOH,MALc,KAAK,MAAM,KAAK,CACV,MAClB,SAAS,KAAK,MAAM,IAAI,CAAC,GAAI,aAAa,KAAK,OAAO,aAAa,CACpE,CAGA,OAAM,SAAS,KAAK,eAAe;GAClC,SAAS,iBAAiB,YAAY,qBAAqB;GAC3D,MAAM,YAAY,qBAAqB;GACvC,CAAC;UAEK,OAAO;AACf,MAAI,WAAW,MAAM,CAAE,OAAM;AAC7B,QAAM,IAAI,SAAS,yBAAyB,EAC3C,SAAS,qDACT,CAAC;;;AAcJ,MAAa,kBAAkB,YAAgD;CAC9E,MAAM,QAAQ,SAAS,SAAS;EAC/B;EACA;EACA;EACA;AAED,QAAO;EACN,IAAI;EACJ,KAAK,KAAK;AACT,UAAO,EACN,SAAS,EACR,UAAU;IACT,GAAG,IAAI;IACP,MAAM,KAAK,UAAU;KACpB,MAAM,IAAI,MAAM,uBAAuB;AACvC,SAAI,CAAC,EAAE,QAAQ,CAAC,MAAM,SAAS,EAAE,KAAK,CACrC,QAAO,IAAI,SAAS,KAAK,SAAS;AAEnC,WAAM,wBACL,UACA,SAAS,iCACT;AACD,YAAO,IAAI,SAAS,KAAK,SAAS;;IAEnC,EACD,EACD;;EAEF;EACA,cAAc;EACd"}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import { InferOptionSchema, InferPluginErrorCodes, InferPluginIDs } from "../types/plugins.mjs";
|
|
2
|
+
import { AccessControl, Role, Statements, SubArray, Subset } from "./access/types.mjs";
|
|
3
|
+
import { AuthorizeResponse, createAccessControl, role } from "./access/access.mjs";
|
|
4
|
+
import "./access/index.mjs";
|
|
5
|
+
import { OrganizationOptions } from "./organization/types.mjs";
|
|
6
|
+
import { InferInvitation, InferMember, InferOrganization, InferOrganizationRolesFromOption, InferOrganizationZodRolesFromOption, InferTeam, Invitation, InvitationInput, InvitationStatus, Member, MemberInput, Organization, OrganizationInput, OrganizationRole, OrganizationSchema, Team, TeamInput, TeamMember, TeamMemberInput, defaultRolesSchema, invitationSchema, invitationStatus, memberSchema, organizationRoleSchema, organizationSchema, roleSchema, teamMemberSchema, teamSchema } from "./organization/schema.mjs";
|
|
7
|
+
import { getOrgAdapter } from "./organization/adapter.mjs";
|
|
8
|
+
import { DefaultOrganizationPlugin, DynamicAccessControlEndpoints, OrganizationCreator, OrganizationEndpoints, OrganizationPlugin, TeamEndpoints, organization, parseRoles } from "./organization/organization.mjs";
|
|
9
|
+
import "./organization/index.mjs";
|
|
10
|
+
import { AdminOptions, InferAdminRolesFromOption, SessionWithImpersonatedBy, UserWithRole } from "./admin/types.mjs";
|
|
11
|
+
import { API_KEY_ERROR_CODES } from "./api-key/error-codes.mjs";
|
|
12
|
+
import { ApiKey, ApiKeyOptions } from "./api-key/types.mjs";
|
|
13
|
+
import { GenericOAuthConfig, GenericOAuthOptions } from "./generic-oauth/types.mjs";
|
|
14
|
+
import { Auth0Options, auth0 } from "./generic-oauth/providers/auth0.mjs";
|
|
15
|
+
import { GumroadOptions, gumroad } from "./generic-oauth/providers/gumroad.mjs";
|
|
16
|
+
import { HubSpotOptions, hubspot } from "./generic-oauth/providers/hubspot.mjs";
|
|
17
|
+
import { KeycloakOptions, keycloak } from "./generic-oauth/providers/keycloak.mjs";
|
|
18
|
+
import { LineOptions, line } from "./generic-oauth/providers/line.mjs";
|
|
19
|
+
import { MicrosoftEntraIdOptions, microsoftEntraId } from "./generic-oauth/providers/microsoft-entra-id.mjs";
|
|
20
|
+
import { OktaOptions, okta } from "./generic-oauth/providers/okta.mjs";
|
|
21
|
+
import { PatreonOptions, patreon } from "./generic-oauth/providers/patreon.mjs";
|
|
22
|
+
import { SlackOptions, slack } from "./generic-oauth/providers/slack.mjs";
|
|
23
|
+
import { BaseOAuthProviderOptions, genericOAuth } from "./generic-oauth/index.mjs";
|
|
24
|
+
import { HIDE_METADATA } from "../utils/hide-metadata.mjs";
|
|
25
|
+
import { JWKOptions, JWSAlgorithms, Jwk, JwtOptions } from "./jwt/types.mjs";
|
|
26
|
+
import { MULTI_SESSION_ERROR_CODES } from "./multi-session/error-codes.mjs";
|
|
27
|
+
import { MultiSessionConfig, multiSession } from "./multi-session/index.mjs";
|
|
28
|
+
import { AuthorizationQuery, Client, CodeVerificationValue, OAuthAccessToken, OIDCMetadata, OIDCOptions, TokenBody } from "./oidc-provider/types.mjs";
|
|
29
|
+
import { OneTimeTokenOptions, oneTimeToken } from "./one-time-token/index.mjs";
|
|
30
|
+
import { PhoneNumberOptions, UserWithPhoneNumber } from "./phone-number/types.mjs";
|
|
31
|
+
import { TWO_FACTOR_ERROR_CODES } from "./two-factor/error-code.mjs";
|
|
32
|
+
import { BackupCodeOptions, backupCode2fa, generateBackupCodes, getBackupCodes, verifyBackupCode } from "./two-factor/backup-codes/index.mjs";
|
|
33
|
+
import { TOTPOptions, totp2fa } from "./two-factor/totp/index.mjs";
|
|
34
|
+
import { TwoFactorOptions, TwoFactorProvider, TwoFactorTable, UserWithTwoFactor } from "./two-factor/types.mjs";
|
|
35
|
+
import { OTPOptions, otp2fa } from "./two-factor/otp/index.mjs";
|
|
36
|
+
import { twoFactorClient } from "./two-factor/client.mjs";
|
|
37
|
+
import { USERNAME_ERROR_CODES } from "./username/error-codes.mjs";
|
|
38
|
+
import { admin } from "./admin/admin.mjs";
|
|
39
|
+
import "./admin/index.mjs";
|
|
40
|
+
import { anonymous } from "./anonymous/index.mjs";
|
|
41
|
+
import { API_KEY_TABLE_NAME, apiKey, defaultKeyHasher } from "./api-key/index.mjs";
|
|
42
|
+
import { BearerOptions, bearer } from "./bearer/index.mjs";
|
|
43
|
+
import { BaseCaptchaOptions, CaptchaFoxOptions, CaptchaOptions, CloudflareTurnstileOptions, GoogleRecaptchaOptions, HCaptchaOptions, Provider } from "./captcha/types.mjs";
|
|
44
|
+
import { captcha } from "./captcha/index.mjs";
|
|
45
|
+
import { CustomSessionPluginOptions, customSession } from "./custom-session/index.mjs";
|
|
46
|
+
import { TimeString, ms, sec } from "../utils/time.mjs";
|
|
47
|
+
import { DeviceAuthorizationOptions, deviceAuthorization, deviceAuthorizationOptionsSchema } from "./device-authorization/index.mjs";
|
|
48
|
+
import { EmailOTPOptions } from "./email-otp/types.mjs";
|
|
49
|
+
import { emailOTP } from "./email-otp/index.mjs";
|
|
50
|
+
import { HaveIBeenPwnedOptions, haveIBeenPwned } from "./haveibeenpwned/index.mjs";
|
|
51
|
+
import { getJwtToken, signJWT } from "./jwt/sign.mjs";
|
|
52
|
+
import { createJwk, generateExportedKeyPair, toExpJWT } from "./jwt/utils.mjs";
|
|
53
|
+
import { verifyJWT } from "./jwt/verify.mjs";
|
|
54
|
+
import { jwt } from "./jwt/index.mjs";
|
|
55
|
+
import { LastLoginMethodOptions, lastLoginMethod } from "./last-login-method/index.mjs";
|
|
56
|
+
import { MagicLinkOptions, magicLink } from "./magic-link/index.mjs";
|
|
57
|
+
import { getClient, getMetadata, oidcProvider } from "./oidc-provider/index.mjs";
|
|
58
|
+
import { getMCPProtectedResourceMetadata, getMCPProviderMetadata, mcp, oAuthDiscoveryMetadata, oAuthProtectedResourceMetadata, withMcpAuth } from "./mcp/index.mjs";
|
|
59
|
+
import { OAuthProxyOptions, oAuthProxy } from "./oauth-proxy/index.mjs";
|
|
60
|
+
import { OneTapOptions, oneTap } from "./one-tap/index.mjs";
|
|
61
|
+
import { FieldSchema, OpenAPIModelSchema, Path, generator } from "./open-api/generator.mjs";
|
|
62
|
+
import { OpenAPIOptions, openAPI } from "./open-api/index.mjs";
|
|
63
|
+
import { phoneNumber } from "./phone-number/index.mjs";
|
|
64
|
+
import { SIWEPluginOptions, siwe } from "./siwe/index.mjs";
|
|
65
|
+
import { twoFactor } from "./two-factor/index.mjs";
|
|
66
|
+
import { UsernameOptions, username } from "./username/index.mjs";
|
|
67
|
+
import { AuthEndpoint, AuthMiddleware, createAuthEndpoint, createAuthMiddleware, optionsMiddleware } from "@better-auth/core/api";
|
|
68
|
+
export { API_KEY_ERROR_CODES, API_KEY_TABLE_NAME, AccessControl, AdminOptions, ApiKey, ApiKeyOptions, Auth0Options, type AuthEndpoint, type AuthMiddleware, AuthorizationQuery, AuthorizeResponse, BackupCodeOptions, BaseCaptchaOptions, BaseOAuthProviderOptions, BearerOptions, CaptchaFoxOptions, CaptchaOptions, Client, CloudflareTurnstileOptions, CodeVerificationValue, CustomSessionPluginOptions, DefaultOrganizationPlugin, DeviceAuthorizationOptions, DynamicAccessControlEndpoints, MULTI_SESSION_ERROR_CODES as ERROR_CODES, EmailOTPOptions, FieldSchema, GenericOAuthConfig, GenericOAuthOptions, GoogleRecaptchaOptions, GumroadOptions, HCaptchaOptions, HIDE_METADATA, HaveIBeenPwnedOptions, HubSpotOptions, InferAdminRolesFromOption, InferInvitation, InferMember, InferOptionSchema, InferOrganization, InferOrganizationRolesFromOption, InferOrganizationZodRolesFromOption, InferPluginErrorCodes, InferPluginIDs, InferTeam, Invitation, InvitationInput, InvitationStatus, JWKOptions, JWSAlgorithms, Jwk, JwtOptions, KeycloakOptions, LastLoginMethodOptions, LineOptions, MagicLinkOptions, Member, MemberInput, MicrosoftEntraIdOptions, MultiSessionConfig, OAuthAccessToken, OAuthProxyOptions, OIDCMetadata, OIDCOptions, OTPOptions, OktaOptions, OneTapOptions, OneTimeTokenOptions, OpenAPIModelSchema, OpenAPIOptions, Organization, OrganizationCreator, OrganizationEndpoints, OrganizationInput, OrganizationOptions, OrganizationPlugin, OrganizationRole, OrganizationSchema, Path, PatreonOptions, PhoneNumberOptions, Provider, Role, SIWEPluginOptions, SessionWithImpersonatedBy, SlackOptions, Statements, SubArray, Subset, TOTPOptions, TWO_FACTOR_ERROR_CODES, Team, TeamEndpoints, TeamInput, TeamMember, TeamMemberInput, TimeString, TokenBody, TwoFactorOptions, TwoFactorProvider, TwoFactorTable, USERNAME_ERROR_CODES, UserWithPhoneNumber, UserWithRole, UserWithTwoFactor, UsernameOptions, admin, anonymous, apiKey, auth0, backupCode2fa, bearer, captcha, createAccessControl, createAuthEndpoint, createAuthMiddleware, createJwk, customSession, defaultKeyHasher, defaultRolesSchema, deviceAuthorization, deviceAuthorizationOptionsSchema, emailOTP, generateBackupCodes, generateExportedKeyPair, generator, genericOAuth, getBackupCodes, getClient, getJwtToken, getMCPProtectedResourceMetadata, getMCPProviderMetadata, getMetadata, getOrgAdapter, gumroad, haveIBeenPwned, hubspot, invitationSchema, invitationStatus, jwt, keycloak, lastLoginMethod, line, magicLink, mcp, memberSchema, microsoftEntraId, ms, multiSession, oAuthDiscoveryMetadata, oAuthProtectedResourceMetadata, oAuthProxy, oidcProvider, okta, oneTap, oneTimeToken, openAPI, optionsMiddleware, organization, organizationRoleSchema, organizationSchema, otp2fa, parseRoles, patreon, phoneNumber, role, roleSchema, sec, signJWT, siwe, slack, teamMemberSchema, teamSchema, toExpJWT, totp2fa, twoFactor, twoFactorClient, username, verifyBackupCode, verifyJWT, withMcpAuth };
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { HIDE_METADATA } from "../utils/hide-metadata.mjs";
|
|
2
|
+
import { createAccessControl, role } from "./access/access.mjs";
|
|
3
|
+
import "./access/index.mjs";
|
|
4
|
+
import { API_KEY_ERROR_CODES } from "./api-key/error-codes.mjs";
|
|
5
|
+
import { MULTI_SESSION_ERROR_CODES } from "./multi-session/error-codes.mjs";
|
|
6
|
+
import { TWO_FACTOR_ERROR_CODES } from "./two-factor/error-code.mjs";
|
|
7
|
+
import { twoFactorClient } from "./two-factor/client.mjs";
|
|
8
|
+
import { USERNAME_ERROR_CODES } from "./username/error-codes.mjs";
|
|
9
|
+
import { admin } from "./admin/admin.mjs";
|
|
10
|
+
import "./admin/index.mjs";
|
|
11
|
+
import { anonymous } from "./anonymous/index.mjs";
|
|
12
|
+
import { API_KEY_TABLE_NAME, apiKey, defaultKeyHasher } from "./api-key/index.mjs";
|
|
13
|
+
import { bearer } from "./bearer/index.mjs";
|
|
14
|
+
import { captcha } from "./captcha/index.mjs";
|
|
15
|
+
import { customSession } from "./custom-session/index.mjs";
|
|
16
|
+
import { deviceAuthorization, deviceAuthorizationOptionsSchema } from "./device-authorization/index.mjs";
|
|
17
|
+
import { emailOTP } from "./email-otp/index.mjs";
|
|
18
|
+
import { auth0 } from "./generic-oauth/providers/auth0.mjs";
|
|
19
|
+
import { gumroad } from "./generic-oauth/providers/gumroad.mjs";
|
|
20
|
+
import { hubspot } from "./generic-oauth/providers/hubspot.mjs";
|
|
21
|
+
import { keycloak } from "./generic-oauth/providers/keycloak.mjs";
|
|
22
|
+
import { line } from "./generic-oauth/providers/line.mjs";
|
|
23
|
+
import { microsoftEntraId } from "./generic-oauth/providers/microsoft-entra-id.mjs";
|
|
24
|
+
import { okta } from "./generic-oauth/providers/okta.mjs";
|
|
25
|
+
import { patreon } from "./generic-oauth/providers/patreon.mjs";
|
|
26
|
+
import { slack } from "./generic-oauth/providers/slack.mjs";
|
|
27
|
+
import { genericOAuth } from "./generic-oauth/index.mjs";
|
|
28
|
+
import { haveIBeenPwned } from "./haveibeenpwned/index.mjs";
|
|
29
|
+
import { createJwk, generateExportedKeyPair, toExpJWT } from "./jwt/utils.mjs";
|
|
30
|
+
import { getJwtToken, signJWT } from "./jwt/sign.mjs";
|
|
31
|
+
import { verifyJWT } from "./jwt/verify.mjs";
|
|
32
|
+
import { jwt } from "./jwt/index.mjs";
|
|
33
|
+
import { lastLoginMethod } from "./last-login-method/index.mjs";
|
|
34
|
+
import { magicLink } from "./magic-link/index.mjs";
|
|
35
|
+
import { getClient, getMetadata, oidcProvider } from "./oidc-provider/index.mjs";
|
|
36
|
+
import { getMCPProtectedResourceMetadata, getMCPProviderMetadata, mcp, oAuthDiscoveryMetadata, oAuthProtectedResourceMetadata, withMcpAuth } from "./mcp/index.mjs";
|
|
37
|
+
import { multiSession } from "./multi-session/index.mjs";
|
|
38
|
+
import { oAuthProxy } from "./oauth-proxy/index.mjs";
|
|
39
|
+
import { oneTap } from "./one-tap/index.mjs";
|
|
40
|
+
import { oneTimeToken } from "./one-time-token/index.mjs";
|
|
41
|
+
import { openAPI } from "./open-api/index.mjs";
|
|
42
|
+
import { getOrgAdapter } from "./organization/adapter.mjs";
|
|
43
|
+
import { organization, parseRoles } from "./organization/organization.mjs";
|
|
44
|
+
import "./organization/index.mjs";
|
|
45
|
+
import { phoneNumber } from "./phone-number/index.mjs";
|
|
46
|
+
import { siwe } from "./siwe/index.mjs";
|
|
47
|
+
import { twoFactor } from "./two-factor/index.mjs";
|
|
48
|
+
import { username } from "./username/index.mjs";
|
|
49
|
+
import { createAuthEndpoint, createAuthMiddleware, optionsMiddleware } from "@better-auth/core/api";
|
|
50
|
+
|
|
51
|
+
export { API_KEY_ERROR_CODES, API_KEY_TABLE_NAME, MULTI_SESSION_ERROR_CODES as ERROR_CODES, HIDE_METADATA, TWO_FACTOR_ERROR_CODES, USERNAME_ERROR_CODES, admin, anonymous, apiKey, auth0, bearer, captcha, createAccessControl, createAuthEndpoint, createAuthMiddleware, createJwk, customSession, defaultKeyHasher, deviceAuthorization, deviceAuthorizationOptionsSchema, emailOTP, generateExportedKeyPair, genericOAuth, getClient, getJwtToken, getMCPProtectedResourceMetadata, getMCPProviderMetadata, getMetadata, getOrgAdapter, gumroad, haveIBeenPwned, hubspot, jwt, keycloak, lastLoginMethod, line, magicLink, mcp, microsoftEntraId, multiSession, oAuthDiscoveryMetadata, oAuthProtectedResourceMetadata, oAuthProxy, oidcProvider, okta, oneTap, oneTimeToken, openAPI, optionsMiddleware, organization, parseRoles, patreon, phoneNumber, role, signJWT, siwe, slack, toExpJWT, twoFactor, twoFactorClient, username, verifyJWT, withMcpAuth };
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
//#region src/plugins/jwt/adapter.ts
|
|
2
|
+
const getJwksAdapter = (adapter, options) => {
|
|
3
|
+
return {
|
|
4
|
+
getAllKeys: async (ctx) => {
|
|
5
|
+
if (options?.adapter?.getJwks) return await options.adapter.getJwks(ctx);
|
|
6
|
+
return await adapter.findMany({ model: "jwks" });
|
|
7
|
+
},
|
|
8
|
+
getLatestKey: async (ctx) => {
|
|
9
|
+
if (options?.adapter?.getJwks) return (await options.adapter.getJwks(ctx))?.sort((a, b) => b.createdAt.getTime() - a.createdAt.getTime())[0];
|
|
10
|
+
return (await adapter.findMany({ model: "jwks" }))?.sort((a, b) => b.createdAt.getTime() - a.createdAt.getTime())[0];
|
|
11
|
+
},
|
|
12
|
+
createJwk: async (ctx, webKey) => {
|
|
13
|
+
if (options?.adapter?.createJwk) return await options.adapter.createJwk(webKey, ctx);
|
|
14
|
+
return await adapter.create({
|
|
15
|
+
model: "jwks",
|
|
16
|
+
data: {
|
|
17
|
+
...webKey,
|
|
18
|
+
createdAt: /* @__PURE__ */ new Date()
|
|
19
|
+
}
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
};
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
//#endregion
|
|
26
|
+
export { getJwksAdapter };
|
|
27
|
+
//# sourceMappingURL=adapter.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"adapter.mjs","names":[],"sources":["../../../src/plugins/jwt/adapter.ts"],"sourcesContent":["import type {\n\tBetterAuthOptions,\n\tGenericEndpointContext,\n} from \"@better-auth/core\";\nimport type { DBAdapter } from \"@better-auth/core/db/adapter\";\nimport type { Jwk, JwtOptions } from \"./types\";\n\nexport const getJwksAdapter = (\n\tadapter: DBAdapter<BetterAuthOptions>,\n\toptions?: JwtOptions,\n) => {\n\treturn {\n\t\tgetAllKeys: async (ctx: GenericEndpointContext) => {\n\t\t\tif (options?.adapter?.getJwks) {\n\t\t\t\treturn await options.adapter.getJwks(ctx);\n\t\t\t}\n\t\t\treturn await adapter.findMany<Jwk>({\n\t\t\t\tmodel: \"jwks\",\n\t\t\t});\n\t\t},\n\t\tgetLatestKey: async (ctx: GenericEndpointContext) => {\n\t\t\tif (options?.adapter?.getJwks) {\n\t\t\t\tconst keys = await options.adapter.getJwks(ctx);\n\t\t\t\treturn keys?.sort(\n\t\t\t\t\t(a, b) => b.createdAt.getTime() - a.createdAt.getTime(),\n\t\t\t\t)[0];\n\t\t\t}\n\t\t\tconst keys = await adapter.findMany<Jwk>({\n\t\t\t\tmodel: \"jwks\",\n\t\t\t});\n\t\t\treturn keys?.sort(\n\t\t\t\t(a, b) => b.createdAt.getTime() - a.createdAt.getTime(),\n\t\t\t)[0];\n\t\t},\n\t\tcreateJwk: async (ctx: GenericEndpointContext, webKey: Omit<Jwk, \"id\">) => {\n\t\t\tif (options?.adapter?.createJwk) {\n\t\t\t\treturn await options.adapter.createJwk(webKey, ctx);\n\t\t\t}\n\t\t\tconst jwk = await adapter.create<Omit<Jwk, \"id\">, Jwk>({\n\t\t\t\tmodel: \"jwks\",\n\t\t\t\tdata: {\n\t\t\t\t\t...webKey,\n\t\t\t\t\tcreatedAt: new Date(),\n\t\t\t\t},\n\t\t\t});\n\n\t\t\treturn jwk;\n\t\t},\n\t};\n};\n"],"mappings":";AAOA,MAAa,kBACZ,SACA,YACI;AACJ,QAAO;EACN,YAAY,OAAO,QAAgC;AAClD,OAAI,SAAS,SAAS,QACrB,QAAO,MAAM,QAAQ,QAAQ,QAAQ,IAAI;AAE1C,UAAO,MAAM,QAAQ,SAAc,EAClC,OAAO,QACP,CAAC;;EAEH,cAAc,OAAO,QAAgC;AACpD,OAAI,SAAS,SAAS,QAErB,SADa,MAAM,QAAQ,QAAQ,QAAQ,IAAI,GAClC,MACX,GAAG,MAAM,EAAE,UAAU,SAAS,GAAG,EAAE,UAAU,SAAS,CACvD,CAAC;AAKH,WAHa,MAAM,QAAQ,SAAc,EACxC,OAAO,QACP,CAAC,GACW,MACX,GAAG,MAAM,EAAE,UAAU,SAAS,GAAG,EAAE,UAAU,SAAS,CACvD,CAAC;;EAEH,WAAW,OAAO,KAA6B,WAA4B;AAC1E,OAAI,SAAS,SAAS,UACrB,QAAO,MAAM,QAAQ,QAAQ,UAAU,QAAQ,IAAI;AAUpD,UARY,MAAM,QAAQ,OAA6B;IACtD,OAAO;IACP,MAAM;KACL,GAAG;KACH,2BAAW,IAAI,MAAM;KACrB;IACD,CAAC;;EAIH"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { JWKOptions, JWSAlgorithms, Jwk, JwtOptions } from "./types.mjs";
|
|
2
|
+
|
|
3
|
+
//#region src/plugins/jwt/client.d.ts
|
|
4
|
+
interface JwtClientOptions {
|
|
5
|
+
jwks?: {
|
|
6
|
+
/**
|
|
7
|
+
* The path of the endpoint exposing the JWKS.
|
|
8
|
+
* Must match the server configuration.
|
|
9
|
+
*
|
|
10
|
+
* @default /jwks
|
|
11
|
+
*/
|
|
12
|
+
jwksPath?: string;
|
|
13
|
+
};
|
|
14
|
+
}
|
|
15
|
+
declare const jwtClient: (options?: JwtClientOptions) => BetterAuthClientPlugin;
|
|
16
|
+
//#endregion
|
|
17
|
+
export { jwtClient };
|
|
18
|
+
//# sourceMappingURL=client.d.mts.map
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
//#region src/plugins/jwt/client.ts
|
|
2
|
+
const jwtClient = (options) => {
|
|
3
|
+
const jwksPath = options?.jwks?.jwksPath ?? "/jwks";
|
|
4
|
+
return {
|
|
5
|
+
id: "better-auth-client",
|
|
6
|
+
$InferServerPlugin: {},
|
|
7
|
+
pathMethods: { [jwksPath]: "GET" },
|
|
8
|
+
getActions: ($fetch) => ({ jwks: async (fetchOptions) => {
|
|
9
|
+
return await $fetch(jwksPath, {
|
|
10
|
+
method: "GET",
|
|
11
|
+
...fetchOptions
|
|
12
|
+
});
|
|
13
|
+
} })
|
|
14
|
+
};
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
//#endregion
|
|
18
|
+
export { jwtClient };
|
|
19
|
+
//# sourceMappingURL=client.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client.mjs","names":[],"sources":["../../../src/plugins/jwt/client.ts"],"sourcesContent":["import type { BetterAuthClientPlugin } from \"@better-auth/core\";\nimport type { JSONWebKeySet } from \"jose\";\nimport type { jwt } from \"./index\";\n\ninterface JwtClientOptions {\n\tjwks?: {\n\t\t/**\n\t\t * The path of the endpoint exposing the JWKS.\n\t\t * Must match the server configuration.\n\t\t *\n\t\t * @default /jwks\n\t\t */\n\t\tjwksPath?: string;\n\t};\n}\n\nexport const jwtClient = (options?: JwtClientOptions) => {\n\tconst jwksPath = options?.jwks?.jwksPath ?? \"/jwks\";\n\n\treturn {\n\t\tid: \"better-auth-client\",\n\t\t$InferServerPlugin: {} as ReturnType<typeof jwt>,\n\t\tpathMethods: {\n\t\t\t[jwksPath]: \"GET\",\n\t\t},\n\t\tgetActions: ($fetch) => ({\n\t\t\tjwks: async (fetchOptions?: any) => {\n\t\t\t\treturn await $fetch<JSONWebKeySet>(jwksPath, {\n\t\t\t\t\tmethod: \"GET\",\n\t\t\t\t\t...fetchOptions,\n\t\t\t\t});\n\t\t\t},\n\t\t}),\n\t} satisfies BetterAuthClientPlugin;\n};\n\nexport type * from \"./types\";\n"],"mappings":";AAgBA,MAAa,aAAa,YAA+B;CACxD,MAAM,WAAW,SAAS,MAAM,YAAY;AAE5C,QAAO;EACN,IAAI;EACJ,oBAAoB,EAAE;EACtB,aAAa,GACX,WAAW,OACZ;EACD,aAAa,YAAY,EACxB,MAAM,OAAO,iBAAuB;AACnC,UAAO,MAAM,OAAsB,UAAU;IAC5C,QAAQ;IACR,GAAG;IACH,CAAC;KAEH;EACD"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { JWKOptions, JWSAlgorithms, Jwk, JwtOptions } from "./types.mjs";
|
|
2
|
+
import { getJwtToken, signJWT } from "./sign.mjs";
|
|
3
|
+
import { createJwk, generateExportedKeyPair, toExpJWT } from "./utils.mjs";
|
|
4
|
+
import { verifyJWT } from "./verify.mjs";
|
|
5
|
+
|
|
6
|
+
//#region src/plugins/jwt/index.d.ts
|
|
7
|
+
declare module "@better-auth/core" {
|
|
8
|
+
interface BetterAuthPluginRegistry<AuthOptions, Options> {
|
|
9
|
+
jwt: {
|
|
10
|
+
creator: typeof jwt;
|
|
11
|
+
};
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
declare const jwt: <O extends JwtOptions>(options?: O) => BetterAuthPlugin;
|
|
15
|
+
//#endregion
|
|
16
|
+
export { JWKOptions, JWSAlgorithms, Jwk, JwtOptions, createJwk, generateExportedKeyPair, getJwtToken, jwt, signJWT, toExpJWT, verifyJWT };
|
|
17
|
+
//# sourceMappingURL=index.d.mts.map
|