Skip to content

Commit 1ff605e

Browse files
committed
chore: fixed PR comments
1 parent 038661d commit 1ff605e

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

src/utils/theme/themeEngine.ts

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -221,6 +221,21 @@ export function clearThemeCache(): void {
221221
currentThemeCache = {};
222222
}
223223

224+
export const getCaptchaThemeFromSDK = (
225+
screenInstance: Auth0ScreenInstance
226+
): "light" | "dark" | "auto" => {
227+
const allowedThemes = ["light", "dark", "auto"] as const;
228+
const rawTheme =
229+
screenInstance?.branding?.themes?.default?.colors?.captcha_widget_theme;
230+
231+
// Type guard to check if the raw theme is a valid theme
232+
const isValidTheme = (theme: unknown): theme is "light" | "dark" | "auto" => {
233+
return allowedThemes.includes(theme as "light" | "dark" | "auto");
234+
};
235+
236+
return isValidTheme(rawTheme) ? rawTheme : "auto";
237+
};
238+
224239
export const getCaptchaTheme = (
225240
theme: "light" | "dark" | "auto" | undefined
226241
) => {

0 commit comments

Comments
 (0)