lhisp-oauth-client 1.0.25 → 1.0.27

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lhisp-oauth-client",
3
- "version": "1.0.25",
3
+ "version": "1.0.27",
4
4
  "main": "src/index",
5
5
  "types": "src/index.d.ts",
6
6
  "repository": "git@bitbucket.org:leandro_costa/lhisp-oauth-client.git",
@@ -18,11 +18,13 @@ export declare class LhispOauthClient<iAccessToken extends AccessToken = AccessT
18
18
  protected authHeaders?: AxiosHeaders;
19
19
  protected grantType?: string;
20
20
  protected agent: https.Agent;
21
+ protected authData: Record<string, string>;
21
22
  protected accessToken?: iAccessToken;
22
23
  protected refreshToken?: iAccessToken;
23
24
  protected tokenCreatedAt: number;
24
25
  protected tokenExpiresIn: number;
25
26
  protected sendAuthCredentialsOnRequestBody?: boolean;
27
+ protected timeout: number;
26
28
  protected formatAccessToken?: (accessToken?: iAccessToken) => string;
27
29
  constructor(params: LhispOauthClientConstructorParams);
28
30
  getAuthHeaderValue(): string;
@@ -31,6 +31,7 @@ const lhisp_oauth_client_t_1 = require("./lhisp-oauth-client.t");
31
31
  const lhisp_logger_1 = __importDefault(require("lhisp-logger"));
32
32
  class LhispOauthClient {
33
33
  constructor(params) {
34
+ this.authData = {};
34
35
  this.tokenCreatedAt = 0;
35
36
  this.tokenExpiresIn = 0;
36
37
  if (params.certificado) {
@@ -48,6 +49,7 @@ class LhispOauthClient {
48
49
  this.certificado = params.certificado;
49
50
  this.headers = (params.headers ? params.headers : {});
50
51
  this.authHeaders = (params.authHeaders ? params.authHeaders : {});
52
+ this.authData = params.authData || {};
51
53
  this.apiUrl = params.apiUrl;
52
54
  this.authUrl = params.authUrl;
53
55
  this.authScope = params.authScope;
@@ -59,6 +61,7 @@ class LhispOauthClient {
59
61
  this.tokenHeaderName = params.tokenHeaderName || lhisp_oauth_client_t_1.defaultTokenHeaderName;
60
62
  this.sendAuthCredentialsOnRequestBody = params.sendAuthCredentialsOnRequestBody;
61
63
  this.formatAccessToken = params.formatAccessToken;
64
+ this.timeout = params.timeout ? params.timeout : 60000;
62
65
  }
63
66
  getAuthHeaderValue() {
64
67
  return `Basic ${Buffer.from(`${this.clientId}:${this.clientSecret}`).toString("base64")}`;
@@ -96,7 +99,8 @@ class LhispOauthClient {
96
99
  url: this.authUrl,
97
100
  httpsAgent: this.agent,
98
101
  headers: Object.assign({ [this.authHeaderName]: this.getAuthHeaderValue(), "Content-Type": this.authContentType }, this.authHeaders),
99
- data: {},
102
+ data: Object.assign({}, this.authData),
103
+ timeout: this.timeout,
100
104
  };
101
105
  if (this.grantType)
102
106
  authRequestOpt.data.grant_type = this.grantType;
@@ -142,7 +146,7 @@ class LhispOauthClient {
142
146
  const headers = Object.assign({ "Content-Type": contentType, [this.tokenHeaderName]: this.getAuthToken() }, (this.headers || {}));
143
147
  const response = yield axios_1.default.request(Object.assign({ method, url: `${this.apiUrl}${path}`, httpsAgent: this.agent, headers,
144
148
  data,
145
- params }, opt));
149
+ params, timeout: this.timeout }, opt));
146
150
  return response.data;
147
151
  }
148
152
  catch (error) {
@@ -17,9 +17,11 @@ export interface LhispOauthClientConstructorParams {
17
17
  authHeaders?: Headers;
18
18
  grantType?: string;
19
19
  authContentType?: ContentType;
20
+ authData?: Record<string, string>;
20
21
  sendAuthCredentialsOnRequestBody?: boolean;
21
22
  formatAccessToken?: (accessToken?: AccessToken) => string;
22
23
  debug?: boolean;
24
+ timeout?: number;
23
25
  }
24
26
  export interface ExecutarRequestParams extends AxiosRequestConfig {
25
27
  path: string;