[PR #7146] [MERGED] chore(core): add BetterAuthPluginRegistry for type system #24002

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

📋 Pull Request Information

Original PR: https://github.com/better-auth/better-auth/pull/7146
Author: @himself65
Created: 1/6/2026
Status: Merged
Merged: 1/7/2026
Merged by: @himself65

Base: canaryHead: himself65/2026/01/06/plugin-system


📝 Commits (9)

📊 Changes

43 files changed (+408 additions, -72 deletions)

View changed files

📝 knip.jsonc (+3 -1)
📝 packages/better-auth/src/context/create-context.ts (+3 -5)
📝 packages/better-auth/src/plugins/admin/admin.ts (+9 -0)
📝 packages/better-auth/src/plugins/anonymous/index.ts (+9 -0)
📝 packages/better-auth/src/plugins/api-key/index.ts (+9 -0)
📝 packages/better-auth/src/plugins/bearer/index.ts (+9 -0)
📝 packages/better-auth/src/plugins/captcha/index.ts (+10 -0)
📝 packages/better-auth/src/plugins/custom-session/index.ts (+9 -0)
📝 packages/better-auth/src/plugins/device-authorization/index.ts (+9 -0)
📝 packages/better-auth/src/plugins/email-otp/index.ts (+9 -0)
📝 packages/better-auth/src/plugins/generic-oauth/index.ts (+9 -0)
📝 packages/better-auth/src/plugins/haveibeenpwned/index.ts (+10 -1)
📝 packages/better-auth/src/plugins/jwt/index.ts (+9 -0)
📝 packages/better-auth/src/plugins/last-login-method/index.ts (+8 -0)
📝 packages/better-auth/src/plugins/magic-link/index.ts (+9 -0)
📝 packages/better-auth/src/plugins/mcp/index.ts (+9 -0)
📝 packages/better-auth/src/plugins/multi-session/index.ts (+9 -0)
📝 packages/better-auth/src/plugins/oauth-proxy/index.ts (+9 -0)
📝 packages/better-auth/src/plugins/oidc-provider/index.ts (+12 -8)
📝 packages/better-auth/src/plugins/one-tap/index.ts (+9 -0)

...and 23 more files

📄 Description

Summary by cubic

Introduces a typed plugin registry (BetterAuthPluginRegistry) and updates getPlugin to return strongly typed plugin instances based on registry entries. Standardizes plugin IDs to kebab-case and hardens JWT/OAuth/OIDC flows when the JWT plugin is absent.

  • Refactors

    • Added BetterAuthPluginRegistry and BetterAuthPluginRegistryIdentifier in core; getPlugin infers types from each plugin’s creator and returns null when missing.
    • Registered plugins in the registry across built-ins and standardized IDs (oidc-provider, oauth-provider, have-i-been-pwned); updated OAuth/OIDC to use context.getPlugin("jwt") with null-safe checks and lazy lookup.
  • Migration

    • Plugin authors should augment BetterAuthPluginRegistry with their plugin ID and creator type so getPlugin returns the correct instance type, and adopt the new kebab-case plugin IDs where renamed.

Written for commit 344ca40e45. 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/7146 **Author:** [@himself65](https://github.com/himself65) **Created:** 1/6/2026 **Status:** ✅ Merged **Merged:** 1/7/2026 **Merged by:** [@himself65](https://github.com/himself65) **Base:** `canary` ← **Head:** `himself65/2026/01/06/plugin-system` --- ### 📝 Commits (9) - [`d39e94a`](https://github.com/better-auth/better-auth/commit/d39e94a19034734aee17c679969968c5ac4ed18d) chore(core): add `BetterAuthPluginRegistry` for type system - [`a013485`](https://github.com/better-auth/better-auth/commit/a013485a5d80a2c9169e3a67c986b71043828d43) fix: type - [`08d9b10`](https://github.com/better-auth/better-auth/commit/08d9b10848de0cf927d63f84eee7c2b8677ed424) fix: lint - [`d88ad86`](https://github.com/better-auth/better-auth/commit/d88ad86d24eaa99d2d5e8ba8569b5d0e5552bbb1) fix: type - [`62ac150`](https://github.com/better-auth/better-auth/commit/62ac1500256dd022f25121c1743f9bfff9f040fc) fix: lint - [`8b9ba20`](https://github.com/better-auth/better-auth/commit/8b9ba20b990d894e991b335ea9191d858ffbb149) fix: type - [`9cd7bc2`](https://github.com/better-auth/better-auth/commit/9cd7bc25f82aa767fa648275d5674a001c984c32) Merge branch 'canary' into himself65/2026/01/06/plugin-system - [`26cdec0`](https://github.com/better-auth/better-auth/commit/26cdec0508611cf70fafdea8abe37a992bbaab83) fix: type - [`344ca40`](https://github.com/better-auth/better-auth/commit/344ca40e45d8c19ff68f83db0ee8894c5cd234c5) fix: tyep ### 📊 Changes **43 files changed** (+408 additions, -72 deletions) <details> <summary>View changed files</summary> 📝 `knip.jsonc` (+3 -1) 📝 `packages/better-auth/src/context/create-context.ts` (+3 -5) 📝 `packages/better-auth/src/plugins/admin/admin.ts` (+9 -0) 📝 `packages/better-auth/src/plugins/anonymous/index.ts` (+9 -0) 📝 `packages/better-auth/src/plugins/api-key/index.ts` (+9 -0) 📝 `packages/better-auth/src/plugins/bearer/index.ts` (+9 -0) 📝 `packages/better-auth/src/plugins/captcha/index.ts` (+10 -0) 📝 `packages/better-auth/src/plugins/custom-session/index.ts` (+9 -0) 📝 `packages/better-auth/src/plugins/device-authorization/index.ts` (+9 -0) 📝 `packages/better-auth/src/plugins/email-otp/index.ts` (+9 -0) 📝 `packages/better-auth/src/plugins/generic-oauth/index.ts` (+9 -0) 📝 `packages/better-auth/src/plugins/haveibeenpwned/index.ts` (+10 -1) 📝 `packages/better-auth/src/plugins/jwt/index.ts` (+9 -0) 📝 `packages/better-auth/src/plugins/last-login-method/index.ts` (+8 -0) 📝 `packages/better-auth/src/plugins/magic-link/index.ts` (+9 -0) 📝 `packages/better-auth/src/plugins/mcp/index.ts` (+9 -0) 📝 `packages/better-auth/src/plugins/multi-session/index.ts` (+9 -0) 📝 `packages/better-auth/src/plugins/oauth-proxy/index.ts` (+9 -0) 📝 `packages/better-auth/src/plugins/oidc-provider/index.ts` (+12 -8) 📝 `packages/better-auth/src/plugins/one-tap/index.ts` (+9 -0) _...and 23 more files_ </details> ### 📄 Description <!-- This is an auto-generated description by cubic. --> ## Summary by cubic Introduces a typed plugin registry (BetterAuthPluginRegistry) and updates getPlugin to return strongly typed plugin instances based on registry entries. Standardizes plugin IDs to kebab-case and hardens JWT/OAuth/OIDC flows when the JWT plugin is absent. - **Refactors** - Added BetterAuthPluginRegistry and BetterAuthPluginRegistryIdentifier in core; getPlugin infers types from each plugin’s creator and returns null when missing. - Registered plugins in the registry across built-ins and standardized IDs (oidc-provider, oauth-provider, have-i-been-pwned); updated OAuth/OIDC to use context.getPlugin("jwt") with null-safe checks and lazy lookup. - **Migration** - Plugin authors should augment BetterAuthPluginRegistry with their plugin ID and creator type so getPlugin returns the correct instance type, and adopt the new kebab-case plugin IDs where renamed. <sup>Written for commit 344ca40e45d8c19ff68f83db0ee8894c5cd234c5. 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:07:08 -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#24002