lhisp-oauth-client 1.0.35 → 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.35",
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": "^1.0.16"
26
+ "axios": "^1.10.0"
27
27
  }
28
28
  }
@@ -1,5 +1,5 @@
1
- import https from "https";
2
1
  import { AxiosHeaders } from "axios";
2
+ import https from "https";
3
3
  import { AccessToken, ContentType, ExecutarRequestParams, LhispOauthClientConstructorParams } from "./lhisp-oauth-client.t";
4
4
  export declare class LhispOauthClient<iAccessToken extends AccessToken = AccessToken> {
5
5
  protected authUrl: string;
@@ -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 }: {
@@ -24,11 +24,10 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
24
24
  };
25
25
  Object.defineProperty(exports, "__esModule", { value: true });
26
26
  exports.LhispOauthClient = void 0;
27
- const querystring_1 = __importDefault(require("querystring"));
28
- const https_1 = __importDefault(require("https"));
29
27
  const axios_1 = __importDefault(require("axios"));
28
+ const https_1 = __importDefault(require("https"));
29
+ const querystring_1 = __importDefault(require("querystring"));
30
30
  const lhisp_oauth_client_t_1 = require("./lhisp-oauth-client.t");
31
- const lhisp_logger_1 = __importDefault(require("lhisp-logger"));
32
31
  class LhispOauthClient {
33
32
  constructor(params) {
34
33
  this.authData = {};
@@ -62,6 +61,7 @@ class LhispOauthClient {
62
61
  this.sendAuthCredentialsOnRequestBody = params.sendAuthCredentialsOnRequestBody;
63
62
  this.formatAccessToken = params.formatAccessToken;
64
63
  this.timeout = params.timeout ? params.timeout : 60000;
64
+ this.logger = params.logger || consoleLogger;
65
65
  }
66
66
  getAuthHeaderValue() {
67
67
  return `Basic ${Buffer.from(`${this.clientId}:${this.clientSecret}`).toString("base64")}`;
@@ -118,7 +118,7 @@ class LhispOauthClient {
118
118
  });
119
119
  const resp = yield axios_1.default.request(authRequestOpt);
120
120
  if (!(resp === null || resp === void 0 ? void 0 : resp.data)) {
121
- lhisp_logger_1.default.error({ message: "LhispOauthClient.getAccessToken", resp });
121
+ this.logger.error({ message: "LhispOauthClient.getAccessToken", resp });
122
122
  throw new Error("Resposta inválida ao obter token de acesso.");
123
123
  }
124
124
  this.accessToken = this.buildAccessToken(resp.data);
@@ -127,7 +127,7 @@ class LhispOauthClient {
127
127
  return this.accessToken;
128
128
  }
129
129
  catch (error) {
130
- lhisp_logger_1.default.error({ message: "LhispOauthClient.getAccessToken", error });
130
+ this.logger.error({ message: "LhispOauthClient.getAccessToken", error });
131
131
  throw error;
132
132
  }
133
133
  });
@@ -157,7 +157,7 @@ class LhispOauthClient {
157
157
  return response.data;
158
158
  }
159
159
  catch (error) {
160
- lhisp_logger_1.default.error({
160
+ this.logger.error({
161
161
  message: "LhispOauthClient.executarRequest",
162
162
  method,
163
163
  url: `${this.apiUrl}${path}`,
@@ -197,3 +197,4 @@ class LhispOauthClient {
197
197
  }
198
198
  }
199
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;