style(13-03): apply Prettier formatting across repo
Mechanical reformat — no logic changes. 398 files changed, 19125 insertions(+), 16457 deletions(-). Prettier 3.8.4 with .prettierrc (singleQuote:true, semi:true, tabWidth:2, trailingComma:all, printWidth:100). Isolated per D-13-08 for reviewability.
This commit is contained in:
@@ -21,8 +21,8 @@
|
||||
* cookie only when the library produced a valid session this request.
|
||||
*/
|
||||
|
||||
import type { MiddlewareHandler } from 'hono'
|
||||
import { setCookie } from 'hono/cookie'
|
||||
import type { MiddlewareHandler } from 'hono';
|
||||
import { setCookie } from 'hono/cookie';
|
||||
|
||||
/**
|
||||
* Returns a Hono MiddlewareHandler that upgrades the session-scoped oidc-auth cookie
|
||||
@@ -37,7 +37,7 @@ export function persistSessionCookie(): MiddlewareHandler {
|
||||
// The 'as never' cast is required because 'oidcAuthJwt' is a library-internal key
|
||||
// that is not declared in Hono's ContextVariableMap — mirrors the loose-context
|
||||
// convention used elsewhere in this codebase (e.g. resolveUserId).
|
||||
const jwt = c.get('oidcAuthJwt' as never) as string | undefined
|
||||
const jwt = c.get('oidcAuthJwt' as never) as string | undefined;
|
||||
|
||||
// CRITICAL CORRECTNESS GUARD: if no valid session JWT is on context (logged-out,
|
||||
// deleted, or never-set request), do NOT touch cookies and fall straight through.
|
||||
@@ -45,16 +45,16 @@ export function persistSessionCookie(): MiddlewareHandler {
|
||||
// logged-out user would receive a new oidc-auth Set-Cookie with no value, which
|
||||
// could re-authenticate them or produce confusing browser state.
|
||||
if (!jwt) {
|
||||
await next()
|
||||
return
|
||||
await next();
|
||||
return;
|
||||
}
|
||||
|
||||
// A valid session JWT is present — re-issue the cookie BEFORE next() so that if
|
||||
// any future downstream handler deletes the cookie, that delete Set-Cookie header
|
||||
// comes last and wins (safe ordering even without a current logout/revoke route).
|
||||
const name = process.env.OIDC_COOKIE_NAME ?? 'oidc-auth'
|
||||
const path = process.env.OIDC_COOKIE_PATH ?? '/'
|
||||
const maxAge = Number(process.env.OIDC_AUTH_EXPIRES ?? 86400)
|
||||
const name = process.env.OIDC_COOKIE_NAME ?? 'oidc-auth';
|
||||
const path = process.env.OIDC_COOKIE_PATH ?? '/';
|
||||
const maxAge = Number(process.env.OIDC_AUTH_EXPIRES ?? 86400);
|
||||
|
||||
// Build the options object. domain is included ONLY when OIDC_COOKIE_DOMAIN is set —
|
||||
// mirroring the library's own conditional-domain logic so the two Set-Cookie headers
|
||||
@@ -66,15 +66,15 @@ export function persistSessionCookie(): MiddlewareHandler {
|
||||
secure: true,
|
||||
sameSite: 'Lax',
|
||||
maxAge, // seconds — Hono's setCookie maxAge unit matches OIDC_AUTH_EXPIRES unit
|
||||
}
|
||||
};
|
||||
|
||||
if (process.env.OIDC_COOKIE_DOMAIN) {
|
||||
options.domain = process.env.OIDC_COOKIE_DOMAIN
|
||||
options.domain = process.env.OIDC_COOKIE_DOMAIN;
|
||||
}
|
||||
|
||||
// Re-issue the same JWT the library signed. Do NOT re-sign or modify the payload.
|
||||
setCookie(c, name, jwt, options)
|
||||
setCookie(c, name, jwt, options);
|
||||
|
||||
await next()
|
||||
}
|
||||
await next();
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user