feat: add support for Online Access (Online Refresh Tokens)#1133
Conversation
|
Note Reviews pausedIt looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
📝 WalkthroughWalkthroughAdds ChangesOnline Refresh Token (ORT) Revocation
Estimated code review effort: 3 (Moderate) | ~25 minutes Sequence Diagram(s)sequenceDiagram
participant App
participant Auth0Provider
participant Auth0Client
App->>Auth0Provider: revokeRefreshToken(options)
Auth0Provider->>Auth0Client: revokeRefreshToken(opts)
Auth0Client-->>Auth0Provider: revocation complete
Auth0Provider->>Auth0Client: getUser()
Auth0Client-->>Auth0Provider: user state
Auth0Provider->>Auth0Provider: dispatch GET_ACCESS_TOKEN_COMPLETE
Auth0Provider-->>App: updated auth state
Suggested reviewers: 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
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. Comment |
52cf1aa to
01181d8
Compare
3368a78 to
1448d37
Compare
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 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 829-840: The current example shows a try/catch without actually
exercising the failing path, so replace it with a real validation or
error-boundary pattern tied to Auth0Provider/Auth0Client. Use the Auth0Provider
render path or an explicit pre-render configuration check that invokes the same
options that trigger InvalidConfigurationError, then catch and handle that error
with the suggested fix. Make sure the example demonstrates a concrete,
executable path that can actually raise and catch InvalidConfigurationError
rather than a placeholder block.
🪄 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: a62d0e85-f108-4cd5-b93b-f27378bdf821
📒 Files selected for processing (7)
EXAMPLES.md__mocks__/@auth0/auth0-spa-js.tsx__tests__/auth-provider.test.tsxpackage.jsonsrc/auth0-context.tsxsrc/auth0-provider.tsxsrc/index.tsx
90255c8 to
6704e51
Compare
|
Can you also sign all the commits and push them back up. Some of them are missing signatures. |
Adds revokeRefreshToken() to the useAuth0 hook, wrapping the underlying Auth0Client method and keeping isAuthenticated/user in sync after the call. This is the one gap in Online Access support — refreshTokenMode, useDpop, and useMrrt already pass through Auth0Provider's existing Auth0ClientOptions config surface. Also exports RefreshTokenMode, InvalidConfigurationError, MissingScopesError, and RevokeRefreshTokenOptions from the package root, and documents the feature in EXAMPLES.md.
Online Access (Online Refresh Tokens) is gated behind Auth0 account team enablement. Adds the same Early Access notice used for the MFA section.
RefreshTokenMode is not exported until 2.23.0 — the previous ^2.22.0 range let installs resolve to an older minor where RefreshTokenMode is undefined, breaking refreshTokenMode: RefreshTokenMode.Online at runtime.
- Replace non-functional try/catch example in EXAMPLES.md with a
working React error boundary, since Auth0Provider constructs
Auth0Client during render (inside useState), so a call-site
try/catch around it can never catch InvalidConfigurationError
- Wrap revokeRefreshToken's post-revocation dispatch in try/finally,
matching the established pattern used by every other async method
in the provider (getAccessTokenSilently, getAccessTokenWithPopup,
etc.)
- Assert auth state is left untouched in the revokeRefreshToken
error-rethrow test, not just that the error propagates
Addresses review feedback from cschetan77 and coderabbitai on
#1133.
6f8270f to
d59ada5
Compare
**Added** - feat: add support for Online Access (Online Refresh Tokens) [\#1133](#1133) ([NandanPrabhu](https://github.com/NandanPrabhu))
Summary
Adds full support for Online Access (Online Refresh Tokens / ORTs) in
auth0-react, mirroring the underlyingauth0-spa-jsfeature.Most of the configuration surface (
refreshTokenMode,useDpop,useMrrt,useRefreshTokens) already passed through automatically viaAuth0Provider's existingAuth0ClientOptionsspread — no changes needed there.Changes
revokeRefreshTokeninAuth0Providerre-syncsuser/isAuthenticatedviaclient.getUser()— this correctly reflects both online-mode session clearing and offline-mode no-op behavior, and still re-syncs (to the unchanged state) if revocation failsSYNC_USERreducer action for this state re-sync, instead of reusingGET_ACCESS_TOKEN_COMPLETE, so the action name reflects what's actually happeningRefreshTokenMode,InvalidConfigurationError,MissingScopesErrorfrom the package rootAuth0ClientJest mockEXAMPLES.md, including a React error-boundary example for catchingInvalidConfigurationError—Auth0ProviderconstructsAuth0ClientinsideuseState()during render, so a call-sitetry/catchcan't catch it, but an error boundary canUsage
Testing
npx jest --no-coverage— 143 tests)npx tsc --noEmit— zero TypeScript errorsnpm run lint— zero errors/warningsauth0-spa-jsand smoke-testedRefreshTokenModeresolves correctly