Skip to content

Commit c290eff

Browse files
Release 1.2.6
- Igualando pacote ao sdk-node-apis-efi na versão 1.2.17 https://github.com/efipay/sdk-node-apis-efi/releases/tag/1.2.17
1 parent dad3748 commit c290eff

File tree

8 files changed

+57
-10
lines changed

8 files changed

+57
-10
lines changed

dist/cjs/index.cjs

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -584,7 +584,7 @@ var exports$1 = {
584584
}
585585
};
586586
var description = "Module for integration with Efi Bank API";
587-
var version = "1.2.5";
587+
var version = "1.2.6";
588588
var deprecated = "Este pacote será descontinuado. Use o 'sdk-node-apis-efi' no lugar.";
589589
var author = "Efi Bank - Consultoria Técnica | João Vitor Oliveira | João Lucas";
590590
var license = "MIT";
@@ -778,6 +778,9 @@ class Endpoints {
778778
});
779779
}
780780
isExpired() {
781+
if (!this.options.cache) {
782+
return true;
783+
}
781784
let current_time = new Date().getTime() / 1000;
782785
if (current_time > this.auth.authDate + this.auth.expires_in) {
783786
return true;
@@ -850,7 +853,10 @@ class Endpoints {
850853
updateRoute();
851854
query = getQueryString();
852855
let headers = new Object();
853-
headers['x-skip-mtls-checking'] = !this.options.validateMtls;
856+
if (endpoint.route === this.constants.APIS.PIX.ENDPOINTS.pixConfigWebhook.route && endpoint.method === this.constants.APIS.PIX.ENDPOINTS.pixConfigWebhook.method) {
857+
this.options.validateMtls = this.options.validateMtls || this.options.validate_mtls;
858+
headers['x-skip-mtls-checking'] = !this.options.validateMtls;
859+
}
854860
if (this.options.partner_token) {
855861
headers['partner-token'] = this.options.partner_token;
856862
}
@@ -5820,12 +5826,18 @@ class EfiPay extends AllMethods {
58205826
* @param {string} [options.partner_token] - Token de parceiro caso tenha.
58215827
* @param {string} [options.certificate] - Caminho para o certificado
58225828
* @param {boolean} [options.cert_base64] - Indica se será enviado o certificado em base64
5829+
* @param {boolean} [options.validate_mtls] - Indica se será utilizado mTLS ou não no webhook
5830+
* @param {boolean} [options.validateMtls] - Indica se será utilizado mTLS ou não no webhook
5831+
* @param {boolean} [options.cache] - Inidica se você deseja usar cache no token de autenticação, por padrão `true`
58235832
*
58245833
* @param {string} [options.pix_cert] - # PRETERIDO # Caminho para o certificado
58255834
* @param {string} [options.pemKey] - Caminho para a chave privada, caso opte por enviar o certificado em PEM.
58265835
*/
58275836
constructor(options) {
58285837
super();
5838+
if (options.cache === undefined) {
5839+
options.cache = true;
5840+
}
58295841
if (options.pix_cert) {
58305842
console.warn('⚠️ WARNING:\nO parâmetro "pix_cert" foi preterido, utilize "certificate" no lugar.');
58315843
options.certificate = options.pix_cert;

dist/esm/index.mjs

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -575,7 +575,7 @@ var exports = {
575575
}
576576
};
577577
var description = "Module for integration with Efi Bank API";
578-
var version = "1.2.5";
578+
var version = "1.2.6";
579579
var deprecated = "Este pacote será descontinuado. Use o 'sdk-node-apis-efi' no lugar.";
580580
var author = "Efi Bank - Consultoria Técnica | João Vitor Oliveira | João Lucas";
581581
var license = "MIT";
@@ -769,6 +769,9 @@ class Endpoints {
769769
});
770770
}
771771
isExpired() {
772+
if (!this.options.cache) {
773+
return true;
774+
}
772775
let current_time = new Date().getTime() / 1000;
773776
if (current_time > this.auth.authDate + this.auth.expires_in) {
774777
return true;
@@ -841,7 +844,10 @@ class Endpoints {
841844
updateRoute();
842845
query = getQueryString();
843846
let headers = new Object();
844-
headers['x-skip-mtls-checking'] = !this.options.validateMtls;
847+
if (endpoint.route === this.constants.APIS.PIX.ENDPOINTS.pixConfigWebhook.route && endpoint.method === this.constants.APIS.PIX.ENDPOINTS.pixConfigWebhook.method) {
848+
this.options.validateMtls = this.options.validateMtls || this.options.validate_mtls;
849+
headers['x-skip-mtls-checking'] = !this.options.validateMtls;
850+
}
845851
if (this.options.partner_token) {
846852
headers['partner-token'] = this.options.partner_token;
847853
}
@@ -5811,12 +5817,18 @@ class EfiPay extends AllMethods {
58115817
* @param {string} [options.partner_token] - Token de parceiro caso tenha.
58125818
* @param {string} [options.certificate] - Caminho para o certificado
58135819
* @param {boolean} [options.cert_base64] - Indica se será enviado o certificado em base64
5820+
* @param {boolean} [options.validate_mtls] - Indica se será utilizado mTLS ou não no webhook
5821+
* @param {boolean} [options.validateMtls] - Indica se será utilizado mTLS ou não no webhook
5822+
* @param {boolean} [options.cache] - Inidica se você deseja usar cache no token de autenticação, por padrão `true`
58145823
*
58155824
* @param {string} [options.pix_cert] - # PRETERIDO # Caminho para o certificado
58165825
* @param {string} [options.pemKey] - Caminho para a chave privada, caso opte por enviar o certificado em PEM.
58175826
*/
58185827
constructor(options) {
58195828
super();
5829+
if (options.cache === undefined) {
5830+
options.cache = true;
5831+
}
58205832
if (options.pix_cert) {
58215833
console.warn('⚠️ WARNING:\nO parâmetro "pix_cert" foi preterido, utilize "certificate" no lugar.');
58225834
options.certificate = options.pix_cert;

dist/types/index.d.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@ export default class EfiPay extends AllMethods {
88
* @param {string} [options.partner_token] - Token de parceiro caso tenha.
99
* @param {string} [options.certificate] - Caminho para o certificado
1010
* @param {boolean} [options.cert_base64] - Indica se será enviado o certificado em base64
11+
* @param {boolean} [options.validate_mtls] - Indica se será utilizado mTLS ou não no webhook
12+
* @param {boolean} [options.validateMtls] - Indica se será utilizado mTLS ou não no webhook
13+
* @param {boolean} [options.cache] - Inidica se você deseja usar cache no token de autenticação, por padrão `true`
1114
*
1215
* @param {string} [options.pix_cert] - # PRETERIDO # Caminho para o certificado
1316
* @param {string} [options.pemKey] - Caminho para a chave privada, caso opte por enviar o certificado em PEM.
@@ -19,6 +22,9 @@ export default class EfiPay extends AllMethods {
1922
partner_token?: string | undefined;
2023
certificate?: string | undefined;
2124
cert_base64?: boolean | undefined;
25+
validate_mtls?: boolean | undefined;
26+
validateMtls?: boolean | undefined;
27+
cache?: boolean | undefined;
2228
pix_cert?: string | undefined;
2329
pemKey?: string | undefined;
2430
});

examples/exclusives/med/medDefense.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@ let body = {
1212
justificativa: "Justificativa"
1313
}
1414

15-
// O método medDefebse indica os campos que devem ser enviados e que serão retornados
16-
efipay.medDefebse(params, body)
15+
// O método medDefense indica os campos que devem ser enviados e que serão retornados
16+
efipay.medDefense(params, body)
1717
.then((resposta) => {
1818
console.log(resposta) // Aqui você tera acesso a resposta da API e os campos retornados de forma intuitiva
1919
})

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
}
1111
},
1212
"description": "Module for integration with Efi Bank API",
13-
"version": "1.2.5",
13+
"version": "1.2.6",
1414
"deprecated": "Este pacote será descontinuado. Use o 'sdk-node-apis-efi' no lugar.",
1515
"author": "Efi Bank - Consultoria Técnica | João Vitor Oliveira | João Lucas",
1616
"license": "MIT",

src/index.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,18 @@ export default class EfiPay extends AllMethods {
1414
* @param {string} [options.partner_token] - Token de parceiro caso tenha.
1515
* @param {string} [options.certificate] - Caminho para o certificado
1616
* @param {boolean} [options.cert_base64] - Indica se será enviado o certificado em base64
17+
* @param {boolean} [options.validate_mtls] - Indica se será utilizado mTLS ou não no webhook
18+
* @param {boolean} [options.validateMtls] - Indica se será utilizado mTLS ou não no webhook
19+
* @param {boolean} [options.cache] - Inidica se você deseja usar cache no token de autenticação, por padrão `true`
1720
*
1821
* @param {string} [options.pix_cert] - # PRETERIDO # Caminho para o certificado
1922
* @param {string} [options.pemKey] - Caminho para a chave privada, caso opte por enviar o certificado em PEM.
2023
*/
2124
constructor(options) {
2225
super()
26+
if (options.cache === undefined) {
27+
options.cache = true
28+
}
2329
if (options.pix_cert) {
2430
console.warn('⚠️ WARNING:\nO parâmetro "pix_cert" foi preterido, utilize "certificate" no lugar.');
2531
options.certificate = options.pix_cert;

src/lib/endpoints.js

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import axios from 'axios'
66
import randomstring from 'randomstring'
77

88
class Endpoints {
9+
910
constructor(options, constants) {
1011
this.options = options
1112
this.auth = null
@@ -153,6 +154,9 @@ class Endpoints {
153154
}
154155

155156
isExpired() {
157+
if (!this.options.cache) {
158+
return true
159+
}
156160
let current_time = new Date().getTime() / 1000
157161
if (current_time > this.auth.authDate + this.auth.expires_in) {
158162
return true
@@ -232,7 +236,14 @@ class Endpoints {
232236
query = getQueryString()
233237

234238
let headers = new Object()
235-
headers['x-skip-mtls-checking'] = !this.options.validateMtls
239+
240+
if (endpoint.route === this.constants.APIS.PIX.ENDPOINTS.pixConfigWebhook.route && endpoint.method === this.constants.APIS.PIX.ENDPOINTS.pixConfigWebhook.method) {
241+
242+
this.options.validateMtls = this.options.validateMtls || this.options.validate_mtls
243+
244+
headers['x-skip-mtls-checking'] = !this.options.validateMtls
245+
246+
}
236247

237248
if (this.options.partner_token) {
238249
headers['partner-token'] = this.options.partner_token

0 commit comments

Comments
 (0)