@wardenjs/ssr-logging
v0.2.0
Published
Security logging for Fetch-API servers: a redacting JSON logger, a security-event sink and an error boundary that hides internals.
Downloads
121
Maintainers
Readme
@wardenjs/ssr-logging
Part of warden's server track: security controls as decorators for any Fetch-API handler (Next.js route handlers, Hono, Bun, Deno, Workers). Here SSR means server side, not server-side rendering.
Structured logging with redaction, and the request-level error boundary.
npm i @wardenjs/ssr @wardenjs/ssr-loggingimport { createLogger, requestLogger } from '@wardenjs/ssr-logging';
export const logger = createLogger({ fields: { service: 'api' } });
const api = chain().use(secureHeaders()).use(requestLogger(logger));
export const GET = api.handle(async (_r, { log }) => {
log.info('listing posts');
return Response.json(await list());
});
// Audit every plugin through one place:
const session = sessions({ secret, issuer, onEvent: logger.event });- Redacts secrets by key at any depth (
password,userPassword,x-api-key,refresh_token, …), bounded in depth, breadth and length, cycle-safe. - Messages are single-line, so input cannot forge a log entry.
requestLoggeraddslogandrequestId, setsX-Request-Id, and turns unexpected errors into an opaque 500 that carries only the id.eventlogs the client IP truncated to /24 or /48.- Default sink: one JSON line on stdout/stderr. Pass
sinkfor anything else.
