Merged in development (pull request #16)

feat: add authHeaders
This commit is contained in:
Leandro Costa 2023-11-27 22:34:44 +00:00
commit fa78a887fb
4 changed files with 7 additions and 3 deletions

4
package-lock.json generated
View file

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

View file

@ -1,6 +1,6 @@
{ {
"name": "lhisp-oauth-client", "name": "lhisp-oauth-client",
"version": "1.0.24", "version": "1.0.25",
"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

@ -15,6 +15,7 @@ export interface LhispOauthClientConstructorParams {
authHeaderName?: string; authHeaderName?: string;
tokenHeaderName?: string; tokenHeaderName?: string;
headers?: Headers; headers?: Headers;
authHeaders?: Headers;
grantType?: string; grantType?: string;
authContentType?: ContentType; authContentType?: ContentType;
sendAuthCredentialsOnRequestBody?: boolean; sendAuthCredentialsOnRequestBody?: boolean;

View file

@ -25,6 +25,7 @@ export class LhispOauthClient<iAccessToken extends AccessToken = AccessToken> {
protected senhaCertificado?: string; protected senhaCertificado?: string;
protected authScope?: string; protected authScope?: string;
protected headers?: AxiosHeaders; protected headers?: AxiosHeaders;
protected authHeaders?: AxiosHeaders;
protected grantType?: string; protected grantType?: string;
protected agent: https.Agent; protected agent: https.Agent;
protected accessToken?: iAccessToken; protected accessToken?: iAccessToken;
@ -49,6 +50,7 @@ export class LhispOauthClient<iAccessToken extends AccessToken = AccessToken> {
this.certificado = params.certificado; this.certificado = params.certificado;
this.headers = (params.headers ? params.headers : {}) as any as AxiosHeaders; this.headers = (params.headers ? params.headers : {}) as any as AxiosHeaders;
this.authHeaders = (params.authHeaders ? params.authHeaders : {}) as any as AxiosHeaders;
this.apiUrl = params.apiUrl; this.apiUrl = params.apiUrl;
this.authUrl = params.authUrl; this.authUrl = params.authUrl;
this.authScope = params.authScope; this.authScope = params.authScope;
@ -101,6 +103,7 @@ export class LhispOauthClient<iAccessToken extends AccessToken = AccessToken> {
headers: { headers: {
[this.authHeaderName]: this.getAuthHeaderValue(), [this.authHeaderName]: this.getAuthHeaderValue(),
"Content-Type": this.authContentType, "Content-Type": this.authContentType,
...this.authHeaders,
}, },
data: {}, data: {},
}; };