import { t } from "@lingui/macro"; import { html, TemplateResult } from "lit"; import { customElement } from "lit/decorators"; import { ifDefined } from "lit/directives/if-defined"; import { CertificateKeyPair, CertificateKeyPairRequest, CryptoApi } from "@goauthentik/api"; import { DEFAULT_CONFIG } from "../../api/Config"; import "../../elements/CodeMirror"; import "../../elements/forms/HorizontalFormElement"; import { ModelForm } from "../../elements/forms/ModelForm"; @customElement("ak-crypto-certificate-form") export class CertificateKeyPairForm extends ModelForm { loadInstance(pk: string): Promise { return new CryptoApi(DEFAULT_CONFIG).cryptoCertificatekeypairsRetrieve({ kpUuid: pk, }); } getSuccessMessage(): string { if (this.instance) { return t`Successfully updated certificate-key pair.`; } else { return t`Successfully created certificate-key pair.`; } } send = (data: CertificateKeyPair): Promise => { if (this.instance) { return new CryptoApi(DEFAULT_CONFIG).cryptoCertificatekeypairsPartialUpdate({ kpUuid: this.instance.pk || "", patchedCertificateKeyPairRequest: data, }); } else { return new CryptoApi(DEFAULT_CONFIG).cryptoCertificatekeypairsCreate({ certificateKeyPairRequest: data as unknown as CertificateKeyPairRequest, }); } }; renderForm(): TemplateResult { return html` ${t`PEM-encoded Certificate data.`} ${t`Optional Private Key. If this is set, you can use this keypair for encryption.`} `; } }
${t`PEM-encoded Certificate data.`}
${t`Optional Private Key. If this is set, you can use this keypair for encryption.`}