[PR #5135] [MERGED] refactor: move oauth2 to core #14049

Closed
opened 2026-04-13 09:17:18 -05:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/better-auth/better-auth/pull/5135
Author: @himself65
Created: 10/6/2025
Status: Merged
Merged: 10/7/2025
Merged by: @himself65

Base: canaryHead: himself65/2025/10/06/oauth-code


📝 Commits (7)

📊 Changes

52 files changed (+375 additions, -300 deletions)

View changed files

📝 packages/better-auth/src/api/routes/account.test.ts (+2 -2)
📝 packages/better-auth/src/api/routes/account.ts (+2 -1)
📝 packages/better-auth/src/api/routes/callback.ts (+1 -1)
📝 packages/better-auth/src/oauth2/index.ts (+1 -3)
📝 packages/better-auth/src/oauth2/link-account.test.ts (+2 -2)
📝 packages/better-auth/src/oauth2/utils.ts (+0 -34)
📝 packages/better-auth/src/plugins/admin/admin.test.ts (+2 -2)
📝 packages/better-auth/src/plugins/anonymous/anon.test.ts (+2 -2)
📝 packages/better-auth/src/plugins/generic-oauth/index.ts (+2 -2)
📝 packages/better-auth/src/plugins/last-login-method/last-login-method.test.ts (+2 -2)
📝 packages/better-auth/src/plugins/oauth-proxy/oauth-proxy.test.ts (+2 -2)
📝 packages/better-auth/src/plugins/sso/index.ts (+3 -4)
📝 packages/better-auth/src/social-providers/apple.ts (+1 -1)
📝 packages/better-auth/src/social-providers/atlassian.ts (+5 -2)
📝 packages/better-auth/src/social-providers/cognito.ts (+5 -2)
📝 packages/better-auth/src/social-providers/discord.ts (+4 -1)
📝 packages/better-auth/src/social-providers/dropbox.ts (+1 -1)
📝 packages/better-auth/src/social-providers/facebook.ts (+5 -2)
📝 packages/better-auth/src/social-providers/figma.ts (+5 -2)
📝 packages/better-auth/src/social-providers/github.ts (+1 -1)

...and 32 more files

📄 Description

Summary by cubic

Moves OAuth2 logic to the core package and updates all providers/plugins to use the centralized API. Simplifies imports, removes duplication, and keeps public API stable via re-exports.

  • Refactors

    • Centralized OAuth2 types and interfaces in core/oauth2/oauth-provider.ts.
    • Moved utils to core (getOAuth2Tokens, generateCodeChallenge via Web Crypto).
    • Exposed core OAuth2 entrypoints: createAuthorizationURL, validateAuthorizationCode, refreshAccessToken, client credentials helpers.
    • Updated better-auth/oauth2 to re-export from @better-auth/core/oauth2; removed duplicate utils.
    • Updated generic OAuth plugin and social providers (Google, Atlassian, Salesforce, Figma, Cognito) to import from the new core paths.
  • Migration

    • No changes for common users; imports via better-auth/oauth2 still work.
    • If importing internal utils directly, switch to @better-auth/core/oauth2. Note: encodeOAuthParameter was removed.

🔄 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/5135 **Author:** [@himself65](https://github.com/himself65) **Created:** 10/6/2025 **Status:** ✅ Merged **Merged:** 10/7/2025 **Merged by:** [@himself65](https://github.com/himself65) **Base:** `canary` ← **Head:** `himself65/2025/10/06/oauth-code` --- ### 📝 Commits (7) - [`375e5ad`](https://github.com/better-auth/better-auth/commit/375e5ad2e1f32822e1f6b9067a32488de542a220) refactor: move oauth2 to core - [`dddc793`](https://github.com/better-auth/better-auth/commit/dddc79355c6ef89d4b85d36c59a9b5aaaccece7f) refactor: move oauth2 to core - [`4c84303`](https://github.com/better-auth/better-auth/commit/4c84303d90e93379e6807a933bab258c6f26499b) refactor: test - [`194c6fc`](https://github.com/better-auth/better-auth/commit/194c6fc54b5c559bdaab833b0b7c4f683f70102a) chore: deps - [`5064fef`](https://github.com/better-auth/better-auth/commit/5064fef42760b0ee2524cb0420c65a6e069f3944) chore: deps - [`91c6cc1`](https://github.com/better-auth/better-auth/commit/91c6cc1d6315f1c834b760ba221c3c0f7caaea27) fix: import from subpath - [`5a69877`](https://github.com/better-auth/better-auth/commit/5a6987779fdc82742d7e14b76c5414a06357d438) fix: jose ### 📊 Changes **52 files changed** (+375 additions, -300 deletions) <details> <summary>View changed files</summary> 📝 `packages/better-auth/src/api/routes/account.test.ts` (+2 -2) 📝 `packages/better-auth/src/api/routes/account.ts` (+2 -1) 📝 `packages/better-auth/src/api/routes/callback.ts` (+1 -1) 📝 `packages/better-auth/src/oauth2/index.ts` (+1 -3) 📝 `packages/better-auth/src/oauth2/link-account.test.ts` (+2 -2) 📝 `packages/better-auth/src/oauth2/utils.ts` (+0 -34) 📝 `packages/better-auth/src/plugins/admin/admin.test.ts` (+2 -2) 📝 `packages/better-auth/src/plugins/anonymous/anon.test.ts` (+2 -2) 📝 `packages/better-auth/src/plugins/generic-oauth/index.ts` (+2 -2) 📝 `packages/better-auth/src/plugins/last-login-method/last-login-method.test.ts` (+2 -2) 📝 `packages/better-auth/src/plugins/oauth-proxy/oauth-proxy.test.ts` (+2 -2) 📝 `packages/better-auth/src/plugins/sso/index.ts` (+3 -4) 📝 `packages/better-auth/src/social-providers/apple.ts` (+1 -1) 📝 `packages/better-auth/src/social-providers/atlassian.ts` (+5 -2) 📝 `packages/better-auth/src/social-providers/cognito.ts` (+5 -2) 📝 `packages/better-auth/src/social-providers/discord.ts` (+4 -1) 📝 `packages/better-auth/src/social-providers/dropbox.ts` (+1 -1) 📝 `packages/better-auth/src/social-providers/facebook.ts` (+5 -2) 📝 `packages/better-auth/src/social-providers/figma.ts` (+5 -2) 📝 `packages/better-auth/src/social-providers/github.ts` (+1 -1) _...and 32 more files_ </details> ### 📄 Description <!-- This is an auto-generated description by cubic. --> ## Summary by cubic Moves OAuth2 logic to the core package and updates all providers/plugins to use the centralized API. Simplifies imports, removes duplication, and keeps public API stable via re-exports. - **Refactors** - Centralized OAuth2 types and interfaces in core/oauth2/oauth-provider.ts. - Moved utils to core (getOAuth2Tokens, generateCodeChallenge via Web Crypto). - Exposed core OAuth2 entrypoints: createAuthorizationURL, validateAuthorizationCode, refreshAccessToken, client credentials helpers. - Updated better-auth/oauth2 to re-export from @better-auth/core/oauth2; removed duplicate utils. - Updated generic OAuth plugin and social providers (Google, Atlassian, Salesforce, Figma, Cognito) to import from the new core paths. - **Migration** - No changes for common users; imports via better-auth/oauth2 still work. - If importing internal utils directly, switch to @better-auth/core/oauth2. Note: encodeOAuthParameter was removed. <!-- 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-13 09:17:18 -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#14049