@hammadj/better-auth 1.5.0-beta.10
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/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 +62 -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,181 @@
|
|
|
1
|
+
import { PrettifyDeep, UnionToIntersection } from "../types/helper.mjs";
|
|
2
|
+
import { InferRoute } from "../client/path-to-object.mjs";
|
|
3
|
+
import { InferErrorCodes, IsSignal, SessionQueryParams } from "../client/types.mjs";
|
|
4
|
+
import { DefaultSessionAPI, FilteredAPI, InferAPI } from "../types/api.mjs";
|
|
5
|
+
import { Session, User } from "../types/models.mjs";
|
|
6
|
+
import { Auth } from "../types/auth.mjs";
|
|
7
|
+
import "../types/index.mjs";
|
|
8
|
+
import "../index.mjs";
|
|
9
|
+
import { setCookieToHeader } from "../cookies/cookie-utils.mjs";
|
|
10
|
+
import "../cookies/index.mjs";
|
|
11
|
+
import { Awaitable, BetterAuthClientOptions, BetterAuthOptions } from "@better-auth/core";
|
|
12
|
+
import * as nanostores3 from "nanostores";
|
|
13
|
+
import * as _better_fetch_fetch4 from "@better-fetch/fetch";
|
|
14
|
+
import { SuccessContext } from "@better-fetch/fetch";
|
|
15
|
+
|
|
16
|
+
//#region src/test-utils/test-instance.d.ts
|
|
17
|
+
declare function getTestInstance<O extends Partial<BetterAuthOptions>, C extends BetterAuthClientOptions>(options?: O | undefined, config?: {
|
|
18
|
+
clientOptions?: C;
|
|
19
|
+
port?: number;
|
|
20
|
+
disableTestUser?: boolean;
|
|
21
|
+
testUser?: Partial<User>;
|
|
22
|
+
testWith?: "sqlite" | "postgres" | "mongodb" | "mysql";
|
|
23
|
+
} | undefined): Promise<{
|
|
24
|
+
auth: Auth<O>;
|
|
25
|
+
client: UnionToIntersection<(C extends undefined ? {} : C) & {
|
|
26
|
+
baseURL: string | undefined;
|
|
27
|
+
fetchOptions: {
|
|
28
|
+
customFetchImpl: (url: string | URL | Request, init?: RequestInit | undefined) => Promise<Response>;
|
|
29
|
+
};
|
|
30
|
+
} extends infer T ? T extends (C extends undefined ? {} : C) & {
|
|
31
|
+
baseURL: string | undefined;
|
|
32
|
+
fetchOptions: {
|
|
33
|
+
customFetchImpl: (url: string | URL | Request, init?: RequestInit | undefined) => Promise<Response>;
|
|
34
|
+
};
|
|
35
|
+
} ? T extends {
|
|
36
|
+
plugins: Array<infer Plugin>;
|
|
37
|
+
} ? UnionToIntersection<Plugin extends BetterAuthClientPlugin ? Plugin["getAtoms"] extends ((fetch: any) => infer Atoms) ? Atoms extends Record<string, any> ? { [key in keyof Atoms as IsSignal<key> extends true ? never : key extends string ? `use${Capitalize<key>}` : never]: Atoms[key] } : {} : {} : {}> : {} : never : never> & UnionToIntersection<InferRoute<((C extends undefined ? {} : C) & {
|
|
38
|
+
baseURL: string | undefined;
|
|
39
|
+
fetchOptions: {
|
|
40
|
+
customFetchImpl: (url: string | URL | Request, init?: RequestInit | undefined) => Promise<Response>;
|
|
41
|
+
};
|
|
42
|
+
})["plugins"] extends any[] ? DefaultSessionAPI & FilteredAPI<any> & (((C extends undefined ? {} : C) & {
|
|
43
|
+
baseURL: string | undefined;
|
|
44
|
+
fetchOptions: {
|
|
45
|
+
customFetchImpl: (url: string | URL | Request, init?: RequestInit | undefined) => Promise<Response>;
|
|
46
|
+
};
|
|
47
|
+
})["plugins"] extends (infer Pl)[] ? UnionToIntersection<Pl extends {
|
|
48
|
+
$InferServerPlugin: infer Plug;
|
|
49
|
+
} ? Plug extends {
|
|
50
|
+
endpoints: infer Endpoints;
|
|
51
|
+
} ? Endpoints : {} : {}> : {}) : InferAPI<any>, (C extends undefined ? {} : C) & {
|
|
52
|
+
baseURL: string | undefined;
|
|
53
|
+
fetchOptions: {
|
|
54
|
+
customFetchImpl: (url: string | URL | Request, init?: RequestInit | undefined) => Promise<Response>;
|
|
55
|
+
};
|
|
56
|
+
}>> & (((C extends undefined ? {} : C) & {
|
|
57
|
+
baseURL: string | undefined;
|
|
58
|
+
fetchOptions: {
|
|
59
|
+
customFetchImpl: (url: string | URL | Request, init?: RequestInit | undefined) => Promise<Response>;
|
|
60
|
+
};
|
|
61
|
+
})["plugins"] extends (infer Plugin_1)[] ? UnionToIntersection<Plugin_1 extends BetterAuthClientPlugin ? Plugin_1["getActions"] extends ((...args: any) => infer Actions) ? Actions : {} : {}> : {}) & UnionToIntersection<InferRoute<((C extends undefined ? {} : C) & {
|
|
62
|
+
baseURL: string | undefined;
|
|
63
|
+
fetchOptions: {
|
|
64
|
+
customFetchImpl: (url: string | URL | Request, init?: RequestInit | undefined) => Promise<Response>;
|
|
65
|
+
};
|
|
66
|
+
})["$InferAuth"] extends {
|
|
67
|
+
plugins: infer Plugins;
|
|
68
|
+
} ? Plugins extends (infer Plugin_2)[] ? Plugin_2 extends {
|
|
69
|
+
endpoints: infer Endpoints_1;
|
|
70
|
+
} ? Endpoints_1 : {} : {} : {}, (C extends undefined ? {} : C) & {
|
|
71
|
+
baseURL: string | undefined;
|
|
72
|
+
fetchOptions: {
|
|
73
|
+
customFetchImpl: (url: string | URL | Request, init?: RequestInit | undefined) => Promise<Response>;
|
|
74
|
+
};
|
|
75
|
+
}>> & {
|
|
76
|
+
useSession: nanostores3.Atom<{
|
|
77
|
+
data: UnionToIntersection<InferRoute<((C extends undefined ? {} : C) & {
|
|
78
|
+
baseURL: string | undefined;
|
|
79
|
+
fetchOptions: {
|
|
80
|
+
customFetchImpl: (url: string | URL | Request, init?: RequestInit | undefined) => Promise<Response>;
|
|
81
|
+
};
|
|
82
|
+
})["plugins"] extends any[] ? DefaultSessionAPI & FilteredAPI<any> & (((C extends undefined ? {} : C) & {
|
|
83
|
+
baseURL: string | undefined;
|
|
84
|
+
fetchOptions: {
|
|
85
|
+
customFetchImpl: (url: string | URL | Request, init?: RequestInit | undefined) => Promise<Response>;
|
|
86
|
+
};
|
|
87
|
+
})["plugins"] extends (infer Pl)[] ? UnionToIntersection<Pl extends {
|
|
88
|
+
$InferServerPlugin: infer Plug;
|
|
89
|
+
} ? Plug extends {
|
|
90
|
+
endpoints: infer Endpoints;
|
|
91
|
+
} ? Endpoints : {} : {}> : {}) : InferAPI<any>, (C extends undefined ? {} : C) & {
|
|
92
|
+
baseURL: string | undefined;
|
|
93
|
+
fetchOptions: {
|
|
94
|
+
customFetchImpl: (url: string | URL | Request, init?: RequestInit | undefined) => Promise<Response>;
|
|
95
|
+
};
|
|
96
|
+
}>> extends {
|
|
97
|
+
getSession: () => Promise<infer Res>;
|
|
98
|
+
} ? Res extends {
|
|
99
|
+
data: null;
|
|
100
|
+
error: {
|
|
101
|
+
message?: string | undefined;
|
|
102
|
+
status: number;
|
|
103
|
+
statusText: string;
|
|
104
|
+
};
|
|
105
|
+
} | {
|
|
106
|
+
data: infer S;
|
|
107
|
+
error: null;
|
|
108
|
+
} ? S : Res extends Record<string, any> ? Res : never : never;
|
|
109
|
+
error: _better_fetch_fetch4.BetterFetchError | null;
|
|
110
|
+
isPending: boolean;
|
|
111
|
+
isRefetching: boolean;
|
|
112
|
+
refetch: (queryParams?: {
|
|
113
|
+
query?: SessionQueryParams;
|
|
114
|
+
} | undefined) => Promise<void>;
|
|
115
|
+
}>;
|
|
116
|
+
$fetch: _better_fetch_fetch4.BetterFetch<any, any, any, any>;
|
|
117
|
+
$store: {
|
|
118
|
+
notify: (signal?: (Omit<string, "$sessionSignal"> | "$sessionSignal") | undefined) => void;
|
|
119
|
+
listen: (signal: Omit<string, "$sessionSignal"> | "$sessionSignal", listener: (value: boolean, oldValue?: boolean | undefined) => void) => void;
|
|
120
|
+
atoms: Record<string, nanostores3.WritableAtom<any>>;
|
|
121
|
+
};
|
|
122
|
+
$Infer: {
|
|
123
|
+
Session: NonNullable<UnionToIntersection<InferRoute<((C extends undefined ? {} : C) & {
|
|
124
|
+
baseURL: string | undefined;
|
|
125
|
+
fetchOptions: {
|
|
126
|
+
customFetchImpl: (url: string | URL | Request, init?: RequestInit | undefined) => Promise<Response>;
|
|
127
|
+
};
|
|
128
|
+
})["plugins"] extends any[] ? DefaultSessionAPI & FilteredAPI<any> & (((C extends undefined ? {} : C) & {
|
|
129
|
+
baseURL: string | undefined;
|
|
130
|
+
fetchOptions: {
|
|
131
|
+
customFetchImpl: (url: string | URL | Request, init?: RequestInit | undefined) => Promise<Response>;
|
|
132
|
+
};
|
|
133
|
+
})["plugins"] extends (infer Pl)[] ? UnionToIntersection<Pl extends {
|
|
134
|
+
$InferServerPlugin: infer Plug;
|
|
135
|
+
} ? Plug extends {
|
|
136
|
+
endpoints: infer Endpoints;
|
|
137
|
+
} ? Endpoints : {} : {}> : {}) : InferAPI<any>, (C extends undefined ? {} : C) & {
|
|
138
|
+
baseURL: string | undefined;
|
|
139
|
+
fetchOptions: {
|
|
140
|
+
customFetchImpl: (url: string | URL | Request, init?: RequestInit | undefined) => Promise<Response>;
|
|
141
|
+
};
|
|
142
|
+
}>> extends {
|
|
143
|
+
getSession: () => Promise<infer Res>;
|
|
144
|
+
} ? Res extends {
|
|
145
|
+
data: null;
|
|
146
|
+
error: {
|
|
147
|
+
message?: string | undefined;
|
|
148
|
+
status: number;
|
|
149
|
+
statusText: string;
|
|
150
|
+
};
|
|
151
|
+
} | {
|
|
152
|
+
data: infer S;
|
|
153
|
+
error: null;
|
|
154
|
+
} ? S : Res extends Record<string, any> ? Res : never : never>;
|
|
155
|
+
};
|
|
156
|
+
$ERROR_CODES: PrettifyDeep<InferErrorCodes<Option> & typeof Awaitable>;
|
|
157
|
+
};
|
|
158
|
+
testUser: any;
|
|
159
|
+
signInWithTestUser: () => Promise<{
|
|
160
|
+
session: Session;
|
|
161
|
+
user: User;
|
|
162
|
+
headers: Headers;
|
|
163
|
+
setCookie: (name: string, value: string) => void;
|
|
164
|
+
runWithUser: (fn: (headers: Headers) => Promise<void>) => Promise<void>;
|
|
165
|
+
}>;
|
|
166
|
+
signInWithUser: (email: string, password: string) => Promise<{
|
|
167
|
+
res: {
|
|
168
|
+
user: User;
|
|
169
|
+
session: Session;
|
|
170
|
+
};
|
|
171
|
+
headers: Headers;
|
|
172
|
+
}>;
|
|
173
|
+
cookieSetter: typeof setCookieToHeader;
|
|
174
|
+
customFetchImpl: (url: string | URL | Request, init?: RequestInit | undefined) => Promise<Response>;
|
|
175
|
+
sessionSetter: (headers: Headers) => (context: SuccessContext) => void;
|
|
176
|
+
db: DBAdapter<BetterAuthOptions>;
|
|
177
|
+
runWithUser: (email: string, password: string, fn: (headers: Headers) => Awaitable<void>) => Promise<void>;
|
|
178
|
+
}>;
|
|
179
|
+
//#endregion
|
|
180
|
+
export { getTestInstance };
|
|
181
|
+
//# sourceMappingURL=test-instance.d.mts.map
|
|
@@ -0,0 +1,210 @@
|
|
|
1
|
+
import { getAdapter } from "../db/adapter-kysely.mjs";
|
|
2
|
+
import { getMigrations } from "../db/get-migration.mjs";
|
|
3
|
+
import { getBaseURL } from "../utils/url.mjs";
|
|
4
|
+
import { parseSetCookieHeader, setCookieToHeader } from "../cookies/cookie-utils.mjs";
|
|
5
|
+
import "../cookies/index.mjs";
|
|
6
|
+
import { betterAuth } from "../auth/full.mjs";
|
|
7
|
+
import { createAuthClient } from "../client/vanilla.mjs";
|
|
8
|
+
import "../client/index.mjs";
|
|
9
|
+
import { bearer } from "../plugins/bearer/index.mjs";
|
|
10
|
+
import "../plugins/index.mjs";
|
|
11
|
+
import { sql } from "kysely";
|
|
12
|
+
import { AsyncLocalStorage } from "node:async_hooks";
|
|
13
|
+
import { afterAll } from "vitest";
|
|
14
|
+
|
|
15
|
+
//#region src/test-utils/test-instance.ts
|
|
16
|
+
const cleanupSet = /* @__PURE__ */ new Set();
|
|
17
|
+
const currentUserContextStorage = new AsyncLocalStorage();
|
|
18
|
+
afterAll(async () => {
|
|
19
|
+
for (const cleanup of cleanupSet) {
|
|
20
|
+
await cleanup();
|
|
21
|
+
cleanupSet.delete(cleanup);
|
|
22
|
+
}
|
|
23
|
+
});
|
|
24
|
+
async function getTestInstance(options, config) {
|
|
25
|
+
const testWith = config?.testWith || "sqlite";
|
|
26
|
+
async function getPostgres() {
|
|
27
|
+
const { Kysely, PostgresDialect } = await import("kysely");
|
|
28
|
+
const { Pool } = await import("pg");
|
|
29
|
+
return new Kysely({ dialect: new PostgresDialect({ pool: new Pool({ connectionString: "postgres://user:password@localhost:5432/better_auth" }) }) });
|
|
30
|
+
}
|
|
31
|
+
async function getSqlite() {
|
|
32
|
+
const { DatabaseSync } = await import("node:sqlite");
|
|
33
|
+
return new DatabaseSync(":memory:");
|
|
34
|
+
}
|
|
35
|
+
async function getMysql() {
|
|
36
|
+
const { Kysely, MysqlDialect } = await import("kysely");
|
|
37
|
+
const { createPool } = await import("mysql2/promise");
|
|
38
|
+
return new Kysely({ dialect: new MysqlDialect(createPool("mysql://user:password@localhost:3306/better_auth")) });
|
|
39
|
+
}
|
|
40
|
+
async function mongodbClient() {
|
|
41
|
+
const { MongoClient } = await import("mongodb");
|
|
42
|
+
const dbClient = async (connectionString, dbName) => {
|
|
43
|
+
const client = new MongoClient(connectionString);
|
|
44
|
+
await client.connect();
|
|
45
|
+
return client.db(dbName);
|
|
46
|
+
};
|
|
47
|
+
return await dbClient("mongodb://127.0.0.1:27017", "better-auth");
|
|
48
|
+
}
|
|
49
|
+
const opts = {
|
|
50
|
+
socialProviders: {
|
|
51
|
+
github: {
|
|
52
|
+
clientId: "test",
|
|
53
|
+
clientSecret: "test"
|
|
54
|
+
},
|
|
55
|
+
google: {
|
|
56
|
+
clientId: "test",
|
|
57
|
+
clientSecret: "test"
|
|
58
|
+
}
|
|
59
|
+
},
|
|
60
|
+
secret: "better-auth-secret-that-is-long-enough-for-validation-test",
|
|
61
|
+
database: testWith === "postgres" ? {
|
|
62
|
+
db: await getPostgres(),
|
|
63
|
+
type: "postgres"
|
|
64
|
+
} : testWith === "mongodb" ? await Promise.all([mongodbClient(), await import("../adapters/mongodb-adapter/index.mjs")]).then(([db, { mongodbAdapter }]) => mongodbAdapter(db)) : testWith === "mysql" ? {
|
|
65
|
+
db: await getMysql(),
|
|
66
|
+
type: "mysql"
|
|
67
|
+
} : await getSqlite(),
|
|
68
|
+
emailAndPassword: { enabled: true },
|
|
69
|
+
rateLimit: { enabled: false },
|
|
70
|
+
advanced: { cookies: {} },
|
|
71
|
+
logger: { level: "debug" }
|
|
72
|
+
};
|
|
73
|
+
const auth = betterAuth({
|
|
74
|
+
baseURL: "http://localhost:" + (config?.port || 3e3),
|
|
75
|
+
...opts,
|
|
76
|
+
...options,
|
|
77
|
+
plugins: [bearer(), ...options?.plugins || []]
|
|
78
|
+
});
|
|
79
|
+
const testUser = {
|
|
80
|
+
email: "test@test.com",
|
|
81
|
+
password: "test123456",
|
|
82
|
+
name: "test user",
|
|
83
|
+
...config?.testUser
|
|
84
|
+
};
|
|
85
|
+
async function createTestUser() {
|
|
86
|
+
if (config?.disableTestUser) return;
|
|
87
|
+
await auth.api.signUpEmail({ body: testUser });
|
|
88
|
+
}
|
|
89
|
+
if (testWith !== "mongodb") {
|
|
90
|
+
const { runMigrations } = await getMigrations({
|
|
91
|
+
...auth.options,
|
|
92
|
+
database: opts.database
|
|
93
|
+
});
|
|
94
|
+
await runMigrations();
|
|
95
|
+
}
|
|
96
|
+
await createTestUser();
|
|
97
|
+
const cleanup = async () => {
|
|
98
|
+
if (testWith === "mongodb") {
|
|
99
|
+
await (await mongodbClient()).dropDatabase();
|
|
100
|
+
return;
|
|
101
|
+
}
|
|
102
|
+
if (testWith === "postgres") {
|
|
103
|
+
const postgres = await getPostgres();
|
|
104
|
+
await sql`DROP SCHEMA public CASCADE; CREATE SCHEMA public;`.execute(postgres);
|
|
105
|
+
await postgres.destroy();
|
|
106
|
+
return;
|
|
107
|
+
}
|
|
108
|
+
if (testWith === "mysql") {
|
|
109
|
+
const mysql = await getMysql();
|
|
110
|
+
await sql`SET FOREIGN_KEY_CHECKS = 0;`.execute(mysql);
|
|
111
|
+
const tables = await mysql.introspection.getTables();
|
|
112
|
+
for (const table of tables) await mysql.deleteFrom(table.name).execute();
|
|
113
|
+
await sql`SET FOREIGN_KEY_CHECKS = 1;`.execute(mysql);
|
|
114
|
+
return;
|
|
115
|
+
}
|
|
116
|
+
if (testWith === "sqlite") {
|
|
117
|
+
(await getSqlite()).close();
|
|
118
|
+
return;
|
|
119
|
+
}
|
|
120
|
+
};
|
|
121
|
+
cleanupSet.add(cleanup);
|
|
122
|
+
const customFetchImpl = async (url, init) => {
|
|
123
|
+
const headers = init?.headers || {};
|
|
124
|
+
const storageHeaders = currentUserContextStorage.getStore()?.headers;
|
|
125
|
+
return auth.handler(new Request(url, init ? {
|
|
126
|
+
...init,
|
|
127
|
+
headers: new Headers({
|
|
128
|
+
...storageHeaders ? Object.fromEntries(storageHeaders.entries()) : {},
|
|
129
|
+
...headers instanceof Headers ? Object.fromEntries(headers.entries()) : typeof headers === "object" ? headers : {}
|
|
130
|
+
})
|
|
131
|
+
} : { headers }));
|
|
132
|
+
};
|
|
133
|
+
const client = createAuthClient({
|
|
134
|
+
...config?.clientOptions,
|
|
135
|
+
baseURL: getBaseURL(options?.baseURL || "http://localhost:" + (config?.port || 3e3), options?.basePath || "/api/auth"),
|
|
136
|
+
fetchOptions: { customFetchImpl }
|
|
137
|
+
});
|
|
138
|
+
async function signInWithTestUser() {
|
|
139
|
+
if (config?.disableTestUser) throw new Error("Test user is disabled");
|
|
140
|
+
const headers = new Headers();
|
|
141
|
+
const setCookie = (name, value) => {
|
|
142
|
+
const current = headers.get("cookie");
|
|
143
|
+
headers.set("cookie", `${current || ""}; ${name}=${value}`);
|
|
144
|
+
};
|
|
145
|
+
const { data } = await client.signIn.email({
|
|
146
|
+
email: testUser.email,
|
|
147
|
+
password: testUser.password,
|
|
148
|
+
fetchOptions: { onSuccess(context) {
|
|
149
|
+
const signedCookie = parseSetCookieHeader(context.response.headers.get("set-cookie") || "").get("better-auth.session_token")?.value;
|
|
150
|
+
headers.set("cookie", `better-auth.session_token=${signedCookie}`);
|
|
151
|
+
} }
|
|
152
|
+
});
|
|
153
|
+
return {
|
|
154
|
+
session: data.session,
|
|
155
|
+
user: data.user,
|
|
156
|
+
headers,
|
|
157
|
+
setCookie,
|
|
158
|
+
runWithUser: async (fn) => {
|
|
159
|
+
return currentUserContextStorage.run({ headers }, async () => {
|
|
160
|
+
await fn(headers);
|
|
161
|
+
});
|
|
162
|
+
}
|
|
163
|
+
};
|
|
164
|
+
}
|
|
165
|
+
async function signInWithUser(email, password) {
|
|
166
|
+
const headers = new Headers();
|
|
167
|
+
const { data } = await client.signIn.email({
|
|
168
|
+
email,
|
|
169
|
+
password,
|
|
170
|
+
fetchOptions: { onSuccess(context) {
|
|
171
|
+
const signedCookie = parseSetCookieHeader(context.response.headers.get("set-cookie") || "").get("better-auth.session_token")?.value;
|
|
172
|
+
headers.set("cookie", `better-auth.session_token=${signedCookie}`);
|
|
173
|
+
} }
|
|
174
|
+
});
|
|
175
|
+
return {
|
|
176
|
+
res: data,
|
|
177
|
+
headers
|
|
178
|
+
};
|
|
179
|
+
}
|
|
180
|
+
function sessionSetter(headers) {
|
|
181
|
+
return (context) => {
|
|
182
|
+
const header = context.response.headers.get("set-cookie");
|
|
183
|
+
if (header) {
|
|
184
|
+
const signedCookie = parseSetCookieHeader(header || "").get("better-auth.session_token")?.value;
|
|
185
|
+
headers.set("cookie", `better-auth.session_token=${signedCookie}`);
|
|
186
|
+
}
|
|
187
|
+
};
|
|
188
|
+
}
|
|
189
|
+
return {
|
|
190
|
+
auth,
|
|
191
|
+
client,
|
|
192
|
+
testUser,
|
|
193
|
+
signInWithTestUser,
|
|
194
|
+
signInWithUser,
|
|
195
|
+
cookieSetter: setCookieToHeader,
|
|
196
|
+
customFetchImpl,
|
|
197
|
+
sessionSetter,
|
|
198
|
+
db: await getAdapter(auth.options),
|
|
199
|
+
runWithUser: async (email, password, fn) => {
|
|
200
|
+
const { headers } = await signInWithUser(email, password);
|
|
201
|
+
return currentUserContextStorage.run({ headers }, async () => {
|
|
202
|
+
await fn(headers);
|
|
203
|
+
});
|
|
204
|
+
}
|
|
205
|
+
};
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
//#endregion
|
|
209
|
+
export { getTestInstance };
|
|
210
|
+
//# sourceMappingURL=test-instance.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"test-instance.mjs","names":[],"sources":["../../src/test-utils/test-instance.ts"],"sourcesContent":["import { AsyncLocalStorage } from \"node:async_hooks\";\nimport type {\n\tAwaitable,\n\tBetterAuthClientOptions,\n\tBetterAuthOptions,\n} from \"@better-auth/core\";\nimport type { SuccessContext } from \"@better-fetch/fetch\";\nimport { sql } from \"kysely\";\nimport { afterAll } from \"vitest\";\nimport { betterAuth } from \"../auth/full\";\nimport { createAuthClient } from \"../client\";\nimport { parseSetCookieHeader, setCookieToHeader } from \"../cookies\";\nimport { getAdapter } from \"../db/adapter-kysely\";\nimport { getMigrations } from \"../db/get-migration\";\nimport { bearer } from \"../plugins\";\nimport type { Session, User } from \"../types\";\nimport { getBaseURL } from \"../utils/url\";\n\nconst cleanupSet = new Set<Function>();\n\ntype CurrentUserContext = {\n\theaders: Headers;\n};\nconst currentUserContextStorage = new AsyncLocalStorage<CurrentUserContext>();\n\nafterAll(async () => {\n\tfor (const cleanup of cleanupSet) {\n\t\tawait cleanup();\n\t\tcleanupSet.delete(cleanup);\n\t}\n});\n\nexport async function getTestInstance<\n\tO extends Partial<BetterAuthOptions>,\n\tC extends BetterAuthClientOptions,\n>(\n\toptions?: O | undefined,\n\tconfig?:\n\t\t| {\n\t\t\t\tclientOptions?: C;\n\t\t\t\tport?: number;\n\t\t\t\tdisableTestUser?: boolean;\n\t\t\t\ttestUser?: Partial<User>;\n\t\t\t\ttestWith?: \"sqlite\" | \"postgres\" | \"mongodb\" | \"mysql\";\n\t\t }\n\t\t| undefined,\n) {\n\tconst testWith = config?.testWith || \"sqlite\";\n\n\tasync function getPostgres() {\n\t\tconst { Kysely, PostgresDialect } = await import(\"kysely\");\n\t\tconst { Pool } = await import(\"pg\");\n\t\treturn new Kysely({\n\t\t\tdialect: new PostgresDialect({\n\t\t\t\tpool: new Pool({\n\t\t\t\t\tconnectionString:\n\t\t\t\t\t\t\"postgres://user:password@localhost:5432/better_auth\",\n\t\t\t\t}),\n\t\t\t}),\n\t\t});\n\t}\n\n\tasync function getSqlite() {\n\t\tconst { DatabaseSync } = await import(\"node:sqlite\");\n\t\treturn new DatabaseSync(\":memory:\");\n\t}\n\n\tasync function getMysql() {\n\t\tconst { Kysely, MysqlDialect } = await import(\"kysely\");\n\t\tconst { createPool } = await import(\"mysql2/promise\");\n\t\treturn new Kysely({\n\t\t\tdialect: new MysqlDialect(\n\t\t\t\tcreatePool(\"mysql://user:password@localhost:3306/better_auth\"),\n\t\t\t),\n\t\t});\n\t}\n\n\tasync function mongodbClient() {\n\t\tconst { MongoClient } = await import(\"mongodb\");\n\t\tconst dbClient = async (connectionString: string, dbName: string) => {\n\t\t\tconst client = new MongoClient(connectionString);\n\t\t\tawait client.connect();\n\t\t\tconst db = client.db(dbName);\n\t\t\treturn db;\n\t\t};\n\t\tconst db = await dbClient(\"mongodb://127.0.0.1:27017\", \"better-auth\");\n\t\treturn db;\n\t}\n\n\tconst opts = {\n\t\tsocialProviders: {\n\t\t\tgithub: {\n\t\t\t\tclientId: \"test\",\n\t\t\t\tclientSecret: \"test\",\n\t\t\t},\n\t\t\tgoogle: {\n\t\t\t\tclientId: \"test\",\n\t\t\t\tclientSecret: \"test\",\n\t\t\t},\n\t\t},\n\t\tsecret: \"better-auth-secret-that-is-long-enough-for-validation-test\",\n\t\tdatabase:\n\t\t\ttestWith === \"postgres\"\n\t\t\t\t? { db: await getPostgres(), type: \"postgres\" }\n\t\t\t\t: testWith === \"mongodb\"\n\t\t\t\t\t? await Promise.all([\n\t\t\t\t\t\t\tmongodbClient(),\n\t\t\t\t\t\t\tawait import(\"../adapters/mongodb-adapter\"),\n\t\t\t\t\t\t]).then(([db, { mongodbAdapter }]) => mongodbAdapter(db))\n\t\t\t\t\t: testWith === \"mysql\"\n\t\t\t\t\t\t? { db: await getMysql(), type: \"mysql\" }\n\t\t\t\t\t\t: await getSqlite(),\n\t\temailAndPassword: {\n\t\t\tenabled: true,\n\t\t},\n\t\trateLimit: {\n\t\t\tenabled: false,\n\t\t},\n\t\tadvanced: {\n\t\t\tcookies: {},\n\t\t},\n\t\tlogger: {\n\t\t\tlevel: \"debug\",\n\t\t},\n\t} satisfies BetterAuthOptions;\n\n\tconst auth = betterAuth({\n\t\tbaseURL: \"http://localhost:\" + (config?.port || 3000),\n\t\t...opts,\n\t\t...options,\n\t\tplugins: [bearer(), ...(options?.plugins || [])],\n\t} as unknown as O);\n\n\tconst testUser = {\n\t\temail: \"test@test.com\",\n\t\tpassword: \"test123456\",\n\t\tname: \"test user\",\n\t\t...config?.testUser,\n\t};\n\tasync function createTestUser() {\n\t\tif (config?.disableTestUser) {\n\t\t\treturn;\n\t\t}\n\t\t//@ts-expect-error\n\t\tawait auth.api.signUpEmail({\n\t\t\tbody: testUser,\n\t\t});\n\t}\n\n\tif (testWith !== \"mongodb\") {\n\t\tconst { runMigrations } = await getMigrations({\n\t\t\t...auth.options,\n\t\t\tdatabase: opts.database,\n\t\t});\n\t\tawait runMigrations();\n\t}\n\n\tawait createTestUser();\n\n\tconst cleanup = async () => {\n\t\tif (testWith === \"mongodb\") {\n\t\t\tconst db = await mongodbClient();\n\t\t\tawait db.dropDatabase();\n\t\t\treturn;\n\t\t}\n\t\tif (testWith === \"postgres\") {\n\t\t\tconst postgres = await getPostgres();\n\t\t\tawait sql`DROP SCHEMA public CASCADE; CREATE SCHEMA public;`.execute(\n\t\t\t\tpostgres,\n\t\t\t);\n\t\t\tawait postgres.destroy();\n\t\t\treturn;\n\t\t}\n\n\t\tif (testWith === \"mysql\") {\n\t\t\tconst mysql = await getMysql();\n\t\t\tawait sql`SET FOREIGN_KEY_CHECKS = 0;`.execute(mysql);\n\t\t\tconst tables = await mysql.introspection.getTables();\n\t\t\tfor (const table of tables) {\n\t\t\t\t// @ts-expect-error\n\t\t\t\tawait mysql.deleteFrom(table.name).execute();\n\t\t\t}\n\t\t\tawait sql`SET FOREIGN_KEY_CHECKS = 1;`.execute(mysql);\n\t\t\treturn;\n\t\t}\n\t\tif (testWith === \"sqlite\") {\n\t\t\tconst sqlite = await getSqlite();\n\t\t\tsqlite.close();\n\t\t\treturn;\n\t\t}\n\t};\n\tcleanupSet.add(cleanup);\n\n\tconst customFetchImpl = async (\n\t\turl: string | URL | Request,\n\t\tinit?: RequestInit | undefined,\n\t) => {\n\t\tconst headers = init?.headers || {};\n\t\tconst storageHeaders = currentUserContextStorage.getStore()?.headers;\n\t\treturn auth.handler(\n\t\t\tnew Request(\n\t\t\t\turl,\n\t\t\t\tinit\n\t\t\t\t\t? {\n\t\t\t\t\t\t\t...init,\n\t\t\t\t\t\t\theaders: new Headers({\n\t\t\t\t\t\t\t\t...(storageHeaders\n\t\t\t\t\t\t\t\t\t? Object.fromEntries(storageHeaders.entries())\n\t\t\t\t\t\t\t\t\t: {}),\n\t\t\t\t\t\t\t\t...(headers instanceof Headers\n\t\t\t\t\t\t\t\t\t? Object.fromEntries(headers.entries())\n\t\t\t\t\t\t\t\t\t: typeof headers === \"object\"\n\t\t\t\t\t\t\t\t\t\t? headers\n\t\t\t\t\t\t\t\t\t\t: {}),\n\t\t\t\t\t\t\t}),\n\t\t\t\t\t\t}\n\t\t\t\t\t: {\n\t\t\t\t\t\t\theaders,\n\t\t\t\t\t\t},\n\t\t\t),\n\t\t);\n\t};\n\n\tconst client = createAuthClient({\n\t\t...(config?.clientOptions as C extends undefined ? {} : C),\n\t\tbaseURL: getBaseURL(\n\t\t\toptions?.baseURL || \"http://localhost:\" + (config?.port || 3000),\n\t\t\toptions?.basePath || \"/api/auth\",\n\t\t),\n\t\tfetchOptions: {\n\t\t\tcustomFetchImpl,\n\t\t},\n\t});\n\n\tasync function signInWithTestUser() {\n\t\tif (config?.disableTestUser) {\n\t\t\tthrow new Error(\"Test user is disabled\");\n\t\t}\n\t\tconst headers = new Headers();\n\t\tconst setCookie = (name: string, value: string) => {\n\t\t\tconst current = headers.get(\"cookie\");\n\t\t\theaders.set(\"cookie\", `${current || \"\"}; ${name}=${value}`);\n\t\t};\n\t\t//@ts-expect-error\n\t\tconst { data } = await client.signIn.email({\n\t\t\temail: testUser.email,\n\t\t\tpassword: testUser.password,\n\t\t\tfetchOptions: {\n\t\t\t\t//@ts-expect-error\n\t\t\t\tonSuccess(context) {\n\t\t\t\t\tconst header = context.response.headers.get(\"set-cookie\");\n\t\t\t\t\tconst cookies = parseSetCookieHeader(header || \"\");\n\t\t\t\t\tconst signedCookie = cookies.get(\"better-auth.session_token\")?.value;\n\t\t\t\t\theaders.set(\"cookie\", `better-auth.session_token=${signedCookie}`);\n\t\t\t\t},\n\t\t\t},\n\t\t});\n\t\treturn {\n\t\t\tsession: data.session as Session,\n\t\t\tuser: data.user as User,\n\t\t\theaders,\n\t\t\tsetCookie,\n\t\t\trunWithUser: async (fn: (headers: Headers) => Promise<void>) => {\n\t\t\t\treturn currentUserContextStorage.run({ headers }, async () => {\n\t\t\t\t\tawait fn(headers);\n\t\t\t\t});\n\t\t\t},\n\t\t};\n\t}\n\tasync function signInWithUser(email: string, password: string) {\n\t\tconst headers = new Headers();\n\t\t//@ts-expect-error\n\t\tconst { data } = await client.signIn.email({\n\t\t\temail,\n\t\t\tpassword,\n\t\t\tfetchOptions: {\n\t\t\t\t//@ts-expect-error\n\t\t\t\tonSuccess(context) {\n\t\t\t\t\tconst header = context.response.headers.get(\"set-cookie\");\n\t\t\t\t\tconst cookies = parseSetCookieHeader(header || \"\");\n\t\t\t\t\tconst signedCookie = cookies.get(\"better-auth.session_token\")?.value;\n\t\t\t\t\theaders.set(\"cookie\", `better-auth.session_token=${signedCookie}`);\n\t\t\t\t},\n\t\t\t},\n\t\t});\n\t\treturn {\n\t\t\tres: data as {\n\t\t\t\tuser: User;\n\t\t\t\tsession: Session;\n\t\t\t},\n\t\t\theaders,\n\t\t};\n\t}\n\n\tfunction sessionSetter(headers: Headers) {\n\t\treturn (context: SuccessContext) => {\n\t\t\tconst header = context.response.headers.get(\"set-cookie\");\n\t\t\tif (header) {\n\t\t\t\tconst cookies = parseSetCookieHeader(header || \"\");\n\t\t\t\tconst signedCookie = cookies.get(\"better-auth.session_token\")?.value;\n\t\t\t\theaders.set(\"cookie\", `better-auth.session_token=${signedCookie}`);\n\t\t\t}\n\t\t};\n\t}\n\n\treturn {\n\t\tauth,\n\t\tclient,\n\t\ttestUser,\n\t\tsignInWithTestUser,\n\t\tsignInWithUser,\n\t\tcookieSetter: setCookieToHeader,\n\t\tcustomFetchImpl,\n\t\tsessionSetter,\n\t\tdb: await getAdapter(auth.options),\n\t\trunWithUser: async (\n\t\t\temail: string,\n\t\t\tpassword: string,\n\t\t\tfn: (headers: Headers) => Awaitable<void>,\n\t\t) => {\n\t\t\tconst { headers } = await signInWithUser(email, password);\n\t\t\treturn currentUserContextStorage.run({ headers }, async () => {\n\t\t\t\tawait fn(headers);\n\t\t\t});\n\t\t},\n\t};\n}\n"],"mappings":"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"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { DBAdapter, DBAdapter as DBAdapter$1, DBAdapterInstance, DBAdapterInstance as DBAdapterInstance$1, DBAdapterSchemaCreation, DBAdapterSchemaCreation as DBAdapterSchemaCreation$1, DBTransactionAdapter, DBTransactionAdapter as DBTransactionAdapter$1, JoinConfig, JoinOption, Where as Where$1 } from "@better-auth/core/db/adapter";
|
|
2
|
+
|
|
3
|
+
//#region src/types/adapter.d.ts
|
|
4
|
+
/**
|
|
5
|
+
* Adapter Interface
|
|
6
|
+
*
|
|
7
|
+
* @deprecated Use `DBAdapter` from `@better-auth/core/db/adapter` instead.
|
|
8
|
+
*/
|
|
9
|
+
type Adapter = DBAdapter;
|
|
10
|
+
/**
|
|
11
|
+
* @deprecated Use `DBTransactionAdapter` from `@better-auth/core/db/adapter` instead.
|
|
12
|
+
*/
|
|
13
|
+
type TransactionAdapter = DBTransactionAdapter;
|
|
14
|
+
/**
|
|
15
|
+
* @deprecated Use `DBAdapterSchemaCreation` from `@better-auth/core/db/adapter` instead.
|
|
16
|
+
*/
|
|
17
|
+
type AdapterSchemaCreation = DBAdapterSchemaCreation;
|
|
18
|
+
/**
|
|
19
|
+
* @deprecated Use `DBAdapterInstance` from `@better-auth/core/db/adapter` instead.
|
|
20
|
+
*/
|
|
21
|
+
type AdapterInstance = DBAdapterInstance;
|
|
22
|
+
//#endregion
|
|
23
|
+
export { Adapter, AdapterInstance, AdapterSchemaCreation, type DBAdapter$1 as DBAdapter, type DBAdapterInstance$1 as DBAdapterInstance, type DBAdapterSchemaCreation$1 as DBAdapterSchemaCreation, type DBTransactionAdapter$1 as DBTransactionAdapter, type JoinConfig, type JoinOption, TransactionAdapter, type Where$1 as Where };
|
|
24
|
+
//# sourceMappingURL=adapter.d.mts.map
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { PrettifyDeep, UnionToIntersection } from "./helper.mjs";
|
|
2
|
+
import { Endpoint } from "better-call";
|
|
3
|
+
|
|
4
|
+
//#region src/types/api.d.ts
|
|
5
|
+
type FilteredAPI<API> = Omit<API, API extends { [key in infer K]: Endpoint } ? K extends string ? K extends "getSession" ? never : API[K]["options"]["metadata"] extends {
|
|
6
|
+
isAction: false;
|
|
7
|
+
} | {
|
|
8
|
+
scope: "http";
|
|
9
|
+
} ? K : never : never : never>;
|
|
10
|
+
/**
|
|
11
|
+
* Default getSession signature used as a fallback when type inference fails.
|
|
12
|
+
* This ensures getSession is always available on auth.api even with complex
|
|
13
|
+
* plugin configurations that cause TypeScript inference to fall back to `any`.
|
|
14
|
+
*/
|
|
15
|
+
type DefaultSessionAPI = {
|
|
16
|
+
getSession: <R extends boolean = false, H extends boolean = false>(context: {
|
|
17
|
+
headers: Headers;
|
|
18
|
+
query?: {
|
|
19
|
+
disableCookieCache?: boolean;
|
|
20
|
+
disableRefresh?: boolean;
|
|
21
|
+
} | undefined;
|
|
22
|
+
asResponse?: R | undefined;
|
|
23
|
+
returnHeaders?: H | undefined;
|
|
24
|
+
}) => false extends R ? H extends true ? Promise<{
|
|
25
|
+
headers: Headers;
|
|
26
|
+
response: {
|
|
27
|
+
session: any;
|
|
28
|
+
user: any;
|
|
29
|
+
} | null;
|
|
30
|
+
}> : Promise<{
|
|
31
|
+
session: any;
|
|
32
|
+
user: any;
|
|
33
|
+
} | null> : Promise<Response>;
|
|
34
|
+
};
|
|
35
|
+
type InferSessionAPI<API> = API extends {
|
|
36
|
+
[key: string]: infer E;
|
|
37
|
+
} ? UnionToIntersection<E extends Endpoint ? E["path"] extends "/get-session" ? {
|
|
38
|
+
getSession: <R extends boolean = false, H extends boolean = false>(context: {
|
|
39
|
+
headers: Headers;
|
|
40
|
+
query?: {
|
|
41
|
+
disableCookieCache?: boolean;
|
|
42
|
+
disableRefresh?: boolean;
|
|
43
|
+
} | undefined;
|
|
44
|
+
asResponse?: R | undefined;
|
|
45
|
+
returnHeaders?: H | undefined;
|
|
46
|
+
}) => false extends R ? H extends true ? Promise<{
|
|
47
|
+
headers: Headers;
|
|
48
|
+
response: PrettifyDeep<Awaited<ReturnType<E>>> | null;
|
|
49
|
+
}> : Promise<PrettifyDeep<Awaited<ReturnType<E>>> | null> : Promise<Response>;
|
|
50
|
+
} : never : never> : never;
|
|
51
|
+
/**
|
|
52
|
+
* Combines InferSessionAPI with a DefaultSessionAPI fallback.
|
|
53
|
+
* When InferSessionAPI produces a valid getSession type, it takes precedence.
|
|
54
|
+
* When inference fails (API becomes `any`), DefaultSessionAPI provides the fallback.
|
|
55
|
+
*/
|
|
56
|
+
type SessionAPIWithFallback<API> = InferSessionAPI<API> extends {
|
|
57
|
+
getSession: any;
|
|
58
|
+
} ? InferSessionAPI<API> : DefaultSessionAPI;
|
|
59
|
+
type InferAPI<API> = SessionAPIWithFallback<API> & FilteredAPI<API>;
|
|
60
|
+
//#endregion
|
|
61
|
+
export { DefaultSessionAPI, FilteredAPI, InferAPI, InferSessionAPI };
|
|
62
|
+
//# sourceMappingURL=api.d.mts.map
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { PrettifyDeep } from "./helper.mjs";
|
|
2
|
+
import { InferAPI } from "./api.mjs";
|
|
3
|
+
import { InferPluginTypes, InferSession, InferUser } from "./models.mjs";
|
|
4
|
+
import { InferPluginErrorCodes } from "./plugins.mjs";
|
|
5
|
+
import { router } from "../api/index.mjs";
|
|
6
|
+
import { AuthContext, BetterAuthOptions } from "@better-auth/core";
|
|
7
|
+
import { BASE_ERROR_CODES } from "@better-auth/core/error";
|
|
8
|
+
|
|
9
|
+
//#region src/types/auth.d.ts
|
|
10
|
+
type Auth<Options extends BetterAuthOptions = BetterAuthOptions> = {
|
|
11
|
+
handler: (request: Request) => Promise<Response>;
|
|
12
|
+
api: InferAPI<ReturnType<typeof router<Options>>["endpoints"]>;
|
|
13
|
+
options: Options;
|
|
14
|
+
$ERROR_CODES: InferPluginErrorCodes<Options> & typeof BASE_ERROR_CODES;
|
|
15
|
+
$context: Promise<AuthContext<Options>>;
|
|
16
|
+
/**
|
|
17
|
+
* Share types
|
|
18
|
+
*/
|
|
19
|
+
$Infer: InferPluginTypes<Options> extends {
|
|
20
|
+
Session: any;
|
|
21
|
+
} ? InferPluginTypes<Options> : {
|
|
22
|
+
Session: {
|
|
23
|
+
session: PrettifyDeep<InferSession<Options>>;
|
|
24
|
+
user: PrettifyDeep<InferUser<Options>>;
|
|
25
|
+
};
|
|
26
|
+
} & InferPluginTypes<Options>;
|
|
27
|
+
};
|
|
28
|
+
//#endregion
|
|
29
|
+
export { Auth };
|
|
30
|
+
//# sourceMappingURL=auth.d.mts.map
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { Primitive } from "@better-auth/core";
|
|
2
|
+
|
|
3
|
+
//#region src/types/helper.d.ts
|
|
4
|
+
type LiteralNumber = 0 | (number & Record<never, never>);
|
|
5
|
+
type OmitId<T extends {
|
|
6
|
+
id: unknown;
|
|
7
|
+
}> = Omit<T, "id">;
|
|
8
|
+
type Prettify<T> = Omit<T, never>;
|
|
9
|
+
type PreserveJSDoc<T> = { [K in keyof T]: T[K] } & {};
|
|
10
|
+
type PrettifyDeep<T> = { [K in keyof T]: T[K] extends ((...args: any[]) => any) ? T[K] : T[K] extends object ? T[K] extends Array<any> ? T[K] : T[K] extends Date ? T[K] : PrettifyDeep<T[K]> : T[K] } & {};
|
|
11
|
+
type LiteralUnion<LiteralType, BaseType extends Primitive> = LiteralType | (BaseType & Record<never, never>);
|
|
12
|
+
type UnionToIntersection<U> = (U extends any ? (k: U) => void : never) extends ((k: infer I) => void) ? I : never;
|
|
13
|
+
type RequiredKeysOf<BaseType extends object> = Exclude<{ [Key in keyof BaseType]: BaseType extends Record<Key, BaseType[Key]> ? Key : never }[keyof BaseType], undefined>;
|
|
14
|
+
type HasRequiredKeys<BaseType extends object> = RequiredKeysOf<BaseType> extends never ? false : true;
|
|
15
|
+
type WithoutEmpty<T> = T extends T ? ({} extends T ? never : T) : never;
|
|
16
|
+
type StripEmptyObjects<T> = T extends { [K in keyof T]: never } ? never : T extends object ? { [K in keyof T as T[K] extends never ? never : K]: T[K] } : T;
|
|
17
|
+
type DeepPartial<T> = T extends Function ? T : T extends object ? { [K in keyof T]?: DeepPartial<T[K]> } : T;
|
|
18
|
+
type Expand<T> = T extends infer O ? { [K in keyof O]: O[K] } : never;
|
|
19
|
+
//#endregion
|
|
20
|
+
export { DeepPartial, Expand, HasRequiredKeys, LiteralNumber, LiteralUnion, OmitId, PreserveJSDoc, Prettify, PrettifyDeep, RequiredKeysOf, StripEmptyObjects, UnionToIntersection, WithoutEmpty };
|
|
21
|
+
//# sourceMappingURL=helper.d.mts.map
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { __exportAll, __reExport } from "../_virtual/rolldown_runtime.mjs";
|
|
2
|
+
import { DeepPartial, Expand, HasRequiredKeys, LiteralNumber, LiteralUnion, OmitId, PreserveJSDoc, Prettify, PrettifyDeep, RequiredKeysOf, StripEmptyObjects, UnionToIntersection, WithoutEmpty } from "./helper.mjs";
|
|
3
|
+
import { AtomListener, BetterAuthClientOptions, BetterAuthClientPlugin, ClientAtomListener, ClientOptions, ClientStore, InferActions, InferAdditionalFromClient, InferClientAPI, InferErrorCodes, InferPluginsFromClient, InferSessionFromClient, InferUserFromClient, IsSignal, SessionQueryParams, Store } from "../client/types.mjs";
|
|
4
|
+
import { Adapter, AdapterInstance, AdapterSchemaCreation, DBAdapter, DBAdapterInstance, DBAdapterSchemaCreation, DBTransactionAdapter, JoinConfig, JoinOption, TransactionAdapter, Where } from "./adapter.mjs";
|
|
5
|
+
import { DefaultSessionAPI, FilteredAPI, InferAPI, InferSessionAPI } from "./api.mjs";
|
|
6
|
+
import { Account, AdditionalSessionFieldsInput, AdditionalSessionFieldsOutput, AdditionalUserFieldsInput, AdditionalUserFieldsOutput, InferPluginTypes, InferSession, InferUser, RateLimit, Session, User, Verification } from "./models.mjs";
|
|
7
|
+
import { InferOptionSchema, InferPluginErrorCodes, InferPluginIDs } from "./plugins.mjs";
|
|
8
|
+
import { Auth } from "./auth.mjs";
|
|
9
|
+
import { BetterAuthAdvancedOptions, BetterAuthCookies, BetterAuthOptions, BetterAuthPlugin, BetterAuthRateLimitOptions, StoreIdentifierOption } from "@better-auth/core";
|
|
10
|
+
export * from "@better-auth/core/social-providers";
|
|
11
|
+
export { Account, Adapter, AdapterInstance, AdapterSchemaCreation, AdditionalSessionFieldsInput, AdditionalSessionFieldsOutput, AdditionalUserFieldsInput, AdditionalUserFieldsOutput, AtomListener, Auth, type BetterAuthAdvancedOptions, BetterAuthClientOptions, BetterAuthClientPlugin, type BetterAuthCookies, type BetterAuthOptions, type BetterAuthPlugin, type BetterAuthRateLimitOptions, ClientAtomListener, ClientOptions, ClientStore, DBAdapter, DBAdapterInstance, DBAdapterSchemaCreation, DBTransactionAdapter, DeepPartial, DefaultSessionAPI, Expand, FilteredAPI, HasRequiredKeys, InferAPI, InferActions, InferAdditionalFromClient, InferClientAPI, InferErrorCodes, InferOptionSchema, InferPluginErrorCodes, InferPluginIDs, InferPluginTypes, InferPluginsFromClient, InferSession, InferSessionAPI, InferSessionFromClient, InferUser, InferUserFromClient, IsSignal, JoinConfig, JoinOption, LiteralNumber, LiteralUnion, OmitId, PreserveJSDoc, Prettify, PrettifyDeep, RateLimit, RequiredKeysOf, Session, SessionQueryParams, Store, type StoreIdentifierOption, StripEmptyObjects, TransactionAdapter, UnionToIntersection, User, Verification, Where, WithoutEmpty };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { };
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { InferFieldsFromOptions, InferFieldsFromPlugins } from "../db/field.mjs";
|
|
2
|
+
import "../db/index.mjs";
|
|
3
|
+
import { StripEmptyObjects, UnionToIntersection } from "./helper.mjs";
|
|
4
|
+
import { BetterAuthOptions, BetterAuthPlugin } from "@better-auth/core";
|
|
5
|
+
import { Account, RateLimit, Session, Session as Session$1, User, User as User$1, Verification } from "@better-auth/core/db";
|
|
6
|
+
|
|
7
|
+
//#region src/types/models.d.ts
|
|
8
|
+
type AdditionalUserFieldsInput<Options extends BetterAuthOptions> = InferFieldsFromPlugins<Options, "user", "input"> & InferFieldsFromOptions<Options, "user", "input">;
|
|
9
|
+
type AdditionalUserFieldsOutput<Options extends BetterAuthOptions> = InferFieldsFromPlugins<Options, "user", "output"> & InferFieldsFromOptions<Options, "user", "output">;
|
|
10
|
+
type AdditionalSessionFieldsInput<Options extends BetterAuthOptions> = InferFieldsFromPlugins<Options, "session", "input"> & InferFieldsFromOptions<Options, "session", "input">;
|
|
11
|
+
type AdditionalSessionFieldsOutput<Options extends BetterAuthOptions> = InferFieldsFromPlugins<Options, "session", "output"> & InferFieldsFromOptions<Options, "session", "output">;
|
|
12
|
+
type InferUser<O extends BetterAuthOptions> = UnionToIntersection<StripEmptyObjects<User & AdditionalUserFieldsOutput<O>>>;
|
|
13
|
+
type InferSession<O extends BetterAuthOptions> = UnionToIntersection<StripEmptyObjects<Session & AdditionalSessionFieldsOutput<O>>>;
|
|
14
|
+
type InferPluginTypes<O extends BetterAuthOptions> = O["plugins"] extends Array<infer P> ? UnionToIntersection<P extends BetterAuthPlugin ? P["$Infer"] extends Record<string, any> ? P["$Infer"] : {} : {}> : {};
|
|
15
|
+
//#endregion
|
|
16
|
+
export { type Account, AdditionalSessionFieldsInput, AdditionalSessionFieldsOutput, AdditionalUserFieldsInput, AdditionalUserFieldsOutput, InferPluginTypes, InferSession, InferUser, type RateLimit, type Session$1 as Session, type User$1 as User, type Verification };
|
|
17
|
+
//# sourceMappingURL=models.d.mts.map
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { UnionToIntersection } from "./helper.mjs";
|
|
2
|
+
import { BetterAuthOptions, BetterAuthPlugin } from "@better-auth/core";
|
|
3
|
+
import { BetterAuthPluginDBSchema } from "@better-auth/core/db";
|
|
4
|
+
|
|
5
|
+
//#region src/types/plugins.d.ts
|
|
6
|
+
type InferOptionSchema<S extends BetterAuthPluginDBSchema> = S extends Record<string, {
|
|
7
|
+
fields: infer Fields;
|
|
8
|
+
}> ? { [K in keyof S]?: {
|
|
9
|
+
modelName?: string | undefined;
|
|
10
|
+
fields?: { [P in keyof Fields]?: string } | undefined;
|
|
11
|
+
} } : never;
|
|
12
|
+
type InferPluginErrorCodes<O extends BetterAuthOptions> = O["plugins"] extends Array<infer P> ? UnionToIntersection<P extends BetterAuthPlugin ? P["$ERROR_CODES"] extends Record<string, any> ? P["$ERROR_CODES"] : {} : {}> : {};
|
|
13
|
+
type InferPluginIDs<O extends BetterAuthOptions> = O["plugins"] extends Array<infer P> ? UnionToIntersection<P extends BetterAuthPlugin ? P["id"] : never> : never;
|
|
14
|
+
//#endregion
|
|
15
|
+
export { InferOptionSchema, InferPluginErrorCodes, InferPluginIDs };
|
|
16
|
+
//# sourceMappingURL=plugins.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"boolean.mjs","names":[],"sources":["../../src/utils/boolean.ts"],"sourcesContent":["export function toBoolean(value: any): boolean {\n\treturn value === \"true\" || value === true;\n}\n"],"mappings":";AAAA,SAAgB,UAAU,OAAqB;AAC9C,QAAO,UAAU,UAAU,UAAU"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"constants.mjs","names":[],"sources":["../../src/utils/constants.ts"],"sourcesContent":["export const DEFAULT_SECRET = \"better-auth-secret-12345678901234567890\";\n"],"mappings":";AAAA,MAAa,iBAAiB"}
|