Skip to content

[DO NOT MERGE] feat(userinfo): add getUserInfo() to auth0-auth-js and auth0-server-js - #228

Draft
tusharpandey13 wants to merge 1 commit into
mainfrom
feat/userinfo-g8
Draft

[DO NOT MERGE] feat(userinfo): add getUserInfo() to auth0-auth-js and auth0-server-js#228
tusharpandey13 wants to merge 1 commit into
mainfrom
feat/userinfo-g8

Conversation

@tusharpandey13

Copy link
Copy Markdown
Contributor

Summary

  • Adds OIDC /userinfo support (gap G8 — last open item in the node-auth0 authentication-separation parity set).
  • auth0-auth-js: AuthClient.getUserInfo(options) — stateless live fetch via openid-client fetchUserInfo; optional expectedSubject (defaults to skipSubjectCheck). New UserInfoError, GetUserInfoOptions, and an auth0-owned UserInfoResponse interface (only sub required + catch-all index signature) for a stable public contract independent of the openid-client version.
  • auth0-server-js: ServerClient.getUserInfo(storeOptions?) — live fetch using the session access token with automatic refresh. Throws MissingSessionError on no session / missing user sub / resolver-mode domain mismatch; resolves the per-domain AuthClient in resolver mode; always passes the session sub as expectedSubject for an OIDC subject-consistency check. Re-exports UserInfoError.

Additive, minor version bump in both packages. No breaking changes.

Design notes

  • getUserInfo() is a live network call — distinct from the existing getUser(), which returns cached ID-token claims. Documented in EXAMPLES.md.
  • Server layer passes the session sub to openid-client so a token/session subject mismatch is caught automatically (stronger than node-auth0).
  • Resolver-mode delegation uses #getAuthClient(domain) (mirrors logout / revokeRefreshToken), because this.authClient is only available for a static-domain configuration.

Test plan

  • auth0-auth-js: 12 unit tests (success, 401/403, network error, subject match/mismatch, skip-subject default, missing endpoint) — MSW HTTP layer
  • auth0-server-js: 11 unit tests (fresh/refresh success, no session, no-user guard, resolver match/mismatch, sub consistency/mismatch, refresh fail, session expiry, post-refresh 401)
  • npm run build / npm run lint pass both packages
  • Full suites green: 372 (auth-js) + 383 (server-js)

Risk

/userinfo shows 89.1% success over 90d (lowest of the ported endpoints) — likely benign (401s from expired/invalid access tokens). Cross-check the grant-type/endpoint telemetry stitch before GA. Non-blocking for merge.

🤖 Generated with Claude Code

…s (G8)

Adds OIDC /userinfo support to close the last gap (G8) in the node-auth0
authentication-separation parity set.

auth0-auth-js (stateless core):
- AuthClient.getUserInfo(options): live /userinfo fetch via openid-client
  fetchUserInfo; optional expectedSubject (defaults to skipSubjectCheck).
- New UserInfoError (extends ApiError), GetUserInfoOptions, and an
  auth0-owned UserInfoResponse interface (only `sub` required, catch-all
  index signature) for a stable public contract independent of openid-client.

auth0-server-js (session layer):
- ServerClient.getUserInfo(storeOptions?): live fetch using the session's
  access token (auto-refresh via getAccessToken). Throws MissingSessionError
  on no session, missing user sub, or resolver-mode domain mismatch; resolves
  the per-domain AuthClient in resolver mode. Always passes the session `sub`
  as expectedSubject for an OIDC subject-consistency check. Re-exports
  UserInfoError.

Tests: 12 auth-js + 11 server-js (MSW HTTP-layer). Docs: EXAMPLES.md in both
packages. Additive, minor bump; no breaking changes.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Jul 17, 2026

Copy link
Copy Markdown

Warning

Review limit reached

@tusharpandey13, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 19 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 4c5cc958-0fa6-4d96-942e-e22b92e3d0a8

📥 Commits

Reviewing files that changed from the base of the PR and between 60d0e42 and 49ba3df.

📒 Files selected for processing (9)
  • packages/auth0-auth-js/EXAMPLES.md
  • packages/auth0-auth-js/src/auth-client.spec.ts
  • packages/auth0-auth-js/src/auth-client.ts
  • packages/auth0-auth-js/src/errors.ts
  • packages/auth0-auth-js/src/types.ts
  • packages/auth0-server-js/EXAMPLES.md
  • packages/auth0-server-js/src/index.ts
  • packages/auth0-server-js/src/server-client.spec.ts
  • packages/auth0-server-js/src/server-client.ts
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/userinfo-g8

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.

@tusharpandey13 tusharpandey13 changed the title feat(userinfo): add getUserInfo() to auth0-auth-js and auth0-server-js (G8) feat(userinfo): add getUserInfo() to auth0-auth-js and auth0-server-js Jul 17, 2026
@tusharpandey13
tusharpandey13 marked this pull request as draft July 20, 2026 05:26
@tusharpandey13 tusharpandey13 changed the title feat(userinfo): add getUserInfo() to auth0-auth-js and auth0-server-js [DO NOT MERGE] feat(userinfo): add getUserInfo() to auth0-auth-js and auth0-server-js Jul 20, 2026
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