@peculiar/fortify-webcomponents
Version:
Web-components for creating CSR or Certificate and viewing certificates list using Fortify
210 lines (195 loc) • 9.91 kB
JavaScript
/*!
* © Peculiar Ventures https://peculiarventures.com/ - BSD 3-Clause License
*/
import { A as AsnData, aV as Attribute$1, e as AsnParser, C as Convert_1, aW as id_DomainNameBeneficiary, aX as DomainNameBeneficiary, aY as id_DomainNameLegalRepresentative, aZ as DomainNameLegalRepresentative, a_ as id_DomainNameOwner, a$ as DomainNameOwner, b0 as id_DomainNameTechnicalOperator, b1 as DomainNameTechnicalOperator, b2 as id_TypeRelationship, b3 as TypeRelationship, b4 as id_ActivityDescription, b5 as ActivityDescription, b6 as id_WebGDPR, b7 as WebGDPR, b8 as id_InsuranceValue, b9 as InsuranceValue, ba as id_ValuationRanking, bb as ValuationRanking, bc as id_pkcs9_at_challengePassword, bd as ChallengePassword, be as id_pkcs9_at_unstructuredName, bf as UnstructuredName, bg as id_pkcs9_at_extensionRequest, bh as ExtensionRequest, O as OIDs, l as l10n, aD as Name } from './certification_request.js';
import { h } from '@stencil/core/internal/client';
import { a as RowValue, b as getStringByOID, j as camelCaseToWords, T as TableRowTable, G as GeneralNamePart, R as RowTitle } from './miscellaneous.js';
/*!
* © Peculiar Ventures https://peculiarventures.com/ - MIT License
*/
const attributesParsers = {
[id_DomainNameBeneficiary]: DomainNameBeneficiary,
[id_DomainNameLegalRepresentative]: DomainNameLegalRepresentative,
[id_DomainNameOwner]: DomainNameOwner,
[id_DomainNameTechnicalOperator]: DomainNameTechnicalOperator,
[id_TypeRelationship]: TypeRelationship,
[id_ActivityDescription]: ActivityDescription,
[id_WebGDPR]: WebGDPR,
[id_InsuranceValue]: InsuranceValue,
[id_ValuationRanking]: ValuationRanking,
[id_pkcs9_at_challengePassword]: ChallengePassword,
[id_pkcs9_at_unstructuredName]: UnstructuredName,
[id_pkcs9_at_extensionRequest]: ExtensionRequest,
};
class Attribute extends AsnData {
getAsnExtnValue() {
return this.asn.values[0];
}
constructor(raw) {
super(raw, Attribute$1);
const asnExtnValue = this.getAsnExtnValue();
try {
const target = attributesParsers[this.asn.type];
if (target) {
this.value = AsnParser.parse(asnExtnValue, target);
}
else {
console.warn(`Didn't detect parser for "${this.asn.type}" attribute.`);
this.value = Convert_1.ToHex(asnExtnValue);
}
}
catch (error) {
console.error(`Error parse "${this.asn.type}" attribute:`, error.message);
this.value = Convert_1.ToHex(asnExtnValue);
}
}
}
/*!
* © Peculiar Ventures https://peculiarventures.com/ - MIT License
*/
const BasicAttribute = (props, children) => {
const { attribute } = props;
return ([
h(RowValue, { name: "Name", value: getStringByOID(attribute.asn.type) }),
children,
h("tr", null, h("td", { colSpan: 2, class: "divider" }, h("span", null))),
]);
};
/*!
* © Peculiar Ventures https://peculiarventures.com/ - MIT License
*/
const NamePart = (props) => {
const { name } = props;
if (!name) {
return null;
}
return name.map((relativeDistinguishedName) => (relativeDistinguishedName.map((attributeTypeAndValue) => (h(RowValue, { name: OIDs[attributeTypeAndValue.type] || attributeTypeAndValue.type, value: attributeTypeAndValue.value.toString() })))));
};
/*!
* © Peculiar Ventures https://peculiarventures.com/ - MIT License
*/
const NameAttribute = (props) => {
const { attribute } = props;
return (h(BasicAttribute, { attribute: attribute }, h(NamePart, { name: attribute.value })));
};
/*!
* © Peculiar Ventures https://peculiarventures.com/ - MIT License
*/
const ActivityDescriptionAttribute = (props) => {
const { attribute } = props;
return (h(BasicAttribute, { attribute: attribute }, h(RowValue, { name: camelCaseToWords('codeAuthority'), value: "" }), h(TableRowTable, null, h(GeneralNamePart, { generalName: attribute.value.codeAuthority, getDNSNameLink: () => '', getIPAddressLink: () => '' })), h(RowValue, { name: camelCaseToWords('codeId'), value: "" }), h(TableRowTable, null, h(GeneralNamePart, { generalName: attribute.value.codeId, getDNSNameLink: () => '', getIPAddressLink: () => '' })), h(RowValue, { name: camelCaseToWords('shortName'), value: attribute.value.shortName }), h(RowValue, { name: camelCaseToWords('shortDescription'), value: attribute.value.shortDescription })));
};
/*!
* © Peculiar Ventures https://peculiarventures.com/ - MIT License
*/
const WebGdprAttribute = (props) => {
const { attribute } = props;
return (h(BasicAttribute, { attribute: attribute }, h(RowValue, { name: camelCaseToWords('assessmentAuthority'), value: "" }), h(TableRowTable, null, h(GeneralNamePart, { generalName: attribute.value.assessmentAuthority, getDNSNameLink: () => '', getIPAddressLink: () => '' })), h(RowValue, { name: camelCaseToWords('assessmentLocation'), value: "" }), h(TableRowTable, null, h(GeneralNamePart, { generalName: attribute.value.assessmentLocation, getDNSNameLink: () => '', getIPAddressLink: () => '' })), h(RowValue, { name: camelCaseToWords('assessmentRef'), value: "" }), h(TableRowTable, null, h(GeneralNamePart, { generalName: attribute.value.assessmentRef, getDNSNameLink: () => '', getIPAddressLink: () => '' })), h(RowValue, { name: camelCaseToWords('dataStorageTerritory'), value: attribute.value.dataStorageTerritory }), h(RowValue, { name: camelCaseToWords('description'), value: attribute.value.description })));
};
/*!
* © Peculiar Ventures https://peculiarventures.com/ - MIT License
*/
const InsuranceValueAttribute = (props) => {
const { attribute } = props;
const value = `${attribute.value.base} * 10^${attribute.value.degree} ${attribute.value.location}`;
return (h(BasicAttribute, { attribute: attribute }, h(RowValue, { name: "Value", value: value })));
};
/*!
* © Peculiar Ventures https://peculiarventures.com/ - MIT License
*/
const TypeRelationshipAttribute = (props) => {
const { attribute } = props;
return (h(BasicAttribute, { attribute: attribute }, Object.keys(attribute.value).map((keyName) => (h(RowValue, { name: keyName, value: attribute.value[keyName].toNumber() ? l10n.getString('yes') : l10n.getString('no') })))));
};
/*!
* © Peculiar Ventures https://peculiarventures.com/ - MIT License
*/
const getValueRank = (value) => {
let ratio = 1;
if (value / 100 > 1) {
ratio = 100;
}
else if (value / 10 > 1) {
ratio = 10;
}
return `${value}/${5 * ratio}`;
};
const ValuationRankingAttribute = (props) => {
const { attribute } = props;
const values = Object.keys(attribute.value).map((keyName) => ([
getValueRank(attribute.value[keyName]),
h("br", null),
]));
return (h(BasicAttribute, { attribute: attribute }, h(RowValue, { name: "Value", value: values })));
};
/*!
* © Peculiar Ventures https://peculiarventures.com/ - MIT License
*/
const AsStringAttribute = (props) => {
const { attribute } = props;
return (h(BasicAttribute, { attribute: attribute }, h(RowValue, { name: "Value", value: attribute.value, monospace: true })));
};
/*!
* © Peculiar Ventures https://peculiarventures.com/ - MIT License
*/
const UnstructuredNameAttribute = (props) => {
const { attribute } = props;
return (h(BasicAttribute, { attribute: attribute }, h(RowValue, { name: "Value", value: attribute.value.utf8String })));
};
/*!
* © Peculiar Ventures https://peculiarventures.com/ - MIT License
*/
const ChallengePasswordAttribute = (props) => {
const { attribute } = props;
return (h(BasicAttribute, { attribute: attribute }, h(RowValue, { name: "Value", value: attribute.value.toString() })));
};
/*!
* © Peculiar Ventures https://peculiarventures.com/ - MIT License
*/
const Attributes = (props) => {
const { attributes } = props;
if (!attributes || !attributes.length) {
return null;
}
return ([
h(RowTitle, { value: "Attributes" }),
attributes.map((attribute) => {
try {
if (attribute.value instanceof Name) {
return (h(NameAttribute, { attribute: attribute }));
}
if (attribute.value instanceof ActivityDescription) {
return (h(ActivityDescriptionAttribute, { attribute: attribute }));
}
if (attribute.value instanceof WebGDPR) {
return (h(WebGdprAttribute, { attribute: attribute }));
}
if (attribute.value instanceof InsuranceValue) {
return (h(InsuranceValueAttribute, { attribute: attribute }));
}
if (attribute.value instanceof TypeRelationship) {
return (h(TypeRelationshipAttribute, { attribute: attribute }));
}
if (attribute.value instanceof ValuationRanking) {
return (h(ValuationRankingAttribute, { attribute: attribute }));
}
if (attribute.value instanceof UnstructuredName) {
return (h(UnstructuredNameAttribute, { attribute: attribute }));
}
if (attribute.value instanceof ChallengePassword) {
return (h(ChallengePasswordAttribute, { attribute: attribute }));
}
if (typeof attribute.value === 'string') {
return (h(AsStringAttribute, { attribute: attribute }));
}
return (h(BasicAttribute, { attribute: attribute }));
}
catch (error) {
console.error('Error render attribute:', attribute.asn.type);
return null;
}
}),
]);
};
export { Attribute as A, Attributes as a };
//# sourceMappingURL=index2.js.map