nfets 0.0.46 → 0.0.48
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/chunk-CAMDTF2T.mjs +20 -0
- package/dist/{chunk-EG7US67K.mjs → chunk-Q47VIRPG.mjs} +1 -1
- package/dist/core/index.mjs +1 -1
- package/dist/index.cjs +100 -82
- package/dist/index.d.cts +2 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.mjs +1 -1
- package/dist/nfe/index.cjs +99 -81
- package/dist/nfe/index.d.cts +138 -5
- package/dist/nfe/index.d.ts +138 -5
- package/dist/nfe/index.mjs +1 -1
- package/package.json +1 -1
- package/dist/chunk-LP4JOWRA.mjs +0 -2
|
@@ -115,7 +115,7 @@ ${e.join(`
|
|
|
115
115
|
`):this.result.push("?>"))}WriteElementNode(e){let t=this.state;this.state===yi.BeforeDocElement&&(this.state=yi.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===yi.BeforeDocElement&&(this.state=yi.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(!xO(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 l=!0;if(this.exclusive&&!this.IsNamespaceInclusive(e,u)){let h=oH(e,u);if(h>1)l=!1;else if(h===0)continue}if(!this.IsNamespaceRendered(u,a.nodeValue)&&l){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(q0e);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];xO(s)||t.push(s)}t.sort(H0e),t.forEach(n=>{n!=null&&(this.result.push(" "),this.result.push(n.nodeName),this.result.push('="'),this.result.push(this.NormalizeString(n.nodeValue,qt.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===qt.Attribute||this.IsTextNode(t))?n.push("<"):i===">"&&this.IsTextNode(t)?n.push(">"):i==="&"&&(t===qt.Attribute||this.IsTextNode(t))?n.push("&"):i==='"'&&t===qt.Attribute?n.push("""):i===" "&&t===qt.Attribute?n.push("	"):i===`
|
|
116
116
|
`&&t===qt.Attribute?n.push("
"):i==="\r"?n.push("
"):n.push(i)}return n.join("")}IsTextNode(e){switch(e){case qt.Text:case qt.CDATA:case qt.SignificantWhitespace:case qt.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 q0e(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(q0e,"XmlDsigC14NTransformNamespacesComparer");function H0e(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(H0e,"XmlDsigC14NTransformAttributesComparer");function oH(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(!xO(i)&&e&&r.attributes[s].prefix===e)return++t}for(let s=r.firstChild;s;s=s.nextSibling)if(s.nodeType===qt.Element){let a=oH(s,e,t);if(s.nodeType===qt.Element&&a)return++t+a}return t}o(oH,"IsNamespaceUsed");function xO(r){let e=/xmlns:/;return!!(r!==null&&r.nodeType===qt.Attribute&&(r.nodeName==="xmlns"||e.test(r.nodeName)))}o(xO,"IsNamespaceNode");var f2=class extends Qi{static{o(this,"SignatureMethodOther")}OnLoadXml(e){for(let t=0;t<e.childNodes.length;t++){let n=e.childNodes.item(t);if(n.nodeType!==qt.Element||n.nodeName===ye.ElementNames.HMACOutputLength)continue;let s;switch(n.localName){case ye.ElementNames.RSAPSSParams:s=_a;break;default:break}if(s){let i=new s;i.LoadXml(n),this.Add(i)}}}};f2=Xe([Ht({localName:"Other"})],f2);var So=class extends Wr{static{o(this,"SignatureMethod")}};Xe([Ur({localName:ye.AttributeNames.Algorithm,required:!0,defaultValue:""}),dt("design:type",String)],So.prototype,"Algorithm",void 0);Xe([Jt({localName:ye.ElementNames.HMACOutputLength,namespaceURI:ye.NamespaceURI,prefix:ye.DefaultPrefix,converter:kv}),dt("design:type",Number)],So.prototype,"HMACOutputLength",void 0);Xe([Jt({parser:f2,noRoot:!0,minOccurs:0}),dt("design:type",f2)],So.prototype,"Any",void 0);So=Xe([Ht({localName:ye.ElementNames.SignatureMethod})],So);var M0=class extends Wr{static{o(this,"CanonicalizationMethod")}};Xe([Ur({localName:ye.AttributeNames.Algorithm,required:!0,defaultValue:ye.DefaultCanonMethod}),dt("design:type",String)],M0.prototype,"Algorithm",void 0);M0=Xe([Ht({localName:ye.ElementNames.CanonicalizationMethod})],M0);var q0=class extends Wr{static{o(this,"DataObject")}};Xe([Ur({localName:ye.AttributeNames.Id,defaultValue:""}),dt("design:type",String)],q0.prototype,"Id",void 0);Xe([Ur({localName:ye.AttributeNames.MimeType,defaultValue:""}),dt("design:type",String)],q0.prototype,"MimeType",void 0);Xe([Ur({localName:ye.AttributeNames.Encoding,defaultValue:""}),dt("design:type",String)],q0.prototype,"Encoding",void 0);q0=Xe([Ht({localName:ye.ElementNames.Object})],q0);var $x=class extends Qi{static{o(this,"DataObjects")}};$x=Xe([Ht({localName:"xmldsig_objects",parser:q0})],$x);var gs=class extends Wr{static{o(this,"Transform")}constructor(){super(...arguments),this.innerXml=null}GetOutput(){throw new $e(De.METHOD_NOT_IMPLEMENTED)}LoadInnerXml(e){if(!e)throw new $e(De.PARAM_REQUIRED,"node");this.innerXml=e}GetInnerXml(){return this.innerXml}};Xe([Ur({localName:ye.AttributeNames.Algorithm,defaultValue:""}),dt("design:type",String)],gs.prototype,"Algorithm",void 0);Xe([Jt({localName:ye.ElementNames.XPath,defaultValue:""}),dt("design:type",String)],gs.prototype,"XPath",void 0);gs=Xe([Ht({localName:ye.ElementNames.Transform})],gs);var Au=class extends gs{static{o(this,"XmlDsigBase64Transform")}constructor(){super(...arguments),this.Algorithm=ye.AlgorithmNamespaces.XmlDsigBase64Transform}GetOutput(){if(!this.innerXml)throw new $e(De.PARAM_REQUIRED,"innerXml");return br.FromString(this.innerXml.textContent||"","base64")}};var Eo=class extends gs{static{o(this,"XmlDsigC14NTransform")}constructor(){super(...arguments),this.Algorithm="http://www.w3.org/TR/2001/REC-xml-c14n-20010315",this.xmlCanonicalizer=new wo(!1,!1)}GetOutput(){if(!this.innerXml)throw new $e(De.PARAM_REQUIRED,"innerXml");return this.xmlCanonicalizer.Canonicalize(this.innerXml)}},bo=class extends Eo{static{o(this,"XmlDsigC14NWithCommentsTransform")}constructor(){super(...arguments),this.Algorithm="http://www.w3.org/TR/2001/REC-xml-c14n-20010315#WithComments",this.xmlCanonicalizer=new wo(!0,!1)}};var Cu=class extends gs{static{o(this,"XmlDsigEnvelopedSignatureTransform")}constructor(){super(...arguments),this.Algorithm="http://www.w3.org/2000/09/xmldsig#enveloped-signature"}GetOutput(){if(!this.innerXml)throw new $e(De.PARAM_REQUIRED,"innerXml");let e=this.innerXml.firstChild,t=[];for(;e;)pi(e)&&e.localName===ye.ElementNames.Signature&&e.namespaceURI===ye.NamespaceURI&&t.push(e),e=e.nextSibling;for(let n of t)n.parentNode?.removeChild(n);return this.innerXml}};var Ao=class extends gs{static{o(this,"XmlDsigExcC14NTransform")}constructor(){super(...arguments),this.Algorithm="http://www.w3.org/2001/10/xml-exc-c14n#",this.xmlCanonicalizer=new wo(!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 $e(De.PARAM_REQUIRED,"innerXml");return this.xmlCanonicalizer.Canonicalize(this.innerXml)}setInclusiveNamespacesElement(e){let t=e.getAttribute("PrefixList");t&&t.length>0&&(this.xmlCanonicalizer.InclusiveNamespacesPrefixList=t)}},Co=class extends Ao{static{o(this,"XmlDsigExcC14NWithCommentsTransform")}constructor(){super(...arguments),this.Algorithm="http://www.w3.org/2001/10/xml-exc-c14n#WithComments",this.xmlCanonicalizer=new wo(!0,!0)}};function uH(r){return r.parentNode?uH(r.parentNode):r}o(uH,"lookupParentNode");var H0=class extends gs{static{o(this,"XmlDsigXPathTransform")}constructor(){super(...arguments),this.Algorithm=ye.AlgorithmNamespaces.XmlDsigXPathTransform}GetOutput(){if(!this.innerXml)throw new $e(De.PARAM_REQUIRED,"innerXml");this.Filter(uH(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:Nd("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"?Nd("xpath"):self;return!n.evaluate(a,e,{lookupNamespaceURI:o(l=>i.lookupNamespaceURI(l),"lookupNamespaceURI")},u.XPathResult.ANY_TYPE,null).booleanValue}catch{return!1}}};Xe([Jt({localName:ye.ElementNames.XPath,namespaceURI:ye.NamespaceURI,prefix:ye.DefaultPrefix,required:!0}),dt("design:type",String)],H0.prototype,"XPath",void 0);var K0=class extends Qi{static{o(this,"Transforms")}OnLoadXml(e){super.OnLoadXml(e),this.items=this.GetIterator().map(t=>{switch(t.Algorithm){case ye.AlgorithmNamespaces.XmlDsigEnvelopedSignatureTransform:return ep(t,Cu);case ye.AlgorithmNamespaces.XmlDsigC14NTransform:return ep(t,Eo);case ye.AlgorithmNamespaces.XmlDsigC14NWithCommentsTransform:return ep(t,bo);case ye.AlgorithmNamespaces.XmlDsigExcC14NTransform:return ep(t,Ao);case ye.AlgorithmNamespaces.XmlDsigExcC14NWithCommentsTransform:return ep(t,Co);case ye.AlgorithmNamespaces.XmlDsigBase64Transform:return ep(t,Au);case ye.AlgorithmNamespaces.XmlDsigXPathTransform:return ep(t,H0);default:try{let n=Gx.CreateFromName(t.Algorithm);if(!t.Element)throw new Error("Transform element is not defined");return n.LoadXml(t.Element),n}catch{throw new $e(De.CRYPTOGRAPHIC_UNKNOWN_TRANSFORM,t.Algorithm)}}})}};K0=Xe([Ht({localName:ye.ElementNames.Transforms,parser:gs})],K0);function ep(r,e){let t=new e;if(!r.Element)throw new Error("Transform element is not defined");return t.LoadXml(r.Element),t}o(ep,"ChangeTransform");var No=class extends Wr{static{o(this,"Reference")}constructor(e){super(),this.DigestMethod=new Zi,e&&(this.Uri=e)}};Xe([Ur({defaultValue:""}),dt("design:type",String)],No.prototype,"Id",void 0);Xe([Ur({localName:ye.AttributeNames.URI}),dt("design:type",String)],No.prototype,"Uri",void 0);Xe([Ur({localName:ye.AttributeNames.Type,defaultValue:""}),dt("design:type",String)],No.prototype,"Type",void 0);Xe([Jt({parser:K0}),dt("design:type",K0)],No.prototype,"Transforms",void 0);Xe([Jt({required:!0,parser:Zi}),dt("design:type",Zi)],No.prototype,"DigestMethod",void 0);Xe([Jt({required:!0,localName:ye.ElementNames.DigestValue,namespaceURI:ye.NamespaceURI,prefix:ye.DefaultPrefix,converter:Ki}),dt("design:type",Uint8Array)],No.prototype,"DigestValue",void 0);No=Xe([Ht({localName:ye.ElementNames.Reference}),dt("design:paramtypes",[String])],No);var $0=class extends Qi{static{o(this,"References")}};$0=Xe([Ht({localName:"References",parser:No})],$0);var Nu=class extends Wr{static{o(this,"SignedInfo")}};Xe([Ur({localName:ye.AttributeNames.Id,defaultValue:""}),dt("design:type",String)],Nu.prototype,"Id",void 0);Xe([Jt({parser:M0,required:!0}),dt("design:type",M0)],Nu.prototype,"CanonicalizationMethod",void 0);Xe([Jt({parser:So,required:!0}),dt("design:type",So)],Nu.prototype,"SignatureMethod",void 0);Xe([Jt({parser:$0,minOccurs:1,noRoot:!0}),dt("design:type",$0)],Nu.prototype,"References",void 0);Nu=Xe([Ht({localName:ye.ElementNames.SignedInfo})],Nu);var z0="http://www.w3.org/2001/04/xmldsig-more#",J0="ecdsa",tp=class extends Ws{static{o(this,"EcdsaPublicKey")}};Xe([Jt({localName:ye.ElementNames.X,namespaceURI:z0,prefix:J0,required:!0,converter:Ki}),dt("design:type",Uint8Array)],tp.prototype,"X",void 0);Xe([Jt({localName:ye.ElementNames.Y,namespaceURI:z0,prefix:J0,required:!0,converter:Ki}),dt("design:type",Uint8Array)],tp.prototype,"Y",void 0);tp=Xe([Ht({localName:ye.ElementNames.PublicKey,namespaceURI:z0,prefix:J0})],tp);var G0=class extends Ws{static{o(this,"NamedCurve")}};Xe([Ur({localName:ye.AttributeNames.URI,required:!0}),dt("design:type",String)],G0.prototype,"Uri",void 0);G0=Xe([Ht({localName:ye.ElementNames.NamedCurve,namespaceURI:z0,prefix:J0})],G0);var X0=class extends Ws{static{o(this,"DomainParameters")}};Xe([Jt({parser:G0}),dt("design:type",G0)],X0.prototype,"NamedCurve",void 0);X0=Xe([Ht({localName:ye.ElementNames.DomainParameters,namespaceURI:z0,prefix:J0})],X0);var W0=class extends vi{static{o(this,"EcdsaKeyValue")}constructor(){super(...arguments),this.name=ye.ElementNames.ECDSAKeyValue,this.key=null,this.jwk=null,this.keyUsage=null}static canImportCryptoKey(e){return e.algorithm.name.toUpperCase()===Eu.toUpperCase()}get NamedCurve(){return lH(this.DomainParameters.NamedCurve.Uri)}async importKey(e){if(!e.algorithm.name||e.algorithm.name.toUpperCase()!=="ECDSA")throw new $e(De.ALGORITHM_WRONG_NAME,e.algorithm.name);let t=await bn.crypto.subtle.exportKey("jwk",e);return this.key=e,this.jwk=t,this.PublicKey=new tp,this.PublicKey.X=br.FromString(t.x||"","base64url"),this.PublicKey.Y=br.FromString(t.y||"","base64url"),this.DomainParameters||(this.DomainParameters=new X0),this.DomainParameters.NamedCurve||(this.DomainParameters.NamedCurve=new G0),this.DomainParameters.NamedCurve.Uri=lH(t.crv||""),this.keyUsage=e.usages,this}async exportKey(e){if(this.key)return this.key;let t=br.ToBase64Url(this.PublicKey.X),n=br.ToBase64Url(this.PublicKey.Y),s=K0e(this.DomainParameters.NamedCurve.Uri),i={kty:"EC",crv:s,x:t,y:n,ext:!0};this.keyUsage=["verify"];let a=await bn.crypto.subtle.importKey("jwk",i,{name:"ECDSA",namedCurve:s},!0,this.keyUsage);return this.key=a,this.key}};Xe([Jt({parser:X0}),dt("design:type",X0)],W0.prototype,"DomainParameters",void 0);Xe([Jt({parser:tp,required:!0}),dt("design:type",tp)],W0.prototype,"PublicKey",void 0);W0=Xe([Ht({localName:ye.ElementNames.ECDSAKeyValue,namespaceURI:z0,prefix:J0})],W0);function lH(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 $e(De.CRYPTOGRAPHIC,"Unknown NamedCurve")}o(lH,"GetNamedCurveOid");function K0e(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 $e(De.CRYPTOGRAPHIC,"Unknown NamedCurve OID")}o(K0e,"GetNamedCurveFromOid");var $0e=class extends Map{static{o(this,"KeyInfoClauseRegistry")}},Dl=new $0e;Dl.set(ye.ElementNames.RSAKeyValue,j0);Dl.set(ye.ElementNames.ECDSAKeyValue,W0);var h2=class{static{o(this,"KeyInfoClauseFactory")}static create(e){let t=Dl.get(e);if(!t)throw new $e(De.KEY_INFO_CLAUSE_NOT_SUPPORTED,e);return new t}};var Xx=class extends vi{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 Dl)if(t.canImportCryptoKey(e)){let n=new t;return await n.importKey(e),this.Value=n,this}throw new $e(De.ALGORITHM_NOT_SUPPORTED,e.algorithm.name)}async exportKey(e){if(!this.Value)throw new $e(De.NULL_REFERENCE);return this.Value.exportKey(e)}OnGetXml(e){if(!this.Value)throw new $e(De.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(pi(n))try{let s=n.localName,i=h2.create(s);i.LoadXml(n),this.value=i;return}catch{}}throw new $e(De.CRYPTOGRAPHIC,"Unsupported KeyValue in use")}};Xx=Xe([Ht({localName:ye.ElementNames.KeyValue}),dt("design:paramtypes",[vi])],Xx);var G0e={"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"}},Y0=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 bn.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()===Eu){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=G0e[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=Qr(this.raw.buffer);this.simpl=new ms({schema:t.result})}isHashedAlgorithm(e){return!!e.hash}};var p2=class extends Wr{static{o(this,"X509IssuerSerial")}};Xe([Jt({localName:ye.ElementNames.X509IssuerName,namespaceURI:ye.NamespaceURI,prefix:ye.DefaultPrefix,required:!0}),dt("design:type",String)],p2.prototype,"X509IssuerName",void 0);Xe([Jt({localName:ye.ElementNames.X509SerialNumber,namespaceURI:ye.NamespaceURI,prefix:ye.DefaultPrefix,required:!0}),dt("design:type",String)],p2.prototype,"X509SerialNumber",void 0);p2=Xe([Ht({localName:ye.ElementNames.X509IssuerSerial})],p2);var rp;(function(r){r[r.None=0]="None",r[r.EndCertOnly=1]="EndCertOnly",r[r.ExcludeRoot=2]="ExcludeRoot",r[r.WholeChain=3]="WholeChain"})(rp||(rp={}));var Q0=class extends vi{static{o(this,"KeyInfoX509Data")}constructor(e,t=rp.None){if(super(),this.x509crl=null,this.SubjectKeyIdList=[],e){if(e instanceof Uint8Array)this.AddCertificate(new Y0(e));else if(e instanceof Y0)switch(t){case rp.None:case rp.EndCertOnly:this.AddCertificate(e);break;case rp.ExcludeRoot:this.AddCertificatesChainFrom(e,!1);break;case rp.WholeChain:this.AddCertificatesChainFrom(e,!0);break}}}async importKey(e){throw new $e(De.METHOD_NOT_SUPPORTED)}async exportKey(e){if(!this.Certificates.length)throw new $e(De.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 $e(De.PARAM_REQUIRED,"certificate");this.X509CertificateList||(this.X509CertificateList=[]),this.X509CertificateList.push(e)}AddIssuerSerial(e,t){if(e==null)throw new $e(De.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=br.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(ye.NamespaceURI,n+ye.ElementNames.X509IssuerSerial),a=e.createElementNS(ye.NamespaceURI,n+ye.ElementNames.X509IssuerName);a.textContent=s.issuerName,i.appendChild(a);let u=e.createElementNS(ye.NamespaceURI,n+ye.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(ye.NamespaceURI,n+ye.ElementNames.X509SKI);i.textContent=br.ToBase64(s),t.appendChild(i)}),this.SubjectNameList!=null&&this.SubjectNameList.length>0&&this.SubjectNameList.forEach(s=>{let i=e.createElementNS(ye.NamespaceURI,n+ye.ElementNames.X509SubjectName);i.textContent=s,t.appendChild(i)}),this.X509CertificateList!=null&&this.X509CertificateList.length>0&&this.X509CertificateList.forEach(s=>{let i=e.createElementNS(ye.NamespaceURI,n+ye.ElementNames.X509Certificate);i.textContent=br.ToBase64(s.GetRaw()),t.appendChild(i)}),this.x509crl!=null){let s=e.createElementNS(ye.NamespaceURI,n+ye.ElementNames.X509CRL);s.textContent=br.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(ye.ElementNames.X509IssuerSerial);t&&t.forEach(s=>{let i=Wr.GetChild(s,ye.ElementNames.X509IssuerName,ye.NamespaceURI,!0),a=Wr.GetChild(s,ye.ElementNames.X509SerialNumber,ye.NamespaceURI,!0);i&&i.textContent&&a&&a.textContent&&this.AddIssuerSerial(i.textContent,a.textContent)}),t=this.GetChildren(ye.ElementNames.X509SKI),t&&t.forEach(s=>{if(s.textContent){let i=br.FromBase64(s.textContent);this.AddSubjectKeyId(i)}}),t=this.GetChildren(ye.ElementNames.X509SubjectName),t?.forEach(s=>{s.textContent&&this.AddSubjectName(s.textContent)}),t=this.GetChildren(ye.ElementNames.X509Certificate),t&&t.forEach(s=>{if(s.textContent){let i=br.FromBase64(s.textContent);this.AddCertificate(new Y0(i))}});let n=this.GetChild(ye.ElementNames.X509CRL,!1);n&&n.textContent&&(this.x509crl=br.FromBase64(n.textContent))}AddCertificatesChainFrom(e,t){}};Q0=Xe([Ht({localName:ye.ElementNames.X509Data}),dt("design:paramtypes",[Object,Object])],Q0);var Wx=class extends vi{static{o(this,"SPKIData")}async importKey(e){let t=await bn.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 bn.crypto.subtle.importKey("spki",this.SPKIexp,e,!0,["verify"]);return this.Key=t,t}};Xe([Jt({localName:ye.ElementNames.SPKIexp,namespaceURI:ye.NamespaceURI,prefix:ye.DefaultPrefix,required:!0,converter:Ki}),dt("design:type",Object)],Wx.prototype,"SPKIexp",void 0);Wx=Xe([Ht({localName:ye.ElementNames.SPKIData})],Wx);var np=class extends Qi{static{o(this,"KeyInfo")}OnLoadXml(e){for(let t=0;t<e.childNodes.length;t++){let n=e.childNodes.item(t);if(n.nodeType!==qt.Element)continue;let s=null;switch(n.localName){case ye.ElementNames.KeyValue:s=Xx;break;case ye.ElementNames.X509Data:s=Q0;break;case ye.ElementNames.SPKIData:s=Wx;break;case ye.ElementNames.KeyName:case ye.ElementNames.RetrievalMethod:case ye.ElementNames.PGPData:case ye.ElementNames.MgmtData:}if(s){let i=new s;i.LoadXml(n),this.Add(i)}}}};Xe([Ur({localName:ye.AttributeNames.Id,defaultValue:""}),dt("design:type",String)],np.prototype,"Id",void 0);np=Xe([Ht({localName:ye.ElementNames.KeyInfo})],np);var Bl=class extends Wr{static{o(this,"Signature")}};Xe([Ur({localName:ye.AttributeNames.Id,defaultValue:""}),dt("design:type",String)],Bl.prototype,"Id",void 0);Xe([Jt({parser:Nu,required:!0}),dt("design:type",Nu)],Bl.prototype,"SignedInfo",void 0);Xe([Jt({localName:ye.ElementNames.SignatureValue,namespaceURI:ye.NamespaceURI,prefix:ye.DefaultPrefix,required:!0,converter:Ki,defaultValue:null}),dt("design:type",Object)],Bl.prototype,"SignatureValue",void 0);Xe([Jt({parser:np}),dt("design:type",np)],Bl.prototype,"KeyInfo",void 0);Xe([Jt({parser:$x,noRoot:!0}),dt("design:type",$x)],Bl.prototype,"ObjectList",void 0);Bl=Xe([Ht({localName:ye.ElementNames.Signature})],Bl);var W0e=class extends Map{static{o(this,"AlgorithmRegistry")}},gr=new W0e;gr.set(i2,{type:"signature",algorithm:k0});gr.set(a2,{type:"signature",algorithm:L0});gr.set(o2,{type:"signature",algorithm:V0});gr.set(u2,{type:"signature",algorithm:U0});gr.set(i2,{type:"signature",algorithm:k0});gr.set(a2,{type:"signature",algorithm:L0});gr.set(o2,{type:"signature",algorithm:V0});gr.set(u2,{type:"signature",algorithm:U0});gr.set(yO,{type:"signature",algorithm:l2});gr.set(ZC,{type:"signature",algorithm:D0});gr.set(e2,{type:"signature",algorithm:B0});gr.set(t2,{type:"signature",algorithm:R0});gr.set(r2,{type:"signature",algorithm:O0});gr.set(ZC.toUpperCase(),{type:"signature",algorithm:D0});gr.set(e2.toUpperCase(),{type:"signature",algorithm:B0});gr.set(t2.toUpperCase(),{type:"signature",algorithm:R0});gr.set(r2.toUpperCase(),{type:"signature",algorithm:O0});gr.set(hO,{type:"signature",algorithm:Mx});gr.set(pO,{type:"signature",algorithm:qx});gr.set(dO,{type:"signature",algorithm:Hx});gr.set(mO,{type:"signature",algorithm:Kx});gr.set(N0,{type:"hash",algorithm:JC});gr.set(T0,{type:"hash",algorithm:Fx});gr.set(I0,{type:"hash",algorithm:YC});gr.set(_0,{type:"hash",algorithm:QC});var sp=class{static{o(this,"AlgorithmFactory")}static createHashAlgorithmFromNamespace(e){for(let[t,{type:n,algorithm:s}]of gr)if(n==="hash"&&t===e)return new s;throw new $e(De.ALGORITHM_NOT_SUPPORTED,e)}static createSignatureAlgorithmFromMethod(e){for(let[t,{type:n,algorithm:s}]of gr)if(n==="signature"&&e.Algorithm===t){let i=new s;return i.fromMethod&&i.fromMethod(e),i}throw new $e(De.ALGORITHM_NOT_SUPPORTED,e.Algorithm)}static createHashAlgorithmFromAlgorithm(e){for(let[,{type:t,algorithm:n}]of gr)if(t==="hash"){let s=new n;if(s.algorithm.name.toUpperCase()===e.name.toUpperCase())return s}throw new $e(De.ALGORITHM_NOT_SUPPORTED,e.name)}static createSignatureAlgorithmFromAlgorithm(e){for(let[,{type:t,algorithm:n}]of gr)if(t==="signature"){let s=n.fromAlgorithm(e);if(s)return s}throw new $e(De.ALGORITHM_NOT_SUPPORTED,e.name)}};var z0e=class extends Map{static{o(this,"TransformRegistry")}},Tu=new z0e;Tu.set(ye.AlgorithmNamespaces.XmlDsigBase64Transform,Au);Tu.set(ye.AlgorithmNamespaces.XmlDsigC14NTransform,Eo);Tu.set(ye.AlgorithmNamespaces.XmlDsigC14NWithCommentsTransform,bo);Tu.set(ye.AlgorithmNamespaces.XmlDsigEnvelopedSignatureTransform,Cu);Tu.set(ye.AlgorithmNamespaces.XmlDsigExcC14NTransform,Ao);Tu.set(ye.AlgorithmNamespaces.XmlDsigExcC14NWithCommentsTransform,Co);var Gx=class{static{o(this,"CryptoConfig")}static CreateFromName(e){if(!e)throw new $e(De.PARAM_REQUIRED,"name");let t=Tu.get(e);if(t)return new t;let n;switch(e){case ye.AlgorithmNamespaces.XmlDsigBase64Transform:n=new Au;break;case ye.AlgorithmNamespaces.XmlDsigC14NTransform:n=new Eo;break;case ye.AlgorithmNamespaces.XmlDsigC14NWithCommentsTransform:n=new bo;break;case ye.AlgorithmNamespaces.XmlDsigEnvelopedSignatureTransform:n=new Cu;break;case ye.AlgorithmNamespaces.XmlDsigXPathTransform:throw new $e(De.ALGORITHM_NOT_SUPPORTED,e);case ye.AlgorithmNamespaces.XmlDsigXsltTransform:throw new $e(De.ALGORITHM_NOT_SUPPORTED,e);case ye.AlgorithmNamespaces.XmlDsigExcC14NTransform:n=new Ao;break;case ye.AlgorithmNamespaces.XmlDsigExcC14NWithCommentsTransform:n=new Co;break;case ye.AlgorithmNamespaces.XmlDecryptionTransform:throw new $e(De.ALGORITHM_NOT_SUPPORTED,e);default:throw new $e(De.ALGORITHM_NOT_SUPPORTED,e)}return n}static CreateSignatureAlgorithm(e){return sp.createSignatureAlgorithmFromMethod(e)}static CreateHashAlgorithm(e){return sp.createHashAlgorithmFromNamespace(e)}static GetHashAlgorithm(e){let t=typeof e=="string"?{name:e}:e;return sp.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}),sp.createSignatureAlgorithmFromAlgorithm(t)}static CreateSignatureMethod(e){let t=new So;return t.Algorithm=e.namespaceURI,e.toMethod&&e.toMethod(t),t}static RegisterSignatureAlgorithm(e,t){gr.set(e,{type:"signature",algorithm:t})}static RegisterHashAlgorithm(e,t){gr.set(e,{type:"hash",algorithm:t})}static RegisterKeyInfoClause(e,t){Dl.set(e,t)}static RegisterTransform(e,t){Tu.set(e,t)}};var d2=Hl(U_(),1);var fH={xmldec:{version:"1.0",encoding:"UTF-8",standalone:void 0}};var hH={explicitArray:!1,explicitRoot:!1,preserveChildrenOrder:!0};var Jke={[Cr.AC]:"America/Rio_Branco",[Cr.AL]:"America/Maceio",[Cr.AM]:"America/Manaus",[Cr.AP]:"America/Belem",[Cr.BA]:"America/Bahia",[Cr.CE]:"America/Fortaleza",[Cr.DF]:"America/Sao_Paulo",[Cr.ES]:"America/Sao_Paulo",[Cr.GO]:"America/Sao_Paulo",[Cr.MA]:"America/Fortaleza",[Cr.MG]:"America/Sao_Paulo",[Cr.MS]:"America/Campo_Grande",[Cr.MT]:"America/Cuiaba",[Cr.PA]:"America/Belem",[Cr.PB]:"America/Fortaleza",[Cr.PE]:"America/Recife",[Cr.PI]:"America/Fortaleza",[Cr.PR]:"America/Sao_Paulo",[Cr.RJ]:"America/Sao_Paulo",[Cr.RN]:"America/Fortaleza",[Cr.RO]:"America/Porto_Velho",[Cr.RR]:"America/Boa_Vista",[Cr.RS]:"America/Sao_Paulo",[Cr.SC]:"America/Sao_Paulo",[Cr.SE]:"America/Maceio",[Cr.SP]:"America/Sao_Paulo",[Cr.TO]:"America/Araguaina"};var pH=class{static{o(this,"Xml2JsToolkit")}xml2js;constructor(e=Q0e){this.xml2js=e,_9({XMLSerializer:d2.default.XMLSerializer,DOMParser:d2.default.DOMParser,DOMImplementation:d2.default.DOMImplementation})}async validate(e,t){if(!e||e.trim().length===0)return Es(new sn("Please provide a valid xml content"));if(!t||t.trim().length===0)return Es(new sn("Please provide a valid existing xsd path"));try{return await tM.validate(e,t),Ii()}catch(n){return Zl(n)}}parse(e,t){return new Promise((n,s)=>new this.xml2js.Parser({...hH,...t}).parseString(e,(i,a)=>i?s(i):n(a)))}build(e,t){return Promise.resolve(new this.xml2js.Builder({...fH,...t}).buildObject(e))}digest(e,t,n=yg){return this.hash(this.canonicalize(e,n),t)}canonicalize(e,t=yg){let n=Hi(this.clear(e));return new wo(t.includeComments,t.exclusive).Canonicalize(n)}getNode(e,t){let s=Hi(e).documentElement.getElementsByTagName(t).item(0);return s?this.clear(lo(s)):null}getFirstNode(e){let n=Hi(e).documentElement.firstChild;return n?this.clear(lo(n)):null}getAttribute(e,t){return Hi(e).documentElement.getAttribute(t)}appendNode(e,t){let n=Hi(e),{documentElement:s}=Hi(t);return n.documentElement.appendChild(s),this.clear(lo(n))}hash(e,t){return Y0e.createHash(t).update(e,"utf8").digest().toString("base64")}clear(e){return['xmlns:default="http://www.w3.org/2000/09/xmldsig#"',' standalone="no"',"default:",":default",`
|
|
117
117
|
`,"\r"," "].reduce((n,s)=>n.replace(s,""),e.replace(/(>)\s*(<)/gm,"$1$2"))}};import{registerDecorator as Z0e}from"class-validator";var dH=o(r=>(e,t)=>{Z0e({name:"isDecimal",target:e.constructor,propertyName:t,options:r,validator:{validate(n){return n instanceof Ap?!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 mH}from"class-validator";var Z0=Symbol("choice"),eg=o(r=>r==null||r==="","isEmpty"),L4e=o(r=>e=>{let{properties:t,required:n=!1,...s}=r,i=Reflect.getMetadata(Z0,e)??[],a={properties:t,required:n};i.push(a),Reflect.defineMetadata(Z0,i,e);for(let u of t)mH({name:"choice",target:e,propertyName:u,options:s,validator:{validate(c,l){let h=l.object,m=l.property,g=Reflect.getMetadata(Z0,e);if(!g)return!0;let y=g.find(v=>v.properties.includes(m));if(!y||eg(c))return!0;for(let v of y.properties){if(v===m)continue;let S=h[v];if(!eg(S))return!1}for(let v of g)if(v!==y)for(let S of v.properties){let w=h[S];if(!eg(w))return!1}return!0},defaultMessage(c){let l=Reflect.getMetadata(Z0,e);if(!l)return`${c.property} validation error`;let h=l.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 y=m[g];if(!eg(y)&&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 l)if(g!==h)for(let y of g.properties){let v=m[y];if(!eg(v))return`${c.property} cannot be set because ${y} from a different choice group is already set.`}return`${c.property} validation error`}}});if(n)for(let u of t)mH({name:"choiceGroupRequired",target:e,propertyName:u,options:{...s,always:!0},validator:{validate(c,l){let h=l.object,m=Reflect.getMetadata(Z0,e);if(!m)return!0;let g=m.find(y=>y.properties.includes(l.property));if(!g?.required)return!0;for(let y of g.properties){let v=h[y];if(!eg(v))return!0}return l.property!==g.properties[0]},defaultMessage(c){let l=Reflect.getMetadata(Z0,e);if(!l)return"At least one property from a choice group must be provided";let h=l.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 ege}from"class-transformer";var H4e=o(({fixed:r,...e}={fixed:2})=>(t,n)=>{dH(e)(t,n),ege(({value:s})=>Ap.newOrUndefined(s)?.toFixed(r))(t,n)},"TransformDecimal");import{Transform as nge}from"class-transformer";import{IsDateString as sge}from"class-validator";import wO from"dayjs";import tge from"dayjs/plugin/utc.js";import rge from"dayjs/plugin/timezone.js";wO.extend(tge);wO.extend(rge);var gH=wO;var Z4e=o((r={})=>(e,t)=>{nge(({value:n})=>{let s=n instanceof Date?n.toISOString():n;return s?gH(s).tz("America/Sao_Paulo").format(r.format):void 0})(e,t),sge()(e,t)},"TransformDateString");var vH=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,w)=>v+S*a[w],0)%11,l=c===0||c===1?0:11-c,h=[5,4,3,2,9,8,7,6,5,4,3,2],g=[...n,l].reduce((v,S,w)=>v+S*h[w],0)%11,y=g===0||g===1?0:11-g;return s===l&&i===y}};var yH=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 xH=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 wH=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 SH=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 y=g%s,v=s-y;return(s===11&&y<=1||s===10&&y===0)&&(v=0),v===n[t.length-2]&&c===n[t.length-1]}};var EH=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 bH=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]),l=0;for(let m=11,g=0;m>=0;m--,g=(g+1)%i.length)l+=c[m]*i[g];let h=11-l%11;return(h===10||h===11)&&(h=0),u===s[0]&&h===s[1]}};var AH=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 CH=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 NH=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 TH=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 y=0;y<12;y++){let v=y%2===0?1:2,S=(parseInt(s[y])*v).toString();i+=S.split("").reduce((w,C)=>w+parseInt(C),0)}let u=Math.ceil(i/10)*10-i,c=n+u.toString(),l=[3,2,11,10,9,8,7,6,5,4,3,2],h=0;for(let y=0;y<12;y++)h+=parseInt(c[y])*l[y];let m=h%11,g=m<2?0:11-m;return parseInt(t[11])===u&&parseInt(t[12])===g}};var IH=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 _H=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 DH=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 BH=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 RH=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 y=0;y<7;y++)i+=n[y]*s[y];let a=i%11,u=a===0||a===1?0:11-a,c=[...n,u],l=[9,8,7,6,5,4,3,2],h=0;for(let y=0;y<8;y++)h+=c[y]*l[y];let m=h%11,g=m===0||m===1?0:11-m;return u===parseInt(t[7])&&g===parseInt(t[8])}};var OH=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 PH=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],l=0;for(let m=0;m<9;m++)l+=c[m]*i[m];let h=11-l%11;return h>=10&&(h=0),u===parseInt(t[8])&&h===parseInt(t[9])}};var kH=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 LH=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 l=0;l<n.length;l++)i+=s[l]*n[l];let u=i*10%11;return(u===10?0:u)===parseInt(t[t.length-1])}};var VH=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 UH=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 jH=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 FH=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 MH=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 qH=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 l=c%11%10;return a===n[8]&&l===n[11]}};var HH=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 l=0;l<i.length;l++)a+=s[l]*i[l];let u=a%11;return(u<2?0:11-u)===parseInt(t[10])}};var Cd=class{static{o(this,"ASN1")}extractCertificateInfo(e){let n=e.subject.split(`
|
|
118
|
-
`).reduce((i,a)=>{let[u,c]=a.split("=").map(l=>l.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"),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 l=Buffer.concat([c,n,i[1]]),h=this.length(l),m=n.length,g=l.subarray(2+m,2+m+h),y=g.length-c.length-2;if(y<=0||y>g.length)return;let S=g.subarray(-y).toString("utf8");return S.substring(Buffer.from(S).findIndex((w,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 $H=class{static{o(this,"NativeCertificateRepository")}httpClient;signer;cache;constructor(e,t,n=new Ww){this.httpClient=e,this.signer=t,this.cache=n}async read(e){try{let{password:t}=e,n=await this.getPfxBuffer(e);if(n.isLeft())return n;let s=Rl.default.asn1.fromDer(n.value.toString("binary")),i=Rl.default.pkcs12.pkcs12FromAsn1(s,t),{certBag:a}=Rl.default.pki.oids,c=i.getBags({bagType:a})[a];if(!c?.length)return Es(new sn("Cannot read certificate"));let[{cert:l},...h]=c;if(!l)return Es(new sn("Issuer Certificate not found"));let m=h.reduce((y,{cert:v})=>(v&&y.push(new m2.X509Certificate(Rl.default.pki.certificateToPem(v))),y),[]),g=new m2.X509Certificate(Rl.default.pki.certificateToPem(l));return Ii({ca:m,password:t,certificate:g,privateKey:this.getPrivateKey(i)})}catch(t){return Zl(t)}}getPrivateKey(e){let{pkcs8ShroudedKeyBag:t}=Rl.default.pki.oids,s=e.getBags({bagType:t})[t]?.[0]?.key;if(s)return m2.createPrivateKey(Rl.default.pki.privateKeyToPem(s))}async sign(e,t,n=Uu.SHA1){return this.signer.sign(e,t,n)}getCertificateInfo(e){return new Cd().extractCertificateInfo(e)}getStringCertificate(e){return e.raw.toString("base64")}getStringPrivateKey(e){try{return e.export({type:"pkcs8",format:"pem"})}catch{throw new sn("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 Ii(i);if(ige.isAbsolute(t)||KH.existsSync(t))return this.hitBufferOnCache(s,KH.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 Zl(a)}return this.hitBufferOnCache(s,Buffer.from(t,"base64"))}getCacheKey(e,t){return m2.createHash("sha256").update(`${e}.${t}`).digest("hex")}async hitBufferOnCache(e,t){return await this.cache.set(e,t),Ii(t)}isValidRemoteUrl(e){try{return new URL(e),!0}catch{return!1}}};export{BN as a,G3 as b,RN as c,Uu as d,ON as e,Cr as f,oge as g,cge as h,
|
|
118
|
+
`).reduce((i,a)=>{let[u,c]=a.split("=").map(l=>l.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"),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 l=Buffer.concat([c,n,i[1]]),h=this.length(l),m=n.length,g=l.subarray(2+m,2+m+h),y=g.length-c.length-2;if(y<=0||y>g.length)return;let S=g.subarray(-y).toString("utf8");return S.substring(Buffer.from(S).findIndex((w,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 $H=class{static{o(this,"NativeCertificateRepository")}httpClient;signer;cache;constructor(e,t,n=new Ww){this.httpClient=e,this.signer=t,this.cache=n}async read(e){try{let{password:t}=e,n=await this.getPfxBuffer(e);if(n.isLeft())return n;let s=Rl.default.asn1.fromDer(n.value.toString("binary")),i=Rl.default.pkcs12.pkcs12FromAsn1(s,t),{certBag:a}=Rl.default.pki.oids,c=i.getBags({bagType:a})[a];if(!c?.length)return Es(new sn("Cannot read certificate"));let[{cert:l},...h]=c;if(!l)return Es(new sn("Issuer Certificate not found"));let m=h.reduce((y,{cert:v})=>(v&&y.push(new m2.X509Certificate(Rl.default.pki.certificateToPem(v))),y),[]),g=new m2.X509Certificate(Rl.default.pki.certificateToPem(l));return Ii({ca:m,password:t,certificate:g,privateKey:this.getPrivateKey(i)})}catch(t){return Zl(t)}}getPrivateKey(e){let{pkcs8ShroudedKeyBag:t}=Rl.default.pki.oids,s=e.getBags({bagType:t})[t]?.[0]?.key;if(s)return m2.createPrivateKey(Rl.default.pki.privateKeyToPem(s))}async sign(e,t,n=Uu.SHA1){return this.signer.sign(e,t,n)}getCertificateInfo(e){return new Cd().extractCertificateInfo(e)}getStringCertificate(e){return e.raw.toString("base64")}getStringPrivateKey(e){try{return e.export({type:"pkcs8",format:"pem"})}catch{throw new sn("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 Ii(i);if(ige.isAbsolute(t)||KH.existsSync(t))return this.hitBufferOnCache(s,KH.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 Zl(a)}return this.hitBufferOnCache(s,Buffer.from(t,"base64"))}getCacheKey(e,t){return m2.createHash("sha256").update(`${e}.${t}`).digest("hex")}async hitBufferOnCache(e,t){return await this.cache.set(e,t),Ii(t)}isValidRemoteUrl(e){try{return new URL(e),!0}catch{return!1}}};export{BN as a,G3 as b,RN as c,Uu as d,ON as e,Cr as f,oge as g,cge as h,Jke as i,sn as j,X3 as k,PN as l,wp as m,Es as n,Ii as o,W3 as p,z3 as q,xg as r,Uge as s,jge as t,jw as u,J3 as v,Y3 as w,Q3 as x,zge as y,Ap as z,pk as A,Zl as B,Ww as C,$H as D,sb as E,QF as F,ZF as G,pH as H,dH as I,L4e as J,H4e as K,gH as L,Z4e as M,vH as N,yH as O,xH as P,wH as Q,SH as R,EH as S,bH as T,AH as U,CH as V,NH as W,TH as X,IH as Y,_H as Z,DH as _,BH as $,RH as aa,OH as ba,PH as ca,kH as da,LH as ea,VH as fa,UH as ga,jH as ha,FH as ia,MH as ja,qH as ka,HH as la,Cd as ma};
|
|
119
119
|
/*! Bundled license information:
|
|
120
120
|
|
|
121
121
|
lodash/lodash.js:
|
package/dist/core/index.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { createRequire } from 'module'; const require = createRequire(import.meta.url);
|
|
2
|
-
import"../chunk-23RWB4QQ.mjs";import{$ as
|
|
2
|
+
import"../chunk-23RWB4QQ.mjs";import{$ as T,A as w,C as x,D as y,G as z,H as A,I as B,J as C,K as D,M as E,N as F,O as G,P as H,Q as I,R as J,S as K,T as L,U as M,V as N,W as O,X as P,Y as Q,Z as R,_ as S,a,aa as U,b,ba as V,c,ca as W,d,da as X,e,ea as Y,f,fa as Z,g,ga as _,h,ha as $,ia as aa,j as i,ja as ba,k as j,ka as ca,la as da,m as k,ma as ea,p as l,q as m,r as n,s as o,t as p,u as q,v as r,w as s,x as t,y as u,z as v}from"../chunk-Q47VIRPG.mjs";import"../chunk-W6MRGYXP.mjs";export{ea as ASN1,b as CanonicalizationMethod,C as Choice,v as Decimal,e as DigestAlgorithm,l as EntitySigner,h as Environment,B as IsDecimal,w as MemoryCacheAdapter,i as NFeTsError,y as NativeCertificateRepository,x as NullCacheAdapter,d as SignatureAlgorithm,c as SignatureMethod,a as SignatureNamespace,k as Signer,p as SkipAllValidations,o as SkipValidation,n as SkipValidationMetadata,z as SoapRemoteTransmissionRepository,g as StateAcronyms,F as StateCodeAcValidator,G as StateCodeAlValidator,H as StateCodeAmValidator,I as StateCodeApValidator,J as StateCodeBaValidator,K as StateCodeCeValidator,L as StateCodeDfValidator,M as StateCodeEsValidator,N as StateCodeGoValidator,O as StateCodeMaValidator,P as StateCodeMgValidator,Q as StateCodeMsValidator,R as StateCodeMtValidator,S as StateCodePaValidator,T as StateCodePbValidator,U as StateCodePeValidator,V as StateCodePiValidator,W as StateCodePrValidator,X as StateCodeRjValidator,Y as StateCodeRnValidator,Z as StateCodeRoValidator,_ as StateCodeRrValidator,$ as StateCodeRsValidator,aa as StateCodeScValidator,ba as StateCodeSeValidator,ca as StateCodeSpValidator,da as StateCodeToValidator,f as StateCodes,E as TransformDateString,D as TransformDecimal,s as ValidateErrorsMetadata,u as Validates,j as ValidationError,A as Xml2JsToolkit,m as XmlSigner,q as clearEmptyValues,t as mapConstraintsToErrors,r as plainToInstance};
|