import { getParseQueryStringFromLocation, OidcClient } from '@axa-fr/oidc-client'; import { ComponentType, useEffect } from 'react'; const SilentLogin: ComponentType = ({ configurationName }) => { const queryParams = getParseQueryStringFromLocation(window.location.href); const getOidc = OidcClient.getOrThrow; const oidc = getOidc(configurationName); let extras = null; for (const [key, value] of Object.entries(queryParams)) { if (key === 'state' || key === 'scope') { continue; } extras ??= {}; extras[key] = value; } useEffect(() => { if (!oidc.tokens || queryParams.prompt === 'none' || queryParams._oidc_resource) { oidc .loginAsync(null, extras, true, queryParams.scope) .catch(error => console.error('Silent authorization failed:', error)); } }, []); return <>; }; export default SilentLogin;