lhisp-oauth-client 1.0.21 → 1.0.23

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.21",
3
+ "version": "1.0.23",
4
4
  "main": "src/index",
5
5
  "types": "src/index.d.ts",
6
6
  "repository": "git@bitbucket.org:leandro_costa/lhisp-oauth-client.git",
@@ -22,7 +22,7 @@ export declare class LhispOauthClient<iAccessToken extends AccessToken = AccessT
22
22
  protected tokenCreatedAt: number;
23
23
  protected tokenExpiresIn: number;
24
24
  protected sendAuthCredentialsOnRequestBody?: boolean;
25
- protected forceTokenTypeToCamelCase?: boolean;
25
+ protected formatAccessToken?: (accessToken?: iAccessToken) => string;
26
26
  constructor(params: LhispOauthClientConstructorParams);
27
27
  getAuthHeaderValue(): string;
28
28
  parseData({ data, contentType }: {
@@ -46,6 +46,7 @@ class LhispOauthClient {
46
46
  this.authHeaderName = params.authHeaderName || lhisp_oauth_client_t_1.defaultAuthHeaderName;
47
47
  this.tokenHeaderName = params.tokenHeaderName || lhisp_oauth_client_t_1.defaultTokenHeaderName;
48
48
  this.sendAuthCredentialsOnRequestBody = params.sendAuthCredentialsOnRequestBody;
49
+ this.formatAccessToken = params.formatAccessToken;
49
50
  }
50
51
  getAuthHeaderValue() {
51
52
  return `Basic ${Buffer.from(`${this.clientId}:${this.clientSecret}`).toString("base64")}`;
@@ -118,11 +119,11 @@ class LhispOauthClient {
118
119
  return data;
119
120
  }
120
121
  getAuthToken() {
121
- var _a, _b, _c, _d, _e, _f, _g;
122
- const tokenType = this.forceTokenTypeToCamelCase
123
- ? `${(_c = (_b = (_a = this.accessToken) === null || _a === void 0 ? void 0 : _a.token_type) === null || _b === void 0 ? void 0 : _b[0]) === null || _c === void 0 ? void 0 : _c.toUpperCase()}${(_e = (_d = this.accessToken) === null || _d === void 0 ? void 0 : _d.token_type) === null || _e === void 0 ? void 0 : _e.substring(1)}`
124
- : (_f = this.accessToken) === null || _f === void 0 ? void 0 : _f.token_type;
125
- return `${tokenType} ${(_g = this.accessToken) === null || _g === void 0 ? void 0 : _g.access_token}`;
122
+ var _a, _b;
123
+ if (this.formatAccessToken) {
124
+ return this.formatAccessToken(this.accessToken);
125
+ }
126
+ return `${(_a = this.accessToken) === null || _a === void 0 ? void 0 : _a.token_type} ${(_b = this.accessToken) === null || _b === void 0 ? void 0 : _b.access_token}`;
126
127
  }
127
128
  executarRequest({ method, path, data, params, contentType = lhisp_oauth_client_t_1.ContentType.APPLICATION_JSON, }) {
128
129
  return __awaiter(this, void 0, void 0, function* () {
@@ -17,7 +17,7 @@ export interface LhispOauthClientConstructorParams {
17
17
  grantType?: string;
18
18
  authContentType?: ContentType;
19
19
  sendAuthCredentialsOnRequestBody?: boolean;
20
- forceTokenTypeToCamelCase?: boolean;
20
+ formatAccessToken?: (accessToken?: AccessToken) => string;
21
21
  debug?: boolean;
22
22
  }
23
23
  export interface ExecutarRequestParams extends AxiosRequestConfig {