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