From 2792b3e7b51857cee736a67752e0b7f5661ef04b Mon Sep 17 00:00:00 2001 From: Leandro Costa Date: Wed, 8 Nov 2023 23:53:18 -0300 Subject: [PATCH] feat: forceTokenTypeToCamelCase --- src/lhisp-oauth-client.t.ts | 1 + src/lhisp-oauth-client.ts | 6 +++++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/src/lhisp-oauth-client.t.ts b/src/lhisp-oauth-client.t.ts index 828ec82..288fbe4 100644 --- a/src/lhisp-oauth-client.t.ts +++ b/src/lhisp-oauth-client.t.ts @@ -18,6 +18,7 @@ export interface LhispOauthClientConstructorParams { grantType?: string; authContentType?: ContentType; sendAuthCredentialsOnRequestBody?: boolean; + forceTokenTypeToCamelCase?: boolean; debug?: boolean; } diff --git a/src/lhisp-oauth-client.ts b/src/lhisp-oauth-client.ts index 4f60aef..5e22a1b 100644 --- a/src/lhisp-oauth-client.ts +++ b/src/lhisp-oauth-client.ts @@ -32,6 +32,7 @@ export class LhispOauthClient { protected tokenCreatedAt = 0; protected tokenExpiresIn = 0; protected sendAuthCredentialsOnRequestBody?: boolean; + protected forceTokenTypeToCamelCase?: boolean; constructor(params: LhispOauthClientConstructorParams) { if (params.certificado) { @@ -131,7 +132,10 @@ export class LhispOauthClient { } getAuthToken() { - return `${this.accessToken?.token_type} ${this.accessToken?.access_token}`; + const tokenType = this.forceTokenTypeToCamelCase + ? `${this.accessToken?.token_type?.[0]?.toUpperCase()}${this.accessToken?.token_type?.substring(1)}` + : this.accessToken?.token_type; + return `${tokenType} ${this.accessToken?.access_token}`; } async executarRequest({