@jskit-ai/oidc-issuer-core 0.1.19 → 0.1.20

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": "@jskit-ai/oidc-issuer-core",
3
- "version": "0.1.19",
3
+ "version": "0.1.20",
4
4
  "type": "module",
5
5
  "scripts": {
6
6
  "test": "jskit test"
@@ -113,16 +113,16 @@
113
113
  }
114
114
  },
115
115
  "dependencies": {
116
- "@jskit-ai/database-runtime": "0.1.260",
116
+ "@jskit-ai/database-runtime": "0.1.261",
117
117
  "jose": "6.2.12",
118
118
  "knex": "^3.1.0",
119
119
  "nodemailer": "10.2.1",
120
120
  "oidc-provider": "9.12.2"
121
121
  },
122
122
  "devDependencies": {
123
- "@jskit-ai/auth-provider-local-core": "0.2.14"
123
+ "@jskit-ai/auth-provider-local-core": "0.2.15"
124
124
  },
125
125
  "peerDependencies": {
126
- "@jskit-ai/kernel": "0.2.11"
126
+ "@jskit-ai/kernel": "0.2.12"
127
127
  }
128
128
  }
@@ -2,7 +2,7 @@
2
2
  "private": true,
3
3
  "type": "module",
4
4
  "dependencies": {
5
- "@jskit-ai/database-runtime-mysql": "0.1.258",
6
- "@jskit-ai/oidc-issuer-core": "0.1.19"
5
+ "@jskit-ai/database-runtime-mysql": "0.1.259",
6
+ "@jskit-ai/oidc-issuer-core": "0.1.20"
7
7
  }
8
8
  }
@@ -30,13 +30,6 @@ function sendRegistrationError(reply, error) {
30
30
  });
31
31
  }
32
32
 
33
- /** Keeps the hub's own client rows in step once oidc-provider has answered with `status`. */
34
- function onProviderStatus(reply, matches, action) {
35
- reply.raw.once("finish", () => {
36
- if (matches(reply.raw.statusCode)) action().catch(() => {});
37
- });
38
- }
39
-
40
33
  function parseJsonBody(buffer) {
41
34
  try {
42
35
  return JSON.parse(Buffer.isBuffer(buffer) ? buffer.toString("utf8") : String(buffer || ""));
@@ -85,6 +78,19 @@ async function createOidcIssuer({
85
78
  });
86
79
  const { clients } = hub;
87
80
  let timer = null;
81
+ // Client row writes that follow a sent response; close() waits for them, so they finish before the database closes.
82
+ const followUps = new Set();
83
+
84
+ /** Keeps the hub's own client rows in step once oidc-provider has answered with `status`. */
85
+ function onProviderStatus(reply, matches, action) {
86
+ reply.raw.once("finish", () => {
87
+ if (!matches(reply.raw.statusCode)) return;
88
+ const write = action()
89
+ .catch((error) => logger.warn({ err: error }, "The hub could not keep its client row in step with a registration change."))
90
+ .finally(() => followUps.delete(write));
91
+ followUps.add(write);
92
+ });
93
+ }
88
94
 
89
95
  function forwardToProvider(request, reply) {
90
96
  const issuer = new URL(config.issuer);
@@ -184,6 +190,7 @@ async function createOidcIssuer({
184
190
  async function close() {
185
191
  if (timer) clearInterval(timer);
186
192
  timer = null;
193
+ await Promise.all(followUps);
187
194
  }
188
195
 
189
196
  return Object.freeze({