@peculiar/fortify-webcomponents
Version:
Web-components for creating CSR or Certificate and viewing certificates list using Fortify
17 lines • 5.75 kB
JavaScript
/*!
* © Peculiar Ventures https://peculiarventures.com/ - BSD 3-Clause License
*/
import{e as t,o as s,p as i,C as e,q as r,r as a,s as n,t as h,u as o,v as c,w as u,x as l,y as f,T as g,z as m,B as p,F as d,W as w,G as b,I as E,H as A,V as v,J as C,K as y,L as x,U as R,M as P,Q as S,X as D,P as N,f as q,A as H,D as K,Y as L,N as M,i as T,g as X,h as j,R as I,Z as V}from"./p-4227eec7.js";import{c as $,E as B,g as O}from"./p-db3ee43d.js";
/*!
* © Peculiar Ventures https://peculiarventures.com/ - MIT License
*/const z={[r]:a,[n]:h,[o]:c,[u]:l,[f]:g,[m]:p,[d]:w,[b]:E,[A]:v,[C]:y,[x]:R,[P]:S};class F extends t{getAsnExtnValue(){return this.asn.values[0]}constructor(t){super(t,s);const r=this.getAsnExtnValue();try{const t=z[this.asn.type];if(t){this.value=i.parse(r,t)}else{console.warn(`Didn't detect parser for "${this.asn.type}" attribute.`);this.value=e.ToHex(r)}}catch(t){console.error(`Error parse "${this.asn.type}" attribute:`,t.message);this.value=e.ToHex(r)}}}
/*!
* © Peculiar Ventures https://peculiarventures.com/ - MIT License
*/class G extends t{constructor(t){var s;super($(t),D);this.thumbprints={};this.type="X.509 Attribute Certificate";this.tag=N.AttributeCertificateTag;const{acinfo:i}=this.asn;this.serialNumber=e.ToHex(i.serialNumber);this.version=i.version;const r=i.attrCertValidityPeriod.notBeforeTime;if(!r){throw new Error("Cannot get 'notBefore' value")}this.notBefore=r;const a=i.attrCertValidityPeriod.notAfterTime;if(!a){throw new Error("Cannot get 'notAfter' value")}this.notAfter=a;this.validity=q(this.notBefore,this.notAfter);this.issuer=i.issuer.v1Form||((s=i.issuer.v2Form)===null||s===void 0?void 0:s.issuerName);this.holder=i.holder}get signature(){const{signatureValue:t,signatureAlgorithm:s}=this.asn;return{value:t,algorithm:s.algorithm}}parseExtensions(){const{acinfo:t}=this.asn;if(t.extensions){this.extensions=t.extensions.map((t=>new B(H.serialize(t))))}}parseAttributes(){const{acinfo:t}=this.asn;if(t.attributes){this.attributes=t.attributes.map((t=>new F(H.serialize(t))))}}async getThumbprint(t="SHA-1"){try{const s=await O(t,this.raw);if(s){this.thumbprints[t]=e.ToHex(s)}}catch(t){console.error("Error thumbprint get:",t)}}get commonName(){return`attribute-certificate-${this.thumbprints["SHA-1"]}`}toString(t="pem"){switch(t){case"pem":return N.encode(this.raw,this.tag);case"base64url":return e.ToBase64Url(this.raw);default:return e.ToBase64(this.raw)}}downloadAsPEM(t){K.attrCert.asPEM(this.toString("pem"),t||this.commonName)}downloadAsDER(t){K.attrCert.asDER(this.raw,t||this.commonName)}}
/*!
* © Peculiar Ventures https://peculiarventures.com/ - MIT License
*/class J extends t{constructor(t){super($(t),L);this.thumbprints={};this.type="PKCS#10 Certificate Request";this.tag=N.CertificateRequestTag;const{certificationRequestInfo:s}=this.asn;this.subject=new M(s.subject).toJSON();this.version=s.version}get publicKey(){const{subjectPublicKey:t,algorithm:s}=this.asn.certificationRequestInfo.subjectPKInfo;let i;if(s.algorithm===T&&s.parameters){i=H.parse(s.parameters,X)}if(s.algorithm===j){i=H.parse(t,I)}const e=H.serialize(this.asn.certificationRequestInfo.subjectPKInfo);return{params:i,value:e,algorithm:s.algorithm}}get signature(){const{signature:t,signatureAlgorithm:s}=this.asn;return{value:t,algorithm:s.algorithm}}get commonName(){if(!this.subject){return""}for(let t=0;t<this.subject.length;t+=1){const s=this.subject[t];if(s.shortName==="CN"||s.shortName==="E"||s.shortName==="O"){return s.value}}return""}async getThumbprint(t="SHA-1"){try{const s=await O(t,this.raw);if(s){this.thumbprints[t]=e.ToHex(s)}}catch(t){console.error("Error thumbprint get:",t)}}parseAttributes(){const{certificationRequestInfo:t}=this.asn;if(t.attributes){this.attributes=t.attributes.map((t=>new F(H.serialize(t))));const s=this.attributes.find((t=>t.asn.type===P));if(s){this.extensions=s.value.map((t=>new B(H.serialize(t))))}}}toString(t="pem"){switch(t){case"pem":return N.encode(this.raw,this.tag);case"base64url":return e.ToBase64Url(this.raw);default:return e.ToBase64(this.raw)}}downloadAsPEM(t){K.csr.asPEM(this.toString("pem"),t||this.commonName)}downloadAsDER(t){K.csr.asDER(this.raw,t||this.commonName)}}
/*!
* © Peculiar Ventures https://peculiarventures.com/ - MIT License
*/class Q extends t{constructor(t){super($(t),V);this.thumbprints={};this.type="X.509 Certificate Revocation List";this.tag=N.CrlTag;const{tbsCertList:s}=this.asn;this.issuer=new M(s.issuer).toJSON();this.version=s.version+1;this.lastUpdate=s.thisUpdate.getTime();this.nextUpdate=s.nextUpdate.getTime();this.revokedCertificates=(s.revokedCertificates||[]).map((t=>{var s;return{revocationDate:t.revocationDate,userCertificate:t.userCertificate,crlEntryExtensions:(s=t.crlEntryExtensions)===null||s===void 0?void 0:s.map((t=>new B(H.serialize(t))))}}))}async getThumbprint(t="SHA-1"){try{const s=await O(t,this.raw);if(s){this.thumbprints[t]=e.ToHex(s)}}catch(t){console.error("Error thumbprint get:",t)}}get signature(){const{signature:t,signatureAlgorithm:s}=this.asn;return{value:t,algorithm:s.algorithm}}get commonName(){if(!this.issuer){return""}for(let t=0;t<this.issuer.length;t+=1){const s=this.issuer[t];if(s.shortName==="CN"||s.shortName==="E"||s.shortName==="O"){return s.value}}return""}parseExtensions(){const{tbsCertList:t}=this.asn;if(t.crlExtensions){this.extensions=t.crlExtensions.map((t=>new B(H.serialize(t))))}}toString(t="pem"){switch(t){case"pem":return N.encode(this.raw,this.tag);case"base64url":return e.ToBase64Url(this.raw);default:return e.ToBase64(this.raw)}}downloadAsPEM(t){K.crl.asPEM(this.toString("pem"),t||this.commonName)}downloadAsDER(t){K.crl.asDER(this.raw,t||this.commonName)}}export{J as P,G as X,Q as a};
//# sourceMappingURL=p-e4075fb2.js.map