lhisp-oauth-client 1.0.26 → 1.0.29

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.26",
3
+ "version": "1.0.29",
4
4
  "main": "src/index",
5
5
  "types": "src/index.d.ts",
6
6
  "repository": "git@bitbucket.org:leandro_costa/lhisp-oauth-client.git",
@@ -24,6 +24,7 @@ export declare class LhispOauthClient<iAccessToken extends AccessToken = AccessT
24
24
  protected tokenCreatedAt: number;
25
25
  protected tokenExpiresIn: number;
26
26
  protected sendAuthCredentialsOnRequestBody?: boolean;
27
+ protected timeout: number;
27
28
  protected formatAccessToken?: (accessToken?: iAccessToken) => string;
28
29
  constructor(params: LhispOauthClientConstructorParams);
29
30
  getAuthHeaderValue(): string;
@@ -37,7 +37,7 @@ class LhispOauthClient {
37
37
  if (params.certificado) {
38
38
  this.agent = new https_1.default.Agent({
39
39
  pfx: Buffer.isBuffer(params.certificado) ? params.certificado : Buffer.from(params.certificado, "base64"),
40
- passphrase: params.senhaCertificado,
40
+ passphrase: params.senhaCertificado ? params.senhaCertificado : undefined,
41
41
  rejectUnauthorized: false,
42
42
  });
43
43
  }
@@ -61,6 +61,7 @@ class LhispOauthClient {
61
61
  this.tokenHeaderName = params.tokenHeaderName || lhisp_oauth_client_t_1.defaultTokenHeaderName;
62
62
  this.sendAuthCredentialsOnRequestBody = params.sendAuthCredentialsOnRequestBody;
63
63
  this.formatAccessToken = params.formatAccessToken;
64
+ this.timeout = params.timeout ? params.timeout : 60000;
64
65
  }
65
66
  getAuthHeaderValue() {
66
67
  return `Basic ${Buffer.from(`${this.clientId}:${this.clientSecret}`).toString("base64")}`;
@@ -99,6 +100,7 @@ class LhispOauthClient {
99
100
  httpsAgent: this.agent,
100
101
  headers: Object.assign({ [this.authHeaderName]: this.getAuthHeaderValue(), "Content-Type": this.authContentType }, this.authHeaders),
101
102
  data: Object.assign({}, this.authData),
103
+ timeout: this.timeout,
102
104
  };
103
105
  if (this.grantType)
104
106
  authRequestOpt.data.grant_type = this.grantType;
@@ -144,7 +146,7 @@ class LhispOauthClient {
144
146
  const headers = Object.assign({ "Content-Type": contentType, [this.tokenHeaderName]: this.getAuthToken() }, (this.headers || {}));
145
147
  const response = yield axios_1.default.request(Object.assign({ method, url: `${this.apiUrl}${path}`, httpsAgent: this.agent, headers,
146
148
  data,
147
- params }, opt));
149
+ params, timeout: this.timeout }, opt));
148
150
  return response.data;
149
151
  }
150
152
  catch (error) {
@@ -21,6 +21,7 @@ export interface LhispOauthClientConstructorParams {
21
21
  sendAuthCredentialsOnRequestBody?: boolean;
22
22
  formatAccessToken?: (accessToken?: AccessToken) => string;
23
23
  debug?: boolean;
24
+ timeout?: number;
24
25
  }
25
26
  export interface ExecutarRequestParams extends AxiosRequestConfig {
26
27
  path: string;