edockit 0.2.3 → 0.2.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.umd.js CHANGED
@@ -1,17 +1,17 @@
1
- var rl=Object.defineProperty,il=Object.defineProperties;var ol=Object.getOwnPropertyDescriptors;var ri=Object.getOwnPropertySymbols;var ra=Object.prototype.hasOwnProperty,ia=Object.prototype.propertyIsEnumerable;var ta=(x,R,V)=>R in x?rl(x,R,{enumerable:!0,configurable:!0,writable:!0,value:V}):x[R]=V,T=(x,R)=>{for(var V in R||(R={}))ra.call(R,V)&&ta(x,V,R[V]);if(ri)for(var V of ri(R))ia.call(R,V)&&ta(x,V,R[V]);return x},L=(x,R)=>il(x,ol(R));var D=(x,R)=>{var V={};for(var ie in x)ra.call(x,ie)&&R.indexOf(ie)<0&&(V[ie]=x[ie]);if(x!=null&&ri)for(var ie of ri(x))R.indexOf(ie)<0&&ia.call(x,ie)&&(V[ie]=x[ie]);return V};/*!
1
+ var ll=Object.defineProperty,ul=Object.defineProperties;var fl=Object.getOwnPropertyDescriptors;var ri=Object.getOwnPropertySymbols;var na=Object.prototype.hasOwnProperty,oa=Object.prototype.propertyIsEnumerable;var ia=(x,R,V)=>R in x?ll(x,R,{enumerable:!0,configurable:!0,writable:!0,value:V}):x[R]=V,T=(x,R)=>{for(var V in R||(R={}))na.call(R,V)&&ia(x,V,R[V]);if(ri)for(var V of ri(R))oa.call(R,V)&&ia(x,V,R[V]);return x},H=(x,R)=>ul(x,fl(R));var D=(x,R)=>{var V={};for(var ie in x)na.call(x,ie)&&R.indexOf(ie)<0&&(V[ie]=x[ie]);if(x!=null&&ri)for(var ie of ri(x))R.indexOf(ie)<0&&oa.call(x,ie)&&(V[ie]=x[ie]);return V};/*!
2
2
  * MIT License
3
3
  * Copyright (c) 2025 Edgars Jēkabsons, ZenomyTech SIA
4
- */(function(x,R){typeof exports=="object"&&typeof module!="undefined"?R(exports,require("fflate"),require("@peculiar/x509")):typeof define=="function"&&define.amd?define(["exports","fflate","@peculiar/x509"],R):(x=typeof globalThis!="undefined"?globalThis:x||self,R(x.edockit={},x.fflate,x.peculiarX509))})(this,function(x,R,V){"use strict";function ie(r,e){const t=[],i=e.split(",").map(s=>s.trim()),o=[];for(const s of i){const c=s.split(/\\:|:/).filter(Boolean);c.length===1?o.push({name:c[0]}):c.length===2&&o.push({ns:c[0],name:c[1]})}function n(s){if(s){if(s.nodeType===1){const c=s,l=c.nodeName,f=c.localName;for(const p of o){if(p.ns&&l===`${p.ns}:${p.name}`){t.push(c);break}if(f===p.name||l===p.name){t.push(c);break}if(l.endsWith(`:${p.name}`)){t.push(c);break}}}if(s.childNodes)for(let c=0;c<s.childNodes.length;c++)n(s.childNodes[c])}}return n(r),t}const Wo={ds:"http://www.w3.org/2000/09/xmldsig#",dsig11:"http://www.w3.org/2009/xmldsig11#",dsig2:"http://www.w3.org/2010/xmldsig2#",ec:"http://www.w3.org/2001/10/xml-exc-c14n#",dsig_more:"http://www.w3.org/2001/04/xmldsig-more#",xenc:"http://www.w3.org/2001/04/xmlenc#",xenc11:"http://www.w3.org/2009/xmlenc11#",xades:"http://uri.etsi.org/01903/v1.3.2#",xades141:"http://uri.etsi.org/01903/v1.4.1#",asic:"http://uri.etsi.org/02918/v1.2.1#"};function Jo(){if(typeof window!="undefined"&&window.DOMParser)return new window.DOMParser;try{const{DOMParser:r}=require("@xmldom/xmldom");return new r}catch(r){throw new Error("XML DOM parser not available. In Node.js environments, please install @xmldom/xmldom package.")}}function oa(r,e,t=Wo){try{if(typeof document!="undefined"&&typeof document.evaluate=="function"){const i="ownerDocument"in r?r.ownerDocument:r;if(!i||typeof i.evaluate!="function")return null;const o=Ko(t);return i.evaluate(e,r,o,XPathResult.FIRST_ORDERED_NODE_TYPE,null).singleNodeValue}else{const i=require("xpath"),o=t;try{const n=i.select(e,r,o);return n.length>0?n[0]:null}catch(n){if(typeof n=="object"&&n!==null&&"message"in n&&typeof n.message=="string"&&n.message.includes("Cannot resolve QName")){const s=e.match(/local-name\(\)='([^']+)'/);if(s&&s[1]){const c=`.//*[local-name()='${s[1]}']`,l=i.select(c,r);return l.length>0?l[0]:null}}throw n}}}catch(i){return console.error(`XPath evaluation failed for "${e}":`,i),null}}function na(r,e,t=Wo){try{if(typeof document!="undefined"&&typeof document.evaluate=="function"){const i="ownerDocument"in r?r.ownerDocument:r;if(!i||typeof i.evaluate!="function")return[];const o=Ko(t),n=i.evaluate(e,r,o,XPathResult.ORDERED_NODE_SNAPSHOT_TYPE,null),s=[];for(let c=0;c<n.snapshotLength;c++)s.push(n.snapshotItem(c));return s}else{const i=require("xpath"),o=t;try{return i.select(e,r,o)}catch(n){if(typeof n=="object"&&n!==null&&"message"in n&&typeof n.message=="string"&&n.message.includes("Cannot resolve QName")){const s=e.match(/local-name\(\)='([^']+)'/);if(s&&s[1]){const c=`.//*[local-name()='${s[1]}']`;return i.select(c,r)}}throw n}}}catch(i){return console.error(`XPath evaluation failed for "${e}":`,i),[]}}function Ko(r){return function(e){return e===null?null:r[e]||null}}function Yo(r){const e=r.split(",").map(i=>i.trim()),t=[];for(const i of e){const o=i.split(/\\:|:/).filter(Boolean);o.length===1?t.push(`.//*[local-name()='${o[0]}']`):o.length===2&&t.push(`.//${o[0]}:${o[1]} | .//*[local-name()='${o[1]}']`)}return t.join(" | ")}function K(r,e){if(typeof r.querySelector=="function")try{const i=r.querySelector(e);if(i)return i}catch(i){}const t=ie(r,e);if(t.length>0)return t[0];try{const i=Yo(e);return oa(r,i)}catch(i){return console.warn("XPath query failed, using direct DOM traversal as fallback"),null}}function Xt(r,e){if(typeof r.querySelectorAll=="function")try{const i=r.querySelectorAll(e);if(i.length>0){const o=[];for(let n=0;n<i.length;n++)o.push(i[n]);return o}}catch(i){}const t=ie(r,e);if(t.length>0)return t;try{const i=Yo(e);return na(r,i)}catch(i){return console.warn("XPath query failed, using direct DOM traversal as fallback"),[]}}function sa(r){if(typeof window!="undefined"&&window.XMLSerializer)return new window.XMLSerializer().serializeToString(r);try{const{XMLSerializer:e}=require("@xmldom/xmldom");return new e().serializeToString(r)}catch(e){throw new Error("XML Serializer not available. In Node.js environments, please install @xmldom/xmldom package.")}}const Je={default:"c14n","http://www.w3.org/TR/2001/REC-xml-c14n-20010315":"c14n","http://www.w3.org/2006/12/xml-c14n11":"c14n11","http://www.w3.org/2001/10/xml-exc-c14n#":"c14n_exc"},mt={c14n:{beforeChildren:()=>"",afterChildren:()=>"",betweenChildren:()=>"",afterElement:()=>"",isCanonicalizationMethod:"c14n"},c14n11:{beforeChildren:(r,e)=>e?"":r?`
4
+ */(function(x,R){typeof exports=="object"&&typeof module!="undefined"?R(exports,require("fflate"),require("@peculiar/x509")):typeof define=="function"&&define.amd?define(["exports","fflate","@peculiar/x509"],R):(x=typeof globalThis!="undefined"?globalThis:x||self,R(x.edockit={},x.fflate,x.peculiarX509))})(this,function(x,R,V){"use strict";function ie(r,e){const t=[],i=e.split(",").map(s=>s.trim()),n=[];for(const s of i){const c=s.split(/\\:|:/).filter(Boolean);c.length===1?n.push({name:c[0]}):c.length===2&&n.push({ns:c[0],name:c[1]})}function o(s){if(s){if(s.nodeType===1){const c=s,l=c.nodeName,f=c.localName;for(const p of n){if(p.ns&&l===`${p.ns}:${p.name}`){t.push(c);break}if(f===p.name||l===p.name){t.push(c);break}if(l.endsWith(`:${p.name}`)){t.push(c);break}}}if(s.childNodes)for(let c=0;c<s.childNodes.length;c++)o(s.childNodes[c])}}return o(r),t}const Wn={ds:"http://www.w3.org/2000/09/xmldsig#",dsig11:"http://www.w3.org/2009/xmldsig11#",dsig2:"http://www.w3.org/2010/xmldsig2#",ec:"http://www.w3.org/2001/10/xml-exc-c14n#",dsig_more:"http://www.w3.org/2001/04/xmldsig-more#",xenc:"http://www.w3.org/2001/04/xmlenc#",xenc11:"http://www.w3.org/2009/xmlenc11#",xades:"http://uri.etsi.org/01903/v1.3.2#",xades141:"http://uri.etsi.org/01903/v1.4.1#",asic:"http://uri.etsi.org/02918/v1.2.1#"};function Jn(){if(typeof window!="undefined"&&window.DOMParser)return new window.DOMParser;try{const{DOMParser:r}=require("@xmldom/xmldom");return new r}catch(r){throw new Error("XML DOM parser not available. In Node.js environments, please install @xmldom/xmldom package.")}}function sa(r,e,t=Wn){try{if(typeof document!="undefined"&&typeof document.evaluate=="function"){const i="ownerDocument"in r?r.ownerDocument:r;if(!i||typeof i.evaluate!="function")return null;const n=Kn(t);return i.evaluate(e,r,n,XPathResult.FIRST_ORDERED_NODE_TYPE,null).singleNodeValue}else{const i=require("xpath"),n=t;try{const o=i.select(e,r,n);return o.length>0?o[0]:null}catch(o){if(typeof o=="object"&&o!==null&&"message"in o&&typeof o.message=="string"&&o.message.includes("Cannot resolve QName")){const s=e.match(/local-name\(\)='([^']+)'/);if(s&&s[1]){const c=`.//*[local-name()='${s[1]}']`,l=i.select(c,r);return l.length>0?l[0]:null}}throw o}}}catch(i){return console.error(`XPath evaluation failed for "${e}":`,i),null}}function aa(r,e,t=Wn){try{if(typeof document!="undefined"&&typeof document.evaluate=="function"){const i="ownerDocument"in r?r.ownerDocument:r;if(!i||typeof i.evaluate!="function")return[];const n=Kn(t),o=i.evaluate(e,r,n,XPathResult.ORDERED_NODE_SNAPSHOT_TYPE,null),s=[];for(let c=0;c<o.snapshotLength;c++)s.push(o.snapshotItem(c));return s}else{const i=require("xpath"),n=t;try{return i.select(e,r,n)}catch(o){if(typeof o=="object"&&o!==null&&"message"in o&&typeof o.message=="string"&&o.message.includes("Cannot resolve QName")){const s=e.match(/local-name\(\)='([^']+)'/);if(s&&s[1]){const c=`.//*[local-name()='${s[1]}']`;return i.select(c,r)}}throw o}}}catch(i){return console.error(`XPath evaluation failed for "${e}":`,i),[]}}function Kn(r){return function(e){return e===null?null:r[e]||null}}function Yn(r){const e=r.split(",").map(i=>i.trim()),t=[];for(const i of e){const n=i.split(/\\:|:/).filter(Boolean);n.length===1?t.push(`.//*[local-name()='${n[0]}']`):n.length===2&&t.push(`.//${n[0]}:${n[1]} | .//*[local-name()='${n[1]}']`)}return t.join(" | ")}function K(r,e){if(typeof r.querySelector=="function")try{const i=r.querySelector(e);if(i)return i}catch(i){}const t=ie(r,e);if(t.length>0)return t[0];try{const i=Yn(e);return sa(r,i)}catch(i){return console.warn("XPath query failed, using direct DOM traversal as fallback"),null}}function Xt(r,e){if(typeof r.querySelectorAll=="function")try{const i=r.querySelectorAll(e);if(i.length>0){const n=[];for(let o=0;o<i.length;o++)n.push(i[o]);return n}}catch(i){}const t=ie(r,e);if(t.length>0)return t;try{const i=Yn(e);return aa(r,i)}catch(i){return console.warn("XPath query failed, using direct DOM traversal as fallback"),[]}}function ca(r){if(typeof window!="undefined"&&window.XMLSerializer)return new window.XMLSerializer().serializeToString(r);try{const{XMLSerializer:e}=require("@xmldom/xmldom");return new e().serializeToString(r)}catch(e){throw new Error("XML Serializer not available. In Node.js environments, please install @xmldom/xmldom package.")}}const Ye={default:"c14n","http://www.w3.org/TR/2001/REC-xml-c14n-20010315":"c14n","http://www.w3.org/2006/12/xml-c14n11":"c14n11","http://www.w3.org/2001/10/xml-exc-c14n#":"c14n_exc"},mt={c14n:{beforeChildren:()=>"",afterChildren:()=>"",betweenChildren:()=>"",afterElement:()=>"",isCanonicalizationMethod:"c14n"},c14n11:{beforeChildren:(r,e)=>e?"":r?`
5
5
  `:"",afterChildren:(r,e)=>e?"":r?`
6
6
  `:"",betweenChildren:(r,e,t)=>t?"":r&&e?`
7
- `:"",afterElement:()=>"",isCanonicalizationMethod:"c14n11"},c14n_exc:{beforeChildren:()=>"",afterChildren:()=>"",betweenChildren:()=>"",afterElement:()=>"",isCanonicalizationMethod:"c14n_exc"}},H={ELEMENT_NODE:1,TEXT_NODE:3};class P{constructor(e=mt.c14n){this.method=e}static fromMethod(e){const t=Je[e];if(!t)throw new Error(`Unsupported canonicalization method: ${e}`);return new P(mt[t])}setMethod(e){this.method=e}static escapeXml(e){return e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&apos;")}static collectNamespaces(e,t=new Map){let i=e;for(;i&&i.nodeType===H.ELEMENT_NODE;){const o=i,n=o.getAttribute("xmlns");n!==null&&!t.has("")&&t.set("",n);const s=o.attributes;for(let c=0;c<s.length;c++){const l=s[c];if(l.name.startsWith("xmlns:")){const f=l.name.substring(6);t.has(f)||t.set(f,l.value)}}i=i.parentNode}return t}static collectUsedNamespaces(e,t=new Map,i=[]){const o=new Map,n=new Set;function s(c,l=!1){if(c.nodeType===H.ELEMENT_NODE){const f=c,p=f.namespaceURI,d=f.prefix||"";if(d&&p&&(l||!n.has(d))){n.add(d);const y=t.get(d);y&&y===p&&!o.has(d)&&o.set(d,y)}const w=f.attributes;for(let y=0;y<w.length;y++){const g=w[y];if(g.name.includes(":")&&!g.name.startsWith("xmlns:")){const B=g.name.split(":")[0];if(l||!n.has(B)){n.add(B);const m=t.get(B);m&&!o.has(B)&&o.set(B,m)}}}for(const y of i){const g=t.get(y);g&&!o.has(y)&&o.set(y,g)}for(let y=0;y<c.childNodes.length;y++)s(c.childNodes[y],!1)}}return s(e,!0),o}static isBase64Element(e){if(e.nodeType!==H.ELEMENT_NODE)return!1;const t=e,i=t.localName||t.nodeName.split(":").pop()||"";return this.base64Elements.has(i)}static analyzeWhitespace(e){const t=e.nodeType===H.ELEMENT_NODE?e:e.documentElement;function i(o){if(o.nodeType===H.ELEMENT_NODE){o._whitespace={hasMixedContent:!1,hasExistingLinebreaks:!1,originalContent:{}};const n=Array.from(o.childNodes);let s=!1,c=!1,l=!1;for(const f of n)if(f.nodeType===H.TEXT_NODE&&(f.nodeValue||"").trim().length>0){s=!0;break}for(const f of n)if(f.nodeType===H.ELEMENT_NODE){c=!0;break}for(let f=0;f<n.length;f++){const p=n[f];if(p.nodeType===H.TEXT_NODE){const d=p.nodeValue||"";p._originalText=d,d.includes(`
8
- `)&&(l=!0)}else p.nodeType===H.ELEMENT_NODE&&i(p)}o._whitespace.hasMixedContent=s&&c,o._whitespace.hasExistingLinebreaks=l}}i(t)}canonicalize(e,t=new Map,i={isStartingNode:!0}){var o,n,s;if(!e)return"";let c="";if(e.nodeType===H.ELEMENT_NODE){const l=new Map(t),f=e,p=f.getAttribute("xmlns");p!==null&&l.set("",p);const d=f.attributes;for(let O=0;O<d.length;O++){const I=d[O];if(I.name.startsWith("xmlns:")){const M=I.name.substring(6);l.set(M,I.value)}}const w=f.prefix||"",y=f.localName||f.nodeName.split(":").pop()||"",g=w?`${w}:${y}`:y;if(c+="<"+g,i.isStartingNode){const O=P.collectNamespaces(e),I=Array.from(O.entries()).sort((M,ye)=>M[0]===""?-1:ye[0]===""?1:M[0].localeCompare(ye[0]));for(const[M,ye]of I)M===""?c+=` xmlns="${ye}"`:c+=` xmlns:${M}="${ye}"`}else{const O=Array.from(l.entries()).filter(([I,M])=>!t.has(I)||t.get(I)!==M).sort((I,M)=>I[0]===""?-1:M[0]===""?1:I[0].localeCompare(M[0]));for(const[I,M]of O)I===""?c+=` xmlns="${M}"`:c+=` xmlns:${I}="${M}"`}const B=f.attributes,m=[];for(let O=0;O<B.length;O++){const I=B[O];I.name.startsWith("xmlns")||m.push(I)}m.sort((O,I)=>O.name.localeCompare(I.name));for(const O of m)c+=` ${O.name}="${P.escapeXml(O.value)}"`;c+=">";const S=Array.from(e.childNodes);let $=!1,vt=!1;const je=((o=e._whitespace)==null?void 0:o.hasMixedContent)||!1;for(const O of S)if(O.nodeType===H.ELEMENT_NODE){$=!0;break}const Gt=this.method.isCanonicalizationMethod==="c14n11"&&$&&!((n=e._whitespace)!=null&&n.hasExistingLinebreaks)&&!je;Gt&&(c+=this.method.beforeChildren($,je));for(let O=0;O<S.length;O++){const I=S[O],M=I.nodeType===H.ELEMENT_NODE,ye=O<S.length-1?S[O+1]:null;if(ye&&(ye.nodeType,H.ELEMENT_NODE),I.nodeType===H.TEXT_NODE){const zt=I.nodeValue||"";P.isBase64Element(e)?c+=zt.replace(/\r/g,"&#xD;"):c+=I._originalText||zt,vt=!1;continue}M&&(vt&&this.method.isCanonicalizationMethod==="c14n11"&&!((s=e._whitespace)!=null&&s.hasExistingLinebreaks)&&!je&&(c+=this.method.betweenChildren(!0,!0,je)),c+=this.canonicalize(I,l,{isStartingNode:!1}),vt=!0)}Gt&&(c+=this.method.afterChildren($,je)),c+="</"+g+">"}else if(e.nodeType===H.TEXT_NODE){const l=e._originalText||e.nodeValue||"";c+=P.escapeXml(l)}return c}canonicalizeExclusive(e,t=new Map,i={}){if(!e)return"";const{inclusiveNamespacePrefixList:o=[],isStartingNode:n=!0}=i;let s="";if(e.nodeType===H.ELEMENT_NODE){const c=e,l=P.collectNamespaces(c),f=n?P.collectUsedNamespaces(c,l,o):new Map,p=c.prefix||"",d=c.localName||c.nodeName.split(":").pop()||"",w=p?`${p}:${d}`:d;if(s+="<"+w,n){const m=Array.from(f.entries()).sort((S,$)=>S[0]===""?-1:$[0]===""?1:S[0].localeCompare($[0]));for(const[S,$]of m)S===""?s+=` xmlns="${$}"`:s+=` xmlns:${S}="${$}"`}const y=c.attributes,g=[];for(let m=0;m<y.length;m++){const S=y[m];S.name.startsWith("xmlns")||g.push(S)}g.sort((m,S)=>m.name.localeCompare(S.name));for(const m of g)s+=` ${m.name}="${P.escapeXml(m.value)}"`;s+=">";const B=Array.from(e.childNodes);for(let m=0;m<B.length;m++){const S=B[m];if(S.nodeType===H.TEXT_NODE){const $=S.nodeValue||"";P.isBase64Element(e)?s+=$.replace(/\r/g,"&#xD;"):s+=P.escapeXml($)}else S.nodeType===H.ELEMENT_NODE&&(s+=this.canonicalizeExclusive(S,new Map([...t,...f]),{inclusiveNamespacePrefixList:o,isStartingNode:!1}))}s+="</"+w+">"}else if(e.nodeType===H.TEXT_NODE){const c=e.nodeValue||"";s+=P.escapeXml(c)}return s}static c14n(e){return this.analyzeWhitespace(e),new P(mt.c14n).canonicalize(e)}static c14n11(e){return this.analyzeWhitespace(e),new P(mt.c14n11).canonicalize(e)}static c14n_exc(e,t=[]){return this.analyzeWhitespace(e),new P(mt.c14n_exc).canonicalizeExclusive(e,new Map,{inclusiveNamespacePrefixList:t})}static canonicalize(e,t,i={}){switch(Je[t]||Je.default){case"c14n":return this.c14n(e);case"c14n11":return this.c14n11(e);case"c14n_exc":return this.c14n_exc(e,i.inclusiveNamespacePrefixList||[]);default:throw new Error(`Unsupported canonicalization method: ${t}`)}}}P.base64Elements=new Set(["DigestValue","X509Certificate","EncapsulatedTimeStamp","EncapsulatedOCSPValue","IssuerSerialV2"]);var aa=(r,e,t)=>new Promise((i,o)=>{var n=l=>{try{c(t.next(l))}catch(f){o(f)}},s=l=>{try{c(t.throw(l))}catch(f){o(f)}},c=l=>l.done?i(l.value):Promise.resolve(l.value).then(n,s);c((t=t.apply(r,e)).next())});function ca(r){if(!r)return"";const e=r.replace(/\s+/g,""),t=[];for(let i=0;i<e.length;i+=64)t.push(e.substring(i,i+64));return`-----BEGIN CERTIFICATE-----
7
+ `:"",afterElement:()=>"",isCanonicalizationMethod:"c14n11"},c14n_exc:{beforeChildren:()=>"",afterChildren:()=>"",betweenChildren:()=>"",afterElement:()=>"",isCanonicalizationMethod:"c14n_exc"}},$={ELEMENT_NODE:1,TEXT_NODE:3};class M{constructor(e=mt.c14n){this.method=e}static fromMethod(e){const t=Ye[e];if(!t)throw new Error(`Unsupported canonicalization method: ${e}`);return new M(mt[t])}setMethod(e){this.method=e}static escapeXml(e){return e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&apos;")}static collectNamespaces(e,t=new Map){let i=e;for(;i&&i.nodeType===$.ELEMENT_NODE;){const n=i,o=n.getAttribute("xmlns");o!==null&&!t.has("")&&t.set("",o);const s=n.attributes;for(let c=0;c<s.length;c++){const l=s[c];if(l.name.startsWith("xmlns:")){const f=l.name.substring(6);t.has(f)||t.set(f,l.value)}}i=i.parentNode}return t}static collectUsedNamespaces(e,t=new Map,i=[]){const n=new Map,o=new Set;function s(c,l=!1){if(c.nodeType===$.ELEMENT_NODE){const f=c,p=f.namespaceURI,d=f.prefix||"";if(d&&p&&(l||!o.has(d))){o.add(d);const y=t.get(d);y&&y===p&&!n.has(d)&&n.set(d,y)}const w=f.attributes;for(let y=0;y<w.length;y++){const g=w[y];if(g.name.includes(":")&&!g.name.startsWith("xmlns:")){const B=g.name.split(":")[0];if(l||!o.has(B)){o.add(B);const m=t.get(B);m&&!n.has(B)&&n.set(B,m)}}}for(const y of i){const g=t.get(y);g&&!n.has(y)&&n.set(y,g)}for(let y=0;y<c.childNodes.length;y++)s(c.childNodes[y],!1)}}return s(e,!0),n}static isBase64Element(e){if(e.nodeType!==$.ELEMENT_NODE)return!1;const t=e,i=t.localName||t.nodeName.split(":").pop()||"";return this.base64Elements.has(i)}static analyzeWhitespace(e){const t=e.nodeType===$.ELEMENT_NODE?e:e.documentElement;function i(n){if(n.nodeType===$.ELEMENT_NODE){n._whitespace={hasMixedContent:!1,hasExistingLinebreaks:!1,originalContent:{}};const o=Array.from(n.childNodes);let s=!1,c=!1,l=!1;for(const f of o)if(f.nodeType===$.TEXT_NODE&&(f.nodeValue||"").trim().length>0){s=!0;break}for(const f of o)if(f.nodeType===$.ELEMENT_NODE){c=!0;break}for(let f=0;f<o.length;f++){const p=o[f];if(p.nodeType===$.TEXT_NODE){const d=p.nodeValue||"";p._originalText=d,d.includes(`
8
+ `)&&(l=!0)}else p.nodeType===$.ELEMENT_NODE&&i(p)}n._whitespace.hasMixedContent=s&&c,n._whitespace.hasExistingLinebreaks=l}}i(t)}canonicalize(e,t=new Map,i={isStartingNode:!0}){var n,o,s;if(!e)return"";let c="";if(e.nodeType===$.ELEMENT_NODE){const l=new Map(t),f=e,p=f.getAttribute("xmlns");p!==null&&l.set("",p);const d=f.attributes;for(let O=0;O<d.length;O++){const I=d[O];if(I.name.startsWith("xmlns:")){const L=I.name.substring(6);l.set(L,I.value)}}const w=f.prefix||"",y=f.localName||f.nodeName.split(":").pop()||"",g=w?`${w}:${y}`:y;if(c+="<"+g,i.isStartingNode){const O=M.collectNamespaces(e),I=Array.from(O.entries()).sort((L,we)=>L[0]===""?-1:we[0]===""?1:L[0].localeCompare(we[0]));for(const[L,we]of I)L===""?c+=` xmlns="${we}"`:c+=` xmlns:${L}="${we}"`}else{const O=Array.from(l.entries()).filter(([I,L])=>!t.has(I)||t.get(I)!==L).sort((I,L)=>I[0]===""?-1:L[0]===""?1:I[0].localeCompare(L[0]));for(const[I,L]of O)I===""?c+=` xmlns="${L}"`:c+=` xmlns:${I}="${L}"`}const B=f.attributes,m=[];for(let O=0;O<B.length;O++){const I=B[O];I.name.startsWith("xmlns")||m.push(I)}m.sort((O,I)=>O.name.localeCompare(I.name));for(const O of m)c+=` ${O.name}="${M.escapeXml(O.value)}"`;c+=">";const S=Array.from(e.childNodes);let F=!1,Oe=!1;const Ue=((n=e._whitespace)==null?void 0:n.hasMixedContent)||!1;for(const O of S)if(O.nodeType===$.ELEMENT_NODE){F=!0;break}const Gt=this.method.isCanonicalizationMethod==="c14n11"&&F&&!((o=e._whitespace)!=null&&o.hasExistingLinebreaks)&&!Ue;Gt&&(c+=this.method.beforeChildren(F,Ue));for(let O=0;O<S.length;O++){const I=S[O],L=I.nodeType===$.ELEMENT_NODE,we=O<S.length-1?S[O+1]:null;if(we&&(we.nodeType,$.ELEMENT_NODE),I.nodeType===$.TEXT_NODE){const zt=I.nodeValue||"";M.isBase64Element(e)?c+=zt.replace(/\r/g,"&#xD;"):c+=I._originalText||zt,Oe=!1;continue}L&&(Oe&&this.method.isCanonicalizationMethod==="c14n11"&&!((s=e._whitespace)!=null&&s.hasExistingLinebreaks)&&!Ue&&(c+=this.method.betweenChildren(!0,!0,Ue)),c+=this.canonicalize(I,l,{isStartingNode:!1}),Oe=!0)}Gt&&(c+=this.method.afterChildren(F,Ue)),c+="</"+g+">"}else if(e.nodeType===$.TEXT_NODE){const l=e._originalText||e.nodeValue||"";c+=M.escapeXml(l)}return c}canonicalizeExclusive(e,t=new Map,i={}){if(!e)return"";const{inclusiveNamespacePrefixList:n=[],isStartingNode:o=!0}=i;let s="";if(e.nodeType===$.ELEMENT_NODE){const c=e,l=M.collectNamespaces(c),f=o?M.collectUsedNamespaces(c,l,n):new Map,p=c.prefix||"",d=c.localName||c.nodeName.split(":").pop()||"",w=p?`${p}:${d}`:d;if(s+="<"+w,o){const m=Array.from(f.entries()).sort((S,F)=>S[0]===""?-1:F[0]===""?1:S[0].localeCompare(F[0]));for(const[S,F]of m)S===""?s+=` xmlns="${F}"`:s+=` xmlns:${S}="${F}"`}const y=c.attributes,g=[];for(let m=0;m<y.length;m++){const S=y[m];S.name.startsWith("xmlns")||g.push(S)}g.sort((m,S)=>m.name.localeCompare(S.name));for(const m of g)s+=` ${m.name}="${M.escapeXml(m.value)}"`;s+=">";const B=Array.from(e.childNodes);for(let m=0;m<B.length;m++){const S=B[m];if(S.nodeType===$.TEXT_NODE){const F=S.nodeValue||"";M.isBase64Element(e)?s+=F.replace(/\r/g,"&#xD;"):s+=M.escapeXml(F)}else S.nodeType===$.ELEMENT_NODE&&(s+=this.canonicalizeExclusive(S,new Map([...t,...f]),{inclusiveNamespacePrefixList:n,isStartingNode:!1}))}s+="</"+w+">"}else if(e.nodeType===$.TEXT_NODE){const c=e.nodeValue||"";s+=M.escapeXml(c)}return s}static c14n(e){return this.analyzeWhitespace(e),new M(mt.c14n).canonicalize(e)}static c14n11(e){return this.analyzeWhitespace(e),new M(mt.c14n11).canonicalize(e)}static c14n_exc(e,t=[]){return this.analyzeWhitespace(e),new M(mt.c14n_exc).canonicalizeExclusive(e,new Map,{inclusiveNamespacePrefixList:t})}static canonicalize(e,t,i={}){switch(Ye[t]||Ye.default){case"c14n":return this.c14n(e);case"c14n11":return this.c14n11(e);case"c14n_exc":return this.c14n_exc(e,i.inclusiveNamespacePrefixList||[]);default:throw new Error(`Unsupported canonicalization method: ${t}`)}}}M.base64Elements=new Set(["DigestValue","X509Certificate","EncapsulatedTimeStamp","EncapsulatedOCSPValue","IssuerSerialV2"]);var la=(r,e,t)=>new Promise((i,n)=>{var o=l=>{try{c(t.next(l))}catch(f){n(f)}},s=l=>{try{c(t.throw(l))}catch(f){n(f)}},c=l=>l.done?i(l.value):Promise.resolve(l.value).then(o,s);c((t=t.apply(r,e)).next())});function ua(r){if(!r)return"";const e=r.replace(/\s+/g,""),t=[];for(let i=0;i<e.length;i+=64)t.push(e.substring(i,i+64));return`-----BEGIN CERTIFICATE-----
9
9
  ${t.join(`
10
10
  `)}
11
- -----END CERTIFICATE-----`}function Zo(r){var e,t,i,o,n,s,c,l;const f={validFrom:r.notBefore,validTo:r.notAfter,issuer:{}};try{if(typeof r.subject=="object"&&r.subject!==null){const p=r.subject;f.commonName=p.commonName,f.organization=p.organizationName,f.country=p.countryName}if(typeof r.issuer=="object"&&r.issuer!==null){const p=r.issuer;f.issuer.commonName=p.commonName,f.issuer.organization=p.organizationName,f.issuer.country=p.countryName}}catch(p){console.warn("Could not extract subject/issuer as objects:",p)}try{if(typeof r.subject=="string"){const p=r.subject.split(",");for(const d of p){const[w,y]=d.trim().split("=");w==="CN"&&(f.commonName=f.commonName||y),w==="O"&&(f.organization=f.organization||y),w==="C"&&(f.country=f.country||y),w==="SN"&&(f.surname=y),(w==="G"||w==="GN")&&(f.givenName=y),(w==="SERIALNUMBER"||w==="2.5.4.5")&&(f.serialNumber=y==null?void 0:y.replace("PNOLV-",""))}}if(typeof r.issuer=="string"){const p=r.issuer.split(",");for(const d of p){const[w,y]=d.trim().split("=");w==="CN"&&(f.issuer.commonName=f.issuer.commonName||y),w==="O"&&(f.issuer.organization=f.issuer.organization||y),w==="C"&&(f.issuer.country=f.issuer.country||y)}}}catch(p){console.warn("Could not extract subject/issuer as strings:",p)}try{if("subjectName"in r&&(e=r.subjectName)!=null&&e.getField){const p=r.subjectName;f.commonName=f.commonName||((t=p.getField("CN"))==null?void 0:t[0]),f.surname=f.surname||((i=p.getField("SN"))==null?void 0:i[0]),f.givenName=f.givenName||((o=p.getField("G"))==null?void 0:o[0]),f.serialNumber=f.serialNumber||((s=(n=p.getField("2.5.4.5"))==null?void 0:n[0])==null?void 0:s.replace("PNOLV-","")),f.country=f.country||((c=p.getField("C"))==null?void 0:c[0]),f.organization=f.organization||((l=p.getField("O"))==null?void 0:l[0])}}catch(p){console.warn("Could not extract fields using getField method:",p)}return!f.serialNumber&&r.serialNumber&&(f.serialNumber=r.serialNumber),f}function Qo(r){return aa(this,null,function*(){try{let e=r;if(!r.includes("-----BEGIN CERTIFICATE-----")){const o=r.replace(/[\r\n\s]/g,"");e=ca(o)}const t=new V.X509Certificate(e),i=Zo(t);return{subject:{commonName:i.commonName,organization:i.organization,country:i.country,surname:i.surname,givenName:i.givenName,serialNumber:i.serialNumber},validFrom:i.validFrom,validTo:i.validTo,issuer:i.issuer,serialNumber:t.serialNumber}}catch(e){throw console.error("Certificate parsing error:",e),new Error("Failed to parse certificate: "+(e instanceof Error?e.message:String(e)))}})}function la(r,e=new Date){const t="notBefore"in r?r.notBefore:r.validFrom,i="notAfter"in r?r.notAfter:r.validTo;return e<t?{isValid:!1,reason:`Certificate not yet valid. Valid from ${t.toISOString()}`}:e>i?{isValid:!1,reason:`Certificate expired. Valid until ${i.toISOString()}`}:{isValid:!0}}function ua(r){const{subject:e}=r;return e.givenName&&e.surname?`${e.givenName} ${e.surname}`:e.commonName?e.commonName:e.serialNumber||"Unknown Signer"}function fa(r){const{validFrom:e,validTo:t}=r,i=o=>o.toLocaleDateString(void 0,{year:"numeric",month:"long",day:"numeric"});return`${i(e)} to ${i(t)}`}function Wt(r){if(!r)return"";const e=r.replace(/\s+/g,""),t=[];for(let i=0;i<e.length;i+=64)t.push(e.substring(i,i+64));return`-----BEGIN CERTIFICATE-----
11
+ -----END CERTIFICATE-----`}function Zn(r){var e,t,i,n,o,s,c,l;const f={validFrom:r.notBefore,validTo:r.notAfter,issuer:{}};try{if(typeof r.subject=="object"&&r.subject!==null){const p=r.subject;f.commonName=p.commonName,f.organization=p.organizationName,f.country=p.countryName}if(typeof r.issuer=="object"&&r.issuer!==null){const p=r.issuer;f.issuer.commonName=p.commonName,f.issuer.organization=p.organizationName,f.issuer.country=p.countryName}}catch(p){console.warn("Could not extract subject/issuer as objects:",p)}try{if(typeof r.subject=="string"){const p=r.subject.split(",");for(const d of p){const[w,y]=d.trim().split("=");w==="CN"&&(f.commonName=f.commonName||y),w==="O"&&(f.organization=f.organization||y),w==="C"&&(f.country=f.country||y),w==="SN"&&(f.surname=y),(w==="G"||w==="GN")&&(f.givenName=y),(w==="SERIALNUMBER"||w==="2.5.4.5")&&(f.serialNumber=y==null?void 0:y.replace("PNOLV-",""))}}if(typeof r.issuer=="string"){const p=r.issuer.split(",");for(const d of p){const[w,y]=d.trim().split("=");w==="CN"&&(f.issuer.commonName=f.issuer.commonName||y),w==="O"&&(f.issuer.organization=f.issuer.organization||y),w==="C"&&(f.issuer.country=f.issuer.country||y)}}}catch(p){console.warn("Could not extract subject/issuer as strings:",p)}try{if("subjectName"in r&&(e=r.subjectName)!=null&&e.getField){const p=r.subjectName;f.commonName=f.commonName||((t=p.getField("CN"))==null?void 0:t[0]),f.surname=f.surname||((i=p.getField("SN"))==null?void 0:i[0]),f.givenName=f.givenName||((n=p.getField("G"))==null?void 0:n[0]),f.serialNumber=f.serialNumber||((s=(o=p.getField("2.5.4.5"))==null?void 0:o[0])==null?void 0:s.replace("PNOLV-","")),f.country=f.country||((c=p.getField("C"))==null?void 0:c[0]),f.organization=f.organization||((l=p.getField("O"))==null?void 0:l[0])}}catch(p){console.warn("Could not extract fields using getField method:",p)}return!f.serialNumber&&r.serialNumber&&(f.serialNumber=r.serialNumber),f}function Qn(r){return la(this,null,function*(){try{let e=r;if(!r.includes("-----BEGIN CERTIFICATE-----")){const n=r.replace(/[\r\n\s]/g,"");e=ua(n)}const t=new V.X509Certificate(e),i=Zn(t);return{subject:{commonName:i.commonName,organization:i.organization,country:i.country,surname:i.surname,givenName:i.givenName,serialNumber:i.serialNumber},validFrom:i.validFrom,validTo:i.validTo,issuer:i.issuer,serialNumber:t.serialNumber}}catch(e){throw console.error("Certificate parsing error:",e),new Error("Failed to parse certificate: "+(e instanceof Error?e.message:String(e)))}})}function fa(r,e=new Date){const t="notBefore"in r?r.notBefore:r.validFrom,i="notAfter"in r?r.notAfter:r.validTo;return e<t?{isValid:!1,reason:`Certificate not yet valid. Valid from ${t.toISOString()}`}:e>i?{isValid:!1,reason:`Certificate expired. Valid until ${i.toISOString()}`}:{isValid:!0}}function ha(r){const{subject:e}=r;return e.givenName&&e.surname?`${e.givenName} ${e.surname}`:e.commonName?e.commonName:e.serialNumber||"Unknown Signer"}function pa(r){const{validFrom:e,validTo:t}=r,i=n=>n.toLocaleDateString(void 0,{year:"numeric",month:"long",day:"numeric"});return`${i(e)} to ${i(t)}`}function Wt(r){if(!r)return"";const e=r.replace(/\s+/g,""),t=[];for(let i=0;i<e.length;i+=64)t.push(e.substring(i,i+64));return`-----BEGIN CERTIFICATE-----
12
12
  ${t.join(`
13
13
  `)}
14
- -----END CERTIFICATE-----`}var ha=Object.defineProperty,pa=Object.defineProperties,da=Object.getOwnPropertyDescriptors,en=Object.getOwnPropertySymbols,ya=Object.prototype.hasOwnProperty,ga=Object.prototype.propertyIsEnumerable,tn=(r,e,t)=>e in r?ha(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,rn=(r,e)=>{for(var t in e||(e={}))ya.call(e,t)&&tn(r,t,e[t]);if(en)for(var t of en(e))ga.call(e,t)&&tn(r,t,e[t]);return r},on=(r,e)=>pa(r,da(e));function va(r){return Array.from(r.keys()).filter(e=>e.match(/META-INF\/signatures\d*\.xml$/)||e.match(/META-INF\/.*signatures.*\.xml$/i))}function ma(r,e){const t=new TextDecoder().decode(r),i=Jo().parseFromString(t,"application/xml"),o=Xt(i,"ds\\:Signature, Signature");if(o.length===0){if(console.warn(`No Signature elements found in ${e}`),t.includes("XAdESSignatures")){const s=i.documentElement;if(s){const l=K(s,"ds\\:Signature, Signature");if(l){let f=nn(l,i);return f.rawXml=t,f}}const c=wa(t);if(c)return on(rn({},c),{rawXml:t})}return null}let n=nn(o[0],i);return n.rawXml=t,n}function nn(r,e){var t,i,o,n,s;const c=r.getAttribute("Id")||"unknown",l=K(r,"ds\\:SignedInfo, SignedInfo");if(!l)throw new Error("SignedInfo element not found");const f=K(l,"ds\\:CanonicalizationMethod, CanonicalizationMethod");let p=Je.default;f&&(p=f.getAttribute("Algorithm")||p);let d="";d=sa(l);const w=K(l,"ds\\:SignatureMethod, SignatureMethod"),y=(w==null?void 0:w.getAttribute("Algorithm"))||"",g=K(r,"ds\\:SignatureValue, SignatureValue"),B=((t=g==null?void 0:g.textContent)==null?void 0:t.replace(/\s+/g,""))||"";let m="",S="",$=[],vt,je;const Gt=K(r,"ds\\:KeyInfo, KeyInfo");if(Gt){const _=K(Gt,"ds\\:X509Data, X509Data");if(_){const X=Xt(_,"ds\\:X509Certificate, X509Certificate");if(X.length>0){m=((i=X[0].textContent)==null?void 0:i.replace(/\s+/g,""))||"";for(let Ue=1;Ue<X.length;Ue++){const be=((o=X[Ue].textContent)==null?void 0:o.replace(/\s+/g,""))||"";be&&$.push(Wt(be))}}}}if(!m){const _=K(r,"ds\\:X509Certificate, X509Certificate");_&&(m=((n=_.textContent)==null?void 0:n.replace(/\s+/g,""))||"")}const O=K(e,"xades\\:CertificateValues, CertificateValues");if(O){const _=Xt(O,"xades\\:EncapsulatedX509Certificate, EncapsulatedX509Certificate");for(const X of _){const Ue=((s=X.textContent)==null?void 0:s.replace(/\s+/g,""))||"";if(Ue){const be=Wt(Ue);$.includes(be)||$.push(be)}}}if(m){S=Wt(m);try{const _=new V.X509Certificate(S),X=_.publicKey.algorithm;je=on(rn({algorithm:X.name},"namedCurve"in X?{namedCurve:X.namedCurve}:{}),{rawData:_.publicKey.rawData}),vt=Zo(_)}catch(_){console.error("Failed to extract certificate information:",_)}}const I=K(e,"xades\\:SigningTime, SigningTime"),M=I&&I.textContent?new Date(I.textContent.trim()):new Date,ye=[],zt={},Zs={},tl=Xt(l,"ds\\:Reference, Reference");for(const _ of tl){const X=_.getAttribute("URI")||"",Ue=_.getAttribute("Type")||"";if(!X||X.startsWith("#")||Ue.includes("SignedProperties"))continue;let be=X;try{be=decodeURIComponent(X)}catch(ti){console.error(`Failed to decode URI: ${X}`,ti)}const zo=be.startsWith("./")?be.substring(2):be;ye.push(zo);const ea=K(_,"ds\\:DigestMethod, DigestMethod");if(ea){const ti=ea.getAttribute("Algorithm");ti&&(Zs[zo]=ti)}const Xo=K(_,"ds\\:DigestValue, DigestValue");Xo&&Xo.textContent&&(zt[zo]=Xo.textContent.replace(/\s+/g,""))}let Qs;const Go=K(e,"xades\\:EncapsulatedTimeStamp, EncapsulatedTimeStamp");return Go&&Go.textContent&&(Qs=Go.textContent.replace(/\s+/g,"")),{id:c,signingTime:M,certificate:m,certificatePEM:S,certificateChain:$.length>0?$:void 0,publicKey:je,signerInfo:vt,signedChecksums:zt,digestAlgorithms:Zs,references:ye,algorithm:y,signatureValue:B,signedInfoXml:d,canonicalizationMethod:p,signatureTimestamp:Qs}}function wa(r){try{const e=r.match(/<ds:Signature[^>]*Id=["']([^"']*)["']/),t=e&&e[1]?e[1]:"unknown",i=r.match(/<ds:SignatureValue[^>]*>([\s\S]*?)<\/ds:SignatureValue>/),o=i&&i[1]?i[1].replace(/\s+/g,""):"",n=r.match(/<ds:X509Certificate>([\s\S]*?)<\/ds:X509Certificate>/),s=n&&n[1]?n[1].replace(/\s+/g,""):"",c=r.match(/<ds:SignatureMethod[^>]*Algorithm=["']([^"']*)["']/),l=c&&c[1]?c[1]:"",f=r.match(/<xades:SigningTime>([\s\S]*?)<\/xades:SigningTime>/),p=f&&f[1]?new Date(f[1].trim()):new Date,d=[],w={},y=/<ds:Reference[^>]*URI=["']([^#][^"']*)["'][^>]*>[\s\S]*?<ds:DigestValue>([\s\S]*?)<\/ds:DigestValue>/g;let g;for(;(g=y.exec(r))!==null;)if(g[1]&&!g[1].startsWith("#")){const m=decodeURIComponent(g[1]);d.push(m),g[2]&&(w[m]=g[2].replace(/\s+/g,""))}const B=Wt(s);return{id:t,signingTime:p,certificate:s,certificatePEM:B,signedChecksums:w,references:d,algorithm:l,signatureValue:o}}catch(e){return console.error("Error in fallback text parsing:",e),null}}function ba(r){try{const e=R.unzipSync(r),t=new Map,i=[],o=[];Object.entries(e).forEach(([f,p])=>{t.set(f,p),f.startsWith("META-INF/")||f==="mimetype"?o.push(f):i.push(f)});const n=[],s=va(t),c=new Set;for(const f of s){const p=t.get(f);if(p)try{const d=ma(p,f);d&&(n.push(d),d.references&&d.references.length>0&&d.references.forEach(w=>{t.has(w)&&c.add(w)}))}catch(d){console.error(`Error parsing signature ${f}:`,d)}}const l=Array.from(c);return{files:t,documentFileList:i,metadataFileList:o,signedFileList:l,signatures:n}}catch(e){throw new Error(`Failed to parse eDoc container: ${e instanceof Error?e.message:String(e)}`)}}function Aa(r){const e=()=>{},t=new Uint8Array(r);if(t[0]!==48)return r;const i=[6,9,42,134,72,134,247,13,1,1,1];let o=-1;for(let g=0;g<=t.length-i.length;g++){let B=!0;for(let m=0;m<i.length;m++)if(t[g+m]!==i[m]){B=!1;break}if(B){o=g;break}}if(o===-1)return r;let n=-1;for(let g=o+i.length;g<t.length;g++)if(t[g]===3){n=g;break}if(n===-1)return r;let s=0;(t[n+1]&128)===0?s=1:s=1+(t[n+1]&127);const c=n+1+s;if(c>=t.length)return r;const l=c+1;if(l>=t.length||t[l]!==48)return r;let f=0;(t[l+1]&128)===0?f=1:f=1+(t[l+1]&127);const p=l+1+f;if(p>=t.length||t[p]!==2)return r;let d=0,w=0;if((t[p+1]&128)===0)w=t[p+1],d=1;else{const g=t[p+1]&127;d=1+g,w=0;for(let B=0;B<g;B++)w=w<<8|t[p+2+B]}const y=p+1+d;if(y>=t.length)return r;if((t[y]&128)!==0){const g=new Uint8Array(t.length+1);if(g.set(t.slice(0,y)),g[y]=0,g.set(t.slice(y),y+1),(t[p+1]&128)===0)g[p+1]=t[p+1]+1;else{const B=t[p+1]&127;let m=0;for(let S=0;S<B;S++)m=m<<8|t[p+2+S];m+=1;for(let S=B-1;S>=0;S--)g[p+2+S]=m&255,m>>=8}if((t[l+1]&128)===0)g[l+1]=t[l+1]+1;else{const B=t[l+1]&127;let m=0;for(let S=0;S<B;S++)m=m<<8|t[l+2+S];m+=1;for(let S=B-1;S>=0;S--)g[l+2+S]=m&255,m>>=8}if((t[n+1]&128)===0)g[n+1]=t[n+1]+1;else{const B=t[n+1]&127;let m=0;for(let S=0;S<B;S++)m=m<<8|t[n+2+S];m+=1;for(let S=B-1;S>=0;S--)g[n+2+S]=m&255,m>>=8}if((t[1]&128)===0)g[1]=t[1]+1;else{const B=t[1]&127;let m=0;for(let S=0;S<B;S++)m=m<<8|t[2+S];m+=1;for(let S=B-1;S>=0;S--)g[2+S]=m&255,m>>=8}return e("Fixed key length: "+g.length),g.buffer}return r}const Sa={ocspEnabled:!0,crlEnabled:!0,ocspTimeout:5e3,crlTimeout:1e4};/*!
14
+ -----END CERTIFICATE-----`}var da=Object.defineProperty,ya=Object.defineProperties,ga=Object.getOwnPropertyDescriptors,eo=Object.getOwnPropertySymbols,va=Object.prototype.hasOwnProperty,ma=Object.prototype.propertyIsEnumerable,to=(r,e,t)=>e in r?da(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,ro=(r,e)=>{for(var t in e||(e={}))va.call(e,t)&&to(r,t,e[t]);if(eo)for(var t of eo(e))ma.call(e,t)&&to(r,t,e[t]);return r},io=(r,e)=>ya(r,ga(e));function wa(r){return Array.from(r.keys()).filter(e=>e.match(/META-INF\/signatures\d*\.xml$/)||e.match(/META-INF\/.*signatures.*\.xml$/i))}function ba(r,e){const t=new TextDecoder().decode(r),i=Jn().parseFromString(t,"application/xml"),n=Xt(i,"ds\\:Signature, Signature");if(n.length===0){if(console.warn(`No Signature elements found in ${e}`),t.includes("XAdESSignatures")){const s=i.documentElement;if(s){const l=K(s,"ds\\:Signature, Signature");if(l){let f=no(l,i);return f.rawXml=t,f}}const c=Aa(t);if(c)return io(ro({},c),{rawXml:t})}return null}let o=no(n[0],i);return o.rawXml=t,o}function no(r,e){var t,i,n,o,s;const c=r.getAttribute("Id")||"unknown",l=K(r,"ds\\:SignedInfo, SignedInfo");if(!l)throw new Error("SignedInfo element not found");const f=K(l,"ds\\:CanonicalizationMethod, CanonicalizationMethod");let p=Ye.default;f&&(p=f.getAttribute("Algorithm")||p);let d="";d=ca(l);const w=K(l,"ds\\:SignatureMethod, SignatureMethod"),y=(w==null?void 0:w.getAttribute("Algorithm"))||"",g=K(r,"ds\\:SignatureValue, SignatureValue"),B=((t=g==null?void 0:g.textContent)==null?void 0:t.replace(/\s+/g,""))||"";let m;if(g)try{m=new M().canonicalize(g)}catch(P){}let S="",F="",Oe=[],Ue,Gt;const O=K(r,"ds\\:KeyInfo, KeyInfo");if(O){const P=K(O,"ds\\:X509Data, X509Data");if(P){const X=Xt(P,"ds\\:X509Certificate, X509Certificate");if(X.length>0){S=((i=X[0].textContent)==null?void 0:i.replace(/\s+/g,""))||"";for(let De=1;De<X.length;De++){const be=((n=X[De].textContent)==null?void 0:n.replace(/\s+/g,""))||"";be&&Oe.push(Wt(be))}}}}if(!S){const P=K(r,"ds\\:X509Certificate, X509Certificate");P&&(S=((o=P.textContent)==null?void 0:o.replace(/\s+/g,""))||"")}const I=K(e,"xades\\:CertificateValues, CertificateValues");if(I){const P=Xt(I,"xades\\:EncapsulatedX509Certificate, EncapsulatedX509Certificate");for(const X of P){const De=((s=X.textContent)==null?void 0:s.replace(/\s+/g,""))||"";if(De){const be=Wt(De);Oe.includes(be)||Oe.push(be)}}}if(S){F=Wt(S);try{const P=new V.X509Certificate(F),X=P.publicKey.algorithm;Gt=io(ro({algorithm:X.name},"namedCurve"in X?{namedCurve:X.namedCurve}:{}),{rawData:P.publicKey.rawData}),Ue=Zn(P)}catch(P){console.error("Failed to extract certificate information:",P)}}const L=K(e,"xades\\:SigningTime, SigningTime"),we=L&&L.textContent?new Date(L.textContent.trim()):new Date,zt=[],Qs={},ea={},cl=Xt(l,"ds\\:Reference, Reference");for(const P of cl){const X=P.getAttribute("URI")||"",De=P.getAttribute("Type")||"";if(!X||X.startsWith("#")||De.includes("SignedProperties"))continue;let be=X;try{be=decodeURIComponent(X)}catch(ti){console.error(`Failed to decode URI: ${X}`,ti)}const zn=be.startsWith("./")?be.substring(2):be;zt.push(zn);const ra=K(P,"ds\\:DigestMethod, DigestMethod");if(ra){const ti=ra.getAttribute("Algorithm");ti&&(ea[zn]=ti)}const Xn=K(P,"ds\\:DigestValue, DigestValue");Xn&&Xn.textContent&&(Qs[zn]=Xn.textContent.replace(/\s+/g,""))}let ta;const Gn=K(e,"xades\\:EncapsulatedTimeStamp, EncapsulatedTimeStamp");return Gn&&Gn.textContent&&(ta=Gn.textContent.replace(/\s+/g,"")),{id:c,signingTime:we,certificate:S,certificatePEM:F,certificateChain:Oe.length>0?Oe:void 0,publicKey:Gt,signerInfo:Ue,signedChecksums:Qs,digestAlgorithms:ea,references:zt,algorithm:y,signatureValue:B,canonicalSignatureValue:m,signedInfoXml:d,canonicalizationMethod:p,signatureTimestamp:ta}}function Aa(r){try{const e=r.match(/<ds:Signature[^>]*Id=["']([^"']*)["']/),t=e&&e[1]?e[1]:"unknown",i=r.match(/<ds:SignatureValue[^>]*>([\s\S]*?)<\/ds:SignatureValue>/),n=i&&i[1]?i[1].replace(/\s+/g,""):"",o=r.match(/<ds:X509Certificate>([\s\S]*?)<\/ds:X509Certificate>/),s=o&&o[1]?o[1].replace(/\s+/g,""):"",c=r.match(/<ds:SignatureMethod[^>]*Algorithm=["']([^"']*)["']/),l=c&&c[1]?c[1]:"",f=r.match(/<xades:SigningTime>([\s\S]*?)<\/xades:SigningTime>/),p=f&&f[1]?new Date(f[1].trim()):new Date,d=[],w={},y=/<ds:Reference[^>]*URI=["']([^#][^"']*)["'][^>]*>[\s\S]*?<ds:DigestValue>([\s\S]*?)<\/ds:DigestValue>/g;let g;for(;(g=y.exec(r))!==null;)if(g[1]&&!g[1].startsWith("#")){const m=decodeURIComponent(g[1]);d.push(m),g[2]&&(w[m]=g[2].replace(/\s+/g,""))}const B=Wt(s);return{id:t,signingTime:p,certificate:s,certificatePEM:B,signedChecksums:w,references:d,algorithm:l,signatureValue:n}}catch(e){return console.error("Error in fallback text parsing:",e),null}}function Sa(r){try{const e=R.unzipSync(r),t=new Map,i=[],n=[];Object.entries(e).forEach(([f,p])=>{t.set(f,p),f.startsWith("META-INF/")||f==="mimetype"?n.push(f):i.push(f)});const o=[],s=wa(t),c=new Set;for(const f of s){const p=t.get(f);if(p)try{const d=ba(p,f);d&&(o.push(d),d.references&&d.references.length>0&&d.references.forEach(w=>{t.has(w)&&c.add(w)}))}catch(d){console.error(`Error parsing signature ${f}:`,d)}}const l=Array.from(c);return{files:t,documentFileList:i,metadataFileList:n,signedFileList:l,signatures:o}}catch(e){throw new Error(`Failed to parse eDoc container: ${e instanceof Error?e.message:String(e)}`)}}function Ba(r){const e=()=>{},t=new Uint8Array(r);if(t[0]!==48)return r;const i=[6,9,42,134,72,134,247,13,1,1,1];let n=-1;for(let g=0;g<=t.length-i.length;g++){let B=!0;for(let m=0;m<i.length;m++)if(t[g+m]!==i[m]){B=!1;break}if(B){n=g;break}}if(n===-1)return r;let o=-1;for(let g=n+i.length;g<t.length;g++)if(t[g]===3){o=g;break}if(o===-1)return r;let s=0;(t[o+1]&128)===0?s=1:s=1+(t[o+1]&127);const c=o+1+s;if(c>=t.length)return r;const l=c+1;if(l>=t.length||t[l]!==48)return r;let f=0;(t[l+1]&128)===0?f=1:f=1+(t[l+1]&127);const p=l+1+f;if(p>=t.length||t[p]!==2)return r;let d=0,w=0;if((t[p+1]&128)===0)w=t[p+1],d=1;else{const g=t[p+1]&127;d=1+g,w=0;for(let B=0;B<g;B++)w=w<<8|t[p+2+B]}const y=p+1+d;if(y>=t.length)return r;if((t[y]&128)!==0){const g=new Uint8Array(t.length+1);if(g.set(t.slice(0,y)),g[y]=0,g.set(t.slice(y),y+1),(t[p+1]&128)===0)g[p+1]=t[p+1]+1;else{const B=t[p+1]&127;let m=0;for(let S=0;S<B;S++)m=m<<8|t[p+2+S];m+=1;for(let S=B-1;S>=0;S--)g[p+2+S]=m&255,m>>=8}if((t[l+1]&128)===0)g[l+1]=t[l+1]+1;else{const B=t[l+1]&127;let m=0;for(let S=0;S<B;S++)m=m<<8|t[l+2+S];m+=1;for(let S=B-1;S>=0;S--)g[l+2+S]=m&255,m>>=8}if((t[o+1]&128)===0)g[o+1]=t[o+1]+1;else{const B=t[o+1]&127;let m=0;for(let S=0;S<B;S++)m=m<<8|t[o+2+S];m+=1;for(let S=B-1;S>=0;S--)g[o+2+S]=m&255,m>>=8}if((t[1]&128)===0)g[1]=t[1]+1;else{const B=t[1]&127;let m=0;for(let S=0;S<B;S++)m=m<<8|t[2+S];m+=1;for(let S=B-1;S>=0;S--)g[2+S]=m&255,m>>=8}return e("Fixed key length: "+g.length),g.buffer}return r}const ka={ocspEnabled:!0,crlEnabled:!0,ocspTimeout:5e3,crlTimeout:1e4};/*!
15
15
  * MIT License
16
16
  *
17
17
  * Copyright (c) 2017-2024 Peculiar Ventures, LLC
@@ -34,9 +34,9 @@ ${t.join(`
34
34
  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
35
35
  * SOFTWARE.
36
36
  *
37
- */const Ba="[object ArrayBuffer]";class N{static isArrayBuffer(e){return Object.prototype.toString.call(e)===Ba}static toArrayBuffer(e){return this.isArrayBuffer(e)?e:e.byteLength===e.buffer.byteLength||e.byteOffset===0&&e.byteLength===e.buffer.byteLength?e.buffer:this.toUint8Array(e.buffer).slice(e.byteOffset,e.byteOffset+e.byteLength).buffer}static toUint8Array(e){return this.toView(e,Uint8Array)}static toView(e,t){if(e.constructor===t)return e;if(this.isArrayBuffer(e))return new t(e);if(this.isArrayBufferView(e))return new t(e.buffer,e.byteOffset,e.byteLength);throw new TypeError("The provided value is not of type '(ArrayBuffer or ArrayBufferView)'")}static isBufferSource(e){return this.isArrayBufferView(e)||this.isArrayBuffer(e)}static isArrayBufferView(e){return ArrayBuffer.isView(e)||e&&this.isArrayBuffer(e.buffer)}static isEqual(e,t){const i=N.toUint8Array(e),o=N.toUint8Array(t);if(i.length!==o.byteLength)return!1;for(let n=0;n<i.length;n++)if(i[n]!==o[n])return!1;return!0}static concat(...e){let t;Array.isArray(e[0])&&!(e[1]instanceof Function)||Array.isArray(e[0])&&e[1]instanceof Function?t=e[0]:e[e.length-1]instanceof Function?t=e.slice(0,e.length-1):t=e;let i=0;for(const s of t)i+=s.byteLength;const o=new Uint8Array(i);let n=0;for(const s of t){const c=this.toUint8Array(s);o.set(c,n),n+=c.length}return e[e.length-1]instanceof Function?this.toView(o,e[e.length-1]):o.buffer}}const ii="string",ka=/^[0-9a-f\s]+$/i,xa=/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/,Na=/^[a-zA-Z0-9-_]+$/;class sn{static fromString(e){const t=unescape(encodeURIComponent(e)),i=new Uint8Array(t.length);for(let o=0;o<t.length;o++)i[o]=t.charCodeAt(o);return i.buffer}static toString(e){const t=N.toUint8Array(e);let i="";for(let n=0;n<t.length;n++)i+=String.fromCharCode(t[n]);return decodeURIComponent(escape(i))}}class ge{static toString(e,t=!1){const i=N.toArrayBuffer(e),o=new DataView(i);let n="";for(let s=0;s<i.byteLength;s+=2){const c=o.getUint16(s,t);n+=String.fromCharCode(c)}return n}static fromString(e,t=!1){const i=new ArrayBuffer(e.length*2),o=new DataView(i);for(let n=0;n<e.length;n++)o.setUint16(n*2,e.charCodeAt(n),t);return i}}class U{static isHex(e){return typeof e===ii&&ka.test(e)}static isBase64(e){return typeof e===ii&&xa.test(e)}static isBase64Url(e){return typeof e===ii&&Na.test(e)}static ToString(e,t="utf8"){const i=N.toUint8Array(e);switch(t.toLowerCase()){case"utf8":return this.ToUtf8String(i);case"binary":return this.ToBinary(i);case"hex":return this.ToHex(i);case"base64":return this.ToBase64(i);case"base64url":return this.ToBase64Url(i);case"utf16le":return ge.toString(i,!0);case"utf16":case"utf16be":return ge.toString(i);default:throw new Error(`Unknown type of encoding '${t}'`)}}static FromString(e,t="utf8"){if(!e)return new ArrayBuffer(0);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);case"utf16le":return ge.fromString(e,!0);case"utf16":case"utf16be":return ge.fromString(e);default:throw new Error(`Unknown type of encoding '${t}'`)}}static ToBase64(e){const t=N.toUint8Array(e);if(typeof btoa!="undefined"){const i=this.ToString(t,"binary");return btoa(i)}else return Buffer.from(t).toString("base64")}static FromBase64(e){const t=this.formatString(e);if(!t)return new ArrayBuffer(0);if(!U.isBase64(t))throw new TypeError("Argument 'base64Text' is not Base64 encoded");return typeof atob!="undefined"?this.FromBinary(atob(t)):new Uint8Array(Buffer.from(t,"base64")).buffer}static FromBase64Url(e){const t=this.formatString(e);if(!t)return new ArrayBuffer(0);if(!U.isBase64Url(t))throw new TypeError("Argument 'base64url' is not Base64Url encoded");return this.FromBase64(this.Base64Padding(t.replace(/\-/g,"+").replace(/\_/g,"/")))}static ToBase64Url(e){return this.ToBase64(e).replace(/\+/g,"-").replace(/\//g,"_").replace(/\=/g,"")}static FromUtf8String(e,t=U.DEFAULT_UTF8_ENCODING){switch(t){case"ascii":return this.FromBinary(e);case"utf8":return sn.fromString(e);case"utf16":case"utf16be":return ge.fromString(e);case"utf16le":case"usc2":return ge.fromString(e,!0);default:throw new Error(`Unknown type of encoding '${t}'`)}}static ToUtf8String(e,t=U.DEFAULT_UTF8_ENCODING){switch(t){case"ascii":return this.ToBinary(e);case"utf8":return sn.toString(e);case"utf16":case"utf16be":return ge.toString(e);case"utf16le":case"usc2":return ge.toString(e,!0);default:throw new Error(`Unknown type of encoding '${t}'`)}}static FromBinary(e){const t=e.length,i=new Uint8Array(t);for(let o=0;o<t;o++)i[o]=e.charCodeAt(o);return i.buffer}static ToBinary(e){const t=N.toUint8Array(e);let i="";for(let o=0;o<t.length;o++)i+=String.fromCharCode(t[o]);return i}static ToHex(e){const t=N.toUint8Array(e);let i="";const o=t.length;for(let n=0;n<o;n++){const s=t[n];s<16&&(i+="0"),i+=s.toString(16)}return i}static FromHex(e){let t=this.formatString(e);if(!t)return new ArrayBuffer(0);if(!U.isHex(t))throw new TypeError("Argument 'hexString' is not HEX encoded");t.length%2&&(t=`0${t}`);const i=new Uint8Array(t.length/2);for(let o=0;o<t.length;o=o+2){const n=t.slice(o,o+2);i[o/2]=parseInt(n,16)}return i.buffer}static ToUtf16String(e,t=!1){return ge.toString(e,t)}static FromUtf16String(e,t=!1){return ge.fromString(e,t)}static Base64Padding(e){const t=4-e.length%4;if(t<4)for(let i=0;i<t;i++)e+="=";return e}static formatString(e){return(e==null?void 0:e.replace(/[\n\r\t ]/g,""))||""}}U.DEFAULT_UTF8_ENCODING="utf8";function Ca(r,e){if(!(r&&e)||r.byteLength!==e.byteLength)return!1;const t=new Uint8Array(r),i=new Uint8Array(e);for(let o=0;o<r.byteLength;o++)if(t[o]!==i[o])return!1;return!0}/*!
37
+ */const xa="[object ArrayBuffer]";class N{static isArrayBuffer(e){return Object.prototype.toString.call(e)===xa}static toArrayBuffer(e){return this.isArrayBuffer(e)?e:e.byteLength===e.buffer.byteLength||e.byteOffset===0&&e.byteLength===e.buffer.byteLength?e.buffer:this.toUint8Array(e.buffer).slice(e.byteOffset,e.byteOffset+e.byteLength).buffer}static toUint8Array(e){return this.toView(e,Uint8Array)}static toView(e,t){if(e.constructor===t)return e;if(this.isArrayBuffer(e))return new t(e);if(this.isArrayBufferView(e))return new t(e.buffer,e.byteOffset,e.byteLength);throw new TypeError("The provided value is not of type '(ArrayBuffer or ArrayBufferView)'")}static isBufferSource(e){return this.isArrayBufferView(e)||this.isArrayBuffer(e)}static isArrayBufferView(e){return ArrayBuffer.isView(e)||e&&this.isArrayBuffer(e.buffer)}static isEqual(e,t){const i=N.toUint8Array(e),n=N.toUint8Array(t);if(i.length!==n.byteLength)return!1;for(let o=0;o<i.length;o++)if(i[o]!==n[o])return!1;return!0}static concat(...e){let t;Array.isArray(e[0])&&!(e[1]instanceof Function)||Array.isArray(e[0])&&e[1]instanceof Function?t=e[0]:e[e.length-1]instanceof Function?t=e.slice(0,e.length-1):t=e;let i=0;for(const s of t)i+=s.byteLength;const n=new Uint8Array(i);let o=0;for(const s of t){const c=this.toUint8Array(s);n.set(c,o),o+=c.length}return e[e.length-1]instanceof Function?this.toView(n,e[e.length-1]):n.buffer}}const ii="string",Na=/^[0-9a-f\s]+$/i,Ca=/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/,Ea=/^[a-zA-Z0-9-_]+$/;class oo{static fromString(e){const t=unescape(encodeURIComponent(e)),i=new Uint8Array(t.length);for(let n=0;n<t.length;n++)i[n]=t.charCodeAt(n);return i.buffer}static toString(e){const t=N.toUint8Array(e);let i="";for(let o=0;o<t.length;o++)i+=String.fromCharCode(t[o]);return decodeURIComponent(escape(i))}}class ye{static toString(e,t=!1){const i=N.toArrayBuffer(e),n=new DataView(i);let o="";for(let s=0;s<i.byteLength;s+=2){const c=n.getUint16(s,t);o+=String.fromCharCode(c)}return o}static fromString(e,t=!1){const i=new ArrayBuffer(e.length*2),n=new DataView(i);for(let o=0;o<e.length;o++)n.setUint16(o*2,e.charCodeAt(o),t);return i}}class U{static isHex(e){return typeof e===ii&&Na.test(e)}static isBase64(e){return typeof e===ii&&Ca.test(e)}static isBase64Url(e){return typeof e===ii&&Ea.test(e)}static ToString(e,t="utf8"){const i=N.toUint8Array(e);switch(t.toLowerCase()){case"utf8":return this.ToUtf8String(i);case"binary":return this.ToBinary(i);case"hex":return this.ToHex(i);case"base64":return this.ToBase64(i);case"base64url":return this.ToBase64Url(i);case"utf16le":return ye.toString(i,!0);case"utf16":case"utf16be":return ye.toString(i);default:throw new Error(`Unknown type of encoding '${t}'`)}}static FromString(e,t="utf8"){if(!e)return new ArrayBuffer(0);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);case"utf16le":return ye.fromString(e,!0);case"utf16":case"utf16be":return ye.fromString(e);default:throw new Error(`Unknown type of encoding '${t}'`)}}static ToBase64(e){const t=N.toUint8Array(e);if(typeof btoa!="undefined"){const i=this.ToString(t,"binary");return btoa(i)}else return Buffer.from(t).toString("base64")}static FromBase64(e){const t=this.formatString(e);if(!t)return new ArrayBuffer(0);if(!U.isBase64(t))throw new TypeError("Argument 'base64Text' is not Base64 encoded");return typeof atob!="undefined"?this.FromBinary(atob(t)):new Uint8Array(Buffer.from(t,"base64")).buffer}static FromBase64Url(e){const t=this.formatString(e);if(!t)return new ArrayBuffer(0);if(!U.isBase64Url(t))throw new TypeError("Argument 'base64url' is not Base64Url encoded");return this.FromBase64(this.Base64Padding(t.replace(/\-/g,"+").replace(/\_/g,"/")))}static ToBase64Url(e){return this.ToBase64(e).replace(/\+/g,"-").replace(/\//g,"_").replace(/\=/g,"")}static FromUtf8String(e,t=U.DEFAULT_UTF8_ENCODING){switch(t){case"ascii":return this.FromBinary(e);case"utf8":return oo.fromString(e);case"utf16":case"utf16be":return ye.fromString(e);case"utf16le":case"usc2":return ye.fromString(e,!0);default:throw new Error(`Unknown type of encoding '${t}'`)}}static ToUtf8String(e,t=U.DEFAULT_UTF8_ENCODING){switch(t){case"ascii":return this.ToBinary(e);case"utf8":return oo.toString(e);case"utf16":case"utf16be":return ye.toString(e);case"utf16le":case"usc2":return ye.toString(e,!0);default:throw new Error(`Unknown type of encoding '${t}'`)}}static FromBinary(e){const t=e.length,i=new Uint8Array(t);for(let n=0;n<t;n++)i[n]=e.charCodeAt(n);return i.buffer}static ToBinary(e){const t=N.toUint8Array(e);let i="";for(let n=0;n<t.length;n++)i+=String.fromCharCode(t[n]);return i}static ToHex(e){const t=N.toUint8Array(e);let i="";const n=t.length;for(let o=0;o<n;o++){const s=t[o];s<16&&(i+="0"),i+=s.toString(16)}return i}static FromHex(e){let t=this.formatString(e);if(!t)return new ArrayBuffer(0);if(!U.isHex(t))throw new TypeError("Argument 'hexString' is not HEX encoded");t.length%2&&(t=`0${t}`);const i=new Uint8Array(t.length/2);for(let n=0;n<t.length;n=n+2){const o=t.slice(n,n+2);i[n/2]=parseInt(o,16)}return i.buffer}static ToUtf16String(e,t=!1){return ye.toString(e,t)}static FromUtf16String(e,t=!1){return ye.fromString(e,t)}static Base64Padding(e){const t=4-e.length%4;if(t<4)for(let i=0;i<t;i++)e+="=";return e}static formatString(e){return(e==null?void 0:e.replace(/[\n\r\t ]/g,""))||""}}U.DEFAULT_UTF8_ENCODING="utf8";function Ia(r,e){if(!(r&&e)||r.byteLength!==e.byteLength)return!1;const t=new Uint8Array(r),i=new Uint8Array(e);for(let n=0;n<r.byteLength;n++)if(t[n]!==i[n])return!1;return!0}/*!
38
38
  Copyright (c) Peculiar Ventures, LLC
39
- */function Ke(r,e){let t=0;if(r.length===1)return r[0];for(let i=r.length-1;i>=0;i--)t+=r[r.length-1-i]*Math.pow(2,e*i);return t}function De(r,e,t=-1){const i=t;let o=r,n=0,s=Math.pow(2,e);for(let c=1;c<8;c++){if(r<s){let l;if(i<0)l=new ArrayBuffer(c),n=c;else{if(i<c)return new ArrayBuffer(0);l=new ArrayBuffer(i),n=i}const f=new Uint8Array(l);for(let p=c-1;p>=0;p--){const d=Math.pow(2,p*e);f[n-p-1]=Math.floor(o/d),o-=f[n-p-1]*d}return l}s*=Math.pow(2,e)}return new ArrayBuffer(0)}function oi(...r){let e=0,t=0;for(const n of r)e+=n.length;const i=new ArrayBuffer(e),o=new Uint8Array(i);for(const n of r)o.set(n,t),t+=n.length;return o}function an(){const r=new Uint8Array(this.valueHex);if(this.valueHex.byteLength>=2){const c=r[0]===255&&r[1]&128,l=r[0]===0&&(r[1]&128)===0;(c||l)&&this.warnings.push("Needlessly long format")}const e=new ArrayBuffer(this.valueHex.byteLength),t=new Uint8Array(e);for(let c=0;c<this.valueHex.byteLength;c++)t[c]=0;t[0]=r[0]&128;const i=Ke(t,8),o=new ArrayBuffer(this.valueHex.byteLength),n=new Uint8Array(o);for(let c=0;c<this.valueHex.byteLength;c++)n[c]=r[c];return n[0]&=127,Ke(n,8)-i}function Ea(r){const e=r<0?r*-1:r;let t=128;for(let i=1;i<8;i++){if(e<=t){if(r<0){const s=t-e,c=De(s,8,i),l=new Uint8Array(c);return l[0]|=128,c}let o=De(e,8,i),n=new Uint8Array(o);if(n[0]&128){const s=o.slice(0),c=new Uint8Array(s);o=new ArrayBuffer(o.byteLength+1),n=new Uint8Array(o);for(let l=0;l<s.byteLength;l++)n[l+1]=c[l];n[0]=0}return o}t*=Math.pow(2,8)}return new ArrayBuffer(0)}function Ia(r,e){if(r.byteLength!==e.byteLength)return!1;const t=new Uint8Array(r),i=new Uint8Array(e);for(let o=0;o<t.length;o++)if(t[o]!==i[o])return!1;return!0}function ee(r,e){const t=r.toString(10);if(e<t.length)return"";const i=e-t.length,o=new Array(i);for(let s=0;s<i;s++)o[s]="0";return o.join("").concat(t)}/*!
39
+ */function Ze(r,e){let t=0;if(r.length===1)return r[0];for(let i=r.length-1;i>=0;i--)t+=r[r.length-1-i]*Math.pow(2,e*i);return t}function Re(r,e,t=-1){const i=t;let n=r,o=0,s=Math.pow(2,e);for(let c=1;c<8;c++){if(r<s){let l;if(i<0)l=new ArrayBuffer(c),o=c;else{if(i<c)return new ArrayBuffer(0);l=new ArrayBuffer(i),o=i}const f=new Uint8Array(l);for(let p=c-1;p>=0;p--){const d=Math.pow(2,p*e);f[o-p-1]=Math.floor(n/d),n-=f[o-p-1]*d}return l}s*=Math.pow(2,e)}return new ArrayBuffer(0)}function ni(...r){let e=0,t=0;for(const o of r)e+=o.length;const i=new ArrayBuffer(e),n=new Uint8Array(i);for(const o of r)n.set(o,t),t+=o.length;return n}function so(){const r=new Uint8Array(this.valueHex);if(this.valueHex.byteLength>=2){const c=r[0]===255&&r[1]&128,l=r[0]===0&&(r[1]&128)===0;(c||l)&&this.warnings.push("Needlessly long format")}const e=new ArrayBuffer(this.valueHex.byteLength),t=new Uint8Array(e);for(let c=0;c<this.valueHex.byteLength;c++)t[c]=0;t[0]=r[0]&128;const i=Ze(t,8),n=new ArrayBuffer(this.valueHex.byteLength),o=new Uint8Array(n);for(let c=0;c<this.valueHex.byteLength;c++)o[c]=r[c];return o[0]&=127,Ze(o,8)-i}function Oa(r){const e=r<0?r*-1:r;let t=128;for(let i=1;i<8;i++){if(e<=t){if(r<0){const s=t-e,c=Re(s,8,i),l=new Uint8Array(c);return l[0]|=128,c}let n=Re(e,8,i),o=new Uint8Array(n);if(o[0]&128){const s=n.slice(0),c=new Uint8Array(s);n=new ArrayBuffer(n.byteLength+1),o=new Uint8Array(n);for(let l=0;l<s.byteLength;l++)o[l+1]=c[l];o[0]=0}return n}t*=Math.pow(2,8)}return new ArrayBuffer(0)}function Ta(r,e){if(r.byteLength!==e.byteLength)return!1;const t=new Uint8Array(r),i=new Uint8Array(e);for(let n=0;n<t.length;n++)if(t[n]!==i[n])return!1;return!0}function ee(r,e){const t=r.toString(10);if(e<t.length)return"";const i=e-t.length,n=new Array(i);for(let s=0;s<i;s++)n[s]="0";return n.join("").concat(t)}/*!
40
40
  * Copyright (c) 2014, GMO GlobalSign
41
41
  * Copyright (c) 2015-2022, Peculiar Ventures
42
42
  * All rights reserved.
@@ -68,15 +68,15 @@ ${t.join(`
68
68
  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
69
69
  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
70
70
  *
71
- */function Jt(){if(typeof BigInt=="undefined")throw new Error("BigInt is not defined. Your environment doesn't implement BigInt.")}function ni(r){let e=0,t=0;for(let o=0;o<r.length;o++){const n=r[o];e+=n.byteLength}const i=new Uint8Array(e);for(let o=0;o<r.length;o++){const n=r[o];i.set(new Uint8Array(n),t),t+=n.byteLength}return i.buffer}function Ae(r,e,t,i){return e instanceof Uint8Array?e.byteLength?t<0?(r.error="Wrong parameter: inputOffset less than zero",!1):i<0?(r.error="Wrong parameter: inputLength less than zero",!1):e.byteLength-t-i<0?(r.error="End of input reached before message was fully decoded (inconsistent offset and length values)",!1):!0:(r.error="Wrong parameter: inputBuffer has zero length",!1):(r.error="Wrong parameter: inputBuffer must be 'Uint8Array'",!1)}class Kt{constructor(){this.items=[]}write(e){this.items.push(e)}final(){return ni(this.items)}}const wt=[new Uint8Array([1])],cn="0123456789",si="name",ln="valueHexView",Oa="isHexOnly",Ta="idBlock",Va="tagClass",ja="tagNumber",Ua="isConstructed",Da="fromBER",Ra="toBER",La="local",Y="",se=new ArrayBuffer(0),Yt=new Uint8Array(0),bt="EndOfContent",un="OCTET STRING",fn="BIT STRING";function ve(r){var e;return e=class extends r{get valueHex(){return this.valueHexView.slice().buffer}set valueHex(i){this.valueHexView=new Uint8Array(i)}constructor(...i){var o;super(...i);const n=i[0]||{};this.isHexOnly=(o=n.isHexOnly)!==null&&o!==void 0?o:!1,this.valueHexView=n.valueHex?N.toUint8Array(n.valueHex):Yt}fromBER(i,o,n){const s=i instanceof ArrayBuffer?new Uint8Array(i):i;if(!Ae(this,s,o,n))return-1;const c=o+n;return this.valueHexView=s.subarray(o,c),this.valueHexView.length?(this.blockLength=n,c):(this.warnings.push("Zero buffer length"),o)}toBER(i=!1){return this.isHexOnly?i?new ArrayBuffer(this.valueHexView.byteLength):this.valueHexView.byteLength===this.valueHexView.buffer.byteLength?this.valueHexView.buffer:this.valueHexView.slice().buffer:(this.error="Flag 'isHexOnly' is not set, abort",se)}toJSON(){return L(T({},super.toJSON()),{isHexOnly:this.isHexOnly,valueHex:U.ToHex(this.valueHexView)})}},e.NAME="hexBlock",e}class Re{static blockName(){return this.NAME}get valueBeforeDecode(){return this.valueBeforeDecodeView.slice().buffer}set valueBeforeDecode(e){this.valueBeforeDecodeView=new Uint8Array(e)}constructor({blockLength:e=0,error:t=Y,warnings:i=[],valueBeforeDecode:o=Yt}={}){this.blockLength=e,this.error=t,this.warnings=i,this.valueBeforeDecodeView=N.toUint8Array(o)}toJSON(){return{blockName:this.constructor.NAME,blockLength:this.blockLength,error:this.error,warnings:this.warnings,valueBeforeDecode:U.ToHex(this.valueBeforeDecodeView)}}}Re.NAME="baseBlock";class W extends Re{fromBER(e,t,i){throw TypeError("User need to make a specific function in a class which extends 'ValueBlock'")}toBER(e,t){throw TypeError("User need to make a specific function in a class which extends 'ValueBlock'")}}W.NAME="valueBlock";class hn extends ve(Re){constructor({idBlock:e={}}={}){var t,i,o,n;super(),e?(this.isHexOnly=(t=e.isHexOnly)!==null&&t!==void 0?t:!1,this.valueHexView=e.valueHex?N.toUint8Array(e.valueHex):Yt,this.tagClass=(i=e.tagClass)!==null&&i!==void 0?i:-1,this.tagNumber=(o=e.tagNumber)!==null&&o!==void 0?o:-1,this.isConstructed=(n=e.isConstructed)!==null&&n!==void 0?n:!1):(this.tagClass=-1,this.tagNumber=-1,this.isConstructed=!1)}toBER(e=!1){let t=0;switch(this.tagClass){case 1:t|=0;break;case 2:t|=64;break;case 3:t|=128;break;case 4:t|=192;break;default:return this.error="Unknown tag class",se}if(this.isConstructed&&(t|=32),this.tagNumber<31&&!this.isHexOnly){const o=new Uint8Array(1);if(!e){let n=this.tagNumber;n&=31,t|=n,o[0]=t}return o.buffer}if(!this.isHexOnly){const o=De(this.tagNumber,7),n=new Uint8Array(o),s=o.byteLength,c=new Uint8Array(s+1);if(c[0]=t|31,!e){for(let l=0;l<s-1;l++)c[l+1]=n[l]|128;c[s]=n[s-1]}return c.buffer}const i=new Uint8Array(this.valueHexView.byteLength+1);if(i[0]=t|31,!e){const o=this.valueHexView;for(let n=0;n<o.length-1;n++)i[n+1]=o[n]|128;i[this.valueHexView.byteLength]=o[o.length-1]}return i.buffer}fromBER(e,t,i){const o=N.toUint8Array(e);if(!Ae(this,o,t,i))return-1;const n=o.subarray(t,t+i);if(n.length===0)return this.error="Zero buffer length",-1;switch(n[0]&192){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=(n[0]&32)===32,this.isHexOnly=!1;const c=n[0]&31;if(c!==31)this.tagNumber=c,this.blockLength=1;else{let l=1,f=this.valueHexView=new Uint8Array(255),p=255;for(;n[l]&128;){if(f[l-1]=n[l]&127,l++,l>=n.length)return this.error="End of input reached before message was fully decoded",-1;if(l===p){p+=255;const w=new Uint8Array(p);for(let y=0;y<f.length;y++)w[y]=f[y];f=this.valueHexView=new Uint8Array(p)}}this.blockLength=l+1,f[l-1]=n[l]&127;const d=new Uint8Array(l);for(let w=0;w<l;w++)d[w]=f[w];f=this.valueHexView=new Uint8Array(l),f.set(d),this.blockLength<=9?this.tagNumber=Ke(f,7):(this.isHexOnly=!0,this.warnings.push("Tag too long, represented as hex-coded"))}if(this.tagClass===1&&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}toJSON(){return L(T({},super.toJSON()),{tagClass:this.tagClass,tagNumber:this.tagNumber,isConstructed:this.isConstructed})}}hn.NAME="identificationBlock";class pn extends Re{constructor({lenBlock:e={}}={}){var t,i,o;super(),this.isIndefiniteForm=(t=e.isIndefiniteForm)!==null&&t!==void 0?t:!1,this.longFormUsed=(i=e.longFormUsed)!==null&&i!==void 0?i:!1,this.length=(o=e.length)!==null&&o!==void 0?o:0}fromBER(e,t,i){const o=N.toUint8Array(e);if(!Ae(this,o,t,i))return-1;const n=o.subarray(t,t+i);if(n.length===0)return this.error="Zero buffer length",-1;if(n[0]===255)return this.error="Length block 0xFF is reserved by standard",-1;if(this.isIndefiniteForm=n[0]===128,this.isIndefiniteForm)return this.blockLength=1,t+this.blockLength;if(this.longFormUsed=!!(n[0]&128),this.longFormUsed===!1)return this.length=n[0],this.blockLength=1,t+this.blockLength;const s=n[0]&127;if(s>8)return this.error="Too big integer",-1;if(s+1>n.length)return this.error="End of input reached before message was fully decoded",-1;const c=t+1,l=o.subarray(c,c+s);return l[s-1]===0&&this.warnings.push("Needlessly long encoded length"),this.length=Ke(l,8),this.longFormUsed&&this.length<=127&&this.warnings.push("Unnecessary usage of long length form"),this.blockLength=s+1,t+this.blockLength}toBER(e=!1){let t,i;if(this.length>127&&(this.longFormUsed=!0),this.isIndefiniteForm)return t=new ArrayBuffer(1),e===!1&&(i=new Uint8Array(t),i[0]=128),t;if(this.longFormUsed){const o=De(this.length,8);if(o.byteLength>127)return this.error="Too big length",se;if(t=new ArrayBuffer(o.byteLength+1),e)return t;const n=new Uint8Array(o);i=new Uint8Array(t),i[0]=o.byteLength|128;for(let s=0;s<o.byteLength;s++)i[s+1]=n[s];return t}return t=new ArrayBuffer(1),e===!1&&(i=new Uint8Array(t),i[0]=this.length),t}toJSON(){return L(T({},super.toJSON()),{isIndefiniteForm:this.isIndefiniteForm,longFormUsed:this.longFormUsed,length:this.length})}}pn.NAME="lengthBlock";const b={};class q extends Re{constructor(s={},n){var c=s,{name:e=Y,optional:t=!1,primitiveSchema:i}=c,o=D(c,["name","optional","primitiveSchema"]);super(o),this.name=e,this.optional=t,i&&(this.primitiveSchema=i),this.idBlock=new hn(o),this.lenBlock=new pn(o),this.valueBlock=n?new n(o):new W(o)}fromBER(e,t,i){const o=this.valueBlock.fromBER(e,t,this.lenBlock.isIndefiniteForm?i:this.lenBlock.length);return o===-1?(this.error=this.valueBlock.error,o):(this.idBlock.error.length||(this.blockLength+=this.idBlock.blockLength),this.lenBlock.error.length||(this.blockLength+=this.lenBlock.blockLength),this.valueBlock.error.length||(this.blockLength+=this.valueBlock.blockLength),o)}toBER(e,t){const i=t||new Kt;t||dn(this);const o=this.idBlock.toBER(e);if(i.write(o),this.lenBlock.isIndefiniteForm)i.write(new Uint8Array([128]).buffer),this.valueBlock.toBER(e,i),i.write(new ArrayBuffer(2));else{const n=this.valueBlock.toBER(e);this.lenBlock.length=n.byteLength;const s=this.lenBlock.toBER(e);i.write(s),i.write(n)}return t?se:i.final()}toJSON(){const e=L(T({},super.toJSON()),{idBlock:this.idBlock.toJSON(),lenBlock:this.lenBlock.toJSON(),valueBlock:this.valueBlock.toJSON(),name:this.name,optional:this.optional});return this.primitiveSchema&&(e.primitiveSchema=this.primitiveSchema.toJSON()),e}toString(e="ascii"){return e==="ascii"?this.onAsciiEncoding():U.ToHex(this.toBER())}onAsciiEncoding(){const e=this.constructor.NAME,t=U.ToHex(this.valueBlock.valueBeforeDecodeView);return`${e} : ${t}`}isEqual(e){if(this===e)return!0;if(!(e instanceof this.constructor))return!1;const t=this.toBER(),i=e.toBER();return Ia(t,i)}}q.NAME="BaseBlock";function dn(r){var e;if(r instanceof b.Constructed)for(const t of r.valueBlock.value)dn(t)&&(r.lenBlock.isIndefiniteForm=!0);return!!(!((e=r.lenBlock)===null||e===void 0)&&e.isIndefiniteForm)}class ai extends q{getValue(){return this.valueBlock.value}setValue(e){this.valueBlock.value=e}constructor(o={},i){var n=o,{value:e=Y}=n,t=D(n,["value"]);super(t,i),e&&this.fromString(e)}fromBER(e,t,i){const o=this.valueBlock.fromBER(e,t,this.lenBlock.isIndefiniteForm?i:this.lenBlock.length);return o===-1?(this.error=this.valueBlock.error,o):(this.fromBuffer(this.valueBlock.valueHexView),this.idBlock.error.length||(this.blockLength+=this.idBlock.blockLength),this.lenBlock.error.length||(this.blockLength+=this.lenBlock.blockLength),this.valueBlock.error.length||(this.blockLength+=this.valueBlock.blockLength),o)}onAsciiEncoding(){return`${this.constructor.NAME} : '${this.valueBlock.value}'`}}ai.NAME="BaseStringBlock";class yn extends ve(W){constructor(i={}){var o=i,{isHexOnly:e=!0}=o,t=D(o,["isHexOnly"]);super(t),this.isHexOnly=e}}yn.NAME="PrimitiveValueBlock";var gn;class At extends q{constructor(e={}){super(e,yn),this.idBlock.isConstructed=!1}}gn=At,b.Primitive=gn,At.NAME="PRIMITIVE";function Ha(r,e){if(r instanceof e)return r;const t=new e;return t.idBlock=r.idBlock,t.lenBlock=r.lenBlock,t.warnings=r.warnings,t.valueBeforeDecodeView=r.valueBeforeDecodeView,t}function Ye(r,e=0,t=r.length){const i=e;let o=new q({},W);const n=new Re;if(!Ae(n,r,e,t))return o.error=n.error,{offset:-1,result:o};if(!r.subarray(e,e+t).length)return o.error="Zero buffer length",{offset:-1,result:o};let c=o.idBlock.fromBER(r,e,t);if(o.idBlock.warnings.length&&o.warnings.concat(o.idBlock.warnings),c===-1)return o.error=o.idBlock.error,{offset:-1,result:o};if(e=c,t-=o.idBlock.blockLength,c=o.lenBlock.fromBER(r,e,t),o.lenBlock.warnings.length&&o.warnings.concat(o.lenBlock.warnings),c===-1)return o.error=o.lenBlock.error,{offset:-1,result:o};if(e=c,t-=o.lenBlock.blockLength,!o.idBlock.isConstructed&&o.lenBlock.isIndefiniteForm)return o.error="Indefinite length form used for primitive encoding form",{offset:-1,result:o};let l=q;switch(o.idBlock.tagClass){case 1:if(o.idBlock.tagNumber>=37&&o.idBlock.isHexOnly===!1)return o.error="UNIVERSAL 37 and upper tags are reserved by ASN.1 standard",{offset:-1,result:o};switch(o.idBlock.tagNumber){case 0:if(o.idBlock.isConstructed&&o.lenBlock.length>0)return o.error="Type [UNIVERSAL 0] is reserved",{offset:-1,result:o};l=b.EndOfContent;break;case 1:l=b.Boolean;break;case 2:l=b.Integer;break;case 3:l=b.BitString;break;case 4:l=b.OctetString;break;case 5:l=b.Null;break;case 6:l=b.ObjectIdentifier;break;case 10:l=b.Enumerated;break;case 12:l=b.Utf8String;break;case 13:l=b.RelativeObjectIdentifier;break;case 14:l=b.TIME;break;case 15:return o.error="[UNIVERSAL 15] is reserved by ASN.1 standard",{offset:-1,result:o};case 16:l=b.Sequence;break;case 17:l=b.Set;break;case 18:l=b.NumericString;break;case 19:l=b.PrintableString;break;case 20:l=b.TeletexString;break;case 21:l=b.VideotexString;break;case 22:l=b.IA5String;break;case 23:l=b.UTCTime;break;case 24:l=b.GeneralizedTime;break;case 25:l=b.GraphicString;break;case 26:l=b.VisibleString;break;case 27:l=b.GeneralString;break;case 28:l=b.UniversalString;break;case 29:l=b.CharacterString;break;case 30:l=b.BmpString;break;case 31:l=b.DATE;break;case 32:l=b.TimeOfDay;break;case 33:l=b.DateTime;break;case 34:l=b.Duration;break;default:{const f=o.idBlock.isConstructed?new b.Constructed:new b.Primitive;f.idBlock=o.idBlock,f.lenBlock=o.lenBlock,f.warnings=o.warnings,o=f}}break;case 2:case 3:case 4:default:l=o.idBlock.isConstructed?b.Constructed:b.Primitive}return o=Ha(o,l),c=o.fromBER(r,e,o.lenBlock.isIndefiniteForm?t:o.lenBlock.length),o.valueBeforeDecodeView=r.subarray(i,i+o.blockLength),{offset:c,result:o}}function Ze(r){if(!r.byteLength){const e=new q({},W);return e.error="Input buffer has zero length",{offset:-1,result:e}}return Ye(N.toUint8Array(r).slice(),0,r.byteLength)}function $a(r,e){return r?1:e}class Oe extends W{constructor(o={}){var n=o,{value:e=[],isIndefiniteForm:t=!1}=n,i=D(n,["value","isIndefiniteForm"]);super(i),this.value=e,this.isIndefiniteForm=t}fromBER(e,t,i){const o=N.toUint8Array(e);if(!Ae(this,o,t,i))return-1;if(this.valueBeforeDecodeView=o.subarray(t,t+i),this.valueBeforeDecodeView.length===0)return this.warnings.push("Zero buffer length"),t;let n=t;for(;$a(this.isIndefiniteForm,i)>0;){const s=Ye(o,n,i);if(s.offset===-1)return this.error=s.result.error,this.warnings.concat(s.result.warnings),-1;if(n=s.offset,this.blockLength+=s.result.blockLength,i-=s.result.blockLength,this.value.push(s.result),this.isIndefiniteForm&&s.result.constructor.NAME===bt)break}return this.isIndefiniteForm&&(this.value[this.value.length-1].constructor.NAME===bt?this.value.pop():this.warnings.push("No EndOfContent block encoded")),n}toBER(e,t){const i=t||new Kt;for(let o=0;o<this.value.length;o++)this.value[o].toBER(e,i);return t?se:i.final()}toJSON(){const e=L(T({},super.toJSON()),{isIndefiniteForm:this.isIndefiniteForm,value:[]});for(const t of this.value)e.value.push(t.toJSON());return e}}Oe.NAME="ConstructedValueBlock";var vn;class J extends q{constructor(e={}){super(e,Oe),this.idBlock.isConstructed=!0}fromBER(e,t,i){this.valueBlock.isIndefiniteForm=this.lenBlock.isIndefiniteForm;const o=this.valueBlock.fromBER(e,t,this.lenBlock.isIndefiniteForm?i:this.lenBlock.length);return o===-1?(this.error=this.valueBlock.error,o):(this.idBlock.error.length||(this.blockLength+=this.idBlock.blockLength),this.lenBlock.error.length||(this.blockLength+=this.lenBlock.blockLength),this.valueBlock.error.length||(this.blockLength+=this.valueBlock.blockLength),o)}onAsciiEncoding(){const e=[];for(const i of this.valueBlock.value)e.push(i.toString("ascii").split(`
72
- `).map(o=>` ${o}`).join(`
71
+ */function Jt(){if(typeof BigInt=="undefined")throw new Error("BigInt is not defined. Your environment doesn't implement BigInt.")}function oi(r){let e=0,t=0;for(let n=0;n<r.length;n++){const o=r[n];e+=o.byteLength}const i=new Uint8Array(e);for(let n=0;n<r.length;n++){const o=r[n];i.set(new Uint8Array(o),t),t+=o.byteLength}return i.buffer}function Ae(r,e,t,i){return e instanceof Uint8Array?e.byteLength?t<0?(r.error="Wrong parameter: inputOffset less than zero",!1):i<0?(r.error="Wrong parameter: inputLength less than zero",!1):e.byteLength-t-i<0?(r.error="End of input reached before message was fully decoded (inconsistent offset and length values)",!1):!0:(r.error="Wrong parameter: inputBuffer has zero length",!1):(r.error="Wrong parameter: inputBuffer must be 'Uint8Array'",!1)}class Kt{constructor(){this.items=[]}write(e){this.items.push(e)}final(){return oi(this.items)}}const wt=[new Uint8Array([1])],ao="0123456789",si="name",co="valueHexView",Va="isHexOnly",ja="idBlock",Ua="tagClass",Da="tagNumber",Ra="isConstructed",La="fromBER",Ha="toBER",$a="local",Y="",se=new ArrayBuffer(0),Yt=new Uint8Array(0),bt="EndOfContent",lo="OCTET STRING",uo="BIT STRING";function ge(r){var e;return e=class extends r{get valueHex(){return this.valueHexView.slice().buffer}set valueHex(i){this.valueHexView=new Uint8Array(i)}constructor(...i){var n;super(...i);const o=i[0]||{};this.isHexOnly=(n=o.isHexOnly)!==null&&n!==void 0?n:!1,this.valueHexView=o.valueHex?N.toUint8Array(o.valueHex):Yt}fromBER(i,n,o){const s=i instanceof ArrayBuffer?new Uint8Array(i):i;if(!Ae(this,s,n,o))return-1;const c=n+o;return this.valueHexView=s.subarray(n,c),this.valueHexView.length?(this.blockLength=o,c):(this.warnings.push("Zero buffer length"),n)}toBER(i=!1){return this.isHexOnly?i?new ArrayBuffer(this.valueHexView.byteLength):this.valueHexView.byteLength===this.valueHexView.buffer.byteLength?this.valueHexView.buffer:this.valueHexView.slice().buffer:(this.error="Flag 'isHexOnly' is not set, abort",se)}toJSON(){return H(T({},super.toJSON()),{isHexOnly:this.isHexOnly,valueHex:U.ToHex(this.valueHexView)})}},e.NAME="hexBlock",e}class Le{static blockName(){return this.NAME}get valueBeforeDecode(){return this.valueBeforeDecodeView.slice().buffer}set valueBeforeDecode(e){this.valueBeforeDecodeView=new Uint8Array(e)}constructor({blockLength:e=0,error:t=Y,warnings:i=[],valueBeforeDecode:n=Yt}={}){this.blockLength=e,this.error=t,this.warnings=i,this.valueBeforeDecodeView=N.toUint8Array(n)}toJSON(){return{blockName:this.constructor.NAME,blockLength:this.blockLength,error:this.error,warnings:this.warnings,valueBeforeDecode:U.ToHex(this.valueBeforeDecodeView)}}}Le.NAME="baseBlock";class W extends Le{fromBER(e,t,i){throw TypeError("User need to make a specific function in a class which extends 'ValueBlock'")}toBER(e,t){throw TypeError("User need to make a specific function in a class which extends 'ValueBlock'")}}W.NAME="valueBlock";class fo extends ge(Le){constructor({idBlock:e={}}={}){var t,i,n,o;super(),e?(this.isHexOnly=(t=e.isHexOnly)!==null&&t!==void 0?t:!1,this.valueHexView=e.valueHex?N.toUint8Array(e.valueHex):Yt,this.tagClass=(i=e.tagClass)!==null&&i!==void 0?i:-1,this.tagNumber=(n=e.tagNumber)!==null&&n!==void 0?n:-1,this.isConstructed=(o=e.isConstructed)!==null&&o!==void 0?o:!1):(this.tagClass=-1,this.tagNumber=-1,this.isConstructed=!1)}toBER(e=!1){let t=0;switch(this.tagClass){case 1:t|=0;break;case 2:t|=64;break;case 3:t|=128;break;case 4:t|=192;break;default:return this.error="Unknown tag class",se}if(this.isConstructed&&(t|=32),this.tagNumber<31&&!this.isHexOnly){const n=new Uint8Array(1);if(!e){let o=this.tagNumber;o&=31,t|=o,n[0]=t}return n.buffer}if(!this.isHexOnly){const n=Re(this.tagNumber,7),o=new Uint8Array(n),s=n.byteLength,c=new Uint8Array(s+1);if(c[0]=t|31,!e){for(let l=0;l<s-1;l++)c[l+1]=o[l]|128;c[s]=o[s-1]}return c.buffer}const i=new Uint8Array(this.valueHexView.byteLength+1);if(i[0]=t|31,!e){const n=this.valueHexView;for(let o=0;o<n.length-1;o++)i[o+1]=n[o]|128;i[this.valueHexView.byteLength]=n[n.length-1]}return i.buffer}fromBER(e,t,i){const n=N.toUint8Array(e);if(!Ae(this,n,t,i))return-1;const o=n.subarray(t,t+i);if(o.length===0)return this.error="Zero buffer length",-1;switch(o[0]&192){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=(o[0]&32)===32,this.isHexOnly=!1;const c=o[0]&31;if(c!==31)this.tagNumber=c,this.blockLength=1;else{let l=1,f=this.valueHexView=new Uint8Array(255),p=255;for(;o[l]&128;){if(f[l-1]=o[l]&127,l++,l>=o.length)return this.error="End of input reached before message was fully decoded",-1;if(l===p){p+=255;const w=new Uint8Array(p);for(let y=0;y<f.length;y++)w[y]=f[y];f=this.valueHexView=new Uint8Array(p)}}this.blockLength=l+1,f[l-1]=o[l]&127;const d=new Uint8Array(l);for(let w=0;w<l;w++)d[w]=f[w];f=this.valueHexView=new Uint8Array(l),f.set(d),this.blockLength<=9?this.tagNumber=Ze(f,7):(this.isHexOnly=!0,this.warnings.push("Tag too long, represented as hex-coded"))}if(this.tagClass===1&&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}toJSON(){return H(T({},super.toJSON()),{tagClass:this.tagClass,tagNumber:this.tagNumber,isConstructed:this.isConstructed})}}fo.NAME="identificationBlock";class ho extends Le{constructor({lenBlock:e={}}={}){var t,i,n;super(),this.isIndefiniteForm=(t=e.isIndefiniteForm)!==null&&t!==void 0?t:!1,this.longFormUsed=(i=e.longFormUsed)!==null&&i!==void 0?i:!1,this.length=(n=e.length)!==null&&n!==void 0?n:0}fromBER(e,t,i){const n=N.toUint8Array(e);if(!Ae(this,n,t,i))return-1;const o=n.subarray(t,t+i);if(o.length===0)return this.error="Zero buffer length",-1;if(o[0]===255)return this.error="Length block 0xFF is reserved by standard",-1;if(this.isIndefiniteForm=o[0]===128,this.isIndefiniteForm)return this.blockLength=1,t+this.blockLength;if(this.longFormUsed=!!(o[0]&128),this.longFormUsed===!1)return this.length=o[0],this.blockLength=1,t+this.blockLength;const s=o[0]&127;if(s>8)return this.error="Too big integer",-1;if(s+1>o.length)return this.error="End of input reached before message was fully decoded",-1;const c=t+1,l=n.subarray(c,c+s);return l[s-1]===0&&this.warnings.push("Needlessly long encoded length"),this.length=Ze(l,8),this.longFormUsed&&this.length<=127&&this.warnings.push("Unnecessary usage of long length form"),this.blockLength=s+1,t+this.blockLength}toBER(e=!1){let t,i;if(this.length>127&&(this.longFormUsed=!0),this.isIndefiniteForm)return t=new ArrayBuffer(1),e===!1&&(i=new Uint8Array(t),i[0]=128),t;if(this.longFormUsed){const n=Re(this.length,8);if(n.byteLength>127)return this.error="Too big length",se;if(t=new ArrayBuffer(n.byteLength+1),e)return t;const o=new Uint8Array(n);i=new Uint8Array(t),i[0]=n.byteLength|128;for(let s=0;s<n.byteLength;s++)i[s+1]=o[s];return t}return t=new ArrayBuffer(1),e===!1&&(i=new Uint8Array(t),i[0]=this.length),t}toJSON(){return H(T({},super.toJSON()),{isIndefiniteForm:this.isIndefiniteForm,longFormUsed:this.longFormUsed,length:this.length})}}ho.NAME="lengthBlock";const b={};class _ extends Le{constructor(s={},o){var c=s,{name:e=Y,optional:t=!1,primitiveSchema:i}=c,n=D(c,["name","optional","primitiveSchema"]);super(n),this.name=e,this.optional=t,i&&(this.primitiveSchema=i),this.idBlock=new fo(n),this.lenBlock=new ho(n),this.valueBlock=o?new o(n):new W(n)}fromBER(e,t,i){const n=this.valueBlock.fromBER(e,t,this.lenBlock.isIndefiniteForm?i:this.lenBlock.length);return n===-1?(this.error=this.valueBlock.error,n):(this.idBlock.error.length||(this.blockLength+=this.idBlock.blockLength),this.lenBlock.error.length||(this.blockLength+=this.lenBlock.blockLength),this.valueBlock.error.length||(this.blockLength+=this.valueBlock.blockLength),n)}toBER(e,t){const i=t||new Kt;t||po(this);const n=this.idBlock.toBER(e);if(i.write(n),this.lenBlock.isIndefiniteForm)i.write(new Uint8Array([128]).buffer),this.valueBlock.toBER(e,i),i.write(new ArrayBuffer(2));else{const o=this.valueBlock.toBER(e);this.lenBlock.length=o.byteLength;const s=this.lenBlock.toBER(e);i.write(s),i.write(o)}return t?se:i.final()}toJSON(){const e=H(T({},super.toJSON()),{idBlock:this.idBlock.toJSON(),lenBlock:this.lenBlock.toJSON(),valueBlock:this.valueBlock.toJSON(),name:this.name,optional:this.optional});return this.primitiveSchema&&(e.primitiveSchema=this.primitiveSchema.toJSON()),e}toString(e="ascii"){return e==="ascii"?this.onAsciiEncoding():U.ToHex(this.toBER())}onAsciiEncoding(){const e=this.constructor.NAME,t=U.ToHex(this.valueBlock.valueBeforeDecodeView);return`${e} : ${t}`}isEqual(e){if(this===e)return!0;if(!(e instanceof this.constructor))return!1;const t=this.toBER(),i=e.toBER();return Ta(t,i)}}_.NAME="BaseBlock";function po(r){var e;if(r instanceof b.Constructed)for(const t of r.valueBlock.value)po(t)&&(r.lenBlock.isIndefiniteForm=!0);return!!(!((e=r.lenBlock)===null||e===void 0)&&e.isIndefiniteForm)}class ai extends _{getValue(){return this.valueBlock.value}setValue(e){this.valueBlock.value=e}constructor(n={},i){var o=n,{value:e=Y}=o,t=D(o,["value"]);super(t,i),e&&this.fromString(e)}fromBER(e,t,i){const n=this.valueBlock.fromBER(e,t,this.lenBlock.isIndefiniteForm?i:this.lenBlock.length);return n===-1?(this.error=this.valueBlock.error,n):(this.fromBuffer(this.valueBlock.valueHexView),this.idBlock.error.length||(this.blockLength+=this.idBlock.blockLength),this.lenBlock.error.length||(this.blockLength+=this.lenBlock.blockLength),this.valueBlock.error.length||(this.blockLength+=this.valueBlock.blockLength),n)}onAsciiEncoding(){return`${this.constructor.NAME} : '${this.valueBlock.value}'`}}ai.NAME="BaseStringBlock";class yo extends ge(W){constructor(i={}){var n=i,{isHexOnly:e=!0}=n,t=D(n,["isHexOnly"]);super(t),this.isHexOnly=e}}yo.NAME="PrimitiveValueBlock";var go;class At extends _{constructor(e={}){super(e,yo),this.idBlock.isConstructed=!1}}go=At,b.Primitive=go,At.NAME="PRIMITIVE";function Ma(r,e){if(r instanceof e)return r;const t=new e;return t.idBlock=r.idBlock,t.lenBlock=r.lenBlock,t.warnings=r.warnings,t.valueBeforeDecodeView=r.valueBeforeDecodeView,t}function Qe(r,e=0,t=r.length){const i=e;let n=new _({},W);const o=new Le;if(!Ae(o,r,e,t))return n.error=o.error,{offset:-1,result:n};if(!r.subarray(e,e+t).length)return n.error="Zero buffer length",{offset:-1,result:n};let c=n.idBlock.fromBER(r,e,t);if(n.idBlock.warnings.length&&n.warnings.concat(n.idBlock.warnings),c===-1)return n.error=n.idBlock.error,{offset:-1,result:n};if(e=c,t-=n.idBlock.blockLength,c=n.lenBlock.fromBER(r,e,t),n.lenBlock.warnings.length&&n.warnings.concat(n.lenBlock.warnings),c===-1)return n.error=n.lenBlock.error,{offset:-1,result:n};if(e=c,t-=n.lenBlock.blockLength,!n.idBlock.isConstructed&&n.lenBlock.isIndefiniteForm)return n.error="Indefinite length form used for primitive encoding form",{offset:-1,result:n};let l=_;switch(n.idBlock.tagClass){case 1:if(n.idBlock.tagNumber>=37&&n.idBlock.isHexOnly===!1)return n.error="UNIVERSAL 37 and upper tags are reserved by ASN.1 standard",{offset:-1,result:n};switch(n.idBlock.tagNumber){case 0:if(n.idBlock.isConstructed&&n.lenBlock.length>0)return n.error="Type [UNIVERSAL 0] is reserved",{offset:-1,result:n};l=b.EndOfContent;break;case 1:l=b.Boolean;break;case 2:l=b.Integer;break;case 3:l=b.BitString;break;case 4:l=b.OctetString;break;case 5:l=b.Null;break;case 6:l=b.ObjectIdentifier;break;case 10:l=b.Enumerated;break;case 12:l=b.Utf8String;break;case 13:l=b.RelativeObjectIdentifier;break;case 14:l=b.TIME;break;case 15:return n.error="[UNIVERSAL 15] is reserved by ASN.1 standard",{offset:-1,result:n};case 16:l=b.Sequence;break;case 17:l=b.Set;break;case 18:l=b.NumericString;break;case 19:l=b.PrintableString;break;case 20:l=b.TeletexString;break;case 21:l=b.VideotexString;break;case 22:l=b.IA5String;break;case 23:l=b.UTCTime;break;case 24:l=b.GeneralizedTime;break;case 25:l=b.GraphicString;break;case 26:l=b.VisibleString;break;case 27:l=b.GeneralString;break;case 28:l=b.UniversalString;break;case 29:l=b.CharacterString;break;case 30:l=b.BmpString;break;case 31:l=b.DATE;break;case 32:l=b.TimeOfDay;break;case 33:l=b.DateTime;break;case 34:l=b.Duration;break;default:{const f=n.idBlock.isConstructed?new b.Constructed:new b.Primitive;f.idBlock=n.idBlock,f.lenBlock=n.lenBlock,f.warnings=n.warnings,n=f}}break;case 2:case 3:case 4:default:l=n.idBlock.isConstructed?b.Constructed:b.Primitive}return n=Ma(n,l),c=n.fromBER(r,e,n.lenBlock.isIndefiniteForm?t:n.lenBlock.length),n.valueBeforeDecodeView=r.subarray(i,i+n.blockLength),{offset:c,result:n}}function et(r){if(!r.byteLength){const e=new _({},W);return e.error="Input buffer has zero length",{offset:-1,result:e}}return Qe(N.toUint8Array(r).slice(),0,r.byteLength)}function Pa(r,e){return r?1:e}class Te extends W{constructor(n={}){var o=n,{value:e=[],isIndefiniteForm:t=!1}=o,i=D(o,["value","isIndefiniteForm"]);super(i),this.value=e,this.isIndefiniteForm=t}fromBER(e,t,i){const n=N.toUint8Array(e);if(!Ae(this,n,t,i))return-1;if(this.valueBeforeDecodeView=n.subarray(t,t+i),this.valueBeforeDecodeView.length===0)return this.warnings.push("Zero buffer length"),t;let o=t;for(;Pa(this.isIndefiniteForm,i)>0;){const s=Qe(n,o,i);if(s.offset===-1)return this.error=s.result.error,this.warnings.concat(s.result.warnings),-1;if(o=s.offset,this.blockLength+=s.result.blockLength,i-=s.result.blockLength,this.value.push(s.result),this.isIndefiniteForm&&s.result.constructor.NAME===bt)break}return this.isIndefiniteForm&&(this.value[this.value.length-1].constructor.NAME===bt?this.value.pop():this.warnings.push("No EndOfContent block encoded")),o}toBER(e,t){const i=t||new Kt;for(let n=0;n<this.value.length;n++)this.value[n].toBER(e,i);return t?se:i.final()}toJSON(){const e=H(T({},super.toJSON()),{isIndefiniteForm:this.isIndefiniteForm,value:[]});for(const t of this.value)e.value.push(t.toJSON());return e}}Te.NAME="ConstructedValueBlock";var vo;class J extends _{constructor(e={}){super(e,Te),this.idBlock.isConstructed=!0}fromBER(e,t,i){this.valueBlock.isIndefiniteForm=this.lenBlock.isIndefiniteForm;const n=this.valueBlock.fromBER(e,t,this.lenBlock.isIndefiniteForm?i:this.lenBlock.length);return n===-1?(this.error=this.valueBlock.error,n):(this.idBlock.error.length||(this.blockLength+=this.idBlock.blockLength),this.lenBlock.error.length||(this.blockLength+=this.lenBlock.blockLength),this.valueBlock.error.length||(this.blockLength+=this.valueBlock.blockLength),n)}onAsciiEncoding(){const e=[];for(const i of this.valueBlock.value)e.push(i.toString("ascii").split(`
72
+ `).map(n=>` ${n}`).join(`
73
73
  `));const t=this.idBlock.tagClass===3?`[${this.idBlock.tagNumber}]`:this.constructor.NAME;return e.length?`${t} :
74
74
  ${e.join(`
75
- `)}`:`${t} :`}}vn=J,b.Constructed=vn,J.NAME="CONSTRUCTED";class mn extends W{fromBER(e,t,i){return t}toBER(e){return se}}mn.override="EndOfContentValueBlock";var wn;class ci extends q{constructor(e={}){super(e,mn),this.idBlock.tagClass=1,this.idBlock.tagNumber=0}}wn=ci,b.EndOfContent=wn,ci.NAME=bt;var bn;class Le extends q{constructor(e={}){super(e,W),this.idBlock.tagClass=1,this.idBlock.tagNumber=5}fromBER(e,t,i){return this.lenBlock.length>0&&this.warnings.push("Non-zero length of value block for Null type"),this.idBlock.error.length||(this.blockLength+=this.idBlock.blockLength),this.lenBlock.error.length||(this.blockLength+=this.lenBlock.blockLength),this.blockLength+=i,t+i>e.byteLength?(this.error="End of input reached before message was fully decoded (inconsistent offset and length values)",-1):t+i}toBER(e,t){const i=new ArrayBuffer(2);if(!e){const o=new Uint8Array(i);o[0]=5,o[1]=0}return t&&t.write(i),i}onAsciiEncoding(){return`${this.constructor.NAME}`}}bn=Le,b.Null=bn,Le.NAME="NULL";class An extends ve(W){get value(){for(const e of this.valueHexView)if(e>0)return!0;return!1}set value(e){this.valueHexView[0]=e?255:0}constructor(i={}){var o=i,{value:e}=o,t=D(o,["value"]);super(t),t.valueHex?this.valueHexView=N.toUint8Array(t.valueHex):this.valueHexView=new Uint8Array(1),e&&(this.value=e)}fromBER(e,t,i){const o=N.toUint8Array(e);return Ae(this,o,t,i)?(this.valueHexView=o.subarray(t,t+i),i>1&&this.warnings.push("Boolean value encoded in more then 1 octet"),this.isHexOnly=!0,an.call(this),this.blockLength=i,t+i):-1}toBER(){return this.valueHexView.slice()}toJSON(){return L(T({},super.toJSON()),{value:this.value})}}An.NAME="BooleanValueBlock";var Sn;class Zt extends q{getValue(){return this.valueBlock.value}setValue(e){this.valueBlock.value=e}constructor(e={}){super(e,An),this.idBlock.tagClass=1,this.idBlock.tagNumber=1}onAsciiEncoding(){return`${this.constructor.NAME} : ${this.getValue}`}}Sn=Zt,b.Boolean=Sn,Zt.NAME="BOOLEAN";class Bn extends ve(Oe){constructor(i={}){var o=i,{isConstructed:e=!1}=o,t=D(o,["isConstructed"]);super(t),this.isConstructed=e}fromBER(e,t,i){let o=0;if(this.isConstructed){if(this.isHexOnly=!1,o=Oe.prototype.fromBER.call(this,e,t,i),o===-1)return o;for(let n=0;n<this.value.length;n++){const s=this.value[n].constructor.NAME;if(s===bt){if(this.isIndefiniteForm)break;return this.error="EndOfContent is unexpected, OCTET STRING may consists of OCTET STRINGs only",-1}if(s!==un)return this.error="OCTET STRING may consists of OCTET STRINGs only",-1}}else this.isHexOnly=!0,o=super.fromBER(e,t,i),this.blockLength=i;return o}toBER(e,t){return this.isConstructed?Oe.prototype.toBER.call(this,e,t):e?new ArrayBuffer(this.valueHexView.byteLength):this.valueHexView.slice().buffer}toJSON(){return L(T({},super.toJSON()),{isConstructed:this.isConstructed})}}Bn.NAME="OctetStringValueBlock";var li;class He extends q{constructor(o={}){var n=o,{idBlock:e={},lenBlock:t={}}=n,i=D(n,["idBlock","lenBlock"]);var s,c;(s=i.isConstructed)!==null&&s!==void 0||(i.isConstructed=!!(!((c=i.value)===null||c===void 0)&&c.length)),super(T({idBlock:T({isConstructed:i.isConstructed},e),lenBlock:L(T({},t),{isIndefiniteForm:!!i.isIndefiniteForm})},i),Bn),this.idBlock.tagClass=1,this.idBlock.tagNumber=4}fromBER(e,t,i){if(this.valueBlock.isConstructed=this.idBlock.isConstructed,this.valueBlock.isIndefiniteForm=this.lenBlock.isIndefiniteForm,i===0)return this.idBlock.error.length===0&&(this.blockLength+=this.idBlock.blockLength),this.lenBlock.error.length===0&&(this.blockLength+=this.lenBlock.blockLength),t;if(!this.valueBlock.isConstructed){const n=(e instanceof ArrayBuffer?new Uint8Array(e):e).subarray(t,t+i);try{if(n.byteLength){const s=Ye(n,0,n.byteLength);s.offset!==-1&&s.offset===i&&(this.valueBlock.value=[s.result])}}catch(s){}}return super.fromBER(e,t,i)}onAsciiEncoding(){if(this.valueBlock.isConstructed||this.valueBlock.value&&this.valueBlock.value.length)return J.prototype.onAsciiEncoding.call(this);const e=this.constructor.NAME,t=U.ToHex(this.valueBlock.valueHexView);return`${e} : ${t}`}getValue(){if(!this.idBlock.isConstructed)return this.valueBlock.valueHexView.slice().buffer;const e=[];for(const t of this.valueBlock.value)t instanceof li&&e.push(t.valueBlock.valueHexView);return N.concat(e)}}li=He,b.OctetString=li,He.NAME=un;class kn extends ve(Oe){constructor(o={}){var n=o,{unusedBits:e=0,isConstructed:t=!1}=n,i=D(n,["unusedBits","isConstructed"]);super(i),this.unusedBits=e,this.isConstructed=t,this.blockLength=this.valueHexView.byteLength}fromBER(e,t,i){if(!i)return t;let o=-1;if(this.isConstructed){if(o=Oe.prototype.fromBER.call(this,e,t,i),o===-1)return o;for(const c of this.value){const l=c.constructor.NAME;if(l===bt){if(this.isIndefiniteForm)break;return this.error="EndOfContent is unexpected, BIT STRING may consists of BIT STRINGs only",-1}if(l!==fn)return this.error="BIT STRING may consists of BIT STRINGs only",-1;const f=c.valueBlock;if(this.unusedBits>0&&f.unusedBits>0)return this.error='Using of "unused bits" inside constructive BIT STRING allowed for least one only',-1;this.unusedBits=f.unusedBits}return o}const n=N.toUint8Array(e);if(!Ae(this,n,t,i))return-1;const s=n.subarray(t,t+i);if(this.unusedBits=s[0],this.unusedBits>7)return this.error="Unused bits for BitString must be in range 0-7",-1;if(!this.unusedBits){const c=s.subarray(1);try{if(c.byteLength){const l=Ye(c,0,c.byteLength);l.offset!==-1&&l.offset===i-1&&(this.value=[l.result])}}catch(l){}}return this.valueHexView=s.subarray(1),this.blockLength=s.length,t+i}toBER(e,t){if(this.isConstructed)return Oe.prototype.toBER.call(this,e,t);if(e)return new ArrayBuffer(this.valueHexView.byteLength+1);if(!this.valueHexView.byteLength)return se;const i=new Uint8Array(this.valueHexView.length+1);return i[0]=this.unusedBits,i.set(this.valueHexView,1),i.buffer}toJSON(){return L(T({},super.toJSON()),{unusedBits:this.unusedBits,isConstructed:this.isConstructed})}}kn.NAME="BitStringValueBlock";var xn;class $e extends q{constructor(o={}){var n=o,{idBlock:e={},lenBlock:t={}}=n,i=D(n,["idBlock","lenBlock"]);var s,c;(s=i.isConstructed)!==null&&s!==void 0||(i.isConstructed=!!(!((c=i.value)===null||c===void 0)&&c.length)),super(T({idBlock:T({isConstructed:i.isConstructed},e),lenBlock:L(T({},t),{isIndefiniteForm:!!i.isIndefiniteForm})},i),kn),this.idBlock.tagClass=1,this.idBlock.tagNumber=3}fromBER(e,t,i){return this.valueBlock.isConstructed=this.idBlock.isConstructed,this.valueBlock.isIndefiniteForm=this.lenBlock.isIndefiniteForm,super.fromBER(e,t,i)}onAsciiEncoding(){if(this.valueBlock.isConstructed||this.valueBlock.value&&this.valueBlock.value.length)return J.prototype.onAsciiEncoding.call(this);{const e=[],t=this.valueBlock.valueHexView;for(const s of t)e.push(s.toString(2).padStart(8,"0"));const i=e.join(""),o=this.constructor.NAME,n=i.substring(0,i.length-this.valueBlock.unusedBits);return`${o} : ${n}`}}}xn=$e,b.BitString=xn,$e.NAME=fn;var Nn;function Ma(r,e){const t=new Uint8Array([0]),i=new Uint8Array(r),o=new Uint8Array(e);let n=i.slice(0);const s=n.length-1,c=o.slice(0),l=c.length-1;let f=0;const p=l<s?s:l;let d=0;for(let w=p;w>=0;w--,d++){switch(!0){case d<c.length:f=n[s-d]+c[l-d]+t[0];break;default:f=n[s-d]+t[0]}switch(t[0]=f/10,!0){case d>=n.length:n=oi(new Uint8Array([f%10]),n);break;default:n[s-d]=f%10}}return t[0]>0&&(n=oi(t,n)),n}function Cn(r){if(r>=wt.length)for(let e=wt.length;e<=r;e++){const t=new Uint8Array([0]);let i=wt[e-1].slice(0);for(let o=i.length-1;o>=0;o--){const n=new Uint8Array([(i[o]<<1)+t[0]]);t[0]=n[0]/10,i[o]=n[0]%10}t[0]>0&&(i=oi(t,i)),wt.push(i)}return wt[r]}function Pa(r,e){let t=0;const i=new Uint8Array(r),o=new Uint8Array(e),n=i.slice(0),s=n.length-1,c=o.slice(0),l=c.length-1;let f,p=0;for(let d=l;d>=0;d--,p++)switch(f=n[s-p]-c[l-p]-t,!0){case f<0:t=1,n[s-p]=f+10;break;default:t=0,n[s-p]=f}if(t>0)for(let d=s-l+1;d>=0;d--,p++)if(f=n[s-p]-t,f<0)t=1,n[s-p]=f+10;else{t=0,n[s-p]=f;break}return n.slice()}class ui extends ve(W){setValueHex(){this.valueHexView.length>=4?(this.warnings.push("Too big Integer for decoding, hex only"),this.isHexOnly=!0,this._valueDec=0):(this.isHexOnly=!1,this.valueHexView.length>0&&(this._valueDec=an.call(this)))}constructor(i={}){var o=i,{value:e}=o,t=D(o,["value"]);super(t),this._valueDec=0,t.valueHex&&this.setValueHex(),e!==void 0&&(this.valueDec=e)}set valueDec(e){this._valueDec=e,this.isHexOnly=!1,this.valueHexView=new Uint8Array(Ea(e))}get valueDec(){return this._valueDec}fromDER(e,t,i,o=0){const n=this.fromBER(e,t,i);if(n===-1)return n;const s=this.valueHexView;return s[0]===0&&(s[1]&128)!==0?this.valueHexView=s.subarray(1):o!==0&&s.length<o&&(o-s.length>1&&(o=s.length+1),this.valueHexView=s.subarray(o-s.length)),n}toDER(e=!1){const t=this.valueHexView;switch(!0){case(t[0]&128)!==0:{const i=new Uint8Array(this.valueHexView.length+1);i[0]=0,i.set(t,1),this.valueHexView=i}break;case(t[0]===0&&(t[1]&128)===0):this.valueHexView=this.valueHexView.subarray(1);break}return this.toBER(e)}fromBER(e,t,i){const o=super.fromBER(e,t,i);return o===-1||this.setValueHex(),o}toBER(e){return e?new ArrayBuffer(this.valueHexView.length):this.valueHexView.slice().buffer}toJSON(){return L(T({},super.toJSON()),{valueDec:this.valueDec})}toString(){const e=this.valueHexView.length*8-1;let t=new Uint8Array(this.valueHexView.length*8/3),i=0,o;const n=this.valueHexView;let s="",c=!1;for(let l=n.byteLength-1;l>=0;l--){o=n[l];for(let f=0;f<8;f++){if((o&1)===1)switch(i){case e:t=Pa(Cn(i),t),s="-";break;default:t=Ma(t,Cn(i))}i++,o>>=1}}for(let l=0;l<t.length;l++)t[l]&&(c=!0),c&&(s+=cn.charAt(t[l]));return c===!1&&(s+=cn.charAt(0)),s}}Nn=ui,ui.NAME="IntegerValueBlock",Object.defineProperty(Nn.prototype,"valueHex",{set:function(r){this.valueHexView=new Uint8Array(r),this.setValueHex()},get:function(){return this.valueHexView.slice().buffer}});var St;class Qe extends q{constructor(e={}){super(e,ui),this.idBlock.tagClass=1,this.idBlock.tagNumber=2}toBigInt(){return Jt(),BigInt(this.valueBlock.toString())}static fromBigInt(e){Jt();const t=BigInt(e),i=new Kt,o=t.toString(16).replace(/^-/,""),n=new Uint8Array(U.FromHex(o));if(t<0){const c=new Uint8Array(n.length+(n[0]&128?1:0));c[0]|=128;const f=BigInt(`0x${U.ToHex(c)}`)+t,p=N.toUint8Array(U.FromHex(f.toString(16)));p[0]|=128,i.write(p)}else n[0]&128&&i.write(new Uint8Array([0])),i.write(n);return new St({valueHex:i.final()})}convertToDER(){const e=new St({valueHex:this.valueBlock.valueHexView});return e.valueBlock.toDER(),e}convertFromDER(){return new St({valueHex:this.valueBlock.valueHexView[0]===0?this.valueBlock.valueHexView.subarray(1):this.valueBlock.valueHexView})}onAsciiEncoding(){return`${this.constructor.NAME} : ${this.valueBlock.toString()}`}}St=Qe,b.Integer=St,Qe.NAME="INTEGER";var En;class Qt extends Qe{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=10}}En=Qt,b.Enumerated=En,Qt.NAME="ENUMERATED";class fi extends ve(W){constructor(o={}){var n=o,{valueDec:e=-1,isFirstSid:t=!1}=n,i=D(n,["valueDec","isFirstSid"]);super(i),this.valueDec=e,this.isFirstSid=t}fromBER(e,t,i){if(!i)return t;const o=N.toUint8Array(e);if(!Ae(this,o,t,i))return-1;const n=o.subarray(t,t+i);this.valueHexView=new Uint8Array(i);for(let c=0;c<i&&(this.valueHexView[c]=n[c]&127,this.blockLength++,(n[c]&128)!==0);c++);const s=new Uint8Array(this.blockLength);for(let c=0;c<this.blockLength;c++)s[c]=this.valueHexView[c];return this.valueHexView=s,(n[this.blockLength-1]&128)!==0?(this.error="End of input reached before message was fully decoded",-1):(this.valueHexView[0]===0&&this.warnings.push("Needlessly long format of SID encoding"),this.blockLength<=8?this.valueDec=Ke(this.valueHexView,7):(this.isHexOnly=!0,this.warnings.push("Too big SID for decoding, hex only")),t+this.blockLength)}set valueBigInt(e){Jt();let t=BigInt(e).toString(2);for(;t.length%7;)t="0"+t;const i=new Uint8Array(t.length/7);for(let o=0;o<i.length;o++)i[o]=parseInt(t.slice(o*7,o*7+7),2)+(o+1<i.length?128:0);this.fromBER(i.buffer,0,i.length)}toBER(e){if(this.isHexOnly){if(e)return new ArrayBuffer(this.valueHexView.byteLength);const o=this.valueHexView,n=new Uint8Array(this.blockLength);for(let s=0;s<this.blockLength-1;s++)n[s]=o[s]|128;return n[this.blockLength-1]=o[this.blockLength-1],n.buffer}const t=De(this.valueDec,7);if(t.byteLength===0)return this.error="Error during encoding SID value",se;const i=new Uint8Array(t.byteLength);if(!e){const o=new Uint8Array(t),n=t.byteLength-1;for(let s=0;s<n;s++)i[s]=o[s]|128;i[n]=o[n]}return i}toString(){let e="";if(this.isHexOnly)e=U.ToHex(this.valueHexView);else if(this.isFirstSid){let 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}toJSON(){return L(T({},super.toJSON()),{valueDec:this.valueDec,isFirstSid:this.isFirstSid})}}fi.NAME="sidBlock";class In extends W{constructor(i={}){var o=i,{value:e=Y}=o,t=D(o,["value"]);super(t),this.value=[],e&&this.fromString(e)}fromBER(e,t,i){let o=t;for(;i>0;){const n=new fi;if(o=n.fromBER(e,o,i),o===-1)return this.blockLength=0,this.error=n.error,o;this.value.length===0&&(n.isFirstSid=!0),this.blockLength+=n.blockLength,i-=n.blockLength,this.value.push(n)}return o}toBER(e){const t=[];for(let i=0;i<this.value.length;i++){const o=this.value[i].toBER(e);if(o.byteLength===0)return this.error=this.value[i].error,se;t.push(o)}return ni(t)}fromString(e){this.value=[];let t=0,i=0,o="",n=!1;do if(i=e.indexOf(".",t),i===-1?o=e.substring(t):o=e.substring(t,i),t=i+1,n){const s=this.value[0];let c=0;switch(s.valueDec){case 0:break;case 1:c=40;break;case 2:c=80;break;default:this.value=[];return}const l=parseInt(o,10);if(isNaN(l))return;s.valueDec=l+c,n=!1}else{const s=new fi;if(o>Number.MAX_SAFE_INTEGER){Jt();const c=BigInt(o);s.valueBigInt=c}else if(s.valueDec=parseInt(o,10),isNaN(s.valueDec))return;this.value.length||(s.isFirstSid=!0,n=!0),this.value.push(s)}while(i!==-1)}toString(){let e="",t=!1;for(let i=0;i<this.value.length;i++){t=this.value[i].isHexOnly;let o=this.value[i].toString();i!==0&&(e=`${e}.`),t?(o=`{${o}}`,this.value[i].isFirstSid?e=`2.{${o} - 80}`:e+=o):e+=o}return e}toJSON(){const e=L(T({},super.toJSON()),{value:this.toString(),sidArray:[]});for(let t=0;t<this.value.length;t++)e.sidArray.push(this.value[t].toJSON());return e}}In.NAME="ObjectIdentifierValueBlock";var On;class er extends q{getValue(){return this.valueBlock.toString()}setValue(e){this.valueBlock.fromString(e)}constructor(e={}){super(e,In),this.idBlock.tagClass=1,this.idBlock.tagNumber=6}onAsciiEncoding(){return`${this.constructor.NAME} : ${this.valueBlock.toString()||"empty"}`}toJSON(){return L(T({},super.toJSON()),{value:this.getValue()})}}On=er,b.ObjectIdentifier=On,er.NAME="OBJECT IDENTIFIER";class hi extends ve(Re){constructor(i={}){var o=i,{valueDec:e=0}=o,t=D(o,["valueDec"]);super(t),this.valueDec=e}fromBER(e,t,i){if(i===0)return t;const o=N.toUint8Array(e);if(!Ae(this,o,t,i))return-1;const n=o.subarray(t,t+i);this.valueHexView=new Uint8Array(i);for(let c=0;c<i&&(this.valueHexView[c]=n[c]&127,this.blockLength++,(n[c]&128)!==0);c++);const s=new Uint8Array(this.blockLength);for(let c=0;c<this.blockLength;c++)s[c]=this.valueHexView[c];return this.valueHexView=s,(n[this.blockLength-1]&128)!==0?(this.error="End of input reached before message was fully decoded",-1):(this.valueHexView[0]===0&&this.warnings.push("Needlessly long format of SID encoding"),this.blockLength<=8?this.valueDec=Ke(this.valueHexView,7):(this.isHexOnly=!0,this.warnings.push("Too big SID for decoding, hex only")),t+this.blockLength)}toBER(e){if(this.isHexOnly){if(e)return new ArrayBuffer(this.valueHexView.byteLength);const o=this.valueHexView,n=new Uint8Array(this.blockLength);for(let s=0;s<this.blockLength-1;s++)n[s]=o[s]|128;return n[this.blockLength-1]=o[this.blockLength-1],n.buffer}const t=De(this.valueDec,7);if(t.byteLength===0)return this.error="Error during encoding SID value",se;const i=new Uint8Array(t.byteLength);if(!e){const o=new Uint8Array(t),n=t.byteLength-1;for(let s=0;s<n;s++)i[s]=o[s]|128;i[n]=o[n]}return i.buffer}toString(){let e="";return this.isHexOnly?e=U.ToHex(this.valueHexView):e=this.valueDec.toString(),e}toJSON(){return L(T({},super.toJSON()),{valueDec:this.valueDec})}}hi.NAME="relativeSidBlock";class Tn extends W{constructor(i={}){var o=i,{value:e=Y}=o,t=D(o,["value"]);super(t),this.value=[],e&&this.fromString(e)}fromBER(e,t,i){let o=t;for(;i>0;){const n=new hi;if(o=n.fromBER(e,o,i),o===-1)return this.blockLength=0,this.error=n.error,o;this.blockLength+=n.blockLength,i-=n.blockLength,this.value.push(n)}return o}toBER(e,t){const i=[];for(let o=0;o<this.value.length;o++){const n=this.value[o].toBER(e);if(n.byteLength===0)return this.error=this.value[o].error,se;i.push(n)}return ni(i)}fromString(e){this.value=[];let t=0,i=0,o="";do{i=e.indexOf(".",t),i===-1?o=e.substring(t):o=e.substring(t,i),t=i+1;const n=new hi;if(n.valueDec=parseInt(o,10),isNaN(n.valueDec))return!0;this.value.push(n)}while(i!==-1);return!0}toString(){let e="",t=!1;for(let i=0;i<this.value.length;i++){t=this.value[i].isHexOnly;let o=this.value[i].toString();i!==0&&(e=`${e}.`),t&&(o=`{${o}}`),e+=o}return e}toJSON(){const e=L(T({},super.toJSON()),{value:this.toString(),sidArray:[]});for(let t=0;t<this.value.length;t++)e.sidArray.push(this.value[t].toJSON());return e}}Tn.NAME="RelativeObjectIdentifierValueBlock";var Vn;class pi extends q{getValue(){return this.valueBlock.toString()}setValue(e){this.valueBlock.fromString(e)}constructor(e={}){super(e,Tn),this.idBlock.tagClass=1,this.idBlock.tagNumber=13}onAsciiEncoding(){return`${this.constructor.NAME} : ${this.valueBlock.toString()||"empty"}`}toJSON(){return L(T({},super.toJSON()),{value:this.getValue()})}}Vn=pi,b.RelativeObjectIdentifier=Vn,pi.NAME="RelativeObjectIdentifier";var jn;class ae extends J{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=16}}jn=ae,b.Sequence=jn,ae.NAME="SEQUENCE";var Un;class me extends J{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=17}}Un=me,b.Set=Un,me.NAME="SET";class Dn extends ve(W){constructor(t={}){var e=D(t,[]);super(e),this.isHexOnly=!0,this.value=Y}toJSON(){return L(T({},super.toJSON()),{value:this.value})}}Dn.NAME="StringValueBlock";class Rn extends Dn{}Rn.NAME="SimpleStringValueBlock";class te extends ai{constructor(t={}){var e=D(t,[]);super(e,Rn)}fromBuffer(e){this.valueBlock.value=String.fromCharCode.apply(null,N.toUint8Array(e))}fromString(e){const t=e.length,i=this.valueBlock.valueHexView=new Uint8Array(t);for(let o=0;o<t;o++)i[o]=e.charCodeAt(o);this.valueBlock.value=e}}te.NAME="SIMPLE STRING";class Ln extends te{fromBuffer(e){this.valueBlock.valueHexView=N.toUint8Array(e);try{this.valueBlock.value=U.ToUtf8String(e)}catch(t){this.warnings.push(`Error during "decodeURIComponent": ${t}, using raw string`),this.valueBlock.value=U.ToBinary(e)}}fromString(e){this.valueBlock.valueHexView=new Uint8Array(U.FromUtf8String(e)),this.valueBlock.value=e}}Ln.NAME="Utf8StringValueBlock";var Hn;class Se extends Ln{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=12}}Hn=Se,b.Utf8String=Hn,Se.NAME="UTF8String";class $n extends te{fromBuffer(e){this.valueBlock.value=U.ToUtf16String(e),this.valueBlock.valueHexView=N.toUint8Array(e)}fromString(e){this.valueBlock.value=e,this.valueBlock.valueHexView=new Uint8Array(U.FromUtf16String(e))}}$n.NAME="BmpStringValueBlock";var Mn;class tr extends $n{constructor(t={}){var e=D(t,[]);super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=30}}Mn=tr,b.BmpString=Mn,tr.NAME="BMPString";class Pn extends te{fromBuffer(e){const t=ArrayBuffer.isView(e)?e.slice().buffer:e.slice(0),i=new Uint8Array(t);for(let o=0;o<i.length;o+=4)i[o]=i[o+3],i[o+1]=i[o+2],i[o+2]=0,i[o+3]=0;this.valueBlock.value=String.fromCharCode.apply(null,new Uint32Array(t))}fromString(e){const t=e.length,i=this.valueBlock.valueHexView=new Uint8Array(t*4);for(let o=0;o<t;o++){const n=De(e.charCodeAt(o),8),s=new Uint8Array(n);if(s.length>4)continue;const c=4-s.length;for(let l=s.length-1;l>=0;l--)i[o*4+l+c]=s[l]}this.valueBlock.value=e}}Pn.NAME="UniversalStringValueBlock";var _n;class rr extends Pn{constructor(t={}){var e=D(t,[]);super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=28}}_n=rr,b.UniversalString=_n,rr.NAME="UniversalString";var qn;class ir extends te{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=18}}qn=ir,b.NumericString=qn,ir.NAME="NumericString";var Fn;class or extends te{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=19}}Fn=or,b.PrintableString=Fn,or.NAME="PrintableString";var Gn;class nr extends te{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=20}}Gn=nr,b.TeletexString=Gn,nr.NAME="TeletexString";var zn;class sr extends te{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=21}}zn=sr,b.VideotexString=zn,sr.NAME="VideotexString";var Xn;class ar extends te{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=22}}Xn=ar,b.IA5String=Xn,ar.NAME="IA5String";var Wn;class cr extends te{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=25}}Wn=cr,b.GraphicString=Wn,cr.NAME="GraphicString";var Jn;class Bt extends te{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=26}}Jn=Bt,b.VisibleString=Jn,Bt.NAME="VisibleString";var Kn;class lr extends te{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=27}}Kn=lr,b.GeneralString=Kn,lr.NAME="GeneralString";var Yn;class ur extends te{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=29}}Yn=ur,b.CharacterString=Yn,ur.NAME="CharacterString";var Zn;class kt extends Bt{constructor(o={}){var n=o,{value:e,valueDate:t}=n,i=D(n,["value","valueDate"]);if(super(i),this.year=0,this.month=0,this.day=0,this.hour=0,this.minute=0,this.second=0,e){this.fromString(e),this.valueBlock.valueHexView=new Uint8Array(e.length);for(let s=0;s<e.length;s++)this.valueBlock.valueHexView[s]=e.charCodeAt(s)}t&&(this.fromDate(t),this.valueBlock.valueHexView=new Uint8Array(this.toBuffer())),this.idBlock.tagClass=1,this.idBlock.tagNumber=23}fromBuffer(e){this.fromString(String.fromCharCode.apply(null,N.toUint8Array(e)))}toBuffer(){const e=this.toString(),t=new ArrayBuffer(e.length),i=new Uint8Array(t);for(let o=0;o<e.length;o++)i[o]=e.charCodeAt(o);return t}fromDate(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()}toDate(){return new Date(Date.UTC(this.year,this.month-1,this.day,this.hour,this.minute,this.second))}fromString(e){const i=/(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})Z/ig.exec(e);if(i===null){this.error="Wrong input string for conversion";return}const o=parseInt(i[1],10);o>=50?this.year=1900+o:this.year=2e3+o,this.month=parseInt(i[2],10),this.day=parseInt(i[3],10),this.hour=parseInt(i[4],10),this.minute=parseInt(i[5],10),this.second=parseInt(i[6],10)}toString(e="iso"){if(e==="iso"){const t=new Array(7);return t[0]=ee(this.year<2e3?this.year-1900:this.year-2e3,2),t[1]=ee(this.month,2),t[2]=ee(this.day,2),t[3]=ee(this.hour,2),t[4]=ee(this.minute,2),t[5]=ee(this.second,2),t[6]="Z",t.join("")}return super.toString(e)}onAsciiEncoding(){return`${this.constructor.NAME} : ${this.toDate().toISOString()}`}toJSON(){return L(T({},super.toJSON()),{year:this.year,month:this.month,day:this.day,hour:this.hour,minute:this.minute,second:this.second})}}Zn=kt,b.UTCTime=Zn,kt.NAME="UTCTime";var Qn;class fr extends kt{constructor(e={}){var t;super(e),(t=this.millisecond)!==null&&t!==void 0||(this.millisecond=0),this.idBlock.tagClass=1,this.idBlock.tagNumber=24}fromDate(e){super.fromDate(e),this.millisecond=e.getUTCMilliseconds()}toDate(){const e=Date.UTC(this.year,this.month-1,this.day,this.hour,this.minute,this.second,this.millisecond);return new Date(e)}fromString(e){let t=!1,i="",o="",n=0,s,c=0,l=0;if(e[e.length-1]==="Z")i=e.substring(0,e.length-1),t=!0;else{const d=new Number(e[e.length-1]);if(isNaN(d.valueOf()))throw new Error("Wrong input string for conversion");i=e}if(t){if(i.indexOf("+")!==-1)throw new Error("Wrong input string for conversion");if(i.indexOf("-")!==-1)throw new Error("Wrong input string for conversion")}else{let d=1,w=i.indexOf("+"),y="";if(w===-1&&(w=i.indexOf("-"),d=-1),w!==-1){if(y=i.substring(w+1),i=i.substring(0,w),y.length!==2&&y.length!==4)throw new Error("Wrong input string for conversion");let g=parseInt(y.substring(0,2),10);if(isNaN(g.valueOf()))throw new Error("Wrong input string for conversion");if(c=d*g,y.length===4){if(g=parseInt(y.substring(2,4),10),isNaN(g.valueOf()))throw new Error("Wrong input string for conversion");l=d*g}}}let f=i.indexOf(".");if(f===-1&&(f=i.indexOf(",")),f!==-1){const d=new Number(`0${i.substring(f)}`);if(isNaN(d.valueOf()))throw new Error("Wrong input string for conversion");n=d.valueOf(),o=i.substring(0,f)}else o=i;switch(!0){case o.length===8:if(s=/(\d{4})(\d{2})(\d{2})/ig,f!==-1)throw new Error("Wrong input string for conversion");break;case o.length===10:if(s=/(\d{4})(\d{2})(\d{2})(\d{2})/ig,f!==-1){let d=60*n;this.minute=Math.floor(d),d=60*(d-this.minute),this.second=Math.floor(d),d=1e3*(d-this.second),this.millisecond=Math.floor(d)}break;case o.length===12:if(s=/(\d{4})(\d{2})(\d{2})(\d{2})(\d{2})/ig,f!==-1){let d=60*n;this.second=Math.floor(d),d=1e3*(d-this.second),this.millisecond=Math.floor(d)}break;case o.length===14:if(s=/(\d{4})(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})/ig,f!==-1){const d=1e3*n;this.millisecond=Math.floor(d)}break;default:throw new Error("Wrong input string for conversion")}const p=s.exec(o);if(p===null)throw new Error("Wrong input string for conversion");for(let d=1;d<p.length;d++)switch(d){case 1:this.year=parseInt(p[d],10);break;case 2:this.month=parseInt(p[d],10);break;case 3:this.day=parseInt(p[d],10);break;case 4:this.hour=parseInt(p[d],10)+c;break;case 5:this.minute=parseInt(p[d],10)+l;break;case 6:this.second=parseInt(p[d],10);break;default:throw new Error("Wrong input string for conversion")}if(t===!1){const d=new Date(this.year,this.month,this.day,this.hour,this.minute,this.second,this.millisecond);this.year=d.getUTCFullYear(),this.month=d.getUTCMonth(),this.day=d.getUTCDay(),this.hour=d.getUTCHours(),this.minute=d.getUTCMinutes(),this.second=d.getUTCSeconds(),this.millisecond=d.getUTCMilliseconds()}}toString(e="iso"){if(e==="iso"){const t=[];return t.push(ee(this.year,4)),t.push(ee(this.month,2)),t.push(ee(this.day,2)),t.push(ee(this.hour,2)),t.push(ee(this.minute,2)),t.push(ee(this.second,2)),this.millisecond!==0&&(t.push("."),t.push(ee(this.millisecond,3))),t.push("Z"),t.join("")}return super.toString(e)}toJSON(){return L(T({},super.toJSON()),{millisecond:this.millisecond})}}Qn=fr,b.GeneralizedTime=Qn,fr.NAME="GeneralizedTime";var es;class di extends Se{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=31}}es=di,b.DATE=es,di.NAME="DATE";var ts;class yi extends Se{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=32}}ts=yi,b.TimeOfDay=ts,yi.NAME="TimeOfDay";var rs;class gi extends Se{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=33}}rs=gi,b.DateTime=rs,gi.NAME="DateTime";var is;class vi extends Se{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=34}}is=vi,b.Duration=is,vi.NAME="Duration";var os;class mi extends Se{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=14}}os=mi,b.TIME=os,mi.NAME="TIME";class Me{constructor({name:e=Y,optional:t=!1}={}){this.name=e,this.optional=t}}class wi extends Me{constructor(i={}){var o=i,{value:e=[]}=o,t=D(o,["value"]);super(t),this.value=e}}class hr extends Me{constructor(o={}){var n=o,{value:e=new Me,local:t=!1}=n,i=D(n,["value","local"]);super(i),this.value=e,this.local=t}}class _a{get data(){return this.dataView.slice().buffer}set data(e){this.dataView=N.toUint8Array(e)}constructor({data:e=Yt}={}){this.dataView=N.toUint8Array(e)}fromBER(e,t,i){const o=t+i;return this.dataView=N.toUint8Array(e).subarray(t,o),o}toBER(e){return this.dataView.slice().buffer}}function Te(r,e,t){if(t instanceof wi){for(const n of t.value)if(Te(r,e,n).verified)return{verified:!0,result:r};{const n={verified:!1,result:{error:"Wrong values for Choice type"}};return t.hasOwnProperty(si)&&(n.name=t.name),n}}if(t instanceof Me)return t.hasOwnProperty(si)&&(r[t.name]=e),{verified:!0,result:r};if(!(r instanceof Object))return{verified:!1,result:{error:"Wrong root object"}};if(!(e instanceof Object))return{verified:!1,result:{error:"Wrong ASN.1 data"}};if(!(t instanceof Object))return{verified:!1,result:{error:"Wrong ASN.1 schema"}};if(!(Ta in t))return{verified:!1,result:{error:"Wrong ASN.1 schema"}};if(!(Da in t.idBlock))return{verified:!1,result:{error:"Wrong ASN.1 schema"}};if(!(Ra in t.idBlock))return{verified:!1,result:{error:"Wrong ASN.1 schema"}};const i=t.idBlock.toBER(!1);if(i.byteLength===0)return{verified:!1,result:{error:"Error encoding idBlock for ASN.1 schema"}};if(t.idBlock.fromBER(i,0,i.byteLength)===-1)return{verified:!1,result:{error:"Error decoding idBlock for ASN.1 schema"}};if(t.idBlock.hasOwnProperty(Va)===!1)return{verified:!1,result:{error:"Wrong ASN.1 schema"}};if(t.idBlock.tagClass!==e.idBlock.tagClass)return{verified:!1,result:r};if(t.idBlock.hasOwnProperty(ja)===!1)return{verified:!1,result:{error:"Wrong ASN.1 schema"}};if(t.idBlock.tagNumber!==e.idBlock.tagNumber)return{verified:!1,result:r};if(t.idBlock.hasOwnProperty(Ua)===!1)return{verified:!1,result:{error:"Wrong ASN.1 schema"}};if(t.idBlock.isConstructed!==e.idBlock.isConstructed)return{verified:!1,result:r};if(!(Oa in t.idBlock))return{verified:!1,result:{error:"Wrong ASN.1 schema"}};if(t.idBlock.isHexOnly!==e.idBlock.isHexOnly)return{verified:!1,result:r};if(t.idBlock.isHexOnly){if(!(ln in t.idBlock))return{verified:!1,result:{error:"Wrong ASN.1 schema"}};const n=t.idBlock.valueHexView,s=e.idBlock.valueHexView;if(n.length!==s.length)return{verified:!1,result:r};for(let c=0;c<n.length;c++)if(n[c]!==s[1])return{verified:!1,result:r}}if(t.name&&(t.name=t.name.replace(/^\s+|\s+$/g,Y),t.name&&(r[t.name]=e)),t instanceof b.Constructed){let n=0,s={verified:!1,result:{error:"Unknown error"}},c=t.valueBlock.value.length;if(c>0&&t.valueBlock.value[0]instanceof hr&&(c=e.valueBlock.value.length),c===0)return{verified:!0,result:r};if(e.valueBlock.value.length===0&&t.valueBlock.value.length!==0){let l=!0;for(let f=0;f<t.valueBlock.value.length;f++)l=l&&(t.valueBlock.value[f].optional||!1);return l?{verified:!0,result:r}:(t.name&&(t.name=t.name.replace(/^\s+|\s+$/g,Y),t.name&&delete r[t.name]),r.error="Inconsistent object length",{verified:!1,result:r})}for(let l=0;l<c;l++)if(l-n>=e.valueBlock.value.length){if(t.valueBlock.value[l].optional===!1){const f={verified:!1,result:r};return r.error="Inconsistent length between ASN.1 data and schema",t.name&&(t.name=t.name.replace(/^\s+|\s+$/g,Y),t.name&&(delete r[t.name],f.name=t.name)),f}}else if(t.valueBlock.value[0]instanceof hr){if(s=Te(r,e.valueBlock.value[l],t.valueBlock.value[0].value),s.verified===!1)if(t.valueBlock.value[0].optional)n++;else return t.name&&(t.name=t.name.replace(/^\s+|\s+$/g,Y),t.name&&delete r[t.name]),s;if(si in t.valueBlock.value[0]&&t.valueBlock.value[0].name.length>0){let f={};La in t.valueBlock.value[0]&&t.valueBlock.value[0].local?f=e:f=r,typeof f[t.valueBlock.value[0].name]=="undefined"&&(f[t.valueBlock.value[0].name]=[]),f[t.valueBlock.value[0].name].push(e.valueBlock.value[l])}}else if(s=Te(r,e.valueBlock.value[l-n],t.valueBlock.value[l]),s.verified===!1)if(t.valueBlock.value[l].optional)n++;else return t.name&&(t.name=t.name.replace(/^\s+|\s+$/g,Y),t.name&&delete r[t.name]),s;if(s.verified===!1){const l={verified:!1,result:r};return t.name&&(t.name=t.name.replace(/^\s+|\s+$/g,Y),t.name&&(delete r[t.name],l.name=t.name)),l}return{verified:!0,result:r}}if(t.primitiveSchema&&ln in e.valueBlock){const n=Ye(e.valueBlock.valueHexView);if(n.offset===-1){const s={verified:!1,result:n.result};return t.name&&(t.name=t.name.replace(/^\s+|\s+$/g,Y),t.name&&(delete r[t.name],s.name=t.name)),s}return Te(r,n.result,t.primitiveSchema)}return{verified:!0,result:r}}function qa(r,e){if(!(e instanceof Object))return{verified:!1,result:{error:"Wrong ASN.1 schema type"}};const t=Ye(N.toUint8Array(r));return t.offset===-1?{verified:!1,result:t.result}:Te(t.result,t.result,e)}var ns=Object.freeze({__proto__:null,Any:Me,BaseBlock:q,BaseStringBlock:ai,BitString:$e,BmpString:tr,Boolean:Zt,CharacterString:ur,Choice:wi,Constructed:J,DATE:di,DateTime:gi,Duration:vi,EndOfContent:ci,Enumerated:Qt,GeneralString:lr,GeneralizedTime:fr,GraphicString:cr,HexBlock:ve,IA5String:ar,Integer:Qe,Null:Le,NumericString:ir,ObjectIdentifier:er,OctetString:He,Primitive:At,PrintableString:or,RawData:_a,RelativeObjectIdentifier:pi,Repeated:hr,Sequence:ae,Set:me,TIME:mi,TeletexString:nr,TimeOfDay:yi,UTCTime:kt,UniversalString:rr,Utf8String:Se,ValueBlock:W,VideotexString:sr,ViewWriter:Kt,VisibleString:Bt,compareSchema:Te,fromBER:Ze,verifySchema:qa}),v;(function(r){r[r.Sequence=0]="Sequence",r[r.Set=1]="Set",r[r.Choice=2]="Choice"})(v||(v={}));var h;(function(r){r[r.Any=1]="Any",r[r.Boolean=2]="Boolean",r[r.OctetString=3]="OctetString",r[r.BitString=4]="BitString",r[r.Integer=5]="Integer",r[r.Enumerated=6]="Enumerated",r[r.ObjectIdentifier=7]="ObjectIdentifier",r[r.Utf8String=8]="Utf8String",r[r.BmpString=9]="BmpString",r[r.UniversalString=10]="UniversalString",r[r.NumericString=11]="NumericString",r[r.PrintableString=12]="PrintableString",r[r.TeletexString=13]="TeletexString",r[r.VideotexString=14]="VideotexString",r[r.IA5String=15]="IA5String",r[r.GraphicString=16]="GraphicString",r[r.VisibleString=17]="VisibleString",r[r.GeneralString=18]="GeneralString",r[r.CharacterString=19]="CharacterString",r[r.UTCTime=20]="UTCTime",r[r.GeneralizedTime=21]="GeneralizedTime",r[r.DATE=22]="DATE",r[r.TimeOfDay=23]="TimeOfDay",r[r.DateTime=24]="DateTime",r[r.Duration=25]="Duration",r[r.TIME=26]="TIME",r[r.Null=27]="Null"})(h||(h={}));class pr{constructor(e,t=0){if(this.unusedBits=0,this.value=new ArrayBuffer(0),e)if(typeof e=="number")this.fromNumber(e);else if(N.isBufferSource(e))this.unusedBits=t,this.value=N.toArrayBuffer(e);else throw TypeError("Unsupported type of 'params' argument for BitString")}fromASN(e){if(!(e instanceof $e))throw new TypeError("Argument 'asn' is not instance of ASN.1 BitString");return this.unusedBits=e.valueBlock.unusedBits,this.value=e.valueBlock.valueHex,this}toASN(){return new $e({unusedBits:this.unusedBits,valueHex:this.value})}toSchema(e){return new $e({name:e})}toNumber(){let e="";const t=new Uint8Array(this.value);for(const i of t)e+=i.toString(2).padStart(8,"0");return e=e.split("").reverse().join(""),this.unusedBits&&(e=e.slice(this.unusedBits).padStart(this.unusedBits,"0")),parseInt(e,2)}fromNumber(e){let t=e.toString(2);const i=t.length+7>>3;this.unusedBits=(i<<3)-t.length;const o=new Uint8Array(i);t=t.padStart(i<<3,"0").split("").reverse().join("");let n=0;for(;n<i;)o[n]=parseInt(t.slice(n<<3,(n<<3)+8),2),n++;this.value=o.buffer}}class C{get byteLength(){return this.buffer.byteLength}get byteOffset(){return 0}constructor(e){typeof e=="number"?this.buffer=new ArrayBuffer(e):N.isBufferSource(e)?this.buffer=N.toArrayBuffer(e):Array.isArray(e)?this.buffer=new Uint8Array(e):this.buffer=new ArrayBuffer(0)}fromASN(e){if(!(e instanceof He))throw new TypeError("Argument 'asn' is not instance of ASN.1 OctetString");return this.buffer=e.valueBlock.valueHex,this}toASN(){return new He({valueHex:this.buffer})}toSchema(e){return new He({name:e})}}const Fa={fromASN:r=>r instanceof Le?null:r.valueBeforeDecodeView,toASN:r=>{if(r===null)return new Le;const e=Ze(r);if(e.result.error)throw new Error(e.result.error);return e.result}},Ga={fromASN:r=>r.valueBlock.valueHexView.byteLength>=4?r.valueBlock.toString():r.valueBlock.valueDec,toASN:r=>new Qe({value:+r})},za={fromASN:r=>r.valueBlock.valueDec,toASN:r=>new Qt({value:r})},re={fromASN:r=>r.valueBlock.valueHexView,toASN:r=>new Qe({valueHex:r})},Xa={fromASN:r=>r.valueBlock.valueHexView,toASN:r=>new $e({valueHex:r})},Wa={fromASN:r=>r.valueBlock.toString(),toASN:r=>new er({value:r})},Ja={fromASN:r=>r.valueBlock.value,toASN:r=>new Zt({value:r})},bi={fromASN:r=>r.valueBlock.valueHexView,toASN:r=>new He({valueHex:r})},Ka={fromASN:r=>new C(r.getValue()),toASN:r=>r.toASN()};function oe(r){return{fromASN:e=>e.valueBlock.value,toASN:e=>new r({value:e})}}const Ya=oe(Se),Za=oe(tr),Qa=oe(rr),ec=oe(ir),tc=oe(or),rc=oe(nr),ic=oe(sr),oc=oe(ar),nc=oe(cr),sc=oe(Bt),ac=oe(lr),cc=oe(ur),lc={fromASN:r=>r.toDate(),toASN:r=>new kt({valueDate:r})},uc={fromASN:r=>r.toDate(),toASN:r=>new fr({valueDate:r})},fc={fromASN:()=>null,toASN:()=>new Le};function xt(r){switch(r){case h.Any:return Fa;case h.BitString:return Xa;case h.BmpString:return Za;case h.Boolean:return Ja;case h.CharacterString:return cc;case h.Enumerated:return za;case h.GeneralString:return ac;case h.GeneralizedTime:return uc;case h.GraphicString:return nc;case h.IA5String:return oc;case h.Integer:return Ga;case h.Null:return fc;case h.NumericString:return ec;case h.ObjectIdentifier:return Wa;case h.OctetString:return bi;case h.PrintableString:return tc;case h.TeletexString:return rc;case h.UTCTime:return lc;case h.UniversalString:return Qa;case h.Utf8String:return Ya;case h.VideotexString:return ic;case h.VisibleString:return sc;default:return null}}function Be(r){return typeof r=="function"&&r.prototype?r.prototype.toASN&&r.prototype.fromASN?!0:Be(r.prototype):!!(r&&typeof r=="object"&&"toASN"in r&&"fromASN"in r)}function ss(r){var e;if(r){const t=Object.getPrototypeOf(r);return((e=t==null?void 0:t.prototype)===null||e===void 0?void 0:e.constructor)===Array?!0:ss(t)}return!1}function hc(r,e){if(!(r&&e)||r.byteLength!==e.byteLength)return!1;const t=new Uint8Array(r),i=new Uint8Array(e);for(let o=0;o<r.byteLength;o++)if(t[o]!==i[o])return!1;return!0}class pc{constructor(){this.items=new WeakMap}has(e){return this.items.has(e)}get(e,t=!1){const i=this.items.get(e);if(!i)throw new Error(`Cannot get schema for '${e.prototype.constructor.name}' target`);if(t&&!i.schema)throw new Error(`Schema '${e.prototype.constructor.name}' doesn't contain ASN.1 schema. Call 'AsnSchemaStorage.cache'.`);return i}cache(e){const t=this.get(e);t.schema||(t.schema=this.create(e,!0))}createDefault(e){const t={type:v.Sequence,items:{}},i=this.findParentSchema(e);return i&&(Object.assign(t,i),t.items=Object.assign({},t.items,i.items)),t}create(e,t){const i=this.items.get(e)||this.createDefault(e),o=[];for(const n in i.items){const s=i.items[n],c=t?n:"";let l;if(typeof s.type=="number"){const p=h[s.type],d=ns[p];if(!d)throw new Error(`Cannot get ASN1 class by name '${p}'`);l=new d({name:c})}else Be(s.type)?l=new s.type().toSchema(c):s.optional?this.get(s.type).type===v.Choice?l=new Me({name:c}):(l=this.create(s.type,!1),l.name=c):l=new Me({name:c});const f=!!s.optional||s.defaultValue!==void 0;if(s.repeated){l.name="";const p=s.repeated==="set"?me:ae;l=new p({name:"",value:[new hr({name:c,value:l})]})}if(s.context!==null&&s.context!==void 0)if(s.implicit)if(typeof s.type=="number"||Be(s.type)){const p=s.repeated?J:At;o.push(new p({name:c,optional:f,idBlock:{tagClass:3,tagNumber:s.context}}))}else{this.cache(s.type);const p=!!s.repeated;let d=p?l:this.get(s.type,!0).schema;d="valueBlock"in d?d.valueBlock.value:d.value,o.push(new J({name:p?"":c,optional:f,idBlock:{tagClass:3,tagNumber:s.context},value:d}))}else o.push(new J({optional:f,idBlock:{tagClass:3,tagNumber:s.context},value:[l]}));else l.optional=f,o.push(l)}switch(i.type){case v.Sequence:return new ae({value:o,name:""});case v.Set:return new me({value:o,name:""});case v.Choice:return new wi({value:o,name:""});default:throw new Error("Unsupported ASN1 type in use")}}set(e,t){return this.items.set(e,t),this}findParentSchema(e){const t=Object.getPrototypeOf(e);return t?this.items.get(t)||this.findParentSchema(t):null}}const F=new pc,A=r=>e=>{let t;F.has(e)?t=F.get(e):(t=F.createDefault(e),F.set(e,t)),Object.assign(t,r)},u=r=>(e,t)=>{let i;F.has(e.constructor)?i=F.get(e.constructor):(i=F.createDefault(e.constructor),F.set(e.constructor,i));const o=Object.assign({},r);if(typeof o.type=="number"&&!o.converter){const n=xt(r.type);if(!n)throw new Error(`Cannot get default converter for property '${t}' of ${e.constructor.name}`);o.converter=n}o.raw=r.raw,i.items[t]=o};class Nt extends Error{constructor(){super(...arguments),this.schemas=[]}}class dc{static parse(e,t){const i=Ze(e);if(i.result.error)throw new Error(i.result.error);return this.fromASN(i.result,t)}static fromASN(e,t){try{if(Be(t))return new t().fromASN(e);const i=F.get(t);F.cache(t);let o=i.schema;const n=this.handleChoiceTypes(e,i,t,o);if(n!=null&&n.result)return n.result;n!=null&&n.targetSchema&&(o=n.targetSchema);const s=this.handleSequenceTypes(e,i,t,o),c=new t;return ss(t)?this.handleArrayTypes(e,i,t):(this.processSchemaItems(i,s,c),c)}catch(i){throw i instanceof Nt&&i.schemas.push(t.name),i}}static handleChoiceTypes(e,t,i,o){if(e.constructor===J&&t.type===v.Choice&&e.idBlock.tagClass===3)for(const n in t.items){const s=t.items[n];if(s.context===e.idBlock.tagNumber&&s.implicit&&typeof s.type=="function"&&F.has(s.type)){const c=F.get(s.type);if(c&&c.type===v.Sequence){const l=new ae;if("value"in e.valueBlock&&Array.isArray(e.valueBlock.value)&&"value"in l.valueBlock){l.valueBlock.value=e.valueBlock.value;const f=this.fromASN(l,s.type),p=new i;return p[n]=f,{result:p}}}}}else if(e.constructor===J&&t.type!==v.Choice){const n=new J({idBlock:{tagClass:3,tagNumber:e.idBlock.tagNumber},value:t.schema.valueBlock.value});for(const s in t.items)delete e[s];return{targetSchema:n}}return null}static handleSequenceTypes(e,t,i,o){if(t.type===v.Sequence){const n=Te({},e,o);if(!n.verified)throw new Nt(`Data does not match to ${i.name} ASN1 schema.${n.result.error?` ${n.result.error}`:""}`);return n}else{const n=Te({},e,o);if(!n.verified)throw new Nt(`Data does not match to ${i.name} ASN1 schema.${n.result.error?` ${n.result.error}`:""}`);return n}}static processRepeatedField(e,t,i){let o=e.slice(t);if(o.length===1&&o[0].constructor.name==="Sequence"){const n=o[0];n.valueBlock&&n.valueBlock.value&&Array.isArray(n.valueBlock.value)&&(o=n.valueBlock.value)}if(typeof i.type=="number"){const n=xt(i.type);if(!n)throw new Error(`No converter for ASN.1 type ${i.type}`);return o.filter(s=>s&&s.valueBlock).map(s=>{try{return n.fromASN(s)}catch(c){return}}).filter(s=>s!==void 0)}else return o.filter(n=>n&&n.valueBlock).map(n=>{try{return this.fromASN(n,i.type)}catch(s){return}}).filter(n=>n!==void 0)}static processPrimitiveField(e,t){const i=xt(t.type);if(!i)throw new Error(`No converter for ASN.1 type ${t.type}`);return i.fromASN(e)}static isOptionalChoiceField(e){return e.optional&&typeof e.type=="function"&&F.has(e.type)&&F.get(e.type).type===v.Choice}static processOptionalChoiceField(e,t){try{return{processed:!0,value:this.fromASN(e,t.type)}}catch(i){if(i instanceof Nt&&/Wrong values for Choice type/.test(i.message))return{processed:!1};throw i}}static handleArrayTypes(e,t,i){if(!("value"in e.valueBlock&&Array.isArray(e.valueBlock.value)))throw new Error("Cannot get items from the ASN.1 parsed value. ASN.1 object is not constructed.");const o=t.itemType;if(typeof o=="number"){const n=xt(o);if(!n)throw new Error(`Cannot get default converter for array item of ${i.name} ASN1 schema`);return i.from(e.valueBlock.value,s=>n.fromASN(s))}else return i.from(e.valueBlock.value,n=>this.fromASN(n,o))}static processSchemaItems(e,t,i){for(const o in e.items){const n=t.result[o];if(!n)continue;const s=e.items[o],c=s.type;let l;typeof c=="number"||Be(c)?l=this.processPrimitiveSchemaItem(n,s,c):l=this.processComplexSchemaItem(n,s,c),l&&typeof l=="object"&&"value"in l&&"raw"in l?(i[o]=l.value,i[`${o}Raw`]=l.raw):i[o]=l}}static processPrimitiveSchemaItem(e,t,i){var o;const n=(o=t.converter)!==null&&o!==void 0?o:Be(i)?new i:null;if(!n)throw new Error("Converter is empty");return t.repeated?this.processRepeatedPrimitiveItem(e,t,n):this.processSinglePrimitiveItem(e,t,i,n)}static processRepeatedPrimitiveItem(e,t,i){if(t.implicit){const o=t.repeated==="sequence"?ae:me,n=new o;n.valueBlock=e.valueBlock;const s=Ze(n.toBER(!1));if(s.offset===-1)throw new Error(`Cannot parse the child item. ${s.result.error}`);if(!("value"in s.result.valueBlock&&Array.isArray(s.result.valueBlock.value)))throw new Error("Cannot get items from the ASN.1 parsed value. ASN.1 object is not constructed.");const c=s.result.valueBlock.value;return Array.from(c,l=>i.fromASN(l))}else return Array.from(e,o=>i.fromASN(o))}static processSinglePrimitiveItem(e,t,i,o){let n=e;if(t.implicit){let s;if(Be(i))s=new i().toSchema("");else{const c=h[i],l=ns[c];if(!l)throw new Error(`Cannot get '${c}' class from asn1js module`);s=new l}s.valueBlock=n.valueBlock,n=Ze(s.toBER(!1)).result}return o.fromASN(n)}static processComplexSchemaItem(e,t,i){if(t.repeated){if(!Array.isArray(e))throw new Error("Cannot get list of items from the ASN.1 parsed value. ASN.1 value should be iterable.");return Array.from(e,o=>this.fromASN(o,i))}else{const o=this.handleImplicitTagging(e,t,i);if(this.isOptionalChoiceField(t))try{return this.fromASN(o,i)}catch(n){if(n instanceof Nt&&/Wrong values for Choice type/.test(n.message))return;throw n}else{const n=this.fromASN(o,i);return t.raw?{value:n,raw:e.valueBeforeDecodeView}:n}}}static handleImplicitTagging(e,t,i){if(t.implicit&&typeof t.context=="number"){const o=F.get(i);if(o.type===v.Sequence){const n=new ae;if("value"in e.valueBlock&&Array.isArray(e.valueBlock.value)&&"value"in n.valueBlock)return n.valueBlock.value=e.valueBlock.value,n}else if(o.type===v.Set){const n=new me;if("value"in e.valueBlock&&Array.isArray(e.valueBlock.value)&&"value"in n.valueBlock)return n.valueBlock.value=e.valueBlock.value,n}}return e}}class Ai{static serialize(e){return e instanceof q?e.toBER(!1):this.toASN(e).toBER(!1)}static toASN(e){if(e&&typeof e=="object"&&Be(e))return e.toASN();if(!(e&&typeof e=="object"))throw new TypeError("Parameter 1 should be type of Object.");const t=e.constructor,i=F.get(t);F.cache(t);let o=[];if(i.itemType){if(!Array.isArray(e))throw new TypeError("Parameter 1 should be type of Array.");if(typeof i.itemType=="number"){const s=xt(i.itemType);if(!s)throw new Error(`Cannot get default converter for array item of ${t.name} ASN1 schema`);o=e.map(c=>s.toASN(c))}else o=e.map(s=>this.toAsnItem({type:i.itemType},"[]",t,s))}else for(const s in i.items){const c=i.items[s],l=e[s];if(l===void 0||c.defaultValue===l||typeof c.defaultValue=="object"&&typeof l=="object"&&hc(this.serialize(c.defaultValue),this.serialize(l)))continue;const f=Ai.toAsnItem(c,s,t,l);if(typeof c.context=="number")if(c.implicit)if(!c.repeated&&(typeof c.type=="number"||Be(c.type))){const p={};p.valueHex=f instanceof Le?f.valueBeforeDecodeView:f.valueBlock.toBER(),o.push(new At(T({optional:c.optional,idBlock:{tagClass:3,tagNumber:c.context}},p)))}else o.push(new J({optional:c.optional,idBlock:{tagClass:3,tagNumber:c.context},value:f.valueBlock.value}));else o.push(new J({optional:c.optional,idBlock:{tagClass:3,tagNumber:c.context},value:[f]}));else c.repeated?o=o.concat(f):o.push(f)}let n;switch(i.type){case v.Sequence:n=new ae({value:o});break;case v.Set:n=new me({value:o});break;case v.Choice:if(!o[0])throw new Error(`Schema '${t.name}' has wrong data. Choice cannot be empty.`);n=o[0];break}return n}static toAsnItem(e,t,i,o){let n;if(typeof e.type=="number"){const s=e.converter;if(!s)throw new Error(`Property '${t}' doesn't have converter for type ${h[e.type]} in schema '${i.name}'`);if(e.repeated){if(!Array.isArray(o))throw new TypeError("Parameter 'objProp' should be type of Array.");const c=Array.from(o,f=>s.toASN(f)),l=e.repeated==="sequence"?ae:me;n=new l({value:c})}else n=s.toASN(o)}else if(e.repeated){if(!Array.isArray(o))throw new TypeError("Parameter 'objProp' should be type of Array.");const s=Array.from(o,l=>this.toASN(l)),c=e.repeated==="sequence"?ae:me;n=new c({value:s})}else n=this.toASN(o);return n}}class j extends Array{constructor(e=[]){if(typeof e=="number")super(e);else{super();for(const t of e)this.push(t)}}}class ce{static serialize(e){return Ai.serialize(e)}static parse(e,t){return dc.parse(e,t)}static toString(e){const t=N.isBufferSource(e)?N.toArrayBuffer(e):ce.serialize(e),i=Ze(t);if(i.offset===-1)throw new Error(`Cannot decode ASN.1 data. ${i.result.error}`);return i.result.toString()}}function a(r,e,t,i){var o=arguments.length,n=o<3?e:i===null?i=Object.getOwnPropertyDescriptor(e,t):i,s;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")n=Reflect.decorate(r,e,t,i);else for(var c=r.length-1;c>=0;c--)(s=r[c])&&(n=(o<3?s(n):o>3?s(e,t,n):s(e,t))||n);return o>3&&n&&Object.defineProperty(e,t,n),n}typeof SuppressedError=="function"&&SuppressedError;var Si;let as=Si=class extends j{constructor(e){super(e),Object.setPrototypeOf(this,Si.prototype)}};as=Si=a([A({type:v.Sequence,itemType:h.ObjectIdentifier})],as);let Bi=class{constructor(e=new Date){this.value=e}};a([u({type:h.GeneralizedTime})],Bi.prototype,"value",void 0),Bi=a([A({type:v.Choice})],Bi);let ki=class{constructor(e=null){this.value=e}};a([u({type:h.Null})],ki.prototype,"value",void 0),ki=a([A({type:v.Choice})],ki);class cs{static isIPv4(e){return/^(\d{1,3}\.){3}\d{1,3}$/.test(e)}static parseIPv4(e){const t=e.split(".");if(t.length!==4)throw new Error("Invalid IPv4 address");return t.map(i=>{const o=parseInt(i,10);if(isNaN(o)||o<0||o>255)throw new Error("Invalid IPv4 address part");return o})}static parseIPv6(e){const i=this.expandIPv6(e).split(":");if(i.length!==8)throw new Error("Invalid IPv6 address");return i.reduce((o,n)=>{const s=parseInt(n,16);if(isNaN(s)||s<0||s>65535)throw new Error("Invalid IPv6 address part");return o.push(s>>8&255),o.push(s&255),o},[])}static expandIPv6(e){if(!e.includes("::"))return e;const t=e.split("::");if(t.length>2)throw new Error("Invalid IPv6 address");const i=t[0]?t[0].split(":"):[],o=t[1]?t[1].split(":"):[],n=8-(i.length+o.length);if(n<0)throw new Error("Invalid IPv6 address");return[...i,...Array(n).fill("0"),...o].join(":")}static formatIPv6(e){const t=[];for(let i=0;i<16;i+=2)t.push((e[i]<<8|e[i+1]).toString(16));return this.compressIPv6(t.join(":"))}static compressIPv6(e){const t=e.split(":");let i=-1,o=0,n=-1,s=0;for(let c=0;c<t.length;c++)t[c]==="0"?(n===-1&&(n=c),s++):(s>o&&(i=n,o=s),n=-1,s=0);if(s>o&&(i=n,o=s),o>1){const c=t.slice(0,i).join(":"),l=t.slice(i+o).join(":");return`${c}::${l}`}return e}static parseCIDR(e){const[t,i]=e.split("/"),o=parseInt(i,10);if(this.isIPv4(t)){if(o<0||o>32)throw new Error("Invalid IPv4 prefix length");return[this.parseIPv4(t),o]}else{if(o<0||o>128)throw new Error("Invalid IPv6 prefix length");return[this.parseIPv6(t),o]}}static decodeIP(e){if(e.length===64&&parseInt(e,16)===0)return"::/0";if(e.length!==16)return e;const t=parseInt(e.slice(8),16).toString(2).split("").reduce((o,n)=>o+ +n,0);let i=e.slice(0,8).replace(/(.{2})/g,o=>`${parseInt(o,16)}.`);return i=i.slice(0,-1),`${i}/${t}`}static toString(e){const t=new Uint8Array(e);if(t.length===4)return Array.from(t).join(".");if(t.length===16)return this.formatIPv6(t);if(t.length===8||t.length===32){const i=t.length/2,o=t.slice(0,i),n=t.slice(i);if(t.every(l=>l===0))return t.length===8?"0.0.0.0/0":"::/0";const c=n.reduce((l,f)=>l+(f.toString(2).match(/1/g)||[]).length,0);return t.length===8?`${Array.from(o).join(".")}/${c}`:`${this.formatIPv6(o)}/${c}`}return this.decodeIP(U.ToHex(e))}static fromString(e){if(e.includes("/")){const[i,o]=this.parseCIDR(e),n=new Uint8Array(i.length);let s=o;for(let l=0;l<n.length;l++)s>=8?(n[l]=255,s-=8):s>0&&(n[l]=255<<8-s,s=0);const c=new Uint8Array(i.length*2);return c.set(i,0),c.set(n,i.length),c.buffer}const t=this.isIPv4(e)?this.parseIPv4(e):this.parseIPv6(e);return new Uint8Array(t).buffer}}var xi,Ni,Ci;let le=class{constructor(e={}){Object.assign(this,e)}toString(){return this.bmpString||this.printableString||this.teletexString||this.universalString||this.utf8String||""}};a([u({type:h.TeletexString})],le.prototype,"teletexString",void 0),a([u({type:h.PrintableString})],le.prototype,"printableString",void 0),a([u({type:h.UniversalString})],le.prototype,"universalString",void 0),a([u({type:h.Utf8String})],le.prototype,"utf8String",void 0),a([u({type:h.BmpString})],le.prototype,"bmpString",void 0),le=a([A({type:v.Choice})],le);let et=class extends le{constructor(e={}){super(e),Object.assign(this,e)}toString(){return this.ia5String||(this.anyValue?U.ToHex(this.anyValue):super.toString())}};a([u({type:h.IA5String})],et.prototype,"ia5String",void 0),a([u({type:h.Any})],et.prototype,"anyValue",void 0),et=a([A({type:v.Choice})],et);class Ei{constructor(e={}){this.type="",this.value=new et,Object.assign(this,e)}}a([u({type:h.ObjectIdentifier})],Ei.prototype,"type",void 0),a([u({type:et})],Ei.prototype,"value",void 0);let dr=xi=class extends j{constructor(e){super(e),Object.setPrototypeOf(this,xi.prototype)}};dr=xi=a([A({type:v.Set,itemType:Ei})],dr);let Ii=Ni=class extends j{constructor(e){super(e),Object.setPrototypeOf(this,Ni.prototype)}};Ii=Ni=a([A({type:v.Sequence,itemType:dr})],Ii);let Z=Ci=class extends Ii{constructor(e){super(e),Object.setPrototypeOf(this,Ci.prototype)}};Z=Ci=a([A({type:v.Sequence})],Z);const yc={fromASN:r=>cs.toString(bi.fromASN(r)),toASN:r=>bi.toASN(cs.fromString(r))};class Oi{constructor(e={}){this.typeId="",this.value=new ArrayBuffer(0),Object.assign(this,e)}}a([u({type:h.ObjectIdentifier})],Oi.prototype,"typeId",void 0),a([u({type:h.Any,context:0})],Oi.prototype,"value",void 0);class Ti{constructor(e={}){this.partyName=new le,Object.assign(this,e)}}a([u({type:le,optional:!0,context:0,implicit:!0})],Ti.prototype,"nameAssigner",void 0),a([u({type:le,context:1,implicit:!0})],Ti.prototype,"partyName",void 0);let E=class{constructor(e={}){Object.assign(this,e)}};a([u({type:Oi,context:0,implicit:!0})],E.prototype,"otherName",void 0),a([u({type:h.IA5String,context:1,implicit:!0})],E.prototype,"rfc822Name",void 0),a([u({type:h.IA5String,context:2,implicit:!0})],E.prototype,"dNSName",void 0),a([u({type:h.Any,context:3,implicit:!0})],E.prototype,"x400Address",void 0),a([u({type:Z,context:4,implicit:!1})],E.prototype,"directoryName",void 0),a([u({type:Ti,context:5})],E.prototype,"ediPartyName",void 0),a([u({type:h.IA5String,context:6,implicit:!0})],E.prototype,"uniformResourceIdentifier",void 0),a([u({type:h.OctetString,context:7,implicit:!0,converter:yc})],E.prototype,"iPAddress",void 0),a([u({type:h.ObjectIdentifier,context:8,implicit:!0})],E.prototype,"registeredID",void 0),E=a([A({type:v.Choice})],E);var Vi;class yr{constructor(e={}){this.accessMethod="",this.accessLocation=new E,Object.assign(this,e)}}a([u({type:h.ObjectIdentifier})],yr.prototype,"accessMethod",void 0),a([u({type:E})],yr.prototype,"accessLocation",void 0);let gr=Vi=class extends j{constructor(e){super(e),Object.setPrototypeOf(this,Vi.prototype)}};gr=Vi=a([A({type:v.Sequence,itemType:yr})],gr);class ls extends C{}class ji{constructor(e={}){e&&Object.assign(this,e)}}a([u({type:ls,context:0,optional:!0,implicit:!0})],ji.prototype,"keyIdentifier",void 0),a([u({type:E,context:1,optional:!0,implicit:!0,repeated:"sequence"})],ji.prototype,"authorityCertIssuer",void 0),a([u({type:h.Integer,context:2,optional:!0,implicit:!0,converter:re})],ji.prototype,"authorityCertSerialNumber",void 0);class us{constructor(e={}){this.cA=!1,Object.assign(this,e)}}a([u({type:h.Boolean,defaultValue:!1})],us.prototype,"cA",void 0),a([u({type:h.Integer,optional:!0})],us.prototype,"pathLenConstraint",void 0);var Ui;let ue=Ui=class extends j{constructor(e){super(e),Object.setPrototypeOf(this,Ui.prototype)}};ue=Ui=a([A({type:v.Sequence,itemType:E})],ue);var Di;let fs=Di=class extends ue{constructor(e){super(e),Object.setPrototypeOf(this,Di.prototype)}};fs=Di=a([A({type:v.Sequence})],fs);var Ri;let ke=class{constructor(e={}){Object.assign(this,e)}toString(){return this.ia5String||this.visibleString||this.bmpString||this.utf8String||""}};a([u({type:h.IA5String})],ke.prototype,"ia5String",void 0),a([u({type:h.VisibleString})],ke.prototype,"visibleString",void 0),a([u({type:h.BmpString})],ke.prototype,"bmpString",void 0),a([u({type:h.Utf8String})],ke.prototype,"utf8String",void 0),ke=a([A({type:v.Choice})],ke);class Li{constructor(e={}){this.organization=new ke,this.noticeNumbers=[],Object.assign(this,e)}}a([u({type:ke})],Li.prototype,"organization",void 0),a([u({type:h.Integer,repeated:"sequence"})],Li.prototype,"noticeNumbers",void 0);class Hi{constructor(e={}){Object.assign(this,e)}}a([u({type:Li,optional:!0})],Hi.prototype,"noticeRef",void 0),a([u({type:ke,optional:!0})],Hi.prototype,"explicitText",void 0);let vr=class{constructor(e={}){Object.assign(this,e)}};a([u({type:h.IA5String})],vr.prototype,"cPSuri",void 0),a([u({type:Hi})],vr.prototype,"userNotice",void 0),vr=a([A({type:v.Choice})],vr);class $i{constructor(e={}){this.policyQualifierId="",this.qualifier=new ArrayBuffer(0),Object.assign(this,e)}}a([u({type:h.ObjectIdentifier})],$i.prototype,"policyQualifierId",void 0),a([u({type:h.Any})],$i.prototype,"qualifier",void 0);class Mi{constructor(e={}){this.policyIdentifier="",Object.assign(this,e)}}a([u({type:h.ObjectIdentifier})],Mi.prototype,"policyIdentifier",void 0),a([u({type:$i,repeated:"sequence",optional:!0})],Mi.prototype,"policyQualifiers",void 0);let hs=Ri=class extends j{constructor(e){super(e),Object.setPrototypeOf(this,Ri.prototype)}};hs=Ri=a([A({type:v.Sequence,itemType:Mi})],hs);let mr=class{constructor(e=0){this.value=e}};a([u({type:h.Integer})],mr.prototype,"value",void 0),mr=a([A({type:v.Choice})],mr);let ps=class extends mr{};ps=a([A({type:v.Choice})],ps);var Pi,fe;(function(r){r[r.unused=1]="unused",r[r.keyCompromise=2]="keyCompromise",r[r.cACompromise=4]="cACompromise",r[r.affiliationChanged=8]="affiliationChanged",r[r.superseded=16]="superseded",r[r.cessationOfOperation=32]="cessationOfOperation",r[r.certificateHold=64]="certificateHold",r[r.privilegeWithdrawn=128]="privilegeWithdrawn",r[r.aACompromise=256]="aACompromise"})(fe||(fe={}));class ds extends pr{toJSON(){const e=[],t=this.toNumber();return t&fe.aACompromise&&e.push("aACompromise"),t&fe.affiliationChanged&&e.push("affiliationChanged"),t&fe.cACompromise&&e.push("cACompromise"),t&fe.certificateHold&&e.push("certificateHold"),t&fe.cessationOfOperation&&e.push("cessationOfOperation"),t&fe.keyCompromise&&e.push("keyCompromise"),t&fe.privilegeWithdrawn&&e.push("privilegeWithdrawn"),t&fe.superseded&&e.push("superseded"),t&fe.unused&&e.push("unused"),e}toString(){return`[${this.toJSON().join(", ")}]`}}let tt=class{constructor(e={}){Object.assign(this,e)}};a([u({type:E,context:0,repeated:"sequence",implicit:!0})],tt.prototype,"fullName",void 0),a([u({type:dr,context:1,implicit:!0})],tt.prototype,"nameRelativeToCRLIssuer",void 0),tt=a([A({type:v.Choice})],tt);class Ct{constructor(e={}){Object.assign(this,e)}}a([u({type:tt,context:0,optional:!0})],Ct.prototype,"distributionPoint",void 0),a([u({type:ds,context:1,optional:!0,implicit:!0})],Ct.prototype,"reasons",void 0),a([u({type:E,context:2,optional:!0,repeated:"sequence",implicit:!0})],Ct.prototype,"cRLIssuer",void 0);let _i=Pi=class extends j{constructor(e){super(e),Object.setPrototypeOf(this,Pi.prototype)}};_i=Pi=a([A({type:v.Sequence,itemType:Ct})],_i);var qi;let ys=qi=class extends _i{constructor(e){super(e),Object.setPrototypeOf(this,qi.prototype)}};ys=qi=a([A({type:v.Sequence,itemType:Ct})],ys);class G{constructor(e={}){this.onlyContainsUserCerts=G.ONLY,this.onlyContainsCACerts=G.ONLY,this.indirectCRL=G.ONLY,this.onlyContainsAttributeCerts=G.ONLY,Object.assign(this,e)}}G.ONLY=!1,a([u({type:tt,context:0,optional:!0})],G.prototype,"distributionPoint",void 0),a([u({type:h.Boolean,context:1,defaultValue:G.ONLY,implicit:!0})],G.prototype,"onlyContainsUserCerts",void 0),a([u({type:h.Boolean,context:2,defaultValue:G.ONLY,implicit:!0})],G.prototype,"onlyContainsCACerts",void 0),a([u({type:ds,context:3,optional:!0,implicit:!0})],G.prototype,"onlySomeReasons",void 0),a([u({type:h.Boolean,context:4,defaultValue:G.ONLY,implicit:!0})],G.prototype,"indirectCRL",void 0),a([u({type:h.Boolean,context:5,defaultValue:G.ONLY,implicit:!0})],G.prototype,"onlyContainsAttributeCerts",void 0);var Et;(function(r){r[r.unspecified=0]="unspecified",r[r.keyCompromise=1]="keyCompromise",r[r.cACompromise=2]="cACompromise",r[r.affiliationChanged=3]="affiliationChanged",r[r.superseded=4]="superseded",r[r.cessationOfOperation=5]="cessationOfOperation",r[r.certificateHold=6]="certificateHold",r[r.removeFromCRL=8]="removeFromCRL",r[r.privilegeWithdrawn=9]="privilegeWithdrawn",r[r.aACompromise=10]="aACompromise"})(Et||(Et={}));let wr=class{constructor(e=Et.unspecified){this.reason=Et.unspecified,this.reason=e}toJSON(){return Et[this.reason]}toString(){return this.toJSON()}};a([u({type:h.Enumerated})],wr.prototype,"reason",void 0),wr=a([A({type:v.Choice})],wr);var Fi;let gs=Fi=class extends j{constructor(e){super(e),Object.setPrototypeOf(this,Fi.prototype)}};gs=Fi=a([A({type:v.Sequence,itemType:h.ObjectIdentifier})],gs);let Gi=class{constructor(e=new ArrayBuffer(0)){this.value=e}};a([u({type:h.Integer,converter:re})],Gi.prototype,"value",void 0),Gi=a([A({type:v.Choice})],Gi);let zi=class{constructor(e){this.value=new Date,e&&(this.value=e)}};a([u({type:h.GeneralizedTime})],zi.prototype,"value",void 0),zi=a([A({type:v.Choice})],zi);var Xi;let vs=Xi=class extends ue{constructor(e){super(e),Object.setPrototypeOf(this,Xi.prototype)}};vs=Xi=a([A({type:v.Sequence})],vs);var ms;(function(r){r[r.digitalSignature=1]="digitalSignature",r[r.nonRepudiation=2]="nonRepudiation",r[r.keyEncipherment=4]="keyEncipherment",r[r.dataEncipherment=8]="dataEncipherment",r[r.keyAgreement=16]="keyAgreement",r[r.keyCertSign=32]="keyCertSign",r[r.cRLSign=64]="cRLSign",r[r.encipherOnly=128]="encipherOnly",r[r.decipherOnly=256]="decipherOnly"})(ms||(ms={}));var Wi;class br{constructor(e={}){this.base=new E,this.minimum=0,Object.assign(this,e)}}a([u({type:E})],br.prototype,"base",void 0),a([u({type:h.Integer,context:0,defaultValue:0,implicit:!0})],br.prototype,"minimum",void 0),a([u({type:h.Integer,context:1,optional:!0,implicit:!0})],br.prototype,"maximum",void 0);let Ar=Wi=class extends j{constructor(e){super(e),Object.setPrototypeOf(this,Wi.prototype)}};Ar=Wi=a([A({type:v.Sequence,itemType:br})],Ar);class ws{constructor(e={}){Object.assign(this,e)}}a([u({type:Ar,context:0,optional:!0,implicit:!0})],ws.prototype,"permittedSubtrees",void 0),a([u({type:Ar,context:1,optional:!0,implicit:!0})],ws.prototype,"excludedSubtrees",void 0);class bs{constructor(e={}){Object.assign(this,e)}}a([u({type:h.Integer,context:0,implicit:!0,optional:!0,converter:re})],bs.prototype,"requireExplicitPolicy",void 0),a([u({type:h.Integer,context:1,implicit:!0,optional:!0,converter:re})],bs.prototype,"inhibitPolicyMapping",void 0);var Ji;class Ki{constructor(e={}){this.issuerDomainPolicy="",this.subjectDomainPolicy="",Object.assign(this,e)}}a([u({type:h.ObjectIdentifier})],Ki.prototype,"issuerDomainPolicy",void 0),a([u({type:h.ObjectIdentifier})],Ki.prototype,"subjectDomainPolicy",void 0);let As=Ji=class extends j{constructor(e){super(e),Object.setPrototypeOf(this,Ji.prototype)}};As=Ji=a([A({type:v.Sequence,itemType:Ki})],As);var Yi;let Ss=Yi=class extends ue{constructor(e){super(e),Object.setPrototypeOf(this,Yi.prototype)}};Ss=Yi=a([A({type:v.Sequence})],Ss);class It{constructor(e={}){this.type="",this.values=[],Object.assign(this,e)}}a([u({type:h.ObjectIdentifier})],It.prototype,"type",void 0),a([u({type:h.Any,repeated:"set"})],It.prototype,"values",void 0);var Zi;let Bs=Zi=class extends j{constructor(e){super(e),Object.setPrototypeOf(this,Zi.prototype)}};Bs=Zi=a([A({type:v.Sequence,itemType:It})],Bs);class Ot extends ls{}class ks{constructor(e={}){Object.assign(this,e)}}a([u({type:h.GeneralizedTime,context:0,implicit:!0,optional:!0})],ks.prototype,"notBefore",void 0),a([u({type:h.GeneralizedTime,context:1,implicit:!0,optional:!0})],ks.prototype,"notAfter",void 0);var Tt;(function(r){r[r.keyUpdateAllowed=1]="keyUpdateAllowed",r[r.newExtensions=2]="newExtensions",r[r.pKIXCertificate=4]="pKIXCertificate"})(Tt||(Tt={}));class xs extends pr{toJSON(){const e=[],t=this.toNumber();return t&Tt.pKIXCertificate&&e.push("pKIXCertificate"),t&Tt.newExtensions&&e.push("newExtensions"),t&Tt.keyUpdateAllowed&&e.push("keyUpdateAllowed"),e}toString(){return`[${this.toJSON().join(", ")}]`}}class Ns{constructor(e={}){this.entrustVers="",this.entrustInfoFlags=new xs,Object.assign(this,e)}}a([u({type:h.GeneralString})],Ns.prototype,"entrustVers",void 0),a([u({type:xs})],Ns.prototype,"entrustInfoFlags",void 0);var Qi;let Cs=Qi=class extends j{constructor(e){super(e),Object.setPrototypeOf(this,Qi.prototype)}};Cs=Qi=a([A({type:v.Sequence,itemType:yr})],Cs);class k{constructor(e={}){this.algorithm="",Object.assign(this,e)}isEqual(e){return e instanceof k&&e.algorithm==this.algorithm&&(e.parameters&&this.parameters&&Ca(e.parameters,this.parameters)||e.parameters===this.parameters)}}a([u({type:h.ObjectIdentifier})],k.prototype,"algorithm",void 0),a([u({type:h.Any,optional:!0})],k.prototype,"parameters",void 0);class Sr{constructor(e={}){this.algorithm=new k,this.subjectPublicKey=new ArrayBuffer(0),Object.assign(this,e)}}a([u({type:k})],Sr.prototype,"algorithm",void 0),a([u({type:h.BitString})],Sr.prototype,"subjectPublicKey",void 0);let z=class{constructor(e){if(e)if(typeof e=="string"||typeof e=="number"||e instanceof Date){const t=new Date(e);t.getUTCFullYear()>2049?this.generalTime=t:this.utcTime=t}else Object.assign(this,e)}getTime(){const e=this.utcTime||this.generalTime;if(!e)throw new Error("Cannot get time from CHOICE object");return e}};a([u({type:h.UTCTime})],z.prototype,"utcTime",void 0),a([u({type:h.GeneralizedTime})],z.prototype,"generalTime",void 0),z=a([A({type:v.Choice})],z);class Br{constructor(e){this.notBefore=new z(new Date),this.notAfter=new z(new Date),e&&(this.notBefore=new z(e.notBefore),this.notAfter=new z(e.notAfter))}}a([u({type:z})],Br.prototype,"notBefore",void 0),a([u({type:z})],Br.prototype,"notAfter",void 0);var eo;class Q{constructor(e={}){this.extnID="",this.critical=Q.CRITICAL,this.extnValue=new C,Object.assign(this,e)}}Q.CRITICAL=!1,a([u({type:h.ObjectIdentifier})],Q.prototype,"extnID",void 0),a([u({type:h.Boolean,defaultValue:Q.CRITICAL})],Q.prototype,"critical",void 0),a([u({type:C})],Q.prototype,"extnValue",void 0);let rt=eo=class extends j{constructor(e){super(e),Object.setPrototypeOf(this,eo.prototype)}};rt=eo=a([A({type:v.Sequence,itemType:Q})],rt);var kr;(function(r){r[r.v1=0]="v1",r[r.v2=1]="v2",r[r.v3=2]="v3"})(kr||(kr={}));class ne{constructor(e={}){this.version=kr.v1,this.serialNumber=new ArrayBuffer(0),this.signature=new k,this.issuer=new Z,this.validity=new Br,this.subject=new Z,this.subjectPublicKeyInfo=new Sr,Object.assign(this,e)}}a([u({type:h.Integer,context:0,defaultValue:kr.v1})],ne.prototype,"version",void 0),a([u({type:h.Integer,converter:re})],ne.prototype,"serialNumber",void 0),a([u({type:k})],ne.prototype,"signature",void 0),a([u({type:Z})],ne.prototype,"issuer",void 0),a([u({type:Br})],ne.prototype,"validity",void 0),a([u({type:Z})],ne.prototype,"subject",void 0),a([u({type:Sr})],ne.prototype,"subjectPublicKeyInfo",void 0),a([u({type:h.BitString,context:1,implicit:!0,optional:!0})],ne.prototype,"issuerUniqueID",void 0),a([u({type:h.BitString,context:2,implicit:!0,optional:!0})],ne.prototype,"subjectUniqueID",void 0),a([u({type:rt,context:3,optional:!0})],ne.prototype,"extensions",void 0);class it{constructor(e={}){this.tbsCertificate=new ne,this.signatureAlgorithm=new k,this.signatureValue=new ArrayBuffer(0),Object.assign(this,e)}}a([u({type:ne,raw:!0})],it.prototype,"tbsCertificate",void 0),a([u({type:k})],it.prototype,"signatureAlgorithm",void 0),a([u({type:h.BitString})],it.prototype,"signatureValue",void 0);class xr{constructor(e={}){this.userCertificate=new ArrayBuffer(0),this.revocationDate=new z,Object.assign(this,e)}}a([u({type:h.Integer,converter:re})],xr.prototype,"userCertificate",void 0),a([u({type:z})],xr.prototype,"revocationDate",void 0),a([u({type:Q,optional:!0,repeated:"sequence"})],xr.prototype,"crlEntryExtensions",void 0);class xe{constructor(e={}){this.signature=new k,this.issuer=new Z,this.thisUpdate=new z,Object.assign(this,e)}}a([u({type:h.Integer,optional:!0})],xe.prototype,"version",void 0),a([u({type:k})],xe.prototype,"signature",void 0),a([u({type:Z})],xe.prototype,"issuer",void 0),a([u({type:z})],xe.prototype,"thisUpdate",void 0),a([u({type:z,optional:!0})],xe.prototype,"nextUpdate",void 0),a([u({type:xr,repeated:"sequence",optional:!0})],xe.prototype,"revokedCertificates",void 0),a([u({type:Q,optional:!0,context:0,repeated:"sequence"})],xe.prototype,"crlExtensions",void 0);class to{constructor(e={}){this.tbsCertList=new xe,this.signatureAlgorithm=new k,this.signature=new ArrayBuffer(0),Object.assign(this,e)}}a([u({type:xe,raw:!0})],to.prototype,"tbsCertList",void 0),a([u({type:k})],to.prototype,"signatureAlgorithm",void 0),a([u({type:h.BitString})],to.prototype,"signature",void 0);var ro;class io{constructor(e={}){this.sigIdentifier=new k,Object.assign(this,e)}}a([u({type:k})],io.prototype,"sigIdentifier",void 0),a([u({type:k,optional:!0})],io.prototype,"certIdentifier",void 0);let Es=ro=class extends j{constructor(e){super(e),Object.setPrototypeOf(this,ro.prototype)}};Es=ro=a([A({type:v.Sequence,itemType:io})],Es);class Is{constructor(e={}){this.issuer=new Z,this.locator=new gr,Object.assign(this,e)}}a([u({type:Z})],Is.prototype,"issuer",void 0),a([u({type:gr})],Is.prototype,"locator",void 0);class gc extends C{}let ot=class{constructor(e={}){Object.assign(this,e)}};a([u({type:Z,context:1})],ot.prototype,"byName",void 0),a([u({type:gc,context:2})],ot.prototype,"byKey",void 0),ot=a([A({type:v.Choice})],ot);class Ne{constructor(e={}){this.hashAlgorithm=new k,this.issuerNameHash=new C,this.issuerKeyHash=new C,this.serialNumber=new ArrayBuffer(0),Object.assign(this,e)}}a([u({type:k})],Ne.prototype,"hashAlgorithm",void 0),a([u({type:C})],Ne.prototype,"issuerNameHash",void 0),a([u({type:C})],Ne.prototype,"issuerKeyHash",void 0),a([u({type:h.Integer,converter:re})],Ne.prototype,"serialNumber",void 0);class oo{constructor(e={}){this.revocationTime=new Date,Object.assign(this,e)}}a([u({type:h.GeneralizedTime})],oo.prototype,"revocationTime",void 0),a([u({type:wr,context:0,optional:!0})],oo.prototype,"revocationReason",void 0);let Pe=class{constructor(e={}){Object.assign(this,e)}};a([u({type:h.Null,context:0,implicit:!0})],Pe.prototype,"good",void 0),a([u({type:oo,context:1,implicit:!0})],Pe.prototype,"revoked",void 0),a([u({type:h.Null,context:2,implicit:!0})],Pe.prototype,"unknown",void 0),Pe=a([A({type:v.Choice})],Pe);class nt{constructor(e={}){this.certID=new Ne,this.certStatus=new Pe,this.thisUpdate=new Date,Object.assign(this,e)}}a([u({type:Ne})],nt.prototype,"certID",void 0),a([u({type:Pe})],nt.prototype,"certStatus",void 0),a([u({type:h.GeneralizedTime})],nt.prototype,"thisUpdate",void 0),a([u({type:h.GeneralizedTime,context:0,optional:!0})],nt.prototype,"nextUpdate",void 0),a([u({type:Q,context:1,repeated:"sequence",optional:!0})],nt.prototype,"singleExtensions",void 0);var st;(function(r){r[r.v1=0]="v1"})(st||(st={}));class _e{constructor(e={}){this.version=st.v1,this.responderID=new ot,this.producedAt=new Date,this.responses=[],Object.assign(this,e)}}a([u({type:h.Integer,context:0,defaultValue:st.v1})],_e.prototype,"version",void 0),a([u({type:ot})],_e.prototype,"responderID",void 0),a([u({type:h.GeneralizedTime})],_e.prototype,"producedAt",void 0),a([u({type:nt,repeated:"sequence"})],_e.prototype,"responses",void 0),a([u({type:Q,repeated:"sequence",context:1,optional:!0})],_e.prototype,"responseExtensions",void 0);class Vt{constructor(e={}){this.tbsResponseData=new _e,this.signatureAlgorithm=new k,this.signature=new ArrayBuffer(0),Object.assign(this,e)}}a([u({type:_e,raw:!0})],Vt.prototype,"tbsResponseData",void 0),a([u({type:k})],Vt.prototype,"signatureAlgorithm",void 0),a([u({type:h.BitString})],Vt.prototype,"signature",void 0),a([u({type:it,repeated:"sequence",optional:!0,context:0})],Vt.prototype,"certs",void 0);class Nr{constructor(e={}){this.signatureAlgorithm=new k,this.signature=new ArrayBuffer(0),Object.assign(this,e)}}a([u({type:k})],Nr.prototype,"signatureAlgorithm",void 0),a([u({type:h.BitString})],Nr.prototype,"signature",void 0),a([u({type:it,repeated:"sequence",optional:!0,context:0})],Nr.prototype,"certs",void 0);class Cr{constructor(e={}){this.reqCert=new Ne,Object.assign(this,e)}}a([u({type:Ne})],Cr.prototype,"reqCert",void 0),a([u({type:Q,repeated:"sequence",optional:!0})],Cr.prototype,"singleRequestExtensions",void 0);class qe{constructor(e={}){this.version=st.v1,this.requestList=[],Object.assign(this,e)}}a([u({type:h.Integer,context:0,defaultValue:st.v1})],qe.prototype,"version",void 0),a([u({type:E,context:1,optional:!0})],qe.prototype,"requestorName",void 0),a([u({type:Cr,repeated:"sequence"})],qe.prototype,"requestList",void 0),a([u({type:Q,context:2,optional:!0,repeated:"sequence"})],qe.prototype,"requestExtensions",void 0);class no{constructor(e={}){this.tbsRequest=new qe,Object.assign(this,e)}}a([u({type:qe,raw:!0})],no.prototype,"tbsRequest",void 0),a([u({type:Nr,optional:!0,context:0})],no.prototype,"optionalSignature",void 0);var Ce;(function(r){r[r.successful=0]="successful",r[r.malformedRequest=1]="malformedRequest",r[r.internalError=2]="internalError",r[r.tryLater=3]="tryLater",r[r.sigRequired=5]="sigRequired",r[r.unauthorized=6]="unauthorized"})(Ce||(Ce={}));class so{constructor(e={}){this.responseType="",this.response=new C,Object.assign(this,e)}}a([u({type:h.ObjectIdentifier})],so.prototype,"responseType",void 0),a([u({type:C})],so.prototype,"response",void 0);class ao{constructor(e={}){this.responseStatus=Ce.successful,Object.assign(this,e)}}a([u({type:h.Enumerated})],ao.prototype,"responseStatus",void 0),a([u({type:so,context:0,optional:!0})],ao.prototype,"responseBytes",void 0);var Er=(r,e,t)=>new Promise((i,o)=>{var n=l=>{try{c(t.next(l))}catch(f){o(f)}},s=l=>{try{c(t.throw(l))}catch(f){o(f)}},c=l=>l.done?i(l.value):Promise.resolve(l.value).then(n,s);c((t=t.apply(r,e)).next())});function co(r){return Er(this,arguments,function*(e,t={}){const{timeout:i=1e4,method:o="GET",body:n,contentType:s,accept:c,proxyUrl:l}=t,f=l?`${l}${encodeURIComponent(e)}`:e,p=new AbortController,d=setTimeout(()=>p.abort(),i);try{const w={};s&&(w["Content-Type"]=s),c&&(w.Accept=c);const y=yield fetch(f,{method:o,headers:w,body:n?new Uint8Array(n):void 0,signal:p.signal});if(clearTimeout(d),!y.ok)return{ok:!1,status:y.status,error:`HTTP ${y.status}: ${y.statusText}`};const g=yield y.arrayBuffer();return{ok:!0,status:y.status,data:g}}catch(w){return clearTimeout(d),w instanceof Error?w.name==="AbortError"?{ok:!1,status:0,error:`Request timeout after ${i}ms`}:{ok:!1,status:0,error:w.message}:{ok:!1,status:0,error:String(w)}}})}function vc(r,e,t=5e3,i){return Er(this,null,function*(){return co(r,{method:"POST",body:e,contentType:"application/ocsp-request",accept:"application/ocsp-response",timeout:t,proxyUrl:i})})}function mc(r,e=1e4,t){return Er(this,null,function*(){return co(r,{method:"GET",accept:"application/pkix-crl",timeout:e,proxyUrl:t})})}function wc(r,e=5e3,t){return Er(this,null,function*(){return co(r,{method:"GET",accept:"application/pkix-cert",timeout:e,proxyUrl:t})})}function Os(r){const e=new Uint8Array(r);if(typeof btoa=="function"){let t="";for(let i=0;i<e.length;i++)t+=String.fromCharCode(e[i]);return btoa(t)}return Buffer.from(e).toString("base64")}function lo(r){if(typeof atob=="function"){const t=atob(r),i=new Uint8Array(t.length);for(let o=0;o<t.length;o++)i[o]=t.charCodeAt(o);return i.buffer}const e=Buffer.from(r,"base64");return e.buffer.slice(e.byteOffset,e.byteOffset+e.byteLength)}function bc(r){return new Uint8Array(lo(r))}function Ir(r){return Array.from(new Uint8Array(r)).map(e=>e.toString(16).padStart(2,"0")).join("")}function Ac(r){const e=new Uint8Array(r.length/2);for(let t=0;t<r.length;t+=2)e[t/2]=parseInt(r.substring(t,t+2),16);return e.buffer}function Ts(r,e="CERTIFICATE"){const t=Os(r).match(/.{1,64}/g)||[];return`-----BEGIN ${e}-----
75
+ `)}`:`${t} :`}}vo=J,b.Constructed=vo,J.NAME="CONSTRUCTED";class mo extends W{fromBER(e,t,i){return t}toBER(e){return se}}mo.override="EndOfContentValueBlock";var wo;class ci extends _{constructor(e={}){super(e,mo),this.idBlock.tagClass=1,this.idBlock.tagNumber=0}}wo=ci,b.EndOfContent=wo,ci.NAME=bt;var bo;class He extends _{constructor(e={}){super(e,W),this.idBlock.tagClass=1,this.idBlock.tagNumber=5}fromBER(e,t,i){return this.lenBlock.length>0&&this.warnings.push("Non-zero length of value block for Null type"),this.idBlock.error.length||(this.blockLength+=this.idBlock.blockLength),this.lenBlock.error.length||(this.blockLength+=this.lenBlock.blockLength),this.blockLength+=i,t+i>e.byteLength?(this.error="End of input reached before message was fully decoded (inconsistent offset and length values)",-1):t+i}toBER(e,t){const i=new ArrayBuffer(2);if(!e){const n=new Uint8Array(i);n[0]=5,n[1]=0}return t&&t.write(i),i}onAsciiEncoding(){return`${this.constructor.NAME}`}}bo=He,b.Null=bo,He.NAME="NULL";class Ao extends ge(W){get value(){for(const e of this.valueHexView)if(e>0)return!0;return!1}set value(e){this.valueHexView[0]=e?255:0}constructor(i={}){var n=i,{value:e}=n,t=D(n,["value"]);super(t),t.valueHex?this.valueHexView=N.toUint8Array(t.valueHex):this.valueHexView=new Uint8Array(1),e&&(this.value=e)}fromBER(e,t,i){const n=N.toUint8Array(e);return Ae(this,n,t,i)?(this.valueHexView=n.subarray(t,t+i),i>1&&this.warnings.push("Boolean value encoded in more then 1 octet"),this.isHexOnly=!0,so.call(this),this.blockLength=i,t+i):-1}toBER(){return this.valueHexView.slice()}toJSON(){return H(T({},super.toJSON()),{value:this.value})}}Ao.NAME="BooleanValueBlock";var So;class Zt extends _{getValue(){return this.valueBlock.value}setValue(e){this.valueBlock.value=e}constructor(e={}){super(e,Ao),this.idBlock.tagClass=1,this.idBlock.tagNumber=1}onAsciiEncoding(){return`${this.constructor.NAME} : ${this.getValue}`}}So=Zt,b.Boolean=So,Zt.NAME="BOOLEAN";class Bo extends ge(Te){constructor(i={}){var n=i,{isConstructed:e=!1}=n,t=D(n,["isConstructed"]);super(t),this.isConstructed=e}fromBER(e,t,i){let n=0;if(this.isConstructed){if(this.isHexOnly=!1,n=Te.prototype.fromBER.call(this,e,t,i),n===-1)return n;for(let o=0;o<this.value.length;o++){const s=this.value[o].constructor.NAME;if(s===bt){if(this.isIndefiniteForm)break;return this.error="EndOfContent is unexpected, OCTET STRING may consists of OCTET STRINGs only",-1}if(s!==lo)return this.error="OCTET STRING may consists of OCTET STRINGs only",-1}}else this.isHexOnly=!0,n=super.fromBER(e,t,i),this.blockLength=i;return n}toBER(e,t){return this.isConstructed?Te.prototype.toBER.call(this,e,t):e?new ArrayBuffer(this.valueHexView.byteLength):this.valueHexView.slice().buffer}toJSON(){return H(T({},super.toJSON()),{isConstructed:this.isConstructed})}}Bo.NAME="OctetStringValueBlock";var li;class $e extends _{constructor(n={}){var o=n,{idBlock:e={},lenBlock:t={}}=o,i=D(o,["idBlock","lenBlock"]);var s,c;(s=i.isConstructed)!==null&&s!==void 0||(i.isConstructed=!!(!((c=i.value)===null||c===void 0)&&c.length)),super(T({idBlock:T({isConstructed:i.isConstructed},e),lenBlock:H(T({},t),{isIndefiniteForm:!!i.isIndefiniteForm})},i),Bo),this.idBlock.tagClass=1,this.idBlock.tagNumber=4}fromBER(e,t,i){if(this.valueBlock.isConstructed=this.idBlock.isConstructed,this.valueBlock.isIndefiniteForm=this.lenBlock.isIndefiniteForm,i===0)return this.idBlock.error.length===0&&(this.blockLength+=this.idBlock.blockLength),this.lenBlock.error.length===0&&(this.blockLength+=this.lenBlock.blockLength),t;if(!this.valueBlock.isConstructed){const o=(e instanceof ArrayBuffer?new Uint8Array(e):e).subarray(t,t+i);try{if(o.byteLength){const s=Qe(o,0,o.byteLength);s.offset!==-1&&s.offset===i&&(this.valueBlock.value=[s.result])}}catch(s){}}return super.fromBER(e,t,i)}onAsciiEncoding(){if(this.valueBlock.isConstructed||this.valueBlock.value&&this.valueBlock.value.length)return J.prototype.onAsciiEncoding.call(this);const e=this.constructor.NAME,t=U.ToHex(this.valueBlock.valueHexView);return`${e} : ${t}`}getValue(){if(!this.idBlock.isConstructed)return this.valueBlock.valueHexView.slice().buffer;const e=[];for(const t of this.valueBlock.value)t instanceof li&&e.push(t.valueBlock.valueHexView);return N.concat(e)}}li=$e,b.OctetString=li,$e.NAME=lo;class ko extends ge(Te){constructor(n={}){var o=n,{unusedBits:e=0,isConstructed:t=!1}=o,i=D(o,["unusedBits","isConstructed"]);super(i),this.unusedBits=e,this.isConstructed=t,this.blockLength=this.valueHexView.byteLength}fromBER(e,t,i){if(!i)return t;let n=-1;if(this.isConstructed){if(n=Te.prototype.fromBER.call(this,e,t,i),n===-1)return n;for(const c of this.value){const l=c.constructor.NAME;if(l===bt){if(this.isIndefiniteForm)break;return this.error="EndOfContent is unexpected, BIT STRING may consists of BIT STRINGs only",-1}if(l!==uo)return this.error="BIT STRING may consists of BIT STRINGs only",-1;const f=c.valueBlock;if(this.unusedBits>0&&f.unusedBits>0)return this.error='Using of "unused bits" inside constructive BIT STRING allowed for least one only',-1;this.unusedBits=f.unusedBits}return n}const o=N.toUint8Array(e);if(!Ae(this,o,t,i))return-1;const s=o.subarray(t,t+i);if(this.unusedBits=s[0],this.unusedBits>7)return this.error="Unused bits for BitString must be in range 0-7",-1;if(!this.unusedBits){const c=s.subarray(1);try{if(c.byteLength){const l=Qe(c,0,c.byteLength);l.offset!==-1&&l.offset===i-1&&(this.value=[l.result])}}catch(l){}}return this.valueHexView=s.subarray(1),this.blockLength=s.length,t+i}toBER(e,t){if(this.isConstructed)return Te.prototype.toBER.call(this,e,t);if(e)return new ArrayBuffer(this.valueHexView.byteLength+1);if(!this.valueHexView.byteLength)return se;const i=new Uint8Array(this.valueHexView.length+1);return i[0]=this.unusedBits,i.set(this.valueHexView,1),i.buffer}toJSON(){return H(T({},super.toJSON()),{unusedBits:this.unusedBits,isConstructed:this.isConstructed})}}ko.NAME="BitStringValueBlock";var xo;class Me extends _{constructor(n={}){var o=n,{idBlock:e={},lenBlock:t={}}=o,i=D(o,["idBlock","lenBlock"]);var s,c;(s=i.isConstructed)!==null&&s!==void 0||(i.isConstructed=!!(!((c=i.value)===null||c===void 0)&&c.length)),super(T({idBlock:T({isConstructed:i.isConstructed},e),lenBlock:H(T({},t),{isIndefiniteForm:!!i.isIndefiniteForm})},i),ko),this.idBlock.tagClass=1,this.idBlock.tagNumber=3}fromBER(e,t,i){return this.valueBlock.isConstructed=this.idBlock.isConstructed,this.valueBlock.isIndefiniteForm=this.lenBlock.isIndefiniteForm,super.fromBER(e,t,i)}onAsciiEncoding(){if(this.valueBlock.isConstructed||this.valueBlock.value&&this.valueBlock.value.length)return J.prototype.onAsciiEncoding.call(this);{const e=[],t=this.valueBlock.valueHexView;for(const s of t)e.push(s.toString(2).padStart(8,"0"));const i=e.join(""),n=this.constructor.NAME,o=i.substring(0,i.length-this.valueBlock.unusedBits);return`${n} : ${o}`}}}xo=Me,b.BitString=xo,Me.NAME=uo;var No;function _a(r,e){const t=new Uint8Array([0]),i=new Uint8Array(r),n=new Uint8Array(e);let o=i.slice(0);const s=o.length-1,c=n.slice(0),l=c.length-1;let f=0;const p=l<s?s:l;let d=0;for(let w=p;w>=0;w--,d++){switch(!0){case d<c.length:f=o[s-d]+c[l-d]+t[0];break;default:f=o[s-d]+t[0]}switch(t[0]=f/10,!0){case d>=o.length:o=ni(new Uint8Array([f%10]),o);break;default:o[s-d]=f%10}}return t[0]>0&&(o=ni(t,o)),o}function Co(r){if(r>=wt.length)for(let e=wt.length;e<=r;e++){const t=new Uint8Array([0]);let i=wt[e-1].slice(0);for(let n=i.length-1;n>=0;n--){const o=new Uint8Array([(i[n]<<1)+t[0]]);t[0]=o[0]/10,i[n]=o[0]%10}t[0]>0&&(i=ni(t,i)),wt.push(i)}return wt[r]}function qa(r,e){let t=0;const i=new Uint8Array(r),n=new Uint8Array(e),o=i.slice(0),s=o.length-1,c=n.slice(0),l=c.length-1;let f,p=0;for(let d=l;d>=0;d--,p++)switch(f=o[s-p]-c[l-p]-t,!0){case f<0:t=1,o[s-p]=f+10;break;default:t=0,o[s-p]=f}if(t>0)for(let d=s-l+1;d>=0;d--,p++)if(f=o[s-p]-t,f<0)t=1,o[s-p]=f+10;else{t=0,o[s-p]=f;break}return o.slice()}class ui extends ge(W){setValueHex(){this.valueHexView.length>=4?(this.warnings.push("Too big Integer for decoding, hex only"),this.isHexOnly=!0,this._valueDec=0):(this.isHexOnly=!1,this.valueHexView.length>0&&(this._valueDec=so.call(this)))}constructor(i={}){var n=i,{value:e}=n,t=D(n,["value"]);super(t),this._valueDec=0,t.valueHex&&this.setValueHex(),e!==void 0&&(this.valueDec=e)}set valueDec(e){this._valueDec=e,this.isHexOnly=!1,this.valueHexView=new Uint8Array(Oa(e))}get valueDec(){return this._valueDec}fromDER(e,t,i,n=0){const o=this.fromBER(e,t,i);if(o===-1)return o;const s=this.valueHexView;return s[0]===0&&(s[1]&128)!==0?this.valueHexView=s.subarray(1):n!==0&&s.length<n&&(n-s.length>1&&(n=s.length+1),this.valueHexView=s.subarray(n-s.length)),o}toDER(e=!1){const t=this.valueHexView;switch(!0){case(t[0]&128)!==0:{const i=new Uint8Array(this.valueHexView.length+1);i[0]=0,i.set(t,1),this.valueHexView=i}break;case(t[0]===0&&(t[1]&128)===0):this.valueHexView=this.valueHexView.subarray(1);break}return this.toBER(e)}fromBER(e,t,i){const n=super.fromBER(e,t,i);return n===-1||this.setValueHex(),n}toBER(e){return e?new ArrayBuffer(this.valueHexView.length):this.valueHexView.slice().buffer}toJSON(){return H(T({},super.toJSON()),{valueDec:this.valueDec})}toString(){const e=this.valueHexView.length*8-1;let t=new Uint8Array(this.valueHexView.length*8/3),i=0,n;const o=this.valueHexView;let s="",c=!1;for(let l=o.byteLength-1;l>=0;l--){n=o[l];for(let f=0;f<8;f++){if((n&1)===1)switch(i){case e:t=qa(Co(i),t),s="-";break;default:t=_a(t,Co(i))}i++,n>>=1}}for(let l=0;l<t.length;l++)t[l]&&(c=!0),c&&(s+=ao.charAt(t[l]));return c===!1&&(s+=ao.charAt(0)),s}}No=ui,ui.NAME="IntegerValueBlock",Object.defineProperty(No.prototype,"valueHex",{set:function(r){this.valueHexView=new Uint8Array(r),this.setValueHex()},get:function(){return this.valueHexView.slice().buffer}});var St;class tt extends _{constructor(e={}){super(e,ui),this.idBlock.tagClass=1,this.idBlock.tagNumber=2}toBigInt(){return Jt(),BigInt(this.valueBlock.toString())}static fromBigInt(e){Jt();const t=BigInt(e),i=new Kt,n=t.toString(16).replace(/^-/,""),o=new Uint8Array(U.FromHex(n));if(t<0){const c=new Uint8Array(o.length+(o[0]&128?1:0));c[0]|=128;const f=BigInt(`0x${U.ToHex(c)}`)+t,p=N.toUint8Array(U.FromHex(f.toString(16)));p[0]|=128,i.write(p)}else o[0]&128&&i.write(new Uint8Array([0])),i.write(o);return new St({valueHex:i.final()})}convertToDER(){const e=new St({valueHex:this.valueBlock.valueHexView});return e.valueBlock.toDER(),e}convertFromDER(){return new St({valueHex:this.valueBlock.valueHexView[0]===0?this.valueBlock.valueHexView.subarray(1):this.valueBlock.valueHexView})}onAsciiEncoding(){return`${this.constructor.NAME} : ${this.valueBlock.toString()}`}}St=tt,b.Integer=St,tt.NAME="INTEGER";var Eo;class Qt extends tt{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=10}}Eo=Qt,b.Enumerated=Eo,Qt.NAME="ENUMERATED";class fi extends ge(W){constructor(n={}){var o=n,{valueDec:e=-1,isFirstSid:t=!1}=o,i=D(o,["valueDec","isFirstSid"]);super(i),this.valueDec=e,this.isFirstSid=t}fromBER(e,t,i){if(!i)return t;const n=N.toUint8Array(e);if(!Ae(this,n,t,i))return-1;const o=n.subarray(t,t+i);this.valueHexView=new Uint8Array(i);for(let c=0;c<i&&(this.valueHexView[c]=o[c]&127,this.blockLength++,(o[c]&128)!==0);c++);const s=new Uint8Array(this.blockLength);for(let c=0;c<this.blockLength;c++)s[c]=this.valueHexView[c];return this.valueHexView=s,(o[this.blockLength-1]&128)!==0?(this.error="End of input reached before message was fully decoded",-1):(this.valueHexView[0]===0&&this.warnings.push("Needlessly long format of SID encoding"),this.blockLength<=8?this.valueDec=Ze(this.valueHexView,7):(this.isHexOnly=!0,this.warnings.push("Too big SID for decoding, hex only")),t+this.blockLength)}set valueBigInt(e){Jt();let t=BigInt(e).toString(2);for(;t.length%7;)t="0"+t;const i=new Uint8Array(t.length/7);for(let n=0;n<i.length;n++)i[n]=parseInt(t.slice(n*7,n*7+7),2)+(n+1<i.length?128:0);this.fromBER(i.buffer,0,i.length)}toBER(e){if(this.isHexOnly){if(e)return new ArrayBuffer(this.valueHexView.byteLength);const n=this.valueHexView,o=new Uint8Array(this.blockLength);for(let s=0;s<this.blockLength-1;s++)o[s]=n[s]|128;return o[this.blockLength-1]=n[this.blockLength-1],o.buffer}const t=Re(this.valueDec,7);if(t.byteLength===0)return this.error="Error during encoding SID value",se;const i=new Uint8Array(t.byteLength);if(!e){const n=new Uint8Array(t),o=t.byteLength-1;for(let s=0;s<o;s++)i[s]=n[s]|128;i[o]=n[o]}return i}toString(){let e="";if(this.isHexOnly)e=U.ToHex(this.valueHexView);else if(this.isFirstSid){let 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}toJSON(){return H(T({},super.toJSON()),{valueDec:this.valueDec,isFirstSid:this.isFirstSid})}}fi.NAME="sidBlock";class Io extends W{constructor(i={}){var n=i,{value:e=Y}=n,t=D(n,["value"]);super(t),this.value=[],e&&this.fromString(e)}fromBER(e,t,i){let n=t;for(;i>0;){const o=new fi;if(n=o.fromBER(e,n,i),n===-1)return this.blockLength=0,this.error=o.error,n;this.value.length===0&&(o.isFirstSid=!0),this.blockLength+=o.blockLength,i-=o.blockLength,this.value.push(o)}return n}toBER(e){const t=[];for(let i=0;i<this.value.length;i++){const n=this.value[i].toBER(e);if(n.byteLength===0)return this.error=this.value[i].error,se;t.push(n)}return oi(t)}fromString(e){this.value=[];let t=0,i=0,n="",o=!1;do if(i=e.indexOf(".",t),i===-1?n=e.substring(t):n=e.substring(t,i),t=i+1,o){const s=this.value[0];let c=0;switch(s.valueDec){case 0:break;case 1:c=40;break;case 2:c=80;break;default:this.value=[];return}const l=parseInt(n,10);if(isNaN(l))return;s.valueDec=l+c,o=!1}else{const s=new fi;if(n>Number.MAX_SAFE_INTEGER){Jt();const c=BigInt(n);s.valueBigInt=c}else if(s.valueDec=parseInt(n,10),isNaN(s.valueDec))return;this.value.length||(s.isFirstSid=!0,o=!0),this.value.push(s)}while(i!==-1)}toString(){let e="",t=!1;for(let i=0;i<this.value.length;i++){t=this.value[i].isHexOnly;let n=this.value[i].toString();i!==0&&(e=`${e}.`),t?(n=`{${n}}`,this.value[i].isFirstSid?e=`2.{${n} - 80}`:e+=n):e+=n}return e}toJSON(){const e=H(T({},super.toJSON()),{value:this.toString(),sidArray:[]});for(let t=0;t<this.value.length;t++)e.sidArray.push(this.value[t].toJSON());return e}}Io.NAME="ObjectIdentifierValueBlock";var Oo;class er extends _{getValue(){return this.valueBlock.toString()}setValue(e){this.valueBlock.fromString(e)}constructor(e={}){super(e,Io),this.idBlock.tagClass=1,this.idBlock.tagNumber=6}onAsciiEncoding(){return`${this.constructor.NAME} : ${this.valueBlock.toString()||"empty"}`}toJSON(){return H(T({},super.toJSON()),{value:this.getValue()})}}Oo=er,b.ObjectIdentifier=Oo,er.NAME="OBJECT IDENTIFIER";class hi extends ge(Le){constructor(i={}){var n=i,{valueDec:e=0}=n,t=D(n,["valueDec"]);super(t),this.valueDec=e}fromBER(e,t,i){if(i===0)return t;const n=N.toUint8Array(e);if(!Ae(this,n,t,i))return-1;const o=n.subarray(t,t+i);this.valueHexView=new Uint8Array(i);for(let c=0;c<i&&(this.valueHexView[c]=o[c]&127,this.blockLength++,(o[c]&128)!==0);c++);const s=new Uint8Array(this.blockLength);for(let c=0;c<this.blockLength;c++)s[c]=this.valueHexView[c];return this.valueHexView=s,(o[this.blockLength-1]&128)!==0?(this.error="End of input reached before message was fully decoded",-1):(this.valueHexView[0]===0&&this.warnings.push("Needlessly long format of SID encoding"),this.blockLength<=8?this.valueDec=Ze(this.valueHexView,7):(this.isHexOnly=!0,this.warnings.push("Too big SID for decoding, hex only")),t+this.blockLength)}toBER(e){if(this.isHexOnly){if(e)return new ArrayBuffer(this.valueHexView.byteLength);const n=this.valueHexView,o=new Uint8Array(this.blockLength);for(let s=0;s<this.blockLength-1;s++)o[s]=n[s]|128;return o[this.blockLength-1]=n[this.blockLength-1],o.buffer}const t=Re(this.valueDec,7);if(t.byteLength===0)return this.error="Error during encoding SID value",se;const i=new Uint8Array(t.byteLength);if(!e){const n=new Uint8Array(t),o=t.byteLength-1;for(let s=0;s<o;s++)i[s]=n[s]|128;i[o]=n[o]}return i.buffer}toString(){let e="";return this.isHexOnly?e=U.ToHex(this.valueHexView):e=this.valueDec.toString(),e}toJSON(){return H(T({},super.toJSON()),{valueDec:this.valueDec})}}hi.NAME="relativeSidBlock";class To extends W{constructor(i={}){var n=i,{value:e=Y}=n,t=D(n,["value"]);super(t),this.value=[],e&&this.fromString(e)}fromBER(e,t,i){let n=t;for(;i>0;){const o=new hi;if(n=o.fromBER(e,n,i),n===-1)return this.blockLength=0,this.error=o.error,n;this.blockLength+=o.blockLength,i-=o.blockLength,this.value.push(o)}return n}toBER(e,t){const i=[];for(let n=0;n<this.value.length;n++){const o=this.value[n].toBER(e);if(o.byteLength===0)return this.error=this.value[n].error,se;i.push(o)}return oi(i)}fromString(e){this.value=[];let t=0,i=0,n="";do{i=e.indexOf(".",t),i===-1?n=e.substring(t):n=e.substring(t,i),t=i+1;const o=new hi;if(o.valueDec=parseInt(n,10),isNaN(o.valueDec))return!0;this.value.push(o)}while(i!==-1);return!0}toString(){let e="",t=!1;for(let i=0;i<this.value.length;i++){t=this.value[i].isHexOnly;let n=this.value[i].toString();i!==0&&(e=`${e}.`),t&&(n=`{${n}}`),e+=n}return e}toJSON(){const e=H(T({},super.toJSON()),{value:this.toString(),sidArray:[]});for(let t=0;t<this.value.length;t++)e.sidArray.push(this.value[t].toJSON());return e}}To.NAME="RelativeObjectIdentifierValueBlock";var Vo;class pi extends _{getValue(){return this.valueBlock.toString()}setValue(e){this.valueBlock.fromString(e)}constructor(e={}){super(e,To),this.idBlock.tagClass=1,this.idBlock.tagNumber=13}onAsciiEncoding(){return`${this.constructor.NAME} : ${this.valueBlock.toString()||"empty"}`}toJSON(){return H(T({},super.toJSON()),{value:this.getValue()})}}Vo=pi,b.RelativeObjectIdentifier=Vo,pi.NAME="RelativeObjectIdentifier";var jo;class ae extends J{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=16}}jo=ae,b.Sequence=jo,ae.NAME="SEQUENCE";var Uo;class ve extends J{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=17}}Uo=ve,b.Set=Uo,ve.NAME="SET";class Do extends ge(W){constructor(t={}){var e=D(t,[]);super(e),this.isHexOnly=!0,this.value=Y}toJSON(){return H(T({},super.toJSON()),{value:this.value})}}Do.NAME="StringValueBlock";class Ro extends Do{}Ro.NAME="SimpleStringValueBlock";class te extends ai{constructor(t={}){var e=D(t,[]);super(e,Ro)}fromBuffer(e){this.valueBlock.value=String.fromCharCode.apply(null,N.toUint8Array(e))}fromString(e){const t=e.length,i=this.valueBlock.valueHexView=new Uint8Array(t);for(let n=0;n<t;n++)i[n]=e.charCodeAt(n);this.valueBlock.value=e}}te.NAME="SIMPLE STRING";class Lo extends te{fromBuffer(e){this.valueBlock.valueHexView=N.toUint8Array(e);try{this.valueBlock.value=U.ToUtf8String(e)}catch(t){this.warnings.push(`Error during "decodeURIComponent": ${t}, using raw string`),this.valueBlock.value=U.ToBinary(e)}}fromString(e){this.valueBlock.valueHexView=new Uint8Array(U.FromUtf8String(e)),this.valueBlock.value=e}}Lo.NAME="Utf8StringValueBlock";var Ho;class Se extends Lo{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=12}}Ho=Se,b.Utf8String=Ho,Se.NAME="UTF8String";class $o extends te{fromBuffer(e){this.valueBlock.value=U.ToUtf16String(e),this.valueBlock.valueHexView=N.toUint8Array(e)}fromString(e){this.valueBlock.value=e,this.valueBlock.valueHexView=new Uint8Array(U.FromUtf16String(e))}}$o.NAME="BmpStringValueBlock";var Mo;class tr extends $o{constructor(t={}){var e=D(t,[]);super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=30}}Mo=tr,b.BmpString=Mo,tr.NAME="BMPString";class Po extends te{fromBuffer(e){const t=ArrayBuffer.isView(e)?e.slice().buffer:e.slice(0),i=new Uint8Array(t);for(let n=0;n<i.length;n+=4)i[n]=i[n+3],i[n+1]=i[n+2],i[n+2]=0,i[n+3]=0;this.valueBlock.value=String.fromCharCode.apply(null,new Uint32Array(t))}fromString(e){const t=e.length,i=this.valueBlock.valueHexView=new Uint8Array(t*4);for(let n=0;n<t;n++){const o=Re(e.charCodeAt(n),8),s=new Uint8Array(o);if(s.length>4)continue;const c=4-s.length;for(let l=s.length-1;l>=0;l--)i[n*4+l+c]=s[l]}this.valueBlock.value=e}}Po.NAME="UniversalStringValueBlock";var _o;class rr extends Po{constructor(t={}){var e=D(t,[]);super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=28}}_o=rr,b.UniversalString=_o,rr.NAME="UniversalString";var qo;class ir extends te{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=18}}qo=ir,b.NumericString=qo,ir.NAME="NumericString";var Fo;class nr extends te{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=19}}Fo=nr,b.PrintableString=Fo,nr.NAME="PrintableString";var Go;class or extends te{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=20}}Go=or,b.TeletexString=Go,or.NAME="TeletexString";var zo;class sr extends te{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=21}}zo=sr,b.VideotexString=zo,sr.NAME="VideotexString";var Xo;class ar extends te{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=22}}Xo=ar,b.IA5String=Xo,ar.NAME="IA5String";var Wo;class cr extends te{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=25}}Wo=cr,b.GraphicString=Wo,cr.NAME="GraphicString";var Jo;class Bt extends te{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=26}}Jo=Bt,b.VisibleString=Jo,Bt.NAME="VisibleString";var Ko;class lr extends te{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=27}}Ko=lr,b.GeneralString=Ko,lr.NAME="GeneralString";var Yo;class ur extends te{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=29}}Yo=ur,b.CharacterString=Yo,ur.NAME="CharacterString";var Zo;class kt extends Bt{constructor(n={}){var o=n,{value:e,valueDate:t}=o,i=D(o,["value","valueDate"]);if(super(i),this.year=0,this.month=0,this.day=0,this.hour=0,this.minute=0,this.second=0,e){this.fromString(e),this.valueBlock.valueHexView=new Uint8Array(e.length);for(let s=0;s<e.length;s++)this.valueBlock.valueHexView[s]=e.charCodeAt(s)}t&&(this.fromDate(t),this.valueBlock.valueHexView=new Uint8Array(this.toBuffer())),this.idBlock.tagClass=1,this.idBlock.tagNumber=23}fromBuffer(e){this.fromString(String.fromCharCode.apply(null,N.toUint8Array(e)))}toBuffer(){const e=this.toString(),t=new ArrayBuffer(e.length),i=new Uint8Array(t);for(let n=0;n<e.length;n++)i[n]=e.charCodeAt(n);return t}fromDate(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()}toDate(){return new Date(Date.UTC(this.year,this.month-1,this.day,this.hour,this.minute,this.second))}fromString(e){const i=/(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})Z/ig.exec(e);if(i===null){this.error="Wrong input string for conversion";return}const n=parseInt(i[1],10);n>=50?this.year=1900+n:this.year=2e3+n,this.month=parseInt(i[2],10),this.day=parseInt(i[3],10),this.hour=parseInt(i[4],10),this.minute=parseInt(i[5],10),this.second=parseInt(i[6],10)}toString(e="iso"){if(e==="iso"){const t=new Array(7);return t[0]=ee(this.year<2e3?this.year-1900:this.year-2e3,2),t[1]=ee(this.month,2),t[2]=ee(this.day,2),t[3]=ee(this.hour,2),t[4]=ee(this.minute,2),t[5]=ee(this.second,2),t[6]="Z",t.join("")}return super.toString(e)}onAsciiEncoding(){return`${this.constructor.NAME} : ${this.toDate().toISOString()}`}toJSON(){return H(T({},super.toJSON()),{year:this.year,month:this.month,day:this.day,hour:this.hour,minute:this.minute,second:this.second})}}Zo=kt,b.UTCTime=Zo,kt.NAME="UTCTime";var Qo;class fr extends kt{constructor(e={}){var t;super(e),(t=this.millisecond)!==null&&t!==void 0||(this.millisecond=0),this.idBlock.tagClass=1,this.idBlock.tagNumber=24}fromDate(e){super.fromDate(e),this.millisecond=e.getUTCMilliseconds()}toDate(){const e=Date.UTC(this.year,this.month-1,this.day,this.hour,this.minute,this.second,this.millisecond);return new Date(e)}fromString(e){let t=!1,i="",n="",o=0,s,c=0,l=0;if(e[e.length-1]==="Z")i=e.substring(0,e.length-1),t=!0;else{const d=new Number(e[e.length-1]);if(isNaN(d.valueOf()))throw new Error("Wrong input string for conversion");i=e}if(t){if(i.indexOf("+")!==-1)throw new Error("Wrong input string for conversion");if(i.indexOf("-")!==-1)throw new Error("Wrong input string for conversion")}else{let d=1,w=i.indexOf("+"),y="";if(w===-1&&(w=i.indexOf("-"),d=-1),w!==-1){if(y=i.substring(w+1),i=i.substring(0,w),y.length!==2&&y.length!==4)throw new Error("Wrong input string for conversion");let g=parseInt(y.substring(0,2),10);if(isNaN(g.valueOf()))throw new Error("Wrong input string for conversion");if(c=d*g,y.length===4){if(g=parseInt(y.substring(2,4),10),isNaN(g.valueOf()))throw new Error("Wrong input string for conversion");l=d*g}}}let f=i.indexOf(".");if(f===-1&&(f=i.indexOf(",")),f!==-1){const d=new Number(`0${i.substring(f)}`);if(isNaN(d.valueOf()))throw new Error("Wrong input string for conversion");o=d.valueOf(),n=i.substring(0,f)}else n=i;switch(!0){case n.length===8:if(s=/(\d{4})(\d{2})(\d{2})/ig,f!==-1)throw new Error("Wrong input string for conversion");break;case n.length===10:if(s=/(\d{4})(\d{2})(\d{2})(\d{2})/ig,f!==-1){let d=60*o;this.minute=Math.floor(d),d=60*(d-this.minute),this.second=Math.floor(d),d=1e3*(d-this.second),this.millisecond=Math.floor(d)}break;case n.length===12:if(s=/(\d{4})(\d{2})(\d{2})(\d{2})(\d{2})/ig,f!==-1){let d=60*o;this.second=Math.floor(d),d=1e3*(d-this.second),this.millisecond=Math.floor(d)}break;case n.length===14:if(s=/(\d{4})(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})/ig,f!==-1){const d=1e3*o;this.millisecond=Math.floor(d)}break;default:throw new Error("Wrong input string for conversion")}const p=s.exec(n);if(p===null)throw new Error("Wrong input string for conversion");for(let d=1;d<p.length;d++)switch(d){case 1:this.year=parseInt(p[d],10);break;case 2:this.month=parseInt(p[d],10);break;case 3:this.day=parseInt(p[d],10);break;case 4:this.hour=parseInt(p[d],10)+c;break;case 5:this.minute=parseInt(p[d],10)+l;break;case 6:this.second=parseInt(p[d],10);break;default:throw new Error("Wrong input string for conversion")}if(t===!1){const d=new Date(this.year,this.month,this.day,this.hour,this.minute,this.second,this.millisecond);this.year=d.getUTCFullYear(),this.month=d.getUTCMonth(),this.day=d.getUTCDay(),this.hour=d.getUTCHours(),this.minute=d.getUTCMinutes(),this.second=d.getUTCSeconds(),this.millisecond=d.getUTCMilliseconds()}}toString(e="iso"){if(e==="iso"){const t=[];return t.push(ee(this.year,4)),t.push(ee(this.month,2)),t.push(ee(this.day,2)),t.push(ee(this.hour,2)),t.push(ee(this.minute,2)),t.push(ee(this.second,2)),this.millisecond!==0&&(t.push("."),t.push(ee(this.millisecond,3))),t.push("Z"),t.join("")}return super.toString(e)}toJSON(){return H(T({},super.toJSON()),{millisecond:this.millisecond})}}Qo=fr,b.GeneralizedTime=Qo,fr.NAME="GeneralizedTime";var es;class di extends Se{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=31}}es=di,b.DATE=es,di.NAME="DATE";var ts;class yi extends Se{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=32}}ts=yi,b.TimeOfDay=ts,yi.NAME="TimeOfDay";var rs;class gi extends Se{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=33}}rs=gi,b.DateTime=rs,gi.NAME="DateTime";var is;class vi extends Se{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=34}}is=vi,b.Duration=is,vi.NAME="Duration";var ns;class mi extends Se{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=14}}ns=mi,b.TIME=ns,mi.NAME="TIME";class Pe{constructor({name:e=Y,optional:t=!1}={}){this.name=e,this.optional=t}}class wi extends Pe{constructor(i={}){var n=i,{value:e=[]}=n,t=D(n,["value"]);super(t),this.value=e}}class hr extends Pe{constructor(n={}){var o=n,{value:e=new Pe,local:t=!1}=o,i=D(o,["value","local"]);super(i),this.value=e,this.local=t}}class Fa{get data(){return this.dataView.slice().buffer}set data(e){this.dataView=N.toUint8Array(e)}constructor({data:e=Yt}={}){this.dataView=N.toUint8Array(e)}fromBER(e,t,i){const n=t+i;return this.dataView=N.toUint8Array(e).subarray(t,n),n}toBER(e){return this.dataView.slice().buffer}}function Ve(r,e,t){if(t instanceof wi){for(const o of t.value)if(Ve(r,e,o).verified)return{verified:!0,result:r};{const o={verified:!1,result:{error:"Wrong values for Choice type"}};return t.hasOwnProperty(si)&&(o.name=t.name),o}}if(t instanceof Pe)return t.hasOwnProperty(si)&&(r[t.name]=e),{verified:!0,result:r};if(!(r instanceof Object))return{verified:!1,result:{error:"Wrong root object"}};if(!(e instanceof Object))return{verified:!1,result:{error:"Wrong ASN.1 data"}};if(!(t instanceof Object))return{verified:!1,result:{error:"Wrong ASN.1 schema"}};if(!(ja in t))return{verified:!1,result:{error:"Wrong ASN.1 schema"}};if(!(La in t.idBlock))return{verified:!1,result:{error:"Wrong ASN.1 schema"}};if(!(Ha in t.idBlock))return{verified:!1,result:{error:"Wrong ASN.1 schema"}};const i=t.idBlock.toBER(!1);if(i.byteLength===0)return{verified:!1,result:{error:"Error encoding idBlock for ASN.1 schema"}};if(t.idBlock.fromBER(i,0,i.byteLength)===-1)return{verified:!1,result:{error:"Error decoding idBlock for ASN.1 schema"}};if(t.idBlock.hasOwnProperty(Ua)===!1)return{verified:!1,result:{error:"Wrong ASN.1 schema"}};if(t.idBlock.tagClass!==e.idBlock.tagClass)return{verified:!1,result:r};if(t.idBlock.hasOwnProperty(Da)===!1)return{verified:!1,result:{error:"Wrong ASN.1 schema"}};if(t.idBlock.tagNumber!==e.idBlock.tagNumber)return{verified:!1,result:r};if(t.idBlock.hasOwnProperty(Ra)===!1)return{verified:!1,result:{error:"Wrong ASN.1 schema"}};if(t.idBlock.isConstructed!==e.idBlock.isConstructed)return{verified:!1,result:r};if(!(Va in t.idBlock))return{verified:!1,result:{error:"Wrong ASN.1 schema"}};if(t.idBlock.isHexOnly!==e.idBlock.isHexOnly)return{verified:!1,result:r};if(t.idBlock.isHexOnly){if(!(co in t.idBlock))return{verified:!1,result:{error:"Wrong ASN.1 schema"}};const o=t.idBlock.valueHexView,s=e.idBlock.valueHexView;if(o.length!==s.length)return{verified:!1,result:r};for(let c=0;c<o.length;c++)if(o[c]!==s[1])return{verified:!1,result:r}}if(t.name&&(t.name=t.name.replace(/^\s+|\s+$/g,Y),t.name&&(r[t.name]=e)),t instanceof b.Constructed){let o=0,s={verified:!1,result:{error:"Unknown error"}},c=t.valueBlock.value.length;if(c>0&&t.valueBlock.value[0]instanceof hr&&(c=e.valueBlock.value.length),c===0)return{verified:!0,result:r};if(e.valueBlock.value.length===0&&t.valueBlock.value.length!==0){let l=!0;for(let f=0;f<t.valueBlock.value.length;f++)l=l&&(t.valueBlock.value[f].optional||!1);return l?{verified:!0,result:r}:(t.name&&(t.name=t.name.replace(/^\s+|\s+$/g,Y),t.name&&delete r[t.name]),r.error="Inconsistent object length",{verified:!1,result:r})}for(let l=0;l<c;l++)if(l-o>=e.valueBlock.value.length){if(t.valueBlock.value[l].optional===!1){const f={verified:!1,result:r};return r.error="Inconsistent length between ASN.1 data and schema",t.name&&(t.name=t.name.replace(/^\s+|\s+$/g,Y),t.name&&(delete r[t.name],f.name=t.name)),f}}else if(t.valueBlock.value[0]instanceof hr){if(s=Ve(r,e.valueBlock.value[l],t.valueBlock.value[0].value),s.verified===!1)if(t.valueBlock.value[0].optional)o++;else return t.name&&(t.name=t.name.replace(/^\s+|\s+$/g,Y),t.name&&delete r[t.name]),s;if(si in t.valueBlock.value[0]&&t.valueBlock.value[0].name.length>0){let f={};$a in t.valueBlock.value[0]&&t.valueBlock.value[0].local?f=e:f=r,typeof f[t.valueBlock.value[0].name]=="undefined"&&(f[t.valueBlock.value[0].name]=[]),f[t.valueBlock.value[0].name].push(e.valueBlock.value[l])}}else if(s=Ve(r,e.valueBlock.value[l-o],t.valueBlock.value[l]),s.verified===!1)if(t.valueBlock.value[l].optional)o++;else return t.name&&(t.name=t.name.replace(/^\s+|\s+$/g,Y),t.name&&delete r[t.name]),s;if(s.verified===!1){const l={verified:!1,result:r};return t.name&&(t.name=t.name.replace(/^\s+|\s+$/g,Y),t.name&&(delete r[t.name],l.name=t.name)),l}return{verified:!0,result:r}}if(t.primitiveSchema&&co in e.valueBlock){const o=Qe(e.valueBlock.valueHexView);if(o.offset===-1){const s={verified:!1,result:o.result};return t.name&&(t.name=t.name.replace(/^\s+|\s+$/g,Y),t.name&&(delete r[t.name],s.name=t.name)),s}return Ve(r,o.result,t.primitiveSchema)}return{verified:!0,result:r}}function Ga(r,e){if(!(e instanceof Object))return{verified:!1,result:{error:"Wrong ASN.1 schema type"}};const t=Qe(N.toUint8Array(r));return t.offset===-1?{verified:!1,result:t.result}:Ve(t.result,t.result,e)}var os=Object.freeze({__proto__:null,Any:Pe,BaseBlock:_,BaseStringBlock:ai,BitString:Me,BmpString:tr,Boolean:Zt,CharacterString:ur,Choice:wi,Constructed:J,DATE:di,DateTime:gi,Duration:vi,EndOfContent:ci,Enumerated:Qt,GeneralString:lr,GeneralizedTime:fr,GraphicString:cr,HexBlock:ge,IA5String:ar,Integer:tt,Null:He,NumericString:ir,ObjectIdentifier:er,OctetString:$e,Primitive:At,PrintableString:nr,RawData:Fa,RelativeObjectIdentifier:pi,Repeated:hr,Sequence:ae,Set:ve,TIME:mi,TeletexString:or,TimeOfDay:yi,UTCTime:kt,UniversalString:rr,Utf8String:Se,ValueBlock:W,VideotexString:sr,ViewWriter:Kt,VisibleString:Bt,compareSchema:Ve,fromBER:et,verifySchema:Ga}),v;(function(r){r[r.Sequence=0]="Sequence",r[r.Set=1]="Set",r[r.Choice=2]="Choice"})(v||(v={}));var h;(function(r){r[r.Any=1]="Any",r[r.Boolean=2]="Boolean",r[r.OctetString=3]="OctetString",r[r.BitString=4]="BitString",r[r.Integer=5]="Integer",r[r.Enumerated=6]="Enumerated",r[r.ObjectIdentifier=7]="ObjectIdentifier",r[r.Utf8String=8]="Utf8String",r[r.BmpString=9]="BmpString",r[r.UniversalString=10]="UniversalString",r[r.NumericString=11]="NumericString",r[r.PrintableString=12]="PrintableString",r[r.TeletexString=13]="TeletexString",r[r.VideotexString=14]="VideotexString",r[r.IA5String=15]="IA5String",r[r.GraphicString=16]="GraphicString",r[r.VisibleString=17]="VisibleString",r[r.GeneralString=18]="GeneralString",r[r.CharacterString=19]="CharacterString",r[r.UTCTime=20]="UTCTime",r[r.GeneralizedTime=21]="GeneralizedTime",r[r.DATE=22]="DATE",r[r.TimeOfDay=23]="TimeOfDay",r[r.DateTime=24]="DateTime",r[r.Duration=25]="Duration",r[r.TIME=26]="TIME",r[r.Null=27]="Null"})(h||(h={}));class pr{constructor(e,t=0){if(this.unusedBits=0,this.value=new ArrayBuffer(0),e)if(typeof e=="number")this.fromNumber(e);else if(N.isBufferSource(e))this.unusedBits=t,this.value=N.toArrayBuffer(e);else throw TypeError("Unsupported type of 'params' argument for BitString")}fromASN(e){if(!(e instanceof Me))throw new TypeError("Argument 'asn' is not instance of ASN.1 BitString");return this.unusedBits=e.valueBlock.unusedBits,this.value=e.valueBlock.valueHex,this}toASN(){return new Me({unusedBits:this.unusedBits,valueHex:this.value})}toSchema(e){return new Me({name:e})}toNumber(){let e="";const t=new Uint8Array(this.value);for(const i of t)e+=i.toString(2).padStart(8,"0");return e=e.split("").reverse().join(""),this.unusedBits&&(e=e.slice(this.unusedBits).padStart(this.unusedBits,"0")),parseInt(e,2)}fromNumber(e){let t=e.toString(2);const i=t.length+7>>3;this.unusedBits=(i<<3)-t.length;const n=new Uint8Array(i);t=t.padStart(i<<3,"0").split("").reverse().join("");let o=0;for(;o<i;)n[o]=parseInt(t.slice(o<<3,(o<<3)+8),2),o++;this.value=n.buffer}}class C{get byteLength(){return this.buffer.byteLength}get byteOffset(){return 0}constructor(e){typeof e=="number"?this.buffer=new ArrayBuffer(e):N.isBufferSource(e)?this.buffer=N.toArrayBuffer(e):Array.isArray(e)?this.buffer=new Uint8Array(e):this.buffer=new ArrayBuffer(0)}fromASN(e){if(!(e instanceof $e))throw new TypeError("Argument 'asn' is not instance of ASN.1 OctetString");return this.buffer=e.valueBlock.valueHex,this}toASN(){return new $e({valueHex:this.buffer})}toSchema(e){return new $e({name:e})}}const za={fromASN:r=>r instanceof He?null:r.valueBeforeDecodeView,toASN:r=>{if(r===null)return new He;const e=et(r);if(e.result.error)throw new Error(e.result.error);return e.result}},Xa={fromASN:r=>r.valueBlock.valueHexView.byteLength>=4?r.valueBlock.toString():r.valueBlock.valueDec,toASN:r=>new tt({value:+r})},Wa={fromASN:r=>r.valueBlock.valueDec,toASN:r=>new Qt({value:r})},re={fromASN:r=>r.valueBlock.valueHexView,toASN:r=>new tt({valueHex:r})},Ja={fromASN:r=>r.valueBlock.valueHexView,toASN:r=>new Me({valueHex:r})},Ka={fromASN:r=>r.valueBlock.toString(),toASN:r=>new er({value:r})},Ya={fromASN:r=>r.valueBlock.value,toASN:r=>new Zt({value:r})},bi={fromASN:r=>r.valueBlock.valueHexView,toASN:r=>new $e({valueHex:r})},Za={fromASN:r=>new C(r.getValue()),toASN:r=>r.toASN()};function ne(r){return{fromASN:e=>e.valueBlock.value,toASN:e=>new r({value:e})}}const Qa=ne(Se),ec=ne(tr),tc=ne(rr),rc=ne(ir),ic=ne(nr),nc=ne(or),oc=ne(sr),sc=ne(ar),ac=ne(cr),cc=ne(Bt),lc=ne(lr),uc=ne(ur),fc={fromASN:r=>r.toDate(),toASN:r=>new kt({valueDate:r})},hc={fromASN:r=>r.toDate(),toASN:r=>new fr({valueDate:r})},pc={fromASN:()=>null,toASN:()=>new He};function xt(r){switch(r){case h.Any:return za;case h.BitString:return Ja;case h.BmpString:return ec;case h.Boolean:return Ya;case h.CharacterString:return uc;case h.Enumerated:return Wa;case h.GeneralString:return lc;case h.GeneralizedTime:return hc;case h.GraphicString:return ac;case h.IA5String:return sc;case h.Integer:return Xa;case h.Null:return pc;case h.NumericString:return rc;case h.ObjectIdentifier:return Ka;case h.OctetString:return bi;case h.PrintableString:return ic;case h.TeletexString:return nc;case h.UTCTime:return fc;case h.UniversalString:return tc;case h.Utf8String:return Qa;case h.VideotexString:return oc;case h.VisibleString:return cc;default:return null}}function Be(r){return typeof r=="function"&&r.prototype?r.prototype.toASN&&r.prototype.fromASN?!0:Be(r.prototype):!!(r&&typeof r=="object"&&"toASN"in r&&"fromASN"in r)}function ss(r){var e;if(r){const t=Object.getPrototypeOf(r);return((e=t==null?void 0:t.prototype)===null||e===void 0?void 0:e.constructor)===Array?!0:ss(t)}return!1}function dc(r,e){if(!(r&&e)||r.byteLength!==e.byteLength)return!1;const t=new Uint8Array(r),i=new Uint8Array(e);for(let n=0;n<r.byteLength;n++)if(t[n]!==i[n])return!1;return!0}class yc{constructor(){this.items=new WeakMap}has(e){return this.items.has(e)}get(e,t=!1){const i=this.items.get(e);if(!i)throw new Error(`Cannot get schema for '${e.prototype.constructor.name}' target`);if(t&&!i.schema)throw new Error(`Schema '${e.prototype.constructor.name}' doesn't contain ASN.1 schema. Call 'AsnSchemaStorage.cache'.`);return i}cache(e){const t=this.get(e);t.schema||(t.schema=this.create(e,!0))}createDefault(e){const t={type:v.Sequence,items:{}},i=this.findParentSchema(e);return i&&(Object.assign(t,i),t.items=Object.assign({},t.items,i.items)),t}create(e,t){const i=this.items.get(e)||this.createDefault(e),n=[];for(const o in i.items){const s=i.items[o],c=t?o:"";let l;if(typeof s.type=="number"){const p=h[s.type],d=os[p];if(!d)throw new Error(`Cannot get ASN1 class by name '${p}'`);l=new d({name:c})}else Be(s.type)?l=new s.type().toSchema(c):s.optional?this.get(s.type).type===v.Choice?l=new Pe({name:c}):(l=this.create(s.type,!1),l.name=c):l=new Pe({name:c});const f=!!s.optional||s.defaultValue!==void 0;if(s.repeated){l.name="";const p=s.repeated==="set"?ve:ae;l=new p({name:"",value:[new hr({name:c,value:l})]})}if(s.context!==null&&s.context!==void 0)if(s.implicit)if(typeof s.type=="number"||Be(s.type)){const p=s.repeated?J:At;n.push(new p({name:c,optional:f,idBlock:{tagClass:3,tagNumber:s.context}}))}else{this.cache(s.type);const p=!!s.repeated;let d=p?l:this.get(s.type,!0).schema;d="valueBlock"in d?d.valueBlock.value:d.value,n.push(new J({name:p?"":c,optional:f,idBlock:{tagClass:3,tagNumber:s.context},value:d}))}else n.push(new J({optional:f,idBlock:{tagClass:3,tagNumber:s.context},value:[l]}));else l.optional=f,n.push(l)}switch(i.type){case v.Sequence:return new ae({value:n,name:""});case v.Set:return new ve({value:n,name:""});case v.Choice:return new wi({value:n,name:""});default:throw new Error("Unsupported ASN1 type in use")}}set(e,t){return this.items.set(e,t),this}findParentSchema(e){const t=Object.getPrototypeOf(e);return t?this.items.get(t)||this.findParentSchema(t):null}}const q=new yc,A=r=>e=>{let t;q.has(e)?t=q.get(e):(t=q.createDefault(e),q.set(e,t)),Object.assign(t,r)},u=r=>(e,t)=>{let i;q.has(e.constructor)?i=q.get(e.constructor):(i=q.createDefault(e.constructor),q.set(e.constructor,i));const n=Object.assign({},r);if(typeof n.type=="number"&&!n.converter){const o=xt(r.type);if(!o)throw new Error(`Cannot get default converter for property '${t}' of ${e.constructor.name}`);n.converter=o}n.raw=r.raw,i.items[t]=n};class Nt extends Error{constructor(){super(...arguments),this.schemas=[]}}class as{static parse(e,t){const i=et(e);if(i.result.error)throw new Error(i.result.error);return this.fromASN(i.result,t)}static fromASN(e,t){try{if(Be(t))return new t().fromASN(e);const i=q.get(t);q.cache(t);let n=i.schema;const o=this.handleChoiceTypes(e,i,t,n);if(o!=null&&o.result)return o.result;o!=null&&o.targetSchema&&(n=o.targetSchema);const s=this.handleSequenceTypes(e,i,t,n),c=new t;return ss(t)?this.handleArrayTypes(e,i,t):(this.processSchemaItems(i,s,c),c)}catch(i){throw i instanceof Nt&&i.schemas.push(t.name),i}}static handleChoiceTypes(e,t,i,n){if(e.constructor===J&&t.type===v.Choice&&e.idBlock.tagClass===3)for(const o in t.items){const s=t.items[o];if(s.context===e.idBlock.tagNumber&&s.implicit&&typeof s.type=="function"&&q.has(s.type)){const c=q.get(s.type);if(c&&c.type===v.Sequence){const l=new ae;if("value"in e.valueBlock&&Array.isArray(e.valueBlock.value)&&"value"in l.valueBlock){l.valueBlock.value=e.valueBlock.value;const f=this.fromASN(l,s.type),p=new i;return p[o]=f,{result:p}}}}}else if(e.constructor===J&&t.type!==v.Choice){const o=new J({idBlock:{tagClass:3,tagNumber:e.idBlock.tagNumber},value:t.schema.valueBlock.value});for(const s in t.items)delete e[s];return{targetSchema:o}}return null}static handleSequenceTypes(e,t,i,n){if(t.type===v.Sequence){const o=Ve({},e,n);if(!o.verified)throw new Nt(`Data does not match to ${i.name} ASN1 schema.${o.result.error?` ${o.result.error}`:""}`);return o}else{const o=Ve({},e,n);if(!o.verified)throw new Nt(`Data does not match to ${i.name} ASN1 schema.${o.result.error?` ${o.result.error}`:""}`);return o}}static processRepeatedField(e,t,i){let n=e.slice(t);if(n.length===1&&n[0].constructor.name==="Sequence"){const o=n[0];o.valueBlock&&o.valueBlock.value&&Array.isArray(o.valueBlock.value)&&(n=o.valueBlock.value)}if(typeof i.type=="number"){const o=xt(i.type);if(!o)throw new Error(`No converter for ASN.1 type ${i.type}`);return n.filter(s=>s&&s.valueBlock).map(s=>{try{return o.fromASN(s)}catch(c){return}}).filter(s=>s!==void 0)}else return n.filter(o=>o&&o.valueBlock).map(o=>{try{return this.fromASN(o,i.type)}catch(s){return}}).filter(o=>o!==void 0)}static processPrimitiveField(e,t){const i=xt(t.type);if(!i)throw new Error(`No converter for ASN.1 type ${t.type}`);return i.fromASN(e)}static isOptionalChoiceField(e){return e.optional&&typeof e.type=="function"&&q.has(e.type)&&q.get(e.type).type===v.Choice}static processOptionalChoiceField(e,t){try{return{processed:!0,value:this.fromASN(e,t.type)}}catch(i){if(i instanceof Nt&&/Wrong values for Choice type/.test(i.message))return{processed:!1};throw i}}static handleArrayTypes(e,t,i){if(!("value"in e.valueBlock&&Array.isArray(e.valueBlock.value)))throw new Error("Cannot get items from the ASN.1 parsed value. ASN.1 object is not constructed.");const n=t.itemType;if(typeof n=="number"){const o=xt(n);if(!o)throw new Error(`Cannot get default converter for array item of ${i.name} ASN1 schema`);return i.from(e.valueBlock.value,s=>o.fromASN(s))}else return i.from(e.valueBlock.value,o=>this.fromASN(o,n))}static processSchemaItems(e,t,i){for(const n in e.items){const o=t.result[n];if(!o)continue;const s=e.items[n],c=s.type;let l;typeof c=="number"||Be(c)?l=this.processPrimitiveSchemaItem(o,s,c):l=this.processComplexSchemaItem(o,s,c),l&&typeof l=="object"&&"value"in l&&"raw"in l?(i[n]=l.value,i[`${n}Raw`]=l.raw):i[n]=l}}static processPrimitiveSchemaItem(e,t,i){var n;const o=(n=t.converter)!==null&&n!==void 0?n:Be(i)?new i:null;if(!o)throw new Error("Converter is empty");return t.repeated?this.processRepeatedPrimitiveItem(e,t,o):this.processSinglePrimitiveItem(e,t,i,o)}static processRepeatedPrimitiveItem(e,t,i){if(t.implicit){const n=t.repeated==="sequence"?ae:ve,o=new n;o.valueBlock=e.valueBlock;const s=et(o.toBER(!1));if(s.offset===-1)throw new Error(`Cannot parse the child item. ${s.result.error}`);if(!("value"in s.result.valueBlock&&Array.isArray(s.result.valueBlock.value)))throw new Error("Cannot get items from the ASN.1 parsed value. ASN.1 object is not constructed.");const c=s.result.valueBlock.value;return Array.from(c,l=>i.fromASN(l))}else return Array.from(e,n=>i.fromASN(n))}static processSinglePrimitiveItem(e,t,i,n){let o=e;if(t.implicit){let s;if(Be(i))s=new i().toSchema("");else{const c=h[i],l=os[c];if(!l)throw new Error(`Cannot get '${c}' class from asn1js module`);s=new l}s.valueBlock=o.valueBlock,o=et(s.toBER(!1)).result}return n.fromASN(o)}static processComplexSchemaItem(e,t,i){if(t.repeated){if(!Array.isArray(e))throw new Error("Cannot get list of items from the ASN.1 parsed value. ASN.1 value should be iterable.");return Array.from(e,n=>this.fromASN(n,i))}else{const n=this.handleImplicitTagging(e,t,i);if(this.isOptionalChoiceField(t))try{return this.fromASN(n,i)}catch(o){if(o instanceof Nt&&/Wrong values for Choice type/.test(o.message))return;throw o}else{const o=this.fromASN(n,i);return t.raw?{value:o,raw:e.valueBeforeDecodeView}:o}}}static handleImplicitTagging(e,t,i){if(t.implicit&&typeof t.context=="number"){const n=q.get(i);if(n.type===v.Sequence){const o=new ae;if("value"in e.valueBlock&&Array.isArray(e.valueBlock.value)&&"value"in o.valueBlock)return o.valueBlock.value=e.valueBlock.value,o}else if(n.type===v.Set){const o=new ve;if("value"in e.valueBlock&&Array.isArray(e.valueBlock.value)&&"value"in o.valueBlock)return o.valueBlock.value=e.valueBlock.value,o}}return e}}class Ai{static serialize(e){return e instanceof _?e.toBER(!1):this.toASN(e).toBER(!1)}static toASN(e){if(e&&typeof e=="object"&&Be(e))return e.toASN();if(!(e&&typeof e=="object"))throw new TypeError("Parameter 1 should be type of Object.");const t=e.constructor,i=q.get(t);q.cache(t);let n=[];if(i.itemType){if(!Array.isArray(e))throw new TypeError("Parameter 1 should be type of Array.");if(typeof i.itemType=="number"){const s=xt(i.itemType);if(!s)throw new Error(`Cannot get default converter for array item of ${t.name} ASN1 schema`);n=e.map(c=>s.toASN(c))}else n=e.map(s=>this.toAsnItem({type:i.itemType},"[]",t,s))}else for(const s in i.items){const c=i.items[s],l=e[s];if(l===void 0||c.defaultValue===l||typeof c.defaultValue=="object"&&typeof l=="object"&&dc(this.serialize(c.defaultValue),this.serialize(l)))continue;const f=Ai.toAsnItem(c,s,t,l);if(typeof c.context=="number")if(c.implicit)if(!c.repeated&&(typeof c.type=="number"||Be(c.type))){const p={};p.valueHex=f instanceof He?f.valueBeforeDecodeView:f.valueBlock.toBER(),n.push(new At(T({optional:c.optional,idBlock:{tagClass:3,tagNumber:c.context}},p)))}else n.push(new J({optional:c.optional,idBlock:{tagClass:3,tagNumber:c.context},value:f.valueBlock.value}));else n.push(new J({optional:c.optional,idBlock:{tagClass:3,tagNumber:c.context},value:[f]}));else c.repeated?n=n.concat(f):n.push(f)}let o;switch(i.type){case v.Sequence:o=new ae({value:n});break;case v.Set:o=new ve({value:n});break;case v.Choice:if(!n[0])throw new Error(`Schema '${t.name}' has wrong data. Choice cannot be empty.`);o=n[0];break}return o}static toAsnItem(e,t,i,n){let o;if(typeof e.type=="number"){const s=e.converter;if(!s)throw new Error(`Property '${t}' doesn't have converter for type ${h[e.type]} in schema '${i.name}'`);if(e.repeated){if(!Array.isArray(n))throw new TypeError("Parameter 'objProp' should be type of Array.");const c=Array.from(n,f=>s.toASN(f)),l=e.repeated==="sequence"?ae:ve;o=new l({value:c})}else o=s.toASN(n)}else if(e.repeated){if(!Array.isArray(n))throw new TypeError("Parameter 'objProp' should be type of Array.");const s=Array.from(n,l=>this.toASN(l)),c=e.repeated==="sequence"?ae:ve;o=new c({value:s})}else o=this.toASN(n);return o}}class j extends Array{constructor(e=[]){if(typeof e=="number")super(e);else{super();for(const t of e)this.push(t)}}}class ce{static serialize(e){return Ai.serialize(e)}static parse(e,t){return as.parse(e,t)}static toString(e){const t=N.isBufferSource(e)?N.toArrayBuffer(e):ce.serialize(e),i=et(t);if(i.offset===-1)throw new Error(`Cannot decode ASN.1 data. ${i.result.error}`);return i.result.toString()}}function a(r,e,t,i){var n=arguments.length,o=n<3?e:i===null?i=Object.getOwnPropertyDescriptor(e,t):i,s;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")o=Reflect.decorate(r,e,t,i);else for(var c=r.length-1;c>=0;c--)(s=r[c])&&(o=(n<3?s(o):n>3?s(e,t,o):s(e,t))||o);return n>3&&o&&Object.defineProperty(e,t,o),o}typeof SuppressedError=="function"&&SuppressedError;var Si;let cs=Si=class extends j{constructor(e){super(e),Object.setPrototypeOf(this,Si.prototype)}};cs=Si=a([A({type:v.Sequence,itemType:h.ObjectIdentifier})],cs);let Bi=class{constructor(e=new Date){this.value=e}};a([u({type:h.GeneralizedTime})],Bi.prototype,"value",void 0),Bi=a([A({type:v.Choice})],Bi);let ki=class{constructor(e=null){this.value=e}};a([u({type:h.Null})],ki.prototype,"value",void 0),ki=a([A({type:v.Choice})],ki);class ls{static isIPv4(e){return/^(\d{1,3}\.){3}\d{1,3}$/.test(e)}static parseIPv4(e){const t=e.split(".");if(t.length!==4)throw new Error("Invalid IPv4 address");return t.map(i=>{const n=parseInt(i,10);if(isNaN(n)||n<0||n>255)throw new Error("Invalid IPv4 address part");return n})}static parseIPv6(e){const i=this.expandIPv6(e).split(":");if(i.length!==8)throw new Error("Invalid IPv6 address");return i.reduce((n,o)=>{const s=parseInt(o,16);if(isNaN(s)||s<0||s>65535)throw new Error("Invalid IPv6 address part");return n.push(s>>8&255),n.push(s&255),n},[])}static expandIPv6(e){if(!e.includes("::"))return e;const t=e.split("::");if(t.length>2)throw new Error("Invalid IPv6 address");const i=t[0]?t[0].split(":"):[],n=t[1]?t[1].split(":"):[],o=8-(i.length+n.length);if(o<0)throw new Error("Invalid IPv6 address");return[...i,...Array(o).fill("0"),...n].join(":")}static formatIPv6(e){const t=[];for(let i=0;i<16;i+=2)t.push((e[i]<<8|e[i+1]).toString(16));return this.compressIPv6(t.join(":"))}static compressIPv6(e){const t=e.split(":");let i=-1,n=0,o=-1,s=0;for(let c=0;c<t.length;c++)t[c]==="0"?(o===-1&&(o=c),s++):(s>n&&(i=o,n=s),o=-1,s=0);if(s>n&&(i=o,n=s),n>1){const c=t.slice(0,i).join(":"),l=t.slice(i+n).join(":");return`${c}::${l}`}return e}static parseCIDR(e){const[t,i]=e.split("/"),n=parseInt(i,10);if(this.isIPv4(t)){if(n<0||n>32)throw new Error("Invalid IPv4 prefix length");return[this.parseIPv4(t),n]}else{if(n<0||n>128)throw new Error("Invalid IPv6 prefix length");return[this.parseIPv6(t),n]}}static decodeIP(e){if(e.length===64&&parseInt(e,16)===0)return"::/0";if(e.length!==16)return e;const t=parseInt(e.slice(8),16).toString(2).split("").reduce((n,o)=>n+ +o,0);let i=e.slice(0,8).replace(/(.{2})/g,n=>`${parseInt(n,16)}.`);return i=i.slice(0,-1),`${i}/${t}`}static toString(e){const t=new Uint8Array(e);if(t.length===4)return Array.from(t).join(".");if(t.length===16)return this.formatIPv6(t);if(t.length===8||t.length===32){const i=t.length/2,n=t.slice(0,i),o=t.slice(i);if(t.every(l=>l===0))return t.length===8?"0.0.0.0/0":"::/0";const c=o.reduce((l,f)=>l+(f.toString(2).match(/1/g)||[]).length,0);return t.length===8?`${Array.from(n).join(".")}/${c}`:`${this.formatIPv6(n)}/${c}`}return this.decodeIP(U.ToHex(e))}static fromString(e){if(e.includes("/")){const[i,n]=this.parseCIDR(e),o=new Uint8Array(i.length);let s=n;for(let l=0;l<o.length;l++)s>=8?(o[l]=255,s-=8):s>0&&(o[l]=255<<8-s,s=0);const c=new Uint8Array(i.length*2);return c.set(i,0),c.set(o,i.length),c.buffer}const t=this.isIPv4(e)?this.parseIPv4(e):this.parseIPv6(e);return new Uint8Array(t).buffer}}var xi,Ni,Ci;let le=class{constructor(e={}){Object.assign(this,e)}toString(){return this.bmpString||this.printableString||this.teletexString||this.universalString||this.utf8String||""}};a([u({type:h.TeletexString})],le.prototype,"teletexString",void 0),a([u({type:h.PrintableString})],le.prototype,"printableString",void 0),a([u({type:h.UniversalString})],le.prototype,"universalString",void 0),a([u({type:h.Utf8String})],le.prototype,"utf8String",void 0),a([u({type:h.BmpString})],le.prototype,"bmpString",void 0),le=a([A({type:v.Choice})],le);let rt=class extends le{constructor(e={}){super(e),Object.assign(this,e)}toString(){return this.ia5String||(this.anyValue?U.ToHex(this.anyValue):super.toString())}};a([u({type:h.IA5String})],rt.prototype,"ia5String",void 0),a([u({type:h.Any})],rt.prototype,"anyValue",void 0),rt=a([A({type:v.Choice})],rt);class Ei{constructor(e={}){this.type="",this.value=new rt,Object.assign(this,e)}}a([u({type:h.ObjectIdentifier})],Ei.prototype,"type",void 0),a([u({type:rt})],Ei.prototype,"value",void 0);let dr=xi=class extends j{constructor(e){super(e),Object.setPrototypeOf(this,xi.prototype)}};dr=xi=a([A({type:v.Set,itemType:Ei})],dr);let Ii=Ni=class extends j{constructor(e){super(e),Object.setPrototypeOf(this,Ni.prototype)}};Ii=Ni=a([A({type:v.Sequence,itemType:dr})],Ii);let Z=Ci=class extends Ii{constructor(e){super(e),Object.setPrototypeOf(this,Ci.prototype)}};Z=Ci=a([A({type:v.Sequence})],Z);const gc={fromASN:r=>ls.toString(bi.fromASN(r)),toASN:r=>bi.toASN(ls.fromString(r))};class Oi{constructor(e={}){this.typeId="",this.value=new ArrayBuffer(0),Object.assign(this,e)}}a([u({type:h.ObjectIdentifier})],Oi.prototype,"typeId",void 0),a([u({type:h.Any,context:0})],Oi.prototype,"value",void 0);class Ti{constructor(e={}){this.partyName=new le,Object.assign(this,e)}}a([u({type:le,optional:!0,context:0,implicit:!0})],Ti.prototype,"nameAssigner",void 0),a([u({type:le,context:1,implicit:!0})],Ti.prototype,"partyName",void 0);let E=class{constructor(e={}){Object.assign(this,e)}};a([u({type:Oi,context:0,implicit:!0})],E.prototype,"otherName",void 0),a([u({type:h.IA5String,context:1,implicit:!0})],E.prototype,"rfc822Name",void 0),a([u({type:h.IA5String,context:2,implicit:!0})],E.prototype,"dNSName",void 0),a([u({type:h.Any,context:3,implicit:!0})],E.prototype,"x400Address",void 0),a([u({type:Z,context:4,implicit:!1})],E.prototype,"directoryName",void 0),a([u({type:Ti,context:5})],E.prototype,"ediPartyName",void 0),a([u({type:h.IA5String,context:6,implicit:!0})],E.prototype,"uniformResourceIdentifier",void 0),a([u({type:h.OctetString,context:7,implicit:!0,converter:gc})],E.prototype,"iPAddress",void 0),a([u({type:h.ObjectIdentifier,context:8,implicit:!0})],E.prototype,"registeredID",void 0),E=a([A({type:v.Choice})],E);var Vi;class yr{constructor(e={}){this.accessMethod="",this.accessLocation=new E,Object.assign(this,e)}}a([u({type:h.ObjectIdentifier})],yr.prototype,"accessMethod",void 0),a([u({type:E})],yr.prototype,"accessLocation",void 0);let gr=Vi=class extends j{constructor(e){super(e),Object.setPrototypeOf(this,Vi.prototype)}};gr=Vi=a([A({type:v.Sequence,itemType:yr})],gr);class us extends C{}class ji{constructor(e={}){e&&Object.assign(this,e)}}a([u({type:us,context:0,optional:!0,implicit:!0})],ji.prototype,"keyIdentifier",void 0),a([u({type:E,context:1,optional:!0,implicit:!0,repeated:"sequence"})],ji.prototype,"authorityCertIssuer",void 0),a([u({type:h.Integer,context:2,optional:!0,implicit:!0,converter:re})],ji.prototype,"authorityCertSerialNumber",void 0);class fs{constructor(e={}){this.cA=!1,Object.assign(this,e)}}a([u({type:h.Boolean,defaultValue:!1})],fs.prototype,"cA",void 0),a([u({type:h.Integer,optional:!0})],fs.prototype,"pathLenConstraint",void 0);var Ui;let ue=Ui=class extends j{constructor(e){super(e),Object.setPrototypeOf(this,Ui.prototype)}};ue=Ui=a([A({type:v.Sequence,itemType:E})],ue);var Di;let hs=Di=class extends ue{constructor(e){super(e),Object.setPrototypeOf(this,Di.prototype)}};hs=Di=a([A({type:v.Sequence})],hs);var Ri;let ke=class{constructor(e={}){Object.assign(this,e)}toString(){return this.ia5String||this.visibleString||this.bmpString||this.utf8String||""}};a([u({type:h.IA5String})],ke.prototype,"ia5String",void 0),a([u({type:h.VisibleString})],ke.prototype,"visibleString",void 0),a([u({type:h.BmpString})],ke.prototype,"bmpString",void 0),a([u({type:h.Utf8String})],ke.prototype,"utf8String",void 0),ke=a([A({type:v.Choice})],ke);class Li{constructor(e={}){this.organization=new ke,this.noticeNumbers=[],Object.assign(this,e)}}a([u({type:ke})],Li.prototype,"organization",void 0),a([u({type:h.Integer,repeated:"sequence"})],Li.prototype,"noticeNumbers",void 0);class Hi{constructor(e={}){Object.assign(this,e)}}a([u({type:Li,optional:!0})],Hi.prototype,"noticeRef",void 0),a([u({type:ke,optional:!0})],Hi.prototype,"explicitText",void 0);let vr=class{constructor(e={}){Object.assign(this,e)}};a([u({type:h.IA5String})],vr.prototype,"cPSuri",void 0),a([u({type:Hi})],vr.prototype,"userNotice",void 0),vr=a([A({type:v.Choice})],vr);class $i{constructor(e={}){this.policyQualifierId="",this.qualifier=new ArrayBuffer(0),Object.assign(this,e)}}a([u({type:h.ObjectIdentifier})],$i.prototype,"policyQualifierId",void 0),a([u({type:h.Any})],$i.prototype,"qualifier",void 0);class Mi{constructor(e={}){this.policyIdentifier="",Object.assign(this,e)}}a([u({type:h.ObjectIdentifier})],Mi.prototype,"policyIdentifier",void 0),a([u({type:$i,repeated:"sequence",optional:!0})],Mi.prototype,"policyQualifiers",void 0);let ps=Ri=class extends j{constructor(e){super(e),Object.setPrototypeOf(this,Ri.prototype)}};ps=Ri=a([A({type:v.Sequence,itemType:Mi})],ps);let mr=class{constructor(e=0){this.value=e}};a([u({type:h.Integer})],mr.prototype,"value",void 0),mr=a([A({type:v.Choice})],mr);let ds=class extends mr{};ds=a([A({type:v.Choice})],ds);var Pi,fe;(function(r){r[r.unused=1]="unused",r[r.keyCompromise=2]="keyCompromise",r[r.cACompromise=4]="cACompromise",r[r.affiliationChanged=8]="affiliationChanged",r[r.superseded=16]="superseded",r[r.cessationOfOperation=32]="cessationOfOperation",r[r.certificateHold=64]="certificateHold",r[r.privilegeWithdrawn=128]="privilegeWithdrawn",r[r.aACompromise=256]="aACompromise"})(fe||(fe={}));class ys extends pr{toJSON(){const e=[],t=this.toNumber();return t&fe.aACompromise&&e.push("aACompromise"),t&fe.affiliationChanged&&e.push("affiliationChanged"),t&fe.cACompromise&&e.push("cACompromise"),t&fe.certificateHold&&e.push("certificateHold"),t&fe.cessationOfOperation&&e.push("cessationOfOperation"),t&fe.keyCompromise&&e.push("keyCompromise"),t&fe.privilegeWithdrawn&&e.push("privilegeWithdrawn"),t&fe.superseded&&e.push("superseded"),t&fe.unused&&e.push("unused"),e}toString(){return`[${this.toJSON().join(", ")}]`}}let it=class{constructor(e={}){Object.assign(this,e)}};a([u({type:E,context:0,repeated:"sequence",implicit:!0})],it.prototype,"fullName",void 0),a([u({type:dr,context:1,implicit:!0})],it.prototype,"nameRelativeToCRLIssuer",void 0),it=a([A({type:v.Choice})],it);class Ct{constructor(e={}){Object.assign(this,e)}}a([u({type:it,context:0,optional:!0})],Ct.prototype,"distributionPoint",void 0),a([u({type:ys,context:1,optional:!0,implicit:!0})],Ct.prototype,"reasons",void 0),a([u({type:E,context:2,optional:!0,repeated:"sequence",implicit:!0})],Ct.prototype,"cRLIssuer",void 0);let _i=Pi=class extends j{constructor(e){super(e),Object.setPrototypeOf(this,Pi.prototype)}};_i=Pi=a([A({type:v.Sequence,itemType:Ct})],_i);var qi;let gs=qi=class extends _i{constructor(e){super(e),Object.setPrototypeOf(this,qi.prototype)}};gs=qi=a([A({type:v.Sequence,itemType:Ct})],gs);class G{constructor(e={}){this.onlyContainsUserCerts=G.ONLY,this.onlyContainsCACerts=G.ONLY,this.indirectCRL=G.ONLY,this.onlyContainsAttributeCerts=G.ONLY,Object.assign(this,e)}}G.ONLY=!1,a([u({type:it,context:0,optional:!0})],G.prototype,"distributionPoint",void 0),a([u({type:h.Boolean,context:1,defaultValue:G.ONLY,implicit:!0})],G.prototype,"onlyContainsUserCerts",void 0),a([u({type:h.Boolean,context:2,defaultValue:G.ONLY,implicit:!0})],G.prototype,"onlyContainsCACerts",void 0),a([u({type:ys,context:3,optional:!0,implicit:!0})],G.prototype,"onlySomeReasons",void 0),a([u({type:h.Boolean,context:4,defaultValue:G.ONLY,implicit:!0})],G.prototype,"indirectCRL",void 0),a([u({type:h.Boolean,context:5,defaultValue:G.ONLY,implicit:!0})],G.prototype,"onlyContainsAttributeCerts",void 0);var Et;(function(r){r[r.unspecified=0]="unspecified",r[r.keyCompromise=1]="keyCompromise",r[r.cACompromise=2]="cACompromise",r[r.affiliationChanged=3]="affiliationChanged",r[r.superseded=4]="superseded",r[r.cessationOfOperation=5]="cessationOfOperation",r[r.certificateHold=6]="certificateHold",r[r.removeFromCRL=8]="removeFromCRL",r[r.privilegeWithdrawn=9]="privilegeWithdrawn",r[r.aACompromise=10]="aACompromise"})(Et||(Et={}));let wr=class{constructor(e=Et.unspecified){this.reason=Et.unspecified,this.reason=e}toJSON(){return Et[this.reason]}toString(){return this.toJSON()}};a([u({type:h.Enumerated})],wr.prototype,"reason",void 0),wr=a([A({type:v.Choice})],wr);var Fi;let vs=Fi=class extends j{constructor(e){super(e),Object.setPrototypeOf(this,Fi.prototype)}};vs=Fi=a([A({type:v.Sequence,itemType:h.ObjectIdentifier})],vs);let Gi=class{constructor(e=new ArrayBuffer(0)){this.value=e}};a([u({type:h.Integer,converter:re})],Gi.prototype,"value",void 0),Gi=a([A({type:v.Choice})],Gi);let zi=class{constructor(e){this.value=new Date,e&&(this.value=e)}};a([u({type:h.GeneralizedTime})],zi.prototype,"value",void 0),zi=a([A({type:v.Choice})],zi);var Xi;let ms=Xi=class extends ue{constructor(e){super(e),Object.setPrototypeOf(this,Xi.prototype)}};ms=Xi=a([A({type:v.Sequence})],ms);var ws;(function(r){r[r.digitalSignature=1]="digitalSignature",r[r.nonRepudiation=2]="nonRepudiation",r[r.keyEncipherment=4]="keyEncipherment",r[r.dataEncipherment=8]="dataEncipherment",r[r.keyAgreement=16]="keyAgreement",r[r.keyCertSign=32]="keyCertSign",r[r.cRLSign=64]="cRLSign",r[r.encipherOnly=128]="encipherOnly",r[r.decipherOnly=256]="decipherOnly"})(ws||(ws={}));var Wi;class br{constructor(e={}){this.base=new E,this.minimum=0,Object.assign(this,e)}}a([u({type:E})],br.prototype,"base",void 0),a([u({type:h.Integer,context:0,defaultValue:0,implicit:!0})],br.prototype,"minimum",void 0),a([u({type:h.Integer,context:1,optional:!0,implicit:!0})],br.prototype,"maximum",void 0);let Ar=Wi=class extends j{constructor(e){super(e),Object.setPrototypeOf(this,Wi.prototype)}};Ar=Wi=a([A({type:v.Sequence,itemType:br})],Ar);class bs{constructor(e={}){Object.assign(this,e)}}a([u({type:Ar,context:0,optional:!0,implicit:!0})],bs.prototype,"permittedSubtrees",void 0),a([u({type:Ar,context:1,optional:!0,implicit:!0})],bs.prototype,"excludedSubtrees",void 0);class As{constructor(e={}){Object.assign(this,e)}}a([u({type:h.Integer,context:0,implicit:!0,optional:!0,converter:re})],As.prototype,"requireExplicitPolicy",void 0),a([u({type:h.Integer,context:1,implicit:!0,optional:!0,converter:re})],As.prototype,"inhibitPolicyMapping",void 0);var Ji;class Ki{constructor(e={}){this.issuerDomainPolicy="",this.subjectDomainPolicy="",Object.assign(this,e)}}a([u({type:h.ObjectIdentifier})],Ki.prototype,"issuerDomainPolicy",void 0),a([u({type:h.ObjectIdentifier})],Ki.prototype,"subjectDomainPolicy",void 0);let Ss=Ji=class extends j{constructor(e){super(e),Object.setPrototypeOf(this,Ji.prototype)}};Ss=Ji=a([A({type:v.Sequence,itemType:Ki})],Ss);var Yi;let Bs=Yi=class extends ue{constructor(e){super(e),Object.setPrototypeOf(this,Yi.prototype)}};Bs=Yi=a([A({type:v.Sequence})],Bs);class It{constructor(e={}){this.type="",this.values=[],Object.assign(this,e)}}a([u({type:h.ObjectIdentifier})],It.prototype,"type",void 0),a([u({type:h.Any,repeated:"set"})],It.prototype,"values",void 0);var Zi;let ks=Zi=class extends j{constructor(e){super(e),Object.setPrototypeOf(this,Zi.prototype)}};ks=Zi=a([A({type:v.Sequence,itemType:It})],ks);class Ot extends us{}class xs{constructor(e={}){Object.assign(this,e)}}a([u({type:h.GeneralizedTime,context:0,implicit:!0,optional:!0})],xs.prototype,"notBefore",void 0),a([u({type:h.GeneralizedTime,context:1,implicit:!0,optional:!0})],xs.prototype,"notAfter",void 0);var Tt;(function(r){r[r.keyUpdateAllowed=1]="keyUpdateAllowed",r[r.newExtensions=2]="newExtensions",r[r.pKIXCertificate=4]="pKIXCertificate"})(Tt||(Tt={}));class Ns extends pr{toJSON(){const e=[],t=this.toNumber();return t&Tt.pKIXCertificate&&e.push("pKIXCertificate"),t&Tt.newExtensions&&e.push("newExtensions"),t&Tt.keyUpdateAllowed&&e.push("keyUpdateAllowed"),e}toString(){return`[${this.toJSON().join(", ")}]`}}class Cs{constructor(e={}){this.entrustVers="",this.entrustInfoFlags=new Ns,Object.assign(this,e)}}a([u({type:h.GeneralString})],Cs.prototype,"entrustVers",void 0),a([u({type:Ns})],Cs.prototype,"entrustInfoFlags",void 0);var Qi;let Es=Qi=class extends j{constructor(e){super(e),Object.setPrototypeOf(this,Qi.prototype)}};Es=Qi=a([A({type:v.Sequence,itemType:yr})],Es);class k{constructor(e={}){this.algorithm="",Object.assign(this,e)}isEqual(e){return e instanceof k&&e.algorithm==this.algorithm&&(e.parameters&&this.parameters&&Ia(e.parameters,this.parameters)||e.parameters===this.parameters)}}a([u({type:h.ObjectIdentifier})],k.prototype,"algorithm",void 0),a([u({type:h.Any,optional:!0})],k.prototype,"parameters",void 0);class Sr{constructor(e={}){this.algorithm=new k,this.subjectPublicKey=new ArrayBuffer(0),Object.assign(this,e)}}a([u({type:k})],Sr.prototype,"algorithm",void 0),a([u({type:h.BitString})],Sr.prototype,"subjectPublicKey",void 0);let z=class{constructor(e){if(e)if(typeof e=="string"||typeof e=="number"||e instanceof Date){const t=new Date(e);t.getUTCFullYear()>2049?this.generalTime=t:this.utcTime=t}else Object.assign(this,e)}getTime(){const e=this.utcTime||this.generalTime;if(!e)throw new Error("Cannot get time from CHOICE object");return e}};a([u({type:h.UTCTime})],z.prototype,"utcTime",void 0),a([u({type:h.GeneralizedTime})],z.prototype,"generalTime",void 0),z=a([A({type:v.Choice})],z);class Br{constructor(e){this.notBefore=new z(new Date),this.notAfter=new z(new Date),e&&(this.notBefore=new z(e.notBefore),this.notAfter=new z(e.notAfter))}}a([u({type:z})],Br.prototype,"notBefore",void 0),a([u({type:z})],Br.prototype,"notAfter",void 0);var en;class Q{constructor(e={}){this.extnID="",this.critical=Q.CRITICAL,this.extnValue=new C,Object.assign(this,e)}}Q.CRITICAL=!1,a([u({type:h.ObjectIdentifier})],Q.prototype,"extnID",void 0),a([u({type:h.Boolean,defaultValue:Q.CRITICAL})],Q.prototype,"critical",void 0),a([u({type:C})],Q.prototype,"extnValue",void 0);let nt=en=class extends j{constructor(e){super(e),Object.setPrototypeOf(this,en.prototype)}};nt=en=a([A({type:v.Sequence,itemType:Q})],nt);var kr;(function(r){r[r.v1=0]="v1",r[r.v2=1]="v2",r[r.v3=2]="v3"})(kr||(kr={}));class oe{constructor(e={}){this.version=kr.v1,this.serialNumber=new ArrayBuffer(0),this.signature=new k,this.issuer=new Z,this.validity=new Br,this.subject=new Z,this.subjectPublicKeyInfo=new Sr,Object.assign(this,e)}}a([u({type:h.Integer,context:0,defaultValue:kr.v1})],oe.prototype,"version",void 0),a([u({type:h.Integer,converter:re})],oe.prototype,"serialNumber",void 0),a([u({type:k})],oe.prototype,"signature",void 0),a([u({type:Z})],oe.prototype,"issuer",void 0),a([u({type:Br})],oe.prototype,"validity",void 0),a([u({type:Z})],oe.prototype,"subject",void 0),a([u({type:Sr})],oe.prototype,"subjectPublicKeyInfo",void 0),a([u({type:h.BitString,context:1,implicit:!0,optional:!0})],oe.prototype,"issuerUniqueID",void 0),a([u({type:h.BitString,context:2,implicit:!0,optional:!0})],oe.prototype,"subjectUniqueID",void 0),a([u({type:nt,context:3,optional:!0})],oe.prototype,"extensions",void 0);class _e{constructor(e={}){this.tbsCertificate=new oe,this.signatureAlgorithm=new k,this.signatureValue=new ArrayBuffer(0),Object.assign(this,e)}}a([u({type:oe,raw:!0})],_e.prototype,"tbsCertificate",void 0),a([u({type:k})],_e.prototype,"signatureAlgorithm",void 0),a([u({type:h.BitString})],_e.prototype,"signatureValue",void 0);class xr{constructor(e={}){this.userCertificate=new ArrayBuffer(0),this.revocationDate=new z,Object.assign(this,e)}}a([u({type:h.Integer,converter:re})],xr.prototype,"userCertificate",void 0),a([u({type:z})],xr.prototype,"revocationDate",void 0),a([u({type:Q,optional:!0,repeated:"sequence"})],xr.prototype,"crlEntryExtensions",void 0);class xe{constructor(e={}){this.signature=new k,this.issuer=new Z,this.thisUpdate=new z,Object.assign(this,e)}}a([u({type:h.Integer,optional:!0})],xe.prototype,"version",void 0),a([u({type:k})],xe.prototype,"signature",void 0),a([u({type:Z})],xe.prototype,"issuer",void 0),a([u({type:z})],xe.prototype,"thisUpdate",void 0),a([u({type:z,optional:!0})],xe.prototype,"nextUpdate",void 0),a([u({type:xr,repeated:"sequence",optional:!0})],xe.prototype,"revokedCertificates",void 0),a([u({type:Q,optional:!0,context:0,repeated:"sequence"})],xe.prototype,"crlExtensions",void 0);class tn{constructor(e={}){this.tbsCertList=new xe,this.signatureAlgorithm=new k,this.signature=new ArrayBuffer(0),Object.assign(this,e)}}a([u({type:xe,raw:!0})],tn.prototype,"tbsCertList",void 0),a([u({type:k})],tn.prototype,"signatureAlgorithm",void 0),a([u({type:h.BitString})],tn.prototype,"signature",void 0);var rn;class nn{constructor(e={}){this.sigIdentifier=new k,Object.assign(this,e)}}a([u({type:k})],nn.prototype,"sigIdentifier",void 0),a([u({type:k,optional:!0})],nn.prototype,"certIdentifier",void 0);let Is=rn=class extends j{constructor(e){super(e),Object.setPrototypeOf(this,rn.prototype)}};Is=rn=a([A({type:v.Sequence,itemType:nn})],Is);class Os{constructor(e={}){this.issuer=new Z,this.locator=new gr,Object.assign(this,e)}}a([u({type:Z})],Os.prototype,"issuer",void 0),a([u({type:gr})],Os.prototype,"locator",void 0);class vc extends C{}let ot=class{constructor(e={}){Object.assign(this,e)}};a([u({type:Z,context:1})],ot.prototype,"byName",void 0),a([u({type:vc,context:2})],ot.prototype,"byKey",void 0),ot=a([A({type:v.Choice})],ot);class Ne{constructor(e={}){this.hashAlgorithm=new k,this.issuerNameHash=new C,this.issuerKeyHash=new C,this.serialNumber=new ArrayBuffer(0),Object.assign(this,e)}}a([u({type:k})],Ne.prototype,"hashAlgorithm",void 0),a([u({type:C})],Ne.prototype,"issuerNameHash",void 0),a([u({type:C})],Ne.prototype,"issuerKeyHash",void 0),a([u({type:h.Integer,converter:re})],Ne.prototype,"serialNumber",void 0);class on{constructor(e={}){this.revocationTime=new Date,Object.assign(this,e)}}a([u({type:h.GeneralizedTime})],on.prototype,"revocationTime",void 0),a([u({type:wr,context:0,optional:!0})],on.prototype,"revocationReason",void 0);let qe=class{constructor(e={}){Object.assign(this,e)}};a([u({type:h.Null,context:0,implicit:!0})],qe.prototype,"good",void 0),a([u({type:on,context:1,implicit:!0})],qe.prototype,"revoked",void 0),a([u({type:h.Null,context:2,implicit:!0})],qe.prototype,"unknown",void 0),qe=a([A({type:v.Choice})],qe);class st{constructor(e={}){this.certID=new Ne,this.certStatus=new qe,this.thisUpdate=new Date,Object.assign(this,e)}}a([u({type:Ne})],st.prototype,"certID",void 0),a([u({type:qe})],st.prototype,"certStatus",void 0),a([u({type:h.GeneralizedTime})],st.prototype,"thisUpdate",void 0),a([u({type:h.GeneralizedTime,context:0,optional:!0})],st.prototype,"nextUpdate",void 0),a([u({type:Q,context:1,repeated:"sequence",optional:!0})],st.prototype,"singleExtensions",void 0);var at;(function(r){r[r.v1=0]="v1"})(at||(at={}));class Fe{constructor(e={}){this.version=at.v1,this.responderID=new ot,this.producedAt=new Date,this.responses=[],Object.assign(this,e)}}a([u({type:h.Integer,context:0,defaultValue:at.v1})],Fe.prototype,"version",void 0),a([u({type:ot})],Fe.prototype,"responderID",void 0),a([u({type:h.GeneralizedTime})],Fe.prototype,"producedAt",void 0),a([u({type:st,repeated:"sequence"})],Fe.prototype,"responses",void 0),a([u({type:Q,repeated:"sequence",context:1,optional:!0})],Fe.prototype,"responseExtensions",void 0);class Vt{constructor(e={}){this.tbsResponseData=new Fe,this.signatureAlgorithm=new k,this.signature=new ArrayBuffer(0),Object.assign(this,e)}}a([u({type:Fe,raw:!0})],Vt.prototype,"tbsResponseData",void 0),a([u({type:k})],Vt.prototype,"signatureAlgorithm",void 0),a([u({type:h.BitString})],Vt.prototype,"signature",void 0),a([u({type:_e,repeated:"sequence",optional:!0,context:0})],Vt.prototype,"certs",void 0);class Nr{constructor(e={}){this.signatureAlgorithm=new k,this.signature=new ArrayBuffer(0),Object.assign(this,e)}}a([u({type:k})],Nr.prototype,"signatureAlgorithm",void 0),a([u({type:h.BitString})],Nr.prototype,"signature",void 0),a([u({type:_e,repeated:"sequence",optional:!0,context:0})],Nr.prototype,"certs",void 0);class Cr{constructor(e={}){this.reqCert=new Ne,Object.assign(this,e)}}a([u({type:Ne})],Cr.prototype,"reqCert",void 0),a([u({type:Q,repeated:"sequence",optional:!0})],Cr.prototype,"singleRequestExtensions",void 0);class Ge{constructor(e={}){this.version=at.v1,this.requestList=[],Object.assign(this,e)}}a([u({type:h.Integer,context:0,defaultValue:at.v1})],Ge.prototype,"version",void 0),a([u({type:E,context:1,optional:!0})],Ge.prototype,"requestorName",void 0),a([u({type:Cr,repeated:"sequence"})],Ge.prototype,"requestList",void 0),a([u({type:Q,context:2,optional:!0,repeated:"sequence"})],Ge.prototype,"requestExtensions",void 0);class sn{constructor(e={}){this.tbsRequest=new Ge,Object.assign(this,e)}}a([u({type:Ge,raw:!0})],sn.prototype,"tbsRequest",void 0),a([u({type:Nr,optional:!0,context:0})],sn.prototype,"optionalSignature",void 0);var Ce;(function(r){r[r.successful=0]="successful",r[r.malformedRequest=1]="malformedRequest",r[r.internalError=2]="internalError",r[r.tryLater=3]="tryLater",r[r.sigRequired=5]="sigRequired",r[r.unauthorized=6]="unauthorized"})(Ce||(Ce={}));class an{constructor(e={}){this.responseType="",this.response=new C,Object.assign(this,e)}}a([u({type:h.ObjectIdentifier})],an.prototype,"responseType",void 0),a([u({type:C})],an.prototype,"response",void 0);class cn{constructor(e={}){this.responseStatus=Ce.successful,Object.assign(this,e)}}a([u({type:h.Enumerated})],cn.prototype,"responseStatus",void 0),a([u({type:an,context:0,optional:!0})],cn.prototype,"responseBytes",void 0);var Er=(r,e,t)=>new Promise((i,n)=>{var o=l=>{try{c(t.next(l))}catch(f){n(f)}},s=l=>{try{c(t.throw(l))}catch(f){n(f)}},c=l=>l.done?i(l.value):Promise.resolve(l.value).then(o,s);c((t=t.apply(r,e)).next())});function ln(r){return Er(this,arguments,function*(e,t={}){const{timeout:i=1e4,method:n="GET",body:o,contentType:s,accept:c,proxyUrl:l}=t,f=l?`${l}${encodeURIComponent(e)}`:e,p=new AbortController,d=setTimeout(()=>p.abort(),i);try{const w={};s&&(w["Content-Type"]=s),c&&(w.Accept=c);const y=yield fetch(f,{method:n,headers:w,body:o?new Uint8Array(o):void 0,signal:p.signal});if(clearTimeout(d),!y.ok)return{ok:!1,status:y.status,error:`HTTP ${y.status}: ${y.statusText}`};const g=yield y.arrayBuffer();return{ok:!0,status:y.status,data:g}}catch(w){return clearTimeout(d),w instanceof Error?w.name==="AbortError"?{ok:!1,status:0,error:`Request timeout after ${i}ms`}:{ok:!1,status:0,error:w.message}:{ok:!1,status:0,error:String(w)}}})}function mc(r,e,t=5e3,i){return Er(this,null,function*(){return ln(r,{method:"POST",body:e,contentType:"application/ocsp-request",accept:"application/ocsp-response",timeout:t,proxyUrl:i})})}function wc(r,e=1e4,t){return Er(this,null,function*(){return ln(r,{method:"GET",accept:"application/pkix-crl",timeout:e,proxyUrl:t})})}function bc(r,e=5e3,t){return Er(this,null,function*(){return ln(r,{method:"GET",accept:"application/pkix-cert",timeout:e,proxyUrl:t})})}function Ts(r){const e=new Uint8Array(r);if(typeof btoa=="function"){let t="";for(let i=0;i<e.length;i++)t+=String.fromCharCode(e[i]);return btoa(t)}return Buffer.from(e).toString("base64")}function Vs(r){const e=r.replace(/\s/g,"");if(typeof atob=="function"){const i=atob(e),n=new Uint8Array(i.length);for(let o=0;o<i.length;o++)n[o]=i.charCodeAt(o);return n.buffer}const t=Buffer.from(e,"base64");return t.buffer.slice(t.byteOffset,t.byteOffset+t.byteLength)}function Ac(r){return new Uint8Array(Vs(r))}function un(r){return Array.from(new Uint8Array(r)).map(e=>e.toString(16).padStart(2,"0")).join("")}function Sc(r){const e=new Uint8Array(r.length/2);for(let t=0;t<r.length;t+=2)e[t/2]=parseInt(r.substring(t,t+2),16);return e.buffer}function js(r,e="CERTIFICATE"){const t=Ts(r).match(/.{1,64}/g)||[];return`-----BEGIN ${e}-----
76
76
  ${t.join(`
77
77
  `)}
78
- -----END ${e}-----`}var Or=(r,e,t)=>new Promise((i,o)=>{var n=l=>{try{c(t.next(l))}catch(f){o(f)}},s=l=>{try{c(t.throw(l))}catch(f){o(f)}},c=l=>l.done?i(l.value):Promise.resolve(l.value).then(n,s);c((t=t.apply(r,e)).next())});const Vs="1.3.6.1.5.5.7.1.1",Sc="1.3.14.3.2.26";function js(r){return Or(this,null,function*(){if(typeof crypto!="undefined"&&crypto.subtle)return crypto.subtle.digest("SHA-1",r);const e=require("crypto").createHash("sha1");return e.update(Buffer.from(r)),e.digest().buffer})}function Bc(r){try{const e=r.getExtension(Vs);return e?e.ocsp.filter(t=>t.type==="url").map(t=>t.value):[]}catch(e){return[]}}function kc(r){try{const e=r.getExtension(Vs);return e?e.caIssuers.filter(t=>t.type==="url").map(t=>t.value):[]}catch(e){return[]}}function xc(r,e){const t=r.issuer;for(const i of e)try{const o=new V.X509Certificate(i);if(o.subject===t)return o}catch(o){}return null}function Nc(r,e=5e3,t){return Or(this,null,function*(){const i=kc(r);for(const o of i)try{const n=yield wc(o,e,t);if(n.ok&&n.data)try{return new V.X509Certificate(n.data)}catch(s){const c=Ts(n.data);return new V.X509Certificate(c)}}catch(n){}return null})}function Cc(r,e){return Or(this,null,function*(){const t=ce.serialize(e.subjectName.toJSON()),i=yield js(t),o=yield js(e.publicKey.rawData),n=Ac(r.serialNumber),s=new Ne({hashAlgorithm:new k({algorithm:Sc}),issuerNameHash:new C(i),issuerKeyHash:new C(o),serialNumber:n}),c=new Cr({reqCert:s}),l=new qe({requestList:[c]}),f=new no({tbsRequest:l});return ce.serialize(f)})}function Ec(r){const e=new Date;try{const t=ce.parse(r,ao);switch(t.responseStatus){case Ce.successful:break;case Ce.malformedRequest:return{isValid:!1,status:"error",method:"ocsp",reason:"OCSP responder returned: malformed request",checkedAt:e};case Ce.internalError:return{isValid:!1,status:"error",method:"ocsp",reason:"OCSP responder returned: internal error",checkedAt:e};case Ce.tryLater:return{isValid:!1,status:"unknown",method:"ocsp",reason:"OCSP responder returned: try later",checkedAt:e};case Ce.sigRequired:return{isValid:!1,status:"error",method:"ocsp",reason:"OCSP responder requires signature",checkedAt:e};case Ce.unauthorized:return{isValid:!1,status:"error",method:"ocsp",reason:"OCSP responder returned: unauthorized",checkedAt:e};default:return{isValid:!1,status:"error",method:"ocsp",reason:`OCSP responder returned unknown status: ${t.responseStatus}`,checkedAt:e}}if(!t.responseBytes)return{isValid:!1,status:"error",method:"ocsp",reason:"OCSP response has no response bytes",checkedAt:e};const i=ce.parse(t.responseBytes.response.buffer,Vt).tbsResponseData.responses;if(!i||i.length===0)return{isValid:!1,status:"error",method:"ocsp",reason:"OCSP response contains no certificate status",checkedAt:e};const o=i[0].certStatus;return o.good!==void 0?{isValid:!0,status:"good",method:"ocsp",checkedAt:e}:o.revoked?{isValid:!1,status:"revoked",method:"ocsp",reason:o.revoked.revocationReason!==void 0?`Certificate revoked (reason: ${o.revoked.revocationReason})`:"Certificate revoked",revokedAt:o.revoked.revocationTime,checkedAt:e}:o.unknown!==void 0?{isValid:!1,status:"unknown",method:"ocsp",reason:"OCSP responder does not know about this certificate",checkedAt:e}:{isValid:!1,status:"error",method:"ocsp",reason:"Unexpected certificate status in OCSP response",checkedAt:e}}catch(t){return{isValid:!1,status:"error",method:"ocsp",reason:`Failed to parse OCSP response: ${t instanceof Error?t.message:String(t)}`,checkedAt:e}}}function Ic(r,e){return Or(this,arguments,function*(t,i,o={}){const{timeout:n=5e3,certificateChain:s=[],proxyUrl:c}=o,l=new Date,f=Bc(t);if(f.length===0)return{isValid:!1,status:"unknown",method:"ocsp",reason:"Certificate has no OCSP responder URL",checkedAt:l};let p=i;if(p||(p=xc(t,s)),p||(p=yield Nc(t,n,c)),!p)return{isValid:!1,status:"unknown",method:"ocsp",reason:"Could not find or fetch issuer certificate for OCSP",checkedAt:l};let d;try{d=yield Cc(t,p)}catch(w){return{isValid:!1,status:"error",method:"ocsp",reason:`Failed to build OCSP request: ${w instanceof Error?w.message:String(w)}`,checkedAt:l}}for(const w of f)try{const y=yield vc(w,d,n,c);if(y.ok&&y.data)return Ec(y.data)}catch(y){}return{isValid:!1,status:"error",method:"ocsp",reason:"All OCSP requests failed",checkedAt:l}})}var Oc=(r,e,t)=>new Promise((i,o)=>{var n=l=>{try{c(t.next(l))}catch(f){o(f)}},s=l=>{try{c(t.throw(l))}catch(f){o(f)}},c=l=>l.done?i(l.value):Promise.resolve(l.value).then(n,s);c((t=t.apply(r,e)).next())});const Tc="2.5.29.31";function Vc(r){try{const e=r.getExtension(Tc);if(!e)return[];const t=[];for(const i of e.distributionPoints)if(i.distributionPoint){const o=i.distributionPoint;if("fullName"in o&&o.fullName)for(const n of o.fullName)n.uniformResourceIdentifier&&t.push(n.uniformResourceIdentifier)}return t}catch(e){return[]}}function jc(r,e){const t=e.toLowerCase().replace(/^0+(?=.)/,"")||"0";for(const i of r.entries)if((i.serialNumber.toLowerCase().replace(/^0+(?=.)/,"")||"0")===t)return{isRevoked:!0,revokedAt:i.revocationDate,reason:i.reason};return{isRevoked:!1}}function Uc(r){try{return new V.X509Crl(r)}catch(e){try{const t=`-----BEGIN X509 CRL-----
79
- ${(Os(r).match(/.{1,64}/g)||[]).join(`
78
+ -----END ${e}-----`}var Ir=(r,e,t)=>new Promise((i,n)=>{var o=l=>{try{c(t.next(l))}catch(f){n(f)}},s=l=>{try{c(t.throw(l))}catch(f){n(f)}},c=l=>l.done?i(l.value):Promise.resolve(l.value).then(o,s);c((t=t.apply(r,e)).next())});const Us="1.3.6.1.5.5.7.1.1",Bc="1.3.14.3.2.26";function Ds(r){return Ir(this,null,function*(){if(typeof crypto!="undefined"&&crypto.subtle)return crypto.subtle.digest("SHA-1",r);const e=require("crypto").createHash("sha1");return e.update(Buffer.from(r)),e.digest().buffer})}function kc(r){try{const e=r.getExtension(Us);return e?e.ocsp.filter(t=>t.type==="url").map(t=>t.value):[]}catch(e){return[]}}function xc(r){try{const e=r.getExtension(Us);return e?e.caIssuers.filter(t=>t.type==="url").map(t=>t.value):[]}catch(e){return[]}}function Nc(r,e){const t=r.issuer;for(const i of e)try{const n=new V.X509Certificate(i);if(n.subject===t)return n}catch(n){}return null}function Cc(r,e=5e3,t){return Ir(this,null,function*(){const i=xc(r);for(const n of i)try{const o=yield bc(n,e,t);if(o.ok&&o.data)try{return new V.X509Certificate(o.data)}catch(s){const c=js(o.data);return new V.X509Certificate(c)}}catch(o){}return null})}function Ec(r,e){return Ir(this,null,function*(){const t=as.parse(e.rawData,_e),i=ce.serialize(t.tbsCertificate.subject),n=yield Ds(i),o=yield Ds(t.tbsCertificate.subjectPublicKeyInfo.subjectPublicKey),s=Sc(r.serialNumber),c=new Ne({hashAlgorithm:new k({algorithm:Bc}),issuerNameHash:new C(n),issuerKeyHash:new C(o),serialNumber:s}),l=new Cr({reqCert:c}),f=new Ge({requestList:[l]}),p=new sn({tbsRequest:f});return ce.serialize(p)})}function Ic(r){const e=new Date;try{const t=ce.parse(r,cn);switch(t.responseStatus){case Ce.successful:break;case Ce.malformedRequest:return{isValid:!1,status:"error",method:"ocsp",reason:"OCSP responder returned: malformed request",checkedAt:e};case Ce.internalError:return{isValid:!1,status:"error",method:"ocsp",reason:"OCSP responder returned: internal error",checkedAt:e};case Ce.tryLater:return{isValid:!1,status:"unknown",method:"ocsp",reason:"OCSP responder returned: try later",checkedAt:e};case Ce.sigRequired:return{isValid:!1,status:"error",method:"ocsp",reason:"OCSP responder requires signature",checkedAt:e};case Ce.unauthorized:return{isValid:!1,status:"error",method:"ocsp",reason:"OCSP responder returned: unauthorized",checkedAt:e};default:return{isValid:!1,status:"error",method:"ocsp",reason:`OCSP responder returned unknown status: ${t.responseStatus}`,checkedAt:e}}if(!t.responseBytes)return{isValid:!1,status:"error",method:"ocsp",reason:"OCSP response has no response bytes",checkedAt:e};const i=ce.parse(t.responseBytes.response.buffer,Vt).tbsResponseData.responses;if(!i||i.length===0)return{isValid:!1,status:"error",method:"ocsp",reason:"OCSP response contains no certificate status",checkedAt:e};const n=i[0].certStatus;return n.good!==void 0?{isValid:!0,status:"good",method:"ocsp",checkedAt:e}:n.revoked?{isValid:!1,status:"revoked",method:"ocsp",reason:n.revoked.revocationReason!==void 0?`Certificate revoked (reason: ${n.revoked.revocationReason})`:"Certificate revoked",revokedAt:n.revoked.revocationTime,checkedAt:e}:n.unknown!==void 0?{isValid:!1,status:"unknown",method:"ocsp",reason:"OCSP responder does not know about this certificate",checkedAt:e}:{isValid:!1,status:"error",method:"ocsp",reason:"Unexpected certificate status in OCSP response",checkedAt:e}}catch(t){return{isValid:!1,status:"error",method:"ocsp",reason:`Failed to parse OCSP response: ${t instanceof Error?t.message:String(t)}`,checkedAt:e}}}function Oc(r,e){return Ir(this,arguments,function*(t,i,n={}){const{timeout:o=5e3,certificateChain:s=[],proxyUrl:c}=n,l=new Date,f=kc(t);if(f.length===0)return{isValid:!1,status:"unknown",method:"ocsp",reason:"Certificate has no OCSP responder URL",checkedAt:l};let p=i;if(p||(p=Nc(t,s)),p||(p=yield Cc(t,o,c)),!p)return{isValid:!1,status:"unknown",method:"ocsp",reason:"Could not find or fetch issuer certificate for OCSP",checkedAt:l};let d;try{d=yield Ec(t,p)}catch(w){return{isValid:!1,status:"error",method:"ocsp",reason:`Failed to build OCSP request: ${w instanceof Error?w.message:String(w)}`,checkedAt:l}}for(const w of f)try{const y=yield mc(w,d,o,c);if(y.ok&&y.data)return Ic(y.data)}catch(y){}return{isValid:!1,status:"error",method:"ocsp",reason:"All OCSP requests failed",checkedAt:l}})}var Tc=(r,e,t)=>new Promise((i,n)=>{var o=l=>{try{c(t.next(l))}catch(f){n(f)}},s=l=>{try{c(t.throw(l))}catch(f){n(f)}},c=l=>l.done?i(l.value):Promise.resolve(l.value).then(o,s);c((t=t.apply(r,e)).next())});const Vc="2.5.29.31";function jc(r){try{const e=r.getExtension(Vc);if(!e)return[];const t=[];for(const i of e.distributionPoints)if(i.distributionPoint){const n=i.distributionPoint;if("fullName"in n&&n.fullName)for(const o of n.fullName)o.uniformResourceIdentifier&&t.push(o.uniformResourceIdentifier)}return t}catch(e){return[]}}function Uc(r,e){const t=e.toLowerCase().replace(/^0+(?=.)/,"")||"0";for(const i of r.entries)if((i.serialNumber.toLowerCase().replace(/^0+(?=.)/,"")||"0")===t)return{isRevoked:!0,revokedAt:i.revocationDate,reason:i.reason};return{isRevoked:!1}}function Dc(r){try{return new V.X509Crl(r)}catch(e){try{const t=`-----BEGIN X509 CRL-----
79
+ ${(Ts(r).match(/.{1,64}/g)||[]).join(`
80
80
  `)}
81
- -----END X509 CRL-----`;return new V.X509Crl(t)}catch(t){return null}}}function Dc(r){return Oc(this,arguments,function*(e,t={}){const{timeout:i=1e4,proxyUrl:o}=t,n=new Date,s=Vc(e);if(s.length===0)return{isValid:!1,status:"unknown",method:"crl",reason:"Certificate has no CRL distribution point",checkedAt:n};const c=[];for(const l of s)try{const f=yield mc(l,i,o);if(!f.ok||!f.data){c.push(`${l}: ${f.error||"Failed to fetch"}`);continue}const p=Uc(f.data);if(!p){c.push(`${l}: Failed to parse CRL data`);continue}const d=jc(p,e.serialNumber);return d.isRevoked?{isValid:!1,status:"revoked",method:"crl",reason:d.reason!==void 0?`Certificate revoked (reason code: ${d.reason})`:"Certificate revoked",revokedAt:d.revokedAt,checkedAt:n}:{isValid:!0,status:"good",method:"crl",checkedAt:n}}catch(f){c.push(`${l}: ${f instanceof Error?f.message:String(f)}`)}return{isValid:!1,status:"error",method:"crl",reason:`All CRL checks failed: ${c.join("; ")}`,checkedAt:n}})}var Rc=Object.defineProperty,Us=Object.getOwnPropertySymbols,Lc=Object.prototype.hasOwnProperty,Hc=Object.prototype.propertyIsEnumerable,Ds=(r,e,t)=>e in r?Rc(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,Rs=(r,e)=>{for(var t in e||(e={}))Lc.call(e,t)&&Ds(r,t,e[t]);if(Us)for(var t of Us(e))Hc.call(e,t)&&Ds(r,t,e[t]);return r},$c=(r,e,t)=>new Promise((i,o)=>{var n=l=>{try{c(t.next(l))}catch(f){o(f)}},s=l=>{try{c(t.throw(l))}catch(f){o(f)}},c=l=>l.done?i(l.value):Promise.resolve(l.value).then(n,s);c((t=t.apply(r,e)).next())});function uo(r){return $c(this,arguments,function*(e,t={}){const i=new Date,o=Rs(Rs({},Sa),t);let n;try{n=typeof e=="string"?new V.X509Certificate(e):e}catch(f){return{isValid:!1,status:"error",method:"none",reason:`Failed to parse certificate: ${f instanceof Error?f.message:String(f)}`,checkedAt:i}}let s=null,c=null;if(o.ocspEnabled&&(s=yield Ic(n,null,{timeout:o.ocspTimeout,certificateChain:o.certificateChain,proxyUrl:t.proxyUrl}),s.status==="good"||s.status==="revoked"))return s;if(o.crlEnabled&&(c=yield Dc(n,{timeout:o.crlTimeout,proxyUrl:t.proxyUrl}),c.status==="good"||c.status==="revoked"))return c;const l=[];return s!=null&&s.reason&&l.push(`OCSP: ${s.reason}`),c!=null&&c.reason&&l.push(`CRL: ${c.reason}`),{isValid:!1,status:"unknown",method:"none",reason:l.length>0?l.join("; "):"No revocation checking method available",checkedAt:i}})}class at{constructor(e={}){this.issuer=new Z,this.serialNumber=new ArrayBuffer(0),Object.assign(this,e)}}a([u({type:Z})],at.prototype,"issuer",void 0),a([u({type:h.Integer,converter:re})],at.prototype,"serialNumber",void 0);let ct=class{constructor(e={}){Object.assign(this,e)}};a([u({type:Ot,context:0,implicit:!0})],ct.prototype,"subjectKeyIdentifier",void 0),a([u({type:at})],ct.prototype,"issuerAndSerialNumber",void 0),ct=a([A({type:v.Choice})],ct);var Ee;(function(r){r[r.v0=0]="v0",r[r.v1=1]="v1",r[r.v2=2]="v2",r[r.v3=3]="v3",r[r.v4=4]="v4",r[r.v5=5]="v5"})(Ee||(Ee={}));let jt=class extends k{};jt=a([A({type:v.Sequence})],jt);let Tr=class extends k{};Tr=a([A({type:v.Sequence})],Tr);let we=class extends k{};we=a([A({type:v.Sequence})],we);let Vr=class extends k{};Vr=a([A({type:v.Sequence})],Vr);let Ls=class extends k{};Ls=a([A({type:v.Sequence})],Ls);let fo=class extends k{};fo=a([A({type:v.Sequence})],fo);class Ut{constructor(e={}){this.attrType="",this.attrValues=[],Object.assign(this,e)}}a([u({type:h.ObjectIdentifier})],Ut.prototype,"attrType",void 0),a([u({type:h.Any,repeated:"set"})],Ut.prototype,"attrValues",void 0);var ho;class Ie{constructor(e={}){this.version=Ee.v0,this.sid=new ct,this.digestAlgorithm=new jt,this.signatureAlgorithm=new Tr,this.signature=new C,Object.assign(this,e)}}a([u({type:h.Integer})],Ie.prototype,"version",void 0),a([u({type:ct})],Ie.prototype,"sid",void 0),a([u({type:jt})],Ie.prototype,"digestAlgorithm",void 0),a([u({type:Ut,repeated:"set",context:0,implicit:!0,optional:!0,raw:!0})],Ie.prototype,"signedAttrs",void 0),a([u({type:Tr})],Ie.prototype,"signatureAlgorithm",void 0),a([u({type:C})],Ie.prototype,"signature",void 0),a([u({type:Ut,repeated:"set",context:1,implicit:!0,optional:!0})],Ie.prototype,"unsignedAttrs",void 0);let jr=ho=class extends j{constructor(e){super(e),Object.setPrototypeOf(this,ho.prototype)}};jr=ho=a([A({type:v.Set,itemType:Ie})],jr);let Hs=class extends Ie{};Hs=a([A({type:v.Sequence})],Hs);let $s=class extends z{};$s=a([A({type:v.Choice})],$s);class po{constructor(e={}){this.acIssuer=new E,this.acSerial=0,this.attrs=[],Object.assign(this,e)}}a([u({type:E})],po.prototype,"acIssuer",void 0),a([u({type:h.Integer})],po.prototype,"acSerial",void 0),a([u({type:It,repeated:"sequence"})],po.prototype,"attrs",void 0);var yo;let Ur=yo=class extends j{constructor(e){super(e),Object.setPrototypeOf(this,yo.prototype)}};Ur=yo=a([A({type:v.Sequence,itemType:h.ObjectIdentifier})],Ur);class Dr{constructor(e={}){this.permitUnSpecified=!0,Object.assign(this,e)}}a([u({type:h.Integer,optional:!0})],Dr.prototype,"pathLenConstraint",void 0),a([u({type:Ur,implicit:!0,context:0,optional:!0})],Dr.prototype,"permittedAttrs",void 0),a([u({type:Ur,implicit:!0,context:1,optional:!0})],Dr.prototype,"excludedAttrs",void 0),a([u({type:h.Boolean,defaultValue:!0})],Dr.prototype,"permitUnSpecified",void 0);class Fe{constructor(e={}){this.issuer=new ue,this.serial=new ArrayBuffer(0),this.issuerUID=new ArrayBuffer(0),Object.assign(this,e)}}a([u({type:ue})],Fe.prototype,"issuer",void 0),a([u({type:h.Integer,converter:re})],Fe.prototype,"serial",void 0),a([u({type:h.BitString,optional:!0})],Fe.prototype,"issuerUID",void 0);var go;(function(r){r[r.publicKey=0]="publicKey",r[r.publicKeyCert=1]="publicKeyCert",r[r.otherObjectTypes=2]="otherObjectTypes"})(go||(go={}));class Ge{constructor(e={}){this.digestedObjectType=go.publicKey,this.digestAlgorithm=new k,this.objectDigest=new ArrayBuffer(0),Object.assign(this,e)}}a([u({type:h.Enumerated})],Ge.prototype,"digestedObjectType",void 0),a([u({type:h.ObjectIdentifier,optional:!0})],Ge.prototype,"otherObjectTypeID",void 0),a([u({type:k})],Ge.prototype,"digestAlgorithm",void 0),a([u({type:h.BitString})],Ge.prototype,"objectDigest",void 0);class Rr{constructor(e={}){Object.assign(this,e)}}a([u({type:ue,optional:!0})],Rr.prototype,"issuerName",void 0),a([u({type:Fe,context:0,implicit:!0,optional:!0})],Rr.prototype,"baseCertificateID",void 0),a([u({type:Ge,context:1,implicit:!0,optional:!0})],Rr.prototype,"objectDigestInfo",void 0);let lt=class{constructor(e={}){Object.assign(this,e)}};a([u({type:E,repeated:"sequence"})],lt.prototype,"v1Form",void 0),a([u({type:Rr,context:0,implicit:!0})],lt.prototype,"v2Form",void 0),lt=a([A({type:v.Choice})],lt);class Lr{constructor(e={}){this.notBeforeTime=new Date,this.notAfterTime=new Date,Object.assign(this,e)}}a([u({type:h.GeneralizedTime})],Lr.prototype,"notBeforeTime",void 0),a([u({type:h.GeneralizedTime})],Lr.prototype,"notAfterTime",void 0);class Dt{constructor(e={}){Object.assign(this,e)}}a([u({type:Fe,implicit:!0,context:0,optional:!0})],Dt.prototype,"baseCertificateID",void 0),a([u({type:ue,implicit:!0,context:1,optional:!0})],Dt.prototype,"entityName",void 0),a([u({type:Ge,implicit:!0,context:2,optional:!0})],Dt.prototype,"objectDigestInfo",void 0);var vo;(function(r){r[r.v2=1]="v2"})(vo||(vo={}));class he{constructor(e={}){this.version=vo.v2,this.holder=new Dt,this.issuer=new lt,this.signature=new k,this.serialNumber=new ArrayBuffer(0),this.attrCertValidityPeriod=new Lr,this.attributes=[],Object.assign(this,e)}}a([u({type:h.Integer})],he.prototype,"version",void 0),a([u({type:Dt})],he.prototype,"holder",void 0),a([u({type:lt})],he.prototype,"issuer",void 0),a([u({type:k})],he.prototype,"signature",void 0),a([u({type:h.Integer,converter:re})],he.prototype,"serialNumber",void 0),a([u({type:Lr})],he.prototype,"attrCertValidityPeriod",void 0),a([u({type:It,repeated:"sequence"})],he.prototype,"attributes",void 0),a([u({type:h.BitString,optional:!0})],he.prototype,"issuerUniqueID",void 0),a([u({type:rt,optional:!0})],he.prototype,"extensions",void 0);class Hr{constructor(e={}){this.acinfo=new he,this.signatureAlgorithm=new k,this.signatureValue=new ArrayBuffer(0),Object.assign(this,e)}}a([u({type:he})],Hr.prototype,"acinfo",void 0),a([u({type:k})],Hr.prototype,"signatureAlgorithm",void 0),a([u({type:h.BitString})],Hr.prototype,"signatureValue",void 0);var $r;(function(r){r[r.unmarked=1]="unmarked",r[r.unclassified=2]="unclassified",r[r.restricted=4]="restricted",r[r.confidential=8]="confidential",r[r.secret=16]="secret",r[r.topSecret=32]="topSecret"})($r||($r={}));class mo extends pr{}class wo{constructor(e={}){this.type="",this.value=new ArrayBuffer(0),Object.assign(this,e)}}a([u({type:h.ObjectIdentifier,implicit:!0,context:0})],wo.prototype,"type",void 0),a([u({type:h.Any,implicit:!0,context:1})],wo.prototype,"value",void 0);class bo{constructor(e={}){this.policyId="",this.classList=new mo($r.unclassified),Object.assign(this,e)}}a([u({type:h.ObjectIdentifier})],bo.prototype,"policyId",void 0),a([u({type:mo,defaultValue:new mo($r.unclassified)})],bo.prototype,"classList",void 0),a([u({type:wo,repeated:"set"})],bo.prototype,"securityCategories",void 0);class Mr{constructor(e={}){Object.assign(this,e)}}a([u({type:C})],Mr.prototype,"cotets",void 0),a([u({type:h.ObjectIdentifier})],Mr.prototype,"oid",void 0),a([u({type:h.Utf8String})],Mr.prototype,"string",void 0);class Ms{constructor(e={}){this.values=[],Object.assign(this,e)}}a([u({type:ue,implicit:!0,context:0,optional:!0})],Ms.prototype,"policyAuthority",void 0),a([u({type:Mr,repeated:"sequence"})],Ms.prototype,"values",void 0);var Ao;class Pr{constructor(e={}){this.targetCertificate=new Fe,Object.assign(this,e)}}a([u({type:Fe})],Pr.prototype,"targetCertificate",void 0),a([u({type:E,optional:!0})],Pr.prototype,"targetName",void 0),a([u({type:Ge,optional:!0})],Pr.prototype,"certDigestInfo",void 0);let ut=class{constructor(e={}){Object.assign(this,e)}};a([u({type:E,context:0,implicit:!0})],ut.prototype,"targetName",void 0),a([u({type:E,context:1,implicit:!0})],ut.prototype,"targetGroup",void 0),a([u({type:Pr,context:2,implicit:!0})],ut.prototype,"targetCert",void 0),ut=a([A({type:v.Choice})],ut);let So=Ao=class extends j{constructor(e){super(e),Object.setPrototypeOf(this,Ao.prototype)}};So=Ao=a([A({type:v.Sequence,itemType:ut})],So);var Bo;let Ps=Bo=class extends j{constructor(e){super(e),Object.setPrototypeOf(this,Bo.prototype)}};Ps=Bo=a([A({type:v.Sequence,itemType:So})],Ps);class _s{constructor(e={}){Object.assign(this,e)}}a([u({type:ue,implicit:!0,context:0,optional:!0})],_s.prototype,"roleAuthority",void 0),a([u({type:E,implicit:!0,context:1})],_s.prototype,"roleName",void 0);class ko{constructor(e={}){this.service=new E,this.ident=new E,Object.assign(this,e)}}a([u({type:E})],ko.prototype,"service",void 0),a([u({type:E})],ko.prototype,"ident",void 0),a([u({type:C,optional:!0})],ko.prototype,"authInfo",void 0);var xo;class No{constructor(e={}){this.otherCertFormat="",this.otherCert=new ArrayBuffer(0),Object.assign(this,e)}}a([u({type:h.ObjectIdentifier})],No.prototype,"otherCertFormat",void 0),a([u({type:h.Any})],No.prototype,"otherCert",void 0);let ft=class{constructor(e={}){Object.assign(this,e)}};a([u({type:it})],ft.prototype,"certificate",void 0),a([u({type:Hr,context:2,implicit:!0})],ft.prototype,"v2AttrCert",void 0),a([u({type:No,context:3,implicit:!0})],ft.prototype,"other",void 0),ft=a([A({type:v.Choice})],ft);let _r=xo=class extends j{constructor(e){super(e),Object.setPrototypeOf(this,xo.prototype)}};_r=xo=a([A({type:v.Set,itemType:ft})],_r);class qr{constructor(e={}){this.contentType="",this.content=new ArrayBuffer(0),Object.assign(this,e)}}a([u({type:h.ObjectIdentifier})],qr.prototype,"contentType",void 0),a([u({type:h.Any,context:0})],qr.prototype,"content",void 0);let Rt=class{constructor(e={}){Object.assign(this,e)}};a([u({type:C})],Rt.prototype,"single",void 0),a([u({type:h.Any})],Rt.prototype,"any",void 0),Rt=a([A({type:v.Choice})],Rt);class Fr{constructor(e={}){this.eContentType="",Object.assign(this,e)}}a([u({type:h.ObjectIdentifier})],Fr.prototype,"eContentType",void 0),a([u({type:Rt,context:0,optional:!0})],Fr.prototype,"eContent",void 0);let Lt=class{constructor(e={}){Object.assign(this,e)}};a([u({type:C,context:0,implicit:!0,optional:!0})],Lt.prototype,"value",void 0),a([u({type:C,converter:Ka,context:0,implicit:!0,optional:!0,repeated:"sequence"})],Lt.prototype,"constructedValue",void 0),Lt=a([A({type:v.Choice})],Lt);class Ht{constructor(e={}){this.contentType="",this.contentEncryptionAlgorithm=new Vr,Object.assign(this,e)}}a([u({type:h.ObjectIdentifier})],Ht.prototype,"contentType",void 0),a([u({type:Vr})],Ht.prototype,"contentEncryptionAlgorithm",void 0),a([u({type:Lt,optional:!0})],Ht.prototype,"encryptedContent",void 0);class Gr{constructor(e={}){this.keyAttrId="",Object.assign(this,e)}}a([u({type:h.ObjectIdentifier})],Gr.prototype,"keyAttrId",void 0),a([u({type:h.Any,optional:!0})],Gr.prototype,"keyAttr",void 0);var Co;class zr{constructor(e={}){this.subjectKeyIdentifier=new Ot,Object.assign(this,e)}}a([u({type:Ot})],zr.prototype,"subjectKeyIdentifier",void 0),a([u({type:h.GeneralizedTime,optional:!0})],zr.prototype,"date",void 0),a([u({type:Gr,optional:!0})],zr.prototype,"other",void 0);let ht=class{constructor(e={}){Object.assign(this,e)}};a([u({type:zr,context:0,implicit:!0,optional:!0})],ht.prototype,"rKeyId",void 0),a([u({type:at,optional:!0})],ht.prototype,"issuerAndSerialNumber",void 0),ht=a([A({type:v.Choice})],ht);class Eo{constructor(e={}){this.rid=new ht,this.encryptedKey=new C,Object.assign(this,e)}}a([u({type:ht})],Eo.prototype,"rid",void 0),a([u({type:C})],Eo.prototype,"encryptedKey",void 0);let Xr=Co=class extends j{constructor(e){super(e),Object.setPrototypeOf(this,Co.prototype)}};Xr=Co=a([A({type:v.Sequence,itemType:Eo})],Xr);class Io{constructor(e={}){this.algorithm=new k,this.publicKey=new ArrayBuffer(0),Object.assign(this,e)}}a([u({type:k})],Io.prototype,"algorithm",void 0),a([u({type:h.BitString})],Io.prototype,"publicKey",void 0);let ze=class{constructor(e={}){Object.assign(this,e)}};a([u({type:Ot,context:0,implicit:!0,optional:!0})],ze.prototype,"subjectKeyIdentifier",void 0),a([u({type:Io,context:1,implicit:!0,optional:!0})],ze.prototype,"originatorKey",void 0),a([u({type:at,optional:!0})],ze.prototype,"issuerAndSerialNumber",void 0),ze=a([A({type:v.Choice})],ze);class pt{constructor(e={}){this.version=Ee.v3,this.originator=new ze,this.keyEncryptionAlgorithm=new we,this.recipientEncryptedKeys=new Xr,Object.assign(this,e)}}a([u({type:h.Integer})],pt.prototype,"version",void 0),a([u({type:ze,context:0})],pt.prototype,"originator",void 0),a([u({type:C,context:1,optional:!0})],pt.prototype,"ukm",void 0),a([u({type:we})],pt.prototype,"keyEncryptionAlgorithm",void 0),a([u({type:Xr})],pt.prototype,"recipientEncryptedKeys",void 0);let dt=class{constructor(e={}){Object.assign(this,e)}};a([u({type:Ot,context:0,implicit:!0})],dt.prototype,"subjectKeyIdentifier",void 0),a([u({type:at})],dt.prototype,"issuerAndSerialNumber",void 0),dt=a([A({type:v.Choice})],dt);class $t{constructor(e={}){this.version=Ee.v0,this.rid=new dt,this.keyEncryptionAlgorithm=new we,this.encryptedKey=new C,Object.assign(this,e)}}a([u({type:h.Integer})],$t.prototype,"version",void 0),a([u({type:dt})],$t.prototype,"rid",void 0),a([u({type:we})],$t.prototype,"keyEncryptionAlgorithm",void 0),a([u({type:C})],$t.prototype,"encryptedKey",void 0);class Mt{constructor(e={}){this.keyIdentifier=new C,Object.assign(this,e)}}a([u({type:C})],Mt.prototype,"keyIdentifier",void 0),a([u({type:h.GeneralizedTime,optional:!0})],Mt.prototype,"date",void 0),a([u({type:Gr,optional:!0})],Mt.prototype,"other",void 0);class Pt{constructor(e={}){this.version=Ee.v4,this.kekid=new Mt,this.keyEncryptionAlgorithm=new we,this.encryptedKey=new C,Object.assign(this,e)}}a([u({type:h.Integer})],Pt.prototype,"version",void 0),a([u({type:Mt})],Pt.prototype,"kekid",void 0),a([u({type:we})],Pt.prototype,"keyEncryptionAlgorithm",void 0),a([u({type:C})],Pt.prototype,"encryptedKey",void 0);class _t{constructor(e={}){this.version=Ee.v0,this.keyEncryptionAlgorithm=new we,this.encryptedKey=new C,Object.assign(this,e)}}a([u({type:h.Integer})],_t.prototype,"version",void 0),a([u({type:fo,context:0,optional:!0})],_t.prototype,"keyDerivationAlgorithm",void 0),a([u({type:we})],_t.prototype,"keyEncryptionAlgorithm",void 0),a([u({type:C})],_t.prototype,"encryptedKey",void 0);class Oo{constructor(e={}){this.oriType="",this.oriValue=new ArrayBuffer(0),Object.assign(this,e)}}a([u({type:h.ObjectIdentifier})],Oo.prototype,"oriType",void 0),a([u({type:h.Any})],Oo.prototype,"oriValue",void 0);let Ve=class{constructor(e={}){Object.assign(this,e)}};a([u({type:$t,optional:!0})],Ve.prototype,"ktri",void 0),a([u({type:pt,context:1,implicit:!0,optional:!0})],Ve.prototype,"kari",void 0),a([u({type:Pt,context:2,implicit:!0,optional:!0})],Ve.prototype,"kekri",void 0),a([u({type:_t,context:3,implicit:!0,optional:!0})],Ve.prototype,"pwri",void 0),a([u({type:Oo,context:4,implicit:!0,optional:!0})],Ve.prototype,"ori",void 0),Ve=a([A({type:v.Choice})],Ve);var To;let Wr=To=class extends j{constructor(e){super(e),Object.setPrototypeOf(this,To.prototype)}};Wr=To=a([A({type:v.Set,itemType:Ve})],Wr);var Vo;class Jr{constructor(e={}){this.otherRevInfoFormat="",this.otherRevInfo=new ArrayBuffer(0),Object.assign(this,e)}}a([u({type:h.ObjectIdentifier})],Jr.prototype,"otherRevInfoFormat",void 0),a([u({type:h.Any})],Jr.prototype,"otherRevInfo",void 0);let Kr=class{constructor(e={}){this.other=new Jr,Object.assign(this,e)}};a([u({type:Jr,context:1,implicit:!0})],Kr.prototype,"other",void 0),Kr=a([A({type:v.Choice})],Kr);let Yr=Vo=class extends j{constructor(e){super(e),Object.setPrototypeOf(this,Vo.prototype)}};Yr=Vo=a([A({type:v.Set,itemType:Kr})],Yr);class jo{constructor(e={}){Object.assign(this,e)}}a([u({type:_r,context:0,implicit:!0,optional:!0})],jo.prototype,"certs",void 0),a([u({type:Yr,context:1,implicit:!0,optional:!0})],jo.prototype,"crls",void 0);var Uo;let Do=Uo=class extends j{constructor(e){super(e),Object.setPrototypeOf(this,Uo.prototype)}};Do=Uo=a([A({type:v.Set,itemType:Ut})],Do);class qt{constructor(e={}){this.version=Ee.v0,this.recipientInfos=new Wr,this.encryptedContentInfo=new Ht,Object.assign(this,e)}}a([u({type:h.Integer})],qt.prototype,"version",void 0),a([u({type:jo,context:0,implicit:!0,optional:!0})],qt.prototype,"originatorInfo",void 0),a([u({type:Wr})],qt.prototype,"recipientInfos",void 0),a([u({type:Ht})],qt.prototype,"encryptedContentInfo",void 0),a([u({type:Do,context:1,implicit:!0,optional:!0})],qt.prototype,"unprotectedAttrs",void 0);var Ro;let Zr=Ro=class extends j{constructor(e){super(e),Object.setPrototypeOf(this,Ro.prototype)}};Zr=Ro=a([A({type:v.Set,itemType:jt})],Zr);class Xe{constructor(e={}){this.version=Ee.v0,this.digestAlgorithms=new Zr,this.encapContentInfo=new Fr,this.signerInfos=new jr,Object.assign(this,e)}}a([u({type:h.Integer})],Xe.prototype,"version",void 0),a([u({type:Zr})],Xe.prototype,"digestAlgorithms",void 0),a([u({type:Fr})],Xe.prototype,"encapContentInfo",void 0),a([u({type:_r,context:0,implicit:!0,optional:!0})],Xe.prototype,"certificates",void 0),a([u({type:Yr,context:1,implicit:!0,optional:!0})],Xe.prototype,"crls",void 0),a([u({type:jr})],Xe.prototype,"signerInfos",void 0);class Qr{constructor(e={}){this.seconds=0,Object.assign(this,e)}}a([u({type:h.Integer,optional:!0})],Qr.prototype,"seconds",void 0),a([u({type:h.Integer,context:0,implicit:!0,optional:!0})],Qr.prototype,"millis",void 0),a([u({type:h.Integer,context:1,implicit:!0,optional:!0})],Qr.prototype,"micros",void 0);class yt{constructor(e={}){this.hashAlgorithm=new k,this.hashedMessage=new C,Object.assign(this,e)}}a([u({type:k})],yt.prototype,"hashAlgorithm",void 0),a([u({type:C})],yt.prototype,"hashedMessage",void 0);var pe;(function(r){r[r.badAlg=1]="badAlg",r[r.badRequest=2]="badRequest",r[r.badDataFormat=16]="badDataFormat",r[r.timeNotAvailable=8192]="timeNotAvailable",r[r.unacceptedPolicy=16384]="unacceptedPolicy",r[r.unacceptedExtension=32768]="unacceptedExtension",r[r.addInfoNotAvailable=65536]="addInfoNotAvailable",r[r.systemFailure=16777216]="systemFailure"})(pe||(pe={}));class Mc extends pr{toJSON(){const e=this.toNumber(),t=[];return e&pe.addInfoNotAvailable&&t.push("addInfoNotAvailable"),e&pe.badAlg&&t.push("badAlg"),e&pe.badDataFormat&&t.push("badDataFormat"),e&pe.badRequest&&t.push("badRequest"),e&pe.systemFailure&&t.push("systemFailure"),e&pe.systemFailure&&t.push("systemFailure"),e&pe.timeNotAvailable&&t.push("timeNotAvailable"),e&pe.unacceptedExtension&&t.push("unacceptedExtension"),e&pe.unacceptedPolicy&&t.push("unacceptedPolicy"),t}toString(){return`[${this.toJSON().join(", ")}]`}}var Lo;(function(r){r[r.granted=0]="granted",r[r.grantedWithMods=1]="grantedWithMods",r[r.rejection=2]="rejection",r[r.waiting=3]="waiting",r[r.revocationWarning=4]="revocationWarning",r[r.revocationNotification=5]="revocationNotification"})(Lo||(Lo={}));var Ho;let $o=Ho=class extends j{constructor(e){super(e),Object.setPrototypeOf(this,Ho.prototype)}};$o=Ho=a([A({type:v.Sequence,itemType:h.Utf8String})],$o);class Ft{constructor(e={}){this.status=Lo.granted,Object.assign(this,e)}}a([u({type:h.Integer})],Ft.prototype,"status",void 0),a([u({type:$o,optional:!0})],Ft.prototype,"statusString",void 0),a([u({type:Mc,optional:!0})],Ft.prototype,"failInfo",void 0);var Mo;(function(r){r[r.v1=1]="v1"})(Mo||(Mo={}));class gt{constructor(e={}){this.version=Mo.v1,this.messageImprint=new yt,this.certReq=!1,Object.assign(this,e)}}a([u({type:h.Integer})],gt.prototype,"version",void 0),a([u({type:yt})],gt.prototype,"messageImprint",void 0),a([u({type:h.ObjectIdentifier,optional:!0})],gt.prototype,"reqPolicy",void 0),a([u({type:h.Integer,converter:re,optional:!0})],gt.prototype,"nonce",void 0),a([u({type:h.Boolean,defaultValue:!1})],gt.prototype,"certReq",void 0),a([u({type:rt,optional:!0,context:0,implicit:!0})],gt.prototype,"extensions",void 0);let Po=class extends qr{};Po=a([A({type:v.Sequence})],Po);class qs{constructor(e={}){this.status=new Ft,Object.assign(this,e)}}a([u({type:Ft})],qs.prototype,"status",void 0),a([u({type:Po,optional:!0})],qs.prototype,"timeStampToken",void 0);var _o;(function(r){r[r.v1=1]="v1"})(_o||(_o={}));class de{constructor(e={}){this.version=_o.v1,this.policy="",this.messageImprint=new yt,this.serialNumber=new ArrayBuffer(0),this.genTime=new Date,this.ordering=!1,Object.assign(this,e)}}a([u({type:h.Integer})],de.prototype,"version",void 0),a([u({type:h.ObjectIdentifier})],de.prototype,"policy",void 0),a([u({type:yt})],de.prototype,"messageImprint",void 0),a([u({type:h.Integer,converter:re})],de.prototype,"serialNumber",void 0),a([u({type:h.GeneralizedTime})],de.prototype,"genTime",void 0),a([u({type:Qr,optional:!0})],de.prototype,"accuracy",void 0),a([u({type:h.Boolean,defaultValue:!1})],de.prototype,"ordering",void 0),a([u({type:h.Integer,converter:re,optional:!0})],de.prototype,"nonce",void 0),a([u({type:E,context:0,optional:!0})],de.prototype,"tsa",void 0),a([u({type:rt,context:1,implicit:!0,optional:!0})],de.prototype,"extensions",void 0);var qo=(r,e,t)=>new Promise((i,o)=>{var n=l=>{try{c(t.next(l))}catch(f){o(f)}},s=l=>{try{c(t.throw(l))}catch(f){o(f)}},c=l=>l.done?i(l.value):Promise.resolve(l.value).then(n,s);c((t=t.apply(r,e)).next())});const Pc="1.2.840.113549.1.7.2",_c="1.2.840.113549.1.9.16.1.4";function qc(r){return{"1.3.14.3.2.26":"SHA-1","2.16.840.1.101.3.4.2.1":"SHA-256","2.16.840.1.101.3.4.2.2":"SHA-384","2.16.840.1.101.3.4.2.3":"SHA-512"}[r]||r}function Fo(r){try{const e=lo(r),t=ce.parse(e,qr);if(t.contentType!==Pc)return console.warn("Timestamp is not SignedData"),null;const i=ce.parse(t.content,Xe);if(i.encapContentInfo.eContentType!==_c)return console.warn("SignedData does not contain TSTInfo"),null;if(!i.encapContentInfo.eContent)return console.warn("No eContent in SignedData"),null;const o=i.encapContentInfo.eContent;let n;o.single?n=o.single.buffer:o.any?n=o.any:n=ce.serialize(o);const s=ce.parse(n,de);let c;if(i.certificates&&i.certificates.length>0){const p=i.certificates[0];"certificate"in p&&p.certificate&&(c=Ts(ce.serialize(p.certificate)))}let l;s.tsa&&(s.tsa.directoryName?l=s.tsa.directoryName.toString():s.tsa.uniformResourceIdentifier&&(l=s.tsa.uniformResourceIdentifier));let f;return s.accuracy&&(f=(s.accuracy.seconds||0)+(s.accuracy.millis||0)/1e3+(s.accuracy.micros||0)/1e6),{genTime:s.genTime,policy:s.policy,serialNumber:Ir(s.serialNumber),hashAlgorithm:qc(s.messageImprint.hashAlgorithm.algorithm),messageImprint:Ir(s.messageImprint.hashedMessage.buffer),tsaName:l,tsaCertificate:c,accuracy:f}}catch(e){return console.error("Failed to parse timestamp:",e instanceof Error?e.message:String(e)),null}}function Fs(r,e){return qo(this,null,function*(){const t={"SHA-1":"SHA-1","SHA-256":"SHA-256","SHA-384":"SHA-384","SHA-512":"SHA-512"}[e];if(!t)throw new Error(`Unsupported hash algorithm: ${e}`);if(typeof crypto!="undefined"&&crypto.subtle)return crypto.subtle.digest(t,r);const i=require("crypto").createHash(e.toLowerCase().replace("-",""));return i.update(Buffer.from(r)),i.digest().buffer})}function Fc(r,e){return qo(this,null,function*(){try{const t=r.messageImprint.toLowerCase(),i=lo(e),o=yield Fs(i,r.hashAlgorithm);if(Ir(o).toLowerCase()===t)return!0;const n=new TextEncoder().encode(e),s=yield Fs(n.buffer,r.hashAlgorithm);return Ir(s).toLowerCase()===t}catch(t){return console.error("Failed to verify timestamp coverage:",t instanceof Error?t.message:String(t)),!1}})}function Gs(r){return qo(this,arguments,function*(e,t={}){const i=Fo(e);if(!i)return{isValid:!1,reason:"Failed to parse timestamp token"};let o,n;t.signatureValue&&(o=yield Fc(i,t.signatureValue),o||(n="Could not verify timestamp covers signature (implementation-specific hashing)"));let s;if(t.verifyTsaCertificate&&i.tsaCertificate)try{const c=new V.X509Certificate(i.tsaCertificate);if(i.genTime<c.notBefore||i.genTime>c.notAfter)return{isValid:!1,info:i,coversSignature:o,reason:`TSA certificate was not valid at timestamp time (${i.genTime.toISOString()})`};if(t.checkTsaRevocation!==!1)try{if(s=yield uo(c,t.revocationOptions),s.status==="revoked")return{isValid:!1,info:i,coversSignature:o,tsaRevocation:s,reason:`TSA certificate has been revoked: ${s.reason||"No reason provided"}`}}catch(l){s={isValid:!1,status:"error",method:"none",reason:`TSA revocation check failed: ${l instanceof Error?l.message:String(l)}`,checkedAt:new Date}}}catch(c){return{isValid:!1,info:i,coversSignature:o,reason:`Failed to verify TSA certificate: ${c instanceof Error?c.message:String(c)}`}}return{isValid:!0,info:i,coversSignature:o,tsaRevocation:s,reason:n}})}function Gc(r){const e=Fo(r);return(e==null?void 0:e.genTime)||null}var zc=Object.defineProperty,zs=Object.getOwnPropertySymbols,Xc=Object.prototype.hasOwnProperty,Wc=Object.prototype.propertyIsEnumerable,Xs=(r,e,t)=>e in r?zc(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,Ws=(r,e)=>{for(var t in e||(e={}))Xc.call(e,t)&&Xs(r,t,e[t]);if(zs)for(var t of zs(e))Wc.call(e,t)&&Xs(r,t,e[t]);return r},We=(r,e,t)=>new Promise((i,o)=>{var n=l=>{try{c(t.next(l))}catch(f){o(f)}},s=l=>{try{c(t.throw(l))}catch(f){o(f)}},c=l=>l.done?i(l.value):Promise.resolve(l.value).then(n,s);c((t=t.apply(r,e)).next())});function ei(){return typeof window!="undefined"&&typeof window.crypto!="undefined"&&typeof window.crypto.subtle!="undefined"}function Js(r,e){return We(this,null,function*(){const t=e.replace(/-/g,"").toLowerCase();let i;if(t.includes("sha256"))i="sha256";else if(t.includes("sha1"))i="sha1";else if(t.includes("sha384"))i="sha384";else if(t.includes("sha512"))i="sha512";else throw new Error(`Unsupported digest algorithm: ${e}`);return ei()?Jc(r,i):Kc(r,i)})}function Jc(r,e){return We(this,null,function*(){const t={sha1:"SHA-1",sha256:"SHA-256",sha384:"SHA-384",sha512:"SHA-512"}[e];if(!t)throw new Error(`Unsupported browser digest algorithm: ${e}`);const i=yield window.crypto.subtle.digest(t,r),o=Array.from(new Uint8Array(i));return btoa(String.fromCharCode.apply(null,o))})}function Kc(r,e){return new Promise((t,i)=>{try{const o=require("crypto").createHash(e);o.update(Buffer.from(r)),t(o.digest("base64"))}catch(o){i(new Error(`Node digest computation failed: ${o instanceof Error?o.message:String(o)}`))}})}function Yc(r){const e=r.toLowerCase();return e.includes("sha512")?"SHA-512":e.includes("sha384")?"SHA-384":e.includes("sha256")?"SHA-256":e.includes("sha1")?"SHA-1":"SHA-256"}function Ks(r,e){return We(this,null,function*(){const t={};let i=!0,o="SHA-256";r.algorithm&&(r.algorithm.includes("sha1")?o="SHA-1":r.algorithm.includes("sha384")?o="SHA-384":r.algorithm.includes("sha512")&&(o="SHA-512"));const n=Object.entries(r.signedChecksums).map(s=>We(this,[s],function*([c,l]){var f;const p=(f=r.digestAlgorithms)!=null&&f[c]?Yc(r.digestAlgorithms[c]):o,d=e.get(c);if(d){const w=yield Js(d,p),y=l===w;t[c]={expected:l,actual:w,matches:y,fileFound:!0},y||(i=!1)}else{const w=c.includes("/")?c.split("/").pop():c;let y=!1;if(w){for(const[g,B]of e.entries())if(g.endsWith(w)){const m=yield Js(B,p),S=l===m;t[c]={expected:l,actual:m,matches:S,fileFound:!0},S||(i=!1),y=!0;break}}y||(t[c]={expected:l,actual:"",matches:!1,fileFound:!1},i=!1)}}));return yield Promise.all(n),{isValid:i,details:t}})}function Zc(r){return We(this,arguments,function*(e,t=new Date){try{const i=new V.X509Certificate(e),o=la(i,t),n=yield Qo(e);return{isValid:o.isValid,reason:o.reason,info:n}}catch(i){return{isValid:!1,reason:`Certificate parsing error: ${i instanceof Error?i.message:String(i)}`}}})}function Ys(){return ei()?window.crypto.subtle:crypto.subtle}function Qc(r,e,t,i,o){return We(this,null,function*(){try{const n=Jo().parseFromString(r,"application/xml"),s=K(n,"ds:SignedInfo");if(!s)return{isValid:!1,reason:"SignedInfo element not found in provided XML"};const c=o||Je.default,l=P.canonicalize(s,c),f=e.replace(/\s+/g,"");let p;try{p=bc(f)}catch(y){return{isValid:!1,reason:`Failed to decode signature value: ${y instanceof Error?y.message:String(y)}`}}let d;try{const y=Ys();ei()&&i.name==="RSASSA-PKCS1-v1_5"&&(t=Aa(t)),d=yield y.importKey("spki",t,i,!1,["verify"])}catch(y){const g=y instanceof Error?y:new Error(String(y));let B="Unknown reason",m="KEY_IMPORT_ERROR";if(g.name==="DataError"?(B="Key data format is invalid or incompatible",m="INVALID_KEY_FORMAT"):g.name==="NotSupportedError"?(B="Algorithm or parameters not supported",m="UNSUPPORTED_ALGORITHM"):g.message.includes("namedCurve")?(B="Missing or invalid namedCurve parameter",m="INVALID_CURVE"):g.message.includes("hash")&&(B="Incompatible or unsupported hash algorithm",m="INVALID_HASH"),i.name==="ECDSA"){const S=t.byteLength;B+=` (Key length: ${S})`}return{isValid:!1,reason:`Failed to import public key: ${B}`,errorDetails:{category:m,originalMessage:g.message,algorithm:Ws({},i),environment:ei()?"browser":"node",keyLength:t.byteLength}}}const w=new TextEncoder().encode(l);try{const y=yield Ys().verify(i,d,p,w);return{isValid:y,reason:y?void 0:"Signature verification failed"}}catch(y){return{isValid:!1,reason:`Signature verification error: ${y instanceof Error?y.message:String(y)}`}}}catch(n){return{isValid:!1,reason:`SignedInfo verification error: ${n instanceof Error?n.message:String(n)}`}}})}function el(r,e){return We(this,arguments,function*(t,i,o={}){var n;const s=[];let c,l=o.verifyTime||t.signingTime;t.signatureTimestamp&&o.verifyTimestamps!==!1&&(c=yield Gs(t.signatureTimestamp,{signatureValue:t.signatureValue,verifyTsaCertificate:!0,revocationOptions:o.revocationOptions}),c.isValid&&c.info?l=c.info.genTime:c.isValid||s.push(`Timestamp verification failed: ${c.reason||"Unknown reason"}`));const f=yield Zc(t.certificatePEM,l);if(!f.isValid){const y=`Certificate validation error: ${f.reason||"Unknown reason"}`;s.push(y)}if(o.checkRevocation!==!1&&f.isValid)try{const y=yield uo(t.certificatePEM,Ws({certificateChain:t.certificateChain},o.revocationOptions));if(f.revocation=y,y.status==="revoked"){const g=y.revokedAt;if(g&&l<g)f.revocation.isValid=!0,f.revocation.reason=`Certificate was revoked on ${g.toISOString()}, but signature was made on ${l.toISOString()} (before revocation)`;else{f.isValid=!1;const B=g?` on ${g.toISOString()}`:"";f.reason=`Certificate was revoked${B}`,s.push(`Certificate revoked${B}`)}}}catch(y){f.revocation={isValid:!1,status:"error",method:"none",reason:`Revocation check failed: ${y instanceof Error?y.message:String(y)}`,checkedAt:new Date}}const p=o.verifyChecksums!==!1?yield Ks(t,i):{isValid:!0,details:{}};if(!p.isValid){const y=Object.entries(p.details).filter(([g,B])=>!B.matches).map(([g])=>g).join(", ");s.push(`Checksum validation failed for files: ${y}`)}let d={isValid:!0};if(o.verifySignatures!==!1&&t.rawXml&&t.signatureValue&&t.publicKey){const y=t.algorithm||"",g={name:"RSASSA-PKCS1-v1_5",hash:"SHA-256"};if(y.includes("ecdsa")&&t.publicKey.namedCurve&&(g.namedCurve=t.publicKey.namedCurve,g.name="ECDSA"),y.includes("ecdsa-sha256")?g.hash="SHA-256":y.includes("ecdsa-sha384")?g.hash="SHA-384":y.includes("ecdsa-sha512")?g.hash="SHA-512":y.includes("rsa-sha1")?g.hash="SHA-1":y.includes("rsa-pss")?(g.name="RSA-PSS",g.saltLength=32,y.includes("sha384")?(g.hash="SHA-384",g.saltLength=48):y.includes("sha512")?(g.hash="SHA-512",g.saltLength=64):g.hash="SHA-256"):y.includes("rsa-sha384")?g.hash="SHA-384":y.includes("rsa-sha512")&&(g.hash="SHA-512"),d=yield Qc(t.rawXml,t.signatureValue,t.publicKey.rawData,g,t.canonicalizationMethod),!d.isValid){let B=d.reason||"XML signature verification failed";if(d.errorDetails){const m=d.errorDetails;B+=` [Category: ${m.category}, Environment: ${m.environment}`,m.algorithm&&(B+=`, Algorithm: ${m.algorithm.name}`,m.algorithm.namedCurve&&(B+=`, Curve: ${m.algorithm.namedCurve}`)),m.keyLength&&(B+=`, Key length: ${m.keyLength} bytes`),B+="]"}s.push(B)}}else if(o.verifySignatures!==!1){const y=[];t.rawXml||y.push("Signature XML"),t.signatureValue||y.push("SignatureValue"),t.publicKey||y.push("Public Key"),s.push(`Cannot verify XML signature: missing ${y.join(", ")}`),d={isValid:!1,reason:`Missing required components: ${y.join(", ")}`}}const w=!t.signatureTimestamp||o.verifyTimestamps===!1||((n=c==null?void 0:c.isValid)!=null?n:!0);return{isValid:f.isValid&&p.isValid&&d.isValid&&w,certificate:f,checksums:p,signature:o.verifySignatures!==!1?d:void 0,timestamp:c,errors:s.length>0?s:void 0}})}x.CANONICALIZATION_METHODS=Je,x.XMLCanonicalizer=P,x.checkCertificateRevocation=uo,x.formatValidityPeriod=fa,x.getSignerDisplayName=ua,x.getTimestampTime=Gc,x.parseCertificate=Qo,x.parseEdoc=ba,x.parseTimestamp=Fo,x.verifyChecksums=Ks,x.verifySignature=el,x.verifyTimestamp=Gs,Object.defineProperty(x,"__esModule",{value:!0})});
81
+ -----END X509 CRL-----`;return new V.X509Crl(t)}catch(t){return null}}}function Rc(r){return Tc(this,arguments,function*(e,t={}){const{timeout:i=1e4,proxyUrl:n}=t,o=new Date,s=jc(e);if(s.length===0)return{isValid:!1,status:"unknown",method:"crl",reason:"Certificate has no CRL distribution point",checkedAt:o};const c=[];for(const l of s)try{const f=yield wc(l,i,n);if(!f.ok||!f.data){c.push(`${l}: ${f.error||"Failed to fetch"}`);continue}const p=Dc(f.data);if(!p){c.push(`${l}: Failed to parse CRL data`);continue}const d=Uc(p,e.serialNumber);return d.isRevoked?{isValid:!1,status:"revoked",method:"crl",reason:d.reason!==void 0?`Certificate revoked (reason code: ${d.reason})`:"Certificate revoked",revokedAt:d.revokedAt,checkedAt:o}:{isValid:!0,status:"good",method:"crl",checkedAt:o}}catch(f){c.push(`${l}: ${f instanceof Error?f.message:String(f)}`)}return{isValid:!1,status:"error",method:"crl",reason:`All CRL checks failed: ${c.join("; ")}`,checkedAt:o}})}var Lc=Object.defineProperty,Rs=Object.getOwnPropertySymbols,Hc=Object.prototype.hasOwnProperty,$c=Object.prototype.propertyIsEnumerable,Ls=(r,e,t)=>e in r?Lc(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,Hs=(r,e)=>{for(var t in e||(e={}))Hc.call(e,t)&&Ls(r,t,e[t]);if(Rs)for(var t of Rs(e))$c.call(e,t)&&Ls(r,t,e[t]);return r},Mc=(r,e,t)=>new Promise((i,n)=>{var o=l=>{try{c(t.next(l))}catch(f){n(f)}},s=l=>{try{c(t.throw(l))}catch(f){n(f)}},c=l=>l.done?i(l.value):Promise.resolve(l.value).then(o,s);c((t=t.apply(r,e)).next())});function fn(r){return Mc(this,arguments,function*(e,t={}){const i=new Date,n=Hs(Hs({},ka),t);let o;try{o=typeof e=="string"?new V.X509Certificate(e):e}catch(f){return{isValid:!1,status:"error",method:"none",reason:`Failed to parse certificate: ${f instanceof Error?f.message:String(f)}`,checkedAt:i}}let s=null,c=null;if(n.ocspEnabled&&(s=yield Oc(o,null,{timeout:n.ocspTimeout,certificateChain:n.certificateChain,proxyUrl:t.proxyUrl}),s.status==="good"||s.status==="revoked"))return s;if(n.crlEnabled&&(c=yield Rc(o,{timeout:n.crlTimeout,proxyUrl:t.proxyUrl}),c.status==="good"||c.status==="revoked"))return c;const l=[];return s!=null&&s.reason&&l.push(`OCSP: ${s.reason}`),c!=null&&c.reason&&l.push(`CRL: ${c.reason}`),{isValid:!1,status:"unknown",method:"none",reason:l.length>0?l.join("; "):"No revocation checking method available",checkedAt:i}})}class ct{constructor(e={}){this.issuer=new Z,this.serialNumber=new ArrayBuffer(0),Object.assign(this,e)}}a([u({type:Z})],ct.prototype,"issuer",void 0),a([u({type:h.Integer,converter:re})],ct.prototype,"serialNumber",void 0);let lt=class{constructor(e={}){Object.assign(this,e)}};a([u({type:Ot,context:0,implicit:!0})],lt.prototype,"subjectKeyIdentifier",void 0),a([u({type:ct})],lt.prototype,"issuerAndSerialNumber",void 0),lt=a([A({type:v.Choice})],lt);var Ee;(function(r){r[r.v0=0]="v0",r[r.v1=1]="v1",r[r.v2=2]="v2",r[r.v3=3]="v3",r[r.v4=4]="v4",r[r.v5=5]="v5"})(Ee||(Ee={}));let jt=class extends k{};jt=a([A({type:v.Sequence})],jt);let Or=class extends k{};Or=a([A({type:v.Sequence})],Or);let me=class extends k{};me=a([A({type:v.Sequence})],me);let Tr=class extends k{};Tr=a([A({type:v.Sequence})],Tr);let $s=class extends k{};$s=a([A({type:v.Sequence})],$s);let hn=class extends k{};hn=a([A({type:v.Sequence})],hn);class Ut{constructor(e={}){this.attrType="",this.attrValues=[],Object.assign(this,e)}}a([u({type:h.ObjectIdentifier})],Ut.prototype,"attrType",void 0),a([u({type:h.Any,repeated:"set"})],Ut.prototype,"attrValues",void 0);var pn;class Ie{constructor(e={}){this.version=Ee.v0,this.sid=new lt,this.digestAlgorithm=new jt,this.signatureAlgorithm=new Or,this.signature=new C,Object.assign(this,e)}}a([u({type:h.Integer})],Ie.prototype,"version",void 0),a([u({type:lt})],Ie.prototype,"sid",void 0),a([u({type:jt})],Ie.prototype,"digestAlgorithm",void 0),a([u({type:Ut,repeated:"set",context:0,implicit:!0,optional:!0,raw:!0})],Ie.prototype,"signedAttrs",void 0),a([u({type:Or})],Ie.prototype,"signatureAlgorithm",void 0),a([u({type:C})],Ie.prototype,"signature",void 0),a([u({type:Ut,repeated:"set",context:1,implicit:!0,optional:!0})],Ie.prototype,"unsignedAttrs",void 0);let Vr=pn=class extends j{constructor(e){super(e),Object.setPrototypeOf(this,pn.prototype)}};Vr=pn=a([A({type:v.Set,itemType:Ie})],Vr);let Ms=class extends Ie{};Ms=a([A({type:v.Sequence})],Ms);let Ps=class extends z{};Ps=a([A({type:v.Choice})],Ps);class dn{constructor(e={}){this.acIssuer=new E,this.acSerial=0,this.attrs=[],Object.assign(this,e)}}a([u({type:E})],dn.prototype,"acIssuer",void 0),a([u({type:h.Integer})],dn.prototype,"acSerial",void 0),a([u({type:It,repeated:"sequence"})],dn.prototype,"attrs",void 0);var yn;let jr=yn=class extends j{constructor(e){super(e),Object.setPrototypeOf(this,yn.prototype)}};jr=yn=a([A({type:v.Sequence,itemType:h.ObjectIdentifier})],jr);class Ur{constructor(e={}){this.permitUnSpecified=!0,Object.assign(this,e)}}a([u({type:h.Integer,optional:!0})],Ur.prototype,"pathLenConstraint",void 0),a([u({type:jr,implicit:!0,context:0,optional:!0})],Ur.prototype,"permittedAttrs",void 0),a([u({type:jr,implicit:!0,context:1,optional:!0})],Ur.prototype,"excludedAttrs",void 0),a([u({type:h.Boolean,defaultValue:!0})],Ur.prototype,"permitUnSpecified",void 0);class ze{constructor(e={}){this.issuer=new ue,this.serial=new ArrayBuffer(0),this.issuerUID=new ArrayBuffer(0),Object.assign(this,e)}}a([u({type:ue})],ze.prototype,"issuer",void 0),a([u({type:h.Integer,converter:re})],ze.prototype,"serial",void 0),a([u({type:h.BitString,optional:!0})],ze.prototype,"issuerUID",void 0);var gn;(function(r){r[r.publicKey=0]="publicKey",r[r.publicKeyCert=1]="publicKeyCert",r[r.otherObjectTypes=2]="otherObjectTypes"})(gn||(gn={}));class Xe{constructor(e={}){this.digestedObjectType=gn.publicKey,this.digestAlgorithm=new k,this.objectDigest=new ArrayBuffer(0),Object.assign(this,e)}}a([u({type:h.Enumerated})],Xe.prototype,"digestedObjectType",void 0),a([u({type:h.ObjectIdentifier,optional:!0})],Xe.prototype,"otherObjectTypeID",void 0),a([u({type:k})],Xe.prototype,"digestAlgorithm",void 0),a([u({type:h.BitString})],Xe.prototype,"objectDigest",void 0);class Dr{constructor(e={}){Object.assign(this,e)}}a([u({type:ue,optional:!0})],Dr.prototype,"issuerName",void 0),a([u({type:ze,context:0,implicit:!0,optional:!0})],Dr.prototype,"baseCertificateID",void 0),a([u({type:Xe,context:1,implicit:!0,optional:!0})],Dr.prototype,"objectDigestInfo",void 0);let ut=class{constructor(e={}){Object.assign(this,e)}};a([u({type:E,repeated:"sequence"})],ut.prototype,"v1Form",void 0),a([u({type:Dr,context:0,implicit:!0})],ut.prototype,"v2Form",void 0),ut=a([A({type:v.Choice})],ut);class Rr{constructor(e={}){this.notBeforeTime=new Date,this.notAfterTime=new Date,Object.assign(this,e)}}a([u({type:h.GeneralizedTime})],Rr.prototype,"notBeforeTime",void 0),a([u({type:h.GeneralizedTime})],Rr.prototype,"notAfterTime",void 0);class Dt{constructor(e={}){Object.assign(this,e)}}a([u({type:ze,implicit:!0,context:0,optional:!0})],Dt.prototype,"baseCertificateID",void 0),a([u({type:ue,implicit:!0,context:1,optional:!0})],Dt.prototype,"entityName",void 0),a([u({type:Xe,implicit:!0,context:2,optional:!0})],Dt.prototype,"objectDigestInfo",void 0);var vn;(function(r){r[r.v2=1]="v2"})(vn||(vn={}));class he{constructor(e={}){this.version=vn.v2,this.holder=new Dt,this.issuer=new ut,this.signature=new k,this.serialNumber=new ArrayBuffer(0),this.attrCertValidityPeriod=new Rr,this.attributes=[],Object.assign(this,e)}}a([u({type:h.Integer})],he.prototype,"version",void 0),a([u({type:Dt})],he.prototype,"holder",void 0),a([u({type:ut})],he.prototype,"issuer",void 0),a([u({type:k})],he.prototype,"signature",void 0),a([u({type:h.Integer,converter:re})],he.prototype,"serialNumber",void 0),a([u({type:Rr})],he.prototype,"attrCertValidityPeriod",void 0),a([u({type:It,repeated:"sequence"})],he.prototype,"attributes",void 0),a([u({type:h.BitString,optional:!0})],he.prototype,"issuerUniqueID",void 0),a([u({type:nt,optional:!0})],he.prototype,"extensions",void 0);class Lr{constructor(e={}){this.acinfo=new he,this.signatureAlgorithm=new k,this.signatureValue=new ArrayBuffer(0),Object.assign(this,e)}}a([u({type:he})],Lr.prototype,"acinfo",void 0),a([u({type:k})],Lr.prototype,"signatureAlgorithm",void 0),a([u({type:h.BitString})],Lr.prototype,"signatureValue",void 0);var Hr;(function(r){r[r.unmarked=1]="unmarked",r[r.unclassified=2]="unclassified",r[r.restricted=4]="restricted",r[r.confidential=8]="confidential",r[r.secret=16]="secret",r[r.topSecret=32]="topSecret"})(Hr||(Hr={}));class mn extends pr{}class wn{constructor(e={}){this.type="",this.value=new ArrayBuffer(0),Object.assign(this,e)}}a([u({type:h.ObjectIdentifier,implicit:!0,context:0})],wn.prototype,"type",void 0),a([u({type:h.Any,implicit:!0,context:1})],wn.prototype,"value",void 0);class bn{constructor(e={}){this.policyId="",this.classList=new mn(Hr.unclassified),Object.assign(this,e)}}a([u({type:h.ObjectIdentifier})],bn.prototype,"policyId",void 0),a([u({type:mn,defaultValue:new mn(Hr.unclassified)})],bn.prototype,"classList",void 0),a([u({type:wn,repeated:"set"})],bn.prototype,"securityCategories",void 0);class $r{constructor(e={}){Object.assign(this,e)}}a([u({type:C})],$r.prototype,"cotets",void 0),a([u({type:h.ObjectIdentifier})],$r.prototype,"oid",void 0),a([u({type:h.Utf8String})],$r.prototype,"string",void 0);class _s{constructor(e={}){this.values=[],Object.assign(this,e)}}a([u({type:ue,implicit:!0,context:0,optional:!0})],_s.prototype,"policyAuthority",void 0),a([u({type:$r,repeated:"sequence"})],_s.prototype,"values",void 0);var An;class Mr{constructor(e={}){this.targetCertificate=new ze,Object.assign(this,e)}}a([u({type:ze})],Mr.prototype,"targetCertificate",void 0),a([u({type:E,optional:!0})],Mr.prototype,"targetName",void 0),a([u({type:Xe,optional:!0})],Mr.prototype,"certDigestInfo",void 0);let ft=class{constructor(e={}){Object.assign(this,e)}};a([u({type:E,context:0,implicit:!0})],ft.prototype,"targetName",void 0),a([u({type:E,context:1,implicit:!0})],ft.prototype,"targetGroup",void 0),a([u({type:Mr,context:2,implicit:!0})],ft.prototype,"targetCert",void 0),ft=a([A({type:v.Choice})],ft);let Sn=An=class extends j{constructor(e){super(e),Object.setPrototypeOf(this,An.prototype)}};Sn=An=a([A({type:v.Sequence,itemType:ft})],Sn);var Bn;let qs=Bn=class extends j{constructor(e){super(e),Object.setPrototypeOf(this,Bn.prototype)}};qs=Bn=a([A({type:v.Sequence,itemType:Sn})],qs);class Fs{constructor(e={}){Object.assign(this,e)}}a([u({type:ue,implicit:!0,context:0,optional:!0})],Fs.prototype,"roleAuthority",void 0),a([u({type:E,implicit:!0,context:1})],Fs.prototype,"roleName",void 0);class kn{constructor(e={}){this.service=new E,this.ident=new E,Object.assign(this,e)}}a([u({type:E})],kn.prototype,"service",void 0),a([u({type:E})],kn.prototype,"ident",void 0),a([u({type:C,optional:!0})],kn.prototype,"authInfo",void 0);var xn;class Nn{constructor(e={}){this.otherCertFormat="",this.otherCert=new ArrayBuffer(0),Object.assign(this,e)}}a([u({type:h.ObjectIdentifier})],Nn.prototype,"otherCertFormat",void 0),a([u({type:h.Any})],Nn.prototype,"otherCert",void 0);let ht=class{constructor(e={}){Object.assign(this,e)}};a([u({type:_e})],ht.prototype,"certificate",void 0),a([u({type:Lr,context:2,implicit:!0})],ht.prototype,"v2AttrCert",void 0),a([u({type:Nn,context:3,implicit:!0})],ht.prototype,"other",void 0),ht=a([A({type:v.Choice})],ht);let Pr=xn=class extends j{constructor(e){super(e),Object.setPrototypeOf(this,xn.prototype)}};Pr=xn=a([A({type:v.Set,itemType:ht})],Pr);class _r{constructor(e={}){this.contentType="",this.content=new ArrayBuffer(0),Object.assign(this,e)}}a([u({type:h.ObjectIdentifier})],_r.prototype,"contentType",void 0),a([u({type:h.Any,context:0})],_r.prototype,"content",void 0);let Rt=class{constructor(e={}){Object.assign(this,e)}};a([u({type:C})],Rt.prototype,"single",void 0),a([u({type:h.Any})],Rt.prototype,"any",void 0),Rt=a([A({type:v.Choice})],Rt);class qr{constructor(e={}){this.eContentType="",Object.assign(this,e)}}a([u({type:h.ObjectIdentifier})],qr.prototype,"eContentType",void 0),a([u({type:Rt,context:0,optional:!0})],qr.prototype,"eContent",void 0);let Lt=class{constructor(e={}){Object.assign(this,e)}};a([u({type:C,context:0,implicit:!0,optional:!0})],Lt.prototype,"value",void 0),a([u({type:C,converter:Za,context:0,implicit:!0,optional:!0,repeated:"sequence"})],Lt.prototype,"constructedValue",void 0),Lt=a([A({type:v.Choice})],Lt);class Ht{constructor(e={}){this.contentType="",this.contentEncryptionAlgorithm=new Tr,Object.assign(this,e)}}a([u({type:h.ObjectIdentifier})],Ht.prototype,"contentType",void 0),a([u({type:Tr})],Ht.prototype,"contentEncryptionAlgorithm",void 0),a([u({type:Lt,optional:!0})],Ht.prototype,"encryptedContent",void 0);class Fr{constructor(e={}){this.keyAttrId="",Object.assign(this,e)}}a([u({type:h.ObjectIdentifier})],Fr.prototype,"keyAttrId",void 0),a([u({type:h.Any,optional:!0})],Fr.prototype,"keyAttr",void 0);var Cn;class Gr{constructor(e={}){this.subjectKeyIdentifier=new Ot,Object.assign(this,e)}}a([u({type:Ot})],Gr.prototype,"subjectKeyIdentifier",void 0),a([u({type:h.GeneralizedTime,optional:!0})],Gr.prototype,"date",void 0),a([u({type:Fr,optional:!0})],Gr.prototype,"other",void 0);let pt=class{constructor(e={}){Object.assign(this,e)}};a([u({type:Gr,context:0,implicit:!0,optional:!0})],pt.prototype,"rKeyId",void 0),a([u({type:ct,optional:!0})],pt.prototype,"issuerAndSerialNumber",void 0),pt=a([A({type:v.Choice})],pt);class En{constructor(e={}){this.rid=new pt,this.encryptedKey=new C,Object.assign(this,e)}}a([u({type:pt})],En.prototype,"rid",void 0),a([u({type:C})],En.prototype,"encryptedKey",void 0);let zr=Cn=class extends j{constructor(e){super(e),Object.setPrototypeOf(this,Cn.prototype)}};zr=Cn=a([A({type:v.Sequence,itemType:En})],zr);class In{constructor(e={}){this.algorithm=new k,this.publicKey=new ArrayBuffer(0),Object.assign(this,e)}}a([u({type:k})],In.prototype,"algorithm",void 0),a([u({type:h.BitString})],In.prototype,"publicKey",void 0);let We=class{constructor(e={}){Object.assign(this,e)}};a([u({type:Ot,context:0,implicit:!0,optional:!0})],We.prototype,"subjectKeyIdentifier",void 0),a([u({type:In,context:1,implicit:!0,optional:!0})],We.prototype,"originatorKey",void 0),a([u({type:ct,optional:!0})],We.prototype,"issuerAndSerialNumber",void 0),We=a([A({type:v.Choice})],We);class dt{constructor(e={}){this.version=Ee.v3,this.originator=new We,this.keyEncryptionAlgorithm=new me,this.recipientEncryptedKeys=new zr,Object.assign(this,e)}}a([u({type:h.Integer})],dt.prototype,"version",void 0),a([u({type:We,context:0})],dt.prototype,"originator",void 0),a([u({type:C,context:1,optional:!0})],dt.prototype,"ukm",void 0),a([u({type:me})],dt.prototype,"keyEncryptionAlgorithm",void 0),a([u({type:zr})],dt.prototype,"recipientEncryptedKeys",void 0);let yt=class{constructor(e={}){Object.assign(this,e)}};a([u({type:Ot,context:0,implicit:!0})],yt.prototype,"subjectKeyIdentifier",void 0),a([u({type:ct})],yt.prototype,"issuerAndSerialNumber",void 0),yt=a([A({type:v.Choice})],yt);class $t{constructor(e={}){this.version=Ee.v0,this.rid=new yt,this.keyEncryptionAlgorithm=new me,this.encryptedKey=new C,Object.assign(this,e)}}a([u({type:h.Integer})],$t.prototype,"version",void 0),a([u({type:yt})],$t.prototype,"rid",void 0),a([u({type:me})],$t.prototype,"keyEncryptionAlgorithm",void 0),a([u({type:C})],$t.prototype,"encryptedKey",void 0);class Mt{constructor(e={}){this.keyIdentifier=new C,Object.assign(this,e)}}a([u({type:C})],Mt.prototype,"keyIdentifier",void 0),a([u({type:h.GeneralizedTime,optional:!0})],Mt.prototype,"date",void 0),a([u({type:Fr,optional:!0})],Mt.prototype,"other",void 0);class Pt{constructor(e={}){this.version=Ee.v4,this.kekid=new Mt,this.keyEncryptionAlgorithm=new me,this.encryptedKey=new C,Object.assign(this,e)}}a([u({type:h.Integer})],Pt.prototype,"version",void 0),a([u({type:Mt})],Pt.prototype,"kekid",void 0),a([u({type:me})],Pt.prototype,"keyEncryptionAlgorithm",void 0),a([u({type:C})],Pt.prototype,"encryptedKey",void 0);class _t{constructor(e={}){this.version=Ee.v0,this.keyEncryptionAlgorithm=new me,this.encryptedKey=new C,Object.assign(this,e)}}a([u({type:h.Integer})],_t.prototype,"version",void 0),a([u({type:hn,context:0,optional:!0})],_t.prototype,"keyDerivationAlgorithm",void 0),a([u({type:me})],_t.prototype,"keyEncryptionAlgorithm",void 0),a([u({type:C})],_t.prototype,"encryptedKey",void 0);class On{constructor(e={}){this.oriType="",this.oriValue=new ArrayBuffer(0),Object.assign(this,e)}}a([u({type:h.ObjectIdentifier})],On.prototype,"oriType",void 0),a([u({type:h.Any})],On.prototype,"oriValue",void 0);let je=class{constructor(e={}){Object.assign(this,e)}};a([u({type:$t,optional:!0})],je.prototype,"ktri",void 0),a([u({type:dt,context:1,implicit:!0,optional:!0})],je.prototype,"kari",void 0),a([u({type:Pt,context:2,implicit:!0,optional:!0})],je.prototype,"kekri",void 0),a([u({type:_t,context:3,implicit:!0,optional:!0})],je.prototype,"pwri",void 0),a([u({type:On,context:4,implicit:!0,optional:!0})],je.prototype,"ori",void 0),je=a([A({type:v.Choice})],je);var Tn;let Xr=Tn=class extends j{constructor(e){super(e),Object.setPrototypeOf(this,Tn.prototype)}};Xr=Tn=a([A({type:v.Set,itemType:je})],Xr);var Vn;class Wr{constructor(e={}){this.otherRevInfoFormat="",this.otherRevInfo=new ArrayBuffer(0),Object.assign(this,e)}}a([u({type:h.ObjectIdentifier})],Wr.prototype,"otherRevInfoFormat",void 0),a([u({type:h.Any})],Wr.prototype,"otherRevInfo",void 0);let Jr=class{constructor(e={}){this.other=new Wr,Object.assign(this,e)}};a([u({type:Wr,context:1,implicit:!0})],Jr.prototype,"other",void 0),Jr=a([A({type:v.Choice})],Jr);let Kr=Vn=class extends j{constructor(e){super(e),Object.setPrototypeOf(this,Vn.prototype)}};Kr=Vn=a([A({type:v.Set,itemType:Jr})],Kr);class jn{constructor(e={}){Object.assign(this,e)}}a([u({type:Pr,context:0,implicit:!0,optional:!0})],jn.prototype,"certs",void 0),a([u({type:Kr,context:1,implicit:!0,optional:!0})],jn.prototype,"crls",void 0);var Un;let Dn=Un=class extends j{constructor(e){super(e),Object.setPrototypeOf(this,Un.prototype)}};Dn=Un=a([A({type:v.Set,itemType:Ut})],Dn);class qt{constructor(e={}){this.version=Ee.v0,this.recipientInfos=new Xr,this.encryptedContentInfo=new Ht,Object.assign(this,e)}}a([u({type:h.Integer})],qt.prototype,"version",void 0),a([u({type:jn,context:0,implicit:!0,optional:!0})],qt.prototype,"originatorInfo",void 0),a([u({type:Xr})],qt.prototype,"recipientInfos",void 0),a([u({type:Ht})],qt.prototype,"encryptedContentInfo",void 0),a([u({type:Dn,context:1,implicit:!0,optional:!0})],qt.prototype,"unprotectedAttrs",void 0);var Rn;let Yr=Rn=class extends j{constructor(e){super(e),Object.setPrototypeOf(this,Rn.prototype)}};Yr=Rn=a([A({type:v.Set,itemType:jt})],Yr);class Je{constructor(e={}){this.version=Ee.v0,this.digestAlgorithms=new Yr,this.encapContentInfo=new qr,this.signerInfos=new Vr,Object.assign(this,e)}}a([u({type:h.Integer})],Je.prototype,"version",void 0),a([u({type:Yr})],Je.prototype,"digestAlgorithms",void 0),a([u({type:qr})],Je.prototype,"encapContentInfo",void 0),a([u({type:Pr,context:0,implicit:!0,optional:!0})],Je.prototype,"certificates",void 0),a([u({type:Kr,context:1,implicit:!0,optional:!0})],Je.prototype,"crls",void 0),a([u({type:Vr})],Je.prototype,"signerInfos",void 0);class Zr{constructor(e={}){this.seconds=0,Object.assign(this,e)}}a([u({type:h.Integer,optional:!0})],Zr.prototype,"seconds",void 0),a([u({type:h.Integer,context:0,implicit:!0,optional:!0})],Zr.prototype,"millis",void 0),a([u({type:h.Integer,context:1,implicit:!0,optional:!0})],Zr.prototype,"micros",void 0);class gt{constructor(e={}){this.hashAlgorithm=new k,this.hashedMessage=new C,Object.assign(this,e)}}a([u({type:k})],gt.prototype,"hashAlgorithm",void 0),a([u({type:C})],gt.prototype,"hashedMessage",void 0);var pe;(function(r){r[r.badAlg=1]="badAlg",r[r.badRequest=2]="badRequest",r[r.badDataFormat=16]="badDataFormat",r[r.timeNotAvailable=8192]="timeNotAvailable",r[r.unacceptedPolicy=16384]="unacceptedPolicy",r[r.unacceptedExtension=32768]="unacceptedExtension",r[r.addInfoNotAvailable=65536]="addInfoNotAvailable",r[r.systemFailure=16777216]="systemFailure"})(pe||(pe={}));class Pc extends pr{toJSON(){const e=this.toNumber(),t=[];return e&pe.addInfoNotAvailable&&t.push("addInfoNotAvailable"),e&pe.badAlg&&t.push("badAlg"),e&pe.badDataFormat&&t.push("badDataFormat"),e&pe.badRequest&&t.push("badRequest"),e&pe.systemFailure&&t.push("systemFailure"),e&pe.systemFailure&&t.push("systemFailure"),e&pe.timeNotAvailable&&t.push("timeNotAvailable"),e&pe.unacceptedExtension&&t.push("unacceptedExtension"),e&pe.unacceptedPolicy&&t.push("unacceptedPolicy"),t}toString(){return`[${this.toJSON().join(", ")}]`}}var Ln;(function(r){r[r.granted=0]="granted",r[r.grantedWithMods=1]="grantedWithMods",r[r.rejection=2]="rejection",r[r.waiting=3]="waiting",r[r.revocationWarning=4]="revocationWarning",r[r.revocationNotification=5]="revocationNotification"})(Ln||(Ln={}));var Hn;let $n=Hn=class extends j{constructor(e){super(e),Object.setPrototypeOf(this,Hn.prototype)}};$n=Hn=a([A({type:v.Sequence,itemType:h.Utf8String})],$n);class Ft{constructor(e={}){this.status=Ln.granted,Object.assign(this,e)}}a([u({type:h.Integer})],Ft.prototype,"status",void 0),a([u({type:$n,optional:!0})],Ft.prototype,"statusString",void 0),a([u({type:Pc,optional:!0})],Ft.prototype,"failInfo",void 0);var Mn;(function(r){r[r.v1=1]="v1"})(Mn||(Mn={}));class vt{constructor(e={}){this.version=Mn.v1,this.messageImprint=new gt,this.certReq=!1,Object.assign(this,e)}}a([u({type:h.Integer})],vt.prototype,"version",void 0),a([u({type:gt})],vt.prototype,"messageImprint",void 0),a([u({type:h.ObjectIdentifier,optional:!0})],vt.prototype,"reqPolicy",void 0),a([u({type:h.Integer,converter:re,optional:!0})],vt.prototype,"nonce",void 0),a([u({type:h.Boolean,defaultValue:!1})],vt.prototype,"certReq",void 0),a([u({type:nt,optional:!0,context:0,implicit:!0})],vt.prototype,"extensions",void 0);let Pn=class extends _r{};Pn=a([A({type:v.Sequence})],Pn);class Gs{constructor(e={}){this.status=new Ft,Object.assign(this,e)}}a([u({type:Ft})],Gs.prototype,"status",void 0),a([u({type:Pn,optional:!0})],Gs.prototype,"timeStampToken",void 0);var _n;(function(r){r[r.v1=1]="v1"})(_n||(_n={}));class de{constructor(e={}){this.version=_n.v1,this.policy="",this.messageImprint=new gt,this.serialNumber=new ArrayBuffer(0),this.genTime=new Date,this.ordering=!1,Object.assign(this,e)}}a([u({type:h.Integer})],de.prototype,"version",void 0),a([u({type:h.ObjectIdentifier})],de.prototype,"policy",void 0),a([u({type:gt})],de.prototype,"messageImprint",void 0),a([u({type:h.Integer,converter:re})],de.prototype,"serialNumber",void 0),a([u({type:h.GeneralizedTime})],de.prototype,"genTime",void 0),a([u({type:Zr,optional:!0})],de.prototype,"accuracy",void 0),a([u({type:h.Boolean,defaultValue:!1})],de.prototype,"ordering",void 0),a([u({type:h.Integer,converter:re,optional:!0})],de.prototype,"nonce",void 0),a([u({type:E,context:0,optional:!0})],de.prototype,"tsa",void 0),a([u({type:nt,context:1,implicit:!0,optional:!0})],de.prototype,"extensions",void 0);var qn=(r,e,t)=>new Promise((i,n)=>{var o=l=>{try{c(t.next(l))}catch(f){n(f)}},s=l=>{try{c(t.throw(l))}catch(f){n(f)}},c=l=>l.done?i(l.value):Promise.resolve(l.value).then(o,s);c((t=t.apply(r,e)).next())});const _c="1.2.840.113549.1.7.2",qc="1.2.840.113549.1.9.16.1.4";function Fc(r){return{"1.3.14.3.2.26":"SHA-1","2.16.840.1.101.3.4.2.1":"SHA-256","2.16.840.1.101.3.4.2.2":"SHA-384","2.16.840.1.101.3.4.2.3":"SHA-512"}[r]||r}const Gc={"2.5.4.3":"CN","2.5.4.6":"C","2.5.4.7":"L","2.5.4.8":"ST","2.5.4.10":"O","2.5.4.11":"OU","2.5.4.5":"serialNumber","1.2.840.113549.1.9.1":"emailAddress"};function zc(r){var e;const t=[];for(const i of r)for(const n of i){const o=Gc[n.type]||n.type,s=((e=n.value)==null?void 0:e.toString())||"";s&&t.push(`${o}=${s}`)}return t.join(", ")}function Fn(r){try{const e=Vs(r),t=ce.parse(e,_r);if(t.contentType!==_c)return console.warn("Timestamp is not SignedData"),null;const i=ce.parse(t.content,Je);if(i.encapContentInfo.eContentType!==qc)return console.warn("SignedData does not contain TSTInfo"),null;if(!i.encapContentInfo.eContent)return console.warn("No eContent in SignedData"),null;const n=i.encapContentInfo.eContent;let o;n.single?o=n.single.buffer:n.any?o=n.any:o=ce.serialize(n);const s=ce.parse(o,de);let c;if(i.certificates&&i.certificates.length>0){const p=i.certificates[0];"certificate"in p&&p.certificate&&(c=js(ce.serialize(p.certificate)))}let l;s.tsa&&(s.tsa.directoryName?l=zc(s.tsa.directoryName):s.tsa.uniformResourceIdentifier&&(l=s.tsa.uniformResourceIdentifier));let f;return s.accuracy&&(f=(s.accuracy.seconds||0)+(s.accuracy.millis||0)/1e3+(s.accuracy.micros||0)/1e6),{genTime:s.genTime,policy:s.policy,serialNumber:un(s.serialNumber),hashAlgorithm:Fc(s.messageImprint.hashAlgorithm.algorithm),messageImprint:un(s.messageImprint.hashedMessage.buffer),tsaName:l,tsaCertificate:c,accuracy:f}}catch(e){return console.error("Failed to parse timestamp:",e instanceof Error?e.message:String(e)),null}}function Xc(r,e){return qn(this,null,function*(){const t={"SHA-1":"SHA-1","SHA-256":"SHA-256","SHA-384":"SHA-384","SHA-512":"SHA-512"}[e];if(!t)throw new Error(`Unsupported hash algorithm: ${e}`);if(typeof crypto!="undefined"&&crypto.subtle)return crypto.subtle.digest(t,r);const i=require("crypto").createHash(e.toLowerCase().replace("-",""));return i.update(Buffer.from(r)),i.digest().buffer})}function Wc(r,e){return qn(this,null,function*(){try{const t=r.messageImprint.toLowerCase(),i=new TextEncoder().encode(e),n=yield Xc(i.buffer,r.hashAlgorithm);return un(n).toLowerCase()===t}catch(t){return console.error("Failed to verify timestamp coverage:",t instanceof Error?t.message:String(t)),!1}})}function zs(r){return qn(this,arguments,function*(e,t={}){const i=Fn(e);if(!i)return{isValid:!1,reason:"Failed to parse timestamp token"};let n,o;t.canonicalSignatureValue&&(n=yield Wc(i,t.canonicalSignatureValue),n||(o="Could not verify timestamp covers signature (hash mismatch)"));let s;if(t.verifyTsaCertificate&&i.tsaCertificate)try{const c=new V.X509Certificate(i.tsaCertificate);if(i.genTime<c.notBefore||i.genTime>c.notAfter)return{isValid:!1,info:i,coversSignature:n,reason:`TSA certificate was not valid at timestamp time (${i.genTime.toISOString()})`};if(t.checkTsaRevocation!==!1)try{if(s=yield fn(c,t.revocationOptions),s.status==="revoked")return{isValid:!1,info:i,coversSignature:n,tsaRevocation:s,reason:`TSA certificate has been revoked: ${s.reason||"No reason provided"}`}}catch(l){s={isValid:!1,status:"error",method:"none",reason:`TSA revocation check failed: ${l instanceof Error?l.message:String(l)}`,checkedAt:new Date}}}catch(c){return{isValid:!1,info:i,coversSignature:n,reason:`Failed to verify TSA certificate: ${c instanceof Error?c.message:String(c)}`}}return{isValid:!0,info:i,coversSignature:n,tsaRevocation:s,reason:o}})}function Jc(r){const e=Fn(r);return(e==null?void 0:e.genTime)||null}var Kc=Object.defineProperty,Xs=Object.getOwnPropertySymbols,Yc=Object.prototype.hasOwnProperty,Zc=Object.prototype.propertyIsEnumerable,Ws=(r,e,t)=>e in r?Kc(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,Js=(r,e)=>{for(var t in e||(e={}))Yc.call(e,t)&&Ws(r,t,e[t]);if(Xs)for(var t of Xs(e))Zc.call(e,t)&&Ws(r,t,e[t]);return r},Ke=(r,e,t)=>new Promise((i,n)=>{var o=l=>{try{c(t.next(l))}catch(f){n(f)}},s=l=>{try{c(t.throw(l))}catch(f){n(f)}},c=l=>l.done?i(l.value):Promise.resolve(l.value).then(o,s);c((t=t.apply(r,e)).next())});function Qr(){return typeof window!="undefined"&&typeof window.crypto!="undefined"&&typeof window.crypto.subtle!="undefined"}function Ks(r,e){return Ke(this,null,function*(){const t=e.replace(/-/g,"").toLowerCase();let i;if(t.includes("sha256"))i="sha256";else if(t.includes("sha1"))i="sha1";else if(t.includes("sha384"))i="sha384";else if(t.includes("sha512"))i="sha512";else throw new Error(`Unsupported digest algorithm: ${e}`);return Qr()?Qc(r,i):el(r,i)})}function Qc(r,e){return Ke(this,null,function*(){const t={sha1:"SHA-1",sha256:"SHA-256",sha384:"SHA-384",sha512:"SHA-512"}[e];if(!t)throw new Error(`Unsupported browser digest algorithm: ${e}`);const i=yield window.crypto.subtle.digest(t,r),n=Array.from(new Uint8Array(i));return btoa(String.fromCharCode.apply(null,n))})}function el(r,e){return new Promise((t,i)=>{try{const n=require("crypto").createHash(e);n.update(Buffer.from(r)),t(n.digest("base64"))}catch(n){i(new Error(`Node digest computation failed: ${n instanceof Error?n.message:String(n)}`))}})}function tl(r){const e=r.toLowerCase();return e.includes("sha512")?"SHA-512":e.includes("sha384")?"SHA-384":e.includes("sha256")?"SHA-256":e.includes("sha1")?"SHA-1":"SHA-256"}function Ys(r,e){return Ke(this,null,function*(){const t={};let i=!0,n="SHA-256";r.algorithm&&(r.algorithm.includes("sha1")?n="SHA-1":r.algorithm.includes("sha384")?n="SHA-384":r.algorithm.includes("sha512")&&(n="SHA-512"));const o=Object.entries(r.signedChecksums).map(s=>Ke(this,[s],function*([c,l]){var f;const p=(f=r.digestAlgorithms)!=null&&f[c]?tl(r.digestAlgorithms[c]):n,d=e.get(c);if(d){const w=yield Ks(d,p),y=l===w;t[c]={expected:l,actual:w,matches:y,fileFound:!0},y||(i=!1)}else{const w=c.includes("/")?c.split("/").pop():c;let y=!1;if(w){for(const[g,B]of e.entries())if(g.endsWith(w)){const m=yield Ks(B,p),S=l===m;t[c]={expected:l,actual:m,matches:S,fileFound:!0},S||(i=!1),y=!0;break}}y||(t[c]={expected:l,actual:"",matches:!1,fileFound:!1},i=!1)}}));return yield Promise.all(o),{isValid:i,details:t}})}function rl(r){return Ke(this,arguments,function*(e,t=new Date){try{const i=new V.X509Certificate(e),n=fa(i,t),o=yield Qn(e);return{isValid:n.isValid,reason:n.reason,info:o}}catch(i){return{isValid:!1,reason:`Certificate parsing error: ${i instanceof Error?i.message:String(i)}`}}})}function il(r){switch(r){case"P-256":return 32;case"P-384":return 48;case"P-521":return 66;default:return 32}}function nl(r,e){const t=il(e),i=t*2;if(r.length===i)return r;if(r[0]===48)return ol(r,t);if(r.length>i){const n=r.length/2;if(Number.isInteger(n)){const o=r.slice(0,n),s=r.slice(n),c=ei(o,t),l=ei(s,t),f=new Uint8Array(i);return f.set(c,0),f.set(l,t),f}}return r}function ei(r,e){let t=0;for(;t<r.length-1&&r[t]===0;)t++;const i=r.slice(t);if(i.length===e)return i;if(i.length<e){const n=new Uint8Array(e);return n.set(i,e-i.length),n}else return i.slice(i.length-e)}function ol(r,e){let t=0;if(r[t++]!==48)throw new Error("Invalid DER signature: missing SEQUENCE tag");const i=r[t++];if(i&128&&(t+=i&127),r[t++]!==2)throw new Error("Invalid DER signature: missing INTEGER tag for R");const n=r[t++],o=r.slice(t,t+n);if(t+=n,r[t++]!==2)throw new Error("Invalid DER signature: missing INTEGER tag for S");const s=r[t++],c=r.slice(t,t+s),l=new Uint8Array(e*2);return l.set(ei(o,e),0),l.set(ei(c,e),e),l}function Zs(){return Qr()?window.crypto.subtle:crypto.subtle}function sl(r,e,t,i,n){return Ke(this,null,function*(){try{const o=Jn().parseFromString(r,"application/xml"),s=K(o,"ds:SignedInfo");if(!s)return{isValid:!1,reason:"SignedInfo element not found in provided XML"};const c=n||Ye.default,l=M.canonicalize(s,c),f=e.replace(/\s+/g,"");let p;try{p=Ac(f)}catch(y){return{isValid:!1,reason:`Failed to decode signature value: ${y instanceof Error?y.message:String(y)}`}}i.name==="ECDSA"&&(p=nl(p,i.namedCurve));let d;try{const y=Zs();Qr()&&i.name==="RSASSA-PKCS1-v1_5"&&(t=Ba(t)),d=yield y.importKey("spki",t,i,!1,["verify"])}catch(y){const g=y instanceof Error?y:new Error(String(y));let B="Unknown reason",m="KEY_IMPORT_ERROR";if(g.name==="DataError"?(B="Key data format is invalid or incompatible",m="INVALID_KEY_FORMAT"):g.name==="NotSupportedError"?(B="Algorithm or parameters not supported",m="UNSUPPORTED_ALGORITHM"):g.message.includes("namedCurve")?(B="Missing or invalid namedCurve parameter",m="INVALID_CURVE"):g.message.includes("hash")&&(B="Incompatible or unsupported hash algorithm",m="INVALID_HASH"),i.name==="ECDSA"){const S=t.byteLength;B+=` (Key length: ${S})`}return{isValid:!1,reason:`Failed to import public key: ${B}`,errorDetails:{category:m,originalMessage:g.message,algorithm:Js({},i),environment:Qr()?"browser":"node",keyLength:t.byteLength}}}const w=new TextEncoder().encode(l);try{const y=yield Zs().verify(i,d,p,w);return{isValid:y,reason:y?void 0:"Signature verification failed"}}catch(y){return{isValid:!1,reason:`Signature verification error: ${y instanceof Error?y.message:String(y)}`}}}catch(o){return{isValid:!1,reason:`SignedInfo verification error: ${o instanceof Error?o.message:String(o)}`}}})}function al(r,e){return Ke(this,arguments,function*(t,i,n={}){var o;const s=[];let c,l=n.verifyTime||t.signingTime;t.signatureTimestamp&&n.verifyTimestamps!==!1&&(c=yield zs(t.signatureTimestamp,{canonicalSignatureValue:t.canonicalSignatureValue,verifyTsaCertificate:!0,revocationOptions:n.revocationOptions}),c.isValid&&c.info?l=c.info.genTime:c.isValid||s.push(`Timestamp verification failed: ${c.reason||"Unknown reason"}`));const f=yield rl(t.certificatePEM,l);if(!f.isValid){const y=`Certificate validation error: ${f.reason||"Unknown reason"}`;s.push(y)}if(n.checkRevocation!==!1&&f.isValid)try{const y=yield fn(t.certificatePEM,Js({certificateChain:t.certificateChain},n.revocationOptions));if(f.revocation=y,y.status==="revoked"){const g=y.revokedAt,B=g&&g.getTime()>0;if(B&&l<g)f.revocation.isValid=!0,f.revocation.reason=`Certificate was revoked on ${g.toISOString()}, but signature was made on ${l.toISOString()} (before revocation)`;else{f.isValid=!1;const m=B?` on ${g.toISOString()}`:"";f.reason=y.reason||`Certificate has been revoked${m}`,s.push(y.reason||`Certificate revoked${m}`)}}}catch(y){f.revocation={isValid:!1,status:"error",method:"none",reason:`Revocation check failed: ${y instanceof Error?y.message:String(y)}`,checkedAt:new Date}}const p=n.verifyChecksums!==!1?yield Ys(t,i):{isValid:!0,details:{}};if(!p.isValid){const y=Object.entries(p.details).filter(([g,B])=>!B.matches).map(([g])=>g).join(", ");s.push(`Checksum validation failed for files: ${y}`)}let d={isValid:!0};if(n.verifySignatures!==!1&&t.rawXml&&t.signatureValue&&t.publicKey){const y=t.algorithm||"",g={name:"RSASSA-PKCS1-v1_5",hash:"SHA-256"};if(y.includes("ecdsa")&&t.publicKey.namedCurve&&(g.namedCurve=t.publicKey.namedCurve,g.name="ECDSA"),y.includes("ecdsa-sha256")?g.hash="SHA-256":y.includes("ecdsa-sha384")?g.hash="SHA-384":y.includes("ecdsa-sha512")?g.hash="SHA-512":y.includes("rsa-sha1")?g.hash="SHA-1":y.includes("rsa-pss")?(g.name="RSA-PSS",g.saltLength=32,y.includes("sha384")?(g.hash="SHA-384",g.saltLength=48):y.includes("sha512")?(g.hash="SHA-512",g.saltLength=64):g.hash="SHA-256"):y.includes("rsa-sha384")?g.hash="SHA-384":y.includes("rsa-sha512")&&(g.hash="SHA-512"),d=yield sl(t.rawXml,t.signatureValue,t.publicKey.rawData,g,t.canonicalizationMethod),!d.isValid){let B=d.reason||"XML signature verification failed";if(d.errorDetails){const m=d.errorDetails;B+=` [Category: ${m.category}, Environment: ${m.environment}`,m.algorithm&&(B+=`, Algorithm: ${m.algorithm.name}`,m.algorithm.namedCurve&&(B+=`, Curve: ${m.algorithm.namedCurve}`)),m.keyLength&&(B+=`, Key length: ${m.keyLength} bytes`),B+="]"}s.push(B)}}else if(n.verifySignatures!==!1){const y=[];t.rawXml||y.push("Signature XML"),t.signatureValue||y.push("SignatureValue"),t.publicKey||y.push("Public Key"),s.push(`Cannot verify XML signature: missing ${y.join(", ")}`),d={isValid:!1,reason:`Missing required components: ${y.join(", ")}`}}const w=!t.signatureTimestamp||n.verifyTimestamps===!1||((o=c==null?void 0:c.isValid)!=null?o:!0);return{isValid:f.isValid&&p.isValid&&d.isValid&&w,certificate:f,checksums:p,signature:n.verifySignatures!==!1?d:void 0,timestamp:c,errors:s.length>0?s:void 0}})}x.CANONICALIZATION_METHODS=Ye,x.XMLCanonicalizer=M,x.checkCertificateRevocation=fn,x.formatValidityPeriod=pa,x.getSignerDisplayName=ha,x.getTimestampTime=Jc,x.parseCertificate=Qn,x.parseEdoc=Sa,x.parseTimestamp=Fn,x.verifyChecksums=Ys,x.verifySignature=al,x.verifyTimestamp=zs,Object.defineProperty(x,"__esModule",{value:!0})});
82
82
  //# sourceMappingURL=index.umd.js.map