[PR #6502] [MERGED] fix(oidc): compatibility with exact-optional-property #32310

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

📋 Pull Request Information

Original PR: https://github.com/better-auth/better-auth/pull/6502
Author: @ping-maxwell
Created: 12/3/2025
Status: Merged
Merged: 12/4/2025
Merged by: @himself65

Base: canaryHead: fix/oidc-exact-optional-property-type-bug


📝 Commits (5)

📊 Changes

10 files changed (+121 additions, -34 deletions)

View changed files

📝 e2e/smoke/test/fixtures/tsconfig-exact-optional-property-types/package.json (+2 -1)
e2e/smoke/test/fixtures/tsconfig-exact-optional-property-types/src/oidc-provider.ts (+10 -0)
e2e/smoke/test/fixtures/tsconfig-exact-optional-property-types/src/sso.ts (+6 -0)
📝 packages/better-auth/src/db/schema.ts (+10 -6)
📝 packages/better-auth/src/plugins/jwt/sign.ts (+60 -5)
📝 packages/better-auth/src/plugins/jwt/types.ts (+12 -12)
📝 packages/better-auth/src/plugins/oidc-provider/authorize.ts (+4 -2)
📝 packages/better-auth/src/plugins/oidc-provider/index.ts (+13 -7)
📝 packages/better-auth/src/plugins/oidc-provider/types.ts (+1 -1)
📝 pnpm-lock.yaml (+3 -0)

📄 Description

closes https://github.com/better-auth/better-auth/issues/6491


Summary by cubic

Fixes OIDC and JWT handling when TypeScript’s exactOptionalPropertyTypes is enabled, ensuring safe defaults and optional fields don’t cause build or runtime errors. Improves reliability of OIDC flows by guarding undefined values and using explicit defaults.

  • Bug Fixes
    • Made optional config fields explicit with “| undefined” across JWT, OIDC, and DB schema types.
    • Added safe defaults for OIDC values (code/access/refresh token expirations) and guarded scope splitting when undefined.
    • Updated JWT signing to handle optional claims and definePayload correctly, avoiding undefined access.
    • Added an e2e fixture with exactOptionalPropertyTypes (OIDC + SSO) to prevent regressions.

Written for commit 53d2f64f5e. Summary will update automatically 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/6502 **Author:** [@ping-maxwell](https://github.com/ping-maxwell) **Created:** 12/3/2025 **Status:** ✅ Merged **Merged:** 12/4/2025 **Merged by:** [@himself65](https://github.com/himself65) **Base:** `canary` ← **Head:** `fix/oidc-exact-optional-property-type-bug` --- ### 📝 Commits (5) - [`4529494`](https://github.com/better-auth/better-auth/commit/4529494032446827ec155f1079a66a2fcc595de7) fix(oidc): exact-optional-property-type bug - [`c133834`](https://github.com/better-auth/better-auth/commit/c1338341936ea2803f17c2996393bc8da10097b5) chore: lint - [`b5c13f6`](https://github.com/better-auth/better-auth/commit/b5c13f6caf1dd12d23a073346f43f19a5cf3b3cd) wip - [`5f4f882`](https://github.com/better-auth/better-auth/commit/5f4f882277713c677bcc37c4a637d79fee6e038d) chore: lint - [`53d2f64`](https://github.com/better-auth/better-auth/commit/53d2f64f5e38536454ab33e66bbbf41b62bec0f1) fix: type ### 📊 Changes **10 files changed** (+121 additions, -34 deletions) <details> <summary>View changed files</summary> 📝 `e2e/smoke/test/fixtures/tsconfig-exact-optional-property-types/package.json` (+2 -1) ➕ `e2e/smoke/test/fixtures/tsconfig-exact-optional-property-types/src/oidc-provider.ts` (+10 -0) ➕ `e2e/smoke/test/fixtures/tsconfig-exact-optional-property-types/src/sso.ts` (+6 -0) 📝 `packages/better-auth/src/db/schema.ts` (+10 -6) 📝 `packages/better-auth/src/plugins/jwt/sign.ts` (+60 -5) 📝 `packages/better-auth/src/plugins/jwt/types.ts` (+12 -12) 📝 `packages/better-auth/src/plugins/oidc-provider/authorize.ts` (+4 -2) 📝 `packages/better-auth/src/plugins/oidc-provider/index.ts` (+13 -7) 📝 `packages/better-auth/src/plugins/oidc-provider/types.ts` (+1 -1) 📝 `pnpm-lock.yaml` (+3 -0) </details> ### 📄 Description closes https://github.com/better-auth/better-auth/issues/6491 <!-- This is an auto-generated description by cubic. --> --- ## Summary by cubic Fixes OIDC and JWT handling when TypeScript’s exactOptionalPropertyTypes is enabled, ensuring safe defaults and optional fields don’t cause build or runtime errors. Improves reliability of OIDC flows by guarding undefined values and using explicit defaults. - **Bug Fixes** - Made optional config fields explicit with “| undefined” across JWT, OIDC, and DB schema types. - Added safe defaults for OIDC values (code/access/refresh token expirations) and guarded scope splitting when undefined. - Updated JWT signing to handle optional claims and definePayload correctly, avoiding undefined access. - Added an e2e fixture with exactOptionalPropertyTypes (OIDC + SSO) to prevent regressions. <sup>Written for commit 53d2f64f5e38536454ab33e66bbbf41b62bec0f1. Summary will update automatically 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-17 23:09:15 -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#32310