feat: add support for Demonstration of Proof-of-Possession(DPoP) #1345
+695
−36
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 implements DPoP (RFC 9449) support across all platforms (iOS, Android, and Web) for react-native-auth0, enabling sender-constrained OAuth 2.0 tokens for enhanced security.
SDK Version Updates
New Public API Methods
1.
Auth0.getDPoPHeaders(params: DPoPHeadersParams): Promise<Record<string, string>>
url
,method
,accessToken
,tokenType
Authorization
andDPoP
headers2.
useAuth0().getDPoPHeaders(params: DPoPHeadersParams)
New Configuration Options
Auth0Options.useDPoP?: boolean
(default:true
)New Error Types
DPoPError
class extendingAuthError
with normalized error codes:DPOP_GENERATION_FAILED
- General DPoP generation failureDPOP_PROOF_FAILED
- DPoP proof generation failureDPOP_KEY_GENERATION_FAILED
- Key pair generation failureDPOP_KEY_STORAGE_FAILED
- Key storage failureDPOP_KEY_RETRIEVAL_FAILED
- Key retrieval failureDPOP_NONCE_MISMATCH
- Nonce validation failureDPOP_INVALID_TOKEN_TYPE
- Invalid token typeDPOP_MISSING_PARAMETER
- Required parameter missingDPOP_CLEAR_KEY_FAILED
- Key cleanup failureNative Bridge Methods Added
iOS (NativeBridge.swift):
getDPoPHeaders(url:method:accessToken:tokenType:resolve:reject:)
clearDPoPKey(resolve:reject:)
DPoPError.reactNativeErrorCode()
- Maps DPoP errors to RN error codesAndroid (A0Auth0Module.kt):
getDPoPHeaders(url:method:accessToken:tokenType:promise)
clearDPoPKey(promise)
handleDPoPError(error:promise)
- Private error handler with exact exception matchingWeb (WebAuth0Client.ts):
getDPoPHeaders(params)
- Uses auth0-spa-js internal DPoP utilitiesModified Methods
INativeBridge.initialize()
useDPoP?: boolean
parametertrue
ICredentialsManager.clearCredentials()
Architecture Overview
Usage Example
React Hook Usage
References
Testing
Unit Tests
Platform Testing
iOS:
Android:
Web:
Integration Tests
Not Tested
DPoP with Refresh Token Exchange: Per Auth0.swift documentation, DPoP is not applied to existing refresh token exchanges. This is expected behavior and a limitation of the current DPoP implementation in the native SDKs.
Checklist
DPoPError
classBreaking Changes
None. This is a backward-compatible feature addition.
useDPoP: true
), but existing applications will continue to workMigration Notes
For applications that want to adopt DPoP:
useDPoP: true
credentials.tokenType === 'DPoP'
before callinggetDPoPHeaders()
getDPoPHeaders()
for custom API requests when using DPoP tokensSecurity Considerations
✅ Key Storage: All platforms use secure storage
✅ Key Cleanup: DPoP keys are automatically cleared on logout
✅ Error Security: Error messages do not leak sensitive cryptographic details
✅ Token Binding: DPoP cryptographically binds tokens to device-specific keys, preventing token theft attacks