Skip to content

feat: add My Account API support on the web platform - #1608

Merged
subhankarmaiti merged 5 commits into
masterfrom
feat/web-my-account-api-support
Jul 27, 2026
Merged

feat: add My Account API support on the web platform#1608
subhankarmaiti merged 5 commits into
masterfrom
feat/web-my-account-api-support

Conversation

@subhankarmaiti

@subhankarmaiti subhankarmaiti commented Jul 27, 2026

Copy link
Copy Markdown
Contributor

The My Account API is fully available on iOS and Android but was previously unsupported on the web platform, where every method threw UnsupportedOperation. This PR implements web support so that auth0.myAccount works consistently across all platforms, backed by @auth0/auth0-spa-js.

Web consumers can now:

  • List authentication factors and authentication methods
  • Get, update, and delete an authentication method by id
  • Enroll phone, email, TOTP, push notification, and recovery-code factors
  • Enroll passkeys
  • Confirm/verify enrollments

Summary by CodeRabbit

  • New Features

    • Added full My Account API support for web applications.
    • Added factor management for phone, email, TOTP, push notifications, recovery codes, and passkeys.
    • Added browser-based WebAuthn passkey enrollment.
    • Updated the web demo with My Account API workflows and authentication-method management.
  • Bug Fixes

    • Improved passkey and My Account error reporting.
  • Documentation

    • Documented web platform support, passkey enrollment, and DPoP token requirements.

@subhankarmaiti
subhankarmaiti requested a review from a team as a code owner July 27, 2026 05:31
@coderabbitai

coderabbitai Bot commented Jul 27, 2026

Copy link
Copy Markdown

Review Change Stack

Note

Reviews paused

It 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 reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review

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: 2e0b3965-f028-4863-b3f0-16a4ff406edf

📥 Commits

Reviewing files that changed from the base of the PR and between 872a6ca and 91dda27.

📒 Files selected for processing (4)
  • EXAMPLES.md
  • example/src/App.web.tsx
  • src/platforms/web/adapters/WebAuth0Client.ts
  • src/platforms/web/adapters/__tests__/WebAuth0Client.spec.ts
🚧 Files skipped from review as they are similar to previous changes (4)
  • src/platforms/web/adapters/tests/WebAuth0Client.spec.ts
  • EXAMPLES.md
  • src/platforms/web/adapters/WebAuth0Client.ts
  • example/src/App.web.tsx

📝 Walkthrough

Walkthrough

The web platform now implements My Account API operations through Auth0 SPA JS, including authentication-method management, factor enrollment, passkey WebAuthn enrollment, DPoP handling, MRRT-based demo flows, tests, error handling, and updated documentation.

Changes

Web My Account API

Layer / File(s) Summary
Adapter wiring and SPA dependency
package.json, src/platforms/web/adapters/WebMyAccountClient.ts, src/platforms/web/adapters/WebAuth0Client.ts, src/platforms/web/adapters/__tests__/*
The web adapter uses the SPA client, domain, and DPoP configuration, with tests verifying fetcher setup and adapter construction.
My Account operations and error mapping
src/platforms/web/adapters/WebMyAccountClient.ts, src/platforms/web/adapters/__tests__/WebMyAccountClient.spec.ts, src/core/models/*
My Account requests, enrollment flows, authentication-method operations, factor retrieval, response mapping, and error translation are implemented and tested.
Browser passkey ceremony
example/src/passkey/webPasskey.ts
WebAuthn challenge fields and attestation responses are converted between base64url and browser buffer formats.
Demo My Account flows and documentation
example/src/App.web.tsx, EXAMPLES-WEB.md, EXAMPLES.md, README.md
The web demos add MRRT-backed My Account actions and configuration, while documentation covers web passkeys and DPoP behavior.

Estimated code review effort: 4 (Complex) | ~45 minutes

Sequence Diagram(s)

sequenceDiagram
  participant WebDemo
  participant WebAuth0Client
  participant WebMyAccountClient
  participant Auth0SPA
  WebDemo->>Auth0SPA: getApiCredentials for /me/ audience
  WebDemo->>WebMyAccountClient: invoke My Account operation with token
  WebMyAccountClient->>Auth0SPA: create fetcher and call API
  Auth0SPA-->>WebMyAccountClient: return enrollment or account response
  WebMyAccountClient-->>WebDemo: return mapped domain result
Loading

Possibly related PRs

Suggested reviewers: sanchitmehtagit, nandanprabhu

🚥 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 clearly matches the main change: adding My Account API support on the web platform.
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/web-my-account-api-support

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

🧹 Nitpick comments (6)
src/platforms/web/adapters/__tests__/WebMyAccountClient.spec.ts (2)

338-363: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Guard the try/catch assertion block.

If getFactors unexpectedly resolves, the catch body never runs and the test passes silently. Add expect.assertions(4) (or a fail() after the awaited call) so the field assertions are guaranteed to execute.

🤖 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/platforms/web/adapters/__tests__/WebMyAccountClient.spec.ts` around lines
338 - 363, Add an assertion-count guard to the try/catch section of the “wraps
MyAccountApiError into MyAccountError with parsed fields” test, ensuring all
four error-field assertions execute and the test fails if client.getFactors
unexpectedly resolves.

88-336: 🎯 Functional Correctness | 🔵 Trivial | ⚡ Quick win

Enrollment coverage skips several implemented paths.

enrollEmail, enrollPushNotification, getAuthenticationMethodById, and confirmEmail/TOTP/PushNotification have no cases, so a wrong type literal in any of those enrollmentVerify/enrollmentChallenge calls would ship undetected. A parameterized it.each over the type strings would close this cheaply.

🤖 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/platforms/web/adapters/__tests__/WebMyAccountClient.spec.ts` around lines
88 - 336, Add focused parameterized tests in the enrollment challenge/verify
suites for enrollEmail, enrollPushNotification, getAuthenticationMethodById, and
confirmEmail, confirmTOTP, and confirmPushNotification. Use it.each over the
relevant type literals and assert each enrollmentChallenge/enrollmentVerify call
receives the correct type, location, and required mapped fields, covering the
implemented paths without changing production code.

Source: Coding guidelines

src/platforms/web/adapters/WebMyAccountClient.ts (3)

100-126: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Replace the Record<string, any> escape hatch with typed access.

SpaAuthenticationMethod is already a typed snake_case shape; casting through Record<string, any> drops all compile-time checking on 20 field mappings, so a renamed/removed upstream field silently becomes undefined. Same pattern at Lines 147-150 and 172.

As per coding guidelines, "Avoid using any types; use strict TypeScript typing instead".

🤖 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/platforms/web/adapters/WebMyAccountClient.ts` around lines 100 - 126,
Update mapAuthenticationMethod and the corresponding mappings around the
referenced later sections to access SpaAuthenticationMethod fields directly,
removing the Record<string, any> cast. Preserve the existing
snake_case-to-camelCase mapping while relying on the typed interface so invalid
or renamed fields are caught at compile time.

Source: Coding guidelines


297-383: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Five confirm*Enrollment bodies differ only by type and the OTP field.

A single private verifyEnrollment(accessToken, type, id, authSession, otpCode?) helper would collapse ~85 lines while keeping the public signatures intact.

🤖 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/platforms/web/adapters/WebMyAccountClient.ts` around lines 297 - 383, Add
a private verifyEnrollment helper in WebMyAccountClient that accepts
accessToken, enrollment type, id, authSession, and optional otpCode, performs
the shared enrollmentVerify request, maps the response with
mapAuthenticationMethod, and preserves MyAccountError handling through run.
Refactor confirmPhoneEnrollment, confirmEmailEnrollment, confirmTOTPEnrollment,
confirmPushNotificationEnrollment, and confirmRecoveryCodeEnrollment to retain
their existing public signatures while delegating to this helper with the
appropriate type and OTP value.

130-133: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Public methods lack JSDoc.

The class-level comment is good, but none of the ~17 public methods are documented — notably the web-specific DPoP constraint on accessToken and the WebAuthn-serialized authResponse contract, which differ from native.

As per coding guidelines, "Use JSDoc comments to document all public APIs" and "Document platform-specific behavior in JSDoc".

🤖 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/platforms/web/adapters/WebMyAccountClient.ts` around lines 130 - 133,
Document every public method in WebMyAccountClient with JSDoc, including
passkeyEnrollmentChallenge and the other web adapter APIs. Describe each
method’s purpose, the web-specific DPoP requirement for accessToken, and the
WebAuthn-serialized authResponse contract where applicable, while preserving the
existing method behavior and signatures.

Source: Coding guidelines

src/platforms/web/adapters/__tests__/WebAuth0Client.spec.ts (1)

207-209: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Assertion is narrower than the test name.

The title claims the client is "wired with the shared spa-js client", but only instanceof is checked — the constructor args (spa client, domain, useDPoP) are untested. Either rename or assert on the constructor arguments via a spy.

🤖 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/platforms/web/adapters/__tests__/WebAuth0Client.spec.ts` around lines 207
- 209, Strengthen the test named “should provide a WebMyAccountClient wired with
the shared spa-js client” by spying on the WebMyAccountClient constructor and
asserting it receives the shared spa-js client, domain, and useDPoP values;
retain the instance assertion only if useful. Alternatively, rename the test to
describe only the instanceof behavior.
🤖 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 `@example/src/App.web.tsx`:
- Around line 1856-1864: Remove the duplicate hint entry in the styles object
and consolidate the intended color, fontStyle, and marginBottom properties into
the single hint definition. Update the existing hint style near subheading and
buttonGroup; do not leave multiple hint keys.
- Line 364: Remove the debug console.log statement that logs challenge and its
enrollment authSession; leave the surrounding App component logic unchanged.
- Around line 410-433: Update enrollment state handling so the factor type is
preserved separately from the two-value enrollment kind. Adjust onEnrollPhone,
onEnrollEmail, and onEnrollTOTP to store their matching factor types, then
update onConfirmEnrollment to dispatch phone, email, and TOTP factors through
the appropriate confirmation flow so enrollmentVerify receives the correct type.

In `@src/platforms/web/adapters/WebMyAccountClient.ts`:
- Around line 164-169: Update the passkey flow in run so
JSON.parse(authResponse) errors are caught and converted to the expected
PasskeyError, preserving the contract that every passkey operation reports
mapped errors rather than raw SyntaxError instances. Keep valid JSON processing
and the existing EnrollmentVerifyOptions construction unchanged.
- Around line 83-94: Normalize the My Account error type in the
MyAccountApiError handling branch before constructing AuthError: map URI-style
values such as A0E-400-INVALID_PASSKEY to the corresponding PasskeyError code,
including the existing unknown-error fallback, and pass that normalized code as
AuthError’s type/code while preserving the original API details in the
serialized payload.

---

Nitpick comments:
In `@src/platforms/web/adapters/__tests__/WebAuth0Client.spec.ts`:
- Around line 207-209: Strengthen the test named “should provide a
WebMyAccountClient wired with the shared spa-js client” by spying on the
WebMyAccountClient constructor and asserting it receives the shared spa-js
client, domain, and useDPoP values; retain the instance assertion only if
useful. Alternatively, rename the test to describe only the instanceof behavior.

In `@src/platforms/web/adapters/__tests__/WebMyAccountClient.spec.ts`:
- Around line 338-363: Add an assertion-count guard to the try/catch section of
the “wraps MyAccountApiError into MyAccountError with parsed fields” test,
ensuring all four error-field assertions execute and the test fails if
client.getFactors unexpectedly resolves.
- Around line 88-336: Add focused parameterized tests in the enrollment
challenge/verify suites for enrollEmail, enrollPushNotification,
getAuthenticationMethodById, and confirmEmail, confirmTOTP, and
confirmPushNotification. Use it.each over the relevant type literals and assert
each enrollmentChallenge/enrollmentVerify call receives the correct type,
location, and required mapped fields, covering the implemented paths without
changing production code.

In `@src/platforms/web/adapters/WebMyAccountClient.ts`:
- Around line 100-126: Update mapAuthenticationMethod and the corresponding
mappings around the referenced later sections to access SpaAuthenticationMethod
fields directly, removing the Record<string, any> cast. Preserve the existing
snake_case-to-camelCase mapping while relying on the typed interface so invalid
or renamed fields are caught at compile time.
- Around line 297-383: Add a private verifyEnrollment helper in
WebMyAccountClient that accepts accessToken, enrollment type, id, authSession,
and optional otpCode, performs the shared enrollmentVerify request, maps the
response with mapAuthenticationMethod, and preserves MyAccountError handling
through run. Refactor confirmPhoneEnrollment, confirmEmailEnrollment,
confirmTOTPEnrollment, confirmPushNotificationEnrollment, and
confirmRecoveryCodeEnrollment to retain their existing public signatures while
delegating to this helper with the appropriate type and OTP value.
- Around line 130-133: Document every public method in WebMyAccountClient with
JSDoc, including passkeyEnrollmentChallenge and the other web adapter APIs.
Describe each method’s purpose, the web-specific DPoP requirement for
accessToken, and the WebAuthn-serialized authResponse contract where applicable,
while preserving the existing method behavior and signatures.
🪄 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: 121bb551-7155-4cc1-b2b7-0ee094c7bb96

📥 Commits

Reviewing files that changed from the base of the PR and between 47cdc12 and 099baf0.

⛔ Files ignored due to path filters (1)
  • yarn.lock is excluded by !**/yarn.lock, !**/*.lock
📒 Files selected for processing (10)
  • EXAMPLES-WEB.md
  • EXAMPLES.md
  • README.md
  • example/src/App.web.tsx
  • example/src/passkey/webPasskey.ts
  • package.json
  • src/platforms/web/adapters/WebAuth0Client.ts
  • src/platforms/web/adapters/WebMyAccountClient.ts
  • src/platforms/web/adapters/__tests__/WebAuth0Client.spec.ts
  • src/platforms/web/adapters/__tests__/WebMyAccountClient.spec.ts

Comment thread example/src/App.web.tsx Outdated
Comment thread example/src/App.web.tsx
Comment thread example/src/App.web.tsx
Comment thread src/platforms/web/adapters/WebMyAccountClient.ts
Comment thread src/platforms/web/adapters/WebMyAccountClient.ts
Comment thread src/platforms/web/adapters/WebMyAccountClient.ts
Comment thread EXAMPLES-WEB.md Outdated
Comment thread EXAMPLES.md Outdated
Comment thread README.md Outdated
…into feat/web-my-account-api-support

# Conflicts:
#	example/src/App.web.tsx
@subhankarmaiti
subhankarmaiti merged commit b21ca29 into master Jul 27, 2026
5 checks passed
@subhankarmaiti
subhankarmaiti deleted the feat/web-my-account-api-support branch July 27, 2026 18:11
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.

2 participants