UNPKG

xmldsigjs-hotfix

Version:

XMLDSIGjs provides an implementation of XMLDSIG in Typescript/Javascript based on WebCrypto

2 lines 340 kB
var XmlDSigJs=function(e){"use strict";function t(e){return(t="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function r(e,t,r,n,a,i,s){try{var o=e[i](s),u=o.value}catch(e){return void r(e)}o.done?t(u):Promise.resolve(u).then(n,a)}function n(e){return function(){var t=this,n=arguments;return new Promise((function(a,i){var s=e.apply(t,n);function o(e){r(s,a,i,o,u,"next",e)}function u(e){r(s,a,i,o,u,"throw",e)}o(void 0)}))}}function a(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function i(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}function s(e,t,r){return t&&i(e.prototype,t),r&&i(e,r),e}function o(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&l(e,t)}function u(e){return(u=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function l(e,t){return(l=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function c(e,t){return!t||"object"!=typeof t&&"function"!=typeof t?function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(e):t}function h(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],(function(){}))),!0}catch(e){return!1}}();return function(){var r,n=u(e);if(t){var a=u(this).constructor;r=Reflect.construct(n,arguments,a)}else r=n.apply(this,arguments);return c(this,r)}}function m(e,t,r){return(m="undefined"!=typeof Reflect&&Reflect.get?Reflect.get:function(e,t,r){var n=function(e,t){for(;!Object.prototype.hasOwnProperty.call(e,t)&&null!==(e=u(e)););return e}(e,t);if(n){var a=Object.getOwnPropertyDescriptor(n,t);return a.get?a.get.call(r):a.value}})(e,t,r||e)}function f(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){if("undefined"==typeof Symbol||!(Symbol.iterator in Object(e)))return;var r=[],n=!0,a=!1,i=void 0;try{for(var s,o=e[Symbol.iterator]();!(n=(s=o.next()).done)&&(r.push(s.value),!t||r.length!==t);n=!0);}catch(e){a=!0,i=e}finally{try{n||null==o.return||o.return()}finally{if(a)throw i}}return r}(e,t)||g(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function v(e){return function(e){if(Array.isArray(e))return d(e)}(e)||function(e){if("undefined"!=typeof Symbol&&Symbol.iterator in Object(e))return Array.from(e)}(e)||g(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function g(e,t){if(e){if("string"==typeof e)return d(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?d(e,t):void 0}}function d(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r<t;r++)n[r]=e[r];return n}function y(e,t){var r;if("undefined"==typeof Symbol||null==e[Symbol.iterator]){if(Array.isArray(e)||(r=g(e))||t&&e&&"number"==typeof e.length){r&&(e=r);var n=0,a=function(){};return{s:a,n:function(){return n>=e.length?{done:!0}:{done:!1,value:e[n++]}},e:function(e){throw e},f:a}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var i,s=!0,o=!1;return{s:function(){r=e[Symbol.iterator]()},n:function(){var e=r.next();return s=e.done,e},e:function(e){o=!0,i=e},f:function(){try{s||null==r.return||r.return()}finally{if(o)throw i}}}}var p="element",b="attribute",k="content",w=1e9;function S(e){for(var t=arguments.length,r=new Array(t>1?t-1:0),n=1;n<t;n++)r[n-1]=arguments[n];for(var a=arguments[0],i=1;i<arguments.length;i++){var s=arguments[i];for(var o in s)s.hasOwnProperty(o)&&(a[o]=s[o])}return a}function A(e){return function(t){var r=t;r.localName=e.localName||r.name,r.namespaceURI=e.namespaceURI||r.namespaceURI||null,r.prefix=e.prefix||r.prefix||null,r.parser=e.parser||r.parser,r.target!==r&&(r.items=S({},r.items)),r.target=t}}function C(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return function(t,r){var n=t.constructor,a=r;n.items||(n.items={}),n.target!==n&&(n.items=S({},n.items)),n.target=t,e.parser?n.items[a]={parser:e.parser,required:e.required||!1,maxOccurs:e.maxOccurs||w,minOccurs:void 0===e.minOccurs?0:e.minOccurs,noRoot:e.noRoot||!1}:n.items[a]={namespaceURI:e.namespaceURI||null,required:e.required||!1,prefix:e.prefix||null,defaultValue:e.defaultValue,converter:e.converter,noRoot:e.noRoot||!1},e.localName=e.localName||e.parser&&e.parser.localName||a,n.items[a].namespaceURI=e.namespaceURI||e.parser&&e.parser.namespaceURI||null,n.items[a].prefix=e.prefix||e.parser&&e.parser.prefix||null,n.items[a].localName=e.localName,n.items[a].type=p,B(t,a,e)}}function N(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{required:!1,namespaceURI:null};return function(t,r){var n=t.constructor,a=r;e.localName||(e.localName=r),n.items||(n.items={}),n.target!==n&&(n.items=S({},n.items)),n.target=t,n.items[r]=e,n.items[r].type=b,B(t,a,e)}}function B(e,t,r){var n="_".concat(t),a={set:function(e){this[n]!==e&&(this.element=null,this[n]=e)},get:function(){if(void 0===this[n]){var e=r.defaultValue;r.parser&&((e=new r.parser).localName=r.localName),this[n]=e}return this[n]}};Object.defineProperty(e,n,{writable:!0,enumerable:!1}),Object.defineProperty(e,t,a)}var I=function(){function e(t){a(this,e),this.items=new Array,t&&(this.items=t)}return s(e,[{key:"Item",value:function(e){return this.items[e]||null}},{key:"Add",value:function(e){this.items.push(e)}},{key:"Pop",value:function(){return this.items.pop()}},{key:"RemoveAt",value:function(e){this.items=this.items.filter((function(t,r){return r!==e}))}},{key:"Clear",value:function(){this.items=new Array}},{key:"GetIterator",value:function(){return this.items}},{key:"ForEach",value:function(e){this.GetIterator().forEach(e)}},{key:"Map",value:function(t){return new e(this.GetIterator().map(t))}},{key:"Filter",value:function(t){return new e(this.GetIterator().filter(t))}},{key:"Sort",value:function(t){return new e(this.GetIterator().sort(t))}},{key:"Every",value:function(e){return this.GetIterator().every(e)}},{key:"Some",value:function(e){return this.GetIterator().some(e)}},{key:"IsEmpty",value:function(){return 0===this.Count}},{key:"Count",get:function(){return this.items.length}}]),e}();function P(e){for(var t=arguments.length,r=new Array(t>1?t-1:0),n=1;n<t;n++)r[n-1]=arguments[n];for(var a=e,i=/[^%](%\d+)/g,s=null,o=[];s=i.exec(a);)o.push({arg:s[1],index:s.index});for(var u=o.length-1;u>=0;u--){var l=o[u],c=l.arg.substring(1),h=l.index+1;a=a.substring(0,h)+arguments[+c]+a.substring(h+1+c.length)}return a=a.replace("%%","%")}function E(e,t){for(var r=e+"";r.length<t;)r="0"+r;return r}var x,R=function e(t){for(var r=arguments.length,n=new Array(r>1?r-1:0),i=1;i<r;i++)n[i-1]=arguments[i];a(this,e),this.prefix="XMLJS",this.code=t,this.name=this.constructor.name,arguments[0]=L[t];var s=P.apply(this,arguments);this.message="".concat(this.prefix).concat(E(t,4),": ").concat(s),this.stack=new Error(this.message).stack};!function(e){e[e.NONE=0]="NONE",e[e.NULL_REFERENCE=1]="NULL_REFERENCE",e[e.NULL_PARAM=2]="NULL_PARAM",e[e.DECORATOR_NULL_PARAM=3]="DECORATOR_NULL_PARAM",e[e.COLLECTION_LIMIT=4]="COLLECTION_LIMIT",e[e.METHOD_NOT_IMPLEMENTED=5]="METHOD_NOT_IMPLEMENTED",e[e.METHOD_NOT_SUPPORTED=6]="METHOD_NOT_SUPPORTED",e[e.PARAM_REQUIRED=7]="PARAM_REQUIRED",e[e.CONVERTER_UNSUPPORTED=8]="CONVERTER_UNSUPPORTED",e[e.ELEMENT_MALFORMED=9]="ELEMENT_MALFORMED",e[e.ELEMENT_MISSING=10]="ELEMENT_MISSING",e[e.ATTRIBUTE_MISSING=11]="ATTRIBUTE_MISSING",e[e.CONTENT_MISSING=12]="CONTENT_MISSING",e[e.CRYPTOGRAPHIC=13]="CRYPTOGRAPHIC",e[e.CRYPTOGRAPHIC_NO_MODULE=14]="CRYPTOGRAPHIC_NO_MODULE",e[e.CRYPTOGRAPHIC_UNKNOWN_TRANSFORM=15]="CRYPTOGRAPHIC_UNKNOWN_TRANSFORM",e[e.ALGORITHM_NOT_SUPPORTED=16]="ALGORITHM_NOT_SUPPORTED",e[e.ALGORITHM_WRONG_NAME=17]="ALGORITHM_WRONG_NAME",e[e.XML_EXCEPTION=18]="XML_EXCEPTION"}(x||(x={}));var L={};L[x.NONE]="No description",L[x.NULL_REFERENCE]="Null reference",L[x.NULL_PARAM]="'%1' has empty '%2' object",L[x.DECORATOR_NULL_PARAM]="Decorator '%1' has empty '%2' parameter",L[x.COLLECTION_LIMIT]="Collection of '%1' in element '%2' has wrong amount of items",L[x.METHOD_NOT_IMPLEMENTED]="Method is not implemented",L[x.METHOD_NOT_SUPPORTED]="Method is not supported",L[x.PARAM_REQUIRED]="Required parameter is missing '%1'",L[x.CONVERTER_UNSUPPORTED]="Converter is not supported",L[x.ELEMENT_MALFORMED]="Malformed element '%1'",L[x.ELEMENT_MISSING]="Element '%1' is missing in '%2'",L[x.ATTRIBUTE_MISSING]="Attribute '%1' is missing in '%2'",L[x.CONTENT_MISSING]="Content is missing in '%1'",L[x.CRYPTOGRAPHIC]="Cryptographic error: %1",L[x.CRYPTOGRAPHIC_NO_MODULE]="WebCrypto module is not found",L[x.CRYPTOGRAPHIC_UNKNOWN_TRANSFORM]="Unknown transform %1",L[x.ALGORITHM_NOT_SUPPORTED]="Algorithm is not supported '%1'",L[x.ALGORITHM_WRONG_NAME]="Algorithm wrong name in use '%1'",L[x.XML_EXCEPTION]="XML exception: %1";var O,U=function(){function e(){a(this,e)}return s(e,null,[{key:"ToString",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"utf8",r=new Uint8Array(e);switch(t.toLowerCase()){case"utf8":return this.ToUtf8String(r);case"binary":return this.ToBinary(r);case"hex":return this.ToHex(r);case"base64":return this.ToBase64(r);case"base64url":return this.ToBase64Url(r);default:throw new R(x.CONVERTER_UNSUPPORTED)}}},{key:"FromString",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"utf8";switch(t.toLowerCase()){case"utf8":return this.FromUtf8String(e);case"binary":return this.FromBinary(e);case"hex":return this.FromHex(e);case"base64":return this.FromBase64(e);case"base64url":return this.FromBase64Url(e);default:throw new R(x.CONVERTER_UNSUPPORTED)}}},{key:"ToBase64",value:function(e){if("undefined"!=typeof btoa){var t=this.ToString(e,"binary");return btoa(t)}if("undefined"!=typeof Buffer)return Buffer.from(e).toString("base64");throw new R(x.CONVERTER_UNSUPPORTED)}},{key:"FromBase64",value:function(e){if(e=e.replace(/\n/g,"").replace(/\r/g,"").replace(/\t/g,"").replace(/\s/g,""),"undefined"!=typeof atob)return this.FromBinary(atob(e));if("undefined"!=typeof Buffer)return new Uint8Array(Buffer.from(e,"base64"));throw new R(x.CONVERTER_UNSUPPORTED)}},{key:"FromBase64Url",value:function(e){return this.FromBase64(this.Base64Padding(e.replace(/\-/g,"+").replace(/\_/g,"/")))}},{key:"ToBase64Url",value:function(e){return this.ToBase64(e).replace(/\+/g,"-").replace(/\//g,"_").replace(/\=/g,"")}},{key:"FromUtf8String",value:function(e){for(var t=unescape(encodeURIComponent(e)),r=new Uint8Array(t.length),n=0;n<t.length;n++)r[n]=t.charCodeAt(n);return r}},{key:"ToUtf8String",value:function(e){var t=String.fromCharCode.apply(null,e);return decodeURIComponent(escape(t))}},{key:"FromBinary",value:function(e){for(var t=e.length,r=new Uint8Array(t),n=0;n<t;n++)r[n]=e.charCodeAt(n);return r}},{key:"ToBinary",value:function(e){for(var t="",r=0;r<e.length;r++)t+=String.fromCharCode(e[r]);return t}},{key:"ToHex",value:function(e){for(var t=[],r=0;r<e.length;r++){var n=e[r].toString(16);t.push(1===n.length?"0"+n:n)}return t.join("")}},{key:"FromHex",value:function(e){for(var t=new Uint8Array(e.length/2),r=0;r<e.length;r+=2){var n=e.slice(r,r+2);t[r/2]=parseInt(n,16)}return t}},{key:"ToDateTime",value:function(e){return new Date(e)}},{key:"FromDateTime",value:function(e){return e.toISOString()}},{key:"Base64Padding",value:function(e){var t=4-e.length%4;if(t<4)for(var r=0;r<t;r++)e+="=";return e}}]),e}(),D="application/xml";!function(e){e[e.None=0]="None",e[e.Element=1]="Element",e[e.Attribute=2]="Attribute",e[e.Text=3]="Text",e[e.CDATA=4]="CDATA",e[e.EntityReference=5]="EntityReference",e[e.Entity=6]="Entity",e[e.ProcessingInstruction=7]="ProcessingInstruction",e[e.Comment=8]="Comment",e[e.Document=9]="Document",e[e.DocumentType=10]="DocumentType",e[e.DocumentFragment=11]="DocumentFragment",e[e.Notation=12]="Notation",e[e.Whitespace=13]="Whitespace",e[e.SignificantWhitespace=14]="SignificantWhitespace",e[e.EndElement=15]="EndElement",e[e.EndEntity=16]="EndEntity",e[e.XmlDeclaration=17]="XmlDeclaration"}(O||(O={}));var H,V=function(e,t){throw new Error("Not implemented")};if("undefined"==typeof self){H=global;var T=require("xmldom");V=require("xpath.js"),H.XMLSerializer=T.XMLSerializer,H.DOMParser=T.DOMParser,H.DOMImplementation=T.DOMImplementation,H.document=(new DOMImplementation).createDocument("http://www.w3.org/1999/xhtml","html",null)}else H=self;var _="undefined"!=typeof self?function(e,t){for(var r,n=null==e.ownerDocument?e:e.ownerDocument,a=document.createNSResolver(null==e.ownerDocument?e.documentElement:e.ownerDocument.documentElement),i=n.evaluate(t,e,a,XPathResult.ANY_TYPE,null),s=[];r=i.iterateNext();)s.push(r);return s}:V;function j(e){return e=e.replace(/\r\n/g,"\n").replace(/\r/g,"\n"),(new DOMParser).parseFromString(e,D)}function K(e,t){var r=_(e,t);return r&&r.length>0?r[0]:null}function M(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(e&&e.nodeType===O.Element){var r=e;r.namespaceURI&&"http://www.w3.org/XML/1998/namespace"!==r.namespaceURI&&!t[r.prefix||""]&&(t[r.prefix?r.prefix:""]=e.namespaceURI);for(var n=0;n<e.childNodes.length;n++){var a=e.childNodes.item(n);a&&a.nodeType===O.Element&&M(a,t)}}}function X(e){var t={};return M(e,t),t}function G(e){for(var t=arguments.length,r=new Array(t>1?t-1:0),n=1;n<t;n++)r[n-1]=arguments[n];for(var a=arguments[0],i=1;i<arguments.length;i++){var s=arguments[i];for(var o in s)s.hasOwnProperty(o)&&(a[o]=s[o])}return a}function q(e,t){return e&&e.nodeType===t}function F(e){return q(e,O.Element)}function J(e){return q(e,O.Document)}var W={get:function(e){if(e)return U.ToBase64(e)},set:function(e){return U.FromBase64(e)}},z={get:function(e){return e?e.toString():"0"},set:function(e){return Number(e)}},Q="xml_root",Y=function(){function e(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};if(a(this,e),this.prefix=this.GetStatic().prefix||null,this.localName=this.GetStatic().localName,this.namespaceURI=this.GetStatic().namespaceURI,t)for(var r=0,n=Object.entries(t);r<n.length;r++){var i=f(n[r],2),s=i[0],o=i[1];void 0!==o&&(this[s]=o)}}return s(e,[{key:"HasChanged",value:function(){var e=this.GetStatic();if(e.items)for(var t in e.items)if(e.items.hasOwnProperty(t)){var r=e.items[t],n=this[t];if(r.parser&&n&&n.HasChanged())return!0}return null===this.element}},{key:"GetXml",value:function(t){if(!t&&!this.HasChanged())return this.element||null;var r=this.CreateDocument(),n=this.CreateElement(),a=this.GetStatic(),i=this.localName;if(a.items)for(var s in a.items)if(a.items.hasOwnProperty(s)){var o=this[s],u=a.items[s];switch(u.type){case k:var l=u,c=l.converter?l.converter.get(o):o;if(l.required&&null==c)throw new R(x.CONTENT_MISSING,i);(l.defaultValue!==o||l.required)&&(n.textContent=c);break;case b:var h=u,m=h.converter?h.converter.get(o):o;if(h.required&&null==m)throw new R(x.ATTRIBUTE_MISSING,h.localName,i);(h.defaultValue!==o||h.required)&&(h.namespaceURI?n.setAttributeNS(h.namespaceURI,h.localName,m):n.setAttribute(h.localName,m));break;case p:var f=u,v=null;if(f.parser){if(f.required&&!o||f.minOccurs&&!o.Count)throw new R(x.ELEMENT_MISSING,o.localName,i);o&&(v=o.GetXml(void 0===o.element&&(f.required||o.Count)))}else{var g=f.converter?f.converter.get(o):o;if(f.required&&void 0===g)throw new R(x.ELEMENT_MISSING,f.localName,i);if(o!==f.defaultValue||f.required)if(v=f.namespaceURI?r.createElementNS(f.namespaceURI,"".concat(f.prefix?f.prefix+":":"").concat(f.localName)):r.createElement("".concat(f.prefix?f.prefix+":":"").concat(f.localName)),Array.isArray(g)){var d,w=y(g);try{for(w.s();!(d=w.n()).done;){var S=d.value,A=S instanceof e?S.GetXml(!0):S;null!==A&&v.appendChild(A)}}catch(e){w.e(e)}finally{w.f()}}else g instanceof e?v.appendChild(g.GetXml(!0)):v.textContent=g}if(v)if(f.noRoot){for(var C=[],N=0;N<v.childNodes.length;N++){var B=v.childNodes.item(N);F(B)&&C.push(B)}if(C.length<f.minOccurs||C.length>f.maxOccurs)throw new R(x.COLLECTION_LIMIT,o.localName,a.localName);C.forEach((function(e){return n.appendChild(e.cloneNode(!0))}))}else{if(v.childNodes.length<f.minOccurs||v.childNodes.length>f.maxOccurs)throw new R(x.COLLECTION_LIMIT,o.localName,a.localName);n.appendChild(v)}}}return this.OnGetXml(n),this.element=n,n}},{key:"LoadXml",value:function(e){var t,r=this;"string"==typeof e?t=j(e).documentElement:t=e;if(!t)throw new R(x.PARAM_REQUIRED,"element");var n=this.GetStatic(),a=this.localName;if(t.localName!==a||t.namespaceURI!=this.NamespaceURI)throw new R(x.ELEMENT_MALFORMED,a);if(n.items)for(var i in n.items)if(n.items.hasOwnProperty(i)){var s=n.items[i];switch(s.type){case k:var o=s;if(o.required&&!t.textContent)throw new R(x.CONTENT_MISSING,a);if(t.textContent){var u=o.converter?o.converter.set(t.textContent):t.textContent;r[i]=u}else r[i]=o.defaultValue;break;case b:var l=s,c=void 0,h=void 0;if(!l.localName)throw new R(x.PARAM_REQUIRED,"localName");if(l.namespaceURI?(c=t.hasAttributeNS.bind(t,l.namespaceURI,l.localName),h=t.getAttributeNS.bind(t,l.namespaceURI,l.localName)):(c=t.hasAttribute.bind(t,l.localName),h=t.getAttribute.bind(t,l.localName)),l.required&&!c())throw new R(x.ATTRIBUTE_MISSING,l.localName,a);if(c()){var m=l.converter?l.converter.set(h()):h();r[i]=m}else r[i]=l.defaultValue;break;case p:var f=s;if(f.noRoot){if(!f.parser)throw new R(x.XML_EXCEPTION,"Schema for '".concat(f.localName,"' with flag noRoot must have 'parser'"));var v=new f.parser;if(!(v instanceof Z))throw new R(x.XML_EXCEPTION,"Schema for '".concat(f.localName,"' with flag noRoot must have 'parser' like instance of XmlCollection"));if(v.OnLoadXml(t),delete v.element,v.Count<f.minOccurs||v.Count>f.maxOccurs)throw new R(x.COLLECTION_LIMIT,f.parser.localName,a);r[i]=v;continue}for(var g=null,d=0;d<t.childNodes.length;d++){var y=t.childNodes.item(d);if(F(y)){var w=y;if(w.localName===f.localName&&w.namespaceURI==f.namespaceURI){g=w;break}}}if(f.required&&!g)throw new R(x.ELEMENT_MISSING,f.parser?f.parser.localName:f.localName,a);if(f.parser){if(g){var S=new f.parser;S.localName=f.localName,S.namespaceURI=f.namespaceURI,r[i]=S,S.LoadXml(g)}}else if(g){var A=f.converter?f.converter.set(g.textContent):g.textContent;r[i]=A}else r[i]=f.defaultValue}}this.OnLoadXml(t),this.prefix=t.prefix||"",this.element=t}},{key:"toString",value:function(){var e=this.GetXml();return e?(new XMLSerializer).serializeToString(e):""}},{key:"GetElement",value:function(t){var r=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];if(!this.element)throw new R(x.NULL_PARAM,this.localName);return e.GetElement(this.element,t,r)}},{key:"GetChildren",value:function(t,r){if(!this.element)throw new R(x.NULL_PARAM,this.localName);return e.GetChildren(this.element,t,r||this.NamespaceURI||void 0)}},{key:"GetChild",value:function(t){var r=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];if(!this.element)throw new R(x.NULL_PARAM,this.localName);return e.GetChild(this.element,t,this.NamespaceURI||void 0,r)}},{key:"GetFirstChild",value:function(t,r){if(!this.element)throw new R(x.NULL_PARAM,this.localName);return e.GetFirstChild(this.element,t,r)}},{key:"GetAttribute",value:function(t,r){var n=!(arguments.length>2&&void 0!==arguments[2])||arguments[2];if(!this.element)throw new R(x.NULL_PARAM,this.localName);return e.GetAttribute(this.element,t,r,n)}},{key:"IsEmpty",value:function(){return void 0===this.Element}},{key:"OnLoadXml",value:function(e){}},{key:"GetStatic",value:function(){return this.constructor}},{key:"GetPrefix",value:function(){return this.Prefix?this.prefix+":":""}},{key:"OnGetXml",value:function(e){}},{key:"CreateElement",value:function(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null,n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:null;e||(e=this.CreateDocument()),t=t||this.localName,r=r||this.NamespaceURI;var a=((n=n||this.prefix)?"".concat(n,":"):"")+t,i=r?e.createElementNS(r,a):e.createElement(a);return e.importNode(i,!0),i}},{key:"CreateDocument",value:function(){return e.CreateDocument(this.localName,this.NamespaceURI,this.Prefix)}},{key:"Element",get:function(){return this.element}},{key:"Prefix",get:function(){return this.prefix},set:function(e){this.prefix=e}},{key:"LocalName",get:function(){return this.localName}},{key:"NamespaceURI",get:function(){return this.namespaceURI||null}}],[{key:"LoadXml",value:function(e){var t=new this;return t.LoadXml(e),t}},{key:"GetElement",value:function(e,t){var r=!(arguments.length>2&&void 0!==arguments[2])||arguments[2],n=e.getElementsByTagName(t);if(r&&0===n.length)throw new R(x.ELEMENT_MISSING,t,e.localName);return n[0]||null}},{key:"GetAttribute",value:function(e,t,r){var n=!(arguments.length>3&&void 0!==arguments[3])||arguments[3];if(e.hasAttribute(t))return e.getAttribute(t);if(n)throw new R(x.ATTRIBUTE_MISSING,t,e.localName);return r}},{key:"GetElementById",value:function(e,t){if(null==e||null==t)return null;var r=null;return J(e)&&(r=e.getElementById(t)),null==r&&null==(r=K(e,"//*[@Id='".concat(t,"']")))&&null==(r=K(e,"//*[@ID='".concat(t,"']")))&&(r=K(e,"//*[@id='".concat(t,"']"))),r}},{key:"CreateDocument",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:Q,t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null,r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null,n="",a="",i="";r&&(n=r+":",a=":"+r),t&&(i=" xmlns".concat(a,'="').concat(t,'"'));var s="".concat(n).concat(e),o=(new DOMParser).parseFromString("<".concat(s).concat(i,"></").concat(s,">"),D);return o}},{key:"GetChildren",value:function(e,t,r){e=J(e)?e.documentElement:e;for(var n=[],a=0;a<e.childNodes.length;a++){var i=e.childNodes[a];!F(i)||i.localName!==t||i.namespaceURI!==r&&r||n.push(i)}return n}},{key:"GetFirstChild",value:function(e,t,r){e=J(e)?e.documentElement:e;for(var n=0;n<e.childNodes.length;n++){var a=e.childNodes[n];if(F(a)&&a.localName===t&&(a.namespaceURI===r||!r))return a}return null}},{key:"GetChild",value:function(e,t,r){for(var n=!(arguments.length>3&&void 0!==arguments[3])||arguments[3],a=0;a<e.childNodes.length;a++){var i=e.childNodes[a];if(F(i)&&i.localName===t&&(i.namespaceURI===r||!r))return i}if(n)throw new R(x.ELEMENT_MISSING,t,e.localName);return null}}]),e}(),Z=function(e){o(r,e);var t=h(r);function r(){var e;return a(this,r),(e=t.apply(this,arguments)).MaxOccurs=Number.MAX_VALUE,e.MinOccurs=0,e.items=[],e}return s(r,[{key:"HasChanged",value:function(){var e=m(u(r.prototype),"HasChanged",this).call(this),t=this.Some((function(e){return e.HasChanged()}));return e||t}},{key:"Item",value:function(e){return this.items[e]||null}},{key:"Add",value:function(e){this.items.push(e),this.element=null}},{key:"Pop",value:function(){return this.element=null,this.items.pop()}},{key:"RemoveAt",value:function(e){this.items=this.items.filter((function(t,r){return r!==e})),this.element=null}},{key:"Clear",value:function(){this.items=new Array,this.element=null}},{key:"GetIterator",value:function(){return this.items}},{key:"ForEach",value:function(e){this.GetIterator().forEach(e)}},{key:"Map",value:function(e){return new I(this.GetIterator().map(e))}},{key:"Filter",value:function(e){return new I(this.GetIterator().filter(e))}},{key:"Sort",value:function(e){return new I(this.GetIterator().sort(e))}},{key:"Every",value:function(e){return this.GetIterator().every(e)}},{key:"Some",value:function(e){return this.GetIterator().some(e)}},{key:"IsEmpty",value:function(){return 0===this.Count}},{key:"OnGetXml",value:function(e){var t,r=y(this.GetIterator());try{for(r.s();!(t=r.n()).done;){var n=t.value.GetXml();n&&e.appendChild(n)}}catch(e){r.e(e)}finally{r.f()}}},{key:"OnLoadXml",value:function(e){var t=this.GetStatic();if(!t.parser)throw new R(x.XML_EXCEPTION,"".concat(t.localName," doesn't have required 'parser' in @XmlElement"));for(var r=0;r<e.childNodes.length;r++){var n=e.childNodes.item(r);if(F(n)&&n.localName===t.parser.localName&&n.namespaceURI==t.namespaceURI){var a=n,i=new t.parser;i.LoadXml(a),this.Add(i)}}}},{key:"Count",get:function(){return this.items.length}}]),r}(Y),$=function(e){o(r,e);var t=h(r);function r(){return a(this,r),t.apply(this,arguments)}return s(r,[{key:"Add",value:function(e){e.prefix=e.prefix||"",e.namespace=e.namespace||"",m(u(r.prototype),"Add",this).call(this,e)}},{key:"GetPrefix",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:this.Count-1,r=this.Count-1;e=e||"",t>r&&(t=r);for(var n=t;n>=0;n--){var a=this.items[n];if(a.prefix===e)return a}return null}},{key:"GetNamespace",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:this.Count-1,r=this.Count-1;e=e||"",t>r&&(t=r);for(var n=t;n>=0;n--){var a=this.items[n];if(a.namespace===e)return a}return null}}]),r}(I);function ee(e,t){var r=0;if(1===e.length)return e[0];for(var n=e.length-1;n>=0;n--)r+=e[e.length-1-n]*Math.pow(2,t*n);return r}function te(e,t){for(var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:-1,n=r,a=e,i=0,s=Math.pow(2,t),o=1;o<8;o++){if(e<s){var u=void 0;if(n<0)u=new ArrayBuffer(o),i=o;else{if(n<o)return new ArrayBuffer(0);u=new ArrayBuffer(n),i=n}for(var l=new Uint8Array(u),c=o-1;c>=0;c--){var h=Math.pow(2,c*t);l[i-c-1]=Math.floor(a/h),a-=l[i-c-1]*h}return u}s*=Math.pow(2,t)}return new ArrayBuffer(0)}var re="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",ne="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=";var ae=Math.log(2);var ie,se,oe=function(e){if(e.__esModule)return e;var t=Object.defineProperty({},"__esModule",{value:!0});return Object.keys(e).forEach((function(r){var n=Object.getOwnPropertyDescriptor(e,r);Object.defineProperty(t,r,n.get?n:{enumerable:!0,get:function(){return e[r]}})})),t}(Object.freeze({__proto__:null,getUTCDate:function(e){return new Date(e.getTime()+6e4*e.getTimezoneOffset())},getParametersValue:function(e,t,r){return e instanceof Object==!1?r:t in e?e[t]:r},bufferToHexCodes:function(e){var t,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:e.byteLength-r,a=arguments.length>3&&void 0!==arguments[3]&&arguments[3],i="",s=y(new Uint8Array(e,r,n));try{for(s.s();!(t=s.n()).done;){var o=t.value,u=o.toString(16).toUpperCase();1===u.length&&(i+="0"),i+=u,a&&(i+=" ")}}catch(e){s.e(e)}finally{s.f()}return i.trim()},checkBufferParams:function(e,t,r,n){return t instanceof ArrayBuffer==!1?(e.error='Wrong parameter: inputBuffer must be "ArrayBuffer"',!1):0===t.byteLength?(e.error="Wrong parameter: inputBuffer has zero length",!1):r<0?(e.error="Wrong parameter: inputOffset less than zero",!1):n<0?(e.error="Wrong parameter: inputLength less than zero",!1):!(t.byteLength-r-n<0)||(e.error="End of input reached before message was fully decoded (inconsistent offset and length values)",!1)},utilFromBase:ee,utilToBase:te,utilConcatBuf:function(){for(var e=0,t=0,r=arguments.length,n=new Array(r),a=0;a<r;a++)n[a]=arguments[a];for(var i=0,s=n;i<s.length;i++){var o=s[i];e+=o.byteLength}for(var u=new ArrayBuffer(e),l=new Uint8Array(u),c=0,h=n;c<h.length;c++){var m=h[c];l.set(new Uint8Array(m),t),t+=m.byteLength}return u},utilConcatView:function(){for(var e=0,t=0,r=arguments.length,n=new Array(r),a=0;a<r;a++)n[a]=arguments[a];for(var i=0,s=n;i<s.length;i++){var o=s[i];e+=o.length}for(var u=new ArrayBuffer(e),l=new Uint8Array(u),c=0,h=n;c<h.length;c++){var m=h[c];l.set(m,t),t+=m.length}return l},utilDecodeTC:function(){var e=new Uint8Array(this.valueHex);if(this.valueHex.byteLength>=2){var t=255===e[0]&&128&e[1],r=0===e[0]&&0==(128&e[1]);(t||r)&&this.warnings.push("Needlessly long format")}for(var n=new ArrayBuffer(this.valueHex.byteLength),a=new Uint8Array(n),i=0;i<this.valueHex.byteLength;i++)a[i]=0;a[0]=128&e[0];for(var s=ee(a,8),o=new ArrayBuffer(this.valueHex.byteLength),u=new Uint8Array(o),l=0;l<this.valueHex.byteLength;l++)u[l]=e[l];return u[0]&=127,ee(u,8)-s},utilEncodeTC:function(e){for(var t=e<0?-1*e:e,r=128,n=1;n<8;n++){if(t<=r){if(e<0){var a=te(r-t,8,n);return new Uint8Array(a)[0]|=128,a}var i=te(t,8,n),s=new Uint8Array(i);if(128&s[0]){var o=i.slice(0),u=new Uint8Array(o);i=new ArrayBuffer(i.byteLength+1),s=new Uint8Array(i);for(var l=0;l<o.byteLength;l++)s[l+1]=u[l];s[0]=0}return i}r*=Math.pow(2,8)}return new ArrayBuffer(0)},isEqualBuffer:function(e,t){if(e.byteLength!==t.byteLength)return!1;for(var r=new Uint8Array(e),n=new Uint8Array(t),a=0;a<r.length;a++)if(r[a]!==n[a])return!1;return!0},padNumber:function(e,t){var r=e.toString(10);if(t<r.length)return"";for(var n=t-r.length,a=new Array(n),i=0;i<n;i++)a[i]="0";return a.join("").concat(r)},toBase64:function(e){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1],r=arguments.length>2&&void 0!==arguments[2]&&arguments[2],n=arguments.length>3&&void 0!==arguments[3]&&arguments[3],a=0,i=0,s=0,o="",u=t?ne:re;if(n){for(var l=0,c=0;c<e.length;c++)if(0!==e.charCodeAt(c)){l=c;break}e=e.slice(l)}for(;a<e.length;){var h=e.charCodeAt(a++);a>=e.length&&(i=1);var m=e.charCodeAt(a++);a>=e.length&&(s=1);var f=e.charCodeAt(a++),v=h>>2,g=(3&h)<<4|m>>4,d=(15&m)<<2|f>>6,y=63&f;1===i?d=y=64:1===s&&(y=64),o+=r?64===d?"".concat(u.charAt(v)).concat(u.charAt(g)):64===y?"".concat(u.charAt(v)).concat(u.charAt(g)).concat(u.charAt(d)):"".concat(u.charAt(v)).concat(u.charAt(g)).concat(u.charAt(d)).concat(u.charAt(y)):"".concat(u.charAt(v)).concat(u.charAt(g)).concat(u.charAt(d)).concat(u.charAt(y))}return o},fromBase64:function(e){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1],r=arguments.length>2&&void 0!==arguments[2]&&arguments[2],n=t?ne:re;function a(e){for(var t=0;t<64;t++)if(n.charAt(t)===e)return t;return 64}function i(e){return 64===e?0:e}for(var s=0,o="";s<e.length;){var u=a(e.charAt(s++)),l=s>=e.length?0:a(e.charAt(s++)),c=s>=e.length?0:a(e.charAt(s++)),h=s>=e.length?0:a(e.charAt(s++)),m=i(u)<<2|i(l)>>4,f=(15&i(l))<<4|i(c)>>2,v=(3&i(c))<<6|i(h);o+=String.fromCharCode(m),64!==c&&(o+=String.fromCharCode(f)),64!==h&&(o+=String.fromCharCode(v))}if(r){for(var g=o.length,d=-1,y=g-1;y>=0;y--)if(0!==o.charCodeAt(y)){d=y;break}o=-1!==d?o.slice(0,d+1):""}return o},arrayBufferToString:function(e){var t,r="",n=y(new Uint8Array(e));try{for(n.s();!(t=n.n()).done;){var a=t.value;r+=String.fromCharCode(a)}}catch(e){n.e(e)}finally{n.f()}return r},stringToArrayBuffer:function(e){for(var t=e.length,r=new ArrayBuffer(t),n=new Uint8Array(r),a=0;a<t;a++)n[a]=e.charCodeAt(a);return r},nearestPowerOf2:function(e){var t=Math.log(e)/ae,r=Math.floor(t),n=Math.round(t);return r===n?r:n},clearProps:function(e,t){var r,n=y(t);try{for(n.s();!(r=n.n()).done;){delete e[r.value]}}catch(e){n.e(e)}finally{n.f()}}})),ue=(function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.fromBER=de,t.compareSchema=ye,t.verifySchema=function(e,t){if(t instanceof Object==0)return{verified:!1,result:{error:"Wrong ASN.1 schema type"}};var r=de(e);return-1===r.offset?{verified:!1,result:r.result}:ye(r.result,r.result,t)},t.fromJSON=function(e){},t.RawData=t.Repeated=t.Any=t.Choice=t.TIME=t.Duration=t.DateTime=t.TimeOfDay=t.DATE=t.GeneralizedTime=t.UTCTime=t.CharacterString=t.GeneralString=t.VisibleString=t.GraphicString=t.IA5String=t.VideotexString=t.TeletexString=t.PrintableString=t.NumericString=t.UniversalString=t.BmpString=t.RelativeObjectIdentifier=t.Utf8String=t.ObjectIdentifier=t.Enumerated=t.Integer=t.BitString=t.OctetString=t.Null=t.Set=t.Sequence=t.Boolean=t.EndOfContent=t.Constructed=t.Primitive=t.BaseBlock=t.ValueBlock=t.HexBlock=void 0;var r=[new Uint8Array([1])],n="0123456789",i=function(){function e(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};a(this,e),this.blockLength=(0,oe.getParametersValue)(t,"blockLength",0),this.error=(0,oe.getParametersValue)(t,"error",""),this.warnings=(0,oe.getParametersValue)(t,"warnings",[]),this.valueBeforeDecode="valueBeforeDecode"in t?t.valueBeforeDecode.slice(0):new ArrayBuffer(0)}return s(e,[{key:"toJSON",value:function(){return{blockName:this.constructor.blockName(),blockLength:this.blockLength,error:this.error,warnings:this.warnings,valueBeforeDecode:(0,oe.bufferToHexCodes)(this.valueBeforeDecode,0,this.valueBeforeDecode.byteLength)}}}],[{key:"blockName",value:function(){return"baseBlock"}}]),e}(),l=function(e){return function(e){o(r,e);var t=h(r);function r(){var e,n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return a(this,r),(e=t.call(this,n)).isHexOnly=(0,oe.getParametersValue)(n,"isHexOnly",!1),e.valueHex="valueHex"in n?n.valueHex.slice(0):new ArrayBuffer(0),e}return s(r,[{key:"fromBER",value:function(e,t,r){return!1===(0,oe.checkBufferParams)(this,e,t,r)?-1:0===new Uint8Array(e,t,r).length?(this.warnings.push("Zero buffer length"),t):(this.valueHex=e.slice(t,t+r),this.blockLength=r,t+r)}},{key:"toBER",value:function(){var e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];return!0!==this.isHexOnly?(this.error='Flag "isHexOnly" is not set, abort',new ArrayBuffer(0)):!0===e?new ArrayBuffer(this.valueHex.byteLength):this.valueHex.slice(0)}},{key:"toJSON",value:function(){var e={};try{e=m(u(r.prototype),"toJSON",this).call(this)}catch(e){}return e.blockName=this.constructor.blockName(),e.isHexOnly=this.isHexOnly,e.valueHex=(0,oe.bufferToHexCodes)(this.valueHex,0,this.valueHex.byteLength),e}}],[{key:"blockName",value:function(){return"hexBlock"}}]),r}(e)};t.HexBlock=l;var c=function(e){o(r,e);var t=h(r);function r(){var e,n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return a(this,r),e=t.call(this),"idBlock"in n?(e.isHexOnly=(0,oe.getParametersValue)(n.idBlock,"isHexOnly",!1),e.valueHex=(0,oe.getParametersValue)(n.idBlock,"valueHex",new ArrayBuffer(0)),e.tagClass=(0,oe.getParametersValue)(n.idBlock,"tagClass",-1),e.tagNumber=(0,oe.getParametersValue)(n.idBlock,"tagNumber",-1),e.isConstructed=(0,oe.getParametersValue)(n.idBlock,"isConstructed",!1)):(e.tagClass=-1,e.tagNumber=-1,e.isConstructed=!1),e}return s(r,[{key:"toBER",value:function(){var e,t,r=arguments.length>0&&void 0!==arguments[0]&&arguments[0],n=0;switch(this.tagClass){case 1:n|=0;break;case 2:n|=64;break;case 3:n|=128;break;case 4:n|=192;break;default:return this.error="Unknown tag class",new ArrayBuffer(0)}if(this.isConstructed&&(n|=32),this.tagNumber<31&&!this.isHexOnly){if(e=new ArrayBuffer(1),t=new Uint8Array(e),!r){var a=this.tagNumber;n|=a&=31,t[0]=n}return e}if(!1===this.isHexOnly){var i=(0,oe.utilToBase)(this.tagNumber,7),s=new Uint8Array(i),o=i.byteLength;if(e=new ArrayBuffer(o+1),(t=new Uint8Array(e))[0]=31|n,!r){for(var u=0;u<o-1;u++)t[u+1]=128|s[u];t[o]=s[o-1]}return e}if(e=new ArrayBuffer(this.valueHex.byteLength+1),(t=new Uint8Array(e))[0]=31|n,!1===r){for(var l=new Uint8Array(this.valueHex),c=0;c<l.length-1;c++)t[c+1]=128|l[c];t[this.valueHex.byteLength]=l[l.length-1]}return e}},{key:"fromBER",value:function(e,t,r){if(!1===(0,oe.checkBufferParams)(this,e,t,r))return-1;var n=new Uint8Array(e,t,r);if(0===n.length)return this.error="Zero buffer length",-1;switch(192&n[0]){case 0:this.tagClass=1;break;case 64:this.tagClass=2;break;case 128:this.tagClass=3;break;case 192:this.tagClass=4;break;default:return this.error="Unknown tag class",-1}this.isConstructed=32==(32&n[0]),this.isHexOnly=!1;var a=31&n[0];if(31!==a)this.tagNumber=a,this.blockLength=1;else{var i=1;this.valueHex=new ArrayBuffer(255);for(var s=255,o=new Uint8Array(this.valueHex);128&n[i];){if(o[i-1]=127&n[i],++i>=n.length)return this.error="End of input reached before message was fully decoded",-1;if(i===s){s+=255;for(var u=new ArrayBuffer(s),l=new Uint8Array(u),c=0;c<o.length;c++)l[c]=o[c];this.valueHex=new ArrayBuffer(s),o=new Uint8Array(this.valueHex)}}this.blockLength=i+1,o[i-1]=127&n[i];for(var h=new ArrayBuffer(i),m=new Uint8Array(h),f=0;f<i;f++)m[f]=o[f];this.valueHex=new ArrayBuffer(i),(o=new Uint8Array(this.valueHex)).set(m),this.blockLength<=9?this.tagNumber=(0,oe.utilFromBase)(o,7):(this.isHexOnly=!0,this.warnings.push("Tag too long, represented as hex-coded"))}if(1===this.tagClass&&this.isConstructed)switch(this.tagNumber){case 1:case 2:case 5:case 6:case 9:case 13:case 14:case 23:case 24:case 31:case 32:case 33:case 34:return this.error="Constructed encoding used for primitive type",-1}return t+this.blockLength}},{key:"toJSON",value:function(){var e={};try{e=m(u(r.prototype),"toJSON",this).call(this)}catch(e){}return e.blockName=this.constructor.blockName(),e.tagClass=this.tagClass,e.tagNumber=this.tagNumber,e.isConstructed=this.isConstructed,e}}],[{key:"blockName",value:function(){return"identificationBlock"}}]),r}(l(i)),f=function(e){o(r,e);var t=h(r);function r(){var e,n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return a(this,r),e=t.call(this),"lenBlock"in n?(e.isIndefiniteForm=(0,oe.getParametersValue)(n.lenBlock,"isIndefiniteForm",!1),e.longFormUsed=(0,oe.getParametersValue)(n.lenBlock,"longFormUsed",!1),e.length=(0,oe.getParametersValue)(n.lenBlock,"length",0)):(e.isIndefiniteForm=!1,e.longFormUsed=!1,e.length=0),e}return s(r,[{key:"fromBER",value:function(e,t,r){if(!1===(0,oe.checkBufferParams)(this,e,t,r))return-1;var n=new Uint8Array(e,t,r);if(0===n.length)return this.error="Zero buffer length",-1;if(255===n[0])return this.error="Length block 0xFF is reserved by standard",-1;if(this.isIndefiniteForm=128===n[0],!0===this.isIndefiniteForm)return this.blockLength=1,t+this.blockLength;if(this.longFormUsed=!!(128&n[0]),!1===this.longFormUsed)return this.length=n[0],this.blockLength=1,t+this.blockLength;var a=127&n[0];if(a>8)return this.error="Too big integer",-1;if(a+1>n.length)return this.error="End of input reached before message was fully decoded",-1;for(var i=new Uint8Array(a),s=0;s<a;s++)i[s]=n[s+1];return 0===i[a-1]&&this.warnings.push("Needlessly long encoded length"),this.length=(0,oe.utilFromBase)(i,8),this.longFormUsed&&this.length<=127&&this.warnings.push("Unneccesary usage of long length form"),this.blockLength=a+1,t+this.blockLength}},{key:"toBER",value:function(){var e,t,r=arguments.length>0&&void 0!==arguments[0]&&arguments[0];if(this.length>127&&(this.longFormUsed=!0),this.isIndefiniteForm)return e=new ArrayBuffer(1),!1===r&&((t=new Uint8Array(e))[0]=128),e;if(!0===this.longFormUsed){var n=(0,oe.utilToBase)(this.length,8);if(n.byteLength>127)return this.error="Too big length",new ArrayBuffer(0);if(e=new ArrayBuffer(n.byteLength+1),!0===r)return e;var a=new Uint8Array(n);(t=new Uint8Array(e))[0]=128|n.byteLength;for(var i=0;i<n.byteLength;i++)t[i+1]=a[i];return e}return e=new ArrayBuffer(1),!1===r&&((t=new Uint8Array(e))[0]=this.length),e}},{key:"toJSON",value:function(){var e={};try{e=m(u(r.prototype),"toJSON",this).call(this)}catch(e){}return e.blockName=this.constructor.blockName(),e.isIndefiniteForm=this.isIndefiniteForm,e.longFormUsed=this.longFormUsed,e.length=this.length,e}}],[{key:"blockName",value:function(){return"lengthBlock"}}]),r}(i),v=function(e){o(r,e);var t=h(r);function r(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return a(this,r),t.call(this,e)}return s(r,[{key:"fromBER",value:function(e,t,r){throw TypeError('User need to make a specific function in a class which extends "ValueBlock"')}},{key:"toBER",value:function(){throw TypeError('User need to make a specific function in a class which extends "ValueBlock"')}}],[{key:"blockName",value:function(){return"valueBlock"}}]),r}(i);t.ValueBlock=v;var g=function(e){o(r,e);var t=h(r);function r(){var e,n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:v;return a(this,r),e=t.call(this,n),"name"in n&&(e.name=n.name),"optional"in n&&(e.optional=n.optional),"primitiveSchema"in n&&(e.primitiveSchema=n.primitiveSchema),e.idBlock=new c(n),e.lenBlock=new f(n),e.valueBlock=new i(n),e}return s(r,[{key:"fromBER",value:function(e,t,r){var n=this.valueBlock.fromBER(e,t,!0===this.lenBlock.isIndefiniteForm?r:this.lenBlock.length);return-1===n?(this.error=this.valueBlock.error,n):(0===this.idBlock.error.length&&(this.blockLength+=this.idBlock.blockLength),0===this.lenBlock.error.length&&(this.blockLength+=this.lenBlock.blockLength),0===this.valueBlock.error.length&&(this.blockLength+=this.valueBlock.blockLength),n)}},{key:"toBER",value:function(){var e,t=arguments.length>0&&void 0!==arguments[0]&&arguments[0],r=this.idBlock.toBER(t),n=this.valueBlock.toBER(!0);this.lenBlock.length=n.byteLength;var a,i=this.lenBlock.toBER(t);if(e=(0,oe.utilConcatBuf)(r,i),a=!1===t?this.valueBlock.toBER(t):new ArrayBuffer(this.lenBlock.length),e=(0,oe.utilConcatBuf)(e,a),!0===this.lenBlock.isIndefiniteForm){var s=new ArrayBuffer(2);if(!1===t){var o=new Uint8Array(s);o[0]=0,o[1]=0}e=(0,oe.utilConcatBuf)(e,s)}return e}},{key:"toJSON",value:function(){var e={};try{e=m(u(r.prototype),"toJSON",this).call(this)}catch(e){}return e.idBlock=this.idBlock.toJSON(),e.lenBlock=this.lenBlock.toJSON(),e.valueBlock=this.valueBlock.toJSON(),"name"in this&&(e.name=this.name),"optional"in this&&(e.optional=this.optional),"primitiveSchema"in this&&(e.primitiveSchema=this.primitiveSchema.toJSON()),e}}],[{key:"blockName",value:function(){return"BaseBlock"}}]),r}(i);t.BaseBlock=g;var d=function(e){o(r,e);var t=h(r);function r(){var e,n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return a(this,r),(e=t.call(this,n)).valueHex="valueHex"in n?n.valueHex.slice(0):new ArrayBuffer(0),e.isHexOnly=(0,oe.getParametersValue)(n,"isHexOnly",!0),e}return s(r,[{key:"fromBER",value:function(e,t,r){if(!1===(0,oe.checkBufferParams)(this,e,t,r))return-1;var n=new Uint8Array(e,t,r);if(0===n.length)return this.warnings.push("Zero buffer length"),t;this.valueHex=new ArrayBuffer(n.length);for(var a=new Uint8Array(this.valueHex),i=0;i<n.length;i++)a[i]=n[i];return this.blockLength=r,t+r}},{key:"toBER",value:function(){return this.valueHex.slice(0)}},{key:"toJSON",value:function(){var e={};try{e=m(u(r.prototype),"toJSON",this).call(this)}catch(e){}return e.valueHex=(0,oe.bufferToHexCodes)(this.valueHex,0,this.valueHex.byteLength),e.isHexOnly=this.isHexOnly,e}}],[{key:"blockName",value:function(){return"PrimitiveValueBlock"}}]),r}(v),y=function(e){o(r,e);var t=h(r);function r(){var e,n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return a(this,r),(e=t.call(this,n,d)).idBlock.isConstructed=!1,e}return s(r,null,[{key:"blockName",value:function(){return"PRIMITIVE"}}]),r}(g);t.Primitive=y;var p=function(e){o(r,e);var t=h(r);function r(){var e,n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return a(this,r),(e=t.call(this,n)).value=(0,oe.getParametersValue)(n,"value",[]),e.isIndefiniteForm=(0,oe.getParametersValue)(n,"isIndefiniteForm",!1),e}return s(r,[{key:"fromBER",value:function(e,t,r){var n=t,a=r;if(!1===(0,oe.checkBufferParams)(this,e,t,r))return-1;if(0===new Uint8Array(e,t,r).length)return this.warnings.push("Zero buffer length"),t;for(var i,s,o=t;i=this.isIndefiniteForm,s=r,(!0===i?1:s)>0;){var u=ge(e,o,r);if(-1===u.offset)return this.error=u.result.error,this.warnings.concat(u.result.warnings),-1;if(o=u.offset,this.blockLength+=u.result.blockLength,r-=u.result.blockLength,this.value.push(u.result),!0===this.isIndefiniteForm&&u.result.constructor.blockName()===w.blockName())break}return!0===this.isIndefiniteForm&&(this.value[this.value.length-1].constructor.blockName()===w.blockName()?this.value.pop():this.warnings.push("No EndOfContent block encoded")),this.valueBeforeDecode=e.slice(n,n+a),o}},{key:"toBER",value:function(){for(var e=arguments.length>0&&void 0!==arguments[0]&&arguments[0],t=new ArrayBuffer(0),r=0;r<this.value.length;r++){var n=this.value[r].toBER(e);t=(0,oe.utilConcatBuf)(t,n)}return t}},{key:"toJSON",value:function(){var e={};try{e=m(u(r.prototype),"toJSON",this).call(this)}catch(e){}e.isIndefiniteForm=this.isIndefiniteForm,e.value=[];for(var t=0;t<this.value.length;t++)e.value.push(this.value[t].toJSON());return e}}],[{key:"blockName",value:function(){return"ConstructedValueBlock"}}]),r}(v),b=function(e){o(r,e);var t=h(r);function r(){var e,n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return a(this,r),(e=t.call(this,n,p)).idBlock.isConstructed=!0,e}return s(r,[{key:"fromBER",value:function(e,t,r){this.valueBlock.isIndefiniteForm=this.lenBlock.isIndefiniteForm;var n=this.valueBlock.fromBER(e,t,!0===this.lenBlock.isIndefiniteForm?r:this.lenBlock.length);return-1===n?(this.error=this.valueBlock.error,n):(0===this.idBlock.error.length&&(this.blockLength+=this.idBlock.blockLength),0===this.lenBlock.error.length&&(this.blockLength+=this.lenBlock.blockLength),0===this.valueBlock.error.length&&(this.blockLength+=this.valueBlock.blockLength),n)}}],[{key:"blockName",value:function(){return"CONSTRUCTED"}}]),r}(g);t.Constructed=b;var k=function(e){o(r,e);var t=h(r);function r(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return a(this,r),t.call(this,e)}return s(r,[{key:"fromBER",value:function(e,t,r){return t}},{key:"toBER",value:function(){return new ArrayBuffer(0)}}],[{key:"blockName",value:function(){return"EndOfContentValueBlock"}}]),r}(v),w=function(e){o(r,e);var t=h(r);function r(){var e,n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return a(this,r),(e=t.call(this,n,k)).idBlock.tagClass=1,e.idBlock.tagNumber=0,e}return s(r,null,[{key:"blockName",value:function(){return"EndOfContent"}}]),r}(g);t.EndOfContent=w;var S=function(e){o(r,e);var t=h(r);function r(){var e,n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};if(a(this,r),(e=t.call(this,n)).value=(0,oe.getParametersValue)(n,"value",!1),e.isHexOnly=(0,oe.getParametersValue)(n,"isHexOnly",!1),"valueHex"in n)e.valueHex=n.valueHex.slice(0);else if(e.valueHex=new ArrayBuffer(1),!0===e.value){var i=new Uint8Array(e.valueHex);i[0]=255}return e}return s(r,[{key:"fromBER",value:function(e,t,r){if(!1===(0,oe.checkBufferParams)(this,e,t,r))return-1;var n=new Uint8Array(e,t,r);r>1&&this.warnings.push("Boolean value encoded in more then 1 octet"),this.isHexOnly=!0,this.valueHex=new ArrayBuffer(n.length);for(var a=new Uint8Array(this.valueHex),i=0;i<n.length;i++)a[i]=n[i];return 0!==oe.utilDecodeTC.call(this)?this.value=!0:this.value=!1,this.blockLength=r,t+r}},{key:"toBER",value:function(){return this.valueHex}},{key:"toJSON",value:function(){var e={};try{e=m(u(r.prototype),"toJSON",this).call(this)}catch(e){}return e.value=this.value,e.isHexOnly=this.isHexOnly,e.valueHex=(0,oe.bufferToHexCodes)(this.valueHex,0,this.valueHex.byteLength),e}}],[{key:"blockName",value:function(){return"BooleanValueBlock"}}]),r}(v),A=function(e){o(r,e);var t=h(r);function r(){var e,n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return a(this,r),(e=t.call(this,n,S)).idBlock.tagClass=1,e.idBlock.tagNumber=1,e}return s(r,null,[{key:"blockName",value:function(){return"Boolean"}}]),r}(g);t.Boolean=A;var C=function(e){o(r,e);var t=h(r);function r(){var e,n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return a(this,r),(e=t.call(this,n)).idBlock.tagClass=1,e.idBlock.tagNumber=16,e}return s(r,null,[{key:"blockName",value:function(){return"Sequence"}}]),r}(b);t.Sequence=C;var N=function(e){o(r,e);var t=h(r);function r(){var e,n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return a(this,r),(e=t.call(this,n)).idBlock.tagClass=1,e.idBlock.tagNumber=17,e}return s(r,null,[{key:"blockName",value:function(){return"Set"}}]),r}(b);t.Set=N;var B=function(e){o(r,e);var t=h(r);function r(){var e,n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return a(this,r),(e=t.call(this,n,i)).idBlock.tagClass=1,e.idBlock.tagNumber=5,e}return s(r,[{key:"fromBER",value:function(e,t,r){return this.lenBlock.length>0&&this.warnings.push("Non-zero length of value block for Null type"),0===this.idBlock.error.length&&(this.blockLength+=this.idBlock.blockLength),0===this.lenBlock.error.length&&(this.blockLength+=this.lenBlock.blockLength),this.blockLength+=r,t+r>e.byteLength?(this.error="End of input reached before message was fully decoded (inconsistent offset and length values)",-1):t+r}},{key:"toBER",value:function(){var e=arguments.length>0&&void 0!==arguments[0]&&arguments[0],t=new ArrayBuffer(2);if(!0===e)return t;var r=new Uint8Array(t);return r[0]=5,r[1]=0,t}}],[{key:"blockName",value:function(){return"Null"}}]),r}(g);t.Null=B;var I=function(e){o(r,e);var t=h(r);function r(){var e,n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return a(this,r),(e=t.call(this,n)).isConstructed=(0,oe.getParametersValue)(n,"isConstructed",!1),e}return s(r,[{key:"fromBER",value:function(e,t,n){var a=0;if(!0===this.isConstructed){if(this.isHexOnly=!1,-1===(a=p.prototype.fromBER.call(this,e,t,n)))return a;for(var i=0;i<this.value.length;i++){var s=this.value[i].constructor.blockName();if(s===w.blockName()){if(!0===this.isIndefiniteForm)break;return this.error="EndOfContent is unexpected, OCTET STRING may consists of OCTET STRINGs only",-1}if(s!==P.blockName())return this.error="OCTET STRING may consists of OCTET STRINGs only",-1}}else this.isHexOnly=!0,a=m(u(r.prototype),"fromBER",this).call(this,e,t,n),this.blockLength=n;return a}},{key:"toBER",value:function(){var e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];if(!0===this.isConstructed)return p.prototype.toBER.call(this,e);var t=new ArrayBuffer(this.valueHex.byteLength);return!0===e||0===this.valueHex.byteLength?t:t=this.valueHex.slice(0)}},{key:"toJSON",value:function(){var e={};try{e=m(u(r.prototype),"toJSON",this).call(this)}catch(e){}return e.isConstructed=this.isConstructed,e.isHexOnly=this.isHexOnly,e.valueHex=(0,oe.bufferToHexCodes)(this.valueHex,0,this.valueHex.byteLength),e}}],[{key:"blockName",value:function(){return"OctetStringValueBlock"}}]),r}(l(p)),P=function(e){o(r,e);var t=h(r);function r(){var e,n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return a(this,r),(e=t.call(this,n,I)).idBlock.tagClass=1,e.idBlock.tagNumber=4,e}return s(r,[{key:"fromBER",value:function(e,t,n){return this.valueBlock.isConstructed=this.idBlock.isConstructed,this.valueBlock.isIndefiniteForm=this.lenBlock.isIndefiniteForm,0===n?(0===this.idBlock.error.length&&(this.blockLength+=this.idBlock.blockLength),0===this.lenBlock.error.length&&(this.blockLength+=this.lenBlock.blockLength),t):m(u(r.prototype),"fromBER",this).call(this,e,t,n)}},{key:"isEqual",value:function(e){return e instanceof r!=0&&JSON.stringify(this)===JSON.stringify(e)}}],[{key:"blockName",value:function(){return"OctetString"}}]),r}(g);t.OctetString=P;var E=function(e){o(r,e);var t=h(r);function r(){var e,n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return a(this,r),(e=t.call(this,n)).unusedBits=(0,oe.getParametersValue)(n,"unusedBits",0),e.isConstructed=(0,oe.getParametersValue)(n,"isConstructed",!1),e.blockLength=e.valueHex.byteLength,e}return s(r,[{key:"fromBER",value:function(e,t,r){if(0===r)return t;var n=-1;if(!0===this.isConstructed){if(-1===(n=p.prototype.fromBER.call(this,e,t,r)))return n;for(var a=0;a<this.value.length;a++){var i=this.value[a].constructor.blockName();if(i===w.blockName()){if(!0===this.isIndefiniteForm)break;return this.error="EndOfContent is unexpected, BIT STRING may consists of BIT STRINGs only",-1}if(i!==x.blockName())return this.error="BIT STRING may consists of BIT STRINGs only",-1;if(this.unusedBits>0&&this.value[a].valueBlock.unusedBits>0)return this.error='Usign of "unused bits" inside constructive BIT STRING allowed for least one only',-1;if(this.unusedBits=this.value[a].valueBlock.unusedBits,this.unusedBits>7)return this.error="Unused bits for BitString must be in range 0-7",-1}return n}if(!1===(0,oe.checkBufferParams)(this,e,t,r))return-1;var s=new Uint8Array(e,t,r);if(this.unusedBits=s[0],this.unusedBits>7)return this.error="Unused bits for BitString must be in range 0-7",-1;this.valueHex=new ArrayBuffer(s.length-1);for(var o=new Uint8Array(this.valueHex),u=0;u<r-1;u++)o[u]=s[u+1];return this.blockLength=s.length,t+r}},{key:"toBER",value:function(){var e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];if(!0===this.isConstructed)return p.prototype.toBER.call(this,e);if(!0===e)return new ArrayBuffer(this.valueHex.byteLength+1);if(0===this.valueHex.byteLength)return new ArrayBuffer(0);var t=new Uint8Array(this.valueHex),r=new ArrayBuffer(this.valueHex.byteLength+1),n=new Uint8Array(r);n[0]=this.unusedBits;for(var a=0;a<this.valueHex.byteLength;a++)n[a+1]=t[a];return r}},{key:"toJSON",value:function(){var e={};try{e=m(u(r.prototype),"toJSON",this).call(this)}catch(e){}return e.unusedBits=this.unusedBits,e.isConstructed=this.isConstructed,e.isHexOnly=this.isHexOnly,e.valueHex=(0,oe.bufferToHexCodes)(this.valueHex,0,this.valueHex.byteLength),e}}],[{key:"blockName",value:function(){return"BitStringValueBlock"}}]),r}(l(p)),x=function(e){o(r,e);var t=h(r);function r(){var e,n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return a(this,r),(e=t.call(this,n,E)).idBlock.tagClass=1,e.idBlock.tagNumber=3,e}return s(r,[{key:"fromBER",value:function(e,t,n){return 0===n?t:(this.valueBlock.isConstructed=this.idBlock.isConstructed,this.valueBlock.isIndefiniteForm=this.lenBlock.isIndefiniteForm,m(u(r.prototype),"fromBER",this).call(this,e,t,n))}},{key:"isEqual",value:function(e){return e instanceof r!=0&&JSON.stringify(this)===JSON.stringify(e)}}],[{key:"blockName",value:function(){return"BitString"}}]),r}(g);t.BitString=x;var R=function(e){o(i,e);var t=h(i);function i(){var e,r=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return a(this,i),e=t.call(this,r),"value"in r&&(e.valueDec=r.value),e}return s(i,[{key:"fromDER",value:function(e,t,r){var n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:0,a=this.fromBER(e,t,r);if(-1===a)return a;var i=new Uint8Array(this._valueHex);if(0===i[0]&&0!=(128&i[1])){var s=new ArrayBuffer(this._valueHex.byteLength-1),o=new Uint8Array(s);o.set(new Uint8Array(this._valueHex,1,this._valueHex.byteLength-1)),this._valueHex=s.slice(0)}else if(0!==n&&this._valueHex.byteLength<n){n-this._valueHex.byteLength>1&&(n=this._valueHex.byteLength+1);var u=new ArrayBuffer(n),l=new Uint8Array(u);l.set(i,n-this._valueHex.byteLength),this._valueHex=u.slice(0)}return a}},{key:"toDER",value:function(){var e=arguments.length>0&&void 0!==arguments[0]&&arguments[0],t=new Uint8Array(this._valueHex);switch(!0){case 0!=(128&t[0]):var r=new ArrayBuffer(this._valueHex.byteLength+1),n=new Uint8Array(r);n[0]=0,n.set(t,1),this._valueHex=r.slice(0);break;case 0===t[0]&&0==(128&t[1]):var a=new ArrayBuffer(this._valueHex.byteLength-1),i=new Uint8Array(a);i.set(new Uint8Array(this._valueHex,1,this._valueHex.byteLength-1)),this._valueHex=a.slice(0)}return this.toBER(e)}},{key:"fromBER",value:function(e,t,r){var n=m(u(i.prototype),"fromBER",this).call(this,e,t,r);return-1===n?n:(this.blockLength=r,t+r)}},{key:"toBER",value:function(){return this.valueHex.slice(0)}},{key:"toJSON",value:function(){var e={};try{e=m(u(i.prototype),"toJSON",this).call(this)}catch(e){}return e.valueDec=this.valueDec,e}},{key:"toString",value:function(){function e(e,t){for(var r=new Uint8Array([0]),n=new Uint8Array(e),a=new Uint8Array(t),i=n.slice(0),s=i.length-1,o=a.slice(0),u=o.length-1,l=0,c=0,h=u<s?s:u;h>=0;h--,c++){switch(!0){case c<o.length:l=i[s-c]+o[u-c]+r[0];break;default:l=i[s-c]+r[0]}switch(r[0]=l/10,!0){case c>=i.length:i=(0,oe.utilConcatView)(new Uint8Array([l%10]),i);break;default:i[s-c]=l%10}}return r[0]>0&&(i=(0,oe.utilConcatView)(r,i)),i.slice(0)}function t(e){if(e>=r.length)for(var t=r.length;t<=e;t++){for(var n=new Uint8Array([0]),a=r[t-1].slice(0),i=a.length-1;i>=0;i--){var s=new Uint8Array([(a[i]<<1)+n[0]]);n[0]=s[0]/10,a[i]=s[0]%10}n[0]>0&&(a=(0,oe.utilConcatView)(n,a)),r.push(a)}return r[e]}function a(e,t){for(var r,n=0,a=new Uint8Array(e),i=new Uint8Array(t),s=a.slice(0),o=s.length-1,u=i.slice(0),l=u.length-1,c=0,h=l;h>=0;h--,c++)switch(r=s[o-c]-u[l-c]-n,!0){case r<0:n=1,s[o-c]=r+10;break;default:n=0,s[o-c]=r}if(n>0)for(var m=o-l+1;m>=0;m--,c++){if(!((r=s[o-c]-n)<0)){n=0,s[o-c]=r;break}n=1,s[o-c]=r+10}return s.slice()}for(var i,s=8*this._valueHex.byteLength-1,o=new Uint8Array(8*this._valueHex.byteLength/3),u=0,l=new Uint8Array(this._valueHex),c="",h=!1,m=this._valueHex.byteLength-1;m>=0;m--){i=l[m];for(var f=0;f<8;f++){if(1==(1&i))switch(u){case s:o=a(t(u),o),c="-";break;default:o=e(o,t(u))}u++,i>>=1}}for(var v=0;v<o.length;v++)o[v]&&(h=!0),h&&(c+=n.charAt(o[v]));return!1===h&&(c+=n.charAt(0)),c}},{key:"valueHex",set:function(e){this._valueHex=e.slice(0),e.byteLength>=4?(this.warnings.push("Too big Integer for decoding, hex only"),this.isHexOnly=!0,this._valueDec=0):(this.isHexOnly=!1,e.byteLength>0&&(this._valueDec=oe.utilDecodeTC.call(this)))},get:function(){return this._valueHex}},{key:"valueDec",set:function(e){this._valueDec=e,this.isHexOnly=!1,this._valueHex=(0,oe.utilEncodeTC)(e)},get:function(){return this._valueDec}}],[{key:"blockName",value:function(){return"IntegerValueBlock"}}]),i}(l(v)),L=function(e){o(r,e);var t=h(r);function r(){var e,n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return a(this,r),(e=t.call(this,n,R)).idBlock.tagClass=1,e.idBlock.tagNumber=2,e}return s(r,[{key:"isEqual",value:function(e){return e instanceof r?this.valueBlock.isHexOnly&&e.valueBlock.isHexOnly?(0,oe.isEqualBuffer)(this.valueBlock.valueHex,e.valueBlock.valueHex):this.valueBlock.isHexOnly===e.valueBlock.isHexOnly&&this.valueBlock.valueDec===e.valueBlock.valueDec:e instanceof ArrayBuffer&&(0,oe.isEqualBuffer)(this.valueBlock.valueHex,e)}},{key:"convertToDER",value:function(){var e=new r({valueHex:this.valueBlock.valueHex});return e.valueBlock.toDER(),e}},{key:"convertFromDER",value:function(){var e=this.valueBlock.valueHex.byteLength%2?this.valueBlock.valueHex.byteLength+1:this.valueBlock.valueHex.byteLength,t=new r({valueHex:this.valueBlock.valueHex});return t.valueBlock.fromDER(t.valueBlock.valueHex,0,t.valueBlock.valueHex.byteLength,e),t}}],[{key:"blockName",value:function(){return"Integer"}}]),r}(g);t.Integer=L;var O=function(e){o(r,e);var t=h(r);function r(){var e,n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return a(this,r),(e=t.call(this,n)).idBlock.tagClass=1,e.idBlock.tagNumber=10,e}return s(r,null,[{key:"blockName",value:function(){return"Enumerated"}}]),r}(L);t.Enumerated=O;var U=function(e){o(r,e);var t=h(r);function r(){var e,n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return a(this,r),(e=t.call(this,n)).valueDec=(0,oe.getParametersValue)(n,"valueDec",-1),e.isFirstSid=(0,oe.getParametersValue)(n,"isFirstSid",!1),e}return s(r,[{key:"fromBER",value:function(e,t,r){if(0===r)return t;if(!1===(0,oe.checkBufferParams)(this,e,t,r))return-1;var n=new Uint8Array(e,t,r);this.valueHex=new ArrayBuffer(r);for(var a=new Uint8Array(this.valueHex),i=0;i<r&&(a[i]=127&n[i],this.blockLength++,0!=(128&n[i]));i++);for(var s=new ArrayBuffer(this.blockLength),o=new Uint8Array(s),u=0;u<this.blockLength;u++)o[u]=a[u];return this.valueHex=s.slice(0),a=new Uint8Array(this.valueHex),0!=(128&n[this.blockLength-1])?(this.error="End of input reached before message was fully decoded",-1):(0===a[0]&&this.warnings.push("Needlessly long format of SID encoding"),this.blockLength<=8?this.valueDec=(0,oe.utilFromBase)(a,7):(this.isHexOnly=!0,this.warnings.push("Too big SID for decoding, hex only")),t+this.blockLength)}},{key:"toBER",value:function(){var e,t,r=arguments.length>0&&void 0!==arguments[0]&&arguments[0];if(this.isHexOnly){if(!0===r)return new ArrayBuffer(this.valueHex.byteLength);var n=new Uint8Array(this.valueHex);e=new ArrayBuffer(this.blockLength),t=new Uint8Array(e);for(var a=0;a<this.blockLength-1;a++)t[a]=128|n[a];return t[this.blockLength-1]=n[this.blockLength-1],e}var i=(0,oe.utilToBase)(this.valueDec,7);if(0===i.byteLength)return this.error="Error during encoding SID value",new ArrayBuffer(0);if(e=new ArrayBuffer(i.byteLength),!1===r){var s=new Uint8Array(i);t=new Uint8Array(e);for(var o=0;o<i.byteLength-1;o++)t[o]=128|s[o];t[i.byteLength-1]=s[i.byteLength-1]}return e}},{key:"toString",value:function(){var e="";if(!0===this.isHexOnly)e=(0,oe.bufferToHexCodes)(this.valueHex,0,this.valueHex.byteLength);else if(this.isFirstSid){var t=this.valueDec;this.valueDec<=39?e="0.":this.valueDec<=79?(e="1.",t-=40):(e="2.",t-=80),e+=t.toString()}else e=this.valueDec.toString();return e}},{key:"toJSON",value:function(){var e={};try{e=m(u(r.prototype),"toJSON",this).call(this)}catch(e){}return e.valueDec=this.valueDec,e.isFirstSid=this.isFirstSid,e}}],[{key:"blockName",value:function(){return"sidBlock"}}]),r}(l(i)),D=function(e){o(r,e);var t=h(r);function r(){var e,n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return a(this,r),(e=t.call(this,n)).fromString((0,oe.getParametersValue)(n,"value","")),e}return s(r,[{key:"fromBER",value:function(e,t,r){for(var n=t;r>0;){var a=new U;if(-1===(n=a.fromBER(e,n,r)))return this.blockLength=0,this.error=a.error,n;0===this.value.length&&(a.isFirstSid=!0),this.blockLength+=a.blockLength,r-=a.blockLength,this.value.push(a)}return n}},{key:"toBER",value:function(){for(var e=arguments.length>0&&void 0!==arguments[0]&&arguments[0],t=new ArrayBuffer(0),r=0;r<this.value.length;r++){var n=this.value[r].toBER(e);if(0===n.byteLength)return this.error=this.value[r].error,new ArrayBuffer(0);t=(0,oe.utilConcatBuf)(t,n)}return t}},{key:"fromString",value:function(e){this.value=[];var t=0,r=0,n="",a=!1;do{if(n=-1===(r=e.indexOf(".",t))?e.substr(t):e.substr(t,r-t),t=r+1,a){var i=this.value[0],s=0;switch(i.valueDec){case 0:break;case 1:s=40;break;case 2:s=80;break;default:return this.value=[],!1}var o=parseInt(n,10);if(isNaN(o))return!0;i.valueDec=o+s,a=!1}else{var u=new U;if(u.valueDec=parseInt(n,10),isNaN(u.valueDec))return!0;0===this.value.length&&(u.isFirstSid=!0,a=!0),this.value.push(u)}}while(-1!==r);return!0}},{key:"toString",value:function(){for(var e="",t=!1,r=0;r<this.value.length;r++){t=this.value[r].isHexOnly;var n=this.value[r].toString();0!==r&&(e="".concat(e,".")),t?(n="{".concat(n,"}"),this.value[r].isFirstSid?e="2.{".concat(n," - 80}"):e+=n):e+=n}return e}},{key:"toJSON",value:function(){var e={};try{e=m(u(r.prototype),"toJSON",this).call(this)}catch(e){}e.value=this.toString(),e.sidArray=[];for(var t=0;t<this.value.length;t++)e.sidArray.push(this.value[t].toJSON());return e}}],[{key:"blockName",value:function(){return"ObjectIdentifierValueBlock"}}]),r}(v),H=function(e){o(r,e);var t=h(r);function r(){var e,n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return a(this,r),(e=t.call(this,n,D)).idBlock.tagClass=1,e.idBlock.tagNumber=6,e}return s(r,null,[{key:"blockName",value:function(){return"ObjectIdentifier"}}]),r}(g);t.ObjectIdentifier=H;var V=function(e){o(r,e);var t=h(r);function r(){var e,n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return a(this,r),(e=t.call(this,n)).isHexOnly=!0,e.value="",e}return s(r,[{key:"toJSON",value:function(){var e={};try{e=m(u(r.prototype),"toJSON",this).call(this)}catch(e){}return e.value=this.value,e}}],[{key:"blockName",value:function(){return"Utf8StringValueBlock"}}]),r}(l(i)),T=function(e){o(r,e);var t=h(r);function r(){var e,n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return a(this,r),e=t.call(this,n,V),"value"in n&&e.fromString(n.value),e.idBlock.tagClass=1,e.idBlock.tagNumber=12,e}return s(r,[{key:"fromBER",value:function(e,t,r){var n=this.valueBlock.fromBER(e,t,!0===this.lenBlock.isIndefiniteForm?r:this.lenBlock.length);return-1===n?(this.error=this.valueBlock.error,n):(this.fromBuffer(this.valueBlock.valueHex),0===this.idBlock.error.length&&(this.blockLength+=this.idBlock.blockLength),0===this.lenBlock.error.length&&(this.blockLength+=this.lenBlock.blockLength),0===this.valueBlock.error.length&&(this.blockLength+=this.valueBlock.blockLength),n)}},{key:"fromBuffer",value:function(e){this.valueBlock.value=String.fromCharCode.apply(null,new Uint8Array(e));try{this.valueBlock.value=decodeURIComponent(escape(this.valueBlock.value))}catch(e){this.warnings.push('Error during "decodeURIComponent": '.concat(e,", using raw string"))}}},{key:"fromString",value:function(e){var t=unescape(encodeURIComponent(e)),r=t.length;this.valueBlock.valueHex=new ArrayBuffer(r);for(var n=new Uint8Array(this.valueBlock.valueHex),a=0;a<r;a++)n[a]=t.charCodeAt(a);this.valueBlock.value=e}}],[{key:"blockName",value:function(){return"Utf8String"}}]),r}(g);t.Utf8String=T;var _=function(e){o(r,e);var t=h(r);function r(){var e,n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return a(this,r),(e=t.call(this,n)).valueDec=(0,oe.getParametersValue)(n,"valueDec",-1),e}return s(r,[{key:"fromBER",value:function(e,t,r){if(0===r)return t;if(!1===(0,oe.checkBufferParams)(this,e,t,r))return-1;var n=new Uint8Array(e,t,r);this.valueHex=new ArrayBuffer(r);for(var a=new Uint8Array(this.valueHex),i=0;i<r&&(a[i]=127&n[i],this.blockLength++,0!=(128&n[i]));i++);for(var s=new ArrayBuffer(this.blockLength),o=new Uint8Array(s),u=0;u<this.blockLength;u++)o[u]=a[u];return this.valueHex=s.slice(0),a=new Uint8Array(this.valueHex),0!=(128&n[this.blockLength-1])?(this.error="End of input reached before message was fully decoded",-1):(0===a[0]&&this.warnings.push("Needlessly long format of SID encoding"),this.blockLength<=8?this.valueDec=(0,oe.utilFromBase)(a,7):(this.isHexOnly=!0,this.warnings.push("Too big SID for decoding, hex only")),t+this.blockLength)}},{key:"toBER",value:function(){var e,t,r=arguments.length>0&&void 0!==arguments[0]&&arguments[0];if(this.isHexOnly){if(!0===r)return new ArrayBuffer(this.valueHex.byteLength);var n=new Uint8Array(this.valueHex);e=new ArrayBuffer(this.blockLength),t=new Uint8Array(e);for(var a=0;a<this.blockLength-1;a++)t[a]=128|n[a];return t[this.blockLength-1]=n[this.blockLength-1],e}var i=(0,oe.utilToBase)(this.valueDec,7);if(0===i.byteLength)return this.error="Error during encoding SID value",new ArrayBuffer(0);if(e=new ArrayBuffer(i.byteLength),!1===r){var s=new Uint8Array(i);t=new Uint8Array(e);for(var o=0;o<i.byteLength-1;o++)t[o]=128|s[o];t[i.byteLength-1]=s[i.byteLength-1]}return e}},{key:"toString",value:function(){return!0===this.isHexOnly?(0,oe.bufferToHexCodes)(this.valueHex,0,this.valueHex.byteLength):this.valueDec.toString()}},{key:"toJSON",value:function(){var e={};try{e=m(u(r.prototype),"toJSON",this).call(this)}catch(e){}return e.valueDec=this.valueDec,e}}],[{key:"blockName",value:function(){return"relativeSidBlock"}}]),r}(l(i)),j=function(e){o(r,e);var t=h(r);function r(){var e,n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return a(this,r),(e=t.call(this,n)).fromString((0,oe.getParametersValue)(n,"value","")),e}return s(r,[{key:"fromBER",value:function(e,t,r){for(var n=t;r>0;){var a=new _;if(-1===(n=a.fromBER(e,n,r)))return this.blockLength=0,this.error=a.error,n;this.blockLength+=a.blockLength,r-=a.blockLength,this.value.push(a)}return n}},{key:"toBER",value:function(){for(var e=arguments.length>0&&void 0!==arguments[0]&&arguments[0],t=new ArrayBuffer(0),r=0;r<this.value.length;r++){var n=this.value[r].toBER(e);if(0===n.byteLength)return this.error=this.value[r].error,new ArrayBuffer(0);t=(0,oe.utilConcatBuf)(t,n)}return t}},{key:"fromString",value:function(e){this.value=[];var t=0,r=0,n="";do{n=-1===(r=e.indexOf(".",t))?e.substr(t):e.substr(t,r-t),t=r+1;var a=new _;if(a.valueDec=parseInt(n,10),isNaN(a.valueDec))return!0;this.value.push(a)}while(-1!==r);return!0}},{key:"toString",value:function(){for(var e="",t=!1,r=0;r<this.value.length;r++){t=this.value[r].isHexOnly;var n=this.value[r].toString();0!==r&&(e="".concat(e,".")),e+=t?n="{".concat(n,"}"):n}return e}},{key:"toJSON",value:function(){var e={};try{e=m(u(r.prototype),"toJSON",this).call(this)}catch(e){}e.value=this.toString(),e.sidArray=[];for(var t=0;t<this.value.length;t++)e.sidArray.push(this.value[t].toJSON());return e}}],[{key:"blockName",value:function(){return"RelativeObjectIdentifierValueBlock"}}]),r}(v),K=function(e){o(r,e);var t=h(r);function r(){var e,n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return a(this,r),(e=t.call(this,n,j)).idBlock.tagClass=1,e.idBlock.tagNumber=13,e}return s(r,null,[{key:"blockName",value:function(){return"RelativeObjectIdentifier"}}]),r}(g);t.RelativeObjectIdentifier=K;var M=function(e){o(r,e);var t=h(r);function r(){var e,n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return a(this,r),(e=t.call(this,n)).isHexOnly=!0,e.value="",e}return s(r,[{key:"toJSON",value:function(){var e={};try{e=m(u(r.prototype),"toJSON",this).call(this)}catch(e){}return e.value=this.value,e}}],[{key:"blockName",value:function(){return"BmpStringValueBlock"}}]),r}(l(i)),X=function(e){o(r,e);var t=h(r);function r(){var e,n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return a(this,r),e=t.call(this,n,M),"value"in n&&e.fromString(n.value),e.idBlock.tagClass=1,e.idBlock.tagNumber=30,e}return s(r,[{key:"fromBER",value:function(e,t,r){var n=this.valueBlock.fromBER(e,t,!0===this.lenBlock.isIndefiniteForm?r:this.lenBlock.length);return-1===n?(this.error=this.valueBlock.error,n):(this.fromBuffer(this.valueBlock.valueHex),0===this.idBlock.error.length&&(this.blockLength+=this.idBlock.blockLength),0===this.lenBlock.error.length&&(this.blockLength+=this.lenBlock.blockLength),0===this.valueBlock.error.length&&(this.blockLength+=this.valueBlock.blockLength),n)}},{key:"fromBuffer",value:function(e){for(var t=e.slice(0),r=new Uint8Array(t),n=0;n<r.length;n+=2){var a=r[n];r[n]=r[n+1],r[n+1]=a}this.valueBlock.value=String.fromCharCode.apply(null,new Uint16Array(t))}},{key:"fromString",value:function(e){var t=e.length;this.valueBlock.valueHex=new ArrayBuffer(2*t);for(var r=new Uint8Array(this.valueBlock.valueHex),n=0;n<t;n++){var a=(0,oe.utilToBase)(e.charCodeAt(n),8),i=new Uint8Array(a);if(!(i.length>2))for(var s=2-i.length,o=i.length-1;o>=0;o--)r[2*n+o+s]=i[o]}this.valueBlock.value=e}}],[{key:"blockName",value:function(){return"BmpString"}}]),r}(g);t.BmpString=X;var G=function(e){o(r,e);var t=h(r);function r(){var e,n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return a(this,r),(e=t.call(this,n)).isHexOnly=!0,e.value="",e}return s(r,[{key:"toJSON",value:function(){var e={};try{e=m(u(r.prototype),"toJSON",this).call(this)}catch(e){}return e.value=this.value,e}}],[{key:"blockName",value:function(){return"UniversalStringValueBlock"}}]),r}(l(i)),q=function(e){o(r,e);var t=h(r);function r(){var e,n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return a(this,r),e=t.call(this,n,G),"value"in n&&e.fromString(n.value),e.idBlock.tagClass=1,e.idBlock.tagNumber=28,e}return s(r,[{key:"fromBER",value:function(e,t,r){var n=this.valueBlock.fromBER(e,t,!0===this.lenBlock.isIndefiniteForm?r:this.lenBlock.length);return-1===n?(this.error=this.valueBlock.error,n):(this.fromBuffer(this.valueBlock.valueHex),0===this.idBlock.error.length&&(this.blockLength+=this.idBlock.blockLength),0===this.lenBlock.error.length&&(this.blockLength+=this.lenBlock.blockLength),0===this.valueBlock.error.length&&(this.blockLength+=this.valueBlock.blockLength),n)}},{key:"fromBuffer",value:function(e){for(var t=e.slice(0),r=new Uint8Array(t),n=0;n<r.length;n+=4)r[n]=r[n+3],r[n+1]=r[n+2],r[n+2]=0,r[n+3]=0;this.valueBlock.value=String.fromCharCode.apply(null,new Uint32Array(t))}},{key:"fromString",value:function(e){var t=e.length;this.valueBlock.valueHex=new ArrayBuffer(4*t);for(var r=new Uint8Array(this.valueBlock.valueHex),n=0;n<t;n++){var a=(0,oe.utilToBase)(e.charCodeAt(n),8),i=new Uint8Array(a);if(!(i.length>4))for(var s=4-i.length,o=i.length-1;o>=0;o--)r[4*n+o+s]=i[o]}this.valueBlock.value=e}}],[{key:"blockName",value:function(){return"UniversalString"}}]),r}(g);t.UniversalString=q;var F=function(e){o(r,e);var t=h(r);function r(){var e,n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return a(this,r),(e=t.call(this,n)).value="",e.isHexOnly=!0,e}return s(r,[{key:"toJSON",value:function(){var e={};try{e=m(u(r.prototype),"toJSON",this).call(this)}catch(e){}return e.value=this.value,e}}],[{key:"blockName",value:function(){return"SimpleStringValueBlock"}}]),r}(l(i)),J=function(e){o(r,e);var t=h(r);function r(){var e,n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return a(this,r),e=t.call(this,n,F),"value"in n&&e.fromString(n.value),e}return s(r,[{key:"fromBER",value:function(e,t,r){var n=this.valueBlock.fromBER(e,t,!0===this.lenBlock.isIndefiniteForm?r:this.lenBlock.length);return-1===n?(this.error=this.valueBlock.error,n):(this.fromBuffer(this.valueBlock.valueHex),0===this.idBlock.error.length&&(this.blockLength+=this.idBlock.blockLength),0===this.lenBlock.error.length&&(this.blockLength+=this.lenBlock.blockLength),0===this.valueBlock.error.length&&(this.blockLength+=this.valueBlock.blockLength),n)}},{key:"fromBuffer",value:function(e){this.valueBlock.value=String.fromCharCode.apply(null,new Uint8Array(e))}},{key:"fromString",value:function(e){var t=e.length;this.valueBlock.valueHex=new ArrayBuffer(t);for(var r=new Uint8Array(this.valueBlock.valueHex),n=0;n<t;n++)r[n]=e.charCodeAt(n);this.valueBlock.value=e}}],[{key:"blockName",value:function(){return"SIMPLESTRING"}}]),r}(g),W=function(e){o(r,e);var t=h(r);function r(){var e,n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return a(this,r),(e=t.call(this,n)).idBlock.tagClass=1,e.idBlock.tagNumber=18,e}return s(r,null,[{key:"blockName",value:function(){return"NumericString"}}]),r}(J);t.NumericString=W;var z=function(e){o(r,e);var t=h(r);function r(){var e,n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return a(this,r),(e=t.call(this,n)).idBlock.tagClass=1,e.idBlock.tagNumber=19,e}return s(r,null,[{key:"blockName",value:function(){return"PrintableString"}}]),r}(J);t.PrintableString=z;var Q=function(e){o(r,e);var t=h(r);function r(){var e,n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return a(this,r),(e=t.call(this,n)).idBlock.tagClass=1,e.idBlock.tagNumber=20,e}return s(r,null,[{key:"blockName",value:function(){return"TeletexString"}}]),r}(J);t.TeletexString=Q;var Y=function(e){o(r,e);var t=h(r);function r(){var e,n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return a(this,r),(e=t.call(this,n)).idBlock.tagClass=1,e.idBlock.tagNumber=21,e}return s(r,null,[{key:"blockName",value:function(){return"VideotexString"}}]),r}(J);t.VideotexString=Y;var Z=function(e){o(r,e);var t=h(r);function r(){var e,n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return a(this,r),(e=t.call(this,n)).idBlock.tagClass=1,e.idBlock.tagNumber=22,e}return s(r,null,[{key:"blockName",value:function(){return"IA5String"}}]),r}(J);t.IA5String=Z;var $=function(e){o(r,e);var t=h(r);function r(){var e,n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return a(this,r),(e=t.call(this,n)).idBlock.tagClass=1,e.idBlock.tagNumber=25,e}return s(r,null,[{key:"blockName",value:function(){return"GraphicString"}}]),r}(J);t.GraphicString=$;var ee=function(e){o(r,e);var t=h(r);function r(){var e,n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return a(this,r),(e=t.call(this,n)).idBlock.tagClass=1,e.idBlock.tagNumber=26,e}return s(r,null,[{key:"blockName",value:function(){return"VisibleString"}}]),r}(J);t.VisibleString=ee;var te=function(e){o(r,e);var t=h(r);function r(){var e,n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return a(this,r),(e=t.call(this,n)).idBlock.tagClass=1,e.idBlock.tagNumber=27,e}return s(r,null,[{key:"blockName",value:function(){return"GeneralString"}}]),r}(J);t.GeneralString=te;var re=function(e){o(r,e);var t=h(r);function r(){var e,n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return a(this,r),(e=t.call(this,n)).idBlock.tagClass=1,e.idBlock.tagNumber=29,e}return s(r,null,[{key:"blockName",value:function(){return"CharacterString"}}]),r}(J);t.CharacterString=re;var ne=function(e){o(r,e);var t=h(r);function r(){var e,n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};if(a(this,r),(e=t.call(this,n)).year=0,e.month=0,e.day=0,e.hour=0,e.minute=0,e.second=0,"value"in n){e.fromString(n.value),e.valueBlock.valueHex=new ArrayBuffer(n.value.length);for(var i=new Uint8Array(e.valueBlock.valueHex),s=0;s<n.value.length;s++)i[s]=n.value.charCodeAt(s)}return"valueDate"in n&&(e.fromDate(n.valueDate),e.valueBlock.valueHex=e.toBuffer()),e.idBlock.tagClass=1,e.idBlock.tagNumber=23,e}return s(r,[{key:"fromBER",value:function(e,t,r){var n=this.valueBlock.fromBER(e,t,!0===this.lenBlock.isIndefiniteForm?r:this.lenBlock.length);return-1===n?(this.error=this.valueBlock.error,n):(this.fromBuffer(this.valueBlock.valueHex),0===this.idBlock.error.length&&(this.blockLength+=this.idBlock.blockLength),0===this.lenBlock.error.length&&(this.blockLength+=this.lenBlock.blockLength),0===this.valueBlock.error.length&&(this.blockLength+=this.valueBlock.blockLength),n)}},{key:"fromBuffer",value:function(e){this.fromString(String.fromCharCode.apply(null,new Uint8Array(e)))}},{key:"toBuffer",value:function(){for(var e=this.toString(),t=new ArrayBuffer(e.length),r=new Uint8Array(t),n=0;n<e.length;n++)r[n]=e.charCodeAt(n);return t}},{key:"fromDate",value:function(e){this.year=e.getUTCFullYear(),this.month=e.getUTCMonth()+1,this.day=e.getUTCDate(),this.hour=e.getUTCHours(),this.minute=e.getUTCMinutes(),this.second=e.getUTCSeconds()}},{key:"toDate",value:function(){return new Date(Date.UTC(this.year,this.month-1,this.day,this.hour,this.minute,this.second))}},{key:"fromString",value:function(e){var t=/(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})Z/gi.exec(e);if(null!==t){var r=parseInt(t[1],10);this.year=r>=50?1900+r:2e3+r,this.month=parseInt(t[2],10),this.day=parseInt(t[3],10),this.hour=parseInt(t[4],10),this.minute=parseInt(t[5],10),this.second=parseInt(t[6],10)}else this.error="Wrong input string for convertion"}},{key:"toString",value:function(){var e=new Array(7);return e[0]=(0,oe.padNumber)(this.year<2e3?this.year-1900:this.year-2e3,2),e[1]=(0,oe.padNumber)(this.month,2),e[2]=(0,oe.padNumber)(this.day,2),e[3]=(0,oe.padNumber)(this.hour,2),e[4]=(0,oe.padNumber)(this.minute,2),e[5]=(0,oe.padNumber)(this.second,2),e[6]="Z",e.join("")}},{key:"toJSON",value:function(){var e={};try{e=m(u(r.prototype),"toJSON",this).call(this)}catch(e){}return e.year=this.year,e.month=this.month,e.day=this.day,e.hour=this.hour,e.minute=this.minute,e.second=this.second,e}}],[{key:"blockName",value:function(){return"UTCTime"}}]),r}(ee);t.UTCTime=ne;var ae=function(e){o(r,e);var t=h(r);function r(){var e,n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};if(a(this,r),(e=t.call(this,n)).year=0,e.month=0,e.day=0,e.hour=0,e.minute=0,e.second=0,e.millisecond=0,"value"in n){e.fromString(n.value),e.valueBlock.valueHex=new ArrayBuffer(n.value.length);for(var i=new Uint8Array(e.valueBlock.valueHex),s=0;s<n.value.length;s++)i[s]=n.value.charCodeAt(s)}return"valueDate"in n&&(e.fromDate(n.valueDate),e.valueBlock.valueHex=e.toBuffer()),e.idBlock.tagClass=1,e.idBlock.tagNumber=24,e}return s(r,[{key:"fromBER",value:function(e,t,r){var n=this.valueBlock.fromBER(e,t,!0===this.lenBlock.isIndefiniteForm?r:this.lenBlock.length);return-1===n?(this.error=this.valueBlock.error,n):(this.fromBuffer(this.valueBlock.valueHex),0===this.idBlock.error.length&&(this.blockLength+=this.idBlock.blockLength),0===this.lenBlock.error.length&&(this.blockLength+=this.lenBlock.blockLength),0===this.valueBlock.error.length&&(this.blockLength+=this.valueBlock.blockLength),n)}},{key:"fromBuffer",value:function(e){this.fromString(String.fromCharCode.apply(null,new Uint8Array(e)))}},{key:"toBuffer",value:function(){for(var e=this.toString(),t=new ArrayBuffer(e.length),r=new Uint8Array(t),n=0;n<e.length;n++)r[n]=e.charCodeAt(n);return t}},{key:"fromDate",value:function(e){this.year=e.getUTCFullYear(),this.month=e.getUTCMonth()+1,this.day=e.getUTCDate(),this.hour=e.getUTCHours(),this.minute=e.getUTCMinutes(),this.second=e.getUTCSeconds(),this.millisecond=e.getUTCMilliseconds()}},{key:"toDate",value:function(){return new Date(Date.UTC(this.year,this.month-1,this.day,this.hour,this.minute,this.second,this.millisecond))}},{key:"fromString",value:function(e){var t,r=!1,n="",a="",i=0,s=0,o=0;if("Z"===e[e.length-1])n=e.substr(0,e.length-1),r=!0;else{var u=new Number(e[e.length-1]);if(isNaN(u.valueOf()))throw new Error("Wrong input string for convertion");n=e}if(r){if(-1!==n.indexOf("+"))throw new Error("Wrong input string for convertion");if(-1!==n.indexOf("-"))throw new Error("Wrong input string for convertion")}else{var l=1,c=n.indexOf("+"),h="";if(-1===c&&(c=n.indexOf("-"),l=-1),-1!==c){if(h=n.substr(c+1),n=n.substr(0,c),2!==h.length&&4!==h.length)throw new Error("Wrong input string for convertion");var m=new Number(h.substr(0,2));if(isNaN(m.valueOf()))throw new Error("Wrong input string for convertion");if(s=l*m,4===h.length){if(m=new Number(h.substr(2,2)),isNaN(m.valueOf()))throw new Error("Wrong input string for convertion");o=l*m}}}var f=n.indexOf(".");if(-1===f&&(f=n.indexOf(",")),-1!==f){var v=new Number("0".concat(n.substr(f)));if(isNaN(v.valueOf()))throw new Error("Wrong input string for convertion");i=v.valueOf(),a=n.substr(0,f)}else a=n;switch(!0){case 8===a.length:if(t=/(\d{4})(\d{2})(\d{2})/gi,-1!==f)throw new Error("Wrong input string for convertion");break;case 10===a.length:if(t=/(\d{4})(\d{2})(\d{2})(\d{2})/gi,-1!==f){var g=60*i;this.minute=Math.floor(g),g=60*(g-this.minute),this.second=Math.floor(g),g=1e3*(g-this.second),this.millisecond=Math.floor(g)}break;case 12===a.length:if(t=/(\d{4})(\d{2})(\d{2})(\d{2})(\d{2})/gi,-1!==f){var d=60*i;this.second=Math.floor(d),d=1e3*(d-this.second),this.millisecond=Math.floor(d)}break;case 14===a.length:if(t=/(\d{4})(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})/gi,-1!==f){var y=1e3*i;this.millisecond=Math.floor(y)}break;default:throw new Error("Wrong input string for convertion")}var p=t.exec(a);if(null===p)throw new Error("Wrong input string for convertion");for(var b=1;b<p.length;b++)switch(b){case 1:this.year=parseInt(p[b],10);break;case 2:this.month=parseInt(p[b],10);break;case 3:this.day=parseInt(p[b],10);break;case 4:this.hour=parseInt(p[b],10)+s;break;case 5:this.minute=parseInt(p[b],10)+o;break;case 6:this.second=parseInt(p[b],10);break;default:throw new Error("Wrong input string for convertion")}if(!1===r){var k=new Date(this.year,this.month,this.day,this.hour,this.minute,this.second,this.millisecond);this.year=k.getUTCFullYear(),this.month=k.getUTCMonth(),this.day=k.getUTCDay(),this.hour=k.getUTCHours(),this.minute=k.getUTCMinutes(),this.second=k.getUTCSeconds(),this.millisecond=k.getUTCMilliseconds()}}},{key:"toString",value:function(){var e=[];return e.push((0,oe.padNumber)(this.year,4)),e.push((0,oe.padNumber)(this.month,2)),e.push((0,oe.padNumber)(this.day,2)),e.push((0,oe.padNumber)(this.hour,2)),e.push((0,oe.padNumber)(this.minute,2)),e.push((0,oe.padNumber)(this.second,2)),0!==this.millisecond&&(e.push("."),e.push((0,oe.padNumber)(this.millisecond,3))),e.push("Z"),e.join("")}},{key:"toJSON",value:function(){var e={};try{e=m(u(r.prototype),"toJSON",this).call(this)}catch(e){}return e.year=this.year,e.month=this.month,e.day=this.day,e.hour=this.hour,e.minute=this.minute,e.second=this.second,e.millisecond=this.millisecond,e}}],[{key:"blockName",value:function(){return"GeneralizedTime"}}]),r}(ee);t.GeneralizedTime=ae;var ie=function(e){o(r,e);var t=h(r);function r(){var e,n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return a(this,r),(e=t.call(this,n)).idBlock.tagClass=1,e.idBlock.tagNumber=31,e}return s(r,null,[{key:"blockName",value:function(){return"DATE"}}]),r}(T);t.DATE=ie;var se=function(e){o(r,e);var t=h(r);function r(){var e,n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return a(this,r),(e=t.call(this,n)).idBlock.tagClass=1,e.idBlock.tagNumber=32,e}return s(r,null,[{key:"blockName",value:function(){return"TimeOfDay"}}]),r}(T);t.TimeOfDay=se;var ue=function(e){o(r,e);var t=h(r);function r(){var e,n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return a(this,r),(e=t.call(this,n)).idBlock.tagClass=1,e.idBlock.tagNumber=33,e}return s(r,null,[{key:"blockName",value:function(){return"DateTime"}}]),r}(T);t.DateTime=ue;var le=function(e){o(r,e);var t=h(r);function r(){var e,n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return a(this,r),(e=t.call(this,n)).idBlock.tagClass=1,e.idBlock.tagNumber=34,e}return s(r,null,[{key:"blockName",value:function(){return"Duration"}}]),r}(T);t.Duration=le;var ce=function(e){o(r,e);var t=h(r);function r(){var e,n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return a(this,r),(e=t.call(this,n)).idBlock.tagClass=1,e.idBlock.tagNumber=14,e}return s(r,null,[{key:"blockName",value:function(){return"TIME"}}]),r}(T);t.TIME=ce;var he=function e(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};a(this,e),this.value=(0,oe.getParametersValue)(t,"value",[]),this.optional=(0,oe.getParametersValue)(t,"optional",!1)};t.Choice=he;var me=function e(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};a(this,e),this.name=(0,oe.getParametersValue)(t,"name",""),this.optional=(0,oe.getParametersValue)(t,"optional",!1)};t.Any=me;var fe=function e(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};a(this,e),this.name=(0,oe.getParametersValue)(t,"name",""),this.optional=(0,oe.getParametersValue)(t,"optional",!1),this.value=(0,oe.getParametersValue)(t,"value",new me),this.local=(0,oe.getParametersValue)(t,"local",!1)};t.Repeated=fe;var ve=function(){function e(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};a(this,e),this.data=(0,oe.getParametersValue)(t,"data",new ArrayBuffer(0))}return s(e,[{key:"fromBER",value:function(e,t,r){return this.data=e.slice(t,r),t+r}},{key:"toBER",value:function(){return this.data}}]),e}();function ge(e,t,r){var n=t,a=new g({},Object),s=new i;if(!1===(0,oe.checkBufferParams)(s,e,t,r))return a.error=s.error,{offset:-1,result:a};if(0===new Uint8Array(e,t,r).length)return this.error="Zero buffer length",{offset:-1,result:a};var o=a.idBlock.fromBER(e,t,r);if(a.warnings.concat(a.idBlock.warnings),-1===o)return a.error=a.idBlock.error,{offset:-1,result:a};if(t=o,r-=a.idBlock.blockLength,o=a.lenBlock.fromBER(e,t,r),a.warnings.concat(a.lenBlock.warnings),-1===o)return a.error=a.lenBlock.error,{offset:-1,result:a};if(t=o,r-=a.lenBlock.blockLength,!1===a.idBlock.isConstructed&&!0===a.lenBlock.isIndefiniteForm)return a.error="Indefinite length form used for primitive encoding form",{offset:-1,result:a};var u=g;switch(a.idBlock.tagClass){case 1:if(a.idBlock.tagNumber>=37&&!1===a.idBlock.isHexOnly)return a.error="UNIVERSAL 37 and upper tags are reserved by ASN.1 standard",{offset:-1,result:a};switch(a.idBlock.tagNumber){case 0:if(!0===a.idBlock.isConstructed&&a.lenBlock.length>0)return a.error="Type [UNIVERSAL 0] is reserved",{offset:-1,result:a};u=w;break;case 1:u=A;break;case 2:u=L;break;case 3:u=x;break;case 4:u=P;break;case 5:u=B;break;case 6:u=H;break;case 10:u=O;break;case 12:u=T;break;case 13:u=K;break;case 14:u=ce;break;case 15:return a.error="[UNIVERSAL 15] is reserved by ASN.1 standard",{offset:-1,result:a};case 16:u=C;break;case 17:u=N;break;case 18:u=W;break;case 19:u=z;break;case 20:u=Q;break;case 21:u=Y;break;case 22:u=Z;break;case 23:u=ne;break;case 24:u=ae;break;case 25:u=$;break;case 26:u=ee;break;case 27:u=te;break;case 28:u=q;break;case 29:u=re;break;case 30:u=X;break;case 31:u=ie;break;case 32:u=se;break;case 33:u=ue;break;case 34:u=le;break;default:var l;(l=!0===a.idBlock.isConstructed?new b:new y).idBlock=a.idBlock,l.lenBlock=a.lenBlock,l.warnings=a.warnings,o=(a=l).fromBER(e,t,r)}break;case 2:case 3:case 4:default:u=!0===a.idBlock.isConstructed?b:y}return o=(a=function(e,t){if(e instanceof t)return e;var r=new t;return r.idBlock=e.idBlock,r.lenBlock=e.lenBlock,r.warnings=e.warnings,r.valueBeforeDecode=e.valueBeforeDecode.slice(0),r}(a,u)).fromBER(e,t,!0===a.lenBlock.isIndefiniteForm?r:a.lenBlock.length),a.valueBeforeDecode=e.slice(n,n+a.blockLength),{offset:o,result:a}}function de(e){if(0===e.byteLength){var t=new g({},Object);return t.error="Input buffer has zero length",{offset:-1,result:t}}return ge(e,0,e.byteLength)}function ye(e,t,r){if(r instanceof he){for(var n=0;n<r.value.length;n++)if(!0===ye(e,t,r.value[n]).verified)return{verified:!0,result:e};var a={verified:!1,result:{error:"Wrong values for Choice type"}};return r.hasOwnProperty("name")&&(a.name=r.name),a}if(r instanceof me)return r.hasOwnProperty("name")&&(e[r.name]=t),{verified:!0,result:e};if(e instanceof Object==0)return{verified:!1,result:{error:"Wrong root object"}};if(t instanceof Object==0)return{verified:!1,result:{error:"Wrong ASN.1 data"}};if(r instanceof Object==0)return{verified:!1,result:{error:"Wrong ASN.1 schema"}};if("idBlock"in r==0)return{verified:!1,result:{error:"Wrong ASN.1 schema"}};if("fromBER"in r.idBlock==0)return{verified:!1,result:{error:"Wrong ASN.1 schema"}};if("toBER"in r.idBlock==0)return{verified:!1,result:{error:"Wrong ASN.1 schema"}};var i=r.idBlock.toBER(!1);if(0===i.byteLength)return{verified:!1,result:{error:"Error encoding idBlock for ASN.1 schema"}};if(-1===r.idBlock.fromBER(i,0,i.byteLength))return{verified:!1,result:{error:"Error decoding idBlock for ASN.1 schema"}};if(!1===r.idBlock.hasOwnProperty("tagClass"))return{verified:!1,result:{error:"Wrong ASN.1 schema"}};if(r.idBlock.tagClass!==t.idBlock.tagClass)return{verified:!1,result:e};if(!1===r.idBlock.hasOwnProperty("tagNumber"))return{verified:!1,result:{error:"Wrong ASN.1 schema"}};if(r.idBlock.tagNumber!==t.idBlock.tagNumber)return{verified:!1,result:e};if(!1===r.idBlock.hasOwnProperty("isConstructed"))return{verified:!1,result:{error:"Wrong ASN.1 schema"}};if(r.idBlock.isConstructed!==t.idBlock.isConstructed)return{verified:!1,result:e};if("isHexOnly"in r.idBlock==0)return{verified:!1,result:{error:"Wrong ASN.1 schema"}};if(r.idBlock.isHexOnly!==t.idBlock.isHexOnly)return{verified:!1,result:e};if(!0===r.idBlock.isHexOnly){if("valueHex"in r.idBlock==0)return{verified:!1,result:{error:"Wrong ASN.1 schema"}};var s=new Uint8Array(r.idBlock.valueHex),o=new Uint8Array(t.idBlock.valueHex);if(s.length!==o.length)return{verified:!1,result:e};for(var u=0;u<s.length;u++)if(s[u]!==o[1])return{verified:!1,result:e}}if(r.hasOwnProperty("name")&&(r.name=r.name.replace(/^\s+|\s+$/g,""),""!==r.name&&(e[r.name]=t)),!0===r.idBlock.isConstructed){var l=0,c={verified:!1},h=r.valueBlock.value.length;if(h>0&&r.valueBlock.value[0]instanceof fe&&(h=t.valueBlock.value.length),0===h)return{verified:!0,result:e};if(0===t.valueBlock.value.length&&0!==r.valueBlock.value.length){for(var m=!0,f=0;f<r.valueBlock.value.length;f++)m=m&&(r.valueBlock.value[f].optional||!1);return!0===m?{verified:!0,result:e}:(r.hasOwnProperty("name")&&(r.name=r.name.replace(/^\s+|\s+$/g,""),""!==r.name&&delete e[r.name]),e.error="Inconsistent object length",{verified:!1,result:e})}for(var v=0;v<h;v++)if(v-l>=t.valueBlock.value.length){if(!1===r.valueBlock.value[v].optional){var g={verified:!1,result:e};return e.error="Inconsistent length between ASN.1 data and schema",r.hasOwnProperty("name")&&(r.name=r.name.replace(/^\s+|\s+$/g,""),""!==r.name&&(delete e[r.name],g.name=r.name)),g}}else if(r.valueBlock.value[0]instanceof fe){if(!1===(c=ye(e,t.valueBlock.value[v],r.valueBlock.value[0].value)).verified){if(!0!==r.valueBlock.value[0].optional)return r.hasOwnProperty("name")&&(r.name=r.name.replace(/^\s+|\s+$/g,""),""!==r.name&&delete e[r.name]),c;l++}if("name"in r.valueBlock.value[0]&&r.valueBlock.value[0].name.length>0){var d={};void 0===(d="local"in r.valueBlock.value[0]&&!0===r.valueBlock.value[0].local?t:e)[r.valueBlock.value[0].name]&&(d[r.valueBlock.value[0].name]=[]),d[r.valueBlock.value[0].name].push(t.valueBlock.value[v])}}else if(!1===(c=ye(e,t.valueBlock.value[v-l],r.valueBlock.value[v])).verified){if(!0!==r.valueBlock.value[v].optional)return r.hasOwnProperty("name")&&(r.name=r.name.replace(/^\s+|\s+$/g,""),""!==r.name&&delete e[r.name]),c;l++}if(!1===c.verified){var y={verified:!1,result:e};return r.hasOwnProperty("name")&&(r.name=r.name.replace(/^\s+|\s+$/g,""),""!==r.name&&(delete e[r.name],y.name=r.name)),y}return{verified:!0,result:e}}if("primitiveSchema"in r&&"valueHex"in t.valueBlock){var p=de(t.valueBlock.valueHex);if(-1===p.offset){var b={verified:!1,result:p.result};return r.hasOwnProperty("name")&&(r.name=r.name.replace(/^\s+|\s+$/g,""),""!==r.name&&(delete e[r.name],b.name=r.name)),b}return ye(e,p.result,r.primitiveSchema)}return{verified:!0,result:e}}t.RawData=ve}(se={path:ie,exports:{},require:function(e,t){return function(){throw new Error("Dynamic requires are not currently supported by @rollup/plugin-commonjs")}(null==t&&se.path)}},se.exports),se.exports);function le(e,t,r){return e instanceof Object==!1?r:t in e?e[t]:r}function ce(e){var t,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:e.byteLength-r,a=arguments.length>3&&void 0!==arguments[3]&&arguments[3],i="",s=y(new Uint8Array(e,r,n));try{for(s.s();!(t=s.n()).done;){var o=t.value,u=o.toString(16).toUpperCase();1===u.length&&(i+="0"),i+=u,a&&(i+=" ")}}catch(e){s.e(e)}finally{s.f()}return i.trim()}function he(e,t){for(var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:-1,n=r,a=e,i=0,s=Math.pow(2,t),o=1;o<8;o++){if(e<s){var u=void 0;if(n<0)u=new ArrayBuffer(o),i=o;else{if(n<o)return new ArrayBuffer(0);u=new ArrayBuffer(n),i=n}for(var l=new Uint8Array(u),c=o-1;c>=0;c--){var h=Math.pow(2,c*t);l[i-c-1]=Math.floor(a/h),a-=l[i-c-1]*h}return u}s*=Math.pow(2,t)}return new ArrayBuffer(0)}function me(){for(var e=0,t=0,r=arguments.length,n=new Array(r),a=0;a<r;a++)n[a]=arguments[a];for(var i=0,s=n;i<s.length;i++){var o=s[i];e+=o.byteLength}for(var u=new ArrayBuffer(e),l=new Uint8Array(u),c=0,h=n;c<h.length;c++){var m=h[c];l.set(new Uint8Array(m),t),t+=m.byteLength}return u}function fe(e,t){if(e.byteLength!==t.byteLength)return!1;for(var r=new Uint8Array(e),n=new Uint8Array(t),a=0;a<r.length;a++)if(r[a]!==n[a])return!1;return!0}var ve="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",ge="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=";function de(e){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1],r=arguments.length>2&&void 0!==arguments[2]&&arguments[2],n=arguments.length>3&&void 0!==arguments[3]&&arguments[3],a=0,i=0,s=0,o="",u=t?ge:ve;if(n){for(var l=0,c=0;c<e.length;c++)if(0!==e.charCodeAt(c)){l=c;break}e=e.slice(l)}for(;a<e.length;){var h=e.charCodeAt(a++);a>=e.length&&(i=1);var m=e.charCodeAt(a++);a>=e.length&&(s=1);var f=e.charCodeAt(a++),v=h>>2,g=(3&h)<<4|m>>4,d=(15&m)<<2|f>>6,y=63&f;1===i?d=y=64:1===s&&(y=64),o+=r?64===d?"".concat(u.charAt(v)).concat(u.charAt(g)):64===y?"".concat(u.charAt(v)).concat(u.charAt(g)).concat(u.charAt(d)):"".concat(u.charAt(v)).concat(u.charAt(g)).concat(u.charAt(d)).concat(u.charAt(y)):"".concat(u.charAt(v)).concat(u.charAt(g)).concat(u.charAt(d)).concat(u.charAt(y))}return o}function ye(e){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1],r=arguments.length>2&&void 0!==arguments[2]&&arguments[2],n=t?ge:ve;function a(e){for(var t=0;t<64;t++)if(n.charAt(t)===e)return t;return 64}function i(e){return 64===e?0:e}for(var s=0,o="";s<e.length;){var u=a(e.charAt(s++)),l=s>=e.length?0:a(e.charAt(s++)),c=s>=e.length?0:a(e.charAt(s++)),h=s>=e.length?0:a(e.charAt(s++)),m=i(u)<<2|i(l)>>4,f=(15&i(l))<<4|i(c)>>2,v=(3&i(c))<<6|i(h);o+=String.fromCharCode(m),64!==c&&(o+=String.fromCharCode(f)),64!==h&&(o+=String.fromCharCode(v))}if(r){for(var g=o.length,d=-1,y=g-1;y>=0;y--)if(0!==o.charCodeAt(y)){d=y;break}o=-1!==d?o.slice(0,d+1):""}return o}function pe(e){var t,r="",n=y(new Uint8Array(e));try{for(n.s();!(t=n.n()).done;){var a=t.value;r+=String.fromCharCode(a)}}catch(e){n.e(e)}finally{n.f()}return r}function be(e){for(var t=e.length,r=new ArrayBuffer(t),n=new Uint8Array(r),a=0;a<t;a++)n[a]=e.charCodeAt(a);return r}var ke=Math.log(2);function we(e,t){var r,n=y(t);try{for(n.s();!(r=n.n()).done;){delete e[r.value]}}catch(e){n.e(e)}finally{n.f()}}var Se=function(){function e(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};a(this,e),this.algorithmId=le(t,"algorithmId",e.defaultValues("algorithmId")),"algorithmParams"in t&&(this.algorithmParams=le(t,"algorithmParams",e.defaultValues("algorithmParams"))),"schema"in t&&this.fromSchema(t.schema)}return s(e,[{key:"fromSchema",value:function(t){we(t,["algorithm","params"]);var r=ue.compareSchema(t,t,e.schema({names:{algorithmIdentifier:"algorithm",algorithmParams:"params"}}));if(!1===r.verified)throw new Error("Object's schema was not verified against input data for AlgorithmIdentifier");this.algorithmId=r.result.algorithm.valueBlock.toString(),"params"in r.result&&(this.algorithmParams=r.result.params)}},{key:"toSchema",value:function(){var e=[];return e.push(new ue.ObjectIdentifier({value:this.algorithmId})),"algorithmParams"in this&&this.algorithmParams instanceof ue.Any==!1&&e.push(this.algorithmParams),new ue.Sequence({value:e})}},{key:"toJSON",value:function(){var e={algorithmId:this.algorithmId};return"algorithmParams"in this&&this.algorithmParams instanceof ue.Any==!1&&(e.algorithmParams=this.algorithmParams.toJSON()),e}},{key:"isEqual",value:function(t){return t instanceof e!=!1&&(this.algorithmId===t.algorithmId&&("algorithmParams"in this?"algorithmParams"in t&&JSON.stringify(this.algorithmParams)===JSON.stringify(t.algorithmParams):!("algorithmParams"in t)))}}],[{key:"defaultValues",value:function(e){switch(e){case"algorithmId":return"";case"algorithmParams":return new ue.Any;default:throw new Error("Invalid member name for AlgorithmIdentifier class: ".concat(e))}}},{key:"compareWithDefault",value:function(e,t){switch(e){case"algorithmId":return""===t;case"algorithmParams":return t instanceof ue.Any;default:throw new Error("Invalid member name for AlgorithmIdentifier class: ".concat(e))}}},{key:"schema",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=le(e,"names",{});return new ue.Sequence({name:t.blockName||"",optional:t.optional||!1,value:[new ue.ObjectIdentifier({name:t.algorithmIdentifier||""}),new ue.Any({name:t.algorithmParams||"",optional:!0})]})}}]),e}(),Ae=function(){function e(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};a(this,e),this.x=le(t,"x",e.defaultValues("x")),this.y=le(t,"y",e.defaultValues("y")),this.namedCurve=le(t,"namedCurve",e.defaultValues("namedCurve")),"schema"in t&&this.fromSchema(t.schema),"json"in t&&this.fromJSON(t.json)}return s(e,[{key:"fromSchema",value:function(e){if(e instanceof ArrayBuffer==!1)throw new Error("Object's schema was not verified against input data for ECPublicKey");var t;if(4!==new Uint8Array(e)[0])throw new Error("Object's schema was not verified against input data for ECPublicKey");switch(this.namedCurve){case"1.2.840.10045.3.1.7":t=32;break;case"1.3.132.0.34":t=48;break;case"1.3.132.0.35":t=66;break;default:throw new Error("Incorrect curve OID: ".concat(this.namedCurve))}if(e.byteLength!==2*t+1)throw new Error("Object's schema was not verified against input data for ECPublicKey");this.x=e.slice(1,t+1),this.y=e.slice(1+t,2*t+1)}},{key:"toSchema",value:function(){return new ue.RawData({data:me(new Uint8Array([4]).buffer,this.x,this.y)})}},{key:"toJSON",value:function(){var e="";switch(this.namedCurve){case"1.2.840.10045.3.1.7":e="P-256";break;case"1.3.132.0.34":e="P-384";break;case"1.3.132.0.35":e="P-521"}return{crv:e,x:de(pe(this.x),!0,!0,!1),y:de(pe(this.y),!0,!0,!1)}}},{key:"fromJSON",value:function(e){var t=0;if(!("crv"in e))throw new Error('Absent mandatory parameter "crv"');switch(e.crv.toUpperCase()){case"P-256":this.namedCurve="1.2.840.10045.3.1.7",t=32;break;case"P-384":this.namedCurve="1.3.132.0.34",t=48;break;case"P-521":this.namedCurve="1.3.132.0.35",t=66}if(!("x"in e))throw new Error('Absent mandatory parameter "x"');var r=be(ye(e.x,!0));if(r.byteLength<t){this.x=new ArrayBuffer(t);var n=new Uint8Array(this.x),a=new Uint8Array(r);n.set(a,1)}else this.x=r.slice(0,t);if(!("y"in e))throw new Error('Absent mandatory parameter "y"');var i=be(ye(e.y,!0));if(i.byteLength<t){this.y=new ArrayBuffer(t);var s=new Uint8Array(this.y),o=new Uint8Array(i);s.set(o,1)}else this.y=i.slice(0,t)}}],[{key:"defaultValues",value:function(e){switch(e){case"x":case"y":return new ArrayBuffer(0);case"namedCurve":return"";default:throw new Error("Invalid member name for ECCPublicKey class: ".concat(e))}}},{key:"compareWithDefault",value:function(t,r){switch(t){case"x":case"y":return fe(r,e.defaultValues(t));case"namedCurve":return""===r;default:throw new Error("Invalid member name for ECCPublicKey class: ".concat(t))}}},{key:"schema",value:function(){return new ue.RawData}}]),e}(),Ce=function(){function e(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};a(this,e),this.modulus=le(t,"modulus",e.defaultValues("modulus")),this.publicExponent=le(t,"publicExponent",e.defaultValues("publicExponent")),"schema"in t&&this.fromSchema(t.schema),"json"in t&&this.fromJSON(t.json)}return s(e,[{key:"fromSchema",value:function(t){we(t,["modulus","publicExponent"]);var r=ue.compareSchema(t,t,e.schema({names:{modulus:"modulus",publicExponent:"publicExponent"}}));if(!1===r.verified)throw new Error("Object's schema was not verified against input data for RSAPublicKey");this.modulus=r.result.modulus.convertFromDER(256),this.publicExponent=r.result.publicExponent}},{key:"toSchema",value:function(){return new ue.Sequence({value:[this.modulus.convertToDER(),this.publicExponent]})}},{key:"toJSON",value:function(){return{n:de(pe(this.modulus.valueBlock.valueHex),!0,!0,!0),e:de(pe(this.publicExponent.valueBlock.valueHex),!0,!0,!0)}}},{key:"fromJSON",value:function(e){if(!("n"in e))throw new Error('Absent mandatory parameter "n"');var t,r,n,a,i=be(ye(e.n,!0));if(this.modulus=new ue.Integer({valueHex:i.slice(0,Math.pow(2,(t=i.byteLength,r=Math.log(t)/ke,n=Math.floor(r),a=Math.round(r),n===a?n:a)))}),!("e"in e))throw new Error('Absent mandatory parameter "e"');this.publicExponent=new ue.Integer({valueHex:be(ye(e.e,!0)).slice(0,3)})}}],[{key:"defaultValues",value:function(e){switch(e){case"modulus":case"publicExponent":return new ue.Integer;default:throw new Error("Invalid member name for RSAPublicKey class: ".concat(e))}}},{key:"schema",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=le(e,"names",{});return new ue.Sequence({name:t.blockName||"",value:[new ue.Integer({name:t.modulus||""}),new ue.Integer({name:t.publicExponent||""})]})}}]),e}(),Ne=function(){function e(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};a(this,e),this.algorithm=le(t,"algorithm",e.defaultValues("algorithm")),this.subjectPublicKey=le(t,"subjectPublicKey",e.defaultValues("subjectPublicKey")),"parsedKey"in t&&(this.parsedKey=le(t,"parsedKey",e.defaultValues("parsedKey"))),"schema"in t&&this.fromSchema(t.schema),"json"in t&&this.fromJSON(t.json)}return s(e,[{key:"fromSchema",value:function(t){we(t,["algorithm","subjectPublicKey"]);var r=ue.compareSchema(t,t,e.schema({names:{algorithm:{names:{blockName:"algorithm"}},subjectPublicKey:"subjectPublicKey"}}));if(!1===r.verified)throw new Error("Object's schema was not verified against input data for PublicKeyInfo");switch(this.algorithm=new Se({schema:r.result.algorithm}),this.subjectPublicKey=r.result.subjectPublicKey,this.algorithm.algorithmId){case"1.2.840.10045.2.1":if("algorithmParams"in this.algorithm&&this.algorithm.algorithmParams.constructor.blockName()===ue.ObjectIdentifier.blockName())try{this.parsedKey=new Ae({namedCurve:this.algorithm.algorithmParams.valueBlock.toString(),schema:this.subjectPublicKey.valueBlock.valueHex})}catch(e){}break;case"1.2.840.113549.1.1.1":var n=ue.fromBER(this.subjectPublicKey.valueBlock.valueHex);if(-1!==n.offset)try{this.parsedKey=new Ce({schema:n.result})}catch(e){}}}},{key:"toSchema",value:function(){return new ue.Sequence({value:[this.algorithm.toSchema(),this.subjectPublicKey]})}},{key:"toJSON",value:function(){if("parsedKey"in this==!1)return{algorithm:this.algorithm.toJSON(),subjectPublicKey:this.subjectPublicKey.toJSON()};var e={};switch(this.algorithm.algorithmId){case"1.2.840.10045.2.1":e.kty="EC";break;case"1.2.840.113549.1.1.1":e.kty="RSA"}for(var t=this.parsedKey.toJSON(),r=0,n=Object.keys(t);r<n.length;r++){var a=n[r];e[a]=t[a]}return e}},{key:"fromJSON",value:function(e){if("kty"in e){switch(e.kty.toUpperCase()){case"EC":this.parsedKey=new Ae({json:e}),this.algorithm=new Se({algorithmId:"1.2.840.10045.2.1",algorithmParams:new ue.ObjectIdentifier({value:this.parsedKey.namedCurve})});break;case"RSA":this.parsedKey=new Ce({json:e}),this.algorithm=new Se({algorithmId:"1.2.840.113549.1.1.1",algorithmParams:new ue.Null});break;default:throw new Error('Invalid value for "kty" parameter: '.concat(e.kty))}this.subjectPublicKey=new ue.BitString({valueHex:this.parsedKey.toSchema().toBER(!1)})}}},{key:"importKey",value:function(e){var t=Promise.resolve(),r=this;if(void 0===e)return Promise.reject("Need to provide publicKey input parameter");var n=je();return void 0===n?Promise.reject("Unable to create WebCrypto object"):t=(t=t.then((function(){return n.exportKey("spki",e)}))).then((function(e){var t=ue.fromBER(e);try{r.fromSchema(t.result)}catch(e){return Promise.reject("Error during initializing object from schema")}}),(function(e){return Promise.reject("Error during exporting public key: ".concat(e))}))}}],[{key:"defaultValues",value:function(e){switch(e){case"algorithm":return new Se;case"subjectPublicKey":return new ue.BitString;default:throw new Error("Invalid member name for PublicKeyInfo class: ".concat(e))}}},{key:"schema",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=le(e,"names",{});return new ue.Sequence({name:t.blockName||"",value:[Se.schema(t.algorithm||{}),new ue.BitString({name:t.subjectPublicKey||""})]})}}]),e}(),Be=function(){function e(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};a(this,e),this.type=le(t,"type",e.defaultValues("type")),this.values=le(t,"values",e.defaultValues("values")),"schema"in t&&this.fromSchema(t.schema)}return s(e,[{key:"fromSchema",value:function(t){we(t,["type","values"]);var r=ue.compareSchema(t,t,e.schema({names:{type:"type",values:"values"}}));if(!1===r.verified)throw new Error("Object's schema was not verified against input data for Attribute");this.type=r.result.type.valueBlock.toString(),this.values=r.result.values}},{key:"toSchema",value:function(){return new ue.Sequence({value:[new ue.ObjectIdentifier({value:this.type}),new ue.Set({value:this.values})]})}},{key:"toJSON",value:function(){return{type:this.type,values:Array.from(this.values,(function(e){return e.toJSON()}))}}}],[{key:"defaultValues",value:function(e){switch(e){case"type":return"";case"values":return[];default:throw new Error("Invalid member name for Attribute class: ".concat(e))}}},{key:"compareWithDefault",value:function(e,t){switch(e){case"type":return""===t;case"values":return 0===t.length;default:throw new Error("Invalid member name for Attribute class: ".concat(e))}}},{key:"schema",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=le(e,"names",{});return new ue.Sequence({name:t.blockName||"",value:[new ue.ObjectIdentifier({name:t.type||""}),new ue.Set({name:t.setName||"",value:[new ue.Repeated({name:t.values||"",value:new ue.Any})]})]})}}]),e}(),Ie=function(){function e(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};a(this,e),this.version=le(t,"version",e.defaultValues("version")),this.privateKey=le(t,"privateKey",e.defaultValues("privateKey")),"namedCurve"in t&&(this.namedCurve=le(t,"namedCurve",e.defaultValues("namedCurve"))),"publicKey"in t&&(this.publicKey=le(t,"publicKey",e.defaultValues("publicKey"))),"schema"in t&&this.fromSchema(t.schema),"json"in t&&this.fromJSON(t.json)}return s(e,[{key:"fromSchema",value:function(t){we(t,["version","privateKey","namedCurve","publicKey"]);var r=ue.compareSchema(t,t,e.schema({names:{version:"version",privateKey:"privateKey",namedCurve:"namedCurve",publicKey:"publicKey"}}));if(!1===r.verified)throw new Error("Object's schema was not verified against input data for ECPrivateKey");if(this.version=r.result.version.valueBlock.valueDec,this.privateKey=r.result.privateKey,"namedCurve"in r.result&&(this.namedCurve=r.result.namedCurve.valueBlock.toString()),"publicKey"in r.result){var n={schema:r.result.publicKey.valueBlock.valueHex};"namedCurve"in this&&(n.namedCurve=this.namedCurve),this.publicKey=new Ae(n)}}},{key:"toSchema",value:function(){var e=[new ue.Integer({value:this.version}),this.privateKey];return"namedCurve"in this&&e.push(new ue.Constructed({idBlock:{tagClass:3,tagNumber:0},value:[new ue.ObjectIdentifier({value:this.namedCurve})]})),"publicKey"in this&&e.push(new ue.Constructed({idBlock:{tagClass:3,tagNumber:1},value:[new ue.BitString({valueHex:this.publicKey.toSchema().toBER(!1)})]})),new ue.Sequence({value:e})}},{key:"toJSON",value:function(){if("namedCurve"in this==!1||e.compareWithDefault("namedCurve",this.namedCurve))throw new Error('Not enough information for making JSON: absent "namedCurve" value');var t="";switch(this.namedCurve){case"1.2.840.10045.3.1.7":t="P-256";break;case"1.3.132.0.34":t="P-384";break;case"1.3.132.0.35":t="P-521"}var r={crv:t,d:de(pe(this.privateKey.valueBlock.valueHex),!0,!0,!1)};if("publicKey"in this){var n=this.publicKey.toJSON();r.x=n.x,r.y=n.y}return r}},{key:"fromJSON",value:function(e){var t=0;if(!("crv"in e))throw new Error('Absent mandatory parameter "crv"');switch(e.crv.toUpperCase()){case"P-256":this.namedCurve="1.2.840.10045.3.1.7",t=32;break;case"P-384":this.namedCurve="1.3.132.0.34",t=48;break;case"P-521":this.namedCurve="1.3.132.0.35",t=66}if(!("d"in e))throw new Error('Absent mandatory parameter "d"');var r=be(ye(e.d,!0));if(r.byteLength<t){var n=new ArrayBuffer(t),a=new Uint8Array(n),i=new Uint8Array(r);a.set(i,1),this.privateKey=new ue.OctetString({valueHex:n})}else this.privateKey=new ue.OctetString({valueHex:r.slice(0,t)});"x"in e&&"y"in e&&(this.publicKey=new Ae({json:e}))}}],[{key:"defaultValues",value:function(e){switch(e){case"version":return 1;case"privateKey":return new ue.OctetString;case"namedCurve":return"";case"publicKey":return new Ae;default:throw new Error("Invalid member name for ECCPrivateKey class: ".concat(e))}}},{key:"compareWithDefault",value:function(t,r){switch(t){case"version":return r===e.defaultValues(t);case"privateKey":return r.isEqual(e.defaultValues(t));case"namedCurve":return""===r;case"publicKey":return Ae.compareWithDefault("namedCurve",r.namedCurve)&&Ae.compareWithDefault("x",r.x)&&Ae.compareWithDefault("y",r.y);default:throw new Error("Invalid member name for ECCPrivateKey class: ".concat(t))}}},{key:"schema",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=le(e,"names",{});return new ue.Sequence({name:t.blockName||"",value:[new ue.Integer({name:t.version||""}),new ue.OctetString({name:t.privateKey||""}),new ue.Constructed({optional:!0,idBlock:{tagClass:3,tagNumber:0},value:[new ue.ObjectIdentifier({name:t.namedCurve||""})]}),new ue.Constructed({optional:!0,idBlock:{tagClass:3,tagNumber:1},value:[new ue.BitString({name:t.publicKey||""})]})]})}}]),e}(),Pe=function(){function e(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};a(this,e),this.prime=le(t,"prime",e.defaultValues("prime")),this.exponent=le(t,"exponent",e.defaultValues("exponent")),this.coefficient=le(t,"coefficient",e.defaultValues("coefficient")),"schema"in t&&this.fromSchema(t.schema),"json"in t&&this.fromJSON(t.json)}return s(e,[{key:"fromSchema",value:function(t){we(t,["prime","exponent","coefficient"]);var r=ue.compareSchema(t,t,e.schema({names:{prime:"prime",exponent:"exponent",coefficient:"coefficient"}}));if(!1===r.verified)throw new Error("Object's schema was not verified against input data for OtherPrimeInfo");this.prime=r.result.prime.convertFromDER(),this.exponent=r.result.exponent.convertFromDER(),this.coefficient=r.result.coefficient.convertFromDER()}},{key:"toSchema",value:function(){return new ue.Sequence({value:[this.prime.convertToDER(),this.exponent.convertToDER(),this.coefficient.convertToDER()]})}},{key:"toJSON",value:function(){return{r:de(pe(this.prime.valueBlock.valueHex),!0,!0),d:de(pe(this.exponent.valueBlock.valueHex),!0,!0),t:de(pe(this.coefficient.valueBlock.valueHex),!0,!0)}}},{key:"fromJSON",value:function(e){if(!("r"in e))throw new Error('Absent mandatory parameter "r"');if(this.prime=new ue.Integer({valueHex:be(ye(e.r,!0))}),!("d"in e))throw new Error('Absent mandatory parameter "d"');if(this.exponent=new ue.Integer({valueHex:be(ye(e.d,!0))}),!("t"in e))throw new Error('Absent mandatory parameter "t"');this.coefficient=new ue.Integer({valueHex:be(ye(e.t,!0))})}}],[{key:"defaultValues",value:function(e){switch(e){case"prime":case"exponent":case"coefficient":return new ue.Integer;default:throw new Error("Invalid member name for OtherPrimeInfo class: ".concat(e))}}},{key:"schema",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=le(e,"names",{});return new ue.Sequence({name:t.blockName||"",value:[new ue.Integer({name:t.prime||""}),new ue.Integer({name:t.exponent||""}),new ue.Integer({name:t.coefficient||""})]})}}]),e}(),Ee=function(){function e(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};a(this,e),this.version=le(t,"version",e.defaultValues("version")),this.modulus=le(t,"modulus",e.defaultValues("modulus")),this.publicExponent=le(t,"publicExponent",e.defaultValues("publicExponent")),this.privateExponent=le(t,"privateExponent",e.defaultValues("privateExponent")),this.prime1=le(t,"prime1",e.defaultValues("prime1")),this.prime2=le(t,"prime2",e.defaultValues("prime2")),this.exponent1=le(t,"exponent1",e.defaultValues("exponent1")),this.exponent2=le(t,"exponent2",e.defaultValues("exponent2")),this.coefficient=le(t,"coefficient",e.defaultValues("coefficient")),"otherPrimeInfos"in t&&(this.otherPrimeInfos=le(t,"otherPrimeInfos",e.defaultValues("otherPrimeInfos"))),"schema"in t&&this.fromSchema(t.schema),"json"in t&&this.fromJSON(t.json)}return s(e,[{key:"fromSchema",value:function(t){we(t,["version","modulus","publicExponent","privateExponent","prime1","prime2","exponent1","exponent2","coefficient","otherPrimeInfos"]);var r=ue.compareSchema(t,t,e.schema({names:{version:"version",modulus:"modulus",publicExponent:"publicExponent",privateExponent:"privateExponent",prime1:"prime1",prime2:"prime2",exponent1:"exponent1",exponent2:"exponent2",coefficient:"coefficient",otherPrimeInfo:{names:{blockName:"otherPrimeInfos"}}}}));if(!1===r.verified)throw new Error("Object's schema was not verified against input data for RSAPrivateKey");this.version=r.result.version.valueBlock.valueDec,this.modulus=r.result.modulus.convertFromDER(256),this.publicExponent=r.result.publicExponent,this.privateExponent=r.result.privateExponent.convertFromDER(256),this.prime1=r.result.prime1.convertFromDER(128),this.prime2=r.result.prime2.convertFromDER(128),this.exponent1=r.result.exponent1.convertFromDER(128),this.exponent2=r.result.exponent2.convertFromDER(128),this.coefficient=r.result.coefficient.convertFromDER(128),"otherPrimeInfos"in r.result&&(this.otherPrimeInfos=Array.from(r.result.otherPrimeInfos,(function(e){return new Pe({schema:e})})))}},{key:"toSchema",value:function(){var e=[];return e.push(new ue.Integer({value:this.version})),e.push(this.modulus.convertToDER()),e.push(this.publicExponent),e.push(this.privateExponent.convertToDER()),e.push(this.prime1.convertToDER()),e.push(this.prime2.convertToDER()),e.push(this.exponent1.convertToDER()),e.push(this.exponent2.convertToDER()),e.push(this.coefficient.convertToDER()),"otherPrimeInfos"in this&&e.push(new ue.Sequence({value:Array.from(this.otherPrimeInfos,(function(e){return e.toSchema()}))})),new ue.Sequence({value:e})}},{key:"toJSON",value:function(){var e={n:de(pe(this.modulus.valueBlock.valueHex),!0,!0,!0),e:de(pe(this.publicExponent.valueBlock.valueHex),!0,!0,!0),d:de(pe(this.privateExponent.valueBlock.valueHex),!0,!0,!0),p:de(pe(this.prime1.valueBlock.valueHex),!0,!0,!0),q:de(pe(this.prime2.valueBlock.valueHex),!0,!0,!0),dp:de(pe(this.exponent1.valueBlock.valueHex),!0,!0,!0),dq:de(pe(this.exponent2.valueBlock.valueHex),!0,!0,!0),qi:de(pe(this.coefficient.valueBlock.valueHex),!0,!0,!0)};return"otherPrimeInfos"in this&&(e.oth=Array.from(this.otherPrimeInfos,(function(e){return e.toJSON()}))),e}},{key:"fromJSON",value:function(e){if(!("n"in e))throw new Error('Absent mandatory parameter "n"');if(this.modulus=new ue.Integer({valueHex:be(ye(e.n,!0,!0))}),!("e"in e))throw new Error('Absent mandatory parameter "e"');if(this.publicExponent=new ue.Integer({valueHex:be(ye(e.e,!0,!0))}),!("d"in e))throw new Error('Absent mandatory parameter "d"');if(this.privateExponent=new ue.Integer({valueHex:be(ye(e.d,!0,!0))}),!("p"in e))throw new Error('Absent mandatory parameter "p"');if(this.prime1=new ue.Integer({valueHex:be(ye(e.p,!0,!0))}),!("q"in e))throw new Error('Absent mandatory parameter "q"');if(this.prime2=new ue.Integer({valueHex:be(ye(e.q,!0,!0))}),!("dp"in e))throw new Error('Absent mandatory parameter "dp"');if(this.exponent1=new ue.Integer({valueHex:be(ye(e.dp,!0,!0))}),!("dq"in e))throw new Error('Absent mandatory parameter "dq"');if(this.exponent2=new ue.Integer({valueHex:be(ye(e.dq,!0,!0))}),!("qi"in e))throw new Error('Absent mandatory parameter "qi"');this.coefficient=new ue.Integer({valueHex:be(ye(e.qi,!0,!0))}),"oth"in e&&(this.otherPrimeInfos=Array.from(e.oth,(function(e){return new Pe({json:e})})))}}],[{key:"defaultValues",value:function(e){switch(e){case"version":return 0;case"modulus":case"publicExponent":case"privateExponent":case"prime1":case"prime2":case"exponent1":case"exponent2":case"coefficient":return new ue.Integer;case"otherPrimeInfos":return[];default:throw new Error("Invalid member name for RSAPrivateKey class: ".concat(e))}}},{key:"schema",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=le(e,"names",{});return new ue.Sequence({name:t.blockName||"",value:[new ue.Integer({name:t.version||""}),new ue.Integer({name:t.modulus||""}),new ue.Integer({name:t.publicExponent||""}),new ue.Integer({name:t.privateExponent||""}),new ue.Integer({name:t.prime1||""}),new ue.Integer({name:t.prime2||""}),new ue.Integer({name:t.exponent1||""}),new ue.Integer({name:t.exponent2||""}),new ue.Integer({name:t.coefficient||""}),new ue.Sequence({optional:!0,value:[new ue.Repeated({name:t.otherPrimeInfosName||"",value:Pe.schema(t.otherPrimeInfo||{})})]})]})}}]),e}(),xe=function(){function e(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};a(this,e),this.version=le(t,"version",e.defaultValues("version")),this.privateKeyAlgorithm=le(t,"privateKeyAlgorithm",e.defaultValues("privateKeyAlgorithm")),this.privateKey=le(t,"privateKey",e.defaultValues("privateKey")),"attributes"in t&&(this.attributes=le(t,"attributes",e.defaultValues("attributes"))),"parsedKey"in t&&(this.parsedKey=le(t,"parsedKey",e.defaultValues("parsedKey"))),"schema"in t&&this.fromSchema(t.schema),"json"in t&&this.fromJSON(t.json)}return s(e,[{key:"fromSchema",value:function(t){we(t,["version","privateKeyAlgorithm","privateKey","attributes"]);var r=ue.compareSchema(t,t,e.schema({names:{version:"version",privateKeyAlgorithm:{names:{blockName:"privateKeyAlgorithm"}},privateKey:"privateKey",attributes:"attributes"}}));if(!1===r.verified)throw new Error("Object's schema was not verified against input data for PrivateKeyInfo");switch(this.version=r.result.version.valueBlock.valueDec,this.privateKeyAlgorithm=new Se({schema:r.result.privateKeyAlgorithm}),this.privateKey=r.result.privateKey,"attributes"in r.result&&(this.attributes=Array.from(r.result.attributes,(function(e){return new Be({schema:e})}))),this.privateKeyAlgorithm.algorithmId){case"1.2.840.113549.1.1.1":var n=ue.fromBER(this.privateKey.valueBlock.valueHex);-1!==n.offset&&(this.parsedKey=new Ee({schema:n.result}));break;case"1.2.840.10045.2.1":if("algorithmParams"in this.privateKeyAlgorithm&&this.privateKeyAlgorithm.algorithmParams instanceof ue.ObjectIdentifier){var a=ue.fromBER(this.privateKey.valueBlock.valueHex);-1!==a.offset&&(this.parsedKey=new Ie({namedCurve:this.privateKeyAlgorithm.algorithmParams.valueBlock.toString(),schema:a.result}))}}}},{key:"toSchema",value:function(){var e=[new ue.Integer({value:this.version}),this.privateKeyAlgorithm.toSchema(),this.privateKey];return"attributes"in this&&e.push(new ue.Constructed({optional:!0,idBlock:{tagClass:3,tagNumber:0},value:Array.from(this.attributes,(function(e){return e.toSchema()}))})),new ue.Sequence({value:e})}},{key:"toJSON",value:function(){if("parsedKey"in this==!1){var e={version:this.version,privateKeyAlgorithm:this.privateKeyAlgorithm.toJSON(),privateKey:this.privateKey.toJSON()};return"attributes"in this&&(e.attributes=Array.from(this.attributes,(function(e){return e.toJSON()}))),e}var t={};switch(this.privateKeyAlgorithm.algorithmId){case"1.2.840.10045.2.1":t.kty="EC";break;case"1.2.840.113549.1.1.1":t.kty="RSA"}for(var r=this.parsedKey.toJSON(),n=0,a=Object.keys(r);n<a.length;n++){var i=a[n];t[i]=r[i]}return t}},{key:"fromJSON",value:function(e){if("kty"in e){switch(e.kty.toUpperCase()){case"EC":this.parsedKey=new Ie({json:e}),this.privateKeyAlgorithm=new Se({algorithmId:"1.2.840.10045.2.1",algorithmParams:new ue.ObjectIdentifier({value:this.parsedKey.namedCurve})});break;case"RSA":this.parsedKey=new Ee({json:e}),this.privateKeyAlgorithm=new Se({algorithmId:"1.2.840.113549.1.1.1",algorithmParams:new ue.Null});break;default:throw new Error('Invalid value for "kty" parameter: '.concat(e.kty))}this.privateKey=new ue.OctetString({valueHex:this.parsedKey.toSchema().toBER(!1)})}}}],[{key:"defaultValues",value:function(e){switch(e){case"version":return 0;case"privateKeyAlgorithm":return new Se;case"privateKey":return new ue.OctetString;case"attributes":return[];case"parsedKey":return{};default:throw new Error("Invalid member name for PrivateKeyInfo class: ".concat(e))}}},{key:"schema",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=le(e,"names",{});return new ue.Sequence({name:t.blockName||"",value:[new ue.Integer({name:t.version||""}),Se.schema(t.privateKeyAlgorithm||{}),new ue.OctetString({name:t.privateKey||""}),new ue.Constructed({optional:!0,idBlock:{tagClass:3,tagNumber:0},value:[new ue.Repeated({name:t.attributes||"",value:Be.schema()})]})]})}}]),e}(),Re=function(){function e(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};if(a(this,e),this.contentType=le(t,"contentType",e.defaultValues("contentType")),this.contentEncryptionAlgorithm=le(t,"contentEncryptionAlgorithm",e.defaultValues("contentEncryptionAlgorithm")),"encryptedContent"in t&&(this.encryptedContent=t.encryptedContent,1===this.encryptedContent.idBlock.tagClass&&4===this.encryptedContent.idBlock.tagNumber&&!1===this.encryptedContent.idBlock.isConstructed)){for(var r=new ue.OctetString({idBlock:{isConstructed:!0},isConstructed:!0}),n=0,i=this.encryptedContent.valueBlock.valueHex.byteLength;i>0;){for(var s=new Uint8Array(this.encryptedContent.valueBlock.valueHex,n,n+1024>this.encryptedContent.valueBlock.valueHex.byteLength?this.encryptedContent.valueBlock.valueHex.byteLength-n:1024),o=new ArrayBuffer(s.length),u=new Uint8Array(o),l=0;l<u.length;l++)u[l]=s[l];r.valueBlock.value.push(new ue.OctetString({valueHex:o})),i-=s.length,n+=s.length}this.encryptedContent=r}"schema"in t&&this.fromSchema(t.schema)}return s(e,[{key:"fromSchema",value:function(t){we(t,["contentType","contentEncryptionAlgorithm","encryptedContent"]);var r=ue.compareSchema(t,t,e.schema({names:{contentType:"contentType",contentEncryptionAlgorithm:{names:{blockName:"contentEncryptionAlgorithm"}},encryptedContent:"encryptedContent"}}));if(!1===r.verified)throw new Error("Object's schema was not verified against input data for EncryptedContentInfo");this.contentType=r.result.contentType.valueBlock.toString(),this.contentEncryptionAlgorithm=new Se({schema:r.result.contentEncryptionAlgorithm}),"encryptedContent"in r.result&&(this.encryptedContent=r.result.encryptedContent,this.encryptedContent.idBlock.tagClass=1,this.encryptedContent.idBlock.tagNumber=4)}},{key:"toSchema",value:function(){var e={isIndefiniteForm:!1},t=[];if(t.push(new ue.ObjectIdentifier({value:this.contentType})),t.push(this.contentEncryptionAlgorithm.toSchema()),"encryptedContent"in this){e.isIndefiniteForm=this.encryptedContent.idBlock.isConstructed;var r=this.encryptedContent;r.idBlock.tagClass=3,r.idBlock.tagNumber=0,r.lenBlock.isIndefiniteForm=this.encryptedContent.idBlock.isConstructed,t.push(r)}return new ue.Sequence({lenBlock:e,value:t})}},{key:"toJSON",value:function(){var e={contentType:this.contentType,contentEncryptionAlgorithm:this.contentEncryptionAlgorithm.toJSON()};return"encryptedContent"in this&&(e.encryptedContent=this.encryptedContent.toJSON()),e}}],[{key:"defaultValues",value:function(e){switch(e){case"contentType":return"";case"contentEncryptionAlgorithm":return new Se;case"encryptedContent":return new ue.OctetString;default:throw new Error("Invalid member name for EncryptedContentInfo class: ".concat(e))}}},{key:"compareWithDefault",value:function(t,r){switch(t){case"contentType":return""===r;case"contentEncryptionAlgorithm":return""===r.algorithmId&&"algorithmParams"in r==!1;case"encryptedContent":return r.isEqual(e.defaultValues(t));default:throw new Error("Invalid member name for EncryptedContentInfo class: ".concat(t))}}},{key:"schema",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=le(e,"names",{});return new ue.Sequence({name:t.blockName||"",value:[new ue.ObjectIdentifier({name:t.contentType||""}),Se.schema(t.contentEncryptionAlgorithm||{}),new ue.Choice({value:[new ue.Constructed({name:t.encryptedContent||"",idBlock:{tagClass:3,tagNumber:0},value:[new ue.Repeated({value:new ue.OctetString})]}),new ue.Primitive({name:t.encryptedContent||"",idBlock:{tagClass:3,tagNumber:0}})]})]})}}]),e}(),Le=function(){function e(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};a(this,e),this.hashAlgorithm=le(t,"hashAlgorithm",e.defaultValues("hashAlgorithm")),this.maskGenAlgorithm=le(t,"maskGenAlgorithm",e.defaultValues("maskGenAlgorithm")),this.saltLength=le(t,"saltLength",e.defaultValues("saltLength")),this.trailerField=le(t,"trailerField",e.defaultValues("trailerField")),"schema"in t&&this.fromSchema(t.schema)}return s(e,[{key:"fromSchema",value:function(t){we(t,["hashAlgorithm","maskGenAlgorithm","saltLength","trailerField"]);var r=ue.compareSchema(t,t,e.schema({names:{hashAlgorithm:{names:{blockName:"hashAlgorithm"}},maskGenAlgorithm:{names:{blockName:"maskGenAlgorithm"}},saltLength:"saltLength",trailerField:"trailerField"}}));if(!1===r.verified)throw new Error("Object's schema was not verified against input data for RSASSAPSSParams");"hashAlgorithm"in r.result&&(this.hashAlgorithm=new Se({schema:r.result.hashAlgorithm})),"maskGenAlgorithm"in r.result&&(this.maskGenAlgorithm=new Se({schema:r.result.maskGenAlgorithm})),"saltLength"in r.result&&(this.saltLength=r.result.saltLength.valueBlock.valueDec),"trailerField"in r.result&&(this.trailerField=r.result.trailerField.valueBlock.valueDec)}},{key:"toSchema",value:function(){var t=[];return this.hashAlgorithm.isEqual(e.defaultValues("hashAlgorithm"))||t.push(new ue.Constructed({idBlock:{tagClass:3,tagNumber:0},value:[this.hashAlgorithm.toSchema()]})),this.maskGenAlgorithm.isEqual(e.defaultValues("maskGenAlgorithm"))||t.push(new ue.Constructed({idBlock:{tagClass:3,tagNumber:1},value:[this.maskGenAlgorithm.toSchema()]})),this.saltLength!==e.defaultValues("saltLength")&&t.push(new ue.Constructed({idBlock:{tagClass:3,tagNumber:2},value:[new ue.Integer({value:this.saltLength})]})),this.trailerField!==e.defaultValues("trailerField")&&t.push(new ue.Constructed({idBlock:{tagClass:3,tagNumber:3},value:[new ue.Integer({value:this.trailerField})]})),new ue.Sequence({value:t})}},{key:"toJSON",value:function(){var t={};return this.hashAlgorithm.isEqual(e.defaultValues("hashAlgorithm"))||(t.hashAlgorithm=this.hashAlgorithm.toJSON()),this.maskGenAlgorithm.isEqual(e.defaultValues("maskGenAlgorithm"))||(t.maskGenAlgorithm=this.maskGenAlgorithm.toJSON()),this.saltLength!==e.defaultValues("saltLength")&&(t.saltLength=this.saltLength),this.trailerField!==e.defaultValues("trailerField")&&(t.trailerField=this.trailerField),t}}],[{key:"defaultValues",value:function(e){switch(e){case"hashAlgorithm":return new Se({algorithmId:"1.3.14.3.2.26",algorithmParams:new ue.Null});case"maskGenAlgorithm":return new Se({algorithmId:"1.2.840.113549.1.1.8",algorithmParams:new Se({algorithmId:"1.3.14.3.2.26",algorithmParams:new ue.Null}).toSchema()});case"saltLength":return 20;case"trailerField":return 1;default:throw new Error("Invalid member name for RSASSAPSSParams class: ".concat(e))}}},{key:"schema",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=le(e,"names",{});return new ue.Sequence({name:t.blockName||"",value:[new ue.Constructed({idBlock:{tagClass:3,tagNumber:0},optional:!0,value:[Se.schema(t.hashAlgorithm||{})]}),new ue.Constructed({idBlock:{tagClass:3,tagNumber:1},optional:!0,value:[Se.schema(t.maskGenAlgorithm||{})]}),new ue.Constructed({idBlock:{tagClass:3,tagNumber:2},optional:!0,value:[new ue.Integer({name:t.saltLength||""})]}),new ue.Constructed({idBlock:{tagClass:3,tagNumber:3},optional:!0,value:[new ue.Integer({name:t.trailerField||""})]})]})}}]),e}(),Oe=function(){function e(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};a(this,e),this.salt=le(t,"salt",e.defaultValues("salt")),this.iterationCount=le(t,"iterationCount",e.defaultValues("iterationCount")),"keyLength"in t&&(this.keyLength=le(t,"keyLength",e.defaultValues("keyLength"))),"prf"in t&&(this.prf=le(t,"prf",e.defaultValues("prf"))),"schema"in t&&this.fromSchema(t.schema)}return s(e,[{key:"fromSchema",value:function(t){we(t,["salt","iterationCount","keyLength","prf"]);var r=ue.compareSchema(t,t,e.schema({names:{saltPrimitive:"salt",saltConstructed:{names:{blockName:"salt"}},iterationCount:"iterationCount",keyLength:"keyLength",prf:{names:{blockName:"prf",optional:!0}}}}));if(!1===r.verified)throw new Error("Object's schema was not verified against input data for PBKDF2Params");this.salt=r.result.salt,this.iterationCount=r.result.iterationCount.valueBlock.valueDec,"keyLength"in r.result&&(this.keyLength=r.result.keyLength.valueBlock.valueDec),"prf"in r.result&&(this.prf=new Se({schema:r.result.prf}))}},{key:"toSchema",value:function(){var t=[];return t.push(this.salt),t.push(new ue.Integer({value:this.iterationCount})),"keyLength"in this&&e.defaultValues("keyLength")!==this.keyLength&&t.push(new ue.Integer({value:this.keyLength})),"prf"in this&&!1===e.defaultValues("prf").isEqual(this.prf)&&t.push(this.prf.toSchema()),new ue.Sequence({value:t})}},{key:"toJSON",value:function(){var t={salt:this.salt.toJSON(),iterationCount:this.iterationCount};return"keyLength"in this&&e.defaultValues("keyLength")!==this.keyLength&&(t.keyLength=this.keyLength),"prf"in this&&!1===e.defaultValues("prf").isEqual(this.prf)&&(t.prf=this.prf.toJSON()),t}}],[{key:"defaultValues",value:function(e){switch(e){case"salt":return{};case"iterationCount":return-1;case"keyLength":return 0;case"prf":return new Se({algorithmId:"1.3.14.3.2.26",algorithmParams:new ue.Null});default:throw new Error("Invalid member name for PBKDF2Params class: ".concat(e))}}},{key:"schema",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=le(e,"names",{});return new ue.Sequence({name:t.blockName||"",value:[new ue.Choice({value:[new ue.OctetString({name:t.saltPrimitive||""}),Se.schema(t.saltConstructed||{})]}),new ue.Integer({name:t.iterationCount||""}),new ue.Integer({name:t.keyLength||"",optional:!0}),Se.schema(t.prf||{names:{optional:!0}})]})}}]),e}(),Ue=function(){function e(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};a(this,e),this.keyDerivationFunc=le(t,"keyDerivationFunc",e.defaultValues("keyDerivationFunc")),this.encryptionScheme=le(t,"encryptionScheme",e.defaultValues("encryptionScheme")),"schema"in t&&this.fromSchema(t.schema)}return s(e,[{key:"fromSchema",value:function(t){we(t,["keyDerivationFunc","encryptionScheme"]);var r=ue.compareSchema(t,t,e.schema({names:{keyDerivationFunc:{names:{blockName:"keyDerivationFunc"}},encryptionScheme:{names:{blockName:"encryptionScheme"}}}}));if(!1===r.verified)throw new Error("Object's schema was not verified against input data for PBES2Params");this.keyDerivationFunc=new Se({schema:r.result.keyDerivationFunc}),this.encryptionScheme=new Se({schema:r.result.encryptionScheme})}},{key:"toSchema",value:function(){return new ue.Sequence({value:[this.keyDerivationFunc.toSchema(),this.encryptionScheme.toSchema()]})}},{key:"toJSON",value:function(){return{keyDerivationFunc:this.keyDerivationFunc.toJSON(),encryptionScheme:this.encryptionScheme.toJSON()}}}],[{key:"defaultValues",value:function(e){switch(e){case"keyDerivationFunc":case"encryptionScheme":return new Se;default:throw new Error("Invalid member name for PBES2Params class: ".concat(e))}}},{key:"schema",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=le(e,"names",{});return new ue.Sequence({name:t.blockName||"",value:[Se.schema(t.keyDerivationFunc||{}),Se.schema(t.encryptionScheme||{})]})}}]),e}();function De(e,t,r,n,a,i){var s,o,u=[];switch(t.toUpperCase()){case"SHA-1":s=20,o=64;break;case"SHA-256":s=32,o=64;break;case"SHA-384":s=48,o=128;break;case"SHA-512":s=64,o=128;break;default:throw new Error("Unsupported hashing algorithm")}for(var l=new Uint8Array(n),c=new ArrayBuffer(2*n.byteLength+2),h=new Uint8Array(c),m=0;m<l.length;m++)h[2*m]=0,h[2*m+1]=l[m];h[h.length-2]=0,h[h.length-1]=0,n=c.slice(0);for(var f=new ArrayBuffer(o),g=new Uint8Array(f),d=0;d<f.byteLength;d++)g[d]=3;for(var y=a.byteLength,p=o*Math.ceil(y/o),b=new ArrayBuffer(p),k=new Uint8Array(b),w=new Uint8Array(a),S=0;S<p;S++)k[S]=w[S%y];for(var A=n.byteLength,C=o*Math.ceil(A/o),N=new ArrayBuffer(C),B=new Uint8Array(N),I=new Uint8Array(n),P=0;P<C;P++)B[P]=I[P%A];var E=b.byteLength+N.byteLength,x=new ArrayBuffer(E),R=new Uint8Array(x);R.set(k),R.set(B,k.length);for(var L=Math.ceil((r>>3)/s),O=Promise.resolve(x),U=0;U<=L;U++){O=O.then((function(e){var t=new ArrayBuffer(f.byteLength+e.byteLength),r=new Uint8Array(t);return r.set(g),r.set(R,g.length),t}));for(var D=0;D<i;D++)O=O.then((function(r){return e.digest({name:t},new Uint8Array(r))}));O=O.then((function(e){for(var t=new ArrayBuffer(o),r=new Uint8Array(t),n=0;n<t.byteLength;n++)r[n]=e[n%e.length];for(var a=Math.ceil(y/o)+Math.ceil(A/o),i=[],s=0,l=o,c=0;c<a;c++){var h=Array.from(new Uint8Array(x.slice(s,s+l)));(s+=o)+o>x.byteLength&&(l=x.byteLength-s);for(var m=511,f=t.byteLength-1;f>=0;f--)m>>=8,m+=r[f]+h[f],h[f]=255&m;i.push.apply(i,v(h))}return x=new ArrayBuffer(i.length),(R=new Uint8Array(x)).set(i),u.push.apply(u,v(new Uint8Array(e))),x}))}return O=O.then((function(){var e=new ArrayBuffer(r>>3);return new Uint8Array(e).set(new Uint8Array(u).slice(0,r>>3)),e}))}var He=function(){function e(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};a(this,e),this.crypto=le(t,"crypto",{}),this.subtle=le(t,"subtle",{}),this.name=le(t,"name","")}return s(e,[{key:"importKey",value:function(e,t,r,n,a){var i=this,s={};switch(t instanceof Uint8Array&&(t=t.buffer),e.toLowerCase()){case"raw":return this.subtle.importKey("raw",t,r,n,a);case"spki":var o=ue.fromBER(t);if(-1===o.offset)return Promise.reject("Incorrect keyData");var u=new Ne;try{u.fromSchema(o.result)}catch(e){return Promise.reject("Incorrect keyData")}switch(r.name.toUpperCase()){case"RSA-PSS":switch(r.hash.name.toUpperCase()){case"SHA-1":s.alg="PS1";break;case"SHA-256":s.alg="PS256";break;case"SHA-384":s.alg="PS384";break;case"SHA-512":s.alg="PS512";break;default:return Promise.reject("Incorrect hash algorithm: ".concat(r.hash.name.toUpperCase()))}case"RSASSA-PKCS1-V1_5":if(a=["verify"],s.kty="RSA",s.ext=n,s.key_ops=a,"1.2.840.113549.1.1.1"!==u.algorithm.algorithmId)return Promise.reject("Incorrect public key algorithm: ".concat(u.algorithm.algorithmId));if("alg"in s==!1)switch(r.hash.name.toUpperCase()){case"SHA-1":s.alg="RS1";break;case"SHA-256":s.alg="RS256";break;case"SHA-384":s.alg="RS384";break;case"SHA-512":s.alg="RS512";break;default:return Promise.reject("Incorrect hash algorithm: ".concat(r.hash.name.toUpperCase()))}for(var l=u.toJSON(),c=0,h=Object.keys(l);c<h.length;c++){var m=h[c];s[m]=l[m]}break;case"ECDSA":a=["verify"];case"ECDH":if(s={kty:"EC",ext:n,key_ops:a},"1.2.840.10045.2.1"!==u.algorithm.algorithmId)return Promise.reject("Incorrect public key algorithm: ".concat(u.algorithm.algorithmId));for(var f=u.toJSON(),v=0,g=Object.keys(f);v<g.length;v++){var d=g[v];s[d]=f[d]}break;case"RSA-OAEP":if(s.kty="RSA",s.ext=n,s.key_ops=a,"safari"===this.name.toLowerCase())s.alg="RSA-OAEP";else switch(r.hash.name.toUpperCase()){case"SHA-1":s.alg="RSA-OAEP";break;case"SHA-256":s.alg="RSA-OAEP-256";break;case"SHA-384":s.alg="RSA-OAEP-384";break;case"SHA-512":s.alg="RSA-OAEP-512";break;default:return Promise.reject("Incorrect hash algorithm: ".concat(r.hash.name.toUpperCase()))}for(var y=u.toJSON(),p=0,b=Object.keys(y);p<b.length;p++){var k=b[p];s[k]=y[k]}break;default:return Promise.reject("Incorrect algorithm name: ".concat(r.name.toUpperCase()))}break;case"pkcs8":var w=new xe,S=ue.fromBER(t);if(-1===S.offset)return Promise.reject("Incorrect keyData");try{w.fromSchema(S.result)}catch(e){return Promise.reject("Incorrect keyData")}if("parsedKey"in w==!1)return Promise.reject("Incorrect keyData");switch(r.name.toUpperCase()){case"RSA-PSS":switch(r.hash.name.toUpperCase()){case"SHA-1":s.alg="PS1";break;case"SHA-256":s.alg="PS256";break;case"SHA-384":s.alg="PS384";break;case"SHA-512":s.alg="PS512";break;default:return Promise.reject("Incorrect hash algorithm: ".concat(r.hash.name.toUpperCase()))}case"RSASSA-PKCS1-V1_5":if(a=["sign"],s.kty="RSA",s.ext=n,s.key_ops=a,"1.2.840.113549.1.1.1"!==w.privateKeyAlgorithm.algorithmId)return Promise.reject("Incorrect private key algorithm: ".concat(w.privateKeyAlgorithm.algorithmId));if("alg"in s==!1)switch(r.hash.name.toUpperCase()){case"SHA-1":s.alg="RS1";break;case"SHA-256":s.alg="RS256";break;case"SHA-384":s.alg="RS384";break;case"SHA-512":s.alg="RS512";break;default:return Promise.reject("Incorrect hash algorithm: ".concat(r.hash.name.toUpperCase()))}for(var A=w.toJSON(),C=0,N=Object.keys(A);C<N.length;C++){var B=N[C];s[B]=A[B]}break;case"ECDSA":a=["sign"];case"ECDH":if(s={kty:"EC",ext:n,key_ops:a},"1.2.840.10045.2.1"!==w.privateKeyAlgorithm.algorithmId)return Promise.reject("Incorrect algorithm: ".concat(w.privateKeyAlgorithm.algorithmId));for(var I=w.toJSON(),P=0,E=Object.keys(I);P<E.length;P++){var x=E[P];s[x]=I[x]}break;case"RSA-OAEP":if(s.kty="RSA",s.ext=n,s.key_ops=a,"safari"===this.name.toLowerCase())s.alg="RSA-OAEP";else switch(r.hash.name.toUpperCase()){case"SHA-1":s.alg="RSA-OAEP";break;case"SHA-256":s.alg="RSA-OAEP-256";break;case"SHA-384":s.alg="RSA-OAEP-384";break;case"SHA-512":s.alg="RSA-OAEP-512";break;default:return Promise.reject("Incorrect hash algorithm: ".concat(r.hash.name.toUpperCase()))}for(var R=w.toJSON(),L=0,O=Object.keys(R);L<O.length;L++){var U=O[L];s[U]=R[U]}break;default:return Promise.reject("Incorrect algorithm name: ".concat(r.name.toUpperCase()))}break;case"jwk":s=t;break;default:return Promise.reject("Incorrect format: ".concat(e))}return"safari"===this.name.toLowerCase()?Promise.resolve().then((function(){return i.subtle.importKey("jwk",be(JSON.stringify(s)),r,n,a)})).then((function(e){return e}),(function(){return i.subtle.importKey("jwk",s,r,n,a)})):this.subtle.importKey("jwk",s,r,n,a)}},{key:"exportKey",value:function(e,t){var r=this.subtle.exportKey("jwk",t);switch("safari"===this.name.toLowerCase()&&(r=r.then((function(e){return e instanceof ArrayBuffer?JSON.parse(pe(e)):e}))),e.toLowerCase()){case"raw":return this.subtle.exportKey("raw",t);case"spki":r=r.then((function(e){var t=new Ne;try{t.fromJSON(e)}catch(e){return Promise.reject("Incorrect key data")}return t.toSchema().toBER(!1)}));break;case"pkcs8":r=r.then((function(e){var t=new xe;try{t.fromJSON(e)}catch(e){return Promise.reject("Incorrect key data")}return t.toSchema().toBER(!1)}));break;case"jwk":break;default:return Promise.reject("Incorrect format: ".concat(e))}return r}},{key:"convert",value:function(e,t,r,n,a,i){var s=this;switch(e.toLowerCase()){case"raw":switch(t.toLowerCase()){case"raw":return Promise.resolve(r);case"spki":return Promise.resolve().then((function(){return s.importKey("raw",r,n,a,i)})).then((function(e){return s.exportKey("spki",e)}));case"pkcs8":return Promise.resolve().then((function(){return s.importKey("raw",r,n,a,i)})).then((function(e){return s.exportKey("pkcs8",e)}));case"jwk":return Promise.resolve().then((function(){return s.importKey("raw",r,n,a,i)})).then((function(e){return s.exportKey("jwk",e)}));default:return Promise.reject("Incorrect outputFormat: ".concat(t))}case"spki":switch(t.toLowerCase()){case"raw":return Promise.resolve().then((function(){return s.importKey("spki",r,n,a,i)})).then((function(e){return s.exportKey("raw",e)}));case"spki":return Promise.resolve(r);case"pkcs8":return Promise.reject("Impossible to convert between SPKI/PKCS8");case"jwk":return Promise.resolve().then((function(){return s.importKey("spki",r,n,a,i)})).then((function(e){return s.exportKey("jwk",e)}));default:return Promise.reject("Incorrect outputFormat: ".concat(t))}case"pkcs8":switch(t.toLowerCase()){case"raw":return Promise.resolve().then((function(){return s.importKey("pkcs8",r,n,a,i)})).then((function(e){return s.exportKey("raw",e)}));case"spki":return Promise.reject("Impossible to convert between SPKI/PKCS8");case"pkcs8":return Promise.resolve(r);case"jwk":return Promise.resolve().then((function(){return s.importKey("pkcs8",r,n,a,i)})).then((function(e){return s.exportKey("jwk",e)}));default:return Promise.reject("Incorrect outputFormat: ".concat(t))}case"jwk":switch(t.toLowerCase()){case"raw":return Promise.resolve().then((function(){return s.importKey("jwk",r,n,a,i)})).then((function(e){return s.exportKey("raw",e)}));case"spki":return Promise.resolve().then((function(){return s.importKey("jwk",r,n,a,i)})).then((function(e){return s.exportKey("spki",e)}));case"pkcs8":return Promise.resolve().then((function(){return s.importKey("jwk",r,n,a,i)})).then((function(e){return s.exportKey("pkcs8",e)}));case"jwk":return Promise.resolve(r);default:return Promise.reject("Incorrect outputFormat: ".concat(t))}default:return Promise.reject("Incorrect inputFormat: ".concat(e))}}},{key:"encrypt",value:function(){var e;return(e=this.subtle).encrypt.apply(e,arguments)}},{key:"decrypt",value:function(){var e;return(e=this.subtle).decrypt.apply(e,arguments)}},{key:"sign",value:function(){var e;return(e=this.subtle).sign.apply(e,arguments)}},{key:"verify",value:function(){var e;return(e=this.subtle).verify.apply(e,arguments)}},{key:"digest",value:function(){var e;return(e=this.subtle).digest.apply(e,arguments)}},{key:"generateKey",value:function(){var e;return(e=this.subtle).generateKey.apply(e,arguments)}},{key:"deriveKey",value:function(){var e;return(e=this.subtle).deriveKey.apply(e,arguments)}},{key:"deriveBits",value:function(){var e;return(e=this.subtle).deriveBits.apply(e,arguments)}},{key:"wrapKey",value:function(){var e;return(e=this.subtle).wrapKey.apply(e,arguments)}},{key:"unwrapKey",value:function(){var e;return(e=this.subtle).unwrapKey.apply(e,arguments)}},{key:"getRandomValues",value:function(e){if("getRandomValues"in this.crypto==!1)throw new Error("No support for getRandomValues");return this.crypto.getRandomValues(e)}},{key:"getAlgorithmByOID",value:function(e){switch(e){case"1.2.840.113549.1.1.1":case"1.2.840.113549.1.1.5":return{name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-1"}};case"1.2.840.113549.1.1.11":return{name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-256"}};case"1.2.840.113549.1.1.12":return{name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-384"}};case"1.2.840.113549.1.1.13":return{name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-512"}};case"1.2.840.113549.1.1.10":return{name:"RSA-PSS"};case"1.2.840.113549.1.1.7":return{name:"RSA-OAEP"};case"1.2.840.10045.2.1":case"1.2.840.10045.4.1":return{name:"ECDSA",hash:{name:"SHA-1"}};case"1.2.840.10045.4.3.2":return{name:"ECDSA",hash:{name:"SHA-256"}};case"1.2.840.10045.4.3.3":return{name:"ECDSA",hash:{name:"SHA-384"}};case"1.2.840.10045.4.3.4":return{name:"ECDSA",hash:{name:"SHA-512"}};case"1.3.133.16.840.63.0.2":return{name:"ECDH",kdf:"SHA-1"};case"1.3.132.1.11.1":return{name:"ECDH",kdf:"SHA-256"};case"1.3.132.1.11.2":return{name:"ECDH",kdf:"SHA-384"};case"1.3.132.1.11.3":return{name:"ECDH",kdf:"SHA-512"};case"2.16.840.1.101.3.4.1.2":return{name:"AES-CBC",length:128};case"2.16.840.1.101.3.4.1.22":return{name:"AES-CBC",length:192};case"2.16.840.1.101.3.4.1.42":return{name:"AES-CBC",length:256};case"2.16.840.1.101.3.4.1.6":return{name:"AES-GCM",length:128};case"2.16.840.1.101.3.4.1.26":return{name:"AES-GCM",length:192};case"2.16.840.1.101.3.4.1.46":return{name:"AES-GCM",length:256};case"2.16.840.1.101.3.4.1.4":return{name:"AES-CFB",length:128};case"2.16.840.1.101.3.4.1.24":return{name:"AES-CFB",length:192};case"2.16.840.1.101.3.4.1.44":return{name:"AES-CFB",length:256};case"2.16.840.1.101.3.4.1.5":return{name:"AES-KW",length:128};case"2.16.840.1.101.3.4.1.25":return{name:"AES-KW",length:192};case"2.16.840.1.101.3.4.1.45":return{name:"AES-KW",length:256};case"1.2.840.113549.2.7":return{name:"HMAC",hash:{name:"SHA-1"}};case"1.2.840.113549.2.9":return{name:"HMAC",hash:{name:"SHA-256"}};case"1.2.840.113549.2.10":return{name:"HMAC",hash:{name:"SHA-384"}};case"1.2.840.113549.2.11":return{name:"HMAC",hash:{name:"SHA-512"}};case"1.2.840.113549.1.9.16.3.5":return{name:"DH"};case"1.3.14.3.2.26":return{name:"SHA-1"};case"2.16.840.1.101.3.4.2.1":return{name:"SHA-256"};case"2.16.840.1.101.3.4.2.2":return{name:"SHA-384"};case"2.16.840.1.101.3.4.2.3":return{name:"SHA-512"};case"1.2.840.113549.1.5.12":return{name:"PBKDF2"};case"1.2.840.10045.3.1.7":return{name:"P-256"};case"1.3.132.0.34":return{name:"P-384"};case"1.3.132.0.35":return{name:"P-521"}}return{}}},{key:"getOIDByAlgorithm",value:function(e){var t="";switch(e.name.toUpperCase()){case"RSASSA-PKCS1-V1_5":switch(e.hash.name.toUpperCase()){case"SHA-1":t="1.2.840.113549.1.1.5";break;case"SHA-256":t="1.2.840.113549.1.1.11";break;case"SHA-384":t="1.2.840.113549.1.1.12";break;case"SHA-512":t="1.2.840.113549.1.1.13"}break;case"RSA-PSS":t="1.2.840.113549.1.1.10";break;case"RSA-OAEP":t="1.2.840.113549.1.1.7";break;case"ECDSA":switch(e.hash.name.toUpperCase()){case"SHA-1":t="1.2.840.10045.4.1";break;case"SHA-256":t="1.2.840.10045.4.3.2";break;case"SHA-384":t="1.2.840.10045.4.3.3";break;case"SHA-512":t="1.2.840.10045.4.3.4"}break;case"ECDH":switch(e.kdf.toUpperCase()){case"SHA-1":t="1.3.133.16.840.63.0.2";break;case"SHA-256":t="1.3.132.1.11.1";break;case"SHA-384":t="1.3.132.1.11.2";break;case"SHA-512":t="1.3.132.1.11.3"}break;case"AES-CTR":break;case"AES-CBC":switch(e.length){case 128:t="2.16.840.1.101.3.4.1.2";break;case 192:t="2.16.840.1.101.3.4.1.22";break;case 256:t="2.16.840.1.101.3.4.1.42"}break;case"AES-CMAC":break;case"AES-GCM":switch(e.length){case 128:t="2.16.840.1.101.3.4.1.6";break;case 192:t="2.16.840.1.101.3.4.1.26";break;case 256:t="2.16.840.1.101.3.4.1.46"}break;case"AES-CFB":switch(e.length){case 128:t="2.16.840.1.101.3.4.1.4";break;case 192:t="2.16.840.1.101.3.4.1.24";break;case 256:t="2.16.840.1.101.3.4.1.44"}break;case"AES-KW":switch(e.length){case 128:t="2.16.840.1.101.3.4.1.5";break;case 192:t="2.16.840.1.101.3.4.1.25";break;case 256:t="2.16.840.1.101.3.4.1.45"}break;case"HMAC":switch(e.hash.name.toUpperCase()){case"SHA-1":t="1.2.840.113549.2.7";break;case"SHA-256":t="1.2.840.113549.2.9";break;case"SHA-384":t="1.2.840.113549.2.10";break;case"SHA-512":t="1.2.840.113549.2.11"}break;case"DH":t="1.2.840.113549.1.9.16.3.5";break;case"SHA-1":t="1.3.14.3.2.26";break;case"SHA-256":t="2.16.840.1.101.3.4.2.1";break;case"SHA-384":t="2.16.840.1.101.3.4.2.2";break;case"SHA-512":t="2.16.840.1.101.3.4.2.3";break;case"CONCAT":case"HKDF":break;case"PBKDF2":t="1.2.840.113549.1.5.12";break;case"P-256":t="1.2.840.10045.3.1.7";break;case"P-384":t="1.3.132.0.34";break;case"P-521":t="1.3.132.0.35"}return t}},{key:"getAlgorithmParameters",value:function(e,t){var r={algorithm:{},usages:[]};switch(e.toUpperCase()){case"RSASSA-PKCS1-V1_5":switch(t.toLowerCase()){case"generatekey":r={algorithm:{name:"RSASSA-PKCS1-v1_5",modulusLength:2048,publicExponent:new Uint8Array([1,0,1]),hash:{name:"SHA-256"}},usages:["sign","verify"]};break;case"verify":case"sign":case"importkey":r={algorithm:{name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-256"}},usages:["verify"]};break;case"exportkey":default:return{algorithm:{name:"RSASSA-PKCS1-v1_5"},usages:[]}}break;case"RSA-PSS":switch(t.toLowerCase()){case"sign":case"verify":r={algorithm:{name:"RSA-PSS",hash:{name:"SHA-1"},saltLength:20},usages:["sign","verify"]};break;case"generatekey":r={algorithm:{name:"RSA-PSS",modulusLength:2048,publicExponent:new Uint8Array([1,0,1]),hash:{name:"SHA-1"}},usages:["sign","verify"]};break;case"importkey":r={algorithm:{name:"RSA-PSS",hash:{name:"SHA-1"}},usages:["verify"]};break;case"exportkey":default:return{algorithm:{name:"RSA-PSS"},usages:[]}}break;case"RSA-OAEP":switch(t.toLowerCase()){case"encrypt":case"decrypt":r={algorithm:{name:"RSA-OAEP"},usages:["encrypt","decrypt"]};break;case"generatekey":r={algorithm:{name:"RSA-OAEP",modulusLength:2048,publicExponent:new Uint8Array([1,0,1]),hash:{name:"SHA-256"}},usages:["encrypt","decrypt","wrapKey","unwrapKey"]};break;case"importkey":r={algorithm:{name:"RSA-OAEP",hash:{name:"SHA-256"}},usages:["encrypt"]};break;case"exportkey":default:return{algorithm:{name:"RSA-OAEP"},usages:[]}}break;case"ECDSA":switch(t.toLowerCase()){case"generatekey":r={algorithm:{name:"ECDSA",namedCurve:"P-256"},usages:["sign","verify"]};break;case"importkey":r={algorithm:{name:"ECDSA",namedCurve:"P-256"},usages:["verify"]};break;case"verify":case"sign":r={algorithm:{name:"ECDSA",hash:{name:"SHA-256"}},usages:["sign"]};break;default:return{algorithm:{name:"ECDSA"},usages:[]}}break;case"ECDH":switch(t.toLowerCase()){case"exportkey":case"importkey":case"generatekey":r={algorithm:{name:"ECDH",namedCurve:"P-256"},usages:["deriveKey","deriveBits"]};break;case"derivekey":case"derivebits":r={algorithm:{name:"ECDH",namedCurve:"P-256",public:[]},usages:["encrypt","decrypt"]};break;default:return{algorithm:{name:"ECDH"},usages:[]}}break;case"AES-CTR":switch(t.toLowerCase()){case"importkey":case"exportkey":case"generatekey":r={algorithm:{name:"AES-CTR",length:256},usages:["encrypt","decrypt","wrapKey","unwrapKey"]};break;case"decrypt":case"encrypt":r={algorithm:{name:"AES-CTR",counter:new Uint8Array(16),length:10},usages:["encrypt","decrypt","wrapKey","unwrapKey"]};break;default:return{algorithm:{name:"AES-CTR"},usages:[]}}break;case"AES-CBC":switch(t.toLowerCase()){case"importkey":case"exportkey":case"generatekey":r={algorithm:{name:"AES-CBC",length:256},usages:["encrypt","decrypt","wrapKey","unwrapKey"]};break;case"decrypt":case"encrypt":r={algorithm:{name:"AES-CBC",iv:this.getRandomValues(new Uint8Array(16))},usages:["encrypt","decrypt","wrapKey","unwrapKey"]};break;default:return{algorithm:{name:"AES-CBC"},usages:[]}}break;case"AES-GCM":switch(t.toLowerCase()){case"importkey":case"exportkey":case"generatekey":r={algorithm:{name:"AES-GCM",length:256},usages:["encrypt","decrypt","wrapKey","unwrapKey"]};break;case"decrypt":case"encrypt":r={algorithm:{name:"AES-GCM",iv:this.getRandomValues(new Uint8Array(16))},usages:["encrypt","decrypt","wrapKey","unwrapKey"]};break;default:return{algorithm:{name:"AES-GCM"},usages:[]}}break;case"AES-KW":switch(t.toLowerCase()){case"importkey":case"exportkey":case"generatekey":case"wrapkey":case"unwrapkey":r={algorithm:{name:"AES-KW",length:256},usages:["wrapKey","unwrapKey"]};break;default:return{algorithm:{name:"AES-KW"},usages:[]}}break;case"HMAC":switch(t.toLowerCase()){case"sign":case"verify":r={algorithm:{name:"HMAC"},usages:["sign","verify"]};break;case"importkey":case"exportkey":case"generatekey":r={algorithm:{name:"HMAC",length:32,hash:{name:"SHA-256"}},usages:["sign","verify"]};break;default:return{algorithm:{name:"HMAC"},usages:[]}}break;case"HKDF":switch(t.toLowerCase()){case"derivekey":r={algorithm:{name:"HKDF",hash:"SHA-256",salt:new Uint8Array([]),info:new Uint8Array([])},usages:["encrypt","decrypt"]};break;default:return{algorithm:{name:"HKDF"},usages:[]}}break;case"PBKDF2":switch(t.toLowerCase()){case"derivekey":r={algorithm:{name:"PBKDF2",hash:{name:"SHA-256"},salt:new Uint8Array([]),iterations:1e4},usages:["encrypt","decrypt"]};break;default:return{algorithm:{name:"PBKDF2"},usages:[]}}}return r}},{key:"getHashAlgorithm",value:function(e){var t="";switch(e.algorithmId){case"1.2.840.10045.4.1":case"1.2.840.113549.1.1.5":t="SHA-1";break;case"1.2.840.10045.4.3.2":case"1.2.840.113549.1.1.11":t="SHA-256";break;case"1.2.840.10045.4.3.3":case"1.2.840.113549.1.1.12":t="SHA-384";break;case"1.2.840.10045.4.3.4":case"1.2.840.113549.1.1.13":t="SHA-512";break;case"1.2.840.113549.1.1.10":try{var r=new Le({schema:e.algorithmParams});if("hashAlgorithm"in r){var n=this.getAlgorithmByOID(r.hashAlgorithm.algorithmId);if("name"in n==!1)return"";t=n.name}else t="SHA-1"}catch(e){}}return t}},{key:"encryptEncryptedContentInfo",value:function(e){var t=this;if(e instanceof Object==!1)return Promise.reject('Parameters must have type "Object"');if("password"in e==!1)return Promise.reject('Absent mandatory parameter "password"');if("contentEncryptionAlgorithm"in e==!1)return Promise.reject('Absent mandatory parameter "contentEncryptionAlgorithm"');if("hmacHashAlgorithm"in e==!1)return Promise.reject('Absent mandatory parameter "hmacHashAlgorithm"');if("iterationCount"in e==!1)return Promise.reject('Absent mandatory parameter "iterationCount"');if("contentToEncrypt"in e==!1)return Promise.reject('Absent mandatory parameter "contentToEncrypt"');if("contentType"in e==!1)return Promise.reject('Absent mandatory parameter "contentType"');var r=this.getOIDByAlgorithm(e.contentEncryptionAlgorithm);if(""===r)return Promise.reject('Wrong "contentEncryptionAlgorithm" value');var n=this.getOIDByAlgorithm({name:"PBKDF2"});if(""===n)return Promise.reject("Can not find OID for PBKDF2");var a=this.getOIDByAlgorithm({name:"HMAC",hash:{name:e.hmacHashAlgorithm}});if(""===a)return Promise.reject('Incorrect value for "hmacHashAlgorithm": '.concat(e.hmacHashAlgorithm));var i=Promise.resolve(),s=new ArrayBuffer(16),o=new Uint8Array(s);this.getRandomValues(o);var u=new ArrayBuffer(64),l=new Uint8Array(u);this.getRandomValues(l);var c=new Uint8Array(e.contentToEncrypt),h=new Oe({salt:new ue.OctetString({valueHex:u}),iterationCount:e.iterationCount,prf:new Se({algorithmId:a,algorithmParams:new ue.Null})});return i=(i=(i=(i=i.then((function(){var r=new Uint8Array(e.password);return t.importKey("raw",r,"PBKDF2",!1,["deriveKey"])}),(function(e){return Promise.reject(e)}))).then((function(r){return t.deriveKey({name:"PBKDF2",hash:{name:e.hmacHashAlgorithm},salt:l,iterations:e.iterationCount},r,e.contentEncryptionAlgorithm,!1,["encrypt"])}),(function(e){return Promise.reject(e)}))).then((function(r){return t.encrypt({name:e.contentEncryptionAlgorithm.name,iv:o},r,c)}),(function(e){return Promise.reject(e)}))).then((function(t){var a=new Ue({keyDerivationFunc:new Se({algorithmId:n,algorithmParams:h.toSchema()}),encryptionScheme:new Se({algorithmId:r,algorithmParams:new ue.OctetString({valueHex:s})})});return new Re({contentType:e.contentType,contentEncryptionAlgorithm:new Se({algorithmId:"1.2.840.113549.1.5.13",algorithmParams:a.toSchema()}),encryptedContent:new ue.OctetString({valueHex:t})})}),(function(e){return Promise.reject(e)}))}},{key:"decryptEncryptedContentInfo",value:function(e){var t=this;if(e instanceof Object==!1)return Promise.reject('Parameters must have type "Object"');if("password"in e==!1)return Promise.reject('Absent mandatory parameter "password"');if("encryptedContentInfo"in e==!1)return Promise.reject('Absent mandatory parameter "encryptedContentInfo"');if("1.2.840.113549.1.5.13"!==e.encryptedContentInfo.contentEncryptionAlgorithm.algorithmId)return Promise.reject('Unknown "contentEncryptionAlgorithm": '.concat(e.encryptedContentInfo.contentEncryptionAlgorithm.algorithmId));var r,n,a=Promise.resolve();try{r=new Ue({schema:e.encryptedContentInfo.contentEncryptionAlgorithm.algorithmParams})}catch(e){return Promise.reject('Incorrectly encoded "pbes2Parameters"')}try{n=new Oe({schema:r.keyDerivationFunc.algorithmParams})}catch(e){return Promise.reject('Incorrectly encoded "pbkdf2Params"')}var i=this.getAlgorithmByOID(r.encryptionScheme.algorithmId);if("name"in i==!1)return Promise.reject('Incorrect OID for "contentEncryptionAlgorithm": '.concat(r.encryptionScheme.algorithmId));var s=r.encryptionScheme.algorithmParams.valueBlock.valueHex,o=new Uint8Array(s),u=n.salt.valueBlock.valueHex,l=new Uint8Array(u),c=n.iterationCount,h="SHA-1";if("prf"in n){var m=this.getAlgorithmByOID(n.prf.algorithmId);if("name"in m==!1)return Promise.reject("Incorrect OID for HMAC hash algorithm");h=m.hash.name}return a=(a=(a=a.then((function(){return t.importKey("raw",e.password,"PBKDF2",!1,["deriveKey"])}),(function(e){return Promise.reject(e)}))).then((function(e){return t.deriveKey({name:"PBKDF2",hash:{name:h},salt:l,iterations:c},e,i,!1,["decrypt"])}),(function(e){return Promise.reject(e)}))).then((function(r){var n=new ArrayBuffer(0);if(!1===e.encryptedContentInfo.encryptedContent.idBlock.isConstructed)n=e.encryptedContentInfo.encryptedContent.valueBlock.valueHex;else{var a,s=y(e.encryptedContentInfo.encryptedContent.valueBlock.value);try{for(s.s();!(a=s.n()).done;){n=me(n,a.value.valueBlock.valueHex)}}catch(e){s.e(e)}finally{s.f()}}return t.decrypt({name:i.name,iv:o},r,n)}),(function(e){return Promise.reject(e)}))}},{key:"stampDataWithPassword",value:function(e){var t,r=this;if(e instanceof Object==!1)return Promise.reject('Parameters must have type "Object"');if("password"in e==!1)return Promise.reject('Absent mandatory parameter "password"');if("hashAlgorithm"in e==!1)return Promise.reject('Absent mandatory parameter "hashAlgorithm"');if("salt"in e==!1)return Promise.reject('Absent mandatory parameter "iterationCount"');if("iterationCount"in e==!1)return Promise.reject('Absent mandatory parameter "salt"');if("contentToStamp"in e==!1)return Promise.reject('Absent mandatory parameter "contentToStamp"');switch(e.hashAlgorithm.toLowerCase()){case"sha-1":t=160;break;case"sha-256":t=256;break;case"sha-384":t=384;break;case"sha-512":t=512;break;default:return Promise.reject('Incorrect "parameters.hashAlgorithm" parameter: '.concat(e.hashAlgorithm))}var n=Promise.resolve(),a={name:"HMAC",length:t,hash:{name:e.hashAlgorithm}};return n=(n=(n=n.then((function(){return De(r,e.hashAlgorithm,t,e.password,e.salt,e.iterationCount)}))).then((function(e){return r.importKey("raw",new Uint8Array(e),a,!1,["sign"])}))).then((function(t){return r.sign(a,t,new Uint8Array(e.contentToStamp))}),(function(e){return Promise.reject(e)}))}},{key:"verifyDataStampedWithPassword",value:function(e){var t,r=this;if(e instanceof Object==!1)return Promise.reject('Parameters must have type "Object"');if("password"in e==!1)return Promise.reject('Absent mandatory parameter "password"');if("hashAlgorithm"in e==!1)return Promise.reject('Absent mandatory parameter "hashAlgorithm"');if("salt"in e==!1)return Promise.reject('Absent mandatory parameter "iterationCount"');if("iterationCount"in e==!1)return Promise.reject('Absent mandatory parameter "salt"');if("contentToVerify"in e==!1)return Promise.reject('Absent mandatory parameter "contentToVerify"');if("signatureToVerify"in e==!1)return Promise.reject('Absent mandatory parameter "signatureToVerify"');switch(e.hashAlgorithm.toLowerCase()){case"sha-1":t=160;break;case"sha-256":t=256;break;case"sha-384":t=384;break;case"sha-512":t=512;break;default:return Promise.reject('Incorrect "parameters.hashAlgorithm" parameter: '.concat(e.hashAlgorithm))}var n=Promise.resolve(),a={name:"HMAC",length:t,hash:{name:e.hashAlgorithm}};return n=(n=(n=n.then((function(){return De(r,e.hashAlgorithm,t,e.password,e.salt,e.iterationCount)}))).then((function(e){return r.importKey("raw",new Uint8Array(e),a,!1,["verify"])}))).then((function(t){return r.verify(a,t,new Uint8Array(e.signatureToVerify),new Uint8Array(e.contentToVerify))}),(function(e){return Promise.reject(e)}))}},{key:"getSignatureParameters",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"SHA-1",r=this.getOIDByAlgorithm({name:t});if(""===r)return Promise.reject("Unsupported hash algorithm: ".concat(t));var n=new Se,a=this.getAlgorithmParameters(e.algorithm.name,"sign");switch(a.algorithm.hash.name=t,e.algorithm.name.toUpperCase()){case"RSASSA-PKCS1-V1_5":case"ECDSA":n.algorithmId=this.getOIDByAlgorithm(a.algorithm);break;case"RSA-PSS":switch(t.toUpperCase()){case"SHA-256":a.algorithm.saltLength=32;break;case"SHA-384":a.algorithm.saltLength=48;break;case"SHA-512":a.algorithm.saltLength=64}var i={};if("SHA-1"!==t.toUpperCase()){var s=this.getOIDByAlgorithm({name:t});if(""===s)return Promise.reject("Unsupported hash algorithm: ".concat(t));i.hashAlgorithm=new Se({algorithmId:s,algorithmParams:new ue.Null}),i.maskGenAlgorithm=new Se({algorithmId:"1.2.840.113549.1.1.8",algorithmParams:i.hashAlgorithm.toSchema()})}20!==a.algorithm.saltLength&&(i.saltLength=a.algorithm.saltLength);var o=new Le(i);n.algorithmId="1.2.840.113549.1.1.10",n.algorithmParams=o.toSchema();break;default:return Promise.reject("Unsupported signature algorithm: ".concat(e.algorithm.name))}return Promise.resolve().then((function(){return{signatureAlgorithm:n,parameters:a}}))}},{key:"signWithPrivateKey",value:function(e,t,r){return this.sign(r.algorithm,t,new Uint8Array(e)).then((function(e){return"ECDSA"===r.algorithm.name&&(e=function(e){if(e.byteLength%2!=0)return new ArrayBuffer(0);var t=e.byteLength/2,r=new ArrayBuffer(t);new Uint8Array(r).set(new Uint8Array(e,0,t));var n=new ue.Integer({valueHex:r}),a=new ArrayBuffer(t);new Uint8Array(a).set(new Uint8Array(e,t,t));var i=new ue.Integer({valueHex:a});return new ue.Sequence({value:[n.convertToDER(),i.convertToDER()]}).toBER(!1)}(e)),e}),(function(e){return Promise.reject("Signing error: ".concat(e))}))}},{key:"fillPublicKeyParameters",value:function(e,t){var r,n={},a=this.getHashAlgorithm(t);if(""===a)return Promise.reject("Unsupported signature algorithm: ".concat(t.algorithmId));r="1.2.840.113549.1.1.10"===t.algorithmId?t.algorithmId:e.algorithm.algorithmId;var i=this.getAlgorithmByOID(r);if("name"in i==="")return Promise.reject("Unsupported public key algorithm: ".concat(t.algorithmId));if(n.algorithm=this.getAlgorithmParameters(i.name,"importkey"),"hash"in n.algorithm.algorithm&&(n.algorithm.algorithm.hash.name=a),"ECDSA"===i.name){var s=!1;if("algorithmParams"in e.algorithm==!0&&"idBlock"in e.algorithm.algorithmParams&&1===e.algorithm.algorithmParams.idBlock.tagClass&&6===e.algorithm.algorithmParams.idBlock.tagNumber&&(s=!0),!1===s)return Promise.reject("Incorrect type for ECDSA public key parameters");var o=this.getAlgorithmByOID(e.algorithm.algorithmParams.valueBlock.toString());if("name"in o==!1)return Promise.reject("Unsupported named curve algorithm: ".concat(e.algorithm.algorithmParams.valueBlock.toString()));n.algorithm.algorithm.namedCurve=o.name}return n}},{key:"getPublicKey",value:function(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null;null===r&&(r=this.fillPublicKeyParameters(e,t));var n=e.toSchema(),a=n.toBER(!1),i=new Uint8Array(a);return this.importKey("spki",i,r.algorithm.algorithm,!0,r.algorithm.usages)}},{key:"verifyWithPublicKey",value:function(e,t,r,n){var a=this,i=arguments.length>4&&void 0!==arguments[4]?arguments[4]:null,s=Promise.resolve();if(null===i){if(""===(i=this.getHashAlgorithm(n)))return Promise.reject("Unsupported signature algorithm: ".concat(n.algorithmId));s=s.then((function(){return a.getPublicKey(r,n)}))}else{var o,u={};o="1.2.840.113549.1.1.10"===n.algorithmId?n.algorithmId:r.algorithm.algorithmId;var l=this.getAlgorithmByOID(o);if("name"in l==="")return Promise.reject("Unsupported public key algorithm: ".concat(n.algorithmId));if(u.algorithm=this.getAlgorithmParameters(l.name,"importkey"),"hash"in u.algorithm.algorithm&&(u.algorithm.algorithm.hash.name=i),"ECDSA"===l.name){var c=!1;if("algorithmParams"in r.algorithm==!0&&"idBlock"in r.algorithm.algorithmParams&&1===r.algorithm.algorithmParams.idBlock.tagClass&&6===r.algorithm.algorithmParams.idBlock.tagNumber&&(c=!0),!1===c)return Promise.reject("Incorrect type for ECDSA public key parameters");var h=this.getAlgorithmByOID(r.algorithm.algorithmParams.valueBlock.toString());if("name"in h==!1)return Promise.reject("Unsupported named curve algorithm: ".concat(r.algorithm.algorithmParams.valueBlock.toString()));u.algorithm.algorithm.namedCurve=h.name}s=s.then((function(){return a.getPublicKey(r,null,u)}))}return s=s.then((function(r){var s=a.getAlgorithmParameters(r.algorithm.name,"verify");"hash"in s.algorithm&&(s.algorithm.hash.name=i);var o=t.valueBlock.valueHex;"ECDSA"===r.algorithm.name&&(o=Me(ue.fromBER(o).result));if("RSA-PSS"===r.algorithm.name){var u;try{u=new Le({schema:n.algorithmParams})}catch(e){return Promise.reject(e)}s.algorithm.saltLength="saltLength"in u?u.saltLength:20;var l="SHA-1";if("hashAlgorithm"in u){var c=a.getAlgorithmByOID(u.hashAlgorithm.algorithmId);if("name"in c==!1)return Promise.reject("Unrecognized hash algorithm: ".concat(u.hashAlgorithm.algorithmId));l=c.name}s.algorithm.hash.name=l}return a.verify(s.algorithm,r,new Uint8Array(o),new Uint8Array(e))}))}}]),e}(),Ve={name:"none",crypto:null,subtle:null};function Te(e,r,n){if("undefined"!=typeof process&&"pid"in process&&"undefined"!=typeof global&&"undefined"==typeof window){if(void 0===global[process.pid])global[process.pid]={};else if("object"!==t(global[process.pid]))throw new Error("Name global.".concat(process.pid," already exists and it is not an object"));if(void 0===global[process.pid].pkijs)global[process.pid].pkijs={};else if("object"!==t(global[process.pid].pkijs))throw new Error("Name global.".concat(process.pid,".pkijs already exists and it is not an object"));global[process.pid].pkijs.engine={name:e,crypto:r,subtle:n}}else Ve={name:e,crypto:r,subtle:n}}function _e(){if("undefined"!=typeof process&&"pid"in process&&"undefined"!=typeof global&&"undefined"==typeof window){var e;try{e=global[process.pid].pkijs.engine}catch(e){throw new Error('Please call "setEngine" before call to "getEngine"')}return e}return Ve}function je(){var e=_e();if(null!==e.subtle)return e.subtle}function Ke(e){for(var t=!1,r="",n=e.trim(),a=0;a<n.length;a++)32===n.charCodeAt(a)?!1===t&&(t=!0):(t&&(r+=" ",t=!1),r+=n[a]);return r.toLowerCase()}function Me(e){if(e instanceof ue.Sequence==!1)return new ArrayBuffer(0);if(2!==e.valueBlock.value.length)return new ArrayBuffer(0);if(e.valueBlock.value[0]instanceof ue.Integer==!1)return new ArrayBuffer(0);if(e.valueBlock.value[1]instanceof ue.Integer==!1)return new ArrayBuffer(0);var t=e.valueBlock.value[0].convertFromDER(),r=e.valueBlock.value[1].convertFromDER();switch(!0){case t.valueBlock.valueHex.byteLength<r.valueBlock.valueHex.byteLength:if(r.valueBlock.valueHex.byteLength-t.valueBlock.valueHex.byteLength!=1)throw new Error("Incorrect DER integer decoding");var n=r.valueBlock.valueHex.byteLength,a=new Uint8Array(t.valueBlock.valueHex),i=new ArrayBuffer(n),s=new Uint8Array(i);return s.set(a,1),s[0]=0,me(i,r.valueBlock.valueHex);case t.valueBlock.valueHex.byteLength>r.valueBlock.valueHex.byteLength:if(t.valueBlock.valueHex.byteLength-r.valueBlock.valueHex.byteLength!=1)throw new Error("Incorrect DER integer decoding");var o=t.valueBlock.valueHex.byteLength,u=new Uint8Array(r.valueBlock.valueHex),l=new ArrayBuffer(o),c=new Uint8Array(l);return c.set(u,1),c[0]=0,me(t.valueBlock.valueHex,l);default:if(t.valueBlock.valueHex.byteLength%2){var h=t.valueBlock.valueHex.byteLength+1,m=new Uint8Array(t.valueBlock.valueHex),f=new ArrayBuffer(h),v=new Uint8Array(f);v.set(m,1),v[0]=0;var g=new Uint8Array(r.valueBlock.valueHex),d=new ArrayBuffer(h),y=new Uint8Array(d);return y.set(g,1),y[0]=0,me(f,d)}}return me(t.valueBlock.valueHex,r.valueBlock.valueHex)}!function(){if("undefined"!=typeof self&&"crypto"in self){var e,t="webcrypto",r=self.crypto;if("webkitSubtle"in self.crypto){try{e=self.crypto.webkitSubtle}catch(t){e=self.crypto.subtle}t="safari"}"subtle"in self.crypto&&(e=self.crypto.subtle),Ve=void 0===e?{name:t,crypto:r,subtle:null}:{name:t,crypto:r,subtle:new He({name:t,crypto:self.crypto,subtle:e})}}Te(Ve.name,Ve.crypto,Ve.subtle)}();var Xe=function(){function e(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};a(this,e),this.type=le(t,"type",e.defaultValues("type")),this.value=le(t,"value",e.defaultValues("value")),"schema"in t&&this.fromSchema(t.schema)}return s(e,[{key:"fromSchema",value:function(t){we(t,["type","typeValue"]);var r=ue.compareSchema(t,t,e.schema({names:{type:"type",value:"typeValue"}}));if(!1===r.verified)throw new Error("Object's schema was not verified against input data for AttributeTypeAndValue");this.type=r.result.type.valueBlock.toString(),this.value=r.result.typeValue}},{key:"toSchema",value:function(){return new ue.Sequence({value:[new ue.ObjectIdentifier({value:this.type}),this.value]})}},{key:"toJSON",value:function(){var e={type:this.type};return 0!==Object.keys(this.value).length?e.value=this.value.toJSON():e.value=this.value,e}},{key:"isEqual",value:function(t){var r=[ue.Utf8String.blockName(),ue.BmpString.blockName(),ue.UniversalString.blockName(),ue.NumericString.blockName(),ue.PrintableString.blockName(),ue.TeletexString.blockName(),ue.VideotexString.blockName(),ue.IA5String.blockName(),ue.GraphicString.blockName(),ue.VisibleString.blockName(),ue.GeneralString.blockName(),ue.CharacterString.blockName()];if(t.constructor.blockName()===e.blockName()){if(this.type!==t.type)return!1;var n=!1,a=this.value.constructor.blockName();if(a===t.value.constructor.blockName()){var i,s=y(r);try{for(s.s();!(i=s.n()).done;){if(a===i.value){n=!0;break}}}catch(e){s.e(e)}finally{s.f()}}if(n){var o=Ke(this.value.valueBlock.value),u=Ke(t.value.valueBlock.value);if(0!==o.localeCompare(u))return!1}else if(!1===fe(this.value.valueBeforeDecode,t.value.valueBeforeDecode))return!1;return!0}return t instanceof ArrayBuffer&&fe(this.value.valueBeforeDecode,t)}}],[{key:"defaultValues",value:function(e){switch(e){case"type":return"";case"value":return{};default:throw new Error("Invalid member name for AttributeTypeAndValue class: ".concat(e))}}},{key:"schema",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=le(e,"names",{});return new ue.Sequence({name:t.blockName||"",value:[new ue.ObjectIdentifier({name:t.type||""}),new ue.Any({name:t.value||""})]})}},{key:"blockName",value:function(){return"AttributeTypeAndValue"}}]),e}(),Ge=function(){function e(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};a(this,e),this.typesAndValues=le(t,"typesAndValues",e.defaultValues("typesAndValues")),this.valueBeforeDecode=le(t,"valueBeforeDecode",e.defaultValues("valueBeforeDecode")),"schema"in t&&this.fromSchema(t.schema)}return s(e,[{key:"fromSchema",value:function(t){we(t,["RDN","typesAndValues"]);var r=ue.compareSchema(t,t,e.schema({names:{blockName:"RDN",repeatedSet:"typesAndValues"}}));if(!1===r.verified)throw new Error("Object's schema was not verified against input data for RelativeDistinguishedNames");"typesAndValues"in r.result&&(this.typesAndValues=Array.from(r.result.typesAndValues,(function(e){return new Xe({schema:e})}))),this.valueBeforeDecode=r.result.RDN.valueBeforeDecode}},{key:"toSchema",value:function(){return 0===this.valueBeforeDecode.byteLength?new ue.Sequence({value:[new ue.Set({value:Array.from(this.typesAndValues,(function(e){return e.toSchema()}))})]}):ue.fromBER(this.valueBeforeDecode).result}},{key:"toJSON",value:function(){return{typesAndValues:Array.from(this.typesAndValues,(function(e){return e.toJSON()}))}}},{key:"isEqual",value:function(t){if(t instanceof e){if(this.typesAndValues.length!==t.typesAndValues.length)return!1;var r,n=y(this.typesAndValues.entries());try{for(n.s();!(r=n.n()).done;){var a=f(r.value,2),i=a[0];if(!1===a[1].isEqual(t.typesAndValues[i]))return!1}}catch(e){n.e(e)}finally{n.f()}return!0}return t instanceof ArrayBuffer&&fe(this.valueBeforeDecode,t)}}],[{key:"defaultValues",value:function(e){switch(e){case"typesAndValues":return[];case"valueBeforeDecode":return new ArrayBuffer(0);default:throw new Error("Invalid member name for RelativeDistinguishedNames class: ".concat(e))}}},{key:"compareWithDefault",value:function(e,t){switch(e){case"typesAndValues":return 0===t.length;case"valueBeforeDecode":return 0===t.byteLength;default:throw new Error("Invalid member name for RelativeDistinguishedNames class: ".concat(e))}}},{key:"schema",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=le(e,"names",{});return new ue.Sequence({name:t.blockName||"",value:[new ue.Repeated({name:t.repeatedSequence||"",value:new ue.Set({value:[new ue.Repeated({name:t.repeatedSet||"",value:Xe.schema(t.typeAndValue||{})})]})})]})}}]),e}();function qe(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=arguments.length>1&&void 0!==arguments[1]&&arguments[1],r=le(e,"names",{});return new ue.Sequence({optional:t,value:[new ue.Constructed({optional:!0,idBlock:{tagClass:2,tagNumber:1},name:r.country_name||"",value:[new ue.Choice({value:[new ue.NumericString,new ue.PrintableString]})]}),new ue.Constructed({optional:!0,idBlock:{tagClass:2,tagNumber:2},name:r.administration_domain_name||"",value:[new ue.Choice({value:[new ue.NumericString,new ue.PrintableString]})]}),new ue.Primitive({optional:!0,idBlock:{tagClass:3,tagNumber:0},name:r.network_address||"",isHexOnly:!0}),new ue.Primitive({optional:!0,idBlock:{tagClass:3,tagNumber:1},name:r.terminal_identifier||"",isHexOnly:!0}),new ue.Constructed({optional:!0,idBlock:{tagClass:3,tagNumber:2},name:r.private_domain_name||"",value:[new ue.Choice({value:[new ue.NumericString,new ue.PrintableString]})]}),new ue.Primitive({optional:!0,idBlock:{tagClass:3,tagNumber:3},name:r.organization_name||"",isHexOnly:!0}),new ue.Primitive({optional:!0,name:r.numeric_user_identifier||"",idBlock:{tagClass:3,tagNumber:4},isHexOnly:!0}),new ue.Constructed({optional:!0,name:r.personal_name||"",idBlock:{tagClass:3,tagNumber:5},value:[new ue.Primitive({idBlock:{tagClass:3,tagNumber:0},isHexOnly:!0}),new ue.Primitive({optional:!0,idBlock:{tagClass:3,tagNumber:1},isHexOnly:!0}),new ue.Primitive({optional:!0,idBlock:{tagClass:3,tagNumber:2},isHexOnly:!0}),new ue.Primitive({optional:!0,idBlock:{tagClass:3,tagNumber:3},isHexOnly:!0})]}),new ue.Constructed({optional:!0,name:r.organizational_unit_names||"",idBlock:{tagClass:3,tagNumber:6},value:[new ue.Repeated({value:new ue.PrintableString})]})]})}function Fe(){var e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];return new ue.Sequence({optional:e,value:[new ue.PrintableString,new ue.PrintableString]})}function Je(){var e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];return new ue.Set({optional:e,value:[new ue.Primitive({optional:!0,idBlock:{tagClass:3,tagNumber:0},isHexOnly:!0}),new ue.Constructed({optional:!0,idBlock:{tagClass:3,tagNumber:1},value:[new ue.Any]})]})}var We=function(){function e(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};a(this,e),this.type=le(t,"type",e.defaultValues("type")),this.value=le(t,"value",e.defaultValues("value")),"schema"in t&&this.fromSchema(t.schema)}return s(e,[{key:"fromSchema",value:function(t){we(t,["blockName","otherName","rfc822Name","dNSName","x400Address","directoryName","ediPartyName","uniformResourceIdentifier","iPAddress","registeredID"]);var r=ue.compareSchema(t,t,e.schema({names:{blockName:"blockName",otherName:"otherName",rfc822Name:"rfc822Name",dNSName:"dNSName",x400Address:"x400Address",directoryName:{names:{blockName:"directoryName"}},ediPartyName:"ediPartyName",uniformResourceIdentifier:"uniformResourceIdentifier",iPAddress:"iPAddress",registeredID:"registeredID"}}));if(!1===r.verified)throw new Error("Object's schema was not verified against input data for GeneralName");switch(this.type=r.result.blockName.idBlock.tagNumber,this.type){case 0:this.value=r.result.blockName;break;case 1:case 2:case 6:var n=r.result.blockName;n.idBlock.tagClass=1,n.idBlock.tagNumber=22;var a=n.toBER(!1);this.value=ue.fromBER(a).result.valueBlock.value;break;case 3:this.value=r.result.blockName;break;case 4:this.value=new Ge({schema:r.result.directoryName});break;case 5:this.value=r.result.ediPartyName;break;case 7:this.value=new ue.OctetString({valueHex:r.result.blockName.valueBlock.valueHex});break;case 8:var i=r.result.blockName;i.idBlock.tagClass=1,i.idBlock.tagNumber=6;var s=i.toBER(!1);this.value=ue.fromBER(s).result.valueBlock.toString()}}},{key:"toSchema",value:function(){switch(this.type){case 0:case 3:case 5:return new ue.Constructed({idBlock:{tagClass:3,tagNumber:this.type},value:[this.value]});case 1:case 2:case 6:var t=new ue.IA5String({value:this.value});return t.idBlock.tagClass=3,t.idBlock.tagNumber=this.type,t;case 4:return new ue.Constructed({idBlock:{tagClass:3,tagNumber:4},value:[this.value.toSchema()]});case 7:var r=this.value;return r.idBlock.tagClass=3,r.idBlock.tagNumber=this.type,r;case 8:var n=new ue.ObjectIdentifier({value:this.value});return n.idBlock.tagClass=3,n.idBlock.tagNumber=this.type,n;default:return e.schema()}}},{key:"toJSON",value:function(){var e={type:this.type,value:""};if("string"==typeof this.value)e.value=this.value;else try{e.value=this.value.toJSON()}catch(e){}return e}}],[{key:"defaultValues",value:function(e){switch(e){case"type":return 9;case"value":return{};default:throw new Error("Invalid member name for GeneralName class: ".concat(e))}}},{key:"compareWithDefault",value:function(t,r){switch(t){case"type":return r===e.defaultValues(t);case"value":return 0===Object.keys(r).length;default:throw new Error("Invalid member name for GeneralName class: ".concat(t))}}},{key:"schema",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=le(e,"names",{});return new ue.Choice({value:[new ue.Constructed({idBlock:{tagClass:3,tagNumber:0},name:t.blockName||"",value:[new ue.ObjectIdentifier,new ue.Constructed({idBlock:{tagClass:3,tagNumber:0},value:[new ue.Any]})]}),new ue.Primitive({name:t.blockName||"",idBlock:{tagClass:3,tagNumber:1}}),new ue.Primitive({name:t.blockName||"",idBlock:{tagClass:3,tagNumber:2}}),new ue.Constructed({idBlock:{tagClass:3,tagNumber:3},name:t.blockName||"",value:[qe(t.builtInStandardAttributes||{},!1),Fe(!0),Je(!0)]}),new ue.Constructed({idBlock:{tagClass:3,tagNumber:4},name:t.blockName||"",value:[Ge.schema(t.directoryName||{})]}),new ue.Constructed({idBlock:{tagClass:3,tagNumber:5},name:t.blockName||"",value:[new ue.Constructed({optional:!0,idBlock:{tagClass:3,tagNumber:0},value:[new ue.Choice({value:[new ue.TeletexString,new ue.PrintableString,new ue.UniversalString,new ue.Utf8String,new ue.BmpString]})]}),new ue.Constructed({idBlock:{tagClass:3,tagNumber:1},value:[new ue.Choice({value:[new ue.TeletexString,new ue.PrintableString,new ue.UniversalString,new ue.Utf8String,new ue.BmpString]})]})]}),new ue.Primitive({name:t.blockName||"",idBlock:{tagClass:3,tagNumber:6}}),new ue.Primitive({name:t.blockName||"",idBlock:{tagClass:3,tagNumber:7}}),new ue.Primitive({name:t.blockName||"",idBlock:{tagClass:3,tagNumber:8}})]})}}]),e}(),ze=function(){function e(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};a(this,e),this.accessMethod=le(t,"accessMethod",e.defaultValues("accessMethod")),this.accessLocation=le(t,"accessLocation",e.defaultValues("accessLocation")),"schema"in t&&this.fromSchema(t.schema)}return s(e,[{key:"fromSchema",value:function(t){we(t,["accessMethod","accessLocation"]);var r=ue.compareSchema(t,t,e.schema({names:{accessMethod:"accessMethod",accessLocation:{names:{blockName:"accessLocation"}}}}));if(!1===r.verified)throw new Error("Object's schema was not verified against input data for AccessDescription");this.accessMethod=r.result.accessMethod.valueBlock.toString(),this.accessLocation=new We({schema:r.result.accessLocation})}},{key:"toSchema",value:function(){return new ue.Sequence({value:[new ue.ObjectIdentifier({value:this.accessMethod}),this.accessLocation.toSchema()]})}},{key:"toJSON",value:function(){return{accessMethod:this.accessMethod,accessLocation:this.accessLocation.toJSON()}}}],[{key:"defaultValues",value:function(e){switch(e){case"accessMethod":return"";case"accessLocation":return new We;default:throw new Error("Invalid member name for AccessDescription class: ".concat(e))}}},{key:"schema",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=le(e,"names",{});return new ue.Sequence({name:t.blockName||"",value:[new ue.ObjectIdentifier({name:t.accessMethod||""}),We.schema(t.accessLocation||{})]})}}]),e}(),Qe=function(){function e(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};a(this,e),this.altNames=le(t,"altNames",e.defaultValues("altNames")),"schema"in t&&this.fromSchema(t.schema)}return s(e,[{key:"fromSchema",value:function(t){we(t,["altNames"]);var r=ue.compareSchema(t,t,e.schema({names:{altNames:"altNames"}}));if(!1===r.verified)throw new Error("Object's schema was not verified against input data for AltName");"altNames"in r.result&&(this.altNames=Array.from(r.result.altNames,(function(e){return new We({schema:e})})))}},{key:"toSchema",value:function(){return new ue.Sequence({value:Array.from(this.altNames,(function(e){return e.toSchema()}))})}},{key:"toJSON",value:function(){return{altNames:Array.from(this.altNames,(function(e){return e.toJSON()}))}}}],[{key:"defaultValues",value:function(e){switch(e){case"altNames":return[];default:throw new Error("Invalid member name for AltName class: ".concat(e))}}},{key:"schema",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=le(e,"names",{});return new ue.Sequence({name:t.blockName||"",value:[new ue.Repeated({name:t.altNames||"",value:We.schema()})]})}}]),e}(),Ye=function(){function e(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};a(this,e),this.type=le(t,"type",e.defaultValues("type")),this.value=le(t,"value",e.defaultValues("value")),"schema"in t&&this.fromSchema(t.schema)}return s(e,[{key:"fromSchema",value:function(t){we(t,["utcTimeName","generalTimeName"]);var r=ue.compareSchema(t,t,e.schema({names:{utcTimeName:"utcTimeName",generalTimeName:"generalTimeName"}}));if(!1===r.verified)throw new Error("Object's schema was not verified against input data for Time");"utcTimeName"in r.result&&(this.type=0,this.value=r.result.utcTimeName.toDate()),"generalTimeName"in r.result&&(this.type=1,this.value=r.result.generalTimeName.toDate())}},{key:"toSchema",value:function(){var e={};return 0===this.type&&(e=new ue.UTCTime({valueDate:this.value})),1===this.type&&(e=new ue.GeneralizedTime({valueDate:this.value})),e}},{key:"toJSON",value:function(){return{type:this.type,value:this.value}}}],[{key:"defaultValues",value:function(e){switch(e){case"type":return 0;case"value":return new Date(0,0,0);default:throw new Error("Invalid member name for Time class: ".concat(e))}}},{key:"schema",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=arguments.length>1&&void 0!==arguments[1]&&arguments[1],r=le(e,"names",{});return new ue.Choice({optional:t,value:[new ue.UTCTime({name:r.utcTimeName||""}),new ue.GeneralizedTime({name:r.generalTimeName||""})]})}}]),e}(),Ze=function(){function e(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};a(this,e),this.attributes=le(t,"attributes",e.defaultValues("attributes")),"schema"in t&&this.fromSchema(t.schema)}return s(e,[{key:"fromSchema",value:function(t){we(t,["attributes"]);var r=ue.compareSchema(t,t,e.schema({names:{attributes:"attributes"}}));if(!1===r.verified)throw new Error("Object's schema was not verified against input data for SubjectDirectoryAttributes");this.attributes=Array.from(r.result.attributes,(function(e){return new Be({schema:e})}))}},{key:"toSchema",value:function(){return new ue.Sequence({value:Array.from(this.attributes,(function(e){return e.toSchema()}))})}},{key:"toJSON",value:function(){return{attributes:Array.from(this.attributes,(function(e){return e.toJSON()}))}}}],[{key:"defaultValues",value:function(e){switch(e){case"attributes":return[];default:throw new Error("Invalid member name for SubjectDirectoryAttributes class: ".concat(e))}}},{key:"schema",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=le(e,"names",{});return new ue.Sequence({name:t.blockName||"",value:[new ue.Repeated({name:t.attributes||"",value:Be.schema()})]})}}]),e}(),$e=function(){function e(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};a(this,e),"notBefore"in t&&(this.notBefore=le(t,"notBefore",e.defaultValues("notBefore"))),"notAfter"in t&&(this.notAfter=le(t,"notAfter",e.defaultValues("notAfter"))),"schema"in t&&this.fromSchema(t.schema)}return s(e,[{key:"fromSchema",value:function(t){we(t,["notBefore","notAfter"]);var r=ue.compareSchema(t,t,e.schema({names:{notBefore:"notBefore",notAfter:"notAfter"}}));if(!1===r.verified)throw new Error("Object's schema was not verified against input data for PrivateKeyUsagePeriod");if("notBefore"in r.result){var n=new ue.GeneralizedTime;n.fromBuffer(r.result.notBefore.valueBlock.valueHex),this.notBefore=n.toDate()}if("notAfter"in r.result){var a=new ue.GeneralizedTime({valueHex:r.result.notAfter.valueBlock.valueHex});a.fromBuffer(r.result.notAfter.valueBlock.valueHex),this.notAfter=a.toDate()}}},{key:"toSchema",value:function(){var e=[];return"notBefore"in this&&e.push(new ue.Primitive({idBlock:{tagClass:3,tagNumber:0},valueHex:new ue.GeneralizedTime({valueDate:this.notBefore}).valueBlock.valueHex})),"notAfter"in this&&e.push(new ue.Primitive({idBlock:{tagClass:3,tagNumber:1},valueHex:new ue.GeneralizedTime({valueDate:this.notAfter}).valueBlock.valueHex})),new ue.Sequence({value:e})}},{key:"toJSON",value:function(){var e={};return"notBefore"in this&&(e.notBefore=this.notBefore),"notAfter"in this&&(e.notAfter=this.notAfter),e}}],[{key:"defaultValues",value:function(e){switch(e){case"notBefore":case"notAfter":return new Date;default:throw new Error("Invalid member name for PrivateKeyUsagePeriod class: ".concat(e))}}},{key:"schema",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=le(e,"names",{});return new ue.Sequence({name:t.blockName||"",value:[new ue.Primitive({name:t.notBefore||"",optional:!0,idBlock:{tagClass:3,tagNumber:0}}),new ue.Primitive({name:t.notAfter||"",optional:!0,idBlock:{tagClass:3,tagNumber:1}})]})}}]),e}(),et=function(){function e(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};a(this,e),this.cA=le(t,"cA",!1),"pathLenConstraint"in t&&(this.pathLenConstraint=le(t,"pathLenConstraint",0)),"schema"in t&&this.fromSchema(t.schema)}return s(e,[{key:"fromSchema",value:function(t){we(t,["cA","pathLenConstraint"]);var r=ue.compareSchema(t,t,e.schema({names:{cA:"cA",pathLenConstraint:"pathLenConstraint"}}));if(!1===r.verified)throw new Error("Object's schema was not verified against input data for BasicConstraints");"cA"in r.result&&(this.cA=r.result.cA.valueBlock.value),"pathLenConstraint"in r.result&&(r.result.pathLenConstraint.valueBlock.isHexOnly?this.pathLenConstraint=r.result.pathLenConstraint:this.pathLenConstraint=r.result.pathLenConstraint.valueBlock.valueDec)}},{key:"toSchema",value:function(){var t=[];return this.cA!==e.defaultValues("cA")&&t.push(new ue.Boolean({value:this.cA})),"pathLenConstraint"in this&&(this.pathLenConstraint instanceof ue.Integer?t.push(this.pathLenConstraint):t.push(new ue.Integer({value:this.pathLenConstraint}))),new ue.Sequence({value:t})}},{key:"toJSON",value:function(){var t={};return this.cA!==e.defaultValues("cA")&&(t.cA=this.cA),"pathLenConstraint"in this&&(this.pathLenConstraint instanceof ue.Integer?t.pathLenConstraint=this.pathLenConstraint.toJSON():t.pathLenConstraint=this.pathLenConstraint),t}}],[{key:"defaultValues",value:function(e){switch(e){case"cA":return!1;default:throw new Error("Invalid member name for BasicConstraints class: ".concat(e))}}},{key:"schema",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=le(e,"names",{});return new ue.Sequence({name:t.blockName||"",value:[new ue.Boolean({optional:!0,name:t.cA||""}),new ue.Integer({optional:!0,name:t.pathLenConstraint||""})]})}}]),e}(),tt=function(){function e(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};a(this,e),"distributionPoint"in t&&(this.distributionPoint=le(t,"distributionPoint",e.defaultValues("distributionPoint"))),this.onlyContainsUserCerts=le(t,"onlyContainsUserCerts",e.defaultValues("onlyContainsUserCerts")),this.onlyContainsCACerts=le(t,"onlyContainsCACerts",e.defaultValues("onlyContainsCACerts")),"onlySomeReasons"in t&&(this.onlySomeReasons=le(t,"onlySomeReasons",e.defaultValues("onlySomeReasons"))),this.indirectCRL=le(t,"indirectCRL",e.defaultValues("indirectCRL")),this.onlyContainsAttributeCerts=le(t,"onlyContainsAttributeCerts",e.defaultValues("onlyContainsAttributeCerts")),"schema"in t&&this.fromSchema(t.schema)}return s(e,[{key:"fromSchema",value:function(t){we(t,["distributionPoint","distributionPointNames","onlyContainsUserCerts","onlyContainsCACerts","onlySomeReasons","indirectCRL","onlyContainsAttributeCerts"]);var r=ue.compareSchema(t,t,e.schema({names:{distributionPoint:"distributionPoint",distributionPointNames:"distributionPointNames",onlyContainsUserCerts:"onlyContainsUserCerts",onlyContainsCACerts:"onlyContainsCACerts",onlySomeReasons:"onlySomeReasons",indirectCRL:"indirectCRL",onlyContainsAttributeCerts:"onlyContainsAttributeCerts"}}));if(!1===r.verified)throw new Error("Object's schema was not verified against input data for IssuingDistributionPoint");if("distributionPoint"in r.result)switch(!0){case 0===r.result.distributionPoint.idBlock.tagNumber:this.distributionPoint=Array.from(r.result.distributionPointNames,(function(e){return new We({schema:e})}));break;case 1===r.result.distributionPoint.idBlock.tagNumber:this.distributionPoint=new Ge({schema:new ue.Sequence({value:r.result.distributionPoint.valueBlock.value})});break;default:throw new Error("Unknown tagNumber for distributionPoint: {$asn1.result.distributionPoint.idBlock.tagNumber}")}if("onlyContainsUserCerts"in r.result){var n=new Uint8Array(r.result.onlyContainsUserCerts.valueBlock.valueHex);this.onlyContainsUserCerts=0!==n[0]}if("onlyContainsCACerts"in r.result){var a=new Uint8Array(r.result.onlyContainsCACerts.valueBlock.valueHex);this.onlyContainsCACerts=0!==a[0]}if("onlySomeReasons"in r.result){var i=new Uint8Array(r.result.onlySomeReasons.valueBlock.valueHex);this.onlySomeReasons=i[0]}if("indirectCRL"in r.result){var s=new Uint8Array(r.result.indirectCRL.valueBlock.valueHex);this.indirectCRL=0!==s[0]}if("onlyContainsAttributeCerts"in r.result){var o=new Uint8Array(r.result.onlyContainsAttributeCerts.valueBlock.valueHex);this.onlyContainsAttributeCerts=0!==o[0]}}},{key:"toSchema",value:function(){var t,r=[];"distributionPoint"in this&&(this.distributionPoint instanceof Array?t=new ue.Constructed({idBlock:{tagClass:3,tagNumber:0},value:Array.from(this.distributionPoint,(function(e){return e.toSchema()}))}):((t=this.distributionPoint.toSchema()).idBlock.tagClass=3,t.idBlock.tagNumber=1),r.push(new ue.Constructed({idBlock:{tagClass:3,tagNumber:0},value:[t]})));if(this.onlyContainsUserCerts!==e.defaultValues("onlyContainsUserCerts")&&r.push(new ue.Primitive({idBlock:{tagClass:3,tagNumber:1},valueHex:new Uint8Array([255]).buffer})),this.onlyContainsCACerts!==e.defaultValues("onlyContainsCACerts")&&r.push(new ue.Primitive({idBlock:{tagClass:3,tagNumber:2},valueHex:new Uint8Array([255]).buffer})),"onlySomeReasons"in this){var n=new ArrayBuffer(1);new Uint8Array(n)[0]=this.onlySomeReasons,r.push(new ue.Primitive({idBlock:{tagClass:3,tagNumber:3},valueHex:n}))}return this.indirectCRL!==e.defaultValues("indirectCRL")&&r.push(new ue.Primitive({idBlock:{tagClass:3,tagNumber:4},valueHex:new Uint8Array([255]).buffer})),this.onlyContainsAttributeCerts!==e.defaultValues("onlyContainsAttributeCerts")&&r.push(new ue.Primitive({idBlock:{tagClass:3,tagNumber:5},valueHex:new Uint8Array([255]).buffer})),new ue.Sequence({value:r})}},{key:"toJSON",value:function(){var t={};return"distributionPoint"in this&&(this.distributionPoint instanceof Array?t.distributionPoint=Array.from(this.distributionPoint,(function(e){return e.toJSON()})):t.distributionPoint=this.distributionPoint.toJSON()),this.onlyContainsUserCerts!==e.defaultValues("onlyContainsUserCerts")&&(t.onlyContainsUserCerts=this.onlyContainsUserCerts),this.onlyContainsCACerts!==e.defaultValues("onlyContainsCACerts")&&(t.onlyContainsCACerts=this.onlyContainsCACerts),"onlySomeReasons"in this&&(t.onlySomeReasons=this.onlySomeReasons),this.indirectCRL!==e.defaultValues("indirectCRL")&&(t.indirectCRL=this.indirectCRL),this.onlyContainsAttributeCerts!==e.defaultValues("onlyContainsAttributeCerts")&&(t.onlyContainsAttributeCerts=this.onlyContainsAttributeCerts),t}}],[{key:"defaultValues",value:function(e){switch(e){case"distributionPoint":return[];case"onlyContainsUserCerts":case"onlyContainsCACerts":return!1;case"onlySomeReasons":return 0;case"indirectCRL":case"onlyContainsAttributeCerts":return!1;default:throw new Error("Invalid member name for IssuingDistributionPoint class: ".concat(e))}}},{key:"schema",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=le(e,"names",{});return new ue.Sequence({name:t.blockName||"",value:[new ue.Constructed({optional:!0,idBlock:{tagClass:3,tagNumber:0},value:[new ue.Choice({value:[new ue.Constructed({name:t.distributionPoint||"",idBlock:{tagClass:3,tagNumber:0},value:[new ue.Repeated({name:t.distributionPointNames||"",value:We.schema()})]}),new ue.Constructed({name:t.distributionPoint||"",idBlock:{tagClass:3,tagNumber:1},value:Ge.schema().valueBlock.value})]})]}),new ue.Primitive({name:t.onlyContainsUserCerts||"",optional:!0,idBlock:{tagClass:3,tagNumber:1}}),new ue.Primitive({name:t.onlyContainsCACerts||"",optional:!0,idBlock:{tagClass:3,tagNumber:2}}),new ue.Primitive({name:t.onlySomeReasons||"",optional:!0,idBlock:{tagClass:3,tagNumber:3}}),new ue.Primitive({name:t.indirectCRL||"",optional:!0,idBlock:{tagClass:3,tagNumber:4}}),new ue.Primitive({name:t.onlyContainsAttributeCerts||"",optional:!0,idBlock:{tagClass:3,tagNumber:5}})]})}}]),e}(),rt=function(){function e(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};a(this,e),this.names=le(t,"names",e.defaultValues("names")),"schema"in t&&this.fromSchema(t.schema)}return s(e,[{key:"fromSchema",value:function(t){we(t,["names","generalNames"]);var r=ue.compareSchema(t,t,e.schema({names:{blockName:"names",generalNames:"generalNames"}}));if(!1===r.verified)throw new Error("Object's schema was not verified against input data for GeneralNames");this.names=Array.from(r.result.generalNames,(function(e){return new We({schema:e})}))}},{key:"toSchema",value:function(){return new ue.Sequence({value:Array.from(this.names,(function(e){return e.toSchema()}))})}},{key:"toJSON",value:function(){return{names:Array.from(this.names,(function(e){return e.toJSON()}))}}}],[{key:"defaultValues",value:function(e){switch(e){case"names":return[];default:throw new Error("Invalid member name for GeneralNames class: ".concat(e))}}},{key:"schema",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=arguments.length>1&&void 0!==arguments[1]&&arguments[1],r=le(e,"names",{});return new ue.Sequence({optional:t,name:r.blockName||"",value:[new ue.Repeated({name:r.generalNames||"",value:We.schema()})]})}}]),e}(),nt=function(){function e(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};a(this,e),this.base=le(t,"base",e.defaultValues("base")),this.minimum=le(t,"minimum",e.defaultValues("minimum")),"maximum"in t&&(this.maximum=le(t,"maximum",e.defaultValues("maximum"))),"schema"in t&&this.fromSchema(t.schema)}return s(e,[{key:"fromSchema",value:function(t){we(t,["base","minimum","maximum"]);var r=ue.compareSchema(t,t,e.schema({names:{base:{names:{blockName:"base"}},minimum:"minimum",maximum:"maximum"}}));if(!1===r.verified)throw new Error("Object's schema was not verified against input data for GeneralSubtree");this.base=new We({schema:r.result.base}),"minimum"in r.result&&(r.result.minimum.valueBlock.isHexOnly?this.minimum=r.result.minimum:this.minimum=r.result.minimum.valueBlock.valueDec),"maximum"in r.result&&(r.result.maximum.valueBlock.isHexOnly?this.maximum=r.result.maximum:this.maximum=r.result.maximum.valueBlock.valueDec)}},{key:"toSchema",value:function(){var e=[];if(e.push(this.base.toSchema()),0!==this.minimum){var t=0;t=this.minimum instanceof ue.Integer?this.minimum:new ue.Integer({value:this.minimum}),e.push(new ue.Constructed({optional:!0,idBlock:{tagClass:3,tagNumber:0},value:[t]}))}if("maximum"in this){var r=0;r=this.maximum instanceof ue.Integer?this.maximum:new ue.Integer({value:this.maximum}),e.push(new ue.Constructed({optional:!0,idBlock:{tagClass:3,tagNumber:1},value:[r]}))}return new ue.Sequence({value:e})}},{key:"toJSON",value:function(){var e={base:this.base.toJSON()};return 0!==this.minimum&&("number"==typeof this.minimum?e.minimum=this.minimum:e.minimum=this.minimum.toJSON()),"maximum"in this&&("number"==typeof this.maximum?e.maximum=this.maximum:e.maximum=this.maximum.toJSON()),e}}],[{key:"defaultValues",value:function(e){switch(e){case"base":return new We;case"minimum":case"maximum":return 0;default:throw new Error("Invalid member name for GeneralSubtree class: ".concat(e))}}},{key:"schema",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=le(e,"names",{});return new ue.Sequence({name:t.blockName||"",value:[We.schema(t.base||{}),new ue.Constructed({optional:!0,idBlock:{tagClass:3,tagNumber:0},value:[new ue.Integer({name:t.minimum||""})]}),new ue.Constructed({optional:!0,idBlock:{tagClass:3,tagNumber:1},value:[new ue.Integer({name:t.maximum||""})]})]})}}]),e}(),at=function(){function e(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};a(this,e),"permittedSubtrees"in t&&(this.permittedSubtrees=le(t,"permittedSubtrees",e.defaultValues("permittedSubtrees"))),"excludedSubtrees"in t&&(this.excludedSubtrees=le(t,"excludedSubtrees",e.defaultValues("excludedSubtrees"))),"schema"in t&&this.fromSchema(t.schema)}return s(e,[{key:"fromSchema",value:function(t){we(t,["permittedSubtrees","excludedSubtrees"]);var r=ue.compareSchema(t,t,e.schema({names:{permittedSubtrees:"permittedSubtrees",excludedSubtrees:"excludedSubtrees"}}));if(!1===r.verified)throw new Error("Object's schema was not verified against input data for NameConstraints");"permittedSubtrees"in r.result&&(this.permittedSubtrees=Array.from(r.result.permittedSubtrees,(function(e){return new nt({schema:e})}))),"excludedSubtrees"in r.result&&(this.excludedSubtrees=Array.from(r.result.excludedSubtrees,(function(e){return new nt({schema:e})})))}},{key:"toSchema",value:function(){var e=[];return"permittedSubtrees"in this&&e.push(new ue.Constructed({idBlock:{tagClass:3,tagNumber:0},value:Array.from(this.permittedSubtrees,(function(e){return e.toSchema()}))})),"excludedSubtrees"in this&&e.push(new ue.Constructed({idBlock:{tagClass:3,tagNumber:1},value:Array.from(this.excludedSubtrees,(function(e){return e.toSchema()}))})),new ue.Sequence({value:e})}},{key:"toJSON",value:function(){var e={};return"permittedSubtrees"in this&&(e.permittedSubtrees=Array.from(this.permittedSubtrees,(function(e){return e.toJSON()}))),"excludedSubtrees"in this&&(e.excludedSubtrees=Array.from(this.excludedSubtrees,(function(e){return e.toJSON()}))),e}}],[{key:"defaultValues",value:function(e){switch(e){case"permittedSubtrees":case"excludedSubtrees":return[];default:throw new Error("Invalid member name for NameConstraints class: ".concat(e))}}},{key:"schema",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=le(e,"names",{});return new ue.Sequence({name:t.blockName||"",value:[new ue.Constructed({optional:!0,idBlock:{tagClass:3,tagNumber:0},value:[new ue.Repeated({name:t.permittedSubtrees||"",value:nt.schema()})]}),new ue.Constructed({optional:!0,idBlock:{tagClass:3,tagNumber:1},value:[new ue.Repeated({name:t.excludedSubtrees||"",value:nt.schema()})]})]})}}]),e}(),it=function(){function e(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};a(this,e),"distributionPoint"in t&&(this.distributionPoint=le(t,"distributionPoint",e.defaultValues("distributionPoint"))),"reasons"in t&&(this.reasons=le(t,"reasons",e.defaultValues("reasons"))),"cRLIssuer"in t&&(this.cRLIssuer=le(t,"cRLIssuer",e.defaultValues("cRLIssuer"))),"schema"in t&&this.fromSchema(t.schema)}return s(e,[{key:"fromSchema",value:function(t){we(t,["distributionPoint","distributionPointNames","reasons","cRLIssuer","cRLIssuerNames"]);var r=ue.compareSchema(t,t,e.schema({names:{distributionPoint:"distributionPoint",distributionPointNames:"distributionPointNames",reasons:"reasons",cRLIssuer:"cRLIssuer",cRLIssuerNames:"cRLIssuerNames"}}));if(!1===r.verified)throw new Error("Object's schema was not verified against input data for DistributionPoint");"distributionPoint"in r.result&&(0===r.result.distributionPoint.idBlock.tagNumber&&(this.distributionPoint=Array.from(r.result.distributionPointNames,(function(e){return new We({schema:e})}))),1===r.result.distributionPoint.idBlock.tagNumber&&(this.distributionPoint=new Ge({schema:new ue.Sequence({value:r.result.distributionPoint.valueBlock.value})}))),"reasons"in r.result&&(this.reasons=new ue.BitString({valueHex:r.result.reasons.valueBlock.valueHex})),"cRLIssuer"in r.result&&(this.cRLIssuer=Array.from(r.result.cRLIssuerNames,(function(e){return new We({schema:e})})))}},{key:"toSchema",value:function(){var e,t=[];"distributionPoint"in this&&(e=this.distributionPoint instanceof Array?new ue.Constructed({idBlock:{tagClass:3,tagNumber:0},value:Array.from(this.distributionPoint,(function(e){return e.toSchema()}))}):new ue.Constructed({idBlock:{tagClass:3,tagNumber:1},value:[this.distributionPoint.toSchema()]}),t.push(new ue.Constructed({idBlock:{tagClass:3,tagNumber:0},value:[e]})));return"reasons"in this&&t.push(new ue.Primitive({idBlock:{tagClass:3,tagNumber:1},valueHex:this.reasons.valueBlock.valueHex})),"cRLIssuer"in this&&t.push(new ue.Constructed({idBlock:{tagClass:3,tagNumber:2},value:Array.from(this.cRLIssuer,(function(e){return e.toSchema()}))})),new ue.Sequence({value:t})}},{key:"toJSON",value:function(){var e={};return"distributionPoint"in this&&(this.distributionPoint instanceof Array?e.distributionPoint=Array.from(this.distributionPoint,(function(e){return e.toJSON()})):e.distributionPoint=this.distributionPoint.toJSON()),"reasons"in this&&(e.reasons=this.reasons.toJSON()),"cRLIssuer"in this&&(e.cRLIssuer=Array.from(this.cRLIssuer,(function(e){return e.toJSON()}))),e}}],[{key:"defaultValues",value:function(e){switch(e){case"distributionPoint":return[];case"reasons":return new ue.BitString;case"cRLIssuer":return[];default:throw new Error("Invalid member name for DistributionPoint class: ".concat(e))}}},{key:"schema",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=le(e,"names",{});return new ue.Sequence({name:t.blockName||"",value:[new ue.Constructed({optional:!0,idBlock:{tagClass:3,tagNumber:0},value:[new ue.Choice({value:[new ue.Constructed({name:t.distributionPoint||"",optional:!0,idBlock:{tagClass:3,tagNumber:0},value:[new ue.Repeated({name:t.distributionPointNames||"",value:We.schema()})]}),new ue.Constructed({name:t.distributionPoint||"",optional:!0,idBlock:{tagClass:3,tagNumber:1},value:Ge.schema().valueBlock.value})]})]}),new ue.Primitive({name:t.reasons||"",optional:!0,idBlock:{tagClass:3,tagNumber:1}}),new ue.Constructed({name:t.cRLIssuer||"",optional:!0,idBlock:{tagClass:3,tagNumber:2},value:[new ue.Repeated({name:t.cRLIssuerNames||"",value:We.schema()})]})]})}}]),e}(),st=function(){function e(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};a(this,e),this.distributionPoints=le(t,"distributionPoints",e.defaultValues("distributionPoints")),"schema"in t&&this.fromSchema(t.schema)}return s(e,[{key:"fromSchema",value:function(t){we(t,["distributionPoints"]);var r=ue.compareSchema(t,t,e.schema({names:{distributionPoints:"distributionPoints"}}));if(!1===r.verified)throw new Error("Object's schema was not verified against input data for CRLDistributionPoints");this.distributionPoints=Array.from(r.result.distributionPoints,(function(e){return new it({schema:e})}))}},{key:"toSchema",value:function(){return new ue.Sequence({value:Array.from(this.distributionPoints,(function(e){return e.toSchema()}))})}},{key:"toJSON",value:function(){return{distributionPoints:Array.from(this.distributionPoints,(function(e){return e.toJSON()}))}}}],[{key:"defaultValues",value:function(e){switch(e){case"distributionPoints":return[];default:throw new Error("Invalid member name for CRLDistributionPoints class: ".concat(e))}}},{key:"schema",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=le(e,"names",{});return new ue.Sequence({name:t.blockName||"",value:[new ue.Repeated({name:t.distributionPoints||"",value:it.schema()})]})}}]),e}(),ot=function(){function e(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};a(this,e),this.policyQualifierId=le(t,"policyQualifierId",e.defaultValues("policyQualifierId")),this.qualifier=le(t,"qualifier",e.defaultValues("qualifier")),"schema"in t&&this.fromSchema(t.schema)}return s(e,[{key:"fromSchema",value:function(t){we(t,["policyQualifierId","qualifier"]);var r=ue.compareSchema(t,t,e.schema({names:{policyQualifierId:"policyQualifierId",qualifier:"qualifier"}}));if(!1===r.verified)throw new Error("Object's schema was not verified against input data for PolicyQualifierInfo");this.policyQualifierId=r.result.policyQualifierId.valueBlock.toString(),this.qualifier=r.result.qualifier}},{key:"toSchema",value:function(){return new ue.Sequence({value:[new ue.ObjectIdentifier({value:this.policyQualifierId}),this.qualifier]})}},{key:"toJSON",value:function(){return{policyQualifierId:this.policyQualifierId,qualifier:this.qualifier.toJSON()}}}],[{key:"defaultValues",value:function(e){switch(e){case"policyQualifierId":return"";case"qualifier":return new ue.Any;default:throw new Error("Invalid member name for PolicyQualifierInfo class: ".concat(e))}}},{key:"schema",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=le(e,"names",{});return new ue.Sequence({name:t.blockName||"",value:[new ue.ObjectIdentifier({name:t.policyQualifierId||""}),new ue.Any({name:t.qualifier||""})]})}}]),e}(),ut=function(){function e(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};a(this,e),this.policyIdentifier=le(t,"policyIdentifier",e.defaultValues("policyIdentifier")),"policyQualifiers"in t&&(this.policyQualifiers=le(t,"policyQualifiers",e.defaultValues("policyQualifiers"))),"schema"in t&&this.fromSchema(t.schema)}return s(e,[{key:"fromSchema",value:function(t){we(t,["policyIdentifier","policyQualifiers"]);var r=ue.compareSchema(t,t,e.schema({names:{policyIdentifier:"policyIdentifier",policyQualifiers:"policyQualifiers"}}));if(!1===r.verified)throw new Error("Object's schema was not verified against input data for PolicyInformation");this.policyIdentifier=r.result.policyIdentifier.valueBlock.toString(),"policyQualifiers"in r.result&&(this.policyQualifiers=Array.from(r.result.policyQualifiers,(function(e){return new ot({schema:e})})))}},{key:"toSchema",value:function(){var e=[];return e.push(new ue.ObjectIdentifier({value:this.policyIdentifier})),"policyQualifiers"in this&&e.push(new ue.Sequence({value:Array.from(this.policyQualifiers,(function(e){return e.toSchema()}))})),new ue.Sequence({value:e})}},{key:"toJSON",value:function(){var e={policyIdentifier:this.policyIdentifier};return"policyQualifiers"in this&&(e.policyQualifiers=Array.from(this.policyQualifiers,(function(e){return e.toJSON()}))),e}}],[{key:"defaultValues",value:function(e){switch(e){case"policyIdentifier":return"";case"policyQualifiers":return[];default:throw new Error("Invalid member name for PolicyInformation class: ".concat(e))}}},{key:"schema",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=le(e,"names",{});return new ue.Sequence({name:t.blockName||"",value:[new ue.ObjectIdentifier({name:t.policyIdentifier||""}),new ue.Sequence({optional:!0,value:[new ue.Repeated({name:t.policyQualifiers||"",value:ot.schema()})]})]})}}]),e}(),lt=function(){function e(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};a(this,e),this.certificatePolicies=le(t,"certificatePolicies",e.defaultValues("certificatePolicies")),"schema"in t&&this.fromSchema(t.schema)}return s(e,[{key:"fromSchema",value:function(t){we(t,["certificatePolicies"]);var r=ue.compareSchema(t,t,e.schema({names:{certificatePolicies:"certificatePolicies"}}));if(!1===r.verified)throw new Error("Object's schema was not verified against input data for CertificatePolicies");this.certificatePolicies=Array.from(r.result.certificatePolicies,(function(e){return new ut({schema:e})}))}},{key:"toSchema",value:function(){return new ue.Sequence({value:Array.from(this.certificatePolicies,(function(e){return e.toSchema()}))})}},{key:"toJSON",value:function(){return{certificatePolicies:Array.from(this.certificatePolicies,(function(e){return e.toJSON()}))}}}],[{key:"defaultValues",value:function(e){switch(e){case"certificatePolicies":return[];default:throw new Error("Invalid member name for CertificatePolicies class: ".concat(e))}}},{key:"schema",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=le(e,"names",{});return new ue.Sequence({name:t.blockName||"",value:[new ue.Repeated({name:t.certificatePolicies||"",value:ut.schema()})]})}}]),e}(),ct=function(){function e(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};a(this,e),this.issuerDomainPolicy=le(t,"issuerDomainPolicy",e.defaultValues("issuerDomainPolicy")),this.subjectDomainPolicy=le(t,"subjectDomainPolicy",e.defaultValues("subjectDomainPolicy")),"schema"in t&&this.fromSchema(t.schema)}return s(e,[{key:"fromSchema",value:function(t){we(t,["issuerDomainPolicy","subjectDomainPolicy"]);var r=ue.compareSchema(t,t,e.schema({names:{issuerDomainPolicy:"issuerDomainPolicy",subjectDomainPolicy:"subjectDomainPolicy"}}));if(!1===r.verified)throw new Error("Object's schema was not verified against input data for PolicyMapping");this.issuerDomainPolicy=r.result.issuerDomainPolicy.valueBlock.toString(),this.subjectDomainPolicy=r.result.subjectDomainPolicy.valueBlock.toString()}},{key:"toSchema",value:function(){return new ue.Sequence({value:[new ue.ObjectIdentifier({value:this.issuerDomainPolicy}),new ue.ObjectIdentifier({value:this.subjectDomainPolicy})]})}},{key:"toJSON",value:function(){return{issuerDomainPolicy:this.issuerDomainPolicy,subjectDomainPolicy:this.subjectDomainPolicy}}}],[{key:"defaultValues",value:function(e){switch(e){case"issuerDomainPolicy":case"subjectDomainPolicy":return"";default:throw new Error("Invalid member name for PolicyMapping class: ".concat(e))}}},{key:"schema",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=le(e,"names",{});return new ue.Sequence({name:t.blockName||"",value:[new ue.ObjectIdentifier({name:t.issuerDomainPolicy||""}),new ue.ObjectIdentifier({name:t.subjectDomainPolicy||""})]})}}]),e}(),ht=function(){function e(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};a(this,e),this.mappings=le(t,"mappings",e.defaultValues("mappings")),"schema"in t&&this.fromSchema(t.schema)}return s(e,[{key:"fromSchema",value:function(t){we(t,["mappings"]);var r=ue.compareSchema(t,t,e.schema({names:{mappings:"mappings"}}));if(!1===r.verified)throw new Error("Object's schema was not verified against input data for PolicyMappings");this.mappings=Array.from(r.result.mappings,(function(e){return new ct({schema:e})}))}},{key:"toSchema",value:function(){return new ue.Sequence({value:Array.from(this.mappings,(function(e){return e.toSchema()}))})}},{key:"toJSON",value:function(){return{mappings:Array.from(this.mappings,(function(e){return e.toJSON()}))}}}],[{key:"defaultValues",value:function(e){switch(e){case"mappings":return[];default:throw new Error("Invalid member name for PolicyMappings class: ".concat(e))}}},{key:"schema",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=le(e,"names",{});return new ue.Sequence({name:t.blockName||"",value:[new ue.Repeated({name:t.mappings||"",value:ct.schema()})]})}}]),e}(),mt=function(){function e(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};a(this,e),"keyIdentifier"in t&&(this.keyIdentifier=le(t,"keyIdentifier",e.defaultValues("keyIdentifier"))),"authorityCertIssuer"in t&&(this.authorityCertIssuer=le(t,"authorityCertIssuer",e.defaultValues("authorityCertIssuer"))),"authorityCertSerialNumber"in t&&(this.authorityCertSerialNumber=le(t,"authorityCertSerialNumber",e.defaultValues("authorityCertSerialNumber"))),"schema"in t&&this.fromSchema(t.schema)}return s(e,[{key:"fromSchema",value:function(t){we(t,["keyIdentifier","authorityCertIssuer","authorityCertSerialNumber"]);var r=ue.compareSchema(t,t,e.schema({names:{keyIdentifier:"keyIdentifier",authorityCertIssuer:"authorityCertIssuer",authorityCertSerialNumber:"authorityCertSerialNumber"}}));if(!1===r.verified)throw new Error("Object's schema was not verified against input data for AuthorityKeyIdentifier");"keyIdentifier"in r.result&&(this.keyIdentifier=new ue.OctetString({valueHex:r.result.keyIdentifier.valueBlock.valueHex})),"authorityCertIssuer"in r.result&&(this.authorityCertIssuer=Array.from(r.result.authorityCertIssuer,(function(e){return new We({schema:e})}))),"authorityCertSerialNumber"in r.result&&(this.authorityCertSerialNumber=new ue.Integer({valueHex:r.result.authorityCertSerialNumber.valueBlock.valueHex}))}},{key:"toSchema",value:function(){var e=[];return"keyIdentifier"in this&&e.push(new ue.Primitive({idBlock:{tagClass:3,tagNumber:0},valueHex:this.keyIdentifier.valueBlock.valueHex})),"authorityCertIssuer"in this&&e.push(new ue.Constructed({idBlock:{tagClass:3,tagNumber:1},value:Array.from(this.authorityCertIssuer,(function(e){return e.toSchema()}))})),"authorityCertSerialNumber"in this&&e.push(new ue.Primitive({idBlock:{tagClass:3,tagNumber:2},valueHex:this.authorityCertSerialNumber.valueBlock.valueHex})),new ue.Sequence({value:e})}},{key:"toJSON",value:function(){var e={};return"keyIdentifier"in this&&(e.keyIdentifier=this.keyIdentifier.toJSON()),"authorityCertIssuer"in this&&(e.authorityCertIssuer=Array.from(this.authorityCertIssuer,(function(e){return e.toJSON()}))),"authorityCertSerialNumber"in this&&(e.authorityCertSerialNumber=this.authorityCertSerialNumber.toJSON()),e}}],[{key:"defaultValues",value:function(e){switch(e){case"keyIdentifier":return new ue.OctetString;case"authorityCertIssuer":return[];case"authorityCertSerialNumber":return new ue.Integer;default:throw new Error("Invalid member name for AuthorityKeyIdentifier class: ".concat(e))}}},{key:"schema",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=le(e,"names",{});return new ue.Sequence({name:t.blockName||"",value:[new ue.Primitive({name:t.keyIdentifier||"",optional:!0,idBlock:{tagClass:3,tagNumber:0}}),new ue.Constructed({optional:!0,idBlock:{tagClass:3,tagNumber:1},value:[new ue.Repeated({name:t.authorityCertIssuer||"",value:We.schema()})]}),new ue.Primitive({name:t.authorityCertSerialNumber||"",optional:!0,idBlock:{tagClass:3,tagNumber:2}})]})}}]),e}(),ft=function(){function e(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};a(this,e),"requireExplicitPolicy"in t&&(this.requireExplicitPolicy=le(t,"requireExplicitPolicy",e.defaultValues("requireExplicitPolicy"))),"inhibitPolicyMapping"in t&&(this.inhibitPolicyMapping=le(t,"inhibitPolicyMapping",e.defaultValues("inhibitPolicyMapping"))),"schema"in t&&this.fromSchema(t.schema)}return s(e,[{key:"fromSchema",value:function(t){we(t,["requireExplicitPolicy","inhibitPolicyMapping"]);var r=ue.compareSchema(t,t,e.schema({names:{requireExplicitPolicy:"requireExplicitPolicy",inhibitPolicyMapping:"inhibitPolicyMapping"}}));if(!1===r.verified)throw new Error("Object's schema was not verified against input data for PolicyConstraints");if("requireExplicitPolicy"in r.result){var n=r.result.requireExplicitPolicy;n.idBlock.tagClass=1,n.idBlock.tagNumber=2;var a=n.toBER(!1),i=ue.fromBER(a);this.requireExplicitPolicy=i.result.valueBlock.valueDec}if("inhibitPolicyMapping"in r.result){var s=r.result.inhibitPolicyMapping;s.idBlock.tagClass=1,s.idBlock.tagNumber=2;var o=s.toBER(!1),u=ue.fromBER(o);this.inhibitPolicyMapping=u.result.valueBlock.valueDec}}},{key:"toSchema",value:function(){var e=[];if("requireExplicitPolicy"in this){var t=new ue.Integer({value:this.requireExplicitPolicy});t.idBlock.tagClass=3,t.idBlock.tagNumber=0,e.push(t)}if("inhibitPolicyMapping"in this){var r=new ue.Integer({value:this.inhibitPolicyMapping});r.idBlock.tagClass=3,r.idBlock.tagNumber=1,e.push(r)}return new ue.Sequence({value:e})}},{key:"toJSON",value:function(){var e={};return"requireExplicitPolicy"in this&&(e.requireExplicitPolicy=this.requireExplicitPolicy),"inhibitPolicyMapping"in this&&(e.inhibitPolicyMapping=this.inhibitPolicyMapping),e}}],[{key:"defaultValues",value:function(e){switch(e){case"requireExplicitPolicy":case"inhibitPolicyMapping":return 0;default:throw new Error("Invalid member name for PolicyConstraints class: ".concat(e))}}},{key:"schema",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=le(e,"names",{});return new ue.Sequence({name:t.blockName||"",value:[new ue.Primitive({name:t.requireExplicitPolicy||"",optional:!0,idBlock:{tagClass:3,tagNumber:0}}),new ue.Primitive({name:t.inhibitPolicyMapping||"",optional:!0,idBlock:{tagClass:3,tagNumber:1}})]})}}]),e}(),vt=function(){function e(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};a(this,e),this.keyPurposes=le(t,"keyPurposes",e.defaultValues("keyPurposes")),"schema"in t&&this.fromSchema(t.schema)}return s(e,[{key:"fromSchema",value:function(t){we(t,["keyPurposes"]);var r=ue.compareSchema(t,t,e.schema({names:{keyPurposes:"keyPurposes"}}));if(!1===r.verified)throw new Error("Object's schema was not verified against input data for ExtKeyUsage");this.keyPurposes=Array.from(r.result.keyPurposes,(function(e){return e.valueBlock.toString()}))}},{key:"toSchema",value:function(){return new ue.Sequence({value:Array.from(this.keyPurposes,(function(e){return new ue.ObjectIdentifier({value:e})}))})}},{key:"toJSON",value:function(){return{keyPurposes:Array.from(this.keyPurposes)}}}],[{key:"defaultValues",value:function(e){switch(e){case"keyPurposes":return[];default:throw new Error("Invalid member name for ExtKeyUsage class: ".concat(e))}}},{key:"schema",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=le(e,"names",{});return new ue.Sequence({name:t.blockName||"",value:[new ue.Repeated({name:t.keyPurposes||"",value:new ue.ObjectIdentifier})]})}}]),e}(),gt=function(){function e(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};a(this,e),this.accessDescriptions=le(t,"accessDescriptions",e.defaultValues("accessDescriptions")),"schema"in t&&this.fromSchema(t.schema)}return s(e,[{key:"fromSchema",value:function(t){we(t,["accessDescriptions"]);var r=ue.compareSchema(t,t,e.schema({names:{accessDescriptions:"accessDescriptions"}}));if(!1===r.verified)throw new Error("Object's schema was not verified against input data for InfoAccess");this.accessDescriptions=Array.from(r.result.accessDescriptions,(function(e){return new ze({schema:e})}))}},{key:"toSchema",value:function(){return new ue.Sequence({value:Array.from(this.accessDescriptions,(function(e){return e.toSchema()}))})}},{key:"toJSON",value:function(){return{accessDescriptions:Array.from(this.accessDescriptions,(function(e){return e.toJSON()}))}}}],[{key:"defaultValues",value:function(e){switch(e){case"accessDescriptions":return[];default:throw new Error("Invalid member name for InfoAccess class: ".concat(e))}}},{key:"schema",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=le(e,"names",{});return new ue.Sequence({name:t.blockName||"",value:[new ue.Repeated({name:t.accessDescriptions||"",value:ze.schema()})]})}}]),e}(),dt=function(){function e(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};a(this,e),this.clear();for(var r=0,n=Object.keys(t);r<n.length;r++){var i=n[r];switch(i){case"length":this.length=t.length;break;case"stub":for(var s=0;s<this._view.length;s++)this._view[s]=t.stub;break;case"view":this.fromUint8Array(t.view);break;case"buffer":this.fromArrayBuffer(t.buffer);break;case"string":this.fromString(t.string);break;case"hexstring":this.fromHexString(t.hexstring)}}}return s(e,[{key:"clear",value:function(){this._buffer=new ArrayBuffer(0),this._view=new Uint8Array(this._buffer)}},{key:"fromArrayBuffer",value:function(e){this.buffer=e}},{key:"fromUint8Array",value:function(e){this._buffer=new ArrayBuffer(e.length),this._view=new Uint8Array(this._buffer),this._view.set(e)}},{key:"fromString",value:function(e){var t=e.length;this.length=t;for(var r=0;r<t;r++)this.view[r]=e.charCodeAt(r)}},{key:"toString",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0,t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:this.view.length-e,r="";(e>=this.view.length||e<0)&&(e=0),(t>=this.view.length||t<0)&&(t=this.view.length-e);for(var n=e;n<e+t;n++)r+=String.fromCharCode(this.view[n]);return r}},{key:"fromHexString",value:function(e){var t=e.length;this.buffer=new ArrayBuffer(t>>1),this.view=new Uint8Array(this.buffer);var r=new Map;r.set("0",0),r.set("1",1),r.set("2",2),r.set("3",3),r.set("4",4),r.set("5",5),r.set("6",6),r.set("7",7),r.set("8",8),r.set("9",9),r.set("A",10),r.set("a",10),r.set("B",11),r.set("b",11),r.set("C",12),r.set("c",12),r.set("D",13),r.set("d",13),r.set("E",14),r.set("e",14),r.set("F",15),r.set("f",15);for(var n=0,a=0,i=0;i<t;i++)i%2?(a|=r.get(e.charAt(i)),this.view[n]=a,n++):a=r.get(e.charAt(i))<<4}},{key:"toHexString",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0,t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:this.view.length-e,r="";(e>=this.view.length||e<0)&&(e=0),(t>=this.view.length||t<0)&&(t=this.view.length-e);for(var n=e;n<e+t;n++){var a=this.view[n].toString(16).toUpperCase();r=r+(1==a.length?"0":"")+a}return r}},{key:"copy",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:this._buffer.byteLength-t;if(0===t&&0===this._buffer.byteLength)return new e;if(t<0||t>this._buffer.byteLength-1)throw new Error("Wrong start position: ".concat(t));var n=new e;return n._buffer=this._buffer.slice(t,t+r),n._view=new Uint8Array(n._buffer),n}},{key:"slice",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:this._buffer.byteLength;if(0===t&&0===this._buffer.byteLength)return new e;if(t<0||t>this._buffer.byteLength-1)throw new Error("Wrong start position: ".concat(t));var n=new e;return n._buffer=this._buffer.slice(t,r),n._view=new Uint8Array(n._buffer),n}},{key:"realloc",value:function(e){var t=new ArrayBuffer(e),r=new Uint8Array(t);e>this._view.length?r.set(this._view):r.set(new Uint8Array(this._buffer,0,e)),this._buffer=t.slice(0),this._view=new Uint8Array(this._buffer)}},{key:"append",value:function(e){var t=this._buffer.byteLength,r=e._buffer.byteLength,n=e._view.slice();this.realloc(t+r),this._view.set(n,t)}},{key:"insert",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:this._buffer.byteLength-t;return!(t>this._buffer.byteLength-1)&&(r>this._buffer.byteLength-t&&(r=this._buffer.byteLength-t),r>e._buffer.byteLength&&(r=e._buffer.byteLength),r==e._buffer.byteLength?this._view.set(e._view,t):this._view.set(e._view.slice(0,r),t),!0)}},{key:"isEqual",value:function(e){if(this._buffer.byteLength!=e._buffer.byteLength)return!1;for(var t=0;t<e._buffer.byteLength;t++)if(this.view[t]!=e.view[t])return!1;return!0}},{key:"isEqualView",value:function(e){if(e.length!=this.view.length)return!1;for(var t=0;t<e.length;t++)if(this.view[t]!=e[t])return!1;return!0}},{key:"findPattern",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null,r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null,n=arguments.length>3&&void 0!==arguments[3]&&arguments[3];null==t&&(t=n?this.buffer.byteLength:0),t>this.buffer.byteLength&&(t=this.buffer.byteLength),n?(null==r&&(r=t),r>t&&(r=t)):(null==r&&(r=this.buffer.byteLength-t),r>this.buffer.byteLength-t&&(r=this.buffer.byteLength-t));var a=e.buffer.byteLength;if(a>r)return-1;for(var i=[],s=0;s<a;s++)i.push(e.view[s]);for(var o=0;o<=r-a;o++){for(var u=!0,l=n?t-a-o:t+o,c=0;c<a;c++)if(this.view[c+l]!=i[c]){u=!1;break}if(u)return n?t-a-o:t+a+o}return-1}},{key:"findFirstIn",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null,r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null,n=arguments.length>3&&void 0!==arguments[3]&&arguments[3];null==t&&(t=n?this.buffer.byteLength:0),t>this.buffer.byteLength&&(t=this.buffer.byteLength),n?(null==r&&(r=t),r>t&&(r=t)):(null==r&&(r=this.buffer.byteLength-t),r>this.buffer.byteLength-t&&(r=this.buffer.byteLength-t));for(var a={id:-1,position:n?0:t+r,length:0},i=0;i<e.length;i++){var s=this.findPattern(e[i],t,r,n);if(-1!=s){var o=!1,u=e[i].length;n?s-u>=a.position-a.length&&(o=!0):s-u<=a.position-a.length&&(o=!0),o&&(a.position=s,a.id=i,a.length=u)}}return a}},{key:"findAllIn",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:this.buffer.byteLength-t,n=[];if(null==t&&(t=0),t>this.buffer.byteLength-1)return n;null==r&&(r=this.buffer.byteLength-t),r>this.buffer.byteLength-t&&(r=this.buffer.byteLength-t);for(var a={id:-1,position:t};;){var i=a.position;if(-1==(a=this.findFirstIn(e,a.position,r)).id)break;r-=a.position-i,n.push({id:a.id,position:a.position})}return n}},{key:"findAllPatternIn",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:this.buffer.byteLength-t;null==t&&(t=0),t>this.buffer.byteLength&&(t=this.buffer.byteLength),null==r&&(r=this.buffer.byteLength-t),r>this.buffer.byteLength-t&&(r=this.buffer.byteLength-t);var n=[],a=e.buffer.byteLength;if(a>r)return-1;for(var i=Array.from(e.view),s=0;s<=r-a;s++){for(var o=!0,u=t+s,l=0;l<a;l++)if(this.view[l+u]!=i[l]){o=!1;break}o&&(n.push(t+a+s),s+=a-1)}return n}},{key:"findFirstNotIn",value:function(t){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null,a=arguments.length>3&&void 0!==arguments[3]&&arguments[3];null==r&&(r=a?this.buffer.byteLength:0),r>this.buffer.byteLength&&(r=this.buffer.byteLength),a?(null==n&&(n=r),n>r&&(n=r)):(null==n&&(n=this.buffer.byteLength-r),n>this.buffer.byteLength-r&&(n=this.buffer.byteLength-r));for(var i={left:{id:-1,position:r},right:{id:-1,position:0},value:new e},s=n;s>0;){if(i.right=this.findFirstIn(t,a?r-n+s:r+n-s,s,a),-1==i.right.id){n=s,a?r-=n:r=i.left.position,i.value=new e,i.value._buffer=this._buffer.slice(r,r+n),i.value._view=new Uint8Array(i.value._buffer);break}if(i.right.position!=(a?i.left.position-t[i.right.id].buffer.byteLength:i.left.position+t[i.right.id].buffer.byteLength)){a?(r=i.right.position+t[i.right.id].buffer.byteLength,n=i.left.position-i.right.position-t[i.right.id].buffer.byteLength):(r=i.left.position,n=i.right.position-i.left.position-t[i.right.id].buffer.byteLength),i.value=new e,i.value._buffer=this._buffer.slice(r,r+n),i.value._view=new Uint8Array(i.value._buffer);break}i.left=i.right,s-=t[i.right.id]._buffer.byteLength}if(a){var o=i.right;i.right=i.left,i.left=o}return i}},{key:"findAllNotIn",value:function(t){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null,a=[];if(null==r&&(r=0),r>this.buffer.byteLength-1)return a;null==n&&(n=this.buffer.byteLength-r),n>this.buffer.byteLength-r&&(n=this.buffer.byteLength-r);var i={left:{id:-1,position:r},right:{id:-1,position:r},value:new e};do{var s=i.right.position;n-=(i=this.findFirstNotIn(t,i.right.position,n)).right.position-s,a.push({left:{id:i.left.id,position:i.left.position},right:{id:i.right.id,position:i.right.position},value:i.value})}while(-1!=i.right.id);return a}},{key:"findFirstSequence",value:function(t){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null,a=arguments.length>3&&void 0!==arguments[3]&&arguments[3];null==r&&(r=a?this.buffer.byteLength:0),r>this.buffer.byteLength&&(r=this.buffer.byteLength),a?(null==n&&(n=r),n>r&&(n=r)):(null==n&&(n=this.buffer.byteLength-r),n>this.buffer.byteLength-r&&(n=this.buffer.byteLength-r));var i=this.skipNotPatterns(t,r,n,a);if(-1==i)return{position:-1,value:new e};var s=this.skipPatterns(t,i,n-(a?r-i:i-r),a);a?(r=s,n=i-s):(r=i,n=s-i);var o=new e;return o._buffer=this._buffer.slice(r,r+n),o._view=new Uint8Array(o._buffer),{position:s,value:o}}},{key:"findAllSequences",value:function(t){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null,a=[];if(null==r&&(r=0),r>this.buffer.byteLength-1)return a;null==n&&(n=this.buffer.byteLength-r),n>this.buffer.byteLength-r&&(n=this.buffer.byteLength-r);var i={position:r,value:new e};do{var s=i.position;-1!=(i=this.findFirstSequence(t,i.position,n)).position&&(n-=i.position-s,a.push({position:i.position,value:i.value}))}while(-1!=i.position);return a}},{key:"findPairedPatterns",value:function(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null,n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:null,a=[];if(e.isEqual(t))return a;if(null==r&&(r=0),r>this.buffer.byteLength-1)return a;null==n&&(n=this.buffer.byteLength-r),n>this.buffer.byteLength-r&&(n=this.buffer.byteLength-r);var i=0,s=this.findAllPatternIn(e,r,n);if(0==s.length)return a;var o=this.findAllPatternIn(t,r,n);if(0==o.length)return a;for(;i<s.length&&0!=o.length;)if(s[0]!=o[0]){if(s[i]>o[0])break;for(;s[i]<o[0]&&!(++i>=s.length););a.push({left:s[i-1],right:o[0]}),s.splice(i-1,1),o.splice(0,1),i=0}else a.push({left:s[0],right:o[0]}),s.splice(0,1),o.splice(0,1);return a.sort((function(e,t){return e.left-t.left})),a}},{key:"findPairedArrays",value:function(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null,n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:null,a=[];if(null==r&&(r=0),r>this.buffer.byteLength-1)return a;null==n&&(n=this.buffer.byteLength-r),n>this.buffer.byteLength-r&&(n=this.buffer.byteLength-r);var i=0,s=this.findAllIn(e,r,n);if(0==s.length)return a;var o=this.findAllIn(t,r,n);if(0==o.length)return a;for(;i<s.length&&0!=o.length;)if(s[0].position!=o[0].position){if(s[i].position>o[0].position)break;for(;s[i].position<o[0].position&&!(++i>=s.length););a.push({left:s[i-1],right:o[0]}),s.splice(i-1,1),o.splice(0,1),i=0}else a.push({left:s[0],right:o[0]}),s.splice(0,1),o.splice(0,1);return a.sort((function(e,t){return e.left.position-t.left.position})),a}},{key:"replacePattern",value:function(e,t){var r,n,a,i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null,s=arguments.length>3&&void 0!==arguments[3]?arguments[3]:null,o=arguments.length>4&&void 0!==arguments[4]?arguments[4]:null,u={status:-1,searchPatternPositions:[],replacePatternPositions:[]};if(null==i&&(i=0),i>this.buffer.byteLength-1)return!1;if(null==s&&(s=this.buffer.byteLength-i),s>this.buffer.byteLength-i&&(s=this.buffer.byteLength-i),null==o){if(0==(n=this.findAllIn([e],i,s)).length)return u}else n=o;(r=u.searchPatternPositions).push.apply(r,v(Array.from(n,(function(e){return e.position}))));var l=e.buffer.byteLength-t.buffer.byteLength,c=new ArrayBuffer(this.view.length-n.length*l),h=new Uint8Array(c);for(h.set(new Uint8Array(this.buffer,0,i)),a=0;a<n.length;a++){var m=0==a?i:n[a-1].position;h.set(new Uint8Array(this.buffer,m,n[a].position-e.buffer.byteLength-m),m-a*l),h.set(t.view,n[a].position-e.buffer.byteLength-a*l),u.replacePatternPositions.push(n[a].position-e.buffer.byteLength-a*l)}return a--,h.set(new Uint8Array(this.buffer,n[a].position,this.buffer.byteLength-n[a].position),n[a].position-e.buffer.byteLength+t.buffer.byteLength-a*l),this.buffer=c,this.view=new Uint8Array(this.buffer),u.status=1,u}},{key:"skipPatterns",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null,r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null,n=arguments.length>3&&void 0!==arguments[3]&&arguments[3];null==t&&(t=n?this.buffer.byteLength:0),t>this.buffer.byteLength&&(t=this.buffer.byteLength),n?(null==r&&(r=t),r>t&&(r=t)):(null==r&&(r=this.buffer.byteLength-t),r>this.buffer.byteLength-t&&(r=this.buffer.byteLength-t));for(var a=t,i=0;i<e.length;i++){for(var s=e[i].buffer.byteLength,o=n?a-s:a,u=!0,l=0;l<s;l++)if(this.view[l+o]!=e[i].view[l]){u=!1;break}if(u)if(i=-1,n){if((a-=s)<=0)return a}else if((a+=s)>=t+r)return a}return a}},{key:"skipNotPatterns",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null,r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null,n=arguments.length>3&&void 0!==arguments[3]&&arguments[3];null==t&&(t=n?this.buffer.byteLength:0),t>this.buffer.byteLength&&(t=this.buffer.byteLength),n?(null==r&&(r=t),r>t&&(r=t)):(null==r&&(r=this.buffer.byteLength-t),r>this.buffer.byteLength-t&&(r=this.buffer.byteLength-t));for(var a=-1,i=0;i<r;i++){for(var s=0;s<e.length;s++){for(var o=e[s].buffer.byteLength,u=n?t-i-o:t+i,l=!0,c=0;c<o;c++)if(this.view[c+u]!=e[s].view[c]){l=!1;break}if(l){a=n?t-i:t+i;break}}if(-1!=a)break}return a}},{key:"buffer",set:function(e){this._buffer=e.slice(0),this._view=new Uint8Array(this._buffer)},get:function(){return this._buffer}},{key:"view",set:function(e){this._buffer=new ArrayBuffer(e.length),this._view=new Uint8Array(this._buffer),this._view.set(e)},get:function(){return this._view}},{key:"length",get:function(){return this._buffer.byteLength},set:function(e){this._buffer=new ArrayBuffer(e),this._view=new Uint8Array(this._buffer)}}]),e}(),yt=function(){function e(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};a(this,e),this.stream=new dt,this._length=0,this.backward=!1,this._start=0,this.appendBlock=0,this.prevLength=0,this.prevStart=0;for(var r=0,n=Object.keys(t);r<n.length;r++){var i=n[r];switch(i){case"stream":this.stream=t.stream;break;case"backward":this.backward=t.backward,this._start=this.stream.buffer.byteLength;break;case"length":this._length=t.length;break;case"start":this._start=t.start;break;case"appendBlock":this.appendBlock=t.appendBlock;break;case"view":this.stream=new dt({view:t.view});break;case"buffer":this.stream=new dt({buffer:t.buffer});break;case"string":this.stream=new dt({string:t.string});break;case"hexstring":this.stream=new dt({hexstring:t.hexstring})}}}return s(e,[{key:"resetPosition",value:function(){this._start=this.prevStart,this._length=this.prevLength}},{key:"findPattern",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;(null==t||t>this.length)&&(t=this.length);var r=this.stream.findPattern(e,this.start,this.length,this.backward);if(-1==r)return r;if(this.backward){if(r<this.start-e.buffer.byteLength-t)return-1}else if(r>this.start+e.buffer.byteLength+t)return-1;return this.start=r,r}},{key:"findFirstIn",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;(null==t||t>this.length)&&(t=this.length);var r=this.stream.findFirstIn(e,this.start,this.length,this.backward);if(-1==r.id)return r;if(this.backward){if(r.position<this.start-e[r.id].buffer.byteLength-t)return{id:-1,position:this.backward?0:this.start+this.length}}else if(r.position>this.start+e[r.id].buffer.byteLength+t)return{id:-1,position:this.backward?0:this.start+this.length};return this.start=r.position,r}},{key:"findAllIn",value:function(e){var t=this.backward?this.start-this.length:this.start;return this.stream.findAllIn(e,t,this.length)}},{key:"findFirstNotIn",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;(null==t||t>this._length)&&(t=this._length);var r=this._stream.findFirstNotIn(e,this._start,this._length,this.backward);if(-1==r.left.id&&-1==r.right.id)return r;if(this.backward){if(-1!=r.right.id&&r.right.position<this._start-e[r.right.id]._buffer.byteLength-t)return{left:{id:-1,position:this._start},right:{id:-1,position:0},value:new dt}}else if(-1!=r.left.id&&r.left.position>this._start+e[r.left.id]._buffer.byteLength+t)return{left:{id:-1,position:this._start},right:{id:-1,position:0},value:new dt};return this.backward?-1==r.left.id?this.start=0:this.start=r.left.position:-1==r.right.id?this.start=this._start+this._length:this.start=r.right.position,r}},{key:"findAllNotIn",value:function(e){var t=this.backward?this._start-this._length:this._start;return this._stream.findAllNotIn(e,t,this._length)}},{key:"findFirstSequence",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null,r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null;(null==t||t>this._length)&&(t=this._length),(null==r||r>t)&&(r=t);var n=this._stream.findFirstSequence(e,this._start,t,this.backward);if(0==n.value.buffer.byteLength)return n;if(this.backward){if(n.position<this._start-n.value._buffer.byteLength-r)return{position:-1,value:new dt}}else if(n.position>this._start+n.value._buffer.byteLength+r)return{position:-1,value:new dt};return this.start=n.position,n}},{key:"findAllSequences",value:function(e){var t=this.backward?this.start-this.length:this.start;return this.stream.findAllSequences(e,t,this.length)}},{key:"findPairedPatterns",value:function(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null;(null==r||r>this.length)&&(r=this.length);var n=this.backward?this.start-this.length:this.start,a=this.stream.findPairedPatterns(e,t,n,this.length);if(a.length)if(this.backward){if(a[0].right<this.start-t.buffer.byteLength-r)return[]}else if(a[0].left>this.start+e.buffer.byteLength+r)return[];return a}},{key:"findPairedArrays",value:function(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null;(null==r||r>this.length)&&(r=this.length);var n=this.backward?this.start-this.length:this.start,a=this.stream.findPairedArrays(e,t,n,this.length);if(a.length)if(this.backward){if(a[0].right.position<this.start-t[a[0].right.id].buffer.byteLength-r)return[]}else if(a[0].left.position>this.start+e[a[0].left.id].buffer.byteLength+r)return[];return a}},{key:"replacePattern",value:function(e,t){var r=this.backward?this.start-this.length:this.start;return this.stream.replacePattern(e,t,r,this.length)}},{key:"skipPatterns",value:function(e){var t=this.stream.skipPatterns(e,this.start,this.length,this.backward);return this.start=t,t}},{key:"skipNotPatterns",value:function(e){var t=this.stream.skipNotPatterns(e,this.start,this.length,this.backward);return-1==t?-1:(this.start=t,t)}},{key:"append",value:function(e){this._start+e._buffer.byteLength>this._stream._buffer.byteLength&&(e._buffer.byteLength>this.appendBlock&&(this.appendBlock=e._buffer.byteLength+1e3),this._stream.realloc(this._stream._buffer.byteLength+this.appendBlock)),this._stream._view.set(e._view,this._start),this._length+=2*e._buffer.byteLength,this.start=this._start+e._buffer.byteLength,this.prevLength-=2*e._buffer.byteLength}},{key:"appendView",value:function(e){this._start+e.length>this._stream._buffer.byteLength&&(e.length>this.appendBlock&&(this.appendBlock=e.length+1e3),this._stream.realloc(this._stream._buffer.byteLength+this.appendBlock)),this._stream._view.set(e,this._start),this._length+=2*e.length,this.start=this._start+e.length,this.prevLength-=2*e.length}},{key:"appendChar",value:function(e){this._start+1>this._stream._buffer.byteLength&&(1>this.appendBlock&&(this.appendBlock=1e3),this._stream.realloc(this._stream._buffer.byteLength+this.appendBlock)),this._stream._view[this._start]=e,this._length+=2,this.start=this._start+1,this.prevLength-=2}},{key:"appendUint16",value:function(e){this._start+2>this._stream._buffer.byteLength&&(2>this.appendBlock&&(this.appendBlock=1e3),this._stream.realloc(this._stream._buffer.byteLength+this.appendBlock));var t=new Uint16Array([e]),r=new Uint8Array(t.buffer);this._stream._view[this._start]=r[1],this._stream._view[this._start+1]=r[0],this._length+=4,this.start=this._start+2,this.prevLength-=4}},{key:"appendUint24",value:function(e){this._start+3>this._stream._buffer.byteLength&&(3>this.appendBlock&&(this.appendBlock=1e3),this._stream.realloc(this._stream._buffer.byteLength+this.appendBlock));var t=new Uint32Array([e]),r=new Uint8Array(t.buffer);this._stream._view[this._start]=r[2],this._stream._view[this._start+1]=r[1],this._stream._view[this._start+2]=r[0],this._length+=6,this.start=this._start+3,this.prevLength-=6}},{key:"appendUint32",value:function(e){this._start+4>this._stream._buffer.byteLength&&(4>this.appendBlock&&(this.appendBlock=1e3),this._stream.realloc(this._stream._buffer.byteLength+this.appendBlock));var t=new Uint32Array([e]),r=new Uint8Array(t.buffer);this._stream._view[this._start]=r[3],this._stream._view[this._start+1]=r[2],this._stream._view[this._start+2]=r[1],this._stream._view[this._start+3]=r[0],this._length+=8,this.start=this._start+4,this.prevLength-=8}},{key:"getBlock",value:function(e){var t,r=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];if(this._length<=0)return[];if(this._length<e&&(e=this._length),this.backward){var n=this._stream._buffer.slice(this._length-e,this._length),a=new Uint8Array(n);t=new Array(e);for(var i=0;i<e;i++)t[e-1-i]=a[i]}else{var s=this._stream._buffer.slice(this._start,this._start+e);t=Array.from(new Uint8Array(s))}return r&&(this.start+=this.backward?-1*e:e),t}},{key:"getUint16",value:function(){var e=!(arguments.length>0&&void 0!==arguments[0])||arguments[0],t=this.getBlock(2,e);if(t.length<2)return 0;var r=new Uint16Array(1),n=new Uint8Array(r.buffer);return n[0]=t[1],n[1]=t[0],r[0]}},{key:"getInt16",value:function(){var e=!(arguments.length>0&&void 0!==arguments[0])||arguments[0],t=this.getBlock(2,e);if(t.length<2)return 0;var r=new Int16Array(1),n=new Uint8Array(r.buffer);return n[0]=t[1],n[1]=t[0],r[0]}},{key:"getUint24",value:function(){var e=!(arguments.length>0&&void 0!==arguments[0])||arguments[0],t=this.getBlock(3,e);if(t.length<3)return 0;for(var r=new Uint32Array(1),n=new Uint8Array(r.buffer),a=3;a>=1;a--)n[3-a]=t[a-1];return r[0]}},{key:"getUint32",value:function(){var e=!(arguments.length>0&&void 0!==arguments[0])||arguments[0],t=this.getBlock(4,e);if(t.length<4)return 0;for(var r=new Uint32Array(1),n=new Uint8Array(r.buffer),a=3;a>=0;a--)n[3-a]=t[a];return r[0]}},{key:"getInt32",value:function(){var e=!(arguments.length>0&&void 0!==arguments[0])||arguments[0],t=this.getBlock(4,e);if(t.length<4)return 0;for(var r=new Int32Array(1),n=new Uint8Array(r.buffer),a=3;a>=0;a--)n[3-a]=t[a];return r[0]}},{key:"stream",set:function(e){this._stream=e,this.prevLength=this._length,this._length=e._buffer.byteLength,this.prevStart=this._start,this._start=0},get:function(){return this._stream}},{key:"length",set:function(e){this.prevLength=this._length,this._length=e},get:function(){return this.appendBlock?this.start:this._length}},{key:"start",set:function(e){e>this.stream.buffer.byteLength||(this.prevStart=this._start,this.prevLength=this._length,this._length-=this.backward?this._start-e:e-this._start,this._start=e)},get:function(){return this._start}},{key:"buffer",get:function(){return this._stream._buffer.slice(0,this._length)}}]),e}(),pt=function(){function e(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};a(this,e),this.version=le(t,"version",e.defaultValues("version")),this.logID=le(t,"logID",e.defaultValues("logID")),this.timestamp=le(t,"timestamp",e.defaultValues("timestamp")),this.extensions=le(t,"extensions",e.defaultValues("extensions")),this.hashAlgorithm=le(t,"hashAlgorithm",e.defaultValues("hashAlgorithm")),this.signatureAlgorithm=le(t,"signatureAlgorithm",e.defaultValues("signatureAlgorithm")),this.signature=le(t,"signature",e.defaultValues("signature")),"schema"in t&&this.fromSchema(t.schema),"stream"in t&&this.fromStream(t.stream)}var t;return s(e,[{key:"fromSchema",value:function(e){if(e instanceof ue.RawData==!1)throw new Error("Object's schema was not verified against input data for SignedCertificateTimestamp");var t=new yt({stream:new dt({buffer:e.data})});this.fromStream(t)}},{key:"fromStream",value:function(e){var t=e.getUint16();if(this.version=e.getBlock(1)[0],0===this.version){this.logID=new Uint8Array(e.getBlock(32)).buffer.slice(0),this.timestamp=new Date(function(e,t){var r=0;if(1===e.length)return e[0];for(var n=e.length-1;n>=0;n--)r+=e[e.length-1-n]*Math.pow(2,t*n);return r}(new Uint8Array(e.getBlock(8)),8));var r=e.getUint16();switch(this.extensions=new Uint8Array(e.getBlock(r)).buffer.slice(0),e.getBlock(1)[0]){case 0:this.hashAlgorithm="none";break;case 1:this.hashAlgorithm="md5";break;case 2:this.hashAlgorithm="sha1";break;case 3:this.hashAlgorithm="sha224";break;case 4:this.hashAlgorithm="sha256";break;case 5:this.hashAlgorithm="sha384";break;case 6:this.hashAlgorithm="sha512";break;default:throw new Error("Object's stream was not correct for SignedCertificateTimestamp")}switch(e.getBlock(1)[0]){case 0:this.signatureAlgorithm="anonymous";break;case 1:this.signatureAlgorithm="rsa";break;case 2:this.signatureAlgorithm="dsa";break;case 3:this.signatureAlgorithm="ecdsa";break;default:throw new Error("Object's stream was not correct for SignedCertificateTimestamp")}var n=e.getUint16(),a=new Uint8Array(e.getBlock(n)).buffer.slice(0),i=ue.fromBER(a);if(-1===i.offset)throw new Error("Object's stream was not correct for SignedCertificateTimestamp");if(this.signature=i.result,t!==47+r+n)throw new Error("Object's stream was not correct for SignedCertificateTimestamp")}}},{key:"toSchema",value:function(){var e=this.toStream();return new ue.RawData({data:e.stream.buffer})}},{key:"toStream",value:function(){var e=new yt;e.appendUint16(47+this.extensions.byteLength+this.signature.valueBeforeDecode.byteLength),e.appendChar(this.version),e.appendView(new Uint8Array(this.logID));var t,r,n=new ArrayBuffer(8),a=new Uint8Array(n),i=he(this.timestamp.valueOf(),8);switch(a.set(new Uint8Array(i),8-i.byteLength),e.appendView(a),e.appendUint16(this.extensions.byteLength),this.extensions.byteLength&&e.appendView(new Uint8Array(this.extensions)),this.hashAlgorithm.toLowerCase()){case"none":t=0;break;case"md5":t=1;break;case"sha1":t=2;break;case"sha224":t=3;break;case"sha256":t=4;break;case"sha384":t=5;break;case"sha512":t=6;break;default:throw new Error("Incorrect data for hashAlgorithm: ".concat(this.hashAlgorithm))}switch(e.appendChar(t),this.signatureAlgorithm.toLowerCase()){case"anonymous":r=0;break;case"rsa":r=1;break;case"dsa":r=2;break;case"ecdsa":r=3;break;default:throw new Error("Incorrect data for signatureAlgorithm: ".concat(this.signatureAlgorithm))}e.appendChar(r);var s=this.signature.toBER(!1);return e.appendUint16(s.byteLength),e.appendView(new Uint8Array(s)),e}},{key:"toJSON",value:function(){return{version:this.version,logID:ce(this.logID),timestamp:this.timestamp,extensions:ce(this.extensions),hashAlgorithm:this.hashAlgorithm,signatureAlgorithm:this.signatureAlgorithm,signature:this.signature.toJSON()}}},{key:"verify",value:(t=n(regeneratorRuntime.mark((function e(t,r){var n,a,i,s,o,u,l,c,h,m,f,v,g=arguments;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:n=g.length>2&&void 0!==g[2]?g[2]:0,a=de(pe(this.logID)),i=null,o=new yt,u=y(t),e.prev=5,u.s();case 7:if((l=u.n()).done){e.next=14;break}if((c=l.value).log_id!==a){e.next=12;break}return i=c.key,e.abrupt("break",14);case 12:e.next=7;break;case 14:e.next=19;break;case 16:e.prev=16,e.t0=e.catch(5),u.e(e.t0);case 19:return e.prev=19,u.f(),e.finish(19);case 22:if(null!==i){e.next=24;break}throw new Error("Public key not found for CT with logId: ".concat(a));case 24:if(-1!==(h=ue.fromBER(be(ye(i)))).offset){e.next=27;break}throw new Error("Incorrect key value for CT Log with logId: ".concat(a));case 27:return s=new Ne({schema:h.result}),o.appendChar(0),o.appendChar(0),m=new ArrayBuffer(8),f=new Uint8Array(m),v=he(this.timestamp.valueOf(),8),f.set(new Uint8Array(v),8-v.byteLength),o.appendView(f),o.appendUint16(n),0===n&&o.appendUint24(r.byteLength),o.appendView(new Uint8Array(r)),o.appendUint16(this.extensions.byteLength),0!==this.extensions.byteLength&&o.appendView(new Uint8Array(this.extensions)),e.abrupt("return",_e().subtle.verifyWithPublicKey(o._stream._buffer.slice(0,o._length),{valueBlock:{valueHex:this.signature.toBER(!1)}},s,{algorithmId:""},"SHA-256"));case 41:case"end":return e.stop()}}),e,this,[[5,16,19,22]])}))),function(e,r){return t.apply(this,arguments)})}],[{key:"defaultValues",value:function(e){switch(e){case"version":return 0;case"logID":case"extensions":return new ArrayBuffer(0);case"timestamp":return new Date(0);case"hashAlgorithm":case"signatureAlgorithm":return"";case"signature":return new ue.Any;default:throw new Error("Invalid member name for SignedCertificateTimestamp class: ".concat(e))}}}]),e}(),bt=function(){function e(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};a(this,e),this.timestamps=le(t,"timestamps",e.defaultValues("timestamps")),"schema"in t&&this.fromSchema(t.schema)}return s(e,[{key:"fromSchema",value:function(e){if(e instanceof ue.OctetString==!1)throw new Error("Object's schema was not verified against input data for SignedCertificateTimestampList");var t=new yt({stream:new dt({buffer:e.valueBlock.valueHex})});if(t.getUint16()!==t.length)throw new Error("Object's schema was not verified against input data for SignedCertificateTimestampList");for(;t.length;)this.timestamps.push(new pt({stream:t}))}},{key:"toSchema",value:function(){var e,t=new yt,r=0,n=[],a=y(this.timestamps);try{for(a.s();!(e=a.n()).done;){var i=e.value.toStream();n.push(i),r+=i.stream.buffer.byteLength}}catch(e){a.e(e)}finally{a.f()}t.appendUint16(r);for(var s=0,o=n;s<o.length;s++){var u=o[s];t.appendView(u.stream.view)}return new ue.OctetString({valueHex:t.stream.buffer.slice(0)})}},{key:"toJSON",value:function(){return{timestamps:Array.from(this.timestamps,(function(e){return e.toJSON()}))}}}],[{key:"defaultValues",value:function(e){switch(e){case"timestamps":return[];default:throw new Error("Invalid member name for SignedCertificateTimestampList class: ".concat(e))}}},{key:"compareWithDefault",value:function(e,t){switch(e){case"timestamps":return 0===t.length;default:throw new Error("Invalid member name for SignedCertificateTimestampList class: ".concat(e))}}},{key:"schema",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=le(e,"names",{});return"optional"in t==!1&&(t.optional=!1),new ue.OctetString({name:t.blockName||"SignedCertificateTimestampList",optional:t.optional})}}]),e}(),kt=function(){function e(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};a(this,e),this.templateID=le(t,"templateID",e.defaultValues("templateID")),"templateMajorVersion"in t&&(this.templateMajorVersion=le(t,"templateMajorVersion",e.defaultValues("templateMajorVersion"))),"templateMinorVersion"in t&&(this.templateMinorVersion=le(t,"templateMinorVersion",e.defaultValues("templateMinorVersion"))),"schema"in t&&this.fromSchema(t.schema)}return s(e,[{key:"fromSchema",value:function(t){we(t,["templateID","templateMajorVersion","templateMinorVersion"]);var r=ue.compareSchema(t,t,e.schema({names:{templateID:"templateID",templateMajorVersion:"templateMajorVersion",templateMinorVersion:"templateMinorVersion"}}));if(!1===r.verified)throw new Error("Object's schema was not verified against input data for CertificateTemplate");this.templateID=r.result.templateID.valueBlock.toString(),"templateMajorVersion"in r.result&&(this.templateMajorVersion=r.result.templateMajorVersion.valueBlock.valueDec),"templateMinorVersion"in r.result&&(this.templateMinorVersion=r.result.templateMinorVersion.valueBlock.valueDec)}},{key:"toSchema",value:function(){var e=[];return e.push(new ue.ObjectIdentifier({value:this.templateID})),"templateMajorVersion"in this&&e.push(new ue.Integer({value:this.templateMajorVersion})),"templateMinorVersion"in this&&e.push(new ue.Integer({value:this.templateMinorVersion})),new ue.Sequence({value:e})}},{key:"toJSON",value:function(){var e={extnID:this.templateID};return"templateMajorVersion"in this&&(e.templateMajorVersion=this.templateMajorVersion),"templateMinorVersion"in this&&(e.templateMinorVersion=this.templateMinorVersion),e}}],[{key:"defaultValues",value:function(e){switch(e){case"templateID":return"";case"templateMajorVersion":case"templateMinorVersion":return 0;default:throw new Error("Invalid member name for CertificateTemplate class: ".concat(e))}}},{key:"schema",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=le(e,"names",{});return new ue.Sequence({name:t.blockName||"",value:[new ue.ObjectIdentifier({name:t.templateID||""}),new ue.Integer({name:t.templateMajorVersion||"",optional:!0}),new ue.Integer({name:t.templateMinorVersion||"",optional:!0})]})}}]),e}(),wt=function(){function e(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};a(this,e),this.certificateIndex=le(t,"certificateIndex",e.defaultValues("certificateIndex")),this.keyIndex=le(t,"keyIndex",e.defaultValues("keyIndex")),"schema"in t&&this.fromSchema(t.schema)}return s(e,[{key:"fromSchema",value:function(e){if(e.constructor.blockName()!==ue.Integer.blockName())throw new Error("Object's schema was not verified against input data for CAVersion");var t=e.valueBlock.valueHex.slice(0),r=new Uint8Array(t);switch(!0){case t.byteLength<4:var n=new ArrayBuffer(4);new Uint8Array(n).set(r,4-t.byteLength),t=n.slice(0);break;case t.byteLength>4:var a=new ArrayBuffer(4);new Uint8Array(a).set(r.slice(0,4)),t=a.slice(0)}var i=t.slice(0,2),s=new Uint8Array(i),o=s[0];s[0]=s[1],s[1]=o;var u=new Uint16Array(i);this.keyIndex=u[0];var l=t.slice(2),c=new Uint8Array(l);o=c[0],c[0]=c[1],c[1]=o;var h=new Uint16Array(l);this.certificateIndex=h[0]}},{key:"toSchema",value:function(){var e=new ArrayBuffer(2);new Uint16Array(e)[0]=this.certificateIndex;var t=new Uint8Array(e),r=t[0];t[0]=t[1],t[1]=r;var n=new ArrayBuffer(2);new Uint16Array(n)[0]=this.keyIndex;var a=new Uint8Array(n);return r=a[0],a[0]=a[1],a[1]=r,new ue.Integer({valueHex:me(n,e)})}},{key:"toJSON",value:function(){return{certificateIndex:this.certificateIndex,keyIndex:this.keyIndex}}}],[{key:"defaultValues",value:function(e){switch(e){case"certificateIndex":case"keyIndex":return 0;default:throw new Error("Invalid member name for CAVersion class: ".concat(e))}}},{key:"schema",value:function(){return new ue.Integer}}]),e}(),St=function(){function e(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};a(this,e),this.id=le(t,"id",e.defaultValues("id")),"type"in t&&(this.type=le(t,"type",e.defaultValues("type"))),"schema"in t&&this.fromSchema(t.schema)}return s(e,[{key:"fromSchema",value:function(t){we(t,["id","type"]);var r=ue.compareSchema(t,t,e.schema({names:{id:"id",type:"type"}}));if(!1===r.verified)throw new Error("Object's schema was not verified against input data for QCStatement");this.id=r.result.id.valueBlock.toString(),"type"in r.result&&(this.type=r.result.type)}},{key:"toSchema",value:function(){var e=[new ue.ObjectIdentifier({value:this.id})];return"type"in this&&e.push(this.type),new ue.Sequence({value:e})}},{key:"toJSON",value:function(){var e={id:this.id};return"type"in this&&(e.type=this.type.toJSON()),e}}],[{key:"defaultValues",value:function(e){switch(e){case"id":return"";case"type":return new ue.Null;default:throw new Error("Invalid member name for QCStatement class: ".concat(e))}}},{key:"compareWithDefault",value:function(e,t){switch(e){case"id":return""===t;case"type":return t instanceof ue.Null;default:throw new Error("Invalid member name for QCStatement class: ".concat(e))}}},{key:"schema",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=le(e,"names",{});return new ue.Sequence({name:t.blockName||"",value:[new ue.ObjectIdentifier({name:t.id||""}),new ue.Any({name:t.type||"",optional:!0})]})}}]),e}(),At=function(){function e(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};a(this,e),this.values=le(t,"values",e.defaultValues("values")),"schema"in t&&this.fromSchema(t.schema)}return s(e,[{key:"fromSchema",value:function(t){we(t,["values"]);var r=ue.compareSchema(t,t,e.schema({names:{values:"values"}}));if(!1===r.verified)throw new Error("Object's schema was not verified against input data for QCStatements");this.values=Array.from(r.result.values,(function(e){return new St({schema:e})}))}},{key:"toSchema",value:function(){return new ue.Sequence({value:Array.from(this.values,(function(e){return e.toSchema()}))})}},{key:"toJSON",value:function(){return{extensions:Array.from(this.values,(function(e){return e.toJSON()}))}}}],[{key:"defaultValues",value:function(e){switch(e){case"values":return[];default:throw new Error("Invalid member name for QCStatements class: ".concat(e))}}},{key:"compareWithDefault",value:function(e,t){switch(e){case"values":return 0===t.length;default:throw new Error("Invalid member name for QCStatements class: ".concat(e))}}},{key:"schema",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=le(e,"names",{});return new ue.Sequence({name:t.blockName||"",value:[new ue.Repeated({name:t.values||"",value:St.schema(t.value||{})})]})}}]),e}(),Ct=function(){function e(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};a(this,e),this.extnID=le(t,"extnID",e.defaultValues("extnID")),this.critical=le(t,"critical",e.defaultValues("critical")),this.extnValue="extnValue"in t?new ue.OctetString({valueHex:t.extnValue}):e.defaultValues("extnValue"),"parsedValue"in t&&(this.parsedValue=le(t,"parsedValue",e.defaultValues("parsedValue"))),"schema"in t&&this.fromSchema(t.schema)}return s(e,[{key:"fromSchema",value:function(t){we(t,["extnID","critical","extnValue"]);var r=ue.compareSchema(t,t,e.schema({names:{extnID:"extnID",critical:"critical",extnValue:"extnValue"}}));if(!1===r.verified)throw new Error("Object's schema was not verified against input data for Extension");if(this.extnID=r.result.extnID.valueBlock.toString(),"critical"in r.result&&(this.critical=r.result.critical.valueBlock.value),this.extnValue=r.result.extnValue,-1!==(r=ue.fromBER(this.extnValue.valueBlock.valueHex)).offset)switch(this.extnID){case"2.5.29.9":try{this.parsedValue=new Ze({schema:r.result})}catch(e){this.parsedValue=new Ze,this.parsedValue.parsingError="Incorrectly formated SubjectDirectoryAttributes"}break;case"2.5.29.14":case"2.5.29.15":this.parsedValue=r.result;break;case"2.5.29.16":try{this.parsedValue=new $e({schema:r.result})}catch(e){this.parsedValue=new $e,this.parsedValue.parsingError="Incorrectly formated PrivateKeyUsagePeriod"}break;case"2.5.29.17":case"2.5.29.18":try{this.parsedValue=new Qe({schema:r.result})}catch(e){this.parsedValue=new Qe,this.parsedValue.parsingError="Incorrectly formated AltName"}break;case"2.5.29.19":try{this.parsedValue=new et({schema:r.result})}catch(e){this.parsedValue=new et,this.parsedValue.parsingError="Incorrectly formated BasicConstraints"}break;case"2.5.29.20":case"2.5.29.27":case"2.5.29.21":case"2.5.29.24":this.parsedValue=r.result;break;case"2.5.29.28":try{this.parsedValue=new tt({schema:r.result})}catch(e){this.parsedValue=new tt,this.parsedValue.parsingError="Incorrectly formated IssuingDistributionPoint"}break;case"2.5.29.29":try{this.parsedValue=new rt({schema:r.result})}catch(e){this.parsedValue=new rt,this.parsedValue.parsingError="Incorrectly formated GeneralNames"}break;case"2.5.29.30":try{this.parsedValue=new at({schema:r.result})}catch(e){this.parsedValue=new at,this.parsedValue.parsingError="Incorrectly formated NameConstraints"}break;case"2.5.29.31":case"2.5.29.46":try{this.parsedValue=new st({schema:r.result})}catch(e){this.parsedValue=new st,this.parsedValue.parsingError="Incorrectly formated CRLDistributionPoints"}break;case"2.5.29.32":case"1.3.6.1.4.1.311.21.10":try{this.parsedValue=new lt({schema:r.result})}catch(e){this.parsedValue=new lt,this.parsedValue.parsingError="Incorrectly formated CertificatePolicies"}break;case"2.5.29.33":try{this.parsedValue=new ht({schema:r.result})}catch(e){this.parsedValue=new ht,this.parsedValue.parsingError="Incorrectly formated CertificatePolicies"}break;case"2.5.29.35":try{this.parsedValue=new mt({schema:r.result})}catch(e){this.parsedValue=new mt,this.parsedValue.parsingError="Incorrectly formated AuthorityKeyIdentifier"}break;case"2.5.29.36":try{this.parsedValue=new ft({schema:r.result})}catch(e){this.parsedValue=new ft,this.parsedValue.parsingError="Incorrectly formated PolicyConstraints"}break;case"2.5.29.37":try{this.parsedValue=new vt({schema:r.result})}catch(e){this.parsedValue=new vt,this.parsedValue.parsingError="Incorrectly formated ExtKeyUsage"}break;case"2.5.29.54":this.parsedValue=r.result;break;case"1.3.6.1.5.5.7.1.1":case"1.3.6.1.5.5.7.1.11":try{this.parsedValue=new gt({schema:r.result})}catch(e){this.parsedValue=new gt,this.parsedValue.parsingError="Incorrectly formated InfoAccess"}break;case"1.3.6.1.4.1.11129.2.4.2":try{this.parsedValue=new bt({schema:r.result})}catch(e){this.parsedValue=new bt,this.parsedValue.parsingError="Incorrectly formated SignedCertificateTimestampList"}break;case"1.3.6.1.4.1.311.20.2":case"1.3.6.1.4.1.311.21.2":this.parsedValue=r.result;break;case"1.3.6.1.4.1.311.21.7":try{this.parsedValue=new kt({schema:r.result})}catch(e){this.parsedValue=new kt,this.parsedValue.parsingError="Incorrectly formated CertificateTemplate"}break;case"1.3.6.1.4.1.311.21.1":try{this.parsedValue=new wt({schema:r.result})}catch(e){this.parsedValue=new wt,this.parsedValue.parsingError="Incorrectly formated CAVersion"}break;case"1.3.6.1.5.5.7.1.3":try{this.parsedValue=new At({schema:r.result})}catch(e){this.parsedValue=new At,this.parsedValue.parsingError="Incorrectly formated QCStatements"}}}},{key:"toSchema",value:function(){var t=[];return t.push(new ue.ObjectIdentifier({value:this.extnID})),this.critical!==e.defaultValues("critical")&&t.push(new ue.Boolean({value:this.critical})),t.push(this.extnValue),new ue.Sequence({value:t})}},{key:"toJSON",value:function(){var t={extnID:this.extnID,extnValue:this.extnValue.toJSON()};return this.critical!==e.defaultValues("critical")&&(t.critical=this.critical),"parsedValue"in this&&"toJSON"in this.parsedValue&&(t.parsedValue=this.parsedValue.toJSON()),t}}],[{key:"defaultValues",value:function(e){switch(e){case"extnID":return"";case"critical":return!1;case"extnValue":return new ue.OctetString;case"parsedValue":return{};default:throw new Error("Invalid member name for Extension class: ".concat(e))}}},{key:"schema",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=le(e,"names",{});return new ue.Sequence({name:t.blockName||"",value:[new ue.ObjectIdentifier({name:t.extnID||""}),new ue.Boolean({name:t.critical||"",optional:!0}),new ue.OctetString({name:t.extnValue||""})]})}}]),e}(),Nt=function(){function e(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};a(this,e),this.extensions=le(t,"extensions",e.defaultValues("extensions")),"schema"in t&&this.fromSchema(t.schema)}return s(e,[{key:"fromSchema",value:function(t){we(t,["extensions"]);var r=ue.compareSchema(t,t,e.schema({names:{extensions:"extensions"}}));if(!1===r.verified)throw new Error("Object's schema was not verified against input data for Extensions");this.extensions=Array.from(r.result.extensions,(function(e){return new Ct({schema:e})}))}},{key:"toSchema",value:function(){return new ue.Sequence({value:Array.from(this.extensions,(function(e){return e.toSchema()}))})}},{key:"toJSON",value:function(){return{extensions:Array.from(this.extensions,(function(e){return e.toJSON()}))}}}],[{key:"defaultValues",value:function(e){switch(e){case"extensions":return[];default:throw new Error("Invalid member name for Extensions class: ".concat(e))}}},{key:"schema",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=arguments.length>1&&void 0!==arguments[1]&&arguments[1],r=le(e,"names",{});return new ue.Sequence({optional:t,name:r.blockName||"",value:[new ue.Repeated({name:r.extensions||"",value:Ct.schema(r.extension||{})})]})}}]),e}();function Bt(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=le(e,"names",{});return new ue.Sequence({name:t.blockName||"tbsCertificate",value:[new ue.Constructed({optional:!0,idBlock:{tagClass:3,tagNumber:0},value:[new ue.Integer({name:t.tbsCertificateVersion||"tbsCertificate.version"})]}),new ue.Integer({name:t.tbsCertificateSerialNumber||"tbsCertificate.serialNumber"}),Se.schema(t.signature||{names:{blockName:"tbsCertificate.signature"}}),Ge.schema(t.issuer||{names:{blockName:"tbsCertificate.issuer"}}),new ue.Sequence({name:t.tbsCertificateValidity||"tbsCertificate.validity",value:[Ye.schema(t.notBefore||{names:{utcTimeName:"tbsCertificate.notBefore",generalTimeName:"tbsCertificate.notBefore"}}),Ye.schema(t.notAfter||{names:{utcTimeName:"tbsCertificate.notAfter",generalTimeName:"tbsCertificate.notAfter"}})]}),Ge.schema(t.subject||{names:{blockName:"tbsCertificate.subject"}}),Ne.schema(t.subjectPublicKeyInfo||{names:{blockName:"tbsCertificate.subjectPublicKeyInfo"}}),new ue.Primitive({name:t.tbsCertificateIssuerUniqueID||"tbsCertificate.issuerUniqueID",optional:!0,idBlock:{tagClass:3,tagNumber:1}}),new ue.Primitive({name:t.tbsCertificateSubjectUniqueID||"tbsCertificate.subjectUniqueID",optional:!0,idBlock:{tagClass:3,tagNumber:2}}),new ue.Constructed({optional:!0,idBlock:{tagClass:3,tagNumber:3},value:[Nt.schema(t.extensions||{names:{blockName:"tbsCertificate.extensions"}})]})]})}var It=function(){function e(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};a(this,e),this.tbs=le(t,"tbs",e.defaultValues("tbs")),this.version=le(t,"version",e.defaultValues("version")),this.serialNumber=le(t,"serialNumber",e.defaultValues("serialNumber")),this.signature=le(t,"signature",e.defaultValues("signature")),this.issuer=le(t,"issuer",e.defaultValues("issuer")),this.notBefore=le(t,"notBefore",e.defaultValues("notBefore")),this.notAfter=le(t,"notAfter",e.defaultValues("notAfter")),this.subject=le(t,"subject",e.defaultValues("subject")),this.subjectPublicKeyInfo=le(t,"subjectPublicKeyInfo",e.defaultValues("subjectPublicKeyInfo")),"issuerUniqueID"in t&&(this.issuerUniqueID=le(t,"issuerUniqueID",e.defaultValues("issuerUniqueID"))),"subjectUniqueID"in t&&(this.subjectUniqueID=le(t,"subjectUniqueID",e.defaultValues("subjectUniqueID"))),"extensions"in t&&(this.extensions=le(t,"extensions",e.defaultValues("extensions"))),this.signatureAlgorithm=le(t,"signatureAlgorithm",e.defaultValues("signatureAlgorithm")),this.signatureValue=le(t,"signatureValue",e.defaultValues("signatureValue")),"schema"in t&&this.fromSchema(t.schema)}return s(e,[{key:"fromSchema",value:function(t){we(t,["tbsCertificate","tbsCertificate.extensions","tbsCertificate.version","tbsCertificate.serialNumber","tbsCertificate.signature","tbsCertificate.issuer","tbsCertificate.notBefore","tbsCertificate.notAfter","tbsCertificate.subject","tbsCertificate.subjectPublicKeyInfo","tbsCertificate.issuerUniqueID","tbsCertificate.subjectUniqueID","signatureAlgorithm","signatureValue"]);var r=ue.compareSchema(t,t,e.schema({names:{tbsCertificate:{names:{extensions:{names:{extensions:"tbsCertificate.extensions"}}}}}}));if(!1===r.verified)throw new Error("Object's schema was not verified against input data for Certificate");this.tbs=r.result.tbsCertificate.valueBeforeDecode,"tbsCertificate.version"in r.result&&(this.version=r.result["tbsCertificate.version"].valueBlock.valueDec),this.serialNumber=r.result["tbsCertificate.serialNumber"],this.signature=new Se({schema:r.result["tbsCertificate.signature"]}),this.issuer=new Ge({schema:r.result["tbsCertificate.issuer"]}),this.notBefore=new Ye({schema:r.result["tbsCertificate.notBefore"]}),this.notAfter=new Ye({schema:r.result["tbsCertificate.notAfter"]}),this.subject=new Ge({schema:r.result["tbsCertificate.subject"]}),this.subjectPublicKeyInfo=new Ne({schema:r.result["tbsCertificate.subjectPublicKeyInfo"]}),"tbsCertificate.issuerUniqueID"in r.result&&(this.issuerUniqueID=r.result["tbsCertificate.issuerUniqueID"].valueBlock.valueHex),"tbsCertificate.subjectUniqueID"in r.result&&(this.subjectUniqueID=r.result["tbsCertificate.subjectUniqueID"].valueBlock.valueHex),"tbsCertificate.extensions"in r.result&&(this.extensions=Array.from(r.result["tbsCertificate.extensions"],(function(e){return new Ct({schema:e})}))),this.signatureAlgorithm=new Se({schema:r.result.signatureAlgorithm}),this.signatureValue=r.result.signatureValue}},{key:"encodeTBS",value:function(){var t=[];return"version"in this&&this.version!==e.defaultValues("version")&&t.push(new ue.Constructed({optional:!0,idBlock:{tagClass:3,tagNumber:0},value:[new ue.Integer({value:this.version})]})),t.push(this.serialNumber),t.push(this.signature.toSchema()),t.push(this.issuer.toSchema()),t.push(new ue.Sequence({value:[this.notBefore.toSchema(),this.notAfter.toSchema()]})),t.push(this.subject.toSchema()),t.push(this.subjectPublicKeyInfo.toSchema()),"issuerUniqueID"in this&&t.push(new ue.Primitive({optional:!0,idBlock:{tagClass:3,tagNumber:1},valueHex:this.issuerUniqueID})),"subjectUniqueID"in this&&t.push(new ue.Primitive({optional:!0,idBlock:{tagClass:3,tagNumber:2},valueHex:this.subjectUniqueID})),"extensions"in this&&t.push(new ue.Constructed({optional:!0,idBlock:{tagClass:3,tagNumber:3},value:[new ue.Sequence({value:Array.from(this.extensions,(function(e){return e.toSchema()}))})]})),new ue.Sequence({value:t})}},{key:"toSchema",value:function(){var t=arguments.length>0&&void 0!==arguments[0]&&arguments[0],r={};if(!1===t){if(0===this.tbs.length)return e.schema().value[0];r=ue.fromBER(this.tbs).result}else r=this.encodeTBS();return new ue.Sequence({value:[r,this.signatureAlgorithm.toSchema(),this.signatureValue]})}},{key:"toJSON",value:function(){var t={tbs:ce(this.tbs,0,this.tbs.byteLength),serialNumber:this.serialNumber.toJSON(),signature:this.signature.toJSON(),issuer:this.issuer.toJSON(),notBefore:this.notBefore.toJSON(),notAfter:this.notAfter.toJSON(),subject:this.subject.toJSON(),subjectPublicKeyInfo:this.subjectPublicKeyInfo.toJSON(),signatureAlgorithm:this.signatureAlgorithm.toJSON(),signatureValue:this.signatureValue.toJSON()};return"version"in this&&this.version!==e.defaultValues("version")&&(t.version=this.version),"issuerUniqueID"in this&&(t.issuerUniqueID=ce(this.issuerUniqueID,0,this.issuerUniqueID.byteLength)),"subjectUniqueID"in this&&(t.subjectUniqueID=ce(this.subjectUniqueID,0,this.subjectUniqueID.byteLength)),"extensions"in this&&(t.extensions=Array.from(this.extensions,(function(e){return e.toJSON()}))),t}},{key:"getPublicKey",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null;return _e().subtle.getPublicKey(this.subjectPublicKeyInfo,this.signatureAlgorithm,e)}},{key:"getKeyHash",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"SHA-1",t=je();return void 0===t?Promise.reject("Unable to create WebCrypto object"):t.digest({name:e},new Uint8Array(this.subjectPublicKeyInfo.subjectPublicKey.valueBlock.valueHex))}},{key:"sign",value:function(e){var t=this,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"SHA-1";if(void 0===e)return Promise.reject("Need to provide a private key for signing");var n,a=Promise.resolve(),i=_e();return a=(a=(a=(a=(a=a.then((function(){return i.subtle.getSignatureParameters(e,r)}))).then((function(e){n=e.parameters,t.signature=e.signatureAlgorithm,t.signatureAlgorithm=e.signatureAlgorithm}))).then((function(){t.tbs=t.encodeTBS().toBER(!1)}))).then((function(){return i.subtle.signWithPrivateKey(t.tbs,e,n)}))).then((function(e){t.signatureValue=new ue.BitString({valueHex:e})}))}},{key:"verify",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null,t={};return null!==e?t=e.subjectPublicKeyInfo:this.issuer.isEqual(this.subject)&&(t=this.subjectPublicKeyInfo),t instanceof Ne==!1?Promise.reject("Please provide issuer certificate as a parameter"):_e().subtle.verifyWithPublicKey(this.tbs,this.signatureValue,t,this.signatureAlgorithm)}}],[{key:"defaultValues",value:function(e){switch(e){case"tbs":return new ArrayBuffer(0);case"version":return 0;case"serialNumber":return new ue.Integer;case"signature":return new Se;case"issuer":return new Ge;case"notBefore":case"notAfter":return new Ye;case"subject":return new Ge;case"subjectPublicKeyInfo":return new Ne;case"issuerUniqueID":case"subjectUniqueID":return new ArrayBuffer(0);case"extensions":return[];case"signatureAlgorithm":return new Se;case"signatureValue":return new ue.BitString;default:throw new Error("Invalid member name for Certificate class: ".concat(e))}}},{key:"schema",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=le(e,"names",{});return new ue.Sequence({name:t.blockName||"",value:[Bt(t.tbsCertificate),Se.schema(t.signatureAlgorithm||{names:{blockName:"signatureAlgorithm"}}),new ue.BitString({name:t.signatureValue||"signatureValue"})]})}}]),e}(),Pt=null,Et=function(){function e(){a(this,e)}return s(e,null,[{key:"setEngine",value:function(e,t){Pt={getRandomValues:t.getRandomValues.bind(t),subtle:t.subtle,name:e},Te(e,new He({name:e,crypto:t,subtle:t.subtle}),new He({name:e,crypto:t,subtle:t.subtle}))}},{key:"isNodePlugin",value:function(){return"undefined"==typeof self&&"undefined"==typeof window}},{key:"crypto",get:function(){if(!Pt)throw new R(x.CRYPTOGRAPHIC_NO_MODULE);return Pt}}]),e}();Et.isNodePlugin()||Et.setEngine("W3 WebCrypto module",self.crypto);var xt,Rt=function(){function e(){a(this,e)}return s(e,[{key:"getAlgorithmName",value:function(){return this.namespaceURI}}]),e}(),Lt=function(e){o(i,e);var t,r=h(i);function i(){return a(this,i),r.apply(this,arguments)}return s(i,[{key:"Digest",value:(t=n(regeneratorRuntime.mark((function e(t){var r,n,a;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return"string"==typeof t?r=U.FromString(t,"utf8"):ArrayBuffer.isView(t)?r=new Uint8Array(t.buffer):t instanceof ArrayBuffer?r=new Uint8Array(t):(n=(new XMLSerializer).serializeToString(t),r=U.FromString(n,"utf8")),e.next=3,Et.crypto.subtle.digest(this.algorithm,r);case 3:return a=e.sent,e.abrupt("return",new Uint8Array(a));case 5:case"end":return e.stop()}}),e,this)}))),function(e){return t.apply(this,arguments)})}]),i}(Rt),Ot=function(e){o(u,e);var t,r,i=h(u);function u(){return a(this,u),i.apply(this,arguments)}return s(u,[{key:"Sign",value:(r=n(regeneratorRuntime.mark((function e(t,r,n){var a;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return a=U.FromString(t,"utf8"),e.abrupt("return",Et.crypto.subtle.sign(n,r,a));case 2:case"end":return e.stop()}}),e)}))),function(e,t,n){return r.apply(this,arguments)})},{key:"Verify",value:(t=n(regeneratorRuntime.mark((function e(t,r,n,a){var i;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return i=U.FromString(t,"utf8"),e.abrupt("return",Et.crypto.subtle.verify(a||this.algorithm,r,n,i));case 2:case"end":return e.stop()}}),e,this)}))),function(e,r,n,a){return t.apply(this,arguments)})}]),u}(Rt),Ut="SHA-1",Dt="SHA-256",Ht="SHA-384",Vt="SHA-512",Tt="http://www.w3.org/2000/09/xmldsig#sha1",_t="http://www.w3.org/2001/04/xmlenc#sha256",jt="http://www.w3.org/2001/04/xmldsig-more#sha384",Kt="http://www.w3.org/2001/04/xmlenc#sha512",Mt=function(e){o(r,e);var t=h(r);function r(){var e;return a(this,r),(e=t.apply(this,arguments)).algorithm={name:Ut},e.namespaceURI=Tt,e}return r}(Lt),Xt=function(e){o(r,e);var t=h(r);function r(){var e;return a(this,r),(e=t.apply(this,arguments)).algorithm={name:Dt},e.namespaceURI=_t,e}return r}(Lt),Gt=function(e){o(r,e);var t=h(r);function r(){var e;return a(this,r),(e=t.apply(this,arguments)).algorithm={name:Ht},e.namespaceURI=jt,e}return r}(Lt),qt=function(e){o(r,e);var t=h(r);function r(){var e;return a(this,r),(e=t.apply(this,arguments)).algorithm={name:Vt},e.namespaceURI=Kt,e}return r}(Lt),Ft="ECDSA",Jt="http://www.w3.org/2001/04/xmldsig-more#ecdsa-sha1",Wt="http://www.w3.org/2001/04/xmldsig-more#ecdsa-sha256",zt="http://www.w3.org/2001/04/xmldsig-more#ecdsa-sha384",Qt="http://www.w3.org/2001/04/xmldsig-more#ecdsa-sha512",Yt=function(e){o(r,e);var t=h(r);function r(){var e;return a(this,r),(e=t.apply(this,arguments)).algorithm={name:Ft,hash:{name:Ut}},e.namespaceURI=Jt,e}return r}(Ot),Zt=function(e){o(r,e);var t=h(r);function r(){var e;return a(this,r),(e=t.apply(this,arguments)).algorithm={name:Ft,hash:{name:Dt}},e.namespaceURI=Wt,e}return r}(Ot),$t=function(e){o(r,e);var t=h(r);function r(){var e;return a(this,r),(e=t.apply(this,arguments)).algorithm={name:Ft,hash:{name:Ht}},e.namespaceURI=zt,e}return r}(Ot),er=function(e){o(r,e);var t=h(r);function r(){var e;return a(this,r),(e=t.apply(this,arguments)).algorithm={name:Ft,hash:{name:Vt}},e.namespaceURI=Qt,e}return r}(Ot),tr="HMAC",rr="http://www.w3.org/2000/09/xmldsig#hmac-sha1",nr="http://www.w3.org/2001/04/xmldsig-more#hmac-sha256",ar="http://www.w3.org/2001/04/xmldsig-more#hmac-sha384",ir="http://www.w3.org/2001/04/xmldsig-more#hmac-sha512",sr=function(e){o(r,e);var t=h(r);function r(){var e;return a(this,r),(e=t.apply(this,arguments)).algorithm={name:tr,hash:{name:Ut}},e.namespaceURI=rr,e}return r}(Ot),or=function(e){o(r,e);var t=h(r);function r(){var e;return a(this,r),(e=t.apply(this,arguments)).algorithm={name:tr,hash:{name:Dt}},e.namespaceURI=nr,e}return r}(Ot),ur=function(e){o(r,e);var t=h(r);function r(){var e;return a(this,r),(e=t.apply(this,arguments)).algorithm={name:tr,hash:{name:Ht}},e.namespaceURI=ar,e}return r}(Ot),lr=function(e){o(r,e);var t=h(r);function r(){var e;return a(this,r),(e=t.apply(this,arguments)).algorithm={name:tr,hash:{name:Vt}},e.namespaceURI=ir,e}return r}(Ot),cr="RSASSA-PKCS1-v1_5",hr="http://www.w3.org/2000/09/xmldsig#rsa-sha1",mr="http://www.w3.org/2001/04/xmldsig-more#rsa-sha256",fr="http://www.w3.org/2001/04/xmldsig-more#rsa-sha384",vr="http://www.w3.org/2001/04/xmldsig-more#rsa-sha512",gr=function(e){o(r,e);var t=h(r);function r(){var e;return a(this,r),(e=t.apply(this,arguments)).algorithm={name:cr,hash:{name:Ut}},e.namespaceURI=hr,e}return r}(Ot),dr=function(e){o(r,e);var t=h(r);function r(){var e;return a(this,r),(e=t.apply(this,arguments)).algorithm={name:cr,hash:{name:Dt}},e.namespaceURI=mr,e}return r}(Ot),yr=function(e){o(r,e);var t=h(r);function r(){var e;return a(this,r),(e=t.apply(this,arguments)).algorithm={name:cr,hash:{name:Ht}},e.namespaceURI=fr,e}return r}(Ot),pr=function(e){o(r,e);var t=h(r);function r(){var e;return a(this,r),(e=t.apply(this,arguments)).algorithm={name:cr,hash:{name:Vt}},e.namespaceURI=vr,e}return r}(Ot),br="RSA-PSS",kr="http://www.w3.org/2007/05/xmldsig-more#rsa-pss",wr=function(e){o(r,e);var t=h(r);function r(e){var n;return a(this,r),(n=t.call(this)).algorithm={name:br,hash:{name:Ut}},n.namespaceURI=kr,e&&(n.algorithm.saltLength=e),n}return r}(Ot),Sr=function(e){o(r,e);var t=h(r);function r(e){var n;return a(this,r),(n=t.call(this,e)).algorithm.hash.name=Ut,n}return r}(wr),Ar=function(e){o(r,e);var t=h(r);function r(e){var n;return a(this,r),(n=t.call(this,e)).algorithm.hash.name=Dt,n}return r}(wr),Cr=function(e){o(r,e);var t=h(r);function r(e){var n;return a(this,r),(n=t.call(this,e)).algorithm.hash.name=Ht,n}return r}(wr),Nr=function(e){o(r,e);var t=h(r);function r(e){var n;return a(this,r),(n=t.call(this,e)).algorithm.hash.name=Vt,n}return r}(wr),Br="http://www.w3.org/2007/05/xmldsig-more#sha1-rsa-MGF1",Ir="http://www.w3.org/2007/05/xmldsig-more#sha256-rsa-MGF1",Pr="http://www.w3.org/2007/05/xmldsig-more#sha384-rsa-MGF1",Er="http://www.w3.org/2007/05/xmldsig-more#sha512-rsa-MGF1",xr=function(e){o(r,e);var t=h(r);function r(){var e;return a(this,r),(e=t.call(this)).algorithm={name:br,hash:{name:Ut}},e.namespaceURI=Br,e}return r}(Ot),Rr=function(e){o(r,e);var t=h(r);function r(){var e;return a(this,r),(e=t.call(this)).algorithm.hash.name=Ut,e.algorithm.saltLength=20,e}return r}(xr),Lr=function(e){o(r,e);var t=h(r);function r(){var e;return a(this,r),(e=t.call(this)).algorithm.hash.name=Dt,e.algorithm.saltLength=32,e}return r}(xr),Or=function(e){o(r,e);var t=h(r);function r(){var e;return a(this,r),(e=t.call(this)).algorithm.hash.name=Ht,e.algorithm.saltLength=48,e}return r}(xr),Ur=function(e){o(r,e);var t=h(r);function r(){var e;return a(this,r),(e=t.call(this)).algorithm.hash.name=Vt,e.algorithm.saltLength=64,e}return r}(xr);(xt=e.XmlCanonicalizerState||(e.XmlCanonicalizerState={}))[xt.BeforeDocElement=0]="BeforeDocElement",xt[xt.InsideDocElement=1]="InsideDocElement",xt[xt.AfterDocElement=2]="AfterDocElement";var Dr=function(){function t(r,n){var i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:new $;a(this,t),this.propagatedNamespaces=new $,this.result=[],this.visibleNamespaces=new $,this.inclusiveNamespacesPrefixList=[],this.state=e.XmlCanonicalizerState.BeforeDocElement,this.withComments=r,this.exclusive=n,this.propagatedNamespaces=i}return s(t,[{key:"Canonicalize",value:function(e){if(!e)throw new R(x.CRYPTOGRAPHIC,"Parameter 1 is not Node");return this.WriteNode(e),this.result.join("")}},{key:"WriteNode",value:function(t){switch(t.nodeType){case O.Document:case O.DocumentFragment:this.WriteDocumentNode(t);break;case O.Element:this.WriteElementNode(t);break;case O.CDATA:case O.SignificantWhitespace:case O.Text:J(t.parentNode)||this.WriteTextNode(t);break;case O.Whitespace:this.state===e.XmlCanonicalizerState.InsideDocElement&&this.WriteTextNode(t);break;case O.Comment:this.WriteCommentNode(t);break;case O.ProcessingInstruction:this.WriteProcessingInstructionNode(t);break;case O.EntityReference:for(var r=0;r<t.childNodes.length;r++)this.WriteNode(t.childNodes[r]);break;case O.Attribute:case O.EndElement:case O.EndEntity:throw new R(x.CRYPTOGRAPHIC,"Attribute node is impossible here");case O.DocumentType:case O.Entity:case O.Notation:case O.XmlDeclaration:}}},{key:"WriteDocumentNode",value:function(t){this.state=e.XmlCanonicalizerState.BeforeDocElement;for(var r=t.firstChild;null!=r;r=r.nextSibling)this.WriteNode(r)}},{key:"WriteCommentNode",value:function(t){this.withComments&&(this.state===e.XmlCanonicalizerState.AfterDocElement?this.result.push(String.fromCharCode(10)+"\x3c!--"):this.result.push("\x3c!--"),this.result.push(this.NormalizeString(t.nodeValue,O.Comment)),this.state===e.XmlCanonicalizerState.BeforeDocElement?this.result.push("--\x3e"+String.fromCharCode(10)):this.result.push("--\x3e"))}},{key:"WriteTextNode",value:function(e){this.result.push(this.NormalizeString(e.nodeValue,e.nodeType))}},{key:"WriteProcessingInstructionNode",value:function(t){var r=t.nodeName||t.tagName;"xml"!==r&&(this.state===e.XmlCanonicalizerState.AfterDocElement?this.result.push("\n<?"):this.result.push("<?"),this.result.push(r),t.nodeValue&&(this.result.push(" "),this.result.push(this.NormalizeString(t.nodeValue,O.ProcessingInstruction))),this.state===e.XmlCanonicalizerState.BeforeDocElement?this.result.push("?>\n"):this.result.push("?>"))}},{key:"WriteElementNode",value:function(t){var r=this.state;this.state===e.XmlCanonicalizerState.BeforeDocElement&&(this.state=e.XmlCanonicalizerState.InsideDocElement),this.result.push("<"),this.result.push(t.nodeName);var n=this.WriteNamespacesAxis(t);this.WriteAttributesAxis(t),this.result.push(">");for(var a=t.firstChild;null!=a;a=a.nextSibling)this.WriteNode(a);for(this.result.push("</"),this.result.push(t.nodeName),this.result.push(">"),r===e.XmlCanonicalizerState.BeforeDocElement&&(this.state=e.XmlCanonicalizerState.AfterDocElement);n--;)this.visibleNamespaces.Pop()}},{key:"WriteNamespacesAxis",value:function(e){for(var t=this,r=[],n=0,a=0;a<e.attributes.length;a++){var i=e.attributes[a];if(_r(i)){if("xmlns"===i.localName&&!i.prefix&&!i.nodeValue){var s={prefix:i.prefix,namespace:i.nodeValue};r.push(s),this.visibleNamespaces.Add(s),n++}var o,u=null;(o=/xmlns:([\w\.-]+)/.exec(i.nodeName))&&(u=o[1]);var l=!0;if(this.exclusive&&!this.IsNamespaceInclusive(e,u)){var c=Tr(e,u);if(c>1)l=!1;else if(0===c)continue}if(!this.IsNamespaceRendered(u,i.nodeValue)&&l){var h={prefix:u,namespace:i.nodeValue};r.push(h),this.visibleNamespaces.Add(h),n++}}else if(i.prefix&&!this.IsNamespaceRendered(i.prefix,i.namespaceURI)){var m={prefix:i.prefix,namespace:i.namespaceURI};r.push(m),this.visibleNamespaces.Add(m),n++}}if(!this.IsNamespaceRendered(e.prefix,e.namespaceURI)&&"http://www.w3.org/2000/xmlns/"!==e.namespaceURI){var f={prefix:e.prefix,namespace:e.namespaceURI};r.push(f),this.visibleNamespaces.Add(f),n++}r.sort(Hr);var v=null;return r.forEach((function(e){e.prefix!==v&&(v=e.prefix,t.result.push(" xmlns"),e.prefix&&t.result.push(":"+e.prefix),t.result.push('="'),t.result.push(e.namespace),t.result.push('"'))})),n}},{key:"WriteAttributesAxis",value:function(e){for(var t=this,r=[],n=0;n<e.attributes.length;n++){var a=e.attributes[n];_r(a)||r.push(a)}r.sort(Vr),r.forEach((function(e){null!=e&&(t.result.push(" "),t.result.push(e.nodeName),t.result.push('="'),t.result.push(t.NormalizeString(e.nodeValue,O.Attribute)),t.result.push('"'))}))}},{key:"NormalizeString",value:function(e,t){var r=[];if(e)for(var n=0;n<e.length;n++){var a=e[n];"<"!==a||t!==O.Attribute&&!this.IsTextNode(t)?">"===a&&this.IsTextNode(t)?r.push("&gt;"):"&"!==a||t!==O.Attribute&&!this.IsTextNode(t)?'"'===a&&t===O.Attribute?r.push("&quot;"):"\t"===a&&t===O.Attribute?r.push("&#x9;"):"\n"===a&&t===O.Attribute?r.push("&#xA;"):"\r"===a?r.push("&#xD;"):r.push(a):r.push("&amp;"):r.push("&lt;")}return r.join("")}},{key:"IsTextNode",value:function(e){switch(e){case O.Text:case O.CDATA:case O.SignificantWhitespace:case O.Whitespace:return!0}return!1}},{key:"IsNamespaceInclusive",value:function(e,t){var r=t||null;return e.prefix!==r&&-1!==this.inclusiveNamespacesPrefixList.indexOf(r||"")}},{key:"IsNamespaceRendered",value:function(e,t){if(t=t||"",!(e=e||"")&&!t)return!0;if("xml"===e&&"http://www.w3.org/XML/1998/namespace"===t)return!0;var r=this.visibleNamespaces.GetPrefix(e);return!!r&&r.namespace===t}},{key:"InclusiveNamespacesPrefixList",get:function(){return this.inclusiveNamespacesPrefixList.join(" ")},set:function(e){this.inclusiveNamespacesPrefixList=e.split(" ")}}]),t}();function Hr(e,t){return e==t?0:e?t?e.prefix?t.prefix?e.prefix.localeCompare(t.prefix):1:-1:1:-1}function Vr(e,t){if(!e.namespaceURI&&t.namespaceURI)return-1;if(!t.namespaceURI&&e.namespaceURI)return 1;var r=e.namespaceURI+e.localName,n=t.namespaceURI+t.localName;return r===n?0:r<n?-1:1}function Tr(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0,n=t||null;if(e.prefix===n)return++r;if(e.attributes)for(var a=0;a<e.attributes.length;a++){var i=e.attributes[a];if(!_r(i)&&t&&e.attributes[a].prefix===t)return++r}for(var s=e.firstChild;s;s=s.nextSibling)if(s.nodeType===O.Element){var o=s,u=Tr(o,t,r);if(s.nodeType===O.Element&&u)return++r+u}return r}function _r(e){return!(null===e||e.nodeType!==O.Attribute||"xmlns"!==e.nodeName&&!/xmlns:/.test(e.nodeName))}function jr(e,r,n,a){var i,s=arguments.length,o=s<3?r:null===a?a=Object.getOwnPropertyDescriptor(r,n):a;if("object"===("undefined"==typeof Reflect?"undefined":t(Reflect))&&"function"==typeof Reflect.decorate)o=Reflect.decorate(e,r,n,a);else for(var u=e.length-1;u>=0;u--)(i=e[u])&&(o=(s<3?i(o):s>3?i(r,n,o):i(r,n))||o);return s>3&&o&&Object.defineProperty(r,n,o),o}var Kr={DefaultCanonMethod:"http://www.w3.org/TR/2001/REC-xml-c14n-20010315",DefaultDigestMethod:"http://www.w3.org/2001/04/xmlenc#sha256",DefaultPrefix:"ds",ElementNames:{CanonicalizationMethod:"CanonicalizationMethod",DigestMethod:"DigestMethod",DigestValue:"DigestValue",DSAKeyValue:"DSAKeyValue",DomainParameters:"DomainParameters",EncryptedKey:"EncryptedKey",HMACOutputLength:"HMACOutputLength",RSAPSSParams:"RSAPSSParams",MaskGenerationFunction:"MaskGenerationFunction",SaltLength:"SaltLength",KeyInfo:"KeyInfo",KeyName:"KeyName",KeyValue:"KeyValue",Modulus:"Modulus",Exponent:"Exponent",Manifest:"Manifest",Object:"Object",Reference:"Reference",RetrievalMethod:"RetrievalMethod",RSAKeyValue:"RSAKeyValue",ECDSAKeyValue:"ECDSAKeyValue",NamedCurve:"NamedCurve",PublicKey:"PublicKey",Signature:"Signature",SignatureMethod:"SignatureMethod",SignatureValue:"SignatureValue",SignedInfo:"SignedInfo",Transform:"Transform",Transforms:"Transforms",X509Data:"X509Data",PGPData:"PGPData",SPKIData:"SPKIData",SPKIexp:"SPKIexp",MgmtData:"MgmtData",X509IssuerSerial:"X509IssuerSerial",X509IssuerName:"X509IssuerName",X509SerialNumber:"X509SerialNumber",X509SKI:"X509SKI",X509SubjectName:"X509SubjectName",X509Certificate:"X509Certificate",X509CRL:"X509CRL",XPath:"XPath",X:"X",Y:"Y"},AttributeNames:{Algorithm:"Algorithm",Encoding:"Encoding",Id:"Id",MimeType:"MimeType",Type:"Type",URI:"URI"},AlgorithmNamespaces:{XmlDsigBase64Transform:"http://www.w3.org/2000/09/xmldsig#base64",XmlDsigC14NTransform:"http://www.w3.org/TR/2001/REC-xml-c14n-20010315",XmlDsigC14NWithCommentsTransform:"http://www.w3.org/TR/2001/REC-xml-c14n-20010315#WithComments",XmlDsigEnvelopedSignatureTransform:"http://www.w3.org/2000/09/xmldsig#enveloped-signature",XmlDsigXPathTransform:"http://www.w3.org/TR/1999/REC-xpath-19991116",XmlDsigXsltTransform:"http://www.w3.org/TR/1999/REC-xslt-19991116",XmlDsigExcC14NTransform:"http://www.w3.org/2001/10/xml-exc-c14n#",XmlDsigExcC14NWithCommentsTransform:"http://www.w3.org/2001/10/xml-exc-c14n#WithComments",XmlDecryptionTransform:"http://www.w3.org/2002/07/decrypt#XML",XmlLicenseTransform:"urn:mpeg:mpeg21:2003:01-REL-R-NS:licenseTransform"},Uri:{Manifest:"http://www.w3.org/2000/09/xmldsig#Manifest"},NamespaceURI:"http://www.w3.org/2000/09/xmldsig#",NamespaceURIMore:"http://www.w3.org/2007/05/xmldsig-more#",NamespaceURIPss:"http://www.example.org/xmldsig-pss/#"};e.XmlSignatureObject=function(e){o(r,e);var t=h(r);function r(){return a(this,r),t.apply(this,arguments)}return r}(Y),e.XmlSignatureObject=jr([A({localName:"xmldsig",namespaceURI:Kr.NamespaceURI,prefix:Kr.DefaultPrefix})],e.XmlSignatureObject),e.XmlSignatureCollection=function(e){o(r,e);var t=h(r);function r(){return a(this,r),t.apply(this,arguments)}return r}(Z),e.XmlSignatureCollection=jr([A({localName:"xmldsig_collection",namespaceURI:Kr.NamespaceURI,prefix:Kr.DefaultPrefix})],e.XmlSignatureCollection);var Mr=function(e){o(r,e);var t=h(r);function r(){return a(this,r),t.apply(this,arguments)}return r}(e.XmlSignatureObject);e.CanonicalizationMethod=function(e){o(r,e);var t=h(r);function r(){return a(this,r),t.apply(this,arguments)}return r}(e.XmlSignatureObject),jr([N({localName:Kr.AttributeNames.Algorithm,required:!0,defaultValue:Kr.DefaultCanonMethod})],e.CanonicalizationMethod.prototype,"Algorithm",void 0),e.CanonicalizationMethod=jr([A({localName:Kr.ElementNames.CanonicalizationMethod})],e.CanonicalizationMethod),e.DataObject=function(e){o(r,e);var t=h(r);function r(){return a(this,r),t.apply(this,arguments)}return r}(e.XmlSignatureObject),jr([N({localName:Kr.AttributeNames.Id,defaultValue:""})],e.DataObject.prototype,"Id",void 0),jr([N({localName:Kr.AttributeNames.MimeType,defaultValue:""})],e.DataObject.prototype,"MimeType",void 0),jr([N({localName:Kr.AttributeNames.Encoding,defaultValue:""})],e.DataObject.prototype,"Encoding",void 0),e.DataObject=jr([A({localName:Kr.ElementNames.Object})],e.DataObject),e.DataObjects=function(e){o(r,e);var t=h(r);function r(){return a(this,r),t.apply(this,arguments)}return r}(e.XmlSignatureCollection),e.DataObjects=jr([A({localName:"xmldsig_objects",parser:e.DataObject})],e.DataObjects),e.DigestMethod=function(e){o(r,e);var t=h(r);function r(e){var n;return a(this,r),n=t.call(this),e&&(n.Algorithm=e),n}return r}(e.XmlSignatureObject),jr([N({localName:Kr.AttributeNames.Algorithm,required:!0,defaultValue:Kr.DefaultDigestMethod})],e.DigestMethod.prototype,"Algorithm",void 0),e.DigestMethod=jr([A({localName:Kr.ElementNames.DigestMethod})],e.DigestMethod),e.KeyInfo=function(t){o(n,t);var r=h(n);function n(){return a(this,n),r.apply(this,arguments)}return s(n,[{key:"OnLoadXml",value:function(t){for(var r=0;r<t.childNodes.length;r++){var n=t.childNodes.item(r);if(n.nodeType===O.Element){var a=null;switch(n.localName){case Kr.ElementNames.KeyValue:a=e.KeyValue;break;case Kr.ElementNames.X509Data:a=e.KeyInfoX509Data;break;case Kr.ElementNames.SPKIData:a=e.SPKIData;break;case Kr.ElementNames.KeyName:case Kr.ElementNames.RetrievalMethod:case Kr.ElementNames.PGPData:case Kr.ElementNames.MgmtData:}if(a){var i=new a;i.LoadXml(n),this.Add(i)}}}}}]),n}(e.XmlSignatureCollection),jr([N({localName:Kr.AttributeNames.Id,defaultValue:""})],e.KeyInfo.prototype,"Id",void 0),e.KeyInfo=jr([A({localName:Kr.ElementNames.KeyInfo})],e.KeyInfo),e.Transform=function(e){o(r,e);var t=h(r);function r(){var e;return a(this,r),(e=t.apply(this,arguments)).innerXml=null,e}return s(r,[{key:"GetOutput",value:function(){throw new R(x.METHOD_NOT_IMPLEMENTED)}},{key:"LoadInnerXml",value:function(e){if(!e)throw new R(x.PARAM_REQUIRED,"node");this.innerXml=e}},{key:"GetInnerXml",value:function(){return this.innerXml}}]),r}(e.XmlSignatureObject),jr([N({localName:Kr.AttributeNames.Algorithm,defaultValue:""})],e.Transform.prototype,"Algorithm",void 0),jr([C({localName:Kr.ElementNames.XPath,defaultValue:""})],e.Transform.prototype,"XPath",void 0),e.Transform=jr([A({localName:Kr.ElementNames.Transform})],e.Transform);var Xr=function(e){o(r,e);var t=h(r);function r(){var e;return a(this,r),(e=t.apply(this,arguments)).Algorithm=Kr.AlgorithmNamespaces.XmlDsigBase64Transform,e}return s(r,[{key:"GetOutput",value:function(){if(!this.innerXml)throw new R(x.PARAM_REQUIRED,"innerXml");return U.FromString(this.innerXml.textContent||"","base64")}}]),r}(e.Transform),Gr=function(e){o(r,e);var t=h(r);function r(){var e;return a(this,r),(e=t.apply(this,arguments)).Algorithm="http://www.w3.org/TR/2001/REC-xml-c14n-20010315",e.xmlCanonicalizer=new Dr(!1,!1),e}return s(r,[{key:"GetOutput",value:function(){if(!this.innerXml)throw new R(x.PARAM_REQUIRED,"innerXml");return this.xmlCanonicalizer.Canonicalize(this.innerXml)}}]),r}(e.Transform),qr=function(e){o(r,e);var t=h(r);function r(){var e;return a(this,r),(e=t.apply(this,arguments)).Algorithm="http://www.w3.org/TR/2001/REC-xml-c14n-20010315#WithComments",e.xmlCanonicalizer=new Dr(!0,!1),e}return r}(Gr),Fr=function(e){o(r,e);var t=h(r);function r(){var e;return a(this,r),(e=t.apply(this,arguments)).Algorithm="http://www.w3.org/2000/09/xmldsig#enveloped-signature",e}return s(r,[{key:"GetOutput",value:function(){var e;if(!this.innerXml)throw new R(x.PARAM_REQUIRED,"innerXml");for(var t=this.innerXml.firstChild,r=[];t;)F(t)&&t.localName===Kr.ElementNames.Signature&&t.namespaceURI===Kr.NamespaceURI&&r.push(t),t=t.nextSibling;for(var n=0,a=r;n<a.length;n++){var i=a[n];null===(e=i.parentNode)||void 0===e||e.removeChild(i)}return this.innerXml}}]),r}(e.Transform),Jr=function(e){o(r,e);var t=h(r);function r(){var e;return a(this,r),(e=t.apply(this,arguments)).Algorithm="http://www.w3.org/2001/10/xml-exc-c14n#",e.xmlCanonicalizer=new Dr(!1,!0),e}return s(r,[{key:"LoadXml",value:function(e){if(m(u(r.prototype),"LoadXml",this).call(this,e),this.Element&&this.Element.childNodes)for(var t=0;t<this.Element.childNodes.length;t++){var n=this.Element.childNodes[t];if(n&&1===n.nodeType)switch(n.localName){case"InclusiveNamespaces":this.setInclusiveNamespacesElement(n)}}}},{key:"GetOutput",value:function(){if(!this.innerXml)throw new R(x.PARAM_REQUIRED,"innerXml");return this.xmlCanonicalizer.Canonicalize(this.innerXml)}},{key:"setInclusiveNamespacesElement",value:function(e){var t=e.getAttribute("PrefixList");t&&t.length>0&&(this.xmlCanonicalizer.InclusiveNamespacesPrefixList=t)}},{key:"InclusiveNamespacesPrefixList",get:function(){return this.xmlCanonicalizer.InclusiveNamespacesPrefixList},set:function(e){this.xmlCanonicalizer.InclusiveNamespacesPrefixList=e}}]),r}(e.Transform),Wr=function(e){o(r,e);var t=h(r);function r(){var e;return a(this,r),(e=t.apply(this,arguments)).Algorithm="http://www.w3.org/2001/10/xml-exc-c14n#WithComments",e.xmlCanonicalizer=new Dr(!0,!0),e}return r}(Jr),zr=function(e){o(r,e);var t=h(r);function r(){var e;return a(this,r),(e=t.apply(this,arguments)).Algorithm=Kr.AlgorithmNamespaces.XmlDsigXPathTransform,e}return s(r,[{key:"GetOutput",value:function(){if(!this.innerXml)throw new R(x.PARAM_REQUIRED,"innerXml");this.Filter(this.innerXml.ownerDocument||this.innerXml,this.XPath)}},{key:"Filter",value:function(e,t){for(var r=this,n=e.childNodes,a=[],i=0;n&&i<n.length;i++){var s=n.item(i);a.push(s)}a.forEach((function(e){r.Evaluate(e,t)?e.parentNode&&e.parentNode.removeChild(e):r.Filter(e,t)}))}},{key:"GetEvaluator",value:function(e){return"undefined"!=typeof self?null==e.ownerDocument?e:e.ownerDocument:require("xpath")}},{key:"Evaluate",value:function(e,t){try{var r=this.GetEvaluator(e),n=r.createNSResolver(this.GetXml().firstChild),a="boolean(".concat(t,")");return!r.evaluate(a,e,n,("undefined"==typeof self?require("xpath"):self).XPathResult.ANY_TYPE,null).booleanValue}catch(e){return!1}}}]),r}(e.Transform);function Qr(e,t){var r=new t;return r.LoadXml(e.Element),r}jr([C({localName:Kr.ElementNames.XPath,namespaceURI:Kr.NamespaceURI,prefix:Kr.DefaultPrefix,required:!0})],zr.prototype,"XPath",void 0),e.Transforms=function(e){o(r,e);var t=h(r);function r(){return a(this,r),t.apply(this,arguments)}return s(r,[{key:"OnLoadXml",value:function(e){m(u(r.prototype),"OnLoadXml",this).call(this,e),this.items=this.GetIterator().map((function(e){switch(e.Algorithm){case Kr.AlgorithmNamespaces.XmlDsigEnvelopedSignatureTransform:return Qr(e,Fr);case Kr.AlgorithmNamespaces.XmlDsigC14NTransform:return Qr(e,Gr);case Kr.AlgorithmNamespaces.XmlDsigC14NWithCommentsTransform:return Qr(e,qr);case Kr.AlgorithmNamespaces.XmlDsigExcC14NTransform:return Qr(e,Jr);case Kr.AlgorithmNamespaces.XmlDsigExcC14NWithCommentsTransform:return Qr(e,Wr);case Kr.AlgorithmNamespaces.XmlDsigBase64Transform:return Qr(e,Xr);case Kr.AlgorithmNamespaces.XmlDsigXPathTransform:return Qr(e,zr);default:throw new R(x.CRYPTOGRAPHIC_UNKNOWN_TRANSFORM,e.Algorithm)}}))}}]),r}(e.XmlSignatureCollection),e.Transforms=jr([A({localName:Kr.ElementNames.Transforms,parser:e.Transform})],e.Transforms),e.Reference=function(t){o(n,t);var r=h(n);function n(t){var i;return a(this,n),(i=r.call(this)).DigestMethod=new e.DigestMethod,t&&(i.Uri=t),i}return n}(e.XmlSignatureObject),jr([N({defaultValue:""})],e.Reference.prototype,"Id",void 0),jr([N({localName:Kr.AttributeNames.URI})],e.Reference.prototype,"Uri",void 0),jr([N({localName:Kr.AttributeNames.Type,defaultValue:""})],e.Reference.prototype,"Type",void 0),jr([C({parser:e.Transforms})],e.Reference.prototype,"Transforms",void 0),jr([C({required:!0,parser:e.DigestMethod})],e.Reference.prototype,"DigestMethod",void 0),jr([C({required:!0,localName:Kr.ElementNames.DigestValue,namespaceURI:Kr.NamespaceURI,prefix:Kr.DefaultPrefix,converter:W})],e.Reference.prototype,"DigestValue",void 0),e.Reference=jr([A({localName:Kr.ElementNames.Reference})],e.Reference),e.References=function(e){o(r,e);var t=h(r);function r(){return a(this,r),t.apply(this,arguments)}return r}(e.XmlSignatureCollection),e.References=jr([A({localName:"References",parser:e.Reference})],e.References),e.SignatureMethodOther=function(t){o(n,t);var r=h(n);function n(){return a(this,n),r.apply(this,arguments)}return s(n,[{key:"OnLoadXml",value:function(t){for(var r=0;r<t.childNodes.length;r++){var n=t.childNodes.item(r);if(n.nodeType===O.Element&&n.nodeName!==Kr.ElementNames.HMACOutputLength){var a=void 0;switch(n.localName){case Kr.ElementNames.RSAPSSParams:a=e.PssAlgorithmParams}if(a){var i=new a;i.LoadXml(n),this.Add(i)}}}}}]),n}(e.XmlSignatureCollection),e.SignatureMethodOther=jr([A({localName:"Other"})],e.SignatureMethodOther),e.SignatureMethod=function(e){o(r,e);var t=h(r);function r(){return a(this,r),t.apply(this,arguments)}return r}(e.XmlSignatureObject),jr([N({localName:Kr.AttributeNames.Algorithm,required:!0,defaultValue:""})],e.SignatureMethod.prototype,"Algorithm",void 0),jr([C({localName:Kr.ElementNames.HMACOutputLength,namespaceURI:Kr.NamespaceURI,prefix:Kr.DefaultPrefix,converter:z})],e.SignatureMethod.prototype,"HMACOutputLength",void 0),jr([C({parser:e.SignatureMethodOther,noRoot:!0,minOccurs:0})],e.SignatureMethod.prototype,"Any",void 0),e.SignatureMethod=jr([A({localName:Kr.ElementNames.SignatureMethod})],e.SignatureMethod),e.SignedInfo=function(e){o(r,e);var t=h(r);function r(){return a(this,r),t.apply(this,arguments)}return r}(e.XmlSignatureObject),jr([N({localName:Kr.AttributeNames.Id,defaultValue:""})],e.SignedInfo.prototype,"Id",void 0),jr([C({parser:e.CanonicalizationMethod,required:!0})],e.SignedInfo.prototype,"CanonicalizationMethod",void 0),jr([C({parser:e.SignatureMethod,required:!0})],e.SignedInfo.prototype,"SignatureMethod",void 0),jr([C({parser:e.References,minOccurs:1,noRoot:!0})],e.SignedInfo.prototype,"References",void 0),e.SignedInfo=jr([A({localName:Kr.ElementNames.SignedInfo})],e.SignedInfo),e.Signature=function(e){o(r,e);var t=h(r);function r(){return a(this,r),t.apply(this,arguments)}return r}(e.XmlSignatureObject),jr([N({localName:Kr.AttributeNames.Id,defaultValue:""})],e.Signature.prototype,"Id",void 0),jr([C({parser:e.SignedInfo,required:!0})],e.Signature.prototype,"SignedInfo",void 0),jr([C({localName:Kr.ElementNames.SignatureValue,namespaceURI:Kr.NamespaceURI,prefix:Kr.DefaultPrefix,required:!0,converter:W,defaultValue:null})],e.Signature.prototype,"SignatureValue",void 0),jr([C({parser:e.KeyInfo})],e.Signature.prototype,"KeyInfo",void 0),jr([C({parser:e.DataObjects,noRoot:!0})],e.Signature.prototype,"ObjectList",void 0),e.Signature=jr([A({localName:Kr.ElementNames.Signature})],e.Signature);var Yr,Zr="http://www.w3.org/2001/04/xmldsig-more#",$r="ecdsa";function en(e){switch(e){case"P-256":return"urn:oid:1.2.840.10045.3.1.7";case"P-384":return"urn:oid:1.3.132.0.34";case"P-521":return"urn:oid:1.3.132.0.35"}throw new R(x.CRYPTOGRAPHIC,"Unknown NamedCurve")}function tn(e){switch(e){case"urn:oid:1.2.840.10045.3.1.7":return"P-256";case"urn:oid:1.3.132.0.34":return"P-384";case"urn:oid:1.3.132.0.35":return"P-521"}throw new R(x.CRYPTOGRAPHIC,"Unknown NamedCurve OID")}e.EcdsaPublicKey=function(e){o(r,e);var t=h(r);function r(){return a(this,r),t.apply(this,arguments)}return r}(Y),jr([C({localName:Kr.ElementNames.X,namespaceURI:Zr,prefix:$r,required:!0,converter:W})],e.EcdsaPublicKey.prototype,"X",void 0),jr([C({localName:Kr.ElementNames.Y,namespaceURI:Zr,prefix:$r,required:!0,converter:W})],e.EcdsaPublicKey.prototype,"Y",void 0),e.EcdsaPublicKey=jr([A({localName:Kr.ElementNames.PublicKey,namespaceURI:Zr,prefix:$r})],e.EcdsaPublicKey),e.NamedCurve=function(e){o(r,e);var t=h(r);function r(){return a(this,r),t.apply(this,arguments)}return r}(Y),jr([N({localName:Kr.AttributeNames.URI,required:!0})],e.NamedCurve.prototype,"Uri",void 0),e.NamedCurve=jr([A({localName:Kr.ElementNames.NamedCurve,namespaceURI:Zr,prefix:$r})],e.NamedCurve),e.DomainParameters=function(e){o(r,e);var t=h(r);function r(){return a(this,r),t.apply(this,arguments)}return r}(Y),jr([C({parser:e.NamedCurve})],e.DomainParameters.prototype,"NamedCurve",void 0),e.DomainParameters=jr([A({localName:Kr.ElementNames.DomainParameters,namespaceURI:Zr,prefix:$r})],e.DomainParameters),e.EcdsaKeyValue=function(t){o(l,t);var r,i,u=h(l);function l(){var e;return a(this,l),(e=u.apply(this,arguments)).name=Kr.ElementNames.ECDSAKeyValue,e.key=null,e.jwk=null,e.keyUsage=null,e}return s(l,[{key:"importKey",value:(i=n(regeneratorRuntime.mark((function t(r){var n;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if("ECDSA"===r.algorithm.name.toUpperCase()){t.next=2;break}throw new R(x.ALGORITHM_WRONG_NAME,r.algorithm.name);case 2:return t.next=4,Et.crypto.subtle.exportKey("jwk",r);case 4:return n=t.sent,this.key=r,this.jwk=n,this.PublicKey=new e.EcdsaPublicKey,this.PublicKey.X=U.FromString(n.x,"base64url"),this.PublicKey.Y=U.FromString(n.y,"base64url"),this.DomainParameters||(this.DomainParameters=new e.DomainParameters),this.DomainParameters.NamedCurve||(this.DomainParameters.NamedCurve=new e.NamedCurve),this.DomainParameters.NamedCurve.Uri=en(n.crv),this.keyUsage=r.usages,t.abrupt("return",this);case 15:case"end":return t.stop()}}),t,this)}))),function(e){return i.apply(this,arguments)})},{key:"exportKey",value:(r=n(regeneratorRuntime.mark((function e(t){var r,n,a,i,s;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this.key){e.next=2;break}return e.abrupt("return",this.key);case 2:return r=U.ToBase64Url(this.PublicKey.X),n=U.ToBase64Url(this.PublicKey.Y),a=tn(this.DomainParameters.NamedCurve.Uri),i={kty:"EC",crv:a,x:r,y:n,ext:!0},this.keyUsage=["verify"],e.next=9,Et.crypto.subtle.importKey("jwk",i,{name:"ECDSA",namedCurve:a},!0,this.keyUsage);case 9:return s=e.sent,this.key=s,e.abrupt("return",this.key);case 12:case"end":return e.stop()}}),e,this)}))),function(e){return r.apply(this,arguments)})},{key:"NamedCurve",get:function(){return en(this.DomainParameters.NamedCurve.Uri)}}]),l}(Mr),jr([C({parser:e.DomainParameters})],e.EcdsaKeyValue.prototype,"DomainParameters",void 0),jr([C({parser:e.EcdsaPublicKey,required:!0})],e.EcdsaKeyValue.prototype,"PublicKey",void 0),e.EcdsaKeyValue=jr([A({localName:Kr.ElementNames.ECDSAKeyValue,namespaceURI:Zr,prefix:$r})],e.EcdsaKeyValue),e.RsaKeyValue=function(e){o(l,e);var t,r,i=h(l);function l(){var e;return a(this,l),(e=i.apply(this,arguments)).key=null,e.jwk=null,e.keyUsage=[],e}return s(l,[{key:"importKey",value:(r=n(regeneratorRuntime.mark((function e(t){var r,n;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if((r=t.algorithm.name.toUpperCase())===cr.toUpperCase()||r===br.toUpperCase()){e.next=3;break}throw new R(x.ALGORITHM_WRONG_NAME,t.algorithm.name);case 3:return this.key=t,e.next=6,Et.crypto.subtle.exportKey("jwk",t);case 6:return n=e.sent,this.jwk=n,this.Modulus=U.FromBase64Url(n.n),this.Exponent=U.FromBase64Url(n.e),this.keyUsage=t.usages,e.abrupt("return",this);case 12:case"end":return e.stop()}}),e,this)}))),function(e){return r.apply(this,arguments)})},{key:"exportKey",value:(t=n(regeneratorRuntime.mark((function e(t){var r,n,a,i;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this.key){e.next=2;break}return e.abrupt("return",this.key);case 2:if(this.Modulus){e.next=4;break}throw new R(x.CRYPTOGRAPHIC,"RsaKeyValue has no Modulus");case 4:if(r=U.ToBase64Url(this.Modulus),this.Exponent){e.next=7;break}throw new R(x.CRYPTOGRAPHIC,"RsaKeyValue has no Exponent");case 7:n=U.ToBase64Url(this.Exponent),e.t0=t.name.toUpperCase(),e.next=e.t0===cr.toUpperCase()?11:e.t0===br.toUpperCase()?13:15;break;case 11:return a="R",e.abrupt("break",16);case 13:return a="P",e.abrupt("break",16);case 15:throw new R(x.ALGORITHM_NOT_SUPPORTED,t.name);case 16:e.t1=t.hash.name.toUpperCase(),e.next=e.t1===Ut?19:e.t1===Dt?21:e.t1===Ht?23:e.t1===Vt?25:27;break;case 19:return a+="S1",e.abrupt("break",27);case 21:return a+="S256",e.abrupt("break",27);case 23:return a+="S384",e.abrupt("break",27);case 25:return a+="S512",e.abrupt("break",27);case 27:return i={kty:"RSA",alg:a,n:r,e:n,ext:!0},e.abrupt("return",Et.crypto.subtle.importKey("jwk",i,t,!0,this.keyUsage));case 29:case"end":return e.stop()}}),e,this)}))),function(e){return t.apply(this,arguments)})},{key:"LoadXml",value:function(e){m(u(l.prototype),"LoadXml",this).call(this,e),this.keyUsage=["verify"]}}]),l}(Mr),jr([C({localName:Kr.ElementNames.Modulus,prefix:Kr.DefaultPrefix,namespaceURI:Kr.NamespaceURI,required:!0,converter:W})],e.RsaKeyValue.prototype,"Modulus",void 0),jr([C({localName:Kr.ElementNames.Exponent,prefix:Kr.DefaultPrefix,namespaceURI:Kr.NamespaceURI,required:!0,converter:W})],e.RsaKeyValue.prototype,"Exponent",void 0),e.RsaKeyValue=jr([A({localName:Kr.ElementNames.RSAKeyValue})],e.RsaKeyValue);var rn="http://www.w3.org/2007/05/xmldsig-more#",nn="pss";e.MaskGenerationFunction=function(e){o(r,e);var t=h(r);function r(){return a(this,r),t.apply(this,arguments)}return r}(Y),jr([C({parser:e.DigestMethod})],e.MaskGenerationFunction.prototype,"DigestMethod",void 0),jr([N({localName:Kr.AttributeNames.Algorithm,defaultValue:"http://www.w3.org/2007/05/xmldsig-more#MGF1"})],e.MaskGenerationFunction.prototype,"Algorithm",void 0),e.MaskGenerationFunction=jr([A({localName:Kr.ElementNames.MaskGenerationFunction,prefix:nn,namespaceURI:rn})],e.MaskGenerationFunction),e.PssAlgorithmParams=Yr=function(t){o(n,t);var r=h(n);function n(e){var t;return a(this,n),t=r.call(this),e&&t.FromAlgorithm(e),t}return s(n,[{key:"FromAlgorithm",value:function(t){this.DigestMethod=new e.DigestMethod;var r=cn.GetHashAlgorithm(t.hash);this.DigestMethod.Algorithm=r.namespaceURI,t.saltLength&&(this.SaltLength=t.saltLength)}}],[{key:"FromAlgorithm",value:function(e){return new Yr(e)}}]),n}(Y),jr([C({parser:e.DigestMethod})],e.PssAlgorithmParams.prototype,"DigestMethod",void 0),jr([C({parser:e.MaskGenerationFunction})],e.PssAlgorithmParams.prototype,"MGF",void 0),jr([C({converter:z,prefix:nn,namespaceURI:rn})],e.PssAlgorithmParams.prototype,"SaltLength",void 0),jr([C({converter:z})],e.PssAlgorithmParams.prototype,"TrailerField",void 0),e.PssAlgorithmParams=Yr=jr([A({localName:Kr.ElementNames.RSAPSSParams,prefix:nn,namespaceURI:rn})],e.PssAlgorithmParams),e.KeyValue=function(t){o(l,t);var r,i,u=h(l);function l(e){var t;return a(this,l),t=u.call(this),e&&(t.Value=e),t}return s(l,[{key:"importKey",value:(i=n(regeneratorRuntime.mark((function t(r){return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:t.t0=r.algorithm.name.toUpperCase(),t.next=t.t0===br.toUpperCase()||t.t0===cr.toUpperCase()?3:t.t0===Ft.toUpperCase()?7:11;break;case 3:return this.Value=new e.RsaKeyValue,t.next=6,this.Value.importKey(r);case 6:return t.abrupt("break",12);case 7:return this.Value=new e.EcdsaKeyValue,t.next=10,this.Value.importKey(r);case 10:return t.abrupt("break",12);case 11:throw new R(x.ALGORITHM_NOT_SUPPORTED,r.algorithm.name);case 12:return t.abrupt("return",this);case 13:case"end":return t.stop()}}),t,this)}))),function(e){return i.apply(this,arguments)})},{key:"exportKey",value:(r=n(regeneratorRuntime.mark((function e(t){return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.Value){e.next=2;break}throw new R(x.NULL_REFERENCE);case 2:return e.abrupt("return",this.Value.exportKey(t));case 3:case"end":return e.stop()}}),e,this)}))),function(e){return r.apply(this,arguments)})},{key:"OnGetXml",value:function(e){if(!this.Value)throw new R(x.CRYPTOGRAPHIC,"KeyValue has empty value");var t=this.Value.GetXml();t&&e.appendChild(t)}},{key:"OnLoadXml",value:function(t){for(var r=0,n=[e.RsaKeyValue,e.EcdsaKeyValue];r<n.length;r++){var a=n[r];try{for(var i=new a,s=0;s<t.childNodes.length;s++){var o=t.childNodes.item(s);if(F(o))return i.LoadXml(o),void(this.value=i)}}catch(e){}}throw new R(x.CRYPTOGRAPHIC,"Unsupported KeyValue in use")}},{key:"Value",set:function(e){this.element=null,this.value=e},get:function(){return this.value}}]),l}(Mr),e.KeyValue=jr([A({localName:Kr.ElementNames.KeyValue})],e.KeyValue);var an,sn={"2.5.4.3":{short:"CN",long:"CommonName"},"2.5.4.6":{short:"C",long:"Country"},"2.5.4.5":{long:"DeviceSerialNumber"},"0.9.2342.19200300.100.1.25":{short:"DC",long:"DomainComponent"},"1.2.840.113549.1.9.1":{short:"E",long:"EMail"},"2.5.4.42":{short:"G",long:"GivenName"},"2.5.4.43":{short:"I",long:"Initials"},"2.5.4.7":{short:"L",long:"Locality"},"2.5.4.10":{short:"O",long:"Organization"},"2.5.4.11":{short:"OU",long:"OrganizationUnit"},"2.5.4.8":{short:"ST",long:"State"},"2.5.4.9":{short:"Street",long:"StreetAddress"},"2.5.4.4":{short:"SN",long:"SurName"},"2.5.4.12":{short:"T",long:"Title"},"1.2.840.113549.1.9.8":{long:"UnstructuredAddress"},"1.2.840.113549.1.9.2":{long:"UnstructuredName"}},on=function(){function e(t){if(a(this,e),this.publicKey=null,t){var r=new Uint8Array(t);this.LoadRaw(r),this.raw=r}}var t,r;return s(e,[{key:"Thumbprint",value:(r=n(regeneratorRuntime.mark((function e(){var t,r=arguments;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=r.length>0&&void 0!==r[0]?r[0]:"SHA-1",e.abrupt("return",Et.crypto.subtle.digest(t,this.raw));case 2:case"end":return e.stop()}}),e,this)}))),function(){return r.apply(this,arguments)})},{key:"GetRaw",value:function(){return this.raw}},{key:"exportKey",value:(t=n(regeneratorRuntime.mark((function e(t){var r,n;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return(r={algorithm:t,usages:["verify"]}).algorithm.name.toUpperCase()===Ft&&(r.algorithm.namedCurve=this.simpl.subjectPublicKeyInfo.toJSON().crv),this.isHashedAlgorithm(r.algorithm)&&"string"==typeof r.algorithm.hash&&(r.algorithm.hash={name:r.algorithm.hash}),e.next=5,this.simpl.getPublicKey({algorithm:r});case 5:return n=e.sent,this.publicKey=n,e.abrupt("return",n);case 8:case"end":return e.stop()}}),e,this)}))),function(e){return t.apply(this,arguments)})},{key:"NameToString",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:",",r=[];return e.typesAndValues.forEach((function(e){var t=e.type,n=sn[t.toString()],a=n?n.short:null;r.push("".concat(a||t,"=").concat(e.value.valueBlock.value))})),r.join(t+" ")}},{key:"LoadRaw",value:function(e){this.raw=new Uint8Array(e);var t=ue.fromBER(this.raw.buffer);this.simpl=new It({schema:t.result})}},{key:"isHashedAlgorithm",value:function(e){return!!e.hash}},{key:"SerialNumber",get:function(){return this.simpl.serialNumber.valueBlock.toString()}},{key:"Issuer",get:function(){return this.NameToString(this.simpl.issuer)}},{key:"Subject",get:function(){return this.NameToString(this.simpl.subject)}},{key:"PublicKey",get:function(){return this.publicKey}}]),e}();e.X509IssuerSerial=function(e){o(r,e);var t=h(r);function r(){return a(this,r),t.apply(this,arguments)}return r}(e.XmlSignatureObject),jr([C({localName:Kr.ElementNames.X509IssuerName,namespaceURI:Kr.NamespaceURI,prefix:Kr.DefaultPrefix,required:!0})],e.X509IssuerSerial.prototype,"X509IssuerName",void 0),jr([C({localName:Kr.ElementNames.X509SerialNumber,namespaceURI:Kr.NamespaceURI,prefix:Kr.DefaultPrefix,required:!0})],e.X509IssuerSerial.prototype,"X509SerialNumber",void 0),e.X509IssuerSerial=jr([A({localName:Kr.ElementNames.X509IssuerSerial})],e.X509IssuerSerial),(an=e.X509IncludeOption||(e.X509IncludeOption={}))[an.None=0]="None",an[an.EndCertOnly=1]="EndCertOnly",an[an.ExcludeRoot=2]="ExcludeRoot",an[an.WholeChain=3]="WholeChain",e.KeyInfoX509Data=function(t){o(c,t);var r,i,l=h(c);function c(t){var r,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:e.X509IncludeOption.None;if(a(this,c),(r=l.call(this)).x509crl=null,r.SubjectKeyIdList=[],r.key=null,t)if(t instanceof Uint8Array)r.AddCertificate(new on(t));else if(t instanceof on)switch(n){case e.X509IncludeOption.None:case e.X509IncludeOption.EndCertOnly:r.AddCertificate(t);break;case e.X509IncludeOption.ExcludeRoot:r.AddCertificatesChainFrom(t,!1);break;case e.X509IncludeOption.WholeChain:r.AddCertificatesChainFrom(t,!0)}return r}return s(c,[{key:"importKey",value:(i=n(regeneratorRuntime.mark((function e(t){return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:throw new R(x.METHOD_NOT_SUPPORTED);case 1:case"end":return e.stop()}}),e)}))),function(e){return i.apply(this,arguments)})},{key:"exportKey",value:(r=n(regeneratorRuntime.mark((function e(t){var r;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.Certificates.length){e.next=2;break}throw new R(x.NULL_REFERENCE);case 2:return e.next=4,this.Certificates[0].exportKey(t);case 4:return r=e.sent,this.key=r,e.abrupt("return",r);case 7:case"end":return e.stop()}}),e,this)}))),function(e){return r.apply(this,arguments)})},{key:"AddCertificate",value:function(e){if(!e)throw new R(x.PARAM_REQUIRED,"certificate");this.X509CertificateList||(this.X509CertificateList=[]),this.X509CertificateList.push(e)}},{key:"AddIssuerSerial",value:function(e,t){if(null==e)throw new R(x.PARAM_REQUIRED,"issuerName");null==this.IssuerSerialList&&(this.IssuerSerialList=[]);var r={issuerName:e,serialNumber:t};this.IssuerSerialList.push(r)}},{key:"AddSubjectKeyId",value:function(e){var t;(this.SubjectKeyIdList&&(this.SubjectKeyIdList=[]),"string"==typeof e)?null!=e&&(t=U.FromBase64(e),this.SubjectKeyIdList.push(t)):this.SubjectKeyIdList.push(e)}},{key:"AddSubjectName",value:function(e){null==this.SubjectNameList&&(this.SubjectNameList=[]),this.SubjectNameList.push(e)}},{key:"GetXml",value:function(){var e=this.CreateDocument(),t=this.CreateElement(e),r=this.GetPrefix();if(null!=this.IssuerSerialList&&this.IssuerSerialList.length>0&&this.IssuerSerialList.forEach((function(n){var a=e.createElementNS(Kr.NamespaceURI,r+Kr.ElementNames.X509IssuerSerial),i=e.createElementNS(Kr.NamespaceURI,r+Kr.ElementNames.X509IssuerName);i.textContent=n.issuerName,a.appendChild(i);var s=e.createElementNS(Kr.NamespaceURI,r+Kr.ElementNames.X509SerialNumber);s.textContent=n.serialNumber,a.appendChild(s),t.appendChild(a)})),null!=this.SubjectKeyIdList&&this.SubjectKeyIdList.length>0&&this.SubjectKeyIdList.forEach((function(n){var a=e.createElementNS(Kr.NamespaceURI,r+Kr.ElementNames.X509SKI);a.textContent=U.ToBase64(n),t.appendChild(a)})),null!=this.SubjectNameList&&this.SubjectNameList.length>0&&this.SubjectNameList.forEach((function(n){var a=e.createElementNS(Kr.NamespaceURI,r+Kr.ElementNames.X509SubjectName);a.textContent=n,t.appendChild(a)})),null!=this.X509CertificateList&&this.X509CertificateList.length>0&&this.X509CertificateList.forEach((function(n){var a=e.createElementNS(Kr.NamespaceURI,r+Kr.ElementNames.X509Certificate);a.textContent=U.ToBase64(n.GetRaw()),t.appendChild(a)})),null!=this.x509crl){var n=e.createElementNS(Kr.NamespaceURI,r+Kr.ElementNames.X509CRL);n.textContent=U.ToBase64(this.x509crl),t.appendChild(n)}return t}},{key:"LoadXml",value:function(t){var r=this;m(u(c.prototype),"LoadXml",this).call(this,t),this.IssuerSerialList&&(this.IssuerSerialList=[]),this.SubjectKeyIdList&&(this.SubjectKeyIdList=[]),this.SubjectNameList&&(this.SubjectNameList=[]),this.X509CertificateList&&(this.X509CertificateList=[]),this.x509crl=null;var n=this.GetChildren(Kr.ElementNames.X509IssuerSerial);n&&n.forEach((function(t){var n=e.XmlSignatureObject.GetChild(t,Kr.ElementNames.X509IssuerName,Kr.NamespaceURI,!0),a=e.XmlSignatureObject.GetChild(t,Kr.ElementNames.X509SerialNumber,Kr.NamespaceURI,!0);n&&n.textContent&&a&&a.textContent&&r.AddIssuerSerial(n.textContent,a.textContent)})),(n=this.GetChildren(Kr.ElementNames.X509SKI))&&n.forEach((function(e){if(e.textContent){var t=U.FromBase64(e.textContent);r.AddSubjectKeyId(t)}})),null!=(n=this.GetChildren(Kr.ElementNames.X509SubjectName))&&n.forEach((function(e){e.textContent&&r.AddSubjectName(e.textContent)})),(n=this.GetChildren(Kr.ElementNames.X509Certificate))&&n.forEach((function(e){if(e.textContent){var t=U.FromBase64(e.textContent);r.AddCertificate(new on(t))}}));var a=this.GetChild(Kr.ElementNames.X509CRL,!1);a&&a.textContent&&(this.x509crl=U.FromBase64(a.textContent))}},{key:"AddCertificatesChainFrom",value:function(e,t){throw new R(x.METHOD_NOT_IMPLEMENTED)}},{key:"Key",get:function(){return this.key}},{key:"Certificates",get:function(){return this.X509CertificateList}},{key:"CRL",get:function(){return this.x509crl},set:function(e){this.x509crl=e}},{key:"IssuerSerials",get:function(){return this.IssuerSerialList}},{key:"SubjectKeyIds",get:function(){return this.SubjectKeyIdList}},{key:"SubjectNames",get:function(){return this.SubjectNameList}}]),c}(Mr),e.KeyInfoX509Data=jr([A({localName:Kr.ElementNames.X509Data})],e.KeyInfoX509Data),e.SPKIData=function(e){o(u,e);var t,r,i=h(u);function u(){return a(this,u),i.apply(this,arguments)}return s(u,[{key:"importKey",value:(r=n(regeneratorRuntime.mark((function e(t){var r;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,Et.crypto.subtle.exportKey("spki",t);case 2:return r=e.sent,this.SPKIexp=new Uint8Array(r),this.Key=t,e.abrupt("return",this);case 6:case"end":return e.stop()}}),e,this)}))),function(e){return r.apply(this,arguments)})},{key:"exportKey",value:(t=n(regeneratorRuntime.mark((function e(t){var r;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,Et.crypto.subtle.importKey("spki",this.SPKIexp,t,!0,["verify"]);case 2:return r=e.sent,this.Key=r,e.abrupt("return",r);case 5:case"end":return e.stop()}}),e,this)}))),function(e){return t.apply(this,arguments)})}]),u}(Mr),jr([C({localName:Kr.ElementNames.SPKIexp,namespaceURI:Kr.NamespaceURI,prefix:Kr.DefaultPrefix,required:!0,converter:W})],e.SPKIData.prototype,"SPKIexp",void 0),e.SPKIData=jr([A({localName:Kr.ElementNames.SPKIData})],e.SPKIData);var un={};un[hr]=gr,un[mr]=dr,un[fr]=yr,un[vr]=pr,un[Jt]=Yt,un[Wt]=Zt,un[zt]=$t,un[Qt]=er,un[rr]=sr,un[nr]=or,un[ar]=ur,un[ir]=lr,un[Br]=Rr,un[Ir]=Lr,un[Pr]=Or,un[Er]=Ur;var ln={};ln[Tt]=Mt,ln[_t]=Xt,ln[jt]=Gt,ln[Kt]=qt;var cn=function(){function t(){a(this,t)}return s(t,null,[{key:"CreateFromName",value:function(e){var t;switch(e){case Kr.AlgorithmNamespaces.XmlDsigBase64Transform:t=new Xr;break;case Kr.AlgorithmNamespaces.XmlDsigC14NTransform:t=new Gr;break;case Kr.AlgorithmNamespaces.XmlDsigC14NWithCommentsTransform:t=new qr;break;case Kr.AlgorithmNamespaces.XmlDsigEnvelopedSignatureTransform:t=new Fr;break;case Kr.AlgorithmNamespaces.XmlDsigXPathTransform:case Kr.AlgorithmNamespaces.XmlDsigXsltTransform:throw new R(x.ALGORITHM_NOT_SUPPORTED,e);case Kr.AlgorithmNamespaces.XmlDsigExcC14NTransform:t=new Jr;break;case Kr.AlgorithmNamespaces.XmlDsigExcC14NWithCommentsTransform:t=new Wr;break;case Kr.AlgorithmNamespaces.XmlDecryptionTransform:default:throw new R(x.ALGORITHM_NOT_SUPPORTED,e)}return t}},{key:"CreateSignatureAlgorithm",value:function(t){var r=un[t.Algorithm]||null;if(r)return new r;if(t.Algorithm===kr){var n;if(t.Any.Some((function(t){return t instanceof e.PssAlgorithmParams&&(n=t),!!n})),n)switch(n.DigestMethod.Algorithm){case Tt:return new Sr(n.SaltLength);case _t:return new Ar(n.SaltLength);case jt:return new Cr(n.SaltLength);case Kt:return new Nr(n.SaltLength)}throw new R(x.CRYPTOGRAPHIC,"Cannot get params for RSA-PSS algoriithm")}throw new Error("signature algorithm '".concat(t.Algorithm,"' is not supported"))}},{key:"CreateHashAlgorithm",value:function(e){var t=ln[e];if(t)return new t;throw new Error("hash algorithm '"+e+"' is not supported")}},{key:"GetHashAlgorithm",value:function(e){var t="string"==typeof e?{name:e}:e;switch(t.name.toUpperCase()){case Ut:return new Mt;case Dt:return new Xt;case Ht:return new Gt;case Vt:return new qt;default:throw new R(x.ALGORITHM_NOT_SUPPORTED,t.name)}}},{key:"GetSignatureAlgorithm",value:function(e){"string"==typeof e.hash&&(e.hash={name:e.hash});var t,r=e.hash.name;if(!r)throw new Error("Signing algorithm doesn't have name for hash");switch(e.name.toUpperCase()){case cr.toUpperCase():switch(r.toUpperCase()){case Ut:t=new gr;break;case Dt:t=new dr;break;case Ht:t=new yr;break;case Vt:t=new pr;break;default:throw new R(x.ALGORITHM_NOT_SUPPORTED,"".concat(e.name,":").concat(r))}break;case br.toUpperCase():var n=e.saltLength;switch(r.toUpperCase()){case Ut:t=n?new Sr(n):new Rr;break;case Dt:t=n?new Ar(n):new Lr;break;case Ht:t=n?new Cr(n):new Or;break;case Vt:t=n?new Nr(n):new Ur;break;default:throw new R(x.ALGORITHM_NOT_SUPPORTED,"".concat(e.name,":").concat(r))}e.saltLength=t.algorithm.saltLength;break;case Ft:switch(r.toUpperCase()){case Ut:t=new Yt;break;case Dt:t=new Zt;break;case Ht:t=new $t;break;case Vt:t=new er;break;default:throw new R(x.ALGORITHM_NOT_SUPPORTED,"".concat(e.name,":").concat(r))}break;case tr:switch(r.toUpperCase()){case Ut:t=new sr;break;case Dt:t=new or;break;case Ht:t=new ur;break;case Vt:t=new lr;break;default:throw new R(x.ALGORITHM_NOT_SUPPORTED,"".concat(e.name,":").concat(r))}break;default:throw new R(x.ALGORITHM_NOT_SUPPORTED,e.name)}return t}}]),t}(),hn=function(){function t(r){if(a(this,t),this.signature=new e.Signature,r&&r.nodeType===O.Document)this.document=r;else if(r&&r.nodeType===O.Element){var n=(new XMLSerializer).serializeToString(r);this.document=(new DOMParser).parseFromString(n,D)}}var r,i,o,u,l,c,h,m;return s(t,[{key:"Sign",value:(m=n(regeneratorRuntime.mark((function t(r,n,a,i){var s,o,u,l,c,h,m,f,v;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return a=a.cloneNode(!0),u=G({},r),n.algorithm.hash&&(u.hash=n.algorithm.hash),s=cn.GetSignatureAlgorithm(u),t.next=6,this.ApplySignOptions(this.XmlSignature,r,n,i);case 6:return o=this.XmlSignature.SignedInfo,t.next=9,this.DigestReferences(a.documentElement);case 9:if(o.SignatureMethod.Algorithm=s.namespaceURI,!(s instanceof wr)){t.next=17;break}"string"==typeof(l=G({},n.algorithm,u)).hash&&(l.hash={name:l.hash}),c=new e.PssAlgorithmParams(l),this.XmlSignature.SignedInfo.SignatureMethod.Any.Add(c),t.next=32;break;case 17:if(tr.toUpperCase()!==r.name.toUpperCase()){t.next=32;break}h=0,m=n.algorithm,t.t0=m.hash.name.toUpperCase(),t.next=t.t0===Ut?23:t.t0===Dt?25:t.t0===Ht?27:t.t0===Vt?29:31;break;case 23:return h=m.length||160,t.abrupt("break",31);case 25:return h=m.length||256,t.abrupt("break",31);case 27:return h=m.length||384,t.abrupt("break",31);case 29:return h=m.length||512,t.abrupt("break",31);case 31:this.XmlSignature.SignedInfo.SignatureMethod.HMACOutputLength=h;case 32:return f=this.TransformSignedInfo(a),t.next=35,s.Sign(f,n,u);case 35:return v=t.sent,this.Key=n,this.XmlSignature.SignatureValue=new Uint8Array(v),this.document=a,t.abrupt("return",this.XmlSignature);case 40:case"end":return t.stop()}}),t,this)}))),function(e,t,r,n){return m.apply(this,arguments)})},{key:"Verify",value:(h=n(regeneratorRuntime.mark((function e(t){var r,n;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if((r=this.document)&&r.documentElement){e.next=3;break}throw new R(x.NULL_PARAM,"SignedXml","document");case 3:return e.next=5,this.ValidateReferences(r.documentElement);case 5:if(!e.sent){e.next=18;break}if(!t){e.next=11;break}e.t0=[t],e.next=14;break;case 11:return e.next=13,this.GetPublicKeys();case 13:e.t0=e.sent;case 14:return n=e.t0,e.abrupt("return",this.ValidateSignatureValue(n));case 18:return e.abrupt("return",!1);case 19:case"end":return e.stop()}}),e,this)}))),function(e){return h.apply(this,arguments)})},{key:"GetXml",value:function(){return this.signature.GetXml()}},{key:"LoadXml",value:function(t){this.signature=e.Signature.LoadXml(t)}},{key:"toString",value:function(){var e=this.XmlSignature;if(e.SignedInfo.References&&e.SignedInfo.References.Some((function(e){return e.Transforms&&e.Transforms.Some((function(e){return e instanceof Fr}))}))){var t=this.document.documentElement.cloneNode(!0),r=this.XmlSignature.GetXml();if(!r)throw new R(x.XML_EXCEPTION,"Cannot get Xml element from Signature");var n=r.cloneNode(!0);return t.appendChild(n),(new XMLSerializer).serializeToString(t)}return this.XmlSignature.toString()}},{key:"GetPublicKeys",value:(c=n(regeneratorRuntime.mark((function t(){var r,n,a,i,s,o,u,l,c,h;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:r=[],n=y(this.XmlSignature.KeyInfo.GetIterator()),t.prev=2,n.s();case 4:if((a=n.n()).done){t.next=35;break}if(i=a.value,s=cn.CreateSignatureAlgorithm(this.XmlSignature.SignedInfo.SignatureMethod),!(i instanceof e.KeyInfoX509Data)){t.next=29;break}o=y(i.Certificates),t.prev=9,o.s();case 11:if((u=o.n()).done){t.next=19;break}return l=u.value,t.next=15,l.exportKey(s.algorithm);case 15:c=t.sent,r.push(c);case 17:t.next=11;break;case 19:t.next=24;break;case 21:t.prev=21,t.t0=t.catch(9),o.e(t.t0);case 24:return t.prev=24,o.f(),t.finish(24);case 27:t.next=33;break;case 29:return t.next=31,i.exportKey(s.algorithm);case 31:h=t.sent,r.push(h);case 33:t.next=4;break;case 35:t.next=40;break;case 37:t.prev=37,t.t1=t.catch(2),n.e(t.t1);case 40:return t.prev=40,n.f(),t.finish(40);case 43:return t.abrupt("return",r);case 44:case"end":return t.stop()}}),t,this,[[2,37,40,43],[9,21,24,27]])}))),function(){return c.apply(this,arguments)})},{key:"GetSignatureNamespaces",value:function(){var e={};return this.XmlSignature.NamespaceURI&&(e[this.XmlSignature.Prefix||""]=this.XmlSignature.NamespaceURI),e}},{key:"CopyNamespaces",value:function(e,t,r){this.InjectNamespaces(gn(e),t,r)}},{key:"InjectNamespaces",value:function(e,t,r){for(var n in e){var a=e[n];r&&""===n||t.setAttribute("xmlns"+(n?":"+n:""),a)}}},{key:"DigestReference",value:(l=n(regeneratorRuntime.mark((function e(t,r,n){var a,i,s,o,u,l,c,h,m,f,v,g,d;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!r.Uri){e.next=25;break}if(r.Uri.indexOf("#xpointer")?"#"===r.Uri[0]&&(a=r.Uri.substring(1)):(i=(i=(i=r.Uri).substring(9).replace(/[\r\n\t\s]/g,"")).length<2||"("!==i[0]||")"!==i[i.length-1]?"":i.substring(1,i.length-1)).length>6&&0===i.indexOf("id(")&&")"===i[i.length-1]&&(a=i.substring(4,i.length-2)),!a){e.next=25;break}s=null,o=[this.XmlSignature.KeyInfo.GetXml()],this.XmlSignature.ObjectList.ForEach((function(e){o.push(e.GetXml())})),u=0,l=o;case 7:if(!(u<l.length)){e.next=22;break}if(!(c=l[u])){e.next=19;break}if(!(s=mn(c,a))){e.next=19;break}return h=s.cloneNode(!0),this.CopyNamespaces(t,h,!1),this.Parent&&(m=this.Parent instanceof Y?this.Parent.GetXml():this.Parent,this.CopyNamespaces(m,h,!0)),this.CopyNamespaces(s,h,!1),this.InjectNamespaces(this.GetSignatureNamespaces(),h,!0),t=h,e.abrupt("break",22);case 19:u++,e.next=7;break;case 22:if(!s&&t&&(s=Y.GetElementById(t,a))&&(f=s.cloneNode(!0),this.CopyNamespaces(s,f,!1),this.CopyNamespaces(t,f,!1),t=f),null!=s){e.next=25;break}throw new R(x.CRYPTOGRAPHIC,"Cannot get object by reference: ".concat(a));case 25:if(v=null,!r.Transforms||!r.Transforms.Count){e.next=30;break}v=this.ApplyTransforms(r.Transforms,t),e.next=39;break;case 30:if(!r.Uri||"#"===r.Uri[0]){e.next=36;break}if(t.ownerDocument){e.next=33;break}throw new Error("Cannot get ownerDocument from XML document");case 33:v=(new XMLSerializer).serializeToString(t.ownerDocument),e.next=39;break;case 36:(g=new Gr).LoadInnerXml(t),v=g.GetOutput();case 39:if(r.DigestMethod.Algorithm){e.next=41;break}throw new R(x.NULL_PARAM,"Reference","DigestMethod");case 41:return d=cn.CreateHashAlgorithm(r.DigestMethod.Algorithm),e.abrupt("return",d.Digest(v));case 43:case"end":return e.stop()}}),e,this)}))),function(e,t,r){return l.apply(this,arguments)})},{key:"DigestReferences",value:(u=n(regeneratorRuntime.mark((function e(t){var r,n,a,i;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:r=y(this.XmlSignature.SignedInfo.References.GetIterator()),e.prev=1,r.s();case 3:if((n=r.n()).done){e.next=14;break}if(!(a=n.value).DigestValue){e.next=7;break}return e.abrupt("continue",12);case 7:return a.DigestMethod.Algorithm||(a.DigestMethod.Algorithm=(new Xt).namespaceURI),e.next=10,this.DigestReference(t,a,!1);case 10:i=e.sent,a.DigestValue=i;case 12:e.next=3;break;case 14:e.next=19;break;case 16:e.prev=16,e.t0=e.catch(1),r.e(e.t0);case 19:return e.prev=19,r.f(),e.finish(19);case 22:case"end":return e.stop()}}),e,this,[[1,16,19,22]])}))),function(e){return u.apply(this,arguments)})},{key:"TransformSignedInfo",value:function(e){var t=cn.CreateFromName(this.XmlSignature.SignedInfo.CanonicalizationMethod.Algorithm),r=this.XmlSignature.SignedInfo.GetXml();if(!r)throw new R(x.XML_EXCEPTION,"Cannot get Xml element from SignedInfo");var n=r.cloneNode(!0);if(this.CopyNamespaces(r,n,!1),e&&(e.nodeType===O.Document?this.CopyNamespaces(e.documentElement,n,!1):this.CopyNamespaces(e,n,!1)),this.Parent){var a=this.Parent instanceof Y?this.Parent.GetXml():this.Parent;a&&this.CopyNamespaces(a,n,!1)}var i=X(r);for(var s in i){var o=i[s];s!==n.prefix&&n.setAttribute("xmlns"+(s?":"+s:""),o)}return t.LoadInnerXml(n),t.GetOutput()}},{key:"ResolveTransform",value:function(e){switch(e){case"enveloped":return new Fr;case"c14n":return new Gr;case"c14n-com":return new qr;case"exc-c14n":return new Jr;case"exc-c14n-com":return new Wr;case"base64":return new Xr;case"xpath":return new zr;default:throw new R(x.CRYPTOGRAPHIC_UNKNOWN_TRANSFORM,e)}}},{key:"ApplyTransforms",value:function(e,t){var r=null;if(e.Sort((function(e,t){var r=[Gr,qr,Jr,Wr];return r.some((function(t){return e instanceof t}))?1:r.some((function(e){return t instanceof e}))?-1:0})).ForEach((function(e){e.LoadInnerXml(t),e instanceof zr?e.GetOutput():r=e.GetOutput()})),1===e.Count&&e.Item(0)instanceof Fr){var n=new Gr;n.LoadInnerXml(t),r=n.GetOutput()}return r}},{key:"ApplySignOptions",value:(o=n(regeneratorRuntime.mark((function t(r,n,a){var i,s,o,u,l,c=this,h=arguments;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if((i=h.length>3&&void 0!==h[3]?h[3]:{}).id&&(this.XmlSignature.Id=i.id),!i.keyValue||a.algorithm.name.toUpperCase()===tr){t.next=9;break}return r.KeyInfo||(r.KeyInfo=new e.KeyInfo),s=r.KeyInfo,o=new e.KeyValue,s.Add(o),t.next=9,o.importKey(i.keyValue);case 9:i.x509&&(r.KeyInfo||(r.KeyInfo=new e.KeyInfo),u=r.KeyInfo,i.x509.forEach((function(t){var r=U.FromBase64(t),n=new e.KeyInfoX509Data(r);u.Add(n)}))),i.references&&i.references.forEach((function(t){var n=new e.Reference;t.id&&(n.Id=t.id),null!==t.uri&&void 0!==t.uri&&(n.Uri=t.uri),t.type&&(n.Type=t.type);var a=cn.GetHashAlgorithm(t.hash);if(n.DigestMethod.Algorithm=a.namespaceURI,t.transforms&&t.transforms.length){var i=new e.Transforms;t.transforms.forEach((function(e){i.Add(c.ResolveTransform(e))})),n.Transforms=i}r.SignedInfo.References||(r.SignedInfo.References=new e.References),r.SignedInfo.References.Add(n)})),r.SignedInfo.References.Count||(l=new e.Reference,r.SignedInfo.References.Add(l));case 12:case"end":return t.stop()}}),t,this)}))),function(e,t,r){return o.apply(this,arguments)})},{key:"ValidateReferences",value:(i=n(regeneratorRuntime.mark((function e(t){var r,n,a,i,s,o,u;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:r=y(this.XmlSignature.SignedInfo.References.GetIterator()),e.prev=1,r.s();case 3:if((n=r.n()).done){e.next=15;break}return a=n.value,e.next=7,this.DigestReference(t,a,!1);case 7:if(i=e.sent,s=U.ToBase64(i),o=U.ToString(a.DigestValue,"base64"),s===o){e.next=13;break}throw u="Invalid digest for uri '".concat(a.Uri,"'. Calculated digest is ").concat(s," but the xml to validate supplies digest ").concat(o),new R(x.CRYPTOGRAPHIC,u);case 13:e.next=3;break;case 15:e.next=20;break;case 17:e.prev=17,e.t0=e.catch(1),r.e(e.t0);case 20:return e.prev=20,r.f(),e.finish(20);case 23:return e.abrupt("return",!0);case 24:case"end":return e.stop()}}),e,this,[[1,17,20,23]])}))),function(e){return i.apply(this,arguments)})},{key:"ValidateSignatureValue",value:(r=n(regeneratorRuntime.mark((function e(t){var r,n,a,i,s;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:n=this.TransformSignedInfo(this.document),r=cn.CreateSignatureAlgorithm(this.XmlSignature.SignedInfo.SignatureMethod),a=y(t),e.prev=3,a.s();case 5:if((i=a.n()).done){e.next=14;break}return s=i.value,e.next=9,r.Verify(n,s,this.Signature);case 9:if(!e.sent){e.next=12;break}return e.abrupt("return",!0);case 12:e.next=5;break;case 14:e.next=19;break;case 16:e.prev=16,e.t0=e.catch(3),a.e(e.t0);case 19:return e.prev=19,a.f(),e.finish(19);case 22:return e.abrupt("return",!1);case 23:case"end":return e.stop()}}),e,this,[[3,16,19,22]])}))),function(e){return r.apply(this,arguments)})},{key:"XmlSignature",get:function(){return this.signature}},{key:"Signature",get:function(){return this.XmlSignature.SignatureValue}}]),t}();function mn(e,t){if(e.nodeType!==O.Element)return null;if(e.hasAttribute("Id")&&e.getAttribute("Id")===t)return e;if(e.childNodes&&e.childNodes.length)for(var r=0;r<e.childNodes.length;r++){var n=mn(e.childNodes[r],t);if(n)return n}return null}function fn(e,t,r){t in e||(e[t]=r)}function vn(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(e&&e.nodeType===O.Element){var r=e;r.namespaceURI&&"http://www.w3.org/XML/1998/namespace"!==r.namespaceURI&&fn(t,r.prefix?r.prefix:"",e.namespaceURI);for(var n=0;n<r.attributes.length;n++){var a=r.attributes.item(n);a&&"xmlns"===a.prefix&&fn(t,a.localName?a.localName:"",a.value)}e.parentNode&&vn(e.parentNode,t)}}function gn(e){var t={};return vn(e,t),t}return e.Application=Et,e.CryptoConfig=cn,e.ECDSA=Ft,e.ECDSA_SHA1_NAMESPACE=Jt,e.ECDSA_SHA256_NAMESPACE=Wt,e.ECDSA_SHA384_NAMESPACE=zt,e.ECDSA_SHA512_NAMESPACE=Qt,e.EcdsaSha1=Yt,e.EcdsaSha256=Zt,e.EcdsaSha384=$t,e.EcdsaSha512=er,e.HMAC=tr,e.HMAC_SHA1_NAMESPACE=rr,e.HMAC_SHA256_NAMESPACE=nr,e.HMAC_SHA384_NAMESPACE=ar,e.HMAC_SHA512_NAMESPACE=ir,e.HmacSha1=sr,e.HmacSha256=or,e.HmacSha384=ur,e.HmacSha512=lr,e.KeyInfoClause=Mr,e.Parse=j,e.RSA_PKCS1=cr,e.RSA_PKCS1_SHA1_NAMESPACE=hr,e.RSA_PKCS1_SHA256_NAMESPACE=mr,e.RSA_PKCS1_SHA384_NAMESPACE=fr,e.RSA_PKCS1_SHA512_NAMESPACE=vr,e.RSA_PSS=br,e.RSA_PSS_SHA1_NAMESPACE=Br,e.RSA_PSS_SHA256_NAMESPACE=Ir,e.RSA_PSS_SHA384_NAMESPACE=Pr,e.RSA_PSS_SHA512_NAMESPACE=Er,e.RSA_PSS_WITH_PARAMS_NAMESPACE=kr,e.RsaPkcs1Sha1=gr,e.RsaPkcs1Sha256=dr,e.RsaPkcs1Sha384=yr,e.RsaPkcs1Sha512=pr,e.RsaPssBase=wr,e.RsaPssSha1=Sr,e.RsaPssSha256=Ar,e.RsaPssSha384=Cr,e.RsaPssSha512=Nr,e.RsaPssWithoutParamsBase=xr,e.RsaPssWithoutParamsSha1=Rr,e.RsaPssWithoutParamsSha256=Lr,e.RsaPssWithoutParamsSha384=Or,e.RsaPssWithoutParamsSha512=Ur,e.SHA1=Ut,e.SHA1_NAMESPACE=Tt,e.SHA256=Dt,e.SHA256_NAMESPACE=_t,e.SHA384=Ht,e.SHA384_NAMESPACE=jt,e.SHA512=Vt,e.SHA512_NAMESPACE=Kt,e.Select=_,e.SelectRootNamespaces=gn,e.Sha1=Mt,e.Sha256=Xt,e.Sha384=Gt,e.Sha512=qt,e.SignedXml=hn,e.Stringify=function(e){return(new XMLSerializer).serializeToString(e)},e.X509Certificate=on,e.XmlCanonicalizer=Dr,e.XmlDsigBase64Transform=Xr,e.XmlDsigC14NTransform=Gr,e.XmlDsigC14NWithCommentsTransform=qr,e.XmlDsigEnvelopedSignatureTransform=Fr,e.XmlDsigExcC14NTransform=Jr,e.XmlDsigExcC14NWithCommentsTransform=Wr,e.XmlDsigXPathTransform=zr,e.XmlSignature=Kr,e}({});