feat: add DPoP support with fetcher API #732
Merged
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.
Description
Adds DPoP (Demonstrating Proof-of-Possession) support by exposing new authentication methods from
@auth0/auth0-spa-jsv2.10.0. DPoP cryptographically binds access tokens to clients, preventing token theft and replay attacks.What is DPoP?
DPoP prevents security vulnerabilities by:
Changes
1. Dependency & Compatibility Updates
⬆️ Upgrade
@auth0/auth0-spa-jsto v2.10.0🔧 Update
handleRedirectCallbackreturn typeConnectAccountRedirectResultto support account linking flows🧪 Add
cross-fetchpolyfilltest-setup.ts- only affects test environment, not production2. New DPoP Methods
getDpopNonce(id?)setDpopNonce(nonce, id?)generateDpopProof(params)createFetcher(config?)3. New Exports
Class:
UseDpopNonceError- DPoP nonce error classTypes:
FetcherConfig- Fetcher configuration optionsFetcher- Fetcher instance typeCustomFetchMinimalOutput- Custom response type constraint4. Documentation & Testing
Usage
Basic Setup
Recommended: Using
createFetcher()⭐The simplest way to make authenticated API calls with DPoP:
What
createFetcher()does automatically:getAccessTokenSilently()Authorizationheaders (DPoP <token>orBearer <token>)DPoPheaderMultiple APIs
Advanced: Manual DPoP Management
For scenarios requiring full control:
Error Handling
Why Use
createFetcher()?createFetcher()Breaking Changes
None - Fully backward compatible:
handleRedirectCallbackreturn type is a union (includes old type)useDpop: trueMigration Guide
Enable DPoP
Update API Calls (Recommended)
Testing
getDpopNonce()with/without IDsetDpopNonce()with/without IDgenerateDpopProof()createFetcher()with/without configRelated
@auth0/auth0-spa-js>= 2.10.0 (included)Checklist