@oauth-spa-kit/server 2.2.0 → 2.3.0

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.
Files changed (2) hide show
  1. package/dist/handlers.js +10 -4
  2. package/package.json +2 -2
package/dist/handlers.js CHANGED
@@ -309,11 +309,17 @@ export function createLivenessHandler(config) {
309
309
  try {
310
310
  result = await getUserInfo(request, config);
311
311
  }
312
- catch (cause) {
312
+ catch {
313
+ // Any failure here -- a rejected refresh (TokenExchangeError) or the AS's
314
+ // userinfo_endpoint itself rejecting the access token (OAuthError, e.g. the session
315
+ // backing it was explicitly revoked server-side) -- means this session is dead. Clear
316
+ // the local cookie unconditionally rather than only for TokenExchangeError: leaving a
317
+ // known-dead cookie in place is only harmless because the default Nuxt/React wiring
318
+ // immediately redirects to a fresh login on `onSessionExpired`: a consumer that
319
+ // instead just shows a "session expired" message would otherwise keep sending a
320
+ // cookie doomed to fail every subsequent request.
313
321
  const headers = new Headers({ "content-type": "application/json" });
314
- if (cause instanceof TokenExchangeError) {
315
- headers.append("Set-Cookie", clearSessionHeader(config.session));
316
- }
322
+ headers.append("Set-Cookie", clearSessionHeader(config.session));
317
323
  return new Response(JSON.stringify({ alive: false }), { status: 401, headers });
318
324
  }
319
325
  if (!result) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@oauth-spa-kit/server",
3
- "version": "2.2.0",
3
+ "version": "2.3.0",
4
4
  "description": "BFF-pattern OAuth handlers: sealed HttpOnly-cookie sessions + login/callback/refresh/logout route factories, built on Web-standard Request/Response so they drop into Nitro, Next.js route handlers, Cloudflare Workers, or plain Node (via a small adapter).",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -22,7 +22,7 @@
22
22
  "node": ">=18"
23
23
  },
24
24
  "dependencies": {
25
- "@oauth-spa-kit/core": "2.2.0"
25
+ "@oauth-spa-kit/core": "2.3.0"
26
26
  },
27
27
  "devDependencies": {
28
28
  "typescript": "^5.6.0",