From 9730df2f9b991b341a2d3d56f1a007ca5a27c76f Mon Sep 17 00:00:00 2001 From: Nicu Chiciuc Date: Sun, 15 Nov 2026 17:11:40 +0200 Subject: [PATCH 1/3] convex-auth-tanstack-start 0.2.0: Convex Auth 2.0.0, SessionProvider takes isAuthenticated The catalog moves to @convex-dev/auth 2.0.0 and convex 1.48.0, which 2.0.0 needs. 2.0.0 and its new password-hash-wasm 0.0.0 are younger than the release-age rule, so each gets an exact-version exclusion with its removal date. SessionProvider passes the app's isAuthenticated query to ConvexAuthNextjsProvider by name, which 2.0.0 requires, so a session revoked on the deployment signs the browser out. convexAuth() pre-bundles convex/server, which 2.0.0's provider imports. The OAuth test follows 2.0.0: no REJECTED flow error, and no accessTokenExpiresAt in the token bundle. --- .../convex-auth-tanstack-start/CHANGELOG.md | 23 ++ packages/convex-auth-tanstack-start/README.md | 71 +++-- .../convex-auth-tanstack-start/package.json | 6 +- .../convex-auth-tanstack-start/src/index.tsx | 9 + .../src/oauth.test.ts | 8 +- .../convex-auth-tanstack-start/src/vite.ts | 3 +- pnpm-lock.yaml | 258 +++++------------- pnpm-workspace.yaml | 12 +- 8 files changed, 164 insertions(+), 226 deletions(-) diff --git a/packages/convex-auth-tanstack-start/CHANGELOG.md b/packages/convex-auth-tanstack-start/CHANGELOG.md index e80f251..6519696 100644 --- a/packages/convex-auth-tanstack-start/CHANGELOG.md +++ b/packages/convex-auth-tanstack-start/CHANGELOG.md @@ -1,5 +1,28 @@ # Changelog +## 0.2.0 + +- Convex Auth 2.0.0, the stable release. The `@convex-dev/auth` peer is pinned to `2.0.0`, and + `convex` is `^1.48.0`, which 2.0.0 needs. Convex Auth 2.0.0-beta.0 stays on 0.1.x. +- `SessionProvider` takes a required `isAuthenticated` prop, the app's `isAuthenticated` query, + which `setupConvexAuth` returns in 2.0.0. The provider subscribes to it while signed in, so a + session that ends on the deployment signs the browser out at once. +- What an app changes, besides Convex Auth's own + [upgrade steps](https://github.com/convex/convex-auth/releases/tag/v2.0.0): + - `convex/auth.ts` exports `isAuthenticated` next to `signOut` and `refreshSession`. + - The root route passes it: + ``. + - `convex/auth.config.ts` is `providers: [convexAuthProvider()]`, and the core component is + mounted as `app.use(auth)`. The deployment signs the tokens, so the key pair variables go from + every deployment, the app's `defineApp({ env })`, its scripts, and its CI. + - The core serves no HTTP routes. On Convex, `convex/http.ts` drops its exact routes for + `/auth/signin`, `/auth/refresh`, and `/auth/signout`: the catch-all of `routeAll` sends them to + the app's server. An OAuth component's `httpPrefix`, such as `/auth/github`, still wins for its + callback. + - `useOauth().flowError` has no `REJECTED` any more: a `ConvexError` from `createUser` or + `onSignIn` comes back as `OTHER_ERROR` with that error as `cause`. +- `convexAuth()` pre-bundles `convex/server` for the dev server, which 2.0.0's provider imports. + ## 0.1.2 - `useSignOutSession` loads `landingUrl` with `location.replace`, so Back after a sign-out no longer diff --git a/packages/convex-auth-tanstack-start/README.md b/packages/convex-auth-tanstack-start/README.md index 0352e31..71eba08 100644 --- a/packages/convex-auth-tanstack-start/README.md +++ b/packages/convex-auth-tanstack-start/README.md @@ -25,17 +25,17 @@ plugins: [convexSsr(), convexAuth(), tanstackStart(), react()], plugins: [convexAuth(), cloudflare({ viteEnvironment: { name: "ssr" } }), tanstackStart(), react()], ``` -Convex Auth 2.0.0-beta.0 keeps its SSR provider in a file that its exports map does not expose, and +Convex Auth 2.0.0 keeps its SSR provider in a file that its exports map does not expose, and `convexAuth()` resolves it; [Why these settings exist](#why-these-settings-exist) has the rest. ## Sessions This package is interim: the session lines are Convex Auth's own API, and their home is a TanStack Start integration in Convex Auth itself, which is being discussed with Convex. Until then they live -here, and they need Convex Auth 2.0.0-beta.0 exactly (`@convex-dev/auth@2.0.0-beta.0`, npm tag -`beta`). That beta signs in with OAuth providers ([OAuth sign-in](#oauth-sign-in)), and with email -and password, with sign-up verification and password recovery by email link, sent through Resend -only; it has no magic links and no email codes (OTP) yet. +here, and they need Convex Auth 2.0.0 exactly (`@convex-dev/auth@2.0.0`). It signs in with OAuth +providers ([OAuth sign-in](#oauth-sign-in)), with a username and a password, with passkeys, and with +email and password, with sign-up verification and password recovery by email link, sent through +Resend only; it has no magic links and no email codes (OTP). With [Convex Auth](https://github.com/get-convex/convex-auth) sessions in httpOnly cookies, `src/server.ts` answers the `/auth` routes, reads the session of the request's cookies, and passes @@ -65,7 +65,13 @@ route a typed `serverContext`. The token is `undefined` for a render that knows session, the prerender. The app creates its Convex client with `expectAuth: true`. The root route gives the token to the server render's Convex client and wraps the document in the -session provider: +session provider, with the app's `isAuthenticated` query, which `convex/auth.ts` exports from +`setupConvexAuth`: + +```ts +const core = setupConvexAuth({ component: components.auth }); +export const { signOut, refreshSession, isAuthenticated } = core; +``` ```tsx import { SessionProvider, sessionBeforeLoad } from "@samebase/convex-auth-tanstack-start"; @@ -81,7 +87,11 @@ export const Route = createRootRouteWithContext<{ function Root() { const { convexQueryClient, token } = Route.useRouteContext(); return ( - + {/* ... */} ); @@ -116,9 +126,11 @@ Without `next`, the gate is `redirectWithoutSession(serverContext, { to: "/signi - `sessionBeforeLoad`: on the server, the render's Convex HTTP client queries with the token, so loaders run as the user. It puts `token` in the route context. -- `SessionProvider`: Convex Auth's provider, started from the token of the server render. It also - releases `expectAuth` for a visitor without a session, which Convex's provider never does, and it - finishes OAuth flows, as [OAuth sign-in](#oauth-sign-in) says. +- `SessionProvider`: Convex Auth's provider, started from the token of the server render. While + signed in, it subscribes to `isAuthenticated`, so a session that ends on the deployment, such as + one that a password recovery revokes, signs the browser out at once. It also releases `expectAuth` + for a visitor without a session, which Convex's provider never does, and it finishes OAuth flows, + as [OAuth sign-in](#oauth-sign-in) says. - `redirectWithoutSession`: a server render without a session throws `redirect(options)`, with the options of TanStack's `redirect()`. Only the server render has the cookie; a browser navigation has no `serverContext`. @@ -138,9 +150,10 @@ Without `next`, the gate is `redirectWithoutSession(serverContext, { to: "/signi sign-in redirect and `next`. Convex Auth's `signOut()` resolves even when the route failed, so a reload after it alone signs the user back in from the cookie. -`@convex-dev/auth` is a peer dependency pinned to 2.0.0-beta.0, because `convexAuth()` resolves a -file inside that version. An app on Convex Auth 0.0.x stays on -`@samebase/convex-hosting-tanstack-start` 0.9.x, which had these helpers in its `convex-auth` entry. +`@convex-dev/auth` is a peer dependency pinned to 2.0.0, because `convexAuth()` resolves a file +inside that version. An app on Convex Auth 2.0.0-beta.0 stays on 0.1.x of this package, and an app +on Convex Auth 0.0.x on `@samebase/convex-hosting-tanstack-start` 0.9.x, which had these helpers in +its `convex-auth` entry. The package declares Start's `Register.server` with a request context that holds only the token, so an app that uses it cannot add its own fields to `serverContext` today; an app that needs that is @@ -185,9 +198,9 @@ The app wires each provider in four places, here GitHub: ``` Google goes under `/auth/google` the same way. Convex Auth's docs use `/oauth/github`; any prefix - works that no route of the app uses, and `/auth/github` keeps the providers next to the core's - `/auth`. The component's variables are required, and Convex refuses a push that binds them to - optional variables of the app, so every deployment needs them, previews included. + works that no route of the app uses, and `/auth/github` keeps the providers next to the app's + `/auth` routes. The component's variables are required, and Convex refuses a push that binds them + to optional variables of the app, so every deployment needs them, previews included. - `convex/auth.ts` exports the provider's two functions, with the origin of the site in `allowedRedirectOrigins`: @@ -200,22 +213,20 @@ The app wires each provider in four places, here GitHub: ``` `createUserGithub` is an internal mutation that takes - `provider: v.object({ name: v.literal("github"), accountId: v.string(), profile: vGithubProfile })`, - with `vGithubProfile` from `@convex-dev/auth/methods/github/server`, and returns the new user's - id. + `method: v.object({ name: v.literal("github"), profile: vGithubProfile })`, with `vGithubProfile` + from `@convex-dev/auth/methods/github/server`, and returns the new user's id. - `src/server.ts` adds each `completeSignIn*` function to the `signIn` list of `setupConvexAuthServer`. The `startSignIn*` functions stay out: they mint no session, and the client calls them on the deployment. - A button calls the hook's `signIn()`, and the page shows `useOauth().flowError`. -`convex/http.ts` keeps its order: `routeAll(...)` first, which returns the handler, then the exact -`POST` routes for `/auth/signin`, `/auth/refresh`, and `/auth/signout` on that handler. The -components' prefixes come from `convex/convex.config.ts`, not from `http.ts`. For each request, -Convex takes an exact route of the app first, then the longest prefix among the app's prefixes and -the components' `httpPrefix`: `/auth/github/callback` goes to the GitHub component, the key set -under `/auth` to the core, the three exact routes to the app's server, and every other path to the -catch-all of `routeAll`. +On Convex, `convex/http.ts` needs nothing for the providers: their prefixes come from +`convex/convex.config.ts`, and Convex Auth's core serves no HTTP routes. For each request, Convex +takes an exact route of the app first, then the longest prefix among the app's prefixes and the +components' `httpPrefix`: `/auth/github/callback` goes to the GitHub component, and every other +path, `/auth/signin`, `/auth/refresh`, and `/auth/signout` included, to the catch-all of `routeAll` +and the app's server. `useOauth().flowError` says why the last flow failed after the provider sent the browser back, or is `null`. The app switches on `error` and supplies its own text: @@ -224,9 +235,9 @@ catch-all of `routeAll`. - `EXPIRED`: the flow took too long, or its code was redeemed already or does not match the flow that this browser saved. - `INVALID_FLOW`: this browser has no saved flow: another browser started it, or it finished. -- `REJECTED`: the app's `createUser` or `onSignIn` threw a `ConvexError`; `data` is its data. - `OTHER_ERROR`: anything else, such as a failed exchange with the provider or a redemption that - threw; `cause` holds it. + threw; `cause` holds it. When the app's `createUser` or `onSignIn` turned the sign-in down by + throwing a `ConvexError`, `cause` is that error. A start that fails before the provider, such as a `redirectTo` whose origin is not in `allowedRedirectOrigins`, comes back from `signIn()` as @@ -247,8 +258,8 @@ What the app must not do: `convexAuth()` applies to development and builds: -- `@convex-dev/auth/ssr/nextjs/client` resolves to the file of Convex Auth 2.0.0-beta.0 that holds - `ConvexAuthNextjsProvider`. The file imports no Next.js code; only beta.0's exports map hides it. +- `@convex-dev/auth/ssr/nextjs/client` resolves to the file of Convex Auth 2.0.0 that holds + `ConvexAuthNextjsProvider`. The file imports no Next.js code; only 2.0.0's exports map hides it. - `@convex-dev/auth` is inlined in the server render, so the dev server does not load the aliased file through Vite and the rest of Convex Auth through Node, each with its own copy of the React contexts that the provider sets and the hooks read. diff --git a/packages/convex-auth-tanstack-start/package.json b/packages/convex-auth-tanstack-start/package.json index e205008..2eddc14 100644 --- a/packages/convex-auth-tanstack-start/package.json +++ b/packages/convex-auth-tanstack-start/package.json @@ -1,6 +1,6 @@ { "name": "@samebase/convex-auth-tanstack-start", - "version": "0.1.2", + "version": "0.2.0", "description": "Convex Auth cookie sessions in TanStack Start, on any host.", "keywords": [ "auth", @@ -52,11 +52,11 @@ "typescript": "catalog:" }, "peerDependencies": { - "@convex-dev/auth": "2.0.0-beta.0", + "@convex-dev/auth": "2.0.0", "@convex-dev/react-query": "^0.1.0", "@tanstack/react-router": "^1.170.38", "@tanstack/react-start": "^1.168.60", - "convex": "^1.46.0", + "convex": "^1.48.0", "react": "^19.2.0", "react-dom": "^19.2.0", "vite": "*" diff --git a/packages/convex-auth-tanstack-start/src/index.tsx b/packages/convex-auth-tanstack-start/src/index.tsx index 936cfe1..78a5946 100644 --- a/packages/convex-auth-tanstack-start/src/index.tsx +++ b/packages/convex-auth-tanstack-start/src/index.tsx @@ -11,6 +11,7 @@ // away when that exists. import { useAuthActions } from "@convex-dev/auth/react"; +import type { IsAuthenticatedFn } from "@convex-dev/auth/ssr"; // The `convexAuth()` Vite plugin resolves this specifier to the file that holds the provider. import { ConvexAuthNextjsProvider } from "@convex-dev/auth/ssr/nextjs/client"; import type { ConvexQueryClient } from "@convex-dev/react-query"; @@ -31,6 +32,7 @@ import { // generated route tree, which is what makes the augmentation visible to it. import type {} from "@tanstack/react-start"; import { useConvexAuth, type ConvexReactClient } from "convex/react"; +import { getFunctionName } from "convex/server"; import { createContext, useContext, useEffect, useRef, type ReactNode } from "react"; import { oauthKeepingHistoryState } from "./oauth.js"; @@ -76,14 +78,20 @@ const SessionToken = createContext(undefined); * subscription until a token arrives, so a page rendered as the user gets the user's live answer. * Convex's provider never releases that hold for a visitor without a session, so this releases it * when the provider reports none. The provider reads `initialToken` once, when it mounts. + * + * `isAuthenticated` is the app's `isAuthenticated` query, which `setupConvexAuth` returns. The + * provider subscribes to it while signed in, so a session that ends on the deployment, such as one + * that a password recovery revokes, signs the browser out at once. */ export function SessionProvider({ client, token, + isAuthenticated, children, }: { client: ConvexReactClient; token: string | null | undefined; + isAuthenticated: IsAuthenticatedFn; children: ReactNode; }) { return ( @@ -91,6 +99,7 @@ export function SessionProvider({ ("auth:completeSignInWithGithub"), }; -const session = { accessToken: "access-1", accessTokenExpiresAt: 0, userId: "user-1" }; +const session = { accessToken: "access-1", userId: "user-1" }; afterEach(() => { vi.unstubAllGlobals(); @@ -106,6 +106,8 @@ test("redeems the code through the sign-in route and cleans the URL with the rou }); const thrown = new Error("The sign-in route answered 500."); +// The app's `createUser` or `onSignIn` turning the sign-in down. +const rejected = new ConvexError({ reason: "not invited" }); test.each([ { url: "/?convexAuthError=access_denied", flowError: { error: "ACCESS_DENIED" } }, @@ -119,9 +121,9 @@ test.each([ { url: "/?convexAuthCode=code-1", completeSignIn: async () => { - throw new ConvexError({ reason: "not invited" }); + throw rejected; }, - flowError: { error: "REJECTED", data: { reason: "not invited" } }, + flowError: { error: "OTHER_ERROR", cause: rejected }, }, { url: "/?convexAuthError=oauth_error", diff --git a/packages/convex-auth-tanstack-start/src/vite.ts b/packages/convex-auth-tanstack-start/src/vite.ts index e9ee28f..1b10b27 100644 --- a/packages/convex-auth-tanstack-start/src/vite.ts +++ b/packages/convex-auth-tanstack-start/src/vite.ts @@ -15,7 +15,7 @@ export function convexAuth(): Plugin { return { resolve: { alias: [ - // Convex Auth 2.0.0-beta.0 keeps its SSR provider in a file that its exports map does + // Convex Auth 2.0.0 keeps its SSR provider in a file that its exports map does // not expose. The upstream fix is an export (convex/convex-auth#350 and #126). { find: /^@convex-dev\/auth\/ssr\/nextjs\/client$/, @@ -39,6 +39,7 @@ export function convexAuth(): Plugin { include: [ "convex/browser", "convex/react", + "convex/server", "convex/values", "@convex-dev/auth/methods/oauth/react", "@convex-dev/auth/react", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index b56d40d..8df6bfc 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -6,6 +6,9 @@ importers: .: configDependencies: {} packageManagerDependencies: + '@pnpm/exe': + specifier: 12.12.1 + version: 12.12.1 pnpm: specifier: 12.12.1 version: 12.12.1 @@ -89,6 +92,11 @@ packages: cpu: [x64] os: [win32] + '@pnpm/exe@12.12.1': + resolution: {integrity: sha512-0f0+0BPbnEi/4A0AnTaAUmGq8j9jvdR6ZwEQMY2Ham3NbzSK2WODHSTJOcON4P3r1X6lH4J05D9SsHaBeKYh3w==} + engines: {node: '>=18.*'} + hasBin: true + pnpm@12.12.1: resolution: {integrity: sha512-t/mJNMCx8ppl9dpS8tf5lOf6rVc//d3qFJf7Tcta7AUVkO58fZWjgXK0v64QOluD7fLuhm4Rcxwsr6lgY2EKxQ==} engines: {node: '>=18.*'} @@ -138,6 +146,23 @@ snapshots: '@pnpm/exe.win32-x64@12.12.1': optional: true + '@pnpm/exe@12.12.1': + optionalDependencies: + '@pnpm/exe.android-arm64': 12.12.1 + '@pnpm/exe.android-x64': 12.12.1 + '@pnpm/exe.darwin-arm64': 12.12.1 + '@pnpm/exe.darwin-x64': 12.12.1 + '@pnpm/exe.freebsd-x64': 12.12.1 + '@pnpm/exe.linux-arm64': 12.12.1 + '@pnpm/exe.linux-arm64-musl': 12.12.1 + '@pnpm/exe.linux-ppc64': 12.12.1 + '@pnpm/exe.linux-riscv64': 12.12.1 + '@pnpm/exe.linux-s390x': 12.12.1 + '@pnpm/exe.linux-x64': 12.12.1 + '@pnpm/exe.linux-x64-musl': 12.12.1 + '@pnpm/exe.win32-arm64': 12.12.1 + '@pnpm/exe.win32-x64': 12.12.1 + pnpm@12.12.1: optionalDependencies: '@pnpm/exe.android-arm64': 12.12.1 @@ -165,8 +190,8 @@ settings: catalogs: default: '@convex-dev/auth': - specifier: 2.0.0-beta.0 - version: 2.0.0-beta.0 + specifier: 2.0.0 + version: 2.0.0 '@convex-dev/react-query': specifier: 0.1.0 version: 0.1.0 @@ -195,8 +220,8 @@ catalogs: specifier: 6.1.2 version: 6.1.2 convex: - specifier: 1.46.0 - version: 1.46.0 + specifier: 1.48.0 + version: 1.48.0 convex-test: specifier: 0.0.61 version: 0.0.61 @@ -238,7 +263,7 @@ importers: devDependencies: '@convex-dev/eslint-plugin': specifier: 5.0.0 - version: 5.0.0(convex@1.46.0(react@19.3.0))(eslint@10.13.0(jiti@2.7.0)(supports-color@10.2.2))(supports-color@10.2.2)(typescript@7.0.2) + version: 5.0.0(convex@1.48.0(react@19.3.0))(eslint@10.13.0(jiti@2.7.0)(supports-color@10.2.2))(supports-color@10.2.2)(typescript@7.0.2) '@edge-runtime/vm': specifier: 'catalog:' version: 5.0.0 @@ -262,7 +287,7 @@ importers: version: link:../../packages/convex-hosting convex: specifier: 'catalog:' - version: 1.46.0(react@19.3.0) + version: 1.48.0(react@19.3.0) devDependencies: typescript: specifier: 'catalog:' @@ -278,7 +303,7 @@ importers: dependencies: '@convex-dev/react-query': specifier: 'catalog:' - version: 0.1.0(@tanstack/react-query@5.104.2(react@19.3.0))(convex@1.46.0(react@19.3.0)) + version: 0.1.0(@tanstack/react-query@5.104.2(react@19.3.0))(convex@1.48.0(react@19.3.0)) '@samebase/convex-hosting': specifier: workspace:* version: link:../../packages/convex-hosting @@ -293,7 +318,7 @@ importers: version: 1.168.61(@voidzero-dev/vite-plus-core@1.1.0(@types/node@24.19.2)(esbuild@0.28.1)(jiti@2.7.0)(typescript@7.0.2))(esbuild@0.28.1)(react-dom@19.3.0(react@19.3.0))(react@19.3.0)(supports-color@10.2.2) convex: specifier: 'catalog:' - version: 1.46.0(react@19.3.0) + version: 1.48.0(react@19.3.0) react: specifier: 'catalog:' version: 19.3.0 @@ -321,10 +346,10 @@ importers: dependencies: '@convex-dev/auth': specifier: 'catalog:' - version: 2.0.0-beta.0(convex@1.46.0(react@19.3.0))(react@19.3.0)(typescript@7.0.2)(zod@4.6.6) + version: 2.0.0(convex@1.48.0(react@19.3.0))(react@19.3.0)(typescript@7.0.2)(zod@4.6.6) '@convex-dev/react-query': specifier: 'catalog:' - version: 0.1.0(@tanstack/react-query@5.104.2(react@19.3.0))(convex@1.46.0(react@19.3.0)) + version: 0.1.0(@tanstack/react-query@5.104.2(react@19.3.0))(convex@1.48.0(react@19.3.0)) '@samebase/convex-auth-tanstack-start': specifier: workspace:* version: link:../../packages/convex-auth-tanstack-start @@ -348,7 +373,7 @@ importers: version: 1.168.61(@voidzero-dev/vite-plus-core@1.1.0(@types/node@24.19.2)(esbuild@0.28.1)(jiti@2.7.0)(typescript@7.0.2))(esbuild@0.28.1)(react-dom@19.3.0(react@19.3.0))(react@19.3.0)(supports-color@10.2.2) convex: specifier: 'catalog:' - version: 1.46.0(react@19.3.0) + version: 1.48.0(react@19.3.0) react: specifier: 'catalog:' version: 19.3.0 @@ -376,10 +401,10 @@ importers: dependencies: '@convex-dev/auth': specifier: 'catalog:' - version: 2.0.0-beta.0(convex@1.46.0(react@19.3.0))(react@19.3.0)(typescript@7.0.2)(zod@4.6.6) + version: 2.0.0(convex@1.48.0(react@19.3.0))(react@19.3.0)(typescript@7.0.2)(zod@4.6.6) '@convex-dev/react-query': specifier: 'catalog:' - version: 0.1.0(@tanstack/react-query@5.104.2(react@19.3.0))(convex@1.46.0(react@19.3.0)) + version: 0.1.0(@tanstack/react-query@5.104.2(react@19.3.0))(convex@1.48.0(react@19.3.0)) '@samebase/convex-auth-tanstack-start': specifier: workspace:* version: link:../../packages/convex-auth-tanstack-start @@ -397,7 +422,7 @@ importers: version: 1.168.61(@voidzero-dev/vite-plus-core@1.1.0(@types/node@24.19.2)(esbuild@0.28.1)(jiti@2.7.0)(typescript@7.0.2))(esbuild@0.28.1)(react-dom@19.3.0(react@19.3.0))(react@19.3.0)(supports-color@10.2.2) convex: specifier: 'catalog:' - version: 1.46.0(react@19.3.0) + version: 1.48.0(react@19.3.0) react: specifier: 'catalog:' version: 19.3.0 @@ -435,10 +460,10 @@ importers: devDependencies: '@convex-dev/auth': specifier: 'catalog:' - version: 2.0.0-beta.0(convex@1.46.0(react@19.3.0))(react@19.3.0)(typescript@7.0.2)(zod@4.6.6) + version: 2.0.0(convex@1.48.0(react@19.3.0))(react@19.3.0)(typescript@7.0.2)(zod@4.6.6) '@convex-dev/react-query': specifier: 'catalog:' - version: 0.1.0(@tanstack/react-query@5.104.2(react@19.3.0))(convex@1.46.0(react@19.3.0)) + version: 0.1.0(@tanstack/react-query@5.104.2(react@19.3.0))(convex@1.48.0(react@19.3.0)) '@tanstack/react-router': specifier: 'catalog:' version: 1.170.42(react-dom@19.3.0(react@19.3.0))(react@19.3.0) @@ -453,7 +478,7 @@ importers: version: 19.3.0(@types/react@19.3.0) convex: specifier: 'catalog:' - version: 1.46.0(react@19.3.0) + version: 1.48.0(react@19.3.0) react: specifier: 'catalog:' version: 19.3.0 @@ -481,10 +506,10 @@ importers: version: 24.19.2 convex: specifier: 'catalog:' - version: 1.46.0(react@19.3.0) + version: 1.48.0(react@19.3.0) convex-test: specifier: 'catalog:' - version: 0.0.61(convex@1.46.0(react@19.3.0)) + version: 0.0.61(convex@1.48.0(react@19.3.0)) fast-check: specifier: 'catalog:' version: 4.10.2 @@ -658,12 +683,11 @@ packages: cpu: [x64] os: [win32] - '@convex-dev/auth@2.0.0-beta.0': - resolution: {integrity: sha512-GNIYITbRvLg8Ev5YW3j/rJ71Dft/fGYO5kkTJigVwuYCcn3WOeVY9+1IpKDntzMOZou1uDZwlPnR0BcWZWGaKg==} - hasBin: true + '@convex-dev/auth@2.0.0': + resolution: {integrity: sha512-x8tj4BeEkm9R/SlrrVvGS4jvHle4okGM2Ldni7q0KK1lKTpX0QCMDrULagqLUVTepyik23T+TXzcAurNXL1EEg==} peerDependencies: '@convex-dev/resend': ^0.2.8 - convex: ^1.46.0 + convex: ^1.48.0 next: ^16.0.0 react: ^18.0.0 || ^19.0.0 peerDependenciesMeta: @@ -2377,10 +2401,6 @@ packages: resolution: {integrity: sha512-quJQXlTSUGL2LH9SUXo8VwsY4soanhgo6LNSm84E1LBcE8s3O0wpdiRzyR9z/ZZJMlMWv37qOOb9pdJlMUEKFQ==} engines: {node: '>=8'} - ansi-regex@6.4.0: - resolution: {integrity: sha512-KzTVk2tCWAHtYrvvvaP8bJKJq2pVinhLcGEQdtLIYPbmNGNyYe8QwNaTUYQp2J7/vIsUKt5QCqAfUkYyG9DkOw==} - engines: {node: '>=12'} - ansi-styles@5.2.0: resolution: {integrity: sha512-Cxwpt2SfTzTtXcfOlzGEee8O+c+MmUgGrNiBcXnuWxuFJHe6a5Hz7qwhwe5OgaSYI0IJvkLqWX1ASG+cJOkEiA==} engines: {node: '>=10'} @@ -2389,9 +2409,6 @@ packages: resolution: {integrity: sha512-9k3v7xcHwgdO/DruxGIg4HtjvlAZlcnsX/mzqUb1t3NkYnl9kK2UJ+Gq0io+vQf7iT//BD/HB/NBkUR1LWxoeA==} engines: {node: '>=14'} - argon2id-wasm@0.0.0-alpha.2: - resolution: {integrity: sha512-Bxa3aVWUbpg/hKTyHdjeLT68mJXNLftm1W3tXVXu/X83vmpTJ3zzgOhNMzu33Th2iNDxMU1kU4/MEGgW5udMgQ==} - argparse@2.0.1: resolution: {integrity: sha512-8+9WqebbFzpX9OR+Wa6O29asIogeRMzcGtAINdpMHHyAg10f05aSFVBbcEqGf/PXw1EjAZ+q2/bEBg3DvurK3Q==} @@ -2440,26 +2457,10 @@ packages: resolution: {integrity: sha512-XWAtwJ6OHO+tj0EKCs0Y2UamnyOxseZWltU4x2U2wh8g4AigdjwvtUjvLP2tqkA/avxHEtzxNaqGq/YGNwckKg==} engines: {node: '>=18'} - chalk@5.6.2: - resolution: {integrity: sha512-7NzBL0rN6fMUW+f7A6Io4h40qQlG+xGmtMxfbnH/K7TAtt8JQWVQK+6g0UXKMeVJoyV5EkkNsErQ8pVD3bLHbA==} - engines: {node: ^12.17.0 || ^14.13 || >=16.0.0} - chokidar@5.0.0: resolution: {integrity: sha512-TQMmc3w+5AxjpL8iIiwebF73dRDF4fBIieAqGn9RGCWaEVwQ6Fb2cGe31Yns0RRIzii5goJ1Y7xbMwo1TxMplw==} engines: {node: '>= 20.19.0'} - cli-cursor@5.0.0: - resolution: {integrity: sha512-aCj4O5wKyszjMmDT4tZj93kxyydN/K5zPWSCe6/0AV/AA1pqe5ZBIw0a2ZfPQV7lL5/yb5HsUreJ6UFAF1tEQw==} - engines: {node: '>=18'} - - cli-spinners@3.4.0: - resolution: {integrity: sha512-bXfOC4QcT1tKXGorxL3wbJm6XJPDqEnij2gQ2m7ESQuE+/z9YFIWnl/5RpTiKWbMq3EVKR4fRLJGn6DVfu0mpw==} - engines: {node: '>=18.20'} - - commander@14.0.3: - resolution: {integrity: sha512-H+y0Jo/T1RZ9qPP4Eh1pkcQcLRglraJaSLoyOtHxu6AapkjWVCy2Sit1QQ4x3Dng8qDlSsZEet7g5Pq06MvTgw==} - engines: {node: '>=20'} - convert-source-map@2.0.0: resolution: {integrity: sha512-Kvp459HrV2FEJ1CAsi1Ku+MY3kasH19TFykTz2xWmMeq6bk2NU3XXvfJ+Q61m0xktWwt+1HSYf3JZsTms3aRJg==} @@ -2490,8 +2491,8 @@ packages: peerDependencies: convex: ^1.43.0 - convex@1.46.0: - resolution: {integrity: sha512-dhBwDQTZDOhi5SUGAX17EWNehCdNq6/UFrSL0eLZuGfMkdsQbCVWVRZCzbZ5CF+/pgvoGxtApbEoTSipqL4JTw==} + convex@1.48.0: + resolution: {integrity: sha512-M9jEgTvCN8ziP/VgQQUH+j0ijM7g+NmQd8tFlvETK8/HMC/aaqHZwcu4hBO30X5DV2VIyYK4mOoLQGIb1766ew==} engines: {node: '>=20.0.0', npm: '>=7.0.0'} hasBin: true peerDependencies: @@ -2679,10 +2680,6 @@ packages: resolution: {integrity: sha512-3hN7NaskYvMDLQY55gnW3NQ+mesEAepTqlg+VEbj7zzqEMBVNhzcGYYeqFo/TlYz6eQiFcp1HcsCZO+nGgS8zg==} engines: {node: '>=6.9.0'} - get-east-asian-width@1.7.0: - resolution: {integrity: sha512-XjH1AECxf0giL2V1aU8vKyRR2ppRUb5c0EvT7zuJTokQ74bNo52zOtghqdWIqrhUD79fo3x0WfKZdOqxF6LG1Q==} - engines: {node: '>=18'} - glob-parent@6.0.2: resolution: {integrity: sha512-XxwI8EOhVQgWp6iDL+3b0r86f4d6AX6zSU55HfB4ydCEuXLXc5FcYeOu+nnGftS4TEju/11rt4KJPTMgbfmv4A==} engines: {node: '>=10.13.0'} @@ -2727,14 +2724,6 @@ packages: resolution: {integrity: sha512-xelSayHH36ZgE7ZWhli7pW34hNbNl8Ojv5KVmkJD4hBdD3th8Tfk9vYasLM+mXWOZhFkgZfxhLSnrwRr4elSSg==} engines: {node: '>=0.10.0'} - is-interactive@2.0.0: - resolution: {integrity: sha512-qP1vozQRI+BMOPcjFzrjXuQvdak2pHNUMZoeG2eRbiSqyvbEf/wQtEOTOX1guk6E3t36RkaqiSt8A/6YElNxLQ==} - engines: {node: '>=12'} - - is-unicode-supported@2.1.0: - resolution: {integrity: sha512-mE00Gnza5EEB3Ds0HfMyllZzbBrmLOX3vfWoj9A9PEnTfratQ/BcaJOuMhnkhjXvb2+FkY3VuHqtAGpTPmglFQ==} - engines: {node: '>=18'} - isbot@5.2.2: resolution: {integrity: sha512-iQcBXcd+Rv/pkubRyGh2utW2j1oPG5hZY6TUhVPpqK4G+o3IbxpJNx04hgksjc/N7GK5pEorUxDeg31cFgEk/w==} engines: {node: '>=18'} @@ -2861,10 +2850,6 @@ packages: resolution: {integrity: sha512-iPZK6eYjbxRu3uB4/WZ3EsEIMJFMqAoopl3R+zuq0UjcAm/MO6KCweDgPfP3elTztoKP3KtnVHxTn2NHBSDVUw==} engines: {node: '>=10'} - log-symbols@7.0.1: - resolution: {integrity: sha512-ja1E3yCr9i/0hmBVaM0bfwDjnGy8I/s6PP4DFp+yP+a+mrHO4Rm7DtmnqROTUkHIkqffC84YY7AeqX6oFk0WFg==} - engines: {node: '>=18'} - lru-cache@5.1.1: resolution: {integrity: sha512-KpNARQA3Iwv+jTA0utUVVbrh+Jlrr1Fv0e56GGzAFOXN7dk/FviaDW8LHmK52DlcH4WP2n6gI8vN1aesBFgo9w==} @@ -2883,10 +2868,6 @@ packages: engines: {node: '>=16'} hasBin: true - mimic-function@5.0.1: - resolution: {integrity: sha512-VP79XUPxV2CigYP3jWwAUFSku2aKqBH7uTAapFWCBqutsbmDo96KY5o8uh6U+/YSIn5OxJnXp73beVkpqMIGhA==} - engines: {node: '>=18'} - miniflare@5.20261006.0-alpha: resolution: {integrity: sha512-UP3qIeQKHba59GHxBqD8H2GateacluT4vrjIpqEgH78kCSUxdu8jA0f7MH7ftRSAnnB1oOvEsDtav3xevQDbpQ==} engines: {node: '>=22.0.0'} @@ -2918,18 +2899,10 @@ packages: resolution: {integrity: sha512-5vvB5+W7ePv+p3uqxi+RcW1XAzLW0/hxt3/4X4Lc4qHudzOhmBiBwOY6DRob4WnanAEGvNcLjF+KNOufrUoEQw==} engines: {node: '>=12.20.0'} - onetime@7.0.0: - resolution: {integrity: sha512-VXJjc87FScF88uafS3JllDgvAm+c/Slfz06lorj2uAY34rlUu0Nt+v8wreiImcrgAjjIHp1rXpTDlLOGw29WwQ==} - engines: {node: '>=18'} - optionator@0.9.4: resolution: {integrity: sha512-6IpQ7mKUxRcZNLIObR0hz7lxsapSSIYNZJwXPGeF0mTVqGKFIXj1DQcMoT22S3ROcLyY/rz0PWaWZ9ayWmad9g==} engines: {node: '>= 0.8.0'} - ora@9.4.1: - resolution: {integrity: sha512-6VlU9MLXbjVQD04AZCMX28hVtA5bUoadvUqO76MUCVA0ilwJbMiHsITRPfyVm6p/BC0Av/BXMujx39WCe1LEqw==} - engines: {node: '>=20'} - oxfmt@0.72.0: resolution: {integrity: sha512-16OQeL0uhPZbfmT9S9WWM0Nv9+BmVi8Ra1uTYaSKj/qSCs6FB30KOhz9JoNYw6thT+K5bVxsk/tSEOu497i34g==} engines: {node: ^20.19.0 || >=22.12.0} @@ -2968,6 +2941,9 @@ packages: resolution: {integrity: sha512-LaNjtRWUBY++zB5nE/NwcaoMylSPk+S+ZHNB1TzdbMJMny6dynpAGt7X/tl/QYq3TIeE6nxHppbo2LGymrG5Pw==} engines: {node: '>=10'} + password-hash-wasm@0.0.0: + resolution: {integrity: sha512-SpVGWB4mMf8VuHM1LqrZWLPtH7B4K2vVqAZ6pAnL/eeTLtPqewwnt0DD7428xUPSDrEWd2SDoLoU4z61gj9sYw==} + path-exists@4.0.0: resolution: {integrity: sha512-ak9Qy5Q7jYb2Wwcey5Fpvg2KoAc/ZIhLSLOSBmRmygPsGwkVVt0fZa0qrtMz+m6tJTAHfZQ8FnmB4MG4LWy7/w==} engines: {node: '>=8'} @@ -3051,10 +3027,6 @@ packages: reflect-metadata@0.2.2: resolution: {integrity: sha512-urBwgfrvVP/eAyXx4hluJivBKzuEbSQs9rKWCrCkbSxNv8mxPcUZKeuoF3Uy4mJl3Lwprp6yy5/39VWigZ4K6Q==} - restore-cursor@5.1.0: - resolution: {integrity: sha512-oMA2dcrw6u0YfxJQXm342bFKX/E4sG9rbTzO9ptUcR/e8A33cHuvStiYOwH7fszkZlZ1z/ta9AAoPk2F4qIOHA==} - engines: {node: '>=18'} - rou3@0.8.1: resolution: {integrity: sha512-ePa+XGk00/3HuCqrEnK3LxJW7I0SdNg6EFzKUJG73hMAdDcOUC/i/aSz7LSDwLrGr33kal/rqOGydzwl6U7zBA==} @@ -3097,10 +3069,6 @@ packages: resolution: {integrity: sha512-7++dFhtcx3353uBaq8DDR4NuxBetBzC7ZQOhmTQInHEd6bSrXdiEyzCvG07Z44UYdLShWUyXt5M/yhz8ekcb1A==} engines: {node: '>=8'} - signal-exit@4.1.0: - resolution: {integrity: sha512-bzyZ1e88w9O1iNJbKnOlvYTrWPDl46O1bG0D3XInv+9tkPrxrN8jUUTiFlDkkmKWgn1M6CfIA13SuGqOa9Korw==} - engines: {node: '>=14'} - sirv@3.0.2: resolution: {integrity: sha512-2wcC/oGxHis/BoHkkPwldgiPSYcpZK3JU28WoMVv55yHJgcZ8rlXvuG9iZggz+sU1d4bRgIGASwyWqjxu3FM0g==} engines: {node: '>=18'} @@ -3121,18 +3089,6 @@ packages: std-env@4.3.0: resolution: {integrity: sha512-OtU/EgQ1kIm5KwqQpBC6ZEMXrZRui11w8zgfTWp8cdO9B8OaPsbA8bTHO2P+HNo1VlUTGMVBwPhydu6poeXiag==} - stdin-discarder@0.3.2: - resolution: {integrity: sha512-eCPu1qRxPVkl5605OTWF8Wz40b4Mf45NY5LQmVPQ599knfs5QhASUm9GbJ5BDMDOXgrnh0wyEdvzmL//YMlw0A==} - engines: {node: '>=18'} - - string-width@8.3.0: - resolution: {integrity: sha512-ZbmZM0JCihQN91dWnxoipT2KOEyHqEyfRXUyjuRhW8b/xnqPDoq4gWEVApTVa9db2wN8mmoikgFBbjh71+cGeQ==} - engines: {node: '>=20'} - - strip-ansi@7.2.0: - resolution: {integrity: sha512-yDPMNjp4WyfYBkHnjIRLfca1i6KMyGCtsVgoKe/z1+6vukgaENdgGBZt+ZmKPc4gavvEZ5OgHfHdrazhgNyG7w==} - engines: {node: '>=12'} - supports-color@10.2.2: resolution: {integrity: sha512-SS+jx45GF1QjgEXQx4NJZV9ImqmO2NPz5FNsIHrsDjh2YsHnawpan7SNQ1o8NuhrbHZy9AZhIoCUiCeaW/C80g==} engines: {node: '>=18'} @@ -3385,10 +3341,6 @@ packages: resolution: {integrity: sha512-rVksvsnNCdJ/ohGc6xgPwyN8eheCxsiLM8mxuE/t/mOVqJewPuO1miLpTHQiRgTKCLexL4MeAFVagts7HmNZ2Q==} engines: {node: '>=10'} - yoctocolors@2.2.0: - resolution: {integrity: sha512-xYqdZFUK/VYazNl/oCDYN+3WloWQwMfZxBoiNt6qNyk+xfOdi598muWE42rNZFp1kNOiqW936q5RhUdnpqElSg==} - engines: {node: '>=18'} - youch-core@0.3.3: resolution: {integrity: sha512-ho7XuGjLaJ2hWHoK8yFnsUGy2Y5uDpqSTq1FkHLK4/oqKtyUU1AFbOOxY4IpC9f0fTLjwYbslUz0Po5BpD1wrA==} @@ -3562,20 +3514,16 @@ snapshots: '@cloudflare/workerd-windows-64@1.20261006.1': optional: true - '@convex-dev/auth@2.0.0-beta.0(convex@1.46.0(react@19.3.0))(react@19.3.0)(typescript@7.0.2)(zod@4.6.6)': + '@convex-dev/auth@2.0.0(convex@1.48.0(react@19.3.0))(react@19.3.0)(typescript@7.0.2)(zod@4.6.6)': dependencies: - '@babel/code-frame': 7.29.7 - '@convex-dev/batch-worker': 0.3.6(convex@1.46.0(react@19.3.0))(react@19.3.0)(typescript@7.0.2)(zod@4.6.6) - '@convex-dev/rate-limiter': 0.3.2(convex@1.46.0(react@19.3.0))(react@19.3.0) + '@convex-dev/batch-worker': 0.3.6(convex@1.48.0(react@19.3.0))(react@19.3.0)(typescript@7.0.2)(zod@4.6.6) + '@convex-dev/rate-limiter': 0.3.2(convex@1.48.0(react@19.3.0))(react@19.3.0) '@simplewebauthn/browser': 14.0.0 '@simplewebauthn/server': 14.0.3 - argon2id-wasm: 0.0.0-alpha.2 - chalk: 5.6.2 - commander: 14.0.3 - convex: 1.46.0(react@19.3.0) + convex: 1.48.0(react@19.3.0) cookie: 1.1.1 jose: 5.10.0 - ora: 9.4.1 + password-hash-wasm: 0.0.0 optionalDependencies: react: 19.3.0 transitivePeerDependencies: @@ -3584,10 +3532,10 @@ snapshots: - typescript - zod - '@convex-dev/batch-worker@0.3.6(convex@1.46.0(react@19.3.0))(react@19.3.0)(typescript@7.0.2)(zod@4.6.6)': + '@convex-dev/batch-worker@0.3.6(convex@1.48.0(react@19.3.0))(react@19.3.0)(typescript@7.0.2)(zod@4.6.6)': dependencies: - convex: 1.46.0(react@19.3.0) - convex-helpers: 0.1.128(convex@1.46.0(react@19.3.0))(react@19.3.0)(typescript@7.0.2)(zod@4.6.6) + convex: 1.48.0(react@19.3.0) + convex-helpers: 0.1.128(convex@1.48.0(react@19.3.0))(react@19.3.0)(typescript@7.0.2)(zod@4.6.6) transitivePeerDependencies: - '@standard-schema/spec' - hono @@ -3595,26 +3543,26 @@ snapshots: - typescript - zod - '@convex-dev/eslint-plugin@5.0.0(convex@1.46.0(react@19.3.0))(eslint@10.13.0(jiti@2.7.0)(supports-color@10.2.2))(supports-color@10.2.2)(typescript@7.0.2)': + '@convex-dev/eslint-plugin@5.0.0(convex@1.48.0(react@19.3.0))(eslint@10.13.0(jiti@2.7.0)(supports-color@10.2.2))(supports-color@10.2.2)(typescript@7.0.2)': dependencies: '@typescript-eslint/types': 8.58.2 '@typescript-eslint/utils': 8.58.2(eslint@10.13.0(jiti@2.7.0)(supports-color@10.2.2))(supports-color@10.2.2)(typescript@7.0.2) - convex: 1.46.0(react@19.3.0) + convex: 1.48.0(react@19.3.0) transitivePeerDependencies: - eslint - supports-color - typescript - '@convex-dev/rate-limiter@0.3.2(convex@1.46.0(react@19.3.0))(react@19.3.0)': + '@convex-dev/rate-limiter@0.3.2(convex@1.48.0(react@19.3.0))(react@19.3.0)': dependencies: - convex: 1.46.0(react@19.3.0) + convex: 1.48.0(react@19.3.0) optionalDependencies: react: 19.3.0 - '@convex-dev/react-query@0.1.0(@tanstack/react-query@5.104.2(react@19.3.0))(convex@1.46.0(react@19.3.0))': + '@convex-dev/react-query@0.1.0(@tanstack/react-query@5.104.2(react@19.3.0))(convex@1.48.0(react@19.3.0))': dependencies: '@tanstack/react-query': 5.104.2(react@19.3.0) - convex: 1.46.0(react@19.3.0) + convex: 1.48.0(react@19.3.0) '@cspotcode/source-map-support@0.8.1': dependencies: @@ -4954,14 +4902,10 @@ snapshots: ansi-regex@5.0.1: {} - ansi-regex@6.4.0: {} - ansi-styles@5.2.0: {} ansis@4.4.0: {} - argon2id-wasm@0.0.0-alpha.2: {} - argparse@2.0.1: {} aria-query@5.3.0: @@ -5015,35 +4959,25 @@ snapshots: chai@6.3.0: {} - chalk@5.6.2: {} - chokidar@5.0.0: dependencies: readdirp: 5.1.1 - cli-cursor@5.0.0: - dependencies: - restore-cursor: 5.1.0 - - cli-spinners@3.4.0: {} - - commander@14.0.3: {} - convert-source-map@2.0.0: {} - convex-helpers@0.1.128(convex@1.46.0(react@19.3.0))(react@19.3.0)(typescript@7.0.2)(zod@4.6.6): + convex-helpers@0.1.128(convex@1.48.0(react@19.3.0))(react@19.3.0)(typescript@7.0.2)(zod@4.6.6): dependencies: - convex: 1.46.0(react@19.3.0) + convex: 1.48.0(react@19.3.0) optionalDependencies: react: 19.3.0 typescript: 7.0.2 zod: 4.6.6 - convex-test@0.0.61(convex@1.46.0(react@19.3.0)): + convex-test@0.0.61(convex@1.48.0(react@19.3.0)): dependencies: - convex: 1.46.0(react@19.3.0) + convex: 1.48.0(react@19.3.0) - convex@1.46.0(react@19.3.0): + convex@1.48.0(react@19.3.0): dependencies: esbuild: 0.27.0 prettier: 3.9.10 @@ -5264,8 +5198,6 @@ snapshots: gensync@1.0.0-beta.2: {} - get-east-asian-width@1.7.0: {} - glob-parent@6.0.2: dependencies: is-glob: 4.0.3 @@ -5295,10 +5227,6 @@ snapshots: dependencies: is-extglob: 2.1.1 - is-interactive@2.0.0: {} - - is-unicode-supported@2.1.0: {} - isbot@5.2.2: {} isexe@2.0.0: {} @@ -5385,11 +5313,6 @@ snapshots: dependencies: p-locate: 5.0.0 - log-symbols@7.0.1: - dependencies: - is-unicode-supported: 2.1.0 - yoctocolors: 2.2.0 - lru-cache@5.1.1: dependencies: yallist: 3.1.1 @@ -5406,8 +5329,6 @@ snapshots: mime@4.1.1: {} - mimic-function@5.0.1: {} - miniflare@5.20261006.0-alpha(@types/node@24.19.2): dependencies: '@cspotcode/source-map-support': 0.8.1 @@ -5437,10 +5358,6 @@ snapshots: obug@3.0.0: {} - onetime@7.0.0: - dependencies: - mimic-function: 5.0.1 - optionator@0.9.4: dependencies: deep-is: 0.1.4 @@ -5450,17 +5367,6 @@ snapshots: type-check: 0.4.0 word-wrap: 1.2.5 - ora@9.4.1: - dependencies: - chalk: 5.6.2 - cli-cursor: 5.0.0 - cli-spinners: 3.4.0 - is-interactive: 2.0.0 - is-unicode-supported: 2.1.0 - log-symbols: 7.0.1 - stdin-discarder: 0.3.2 - string-width: 8.3.0 - oxfmt@0.72.0(vite-plus@1.1.0(@edge-runtime/vm@5.0.0)(@types/node@24.19.2)(esbuild@0.28.1)(jiti@2.7.0)(typescript@7.0.2)): dependencies: tinypool: 2.2.0 @@ -5527,6 +5433,8 @@ snapshots: dependencies: p-limit: 3.1.0 + password-hash-wasm@0.0.0: {} + path-exists@4.0.0: {} path-key@3.1.1: {} @@ -5586,11 +5494,6 @@ snapshots: reflect-metadata@0.2.2: {} - restore-cursor@5.1.0: - dependencies: - onetime: 7.0.0 - signal-exit: 4.1.0 - rou3@0.8.1: {} scheduler@0.28.0: {} @@ -5644,8 +5547,6 @@ snapshots: shebang-regex@3.0.0: {} - signal-exit@4.1.0: {} - sirv@3.0.2: dependencies: '@polka/url': 1.0.0-next.29 @@ -5660,17 +5561,6 @@ snapshots: std-env@4.3.0: {} - stdin-discarder@0.3.2: {} - - string-width@8.3.0: - dependencies: - get-east-asian-width: 1.7.0 - strip-ansi: 7.2.0 - - strip-ansi@7.2.0: - dependencies: - ansi-regex: 6.4.0 - supports-color@10.2.2: {} tinybench@6.2.2: {} @@ -5898,8 +5788,6 @@ snapshots: yocto-queue@0.1.0: {} - yoctocolors@2.2.0: {} - youch-core@0.3.3: dependencies: '@poppinss/exception': 1.2.3 diff --git a/pnpm-workspace.yaml b/pnpm-workspace.yaml index 0703b77..bcb5d58 100644 --- a/pnpm-workspace.yaml +++ b/pnpm-workspace.yaml @@ -3,7 +3,7 @@ packages: - "examples/*" catalog: - "@convex-dev/auth": 2.0.0-beta.0 + "@convex-dev/auth": 2.0.0 "@convex-dev/react-query": 0.1.0 "@edge-runtime/vm": 5.0.0 "@tanstack/react-query": 5.104.2 @@ -13,7 +13,7 @@ catalog: "@types/react": 19.3.0 "@types/react-dom": 19.3.0 "@vitejs/plugin-react": 6.1.2 - convex: 1.46.0 + convex: 1.48.0 ignore: 7.0.12 mime: 4.1.1 convex-test: 0.0.61 @@ -43,8 +43,12 @@ minimumReleaseAge: 10080 minimumReleaseAgeStrict: true minimumReleaseAgeIgnoreMissingTime: false minimumReleaseAgeExclude: - # 2.0.0-beta.0 of 2026-10-15; remove after 2026-10-22. - - "@convex-dev/auth@2.0.0-beta.0" + # Convex Auth 2.0.0, the stable release, published 2026-11-12 17:22 UTC. Remove after + # 2026-11-19 17:23 UTC. + - "@convex-dev/auth@2.0.0" + # Convex Auth 2.0.0's password hashing, a dependency of it, published 2026-11-09 23:53 UTC. + # Remove after 2026-11-16 23:54 UTC. + - "password-hash-wasm@0.0.0" blockExoticSubdeps: true trustPolicy: no-downgrade trustPolicyExclude: From cbd8d7e3bcc2bbd1ad7500ff98ebefd651ee556e Mon Sep 17 00:00:00 2001 From: Nicu Chiciuc Date: Sun, 15 Nov 2026 17:11:40 +0200 Subject: [PATCH 2/3] examples: Convex Auth 2.0.0, with username and password sign-in 2.0.0 no longer exports the anonymous method, so both SSR examples sign up and sign in with a username and a password (the authPassword and authUsername components). The deployment signs the tokens (convexAuthProvider()), so the key pair variables and their setup steps go. The core serves no HTTP routes, so convex/http.ts drops its exact /auth routes and the catch-all reaches the app's server. --- examples/tanstack-ssr-workers.patch | 33 +++++------ examples/tanstack-ssr-workers/README.md | 34 ++++++------ .../convex/_generated/api.d.ts | 3 +- .../convex/_generated/server.d.ts | 2 - .../convex/auth.config.ts | 15 +---- examples/tanstack-ssr-workers/convex/auth.ts | 11 ++-- .../convex/convex.config.ts | 17 ++---- .../tanstack-ssr-workers/convex/schema.ts | 5 +- examples/tanstack-ssr-workers/convex/todos.ts | 9 ++- examples/tanstack-ssr-workers/convex/users.ts | 23 +++----- .../src/routes/__root.tsx | 6 +- .../src/routes/signin.tsx | 55 ++++++++++++++++--- examples/tanstack-ssr-workers/src/server.ts | 2 +- examples/tanstack-ssr/README.md | 38 ++++++------- .../tanstack-ssr/convex/_generated/api.d.ts | 3 +- .../convex/_generated/server.d.ts | 2 - examples/tanstack-ssr/convex/auth.config.ts | 15 +---- examples/tanstack-ssr/convex/auth.ts | 11 ++-- examples/tanstack-ssr/convex/convex.config.ts | 17 ++---- examples/tanstack-ssr/convex/http.ts | 9 +-- examples/tanstack-ssr/convex/schema.ts | 5 +- examples/tanstack-ssr/convex/todos.ts | 9 ++- examples/tanstack-ssr/convex/users.ts | 23 +++----- examples/tanstack-ssr/src/routes/__root.tsx | 6 +- examples/tanstack-ssr/src/routes/signin.tsx | 55 ++++++++++++++++--- examples/tanstack-ssr/src/server.ts | 2 +- 26 files changed, 221 insertions(+), 189 deletions(-) diff --git a/examples/tanstack-ssr-workers.patch b/examples/tanstack-ssr-workers.patch index 4325014..fb80a58 100644 --- a/examples/tanstack-ssr-workers.patch +++ b/examples/tanstack-ssr-workers.patch @@ -1,27 +1,25 @@ diff --git a/convex/convex.config.ts b/convex/convex.config.ts -index 1831f4b4fa5703fe1332d9cf45fb2308a57be703..dcc4d5f09735722e1164710651a0c69d58a01869 100644 +index f1de5f3eb4076bb0989528ea47c6b3d6c3f0727c..9fafe59d4ef5e805e2b6a168a6d646b985d1c278 100644 --- a/convex/convex.config.ts +++ b/convex/convex.config.ts -@@ -2,7 +2,6 @@ import { defineApp } from "convex/server"; - import { v } from "convex/values"; +@@ -2,11 +2,9 @@ import { defineApp } from "convex/server"; import auth from "@convex-dev/auth/convex.config"; - import anonymous from "@convex-dev/auth/components/anonymous/convex.config"; + import authPassword from "@convex-dev/auth/components/password/convex.config"; + import authUsername from "@convex-dev/auth/components/username/convex.config"; -import hosting from "@samebase/convex-hosting/convex.config"; - // A push fails while either variable is missing on the deployment. - const app = defineApp({ -@@ -13,5 +12,4 @@ app.use(auth, { - env: { AUTH_PRIVATE_KEY: app.env.AUTH_PRIVATE_KEY, AUTH_JWKS: app.env.AUTH_JWKS }, - }); - app.use(anonymous); + const app = defineApp(); + app.use(auth); + app.use(authPassword); + app.use(authUsername); -app.use(hosting); export default app; diff --git a/convex/http.ts b/convex/http.ts deleted file mode 100644 -index 4ae60e6c413b09f9d22481a9cba1b67b633b2529..0000000000000000000000000000000000000000 +index c9e6b0a32b33e4806a813d1d311e98ee44334735..0000000000000000000000000000000000000000 --- a/convex/http.ts +++ /dev/null -@@ -1,21 +0,0 @@ +@@ -1,16 +0,0 @@ -import { httpRouter } from "convex/server"; -import { routeAll } from "@samebase/convex-hosting"; -import { components } from "./_generated/api.js"; @@ -34,13 +32,8 @@ index 4ae60e6c413b09f9d22481a9cba1b67b633b2529..00000000000000000000000000000000 - -// Every method, every path: a file for a path that has one (another method than GET or HEAD on it -// answers 405), the app's server (src/server.ts) for every other path, as a Cloudflare Worker with --// static assets does. --const handler = routeAll({ http, component: components.hosting, assets, worker: server }); --// Exact routes for the three auth paths: the Convex Auth component holds the /auth prefix, where it --// serves the key set, and the longest prefix wins, so the catch-all above never sees them. --for (const path of ["/auth/signin", "/auth/refresh", "/auth/signout"]) { -- http.route({ path, method: "POST", handler }); --} +-// static assets does. The /auth routes are the app's server's too: Convex Auth serves no HTTP routes. +-routeAll({ http, component: components.hosting, assets, worker: server }); - -export default http; diff --git a/package.json b/package.json @@ -87,7 +80,7 @@ index 011481b677588aa747f29f9a0945abe4b382e3bd..8eb172e64d333d2718fca213710cf8ea } } diff --git a/src/server.ts b/src/server.ts -index c4c4df479192d2a3feb175659b9de1420d5a8b8f..a6c3d84c461c20ddc45b4eaeb577c5e92abdad29 100644 +index eb6502e41bcd04c3e1b8f20df3ce2fb5f88e0046..f13b1405e9ccc54710aecb61f29acd62d16b7bd0 100644 --- a/src/server.ts +++ b/src/server.ts @@ -1,5 +1,5 @@ diff --git a/examples/tanstack-ssr-workers/README.md b/examples/tanstack-ssr-workers/README.md index e6e4cc5..cb5f8df 100644 --- a/examples/tanstack-ssr-workers/README.md +++ b/examples/tanstack-ssr-workers/README.md @@ -17,9 +17,9 @@ own Convex project. ## Kinds of pages -The demo data is a to-do list in `convex/todos.ts`, after the one in `samebase/base`: each anonymous -user gets a readable name when it is created, todos have an author and a done state, and a public -site needs caps on text length and todos per user. +The demo data is a to-do list in `convex/todos.ts`, after the one in `samebase/base`: each user is +named by the username they signed up with, todos have an author and a done state, and a public site +needs caps on text length and todos per user. - `/about`: a static file from the build. `vite.config.ts` has TanStack Start prerender this page only, into `dist/client/about/index.html`, and Cloudflare serves it like any other file: `/about` @@ -37,7 +37,8 @@ site needs caps on text length and todos per user. `todos.list`, the form adds one with `todos.add`, and a checkbox toggles `todos.toggle`. The page sits behind the pathless layout in `src/routes/_authed.tsx`: without a session, the server redirects to `/signin`, and the browser does the same when the session ends. -- `/signin`: a button that signs in anonymously and opens `/todos`. +- `/signin`: a username and a password, with a button that signs in and one that signs up, and then + opens `/todos`. - The header on every page: the root route's loader queries `users.me`, so the first HTML response of a rendered page shows `Signed in as ` with a sign-out button, or a link to `/signin`. The build has no session, so on `/about` the header fills in after React hydrates. @@ -64,10 +65,16 @@ none. `expectAuth` holds queries only before the first authentication, so sign-o The cookies are `Secure` when the request came over HTTPS, and not in `pnpm run dev`, which serves plain HTTP. -The example signs in anonymously: each sign-in creates a user. Password sign-in changes the provider -in `convex/convex.config.ts` and `convex/auth.ts`, the `signIn: [...]` list in `src/server.ts`, and -the button on `/signin`. The other routes stay the same. OAuth sign-in adds a provider's component, -its functions, its `completeSignIn*` function in the `signIn` list, and a button, as that package's +The provider also subscribes to the app's `isAuthenticated` query while signed in, so a session that +ends on the deployment signs the browser out at once, and the gate leaves `/todos`. + +The example signs in with Convex Auth's username and password method: its `authPassword` and +`authUsername` components in `convex/convex.config.ts`, and its sign-up and sign-in functions in +`convex/auth.ts` and in the `signIn: [...]` list of `src/server.ts`. Another method changes those +three places and the form on `/signin`. The other routes stay the same. The deployment signs the +tokens with its own key (`convexAuthProvider()` in `convex/auth.config.ts`), so no deployment needs +a key pair. OAuth sign-in adds a provider's component, its functions, its `completeSignIn*` function +in the `signIn` list, and a button, as that package's [OAuth sign-in](../../packages/convex-auth-tanstack-start/README.md#oauth-sign-in) says. ## Where code goes @@ -93,14 +100,10 @@ From `examples/tanstack-ssr-workers`: ```sh pnpm install -npx convex dev --skip-push # creates your dev deployment and .env.local, no push -npx @convex-dev/auth # new deployment only: sets AUTH_PRIVATE_KEY and AUTH_JWKS on it -npx convex dev # pushes, then work as usual +npx convex dev # creates your dev deployment and .env.local, pushes, keeps running pnpm run dev # in a second terminal ``` -Production needs its own key pair on the production deployment before the first deploy. - The Cloudflare Vite plugin passes the values of `.env.local` to the local Worker as variables and copies them into `dist/server/.dev.vars`; `wrangler deploy` does not upload that file. @@ -117,11 +120,6 @@ Workers Builds runs `pnpm run deploy` (`wrangler deploy`) on `main` and `pnpm ru (`wrangler preview`) on other branches. Both read the configuration that the build wrote to `dist/server/wrangler.json`. -The preview deployments need the signing keys as the project's defaults for preview deployments, -which Convex copies into each new preview before the first push: -`npx convex env default set --type preview AUTH_PRIVATE_KEY ...` and the same for `AUTH_JWKS`. Use a -pair of their own, not the production pair. - ## Commands - `pnpm run dev`: Vite's dev server, with the Worker in Cloudflare's runtime, and `npx convex dev` diff --git a/examples/tanstack-ssr-workers/convex/_generated/api.d.ts b/examples/tanstack-ssr-workers/convex/_generated/api.d.ts index cb95893..d1960b1 100644 --- a/examples/tanstack-ssr-workers/convex/_generated/api.d.ts +++ b/examples/tanstack-ssr-workers/convex/_generated/api.d.ts @@ -52,5 +52,6 @@ export declare const internal: FilterApi< export declare const components: { auth: import("@convex-dev/auth/_generated/component.js").ComponentApi<"auth">; - authAnonymous: import("@convex-dev/auth/components/anonymous/_generated/component.js").ComponentApi<"authAnonymous">; + authPassword: import("@convex-dev/auth/components/password/_generated/component.js").ComponentApi<"authPassword">; + authUsername: import("@convex-dev/auth/components/username/_generated/component.js").ComponentApi<"authUsername">; }; diff --git a/examples/tanstack-ssr-workers/convex/_generated/server.d.ts b/examples/tanstack-ssr-workers/convex/_generated/server.d.ts index 96819a6..f235db4 100644 --- a/examples/tanstack-ssr-workers/convex/_generated/server.d.ts +++ b/examples/tanstack-ssr-workers/convex/_generated/server.d.ts @@ -30,8 +30,6 @@ import type { DataModel } from "./dataModel.js"; type Env = { readonly CONVEX_CLOUD_URL: string; readonly CONVEX_SITE_URL: string; - readonly AUTH_JWKS: string; - readonly AUTH_PRIVATE_KEY: string; }; /** diff --git a/examples/tanstack-ssr-workers/convex/auth.config.ts b/examples/tanstack-ssr-workers/convex/auth.config.ts index 4205875..03f69c1 100644 --- a/examples/tanstack-ssr-workers/convex/auth.config.ts +++ b/examples/tanstack-ssr-workers/convex/auth.config.ts @@ -1,16 +1,7 @@ import type { AuthConfig } from "convex/server"; -import { env } from "./_generated/server.js"; +import { convexAuthProvider } from "@convex-dev/auth/server"; -// The core signs tokens for the issuer CONVEX_SITE_URL and the audience "convex", and serves the -// key set under its /auth mount. +// The deployment signs the tokens with its own key, so the app keeps no key pair. export default { - providers: [ - { - type: "customJwt", - applicationID: "convex", - issuer: env.CONVEX_SITE_URL, - jwks: `${env.CONVEX_SITE_URL}/auth/.well-known/jwks.json`, - algorithm: "RS256", - }, - ], + providers: [convexAuthProvider()], } satisfies AuthConfig; diff --git a/examples/tanstack-ssr-workers/convex/auth.ts b/examples/tanstack-ssr-workers/convex/auth.ts index f1c1a1f..996a17a 100644 --- a/examples/tanstack-ssr-workers/convex/auth.ts +++ b/examples/tanstack-ssr-workers/convex/auth.ts @@ -1,10 +1,11 @@ import { setupConvexAuth } from "@convex-dev/auth/server"; -import { setupAnonymous } from "@convex-dev/auth/methods/anonymous/server"; +import { setupUsernamePassword } from "@convex-dev/auth/methods/username-password/server"; import { components, internal } from "./_generated/api.js"; const core = setupConvexAuth({ component: components.auth }); -export const { signOut, refreshSession } = core; +export const { signOut, refreshSession, isAuthenticated } = core; -export const { signInAnonymously } = setupAnonymous(core, { - component: components.authAnonymous, -}).attachUserCallbacks({ createUser: internal.users.createUserAnonymous }); +export const { signUpWithUsernamePassword, signInWithUsernamePassword } = setupUsernamePassword( + core, + { component: components.authPassword, usernameComponent: components.authUsername }, +).attachUserCallbacks({ createUser: internal.users.createUser }); diff --git a/examples/tanstack-ssr-workers/convex/convex.config.ts b/examples/tanstack-ssr-workers/convex/convex.config.ts index dcc4d5f..9fafe59 100644 --- a/examples/tanstack-ssr-workers/convex/convex.config.ts +++ b/examples/tanstack-ssr-workers/convex/convex.config.ts @@ -1,15 +1,10 @@ import { defineApp } from "convex/server"; -import { v } from "convex/values"; import auth from "@convex-dev/auth/convex.config"; -import anonymous from "@convex-dev/auth/components/anonymous/convex.config"; +import authPassword from "@convex-dev/auth/components/password/convex.config"; +import authUsername from "@convex-dev/auth/components/username/convex.config"; -// A push fails while either variable is missing on the deployment. -const app = defineApp({ - env: { AUTH_PRIVATE_KEY: v.string(), AUTH_JWKS: v.string() }, -}); -app.use(auth, { - httpPrefix: "/auth", - env: { AUTH_PRIVATE_KEY: app.env.AUTH_PRIVATE_KEY, AUTH_JWKS: app.env.AUTH_JWKS }, -}); -app.use(anonymous); +const app = defineApp(); +app.use(auth); +app.use(authPassword); +app.use(authUsername); export default app; diff --git a/examples/tanstack-ssr-workers/convex/schema.ts b/examples/tanstack-ssr-workers/convex/schema.ts index 1f3398e..4348e58 100644 --- a/examples/tanstack-ssr-workers/convex/schema.ts +++ b/examples/tanstack-ssr-workers/convex/schema.ts @@ -6,6 +6,7 @@ export default defineSchema({ "by_user", ["userId"], ), - // One document for each Convex Auth user. The auth components keep the accounts and sessions. - users: defineTable({ name: v.string() }), + // One document for each Convex Auth user. The auth components keep the usernames, the passwords, + // and the sessions. + users: defineTable({}), }); diff --git a/examples/tanstack-ssr-workers/convex/todos.ts b/examples/tanstack-ssr-workers/convex/todos.ts index ac66267..fa68edd 100644 --- a/examples/tanstack-ssr-workers/convex/todos.ts +++ b/examples/tanstack-ssr-workers/convex/todos.ts @@ -1,9 +1,10 @@ import { getAuthUserId } from "@convex-dev/auth/server"; import { v } from "convex/values"; +import { components } from "./_generated/api.js"; import type { Id } from "./_generated/dataModel.js"; import { mutation, query } from "./_generated/server.js"; -// The site is public and sign-in is anonymous, so each user and each todo stays small. +// The site is public and anyone can sign up, so each user and each todo stays small. const MAX_TODOS_PER_USER = 50; const MAX_TEXT_LENGTH = 280; @@ -17,8 +18,10 @@ export const latest = query({ const names = new Map, string>(); for (const todo of todos) { if (!names.has(todo.userId)) { - const user = await ctx.db.get("users", todo.userId); - names.set(todo.userId, user?.name ?? "Guest"); + const name = await ctx.runQuery(components.authUsername.public.getUsername, { + userId: todo.userId, + }); + names.set(todo.userId, name ?? "Guest"); } } return todos.map((todo) => ({ diff --git a/examples/tanstack-ssr-workers/convex/users.ts b/examples/tanstack-ssr-workers/convex/users.ts index 5ec54c2..4e40269 100644 --- a/examples/tanstack-ssr-workers/convex/users.ts +++ b/examples/tanstack-ssr-workers/convex/users.ts @@ -1,23 +1,13 @@ import { getAuthUserId } from "@convex-dev/auth/server"; import { v } from "convex/values"; +import { components } from "./_generated/api.js"; import { internalMutation, query } from "./_generated/server.js"; -const NAMES = ["Ash", "Birch", "Cedar", "Dune", "Elm", "Fern", "Grove", "Harbor", "Ivy", "Juniper"]; - -export const createUserAnonymous = internalMutation({ - args: { - provider: v.object({ - name: v.literal("anonymous"), - accountId: v.string(), - profile: v.object({}), - }), - }, +export const createUser = internalMutation({ + args: { method: v.object({ name: v.literal("usernamePassword"), profile: v.object({}) }) }, returns: v.id("users"), - handler: async (ctx) => { - // A readable name instead of an id. Two users can share one; nothing depends on the name. - const name = `${NAMES[Math.floor(Math.random() * NAMES.length)]} ${Math.floor(Math.random() * 900) + 100}`; - return await ctx.db.insert("users", { name }); - }, + // The username component keeps the username; the user document holds nothing yet. + handler: async (ctx) => await ctx.db.insert("users", {}), }); export const me = query({ @@ -28,6 +18,7 @@ export const me = query({ if (userId === null) return null; const user = await ctx.db.get("users", userId); if (user === null) return null; - return { id: user._id, name: user.name, since: user._creationTime }; + const name = await ctx.runQuery(components.authUsername.public.getUsername, { userId }); + return { id: user._id, name: name ?? "Guest", since: user._creationTime }; }, }); diff --git a/examples/tanstack-ssr-workers/src/routes/__root.tsx b/examples/tanstack-ssr-workers/src/routes/__root.tsx index e4ddff4..0037756 100644 --- a/examples/tanstack-ssr-workers/src/routes/__root.tsx +++ b/examples/tanstack-ssr-workers/src/routes/__root.tsx @@ -44,7 +44,11 @@ export const Route = createRootRouteWithContext<{ function Root() { const { convexQueryClient, token } = Route.useRouteContext(); return ( - + diff --git a/examples/tanstack-ssr-workers/src/routes/signin.tsx b/examples/tanstack-ssr-workers/src/routes/signin.tsx index eca5130..cadbfec 100644 --- a/examples/tanstack-ssr-workers/src/routes/signin.tsx +++ b/examples/tanstack-ssr-workers/src/routes/signin.tsx @@ -1,5 +1,10 @@ import { createFileRoute } from "@tanstack/react-router"; -import { useSignInAnonymously } from "@convex-dev/auth/methods/anonymous/react"; +import { DEFAULT_MIN_PASSWORD_LENGTH } from "@convex-dev/auth/methods/username-password"; +import { + useSignInWithUsernamePassword, + useSignUpWithUsernamePassword, +} from "@convex-dev/auth/methods/username-password/react"; +import { useState } from "react"; import { api } from "../../convex/_generated/api.js"; export const Route = createFileRoute("/signin")({ @@ -7,22 +12,56 @@ export const Route = createFileRoute("/signin")({ }); function SignIn() { - const { signIn } = useSignInAnonymously(api.auth); + const { signIn } = useSignInWithUsernamePassword(api.auth); + const { signUp } = useSignUpWithUsernamePassword(api.auth); + const [username, setUsername] = useState(""); + const [password, setPassword] = useState(""); + const [error, setError] = useState(null); return (

Sign in

- + setUsername(event.target.value)} + /> + setPassword(event.target.value)} + autoComplete="current-password" + minLength={DEFAULT_MIN_PASSWORD_LENGTH} + required + /> + + + + {error !== null &&

{`Failed: ${error}`}

}
); } diff --git a/examples/tanstack-ssr-workers/src/server.ts b/examples/tanstack-ssr-workers/src/server.ts index a6c3d84..f13b140 100644 --- a/examples/tanstack-ssr-workers/src/server.ts +++ b/examples/tanstack-ssr-workers/src/server.ts @@ -22,7 +22,7 @@ const server = { convexUrl, refreshSession: api.auth.refreshSession, signOut: api.auth.signOut, - signIn: [api.auth.signInAnonymously], + signIn: [api.auth.signInWithUsernamePassword, api.auth.signUpWithUsernamePassword], cookieOptions, }); switch (url.pathname) { diff --git a/examples/tanstack-ssr/README.md b/examples/tanstack-ssr/README.md index 75c1f2b..9f74a12 100644 --- a/examples/tanstack-ssr/README.md +++ b/examples/tanstack-ssr/README.md @@ -12,9 +12,9 @@ example has its own schema, so it needs its own Convex project. ## Kinds of pages -The demo data is a to-do list in `convex/todos.ts`, after the one in `samebase/base`: each anonymous -user gets a readable name when it is created, todos have an author and a done state, and a public -site needs caps on text length and todos per user. +The demo data is a to-do list in `convex/todos.ts`, after the one in `samebase/base`: each user is +named by the username they signed up with, todos have an author and a done state, and a public site +needs caps on text length and todos per user. - `/about`: a static file from the build. `vite.config.ts` has TanStack Start prerender this page only, into `dist/client/about/index.html`, and `routeAll` serves it like any other file. As on @@ -30,7 +30,8 @@ site needs caps on text length and todos per user. `todos.list`, the form adds one with `todos.add`, and a checkbox toggles `todos.toggle`. The page sits behind the pathless layout in `src/routes/_authed.tsx`: without a session, the server redirects to `/signin`, and the browser does the same when the session ends. -- `/signin`: a button that signs in anonymously and opens `/todos`. +- `/signin`: a username and a password, with a button that signs in and one that signs up, and then + opens `/todos`. - `/stream`: the loader returns a promise that resolves two seconds later, without awaiting it. The document goes out at once with a fallback, and the value follows in a later chunk, as on a Worker; the header's link requests the document, because a navigation inside the app would run the loader @@ -62,10 +63,16 @@ Convex's AuthKit template decides `expectAuth` on the server per request; TanSta client before the page knows the session, so `SessionProvider` releases it when the provider reports none. `expectAuth` holds queries only before the first authentication, so sign-out reloads the page. -The example signs in anonymously: each sign-in creates a user. Password sign-in changes the provider -in `convex/convex.config.ts` and `convex/auth.ts`, the `signIn: [...]` list in `src/server.ts`, and -the button on `/signin`. The other routes stay the same. OAuth sign-in adds a provider's component, -its functions, its `completeSignIn*` function in the `signIn` list, and a button, as that package's +The provider also subscribes to the app's `isAuthenticated` query while signed in, so a session that +ends on the deployment signs the browser out at once, and the gate leaves `/todos`. + +The example signs in with Convex Auth's username and password method: its `authPassword` and +`authUsername` components in `convex/convex.config.ts`, and its sign-up and sign-in functions in +`convex/auth.ts` and in the `signIn: [...]` list of `src/server.ts`. Another method changes those +three places and the form on `/signin`. The other routes stay the same. The deployment signs the +tokens with its own key (`convexAuthProvider()` in `convex/auth.config.ts`), so no deployment needs +a key pair. OAuth sign-in adds a provider's component, its functions, its `completeSignIn*` function +in the `signIn` list, and a button, as that package's [OAuth sign-in](../../packages/convex-auth-tanstack-start/README.md#oauth-sign-in) says. ## Where code goes @@ -101,7 +108,6 @@ npx convex dev # creates your dev deployment and .env.local; In another: ```sh -npx @convex-dev/auth # new deployment only: sets AUTH_PRIVATE_KEY and AUTH_JWKS on it pnpm run deploy:dev # builds, uploads, writes .convex-hosting/version.js, pushes ``` @@ -117,8 +123,6 @@ URL when it ends. Local deployment (anonymous or `--local`): the backend runs inside `npx convex dev`, so the first terminal must stay open while `deploy:dev` uploads, else the upload fails with `fetch failed`. -Production needs its own key pair on the production deployment before the first `pnpm run deploy`. - ## Previews `.github/workflows/preview-examples.yml` deploys each pull request to a Convex preview deployment @@ -126,15 +130,9 @@ named after its branch, through [`actions/preview`](../../actions/preview/action request shows the site URL as a deployment. A second push reuses the deployment, and closing the pull request deletes it ([`actions/cleanup`](../../actions/cleanup/action.yml)). Convex deletes a preview deployment some days after its creation (five on the free plan), and the hosting component's -files go with it. The workflow needs two things once per project: - -- A preview deploy key, as the repository secret `CONVEX_PREVIEW_DEPLOY_KEY_TANSTACK_SSR`. The - dashboard creates one under Project Settings, and so does the platform API - (`POST /v1/projects//create_preview_deploy_key`). -- The signing keys as the project's defaults for preview deployments, which Convex copies into each - new preview before the first push: - `npx convex env default set --type preview AUTH_PRIVATE_KEY ...` and the same for `AUTH_JWKS`. Use - a pair of their own, not the production pair. +files go with it. The workflow needs a preview deploy key once per project, as the repository secret +`CONVEX_PREVIEW_DEPLOY_KEY_TANSTACK_SSR`. The dashboard creates one under Project Settings, and so +does the platform API (`POST /v1/projects//create_preview_deploy_key`). ## Commands diff --git a/examples/tanstack-ssr/convex/_generated/api.d.ts b/examples/tanstack-ssr/convex/_generated/api.d.ts index 42a9757..7ad7490 100644 --- a/examples/tanstack-ssr/convex/_generated/api.d.ts +++ b/examples/tanstack-ssr/convex/_generated/api.d.ts @@ -54,6 +54,7 @@ export declare const internal: FilterApi< export declare const components: { auth: import("@convex-dev/auth/_generated/component.js").ComponentApi<"auth">; - authAnonymous: import("@convex-dev/auth/components/anonymous/_generated/component.js").ComponentApi<"authAnonymous">; + authPassword: import("@convex-dev/auth/components/password/_generated/component.js").ComponentApi<"authPassword">; + authUsername: import("@convex-dev/auth/components/username/_generated/component.js").ComponentApi<"authUsername">; hosting: import("@samebase/convex-hosting/_generated/component.js").ComponentApi<"hosting">; }; diff --git a/examples/tanstack-ssr/convex/_generated/server.d.ts b/examples/tanstack-ssr/convex/_generated/server.d.ts index 96819a6..f235db4 100644 --- a/examples/tanstack-ssr/convex/_generated/server.d.ts +++ b/examples/tanstack-ssr/convex/_generated/server.d.ts @@ -30,8 +30,6 @@ import type { DataModel } from "./dataModel.js"; type Env = { readonly CONVEX_CLOUD_URL: string; readonly CONVEX_SITE_URL: string; - readonly AUTH_JWKS: string; - readonly AUTH_PRIVATE_KEY: string; }; /** diff --git a/examples/tanstack-ssr/convex/auth.config.ts b/examples/tanstack-ssr/convex/auth.config.ts index 4205875..03f69c1 100644 --- a/examples/tanstack-ssr/convex/auth.config.ts +++ b/examples/tanstack-ssr/convex/auth.config.ts @@ -1,16 +1,7 @@ import type { AuthConfig } from "convex/server"; -import { env } from "./_generated/server.js"; +import { convexAuthProvider } from "@convex-dev/auth/server"; -// The core signs tokens for the issuer CONVEX_SITE_URL and the audience "convex", and serves the -// key set under its /auth mount. +// The deployment signs the tokens with its own key, so the app keeps no key pair. export default { - providers: [ - { - type: "customJwt", - applicationID: "convex", - issuer: env.CONVEX_SITE_URL, - jwks: `${env.CONVEX_SITE_URL}/auth/.well-known/jwks.json`, - algorithm: "RS256", - }, - ], + providers: [convexAuthProvider()], } satisfies AuthConfig; diff --git a/examples/tanstack-ssr/convex/auth.ts b/examples/tanstack-ssr/convex/auth.ts index f1c1a1f..996a17a 100644 --- a/examples/tanstack-ssr/convex/auth.ts +++ b/examples/tanstack-ssr/convex/auth.ts @@ -1,10 +1,11 @@ import { setupConvexAuth } from "@convex-dev/auth/server"; -import { setupAnonymous } from "@convex-dev/auth/methods/anonymous/server"; +import { setupUsernamePassword } from "@convex-dev/auth/methods/username-password/server"; import { components, internal } from "./_generated/api.js"; const core = setupConvexAuth({ component: components.auth }); -export const { signOut, refreshSession } = core; +export const { signOut, refreshSession, isAuthenticated } = core; -export const { signInAnonymously } = setupAnonymous(core, { - component: components.authAnonymous, -}).attachUserCallbacks({ createUser: internal.users.createUserAnonymous }); +export const { signUpWithUsernamePassword, signInWithUsernamePassword } = setupUsernamePassword( + core, + { component: components.authPassword, usernameComponent: components.authUsername }, +).attachUserCallbacks({ createUser: internal.users.createUser }); diff --git a/examples/tanstack-ssr/convex/convex.config.ts b/examples/tanstack-ssr/convex/convex.config.ts index 1831f4b..f1de5f3 100644 --- a/examples/tanstack-ssr/convex/convex.config.ts +++ b/examples/tanstack-ssr/convex/convex.config.ts @@ -1,17 +1,12 @@ import { defineApp } from "convex/server"; -import { v } from "convex/values"; import auth from "@convex-dev/auth/convex.config"; -import anonymous from "@convex-dev/auth/components/anonymous/convex.config"; +import authPassword from "@convex-dev/auth/components/password/convex.config"; +import authUsername from "@convex-dev/auth/components/username/convex.config"; import hosting from "@samebase/convex-hosting/convex.config"; -// A push fails while either variable is missing on the deployment. -const app = defineApp({ - env: { AUTH_PRIVATE_KEY: v.string(), AUTH_JWKS: v.string() }, -}); -app.use(auth, { - httpPrefix: "/auth", - env: { AUTH_PRIVATE_KEY: app.env.AUTH_PRIVATE_KEY, AUTH_JWKS: app.env.AUTH_JWKS }, -}); -app.use(anonymous); +const app = defineApp(); +app.use(auth); +app.use(authPassword); +app.use(authUsername); app.use(hosting); export default app; diff --git a/examples/tanstack-ssr/convex/http.ts b/examples/tanstack-ssr/convex/http.ts index 4ae60e6..c9e6b0a 100644 --- a/examples/tanstack-ssr/convex/http.ts +++ b/examples/tanstack-ssr/convex/http.ts @@ -10,12 +10,7 @@ const http = httpRouter(); // Every method, every path: a file for a path that has one (another method than GET or HEAD on it // answers 405), the app's server (src/server.ts) for every other path, as a Cloudflare Worker with -// static assets does. -const handler = routeAll({ http, component: components.hosting, assets, worker: server }); -// Exact routes for the three auth paths: the Convex Auth component holds the /auth prefix, where it -// serves the key set, and the longest prefix wins, so the catch-all above never sees them. -for (const path of ["/auth/signin", "/auth/refresh", "/auth/signout"]) { - http.route({ path, method: "POST", handler }); -} +// static assets does. The /auth routes are the app's server's too: Convex Auth serves no HTTP routes. +routeAll({ http, component: components.hosting, assets, worker: server }); export default http; diff --git a/examples/tanstack-ssr/convex/schema.ts b/examples/tanstack-ssr/convex/schema.ts index 1f3398e..4348e58 100644 --- a/examples/tanstack-ssr/convex/schema.ts +++ b/examples/tanstack-ssr/convex/schema.ts @@ -6,6 +6,7 @@ export default defineSchema({ "by_user", ["userId"], ), - // One document for each Convex Auth user. The auth components keep the accounts and sessions. - users: defineTable({ name: v.string() }), + // One document for each Convex Auth user. The auth components keep the usernames, the passwords, + // and the sessions. + users: defineTable({}), }); diff --git a/examples/tanstack-ssr/convex/todos.ts b/examples/tanstack-ssr/convex/todos.ts index ac66267..fa68edd 100644 --- a/examples/tanstack-ssr/convex/todos.ts +++ b/examples/tanstack-ssr/convex/todos.ts @@ -1,9 +1,10 @@ import { getAuthUserId } from "@convex-dev/auth/server"; import { v } from "convex/values"; +import { components } from "./_generated/api.js"; import type { Id } from "./_generated/dataModel.js"; import { mutation, query } from "./_generated/server.js"; -// The site is public and sign-in is anonymous, so each user and each todo stays small. +// The site is public and anyone can sign up, so each user and each todo stays small. const MAX_TODOS_PER_USER = 50; const MAX_TEXT_LENGTH = 280; @@ -17,8 +18,10 @@ export const latest = query({ const names = new Map, string>(); for (const todo of todos) { if (!names.has(todo.userId)) { - const user = await ctx.db.get("users", todo.userId); - names.set(todo.userId, user?.name ?? "Guest"); + const name = await ctx.runQuery(components.authUsername.public.getUsername, { + userId: todo.userId, + }); + names.set(todo.userId, name ?? "Guest"); } } return todos.map((todo) => ({ diff --git a/examples/tanstack-ssr/convex/users.ts b/examples/tanstack-ssr/convex/users.ts index 5ec54c2..4e40269 100644 --- a/examples/tanstack-ssr/convex/users.ts +++ b/examples/tanstack-ssr/convex/users.ts @@ -1,23 +1,13 @@ import { getAuthUserId } from "@convex-dev/auth/server"; import { v } from "convex/values"; +import { components } from "./_generated/api.js"; import { internalMutation, query } from "./_generated/server.js"; -const NAMES = ["Ash", "Birch", "Cedar", "Dune", "Elm", "Fern", "Grove", "Harbor", "Ivy", "Juniper"]; - -export const createUserAnonymous = internalMutation({ - args: { - provider: v.object({ - name: v.literal("anonymous"), - accountId: v.string(), - profile: v.object({}), - }), - }, +export const createUser = internalMutation({ + args: { method: v.object({ name: v.literal("usernamePassword"), profile: v.object({}) }) }, returns: v.id("users"), - handler: async (ctx) => { - // A readable name instead of an id. Two users can share one; nothing depends on the name. - const name = `${NAMES[Math.floor(Math.random() * NAMES.length)]} ${Math.floor(Math.random() * 900) + 100}`; - return await ctx.db.insert("users", { name }); - }, + // The username component keeps the username; the user document holds nothing yet. + handler: async (ctx) => await ctx.db.insert("users", {}), }); export const me = query({ @@ -28,6 +18,7 @@ export const me = query({ if (userId === null) return null; const user = await ctx.db.get("users", userId); if (user === null) return null; - return { id: user._id, name: user.name, since: user._creationTime }; + const name = await ctx.runQuery(components.authUsername.public.getUsername, { userId }); + return { id: user._id, name: name ?? "Guest", since: user._creationTime }; }, }); diff --git a/examples/tanstack-ssr/src/routes/__root.tsx b/examples/tanstack-ssr/src/routes/__root.tsx index e4ddff4..0037756 100644 --- a/examples/tanstack-ssr/src/routes/__root.tsx +++ b/examples/tanstack-ssr/src/routes/__root.tsx @@ -44,7 +44,11 @@ export const Route = createRootRouteWithContext<{ function Root() { const { convexQueryClient, token } = Route.useRouteContext(); return ( - + diff --git a/examples/tanstack-ssr/src/routes/signin.tsx b/examples/tanstack-ssr/src/routes/signin.tsx index eca5130..cadbfec 100644 --- a/examples/tanstack-ssr/src/routes/signin.tsx +++ b/examples/tanstack-ssr/src/routes/signin.tsx @@ -1,5 +1,10 @@ import { createFileRoute } from "@tanstack/react-router"; -import { useSignInAnonymously } from "@convex-dev/auth/methods/anonymous/react"; +import { DEFAULT_MIN_PASSWORD_LENGTH } from "@convex-dev/auth/methods/username-password"; +import { + useSignInWithUsernamePassword, + useSignUpWithUsernamePassword, +} from "@convex-dev/auth/methods/username-password/react"; +import { useState } from "react"; import { api } from "../../convex/_generated/api.js"; export const Route = createFileRoute("/signin")({ @@ -7,22 +12,56 @@ export const Route = createFileRoute("/signin")({ }); function SignIn() { - const { signIn } = useSignInAnonymously(api.auth); + const { signIn } = useSignInWithUsernamePassword(api.auth); + const { signUp } = useSignUpWithUsernamePassword(api.auth); + const [username, setUsername] = useState(""); + const [password, setPassword] = useState(""); + const [error, setError] = useState(null); return (

Sign in

- + setUsername(event.target.value)} + /> + setPassword(event.target.value)} + autoComplete="current-password" + minLength={DEFAULT_MIN_PASSWORD_LENGTH} + required + /> + + + + {error !== null &&

{`Failed: ${error}`}

}
); } diff --git a/examples/tanstack-ssr/src/server.ts b/examples/tanstack-ssr/src/server.ts index c4c4df4..eb6502e 100644 --- a/examples/tanstack-ssr/src/server.ts +++ b/examples/tanstack-ssr/src/server.ts @@ -22,7 +22,7 @@ const server = { convexUrl, refreshSession: api.auth.refreshSession, signOut: api.auth.signOut, - signIn: [api.auth.signInAnonymously], + signIn: [api.auth.signInWithUsernamePassword, api.auth.signUpWithUsernamePassword], cookieOptions, }); switch (url.pathname) { From e4bd0e8ef611fda9a5b77a3d6ef40eef582e1c32 Mon Sep 17 00:00:00 2001 From: Nicu Chiciuc Date: Sun, 15 Nov 2026 17:11:51 +0200 Subject: [PATCH 3/3] docs: Convex Auth 2.0.0 serves no /auth routes and signs with the deployment's key --- docs/design.md | 13 +++++++------ docs/domains.md | 2 +- docs/workers.md | 3 ++- 3 files changed, 10 insertions(+), 8 deletions(-) diff --git a/docs/design.md b/docs/design.md index 7b1091a..1b8842d 100644 --- a/docs/design.md +++ b/docs/design.md @@ -201,10 +201,11 @@ part in it. The app's `convex/http.ts` calls `routeAll`, which routes the site's action, one `pathPrefix: "/"` route per method Convex routes, because every request reaches a Cloudflare Worker's asset router: a file answers GET, another method on a file answers 405, and a request that matches no file goes to -the app's server. A server-rendered app with Convex Auth adds one exact `POST` route per `/auth` -path: the Convex Auth component holds the `/auth` prefix, where it serves the key set, and Convex -picks the longest matching prefix, so only an exact route reaches the app there. Convex answers -`HEAD` through the `GET` handler and drops the body. +the app's server. A server-rendered app with Convex Auth adds no route for its `/auth` paths: Convex +Auth 2.0.0's core serves no HTTP routes, so the catch-all reaches the app's server there. Convex +picks an exact route first, then the longest matching prefix, so an OAuth component's `httpPrefix`, +such as `/auth/github`, still takes its callback. Convex answers `HEAD` through the `GET` handler +and drops the body. ```ts import { routeAll } from "@samebase/convex-hosting"; @@ -530,7 +531,7 @@ The session pieces moved from the adapter's `convex-auth` entry to the auth pack | The gate | Auth package: `redirectWithoutSession` and `RedirectWithoutSession`; the app gives the redirect options | Only the server render has the cookie; the browser follows the provider | | The session state in components | Auth package: `SignedIn` and `SignedOut` | Convex's provider reports loading during the server render and the hydration | | The cookie session lines in `src/server.ts` | Convex Auth's own API, written in the app | A helper for HTTP actions belongs upstream | -| The `/auth/*` routes | Convex Auth's own API (`setupConvexAuthServer`), answered by `src/server.ts`; `convex/http.ts` forwards the three `POST`s | The handlers are Convex Auth's; the paths are the app's, and the cookies belong to the site's origin | +| The `/auth/*` routes | Convex Auth's own API (`setupConvexAuthServer`), answered by `src/server.ts`; the catch-all of `routeAll` reaches it | The handlers are Convex Auth's; the paths are the app's, and the cookies belong to the site's origin | | The Convex Auth setup files | App, with Convex Auth's own API | The providers and the users table are the app's | | Deploy and preview commands | Hosting package: `convex-hosting deploy`, in the app's scripts and CI | The upload must run between the build and the push | @@ -552,7 +553,7 @@ or ChessMerge goes; the list is checked at every release. At 0.8.0 and 0.5.0 tha | adapter `vite`: `convexSsr()` | `vite.config.ts` of server-rendered apps | The `ssr` environment settings that make Start's server build run in Convex's runtime, the `node:stream` stub included | | adapter `server` | `src/server.ts` of server-rendered apps | Start's own stream handler, typed as TanStack's `RequestHandler`, so `fetch(request, { context })` takes the app's registered context; pages stream as on a Worker | | adapter `server-build` (types) | `convex/http.ts` of server-rendered apps | The type of the built server module: `{ fetch(request) }`, the shape of the app's `src/server.ts` | -| auth `vite`: `convexAuth()` | `vite.config.ts` of both SSR examples, next to `convexSsr()` or Cloudflare's plugin | Resolves the Convex Auth 2.0.0-beta.0 file that holds the SSR provider, which its exports map does not expose, and keeps one copy of Convex Auth in development | +| auth `vite`: `convexAuth()` | `vite.config.ts` of both SSR examples, next to `convexSsr()` or Cloudflare's plugin | Resolves the Convex Auth 2.0.0 file that holds the SSR provider, which its exports map does not expose, and keeps one copy of Convex Auth in development | | auth `.`: `sessionBeforeLoad` | The root route | The same `beforeLoad` in every app with cookie sessions | | auth `.`: `SessionProvider` | The root component | Convex Auth's provider with the server token, plus the release of `expectAuth` for a signed-out visitor | | auth `.`: `redirectWithoutSession`, `RedirectWithoutSession` | The `_authed` layout | The server render has the cookie; the browser follows the provider; two moments, two pieces | diff --git a/docs/domains.md b/docs/domains.md index cd1d1ad..7f9aaa3 100644 --- a/docs/domains.md +++ b/docs/domains.md @@ -12,7 +12,7 @@ Cloudflare, make the `CNAME` DNS only; Convex documents a proxied record as an 30 minutes. Do not choose the domain under "Override Environment Variables". That changes `CONVEX_SITE_URL` -everywhere in the app, and Convex Auth uses it as the token issuer and in its redirect URLs. +everywhere in the app, and Convex Auth's OAuth components use it in their callback URLs. To move a domain from another host, such as a Worker's custom domain, add the `TXT` record first, then replace the old record with the `CNAME` right away. While the name has no record, resolvers diff --git a/docs/workers.md b/docs/workers.md index d513af8..f2aa33f 100644 --- a/docs/workers.md +++ b/docs/workers.md @@ -54,4 +54,5 @@ with: the production build variables, and the project's preview deploy key in Previews Base. Builds reads the Node and pnpm versions from the repository's `.node-version` and `packageManager`. -The example's README describes the Convex side: the signing keys of production and of previews. +The Convex side needs nothing else: each deployment, previews included, signs the session tokens +with its own key.