import { CertificateKeyPair, CryptoApi } from "authentik-api"; import { t } from "@lingui/macro"; import { customElement, property } from "lit-element"; import { html, TemplateResult } from "lit-html"; import { DEFAULT_CONFIG } from "../../api/Config"; import { Form } from "../../elements/forms/Form"; import { ifDefined } from "lit-html/directives/if-defined"; import "../../elements/forms/HorizontalFormElement"; import "../../elements/CodeMirror"; @customElement("ak-crypto-certificate-form") export class CertificateKeyPairForm extends Form { @property({attribute: false}) keyPair?: CertificateKeyPair; getSuccessMessage(): string { if (this.keyPair) { return t`Successfully updated certificate-key pair.`; } else { return t`Successfully created certificate-key pair.`; } } send = (data: CertificateKeyPair): Promise => { if (this.keyPair) { return new CryptoApi(DEFAULT_CONFIG).cryptoCertificatekeypairsPartialUpdate({ kpUuid: this.keyPair.pk || "", data: data }); } else { return new CryptoApi(DEFAULT_CONFIG).cryptoCertificatekeypairsCreate({ data: data }); } }; renderForm(): TemplateResult { return html`

${t`PEM-encoded Certificate data.`}

${t`Optional Private Key. If this is set, you can use this keypair for encryption.`}

`; } }