lhisp-oauth-client 1.0.36 → 1.0.37

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.36",
3
+ "version": "1.0.37",
4
4
  "main": "src/index",
5
5
  "types": "src/index.d.ts",
6
6
  "repository": {
@@ -12,6 +12,7 @@
12
12
  "scripts": {
13
13
  "build": "tsc",
14
14
  "test": "jest",
15
+ "publish": "rm -rfv dist/; npm run build; cd dist; cp ../package* .; npm publish; cd -; rm -rfv dist/;",
15
16
  "test:watch": "jest --watchAll"
16
17
  },
17
18
  "devDependencies": {
@@ -22,7 +23,6 @@
22
23
  "typescript": "^5.8.3"
23
24
  },
24
25
  "dependencies": {
25
- "axios": "^1.10.0",
26
- "lhisp-logger": "^2.2.2"
26
+ "axios": "^1.10.0"
27
27
  }
28
28
  }
@@ -24,6 +24,7 @@ export declare class LhispOauthClient<iAccessToken extends AccessToken = AccessT
24
24
  protected sendAuthCredentialsOnRequestBody?: boolean;
25
25
  protected timeout: number;
26
26
  protected formatAccessToken?: (accessToken?: iAccessToken) => string;
27
+ private logger;
27
28
  constructor(params: LhispOauthClientConstructorParams);
28
29
  getAuthHeaderValue(): string;
29
30
  parseData({ data, contentType }: {
@@ -26,10 +26,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
26
26
  exports.LhispOauthClient = void 0;
27
27
  const axios_1 = __importDefault(require("axios"));
28
28
  const https_1 = __importDefault(require("https"));
29
- const lhisp_logger_1 = __importDefault(require("lhisp-logger"));
30
29
  const querystring_1 = __importDefault(require("querystring"));
31
30
  const lhisp_oauth_client_t_1 = require("./lhisp-oauth-client.t");
32
- const logger = (0, lhisp_logger_1.default)({ name: "lhisp-oauth-client" });
33
31
  class LhispOauthClient {
34
32
  constructor(params) {
35
33
  this.authData = {};
@@ -63,6 +61,7 @@ class LhispOauthClient {
63
61
  this.sendAuthCredentialsOnRequestBody = params.sendAuthCredentialsOnRequestBody;
64
62
  this.formatAccessToken = params.formatAccessToken;
65
63
  this.timeout = params.timeout ? params.timeout : 60000;
64
+ this.logger = params.logger || consoleLogger;
66
65
  }
67
66
  getAuthHeaderValue() {
68
67
  return `Basic ${Buffer.from(`${this.clientId}:${this.clientSecret}`).toString("base64")}`;
@@ -119,7 +118,7 @@ class LhispOauthClient {
119
118
  });
120
119
  const resp = yield axios_1.default.request(authRequestOpt);
121
120
  if (!(resp === null || resp === void 0 ? void 0 : resp.data)) {
122
- logger.error({ message: "LhispOauthClient.getAccessToken", resp });
121
+ this.logger.error({ message: "LhispOauthClient.getAccessToken", resp });
123
122
  throw new Error("Resposta inválida ao obter token de acesso.");
124
123
  }
125
124
  this.accessToken = this.buildAccessToken(resp.data);
@@ -128,7 +127,7 @@ class LhispOauthClient {
128
127
  return this.accessToken;
129
128
  }
130
129
  catch (error) {
131
- logger.error({ message: "LhispOauthClient.getAccessToken", error });
130
+ this.logger.error({ message: "LhispOauthClient.getAccessToken", error });
132
131
  throw error;
133
132
  }
134
133
  });
@@ -158,7 +157,7 @@ class LhispOauthClient {
158
157
  return response.data;
159
158
  }
160
159
  catch (error) {
161
- logger.error({
160
+ this.logger.error({
162
161
  message: "LhispOauthClient.executarRequest",
163
162
  method,
164
163
  url: `${this.apiUrl}${path}`,
@@ -198,3 +197,4 @@ class LhispOauthClient {
198
197
  }
199
198
  }
200
199
  exports.LhispOauthClient = LhispOauthClient;
200
+ const consoleLogger = Object.assign(Object.assign({}, console), { child: () => consoleLogger });
@@ -1,4 +1,11 @@
1
1
  import { AxiosRequestConfig } from "axios";
2
+ export interface Logger {
3
+ child: (params: any) => Logger;
4
+ info: Console["info"];
5
+ warn: Console["warn"];
6
+ error: Console["error"];
7
+ debug: Console["debug"];
8
+ }
2
9
  export interface Headers {
3
10
  [name: string]: any;
4
11
  }
@@ -21,6 +28,7 @@ export interface LhispOauthClientConstructorParams {
21
28
  formatAccessToken?: (accessToken?: AccessToken) => string;
22
29
  debug?: boolean;
23
30
  timeout?: number;
31
+ logger?: Logger;
24
32
  }
25
33
  export interface ExecutarRequestParams extends AxiosRequestConfig {
26
34
  path: string;