[PR #7902] [CLOSED] Auth api context typing #24523

Closed
opened 2026-04-15 22:24:40 -05:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/better-auth/better-auth/pull/7902
Author: @Bekacru
Created: 2/11/2026
Status: Closed

Base: canaryHead: cursor/auth-api-context-typing-80cb


📝 Commits (1)

  • 91c957e feat(types): add typed context parameter to auth.api endpoints

📊 Changes

4 files changed (+213 additions, -37 deletions)

View changed files

📝 packages/better-auth/src/api/to-auth-endpoints.ts (+19 -7)
📝 packages/better-auth/src/types/api.ts (+141 -28)
📝 packages/better-auth/src/types/auth.ts (+1 -1)
📝 packages/better-auth/src/types/types.test.ts (+52 -1)

📄 Description

Add typed context parameter to all auth.api calls to allow users to pass partial AuthContext objects.

This enables server-side context overrides and improves type safety for auth.api endpoint inputs.


Slack Thread

Open in Cursor Open in Web


Summary by cubic

Adds a typed context parameter to all auth.api endpoints so callers can pass a partial AuthContext (e.g., session). This enables server-side overrides and avoids extra lookups while improving type safety.

  • New Features
    • All endpoints, including getSession, now accept context with a DeepPartial AuthContext.
    • User-provided context is merged with internal defaults; session defaults to null unless supplied; existing endpoint overloads (asResponse/returnHeaders/returnStatus) are preserved.
    • Introduces APIContextInput, WithContextInput, AddContextToAPI; updates InferAPI; adds type tests verifying context support.

Written for commit 91c957e7a4. Summary will update on new commits.


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/better-auth/better-auth/pull/7902 **Author:** [@Bekacru](https://github.com/Bekacru) **Created:** 2/11/2026 **Status:** ❌ Closed **Base:** `canary` ← **Head:** `cursor/auth-api-context-typing-80cb` --- ### 📝 Commits (1) - [`91c957e`](https://github.com/better-auth/better-auth/commit/91c957e7a4b3fb4867601db30fd7100cc5b8b88d) feat(types): add typed context parameter to auth.api endpoints ### 📊 Changes **4 files changed** (+213 additions, -37 deletions) <details> <summary>View changed files</summary> 📝 `packages/better-auth/src/api/to-auth-endpoints.ts` (+19 -7) 📝 `packages/better-auth/src/types/api.ts` (+141 -28) 📝 `packages/better-auth/src/types/auth.ts` (+1 -1) 📝 `packages/better-auth/src/types/types.test.ts` (+52 -1) </details> ### 📄 Description Add typed `context` parameter to all `auth.api` calls to allow users to pass partial `AuthContext` objects. This enables server-side context overrides and improves type safety for `auth.api` endpoint inputs. --- [Slack Thread](https://betterauth.slack.com/archives/C0A8B5BARUK/p1770771748538879?thread_ts=1770771748.538879&cid=C0A8B5BARUK) <p><a href="https://cursor.com/background-agent?bcId=bc-55ef9871-c961-57d9-b0cf-7f64f10ee1ec"><picture><source media="(prefers-color-scheme: dark)" srcset="https://cursor.com/assets/images/open-in-cursor-dark.png"><source media="(prefers-color-scheme: light)" srcset="https://cursor.com/assets/images/open-in-cursor-light.png"><img alt="Open in Cursor" width="131" height="28" src="https://cursor.com/assets/images/open-in-cursor-dark.png"></picture></a>&nbsp;<a href="https://cursor.com/agents?id=bc-55ef9871-c961-57d9-b0cf-7f64f10ee1ec"><picture><source media="(prefers-color-scheme: dark)" srcset="https://cursor.com/assets/images/open-in-web-dark.png"><source media="(prefers-color-scheme: light)" srcset="https://cursor.com/assets/images/open-in-web-light.png"><img alt="Open in Web" width="114" height="28" src="https://cursor.com/assets/images/open-in-web-dark.png"></picture></a></p> <!-- This is an auto-generated description by cubic. --> --- ## Summary by cubic Adds a typed context parameter to all auth.api endpoints so callers can pass a partial AuthContext (e.g., session). This enables server-side overrides and avoids extra lookups while improving type safety. - New Features - All endpoints, including getSession, now accept context with a DeepPartial AuthContext. - User-provided context is merged with internal defaults; session defaults to null unless supplied; existing endpoint overloads (asResponse/returnHeaders/returnStatus) are preserved. - Introduces APIContextInput, WithContextInput, AddContextToAPI; updates InferAPI; adds type tests verifying context support. <sup>Written for commit 91c957e7a4b3fb4867601db30fd7100cc5b8b88d. Summary will update on new commits.</sup> <!-- End of auto-generated description by cubic. --> --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
GiteaMirror added the pull-request label 2026-04-15 22:24:40 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/better-auth#24523