Add silentAuthResponseMode configuration option #1471
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Changes
This PR adds a new
silentAuthResponseModeconfiguration option toAuth0ClientOptionsthat allows developers to choose between'web_message'(postMessage) and'query'(URL polling) response modes for silent authentication flows.What Changed
New Configuration Option (
src/global.ts)silentAuthResponseMode?: 'web_message' | 'query'toAuth0ClientOptions'web_message'for backward compatibilitygetTokenSilentlyandcheckSessionmethodsloginWithPopup,loginWithRedirect,getTokenWithPopup) remain unaffected with their hardcoded response modesRefactored
runIframeFunction (src/utils.ts)runIframeinto three functions:runIframeWithWebMessage: Handles postMessage-based communication (existing behavior)runIframeWithQueryMode: New URL polling implementation that checksiframe.contentWindow.location.hrefevery 100msrunIframe: Main delegator function that routes to the appropriate handlerrunIframe(authorizeUrl, eventOrigin, timeoutInSeconds, responseMode, redirectUri)Updated Silent Auth Flow (
src/Auth0Client.ts)_getTokenFromIFramemethod to:silentAuthResponseModeto_prepareAuthorizeUrlsilentAuthResponseModeandredirect_uritorunIframeresponse_modevalue to Auth0 in the authorization URLWhy This is Important
The
'query'response mode provides a fallback for restrictive environments where postMessage communication may be blocked or limited (e.g., certain enterprise security policies, iframe restrictions). This gives developers more flexibility when implementing silent authentication.Usage
References
Testing
All existing tests have been updated to account for the new 5-parameter runIframe signature.
Checklist