/* eslint-disable */ // @ts-nocheck import { ProviderRepresentation } from "@keycloak/keycloak-admin-client/lib/defs/serverInfoRepesentation"; import { ActionGroup, Button, FormGroup, Switch } from "../../../shared/@patternfly/react-core"; import { useTranslation } from "react-i18next"; import { HelpItem, SelectControl } from "../../../shared/keycloak-ui-shared"; import { FormAccess } from "../../components/form/FormAccess"; import { MultiLineInput } from "../../components/multi-line-input/MultiLineInput"; import { useServerInfo } from "../../context/server-info/ServerInfoProvider"; import { convertAttributeNameToForm, sortProviders } from "../../util"; import { FormFields } from "../ClientDetails"; import { ApplicationUrls } from "./ApplicationUrls"; import { Controller, useFormContext } from "react-hook-form"; type FineGrainOpenIdConnectProps = { save: () => void; reset: () => void; hasConfigureAccess?: boolean; }; export const FineGrainOpenIdConnect = ({ save, reset, hasConfigureAccess, }: FineGrainOpenIdConnectProps) => { const { t } = useTranslation(); const { control } = useFormContext(); const providers = useServerInfo().providers; const clientSignatureProviders = providers?.clientSignature.providers; const contentEncryptionProviders = providers?.contentencryption.providers; const cekManagementProviders = providers?.cekmanagement.providers; const signatureProviders = providers?.signature.providers; const convert = (list: { [index: string]: ProviderRepresentation }) => sortProviders(list).map((i) => ({ key: i, value: i })); const prependEmpty = (list: { [index: string]: ProviderRepresentation }) => [ { key: "", value: t("choose") }, ...convert(list), ]; const prependNone = (list: { [index: string]: ProviderRepresentation }) => [ { key: "none", value: t("none") }, ...convert(list), ]; return ( ( "attributes.access.token.signed.response.alg", )} label={t("accessTokenSignatureAlgorithm")} labelIcon={t("accessTokenSignatureAlgorithmHelp")} controller={{ defaultValue: "", }} options={prependEmpty(clientSignatureProviders!)} /> } > ( "attributes.access.token.header.type.rfc9068", )} defaultValue="false" control={control} render={({ field }) => ( field.onChange(value.toString())} aria-label={t("useRfc9068AccessTokenType")} /> )} /> ( "attributes.id.token.signed.response.alg", )} label={t("idTokenSignatureAlgorithm")} labelIcon={t("idTokenSignatureAlgorithmHelp")} controller={{ defaultValue: "", }} options={prependEmpty(clientSignatureProviders!)} /> ( "attributes.id.token.encrypted.response.alg", )} label={t("idTokenEncryptionKeyManagementAlgorithm")} labelIcon={t("idTokenEncryptionKeyManagementAlgorithmHelp")} controller={{ defaultValue: "", }} options={prependEmpty(cekManagementProviders!)} /> ( "attributes.id.token.encrypted.response.enc", )} label={t("idTokenEncryptionContentEncryptionAlgorithm")} labelIcon={t("idTokenEncryptionContentEncryptionAlgorithmHelp")} controller={{ defaultValue: "", }} options={prependEmpty(contentEncryptionProviders!)} /> } > ( "attributes.id.token.as.detached.signature", )} defaultValue="false" control={control} render={({ field }) => ( field.onChange(value.toString())} aria-label={t("idTokenAsDetachedSignature")} /> )} /> ( "attributes.user.info.response.signature.alg", )} label={t("userInfoSignedResponseAlgorithm")} labelIcon={t("userInfoSignedResponseAlgorithmHelp")} controller={{ defaultValue: "", }} options={prependEmpty(signatureProviders!)} /> ( "attributes.user.info.encrypted.response.alg", )} label={t("userInfoResponseEncryptionKeyManagementAlgorithm")} labelIcon={t("userInfoResponseEncryptionKeyManagementAlgorithmHelp")} controller={{ defaultValue: "", }} options={prependEmpty(cekManagementProviders!)} /> ( "attributes.user.info.encrypted.response.enc", )} label={t("userInfoResponseEncryptionContentEncryptionAlgorithm")} labelIcon={t( "userInfoResponseEncryptionContentEncryptionAlgorithmHelp", )} controller={{ defaultValue: "", }} options={prependEmpty(contentEncryptionProviders!)} /> ( "attributes.request.object.signature.alg", )} label={t("requestObjectSignatureAlgorithm")} labelIcon={t("requestObjectSignatureAlgorithmHelp")} controller={{ defaultValue: "", }} options={prependNone(clientSignatureProviders!)} /> ( "attributes.request.object.encryption.alg", )} label={t("requestObjectEncryption")} labelIcon={t("requestObjectEncryptionHelp")} controller={{ defaultValue: "", }} options={prependEmpty(cekManagementProviders!)} /> ( "attributes.request.object.encryption.enc", )} label={t("requestObjectEncoding")} labelIcon={t("requestObjectEncodingHelp")} controller={{ defaultValue: "", }} options={prependEmpty(contentEncryptionProviders!)} /> ( "attributes.request.object.required", )} label={t("requestObjectRequired")} labelIcon={t("requestObjectRequiredHelp")} controller={{ defaultValue: "not required", }} options={[ "not required", "request or request_uri", "request only", "request_uri only", ].map((p) => ({ key: p, value: t(`requestObject.${p}`), }))} /> } > ( "attributes.authorization.signed.response.alg", )} label={t("authorizationSignedResponseAlg")} labelIcon={t("authorizationSignedResponseAlgHelp")} controller={{ defaultValue: "", }} options={prependEmpty(signatureProviders!)} /> ( "attributes.authorization.encrypted.response.alg", )} label={t("authorizationEncryptedResponseAlg")} labelIcon={t("authorizationEncryptedResponseAlgHelp")} controller={{ defaultValue: "", }} options={prependEmpty(cekManagementProviders!)} /> ( "attributes.authorization.encrypted.response.enc", )} label={t("authorizationEncryptedResponseEnc")} labelIcon={t("authorizationEncryptedResponseEncHelp")} controller={{ defaultValue: "", }} options={prependEmpty(contentEncryptionProviders!)} /> ); };