Skip to content

fix(oidc): compatibility with exact-optional-property#6502

Merged
himself65 merged 5 commits intobetter-auth:canaryfrom
ping-maxwell:fix/oidc-exact-optional-property-type-bug
Dec 4, 2025
Merged

fix(oidc): compatibility with exact-optional-property#6502
himself65 merged 5 commits intobetter-auth:canaryfrom
ping-maxwell:fix/oidc-exact-optional-property-type-bug

Conversation

@ping-maxwell
Copy link
Copy Markdown
Member

@ping-maxwell ping-maxwell commented Dec 3, 2025

closes #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 53d2f64. Summary will update automatically on new commits.

@vercel
Copy link
Copy Markdown

vercel bot commented Dec 3, 2025

@ping-maxwell is attempting to deploy a commit to the better-auth Team on Vercel.

A member of the Team first needs to authorize it.

@pkg-pr-new
Copy link
Copy Markdown

pkg-pr-new bot commented Dec 3, 2025

Open in StackBlitz

better-auth

npm i https://pkg.pr.new/better-auth/better-auth@6502

@better-auth/cli

npm i https://pkg.pr.new/better-auth/better-auth/@better-auth/cli@6502

@better-auth/core

npm i https://pkg.pr.new/better-auth/better-auth/@better-auth/core@6502

@better-auth/expo

npm i https://pkg.pr.new/better-auth/better-auth/@better-auth/expo@6502

@better-auth/passkey

npm i https://pkg.pr.new/better-auth/better-auth/@better-auth/passkey@6502

@better-auth/scim

npm i https://pkg.pr.new/better-auth/better-auth/@better-auth/scim@6502

@better-auth/sso

npm i https://pkg.pr.new/better-auth/better-auth/@better-auth/sso@6502

@better-auth/stripe

npm i https://pkg.pr.new/better-auth/better-auth/@better-auth/stripe@6502

@better-auth/telemetry

npm i https://pkg.pr.new/better-auth/better-auth/@better-auth/telemetry@6502

commit: 53d2f64

@himself65 himself65 changed the title fix(oidc): exact-optional-property-type bug fix(oidc): compatibility with exact-optional-property Dec 3, 2025
@ping-maxwell
Copy link
Copy Markdown
Member Author

@himself65 tests still failing for some reason, dont merge yet

Copy link
Copy Markdown
Contributor

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No issues found across 10 files

@himself65
Copy link
Copy Markdown
Contributor

type is broken now

@himself65
Copy link
Copy Markdown
Contributor

see smoke test CI

Copy link
Copy Markdown
Contributor

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

2 issues found across 10 files

Prompt for AI agents (all 2 issues)

Check if these issues are valid — if so, understand the root cause of each and fix them.


<file name="packages/better-auth/src/plugins/jwt/types.ts">

<violation number="1" location="packages/better-auth/src/plugins/jwt/types.ts:97">
P2: The `| undefined` is applied to the function&#39;s return type, not the property itself. This changes the function&#39;s semantic to allow returning `undefined`, which may not be intended. For `exactOptionalPropertyTypes` compatibility, wrap the entire function type in parentheses like the `sign` property does.</violation>

<violation number="2" location="packages/better-auth/src/plugins/jwt/types.ts:106">
P2: The `| undefined` is applied to the function&#39;s return type, not the property itself. This changes the function&#39;s semantic to allow returning `undefined`, which may not be intended. For consistency with `sign`, wrap the entire function type in parentheses.</violation>
</file>

Reply to cubic to teach it or ask questions. Re-run a review with @cubic-dev-ai review this PR

@ping-maxwell
Copy link
Copy Markdown
Member Author

see smoke test CI

Yeah I added oidc to the smoke CI. im working on it.

@ping-maxwell
Copy link
Copy Markdown
Member Author

@himself65 it's fixed now

@himself65 himself65 merged commit 2fc58d6 into better-auth:canary Dec 4, 2025
9 of 12 checks passed
@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Dec 4, 2025

✅ Automatically cherry-picked to main branch!

Paola3stefania pushed a commit to Paola3stefania/better-auth that referenced this pull request Dec 5, 2025
@better-auth better-auth locked as resolved and limited conversation to collaborators Mar 31, 2026
@bytaesu bytaesu added the locked Locked conversations after being closed for 7 days label Mar 31, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

locked Locked conversations after being closed for 7 days

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Support "exactOptionalPropertyTypes": true in tsconfig.json

3 participants