Redacted
The Redacted module provides functionality for handling sensitive information securely within your application. By using the Redacted data type, you can ensure that sensitive values are not accidentally exposed in logs or error messages.
Constructors
Equivalence
getEquivalence
Added in v3.3.0
Source
Generates an equivalence relation for Redacted<A> values based on an equivalence relation for the underlying values A. This function is useful for comparing Redacted instances without exposing their contents.
Signature
declare function getEquivalence<A>(isEquivalent: Equivalence<A>): Equivalence<Redacted<A>>;Getters
Retrieves the original value from a Redacted instance. Use this function with caution, as it exposes the sensitive data.
Signature
declare const value: <A>(self: Redacted<A>) => A;Example
import * as assert from "node:assert"
import { Redacted } from "effect"
const API_KEY = Redacted.make("1234567890")
assert.equal(Redacted.value(API_KEY), "1234567890")Models
Other
Refinements
isRedacted
Added in v3.3.0
Source
Signature
declare const isRedacted: (u: unknown) => u is Redacted<unknown>;Symbols
RedactedTypeId
Added in v3.3.0
Source
Signature
declare const RedactedTypeId: unique symbol;RedactedTypeId type
Added in v3.3.0
Source
Signature
type RedactedTypeId = typeof RedactedTypeId;Unsafe
unsafeWipe
Added in v3.3.0
Source
Erases the underlying value of a Redacted instance, rendering it unusable. This function is intended to ensure that sensitive data does not remain in memory longer than necessary.
Signature
declare const unsafeWipe: <A>(self: Redacted<A>) => boolean;Example
import * as assert from "node:assert"
import { Redacted } from "effect"
const API_KEY = Redacted.make("1234567890")
assert.equal(Redacted.value(API_KEY), "1234567890")
Redacted.unsafeWipe(API_KEY)
assert.throws(() => Redacted.value(API_KEY), new Error("Unable to get redacted value"))
This function creates a
Redacted<A>instance from a given valueA, securely hiding its content.