UNPKG

@peculiar/fortify-webcomponents

Version:

Web-components for creating CSR or Certificate and viewing certificates list using Fortify

63 lines (59 loc) 2.35 kB
/*! * © Peculiar Ventures https://peculiarventures.com/ - BSD 3-Clause License */ import { h } from '@stencil/core/internal/client'; import { l as l10n, C as Convert_1 } from './certification_request.js'; import { R as RowTitle, a as RowValue, b as getStringByOID, T as TableRowTable } from './miscellaneous.js'; /*! * © Peculiar Ventures https://peculiarventures.com/ - MIT License */ function getPublicKeyModulus(publicKey) { if (publicKey.params && 'modulus' in publicKey.params) { let length = publicKey.params.modulus.byteLength; if (length % 2) { length -= 1; } return length * 8; } return null; } function getPublicKeyExponent(publicKey) { if (publicKey.params && 'publicExponent' in publicKey.params) { return publicKey.params.publicExponent.byteLength === 3 ? 65537 : 3; } return null; } const PublicKey = (props) => { const { publicKey } = props; if (!publicKey) { return null; } function renderKeyDetails(key) { return [ h(RowValue, { name: l10n.getString('algorithm'), value: getStringByOID(key.algorithm) }), h(RowValue, { name: l10n.getString('namedCurve'), value: getStringByOID((key.params && 'namedCurve' in key.params) ? key.params.namedCurve : undefined) }), h(RowValue, { name: l10n.getString('exponent'), value: getPublicKeyExponent(key) }), h(RowValue, { name: l10n.getString('modulus'), value: getPublicKeyModulus(key) }), h(RowValue, { name: l10n.getString('value'), value: Convert_1.ToHex(key.value), monospace: true, collapse: true }), ]; } return [ h(RowTitle, { value: l10n.getString('publicKeyInfo') }), renderKeyDetails(publicKey), (Array.isArray(publicKey.params) && publicKey.params.length && publicKey.params.map((param) => (h(TableRowTable, null, renderKeyDetails(param))))), ]; }; /*! * © Peculiar Ventures https://peculiarventures.com/ - MIT License */ const SubjectName = (props) => { const { name } = props; return [ h(RowTitle, { value: l10n.getString('subjectName') }), name.map((n) => (h(RowValue, { name: n.name || n.type, value: n.value }))), ]; }; export { PublicKey as P, SubjectName as S }; //# sourceMappingURL=subject_name.js.map