@lacspace/redact
Redact secrets & PII from strings and objects before logging — masks sensitive keys and patterns (JWTs, API keys, emails, cards, IPs). Safe AWS/Mongo logs. Zero-dependency, isomorphic.
npm i @lacspace/redactUsage
import { redact, redactString, createRedactor } from "@lacspace/redact";
redact({
email: "jane@example.com",
password: "hunter2",
headers: { authorization: "Bearer eyJhbG.eyJz.sig" },
card: "4242 4242 4242 4242",
});
// { email: "j•••@example.com", password: "[REDACTED]",
// headers: { authorization: "[REDACTED]" }, card: "[REDACTED]" }
redactString("token=eyJhbG.eyJz.sig for user a@b.com");
// "token=[REDACTED_JWT] for user a•••@b.com"
// bind once, use as a logger serializer
const scrub = createRedactor({ keys: ["x-internal-token"] });
logger.info(scrub(requestContext));Exports 6
SENSITIVE_KEYScreateRedactormaskEmailmaskStringredactredactStringKeywords
More in Security Kit
Issue & verify API keys the right way — prefixed high-entropy keys, store only the SHA-256 hash, constant-time verify, last-4 display. Isomorphic over Web Crypto.
@lacspace/cryptoSafe, boring cryptography over Web Crypto — authenticated AES-256-GCM, PBKDF2 key derivation, SHA-256, HMAC, secure random and constant-time compare. Isomorphic (Node, edge, browser, RN).
@lacspace/headersSecure HTTP headers & a typed Content-Security-Policy builder — HSTS, X-Frame-Options, Referrer-Policy, Permissions-Policy. Framework-agnostic + Next.js. Zero-dependency, isomorphic.
@lacspace/jwtJSON Web Tokens (HS256/384/512) with strict expiry/issuer/audience checks + secure random & CSRF tokens. Isomorphic over Web Crypto — Node, edge, browser.
@lacspace/lockAccount lockout & brute-force protection (server lock) — N-strikes, exponential backoff, self-resetting window, pluggable store. Zero-dependency, isomorphic.
@lacspace/mfaOrchestrate multi-factor auth — combine password + TOTP + passkeys into 2FA/3FA step-up flows with NIST assurance levels (AAL). Zero-dependency (bar @lacspace/otp), isomorphic.