@seidor-cloud-produtos/orbit-backend-lib 0.0.41 → 0.0.43

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.
@@ -17,5 +17,6 @@ export default class Authorization extends APIAuthValidator {
17
17
  protected getRequestId(): string;
18
18
  protected handleAuthorized(): Promise<Response>;
19
19
  protected getAuthorizationsHeader(): string;
20
+ protected getAuthsHeader(): string;
20
21
  }
21
22
  export {};
@@ -20,5 +20,8 @@ class Authorization extends api_validator_1.APIAuthValidator {
20
20
  getAuthorizationsHeader() {
21
21
  return this.controller.request.headers.authorizations;
22
22
  }
23
+ getAuthsHeader() {
24
+ return this.controller.request.headers.auths;
25
+ }
23
26
  }
24
27
  exports.default = Authorization;
@@ -17,4 +17,5 @@ export default class AuthorizationExpress extends APIAuthValidator {
17
17
  ): Promise<Response<any, Record<string, any>>>;
18
18
  private setResponseHeaders;
19
19
  protected getAuthorizationsHeader(): string;
20
+ protected getAuthsHeader(): string;
20
21
  }
@@ -26,5 +26,8 @@ class AuthorizationExpress extends api_validator_1.APIAuthValidator {
26
26
  getAuthorizationsHeader() {
27
27
  return this.controller.request.headers.authorizations;
28
28
  }
29
+ getAuthsHeader() {
30
+ return this.controller.request.headers.auths;
31
+ }
29
32
  }
30
33
  exports.default = AuthorizationExpress;
@@ -14,4 +14,5 @@ export declare abstract class APIAuthValidator extends AuthValidator {
14
14
  protected abstract unauthorize(response: UnauthorizedResponse): any;
15
15
  protected abstract getRequestId(): string;
16
16
  protected abstract getAuthorizationsHeader(): string;
17
+ protected abstract getAuthsHeader(): string;
17
18
  }
@@ -24,9 +24,17 @@ class APIAuthValidator extends auth_validator_1.default {
24
24
  return this;
25
25
  }
26
26
  async getAuthorizations() {
27
- const authorizations = this.getAuthorizationsHeader();
27
+ const authorizations =
28
+ this.getAuthorizationsHeader() || this.getAuthsHeader();
28
29
  if (typeof authorizations === 'string') {
29
- return JSON.parse(authorizations);
30
+ try {
31
+ return JSON.parse(authorizations);
32
+ } catch (e) {
33
+ console.log('AuthorizationsHeader', this.getAuthorizationsHeader());
34
+ console.log('AuthsHeader', this.getAuthsHeader());
35
+ console.log('authorizations', authorizations);
36
+ return [];
37
+ }
30
38
  }
31
39
  return authorizations;
32
40
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@seidor-cloud-produtos/orbit-backend-lib",
3
- "version": "0.0.41",
3
+ "version": "0.0.43",
4
4
  "description": "Internal lib for backend components",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",