UNPKG

@peculiar/fortify-webcomponents

Version:

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

9 lines 6.05 kB
var __extends=this&&this.__extends||function(){var t=function(n,r){t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,n){t.__proto__=n}||function(t,n){for(var r in n)if(Object.prototype.hasOwnProperty.call(n,r))t[r]=n[r]};return t(n,r)};return function(n,r){if(typeof r!=="function"&&r!==null)throw new TypeError("Class extends value "+String(r)+" is not a constructor or null");t(n,r);function e(){this.constructor=n}n.prototype=r===null?Object.create(r):(e.prototype=r.prototype,new e)}}();var __awaiter=this&&this.__awaiter||function(t,n,r,e){function i(t){return t instanceof r?t:new r((function(n){n(t)}))}return new(r||(r=Promise))((function(r,u){function o(t){try{f(e.next(t))}catch(t){u(t)}}function a(t){try{f(e["throw"](t))}catch(t){u(t)}}function f(t){t.done?r(t.value):i(t.value).then(o,a)}f((e=e.apply(t,n||[])).next())}))};var __generator=this&&this.__generator||function(t,n){var r={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(n){return f([t,n])}}function f(a){if(e)throw new TypeError("Generator is already executing.");while(o&&(o=0,a[0]&&(r=0)),r)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:r.label++;return{value:a[1],done:false};case 5:r.label++;i=a[1];a=[0];continue;case 7:a=r.ops.pop();r.trys.pop();continue;default:if(!(u=r.trys,u=u.length>0&&u[u.length-1])&&(a[0]===6||a[0]===2)){r=0;continue}if(a[0]===3&&(!u||a[1]>u[0]&&a[1]<u[3])){r.label=a[1];break}if(a[0]===6&&r.label<u[1]){r.label=u[1];u=a;break}if(u&&r.label<u[2]){r.label=u[2];r.ops.push(a);break}if(u[2])r.ops.pop();r.trys.pop();continue}a=n.call(t,r)}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 n,r,e,i,u,o,a,f,c,s,h,l,v,b,m,w,g,y,_,p;return{setters:[function(t){n=t.e;r=t.c;e=t.P;i=t.C;u=t.N;o=t.f;a=t.A;f=t.i;c=t.g;s=t.h;h=t.R;l=t.j;v=t.k;b=t.l;m=t.m;w=t.n;g=t.D},function(t){y=t.c;_=t.E;p=t.g}],execute:function(){ /*! * © Peculiar Ventures https://peculiarventures.com/ - MIT License */ var O=function(t){__extends(n,t);function n(n){var a=t.call(this,y(n),r)||this;a.thumbprints={};a.type="X.509 Certificate";a.tag=e.CertificateTag;var f=a.asn.tbsCertificate;a.serialNumber=i.ToHex(f.serialNumber);a.subject=new u(f.subject).toJSON();a.issuer=new u(f.issuer).toJSON();a.version=f.version+1;var c=f.validity.notBefore.utcTime||f.validity.notBefore.generalTime;if(!c){throw new Error("Cannot get 'notBefore' value")}a.notBefore=c;var s=f.validity.notAfter.utcTime||f.validity.notAfter.generalTime;if(!s){throw new Error("Cannot get 'notAfter' value")}a.notAfter=s;a.validity=o(a.notBefore,a.notAfter);return a}n.prototype.parseExtensions=function(){var t=this.asn.tbsCertificate;if(t.extensions){this.extensions=t.extensions.map((function(t){return new _(a.serialize(t))}))}};n.prototype.getPublicKeyInfo=function(t){var n=this;var r=t.subjectPublicKey,e=t.algorithm;var i;if(e.algorithm===f&&e.parameters){i=a.parse(e.parameters,c)}if(e.algorithm===s){i=a.parse(r,h)}if(e.algorithm===l){i=a.parse(r,v);i=i.map((function(t){return n.getPublicKeyInfo(t)}))}var u=a.serialize(t);return{params:i,value:u,algorithm:e.algorithm}};Object.defineProperty(n.prototype,"publicKey",{get:function(){return this.getPublicKeyInfo(this.asn.tbsCertificate.subjectPublicKeyInfo)},enumerable:false,configurable:true});Object.defineProperty(n.prototype,"signature",{get:function(){var t=this.asn,n=t.signatureValue,r=t.signatureAlgorithm;var e;if(r.algorithm===b){var i=a.parse(n,m);var u=a.parse(r.parameters,w);e=u.map((function(t,n){return Object.assign(Object.assign({},t),{value:i[n]})}))}return{params:e,value:n,algorithm:r.algorithm}},enumerable:false,configurable:true});n.prototype.getThumbprint=function(){return __awaiter(this,arguments,void 0,(function(t){var n,r;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,p(t,this.raw)];case 1:n=e.sent();if(n){this.thumbprints[t]=i.ToHex(n)}return[3,3];case 2:r=e.sent();console.error("Error thumbprint get:",r);return[3,3];case 3:return[2]}}))}))};Object.defineProperty(n.prototype,"commonName",{get:function(){if(!this.subject){return""}for(var t=0;t<this.subject.length;t+=1){var n=this.subject[t];if(n.shortName==="CN"||n.shortName==="E"||n.shortName==="O"){return n.value}}return""},enumerable:false,configurable:true});Object.defineProperty(n.prototype,"issuerCommonName",{get:function(){if(!this.issuer){return""}for(var t=0;t<this.issuer.length;t+=1){var n=this.issuer[t];if(n.shortName==="CN"){return n.value}if(n.shortName==="E"){return n.value}}return""},enumerable:false,configurable:true});Object.defineProperty(n.prototype,"isRoot",{get:function(){return JSON.stringify(this.issuer)===JSON.stringify(this.subject)},enumerable:false,configurable:true});n.prototype.subjectToString=function(){if(!this.subject){return""}return this.subject.map((function(t){return"".concat(t.shortName,"=").concat(t.value)})).join(", ")};n.prototype.issuerToString=function(){if(!this.issuer){return""}return this.issuer.map((function(t){return"".concat(t.shortName,"=").concat(t.value)})).join(", ")};n.prototype.toString=function(t){if(t===void 0){t="pem"}switch(t){case"pem":return e.encode(this.raw,this.tag);case"base64url":return i.ToBase64Url(this.raw);default:return i.ToBase64(this.raw)}};n.prototype.downloadAsPEM=function(t){g.cert.asPEM(this.toString("pem"),t||this.commonName)};n.prototype.downloadAsDER=function(t){g.cert.asDER(this.raw,t||this.commonName)};return n}(n);t("X",O)}}})); //# sourceMappingURL=p-370dcf83.system.js.map