@peculiar/fortify-webcomponents
Version:
Web-components for creating CSR or Certificate and viewing certificates list using Fortify
1,512 lines (1,495 loc) • 56.6 kB
JavaScript
/*!
* © Peculiar Ventures https://peculiarventures.com/ - BSD 3-Clause License
*/
import { h, proxyCustomElement, HTMLElement, createEvent, Host } from '@stencil/core/internal/client';
import { E as EName, k as ESignatureAlgorithm, l as EHashAlgorithm, F as FortifyStatus, a as FortifyButton, N as Name, c as FortifyAPI, d as FortifyConnecting, e as FortifyAuthorization, f as FortifyNotDetected, g as FortifyNotSupported, h as FortifyChallengeNotApproved, i as FortifyProvidersEmpty, j as FortifyLayout } from './fortify-layout.js';
import { D as Download, bA as downloadFromBuffer, C as Convert_1 } from './certification_request.js';
import { g as getString, l as l10n } from './l10n.js';
import { T as Typography } from './typography.js';
/**
* @license
* Copyright (c) Peculiar Ventures, LLC.
*
* This source code is licensed under the BSD 3-Clause license found in the
* LICENSE file in the root directory of this source tree.
*/
const InputRequiredIcon = (props) => (h("svg", Object.assign({}, props, { width: "6px", height: "6px", fill: "none", xmlns: "http://www.w3.org/2000/svg" }),
h("path", { fill: "currentColor", "fill-rule": "evenodd", "clip-rule": "evenodd", d: "M.611 0A.608.608 0 000 .605a.6.6 0 00.204.451c.003.003 0 .007 0 .01l4.739 4.75c.002.002.006 0 .007.002a.604.604 0 001.038-.423L6 1.597C6 .715 5.285 0 4.403 0H.611z" })));
/**
* @license
* Copyright (c) Peculiar Ventures, LLC.
*
* This source code is licensed under the BSD 3-Clause license found in the
* LICENSE file in the root directory of this source tree.
*/
const ArrowDownIcon = (props) => (h("svg", Object.assign({}, props, { viewBox: "0 0 24 24", width: "24px", height: "24px", fill: "none", xmlns: "http://www.w3.org/2000/svg" }),
h("path", { d: "M12.39 14.512a.5.5 0 01-.78 0l-2.96-3.7A.5.5 0 019.04 10h5.92a.5.5 0 01.39.812l-2.96 3.7z", fill: "currentColor" })));
/**
* @license
* Copyright (c) Peculiar Ventures, LLC.
*
* This source code is licensed under the BSD 3-Clause license found in the
* LICENSE file in the root directory of this source tree.
*/
const CheckIcon = (props) => (h("svg", Object.assign({}, props, { viewBox: "0 0 24 24", width: "24px", height: "24px", fill: "none", xmlns: "http://www.w3.org/2000/svg" }),
h("path", { fill: "currentColor", d: "M4.338 11.656l5.98 5.667a1 1 0 001.452-.081l7.144-8.453a.51.51 0 00-.043-.716l-.38-.338a.508.508 0 00-.717.043l-6.84 7.7-5.584-4.96a.509.509 0 00-.717.042l-.337.38a.51.51 0 00.042.716z" })));
const defaultFormPolicyConfig = () => ({
subject: {
fields: {
[EName.CommonName]: {
required: true,
},
[EName.Organization]: {
required: false,
},
[EName.OrganizationUnit]: {
required: false,
},
[EName.Country]: {
required: false,
defaultValue: 'US',
},
[EName.Region]: {
required: false,
},
[EName.State]: {
required: false,
},
},
},
publicKey: {
fields: {
signatureAlgorithm: {
required: true,
defaultValue: ESignatureAlgorithm.RSA2048,
},
hashAlgorithm: {
required: true,
defaultValue: EHashAlgorithm.SHA_256,
},
},
},
options: {
fields: {
useSelfSignedCertificate: {
required: false,
},
},
},
});
/**
* @license
* Copyright (c) Peculiar Ventures, LLC.
*
* This source code is licensed under the BSD 3-Clause license found in the
* LICENSE file in the root directory of this source tree.
*/
const EnrollmentRejected = (props) => {
const { onCancel, onAccept } = props;
return (h(FortifyStatus, { title: getString('enrollment.error.title'), description: getString('If you want to try again click the button below') },
h(FortifyButton, { onClick: onCancel }, getString('actions.cancel')),
h(FortifyButton, { variant: "primary", onClick: onAccept }, getString('actions.tryAgain'))));
};
/**
* @license
* Copyright (c) Peculiar Ventures, LLC.
*
* This source code is licensed under the BSD 3-Clause license found in the
* LICENSE file in the root directory of this source tree.
*/
const EnrollmentResolved = (props) => {
const { pem, type, name, onClose, } = props;
const handleClickDownload = () => {
if (type === 'pkcs10') {
Download.csr.asPEM(pem, name);
}
else {
Download.cert.asPEM(pem, name);
}
};
return (h("div", { class: "enrollment_form" },
h("header", { class: "enrollment_form_header" },
h(Typography, { variant: "h5", color: "black" }, type === 'pkcs10' ? getString('enrollment.success.csr.title') : getString('enrollment.success.certificate.title'))),
h("div", { class: "enrollment_form_content" },
h("textarea", { class: "form_field form_field_result t-b3", readOnly: true }, pem)),
h("footer", { class: "enrollment_form_footer container_actions" },
h(FortifyButton, { onClick: onClose }, getString('actions.close')),
h(FortifyButton, { variant: "primary", onClick: handleClickDownload }, "Download PEM"))));
};
/**
* @license
* Copyright (c) Peculiar Ventures, LLC.
*
* This source code is licensed under the BSD 3-Clause license found in the
* LICENSE file in the root directory of this source tree.
*/
const FortifySelect = (props) => {
const { label, options, disabled, name, required, defaultValue, readOnly, } = props;
const renderIconRequired = () => {
if (!required) {
return null;
}
return (h(InputRequiredIcon, { class: "form_field_icon_required" }));
};
const renderIconArrowDown = () => (h(ArrowDownIcon, { class: "form_field_icon_arrow_down" }));
return (h("label", null,
h(Typography, { variant: "c2", color: "gray-10", component: "span" }, label),
h("div", { class: "form_field_container" },
h("select", { class: "form_field t-b3", name: name, disabled: disabled, required: required, tabIndex: readOnly ? -1 : undefined }, options.map((opt) => (h("option", { key: opt.value, value: opt.value, selected: defaultValue === opt.value }, opt.name)))),
renderIconRequired(),
renderIconArrowDown())));
};
/**
* @license
* Copyright (c) Peculiar Ventures, LLC.
*
* This source code is licensed under the BSD 3-Clause license found in the
* LICENSE file in the root directory of this source tree.
*/
const FortifyCheckbox = (props) => {
const { label, name, disabled, defaultChecked, required, readOnly, } = props;
return (h("label", { class: "form_checkbox_root" },
h("div", { class: "form_checkbox_container" },
h("input", { type: "checkbox", name: name, disabled: disabled, defaultChecked: defaultChecked, required: required, tabIndex: readOnly ? -1 : undefined, readOnly: readOnly, class: "form_checkbox", onClick: (event) => {
if (readOnly) {
event.preventDefault();
return false;
}
return undefined;
} }),
h(CheckIcon, { "aria-hidden": "true", class: "form_checkbox_icon_check" })),
h(Typography, { variant: "b3", color: "black", component: "span" }, label)));
};
/**
* @license
* Copyright (c) Peculiar Ventures, LLC.
*
* This source code is licensed under the BSD 3-Clause license found in the
* LICENSE file in the root directory of this source tree.
*/
var __rest$3 = (undefined && undefined.__rest) || function (s, e) {
var t = {};
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
t[p] = s[p];
if (s != null && typeof Object.getOwnPropertySymbols === "function")
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
t[p[i]] = s[p[i]];
}
return t;
};
const EnrollmentFormPublicKey = (props) => {
const { formPolicy } = props, other = __rest$3(props, ["formPolicy"]);
const renderFields = () => Object.keys(formPolicy).map((keyName) => {
const field = formPolicy[keyName];
const options = keyName === 'signatureAlgorithm' ? ESignatureAlgorithm : EHashAlgorithm;
return (h(FortifySelect, { name: keyName, label: field.label || getString(`enrollment.label.${keyName}`), options: Object.entries(options).map((option) => ({
value: option[1],
name: option[1],
})), required: field.required, defaultValue: field.defaultValue, readOnly: field.readOnly }));
});
return (h("div", Object.assign({}, other),
renderFields(),
h("div", null),
h("div", { class: "mt_2" },
h(Typography, { variant: "c2", color: "gray-10" }, getString('enrollment.title.usage')),
h("div", { class: "enrollment_form_group_fields_usage mt_4" },
h(FortifyCheckbox, { label: getString('enrollment.label.sign'), name: "sign", defaultChecked: true, readOnly: true }),
h(FortifyCheckbox, { label: getString('enrollment.label.verify'), name: "verify", defaultChecked: true, readOnly: true })))));
};
const countries = [
{
code: "AF",
name: "Afghanistan"
},
{
code: "AX",
name: "Åland Islands"
},
{
code: "AL",
name: "Albania"
},
{
code: "DZ",
name: "Algeria"
},
{
code: "AS",
name: "American Samoa"
},
{
code: "AD",
name: "AndorrA"
},
{
code: "AO",
name: "Angola"
},
{
code: "AI",
name: "Anguilla"
},
{
code: "AQ",
name: "Antarctica"
},
{
code: "AG",
name: "Antigua and Barbuda"
},
{
code: "AR",
name: "Argentina"
},
{
code: "AM",
name: "Armenia"
},
{
code: "AW",
name: "Aruba"
},
{
code: "AU",
name: "Australia"
},
{
code: "AT",
name: "Austria"
},
{
code: "AZ",
name: "Azerbaijan"
},
{
code: "BS",
name: "Bahamas"
},
{
code: "BH",
name: "Bahrain"
},
{
code: "BD",
name: "Bangladesh"
},
{
code: "BB",
name: "Barbados"
},
{
code: "BY",
name: "Belarus"
},
{
code: "BE",
name: "Belgium"
},
{
code: "BZ",
name: "Belize"
},
{
code: "BJ",
name: "Benin"
},
{
code: "BM",
name: "Bermuda"
},
{
code: "BT",
name: "Bhutan"
},
{
code: "BO",
name: "Bolivia"
},
{
code: "BA",
name: "Bosnia and Herzegovina"
},
{
code: "BW",
name: "Botswana"
},
{
code: "BV",
name: "Bouvet Island"
},
{
code: "BR",
name: "Brazil"
},
{
code: "IO",
name: "British Indian Ocean Territory"
},
{
code: "CA",
name: "Canada"
},
{
code: "BN",
name: "Brunei Darussalam"
},
{
code: "BG",
name: "Bulgaria"
},
{
code: "BF",
name: "Burkina Faso"
},
{
code: "BI",
name: "Burundi"
},
{
code: "KH",
name: "Cambodia"
},
{
code: "CM",
name: "Cameroon"
},
{
code: "CV",
name: "Cape Verde"
},
{
code: "KY",
name: "Cayman Islands"
},
{
code: "CF",
name: "Central African Republic"
},
{
code: "TD",
name: "Chad"
},
{
code: "CL",
name: "Chile"
},
{
code: "CN",
name: "China"
},
{
code: "CX",
name: "Christmas Island"
},
{
code: "CC",
name: "Cocos (Keeling) Islands"
},
{
code: "CO",
name: "Colombia"
},
{
code: "KM",
name: "Comoros"
},
{
code: "CG",
name: "Congo"
},
{
code: "CD",
name: "Congo, The Democratic Republic of the"
},
{
code: "CK",
name: "Cook Islands"
},
{
code: "CR",
name: "Costa Rica"
},
{
code: "CI",
name: "Cote D\"Ivoire"
},
{
code: "HR",
name: "Croatia"
},
{
code: "CU",
name: "Cuba"
},
{
code: "CY",
name: "Cyprus"
},
{
code: "CZ",
name: "Czech Republic"
},
{
code: "DK",
name: "Denmark"
},
{
code: "DJ",
name: "Djibouti"
},
{
code: "DM",
name: "Dominica"
},
{
code: "DO",
name: "Dominican Republic"
},
{
code: "EC",
name: "Ecuador"
},
{
code: "EG",
name: "Egypt"
},
{
code: "SV",
name: "El Salvador"
},
{
code: "GQ",
name: "Equatorial Guinea"
},
{
code: "ER",
name: "Eritrea"
},
{
code: "EE",
name: "Estonia"
},
{
code: "ET",
name: "Ethiopia"
},
{
code: "FK",
name: "Falkland Islands (Malvinas)"
},
{
code: "FO",
name: "Faroe Islands"
},
{
code: "FJ",
name: "Fiji"
},
{
code: "FI",
name: "Finland"
},
{
code: "FR",
name: "France"
},
{
code: "GF",
name: "French Guiana"
},
{
code: "PF",
name: "French Polynesia"
},
{
code: "TF",
name: "French Southern Territories"
},
{
code: "GA",
name: "Gabon"
},
{
code: "GM",
name: "Gambia"
},
{
code: "GE",
name: "Georgia"
},
{
code: "DE",
name: "Germany"
},
{
code: "GH",
name: "Ghana"
},
{
code: "GI",
name: "Gibraltar"
},
{
code: "GR",
name: "Greece"
},
{
code: "GL",
name: "Greenland"
},
{
code: "GD",
name: "Grenada"
},
{
code: "GP",
name: "Guadeloupe"
},
{
code: "GU",
name: "Guam"
},
{
code: "GT",
name: "Guatemala"
},
{
code: "GG",
name: "Guernsey"
},
{
code: "GN",
name: "Guinea"
},
{
code: "GW",
name: "Guinea-Bissau"
},
{
code: "GY",
name: "Guyana"
},
{
code: "HT",
name: "Haiti"
},
{
code: "HM",
name: "Heard Island and Mcdonald Islands"
},
{
code: "VA",
name: "Holy See (Vatican City State)"
},
{
code: "HN",
name: "Honduras"
},
{
code: "HK",
name: "Hong Kong"
},
{
code: "HU",
name: "Hungary"
},
{
code: "IS",
name: "Iceland"
},
{
code: "IN",
name: "India"
},
{
code: "ID",
name: "Indonesia"
},
{
code: "IR",
name: "Iran, Islamic Republic Of"
},
{
code: "IQ",
name: "Iraq"
},
{
code: "IE",
name: "Ireland"
},
{
code: "IM",
name: "Isle of Man"
},
{
code: "IL",
name: "Israel"
},
{
code: "IT",
name: "Italy"
},
{
code: "JM",
name: "Jamaica"
},
{
code: "JP",
name: "Japan"
},
{
code: "JE",
name: "Jersey"
},
{
code: "JO",
name: "Jordan"
},
{
code: "KZ",
name: "Kazakhstan"
},
{
code: "KE",
name: "Kenya"
},
{
code: "KI",
name: "Kiribati"
},
{
code: "KP",
name: "Korea, Democratic People\"S Republic of"
},
{
code: "KR",
name: "Korea, Republic of"
},
{
code: "KW",
name: "Kuwait"
},
{
code: "KG",
name: "Kyrgyzstan"
},
{
code: "LA",
name: "Lao People\"S Democratic Republic"
},
{
code: "LV",
name: "Latvia"
},
{
code: "LB",
name: "Lebanon"
},
{
code: "LS",
name: "Lesotho"
},
{
code: "LR",
name: "Liberia"
},
{
code: "LY",
name: "Libyan Arab Jamahiriya"
},
{
code: "LI",
name: "Liechtenstein"
},
{
code: "LT",
name: "Lithuania"
},
{
code: "LU",
name: "Luxembourg"
},
{
code: "MO",
name: "Macao"
},
{
code: "MK",
name: "Macedonia, The Former Yugoslav Republic of"
},
{
code: "MG",
name: "Madagascar"
},
{
code: "MW",
name: "Malawi"
},
{
code: "MY",
name: "Malaysia"
},
{
code: "MV",
name: "Maldives"
},
{
code: "ML",
name: "Mali"
},
{
code: "MT",
name: "Malta"
},
{
code: "MH",
name: "Marshall Islands"
},
{
code: "MQ",
name: "Martinique"
},
{
code: "MR",
name: "Mauritania"
},
{
code: "MU",
name: "Mauritius"
},
{
code: "YT",
name: "Mayotte"
},
{
code: "MX",
name: "Mexico"
},
{
code: "FM",
name: "Micronesia, Federated States of"
},
{
code: "MD",
name: "Moldova, Republic of"
},
{
code: "MC",
name: "Monaco"
},
{
code: "MN",
name: "Mongolia"
},
{
code: "MS",
name: "Montserrat"
},
{
code: "MA",
name: "Morocco"
},
{
code: "MZ",
name: "Mozambique"
},
{
code: "MM",
name: "Myanmar"
},
{
code: "NA",
name: "Namibia"
},
{
code: "NR",
name: "Nauru"
},
{
code: "NP",
name: "Nepal"
},
{
code: "NL",
name: "Netherlands"
},
{
code: "AN",
name: "Netherlands Antilles"
},
{
code: "NC",
name: "New Caledonia"
},
{
code: "NZ",
name: "New Zealand"
},
{
code: "NI",
name: "Nicaragua"
},
{
code: "NE",
name: "Niger"
},
{
code: "NG",
name: "Nigeria"
},
{
code: "NU",
name: "Niue"
},
{
code: "NF",
name: "Norfolk Island"
},
{
code: "MP",
name: "Northern Mariana Islands"
},
{
code: "NO",
name: "Norway"
},
{
code: "OM",
name: "Oman"
},
{
code: "PK",
name: "Pakistan"
},
{
code: "PW",
name: "Palau"
},
{
code: "PS",
name: "Palestinian Territory, Occupied"
},
{
code: "PA",
name: "Panama"
},
{
code: "PG",
name: "Papua New Guinea"
},
{
code: "PY",
name: "Paraguay"
},
{
code: "PE",
name: "Peru"
},
{
code: "PH",
name: "Philippines"
},
{
code: "PN",
name: "Pitcairn"
},
{
code: "PL",
name: "Poland"
},
{
code: "PT",
name: "Portugal"
},
{
code: "PR",
name: "Puerto Rico"
},
{
code: "QA",
name: "Qatar"
},
{
code: "RE",
name: "Reunion"
},
{
code: "RO",
name: "Romania"
},
{
code: "RU",
name: "Russian Federation"
},
{
code: "RW",
name: "RWANDA"
},
{
code: "SH",
name: "Saint Helena"
},
{
code: "KN",
name: "Saint Kitts and Nevis"
},
{
code: "LC",
name: "Saint Lucia"
},
{
code: "PM",
name: "Saint Pierre and Miquelon"
},
{
code: "VC",
name: "Saint Vincent and the Grenadines"
},
{
code: "WS",
name: "Samoa"
},
{
code: "SM",
name: "San Marino"
},
{
code: "ST",
name: "Sao Tome and Principe"
},
{
code: "SA",
name: "Saudi Arabia"
},
{
code: "SN",
name: "Senegal"
},
{
code: "CS",
name: "Serbia and Montenegro"
},
{
code: "SC",
name: "Seychelles"
},
{
code: "SL",
name: "Sierra Leone"
},
{
code: "SG",
name: "Singapore"
},
{
code: "SK",
name: "Slovakia"
},
{
code: "SI",
name: "Slovenia"
},
{
code: "SB",
name: "Solomon Islands"
},
{
code: "SO",
name: "Somalia"
},
{
code: "ZA",
name: "South Africa"
},
{
code: "GS",
name: "South Georgia and the South Sandwich Islands"
},
{
code: "ES",
name: "Spain"
},
{
code: "LK",
name: "Sri Lanka"
},
{
code: "SD",
name: "Sudan"
},
{
code: "SR",
name: "Suriname"
},
{
code: "SJ",
name: "Svalbard and Jan Mayen"
},
{
code: "SZ",
name: "Swaziland"
},
{
code: "SE",
name: "Sweden"
},
{
code: "CH",
name: "Switzerland"
},
{
code: "SY",
name: "Syrian Arab Republic"
},
{
code: "TW",
name: "Taiwan, Province of China"
},
{
code: "TJ",
name: "Tajikistan"
},
{
code: "TZ",
name: "Tanzania, United Republic of"
},
{
code: "TH",
name: "Thailand"
},
{
code: "TL",
name: "Timor-Leste"
},
{
code: "TG",
name: "Togo"
},
{
code: "TK",
name: "Tokelau"
},
{
code: "TO",
name: "Tonga"
},
{
code: "TT",
name: "Trinidad and Tobago"
},
{
code: "TN",
name: "Tunisia"
},
{
code: "TR",
name: "Turkey"
},
{
code: "TM",
name: "Turkmenistan"
},
{
code: "TC",
name: "Turks and Caicos Islands"
},
{
code: "TV",
name: "Tuvalu"
},
{
code: "UG",
name: "Uganda"
},
{
code: "UA",
name: "Ukraine"
},
{
code: "AE",
name: "United Arab Emirates"
},
{
code: "GB",
name: "United Kingdom"
},
{
code: "US",
name: "United States"
},
{
code: "UM",
name: "United States Minor Outlying Islands"
},
{
code: "UY",
name: "Uruguay"
},
{
code: "UZ",
name: "Uzbekistan"
},
{
code: "VU",
name: "Vanuatu"
},
{
code: "VE",
name: "Venezuela"
},
{
code: "VN",
name: "Viet Nam"
},
{
code: "VG",
name: "Virgin Islands, British"
},
{
code: "VI",
name: "Virgin Islands, U.S."
},
{
code: "WF",
name: "Wallis and Futuna"
},
{
code: "EH",
name: "Western Sahara"
},
{
code: "YE",
name: "Yemen"
},
{
code: "ZM",
name: "Zambia"
},
{
code: "ZW",
name: "Zimbabwe"
}
];
/**
* @license
* Copyright (c) Peculiar Ventures, LLC.
*
* This source code is licensed under the BSD 3-Clause license found in the
* LICENSE file in the root directory of this source tree.
*/
const FortifyInput = (props) => {
const { label, disabled, maxLength, name, placeholder, readOnly, required, defaultValue, } = props;
const renderIconRequired = () => {
if (!required) {
return null;
}
return (h(InputRequiredIcon, { class: "form_field_icon_required" }));
};
return (h("label", null,
h(Typography, { variant: "c2", color: "gray-10", component: "span" }, label),
h("div", { class: "form_field_container" },
h("input", { class: "form_field t-b3", type: "text", disabled: disabled, maxLength: maxLength, name: name, placeholder: placeholder, readOnly: readOnly, required: required, defaultValue: defaultValue }),
renderIconRequired())));
};
/**
* @license
* Copyright (c) Peculiar Ventures, LLC.
*
* This source code is licensed under the BSD 3-Clause license found in the
* LICENSE file in the root directory of this source tree.
*/
var __rest$2 = (undefined && undefined.__rest) || function (s, e) {
var t = {};
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
t[p] = s[p];
if (s != null && typeof Object.getOwnPropertySymbols === "function")
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
t[p[i]] = s[p[i]];
}
return t;
};
const EnrollmentFormSubject = (props) => {
const { formPolicy } = props, other = __rest$2(props, ["formPolicy"]);
const renderFields = () => {
if ('subjectName' in formPolicy) {
const field = formPolicy.subjectName;
return (h(FortifyInput, { name: "subjectName", label: field.label, required: field.required, defaultValue: field.defaultValue, readOnly: field.readOnly }));
}
const availableSubjectCodes = Object.values(EName);
return Object.keys(formPolicy).map((keyName) => {
const field = formPolicy[keyName];
if (!availableSubjectCodes.includes(keyName)) {
return null;
}
if (keyName === EName.Country) {
return (h(FortifySelect, { name: keyName, label: field.label || getString(`enrollment.label.${keyName}`), options: countries.map((ctr) => ({
name: ctr.name,
value: ctr.code,
})), required: field.required, defaultValue: field.defaultValue, readOnly: field.readOnly }));
}
return (h(FortifyInput, { name: keyName, label: field.label || getString(`enrollment.label.${keyName}`), required: field.required, defaultValue: field.defaultValue, readOnly: field.readOnly }));
});
};
return (h("div", Object.assign({}, other), renderFields()));
};
/**
* @license
* Copyright (c) Peculiar Ventures, LLC.
*
* This source code is licensed under the BSD 3-Clause license found in the
* LICENSE file in the root directory of this source tree.
*/
var __rest$1 = (undefined && undefined.__rest) || function (s, e) {
var t = {};
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
t[p] = s[p];
if (s != null && typeof Object.getOwnPropertySymbols === "function")
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
t[p[i]] = s[p[i]];
}
return t;
};
const EnrollmentFormOptions = (props) => {
const { formPolicy } = props, other = __rest$1(props, ["formPolicy"]);
const field = formPolicy.useSelfSignedCertificate;
return (h("div", Object.assign({}, other),
h(FortifyCheckbox, { name: "useSelfSignedCertificate", label: field.label || getString('enrollment.label.useSelfSignedCertificate'), defaultChecked: field.defaultValue, required: field.required, readOnly: field.readOnly })));
};
/**
* @license
* Copyright (c) Peculiar Ventures, LLC.
*
* This source code is licensed under the BSD 3-Clause license found in the
* LICENSE file in the root directory of this source tree.
*/
var __rest = (undefined && undefined.__rest) || function (s, e) {
var t = {};
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
t[p] = s[p];
if (s != null && typeof Object.getOwnPropertySymbols === "function")
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
t[p[i]] = s[p[i]];
}
return t;
};
const EnrollmentFormProvider = (props) => {
const { providers = [] } = props, other = __rest(props, ["providers"]);
return (h("div", Object.assign({}, other),
h(FortifySelect, { label: getString('enrollment.label.provider'), options: providers.map((prv) => ({
name: prv.name,
value: prv.id,
})), name: "providerId", required: true })));
};
/**
* @license
* Copyright (c) Peculiar Ventures, LLC.
*
* This source code is licensed under the BSD 3-Clause license found in the
* LICENSE file in the root directory of this source tree.
*/
const FORM_ID = 'enrollment-form';
const EnrollmentForm = (props) => {
const { formPolicy, providers = [], onSubmit, onCancel, } = props;
const handleSubmit = (event) => {
event.preventDefault();
if (event.target instanceof HTMLFormElement) {
const formData = new FormData(event.target);
const availableSubjectCodes = Object.values(EName);
const data = {
subjectName: '',
useSelfSignedCertificate: false,
providerId: '',
signatureAlgorithm: ESignatureAlgorithm.RSA2048,
hashAlgorithm: EHashAlgorithm.SHA_256,
};
formData.forEach((value, key) => {
if (key in data) {
data[key] = value;
}
if (key === 'useSelfSignedCertificate') {
data[key] = true;
}
if (availableSubjectCodes.includes(key) && value) {
if (!data.subjectName) {
data.subjectName = `${key}=${value}`;
}
else {
data.subjectName = data.subjectName.concat(`, ${key}=${value}`);
}
}
});
onSubmit(data);
}
};
return (h("div", { class: "enrollment_form" },
h("header", { class: "enrollment_form_header" },
h(Typography, { variant: "h5", color: "black" }, getString('enrollment.title'))),
h("form", { onSubmit: handleSubmit, class: "enrollment_form_content", id: FORM_ID },
h("div", { class: "enrollment_form_group" },
h(Typography, { variant: "s2", color: "black" }, getString('enrollment.title.provider')),
h(EnrollmentFormProvider, { class: "enrollment_form_group_fields mt_2", providers: providers })),
h("div", { class: "enrollment_form_group" },
h(Typography, { variant: "s2", color: "black" }, formPolicy.subject.title || getString('enrollment.title.subject')),
h(EnrollmentFormSubject, { class: "enrollment_form_group_fields mt_2", formPolicy: formPolicy.subject.fields })),
h("div", { class: "enrollment_form_group" },
h(Typography, { variant: "s2", color: "black" }, formPolicy.publicKey.title || getString('enrollment.title.publicKey')),
h(EnrollmentFormPublicKey, { class: "enrollment_form_group_fields mt_2", formPolicy: formPolicy.publicKey.fields })),
h("div", { class: "enrollment_form_group" },
h(Typography, { variant: "s2", color: "black" }, formPolicy.options.title || getString('enrollment.title.options')),
h(EnrollmentFormOptions, { class: "mt_6", formPolicy: formPolicy.options.fields }))),
h("footer", { class: "enrollment_form_footer container_actions" },
h(FortifyButton, { onClick: onCancel }, getString('actions.cancel')),
h(FortifyButton, { variant: "primary", type: "submit", ref: (el) => el === null || el === void 0 ? void 0 : el.setAttribute('form', FORM_ID) }, getString('actions.create')))));
};
const fortifyEnrollmentCss = "*{-webkit-box-sizing:border-box;box-sizing:border-box;margin:0;padding:0;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale;-moz-text-size-adjust:none;-ms-text-size-adjust:none;text-size-adjust:none;-webkit-text-size-adjust:none;-webkit-tap-highlight-color:transparent;font-family:var(--pv-font-family, inherit)}.t-h1{font-weight:var(--pv-text-h1-weight);font-size:var(--pv-text-h1-size);line-height:var(--pv-text-h1-height);letter-spacing:var(--pv-text-h1-spacing)}.t-h2{font-weight:var(--pv-text-h2-weight);font-size:var(--pv-text-h2-size);line-height:var(--pv-text-h2-height);letter-spacing:var(--pv-text-h2-spacing)}.t-h3{font-weight:var(--pv-text-h3-weight);font-size:var(--pv-text-h3-size);line-height:var(--pv-text-h3-height);letter-spacing:var(--pv-text-h3-spacing)}.t-h4{font-weight:var(--pv-text-h4-weight);font-size:var(--pv-text-h4-size);line-height:var(--pv-text-h4-height);letter-spacing:var(--pv-text-h4-spacing)}.t-h5{font-weight:var(--pv-text-h5-weight);font-size:var(--pv-text-h5-size);line-height:var(--pv-text-h5-height);letter-spacing:var(--pv-text-h5-spacing)}.t-s1{font-weight:var(--pv-text-s1-weight);font-size:var(--pv-text-s1-size);line-height:var(--pv-text-s1-height);letter-spacing:var(--pv-text-s1-spacing)}.t-s2{font-weight:var(--pv-text-s2-weight);font-size:var(--pv-text-s2-size);line-height:var(--pv-text-s2-height);letter-spacing:var(--pv-text-s2-spacing)}.t-b1{font-weight:var(--pv-text-b1-weight);font-size:var(--pv-text-b1-size);line-height:var(--pv-text-b1-height);letter-spacing:var(--pv-text-b1-spacing)}.t-b2{font-weight:var(--pv-text-b2-weight);font-size:var(--pv-text-b2-size);line-height:var(--pv-text-b2-height);letter-spacing:var(--pv-text-b2-spacing)}.t-b3{font-weight:var(--pv-text-b3-weight);font-size:var(--pv-text-b3-size);line-height:var(--pv-text-b3-height);letter-spacing:var(--pv-text-b3-spacing)}.t-btn1{font-weight:var(--pv-text-btn1-weight);font-size:var(--pv-text-btn1-size);line-height:var(--pv-text-btn1-height);letter-spacing:var(--pv-text-btn1-spacing)}.t-btn2{font-weight:var(--pv-text-btn2-weight);font-size:var(--pv-text-btn2-size);line-height:var(--pv-text-btn2-height);letter-spacing:var(--pv-text-btn2-spacing)}.t-c1{font-weight:var(--pv-text-c1-weight);font-size:var(--pv-text-c1-size);line-height:var(--pv-text-c1-height);letter-spacing:var(--pv-text-c1-spacing)}.t-c2{font-weight:var(--pv-text-c2-weight);font-size:var(--pv-text-c2-size);line-height:var(--pv-text-c2-height);letter-spacing:var(--pv-text-c2-spacing)}.c-primary-tint-5{--pv-color-base:var(--pv-color-primary-tint-5)}.c-primary-tint-4{--pv-color-base:var(--pv-color-primary-tint-4)}.c-primary-tint-3{--pv-color-base:var(--pv-color-primary-tint-3)}.c-primary-tint-2{--pv-color-base:var(--pv-color-primary-tint-2)}.c-primary-tint-1{--pv-color-base:var(--pv-color-primary-tint-1)}.c-primary{--pv-color-base:var(--pv-color-primary)}.c-primary-shade-1{--pv-color-base:var(--pv-color-primary-shade-1)}.c-primary-shade-2{--pv-color-base:var(--pv-color-primary-shade-2)}.c-primary-shade-3{--pv-color-base:var(--pv-color-primary-shade-3)}.c-primary-shade-4{--pv-color-base:var(--pv-color-primary-shade-4)}.c-primary-shade-5{--pv-color-base:var(--pv-color-primary-shade-5)}.c-primary-contrast{--pv-color-base:var(--pv-color-primary-contrast)}.c-secondary-tint-5{--pv-color-base:var(--pv-color-secondary-tint-5)}.c-secondary-tint-4{--pv-color-base:var(--pv-color-secondary-tint-4)}.c-secondary-tint-3{--pv-color-base:var(--pv-color-secondary-tint-3)}.c-secondary-tint-2{--pv-color-base:var(--pv-color-secondary-tint-2)}.c-secondary-tint-1{--pv-color-base:var(--pv-color-secondary-tint-1)}.c-secondary{--pv-color-base:var(--pv-color-secondary)}.c-secondary-shade-1{--pv-color-base:var(--pv-color-secondary-shade-1)}.c-secondary-shade-2{--pv-color-base:var(--pv-color-secondary-shade-2)}.c-secondary-shade-3{--pv-color-base:var(--pv-color-secondary-shade-3)}.c-secondary-shade-4{--pv-color-base:var(--pv-color-secondary-shade-4)}.c-secondary-shade-5{--pv-color-base:var(--pv-color-secondary-shade-5)}.c-secondary-contrast{--pv-color-base:var(--pv-color-secondary-contrast)}.c-wrong-tint-5{--pv-color-base:var(--pv-color-wrong-tint-5)}.c-wrong-tint-4{--pv-color-base:var(--pv-color-wrong-tint-4)}.c-wrong-tint-3{--pv-color-base:var(--pv-color-wrong-tint-3)}.c-wrong-tint-2{--pv-color-base:var(--pv-color-wrong-tint-2)}.c-wrong-tint-1{--pv-color-base:var(--pv-color-wrong-tint-1)}.c-wrong{--pv-color-base:var(--pv-color-wrong)}.c-wrong-shade-1{--pv-color-base:var(--pv-color-wrong-shade-1)}.c-wrong-shade-2{--pv-color-base:var(--pv-color-wrong-shade-2)}.c-wrong-shade-3{--pv-color-base:var(--pv-color-wrong-shade-3)}.c-wrong-shade-4{--pv-color-base:var(--pv-color-wrong-shade-4)}.c-wrong-shade-5{--pv-color-base:var(--pv-color-wrong-shade-5)}.c-wrong-contrast{--pv-color-base:var(--pv-color-wrong-contrast)}.c-attention-tint-5{--pv-color-base:var(--pv-color-attention-tint-5)}.c-attention-tint-4{--pv-color-base:var(--pv-color-attention-tint-4)}.c-attention-tint-3{--pv-color-base:var(--pv-color-attention-tint-3)}.c-attention-tint-2{--pv-color-base:var(--pv-color-attention-tint-2)}.c-attention-tint-1{--pv-color-base:var(--pv-color-attention-tint-1)}.c-attention{--pv-color-base:var(--pv-color-attention)}.c-attention-shade-1{--pv-color-base:var(--pv-color-attention-shade-1)}.c-attention-shade-2{--pv-color-base:var(--pv-color-attention-shade-2)}.c-attention-shade-3{--pv-color-base:var(--pv-color-attention-shade-3)}.c-attention-shade-4{--pv-color-base:var(--pv-color-attention-shade-4)}.c-attention-shade-5{--pv-color-base:var(--pv-color-attention-shade-5)}.c-success-tint-5{--pv-color-base:var(--pv-color-success-tint-5)}.c-success-tint-4{--pv-color-base:var(--pv-color-success-tint-4)}.c-success-tint-3{--pv-color-base:var(--pv-color-success-tint-3)}.c-success-tint-2{--pv-color-base:var(--pv-color-success-tint-2)}.c-success-tint-1{--pv-color-base:var(--pv-color-success-tint-1)}.c-success{--pv-color-base:var(--pv-color-success)}.c-success-shade-1{--pv-color-base:var(--pv-color-success-shade-1)}.c-success-shade-2{--pv-color-base:var(--pv-color-success-shade-2)}.c-success-shade-3{--pv-color-base:var(--pv-color-success-shade-3)}.c-success-shade-4{--pv-color-base:var(--pv-color-success-shade-4)}.c-success-shade-5{--pv-color-base:var(--pv-color-success-shade-5)}.c-black{--pv-color-base:var(--pv-color-black)}.c-gray-10{--pv-color-base:var(--pv-color-gray-10)}.c-gray-9{--pv-color-base:var(--pv-color-gray-9)}.c-gray-8{--pv-color-base:var(--pv-color-gray-8)}.c-gray-7{--pv-color-base:var(--pv-color-gray-7)}.c-gray-6{--pv-color-base:var(--pv-color-gray-6)}.c-gray-5{--pv-color-base:var(--pv-color-gray-5)}.c-gray-4{--pv-color-base:var(--pv-color-gray-4)}.c-gray-3{--pv-color-base:var(--pv-color-gray-3)}.c-gray-2{--pv-color-base:var(--pv-color-gray-2)}.c-gray-1{--pv-color-base:var(--pv-color-gray-1)}.c-white{--pv-color-base:var(--pv-color-white)}.c-extra-1{--pv-color-base:var(--pv-color-extra-1)}.c-extra-2{--pv-color-base:var(--pv-color-extra-2)}.typography{color:var(--pv-color-base)}.button{display:-ms-inline-flexbox;display:inline-flex;cursor:pointer;background:transparent;border:1px solid transparent;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none;white-space:nowrap;text-decoration:none;outline:none;font-family:inherit;border-radius:4px;height:var(--pv-size-base-7);min-width:var(--pv-size-base-7);padding:0 var(--pv-size-base-3);-webkit-transition:background-color 200ms ease 0s;transition:background-color 200ms ease 0s;-ms-flex-align:center;align-items:center;-ms-flex-pack:center;justify-content:center;gap:var(--pv-size-base);font-size:0;-webkit-transition:background-color 200ms ease 0s, color 200ms ease 0s, border-color 200ms ease 0s, -webkit-box-shadow 200ms ease 0s;transition:background-color 200ms ease 0s, color 200ms ease 0s, border-color 200ms ease 0s, -webkit-box-shadow 200ms ease 0s;transition:background-color 200ms ease 0s, color 200ms ease 0s, box-shadow 200ms ease 0s, border-color 200ms ease 0s;transition:background-color 200ms ease 0s, color 200ms ease 0s, box-shadow 200ms ease 0s, border-color 200ms ease 0s, -webkit-box-shadow 200ms ease 0s}.button_child_text{color:inherit}.button:disabled{pointer-events:none;-webkit-box-shadow:none;box-shadow:none}.button_default{color:var(--pv-color-secondary)}.button_default:hover{background-color:var(--pv-color-secondary-tint-5)}.button_default:focus-visible{background-color:var(--pv-color-secondary-tint-4)}.button_default:active{background-color:var(--pv-color-secondary-tint-3)}.button_default:disabled{color:var(--pv-color-gray-7)}.button_secondary{border-color:var(--pv-color-gray-8);color:var(--pv-color-black)}.button_secondary:hover{background-color:var(--pv-color-gray-3)}.button_secondary:focus-visible{background-color:var(--pv-color-gray-4)}.button_secondary:active{background-color:var(--pv-color-gray-5)}.button_secondary:disabled{color:var(--pv-color-gray-7);border-color:var(--pv-color-gray-4)}.button_primary{background-color:var(--pv-color-primary);color:var(--pv-color-primary-contrast);-webkit-box-shadow:var(--pv-shadow-light-low);box-shadow:var(--pv-shadow-light-low)}.button_primary:hover{background-color:var(--pv-color-primary-tint-1)}.button_primary:focus-visible{background-color:var(--pv-color-primary-tint-2)}.button_primary:active{background-color:var(--pv-color-primary-tint-2);-webkit-box-shadow:var(--pv-shadow-light-medium);box-shadow:var(--pv-shadow-light-medium)}.button_primary:disabled{color:var(--pv-color-gray-8);background-color:var(--pv-color-gray-4)}.button_text{color:var(--pv-color-base);text-decoration:none;background:transparent;display:-ms-inline-flexbox;display:inline-flex;border:none;cursor:pointer;-webkit-transition:opacity 200ms ease 0s;transition:opacity 200ms ease 0s}.button_text:hover{opacity:0.7}.layout{height:100%;display:-ms-flexbox;display:flex;-ms-flex-direction:column;flex-direction:column;background-color:var(--pv-color-white);border-radius:3px;overflow:hidden}.layout_main{-ms-flex:1 1 auto;flex:1 1 auto;overflow:auto;position:relative}.layout_footer{-ms-flex:0 0 auto;flex:0 0 auto;display:-ms-flexbox;display:flex;-ms-flex-pack:justify;justify-content:space-between;height:var(--pv-size-base-10);-ms-flex-align:center;align-items:center;padding:0px var(--pv-size-base-3);border-top:1px solid var(--pv-color-gray-5);gap:var(--pv-size-base-2);color:var(--pv-color-footer-text);background-color:var(--pv-color-footer)}.layout_footer_text{color:inherit}.mt_2{margin-top:var(--pv-size-base-2)}.mt_4{margin-top:var(--pv-size-base-4)}.mt_6{margin-top:var(--pv-size-base-6)}.container_status{height:100%;text-align:center;padding:var(--pv-size-base-12)}.container_status_logo{display:block;margin:0 auto var(--pv-size-base-6)}.container_status_illustration{margin-top:var(--pv-size-base-12);margin-bottom:var(--pv-size-base-10)}.container_status_actions{display:-ms-flexbox;display:flex;gap:var(--pv-size-base-2);-ms-flex-pack:center;justify-content:center}.container_status_authorization_number{height:var(--pv-size-base-8);width:var(--pv-size-base-6);border-radius:4px;border:1px solid var(--pv-color-gray-5);text-align:center;line-height:var(--pv-size-base-8)}.container_actions{display:-ms-flexbox;display:flex;gap:var(--pv-size-base-2)}[hidden]{display:none}:host{display:block;min-height:550px;height:550px}.enrollment_form{height:100%;display:-ms-flexbox;display:flex;-ms-flex-direction:column;flex-direction:column;overflow:hidden}.enrollment_form_header{padding:var(--pv-size-base-6) var(--pv-size-base-6) var(--pv-size-base-4)}.enrollment_form_content{-ms-flex:1 1 auto;flex:1 1 auto;overflow:auto;padding:0 var(--pv-size-base-6)}.enrollment_form_footer{padding:var(--pv-size-base-6);-ms-flex-pack:end;justify-content:flex-end}.enrollment_form_group{padding:var(--pv-size-base-6) 0}.enrollment_form_group:not(:first-child){border-top:1px solid var(--pv-color-gray-4)}.enrollment_form_group_fields{display:grid;grid-column-gap:var(--pv-size-base-2);grid-row-gap:var(--pv-size-base-2);grid-template-columns:repeat(3, minmax(100px, 1fr))}.enrollment_form_group_fields_usage{display:-ms-flexbox;display:flex;gap:var(--pv-size-base-4)}form.enrollment_form_content{border-top:1px solid var(--pv-color-gray-5);border-bottom:1px solid var(--pv-color-gray-5)}.form_field{width:100%;height:var(--pv-size-base-7);border-radius:4px;padding:0 var(--pv-size-base-2);color:var(--pv-color-black);outline:none;background-color:var(--pv-color-gray-1);border:1px solid var(--pv-color-gray-8);-webkit-appearance:none;-moz-appearance:none;appearance:none;-webkit-transition:background-color 200ms ease 0s, color 200ms ease 0s, border-color 200ms ease 0s;transition:background-color 200ms ease 0s, color 200ms ease 0s, border-color 200ms ease 0s}.form_field::-webkit-input-placeholder{color:var(--pv-color-gray-9)}.form_field::-moz-placeholder{color:var(--pv-color-gray-9)}.form_field:-ms-input-placeholder{color:var(--pv-color-gray-9)}.form_field::-ms-input-placeholder{color:var(--pv-color-gray-9)}.form_field::placeholder{color:var(--pv-color-gray-9)}.form_field:hover{background-color:var(--pv-color-gray-3);border-color:var(--pv-color-gray-7)}.form_field:focus-visible{background-color:var(--pv-color-secondary-tint-5);border-color:var(--pv-color-secondary-tint-3)}.form_field:disabled{background-color:var(--pv-color-gray-1);border-color:var(--pv-color-gray-5);color:var(--pv-color-gray-7)}.form_field_container{position:relative;margin-top:3px}.form_field_icon_required{position:absolute;top:2px;right:2px;color:var(--pv-color-wrong)}.form_field_icon_arrow_down{position:absolute;right:0px;top:calc(50% - 12px);pointer-events:none;margin:0px var(--pv-size-base);color:var(--pv-color-gray-10)}.form_field_result{height:calc(100% - var(--pv-size-base));resize:none;margin:0;overflow:auto;padding:var(--pv-size-base-2)}select.form_field{padding-right:var(--pv-size-base-6)}.form_checkbox{width:100%;height:100%;margin:0px;padding:0px;outline:0px;border-radius:2px;-webkit-appearance:none;-moz-appearance:none;appearance:none;color:var(--pv-color-gray-9);border:2px solid currentcolor;background-color:transparent;cursor:pointer}.form_checkbox:checked{color:var(--pv-color-primary-shade-1);background-color:var(--pv-color-primary)}.form_checkbox:checked+[aria-hidden]{opacity:1}.form_checkbox_container{position:relative;width:var(--pv-size-base-4);height:var(--pv-size-base-4)}.form_checkbox_icon_check{display:block;position:absolute;top:0px;left:0px;width:100%;height:100%;opacity:0;color:var(--pv-color-white);pointer-events:none}.form_checkbox_root{display:-ms-flexbox;display:flex;-ms-flex-align:center;align-items:center;gap:var(--pv-size-base-2);text-transform:capitalize}";
const PeculiarFortifyEnrollmentStyle0 = fortifyEnrollmentCss;
/**
* @license
* Copyright (c) Peculiar Ventures, LLC.
*
* This source code is licensed under the BSD 3-Clause license found in the
* LICENSE file in the root directory of this source tree.
*/
var __classPrivateFieldGet = (undefined && undefined.__classPrivateFieldGet) || function (receiver, state, kind, f) {
if (kind === "a" && !f)
throw new TypeError("Private accessor was defined without a getter");
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver))
throw new TypeError("Cannot read private member from an object whose class did not declare it");
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
};
var __classPrivateFieldSet = (undefined && undefined.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
if (kind === "m")
throw new TypeError("Private method is not writable");
if (kind === "a" && !f)
throw new TypeError("Private accessor was defined without a setter");
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver))
throw new TypeError("Cannot write private member to an object whose class did not declare it");
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
};
var _FortifyEnrollment_fortify;
const FortifyEnrollment = /*@__PURE__*/ proxyCustomElement(class FortifyEnrollment extends HTMLElement {
constructor() {
super();
this.__registerHost();
this.__attachShadow();
this.creationCancel = createEvent(this, "creationCancel", 7);
this.creationClose = createEvent(this, "creationClose", 7);
this.creationSuccess = createEvent(this, "creationSuccess", 7);
this.creationFail = createEvent(this, "creationFail", 7);
_FortifyEnrollment_fortify.set(this, void 0);
this.debugEvents = [];
this.handleDocumentKeydown = (event) => {
/**
* Reset Fortify filters manually using `Shift+R` shortcut.
*/
if (event.shiftKey && event.code === 'KeyR') {
__classPrivateFieldGet(this, _FortifyEnrollment_fortify, "f").options.filters = {};
this.tryGetData();
}
/**
* Download Fortify debug events like a json file.
*/
if (event.shiftKey && event.code === 'KeyD') {
downloadFromBuffer(Convert_1.FromString(JSON.stringify(this.debugEvents, undefined, 2)), `debug-fortify-wc.${Date.now()}`, 'json', 'text/json');
}
};
this.handleClickCancel = () => {
this.creationCancel.emit();
};
this.handleClickEnrollRerun = () => {
this.deleteFetching('enroll');
this.enrollResult = undefined;
this.tryGetData();
};
this.handleClickClose = () => {
this.creationClose.emit();
};
this.handleClickTryAgain = async () => {
const login = await this.tryLogin();
if (!login) {
return;
}
await this.tryGetData();
};
this.handleSubmit = async (data) => {
this.setFetching('enroll', 'pending');
try {
const name = new Name(data.subjectName).toJSON();
let commonName = '';
let result;
name.forEach((n) => {
if (!commonName && n[EName.CommonName] && n[EName.CommonName].length) {
// eslint-disable-next-line prefer-destructuring
commonName = n[EName.CommonName][0];
}
});
if (data.useSelfSignedCertificate) {
result = await __classPrivateFieldGet(this, _FortifyEnrollment_fortify, "f").createX509(data.providerId, data);
}
else {
result = await __classPrivateFieldGet(this, _FortifyEnrollment_fortify, "f").createPKCS10(data.providerId, data);
}
this.enrollResult = {
pem: result.pem,
name: commonName,
type: data.useSelfSignedCertificate ? 'x509' : 'pkcs10',
};
this.setFetching('enroll', 'resolved');
this.creationSuccess.emit({
providerId: data.providerId,
raw: result.der,
privateKey: result.privateKey,
publicKey: result.publicKey,
socketProvider: __classPrivateFieldGet(this, _FortifyEnrollment_fortify, "f").server,
});
}
catch (error) {
this.setFetching('enroll', 'rejected');
this.creationFail.emit(error);
}
};
this.language = undefined;
this.downloadAppLink = 'https://fortifyapp.com';
this.helpPageLink = 'https://fortifyapp.com/help';
this.hideFooter = false;
this.filters = {};
this.formPolicy = undefined;
this.providers = [];
this.challenge = undefined;
this.isFetching = {
connectionDetect: 'pending',
};
this.enrollResult = undefined;
}
componentWillLoad() {
l10n.setLocale(this.language);
this.formPolicy = this.formPolicy || defaultFormPolicyConfig();
}
componentDidLoad() {
__classPrivateFieldSet(this, _FortifyEnrollment_fortify, new FortifyAPI({
onDebug: (event) => {
this.debugEvents.push(event);
},
onClose: this.handleCloseConnection.bind(this),
onProvidersAdded: this.tryGetData.bind(this),
onProvidersRemoved: this.tryGetData.bind(this),
filters: this.filters,
}), "f");
this.start();
document.addEventListener('keydown', this.handleDocumentKeydown);
}
disconnectedCallback() {
__classPrivateFieldGet(this, _FortifyEnrollment_fortify, "f").finish();
document.removeEventListener('keydown', this.handleDocumentKeydown);
}
handleCloseConnection() {
this.providers = [];
this.setFetching('connectionDetect', 'rejected');
}
async start() {
this.setFetching('connectionDetect', 'pending');
if (!__classPrivateFieldGet(this, _FortifyEnrollment_fortify, "f").