node-cooper - v0.2.0
    Preparing search index...

    Class default

    Wraps a secret value (CASC.md §4.3's *key-prefixed keys) in the result loadFile/loadString return, so it never leaks by accident: String(secret), template literals, JSON.stringify, and util.inspect/console.log all render the redacted text regardless of the wrapped value. Reach the real value deliberately via reveal() (or the value property) -- redaction is only ever a display-time concern, never a barrier to the application's own deliberate use of the value.

    Mirrors Cooper.Secret. One JS-specific hardening on top: value is a non-enumerable property, so object spread, Object.keys, structuredClone, and logging libraries that walk enumerable keys don't copy the real value out either.

    A secret embedded inside a larger interpolated string ("postgres://user:%{database.password}@host") redacts only the embedded portion -- the result displays as "postgres://user:[~~REDACTED~~]@host", each secret at its own position. redacted carries that precomputed display text; null (an ordinary whole-value secret) falls back to the blanket [~~REDACTED~~] marker. Either way value/reveal() give back the real, fully unmasked value.

    Index
    redacted: string | null

    Display text for a partially redacted string, or null for a whole-value secret.

    value: unknown
    REDACTED: string
    • Parameters

      • _depth: number
      • options: object
      • inspect: (value: unknown, options: object) => string

      Returns string

    • Unwraps value if it is a Secret, returning anything else unchanged -- handy for code that accepts either.

      Parameters

      • value: unknown

      Returns unknown