This is page 44 of 49. Use http://codebase.md/better-auth/better-auth?page={x} to view the full context. # Directory Structure ``` ├── .gitattributes ├── .github │ ├── CODEOWNERS │ ├── FUNDING.yml │ ├── ISSUE_TEMPLATE │ │ ├── bug_report.yml │ │ └── feature_request.yml │ ├── renovate.json5 │ └── workflows │ ├── ci.yml │ ├── e2e.yml │ ├── preview.yml │ └── release.yml ├── .gitignore ├── .npmrc ├── .nvmrc ├── .vscode │ └── settings.json ├── banner-dark.png ├── banner.png ├── biome.json ├── bump.config.ts ├── CODE_OF_CONDUCT.md ├── CONTRIBUTING.md ├── demo │ ├── expo-example │ │ ├── .env.example │ │ ├── .gitignore │ │ ├── app.config.ts │ │ ├── assets │ │ │ ├── bg-image.jpeg │ │ │ ├── fonts │ │ │ │ └── SpaceMono-Regular.ttf │ │ │ ├── icon.png │ │ │ └── images │ │ │ ├── adaptive-icon.png │ │ │ ├── favicon.png │ │ │ ├── logo.png │ │ │ ├── partial-react-logo.png │ │ │ ├── react-logo.png │ │ │ ├── [email protected] │ │ │ ├── [email protected] │ │ │ └── splash.png │ │ ├── babel.config.js │ │ ├── components.json │ │ ├── expo-env.d.ts │ │ ├── index.ts │ │ ├── metro.config.js │ │ ├── nativewind-env.d.ts │ │ ├── package.json │ │ ├── README.md │ │ ├── src │ │ │ ├── app │ │ │ │ ├── _layout.tsx │ │ │ │ ├── api │ │ │ │ │ └── auth │ │ │ │ │ └── [...route]+api.ts │ │ │ │ ├── dashboard.tsx │ │ │ │ ├── forget-password.tsx │ │ │ │ ├── index.tsx │ │ │ │ └── sign-up.tsx │ │ │ ├── components │ │ │ │ ├── icons │ │ │ │ │ └── google.tsx │ │ │ │ └── ui │ │ │ │ ├── avatar.tsx │ │ │ │ ├── button.tsx │ │ │ │ ├── card.tsx │ │ │ │ ├── dialog.tsx │ │ │ │ ├── input.tsx │ │ │ │ ├── separator.tsx │ │ │ │ └── text.tsx │ │ │ ├── global.css │ │ │ └── lib │ │ │ ├── auth-client.ts │ │ │ ├── auth.ts │ │ │ ├── icons │ │ │ │ ├── iconWithClassName.ts │ │ │ │ └── X.tsx │ │ │ └── utils.ts │ │ ├── tailwind.config.js │ │ └── tsconfig.json │ └── nextjs │ ├── .env.example │ ├── .gitignore │ ├── app │ │ ├── (auth) │ │ │ ├── forget-password │ │ │ │ └── page.tsx │ │ │ ├── reset-password │ │ │ │ └── page.tsx │ │ │ ├── sign-in │ │ │ │ ├── loading.tsx │ │ │ │ └── page.tsx │ │ │ └── two-factor │ │ │ ├── otp │ │ │ │ └── page.tsx │ │ │ └── page.tsx │ │ ├── accept-invitation │ │ │ └── [id] │ │ │ ├── invitation-error.tsx │ │ │ └── page.tsx │ │ ├── admin │ │ │ └── page.tsx │ │ ├── api │ │ │ └── auth │ │ │ └── [...all] │ │ │ └── route.ts │ │ ├── apps │ │ │ └── register │ │ │ └── page.tsx │ │ ├── client-test │ │ │ └── page.tsx │ │ ├── dashboard │ │ │ ├── change-plan.tsx │ │ │ ├── client.tsx │ │ │ ├── organization-card.tsx │ │ │ ├── page.tsx │ │ │ ├── upgrade-button.tsx │ │ │ └── user-card.tsx │ │ ├── device │ │ │ ├── approve │ │ │ │ └── page.tsx │ │ │ ├── denied │ │ │ │ └── page.tsx │ │ │ ├── layout.tsx │ │ │ ├── page.tsx │ │ │ └── success │ │ │ └── page.tsx │ │ ├── favicon.ico │ │ ├── features.tsx │ │ ├── fonts │ │ │ ├── GeistMonoVF.woff │ │ │ └── GeistVF.woff │ │ ├── globals.css │ │ ├── layout.tsx │ │ ├── oauth │ │ │ └── authorize │ │ │ ├── concet-buttons.tsx │ │ │ └── page.tsx │ │ ├── page.tsx │ │ └── pricing │ │ └── page.tsx │ ├── components │ │ ├── account-switch.tsx │ │ ├── blocks │ │ │ └── pricing.tsx │ │ ├── logo.tsx │ │ ├── one-tap.tsx │ │ ├── sign-in-btn.tsx │ │ ├── sign-in.tsx │ │ ├── sign-up.tsx │ │ ├── theme-provider.tsx │ │ ├── theme-toggle.tsx │ │ ├── tier-labels.tsx │ │ ├── ui │ │ │ ├── accordion.tsx │ │ │ ├── alert-dialog.tsx │ │ │ ├── alert.tsx │ │ │ ├── aspect-ratio.tsx │ │ │ ├── avatar.tsx │ │ │ ├── badge.tsx │ │ │ ├── breadcrumb.tsx │ │ │ ├── button.tsx │ │ │ ├── calendar.tsx │ │ │ ├── card.tsx │ │ │ ├── carousel.tsx │ │ │ ├── chart.tsx │ │ │ ├── checkbox.tsx │ │ │ ├── collapsible.tsx │ │ │ ├── command.tsx │ │ │ ├── context-menu.tsx │ │ │ ├── copy-button.tsx │ │ │ ├── dialog.tsx │ │ │ ├── drawer.tsx │ │ │ ├── dropdown-menu.tsx │ │ │ ├── form.tsx │ │ │ ├── hover-card.tsx │ │ │ ├── input-otp.tsx │ │ │ ├── input.tsx │ │ │ ├── label.tsx │ │ │ ├── menubar.tsx │ │ │ ├── navigation-menu.tsx │ │ │ ├── pagination.tsx │ │ │ ├── password-input.tsx │ │ │ ├── popover.tsx │ │ │ ├── progress.tsx │ │ │ ├── radio-group.tsx │ │ │ ├── resizable.tsx │ │ │ ├── scroll-area.tsx │ │ │ ├── select.tsx │ │ │ ├── separator.tsx │ │ │ ├── sheet.tsx │ │ │ ├── skeleton.tsx │ │ │ ├── slider.tsx │ │ │ ├── sonner.tsx │ │ │ ├── switch.tsx │ │ │ ├── table.tsx │ │ │ ├── tabs.tsx │ │ │ ├── tabs2.tsx │ │ │ ├── textarea.tsx │ │ │ ├── toast.tsx │ │ │ ├── toaster.tsx │ │ │ ├── toggle-group.tsx │ │ │ ├── toggle.tsx │ │ │ └── tooltip.tsx │ │ └── wrapper.tsx │ ├── components.json │ ├── hooks │ │ └── use-toast.ts │ ├── lib │ │ ├── auth-client.ts │ │ ├── auth-types.ts │ │ ├── auth.ts │ │ ├── email │ │ │ ├── invitation.tsx │ │ │ ├── resend.ts │ │ │ └── reset-password.tsx │ │ ├── metadata.ts │ │ ├── shared.ts │ │ └── utils.ts │ ├── middleware.ts │ ├── next.config.ts │ ├── package.json │ ├── postcss.config.mjs │ ├── public │ │ ├── __og.png │ │ ├── _og.png │ │ ├── favicon │ │ │ ├── android-chrome-192x192.png │ │ │ ├── android-chrome-512x512.png │ │ │ ├── apple-touch-icon.png │ │ │ ├── favicon-16x16.png │ │ │ ├── favicon-32x32.png │ │ │ ├── favicon.ico │ │ │ ├── light │ │ │ │ ├── android-chrome-192x192.png │ │ │ │ ├── android-chrome-512x512.png │ │ │ │ ├── apple-touch-icon.png │ │ │ │ ├── favicon-16x16.png │ │ │ │ ├── favicon-32x32.png │ │ │ │ ├── favicon.ico │ │ │ │ └── site.webmanifest │ │ │ └── site.webmanifest │ │ ├── logo.svg │ │ └── og.png │ ├── README.md │ ├── tailwind.config.ts │ ├── tsconfig.json │ └── turbo.json ├── docker-compose.yml ├── docs │ ├── .env.example │ ├── .gitignore │ ├── app │ │ ├── api │ │ │ ├── ai-chat │ │ │ │ └── route.ts │ │ │ ├── analytics │ │ │ │ ├── conversation │ │ │ │ │ └── route.ts │ │ │ │ ├── event │ │ │ │ │ └── route.ts │ │ │ │ └── feedback │ │ │ │ └── route.ts │ │ │ ├── chat │ │ │ │ └── route.ts │ │ │ ├── og │ │ │ │ └── route.tsx │ │ │ ├── og-release │ │ │ │ └── route.tsx │ │ │ ├── search │ │ │ │ └── route.ts │ │ │ └── support │ │ │ └── route.ts │ │ ├── blog │ │ │ ├── _components │ │ │ │ ├── _layout.tsx │ │ │ │ ├── blog-list.tsx │ │ │ │ ├── changelog-layout.tsx │ │ │ │ ├── default-changelog.tsx │ │ │ │ ├── fmt-dates.tsx │ │ │ │ ├── icons.tsx │ │ │ │ ├── stat-field.tsx │ │ │ │ └── support.tsx │ │ │ ├── [[...slug]] │ │ │ │ └── page.tsx │ │ │ └── layout.tsx │ │ ├── changelogs │ │ │ ├── _components │ │ │ │ ├── _layout.tsx │ │ │ │ ├── changelog-layout.tsx │ │ │ │ ├── default-changelog.tsx │ │ │ │ ├── fmt-dates.tsx │ │ │ │ ├── grid-pattern.tsx │ │ │ │ ├── icons.tsx │ │ │ │ └── stat-field.tsx │ │ │ ├── [[...slug]] │ │ │ │ └── page.tsx │ │ │ └── layout.tsx │ │ ├── community │ │ │ ├── _components │ │ │ │ ├── header.tsx │ │ │ │ └── stats.tsx │ │ │ └── page.tsx │ │ ├── docs │ │ │ ├── [[...slug]] │ │ │ │ ├── page.client.tsx │ │ │ │ └── page.tsx │ │ │ ├── layout.tsx │ │ │ └── lib │ │ │ └── get-llm-text.ts │ │ ├── global.css │ │ ├── layout.config.tsx │ │ ├── layout.tsx │ │ ├── llms.txt │ │ │ ├── [...slug] │ │ │ │ └── route.ts │ │ │ └── route.ts │ │ ├── not-found.tsx │ │ ├── page.tsx │ │ ├── reference │ │ │ └── route.ts │ │ ├── sitemap.xml │ │ ├── static.json │ │ │ └── route.ts │ │ └── v1 │ │ ├── _components │ │ │ └── v1-text.tsx │ │ ├── bg-line.tsx │ │ └── page.tsx │ ├── assets │ │ ├── Geist.ttf │ │ └── GeistMono.ttf │ ├── components │ │ ├── ai-chat-modal.tsx │ │ ├── anchor-scroll-fix.tsx │ │ ├── api-method-tabs.tsx │ │ ├── api-method.tsx │ │ ├── banner.tsx │ │ ├── blocks │ │ │ └── features.tsx │ │ ├── builder │ │ │ ├── beam.tsx │ │ │ ├── code-tabs │ │ │ │ ├── code-editor.tsx │ │ │ │ ├── code-tabs.tsx │ │ │ │ ├── index.tsx │ │ │ │ ├── tab-bar.tsx │ │ │ │ └── theme.ts │ │ │ ├── index.tsx │ │ │ ├── sign-in.tsx │ │ │ ├── sign-up.tsx │ │ │ ├── social-provider.tsx │ │ │ ├── store.ts │ │ │ └── tabs.tsx │ │ ├── display-techstack.tsx │ │ ├── divider-text.tsx │ │ ├── docs │ │ │ ├── docs.client.tsx │ │ │ ├── docs.tsx │ │ │ ├── layout │ │ │ │ ├── nav.tsx │ │ │ │ ├── theme-toggle.tsx │ │ │ │ ├── toc-thumb.tsx │ │ │ │ └── toc.tsx │ │ │ ├── page.client.tsx │ │ │ ├── page.tsx │ │ │ ├── shared.tsx │ │ │ └── ui │ │ │ ├── button.tsx │ │ │ ├── collapsible.tsx │ │ │ ├── popover.tsx │ │ │ └── scroll-area.tsx │ │ ├── endpoint.tsx │ │ ├── features.tsx │ │ ├── floating-ai-search.tsx │ │ ├── fork-button.tsx │ │ ├── generate-apple-jwt.tsx │ │ ├── generate-secret.tsx │ │ ├── github-stat.tsx │ │ ├── icons.tsx │ │ ├── landing │ │ │ ├── gradient-bg.tsx │ │ │ ├── grid-pattern.tsx │ │ │ ├── hero.tsx │ │ │ ├── section-svg.tsx │ │ │ ├── section.tsx │ │ │ ├── spotlight.tsx │ │ │ └── testimonials.tsx │ │ ├── logo-context-menu.tsx │ │ ├── logo.tsx │ │ ├── markdown-renderer.tsx │ │ ├── markdown.tsx │ │ ├── mdx │ │ │ ├── add-to-cursor.tsx │ │ │ └── database-tables.tsx │ │ ├── message-feedback.tsx │ │ ├── mobile-search-icon.tsx │ │ ├── nav-bar.tsx │ │ ├── nav-link.tsx │ │ ├── nav-mobile.tsx │ │ ├── promo-card.tsx │ │ ├── resource-card.tsx │ │ ├── resource-grid.tsx │ │ ├── resource-section.tsx │ │ ├── ripple.tsx │ │ ├── search-dialog.tsx │ │ ├── side-bar.tsx │ │ ├── sidebar-content.tsx │ │ ├── techstack-icons.tsx │ │ ├── theme-provider.tsx │ │ ├── theme-toggler.tsx │ │ └── ui │ │ ├── accordion.tsx │ │ ├── alert-dialog.tsx │ │ ├── alert.tsx │ │ ├── aside-link.tsx │ │ ├── aspect-ratio.tsx │ │ ├── avatar.tsx │ │ ├── background-beams.tsx │ │ ├── background-boxes.tsx │ │ ├── badge.tsx │ │ ├── breadcrumb.tsx │ │ ├── button.tsx │ │ ├── calendar.tsx │ │ ├── callout.tsx │ │ ├── card.tsx │ │ ├── carousel.tsx │ │ ├── chart.tsx │ │ ├── checkbox.tsx │ │ ├── code-block.tsx │ │ ├── collapsible.tsx │ │ ├── command.tsx │ │ ├── context-menu.tsx │ │ ├── dialog.tsx │ │ ├── drawer.tsx │ │ ├── dropdown-menu.tsx │ │ ├── dynamic-code-block.tsx │ │ ├── fade-in.tsx │ │ ├── form.tsx │ │ ├── hover-card.tsx │ │ ├── input-otp.tsx │ │ ├── input.tsx │ │ ├── label.tsx │ │ ├── menubar.tsx │ │ ├── navigation-menu.tsx │ │ ├── pagination.tsx │ │ ├── popover.tsx │ │ ├── progress.tsx │ │ ├── radio-group.tsx │ │ ├── resizable.tsx │ │ ├── scroll-area.tsx │ │ ├── select.tsx │ │ ├── separator.tsx │ │ ├── sheet.tsx │ │ ├── sidebar.tsx │ │ ├── skeleton.tsx │ │ ├── slider.tsx │ │ ├── sonner.tsx │ │ ├── sparkles.tsx │ │ ├── switch.tsx │ │ ├── table.tsx │ │ ├── tabs.tsx │ │ ├── textarea.tsx │ │ ├── toggle-group.tsx │ │ ├── toggle.tsx │ │ ├── tooltip-docs.tsx │ │ ├── tooltip.tsx │ │ └── use-copy-button.tsx │ ├── components.json │ ├── content │ │ ├── blogs │ │ │ ├── 0-supabase-auth-to-planetscale-migration.mdx │ │ │ ├── 1-3.mdx │ │ │ ├── authjs-joins-better-auth.mdx │ │ │ └── seed-round.mdx │ │ ├── changelogs │ │ │ ├── 1-2.mdx │ │ │ └── 1.0.mdx │ │ └── docs │ │ ├── adapters │ │ │ ├── community-adapters.mdx │ │ │ ├── drizzle.mdx │ │ │ ├── mongo.mdx │ │ │ ├── mssql.mdx │ │ │ ├── mysql.mdx │ │ │ ├── other-relational-databases.mdx │ │ │ ├── postgresql.mdx │ │ │ ├── prisma.mdx │ │ │ └── sqlite.mdx │ │ ├── authentication │ │ │ ├── apple.mdx │ │ │ ├── atlassian.mdx │ │ │ ├── cognito.mdx │ │ │ ├── discord.mdx │ │ │ ├── dropbox.mdx │ │ │ ├── email-password.mdx │ │ │ ├── facebook.mdx │ │ │ ├── figma.mdx │ │ │ ├── github.mdx │ │ │ ├── gitlab.mdx │ │ │ ├── google.mdx │ │ │ ├── huggingface.mdx │ │ │ ├── kakao.mdx │ │ │ ├── kick.mdx │ │ │ ├── line.mdx │ │ │ ├── linear.mdx │ │ │ ├── linkedin.mdx │ │ │ ├── microsoft.mdx │ │ │ ├── naver.mdx │ │ │ ├── notion.mdx │ │ │ ├── other-social-providers.mdx │ │ │ ├── paypal.mdx │ │ │ ├── reddit.mdx │ │ │ ├── roblox.mdx │ │ │ ├── salesforce.mdx │ │ │ ├── slack.mdx │ │ │ ├── spotify.mdx │ │ │ ├── tiktok.mdx │ │ │ ├── twitch.mdx │ │ │ ├── twitter.mdx │ │ │ ├── vk.mdx │ │ │ └── zoom.mdx │ │ ├── basic-usage.mdx │ │ ├── comparison.mdx │ │ ├── concepts │ │ │ ├── api.mdx │ │ │ ├── cli.mdx │ │ │ ├── client.mdx │ │ │ ├── cookies.mdx │ │ │ ├── database.mdx │ │ │ ├── email.mdx │ │ │ ├── hooks.mdx │ │ │ ├── oauth.mdx │ │ │ ├── plugins.mdx │ │ │ ├── rate-limit.mdx │ │ │ ├── session-management.mdx │ │ │ ├── typescript.mdx │ │ │ └── users-accounts.mdx │ │ ├── examples │ │ │ ├── astro.mdx │ │ │ ├── next-js.mdx │ │ │ ├── nuxt.mdx │ │ │ ├── remix.mdx │ │ │ └── svelte-kit.mdx │ │ ├── guides │ │ │ ├── auth0-migration-guide.mdx │ │ │ ├── browser-extension-guide.mdx │ │ │ ├── clerk-migration-guide.mdx │ │ │ ├── create-a-db-adapter.mdx │ │ │ ├── next-auth-migration-guide.mdx │ │ │ ├── optimizing-for-performance.mdx │ │ │ ├── saml-sso-with-okta.mdx │ │ │ ├── supabase-migration-guide.mdx │ │ │ └── your-first-plugin.mdx │ │ ├── installation.mdx │ │ ├── integrations │ │ │ ├── astro.mdx │ │ │ ├── convex.mdx │ │ │ ├── elysia.mdx │ │ │ ├── expo.mdx │ │ │ ├── express.mdx │ │ │ ├── fastify.mdx │ │ │ ├── hono.mdx │ │ │ ├── lynx.mdx │ │ │ ├── nestjs.mdx │ │ │ ├── next.mdx │ │ │ ├── nitro.mdx │ │ │ ├── nuxt.mdx │ │ │ ├── remix.mdx │ │ │ ├── solid-start.mdx │ │ │ ├── svelte-kit.mdx │ │ │ ├── tanstack.mdx │ │ │ └── waku.mdx │ │ ├── introduction.mdx │ │ ├── meta.json │ │ ├── plugins │ │ │ ├── 2fa.mdx │ │ │ ├── admin.mdx │ │ │ ├── anonymous.mdx │ │ │ ├── api-key.mdx │ │ │ ├── autumn.mdx │ │ │ ├── bearer.mdx │ │ │ ├── captcha.mdx │ │ │ ├── community-plugins.mdx │ │ │ ├── device-authorization.mdx │ │ │ ├── dodopayments.mdx │ │ │ ├── dub.mdx │ │ │ ├── email-otp.mdx │ │ │ ├── generic-oauth.mdx │ │ │ ├── have-i-been-pwned.mdx │ │ │ ├── jwt.mdx │ │ │ ├── last-login-method.mdx │ │ │ ├── magic-link.mdx │ │ │ ├── mcp.mdx │ │ │ ├── multi-session.mdx │ │ │ ├── oauth-proxy.mdx │ │ │ ├── oidc-provider.mdx │ │ │ ├── one-tap.mdx │ │ │ ├── one-time-token.mdx │ │ │ ├── open-api.mdx │ │ │ ├── organization.mdx │ │ │ ├── passkey.mdx │ │ │ ├── phone-number.mdx │ │ │ ├── polar.mdx │ │ │ ├── siwe.mdx │ │ │ ├── sso.mdx │ │ │ ├── stripe.mdx │ │ │ └── username.mdx │ │ └── reference │ │ ├── contributing.mdx │ │ ├── faq.mdx │ │ ├── options.mdx │ │ ├── resources.mdx │ │ ├── security.mdx │ │ └── telemetry.mdx │ ├── hooks │ │ └── use-mobile.ts │ ├── ignore-build.sh │ ├── lib │ │ ├── blog.ts │ │ ├── chat │ │ │ └── inkeep-qa-schema.ts │ │ ├── constants.ts │ │ ├── export-search-indexes.ts │ │ ├── inkeep-analytics.ts │ │ ├── is-active.ts │ │ ├── metadata.ts │ │ ├── source.ts │ │ └── utils.ts │ ├── next.config.js │ ├── package.json │ ├── postcss.config.js │ ├── proxy.ts │ ├── public │ │ ├── avatars │ │ │ └── beka.jpg │ │ ├── blogs │ │ │ ├── authjs-joins.png │ │ │ ├── seed-round.png │ │ │ └── supabase-ps.png │ │ ├── branding │ │ │ ├── better-auth-brand-assets.zip │ │ │ ├── better-auth-logo-dark.png │ │ │ ├── better-auth-logo-dark.svg │ │ │ ├── better-auth-logo-light.png │ │ │ ├── better-auth-logo-light.svg │ │ │ ├── better-auth-logo-wordmark-dark.png │ │ │ ├── better-auth-logo-wordmark-dark.svg │ │ │ ├── better-auth-logo-wordmark-light.png │ │ │ └── better-auth-logo-wordmark-light.svg │ │ ├── extension-id.png │ │ ├── favicon │ │ │ ├── android-chrome-192x192.png │ │ │ ├── android-chrome-512x512.png │ │ │ ├── apple-touch-icon.png │ │ │ ├── favicon-16x16.png │ │ │ ├── favicon-32x32.png │ │ │ ├── favicon.ico │ │ │ ├── light │ │ │ │ ├── android-chrome-192x192.png │ │ │ │ ├── android-chrome-512x512.png │ │ │ │ ├── apple-touch-icon.png │ │ │ │ ├── favicon-16x16.png │ │ │ │ ├── favicon-32x32.png │ │ │ │ ├── favicon.ico │ │ │ │ └── site.webmanifest │ │ │ └── site.webmanifest │ │ ├── images │ │ │ └── blogs │ │ │ └── better auth (1).png │ │ ├── logo.png │ │ ├── logo.svg │ │ ├── LogoDark.webp │ │ ├── LogoLight.webp │ │ ├── og.png │ │ ├── open-api-reference.png │ │ ├── people-say │ │ │ ├── code-with-antonio.jpg │ │ │ ├── dagmawi-babi.png │ │ │ ├── dax.png │ │ │ ├── dev-ed.png │ │ │ ├── egoist.png │ │ │ ├── guillermo-rauch.png │ │ │ ├── jonathan-wilke.png │ │ │ ├── josh-tried-coding.jpg │ │ │ ├── kitze.jpg │ │ │ ├── lazar-nikolov.png │ │ │ ├── nizzy.png │ │ │ ├── omar-mcadam.png │ │ │ ├── ryan-vogel.jpg │ │ │ ├── saltyatom.jpg │ │ │ ├── sebastien-chopin.png │ │ │ ├── shreyas-mididoddi.png │ │ │ ├── tech-nerd.png │ │ │ ├── theo.png │ │ │ ├── vybhav-bhargav.png │ │ │ └── xavier-pladevall.jpg │ │ ├── plus.svg │ │ ├── release-og │ │ │ ├── 1-2.png │ │ │ ├── 1-3.png │ │ │ └── changelog-og.png │ │ └── v1-og.png │ ├── README.md │ ├── scripts │ │ ├── endpoint-to-doc │ │ │ ├── index.ts │ │ │ ├── input.ts │ │ │ ├── output.mdx │ │ │ └── readme.md │ │ └── sync-orama.ts │ ├── source.config.ts │ ├── tailwind.config.js │ ├── tsconfig.json │ └── turbo.json ├── e2e │ ├── integration │ │ ├── package.json │ │ ├── playwright.config.ts │ │ ├── solid-vinxi │ │ │ ├── .gitignore │ │ │ ├── app.config.ts │ │ │ ├── e2e │ │ │ │ ├── test.spec.ts │ │ │ │ └── utils.ts │ │ │ ├── package.json │ │ │ ├── public │ │ │ │ └── favicon.ico │ │ │ ├── src │ │ │ │ ├── app.tsx │ │ │ │ ├── entry-client.tsx │ │ │ │ ├── entry-server.tsx │ │ │ │ ├── global.d.ts │ │ │ │ ├── lib │ │ │ │ │ ├── auth-client.ts │ │ │ │ │ └── auth.ts │ │ │ │ └── routes │ │ │ │ ├── [...404].tsx │ │ │ │ ├── api │ │ │ │ │ └── auth │ │ │ │ │ └── [...all].ts │ │ │ │ └── index.tsx │ │ │ └── tsconfig.json │ │ ├── test-utils │ │ │ ├── package.json │ │ │ └── src │ │ │ └── playwright.ts │ │ └── vanilla-node │ │ ├── e2e │ │ │ ├── app.ts │ │ │ ├── domain.spec.ts │ │ │ ├── postgres-js.spec.ts │ │ │ ├── test.spec.ts │ │ │ └── utils.ts │ │ ├── index.html │ │ ├── package.json │ │ ├── src │ │ │ ├── main.ts │ │ │ └── vite-env.d.ts │ │ ├── tsconfig.json │ │ └── vite.config.ts │ └── smoke │ ├── package.json │ ├── test │ │ ├── bun.spec.ts │ │ ├── cloudflare.spec.ts │ │ ├── deno.spec.ts │ │ ├── fixtures │ │ │ ├── bun-simple.ts │ │ │ ├── cloudflare │ │ │ │ ├── .gitignore │ │ │ │ ├── drizzle │ │ │ │ │ ├── 0000_clean_vector.sql │ │ │ │ │ └── meta │ │ │ │ │ ├── _journal.json │ │ │ │ │ └── 0000_snapshot.json │ │ │ │ ├── drizzle.config.ts │ │ │ │ ├── package.json │ │ │ │ ├── src │ │ │ │ │ ├── auth-schema.ts │ │ │ │ │ ├── db.ts │ │ │ │ │ └── index.ts │ │ │ │ ├── test │ │ │ │ │ ├── apply-migrations.ts │ │ │ │ │ ├── env.d.ts │ │ │ │ │ └── index.test.ts │ │ │ │ ├── tsconfig.json │ │ │ │ ├── vitest.config.ts │ │ │ │ ├── worker-configuration.d.ts │ │ │ │ └── wrangler.json │ │ │ ├── deno-simple.ts │ │ │ ├── tsconfig-exact-optional-property-types │ │ │ │ ├── package.json │ │ │ │ ├── src │ │ │ │ │ ├── index.ts │ │ │ │ │ └── user-additional-fields.ts │ │ │ │ └── tsconfig.json │ │ │ ├── tsconfig-verbatim-module-syntax-node10 │ │ │ │ ├── package.json │ │ │ │ ├── src │ │ │ │ │ └── index.ts │ │ │ │ └── tsconfig.json │ │ │ └── vite │ │ │ ├── package.json │ │ │ ├── src │ │ │ │ ├── client.ts │ │ │ │ └── server.ts │ │ │ ├── tsconfig.json │ │ │ └── vite.config.ts │ │ ├── ssr.ts │ │ ├── typecheck.spec.ts │ │ └── vite.spec.ts │ └── tsconfig.json ├── LICENSE.md ├── package.json ├── packages │ ├── better-auth │ │ ├── package.json │ │ ├── README.md │ │ ├── src │ │ │ ├── __snapshots__ │ │ │ │ └── init.test.ts.snap │ │ │ ├── adapters │ │ │ │ ├── adapter-factory │ │ │ │ │ ├── index.ts │ │ │ │ │ ├── test │ │ │ │ │ │ ├── __snapshots__ │ │ │ │ │ │ │ └── adapter-factory.test.ts.snap │ │ │ │ │ │ └── adapter-factory.test.ts │ │ │ │ │ └── types.ts │ │ │ │ ├── create-test-suite.ts │ │ │ │ ├── drizzle-adapter │ │ │ │ │ ├── drizzle-adapter.ts │ │ │ │ │ ├── index.ts │ │ │ │ │ └── test │ │ │ │ │ ├── .gitignore │ │ │ │ │ ├── adapter.drizzle.mysql.test.ts │ │ │ │ │ ├── adapter.drizzle.pg.test.ts │ │ │ │ │ ├── adapter.drizzle.sqlite.test.ts │ │ │ │ │ └── generate-schema.ts │ │ │ │ ├── index.ts │ │ │ │ ├── kysely-adapter │ │ │ │ │ ├── bun-sqlite-dialect.ts │ │ │ │ │ ├── dialect.ts │ │ │ │ │ ├── index.ts │ │ │ │ │ ├── kysely-adapter.ts │ │ │ │ │ ├── node-sqlite-dialect.ts │ │ │ │ │ ├── test │ │ │ │ │ │ ├── adapter.kysely.mssql.test.ts │ │ │ │ │ │ ├── adapter.kysely.mysql.test.ts │ │ │ │ │ │ ├── adapter.kysely.pg.test.ts │ │ │ │ │ │ ├── adapter.kysely.sqlite.test.ts │ │ │ │ │ │ └── node-sqlite-dialect.test.ts │ │ │ │ │ └── types.ts │ │ │ │ ├── memory-adapter │ │ │ │ │ ├── adapter.memory.test.ts │ │ │ │ │ ├── index.ts │ │ │ │ │ └── memory-adapter.ts │ │ │ │ ├── mongodb-adapter │ │ │ │ │ ├── adapter.mongo-db.test.ts │ │ │ │ │ ├── index.ts │ │ │ │ │ └── mongodb-adapter.ts │ │ │ │ ├── prisma-adapter │ │ │ │ │ ├── index.ts │ │ │ │ │ ├── prisma-adapter.ts │ │ │ │ │ └── test │ │ │ │ │ ├── .gitignore │ │ │ │ │ ├── base.prisma │ │ │ │ │ ├── generate-auth-config.ts │ │ │ │ │ ├── generate-prisma-schema.ts │ │ │ │ │ ├── get-prisma-client.ts │ │ │ │ │ ├── prisma.mysql.test.ts │ │ │ │ │ ├── prisma.pg.test.ts │ │ │ │ │ ├── prisma.sqlite.test.ts │ │ │ │ │ └── push-prisma-schema.ts │ │ │ │ ├── test-adapter.ts │ │ │ │ ├── test.ts │ │ │ │ ├── tests │ │ │ │ │ ├── auth-flow.ts │ │ │ │ │ ├── index.ts │ │ │ │ │ ├── normal.ts │ │ │ │ │ ├── number-id.ts │ │ │ │ │ ├── performance.ts │ │ │ │ │ └── transactions.ts │ │ │ │ └── utils.ts │ │ │ ├── api │ │ │ │ ├── check-endpoint-conflicts.test.ts │ │ │ │ ├── index.test.ts │ │ │ │ ├── index.ts │ │ │ │ ├── middlewares │ │ │ │ │ ├── index.ts │ │ │ │ │ ├── origin-check.test.ts │ │ │ │ │ └── origin-check.ts │ │ │ │ ├── rate-limiter │ │ │ │ │ ├── index.ts │ │ │ │ │ └── rate-limiter.test.ts │ │ │ │ ├── routes │ │ │ │ │ ├── account.test.ts │ │ │ │ │ ├── account.ts │ │ │ │ │ ├── callback.ts │ │ │ │ │ ├── email-verification.test.ts │ │ │ │ │ ├── email-verification.ts │ │ │ │ │ ├── error.ts │ │ │ │ │ ├── index.ts │ │ │ │ │ ├── ok.ts │ │ │ │ │ ├── reset-password.test.ts │ │ │ │ │ ├── reset-password.ts │ │ │ │ │ ├── session-api.test.ts │ │ │ │ │ ├── session.ts │ │ │ │ │ ├── sign-in.test.ts │ │ │ │ │ ├── sign-in.ts │ │ │ │ │ ├── sign-out.test.ts │ │ │ │ │ ├── sign-out.ts │ │ │ │ │ ├── sign-up.test.ts │ │ │ │ │ ├── sign-up.ts │ │ │ │ │ ├── update-user.test.ts │ │ │ │ │ └── update-user.ts │ │ │ │ ├── to-auth-endpoints.test.ts │ │ │ │ └── to-auth-endpoints.ts │ │ │ ├── auth.test.ts │ │ │ ├── auth.ts │ │ │ ├── call.test.ts │ │ │ ├── client │ │ │ │ ├── client-ssr.test.ts │ │ │ │ ├── client.test.ts │ │ │ │ ├── config.ts │ │ │ │ ├── fetch-plugins.ts │ │ │ │ ├── index.ts │ │ │ │ ├── lynx │ │ │ │ │ ├── index.ts │ │ │ │ │ └── lynx-store.ts │ │ │ │ ├── parser.ts │ │ │ │ ├── path-to-object.ts │ │ │ │ ├── plugins │ │ │ │ │ ├── index.ts │ │ │ │ │ └── infer-plugin.ts │ │ │ │ ├── proxy.ts │ │ │ │ ├── query.ts │ │ │ │ ├── react │ │ │ │ │ ├── index.ts │ │ │ │ │ └── react-store.ts │ │ │ │ ├── session-atom.ts │ │ │ │ ├── solid │ │ │ │ │ ├── index.ts │ │ │ │ │ └── solid-store.ts │ │ │ │ ├── svelte │ │ │ │ │ └── index.ts │ │ │ │ ├── test-plugin.ts │ │ │ │ ├── types.ts │ │ │ │ ├── url.test.ts │ │ │ │ ├── vanilla.ts │ │ │ │ └── vue │ │ │ │ ├── index.ts │ │ │ │ └── vue-store.ts │ │ │ ├── cookies │ │ │ │ ├── check-cookies.ts │ │ │ │ ├── cookie-utils.ts │ │ │ │ ├── cookies.test.ts │ │ │ │ └── index.ts │ │ │ ├── crypto │ │ │ │ ├── buffer.ts │ │ │ │ ├── hash.ts │ │ │ │ ├── index.ts │ │ │ │ ├── jwt.ts │ │ │ │ ├── password.test.ts │ │ │ │ ├── password.ts │ │ │ │ └── random.ts │ │ │ ├── db │ │ │ │ ├── db.test.ts │ │ │ │ ├── field.ts │ │ │ │ ├── get-migration.ts │ │ │ │ ├── get-schema.ts │ │ │ │ ├── get-tables.test.ts │ │ │ │ ├── get-tables.ts │ │ │ │ ├── index.ts │ │ │ │ ├── internal-adapter.test.ts │ │ │ │ ├── internal-adapter.ts │ │ │ │ ├── schema.ts │ │ │ │ ├── secondary-storage.test.ts │ │ │ │ ├── to-zod.ts │ │ │ │ ├── utils.ts │ │ │ │ └── with-hooks.ts │ │ │ ├── index.ts │ │ │ ├── init.test.ts │ │ │ ├── init.ts │ │ │ ├── integrations │ │ │ │ ├── next-js.ts │ │ │ │ ├── node.ts │ │ │ │ ├── react-start.ts │ │ │ │ ├── solid-start.ts │ │ │ │ └── svelte-kit.ts │ │ │ ├── oauth2 │ │ │ │ ├── index.ts │ │ │ │ ├── link-account.test.ts │ │ │ │ ├── link-account.ts │ │ │ │ ├── state.ts │ │ │ │ └── utils.ts │ │ │ ├── plugins │ │ │ │ ├── access │ │ │ │ │ ├── access.test.ts │ │ │ │ │ ├── access.ts │ │ │ │ │ ├── index.ts │ │ │ │ │ └── types.ts │ │ │ │ ├── additional-fields │ │ │ │ │ ├── additional-fields.test.ts │ │ │ │ │ └── client.ts │ │ │ │ ├── admin │ │ │ │ │ ├── access │ │ │ │ │ │ ├── index.ts │ │ │ │ │ │ └── statement.ts │ │ │ │ │ ├── admin.test.ts │ │ │ │ │ ├── admin.ts │ │ │ │ │ ├── client.ts │ │ │ │ │ ├── error-codes.ts │ │ │ │ │ ├── has-permission.ts │ │ │ │ │ ├── index.ts │ │ │ │ │ ├── schema.ts │ │ │ │ │ └── types.ts │ │ │ │ ├── anonymous │ │ │ │ │ ├── anon.test.ts │ │ │ │ │ ├── client.ts │ │ │ │ │ └── index.ts │ │ │ │ ├── api-key │ │ │ │ │ ├── api-key.test.ts │ │ │ │ │ ├── client.ts │ │ │ │ │ ├── index.ts │ │ │ │ │ ├── rate-limit.ts │ │ │ │ │ ├── routes │ │ │ │ │ │ ├── create-api-key.ts │ │ │ │ │ │ ├── delete-all-expired-api-keys.ts │ │ │ │ │ │ ├── delete-api-key.ts │ │ │ │ │ │ ├── get-api-key.ts │ │ │ │ │ │ ├── index.ts │ │ │ │ │ │ ├── list-api-keys.ts │ │ │ │ │ │ ├── update-api-key.ts │ │ │ │ │ │ └── verify-api-key.ts │ │ │ │ │ ├── schema.ts │ │ │ │ │ └── types.ts │ │ │ │ ├── bearer │ │ │ │ │ ├── bearer.test.ts │ │ │ │ │ └── index.ts │ │ │ │ ├── captcha │ │ │ │ │ ├── captcha.test.ts │ │ │ │ │ ├── constants.ts │ │ │ │ │ ├── error-codes.ts │ │ │ │ │ ├── index.ts │ │ │ │ │ ├── types.ts │ │ │ │ │ ├── utils.ts │ │ │ │ │ └── verify-handlers │ │ │ │ │ ├── captchafox.ts │ │ │ │ │ ├── cloudflare-turnstile.ts │ │ │ │ │ ├── google-recaptcha.ts │ │ │ │ │ ├── h-captcha.ts │ │ │ │ │ └── index.ts │ │ │ │ ├── custom-session │ │ │ │ │ ├── client.ts │ │ │ │ │ ├── custom-session.test.ts │ │ │ │ │ └── index.ts │ │ │ │ ├── device-authorization │ │ │ │ │ ├── client.ts │ │ │ │ │ ├── device-authorization.test.ts │ │ │ │ │ ├── index.ts │ │ │ │ │ └── schema.ts │ │ │ │ ├── email-otp │ │ │ │ │ ├── client.ts │ │ │ │ │ ├── email-otp.test.ts │ │ │ │ │ ├── index.ts │ │ │ │ │ └── utils.ts │ │ │ │ ├── generic-oauth │ │ │ │ │ ├── client.ts │ │ │ │ │ ├── generic-oauth.test.ts │ │ │ │ │ └── index.ts │ │ │ │ ├── haveibeenpwned │ │ │ │ │ ├── haveibeenpwned.test.ts │ │ │ │ │ └── index.ts │ │ │ │ ├── index.ts │ │ │ │ ├── jwt │ │ │ │ │ ├── adapter.ts │ │ │ │ │ ├── client.ts │ │ │ │ │ ├── index.ts │ │ │ │ │ ├── jwt.test.ts │ │ │ │ │ ├── schema.ts │ │ │ │ │ ├── sign.ts │ │ │ │ │ ├── types.ts │ │ │ │ │ └── utils.ts │ │ │ │ ├── last-login-method │ │ │ │ │ ├── client.ts │ │ │ │ │ ├── custom-prefix.test.ts │ │ │ │ │ ├── index.ts │ │ │ │ │ └── last-login-method.test.ts │ │ │ │ ├── magic-link │ │ │ │ │ ├── client.ts │ │ │ │ │ ├── index.ts │ │ │ │ │ ├── magic-link.test.ts │ │ │ │ │ └── utils.ts │ │ │ │ ├── mcp │ │ │ │ │ ├── authorize.ts │ │ │ │ │ ├── index.ts │ │ │ │ │ └── mcp.test.ts │ │ │ │ ├── multi-session │ │ │ │ │ ├── client.ts │ │ │ │ │ ├── index.ts │ │ │ │ │ └── multi-session.test.ts │ │ │ │ ├── oauth-proxy │ │ │ │ │ ├── index.ts │ │ │ │ │ └── oauth-proxy.test.ts │ │ │ │ ├── oidc-provider │ │ │ │ │ ├── authorize.ts │ │ │ │ │ ├── client.ts │ │ │ │ │ ├── index.ts │ │ │ │ │ ├── oidc.test.ts │ │ │ │ │ ├── schema.ts │ │ │ │ │ ├── types.ts │ │ │ │ │ ├── ui.ts │ │ │ │ │ └── utils.ts │ │ │ │ ├── one-tap │ │ │ │ │ ├── client.ts │ │ │ │ │ └── index.ts │ │ │ │ ├── one-time-token │ │ │ │ │ ├── client.ts │ │ │ │ │ ├── index.ts │ │ │ │ │ ├── one-time-token.test.ts │ │ │ │ │ └── utils.ts │ │ │ │ ├── open-api │ │ │ │ │ ├── generator.ts │ │ │ │ │ ├── index.ts │ │ │ │ │ ├── logo.ts │ │ │ │ │ └── open-api.test.ts │ │ │ │ ├── organization │ │ │ │ │ ├── access │ │ │ │ │ │ ├── index.ts │ │ │ │ │ │ └── statement.ts │ │ │ │ │ ├── adapter.ts │ │ │ │ │ ├── call.ts │ │ │ │ │ ├── client.test.ts │ │ │ │ │ ├── client.ts │ │ │ │ │ ├── error-codes.ts │ │ │ │ │ ├── has-permission.ts │ │ │ │ │ ├── index.ts │ │ │ │ │ ├── organization-hook.test.ts │ │ │ │ │ ├── organization.test.ts │ │ │ │ │ ├── organization.ts │ │ │ │ │ ├── permission.ts │ │ │ │ │ ├── routes │ │ │ │ │ │ ├── crud-access-control.test.ts │ │ │ │ │ │ ├── crud-access-control.ts │ │ │ │ │ │ ├── crud-invites.ts │ │ │ │ │ │ ├── crud-members.test.ts │ │ │ │ │ │ ├── crud-members.ts │ │ │ │ │ │ ├── crud-org.test.ts │ │ │ │ │ │ ├── crud-org.ts │ │ │ │ │ │ └── crud-team.ts │ │ │ │ │ ├── schema.ts │ │ │ │ │ ├── team.test.ts │ │ │ │ │ └── types.ts │ │ │ │ ├── passkey │ │ │ │ │ ├── client.ts │ │ │ │ │ ├── index.ts │ │ │ │ │ └── passkey.test.ts │ │ │ │ ├── phone-number │ │ │ │ │ ├── client.ts │ │ │ │ │ ├── index.ts │ │ │ │ │ ├── phone-number-error.ts │ │ │ │ │ └── phone-number.test.ts │ │ │ │ ├── siwe │ │ │ │ │ ├── client.ts │ │ │ │ │ ├── index.ts │ │ │ │ │ ├── schema.ts │ │ │ │ │ ├── siwe.test.ts │ │ │ │ │ └── types.ts │ │ │ │ ├── sso │ │ │ │ │ ├── client.ts │ │ │ │ │ ├── index.ts │ │ │ │ │ └── sso.test.ts │ │ │ │ ├── two-factor │ │ │ │ │ ├── backup-codes │ │ │ │ │ │ └── index.ts │ │ │ │ │ ├── client.ts │ │ │ │ │ ├── constant.ts │ │ │ │ │ ├── error-code.ts │ │ │ │ │ ├── index.ts │ │ │ │ │ ├── otp │ │ │ │ │ │ └── index.ts │ │ │ │ │ ├── schema.ts │ │ │ │ │ ├── totp │ │ │ │ │ │ └── index.ts │ │ │ │ │ ├── two-factor.test.ts │ │ │ │ │ ├── types.ts │ │ │ │ │ ├── utils.ts │ │ │ │ │ └── verify-two-factor.ts │ │ │ │ └── username │ │ │ │ ├── client.ts │ │ │ │ ├── error-codes.ts │ │ │ │ ├── index.ts │ │ │ │ ├── schema.ts │ │ │ │ └── username.test.ts │ │ │ ├── social-providers │ │ │ │ └── index.ts │ │ │ ├── social.test.ts │ │ │ ├── test-utils │ │ │ │ ├── headers.ts │ │ │ │ ├── index.ts │ │ │ │ ├── state.ts │ │ │ │ └── test-instance.ts │ │ │ ├── types │ │ │ │ ├── adapter.ts │ │ │ │ ├── api.ts │ │ │ │ ├── helper.ts │ │ │ │ ├── index.ts │ │ │ │ ├── models.ts │ │ │ │ ├── plugins.ts │ │ │ │ └── types.test.ts │ │ │ └── utils │ │ │ ├── await-object.ts │ │ │ ├── boolean.ts │ │ │ ├── clone.ts │ │ │ ├── constants.ts │ │ │ ├── date.ts │ │ │ ├── ensure-utc.ts │ │ │ ├── get-request-ip.ts │ │ │ ├── hashing.ts │ │ │ ├── hide-metadata.ts │ │ │ ├── id.ts │ │ │ ├── import-util.ts │ │ │ ├── index.ts │ │ │ ├── is-atom.ts │ │ │ ├── is-promise.ts │ │ │ ├── json.ts │ │ │ ├── merger.ts │ │ │ ├── middleware-response.ts │ │ │ ├── misc.ts │ │ │ ├── password.ts │ │ │ ├── plugin-helper.ts │ │ │ ├── shim.ts │ │ │ ├── time.ts │ │ │ ├── url.ts │ │ │ └── wildcard.ts │ │ ├── tsconfig.json │ │ ├── tsdown.config.ts │ │ └── vitest.config.ts │ ├── cli │ │ ├── CHANGELOG.md │ │ ├── package.json │ │ ├── README.md │ │ ├── src │ │ │ ├── commands │ │ │ │ ├── generate.ts │ │ │ │ ├── info.ts │ │ │ │ ├── init.ts │ │ │ │ ├── login.ts │ │ │ │ ├── mcp.ts │ │ │ │ ├── migrate.ts │ │ │ │ └── secret.ts │ │ │ ├── generators │ │ │ │ ├── auth-config.ts │ │ │ │ ├── drizzle.ts │ │ │ │ ├── index.ts │ │ │ │ ├── kysely.ts │ │ │ │ ├── prisma.ts │ │ │ │ └── types.ts │ │ │ ├── index.ts │ │ │ └── utils │ │ │ ├── add-svelte-kit-env-modules.ts │ │ │ ├── check-package-managers.ts │ │ │ ├── format-ms.ts │ │ │ ├── get-config.ts │ │ │ ├── get-package-info.ts │ │ │ ├── get-tsconfig-info.ts │ │ │ └── install-dependencies.ts │ │ ├── test │ │ │ ├── __snapshots__ │ │ │ │ ├── auth-schema-mysql-enum.txt │ │ │ │ ├── auth-schema-mysql-number-id.txt │ │ │ │ ├── auth-schema-mysql-passkey-number-id.txt │ │ │ │ ├── auth-schema-mysql-passkey.txt │ │ │ │ ├── auth-schema-mysql.txt │ │ │ │ ├── auth-schema-number-id.txt │ │ │ │ ├── auth-schema-pg-enum.txt │ │ │ │ ├── auth-schema-pg-passkey.txt │ │ │ │ ├── auth-schema-sqlite-enum.txt │ │ │ │ ├── auth-schema-sqlite-number-id.txt │ │ │ │ ├── auth-schema-sqlite-passkey-number-id.txt │ │ │ │ ├── auth-schema-sqlite-passkey.txt │ │ │ │ ├── auth-schema-sqlite.txt │ │ │ │ ├── auth-schema.txt │ │ │ │ ├── migrations.sql │ │ │ │ ├── schema-mongodb.prisma │ │ │ │ ├── schema-mysql-custom.prisma │ │ │ │ ├── schema-mysql.prisma │ │ │ │ ├── schema-numberid.prisma │ │ │ │ └── schema.prisma │ │ │ ├── generate-all-db.test.ts │ │ │ ├── generate.test.ts │ │ │ ├── get-config.test.ts │ │ │ ├── info.test.ts │ │ │ └── migrate.test.ts │ │ ├── tsconfig.json │ │ ├── tsconfig.test.json │ │ └── tsdown.config.ts │ ├── core │ │ ├── package.json │ │ ├── src │ │ │ ├── async_hooks │ │ │ │ └── index.ts │ │ │ ├── context │ │ │ │ ├── index.ts │ │ │ │ └── transaction.ts │ │ │ ├── db │ │ │ │ ├── adapter │ │ │ │ │ └── index.ts │ │ │ │ ├── index.ts │ │ │ │ ├── plugin.ts │ │ │ │ ├── schema │ │ │ │ │ ├── account.ts │ │ │ │ │ ├── rate-limit.ts │ │ │ │ │ ├── session.ts │ │ │ │ │ ├── shared.ts │ │ │ │ │ ├── user.ts │ │ │ │ │ └── verification.ts │ │ │ │ └── type.ts │ │ │ ├── env │ │ │ │ ├── color-depth.ts │ │ │ │ ├── env-impl.ts │ │ │ │ ├── index.ts │ │ │ │ ├── logger.test.ts │ │ │ │ └── logger.ts │ │ │ ├── error │ │ │ │ ├── codes.ts │ │ │ │ └── index.ts │ │ │ ├── index.ts │ │ │ ├── middleware │ │ │ │ └── index.ts │ │ │ ├── oauth2 │ │ │ │ ├── client-credentials-token.ts │ │ │ │ ├── create-authorization-url.ts │ │ │ │ ├── index.ts │ │ │ │ ├── oauth-provider.ts │ │ │ │ ├── refresh-access-token.ts │ │ │ │ ├── utils.ts │ │ │ │ └── validate-authorization-code.ts │ │ │ ├── social-providers │ │ │ │ ├── apple.ts │ │ │ │ ├── atlassian.ts │ │ │ │ ├── cognito.ts │ │ │ │ ├── discord.ts │ │ │ │ ├── dropbox.ts │ │ │ │ ├── facebook.ts │ │ │ │ ├── figma.ts │ │ │ │ ├── github.ts │ │ │ │ ├── gitlab.ts │ │ │ │ ├── google.ts │ │ │ │ ├── huggingface.ts │ │ │ │ ├── index.ts │ │ │ │ ├── kakao.ts │ │ │ │ ├── kick.ts │ │ │ │ ├── line.ts │ │ │ │ ├── linear.ts │ │ │ │ ├── linkedin.ts │ │ │ │ ├── microsoft-entra-id.ts │ │ │ │ ├── naver.ts │ │ │ │ ├── notion.ts │ │ │ │ ├── paypal.ts │ │ │ │ ├── reddit.ts │ │ │ │ ├── roblox.ts │ │ │ │ ├── salesforce.ts │ │ │ │ ├── slack.ts │ │ │ │ ├── spotify.ts │ │ │ │ ├── tiktok.ts │ │ │ │ ├── twitch.ts │ │ │ │ ├── twitter.ts │ │ │ │ ├── vk.ts │ │ │ │ └── zoom.ts │ │ │ ├── types │ │ │ │ ├── context.ts │ │ │ │ ├── cookie.ts │ │ │ │ ├── helper.ts │ │ │ │ ├── index.ts │ │ │ │ ├── init-options.ts │ │ │ │ ├── plugin-client.ts │ │ │ │ └── plugin.ts │ │ │ └── utils │ │ │ ├── error-codes.ts │ │ │ └── index.ts │ │ ├── tsconfig.json │ │ └── tsdown.config.ts │ ├── expo │ │ ├── CHANGELOG.md │ │ ├── package.json │ │ ├── README.md │ │ ├── src │ │ │ ├── client.ts │ │ │ ├── expo.test.ts │ │ │ └── index.ts │ │ ├── tsconfig.json │ │ └── tsdown.config.ts │ ├── sso │ │ ├── package.json │ │ ├── src │ │ │ ├── client.ts │ │ │ ├── index.ts │ │ │ ├── oidc.test.ts │ │ │ └── saml.test.ts │ │ ├── tsconfig.json │ │ └── tsdown.config.ts │ ├── stripe │ │ ├── CHANGELOG.md │ │ ├── package.json │ │ ├── src │ │ │ ├── client.ts │ │ │ ├── hooks.ts │ │ │ ├── index.ts │ │ │ ├── schema.ts │ │ │ ├── stripe.test.ts │ │ │ ├── types.ts │ │ │ └── utils.ts │ │ ├── tsconfig.json │ │ ├── tsdown.config.ts │ │ └── vitest.config.ts │ └── telemetry │ ├── package.json │ ├── src │ │ ├── detectors │ │ │ ├── detect-auth-config.ts │ │ │ ├── detect-database.ts │ │ │ ├── detect-framework.ts │ │ │ ├── detect-project-info.ts │ │ │ ├── detect-runtime.ts │ │ │ └── detect-system-info.ts │ │ ├── index.ts │ │ ├── project-id.ts │ │ ├── telemetry.test.ts │ │ ├── types.ts │ │ └── utils │ │ ├── hash.ts │ │ ├── id.ts │ │ ├── import-util.ts │ │ └── package-json.ts │ ├── tsconfig.json │ └── tsdown.config.ts ├── pnpm-lock.yaml ├── pnpm-workspace.yaml ├── README.md ├── SECURITY.md ├── tsconfig.json └── turbo.json ``` # Files -------------------------------------------------------------------------------- /packages/better-auth/src/adapters/adapter-factory/test/adapter-factory.test.ts: -------------------------------------------------------------------------------- ```typescript import { describe, test, expect } from "vitest"; import { createAdapterFactory } from ".."; import type { AdapterFactoryConfig, AdapterFactoryCustomizeAdapterCreator, } from "../types"; import type { CleanedWhere, Where } from "@better-auth/core/db/adapter"; import type { User } from "../../../types"; import type { BetterAuthOptions } from "@better-auth/core"; import { betterAuth } from "../../../auth"; /* Note that there are basically 2 types of tests here: 1. Making sure that the data within each adapter call is correct. (Transformed to suit the DB, accurate according to the schema, etc.) 2. Making sure the output of each adapter call is correct. (The data is transformed back to the correct format, etc.) The rest are just edge cases. */ async function createTestAdapter( props: { config?: Partial<AdapterFactoryConfig>; options?: BetterAuthOptions; adapter?: ( ...args: Parameters<AdapterFactoryCustomizeAdapterCreator> ) => Partial<ReturnType<AdapterFactoryCustomizeAdapterCreator>>; } = { config: { adapterId: "test-id", adapterName: "Test Adapter", usePlural: false, debugLogs: false, supportsJSON: true, supportsDates: true, supportsBooleans: true, }, options: {}, adapter: () => ({}), }, ) { const { config = { adapterId: "test-id", adapterName: "Test Adapter", usePlural: false, debugLogs: false, supportsJSON: true, supportsDates: true, supportsBooleans: true, }, options = {}, adapter = () => ({}), } = props; const testAdapter = createAdapterFactory({ config: Object.assign( { adapterId: "test-id", adapterName: "Test Adapter", usePlural: false, debugLogs: false, supportsJSON: true, supportsDates: true, supportsBooleans: true, }, config, ), adapter: (...args) => { const x = adapter(...args) as Partial< ReturnType<AdapterFactoryCustomizeAdapterCreator> >; return { async create(data) { if (x.create) { return await x.create(data); } return data.data; }, async update(data) { if (x.update) { return await x.update(data); } return data.update; }, async updateMany(data) { if (x.updateMany) { return await x.updateMany(data); } return 0; }, async count(data) { if (x.count) { return await x.count(data); } return 0; }, async delete(data) { if (x.delete) { return await x.delete(data); } return; }, async deleteMany(data) { if (x.deleteMany) { return await x.deleteMany(data); } return 0; }, async findMany(data) { if (x.findMany) { return await x.findMany(data); } return []; }, async findOne(data) { if (x.findOne) { return await x.findOne(data); } return null; }, options: x.options ?? {}, }; }, }); const auth = betterAuth({ ...options, database: testAdapter, }); return (await auth.$context).adapter; } describe("Create Adapter Helper", async () => { const adapterId = "test-adapter-id"; const adapter = await createTestAdapter({ config: { adapterId, }, }); test("Should have the correct adapter id", () => { expect(adapter.id).toBe(adapterId); }); test("Should use the id generator if passed into the betterAuth config", async () => { const adapter = await createTestAdapter({ config: { debugLogs: {}, }, options: { advanced: { database: { generateId(options) { return "HARD-CODED-ID"; }, }, }, }, }); const res = await adapter.create({ model: "user", data: { name: "test-name" }, }); expect(res).toHaveProperty("id"); expect(res.id).toBe("HARD-CODED-ID"); }); test("Should not generate an id if `advanced.database.generateId` is not defined or false", async () => { const adapter = await createTestAdapter({ config: {}, options: { advanced: { database: { generateId: false, useNumberId: false }, }, }, adapter(args_0) { return { async create(data) { expect(data.data.id).not.toBeDefined(); return data.data; }, }; }, }); const testResult = await adapter.create({ model: "user", data: { name: "test-name" }, }); expect(testResult.id).not.toBeDefined(); }); test("Should throw an error if the database doesn't support numeric ids and the user has enabled `useNumberId`", async () => { let error: any | null = null; try { await createTestAdapter({ config: { supportsNumericIds: false, }, options: { advanced: { database: { useNumberId: true, }, }, }, }); } catch (err) { error = err; } expect(error).not.toBeNull(); }); describe("Checking for the results of an adapter call, as well as the parameters passed into the adapter call", () => { describe("create", () => { test("Should fill in the missing fields in the result", async () => { const res = await adapter.create({ model: "user", data: { name: "test-name" }, }); expect(res).toHaveProperty("id"); expect(res).toHaveProperty("name"); expect(res).toHaveProperty("email"); expect(res).toHaveProperty("emailVerified"); expect(res).toHaveProperty("image"); expect(res).toHaveProperty("createdAt"); expect(res).toHaveProperty("updatedAt"); expect(res?.emailVerified).toEqual(false); expect(res?.name).toEqual("test-name"); expect(res?.email).toEqual(undefined); expect(res?.image).toEqual(undefined); expect(res?.createdAt).toBeInstanceOf(Date); expect(res?.updatedAt).toBeInstanceOf(Date); }); test("should not return string for nullable foreign keys", async () => { const adapter = await createTestAdapter({ config: { debugLogs: {}, }, options: { plugins: [ { id: "test", schema: { testModel: { fields: { nullableReference: { type: "string", references: { field: "id", model: "user" }, required: false, }, }, }, }, }, ], }, }); const res = await adapter.create({ model: "testModel", data: { nullableReference: null }, }); expect(res).toHaveProperty("nullableReference"); expect(res.nullableReference).toBeNull(); const adapter2 = await createTestAdapter({ config: { debugLogs: {}, }, options: { plugins: [ { id: "test", schema: { testModel: { fields: { nullableReference: { type: "string", references: { field: "id", model: "user" }, required: false, }, }, }, }, }, ], advanced: { database: { useNumberId: true, }, }, }, }); const res2 = await adapter2.create({ model: "testModel", data: { nullableReference: null }, }); expect(res2).toHaveProperty("nullableReference"); expect(res2.nullableReference).toBeNull(); }); test('Should include an "id" in the result in all cases, unless "select" is used to exclude it', async () => { const res = await adapter.create({ model: "user", data: { name: "test-name" }, }); expect(res).toHaveProperty("id"); expect(typeof res?.id).toEqual("string"); const adapterWithoutIdGeneration = await createTestAdapter({ config: { disableIdGeneration: true, debugLogs: {}, }, }); const res2 = await adapterWithoutIdGeneration.create({ model: "user", data: { name: "test-name" }, }); // Id will still be present, due to the transformOutput function. However it will be undefined, vvvvv expect(res2).toHaveProperty("id"); expect(typeof res2?.id).toEqual("undefined"); // In a real case, the `id` should always be present const res3 = await adapter.create({ model: "user", data: { name: "test-name" }, select: ["name"], }); expect(res3).toHaveProperty("name"); expect(res3).not.toHaveProperty("id"); }); test('Should receive a generated id during the call, unless "disableIdGeneration" is set to true', async () => { const createWithId: { id: unknown } = await new Promise(async (r) => { const adapter = await createTestAdapter({ adapter(args_0) { return { async create({ data, model, select }) { r(data as any); return data; }, }; }, }); adapter.create({ model: "user", data: { name: "test-name" }, }); }); expect(createWithId).toBeDefined(); expect(createWithId.id).toBeDefined(); expect(typeof createWithId.id).toBe("string"); const createWithoutId: { id: unknown } = await new Promise( async (r) => { const adapter = await createTestAdapter({ config: { disableIdGeneration: true, debugLogs: {}, }, adapter(args_0) { return { async create({ data, model, select }) { r(data as any); return data; }, }; }, }); adapter.create({ model: "user", data: { name: "test-name" }, }); }, ); expect(createWithoutId).toBeDefined(); expect(createWithoutId.id).toBeUndefined(); }); test("Should not modify result null to string for id or fields referencing id", async () => { const result: { id: string; testPluginField: string | null } = await new Promise(async (r) => { const adapter = await createTestAdapter({ adapter(args_0) { return { async create({ data, model, select }) { return data; }, }; }, options: { plugins: [ { id: "test-plugin-id", schema: { testPluginTable: { fields: { testPluginField: { type: "string", required: false, references: { model: "user", field: "id", }, }, }, }, }, }, ], }, }); r( await adapter.create({ model: "testPluginTable", data: { testPluginField: null, }, }), ); }); expect(result.id).toBeTypeOf("string"); expect(result.testPluginField).toBeNull(); }); test("Should modify boolean type to 1 or 0 if the DB doesn't support it. And expect the result to be transformed back to boolean", async () => { // Testing true const createTRUEParameters: { data: { emailVerified: number } } = await new Promise(async (r) => { const adapter = await createTestAdapter({ config: { supportsBooleans: false, }, adapter(args_0) { return { async create(data) { r(data as any); return data.data; }, }; }, }); const res = await adapter.create({ model: "user", data: { emailVerified: true }, }); expect(res).toHaveProperty("emailVerified"); expect(res.emailVerified).toBe(true); }); expect(createTRUEParameters.data).toHaveProperty("emailVerified"); expect(createTRUEParameters.data.emailVerified).toBe(1); // Testing false const createFALSEParameters: { data: { emailVerified: number } } = await new Promise(async (r) => { const adapter = await createTestAdapter({ config: { supportsBooleans: false, }, adapter(args_0) { return { async create(data) { r(data as any); return data.data; }, }; }, }); const res = await adapter.create({ model: "user", data: { emailVerified: false }, }); expect(res).toHaveProperty("emailVerified"); expect(res.emailVerified).toBe(false); }); expect(createFALSEParameters.data).toHaveProperty("emailVerified"); expect(createFALSEParameters.data.emailVerified).toBe(0); }); test("Should modify JSON type to TEXT if the DB doesn't support it. And expect the result to be transformed back to JSON", async () => { const createJSONParameters: { data: { preferences: string } } = await new Promise(async (r) => { const adapter = await createTestAdapter({ config: { supportsJSON: false, }, options: { user: { additionalFields: { preferences: { type: "json", }, }, }, }, adapter(args_0) { return { async create(data) { r(data as any); return data.data; }, }; }, }); const obj = { preferences: { color: "blue", size: "large" } }; const res = await adapter.create({ model: "user", data: obj, }); expect(res).toHaveProperty("preferences"); expect(res.preferences).toEqual(obj.preferences); }); expect(createJSONParameters.data).toHaveProperty("preferences"); expect(createJSONParameters.data.preferences).toEqual( '{"color":"blue","size":"large"}', ); }); test("Should modify date type to TEXT if the DB doesn't support it. And expect the result to be transformed back to date", async () => { const testDate = new Date(); const createDateParameters: { data: { createdAt: string } } = await new Promise(async (r) => { const adapter = await createTestAdapter({ config: { supportsDates: false, }, adapter(args_0) { return { async create(data) { r(data as any); return data.data; }, }; }, }); const res = await adapter.create({ model: "user", data: { createdAt: testDate }, }); expect(res).toHaveProperty("createdAt"); expect(res.createdAt).toBeInstanceOf(Date); }); expect(createDateParameters.data).toHaveProperty("createdAt"); expect(createDateParameters.data.createdAt).toEqual( testDate.toISOString(), ); }); test("Should allow custom transform input", async () => { const createCustomTransformInputParameters: { data: { name: string } } = await new Promise(async (r) => { const adapter = await createTestAdapter({ config: { debugLogs: {}, customTransformInput({ field, data }) { if (field === "name") { return data.toUpperCase(); } return data; }, }, adapter(args_0) { return { async create(data) { r(data as any); return data.data; }, }; }, }); const res = await adapter.create({ model: "user", data: { name: "test-name" }, }); expect(res).toHaveProperty("name"); expect(res.name).toEqual("TEST-NAME"); }); expect(createCustomTransformInputParameters.data).toHaveProperty( "name", ); expect(createCustomTransformInputParameters.data.name).toEqual( "TEST-NAME", ); }); test("Should allow custom transform output", async () => { const createCustomTransformOutputParameters: { data: { name: string }; } = await new Promise(async (r) => { const adapter = await createTestAdapter({ config: { debugLogs: {}, customTransformOutput({ field, data }) { if (field === "name") { return data.toLowerCase(); } return data; }, }, adapter(args_0) { return { async create(data) { r(data as any); return data.data; }, }; }, }); const res = await adapter.create({ model: "user", data: { name: "TEST-NAME" }, }); expect(res).toHaveProperty("name"); expect(res.name).toEqual("test-name"); }); expect(createCustomTransformOutputParameters.data).toHaveProperty( "name", ); expect(createCustomTransformOutputParameters.data.name).toEqual( "TEST-NAME", // Remains the same as the input because we're only transforming the output ); }); test("Should allow custom transform input and output", async () => { const createCustomTransformInputAndOutputParameters: { data: { name: string }; } = await new Promise(async (r) => { const adapter = await createTestAdapter({ config: { debugLogs: {}, customTransformInput({ field, data }) { if (field === "name") { return data.toUpperCase(); } return data; }, customTransformOutput({ field, data }) { if (field === "name") { return data.toLowerCase(); } return data; }, }, adapter(args_0) { return { async create(data) { r(data as any); return data.data; }, }; }, }); const res = await adapter.create({ model: "user", data: { name: "TEST-NAME" }, }); expect(res).toHaveProperty("name"); expect(res.name).toEqual("test-name"); }); expect( createCustomTransformInputAndOutputParameters.data, ).toHaveProperty("name"); expect(createCustomTransformInputAndOutputParameters.data.name).toEqual( "TEST-NAME", ); }); test("Should allow custom map input key transformation", async () => { const parameters: { data: { email_address: string }; } = await new Promise(async (r) => { const adapter = await createTestAdapter({ config: { debugLogs: {}, mapKeysTransformInput: { email: "email_address", }, }, adapter(args_0) { return { async create(data) { r(data as any); return data.data; }, }; }, }); const res = (await adapter.create({ model: "user", data: { email: "[email protected]" }, })) as { email: string }; expect(res).toHaveProperty("email"); expect(res).not.toHaveProperty("email_address"); expect(res.email).toEqual(undefined); // The reason it's undefined is because we did transform `email` to `email_address`, however we never transformed `email_address` back to `email`. }); expect(parameters.data).toHaveProperty("email_address"); expect(parameters.data.email_address).toEqual("[email protected]"); }); test("Should allow custom transform input to transform the where clause", async () => { const parameters: CleanedWhere[] = await new Promise(async (r) => { const adapter = await createTestAdapter({ config: { debugLogs: {}, mapKeysTransformInput: { id: "_id", }, }, adapter(args_0) { return { async findOne({ model, where, select }) { r(where); return {} as any; }, }; }, }); adapter.findOne({ model: "user", where: [{ field: "id", value: "123" }], }); }); expect(parameters[0]!.field).toEqual("_id"); }); test("Should allow custom map output key transformation", async () => { const parameters: { data: { email: string }; } = await new Promise(async (r) => { const adapter = await createTestAdapter({ config: { debugLogs: {}, mapKeysTransformOutput: { email: "wrong_email_key", }, }, adapter(args_0) { return { async create(data) { r(data as any); return data.data; }, }; }, }); const res = (await adapter.create({ model: "user", data: { email: "[email protected]" }, })) as { wrong_email_key: string }; // Even though we're using the output key transformation, we still don't actually get the key transformation we want. // This is because the output is also parsed against the schema, and the `wrong_email_key` key is not in the schema. expect(res).toHaveProperty("wrong_email_key"); expect(res).not.toHaveProperty("email"); expect(res.wrong_email_key).toEqual("[email protected]"); }); expect(parameters.data).toHaveProperty("email"); expect(parameters.data.email).toEqual("[email protected]"); }); test("Should allow custom map input and output key transformation", async () => { const parameters: { data: { email_address: string }; } = await new Promise(async (r) => { const adapter = await createTestAdapter({ config: { debugLogs: {}, mapKeysTransformInput: { email: "email_address", }, mapKeysTransformOutput: { email_address: "email", }, }, adapter(args_0) { return { async create(data) { r(data as any); return data.data; }, }; }, }); const res = await adapter.create({ model: "user", data: { email: "[email protected]" }, }); expect(res).toHaveProperty("email"); expect(res).not.toHaveProperty("email_address"); expect(res.email).toEqual("[email protected]"); }); expect(parameters.data).toHaveProperty("email_address"); expect(parameters.data).not.toHaveProperty("email"); expect(parameters.data.email_address).toEqual("[email protected]"); }); test("Should expect the fields to be transformed into the correct field names if customized", async () => { const parameters: { data: any; select?: string[]; model: string } = await new Promise(async (r) => { const adapter = await createTestAdapter({ config: { debugLogs: {}, }, options: { user: { fields: { email: "email_address", }, }, }, adapter(args_0) { return { async create(data) { r(data as any); return data.data; }, }; }, }); const res = await adapter.create({ model: "user", data: { email: "[email protected]" }, }); expect(res).toHaveProperty("email"); expect(res).not.toHaveProperty("email_address"); expect(res.email).toEqual("[email protected]"); }); expect(parameters).toHaveProperty("data"); expect(parameters.data).toHaveProperty("email_address"); expect(parameters.data).not.toHaveProperty("email"); expect(parameters.data.email_address).toEqual("[email protected]"); }); test("Should expect the model to be transformed into the correct model name if customized", async () => { const parameters: { data: any; select?: string[]; model: string } = await new Promise(async (r) => { const adapter = await createTestAdapter({ config: { debugLogs: {}, }, options: { user: { modelName: "user_table", }, }, adapter(args_0) { return { async create(data) { r(data as any); return data.data; }, }; }, }); const res = await adapter.create({ model: "user", data: { email: "[email protected]" }, }); expect(res).toHaveProperty("id"); expect(res).toHaveProperty("email"); }); expect(parameters).toHaveProperty("model"); expect(parameters.model).toEqual("user_table"); }); test("Should expect the result to follow the schema", async () => { const parameters: { data: any; select?: string[]; model: string } = await new Promise(async (r) => { const adapter = await createTestAdapter({ config: { debugLogs: {}, }, options: { user: { fields: { email: "email_address", }, }, }, adapter(args_0) { return { async create(data) { r(data as any); return data.data; }, }; }, }); const res = await adapter.create({ model: "user", data: { email: "[email protected]" }, }); expect(res).toHaveProperty("email"); expect(res).toHaveProperty("id"); expect(res).toHaveProperty("createdAt"); expect(res).toHaveProperty("updatedAt"); expect(res).toHaveProperty("name"); expect(res).toHaveProperty("emailVerified"); expect(res).toHaveProperty("image"); expect(res).not.toHaveProperty("email_address"); }); expect(parameters).toHaveProperty("data"); expect(parameters.data).toHaveProperty("email_address"); expect(parameters.data).not.toHaveProperty("email"); expect(parameters.data.email_address).toEqual("[email protected]"); }); test("Should expect the result to respect the select fields", async () => { const adapter = await createTestAdapter({ config: { debugLogs: {}, }, options: { user: { fields: { email: "email_address", }, }, }, }); const res = await adapter.create({ model: "user", data: { email: "[email protected]", name: "test-name", emailVerified: false, image: "test-image", }, select: ["email"], }); expect(res).toHaveProperty("email"); expect(res).not.toHaveProperty("name"); expect(res).not.toHaveProperty("emailVerified"); expect(res).not.toHaveProperty("image"); expect(res).toMatchSnapshot(); }); }); describe("update", () => { test("Should fill in the missing fields in the result", async () => { const user: { id: string; name: string } = await adapter.create({ model: "user", data: { name: "test-name" }, }); const res = await adapter.update({ model: "user", where: [{ field: "id", value: user.id }], update: { name: "test-name-2" }, }); expect(res).toHaveProperty("id"); expect(res).toHaveProperty("name"); expect(res).toHaveProperty("email"); expect(res).toHaveProperty("emailVerified"); expect(res).toHaveProperty("image"); expect(res).toHaveProperty("createdAt"); expect(res).toHaveProperty("updatedAt"); }); test(`Should include an "id" in the result in all cases`, async () => { const user: { id: string; name: string } = await adapter.create({ model: "user", data: { name: "test-name" }, }); const res: { id: string } | null = await adapter.update({ model: "user", where: [{ field: "id", value: user.id }], update: { name: "test-name-2" }, }); expect(res).toHaveProperty("id"); }); test("Should modify boolean type to 1 or 0 if the DB doesn't support it. And expect the result to be transformed back to boolean", async () => { // Testing true const updateTRUEParameters: { update: { emailVerified: number } } = await new Promise(async (r) => { const adapter = await createTestAdapter({ config: { supportsBooleans: false, }, adapter(args_0) { return { async update(data) { r(data as any); return data.update; }, }; }, }); const user: { emailVerified: boolean; id: string } = await adapter.create({ model: "user", data: { emailVerified: false }, }); const res = await adapter.update({ model: "user", where: [{ field: "id", value: user.id }], update: { emailVerified: true }, }); expect(res).toHaveProperty("emailVerified"); //@ts-expect-error expect(res.emailVerified).toBe(true); }); expect(updateTRUEParameters.update).toHaveProperty("emailVerified"); expect(updateTRUEParameters.update.emailVerified).toBe(1); // Testing false const createFALSEParameters: { update: { emailVerified: number } } = await new Promise(async (r) => { const adapter = await createTestAdapter({ config: { supportsBooleans: false, }, adapter(args_0) { return { async update(data) { r(data as any); return data.update; }, }; }, }); const user: { emailVerified: boolean; id: string } = await adapter.create({ model: "user", data: { emailVerified: true }, }); const res = await adapter.update({ model: "user", where: [{ field: "id", value: user.id }], update: { emailVerified: false }, }); expect(res).toHaveProperty("emailVerified"); //@ts-expect-error expect(res.emailVerified).toBe(false); }); expect(createFALSEParameters.update).toHaveProperty("emailVerified"); expect(createFALSEParameters.update.emailVerified).toBe(0); }); test("Should modify JSON type to TEXT if the DB doesn't support it. And expect the result to be transformed back to JSON", async () => { const createJSONParameters: { update: { preferences: string } } = await new Promise(async (r) => { const adapter = await createTestAdapter({ config: { supportsJSON: false, }, options: { user: { additionalFields: { preferences: { type: "json", }, }, }, }, adapter(args_0) { return { async update(data) { r(data as any); return data.update; }, }; }, }); const obj = { preferences: { color: "blue", size: "large" } }; const user: { email: string; id: string } = await adapter.create({ model: "user", data: { email: "[email protected]" }, }); const res: typeof obj | null = await adapter.update({ model: "user", where: [{ field: "id", value: user.id }], update: { preferences: obj.preferences }, }); expect(res).toHaveProperty("preferences"); expect(res?.preferences).toEqual(obj.preferences); }); expect(createJSONParameters.update).toHaveProperty("preferences"); expect(createJSONParameters.update.preferences).toEqual( '{"color":"blue","size":"large"}', ); }); test("Should modify date type to TEXT if the DB doesn't support it. And expect the result to be transformed back to date", async () => { const testDate = new Date(); const createDateParameters: { update: { createdAt: string } } = await new Promise(async (r) => { const adapter = await createTestAdapter({ config: { supportsDates: false, }, adapter(args_0) { return { async update(data) { r(data as any); return data.update; }, }; }, }); const user: { email: string; id: string } = await adapter.create({ model: "user", data: { email: "[email protected]" }, }); const res: { createdAt: Date } | null = await adapter.update({ model: "user", where: [{ field: "id", value: user.id }], update: { createdAt: testDate }, }); expect(res).toHaveProperty("createdAt"); expect(res?.createdAt).toBeInstanceOf(Date); }); expect(createDateParameters.update).toHaveProperty("createdAt"); expect(createDateParameters.update.createdAt).toEqual( testDate.toISOString(), ); }); test("Should allow custom transform input", async () => { const createCustomTransformInputParameters: { update: { name: string }; } = await new Promise(async (r) => { const adapter = await createTestAdapter({ config: { customTransformInput({ field, data }) { if (field === "name") { return data.toUpperCase(); } return data; }, }, adapter(args_0) { return { async update(data) { r(data as any); return data.update; }, }; }, }); const user: { id: string; name: string } = await adapter.create({ model: "user", data: { name: "test-name" }, }); const res: { name: string } | null = await adapter.update({ model: "user", where: [{ field: "id", value: user.id }], update: { name: "test-name-2" }, }); expect(res).toHaveProperty("name"); expect(res?.name).toEqual("TEST-NAME-2"); }); expect(createCustomTransformInputParameters.update).toHaveProperty( "name", ); expect(createCustomTransformInputParameters.update.name).toEqual( "TEST-NAME-2", ); }); test("Should allow custom transform output", async () => { const createCustomTransformOutputParameters: { update: { name: string }; } = await new Promise(async (r) => { const adapter = await createTestAdapter({ config: { customTransformOutput({ field, data }) { if (field === "name") { return data.toLowerCase(); } return data; }, }, adapter(args_0) { return { async update(data) { r(data as any); return data.update; }, }; }, }); const user: { id: string; name: string } = await adapter.create({ model: "user", data: { name: "TEST-NAME" }, }); const res: { name: string } | null = await adapter.update({ model: "user", where: [{ field: "id", value: user.id }], update: { name: "test-name-2" }, }); expect(res).toHaveProperty("name"); expect(res?.name).toEqual("test-name-2"); }); expect(createCustomTransformOutputParameters.update).toHaveProperty( "name", ); expect(createCustomTransformOutputParameters.update.name).toEqual( "test-name-2", ); }); test("Should allow custom transform input and output", async () => { const createCustomTransformInputAndOutputParameters: { update: { name: string }; } = await new Promise(async (r) => { const adapter = await createTestAdapter({ config: { customTransformInput({ field, data }) { if (field === "name") { return data.toUpperCase(); } return data; }, customTransformOutput({ field, data }) { if (field === "name") { return data.toLowerCase(); } return data; }, }, adapter(args_0) { return { async update(data) { r(data as any); return data.update; }, }; }, }); const user: { id: string; name: string } = await adapter.create({ model: "user", data: { name: "test-name" }, }); const res: { name: string } | null = await adapter.update({ model: "user", where: [{ field: "id", value: user.id }], update: { name: "test-name-2" }, }); expect(res).toHaveProperty("name"); expect(res?.name).toEqual("test-name-2"); }); expect( createCustomTransformInputAndOutputParameters.update, ).toHaveProperty("name"); expect( createCustomTransformInputAndOutputParameters.update.name, ).toEqual("test-name-2".toUpperCase()); }); test("Should allow custom map input key transformation", async () => { const parameters: { update: { email_address: string }; } = await new Promise(async (r) => { const adapter = await createTestAdapter({ config: { debugLogs: {}, mapKeysTransformInput: { email: "email_address", }, }, adapter(args_0) { return { async update(data) { r(data as any); return data.update; }, }; }, }); const user = (await adapter.create({ model: "user", data: { email: "[email protected]" }, })) as { email: string; id: string }; const res: { email: string } | null = await adapter.update({ model: "user", update: { email: "[email protected]" }, where: [{ field: "id", value: user.id }], }); expect(res).toHaveProperty("email"); expect(res).not.toHaveProperty("email_address"); expect(res?.email).toEqual(undefined); // The reason it's undefined is because we did transform `email` to `email_address`, however we never transformed `email_address` back to `email`. }); expect(parameters.update).toHaveProperty("email_address"); expect(parameters.update.email_address).toEqual("[email protected]"); }); test("Should allow custom map output key transformation", async () => { const parameters: { update: { email: string }; } = await new Promise(async (r) => { const adapter = await createTestAdapter({ config: { debugLogs: {}, mapKeysTransformOutput: { email: "email_address", }, }, adapter(args_0) { return { async update(data) { r(data as any); return data.update; }, }; }, }); const user = (await adapter.create({ model: "user", data: { email: "[email protected]" }, })) as { email: string; id: string }; const res: { email_address: string } | null = await adapter.update({ model: "user", update: { email: "[email protected]" }, where: [{ field: "id", value: user.id }], }); expect(res).toHaveProperty("email_address"); expect(res).not.toHaveProperty("email"); expect(res?.email_address).toEqual("[email protected]"); }); expect(parameters.update).toHaveProperty("email"); expect(parameters.update).not.toHaveProperty("email_address"); expect(parameters.update.email).toEqual("[email protected]"); }); test("Should allow custom map input and output key transformation", async () => { const parameters: { update: { email_address: string }; } = await new Promise(async (r) => { const adapter = await createTestAdapter({ config: { debugLogs: {}, mapKeysTransformInput: { email: "email_address", }, mapKeysTransformOutput: { email_address: "email", }, }, adapter(args_0) { return { async update(data) { r(data as any); return data.update; }, }; }, }); const user = (await adapter.create({ model: "user", data: { email: "[email protected]" }, })) as { email: string; id: string }; const res: { email: string } | null = await adapter.update({ model: "user", update: { email: "[email protected]" }, where: [{ field: "id", value: user.id }], }); expect(res).toHaveProperty("email"); expect(res).not.toHaveProperty("email_address"); expect(res?.email).toEqual("[email protected]"); }); expect(parameters.update).toHaveProperty("email_address"); expect(parameters.update).not.toHaveProperty("email"); expect(parameters.update.email_address).toEqual("[email protected]"); }); test("Should expect the fields to be transformed into the correct field names if customized", async () => { const parameters: { update: { email_address: string }; } = await new Promise(async (r) => { const adapter = await createTestAdapter({ config: { debugLogs: {}, }, options: { user: { fields: { email: "email_address", }, }, }, adapter(args_0) { return { async update(data) { r(data as any); return data.update; }, }; }, }); const user: { id: string; email: string } = await adapter.create({ model: "user", data: { email: "[email protected]" }, }); const res: { email: string } | null = await adapter.update({ model: "user", update: { email: "[email protected]" }, where: [{ field: "id", value: user.id }], }); expect(res).toHaveProperty("email"); expect(res).not.toHaveProperty("email_address"); expect(res?.email).toEqual("[email protected]"); }); expect(parameters.update).toHaveProperty("email_address"); expect(parameters.update).not.toHaveProperty("email"); expect(parameters.update.email_address).toEqual("[email protected]"); }); test("Should expect not to receive an id even if disableIdGeneration is false in an update call", async () => { const parameters: { update: { id: string }; } = await new Promise(async (r) => { const adapter = await createTestAdapter({ config: { disableIdGeneration: true, }, adapter(args_0) { return { async update(data) { r(data as any); return data.update; }, }; }, }); const user: { email: string; id: string } = await adapter.create({ model: "user", data: { email: "[email protected]" }, }); await adapter.update({ model: "user", update: { email: "[email protected]" }, where: [{ field: "id", value: user.id }], }); }); expect(parameters.update).not.toHaveProperty("id"); }); }); describe("find", () => { test("findOne: Should transform the where clause according to the schema", async () => { const parameters: { where: Where[]; model: string; select?: string[] } = await new Promise(async (r) => { const adapter = await createTestAdapter({ options: { user: { fields: { email: "email_address", }, }, }, adapter(args_0) { return { async findOne({ model, where, select }) { const fakeResult: Omit<User, "email"> & { email_address: string; } = { id: "random-id-oudwduwbdouwbdu123b", email_address: "[email protected]", emailVerified: false, createdAt: new Date(), updatedAt: new Date(), name: "test-name", }; r({ model, where, select }); return fakeResult as any; }, }; }, }); const res = await adapter.findOne<User>({ model: "user", where: [{ field: "email", value: "[email protected]" }], }); expect(res).not.toHaveProperty("email_address"); expect(res).toHaveProperty("email"); expect(res?.email).toEqual("[email protected]"); }); expect(parameters.where[0]!.field).toEqual("email_address"); }); test("findMany: Should transform the where clause according to the schema", async () => { const parameters: { where: Where[] | undefined; model: string } = await new Promise(async (r) => { const adapter = await createTestAdapter({ options: { user: { fields: { email: "email_address", }, }, }, adapter(args_0) { return { async findMany({ model, where }) { const fakeResult: (Omit<User, "email"> & { email_address: string; })[] = [ { id: "random-id-eio1d1u12h33123ed", email_address: "[email protected]", emailVerified: false, createdAt: new Date(), updatedAt: new Date(), name: "test-name", }, ]; r({ model, where }); return fakeResult as any; }, }; }, }); const res = await adapter.findMany<User>({ model: "user", where: [{ field: "email", value: "[email protected]" }], }); expect(res[0]).not.toHaveProperty("email_address"); expect(res[0]).toHaveProperty("email"); expect(res[0]?.email).toEqual("[email protected]"); }); expect(parameters.where?.[0]!.field).toEqual("email_address"); }); test("findOne: Should receive an integer id in where clause if the user has enabled `useNumberId`", async () => { const parameters: { where: Where[]; model: string; select?: string[] } = await new Promise(async (r) => { const adapter = await createTestAdapter({ options: { advanced: { database: { useNumberId: true, }, }, }, adapter(args_0) { return { async findOne({ model, where, select }) { const fakeResult: Omit<User, "id"> & { id: number } = { id: 1, email: "[email protected]", emailVerified: false, createdAt: new Date(), updatedAt: new Date(), name: "test-name", }; r({ model, where, select }); return fakeResult as any; }, }; }, }); const res = await adapter.findOne<User>({ model: "user", where: [{ field: "id", value: "1" }], }); expect(res).toHaveProperty("id"); expect(res?.id).toEqual("1"); }); // The where clause should convert the string id value of `"1"` to an int since `useNumberId` is true expect(parameters.where[0]!.value).toEqual(1); }); test("findMany: Should receive an integer id in where clause if the user has enabled `useNumberId`", async () => { const parameters: { where: Where[] | undefined; model: string } = await new Promise(async (r) => { const adapter = await createTestAdapter({ options: { advanced: { database: { useNumberId: true, }, }, }, adapter(args_0) { return { async findMany({ model, where }) { const fakeResult: (Omit<User, "id"> & { id: number })[] = [ { id: 1, email: "[email protected]", emailVerified: false, createdAt: new Date(), updatedAt: new Date(), name: "test-name", }, ]; r({ model, where }); return fakeResult as any; }, }; }, }); const res = await adapter.findMany<User>({ model: "user", where: [{ field: "id", value: "1" }], }); expect(res[0]).toHaveProperty("id"); expect(res[0]!.id).toEqual("1"); }); // The where clause should convert the string id value of `"1"` to an int since `useNumberId` is true expect(parameters.where?.[0]!.value).toEqual(1); }); }); }); }); ```