From 608b4ba8366ae3df8089ece0c532a66d876b4e44 Mon Sep 17 00:00:00 2001 From: kavindadewmith Date: Tue, 17 Mar 2026 20:03:10 +0530 Subject: [PATCH 1/5] Refactor branding preference fetching logic --- packages/javascript/src/models/config.ts | 5 ++++- packages/react/src/contexts/Asgardeo/AsgardeoProvider.tsx | 6 +++--- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/packages/javascript/src/models/config.ts b/packages/javascript/src/models/config.ts index 7d671c03..61422e85 100644 --- a/packages/javascript/src/models/config.ts +++ b/packages/javascript/src/models/config.ts @@ -366,7 +366,10 @@ export interface ThemePreferences { */ direction?: 'ltr' | 'rtl'; /** - * Inherit from Branding from WSO2 Identity Server or Asgardeo. + * Inherit branding from WSO2 Identity Server or Asgardeo. + * When set to `true`, the SDK will fetch and apply branding preferences from the server. + * Defaults to `false` — branding is not fetched unless explicitly enabled. + * @default false */ inheritFromBranding?: boolean; /** diff --git a/packages/react/src/contexts/Asgardeo/AsgardeoProvider.tsx b/packages/react/src/contexts/Asgardeo/AsgardeoProvider.tsx index 20e2fda4..e44d8973 100644 --- a/packages/react/src/contexts/Asgardeo/AsgardeoProvider.tsx +++ b/packages/react/src/contexts/Asgardeo/AsgardeoProvider.tsx @@ -476,8 +476,8 @@ const AsgardeoProvider: FC> = ({ return; } - // Enable branding by default or when explicitly enabled - const shouldFetchBranding: boolean = preferences?.theme?.inheritFromBranding !== false; + // Only fetch branding when explicitly enabled via preferences.theme.inheritFromBranding + const shouldFetchBranding: boolean = preferences?.theme?.inheritFromBranding === true; if (shouldFetchBranding && isInitializedSync && baseUrl && !hasFetchedBranding && !isBrandingLoading) { fetchBranding(); @@ -675,7 +675,7 @@ const AsgardeoProvider: FC> = ({ brandingPreference={brandingPreference} isLoading={isBrandingLoading} error={brandingError} - enabled={preferences?.theme?.inheritFromBranding !== false} + enabled={preferences?.theme?.inheritFromBranding === true} refetch={refetchBranding} > Date: Wed, 25 Mar 2026 18:15:08 +0530 Subject: [PATCH 2/5] Enhance error handling in getBrandingPreference with platform-specific guidance --- .../src/api/getBrandingPreference.ts | 29 +++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/packages/javascript/src/api/getBrandingPreference.ts b/packages/javascript/src/api/getBrandingPreference.ts index 8cd964a8..95cbc6a7 100644 --- a/packages/javascript/src/api/getBrandingPreference.ts +++ b/packages/javascript/src/api/getBrandingPreference.ts @@ -18,6 +18,9 @@ import AsgardeoAPIError from '../errors/AsgardeoAPIError'; import {BrandingPreference} from '../models/branding-preference'; +import {Platform} from '../models/platforms'; +import identifyPlatform from '../utils/identifyPlatform'; +import logger from '../utils/logger'; /** * Configuration for the getBrandingPreference request @@ -155,6 +158,32 @@ const getBrandingPreference = async ({ if (!response?.ok) { const errorText: string = await response.text(); + const platform: Platform = identifyPlatform({baseUrl} as any); + + let errorDescription: string; + try { + const errorBody: {description?: string; message?: string} = JSON.parse(errorText) as { + description?: string; + message?: string; + }; + errorDescription = errorBody?.description || errorBody?.message || errorText; + } catch { + errorDescription = errorText; + } + + let platformConsoleGuidance: string; + if (platform === Platform.Asgardeo || platform === Platform.AsgardeoV2) { + platformConsoleGuidance = 'configure branding preferences in the Asgardeo console'; + } else if (platform === Platform.IdentityServer) { + platformConsoleGuidance = 'configure branding preferences in the WSO2 Identity Server console'; + } else { + platformConsoleGuidance = 'configure branding preferences in the platform console'; + } + + logger.warn( + `[BrandingError] ${errorDescription} To resolve this issue, please ${platformConsoleGuidance}. If you want to suppress this warning and stop fetching branding preferences, set \`\` -> \`preferences\` -> \`theme\` -> \`inheritFromBranding\` to false.` + ); + throw new AsgardeoAPIError( `Failed to get branding preference: ${errorText}`, 'getBrandingPreference-ResponseError-001', From 34887c8e69695e76905c6c67c33597c542ca9adc Mon Sep 17 00:00:00 2001 From: kavindadewmith Date: Wed, 25 Mar 2026 18:22:47 +0530 Subject: [PATCH 3/5] Fix lint errors --- packages/javascript/src/api/getBrandingPreference.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/javascript/src/api/getBrandingPreference.ts b/packages/javascript/src/api/getBrandingPreference.ts index 95cbc6a7..f4dc7e21 100644 --- a/packages/javascript/src/api/getBrandingPreference.ts +++ b/packages/javascript/src/api/getBrandingPreference.ts @@ -181,7 +181,7 @@ const getBrandingPreference = async ({ } logger.warn( - `[BrandingError] ${errorDescription} To resolve this issue, please ${platformConsoleGuidance}. If you want to suppress this warning and stop fetching branding preferences, set \`\` -> \`preferences\` -> \`theme\` -> \`inheritFromBranding\` to false.` + `[BrandingError] ${errorDescription} To resolve this issue, please ${platformConsoleGuidance}. If you want to suppress this warning and stop fetching branding preferences, set \`\` -> \`preferences\` -> \`theme\` -> \`inheritFromBranding\` to false.`, ); throw new AsgardeoAPIError( From 67da5a845d595a804ed8da7970580fe6f928a1f1 Mon Sep 17 00:00:00 2001 From: kavindadewmith Date: Wed, 25 Mar 2026 18:33:38 +0530 Subject: [PATCH 4/5] =?UTF-8?q?Add=20changeset=20=F0=9F=A6=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .changeset/cold-games-lead.md | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 .changeset/cold-games-lead.md diff --git a/.changeset/cold-games-lead.md b/.changeset/cold-games-lead.md new file mode 100644 index 00000000..2e048b69 --- /dev/null +++ b/.changeset/cold-games-lead.md @@ -0,0 +1,6 @@ +--- +'@asgardeo/javascript': minor +'@asgardeo/react': minor +--- + +Set default branding preference API call to false From 1d26f796efbf95406599553b9ece985c0b02ad50 Mon Sep 17 00:00:00 2001 From: kavindadewmith Date: Thu, 26 Mar 2026 16:10:29 +0530 Subject: [PATCH 5/5] Refine platform-specific guidance in getBrandingPreference for Asgardeo --- packages/javascript/src/api/getBrandingPreference.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/javascript/src/api/getBrandingPreference.ts b/packages/javascript/src/api/getBrandingPreference.ts index f4dc7e21..fb1d68fd 100644 --- a/packages/javascript/src/api/getBrandingPreference.ts +++ b/packages/javascript/src/api/getBrandingPreference.ts @@ -172,7 +172,7 @@ const getBrandingPreference = async ({ } let platformConsoleGuidance: string; - if (platform === Platform.Asgardeo || platform === Platform.AsgardeoV2) { + if (platform === Platform.Asgardeo) { platformConsoleGuidance = 'configure branding preferences in the Asgardeo console'; } else if (platform === Platform.IdentityServer) { platformConsoleGuidance = 'configure branding preferences in the WSO2 Identity Server console';