@lucaapp/service-utils 1.2.2 → 1.2.3

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.
@@ -7,10 +7,11 @@ declare class ServiceIdentity {
7
7
  readonly identityKid: string;
8
8
  private readonly identityPrivateKey;
9
9
  private readonly identityPublicKey;
10
+ private readonly debug;
10
11
  private readonly jwksCache;
11
12
  private readonly keyCache;
12
13
  private readonly axiosClient;
13
- constructor(identityName: string, identityKid: string, identityPrivateKey: string, identityPublicKey: string);
14
+ constructor(identityName: string, identityKid: string, identityPrivateKey: string, identityPublicKey: string, debug?: boolean);
14
15
  getRemoteJWKS: (service: string) => import("jose/dist/types/types").GetKeyFunction<jose.JWSHeaderParameters, jose.FlattenedJWSInput>;
15
16
  private getJwtVerifyOptions;
16
17
  getIdentityPublicKey: () => Promise<jose.KeyLike>;
@@ -39,7 +39,7 @@ const JWT_NBF = '0s';
39
39
  const JWT_EXP = '1m';
40
40
  const JWT_CLOCK_TOLERANCE = moment_1.default.duration(1, 'minute').asSeconds();
41
41
  class ServiceIdentity {
42
- constructor(identityName, identityKid, identityPrivateKey, identityPublicKey) {
42
+ constructor(identityName, identityKid, identityPrivateKey, identityPublicKey, debug = false) {
43
43
  this.jwksCache = {};
44
44
  this.keyCache = {};
45
45
  this.getRemoteJWKS = (service) => {
@@ -120,7 +120,16 @@ class ServiceIdentity {
120
120
  this.identityKid = identityKid;
121
121
  this.identityPrivateKey = identityPrivateKey;
122
122
  this.identityPublicKey = identityPublicKey;
123
+ this.debug = debug;
123
124
  this.axiosClient = axios_1.default.create({ proxy: false });
125
+ if (!debug) {
126
+ this.axiosClient.interceptors.response.use(response => response, error => {
127
+ if (error.config.headers.contains(JWT_HEADER_NAME)) {
128
+ delete error.config.headers[JWT_HEADER_NAME];
129
+ }
130
+ return Promise.reject(error);
131
+ });
132
+ }
124
133
  }
125
134
  }
126
135
  exports.ServiceIdentity = ServiceIdentity;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lucaapp/service-utils",
3
- "version": "1.2.2",
3
+ "version": "1.2.3",
4
4
  "main": "dist/index.js",
5
5
  "types": "dist/index.d.ts",
6
6
  "files": [