nfets 0.0.43 → 0.0.45

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.
@@ -108,7 +108,7 @@ ${e.join(`
108
108
  `):this.result.push("?>"))}WriteElementNode(e){let t=this.state;this.state===hi.BeforeDocElement&&(this.state=hi.InsideDocElement),this.result.push("<"),this.result.push(e.nodeName);let n=this.WriteNamespacesAxis(e);this.WriteAttributesAxis(e),this.result.push(">");for(let s=e.firstChild;s!=null;s=s.nextSibling)this.WriteNode(s);for(this.result.push("</"),this.result.push(e.nodeName),this.result.push(">"),t===hi.BeforeDocElement&&(this.state=hi.AfterDocElement);n--;)this.visibleNamespaces.Pop()}WriteNamespacesAxis(e){let t=[],n=0;for(let i=0;i<e.attributes.length;i++){let a=e.attributes[i];if(!HB(a)){if(a.prefix&&!this.IsNamespaceRendered(a.prefix,a.namespaceURI)){let h={prefix:a.prefix,namespace:a.namespaceURI};t.push(h),this.visibleNamespaces.Add(h),n++}continue}if(a.localName==="xmlns"&&!a.prefix&&!a.nodeValue){let h={prefix:a.prefix,namespace:a.nodeValue};t.push(h),this.visibleNamespaces.Add(h),n++}let u=null,c;(c=/xmlns:([\w.-]+)/.exec(a.nodeName))&&(u=c[1]);let f=!0;if(this.exclusive&&!this.IsNamespaceInclusive(e,u)){let h=P9(e,u);if(h>1)f=!1;else if(h===0)continue}if(!this.IsNamespaceRendered(u,a.nodeValue)&&f){let h={prefix:u,namespace:a.nodeValue};t.push(h),this.visibleNamespaces.Add(h),n++}}if(!this.IsNamespaceRendered(e.prefix,e.namespaceURI)&&e.namespaceURI!=="http://www.w3.org/2000/xmlns/"){let i={prefix:e.prefix,namespace:e.namespaceURI};t.push(i),this.visibleNamespaces.Add(i),n++}t.sort(yhe);let s=null;return t.forEach(i=>{i.prefix!==s&&(s=i.prefix,this.result.push(" xmlns"),i.prefix&&this.result.push(":"+i.prefix),this.result.push('="'),this.result.push(i.namespace||""),this.result.push('"'))}),n}WriteAttributesAxis(e){let t=[];for(let n=0;n<e.attributes.length;n++){let s=e.attributes[n];HB(s)||t.push(s)}t.sort(xhe),t.forEach(n=>{n!=null&&(this.result.push(" "),this.result.push(n.nodeName),this.result.push('="'),this.result.push(this.NormalizeString(n.nodeValue,Mt.Attribute)),this.result.push('"'))})}NormalizeString(e,t){let n=[];if(e)for(let s=0;s<e.length;s++){let i=e[s];i==="<"&&(t===Mt.Attribute||this.IsTextNode(t))?n.push("&lt;"):i===">"&&this.IsTextNode(t)?n.push("&gt;"):i==="&"&&(t===Mt.Attribute||this.IsTextNode(t))?n.push("&amp;"):i==='"'&&t===Mt.Attribute?n.push("&quot;"):i===" "&&t===Mt.Attribute?n.push("&#x9;"):i===`
109
109
  `&&t===Mt.Attribute?n.push("&#xA;"):i==="\r"?n.push("&#xD;"):n.push(i)}return n.join("")}IsTextNode(e){switch(e){case Mt.Text:case Mt.CDATA:case Mt.SignificantWhitespace:case Mt.Whitespace:return!0}return!1}IsNamespaceInclusive(e,t){let n=t||null;return e.prefix===n?!1:this.inclusiveNamespacesPrefixList.indexOf(n||"")!==-1}IsNamespaceRendered(e,t){if(e=e||"",t=t||"",!e&&!t||e==="xml"&&t==="http://www.w3.org/XML/1998/namespace")return!0;let n=this.visibleNamespaces.GetPrefix(e);return n?n.namespace===t:!1}};function yhe(r,e){return r==e?0:r?e?r.prefix?e.prefix?r.prefix<e.prefix?-1:r.prefix>e.prefix?1:0:1:-1:1:-1}o(yhe,"XmlDsigC14NTransformNamespacesComparer");function xhe(r,e){if(!r.namespaceURI&&e.namespaceURI)return-1;if(!e.namespaceURI&&r.namespaceURI)return 1;let t=(r.namespaceURI||"")+r.localName,n=(e.namespaceURI||"")+e.localName;return t===n?0:t<n?-1:1}o(xhe,"XmlDsigC14NTransformAttributesComparer");function P9(r,e,t=0){let n=e||null;if(r.prefix===n)return++t;if(r.attributes)for(let s=0;s<r.attributes.length;s++){let i=r.attributes[s];if(!HB(i)&&e&&r.attributes[s].prefix===e)return++t}for(let s=r.firstChild;s;s=s.nextSibling)if(s.nodeType===Mt.Element){let a=P9(s,e,t);if(s.nodeType===Mt.Element&&a)return++t+a}return t}o(P9,"IsNamespaceUsed");function HB(r){let e=/xmlns:/;return!!(r!==null&&r.nodeType===Mt.Attribute&&(r.nodeName==="xmlns"||e.test(r.nodeName)))}o(HB,"IsNamespaceNode");var c2=class extends $i{static{o(this,"SignatureMethodOther")}OnLoadXml(e){for(let t=0;t<e.childNodes.length;t++){let n=e.childNodes.item(t);if(n.nodeType!==Mt.Element||n.nodeName===ge.ElementNames.HMACOutputLength)continue;let s;switch(n.localName){case ge.ElementNames.RSAPSSParams:s=wa;break;default:break}if(s){let i=new s;i.LoadXml(n),this.Add(i)}}}};c2=Ke([Ft({localName:"Other"})],c2);var co=class extends $r{static{o(this,"SignatureMethod")}};Ke([kr({localName:ge.AttributeNames.Algorithm,required:!0,defaultValue:""}),ht("design:type",String)],co.prototype,"Algorithm",void 0);Ke([Wt({localName:ge.ElementNames.HMACOutputLength,namespaceURI:ge.NamespaceURI,prefix:ge.DefaultPrefix,converter:Jg}),ht("design:type",Number)],co.prototype,"HMACOutputLength",void 0);Ke([Wt({parser:c2,noRoot:!0,minOccurs:0}),ht("design:type",c2)],co.prototype,"Any",void 0);co=Ke([Ft({localName:ge.ElementNames.SignatureMethod})],co);var h0=class extends $r{static{o(this,"CanonicalizationMethod")}};Ke([kr({localName:ge.AttributeNames.Algorithm,required:!0,defaultValue:ge.DefaultCanonMethod}),ht("design:type",String)],h0.prototype,"Algorithm",void 0);h0=Ke([Ft({localName:ge.ElementNames.CanonicalizationMethod})],h0);var p0=class extends $r{static{o(this,"DataObject")}};Ke([kr({localName:ge.AttributeNames.Id,defaultValue:""}),ht("design:type",String)],p0.prototype,"Id",void 0);Ke([kr({localName:ge.AttributeNames.MimeType,defaultValue:""}),ht("design:type",String)],p0.prototype,"MimeType",void 0);Ke([kr({localName:ge.AttributeNames.Encoding,defaultValue:""}),ht("design:type",String)],p0.prototype,"Encoding",void 0);p0=Ke([Ft({localName:ge.ElementNames.Object})],p0);var ax=class extends $i{static{o(this,"DataObjects")}};ax=Ke([Ft({localName:"xmldsig_objects",parser:p0})],ax);var fs=class extends $r{static{o(this,"Transform")}constructor(){super(...arguments),this.innerXml=null}GetOutput(){throw new qe(Ie.METHOD_NOT_IMPLEMENTED)}LoadInnerXml(e){if(!e)throw new qe(Ie.PARAM_REQUIRED,"node");this.innerXml=e}GetInnerXml(){return this.innerXml}};Ke([kr({localName:ge.AttributeNames.Algorithm,defaultValue:""}),ht("design:type",String)],fs.prototype,"Algorithm",void 0);Ke([Wt({localName:ge.ElementNames.XPath,defaultValue:""}),ht("design:type",String)],fs.prototype,"XPath",void 0);fs=Ke([Ft({localName:ge.ElementNames.Transform})],fs);var hu=class extends fs{static{o(this,"XmlDsigBase64Transform")}constructor(){super(...arguments),this.Algorithm=ge.AlgorithmNamespaces.XmlDsigBase64Transform}GetOutput(){if(!this.innerXml)throw new qe(Ie.PARAM_REQUIRED,"innerXml");return wr.FromString(this.innerXml.textContent||"","base64")}};var lo=class extends fs{static{o(this,"XmlDsigC14NTransform")}constructor(){super(...arguments),this.Algorithm="http://www.w3.org/TR/2001/REC-xml-c14n-20010315",this.xmlCanonicalizer=new uo(!1,!1)}GetOutput(){if(!this.innerXml)throw new qe(Ie.PARAM_REQUIRED,"innerXml");return this.xmlCanonicalizer.Canonicalize(this.innerXml)}},fo=class extends lo{static{o(this,"XmlDsigC14NWithCommentsTransform")}constructor(){super(...arguments),this.Algorithm="http://www.w3.org/TR/2001/REC-xml-c14n-20010315#WithComments",this.xmlCanonicalizer=new uo(!0,!1)}};var pu=class extends fs{static{o(this,"XmlDsigEnvelopedSignatureTransform")}constructor(){super(...arguments),this.Algorithm="http://www.w3.org/2000/09/xmldsig#enveloped-signature"}GetOutput(){if(!this.innerXml)throw new qe(Ie.PARAM_REQUIRED,"innerXml");let e=this.innerXml.firstChild,t=[];for(;e;)oi(e)&&e.localName===ge.ElementNames.Signature&&e.namespaceURI===ge.NamespaceURI&&t.push(e),e=e.nextSibling;for(let n of t)n.parentNode?.removeChild(n);return this.innerXml}};var ho=class extends fs{static{o(this,"XmlDsigExcC14NTransform")}constructor(){super(...arguments),this.Algorithm="http://www.w3.org/2001/10/xml-exc-c14n#",this.xmlCanonicalizer=new uo(!1,!0)}get InclusiveNamespacesPrefixList(){return this.xmlCanonicalizer.InclusiveNamespacesPrefixList}set InclusiveNamespacesPrefixList(e){this.xmlCanonicalizer.InclusiveNamespacesPrefixList=e}LoadXml(e){if(super.LoadXml(e),this.Element&&this.Element.childNodes)for(let t=0;t<this.Element.childNodes.length;t++){let n=this.Element.childNodes[t];if(n&&n.nodeType===1)switch(n.localName){case"InclusiveNamespaces":this.setInclusiveNamespacesElement(n);break}}}GetOutput(){if(!this.innerXml)throw new qe(Ie.PARAM_REQUIRED,"innerXml");return this.xmlCanonicalizer.Canonicalize(this.innerXml)}setInclusiveNamespacesElement(e){let t=e.getAttribute("PrefixList");t&&t.length>0&&(this.xmlCanonicalizer.InclusiveNamespacesPrefixList=t)}},po=class extends ho{static{o(this,"XmlDsigExcC14NWithCommentsTransform")}constructor(){super(...arguments),this.Algorithm="http://www.w3.org/2001/10/xml-exc-c14n#WithComments",this.xmlCanonicalizer=new uo(!0,!0)}};function k9(r){return r.parentNode?k9(r.parentNode):r}o(k9,"lookupParentNode");var d0=class extends fs{static{o(this,"XmlDsigXPathTransform")}constructor(){super(...arguments),this.Algorithm=ge.AlgorithmNamespaces.XmlDsigXPathTransform}GetOutput(){if(!this.innerXml)throw new qe(Ie.PARAM_REQUIRED,"innerXml");this.Filter(k9(this.innerXml),this.XPath)}Filter(e,t){let n=e.childNodes,s=[];for(let i=0;n&&i<n.length;i++){let a=n.item(i);s.push(a)}s.forEach(i=>{this.Evaluate(i,t)?i.parentNode&&i.parentNode.removeChild(i):this.Filter(i,t)})}GetEvaluator(e){return typeof self<"u"?e.ownerDocument==null?e:e.ownerDocument:Yp("xpath")}Evaluate(e,t){try{let n=this.GetEvaluator(e),s=this.GetXml();if(!s||!s.firstChild)throw new Error("XML element or firstChild is not defined");let i=s.firstChild,a=`boolean(${t})`,u=typeof self>"u"?Yp("xpath"):self;return!n.evaluate(a,e,{lookupNamespaceURI:o(f=>i.lookupNamespaceURI(f),"lookupNamespaceURI")},u.XPathResult.ANY_TYPE,null).booleanValue}catch{return!1}}};Ke([Wt({localName:ge.ElementNames.XPath,namespaceURI:ge.NamespaceURI,prefix:ge.DefaultPrefix,required:!0}),ht("design:type",String)],d0.prototype,"XPath",void 0);var m0=class extends $i{static{o(this,"Transforms")}OnLoadXml(e){super.OnLoadXml(e),this.items=this.GetIterator().map(t=>{switch(t.Algorithm){case ge.AlgorithmNamespaces.XmlDsigEnvelopedSignatureTransform:return Rh(t,pu);case ge.AlgorithmNamespaces.XmlDsigC14NTransform:return Rh(t,lo);case ge.AlgorithmNamespaces.XmlDsigC14NWithCommentsTransform:return Rh(t,fo);case ge.AlgorithmNamespaces.XmlDsigExcC14NTransform:return Rh(t,ho);case ge.AlgorithmNamespaces.XmlDsigExcC14NWithCommentsTransform:return Rh(t,po);case ge.AlgorithmNamespaces.XmlDsigBase64Transform:return Rh(t,hu);case ge.AlgorithmNamespaces.XmlDsigXPathTransform:return Rh(t,d0);default:try{let n=ox.CreateFromName(t.Algorithm);if(!t.Element)throw new Error("Transform element is not defined");return n.LoadXml(t.Element),n}catch{throw new qe(Ie.CRYPTOGRAPHIC_UNKNOWN_TRANSFORM,t.Algorithm)}}})}};m0=Ke([Ft({localName:ge.ElementNames.Transforms,parser:fs})],m0);function Rh(r,e){let t=new e;if(!r.Element)throw new Error("Transform element is not defined");return t.LoadXml(r.Element),t}o(Rh,"ChangeTransform");var mo=class extends $r{static{o(this,"Reference")}constructor(e){super(),this.DigestMethod=new Gi,e&&(this.Uri=e)}};Ke([kr({defaultValue:""}),ht("design:type",String)],mo.prototype,"Id",void 0);Ke([kr({localName:ge.AttributeNames.URI}),ht("design:type",String)],mo.prototype,"Uri",void 0);Ke([kr({localName:ge.AttributeNames.Type,defaultValue:""}),ht("design:type",String)],mo.prototype,"Type",void 0);Ke([Wt({parser:m0}),ht("design:type",m0)],mo.prototype,"Transforms",void 0);Ke([Wt({required:!0,parser:Gi}),ht("design:type",Gi)],mo.prototype,"DigestMethod",void 0);Ke([Wt({required:!0,localName:ge.ElementNames.DigestValue,namespaceURI:ge.NamespaceURI,prefix:ge.DefaultPrefix,converter:Vi}),ht("design:type",Uint8Array)],mo.prototype,"DigestValue",void 0);mo=Ke([Ft({localName:ge.ElementNames.Reference}),ht("design:paramtypes",[String])],mo);var g0=class extends $i{static{o(this,"References")}};g0=Ke([Ft({localName:"References",parser:mo})],g0);var du=class extends $r{static{o(this,"SignedInfo")}};Ke([kr({localName:ge.AttributeNames.Id,defaultValue:""}),ht("design:type",String)],du.prototype,"Id",void 0);Ke([Wt({parser:h0,required:!0}),ht("design:type",h0)],du.prototype,"CanonicalizationMethod",void 0);Ke([Wt({parser:co,required:!0}),ht("design:type",co)],du.prototype,"SignatureMethod",void 0);Ke([Wt({parser:g0,minOccurs:1,noRoot:!0}),ht("design:type",g0)],du.prototype,"References",void 0);du=Ke([Ft({localName:ge.ElementNames.SignedInfo})],du);var w0="http://www.w3.org/2001/04/xmldsig-more#",S0="ecdsa",Oh=class extends Fs{static{o(this,"EcdsaPublicKey")}};Ke([Wt({localName:ge.ElementNames.X,namespaceURI:w0,prefix:S0,required:!0,converter:Vi}),ht("design:type",Uint8Array)],Oh.prototype,"X",void 0);Ke([Wt({localName:ge.ElementNames.Y,namespaceURI:w0,prefix:S0,required:!0,converter:Vi}),ht("design:type",Uint8Array)],Oh.prototype,"Y",void 0);Oh=Ke([Ft({localName:ge.ElementNames.PublicKey,namespaceURI:w0,prefix:S0})],Oh);var v0=class extends Fs{static{o(this,"NamedCurve")}};Ke([kr({localName:ge.AttributeNames.URI,required:!0}),ht("design:type",String)],v0.prototype,"Uri",void 0);v0=Ke([Ft({localName:ge.ElementNames.NamedCurve,namespaceURI:w0,prefix:S0})],v0);var y0=class extends Fs{static{o(this,"DomainParameters")}};Ke([Wt({parser:v0}),ht("design:type",v0)],y0.prototype,"NamedCurve",void 0);y0=Ke([Ft({localName:ge.ElementNames.DomainParameters,namespaceURI:w0,prefix:S0})],y0);var x0=class extends fi{static{o(this,"EcdsaKeyValue")}constructor(){super(...arguments),this.name=ge.ElementNames.ECDSAKeyValue,this.key=null,this.jwk=null,this.keyUsage=null}static canImportCryptoKey(e){return e.algorithm.name.toUpperCase()===lu.toUpperCase()}get NamedCurve(){return V9(this.DomainParameters.NamedCurve.Uri)}async importKey(e){if(!e.algorithm.name||e.algorithm.name.toUpperCase()!=="ECDSA")throw new qe(Ie.ALGORITHM_WRONG_NAME,e.algorithm.name);let t=await yn.crypto.subtle.exportKey("jwk",e);return this.key=e,this.jwk=t,this.PublicKey=new Oh,this.PublicKey.X=wr.FromString(t.x||"","base64url"),this.PublicKey.Y=wr.FromString(t.y||"","base64url"),this.DomainParameters||(this.DomainParameters=new y0),this.DomainParameters.NamedCurve||(this.DomainParameters.NamedCurve=new v0),this.DomainParameters.NamedCurve.Uri=V9(t.crv||""),this.keyUsage=e.usages,this}async exportKey(e){if(this.key)return this.key;let t=wr.ToBase64Url(this.PublicKey.X),n=wr.ToBase64Url(this.PublicKey.Y),s=whe(this.DomainParameters.NamedCurve.Uri),i={kty:"EC",crv:s,x:t,y:n,ext:!0};this.keyUsage=["verify"];let a=await yn.crypto.subtle.importKey("jwk",i,{name:"ECDSA",namedCurve:s},!0,this.keyUsage);return this.key=a,this.key}};Ke([Wt({parser:y0}),ht("design:type",y0)],x0.prototype,"DomainParameters",void 0);Ke([Wt({parser:Oh,required:!0}),ht("design:type",Oh)],x0.prototype,"PublicKey",void 0);x0=Ke([Ft({localName:ge.ElementNames.ECDSAKeyValue,namespaceURI:w0,prefix:S0})],x0);function V9(r){switch(r){case"P-256":return"urn:oid:1.2.840.10045.3.1.7";case"P-384":return"urn:oid:1.3.132.0.34";case"P-521":return"urn:oid:1.3.132.0.35"}throw new qe(Ie.CRYPTOGRAPHIC,"Unknown NamedCurve")}o(V9,"GetNamedCurveOid");function whe(r){switch(r){case"urn:oid:1.2.840.10045.3.1.7":return"P-256";case"urn:oid:1.3.132.0.34":return"P-384";case"urn:oid:1.3.132.0.35":return"P-521"}throw new qe(Ie.CRYPTOGRAPHIC,"Unknown NamedCurve OID")}o(whe,"GetNamedCurveFromOid");var She=class extends Map{static{o(this,"KeyInfoClauseRegistry")}},gl=new She;gl.set(ge.ElementNames.RSAKeyValue,l0);gl.set(ge.ElementNames.ECDSAKeyValue,x0);var l2=class{static{o(this,"KeyInfoClauseFactory")}static create(e){let t=gl.get(e);if(!t)throw new qe(Ie.KEY_INFO_CLAUSE_NOT_SUPPORTED,e);return new t}};var ux=class extends fi{static{o(this,"KeyValue")}set Value(e){this.element=null,this.value=e}get Value(){return this.value}constructor(e){super(),e&&(this.Value=e)}async importKey(e){for(let[,t]of gl)if(t.canImportCryptoKey(e)){let n=new t;return await n.importKey(e),this.Value=n,this}throw new qe(Ie.ALGORITHM_NOT_SUPPORTED,e.algorithm.name)}async exportKey(e){if(!this.Value)throw new qe(Ie.NULL_REFERENCE);return this.Value.exportKey(e)}OnGetXml(e){if(!this.Value)throw new qe(Ie.CRYPTOGRAPHIC,"KeyValue has empty value");let t=this.Value.GetXml();t&&e.appendChild(t)}OnLoadXml(e){for(let t=0;t<e.childNodes.length;t++){let n=e.childNodes.item(t);if(oi(n))try{let s=n.localName,i=l2.create(s);i.LoadXml(n),this.value=i;return}catch{}}throw new qe(Ie.CRYPTOGRAPHIC,"Unsupported KeyValue in use")}};ux=Ke([Ft({localName:ge.ElementNames.KeyValue}),ht("design:paramtypes",[fi])],ux);var Ehe={"2.5.4.3":{short:"CN",long:"CommonName"},"2.5.4.6":{short:"C",long:"Country"},"2.5.4.5":{long:"DeviceSerialNumber"},"0.9.2342.19200300.100.1.25":{short:"DC",long:"DomainComponent"},"1.2.840.113549.1.9.1":{short:"E",long:"EMail"},"2.5.4.42":{short:"G",long:"GivenName"},"2.5.4.43":{short:"I",long:"Initials"},"2.5.4.7":{short:"L",long:"Locality"},"2.5.4.10":{short:"O",long:"Organization"},"2.5.4.11":{short:"OU",long:"OrganizationUnit"},"2.5.4.8":{short:"ST",long:"State"},"2.5.4.9":{short:"Street",long:"StreetAddress"},"2.5.4.4":{short:"SN",long:"SurName"},"2.5.4.12":{short:"T",long:"Title"},"1.2.840.113549.1.9.8":{long:"UnstructuredAddress"},"1.2.840.113549.1.9.2":{long:"UnstructuredName"}},E0=class{static{o(this,"X509Certificate")}constructor(e){if(this.publicKey=null,e){let t=new Uint8Array(e);this.LoadRaw(t),this.raw=t}}get SerialNumber(){return this.simpl.serialNumber.valueBlock.toString()}get Issuer(){return this.NameToString(this.simpl.issuer)}get Subject(){return this.NameToString(this.simpl.subject)}async Thumbprint(e="SHA-1"){return yn.crypto.subtle.digest(e,this.raw)}get PublicKey(){return this.publicKey}GetRaw(){return this.raw}async exportKey(e){if(e){let t={algorithm:e,usages:["verify"]};if(t.algorithm.name.toUpperCase()===lu){let s=this.simpl.subjectPublicKeyInfo.toJSON();if("crv"in s&&s.crv)t.algorithm.namedCurve=s.crv;else throw new Error("Cannot get Curved name from the ECDSA public key")}this.isHashedAlgorithm(t.algorithm)&&typeof t.algorithm.hash=="string"&&(t.algorithm.hash={name:t.algorithm.hash});let n=await this.simpl.getPublicKey({algorithm:t});return this.publicKey=n,n}return this.simpl.subjectPublicKeyInfo.algorithm.algorithmId==="1.2.840.113549.1.1.1"?this.publicKey=await this.simpl.getPublicKey({algorithm:{algorithm:{name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-256"}},usages:["verify"]}}):this.publicKey=await this.simpl.getPublicKey(),this.publicKey}NameToString(e,t=","){let n=[];return e.typesAndValues.forEach(s=>{let i=s.type,a=Ehe[i.toString()],u=a?a.short:null;n.push(`${u||i}=${s.value.valueBlock.value}`)}),n.join(t+" ")}LoadRaw(e){this.raw=new Uint8Array(e);let t=Wr(this.raw.buffer);this.simpl=new ls({schema:t.result})}isHashedAlgorithm(e){return!!e.hash}};var f2=class extends $r{static{o(this,"X509IssuerSerial")}};Ke([Wt({localName:ge.ElementNames.X509IssuerName,namespaceURI:ge.NamespaceURI,prefix:ge.DefaultPrefix,required:!0}),ht("design:type",String)],f2.prototype,"X509IssuerName",void 0);Ke([Wt({localName:ge.ElementNames.X509SerialNumber,namespaceURI:ge.NamespaceURI,prefix:ge.DefaultPrefix,required:!0}),ht("design:type",String)],f2.prototype,"X509SerialNumber",void 0);f2=Ke([Ft({localName:ge.ElementNames.X509IssuerSerial})],f2);var Ph;(function(r){r[r.None=0]="None",r[r.EndCertOnly=1]="EndCertOnly",r[r.ExcludeRoot=2]="ExcludeRoot",r[r.WholeChain=3]="WholeChain"})(Ph||(Ph={}));var b0=class extends fi{static{o(this,"KeyInfoX509Data")}constructor(e,t=Ph.None){if(super(),this.x509crl=null,this.SubjectKeyIdList=[],e){if(e instanceof Uint8Array)this.AddCertificate(new E0(e));else if(e instanceof E0)switch(t){case Ph.None:case Ph.EndCertOnly:this.AddCertificate(e);break;case Ph.ExcludeRoot:this.AddCertificatesChainFrom(e,!1);break;case Ph.WholeChain:this.AddCertificatesChainFrom(e,!0);break}}}async importKey(e){throw new qe(Ie.METHOD_NOT_SUPPORTED)}async exportKey(e){if(!this.Certificates.length)throw new qe(Ie.NULL_REFERENCE);return this.Key=await this.Certificates[0].exportKey(e),this.Key}get Certificates(){return this.X509CertificateList}get CRL(){return this.x509crl}set CRL(e){this.x509crl=e}get IssuerSerials(){return this.IssuerSerialList}get SubjectKeyIds(){return this.SubjectKeyIdList}get SubjectNames(){return this.SubjectNameList}AddCertificate(e){if(!e)throw new qe(Ie.PARAM_REQUIRED,"certificate");this.X509CertificateList||(this.X509CertificateList=[]),this.X509CertificateList.push(e)}AddIssuerSerial(e,t){if(e==null)throw new qe(Ie.PARAM_REQUIRED,"issuerName");this.IssuerSerialList==null&&(this.IssuerSerialList=[]);let n={issuerName:e,serialNumber:t};this.IssuerSerialList.push(n)}AddSubjectKeyId(e){if(this.SubjectKeyIdList&&(this.SubjectKeyIdList=[]),typeof e=="string"){if(e!=null){let t=wr.FromBase64(e);this.SubjectKeyIdList.push(t)}}else this.SubjectKeyIdList.push(e)}AddSubjectName(e){this.SubjectNameList==null&&(this.SubjectNameList=[]),this.SubjectNameList.push(e)}GetXml(){let e=this.CreateDocument(),t=this.CreateElement(e),n=this.GetPrefix();if(this.IssuerSerialList!=null&&this.IssuerSerialList.length>0&&this.IssuerSerialList.forEach(s=>{let i=e.createElementNS(ge.NamespaceURI,n+ge.ElementNames.X509IssuerSerial),a=e.createElementNS(ge.NamespaceURI,n+ge.ElementNames.X509IssuerName);a.textContent=s.issuerName,i.appendChild(a);let u=e.createElementNS(ge.NamespaceURI,n+ge.ElementNames.X509SerialNumber);u.textContent=s.serialNumber,i.appendChild(u),t.appendChild(i)}),this.SubjectKeyIdList!=null&&this.SubjectKeyIdList.length>0&&this.SubjectKeyIdList.forEach(s=>{let i=e.createElementNS(ge.NamespaceURI,n+ge.ElementNames.X509SKI);i.textContent=wr.ToBase64(s),t.appendChild(i)}),this.SubjectNameList!=null&&this.SubjectNameList.length>0&&this.SubjectNameList.forEach(s=>{let i=e.createElementNS(ge.NamespaceURI,n+ge.ElementNames.X509SubjectName);i.textContent=s,t.appendChild(i)}),this.X509CertificateList!=null&&this.X509CertificateList.length>0&&this.X509CertificateList.forEach(s=>{let i=e.createElementNS(ge.NamespaceURI,n+ge.ElementNames.X509Certificate);i.textContent=wr.ToBase64(s.GetRaw()),t.appendChild(i)}),this.x509crl!=null){let s=e.createElementNS(ge.NamespaceURI,n+ge.ElementNames.X509CRL);s.textContent=wr.ToBase64(this.x509crl),t.appendChild(s)}return t}LoadXml(e){super.LoadXml(e),this.IssuerSerialList&&(this.IssuerSerialList=[]),this.SubjectKeyIdList&&(this.SubjectKeyIdList=[]),this.SubjectNameList&&(this.SubjectNameList=[]),this.X509CertificateList&&(this.X509CertificateList=[]),this.x509crl=null;let t=this.GetChildren(ge.ElementNames.X509IssuerSerial);t&&t.forEach(s=>{let i=$r.GetChild(s,ge.ElementNames.X509IssuerName,ge.NamespaceURI,!0),a=$r.GetChild(s,ge.ElementNames.X509SerialNumber,ge.NamespaceURI,!0);i&&i.textContent&&a&&a.textContent&&this.AddIssuerSerial(i.textContent,a.textContent)}),t=this.GetChildren(ge.ElementNames.X509SKI),t&&t.forEach(s=>{if(s.textContent){let i=wr.FromBase64(s.textContent);this.AddSubjectKeyId(i)}}),t=this.GetChildren(ge.ElementNames.X509SubjectName),t?.forEach(s=>{s.textContent&&this.AddSubjectName(s.textContent)}),t=this.GetChildren(ge.ElementNames.X509Certificate),t&&t.forEach(s=>{if(s.textContent){let i=wr.FromBase64(s.textContent);this.AddCertificate(new E0(i))}});let n=this.GetChild(ge.ElementNames.X509CRL,!1);n&&n.textContent&&(this.x509crl=wr.FromBase64(n.textContent))}AddCertificatesChainFrom(e,t){}};b0=Ke([Ft({localName:ge.ElementNames.X509Data}),ht("design:paramtypes",[Object,Object])],b0);var cx=class extends fi{static{o(this,"SPKIData")}async importKey(e){let t=await yn.crypto.subtle.exportKey("spki",e);return this.SPKIexp=new Uint8Array(t),this.Key=e,this}async exportKey(e){if(!this.SPKIexp)throw new Error("SPKI data is not defined");let t=await yn.crypto.subtle.importKey("spki",this.SPKIexp,e,!0,["verify"]);return this.Key=t,t}};Ke([Wt({localName:ge.ElementNames.SPKIexp,namespaceURI:ge.NamespaceURI,prefix:ge.DefaultPrefix,required:!0,converter:Vi}),ht("design:type",Object)],cx.prototype,"SPKIexp",void 0);cx=Ke([Ft({localName:ge.ElementNames.SPKIData})],cx);var kh=class extends $i{static{o(this,"KeyInfo")}OnLoadXml(e){for(let t=0;t<e.childNodes.length;t++){let n=e.childNodes.item(t);if(n.nodeType!==Mt.Element)continue;let s=null;switch(n.localName){case ge.ElementNames.KeyValue:s=ux;break;case ge.ElementNames.X509Data:s=b0;break;case ge.ElementNames.SPKIData:s=cx;break;case ge.ElementNames.KeyName:case ge.ElementNames.RetrievalMethod:case ge.ElementNames.PGPData:case ge.ElementNames.MgmtData:}if(s){let i=new s;i.LoadXml(n),this.Add(i)}}}};Ke([kr({localName:ge.AttributeNames.Id,defaultValue:""}),ht("design:type",String)],kh.prototype,"Id",void 0);kh=Ke([Ft({localName:ge.ElementNames.KeyInfo})],kh);var vl=class extends $r{static{o(this,"Signature")}};Ke([kr({localName:ge.AttributeNames.Id,defaultValue:""}),ht("design:type",String)],vl.prototype,"Id",void 0);Ke([Wt({parser:du,required:!0}),ht("design:type",du)],vl.prototype,"SignedInfo",void 0);Ke([Wt({localName:ge.ElementNames.SignatureValue,namespaceURI:ge.NamespaceURI,prefix:ge.DefaultPrefix,required:!0,converter:Vi,defaultValue:null}),ht("design:type",Object)],vl.prototype,"SignatureValue",void 0);Ke([Wt({parser:kh}),ht("design:type",kh)],vl.prototype,"KeyInfo",void 0);Ke([Wt({parser:ax,noRoot:!0}),ht("design:type",ax)],vl.prototype,"ObjectList",void 0);vl=Ke([Ft({localName:ge.ElementNames.Signature})],vl);var Ahe=class extends Map{static{o(this,"AlgorithmRegistry")}},dr=new Ahe;dr.set(n2,{type:"signature",algorithm:a0});dr.set(s2,{type:"signature",algorithm:o0});dr.set(i2,{type:"signature",algorithm:u0});dr.set(a2,{type:"signature",algorithm:c0});dr.set(n2,{type:"signature",algorithm:a0});dr.set(s2,{type:"signature",algorithm:o0});dr.set(i2,{type:"signature",algorithm:u0});dr.set(a2,{type:"signature",algorithm:c0});dr.set(qB,{type:"signature",algorithm:u2});dr.set(YA,{type:"signature",algorithm:t0});dr.set(QA,{type:"signature",algorithm:r0});dr.set(ZA,{type:"signature",algorithm:n0});dr.set(e2,{type:"signature",algorithm:s0});dr.set(YA.toUpperCase(),{type:"signature",algorithm:t0});dr.set(QA.toUpperCase(),{type:"signature",algorithm:r0});dr.set(ZA.toUpperCase(),{type:"signature",algorithm:n0});dr.set(e2.toUpperCase(),{type:"signature",algorithm:s0});dr.set(LB,{type:"signature",algorithm:rx});dr.set(VB,{type:"signature",algorithm:nx});dr.set(UB,{type:"signature",algorithm:sx});dr.set(jB,{type:"signature",algorithm:ix});dr.set(Ym,{type:"hash",algorithm:WA});dr.set(Qm,{type:"hash",algorithm:tx});dr.set(Zm,{type:"hash",algorithm:zA});dr.set(e0,{type:"hash",algorithm:JA});var Lh=class{static{o(this,"AlgorithmFactory")}static createHashAlgorithmFromNamespace(e){for(let[t,{type:n,algorithm:s}]of dr)if(n==="hash"&&t===e)return new s;throw new qe(Ie.ALGORITHM_NOT_SUPPORTED,e)}static createSignatureAlgorithmFromMethod(e){for(let[t,{type:n,algorithm:s}]of dr)if(n==="signature"&&e.Algorithm===t){let i=new s;return i.fromMethod&&i.fromMethod(e),i}throw new qe(Ie.ALGORITHM_NOT_SUPPORTED,e.Algorithm)}static createHashAlgorithmFromAlgorithm(e){for(let[,{type:t,algorithm:n}]of dr)if(t==="hash"){let s=new n;if(s.algorithm.name.toUpperCase()===e.name.toUpperCase())return s}throw new qe(Ie.ALGORITHM_NOT_SUPPORTED,e.name)}static createSignatureAlgorithmFromAlgorithm(e){for(let[,{type:t,algorithm:n}]of dr)if(t==="signature"){let s=n.fromAlgorithm(e);if(s)return s}throw new qe(Ie.ALGORITHM_NOT_SUPPORTED,e.name)}};var Che=class extends Map{static{o(this,"TransformRegistry")}},mu=new Che;mu.set(ge.AlgorithmNamespaces.XmlDsigBase64Transform,hu);mu.set(ge.AlgorithmNamespaces.XmlDsigC14NTransform,lo);mu.set(ge.AlgorithmNamespaces.XmlDsigC14NWithCommentsTransform,fo);mu.set(ge.AlgorithmNamespaces.XmlDsigEnvelopedSignatureTransform,pu);mu.set(ge.AlgorithmNamespaces.XmlDsigExcC14NTransform,ho);mu.set(ge.AlgorithmNamespaces.XmlDsigExcC14NWithCommentsTransform,po);var ox=class{static{o(this,"CryptoConfig")}static CreateFromName(e){if(!e)throw new qe(Ie.PARAM_REQUIRED,"name");let t=mu.get(e);if(t)return new t;let n;switch(e){case ge.AlgorithmNamespaces.XmlDsigBase64Transform:n=new hu;break;case ge.AlgorithmNamespaces.XmlDsigC14NTransform:n=new lo;break;case ge.AlgorithmNamespaces.XmlDsigC14NWithCommentsTransform:n=new fo;break;case ge.AlgorithmNamespaces.XmlDsigEnvelopedSignatureTransform:n=new pu;break;case ge.AlgorithmNamespaces.XmlDsigXPathTransform:throw new qe(Ie.ALGORITHM_NOT_SUPPORTED,e);case ge.AlgorithmNamespaces.XmlDsigXsltTransform:throw new qe(Ie.ALGORITHM_NOT_SUPPORTED,e);case ge.AlgorithmNamespaces.XmlDsigExcC14NTransform:n=new ho;break;case ge.AlgorithmNamespaces.XmlDsigExcC14NWithCommentsTransform:n=new po;break;case ge.AlgorithmNamespaces.XmlDecryptionTransform:throw new qe(Ie.ALGORITHM_NOT_SUPPORTED,e);default:throw new qe(Ie.ALGORITHM_NOT_SUPPORTED,e)}return n}static CreateSignatureAlgorithm(e){return Lh.createSignatureAlgorithmFromMethod(e)}static CreateHashAlgorithm(e){return Lh.createHashAlgorithmFromNamespace(e)}static GetHashAlgorithm(e){let t=typeof e=="string"?{name:e}:e;return Lh.createHashAlgorithmFromAlgorithm(t)}static GetSignatureAlgorithm(e){let t=typeof e=="string"?{name:e}:e;return"hash"in t&&typeof t.hash=="string"&&(t.hash={name:t.hash}),Lh.createSignatureAlgorithmFromAlgorithm(t)}static CreateSignatureMethod(e){let t=new co;return t.Algorithm=e.namespaceURI,e.toMethod&&e.toMethod(t),t}static RegisterSignatureAlgorithm(e,t){dr.set(e,{type:"signature",algorithm:t})}static RegisterHashAlgorithm(e,t){dr.set(e,{type:"hash",algorithm:t})}static RegisterKeyInfoClause(e,t){gl.set(e,t)}static RegisterTransform(e,t){mu.set(e,t)}};var h2=Zx(OI(),1);var U9={xmldec:{version:"1.0",encoding:"UTF-8",standalone:void 0}};var j9={explicitArray:!1,explicitRoot:!1,preserveChildrenOrder:!0};var M9=class{static{o(this,"Xml2JsToolkit")}xml2js;constructor(e=Ihe){this.xml2js=e,rM({XMLSerializer:h2.default.XMLSerializer,DOMParser:h2.default.DOMParser,DOMImplementation:h2.default.DOMImplementation})}async validate(e,t){try{return await IU.validate(e,t),ri()}catch(n){return qu(n)}}parse(e,t){return new Promise((n,s)=>new this.xml2js.Parser({...j9,...t}).parseString(e,(i,a)=>i?s(i):n(a)))}build(e,t){return Promise.resolve(new this.xml2js.Builder({...U9,...t}).buildObject(e))}digest(e,t,n=K0){return this.hash(this.canonicalize(e,n),t)}canonicalize(e,t=K0){let n=Li(this.clear(e));return new uo(t.includeComments,t.exclusive).Canonicalize(n)}getNode(e,t){let s=Li(e).documentElement.getElementsByTagName(t).item(0);return s?this.clear(Za(s)):null}getFirstNode(e){let n=Li(e).documentElement.firstChild;return n?this.clear(Za(n)):null}getAttribute(e,t){return Li(e).documentElement.getAttribute(t)}appendNode(e,t){let n=Li(e),{documentElement:s}=Li(t);return n.documentElement.appendChild(s),this.clear(Za(n))}hash(e,t){return The.createHash(t).update(e,"utf8").digest().toString("base64")}clear(e){return['xmlns:default="http://www.w3.org/2000/09/xmldsig#"',' standalone="no"',"default:",":default",`
110
110
  `,"\r"," "].reduce((n,s)=>n.replace(s,""),e.replace(/(>)\s*(<)/gm,"$1$2"))}};import{registerDecorator as _he}from"class-validator";var F9=o(r=>(e,t)=>{_he({name:"isDecimal",target:e.constructor,propertyName:t,options:r,validator:{validate(n){return n instanceof np?!0:typeof n=="string"||typeof n=="number"||typeof n=="bigint"},defaultMessage(n){return`${n.property} is not a valid Decimal value`}}})},"IsDecimal");import"reflect-metadata";import{registerDecorator as q9}from"class-validator";var A0=Symbol("choice"),C0=o(r=>r==null||r==="","isEmpty"),VTe=o(r=>e=>{let{properties:t,required:n=!1,...s}=r,i=Reflect.getMetadata(A0,e)??[],a={properties:t,required:n};i.push(a),Reflect.defineMetadata(A0,i,e);for(let u of t)q9({name:"choice",target:e,propertyName:u,options:s,validator:{validate(c,f){let h=f.object,m=f.property,g=Reflect.getMetadata(A0,e);if(!g)return!0;let x=g.find(v=>v.properties.includes(m));if(!x||C0(c))return!0;for(let v of x.properties){if(v===m)continue;let S=h[v];if(!C0(S))return!1}for(let v of g)if(v!==x)for(let S of v.properties){let E=h[S];if(!C0(E))return!1}return!0},defaultMessage(c){let f=Reflect.getMetadata(A0,e);if(!f)return`${c.property} validation error`;let h=f.find(g=>g.properties.includes(c.property));if(!h)return`${c.property} validation error`;let m=c.object;for(let g of h.properties){let x=m[g];if(!C0(x)&&g!==c.property)return`${c.property} cannot be set because ${g} is already set. Only one property from this choice group is allowed.`}for(let g of f)if(g!==h)for(let x of g.properties){let v=m[x];if(!C0(v))return`${c.property} cannot be set because ${x} from a different choice group is already set.`}return`${c.property} validation error`}}});if(n)for(let u of t)q9({name:"choiceGroupRequired",target:e,propertyName:u,options:{...s,always:!0},validator:{validate(c,f){let h=f.object,m=Reflect.getMetadata(A0,e);if(!m)return!0;let g=m.find(x=>x.properties.includes(f.property));if(!g?.required)return!0;for(let x of g.properties){let v=h[x];if(!C0(v))return!0}return f.property!==g.properties[0]},defaultMessage(c){let f=Reflect.getMetadata(A0,e);if(!f)return"At least one property from a choice group must be provided";let h=f.find(m=>m.properties.includes(c.property));return h?`You must provide a value for one of the following properties: ${h.properties.join(", ")}`:"At least one property from a choice group must be provided"}}})},"Choice");import"reflect-metadata";import{Transform as Dhe}from"class-transformer";var KTe=o(({fixed:r,...e}={fixed:2})=>(t,n)=>{F9(e)(t,n),Dhe(({value:s})=>np.newOrUndefined(s)?.toFixed(r))(t,n)},"TransformDecimal");import{Transform as Ohe}from"class-transformer";import{IsDateString as Phe}from"class-validator";import KB from"dayjs";import Bhe from"dayjs/plugin/utc.js";import Rhe from"dayjs/plugin/timezone.js";KB.extend(Bhe);KB.extend(Rhe);var H9=KB;var eIe=o((r={})=>(e,t)=>{Ohe(({value:n})=>{let s=n instanceof Date?n.toISOString():n;return s?H9(s).tz("America/Sao_Paulo").format(r.format):void 0})(e,t),Phe()(e,t)},"TransformDateString");var K9=class{static{o(this,"StateCodeAcValidator")}execute(e){if(e=e.replace(/\D/g,""),!/^01\d{11}$/.test(e))return!1;let t=e.split("").map(Number),n=t.slice(0,11),s=t[11],i=t[12],a=[4,3,2,9,8,7,6,5,4,3,2],c=n.reduce((v,S,E)=>v+S*a[E],0)%11,f=c===0||c===1?0:11-c,h=[5,4,3,2,9,8,7,6,5,4,3,2],g=[...n,f].reduce((v,S,E)=>v+S*h[E],0)%11,x=g===0||g===1?0:11-g;return s===f&&i===x}};var $9=class{static{o(this,"StateCodeAlValidator")}execute(e){let t=e.replace(/\D/g,"");if(t.length!==9||!t.startsWith("24"))return!1;let n=[9,8,7,6,5,4,3,2],s=0;for(let c=0;c<8;c++)s+=parseInt(t[c],10)*n[c];let a=s*10%11;return(a===10?0:a)===parseInt(t[8],10)}};var G9=class{static{o(this,"StateCodeAmValidator")}execute(e){let t=e.replace(/\D/g,"");if(t.length!==9)return!1;let n=[9,8,7,6,5,4,3,2],s=0;for(let a=0;a<8;a++)s+=parseInt(t[a],10)*n[a];let i;if(s<11)i=11-s;else{let a=s%11;i=a<=1?0:11-a}return i===parseInt(t[8],10)}};var X9=class{static{o(this,"StateCodeApValidator")}execute(e){let t=e.replace(/\D/g,"");if(t.length!==9||!t.startsWith("03"))return!1;let n=t.substring(0,8),s=parseInt(n,10),i,a;s>=3017001&&s<=3019022?(i=9,a=1):s>=3000001&&s<=3017e3?(i=5,a=0):(i=0,a=0);let u=[9,8,7,6,5,4,3,2],c=i;for(let m=0;m<8;m++)c+=parseInt(t[m],10)*u[m];let h=11-c%11;return h===10?h=0:h===11&&(h=a),h===parseInt(t[8],10)}};var W9=class{static{o(this,"StateCodeBaValidator")}execute(e){let t=e.replace(/\D/g,"");if(t.length!==8&&t.length!==9)return!1;let n=t.split("").map(S=>parseInt(S,10)),s=(t.length===8?n[0]:n[1])<=5||n[0]===8?10:11,i=t.length===8?[7,6,5,4,3,2]:[8,7,6,5,4,3,2],a=0;for(let S=0;S<i.length;S++)a+=n[S]*i[S];let u=a%s,c=s-u;(s===11&&u<=1||s===10&&u===0)&&(c=0);let h=(t.slice(0,t.length-2)+c.toString()).split("").map(S=>parseInt(S,10)),m=t.length===8?[8,7,6,5,4,3,2]:[9,8,7,6,5,4,3,2],g=0;for(let S=0;S<m.length;S++)g+=h[S]*m[S];let x=g%s,v=s-x;return(s===11&&x<=1||s===10&&x===0)&&(v=0),v===n[t.length-2]&&c===n[t.length-1]}};var z9=class{static{o(this,"StateCodeCeValidator")}execute(e){let t=e.replace(/\D/g,"");if(t.length!==9)return!1;let n=[9,8,7,6,5,4,3,2],s=0;for(let u=0;u<8;u++)s+=parseInt(t[u],10)*n[u];let a=11-s%11;return(a===10||a===11)&&(a=0),a===parseInt(t[8],10)}};var J9=class{static{o(this,"StateCodeDfValidator")}execute(e){let t=e.replace(/\D/g,"");if(t.length!==13||!t.startsWith("07"))return!1;let n=t.slice(0,11).split("").map(Number),s=t.slice(11).split("").map(Number),i=[2,3,4,5,6,7,8,9],a=0;for(let m=10,g=0;m>=0;m--,g=(g+1)%i.length)a+=n[m]*i[g];let u=11-a%11;(u===10||u===11)&&(u=0);let c=n.concat([u]),f=0;for(let m=11,g=0;m>=0;m--,g=(g+1)%i.length)f+=c[m]*i[g];let h=11-f%11;return(h===10||h===11)&&(h=0),u===s[0]&&h===s[1]}};var Y9=class{static{o(this,"StateCodeEsValidator")}execute(e){let t=e.replace(/\D/g,"");if(t.length!==9)return!1;let n=[9,8,7,6,5,4,3,2],s=0;for(let u=0;u<8;u++)s+=parseInt(t[u],10)*n[u];let i=s%11;return(i<2?0:11-i)===parseInt(t[8],10)}};var Q9=class{static{o(this,"StateCodeGoValidator")}execute(e){let t=e.replace(/\D/g,"");if(t.length!==9)return!1;let n=parseInt(t.substring(0,2));if(!(n===10||n===11||n>=20&&n<=29))return!1;let s=[9,8,7,6,5,4,3,2],i=0;for(let c=0;c<8;c++)i+=parseInt(t[c],10)*s[c];let a=i%11;return(a===0||a===1?0:11-a)===parseInt(t[8],10)}};var Z9=class{static{o(this,"StateCodeMaValidator")}execute(e){let t=e.replace(/\D/g,"");if(t.length!==9||!t.startsWith("12"))return!1;let n=[9,8,7,6,5,4,3,2],s=0;for(let u=0;u<8;u++)s+=parseInt(t[u],10)*n[u];let i=s%11;return(i===0||i===1?0:11-i)===parseInt(t[8],10)}};var eq=class{static{o(this,"StateCodeMgValidator")}execute(e){let t=e.replace(/\D/g,"");if(t.length!==13)return!1;let n=t.slice(0,11),s=n.slice(0,3)+"0"+n.slice(3),i=0;for(let x=0;x<12;x++){let v=x%2===0?1:2,S=(parseInt(s[x])*v).toString();i+=S.split("").reduce((E,C)=>E+parseInt(C),0)}let u=Math.ceil(i/10)*10-i,c=n+u.toString(),f=[3,2,11,10,9,8,7,6,5,4,3,2],h=0;for(let x=0;x<12;x++)h+=parseInt(c[x])*f[x];let m=h%11,g=m<2?0:11-m;return parseInt(t[11])===u&&parseInt(t[12])===g}};var tq=class{static{o(this,"StateCodeMsValidator")}execute(e){let t=e.replace(/\D/g,"");if(t.length!==9||!(t.startsWith("28")||t.startsWith("50")))return!1;let n=[9,8,7,6,5,4,3,2],s=0;for(let c=0;c<8;c++)s+=parseInt(t[c],10)*n[c];let i=s%11,a=11-i;return(i===0||a>9?0:a)===parseInt(t[8],10)}};var rq=class{static{o(this,"StateCodeMtValidator")}execute(e){let t=e.replace(/\D/g,"");if(t.length!==11)return!1;let n=[3,2,9,8,7,6,5,4,3,2],s=0;for(let u=0;u<10;u++)s+=parseInt(t[u],10)*n[u];let i=s%11;return(i===0||i===1?0:11-i)===parseInt(t[10],10)}};var nq=class{static{o(this,"StateCodePaValidator")}execute(e){let t=e.replace(/\D/g,"");if(t.length!==9)return!1;let n=[9,8,7,6,5,4,3,2],s=0;for(let u=0;u<8;u++)s+=parseInt(t[u])*n[u];let i=s%11;return(i===0||i===1?0:11-i)===parseInt(t[8])}};var sq=class{static{o(this,"StateCodePbValidator")}execute(e){let t=e.replace(/\D/g,"");if(t.length!==9)return!1;let n=[9,8,7,6,5,4,3,2],s=0;for(let u=0;u<8;u++)s+=parseInt(t[u])*n[u];let a=11-s%11;return(a===10||a===11)&&(a=0),a===parseInt(t[8])}};var iq=class{static{o(this,"StateCodePeValidator")}execute(e){let t=e.replace(/\D/g,"");if(t.length!==9)return!1;let n=t.slice(0,7).split("").map(Number),s=[8,7,6,5,4,3,2],i=0;for(let x=0;x<7;x++)i+=n[x]*s[x];let a=i%11,u=a===0||a===1?0:11-a,c=[...n,u],f=[9,8,7,6,5,4,3,2],h=0;for(let x=0;x<8;x++)h+=c[x]*f[x];let m=h%11,g=m===0||m===1?0:11-m;return u===parseInt(t[7])&&g===parseInt(t[8])}};var aq=class{static{o(this,"StateCodePiValidator")}execute(e){let t=e.replace(/\D/g,"");if(t.length!==9)return!1;let n=[9,8,7,6,5,4,3,2],s=0;for(let u=0;u<8;u++)s+=parseInt(t[u],10)*n[u];let a=11-s%11;return(a===10||a===11)&&(a=0),a===parseInt(t[8],10)}};var oq=class{static{o(this,"StateCodePrValidator")}execute(e){let t=e.replace(/\D/g,"");if(t.length!==10)return!1;let n=t.slice(0,8).split("").map(Number),s=[3,2,7,6,5,4,3,2],i=[4,3,2,7,6,5,4,3,2],a=0;for(let m=0;m<8;m++)a+=n[m]*s[m];let u=11-a%11;u>=10&&(u=0);let c=[...n,u],f=0;for(let m=0;m<9;m++)f+=c[m]*i[m];let h=11-f%11;return h>=10&&(h=0),u===parseInt(t[8])&&h===parseInt(t[9])}};var uq=class{static{o(this,"StateCodeRjValidator")}execute(e){let t=e.replace(/\D/g,"");if(t.length!==8)return!1;let n=[2,7,6,5,4,3,2],s=0;for(let u=0;u<7;u++)s+=parseInt(t[u],10)*n[u];let i=s%11;return(i<=1?0:11-i)===parseInt(t[7],10)}};var cq=class{static{o(this,"StateCodeRnValidator")}execute(e){let t=e.replace(/\D/g,"");if(!(t.length===9||t.length===10)||!t.startsWith("20"))return!1;let n=t.length===9?[9,8,7,6,5,4,3,2]:[10,9,8,7,6,5,4,3,2],s=t.slice(0,n.length).split("").map(Number),i=0;for(let f=0;f<n.length;f++)i+=s[f]*n[f];let u=i*10%11;return(u===10?0:u)===parseInt(t[t.length-1])}};var lq=class{static{o(this,"StateCodeRoValidator")}execute(e){let t=e.replace(/\D/g,""),n,s;if(t.length===9)n=t.slice(3,8).split("").map(Number),s=[6,5,4,3,2];else if(t.length===14)n=t.slice(0,13).split("").map(Number),s=[6,5,4,3,2,9,8,7,6,5,4,3,2];else return!1;let i=0;for(let c=0;c<s.length;c++)i+=n[c]*s[c];let u=11-i%11;return(u===10||u===11)&&(u-=10),u===parseInt(t[t.length-1])}};var fq=class{static{o(this,"StateCodeRrValidator")}execute(e){let t=e.replace(/\D/g,"");if(t.length!==9||!t.startsWith("24"))return!1;let n=0;for(let i=0;i<8;i++)n+=(i+1)*parseInt(t[i],10);return n%9===parseInt(t[8],10)}};var hq=class{static{o(this,"StateCodeRsValidator")}execute(e){let t=e.replace(/\D/g,"");if(t.length!==10)return!1;let n=[2,9,8,7,6,5,4,3,2],s=0;for(let a=0;a<9;a++)s+=parseInt(t[a],10)*n[a];let i=11-s%11;return(i===10||i===11)&&(i=0),i===parseInt(t[9],10)}};var pq=class{static{o(this,"StateCodeScValidator")}execute(e){let t=e.replace(/\D/g,"");if(t.length!==9)return!1;let n=[9,8,7,6,5,4,3,2],s=0;for(let u=0;u<8;u++)s+=parseInt(t[u],10)*n[u];let a=11-s%11;return(a===10||a===11)&&(a=0),a===parseInt(t[8],10)}};var dq=class{static{o(this,"StateCodeSeValidator")}execute(e){let t=e.replace(/\D/g,"");if(t.length!==9)return!1;let n=[9,8,7,6,5,4,3,2],s=0;for(let u=0;u<8;u++)s+=parseInt(t[u])*n[u];let a=11-s%11;return(a===10||a===11)&&(a=0),a===parseInt(t[8],10)}};var mq=class{static{o(this,"StateCodeSpValidator")}execute(e){let t=e;if(t.length!==12)return!1;let n=t.split("").map(Number),s=[1,3,4,5,6,7,8,10],i=0;for(let h=0;h<8;h++)i+=n[h]*s[h];let a=i%11%10,u=[3,2,10,9,8,7,6,5,4,3,2],c=0;for(let h=0;h<11;h++)c+=n[h]*u[h];let f=c%11%10;return a===n[8]&&f===n[11]}};var gq=class{static{o(this,"StateCodeToValidator")}execute(e){let t=e.replace(/\D/g,"");if(t.length!==11)return!1;let n=t.split(""),s=n.slice(0,2).concat(n.slice(4,10)).map(Number),i=[9,8,7,6,5,4,3,2],a=0;for(let f=0;f<i.length;f++)a+=s[f]*i[f];let u=a%11;return(u<2?0:11-u)===parseInt(t[10])}};var p2=class{static{o(this,"ASN1")}extractCertificateInfo(e){let n=e.subject.split(`
111
- `).reduce((i,a)=>{let[u,c]=a.split("=").map(f=>f.trim());return!u||!c?i:i.set(u,c)},new Map),s=this.oid("2.16.76.1.3.1",e.raw);return{CNPJ:this.oid("2.16.76.1.3.3",e.raw),CPF:s,CN:n.get("CN")?.replace(/:.*$/g,""),O:n.get("O"),OU:n.get("OU"),ST:n.get("ST"),L:n.get("L"),C:n.get("C")}}oid(e,t){let n=this.marker(e),s=t.indexOf(n);if(s===-1)return;let i=[t.subarray(0,s),t.subarray(s)];if(i.length<=1)return;let u=i[0].subarray(-4),c=u.subarray(-2);u[0]===48?c=u:u[1]===48&&(c=u.subarray(-3));let f=Buffer.concat([c,n,i[1]]),h=this.length(f),m=n.length,g=f.subarray(2+m,2+m+h),x=g.length-c.length-2;if(x<=0||x>g.length)return;let S=g.subarray(-x).toString("utf8");return S.substring(Buffer.from(S).findIndex((E,C)=>S.charCodeAt(C)>=32&&S.charCodeAt(C)<=126))}length(e){return e.length<2?0:e[1]<=127?e[1]:Buffer.from([e[1]&15]).reduce((t,n)=>t<<8|n,0)}marker(e){let t=e.split("."),n=t.slice(2).reduce((s,i)=>{let a=this.base128(s,Number.parseInt(i,10),!0);return s.length=0,s.push(...a),s},[]);return Buffer.from([6,n.length+1,40*Number.parseInt(t[0],10)+Number.parseInt(t[1],10),...n])}base128(e,t,n){let s=[...e];if(t>127){let a=this.base128(e,Math.floor(t/128),!1);a.length=0,s.push(...a)}let i=t%128;return n?s.push(i):s.push(128|i),s}};var yq=class{static{o(this,"NativeCertificateRepository")}httpClient;cache;constructor(e,t=new lw){this.httpClient=e,this.cache=t}async read(e){try{let{password:t}=e,n=await this.getPfxBuffer(e);if(n.isLeft())return n;let s=Vh.default.asn1.fromDer(n.value.toString("binary")),i=Vh.default.pkcs12.pkcs12FromAsn1(s,t),{certBag:a,pkcs8ShroudedKeyBag:u}=Vh.default.pki.oids,c=i.getBags({bagType:a}),f=i.getBags({bagType:u}),h=c[a];if(!h?.length)return ti(new dn("Cannot read certificate"));let[{cert:m},...g]=h;if(!m)return ti(new dn("Issuer Certificate not found"));let x=f[u]?.[0].key;if(!x)return ti(new dn("Certificate Private Key not found"));let v=g.reduce((b,{cert:A})=>(A&&b.push(new N0.X509Certificate(Vh.default.pki.certificateToPem(A))),b),[]),S=Vh.default.pki.privateKeyToPem(x),E=Vh.default.pki.certificateToPem(m),C=N0.createPrivateKey(S),_=new N0.X509Certificate(E);return ri({ca:v,password:t,privateKey:C,certificate:_})}catch(t){return qu(t)}}async sign(e,t,n=Nu.SHA1){try{let i=N0.sign(n,Buffer.from(e),{key:t,padding:N0.constants.RSA_PKCS1_PADDING}).toString("base64");return await Promise.resolve(ri(i))}catch(s){return Promise.resolve(qu(s))}}getCertificateInfo(e){return new p2().extractCertificateInfo(e)}getStringCertificate(e){return e.raw.toString("base64")}getStringPrivateKey(e){try{return e.export({type:"pkcs8",format:"pem"}).toString()}catch{throw new dn("Cannot extract private key")}}async getPfxBuffer(e){let{pfxPathOrBase64:t,password:n}=e,s=this.getCacheKey(t,n),i=await this.cache.get(s);if(i)return ri(i);if(khe.isAbsolute(t)||vq.existsSync(t))return this.hitBufferOnCache(s,vq.readFileSync(t));if(this.isValidRemoteUrl(t))try{let a=await this.httpClient.get(t,{responseType:"arraybuffer"});return await this.hitBufferOnCache(s,Buffer.from(a.data))}catch(a){return qu(a)}return this.hitBufferOnCache(s,Buffer.from(t,"base64"))}getCacheKey(e,t){return N0.createHash("sha256").update(`${e}.${t}`).digest("hex")}async hitBufferOnCache(e,t){return await this.cache.set(e,t),ri(t)}isValidRemoteUrl(e){try{return new URL(e),!0}catch{return!1}}};var aDe={[Er.AC]:"America/Rio_Branco",[Er.AL]:"America/Maceio",[Er.AM]:"America/Manaus",[Er.AP]:"America/Belem",[Er.BA]:"America/Bahia",[Er.CE]:"America/Fortaleza",[Er.DF]:"America/Sao_Paulo",[Er.ES]:"America/Sao_Paulo",[Er.GO]:"America/Sao_Paulo",[Er.MA]:"America/Fortaleza",[Er.MG]:"America/Sao_Paulo",[Er.MS]:"America/Campo_Grande",[Er.MT]:"America/Cuiaba",[Er.PA]:"America/Belem",[Er.PB]:"America/Fortaleza",[Er.PE]:"America/Recife",[Er.PI]:"America/Fortaleza",[Er.PR]:"America/Sao_Paulo",[Er.RJ]:"America/Sao_Paulo",[Er.RN]:"America/Fortaleza",[Er.RO]:"America/Porto_Velho",[Er.RR]:"America/Boa_Vista",[Er.RS]:"America/Sao_Paulo",[Er.SC]:"America/Sao_Paulo",[Er.SE]:"America/Maceio",[Er.SP]:"America/Sao_Paulo",[Er.TO]:"America/Araguaina"};export{_C as a,gP as b,DC as c,Nu as d,BC as e,Er as f,Vhe as g,jhe as h,dn as i,vP as j,RC as k,Zh as l,ti as m,ri as n,yP as o,xP as p,$0 as q,dpe as r,mpe as s,tw as t,wP as u,SP as v,EP as w,Cpe as x,np as y,VP as z,lw as A,yq as B,v8 as C,x8 as D,N8 as E,wU as F,M9 as G,F9 as H,VTe as I,KTe as J,eIe as K,K9 as L,$9 as M,G9 as N,X9 as O,W9 as P,z9 as Q,J9 as R,Y9 as S,Q9 as T,Z9 as U,eq as V,tq as W,rq as X,nq as Y,sq as Z,iq as _,aq as $,oq as aa,uq as ba,cq as ca,lq as da,fq as ea,hq as fa,pq as ga,dq as ha,mq as ia,gq as ja,p2 as ka};
111
+ `).reduce((i,a)=>{let[u,c]=a.split("=").map(f=>f.trim());return!u||!c?i:i.set(u,c)},new Map),s=this.oid("2.16.76.1.3.1",e.raw);return{CNPJ:this.oid("2.16.76.1.3.3",e.raw),CPF:s,CN:n.get("CN")?.replace(/:.*$/g,""),O:n.get("O"),OU:n.get("OU"),ST:n.get("ST"),L:n.get("L"),C:n.get("C")}}oid(e,t){let n=this.marker(e),s=t.indexOf(n);if(s===-1)return;let i=[t.subarray(0,s),t.subarray(s)];if(i.length<=1)return;let u=i[0].subarray(-4),c=u.subarray(-2);u[0]===48?c=u:u[1]===48&&(c=u.subarray(-3));let f=Buffer.concat([c,n,i[1]]),h=this.length(f),m=n.length,g=f.subarray(2+m,2+m+h),x=g.length-c.length-2;if(x<=0||x>g.length)return;let S=g.subarray(-x).toString("utf8");return S.substring(Buffer.from(S).findIndex((E,C)=>S.charCodeAt(C)>=32&&S.charCodeAt(C)<=126))}length(e){return e.length<2?0:e[1]<=127?e[1]:Buffer.from([e[1]&15]).reduce((t,n)=>t<<8|n,0)}marker(e){let t=e.split("."),n=t.slice(2).reduce((s,i)=>{let a=this.base128(s,Number.parseInt(i,10),!0);return s.length=0,s.push(...a),s},[]);return Buffer.from([6,n.length+1,40*Number.parseInt(t[0],10)+Number.parseInt(t[1],10),...n])}base128(e,t,n){let s=[...e];if(t>127){let a=this.base128(e,Math.floor(t/128),!1);a.length=0,s.push(...a)}let i=t%128;return n?s.push(i):s.push(128|i),s}};var yq=class{static{o(this,"NativeCertificateRepository")}httpClient;cache;constructor(e,t=new lw){this.httpClient=e,this.cache=t}async read(e){try{let{password:t}=e,n=await this.getPfxBuffer(e);if(n.isLeft())return n;let s=Vh.default.asn1.fromDer(n.value.toString("binary")),i=Vh.default.pkcs12.pkcs12FromAsn1(s,t),{certBag:a,pkcs8ShroudedKeyBag:u}=Vh.default.pki.oids,c=i.getBags({bagType:a}),f=i.getBags({bagType:u}),h=c[a];if(!h?.length)return ti(new dn("Cannot read certificate"));let[{cert:m},...g]=h;if(!m)return ti(new dn("Issuer Certificate not found"));let x=f[u]?.[0].key;if(!x)return ti(new dn("Certificate Private Key not found"));let v=g.reduce((b,{cert:A})=>(A&&b.push(new N0.X509Certificate(Vh.default.pki.certificateToPem(A))),b),[]),S=Vh.default.pki.privateKeyToPem(x),E=Vh.default.pki.certificateToPem(m),C=N0.createPrivateKey(S),_=new N0.X509Certificate(E);return ri({ca:v,password:t,privateKey:C,certificate:_})}catch(t){return qu(t)}}async sign(e,t,n=Nu.SHA1){try{let i=N0.sign(n,Buffer.from(e),{key:t,padding:N0.constants.RSA_PKCS1_PADDING}).toString("base64");return await Promise.resolve(ri(i))}catch(s){return Promise.resolve(qu(s))}}getCertificateInfo(e){return new p2().extractCertificateInfo(e)}getStringCertificate(e){return e.raw.toString("base64")}getStringPrivateKey(e){try{return e.export({type:"pkcs8",format:"pem"})}catch{throw new dn("Cannot extract private key")}}async getPfxBuffer(e){let{pfxPathOrBase64:t,password:n}=e,s=this.getCacheKey(t,n),i=await this.cache.get(s);if(i)return ri(i);if(khe.isAbsolute(t)||vq.existsSync(t))return this.hitBufferOnCache(s,vq.readFileSync(t));if(this.isValidRemoteUrl(t))try{let a=await this.httpClient.get(t,{responseType:"arraybuffer"});return await this.hitBufferOnCache(s,Buffer.from(a.data))}catch(a){return qu(a)}return this.hitBufferOnCache(s,Buffer.from(t,"base64"))}getCacheKey(e,t){return N0.createHash("sha256").update(`${e}.${t}`).digest("hex")}async hitBufferOnCache(e,t){return await this.cache.set(e,t),ri(t)}isValidRemoteUrl(e){try{return new URL(e),!0}catch{return!1}}};var aDe={[Er.AC]:"America/Rio_Branco",[Er.AL]:"America/Maceio",[Er.AM]:"America/Manaus",[Er.AP]:"America/Belem",[Er.BA]:"America/Bahia",[Er.CE]:"America/Fortaleza",[Er.DF]:"America/Sao_Paulo",[Er.ES]:"America/Sao_Paulo",[Er.GO]:"America/Sao_Paulo",[Er.MA]:"America/Fortaleza",[Er.MG]:"America/Sao_Paulo",[Er.MS]:"America/Campo_Grande",[Er.MT]:"America/Cuiaba",[Er.PA]:"America/Belem",[Er.PB]:"America/Fortaleza",[Er.PE]:"America/Recife",[Er.PI]:"America/Fortaleza",[Er.PR]:"America/Sao_Paulo",[Er.RJ]:"America/Sao_Paulo",[Er.RN]:"America/Fortaleza",[Er.RO]:"America/Porto_Velho",[Er.RR]:"America/Boa_Vista",[Er.RS]:"America/Sao_Paulo",[Er.SC]:"America/Sao_Paulo",[Er.SE]:"America/Maceio",[Er.SP]:"America/Sao_Paulo",[Er.TO]:"America/Araguaina"};export{_C as a,gP as b,DC as c,Nu as d,BC as e,Er as f,Vhe as g,jhe as h,dn as i,vP as j,RC as k,Zh as l,ti as m,ri as n,yP as o,xP as p,$0 as q,dpe as r,mpe as s,tw as t,wP as u,SP as v,EP as w,Cpe as x,np as y,VP as z,lw as A,yq as B,v8 as C,x8 as D,N8 as E,wU as F,NU as G,M9 as H,F9 as I,VTe as J,KTe as K,eIe as L,K9 as M,$9 as N,G9 as O,X9 as P,W9 as Q,z9 as R,J9 as S,Y9 as T,Q9 as U,Z9 as V,eq as W,tq as X,rq as Y,nq as Z,sq as _,iq as $,aq as aa,oq as ba,uq as ca,cq as da,lq as ea,fq as fa,hq as ga,pq as ha,dq as ia,mq as ja,gq as ka,p2 as la};
112
112
  /*! Bundled license information:
113
113
 
114
114
  lodash/lodash.js: