Merged in development (pull request #18)

Development
This commit is contained in:
Leandro Costa 2024-01-04 17:43:06 +00:00
commit ef8b3d7aba
4 changed files with 8 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.26", "version": "1.0.27",
"lockfileVersion": 3, "lockfileVersion": 3,
"requires": true, "requires": true,
"packages": { "packages": {
"": { "": {
"name": "lhisp-oauth-client", "name": "lhisp-oauth-client",
"version": "1.0.26", "version": "1.0.27",
"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.26", "version": "1.0.27",
"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

@ -22,6 +22,7 @@ export interface LhispOauthClientConstructorParams {
sendAuthCredentialsOnRequestBody?: boolean; sendAuthCredentialsOnRequestBody?: boolean;
formatAccessToken?: (accessToken?: AccessToken) => string; formatAccessToken?: (accessToken?: AccessToken) => string;
debug?: boolean; debug?: boolean;
timeout?: number;
} }
export interface ExecutarRequestParams extends AxiosRequestConfig { export interface ExecutarRequestParams extends AxiosRequestConfig {

View file

@ -34,6 +34,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 timeout: number;
protected formatAccessToken?: (accessToken?: iAccessToken) => string; protected formatAccessToken?: (accessToken?: iAccessToken) => string;
constructor(params: LhispOauthClientConstructorParams) { constructor(params: LhispOauthClientConstructorParams) {
@ -64,6 +65,7 @@ export class LhispOauthClient<iAccessToken extends AccessToken = AccessToken> {
this.tokenHeaderName = params.tokenHeaderName || defaultTokenHeaderName; this.tokenHeaderName = params.tokenHeaderName || defaultTokenHeaderName;
this.sendAuthCredentialsOnRequestBody = params.sendAuthCredentialsOnRequestBody; this.sendAuthCredentialsOnRequestBody = params.sendAuthCredentialsOnRequestBody;
this.formatAccessToken = params.formatAccessToken; this.formatAccessToken = params.formatAccessToken;
this.timeout = params.timeout ? params.timeout : 60000;
} }
getAuthHeaderValue(): string { getAuthHeaderValue(): string {
@ -110,6 +112,7 @@ export class LhispOauthClient<iAccessToken extends AccessToken = AccessToken> {
data: { data: {
...this.authData, ...this.authData,
}, },
timeout: this.timeout,
}; };
if (this.grantType) authRequestOpt.data.grant_type = this.grantType; if (this.grantType) authRequestOpt.data.grant_type = this.grantType;
@ -171,6 +174,7 @@ export class LhispOauthClient<iAccessToken extends AccessToken = AccessToken> {
headers, headers,
data, data,
params, params,
timeout: this.timeout,
...opt, ...opt,
}); });