edockit 0.2.4 → 0.4.0-dev.0

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.
Files changed (69) hide show
  1. package/CHANGELOG.md +36 -0
  2. package/README.md +81 -175
  3. package/TRUSTED-LIST.md +308 -0
  4. package/dist/certificate-c46e14a0.js +560 -0
  5. package/dist/certificate-c46e14a0.js.map +1 -0
  6. package/dist/certificate-fc0e06f7.js +571 -0
  7. package/dist/certificate-fc0e06f7.js.map +1 -0
  8. package/dist/core/canonicalization/XMLCanonicalizer.d.ts +9 -3
  9. package/dist/core/rsa-digestinfo-workaround.d.ts +29 -0
  10. package/dist/core/trustedlist/build.d.ts +41 -0
  11. package/dist/core/trustedlist/bundled-provider.d.ts +2 -0
  12. package/dist/core/trustedlist/contract.d.ts +19 -0
  13. package/dist/core/trustedlist/dom.d.ts +12 -0
  14. package/dist/core/trustedlist/extract.d.ts +6 -0
  15. package/dist/core/trustedlist/http.d.ts +8 -0
  16. package/dist/core/trustedlist/identity.d.ts +7 -0
  17. package/dist/core/trustedlist/index.d.ts +18 -0
  18. package/dist/core/trustedlist/loader.d.ts +5 -0
  19. package/dist/core/trustedlist/matcher.d.ts +11 -0
  20. package/dist/core/trustedlist/normalize.d.ts +14 -0
  21. package/dist/core/trustedlist/reference-provider.d.ts +12 -0
  22. package/dist/core/trustedlist/types.d.ts +114 -0
  23. package/dist/core/unzip.d.ts +0 -0
  24. package/dist/core/verification.d.ts +50 -0
  25. package/dist/data/trusted-list.d.ts +3 -0
  26. package/dist/identity-1a3dddc3.js +902 -0
  27. package/dist/identity-1a3dddc3.js.map +1 -0
  28. package/dist/identity-b3a70fc1.js +897 -0
  29. package/dist/identity-b3a70fc1.js.map +1 -0
  30. package/dist/index.cjs.js +1275 -7892
  31. package/dist/index.cjs.js.map +1 -1
  32. package/dist/index.d.ts +4 -2
  33. package/dist/index.esm.js +783 -7399
  34. package/dist/index.esm.js.map +1 -1
  35. package/dist/index.umd.js +12 -15
  36. package/dist/index.umd.js.map +1 -1
  37. package/dist/loader-1ac52e12.js +217 -0
  38. package/dist/loader-1ac52e12.js.map +1 -0
  39. package/dist/loader-43d8e17a.js +222 -0
  40. package/dist/loader-43d8e17a.js.map +1 -0
  41. package/dist/normalize-60f2d7e6.js +6270 -0
  42. package/dist/normalize-60f2d7e6.js.map +1 -0
  43. package/dist/normalize-70da6516.js +6214 -0
  44. package/dist/normalize-70da6516.js.map +1 -0
  45. package/dist/reference-provider-1cd85b7b.js +217 -0
  46. package/dist/reference-provider-1cd85b7b.js.map +1 -0
  47. package/dist/reference-provider-53240217.js +211 -0
  48. package/dist/reference-provider-53240217.js.map +1 -0
  49. package/dist/trusted-list-build.cjs.js +575 -0
  50. package/dist/trusted-list-build.cjs.js.map +1 -0
  51. package/dist/trusted-list-build.d.ts +4 -0
  52. package/dist/trusted-list-build.esm.js +564 -0
  53. package/dist/trusted-list-build.esm.js.map +1 -0
  54. package/dist/trusted-list-bundled.cjs.js +30436 -0
  55. package/dist/trusted-list-bundled.cjs.js.map +1 -0
  56. package/dist/trusted-list-bundled.d.ts +1 -0
  57. package/dist/trusted-list-bundled.esm.js +30432 -0
  58. package/dist/trusted-list-bundled.esm.js.map +1 -0
  59. package/dist/trusted-list-http.cjs.js +85 -0
  60. package/dist/trusted-list-http.cjs.js.map +1 -0
  61. package/dist/trusted-list-http.d.ts +1 -0
  62. package/dist/trusted-list-http.esm.js +81 -0
  63. package/dist/trusted-list-http.esm.js.map +1 -0
  64. package/dist/trusted-list.cjs.js +35 -0
  65. package/dist/trusted-list.cjs.js.map +1 -0
  66. package/dist/trusted-list.d.ts +9 -0
  67. package/dist/trusted-list.esm.js +10 -0
  68. package/dist/trusted-list.esm.js.map +1 -0
  69. package/package.json +34 -2
package/dist/index.umd.js CHANGED
@@ -1,17 +1,14 @@
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};/*!
1
+ var Xl=Object.defineProperty,Wl=Object.defineProperties;var Kl=Object.getOwnPropertyDescriptors;var fi=Object.getOwnPropertySymbols;var wa=Object.prototype.hasOwnProperty,ba=Object.prototype.propertyIsEnumerable;var va=(N,q,R)=>q in N?Xl(N,q,{enumerable:!0,configurable:!0,writable:!0,value:R}):N[q]=R,D=(N,q)=>{for(var R in q||(q={}))wa.call(q,R)&&va(N,R,q[R]);if(fi)for(var R of fi(q))ba.call(q,R)&&va(N,R,q[R]);return N},z=(N,q)=>Wl(N,Kl(q));var P=(N,q)=>{var R={};for(var ue in N)wa.call(N,ue)&&q.indexOf(ue)<0&&(R[ue]=N[ue]);if(N!=null&&fi)for(var ue of fi(N))q.indexOf(ue)<0&&ba.call(N,ue)&&(R[ue]=N[ue]);return R};/*!
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()),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
- `:"",afterChildren:(r,e)=>e?"":r?`
6
- `:"",betweenChildren:(r,e,t)=>t?"":r&&e?`
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-----
4
+ */(function(N,q){typeof exports=="object"&&typeof module!="undefined"?q(exports,require("fflate"),require("@peculiar/x509")):typeof define=="function"&&define.amd?define(["exports","fflate","@peculiar/x509"],q):(N=typeof globalThis!="undefined"?globalThis:N||self,q(N.edockit={},N.fflate,N.peculiarX509))})(this,(function(N,q,R){"use strict";function ue(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 d of n){if(d.ns&&l===`${d.ns}:${d.name}`){t.push(c);break}if(f===d.name||l===d.name){t.push(c);break}if(l.endsWith(`:${d.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 no={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 oo(){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 Aa(r,e,t=no){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=so(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 Sa(r,e,t=no){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=so(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 so(r){return function(e){return e===null?null:r[e]||null}}function ao(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 W(r,e){if(typeof r.querySelector=="function")try{const i=r.querySelector(e);if(i)return i}catch(i){}const t=ue(r,e);if(t.length>0)return t[0];try{const i=ao(e);return Aa(r,i)}catch(i){return console.warn("XPath query failed, using direct DOM traversal as fallback"),null}}function rr(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=ue(r,e);if(t.length>0)return t;try{const i=ao(e);return Sa(r,i)}catch(i){return console.warn("XPath query failed, using direct DOM traversal as fallback"),[]}}function ka(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 ot={default:"c14n","http://www.w3.org/TR/2001/REC-xml-c14n-20010315":"c14n","http://www.w3.org/TR/2001/REC-xml-c14n-20010315#WithComments":"c14n","http://www.w3.org/2006/12/xml-c14n11":"c14n11","http://www.w3.org/2006/12/xml-c14n11#WithComments":"c14n11","http://www.w3.org/2001/10/xml-exc-c14n#":"c14n_exc","http://www.w3.org/2001/10/xml-exc-c14n#WithComments":"c14n_exc"},Ct={c14n:{beforeChildren:()=>"",afterChildren:()=>"",betweenChildren:()=>"",afterElement:()=>"",isCanonicalizationMethod:"c14n"},c14n11:{beforeChildren:()=>"",afterChildren:()=>"",betweenChildren:()=>"",afterElement:()=>"",isCanonicalizationMethod:"c14n11"},c14n_exc:{beforeChildren:()=>"",afterChildren:()=>"",betweenChildren:()=>"",afterElement:()=>"",isCanonicalizationMethod:"c14n_exc"}},X={ELEMENT_NODE:1,TEXT_NODE:3};class F{constructor(e=Ct.c14n){this.method=e}static fromMethod(e){const t=ot[e];if(!t)throw new Error(`Unsupported canonicalization method: ${e}`);return new F(Ct[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===X.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===X.ELEMENT_NODE){const f=c,d=f.namespaceURI,p=f.prefix||"";if(p&&d&&(l||!o.has(p))){o.add(p);const y=t.get(p);y&&y===d&&!n.has(p)&&n.set(p,y)}const g=f.attributes;for(let y=0;y<g.length;y++){const v=g[y];if(v.name.includes(":")&&!v.name.startsWith("xmlns:")){const k=v.name.split(":")[0];if(l||!o.has(k)){o.add(k);const w=t.get(k);w&&!n.has(k)&&n.set(k,w)}}}for(const y of i){const v=t.get(y);v&&!n.has(y)&&n.set(y,v)}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!==X.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===X.ELEMENT_NODE?e:e.documentElement;function i(n){if(n.nodeType===X.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===X.TEXT_NODE&&(f.nodeValue||"").trim().length>0){s=!0;break}for(const f of o)if(f.nodeType===X.ELEMENT_NODE){c=!0;break}for(let f=0;f<o.length;f++){const d=o[f];if(d.nodeType===X.TEXT_NODE){const p=d.nodeValue||"";d._originalText=p,p.includes(`
5
+ `)&&(l=!0)}else d.nodeType===X.ELEMENT_NODE&&i(d)}n._whitespace.hasMixedContent=s&&c,n._whitespace.hasExistingLinebreaks=l}}i(t)}canonicalize(e,t=new Map,i={isStartingNode:!0}){var n;return this.method.isCanonicalizationMethod==="c14n_exc"?this.canonicalizeExclusive(e,t,{inclusiveNamespacePrefixList:i.inclusiveNamespacePrefixList,isStartingNode:i.isStartingNode}):this.canonicalizeStandard(e,t,{isStartingNode:(n=i.isStartingNode)!=null?n:!0})}canonicalizeStandard(e,t=new Map,i={isStartingNode:!0}){var n,o,s;if(!e)return"";let c="";if(e.nodeType===X.ELEMENT_NODE){const l=new Map(t),f=e,d=f.getAttribute("xmlns");d!==null&&l.set("",d);const p=f.attributes;for(let x=0;x<p.length;x++){const T=p[x];if(T.name.startsWith("xmlns:")){const H=T.name.substring(6);l.set(H,T.value)}}const g=f.prefix||"",y=f.localName||f.nodeName.split(":").pop()||"",v=g?`${g}:${y}`:y;if(c+="<"+v,i.isStartingNode){const x=F.collectNamespaces(e),T=Array.from(x.entries()).sort((H,$)=>H[0]===""?-1:$[0]===""?1:H[0].localeCompare($[0]));for(const[H,$]of T)H===""?c+=` xmlns="${$}"`:c+=` xmlns:${H}="${$}"`}else{const x=Array.from(l.entries()).filter(([T,H])=>!t.has(T)||t.get(T)!==H).sort((T,H)=>T[0]===""?-1:H[0]===""?1:T[0].localeCompare(H[0]));for(const[T,H]of x)T===""?c+=` xmlns="${H}"`:c+=` xmlns:${T}="${H}"`}const k=f.attributes,w=[];for(let x=0;x<k.length;x++){const T=k[x];T.name.startsWith("xmlns")||w.push(T)}w.sort((x,T)=>x.name.localeCompare(T.name));for(const x of w)c+=` ${x.name}="${F.escapeXml(x.value)}"`;c+=">";const A=Array.from(e.childNodes);let I=!1,_e=!1;const re=((n=e._whitespace)==null?void 0:n.hasMixedContent)||!1;for(const x of A)if(x.nodeType===X.ELEMENT_NODE){I=!0;break}const de=this.method.isCanonicalizationMethod==="c14n11"&&I&&!((o=e._whitespace)!=null&&o.hasExistingLinebreaks)&&!re;de&&(c+=this.method.beforeChildren(I,re));for(let x=0;x<A.length;x++){const T=A[x],H=T.nodeType===X.ELEMENT_NODE,$=x<A.length-1?A[x+1]:null;if($&&($.nodeType,X.ELEMENT_NODE),T.nodeType===X.TEXT_NODE){const Q=T.nodeValue||"";F.isBase64Element(e)?c+=Q.replace(/\r/g,"&#xD;"):c+=T._originalText||Q,_e=!1;continue}H&&(_e&&this.method.isCanonicalizationMethod==="c14n11"&&!((s=e._whitespace)!=null&&s.hasExistingLinebreaks)&&!re&&(c+=this.method.betweenChildren(!0,!0,re)),c+=this.canonicalizeStandard(T,l,{isStartingNode:!1}),_e=!0)}de&&(c+=this.method.afterChildren(I,re)),c+="</"+v+">"}else if(e.nodeType===X.TEXT_NODE){const l=e._originalText||e.nodeValue||"";c+=F.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===X.ELEMENT_NODE){const c=e,l=F.collectNamespaces(c),f=o?F.collectUsedNamespaces(c,l,n):new Map,d=c.prefix||"",p=c.localName||c.nodeName.split(":").pop()||"",g=d?`${d}:${p}`:p;if(s+="<"+g,o){const w=Array.from(f.entries()).sort((A,I)=>A[0]===""?-1:I[0]===""?1:A[0].localeCompare(I[0]));for(const[A,I]of w)A===""?s+=` xmlns="${I}"`:s+=` xmlns:${A}="${I}"`}const y=c.attributes,v=[];for(let w=0;w<y.length;w++){const A=y[w];A.name.startsWith("xmlns")||v.push(A)}v.sort((w,A)=>w.name.localeCompare(A.name));for(const w of v)s+=` ${w.name}="${F.escapeXml(w.value)}"`;s+=">";const k=Array.from(e.childNodes);for(let w=0;w<k.length;w++){const A=k[w];if(A.nodeType===X.TEXT_NODE){const I=A.nodeValue||"";F.isBase64Element(e)?s+=I.replace(/\r/g,"&#xD;"):s+=F.escapeXml(I)}else A.nodeType===X.ELEMENT_NODE&&(s+=this.canonicalizeExclusive(A,new Map([...t,...f]),{inclusiveNamespacePrefixList:n,isStartingNode:!1}))}s+="</"+g+">"}else if(e.nodeType===X.TEXT_NODE){const c=e.nodeValue||"";s+=F.escapeXml(c)}return s}static c14n(e){return this.analyzeWhitespace(e),new F(Ct.c14n).canonicalize(e)}static c14n11(e){return this.analyzeWhitespace(e),new F(Ct.c14n11).canonicalize(e)}static c14n_exc(e,t=[]){return this.analyzeWhitespace(e),new F(Ct.c14n_exc).canonicalizeExclusive(e,new Map,{inclusiveNamespacePrefixList:t})}static canonicalize(e,t,i={}){switch(ot[t]||ot.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}`)}}}F.base64Elements=new Set(["DigestValue","X509Certificate","EncapsulatedTimeStamp","EncapsulatedOCSPValue","IssuerSerialV2"]);var Ba=(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 xa(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
6
  ${t.join(`
10
7
  `)}
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-----
8
+ -----END CERTIFICATE-----`}function co(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 d=r.subject;f.commonName=d.commonName,f.organization=d.organizationName,f.country=d.countryName}if(typeof r.issuer=="object"&&r.issuer!==null){const d=r.issuer;f.issuer.commonName=d.commonName,f.issuer.organization=d.organizationName,f.issuer.country=d.countryName}}catch(d){console.warn("Could not extract subject/issuer as objects:",d)}try{if(typeof r.subject=="string"){const d=r.subject.split(",");for(const p of d){const[g,y]=p.trim().split("=");g==="CN"&&(f.commonName=f.commonName||y),g==="O"&&(f.organization=f.organization||y),g==="C"&&(f.country=f.country||y),g==="SN"&&(f.surname=y),(g==="G"||g==="GN")&&(f.givenName=y),(g==="SERIALNUMBER"||g==="2.5.4.5")&&(f.serialNumber=y==null?void 0:y.replace("PNOLV-",""))}}if(typeof r.issuer=="string"){const d=r.issuer.split(",");for(const p of d){const[g,y]=p.trim().split("=");g==="CN"&&(f.issuer.commonName=f.issuer.commonName||y),g==="O"&&(f.issuer.organization=f.issuer.organization||y),g==="C"&&(f.issuer.country=f.issuer.country||y)}}}catch(d){console.warn("Could not extract subject/issuer as strings:",d)}try{if("subjectName"in r&&(e=r.subjectName)!=null&&e.getField){const d=r.subjectName;f.commonName=f.commonName||((t=d.getField("CN"))==null?void 0:t[0]),f.surname=f.surname||((i=d.getField("SN"))==null?void 0:i[0]),f.givenName=f.givenName||((n=d.getField("G"))==null?void 0:n[0]),f.serialNumber=f.serialNumber||((s=(o=d.getField("2.5.4.5"))==null?void 0:o[0])==null?void 0:s.replace("PNOLV-","")),f.country=f.country||((c=d.getField("C"))==null?void 0:c[0]),f.organization=f.organization||((l=d.getField("O"))==null?void 0:l[0])}}catch(d){console.warn("Could not extract fields using getField method:",d)}return!f.serialNumber&&r.serialNumber&&(f.serialNumber=r.serialNumber),f}function lo(r){return Ba(this,null,function*(){try{let e=r;if(!r.includes("-----BEGIN CERTIFICATE-----")){const n=r.replace(/[\r\n\s]/g,"");e=xa(n)}const t=new R.X509Certificate(e),i=co(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 Ca(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 Na(r){const{subject:e}=r;return e.givenName&&e.surname?`${e.givenName} ${e.surname}`:e.commonName?e.commonName:e.serialNumber||"Unknown Signer"}function Ea(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 ir(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
9
  ${t.join(`
13
10
  `)}
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};/*!
11
+ -----END CERTIFICATE-----`}var Ia=Object.defineProperty,Oa=Object.defineProperties,Ta=Object.getOwnPropertyDescriptors,uo=Object.getOwnPropertySymbols,Va=Object.prototype.hasOwnProperty,Ua=Object.prototype.propertyIsEnumerable,fo=(r,e,t)=>e in r?Ia(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,ho=(r,e)=>{for(var t in e||(e={}))Va.call(e,t)&&fo(r,t,e[t]);if(uo)for(var t of uo(e))Ua.call(e,t)&&fo(r,t,e[t]);return r},po=(r,e)=>Oa(r,Ta(e));function Ra(r){var e;if(!r)return;const t=W(r,"ec\\:InclusiveNamespaces, InclusiveNamespaces"),i=(e=t==null?void 0:t.getAttribute("PrefixList"))==null?void 0:e.trim();if(!i)return;const n=i.split(/\s+/).filter(Boolean);return n.length>0?n:void 0}function Da(r){if(!r)return new F;try{return F.fromMethod(r)}catch(e){return new F}}function ja(r){return Array.from(r.keys()).filter(e=>e.match(/META-INF\/signatures\d*\.xml$/)||e.match(/META-INF\/.*signatures.*\.xml$/i))}function La(r,e){const t=new TextDecoder().decode(r),i=oo().parseFromString(t,"application/xml"),n=rr(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=W(s,"ds\\:Signature, Signature");if(l){let f=yo(l,i);return f.rawXml=t,f}}const c=_a(t);if(c)return po(ho({},c),{rawXml:t})}return null}let o=yo(n[0],i);return o.rawXml=t,o}function yo(r,e){var t,i,n,o,s;const c=r.getAttribute("Id")||"unknown",l=W(r,"ds\\:SignedInfo, SignedInfo");if(!l)throw new Error("SignedInfo element not found");const f=W(l,"ds\\:CanonicalizationMethod, CanonicalizationMethod");let d=ot.default;f&&(d=f.getAttribute("Algorithm")||d);let p="";p=ka(l);const g=W(l,"ds\\:SignatureMethod, SignatureMethod"),y=(g==null?void 0:g.getAttribute("Algorithm"))||"",v=W(r,"ds\\:SignatureValue, SignatureValue"),k=((t=v==null?void 0:v.textContent)==null?void 0:t.replace(/\s+/g,""))||"";let w,A,I;const _e=W(e,"xades\\:SignatureTimeStamp, SignatureTimeStamp");if(_e){const M=W(_e,"ds\\:CanonicalizationMethod, CanonicalizationMethod");A=(M==null?void 0:M.getAttribute("Algorithm"))||void 0,I=Ra(M);const G=W(_e,"xades\\:EncapsulatedTimeStamp, EncapsulatedTimeStamp");G&&G.textContent&&(w=G.textContent.replace(/\s+/g,""))}let re;if(v)try{re=Da(A).canonicalize(v,new Map,{inclusiveNamespacePrefixList:I})}catch(M){}let de="",x="",T=[],H,$;const Q=W(r,"ds\\:KeyInfo, KeyInfo");if(Q){const M=W(Q,"ds\\:X509Data, X509Data");if(M){const G=rr(M,"ds\\:X509Certificate, X509Certificate");if(G.length>0){de=((i=G[0].textContent)==null?void 0:i.replace(/\s+/g,""))||"";for(let qe=1;qe<G.length;qe++){const Ee=((n=G[qe].textContent)==null?void 0:n.replace(/\s+/g,""))||"";Ee&&T.push(ir(Ee))}}}}if(!de){const M=W(r,"ds\\:X509Certificate, X509Certificate");M&&(de=((o=M.textContent)==null?void 0:o.replace(/\s+/g,""))||"")}const He=W(e,"xades\\:CertificateValues, CertificateValues");if(He){const M=rr(He,"xades\\:EncapsulatedX509Certificate, EncapsulatedX509Certificate");for(const G of M){const qe=((s=G.textContent)==null?void 0:s.replace(/\s+/g,""))||"";if(qe){const Ee=ir(qe);T.includes(Ee)||T.push(Ee)}}}if(de){x=ir(de);try{const M=new R.X509Certificate(x),G=M.publicKey.algorithm;$=po(ho({algorithm:G.name},"namedCurve"in G?{namedCurve:G.namedCurve}:{}),{rawData:M.publicKey.rawData}),H=co(M)}catch(M){console.error("Failed to extract certificate information:",M)}}const tr=W(e,"xades\\:SigningTime, SigningTime"),B=tr&&tr.textContent?new Date(tr.textContent.trim()):new Date,L=[],pe={},se={},Gl=rr(l,"ds\\:Reference, Reference");for(const M of Gl){const G=M.getAttribute("URI")||"",qe=M.getAttribute("Type")||"";if(!G||G.startsWith("#")||qe.includes("SignedProperties"))continue;let Ee=G;try{Ee=decodeURIComponent(G)}catch(ui){console.error(`Failed to decode URI: ${G}`,ui)}const ro=Ee.startsWith("./")?Ee.substring(2):Ee;L.push(ro);const ma=W(M,"ds\\:DigestMethod, DigestMethod");if(ma){const ui=ma.getAttribute("Algorithm");ui&&(se[ro]=ui)}const io=W(M,"ds\\:DigestValue, DigestValue");io&&io.textContent&&(pe[ro]=io.textContent.replace(/\s+/g,""))}return{id:c,signingTime:B,certificate:de,certificatePEM:x,certificateChain:T.length>0?T:void 0,publicKey:$,signerInfo:H,signedChecksums:pe,digestAlgorithms:se,references:L,algorithm:y,signatureValue:k,canonicalSignatureValue:re,signedInfoXml:p,canonicalizationMethod:d,signatureTimestamp:w}}function _a(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>/),d=f&&f[1]?new Date(f[1].trim()):new Date,p=[],g={},y=/<ds:Reference[^>]*URI=["']([^#][^"']*)["'][^>]*>[\s\S]*?<ds:DigestValue>([\s\S]*?)<\/ds:DigestValue>/g;let v;for(;(v=y.exec(r))!==null;)if(v[1]&&!v[1].startsWith("#")){const w=decodeURIComponent(v[1]);p.push(w),v[2]&&(g[w]=v[2].replace(/\s+/g,""))}const k=ir(s);return{id:t,signingTime:d,certificate:s,certificatePEM:k,signedChecksums:g,references:p,algorithm:l,signatureValue:n}}catch(e){return console.error("Error in fallback text parsing:",e),null}}function Ha(r){try{const e=q.unzipSync(r),t=new Map,i=[],n=[];Object.entries(e).forEach(([f,d])=>{t.set(f,d),f.startsWith("META-INF/")||f==="mimetype"?n.push(f):i.push(f)});const o=[],s=ja(t),c=new Set;for(const f of s){const d=t.get(f);if(d)try{const p=La(d,f);p&&(o.push(p),p.references&&p.references.length>0&&p.references.forEach(g=>{t.has(g)&&c.add(g)}))}catch(p){console.error(`Error parsing signature ${f}:`,p)}}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 $a(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 v=0;v<=t.length-i.length;v++){let k=!0;for(let w=0;w<i.length;w++)if(t[v+w]!==i[w]){k=!1;break}if(k){n=v;break}}if(n===-1)return r;let o=-1;for(let v=n+i.length;v<t.length;v++)if(t[v]===3){o=v;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 d=l+1+f;if(d>=t.length||t[d]!==2)return r;let p=0,g=0;if((t[d+1]&128)===0)g=t[d+1],p=1;else{const v=t[d+1]&127;p=1+v,g=0;for(let k=0;k<v;k++)g=g<<8|t[d+2+k]}const y=d+1+p;if(y>=t.length)return r;if((t[y]&128)!==0){const v=new Uint8Array(t.length+1);if(v.set(t.slice(0,y)),v[y]=0,v.set(t.slice(y),y+1),(t[d+1]&128)===0)v[d+1]=t[d+1]+1;else{const k=t[d+1]&127;let w=0;for(let A=0;A<k;A++)w=w<<8|t[d+2+A];w+=1;for(let A=k-1;A>=0;A--)v[d+2+A]=w&255,w>>=8}if((t[l+1]&128)===0)v[l+1]=t[l+1]+1;else{const k=t[l+1]&127;let w=0;for(let A=0;A<k;A++)w=w<<8|t[l+2+A];w+=1;for(let A=k-1;A>=0;A--)v[l+2+A]=w&255,w>>=8}if((t[o+1]&128)===0)v[o+1]=t[o+1]+1;else{const k=t[o+1]&127;let w=0;for(let A=0;A<k;A++)w=w<<8|t[o+2+A];w+=1;for(let A=k-1;A>=0;A--)v[o+2+A]=w&255,w>>=8}if((t[1]&128)===0)v[1]=t[1]+1;else{const k=t[1]&127;let w=0;for(let A=0;A<k;A++)w=w<<8|t[2+A];w+=1;for(let A=k-1;A>=0;A--)v[2+A]=w&255,w>>=8}return e("Fixed key length: "+v.length),v.buffer}return r}const Ma={ocspEnabled:!0,crlEnabled:!0,ocspTimeout:5e3,crlTimeout:1e4};/*!
15
12
  * MIT License
16
13
  *
17
14
  * Copyright (c) 2017-2024 Peculiar Ventures, LLC
@@ -34,9 +31,9 @@ ${t.join(`
34
31
  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
35
32
  * SOFTWARE.
36
33
  *
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}/*!
34
+ */const Pa="[object ArrayBuffer]";class E{static isArrayBuffer(e){return Object.prototype.toString.call(e)===Pa}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=E.toUint8Array(e),n=E.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 hi="string",qa=/^[0-9a-f\s]+$/i,Fa=/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/,za=/^[a-zA-Z0-9-_]+$/;class go{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=E.toUint8Array(e);let i="";for(let o=0;o<t.length;o++)i+=String.fromCharCode(t[o]);return decodeURIComponent(escape(i))}}class ke{static toString(e,t=!1){const i=E.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 _{static isHex(e){return typeof e===hi&&qa.test(e)}static isBase64(e){return typeof e===hi&&Fa.test(e)}static isBase64Url(e){return typeof e===hi&&za.test(e)}static ToString(e,t="utf8"){const i=E.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 ke.toString(i,!0);case"utf16":case"utf16be":return ke.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 ke.fromString(e,!0);case"utf16":case"utf16be":return ke.fromString(e);default:throw new Error(`Unknown type of encoding '${t}'`)}}static ToBase64(e){const t=E.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(!_.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(!_.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=_.DEFAULT_UTF8_ENCODING){switch(t){case"ascii":return this.FromBinary(e);case"utf8":return go.fromString(e);case"utf16":case"utf16be":return ke.fromString(e);case"utf16le":case"usc2":return ke.fromString(e,!0);default:throw new Error(`Unknown type of encoding '${t}'`)}}static ToUtf8String(e,t=_.DEFAULT_UTF8_ENCODING){switch(t){case"ascii":return this.ToBinary(e);case"utf8":return go.toString(e);case"utf16":case"utf16be":return ke.toString(e);case"utf16le":case"usc2":return ke.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=E.toUint8Array(e);let i="";for(let n=0;n<t.length;n++)i+=String.fromCharCode(t[n]);return i}static ToHex(e){const t=E.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(!_.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 ke.toString(e,t)}static FromUtf16String(e,t=!1){return ke.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,""))||""}}_.DEFAULT_UTF8_ENCODING="utf8";function Ga(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
35
  Copyright (c) Peculiar Ventures, LLC
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)}/*!
36
+ */function st(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 Fe(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 d=c-1;d>=0;d--){const p=Math.pow(2,d*e);f[o-d-1]=Math.floor(n/p),n-=f[o-d-1]*p}return l}s*=Math.pow(2,e)}return new ArrayBuffer(0)}function di(...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 mo(){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=st(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,st(o,8)-i}function Xa(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=Fe(s,8,i),l=new Uint8Array(c);return l[0]|=128,c}let n=Fe(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 Wa(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 ae(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
37
  * Copyright (c) 2014, GMO GlobalSign
41
38
  * Copyright (c) 2015-2022, Peculiar Ventures
42
39
  * All rights reserved.
@@ -68,15 +65,15 @@ ${t.join(`
68
65
  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
69
66
  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
70
67
  *
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(`
68
+ */function nr(){if(typeof BigInt=="undefined")throw new Error("BigInt is not defined. Your environment doesn't implement BigInt.")}function pi(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 Ie(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 or{constructor(){this.items=[]}write(e){this.items.push(e)}final(){return pi(this.items)}}const Nt=[new Uint8Array([1])],vo="0123456789",yi="name",wo="valueHexView",Ka="isHexOnly",Ja="idBlock",Za="tagClass",Ya="tagNumber",Qa="isConstructed",ec="fromBER",tc="toBER",rc="local",ie="",Be=new ArrayBuffer(0),sr=new Uint8Array(0),Et="EndOfContent",bo="OCTET STRING",Ao="BIT STRING";function xe(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?E.toUint8Array(o.valueHex):sr}fromBER(i,n,o){const s=i instanceof ArrayBuffer?new Uint8Array(i):i;if(!Ie(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",Be)}toJSON(){return z(D({},super.toJSON()),{isHexOnly:this.isHexOnly,valueHex:_.ToHex(this.valueHexView)})}},e.NAME="hexBlock",e}class ze{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=ie,warnings:i=[],valueBeforeDecode:n=sr}={}){this.blockLength=e,this.error=t,this.warnings=i,this.valueBeforeDecodeView=E.toUint8Array(n)}toJSON(){return{blockName:this.constructor.NAME,blockLength:this.blockLength,error:this.error,warnings:this.warnings,valueBeforeDecode:_.ToHex(this.valueBeforeDecodeView)}}}ze.NAME="baseBlock";class ee extends ze{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'")}}ee.NAME="valueBlock";class So extends xe(ze){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?E.toUint8Array(e.valueHex):sr,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",Be}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=Fe(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=E.toUint8Array(e);if(!Ie(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),d=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===d){d+=255;const g=new Uint8Array(d);for(let y=0;y<f.length;y++)g[y]=f[y];f=this.valueHexView=new Uint8Array(d)}}this.blockLength=l+1,f[l-1]=o[l]&127;const p=new Uint8Array(l);for(let g=0;g<l;g++)p[g]=f[g];f=this.valueHexView=new Uint8Array(l),f.set(p),this.blockLength<=9?this.tagNumber=st(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 z(D({},super.toJSON()),{tagClass:this.tagClass,tagNumber:this.tagNumber,isConstructed:this.isConstructed})}}So.NAME="identificationBlock";class ko extends ze{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=E.toUint8Array(e);if(!Ie(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=st(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=Fe(this.length,8);if(n.byteLength>127)return this.error="Too big length",Be;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 z(D({},super.toJSON()),{isIndefiniteForm:this.isIndefiniteForm,longFormUsed:this.longFormUsed,length:this.length})}}ko.NAME="lengthBlock";const b={};class K extends ze{constructor(s={},o){var c=s,{name:e=ie,optional:t=!1,primitiveSchema:i}=c,n=P(c,["name","optional","primitiveSchema"]);super(n),this.name=e,this.optional=t,i&&(this.primitiveSchema=i),this.idBlock=new So(n),this.lenBlock=new ko(n),this.valueBlock=o?new o(n):new ee(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 or;t||Bo(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?Be:i.final()}toJSON(){const e=z(D({},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():_.ToHex(this.toBER())}onAsciiEncoding(){const e=this.constructor.NAME,t=_.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 Wa(t,i)}}K.NAME="BaseBlock";function Bo(r){var e;if(r instanceof b.Constructed)for(const t of r.valueBlock.value)Bo(t)&&(r.lenBlock.isIndefiniteForm=!0);return!!(!((e=r.lenBlock)===null||e===void 0)&&e.isIndefiniteForm)}class gi extends K{getValue(){return this.valueBlock.value}setValue(e){this.valueBlock.value=e}constructor(n={},i){var o=n,{value:e=ie}=o,t=P(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}'`}}gi.NAME="BaseStringBlock";class xo extends xe(ee){constructor(i={}){var n=i,{isHexOnly:e=!0}=n,t=P(n,["isHexOnly"]);super(t),this.isHexOnly=e}}xo.NAME="PrimitiveValueBlock";var Co;class It extends K{constructor(e={}){super(e,xo),this.idBlock.isConstructed=!1}}Co=It,b.Primitive=Co,It.NAME="PRIMITIVE";function ic(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 at(r,e=0,t=r.length){const i=e;let n=new K({},ee);const o=new ze;if(!Ie(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=K;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;default:l=n.idBlock.isConstructed?b.Constructed:b.Primitive}return n=ic(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 ct(r){if(!r.byteLength){const e=new K({},ee);return e.error="Input buffer has zero length",{offset:-1,result:e}}return at(E.toUint8Array(r).slice(),0,r.byteLength)}function nc(r,e){return r?1:e}class $e extends ee{constructor(n={}){var o=n,{value:e=[],isIndefiniteForm:t=!1}=o,i=P(o,["value","isIndefiniteForm"]);super(i),this.value=e,this.isIndefiniteForm=t}fromBER(e,t,i){const n=E.toUint8Array(e);if(!Ie(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(;nc(this.isIndefiniteForm,i)>0;){const s=at(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===Et)break}return this.isIndefiniteForm&&(this.value[this.value.length-1].constructor.NAME===Et?this.value.pop():this.warnings.push("No EndOfContent block encoded")),o}toBER(e,t){const i=t||new or;for(let n=0;n<this.value.length;n++)this.value[n].toBER(e,i);return t?Be:i.final()}toJSON(){const e=z(D({},super.toJSON()),{isIndefiniteForm:this.isIndefiniteForm,value:[]});for(const t of this.value)e.value.push(t.toJSON());return e}}$e.NAME="ConstructedValueBlock";var No;class te extends K{constructor(e={}){super(e,$e),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
69
  `).map(n=>` ${n}`).join(`
73
70
  `));const t=this.idBlock.tagClass===3?`[${this.idBlock.tagNumber}]`:this.constructor.NAME;return e.length?`${t} :
74
71
  ${e.join(`
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}-----
72
+ `)}`:`${t} :`}}No=te,b.Constructed=No,te.NAME="CONSTRUCTED";class Eo extends ee{fromBER(e,t,i){return t}toBER(e){return Be}}Eo.override="EndOfContentValueBlock";var Io;class mi extends K{constructor(e={}){super(e,Eo),this.idBlock.tagClass=1,this.idBlock.tagNumber=0}}Io=mi,b.EndOfContent=Io,mi.NAME=Et;var Oo;class Ge extends K{constructor(e={}){super(e,ee),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}`}}Oo=Ge,b.Null=Oo,Ge.NAME="NULL";class To extends xe(ee){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=P(n,["value"]);super(t),t.valueHex?this.valueHexView=E.toUint8Array(t.valueHex):this.valueHexView=new Uint8Array(1),e&&(this.value=e)}fromBER(e,t,i){const n=E.toUint8Array(e);return Ie(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,mo.call(this),this.blockLength=i,t+i):-1}toBER(){return this.valueHexView.slice()}toJSON(){return z(D({},super.toJSON()),{value:this.value})}}To.NAME="BooleanValueBlock";var Vo;class ar extends K{getValue(){return this.valueBlock.value}setValue(e){this.valueBlock.value=e}constructor(e={}){super(e,To),this.idBlock.tagClass=1,this.idBlock.tagNumber=1}onAsciiEncoding(){return`${this.constructor.NAME} : ${this.getValue}`}}Vo=ar,b.Boolean=Vo,ar.NAME="BOOLEAN";class Uo extends xe($e){constructor(i={}){var n=i,{isConstructed:e=!1}=n,t=P(n,["isConstructed"]);super(t),this.isConstructed=e}fromBER(e,t,i){let n=0;if(this.isConstructed){if(this.isHexOnly=!1,n=$e.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===Et){if(this.isIndefiniteForm)break;return this.error="EndOfContent is unexpected, OCTET STRING may consists of OCTET STRINGs only",-1}if(s!==bo)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?$e.prototype.toBER.call(this,e,t):e?new ArrayBuffer(this.valueHexView.byteLength):this.valueHexView.slice().buffer}toJSON(){return z(D({},super.toJSON()),{isConstructed:this.isConstructed})}}Uo.NAME="OctetStringValueBlock";var vi;class Xe extends K{constructor(n={}){var o=n,{idBlock:e={},lenBlock:t={}}=o,i=P(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(D({idBlock:D({isConstructed:i.isConstructed},e),lenBlock:z(D({},t),{isIndefiniteForm:!!i.isIndefiniteForm})},i),Uo),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=at(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 te.prototype.onAsciiEncoding.call(this);const e=this.constructor.NAME,t=_.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 vi&&e.push(t.valueBlock.valueHexView);return E.concat(e)}}vi=Xe,b.OctetString=vi,Xe.NAME=bo;class Ro extends xe($e){constructor(n={}){var o=n,{unusedBits:e=0,isConstructed:t=!1}=o,i=P(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=$e.prototype.fromBER.call(this,e,t,i),n===-1)return n;for(const c of this.value){const l=c.constructor.NAME;if(l===Et){if(this.isIndefiniteForm)break;return this.error="EndOfContent is unexpected, BIT STRING may consists of BIT STRINGs only",-1}if(l!==Ao)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=E.toUint8Array(e);if(!Ie(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=at(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 $e.prototype.toBER.call(this,e,t);if(e)return new ArrayBuffer(this.valueHexView.byteLength+1);if(!this.valueHexView.byteLength){const n=new Uint8Array(1);return n[0]=0,n.buffer}const i=new Uint8Array(this.valueHexView.length+1);return i[0]=this.unusedBits,i.set(this.valueHexView,1),i.buffer}toJSON(){return z(D({},super.toJSON()),{unusedBits:this.unusedBits,isConstructed:this.isConstructed})}}Ro.NAME="BitStringValueBlock";var Do;class We extends K{constructor(n={}){var o=n,{idBlock:e={},lenBlock:t={}}=o,i=P(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(D({idBlock:D({isConstructed:i.isConstructed},e),lenBlock:z(D({},t),{isIndefiniteForm:!!i.isIndefiniteForm})},i),Ro),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 te.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}`}}}Do=We,b.BitString=Do,We.NAME=Ao;var jo;function oc(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 d=l<s?s:l;let p=0;for(let g=d;g>=0;g--,p++)!0===p<c.length?f=o[s-p]+c[l-p]+t[0]:f=o[s-p]+t[0],t[0]=f/10,!0===p>=o.length?o=di(new Uint8Array([f%10]),o):o[s-p]=f%10;return t[0]>0&&(o=di(t,o)),o}function Lo(r){if(r>=Nt.length)for(let e=Nt.length;e<=r;e++){const t=new Uint8Array([0]);let i=Nt[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=di(t,i)),Nt.push(i)}return Nt[r]}function sc(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,d=0;for(let p=l;p>=0;p--,d++)f=o[s-d]-c[l-d]-t,!0===f<0?(t=1,o[s-d]=f+10):(t=0,o[s-d]=f);if(t>0)for(let p=s-l+1;p>=0;p--,d++)if(f=o[s-d]-t,f<0)t=1,o[s-d]=f+10;else{t=0,o[s-d]=f;break}return o.slice()}class wi extends xe(ee){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=mo.call(this)))}constructor(i={}){var n=i,{value:e}=n,t=P(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(Xa(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 z(D({},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++)(n&1)===1&&(i===e?(t=sc(Lo(i),t),s="-"):t=oc(t,Lo(i))),i++,n>>=1}for(let l=0;l<t.length;l++)t[l]&&(c=!0),c&&(s+=vo.charAt(t[l]));return c===!1&&(s+=vo.charAt(0)),s}}jo=wi,wi.NAME="IntegerValueBlock",Object.defineProperty(jo.prototype,"valueHex",{set:function(r){this.valueHexView=new Uint8Array(r),this.setValueHex()},get:function(){return this.valueHexView.slice().buffer}});var Ot;class lt extends K{constructor(e={}){super(e,wi),this.idBlock.tagClass=1,this.idBlock.tagNumber=2}toBigInt(){return nr(),BigInt(this.valueBlock.toString())}static fromBigInt(e){nr();const t=BigInt(e),i=new or,n=t.toString(16).replace(/^-/,""),o=new Uint8Array(_.FromHex(n));if(t<0){const c=new Uint8Array(o.length+(o[0]&128?1:0));c[0]|=128;const f=BigInt(`0x${_.ToHex(c)}`)+t,d=E.toUint8Array(_.FromHex(f.toString(16)));d[0]|=128,i.write(d)}else o[0]&128&&i.write(new Uint8Array([0])),i.write(o);return new Ot({valueHex:i.final()})}convertToDER(){const e=new Ot({valueHex:this.valueBlock.valueHexView});return e.valueBlock.toDER(),e}convertFromDER(){return new Ot({valueHex:this.valueBlock.valueHexView[0]===0?this.valueBlock.valueHexView.subarray(1):this.valueBlock.valueHexView})}onAsciiEncoding(){return`${this.constructor.NAME} : ${this.valueBlock.toString()}`}}Ot=lt,b.Integer=Ot,lt.NAME="INTEGER";var _o;class cr extends lt{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=10}}_o=cr,b.Enumerated=_o,cr.NAME="ENUMERATED";class bi extends xe(ee){constructor(n={}){var o=n,{valueDec:e=-1,isFirstSid:t=!1}=o,i=P(o,["valueDec","isFirstSid"]);super(i),this.valueDec=e,this.isFirstSid=t}fromBER(e,t,i){if(!i)return t;const n=E.toUint8Array(e);if(!Ie(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=st(this.valueHexView,7):(this.isHexOnly=!0,this.warnings.push("Too big SID for decoding, hex only")),t+this.blockLength)}set valueBigInt(e){nr();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=Fe(this.valueDec,7);if(t.byteLength===0)return this.error="Error during encoding SID value",Be;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=_.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 z(D({},super.toJSON()),{valueDec:this.valueDec,isFirstSid:this.isFirstSid})}}bi.NAME="sidBlock";class Ho extends ee{constructor(i={}){var n=i,{value:e=ie}=n,t=P(n,["value"]);super(t),this.value=[],e&&this.fromString(e)}fromBER(e,t,i){let n=t;for(;i>0;){const o=new bi;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,Be;t.push(n)}return pi(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 bi;if(n>Number.MAX_SAFE_INTEGER){nr();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=z(D({},super.toJSON()),{value:this.toString(),sidArray:[]});for(let t=0;t<this.value.length;t++)e.sidArray.push(this.value[t].toJSON());return e}}Ho.NAME="ObjectIdentifierValueBlock";var $o;class lr extends K{getValue(){return this.valueBlock.toString()}setValue(e){this.valueBlock.fromString(e)}constructor(e={}){super(e,Ho),this.idBlock.tagClass=1,this.idBlock.tagNumber=6}onAsciiEncoding(){return`${this.constructor.NAME} : ${this.valueBlock.toString()||"empty"}`}toJSON(){return z(D({},super.toJSON()),{value:this.getValue()})}}$o=lr,b.ObjectIdentifier=$o,lr.NAME="OBJECT IDENTIFIER";class Ai extends xe(ze){constructor(i={}){var n=i,{valueDec:e=0}=n,t=P(n,["valueDec"]);super(t),this.valueDec=e}fromBER(e,t,i){if(i===0)return t;const n=E.toUint8Array(e);if(!Ie(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=st(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=Fe(this.valueDec,7);if(t.byteLength===0)return this.error="Error during encoding SID value",Be;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=_.ToHex(this.valueHexView):e=this.valueDec.toString(),e}toJSON(){return z(D({},super.toJSON()),{valueDec:this.valueDec})}}Ai.NAME="relativeSidBlock";class Mo extends ee{constructor(i={}){var n=i,{value:e=ie}=n,t=P(n,["value"]);super(t),this.value=[],e&&this.fromString(e)}fromBER(e,t,i){let n=t;for(;i>0;){const o=new Ai;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,Be;i.push(o)}return pi(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 Ai;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=z(D({},super.toJSON()),{value:this.toString(),sidArray:[]});for(let t=0;t<this.value.length;t++)e.sidArray.push(this.value[t].toJSON());return e}}Mo.NAME="RelativeObjectIdentifierValueBlock";var Po;class Si extends K{getValue(){return this.valueBlock.toString()}setValue(e){this.valueBlock.fromString(e)}constructor(e={}){super(e,Mo),this.idBlock.tagClass=1,this.idBlock.tagNumber=13}onAsciiEncoding(){return`${this.constructor.NAME} : ${this.valueBlock.toString()||"empty"}`}toJSON(){return z(D({},super.toJSON()),{value:this.getValue()})}}Po=Si,b.RelativeObjectIdentifier=Po,Si.NAME="RelativeObjectIdentifier";var qo;class ye extends te{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=16}}qo=ye,b.Sequence=qo,ye.NAME="SEQUENCE";var Fo;class Ce extends te{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=17}}Fo=Ce,b.Set=Fo,Ce.NAME="SET";class zo extends xe(ee){constructor(t={}){var e=P(t,[]);super(e),this.isHexOnly=!0,this.value=ie}toJSON(){return z(D({},super.toJSON()),{value:this.value})}}zo.NAME="StringValueBlock";class Go extends zo{}Go.NAME="SimpleStringValueBlock";class ce extends gi{constructor(t={}){var e=P(t,[]);super(e,Go)}fromBuffer(e){this.valueBlock.value=String.fromCharCode.apply(null,E.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}}ce.NAME="SIMPLE STRING";class Xo extends ce{fromBuffer(e){this.valueBlock.valueHexView=E.toUint8Array(e);try{this.valueBlock.value=_.ToUtf8String(e)}catch(t){this.warnings.push(`Error during "decodeURIComponent": ${t}, using raw string`),this.valueBlock.value=_.ToBinary(e)}}fromString(e){this.valueBlock.valueHexView=new Uint8Array(_.FromUtf8String(e)),this.valueBlock.value=e}}Xo.NAME="Utf8StringValueBlock";var Wo;class Oe extends Xo{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=12}}Wo=Oe,b.Utf8String=Wo,Oe.NAME="UTF8String";class Ko extends ce{fromBuffer(e){this.valueBlock.value=_.ToUtf16String(e),this.valueBlock.valueHexView=E.toUint8Array(e)}fromString(e){this.valueBlock.value=e,this.valueBlock.valueHexView=new Uint8Array(_.FromUtf16String(e))}}Ko.NAME="BmpStringValueBlock";var Jo;class ur extends Ko{constructor(t={}){var e=P(t,[]);super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=30}}Jo=ur,b.BmpString=Jo,ur.NAME="BMPString";class Zo extends ce{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=Fe(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}}Zo.NAME="UniversalStringValueBlock";var Yo;class fr extends Zo{constructor(t={}){var e=P(t,[]);super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=28}}Yo=fr,b.UniversalString=Yo,fr.NAME="UniversalString";var Qo;class hr extends ce{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=18}}Qo=hr,b.NumericString=Qo,hr.NAME="NumericString";var es;class dr extends ce{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=19}}es=dr,b.PrintableString=es,dr.NAME="PrintableString";var ts;class pr extends ce{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=20}}ts=pr,b.TeletexString=ts,pr.NAME="TeletexString";var rs;class yr extends ce{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=21}}rs=yr,b.VideotexString=rs,yr.NAME="VideotexString";var is;class gr extends ce{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=22}}is=gr,b.IA5String=is,gr.NAME="IA5String";var ns;class mr extends ce{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=25}}ns=mr,b.GraphicString=ns,mr.NAME="GraphicString";var os;class Tt extends ce{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=26}}os=Tt,b.VisibleString=os,Tt.NAME="VisibleString";var ss;class vr extends ce{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=27}}ss=vr,b.GeneralString=ss,vr.NAME="GeneralString";var as;class wr extends ce{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=29}}as=wr,b.CharacterString=as,wr.NAME="CharacterString";var cs;class Vt extends Tt{constructor(n={}){var o=n,{value:e,valueDate:t}=o,i=P(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,E.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]=ae(this.year<2e3?this.year-1900:this.year-2e3,2),t[1]=ae(this.month,2),t[2]=ae(this.day,2),t[3]=ae(this.hour,2),t[4]=ae(this.minute,2),t[5]=ae(this.second,2),t[6]="Z",t.join("")}return super.toString(e)}onAsciiEncoding(){return`${this.constructor.NAME} : ${this.toDate().toISOString()}`}toJSON(){return z(D({},super.toJSON()),{year:this.year,month:this.month,day:this.day,hour:this.hour,minute:this.minute,second:this.second})}}cs=Vt,b.UTCTime=cs,Vt.NAME="UTCTime";var ls;class br extends Vt{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 p=new Number(e[e.length-1]);if(isNaN(p.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 p=1,g=i.indexOf("+"),y="";if(g===-1&&(g=i.indexOf("-"),p=-1),g!==-1){if(y=i.substring(g+1),i=i.substring(0,g),y.length!==2&&y.length!==4)throw new Error("Wrong input string for conversion");let v=parseInt(y.substring(0,2),10);if(isNaN(v.valueOf()))throw new Error("Wrong input string for conversion");if(c=p*v,y.length===4){if(v=parseInt(y.substring(2,4),10),isNaN(v.valueOf()))throw new Error("Wrong input string for conversion");l=p*v}}}let f=i.indexOf(".");if(f===-1&&(f=i.indexOf(",")),f!==-1){const p=new Number(`0${i.substring(f)}`);if(isNaN(p.valueOf()))throw new Error("Wrong input string for conversion");o=p.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 p=60*o;this.minute=Math.floor(p),p=60*(p-this.minute),this.second=Math.floor(p),p=1e3*(p-this.second),this.millisecond=Math.floor(p)}break;case n.length===12:if(s=/(\d{4})(\d{2})(\d{2})(\d{2})(\d{2})/ig,f!==-1){let p=60*o;this.second=Math.floor(p),p=1e3*(p-this.second),this.millisecond=Math.floor(p)}break;case n.length===14:if(s=/(\d{4})(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})/ig,f!==-1){const p=1e3*o;this.millisecond=Math.floor(p)}break;default:throw new Error("Wrong input string for conversion")}const d=s.exec(n);if(d===null)throw new Error("Wrong input string for conversion");for(let p=1;p<d.length;p++)switch(p){case 1:this.year=parseInt(d[p],10);break;case 2:this.month=parseInt(d[p],10);break;case 3:this.day=parseInt(d[p],10);break;case 4:this.hour=parseInt(d[p],10)+c;break;case 5:this.minute=parseInt(d[p],10)+l;break;case 6:this.second=parseInt(d[p],10);break;default:throw new Error("Wrong input string for conversion")}if(t===!1){const p=new Date(this.year,this.month,this.day,this.hour,this.minute,this.second,this.millisecond);this.year=p.getUTCFullYear(),this.month=p.getUTCMonth(),this.day=p.getUTCDay(),this.hour=p.getUTCHours(),this.minute=p.getUTCMinutes(),this.second=p.getUTCSeconds(),this.millisecond=p.getUTCMilliseconds()}}toString(e="iso"){if(e==="iso"){const t=[];return t.push(ae(this.year,4)),t.push(ae(this.month,2)),t.push(ae(this.day,2)),t.push(ae(this.hour,2)),t.push(ae(this.minute,2)),t.push(ae(this.second,2)),this.millisecond!==0&&(t.push("."),t.push(ae(this.millisecond,3))),t.push("Z"),t.join("")}return super.toString(e)}toJSON(){return z(D({},super.toJSON()),{millisecond:this.millisecond})}}ls=br,b.GeneralizedTime=ls,br.NAME="GeneralizedTime";var us;class ki extends Oe{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=31}}us=ki,b.DATE=us,ki.NAME="DATE";var fs;class Bi extends Oe{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=32}}fs=Bi,b.TimeOfDay=fs,Bi.NAME="TimeOfDay";var hs;class xi extends Oe{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=33}}hs=xi,b.DateTime=hs,xi.NAME="DateTime";var ds;class Ci extends Oe{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=34}}ds=Ci,b.Duration=ds,Ci.NAME="Duration";var ps;class Ni extends Oe{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=14}}ps=Ni,b.TIME=ps,Ni.NAME="TIME";class Ke{constructor({name:e=ie,optional:t=!1}={}){this.name=e,this.optional=t}}class Ei extends Ke{constructor(i={}){var n=i,{value:e=[]}=n,t=P(n,["value"]);super(t),this.value=e}}class Ar extends Ke{constructor(n={}){var o=n,{value:e=new Ke,local:t=!1}=o,i=P(o,["value","local"]);super(i),this.value=e,this.local=t}}class ac{get data(){return this.dataView.slice().buffer}set data(e){this.dataView=E.toUint8Array(e)}constructor({data:e=sr}={}){this.dataView=E.toUint8Array(e)}fromBER(e,t,i){const n=t+i;return this.dataView=E.toUint8Array(e).subarray(t,n),n}toBER(e){return this.dataView.slice().buffer}}function Me(r,e,t){if(t instanceof Ei){for(const o of t.value)if(Me(r,e,o).verified)return{verified:!0,result:r};{const o={verified:!1,result:{error:"Wrong values for Choice type"}};return t.hasOwnProperty(yi)&&(o.name=t.name),o}}if(t instanceof Ke)return t.hasOwnProperty(yi)&&(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(!(ec in t.idBlock))return{verified:!1,result:{error:"Wrong ASN.1 schema"}};if(!(tc 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(Za)===!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(Ya)===!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(Qa)===!1)return{verified:!1,result:{error:"Wrong ASN.1 schema"}};if(t.idBlock.isConstructed!==e.idBlock.isConstructed)return{verified:!1,result:r};if(!(Ka 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(!(wo 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,ie),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 Ar&&(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,ie),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,ie),t.name&&(delete r[t.name],f.name=t.name)),f}}else if(t.valueBlock.value[0]instanceof Ar){if(s=Me(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,ie),t.name&&delete r[t.name]),s;if(yi in t.valueBlock.value[0]&&t.valueBlock.value[0].name.length>0){let f={};rc 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=Me(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,ie),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,ie),t.name&&(delete r[t.name],l.name=t.name)),l}return{verified:!0,result:r}}if(t.primitiveSchema&&wo in e.valueBlock){const o=at(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,ie),t.name&&(delete r[t.name],s.name=t.name)),s}return Me(r,o.result,t.primitiveSchema)}return{verified:!0,result:r}}function cc(r,e){if(!(e instanceof Object))return{verified:!1,result:{error:"Wrong ASN.1 schema type"}};const t=at(E.toUint8Array(r));return t.offset===-1?{verified:!1,result:t.result}:Me(t.result,t.result,e)}var ys=Object.freeze({__proto__:null,Any:Ke,BaseBlock:K,BaseStringBlock:gi,BitString:We,BmpString:ur,Boolean:ar,CharacterString:wr,Choice:Ei,Constructed:te,DATE:ki,DateTime:xi,Duration:Ci,EndOfContent:mi,Enumerated:cr,GeneralString:vr,GeneralizedTime:br,GraphicString:mr,HexBlock:xe,IA5String:gr,Integer:lt,Null:Ge,NumericString:hr,ObjectIdentifier:lr,OctetString:Xe,Primitive:It,PrintableString:dr,RawData:ac,RelativeObjectIdentifier:Si,Repeated:Ar,Sequence:ye,Set:Ce,TIME:Ni,TeletexString:pr,TimeOfDay:Bi,UTCTime:Vt,UniversalString:fr,Utf8String:Oe,ValueBlock:ee,VideotexString:yr,ViewWriter:or,VisibleString:Tt,compareSchema:Me,fromBER:ct,verifySchema:cc}),m;(function(r){r[r.Sequence=0]="Sequence",r[r.Set=1]="Set",r[r.Choice=2]="Choice"})(m||(m={}));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 Sr{constructor(e,t=0){if(this.unusedBits=0,this.value=new ArrayBuffer(0),e)if(typeof e=="number")this.fromNumber(e);else if(E.isBufferSource(e))this.unusedBits=t,this.value=E.toArrayBuffer(e);else throw TypeError("Unsupported type of 'params' argument for BitString")}fromASN(e){if(!(e instanceof We))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 We({unusedBits:this.unusedBits,valueHex:this.value})}toSchema(e){return new We({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 O{get byteLength(){return this.buffer.byteLength}get byteOffset(){return 0}constructor(e){typeof e=="number"?this.buffer=new ArrayBuffer(e):E.isBufferSource(e)?this.buffer=E.toArrayBuffer(e):Array.isArray(e)?this.buffer=new Uint8Array(e):this.buffer=new ArrayBuffer(0)}fromASN(e){if(!(e instanceof Xe))throw new TypeError("Argument 'asn' is not instance of ASN.1 OctetString");return this.buffer=e.valueBlock.valueHex,this}toASN(){return new Xe({valueHex:this.buffer})}toSchema(e){return new Xe({name:e})}}const lc={fromASN:r=>r instanceof Ge?null:r.valueBeforeDecodeView,toASN:r=>{if(r===null)return new Ge;const e=ct(r);if(e.result.error)throw new Error(e.result.error);return e.result}},uc={fromASN:r=>r.valueBlock.valueHexView.byteLength>=4?r.valueBlock.toString():r.valueBlock.valueDec,toASN:r=>new lt({value:+r})},fc={fromASN:r=>r.valueBlock.valueDec,toASN:r=>new cr({value:r})},le={fromASN:r=>r.valueBlock.valueHexView,toASN:r=>new lt({valueHex:r})},hc={fromASN:r=>r.valueBlock.valueHexView,toASN:r=>new We({valueHex:r})},dc={fromASN:r=>r.valueBlock.toString(),toASN:r=>new lr({value:r})},pc={fromASN:r=>r.valueBlock.value,toASN:r=>new ar({value:r})},Ii={fromASN:r=>r.valueBlock.valueHexView,toASN:r=>new Xe({valueHex:r})},yc={fromASN:r=>new O(r.getValue()),toASN:r=>r.toASN()};function fe(r){return{fromASN:e=>e.valueBlock.value,toASN:e=>new r({value:e})}}const gc=fe(Oe),mc=fe(ur),vc=fe(fr),wc=fe(hr),bc=fe(dr),Ac=fe(pr),Sc=fe(yr),kc=fe(gr),Bc=fe(mr),xc=fe(Tt),Cc=fe(vr),Nc=fe(wr),Ec={fromASN:r=>r.toDate(),toASN:r=>new Vt({valueDate:r})},Ic={fromASN:r=>r.toDate(),toASN:r=>new br({valueDate:r})},Oc={fromASN:()=>null,toASN:()=>new Ge};function Ut(r){switch(r){case h.Any:return lc;case h.BitString:return hc;case h.BmpString:return mc;case h.Boolean:return pc;case h.CharacterString:return Nc;case h.Enumerated:return fc;case h.GeneralString:return Cc;case h.GeneralizedTime:return Ic;case h.GraphicString:return Bc;case h.IA5String:return kc;case h.Integer:return uc;case h.Null:return Oc;case h.NumericString:return wc;case h.ObjectIdentifier:return dc;case h.OctetString:return Ii;case h.PrintableString:return bc;case h.TeletexString:return Ac;case h.UTCTime:return Ec;case h.UniversalString:return vc;case h.Utf8String:return gc;case h.VideotexString:return Sc;case h.VisibleString:return xc;default:return null}}function Te(r){return typeof r=="function"&&r.prototype?r.prototype.toASN&&r.prototype.fromASN?!0:Te(r.prototype):!!(r&&typeof r=="object"&&"toASN"in r&&"fromASN"in r)}function gs(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:gs(t)}return!1}function Tc(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 Vc{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:m.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 d=h[s.type],p=ys[d];if(!p)throw new Error(`Cannot get ASN1 class by name '${d}'`);l=new p({name:c})}else Te(s.type)?l=new s.type().toSchema(c):s.optional?this.get(s.type).type===m.Choice?l=new Ke({name:c}):(l=this.create(s.type,!1),l.name=c):l=new Ke({name:c});const f=!!s.optional||s.defaultValue!==void 0;if(s.repeated){l.name="";const d=s.repeated==="set"?Ce:ye;l=new d({name:"",value:[new Ar({name:c,value:l})]})}if(s.context!==null&&s.context!==void 0)if(s.implicit)if(typeof s.type=="number"||Te(s.type)){const d=s.repeated?te:It;n.push(new d({name:c,optional:f,idBlock:{tagClass:3,tagNumber:s.context}}))}else{this.cache(s.type);const d=!!s.repeated;let p=d?l:this.get(s.type,!0).schema;p="valueBlock"in p?p.valueBlock.value:p.value,n.push(new te({name:d?"":c,optional:f,idBlock:{tagClass:3,tagNumber:s.context},value:p}))}else n.push(new te({optional:f,idBlock:{tagClass:3,tagNumber:s.context},value:[l]}));else l.optional=f,n.push(l)}switch(i.type){case m.Sequence:return new ye({value:n,name:""});case m.Set:return new Ce({value:n,name:""});case m.Choice:return new Ei({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 J=new Vc,S=r=>e=>{let t;J.has(e)?t=J.get(e):(t=J.createDefault(e),J.set(e,t)),Object.assign(t,r)},u=r=>(e,t)=>{let i;J.has(e.constructor)?i=J.get(e.constructor):(i=J.createDefault(e.constructor),J.set(e.constructor,i));const n=Object.assign({},r);if(typeof n.type=="number"&&!n.converter){const o=Ut(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 Rt extends Error{constructor(){super(...arguments),this.schemas=[]}}class ms{static parse(e,t){const i=ct(e);if(i.result.error)throw new Error(i.result.error);return this.fromASN(i.result,t)}static fromASN(e,t){try{if(Te(t))return new t().fromASN(e);const i=J.get(t);J.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 gs(t)?this.handleArrayTypes(e,i,t):(this.processSchemaItems(i,s,c),c)}catch(i){throw i instanceof Rt&&i.schemas.push(t.name),i}}static handleChoiceTypes(e,t,i,n){if(e.constructor===te&&t.type===m.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"&&J.has(s.type)){const c=J.get(s.type);if(c&&c.type===m.Sequence){const l=new ye;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),d=new i;return d[o]=f,{result:d}}}}}else if(e.constructor===te&&t.type!==m.Choice){const o=new te({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===m.Sequence){const o=Me({},e,n);if(!o.verified)throw new Rt(`Data does not match to ${i.name} ASN1 schema.${o.result.error?` ${o.result.error}`:""}`);return o}else{const o=Me({},e,n);if(!o.verified)throw new Rt(`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=Ut(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=Ut(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"&&J.has(e.type)&&J.get(e.type).type===m.Choice}static processOptionalChoiceField(e,t){try{return{processed:!0,value:this.fromASN(e,t.type)}}catch(i){if(i instanceof Rt&&/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=Ut(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"||Te(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:Te(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"?ye:Ce,o=new n;o.valueBlock=e.valueBlock;const s=ct(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(Te(i))s=new i().toSchema("");else{const c=h[i],l=ys[c];if(!l)throw new Error(`Cannot get '${c}' class from asn1js module`);s=new l}s.valueBlock=o.valueBlock,o=ct(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 Rt&&/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=J.get(i);if(n.type===m.Sequence){const o=new ye;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===m.Set){const o=new Ce;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 Oi{static serialize(e){return e instanceof K?e.toBER(!1):this.toASN(e).toBER(!1)}static toASN(e){if(e&&typeof e=="object"&&Te(e))return e.toASN();if(!(e&&typeof e=="object"))throw new TypeError("Parameter 1 should be type of Object.");const t=e.constructor,i=J.get(t);J.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=Ut(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"&&Tc(this.serialize(c.defaultValue),this.serialize(l)))continue;const f=Oi.toAsnItem(c,s,t,l);if(typeof c.context=="number")if(c.implicit)if(!c.repeated&&(typeof c.type=="number"||Te(c.type))){const d={};d.valueHex=f instanceof Ge?f.valueBeforeDecodeView:f.valueBlock.toBER(),n.push(new It(D({optional:c.optional,idBlock:{tagClass:3,tagNumber:c.context}},d)))}else n.push(new te({optional:c.optional,idBlock:{tagClass:3,tagNumber:c.context},value:f.valueBlock.value}));else n.push(new te({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 m.Sequence:o=new ye({value:n});break;case m.Set:o=new Ce({value:n});break;case m.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"?ye:Ce;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"?ye:Ce;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 ge{static serialize(e){return Oi.serialize(e)}static parse(e,t){return ms.parse(e,t)}static toString(e){const t=E.isBufferSource(e)?E.toArrayBuffer(e):ge.serialize(e),i=ct(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 Ti;let vs=Ti=class extends j{constructor(e){super(e),Object.setPrototypeOf(this,Ti.prototype)}};vs=Ti=a([S({type:m.Sequence,itemType:h.ObjectIdentifier})],vs);let Vi=class{constructor(e=new Date){this.value=e}};a([u({type:h.GeneralizedTime})],Vi.prototype,"value",void 0),Vi=a([S({type:m.Choice})],Vi);let Ui=class{constructor(e=null){this.value=e}};a([u({type:h.Null})],Ui.prototype,"value",void 0),Ui=a([S({type:m.Choice})],Ui);class ws{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(_.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 Ri,Di,ji;let me=class{constructor(e={}){Object.assign(this,e)}toString(){return this.bmpString||this.printableString||this.teletexString||this.universalString||this.utf8String||""}};a([u({type:h.TeletexString})],me.prototype,"teletexString",void 0),a([u({type:h.PrintableString})],me.prototype,"printableString",void 0),a([u({type:h.UniversalString})],me.prototype,"universalString",void 0),a([u({type:h.Utf8String})],me.prototype,"utf8String",void 0),a([u({type:h.BmpString})],me.prototype,"bmpString",void 0),me=a([S({type:m.Choice})],me);let ut=class extends me{constructor(e={}){super(e),Object.assign(this,e)}toString(){return this.ia5String||(this.anyValue?_.ToHex(this.anyValue):super.toString())}};a([u({type:h.IA5String})],ut.prototype,"ia5String",void 0),a([u({type:h.Any})],ut.prototype,"anyValue",void 0),ut=a([S({type:m.Choice})],ut);class Li{constructor(e={}){this.type="",this.value=new ut,Object.assign(this,e)}}a([u({type:h.ObjectIdentifier})],Li.prototype,"type",void 0),a([u({type:ut})],Li.prototype,"value",void 0);let kr=Ri=class extends j{constructor(e){super(e),Object.setPrototypeOf(this,Ri.prototype)}};kr=Ri=a([S({type:m.Set,itemType:Li})],kr);let _i=Di=class extends j{constructor(e){super(e),Object.setPrototypeOf(this,Di.prototype)}};_i=Di=a([S({type:m.Sequence,itemType:kr})],_i);let ne=ji=class extends _i{constructor(e){super(e),Object.setPrototypeOf(this,ji.prototype)}};ne=ji=a([S({type:m.Sequence})],ne);const Uc={fromASN:r=>ws.toString(Ii.fromASN(r)),toASN:r=>Ii.toASN(ws.fromString(r))};class Hi{constructor(e={}){this.typeId="",this.value=new ArrayBuffer(0),Object.assign(this,e)}}a([u({type:h.ObjectIdentifier})],Hi.prototype,"typeId",void 0),a([u({type:h.Any,context:0})],Hi.prototype,"value",void 0);class $i{constructor(e={}){this.partyName=new me,Object.assign(this,e)}}a([u({type:me,optional:!0,context:0,implicit:!0})],$i.prototype,"nameAssigner",void 0),a([u({type:me,context:1,implicit:!0})],$i.prototype,"partyName",void 0);let V=class{constructor(e={}){Object.assign(this,e)}};a([u({type:Hi,context:0,implicit:!0})],V.prototype,"otherName",void 0),a([u({type:h.IA5String,context:1,implicit:!0})],V.prototype,"rfc822Name",void 0),a([u({type:h.IA5String,context:2,implicit:!0})],V.prototype,"dNSName",void 0),a([u({type:h.Any,context:3,implicit:!0})],V.prototype,"x400Address",void 0),a([u({type:ne,context:4,implicit:!1})],V.prototype,"directoryName",void 0),a([u({type:$i,context:5})],V.prototype,"ediPartyName",void 0),a([u({type:h.IA5String,context:6,implicit:!0})],V.prototype,"uniformResourceIdentifier",void 0),a([u({type:h.OctetString,context:7,implicit:!0,converter:Uc})],V.prototype,"iPAddress",void 0),a([u({type:h.ObjectIdentifier,context:8,implicit:!0})],V.prototype,"registeredID",void 0),V=a([S({type:m.Choice})],V);var Mi;class Br{constructor(e={}){this.accessMethod="",this.accessLocation=new V,Object.assign(this,e)}}a([u({type:h.ObjectIdentifier})],Br.prototype,"accessMethod",void 0),a([u({type:V})],Br.prototype,"accessLocation",void 0);let xr=Mi=class extends j{constructor(e){super(e),Object.setPrototypeOf(this,Mi.prototype)}};xr=Mi=a([S({type:m.Sequence,itemType:Br})],xr);class bs extends O{}class Pi{constructor(e={}){e&&Object.assign(this,e)}}a([u({type:bs,context:0,optional:!0,implicit:!0})],Pi.prototype,"keyIdentifier",void 0),a([u({type:V,context:1,optional:!0,implicit:!0,repeated:"sequence"})],Pi.prototype,"authorityCertIssuer",void 0),a([u({type:h.Integer,context:2,optional:!0,implicit:!0,converter:le})],Pi.prototype,"authorityCertSerialNumber",void 0);class As{constructor(e={}){this.cA=!1,Object.assign(this,e)}}a([u({type:h.Boolean,defaultValue:!1})],As.prototype,"cA",void 0),a([u({type:h.Integer,optional:!0})],As.prototype,"pathLenConstraint",void 0);var qi;let ve=qi=class extends j{constructor(e){super(e),Object.setPrototypeOf(this,qi.prototype)}};ve=qi=a([S({type:m.Sequence,itemType:V})],ve);var Fi;let Ss=Fi=class extends ve{constructor(e){super(e),Object.setPrototypeOf(this,Fi.prototype)}};Ss=Fi=a([S({type:m.Sequence})],Ss);var zi;let Ve=class{constructor(e={}){Object.assign(this,e)}toString(){return this.ia5String||this.visibleString||this.bmpString||this.utf8String||""}};a([u({type:h.IA5String})],Ve.prototype,"ia5String",void 0),a([u({type:h.VisibleString})],Ve.prototype,"visibleString",void 0),a([u({type:h.BmpString})],Ve.prototype,"bmpString",void 0),a([u({type:h.Utf8String})],Ve.prototype,"utf8String",void 0),Ve=a([S({type:m.Choice})],Ve);class Gi{constructor(e={}){this.organization=new Ve,this.noticeNumbers=[],Object.assign(this,e)}}a([u({type:Ve})],Gi.prototype,"organization",void 0),a([u({type:h.Integer,repeated:"sequence"})],Gi.prototype,"noticeNumbers",void 0);class Xi{constructor(e={}){Object.assign(this,e)}}a([u({type:Gi,optional:!0})],Xi.prototype,"noticeRef",void 0),a([u({type:Ve,optional:!0})],Xi.prototype,"explicitText",void 0);let Cr=class{constructor(e={}){Object.assign(this,e)}};a([u({type:h.IA5String})],Cr.prototype,"cPSuri",void 0),a([u({type:Xi})],Cr.prototype,"userNotice",void 0),Cr=a([S({type:m.Choice})],Cr);class Wi{constructor(e={}){this.policyQualifierId="",this.qualifier=new ArrayBuffer(0),Object.assign(this,e)}}a([u({type:h.ObjectIdentifier})],Wi.prototype,"policyQualifierId",void 0),a([u({type:h.Any})],Wi.prototype,"qualifier",void 0);class Ki{constructor(e={}){this.policyIdentifier="",Object.assign(this,e)}}a([u({type:h.ObjectIdentifier})],Ki.prototype,"policyIdentifier",void 0),a([u({type:Wi,repeated:"sequence",optional:!0})],Ki.prototype,"policyQualifiers",void 0);let ks=zi=class extends j{constructor(e){super(e),Object.setPrototypeOf(this,zi.prototype)}};ks=zi=a([S({type:m.Sequence,itemType:Ki})],ks);let Nr=class{constructor(e=0){this.value=e}};a([u({type:h.Integer})],Nr.prototype,"value",void 0),Nr=a([S({type:m.Choice})],Nr);let Bs=class extends Nr{};Bs=a([S({type:m.Choice})],Bs);var Ji,we;(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"})(we||(we={}));class xs extends Sr{toJSON(){const e=[],t=this.toNumber();return t&we.aACompromise&&e.push("aACompromise"),t&we.affiliationChanged&&e.push("affiliationChanged"),t&we.cACompromise&&e.push("cACompromise"),t&we.certificateHold&&e.push("certificateHold"),t&we.cessationOfOperation&&e.push("cessationOfOperation"),t&we.keyCompromise&&e.push("keyCompromise"),t&we.privilegeWithdrawn&&e.push("privilegeWithdrawn"),t&we.superseded&&e.push("superseded"),t&we.unused&&e.push("unused"),e}toString(){return`[${this.toJSON().join(", ")}]`}}let ft=class{constructor(e={}){Object.assign(this,e)}};a([u({type:V,context:0,repeated:"sequence",implicit:!0})],ft.prototype,"fullName",void 0),a([u({type:kr,context:1,implicit:!0})],ft.prototype,"nameRelativeToCRLIssuer",void 0),ft=a([S({type:m.Choice})],ft);class Dt{constructor(e={}){Object.assign(this,e)}}a([u({type:ft,context:0,optional:!0})],Dt.prototype,"distributionPoint",void 0),a([u({type:xs,context:1,optional:!0,implicit:!0})],Dt.prototype,"reasons",void 0),a([u({type:V,context:2,optional:!0,repeated:"sequence",implicit:!0})],Dt.prototype,"cRLIssuer",void 0);let Zi=Ji=class extends j{constructor(e){super(e),Object.setPrototypeOf(this,Ji.prototype)}};Zi=Ji=a([S({type:m.Sequence,itemType:Dt})],Zi);var Yi;let Cs=Yi=class extends Zi{constructor(e){super(e),Object.setPrototypeOf(this,Yi.prototype)}};Cs=Yi=a([S({type:m.Sequence,itemType:Dt})],Cs);class Z{constructor(e={}){this.onlyContainsUserCerts=Z.ONLY,this.onlyContainsCACerts=Z.ONLY,this.indirectCRL=Z.ONLY,this.onlyContainsAttributeCerts=Z.ONLY,Object.assign(this,e)}}Z.ONLY=!1,a([u({type:ft,context:0,optional:!0})],Z.prototype,"distributionPoint",void 0),a([u({type:h.Boolean,context:1,defaultValue:Z.ONLY,implicit:!0})],Z.prototype,"onlyContainsUserCerts",void 0),a([u({type:h.Boolean,context:2,defaultValue:Z.ONLY,implicit:!0})],Z.prototype,"onlyContainsCACerts",void 0),a([u({type:xs,context:3,optional:!0,implicit:!0})],Z.prototype,"onlySomeReasons",void 0),a([u({type:h.Boolean,context:4,defaultValue:Z.ONLY,implicit:!0})],Z.prototype,"indirectCRL",void 0),a([u({type:h.Boolean,context:5,defaultValue:Z.ONLY,implicit:!0})],Z.prototype,"onlyContainsAttributeCerts",void 0);var jt;(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"})(jt||(jt={}));let Er=class{constructor(e=jt.unspecified){this.reason=jt.unspecified,this.reason=e}toJSON(){return jt[this.reason]}toString(){return this.toJSON()}};a([u({type:h.Enumerated})],Er.prototype,"reason",void 0),Er=a([S({type:m.Choice})],Er);var Qi;let Ns=Qi=class extends j{constructor(e){super(e),Object.setPrototypeOf(this,Qi.prototype)}};Ns=Qi=a([S({type:m.Sequence,itemType:h.ObjectIdentifier})],Ns);let en=class{constructor(e=new ArrayBuffer(0)){this.value=e}};a([u({type:h.Integer,converter:le})],en.prototype,"value",void 0),en=a([S({type:m.Choice})],en);let tn=class{constructor(e){this.value=new Date,e&&(this.value=e)}};a([u({type:h.GeneralizedTime})],tn.prototype,"value",void 0),tn=a([S({type:m.Choice})],tn);var rn;let Es=rn=class extends ve{constructor(e){super(e),Object.setPrototypeOf(this,rn.prototype)}};Es=rn=a([S({type:m.Sequence})],Es);var Is;(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"})(Is||(Is={}));var nn;class Ir{constructor(e={}){this.base=new V,this.minimum=0,Object.assign(this,e)}}a([u({type:V})],Ir.prototype,"base",void 0),a([u({type:h.Integer,context:0,defaultValue:0,implicit:!0})],Ir.prototype,"minimum",void 0),a([u({type:h.Integer,context:1,optional:!0,implicit:!0})],Ir.prototype,"maximum",void 0);let Or=nn=class extends j{constructor(e){super(e),Object.setPrototypeOf(this,nn.prototype)}};Or=nn=a([S({type:m.Sequence,itemType:Ir})],Or);class Os{constructor(e={}){Object.assign(this,e)}}a([u({type:Or,context:0,optional:!0,implicit:!0})],Os.prototype,"permittedSubtrees",void 0),a([u({type:Or,context:1,optional:!0,implicit:!0})],Os.prototype,"excludedSubtrees",void 0);class Ts{constructor(e={}){Object.assign(this,e)}}a([u({type:h.Integer,context:0,implicit:!0,optional:!0,converter:le})],Ts.prototype,"requireExplicitPolicy",void 0),a([u({type:h.Integer,context:1,implicit:!0,optional:!0,converter:le})],Ts.prototype,"inhibitPolicyMapping",void 0);var on;class sn{constructor(e={}){this.issuerDomainPolicy="",this.subjectDomainPolicy="",Object.assign(this,e)}}a([u({type:h.ObjectIdentifier})],sn.prototype,"issuerDomainPolicy",void 0),a([u({type:h.ObjectIdentifier})],sn.prototype,"subjectDomainPolicy",void 0);let Vs=on=class extends j{constructor(e){super(e),Object.setPrototypeOf(this,on.prototype)}};Vs=on=a([S({type:m.Sequence,itemType:sn})],Vs);var an;let Us=an=class extends ve{constructor(e){super(e),Object.setPrototypeOf(this,an.prototype)}};Us=an=a([S({type:m.Sequence})],Us);class Lt{constructor(e={}){this.type="",this.values=[],Object.assign(this,e)}}a([u({type:h.ObjectIdentifier})],Lt.prototype,"type",void 0),a([u({type:h.Any,repeated:"set"})],Lt.prototype,"values",void 0);var cn;let Rs=cn=class extends j{constructor(e){super(e),Object.setPrototypeOf(this,cn.prototype)}};Rs=cn=a([S({type:m.Sequence,itemType:Lt})],Rs);class _t extends bs{}class Ds{constructor(e={}){Object.assign(this,e)}}a([u({type:h.GeneralizedTime,context:0,implicit:!0,optional:!0})],Ds.prototype,"notBefore",void 0),a([u({type:h.GeneralizedTime,context:1,implicit:!0,optional:!0})],Ds.prototype,"notAfter",void 0);var Ht;(function(r){r[r.keyUpdateAllowed=1]="keyUpdateAllowed",r[r.newExtensions=2]="newExtensions",r[r.pKIXCertificate=4]="pKIXCertificate"})(Ht||(Ht={}));class js extends Sr{toJSON(){const e=[],t=this.toNumber();return t&Ht.pKIXCertificate&&e.push("pKIXCertificate"),t&Ht.newExtensions&&e.push("newExtensions"),t&Ht.keyUpdateAllowed&&e.push("keyUpdateAllowed"),e}toString(){return`[${this.toJSON().join(", ")}]`}}class Ls{constructor(e={}){this.entrustVers="",this.entrustInfoFlags=new js,Object.assign(this,e)}}a([u({type:h.GeneralString})],Ls.prototype,"entrustVers",void 0),a([u({type:js})],Ls.prototype,"entrustInfoFlags",void 0);var ln;let _s=ln=class extends j{constructor(e){super(e),Object.setPrototypeOf(this,ln.prototype)}};_s=ln=a([S({type:m.Sequence,itemType:Br})],_s);class C{constructor(e={}){this.algorithm="",Object.assign(this,e)}isEqual(e){return e instanceof C&&e.algorithm==this.algorithm&&(e.parameters&&this.parameters&&Ga(e.parameters,this.parameters)||e.parameters===this.parameters)}}a([u({type:h.ObjectIdentifier})],C.prototype,"algorithm",void 0),a([u({type:h.Any,optional:!0})],C.prototype,"parameters",void 0);class Tr{constructor(e={}){this.algorithm=new C,this.subjectPublicKey=new ArrayBuffer(0),Object.assign(this,e)}}a([u({type:C})],Tr.prototype,"algorithm",void 0),a([u({type:h.BitString})],Tr.prototype,"subjectPublicKey",void 0);let Y=class{constructor(e){if(e)if(typeof e=="string"||typeof e=="number"||e instanceof Date){const t=new Date(e);t.setMilliseconds(0),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})],Y.prototype,"utcTime",void 0),a([u({type:h.GeneralizedTime})],Y.prototype,"generalTime",void 0),Y=a([S({type:m.Choice})],Y);class Vr{constructor(e){this.notBefore=new Y(new Date),this.notAfter=new Y(new Date),e&&(this.notBefore=new Y(e.notBefore),this.notAfter=new Y(e.notAfter))}}a([u({type:Y})],Vr.prototype,"notBefore",void 0),a([u({type:Y})],Vr.prototype,"notAfter",void 0);var un;class oe{constructor(e={}){this.extnID="",this.critical=oe.CRITICAL,this.extnValue=new O,Object.assign(this,e)}}oe.CRITICAL=!1,a([u({type:h.ObjectIdentifier})],oe.prototype,"extnID",void 0),a([u({type:h.Boolean,defaultValue:oe.CRITICAL})],oe.prototype,"critical",void 0),a([u({type:O})],oe.prototype,"extnValue",void 0);let ht=un=class extends j{constructor(e){super(e),Object.setPrototypeOf(this,un.prototype)}};ht=un=a([S({type:m.Sequence,itemType:oe})],ht);var Ur;(function(r){r[r.v1=0]="v1",r[r.v2=1]="v2",r[r.v3=2]="v3"})(Ur||(Ur={}));class he{constructor(e={}){this.version=Ur.v1,this.serialNumber=new ArrayBuffer(0),this.signature=new C,this.issuer=new ne,this.validity=new Vr,this.subject=new ne,this.subjectPublicKeyInfo=new Tr,Object.assign(this,e)}}a([u({type:h.Integer,context:0,defaultValue:Ur.v1})],he.prototype,"version",void 0),a([u({type:h.Integer,converter:le})],he.prototype,"serialNumber",void 0),a([u({type:C})],he.prototype,"signature",void 0),a([u({type:ne})],he.prototype,"issuer",void 0),a([u({type:Vr})],he.prototype,"validity",void 0),a([u({type:ne})],he.prototype,"subject",void 0),a([u({type:Tr})],he.prototype,"subjectPublicKeyInfo",void 0),a([u({type:h.BitString,context:1,implicit:!0,optional:!0})],he.prototype,"issuerUniqueID",void 0),a([u({type:h.BitString,context:2,implicit:!0,optional:!0})],he.prototype,"subjectUniqueID",void 0),a([u({type:ht,context:3,optional:!0})],he.prototype,"extensions",void 0);class Je{constructor(e={}){this.tbsCertificate=new he,this.signatureAlgorithm=new C,this.signatureValue=new ArrayBuffer(0),Object.assign(this,e)}}a([u({type:he,raw:!0})],Je.prototype,"tbsCertificate",void 0),a([u({type:C})],Je.prototype,"signatureAlgorithm",void 0),a([u({type:h.BitString})],Je.prototype,"signatureValue",void 0);class Rr{constructor(e={}){this.userCertificate=new ArrayBuffer(0),this.revocationDate=new Y,Object.assign(this,e)}}a([u({type:h.Integer,converter:le})],Rr.prototype,"userCertificate",void 0),a([u({type:Y})],Rr.prototype,"revocationDate",void 0),a([u({type:oe,optional:!0,repeated:"sequence"})],Rr.prototype,"crlEntryExtensions",void 0);class Ue{constructor(e={}){this.signature=new C,this.issuer=new ne,this.thisUpdate=new Y,Object.assign(this,e)}}a([u({type:h.Integer,optional:!0})],Ue.prototype,"version",void 0),a([u({type:C})],Ue.prototype,"signature",void 0),a([u({type:ne})],Ue.prototype,"issuer",void 0),a([u({type:Y})],Ue.prototype,"thisUpdate",void 0),a([u({type:Y,optional:!0})],Ue.prototype,"nextUpdate",void 0),a([u({type:Rr,repeated:"sequence",optional:!0})],Ue.prototype,"revokedCertificates",void 0),a([u({type:oe,optional:!0,context:0,repeated:"sequence"})],Ue.prototype,"crlExtensions",void 0);class fn{constructor(e={}){this.tbsCertList=new Ue,this.signatureAlgorithm=new C,this.signature=new ArrayBuffer(0),Object.assign(this,e)}}a([u({type:Ue,raw:!0})],fn.prototype,"tbsCertList",void 0),a([u({type:C})],fn.prototype,"signatureAlgorithm",void 0),a([u({type:h.BitString})],fn.prototype,"signature",void 0);var hn;class dn{constructor(e={}){this.sigIdentifier=new C,Object.assign(this,e)}}a([u({type:C})],dn.prototype,"sigIdentifier",void 0),a([u({type:C,optional:!0})],dn.prototype,"certIdentifier",void 0);let Hs=hn=class extends j{constructor(e){super(e),Object.setPrototypeOf(this,hn.prototype)}};Hs=hn=a([S({type:m.Sequence,itemType:dn})],Hs);class $s{constructor(e={}){this.issuer=new ne,this.locator=new xr,Object.assign(this,e)}}a([u({type:ne})],$s.prototype,"issuer",void 0),a([u({type:xr})],$s.prototype,"locator",void 0);class Rc extends O{}let dt=class{constructor(e={}){Object.assign(this,e)}};a([u({type:ne,context:1})],dt.prototype,"byName",void 0),a([u({type:Rc,context:2})],dt.prototype,"byKey",void 0),dt=a([S({type:m.Choice})],dt);class Re{constructor(e={}){this.hashAlgorithm=new C,this.issuerNameHash=new O,this.issuerKeyHash=new O,this.serialNumber=new ArrayBuffer(0),Object.assign(this,e)}}a([u({type:C})],Re.prototype,"hashAlgorithm",void 0),a([u({type:O})],Re.prototype,"issuerNameHash",void 0),a([u({type:O})],Re.prototype,"issuerKeyHash",void 0),a([u({type:h.Integer,converter:le})],Re.prototype,"serialNumber",void 0);class pn{constructor(e={}){this.revocationTime=new Date,Object.assign(this,e)}}a([u({type:h.GeneralizedTime})],pn.prototype,"revocationTime",void 0),a([u({type:Er,context:0,optional:!0})],pn.prototype,"revocationReason",void 0);let Ze=class{constructor(e={}){Object.assign(this,e)}};a([u({type:h.Null,context:0,implicit:!0})],Ze.prototype,"good",void 0),a([u({type:pn,context:1,implicit:!0})],Ze.prototype,"revoked",void 0),a([u({type:h.Null,context:2,implicit:!0})],Ze.prototype,"unknown",void 0),Ze=a([S({type:m.Choice})],Ze);class pt{constructor(e={}){this.certID=new Re,this.certStatus=new Ze,this.thisUpdate=new Date,Object.assign(this,e)}}a([u({type:Re})],pt.prototype,"certID",void 0),a([u({type:Ze})],pt.prototype,"certStatus",void 0),a([u({type:h.GeneralizedTime})],pt.prototype,"thisUpdate",void 0),a([u({type:h.GeneralizedTime,context:0,optional:!0})],pt.prototype,"nextUpdate",void 0),a([u({type:oe,context:1,repeated:"sequence",optional:!0})],pt.prototype,"singleExtensions",void 0);var yt;(function(r){r[r.v1=0]="v1"})(yt||(yt={}));class Ye{constructor(e={}){this.version=yt.v1,this.responderID=new dt,this.producedAt=new Date,this.responses=[],Object.assign(this,e)}}a([u({type:h.Integer,context:0,defaultValue:yt.v1})],Ye.prototype,"version",void 0),a([u({type:dt})],Ye.prototype,"responderID",void 0),a([u({type:h.GeneralizedTime})],Ye.prototype,"producedAt",void 0),a([u({type:pt,repeated:"sequence"})],Ye.prototype,"responses",void 0),a([u({type:oe,repeated:"sequence",context:1,optional:!0})],Ye.prototype,"responseExtensions",void 0);class $t{constructor(e={}){this.tbsResponseData=new Ye,this.signatureAlgorithm=new C,this.signature=new ArrayBuffer(0),Object.assign(this,e)}}a([u({type:Ye,raw:!0})],$t.prototype,"tbsResponseData",void 0),a([u({type:C})],$t.prototype,"signatureAlgorithm",void 0),a([u({type:h.BitString})],$t.prototype,"signature",void 0),a([u({type:Je,repeated:"sequence",optional:!0,context:0})],$t.prototype,"certs",void 0);class Dr{constructor(e={}){this.signatureAlgorithm=new C,this.signature=new ArrayBuffer(0),Object.assign(this,e)}}a([u({type:C})],Dr.prototype,"signatureAlgorithm",void 0),a([u({type:h.BitString})],Dr.prototype,"signature",void 0),a([u({type:Je,repeated:"sequence",optional:!0,context:0})],Dr.prototype,"certs",void 0);class jr{constructor(e={}){this.reqCert=new Re,Object.assign(this,e)}}a([u({type:Re})],jr.prototype,"reqCert",void 0),a([u({type:oe,repeated:"sequence",optional:!0})],jr.prototype,"singleRequestExtensions",void 0);class Qe{constructor(e={}){this.version=yt.v1,this.requestList=[],Object.assign(this,e)}}a([u({type:h.Integer,context:0,defaultValue:yt.v1})],Qe.prototype,"version",void 0),a([u({type:V,context:1,optional:!0})],Qe.prototype,"requestorName",void 0),a([u({type:jr,repeated:"sequence"})],Qe.prototype,"requestList",void 0),a([u({type:oe,context:2,optional:!0,repeated:"sequence"})],Qe.prototype,"requestExtensions",void 0);class yn{constructor(e={}){this.tbsRequest=new Qe,Object.assign(this,e)}}a([u({type:Qe,raw:!0})],yn.prototype,"tbsRequest",void 0),a([u({type:Dr,optional:!0,context:0})],yn.prototype,"optionalSignature",void 0);var De;(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"})(De||(De={}));class gn{constructor(e={}){this.responseType="",this.response=new O,Object.assign(this,e)}}a([u({type:h.ObjectIdentifier})],gn.prototype,"responseType",void 0),a([u({type:O})],gn.prototype,"response",void 0);class mn{constructor(e={}){this.responseStatus=De.successful,Object.assign(this,e)}}a([u({type:h.Enumerated})],mn.prototype,"responseStatus",void 0),a([u({type:gn,context:0,optional:!0})],mn.prototype,"responseBytes",void 0);var Lr=(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 vn(r){return Lr(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,d=new AbortController,p=setTimeout(()=>d.abort(),i);try{const g={};s&&(g["Content-Type"]=s),c&&(g.Accept=c);const y=yield fetch(f,{method:n,headers:g,body:o?new Uint8Array(o):void 0,signal:d.signal});if(clearTimeout(p),!y.ok)return{ok:!1,status:y.status,error:`HTTP ${y.status}: ${y.statusText}`};const v=yield y.arrayBuffer();return{ok:!0,status:y.status,data:v}}catch(g){return clearTimeout(p),g instanceof Error?g.name==="AbortError"?{ok:!1,status:0,error:`Request timeout after ${i}ms`}:{ok:!1,status:0,error:g.message}:{ok:!1,status:0,error:String(g)}}})}function Dc(r,e,t=5e3,i){return Lr(this,null,function*(){return vn(r,{method:"POST",body:e,contentType:"application/ocsp-request",accept:"application/ocsp-response",timeout:t,proxyUrl:i})})}function jc(r,e=1e4,t){return Lr(this,null,function*(){return vn(r,{method:"GET",accept:"application/pkix-crl",timeout:e,proxyUrl:t})})}function Lc(r,e=5e3,t){return Lr(this,null,function*(){return vn(r,{method:"GET",accept:"application/pkix-cert",timeout:e,proxyUrl:t})})}function Ms(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 Ps(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 _c(r){return new Uint8Array(Ps(r))}function _r(r){return Array.from(new Uint8Array(r)).map(e=>e.toString(16).padStart(2,"0")).join("")}function Hc(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 qs(r,e="CERTIFICATE"){const t=Ms(r).match(/.{1,64}/g)||[];return`-----BEGIN ${e}-----
76
73
  ${t.join(`
77
74
  `)}
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(`
75
+ -----END ${e}-----`}var Hr=(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 Fs="1.3.6.1.5.5.7.1.1",$c="1.3.14.3.2.26";function zs(r){return Hr(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 Mc(r){try{const e=r.getExtension(Fs);return e?e.ocsp.filter(t=>t.type==="url").map(t=>t.value):[]}catch(e){return[]}}function Pc(r){try{const e=r.getExtension(Fs);return e?e.caIssuers.filter(t=>t.type==="url").map(t=>t.value):[]}catch(e){return[]}}function Gs(r,e){const t=r.issuer;for(const i of e)try{const n=new R.X509Certificate(i);if(n.subject===t)return n}catch(n){}return null}function Xs(r,e=5e3,t){return Hr(this,null,function*(){const i=Pc(r);for(const n of i)try{const o=yield Lc(n,e,t);if(o.ok&&o.data)try{return new R.X509Certificate(o.data)}catch(s){const c=qs(o.data);return new R.X509Certificate(c)}}catch(o){}return null})}function qc(r,e){return Hr(this,null,function*(){const t=ms.parse(e.rawData,Je),i=ge.serialize(t.tbsCertificate.subject),n=yield zs(i),o=yield zs(t.tbsCertificate.subjectPublicKeyInfo.subjectPublicKey),s=Hc(r.serialNumber),c=new Re({hashAlgorithm:new C({algorithm:$c}),issuerNameHash:new O(n),issuerKeyHash:new O(o),serialNumber:s}),l=new jr({reqCert:c}),f=new Qe({requestList:[l]}),d=new yn({tbsRequest:f});return ge.serialize(d)})}function Fc(r){const e=new Date;try{const t=ge.parse(r,mn);switch(t.responseStatus){case De.successful:break;case De.malformedRequest:return{isValid:!1,status:"error",method:"ocsp",reason:"OCSP responder returned: malformed request",checkedAt:e};case De.internalError:return{isValid:!1,status:"error",method:"ocsp",reason:"OCSP responder returned: internal error",checkedAt:e};case De.tryLater:return{isValid:!1,status:"unknown",method:"ocsp",reason:"OCSP responder returned: try later",checkedAt:e};case De.sigRequired:return{isValid:!1,status:"error",method:"ocsp",reason:"OCSP responder requires signature",checkedAt:e};case De.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=ge.parse(t.responseBytes.response.buffer,$t).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 zc(r,e){return Hr(this,arguments,function*(t,i,n={}){const{timeout:o=5e3,certificateChain:s=[],proxyUrl:c}=n,l=new Date,f=Mc(t);if(f.length===0)return{isValid:!1,status:"unknown",method:"ocsp",reason:"Certificate has no OCSP responder URL",checkedAt:l};let d=i;if(d||(d=Gs(t,s)),d||(d=yield Xs(t,o,c)),!d)return{isValid:!1,status:"unknown",method:"ocsp",reason:"Could not find or fetch issuer certificate for OCSP",checkedAt:l};let p;try{p=yield qc(t,d)}catch(g){return{isValid:!1,status:"error",method:"ocsp",reason:`Failed to build OCSP request: ${g instanceof Error?g.message:String(g)}`,checkedAt:l}}for(const g of f)try{const y=yield Dc(g,p,o,c);if(y.ok&&y.data)return Fc(y.data)}catch(y){}return{isValid:!1,status:"error",method:"ocsp",reason:"All OCSP requests failed",checkedAt:l}})}var Gc=(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 Xc="2.5.29.31";function Wc(r){try{const e=r.getExtension(Xc);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)if(o.uniformResourceIdentifier){const s=o.uniformResourceIdentifier;(s.startsWith("http://")||s.startsWith("https://"))&&t.push(s)}}}return t}catch(e){return[]}}function Kc(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 Jc(r){try{return new R.X509Crl(r)}catch(e){try{const t=`-----BEGIN X509 CRL-----
76
+ ${(Ms(r).match(/.{1,64}/g)||[]).join(`
80
77
  `)}
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})});
78
+ -----END X509 CRL-----`;return new R.X509Crl(t)}catch(t){return null}}}function Zc(r){return Gc(this,arguments,function*(e,t={}){const{timeout:i=1e4,proxyUrl:n}=t,o=new Date,s=Wc(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 jc(l,i,n);if(!f.ok||!f.data){c.push(`${l}: ${f.error||"Failed to fetch"}`);continue}const d=Jc(f.data);if(!d){c.push(`${l}: Failed to parse CRL data`);continue}const p=Kc(d,e.serialNumber);return p.isRevoked?{isValid:!1,status:"revoked",method:"crl",reason:p.reason!==void 0?`Certificate revoked (reason code: ${p.reason})`:"Certificate revoked",revokedAt:p.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 Yc=Object.defineProperty,Ws=Object.getOwnPropertySymbols,Qc=Object.prototype.hasOwnProperty,el=Object.prototype.propertyIsEnumerable,Ks=(r,e,t)=>e in r?Yc(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,Js=(r,e)=>{for(var t in e||(e={}))Qc.call(e,t)&&Ks(r,t,e[t]);if(Ws)for(var t of Ws(e))el.call(e,t)&&Ks(r,t,e[t]);return r},tl=(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 wn(r){return tl(this,arguments,function*(e,t={}){const i=new Date,n=Js(Js({},Ma),t);let o;try{o=typeof e=="string"?new R.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 zc(o,null,{timeout:n.ocspTimeout,certificateChain:n.certificateChain,proxyUrl:t.proxyUrl}),s.status==="good"||s.status==="revoked"))return s;if(n.crlEnabled&&(c=yield Zc(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 gt{constructor(e={}){this.issuer=new ne,this.serialNumber=new ArrayBuffer(0),Object.assign(this,e)}}a([u({type:ne})],gt.prototype,"issuer",void 0),a([u({type:h.Integer,converter:le})],gt.prototype,"serialNumber",void 0);let mt=class{constructor(e={}){Object.assign(this,e)}};a([u({type:_t,context:0,implicit:!0})],mt.prototype,"subjectKeyIdentifier",void 0),a([u({type:gt})],mt.prototype,"issuerAndSerialNumber",void 0),mt=a([S({type:m.Choice})],mt);var je;(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"})(je||(je={}));let Mt=class extends C{};Mt=a([S({type:m.Sequence})],Mt);let $r=class extends C{};$r=a([S({type:m.Sequence})],$r);let Ne=class extends C{};Ne=a([S({type:m.Sequence})],Ne);let Mr=class extends C{};Mr=a([S({type:m.Sequence})],Mr);let Zs=class extends C{};Zs=a([S({type:m.Sequence})],Zs);let bn=class extends C{};bn=a([S({type:m.Sequence})],bn);class Pt{constructor(e={}){this.attrType="",this.attrValues=[],Object.assign(this,e)}}a([u({type:h.ObjectIdentifier})],Pt.prototype,"attrType",void 0),a([u({type:h.Any,repeated:"set"})],Pt.prototype,"attrValues",void 0);var An;class Le{constructor(e={}){this.version=je.v0,this.sid=new mt,this.digestAlgorithm=new Mt,this.signatureAlgorithm=new $r,this.signature=new O,Object.assign(this,e)}}a([u({type:h.Integer})],Le.prototype,"version",void 0),a([u({type:mt})],Le.prototype,"sid",void 0),a([u({type:Mt})],Le.prototype,"digestAlgorithm",void 0),a([u({type:Pt,repeated:"set",context:0,implicit:!0,optional:!0,raw:!0})],Le.prototype,"signedAttrs",void 0),a([u({type:$r})],Le.prototype,"signatureAlgorithm",void 0),a([u({type:O})],Le.prototype,"signature",void 0),a([u({type:Pt,repeated:"set",context:1,implicit:!0,optional:!0})],Le.prototype,"unsignedAttrs",void 0);let Pr=An=class extends j{constructor(e){super(e),Object.setPrototypeOf(this,An.prototype)}};Pr=An=a([S({type:m.Set,itemType:Le})],Pr);let Ys=class extends Le{};Ys=a([S({type:m.Sequence})],Ys);let Qs=class extends Y{};Qs=a([S({type:m.Choice})],Qs);class Sn{constructor(e={}){this.acIssuer=new V,this.acSerial=0,this.attrs=[],Object.assign(this,e)}}a([u({type:V})],Sn.prototype,"acIssuer",void 0),a([u({type:h.Integer})],Sn.prototype,"acSerial",void 0),a([u({type:Lt,repeated:"sequence"})],Sn.prototype,"attrs",void 0);var kn;let qr=kn=class extends j{constructor(e){super(e),Object.setPrototypeOf(this,kn.prototype)}};qr=kn=a([S({type:m.Sequence,itemType:h.ObjectIdentifier})],qr);class Fr{constructor(e={}){this.permitUnSpecified=!0,Object.assign(this,e)}}a([u({type:h.Integer,optional:!0})],Fr.prototype,"pathLenConstraint",void 0),a([u({type:qr,implicit:!0,context:0,optional:!0})],Fr.prototype,"permittedAttrs",void 0),a([u({type:qr,implicit:!0,context:1,optional:!0})],Fr.prototype,"excludedAttrs",void 0),a([u({type:h.Boolean,defaultValue:!0})],Fr.prototype,"permitUnSpecified",void 0);class et{constructor(e={}){this.issuer=new ve,this.serial=new ArrayBuffer(0),this.issuerUID=new ArrayBuffer(0),Object.assign(this,e)}}a([u({type:ve})],et.prototype,"issuer",void 0),a([u({type:h.Integer,converter:le})],et.prototype,"serial",void 0),a([u({type:h.BitString,optional:!0})],et.prototype,"issuerUID",void 0);var Bn;(function(r){r[r.publicKey=0]="publicKey",r[r.publicKeyCert=1]="publicKeyCert",r[r.otherObjectTypes=2]="otherObjectTypes"})(Bn||(Bn={}));class tt{constructor(e={}){this.digestedObjectType=Bn.publicKey,this.digestAlgorithm=new C,this.objectDigest=new ArrayBuffer(0),Object.assign(this,e)}}a([u({type:h.Enumerated})],tt.prototype,"digestedObjectType",void 0),a([u({type:h.ObjectIdentifier,optional:!0})],tt.prototype,"otherObjectTypeID",void 0),a([u({type:C})],tt.prototype,"digestAlgorithm",void 0),a([u({type:h.BitString})],tt.prototype,"objectDigest",void 0);class zr{constructor(e={}){Object.assign(this,e)}}a([u({type:ve,optional:!0})],zr.prototype,"issuerName",void 0),a([u({type:et,context:0,implicit:!0,optional:!0})],zr.prototype,"baseCertificateID",void 0),a([u({type:tt,context:1,implicit:!0,optional:!0})],zr.prototype,"objectDigestInfo",void 0);let vt=class{constructor(e={}){Object.assign(this,e)}};a([u({type:V,repeated:"sequence"})],vt.prototype,"v1Form",void 0),a([u({type:zr,context:0,implicit:!0})],vt.prototype,"v2Form",void 0),vt=a([S({type:m.Choice})],vt);class Gr{constructor(e={}){this.notBeforeTime=new Date,this.notAfterTime=new Date,Object.assign(this,e)}}a([u({type:h.GeneralizedTime})],Gr.prototype,"notBeforeTime",void 0),a([u({type:h.GeneralizedTime})],Gr.prototype,"notAfterTime",void 0);class qt{constructor(e={}){Object.assign(this,e)}}a([u({type:et,implicit:!0,context:0,optional:!0})],qt.prototype,"baseCertificateID",void 0),a([u({type:ve,implicit:!0,context:1,optional:!0})],qt.prototype,"entityName",void 0),a([u({type:tt,implicit:!0,context:2,optional:!0})],qt.prototype,"objectDigestInfo",void 0);var xn;(function(r){r[r.v2=1]="v2"})(xn||(xn={}));class be{constructor(e={}){this.version=xn.v2,this.holder=new qt,this.issuer=new vt,this.signature=new C,this.serialNumber=new ArrayBuffer(0),this.attrCertValidityPeriod=new Gr,this.attributes=[],Object.assign(this,e)}}a([u({type:h.Integer})],be.prototype,"version",void 0),a([u({type:qt})],be.prototype,"holder",void 0),a([u({type:vt})],be.prototype,"issuer",void 0),a([u({type:C})],be.prototype,"signature",void 0),a([u({type:h.Integer,converter:le})],be.prototype,"serialNumber",void 0),a([u({type:Gr})],be.prototype,"attrCertValidityPeriod",void 0),a([u({type:Lt,repeated:"sequence"})],be.prototype,"attributes",void 0),a([u({type:h.BitString,optional:!0})],be.prototype,"issuerUniqueID",void 0),a([u({type:ht,optional:!0})],be.prototype,"extensions",void 0);class Xr{constructor(e={}){this.acinfo=new be,this.signatureAlgorithm=new C,this.signatureValue=new ArrayBuffer(0),Object.assign(this,e)}}a([u({type:be})],Xr.prototype,"acinfo",void 0),a([u({type:C})],Xr.prototype,"signatureAlgorithm",void 0),a([u({type:h.BitString})],Xr.prototype,"signatureValue",void 0);var Wr;(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"})(Wr||(Wr={}));class Cn extends Sr{}class Nn{constructor(e={}){this.type="",this.value=new ArrayBuffer(0),Object.assign(this,e)}}a([u({type:h.ObjectIdentifier,implicit:!0,context:0})],Nn.prototype,"type",void 0),a([u({type:h.Any,implicit:!0,context:1})],Nn.prototype,"value",void 0);class En{constructor(e={}){this.policyId="",this.classList=new Cn(Wr.unclassified),Object.assign(this,e)}}a([u({type:h.ObjectIdentifier})],En.prototype,"policyId",void 0),a([u({type:Cn,defaultValue:new Cn(Wr.unclassified)})],En.prototype,"classList",void 0),a([u({type:Nn,repeated:"set"})],En.prototype,"securityCategories",void 0);class Kr{constructor(e={}){Object.assign(this,e)}}a([u({type:O})],Kr.prototype,"cotets",void 0),a([u({type:h.ObjectIdentifier})],Kr.prototype,"oid",void 0),a([u({type:h.Utf8String})],Kr.prototype,"string",void 0);class ea{constructor(e={}){this.values=[],Object.assign(this,e)}}a([u({type:ve,implicit:!0,context:0,optional:!0})],ea.prototype,"policyAuthority",void 0),a([u({type:Kr,repeated:"sequence"})],ea.prototype,"values",void 0);var In;class Jr{constructor(e={}){this.targetCertificate=new et,Object.assign(this,e)}}a([u({type:et})],Jr.prototype,"targetCertificate",void 0),a([u({type:V,optional:!0})],Jr.prototype,"targetName",void 0),a([u({type:tt,optional:!0})],Jr.prototype,"certDigestInfo",void 0);let wt=class{constructor(e={}){Object.assign(this,e)}};a([u({type:V,context:0,implicit:!0})],wt.prototype,"targetName",void 0),a([u({type:V,context:1,implicit:!0})],wt.prototype,"targetGroup",void 0),a([u({type:Jr,context:2,implicit:!0})],wt.prototype,"targetCert",void 0),wt=a([S({type:m.Choice})],wt);let On=In=class extends j{constructor(e){super(e),Object.setPrototypeOf(this,In.prototype)}};On=In=a([S({type:m.Sequence,itemType:wt})],On);var Tn;let ta=Tn=class extends j{constructor(e){super(e),Object.setPrototypeOf(this,Tn.prototype)}};ta=Tn=a([S({type:m.Sequence,itemType:On})],ta);class ra{constructor(e={}){Object.assign(this,e)}}a([u({type:ve,implicit:!0,context:0,optional:!0})],ra.prototype,"roleAuthority",void 0),a([u({type:V,implicit:!0,context:1})],ra.prototype,"roleName",void 0);class Vn{constructor(e={}){this.service=new V,this.ident=new V,Object.assign(this,e)}}a([u({type:V})],Vn.prototype,"service",void 0),a([u({type:V})],Vn.prototype,"ident",void 0),a([u({type:O,optional:!0})],Vn.prototype,"authInfo",void 0);var Un;class Rn{constructor(e={}){this.otherCertFormat="",this.otherCert=new ArrayBuffer(0),Object.assign(this,e)}}a([u({type:h.ObjectIdentifier})],Rn.prototype,"otherCertFormat",void 0),a([u({type:h.Any})],Rn.prototype,"otherCert",void 0);let bt=class{constructor(e={}){Object.assign(this,e)}};a([u({type:Je})],bt.prototype,"certificate",void 0),a([u({type:Xr,context:2,implicit:!0})],bt.prototype,"v2AttrCert",void 0),a([u({type:Rn,context:3,implicit:!0})],bt.prototype,"other",void 0),bt=a([S({type:m.Choice})],bt);let Zr=Un=class extends j{constructor(e){super(e),Object.setPrototypeOf(this,Un.prototype)}};Zr=Un=a([S({type:m.Set,itemType:bt})],Zr);class Yr{constructor(e={}){this.contentType="",this.content=new ArrayBuffer(0),Object.assign(this,e)}}a([u({type:h.ObjectIdentifier})],Yr.prototype,"contentType",void 0),a([u({type:h.Any,context:0})],Yr.prototype,"content",void 0);let Ft=class{constructor(e={}){Object.assign(this,e)}};a([u({type:O})],Ft.prototype,"single",void 0),a([u({type:h.Any})],Ft.prototype,"any",void 0),Ft=a([S({type:m.Choice})],Ft);class Qr{constructor(e={}){this.eContentType="",Object.assign(this,e)}}a([u({type:h.ObjectIdentifier})],Qr.prototype,"eContentType",void 0),a([u({type:Ft,context:0,optional:!0})],Qr.prototype,"eContent",void 0);let zt=class{constructor(e={}){Object.assign(this,e)}};a([u({type:O,context:0,implicit:!0,optional:!0})],zt.prototype,"value",void 0),a([u({type:O,converter:yc,context:0,implicit:!0,optional:!0,repeated:"sequence"})],zt.prototype,"constructedValue",void 0),zt=a([S({type:m.Choice})],zt);class Gt{constructor(e={}){this.contentType="",this.contentEncryptionAlgorithm=new Mr,Object.assign(this,e)}}a([u({type:h.ObjectIdentifier})],Gt.prototype,"contentType",void 0),a([u({type:Mr})],Gt.prototype,"contentEncryptionAlgorithm",void 0),a([u({type:zt,optional:!0})],Gt.prototype,"encryptedContent",void 0);class ei{constructor(e={}){this.keyAttrId="",Object.assign(this,e)}}a([u({type:h.ObjectIdentifier})],ei.prototype,"keyAttrId",void 0),a([u({type:h.Any,optional:!0})],ei.prototype,"keyAttr",void 0);var Dn;class ti{constructor(e={}){this.subjectKeyIdentifier=new _t,Object.assign(this,e)}}a([u({type:_t})],ti.prototype,"subjectKeyIdentifier",void 0),a([u({type:h.GeneralizedTime,optional:!0})],ti.prototype,"date",void 0),a([u({type:ei,optional:!0})],ti.prototype,"other",void 0);let At=class{constructor(e={}){Object.assign(this,e)}};a([u({type:ti,context:0,implicit:!0,optional:!0})],At.prototype,"rKeyId",void 0),a([u({type:gt,optional:!0})],At.prototype,"issuerAndSerialNumber",void 0),At=a([S({type:m.Choice})],At);class jn{constructor(e={}){this.rid=new At,this.encryptedKey=new O,Object.assign(this,e)}}a([u({type:At})],jn.prototype,"rid",void 0),a([u({type:O})],jn.prototype,"encryptedKey",void 0);let ri=Dn=class extends j{constructor(e){super(e),Object.setPrototypeOf(this,Dn.prototype)}};ri=Dn=a([S({type:m.Sequence,itemType:jn})],ri);class Ln{constructor(e={}){this.algorithm=new C,this.publicKey=new ArrayBuffer(0),Object.assign(this,e)}}a([u({type:C})],Ln.prototype,"algorithm",void 0),a([u({type:h.BitString})],Ln.prototype,"publicKey",void 0);let rt=class{constructor(e={}){Object.assign(this,e)}};a([u({type:_t,context:0,implicit:!0,optional:!0})],rt.prototype,"subjectKeyIdentifier",void 0),a([u({type:Ln,context:1,implicit:!0,optional:!0})],rt.prototype,"originatorKey",void 0),a([u({type:gt,optional:!0})],rt.prototype,"issuerAndSerialNumber",void 0),rt=a([S({type:m.Choice})],rt);class St{constructor(e={}){this.version=je.v3,this.originator=new rt,this.keyEncryptionAlgorithm=new Ne,this.recipientEncryptedKeys=new ri,Object.assign(this,e)}}a([u({type:h.Integer})],St.prototype,"version",void 0),a([u({type:rt,context:0})],St.prototype,"originator",void 0),a([u({type:O,context:1,optional:!0})],St.prototype,"ukm",void 0),a([u({type:Ne})],St.prototype,"keyEncryptionAlgorithm",void 0),a([u({type:ri})],St.prototype,"recipientEncryptedKeys",void 0);let kt=class{constructor(e={}){Object.assign(this,e)}};a([u({type:_t,context:0,implicit:!0})],kt.prototype,"subjectKeyIdentifier",void 0),a([u({type:gt})],kt.prototype,"issuerAndSerialNumber",void 0),kt=a([S({type:m.Choice})],kt);class Xt{constructor(e={}){this.version=je.v0,this.rid=new kt,this.keyEncryptionAlgorithm=new Ne,this.encryptedKey=new O,Object.assign(this,e)}}a([u({type:h.Integer})],Xt.prototype,"version",void 0),a([u({type:kt})],Xt.prototype,"rid",void 0),a([u({type:Ne})],Xt.prototype,"keyEncryptionAlgorithm",void 0),a([u({type:O})],Xt.prototype,"encryptedKey",void 0);class Wt{constructor(e={}){this.keyIdentifier=new O,Object.assign(this,e)}}a([u({type:O})],Wt.prototype,"keyIdentifier",void 0),a([u({type:h.GeneralizedTime,optional:!0})],Wt.prototype,"date",void 0),a([u({type:ei,optional:!0})],Wt.prototype,"other",void 0);class Kt{constructor(e={}){this.version=je.v4,this.kekid=new Wt,this.keyEncryptionAlgorithm=new Ne,this.encryptedKey=new O,Object.assign(this,e)}}a([u({type:h.Integer})],Kt.prototype,"version",void 0),a([u({type:Wt})],Kt.prototype,"kekid",void 0),a([u({type:Ne})],Kt.prototype,"keyEncryptionAlgorithm",void 0),a([u({type:O})],Kt.prototype,"encryptedKey",void 0);class Jt{constructor(e={}){this.version=je.v0,this.keyEncryptionAlgorithm=new Ne,this.encryptedKey=new O,Object.assign(this,e)}}a([u({type:h.Integer})],Jt.prototype,"version",void 0),a([u({type:bn,context:0,optional:!0})],Jt.prototype,"keyDerivationAlgorithm",void 0),a([u({type:Ne})],Jt.prototype,"keyEncryptionAlgorithm",void 0),a([u({type:O})],Jt.prototype,"encryptedKey",void 0);class _n{constructor(e={}){this.oriType="",this.oriValue=new ArrayBuffer(0),Object.assign(this,e)}}a([u({type:h.ObjectIdentifier})],_n.prototype,"oriType",void 0),a([u({type:h.Any})],_n.prototype,"oriValue",void 0);let Pe=class{constructor(e={}){Object.assign(this,e)}};a([u({type:Xt,optional:!0})],Pe.prototype,"ktri",void 0),a([u({type:St,context:1,implicit:!0,optional:!0})],Pe.prototype,"kari",void 0),a([u({type:Kt,context:2,implicit:!0,optional:!0})],Pe.prototype,"kekri",void 0),a([u({type:Jt,context:3,implicit:!0,optional:!0})],Pe.prototype,"pwri",void 0),a([u({type:_n,context:4,implicit:!0,optional:!0})],Pe.prototype,"ori",void 0),Pe=a([S({type:m.Choice})],Pe);var Hn;let ii=Hn=class extends j{constructor(e){super(e),Object.setPrototypeOf(this,Hn.prototype)}};ii=Hn=a([S({type:m.Set,itemType:Pe})],ii);var $n;class ni{constructor(e={}){this.otherRevInfoFormat="",this.otherRevInfo=new ArrayBuffer(0),Object.assign(this,e)}}a([u({type:h.ObjectIdentifier})],ni.prototype,"otherRevInfoFormat",void 0),a([u({type:h.Any})],ni.prototype,"otherRevInfo",void 0);let oi=class{constructor(e={}){this.other=new ni,Object.assign(this,e)}};a([u({type:ni,context:1,implicit:!0})],oi.prototype,"other",void 0),oi=a([S({type:m.Choice})],oi);let si=$n=class extends j{constructor(e){super(e),Object.setPrototypeOf(this,$n.prototype)}};si=$n=a([S({type:m.Set,itemType:oi})],si);class Mn{constructor(e={}){Object.assign(this,e)}}a([u({type:Zr,context:0,implicit:!0,optional:!0})],Mn.prototype,"certs",void 0),a([u({type:si,context:1,implicit:!0,optional:!0})],Mn.prototype,"crls",void 0);var Pn;let qn=Pn=class extends j{constructor(e){super(e),Object.setPrototypeOf(this,Pn.prototype)}};qn=Pn=a([S({type:m.Set,itemType:Pt})],qn);class Zt{constructor(e={}){this.version=je.v0,this.recipientInfos=new ii,this.encryptedContentInfo=new Gt,Object.assign(this,e)}}a([u({type:h.Integer})],Zt.prototype,"version",void 0),a([u({type:Mn,context:0,implicit:!0,optional:!0})],Zt.prototype,"originatorInfo",void 0),a([u({type:ii})],Zt.prototype,"recipientInfos",void 0),a([u({type:Gt})],Zt.prototype,"encryptedContentInfo",void 0),a([u({type:qn,context:1,implicit:!0,optional:!0})],Zt.prototype,"unprotectedAttrs",void 0);var Fn;let ai=Fn=class extends j{constructor(e){super(e),Object.setPrototypeOf(this,Fn.prototype)}};ai=Fn=a([S({type:m.Set,itemType:Mt})],ai);class it{constructor(e={}){this.version=je.v0,this.digestAlgorithms=new ai,this.encapContentInfo=new Qr,this.signerInfos=new Pr,Object.assign(this,e)}}a([u({type:h.Integer})],it.prototype,"version",void 0),a([u({type:ai})],it.prototype,"digestAlgorithms",void 0),a([u({type:Qr})],it.prototype,"encapContentInfo",void 0),a([u({type:Zr,context:0,implicit:!0,optional:!0})],it.prototype,"certificates",void 0),a([u({type:si,context:1,implicit:!0,optional:!0})],it.prototype,"crls",void 0),a([u({type:Pr})],it.prototype,"signerInfos",void 0);class ci{constructor(e={}){this.seconds=0,Object.assign(this,e)}}a([u({type:h.Integer,optional:!0})],ci.prototype,"seconds",void 0),a([u({type:h.Integer,context:0,implicit:!0,optional:!0})],ci.prototype,"millis",void 0),a([u({type:h.Integer,context:1,implicit:!0,optional:!0})],ci.prototype,"micros",void 0);class Bt{constructor(e={}){this.hashAlgorithm=new C,this.hashedMessage=new O,Object.assign(this,e)}}a([u({type:C})],Bt.prototype,"hashAlgorithm",void 0),a([u({type:O})],Bt.prototype,"hashedMessage",void 0);var Ae;(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"})(Ae||(Ae={}));class rl extends Sr{toJSON(){const e=this.toNumber(),t=[];return e&Ae.addInfoNotAvailable&&t.push("addInfoNotAvailable"),e&Ae.badAlg&&t.push("badAlg"),e&Ae.badDataFormat&&t.push("badDataFormat"),e&Ae.badRequest&&t.push("badRequest"),e&Ae.systemFailure&&t.push("systemFailure"),e&Ae.systemFailure&&t.push("systemFailure"),e&Ae.timeNotAvailable&&t.push("timeNotAvailable"),e&Ae.unacceptedExtension&&t.push("unacceptedExtension"),e&Ae.unacceptedPolicy&&t.push("unacceptedPolicy"),t}toString(){return`[${this.toJSON().join(", ")}]`}}var zn;(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"})(zn||(zn={}));var Gn;let Xn=Gn=class extends j{constructor(e){super(e),Object.setPrototypeOf(this,Gn.prototype)}};Xn=Gn=a([S({type:m.Sequence,itemType:h.Utf8String})],Xn);class Yt{constructor(e={}){this.status=zn.granted,Object.assign(this,e)}}a([u({type:h.Integer})],Yt.prototype,"status",void 0),a([u({type:Xn,optional:!0})],Yt.prototype,"statusString",void 0),a([u({type:rl,optional:!0})],Yt.prototype,"failInfo",void 0);var Wn;(function(r){r[r.v1=1]="v1"})(Wn||(Wn={}));class xt{constructor(e={}){this.version=Wn.v1,this.messageImprint=new Bt,this.certReq=!1,Object.assign(this,e)}}a([u({type:h.Integer})],xt.prototype,"version",void 0),a([u({type:Bt})],xt.prototype,"messageImprint",void 0),a([u({type:h.ObjectIdentifier,optional:!0})],xt.prototype,"reqPolicy",void 0),a([u({type:h.Integer,converter:le,optional:!0})],xt.prototype,"nonce",void 0),a([u({type:h.Boolean,defaultValue:!1})],xt.prototype,"certReq",void 0),a([u({type:ht,optional:!0,context:0,implicit:!0})],xt.prototype,"extensions",void 0);let Kn=class extends Yr{};Kn=a([S({type:m.Sequence})],Kn);class ia{constructor(e={}){this.status=new Yt,Object.assign(this,e)}}a([u({type:Yt})],ia.prototype,"status",void 0),a([u({type:Kn,optional:!0})],ia.prototype,"timeStampToken",void 0);var Jn;(function(r){r[r.v1=1]="v1"})(Jn||(Jn={}));class Se{constructor(e={}){this.version=Jn.v1,this.policy="",this.messageImprint=new Bt,this.serialNumber=new ArrayBuffer(0),this.genTime=new Date,this.ordering=!1,Object.assign(this,e)}}a([u({type:h.Integer})],Se.prototype,"version",void 0),a([u({type:h.ObjectIdentifier})],Se.prototype,"policy",void 0),a([u({type:Bt})],Se.prototype,"messageImprint",void 0),a([u({type:h.Integer,converter:le})],Se.prototype,"serialNumber",void 0),a([u({type:h.GeneralizedTime})],Se.prototype,"genTime",void 0),a([u({type:ci,optional:!0})],Se.prototype,"accuracy",void 0),a([u({type:h.Boolean,defaultValue:!1})],Se.prototype,"ordering",void 0),a([u({type:h.Integer,converter:le,optional:!0})],Se.prototype,"nonce",void 0),a([u({type:V,context:0,optional:!0})],Se.prototype,"tsa",void 0),a([u({type:ht,context:1,implicit:!0,optional:!0})],Se.prototype,"extensions",void 0);var Zn=(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 il="1.2.840.113549.1.7.2",nl="1.2.840.113549.1.9.16.1.4";function ol(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 sl={"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 al(r){var e;const t=[];for(const i of r)for(const n of i){const o=sl[n.type]||n.type,s=((e=n.value)==null?void 0:e.toString())||"";s&&t.push(`${o}=${s}`)}return t.join(", ")}function Yn(r){try{const e=Ps(r),t=ge.parse(e,Yr);if(t.contentType!==il)return console.warn("Timestamp is not SignedData"),null;const i=ge.parse(t.content,it);if(i.encapContentInfo.eContentType!==nl)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=ge.serialize(n);const s=ge.parse(o,Se);let c;if(i.certificates&&i.certificates.length>0){const d=i.certificates[0];"certificate"in d&&d.certificate&&(c=qs(ge.serialize(d.certificate)))}let l;s.tsa&&(s.tsa.directoryName?l=al(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:_r(s.serialNumber),hashAlgorithm:ol(s.messageImprint.hashAlgorithm.algorithm),messageImprint:_r(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 cl(r,e){return Zn(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 ll(r,e){return Zn(this,null,function*(){try{const t=r.messageImprint.toLowerCase(),i=new TextEncoder().encode(e),n=yield cl(i.buffer,r.hashAlgorithm);return _r(n).toLowerCase()===t}catch(t){return console.error("Failed to verify timestamp coverage:",t instanceof Error?t.message:String(t)),!1}})}function na(r){return Zn(this,arguments,function*(e,t={}){const i=Yn(e);if(!i)return{isValid:!1,reason:"Failed to parse timestamp token"};let n,o;t.canonicalSignatureValue&&(n=yield ll(i,t.canonicalSignatureValue),n||(o="Could not verify timestamp covers signature (hash mismatch)"));let s;if(t.verifyTsaCertificate&&i.tsaCertificate)try{const c=new R.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 wn(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 ul(r){const e=Yn(r);return(e==null?void 0:e.genTime)||null}var fl=(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 hl(r){const e=new Uint8Array(r);let t=0;const i=()=>{const o=e[t++];if((o&128)===0)return o;const s=o&127;let c=0;for(let l=0;l<s;l++)c=c<<8|e[t++];return c},n=()=>{if(e[t++]!==2)return BigInt(0);const o=i();let s=BigInt(0);for(let c=0;c<o;c++)s=s<<BigInt(8)|BigInt(e[t++]);return s};try{if(e[t++]!==48||(i(),e[t++]!==48))return null;const o=i();if(t+=o,e[t++]!==3||(i(),t++,e[t++]!==48))return null;i();const s=n(),c=n();return{n:s,e:c}}catch(o){return null}}function dl(r,e,t){let i=BigInt(1);for(r=r%t;e>0;)e%BigInt(2)===BigInt(1)&&(i=i*r%t),e=e>>BigInt(1),r=r*r%t;return i}function pl(r){let e=BigInt(0);for(const t of r)e=e<<BigInt(8)|BigInt(t);return e}function yl(r,e){const t=new Uint8Array(e);for(let i=e-1;i>=0;i--)t[i]=Number(r&BigInt(255)),r=r>>BigInt(8);return t}function gl(r){if(r[0]!==0||r[1]!==1)return null;let e=-1;for(let t=2;t<r.length;t++){if(r[t]===0){e=t;break}if(r[t]!==255)return null}return e===-1||e<10?null:r.slice(e+1)}function ml(r,e){for(let t=0;t<r.length-1;t++)if(r[t]===4){const i=r[t+1];if(i===e&&t+2+i<=r.length)return r.slice(t+2,t+2+i)}return null}function vl(r){switch(r.toLowerCase().replace("-","")){case"sha1":return 20;case"sha256":return 32;case"sha384":return 48;case"sha512":return 64;default:return 32}}function oa(){return typeof window!="undefined"&&typeof window.crypto!="undefined"&&typeof window.crypto.subtle!="undefined"}function sa(r,e,t,i){return fl(this,null,function*(){try{let n;if(oa()){const f=hl(r);if(!f)return!1;const{n:d,e:p}=f,g=Math.ceil(d.toString(16).length/2),y=pl(e),v=dl(y,p,d),k=yl(v,g);n=gl(k)}else{const f=require("crypto"),d=f.createPublicKey({key:Buffer.from(r),format:"der",type:"spki"}),p=f.publicDecrypt({key:d,padding:f.constants.RSA_PKCS1_PADDING},Buffer.from(e));n=new Uint8Array(p)}if(!n)return!1;const o=vl(i),s=ml(n,o);if(!s)return!1;let c;if(oa()){let f=i.toUpperCase().replace(/-/g,"");f=f.replace(/^SHA(\d)/,"SHA-$1");const d=yield window.crypto.subtle.digest(f,new Uint8Array(t));c=new Uint8Array(d)}else{const f=require("crypto"),d=i.toLowerCase().replace("-","");c=f.createHash(d).update(Buffer.from(t)).digest()}if(s.length!==c.length)return!1;let l=0;for(let f=0;f<s.length;f++)l|=s[f]^c[f];return l===0}catch(n){return!1}})}const wl={c:"C",cn:"CN",dnq:"DNQ",emailaddress:"E",e:"E",g:"GN",givenname:"GN",gn:"GN",l:"L",o:"O",organizationidentifier:"ORGANIZATIONIDENTIFIER","2.5.4.97":"ORGANIZATIONIDENTIFIER","oid.2.5.4.97":"ORGANIZATIONIDENTIFIER",ou:"OU",serialnumber:"SERIALNUMBER",sn:"SN",st:"ST",surname:"SN",street:"STREET","2.5.4.5":"SERIALNUMBER"};function aa(r,e){const t=[];let i="",n=!1;for(const o of r){if(n){i+=o,n=!1;continue}if(o==="\\"){i+=o,n=!0;continue}if(o===e){t.push(i),i="";continue}i+=o}return t.push(i),t}function bl(r){const e=r.trim();return wl[e.toLowerCase()]||e.toUpperCase()}function Al(r,e){const t=e.trim().replace(/\s+/g," ");return r==="C"?t.toUpperCase():t}function Sl(r){return r&&r.replace(/[^a-fA-F0-9]/g,"").toLowerCase()||null}function Qn(r){return Array.from(r,e=>e.toString(16).padStart(2,"0")).join("")}function kl(r){const e=r.replace(/\s+/g,"");try{if(typeof Buffer!="undefined")return Uint8Array.from(Buffer.from(e,"base64"));if(typeof atob=="function"){const t=atob(e);return Uint8Array.from(t,i=>i.charCodeAt(0))}}catch(t){return null}return null}function ca(r){if(!r)return null;if(typeof r!="string")return ArrayBuffer.isView(r)?Qn(new Uint8Array(r.buffer,r.byteOffset,r.byteLength)):Qn(new Uint8Array(r));const e=r.trim();if(!e)return null;const t=Sl(e),i=e.replace(/[\s:-]+/g,"");if(t&&/^[a-fA-F0-9]+$/.test(i)&&i.length%2===0)return t;if(/^[A-Za-z0-9+/=\s]+$/.test(e)&&e.replace(/\s+/g,"").length%4===0){const n=kl(e);if(n&&n.length>0)return Qn(n)}return t}function eo(r){return r?aa(r,",").map(e=>e.trim()).filter(Boolean).map(e=>{const[t,...i]=aa(e,"=");if(!t||i.length===0)return e.replace(/\s+/g," ");const n=bl(t),o=Al(n,i.join("="));return`${n}=${o}`}).sort((e,t)=>e.localeCompare(t)).join(","):""}var to=(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 Bl="2.5.29.35",xl="2.5.29.14";function la(r){return to(this,null,function*(){const e=yield crypto.subtle.digest("SHA-256",r);return _r(e)})}function Cl(r){const e=r.getExtension(Bl);return ca(e==null?void 0:e.keyId)}function Nl(r){const e=r.getExtension(xl);return ca(e==null?void 0:e.keyId)}function El(r){return to(this,arguments,function*(e,t={}){const i=new R.X509Certificate(e);let n=t.certificateChain&&t.certificateChain.length>0?Gs(i,t.certificateChain):null;return!n&&t.fetchOptions&&(n=yield Xs(i,t.fetchOptions.timeout,t.fetchOptions.proxyUrl)),{issuerSubjectDn:eo(i.issuer),authorityKeyIdentifierHex:Cl(i),issuerCertificate:n?{subjectDn:eo(n.subject),spkiSha256Hex:yield la(n.publicKey.rawData)}:null}})}function Il(r){return to(this,null,function*(){const e=new R.X509Certificate(r);return{subjectDn:eo(e.subject),subjectKeyIdentifierHex:Nl(e),spkiSha256Hex:yield la(e.publicKey.rawData)}})}var Ol=Object.defineProperty,ua=Object.getOwnPropertySymbols,Tl=Object.prototype.hasOwnProperty,Vl=Object.prototype.propertyIsEnumerable,fa=(r,e,t)=>e in r?Ol(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,Qt=(r,e)=>{for(var t in e||(e={}))Tl.call(e,t)&&fa(r,t,e[t]);if(ua)for(var t of ua(e))Vl.call(e,t)&&fa(r,t,e[t]);return r},nt=(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 U(r,e,t,i,n){return Qt(Qt({check:r,label:e,status:t},i?{detail:i}:{}),n?{country:n}:{})}function ha(r){const e=Object.entries(r.details).filter(([t,i])=>!i.matches).map(([t])=>t).join(", ");return e?`Checksum validation failed for files: ${e}`:"Checksum validation failed"}function da(r,e,t,i,n,o){return i?U(r,e,"indeterminate",i):t?t.confidence==="dn_only"&&!o?U(r,e,"indeterminate",t.detail||n,t.country):t.trustedAtTime===!0?U(r,e,"pass",t.detail,t.country):t.trustedAtTime===!1||!t.found?U(r,e,"fail",t.detail,t.country):U(r,e,"indeterminate",t.detail||n,t.country):U(r,e,"indeterminate",n)}function Ul({options:r,signatureInfo:e,certificateValidityAtSigningTime:t,certificateResult:i,checksumResult:n,signatureResult:o,timestampResult:s,overallStatus:c,trustListMatch:l,trustListError:f,timestampTrustListMatch:d,timestampTrustListError:p}){var g;const y=[];return r.verifyChecksums===!1?y.push(U("document_integrity","Document integrity","skipped","Checksum verification not enabled")):y.push(U("document_integrity","Document integrity",n.isValid?"pass":"fail",n.isValid?void 0:ha(n))),r.verifySignatures===!1?y.push(U("signature_valid","Signature cryptographically valid","skipped","Signature verification not enabled")):o.unsupportedPlatform?y.push(U("signature_valid","Signature cryptographically valid","indeterminate",o.reason||"Signature verification is not supported on this platform")):y.push(U("signature_valid","Signature cryptographically valid",o.isValid?"pass":"fail",o.isValid?void 0:o.reason)),t.isValid?y.push(U("certificate_valid_at_signing_time","Certificate valid at trusted signing time","pass")):y.push(U("certificate_valid_at_signing_time","Certificate valid at trusted signing time",c==="INDETERMINATE"?"indeterminate":"fail",t.reason||i.reason)),e.signatureTimestamp?y.push(U("timestamp_present","Signature timestamp present","pass")):y.push(U("timestamp_present","Signature timestamp present","skipped","Signature timestamp not present")),e.signatureTimestamp?r.verifyTimestamps===!1?y.push(U("timestamp_valid","Timestamp valid and bound to signature","skipped","Timestamp verification not enabled")):s?s.coversSignature===!1?y.push(U("timestamp_valid","Timestamp valid and bound to signature","fail",s.reason||"Timestamp token does not cover the signature value")):s.isValid?s.coversSignature===!0?y.push(U("timestamp_valid","Timestamp valid and bound to signature","pass")):y.push(U("timestamp_valid","Timestamp valid and bound to signature","indeterminate",s.reason||"Timestamp token verified, but signature binding could not be confirmed")):y.push(U("timestamp_valid","Timestamp valid and bound to signature","fail",s.reason||"Timestamp verification failed")):y.push(U("timestamp_valid","Timestamp valid and bound to signature","indeterminate","Timestamp verification did not return a result")):y.push(U("timestamp_valid","Timestamp valid and bound to signature","skipped","Signature timestamp not present")),e.signatureTimestamp?r.verifyTimestamps===!1?y.push(U("timestamp_authority_trusted_at_signing_time","Timestamp authority trusted at signing time","skipped","Timestamp verification not enabled")):r.trustListProvider?(g=s==null?void 0:s.info)!=null&&g.tsaCertificate?y.push(da("timestamp_authority_trusted_at_signing_time","Timestamp authority trusted at signing time",d,p,"Timestamp authority trust check did not return a result",r.allowWeakDnOnlyTrustMatch===!0)):y.push(U("timestamp_authority_trusted_at_signing_time","Timestamp authority trusted at signing time","indeterminate",(s==null?void 0:s.reason)||"Timestamp verification did not produce a TSA certificate")):y.push(U("timestamp_authority_trusted_at_signing_time","Timestamp authority trusted at signing time","skipped","Trusted-list provider not configured")):y.push(U("timestamp_authority_trusted_at_signing_time","Timestamp authority trusted at signing time","skipped","Signature timestamp not present")),r.checkRevocation===!1?y.push(U("certificate_not_revoked_at_signing_time","Certificate not revoked at signing time","skipped","Revocation check not enabled")):i.revocation?i.revocation.status==="good"||i.revocation.isValid?y.push(U("certificate_not_revoked_at_signing_time","Certificate not revoked at signing time","pass",i.revocation.reason)):i.revocation.status==="unknown"||i.revocation.status==="error"?y.push(U("certificate_not_revoked_at_signing_time","Certificate not revoked at signing time","indeterminate",i.revocation.reason)):y.push(U("certificate_not_revoked_at_signing_time","Certificate not revoked at signing time","fail",i.revocation.reason)):y.push(U("certificate_not_revoked_at_signing_time","Certificate not revoked at signing time","skipped","Revocation check was not performed")),r.trustListProvider?y.push(da("issuer_trusted_at_signing_time","Issuer trusted at signing time",l,f,"Issuer trust check did not return a result",r.allowWeakDnOnlyTrustMatch===!0)):y.push(U("issuer_trusted_at_signing_time","Issuer trusted at signing time","skipped","Trusted-list provider not configured")),y}function er(){return typeof window!="undefined"&&typeof window.crypto!="undefined"&&typeof window.crypto.subtle!="undefined"}function Rl(){if(typeof navigator=="undefined")return!1;const r=navigator.userAgent,e=/AppleWebKit/.test(r),t=/Chrome/.test(r)||/Chromium/.test(r)||/Edg/.test(r);return e&&!t}function Dl(r){const e=new Uint8Array(r),t=[6,9,42,134,72,134,247,13,1,1,1];let i=-1;for(let c=0;c<=e.length-t.length;c++){let l=!0;for(let f=0;f<t.length;f++)if(e[c+f]!==t[f]){l=!1;break}if(l){i=c;break}}if(i===-1)return 0;let n=-1;for(let c=i+t.length;c<e.length;c++)if(e[c]===3){n=c;break}if(n===-1)return 0;let o=n+1;if((e[o]&128)===0?o+=1:o+=1+(e[o]&127),o+=1,e[o]!==48||(o+=1,(e[o]&128)===0?o+=1:o+=1+(e[o]&127),e[o]!==2))return 0;o+=1;let s=0;if((e[o]&128)===0)s=e[o];else{const c=e[o]&127;for(let l=0;l<c;l++)s=s<<8|e[o+1+l]}return s*8}function jl(r){return!er()||!Rl()?!0:r<=4096}function pa(r,e){return nt(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 er()?Ll(r,i):_l(r,i)})}function Ll(r,e){return nt(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,new Uint8Array(r)),n=Array.from(new Uint8Array(i));return btoa(String.fromCharCode.apply(null,n))})}function _l(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 Hl(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 ya(r,e){return nt(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=>nt(null,[s],function*([c,l]){var f;const d=(f=r.digestAlgorithms)!=null&&f[c]?Hl(r.digestAlgorithms[c]):n,p=e.get(c);if(p){const g=yield pa(p,d),y=l===g;t[c]={expected:l,actual:g,matches:y,fileFound:!0},y||(i=!1)}else{const g=c.includes("/")?c.split("/").pop():c;let y=!1;if(g){for(const[v,k]of e.entries())if(v.endsWith(g)){const w=yield pa(k,d),A=l===w;t[c]={expected:l,actual:w,matches:A,fileFound:!0},A||(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 $l(r){return nt(this,arguments,function*(e,t=new Date){try{const i=new R.X509Certificate(e),n=Ca(i,t),o=yield lo(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 Ml(r){switch(r){case"P-256":return 32;case"P-384":return 48;case"P-521":return 66;default:return 32}}function Pl(r,e){const t=Ml(e),i=t*2;if(r.length===i)return r;if(r[0]===48)return ql(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=li(o,t),l=li(s,t),f=new Uint8Array(i);return f.set(c,0),f.set(l,t),f}}return r}function li(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 ql(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(li(o,e),0),l.set(li(c,e),e),l}function ga(){return er()?window.crypto.subtle:crypto.subtle}function Fl(r,e,t,i,n){return nt(this,null,function*(){try{const o=oo().parseFromString(r,"application/xml"),s=W(o,"ds:SignedInfo");if(!s)return{isValid:!1,reason:"SignedInfo element not found in provided XML"};const c=n||ot.default,l=F.canonicalize(s,c),f=e.replace(/\s+/g,"");let d;try{d=_c(f)}catch(y){return{isValid:!1,reason:`Failed to decode signature value: ${y instanceof Error?y.message:String(y)}`}}i.name==="ECDSA"&&(d=Pl(d,i.namedCurve));let p;try{const y=ga(),v=i.name==="RSASSA-PKCS1-v1_5"||i.name==="RSA-PSS";if(v){const k=Dl(t);if(k>0&&!jl(k))return{isValid:!1,unsupportedPlatform:!0,reason:`RSA key size (${k} bits) not supported in this browser`,errorDetails:{category:"RSA_KEY_SIZE_UNSUPPORTED",originalMessage:"Safari/WebKit only supports RSA keys up to 4096 bits",algorithm:Qt({},i),environment:"browser",keyLength:t.byteLength}}}if(er()&&v)try{p=yield y.importKey("spki",t,i,!1,["verify"])}catch(k){const w=$a(t);p=yield y.importKey("spki",w,i,!1,["verify"])}else p=yield y.importKey("spki",t,i,!1,["verify"])}catch(y){const v=y instanceof Error?y:new Error(String(y));let k="Unknown reason",w="KEY_IMPORT_ERROR";if(v.name==="DataError"?(k="Key data format is invalid or incompatible",w="INVALID_KEY_FORMAT"):v.name==="NotSupportedError"?(k="Algorithm or parameters not supported",w="UNSUPPORTED_ALGORITHM"):v.message.includes("namedCurve")?(k="Missing or invalid namedCurve parameter",w="INVALID_CURVE"):v.message.includes("hash")&&(k="Incompatible or unsupported hash algorithm",w="INVALID_HASH"),i.name==="ECDSA"){const A=t.byteLength;k+=` (Key length: ${A})`}return{isValid:!1,reason:`Failed to import public key: ${k}`,errorDetails:{category:w,originalMessage:v.message,algorithm:Qt({},i),environment:er()?"browser":"node",keyLength:t.byteLength}}}const g=new TextEncoder().encode(l);try{return(yield ga().verify(i,p,new Uint8Array(d),new Uint8Array(g)))?{isValid:!0}:i.name==="RSASSA-PKCS1-v1_5"&&(yield sa(t,d,g,i.hash))?{isValid:!0}:{isValid:!1,reason:"Signature verification failed"}}catch(y){return i.name==="RSASSA-PKCS1-v1_5"&&(yield sa(t,d,g,i.hash))?{isValid:!0}:{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 zl(r,e){return nt(this,arguments,function*(t,i,n={}){var o,s,c,l,f,d;const p=[];let g,y,v,k,w,A=n.verifyTime||t.signingTime;t.signatureTimestamp&&n.verifyTimestamps!==!1&&(g=yield na(t.signatureTimestamp,{canonicalSignatureValue:t.canonicalSignatureValue,verifyTsaCertificate:!0,revocationOptions:n.revocationOptions}),g.isValid&&g.info?A=g.info.genTime:g.isValid||p.push(`Timestamp verification failed: ${g.reason||"Unknown reason"}`));const I=yield $l(t.certificatePEM,A),_e={isValid:I.isValid,reason:I.reason};if(!I.isValid){const B=`Certificate validation error: ${I.reason||"Unknown reason"}`;p.push(B)}if(n.checkRevocation!==!1&&I.isValid)try{const B=yield wn(t.certificatePEM,Qt({certificateChain:t.certificateChain},n.revocationOptions));if(I.revocation=B,B.status==="revoked"){const L=B.revokedAt,pe=L&&L.getTime()>0;if(pe&&A<L)I.revocation.isValid=!0,I.revocation.reason=`Certificate was revoked on ${L.toISOString()}, but signature was made on ${A.toISOString()} (before revocation)`;else{I.isValid=!1;const se=pe?` on ${L.toISOString()}`:"";I.reason=B.reason||`Certificate has been revoked${se}`,p.push(B.reason||`Certificate revoked${se}`)}}}catch(B){I.revocation={isValid:!1,status:"error",method:"none",reason:`Revocation check failed: ${B instanceof Error?B.message:String(B)}`,checkedAt:new Date}}if(n.trustListProvider){try{const B=yield El(t.certificatePEM,{certificateChain:t.certificateChain,fetchOptions:n.trustedListFetchOptions});y=yield n.trustListProvider.match({purpose:"signature_issuer",subjectDn:B.issuerSubjectDn,skiHex:B.authorityKeyIdentifierHex,spkiSha256Hex:(o=B.issuerCertificate)==null?void 0:o.spkiSha256Hex,time:A})}catch(B){v=`Trusted list check failed: ${B instanceof Error?B.message:String(B)}`,p.push(v)}if((s=g==null?void 0:g.info)!=null&&s.tsaCertificate&&g.info.genTime)try{const B=yield Il(g.info.tsaCertificate);k=yield n.trustListProvider.match({purpose:"timestamp_tsa",subjectDn:B.subjectDn,skiHex:B.subjectKeyIdentifierHex,spkiSha256Hex:B.spkiSha256Hex,time:g.info.genTime})}catch(B){w=`Timestamp authority trusted-list check failed: ${B instanceof Error?B.message:String(B)}`,p.push(w)}}const re=n.verifyChecksums!==!1?yield ya(t,i):{isValid:!0,details:{}},de=re.isValid?void 0:ha(re);de&&p.push(de);let x={isValid:!0};if(n.verifySignatures!==!1&&t.rawXml&&t.signatureValue&&t.publicKey){const B=t.algorithm||"",L={name:"RSASSA-PKCS1-v1_5",hash:"SHA-256"};if(B.includes("ecdsa")&&t.publicKey.namedCurve&&(L.namedCurve=t.publicKey.namedCurve,L.name="ECDSA"),B.includes("ecdsa-sha256")?L.hash="SHA-256":B.includes("ecdsa-sha384")?L.hash="SHA-384":B.includes("ecdsa-sha512")?L.hash="SHA-512":B.includes("rsa-sha1")?L.hash="SHA-1":B.includes("rsa-pss")?(L.name="RSA-PSS",L.saltLength=32,B.includes("sha384")?(L.hash="SHA-384",L.saltLength=48):B.includes("sha512")?(L.hash="SHA-512",L.saltLength=64):L.hash="SHA-256"):B.includes("rsa-sha384")?L.hash="SHA-384":B.includes("rsa-sha512")&&(L.hash="SHA-512"),x=yield Fl(t.rawXml,t.signatureValue,t.publicKey.rawData,L,t.canonicalizationMethod),!x.isValid){let pe=x.reason||"XML signature verification failed";if(x.errorDetails){const se=x.errorDetails;pe+=` [Category: ${se.category}, Environment: ${se.environment}`,se.algorithm&&(pe+=`, Algorithm: ${se.algorithm.name}`,se.algorithm.namedCurve&&(pe+=`, Curve: ${se.algorithm.namedCurve}`)),se.keyLength&&(pe+=`, Key length: ${se.keyLength} bytes`),pe+="]"}p.push(pe)}}else if(n.verifySignatures!==!1){const B=[];t.rawXml||B.push("Signature XML"),t.signatureValue||B.push("SignatureValue"),t.publicKey||B.push("Public Key"),p.push(`Cannot verify XML signature: missing ${B.join(", ")}`),x={isValid:!1,reason:`Missing required components: ${B.join(", ")}`}}const T=!t.signatureTimestamp||n.verifyTimestamps===!1||((c=g==null?void 0:g.isValid)!=null?c:!0),H=I.isValid&&re.isValid&&x.isValid&&T;let $="VALID",Q;const He=[];H||(x.unsupportedPlatform?($="UNSUPPORTED",Q=x.reason,He.push({code:"RSA_KEY_SIZE_UNSUPPORTED",description:x.reason||"RSA key size not supported",platform:"Safari/WebKit"})):re.isValid?!x.isValid&&!x.unsupportedPlatform?($="INVALID",Q=x.reason||"Signature verification failed"):I.isValid?g&&!g.isValid?($="INDETERMINATE",Q=g.reason||"Timestamp verification failed",He.push({code:"TIMESTAMP_VERIFICATION_FAILED",description:g.reason||"Could not verify timestamp to establish proof of existence"})):((d=I.revocation)==null?void 0:d.status)==="unknown"?($="INDETERMINATE",Q="Certificate revocation status could not be determined",He.push({code:"REVOCATION_UNKNOWN",description:I.revocation.reason||"Could not check certificate revocation status"})):($="INVALID",Q=p[0]||"Verification failed"):(l=I.reason)!=null&&l.includes("expired")&&!(g!=null&&g.isValid)?($="INDETERMINATE",Q="Certificate expired and no valid timestamp proof",He.push({code:"CERT_EXPIRED_NO_POE",description:"Certificate has expired and there is no valid timestamp to prove signature was made when certificate was valid"})):((f=I.revocation)==null?void 0:f.status)==="revoked"?($="INVALID",Q="Certificate has been revoked"):($="INDETERMINATE",Q=I.reason||"Certificate validation inconclusive"):($="INVALID",Q="File integrity check failed"));const tr=n.includeChecklist?Ul({options:n,signatureInfo:t,certificateValidityAtSigningTime:_e,certificateResult:I,checksumResult:re,signatureResult:x,timestampResult:g,overallStatus:$,trustListMatch:y,trustListError:v,timestampTrustListMatch:k,timestampTrustListError:w}):void 0;return{isValid:H,status:$,statusMessage:Q,limitations:He.length>0?He:void 0,certificate:I,checksums:re,signature:n.verifySignatures!==!1?x:void 0,timestamp:g,checklist:tr,trustListMatch:y,timestampTrustListMatch:k,errors:p.length>0?p:void 0}})}N.CANONICALIZATION_METHODS=ot,N.XMLCanonicalizer=F,N.checkCertificateRevocation=wn,N.formatValidityPeriod=Ea,N.getSignerDisplayName=Na,N.getTimestampTime=ul,N.parseCertificate=lo,N.parseEdoc=Ha,N.parseTimestamp=Yn,N.verifyChecksums=ya,N.verifySignature=zl,N.verifyTimestamp=na,Object.defineProperty(N,"__esModule",{value:!0})}));
82
79
  //# sourceMappingURL=index.umd.js.map