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