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

Closed
opened 2026-04-13 10:31:25 -05:00 by GiteaMirror · 0 comments
Owner

Original Pull Request: https://github.com/better-auth/better-auth/pull/8761

State: closed
Merged: Yes


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.

**Original Pull Request:** https://github.com/better-auth/better-auth/pull/8761 **State:** closed **Merged:** Yes --- ## 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. -->
GiteaMirror added the pull-request label 2026-04-13 10:31: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#16443