@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,10 @@
|
|
|
1
|
+
//#region src/client/focus-manager.d.ts
|
|
2
|
+
type FocusListener = (focused: boolean) => void;
|
|
3
|
+
declare const kFocusManager: unique symbol;
|
|
4
|
+
interface FocusManager {
|
|
5
|
+
setFocused(focused: boolean): void;
|
|
6
|
+
subscribe(listener: FocusListener): () => void;
|
|
7
|
+
setup(): () => void;
|
|
8
|
+
}
|
|
9
|
+
//#endregion
|
|
10
|
+
export { FocusListener, FocusManager, kFocusManager };
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
//#region src/client/focus-manager.ts
|
|
2
|
+
const kFocusManager = Symbol.for("better-auth:focus-manager");
|
|
3
|
+
var WindowFocusManager = class {
|
|
4
|
+
listeners = /* @__PURE__ */ new Set();
|
|
5
|
+
subscribe(listener) {
|
|
6
|
+
this.listeners.add(listener);
|
|
7
|
+
return () => {
|
|
8
|
+
this.listeners.delete(listener);
|
|
9
|
+
};
|
|
10
|
+
}
|
|
11
|
+
setFocused(focused) {
|
|
12
|
+
this.listeners.forEach((listener) => listener(focused));
|
|
13
|
+
}
|
|
14
|
+
setup() {
|
|
15
|
+
if (typeof window === "undefined" || typeof document === "undefined" || typeof window.addEventListener === "undefined") return () => {};
|
|
16
|
+
const visibilityHandler = () => {
|
|
17
|
+
if (document.visibilityState === "visible") this.setFocused(true);
|
|
18
|
+
};
|
|
19
|
+
document.addEventListener("visibilitychange", visibilityHandler, false);
|
|
20
|
+
return () => {
|
|
21
|
+
document.removeEventListener("visibilitychange", visibilityHandler, false);
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
};
|
|
25
|
+
function getGlobalFocusManager() {
|
|
26
|
+
if (!globalThis[kFocusManager]) globalThis[kFocusManager] = new WindowFocusManager();
|
|
27
|
+
return globalThis[kFocusManager];
|
|
28
|
+
}
|
|
29
|
+
//#endregion
|
|
30
|
+
export { getGlobalFocusManager, kFocusManager };
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { ExtractPluginField, HasRequiredKeys, InferPluginFieldFromTuple, IsAny, OverrideMerge, Prettify, PrettifyDeep, RequiredKeysOf, StripEmptyObjects, UnionToIntersection } from "../types/helper.mjs";
|
|
2
|
+
import { CamelCase, InferCtx, InferRoute, InferRoutes, InferSessionUpdateCtx, InferSignUpEmailCtx, InferUserUpdateCtx, MergeRoutes, PathToObject, ProxyRequest } from "./path-to-object.mjs";
|
|
3
|
+
import { BetterAuthClientOptions, BetterAuthClientPlugin, ClientAtomListener, ClientStore, InferActions, InferAdditionalFromClient, InferClientAPI, InferErrorCodes, InferSessionFromClient, InferUserFromClient, IsSignal, SessionQueryParams } from "./types.mjs";
|
|
4
|
+
import { BroadcastChannel, BroadcastListener, BroadcastMessage, getGlobalBroadcastChannel, kBroadcastChannel } from "./broadcast-channel.mjs";
|
|
5
|
+
import { isJsonEqual, withEquality } from "./equality.mjs";
|
|
6
|
+
import { FocusListener, FocusManager, kFocusManager } from "./focus-manager.mjs";
|
|
7
|
+
import { OnlineListener, OnlineManager, kOnlineManager } from "./online-manager.mjs";
|
|
8
|
+
import { parseJSON } from "./parser.mjs";
|
|
9
|
+
import { AuthQueryAtom, AuthQueryState, useAuthQuery } from "./query.mjs";
|
|
10
|
+
import { SessionRefreshOptions, createSessionRefreshManager } from "./session-refresh.mjs";
|
|
11
|
+
import { AuthClient, createAuthClient } from "./vanilla.mjs";
|
|
12
|
+
import { AccessControl, ArrayElement, ExactRoleStatements, Role, RoleAuthorizeRequest, RoleInput, RoleStatements, Statements, SubArray, Subset } from "../plugins/access/types.mjs";
|
|
13
|
+
import { AuthorizeResponse, createAccessControl, role } from "../plugins/access/access.mjs";
|
|
14
|
+
import { OrganizationOptions } from "../plugins/organization/types.mjs";
|
|
15
|
+
import { InferInvitation, InferMember, InferOrganization, InferOrganizationRolesFromOption, InferOrganizationZodRolesFromOption, InferTeam, Invitation, InvitationInput, InvitationStatus, Member, MemberInput, Organization, OrganizationInput, OrganizationRole, OrganizationSchema, Team, TeamInput, TeamMember, TeamMemberInput, defaultRolesSchema, invitationSchema, invitationStatus, memberSchema, organizationRoleSchema, organizationSchema, roleSchema, teamMemberSchema, teamSchema } from "../plugins/organization/schema.mjs";
|
|
16
|
+
import { getOrgAdapter } from "../plugins/organization/adapter.mjs";
|
|
17
|
+
import { hasPermission } from "../plugins/organization/has-permission.mjs";
|
|
18
|
+
import { DefaultOrganizationPlugin, DynamicAccessControlEndpoints, OrganizationCreator, OrganizationEndpoints, OrganizationPlugin, TeamEndpoints, organization, parseRoles } from "../plugins/organization/organization.mjs";
|
|
19
|
+
import { BetterAuthOptions, BetterAuthPlugin } from "@better-auth/core";
|
|
20
|
+
import { DBPrimitive } from "@better-auth/core/db";
|
|
21
|
+
export * from "@better-auth/core/db";
|
|
22
|
+
export * from "nanostores";
|
|
23
|
+
export * from "@better-fetch/fetch";
|
|
24
|
+
|
|
25
|
+
//#region src/client/index.d.ts
|
|
26
|
+
declare const InferPlugin: <T extends BetterAuthPlugin>() => {
|
|
27
|
+
id: "infer-server-plugin";
|
|
28
|
+
version: string;
|
|
29
|
+
$InferServerPlugin: T;
|
|
30
|
+
};
|
|
31
|
+
declare function InferAuth<O extends {
|
|
32
|
+
options: BetterAuthOptions;
|
|
33
|
+
}>(): O["options"];
|
|
34
|
+
//#endregion
|
|
35
|
+
export { AccessControl, ArrayElement, AuthClient, AuthQueryAtom, AuthQueryState, AuthorizeResponse, BetterAuthClientOptions, BetterAuthClientPlugin, BroadcastChannel, BroadcastListener, BroadcastMessage, CamelCase, ClientAtomListener, ClientStore, type DBPrimitive, DefaultOrganizationPlugin, DynamicAccessControlEndpoints, ExactRoleStatements, ExtractPluginField, type FocusListener, type FocusManager, HasRequiredKeys, InferActions, InferAdditionalFromClient, InferAuth, InferClientAPI, InferCtx, InferErrorCodes, InferInvitation, InferMember, InferOrganization, InferOrganizationRolesFromOption, InferOrganizationZodRolesFromOption, InferPlugin, InferPluginFieldFromTuple, InferRoute, InferRoutes, InferSessionFromClient, InferSessionUpdateCtx, InferSignUpEmailCtx, InferTeam, InferUserFromClient, InferUserUpdateCtx, Invitation, InvitationInput, InvitationStatus, IsAny, IsSignal, Member, MemberInput, MergeRoutes, type OnlineListener, type OnlineManager, Organization, OrganizationCreator, OrganizationEndpoints, OrganizationInput, OrganizationOptions, OrganizationPlugin, OrganizationRole, OrganizationSchema, OverrideMerge, PathToObject, Prettify, PrettifyDeep, ProxyRequest, RequiredKeysOf, Role, RoleAuthorizeRequest, RoleInput, RoleStatements, SessionQueryParams, SessionRefreshOptions, Statements, StripEmptyObjects, SubArray, Subset, Team, TeamEndpoints, TeamInput, TeamMember, TeamMemberInput, type UnionToIntersection, createAccessControl, createAuthClient, createSessionRefreshManager, defaultRolesSchema, getGlobalBroadcastChannel, getOrgAdapter, hasPermission, invitationSchema, invitationStatus, isJsonEqual, kBroadcastChannel, kFocusManager, kOnlineManager, memberSchema, organization, organizationRoleSchema, organizationSchema, parseJSON, parseRoles, role, roleSchema, teamMemberSchema, teamSchema, useAuthQuery, withEquality };
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { PACKAGE_VERSION } from "../version.mjs";
|
|
2
|
+
import { getGlobalBroadcastChannel, kBroadcastChannel } from "./broadcast-channel.mjs";
|
|
3
|
+
import { isJsonEqual, withEquality } from "./equality.mjs";
|
|
4
|
+
import { kFocusManager } from "./focus-manager.mjs";
|
|
5
|
+
import { kOnlineManager } from "./online-manager.mjs";
|
|
6
|
+
import { parseJSON } from "./parser.mjs";
|
|
7
|
+
import { useAuthQuery } from "./query.mjs";
|
|
8
|
+
import { createSessionRefreshManager } from "./session-refresh.mjs";
|
|
9
|
+
import { createAuthClient } from "./vanilla.mjs";
|
|
10
|
+
//#region src/client/index.ts
|
|
11
|
+
const InferPlugin = () => {
|
|
12
|
+
return {
|
|
13
|
+
id: "infer-server-plugin",
|
|
14
|
+
version: PACKAGE_VERSION,
|
|
15
|
+
$InferServerPlugin: {}
|
|
16
|
+
};
|
|
17
|
+
};
|
|
18
|
+
function InferAuth() {
|
|
19
|
+
return {};
|
|
20
|
+
}
|
|
21
|
+
//#endregion
|
|
22
|
+
export { InferAuth, InferPlugin, createAuthClient, createSessionRefreshManager, getGlobalBroadcastChannel, isJsonEqual, kBroadcastChannel, kFocusManager, kOnlineManager, parseJSON, useAuthQuery, withEquality };
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { ExtractPluginField, HasRequiredKeys, InferPluginFieldFromTuple, IsAny, OverrideMerge, Prettify, PrettifyDeep, RequiredKeysOf, StripEmptyObjects, UnionToIntersection } from "../../types/helper.mjs";
|
|
2
|
+
import { InferActions, InferClientAPI, InferErrorCodes, IsSignal, SessionQueryParams } from "../types.mjs";
|
|
3
|
+
import { getClientConfig } from "../config.mjs";
|
|
4
|
+
import { useStore } from "./lynx-store.mjs";
|
|
5
|
+
import { BetterAuthClientOptions } from "@better-auth/core";
|
|
6
|
+
import { BASE_ERROR_CODES } from "@better-auth/core/error";
|
|
7
|
+
import { BetterFetchError, BetterFetchResponse } from "@better-fetch/fetch";
|
|
8
|
+
export * from "nanostores";
|
|
9
|
+
export * from "@better-fetch/fetch";
|
|
10
|
+
|
|
11
|
+
//#region src/client/lynx/index.d.ts
|
|
12
|
+
type InferResolvedHooks<O extends BetterAuthClientOptions> = O extends {
|
|
13
|
+
plugins: Array<infer Plugin>;
|
|
14
|
+
} ? UnionToIntersection<Plugin extends {
|
|
15
|
+
getAtoms?: infer GetAtoms;
|
|
16
|
+
} ? 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]: () => ReturnType<Atoms[key]["get"]> } : {} : {} : {}> : {};
|
|
17
|
+
type ClientConfig = ReturnType<typeof getClientConfig>;
|
|
18
|
+
type ClientSession<Option extends BetterAuthClientOptions> = InferClientAPI<Option> extends {
|
|
19
|
+
getSession: () => Promise<infer Res>;
|
|
20
|
+
} ? Res extends BetterFetchResponse<infer S> ? S : Res : never;
|
|
21
|
+
/**
|
|
22
|
+
* Lynx client returned by `createAuthClient`.
|
|
23
|
+
*/
|
|
24
|
+
type LynxAuthClient<Option extends BetterAuthClientOptions> = UnionToIntersection<InferResolvedHooks<Option>> & InferClientAPI<Option> & InferActions<Option> & {
|
|
25
|
+
hydrateSession(session: NonNullable<ClientSession<Option>> | null): void;
|
|
26
|
+
useSession: () => {
|
|
27
|
+
data: ClientSession<Option>;
|
|
28
|
+
isPending: boolean;
|
|
29
|
+
error: BetterFetchError | null;
|
|
30
|
+
refetch: (queryParams?: {
|
|
31
|
+
query?: SessionQueryParams;
|
|
32
|
+
} | undefined) => Promise<void>;
|
|
33
|
+
};
|
|
34
|
+
$Infer: {
|
|
35
|
+
Session: NonNullable<ClientSession<Option>>;
|
|
36
|
+
};
|
|
37
|
+
$fetch: ClientConfig["$fetch"];
|
|
38
|
+
$store: ClientConfig["$store"];
|
|
39
|
+
$ERROR_CODES: PrettifyDeep<InferErrorCodes<Option> & typeof BASE_ERROR_CODES>;
|
|
40
|
+
};
|
|
41
|
+
declare function createAuthClient<Option extends BetterAuthClientOptions>(options?: Option | undefined): LynxAuthClient<Option>;
|
|
42
|
+
//#endregion
|
|
43
|
+
export { ExtractPluginField, HasRequiredKeys, InferPluginFieldFromTuple, IsAny, LynxAuthClient, OverrideMerge, Prettify, PrettifyDeep, RequiredKeysOf, StripEmptyObjects, type UnionToIntersection, createAuthClient, useStore };
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { getClientConfig } from "../config.mjs";
|
|
2
|
+
import { createDynamicPathProxy } from "../proxy.mjs";
|
|
3
|
+
import { useStore } from "./lynx-store.mjs";
|
|
4
|
+
import { capitalizeFirstLetter } from "@better-auth/core/utils/string";
|
|
5
|
+
//#region src/client/lynx/index.ts
|
|
6
|
+
function getAtomKey(str) {
|
|
7
|
+
return `use${capitalizeFirstLetter(str)}`;
|
|
8
|
+
}
|
|
9
|
+
function createAuthClient(options) {
|
|
10
|
+
const { pluginPathMethods, pluginsActions, pluginsAtoms, hydrateSession, $fetch, $store, atomListeners } = getClientConfig(options);
|
|
11
|
+
const resolvedHooks = {};
|
|
12
|
+
for (const [key, value] of Object.entries(pluginsAtoms)) resolvedHooks[getAtomKey(key)] = () => useStore(value);
|
|
13
|
+
return createDynamicPathProxy({
|
|
14
|
+
...pluginsActions,
|
|
15
|
+
...resolvedHooks,
|
|
16
|
+
hydrateSession,
|
|
17
|
+
$fetch,
|
|
18
|
+
$store
|
|
19
|
+
}, $fetch, pluginPathMethods, pluginsAtoms, atomListeners);
|
|
20
|
+
}
|
|
21
|
+
//#endregion
|
|
22
|
+
export { createAuthClient, useStore };
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { Store, StoreValue } from "nanostores";
|
|
2
|
+
import { DependencyList } from "@lynx-js/react";
|
|
3
|
+
|
|
4
|
+
//#region src/client/lynx/lynx-store.d.ts
|
|
5
|
+
type StoreKeys<T> = T extends {
|
|
6
|
+
setKey: (k: infer K, v: any) => unknown;
|
|
7
|
+
} ? K : never;
|
|
8
|
+
interface UseStoreOptions<SomeStore> {
|
|
9
|
+
/**
|
|
10
|
+
* @default
|
|
11
|
+
* ```ts
|
|
12
|
+
* [store, options.keys]
|
|
13
|
+
* ```
|
|
14
|
+
*/
|
|
15
|
+
deps?: DependencyList | undefined;
|
|
16
|
+
/**
|
|
17
|
+
* Will re-render components only on specific key changes.
|
|
18
|
+
*/
|
|
19
|
+
keys?: StoreKeys<SomeStore>[] | undefined;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Subscribe to store changes and get store's value.
|
|
23
|
+
*
|
|
24
|
+
* Can be used with store builder too.
|
|
25
|
+
*
|
|
26
|
+
* ```js
|
|
27
|
+
* import { useStore } from 'nanostores/react'
|
|
28
|
+
*
|
|
29
|
+
* import { router } from '../store/router'
|
|
30
|
+
*
|
|
31
|
+
* export const Layout = () => {
|
|
32
|
+
* let page = useStore(router)
|
|
33
|
+
* if (page.route === 'home') {
|
|
34
|
+
* return <HomePage />
|
|
35
|
+
* } else {
|
|
36
|
+
* return <Error404 />
|
|
37
|
+
* }
|
|
38
|
+
* }
|
|
39
|
+
* ```
|
|
40
|
+
*
|
|
41
|
+
* @param store Store instance.
|
|
42
|
+
* @returns Store value.
|
|
43
|
+
*/
|
|
44
|
+
declare function useStore<SomeStore extends Store>(store: SomeStore, options?: UseStoreOptions<SomeStore>): StoreValue<SomeStore>;
|
|
45
|
+
//#endregion
|
|
46
|
+
export { useStore };
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { listenKeys } from "nanostores";
|
|
2
|
+
import { useCallback, useRef, useSyncExternalStore } from "@lynx-js/react";
|
|
3
|
+
//#region src/client/lynx/lynx-store.ts
|
|
4
|
+
/**
|
|
5
|
+
* Subscribe to store changes and get store's value.
|
|
6
|
+
*
|
|
7
|
+
* Can be used with store builder too.
|
|
8
|
+
*
|
|
9
|
+
* ```js
|
|
10
|
+
* import { useStore } from 'nanostores/react'
|
|
11
|
+
*
|
|
12
|
+
* import { router } from '../store/router'
|
|
13
|
+
*
|
|
14
|
+
* export const Layout = () => {
|
|
15
|
+
* let page = useStore(router)
|
|
16
|
+
* if (page.route === 'home') {
|
|
17
|
+
* return <HomePage />
|
|
18
|
+
* } else {
|
|
19
|
+
* return <Error404 />
|
|
20
|
+
* }
|
|
21
|
+
* }
|
|
22
|
+
* ```
|
|
23
|
+
*
|
|
24
|
+
* @param store Store instance.
|
|
25
|
+
* @returns Store value.
|
|
26
|
+
*/
|
|
27
|
+
function useStore(store, options = {}) {
|
|
28
|
+
const snapshotRef = useRef(store.get());
|
|
29
|
+
const { keys, deps = [store, keys] } = options;
|
|
30
|
+
const subscribe = useCallback((onChange) => {
|
|
31
|
+
const emitChange = (value) => {
|
|
32
|
+
if (snapshotRef.current === value) return;
|
|
33
|
+
snapshotRef.current = value;
|
|
34
|
+
onChange();
|
|
35
|
+
};
|
|
36
|
+
emitChange(store.value);
|
|
37
|
+
if (keys?.length) return listenKeys(store, keys, emitChange);
|
|
38
|
+
return store.listen(emitChange);
|
|
39
|
+
}, deps);
|
|
40
|
+
const get = () => snapshotRef.current;
|
|
41
|
+
return useSyncExternalStore(subscribe, get, get);
|
|
42
|
+
}
|
|
43
|
+
//#endregion
|
|
44
|
+
export { useStore };
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
//#region src/client/online-manager.d.ts
|
|
2
|
+
type OnlineListener = (online: boolean) => void;
|
|
3
|
+
declare const kOnlineManager: unique symbol;
|
|
4
|
+
interface OnlineManager {
|
|
5
|
+
setOnline(online: boolean): void;
|
|
6
|
+
isOnline: boolean;
|
|
7
|
+
subscribe(listener: OnlineListener): () => void;
|
|
8
|
+
setup(): () => void;
|
|
9
|
+
}
|
|
10
|
+
//#endregion
|
|
11
|
+
export { OnlineListener, OnlineManager, kOnlineManager };
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
//#region src/client/online-manager.ts
|
|
2
|
+
const kOnlineManager = Symbol.for("better-auth:online-manager");
|
|
3
|
+
var WindowOnlineManager = class {
|
|
4
|
+
listeners = /* @__PURE__ */ new Set();
|
|
5
|
+
isOnline = typeof navigator !== "undefined" ? navigator.onLine : true;
|
|
6
|
+
subscribe(listener) {
|
|
7
|
+
this.listeners.add(listener);
|
|
8
|
+
return () => {
|
|
9
|
+
this.listeners.delete(listener);
|
|
10
|
+
};
|
|
11
|
+
}
|
|
12
|
+
setOnline(online) {
|
|
13
|
+
this.isOnline = online;
|
|
14
|
+
this.listeners.forEach((listener) => listener(online));
|
|
15
|
+
}
|
|
16
|
+
setup() {
|
|
17
|
+
if (typeof window === "undefined" || typeof window.addEventListener === "undefined") return () => {};
|
|
18
|
+
const onOnline = () => this.setOnline(true);
|
|
19
|
+
const onOffline = () => this.setOnline(false);
|
|
20
|
+
window.addEventListener("online", onOnline, false);
|
|
21
|
+
window.addEventListener("offline", onOffline, false);
|
|
22
|
+
return () => {
|
|
23
|
+
window.removeEventListener("online", onOnline, false);
|
|
24
|
+
window.removeEventListener("offline", onOffline, false);
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
};
|
|
28
|
+
function getGlobalOnlineManager() {
|
|
29
|
+
if (!globalThis[kOnlineManager]) globalThis[kOnlineManager] = new WindowOnlineManager();
|
|
30
|
+
return globalThis[kOnlineManager];
|
|
31
|
+
}
|
|
32
|
+
//#endregion
|
|
33
|
+
export { getGlobalOnlineManager, kOnlineManager };
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
//#region src/client/parser.d.ts
|
|
2
|
+
type ParseOptions = {
|
|
3
|
+
/** Throw errors instead of returning the original value */strict?: boolean | undefined; /** Log warnings when suspicious patterns are detected */
|
|
4
|
+
warnings?: boolean | undefined; /** Custom reviver function */
|
|
5
|
+
reviver?: ((key: string, value: any) => any) | undefined; /** Automatically convert ISO date strings to Date objects */
|
|
6
|
+
parseDates?: boolean | undefined;
|
|
7
|
+
};
|
|
8
|
+
declare function parseJSON<T = unknown>(value: unknown, options?: ParseOptions): T;
|
|
9
|
+
//#endregion
|
|
10
|
+
export { parseJSON };
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
//#region src/client/parser.ts
|
|
2
|
+
const PROTO_POLLUTION_PATTERNS = {
|
|
3
|
+
proto: /"(?:_|\\u0{2}5[Ff]){2}(?:p|\\u0{2}70)(?:r|\\u0{2}72)(?:o|\\u0{2}6[Ff])(?:t|\\u0{2}74)(?:o|\\u0{2}6[Ff])(?:_|\\u0{2}5[Ff]){2}"\s*:/,
|
|
4
|
+
constructor: /"(?:c|\\u0063)(?:o|\\u006[Ff])(?:n|\\u006[Ee])(?:s|\\u0073)(?:t|\\u0074)(?:r|\\u0072)(?:u|\\u0075)(?:c|\\u0063)(?:t|\\u0074)(?:o|\\u006[Ff])(?:r|\\u0072)"\s*:/,
|
|
5
|
+
protoShort: /"__proto__"\s*:/,
|
|
6
|
+
constructorShort: /"constructor"\s*:/
|
|
7
|
+
};
|
|
8
|
+
const JSON_SIGNATURE = /^\s*["[{]|^\s*-?\d{1,16}(\.\d{1,17})?([Ee][+-]?\d+)?\s*$/;
|
|
9
|
+
const SPECIAL_VALUES = {
|
|
10
|
+
true: true,
|
|
11
|
+
false: false,
|
|
12
|
+
null: null,
|
|
13
|
+
undefined: void 0,
|
|
14
|
+
nan: NaN,
|
|
15
|
+
infinity: Number.POSITIVE_INFINITY,
|
|
16
|
+
"-infinity": Number.NEGATIVE_INFINITY
|
|
17
|
+
};
|
|
18
|
+
const ISO_DATE_REGEX = /^(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2}):(\d{2})(?:\.(\d{1,7}))?(?:Z|([+-])(\d{2}):(\d{2}))$/;
|
|
19
|
+
function isValidDate(date) {
|
|
20
|
+
return date instanceof Date && !isNaN(date.getTime());
|
|
21
|
+
}
|
|
22
|
+
function parseISODate(value) {
|
|
23
|
+
const match = ISO_DATE_REGEX.exec(value);
|
|
24
|
+
if (!match) return null;
|
|
25
|
+
const [, year, month, day, hour, minute, second, ms, offsetSign, offsetHour, offsetMinute] = match;
|
|
26
|
+
const date = new Date(Date.UTC(parseInt(year, 10), parseInt(month, 10) - 1, parseInt(day, 10), parseInt(hour, 10), parseInt(minute, 10), parseInt(second, 10), ms ? parseInt(ms.padEnd(3, "0"), 10) : 0));
|
|
27
|
+
if (offsetSign) {
|
|
28
|
+
const offset = (parseInt(offsetHour, 10) * 60 + parseInt(offsetMinute, 10)) * (offsetSign === "+" ? -1 : 1);
|
|
29
|
+
date.setUTCMinutes(date.getUTCMinutes() + offset);
|
|
30
|
+
}
|
|
31
|
+
return isValidDate(date) ? date : null;
|
|
32
|
+
}
|
|
33
|
+
function betterJSONParse(value, options = {}) {
|
|
34
|
+
const { strict = false, warnings = false, reviver, parseDates = true } = options;
|
|
35
|
+
if (typeof value !== "string") return value;
|
|
36
|
+
const trimmed = value.trim();
|
|
37
|
+
const lowerValue = trimmed.toLowerCase();
|
|
38
|
+
if (lowerValue.length <= 9 && lowerValue in SPECIAL_VALUES) return SPECIAL_VALUES[lowerValue];
|
|
39
|
+
if (!JSON_SIGNATURE.test(trimmed)) {
|
|
40
|
+
if (strict) throw new SyntaxError("[better-json] Invalid JSON");
|
|
41
|
+
return value;
|
|
42
|
+
}
|
|
43
|
+
if (Object.entries(PROTO_POLLUTION_PATTERNS).some(([key, pattern]) => {
|
|
44
|
+
const matches = pattern.test(trimmed);
|
|
45
|
+
if (matches && warnings) console.warn(`[better-json] Detected potential prototype pollution attempt using ${key} pattern`);
|
|
46
|
+
return matches;
|
|
47
|
+
}) && strict) throw new Error("[better-json] Potential prototype pollution attempt detected");
|
|
48
|
+
try {
|
|
49
|
+
const secureReviver = (key, value) => {
|
|
50
|
+
if (key === "__proto__" || key === "constructor" && value && typeof value === "object" && "prototype" in value) {
|
|
51
|
+
if (warnings) console.warn(`[better-json] Dropping "${key}" key to prevent prototype pollution`);
|
|
52
|
+
return;
|
|
53
|
+
}
|
|
54
|
+
if (parseDates && typeof value === "string") {
|
|
55
|
+
const date = parseISODate(value);
|
|
56
|
+
if (date) return date;
|
|
57
|
+
}
|
|
58
|
+
return reviver ? reviver(key, value) : value;
|
|
59
|
+
};
|
|
60
|
+
return JSON.parse(trimmed, secureReviver);
|
|
61
|
+
} catch (error) {
|
|
62
|
+
if (strict) throw error;
|
|
63
|
+
return value;
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
function parseJSON(value, options = { strict: true }) {
|
|
67
|
+
return betterJSONParse(value, options);
|
|
68
|
+
}
|
|
69
|
+
//#endregion
|
|
70
|
+
export { parseJSON };
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
import { HasRequiredKeys, IsAny, Prettify as Prettify$1, UnionToIntersection } from "../types/helper.mjs";
|
|
2
|
+
import { InferAdditionalFromClient, InferSessionFromClient, InferUserFromClient } from "./types.mjs";
|
|
3
|
+
import { BetterAuthClientOptions, ClientFetchOption } from "@better-auth/core";
|
|
4
|
+
import { SocialProviderList } from "@better-auth/core/social-providers";
|
|
5
|
+
import { Endpoint, InputContext, StandardSchemaV1 as StandardSchemaV1$1 } from "better-call";
|
|
6
|
+
import { BetterFetchResponse } from "@better-fetch/fetch";
|
|
7
|
+
|
|
8
|
+
//#region src/client/path-to-object.d.ts
|
|
9
|
+
/**
|
|
10
|
+
* Extract generic OAuth provider IDs from the client options.
|
|
11
|
+
* Supports both `$InferAuth` (server type bridge) and client plugins
|
|
12
|
+
* with `$InferServerPlugin`.
|
|
13
|
+
*/
|
|
14
|
+
type InferGenericOAuthProviderIds<O extends BetterAuthClientOptions> = (O extends {
|
|
15
|
+
$InferAuth: {
|
|
16
|
+
options: {
|
|
17
|
+
plugins: Array<infer P>;
|
|
18
|
+
};
|
|
19
|
+
};
|
|
20
|
+
} ? P extends {
|
|
21
|
+
id: "generic-oauth";
|
|
22
|
+
options: {
|
|
23
|
+
config: Array<{
|
|
24
|
+
providerId: infer ID;
|
|
25
|
+
}>;
|
|
26
|
+
};
|
|
27
|
+
} ? ID & string : never : never) | (O extends {
|
|
28
|
+
plugins: Array<infer P>;
|
|
29
|
+
} ? P extends {
|
|
30
|
+
$InferServerPlugin: {
|
|
31
|
+
id: "generic-oauth";
|
|
32
|
+
options: {
|
|
33
|
+
config: Array<{
|
|
34
|
+
providerId: infer ID;
|
|
35
|
+
}>;
|
|
36
|
+
};
|
|
37
|
+
};
|
|
38
|
+
} ? ID & string : never : never);
|
|
39
|
+
type KeepNullishFromOriginal<Original, Replaced> = Replaced | (undefined extends Original ? undefined : never) | (null extends Original ? null : never);
|
|
40
|
+
type ReplaceTopLevelField<Data, Field extends "user" | "session", Replaced> = Data extends object ? Field extends keyof Data ? Omit<Data, Field> & { [K in Field]: KeepNullishFromOriginal<Data[K], Replaced> } : Data : Data;
|
|
41
|
+
type ReplaceAuthUserAndSession<Data, ClientOpts extends BetterAuthClientOptions> = ReplaceTopLevelField<ReplaceTopLevelField<Data, "user", InferUserFromClient<ClientOpts>>, "session", InferSessionFromClient<ClientOpts>>;
|
|
42
|
+
type MergeCustomSessionField<R extends object, Field extends "user" | "session", InferType> = Field extends keyof R ? { [K in Field]: KeepNullishFromOriginal<R[K], NonNullable<R[K]> & InferType> } : {};
|
|
43
|
+
type MergeCustomSessionWithInferred<R, ClientOpts extends BetterAuthClientOptions> = R extends object ? Omit<R, "user" | "session"> & MergeCustomSessionField<R, "user", InferUserFromClient<ClientOpts>> & MergeCustomSessionField<R, "session", InferSessionFromClient<ClientOpts>> : never;
|
|
44
|
+
type RefineAuthResponse<Data, ClientOpts extends BetterAuthClientOptions> = Data extends {
|
|
45
|
+
token: unknown;
|
|
46
|
+
} | {
|
|
47
|
+
redirect: unknown;
|
|
48
|
+
} ? ReplaceAuthUserAndSession<Data, ClientOpts> : Data;
|
|
49
|
+
type CamelCase<S extends string> = S extends `${infer P1}-${infer P2}${infer P3}` ? `${Lowercase<P1>}${Uppercase<P2>}${CamelCase<P3>}` : Lowercase<S>;
|
|
50
|
+
type PathToObject<T extends string, Fn extends (...args: any[]) => any> = T extends `/${infer Segment}/${infer Rest}` ? { [K in CamelCase<Segment>]: PathToObject<`/${Rest}`, Fn> } : T extends `/${infer Segment}` ? { [K in CamelCase<Segment>]: Fn } : never;
|
|
51
|
+
type InferSignUpEmailCtx<ClientOpts extends BetterAuthClientOptions, FetchOptions extends ClientFetchOption> = {
|
|
52
|
+
email: string;
|
|
53
|
+
name: string;
|
|
54
|
+
password: string;
|
|
55
|
+
image?: string | undefined;
|
|
56
|
+
callbackURL?: string | undefined;
|
|
57
|
+
fetchOptions?: FetchOptions | undefined;
|
|
58
|
+
} & UnionToIntersection<InferAdditionalFromClient<ClientOpts, "user", "input">>;
|
|
59
|
+
type InferUserUpdateCtx<ClientOpts extends BetterAuthClientOptions, FetchOptions extends ClientFetchOption> = {
|
|
60
|
+
image?: (string | null) | undefined;
|
|
61
|
+
name?: string | undefined;
|
|
62
|
+
fetchOptions?: FetchOptions | undefined;
|
|
63
|
+
} & Partial<UnionToIntersection<InferAdditionalFromClient<ClientOpts, "user", "input">>>;
|
|
64
|
+
type InferSessionUpdateCtx<ClientOpts extends BetterAuthClientOptions, FetchOptions extends ClientFetchOption> = {
|
|
65
|
+
fetchOptions?: FetchOptions | undefined;
|
|
66
|
+
} & Partial<UnionToIntersection<InferAdditionalFromClient<ClientOpts, "session", "input">>>;
|
|
67
|
+
type InferCtxQuery<C extends InputContext<any, any>, FetchOptions extends ClientFetchOption> = C["query"] extends Record<string, any> ? {
|
|
68
|
+
query: C["query"];
|
|
69
|
+
fetchOptions?: FetchOptions | undefined;
|
|
70
|
+
} : C["query"] extends Record<string, any> | undefined ? {
|
|
71
|
+
query?: C["query"] | undefined;
|
|
72
|
+
fetchOptions?: FetchOptions | undefined;
|
|
73
|
+
} : {
|
|
74
|
+
fetchOptions?: FetchOptions | undefined;
|
|
75
|
+
};
|
|
76
|
+
type InferBodyCtx<Body, FetchOptions extends ClientFetchOption> = Body extends Record<string, unknown> ? Body & {
|
|
77
|
+
fetchOptions?: FetchOptions | undefined;
|
|
78
|
+
} : never;
|
|
79
|
+
type PrettifyUnion<T> = T extends unknown ? Prettify$1<T> : never;
|
|
80
|
+
type HasRequiredKeysInUnion<T> = true extends (T extends unknown ? HasRequiredKeys<T> : never) ? true : false;
|
|
81
|
+
type HasRequiredCtx<C extends InputContext<any, any>, FetchOptions extends ClientFetchOption> = IsAny<C["body"]> extends true ? HasRequiredKeysInUnion<InferCtx<C, FetchOptions>> : undefined extends C["body"] ? HasRequiredKeysInUnion<InferCtxQuery<C, FetchOptions>> : HasRequiredKeysInUnion<InferCtx<C, FetchOptions>>;
|
|
82
|
+
type InferCtx<C extends InputContext<any, any>, FetchOptions extends ClientFetchOption> = IsAny<C["body"]> extends true ? InferCtxQuery<C, FetchOptions> : [NonNullable<C["body"]>] extends [never] ? InferCtxQuery<C, FetchOptions> : NonNullable<C["body"]> extends Record<string, any> ? InferBodyCtx<NonNullable<C["body"]>, FetchOptions> : InferCtxQuery<C, FetchOptions>;
|
|
83
|
+
type MergeRoutes<T> = UnionToIntersection<T>;
|
|
84
|
+
type InferRoute<API, COpts extends BetterAuthClientOptions> = API extends Record<string, infer T> ? T extends Endpoint ? T["options"]["metadata"] extends {
|
|
85
|
+
isAction: false;
|
|
86
|
+
} | {
|
|
87
|
+
SERVER_ONLY: true;
|
|
88
|
+
} | {
|
|
89
|
+
scope: "http";
|
|
90
|
+
} | {
|
|
91
|
+
scope: "server";
|
|
92
|
+
} ? {} : PathToObject<T["path"], T extends ((ctx: infer C) => infer R) ? C extends InputContext<any, any> ? <FetchOptions extends ClientFetchOption<Partial<C["body"]> & Record<string, any>, Partial<C["query"]> & Record<string, any>, C["params"]>>(...data: HasRequiredCtx<C, FetchOptions> extends true ? [PrettifyUnion<T["path"] extends `/sign-up/email` ? InferSignUpEmailCtx<COpts, FetchOptions> : T["path"] extends `/sign-in/social` ? Omit<InferCtx<C, FetchOptions>, "provider"> & {
|
|
93
|
+
provider: SocialProviderList[number] | InferGenericOAuthProviderIds<COpts> | (string & {});
|
|
94
|
+
fetchOptions?: FetchOptions | undefined;
|
|
95
|
+
} : InferCtx<C, FetchOptions>>, FetchOptions?] : [PrettifyUnion<T["path"] extends `/update-user` ? InferUserUpdateCtx<COpts, FetchOptions> : T["path"] extends `/update-session` ? InferSessionUpdateCtx<COpts, FetchOptions> : InferCtx<C, FetchOptions>>?, FetchOptions?]) => Promise<BetterFetchResponse<T["options"]["metadata"] extends {
|
|
96
|
+
CUSTOM_SESSION: boolean;
|
|
97
|
+
} ? MergeCustomSessionWithInferred<NonNullable<Awaited<R>>, COpts> : T["path"] extends "/get-session" ? {
|
|
98
|
+
user: InferUserFromClient<COpts>;
|
|
99
|
+
session: InferSessionFromClient<COpts>;
|
|
100
|
+
} | null : RefineAuthResponse<NonNullable<Awaited<R>>, COpts>, T["options"]["error"] extends StandardSchemaV1$1 ? NonNullable<T["options"]["error"]["~standard"]["types"]>["output"] : {
|
|
101
|
+
code?: string | undefined;
|
|
102
|
+
message?: string | undefined;
|
|
103
|
+
}, FetchOptions["throw"] extends true ? true : COpts["fetchOptions"] extends {
|
|
104
|
+
throw: true;
|
|
105
|
+
} ? true : false>> : never : never> : {} : never;
|
|
106
|
+
type InferRoutes<API extends Record<string, unknown>, ClientOpts extends BetterAuthClientOptions> = MergeRoutes<InferRoute<API, ClientOpts>>;
|
|
107
|
+
type ProxyRequest = {
|
|
108
|
+
options?: ClientFetchOption<any, any> | undefined;
|
|
109
|
+
query?: any | undefined;
|
|
110
|
+
[key: string]: any;
|
|
111
|
+
};
|
|
112
|
+
//#endregion
|
|
113
|
+
export { CamelCase, InferCtx, InferRoute, InferRoutes, InferSessionUpdateCtx, InferSignUpEmailCtx, InferUserUpdateCtx, MergeRoutes, PathToObject, ProxyRequest };
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { FieldAttributeToObject, RemoveFieldsWithReturnedFalse } from "../../db/field.mjs";
|
|
2
|
+
import { ExtractPluginField, HasRequiredKeys, InferPluginFieldFromTuple, IsAny, OverrideMerge, Prettify, PrettifyDeep, RequiredKeysOf, StripEmptyObjects, UnionToIntersection } from "../../types/helper.mjs";
|
|
3
|
+
import { InferInvitation, InferMember, InferOrganization, InferOrganizationRolesFromOption, InferOrganizationZodRolesFromOption, InferTeam, Invitation, InvitationInput, InvitationStatus, Member, MemberInput, Organization, OrganizationInput, OrganizationRole, OrganizationSchema, Team, TeamInput, TeamMember, TeamMemberInput, defaultRolesSchema, invitationSchema, invitationStatus, memberSchema, organizationRoleSchema, organizationSchema, roleSchema, teamMemberSchema, teamSchema } from "../../plugins/organization/schema.mjs";
|
|
4
|
+
import { AdminOptions, InferAdminRolesFromOption, SessionWithImpersonatedBy, UserWithRole } from "../../plugins/admin/types.mjs";
|
|
5
|
+
import { schema } from "../../plugins/anonymous/schema.mjs";
|
|
6
|
+
import { AnonymousOptions, AnonymousSession, UserWithAnonymous } from "../../plugins/anonymous/types.mjs";
|
|
7
|
+
import { JWKOptions, JWSAlgorithms, Jwk, JwtOptions, ResolvedSigningKey } from "../../plugins/jwt/types.mjs";
|
|
8
|
+
import { MULTI_SESSION_ERROR_CODES } from "../../plugins/multi-session/error-codes.mjs";
|
|
9
|
+
import { MultiSessionConfig } from "../../plugins/multi-session/index.mjs";
|
|
10
|
+
import { POPUP_TOKEN_STORAGE_KEY } from "../../plugins/oauth-popup/constants.mjs";
|
|
11
|
+
import { OAUTH_POPUP_ERROR_CODES } from "../../plugins/oauth-popup/error-codes.mjs";
|
|
12
|
+
import { OneTimeTokenOptions } from "../../plugins/one-time-token/index.mjs";
|
|
13
|
+
import { PhoneNumberOptions, UserWithPhoneNumber } from "../../plugins/phone-number/types.mjs";
|
|
14
|
+
import { BackupCodeOptions, backupCode2fa, encodeBackupCodes, generateBackupCodes, getBackupCodes, verifyBackupCode } from "../../plugins/two-factor/backup-codes/index.mjs";
|
|
15
|
+
import { OTPOptions, otp2fa } from "../../plugins/two-factor/otp/index.mjs";
|
|
16
|
+
import { TOTPOptions, totp2fa } from "../../plugins/two-factor/totp/index.mjs";
|
|
17
|
+
import { TwoFactorOptions, TwoFactorProvider, TwoFactorTable, UserWithTwoFactor } from "../../plugins/two-factor/types.mjs";
|
|
18
|
+
import { TWO_FACTOR_ERROR_CODES } from "../../plugins/two-factor/error-code.mjs";
|
|
19
|
+
import { twoFactorClient } from "../../plugins/two-factor/client.mjs";
|
|
20
|
+
import { USERNAME_ERROR_CODES } from "../../plugins/username/error-codes.mjs";
|
|
21
|
+
import { ORGANIZATION_ERROR_CODES } from "../../plugins/organization/error-codes.mjs";
|
|
22
|
+
import { inferAdditionalFields } from "../../plugins/additional-fields/client.mjs";
|
|
23
|
+
import { ADMIN_ERROR_CODES } from "../../plugins/admin/error-codes.mjs";
|
|
24
|
+
import { AdminClientOptions, adminClient } from "../../plugins/admin/client.mjs";
|
|
25
|
+
import { ANONYMOUS_ERROR_CODES } from "../../plugins/anonymous/error-codes.mjs";
|
|
26
|
+
import { anonymousClient } from "../../plugins/anonymous/client.mjs";
|
|
27
|
+
import { customSessionClient } from "../../plugins/custom-session/client.mjs";
|
|
28
|
+
import { deviceAuthorizationClient } from "../../plugins/device-authorization/client.mjs";
|
|
29
|
+
import { EMAIL_OTP_ERROR_CODES } from "../../plugins/email-otp/error-codes.mjs";
|
|
30
|
+
import { emailOTPClient } from "../../plugins/email-otp/client.mjs";
|
|
31
|
+
import { jwtClient } from "../../plugins/jwt/client.mjs";
|
|
32
|
+
import { LastLoginMethodClientConfig, lastLoginMethodClient } from "../../plugins/last-login-method/client.mjs";
|
|
33
|
+
import { magicLinkClient } from "../../plugins/magic-link/client.mjs";
|
|
34
|
+
import { multiSessionClient } from "../../plugins/multi-session/client.mjs";
|
|
35
|
+
import { SignInPopupOptions, SignInPopupResult, createSignInPopup, getStoredPopupToken, oauthPopupClient, popupBearerFetchPlugin } from "../../plugins/oauth-popup/client.mjs";
|
|
36
|
+
import { GoogleOneTapActionOptions, GoogleOneTapOptions, GsiButtonConfiguration, oneTapClient } from "../../plugins/one-tap/client.mjs";
|
|
37
|
+
import { oneTimeTokenClient } from "../../plugins/one-time-token/client.mjs";
|
|
38
|
+
import { OrganizationClientOptions, clientSideHasPermission, inferOrgAdditionalFields, organizationClient } from "../../plugins/organization/client.mjs";
|
|
39
|
+
import { PHONE_NUMBER_ERROR_CODES } from "../../plugins/phone-number/error-codes.mjs";
|
|
40
|
+
import { phoneNumberClient } from "../../plugins/phone-number/client.mjs";
|
|
41
|
+
import { siweClient } from "../../plugins/siwe/client.mjs";
|
|
42
|
+
import { UsernameClientOptions, usernameClient } from "../../plugins/username/client.mjs";
|
|
43
|
+
import { InferServerPlugin } from "./infer-plugin.mjs";
|
|
44
|
+
export { ADMIN_ERROR_CODES, ANONYMOUS_ERROR_CODES, AdminClientOptions, AdminOptions, AnonymousOptions, AnonymousSession, BackupCodeOptions, EMAIL_OTP_ERROR_CODES, ExtractPluginField, type FieldAttributeToObject, GoogleOneTapActionOptions, GoogleOneTapOptions, GsiButtonConfiguration, HasRequiredKeys, InferAdminRolesFromOption, InferInvitation, InferMember, InferOrganization, InferOrganizationRolesFromOption, InferOrganizationZodRolesFromOption, InferPluginFieldFromTuple, InferServerPlugin, InferTeam, Invitation, InvitationInput, InvitationStatus, IsAny, JWKOptions, JWSAlgorithms, Jwk, JwtOptions, LastLoginMethodClientConfig, MULTI_SESSION_ERROR_CODES, Member, MemberInput, MultiSessionConfig, OAUTH_POPUP_ERROR_CODES, ORGANIZATION_ERROR_CODES, OTPOptions, OneTimeTokenOptions, Organization, OrganizationClientOptions, OrganizationInput, OrganizationRole, OrganizationSchema, OverrideMerge, PHONE_NUMBER_ERROR_CODES, POPUP_TOKEN_STORAGE_KEY, PhoneNumberOptions, Prettify, PrettifyDeep, type RemoveFieldsWithReturnedFalse, RequiredKeysOf, ResolvedSigningKey, SessionWithImpersonatedBy, SignInPopupOptions, SignInPopupResult, StripEmptyObjects, TOTPOptions, TWO_FACTOR_ERROR_CODES, Team, TeamInput, TeamMember, TeamMemberInput, TwoFactorOptions, TwoFactorProvider, TwoFactorTable, USERNAME_ERROR_CODES, UnionToIntersection, UserWithAnonymous, UserWithPhoneNumber, UserWithRole, UserWithTwoFactor, UsernameClientOptions, adminClient, anonymousClient, backupCode2fa, clientSideHasPermission, createSignInPopup, customSessionClient, defaultRolesSchema, deviceAuthorizationClient, emailOTPClient, encodeBackupCodes, generateBackupCodes, getBackupCodes, getStoredPopupToken, inferAdditionalFields, inferOrgAdditionalFields, invitationSchema, invitationStatus, jwtClient, lastLoginMethodClient, magicLinkClient, memberSchema, multiSessionClient, oauthPopupClient, oneTapClient, oneTimeTokenClient, organizationClient, organizationRoleSchema, organizationSchema, otp2fa, phoneNumberClient, popupBearerFetchPlugin, roleSchema, schema, siweClient, teamMemberSchema, teamSchema, totp2fa, twoFactorClient, usernameClient, verifyBackupCode };
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { inferAdditionalFields } from "../../plugins/additional-fields/client.mjs";
|
|
2
|
+
import { ADMIN_ERROR_CODES } from "../../plugins/admin/error-codes.mjs";
|
|
3
|
+
import { adminClient } from "../../plugins/admin/client.mjs";
|
|
4
|
+
import { ANONYMOUS_ERROR_CODES } from "../../plugins/anonymous/error-codes.mjs";
|
|
5
|
+
import { anonymousClient } from "../../plugins/anonymous/client.mjs";
|
|
6
|
+
import { customSessionClient } from "../../plugins/custom-session/client.mjs";
|
|
7
|
+
import { deviceAuthorizationClient } from "../../plugins/device-authorization/client.mjs";
|
|
8
|
+
import { EMAIL_OTP_ERROR_CODES } from "../../plugins/email-otp/error-codes.mjs";
|
|
9
|
+
import { emailOTPClient } from "../../plugins/email-otp/client.mjs";
|
|
10
|
+
import { jwtClient } from "../../plugins/jwt/client.mjs";
|
|
11
|
+
import { lastLoginMethodClient } from "../../plugins/last-login-method/client.mjs";
|
|
12
|
+
import { magicLinkClient } from "../../plugins/magic-link/client.mjs";
|
|
13
|
+
import { MULTI_SESSION_ERROR_CODES } from "../../plugins/multi-session/error-codes.mjs";
|
|
14
|
+
import { multiSessionClient } from "../../plugins/multi-session/client.mjs";
|
|
15
|
+
import { POPUP_TOKEN_STORAGE_KEY } from "../../plugins/oauth-popup/constants.mjs";
|
|
16
|
+
import { OAUTH_POPUP_ERROR_CODES } from "../../plugins/oauth-popup/error-codes.mjs";
|
|
17
|
+
import { createSignInPopup, getStoredPopupToken, oauthPopupClient, popupBearerFetchPlugin } from "../../plugins/oauth-popup/client.mjs";
|
|
18
|
+
import { oneTapClient } from "../../plugins/one-tap/client.mjs";
|
|
19
|
+
import { oneTimeTokenClient } from "../../plugins/one-time-token/client.mjs";
|
|
20
|
+
import { ORGANIZATION_ERROR_CODES } from "../../plugins/organization/error-codes.mjs";
|
|
21
|
+
import { clientSideHasPermission, inferOrgAdditionalFields, organizationClient } from "../../plugins/organization/client.mjs";
|
|
22
|
+
import { PHONE_NUMBER_ERROR_CODES } from "../../plugins/phone-number/error-codes.mjs";
|
|
23
|
+
import { phoneNumberClient } from "../../plugins/phone-number/client.mjs";
|
|
24
|
+
import { siweClient } from "../../plugins/siwe/client.mjs";
|
|
25
|
+
import { TWO_FACTOR_ERROR_CODES } from "../../plugins/two-factor/error-code.mjs";
|
|
26
|
+
import { twoFactorClient } from "../../plugins/two-factor/client.mjs";
|
|
27
|
+
import { USERNAME_ERROR_CODES } from "../../plugins/username/error-codes.mjs";
|
|
28
|
+
import { usernameClient } from "../../plugins/username/client.mjs";
|
|
29
|
+
import { InferServerPlugin } from "./infer-plugin.mjs";
|
|
30
|
+
export { ADMIN_ERROR_CODES, ANONYMOUS_ERROR_CODES, EMAIL_OTP_ERROR_CODES, InferServerPlugin, MULTI_SESSION_ERROR_CODES, OAUTH_POPUP_ERROR_CODES, ORGANIZATION_ERROR_CODES, PHONE_NUMBER_ERROR_CODES, POPUP_TOKEN_STORAGE_KEY, TWO_FACTOR_ERROR_CODES, USERNAME_ERROR_CODES, adminClient, anonymousClient, clientSideHasPermission, createSignInPopup, customSessionClient, deviceAuthorizationClient, emailOTPClient, getStoredPopupToken, inferAdditionalFields, inferOrgAdditionalFields, jwtClient, lastLoginMethodClient, magicLinkClient, multiSessionClient, oauthPopupClient, oneTapClient, oneTimeTokenClient, organizationClient, phoneNumberClient, popupBearerFetchPlugin, siweClient, twoFactorClient, usernameClient };
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { BetterAuthOptions } from "@better-auth/core";
|
|
2
|
+
|
|
3
|
+
//#region src/client/plugins/infer-plugin.d.ts
|
|
4
|
+
declare const InferServerPlugin: <AuthOrOption extends BetterAuthOptions | {
|
|
5
|
+
options: BetterAuthOptions;
|
|
6
|
+
}, ID extends string>() => {
|
|
7
|
+
id: "infer-server-plugin";
|
|
8
|
+
version: string;
|
|
9
|
+
$InferServerPlugin: (AuthOrOption extends {
|
|
10
|
+
options: infer O;
|
|
11
|
+
} ? O : AuthOrOption)["plugins"] extends (infer P)[] ? P extends {
|
|
12
|
+
id: ID;
|
|
13
|
+
} ? P : never : never;
|
|
14
|
+
};
|
|
15
|
+
//#endregion
|
|
16
|
+
export { InferServerPlugin };
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { PACKAGE_VERSION } from "../../version.mjs";
|
|
2
|
+
//#region src/client/plugins/infer-plugin.ts
|
|
3
|
+
const InferServerPlugin = () => {
|
|
4
|
+
return {
|
|
5
|
+
id: "infer-server-plugin",
|
|
6
|
+
version: PACKAGE_VERSION,
|
|
7
|
+
$InferServerPlugin: {}
|
|
8
|
+
};
|
|
9
|
+
};
|
|
10
|
+
//#endregion
|
|
11
|
+
export { InferServerPlugin };
|