Merged in development (pull request #12)

feat: parse certificado from base64 string
This commit is contained in:
Leandro Costa 2023-11-09 02:07:36 +00:00
commit 8d12ae5c9e
3 changed files with 5 additions and 5 deletions

4
package-lock.json generated
View file

@ -1,12 +1,12 @@
{ {
"name": "lhisp-oauth-client", "name": "lhisp-oauth-client",
"version": "1.0.16", "version": "1.0.17",
"lockfileVersion": 3, "lockfileVersion": 3,
"requires": true, "requires": true,
"packages": { "packages": {
"": { "": {
"name": "lhisp-oauth-client", "name": "lhisp-oauth-client",
"version": "1.0.16", "version": "1.0.17",
"license": "MIT", "license": "MIT",
"dependencies": { "dependencies": {
"axios": "^1.4.0", "axios": "^1.4.0",

View file

@ -1,6 +1,6 @@
{ {
"name": "lhisp-oauth-client", "name": "lhisp-oauth-client",
"version": "1.0.16", "version": "1.0.17",
"main": "src/index", "main": "src/index",
"types": "src/index.d.ts", "types": "src/index.d.ts",
"repository": "git@bitbucket.org:leandro_costa/lhisp-oauth-client.git", "repository": "git@bitbucket.org:leandro_costa/lhisp-oauth-client.git",

View file

@ -21,7 +21,7 @@ export class LhispOauthClient<iAccessToken extends AccessToken = AccessToken> {
protected authHeaderName: string; protected authHeaderName: string;
protected tokenHeaderName: string; protected tokenHeaderName: string;
protected authContentType: ContentType; protected authContentType: ContentType;
protected certificado?: string; protected certificado?: string | Buffer;
protected senhaCertificado?: string; protected senhaCertificado?: string;
protected authScope?: string; protected authScope?: string;
protected headers?: Headers; protected headers?: Headers;
@ -36,7 +36,7 @@ export class LhispOauthClient<iAccessToken extends AccessToken = AccessToken> {
constructor(params: LhispOauthClientConstructorParams) { constructor(params: LhispOauthClientConstructorParams) {
if (params.certificado) { if (params.certificado) {
this.agent = new https.Agent({ this.agent = new https.Agent({
pfx: params.certificado, pfx: Buffer.isBuffer(params.certificado) ? params.certificado : Buffer.from(params.certificado, "base64"),
passphrase: params.senhaCertificado, passphrase: params.senhaCertificado,
rejectUnauthorized: false, rejectUnauthorized: false,
}); });