Skip to content

Commit 403f87a

Browse files
committed
Release 2.0.1: Compatibilidade com certificado e chave .pem
1 parent 373acd3 commit 403f87a

File tree

8 files changed

+2001
-1847
lines changed

8 files changed

+2001
-1847
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
node_modules
22
*.p12
3+
*.pem
34
simulaMod.ts
45
teste.ts
56
npm-debug.log

.npmignore

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,6 @@
55
package.json
66
README.md
77
tsconfig.json
8-
jest.config.js
8+
jest.config.js
9+
*.p12
10+
*.pem

index.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,10 @@ class Gerencianet {
2121
sandbox: options.sandbox,
2222
};
2323

24+
if(options.pemKey){
25+
credentials.pemKey = options.pemKey
26+
}
27+
2428
const methods = {};
2529
Object.keys(constants.APIS).forEach((endpoint) => {
2630
const key = endpoint as keyof typeof constants.APIS;

package-lock.json

Lines changed: 1978 additions & 1841 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
@@ -1,6 +1,6 @@
11
{
22
"name": "gn-api-sdk-typescript",
3-
"version": "2.0.0",
3+
"version": "2.0.1",
44
"description": "Module for integration with Gerencianet API\"",
55
"main": "dist/index.js",
66
"types": "dist/index.d.ts",

src/endpoints.ts

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,10 +40,18 @@ class Endpoints {
4040

4141
try {
4242
if (this.options.certificate) {
43-
this.agent = new https.Agent({
44-
pfx: fs.readFileSync(this.options.certificate),
45-
passphrase: '',
46-
});
43+
if(this.options.pemKey){
44+
this.agent = new https.Agent({
45+
cert: fs.readFileSync(this.options.certificate),
46+
key: fs.readFileSync(this.options.pemKey),
47+
passphrase: '',
48+
});
49+
}else{
50+
this.agent = new https.Agent({
51+
pfx: fs.readFileSync(this.options.certificate),
52+
passphrase: '',
53+
});
54+
}
4755
this.options.agent = this.agent;
4856
}
4957
} catch (error) {

src/interfaces/gnConfig.interface.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ export interface GnConfig {
77
client_id: string;
88
client_secret: string;
99
certificate?: PathLike | string;
10+
pemKey?: PathLike | string;
1011
sandbox: boolean;
1112
partnerToken?: string;
1213
rawResponse?: any;

src/interfaces/gnCredentials.interface.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ export interface GnCredentials {
77
certificate?: PathLike | string;
88
pix_cert?: PathLike | string;
99
pathCert?: PathLike | string;
10+
pemKey?: PathLike | string;
1011
sandbox: boolean;
1112
validateMtls?: boolean;
1213
partnerToken?: string;

0 commit comments

Comments
 (0)