import { clsx } from "keycloakify/tools/clsx";
import type { PageProps } from "keycloakify/login/pages/PageProps";
import { useGetClassName } from "keycloakify/login/lib/useGetClassName";
import type { KcContext } from "../kcContext";
import type { I18n } from "../i18n";
import { MessageKey } from "keycloakify/login/i18n/i18n";
export default function LoginConfigTotp(props: PageProps, I18n>) {
const { kcContext, i18n, doUseDefaultCss, Template, classes } = props;
const { getClassName } = useGetClassName({
doUseDefaultCss,
classes
});
const { url, isAppInitiatedAction, totp, mode, messagesPerField } = kcContext;
const { msg, msgStr } = i18n;
// NOTE: We should edit the ftl_object_to_js_code_declaring_an_object.ftl
// so that we have access to getAlgorithmKey()
const algToKeyUriAlg: Record<(typeof kcContext)["totp"]["policy"]["algorithm"], string> = {
"HmacSHA1": "SHA1",
"HmacSHA256": "SHA256",
"HmacSHA512": "SHA512"
};
return (
<>
-
{msg("loginTotpStep1")}
{totp.supportedApplications.map(app => (
- {msg(app as MessageKey)}
))}
{mode == "manual" ? (
<>
-
{msg("loginTotpManualStep2")}
{totp.totpSecretEncoded}
{msg("loginTotpScanBarcode")}
-
{msg("loginTotpManualStep3")}
-
{msg("loginTotpType")}: {msg(`loginTotp.${totp.policy.type}`)}
-
{msg("loginTotpAlgorithm")}: {algToKeyUriAlg?.[totp.policy.algorithm] ?? totp.policy.algorithm}
-
{msg("loginTotpDigits")}: {totp.policy.digits}
{totp.policy.type === "totp" ? (
-
{msg("loginTotpInterval")}: {totp.policy.period}
) : (
-
{msg("loginTotpCounter")}: {totp.policy.initialCounter}
)}
>
) : (
{msg("loginTotpStep2")}
{msg("loginTotpUnableToScan")}
)}
{msg("loginTotpStep3")}
{msg("loginTotpStep3DeviceName")}
>
);
}
function LogoutOtherSessions(props: { getClassName: ReturnType["getClassName"]; i18n: I18n }) {
const { getClassName, i18n } = props;
const { msg } = i18n;
return (
);
}