Skip to content

feat: enforce IPSIE session_expiry with a SESSION_EXPIRED error#1597

Open
subhankarmaiti wants to merge 7 commits into
masterfrom
feat/ipsie-session-expiry
Open

feat: enforce IPSIE session_expiry with a SESSION_EXPIRED error#1597
subhankarmaiti wants to merge 7 commits into
masterfrom
feat/ipsie-session-expiry

Conversation

@subhankarmaiti

@subhankarmaiti subhankarmaiti commented Jul 16, 2026

Copy link
Copy Markdown
Contributor

Adds support for the IPSIE SL1 session_expiry claim. When an enterprise connection sets an upstream session ceiling, Auth0 stamps a session_expiry timestamp into the ID token, and the underlying platform SDKs enforce it as a hard ceiling on every credential retrieval — past the ceiling the stored credentials are cleared and refresh is skipped, so the user must re-authenticate.

it surfaces this outcome as a single, platform-agnostic CredentialsManagerError with type === 'SESSION_EXPIRED' across iOS, Android, and Web.

Credentials also expose an optional sessionExpiresAt (Unix seconds), surfaced for display only — enforcement stays in the platform SDKs. On iOS and Web it is decoded from the current ID token's session_expiry claim; on Android it reflects the ceiling pinned at initial login (the value the credentials manager actually enforces). It is undefined when the connection does not emit the claim.

Summary by CodeRabbit

  • New Features
    • Added support for upstream session expiry ceilings via the session_expiry claim.
    • Exposed optional sessionExpiresAt on returned credentials.
    • Introduced a normalized SESSION_EXPIRED error type that indicates re-authentication is required.
  • Bug Fixes
    • Improved consistency across web and native when a session is considered expired (including silent token absence on web).
  • Documentation
    • Updated README error handling guidance and added example documentation for “IPSIE Session Expiry.”
  • Tests
    • Added coverage for decoding session_expiry and propagating SESSION_EXPIRED.
  • Chores
    • Updated dependency versions.

@coderabbitai

coderabbitai Bot commented Jul 16, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 5cd513dd-216b-414c-a313-0b969981efcf

📥 Commits

Reviewing files that changed from the base of the PR and between 6bd99e5 and 30e2cb1.

📒 Files selected for processing (3)
  • README.md
  • ios/NativeBridge.swift
  • src/core/models/__tests__/ErrorCodes.spec.ts
🚧 Files skipped from review as they are similar to previous changes (3)
  • src/core/models/tests/ErrorCodes.spec.ts
  • README.md
  • ios/NativeBridge.swift

📝 Walkthrough

Walkthrough

Changes

The SDK adds optional sessionExpiresAt credential metadata, validates the IPSIE session_expiry claim on web, normalizes session-expired errors across platforms, serializes metadata through native bridges, updates dependencies, tests, and documents the behavior.

IPSIE Session Expiry

Layer / File(s) Summary
Credential and error contracts
src/core/models/Credentials.ts, src/types/common.ts, src/core/models/CredentialsManagerError.ts, src/core/models/__tests__/*
Credentials include optional sessionExpiresAt, while session-expired source codes normalize to SESSION_EXPIRED with corresponding model tests.
Web session expiry handling
src/platforms/web/adapters/*, src/platforms/web/adapters/__tests__/*, package.json
Web credential retrieval validates session_expiry, exposes sessionExpiresAt, classifies missing silent tokens as SESSION_EXPIRED, and tests valid, absent, and invalid claims.
Native metadata and error bridging
android/src/main/java/com/auth0/react/*, ios/NativeBridge.swift, src/platforms/native/adapters/__tests__/*, A0Auth0.podspec
Android and iOS serialize session expiry metadata and map native session-expired errors; native pass-through and error behavior are tested, with the Auth0 pod updated.
Session expiry documentation
README.md, EXAMPLES.md
Documentation describes the session_expiry ceiling, SESSION_EXPIRED, sessionExpiresAt, and re-authentication handling.

Estimated code review effort: 3 (Moderate) | ~25 minutes

Sequence Diagram(s)

sequenceDiagram
  participant Auth0SPAJS
  participant WebCredentialsManager
  participant CredentialsManagerError
  participant Credentials
  Auth0SPAJS->>WebCredentialsManager: getTokenSilently()
  WebCredentialsManager->>CredentialsManagerError: classify undefined token as session_expired
  WebCredentialsManager->>Credentials: store validated session_expiry as sessionExpiresAt
  WebCredentialsManager-->>Auth0SPAJS: return credentials or throw SESSION_EXPIRED
Loading

Suggested reviewers: pmathew92

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly summarizes the main change: enforcing IPSIE session_expiry and surfacing SESSION_EXPIRED errors.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/ipsie-session-expiry

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@subhankarmaiti
subhankarmaiti marked this pull request as ready for review July 23, 2026 13:01
@subhankarmaiti
subhankarmaiti requested a review from a team as a code owner July 23, 2026 13:01

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 6

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
src/platforms/web/adapters/WebCredentialsManager.ts (1)

75-85: 📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win

Replace changed any catch bindings with unknown.

Lines 75, 116, and 133 catch errors as any even though this file is under strict TypeScript. Cast/narrow to an error-like record before reading error, error_description, and message.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/platforms/web/adapters/WebCredentialsManager.ts` around lines 75 - 85,
Update the catch bindings in WebCredentialsManager to use unknown instead of
any, including the handlers around the shown CredentialsManagerError conversion
and the other catches at the referenced locations. Narrow each caught value to
an error-like record before reading error, error_description, or message, while
preserving the existing CredentialsManagerError rethrow and AuthError
construction behavior.

Source: Coding guidelines

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@EXAMPLES.md`:
- Around line 688-691: Update the session_expiry NOTE in EXAMPLES.md to state
that the ceiling is pinned at initial login only on Android. Preserve the
documented current-ID-token behavior for iOS and Web, and keep the no-claim
behavior unchanged.

In `@ios/NativeBridge.swift`:
- Around line 668-679: Update NativeBridge.saveCredentials() and its Credentials
reconstruction to preserve the optional NativeBridge.sessionExpiresAtKey value
exposed by Credentials.asDictionary(). Parse and pass the value through during
explicit saveCredentials() round trips, or explicitly reject credentials
containing it; do not silently discard the session expiration ceiling.

In `@README.md`:
- Around line 757-759: Add a SESSION_EXPIRED branch to the
CredentialsManagerErrorCodes error-handling switch in README.md, following the
clear-and-restart login flow documented in EXAMPLES.md. Keep existing cases and
generic fallback behavior unchanged.

In `@src/core/models/Credentials.ts`:
- Line 17: Add a JSDoc comment directly above the public
Credentials.sessionExpiresAt field, documenting it as the session-ceiling Unix
timestamp and stating that it is undefined when the ID token lacks the IPSIE
session_expiry claim.

In `@src/platforms/web/adapters/WebCredentialsManager.ts`:
- Around line 34-47: Update getApiCredentials to handle an undefined response
from getTokenSilently the same way as the existing token flow: throw
CredentialsManagerError wrapping AuthError with the session_expired code and
re-authentication message before accessing the response. Preserve the existing
handling for valid token responses.

In `@src/types/common.ts`:
- Around line 44-46: Update the JSDoc remarks for the affected property in
common.ts by separating the cross-platform availability/derivation description
from the Android-specific credentials-manager behavior, and label the latter
explicitly as “Android only” using the required JSDoc notation.

---

Outside diff comments:
In `@src/platforms/web/adapters/WebCredentialsManager.ts`:
- Around line 75-85: Update the catch bindings in WebCredentialsManager to use
unknown instead of any, including the handlers around the shown
CredentialsManagerError conversion and the other catches at the referenced
locations. Narrow each caught value to an error-like record before reading
error, error_description, or message, while preserving the existing
CredentialsManagerError rethrow and AuthError construction behavior.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 90aabf45-884d-49e8-b7ab-ed5bf8836182

📥 Commits

Reviewing files that changed from the base of the PR and between 22065da and 6d2bb03.

⛔ Files ignored due to path filters (2)
  • example/ios/Podfile.lock is excluded by !**/*.lock
  • yarn.lock is excluded by !**/yarn.lock, !**/*.lock
📒 Files selected for processing (17)
  • A0Auth0.podspec
  • EXAMPLES.md
  • README.md
  • android/src/main/java/com/auth0/react/A0Auth0Module.kt
  • android/src/main/java/com/auth0/react/CredentialsParser.kt
  • ios/NativeBridge.swift
  • package.json
  • src/core/models/Credentials.ts
  • src/core/models/CredentialsManagerError.ts
  • src/core/models/__tests__/Credentials.spec.ts
  • src/core/models/__tests__/ErrorCodes.spec.ts
  • src/platforms/native/adapters/__tests__/NativeCredentialsManager.errors.spec.ts
  • src/platforms/native/adapters/__tests__/NativeCredentialsManager.spec.ts
  • src/platforms/web/adapters/WebCredentialsManager.ts
  • src/platforms/web/adapters/__tests__/WebCredentialsManager.errors.spec.ts
  • src/platforms/web/adapters/__tests__/WebCredentialsManager.spec.ts
  • src/types/common.ts

Comment thread EXAMPLES.md Outdated
Comment thread ios/NativeBridge.swift
Comment thread README.md
Comment thread src/core/models/Credentials.ts
Comment thread src/platforms/web/adapters/WebCredentialsManager.ts
Comment thread src/types/common.ts Outdated
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant