Skip to content

feat: add MyAccount API client support#1121

Open
yogeshchoudhary147 wants to merge 1 commit into
mainfrom
feat/my-account-api-client
Open

feat: add MyAccount API client support#1121
yogeshchoudhary147 wants to merge 1 commit into
mainfrom
feat/my-account-api-client

Conversation

@yogeshchoudhary147

@yogeshchoudhary147 yogeshchoudhary147 commented Jun 11, 2026

Copy link
Copy Markdown
Contributor

The `myAccount` client introduced in auth0-spa-js#1615 was not yet surfaced through the React SDK. This PR exposes it so it is accessible via `useAuth0`.

Changes

`useAuth0().myAccount` (new)

Factors

  • `getFactors()`: list all MFA factors enabled on the tenant with their `type` and `usage`

Authentication methods

  • `getAuthenticationMethods(type?)`: list enrolled methods, optionally filtered by type
  • `getAuthenticationMethod(id)`: get a single method by ID
  • `updateAuthenticationMethod(id, data)`: update `name` or `preferred_authentication_method`
  • `deleteAuthenticationMethod(id)`: remove an enrolled method

Enrollment (two-step)

  • `enrollmentChallenge(options)`: initiate enrollment for any factor type; returns challenge data (WebAuthn creation options, barcode URI, recovery code, password policy, etc.)
  • `enrollmentVerify(options)`: confirm enrollment; returns the created `AuthenticationMethod`

Supports: `passkey`, `webauthn-platform`, `webauthn-roaming`, `phone`, `email`, `totp`, `push-notification`, `recovery-code`, `password`.

Implementation pattern

`myAccount` follows the same pattern as `mfa` — a `useMemo(() => client.myAccount, [client])` passthrough. No `useCallback` wrappers or `GET_ACCESS_TOKEN_COMPLETE` dispatches are needed since none of these operations affect `isAuthenticated` or `user`.

Exports

`MyAccountApiClient` (type) and `MyAccountApiError` are now exported from the package root.

Dependency

Bumps `@auth0/auth0-spa-js` to `^2.21.1`.

Test plan

11 unit tests in `tests/my-account.test.tsx`. 128 tests passing overall, 100% coverage across all metrics (statements, branches, functions, lines).

Availability

  • `myAccount` is defined on the context after mount
  • All seven methods are present on the client

Methods

  • `getFactors()`: resolves to an array
  • `getAuthenticationMethods()`: resolves to an array
  • `getAuthenticationMethods('passkey')`: type filter forwarded correctly
  • `getAuthenticationMethod(id)`: resolves to correct method
  • `updateAuthenticationMethod(id, data)`: resolves to updated method
  • `deleteAuthenticationMethod(id)`: resolves without error
  • `enrollmentChallenge(options)`: resolves with challenge shape (`id`, `auth_session`)
  • `enrollmentVerify(options)`: resolves to created `AuthenticationMethod`

Error handling

  • `MyAccountApiError` thrown by a method propagates untouched to the caller

@yogeshchoudhary147 yogeshchoudhary147 requested a review from a team as a code owner June 11, 2026 16:02
@yogeshchoudhary147 yogeshchoudhary147 force-pushed the feat/my-account-api-client branch 2 times, most recently from e43f462 to de41faf Compare June 12, 2026 03:56
@yogeshchoudhary147 yogeshchoudhary147 force-pushed the feat/my-account-api-client branch from de41faf to 3838d77 Compare June 12, 2026 04:09
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