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
6 changes: 6 additions & 0 deletions .changeset/cold-games-lead.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
'@asgardeo/javascript': minor
'@asgardeo/react': minor
---

Set default branding preference API call to false
29 changes: 29 additions & 0 deletions packages/javascript/src/api/getBrandingPreference.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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) {
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 \`<AsgardeoProvider>\` -> \`preferences\` -> \`theme\` -> \`inheritFromBranding\` to false.`,
);
Comment on lines +183 to +185
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

Avoid React-specific guidance in the JavaScript package.

The warning message references <AsgardeoProvider>, which is a React-specific component. Since this is in the @asgardeo/javascript package (not @asgardeo/react), the guidance could be confusing or incorrect for developers using this SDK in non-React contexts (vanilla JS, Vue, Angular, etc.).

Consider making the guidance framework-agnostic:

💡 Proposed fix to use framework-agnostic guidance
       logger.warn(
-        `[BrandingError] ${errorDescription} To resolve this issue, please ${platformConsoleGuidance}. If you want to suppress this warning and stop fetching branding preferences, set \`<AsgardeoProvider>\` -> \`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 the \`preferences.theme.inheritFromBranding\` configuration option to false.`,
       );
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
logger.warn(
`[BrandingError] ${errorDescription} To resolve this issue, please ${platformConsoleGuidance}. If you want to suppress this warning and stop fetching branding preferences, set \`<AsgardeoProvider>\` -> \`preferences\` -> \`theme\` -> \`inheritFromBranding\` to false.`,
);
logger.warn(
`[BrandingError] ${errorDescription} To resolve this issue, please ${platformConsoleGuidance}. If you want to suppress this warning and stop fetching branding preferences, set the \`preferences.theme.inheritFromBranding\` configuration option to false.`,
);
🤖 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/api/getBrandingPreference.ts` around lines 183 - 185,
The logger.warn call in getBrandingPreference.ts contains React-specific
guidance referencing `<AsgardeoProvider>`; update the message to be
framework-agnostic by removing the component reference and instead instructing
users to update the SDK configuration (e.g., set
preferences.theme.inheritFromBranding to false) or consult the
platformConsoleGuidance; modify the string built with errorDescription and
platformConsoleGuidance so it reads something like "To stop fetching branding
preferences, set preferences.theme.inheritFromBranding to false in your SDK
configuration" while keeping the existing errorDescription and
platformConsoleGuidance variables.


throw new AsgardeoAPIError(
`Failed to get branding preference: ${errorText}`,
'getBrandingPreference-ResponseError-001',
Expand Down
5 changes: 4 additions & 1 deletion packages/javascript/src/models/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -381,7 +381,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;
/**
Expand Down
6 changes: 3 additions & 3 deletions packages/react/src/contexts/Asgardeo/AsgardeoProvider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -479,8 +479,8 @@ const AsgardeoProvider: FC<PropsWithChildren<AsgardeoProviderProps>> = ({
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();
Expand Down Expand Up @@ -695,7 +695,7 @@ const AsgardeoProvider: FC<PropsWithChildren<AsgardeoProviderProps>> = ({
brandingPreference={brandingPreference}
isLoading={isBrandingLoading}
error={brandingError}
enabled={preferences?.theme?.inheritFromBranding !== false}
enabled={preferences?.theme?.inheritFromBranding === true}
refetch={refetchBranding}
>
<ThemeProvider
Expand Down
Loading