Skip to content

Provide support to use separate resource servers - #46

Merged
rajithacharith merged 1 commit into
thunder-id:mainfrom
rajithacharith:main
Aug 3, 2026
Merged

Provide support to use separate resource servers#46
rajithacharith merged 1 commit into
thunder-id:mainfrom
rajithacharith:main

Conversation

@rajithacharith

@rajithacharith rajithacharith commented Aug 3, 2026

Copy link
Copy Markdown
Contributor

Purpose

Add support for overriding the resource-server endpoints (/flow/execute, /flow/meta, /users/me) independently of the OAuth/OIDC endpoints.

Today the SDK derives both the OAuth endpoints and the Thunder resource APIs from a single config.baseUrl. In a trusted-issuer (federated) setup the two live on different hosts: OAuth/discovery must target the authorization server (IdP), while flow and user-management calls must target the resource server. Because everything was pinned to baseUrl, creating a user (USER_ONBOARDINGPOST /flow/execute) was sent to the IdP instead of the resource server and failed.

The OAuth endpoints were already overridable via config.endpoints; this PR extends that same mechanism to the resource-server endpoints.

Approach

  • Extend config.endpoints with flowExecute, flowMeta, and usersMe, documented alongside the existing OAuth overrides (packages/javascript/src/models/config.ts).
  • Add a small resolveResourceEndpoint(key, config, explicitUrl?) helper that resolves the effective url (explicit per-call URL → config override → undefined to fall back to baseUrl), so behavior is unchanged when no override is set. Exported from the package index.
  • Filter the new resource keys out of the OIDC provider metadata in AuthenticationHelper so they never leak into the OAuth endpoint resolution.
  • Thread the override through every call site that hits these endpoints across javascript, react, vue, nextjs, and express. For the React/Vue context-based providers, expose endpoints through the ThunderID context so FlowMetaProvider/UserProfile can resolve it.

The change is additive and backward-compatible: with no endpoints override set, resolution falls back to ${baseUrl}/... exactly as before.

Related Issues

Related PRs

  • N/A

Checklist

  • Followed the contribution guidelines.
  • Manual test round performed and verified.
  • Documentation provided. (JSDoc on config.endpoints; docs site page updated separately)
  • Tests provided.
    • Unit Tests (resolveResourceEndpoint.test.ts, AuthenticationHelper.resourceEndpoints.test.ts)
    • Integration Tests
  • Breaking changes. (Fill if applicable)
    • Breaking changes section filled.
    • breaking change label added.

Security checks

  • Followed secure coding standards in WSO2 Secure Coding Guidelines
  • Confirmed that this PR doesn't commit any keys, passwords, tokens, usernames, or other secrets.

Summary by CodeRabbit

  • New Features

    • Added configurable resource-server endpoints for user profiles and embedded authentication flows.
    • Resource endpoints can be customized globally or overridden for individual requests.
    • Exposed endpoint resolution utilities and configuration types publicly.
    • Added endpoint configuration support across React, Vue, Next.js, and Express integrations.
  • Bug Fixes

    • Improved separation between OIDC provider endpoints and resource-server endpoints.
  • Tests

    • Added coverage for endpoint resolution, overrides, fallbacks, and authentication endpoint handling.

@coderabbitai

coderabbitai Bot commented Aug 3, 2026

Copy link
Copy Markdown

Review Change Stack

Warning

Review limit reached

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

Next review available in: 13 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: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: 34ab486d-847b-4e60-b88e-a9db561cfbe6

📥 Commits

Reviewing files that changed from the base of the PR and between a9a3f19 and 051e31f.

📒 Files selected for processing (19)
  • packages/express/src/middleware/flow.ts
  • packages/javascript/src/index.ts
  • packages/javascript/src/models/config.ts
  • packages/javascript/src/utils/AuthenticationHelper.ts
  • packages/javascript/src/utils/__tests__/AuthenticationHelper.resourceEndpoints.test.ts
  • packages/javascript/src/utils/__tests__/resolveResourceEndpoint.test.ts
  • packages/javascript/src/utils/resolveResourceEndpoint.ts
  • packages/nextjs/src/ThunderIDNextClient.ts
  • packages/nextjs/src/server/ThunderIDProvider.tsx
  • packages/react/src/ThunderIDReactClient.ts
  • packages/react/src/components/presentation/auth/InviteUser/InviteUser.tsx
  • packages/react/src/contexts/FlowMeta/FlowMetaProvider.tsx
  • packages/react/src/contexts/ThunderID/ThunderIDContext.ts
  • packages/react/src/contexts/ThunderID/ThunderIDProvider.tsx
  • packages/vue/src/ThunderIDVueClient.ts
  • packages/vue/src/components/presentation/user-profile/UserProfile.ts
  • packages/vue/src/models/contexts.ts
  • packages/vue/src/providers/FlowMetaProvider.ts
  • packages/vue/src/providers/ThunderIDProvider.ts
📝 Walkthrough

Walkthrough

The SDKs add configurable resource-server endpoints for flow execution, flow metadata, and current-user operations. React, Vue, Next.js, and Express integrations now resolve these endpoints from configuration or explicit URLs.

Changes

Resource endpoint configuration

Layer / File(s) Summary
Endpoint contract and resolution
packages/javascript/src/models/config.ts, packages/javascript/src/utils/resolveResourceEndpoint.ts, packages/javascript/src/utils/AuthenticationHelper.ts, packages/javascript/src/index.ts, packages/javascript/src/utils/__tests__/*
Adds typed resource endpoint overrides, explicit URL precedence, public exports, OIDC metadata filtering, and Vitest coverage.
React and Vue endpoint wiring
packages/react/src/*, packages/vue/src/*
Exposes endpoint configuration through providers and contexts. Uses resolved endpoints for flows, metadata, and user profile requests.
Next.js and Express endpoint wiring
packages/nextjs/src/*, packages/express/src/middleware/flow.ts
Uses resolved endpoints for flow execution, flow metadata, user retrieval, and profile updates.

Estimated code review effort: 3 (Moderate) | ~25 minutes

Sequence Diagram(s)

sequenceDiagram
  participant Provider
  participant resolveResourceEndpoint
  participant ResourceAPI
  Provider->>resolveResourceEndpoint: Resolve flow or profile endpoint
  resolveResourceEndpoint-->>Provider: Return configured or explicit URL
  Provider->>ResourceAPI: Send request to resolved endpoint
Loading

Possibly related PRs

Suggested reviewers: brionmario, thamindudilshan

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 33.33% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly summarizes the main change: support for separate resource servers.
Description check ✅ Passed The description covers the purpose, approach, issue, testing, documentation, compatibility, and security checks required by the template.
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 unit tests (beta)
  • Create PR with unit tests

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: 2

🧹 Nitpick comments (1)
packages/javascript/src/utils/__tests__/AuthenticationHelper.resourceEndpoints.test.ts (1)

35-64: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Cover all endpoint-resolution methods.

This test only calls resolveEndpointsByBaseURL. Add the same resource-endpoint exclusion assertions for resolveEndpoints and resolveEndpointsExplicitly.

🤖 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
`@packages/javascript/src/utils/__tests__/AuthenticationHelper.resourceEndpoints.test.ts`
around lines 35 - 64, Extend the AuthenticationHelper resource-endpoint
filtering test to also call resolveEndpoints and resolveEndpointsExplicitly,
asserting each result excludes flowExecute, flowMeta, and usersMe in both
camelCase and snake_case while preserving OIDC endpoint resolution and
overrides.
🤖 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 `@packages/javascript/src/utils/AuthenticationHelper.ts`:
- Around line 75-86: Replace the repeated dynamic endpoint assignments with one
typed helper that filters out RESOURCE_ENDPOINT_KEYS, converts OIDC endpoint
names to snake_case, and safely maps configured endpoint values. Use this helper
in resolveEndpoints, resolveEndpointsExplicitly, and resolveEndpointsByBaseURL;
apply the change at packages/javascript/src/utils/AuthenticationHelper.ts lines
75-86, 139-150, and 179-190, respectively.

In `@packages/react/src/ThunderIDReactClient.ts`:
- Line 173: Reload the recovered configuration after client initialization and
before the endpoint resolution in the flow execution path. Update the logic
around this._initializeConfig and resolveResourceEndpoint so it uses the
persisted flowExecute/baseUrl values instead of the stale config loaded before
initialization.

---

Nitpick comments:
In
`@packages/javascript/src/utils/__tests__/AuthenticationHelper.resourceEndpoints.test.ts`:
- Around line 35-64: Extend the AuthenticationHelper resource-endpoint filtering
test to also call resolveEndpoints and resolveEndpointsExplicitly, asserting
each result excludes flowExecute, flowMeta, and usersMe in both camelCase and
snake_case while preserving OIDC endpoint resolution and overrides.
🪄 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: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: f6abc3b9-4169-4f73-a88f-8655111769c9

📥 Commits

Reviewing files that changed from the base of the PR and between 0f22744 and 5225ae3.

📒 Files selected for processing (18)
  • packages/express/src/middleware/flow.ts
  • packages/javascript/src/index.ts
  • packages/javascript/src/models/config.ts
  • packages/javascript/src/utils/AuthenticationHelper.ts
  • packages/javascript/src/utils/__tests__/AuthenticationHelper.resourceEndpoints.test.ts
  • packages/javascript/src/utils/__tests__/resolveResourceEndpoint.test.ts
  • packages/javascript/src/utils/resolveResourceEndpoint.ts
  • packages/nextjs/src/ThunderIDNextClient.ts
  • packages/nextjs/src/server/ThunderIDProvider.tsx
  • packages/react/src/ThunderIDReactClient.ts
  • packages/react/src/contexts/FlowMeta/FlowMetaProvider.tsx
  • packages/react/src/contexts/ThunderID/ThunderIDContext.ts
  • packages/react/src/contexts/ThunderID/ThunderIDProvider.tsx
  • packages/vue/src/ThunderIDVueClient.ts
  • packages/vue/src/components/presentation/user-profile/UserProfile.ts
  • packages/vue/src/models/contexts.ts
  • packages/vue/src/providers/FlowMetaProvider.ts
  • packages/vue/src/providers/ThunderIDProvider.ts

Comment thread packages/javascript/src/utils/AuthenticationHelper.ts Outdated
Comment thread packages/react/src/ThunderIDReactClient.ts

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

♻️ Duplicate comments (1)
packages/javascript/src/utils/AuthenticationHelper.ts (1)

75-86: 📐 Maintainability & Code Quality | 🟠 Major | ⚡ Quick win

Restore type-safe OIDC endpoint mapping.

Static analysis still reports an unsafe assignment at each dynamic endpoint assignment. Resource-key filtering does not narrow arbitrary strings to valid OIDC metadata keys. Convert recognized OIDC endpoint names through one typed mapping before assigning values.

  • packages/javascript/src/utils/AuthenticationHelper.ts#L75-L86: use the typed mapping in resolveEndpoints.
  • packages/javascript/src/utils/AuthenticationHelper.ts#L139-L150: use the typed mapping in resolveEndpointsExplicitly.
  • packages/javascript/src/utils/AuthenticationHelper.ts#L179-L190: use the typed mapping in resolveEndpointsByBaseURL.
🤖 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 `@packages/javascript/src/utils/AuthenticationHelper.ts` around lines 75 - 86,
Restore type-safe OIDC endpoint assignment by introducing or reusing one typed
mapping from recognized endpoint names to OIDC metadata keys, then use it in
resolveEndpoints, resolveEndpointsExplicitly, and resolveEndpointsByBaseURL
instead of assigning through arbitrary dynamic strings. Apply this change at
packages/javascript/src/utils/AuthenticationHelper.ts lines 75-86, 139-150, and
179-190, preserving resource-endpoint filtering and existing value resolution.

Sources: Coding guidelines, Linters/SAST tools

🤖 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 `@packages/react/src/contexts/ThunderID/ThunderIDProvider.tsx`:
- Line 464: Update the reInitialize flow so that after the client is
reinitialized, React config state is refreshed from client.getConfiguration().
Ensure both context endpoint usages receive the updated configuration rather
than stale config state, while preserving the existing client reinitialization
behavior.

In `@packages/vue/src/ThunderIDVueClient.ts`:
- Around line 101-107: The User profile request flow in ThunderIDVueClient must
use typed request options and ThunderIDVueConfig instead of method- or
variable-level any annotations. Update both affected sites in
packages/vue/src/ThunderIDVueClient.ts (lines 101-107 and 126-133): type the
method options with the intended option shape, type configuration data as
ThunderIDVueConfig, and preserve the existing baseUrl, url, and
resolveResourceEndpoint behavior.

---

Duplicate comments:
In `@packages/javascript/src/utils/AuthenticationHelper.ts`:
- Around line 75-86: Restore type-safe OIDC endpoint assignment by introducing
or reusing one typed mapping from recognized endpoint names to OIDC metadata
keys, then use it in resolveEndpoints, resolveEndpointsExplicitly, and
resolveEndpointsByBaseURL instead of assigning through arbitrary dynamic
strings. Apply this change at
packages/javascript/src/utils/AuthenticationHelper.ts lines 75-86, 139-150, and
179-190, preserving resource-endpoint filtering and existing value resolution.
🪄 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: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: 9e1d9dbb-1c07-45f7-b7b2-421a1134de44

📥 Commits

Reviewing files that changed from the base of the PR and between 5225ae3 and a9a3f19.

📒 Files selected for processing (19)
  • packages/express/src/middleware/flow.ts
  • packages/javascript/src/index.ts
  • packages/javascript/src/models/config.ts
  • packages/javascript/src/utils/AuthenticationHelper.ts
  • packages/javascript/src/utils/__tests__/AuthenticationHelper.resourceEndpoints.test.ts
  • packages/javascript/src/utils/__tests__/resolveResourceEndpoint.test.ts
  • packages/javascript/src/utils/resolveResourceEndpoint.ts
  • packages/nextjs/src/ThunderIDNextClient.ts
  • packages/nextjs/src/server/ThunderIDProvider.tsx
  • packages/react/src/ThunderIDReactClient.ts
  • packages/react/src/components/presentation/auth/InviteUser/InviteUser.tsx
  • packages/react/src/contexts/FlowMeta/FlowMetaProvider.tsx
  • packages/react/src/contexts/ThunderID/ThunderIDContext.ts
  • packages/react/src/contexts/ThunderID/ThunderIDProvider.tsx
  • packages/vue/src/ThunderIDVueClient.ts
  • packages/vue/src/components/presentation/user-profile/UserProfile.ts
  • packages/vue/src/models/contexts.ts
  • packages/vue/src/providers/FlowMetaProvider.ts
  • packages/vue/src/providers/ThunderIDProvider.ts
🚧 Files skipped from review as they are similar to previous changes (7)
  • packages/javascript/src/utils/tests/AuthenticationHelper.resourceEndpoints.test.ts
  • packages/javascript/src/utils/tests/resolveResourceEndpoint.test.ts
  • packages/javascript/src/index.ts
  • packages/react/src/contexts/ThunderID/ThunderIDContext.ts
  • packages/vue/src/models/contexts.ts
  • packages/javascript/src/utils/resolveResourceEndpoint.ts
  • packages/javascript/src/models/config.ts

Comment thread packages/react/src/contexts/ThunderID/ThunderIDProvider.tsx
Comment thread packages/vue/src/ThunderIDVueClient.ts Outdated
* });
* ```
*/
const resolveResourceEndpoint = (

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we really need this wrapper?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will fix this with a followup PR as discussed

Comment thread packages/javascript/src/utils/resolveResourceEndpoint.ts
@rajithacharith
rajithacharith merged commit 3088bfa into thunder-id:main Aug 3, 2026
3 checks passed
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