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>>Example
import * as assert from "node:assert"import { Redacted, Equivalence } from "effect"
const API_KEY1 = Redacted.make("1234567890")const API_KEY2 = Redacted.make("1-34567890")const API_KEY3 = Redacted.make("1234567890")
const equivalence = Redacted.getEquivalence(Equivalence.string)
assert.equal(equivalence(API_KEY1, API_KEY2), false)assert.equal(equivalence(API_KEY1, API_KEY3), true)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>) => AExample
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 symbolRedactedTypeId type
Added in v3.3.0
Source
Signature
type RedactedTypeId = typeof RedactedTypeIdUnsafe
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>) => booleanExample
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"))