UNPKG

@peculiar/fortify-webcomponents

Version:

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

17 lines 9.92 kB
var __extends=this&&this.__extends||function(){var t=function(r,n){t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,r){t.__proto__=r}||function(t,r){for(var n in r)if(Object.prototype.hasOwnProperty.call(r,n))t[n]=r[n]};return t(r,n)};return function(r,n){if(typeof n!=="function"&&n!==null)throw new TypeError("Class extends value "+String(n)+" is not a constructor or null");t(r,n);function e(){this.constructor=r}r.prototype=n===null?Object.create(n):(e.prototype=n.prototype,new e)}}();var __awaiter=this&&this.__awaiter||function(t,r,n,e){function i(t){return t instanceof n?t:new n((function(r){r(t)}))}return new(n||(n=Promise))((function(n,u){function o(t){try{s(e.next(t))}catch(t){u(t)}}function a(t){try{s(e["throw"](t))}catch(t){u(t)}}function s(t){t.done?n(t.value):i(t.value).then(o,a)}s((e=e.apply(t,r||[])).next())}))};var __generator=this&&this.__generator||function(t,r){var n={label:0,sent:function(){if(u[0]&1)throw u[1];return u[1]},trys:[],ops:[]},e,i,u,o;return o={next:a(0),throw:a(1),return:a(2)},typeof Symbol==="function"&&(o[Symbol.iterator]=function(){return this}),o;function a(t){return function(r){return s([t,r])}}function s(a){if(e)throw new TypeError("Generator is already executing.");while(o&&(o=0,a[0]&&(n=0)),n)try{if(e=1,i&&(u=a[0]&2?i["return"]:a[0]?i["throw"]||((u=i["return"])&&u.call(i),0):i.next)&&!(u=u.call(i,a[1])).done)return u;if(i=0,u)a=[a[0]&2,u.value];switch(a[0]){case 0:case 1:u=a;break;case 4:n.label++;return{value:a[1],done:false};case 5:n.label++;i=a[1];a=[0];continue;case 7:a=n.ops.pop();n.trys.pop();continue;default:if(!(u=n.trys,u=u.length>0&&u[u.length-1])&&(a[0]===6||a[0]===2)){n=0;continue}if(a[0]===3&&(!u||a[1]>u[0]&&a[1]<u[3])){n.label=a[1];break}if(a[0]===6&&n.label<u[1]){n.label=u[1];u=a;break}if(u&&n.label<u[2]){n.label=u[2];n.ops.push(a);break}if(u[2])n.ops.pop();n.trys.pop();continue}a=r.call(t,n)}catch(t){a=[6,t];i=0}finally{e=u=0}if(a[0]&5)throw a[1];return{value:a[0]?a[1]:void 0,done:true}}}; /*! * © Peculiar Ventures https://peculiarventures.com/ - BSD 3-Clause License */System.register(["./p-920e4680.system.js","./p-3e6ca220.system.js"],(function(t){"use strict";var r,n,e,i,u,o,a,s,c,f,h,l,v,b,m,w,g,_,d,p,y,j,E,O,x,C,S,A,N,k,H,P,X,D,K,R,T,q,B,G,L,z,F;return{setters:[function(t){r=t.e;n=t.o;e=t.p;i=t.C;u=t.q;o=t.r;a=t.s;s=t.t;c=t.u;f=t.v;h=t.w;l=t.x;v=t.y;b=t.T;m=t.z;w=t.B;g=t.F;_=t.W;d=t.G;p=t.I;y=t.H;j=t.V;E=t.J;O=t.K;x=t.L;C=t.U;S=t.M;A=t.Q;N=t.X;k=t.P;H=t.f;P=t.A;X=t.D;D=t.Y;K=t.N;R=t.i;T=t.g;q=t.h;B=t.R;G=t.Z},function(t){L=t.c;z=t.E;F=t.g}],execute:function(){var I; /*! * © Peculiar Ventures https://peculiarventures.com/ - MIT License */var J=(I={},I[u]=o,I[a]=s,I[c]=f,I[h]=l,I[v]=b,I[m]=w,I[g]=_,I[d]=p,I[y]=j,I[E]=O,I[x]=C,I[S]=A,I);var M=function(t){__extends(r,t);function r(r){var u=t.call(this,r,n)||this;var o=u.getAsnExtnValue();try{var a=J[u.asn.type];if(a){u.value=e.parse(o,a)}else{console.warn("Didn't detect parser for \"".concat(u.asn.type,'" attribute.'));u.value=i.ToHex(o)}}catch(t){console.error('Error parse "'.concat(u.asn.type,'" attribute:'),t.message);u.value=i.ToHex(o)}return u}r.prototype.getAsnExtnValue=function(){return this.asn.values[0]};return r}(r); /*! * © Peculiar Ventures https://peculiarventures.com/ - MIT License */var Q=function(t){__extends(r,t);function r(r){var n;var e=t.call(this,L(r),N)||this;e.thumbprints={};e.type="X.509 Attribute Certificate";e.tag=k.AttributeCertificateTag;var u=e.asn.acinfo;e.serialNumber=i.ToHex(u.serialNumber);e.version=u.version;var o=u.attrCertValidityPeriod.notBeforeTime;if(!o){throw new Error("Cannot get 'notBefore' value")}e.notBefore=o;var a=u.attrCertValidityPeriod.notAfterTime;if(!a){throw new Error("Cannot get 'notAfter' value")}e.notAfter=a;e.validity=H(e.notBefore,e.notAfter);e.issuer=u.issuer.v1Form||((n=u.issuer.v2Form)===null||n===void 0?void 0:n.issuerName);e.holder=u.holder;return e}Object.defineProperty(r.prototype,"signature",{get:function(){var t=this.asn,r=t.signatureValue,n=t.signatureAlgorithm;return{value:r,algorithm:n.algorithm}},enumerable:false,configurable:true});r.prototype.parseExtensions=function(){var t=this.asn.acinfo;if(t.extensions){this.extensions=t.extensions.map((function(t){return new z(P.serialize(t))}))}};r.prototype.parseAttributes=function(){var t=this.asn.acinfo;if(t.attributes){this.attributes=t.attributes.map((function(t){return new M(P.serialize(t))}))}};r.prototype.getThumbprint=function(){return __awaiter(this,arguments,void 0,(function(t){var r,n;if(t===void 0){t="SHA-1"}return __generator(this,(function(e){switch(e.label){case 0:e.trys.push([0,2,,3]);return[4,F(t,this.raw)];case 1:r=e.sent();if(r){this.thumbprints[t]=i.ToHex(r)}return[3,3];case 2:n=e.sent();console.error("Error thumbprint get:",n);return[3,3];case 3:return[2]}}))}))};Object.defineProperty(r.prototype,"commonName",{get:function(){return"attribute-certificate-".concat(this.thumbprints["SHA-1"])},enumerable:false,configurable:true});r.prototype.toString=function(t){if(t===void 0){t="pem"}switch(t){case"pem":return k.encode(this.raw,this.tag);case"base64url":return i.ToBase64Url(this.raw);default:return i.ToBase64(this.raw)}};r.prototype.downloadAsPEM=function(t){X.attrCert.asPEM(this.toString("pem"),t||this.commonName)};r.prototype.downloadAsDER=function(t){X.attrCert.asDER(this.raw,t||this.commonName)};return r}(r);t("X",Q); /*! * © Peculiar Ventures https://peculiarventures.com/ - MIT License */var U=function(t){__extends(r,t);function r(r){var n=t.call(this,L(r),D)||this;n.thumbprints={};n.type="PKCS#10 Certificate Request";n.tag=k.CertificateRequestTag;var e=n.asn.certificationRequestInfo;n.subject=new K(e.subject).toJSON();n.version=e.version;return n}Object.defineProperty(r.prototype,"publicKey",{get:function(){var t=this.asn.certificationRequestInfo.subjectPKInfo,r=t.subjectPublicKey,n=t.algorithm;var e;if(n.algorithm===R&&n.parameters){e=P.parse(n.parameters,T)}if(n.algorithm===q){e=P.parse(r,B)}var i=P.serialize(this.asn.certificationRequestInfo.subjectPKInfo);return{params:e,value:i,algorithm:n.algorithm}},enumerable:false,configurable:true});Object.defineProperty(r.prototype,"signature",{get:function(){var t=this.asn,r=t.signature,n=t.signatureAlgorithm;return{value:r,algorithm:n.algorithm}},enumerable:false,configurable:true});Object.defineProperty(r.prototype,"commonName",{get:function(){if(!this.subject){return""}for(var t=0;t<this.subject.length;t+=1){var r=this.subject[t];if(r.shortName==="CN"||r.shortName==="E"||r.shortName==="O"){return r.value}}return""},enumerable:false,configurable:true});r.prototype.getThumbprint=function(){return __awaiter(this,arguments,void 0,(function(t){var r,n;if(t===void 0){t="SHA-1"}return __generator(this,(function(e){switch(e.label){case 0:e.trys.push([0,2,,3]);return[4,F(t,this.raw)];case 1:r=e.sent();if(r){this.thumbprints[t]=i.ToHex(r)}return[3,3];case 2:n=e.sent();console.error("Error thumbprint get:",n);return[3,3];case 3:return[2]}}))}))};r.prototype.parseAttributes=function(){var t=this.asn.certificationRequestInfo;if(t.attributes){this.attributes=t.attributes.map((function(t){return new M(P.serialize(t))}));var r=this.attributes.find((function(t){return t.asn.type===S}));if(r){this.extensions=r.value.map((function(t){return new z(P.serialize(t))}))}}};r.prototype.toString=function(t){if(t===void 0){t="pem"}switch(t){case"pem":return k.encode(this.raw,this.tag);case"base64url":return i.ToBase64Url(this.raw);default:return i.ToBase64(this.raw)}};r.prototype.downloadAsPEM=function(t){X.csr.asPEM(this.toString("pem"),t||this.commonName)};r.prototype.downloadAsDER=function(t){X.csr.asDER(this.raw,t||this.commonName)};return r}(r);t("P",U); /*! * © Peculiar Ventures https://peculiarventures.com/ - MIT License */var V=function(t){__extends(r,t);function r(r){var n=t.call(this,L(r),G)||this;n.thumbprints={};n.type="X.509 Certificate Revocation List";n.tag=k.CrlTag;var e=n.asn.tbsCertList;n.issuer=new K(e.issuer).toJSON();n.version=e.version+1;n.lastUpdate=e.thisUpdate.getTime();n.nextUpdate=e.nextUpdate.getTime();n.revokedCertificates=(e.revokedCertificates||[]).map((function(t){var r;return{revocationDate:t.revocationDate,userCertificate:t.userCertificate,crlEntryExtensions:(r=t.crlEntryExtensions)===null||r===void 0?void 0:r.map((function(t){return new z(P.serialize(t))}))}}));return n}r.prototype.getThumbprint=function(){return __awaiter(this,arguments,void 0,(function(t){var r,n;if(t===void 0){t="SHA-1"}return __generator(this,(function(e){switch(e.label){case 0:e.trys.push([0,2,,3]);return[4,F(t,this.raw)];case 1:r=e.sent();if(r){this.thumbprints[t]=i.ToHex(r)}return[3,3];case 2:n=e.sent();console.error("Error thumbprint get:",n);return[3,3];case 3:return[2]}}))}))};Object.defineProperty(r.prototype,"signature",{get:function(){var t=this.asn,r=t.signature,n=t.signatureAlgorithm;return{value:r,algorithm:n.algorithm}},enumerable:false,configurable:true});Object.defineProperty(r.prototype,"commonName",{get:function(){if(!this.issuer){return""}for(var t=0;t<this.issuer.length;t+=1){var r=this.issuer[t];if(r.shortName==="CN"||r.shortName==="E"||r.shortName==="O"){return r.value}}return""},enumerable:false,configurable:true});r.prototype.parseExtensions=function(){var t=this.asn.tbsCertList;if(t.crlExtensions){this.extensions=t.crlExtensions.map((function(t){return new z(P.serialize(t))}))}};r.prototype.toString=function(t){if(t===void 0){t="pem"}switch(t){case"pem":return k.encode(this.raw,this.tag);case"base64url":return i.ToBase64Url(this.raw);default:return i.ToBase64(this.raw)}};r.prototype.downloadAsPEM=function(t){X.crl.asPEM(this.toString("pem"),t||this.commonName)};r.prototype.downloadAsDER=function(t){X.crl.asDER(this.raw,t||this.commonName)};return r}(r);t("a",V)}}})); //# sourceMappingURL=p-6648d605.system.js.map