@kimjay112/cipherwire-node
v0.1.0
Published
Cipherwire middleware for Node.js (Express, NestJS, Connect): decrypts request bodies, encrypts responses and streams request logs to the dashboard without blocking.
Maintainers
Readme
@kimjay112/cipherwire-node
Middleware for Express, NestJS and Connect. It decrypts Cipherwire request bodies, encrypts responses and streams redacted request logs to your Cipherwire dashboard without blocking requests.
import { cipherwire, cipherwireErrorHandler } from '@kimjay112/cipherwire-node';
app.use(express.json());
app.use(cipherwire({
secretKey: process.env.CIPHERWIRE_SECRET_KEY!,
required: false, // true → reject unencrypted requests
exclude: (req) => req.url === '/health',
logging: {
endpoint: process.env.CIPHERWIRE_ENDPOINT, // default http://localhost:4000
sampleRate: 1, // errors are always logged
redactKeys: ['dob', /^x-internal/],
captureBodies: true,
},
}));
app.use(cipherwireErrorHandler());NestJS: add app.use(cipherwire({ secretKey })) in main.ts. Call recordError(res, exception) from an exception filter to attach stack traces to log entries.
CORS: allow the x-cipherwire request header. The cors package does this by default. The middleware exposes the response headers itself.
