@peculiar/fortify-webcomponents
Version:
Web-components for creating CSR or Certificate and viewing certificates list using Fortify
45 lines • 12.6 kB
JavaScript
var __extends=this&&this.__extends||function(){var t=function(e,i){t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var i in e)if(Object.prototype.hasOwnProperty.call(e,i))t[i]=e[i]};return t(e,i)};return function(e,i){if(typeof i!=="function"&&i!==null)throw new TypeError("Class extends value "+String(i)+" is not a constructor or null");t(e,i);function r(){this.constructor=e}e.prototype=i===null?Object.create(i):(r.prototype=i.prototype,new r)}}();var __awaiter=this&&this.__awaiter||function(t,e,i,r){function n(t){return t instanceof i?t:new i((function(e){e(t)}))}return new(i||(i=Promise))((function(i,a){function s(t){try{u(r.next(t))}catch(t){a(t)}}function o(t){try{u(r["throw"](t))}catch(t){a(t)}}function u(t){t.done?i(t.value):n(t.value).then(s,o)}u((r=r.apply(t,e||[])).next())}))};var __generator=this&&this.__generator||function(t,e){var i={label:0,sent:function(){if(a[0]&1)throw a[1];return a[1]},trys:[],ops:[]},r,n,a,s=Object.create((typeof Iterator==="function"?Iterator:Object).prototype);return s.next=o(0),s["throw"]=o(1),s["return"]=o(2),typeof Symbol==="function"&&(s[Symbol.iterator]=function(){return this}),s;function o(t){return function(e){return u([t,e])}}function u(o){if(r)throw new TypeError("Generator is already executing.");while(s&&(s=0,o[0]&&(i=0)),i)try{if(r=1,n&&(a=o[0]&2?n["return"]:o[0]?n["throw"]||((a=n["return"])&&a.call(n),0):n.next)&&!(a=a.call(n,o[1])).done)return a;if(n=0,a)o=[o[0]&2,a.value];switch(o[0]){case 0:case 1:a=o;break;case 4:i.label++;return{value:o[1],done:false};case 5:i.label++;n=o[1];o=[0];continue;case 7:o=i.ops.pop();i.trys.pop();continue;default:if(!(a=i.trys,a=a.length>0&&a[a.length-1])&&(o[0]===6||o[0]===2)){i=0;continue}if(o[0]===3&&(!a||o[1]>a[0]&&o[1]<a[3])){i.label=o[1];break}if(o[0]===6&&i.label<a[1]){i.label=a[1];a=o;break}if(a&&i.label<a[2]){i.label=a[2];i.ops.push(o);break}if(a[2])i.ops.pop();i.trys.pop();continue}o=e.call(t,i)}catch(t){o=[6,t];n=0}finally{r=a=0}if(o[0]&5)throw o[1];return{value:o[0]?o[1]:void 0,done:true}}};var _b;
/*!
* © Peculiar Ventures https://peculiarventures.com/ - BSD 3-Clause License
*/import{A as AsnData,q as Attribute$1,r as AsnParser,s as PrivateKeyPossessionStatement,t as ExtensionRequest,U as UnstructuredName,u as ChallengePassword,V as ValuationRanking,I as InsuranceValue,W as WebGDPR,v as ActivityDescription,T as TypeRelationship,w as DomainNameTechnicalOperator,x as DomainNameOwner,y as DomainNameLegalRepresentative,z as DomainNameBeneficiary,b as buildExports,B as id_at_statementOfPossession,F as id_pkcs9_at_extensionRequest,G as id_pkcs9_at_unstructuredName,H as id_pkcs9_at_challengePassword,J as id_ValuationRanking,K as id_InsuranceValue,L as id_WebGDPR,M as id_ActivityDescription,Q as id_TypeRelationship,X as id_DomainNameTechnicalOperator,Y as id_DomainNameOwner,Z as id_DomainNameLegalRepresentative,_ as id_DomainNameBeneficiary,$ as AttributeCertificate,P as PemConverter,d as dateDiff,a as AsnConvert,D as Download,a0 as CertificationRequest,N as Name,i as id_ecPublicKey,E as ECParameters,c as id_rsaEncryption,R as RSAPublicKey,a1 as CertificateList}from"./ssh_certificate-CDwMJyak.js";import{c as certificateRawToBuffer,E as Extension,g as getCertificateThumbprint}from"./utils-Bx6Iov6q.js";
/*!
* © Peculiar Ventures https://peculiarventures.com/ - MIT License
*/
/**
* @license
* Copyright (c) Peculiar Ventures, LLC.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/var attributesParsers=(_b={},_b[id_DomainNameBeneficiary]=DomainNameBeneficiary,_b[id_DomainNameLegalRepresentative]=DomainNameLegalRepresentative,_b[id_DomainNameOwner]=DomainNameOwner,_b[id_DomainNameTechnicalOperator]=DomainNameTechnicalOperator,_b[id_TypeRelationship]=TypeRelationship,_b[id_ActivityDescription]=ActivityDescription,_b[id_WebGDPR]=WebGDPR,_b[id_InsuranceValue]=InsuranceValue,_b[id_ValuationRanking]=ValuationRanking,_b[id_pkcs9_at_challengePassword]=ChallengePassword,_b[id_pkcs9_at_unstructuredName]=UnstructuredName,_b[id_pkcs9_at_extensionRequest]=ExtensionRequest,_b[id_at_statementOfPossession]=PrivateKeyPossessionStatement,_b);var Attribute=function(t){__extends(e,t);function e(e){var i=t.call(this,e,Attribute$1)||this;var r=i.getAsnExtnValue();try{var n=attributesParsers[i.asn.type];if(n){i.value=AsnParser.parse(r,n)}else{console.warn("Didn't detect parser for \"".concat(i.asn.type,'" attribute.'));i.value=buildExports.Convert.ToHex(r)}}catch(t){console.error('Error parse "'.concat(i.asn.type,'" attribute:'),t.message);i.value=buildExports.Convert.ToHex(r)}return i}e.prototype.getAsnExtnValue=function(){return this.asn.values[0]};return e}(AsnData);
/*!
* © Peculiar Ventures https://peculiarventures.com/ - MIT License
*/
/**
* @license
* Copyright (c) Peculiar Ventures, LLC.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/var X509AttributeCertificate=function(t){__extends(e,t);function e(e){var i;var r=t.call(this,certificateRawToBuffer(e),AttributeCertificate)||this;r.thumbprints={};r.type="X.509 Attribute Certificate";r.tag=PemConverter.AttributeCertificateTag;var n=r.asn.acinfo;r.serialNumber=buildExports.Convert.ToHex(n.serialNumber);r.version=n.version;var a=n.attrCertValidityPeriod.notBeforeTime;if(!a){throw new Error("Cannot get 'notBefore' value")}r.notBefore=a;var s=n.attrCertValidityPeriod.notAfterTime;if(!s){throw new Error("Cannot get 'notAfter' value")}r.notAfter=s;r.validity=dateDiff(r.notBefore,r.notAfter);r.issuer=n.issuer.v1Form||((i=n.issuer.v2Form)===null||i===void 0?void 0:i.issuerName);r.holder=n.holder;return r}Object.defineProperty(e.prototype,"signature",{get:function(){var t=this.asn,e=t.signatureValue,i=t.signatureAlgorithm;return{value:e,algorithm:i.algorithm}},enumerable:false,configurable:true});e.prototype.parseExtensions=function(){var t=this.asn.acinfo;if(t.extensions){this.extensions=t.extensions.map((function(t){return new Extension(AsnConvert.serialize(t))}))}};e.prototype.parseAttributes=function(){var t=this.asn.acinfo;if(t.attributes){this.attributes=t.attributes.map((function(t){return new Attribute(AsnConvert.serialize(t))}))}};e.prototype.getThumbprint=function(){return __awaiter(this,arguments,void 0,(function(t){var e,i;if(t===void 0){t="SHA-1"}return __generator(this,(function(r){switch(r.label){case 0:r.trys.push([0,2,,3]);return[4,getCertificateThumbprint(t,this.raw)];case 1:e=r.sent();if(e){this.thumbprints[t]=buildExports.Convert.ToHex(e)}return[3,3];case 2:i=r.sent();console.error("Error thumbprint get:",i);return[3,3];case 3:return[2]}}))}))};Object.defineProperty(e.prototype,"commonName",{get:function(){return"attribute-certificate-".concat(this.thumbprints["SHA-1"])},enumerable:false,configurable:true});e.prototype.toString=function(t){if(t===void 0){t="pem"}switch(t){case"pem":return PemConverter.encode(this.raw,this.tag);case"base64url":return buildExports.Convert.ToBase64Url(this.raw);default:return buildExports.Convert.ToBase64(this.raw)}};e.prototype.downloadAsPEM=function(t){Download.attrCert.asPEM(this.toString("pem"),t||this.commonName)};e.prototype.downloadAsDER=function(t){Download.attrCert.asDER(this.raw,t||this.commonName)};return e}(AsnData);
/*!
* © Peculiar Ventures https://peculiarventures.com/ - MIT License
*/
/**
* @license
* Copyright (c) Peculiar Ventures, LLC.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/var Pkcs10CertificateRequest=function(t){__extends(e,t);function e(e){var i=t.call(this,certificateRawToBuffer(e),CertificationRequest)||this;i.thumbprints={};i.type="PKCS#10 Certificate Request";i.tag=PemConverter.CertificateRequestTag;var r=i.asn.certificationRequestInfo;i.subject=new Name(r.subject).toJSON();i.version=r.version;return i}Object.defineProperty(e.prototype,"publicKey",{get:function(){var t=this.asn.certificationRequestInfo.subjectPKInfo,e=t.subjectPublicKey,i=t.algorithm;var r;if(i.algorithm===id_ecPublicKey&&i.parameters){r=AsnConvert.parse(i.parameters,ECParameters)}if(i.algorithm===id_rsaEncryption){r=AsnConvert.parse(e,RSAPublicKey)}var n=AsnConvert.serialize(this.asn.certificationRequestInfo.subjectPKInfo);return{params:r,value:n,algorithm:i.algorithm}},enumerable:false,configurable:true});Object.defineProperty(e.prototype,"signature",{get:function(){var t=this.asn,e=t.signature,i=t.signatureAlgorithm;return{value:e,algorithm:i.algorithm}},enumerable:false,configurable:true});Object.defineProperty(e.prototype,"commonName",{get:function(){if(!this.subject){return""}for(var t=0;t<this.subject.length;t+=1){var e=this.subject[t];if(e.shortName==="CN"||e.shortName==="E"||e.shortName==="O"){return e.value}}return""},enumerable:false,configurable:true});e.prototype.getThumbprint=function(){return __awaiter(this,arguments,void 0,(function(t){var e,i;if(t===void 0){t="SHA-1"}return __generator(this,(function(r){switch(r.label){case 0:r.trys.push([0,2,,3]);return[4,getCertificateThumbprint(t,this.raw)];case 1:e=r.sent();if(e){this.thumbprints[t]=buildExports.Convert.ToHex(e)}return[3,3];case 2:i=r.sent();console.error("Error thumbprint get:",i);return[3,3];case 3:return[2]}}))}))};e.prototype.parseAttributes=function(){var t=this.asn.certificationRequestInfo;if(t.attributes){this.attributes=t.attributes.map((function(t){return new Attribute(AsnConvert.serialize(t))}))}};e.prototype.toString=function(t){if(t===void 0){t="pem"}switch(t){case"pem":return PemConverter.encode(this.raw,this.tag);case"base64url":return buildExports.Convert.ToBase64Url(this.raw);default:return buildExports.Convert.ToBase64(this.raw)}};e.prototype.downloadAsPEM=function(t){Download.csr.asPEM(this.toString("pem"),t||this.commonName)};e.prototype.downloadAsDER=function(t){Download.csr.asDER(this.raw,t||this.commonName)};return e}(AsnData);
/*!
* © Peculiar Ventures https://peculiarventures.com/ - MIT License
*/
/**
* @license
* Copyright (c) Peculiar Ventures, LLC.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/var X509Crl=function(t){__extends(e,t);function e(e){var i=t.call(this,certificateRawToBuffer(e),CertificateList)||this;i.thumbprints={};i.type="X.509 Certificate Revocation List";i.tag=PemConverter.CrlTag;var r=i.asn.tbsCertList;i.issuer=new Name(r.issuer).toJSON();i.version=r.version+1;i.lastUpdate=r.thisUpdate.getTime();i.nextUpdate=r.nextUpdate.getTime();i.revokedCertificates=(r.revokedCertificates||[]).map((function(t){var e;return{revocationDate:t.revocationDate,userCertificate:t.userCertificate,crlEntryExtensions:(e=t.crlEntryExtensions)===null||e===void 0?void 0:e.map((function(t){return new Extension(AsnConvert.serialize(t))}))}}));return i}e.prototype.getThumbprint=function(){return __awaiter(this,arguments,void 0,(function(t){var e,i;if(t===void 0){t="SHA-1"}return __generator(this,(function(r){switch(r.label){case 0:r.trys.push([0,2,,3]);return[4,getCertificateThumbprint(t,this.raw)];case 1:e=r.sent();if(e){this.thumbprints[t]=buildExports.Convert.ToHex(e)}return[3,3];case 2:i=r.sent();console.error("Error thumbprint get:",i);return[3,3];case 3:return[2]}}))}))};Object.defineProperty(e.prototype,"signature",{get:function(){var t=this.asn,e=t.signature,i=t.signatureAlgorithm;return{value:e,algorithm:i.algorithm}},enumerable:false,configurable:true});Object.defineProperty(e.prototype,"commonName",{get:function(){if(!this.issuer){return""}for(var t=0;t<this.issuer.length;t+=1){var e=this.issuer[t];if(e.shortName==="CN"||e.shortName==="E"||e.shortName==="O"){return e.value}}return""},enumerable:false,configurable:true});e.prototype.parseExtensions=function(){var t=this.asn.tbsCertList;if(t.crlExtensions){this.extensions=t.crlExtensions.map((function(t){return new Extension(AsnConvert.serialize(t))}))}};e.prototype.toString=function(t){if(t===void 0){t="pem"}switch(t){case"pem":return PemConverter.encode(this.raw,this.tag);case"base64url":return buildExports.Convert.ToBase64Url(this.raw);default:return buildExports.Convert.ToBase64(this.raw)}};e.prototype.downloadAsPEM=function(t){Download.crl.asPEM(this.toString("pem"),t||this.commonName)};e.prototype.downloadAsDER=function(t){Download.crl.asDER(this.raw,t||this.commonName)};return e}(AsnData);export{Pkcs10CertificateRequest as P,X509AttributeCertificate as X,X509Crl as a};
//# sourceMappingURL=x509_crl-Dw1H8DAG.js.map