commit
0f23e423e1
4 changed files with 11 additions and 9 deletions
4
package-lock.json
generated
4
package-lock.json
generated
|
@ -1,12 +1,12 @@
|
||||||
{
|
{
|
||||||
"name": "lhisp-oauth-client",
|
"name": "lhisp-oauth-client",
|
||||||
"version": "1.0.21",
|
"version": "1.0.23",
|
||||||
"lockfileVersion": 3,
|
"lockfileVersion": 3,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"packages": {
|
"packages": {
|
||||||
"": {
|
"": {
|
||||||
"name": "lhisp-oauth-client",
|
"name": "lhisp-oauth-client",
|
||||||
"version": "1.0.21",
|
"version": "1.0.23",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"axios": "^1.6.1",
|
"axios": "^1.6.1",
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "lhisp-oauth-client",
|
"name": "lhisp-oauth-client",
|
||||||
"version": "1.0.21",
|
"version": "1.0.23",
|
||||||
"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",
|
||||||
|
|
|
@ -18,7 +18,7 @@ export interface LhispOauthClientConstructorParams {
|
||||||
grantType?: string;
|
grantType?: string;
|
||||||
authContentType?: ContentType;
|
authContentType?: ContentType;
|
||||||
sendAuthCredentialsOnRequestBody?: boolean;
|
sendAuthCredentialsOnRequestBody?: boolean;
|
||||||
forceTokenTypeToCamelCase?: boolean;
|
formatAccessToken?: (accessToken?: AccessToken) => string;
|
||||||
debug?: boolean;
|
debug?: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -32,7 +32,7 @@ export class LhispOauthClient<iAccessToken extends AccessToken = AccessToken> {
|
||||||
protected tokenCreatedAt = 0;
|
protected tokenCreatedAt = 0;
|
||||||
protected tokenExpiresIn = 0;
|
protected tokenExpiresIn = 0;
|
||||||
protected sendAuthCredentialsOnRequestBody?: boolean;
|
protected sendAuthCredentialsOnRequestBody?: boolean;
|
||||||
protected forceTokenTypeToCamelCase?: boolean;
|
protected formatAccessToken?: (accessToken?: iAccessToken) => string;
|
||||||
|
|
||||||
constructor(params: LhispOauthClientConstructorParams) {
|
constructor(params: LhispOauthClientConstructorParams) {
|
||||||
if (params.certificado) {
|
if (params.certificado) {
|
||||||
|
@ -59,6 +59,7 @@ export class LhispOauthClient<iAccessToken extends AccessToken = AccessToken> {
|
||||||
this.authHeaderName = params.authHeaderName || defaultAuthHeaderName;
|
this.authHeaderName = params.authHeaderName || defaultAuthHeaderName;
|
||||||
this.tokenHeaderName = params.tokenHeaderName || defaultTokenHeaderName;
|
this.tokenHeaderName = params.tokenHeaderName || defaultTokenHeaderName;
|
||||||
this.sendAuthCredentialsOnRequestBody = params.sendAuthCredentialsOnRequestBody;
|
this.sendAuthCredentialsOnRequestBody = params.sendAuthCredentialsOnRequestBody;
|
||||||
|
this.formatAccessToken = params.formatAccessToken;
|
||||||
}
|
}
|
||||||
|
|
||||||
getAuthHeaderValue(): string {
|
getAuthHeaderValue(): string {
|
||||||
|
@ -132,10 +133,11 @@ export class LhispOauthClient<iAccessToken extends AccessToken = AccessToken> {
|
||||||
}
|
}
|
||||||
|
|
||||||
getAuthToken() {
|
getAuthToken() {
|
||||||
const tokenType = this.forceTokenTypeToCamelCase
|
if (this.formatAccessToken) {
|
||||||
? `${this.accessToken?.token_type?.[0]?.toUpperCase()}${this.accessToken?.token_type?.substring(1)}`
|
return this.formatAccessToken(this.accessToken);
|
||||||
: this.accessToken?.token_type;
|
}
|
||||||
return `${tokenType} ${this.accessToken?.access_token}`;
|
|
||||||
|
return `${this.accessToken?.token_type} ${this.accessToken?.access_token}`;
|
||||||
}
|
}
|
||||||
|
|
||||||
async executarRequest<ResponseType>({
|
async executarRequest<ResponseType>({
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue