10·01Redacted

`Redacted.make` wraps sensitive values so ordinary string conversion and inspection do not reveal them. Call `Redacted.value` only at the narrow integration point that must use the secret. V4 exposes `Redacted.wipeUnsafe` for exceptional cases that require bes

56 — Redacted secrets

Redacted.make wraps sensitive values so ordinary string conversion and inspection do not reveal them. Call Redacted.value only at the narrow integration point that must use the secret. V4 exposes Redacted.wipeUnsafe for exceptional cases that require best-effort erasure.

Use Config.redacted when loading secrets and avoid putting the unwrapped value into logs, errors, spans, metrics, or long-lived application state.


The full test suite

The index.test.ts for this lesson, verbatim from steps/56-redacted/.

index.test.ts
import { describe, expect, it } from "vite-plus/test"
import { Redacted } from "effect"
describe("Redacted", () => {
it("does not reveal secrets through string conversion", () => {
const secret = Redacted.make("super-secret")
expect(String(secret)).not.toContain("super-secret")
expect(Redacted.value(secret)).toBe("super-secret")
})
it("supports explicit equivalence without exposing values", () => {
const equivalent = Redacted.makeEquivalence<string>((a, b) => a === b)
expect(equivalent(Redacted.make("same"), Redacted.make("same"))).toBe(true)
})
})
← PreviousUse PatternNext →HTTP Client Patterns