Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions .changeset/wicked-ghosts-swim.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
---
'@asgardeo/browser': patch
---

Fix SCIM2 responses (`/scim2/Me`, `/scim2/Schemas`, and related organization/profile API calls) not being parsed as JSON.

`FetchHttpClient` only treated a response as JSON when its `Content-Type` header was exactly `application/json`. Asgardeo's SCIM2 endpoints respond with `Content-Type: application/scim+json`, which didn't match, so the response body was returned as raw, unparsed text instead of a parsed object. This caused the user profile to render incorrectly (missing fields, or falling back to a partial ID-token-derived profile) or crash with `TypeError: schemas.forEach is not a function`.

The content-type check now correctly matches `application/json` and any subtype ending in `+json` (e.g. `application/scim+json`), while still treating non-document JSON formats like `application/geo+json-seq` as text (since those aren't parseable as a single JSON document).
7 changes: 3 additions & 4 deletions packages/browser/src/FetchHttpClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -99,10 +99,9 @@ export class FetchHttpClient extends HttpClient {
} as Partial<HttpError>);
}

const contentType: string = fetchResponse.headers.get('content-type') ?? '';
const responseData: T = contentType.includes('application/json')
? await fetchResponse.json()
: ((await fetchResponse.text()) as any);
const contentType: string = (fetchResponse.headers.get('content-type') ?? '').split(';')[0].trim().toLowerCase();
const isJson: boolean = contentType === 'application/json' || contentType.endsWith('+json');
const responseData: T = isJson ? await fetchResponse.json() : ((await fetchResponse.text()) as any);

const responseHeaders: Record<string, string> = {};
fetchResponse.headers.forEach((value: string, key: string) => {
Expand Down
Loading
Loading