@masheev/better-auth 0.0.0-stage → 1.7.5
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 +31 -2
- package/TYPE-PATCH-NOTICE.md +9 -0
- package/TYPE-PATCH-PROVENANCE.json +267 -0
- package/dist/_virtual/_rolldown/runtime.mjs +27 -0
- package/dist/adapters/drizzle-adapter/index.d.mts +1 -0
- package/dist/adapters/drizzle-adapter/index.mjs +2 -0
- package/dist/adapters/index.d.mts +26 -0
- package/dist/adapters/index.mjs +9 -0
- package/dist/adapters/kysely-adapter/index.d.mts +1 -0
- package/dist/adapters/kysely-adapter/index.mjs +2 -0
- package/dist/adapters/memory-adapter/index.d.mts +1 -0
- package/dist/adapters/memory-adapter/index.mjs +2 -0
- package/dist/adapters/mongodb-adapter/index.d.mts +1 -0
- package/dist/adapters/mongodb-adapter/index.mjs +2 -0
- package/dist/adapters/prisma-adapter/index.d.mts +1 -0
- package/dist/adapters/prisma-adapter/index.mjs +2 -0
- package/dist/api/dispatch.d.mts +34 -0
- package/dist/api/dispatch.mjs +275 -0
- package/dist/api/index.d.mts +4053 -0
- package/dist/api/index.mjs +220 -0
- package/dist/api/middlewares/authorization.d.mts +69 -0
- package/dist/api/middlewares/authorization.mjs +78 -0
- package/dist/api/middlewares/index.d.mts +2 -0
- package/dist/api/middlewares/origin-check.d.mts +17 -0
- package/dist/api/middlewares/origin-check.mjs +155 -0
- package/dist/api/rate-limiter/index.mjs +318 -0
- package/dist/api/routes/account.d.mts +413 -0
- package/dist/api/routes/account.mjs +619 -0
- package/dist/api/routes/callback.d.mts +32 -0
- package/dist/api/routes/callback.mjs +261 -0
- package/dist/api/routes/email-verification.d.mts +160 -0
- package/dist/api/routes/email-verification.mjs +324 -0
- package/dist/api/routes/error.d.mts +27 -0
- package/dist/api/routes/error.mjs +387 -0
- package/dist/api/routes/index.d.mts +12 -0
- package/dist/api/routes/ok.d.mts +35 -0
- package/dist/api/routes/ok.mjs +27 -0
- package/dist/api/routes/password.d.mts +182 -0
- package/dist/api/routes/password.mjs +206 -0
- package/dist/api/routes/session.d.mts +450 -0
- package/dist/api/routes/session.mjs +481 -0
- package/dist/api/routes/sign-in.d.mts +186 -0
- package/dist/api/routes/sign-in.mjs +368 -0
- package/dist/api/routes/sign-out.d.mts +51 -0
- package/dist/api/routes/sign-out.mjs +96 -0
- package/dist/api/routes/sign-up.d.mts +159 -0
- package/dist/api/routes/sign-up.mjs +275 -0
- package/dist/api/routes/update-session.d.mts +74 -0
- package/dist/api/routes/update-session.mjs +57 -0
- package/dist/api/routes/update-user.d.mts +428 -0
- package/dist/api/routes/update-user.mjs +522 -0
- package/dist/api/state/oauth.d.mts +53 -0
- package/dist/api/state/oauth.mjs +38 -0
- package/dist/api/state/should-session-refresh.d.mts +12 -0
- package/dist/api/state/should-session-refresh.mjs +13 -0
- package/dist/api/to-auth-endpoints.mjs +60 -0
- package/dist/auth/base.mjs +66 -0
- package/dist/auth/full.d.mts +28 -0
- package/dist/auth/full.mjs +29 -0
- package/dist/auth/minimal.d.mts +10 -0
- package/dist/auth/minimal.mjs +11 -0
- package/dist/auth/trusted-origins.mjs +106 -0
- package/dist/client/broadcast-channel.d.mts +19 -0
- package/dist/client/broadcast-channel.mjs +44 -0
- package/dist/client/config.d.mts +90 -0
- package/dist/client/config.mjs +113 -0
- package/dist/client/equality.d.mts +19 -0
- package/dist/client/equality.mjs +42 -0
- package/dist/client/fetch-plugins.mjs +17 -0
- package/dist/client/focus-manager.d.mts +10 -0
- package/dist/client/focus-manager.mjs +30 -0
- package/dist/client/index.d.mts +35 -0
- package/dist/client/index.mjs +22 -0
- package/dist/client/lynx/index.d.mts +43 -0
- package/dist/client/lynx/index.mjs +22 -0
- package/dist/client/lynx/lynx-store.d.mts +46 -0
- package/dist/client/lynx/lynx-store.mjs +44 -0
- package/dist/client/online-manager.d.mts +11 -0
- package/dist/client/online-manager.mjs +33 -0
- package/dist/client/parser.d.mts +10 -0
- package/dist/client/parser.mjs +70 -0
- package/dist/client/path-to-object.d.mts +113 -0
- package/dist/client/plugins/index.d.mts +44 -0
- package/dist/client/plugins/index.mjs +30 -0
- package/dist/client/plugins/infer-plugin.d.mts +16 -0
- package/dist/client/plugins/infer-plugin.mjs +11 -0
- package/dist/client/proxy.mjs +78 -0
- package/dist/client/query.d.mts +23 -0
- package/dist/client/query.mjs +124 -0
- package/dist/client/react/index.d.mts +44 -0
- package/dist/client/react/index.mjs +22 -0
- package/dist/client/react/react-store.d.mts +46 -0
- package/dist/client/react/react-store.mjs +44 -0
- package/dist/client/session-atom.d.mts +11 -0
- package/dist/client/session-atom.mjs +178 -0
- package/dist/client/session-refresh.d.mts +20 -0
- package/dist/client/session-refresh.mjs +131 -0
- package/dist/client/solid/index.d.mts +44 -0
- package/dist/client/solid/index.mjs +22 -0
- package/dist/client/solid/solid-store.mjs +21 -0
- package/dist/client/svelte/index.d.mts +44 -0
- package/dist/client/svelte/index.mjs +18 -0
- package/dist/client/types.d.mts +51 -0
- package/dist/client/vanilla.d.mts +42 -0
- package/dist/client/vanilla.mjs +18 -0
- package/dist/client/vue/index.d.mts +67 -0
- package/dist/client/vue/index.mjs +54 -0
- package/dist/client/vue/vue-store.mjs +23 -0
- package/dist/context/create-context.mjs +235 -0
- package/dist/context/helpers.mjs +158 -0
- package/dist/context/init-minimal.mjs +17 -0
- package/dist/context/init.mjs +19 -0
- package/dist/context/secret-utils.mjs +53 -0
- package/dist/context/store-capabilities.mjs +12 -0
- package/dist/cookies/cache.mjs +33 -0
- package/dist/cookies/cookie-utils.d.mts +72 -0
- package/dist/cookies/cookie-utils.mjs +203 -0
- package/dist/cookies/index.d.mts +124 -0
- package/dist/cookies/index.mjs +350 -0
- package/dist/cookies/jwt.mjs +44 -0
- package/dist/cookies/session-store.d.mts +32 -0
- package/dist/cookies/session-store.mjs +183 -0
- package/dist/crypto/buffer.d.mts +7 -0
- package/dist/crypto/buffer.mjs +16 -0
- package/dist/crypto/index.d.mts +32 -0
- package/dist/crypto/index.mjs +69 -0
- package/dist/crypto/jwt.d.mts +9 -0
- package/dist/crypto/jwt.mjs +141 -0
- package/dist/crypto/password.d.mts +13 -0
- package/dist/crypto/password.mjs +14 -0
- package/dist/crypto/random.d.mts +4 -0
- package/dist/crypto/random.mjs +5 -0
- package/dist/db/adapter-base.d.mts +7 -0
- package/dist/db/adapter-base.mjs +25 -0
- package/dist/db/adapter-kysely.d.mts +7 -0
- package/dist/db/adapter-kysely.mjs +17 -0
- package/dist/db/field-converter.d.mts +7 -0
- package/dist/db/field-converter.mjs +19 -0
- package/dist/db/field.d.mts +41 -0
- package/dist/db/get-migration.d.mts +56 -0
- package/dist/db/get-migration.mjs +685 -0
- package/dist/db/get-schema.d.mts +13 -0
- package/dist/db/get-schema.mjs +39 -0
- package/dist/db/index.d.mts +10 -0
- package/dist/db/index.mjs +35 -0
- package/dist/db/internal-adapter.d.mts +14 -0
- package/dist/db/internal-adapter.mjs +951 -0
- package/dist/db/revoke-unproven-account-access.d.mts +21 -0
- package/dist/db/revoke-unproven-account-access.mjs +58 -0
- package/dist/db/schema.d.mts +62 -0
- package/dist/db/schema.mjs +161 -0
- package/dist/db/to-zod.d.mts +35 -0
- package/dist/db/to-zod.mjs +23 -0
- package/dist/db/verification-token-storage.mjs +25 -0
- package/dist/db/with-hooks.d.mts +37 -0
- package/dist/db/with-hooks.mjs +255 -0
- package/dist/index.d.mts +30 -0
- package/dist/index.mjs +17 -0
- package/dist/integrations/cookie-plugin-guard.mjs +18 -0
- package/dist/integrations/next-js.d.mts +29 -0
- package/dist/integrations/next-js.mjs +105 -0
- package/dist/integrations/node.d.mts +11 -0
- package/dist/integrations/node.mjs +13 -0
- package/dist/integrations/solid-start.d.mts +22 -0
- package/dist/integrations/solid-start.mjs +15 -0
- package/dist/integrations/svelte-kit.d.mts +38 -0
- package/dist/integrations/svelte-kit.mjs +57 -0
- package/dist/integrations/tanstack-start-solid.d.mts +33 -0
- package/dist/integrations/tanstack-start-solid.mjs +57 -0
- package/dist/integrations/tanstack-start.d.mts +33 -0
- package/dist/integrations/tanstack-start.mjs +57 -0
- package/dist/oauth2/account-key.mjs +43 -0
- package/dist/oauth2/errors.mjs +49 -0
- package/dist/oauth2/index.d.mts +5 -0
- package/dist/oauth2/index.mjs +5 -0
- package/dist/oauth2/link-account.d.mts +96 -0
- package/dist/oauth2/link-account.mjs +329 -0
- package/dist/oauth2/state.d.mts +54 -0
- package/dist/oauth2/state.mjs +67 -0
- package/dist/oauth2/utils.d.mts +11 -0
- package/dist/oauth2/utils.mjs +33 -0
- package/dist/package.mjs +4 -0
- package/dist/plugins/access/access.d.mts +17 -0
- package/dist/plugins/access/access.mjs +78 -0
- package/dist/plugins/access/index.d.mts +3 -0
- package/dist/plugins/access/index.mjs +2 -0
- package/dist/plugins/access/types.d.mts +24 -0
- package/dist/plugins/additional-fields/client.d.mts +100 -0
- package/dist/plugins/additional-fields/client.mjs +11 -0
- package/dist/plugins/admin/access/index.d.mts +2 -0
- package/dist/plugins/admin/access/index.mjs +2 -0
- package/dist/plugins/admin/access/statement.d.mts +51 -0
- package/dist/plugins/admin/access/statement.mjs +52 -0
- package/dist/plugins/admin/admin.d.mts +911 -0
- package/dist/plugins/admin/admin.mjs +89 -0
- package/dist/plugins/admin/client.d.mts +81 -0
- package/dist/plugins/admin/client.mjs +39 -0
- package/dist/plugins/admin/error-codes.d.mts +30 -0
- package/dist/plugins/admin/error-codes.mjs +29 -0
- package/dist/plugins/admin/has-permission.mjs +12 -0
- package/dist/plugins/admin/index.d.mts +3 -0
- package/dist/plugins/admin/index.mjs +2 -0
- package/dist/plugins/admin/routes.mjs +919 -0
- package/dist/plugins/admin/schema.d.mts +40 -0
- package/dist/plugins/admin/schema.mjs +33 -0
- package/dist/plugins/admin/types.d.mts +88 -0
- package/dist/plugins/anonymous/client.d.mts +32 -0
- package/dist/plugins/anonymous/client.mjs +21 -0
- package/dist/plugins/anonymous/error-codes.d.mts +15 -0
- package/dist/plugins/anonymous/error-codes.mjs +14 -0
- package/dist/plugins/anonymous/index.d.mts +175 -0
- package/dist/plugins/anonymous/index.mjs +219 -0
- package/dist/plugins/anonymous/schema.d.mts +15 -0
- package/dist/plugins/anonymous/schema.mjs +9 -0
- package/dist/plugins/anonymous/types.d.mts +65 -0
- package/dist/plugins/bearer/index.d.mts +45 -0
- package/dist/plugins/bearer/index.mjs +74 -0
- package/dist/plugins/captcha/constants.d.mts +9 -0
- package/dist/plugins/captcha/constants.mjs +27 -0
- package/dist/plugins/captcha/error-codes.mjs +13 -0
- package/dist/plugins/captcha/index.d.mts +27 -0
- package/dist/plugins/captcha/index.mjs +79 -0
- package/dist/plugins/captcha/types.d.mts +52 -0
- package/dist/plugins/captcha/utils.mjs +9 -0
- package/dist/plugins/captcha/verify-handlers/captchafox.mjs +27 -0
- package/dist/plugins/captcha/verify-handlers/cloudflare-turnstile.mjs +47 -0
- package/dist/plugins/captcha/verify-handlers/google-recaptcha.mjs +32 -0
- package/dist/plugins/captcha/verify-handlers/h-captcha.mjs +27 -0
- package/dist/plugins/custom-session/client.d.mts +17 -0
- package/dist/plugins/custom-session/client.mjs +7 -0
- package/dist/plugins/custom-session/index.d.mts +73 -0
- package/dist/plugins/custom-session/index.mjs +65 -0
- package/dist/plugins/device-authorization/client.d.mts +17 -0
- package/dist/plugins/device-authorization/client.mjs +18 -0
- package/dist/plugins/device-authorization/error-codes.mjs +19 -0
- package/dist/plugins/device-authorization/index.d.mts +558 -0
- package/dist/plugins/device-authorization/index.mjs +87 -0
- package/dist/plugins/device-authorization/routes.d.mts +32 -0
- package/dist/plugins/device-authorization/routes.mjs +725 -0
- package/dist/plugins/device-authorization/schema.d.mts +18 -0
- package/dist/plugins/device-authorization/schema.mjs +63 -0
- package/dist/plugins/email-otp/client.d.mts +21 -0
- package/dist/plugins/email-otp/client.mjs +17 -0
- package/dist/plugins/email-otp/error-codes.d.mts +10 -0
- package/dist/plugins/email-otp/error-codes.mjs +9 -0
- package/dist/plugins/email-otp/index.d.mts +551 -0
- package/dist/plugins/email-otp/index.mjs +145 -0
- package/dist/plugins/email-otp/otp-token.mjs +55 -0
- package/dist/plugins/email-otp/routes.mjs +784 -0
- package/dist/plugins/email-otp/types.d.mts +109 -0
- package/dist/plugins/email-otp/utils.mjs +17 -0
- package/dist/plugins/generic-oauth/error-codes.mjs +8 -0
- package/dist/plugins/generic-oauth/index.d.mts +52 -0
- package/dist/plugins/generic-oauth/index.mjs +279 -0
- package/dist/plugins/generic-oauth/providers/auth0.d.mts +36 -0
- package/dist/plugins/generic-oauth/providers/auth0.mjs +49 -0
- package/dist/plugins/generic-oauth/providers/gumroad.d.mts +31 -0
- package/dist/plugins/generic-oauth/providers/gumroad.mjs +62 -0
- package/dist/plugins/generic-oauth/providers/hubspot.d.mts +36 -0
- package/dist/plugins/generic-oauth/providers/hubspot.mjs +62 -0
- package/dist/plugins/generic-oauth/providers/index.d.mts +10 -0
- package/dist/plugins/generic-oauth/providers/keycloak.d.mts +36 -0
- package/dist/plugins/generic-oauth/providers/keycloak.mjs +47 -0
- package/dist/plugins/generic-oauth/providers/line.d.mts +54 -0
- package/dist/plugins/generic-oauth/providers/line.mjs +93 -0
- package/dist/plugins/generic-oauth/providers/microsoft-entra-id.d.mts +39 -0
- package/dist/plugins/generic-oauth/providers/microsoft-entra-id.mjs +104 -0
- package/dist/plugins/generic-oauth/providers/okta.d.mts +36 -0
- package/dist/plugins/generic-oauth/providers/okta.mjs +47 -0
- package/dist/plugins/generic-oauth/providers/patreon.d.mts +29 -0
- package/dist/plugins/generic-oauth/providers/patreon.mjs +61 -0
- package/dist/plugins/generic-oauth/providers/slack.d.mts +29 -0
- package/dist/plugins/generic-oauth/providers/slack.mjs +63 -0
- package/dist/plugins/generic-oauth/providers/yandex.d.mts +29 -0
- package/dist/plugins/generic-oauth/providers/yandex.mjs +67 -0
- package/dist/plugins/generic-oauth/types.d.mts +268 -0
- package/dist/plugins/haveibeenpwned/index.d.mts +63 -0
- package/dist/plugins/haveibeenpwned/index.mjs +81 -0
- package/dist/plugins/index.d.mts +69 -0
- package/dist/plugins/index.mjs +49 -0
- package/dist/plugins/jwt/adapter.mjs +68 -0
- package/dist/plugins/jwt/client.d.mts +41 -0
- package/dist/plugins/jwt/client.mjs +19 -0
- package/dist/plugins/jwt/cookie-cache.mjs +77 -0
- package/dist/plugins/jwt/index.d.mts +246 -0
- package/dist/plugins/jwt/index.mjs +214 -0
- package/dist/plugins/jwt/schema.d.mts +33 -0
- package/dist/plugins/jwt/schema.mjs +29 -0
- package/dist/plugins/jwt/sign.d.mts +128 -0
- package/dist/plugins/jwt/sign.mjs +130 -0
- package/dist/plugins/jwt/types.d.mts +256 -0
- package/dist/plugins/jwt/utils.d.mts +41 -0
- package/dist/plugins/jwt/utils.mjs +64 -0
- package/dist/plugins/jwt/verify.d.mts +11 -0
- package/dist/plugins/jwt/verify.mjs +45 -0
- package/dist/plugins/last-login-method/client.d.mts +48 -0
- package/dist/plugins/last-login-method/client.mjs +48 -0
- package/dist/plugins/last-login-method/index.d.mts +127 -0
- package/dist/plugins/last-login-method/index.mjs +98 -0
- package/dist/plugins/magic-link/client.d.mts +10 -0
- package/dist/plugins/magic-link/client.mjs +11 -0
- package/dist/plugins/magic-link/index.d.mts +213 -0
- package/dist/plugins/magic-link/index.mjs +208 -0
- package/dist/plugins/magic-link/utils.mjs +9 -0
- package/dist/plugins/multi-session/client.d.mts +19 -0
- package/dist/plugins/multi-session/client.mjs +19 -0
- package/dist/plugins/multi-session/error-codes.d.mts +8 -0
- package/dist/plugins/multi-session/error-codes.mjs +5 -0
- package/dist/plugins/multi-session/index.d.mts +212 -0
- package/dist/plugins/multi-session/index.mjs +217 -0
- package/dist/plugins/oauth-popup/client.d.mts +82 -0
- package/dist/plugins/oauth-popup/client.mjs +203 -0
- package/dist/plugins/oauth-popup/constants.d.mts +11 -0
- package/dist/plugins/oauth-popup/constants.mjs +11 -0
- package/dist/plugins/oauth-popup/error-codes.d.mts +11 -0
- package/dist/plugins/oauth-popup/error-codes.mjs +10 -0
- package/dist/plugins/oauth-popup/index.d.mts +67 -0
- package/dist/plugins/oauth-popup/index.mjs +232 -0
- package/dist/plugins/oauth-popup/types.d.mts +30 -0
- package/dist/plugins/oauth-proxy/index.d.mts +130 -0
- package/dist/plugins/oauth-proxy/index.mjs +407 -0
- package/dist/plugins/oauth-proxy/utils.mjs +55 -0
- package/dist/plugins/one-tap/client.d.mts +174 -0
- package/dist/plugins/one-tap/client.mjs +208 -0
- package/dist/plugins/one-tap/index.d.mts +82 -0
- package/dist/plugins/one-tap/index.mjs +100 -0
- package/dist/plugins/one-time-token/client.d.mts +10 -0
- package/dist/plugins/one-time-token/client.mjs +11 -0
- package/dist/plugins/one-time-token/index.d.mts +132 -0
- package/dist/plugins/one-time-token/index.mjs +107 -0
- package/dist/plugins/one-time-token/utils.mjs +9 -0
- package/dist/plugins/open-api/generator.d.mts +126 -0
- package/dist/plugins/open-api/generator.mjs +557 -0
- package/dist/plugins/open-api/index.d.mts +97 -0
- package/dist/plugins/open-api/index.mjs +65 -0
- package/dist/plugins/open-api/logo.mjs +13 -0
- package/dist/plugins/organization/access/index.d.mts +2 -0
- package/dist/plugins/organization/access/index.mjs +2 -0
- package/dist/plugins/organization/access/statement.d.mts +113 -0
- package/dist/plugins/organization/access/statement.mjs +77 -0
- package/dist/plugins/organization/adapter.d.mts +815 -0
- package/dist/plugins/organization/adapter.mjs +813 -0
- package/dist/plugins/organization/call.mjs +15 -0
- package/dist/plugins/organization/client.d.mts +375 -0
- package/dist/plugins/organization/client.mjs +104 -0
- package/dist/plugins/organization/error-codes.d.mts +66 -0
- package/dist/plugins/organization/error-codes.mjs +65 -0
- package/dist/plugins/organization/has-permission.d.mts +17 -0
- package/dist/plugins/organization/has-permission.mjs +34 -0
- package/dist/plugins/organization/index.d.mts +6 -0
- package/dist/plugins/organization/index.mjs +4 -0
- package/dist/plugins/organization/organization.d.mts +420 -0
- package/dist/plugins/organization/organization.mjs +886 -0
- package/dist/plugins/organization/permission.d.mts +15 -0
- package/dist/plugins/organization/permission.mjs +14 -0
- package/dist/plugins/organization/routes/crud-access-control.d.mts +511 -0
- package/dist/plugins/organization/routes/crud-access-control.mjs +674 -0
- package/dist/plugins/organization/routes/crud-invites.d.mts +1154 -0
- package/dist/plugins/organization/routes/crud-invites.mjs +602 -0
- package/dist/plugins/organization/routes/crud-members.d.mts +1057 -0
- package/dist/plugins/organization/routes/crud-members.mjs +518 -0
- package/dist/plugins/organization/routes/crud-org.d.mts +918 -0
- package/dist/plugins/organization/routes/crud-org.mjs +455 -0
- package/dist/plugins/organization/routes/crud-team.d.mts +1238 -0
- package/dist/plugins/organization/routes/crud-team.mjs +766 -0
- package/dist/plugins/organization/schema.d.mts +390 -0
- package/dist/plugins/organization/schema.mjs +65 -0
- package/dist/plugins/organization/types.d.mts +691 -0
- package/dist/plugins/phone-number/client.d.mts +31 -0
- package/dist/plugins/phone-number/client.mjs +19 -0
- package/dist/plugins/phone-number/error-codes.d.mts +19 -0
- package/dist/plugins/phone-number/error-codes.mjs +18 -0
- package/dist/plugins/phone-number/index.d.mts +360 -0
- package/dist/plugins/phone-number/index.mjs +57 -0
- package/dist/plugins/phone-number/routes.mjs +529 -0
- package/dist/plugins/phone-number/schema.d.mts +22 -0
- package/dist/plugins/phone-number/schema.mjs +18 -0
- package/dist/plugins/phone-number/types.d.mts +116 -0
- package/dist/plugins/siwe/client.d.mts +14 -0
- package/dist/plugins/siwe/client.mjs +15 -0
- package/dist/plugins/siwe/index.d.mts +62 -0
- package/dist/plugins/siwe/index.mjs +272 -0
- package/dist/plugins/siwe/parse-message.mjs +60 -0
- package/dist/plugins/siwe/schema.d.mts +35 -0
- package/dist/plugins/siwe/schema.mjs +30 -0
- package/dist/plugins/siwe/types.d.mts +43 -0
- package/dist/plugins/test-utils/auth-helpers.mjs +33 -0
- package/dist/plugins/test-utils/cookie-builder.mjs +55 -0
- package/dist/plugins/test-utils/db-helpers.mjs +65 -0
- package/dist/plugins/test-utils/factories.mjs +38 -0
- package/dist/plugins/test-utils/index.d.mts +73 -0
- package/dist/plugins/test-utils/index.mjs +97 -0
- package/dist/plugins/test-utils/otp-sink.mjs +21 -0
- package/dist/plugins/test-utils/types.d.mts +51 -0
- package/dist/plugins/two-factor/backup-codes/index.d.mts +291 -0
- package/dist/plugins/two-factor/backup-codes/index.mjs +341 -0
- package/dist/plugins/two-factor/client.d.mts +76 -0
- package/dist/plugins/two-factor/client.mjs +41 -0
- package/dist/plugins/two-factor/constant.mjs +6 -0
- package/dist/plugins/two-factor/error-code.d.mts +20 -0
- package/dist/plugins/two-factor/error-code.mjs +19 -0
- package/dist/plugins/two-factor/index.d.mts +720 -0
- package/dist/plugins/two-factor/index.mjs +349 -0
- package/dist/plugins/two-factor/otp/index.d.mts +216 -0
- package/dist/plugins/two-factor/otp/index.mjs +252 -0
- package/dist/plugins/two-factor/schema.d.mts +59 -0
- package/dist/plugins/two-factor/schema.mjs +53 -0
- package/dist/plugins/two-factor/totp/index.d.mts +219 -0
- package/dist/plugins/two-factor/totp/index.mjs +230 -0
- package/dist/plugins/two-factor/types.d.mts +111 -0
- package/dist/plugins/two-factor/utils.mjs +9 -0
- package/dist/plugins/two-factor/verify-two-factor.mjs +205 -0
- package/dist/plugins/username/client.d.mts +38 -0
- package/dist/plugins/username/client.mjs +17 -0
- package/dist/plugins/username/error-codes.d.mts +16 -0
- package/dist/plugins/username/error-codes.mjs +15 -0
- package/dist/plugins/username/index.d.mts +326 -0
- package/dist/plugins/username/index.mjs +312 -0
- package/dist/plugins/username/schema.d.mts +50 -0
- package/dist/plugins/username/schema.mjs +25 -0
- package/dist/social-providers/index.d.mts +1 -0
- package/dist/social-providers/index.mjs +2 -0
- package/dist/state.d.mts +48 -0
- package/dist/state.mjs +149 -0
- package/dist/test-utils/headers.d.mts +8 -0
- package/dist/test-utils/headers.mjs +17 -0
- package/dist/test-utils/http-test-instance.d.mts +413 -0
- package/dist/test-utils/http-test-instance.mjs +107 -0
- package/dist/test-utils/index.d.mts +4 -0
- package/dist/test-utils/index.mjs +4 -0
- package/dist/test-utils/test-instance.d.mts +56 -0
- package/dist/test-utils/test-instance.mjs +242 -0
- package/dist/types/adapter.d.mts +2 -0
- package/dist/types/api.d.mts +28 -0
- package/dist/types/auth.d.mts +32 -0
- package/dist/types/helper.d.mts +26 -0
- package/dist/types/index.d.mts +10 -0
- package/dist/types/index.mjs +1 -0
- package/dist/types/models.d.mts +10 -0
- package/dist/types/plugins.d.mts +19 -0
- package/dist/utils/boolean.mjs +6 -0
- package/dist/utils/constants.mjs +4 -0
- package/dist/utils/date.mjs +6 -0
- package/dist/utils/hashing.mjs +18 -0
- package/dist/utils/hide-metadata.d.mts +6 -0
- package/dist/utils/hide-metadata.mjs +4 -0
- package/dist/utils/index.d.mts +4 -0
- package/dist/utils/is-api-error.d.mts +2 -0
- package/dist/utils/is-api-error.mjs +2 -0
- package/dist/utils/is-atom.mjs +6 -0
- package/dist/utils/is-promise.mjs +6 -0
- package/dist/utils/middleware-response.mjs +7 -0
- package/dist/utils/password.mjs +32 -0
- package/dist/utils/plugin-helper.mjs +14 -0
- package/dist/utils/request.mjs +23 -0
- package/dist/utils/shim.mjs +22 -0
- package/dist/utils/time.d.mts +48 -0
- package/dist/utils/time.mjs +98 -0
- package/dist/utils/url.d.mts +78 -0
- package/dist/utils/url.mjs +238 -0
- package/dist/utils/validate-user-info.mjs +44 -0
- package/dist/utils/wildcard.mjs +106 -0
- package/dist/version.mjs +5 -0
- package/package.json +595 -3
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
//#region src/plugins/username/schema.ts
|
|
2
|
+
const getSchema = (normalizer, includeDisplayUsername = true) => {
|
|
3
|
+
const fields = {
|
|
4
|
+
username: {
|
|
5
|
+
type: "string",
|
|
6
|
+
required: false,
|
|
7
|
+
sortable: true,
|
|
8
|
+
unique: true,
|
|
9
|
+
returned: true,
|
|
10
|
+
transform: { input(value) {
|
|
11
|
+
return typeof value !== "string" ? value : normalizer.username(value);
|
|
12
|
+
} }
|
|
13
|
+
},
|
|
14
|
+
displayUsername: {
|
|
15
|
+
type: "string",
|
|
16
|
+
required: false,
|
|
17
|
+
transform: { input(value) {
|
|
18
|
+
return typeof value !== "string" ? value : normalizer.displayUsername(value);
|
|
19
|
+
} }
|
|
20
|
+
}
|
|
21
|
+
};
|
|
22
|
+
return { user: { fields: includeDisplayUsername ? fields : { username: fields.username } } };
|
|
23
|
+
};
|
|
24
|
+
//#endregion
|
|
25
|
+
export { getSchema };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "@better-auth/core/social-providers";
|
package/dist/state.d.mts
ADDED
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { GenericEndpointContext } from "@better-auth/core";
|
|
2
|
+
import { BetterAuthError } from "@better-auth/core/error";
|
|
3
|
+
import * as z from "zod";
|
|
4
|
+
|
|
5
|
+
//#region src/state.d.ts
|
|
6
|
+
declare const stateDataSchema: z.ZodObject<{
|
|
7
|
+
callbackURL: z.ZodString;
|
|
8
|
+
codeVerifier: z.ZodString;
|
|
9
|
+
errorURL: z.ZodOptional<z.ZodString>;
|
|
10
|
+
newUserURL: z.ZodOptional<z.ZodString>;
|
|
11
|
+
expiresAt: z.ZodNumber;
|
|
12
|
+
oauthState: z.ZodOptional<z.ZodString>;
|
|
13
|
+
link: z.ZodOptional<z.ZodObject<{
|
|
14
|
+
email: z.ZodString;
|
|
15
|
+
userId: z.ZodCoercedString<unknown>;
|
|
16
|
+
}, z.core.$strip>>;
|
|
17
|
+
requestSignUp: z.ZodOptional<z.ZodBoolean>;
|
|
18
|
+
idTokenNonce: z.ZodOptional<z.ZodString>;
|
|
19
|
+
serverContext: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
20
|
+
}, z.core.$loose>;
|
|
21
|
+
type StateData = z.infer<typeof stateDataSchema>;
|
|
22
|
+
declare function generateGenericState(c: GenericEndpointContext, stateData: StateData, settings?: {
|
|
23
|
+
cookieName: string;
|
|
24
|
+
}): Promise<{
|
|
25
|
+
state: string;
|
|
26
|
+
codeVerifier: string;
|
|
27
|
+
}>;
|
|
28
|
+
declare function parseGenericState(c: GenericEndpointContext, state: string | undefined, settings?: {
|
|
29
|
+
cookieName?: string;
|
|
30
|
+
skipStateCookieCheck?: boolean;
|
|
31
|
+
}): Promise<{
|
|
32
|
+
[x: string]: unknown;
|
|
33
|
+
callbackURL: string;
|
|
34
|
+
codeVerifier: string;
|
|
35
|
+
expiresAt: number;
|
|
36
|
+
errorURL?: string | undefined;
|
|
37
|
+
newUserURL?: string | undefined;
|
|
38
|
+
oauthState?: string | undefined;
|
|
39
|
+
link?: {
|
|
40
|
+
email: string;
|
|
41
|
+
userId: string;
|
|
42
|
+
} | undefined;
|
|
43
|
+
requestSignUp?: boolean | undefined;
|
|
44
|
+
idTokenNonce?: string | undefined;
|
|
45
|
+
serverContext?: Record<string, unknown> | undefined;
|
|
46
|
+
}>;
|
|
47
|
+
//#endregion
|
|
48
|
+
export { StateData, generateGenericState, parseGenericState };
|
package/dist/state.mjs
ADDED
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
import { generateRandomString } from "./crypto/random.mjs";
|
|
2
|
+
import { symmetricDecrypt, symmetricEncrypt } from "./crypto/index.mjs";
|
|
3
|
+
import { expireCookie } from "./cookies/index.mjs";
|
|
4
|
+
import { BetterAuthError } from "@better-auth/core/error";
|
|
5
|
+
import * as z from "zod";
|
|
6
|
+
//#region src/state.ts
|
|
7
|
+
const stateDataSchema = z.looseObject({
|
|
8
|
+
callbackURL: z.string(),
|
|
9
|
+
codeVerifier: z.string(),
|
|
10
|
+
errorURL: z.string().optional(),
|
|
11
|
+
newUserURL: z.string().optional(),
|
|
12
|
+
expiresAt: z.number(),
|
|
13
|
+
/**
|
|
14
|
+
* CSRF nonce returned to the OAuth provider. When using cookie state storage,
|
|
15
|
+
* this must match the callback `state` query parameter.
|
|
16
|
+
*/
|
|
17
|
+
oauthState: z.string().optional(),
|
|
18
|
+
link: z.object({
|
|
19
|
+
email: z.string(),
|
|
20
|
+
userId: z.coerce.string()
|
|
21
|
+
}).optional(),
|
|
22
|
+
requestSignUp: z.boolean().optional(),
|
|
23
|
+
/**
|
|
24
|
+
* OIDC nonce sent as the authorization request `nonce` parameter when the
|
|
25
|
+
* provider requires an ID token to be bound to this redirect flow.
|
|
26
|
+
*/
|
|
27
|
+
idTokenNonce: z.string().optional(),
|
|
28
|
+
/**
|
|
29
|
+
* Server-controlled values that ride the state across the provider redirect.
|
|
30
|
+
* Populated only by `generateState` from `addOAuthServerContext`, never from
|
|
31
|
+
* the request body, so it is safe to trust on the callback.
|
|
32
|
+
*/
|
|
33
|
+
serverContext: z.record(z.string(), z.unknown()).optional()
|
|
34
|
+
});
|
|
35
|
+
const INTERNAL_STATE_KEYS = new Set(Object.keys(stateDataSchema.shape));
|
|
36
|
+
var StateError = class extends BetterAuthError {
|
|
37
|
+
code;
|
|
38
|
+
details;
|
|
39
|
+
/**
|
|
40
|
+
* The per-flow `errorCallbackURL` recovered from the parsed state, when the
|
|
41
|
+
* failure happened after the state was successfully parsed (for example a
|
|
42
|
+
* nonce or state-cookie mismatch). It was origin-validated at sign-in, so
|
|
43
|
+
* the callback can safely redirect there instead of the default error page.
|
|
44
|
+
* Absent when the state could not be parsed at all.
|
|
45
|
+
*/
|
|
46
|
+
errorURL;
|
|
47
|
+
constructor(message, options) {
|
|
48
|
+
super(message, options);
|
|
49
|
+
this.code = options.code;
|
|
50
|
+
this.details = options.details;
|
|
51
|
+
this.errorURL = options.errorURL;
|
|
52
|
+
}
|
|
53
|
+
};
|
|
54
|
+
async function generateGenericState(c, stateData, settings) {
|
|
55
|
+
const state = generateRandomString(32);
|
|
56
|
+
if (c.context.oauthConfig.storeStateStrategy === "cookie") {
|
|
57
|
+
const payload = {
|
|
58
|
+
...stateData,
|
|
59
|
+
oauthState: state
|
|
60
|
+
};
|
|
61
|
+
const encryptedData = await symmetricEncrypt({
|
|
62
|
+
key: c.context.secretConfig,
|
|
63
|
+
data: JSON.stringify(payload)
|
|
64
|
+
});
|
|
65
|
+
const stateCookie = c.context.createAuthCookie(settings?.cookieName ?? "oauth_state", { maxAge: 600 });
|
|
66
|
+
c.setCookie(stateCookie.name, encryptedData, stateCookie.attributes);
|
|
67
|
+
return {
|
|
68
|
+
state,
|
|
69
|
+
codeVerifier: stateData.codeVerifier
|
|
70
|
+
};
|
|
71
|
+
}
|
|
72
|
+
const stateCookie = c.context.createAuthCookie(settings?.cookieName ?? "state", { maxAge: 300 });
|
|
73
|
+
await c.setSignedCookie(stateCookie.name, state, c.context.secret, stateCookie.attributes);
|
|
74
|
+
const expiresAt = /* @__PURE__ */ new Date();
|
|
75
|
+
expiresAt.setMinutes(expiresAt.getMinutes() + 10);
|
|
76
|
+
if (!await c.context.internalAdapter.createVerificationValue({
|
|
77
|
+
value: JSON.stringify({
|
|
78
|
+
...stateData,
|
|
79
|
+
oauthState: state
|
|
80
|
+
}),
|
|
81
|
+
identifier: state,
|
|
82
|
+
expiresAt
|
|
83
|
+
})) throw new StateError("Unable to create verification. Make sure the database adapter is properly working and there is a verification table in the database", { code: "state_generation_error" });
|
|
84
|
+
return {
|
|
85
|
+
state,
|
|
86
|
+
codeVerifier: stateData.codeVerifier
|
|
87
|
+
};
|
|
88
|
+
}
|
|
89
|
+
async function parseGenericState(c, state, settings) {
|
|
90
|
+
if (!state) throw new StateError("State not found in OAuth callback", { code: "state_not_found" });
|
|
91
|
+
const storeStateStrategy = c.context.oauthConfig.storeStateStrategy;
|
|
92
|
+
let parsedData;
|
|
93
|
+
if (storeStateStrategy === "cookie") {
|
|
94
|
+
const stateCookie = c.context.createAuthCookie(settings?.cookieName ?? "oauth_state");
|
|
95
|
+
const encryptedData = c.getCookie(stateCookie.name);
|
|
96
|
+
if (!encryptedData) throw new StateError("State mismatch: auth state cookie not found", {
|
|
97
|
+
code: "state_mismatch",
|
|
98
|
+
details: { state }
|
|
99
|
+
});
|
|
100
|
+
try {
|
|
101
|
+
const decryptedData = await symmetricDecrypt({
|
|
102
|
+
key: c.context.secretConfig,
|
|
103
|
+
data: encryptedData
|
|
104
|
+
});
|
|
105
|
+
parsedData = stateDataSchema.parse(JSON.parse(decryptedData));
|
|
106
|
+
} catch (error) {
|
|
107
|
+
throw new StateError("State invalid: Failed to decrypt or parse auth state", {
|
|
108
|
+
code: "state_invalid",
|
|
109
|
+
details: { state },
|
|
110
|
+
cause: error
|
|
111
|
+
});
|
|
112
|
+
}
|
|
113
|
+
if (!parsedData.oauthState || parsedData.oauthState !== state) throw new StateError("State mismatch: OAuth state parameter does not match stored state", {
|
|
114
|
+
code: "state_security_mismatch",
|
|
115
|
+
details: { state },
|
|
116
|
+
errorURL: parsedData.errorURL
|
|
117
|
+
});
|
|
118
|
+
expireCookie(c, stateCookie);
|
|
119
|
+
} else {
|
|
120
|
+
const data = await c.context.internalAdapter.findVerificationValue(state);
|
|
121
|
+
if (!data) throw new StateError("State mismatch: verification not found", {
|
|
122
|
+
code: "state_mismatch",
|
|
123
|
+
details: { state }
|
|
124
|
+
});
|
|
125
|
+
parsedData = stateDataSchema.parse(JSON.parse(data.value));
|
|
126
|
+
if (parsedData.oauthState !== void 0 && parsedData.oauthState !== state) throw new StateError("State mismatch: OAuth state parameter does not match stored state", {
|
|
127
|
+
code: "state_security_mismatch",
|
|
128
|
+
details: { state },
|
|
129
|
+
errorURL: parsedData.errorURL
|
|
130
|
+
});
|
|
131
|
+
const stateCookie = c.context.createAuthCookie(settings?.cookieName ?? "state");
|
|
132
|
+
const stateCookieValue = await c.getSignedCookie(stateCookie.name, c.context.secret);
|
|
133
|
+
if (!(settings?.skipStateCookieCheck ?? c.context.oauthConfig.skipStateCookieCheck) && (!stateCookieValue || stateCookieValue !== state)) throw new StateError("State mismatch: State not persisted correctly", {
|
|
134
|
+
code: "state_security_mismatch",
|
|
135
|
+
details: { state },
|
|
136
|
+
errorURL: parsedData.errorURL
|
|
137
|
+
});
|
|
138
|
+
expireCookie(c, stateCookie);
|
|
139
|
+
await c.context.internalAdapter.deleteVerificationByIdentifier(state);
|
|
140
|
+
}
|
|
141
|
+
if (parsedData.expiresAt < Date.now()) throw new StateError("Invalid state: request expired", {
|
|
142
|
+
code: "state_mismatch",
|
|
143
|
+
details: { expiresAt: parsedData.expiresAt },
|
|
144
|
+
errorURL: parsedData.errorURL
|
|
145
|
+
});
|
|
146
|
+
return parsedData;
|
|
147
|
+
}
|
|
148
|
+
//#endregion
|
|
149
|
+
export { INTERNAL_STATE_KEYS, StateError, generateGenericState, parseGenericState };
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { applySetCookies } from "../cookies/cookie-utils.mjs";
|
|
2
|
+
//#region src/test-utils/headers.ts
|
|
3
|
+
/**
|
|
4
|
+
* converts set cookie containing headers to
|
|
5
|
+
* cookie containing headers
|
|
6
|
+
*/
|
|
7
|
+
function convertSetCookieToCookie(headers) {
|
|
8
|
+
const setCookieHeaders = [];
|
|
9
|
+
headers.forEach((value, name) => {
|
|
10
|
+
if (name.toLowerCase() === "set-cookie") setCookieHeaders.push(value);
|
|
11
|
+
});
|
|
12
|
+
if (setCookieHeaders.length === 0) return headers;
|
|
13
|
+
applySetCookies(headers, setCookieHeaders);
|
|
14
|
+
return headers;
|
|
15
|
+
}
|
|
16
|
+
//#endregion
|
|
17
|
+
export { convertSetCookieToCookie };
|
|
@@ -0,0 +1,413 @@
|
|
|
1
|
+
import { SessionQueryParams } from "../client/types.mjs";
|
|
2
|
+
import { Auth } from "../types/auth.mjs";
|
|
3
|
+
import { setCookieToHeader } from "../cookies/cookie-utils.mjs";
|
|
4
|
+
import { getTestInstance } from "./test-instance.mjs";
|
|
5
|
+
import * as _$_better_auth_core0 from "@better-auth/core";
|
|
6
|
+
import { BetterAuthClientOptions, BetterAuthOptions } from "@better-auth/core";
|
|
7
|
+
import * as _$_better_auth_core_db_adapter0 from "@better-auth/core/db/adapter";
|
|
8
|
+
import * as _$nanostores from "nanostores";
|
|
9
|
+
import * as _$_better_fetch_fetch0 from "@better-fetch/fetch";
|
|
10
|
+
import { IncomingMessage, ServerResponse, createServer } from "node:http";
|
|
11
|
+
import { AddressInfo } from "node:net";
|
|
12
|
+
|
|
13
|
+
//#region src/test-utils/http-test-instance.d.ts
|
|
14
|
+
/** A Node request handler that can be installed on an HTTP test listener. */
|
|
15
|
+
type HttpTestRequestHandler = (req: IncomingMessage, res: ServerResponse) => unknown | Promise<unknown>;
|
|
16
|
+
/** A bound HTTP test listener whose request handler can be installed later. */
|
|
17
|
+
type HttpTestServer = {
|
|
18
|
+
url: string;
|
|
19
|
+
address: AddressInfo;
|
|
20
|
+
server: ReturnType<typeof createServer>;
|
|
21
|
+
setRequestHandler: (handler: HttpTestRequestHandler) => void;
|
|
22
|
+
close: () => Promise<void>;
|
|
23
|
+
};
|
|
24
|
+
type GetTestInstanceConfig = NonNullable<Parameters<typeof getTestInstance>[1]>;
|
|
25
|
+
type HttpTestInstanceConfig<C extends BetterAuthClientOptions> = Omit<GetTestInstanceConfig, "port" | "clientOptions"> & {
|
|
26
|
+
clientOptions?: C;
|
|
27
|
+
/**
|
|
28
|
+
* Customizes the HTTP request listener. Receives the bound auth instance
|
|
29
|
+
* and returns a Node request handler. Defaults to
|
|
30
|
+
* `toNodeHandler(auth.handler)`.
|
|
31
|
+
*
|
|
32
|
+
* Use this when the test needs to expose extra routes alongside the auth
|
|
33
|
+
* handler (e.g. a `.well-known/openid-configuration` shim that calls
|
|
34
|
+
* `auth.api.getOpenIdConfig()`).
|
|
35
|
+
*/
|
|
36
|
+
handler?: (auth: Awaited<ReturnType<typeof getTestInstance>>["auth"]) => HttpTestRequestHandler;
|
|
37
|
+
};
|
|
38
|
+
/**
|
|
39
|
+
* Binds an HTTP listener to an OS-assigned port before the final request
|
|
40
|
+
* handler exists. This lets tests construct URL-sensitive applications only
|
|
41
|
+
* after the listener owns its port, then install the application handler.
|
|
42
|
+
*/
|
|
43
|
+
declare function createHttpTestServer(): Promise<HttpTestServer>;
|
|
44
|
+
/**
|
|
45
|
+
* Like `getTestInstance`, but bound to an actual HTTP listener on an
|
|
46
|
+
* OS-assigned port (`port: 0`). The discovered URL is fed back into the auth
|
|
47
|
+
* instance so its `baseURL` matches the listener.
|
|
48
|
+
*
|
|
49
|
+
* This removes the race window that the temp-server-then-rebind pattern
|
|
50
|
+
* introduces. The listener is bound once, holds the port for its lifetime,
|
|
51
|
+
* and only swaps in the real request handler after the auth instance is
|
|
52
|
+
* fully constructed.
|
|
53
|
+
*
|
|
54
|
+
* The caller is responsible for calling `server.close()` in `afterAll`. Any
|
|
55
|
+
* `baseURL` passed in `options` is ignored — the URL must match the
|
|
56
|
+
* listener.
|
|
57
|
+
*/
|
|
58
|
+
declare function getHttpTestInstance<O extends Partial<BetterAuthOptions>, C extends BetterAuthClientOptions>(options?: O, config?: HttpTestInstanceConfig<C>): Promise<{
|
|
59
|
+
server: HttpTestServer;
|
|
60
|
+
baseURL: string;
|
|
61
|
+
port: number;
|
|
62
|
+
auth: Auth<O>;
|
|
63
|
+
client: {
|
|
64
|
+
hydrateSession(session: null): void;
|
|
65
|
+
useSession: _$nanostores.Atom<{
|
|
66
|
+
data: never;
|
|
67
|
+
error: _$_better_fetch_fetch0.BetterFetchError | null;
|
|
68
|
+
isPending: boolean;
|
|
69
|
+
isRefetching: boolean;
|
|
70
|
+
refetch: (queryParams?: {
|
|
71
|
+
query?: SessionQueryParams;
|
|
72
|
+
} | undefined) => Promise<void>;
|
|
73
|
+
}>;
|
|
74
|
+
$fetch: _$_better_fetch_fetch0.BetterFetch<{
|
|
75
|
+
plugins: (_$_better_fetch_fetch0.BetterFetchPlugin<Record<string, any>> | {
|
|
76
|
+
id: string;
|
|
77
|
+
name: string;
|
|
78
|
+
hooks: {
|
|
79
|
+
onSuccess(context: _$_better_fetch_fetch0.SuccessContext<any>): void;
|
|
80
|
+
};
|
|
81
|
+
} | {
|
|
82
|
+
id: string;
|
|
83
|
+
name: string;
|
|
84
|
+
hooks: {
|
|
85
|
+
onSuccess: ((context: _$_better_fetch_fetch0.SuccessContext<any>) => Promise<void> | void) | undefined;
|
|
86
|
+
onError: ((context: _$_better_fetch_fetch0.ErrorContext) => Promise<void> | void) | undefined;
|
|
87
|
+
onRequest: (<T extends Record<string, any>>(context: _$_better_fetch_fetch0.RequestContext<T>) => Promise<_$_better_fetch_fetch0.RequestContext | void> | _$_better_fetch_fetch0.RequestContext | void) | undefined;
|
|
88
|
+
onResponse: ((context: _$_better_fetch_fetch0.ResponseContext) => Promise<Response | void | _$_better_fetch_fetch0.ResponseContext> | Response | _$_better_fetch_fetch0.ResponseContext | void) | undefined;
|
|
89
|
+
};
|
|
90
|
+
})[];
|
|
91
|
+
cache?: RequestCache | undefined;
|
|
92
|
+
credentials?: RequestCredentials;
|
|
93
|
+
integrity?: string | undefined;
|
|
94
|
+
keepalive?: boolean | undefined;
|
|
95
|
+
method: string;
|
|
96
|
+
mode?: RequestMode | undefined;
|
|
97
|
+
priority?: RequestPriority | undefined;
|
|
98
|
+
redirect?: RequestRedirect | undefined;
|
|
99
|
+
referrer?: string | undefined;
|
|
100
|
+
referrerPolicy?: ReferrerPolicy | undefined;
|
|
101
|
+
signal?: AbortSignal | null;
|
|
102
|
+
window?: null | undefined;
|
|
103
|
+
onRetry?: ((response: _$_better_fetch_fetch0.ResponseContext) => Promise<void> | void) | undefined;
|
|
104
|
+
hookOptions?: {
|
|
105
|
+
cloneResponse?: boolean;
|
|
106
|
+
} | undefined;
|
|
107
|
+
timeout?: number | undefined;
|
|
108
|
+
customFetchImpl: _$_better_fetch_fetch0.FetchEsque;
|
|
109
|
+
baseURL: string;
|
|
110
|
+
throw?: boolean | undefined;
|
|
111
|
+
auth?: ({
|
|
112
|
+
type: "Bearer";
|
|
113
|
+
token: string | Promise<string | undefined> | (() => string | Promise<string | undefined> | undefined) | undefined;
|
|
114
|
+
} | {
|
|
115
|
+
type: "Basic";
|
|
116
|
+
username: string | (() => string | undefined) | undefined;
|
|
117
|
+
password: string | (() => string | undefined) | undefined;
|
|
118
|
+
} | {
|
|
119
|
+
type: "Custom";
|
|
120
|
+
prefix: string | (() => string | undefined) | undefined;
|
|
121
|
+
value: string | (() => string | undefined) | undefined;
|
|
122
|
+
}) | undefined;
|
|
123
|
+
headers?: {} | {
|
|
124
|
+
[x: string]: string | undefined;
|
|
125
|
+
accept?: ((string & {}) | "application/json" | "text/plain" | "application/octet-stream") | undefined;
|
|
126
|
+
"content-type"?: ((string & {}) | "application/x-www-form-urlencoded" | "application/json" | "text/plain" | "application/octet-stream" | "multipart/form-data") | undefined;
|
|
127
|
+
authorization?: ((string & {}) | `Bearer ${string}` | `Basic ${string}`) | undefined;
|
|
128
|
+
} | undefined;
|
|
129
|
+
body?: any;
|
|
130
|
+
query?: any;
|
|
131
|
+
params?: any;
|
|
132
|
+
duplex?: "full" | "half" | undefined;
|
|
133
|
+
jsonParser: (text: string) => Promise<any> | any;
|
|
134
|
+
retry?: _$_better_fetch_fetch0.RetryOptions | undefined;
|
|
135
|
+
retryAttempt?: number | undefined;
|
|
136
|
+
output?: (_$_better_fetch_fetch0.StandardSchemaV1 | typeof Blob | typeof File) | undefined;
|
|
137
|
+
errorSchema?: _$_better_fetch_fetch0.StandardSchemaV1 | undefined;
|
|
138
|
+
disableValidation?: boolean | undefined;
|
|
139
|
+
disableSignal?: boolean | undefined;
|
|
140
|
+
}, unknown, unknown, {}>;
|
|
141
|
+
$store: {
|
|
142
|
+
notify: (signal?: (Omit<string, "$sessionSignal"> | "$sessionSignal") | undefined) => void;
|
|
143
|
+
listen: (signal: Omit<string, "$sessionSignal"> | "$sessionSignal", listener: (value: boolean, oldValue?: boolean | undefined) => void) => void;
|
|
144
|
+
atoms: Record<string, _$nanostores.WritableAtom<any>>;
|
|
145
|
+
};
|
|
146
|
+
$Infer: {
|
|
147
|
+
Session: never;
|
|
148
|
+
};
|
|
149
|
+
$ERROR_CODES: {
|
|
150
|
+
USER_NOT_FOUND: {
|
|
151
|
+
readonly code: "USER_NOT_FOUND";
|
|
152
|
+
message: string;
|
|
153
|
+
};
|
|
154
|
+
FAILED_TO_CREATE_USER: {
|
|
155
|
+
readonly code: "FAILED_TO_CREATE_USER";
|
|
156
|
+
message: string;
|
|
157
|
+
};
|
|
158
|
+
FAILED_TO_CREATE_SESSION: {
|
|
159
|
+
readonly code: "FAILED_TO_CREATE_SESSION";
|
|
160
|
+
message: string;
|
|
161
|
+
};
|
|
162
|
+
FAILED_TO_UPDATE_USER: {
|
|
163
|
+
readonly code: "FAILED_TO_UPDATE_USER";
|
|
164
|
+
message: string;
|
|
165
|
+
};
|
|
166
|
+
FAILED_TO_GET_SESSION: {
|
|
167
|
+
readonly code: "FAILED_TO_GET_SESSION";
|
|
168
|
+
message: string;
|
|
169
|
+
};
|
|
170
|
+
INVALID_PASSWORD: {
|
|
171
|
+
readonly code: "INVALID_PASSWORD";
|
|
172
|
+
message: string;
|
|
173
|
+
};
|
|
174
|
+
INVALID_EMAIL: {
|
|
175
|
+
readonly code: "INVALID_EMAIL";
|
|
176
|
+
message: string;
|
|
177
|
+
};
|
|
178
|
+
INVALID_EMAIL_OR_PASSWORD: {
|
|
179
|
+
readonly code: "INVALID_EMAIL_OR_PASSWORD";
|
|
180
|
+
message: string;
|
|
181
|
+
};
|
|
182
|
+
INVALID_USER: {
|
|
183
|
+
readonly code: "INVALID_USER";
|
|
184
|
+
message: string;
|
|
185
|
+
};
|
|
186
|
+
SOCIAL_ACCOUNT_ALREADY_LINKED: {
|
|
187
|
+
readonly code: "SOCIAL_ACCOUNT_ALREADY_LINKED";
|
|
188
|
+
message: string;
|
|
189
|
+
};
|
|
190
|
+
PROVIDER_NOT_FOUND: {
|
|
191
|
+
readonly code: "PROVIDER_NOT_FOUND";
|
|
192
|
+
message: string;
|
|
193
|
+
};
|
|
194
|
+
INVALID_TOKEN: {
|
|
195
|
+
readonly code: "INVALID_TOKEN";
|
|
196
|
+
message: string;
|
|
197
|
+
};
|
|
198
|
+
TOKEN_EXPIRED: {
|
|
199
|
+
readonly code: "TOKEN_EXPIRED";
|
|
200
|
+
message: string;
|
|
201
|
+
};
|
|
202
|
+
ID_TOKEN_NOT_SUPPORTED: {
|
|
203
|
+
readonly code: "ID_TOKEN_NOT_SUPPORTED";
|
|
204
|
+
message: string;
|
|
205
|
+
};
|
|
206
|
+
FAILED_TO_GET_USER_INFO: {
|
|
207
|
+
readonly code: "FAILED_TO_GET_USER_INFO";
|
|
208
|
+
message: string;
|
|
209
|
+
};
|
|
210
|
+
USER_EMAIL_NOT_FOUND: {
|
|
211
|
+
readonly code: "USER_EMAIL_NOT_FOUND";
|
|
212
|
+
message: string;
|
|
213
|
+
};
|
|
214
|
+
EMAIL_NOT_VERIFIED: {
|
|
215
|
+
readonly code: "EMAIL_NOT_VERIFIED";
|
|
216
|
+
message: string;
|
|
217
|
+
};
|
|
218
|
+
PASSWORD_TOO_SHORT: {
|
|
219
|
+
readonly code: "PASSWORD_TOO_SHORT";
|
|
220
|
+
message: string;
|
|
221
|
+
};
|
|
222
|
+
PASSWORD_TOO_LONG: {
|
|
223
|
+
readonly code: "PASSWORD_TOO_LONG";
|
|
224
|
+
message: string;
|
|
225
|
+
};
|
|
226
|
+
USER_ALREADY_EXISTS: {
|
|
227
|
+
readonly code: "USER_ALREADY_EXISTS";
|
|
228
|
+
message: string;
|
|
229
|
+
};
|
|
230
|
+
USER_ALREADY_EXISTS_USE_ANOTHER_EMAIL: {
|
|
231
|
+
readonly code: "USER_ALREADY_EXISTS_USE_ANOTHER_EMAIL";
|
|
232
|
+
message: string;
|
|
233
|
+
};
|
|
234
|
+
EMAIL_CAN_NOT_BE_UPDATED: {
|
|
235
|
+
readonly code: "EMAIL_CAN_NOT_BE_UPDATED";
|
|
236
|
+
message: string;
|
|
237
|
+
};
|
|
238
|
+
CHANGE_EMAIL_DISABLED: {
|
|
239
|
+
readonly code: "CHANGE_EMAIL_DISABLED";
|
|
240
|
+
message: string;
|
|
241
|
+
};
|
|
242
|
+
CREDENTIAL_ACCOUNT_NOT_FOUND: {
|
|
243
|
+
readonly code: "CREDENTIAL_ACCOUNT_NOT_FOUND";
|
|
244
|
+
message: string;
|
|
245
|
+
};
|
|
246
|
+
ACCOUNT_NOT_FOUND: {
|
|
247
|
+
readonly code: "ACCOUNT_NOT_FOUND";
|
|
248
|
+
message: string;
|
|
249
|
+
};
|
|
250
|
+
SESSION_EXPIRED: {
|
|
251
|
+
readonly code: "SESSION_EXPIRED";
|
|
252
|
+
message: string;
|
|
253
|
+
};
|
|
254
|
+
FAILED_TO_UNLINK_LAST_ACCOUNT: {
|
|
255
|
+
readonly code: "FAILED_TO_UNLINK_LAST_ACCOUNT";
|
|
256
|
+
message: string;
|
|
257
|
+
};
|
|
258
|
+
USER_ALREADY_HAS_PASSWORD: {
|
|
259
|
+
readonly code: "USER_ALREADY_HAS_PASSWORD";
|
|
260
|
+
message: string;
|
|
261
|
+
};
|
|
262
|
+
CROSS_SITE_NAVIGATION_LOGIN_BLOCKED: {
|
|
263
|
+
readonly code: "CROSS_SITE_NAVIGATION_LOGIN_BLOCKED";
|
|
264
|
+
message: string;
|
|
265
|
+
};
|
|
266
|
+
VERIFICATION_EMAIL_NOT_ENABLED: {
|
|
267
|
+
readonly code: "VERIFICATION_EMAIL_NOT_ENABLED";
|
|
268
|
+
message: string;
|
|
269
|
+
};
|
|
270
|
+
EMAIL_ALREADY_VERIFIED: {
|
|
271
|
+
readonly code: "EMAIL_ALREADY_VERIFIED";
|
|
272
|
+
message: string;
|
|
273
|
+
};
|
|
274
|
+
EMAIL_MISMATCH: {
|
|
275
|
+
readonly code: "EMAIL_MISMATCH";
|
|
276
|
+
message: string;
|
|
277
|
+
};
|
|
278
|
+
SESSION_NOT_FRESH: {
|
|
279
|
+
readonly code: "SESSION_NOT_FRESH";
|
|
280
|
+
message: string;
|
|
281
|
+
};
|
|
282
|
+
LINKED_ACCOUNT_ALREADY_EXISTS: {
|
|
283
|
+
readonly code: "LINKED_ACCOUNT_ALREADY_EXISTS";
|
|
284
|
+
message: string;
|
|
285
|
+
};
|
|
286
|
+
INVALID_ORIGIN: {
|
|
287
|
+
readonly code: "INVALID_ORIGIN";
|
|
288
|
+
message: string;
|
|
289
|
+
};
|
|
290
|
+
INVALID_CALLBACK_URL: {
|
|
291
|
+
readonly code: "INVALID_CALLBACK_URL";
|
|
292
|
+
message: string;
|
|
293
|
+
};
|
|
294
|
+
INVALID_REDIRECT_URL: {
|
|
295
|
+
readonly code: "INVALID_REDIRECT_URL";
|
|
296
|
+
message: string;
|
|
297
|
+
};
|
|
298
|
+
INVALID_ERROR_CALLBACK_URL: {
|
|
299
|
+
readonly code: "INVALID_ERROR_CALLBACK_URL";
|
|
300
|
+
message: string;
|
|
301
|
+
};
|
|
302
|
+
INVALID_NEW_USER_CALLBACK_URL: {
|
|
303
|
+
readonly code: "INVALID_NEW_USER_CALLBACK_URL";
|
|
304
|
+
message: string;
|
|
305
|
+
};
|
|
306
|
+
MISSING_OR_NULL_ORIGIN: {
|
|
307
|
+
readonly code: "MISSING_OR_NULL_ORIGIN";
|
|
308
|
+
message: string;
|
|
309
|
+
};
|
|
310
|
+
CALLBACK_URL_REQUIRED: {
|
|
311
|
+
readonly code: "CALLBACK_URL_REQUIRED";
|
|
312
|
+
message: string;
|
|
313
|
+
};
|
|
314
|
+
FAILED_TO_CREATE_VERIFICATION: {
|
|
315
|
+
readonly code: "FAILED_TO_CREATE_VERIFICATION";
|
|
316
|
+
message: string;
|
|
317
|
+
};
|
|
318
|
+
FIELD_NOT_ALLOWED: {
|
|
319
|
+
readonly code: "FIELD_NOT_ALLOWED";
|
|
320
|
+
message: string;
|
|
321
|
+
};
|
|
322
|
+
ASYNC_VALIDATION_NOT_SUPPORTED: {
|
|
323
|
+
readonly code: "ASYNC_VALIDATION_NOT_SUPPORTED";
|
|
324
|
+
message: string;
|
|
325
|
+
};
|
|
326
|
+
VALIDATION_ERROR: {
|
|
327
|
+
readonly code: "VALIDATION_ERROR";
|
|
328
|
+
message: string;
|
|
329
|
+
};
|
|
330
|
+
MISSING_FIELD: {
|
|
331
|
+
readonly code: "MISSING_FIELD";
|
|
332
|
+
message: string;
|
|
333
|
+
};
|
|
334
|
+
METHOD_NOT_ALLOWED_DEFER_SESSION_REQUIRED: {
|
|
335
|
+
readonly code: "METHOD_NOT_ALLOWED_DEFER_SESSION_REQUIRED";
|
|
336
|
+
message: string;
|
|
337
|
+
};
|
|
338
|
+
BODY_MUST_BE_AN_OBJECT: {
|
|
339
|
+
readonly code: "BODY_MUST_BE_AN_OBJECT";
|
|
340
|
+
message: string;
|
|
341
|
+
};
|
|
342
|
+
PASSWORD_ALREADY_SET: {
|
|
343
|
+
readonly code: "PASSWORD_ALREADY_SET";
|
|
344
|
+
message: string;
|
|
345
|
+
};
|
|
346
|
+
};
|
|
347
|
+
};
|
|
348
|
+
testUser: {
|
|
349
|
+
id?: string | undefined;
|
|
350
|
+
createdAt?: Date | undefined;
|
|
351
|
+
updatedAt?: Date | undefined;
|
|
352
|
+
email: string;
|
|
353
|
+
emailVerified?: boolean | undefined;
|
|
354
|
+
name: string;
|
|
355
|
+
image?: string | null | undefined;
|
|
356
|
+
password: string;
|
|
357
|
+
};
|
|
358
|
+
signInWithTestUser: () => Promise<{
|
|
359
|
+
session: {
|
|
360
|
+
id: string;
|
|
361
|
+
createdAt: Date;
|
|
362
|
+
updatedAt: Date;
|
|
363
|
+
userId: string;
|
|
364
|
+
expiresAt: Date;
|
|
365
|
+
token: string;
|
|
366
|
+
ipAddress?: string | null | undefined;
|
|
367
|
+
userAgent?: string | null | undefined;
|
|
368
|
+
};
|
|
369
|
+
user: {
|
|
370
|
+
id: string;
|
|
371
|
+
createdAt: Date;
|
|
372
|
+
updatedAt: Date;
|
|
373
|
+
email: string;
|
|
374
|
+
emailVerified: boolean;
|
|
375
|
+
name: string;
|
|
376
|
+
image?: string | null | undefined;
|
|
377
|
+
};
|
|
378
|
+
headers: Headers;
|
|
379
|
+
setCookie: (name: string, value: string) => void;
|
|
380
|
+
runWithUser: (fn: (headers: Headers) => Promise<void>) => Promise<void>;
|
|
381
|
+
}>;
|
|
382
|
+
signInWithUser: (email: string, password: string) => Promise<{
|
|
383
|
+
res: {
|
|
384
|
+
user: {
|
|
385
|
+
id: string;
|
|
386
|
+
createdAt: Date;
|
|
387
|
+
updatedAt: Date;
|
|
388
|
+
email: string;
|
|
389
|
+
emailVerified: boolean;
|
|
390
|
+
name: string;
|
|
391
|
+
image?: string | null | undefined;
|
|
392
|
+
};
|
|
393
|
+
session: {
|
|
394
|
+
id: string;
|
|
395
|
+
createdAt: Date;
|
|
396
|
+
updatedAt: Date;
|
|
397
|
+
userId: string;
|
|
398
|
+
expiresAt: Date;
|
|
399
|
+
token: string;
|
|
400
|
+
ipAddress?: string | null | undefined;
|
|
401
|
+
userAgent?: string | null | undefined;
|
|
402
|
+
};
|
|
403
|
+
};
|
|
404
|
+
headers: Headers;
|
|
405
|
+
}>;
|
|
406
|
+
cookieSetter: typeof setCookieToHeader;
|
|
407
|
+
customFetchImpl: (url: string | URL | Request, init?: RequestInit | undefined) => Promise<Response>;
|
|
408
|
+
sessionSetter: (headers: Headers) => (context: _$_better_fetch_fetch0.SuccessContext) => void;
|
|
409
|
+
db: _$_better_auth_core_db_adapter0.DBAdapter<BetterAuthOptions>;
|
|
410
|
+
runWithUser: (email: string, password: string, fn: (headers: Headers) => _$_better_auth_core0.Awaitable<void>) => Promise<void>;
|
|
411
|
+
}>;
|
|
412
|
+
//#endregion
|
|
413
|
+
export { HttpTestInstanceConfig, HttpTestRequestHandler, HttpTestServer, createHttpTestServer, getHttpTestInstance };
|