infer type of algToKeyUriAlg from type of kcConfig + fix totp interface

- add more yarn dirs to .gitignore
This commit is contained in:
Thomas Silvestre 2023-04-06 17:50:26 +02:00
parent c1e0563eba
commit 564ffc2be9
4 changed files with 9 additions and 6 deletions

4
.gitignore vendored
View File

@ -52,4 +52,6 @@ jspm_packages
/src/account/i18n/baseMessages/
# VS Code devcontainers
.devcontainer
.devcontainer
/.yarn
/.yarnrc.yml

View File

@ -333,7 +333,6 @@ export declare namespace KcContext {
totpSecretEncoded: string;
qrUrl: string;
policy: {
supportedApplications: string[];
algorithm: "HmacSHA1" | "HmacSHA256" | "HmacSHA512";
digits: number;
lookAheadWindow: number;
@ -347,6 +346,7 @@ export declare namespace KcContext {
initialCounter: number;
}
);
supportedApplications: string[];
totpSecretQrCode: string;
manualUrl: string;
totpSecret: string;

View File

@ -453,8 +453,8 @@ export const kcContextMocks: KcContext[] = [
manualUrl: "#",
totpSecret: "G4nsI8lQagRMUchH8jEG",
otpCredentials: [],
supportedApplications: ["FreeOTP", "Google Authenticator"],
policy: {
supportedApplications: ["FreeOTP", "Google Authenticator"],
algorithm: "HmacSHA1",
digits: 6,
lookAheadWindow: 1,

View File

@ -3,6 +3,7 @@ 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<Extract<KcContext, { pageId: "login-config-totp.ftl" }>, I18n>) {
const { kcContext, i18n, doUseDefaultCss, Template, classes } = props;
@ -16,7 +17,7 @@ export default function LoginConfigTotp(props: PageProps<Extract<KcContext, { pa
const { msg, msgStr } = i18n;
const algToKeyUriAlg: Record<KcContext.LoginConfigTotp["totp"]["policy"]["algorithm"], string> = {
const algToKeyUriAlg: Record<(typeof kcContext)["totp"]["policy"]["algorithm"], string> = {
"HmacSHA1": "SHA1",
"HmacSHA256": "SHA256",
"HmacSHA512": "SHA512"
@ -30,8 +31,8 @@ export default function LoginConfigTotp(props: PageProps<Extract<KcContext, { pa
<p>{msg("loginTotpStep1")}</p>
<ul id="kc-totp-supported-apps">
{totp.policy.supportedApplications.map(app => (
<li>{app}</li>
{totp.supportedApplications.map(app => (
<li>{msgStr(app as MessageKey, app)}</li>
))}
</ul>
</li>