File tree Expand file tree Collapse file tree 1 file changed +15
-0
lines changed
Expand file tree Collapse file tree 1 file changed +15
-0
lines changed Original file line number Diff line number Diff 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+
224239export const getCaptchaTheme = (
225240 theme : "light" | "dark" | "auto" | undefined
226241) => {
You can’t perform that action at this time.
0 commit comments