Skip to content
This repository has been archived by the owner on Apr 23, 2024. It is now read-only.

Commit

Permalink
novas variacoes de certificado
Browse files Browse the repository at this point in the history
  • Loading branch information
fnunezzz authored and lealhugui committed Feb 14, 2022
1 parent c446ce5 commit d798a7a
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 10 deletions.
5 changes: 5 additions & 0 deletions lib/factory/interface/nfe/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -379,6 +379,11 @@ export interface Certificado {
key: any;
pfx: any;
password: string;
opcoes?: OpcoesCertificado;
}
export interface OpcoesCertificado {
stringfyPassphrase?: boolean;
removeRejectUnauthorized?: boolean;
}
export declare function fromJsonixObj<T>(json: any): T;
export interface Geral {
Expand Down
24 changes: 19 additions & 5 deletions lib/factory/webservices/webserviceHelper.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,11 +73,25 @@ class WebServiceHelper {
return result;
}
static buildCertAgentOpt(cert) {
return {
rejectUnauthorized: (cert.rejectUnauthorized === undefined) ? true : cert.rejectUnauthorized,
pfx: cert.pfx,
passphrase: cert.password
};
const certAgentOpt = {};
if (cert.opcoes.stringfyPassphrase) {
certAgentOpt.passphrase = cert.password.toString();
}
else
(certAgentOpt.passphrase = cert.password);
if (!cert.opcoes.removeRejectUnauthorized) {
certAgentOpt.rejectUnauthorized = (cert.rejectUnauthorized === undefined) ? true : cert.rejectUnauthorized;
}
if (cert.pfx) {
certAgentOpt.pfx = cert.pfx;
}
if (cert.pem) {
certAgentOpt.cert = cert.pem;
}
if (cert.key) {
certAgentOpt.key = cert.key;
}
return certAgentOpt;
}
static async makeSoapRequest(xml, cert, soap, proxy) {
let result = { xml_enviado: xml };
Expand Down
8 changes: 7 additions & 1 deletion src/factory/interface/nfe/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -429,6 +429,12 @@ export interface Certificado {
key: any;
pfx: any;
password: string;
opcoes?: OpcoesCertificado;
}

export interface OpcoesCertificado {
stringfyPassphrase?: boolean;
removeRejectUnauthorized?: boolean;
}

export function fromJsonixObj<T>(json: any): T {
Expand Down Expand Up @@ -471,4 +477,4 @@ export interface Configuracoes {
webservices: Webservices;
responsavelTecnico?: ResponsavelTecnico;
arquivos: Arquivos;
}
}
17 changes: 13 additions & 4 deletions src/factory/webservices/webserviceHelper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -101,11 +101,20 @@ export abstract class WebServiceHelper {
}

private static buildCertAgentOpt(cert: any) {
return {
rejectUnauthorized: (cert.rejectUnauthorized === undefined) ? true : cert.rejectUnauthorized,
pfx: cert.pfx,
passphrase: cert.password
const certAgentOpt:any = {}

if (cert.opcoes.stringfyPassphrase) {certAgentOpt.passphrase = cert.password.toString()}
else (certAgentOpt.passphrase = cert.password)

if (!cert.opcoes.removeRejectUnauthorized) {
certAgentOpt.rejectUnauthorized = (cert.rejectUnauthorized === undefined) ? true : cert.rejectUnauthorized
}

if (cert.pfx) {certAgentOpt.pfx = cert.pfx}
if (cert.pem) {certAgentOpt.cert = cert.pem}
if (cert.key) {certAgentOpt.key = cert.key}

return certAgentOpt
}

public static async makeSoapRequest(xml: string, cert: any, soap: any, proxy?: WebProxy) {
Expand Down

0 comments on commit d798a7a

Please sign in to comment.