node-sped-nfe 1.1.4 → 1.1.5
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/utils/eventos.js +140 -12
- package/dist/utils/tools.d.ts +1 -0
- package/dist/utils/tools.js +33 -36
- package/package.json +1 -1
package/dist/utils/eventos.js
CHANGED
@@ -673,53 +673,181 @@ const urlEventos400 = {
|
|
673
673
|
"cUF": "32"
|
674
674
|
},
|
675
675
|
"DF": {
|
676
|
+
"mod55": {
|
677
|
+
"producao": {
|
678
|
+
"NFeStatusServico": "https://nfe.svrs.rs.gov.br/ws/NfeStatusServico/NfeStatusServico4.asmx",
|
679
|
+
"NFeAutorizacao": "https://nfe.svrs.rs.gov.br/ws/NfeAutorizacao/NFeAutorizacao4.asmx",
|
680
|
+
"NFeRetAutorizacao": "https://nfe.svrs.rs.gov.br/ws/NfeRetAutorizacao/NFeRetAutorizacao4.asmx",
|
681
|
+
"NFeInutilizacao": "https://nfe.svrs.rs.gov.br/ws/nfeinutilizacao/nfeinutilizacao4.asmx",
|
682
|
+
"NFeConsultaProtocolo": "https://nfe.svrs.rs.gov.br/ws/NfeConsulta/NfeConsulta4.asmx",
|
683
|
+
"RecepcaoEvento": "https://nfe.svrs.rs.gov.br/ws/recepcaoevento/recepcaoevento4.asmx",
|
684
|
+
"NFeConsultaCadastro": "https://cad.svrs.rs.gov.br/ws/cadconsultacadastro/cadconsultacadastro4.asmx"
|
685
|
+
},
|
686
|
+
"homologacao": {
|
687
|
+
"NFeStatusServico": "https://nfe-homologacao.svrs.rs.gov.br/ws/NfeStatusServico/NfeStatusServico4.asmx",
|
688
|
+
"NFeAutorizacao": "https://nfe-homologacao.svrs.rs.gov.br/ws/NfeAutorizacao/NFeAutorizacao4.asmx",
|
689
|
+
"NFeRetAutorizacao": "https://nfe-homologacao.svrs.rs.gov.br/ws/NfeRetAutorizacao/NFeRetAutorizacao4.asmx",
|
690
|
+
"NFeInutilizacao": "https://nfe-homologacao.svrs.rs.gov.br/ws/nfeinutilizacao/nfeinutilizacao4.asmx",
|
691
|
+
"NFeConsultaProtocolo": "https://nfe-homologacao.svrs.rs.gov.br/ws/NfeConsulta/NfeConsulta4.asmx",
|
692
|
+
"RecepcaoEvento": "https://nfe-homologacao.svrs.rs.gov.br/ws/recepcaoevento/recepcaoevento4.asmx",
|
693
|
+
"NFeConsultaCadastro": "https://cad-homologacao.svrs.rs.gov.br/ws/cadconsultacadastro/cadconsultacadastro4.asmx"
|
694
|
+
}
|
695
|
+
},
|
676
696
|
"mod65": {
|
677
697
|
"producao": {
|
698
|
+
"NFeStatusServico": "https://nfce.svrs.rs.gov.br/ws/NfeStatusServico/NfeStatusServico2.asmx",
|
699
|
+
"NFeAutorizacao": "https://nfce.svrs.rs.gov.br/ws/NfeAutorizacao/NFeAutorizacao.asmx",
|
700
|
+
"NFeRetAutorizacao": "https://nfce.svrs.rs.gov.br/ws/NfeRetAutorizacao/NFeRetAutorizacao.asmx",
|
701
|
+
"NFeInutilizacao": "https://nfce.svrs.rs.gov.br/ws/nfeinutilizacao/nfeinutilizacao2.asmx",
|
702
|
+
"NFeConsultaProtocolo": "https://nfce.svrs.rs.gov.br/ws/NfeConsulta/NfeConsulta2.asmx",
|
703
|
+
"RecepcaoEvento": "https://nfce.svrs.rs.gov.br/ws/recepcaoevento/recepcaoevento.asmx",
|
678
704
|
"NFeConsultaQR": "http://www.fazenda.df.gov.br/nfce/qrcode",
|
679
|
-
"urlChave": "www.fazenda.df.gov.br/nfce/consulta"
|
705
|
+
"urlChave": "http://www.fazenda.df.gov.br/nfce/consulta"
|
680
706
|
},
|
681
707
|
"homologacao": {
|
682
|
-
"
|
683
|
-
"
|
708
|
+
"NFeStatusServico": "https://nfce-homologacao.svrs.rs.gov.br/ws/NfeStatusServico/NfeStatusServico2.asmx",
|
709
|
+
"NFeAutorizacao": "https://nfce-homologacao.svrs.rs.gov.br/ws/NfeAutorizacao/NFeAutorizacao.asmx",
|
710
|
+
"NFeRetAutorizacao": "https://nfce-homologacao.svrs.rs.gov.br/ws/NfeRetAutorizacao/NFeRetAutorizacao.asmx",
|
711
|
+
"NFeInutilizacao": "https://nfce-homologacao.svrs.rs.gov.br/ws/nfeinutilizacao/nfeinutilizacao2.asmx",
|
712
|
+
"NFeConsultaProtocolo": "https://nfce-homologacao.svrs.rs.gov.br/ws/NfeConsulta/NfeConsulta2.asmx",
|
713
|
+
"RecepcaoEvento": "https://nfce-homologacao.svrs.rs.gov.br/ws/recepcaoevento/recepcaoevento.asmx",
|
714
|
+
"NFeConsultaQR": "http://www.fazenda.df.gov.br/nfce/qrcode",
|
715
|
+
"urlChave": "http://www.fazenda.df.gov.br/nfce/consulta"
|
684
716
|
}
|
685
717
|
},
|
686
718
|
"cUF": "53"
|
687
719
|
},
|
688
720
|
"MA": {
|
721
|
+
"mod55": {
|
722
|
+
"producao": {
|
723
|
+
"NFeStatusServico": "https://www.sefazvirtual.fazenda.gov.br/NFeStatusServico4/NFeStatusServico4.asmx",
|
724
|
+
"NFeAutorizacao": "https://www.sefazvirtual.fazenda.gov.br/NFeAutorizacao4/NFeAutorizacao4.asmx",
|
725
|
+
"NFeRetAutorizacao": "https://www.sefazvirtual.fazenda.gov.br/NFeRetAutorizacao4/NFeRetAutorizacao4.asmx",
|
726
|
+
"NFeInutilizacao": "https://www.sefazvirtual.fazenda.gov.br/NFeInutilizacao4/NFeInutilizacao4.asmx",
|
727
|
+
"NFeConsultaProtocolo": "https://www.sefazvirtual.fazenda.gov.br/NFeConsultaProtocolo4/NFeConsultaProtocolo4.asmx",
|
728
|
+
"RecepcaoEvento": "https://www.sefazvirtual.fazenda.gov.br/NFeRecepcaoEvento4/NFeRecepcaoEvento4.asmx",
|
729
|
+
"NFeConsultaCadastro": "https://www.sefazvirtual.fazenda.gov.br/CadConsultaCadastro4/CadConsultaCadastro4.asmx"
|
730
|
+
},
|
731
|
+
"homologacao": {
|
732
|
+
"NFeStatusServico": "https://hom.nfe.fazenda.gov.br/NFeStatusServico4/NFeStatusServico4.asmx",
|
733
|
+
"NFeAutorizacao": "https://hom.nfe.fazenda.gov.br/NFeAutorizacao4/NFeAutorizacao4.asmx",
|
734
|
+
"NFeRetAutorizacao": "https://hom.nfe.fazenda.gov.br/NFeRetAutorizacao4/NFeRetAutorizacao4.asmx",
|
735
|
+
"NFeInutilizacao": "https://hom.nfe.fazenda.gov.br/NFeInutilizacao4/NFeInutilizacao4.asmx",
|
736
|
+
"NFeConsultaProtocolo": "https://hom.nfe.fazenda.gov.br/NFeConsultaProtocolo4/NFeConsultaProtocolo4.asmx",
|
737
|
+
"RecepcaoEvento": "https://hom.nfe.fazenda.gov.br/NFeRecepcaoEvento4/NFeRecepcaoEvento4.asmx",
|
738
|
+
"NFeConsultaCadastro": "https://hom.nfe.fazenda.gov.br/CadConsultaCadastro4/CadConsultaCadastro4.asmx"
|
739
|
+
}
|
740
|
+
},
|
689
741
|
"mod65": {
|
690
742
|
"producao": {
|
743
|
+
"NFeStatusServico": "https://nfce.svrs.rs.gov.br/ws/NfeStatusServico/NfeStatusServico2.asmx",
|
744
|
+
"NFeAutorizacao": "https://nfce.svrs.rs.gov.br/ws/NfeAutorizacao/NFeAutorizacao.asmx",
|
745
|
+
"NFeRetAutorizacao": "https://nfce.svrs.rs.gov.br/ws/NfeRetAutorizacao/NFeRetAutorizacao.asmx",
|
746
|
+
"NFeInutilizacao": "https://nfce.svrs.rs.gov.br/ws/nfeinutilizacao/nfeinutilizacao2.asmx",
|
747
|
+
"NFeConsultaProtocolo": "https://nfce.svrs.rs.gov.br/ws/NfeConsulta/NfeConsulta2.asmx",
|
748
|
+
"RecepcaoEvento": "https://nfce.svrs.rs.gov.br/ws/recepcaoevento/recepcaoevento.asmx",
|
691
749
|
"NFeConsultaQR": "http://www.nfce.sefaz.ma.gov.br/portal/consultarNFCe.jsp",
|
692
|
-
"urlChave": "www.sefaz.ma.gov.br/
|
750
|
+
"urlChave": "http://www.nfce.sefaz.ma.gov.br/portal/consultarNFCe.jsp"
|
693
751
|
},
|
694
752
|
"homologacao": {
|
753
|
+
"NFeStatusServico": "https://nfce-homologacao.svrs.rs.gov.br/ws/NfeStatusServico/NfeStatusServico2.asmx",
|
754
|
+
"NFeAutorizacao": "https://nfce-homologacao.svrs.rs.gov.br/ws/NfeAutorizacao/NFeAutorizacao.asmx",
|
755
|
+
"NFeRetAutorizacao": "https://nfce-homologacao.svrs.rs.gov.br/ws/NfeRetAutorizacao/NFeRetAutorizacao.asmx",
|
756
|
+
"NFeInutilizacao": "https://nfce-homologacao.svrs.rs.gov.br/ws/nfeinutilizacao/nfeinutilizacao2.asmx",
|
757
|
+
"NFeConsultaProtocolo": "https://nfce-homologacao.svrs.rs.gov.br/ws/NfeConsulta/NfeConsulta2.asmx",
|
758
|
+
"RecepcaoEvento": "https://nfce-homologacao.svrs.rs.gov.br/ws/recepcaoevento/recepcaoevento.asmx",
|
695
759
|
"NFeConsultaQR": "http://www.hom.nfce.sefaz.ma.gov.br/portal/consultarNFCe.jsp",
|
696
|
-
"urlChave": "www.sefaz.ma.gov.br/
|
760
|
+
"urlChave": "http://www.hom.nfce.sefaz.ma.gov.br/portal/consultarNFCe.jsp"
|
697
761
|
}
|
698
762
|
},
|
699
763
|
"cUF": "21"
|
700
764
|
},
|
701
765
|
"PA": {
|
766
|
+
"mod55": {
|
767
|
+
"producao": {
|
768
|
+
"NFeStatusServico": "https://nfe.svrs.rs.gov.br/ws/NfeStatusServico/NfeStatusServico4.asmx",
|
769
|
+
"NFeAutorizacao": "https://nfe.svrs.rs.gov.br/ws/NfeAutorizacao/NFeAutorizacao4.asmx",
|
770
|
+
"NFeRetAutorizacao": "https://nfe.svrs.rs.gov.br/ws/NfeRetAutorizacao/NFeRetAutorizacao4.asmx",
|
771
|
+
"NFeInutilizacao": "https://nfe.svrs.rs.gov.br/ws/nfeinutilizacao/nfeinutilizacao4.asmx",
|
772
|
+
"NFeConsultaProtocolo": "https://nfe.svrs.rs.gov.br/ws/NfeConsulta/NfeConsulta4.asmx",
|
773
|
+
"RecepcaoEvento": "https://nfe.svrs.rs.gov.br/ws/recepcaoevento/recepcaoevento4.asmx",
|
774
|
+
"NFeConsultaCadastro": "https://cad.svrs.rs.gov.br/ws/cadconsultacadastro/cadconsultacadastro4.asmx"
|
775
|
+
},
|
776
|
+
"homologacao": {
|
777
|
+
"NFeStatusServico": "https://nfe-homologacao.svrs.rs.gov.br/ws/NfeStatusServico/NfeStatusServico4.asmx",
|
778
|
+
"NFeAutorizacao": "https://nfe-homologacao.svrs.rs.gov.br/ws/NfeAutorizacao/NFeAutorizacao4.asmx",
|
779
|
+
"NFeRetAutorizacao": "https://nfe-homologacao.svrs.rs.gov.br/ws/NfeRetAutorizacao/NFeRetAutorizacao4.asmx",
|
780
|
+
"NFeInutilizacao": "https://nfe-homologacao.svrs.rs.gov.br/ws/nfeinutilizacao/nfeinutilizacao4.asmx",
|
781
|
+
"NFeConsultaProtocolo": "https://nfe-homologacao.svrs.rs.gov.br/ws/NfeConsulta/NfeConsulta4.asmx",
|
782
|
+
"RecepcaoEvento": "https://nfe-homologacao.svrs.rs.gov.br/ws/recepcaoevento/recepcaoevento4.asmx",
|
783
|
+
"NFeConsultaCadastro": "https://cad-homologacao.svrs.rs.gov.br/ws/cadconsultacadastro/cadconsultacadastro4.asmx"
|
784
|
+
}
|
785
|
+
},
|
702
786
|
"mod65": {
|
703
787
|
"producao": {
|
704
|
-
"
|
705
|
-
"
|
788
|
+
"NFeStatusServico": "https://nfce.svrs.rs.gov.br/ws/NfeStatusServico/NfeStatusServico2.asmx",
|
789
|
+
"NFeAutorizacao": "https://nfce.svrs.rs.gov.br/ws/NfeAutorizacao/NFeAutorizacao.asmx",
|
790
|
+
"NFeRetAutorizacao": "https://nfce.svrs.rs.gov.br/ws/NfeRetAutorizacao/NFeRetAutorizacao.asmx",
|
791
|
+
"NFeInutilizacao": "https://nfce.svrs.rs.gov.br/ws/nfeinutilizacao/nfeinutilizacao2.asmx",
|
792
|
+
"NFeConsultaProtocolo": "https://nfce.svrs.rs.gov.br/ws/NfeConsulta/NfeConsulta2.asmx",
|
793
|
+
"RecepcaoEvento": "https://nfce.svrs.rs.gov.br/ws/recepcaoevento/recepcaoevento.asmx",
|
794
|
+
"NFeConsultaQR": "https://appnfc.sefa.pa.gov.br/portal/view/consultas/nfce/consultanfce.seam",
|
795
|
+
"urlChave": "https://appnfc.sefa.pa.gov.br/portal/view/consultas/nfce/consultanfce.seam"
|
706
796
|
},
|
707
797
|
"homologacao": {
|
708
|
-
"
|
709
|
-
"
|
798
|
+
"NFeStatusServico": "https://nfce-homologacao.svrs.rs.gov.br/ws/NfeStatusServico/NfeStatusServico2.asmx",
|
799
|
+
"NFeAutorizacao": "https://nfce-homologacao.svrs.rs.gov.br/ws/NfeAutorizacao/NFeAutorizacao.asmx",
|
800
|
+
"NFeRetAutorizacao": "https://nfce-homologacao.svrs.rs.gov.br/ws/NfeRetAutorizacao/NFeRetAutorizacao.asmx",
|
801
|
+
"NFeInutilizacao": "https://nfce-homologacao.svrs.rs.gov.br/ws/nfeinutilizacao/nfeinutilizacao2.asmx",
|
802
|
+
"NFeConsultaProtocolo": "https://nfce-homologacao.svrs.rs.gov.br/ws/NfeConsulta/NfeConsulta2.asmx",
|
803
|
+
"RecepcaoEvento": "https://nfce-homologacao.svrs.rs.gov.br/ws/recepcaoevento/recepcaoevento.asmx",
|
804
|
+
"NFeConsultaQR": "https://appnfc.sefa.pa.gov.br/portal/view/consultas/nfce/consultanfce.seam",
|
805
|
+
"urlChave": "https://appnfc.sefa.pa.gov.br/portal/view/consultas/nfce/consultanfce.seam"
|
710
806
|
}
|
711
807
|
},
|
712
808
|
"cUF": "15"
|
713
809
|
},
|
714
810
|
"PB": {
|
811
|
+
"mod55": {
|
812
|
+
"producao": {
|
813
|
+
"NFeStatusServico": "https://nfe.svrs.rs.gov.br/ws/NfeStatusServico/NfeStatusServico4.asmx",
|
814
|
+
"NFeAutorizacao": "https://nfe.svrs.rs.gov.br/ws/NfeAutorizacao/NFeAutorizacao4.asmx",
|
815
|
+
"NFeRetAutorizacao": "https://nfe.svrs.rs.gov.br/ws/NfeRetAutorizacao/NFeRetAutorizacao4.asmx",
|
816
|
+
"NFeInutilizacao": "https://nfe.svrs.rs.gov.br/ws/nfeinutilizacao/nfeinutilizacao4.asmx",
|
817
|
+
"NFeConsultaProtocolo": "https://nfe.svrs.rs.gov.br/ws/NfeConsulta/NfeConsulta4.asmx",
|
818
|
+
"RecepcaoEvento": "https://nfe.svrs.rs.gov.br/ws/recepcaoevento/recepcaoevento4.asmx",
|
819
|
+
"NFeConsultaCadastro": "https://cad.svrs.rs.gov.br/ws/cadconsultacadastro/cadconsultacadastro4.asmx"
|
820
|
+
},
|
821
|
+
"homologacao": {
|
822
|
+
"NFeStatusServico": "https://nfe-homologacao.svrs.rs.gov.br/ws/NfeStatusServico/NfeStatusServico4.asmx",
|
823
|
+
"NFeAutorizacao": "https://nfe-homologacao.svrs.rs.gov.br/ws/NfeAutorizacao/NfeAutorizacao4.asmx",
|
824
|
+
"NFeRetAutorizacao": "https://nfe-homologacao.svrs.rs.gov.br/ws/NfeRetAutorizacao/NfeRetAutorizacao4.asmx",
|
825
|
+
"NFeInutilizacao": "https://nfe-homologacao.svrs.rs.gov.br/ws/nfeinutilizacao/nfeinutilizacao4.asmx",
|
826
|
+
"NFeConsultaProtocolo": "https://nfe-homologacao.svrs.rs.gov.br/ws/NfeConsulta/NfeConsulta4.asmx",
|
827
|
+
"RecepcaoEvento": "https://nfe-homologacao.svrs.rs.gov.br/ws/recepcaoevento/recepcaoevento4.asmx",
|
828
|
+
"NFeConsultaCadastro": "https://cad-homologacao.svrs.rs.gov.br/ws/cadconsultacadastro/cadconsultacadastro4.asmx"
|
829
|
+
}
|
830
|
+
},
|
715
831
|
"mod65": {
|
716
832
|
"producao": {
|
833
|
+
"NFeStatusServico": "https://nfce.svrs.rs.gov.br/ws/NfeStatusServico/NfeStatusServico2.asmx",
|
834
|
+
"NFeAutorizacao": "https://nfce.svrs.rs.gov.br/ws/NfeAutorizacao/NFeAutorizacao.asmx",
|
835
|
+
"NFeRetAutorizacao": "https://nfce.svrs.rs.gov.br/ws/NfeRetAutorizacao/NFeRetAutorizacao.asmx",
|
836
|
+
"NFeInutilizacao": "https://nfce.svrs.rs.gov.br/ws/nfeinutilizacao/nfeinutilizacao2.asmx",
|
837
|
+
"NFeConsultaProtocolo": "https://nfce.svrs.rs.gov.br/ws/NfeConsulta/NfeConsulta2.asmx",
|
838
|
+
"RecepcaoEvento": "https://nfce.svrs.rs.gov.br/ws/recepcaoevento/recepcaoevento.asmx",
|
717
839
|
"NFeConsultaQR": "http://www.sefaz.pb.gov.br/nfce",
|
718
|
-
"urlChave": "www.
|
840
|
+
"urlChave": "http://www.sefaz.pb.gov.br/nfce"
|
719
841
|
},
|
720
842
|
"homologacao": {
|
721
|
-
"
|
722
|
-
"
|
843
|
+
"NFeStatusServico": "https://nfce-homologacao.svrs.rs.gov.br/ws/NfeStatusServico/NfeStatusServico2.asmx",
|
844
|
+
"NFeAutorizacao": "https://nfce-homologacao.svrs.rs.gov.br/ws/NfeAutorizacao/NFeAutorizacao.asmx",
|
845
|
+
"NFeRetAutorizacao": "https://nfce-homologacao.svrs.rs.gov.br/ws/NfeRetAutorizacao/NFeRetAutorizacao.asmx",
|
846
|
+
"NFeInutilizacao": "https://nfce-homologacao.svrs.rs.gov.br/ws/nfeinutilizacao/nfeinutilizacao2.asmx",
|
847
|
+
"NFeConsultaProtocolo": "https://nfce-homologacao.svrs.rs.gov.br/ws/NfeConsulta/NfeConsulta2.asmx",
|
848
|
+
"RecepcaoEvento": "https://nfce-homologacao.svrs.rs.gov.br/ws/recepcaoevento/recepcaoevento.asmx",
|
849
|
+
"NFeConsultaQR": "http://www.sefaz.pb.gov.br/nfce",
|
850
|
+
"urlChave": "http://www.sefaz.pb.gov.br/nfce"
|
723
851
|
}
|
724
852
|
},
|
725
853
|
"cUF": "25"
|
package/dist/utils/tools.d.ts
CHANGED
package/dist/utils/tools.js
CHANGED
@@ -9,8 +9,8 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
|
|
9
9
|
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
10
10
|
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
11
11
|
};
|
12
|
-
var _Tools_instances, _Tools_cert,
|
13
|
-
import {
|
12
|
+
var _Tools_instances, _Tools_cert, _Tools_pem, _Tools_config, _Tools_gerarQRCodeNFCe, _Tools_xmlValido, _Tools_certTools;
|
13
|
+
import { XMLBuilder } from "fast-xml-parser";
|
14
14
|
import https from "https";
|
15
15
|
import { spawnSync } from "child_process";
|
16
16
|
import tmp from "tmp";
|
@@ -20,17 +20,13 @@ import fs from "fs";
|
|
20
20
|
import path from 'path';
|
21
21
|
import { fileURLToPath } from 'url';
|
22
22
|
import pem from 'pem';
|
23
|
-
import { cUF2UF } from "./extras.js";
|
23
|
+
import { cUF2UF, json2xml, xml2json } from "./extras.js";
|
24
24
|
const __filename = fileURLToPath(import.meta.url);
|
25
25
|
const __dirname = path.dirname(__filename);
|
26
26
|
class Tools {
|
27
27
|
constructor(config = { mod: "", xmllint: 'xmllint', UF: '', tpAmb: 2, CSC: "", CSCid: "", versao: "4.00", timeout: 30, openssl: null }, certificado = { pfx: "", senha: "" }) {
|
28
28
|
_Tools_instances.add(this);
|
29
29
|
_Tools_cert.set(this, void 0);
|
30
|
-
_Tools_xmlTools.set(this, {
|
31
|
-
XMLBuilder: {},
|
32
|
-
XMLParser: {}
|
33
|
-
});
|
34
30
|
_Tools_pem.set(this, {
|
35
31
|
key: "", // A chave privada extraída do PKCS#12, em formato PEM
|
36
32
|
cert: "", // O certificado extraído, em formato PEM
|
@@ -55,15 +51,6 @@ class Tools {
|
|
55
51
|
//Configurar certificado
|
56
52
|
__classPrivateFieldSet(this, _Tools_config, config, "f");
|
57
53
|
__classPrivateFieldSet(this, _Tools_cert, certificado, "f");
|
58
|
-
__classPrivateFieldGet(this, _Tools_xmlTools, "f").XMLBuilder = new XMLBuilder({
|
59
|
-
ignoreAttributes: false,
|
60
|
-
attributeNamePrefix: "@",
|
61
|
-
});
|
62
|
-
__classPrivateFieldGet(this, _Tools_xmlTools, "f").XMLParser = new XMLParser({
|
63
|
-
ignoreAttributes: false,
|
64
|
-
attributeNamePrefix: "@",
|
65
|
-
parseTagValue: false, // Evita conversão automática de valores
|
66
|
-
});
|
67
54
|
}
|
68
55
|
sefazEnviaLote(xml, data = { idLote: 1, indSinc: 0, compactar: false }) {
|
69
56
|
return new Promise(async (resvol, reject) => {
|
@@ -189,7 +176,8 @@ class Tools {
|
|
189
176
|
xml.NFe.infNFeSupl.qrCode = __classPrivateFieldGet(this, _Tools_instances, "m", _Tools_gerarQRCodeNFCe).call(this, xml.NFe, "2", __classPrivateFieldGet(this, _Tools_config, "f").CSCid, __classPrivateFieldGet(this, _Tools_config, "f").CSC);
|
190
177
|
}
|
191
178
|
this.json2xml(xml).then(async (res) => {
|
192
|
-
__classPrivateFieldGet(this, _Tools_instances, "m", _Tools_xmlValido).call(this, res, `nfe_v${__classPrivateFieldGet(this, _Tools_config, "f").versao}`);
|
179
|
+
await __classPrivateFieldGet(this, _Tools_instances, "m", _Tools_xmlValido).call(this, res, `nfe_v${__classPrivateFieldGet(this, _Tools_config, "f").versao}`).catch(reject);
|
180
|
+
;
|
193
181
|
resvol(res);
|
194
182
|
}).catch(err => {
|
195
183
|
reject(err);
|
@@ -198,12 +186,12 @@ class Tools {
|
|
198
186
|
}
|
199
187
|
async xml2json(xml) {
|
200
188
|
return new Promise((resvol, reject) => {
|
201
|
-
|
189
|
+
xml2json(xml).then(resvol).catch(reject);
|
202
190
|
});
|
203
191
|
}
|
204
192
|
async json2xml(obj) {
|
205
193
|
return new Promise((resvol, reject) => {
|
206
|
-
|
194
|
+
json2xml(obj).then(resvol).catch(reject);
|
207
195
|
});
|
208
196
|
}
|
209
197
|
//Obter certificado
|
@@ -247,10 +235,10 @@ class Tools {
|
|
247
235
|
attributeNamePrefix: "@"
|
248
236
|
});
|
249
237
|
// Validação do XML interno (opcional)
|
250
|
-
__classPrivateFieldGet(this, _Tools_instances, "m", _Tools_xmlValido).call(this, builder.build({ consSitNFe }), `consSitNFe_v${__classPrivateFieldGet(this, _Tools_config, "f").versao}`);
|
238
|
+
await __classPrivateFieldGet(this, _Tools_instances, "m", _Tools_xmlValido).call(this, builder.build({ consSitNFe }), `consSitNFe_v${__classPrivateFieldGet(this, _Tools_config, "f").versao}`).catch(reject);
|
239
|
+
;
|
251
240
|
const xml = builder.build(xmlObj);
|
252
241
|
let tempUF = urlEventos(UF, __classPrivateFieldGet(this, _Tools_config, "f").versao);
|
253
|
-
console.log(tempUF);
|
254
242
|
const url = tempUF[`mod${mod}`][(__classPrivateFieldGet(this, _Tools_config, "f").tpAmb == 1 ? "producao" : "homologacao")].NFeConsultaProtocolo;
|
255
243
|
const req = https.request(url, {
|
256
244
|
method: 'POST',
|
@@ -316,7 +304,7 @@ class Tools {
|
|
316
304
|
attributeNamePrefix: "@"
|
317
305
|
});
|
318
306
|
//Validação
|
319
|
-
__classPrivateFieldGet(this, _Tools_instances, "m", _Tools_xmlValido).call(this, tempBuild.build({ consStatServ }), `consStatServ_v${__classPrivateFieldGet(this, _Tools_config, "f").versao}`);
|
307
|
+
await __classPrivateFieldGet(this, _Tools_instances, "m", _Tools_xmlValido).call(this, tempBuild.build({ consStatServ }), `consStatServ_v${__classPrivateFieldGet(this, _Tools_config, "f").versao}`).catch(reject);
|
320
308
|
let tempUF = urlEventos(__classPrivateFieldGet(this, _Tools_config, "f").UF, __classPrivateFieldGet(this, _Tools_config, "f").versao);
|
321
309
|
let xml = tempBuild.build(xmlObj);
|
322
310
|
const req = https.request(tempUF[`mod${__classPrivateFieldGet(this, _Tools_config, "f").mod}`][(__classPrivateFieldGet(this, _Tools_config, "f").tpAmb == 1 ? "producao" : "homologacao")].NFeStatusServico, {
|
@@ -356,8 +344,13 @@ class Tools {
|
|
356
344
|
}
|
357
345
|
});
|
358
346
|
}
|
347
|
+
async validarNFe(xml) {
|
348
|
+
return new Promise((resolve, reject) => {
|
349
|
+
__classPrivateFieldGet(this, _Tools_instances, "m", _Tools_xmlValido).call(this, xml, `nfe_v${__classPrivateFieldGet(this, _Tools_config, "f").versao}`).then(resolve).catch(reject);
|
350
|
+
});
|
351
|
+
}
|
359
352
|
}
|
360
|
-
_Tools_cert = new WeakMap(),
|
353
|
+
_Tools_cert = new WeakMap(), _Tools_pem = new WeakMap(), _Tools_config = new WeakMap(), _Tools_instances = new WeakSet(), _Tools_gerarQRCodeNFCe = function _Tools_gerarQRCodeNFCe(NFe, versaoQRCode = "2", idCSC, CSC) {
|
361
354
|
let s = '|', concat, hash;
|
362
355
|
if (NFe.infNFe.ide.tpEmis == 1) {
|
363
356
|
concat = [NFe.infNFe['@Id'].replace("NFe", ""), versaoQRCode, NFe.infNFe.ide.tpAmb, Number(idCSC)].join(s);
|
@@ -371,19 +364,23 @@ _Tools_cert = new WeakMap(), _Tools_xmlTools = new WeakMap(), _Tools_pem = new W
|
|
371
364
|
}, _Tools_xmlValido =
|
372
365
|
//Validar XML da NFe, somente apos assinar
|
373
366
|
async function _Tools_xmlValido(xml, xsd) {
|
374
|
-
|
375
|
-
|
376
|
-
|
377
|
-
|
378
|
-
|
379
|
-
|
380
|
-
|
381
|
-
|
382
|
-
|
383
|
-
|
384
|
-
|
385
|
-
|
386
|
-
|
367
|
+
return new Promise((resolve, reject) => {
|
368
|
+
const xmlFile = tmp.fileSync({ mode: 0o644, prefix: 'xml-', postfix: '.xml' });
|
369
|
+
fs.writeFileSync(xmlFile.name, xml, { encoding: 'utf8' });
|
370
|
+
const schemaPath = path.resolve(__dirname, `../../schemas/${xsd}.xsd`);
|
371
|
+
const verif = spawnSync(__classPrivateFieldGet(this, _Tools_config, "f").xmllint, ['--noout', '--schema', schemaPath, xmlFile.name], { encoding: 'utf8' });
|
372
|
+
xmlFile.removeCallback();
|
373
|
+
// Aqui, usamos o operador de encadeamento opcional (?.)
|
374
|
+
if (verif.error) {
|
375
|
+
return reject("Biblioteca xmllint não encontrada!");
|
376
|
+
}
|
377
|
+
else if (!verif.stderr.includes(".xml validates")) {
|
378
|
+
return reject(verif.stderr);
|
379
|
+
}
|
380
|
+
else {
|
381
|
+
resolve(true);
|
382
|
+
}
|
383
|
+
});
|
387
384
|
}, _Tools_certTools = function _Tools_certTools() {
|
388
385
|
return new Promise(async (resvol, reject) => {
|
389
386
|
if (__classPrivateFieldGet(this, _Tools_pem, "f").key != "")
|