Skip to content

feat: expose clearDPoPKey() on class and hook APIs#1592

Open
subhankarmaiti wants to merge 4 commits into
masterfrom
feat/expose-clear-dpop-key
Open

feat: expose clearDPoPKey() on class and hook APIs#1592
subhankarmaiti wants to merge 4 commits into
masterfrom
feat/expose-clear-dpop-key

Conversation

@subhankarmaiti

@subhankarmaiti subhankarmaiti commented Jul 13, 2026

Copy link
Copy Markdown
Contributor

Exposes clearDPoPKey() on the Auth0 class and useAuth0 hook (iOS/Android; throws UnsupportedOperation on web). Lets apps clear a corrupted DPoP key pair and retry login instead of disabling DPoP. Adds FAQ 19.

Note: invalidates any active DPoP-bound session — call before a fresh login or on logout.

Summary by CodeRabbit

  • New Features
    • Added clearDPoPKey() to recover from corrupted DPoP state on iOS and Android.
    • Available through the Auth0 client and useAuth0() hook.
    • Clears stored DPoP credentials and cached state when explicitly invoked.
  • Documentation
    • Added FAQ guidance for diagnosing and recovering from DPoP authorization failures.
    • Documented that clearing DPoP state invalidates the current DPoP-bound session and may require signing in again.
    • Documented that this recovery action is unsupported on web.

@subhankarmaiti subhankarmaiti requested a review from a team as a code owner July 13, 2026 18:37
@coderabbitai

coderabbitai Bot commented Jul 13, 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: 1703899f-404b-482d-a470-3c6f8fdb1919

📥 Commits

Reviewing files that changed from the base of the PR and between f5746e5 and 89f3d48.

📒 Files selected for processing (6)
  • src/Auth0.ts
  • src/core/interfaces/IAuth0Client.ts
  • src/hooks/Auth0Context.ts
  • src/hooks/Auth0Provider.tsx
  • src/platforms/native/adapters/NativeAuth0Client.ts
  • src/platforms/web/adapters/WebAuth0Client.ts
🚧 Files skipped from review as they are similar to previous changes (6)
  • src/platforms/native/adapters/NativeAuth0Client.ts
  • src/core/interfaces/IAuth0Client.ts
  • src/platforms/web/adapters/WebAuth0Client.ts
  • src/Auth0.ts
  • src/hooks/Auth0Provider.tsx
  • src/hooks/Auth0Context.ts

📝 Walkthrough

Walkthrough

Adds clearDPoPKey() across the Auth0 class, React context, client interface, and platform clients. Native delegates to the bridge with error conversion, web rejects the operation, and the FAQ documents recovery from corrupted DPoP state.

Changes

DPoP recovery

Layer / File(s) Summary
Public DPoP recovery contracts
src/core/interfaces/IAuth0Client.ts, src/hooks/Auth0Context.ts, src/Auth0.ts
Adds clearDPoPKey() to the client interface, context contract, initial context stub, and class-based API.
Platform clearing implementations
src/platforms/native/adapters/NativeAuth0Client.ts, src/hooks/Auth0Provider.tsx, src/platforms/web/adapters/WebAuth0Client.ts
Wires context calls to the client, delegates native clearing to the bridge with DPoPError conversion, and rejects independent web clearing.
Corrupted DPoP state recovery guidance
FAQ.md
Adds FAQ #19 with hook and class API examples, session invalidation warnings, and platform behavior.

Estimated code review effort: 2 (Simple) | ~10 minutes

Sequence Diagram(s)

sequenceDiagram
  participant Application
  participant Auth0Provider
  participant NativeAuth0Client
  participant NativeBridge
  Application->>Auth0Provider: clearDPoPKey()
  Auth0Provider->>NativeAuth0Client: client.clearDPoPKey()
  NativeAuth0Client->>NativeBridge: clearDPoPKey()
  NativeBridge-->>NativeAuth0Client: completion or AuthError
  NativeAuth0Client-->>Auth0Provider: completion or DPoPError
Loading
🚥 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 accurately summarizes the main change: exposing clearDPoPKey() through the class and hook APIs.
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/expose-clear-dpop-key

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 ESLint

If the error stems from missing dependencies, add them to the package.json file. For unrecoverable errors (e.g., due to private dependencies), disable the tool in the CodeRabbit configuration.

ESLint install failed. For unrecoverable errors, disable the tool in CodeRabbit configuration.


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.

@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: 5

🤖 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 `@FAQ.md`:
- Around line 1091-1093: Remove the “Last resort: disable DPoP” section from the
FAQ, including the recommendation to set useDPoP: false and its FAQ `#16`
reference. Replace it with guidance to investigate or escalate corrupted DPoP
state after clearDPoPKey() fails, while preserving the requirement that DPoP
must never be disabled.
- Around line 1059-1067: Update the handleLogin authorization recovery so
clearDPoPKey and the retry occur only after confirming the caught error is
DPoP-specific; leave cancellation, credential, and network failures unchanged.
Apply the same guard to the second authorization example around its catch/retry
flow, or make key clearing an explicit user-initiated recovery action.

In `@src/core/interfaces/IAuth0Client.ts`:
- Around line 85-96: The public clearDPoPKey documentation is incomplete across
the interface, hook, top-level client, and platform adapters. In
src/core/interfaces/IAuth0Client.ts lines 85-96, src/hooks/Auth0Context.ts lines
424-435, and src/Auth0.ts lines 138-156, document iOS/Android support and that
web throws UnsupportedOperation using platform-name-only notation; add
corresponding JSDoc to NativeAuth0Client at
src/platforms/native/adapters/NativeAuth0Client.ts line 183 identifying the
native implementation, and to WebAuth0Client at
src/platforms/web/adapters/WebAuth0Client.ts line 228 identifying the
unsupported web behavior.

In `@src/platforms/native/adapters/NativeAuth0Client.ts`:
- Around line 184-186: Update the clear-DPoP-key flow after await this.ready to
call clearDPoPKey through this.guardedBridge instead of this.bridge. Preserve
the existing async handling and return behavior while ensuring the call uses the
guarded bridge’s native configuration synchronization.

In `@src/platforms/web/adapters/WebAuth0Client.ts`:
- Around line 232-235: Update the web adapter’s clearDPoPKey failure to throw a
DPoPError instead of the raw AuthError, preserving the existing
unsupported-operation message and ensuring callers receive the same
DPoPError/type shape as NativeAuth0Client.clearDPoPKey().
🪄 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: 5d5c4b6e-c3e9-4954-a1a3-e775eb35d580

📥 Commits

Reviewing files that changed from the base of the PR and between cc36f89 and acd76ff.

📒 Files selected for processing (7)
  • FAQ.md
  • src/Auth0.ts
  • src/core/interfaces/IAuth0Client.ts
  • src/hooks/Auth0Context.ts
  • src/hooks/Auth0Provider.tsx
  • src/platforms/native/adapters/NativeAuth0Client.ts
  • src/platforms/web/adapters/WebAuth0Client.ts

Comment thread FAQ.md Outdated
Comment thread FAQ.md Outdated
Comment thread src/core/interfaces/IAuth0Client.ts
Comment thread src/platforms/native/adapters/NativeAuth0Client.ts Outdated
Comment thread src/platforms/web/adapters/WebAuth0Client.ts Outdated

@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.

Caution

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

⚠️ Outside diff range comments (1)
src/Auth0.ts (1)

147-152: 🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

Clarify the documented web error type and platform notation.

Line 148 says the web implementation throws an UnsupportedOperation error, but src/platforms/web/adapters/WebAuth0Client.ts:239-246 actually throws a DPoPError wrapping an AuthError with that code. Align the wording with Line 152 and use the required platform notation, such as **iOS only**, **Android only**, and Web only`.

As per coding guidelines, platform-specific behavior must use platform name only notation.

🤖 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/Auth0.ts` around lines 147 - 152, The documentation around the DPoP
key-clearing API in Auth0.ts should consistently describe the web failure as a
DPoPError wrapping an AuthError with code UnsupportedOperation. Update the
platform-specific wording to use the required bold notation, including **iOS
only**, **Android only**, and **Web only**, while preserving the existing return
and throws documentation.

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.

Outside diff comments:
In `@src/Auth0.ts`:
- Around line 147-152: The documentation around the DPoP key-clearing API in
Auth0.ts should consistently describe the web failure as a DPoPError wrapping an
AuthError with code UnsupportedOperation. Update the platform-specific wording
to use the required bold notation, including **iOS only**, **Android only**, and
**Web only**, while preserving the existing return and throws documentation.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 9a9f85b0-3c3d-4d3a-86f6-86219ddaf801

📥 Commits

Reviewing files that changed from the base of the PR and between ff18408 and f5746e5.

📒 Files selected for processing (5)
  • src/Auth0.ts
  • src/core/interfaces/IAuth0Client.ts
  • src/hooks/Auth0Context.ts
  • src/platforms/native/adapters/NativeAuth0Client.ts
  • src/platforms/web/adapters/WebAuth0Client.ts
🚧 Files skipped from review as they are similar to previous changes (4)
  • src/core/interfaces/IAuth0Client.ts
  • src/platforms/native/adapters/NativeAuth0Client.ts
  • src/platforms/web/adapters/WebAuth0Client.ts
  • src/hooks/Auth0Context.ts

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