[PR #8761] [MERGED] fix(oauth-provider): normalize auth_time timestamps #25097

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

📋 Pull Request Information

Original PR: https://github.com/better-auth/better-auth/pull/8761
Author: @gustavovalverde
Created: 3/24/2026
Status: Merged
Merged: 3/24/2026
Merged by: @Bekacru

Base: canaryHead: fix/oauth-provider-auth-time-normalization


📝 Commits (2)

  • 68190f1 fix(oauth-provider): normalize auth_time timestamps
  • 9abaa95 fix(oauth-provider): harden auth_time normalization

📊 Changes

3 files changed (+140 additions, -3 deletions)

View changed files

📝 packages/oauth-provider/src/token.ts (+7 -3)
📝 packages/oauth-provider/src/utils/index.ts (+74 -0)
packages/oauth-provider/src/utils/timestamps.test.ts (+59 -0)

📄 Description

Summary

  • normalize adapter-provided session timestamps before deriving OIDC auth_time
  • support createdAt and created_at values returned as dates, numbers, or numeric strings
  • add regression coverage for adapter shapes that omit createdAt and should ignore updatedAt

Summary by cubic

Normalizes OIDC auth_time so tokens use reliable session creation timestamps across adapter shapes, improving compatibility in @better-auth/oauth-provider.

  • Bug Fixes
    • Added normalizeTimestampValue that trims input, accepts Date, epoch ms numbers, numeric strings (e.g., "1774295570569.0"), and ISO strings; rejects NaN and non-finite/invalid dates.
    • Added resolveSessionAuthTime to read createdAt/created_at from direct or nested session objects, supports direct Date values, and never uses updatedAt.
    • Applied normalization in authorization code and refresh token grants; added tests for valid/invalid parsing and regression coverage.

Written for commit 9abaa952f8. 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/8761 **Author:** [@gustavovalverde](https://github.com/gustavovalverde) **Created:** 3/24/2026 **Status:** ✅ Merged **Merged:** 3/24/2026 **Merged by:** [@Bekacru](https://github.com/Bekacru) **Base:** `canary` ← **Head:** `fix/oauth-provider-auth-time-normalization` --- ### 📝 Commits (2) - [`68190f1`](https://github.com/better-auth/better-auth/commit/68190f1e3030966aef9541880f7a542fc325001e) fix(oauth-provider): normalize auth_time timestamps - [`9abaa95`](https://github.com/better-auth/better-auth/commit/9abaa952f8c04900b5d0a13b608026d3165fe0ca) fix(oauth-provider): harden auth_time normalization ### 📊 Changes **3 files changed** (+140 additions, -3 deletions) <details> <summary>View changed files</summary> 📝 `packages/oauth-provider/src/token.ts` (+7 -3) 📝 `packages/oauth-provider/src/utils/index.ts` (+74 -0) ➕ `packages/oauth-provider/src/utils/timestamps.test.ts` (+59 -0) </details> ### 📄 Description ## Summary - normalize adapter-provided session timestamps before deriving OIDC auth_time - support createdAt and created_at values returned as dates, numbers, or numeric strings - add regression coverage for adapter shapes that omit createdAt and should ignore updatedAt <!-- This is an auto-generated description by cubic. --> --- ## Summary by cubic Normalizes OIDC `auth_time` so tokens use reliable session creation timestamps across adapter shapes, improving compatibility in `@better-auth/oauth-provider`. - **Bug Fixes** - Added `normalizeTimestampValue` that trims input, accepts Date, epoch ms numbers, numeric strings (e.g., "1774295570569.0"), and ISO strings; rejects NaN and non-finite/invalid dates. - Added `resolveSessionAuthTime` to read `createdAt`/`created_at` from direct or nested `session` objects, supports direct Date values, and never uses `updatedAt`. - Applied normalization in authorization code and refresh token grants; added tests for valid/invalid parsing and regression coverage. <sup>Written for commit 9abaa952f8c04900b5d0a13b608026d3165fe0ca. 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:43:25 -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#25097