@kronos-integration/service-authenticator 4.1.1 → 4.1.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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kronos-integration/service-authenticator",
3
- "version": "4.1.1",
3
+ "version": "4.1.3",
4
4
  "publishConfig": {
5
5
  "access": "public",
6
6
  "provenance": true
@@ -31,7 +31,7 @@
31
31
  },
32
32
  "dependencies": {
33
33
  "@kronos-integration/endpoint": "^11.0.5",
34
- "@kronos-integration/service": "^15.1.2",
34
+ "@kronos-integration/service": "^15.1.3",
35
35
  "jsonwebtoken": "^9.0.3"
36
36
  },
37
37
  "devDependencies": {
@@ -5,7 +5,8 @@ import {
5
5
  default_attribute,
6
6
  public_key_attribute,
7
7
  private_key_attribute,
8
- object_attribute
8
+ object_attribute,
9
+ duration_ms_attribute
9
10
  } from "pacc";
10
11
  import { Service } from "@kronos-integration/service";
11
12
 
@@ -60,15 +61,17 @@ export class ServiceAuthenticator extends Service {
60
61
  }
61
62
  },
62
63
  access_token: {
64
+ ...object_attribute,
63
65
  attributes: {
64
66
  algorithm,
65
- expiresIn: { default: "1h", type: "duration" }
67
+ expiresIn: { ...duration_ms_attribute, default: "1h" }
66
68
  }
67
69
  },
68
70
  refresh_token: {
71
+ ...object_attribute,
69
72
  attributes: {
70
73
  algorithm,
71
- expiresIn: { default: "90d", type: "duration" }
74
+ expiresIn: { ...duration_ms_attribute, default: "90d" }
72
75
  }
73
76
  }
74
77
  }
@@ -91,7 +94,10 @@ export class ServiceAuthenticator extends Service {
91
94
  };
92
95
  }
93
96
 
94
- async configure(config) {
97
+ async _configure(config) {
98
+ // TODO automatically read credentials
99
+ config.jwt ||= {};
100
+
95
101
  const credentials = await this.getCredentials();
96
102
  if (credentials["jwt.private"]) {
97
103
  config.jwt.private = credentials["jwt.private"];
@@ -99,7 +105,7 @@ export class ServiceAuthenticator extends Service {
99
105
  if (credentials["jwt.public"]) {
100
106
  config.jwt.public = credentials["jwt.public"];
101
107
  }
102
- return super.configure(config);
108
+ return super._configure(config);
103
109
  }
104
110
 
105
111
  /**
@@ -179,7 +185,7 @@ export class ServiceAuthenticator extends Service {
179
185
  };
180
186
  return {
181
187
  token_type: "Bearer",
182
- expires_in: j.access_token.expiresIn,
188
+ expires_in: j.access_token.expiresIn / 1000,
183
189
  access_token: jwt.sign(claims, j.private, j.access_token),
184
190
  refresh_token: jwt.sign(refreshClaims, j.private, j.refresh_token)
185
191
  };