edockit 0.3.0 → 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.
- package/CHANGELOG.md +17 -0
- package/README.md +81 -198
- package/TRUSTED-LIST.md +308 -0
- package/dist/certificate-c46e14a0.js +560 -0
- package/dist/certificate-c46e14a0.js.map +1 -0
- package/dist/certificate-fc0e06f7.js +571 -0
- package/dist/certificate-fc0e06f7.js.map +1 -0
- package/dist/core/canonicalization/XMLCanonicalizer.d.ts +9 -3
- package/dist/core/trustedlist/build.d.ts +41 -0
- package/dist/core/trustedlist/bundled-provider.d.ts +2 -0
- package/dist/core/trustedlist/contract.d.ts +19 -0
- package/dist/core/trustedlist/dom.d.ts +12 -0
- package/dist/core/trustedlist/extract.d.ts +6 -0
- package/dist/core/trustedlist/http.d.ts +8 -0
- package/dist/core/trustedlist/identity.d.ts +7 -0
- package/dist/core/trustedlist/index.d.ts +18 -0
- package/dist/core/trustedlist/loader.d.ts +5 -0
- package/dist/core/trustedlist/matcher.d.ts +11 -0
- package/dist/core/trustedlist/normalize.d.ts +14 -0
- package/dist/core/trustedlist/reference-provider.d.ts +12 -0
- package/dist/core/trustedlist/types.d.ts +114 -0
- package/dist/core/unzip.d.ts +0 -0
- package/dist/core/verification.d.ts +22 -0
- package/dist/data/trusted-list.d.ts +3 -0
- package/dist/identity-1a3dddc3.js +902 -0
- package/dist/identity-1a3dddc3.js.map +1 -0
- package/dist/identity-b3a70fc1.js +897 -0
- package/dist/identity-b3a70fc1.js.map +1 -0
- package/dist/index.cjs.js +909 -8003
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.d.ts +4 -2
- package/dist/index.esm.js +417 -7510
- package/dist/index.esm.js.map +1 -1
- package/dist/index.umd.js +12 -12
- package/dist/index.umd.js.map +1 -1
- package/dist/loader-1ac52e12.js +217 -0
- package/dist/loader-1ac52e12.js.map +1 -0
- package/dist/loader-43d8e17a.js +222 -0
- package/dist/loader-43d8e17a.js.map +1 -0
- package/dist/normalize-60f2d7e6.js +6270 -0
- package/dist/normalize-60f2d7e6.js.map +1 -0
- package/dist/normalize-70da6516.js +6214 -0
- package/dist/normalize-70da6516.js.map +1 -0
- package/dist/reference-provider-1cd85b7b.js +217 -0
- package/dist/reference-provider-1cd85b7b.js.map +1 -0
- package/dist/reference-provider-53240217.js +211 -0
- package/dist/reference-provider-53240217.js.map +1 -0
- package/dist/trusted-list-build.cjs.js +575 -0
- package/dist/trusted-list-build.cjs.js.map +1 -0
- package/dist/trusted-list-build.d.ts +4 -0
- package/dist/trusted-list-build.esm.js +564 -0
- package/dist/trusted-list-build.esm.js.map +1 -0
- package/dist/trusted-list-bundled.cjs.js +30436 -0
- package/dist/trusted-list-bundled.cjs.js.map +1 -0
- package/dist/trusted-list-bundled.d.ts +1 -0
- package/dist/trusted-list-bundled.esm.js +30432 -0
- package/dist/trusted-list-bundled.esm.js.map +1 -0
- package/dist/trusted-list-http.cjs.js +85 -0
- package/dist/trusted-list-http.cjs.js.map +1 -0
- package/dist/trusted-list-http.d.ts +1 -0
- package/dist/trusted-list-http.esm.js +81 -0
- package/dist/trusted-list-http.esm.js.map +1 -0
- package/dist/trusted-list.cjs.js +35 -0
- package/dist/trusted-list.cjs.js.map +1 -0
- package/dist/trusted-list.d.ts +9 -0
- package/dist/trusted-list.esm.js +10 -0
- package/dist/trusted-list.esm.js.map +1 -0
- package/package.json +32 -2
package/dist/index.umd.js
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
var
|
|
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(
|
|
5
|
-
`)&&(l=!0)}else
|
|
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,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}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,"
"):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,"
"):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-----
|
|
6
6
|
${t.join(`
|
|
7
7
|
`)}
|
|
8
|
-
-----END CERTIFICATE-----`}function
|
|
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-----
|
|
9
9
|
${t.join(`
|
|
10
10
|
`)}
|
|
11
|
-
-----END CERTIFICATE-----`}var
|
|
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};/*!
|
|
12
12
|
* MIT License
|
|
13
13
|
*
|
|
14
14
|
* Copyright (c) 2017-2024 Peculiar Ventures, LLC
|
|
@@ -31,9 +31,9 @@ ${t.join(`
|
|
|
31
31
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
32
32
|
* SOFTWARE.
|
|
33
33
|
*
|
|
34
|
-
*/const
|
|
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}/*!
|
|
35
35
|
Copyright (c) Peculiar Ventures, LLC
|
|
36
|
-
*/function
|
|
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)}/*!
|
|
37
37
|
* Copyright (c) 2014, GMO GlobalSign
|
|
38
38
|
* Copyright (c) 2015-2022, Peculiar Ventures
|
|
39
39
|
* All rights reserved.
|
|
@@ -65,15 +65,15 @@ ${t.join(`
|
|
|
65
65
|
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
|
66
66
|
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
67
67
|
*
|
|
68
|
-
*/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 ke(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 Yt{constructor(){this.items=[]}write(e){this.items.push(e)}final(){return oi(this.items)}}const bt=[new Uint8Array([1])],co="0123456789",si="name",lo="valueHexView",ja="isHexOnly",Da="idBlock",Ra="tagClass",La="tagNumber",Ha="isConstructed",$a="fromBER",Ma="toBER",Pa="local",ee="",le=new ArrayBuffer(0),Zt=new Uint8Array(0),At="EndOfContent",uo="OCTET STRING",fo="BIT STRING";function we(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?I.toUint8Array(o.valueHex):Zt}fromBER(i,n,o){const s=i instanceof ArrayBuffer?new Uint8Array(i):i;if(!ke(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",le)}toJSON(){return P(j({},super.toJSON()),{isHexOnly:this.isHexOnly,valueHex:L.ToHex(this.valueHexView)})}},e.NAME="hexBlock",e}class He{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=ee,warnings:i=[],valueBeforeDecode:n=Zt}={}){this.blockLength=e,this.error=t,this.warnings=i,this.valueBeforeDecodeView=I.toUint8Array(n)}toJSON(){return{blockName:this.constructor.NAME,blockLength:this.blockLength,error:this.error,warnings:this.warnings,valueBeforeDecode:L.ToHex(this.valueBeforeDecodeView)}}}He.NAME="baseBlock";class Y extends He{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'")}}Y.NAME="valueBlock";class ho extends we(He){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?I.toUint8Array(e.valueHex):Zt,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",le}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=Le(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=I.toUint8Array(e);if(!ke(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),h=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===h){h+=255;const g=new Uint8Array(h);for(let y=0;y<f.length;y++)g[y]=f[y];f=this.valueHexView=new Uint8Array(h)}}this.blockLength=l+1,f[l-1]=o[l]&127;const d=new Uint8Array(l);for(let g=0;g<l;g++)d[g]=f[g];f=this.valueHexView=new Uint8Array(l),f.set(d),this.blockLength<=9?this.tagNumber=Qe(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 P(j({},super.toJSON()),{tagClass:this.tagClass,tagNumber:this.tagNumber,isConstructed:this.isConstructed})}}ho.NAME="identificationBlock";class po extends He{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=I.toUint8Array(e);if(!ke(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=Qe(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=Le(this.length,8);if(n.byteLength>127)return this.error="Too big length",le;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 P(j({},super.toJSON()),{isIndefiniteForm:this.isIndefiniteForm,longFormUsed:this.longFormUsed,length:this.length})}}po.NAME="lengthBlock";const A={};class G extends He{constructor(s={},o){var c=s,{name:e=ee,optional:t=!1,primitiveSchema:i}=c,n=H(c,["name","optional","primitiveSchema"]);super(n),this.name=e,this.optional=t,i&&(this.primitiveSchema=i),this.idBlock=new ho(n),this.lenBlock=new po(n),this.valueBlock=o?new o(n):new Y(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 Yt;t||yo(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?le:i.final()}toJSON(){const e=P(j({},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():L.ToHex(this.toBER())}onAsciiEncoding(){const e=this.constructor.NAME,t=L.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 Ua(t,i)}}G.NAME="BaseBlock";function yo(r){var e;if(r instanceof A.Constructed)for(const t of r.valueBlock.value)yo(t)&&(r.lenBlock.isIndefiniteForm=!0);return!!(!((e=r.lenBlock)===null||e===void 0)&&e.isIndefiniteForm)}class ai extends G{getValue(){return this.valueBlock.value}setValue(e){this.valueBlock.value=e}constructor(n={},i){var o=n,{value:e=ee}=o,t=H(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 go extends we(Y){constructor(i={}){var n=i,{isHexOnly:e=!0}=n,t=H(n,["isHexOnly"]);super(t),this.isHexOnly=e}}go.NAME="PrimitiveValueBlock";var vo;class St extends G{constructor(e={}){super(e,go),this.idBlock.isConstructed=!1}}vo=St,A.Primitive=vo,St.NAME="PRIMITIVE";function _a(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 et(r,e=0,t=r.length){const i=e;let n=new G({},Y);const o=new He;if(!ke(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=G;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=A.EndOfContent;break;case 1:l=A.Boolean;break;case 2:l=A.Integer;break;case 3:l=A.BitString;break;case 4:l=A.OctetString;break;case 5:l=A.Null;break;case 6:l=A.ObjectIdentifier;break;case 10:l=A.Enumerated;break;case 12:l=A.Utf8String;break;case 13:l=A.RelativeObjectIdentifier;break;case 14:l=A.TIME;break;case 15:return n.error="[UNIVERSAL 15] is reserved by ASN.1 standard",{offset:-1,result:n};case 16:l=A.Sequence;break;case 17:l=A.Set;break;case 18:l=A.NumericString;break;case 19:l=A.PrintableString;break;case 20:l=A.TeletexString;break;case 21:l=A.VideotexString;break;case 22:l=A.IA5String;break;case 23:l=A.UTCTime;break;case 24:l=A.GeneralizedTime;break;case 25:l=A.GraphicString;break;case 26:l=A.VisibleString;break;case 27:l=A.GeneralString;break;case 28:l=A.UniversalString;break;case 29:l=A.CharacterString;break;case 30:l=A.BmpString;break;case 31:l=A.DATE;break;case 32:l=A.TimeOfDay;break;case 33:l=A.DateTime;break;case 34:l=A.Duration;break;default:{const f=n.idBlock.isConstructed?new A.Constructed:new A.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?A.Constructed:A.Primitive}return n=_a(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 tt(r){if(!r.byteLength){const e=new G({},Y);return e.error="Input buffer has zero length",{offset:-1,result:e}}return et(I.toUint8Array(r).slice(),0,r.byteLength)}function qa(r,e){return r?1:e}class Ue extends Y{constructor(n={}){var o=n,{value:e=[],isIndefiniteForm:t=!1}=o,i=H(o,["value","isIndefiniteForm"]);super(i),this.value=e,this.isIndefiniteForm=t}fromBER(e,t,i){const n=I.toUint8Array(e);if(!ke(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(;qa(this.isIndefiniteForm,i)>0;){const s=et(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===At)break}return this.isIndefiniteForm&&(this.value[this.value.length-1].constructor.NAME===At?this.value.pop():this.warnings.push("No EndOfContent block encoded")),o}toBER(e,t){const i=t||new Yt;for(let n=0;n<this.value.length;n++)this.value[n].toBER(e,i);return t?le:i.final()}toJSON(){const e=P(j({},super.toJSON()),{isIndefiniteForm:this.isIndefiniteForm,value:[]});for(const t of this.value)e.value.push(t.toJSON());return e}}Ue.NAME="ConstructedValueBlock";var mo;class Z extends G{constructor(e={}){super(e,Ue),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(`
|
|
69
69
|
`).map(n=>` ${n}`).join(`
|
|
70
70
|
`));const t=this.idBlock.tagClass===3?`[${this.idBlock.tagNumber}]`:this.constructor.NAME;return e.length?`${t} :
|
|
71
71
|
${e.join(`
|
|
72
|
-
`)}`:`${t} :`}}mo=Z,A.Constructed=mo,Z.NAME="CONSTRUCTED";class wo extends Y{fromBER(e,t,i){return t}toBER(e){return le}}wo.override="EndOfContentValueBlock";var bo;class ci extends G{constructor(e={}){super(e,wo),this.idBlock.tagClass=1,this.idBlock.tagNumber=0}}bo=ci,A.EndOfContent=bo,ci.NAME=At;var Ao;class $e extends G{constructor(e={}){super(e,Y),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}`}}Ao=$e,A.Null=Ao,$e.NAME="NULL";class So extends we(Y){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=H(n,["value"]);super(t),t.valueHex?this.valueHexView=I.toUint8Array(t.valueHex):this.valueHexView=new Uint8Array(1),e&&(this.value=e)}fromBER(e,t,i){const n=I.toUint8Array(e);return ke(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,ao.call(this),this.blockLength=i,t+i):-1}toBER(){return this.valueHexView.slice()}toJSON(){return P(j({},super.toJSON()),{value:this.value})}}So.NAME="BooleanValueBlock";var Bo;class Qt extends G{getValue(){return this.valueBlock.value}setValue(e){this.valueBlock.value=e}constructor(e={}){super(e,So),this.idBlock.tagClass=1,this.idBlock.tagNumber=1}onAsciiEncoding(){return`${this.constructor.NAME} : ${this.getValue}`}}Bo=Qt,A.Boolean=Bo,Qt.NAME="BOOLEAN";class ko extends we(Ue){constructor(i={}){var n=i,{isConstructed:e=!1}=n,t=H(n,["isConstructed"]);super(t),this.isConstructed=e}fromBER(e,t,i){let n=0;if(this.isConstructed){if(this.isHexOnly=!1,n=Ue.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===At){if(this.isIndefiniteForm)break;return this.error="EndOfContent is unexpected, OCTET STRING may consists of OCTET STRINGs only",-1}if(s!==uo)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?Ue.prototype.toBER.call(this,e,t):e?new ArrayBuffer(this.valueHexView.byteLength):this.valueHexView.slice().buffer}toJSON(){return P(j({},super.toJSON()),{isConstructed:this.isConstructed})}}ko.NAME="OctetStringValueBlock";var li;class Me extends G{constructor(n={}){var o=n,{idBlock:e={},lenBlock:t={}}=o,i=H(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(j({idBlock:j({isConstructed:i.isConstructed},e),lenBlock:P(j({},t),{isIndefiniteForm:!!i.isIndefiniteForm})},i),ko),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=et(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 Z.prototype.onAsciiEncoding.call(this);const e=this.constructor.NAME,t=L.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 I.concat(e)}}li=Me,A.OctetString=li,Me.NAME=uo;class xo extends we(Ue){constructor(n={}){var o=n,{unusedBits:e=0,isConstructed:t=!1}=o,i=H(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=Ue.prototype.fromBER.call(this,e,t,i),n===-1)return n;for(const c of this.value){const l=c.constructor.NAME;if(l===At){if(this.isIndefiniteForm)break;return this.error="EndOfContent is unexpected, BIT STRING may consists of BIT STRINGs only",-1}if(l!==fo)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=I.toUint8Array(e);if(!ke(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=et(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 Ue.prototype.toBER.call(this,e,t);if(e)return new ArrayBuffer(this.valueHexView.byteLength+1);if(!this.valueHexView.byteLength)return le;const i=new Uint8Array(this.valueHexView.length+1);return i[0]=this.unusedBits,i.set(this.valueHexView,1),i.buffer}toJSON(){return P(j({},super.toJSON()),{unusedBits:this.unusedBits,isConstructed:this.isConstructed})}}xo.NAME="BitStringValueBlock";var No;class Pe extends G{constructor(n={}){var o=n,{idBlock:e={},lenBlock:t={}}=o,i=H(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(j({idBlock:j({isConstructed:i.isConstructed},e),lenBlock:P(j({},t),{isIndefiniteForm:!!i.isIndefiniteForm})},i),xo),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 Z.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}`}}}No=Pe,A.BitString=No,Pe.NAME=fo;var Co;function Fa(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 h=l<s?s:l;let d=0;for(let g=h;g>=0;g--,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 Eo(r){if(r>=bt.length)for(let e=bt.length;e<=r;e++){const t=new Uint8Array([0]);let i=bt[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)),bt.push(i)}return bt[r]}function Ga(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,h=0;for(let d=l;d>=0;d--,h++)switch(f=o[s-h]-c[l-h]-t,!0){case f<0:t=1,o[s-h]=f+10;break;default:t=0,o[s-h]=f}if(t>0)for(let d=s-l+1;d>=0;d--,h++)if(f=o[s-h]-t,f<0)t=1,o[s-h]=f+10;else{t=0,o[s-h]=f;break}return o.slice()}class ui extends we(Y){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=ao.call(this)))}constructor(i={}){var n=i,{value:e}=n,t=H(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(Va(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 P(j({},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=Ga(Eo(i),t),s="-";break;default:t=Fa(t,Eo(i))}i++,n>>=1}}for(let l=0;l<t.length;l++)t[l]&&(c=!0),c&&(s+=co.charAt(t[l]));return c===!1&&(s+=co.charAt(0)),s}}Co=ui,ui.NAME="IntegerValueBlock",Object.defineProperty(Co.prototype,"valueHex",{set:function(r){this.valueHexView=new Uint8Array(r),this.setValueHex()},get:function(){return this.valueHexView.slice().buffer}});var Bt;class rt extends G{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 Yt,n=t.toString(16).replace(/^-/,""),o=new Uint8Array(L.FromHex(n));if(t<0){const c=new Uint8Array(o.length+(o[0]&128?1:0));c[0]|=128;const f=BigInt(`0x${L.ToHex(c)}`)+t,h=I.toUint8Array(L.FromHex(f.toString(16)));h[0]|=128,i.write(h)}else o[0]&128&&i.write(new Uint8Array([0])),i.write(o);return new Bt({valueHex:i.final()})}convertToDER(){const e=new Bt({valueHex:this.valueBlock.valueHexView});return e.valueBlock.toDER(),e}convertFromDER(){return new Bt({valueHex:this.valueBlock.valueHexView[0]===0?this.valueBlock.valueHexView.subarray(1):this.valueBlock.valueHexView})}onAsciiEncoding(){return`${this.constructor.NAME} : ${this.valueBlock.toString()}`}}Bt=rt,A.Integer=Bt,rt.NAME="INTEGER";var Io;class er extends rt{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=10}}Io=er,A.Enumerated=Io,er.NAME="ENUMERATED";class fi extends we(Y){constructor(n={}){var o=n,{valueDec:e=-1,isFirstSid:t=!1}=o,i=H(o,["valueDec","isFirstSid"]);super(i),this.valueDec=e,this.isFirstSid=t}fromBER(e,t,i){if(!i)return t;const n=I.toUint8Array(e);if(!ke(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=Qe(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=Le(this.valueDec,7);if(t.byteLength===0)return this.error="Error during encoding SID value",le;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=L.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 P(j({},super.toJSON()),{valueDec:this.valueDec,isFirstSid:this.isFirstSid})}}fi.NAME="sidBlock";class Oo extends Y{constructor(i={}){var n=i,{value:e=ee}=n,t=H(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,le;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=P(j({},super.toJSON()),{value:this.toString(),sidArray:[]});for(let t=0;t<this.value.length;t++)e.sidArray.push(this.value[t].toJSON());return e}}Oo.NAME="ObjectIdentifierValueBlock";var To;class tr extends G{getValue(){return this.valueBlock.toString()}setValue(e){this.valueBlock.fromString(e)}constructor(e={}){super(e,Oo),this.idBlock.tagClass=1,this.idBlock.tagNumber=6}onAsciiEncoding(){return`${this.constructor.NAME} : ${this.valueBlock.toString()||"empty"}`}toJSON(){return P(j({},super.toJSON()),{value:this.getValue()})}}To=tr,A.ObjectIdentifier=To,tr.NAME="OBJECT IDENTIFIER";class hi extends we(He){constructor(i={}){var n=i,{valueDec:e=0}=n,t=H(n,["valueDec"]);super(t),this.valueDec=e}fromBER(e,t,i){if(i===0)return t;const n=I.toUint8Array(e);if(!ke(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=Qe(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=Le(this.valueDec,7);if(t.byteLength===0)return this.error="Error during encoding SID value",le;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=L.ToHex(this.valueHexView):e=this.valueDec.toString(),e}toJSON(){return P(j({},super.toJSON()),{valueDec:this.valueDec})}}hi.NAME="relativeSidBlock";class Vo extends Y{constructor(i={}){var n=i,{value:e=ee}=n,t=H(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,le;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=P(j({},super.toJSON()),{value:this.toString(),sidArray:[]});for(let t=0;t<this.value.length;t++)e.sidArray.push(this.value[t].toJSON());return e}}Vo.NAME="RelativeObjectIdentifierValueBlock";var Uo;class pi extends G{getValue(){return this.valueBlock.toString()}setValue(e){this.valueBlock.fromString(e)}constructor(e={}){super(e,Vo),this.idBlock.tagClass=1,this.idBlock.tagNumber=13}onAsciiEncoding(){return`${this.constructor.NAME} : ${this.valueBlock.toString()||"empty"}`}toJSON(){return P(j({},super.toJSON()),{value:this.getValue()})}}Uo=pi,A.RelativeObjectIdentifier=Uo,pi.NAME="RelativeObjectIdentifier";var jo;class ue extends Z{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=16}}jo=ue,A.Sequence=jo,ue.NAME="SEQUENCE";var Do;class be extends Z{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=17}}Do=be,A.Set=Do,be.NAME="SET";class Ro extends we(Y){constructor(t={}){var e=H(t,[]);super(e),this.isHexOnly=!0,this.value=ee}toJSON(){return P(j({},super.toJSON()),{value:this.value})}}Ro.NAME="StringValueBlock";class Lo extends Ro{}Lo.NAME="SimpleStringValueBlock";class ne extends ai{constructor(t={}){var e=H(t,[]);super(e,Lo)}fromBuffer(e){this.valueBlock.value=String.fromCharCode.apply(null,I.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}}ne.NAME="SIMPLE STRING";class Ho extends ne{fromBuffer(e){this.valueBlock.valueHexView=I.toUint8Array(e);try{this.valueBlock.value=L.ToUtf8String(e)}catch(t){this.warnings.push(`Error during "decodeURIComponent": ${t}, using raw string`),this.valueBlock.value=L.ToBinary(e)}}fromString(e){this.valueBlock.valueHexView=new Uint8Array(L.FromUtf8String(e)),this.valueBlock.value=e}}Ho.NAME="Utf8StringValueBlock";var $o;class xe extends Ho{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=12}}$o=xe,A.Utf8String=$o,xe.NAME="UTF8String";class Mo extends ne{fromBuffer(e){this.valueBlock.value=L.ToUtf16String(e),this.valueBlock.valueHexView=I.toUint8Array(e)}fromString(e){this.valueBlock.value=e,this.valueBlock.valueHexView=new Uint8Array(L.FromUtf16String(e))}}Mo.NAME="BmpStringValueBlock";var Po;class rr extends Mo{constructor(t={}){var e=H(t,[]);super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=30}}Po=rr,A.BmpString=Po,rr.NAME="BMPString";class _o extends ne{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=Le(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}}_o.NAME="UniversalStringValueBlock";var qo;class ir extends _o{constructor(t={}){var e=H(t,[]);super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=28}}qo=ir,A.UniversalString=qo,ir.NAME="UniversalString";var Fo;class nr extends ne{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=18}}Fo=nr,A.NumericString=Fo,nr.NAME="NumericString";var Go;class or extends ne{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=19}}Go=or,A.PrintableString=Go,or.NAME="PrintableString";var zo;class sr extends ne{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=20}}zo=sr,A.TeletexString=zo,sr.NAME="TeletexString";var Xo;class ar extends ne{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=21}}Xo=ar,A.VideotexString=Xo,ar.NAME="VideotexString";var Wo;class cr extends ne{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=22}}Wo=cr,A.IA5String=Wo,cr.NAME="IA5String";var Ko;class lr extends ne{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=25}}Ko=lr,A.GraphicString=Ko,lr.NAME="GraphicString";var Jo;class kt extends ne{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=26}}Jo=kt,A.VisibleString=Jo,kt.NAME="VisibleString";var Yo;class ur extends ne{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=27}}Yo=ur,A.GeneralString=Yo,ur.NAME="GeneralString";var Zo;class fr extends ne{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=29}}Zo=fr,A.CharacterString=Zo,fr.NAME="CharacterString";var Qo;class xt extends kt{constructor(n={}){var o=n,{value:e,valueDate:t}=o,i=H(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,I.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]=ie(this.year<2e3?this.year-1900:this.year-2e3,2),t[1]=ie(this.month,2),t[2]=ie(this.day,2),t[3]=ie(this.hour,2),t[4]=ie(this.minute,2),t[5]=ie(this.second,2),t[6]="Z",t.join("")}return super.toString(e)}onAsciiEncoding(){return`${this.constructor.NAME} : ${this.toDate().toISOString()}`}toJSON(){return P(j({},super.toJSON()),{year:this.year,month:this.month,day:this.day,hour:this.hour,minute:this.minute,second:this.second})}}Qo=xt,A.UTCTime=Qo,xt.NAME="UTCTime";var es;class hr extends xt{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,g=i.indexOf("+"),y="";if(g===-1&&(g=i.indexOf("-"),d=-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=d*v,y.length===4){if(v=parseInt(y.substring(2,4),10),isNaN(v.valueOf()))throw new Error("Wrong input string for conversion");l=d*v}}}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 h=s.exec(n);if(h===null)throw new Error("Wrong input string for conversion");for(let d=1;d<h.length;d++)switch(d){case 1:this.year=parseInt(h[d],10);break;case 2:this.month=parseInt(h[d],10);break;case 3:this.day=parseInt(h[d],10);break;case 4:this.hour=parseInt(h[d],10)+c;break;case 5:this.minute=parseInt(h[d],10)+l;break;case 6:this.second=parseInt(h[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(ie(this.year,4)),t.push(ie(this.month,2)),t.push(ie(this.day,2)),t.push(ie(this.hour,2)),t.push(ie(this.minute,2)),t.push(ie(this.second,2)),this.millisecond!==0&&(t.push("."),t.push(ie(this.millisecond,3))),t.push("Z"),t.join("")}return super.toString(e)}toJSON(){return P(j({},super.toJSON()),{millisecond:this.millisecond})}}es=hr,A.GeneralizedTime=es,hr.NAME="GeneralizedTime";var ts;class di extends xe{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=31}}ts=di,A.DATE=ts,di.NAME="DATE";var rs;class yi extends xe{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=32}}rs=yi,A.TimeOfDay=rs,yi.NAME="TimeOfDay";var is;class gi extends xe{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=33}}is=gi,A.DateTime=is,gi.NAME="DateTime";var ns;class vi extends xe{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=34}}ns=vi,A.Duration=ns,vi.NAME="Duration";var os;class mi extends xe{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=14}}os=mi,A.TIME=os,mi.NAME="TIME";class _e{constructor({name:e=ee,optional:t=!1}={}){this.name=e,this.optional=t}}class wi extends _e{constructor(i={}){var n=i,{value:e=[]}=n,t=H(n,["value"]);super(t),this.value=e}}class pr extends _e{constructor(n={}){var o=n,{value:e=new _e,local:t=!1}=o,i=H(o,["value","local"]);super(i),this.value=e,this.local=t}}class za{get data(){return this.dataView.slice().buffer}set data(e){this.dataView=I.toUint8Array(e)}constructor({data:e=Zt}={}){this.dataView=I.toUint8Array(e)}fromBER(e,t,i){const n=t+i;return this.dataView=I.toUint8Array(e).subarray(t,n),n}toBER(e){return this.dataView.slice().buffer}}function je(r,e,t){if(t instanceof wi){for(const o of t.value)if(je(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 _e)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(!(Da in t))return{verified:!1,result:{error:"Wrong ASN.1 schema"}};if(!($a in t.idBlock))return{verified:!1,result:{error:"Wrong ASN.1 schema"}};if(!(Ma 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(Ra)===!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(La)===!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(Ha)===!1)return{verified:!1,result:{error:"Wrong ASN.1 schema"}};if(t.idBlock.isConstructed!==e.idBlock.isConstructed)return{verified:!1,result:r};if(!(ja 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(!(lo 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,ee),t.name&&(r[t.name]=e)),t instanceof A.Constructed){let o=0,s={verified:!1,result:{error:"Unknown error"}},c=t.valueBlock.value.length;if(c>0&&t.valueBlock.value[0]instanceof pr&&(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,ee),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,ee),t.name&&(delete r[t.name],f.name=t.name)),f}}else if(t.valueBlock.value[0]instanceof pr){if(s=je(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,ee),t.name&&delete r[t.name]),s;if(si in t.valueBlock.value[0]&&t.valueBlock.value[0].name.length>0){let f={};Pa 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=je(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,ee),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,ee),t.name&&(delete r[t.name],l.name=t.name)),l}return{verified:!0,result:r}}if(t.primitiveSchema&&lo in e.valueBlock){const o=et(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,ee),t.name&&(delete r[t.name],s.name=t.name)),s}return je(r,o.result,t.primitiveSchema)}return{verified:!0,result:r}}function Xa(r,e){if(!(e instanceof Object))return{verified:!1,result:{error:"Wrong ASN.1 schema type"}};const t=et(I.toUint8Array(r));return t.offset===-1?{verified:!1,result:t.result}:je(t.result,t.result,e)}var ss=Object.freeze({__proto__:null,Any:_e,BaseBlock:G,BaseStringBlock:ai,BitString:Pe,BmpString:rr,Boolean:Qt,CharacterString:fr,Choice:wi,Constructed:Z,DATE:di,DateTime:gi,Duration:vi,EndOfContent:ci,Enumerated:er,GeneralString:ur,GeneralizedTime:hr,GraphicString:lr,HexBlock:we,IA5String:cr,Integer:rt,Null:$e,NumericString:nr,ObjectIdentifier:tr,OctetString:Me,Primitive:St,PrintableString:or,RawData:za,RelativeObjectIdentifier:pi,Repeated:pr,Sequence:ue,Set:be,TIME:mi,TeletexString:sr,TimeOfDay:yi,UTCTime:xt,UniversalString:ir,Utf8String:xe,ValueBlock:Y,VideotexString:ar,ViewWriter:Yt,VisibleString:kt,compareSchema:je,fromBER:tt,verifySchema:Xa}),m;(function(r){r[r.Sequence=0]="Sequence",r[r.Set=1]="Set",r[r.Choice=2]="Choice"})(m||(m={}));var p;(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"})(p||(p={}));class dr{constructor(e,t=0){if(this.unusedBits=0,this.value=new ArrayBuffer(0),e)if(typeof e=="number")this.fromNumber(e);else if(I.isBufferSource(e))this.unusedBits=t,this.value=I.toArrayBuffer(e);else throw TypeError("Unsupported type of 'params' argument for BitString")}fromASN(e){if(!(e instanceof Pe))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 Pe({unusedBits:this.unusedBits,valueHex:this.value})}toSchema(e){return new Pe({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):I.isBufferSource(e)?this.buffer=I.toArrayBuffer(e):Array.isArray(e)?this.buffer=new Uint8Array(e):this.buffer=new ArrayBuffer(0)}fromASN(e){if(!(e instanceof Me))throw new TypeError("Argument 'asn' is not instance of ASN.1 OctetString");return this.buffer=e.valueBlock.valueHex,this}toASN(){return new Me({valueHex:this.buffer})}toSchema(e){return new Me({name:e})}}const Wa={fromASN:r=>r instanceof $e?null:r.valueBeforeDecodeView,toASN:r=>{if(r===null)return new $e;const e=tt(r);if(e.result.error)throw new Error(e.result.error);return e.result}},Ka={fromASN:r=>r.valueBlock.valueHexView.byteLength>=4?r.valueBlock.toString():r.valueBlock.valueDec,toASN:r=>new rt({value:+r})},Ja={fromASN:r=>r.valueBlock.valueDec,toASN:r=>new er({value:r})},oe={fromASN:r=>r.valueBlock.valueHexView,toASN:r=>new rt({valueHex:r})},Ya={fromASN:r=>r.valueBlock.valueHexView,toASN:r=>new Pe({valueHex:r})},Za={fromASN:r=>r.valueBlock.toString(),toASN:r=>new tr({value:r})},Qa={fromASN:r=>r.valueBlock.value,toASN:r=>new Qt({value:r})},bi={fromASN:r=>r.valueBlock.valueHexView,toASN:r=>new Me({valueHex:r})},ec={fromASN:r=>new O(r.getValue()),toASN:r=>r.toASN()};function ae(r){return{fromASN:e=>e.valueBlock.value,toASN:e=>new r({value:e})}}const tc=ae(xe),rc=ae(rr),ic=ae(ir),nc=ae(nr),oc=ae(or),sc=ae(sr),ac=ae(ar),cc=ae(cr),lc=ae(lr),uc=ae(kt),fc=ae(ur),hc=ae(fr),pc={fromASN:r=>r.toDate(),toASN:r=>new xt({valueDate:r})},dc={fromASN:r=>r.toDate(),toASN:r=>new hr({valueDate:r})},yc={fromASN:()=>null,toASN:()=>new $e};function Nt(r){switch(r){case p.Any:return Wa;case p.BitString:return Ya;case p.BmpString:return rc;case p.Boolean:return Qa;case p.CharacterString:return hc;case p.Enumerated:return Ja;case p.GeneralString:return fc;case p.GeneralizedTime:return dc;case p.GraphicString:return lc;case p.IA5String:return cc;case p.Integer:return Ka;case p.Null:return yc;case p.NumericString:return nc;case p.ObjectIdentifier:return Za;case p.OctetString:return bi;case p.PrintableString:return oc;case p.TeletexString:return sc;case p.UTCTime:return pc;case p.UniversalString:return ic;case p.Utf8String:return tc;case p.VideotexString:return ac;case p.VisibleString:return uc;default:return null}}function Ne(r){return typeof r=="function"&&r.prototype?r.prototype.toASN&&r.prototype.fromASN?!0:Ne(r.prototype):!!(r&&typeof r=="object"&&"toASN"in r&&"fromASN"in r)}function as(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:as(t)}return!1}function gc(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 h=p[s.type],d=ss[h];if(!d)throw new Error(`Cannot get ASN1 class by name '${h}'`);l=new d({name:c})}else Ne(s.type)?l=new s.type().toSchema(c):s.optional?this.get(s.type).type===m.Choice?l=new _e({name:c}):(l=this.create(s.type,!1),l.name=c):l=new _e({name:c});const f=!!s.optional||s.defaultValue!==void 0;if(s.repeated){l.name="";const h=s.repeated==="set"?be:ue;l=new h({name:"",value:[new pr({name:c,value:l})]})}if(s.context!==null&&s.context!==void 0)if(s.implicit)if(typeof s.type=="number"||Ne(s.type)){const h=s.repeated?Z:St;n.push(new h({name:c,optional:f,idBlock:{tagClass:3,tagNumber:s.context}}))}else{this.cache(s.type);const h=!!s.repeated;let d=h?l:this.get(s.type,!0).schema;d="valueBlock"in d?d.valueBlock.value:d.value,n.push(new Z({name:h?"":c,optional:f,idBlock:{tagClass:3,tagNumber:s.context},value:d}))}else n.push(new Z({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 ue({value:n,name:""});case m.Set:return new be({value:n,name:""});case m.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 z=new vc,S=r=>e=>{let t;z.has(e)?t=z.get(e):(t=z.createDefault(e),z.set(e,t)),Object.assign(t,r)},u=r=>(e,t)=>{let i;z.has(e.constructor)?i=z.get(e.constructor):(i=z.createDefault(e.constructor),z.set(e.constructor,i));const n=Object.assign({},r);if(typeof n.type=="number"&&!n.converter){const o=Nt(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 Ct extends Error{constructor(){super(...arguments),this.schemas=[]}}class cs{static parse(e,t){const i=tt(e);if(i.result.error)throw new Error(i.result.error);return this.fromASN(i.result,t)}static fromASN(e,t){try{if(Ne(t))return new t().fromASN(e);const i=z.get(t);z.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 as(t)?this.handleArrayTypes(e,i,t):(this.processSchemaItems(i,s,c),c)}catch(i){throw i instanceof Ct&&i.schemas.push(t.name),i}}static handleChoiceTypes(e,t,i,n){if(e.constructor===Z&&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"&&z.has(s.type)){const c=z.get(s.type);if(c&&c.type===m.Sequence){const l=new ue;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),h=new i;return h[o]=f,{result:h}}}}}else if(e.constructor===Z&&t.type!==m.Choice){const o=new Z({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=je({},e,n);if(!o.verified)throw new Ct(`Data does not match to ${i.name} ASN1 schema.${o.result.error?` ${o.result.error}`:""}`);return o}else{const o=je({},e,n);if(!o.verified)throw new Ct(`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=Nt(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=Nt(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"&&z.has(e.type)&&z.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 Ct&&/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=Nt(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"||Ne(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:Ne(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"?ue:be,o=new n;o.valueBlock=e.valueBlock;const s=tt(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(Ne(i))s=new i().toSchema("");else{const c=p[i],l=ss[c];if(!l)throw new Error(`Cannot get '${c}' class from asn1js module`);s=new l}s.valueBlock=o.valueBlock,o=tt(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 Ct&&/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=z.get(i);if(n.type===m.Sequence){const o=new ue;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 be;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 G?e.toBER(!1):this.toASN(e).toBER(!1)}static toASN(e){if(e&&typeof e=="object"&&Ne(e))return e.toASN();if(!(e&&typeof e=="object"))throw new TypeError("Parameter 1 should be type of Object.");const t=e.constructor,i=z.get(t);z.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=Nt(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"&&gc(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"||Ne(c.type))){const h={};h.valueHex=f instanceof $e?f.valueBeforeDecodeView:f.valueBlock.toBER(),n.push(new St(j({optional:c.optional,idBlock:{tagClass:3,tagNumber:c.context}},h)))}else n.push(new Z({optional:c.optional,idBlock:{tagClass:3,tagNumber:c.context},value:f.valueBlock.value}));else n.push(new Z({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 ue({value:n});break;case m.Set:o=new be({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 ${p[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"?ue:be;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"?ue:be;o=new c({value:s})}else o=this.toASN(n);return o}}class R extends Array{constructor(e=[]){if(typeof e=="number")super(e);else{super();for(const t of e)this.push(t)}}}class fe{static serialize(e){return Ai.serialize(e)}static parse(e,t){return cs.parse(e,t)}static toString(e){const t=I.isBufferSource(e)?I.toArrayBuffer(e):fe.serialize(e),i=tt(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 ls=Si=class extends R{constructor(e){super(e),Object.setPrototypeOf(this,Si.prototype)}};ls=Si=a([S({type:m.Sequence,itemType:p.ObjectIdentifier})],ls);let Bi=class{constructor(e=new Date){this.value=e}};a([u({type:p.GeneralizedTime})],Bi.prototype,"value",void 0),Bi=a([S({type:m.Choice})],Bi);let ki=class{constructor(e=null){this.value=e}};a([u({type:p.Null})],ki.prototype,"value",void 0),ki=a([S({type:m.Choice})],ki);class us{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(L.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 he=class{constructor(e={}){Object.assign(this,e)}toString(){return this.bmpString||this.printableString||this.teletexString||this.universalString||this.utf8String||""}};a([u({type:p.TeletexString})],he.prototype,"teletexString",void 0),a([u({type:p.PrintableString})],he.prototype,"printableString",void 0),a([u({type:p.UniversalString})],he.prototype,"universalString",void 0),a([u({type:p.Utf8String})],he.prototype,"utf8String",void 0),a([u({type:p.BmpString})],he.prototype,"bmpString",void 0),he=a([S({type:m.Choice})],he);let it=class extends he{constructor(e={}){super(e),Object.assign(this,e)}toString(){return this.ia5String||(this.anyValue?L.ToHex(this.anyValue):super.toString())}};a([u({type:p.IA5String})],it.prototype,"ia5String",void 0),a([u({type:p.Any})],it.prototype,"anyValue",void 0),it=a([S({type:m.Choice})],it);class Ei{constructor(e={}){this.type="",this.value=new it,Object.assign(this,e)}}a([u({type:p.ObjectIdentifier})],Ei.prototype,"type",void 0),a([u({type:it})],Ei.prototype,"value",void 0);let yr=xi=class extends R{constructor(e){super(e),Object.setPrototypeOf(this,xi.prototype)}};yr=xi=a([S({type:m.Set,itemType:Ei})],yr);let Ii=Ni=class extends R{constructor(e){super(e),Object.setPrototypeOf(this,Ni.prototype)}};Ii=Ni=a([S({type:m.Sequence,itemType:yr})],Ii);let te=Ci=class extends Ii{constructor(e){super(e),Object.setPrototypeOf(this,Ci.prototype)}};te=Ci=a([S({type:m.Sequence})],te);const mc={fromASN:r=>us.toString(bi.fromASN(r)),toASN:r=>bi.toASN(us.fromString(r))};class Oi{constructor(e={}){this.typeId="",this.value=new ArrayBuffer(0),Object.assign(this,e)}}a([u({type:p.ObjectIdentifier})],Oi.prototype,"typeId",void 0),a([u({type:p.Any,context:0})],Oi.prototype,"value",void 0);class Ti{constructor(e={}){this.partyName=new he,Object.assign(this,e)}}a([u({type:he,optional:!0,context:0,implicit:!0})],Ti.prototype,"nameAssigner",void 0),a([u({type:he,context:1,implicit:!0})],Ti.prototype,"partyName",void 0);let T=class{constructor(e={}){Object.assign(this,e)}};a([u({type:Oi,context:0,implicit:!0})],T.prototype,"otherName",void 0),a([u({type:p.IA5String,context:1,implicit:!0})],T.prototype,"rfc822Name",void 0),a([u({type:p.IA5String,context:2,implicit:!0})],T.prototype,"dNSName",void 0),a([u({type:p.Any,context:3,implicit:!0})],T.prototype,"x400Address",void 0),a([u({type:te,context:4,implicit:!1})],T.prototype,"directoryName",void 0),a([u({type:Ti,context:5})],T.prototype,"ediPartyName",void 0),a([u({type:p.IA5String,context:6,implicit:!0})],T.prototype,"uniformResourceIdentifier",void 0),a([u({type:p.OctetString,context:7,implicit:!0,converter:mc})],T.prototype,"iPAddress",void 0),a([u({type:p.ObjectIdentifier,context:8,implicit:!0})],T.prototype,"registeredID",void 0),T=a([S({type:m.Choice})],T);var Vi;class gr{constructor(e={}){this.accessMethod="",this.accessLocation=new T,Object.assign(this,e)}}a([u({type:p.ObjectIdentifier})],gr.prototype,"accessMethod",void 0),a([u({type:T})],gr.prototype,"accessLocation",void 0);let vr=Vi=class extends R{constructor(e){super(e),Object.setPrototypeOf(this,Vi.prototype)}};vr=Vi=a([S({type:m.Sequence,itemType:gr})],vr);class fs extends O{}class Ui{constructor(e={}){e&&Object.assign(this,e)}}a([u({type:fs,context:0,optional:!0,implicit:!0})],Ui.prototype,"keyIdentifier",void 0),a([u({type:T,context:1,optional:!0,implicit:!0,repeated:"sequence"})],Ui.prototype,"authorityCertIssuer",void 0),a([u({type:p.Integer,context:2,optional:!0,implicit:!0,converter:oe})],Ui.prototype,"authorityCertSerialNumber",void 0);class hs{constructor(e={}){this.cA=!1,Object.assign(this,e)}}a([u({type:p.Boolean,defaultValue:!1})],hs.prototype,"cA",void 0),a([u({type:p.Integer,optional:!0})],hs.prototype,"pathLenConstraint",void 0);var ji;let pe=ji=class extends R{constructor(e){super(e),Object.setPrototypeOf(this,ji.prototype)}};pe=ji=a([S({type:m.Sequence,itemType:T})],pe);var Di;let ps=Di=class extends pe{constructor(e){super(e),Object.setPrototypeOf(this,Di.prototype)}};ps=Di=a([S({type:m.Sequence})],ps);var Ri;let Ce=class{constructor(e={}){Object.assign(this,e)}toString(){return this.ia5String||this.visibleString||this.bmpString||this.utf8String||""}};a([u({type:p.IA5String})],Ce.prototype,"ia5String",void 0),a([u({type:p.VisibleString})],Ce.prototype,"visibleString",void 0),a([u({type:p.BmpString})],Ce.prototype,"bmpString",void 0),a([u({type:p.Utf8String})],Ce.prototype,"utf8String",void 0),Ce=a([S({type:m.Choice})],Ce);class Li{constructor(e={}){this.organization=new Ce,this.noticeNumbers=[],Object.assign(this,e)}}a([u({type:Ce})],Li.prototype,"organization",void 0),a([u({type:p.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:Ce,optional:!0})],Hi.prototype,"explicitText",void 0);let mr=class{constructor(e={}){Object.assign(this,e)}};a([u({type:p.IA5String})],mr.prototype,"cPSuri",void 0),a([u({type:Hi})],mr.prototype,"userNotice",void 0),mr=a([S({type:m.Choice})],mr);class $i{constructor(e={}){this.policyQualifierId="",this.qualifier=new ArrayBuffer(0),Object.assign(this,e)}}a([u({type:p.ObjectIdentifier})],$i.prototype,"policyQualifierId",void 0),a([u({type:p.Any})],$i.prototype,"qualifier",void 0);class Mi{constructor(e={}){this.policyIdentifier="",Object.assign(this,e)}}a([u({type:p.ObjectIdentifier})],Mi.prototype,"policyIdentifier",void 0),a([u({type:$i,repeated:"sequence",optional:!0})],Mi.prototype,"policyQualifiers",void 0);let ds=Ri=class extends R{constructor(e){super(e),Object.setPrototypeOf(this,Ri.prototype)}};ds=Ri=a([S({type:m.Sequence,itemType:Mi})],ds);let wr=class{constructor(e=0){this.value=e}};a([u({type:p.Integer})],wr.prototype,"value",void 0),wr=a([S({type:m.Choice})],wr);let ys=class extends wr{};ys=a([S({type:m.Choice})],ys);var Pi,de;(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"})(de||(de={}));class gs extends dr{toJSON(){const e=[],t=this.toNumber();return t&de.aACompromise&&e.push("aACompromise"),t&de.affiliationChanged&&e.push("affiliationChanged"),t&de.cACompromise&&e.push("cACompromise"),t&de.certificateHold&&e.push("certificateHold"),t&de.cessationOfOperation&&e.push("cessationOfOperation"),t&de.keyCompromise&&e.push("keyCompromise"),t&de.privilegeWithdrawn&&e.push("privilegeWithdrawn"),t&de.superseded&&e.push("superseded"),t&de.unused&&e.push("unused"),e}toString(){return`[${this.toJSON().join(", ")}]`}}let nt=class{constructor(e={}){Object.assign(this,e)}};a([u({type:T,context:0,repeated:"sequence",implicit:!0})],nt.prototype,"fullName",void 0),a([u({type:yr,context:1,implicit:!0})],nt.prototype,"nameRelativeToCRLIssuer",void 0),nt=a([S({type:m.Choice})],nt);class Et{constructor(e={}){Object.assign(this,e)}}a([u({type:nt,context:0,optional:!0})],Et.prototype,"distributionPoint",void 0),a([u({type:gs,context:1,optional:!0,implicit:!0})],Et.prototype,"reasons",void 0),a([u({type:T,context:2,optional:!0,repeated:"sequence",implicit:!0})],Et.prototype,"cRLIssuer",void 0);let _i=Pi=class extends R{constructor(e){super(e),Object.setPrototypeOf(this,Pi.prototype)}};_i=Pi=a([S({type:m.Sequence,itemType:Et})],_i);var qi;let vs=qi=class extends _i{constructor(e){super(e),Object.setPrototypeOf(this,qi.prototype)}};vs=qi=a([S({type:m.Sequence,itemType:Et})],vs);class X{constructor(e={}){this.onlyContainsUserCerts=X.ONLY,this.onlyContainsCACerts=X.ONLY,this.indirectCRL=X.ONLY,this.onlyContainsAttributeCerts=X.ONLY,Object.assign(this,e)}}X.ONLY=!1,a([u({type:nt,context:0,optional:!0})],X.prototype,"distributionPoint",void 0),a([u({type:p.Boolean,context:1,defaultValue:X.ONLY,implicit:!0})],X.prototype,"onlyContainsUserCerts",void 0),a([u({type:p.Boolean,context:2,defaultValue:X.ONLY,implicit:!0})],X.prototype,"onlyContainsCACerts",void 0),a([u({type:gs,context:3,optional:!0,implicit:!0})],X.prototype,"onlySomeReasons",void 0),a([u({type:p.Boolean,context:4,defaultValue:X.ONLY,implicit:!0})],X.prototype,"indirectCRL",void 0),a([u({type:p.Boolean,context:5,defaultValue:X.ONLY,implicit:!0})],X.prototype,"onlyContainsAttributeCerts",void 0);var It;(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"})(It||(It={}));let br=class{constructor(e=It.unspecified){this.reason=It.unspecified,this.reason=e}toJSON(){return It[this.reason]}toString(){return this.toJSON()}};a([u({type:p.Enumerated})],br.prototype,"reason",void 0),br=a([S({type:m.Choice})],br);var Fi;let ms=Fi=class extends R{constructor(e){super(e),Object.setPrototypeOf(this,Fi.prototype)}};ms=Fi=a([S({type:m.Sequence,itemType:p.ObjectIdentifier})],ms);let Gi=class{constructor(e=new ArrayBuffer(0)){this.value=e}};a([u({type:p.Integer,converter:oe})],Gi.prototype,"value",void 0),Gi=a([S({type:m.Choice})],Gi);let zi=class{constructor(e){this.value=new Date,e&&(this.value=e)}};a([u({type:p.GeneralizedTime})],zi.prototype,"value",void 0),zi=a([S({type:m.Choice})],zi);var Xi;let ws=Xi=class extends pe{constructor(e){super(e),Object.setPrototypeOf(this,Xi.prototype)}};ws=Xi=a([S({type:m.Sequence})],ws);var bs;(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"})(bs||(bs={}));var Wi;class Ar{constructor(e={}){this.base=new T,this.minimum=0,Object.assign(this,e)}}a([u({type:T})],Ar.prototype,"base",void 0),a([u({type:p.Integer,context:0,defaultValue:0,implicit:!0})],Ar.prototype,"minimum",void 0),a([u({type:p.Integer,context:1,optional:!0,implicit:!0})],Ar.prototype,"maximum",void 0);let Sr=Wi=class extends R{constructor(e){super(e),Object.setPrototypeOf(this,Wi.prototype)}};Sr=Wi=a([S({type:m.Sequence,itemType:Ar})],Sr);class As{constructor(e={}){Object.assign(this,e)}}a([u({type:Sr,context:0,optional:!0,implicit:!0})],As.prototype,"permittedSubtrees",void 0),a([u({type:Sr,context:1,optional:!0,implicit:!0})],As.prototype,"excludedSubtrees",void 0);class Ss{constructor(e={}){Object.assign(this,e)}}a([u({type:p.Integer,context:0,implicit:!0,optional:!0,converter:oe})],Ss.prototype,"requireExplicitPolicy",void 0),a([u({type:p.Integer,context:1,implicit:!0,optional:!0,converter:oe})],Ss.prototype,"inhibitPolicyMapping",void 0);var Ki;class Ji{constructor(e={}){this.issuerDomainPolicy="",this.subjectDomainPolicy="",Object.assign(this,e)}}a([u({type:p.ObjectIdentifier})],Ji.prototype,"issuerDomainPolicy",void 0),a([u({type:p.ObjectIdentifier})],Ji.prototype,"subjectDomainPolicy",void 0);let Bs=Ki=class extends R{constructor(e){super(e),Object.setPrototypeOf(this,Ki.prototype)}};Bs=Ki=a([S({type:m.Sequence,itemType:Ji})],Bs);var Yi;let ks=Yi=class extends pe{constructor(e){super(e),Object.setPrototypeOf(this,Yi.prototype)}};ks=Yi=a([S({type:m.Sequence})],ks);class Ot{constructor(e={}){this.type="",this.values=[],Object.assign(this,e)}}a([u({type:p.ObjectIdentifier})],Ot.prototype,"type",void 0),a([u({type:p.Any,repeated:"set"})],Ot.prototype,"values",void 0);var Zi;let xs=Zi=class extends R{constructor(e){super(e),Object.setPrototypeOf(this,Zi.prototype)}};xs=Zi=a([S({type:m.Sequence,itemType:Ot})],xs);class Tt extends fs{}class Ns{constructor(e={}){Object.assign(this,e)}}a([u({type:p.GeneralizedTime,context:0,implicit:!0,optional:!0})],Ns.prototype,"notBefore",void 0),a([u({type:p.GeneralizedTime,context:1,implicit:!0,optional:!0})],Ns.prototype,"notAfter",void 0);var Vt;(function(r){r[r.keyUpdateAllowed=1]="keyUpdateAllowed",r[r.newExtensions=2]="newExtensions",r[r.pKIXCertificate=4]="pKIXCertificate"})(Vt||(Vt={}));class Cs extends dr{toJSON(){const e=[],t=this.toNumber();return t&Vt.pKIXCertificate&&e.push("pKIXCertificate"),t&Vt.newExtensions&&e.push("newExtensions"),t&Vt.keyUpdateAllowed&&e.push("keyUpdateAllowed"),e}toString(){return`[${this.toJSON().join(", ")}]`}}class Es{constructor(e={}){this.entrustVers="",this.entrustInfoFlags=new Cs,Object.assign(this,e)}}a([u({type:p.GeneralString})],Es.prototype,"entrustVers",void 0),a([u({type:Cs})],Es.prototype,"entrustInfoFlags",void 0);var Qi;let Is=Qi=class extends R{constructor(e){super(e),Object.setPrototypeOf(this,Qi.prototype)}};Is=Qi=a([S({type:m.Sequence,itemType:gr})],Is);class k{constructor(e={}){this.algorithm="",Object.assign(this,e)}isEqual(e){return e instanceof k&&e.algorithm==this.algorithm&&(e.parameters&&this.parameters&&Ta(e.parameters,this.parameters)||e.parameters===this.parameters)}}a([u({type:p.ObjectIdentifier})],k.prototype,"algorithm",void 0),a([u({type:p.Any,optional:!0})],k.prototype,"parameters",void 0);class Br{constructor(e={}){this.algorithm=new k,this.subjectPublicKey=new ArrayBuffer(0),Object.assign(this,e)}}a([u({type:k})],Br.prototype,"algorithm",void 0),a([u({type:p.BitString})],Br.prototype,"subjectPublicKey",void 0);let W=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:p.UTCTime})],W.prototype,"utcTime",void 0),a([u({type:p.GeneralizedTime})],W.prototype,"generalTime",void 0),W=a([S({type:m.Choice})],W);class kr{constructor(e){this.notBefore=new W(new Date),this.notAfter=new W(new Date),e&&(this.notBefore=new W(e.notBefore),this.notAfter=new W(e.notAfter))}}a([u({type:W})],kr.prototype,"notBefore",void 0),a([u({type:W})],kr.prototype,"notAfter",void 0);var en;class re{constructor(e={}){this.extnID="",this.critical=re.CRITICAL,this.extnValue=new O,Object.assign(this,e)}}re.CRITICAL=!1,a([u({type:p.ObjectIdentifier})],re.prototype,"extnID",void 0),a([u({type:p.Boolean,defaultValue:re.CRITICAL})],re.prototype,"critical",void 0),a([u({type:O})],re.prototype,"extnValue",void 0);let ot=en=class extends R{constructor(e){super(e),Object.setPrototypeOf(this,en.prototype)}};ot=en=a([S({type:m.Sequence,itemType:re})],ot);var xr;(function(r){r[r.v1=0]="v1",r[r.v2=1]="v2",r[r.v3=2]="v3"})(xr||(xr={}));class ce{constructor(e={}){this.version=xr.v1,this.serialNumber=new ArrayBuffer(0),this.signature=new k,this.issuer=new te,this.validity=new kr,this.subject=new te,this.subjectPublicKeyInfo=new Br,Object.assign(this,e)}}a([u({type:p.Integer,context:0,defaultValue:xr.v1})],ce.prototype,"version",void 0),a([u({type:p.Integer,converter:oe})],ce.prototype,"serialNumber",void 0),a([u({type:k})],ce.prototype,"signature",void 0),a([u({type:te})],ce.prototype,"issuer",void 0),a([u({type:kr})],ce.prototype,"validity",void 0),a([u({type:te})],ce.prototype,"subject",void 0),a([u({type:Br})],ce.prototype,"subjectPublicKeyInfo",void 0),a([u({type:p.BitString,context:1,implicit:!0,optional:!0})],ce.prototype,"issuerUniqueID",void 0),a([u({type:p.BitString,context:2,implicit:!0,optional:!0})],ce.prototype,"subjectUniqueID",void 0),a([u({type:ot,context:3,optional:!0})],ce.prototype,"extensions",void 0);class qe{constructor(e={}){this.tbsCertificate=new ce,this.signatureAlgorithm=new k,this.signatureValue=new ArrayBuffer(0),Object.assign(this,e)}}a([u({type:ce,raw:!0})],qe.prototype,"tbsCertificate",void 0),a([u({type:k})],qe.prototype,"signatureAlgorithm",void 0),a([u({type:p.BitString})],qe.prototype,"signatureValue",void 0);class Nr{constructor(e={}){this.userCertificate=new ArrayBuffer(0),this.revocationDate=new W,Object.assign(this,e)}}a([u({type:p.Integer,converter:oe})],Nr.prototype,"userCertificate",void 0),a([u({type:W})],Nr.prototype,"revocationDate",void 0),a([u({type:re,optional:!0,repeated:"sequence"})],Nr.prototype,"crlEntryExtensions",void 0);class Ee{constructor(e={}){this.signature=new k,this.issuer=new te,this.thisUpdate=new W,Object.assign(this,e)}}a([u({type:p.Integer,optional:!0})],Ee.prototype,"version",void 0),a([u({type:k})],Ee.prototype,"signature",void 0),a([u({type:te})],Ee.prototype,"issuer",void 0),a([u({type:W})],Ee.prototype,"thisUpdate",void 0),a([u({type:W,optional:!0})],Ee.prototype,"nextUpdate",void 0),a([u({type:Nr,repeated:"sequence",optional:!0})],Ee.prototype,"revokedCertificates",void 0),a([u({type:re,optional:!0,context:0,repeated:"sequence"})],Ee.prototype,"crlExtensions",void 0);class tn{constructor(e={}){this.tbsCertList=new Ee,this.signatureAlgorithm=new k,this.signature=new ArrayBuffer(0),Object.assign(this,e)}}a([u({type:Ee,raw:!0})],tn.prototype,"tbsCertList",void 0),a([u({type:k})],tn.prototype,"signatureAlgorithm",void 0),a([u({type:p.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 Os=rn=class extends R{constructor(e){super(e),Object.setPrototypeOf(this,rn.prototype)}};Os=rn=a([S({type:m.Sequence,itemType:nn})],Os);class Ts{constructor(e={}){this.issuer=new te,this.locator=new vr,Object.assign(this,e)}}a([u({type:te})],Ts.prototype,"issuer",void 0),a([u({type:vr})],Ts.prototype,"locator",void 0);class wc extends O{}let st=class{constructor(e={}){Object.assign(this,e)}};a([u({type:te,context:1})],st.prototype,"byName",void 0),a([u({type:wc,context:2})],st.prototype,"byKey",void 0),st=a([S({type:m.Choice})],st);class Ie{constructor(e={}){this.hashAlgorithm=new k,this.issuerNameHash=new O,this.issuerKeyHash=new O,this.serialNumber=new ArrayBuffer(0),Object.assign(this,e)}}a([u({type:k})],Ie.prototype,"hashAlgorithm",void 0),a([u({type:O})],Ie.prototype,"issuerNameHash",void 0),a([u({type:O})],Ie.prototype,"issuerKeyHash",void 0),a([u({type:p.Integer,converter:oe})],Ie.prototype,"serialNumber",void 0);class on{constructor(e={}){this.revocationTime=new Date,Object.assign(this,e)}}a([u({type:p.GeneralizedTime})],on.prototype,"revocationTime",void 0),a([u({type:br,context:0,optional:!0})],on.prototype,"revocationReason",void 0);let Fe=class{constructor(e={}){Object.assign(this,e)}};a([u({type:p.Null,context:0,implicit:!0})],Fe.prototype,"good",void 0),a([u({type:on,context:1,implicit:!0})],Fe.prototype,"revoked",void 0),a([u({type:p.Null,context:2,implicit:!0})],Fe.prototype,"unknown",void 0),Fe=a([S({type:m.Choice})],Fe);class at{constructor(e={}){this.certID=new Ie,this.certStatus=new Fe,this.thisUpdate=new Date,Object.assign(this,e)}}a([u({type:Ie})],at.prototype,"certID",void 0),a([u({type:Fe})],at.prototype,"certStatus",void 0),a([u({type:p.GeneralizedTime})],at.prototype,"thisUpdate",void 0),a([u({type:p.GeneralizedTime,context:0,optional:!0})],at.prototype,"nextUpdate",void 0),a([u({type:re,context:1,repeated:"sequence",optional:!0})],at.prototype,"singleExtensions",void 0);var ct;(function(r){r[r.v1=0]="v1"})(ct||(ct={}));class Ge{constructor(e={}){this.version=ct.v1,this.responderID=new st,this.producedAt=new Date,this.responses=[],Object.assign(this,e)}}a([u({type:p.Integer,context:0,defaultValue:ct.v1})],Ge.prototype,"version",void 0),a([u({type:st})],Ge.prototype,"responderID",void 0),a([u({type:p.GeneralizedTime})],Ge.prototype,"producedAt",void 0),a([u({type:at,repeated:"sequence"})],Ge.prototype,"responses",void 0),a([u({type:re,repeated:"sequence",context:1,optional:!0})],Ge.prototype,"responseExtensions",void 0);class Ut{constructor(e={}){this.tbsResponseData=new Ge,this.signatureAlgorithm=new k,this.signature=new ArrayBuffer(0),Object.assign(this,e)}}a([u({type:Ge,raw:!0})],Ut.prototype,"tbsResponseData",void 0),a([u({type:k})],Ut.prototype,"signatureAlgorithm",void 0),a([u({type:p.BitString})],Ut.prototype,"signature",void 0),a([u({type:qe,repeated:"sequence",optional:!0,context:0})],Ut.prototype,"certs",void 0);class Cr{constructor(e={}){this.signatureAlgorithm=new k,this.signature=new ArrayBuffer(0),Object.assign(this,e)}}a([u({type:k})],Cr.prototype,"signatureAlgorithm",void 0),a([u({type:p.BitString})],Cr.prototype,"signature",void 0),a([u({type:qe,repeated:"sequence",optional:!0,context:0})],Cr.prototype,"certs",void 0);class Er{constructor(e={}){this.reqCert=new Ie,Object.assign(this,e)}}a([u({type:Ie})],Er.prototype,"reqCert",void 0),a([u({type:re,repeated:"sequence",optional:!0})],Er.prototype,"singleRequestExtensions",void 0);class ze{constructor(e={}){this.version=ct.v1,this.requestList=[],Object.assign(this,e)}}a([u({type:p.Integer,context:0,defaultValue:ct.v1})],ze.prototype,"version",void 0),a([u({type:T,context:1,optional:!0})],ze.prototype,"requestorName",void 0),a([u({type:Er,repeated:"sequence"})],ze.prototype,"requestList",void 0),a([u({type:re,context:2,optional:!0,repeated:"sequence"})],ze.prototype,"requestExtensions",void 0);class sn{constructor(e={}){this.tbsRequest=new ze,Object.assign(this,e)}}a([u({type:ze,raw:!0})],sn.prototype,"tbsRequest",void 0),a([u({type:Cr,optional:!0,context:0})],sn.prototype,"optionalSignature",void 0);var Oe;(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"})(Oe||(Oe={}));class an{constructor(e={}){this.responseType="",this.response=new O,Object.assign(this,e)}}a([u({type:p.ObjectIdentifier})],an.prototype,"responseType",void 0),a([u({type:O})],an.prototype,"response",void 0);class cn{constructor(e={}){this.responseStatus=Oe.successful,Object.assign(this,e)}}a([u({type:p.Enumerated})],cn.prototype,"responseStatus",void 0),a([u({type:an,context:0,optional:!0})],cn.prototype,"responseBytes",void 0);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())});function ln(r){return Ir(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,h=new AbortController,d=setTimeout(()=>h.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:h.signal});if(clearTimeout(d),!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(d),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 bc(r,e,t=5e3,i){return Ir(this,null,function*(){return ln(r,{method:"POST",body:e,contentType:"application/ocsp-request",accept:"application/ocsp-response",timeout:t,proxyUrl:i})})}function Ac(r,e=1e4,t){return Ir(this,null,function*(){return ln(r,{method:"GET",accept:"application/pkix-crl",timeout:e,proxyUrl:t})})}function Sc(r,e=5e3,t){return Ir(this,null,function*(){return ln(r,{method:"GET",accept:"application/pkix-cert",timeout:e,proxyUrl:t})})}function Vs(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 Us(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 Bc(r){return new Uint8Array(Us(r))}function un(r){return Array.from(new Uint8Array(r)).map(e=>e.toString(16).padStart(2,"0")).join("")}function kc(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=Vs(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}-----
|
|
73
73
|
${t.join(`
|
|
74
74
|
`)}
|
|
75
|
-
-----END ${e}-----`}var
|
|
76
|
-
${(
|
|
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(`
|
|
77
77
|
`)}
|
|
78
|
-
-----END X509 CRL-----`;return new D.X509Crl(t)}catch(t){return null}}}function Hc(r){return Uc(this,arguments,function*(e,t={}){const{timeout:i=1e4,proxyUrl:n}=t,o=new Date,s=Dc(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 Ac(l,i,n);if(!f.ok||!f.data){c.push(`${l}: ${f.error||"Failed to fetch"}`);continue}const h=Lc(f.data);if(!h){c.push(`${l}: Failed to parse CRL data`);continue}const d=Rc(h,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 $c=Object.defineProperty,Ls=Object.getOwnPropertySymbols,Mc=Object.prototype.hasOwnProperty,Pc=Object.prototype.propertyIsEnumerable,Hs=(r,e,t)=>e in r?$c(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,$s=(r,e)=>{for(var t in e||(e={}))Mc.call(e,t)&&Hs(r,t,e[t]);if(Ls)for(var t of Ls(e))Pc.call(e,t)&&Hs(r,t,e[t]);return r},_c=(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 _c(this,arguments,function*(e,t={}){const i=new Date,n=$s($s({},Na),t);let o;try{o=typeof e=="string"?new D.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 Vc(o,null,{timeout:n.ocspTimeout,certificateChain:n.certificateChain,proxyUrl:t.proxyUrl}),s.status==="good"||s.status==="revoked"))return s;if(n.crlEnabled&&(c=yield Hc(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 lt{constructor(e={}){this.issuer=new te,this.serialNumber=new ArrayBuffer(0),Object.assign(this,e)}}a([u({type:te})],lt.prototype,"issuer",void 0),a([u({type:p.Integer,converter:oe})],lt.prototype,"serialNumber",void 0);let ut=class{constructor(e={}){Object.assign(this,e)}};a([u({type:Tt,context:0,implicit:!0})],ut.prototype,"subjectKeyIdentifier",void 0),a([u({type:lt})],ut.prototype,"issuerAndSerialNumber",void 0),ut=a([S({type:m.Choice})],ut);var Te;(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"})(Te||(Te={}));let jt=class extends k{};jt=a([S({type:m.Sequence})],jt);let Tr=class extends k{};Tr=a([S({type:m.Sequence})],Tr);let Ae=class extends k{};Ae=a([S({type:m.Sequence})],Ae);let Vr=class extends k{};Vr=a([S({type:m.Sequence})],Vr);let Ms=class extends k{};Ms=a([S({type:m.Sequence})],Ms);let hn=class extends k{};hn=a([S({type:m.Sequence})],hn);class Dt{constructor(e={}){this.attrType="",this.attrValues=[],Object.assign(this,e)}}a([u({type:p.ObjectIdentifier})],Dt.prototype,"attrType",void 0),a([u({type:p.Any,repeated:"set"})],Dt.prototype,"attrValues",void 0);var pn;class Ve{constructor(e={}){this.version=Te.v0,this.sid=new ut,this.digestAlgorithm=new jt,this.signatureAlgorithm=new Tr,this.signature=new O,Object.assign(this,e)}}a([u({type:p.Integer})],Ve.prototype,"version",void 0),a([u({type:ut})],Ve.prototype,"sid",void 0),a([u({type:jt})],Ve.prototype,"digestAlgorithm",void 0),a([u({type:Dt,repeated:"set",context:0,implicit:!0,optional:!0,raw:!0})],Ve.prototype,"signedAttrs",void 0),a([u({type:Tr})],Ve.prototype,"signatureAlgorithm",void 0),a([u({type:O})],Ve.prototype,"signature",void 0),a([u({type:Dt,repeated:"set",context:1,implicit:!0,optional:!0})],Ve.prototype,"unsignedAttrs",void 0);let Ur=pn=class extends R{constructor(e){super(e),Object.setPrototypeOf(this,pn.prototype)}};Ur=pn=a([S({type:m.Set,itemType:Ve})],Ur);let Ps=class extends Ve{};Ps=a([S({type:m.Sequence})],Ps);let _s=class extends W{};_s=a([S({type:m.Choice})],_s);class dn{constructor(e={}){this.acIssuer=new T,this.acSerial=0,this.attrs=[],Object.assign(this,e)}}a([u({type:T})],dn.prototype,"acIssuer",void 0),a([u({type:p.Integer})],dn.prototype,"acSerial",void 0),a([u({type:Ot,repeated:"sequence"})],dn.prototype,"attrs",void 0);var yn;let jr=yn=class extends R{constructor(e){super(e),Object.setPrototypeOf(this,yn.prototype)}};jr=yn=a([S({type:m.Sequence,itemType:p.ObjectIdentifier})],jr);class Dr{constructor(e={}){this.permitUnSpecified=!0,Object.assign(this,e)}}a([u({type:p.Integer,optional:!0})],Dr.prototype,"pathLenConstraint",void 0),a([u({type:jr,implicit:!0,context:0,optional:!0})],Dr.prototype,"permittedAttrs",void 0),a([u({type:jr,implicit:!0,context:1,optional:!0})],Dr.prototype,"excludedAttrs",void 0),a([u({type:p.Boolean,defaultValue:!0})],Dr.prototype,"permitUnSpecified",void 0);class Xe{constructor(e={}){this.issuer=new pe,this.serial=new ArrayBuffer(0),this.issuerUID=new ArrayBuffer(0),Object.assign(this,e)}}a([u({type:pe})],Xe.prototype,"issuer",void 0),a([u({type:p.Integer,converter:oe})],Xe.prototype,"serial",void 0),a([u({type:p.BitString,optional:!0})],Xe.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 We{constructor(e={}){this.digestedObjectType=gn.publicKey,this.digestAlgorithm=new k,this.objectDigest=new ArrayBuffer(0),Object.assign(this,e)}}a([u({type:p.Enumerated})],We.prototype,"digestedObjectType",void 0),a([u({type:p.ObjectIdentifier,optional:!0})],We.prototype,"otherObjectTypeID",void 0),a([u({type:k})],We.prototype,"digestAlgorithm",void 0),a([u({type:p.BitString})],We.prototype,"objectDigest",void 0);class Rr{constructor(e={}){Object.assign(this,e)}}a([u({type:pe,optional:!0})],Rr.prototype,"issuerName",void 0),a([u({type:Xe,context:0,implicit:!0,optional:!0})],Rr.prototype,"baseCertificateID",void 0),a([u({type:We,context:1,implicit:!0,optional:!0})],Rr.prototype,"objectDigestInfo",void 0);let ft=class{constructor(e={}){Object.assign(this,e)}};a([u({type:T,repeated:"sequence"})],ft.prototype,"v1Form",void 0),a([u({type:Rr,context:0,implicit:!0})],ft.prototype,"v2Form",void 0),ft=a([S({type:m.Choice})],ft);class Lr{constructor(e={}){this.notBeforeTime=new Date,this.notAfterTime=new Date,Object.assign(this,e)}}a([u({type:p.GeneralizedTime})],Lr.prototype,"notBeforeTime",void 0),a([u({type:p.GeneralizedTime})],Lr.prototype,"notAfterTime",void 0);class Rt{constructor(e={}){Object.assign(this,e)}}a([u({type:Xe,implicit:!0,context:0,optional:!0})],Rt.prototype,"baseCertificateID",void 0),a([u({type:pe,implicit:!0,context:1,optional:!0})],Rt.prototype,"entityName",void 0),a([u({type:We,implicit:!0,context:2,optional:!0})],Rt.prototype,"objectDigestInfo",void 0);var vn;(function(r){r[r.v2=1]="v2"})(vn||(vn={}));class ye{constructor(e={}){this.version=vn.v2,this.holder=new Rt,this.issuer=new ft,this.signature=new k,this.serialNumber=new ArrayBuffer(0),this.attrCertValidityPeriod=new Lr,this.attributes=[],Object.assign(this,e)}}a([u({type:p.Integer})],ye.prototype,"version",void 0),a([u({type:Rt})],ye.prototype,"holder",void 0),a([u({type:ft})],ye.prototype,"issuer",void 0),a([u({type:k})],ye.prototype,"signature",void 0),a([u({type:p.Integer,converter:oe})],ye.prototype,"serialNumber",void 0),a([u({type:Lr})],ye.prototype,"attrCertValidityPeriod",void 0),a([u({type:Ot,repeated:"sequence"})],ye.prototype,"attributes",void 0),a([u({type:p.BitString,optional:!0})],ye.prototype,"issuerUniqueID",void 0),a([u({type:ot,optional:!0})],ye.prototype,"extensions",void 0);class Hr{constructor(e={}){this.acinfo=new ye,this.signatureAlgorithm=new k,this.signatureValue=new ArrayBuffer(0),Object.assign(this,e)}}a([u({type:ye})],Hr.prototype,"acinfo",void 0),a([u({type:k})],Hr.prototype,"signatureAlgorithm",void 0),a([u({type:p.BitString})],Hr.prototype,"signatureValue",void 0);var $r;(function(r){r[r.unmarked=1]="unmarked",r[r.unclassified=2]="unclassified",r[r.restricted=4]="restricted",r[r.confidential=8]="confidential",r[r.secret=16]="secret",r[r.topSecret=32]="topSecret"})($r||($r={}));class mn extends dr{}class wn{constructor(e={}){this.type="",this.value=new ArrayBuffer(0),Object.assign(this,e)}}a([u({type:p.ObjectIdentifier,implicit:!0,context:0})],wn.prototype,"type",void 0),a([u({type:p.Any,implicit:!0,context:1})],wn.prototype,"value",void 0);class bn{constructor(e={}){this.policyId="",this.classList=new mn($r.unclassified),Object.assign(this,e)}}a([u({type:p.ObjectIdentifier})],bn.prototype,"policyId",void 0),a([u({type:mn,defaultValue:new mn($r.unclassified)})],bn.prototype,"classList",void 0),a([u({type:wn,repeated:"set"})],bn.prototype,"securityCategories",void 0);class Mr{constructor(e={}){Object.assign(this,e)}}a([u({type:O})],Mr.prototype,"cotets",void 0),a([u({type:p.ObjectIdentifier})],Mr.prototype,"oid",void 0),a([u({type:p.Utf8String})],Mr.prototype,"string",void 0);class qs{constructor(e={}){this.values=[],Object.assign(this,e)}}a([u({type:pe,implicit:!0,context:0,optional:!0})],qs.prototype,"policyAuthority",void 0),a([u({type:Mr,repeated:"sequence"})],qs.prototype,"values",void 0);var An;class Pr{constructor(e={}){this.targetCertificate=new Xe,Object.assign(this,e)}}a([u({type:Xe})],Pr.prototype,"targetCertificate",void 0),a([u({type:T,optional:!0})],Pr.prototype,"targetName",void 0),a([u({type:We,optional:!0})],Pr.prototype,"certDigestInfo",void 0);let ht=class{constructor(e={}){Object.assign(this,e)}};a([u({type:T,context:0,implicit:!0})],ht.prototype,"targetName",void 0),a([u({type:T,context:1,implicit:!0})],ht.prototype,"targetGroup",void 0),a([u({type:Pr,context:2,implicit:!0})],ht.prototype,"targetCert",void 0),ht=a([S({type:m.Choice})],ht);let Sn=An=class extends R{constructor(e){super(e),Object.setPrototypeOf(this,An.prototype)}};Sn=An=a([S({type:m.Sequence,itemType:ht})],Sn);var Bn;let Fs=Bn=class extends R{constructor(e){super(e),Object.setPrototypeOf(this,Bn.prototype)}};Fs=Bn=a([S({type:m.Sequence,itemType:Sn})],Fs);class Gs{constructor(e={}){Object.assign(this,e)}}a([u({type:pe,implicit:!0,context:0,optional:!0})],Gs.prototype,"roleAuthority",void 0),a([u({type:T,implicit:!0,context:1})],Gs.prototype,"roleName",void 0);class kn{constructor(e={}){this.service=new T,this.ident=new T,Object.assign(this,e)}}a([u({type:T})],kn.prototype,"service",void 0),a([u({type:T})],kn.prototype,"ident",void 0),a([u({type:O,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:p.ObjectIdentifier})],Nn.prototype,"otherCertFormat",void 0),a([u({type:p.Any})],Nn.prototype,"otherCert",void 0);let pt=class{constructor(e={}){Object.assign(this,e)}};a([u({type:qe})],pt.prototype,"certificate",void 0),a([u({type:Hr,context:2,implicit:!0})],pt.prototype,"v2AttrCert",void 0),a([u({type:Nn,context:3,implicit:!0})],pt.prototype,"other",void 0),pt=a([S({type:m.Choice})],pt);let _r=xn=class extends R{constructor(e){super(e),Object.setPrototypeOf(this,xn.prototype)}};_r=xn=a([S({type:m.Set,itemType:pt})],_r);class qr{constructor(e={}){this.contentType="",this.content=new ArrayBuffer(0),Object.assign(this,e)}}a([u({type:p.ObjectIdentifier})],qr.prototype,"contentType",void 0),a([u({type:p.Any,context:0})],qr.prototype,"content",void 0);let Lt=class{constructor(e={}){Object.assign(this,e)}};a([u({type:O})],Lt.prototype,"single",void 0),a([u({type:p.Any})],Lt.prototype,"any",void 0),Lt=a([S({type:m.Choice})],Lt);class Fr{constructor(e={}){this.eContentType="",Object.assign(this,e)}}a([u({type:p.ObjectIdentifier})],Fr.prototype,"eContentType",void 0),a([u({type:Lt,context:0,optional:!0})],Fr.prototype,"eContent",void 0);let Ht=class{constructor(e={}){Object.assign(this,e)}};a([u({type:O,context:0,implicit:!0,optional:!0})],Ht.prototype,"value",void 0),a([u({type:O,converter:ec,context:0,implicit:!0,optional:!0,repeated:"sequence"})],Ht.prototype,"constructedValue",void 0),Ht=a([S({type:m.Choice})],Ht);class $t{constructor(e={}){this.contentType="",this.contentEncryptionAlgorithm=new Vr,Object.assign(this,e)}}a([u({type:p.ObjectIdentifier})],$t.prototype,"contentType",void 0),a([u({type:Vr})],$t.prototype,"contentEncryptionAlgorithm",void 0),a([u({type:Ht,optional:!0})],$t.prototype,"encryptedContent",void 0);class Gr{constructor(e={}){this.keyAttrId="",Object.assign(this,e)}}a([u({type:p.ObjectIdentifier})],Gr.prototype,"keyAttrId",void 0),a([u({type:p.Any,optional:!0})],Gr.prototype,"keyAttr",void 0);var Cn;class zr{constructor(e={}){this.subjectKeyIdentifier=new Tt,Object.assign(this,e)}}a([u({type:Tt})],zr.prototype,"subjectKeyIdentifier",void 0),a([u({type:p.GeneralizedTime,optional:!0})],zr.prototype,"date",void 0),a([u({type:Gr,optional:!0})],zr.prototype,"other",void 0);let dt=class{constructor(e={}){Object.assign(this,e)}};a([u({type:zr,context:0,implicit:!0,optional:!0})],dt.prototype,"rKeyId",void 0),a([u({type:lt,optional:!0})],dt.prototype,"issuerAndSerialNumber",void 0),dt=a([S({type:m.Choice})],dt);class En{constructor(e={}){this.rid=new dt,this.encryptedKey=new O,Object.assign(this,e)}}a([u({type:dt})],En.prototype,"rid",void 0),a([u({type:O})],En.prototype,"encryptedKey",void 0);let Xr=Cn=class extends R{constructor(e){super(e),Object.setPrototypeOf(this,Cn.prototype)}};Xr=Cn=a([S({type:m.Sequence,itemType:En})],Xr);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:p.BitString})],In.prototype,"publicKey",void 0);let Ke=class{constructor(e={}){Object.assign(this,e)}};a([u({type:Tt,context:0,implicit:!0,optional:!0})],Ke.prototype,"subjectKeyIdentifier",void 0),a([u({type:In,context:1,implicit:!0,optional:!0})],Ke.prototype,"originatorKey",void 0),a([u({type:lt,optional:!0})],Ke.prototype,"issuerAndSerialNumber",void 0),Ke=a([S({type:m.Choice})],Ke);class yt{constructor(e={}){this.version=Te.v3,this.originator=new Ke,this.keyEncryptionAlgorithm=new Ae,this.recipientEncryptedKeys=new Xr,Object.assign(this,e)}}a([u({type:p.Integer})],yt.prototype,"version",void 0),a([u({type:Ke,context:0})],yt.prototype,"originator",void 0),a([u({type:O,context:1,optional:!0})],yt.prototype,"ukm",void 0),a([u({type:Ae})],yt.prototype,"keyEncryptionAlgorithm",void 0),a([u({type:Xr})],yt.prototype,"recipientEncryptedKeys",void 0);let gt=class{constructor(e={}){Object.assign(this,e)}};a([u({type:Tt,context:0,implicit:!0})],gt.prototype,"subjectKeyIdentifier",void 0),a([u({type:lt})],gt.prototype,"issuerAndSerialNumber",void 0),gt=a([S({type:m.Choice})],gt);class Mt{constructor(e={}){this.version=Te.v0,this.rid=new gt,this.keyEncryptionAlgorithm=new Ae,this.encryptedKey=new O,Object.assign(this,e)}}a([u({type:p.Integer})],Mt.prototype,"version",void 0),a([u({type:gt})],Mt.prototype,"rid",void 0),a([u({type:Ae})],Mt.prototype,"keyEncryptionAlgorithm",void 0),a([u({type:O})],Mt.prototype,"encryptedKey",void 0);class Pt{constructor(e={}){this.keyIdentifier=new O,Object.assign(this,e)}}a([u({type:O})],Pt.prototype,"keyIdentifier",void 0),a([u({type:p.GeneralizedTime,optional:!0})],Pt.prototype,"date",void 0),a([u({type:Gr,optional:!0})],Pt.prototype,"other",void 0);class _t{constructor(e={}){this.version=Te.v4,this.kekid=new Pt,this.keyEncryptionAlgorithm=new Ae,this.encryptedKey=new O,Object.assign(this,e)}}a([u({type:p.Integer})],_t.prototype,"version",void 0),a([u({type:Pt})],_t.prototype,"kekid",void 0),a([u({type:Ae})],_t.prototype,"keyEncryptionAlgorithm",void 0),a([u({type:O})],_t.prototype,"encryptedKey",void 0);class qt{constructor(e={}){this.version=Te.v0,this.keyEncryptionAlgorithm=new Ae,this.encryptedKey=new O,Object.assign(this,e)}}a([u({type:p.Integer})],qt.prototype,"version",void 0),a([u({type:hn,context:0,optional:!0})],qt.prototype,"keyDerivationAlgorithm",void 0),a([u({type:Ae})],qt.prototype,"keyEncryptionAlgorithm",void 0),a([u({type:O})],qt.prototype,"encryptedKey",void 0);class On{constructor(e={}){this.oriType="",this.oriValue=new ArrayBuffer(0),Object.assign(this,e)}}a([u({type:p.ObjectIdentifier})],On.prototype,"oriType",void 0),a([u({type:p.Any})],On.prototype,"oriValue",void 0);let De=class{constructor(e={}){Object.assign(this,e)}};a([u({type:Mt,optional:!0})],De.prototype,"ktri",void 0),a([u({type:yt,context:1,implicit:!0,optional:!0})],De.prototype,"kari",void 0),a([u({type:_t,context:2,implicit:!0,optional:!0})],De.prototype,"kekri",void 0),a([u({type:qt,context:3,implicit:!0,optional:!0})],De.prototype,"pwri",void 0),a([u({type:On,context:4,implicit:!0,optional:!0})],De.prototype,"ori",void 0),De=a([S({type:m.Choice})],De);var Tn;let Wr=Tn=class extends R{constructor(e){super(e),Object.setPrototypeOf(this,Tn.prototype)}};Wr=Tn=a([S({type:m.Set,itemType:De})],Wr);var Vn;class Kr{constructor(e={}){this.otherRevInfoFormat="",this.otherRevInfo=new ArrayBuffer(0),Object.assign(this,e)}}a([u({type:p.ObjectIdentifier})],Kr.prototype,"otherRevInfoFormat",void 0),a([u({type:p.Any})],Kr.prototype,"otherRevInfo",void 0);let Jr=class{constructor(e={}){this.other=new Kr,Object.assign(this,e)}};a([u({type:Kr,context:1,implicit:!0})],Jr.prototype,"other",void 0),Jr=a([S({type:m.Choice})],Jr);let Yr=Vn=class extends R{constructor(e){super(e),Object.setPrototypeOf(this,Vn.prototype)}};Yr=Vn=a([S({type:m.Set,itemType:Jr})],Yr);class Un{constructor(e={}){Object.assign(this,e)}}a([u({type:_r,context:0,implicit:!0,optional:!0})],Un.prototype,"certs",void 0),a([u({type:Yr,context:1,implicit:!0,optional:!0})],Un.prototype,"crls",void 0);var jn;let Dn=jn=class extends R{constructor(e){super(e),Object.setPrototypeOf(this,jn.prototype)}};Dn=jn=a([S({type:m.Set,itemType:Dt})],Dn);class Ft{constructor(e={}){this.version=Te.v0,this.recipientInfos=new Wr,this.encryptedContentInfo=new $t,Object.assign(this,e)}}a([u({type:p.Integer})],Ft.prototype,"version",void 0),a([u({type:Un,context:0,implicit:!0,optional:!0})],Ft.prototype,"originatorInfo",void 0),a([u({type:Wr})],Ft.prototype,"recipientInfos",void 0),a([u({type:$t})],Ft.prototype,"encryptedContentInfo",void 0),a([u({type:Dn,context:1,implicit:!0,optional:!0})],Ft.prototype,"unprotectedAttrs",void 0);var Rn;let Zr=Rn=class extends R{constructor(e){super(e),Object.setPrototypeOf(this,Rn.prototype)}};Zr=Rn=a([S({type:m.Set,itemType:jt})],Zr);class Je{constructor(e={}){this.version=Te.v0,this.digestAlgorithms=new Zr,this.encapContentInfo=new Fr,this.signerInfos=new Ur,Object.assign(this,e)}}a([u({type:p.Integer})],Je.prototype,"version",void 0),a([u({type:Zr})],Je.prototype,"digestAlgorithms",void 0),a([u({type:Fr})],Je.prototype,"encapContentInfo",void 0),a([u({type:_r,context:0,implicit:!0,optional:!0})],Je.prototype,"certificates",void 0),a([u({type:Yr,context:1,implicit:!0,optional:!0})],Je.prototype,"crls",void 0),a([u({type:Ur})],Je.prototype,"signerInfos",void 0);class Qr{constructor(e={}){this.seconds=0,Object.assign(this,e)}}a([u({type:p.Integer,optional:!0})],Qr.prototype,"seconds",void 0),a([u({type:p.Integer,context:0,implicit:!0,optional:!0})],Qr.prototype,"millis",void 0),a([u({type:p.Integer,context:1,implicit:!0,optional:!0})],Qr.prototype,"micros",void 0);class vt{constructor(e={}){this.hashAlgorithm=new k,this.hashedMessage=new O,Object.assign(this,e)}}a([u({type:k})],vt.prototype,"hashAlgorithm",void 0),a([u({type:O})],vt.prototype,"hashedMessage",void 0);var ge;(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"})(ge||(ge={}));class qc extends dr{toJSON(){const e=this.toNumber(),t=[];return e&ge.addInfoNotAvailable&&t.push("addInfoNotAvailable"),e&ge.badAlg&&t.push("badAlg"),e&ge.badDataFormat&&t.push("badDataFormat"),e&ge.badRequest&&t.push("badRequest"),e&ge.systemFailure&&t.push("systemFailure"),e&ge.systemFailure&&t.push("systemFailure"),e&ge.timeNotAvailable&&t.push("timeNotAvailable"),e&ge.unacceptedExtension&&t.push("unacceptedExtension"),e&ge.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 R{constructor(e){super(e),Object.setPrototypeOf(this,Hn.prototype)}};$n=Hn=a([S({type:m.Sequence,itemType:p.Utf8String})],$n);class Gt{constructor(e={}){this.status=Ln.granted,Object.assign(this,e)}}a([u({type:p.Integer})],Gt.prototype,"status",void 0),a([u({type:$n,optional:!0})],Gt.prototype,"statusString",void 0),a([u({type:qc,optional:!0})],Gt.prototype,"failInfo",void 0);var Mn;(function(r){r[r.v1=1]="v1"})(Mn||(Mn={}));class mt{constructor(e={}){this.version=Mn.v1,this.messageImprint=new vt,this.certReq=!1,Object.assign(this,e)}}a([u({type:p.Integer})],mt.prototype,"version",void 0),a([u({type:vt})],mt.prototype,"messageImprint",void 0),a([u({type:p.ObjectIdentifier,optional:!0})],mt.prototype,"reqPolicy",void 0),a([u({type:p.Integer,converter:oe,optional:!0})],mt.prototype,"nonce",void 0),a([u({type:p.Boolean,defaultValue:!1})],mt.prototype,"certReq",void 0),a([u({type:ot,optional:!0,context:0,implicit:!0})],mt.prototype,"extensions",void 0);let Pn=class extends qr{};Pn=a([S({type:m.Sequence})],Pn);class zs{constructor(e={}){this.status=new Gt,Object.assign(this,e)}}a([u({type:Gt})],zs.prototype,"status",void 0),a([u({type:Pn,optional:!0})],zs.prototype,"timeStampToken",void 0);var _n;(function(r){r[r.v1=1]="v1"})(_n||(_n={}));class ve{constructor(e={}){this.version=_n.v1,this.policy="",this.messageImprint=new vt,this.serialNumber=new ArrayBuffer(0),this.genTime=new Date,this.ordering=!1,Object.assign(this,e)}}a([u({type:p.Integer})],ve.prototype,"version",void 0),a([u({type:p.ObjectIdentifier})],ve.prototype,"policy",void 0),a([u({type:vt})],ve.prototype,"messageImprint",void 0),a([u({type:p.Integer,converter:oe})],ve.prototype,"serialNumber",void 0),a([u({type:p.GeneralizedTime})],ve.prototype,"genTime",void 0),a([u({type:Qr,optional:!0})],ve.prototype,"accuracy",void 0),a([u({type:p.Boolean,defaultValue:!1})],ve.prototype,"ordering",void 0),a([u({type:p.Integer,converter:oe,optional:!0})],ve.prototype,"nonce",void 0),a([u({type:T,context:0,optional:!0})],ve.prototype,"tsa",void 0),a([u({type:ot,context:1,implicit:!0,optional:!0})],ve.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 Fc="1.2.840.113549.1.7.2",Gc="1.2.840.113549.1.9.16.1.4";function zc(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 Xc={"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 Wc(r){var e;const t=[];for(const i of r)for(const n of i){const o=Xc[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=Us(r),t=fe.parse(e,qr);if(t.contentType!==Fc)return console.warn("Timestamp is not SignedData"),null;const i=fe.parse(t.content,Je);if(i.encapContentInfo.eContentType!==Gc)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=fe.serialize(n);const s=fe.parse(o,ve);let c;if(i.certificates&&i.certificates.length>0){const h=i.certificates[0];"certificate"in h&&h.certificate&&(c=js(fe.serialize(h.certificate)))}let l;s.tsa&&(s.tsa.directoryName?l=Wc(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:zc(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 Kc(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 Jc(r,e){return qn(this,null,function*(){try{const t=r.messageImprint.toLowerCase(),i=new TextEncoder().encode(e),n=yield Kc(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 Xs(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 Jc(i,t.canonicalSignatureValue),n||(o="Could not verify timestamp covers signature (hash mismatch)"));let s;if(t.verifyTsaCertificate&&i.tsaCertificate)try{const c=new D.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 Yc(r){const e=Fn(r);return(e==null?void 0:e.genTime)||null}var Zc=(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 Qc(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 el(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 tl(r){let e=BigInt(0);for(const t of r)e=e<<BigInt(8)|BigInt(t);return e}function rl(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 il(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 nl(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 ol(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 Ws(){return typeof window!="undefined"&&typeof window.crypto!="undefined"&&typeof window.crypto.subtle!="undefined"}function Ks(r,e,t,i){return Zc(this,null,function*(){try{let n;if(Ws()){const f=Qc(r);if(!f)return!1;const{n:h,e:d}=f,g=Math.ceil(h.toString(16).length/2),y=tl(e),v=el(y,d,h),B=rl(v,g);n=il(B)}else{const f=require("crypto"),h=f.createPublicKey({key:Buffer.from(r),format:"der",type:"spki"}),d=f.publicDecrypt({key:h,padding:f.constants.RSA_PKCS1_PADDING},Buffer.from(e));n=new Uint8Array(d)}if(!n)return!1;const o=ol(i),s=nl(n,o);if(!s)return!1;let c;if(Ws()){let f=i.toUpperCase().replace(/-/g,"");f=f.replace(/^SHA(\d)/,"SHA-$1");const h=yield window.crypto.subtle.digest(f,t);c=new Uint8Array(h)}else{const f=require("crypto"),h=i.toLowerCase().replace("-","");c=f.createHash(h).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}})}var sl=Object.defineProperty,Js=Object.getOwnPropertySymbols,al=Object.prototype.hasOwnProperty,cl=Object.prototype.propertyIsEnumerable,Ys=(r,e,t)=>e in r?sl(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,Gn=(r,e)=>{for(var t in e||(e={}))al.call(e,t)&&Ys(r,t,e[t]);if(Js)for(var t of Js(e))cl.call(e,t)&&Ys(r,t,e[t]);return r},Ye=(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 zt(){return typeof window!="undefined"&&typeof window.crypto!="undefined"&&typeof window.crypto.subtle!="undefined"}function ll(){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 ul(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 fl(r){return!zt()||!ll()?!0:r<=4096}function Zs(r,e){return Ye(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 zt()?hl(r,i):pl(r,i)})}function hl(r,e){return Ye(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 pl(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 dl(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 Qs(r,e){return Ye(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=>Ye(this,[s],function*([c,l]){var f;const h=(f=r.digestAlgorithms)!=null&&f[c]?dl(r.digestAlgorithms[c]):n,d=e.get(c);if(d){const g=yield Zs(d,h),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,B]of e.entries())if(v.endsWith(g)){const b=yield Zs(B,h),w=l===b;t[c]={expected:l,actual:b,matches:w,fileFound:!0},w||(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 yl(r){return Ye(this,arguments,function*(e,t=new Date){try{const i=new D.X509Certificate(e),n=pa(i,t),o=yield eo(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 gl(r){switch(r){case"P-256":return 32;case"P-384":return 48;case"P-521":return 66;default:return 32}}function vl(r,e){const t=gl(e),i=t*2;if(r.length===i)return r;if(r[0]===48)return ml(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 ml(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 ea(){return zt()?window.crypto.subtle:crypto.subtle}function wl(r,e,t,i,n){return Ye(this,null,function*(){try{const o=Jn().parseFromString(r,"application/xml"),s=Q(o,"ds:SignedInfo");if(!s)return{isValid:!1,reason:"SignedInfo element not found in provided XML"};const c=n||Ze.default,l=q.canonicalize(s,c),f=e.replace(/\s+/g,"");let h;try{h=Bc(f)}catch(y){return{isValid:!1,reason:`Failed to decode signature value: ${y instanceof Error?y.message:String(y)}`}}i.name==="ECDSA"&&(h=vl(h,i.namedCurve));let d;try{const y=ea(),v=i.name==="RSASSA-PKCS1-v1_5"||i.name==="RSA-PSS";if(v){const B=ul(t);if(B>0&&!fl(B))return{isValid:!1,unsupportedPlatform:!0,reason:`RSA key size (${B} bits) not supported in this browser`,errorDetails:{category:"RSA_KEY_SIZE_UNSUPPORTED",originalMessage:"Safari/WebKit only supports RSA keys up to 4096 bits",algorithm:Gn({},i),environment:"browser",keyLength:t.byteLength}}}if(zt()&&v)try{d=yield y.importKey("spki",t,i,!1,["verify"])}catch(B){const b=xa(t);d=yield y.importKey("spki",b,i,!1,["verify"])}else d=yield y.importKey("spki",t,i,!1,["verify"])}catch(y){const v=y instanceof Error?y:new Error(String(y));let B="Unknown reason",b="KEY_IMPORT_ERROR";if(v.name==="DataError"?(B="Key data format is invalid or incompatible",b="INVALID_KEY_FORMAT"):v.name==="NotSupportedError"?(B="Algorithm or parameters not supported",b="UNSUPPORTED_ALGORITHM"):v.message.includes("namedCurve")?(B="Missing or invalid namedCurve parameter",b="INVALID_CURVE"):v.message.includes("hash")&&(B="Incompatible or unsupported hash algorithm",b="INVALID_HASH"),i.name==="ECDSA"){const w=t.byteLength;B+=` (Key length: ${w})`}return{isValid:!1,reason:`Failed to import public key: ${B}`,errorDetails:{category:b,originalMessage:v.message,algorithm:Gn({},i),environment:zt()?"browser":"node",keyLength:t.byteLength}}}const g=new TextEncoder().encode(l);try{return(yield ea().verify(i,d,h,g))?{isValid:!0}:i.name==="RSASSA-PKCS1-v1_5"&&(yield Ks(t,h,g,i.hash))?{isValid:!0}:{isValid:!1,reason:"Signature verification failed"}}catch(y){return i.name==="RSASSA-PKCS1-v1_5"&&(yield Ks(t,h,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 bl(r,e){return Ye(this,arguments,function*(t,i,n={}){var o,s,c,l;const f=[];let h,d=n.verifyTime||t.signingTime;t.signatureTimestamp&&n.verifyTimestamps!==!1&&(h=yield Xs(t.signatureTimestamp,{canonicalSignatureValue:t.canonicalSignatureValue,verifyTsaCertificate:!0,revocationOptions:n.revocationOptions}),h.isValid&&h.info?d=h.info.genTime:h.isValid||f.push(`Timestamp verification failed: ${h.reason||"Unknown reason"}`));const g=yield yl(t.certificatePEM,d);if(!g.isValid){const N=`Certificate validation error: ${g.reason||"Unknown reason"}`;f.push(N)}if(n.checkRevocation!==!1&&g.isValid)try{const N=yield fn(t.certificatePEM,Gn({certificateChain:t.certificateChain},n.revocationOptions));if(g.revocation=N,N.status==="revoked"){const V=N.revokedAt,C=V&&V.getTime()>0;if(C&&d<V)g.revocation.isValid=!0,g.revocation.reason=`Certificate was revoked on ${V.toISOString()}, but signature was made on ${d.toISOString()} (before revocation)`;else{g.isValid=!1;const x=C?` on ${V.toISOString()}`:"";g.reason=N.reason||`Certificate has been revoked${x}`,f.push(N.reason||`Certificate revoked${x}`)}}}catch(N){g.revocation={isValid:!1,status:"error",method:"none",reason:`Revocation check failed: ${N instanceof Error?N.message:String(N)}`,checkedAt:new Date}}const y=n.verifyChecksums!==!1?yield Qs(t,i):{isValid:!0,details:{}};if(!y.isValid){const N=Object.entries(y.details).filter(([V,C])=>!C.matches).map(([V])=>V).join(", ");f.push(`Checksum validation failed for files: ${N}`)}let v={isValid:!0};if(n.verifySignatures!==!1&&t.rawXml&&t.signatureValue&&t.publicKey){const N=t.algorithm||"",V={name:"RSASSA-PKCS1-v1_5",hash:"SHA-256"};if(N.includes("ecdsa")&&t.publicKey.namedCurve&&(V.namedCurve=t.publicKey.namedCurve,V.name="ECDSA"),N.includes("ecdsa-sha256")?V.hash="SHA-256":N.includes("ecdsa-sha384")?V.hash="SHA-384":N.includes("ecdsa-sha512")?V.hash="SHA-512":N.includes("rsa-sha1")?V.hash="SHA-1":N.includes("rsa-pss")?(V.name="RSA-PSS",V.saltLength=32,N.includes("sha384")?(V.hash="SHA-384",V.saltLength=48):N.includes("sha512")?(V.hash="SHA-512",V.saltLength=64):V.hash="SHA-256"):N.includes("rsa-sha384")?V.hash="SHA-384":N.includes("rsa-sha512")&&(V.hash="SHA-512"),v=yield wl(t.rawXml,t.signatureValue,t.publicKey.rawData,V,t.canonicalizationMethod),!v.isValid){let C=v.reason||"XML signature verification failed";if(v.errorDetails){const x=v.errorDetails;C+=` [Category: ${x.category}, Environment: ${x.environment}`,x.algorithm&&(C+=`, Algorithm: ${x.algorithm.name}`,x.algorithm.namedCurve&&(C+=`, Curve: ${x.algorithm.namedCurve}`)),x.keyLength&&(C+=`, Key length: ${x.keyLength} bytes`),C+="]"}f.push(C)}}else if(n.verifySignatures!==!1){const N=[];t.rawXml||N.push("Signature XML"),t.signatureValue||N.push("SignatureValue"),t.publicKey||N.push("Public Key"),f.push(`Cannot verify XML signature: missing ${N.join(", ")}`),v={isValid:!1,reason:`Missing required components: ${N.join(", ")}`}}const B=!t.signatureTimestamp||n.verifyTimestamps===!1||((o=h==null?void 0:h.isValid)!=null?o:!0),b=g.isValid&&y.isValid&&v.isValid&&B;let w="VALID",U;const K=[];return b||(v.unsupportedPlatform?(w="UNSUPPORTED",U=v.reason,K.push({code:"RSA_KEY_SIZE_UNSUPPORTED",description:v.reason||"RSA key size not supported",platform:"Safari/WebKit"})):y.isValid?!v.isValid&&!v.unsupportedPlatform?(w="INVALID",U=v.reason||"Signature verification failed"):g.isValid?h&&!h.isValid?(w="INDETERMINATE",U=h.reason||"Timestamp verification failed",K.push({code:"TIMESTAMP_VERIFICATION_FAILED",description:h.reason||"Could not verify timestamp to establish proof of existence"})):((l=g.revocation)==null?void 0:l.status)==="unknown"?(w="INDETERMINATE",U="Certificate revocation status could not be determined",K.push({code:"REVOCATION_UNKNOWN",description:g.revocation.reason||"Could not check certificate revocation status"})):(w="INVALID",U=f[0]||"Verification failed"):(s=g.reason)!=null&&s.includes("expired")&&!(h!=null&&h.isValid)?(w="INDETERMINATE",U="Certificate expired and no valid timestamp proof",K.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"})):((c=g.revocation)==null?void 0:c.status)==="revoked"?(w="INVALID",U="Certificate has been revoked"):(w="INDETERMINATE",U=g.reason||"Certificate validation inconclusive"):(w="INVALID",U="File integrity check failed")),{isValid:b,status:w,statusMessage:U,limitations:K.length>0?K:void 0,certificate:g,checksums:y,signature:n.verifySignatures!==!1?v:void 0,timestamp:h,errors:f.length>0?f:void 0}})}E.CANONICALIZATION_METHODS=Ze,E.XMLCanonicalizer=q,E.checkCertificateRevocation=fn,E.formatValidityPeriod=ya,E.getSignerDisplayName=da,E.getTimestampTime=Yc,E.parseCertificate=eo,E.parseEdoc=ka,E.parseTimestamp=Fn,E.verifyChecksums=Qs,E.verifySignature=bl,E.verifyTimestamp=Xs,Object.defineProperty(E,"__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})}));
|
|
79
79
|
//# sourceMappingURL=index.umd.js.map
|